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:
-rw-r--r--CMakeLists.txt39
-rw-r--r--build_files/buildbot/config/blender_linux.cmake3
-rw-r--r--build_files/buildbot/config/blender_linux_player.cmake12
-rw-r--r--build_files/buildbot/slave_compile.py10
-rw-r--r--build_files/buildbot/slave_pack.py3
-rw-r--r--build_files/cmake/config/blender_full.cmake2
-rw-r--r--build_files/cmake/config/blender_headless.cmake1
-rw-r--r--build_files/cmake/config/blender_lite.cmake1
-rw-r--r--build_files/cmake/config/blender_release.cmake2
-rw-r--r--build_files/cmake/config/bpy_module.cmake3
-rw-r--r--build_files/cmake/config/cycles_standalone.cmake1
-rw-r--r--build_files/cmake/macros.cmake5
-rw-r--r--doc/doxygen/doxygen.source.h60
-rw-r--r--doc/python_api/examples/bge.constraints.py37
-rw-r--r--doc/python_api/examples/bge.texture.1.py40
-rw-r--r--doc/python_api/examples/bge.texture.2.py237
-rw-r--r--doc/python_api/examples/bge.texture.py46
-rw-r--r--doc/python_api/examples/blf.py49
-rw-r--r--doc/python_api/rst/bge.app.rst49
-rw-r--r--doc/python_api/rst/bge.constraints.rst336
-rw-r--r--doc/python_api/rst/bge.events.rst250
-rw-r--r--doc/python_api/rst/bge.logic.rst1407
-rw-r--r--doc/python_api/rst/bge.render.rst425
-rw-r--r--doc/python_api/rst/bge.texture.rst1557
-rw-r--r--doc/python_api/rst/bge.types.rst38
-rw-r--r--doc/python_api/rst/bge_types/bge.types.BL_ActionActuator.rst78
-rw-r--r--doc/python_api/rst/bge_types/bge.types.BL_ArmatureActuator.rst61
-rw-r--r--doc/python_api/rst/bge_types/bge.types.BL_ArmatureBone.rst105
-rw-r--r--doc/python_api/rst/bge_types/bge.types.BL_ArmatureChannel.rst278
-rw-r--r--doc/python_api/rst/bge_types/bge.types.BL_ArmatureConstraint.rst129
-rw-r--r--doc/python_api/rst/bge_types/bge.types.BL_ArmatureObject.rst34
-rw-r--r--doc/python_api/rst/bge_types/bge.types.BL_Shader.rst230
-rw-r--r--doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst70
-rw-r--r--doc/python_api/rst/bge_types/bge.types.CListValue.rst72
-rw-r--r--doc/python_api/rst/bge_types/bge.types.CPropValue.rst11
-rw-r--r--doc/python_api/rst/bge_types/bge.types.CValue.rst17
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_ArmatureSensor.rst36
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_BlenderMaterial.rst185
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_Camera.rst302
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_CameraActuator.rst47
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst45
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_ConstraintActuator.rst78
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_ConstraintWrapper.rst143
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_FontObject.rst32
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_GameActuator.rst23
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst1013
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_LibLoadStatus.rst51
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_LightObject.rst164
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_MeshProxy.rst134
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_MouseActuator.rst103
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_MouseFocusSensor.rst83
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_NavMeshObject.rst47
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_NearSensor.rst23
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageActuator.rst35
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageSensor.rst38
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst129
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_ParentActuator.rst38
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_PolyProxy.rst139
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_RadarSensor.rst44
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst78
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_SCA_AddObjectActuator.rst55
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_SCA_DynamicActuator.rst29
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_SCA_EndObjectActuator.rst13
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_SCA_ReplaceMeshActuator.rst89
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_Scene.rst186
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_SceneActuator.rst49
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_SoundActuator.rst115
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_StateActuator.rst29
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_SteeringActuator.rst71
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst47
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_TrackToActuator.rst61
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_VehicleWrapper.rst166
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_VertexProxy.rst209
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_VisibilityActuator.rst29
-rw-r--r--doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst79
-rw-r--r--doc/python_api/rst/bge_types/bge.types.PyObjectPlus.rst21
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_2DFilterActuator.rst49
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_ANDController.rst13
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_ActuatorSensor.rst19
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_AlwaysSensor.rst11
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_DelaySensor.rst39
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_IActuator.rst11
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_IController.rst55
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_ILogicBrick.rst29
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_IObject.rst11
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_ISensor.rst101
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_JoystickSensor.rst133
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_KeyboardSensor.rst64
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_MouseSensor.rst39
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_NANDController.rst13
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_NORController.rst13
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_ORController.rst13
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_PropertyActuator.rst29
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_PropertySensor.rst41
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_PythonController.rst54
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_PythonJoystick.rst77
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_PythonKeyboard.rst37
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_PythonMouse.rst35
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_RandomActuator.rst127
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_RandomSensor.rst23
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_XNORController.rst13
-rw-r--r--doc/python_api/rst/bge_types/bge.types.SCA_XORController.rst13
-rw-r--r--doc/python_api/rst/change_log.rst341
-rw-r--r--doc/python_api/rst/gpu.rst684
-rw-r--r--doc/python_api/rst/info_api_reference.rst2
-rw-r--r--doc/python_api/rst/info_quickstart.rst4
-rw-r--r--doc/python_api/rst/info_tips_and_tricks.rst7
-rw-r--r--extern/CMakeLists.txt4
-rw-r--r--extern/audaspace/blender_config.cmake4
-rw-r--r--extern/recastnavigation/CMakeLists.txt72
-rw-r--r--extern/recastnavigation/Detour/Include/DetourCommon.h167
-rw-r--r--extern/recastnavigation/Detour/Include/DetourNode.h149
-rw-r--r--extern/recastnavigation/Detour/Include/DetourStatNavMesh.h234
-rw-r--r--extern/recastnavigation/Detour/Include/DetourStatNavMeshBuilder.h33
-rw-r--r--extern/recastnavigation/Detour/Include/DetourTileNavMesh.h315
-rw-r--r--extern/recastnavigation/Detour/Include/DetourTileNavMeshBuilder.h29
-rw-r--r--extern/recastnavigation/Detour/Source/DetourCommon.cpp244
-rw-r--r--extern/recastnavigation/Detour/Source/DetourNode.cpp140
-rw-r--r--extern/recastnavigation/Detour/Source/DetourStatNavMesh.cpp876
-rw-r--r--extern/recastnavigation/Detour/Source/DetourStatNavMeshBuilder.cpp346
-rw-r--r--extern/recastnavigation/Detour/Source/DetourTileNavMesh.cpp1428
-rw-r--r--extern/recastnavigation/Detour/Source/DetourTileNavMeshBuilder.cpp213
-rw-r--r--extern/recastnavigation/License.txt18
-rw-r--r--extern/recastnavigation/Readme.txt120
-rw-r--r--extern/recastnavigation/Recast/Include/Recast.h1194
-rw-r--r--extern/recastnavigation/Recast/Include/RecastAlloc.h147
-rw-r--r--extern/recastnavigation/Recast/Include/RecastAssert.h33
-rw-r--r--extern/recastnavigation/Recast/Source/Recast.cpp487
-rw-r--r--extern/recastnavigation/Recast/Source/RecastAlloc.cpp84
-rw-r--r--extern/recastnavigation/Recast/Source/RecastArea.cpp591
-rw-r--r--extern/recastnavigation/Recast/Source/RecastContour.cpp1105
-rw-r--r--extern/recastnavigation/Recast/Source/RecastFilter.cpp202
-rw-r--r--extern/recastnavigation/Recast/Source/RecastLayers.cpp613
-rw-r--r--extern/recastnavigation/Recast/Source/RecastMesh.cpp1552
-rw-r--r--extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp1463
-rw-r--r--extern/recastnavigation/Recast/Source/RecastRasterization.cpp454
-rw-r--r--extern/recastnavigation/Recast/Source/RecastRegion.cpp1830
-rw-r--r--extern/recastnavigation/readme-blender.txt22
-rw-r--r--extern/recastnavigation/recast-capi.cpp381
-rw-r--r--extern/recastnavigation/recast-capi.h181
-rw-r--r--intern/CMakeLists.txt10
-rw-r--r--intern/clog/clog.c4
-rw-r--r--intern/container/CMakeLists.txt41
-rw-r--r--intern/container/CTR_HashedPtr.h62
-rw-r--r--intern/container/CTR_Map.h181
-rw-r--r--intern/cycles/blender/addon/ui.py308
-rw-r--r--intern/cycles/blender/blender_session.cpp4
-rw-r--r--intern/decklink/CMakeLists.txt58
-rw-r--r--intern/decklink/DeckLinkAPI.cpp50
-rw-r--r--intern/decklink/DeckLinkAPI.h56
-rw-r--r--intern/decklink/linux/DeckLinkAPI.h767
-rw-r--r--intern/decklink/linux/DeckLinkAPIConfiguration.h192
-rw-r--r--intern/decklink/linux/DeckLinkAPIDeckControl.h215
-rw-r--r--intern/decklink/linux/DeckLinkAPIDiscovery.h71
-rw-r--r--intern/decklink/linux/DeckLinkAPIDispatch.cpp148
-rw-r--r--intern/decklink/linux/DeckLinkAPIModes.h191
-rw-r--r--intern/decklink/linux/DeckLinkAPITypes.h110
-rw-r--r--intern/decklink/linux/DeckLinkAPIVersion.h37
-rw-r--r--intern/decklink/linux/LinuxCOM.h100
-rw-r--r--intern/decklink/win/DeckLinkAPI_h.h13323
-rw-r--r--intern/decklink/win/DeckLinkAPI_i.c343
-rw-r--r--intern/gawain/gawain/gwn_imm_util.h4
-rw-r--r--intern/gawain/gawain/gwn_shader_interface.h1
-rw-r--r--intern/gawain/src/gwn_imm_util.c34
-rw-r--r--intern/gawain/src/gwn_immediate.c2
-rw-r--r--intern/gawain/src/gwn_shader_interface.c1
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp20
-rw-r--r--intern/gpudirect/CMakeLists.txt41
-rw-r--r--intern/gpudirect/dvpapi.cpp147
-rw-r--r--intern/gpudirect/dvpapi.h667
-rw-r--r--intern/moto/CMakeLists.txt77
-rw-r--r--intern/moto/include/MT_CmMatrix4x4.h148
-rw-r--r--intern/moto/include/MT_Matrix3x3.h276
-rw-r--r--intern/moto/include/MT_Matrix3x3.inl128
-rw-r--r--intern/moto/include/MT_Matrix4x4.h262
-rw-r--r--intern/moto/include/MT_Matrix4x4.inl108
-rw-r--r--intern/moto/include/MT_MinMax.h71
-rw-r--r--intern/moto/include/MT_Optimize.h43
-rw-r--r--intern/moto/include/MT_Point2.h83
-rw-r--r--intern/moto/include/MT_Point2.inl54
-rw-r--r--intern/moto/include/MT_Point3.h84
-rw-r--r--intern/moto/include/MT_Point3.inl59
-rw-r--r--intern/moto/include/MT_Quaternion.h114
-rw-r--r--intern/moto/include/MT_Quaternion.inl100
-rw-r--r--intern/moto/include/MT_Scalar.h96
-rw-r--r--intern/moto/include/MT_Stream.h59
-rw-r--r--intern/moto/include/MT_Transform.h190
-rw-r--r--intern/moto/include/MT_Tuple2.h111
-rw-r--r--intern/moto/include/MT_Tuple3.h116
-rw-r--r--intern/moto/include/MT_Tuple4.h126
-rw-r--r--intern/moto/include/MT_Vector2.h114
-rw-r--r--intern/moto/include/MT_Vector2.inl89
-rw-r--r--intern/moto/include/MT_Vector3.h120
-rw-r--r--intern/moto/include/MT_Vector3.inl141
-rw-r--r--intern/moto/include/MT_Vector4.h103
-rw-r--r--intern/moto/include/MT_Vector4.inl80
-rw-r--r--intern/moto/include/MT_assert.h103
-rw-r--r--intern/moto/include/MT_random.h44
-rw-r--r--intern/moto/intern/MT_Assert.cpp68
-rw-r--r--intern/moto/intern/MT_CmMatrix4x4.cpp206
-rw-r--r--intern/moto/intern/MT_Matrix3x3.cpp38
-rw-r--r--intern/moto/intern/MT_Matrix4x4.cpp38
-rw-r--r--intern/moto/intern/MT_Quaternion.cpp38
-rw-r--r--intern/moto/intern/MT_Transform.cpp139
-rw-r--r--intern/moto/intern/MT_Vector2.cpp38
-rw-r--r--intern/moto/intern/MT_Vector3.cpp38
-rw-r--r--intern/moto/intern/MT_Vector4.cpp38
-rw-r--r--intern/moto/intern/MT_random.cpp143
-rw-r--r--intern/string/CMakeLists.txt1
-rw-r--r--intern/string/STR_HashedString.h158
m---------release/datafiles/locale0
m---------release/scripts/addons0
m---------release/scripts/addons_contrib0
-rw-r--r--release/scripts/freestyle/modules/parameter_editor.py13
-rw-r--r--release/scripts/modules/bl_i18n_utils/utils_spell_check.py1
-rw-r--r--release/scripts/modules/bpy/ops.py15
-rw-r--r--release/scripts/modules/bpy_extras/keyconfig_utils.py1
-rw-r--r--release/scripts/modules/bpy_types.py9
-rw-r--r--release/scripts/presets/keyconfig/3dsmax.py15
-rw-r--r--release/scripts/presets/keyconfig/maya.py14
-rw-r--r--release/scripts/startup/bl_operators/object_quick_effects.py130
-rw-r--r--release/scripts/startup/bl_operators/presets.py29
-rw-r--r--release/scripts/startup/bl_operators/wm.py62
-rw-r--r--release/scripts/startup/bl_ui/__init__.py3
-rw-r--r--release/scripts/startup/bl_ui/properties_collection.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_armature.py7
-rw-r--r--release/scripts/startup/bl_ui/properties_data_bone.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_camera.py24
-rw-r--r--release/scripts/startup/bl_ui/properties_data_curve.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lamp.py228
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lattice.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_mesh.py24
-rw-r--r--release/scripts/startup/bl_ui/properties_data_metaball.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py35
-rw-r--r--release/scripts/startup/bl_ui/properties_data_speaker.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_data_workspace.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_freestyle.py22
-rw-r--r--release/scripts/startup/bl_ui/properties_game.py879
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py1004
-rw-r--r--release/scripts/startup/bl_ui/properties_object.py11
-rw-r--r--release/scripts/startup/bl_ui/properties_particle.py43
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_cloth.py15
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_common.py3
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py58
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_field.py9
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_fluid.py20
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_rigidbody.py6
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py5
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_smoke.py18
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_softbody.py17
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py248
-rw-r--r--release/scripts/startup/bl_ui/properties_scene.py40
-rw-r--r--release/scripts/startup/bl_ui/properties_texture.py712
-rw-r--r--release/scripts/startup/bl_ui/properties_view_layer.py44
-rw-r--r--release/scripts/startup/bl_ui/properties_world.py197
-rw-r--r--release/scripts/startup/bl_ui/space_dopesheet.py29
-rw-r--r--release/scripts/startup/bl_ui/space_image.py45
-rw-r--r--release/scripts/startup/bl_ui/space_info.py355
-rw-r--r--release/scripts/startup/bl_ui/space_logic.py145
-rw-r--r--release/scripts/startup/bl_ui/space_node.py14
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py2
-rw-r--r--release/scripts/startup/bl_ui/space_time.py22
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py6
-rw-r--r--release/scripts/startup/bl_ui/space_topbar.py397
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py4
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py176
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py15
-rw-r--r--release/scripts/startup/nodeitems_builtins.py89
-rw-r--r--release/scripts/templates_py/gamelogic.py73
-rw-r--r--release/scripts/templates_py/gamelogic_module.py27
-rw-r--r--release/scripts/templates_py/gamelogic_simple.py17
-rw-r--r--release/scripts/templates_py/ui_list_simple.py12
-rw-r--r--source/CMakeLists.txt4
-rw-r--r--source/blender/CMakeLists.txt4
-rw-r--r--source/blender/alembic/intern/abc_camera.cc4
-rw-r--r--source/blender/alembic/intern/abc_camera.h2
-rw-r--r--source/blender/alembic/intern/abc_curves.cc4
-rw-r--r--source/blender/alembic/intern/abc_curves.h2
-rw-r--r--source/blender/alembic/intern/abc_exporter.cc66
-rw-r--r--source/blender/alembic/intern/abc_exporter.h17
-rw-r--r--source/blender/alembic/intern/abc_hair.cc15
-rw-r--r--source/blender/alembic/intern/abc_hair.h2
-rw-r--r--source/blender/alembic/intern/abc_mball.cc12
-rw-r--r--source/blender/alembic/intern/abc_mball.h2
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc6
-rw-r--r--source/blender/alembic/intern/abc_mesh.h2
-rw-r--r--source/blender/alembic/intern/abc_nurbs.cc4
-rw-r--r--source/blender/alembic/intern/abc_nurbs.h2
-rw-r--r--source/blender/alembic/intern/abc_object.cc7
-rw-r--r--source/blender/alembic/intern/abc_object.h4
-rw-r--r--source/blender/alembic/intern/abc_points.cc6
-rw-r--r--source/blender/alembic/intern/abc_points.h2
-rw-r--r--source/blender/alembic/intern/abc_transform.cc4
-rw-r--r--source/blender/alembic/intern/abc_transform.h2
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc8
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c3
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h164
-rw-r--r--source/blender/blenkernel/BKE_action.h19
-rw-r--r--source/blender/blenkernel/BKE_anim.h10
-rw-r--r--source/blender/blenkernel/BKE_animsys.h6
-rw-r--r--source/blender/blenkernel/BKE_armature.h28
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_bullet.h44
-rw-r--r--source/blender/blenkernel/BKE_camera.h8
-rw-r--r--source/blender/blenkernel/BKE_cloth.h4
-rw-r--r--source/blender/blenkernel/BKE_constraint.h10
-rw-r--r--source/blender/blenkernel/BKE_context.h11
-rw-r--r--source/blender/blenkernel/BKE_crazyspace.h10
-rw-r--r--source/blender/blenkernel/BKE_curve.h8
-rw-r--r--source/blender/blenkernel/BKE_data_transfer.h8
-rw-r--r--source/blender/blenkernel/BKE_displist.h18
-rw-r--r--source/blender/blenkernel/BKE_dynamicpaint.h6
-rw-r--r--source/blender/blenkernel/BKE_editmesh.h4
-rw-r--r--source/blender/blenkernel/BKE_effect.h8
-rw-r--r--source/blender/blenkernel/BKE_fluidsim.h4
-rw-r--r--source/blender/blenkernel/BKE_global.h11
-rw-r--r--source/blender/blenkernel/BKE_groom.h4
-rw-r--r--source/blender/blenkernel/BKE_group.h6
-rw-r--r--source/blender/blenkernel/BKE_hair.h1
-rw-r--r--source/blender/blenkernel/BKE_icons.h36
-rw-r--r--source/blender/blenkernel/BKE_lattice.h8
-rw-r--r--source/blender/blenkernel/BKE_layer.h199
-rw-r--r--source/blender/blenkernel/BKE_library_override.h4
-rw-r--r--source/blender/blenkernel/BKE_main.h5
-rw-r--r--source/blender/blenkernel/BKE_mask.h6
-rw-r--r--source/blender/blenkernel/BKE_material.h15
-rw-r--r--source/blender/blenkernel/BKE_mball.h5
-rw-r--r--source/blender/blenkernel/BKE_mball_tessellate.h4
-rw-r--r--source/blender/blenkernel/BKE_mesh.h8
-rw-r--r--source/blender/blenkernel/BKE_modifier.h22
-rw-r--r--source/blender/blenkernel/BKE_movieclip.h4
-rw-r--r--source/blender/blenkernel/BKE_multires.h14
-rw-r--r--source/blender/blenkernel/BKE_navmesh_conversion.h67
-rw-r--r--source/blender/blenkernel/BKE_node.h28
-rw-r--r--source/blender/blenkernel/BKE_object.h70
-rw-r--r--source/blender/blenkernel/BKE_paint.h9
-rw-r--r--source/blender/blenkernel/BKE_particle.h24
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h6
-rw-r--r--source/blender/blenkernel/BKE_property.h53
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h12
-rw-r--r--source/blender/blenkernel/BKE_sca.h92
-rw-r--r--source/blender/blenkernel/BKE_scene.h32
-rw-r--r--source/blender/blenkernel/BKE_screen.h14
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h13
-rw-r--r--source/blender/blenkernel/BKE_sketch.h149
-rw-r--r--source/blender/blenkernel/BKE_smoke.h2
-rw-r--r--source/blender/blenkernel/BKE_softbody.h4
-rw-r--r--source/blender/blenkernel/BKE_text.h2
-rw-r--r--source/blender/blenkernel/BKE_texture.h26
-rw-r--r--source/blender/blenkernel/BKE_tracking.h1
-rw-r--r--source/blender/blenkernel/BKE_workspace.h11
-rw-r--r--source/blender/blenkernel/BKE_world.h4
-rw-r--r--source/blender/blenkernel/CMakeLists.txt21
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c759
-rw-r--r--source/blender/blenkernel/intern/action.c54
-rw-r--r--source/blender/blenkernel/intern/anim.c6
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c47
-rw-r--r--source/blender/blenkernel/intern/armature.c26
-rw-r--r--source/blender/blenkernel/intern/armature_update.c42
-rw-r--r--source/blender/blenkernel/intern/blendfile.c2
-rw-r--r--source/blender/blenkernel/intern/boids.c10
-rw-r--r--source/blender/blenkernel/intern/bpath.c8
-rw-r--r--source/blender/blenkernel/intern/bullet.c99
-rw-r--r--source/blender/blenkernel/intern/camera.c21
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c1345
-rw-r--r--source/blender/blenkernel/intern/cloth.c11
-rw-r--r--source/blender/blenkernel/intern/constraint.c92
-rw-r--r--source/blender/blenkernel/intern/context.c54
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c20
-rw-r--r--source/blender/blenkernel/intern/curve.c10
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c18
-rw-r--r--source/blender/blenkernel/intern/displist.c74
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c218
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c668
-rw-r--r--source/blender/blenkernel/intern/editmesh.c2
-rw-r--r--source/blender/blenkernel/intern/editmesh_bvh.c2
-rw-r--r--source/blender/blenkernel/intern/editmesh_tangent.c2
-rw-r--r--source/blender/blenkernel/intern/effect.c77
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c4
-rw-r--r--source/blender/blenkernel/intern/groom.c2
-rw-r--r--source/blender/blenkernel/intern/group.c10
-rw-r--r--source/blender/blenkernel/intern/icons.c186
-rw-r--r--source/blender/blenkernel/intern/image.c3
-rw-r--r--source/blender/blenkernel/intern/ipo.c32
-rw-r--r--source/blender/blenkernel/intern/lamp.c46
-rw-r--r--source/blender/blenkernel/intern/lattice.c6
-rw-r--r--source/blender/blenkernel/intern/layer.c156
-rw-r--r--source/blender/blenkernel/intern/layer_utils.c125
-rw-r--r--source/blender/blenkernel/intern/library.c2
-rw-r--r--source/blender/blenkernel/intern/library_override.c34
-rw-r--r--source/blender/blenkernel/intern/library_query.c68
-rw-r--r--source/blender/blenkernel/intern/library_remap.c5
-rw-r--r--source/blender/blenkernel/intern/mask_evaluate.c12
-rw-r--r--source/blender/blenkernel/intern/material.c552
-rw-r--r--source/blender/blenkernel/intern/mball.c10
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c16
-rw-r--r--source/blender/blenkernel/intern/mesh.c41
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c3
-rw-r--r--source/blender/blenkernel/intern/modifier.c16
-rw-r--r--source/blender/blenkernel/intern/movieclip.c2
-rw-r--r--source/blender/blenkernel/intern/multires.c38
-rw-r--r--source/blender/blenkernel/intern/navmesh_conversion.c502
-rw-r--r--source/blender/blenkernel/intern/node.c79
-rw-r--r--source/blender/blenkernel/intern/object.c373
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c70
-rw-r--r--source/blender/blenkernel/intern/object_update.c86
-rw-r--r--source/blender/blenkernel/intern/paint.c6
-rw-r--r--source/blender/blenkernel/intern/particle.c114
-rw-r--r--source/blender/blenkernel/intern/particle_child.c42
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c20
-rw-r--r--source/blender/blenkernel/intern/particle_system.c107
-rw-r--r--source/blender/blenkernel/intern/pbvh.c67
-rw-r--r--source/blender/blenkernel/intern/pointcache.c15
-rw-r--r--source/blender/blenkernel/intern/property.c267
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c38
-rw-r--r--source/blender/blenkernel/intern/sca.c1179
-rw-r--r--source/blender/blenkernel/intern/scene.c279
-rw-r--r--source/blender/blenkernel/intern/screen.c215
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c28
-rw-r--r--source/blender/blenkernel/intern/sequencer.c24
-rw-r--r--source/blender/blenkernel/intern/sketch.c555
-rw-r--r--source/blender/blenkernel/intern/smoke.c47
-rw-r--r--source/blender/blenkernel/intern/softbody.c102
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c1981
-rw-r--r--source/blender/blenkernel/intern/text.c95
-rw-r--r--source/blender/blenkernel/intern/texture.c439
-rw-r--r--source/blender/blenkernel/intern/undo_system.c5
-rw-r--r--source/blender/blenkernel/intern/workspace.c41
-rw-r--r--source/blender/blenkernel/intern/world.c36
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c11
-rw-r--r--source/blender/blenlib/BLI_callbacks.h2
-rw-r--r--source/blender/blenlib/BLI_graph.h185
-rw-r--r--source/blender/blenlib/BLI_linklist_lockfree.h88
-rw-r--r--source/blender/blenlib/BLI_utildefines_stack.h4
-rw-r--r--source/blender/blenlib/CMakeLists.txt5
-rw-r--r--source/blender/blenlib/intern/BLI_linklist_lockfree.c91
-rw-r--r--source/blender/blenlib/intern/graph.c1016
-rw-r--r--source/blender/blenloader/BLO_runtime.h3
-rw-r--r--source/blender/blenloader/CMakeLists.txt1
-rw-r--r--source/blender/blenloader/intern/blend_validate.c151
-rw-r--r--source/blender/blenloader/intern/readblenentry.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c1609
-rw-r--r--source/blender/blenloader/intern/versioning_250.c550
-rw-r--r--source/blender/blenloader/intern/versioning_260.c220
-rw-r--r--source/blender/blenloader/intern/versioning_270.c100
-rw-r--r--source/blender/blenloader/intern/versioning_280.c194
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c6
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c883
-rw-r--r--source/blender/blenloader/intern/writefile.c555
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c67
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c10
-rw-r--r--source/blender/bmesh/operators/bmo_offset_edgeloops.c1
-rw-r--r--source/blender/collada/AnimationExporter.cpp26
-rw-r--r--source/blender/collada/AnimationExporter.h8
-rw-r--r--source/blender/collada/AnimationImporter.cpp25
-rw-r--r--source/blender/collada/ArmatureExporter.cpp12
-rw-r--r--source/blender/collada/ArmatureExporter.h4
-rw-r--r--source/blender/collada/ArmatureImporter.cpp6
-rw-r--r--source/blender/collada/ControllerExporter.cpp12
-rw-r--r--source/blender/collada/ControllerExporter.h6
-rw-r--r--source/blender/collada/DocumentExporter.cpp13
-rw-r--r--source/blender/collada/DocumentExporter.h4
-rw-r--r--source/blender/collada/DocumentImporter.cpp146
-rw-r--r--source/blender/collada/DocumentImporter.h1
-rw-r--r--source/blender/collada/EffectExporter.cpp156
-rw-r--r--source/blender/collada/EffectExporter.h5
-rw-r--r--source/blender/collada/GeometryExporter.cpp6
-rw-r--r--source/blender/collada/GeometryExporter.h6
-rw-r--r--source/blender/collada/ImageExporter.cpp18
-rw-r--r--source/blender/collada/InstanceWriter.cpp6
-rw-r--r--source/blender/collada/LightExporter.cpp26
-rw-r--r--source/blender/collada/MeshImporter.cpp69
-rw-r--r--source/blender/collada/MeshImporter.h10
-rw-r--r--source/blender/collada/SceneExporter.cpp16
-rw-r--r--source/blender/collada/SceneExporter.h6
-rw-r--r--source/blender/collada/TransformWriter.cpp4
-rw-r--r--source/blender/collada/collada.cpp7
-rw-r--r--source/blender/collada/collada.h4
-rw-r--r--source/blender/collada/collada_utils.cpp171
-rw-r--r--source/blender/collada/collada_utils.h8
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp50
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp608
-rw-r--r--source/blender/depsgraph/DEG_depsgraph.h45
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_build.h1
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h8
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc63
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc17
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h1
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc3
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc16
-rw-r--r--source/blender/depsgraph/intern/depsgraph_eval.cc70
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc19
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_iter.cc13
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_types.h4
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc18
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.h2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc8
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc4
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.h2
-rw-r--r--source/blender/draw/CMakeLists.txt16
-rw-r--r--source/blender/draw/engines/basic/basic_engine.c26
-rw-r--r--source/blender/draw/engines/clay/clay_engine.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_effects.c95
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c17
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c155
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c21
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c9
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h17
-rw-r--r--source/blender/draw/engines/eevee/eevee_render.c9
-rw-r--r--source/blender/draw/engines/eevee/eevee_temporal_sampling.c123
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c2
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl56
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl61
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl104
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl19
-rw-r--r--source/blender/draw/engines/eevee/shaders/lamps_lib.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_geom.glsl53
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_vert.glsl28
-rw-r--r--source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl4
-rw-r--r--source/blender/draw/engines/workbench/shaders/solid_flat_frag.glsl8
-rw-r--r--source/blender/draw/engines/workbench/shaders/solid_studio_frag.glsl29
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_diffuse_lib.glsl21
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_studio_vert.glsl13
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_vert.glsl8
-rw-r--r--source/blender/draw/engines/workbench/solid_flat_mode.c110
-rw-r--r--source/blender/draw/engines/workbench/solid_studio_mode.c111
-rw-r--r--source/blender/draw/engines/workbench/workbench_engine.c64
-rw-r--r--source/blender/draw/engines/workbench/workbench_engine.h (renamed from intern/moto/intern/MT_Point3.cpp)25
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c163
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h87
-rw-r--r--source/blender/draw/intern/DRW_render.h10
-rw-r--r--source/blender/draw/intern/draw_armature.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c6
-rw-r--r--source/blender/draw/intern/draw_common.c17
-rw-r--r--source/blender/draw/intern/draw_common.h1
-rw-r--r--source/blender/draw/intern/draw_instance_data.c8
-rw-r--r--source/blender/draw/intern/draw_manager.c93
-rw-r--r--source/blender/draw/intern/draw_manager.h2
-rw-r--r--source/blender/draw/intern/draw_manager_data.c19
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c159
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c8
-rw-r--r--source/blender/draw/intern/draw_manager_texture.c2
-rw-r--r--source/blender/draw/modes/draw_mode_engines.h1
-rw-r--r--source/blender/draw/modes/edit_curve_mode.c9
-rw-r--r--source/blender/draw/modes/edit_lattice_mode.c4
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c4
-rw-r--r--source/blender/draw/modes/edit_metaball_mode.c3
-rw-r--r--source/blender/draw/modes/object_mode.c313
-rw-r--r--source/blender/draw/modes/overlay_mode.c173
-rw-r--r--source/blender/draw/modes/pose_mode.c4
-rw-r--r--source/blender/draw/modes/sculpt_mode.c2
-rw-r--r--source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl7
-rw-r--r--source/blender/draw/modes/shaders/object_outline_detect_frag.glsl126
-rw-r--r--source/blender/draw/modes/shaders/object_outline_prepass_frag.glsl10
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_orientation_frag.glsl10
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_orientation_vert.glsl7
-rw-r--r--source/blender/editors/CMakeLists.txt3
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c4
-rw-r--r--source/blender/editors/animation/anim_draw.c52
-rw-r--r--source/blender/editors/animation/anim_filter.c38
-rw-r--r--source/blender/editors/animation/anim_markers.c27
-rw-r--r--source/blender/editors/animation/anim_ops.c117
-rw-r--r--source/blender/editors/animation/keyframes_draw.c42
-rw-r--r--source/blender/editors/animation/keyframing.c21
-rw-r--r--source/blender/editors/armature/BIF_generate.h49
-rw-r--r--source/blender/editors/armature/BIF_retarget.h171
-rw-r--r--source/blender/editors/armature/CMakeLists.txt8
-rw-r--r--source/blender/editors/armature/armature_add.c57
-rw-r--r--source/blender/editors/armature/armature_edit.c146
-rw-r--r--source/blender/editors/armature/armature_intern.h24
-rw-r--r--source/blender/editors/armature/armature_naming.c8
-rw-r--r--source/blender/editors/armature/armature_ops.c27
-rw-r--r--source/blender/editors/armature/armature_relations.c12
-rw-r--r--source/blender/editors/armature/armature_select.c384
-rw-r--r--source/blender/editors/armature/armature_skinning.c14
-rw-r--r--source/blender/editors/armature/armature_utils.c32
-rw-r--r--source/blender/editors/armature/editarmature_generate.c305
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c2640
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c2653
-rw-r--r--source/blender/editors/armature/editarmature_undo.c81
-rw-r--r--source/blender/editors/armature/meshlaplacian.c2
-rw-r--r--source/blender/editors/armature/meshlaplacian.h2
-rw-r--r--source/blender/editors/armature/pose_edit.c158
-rw-r--r--source/blender/editors/armature/pose_lib.c12
-rw-r--r--source/blender/editors/armature/pose_select.c112
-rw-r--r--source/blender/editors/armature/pose_transform.c116
-rw-r--r--source/blender/editors/armature/pose_utils.c6
-rw-r--r--source/blender/editors/armature/reeb.c3201
-rw-r--r--source/blender/editors/armature/reeb.h207
-rw-r--r--source/blender/editors/curve/CMakeLists.txt1
-rw-r--r--source/blender/editors/curve/editcurve.c8
-rw-r--r--source/blender/editors/curve/editcurve_paint.c7
-rw-r--r--source/blender/editors/curve/editcurve_undo.c77
-rw-r--r--source/blender/editors/curve/editfont.c6
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c5
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c16
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c5
-rw-r--r--source/blender/editors/include/ED_anim_api.h9
-rw-r--r--source/blender/editors/include/ED_armature.h87
-rw-r--r--source/blender/editors/include/ED_buttons.h10
-rw-r--r--source/blender/editors/include/ED_gpencil.h2
-rw-r--r--source/blender/editors/include/ED_keyframing.h11
-rw-r--r--source/blender/editors/include/ED_mesh.h25
-rw-r--r--source/blender/editors/include/ED_object.h19
-rw-r--r--source/blender/editors/include/ED_particle.h6
-rw-r--r--source/blender/editors/include/ED_render.h1
-rw-r--r--source/blender/editors/include/ED_screen.h29
-rw-r--r--source/blender/editors/include/ED_space_api.h2
-rw-r--r--source/blender/editors/include/ED_transform.h2
-rw-r--r--source/blender/editors/include/ED_transform_snap_object_context.h5
-rw-r--r--source/blender/editors/include/ED_undo.h17
-rw-r--r--source/blender/editors/include/ED_util.h5
-rw-r--r--source/blender/editors/include/ED_uvedit.h11
-rw-r--r--source/blender/editors/include/ED_view3d.h76
-rw-r--r--source/blender/editors/include/UI_interface.h63
-rw-r--r--source/blender/editors/include/UI_resources.h4
-rw-r--r--source/blender/editors/interface/interface.c429
-rw-r--r--source/blender/editors/interface/interface_align.c45
-rw-r--r--source/blender/editors/interface/interface_eyedropper_depth.c5
-rw-r--r--source/blender/editors/interface/interface_handlers.c351
-rw-r--r--source/blender/editors/interface/interface_icons.c139
-rw-r--r--source/blender/editors/interface/interface_intern.h16
-rw-r--r--source/blender/editors/interface/interface_layout.c95
-rw-r--r--source/blender/editors/interface/interface_templates.c372
-rw-r--r--source/blender/editors/interface/interface_utils.c76
-rw-r--r--source/blender/editors/interface/interface_widgets.c119
-rw-r--r--source/blender/editors/interface/resources.c66
-rw-r--r--source/blender/editors/io/io_collada.c9
-rw-r--r--source/blender/editors/lattice/CMakeLists.txt1
-rw-r--r--source/blender/editors/lattice/editlattice_undo.c77
-rw-r--r--source/blender/editors/manipulator_library/manipulator_library_presets.c5
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c2
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt13
-rw-r--r--source/blender/editors/mesh/editface.c10
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c8
-rw-r--r--source/blender/editors/mesh/editmesh_bisect.c10
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c57
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c8
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c15
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c6
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c13
-rw-r--r--source/blender/editors/mesh/editmesh_path.c14
-rw-r--r--source/blender/editors/mesh/editmesh_select.c545
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c930
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c83
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c2
-rw-r--r--source/blender/editors/mesh/mesh_data.c3
-rw-r--r--source/blender/editors/mesh/mesh_intern.h9
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c738
-rw-r--r--source/blender/editors/mesh/mesh_ops.c9
-rw-r--r--source/blender/editors/mesh/meshtools.c83
-rw-r--r--source/blender/editors/metaball/CMakeLists.txt1
-rw-r--r--source/blender/editors/metaball/editmball_undo.c77
-rw-r--r--source/blender/editors/metaball/mball_edit.c4
-rw-r--r--source/blender/editors/object/CMakeLists.txt5
-rw-r--r--source/blender/editors/object/object_add.c89
-rw-r--r--source/blender/editors/object/object_bake.c324
-rw-r--r--source/blender/editors/object/object_bake_api.c16
-rw-r--r--source/blender/editors/object/object_constraint.c43
-rw-r--r--source/blender/editors/object/object_data_transfer.c23
-rw-r--r--source/blender/editors/object/object_edit.c759
-rw-r--r--source/blender/editors/object/object_hook.c5
-rw-r--r--source/blender/editors/object/object_intern.h8
-rw-r--r--source/blender/editors/object/object_lod.c114
-rw-r--r--source/blender/editors/object/object_modes.c15
-rw-r--r--source/blender/editors/object/object_modifier.c69
-rw-r--r--source/blender/editors/object/object_ops.c14
-rw-r--r--source/blender/editors/object/object_relations.c213
-rw-r--r--source/blender/editors/object/object_select.c77
-rw-r--r--source/blender/editors/object/object_transform.c50
-rw-r--r--source/blender/editors/object/object_vgroup.c18
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c10
-rw-r--r--source/blender/editors/physics/particle_edit.c176
-rw-r--r--source/blender/editors/physics/particle_object.c58
-rw-r--r--source/blender/editors/physics/physics_fluid.c17
-rw-r--r--source/blender/editors/physics/physics_intern.h4
-rw-r--r--source/blender/editors/render/render_intern.h5
-rw-r--r--source/blender/editors/render/render_internal.c626
-rw-r--r--source/blender/editors/render/render_opengl.c25
-rw-r--r--source/blender/editors/render/render_ops.c3
-rw-r--r--source/blender/editors/render/render_preview.c217
-rw-r--r--source/blender/editors/render/render_shading.c238
-rw-r--r--source/blender/editors/render/render_update.c237
-rw-r--r--source/blender/editors/scene/scene_edit.c2
-rw-r--r--source/blender/editors/screen/area.c201
-rw-r--r--source/blender/editors/screen/screen_context.c164
-rw-r--r--source/blender/editors/screen/screen_edit.c531
-rw-r--r--source/blender/editors/screen/screen_intern.h18
-rw-r--r--source/blender/editors/screen/screen_ops.c255
-rw-r--r--source/blender/editors/screen/screendump.c2
-rw-r--r--source/blender/editors/screen/workspace_edit.c14
-rw-r--r--source/blender/editors/screen/workspace_layout_edit.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c189
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h5
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c18
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c1
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c28
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c54
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_proj.c16
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c13
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c90
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c19
-rw-r--r--source/blender/editors/sound/sound_ops.c2
-rw-r--r--source/blender/editors/space_action/action_draw.c143
-rw-r--r--source/blender/editors/space_action/action_intern.h5
-rw-r--r--source/blender/editors/space_action/space_action.c165
-rw-r--r--source/blender/editors/space_api/spacetypes.c7
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c217
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h1
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c205
-rw-r--r--source/blender/editors/space_clip/clip_toolbar.c23
-rw-r--r--source/blender/editors/space_clip/space_clip.c21
-rw-r--r--source/blender/editors/space_clip/tracking_ops_orient.c6
-rw-r--r--source/blender/editors/space_file/file_panels.c3
-rw-r--r--source/blender/editors/space_file/space_file.c2
-rw-r--r--source/blender/editors/space_graph/space_graph.c53
-rw-r--r--source/blender/editors/space_image/image_draw.c120
-rw-r--r--source/blender/editors/space_image/image_edit.c5
-rw-r--r--source/blender/editors/space_image/image_ops.c6
-rw-r--r--source/blender/editors/space_image/space_image.c27
-rw-r--r--source/blender/editors/space_logic/CMakeLists.txt58
-rw-r--r--source/blender/editors/space_logic/logic_buttons.c166
-rw-r--r--source/blender/editors/space_logic/logic_intern.h55
-rw-r--r--source/blender/editors/space_logic/logic_ops.c753
-rw-r--r--source/blender/editors/space_logic/logic_window.c2594
-rw-r--r--source/blender/editors/space_logic/space_logic.c377
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c2
-rw-r--r--source/blender/editors/space_nla/space_nla.c51
-rw-r--r--source/blender/editors/space_node/drawnode.c56
-rw-r--r--source/blender/editors/space_node/node_add.c14
-rw-r--r--source/blender/editors/space_node/node_draw.c4
-rw-r--r--source/blender/editors/space_node/node_edit.c81
-rw-r--r--source/blender/editors/space_node/node_ops.c2
-rw-r--r--source/blender/editors/space_node/node_templates.c8
-rw-r--r--source/blender/editors/space_node/space_node.c7
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h1
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c91
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c14
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c22
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c1
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h1
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c44
-rw-r--r--source/blender/editors/space_text/text_ops.c3
-rw-r--r--source/blender/editors/space_time/space_time.c861
-rw-r--r--source/blender/editors/space_time/time_intern.h43
-rw-r--r--source/blender/editors/space_time/time_ops.c227
-rw-r--r--source/blender/editors/space_topbar/CMakeLists.txt (renamed from source/blender/editors/space_time/CMakeLists.txt)9
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c265
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt11
-rw-r--r--source/blender/editors/space_view3d/drawanimviz.c438
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c3010
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c366
-rw-r--r--source/blender/editors/space_view3d/drawobject.c9237
-rw-r--r--source/blender/editors/space_view3d/drawsimdebug.c209
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c63
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c922
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c1119
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c96
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h127
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_ruler.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c558
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c243
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c11
-rw-r--r--source/blender/editors/transform/transform.c1688
-rw-r--r--source/blender/editors/transform/transform.h147
-rw-r--r--source/blender/editors/transform/transform_constraints.c120
-rw-r--r--source/blender/editors/transform/transform_conversions.c3145
-rw-r--r--source/blender/editors/transform/transform_generics.c1079
-rw-r--r--source/blender/editors/transform/transform_manipulator.c122
-rw-r--r--source/blender/editors/transform/transform_ops.c20
-rw-r--r--source/blender/editors/transform/transform_orientations.c41
-rw-r--r--source/blender/editors/transform/transform_snap.c330
-rw-r--r--source/blender/editors/transform/transform_snap_object.c38
-rw-r--r--source/blender/editors/undo/ed_undo.c68
-rw-r--r--source/blender/editors/undo/memfile_undo.c2
-rw-r--r--source/blender/editors/util/ed_transverts.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c290
-rw-r--r--source/blender/editors/uvedit/uvedit_intern.h11
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c832
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c335
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp37
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h1
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp101
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h2
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h3
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h6
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h2
-rw-r--r--source/blender/gpu/CMakeLists.txt10
-rw-r--r--source/blender/gpu/GPU_buffers.h188
-rw-r--r--source/blender/gpu/GPU_draw.h59
-rw-r--r--source/blender/gpu/GPU_lamp.h77
-rw-r--r--source/blender/gpu/GPU_material.h110
-rw-r--r--source/blender/gpu/GPU_shader.h2
-rw-r--r--source/blender/gpu/GPU_texture.h2
-rw-r--r--source/blender/gpu/intern/gpu_batch.c2
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c960
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c402
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h3
-rw-r--r--source/blender/gpu/intern/gpu_draw.c1063
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c17
-rw-r--r--source/blender/gpu/intern/gpu_init_exit.c3
-rw-r--r--source/blender/gpu/intern/gpu_lamp.c460
-rw-r--r--source/blender/gpu/intern/gpu_lamp_private.h84
-rw-r--r--source/blender/gpu/intern/gpu_material.c2292
-rw-r--r--source/blender/gpu/intern/gpu_shader.c19
-rw-r--r--source/blender/gpu/intern/gpu_texture.c20
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_smooth_color_uniform_alpha_vert.glsl14
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl21
-rw-r--r--source/blender/gpu/shaders/gpu_shader_flat_id_frag.glsl8
-rw-r--r--source/blender/gpu/shaders/gpu_shader_geometry.glsl5
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl23
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl1822
-rw-r--r--source/blender/gpu/shaders/gpu_shader_vertex.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_vertex_world.glsl4
-rw-r--r--source/blender/ikplugin/BIK_api.h6
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.c8
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.h8
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c14
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.h4
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp79
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.h4
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp13
-rw-r--r--source/blender/imbuf/intern/indexer.c2
-rw-r--r--source/blender/imbuf/intern/jp2.c2
-rw-r--r--source/blender/makesdna/DNA_ID.h12
-rw-r--r--source/blender/makesdna/DNA_action_types.h19
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h583
-rw-r--r--source/blender/makesdna/DNA_anim_types.h5
-rw-r--r--source/blender/makesdna/DNA_armature_types.h2
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h6
-rw-r--r--source/blender/makesdna/DNA_controller_types.h95
-rw-r--r--source/blender/makesdna/DNA_curve_types.h2
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h3
-rw-r--r--source/blender/makesdna/DNA_image_types.h27
-rw-r--r--source/blender/makesdna/DNA_lamp_types.h100
-rw-r--r--source/blender/makesdna/DNA_material_types.h338
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h12
-rw-r--r--source/blender/makesdna/DNA_node_types.h5
-rw-r--r--source/blender/makesdna/DNA_object_force_types.h53
-rw-r--r--source/blender/makesdna/DNA_object_types.h134
-rw-r--r--source/blender/makesdna/DNA_property_types.h65
-rw-r--r--source/blender/makesdna/DNA_scene_types.h379
-rw-r--r--source/blender/makesdna/DNA_screen_types.h60
-rw-r--r--source/blender/makesdna/DNA_sensor_types.h334
-rw-r--r--source/blender/makesdna/DNA_space_types.h119
-rw-r--r--source/blender/makesdna/DNA_texture_types.h132
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h17
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h40
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h9
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h4
-rw-r--r--source/blender/makesdna/DNA_world_types.h111
-rw-r--r--source/blender/makesdna/intern/makesdna.c21
-rw-r--r--source/blender/makesrna/RNA_access.h29
-rw-r--r--source/blender/makesrna/RNA_enum_types.h2
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt11
-rw-r--r--source/blender/makesrna/intern/makesrna.c4
-rw-r--r--source/blender/makesrna/intern/rna_access.c124
-rw-r--r--source/blender/makesrna/intern/rna_actuator.c2220
-rw-r--r--source/blender/makesrna/intern/rna_actuator_api.c77
-rw-r--r--source/blender/makesrna/intern/rna_armature.c19
-rw-r--r--source/blender/makesrna/intern/rna_armature_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_color.c27
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c179
-rw-r--r--source/blender/makesrna/intern/rna_context.c11
-rw-r--r--source/blender/makesrna/intern/rna_controller.c327
-rw-r--r--source/blender/makesrna/intern/rna_controller_api.c86
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c12
-rw-r--r--source/blender/makesrna/intern/rna_hair.c5
-rw-r--r--source/blender/makesrna/intern/rna_image.c86
-rw-r--r--source/blender/makesrna/intern/rna_internal.h1
-rw-r--r--source/blender/makesrna/intern/rna_key.c2
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c446
-rw-r--r--source/blender/makesrna/intern/rna_layer.c161
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c8
-rw-r--r--source/blender/makesrna/intern/rna_material.c1791
-rw-r--r--source/blender/makesrna/intern/rna_mesh_utils.h2
-rw-r--r--source/blender/makesrna/intern/rna_meta.c1
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c100
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c103
-rw-r--r--source/blender/makesrna/intern/rna_object.c649
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c73
-rw-r--r--source/blender/makesrna/intern/rna_pose.c4
-rw-r--r--source/blender/makesrna/intern/rna_property.c203
-rw-r--r--source/blender/makesrna/intern/rna_scene.c1268
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c5
-rw-r--r--source/blender/makesrna/intern/rna_screen.c54
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c5
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c939
-rw-r--r--source/blender/makesrna/intern/rna_sensor_api.c79
-rw-r--r--source/blender/makesrna/intern/rna_sound.c1
-rw-r--r--source/blender/makesrna/intern/rna_space.c472
-rw-r--r--source/blender/makesrna/intern/rna_space_api.c19
-rw-r--r--source/blender/makesrna/intern/rna_texture.c611
-rw-r--r--source/blender/makesrna/intern/rna_texture_api.c51
-rw-r--r--source/blender/makesrna/intern/rna_ui.c13
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c15
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c112
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c44
-rw-r--r--source/blender/makesrna/intern/rna_world.c296
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c8
-rw-r--r--source/blender/modifiers/intern/MOD_array.c2
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c2
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c2
-rw-r--r--source/blender/modifiers/intern/MOD_build.c2
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c4
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c4
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c2
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c4
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c6
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c4
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c2
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c4
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c16
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c2
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c12
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim.c2
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c4
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c4
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c4
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c6
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c2
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c4
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c12
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c2
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c2
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c2
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c2
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c2
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c228
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c4
-rw-r--r--source/blender/modifiers/intern/MOD_remesh.c4
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c2
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c12
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c4
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c4
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c2
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c4
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c4
-rw-r--r--source/blender/modifiers/intern/MOD_softbody.c4
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c2
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c8
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c2
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c4
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c2
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c134
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c2
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c6
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c13
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c2
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c2
-rw-r--r--source/blender/nodes/CMakeLists.txt5
-rw-r--r--source/blender/nodes/NOD_shader.h6
-rw-r--r--source/blender/nodes/NOD_static_types.h6
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c2
-rw-r--r--source/blender/nodes/intern/node_exec.c2
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c62
-rw-r--r--source/blender/nodes/shader/node_shader_util.c47
-rw-r--r--source/blender/nodes/shader/node_shader_util.h6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_camera.c19
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_fresnel.c29
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geom.c163
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_lamp.c91
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_layer_weight.c40
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_material.c374
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c149
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_object_info.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output.c99
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_particle_info.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_texture.c166
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectTransform.c83
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c33
-rw-r--r--source/blender/nodes/texture/node_texture_util.c1
-rw-r--r--source/blender/nodes/texture/node_texture_util.h2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_proc.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_texture.c2
-rw-r--r--source/blender/physics/BPH_mass_spring.h2
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp21
-rw-r--r--source/blender/physics/intern/hair_volume.cpp53
-rw-r--r--source/blender/physics/intern/implicit.h2
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c2
-rw-r--r--source/blender/python/generic/bpy_internal_import.c10
-rw-r--r--source/blender/python/generic/bpy_internal_import.h5
-rw-r--r--source/blender/python/generic/py_capi_utils.h2
-rw-r--r--source/blender/python/intern/CMakeLists.txt10
-rw-r--r--source/blender/python/intern/bpy_app.c10
-rw-r--r--source/blender/python/intern/bpy_app_build_options.c14
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c2
-rw-r--r--source/blender/python/intern/bpy_app_icons.c134
-rw-r--r--source/blender/python/intern/bpy_app_icons.h (renamed from source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h)16
-rw-r--r--source/blender/python/intern/bpy_rna.c64
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c8
-rw-r--r--source/blender/python/intern/gpu.c245
-rw-r--r--source/blender/python/intern/gpu_offscreen.c4
-rw-r--r--source/blender/python/mathutils/mathutils.h2
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.c2
-rw-r--r--source/blender/python/simple_enum_gen.py2
-rw-r--r--source/blender/render/CMakeLists.txt58
-rw-r--r--source/blender/render/extern/include/RE_bake.h3
-rw-r--r--source/blender/render/extern/include/RE_engine.h5
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h64
-rw-r--r--source/blender/render/extern/include/RE_render_ext.h16
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h186
-rw-r--r--source/blender/render/intern/include/envmap.h54
-rw-r--r--source/blender/render/intern/include/initrender.h7
-rw-r--r--source/blender/render/intern/include/occlusion.h49
-rw-r--r--source/blender/render/intern/include/pixelblending.h65
-rw-r--r--source/blender/render/intern/include/pixelshading.h62
-rw-r--r--source/blender/render/intern/include/pointdensity.h52
-rw-r--r--source/blender/render/intern/include/raycounter.h74
-rw-r--r--source/blender/render/intern/include/rayintersection.h136
-rw-r--r--source/blender/render/intern/include/rayobject.h121
-rw-r--r--source/blender/render/intern/include/render_result.h2
-rw-r--r--source/blender/render/intern/include/render_types.h530
-rw-r--r--source/blender/render/intern/include/rendercore.h105
-rw-r--r--source/blender/render/intern/include/renderdatabase.h175
-rw-r--r--source/blender/render/intern/include/renderpipeline.h3
-rw-r--r--source/blender/render/intern/include/shadbuf.h112
-rw-r--r--source/blender/render/intern/include/shading.h105
-rw-r--r--source/blender/render/intern/include/sss.h67
-rw-r--r--source/blender/render/intern/include/strand.h99
-rw-r--r--source/blender/render/intern/include/sunsky.h81
-rw-r--r--source/blender/render/intern/include/texture.h17
-rw-r--r--source/blender/render/intern/include/texture_ocean.h35
-rw-r--r--source/blender/render/intern/include/volume_precache.h39
-rw-r--r--source/blender/render/intern/include/volumetric.h51
-rw-r--r--source/blender/render/intern/include/voxeldata.h47
-rw-r--r--source/blender/render/intern/include/zbuf.h101
-rw-r--r--source/blender/render/intern/raytrace/bvh.h407
-rw-r--r--source/blender/render/intern/raytrace/rayobject.cpp534
-rw-r--r--source/blender/render/intern/raytrace/rayobject_empty.cpp81
-rw-r--r--source/blender/render/intern/raytrace/rayobject_hint.h72
-rw-r--r--source/blender/render/intern/raytrace/rayobject_instance.cpp211
-rw-r--r--source/blender/render/intern/raytrace/rayobject_internal.h157
-rw-r--r--source/blender/render/intern/raytrace/rayobject_octree.cpp1101
-rw-r--r--source/blender/render/intern/raytrace/rayobject_qbvh.cpp160
-rw-r--r--source/blender/render/intern/raytrace/rayobject_raycounter.cpp91
-rw-r--r--source/blender/render/intern/raytrace/rayobject_rtbuild.cpp531
-rw-r--r--source/blender/render/intern/raytrace/rayobject_rtbuild.h125
-rw-r--r--source/blender/render/intern/raytrace/rayobject_svbvh.cpp192
-rw-r--r--source/blender/render/intern/raytrace/rayobject_vbvh.cpp206
-rw-r--r--source/blender/render/intern/raytrace/reorganize.h513
-rw-r--r--source/blender/render/intern/raytrace/svbvh.h317
-rw-r--r--source/blender/render/intern/raytrace/vbvh.h238
-rw-r--r--source/blender/render/intern/source/bake.c1343
-rw-r--r--source/blender/render/intern/source/bake_api.c70
-rw-r--r--source/blender/render/intern/source/convertblender.c5980
-rw-r--r--source/blender/render/intern/source/envmap.c819
-rw-r--r--source/blender/render/intern/source/external_engine.c44
-rw-r--r--source/blender/render/intern/source/imagetexture.c61
-rw-r--r--source/blender/render/intern/source/initrender.c340
-rw-r--r--source/blender/render/intern/source/multires_bake.c100
-rw-r--r--source/blender/render/intern/source/occlusion.c1533
-rw-r--r--source/blender/render/intern/source/pipeline.c1263
-rw-r--r--source/blender/render/intern/source/pixelblending.c400
-rw-r--r--source/blender/render/intern/source/pixelshading.c650
-rw-r--r--source/blender/render/intern/source/pointdensity.c161
-rw-r--r--source/blender/render/intern/source/rayshade.c2474
-rw-r--r--source/blender/render/intern/source/render_result.c23
-rw-r--r--source/blender/render/intern/source/render_texture.c2510
-rw-r--r--source/blender/render/intern/source/rendercore.c2028
-rw-r--r--source/blender/render/intern/source/renderdatabase.c1603
-rw-r--r--source/blender/render/intern/source/shadbuf.c2647
-rw-r--r--source/blender/render/intern/source/shadeinput.c1451
-rw-r--r--source/blender/render/intern/source/shadeoutput.c2162
-rw-r--r--source/blender/render/intern/source/sss.c1074
-rw-r--r--source/blender/render/intern/source/strand.c1069
-rw-r--r--source/blender/render/intern/source/sunsky.c506
-rw-r--r--source/blender/render/intern/source/texture_ocean.c160
-rw-r--r--source/blender/render/intern/source/volume_precache.c855
-rw-r--r--source/blender/render/intern/source/volumetric.c834
-rw-r--r--source/blender/render/intern/source/voxeldata.c571
-rw-r--r--source/blender/render/intern/source/zbuf.c3498
-rw-r--r--source/blender/windowmanager/CMakeLists.txt5
-rw-r--r--source/blender/windowmanager/WM_api.h9
-rw-r--r--source/blender/windowmanager/WM_types.h1
-rw-r--r--source/blender/windowmanager/intern/wm.c8
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c77
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c55
-rw-r--r--source/blender/windowmanager/intern/wm_files.c37
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c2
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c109
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c4
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c15
-rw-r--r--source/blender/windowmanager/intern/wm_window.c34
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c7
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c3
-rw-r--r--source/blenderplayer/CMakeLists.txt274
-rw-r--r--source/blenderplayer/bad_level_call_stubs/CMakeLists.txt79
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c869
-rw-r--r--source/creator/CMakeLists.txt53
-rw-r--r--source/creator/creator.c31
-rw-r--r--source/creator/creator_args.c110
-rw-r--r--source/creator/creator_intern.h2
-rw-r--r--source/creator/creator_signals.c7
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp683
-rw-r--r--source/gameengine/BlenderRoutines/BL_System.cpp102
-rw-r--r--source/gameengine/BlenderRoutines/BL_System.h70
-rw-r--r--source/gameengine/BlenderRoutines/CMakeLists.txt78
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp352
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.h222
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderInputDevice.cpp33
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h80
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp169
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h62
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp192
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h58
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp59
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderSystem.h56
-rw-r--r--source/gameengine/CMakeLists.txt57
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp664
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h158
-rw-r--r--source/gameengine/Converter/BL_ArmatureActuator.cpp271
-rw-r--r--source/gameengine/Converter/BL_ArmatureActuator.h96
-rw-r--r--source/gameengine/Converter/BL_ArmatureChannel.cpp469
-rw-r--r--source/gameengine/Converter/BL_ArmatureChannel.h101
-rw-r--r--source/gameengine/Converter/BL_ArmatureConstraint.cpp456
-rw-r--r--source/gameengine/Converter/BL_ArmatureConstraint.h125
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp691
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.h145
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp2473
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.h56
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.cpp116
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.h107
-rw-r--r--source/gameengine/Converter/BL_MeshDeformer.cpp239
-rw-r--r--source/gameengine/Converter/BL_MeshDeformer.h98
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.cpp227
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.h115
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.cpp563
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.h144
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.cpp237
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.h86
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.cpp384
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.h125
-rw-r--r--source/gameengine/Converter/CMakeLists.txt123
-rw-r--r--source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp81
-rw-r--r--source/gameengine/Converter/KX_BlenderScalarInterpolator.h76
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp1477
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.h232
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp1146
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.h45
-rw-r--r--source/gameengine/Converter/KX_ConvertControllers.cpp250
-rw-r--r--source/gameengine/Converter/KX_ConvertControllers.h47
-rw-r--r--source/gameengine/Converter/KX_ConvertProperties.cpp243
-rw-r--r--source/gameengine/Converter/KX_ConvertProperties.h41
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp663
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.h45
-rw-r--r--source/gameengine/Converter/KX_LibLoadStatus.cpp255
-rw-r--r--source/gameengine/Converter/KX_LibLoadStatus.h93
-rw-r--r--source/gameengine/Converter/KX_SoftBodyDeformer.cpp121
-rw-r--r--source/gameengine/Converter/KX_SoftBodyDeformer.h102
-rw-r--r--source/gameengine/Expressions/CMakeLists.txt91
-rw-r--r--source/gameengine/Expressions/EXP_BoolValue.h65
-rw-r--r--source/gameengine/Expressions/EXP_ConstExpr.h54
-rw-r--r--source/gameengine/Expressions/EXP_EmptyValue.h49
-rw-r--r--source/gameengine/Expressions/EXP_ErrorValue.h47
-rw-r--r--source/gameengine/Expressions/EXP_Expression.h149
-rw-r--r--source/gameengine/Expressions/EXP_FloatValue.h58
-rw-r--r--source/gameengine/Expressions/EXP_HashedPtr.h59
-rw-r--r--source/gameengine/Expressions/EXP_IdentifierExpr.h59
-rw-r--r--source/gameengine/Expressions/EXP_IfExpr.h54
-rw-r--r--source/gameengine/Expressions/EXP_InputParser.h118
-rw-r--r--source/gameengine/Expressions/EXP_IntValue.h73
-rw-r--r--source/gameengine/Expressions/EXP_ListValue.h92
-rw-r--r--source/gameengine/Expressions/EXP_ListWrapper.h109
-rw-r--r--source/gameengine/Expressions/EXP_Operator1Expr.h59
-rw-r--r--source/gameengine/Expressions/EXP_Operator2Expr.h66
-rw-r--r--source/gameengine/Expressions/EXP_PyObjectPlus.h648
-rw-r--r--source/gameengine/Expressions/EXP_Python.h82
-rw-r--r--source/gameengine/Expressions/EXP_PythonCallBack.h40
-rw-r--r--source/gameengine/Expressions/EXP_StringValue.h61
-rw-r--r--source/gameengine/Expressions/EXP_Value.h432
-rw-r--r--source/gameengine/Expressions/EXP_VectorValue.h94
-rw-r--r--source/gameengine/Expressions/EXP_VoidValue.h81
-rw-r--r--source/gameengine/Expressions/intern/BoolValue.cpp216
-rw-r--r--source/gameengine/Expressions/intern/ConstExpr.cpp131
-rw-r--r--source/gameengine/Expressions/intern/EmptyValue.cpp133
-rw-r--r--source/gameengine/Expressions/intern/ErrorValue.cpp131
-rw-r--r--source/gameengine/Expressions/intern/Expression.cpp77
-rw-r--r--source/gameengine/Expressions/intern/FloatValue.cpp329
-rw-r--r--source/gameengine/Expressions/intern/HashedPtr.cpp57
-rw-r--r--source/gameengine/Expressions/intern/IdentifierExpr.cpp103
-rw-r--r--source/gameengine/Expressions/intern/IfExpr.cpp144
-rw-r--r--source/gameengine/Expressions/intern/InputParser.cpp669
-rw-r--r--source/gameengine/Expressions/intern/IntValue.cpp344
-rw-r--r--source/gameengine/Expressions/intern/ListValue.cpp702
-rw-r--r--source/gameengine/Expressions/intern/ListWrapper.cpp424
-rw-r--r--source/gameengine/Expressions/intern/Operator1Expr.cpp151
-rw-r--r--source/gameengine/Expressions/intern/Operator2Expr.cpp276
-rw-r--r--source/gameengine/Expressions/intern/PyObjectPlus.cpp1226
-rw-r--r--source/gameengine/Expressions/intern/PythonCallBack.cpp119
-rw-r--r--source/gameengine/Expressions/intern/StringValue.cpp147
-rw-r--r--source/gameengine/Expressions/intern/Value.cpp672
-rw-r--r--source/gameengine/Expressions/intern/VectorValue.cpp225
-rw-r--r--source/gameengine/GameLogic/CMakeLists.txt147
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp382
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.h214
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h56
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp137
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h52
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp153
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.h71
-rw-r--r--source/gameengine/GameLogic/SCA_ANDController.cpp131
-rw-r--r--source/gameengine/GameLogic/SCA_ANDController.h51
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp68
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorEventManager.h56
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.cpp171
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.h70
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp59
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysEventManager.h50
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.cpp139
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.h53
-rw-r--r--source/gameengine/GameLogic/SCA_BasicEventManager.cpp61
-rw-r--r--source/gameengine/GameLogic/SCA_BasicEventManager.h57
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.cpp170
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.h66
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.cpp83
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.h91
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.cpp159
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.h66
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.cpp140
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.h168
-rw-r--r--source/gameengine/GameLogic/SCA_IController.cpp298
-rw-r--r--source/gameengine/GameLogic/SCA_IController.h112
-rw-r--r--source/gameengine/GameLogic/SCA_IInputDevice.cpp139
-rw-r--r--source/gameengine/GameLogic/SCA_IInputDevice.h334
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.cpp271
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.h167
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.cpp349
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.h229
-rw-r--r--source/gameengine/GameLogic/SCA_IScene.cpp145
-rw-r--r--source/gameengine/GameLogic/SCA_IScene.h87
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.cpp471
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.h220
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickManager.cpp92
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickManager.h59
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp428
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h168
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardManager.cpp80
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardManager.h66
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp668
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.h141
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.cpp342
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.h154
-rw-r--r--source/gameengine/GameLogic/SCA_MouseManager.cpp112
-rw-r--r--source/gameengine/GameLogic/SCA_MouseManager.h75
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.cpp317
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.h120
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.cpp133
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.h52
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.cpp133
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.h48
-rw-r--r--source/gameengine/GameLogic/SCA_ORController.cpp129
-rw-r--r--source/gameengine/GameLogic/SCA_ORController.h49
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp293
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.h90
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyEventManager.cpp57
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyEventManager.h55
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp332
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.h98
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp539
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.h118
-rw-r--r--source/gameengine/GameLogic/SCA_PythonJoystick.cpp188
-rw-r--r--source/gameengine/GameLogic/SCA_PythonJoystick.h56
-rw-r--r--source/gameengine/GameLogic/SCA_PythonKeyboard.cpp153
-rw-r--r--source/gameengine/GameLogic/SCA_PythonKeyboard.h50
-rw-r--r--source/gameengine/GameLogic/SCA_PythonMouse.cpp206
-rw-r--r--source/gameengine/GameLogic/SCA_PythonMouse.h59
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp543
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.h120
-rw-r--r--source/gameengine/GameLogic/SCA_RandomEventManager.cpp58
-rw-r--r--source/gameengine/GameLogic/SCA_RandomEventManager.h54
-rw-r--r--source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp133
-rw-r--r--source/gameengine/GameLogic/SCA_RandomNumberGenerator.h85
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp187
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.h71
-rw-r--r--source/gameengine/GameLogic/SCA_TimeEventManager.cpp120
-rw-r--r--source/gameengine/GameLogic/SCA_TimeEventManager.h62
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.cpp137
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.h53
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.cpp136
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.h48
-rw-r--r--source/gameengine/GamePlayer/CMakeLists.txt27
-rw-r--r--source/gameengine/GamePlayer/common/CMakeLists.txt75
-rw-r--r--source/gameengine/GamePlayer/common/GPC_Canvas.cpp168
-rw-r--r--source/gameengine/GamePlayer/common/GPC_Canvas.h147
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp128
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h90
-rw-r--r--source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp214
-rw-r--r--source/gameengine/GamePlayer/common/GPC_MouseDevice.h103
-rw-r--r--source/gameengine/GamePlayer/ghost/CMakeLists.txt112
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp998
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.h181
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp177
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.h76
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp165
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.h56
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_System.cpp53
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_System.h54
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp1228
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp534
-rw-r--r--source/gameengine/Ketsji/BL_Action.h151
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.cpp164
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.h132
-rw-r--r--source/gameengine/Ketsji/BL_BlenderShader.cpp188
-rw-r--r--source/gameengine/Ketsji/BL_BlenderShader.h96
-rw-r--r--source/gameengine/Ketsji/BL_Material.cpp123
-rw-r--r--source/gameengine/Ketsji/BL_Material.h182
-rw-r--r--source/gameengine/Ketsji/BL_Shader.cpp1478
-rw-r--r--source/gameengine/Ketsji/BL_Shader.h241
-rw-r--r--source/gameengine/Ketsji/BL_Texture.cpp759
-rw-r--r--source/gameengine/Ketsji/BL_Texture.h82
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt265
-rw-r--r--source/gameengine/Ketsji/KXNetwork/CMakeLists.txt56
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp77
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h55
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp139
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h72
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp224
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h90
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp31
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h32
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp32
-rw-r--r--source/gameengine/Ketsji/KX_ArmatureSensor.cpp208
-rw-r--r--source/gameengine/Ketsji/KX_ArmatureSensor.h90
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.cpp1334
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.h200
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp1166
-rw-r--r--source/gameengine/Ketsji/KX_Camera.h334
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.cpp428
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.h138
-rw-r--r--source/gameengine/Ketsji/KX_CameraIpoSGController.cpp126
-rw-r--r--source/gameengine/Ketsji/KX_CameraIpoSGController.h97
-rw-r--r--source/gameengine/Ketsji/KX_CharacterWrapper.cpp167
-rw-r--r--source/gameengine/Ketsji/KX_CharacterWrapper.h40
-rw-r--r--source/gameengine/Ketsji/KX_ClientObjectInfo.h84
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.cpp629
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.h152
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintWrapper.cpp133
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintWrapper.h61
-rw-r--r--source/gameengine/Ketsji/KX_Dome.cpp2051
-rw-r--r--source/gameengine/Ketsji/KX_Dome.h197
-rw-r--r--source/gameengine/Ketsji/KX_EmptyObject.cpp37
-rw-r--r--source/gameengine/Ketsji/KX_EmptyObject.h50
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.cpp300
-rw-r--r--source/gameengine/Ketsji/KX_FontObject.h81
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.cpp267
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.h91
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp4203
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h1142
-rw-r--r--source/gameengine/Ketsji/KX_IInterpolator.h56
-rw-r--r--source/gameengine/Ketsji/KX_IPOTransform.h87
-rw-r--r--source/gameengine/Ketsji/KX_IPO_SGController.cpp373
-rw-r--r--source/gameengine/Ketsji/KX_IPO_SGController.h124
-rw-r--r--source/gameengine/Ketsji/KX_IScalarInterpolator.h52
-rw-r--r--source/gameengine/Ketsji/KX_ISceneConverter.h103
-rw-r--r--source/gameengine/Ketsji/KX_ISystem.h63
-rw-r--r--source/gameengine/Ketsji/KX_IpoConvert.cpp441
-rw-r--r--source/gameengine/Ketsji/KX_IpoConvert.h69
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp2081
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.h553
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp479
-rw-r--r--source/gameengine/Ketsji/KX_Light.h100
-rw-r--r--source/gameengine/Ketsji/KX_LightIpoSGController.cpp122
-rw-r--r--source/gameengine/Ketsji/KX_LightIpoSGController.h105
-rw-r--r--source/gameengine/Ketsji/KX_MaterialIpoController.cpp105
-rw-r--r--source/gameengine/Ketsji/KX_MaterialIpoController.h65
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.cpp464
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.h85
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.cpp106
-rw-r--r--source/gameengine/Ketsji/KX_MotionState.h65
-rw-r--r--source/gameengine/Ketsji/KX_MouseActuator.cpp539
-rw-r--r--source/gameengine/Ketsji/KX_MouseActuator.h132
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp520
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.h208
-rw-r--r--source/gameengine/Ketsji/KX_NavMeshObject.cpp747
-rw-r--r--source/gameengine/Ketsji/KX_NavMeshObject.h80
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.cpp292
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.h107
-rw-r--r--source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp110
-rw-r--r--source/gameengine/Ketsji/KX_ObColorIpoSGController.h80
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp709
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.h234
-rw-r--r--source/gameengine/Ketsji/KX_ObstacleSimulation.cpp832
-rw-r--r--source/gameengine/Ketsji/KX_ObstacleSimulation.h134
-rw-r--r--source/gameengine/Ketsji/KX_OrientationInterpolator.cpp56
-rw-r--r--source/gameengine/Ketsji/KX_OrientationInterpolator.h64
-rw-r--r--source/gameengine/Ketsji/KX_ParentActuator.cpp205
-rw-r--r--source/gameengine/Ketsji/KX_ParentActuator.h91
-rw-r--r--source/gameengine/Ketsji/KX_PhysicsEngineEnums.h42
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.cpp266
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.h85
-rw-r--r--source/gameengine/Ketsji/KX_PositionInterpolator.cpp42
-rw-r--r--source/gameengine/Ketsji/KX_PositionInterpolator.h64
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.cpp750
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.h45
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.cpp215
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.h281
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp2953
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.h95
-rw-r--r--source/gameengine/Ketsji/KX_PythonInitTypes.cpp286
-rw-r--r--source/gameengine/Ketsji/KX_PythonInitTypes.h40
-rw-r--r--source/gameengine/Ketsji/KX_PythonMain.cpp71
-rw-r--r--source/gameengine/Ketsji/KX_PythonMain.h41
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.cpp230
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.h100
-rw-r--r--source/gameengine/Ketsji/KX_RayCast.cpp121
-rw-r--r--source/gameengine/Ketsji/KX_RayCast.h149
-rw-r--r--source/gameengine/Ketsji/KX_RayEventManager.cpp53
-rw-r--r--source/gameengine/Ketsji/KX_RayEventManager.h53
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp383
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.h109
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp284
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h133
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp160
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.h76
-rw-r--r--source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp125
-rw-r--r--source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h74
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp182
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h96
-rw-r--r--source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp155
-rw-r--r--source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h96
-rw-r--r--source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp298
-rw-r--r--source/gameengine/Ketsji/KX_SG_NodeRelationships.h231
-rw-r--r--source/gameengine/Ketsji/KX_ScalarInterpolator.cpp39
-rw-r--r--source/gameengine/Ketsji/KX_ScalarInterpolator.h69
-rw-r--r--source/gameengine/Ketsji/KX_ScalingInterpolator.cpp42
-rw-r--r--source/gameengine/Ketsji/KX_ScalingInterpolator.h64
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp2644
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h697
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.cpp292
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.h109
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp571
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.h127
-rw-r--r--source/gameengine/Ketsji/KX_StateActuator.cpp171
-rw-r--r--source/gameengine/Ketsji/KX_StateActuator.h97
-rw-r--r--source/gameengine/Ketsji/KX_SteeringActuator.cpp639
-rw-r--r--source/gameengine/Ketsji/KX_SteeringActuator.h123
-rw-r--r--source/gameengine/Ketsji/KX_TimeCategoryLogger.cpp141
-rw-r--r--source/gameengine/Ketsji/KX_TimeCategoryLogger.h136
-rw-r--r--source/gameengine/Ketsji/KX_TimeLogger.cpp117
-rw-r--r--source/gameengine/Ketsji/KX_TimeLogger.h114
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.cpp246
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.h109
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp362
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.h138
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp430
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.h98
-rw-r--r--source/gameengine/Ketsji/KX_VehicleWrapper.cpp380
-rw-r--r--source/gameengine/Ketsji/KX_VehicleWrapper.h61
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.cpp595
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.h112
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.cpp127
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.h75
-rw-r--r--source/gameengine/Ketsji/KX_WorldInfo.cpp494
-rw-r--r--source/gameengine/Ketsji/KX_WorldInfo.h105
-rw-r--r--source/gameengine/Ketsji/KX_WorldIpoController.cpp125
-rw-r--r--source/gameengine/Ketsji/KX_WorldIpoController.h117
-rw-r--r--source/gameengine/Network/CMakeLists.txt48
-rw-r--r--source/gameengine/Network/LoopBackNetwork/CMakeLists.txt43
-rw-r--r--source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp112
-rw-r--r--source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h63
-rw-r--r--source/gameengine/Network/NG_NetworkDeviceInterface.h82
-rw-r--r--source/gameengine/Network/NG_NetworkMessage.cpp55
-rw-r--r--source/gameengine/Network/NG_NetworkMessage.h138
-rw-r--r--source/gameengine/Network/NG_NetworkObject.cpp46
-rw-r--r--source/gameengine/Network/NG_NetworkObject.h55
-rw-r--r--source/gameengine/Network/NG_NetworkScene.cpp272
-rw-r--r--source/gameengine/Network/NG_NetworkScene.h118
-rw-r--r--source/gameengine/Physics/Bullet/CMakeLists.txt73
-rw-r--r--source/gameengine/Physics/Bullet/CcdGraphicController.cpp152
-rw-r--r--source/gameengine/Physics/Bullet/CcdGraphicController.h90
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp2668
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h832
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp3795
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h345
-rw-r--r--source/gameengine/Physics/Dummy/CMakeLists.txt41
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp121
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h134
-rw-r--r--source/gameengine/Physics/common/PHY_DynamicTypes.h91
-rw-r--r--source/gameengine/Physics/common/PHY_ICharacter.h39
-rw-r--r--source/gameengine/Physics/common/PHY_IController.h63
-rw-r--r--source/gameengine/Physics/common/PHY_IGraphicController.h60
-rw-r--r--source/gameengine/Physics/common/PHY_IMotionState.h68
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsController.h154
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h226
-rw-r--r--source/gameengine/Physics/common/PHY_IVehicle.h69
-rw-r--r--source/gameengine/Physics/common/PHY_Pro.h68
-rw-r--r--source/gameengine/Rasterizer/CMakeLists.txt92
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.cpp562
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.h114
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.cpp380
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.h93
-rw-r--r--source/gameengine/Rasterizer/RAS_CameraData.h79
-rw-r--r--source/gameengine/Rasterizer/RAS_Deformer.h103
-rw-r--r--source/gameengine/Rasterizer/RAS_FramingManager.cpp425
-rw-r--r--source/gameengine/Rasterizer/RAS_FramingManager.h316
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.cpp128
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.h287
-rw-r--r--source/gameengine/Rasterizer/RAS_ILightObject.h95
-rw-r--r--source/gameengine/Rasterizer/RAS_IOffScreen.h84
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp292
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.h206
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h506
-rw-r--r--source/gameengine/Rasterizer/RAS_ISync.h48
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.cpp679
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.h267
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.cpp573
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.h161
-rw-r--r--source/gameengine/Rasterizer/RAS_ObjectColor.h41
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h55
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h55
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h54
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h45
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h45
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h57
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h62
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h45
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h55
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h61
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt72
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h56
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp278
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h77
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp300
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.h56
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.cpp347
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.h65
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp1694
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h343
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.cpp82
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.h50
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp260
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h77
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp227
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h100
-rw-r--r--source/gameengine/Rasterizer/RAS_Polygon.cpp123
-rw-r--r--source/gameengine/Rasterizer/RAS_Polygon.h101
-rw-r--r--source/gameengine/Rasterizer/RAS_Rect.h104
-rw-r--r--source/gameengine/Rasterizer/RAS_TexMatrix.h42
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.cpp164
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.h146
-rw-r--r--source/gameengine/Rasterizer/RAS_texmatrix.cpp131
-rw-r--r--source/gameengine/SceneGraph/CMakeLists.txt53
-rw-r--r--source/gameengine/SceneGraph/SG_BBox.cpp262
-rw-r--r--source/gameengine/SceneGraph/SG_BBox.h143
-rw-r--r--source/gameengine/SceneGraph/SG_Controller.cpp46
-rw-r--r--source/gameengine/SceneGraph/SG_Controller.h124
-rw-r--r--source/gameengine/SceneGraph/SG_DList.h251
-rw-r--r--source/gameengine/SceneGraph/SG_IObject.cpp111
-rw-r--r--source/gameengine/SceneGraph/SG_IObject.h374
-rw-r--r--source/gameengine/SceneGraph/SG_Node.cpp227
-rw-r--r--source/gameengine/SceneGraph/SG_Node.h278
-rw-r--r--source/gameengine/SceneGraph/SG_ParentRelation.h139
-rw-r--r--source/gameengine/SceneGraph/SG_QList.h164
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.cpp217
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.h294
-rw-r--r--source/gameengine/SceneGraph/SG_Tree.cpp422
-rw-r--r--source/gameengine/SceneGraph/SG_Tree.h163
-rw-r--r--source/gameengine/VideoTexture/BlendType.h86
-rw-r--r--source/gameengine/VideoTexture/CMakeLists.txt119
-rw-r--r--source/gameengine/VideoTexture/Common.h64
-rw-r--r--source/gameengine/VideoTexture/DeckLink.cpp813
-rw-r--r--source/gameengine/VideoTexture/DeckLink.h86
-rw-r--r--source/gameengine/VideoTexture/Exception.cpp241
-rw-r--r--source/gameengine/VideoTexture/Exception.h239
-rw-r--r--source/gameengine/VideoTexture/FilterBase.cpp160
-rw-r--r--source/gameengine/VideoTexture/FilterBase.h161
-rw-r--r--source/gameengine/VideoTexture/FilterBlueScreen.cpp190
-rw-r--r--source/gameengine/VideoTexture/FilterBlueScreen.h105
-rw-r--r--source/gameengine/VideoTexture/FilterColor.cpp354
-rw-r--r--source/gameengine/VideoTexture/FilterColor.h176
-rw-r--r--source/gameengine/VideoTexture/FilterNormal.cpp173
-rw-r--r--source/gameengine/VideoTexture/FilterNormal.h115
-rw-r--r--source/gameengine/VideoTexture/FilterSource.cpp176
-rw-r--r--source/gameengine/VideoTexture/FilterSource.h352
-rw-r--r--source/gameengine/VideoTexture/ImageBase.cpp834
-rw-r--r--source/gameengine/VideoTexture/ImageBase.h392
-rw-r--r--source/gameengine/VideoTexture/ImageBuff.cpp424
-rw-r--r--source/gameengine/VideoTexture/ImageBuff.h69
-rw-r--r--source/gameengine/VideoTexture/ImageMix.cpp216
-rw-r--r--source/gameengine/VideoTexture/ImageMix.h131
-rw-r--r--source/gameengine/VideoTexture/ImageRender.cpp946
-rw-r--r--source/gameengine/VideoTexture/ImageRender.h125
-rw-r--r--source/gameengine/VideoTexture/ImageViewport.cpp467
-rw-r--r--source/gameengine/VideoTexture/ImageViewport.h113
-rw-r--r--source/gameengine/VideoTexture/PyTypeList.cpp97
-rw-r--r--source/gameengine/VideoTexture/PyTypeList.h100
-rw-r--r--source/gameengine/VideoTexture/Texture.cpp533
-rw-r--r--source/gameengine/VideoTexture/Texture.h99
-rw-r--r--source/gameengine/VideoTexture/VideoBase.cpp254
-rw-r--r--source/gameengine/VideoTexture/VideoBase.h207
-rw-r--r--source/gameengine/VideoTexture/VideoDeckLink.cpp1228
-rw-r--r--source/gameengine/VideoTexture/VideoDeckLink.h256
-rw-r--r--source/gameengine/VideoTexture/VideoFFmpeg.cpp1392
-rw-r--r--source/gameengine/VideoTexture/VideoFFmpeg.h219
-rw-r--r--source/gameengine/VideoTexture/blendVideoTex.cpp266
m---------source/tools0
-rw-r--r--tests/gtests/alembic/abc_export_test.cc11
-rw-r--r--tests/gtests/blenlib/BLI_linklist_lockfree_test.cc130
-rw-r--r--tests/gtests/blenlib/CMakeLists.txt1
-rw-r--r--tests/python/bl_rst_completeness.py19
-rw-r--r--tests/python/collada/CMakeLists.txt6
-rw-r--r--tests/python/view_layer/view_layer_common.py2
1636 files changed, 19994 insertions, 305016 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0699c49a053..8a45cce83f8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -165,7 +165,6 @@ option_defaults_init(
_init_OPENCOLORIO
_init_SDL
_init_FFTW3
- _init_GAMEENGINE
_init_OPENSUBDIV
)
@@ -235,13 +234,6 @@ option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke, ocean sim, and
option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
mark_as_advanced(WITH_SYSTEM_BULLET)
-option(WITH_GAMEENGINE "Enable Game Engine" ${_init_GAMEENGINE})
-if(APPLE)
- set(WITH_GAMEENGINE_DECKLINK OFF)
-else()
- option(WITH_GAMEENGINE_DECKLINK "Support BlackMagicDesign DeckLink cards in the Game Engine" ON)
-endif()
-option(WITH_PLAYER "Build Player" OFF)
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
option(WITH_CLAY_ENGINE "Enable Clay engine" ON)
@@ -580,17 +572,13 @@ endif()
#-----------------------------------------------------------------------------
# Check for conflicting/unsupported configurations
-if(NOT WITH_BLENDER AND NOT WITH_PLAYER AND NOT WITH_CYCLES_STANDALONE)
+if(NOT WITH_BLENDER AND NOT WITH_CYCLES_STANDALONE)
message(FATAL_ERROR
- "At least one of WITH_BLENDER or WITH_PLAYER or "
- "WITH_CYCLES_STANDALONE must be enabled, nothing to do!"
+ "At least one of WITH_BLENDER or WITH_CYCLES_STANDALONE "
+ "must be enabled, nothing to do!"
)
endif()
-if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
- message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
-endif()
-
if(NOT WITH_CXX11)
if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
message(FATAL_ERROR "WITH_AUDASPACE requires WITH_CXX11")
@@ -604,9 +592,6 @@ if(NOT WITH_AUDASPACE)
if(WITH_JACK)
message(FATAL_ERROR "WITH_JACK requires WITH_AUDASPACE")
endif()
- if(WITH_GAMEENGINE)
- message(FATAL_ERROR "WITH_GAMEENGINE requires WITH_AUDASPACE")
- endif()
endif()
if(NOT WITH_SDL AND WITH_GHOST_SDL)
@@ -614,10 +599,6 @@ if(NOT WITH_SDL AND WITH_GHOST_SDL)
endif()
# python module, needs some different options
-if(WITH_PYTHON_MODULE AND WITH_PLAYER)
- message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PLAYER to be OFF")
-endif()
-
if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
endif()
@@ -1583,7 +1564,7 @@ if(WITH_GTESTS)
include(GTestTesting)
endif()
-if(WITH_BLENDER OR WITH_PLAYER)
+if(WITH_BLENDER)
add_subdirectory(intern)
add_subdirectory(extern)
@@ -1609,13 +1590,6 @@ endif()
#-----------------------------------------------------------------------------
-# Blender Player
-if(WITH_PLAYER)
- add_subdirectory(source/blenderplayer)
-endif()
-
-
-#-----------------------------------------------------------------------------
# Testing
add_subdirectory(tests)
@@ -1629,9 +1603,6 @@ include(build_files/cmake/packaging.cmake)
if(WITH_BLENDER)
openmp_delayload(blender)
endif()
-if(WITH_PLAYER)
- openmp_delayload(blenderplayer)
-endif()
#-----------------------------------------------------------------------------
# Print Final Configuration
@@ -1665,8 +1636,6 @@ if(FIRST_RUN)
message(STATUS "C++ Compiler: \"${CMAKE_CXX_COMPILER_ID}\"")
info_cfg_text("Build Options:")
- info_cfg_option(WITH_GAMEENGINE)
- info_cfg_option(WITH_PLAYER)
info_cfg_option(WITH_BULLET)
info_cfg_option(WITH_IK_SOLVER)
info_cfg_option(WITH_IK_ITASC)
diff --git a/build_files/buildbot/config/blender_linux.cmake b/build_files/buildbot/config/blender_linux.cmake
index 22e88a82ffd..43f2ff7239d 100644
--- a/build_files/buildbot/config/blender_linux.cmake
+++ b/build_files/buildbot/config/blender_linux.cmake
@@ -21,9 +21,8 @@ else()
message(FATAL_ERROR "Unknown build environment")
endif()
-# Default to only build Blender, not the player
+# Default to only build Blender
set(WITH_BLENDER ON CACHE BOOL "" FORCE)
-set(WITH_PLAYER OFF CACHE BOOL "" FORCE)
# ######## Linux-specific build options ########
# Options which are specific to Linux-only platforms
diff --git a/build_files/buildbot/config/blender_linux_player.cmake b/build_files/buildbot/config/blender_linux_player.cmake
deleted file mode 100644
index 69ab984e386..00000000000
--- a/build_files/buildbot/config/blender_linux_player.cmake
+++ /dev/null
@@ -1,12 +0,0 @@
-# This is applied as an override on top of blender_linux.config
-# Disables all the areas which are not needed for the player.
-set(WITH_COMPOSITOR OFF CACHE BOOL "" FORCE)
-set(WITH_CYCLES OFF CACHE BOOL "" FORCE)
-set(WITH_FREESTYLE OFF CACHE BOOL "" FORCE)
-set(WITH_GHOST_XDND OFF CACHE BOOL "" FORCE)
-set(WITH_OPENCOLLADA OFF CACHE BOOL "" FORCE)
-set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
-set(WITH_LIBMV OFF CACHE BOOL "" FORCE)
-
-set(WITH_BLENDER OFF CACHE BOOL "" FORCE)
-set(WITH_PLAYER ON CACHE BOOL "" FORCE)
diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py
index ff19bcce758..43964dda691 100644
--- a/build_files/buildbot/slave_compile.py
+++ b/build_files/buildbot/slave_compile.py
@@ -60,7 +60,6 @@ if 'cmake' in builder:
# Config file to be used (relative to blender's sources root)
cmake_config_file = "build_files/cmake/config/blender_full.cmake"
- cmake_player_config_file = None
cmake_cuda_config_file = None
# Set build options.
@@ -101,14 +100,13 @@ if 'cmake' in builder:
elif glibc == 'glibc211':
deb_name = "squeeze"
cmake_config_file = "build_files/buildbot/config/blender_linux.cmake"
- cmake_player_config_file = "build_files/buildbot/config/blender_linux_player.cmake"
if builder.endswith('x86_64_cmake'):
chroot_name = 'buildbot_' + deb_name + '_x86_64'
- targets = ['player', 'blender']
+ targets = ['blender']
elif builder.endswith('i686_cmake'):
bits = 32
chroot_name = 'buildbot_' + deb_name + '_i686'
- targets = ['player', 'blender']
+ targets = ['blender']
cmake_extra_options.extend(["-DCMAKE_C_COMPILER=/usr/bin/gcc-7",
"-DCMAKE_CXX_COMPILER=/usr/bin/g++-7"])
@@ -159,9 +157,7 @@ if 'cmake' in builder:
os.chdir(target_build_dir)
# Tweaking CMake options to respect the target
target_cmake_options = cmake_options[:]
- if target == 'player':
- target_cmake_options.append("-C" + os.path.join(blender_dir, cmake_player_config_file))
- elif target == 'cuda':
+ if target == 'cuda':
target_cmake_options += cuda_cmake_options
target_chroot_prefix = cuda_chroot_prefix[:]
target_name = 'cycles_kernel_cuda'
diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py
index a0b5e8c6517..22cf386c77a 100644
--- a/build_files/buildbot/slave_pack.py
+++ b/build_files/buildbot/slave_pack.py
@@ -126,7 +126,6 @@ if builder.find('cmake') != -1:
elif builder.startswith('linux_'):
blender = os.path.join(install_dir, 'blender')
- blenderplayer = os.path.join(install_dir, 'blenderplayer')
buildinfo_h = os.path.join(build_dir, "source", "creator", "buildinfo.h")
blender_h = os.path.join(blender_dir, "source", "blender", "blenkernel", "BKE_blender_version.h")
@@ -149,7 +148,7 @@ if builder.find('cmake') != -1:
# Strip all unused symbols from the binaries
print("Stripping binaries...")
chroot_prefix = ['schroot', '-c', chroot_name, '--']
- subprocess.call(chroot_prefix + ['strip', '--strip-all', blender, blenderplayer])
+ subprocess.call(chroot_prefix + ['strip', '--strip-all', blender])
print("Stripping python...")
py_target = os.path.join(install_dir, blender_version)
diff --git a/build_files/cmake/config/blender_full.cmake b/build_files/cmake/config/blender_full.cmake
index c896c0452b3..635484633c2 100644
--- a/build_files/cmake/config/blender_full.cmake
+++ b/build_files/cmake/config/blender_full.cmake
@@ -16,7 +16,6 @@ set(WITH_CYCLES_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
-set(WITH_GAMEENGINE ON CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR ON CACHE BOOL "" FORCE)
set(WITH_FREESTYLE ON CACHE BOOL "" FORCE)
set(WITH_GHOST_XDND ON CACHE BOOL "" FORCE)
@@ -51,7 +50,6 @@ set(WITH_SDL ON CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT ON CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
-set(WITH_PLAYER ON CACHE BOOL "" FORCE)
set(WITH_MEM_JEMALLOC ON CACHE BOOL "" FORCE)
diff --git a/build_files/cmake/config/blender_headless.cmake b/build_files/cmake/config/blender_headless.cmake
index cfde86aac6d..8f2ad03279c 100644
--- a/build_files/cmake/config/blender_headless.cmake
+++ b/build_files/cmake/config/blender_headless.cmake
@@ -6,7 +6,6 @@
#
set(WITH_HEADLESS ON CACHE BOOL "" FORCE)
-set(WITH_GAMEENGINE OFF CACHE BOOL "" FORCE)
# disable audio, its possible some devs may want this but for now disable
# so the python module doesnt hold the audio device and loads quickly.
diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake
index 1a5e6a3158a..5aa0f4f4bf1 100644
--- a/build_files/cmake/config/blender_lite.cmake
+++ b/build_files/cmake/config/blender_lite.cmake
@@ -21,7 +21,6 @@ set(WITH_CYCLES_OPENSUBDIV OFF CACHE BOOL "" FORCE)
set(WITH_FFTW3 OFF CACHE BOOL "" FORCE)
set(WITH_LIBMV OFF CACHE BOOL "" FORCE)
set(WITH_LLVM OFF CACHE BOOL "" FORCE)
-set(WITH_GAMEENGINE OFF CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR OFF CACHE BOOL "" FORCE)
set(WITH_FREESTYLE OFF CACHE BOOL "" FORCE)
set(WITH_GHOST_XDND OFF CACHE BOOL "" FORCE)
diff --git a/build_files/cmake/config/blender_release.cmake b/build_files/cmake/config/blender_release.cmake
index 26267fd314a..a21c0d43b66 100644
--- a/build_files/cmake/config/blender_release.cmake
+++ b/build_files/cmake/config/blender_release.cmake
@@ -16,7 +16,6 @@ set(WITH_CYCLES_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
-set(WITH_GAMEENGINE ON CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR ON CACHE BOOL "" FORCE)
set(WITH_FREESTYLE ON CACHE BOOL "" FORCE)
set(WITH_GHOST_XDND ON CACHE BOOL "" FORCE)
@@ -51,7 +50,6 @@ set(WITH_SDL ON CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT ON CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
-set(WITH_PLAYER ON CACHE BOOL "" FORCE)
set(WITH_MEM_JEMALLOC ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_CUDA_BINARIES ON CACHE BOOL "" FORCE)
set(CYCLES_CUDA_BINARIES_ARCH sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61 CACHE STRING "" FORCE)
diff --git a/build_files/cmake/config/bpy_module.cmake b/build_files/cmake/config/bpy_module.cmake
index 854d6e49370..2371d3f0d76 100644
--- a/build_files/cmake/config/bpy_module.cmake
+++ b/build_files/cmake/config/bpy_module.cmake
@@ -12,9 +12,6 @@ set(WITH_INSTALL_PORTABLE OFF CACHE BOOL "" FORCE)
# no point int copying python into python
set(WITH_PYTHON_INSTALL OFF CACHE BOOL "" FORCE)
-# dont build the game engine
-set(WITH_GAMEENGINE OFF CACHE BOOL "" FORCE)
-
# disable audio, its possible some devs may want this but for now disable
# so the python module doesnt hold the audio device and loads quickly.
set(WITH_AUDASPACE OFF CACHE BOOL "" FORCE)
diff --git a/build_files/cmake/config/cycles_standalone.cmake b/build_files/cmake/config/cycles_standalone.cmake
index 45f9c100f93..1b12f4de23f 100644
--- a/build_files/cmake/config/cycles_standalone.cmake
+++ b/build_files/cmake/config/cycles_standalone.cmake
@@ -6,7 +6,6 @@
# disable Blender
set(WITH_BLENDER OFF CACHE BOOL "" FORCE)
-set(WITH_PLAYER OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_BLENDER OFF CACHE BOOL "" FORCE)
# build Cycles
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 8f46dc3fc40..6da3c56a8d2 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -583,6 +583,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_editor_space_sequencer
bf_editor_space_text
bf_editor_space_time
+ bf_editor_space_topbar
bf_editor_space_userpref
bf_editor_space_view3d
bf_editor_space_clip
@@ -761,10 +762,6 @@ function(SETUP_BLENDER_SORTED_LIBS)
list_insert_after(BLENDER_SORTED_LIBS "ge_logic_ngnetwork" "extern_bullet")
endif()
- if(WITH_GAMEENGINE_DECKLINK)
- list(APPEND BLENDER_SORTED_LIBS bf_intern_decklink)
- endif()
-
if(WIN32)
list(APPEND BLENDER_SORTED_LIBS bf_intern_gpudirect)
endif()
diff --git a/doc/doxygen/doxygen.source.h b/doc/doxygen/doxygen.source.h
index 6f159bb74df..69271e68e79 100644
--- a/doc/doxygen/doxygen.source.h
+++ b/doc/doxygen/doxygen.source.h
@@ -36,62 +36,6 @@
/* ================================ */
-/** \defgroup bge Game Engine */
-/** \defgroup gamelogic Game Logic
- * \ingroup bge
- */
-/** \defgroup bgeconv Converter
- * \ingroup bge
- */
-/** \defgroup blroutines Blender Routines
- * \ingroup bge
- */
-/** \defgroup expressions Expressions
- * \ingroup bge
- */
-/** \defgroup player Game Player
- * \ingroup bge
- */
-/** \defgroup ketsji Ketsji
- * \ingroup bge
- * \todo check all headers and code files for proper licenses
- */
-/** \defgroup ketsjinet Ketsji Network
- * \ingroup ketsji
- */
-/** \defgroup bgenet Network
- * \ingroup bge
- */
-/** \defgroup bgenetlb Loopback Network
- * \ingroup bgenet
- */
-/** \defgroup phys Physics
- * \ingroup bge
- */
-/** \defgroup physbullet Bullet Physics
- * \ingroup phys
- */
-/** \defgroup physdummy Dummy Physics (none)
- * \ingroup phys
- */
-/** \defgroup bgerast Rasterizer
- * \ingroup bge
- */
-/** \defgroup bgerastoglfilters OpenGL Filters
- * \ingroup bgerast
- */
-/** \defgroup bgerastogl OpenGL Rasterizer
- * \ingroup bgerast
- */
-/** \defgroup bgesg BGE SceneGraph
- * \ingroup bge
- */
-/** \defgroup bgevideotex BGE Video Texture
- * \ingroup bge
- */
-
-/* ================================ */
-
/** \defgroup blender Blender */
/** \defgroup blt BlenTranslation
@@ -268,10 +212,6 @@
* \ingroup editors
*/
-/** \defgroup splogic game logic editor
- * \ingroup editors
- */
-
/** \defgroup spnla NLA editor
* \ingroup editors
*/
diff --git a/doc/python_api/examples/bge.constraints.py b/doc/python_api/examples/bge.constraints.py
deleted file mode 100644
index c617ac0622b..00000000000
--- a/doc/python_api/examples/bge.constraints.py
+++ /dev/null
@@ -1,37 +0,0 @@
-"""
-Basic Physics Constraint
-++++++++++++++++++++++++
-Example of how to create a hinge Physics Constraint between two objects.
-"""
-from bge import logic
-from bge import constraints
-
-# get object list
-objects = logic.getCurrentScene().objects
-
-# get object named Object1 and Object 2
-object_1 = objects["Object1"]
-object_2 = objects["Object2"]
-
-# want to use Edge constraint type
-constraint_type = 2
-
-# get Object1 and Object2 physics IDs
-physics_id_1 = object_1.getPhysicsId()
-physics_id_2 = object_2.getPhysicsId()
-
-# use bottom right edge of Object1 for hinge position
-edge_position_x = 1.0
-edge_position_y = 0.0
-edge_position_z = -1.0
-
-# rotate the pivot z axis about 90 degrees
-edge_angle_x = 0.0
-edge_angle_y = 0.0
-edge_angle_z = 90.0
-
-# create an edge constraint
-constraints.createConstraint(physics_id_1, physics_id_2,
- constraint_type,
- edge_position_x, edge_position_y, edge_position_z,
- edge_angle_x, edge_angle_y, edge_angle_z)
diff --git a/doc/python_api/examples/bge.texture.1.py b/doc/python_api/examples/bge.texture.1.py
deleted file mode 100644
index 732c786c667..00000000000
--- a/doc/python_api/examples/bge.texture.1.py
+++ /dev/null
@@ -1,40 +0,0 @@
-"""
-Texture Replacement
-+++++++++++++++++++
-
-Example of how to replace a texture in game with an external image.
-``createTexture()`` and ``removeTexture()`` are to be called from a
-module Python Controller.
-"""
-from bge import logic
-from bge import texture
-
-
-def createTexture(cont):
- """Create a new Dynamic Texture"""
- obj = cont.owner
-
- # get the reference pointer (ID) of the internal texture
- ID = texture.materialID(obj, 'IMoriginal.png')
-
- # create a texture object
- object_texture = texture.Texture(obj, ID)
-
- # create a new source with an external image
- url = logic.expandPath("//newtexture.jpg")
- new_source = texture.ImageFFmpeg(url)
-
- # the texture has to be stored in a permanent Python object
- logic.texture = object_texture
-
- # update/replace the texture
- logic.texture.source = new_source
- logic.texture.refresh(False)
-
-
-def removeTexture(cont):
- """Delete the Dynamic Texture, reversing back the final to its original state."""
- try:
- del logic.texture
- except:
- pass
diff --git a/doc/python_api/examples/bge.texture.2.py b/doc/python_api/examples/bge.texture.2.py
deleted file mode 100644
index 96619007fba..00000000000
--- a/doc/python_api/examples/bge.texture.2.py
+++ /dev/null
@@ -1,237 +0,0 @@
-"""
-Video Capture with DeckLink
-+++++++++++++++++++++++++++
-Video frames captured with DeckLink cards have pixel formats that are generally not directly
-usable by OpenGL, they must be processed by a shader. The three shaders presented here should
-cover all common video capture cases.
-
-This file reflects the current video transfer method implemented in the Decklink module:
-whenever possible the video images are transferred as float texture because this is more
-compatible with GPUs. Of course, only the pixel formats that have a correspondant GL format
-can be transferred as float. Look for fg_shaders in this file for an exhaustive list.
-
-Other pixel formats will be transferred as 32 bits integer red-channel texture but this
-won't work with certain GPU (Intel GMA); the corresponding shaders are not shown here.
-However, it should not be necessary to use any of them as the list below covers all practical
-cases of video capture with all types of Decklink product.
-
-In other words, only use one of the pixel format below and you will be fine. Note that depending
-on the video stream, only certain pixel formats will be allowed (others will throw an exception).
-For example, to capture a PAL video stream, you must use one of the YUV formats.
-
-To find which pixel format is suitable for a particular video stream, use the 'Media Express'
-utility that comes with the Decklink software : if you see the video in the 'Log and Capture'
-Window, you have selected the right pixel format and you can use the same in Blender.
-
-Notes: * these shaders only decode the RGB channel and set the alpha channel to a fixed
-value (look for color.a = ). It's up to you to add postprocessing to the color.
- * these shaders are compatible with 2D and 3D video stream
-"""
-import bge
-from bge import logic
-from bge import texture as vt
-
-# The default vertex shader, because we need one
-#
-VertexShader = """
-#version 130
- void main()
- {
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- gl_TexCoord[0] = gl_MultiTexCoord0;
- }
-
-"""
-
-# For use with RGB video stream: the pixel is directly usable
-#
-FragmentShader_R10l = """
- #version 130
- uniform sampler2D tex;
- // stereo = 1.0 if 2D image, =0.5 if 3D (left eye below, right eye above)
- uniform float stereo;
- // eye = 0.0 for the left eye, 0.5 for the right eye
- uniform float eye;
-
- void main(void)
- {
- vec4 color;
- float tx, ty;
- tx = gl_TexCoord[0].x;
- ty = eye+gl_TexCoord[0].y*stereo;
- color = texture(tex, vec2(tx,ty));
- color.a = 0.7;
- gl_FragColor = color;
- }
-"""
-
-# For use with YUV video stream
-#
-FragmentShader_2vuy = """
- #version 130
- uniform sampler2D tex;
- // stereo = 1.0 if 2D image, =0.5 if 3D (left eye below, right eye above)
- uniform float stereo;
- // eye = 0.0 for the left eye, 0.5 for the right eye
- uniform float eye;
-
- void main(void)
- {
- vec4 color;
- float tx, ty, width, Y, Cb, Cr;
- int px;
- tx = gl_TexCoord[0].x;
- ty = eye+gl_TexCoord[0].y*stereo;
- width = float(textureSize(tex, 0).x);
- color = texture(tex, vec2(tx, ty));
- px = int(floor(fract(tx*width)*2.0));
- switch (px) {
- case 0:
- Y = color.g;
- break;
- case 1:
- Y = color.a;
- break;
- }
- Y = (Y - 0.0625) * 1.168949772;
- Cb = (color.b - 0.0625) * 1.142857143 - 0.5;
- Cr = (color.r - 0.0625) * 1.142857143 - 0.5;
- color.r = Y + 1.5748 * Cr;
- color.g = Y - 0.1873 * Cb - 0.4681 * Cr;
- color.b = Y + 1.8556 * Cb;
- color.a = 0.7;
- gl_FragColor = color;
- }
-"""
-
-# For use with high resolution YUV
-#
-FragmentShader_v210 = """
- #version 130
- uniform sampler2D tex;
- // stereo = 1.0 if 2D image, =0.5 if 3D (left eye below, right eye above)
- uniform float stereo;
- // eye = 0.0 for the left eye, 0.5 for the right eye
- uniform float eye;
-
- void main(void)
- {
- vec4 color, color1, color2, color3;
- int px;
- float tx, ty, width, sx, dx, bx, Y, Cb, Cr;
- tx = gl_TexCoord[0].x;
- ty = eye+gl_TexCoord[0].y*stereo;
- width = float(textureSize(tex, 0).x);
- // to sample macro pixels (6 pixels in 4 words)
- sx = tx*width*0.25+0.01;
- // index of display pixel in the macro pixel 0..5
- px = int(floor(fract(sx)*6.0));
- // increment as we sample the macro pixel
- dx = 1.0/width;
- // base x coord of macro pixel
- bx = (floor(sx)+0.01)*dx*4.0;
- color = texture(tex, vec2(bx, ty));
- color1 = texture(tex, vec2(bx+dx, ty));
- color2 = texture(tex, vec2(bx+dx*2.0, ty));
- color3 = texture(tex, vec2(bx+dx*3.0, ty));
- switch (px) {
- case 0:
- case 1:
- Cb = color.b;
- Cr = color.r;
- break;
- case 2:
- case 3:
- Cb = color1.g;
- Cr = color2.b;
- break;
- default:
- Cb = color2.r;
- Cr = color3.g;
- break;
- }
- switch (px) {
- case 0:
- Y = color.g;
- break;
- case 1:
- Y = color1.b;
- break;
- case 2:
- Y = color1.r;
- break;
- case 3:
- Y = color2.g;
- break;
- case 4:
- Y = color3.b;
- break;
- default:
- Y = color3.r;
- break;
- }
- Y = (Y - 0.0625) * 1.168949772;
- Cb = (Cb - 0.0625) * 1.142857143 - 0.5;
- Cr = (Cr - 0.0625) * 1.142857143 - 0.5;
- color.r = Y + 1.5748 * Cr;
- color.g = Y - 0.1873 * Cb - 0.4681 * Cr;
- color.b = Y + 1.8556 * Cb;
- color.a = 0.7;
- gl_FragColor = color;
- }
-"""
-
-# The exhausitve list of pixel formats that are transferred as float texture
-# Only use those for greater efficiency and compatiblity.
-#
-fg_shaders = {
- '2vuy' :FragmentShader_2vuy,
- '8BitYUV' :FragmentShader_2vuy,
- 'v210' :FragmentShader_v210,
- '10BitYUV' :FragmentShader_v210,
- '8BitBGRA' :FragmentShader_R10l,
- 'BGRA' :FragmentShader_R10l,
- '8BitARGB' :FragmentShader_R10l,
- '10BitRGBXLE':FragmentShader_R10l,
- 'R10l' :FragmentShader_R10l
- }
-
-
-#
-# Helper function to attach a pixel shader to the material that receives the video frame.
-#
-
-def config_video(obj, format, pixel, is3D=False, mat=0, card=0):
- if pixel not in fg_shaders:
- raise('Unsuported shader')
- shader = obj.meshes[0].materials[mat].getShader()
- if shader is not None and not shader.isValid():
- shader.setSource(VertexShader, fg_shaders[pixel], True)
- shader.setSampler('tex', 0)
- shader.setUniformEyef("eye")
- shader.setUniform1f("stereo", 0.5 if is3D else 1.0)
- tex = vt.Texture(obj, mat)
- tex.source = vt.VideoDeckLink(format + "/" + pixel + ("/3D" if is3D else ""), card)
- print("frame rate: ", tex.source.framerate)
- tex.source.play()
- obj["video"] = tex
-
-#
-# Attach this function to an object that has a material with texture
-# and call it once to initialize the object
-#
-def init(cont):
- # config_video(cont.owner, 'HD720p5994', '8BitBGRA')
- # config_video(cont.owner, 'HD720p5994', '8BitYUV')
- # config_video(cont.owner, 'pal ', '10BitYUV')
- config_video(cont.owner, 'pal ', '8BitYUV')
-
-
-#
-# To be called on every frame
-#
-def play(cont):
- obj = cont.owner
- video = obj.get("video")
- if video is not None:
- video.refresh(True)
diff --git a/doc/python_api/examples/bge.texture.py b/doc/python_api/examples/bge.texture.py
deleted file mode 100644
index 8b24530b10a..00000000000
--- a/doc/python_api/examples/bge.texture.py
+++ /dev/null
@@ -1,46 +0,0 @@
-"""
-Basic Video Playback
-++++++++++++++++++++
-Example of how to replace a texture in game with a video.
-It needs to run everyframe.
-To avoid any confusion with the location of the file,
-we will use ``GameLogic.expandPath()`` to build an absolute file name,
-assuming the video file is in the same directory as the blend-file.
-"""
-import bge
-from bge import texture
-from bge import logic
-
-cont = logic.getCurrentController()
-obj = cont.owner
-
-# the creation of the texture must be done once: save the
-# texture object in an attribute of bge.logic module makes it persistent
-if not hasattr(logic, 'video'):
-
- # identify a static texture by name
- matID = texture.materialID(obj, 'IMvideo.png')
-
- # create a dynamic texture that will replace the static texture
- logic.video = texture.Texture(obj, matID)
-
- # define a source of image for the texture, here a movie
- movie = logic.expandPath('//trailer_400p.ogg')
- logic.video.source = texture.VideoFFmpeg(movie)
- logic.video.source.scale = True
-
- # Note that we can change the ``Texture`` source at any time.
- # Suppose we want to switch between two movies during the game:
- logic.mySources[0] = texture.VideoFFmpeg('movie1.avi')
- logic.mySources[1] = texture.VideoFFmpeg('movie2.avi')
-
- #And then assign (and reassign) the source during the game
- logic.video.source = logic.mySources[movieSel]
-
- # quick off the movie, but it wont play in the background
- logic.video.source.play()
-
-
-# Video playback is not a background process: it happens only when we refresh the texture.
-# So you need to call this function every frame to ensure update of the texture.
-logic.video.refresh(True)
diff --git a/doc/python_api/examples/blf.py b/doc/python_api/examples/blf.py
index f6e87cf488d..e288ac9db66 100644
--- a/doc/python_api/examples/blf.py
+++ b/doc/python_api/examples/blf.py
@@ -2,43 +2,44 @@
Hello World Text Example
++++++++++++++++++++++++
-Blender Game Engine example of using the blf module. For this module to work we
+Example of using the blf module. For this module to work we
need to use the OpenGL wrapper :class:`~bgl` as well.
"""
-# import game engine modules
-from bge import render
-from bge import logic
# import stand alone modules
import bgl
import blf
+import bpy
+font_info = {
+ "font_id": 0,
+ "handler": None,
+}
def init():
"""init function - runs once"""
- # create a new font object, use external ttf file
- font_path = logic.expandPath('//Zeyada.ttf')
- # store the font indice - to use later
- logic.font_id = blf.load(font_path)
+ import os
+ # Create a new font object, use external ttf file.
+ font_path = bpy.path.abspath('//Zeyada.ttf')
+ # Store the font indice - to use later.
+ if os.path.exists(font_path):
+ font_info["font_id"] = blf.load(font_path)
+ else:
+ # Default font.
+ font_info["font_id"] = 0
# set the font drawing routine to run every frame
- scene = logic.getCurrentScene()
- scene.post_draw = [write]
+ font_info["handler"] = bpy.types.SpaceView3D.draw_handler_add(
+ draw_callback_px, (None, None), 'WINDOW', 'POST_PIXEL')
-def write():
- """write on screen"""
- width = render.getWindowWidth()
- height = render.getWindowHeight()
-
- # OpenGL setup
- bgl.glMatrixMode(bgl.GL_PROJECTION)
- bgl.glLoadIdentity()
- bgl.gluOrtho2D(0, width, 0, height)
- bgl.glMatrixMode(bgl.GL_MODELVIEW)
- bgl.glLoadIdentity()
-
+def draw_callback_px(self, context):
+ """Draw on the viewports"""
# BLF drawing routine
- font_id = logic.font_id
- blf.position(font_id, (width * 0.2), (height * 0.3), 0)
+ font_id = font_info["font_id"]
+ blf.position(font_id, 2, 80, 0)
blf.size(font_id, 50, 72)
blf.draw(font_id, "Hello World")
+
+
+if __name__ == '__main__':
+ init()
diff --git a/doc/python_api/rst/bge.app.rst b/doc/python_api/rst/bge.app.rst
deleted file mode 100644
index e8b91ffbcaf..00000000000
--- a/doc/python_api/rst/bge.app.rst
+++ /dev/null
@@ -1,49 +0,0 @@
-
-Application Data (bge.app)
-==========================
-
-Module to access application values that remain unchanged during runtime.
-
-.. module:: bge.app
-
-.. data:: version
-
- The Blender/BGE version as a tuple of 3 ints, eg. (2, 75, 1).
-
- .. note::
-
- Version tuples can be compared simply with (in)equality symbols;
- for example, ``(2, 74, 5) <= (2, 75, 0)`` returns True (lexical order).
-
- :type: tuple of three ints
-
-.. data:: version_string
-
- The Blender/BGE version formatted as a string, eg. "2.75 (sub 1)".
-
- :type: str
-
-.. data:: version_char
-
- The Blender/BGE version character (for minor releases).
-
- :type: str
-
-.. data:: has_texture_ffmpeg
-
- True if the BGE has been built with FFmpeg support,
- enabling use of :class:`~bge.texture.ImageFFmpeg` and :class:`~bge.texture.VideoFFmpeg`.
-
- :type: bool
-
-.. data:: has_joystick
-
- True if the BGE has been built with joystick support.
-
- :type: bool
-
-.. data:: has_physics
-
- True if the BGE has been built with physics support.
-
- :type: bool
diff --git a/doc/python_api/rst/bge.constraints.rst b/doc/python_api/rst/bge.constraints.rst
deleted file mode 100644
index ed965c3dfc1..00000000000
--- a/doc/python_api/rst/bge.constraints.rst
+++ /dev/null
@@ -1,336 +0,0 @@
-
-Physics Constraints (bge.constraints)
-=====================================
-
-.. module:: bge.constraints
-
-
-Examples
---------
-
-.. include:: __/examples/bge.constraints.py
- :start-line: 1
- :end-line: 4
-
-.. literalinclude:: __/examples/bge.constraints.py
- :lines: 6-
-
-
-Functions
----------
-
-.. function:: createConstraint( \
- physicsid_1, physicsid_2, constraint_type, \
- pivot_x=0.0, pivot_y=0.0, pivot_z=0.0, \
- axis_x=0.0, axis_y=0.0, axis_z=0.0, flag=0)
-
- Creates a constraint.
-
- :arg physicsid_1: The physics id of the first object in constraint.
- :type physicsid_1: int
-
- :arg physicsid_2: The physics id of the second object in constraint.
- :type physicsid_2: int
-
- :arg constraint_type: The type of the constraint, see `Create Constraint Constants`_.
-
- :type constraint_type: int
-
- :arg pivot_x: Pivot X position. (optional)
- :type pivot_x: float
-
- :arg pivot_y: Pivot Y position. (optional)
- :type pivot_y: float
-
- :arg pivot_z: Pivot Z position. (optional)
- :type pivot_z: float
-
- :arg axis_x: X axis angle in degrees. (optional)
- :type axis_x: float
-
- :arg axis_y: Y axis angle in degrees. (optional)
- :type axis_y: float
-
- :arg axis_z: Z axis angle in degrees. (optional)
- :type axis_z: float
-
- :arg flag: 128 to disable collision between linked bodies. (optional)
- :type flag: int
-
- :return: A constraint wrapper.
- :rtype: :class:`~bge.types.KX_ConstraintWrapper`
-
-.. function:: exportBulletFile(filename)
-
- Exports a file representing the dynamics world (usually using ``.bullet`` extension).
-
- See `Bullet binary serialization <http://bulletphysics.org/mediawiki-1.5.8/index.php/Bullet_binary_serialization>`__.
-
- :arg filename: File path.
- :type filename: str
-
-.. function:: getAppliedImpulse(constraintId)
-
- :arg constraintId: The id of the constraint.
- :type constraintId: int
-
- :return: The most recent applied impulse.
- :rtype: float
-
-.. function:: getVehicleConstraint(constraintId)
-
- :arg constraintId: The id of the vehicle constraint.
- :type constraintId: int
-
- :return: A vehicle constraint object.
- :rtype: :class:`~bge.types.KX_VehicleWrapper`
-
-.. function:: getCharacter(gameobj)
-
- :arg gameobj: The game object with the character physics.
- :type gameobj: :class:`~bge.types.KX_GameObject`
-
- :return: Character wrapper.
- :rtype: :class:`~bge.types.KX_CharacterWrapper`
-
-.. function:: removeConstraint(constraintId)
-
- Removes a constraint.
-
- :arg constraintId: The id of the constraint to be removed.
- :type constraintId: int
-
-.. function:: setCcdMode(ccdMode)
-
- .. note::
- Very experimental, not recommended
-
- Sets the CCD (Continous Colision Detection) mode in the Physics Environment.
-
- :arg ccdMode: The new CCD mode.
- :type ccdMode: int
-
-.. function:: setContactBreakingTreshold(breakingTreshold)
-
- .. note::
- Reasonable default is 0.02 (if units are meters)
-
- Sets tresholds to do with contact point management.
-
- :arg breakingTreshold: The new contact breaking treshold.
- :type breakingTreshold: float
-
-.. function:: setDeactivationAngularTreshold(angularTreshold)
-
- Sets the angular velocity treshold.
-
- :arg angularTreshold: New deactivation angular treshold.
- :type angularTreshold: float
-
-.. function:: setDeactivationLinearTreshold(linearTreshold)
-
- Sets the linear velocity treshold.
-
- :arg linearTreshold: New deactivation linear treshold.
- :type linearTreshold: float
-
-.. function:: setDeactivationTime(time)
-
- Sets the time after which a resting rigidbody gets deactived.
-
- :arg time: The deactivation time.
- :type time: float
-
-.. function:: setDebugMode(mode)
-
- Sets the debug mode.
-
- :arg mode: The new debug mode, see `Debug Mode Constants`_.
-
- :type mode: int
-
-.. function:: setGravity(x, y, z)
-
- Sets the gravity force.
-
- :arg x: Gravity X force.
- :type x: float
-
- :arg y: Gravity Y force.
- :type y: float
-
- :arg z: Gravity Z force.
- :type z: float
-
-.. function:: setLinearAirDamping(damping)
-
- .. note::
-
- Not implemented
-
- Sets the linear air damping for rigidbodies.
-
-.. function:: setNumIterations(numiter)
-
- Sets the number of iterations for an iterative constraint solver.
-
- :arg numiter: New number of iterations.
- :type numiter: int
-
-.. function:: setNumTimeSubSteps(numsubstep)
-
- Sets the number of substeps for each physics proceed. Tradeoff quality for performance.
-
- :arg numsubstep: New number of substeps.
- :type numsubstep: int
-
-.. function:: setSolverDamping(damping)
-
- .. note::
- Very experimental, not recommended
-
- Sets the damper constant of a penalty based solver.
-
- :arg damping: New damping for the solver.
- :type damping: float
-
-.. function:: setSolverTau(tau)
-
- .. note::
- Very experimental, not recommended
-
- Sets the spring constant of a penalty based solver.
-
- :arg tau: New tau for the solver.
- :type tau: float
-
-.. function:: setSolverType(solverType)
-
- .. note::
- Very experimental, not recommended
-
- Sets the solver type.
-
- :arg solverType: The new type of the solver.
- :type solverType: int
-
-.. function:: setSorConstant(sor)
-
- .. note::
- Very experimental, not recommended
-
- Sets the successive overrelaxation constant.
-
- :arg sor: New sor value.
- :type sor: float
-
-.. function:: setUseEpa(epa)
-
- .. note::
-
- Not implemented
-
-
-Constants
-+++++++++
-
-.. attribute:: error
-
- Symbolic constant string that indicates error.
-
- :type: str
-
-
-Debug Mode Constants
-^^^^^^^^^^^^^^^^^^^^
-
-Debug mode to be used with :func:`setDebugMode`.
-
-
-.. data:: DBG_NODEBUG
-
- No debug.
-
-.. data:: DBG_DRAWWIREFRAME
-
- Draw wireframe in debug.
-
-.. data:: DBG_DRAWAABB
-
- Draw Axis Aligned Bounding Box in debug.
-
-.. data:: DBG_DRAWFREATURESTEXT
-
- Draw features text in debug.
-
-.. data:: DBG_DRAWCONTACTPOINTS
-
- Draw contact points in debug.
-
-.. data:: DBG_NOHELPTEXT
-
- Debug without help text.
-
-.. data:: DBG_DRAWTEXT
-
- Draw text in debug.
-
-.. data:: DBG_PROFILETIMINGS
-
- Draw profile timings in debug.
-
-.. data:: DBG_ENABLESATCOMPARISION
-
- Enable sat comparision in debug.
-
-.. data:: DBG_DISABLEBULLETLCP
-
- Disable Bullet LCP.
-
-.. data:: DBG_ENABLECCD
-
- Enable Continous Collision Detection in debug.
-
-.. data:: DBG_DRAWCONSTRAINTS
-
- Draw constraints in debug.
-
-.. data:: DBG_DRAWCONSTRAINTLIMITS
-
- Draw constraint limits in debug.
-
-.. data:: DBG_FASTWIREFRAME
-
- Draw a fast wireframe in debug.
-
-
-Create Constraint Constants
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Constraint type to be used with :func:`createConstraint`.
-
-
-.. data:: POINTTOPOINT_CONSTRAINT
-
- .. to do
-
-.. data:: LINEHINGE_CONSTRAINT
-
- .. to do
-
-.. data:: ANGULAR_CONSTRAINT
-
- .. to do
-
-.. data:: CONETWIST_CONSTRAINT
-
- .. to do
-
-.. data:: VEHICLE_CONSTRAINT
-
- .. to do
-
-.. data:: GENERIC_6DOF_CONSTRAINT
-
- .. to do
-
diff --git a/doc/python_api/rst/bge.events.rst b/doc/python_api/rst/bge.events.rst
deleted file mode 100644
index 42135926fda..00000000000
--- a/doc/python_api/rst/bge.events.rst
+++ /dev/null
@@ -1,250 +0,0 @@
-
-Game Keys (bge.events)
-======================
-
-*****
-Intro
-*****
-
-This module holds key constants for the SCA_KeyboardSensor.
-
-.. module:: bge.events
-
-.. code-block:: python
-
- # Set a connected keyboard sensor to accept F1
- import bge
-
- co = bge.logic.getCurrentController()
- # 'Keyboard' is a keyboard sensor
- sensor = co.sensors["Keyboard"]
- sensor.key = bge.events.F1KEY
-
- code-block:: python
-
- # Do the all keys thing
- import bge
-
- co = bge.logic.getCurrentController()
- # 'Keyboard' is a keyboard sensor
- sensor = co.sensors["Keyboard"]
-
- for key,status in sensor.events:
- # key[0] == bge.events.keycode, key[1] = status
- if status == bge.logic.KX_INPUT_JUST_ACTIVATED:
- if key == bge.events.WKEY:
- # Activate Forward!
- if key == bge.events.SKEY:
- # Activate Backward!
- if key == bge.events.AKEY:
- # Activate Left!
- if key == bge.events.DKEY:
- # Activate Right!
-
- code-block:: python
-
- # The all keys thing without a keyboard sensor (but you will
- # need an always sensor with pulse mode on)
- import bge
-
- # Just shortening names here
- keyboard = bge.logic.keyboard
- JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
-
- if keyboard.events[bge.events.WKEY] == JUST_ACTIVATED:
- print("Activate Forward!")
- if keyboard.events[bge.events.SKEY] == JUST_ACTIVATED:
- print("Activate Backward!")
- if keyboard.events[bge.events.AKEY] == JUST_ACTIVATED:
- print("Activate Left!")
- if keyboard.events[bge.events.DKEY] == JUST_ACTIVATED:
- print("Activate Right!")
-
-
-*********
-Functions
-*********
-
-.. function:: EventToString(event)
-
- Return the string name of a key event. Will raise a ValueError error if its invalid.
-
- :arg event: key event constant from :mod:`bge.events` or the keyboard sensor.
- :type event: int
- :rtype: string
-
-.. function:: EventToCharacter(event, shift)
-
- Return the string name of a key event. Returns an empty string if the event cant be represented as a character.
-
- :type event: int
- :arg event: key event constant from :mod:`bge.events` or the keyboard sensor.
- :type shift: bool
- :arg shift: set to true if shift is held.
- :rtype: string
-
-****************
-Keys (Constants)
-****************
-
-.. _mouse-keys:
-
-==========
-Mouse Keys
-==========
-
-.. data:: LEFTMOUSE
-.. data:: MIDDLEMOUSE
-.. data:: RIGHTMOUSE
-.. data:: WHEELUPMOUSE
-.. data:: WHEELDOWNMOUSE
-.. data:: MOUSEX
-.. data:: MOUSEY
-
-.. _keyboard-keys:
-
-=============
-Keyboard Keys
-=============
-
--------------
-Alphabet keys
--------------
-
-.. data:: AKEY
-.. data:: BKEY
-.. data:: CKEY
-.. data:: DKEY
-.. data:: EKEY
-.. data:: FKEY
-.. data:: GKEY
-.. data:: HKEY
-.. data:: IKEY
-.. data:: JKEY
-.. data:: KKEY
-.. data:: LKEY
-.. data:: MKEY
-.. data:: NKEY
-.. data:: OKEY
-.. data:: PKEY
-.. data:: QKEY
-.. data:: RKEY
-.. data:: SKEY
-.. data:: TKEY
-.. data:: UKEY
-.. data:: VKEY
-.. data:: WKEY
-.. data:: XKEY
-.. data:: YKEY
-.. data:: ZKEY
-
------------
-Number keys
------------
-
-.. data:: ZEROKEY
-.. data:: ONEKEY
-.. data:: TWOKEY
-.. data:: THREEKEY
-.. data:: FOURKEY
-.. data:: FIVEKEY
-.. data:: SIXKEY
-.. data:: SEVENKEY
-.. data:: EIGHTKEY
-.. data:: NINEKEY
-
---------------
-Modifiers Keys
---------------
-
-.. data:: CAPSLOCKKEY
-.. data:: LEFTCTRLKEY
-.. data:: LEFTALTKEY
-.. data:: RIGHTALTKEY
-.. data:: RIGHTCTRLKEY
-.. data:: RIGHTSHIFTKEY
-.. data:: LEFTSHIFTKEY
-
-----------
-Arrow Keys
-----------
-
-.. data:: LEFTARROWKEY
-.. data:: DOWNARROWKEY
-.. data:: RIGHTARROWKEY
-.. data:: UPARROWKEY
-
---------------
-Numberpad Keys
---------------
-
-.. data:: PAD0
-.. data:: PAD1
-.. data:: PAD2
-.. data:: PAD3
-.. data:: PAD4
-.. data:: PAD5
-.. data:: PAD6
-.. data:: PAD7
-.. data:: PAD8
-.. data:: PAD9
-.. data:: PADPERIOD
-.. data:: PADSLASHKEY
-.. data:: PADASTERKEY
-.. data:: PADMINUS
-.. data:: PADENTER
-.. data:: PADPLUSKEY
-
--------------
-Function Keys
--------------
-
-.. data:: F1KEY
-.. data:: F2KEY
-.. data:: F3KEY
-.. data:: F4KEY
-.. data:: F5KEY
-.. data:: F6KEY
-.. data:: F7KEY
-.. data:: F8KEY
-.. data:: F9KEY
-.. data:: F10KEY
-.. data:: F11KEY
-.. data:: F12KEY
-.. data:: F13KEY
-.. data:: F14KEY
-.. data:: F15KEY
-.. data:: F16KEY
-.. data:: F17KEY
-.. data:: F18KEY
-.. data:: F19KEY
-
-----------
-Other Keys
-----------
-
-.. data:: ACCENTGRAVEKEY
-.. data:: BACKSLASHKEY
-.. data:: BACKSPACEKEY
-.. data:: COMMAKEY
-.. data:: DELKEY
-.. data:: ENDKEY
-.. data:: EQUALKEY
-.. data:: ESCKEY
-.. data:: HOMEKEY
-.. data:: INSERTKEY
-.. data:: LEFTBRACKETKEY
-.. data:: LINEFEEDKEY
-.. data:: MINUSKEY
-.. data:: PAGEDOWNKEY
-.. data:: PAGEUPKEY
-.. data:: PAUSEKEY
-.. data:: PERIODKEY
-.. data:: QUOTEKEY
-.. data:: RIGHTBRACKETKEY
-.. data:: RETKEY (Deprecated: use bge.events.ENTERKEY)
-.. data:: ENTERKEY
-.. data:: SEMICOLONKEY
-.. data:: SLASHKEY
-.. data:: SPACEKEY
-.. data:: TABKEY
diff --git a/doc/python_api/rst/bge.logic.rst b/doc/python_api/rst/bge.logic.rst
deleted file mode 100644
index 5cdb8ebfee9..00000000000
--- a/doc/python_api/rst/bge.logic.rst
+++ /dev/null
@@ -1,1407 +0,0 @@
-
-Game Logic (bge.logic)
-======================
-
-************
-Introduction
-************
-
-Module to access logic functions, imported automatically into the python controllers namespace.
-
-.. module:: bge.logic
-
-.. code-block:: python
-
- # To get the controller thats running this python script:
- cont = bge.logic.getCurrentController() # bge.logic is automatically imported
-
- # To get the game object this controller is on:
- obj = cont.owner
-
-:class:`~bge.types.KX_GameObject` and :class:`~bge.types.KX_Camera` or :class:`~bge.types.KX_LightObject` methods are available depending on the type of object
-
-.. code-block:: python
-
- # To get a sensor linked to this controller.
- # "sensorname" is the name of the sensor as defined in the Blender interface.
- # +---------------------+ +--------+
- # | Sensor "sensorname" +--+ Python +
- # +---------------------+ +--------+
- sens = cont.sensors["sensorname"]
-
- # To get a sequence of all sensors:
- sensors = co.sensors
-
-See the sensor's reference for available methods:
-
-.. hlist::
- :columns: 3
-
- * :class:`~bge.types.KX_MouseFocusSensor`
- * :class:`~bge.types.KX_NearSensor`
- * :class:`~bge.types.KX_NetworkMessageSensor`
- * :class:`~bge.types.KX_RadarSensor`
- * :class:`~bge.types.KX_RaySensor`
- * :class:`~bge.types.KX_TouchSensor`
- * :class:`~bge.types.SCA_DelaySensor`
- * :class:`~bge.types.SCA_JoystickSensor`
- * :class:`~bge.types.SCA_KeyboardSensor`
- * :class:`~bge.types.SCA_MouseSensor`
- * :class:`~bge.types.SCA_PropertySensor`
- * :class:`~bge.types.SCA_RandomSensor`
-
-You can also access actuators linked to the controller
-
-.. code-block:: python
-
- # To get an actuator attached to the controller:
- # +--------+ +-------------------------+
- # + Python +--+ Actuator "actuatorname" |
- # +--------+ +-------------------------+
- actuator = co.actuators["actuatorname"]
-
- # Activate an actuator
- controller.activate(actuator)
-
-See the actuator's reference for available methods
-
-.. hlist::
- :columns: 3
-
- * :class:`~bge.types.BL_ActionActuator`
- * :class:`~bge.types.KX_CameraActuator`
- * :class:`~bge.types.KX_ConstraintActuator`
- * :class:`~bge.types.KX_GameActuator`
- * :class:`~bge.types.KX_MouseActuator`
- * :class:`~bge.types.KX_NetworkMessageActuator`
- * :class:`~bge.types.KX_ObjectActuator`
- * :class:`~bge.types.KX_ParentActuator`
- * :class:`~bge.types.KX_SCA_AddObjectActuator`
- * :class:`~bge.types.KX_SCA_DynamicActuator`
- * :class:`~bge.types.KX_SCA_EndObjectActuator`
- * :class:`~bge.types.KX_SCA_ReplaceMeshActuator`
- * :class:`~bge.types.KX_SceneActuator`
- * :class:`~bge.types.KX_SoundActuator`
- * :class:`~bge.types.KX_StateActuator`
- * :class:`~bge.types.KX_TrackToActuator`
- * :class:`~bge.types.KX_VisibilityActuator`
- * :class:`~bge.types.SCA_2DFilterActuator`
- * :class:`~bge.types.SCA_PropertyActuator`
- * :class:`~bge.types.SCA_RandomActuator`
-
-Most logic brick's methods are accessors for the properties available in the logic buttons.
-Consult the logic bricks documentation for more information on how each logic brick works.
-
-There are also methods to access the current :class:`bge.types.KX_Scene`
-
-.. code-block:: python
-
- # Get the current scene
- scene = bge.logic.getCurrentScene()
-
- # Get the current camera
- cam = scene.active_camera
-
-Matricies as used by the game engine are **row major**
-``matrix[row][col] = float``
-
-:class:`bge.types.KX_Camera` has some examples using matrices.
-
-*********
-Variables
-*********
-
-.. data:: globalDict
-
- A dictionary that is saved between loading blend files so you can use it to store inventory and other variables you want to store between scenes and blend files.
- It can also be written to a file and loaded later on with the game load/save actuators.
-
- .. note:: only python built in types such as int/string/bool/float/tuples/lists can be saved, GameObjects, Actuators etc will not work as expected.
-
-.. data:: keyboard
-
- The current keyboard wrapped in an :class:`~bge.types.SCA_PythonKeyboard` object.
-
-.. data:: mouse
-
- The current mouse wrapped in an :class:`~bge.types.SCA_PythonMouse` object.
-
-.. data:: joysticks
-
- A list of attached :class:`~bge.types.SCA_PythonJoystick`.
- The list size is the maximum number of supported joysticks.
- If no joystick is available for a given slot, the slot is set to None.
-
-*****************
-General functions
-*****************
-
-.. function:: getCurrentController()
-
- Gets the Python controller associated with this Python script.
-
- :rtype: :class:`bge.types.SCA_PythonController`
-
-.. function:: getCurrentScene()
-
- Gets the current Scene.
-
- :rtype: :class:`bge.types.KX_Scene`
-
-.. function:: getSceneList()
-
- Gets a list of the current scenes loaded in the game engine.
-
- :rtype: list of :class:`bge.types.KX_Scene`
-
- .. note:: Scenes in your blend file that have not been converted wont be in this list. This list will only contain scenes such as overlays scenes.
-
-.. function:: loadGlobalDict()
-
- Loads bge.logic.globalDict from a file.
-
-.. function:: saveGlobalDict()
-
- Saves bge.logic.globalDict to a file.
-
-.. function:: startGame(blend)
-
- Loads the blend file.
-
- :arg blend: The name of the blend file
- :type blend: string
-
-.. function:: endGame()
-
- Ends the current game.
-
-.. function:: restartGame()
-
- Restarts the current game by reloading the .blend file (the last saved version, not what is currently running).
-
-.. function:: LibLoad(blend, type, data, load_actions=False, verbose=False, load_scripts=True, async=False)
-
- Converts the all of the datablocks of the given type from the given blend.
-
- :arg blend: The path to the blend file (or the name to use for the library if data is supplied)
- :type blend: string
- :arg type: The datablock type (currently only "Action", "Mesh" and "Scene" are supported)
- :type type: string
- :arg data: Binary data from a blend file (optional)
- :type data: bytes
- :arg load_actions: Search for and load all actions in a given Scene and not just the "active" actions (Scene type only)
- :type load_actions: bool
- :arg verbose: Whether or not to print debugging information (e.g., "SceneName: Scene")
- :type verbose: bool
- :arg load_scripts: Whether or not to load text datablocks as well (can be disabled for some extra security)
- :type load_scripts: bool
- :arg async: Whether or not to do the loading asynchronously (in another thread). Only the "Scene" type is currently supported for this feature.
- :type async: bool
-
- :rtype: :class:`bge.types.KX_LibLoadStatus`
-
- .. note:: Asynchronously loaded libraries will not be available immediately after LibLoad() returns. Use the returned KX_LibLoadStatus to figure out when the libraries are ready.
-
-.. function:: LibNew(name, type, data)
-
- Uses existing datablock data and loads in as a new library.
-
- :arg name: A unique library name used for removal later
- :type name: string
- :arg type: The datablock type (currently only "Mesh" is supported)
- :type type: string
- :arg data: A list of names of the datablocks to load
- :type data: list of strings
-
-.. function:: LibFree(name)
-
- Frees a library, removing all objects and meshes from the currently active scenes.
-
- :arg name: The name of the library to free (the name used in LibNew)
- :type name: string
-
-.. function:: LibList()
-
- Returns a list of currently loaded libraries.
-
- :rtype: list [str]
-
-.. function:: addScene(name, overlay=1)
-
- Loads a scene into the game engine.
-
- .. note::
-
- This function is not effective immediately, the scene is queued
- and added on the next logic cycle where it will be available
- from `getSceneList`
-
- :arg name: The name of the scene
- :type name: string
- :arg overlay: Overlay or underlay (optional)
- :type overlay: integer
-
-.. function:: sendMessage(subject, body="", to="", message_from="")
-
- Sends a message to sensors in any active scene.
-
- :arg subject: The subject of the message
- :type subject: string
- :arg body: The body of the message (optional)
- :type body: string
- :arg to: The name of the object to send the message to (optional)
- :type to: string
- :arg message_from: The name of the object that the message is coming from (optional)
- :type message_from: string
-
-.. function:: setGravity(gravity)
-
- Sets the world gravity.
-
- :arg gravity: gravity vector
- :type gravity: Vector((fx, fy, fz))
-
-.. function:: getSpectrum()
-
- Returns a 512 point list from the sound card.
- This only works if the fmod sound driver is being used.
-
- :rtype: list [float], len(getSpectrum()) == 512
-
-.. function:: getMaxLogicFrame()
-
- Gets the maximum number of logic frames per render frame.
-
- :return: The maximum number of logic frames per render frame
- :rtype: integer
-
-.. function:: setMaxLogicFrame(maxlogic)
-
- Sets the maximum number of logic frames that are executed per render frame.
- This does not affect the physic system that still runs at full frame rate.
-
- :arg maxlogic: The new maximum number of logic frames per render frame. Valid values: 1..5
- :type maxlogic: integer
-
-.. function:: getMaxPhysicsFrame()
-
- Gets the maximum number of physics frames per render frame.
-
- :return: The maximum number of physics frames per render frame
- :rtype: integer
-
-.. function:: setMaxPhysicsFrame(maxphysics)
-
- Sets the maximum number of physics timestep that are executed per render frame.
- Higher value allows physics to keep up with realtime even if graphics slows down the game.
- Physics timestep is fixed and equal to 1/tickrate (see setLogicTicRate)
- maxphysics/ticrate is the maximum delay of the renderer that physics can compensate.
-
- :arg maxphysics: The new maximum number of physics timestep per render frame. Valid values: 1..5.
- :type maxphysics: integer
-
-.. function:: getLogicTicRate()
-
- Gets the logic update frequency.
-
- :return: The logic frequency in Hz
- :rtype: float
-
-.. function:: setLogicTicRate(ticrate)
-
- Sets the logic update frequency.
-
- The logic update frequency is the number of times logic bricks are executed every second.
- The default is 60 Hz.
-
- :arg ticrate: The new logic update frequency (in Hz).
- :type ticrate: float
-
-.. function:: getPhysicsTicRate()
-
- Gets the physics update frequency
-
- :return: The physics update frequency in Hz
- :rtype: float
-
- .. warning: Not implimented yet
-
-.. function:: setPhysicsTicRate(ticrate)
-
- Sets the physics update frequency
-
- The physics update frequency is the number of times the physics system is executed every second.
- The default is 60 Hz.
-
- :arg ticrate: The new update frequency (in Hz).
- :type ticrate: float
-
- .. warning: Not implimented yet
-
-.. function:: getAnimRecordFrame()
-
- Gets the current frame number used for recording animations. This
- number is incremented automatically by Blender when the "Record
- animation" feature is turned on.
-
- :rtype: int
-
-.. function:: setAnimRecordFrame(framenr)
-
- Sets the current frame number used for recording animations. This
- number is automatically incremented by Blender when the "Record
- animation" feature is turned on.
-
- The frame number Must be non-negative, unless Blender has
- :attr:`bpy.types.UserPreferencesEdit.use_negative_frames` enabled
- in its user preferences. Only use non-negative numbers to be on
- the safe side, unless you know what you are doing.
-
- :arg framenr: The new frame number.
- :type framenr: int
-
-.. function:: getExitKey()
-
- Gets the key used to exit the game engine
-
- :return: The key (defaults to :mod:`bge.events.ESCKEY`)
- :rtype: int
-
-.. function:: setExitKey(key)
-
- Sets the key used to exit the game engine
-
- :arg key: A key constant from :mod:`bge.events`
- :type key: int
-
-.. function:: NextFrame()
-
- Render next frame (if Python has control)
-
-.. function:: setRender(render)
-
- Sets the global flag that controls the render of the scene.
- If True, the render is done after the logic frame.
- If False, the render is skipped and another logic frame starts immediately.
-
- .. note::
-
- GPU VSync no longer limits the number of frame per second when render is off,
- but the *Use Frame Rate* option still regulates the fps. To run as many frames
- as possible, untick this option (Render Properties, System panel).
-
- :arg render: the render flag
- :type render: bool
-
-.. function:: getRender()
-
- Get the current value of the global render flag
-
- :return: The flag value
- :rtype: bool
-
-**********************
-Time related functions
-**********************
-
-.. function:: getClockTime()
-
- Get the current BGE render time, in seconds. The BGE render time is the
- simulation time corresponding to the next scene that will be rendered.
-
- :rtype: double
-
-.. function:: getFrameTime()
-
- Get the current BGE frame time, in seconds. The BGE frame time is the
- simulation time corresponding to the current call of the logic system.
- Generally speaking, it is what the user is interested in.
-
- :rtype: double
-
-.. function:: getRealTime()
-
- Get the number of real (system-clock) seconds elapsed since the beginning
- of the simulation.
-
- :rtype: double
-
-.. function:: getTimeScale()
-
- Get the time multiplier between real-time and simulation time. The default
- value is 1.0. A value greater than 1.0 means that the simulation is going
- faster than real-time, a value lower than 1.0 means that the simulation is
- going slower than real-time.
-
- :rtype: double
-
-.. function:: setTimeScale(time_scale)
-
- Set the time multiplier between real-time and simulation time. A value
- greater than 1.0 means that the simulation is going faster than real-time,
- a value lower than 1.0 means that the simulation is going slower than
- real-time. Note that a too large value may lead to some physics
- instabilities.
-
- :arg time_scale: The new time multiplier.
-
-.. function:: getUseExternalClock()
-
- Get if the BGE use the inner BGE clock, or rely or on an external
- clock. The default is to use the inner BGE clock.
-
- :rtype: bool
-
-.. function:: setUseExternalClock(use_external_clock)
-
- Set if the BGE use the inner BGE clock, or rely or on an external
- clock. If the user selects the use of an external clock, he should call
- regularly the setClockTime method.
-
- :arg use_external_clock: the new setting
-
-.. function:: setClockTime(new_time)
-
- Set the next value of the simulation clock. It is preferable to use this
- method from a custom main function in python, as calling it in the logic
- block can easily lead to a blocked system (if the time does not advance
- enough to run at least the next logic step).
-
- :arg new_time: the next value of the BGE clock (in second).
-
-
-*****************
-Utility functions
-*****************
-
-.. function:: expandPath(path)
-
- Converts a blender internal path into a proper file system path.
-
- Use / as directory separator in path
- You can use '//' at the start of the string to define a relative path;
- Blender replaces that string by the directory of the current .blend or runtime file
- to make a full path name. The function also converts the directory separator to
- the local file system format.
-
- :arg path: The path string to be converted/expanded.
- :type path: string
- :return: The converted string
- :rtype: string
-
-.. function:: getAverageFrameRate()
-
- Gets the estimated/average framerate for all the active scenes, not only the current scene.
-
- :return: The estimated average framerate in frames per second
- :rtype: float
-
-.. function:: getBlendFileList(path = "//")
-
- Returns a list of blend files in the same directory as the open blend file, or from using the option argument.
-
- :arg path: Optional directory argument, will be expanded (like expandPath) into the full path.
- :type path: string
- :return: A list of filenames, with no directory prefix
- :rtype: list
-
-.. function:: getRandomFloat()
-
- Returns a random floating point value in the range [0 - 1)
-
-.. function:: PrintGLInfo()
-
- Prints GL Extension Info into the console
-
-.. function:: PrintMemInfo()
-
- Prints engine statistics into the console
-
-.. function:: getProfileInfo()
-
- Returns a Python dictionary that contains the same information as the on screen profiler. The keys are the profiler categories and the values are tuples with the first element being time taken (in ms) and the second element being the percentage of total time.
-
-*********
-Constants
-*********
-
-.. data:: KX_TRUE
-
- True value used by some modules.
-
-.. data:: KX_FALSE
-
- False value used by some modules.
-
-=======
-Sensors
-=======
-
-.. _sensor-status:
-
--------------
-Sensor Status
--------------
-
-.. data:: KX_SENSOR_INACTIVE
-.. data:: KX_SENSOR_JUST_ACTIVATED
-.. data:: KX_SENSOR_ACTIVE
-.. data:: KX_SENSOR_JUST_DEACTIVATED
-
----------------
-Armature Sensor
----------------
-
-.. _armaturesensor-type:
-
-See :class:`bge.types.KX_ArmatureSensor.type`
-
-.. data:: KX_ARMSENSOR_STATE_CHANGED
-
- Detect that the constraint is changing state (active/inactive)
-
- :value: 0
-
-.. data:: KX_ARMSENSOR_LIN_ERROR_BELOW
-
- Detect that the constraint linear error is above a threshold
-
- :value: 1
-
-.. data:: KX_ARMSENSOR_LIN_ERROR_ABOVE
-
- Detect that the constraint linear error is below a threshold
-
- :value: 2
-
-.. data:: KX_ARMSENSOR_ROT_ERROR_BELOW
-
- Detect that the constraint rotation error is above a threshold
-
- :value: 3
-
-.. data:: KX_ARMSENSOR_ROT_ERROR_ABOVE
-
- Detect that the constraint rotation error is below a threshold
-
- :value: 4
-
-
-.. _logic-property-sensor:
-
----------------
-Property Sensor
----------------
-
-.. data:: KX_PROPSENSOR_EQUAL
-
- Activate when the property is equal to the sensor value.
-
- :value: 1
-
-.. data:: KX_PROPSENSOR_NOTEQUAL
-
- Activate when the property is not equal to the sensor value.
-
- :value: 2
-
-.. data:: KX_PROPSENSOR_INTERVAL
-
- Activate when the property is between the specified limits.
-
- :value: 3
-
-.. data:: KX_PROPSENSOR_CHANGED
-
- Activate when the property changes
-
- :value: 4
-
-.. data:: KX_PROPSENSOR_EXPRESSION
-
- Activate when the expression matches
-
- :value: 5
-
-.. data:: KX_PROPSENSOR_LESSTHAN
-
- Activate when the property is less than the sensor value
-
- :value: 6
-
-.. data:: KX_PROPSENSOR_GREATERTHAN
-
- Activate when the property is greater than the sensor value
-
- :value: 7
-
-------------
-Radar Sensor
-------------
-
-See :class:`bge.types.KX_RadarSensor`
-
-.. data:: KX_RADAR_AXIS_POS_X
-.. data:: KX_RADAR_AXIS_POS_Y
-.. data:: KX_RADAR_AXIS_POS_Z
-.. data:: KX_RADAR_AXIS_NEG_X
-.. data:: KX_RADAR_AXIS_NEG_Y
-.. data:: KX_RADAR_AXIS_NEG_Z
-
-----------
-Ray Sensor
-----------
-
-See :class:`bge.types.KX_RaySensor`
-
-.. data:: KX_RAY_AXIS_POS_X
-.. data:: KX_RAY_AXIS_POS_Y
-.. data:: KX_RAY_AXIS_POS_Z
-.. data:: KX_RAY_AXIS_NEG_X
-.. data:: KX_RAY_AXIS_NEG_Y
-.. data:: KX_RAY_AXIS_NEG_Z
-
-
-=========
-Actuators
-=========
-
-.. _action-actuator:
-
----------------
-Action Actuator
----------------
-
-See :class:`bge.types.BL_ActionActuator`
-
-.. data:: KX_ACTIONACT_PLAY
-.. data:: KX_ACTIONACT_PINGPONG
-.. data:: KX_ACTIONACT_FLIPPER
-.. data:: KX_ACTIONACT_LOOPSTOP
-.. data:: KX_ACTIONACT_LOOPEND
-.. data:: KX_ACTIONACT_PROPERTY
-
------------------
-Armature Actuator
------------------
-
- .. _armatureactuator-constants-type:
-
-See :class:`bge.types.BL_ArmatureActuator.type`
-
-.. data:: KX_ACT_ARMATURE_RUN
-
- Just make sure the armature will be updated on the next graphic frame.
- This is the only persistent mode of the actuator:
- it executes automatically once per frame until stopped by a controller
-
- :value: 0
-
-.. data:: KX_ACT_ARMATURE_ENABLE
-
- Enable the constraint.
-
- :value: 1
-
-.. data:: KX_ACT_ARMATURE_DISABLE
-
- Disable the constraint (runtime constraint values are not updated).
-
- :value: 2
-
-.. data:: KX_ACT_ARMATURE_SETTARGET
-
- Change target and subtarget of constraint.
-
- :value: 3
-
-.. data:: KX_ACT_ARMATURE_SETWEIGHT
-
- Change weight of constraint (IK only).
-
- :value: 4
-
-.. data:: KX_ACT_ARMATURE_SETINFLUENCE
-
- Change influence of constraint.
-
- :value: 5
-
--------------------
-Constraint Actuator
--------------------
-
-.. _constraint-actuator-option:
-
-See :class:`bge.types.KX_ConstraintActuator.option`
-
-* Applicable to Distance constraint:
-
-.. data:: KX_CONSTRAINTACT_NORMAL
-
- Activate alignment to surface
-
-.. data:: KX_CONSTRAINTACT_DISTANCE
-
- Activate distance control
-
-.. data:: KX_CONSTRAINTACT_LOCAL
-
- Direction of the ray is along the local axis
-
-* Applicable to Force field constraint:
-
-.. data:: KX_CONSTRAINTACT_DOROTFH
-
- Force field act on rotation as well
-
-* Applicable to both:
-
-.. data:: KX_CONSTRAINTACT_MATERIAL
-
- Detect material rather than property
-
-.. data:: KX_CONSTRAINTACT_PERMANENT
-
- No deactivation if ray does not hit target
-
-.. _constraint-actuator-limit:
-
-See :class:`bge.types.KX_ConstraintActuator.limit`
-
-.. data:: KX_CONSTRAINTACT_LOCX
-
- Limit X coord.
-
-.. data:: KX_CONSTRAINTACT_LOCY
-
- Limit Y coord
-
-.. data:: KX_CONSTRAINTACT_LOCZ
-
- Limit Z coord
-
-.. data:: KX_CONSTRAINTACT_ROTX
-
- Limit X rotation
-
-.. data:: KX_CONSTRAINTACT_ROTY
-
- Limit Y rotation
-
-.. data:: KX_CONSTRAINTACT_ROTZ
-
- Limit Z rotation
-
-.. data:: KX_CONSTRAINTACT_DIRNX
-
- Set distance along negative X axis
-
-.. data:: KX_CONSTRAINTACT_DIRNY
-
- Set distance along negative Y axis
-
-.. data:: KX_CONSTRAINTACT_DIRNZ
-
- Set distance along negative Z axis
-
-.. data:: KX_CONSTRAINTACT_DIRPX
-
- Set distance along positive X axis
-
-.. data:: KX_CONSTRAINTACT_DIRPY
-
- Set distance along positive Y axis
-
-.. data:: KX_CONSTRAINTACT_DIRPZ
-
- Set distance along positive Z axis
-
-.. data:: KX_CONSTRAINTACT_ORIX
-
- Set orientation of X axis
-
-.. data:: KX_CONSTRAINTACT_ORIY
-
- Set orientation of Y axis
-
-.. data:: KX_CONSTRAINTACT_ORIZ
-
- Set orientation of Z axis
-
-.. data:: KX_CONSTRAINTACT_FHNX
-
- Set force field along negative X axis
-
-.. data:: KX_CONSTRAINTACT_FHNY
-
- Set force field along negative Y axis
-
-.. data:: KX_CONSTRAINTACT_FHNZ
-
- Set force field along negative Z axis
-
-.. data:: KX_CONSTRAINTACT_FHPX
-
- Set force field along positive X axis
-
-.. data:: KX_CONSTRAINTACT_FHPY
-
- Set force field along positive Y axis
-
-.. data:: KX_CONSTRAINTACT_FHPZ
-
- Set force field along positive Z axis
-
-----------------
-Dynamic Actuator
-----------------
-
-See :class:`bge.types.KX_SCA_DynamicActuator`
-
-.. data:: KX_DYN_RESTORE_DYNAMICS
-.. data:: KX_DYN_DISABLE_DYNAMICS
-.. data:: KX_DYN_ENABLE_RIGID_BODY
-.. data:: KX_DYN_DISABLE_RIGID_BODY
-.. data:: KX_DYN_SET_MASS
-
-.. _game-actuator:
-
--------------
-Game Actuator
--------------
-
-See :class:`bge.types.KX_GameActuator`
-
-.. data:: KX_GAME_LOAD
-.. data:: KX_GAME_START
-.. data:: KX_GAME_RESTART
-.. data:: KX_GAME_QUIT
-.. data:: KX_GAME_SAVECFG
-.. data:: KX_GAME_LOADCFG
-
-.. _mouse-actuator:
-
----------------
-Mouse Actuator
----------------
-
-.. data:: KX_ACT_MOUSE_OBJECT_AXIS_X
-.. data:: KX_ACT_MOUSE_OBJECT_AXIS_Y
-.. data:: KX_ACT_MOUSE_OBJECT_AXIS_Z
-
----------------
-Parent Actuator
----------------
-
-.. data:: KX_PARENT_REMOVE
-.. data:: KX_PARENT_SET
-
-.. _logic-random-distributions:
-
---------------------
-Random Distributions
---------------------
-
-See :class:`bge.types.SCA_RandomActuator`
-
-.. data:: KX_RANDOMACT_BOOL_CONST
-.. data:: KX_RANDOMACT_BOOL_UNIFORM
-.. data:: KX_RANDOMACT_BOOL_BERNOUILLI
-.. data:: KX_RANDOMACT_INT_CONST
-.. data:: KX_RANDOMACT_INT_UNIFORM
-.. data:: KX_RANDOMACT_INT_POISSON
-.. data:: KX_RANDOMACT_FLOAT_CONST
-.. data:: KX_RANDOMACT_FLOAT_UNIFORM
-.. data:: KX_RANDOMACT_FLOAT_NORMAL
-.. data:: KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
-
---------------
-Scene Actuator
---------------
-
-See :class:`bge.types.KX_SceneActuator`
-
-.. data:: KX_SCENE_RESTART
-.. data:: KX_SCENE_SET_SCENE
-.. data:: KX_SCENE_SET_CAMERA
-.. data:: KX_SCENE_ADD_FRONT_SCENE
-.. data:: KX_SCENE_ADD_BACK_SCENE
-.. data:: KX_SCENE_REMOVE_SCENE
-.. data:: KX_SCENE_SUSPEND
-.. data:: KX_SCENE_RESUME
-
-.. _logic-sound-actuator:
-
---------------
-Sound Actuator
---------------
-
-See :class:`bge.types.KX_SoundActuator`
-
-.. data:: KX_SOUNDACT_PLAYSTOP
-
- :value: 1
-
-.. data:: KX_SOUNDACT_PLAYEND
-
- :value: 2
-
-.. data:: KX_SOUNDACT_LOOPSTOP
-
- :value: 3
-
-.. data:: KX_SOUNDACT_LOOPEND
-
- :value: 4
-
-.. data:: KX_SOUNDACT_LOOPBIDIRECTIONAL
-
- :value: 5
-
-.. data:: KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP
-
- :value: 6
-
------------------
-Steering Actuator
------------------
-
-.. _logic-steering-actuator:
-
-See :class:`bge.types.KX_SteeringActuator.behavior`
-
-.. data:: KX_STEERING_SEEK
-
- :value: 1
-
-.. data:: KX_STEERING_FLEE
-
- :value: 2
-
-.. data:: KX_STEERING_PATHFOLLOWING
-
- :value: 3
-
-.. _logic-trackto-actuator:
-
------------------
-TrackTo Actuator
------------------
-
-See :class:`bge.types.KX_TrackToActuator`
-
-.. data:: KX_TRACK_UPAXIS_POS_X
-.. data:: KX_TRACK_UPAXIS_POS_Y
-.. data:: KX_TRACK_UPAXIS_POS_Z
-.. data:: KX_TRACK_TRAXIS_POS_X
-.. data:: KX_TRACK_TRAXIS_POS_Y
-.. data:: KX_TRACK_TRAXIS_POS_Z
-.. data:: KX_TRACK_TRAXIS_NEG_X
-.. data:: KX_TRACK_TRAXIS_NEG_Y
-.. data:: KX_TRACK_TRAXIS_NEG_Z
-
-=======
-Various
-=======
-
----------
-2D Filter
----------
-
-.. _Two-D-FilterActuator-mode:
-
-.. data:: RAS_2DFILTER_BLUR
-
- :value: 2
-
-.. data:: RAS_2DFILTER_CUSTOMFILTER
-
- Customer filter, the code code is set via shaderText property.
-
- :value: 12
-
-.. data:: RAS_2DFILTER_DILATION
-
- :value: 4
-
-.. data:: RAS_2DFILTER_DISABLED
-
- Disable the filter that is currently active
-
- :value: -1
-
-.. data:: RAS_2DFILTER_ENABLED
-
- Enable the filter that was previously disabled
-
- :value: -2
-
-.. data:: RAS_2DFILTER_EROSION
-
- :value: 5
-
-.. data:: RAS_2DFILTER_GRAYSCALE
-
- :value: 9
-
-.. data:: RAS_2DFILTER_INVERT
-
- :value: 11
-
-.. data:: RAS_2DFILTER_LAPLACIAN
-
- :value: 6
-
-.. data:: RAS_2DFILTER_MOTIONBLUR
-
- Create and enable preset filters
-
- :value: 1
-
-.. data:: RAS_2DFILTER_NOFILTER
-
- Disable and destroy the filter that is currently active
-
- :value: 0
-
-.. data:: RAS_2DFILTER_PREWITT
-
- :value: 8
-
-.. data:: RAS_2DFILTER_SEPIA
-
- :value: 10
-
-.. data:: RAS_2DFILTER_SHARPEN
-
- :value: 3
-
-.. data:: RAS_2DFILTER_SOBEL
-
- :value: 7
-
-----------------
-Armature Channel
-----------------
-.. _armaturechannel-constants-rotation-mode:
-
-See :class:`bge.types.BL_ArmatureChannel.rotation_mode`
-
-.. note:
- euler mode are named as in Blender UI but the actual axis order is reversed
-
-.. data:: ROT_MODE_QUAT
-
- Use quaternion in rotation attribute to update bone rotation.
-
- :value: 0
-
-.. data:: ROT_MODE_XYZ
-
- Use euler_rotation and apply angles on bone's Z, Y, X axis successively.
-
- :value: 1
-
-.. data:: ROT_MODE_XZY
-
- Use euler_rotation and apply angles on bone's Y, Z, X axis successively.
-
- :value: 2
-
-.. data:: ROT_MODE_YXZ
-
- Use euler_rotation and apply angles on bone's Z, X, Y axis successively.
-
- :value: 3
-
-.. data:: ROT_MODE_YZX
-
- Use euler_rotation and apply angles on bone's X, Z, Y axis successively.
-
- :value: 4
-
-.. data:: ROT_MODE_ZXY
-
- Use euler_rotation and apply angles on bone's Y, X, Z axis successively.
-
- :value: 5
-
-.. data:: ROT_MODE_ZYX
-
- Use euler_rotation and apply angles on bone's X, Y, Z axis successively.
-
- :value: 6
-
-
--------------------
-Armature Constraint
--------------------
-.. _armatureconstraint-constants-type:
-
-See :class:`bge.types.BL_ArmatureConstraint.type`
-
-.. data:: CONSTRAINT_TYPE_TRACKTO
-.. data:: CONSTRAINT_TYPE_KINEMATIC
-.. data:: CONSTRAINT_TYPE_ROTLIKE
-.. data:: CONSTRAINT_TYPE_LOCLIKE
-.. data:: CONSTRAINT_TYPE_MINMAX
-.. data:: CONSTRAINT_TYPE_SIZELIKE
-.. data:: CONSTRAINT_TYPE_LOCKTRACK
-.. data:: CONSTRAINT_TYPE_STRETCHTO
-.. data:: CONSTRAINT_TYPE_CLAMPTO
-.. data:: CONSTRAINT_TYPE_TRANSFORM
-.. data:: CONSTRAINT_TYPE_DISTLIMIT
-
-.. _armatureconstraint-constants-ik-type:
-
-See :class:`bge.types.BL_ArmatureConstraint.ik_type`
-
-.. data:: CONSTRAINT_IK_COPYPOSE
-
- constraint is trying to match the position and eventually the rotation of the target.
-
- :value: 0
-
-.. data:: CONSTRAINT_IK_DISTANCE
-
- Constraint is maintaining a certain distance to target subject to ik_mode
-
- :value: 1
-
-.. _armatureconstraint-constants-ik-flag:
-
-See :class:`bge.types.BL_ArmatureConstraint.ik_flag`
-
-.. data:: CONSTRAINT_IK_FLAG_TIP
-
- Set when the constraint operates on the head of the bone and not the tail
-
- :value: 1
-
-.. data:: CONSTRAINT_IK_FLAG_ROT
-
- Set when the constraint tries to match the orientation of the target
-
- :value: 2
-
-.. data:: CONSTRAINT_IK_FLAG_STRETCH
-
- Set when the armature is allowed to stretch (only the bones with stretch factor > 0.0)
-
- :value: 16
-
-.. data:: CONSTRAINT_IK_FLAG_POS
-
- Set when the constraint tries to match the position of the target.
-
- :value: 32
-
-.. _armatureconstraint-constants-ik-mode:
-
-See :class:`bge.types.BL_ArmatureConstraint.ik_mode`
-
-.. data:: CONSTRAINT_IK_MODE_INSIDE
-
- The constraint tries to keep the bone within ik_dist of target
-
- :value: 0
-
-.. data:: CONSTRAINT_IK_MODE_OUTSIDE
-
- The constraint tries to keep the bone outside ik_dist of the target
-
- :value: 1
-
-.. data:: CONSTRAINT_IK_MODE_ONSURFACE
-
- The constraint tries to keep the bone exactly at ik_dist of the target.
-
- :value: 2
-
-.. _input-status:
-
-----------------
-Blender Material
-----------------
-
-.. data:: BL_DST_ALPHA
-.. data:: BL_DST_COLOR
-.. data:: BL_ONE
-.. data:: BL_ONE_MINUS_DST_ALPHA
-.. data:: BL_ONE_MINUS_DST_COLOR
-.. data:: BL_ONE_MINUS_SRC_ALPHA
-.. data:: BL_ONE_MINUS_SRC_COLOR
-.. data:: BL_SRC_ALPHA
-.. data:: BL_SRC_ALPHA_SATURATE
-.. data:: BL_SRC_COLOR
-.. data:: BL_ZERO
-
-------------
-Input Status
-------------
-
-See :class:`bge.types.SCA_PythonKeyboard`, :class:`bge.types.SCA_PythonMouse`, :class:`bge.types.SCA_MouseSensor`, :class:`bge.types.SCA_KeyboardSensor`
-
-.. data:: KX_INPUT_NONE
-.. data:: KX_INPUT_JUST_ACTIVATED
-.. data:: KX_INPUT_ACTIVE
-.. data:: KX_INPUT_JUST_RELEASED
-
--------------
-KX_GameObject
--------------
-.. _gameobject-playaction-mode:
-
-See :class:`bge.types.KX_GameObject.playAction`
-
-.. data:: KX_ACTION_MODE_PLAY
-
- Play the action once.
-
- :value: 0
-
-.. data:: KX_ACTION_MODE_LOOP
-
- Loop the action (repeat it).
-
- :value: 1
-
-.. data:: KX_ACTION_MODE_PING_PONG
-
- Play the action one direct then back the other way when it has completed.
-
- :value: 2
-
-.. _gameobject-playaction-blend:
-
-.. data:: KX_ACTION_BLEND_BLEND
-
- Blend layers using linear interpolation
-
- :value: 0
-
-.. data:: KX_ACTION_BLEND_ADD
-
- Adds the layers together
-
- :value: 1
-
--------------
-Mouse Buttons
--------------
-
-See :class:`bge.types.SCA_MouseSensor`
-
-.. data:: KX_MOUSE_BUT_LEFT
-.. data:: KX_MOUSE_BUT_MIDDLE
-.. data:: KX_MOUSE_BUT_RIGHT
-
---------------------------
-Navigation Mesh Draw Modes
---------------------------
-
-.. _navmesh-draw-mode:
-
-.. data:: RM_WALLS
-
- Draw only the walls.
-
-.. data:: RM_POLYS
-
- Draw only polygons.
-
-.. data:: RM_TRIS
-
- Draw triangle mesh.
-
-------
-Shader
-------
-
-.. data:: VIEWMATRIX
-.. data:: VIEWMATRIX_INVERSE
-.. data:: VIEWMATRIX_INVERSETRANSPOSE
-.. data:: VIEWMATRIX_TRANSPOSE
-.. data:: MODELMATRIX
-.. data:: MODELMATRIX_INVERSE
-.. data:: MODELMATRIX_INVERSETRANSPOSE
-.. data:: MODELMATRIX_TRANSPOSE
-.. data:: MODELVIEWMATRIX
-.. data:: MODELVIEWMATRIX_INVERSE
-.. data:: MODELVIEWMATRIX_INVERSETRANSPOSE
-.. data:: MODELVIEWMATRIX_TRANSPOSE
-.. data:: CAM_POS
-
- Current camera position
-
-.. data:: CONSTANT_TIMER
-
- User a timer for the uniform value.
-
-.. data:: SHD_TANGENT
-
-------
-States
-------
-
-See :class:`bge.types.KX_StateActuator`
-
-.. data:: KX_STATE1
-.. data:: KX_STATE2
-.. data:: KX_STATE3
-.. data:: KX_STATE4
-.. data:: KX_STATE5
-.. data:: KX_STATE6
-.. data:: KX_STATE7
-.. data:: KX_STATE8
-.. data:: KX_STATE9
-.. data:: KX_STATE10
-.. data:: KX_STATE11
-.. data:: KX_STATE12
-.. data:: KX_STATE13
-.. data:: KX_STATE14
-.. data:: KX_STATE15
-.. data:: KX_STATE16
-.. data:: KX_STATE17
-.. data:: KX_STATE18
-.. data:: KX_STATE19
-.. data:: KX_STATE20
-.. data:: KX_STATE21
-.. data:: KX_STATE22
-.. data:: KX_STATE23
-.. data:: KX_STATE24
-.. data:: KX_STATE25
-.. data:: KX_STATE26
-.. data:: KX_STATE27
-.. data:: KX_STATE28
-.. data:: KX_STATE29
-.. data:: KX_STATE30
-
-.. _state-actuator-operation:
-
-See :class:`bge.types.KX_StateActuator.operation`
-
-.. data:: KX_STATE_OP_CLR
-
- Substract bits to state mask
-
- :value: 0
-
-.. data:: KX_STATE_OP_CPY
-
- Copy state mask
-
- :value: 1
-
-.. data:: KX_STATE_OP_NEG
-
- Invert bits to state mask
-
- :value: 2
-
-.. data:: KX_STATE_OP_SET
-
- Add bits to state mask
-
- :value: 3
diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst
deleted file mode 100644
index 02c3beef672..00000000000
--- a/doc/python_api/rst/bge.render.rst
+++ /dev/null
@@ -1,425 +0,0 @@
-
-Rasterizer (bge.render)
-=======================
-
-*****
-Intro
-*****
-
-.. module:: bge.render
-
-Example of using a :class:`bge.types.SCA_MouseSensor`,
-and two :class:`bge.types.KX_ObjectActuator` to implement MouseLook:
-
-.. note::
- This can also be achieved with the :class:`bge.types.KX_MouseActuator`.
-
-.. code-block:: python
-
- # To use a mouse movement sensor "Mouse" and a
- # motion actuator to mouse look:
- import bge
-
- # scale sets the speed of motion
- scale = 1.0, 0.5
-
- co = bge.logic.getCurrentController()
- obj = co.owner
- mouse = co.sensors["Mouse"]
- lmotion = co.actuators["LMove"]
- wmotion = co.actuators["WMove"]
-
- # Transform the mouse coordinates to see how far the mouse has moved.
- def mousePos():
- x = (bge.render.getWindowWidth() / 2 - mouse.position[0]) * scale[0]
- y = (bge.render.getWindowHeight() / 2 - mouse.position[1]) * scale[1]
- return (x, y)
-
- pos = mousePos()
-
- # Set the amount of motion: X is applied in world coordinates...
- wmotion.useLocalTorque = False
- wmotion.torque = ((0.0, 0.0, pos[0]))
-
- # ...Y is applied in local coordinates
- lmotion.useLocalTorque = True
- lmotion.torque = ((-pos[1], 0.0, 0.0))
-
- # Activate both actuators
- co.activate(lmotion)
- co.activate(wmotion)
-
- # Centre the mouse
- bge.render.setMousePosition(int(bge.render.getWindowWidth() / 2), int(bge.render.getWindowHeight() / 2))
-
-*********
-Constants
-*********
-
-.. data:: KX_TEXFACE_MATERIAL
-
- Materials as defined by the texture face settings.
-
-.. data:: KX_BLENDER_MULTITEX_MATERIAL
-
- Materials approximating blender materials with multitexturing.
-
-.. data:: KX_BLENDER_GLSL_MATERIAL
-
- Materials approximating blender materials with GLSL.
-
-.. DATA:: VSYNC_OFF
-
- Disables vsync
-
-.. DATA:: VSYNC_ON
-
- Enables vsync
-
-.. DATA:: VSYNC_ADAPTIVE
-
- Enables adaptive vsync if supported.
- Adaptive vsync enables vsync if the framerate is above the monitors refresh rate.
- Otherwise, vsync is diabled if the framerate is too low.
-
-.. data:: LEFT_EYE
-
- Left eye being used during stereoscopic rendering.
-
-.. data:: RIGHT_EYE
-
- Right eye being used during stereoscopic rendering.
-
-.. data:: RAS_OFS_RENDER_BUFFER
-
- The pixel buffer for offscreen render is a RenderBuffer. Argument to :func:`offScreenCreate`
-
-.. data:: RAS_OFS_RENDER_TEXTURE
-
- The pixel buffer for offscreen render is a Texture. Argument to :func:`offScreenCreate`
-
-
-*****
-Types
-*****
-
-.. class:: RASOffScreen
-
- An off-screen render buffer object.
-
- Use :func:`offScreenCreate` to create it.
- Currently it can only be used in the :class:`bge.texture.ImageRender`
- constructor to render on a FBO rather than the default viewport.
-
- .. attribute:: width
-
- The width in pixel of the FBO
-
- :type: integer
-
- .. attribute:: height
-
- The height in pixel of the FBO
-
- :type: integer
-
- .. attribute:: color
-
- The underlying OpenGL bind code of the texture object that holds
- the rendered image, 0 if the FBO is using RenderBuffer.
- The choice between RenderBuffer and Texture is determined
- by the target argument of :func:`offScreenCreate`.
-
- :type: integer
-
-
-*********
-Functions
-*********
-
-.. function:: getWindowWidth()
-
- Gets the width of the window (in pixels)
-
- :rtype: integer
-
-.. function:: getWindowHeight()
-
- Gets the height of the window (in pixels)
-
- :rtype: integer
-
-.. function:: setWindowSize(width, height)
-
- Set the width and height of the window (in pixels). This also works for fullscreen applications.
-
- .. note:: Only works in the standalone player, not the Blender-embedded player.
-
- :arg width: width in pixels
- :type width: integer
- :arg height: height in pixels
- :type height: integer
-
-.. function:: setFullScreen(enable)
-
- Set whether or not the window should be fullscreen.
-
- .. note:: Only works in the standalone player, not the Blender-embedded player.
-
- :arg enable: ``True`` to set full screen, ``False`` to set windowed.
- :type enable: bool
-
-.. function:: getFullScreen()
-
- Returns whether or not the window is fullscreen.
-
- .. note:: Only works in the standalone player, not the Blender-embedded player; there it always returns False.
-
- :rtype: bool
-
-.. function:: getDisplayDimensions()
-
- Get the display dimensions, in pixels, of the display (e.g., the
- monitor). Can return the size of the entire view, so the
- combination of all monitors; for example, ``(3840, 1080)`` for two
- side-by-side 1080p monitors.
-
- :rtype: tuple (width, height)
-
-.. function:: makeScreenshot(filename)
-
- Writes an image file with the current displayed frame.
-
- The image is written to *'filename'*.
- The path may be absolute (eg. ``/home/foo/image``) or relative when started with
- ``//`` (eg. ``//image``). Note that absolute paths are not portable between platforms.
- If the filename contains a ``#``,
- it will be replaced by an incremental index so that screenshots can be taken multiple
- times without overwriting the previous ones (eg. ``image-#``).
-
- Settings for the image are taken from the render settings (file format and respective settings,
- gamma and colospace conversion, etc).
- The image resolution matches the framebuffer, meaning, the window size and aspect ratio.
- When running from the standalone player, instead of the embedded player, only PNG files are supported.
- Additional color conversions are also not supported.
-
- :arg filename: path and name of the file to write
- :type filename: string
-
-
-.. function:: enableVisibility(visible)
-
- Deprecated; doesn't do anything.
-
-
-.. function:: showMouse(visible)
-
- Enables or disables the operating system mouse cursor.
-
- :arg visible:
- :type visible: boolean
-
-
-.. function:: setMousePosition(x, y)
-
- Sets the mouse cursor position.
-
- :arg x: X-coordinate in screen pixel coordinates.
- :type x: integer
- :arg y: Y-coordinate in screen pixel coordinates.
- :type y: integer
-
-
-.. function:: setBackgroundColor(rgba)
-
- Deprecated and no longer functional. Use :py:meth:`bge.types.KX_WorldInfo.backgroundColor` instead.
-
-
-.. function:: setEyeSeparation(eyesep)
-
- Sets the eye separation for stereo mode. Usually Focal Length/30 provides a confortable value.
-
- :arg eyesep: The distance between the left and right eye.
- :type eyesep: float
-
-
-.. function:: getEyeSeparation()
-
- Gets the current eye separation for stereo mode.
-
- :rtype: float
-
-
-.. function:: setFocalLength(focallength)
-
- Sets the focal length for stereo mode. It uses the current camera focal length as initial value.
-
- :arg focallength: The focal length.
- :type focallength: float
-
-.. function:: getFocalLength()
-
- Gets the current focal length for stereo mode.
-
- :rtype: float
-
-.. function:: getStereoEye()
-
- Gets the current stereoscopy eye being rendered.
- This function is mainly used in a :class:`bge.types.KX_Scene.pre_draw` callback
- function to customize the camera projection matrices for each
- stereoscopic eye.
-
- :rtype: LEFT_EYE, RIGHT_EYE
-
-.. function:: setMaterialMode(mode)
-
- Set the material mode to use for OpenGL rendering.
-
- :arg mode: material mode
- :type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
-
- .. note:: Changes will only affect newly created scenes.
-
-
-.. function:: getMaterialMode(mode)
-
- Get the material mode to use for OpenGL rendering.
-
- :rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
-
-
-.. function:: setGLSLMaterialSetting(setting, enable)
-
- Enables or disables a GLSL material setting.
-
- :arg setting:
- :type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
- :arg enable:
- :type enable: boolean
-
-
-.. function:: getGLSLMaterialSetting(setting)
-
- Get the state of a GLSL material setting.
-
- :arg setting:
- :type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
- :rtype: boolean
-
-.. function:: setAnisotropicFiltering(level)
-
- Set the anisotropic filtering level for textures.
-
- :arg level: The new anisotropic filtering level to use
- :type level: integer (must be one of 1, 2, 4, 8, 16)
-
- .. note:: Changing this value can cause all textures to be recreated, which can be slow.
-
-.. function:: getAnisotropicFiltering()
-
- Get the anisotropic filtering level used for textures.
-
- :rtype: integer (one of 1, 2, 4, 8, 16)
-
-.. function:: setMipmapping(value)
-
- Change how to use mipmapping.
-
- :type value: RAS_MIPMAP_NONE, RAS_MIPMAP_NEAREST, RAS_MIPMAP_LINEAR
-
- .. note:: Changing this value can cause all textures to be recreated, which can be slow.
-
-.. function:: getMipmapping()
-
- Get the current mipmapping setting.
-
- :rtype: RAS_MIPMAP_NONE, RAS_MIPMAP_NEAREST, RAS_MIPMAP_LINEAR
-
-.. function:: drawLine(fromVec,toVec,color)
-
- Draw a line in the 3D scene.
-
- :arg fromVec: the origin of the line
- :type fromVec: list [x, y, z]
- :arg toVec: the end of the line
- :type toVec: list [x, y, z]
- :arg color: the color of the line
- :type color: list [r, g, b]
-
-
-.. function:: enableMotionBlur(factor)
-
- Enable the motion blur effect.
-
- :arg factor: the ammount of motion blur to display.
- :type factor: float [0.0 - 1.0]
-
-
-.. function:: disableMotionBlur()
-
- Disable the motion blur effect.
-
-.. function:: showFramerate(enable)
-
- Show or hide the framerate.
-
- :arg enable:
- :type enable: boolean
-
-.. function:: showProfile(enable)
-
- Show or hide the profile.
-
- :arg enable:
- :type enable: boolean
-
-.. function:: showProperties(enable)
-
- Show or hide the debug properties.
-
- :arg enable:
- :type enable: boolean
-
-.. function:: autoDebugList(enable)
-
- Enable or disable auto adding debug properties to the debug list.
-
- :arg enable:
- :type enable: boolean
-
-.. function:: clearDebugList()
-
- Clears the debug property list.
-
-.. function:: setVsync(value)
-
- Set the vsync value
-
- :arg value: One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE
- :type value: integer
-
-.. function:: getVsync()
-
- Get the current vsync value
-
- :rtype: One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE
-
-.. function:: offScreenCreate(width,height[,samples=0][,target=bge.render.RAS_OFS_RENDER_BUFFER])
-
- Create a Off-screen render buffer object.
-
- :arg width: the width of the buffer in pixels
- :type width: integer
- :arg height: the height of the buffer in pixels
- :type height: integer
- :arg samples: the number of multisample for anti-aliasing (MSAA), 0 to disable MSAA
- :type samples: integer
- :arg target: the pixel storage: :data:`RAS_OFS_RENDER_BUFFER` to render on RenderBuffers (the default),
- :data:`RAS_OFS_RENDER_TEXTURE` to render on texture.
- The later is interesting if you want to access the texture directly (see :attr:`RASOffScreen.color`).
- Otherwise the default is preferable as it's more widely supported by GPUs and more efficient.
- If the GPU does not support MSAA+Texture (e.g. Intel HD GPU), MSAA will be disabled.
- :type target: integer
- :rtype: :class:`RASOffScreen`
-
diff --git a/doc/python_api/rst/bge.texture.rst b/doc/python_api/rst/bge.texture.rst
deleted file mode 100644
index cd99cde0bc8..00000000000
--- a/doc/python_api/rst/bge.texture.rst
+++ /dev/null
@@ -1,1557 +0,0 @@
-
-Video Texture (bge.texture)
-===========================
-
-************
-Introduction
-************
-
-The ``bge.texture`` module allows you to manipulate textures during the game.
-Several sources for texture are possible: video files, image files, video capture,
-memory buffer, camera render or a mix of that.
-The video and image files can be loaded from the Internet using a URL instead of a file name.
-In addition, you can apply filters on the images before sending them to the GPU,
-allowing video effect: blue screen, color band, gray, normal map.
-``bge.texture`` uses FFmpeg to load images and videos.
-All the formats and codecs that FFmpeg supports are supported by ``bge.texture``,
-including but not limited to:
-
-* AVI
-* Ogg
-* Xvid
-* Theora
-* dv1394 camera
-* video4linux capture card (this includes many webcams)
-* videoForWindows capture card (this includes many webcams)
-* JPG
-
-
-How it works
-------------
-
-The principle is simple: first you identify a texture on an existing object using the
-:class:`~bge.texture.materialID` function, then you create a new texture with dynamic content
-and swap the two textures in the GPU.
-
-The game engine is not aware of the substitution and continues to display the object as always,
-except that you are now in control of the texture.
-
-When the texture object is deleted, the new texture is deleted and the old texture restored.
-
-
-Game Preparation
-----------------
-
-Before you can use the :mod:`bge.texture` module,
-you must have objects with textures applied appropriately.
-
-Imagine you want to have a television showing live broadcast programs in the game.
-You will create a television object and UV-apply a different texture at the place of the screen,
-for example ``tv.png``. What this texture looks like is not important;
-probably you want to make it dark gray to simulate power-off state.
-When the television must be turned on, you create a dynamic texture from a video capture card
-and use it instead of ``tv.png``: the TV screen will come to life.
-
-You have two ways to define textures that ``bge.texture`` can grab:
-
-- Simple UV texture.
-- Blender material with image texture channel.
-
-Because ``bge.texture`` works at texture level, it is compatible with all
-the Blender Game Engine's fancy texturing features: GLSL, multi-texture, custom shaders, etc.
-
-
-********
-Examples
-********
-
-.. include:: __/examples/bge.texture.py
- :start-line: 1
- :end-line: 5
-
-.. literalinclude:: __/examples/bge.texture.py
- :lines: 7-
-
-.. include:: __/examples/bge.texture.1.py
- :start-line: 1
- :end-line: 6
-
-.. literalinclude:: __/examples/bge.texture.1.py
- :lines: 8-
-
-.. include:: __/examples/bge.texture.2.py
- :start-line: 1
- :end-line: 6
-
-.. literalinclude:: __/examples/bge.texture.2.py
- :lines: 8-
-
-
-.. module:: bge.texture
-
-*************
-Video classes
-*************
-
-.. class:: VideoFFmpeg(file, capture=-1, rate=25.0, width=0, height=0)
-
- FFmpeg video source, used for video files, video captures, or video streams.
-
- :arg file: Path to the video to load; if capture >= 0 on Windows, this parameter will not be used.
- :type file: str
- :arg capture: Capture device number; if >= 0, the corresponding webcam will be used. (optional)
- :type capture: int
- :arg rate: Capture rate. (optional, used only if capture >= 0)
- :type rate: float
- :arg width: Capture width. (optional, used only if capture >= 0)
- :type width: int
- :arg height: Capture height. (optional, used only if capture >= 0)
- :type height: int
-
- .. attribute:: status
-
- Video status. (readonly)
-
- :type: int
- :value: see `FFmpeg Video and Image Status`_.
-
- .. attribute:: range
-
- The start and stop time of the video playback, expressed in seconds from beginning.
- By default the entire video.
-
- :type: sequence of two floats
-
- .. attribute:: repeat
-
- Number of times to replay the video, -1 for infinite repeat.
-
- :type: int
-
- .. attribute:: framerate
-
- Relative frame rate, <1.0 for slow, >1.0 for fast.
-
- :type: float
-
- .. attribute:: valid
-
- Tells if an image is available. (readonly)
-
- :type: bool
-
- .. attribute:: image
-
- Image data. (readonly)
-
- :type: :class:`~bgl.Buffer` or None
-
- .. attribute:: size
-
- Image size. (readonly)
-
- :type: tuple of two ints
-
- .. attribute:: scale
-
- Set to True to activate fast nearest neighbor scaling algorithm.
- Texture width and height must be a power of 2.
- If the video picture size is not a power of 2, rescaling is required.
- By default ``bge.texture`` uses the precise but slow ``gluScaleImage()`` function.
- Best is to rescale the video offline so that no scaling is necessary at runtime!
-
- :type: bool
-
- .. attribute:: flip
-
- If True the imaged will be flipped vertically.
- FFmpeg always delivers the image upside down, so this attribute is set to True by default.
-
- :type: bool
-
- .. attribute:: filter
-
- An additional filter that is applied on the video before sending it to the GPU.
-
- :type: one of:
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
- .. attribute:: preseek
-
- Number of frames of preseek.
-
- :type: int
-
- .. attribute:: deinterlace
-
- Deinterlace image.
-
- :type: bool
-
- .. method:: play()
-
- Play (restart) video.
-
- :return: Whether the video was ready or stopped.
- :rtype: bool
-
- .. method:: pause()
-
- Pause video.
-
- :return: Whether the video was playing.
- :rtype: bool
-
- .. method:: stop()
-
- Stop video (play will replay it from start).
-
- :return: Whether the video was playing.
- :rtype: bool
-
- .. method:: refresh(buffer=None, format="RGBA", timestamp=-1.0)
-
- Refresh video - get its status and optionally copy the frame to an external buffer.
-
- :arg buffer: An optional object that implements the buffer protocol.
- If specified, the image is copied to the buffer, which must be big enough or an exception is thrown.
- :type buffer: any buffer type
- :arg format: An optional image format specifier for the image that will be copied to the buffer.
- Only valid values are "RGBA" or "BGRA"
- :type format: str
- :arg timestamp: An optional timestamp (in seconds from the start of the movie)
- of the frame to be copied to the buffer.
- :type timestamp: float
- :return: see `FFmpeg Video and Image Status`_.
- :rtype: int
-
-
-*************
-Image classes
-*************
-
-.. class:: ImageFFmpeg(file)
-
- FFmpeg image source, used for image files and web based images.
-
- :arg file: Path to the image to load.
- :type file: str
-
- .. attribute:: status
-
- Image status. (readonly)
-
- :type: int
- :value: see `FFmpeg Video and Image Status`_.
-
- .. attribute:: valid
-
- Tells if an image is available. (readonly)
-
- :type: bool
-
- .. attribute:: image
-
- Image data. (readonly)
-
- :type: :class:`~bgl.Buffer` or None
-
- .. attribute:: size
-
- Image size. (readonly)
-
- :type: tuple of two ints
-
- .. attribute:: scale
-
- Fast scale of image (near neighbour).
-
- :type: bool
-
- .. attribute:: flip
-
- Flip image vertically.
-
- :type: bool
-
- .. attribute:: filter
-
- Pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
- .. method:: refresh(buffer=None, format="RGBA")
-
- Refresh image, get its status and optionally copy the frame to an external buffer.
-
- :arg buffer: An optional object that implements the buffer protocol.
- If specified, the image is copied to the buffer, which must be big enough or an exception is thrown.
- :type buffer: any buffer type
- :arg format: An optional image format specifier for the image that will be copied to the buffer.
- Only valid values are "RGBA" or "BGRA"
- :type format: str
- :return: see `FFmpeg Video and Image Status`_.
- :rtype: int
-
- .. method:: reload(newname=None)
-
- Reload image, i.e. reopen it.
-
- :arg newname: Path to a new image. (optional)
- :type newname: str
-
-.. class:: ImageBuff(width, height, color=0, scale=False)
-
- Image from application memory.
- For computer generated images, drawing applications.
-
- :arg width: Width of the image.
- :type width: int
- :arg height: Height of the image.
- :type height: int
- :arg color: Value to initialize RGB channels with. The initialized buffer will have
- all pixels set to (color, color, color, 255). (optional)
- :type color: int in [0, 255]
- :arg scale: Image uses scaling. (optional)
- :type scale: bool
-
- .. attribute:: filter
-
- Pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
- .. attribute:: flip
-
- Flip image vertically.
-
- :type: bool
-
- .. attribute:: image
-
- Image data. (readonly)
-
- :type: :class:`~bgl.Buffer` or None
-
- .. method:: load(imageBuffer, width, height)
-
- Load image from buffer.
-
- :arg imageBuffer: Buffer to load the image from.
- :type imageBuffer: :class:`~bgl.Buffer` or Python object implementing the buffer protocol (f.ex. bytes)
- :arg width: Width of the image to load.
- :type width: int
- :arg height: Height of the image to load.
- :type height: int
-
- .. method:: plot(imageBuffer, width, height, positionX, positionY, mode=IMB_BLEND_COPY)
-
- Update image buffer.
-
- :arg imageBuffer: Buffer to load the new data from.
- :type imageBuffer: :class:`~bgl.Buffer`, :class:`ImageBuff`
- or Python object implementing the buffer protocol (f.ex. bytes)
- :arg width: Width of the data to load.
- :type width: int
- :arg height: Height of the data to load.
- :type height: int
- :arg positionX: Left boundary of the region to be drawn on.
- :type positionX: int
- :arg positionY: Upper boundary of the region to be drawn on.
- :type positionY: int
- :arg mode: Drawing mode, see `Image Blending Modes`_.
- :type mode: int
-
-
- .. attribute:: scale
-
- Fast scale of image (near neighbour).
-
- :type: bool
-
- .. attribute:: size
-
- Image size. (readonly)
-
- :type: tuple of two ints
-
- .. attribute:: valid
-
- Tells if an image is available. (readonly)
-
- :type: bool
-
-.. class:: ImageMirror(scene, observer, mirror, material=0)
-
- Image source from mirror.
-
- :arg scene: Scene in which the image has to be taken.
- :type scene: :class:`~bge.types.KX_Scene`
- :arg observer: Reference object for the mirror
- (the object from which the mirror has to be looked at, for example a camera).
- :type observer: :class:`~bge.types.KX_GameObject`
- :arg mirror: Object holding the mirror.
- :type mirror: :class:`~bge.types.KX_GameObject`
- :arg material: ID of the mirror's material to be used for mirroring. (optional)
- :type material: int
-
- .. attribute:: alpha
-
- Use alpha in texture.
-
- :type: bool
-
- .. attribute:: background
-
- Background color.
-
- :type: int or float list [r, g, b, a] in [0.0, 255.0]
-
- .. attribute:: capsize
-
- Size of render area.
-
- :type: sequence of two ints
-
- .. attribute:: clip
-
- Clipping distance.
-
- :type: float in [0.01, 5000.0]
-
- .. attribute:: filter
-
- Pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
- .. attribute:: flip
-
- Flip image vertically.
-
- :type: bool
-
- .. attribute:: image
-
- Image data. (readonly)
-
- :type: :class:`~bgl.Buffer` or None
-
- .. method:: refresh(buffer=None, format="RGBA")
-
- Refresh image - render and copy the image to an external buffer (optional)
- then invalidate its current content.
-
- :arg buffer: An optional object that implements the buffer protocol.
- If specified, the image is rendered and copied to the buffer,
- which must be big enough or an exception is thrown.
- :type buffer: any buffer type
- :arg format: An optional image format specifier for the image that will be copied to the buffer.
- Only valid values are "RGBA" or "BGRA"
- :type format: str
-
- .. attribute:: scale
-
- Fast scale of image (near neighbour).
-
- :type: bool
-
- .. attribute:: size
-
- Image size (readonly).
-
- :type: tuple of two ints
-
- .. attribute:: valid
-
- Tells if an image is available. (readonly)
-
- :type: bool
-
- .. attribute:: whole
-
- Use whole viewport to render.
-
- :type: bool
-
-.. class:: ImageMix
-
- Image mixer used to mix multiple image sources together.
-
- .. attribute:: filter
-
- Pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
- .. attribute:: flip
-
- Flip image vertically.
-
- :type: bool
-
- .. method:: getSource(id)
-
- Get image source.
-
- :arg id: Identifier of the source to get.
- :type id: str
-
- :return: Image source.
- :rtype: one of...
-
- * :class:`VideoFFmpeg`
- * :class:`ImageFFmpeg`
- * :class:`ImageBuff`
- * :class:`ImageMirror`
- * :class:`ImageMix`
- * :class:`ImageRender`
- * :class:`ImageViewport`
-
- .. method:: getWeight(id)
-
- Get image source weight.
-
- :arg id: Identifier of the source.
- :type id: str
-
- :return: Weight of the source.
- :rtype: int
-
- .. attribute:: image
-
- Image data. (readonly)
-
- :type: :class:`~bgl.Buffer` or None
-
- .. method:: refresh(buffer=None, format="RGBA")
-
- Refresh image - calculate and copy the image to an external buffer (optional)
- then invalidate its current content.
-
- :arg buffer: An optional object that implements the buffer protocol.
- If specified, the image is calculated and copied to the buffer,
- which must be big enough or an exception is thrown.
- :type buffer: any buffer type
- :arg format: An optional image format specifier for the image that will be copied to the buffer.
- Only valid values are "RGBA" or "BGRA"
- :type format: str
-
- .. attribute:: scale
-
- Fast scale of image (near neighbour).
-
- :type: bool
-
- .. attribute:: size
-
- Image size. (readonly)
-
- :type: tuple of two ints
-
- .. method:: setSource(id, image)
-
- Set image source - all sources must have the same size.
-
- :arg id: Identifier of the source to set.
- :type id: str
- :arg image: Image source of type...
-
- * :class:`VideoFFmpeg`
- * :class:`ImageFFmpeg`
- * :class:`ImageBuff`
- * :class:`ImageMirror`
- * :class:`ImageMix`
- * :class:`ImageRender`
- * :class:`ImageViewport`
-
- .. method:: setWeight(id, weight)
-
- Set image source weight - the sum of the weights should be 256 to get full color intensity in the output.
-
- :arg id: Identifier of the source.
- :type id: str
- :arg weight: Weight of the source.
- :type weight: int
-
- .. attribute:: valid
-
- Tells if an image is available. (readonly)
-
- :type: bool
-
-.. class:: ImageRender(scene, camera)
-
- Image source from a render of a non active camera.
- The render is done on a custom framebuffer object if fbo is specified,
- otherwise on the default framebuffer.
-
- :arg scene: Scene in which the image has to be taken.
- :type scene: :class:`~bge.types.KX_Scene`
- :arg camera: Camera from which the image has to be taken.
- :type camera: :class:`~bge.types.KX_Camera`
- :arg fbo: Off-screen render buffer object (optional)
- :type fbo: :class:`~bge.render.RASOffScreen`
-
- .. attribute:: alpha
-
- Use alpha in texture.
-
- :type: bool
-
- .. attribute:: background
-
- Background color.
-
- :type: int or float list [r, g, b, a] in [0.0, 255.0]
-
- .. attribute:: capsize
-
- Size of render area.
-
- :type: sequence of two ints
-
- .. attribute:: filter
-
- Pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
- .. attribute:: flip
-
- Flip image vertically.
-
- :type: bool
-
- .. attribute:: image
-
- Image data. (readonly)
-
- :type: :class:`~bgl.Buffer` or None
-
- .. attribute:: scale
-
- Fast scale of image (near neighbour).
-
- :type: bool
-
- .. attribute:: size
-
- Image size. (readonly)
-
- :type: tuple of two ints
-
- .. attribute:: valid
-
- Tells if an image is available. (readonly)
-
- :type: bool
-
- .. attribute:: whole
-
- Use whole viewport to render.
-
- :type: bool
-
- .. attribute:: depth
-
- Use depth component of render as array of float - not suitable for texture source,
- should only be used with bge.texture.imageToArray(mode='F').
-
- :type: bool
-
- .. attribute:: zbuff
-
- Use depth component of render as grayscale color - suitable for texture source.
-
- :type: bool
-
- .. method:: render()
-
- Render the scene but do not extract the pixels yet.
- The function returns as soon as the render commands have been send to the GPU.
- The render will proceed asynchronously in the GPU while the host can perform other tasks.
- To complete the render, you can either call :func:`refresh`
- directly of refresh the texture of which this object is the source.
- This method is useful to implement asynchronous render for optimal performance: call render()
- on frame n and refresh() on frame n+1 to give as much as time as possible to the GPU
- to render the frame while the game engine can perform other tasks.
-
- :return: True if the render was initiated, False if the render cannot be performed (e.g. the camera is active)
- :rtype: bool
-
- .. method:: refresh()
- .. method:: refresh(buffer, format="RGBA")
-
- Refresh video - render and optionally copy the image to an external buffer then invalidate its current content.
- The render may have been started earlier with the :func:`render` method,
- in which case this function simply waits for the render operations to complete.
- When called without argument, the pixels are not extracted but the render is guaranteed
- to be completed when the function returns.
- This only makes sense with offscreen render on texture target (see :func:`~bge.render.offScreenCreate`).
-
- :arg buffer: An object that implements the buffer protocol.
- If specified, the image is copied to the buffer, which must be big enough or an exception is thrown.
- The transfer to the buffer is optimal if no processing of the image is needed.
- This is the case if ``flip=False, alpha=True, scale=False, whole=True, depth=False, zbuff=False``
- and no filter is set.
- :type buffer: any buffer type of sufficient size
- :arg format: An optional image format specifier for the image that will be copied to the buffer.
- Only valid values are "RGBA" or "BGRA"
- :type format: str
- :return: True if the render is complete, False if the render cannot be performed (e.g. the camera is active)
- :rtype: bool
-
-.. class:: ImageViewport
-
- Image source from viewport rendered by the active camera.
- To render from a non active camera see :class:`ImageRender`.
-
- .. attribute:: alpha
-
- Use alpha in texture.
-
- :type: bool
-
- .. attribute:: capsize
-
- Size of viewport area being captured.
-
- :type: sequence of two ints
-
- .. attribute:: filter
-
- Pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
- .. attribute:: flip
-
- Flip image vertically.
-
- :type: bool
-
- .. attribute:: image
-
- Image data. (readonly)
-
- :type: :class:`~bgl.Buffer` or None
-
- .. attribute:: position
-
- Upper left corner of the captured area.
-
- :type: sequence of two ints
-
- .. method:: refresh(buffer=None, format="RGBA")
-
- Refresh video - copy the viewport to an external buffer (optional) then invalidate its current content.
-
- :arg buffer: An optional object that implements the buffer protocol. If specified,
- the image is copied to the buffer, which must be big enough or an exception is thrown.
- The transfer to the buffer is optimal if no processing of the image is needed. This is the case if
- ``flip=False, alpha=True, scale=False, whole=True, depth=False, zbuff=False`` and no filter is set.
- :type buffer: any buffer type
- :arg format: An optional image format specifier for the image that will be copied to the buffer.
- Only valid values are "RGBA" or "BGRA"
- :type format: str
-
- .. attribute:: scale
-
- Fast scale of image (near neighbour).
-
- :type: bool
-
- .. attribute:: size
-
- Image size. (readonly)
-
- :type: tuple of two ints
-
- .. attribute:: valid
-
- Tells if an image is available. (readonly)
-
- :type: bool
-
- .. attribute:: whole
-
- Use whole viewport to capture.
-
- :type: bool
-
- .. attribute:: depth
-
- Use depth component of viewport as array of float - not suitable for texture source,
- should only be used with ``bge.texture.imageToArray(mode='F')``.
-
- :type: bool
-
- .. attribute:: zbuff
-
- Use depth component of viewport as grayscale color - suitable for texture source.
-
- :type: bool
-
-.. class:: VideoDeckLink(format, capture=0)
-
- Image source from an external video stream captured with a DeckLink video card from
- Black Magic Design.
- Before this source can be used, a DeckLink hardware device must be installed, it can be a PCIe card
- or a USB device, and the 'Desktop Video' software package (version 10.4 or above must be installed)
- on the host as described in the DeckLink documentation.
- If in addition you have a recent nVideo Quadro card, you can benefit from the 'GPUDirect' technology
- to push the captured video frame very efficiently to the GPU. For this you need to install the
- 'DeckLink SDK' version 10.4 or above and copy the 'dvp.dll' runtime library to Blender's
- installation directory or to any other place where Blender can load a DLL from.
-
- :arg format: string describing the video format to be captured.
- :type format: str
- :arg capture: Card number from which the input video must be captured.
- :type capture: int
-
- The format argument must be written as ``<displayMode>/<pixelFormat>[/3D][:<cacheSize>]``
- where ``<displayMode>`` describes the frame size and rate and <pixelFormat> the encoding of the pixels.
- The optional ``/3D`` suffix is to be used if the video stream is stereo with a left and right eye feed.
- The optional ``:<cacheSize>`` suffix determines the number of the video frames kept in cache, by default 8.
- Some DeckLink cards won't work below a certain cache size. The default value 8 should be sufficient for all cards.
- You may try to reduce the cache size to reduce the memory footprint. For example the The 4K Extreme is known
- to work with 3 frames only, the Extreme 2 needs 4 frames and the Intensity Shuttle needs 6 frames, etc.
- Reducing the cache size may be useful when Decklink is used in conjunction with GPUDirect:
- all frames must be locked in memory in that case and that puts a lot of pressure on memory.
- If you reduce the cache size too much, you'll get no error but no video feed either.
-
- The valid ``<displayMode>`` values are copied from the ``BMDDisplayMode`` enum in the DeckLink API
- without the 'bmdMode' prefix. In case a mode that is not in this list is added in a later version
- of the SDK, it is also possible to specify the 4 letters of the internal code for that mode.
- You will find the internal code in the ``DeckLinkAPIModes.h`` file that is part of the SDK.
- Here is for reference the full list of supported display modes with their equivalent internal code:
-
- Internal Codes
- - NTSC 'ntsc'
- - NTSC2398 'nt23'
- - PAL 'pal '
- - NTSCp 'ntsp'
- - PALp 'palp'
- HD 1080 Modes
- - HD1080p2398 '23ps'
- - HD1080p24 '24ps'
- - HD1080p25 'Hp25'
- - HD1080p2997 'Hp29'
- - HD1080p30 'Hp30'
- - HD1080i50 'Hi50'
- - HD1080i5994 'Hi59'
- - HD1080i6000 'Hi60'
- - HD1080p50 'Hp50'
- - HD1080p5994 'Hp59'
- - HD1080p6000 'Hp60'
- HD 720 Modes
- - HD720p50 'hp50'
- - HD720p5994 'hp59'
- - HD720p60 'hp60'
- 2k Modes
- - 2k2398 '2k23'
- - 2k24 '2k24'
- - 2k25 '2k25'
- 4k Modes
- - 4K2160p2398 '4k23'
- - 4K2160p24 '4k24'
- - 4K2160p25 '4k25'
- - 4K2160p2997 '4k29'
- - 4K2160p30 '4k30'
- - 4K2160p50 '4k50'
- - 4K2160p5994 '4k59'
- - 4K2160p60 '4k60'
-
- Most of names are self explanatory. If necessary refer to the DeckLink API documentation for more information.
-
- Similarly, <pixelFormat> is copied from the BMDPixelFormat enum.
-
- Here is for reference the full list of supported pixel format and their equivalent internal code:
-
- Pixel Formats
- - 8BitYUV '2vuy'
- - 10BitYUV 'v210'
- - 8BitARGB * no equivalent code *
- - 8BitBGRA 'BGRA'
- - 10BitRGB 'r210'
- - 12BitRGB 'R12B'
- - 12BitRGBLE 'R12L'
- - 10BitRGBXLE 'R10l'
- - 10BitRGBX 'R10b'
-
- Refer to the DeckLink SDK documentation for a full description of these pixel format.
- It is important to understand them as the decoding of the pixels is NOT done in VideoTexture
- for performance reason. Instead a specific shader must be used to decode the pixel in the GPU.
- Only the '8BitARGB', '8BitBGRA' and '10BitRGBXLE' pixel formats are mapped directly to OpenGL RGB float textures.
- The '8BitYUV' and '10BitYUV' pixel formats are mapped to openGL RGB float texture but require a shader to decode.
- The other pixel formats are sent as a ``GL_RED_INTEGER`` texture (i.e. a texture with only the
- red channel coded as an unsigned 32 bit integer) and are not recommended for use.
-
- Example: ``HD1080p24/10BitYUV/3D:4`` is equivalent to ``24ps/v210/3D:4``
- and represents a full HD stereo feed at 24 frame per second and 4 frames cache size.
-
- Although video format auto detection is possible with certain DeckLink devices, the corresponding
- API is NOT implemented in the BGE. Therefore it is important to specify the format string that
- matches exactly the video feed. If the format is wrong, no frame will be captured.
- It should be noted that the pixel format that you need to specify is not necessarily the actual
- format in the video feed. For example, the 4K Extreme card delivers 8bit RGBs pixels in the
- '10BitRGBXLE' format. Use the 'Media Express' application included in 'Desktop Video' to discover
- which pixel format works for a particular video stream.
-
- .. attribute:: status
-
- Status of the capture: 1=ready to use, 2=capturing, 3=stopped
-
- :type: int
-
- .. attribute:: framerate
-
- Capture frame rate as computed from the video format.
-
- :type: float
-
- .. attribute:: valid
-
- Tells if the image attribute can be used to retrieve the image.
- Always False in this implementation (the image is not available at python level)
-
- :type: bool
-
- .. attribute:: image
-
- The image data. Always None in this implementation.
-
- :type: :class:`~bgl.Buffer` or None
-
- .. attribute:: size
-
- The size of the frame in pixel.
- Stereo frames have double the height of the video frame, i.e. 3D is delivered to the GPU
- as a single image in top-bottom order, left eye on top.
-
- :type: (int,int)
-
- .. attribute:: scale
-
- Not used in this object.
-
- :type: bool
-
- .. attribute:: flip
-
- Not used in this object.
-
- :type: bool
-
- .. attribute:: filter
-
- Not used in this object.
-
- .. method:: play()
-
- Kick-off the capture after creation of the object.
-
- :return: True if the capture could be started, False otherwise.
- :rtype: bool
-
- .. method:: pause()
-
- Temporary stops the capture. Use play() to restart it.
-
- :return: True if the capture could be paused, False otherwise.
- :rtype: bool
-
- .. method:: stop()
-
- Stops the capture.
-
- :return: True if the capture could be stopped, False otherwise.
- :rtype: bool
-
-
-***************
-Texture classes
-***************
-
-.. class:: Texture(gameObj, materialID=0, textureID=0, textureObj=None)
-
- Class that creates the ``Texture`` object that loads the dynamic texture on the GPU.
-
- :arg gameObj: Game object to be created a video texture on.
- :type gameObj: :class:`~bge.types.KX_GameObject`
- :arg materialID: Material ID default, 0 is the first material. (optional)
- :type materialID: int
- :arg textureID: Texture index in case of multi-texture channel, 0 = first channel by default.
- In case of UV texture, this parameter should always be 0. (optional)
- :type textureID: int
- :arg textureObj: Reference to another ``Texture`` object with shared bindId
- which he user might want to reuse the texture.
- If this argument is used, you should not create any source on this texture
- and there is no need to refresh it either: the other ``Texture`` object will
- provide the texture for both materials/textures.(optional)
- :type textureObj: :class:`Texture`
-
- .. attribute:: bindId
-
- OpenGL Bind Name. (readonly)
-
- :type: int
-
- .. method:: close()
-
- Close dynamic texture and restore original.
-
- .. attribute:: mipmap
-
- Mipmap texture.
-
- :type: bool
-
- .. method:: refresh(refresh_source, timestamp=-1.0)
-
- Refresh texture from source.
-
- :arg refresh_source: Whether to also refresh the image source of the texture.
- :type refresh_source: bool
- :arg timestamp: If the texture controls a VideoFFmpeg object:
- timestamp (in seconds from the start of the movie) of the frame to be loaded; this can be
- used for video-sound synchonization by passing :attr:`~bge.types.KX_SoundActuator.time` to it. (optional)
- :type timestamp: float
-
- .. attribute:: source
-
- Source of texture.
-
- :type: one of...
-
- * :class:`VideoFFmpeg`
- * :class:`VideoDeckLink`
- * :class:`ImageFFmpeg`
- * :class:`ImageBuff`
- * :class:`ImageMirror`
- * :class:`ImageMix`
- * :class:`ImageRender`
- * :class:`ImageViewport`
-
-.. class:: DeckLink(cardIdx=0, format="")
-
- Certain DeckLink devices can be used to playback video: the host sends video frames regularly
- for immediate or scheduled playback. The video feed is outputted on HDMI or SDI interfaces.
- This class supports the immediate playback mode: it has a source attribute that is assigned
- one of the source object in the bge.texture module. Refreshing the DeckLink object causes
- the image source to be computed and sent to the DeckLink device for immediate transmission
- on the output interfaces. Keying is supported: it allows to composite the frame with an
- input video feed that transits through the DeckLink card.
-
- :arg cardIdx: Number of the card to be used for output (0=first card).
- It should be noted that DeckLink devices are usually half duplex:
- they can either be used for capture or playback but not both at the same time.
- :type cardIdx: int
- :arg format: String representing the display mode of the output feed.
- :type format: str
-
- The default value of the format argument is reserved for auto detection but it is currently
- not supported (it will generate a runtime error) and thus the video format must be explicitly
- specified. If keying is the goal (see keying attributes), the format must match exactly the
- input video feed, otherwise it can be any format supported by the device (there will be a
- runtime error if not).
- The format of the string is ``<displayMode>[/3D]``.
-
- Refer to :class:`VideoDeckLink` to get the list of acceptable ``<displayMode>``.
- The optional ``/3D`` suffix is used to create a stereo 3D feed.
- In that case the 'right' attribute must also be set to specify the image source for the right eye.
-
- Note: The pixel format is not specified here because it is always BGRA. The alpha channel is
- used in keying to mix the source with the input video feed, otherwise it is not used.
- If a conversion is needed to match the native video format, it is done inside the DeckLink driver
- or device.
-
- .. attribute:: source
-
- This attribute must be set to one of the image sources. If the image size does not fit exactly
- the frame size, the extend attribute determines what to do.
-
- For best performance, the source image should match exactly the size of the output frame.
- A further optimization is achieved if the image source object is ImageViewport or ImageRender
- set for whole viewport, flip disabled and no filter: the GL frame buffer is copied directly
- to the image buffer and directly from there to the DeckLink card (hence no buffer to buffer
- copy inside VideoTexture).
-
- :type: one of...
- - :class:`VideoFFmpeg`
- - :class:`VideoDeckLink`
- - :class:`ImageFFmpeg`
- - :class:`ImageBuff`
- - :class:`ImageMirror`
- - :class:`ImageMix`
- - :class:`ImageRender`
- - :class:`ImageViewport`
-
- .. attribute:: right
-
- If the video format is stereo 3D, this attribute should be set to an image source object
- that will produce the right eye images. If the goal is to render the BGE scene in 3D,
- it can be achieved with 2 cameras, one for each eye, used by 2 ImageRender with an offscreen
- render buffer that is just the size of the video frame.
-
- :type: one of...
- - :class:`VideoFFmpeg`
- - :class:`VideoDeckLink`
- - :class:`ImageFFmpeg`
- - :class:`ImageBuff`
- - :class:`ImageMirror`
- - :class:`ImageMix`
- - :class:`ImageRender`
- - :class:`ImageViewport`
-
- .. attribute:: keying
-
- Specify if keying is enabled. False (default): the output frame is sent unmodified on
- the output interface (in that case no input video is required). True: the output frame
- is mixed with the input video, using the alpha channel to blend the two images and the
- combination is sent on the output interface.
-
- :type: bool
-
- .. attribute:: level
-
- If keying is enabled, sets the keying level from 0 to 255. This value is a global alpha value
- that multiplies the alpha channel of the image source. Use 255 (the default) to keep the alpha
- channel unmodified, 0 to make the output frame totally transparent.
-
- :type: int
-
- .. attribute:: extend
-
- Determines how the image source should be mapped if the size does not fit the video frame size.
- * False (the default): map the image pixel by pixel.
- If the image size is smaller than the frame size, extra space around the image is filled with
- 0-alpha black. If it is larger, the image is cropped to fit the frame size.
- * True: the image is scaled by the nearest neighbor algorithm to fit the frame size.
- The scaling is fast but poor quality. For best results, always adjust the image source to
- match the size of the output video.
-
- :type: bool
-
- .. method:: close()
-
- Close the DeckLink device and release all resources. After calling this method,
- the object cannot be reactivated, it must be destroyed and a new DeckLink object
- created from fresh to restart the output.
-
- .. method:: refresh(refresh_source,ts)
-
- This method must be called frequently to update the output frame in the DeckLink device.
-
- :arg refresh_source: True if the source objects image buffer should be invalidated after being
- used to compute the output frame. This triggers the recomputing of the
- source image on next refresh, which is normally the desired effect.
- False if the image source buffer should stay valid and reused on next refresh.
- Note that the DeckLink device stores the output frame and replays until a
- new frame is sent from the host. Thus, it is not necessary to refresh the
- DeckLink object if it is known that the image source has not changed.
- :type refresh_source: bool
- :arg ts: The timestamp value passed to the image source object to compute the image.
- If unspecified, the BGE clock is used.
- :type ts: float
-
-
-**************
-Filter classes
-**************
-
-.. class:: FilterBGR24
-
- Source filter BGR24.
-
-.. class:: FilterBlueScreen
-
- Filter for Blue Screen.
- The RGB channels of the color are left unchanged, while the output alpha is obtained as follows:
-
- - if the square of the euclidian distance between the RGB color
- and the filter's reference color is smaller than the filter's lower limit,
- the output alpha is set to 0;
- - if that square is bigger than the filter's upper limit, the output alpha is set to 255;
- - otherwise the output alpha is linarly extrapoled between 0 and 255 in the interval of the limits.
-
- .. attribute:: color
-
- Reference color.
-
- :type: sequence of three ints
- :default: (0, 0, 255)
-
- .. attribute:: limits
-
- Reference color limits.
-
- :type: sequence of two ints
- :default: (64, 64)
-
- .. attribute:: previous
-
- Previous pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
-.. class:: FilterColor
-
- Filter for color calculations.
- The output color is obtained by multiplying the reduced 4x4 matrix with the input color
- and adding the remaining column to the result.
-
- .. attribute:: matrix
-
- Matrix [4][5] for color calculation.
-
- :type: sequence of four sequences of five ints
- :default: ((256, 0, 0, 0, 0), (0, 256, 0, 0, 0), (0, 0, 256, 0, 0), (0, 0, 0, 256, 0))
-
- .. attribute:: previous
-
- Previous pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
-.. class:: FilterGray
-
- Filter for grayscale effect.
- Proportions of R, G and B contributions in the output grayscale are 28:151:77.
-
- .. attribute:: previous
-
- Previous pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
-.. class:: FilterLevel
-
- Filter for levels calculations. Each output color component is obtained as follows:
-
- * if it is smaller than its corresponding min value, it is set to 0;
-
- * if it is bigger than its corresponding max value, it is set to 255;
-
- * Otherwise it is linearly extrapoled between 0 and 255 in the (min, max) interval.
-
- .. attribute:: levels
-
- Levels matrix [4] (min, max).
-
- :type: sequence of four sequences of two ints
- :default: ((0, 255), (0, 255), (0, 255), (0, 255))
-
- .. attribute:: previous
-
- Previous pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
-.. class:: FilterNormal
-
- Normal map filter.
-
- .. attribute:: colorIdx
-
- Index of color used to calculate normal (0 - red, 1 - green, 2 - blue, 3 - alpha).
-
- :type: int in [0, 3]
- :default: 0
-
- .. attribute:: depth
-
- Depth of relief.
-
- :type: float
- :default: 4.0
-
- .. attribute:: previous
-
- Previous pixel filter.
-
- :type: one of...
-
- * :class:`FilterBGR24`
- * :class:`FilterBlueScreen`
- * :class:`FilterColor`
- * :class:`FilterGray`
- * :class:`FilterLevel`
- * :class:`FilterNormal`
- * :class:`FilterRGB24`
- * :class:`FilterRGBA32`
-
-.. class:: FilterRGB24
-
- Returns a new input filter object to be used with :class:`ImageBuff` object when the image passed
- to the :meth:`ImageBuff.load` function has the 3-bytes pixel format BGR.
-
-.. class:: FilterRGBA32
-
- Source filter RGBA32.
-
-
-*********
-Functions
-*********
-
-.. function:: getLastError()
-
- Last error that occurred in a bge.texture function.
-
- :return: The description of the last error occurred in a bge.texture function.
- :rtype: str
-
-.. function:: imageToArray(image, mode)
-
- Returns a :class:`~bgl.Buffer` corresponding to the current image stored in a texture source object.
-
- :arg image: Image source object of type:
-
- * :class:`VideoFFmpeg`
- * :class:`ImageFFmpeg`
- * :class:`ImageBuff`
- * :class:`ImageMirror`
- * :class:`ImageMix`
- * :class:`ImageRender`
- * :class:`ImageViewport`
-
- :arg mode: Optional argument representing the pixel format.
-
- - You can use the characters R, G, B for the 3 color channels, A for the alpha channel,
- 0 to force a fixed 0 color channel and 1 to force a fixed 255 color channel.
-
- Examples:
-
- - "BGR" will return 3 bytes per pixel with the
- Blue, Green and Red channels in that order.
- - "RGB1" will return 4 bytes per pixel with the
- Red, Green, Blue channels in that order and the alpha channel forced to 255.
-
- - A special mode "F" allows to return the image as an array of float.
- This mode should only be used to retrieve the depth buffer of the
- class:`ImageViewport` and :class:`ImageRender` objects.
- The default mode is "RGBA".
-
- :type mode: str
-
- :return: An object representing the image as one dimensional array of bytes of size (pixel_size*width*height),
- line by line starting from the bottom of the image. The pixel size and format is determined by the mode
- parameter. For mode 'F', the array is a one dimensional array of float of size (width*height).
- :rtype: :class:`~bgl.Buffer`
-
-.. function:: materialID(object, name)
-
- Returns a numeric value that can be used in :class:`Texture` to create a dynamic texture.
-
- The value corresponds to an internal material number that uses the texture identified
- by name. name is a string representing a texture name with ``IM`` prefix if you want to
- identify the texture directly. This method works for basic tex face and for material,
- provided the material has a texture channel using that particular texture in first
- position of the texture stack. name can also have ``MA`` prefix if you want to identify
- the texture by material. In that case the material must have a texture channel in first
- position.
-
- If the object has no material that matches name, it generates a runtime error.
- Use try/except to catch the exception.
-
- Ex: ``bge.texture.materialID(obj, 'IMvideo.png')``
-
- :arg object: The game object that uses the texture you want to make dynamic.
- :type object: :class:`~bge.types.KX_GameObject`
- :arg name: Name of the texture/material you want to make dynamic.
- :type name: str
-
- :return: The internal material number.
- :rtype: int
-
-.. function:: setLogFile(filename)
-
- Sets the name of a text file in which runtime error messages will be written,
- in addition to the printing of the messages on the Python console.
- Only the runtime errors specific to the VideoTexture module are written in that file,
- ordinary runtime time errors are not written.
-
- :arg filename: Name of the error log file.
- :type filename: str
-
- :return: -1 if the parameter name is invalid (not of type string), else 0.
- :rtype: int
-
-
-*********
-Constants
-*********
-
-FFmpeg Video and Image Status
-+++++++++++++++++++++++++++++
-
-
-.. data:: SOURCE_ERROR
-
-.. data:: SOURCE_EMPTY
-
-.. data:: SOURCE_READY
-
-.. data:: SOURCE_PLAYING
-
-.. data:: SOURCE_STOPPED
-
-
-Image Blending Modes
-++++++++++++++++++++
-
-See Wikipedia's `Blend Modes <https://en.wikipedia.org/wiki/Blend_modes>`_ for reference.
-
-.. data:: IMB_BLEND_MIX
-
-.. data:: IMB_BLEND_ADD
-
-.. data:: IMB_BLEND_SUB
-
-.. data:: IMB_BLEND_MUL
-
-.. data:: IMB_BLEND_LIGHTEN
-
-.. data:: IMB_BLEND_DARKEN
-
-.. data:: IMB_BLEND_ERASE_ALPHA
-
-.. data:: IMB_BLEND_ADD_ALPHA
-
-.. data:: IMB_BLEND_OVERLAY
-
-.. data:: IMB_BLEND_HARDLIGHT
-
-.. data:: IMB_BLEND_COLORBURN
-
-.. data:: IMB_BLEND_LINEARBURN
-
-.. data:: IMB_BLEND_COLORDODGE
-
-.. data:: IMB_BLEND_SCREEN
-
-.. data:: IMB_BLEND_SOFTLIGHT
-
-.. data:: IMB_BLEND_PINLIGHT
-
-.. data:: IMB_BLEND_VIVIDLIGHT
-
-.. data:: IMB_BLEND_LINEARLIGHT
-
-.. data:: IMB_BLEND_DIFFERENCE
-
-.. data:: IMB_BLEND_EXCLUSION
-
-.. data:: IMB_BLEND_HUE
-
-.. data:: IMB_BLEND_SATURATION
-
-.. data:: IMB_BLEND_LUMINOSITY
-
-.. data:: IMB_BLEND_COLOR
-
-.. data:: IMB_BLEND_COPY
-
-.. data:: IMB_BLEND_COPY_RGB
-
-.. data:: IMB_BLEND_COPY_ALPHA
diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst
deleted file mode 100644
index f24cc3f998c..00000000000
--- a/doc/python_api/rst/bge.types.rst
+++ /dev/null
@@ -1,38 +0,0 @@
-
-Game Types (bge.types)
-======================
-
-.. module:: bge.types
-
-************
-Introduction
-************
-
-This module contains the classes that appear as instances in the Game Engine. A
-script must interact with these classes if it is to affect the behaviour of
-objects in a game.
-
-The following example would move an object (i.e. an instance of
-:class:`KX_GameObject`) one unit up.
-
-.. code-block:: python
-
- # bge.types.SCA_PythonController
- cont = bge.logic.getCurrentController()
-
- # bge.types.KX_GameObject
- obj = cont.owner
- obj.worldPosition.z += 1
-
-To run the code, it could be placed in a Blender text block and executed with
-a :class:`SCA_PythonController` logic brick.
-
-*****
-Types
-*****
-
-.. toctree::
- :glob:
-
- bge.types.*
-
diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ActionActuator.rst b/doc/python_api/rst/bge_types/bge.types.BL_ActionActuator.rst
deleted file mode 100644
index 9b95a5ba611..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.BL_ActionActuator.rst
+++ /dev/null
@@ -1,78 +0,0 @@
-BL_ActionActuator(SCA_IActuator)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: BL_ActionActuator(SCA_IActuator)
-
- Action Actuators apply an action to an actor.
-
- .. attribute:: action
-
- The name of the action to set as the current action.
-
- :type: string
-
- .. attribute:: frameStart
-
- Specifies the starting frame of the animation.
-
- :type: float
-
- .. attribute:: frameEnd
-
- Specifies the ending frame of the animation.
-
- :type: float
-
- .. attribute:: blendIn
-
- Specifies the number of frames of animation to generate when making transitions between actions.
-
- :type: float
-
- .. attribute:: priority
-
- Sets the priority of this actuator. Actuators will lower priority numbers will override actuators with higher numbers.
-
- :type: integer
-
- .. attribute:: frame
-
- Sets the current frame for the animation.
-
- :type: float
-
- .. attribute:: propName
-
- Sets the property to be used in FromProp playback mode.
-
- :type: string
-
- .. attribute:: blendTime
-
- Sets the internal frame timer. This property must be in the range from 0.0 to blendIn.
-
- :type: float
-
- .. attribute:: mode
-
- The operation mode of the actuator. Can be one of :ref:`these constants<action-actuator>`.
-
- :type: integer
-
- .. attribute:: useContinue
-
- The actions continue option, True or False. When True, the action will always play from where last left off,
- otherwise negative events to this actuator will reset it to its start frame.
-
- :type: boolean
-
- .. attribute:: framePropName
-
- The name of the property that is set to the current frame number.
-
- :type: string
-
diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureActuator.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureActuator.rst
deleted file mode 100644
index 579186ac1d6..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureActuator.rst
+++ /dev/null
@@ -1,61 +0,0 @@
-BL_ArmatureActuator(SCA_IActuator)
-==================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: BL_ArmatureActuator(SCA_IActuator)
-
- Armature Actuators change constraint condition on armatures.
-
- .. attribute:: type
-
- The type of action that the actuator executes when it is active.
-
- Can be one of :ref:`these constants <armatureactuator-constants-type>`
-
- :type: integer
-
- .. attribute:: constraint
-
- The constraint object this actuator is controlling.
-
- :type: :class:`BL_ArmatureConstraint`
-
- .. attribute:: target
-
- The object that this actuator will set as primary target to the constraint it controls.
-
- :type: :class:`KX_GameObject`
-
- .. attribute:: subtarget
-
- The object that this actuator will set as secondary target to the constraint it controls.
-
- :type: :class:`KX_GameObject`.
-
- .. note::
-
- Currently, the only secondary target is the pole target for IK constraint.
-
- .. attribute:: weight
-
- The weight this actuator will set on the constraint it controls.
-
- :type: float.
-
- .. note::
-
- Currently only the IK constraint has a weight. It must be a value between 0 and 1.
-
- .. note::
-
- A weight of 0 disables a constraint while still updating constraint runtime values (see :class:`BL_ArmatureConstraint`)
-
- .. attribute:: influence
-
- The influence this actuator will set on the constraint it controls.
-
- :type: float.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureBone.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureBone.rst
deleted file mode 100644
index 14a9ebe9ef3..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureBone.rst
+++ /dev/null
@@ -1,105 +0,0 @@
-BL_ArmatureBone(PyObjectPlus)
-=============================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: BL_ArmatureBone(PyObjectPlus)
-
- Proxy to Blender bone structure. All fields are read-only and comply to RNA names.
- All space attribute correspond to the rest pose.
-
- .. attribute:: name
-
- bone name.
-
- :type: string
-
- .. attribute:: connected
-
- true when the bone head is struck to the parent's tail.
-
- :type: boolean
-
- .. attribute:: hinge
-
- true when bone doesn't inherit rotation or scale from parent bone.
-
- :type: boolean
-
- .. attribute:: inherit_scale
-
- true when bone inherits scaling from parent bone.
-
- :type: boolean
-
- .. attribute:: bbone_segments
-
- number of B-bone segments.
-
- :type: integer
-
- .. attribute:: roll
-
- bone rotation around head-tail axis.
-
- :type: float
-
- .. attribute:: head
-
- location of head end of the bone in parent bone space.
-
- :type: vector [x, y, z]
-
- .. attribute:: tail
-
- location of head end of the bone in parent bone space.
-
- :type: vector [x, y, z]
-
- .. attribute:: length
-
- bone length.
-
- :type: float
-
- .. attribute:: arm_head
-
- location of head end of the bone in armature space.
-
- :type: vector [x, y, z]
-
- .. attribute:: arm_tail
-
- location of tail end of the bone in armature space.
-
- :type: vector [x, y, z]
-
- .. attribute:: arm_mat
-
- matrix of the bone head in armature space.
-
- :type: matrix [4][4]
-
- .. note::
-
- This matrix has no scale part.
-
- .. attribute:: bone_mat
-
- rotation matrix of the bone in parent bone space.
-
- :type: matrix [3][3]
-
- .. attribute:: parent
-
- parent bone, or None for root bone.
-
- :type: :class:`BL_ArmatureBone`
-
- .. attribute:: children
-
- list of bone's children.
-
- :type: list of :class:`BL_ArmatureBone`
diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureChannel.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureChannel.rst
deleted file mode 100644
index 07220534b28..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureChannel.rst
+++ /dev/null
@@ -1,278 +0,0 @@
-BL_ArmatureChannel(PyObjectPlus)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: BL_ArmatureChannel(PyObjectPlus)
-
- Proxy to armature pose channel. Allows to read and set armature pose.
- The attributes are identical to RNA attributes, but mostly in read-only mode.
-
- .. attribute:: name
-
- channel name (=bone name), read-only.
-
- :type: string
-
- .. attribute:: bone
-
- return the bone object corresponding to this pose channel, read-only.
-
- :type: :class:`BL_ArmatureBone`
-
- .. attribute:: parent
-
- return the parent channel object, None if root channel, read-only.
-
- :type: :class:`BL_ArmatureChannel`
-
- .. attribute:: has_ik
-
- true if the bone is part of an active IK chain, read-only.
- This flag is not set when an IK constraint is defined but not enabled (miss target information for example).
-
- :type: boolean
-
- .. attribute:: ik_dof_x
-
- true if the bone is free to rotation in the X axis, read-only.
-
- :type: boolean
-
- .. attribute:: ik_dof_y
-
- true if the bone is free to rotation in the Y axis, read-only.
-
- :type: boolean
-
- .. attribute:: ik_dof_z
-
- true if the bone is free to rotation in the Z axis, read-only.
-
- :type: boolean
-
- .. attribute:: ik_limit_x
-
- true if a limit is imposed on X rotation, read-only.
-
- :type: boolean
-
- .. attribute:: ik_limit_y
-
- true if a limit is imposed on Y rotation, read-only.
-
- :type: boolean
-
- .. attribute:: ik_limit_z
-
- true if a limit is imposed on Z rotation, read-only.
-
- :type: boolean
-
- .. attribute:: ik_rot_control
-
- true if channel rotation should applied as IK constraint, read-only.
-
- :type: boolean
-
- .. attribute:: ik_lin_control
-
- true if channel size should applied as IK constraint, read-only.
-
- :type: boolean
-
- .. attribute:: location
-
- displacement of the bone head in armature local space, read-write.
-
- :type: vector [X, Y, Z].
-
- .. note::
-
- You can only move a bone if it is unconnected to its parent. An action playing on the armature may change the value. An IK chain does not update this value, see joint_rotation.
-
- .. note::
-
- Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see :data:`BL_ArmatureObject.update`).
-
- .. attribute:: scale
-
- scale of the bone relative to its parent, read-write.
-
- :type: vector [sizeX, sizeY, sizeZ].
-
- .. note::
-
- An action playing on the armature may change the value. An IK chain does not update this value, see joint_rotation.
-
- .. note::
-
- Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see :data:`BL_ArmatureObject.update`)
-
- .. attribute:: rotation_quaternion
-
- rotation of the bone relative to its parent expressed as a quaternion, read-write.
-
- :type: vector [qr, qi, qj, qk].
-
- .. note::
-
- This field is only used if rotation_mode is 0. An action playing on the armature may change the value. An IK chain does not update this value, see joint_rotation.
-
- .. note::
-
- Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see :data:`BL_ArmatureObject.update`)
-
- .. attribute:: rotation_euler
-
- rotation of the bone relative to its parent expressed as a set of euler angles, read-write.
-
- :type: vector [X, Y, Z].
-
- .. note::
-
- This field is only used if rotation_mode is > 0. You must always pass the angles in [X, Y, Z] order; the order of applying the angles to the bone depends on rotation_mode. An action playing on the armature may change this field. An IK chain does not update this value, see joint_rotation.
-
- .. note::
-
- Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see :data:`BL_ArmatureObject.update`)
-
- .. attribute:: rotation_mode
-
- Method of updating the bone rotation, read-write.
-
- :type: integer (one of :ref:`these constants <armaturechannel-constants-rotation-mode>`)
-
- .. attribute:: channel_matrix
-
- pose matrix in bone space (deformation of the bone due to action, constraint, etc), Read-only.
- This field is updated after the graphic render, it represents the current pose.
-
- :type: matrix [4][4]
-
- .. attribute:: pose_matrix
-
- pose matrix in armature space, read-only,
- This field is updated after the graphic render, it represents the current pose.
-
- :type: matrix [4][4]
-
- .. attribute:: pose_head
-
- position of bone head in armature space, read-only.
-
- :type: vector [x, y, z]
-
- .. attribute:: pose_tail
-
- position of bone tail in armature space, read-only.
-
- :type: vector [x, y, z]
-
- .. attribute:: ik_min_x
-
- minimum value of X rotation in degree (<= 0) when X rotation is limited (see ik_limit_x), read-only.
-
- :type: float
-
- .. attribute:: ik_max_x
-
- maximum value of X rotation in degree (>= 0) when X rotation is limited (see ik_limit_x), read-only.
-
- :type: float
-
- .. attribute:: ik_min_y
-
- minimum value of Y rotation in degree (<= 0) when Y rotation is limited (see ik_limit_y), read-only.
-
- :type: float
-
- .. attribute:: ik_max_y
-
- maximum value of Y rotation in degree (>= 0) when Y rotation is limited (see ik_limit_y), read-only.
-
- :type: float
-
- .. attribute:: ik_min_z
-
- minimum value of Z rotation in degree (<= 0) when Z rotation is limited (see ik_limit_z), read-only.
-
- :type: float
-
- .. attribute:: ik_max_z
-
- maximum value of Z rotation in degree (>= 0) when Z rotation is limited (see ik_limit_z), read-only.
-
- :type: float
-
- .. attribute:: ik_stiffness_x
-
- bone rotation stiffness in X axis, read-only.
-
- :type: float between 0 and 1
-
- .. attribute:: ik_stiffness_y
-
- bone rotation stiffness in Y axis, read-only.
-
- :type: float between 0 and 1
-
- .. attribute:: ik_stiffness_z
-
- bone rotation stiffness in Z axis, read-only.
-
- :type: float between 0 and 1
-
- .. attribute:: ik_stretch
-
- ratio of scale change that is allowed, 0=bone can't change size, read-only.
-
- :type: float
-
- .. attribute:: ik_rot_weight
-
- weight of rotation constraint when ik_rot_control is set, read-write.
-
- :type: float between 0 and 1
-
- .. attribute:: ik_lin_weight
-
- weight of size constraint when ik_lin_control is set, read-write.
-
- :type: float between 0 and 1
-
- .. attribute:: joint_rotation
-
- Control bone rotation in term of joint angle (for robotic applications), read-write.
-
- When writing to this attribute, you pass a [x, y, z] vector and an appropriate set of euler angles or quaternion is calculated according to the rotation_mode.
-
- When you read this attribute, the current pose matrix is converted into a [x, y, z] vector representing the joint angles.
-
- The value and the meaning of the x, y, z depends on the ik_dof_x/ik_dof_y/ik_dof_z attributes:
-
- * 1DoF joint X, Y or Z: the corresponding x, y, or z value is used an a joint angle in radiant
- * 2DoF joint X+Y or Z+Y: treated as 2 successive 1DoF joints: first X or Z, then Y. The x or z value is used as a joint angle in radiant along the X or Z axis, followed by a rotation along the new Y axis of y radiants.
- * 2DoF joint X+Z: treated as a 2DoF joint with rotation axis on the X/Z plane. The x and z values are used as the coordinates of the rotation vector in the X/Z plane.
- * 3DoF joint X+Y+Z: treated as a revolute joint. The [x, y, z] vector represents the equivalent rotation vector to bring the joint from the rest pose to the new pose.
-
- :type: vector [x, y, z]
-
- .. note::
-
- The bone must be part of an IK chain if you want to set the ik_dof_x/ik_dof_y/ik_dof_z attributes via the UI, but this will interfere with this attribute since the IK solver will overwrite the pose. You can stay in control of the armature if you create an IK constraint but do not finalize it (e.g. don't set a target) the IK solver will not run but the IK panel will show up on the UI for each bone in the chain.
-
- .. note::
-
- [0, 0, 0] always corresponds to the rest pose.
-
- .. note::
-
- You must request the armature pose to update and wait for the next graphic frame to see the effect of setting this attribute (see :data:`BL_ArmatureObject.update`).
-
- .. note::
-
- You can read the result of the calculation in rotation or euler_rotation attributes after setting this attribute.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureConstraint.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureConstraint.rst
deleted file mode 100644
index 1a4370945c1..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureConstraint.rst
+++ /dev/null
@@ -1,129 +0,0 @@
-BL_ArmatureConstraint(PyObjectPlus)
-===================================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: BL_ArmatureConstraint(PyObjectPlus)
-
- Proxy to Armature Constraint. Allows to change constraint on the fly.
- Obtained through :class:`BL_ArmatureObject`.constraints.
-
- .. note::
-
- Not all armature constraints are supported in the GE.
-
-
- .. attribute:: type
-
- Type of constraint, (read-only).
-
- Use one of :ref:`these constants<armatureconstraint-constants-type>`.
-
- :type: integer, one of CONSTRAINT_TYPE_* constants
-
- .. attribute:: name
-
- Name of constraint constructed as <bone_name>:<constraint_name>. constraints list.
-
- :type: string
-
- This name is also the key subscript on :class:`BL_ArmatureObject`.
-
- .. attribute:: enforce
-
- fraction of constraint effect that is enforced. Between 0 and 1.
-
- :type: float
-
- .. attribute:: headtail
-
- Position of target between head and tail of the target bone: 0=head, 1=tail.
-
- :type: float.
-
- .. note::
-
- Only used if the target is a bone (i.e target object is an armature.
-
- .. attribute:: lin_error
-
- runtime linear error (in Blender units) on constraint at the current frame.
-
- This is a runtime value updated on each frame by the IK solver. Only available on IK constraint and iTaSC solver.
-
- :type: float
-
- .. attribute:: rot_error
-
- Runtime rotation error (in radiant) on constraint at the current frame.
-
- :type: float.
-
- This is a runtime value updated on each frame by the IK solver. Only available on IK constraint and iTaSC solver.
-
- It is only set if the constraint has a rotation part, for example, a CopyPose+Rotation IK constraint.
-
- .. attribute:: target
-
- Primary target object for the constraint. The position of this object in the GE will be used as target for the constraint.
-
- :type: :class:`KX_GameObject`.
-
- .. attribute:: subtarget
-
- Secondary target object for the constraint. The position of this object in the GE will be used as secondary target for the constraint.
-
- :type: :class:`KX_GameObject`.
-
- Currently this is only used for pole target on IK constraint.
-
- .. attribute:: active
-
- True if the constraint is active.
-
- :type: boolean
-
- .. note::
-
- An inactive constraint does not update lin_error and rot_error.
-
- .. attribute:: ik_weight
-
- Weight of the IK constraint between 0 and 1.
-
- Only defined for IK constraint.
-
- :type: float
-
- .. attribute:: ik_type
-
- Type of IK constraint, (read-only).
-
- Use one of :ref:`these constants<armatureconstraint-constants-ik-type>`.
-
- :type: integer.
-
- .. attribute:: ik_flag
-
- Combination of IK constraint option flags, read-only.
-
- Use one of :ref:`these constants<armatureconstraint-constants-ik-flag>`.
-
- :type: integer
-
- .. attribute:: ik_dist
-
- Distance the constraint is trying to maintain with target, only used when ik_type=CONSTRAINT_IK_DISTANCE.
-
- :type: float
-
- .. attribute:: ik_mode
-
- Use one of :ref:`these constants<armatureconstraint-constants-ik-mode>`.
-
- Additional mode for IK constraint. Currently only used for Distance constraint:
-
- :type: integer
-
diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureObject.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureObject.rst
deleted file mode 100644
index 8389affe8a9..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureObject.rst
+++ /dev/null
@@ -1,34 +0,0 @@
-BL_ArmatureObject(KX_GameObject)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`KX_GameObject`
-
-.. class:: BL_ArmatureObject(KX_GameObject)
-
- An armature object.
-
- .. attribute:: constraints
-
- The list of armature constraint defined on this armature.
- Elements of the list can be accessed by index or string.
- The key format for string access is '<bone_name>:<constraint_name>'.
-
- :type: list of :class:`BL_ArmatureConstraint`
-
- .. attribute:: channels
-
- The list of armature channels.
- Elements of the list can be accessed by index or name the bone.
-
- :type: list of :class:`BL_ArmatureChannel`
-
- .. method:: update()
-
- Ensures that the armature will be updated on next graphic frame.
-
- This action is unecessary if a KX_ArmatureActuator with mode run is active
- or if an action is playing. Use this function in other cases. It must be called
- on each frame to ensure that the armature is updated continously.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.BL_Shader.rst b/doc/python_api/rst/bge_types/bge.types.BL_Shader.rst
deleted file mode 100644
index a389f68ee04..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.BL_Shader.rst
+++ /dev/null
@@ -1,230 +0,0 @@
-BL_Shader(PyObjectPlus)
-=======================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: BL_Shader(PyObjectPlus)
-
- BL_Shader GLSL shaders.
-
- TODO - Description
-
- .. method:: setUniformfv(name, fList)
-
- Set a uniform with a list of float values
-
- :arg name: the uniform name
- :type name: string
- :arg fList: a list (2, 3 or 4 elements) of float values
- :type fList: list[float]
-
- .. method:: delSource()
-
- Clear the shader. Use this method before the source is changed with :data:`setSource`.
-
- .. method:: getFragmentProg()
-
- Returns the fragment program.
-
- :return: The fragment program.
- :rtype: string
-
- .. method:: getVertexProg()
-
- Get the vertex program.
-
- :return: The vertex program.
- :rtype: string
-
- .. method:: isValid()
-
- Check if the shader is valid.
-
- :return: True if the shader is valid
- :rtype: boolean
-
- .. method:: setAttrib(enum)
-
- Set attribute location. (The parameter is ignored a.t.m. and the value of "tangent" is always used.)
-
- :arg enum: attribute location value
- :type enum: integer
-
- .. method:: setNumberOfPasses( max_pass )
-
- Set the maximum number of passes. Not used a.t.m.
-
- :arg max_pass: the maximum number of passes
- :type max_pass: integer
-
- .. method:: setSampler(name, index)
-
- Set uniform texture sample index.
-
- :arg name: Uniform name
- :type name: string
- :arg index: Texture sample index.
- :type index: integer
-
- .. method:: setSource(vertexProgram, fragmentProgram)
-
- Set the vertex and fragment programs
-
- :arg vertexProgram: Vertex program
- :type vertexProgram: string
- :arg fragmentProgram: Fragment program
- :type fragmentProgram: string
-
- .. method:: setUniform1f(name, fx)
-
- Set a uniform with 1 float value.
-
- :arg name: the uniform name
- :type name: string
- :arg fx: Uniform value
- :type fx: float
-
- .. method:: setUniform1i(name, ix)
-
- Set a uniform with an integer value.
-
- :arg name: the uniform name
- :type name: string
- :arg ix: the uniform value
- :type ix: integer
-
- .. method:: setUniform2f(name, fx, fy)
-
- Set a uniform with 2 float values
-
- :arg name: the uniform name
- :type name: string
- :arg fx: first float value
- :type fx: float
-
- :arg fy: second float value
- :type fy: float
-
- .. method:: setUniform2i(name, ix, iy)
-
- Set a uniform with 2 integer values
-
- :arg name: the uniform name
- :type name: string
- :arg ix: first integer value
- :type ix: integer
- :arg iy: second integer value
- :type iy: integer
-
- .. method:: setUniform3f(name, fx, fy, fz)
-
- Set a uniform with 3 float values.
-
- :arg name: the uniform name
- :type name: string
- :arg fx: first float value
- :type fx: float
- :arg fy: second float value
- :type fy: float
- :arg fz: third float value
- :type fz: float
-
- .. method:: setUniform3i(name, ix, iy, iz)
-
- Set a uniform with 3 integer values
-
- :arg name: the uniform name
- :type name: string
- :arg ix: first integer value
- :type ix: integer
- :arg iy: second integer value
- :type iy: integer
- :arg iz: third integer value
- :type iz: integer
-
- .. method:: setUniform4f(name, fx, fy, fz, fw)
-
- Set a uniform with 4 float values.
-
- :arg name: the uniform name
- :type name: string
- :arg fx: first float value
- :type fx: float
- :arg fy: second float value
- :type fy: float
- :arg fz: third float value
- :type fz: float
- :arg fw: fourth float value
- :type fw: float
-
- .. method:: setUniform4i(name, ix, iy, iz, iw)
-
- Set a uniform with 4 integer values
-
- :arg name: the uniform name
- :type name: string
- :arg ix: first integer value
- :type ix: integer
- :arg iy: second integer value
- :type iy: integer
- :arg iz: third integer value
- :type iz: integer
- :arg iw: fourth integer value
- :type iw: integer
-
- .. method:: setUniformDef(name, type)
-
- Define a new uniform
-
- :arg name: the uniform name
- :type name: string
- :arg type: uniform type
- :type type: UNI_NONE, UNI_INT, UNI_FLOAT, UNI_INT2, UNI_FLOAT2, UNI_INT3, UNI_FLOAT3, UNI_INT4, UNI_FLOAT4, UNI_MAT3, UNI_MAT4, UNI_MAX
-
- .. method:: setUniformMatrix3(name, mat, transpose)
-
- Set a uniform with a 3x3 matrix value
-
- :arg name: the uniform name
- :type name: string
- :arg mat: A 3x3 matrix [[f, f, f], [f, f, f], [f, f, f]]
- :type mat: 3x3 matrix
- :arg transpose: set to True to transpose the matrix
- :type transpose: boolean
-
- .. method:: setUniformMatrix4(name, mat, transpose)
-
- Set a uniform with a 4x4 matrix value
-
- :arg name: the uniform name
- :type name: string
- :arg mat: A 4x4 matrix [[f, f, f, f], [f, f, f, f], [f, f, f, f], [f, f, f, f]]
- :type mat: 4x4 matrix
- :arg transpose: set to True to transpose the matrix
- :type transpose: boolean
-
- .. method:: setUniformiv(name, iList)
-
- Set a uniform with a list of integer values
-
- :arg name: the uniform name
- :type name: string
- :arg iList: a list (2, 3 or 4 elements) of integer values
- :type iList: list[integer]
-
- .. method:: setUniformEyef(name)
-
- Set a uniform with a float value that reflects the eye being render in stereo mode:
- 0.0 for the left eye, 0.5 for the right eye. In non stereo mode, the value of the uniform
- is fixed to 0.0. The typical use of this uniform is in stereo mode to sample stereo textures
- containing the left and right eye images in a top-bottom order.
-
- :arg name: the uniform name
- :type name: string
-
- .. method:: validate()
-
- Validate the shader object.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst b/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst
deleted file mode 100644
index 4bb3d273cb9..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst
+++ /dev/null
@@ -1,70 +0,0 @@
-BL_ShapeActionActuator(SCA_IActuator)
-=====================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: BL_ShapeActionActuator(SCA_IActuator)
-
- ShapeAction Actuators apply an shape action to an mesh object.
-
- .. attribute:: action
-
- The name of the action to set as the current shape action.
-
- :type: string
-
- .. attribute:: frameStart
-
- Specifies the starting frame of the shape animation.
-
- :type: float
-
- .. attribute:: frameEnd
-
- Specifies the ending frame of the shape animation.
-
- :type: float
-
- .. attribute:: blendIn
-
- Specifies the number of frames of animation to generate when making transitions between actions.
-
- :type: float
-
- .. attribute:: priority
-
- Sets the priority of this actuator. Actuators will lower priority numbers will override actuators with higher numbers.
-
- :type: integer
-
- .. attribute:: frame
-
- Sets the current frame for the animation.
-
- :type: float
-
- .. attribute:: propName
-
- Sets the property to be used in FromProp playback mode.
-
- :type: string
-
- .. attribute:: blendTime
-
- Sets the internal frame timer. This property must be in the range from 0.0 to blendin.
-
- :type: float
-
- .. attribute:: mode
-
- The operation mode of the actuator. Can be one of :ref:`these constants<action-actuator>`.
-
- :type: integer
-
- .. attribute:: framePropName
-
- The name of the property that is set to the current frame number.
-
- :type: string
diff --git a/doc/python_api/rst/bge_types/bge.types.CListValue.rst b/doc/python_api/rst/bge_types/bge.types.CListValue.rst
deleted file mode 100644
index ca4cdc44bf5..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.CListValue.rst
+++ /dev/null
@@ -1,72 +0,0 @@
-CListValue(CPropValue)
-======================
-
-.. module:: bge.types
-
-base class --- :class:`CPropValue`
-
-.. class:: CListValue(CPropValue)
-
- This is a list like object used in the game engine internally that behaves similar to a python list in most ways.
-
- As well as the normal index lookup (``val= clist[i]``), CListValue supports string lookups (``val= scene.objects["Cube"]``)
-
- Other operations such as ``len(clist)``, ``list(clist)``, ``clist[0:10]`` are also supported.
-
- .. method:: append(val)
-
- Add an item to the list (like pythons append)
-
- .. warning::
-
- Appending values to the list can cause crashes when the list is used internally by the game engine.
-
- .. method:: count(val)
-
- Count the number of instances of a value in the list.
-
- :return: number of instances
- :rtype: integer
-
- .. method:: index(val)
-
- Return the index of a value in the list.
-
- :return: The index of the value in the list.
- :rtype: integer
-
- .. method:: reverse()
-
- Reverse the order of the list.
-
- .. method:: get(key, default=None)
-
- Return the value matching key, or the default value if its not found.
-
- :return: The key value or a default.
-
- .. method:: from_id(id)
-
- This is a funtion especially for the game engine to return a value with a spesific id.
-
- Since object names are not always unique, the id of an object can be used to get an object from the CValueList.
-
- Example:
-
- .. code-block:: python
-
- myObID=id(gameObject)
- ob= scene.objects.from_id(myObID)
-
- Where ``myObID`` is an int or long from the id function.
-
- This has the advantage that you can store the id in places you could not store a gameObject.
-
- .. warning::
-
- The id is derived from a memory location and will be different each time the game engine starts.
-
- .. warning::
-
- The id can't be stored as an integer in game object properties, as those only have a limited range that the id may not be contained in. Instead an id can be stored as a string game property and converted back to an integer for use in from_id lookups.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.CPropValue.rst b/doc/python_api/rst/bge_types/bge.types.CPropValue.rst
deleted file mode 100644
index 7be28c1e006..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.CPropValue.rst
+++ /dev/null
@@ -1,11 +0,0 @@
-CPropValue(CValue)
-==================
-
-.. module:: bge.types
-
-base class --- :class:`CValue`
-
-.. class:: CPropValue(CValue)
-
- This class has no python functions
-
diff --git a/doc/python_api/rst/bge_types/bge.types.CValue.rst b/doc/python_api/rst/bge_types/bge.types.CValue.rst
deleted file mode 100644
index 52906de5576..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.CValue.rst
+++ /dev/null
@@ -1,17 +0,0 @@
-CValue(PyObjectPlus)
-====================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: CValue(PyObjectPlus)
-
- This class is a basis for other classes.
-
- .. attribute:: name
-
- The name of this CValue derived object (read-only).
-
- :type: string
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ArmatureSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_ArmatureSensor.rst
deleted file mode 100644
index a7123eb5c9d..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_ArmatureSensor.rst
+++ /dev/null
@@ -1,36 +0,0 @@
-KX_ArmatureSensor(SCA_ISensor)
-==============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: KX_ArmatureSensor(SCA_ISensor)
-
- Armature sensor detect conditions on armatures.
-
- .. attribute:: type
-
- The type of measurement that the sensor make when it is active.
-
- Can be one of :ref:`these constants <armaturesensor-type>`
-
- :type: integer.
-
- .. attribute:: constraint
-
- The constraint object this sensor is watching.
-
- :type: :class:`BL_ArmatureConstraint`
-
- .. attribute:: value
-
- The threshold used in the comparison with the constraint error
- The linear error is only updated on CopyPose/Distance IK constraint with iTaSC solver
- The rotation error is only updated on CopyPose+rotation IK constraint with iTaSC solver
- The linear error on CopyPose is always >= 0: it is the norm of the distance between the target and the bone
- The rotation error on CopyPose is always >= 0: it is the norm of the equivalent rotation vector between the bone and the target orientations
- The linear error on Distance can be positive if the distance between the bone and the target is greater than the desired distance, and negative if the distance is smaller.
-
- :type: float
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_BlenderMaterial.rst b/doc/python_api/rst/bge_types/bge.types.KX_BlenderMaterial.rst
deleted file mode 100644
index ece2a65af71..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_BlenderMaterial.rst
+++ /dev/null
@@ -1,185 +0,0 @@
-KX_BlenderMaterial(PyObjectPlus)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: KX_BlenderMaterial(PyObjectPlus)
-
- This is the interface to materials in the game engine.
-
- Materials define the render state to be applied to mesh objects.
-
- The example below shows a simple GLSL shader setup allowing to dynamically mix two texture channels
- in a material. All materials of the object executing this script should have two textures using
- separate UV maps in the two first texture channels.
-
- The code works for both Multitexture and GLSL rendering modes.
-
- .. code-block:: python
-
- from bge import logic
-
- vertex_shader = """
-
- void main(void)
- {
- // simple projection of the vertex position to view space
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- // coordinate of the 1st texture channel
- gl_TexCoord[0] = gl_MultiTexCoord0;
- // coordinate of the 2nd texture channel
- gl_TexCoord[1] = gl_MultiTexCoord1;
- }
- """
-
- fragment_shader ="""
-
- uniform sampler2D texture_0;
- uniform sampler2D texture_1;
- uniform float factor;
-
- void main(void)
- {
- vec4 color_0 = texture2D(texture_0, gl_TexCoord[0].st);
- vec4 color_1 = texture2D(texture_1, gl_TexCoord[1].st);
- gl_FragColor = mix(color_0, color_1, factor);
- }
- """
-
- object = logic.getCurrentController().owner
-
- for mesh in object.meshes:
- for material in mesh.materials:
- shader = material.getShader()
- if shader is not None:
- if not shader.isValid():
- shader.setSource(vertex_shader, fragment_shader, True)
-
- # get the first texture channel of the material
- shader.setSampler('texture_0', 0)
- # get the second texture channel of the material
- shader.setSampler('texture_1', 1)
- # pass another uniform to the shader
- shader.setUniform1f('factor', 0.3)
-
- .. attribute:: shader
-
- The material's shader.
-
- :type: :class:`BL_Shader`
-
- .. attribute:: blending
-
- Ints used for pixel blending, (src, dst), matching the setBlending method.
-
- :type: (integer, integer)
-
- .. attribute:: material_index
-
- The material's index.
-
- :type: integer
-
- .. method:: getShader()
-
- Returns the material's shader.
-
- :return: the material's shader
- :rtype: :class:`BL_Shader`
-
- .. method:: getTextureBindcode(textureslot)
-
- Returns the material's texture OpenGL bind code/id/number/name.
-
- :arg textureslot: Specifies the texture slot number
- :type textureslot: integer
- :return: the material's texture OpenGL bind code/id/number/name
- :rtype: integer
-
- .. attribute:: alpha
-
- The material's alpha transparency.
-
- :type: float between 0.0 and 1.0 inclusive
-
- .. attribute:: hardness
-
- How hard (sharp) the material's specular reflection is.
-
- :type: integer between 1 and 511 inclusive
-
- .. attribute:: emit
-
- Amount of light to emit.
-
- :type: float between 0.0 and 2.0 inclusive
-
- .. attribute:: specularIntensity
-
- How intense (bright) the material's specular reflection is.
-
- :type: float between 0.0 and 1.0 inclusive
-
- .. attribute:: diffuseIntensity
-
- The material's amount of diffuse reflection.
-
- :type: float between 0.0 and 1.0 inclusive
-
- .. attribute:: specularColor
-
- The material's specular color.
-
- :type: :class:`mathutils.Color`
-
- .. attribute:: diffuseColor
-
- The material's diffuse color.
-
- :type: :class:`mathutils.Color`
-
- .. method:: setBlending(src, dest)
-
- Set the pixel color arithmetic functions.
-
- :arg src: Specifies how the red, green, blue, and alpha source blending factors are computed, one of...
-
- * :data:`~bgl.GL_ZERO`
- * :data:`~bgl.GL_ONE`
- * :data:`~bgl.GL_SRC_COLOR`
- * :data:`~bgl.GL_ONE_MINUS_SRC_COLOR`
- * :data:`~bgl.GL_DST_COLOR`
- * :data:`~bgl.GL_ONE_MINUS_DST_COLOR`
- * :data:`~bgl.GL_SRC_ALPHA`
- * :data:`~bgl.GL_ONE_MINUS_SRC_ALPHA`
- * :data:`~bgl.GL_DST_ALPHA`
- * :data:`~bgl.GL_ONE_MINUS_DST_ALPHA`
- * :data:`~bgl.GL_SRC_ALPHA_SATURATE`
-
- :type src: int
-
- :arg dest: Specifies how the red, green, blue, and alpha destination blending factors are computed, one of...
-
- * :data:`~bgl.GL_ZERO`
- * :data:`~bgl.GL_ONE`
- * :data:`~bgl.GL_SRC_COLOR`
- * :data:`~bgl.GL_ONE_MINUS_SRC_COLOR`
- * :data:`~bgl.GL_DST_COLOR`
- * :data:`~bgl.GL_ONE_MINUS_DST_COLOR`
- * :data:`~bgl.GL_SRC_ALPHA`
- * :data:`~bgl.GL_ONE_MINUS_SRC_ALPHA`
- * :data:`~bgl.GL_DST_ALPHA`
- * :data:`~bgl.GL_ONE_MINUS_DST_ALPHA`
- * :data:`~bgl.GL_SRC_ALPHA_SATURATE`
-
- :type dest: int
-
- .. method:: getMaterialIndex()
-
- Returns the material's index.
-
- :return: the material's index
- :rtype: integer
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_Camera.rst b/doc/python_api/rst/bge_types/bge.types.KX_Camera.rst
deleted file mode 100644
index ac5ab4b5fe5..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_Camera.rst
+++ /dev/null
@@ -1,302 +0,0 @@
-KX_Camera(KX_GameObject)
-========================
-
-.. module:: bge.types
-
-base class --- :class:`KX_GameObject`
-
-.. class:: KX_Camera(KX_GameObject)
-
- A Camera object.
-
- .. data:: INSIDE
-
- See :data:`sphereInsideFrustum` and :data:`boxInsideFrustum`
-
- .. data:: INTERSECT
-
- See :data:`sphereInsideFrustum` and :data:`boxInsideFrustum`
-
- .. data:: OUTSIDE
-
- See :data:`sphereInsideFrustum` and :data:`boxInsideFrustum`
-
- .. attribute:: lens
-
- The camera's lens value.
-
- :type: float
-
- .. attribute:: fov
-
- The camera's field of view value.
-
- :type: float
-
- .. attribute:: ortho_scale
-
- The camera's view scale when in orthographic mode.
-
- :type: float
-
- .. attribute:: near
-
- The camera's near clip distance.
-
- :type: float
-
- .. attribute:: far
-
- The camera's far clip distance.
-
- :type: float
-
- .. attribute:: shift_x
-
- The camera's horizontal shift.
-
- :type: float
-
- .. attribute:: shift_y
-
- The camera's vertical shift.
-
- :type: float
-
- .. attribute:: perspective
-
- True if this camera has a perspective transform, False for an orthographic projection.
-
- :type: boolean
-
- .. attribute:: frustum_culling
-
- True if this camera is frustum culling.
-
- :type: boolean
-
- .. attribute:: projection_matrix
-
- This camera's 4x4 projection matrix.
-
- .. note::
-
- This is the identity matrix prior to rendering the first frame (any Python done on frame 1).
-
- :type: 4x4 Matrix [[float]]
-
- .. attribute:: modelview_matrix
-
- This camera's 4x4 model view matrix. (read-only).
-
- :type: 4x4 Matrix [[float]]
-
- .. note::
-
- This matrix is regenerated every frame from the camera's position and orientation. Also, this is the identity matrix prior to rendering the first frame (any Python done on frame 1).
-
- .. attribute:: camera_to_world
-
- This camera's camera to world transform. (read-only).
-
- :type: 4x4 Matrix [[float]]
-
- .. note::
-
- This matrix is regenerated every frame from the camera's position and orientation.
-
- .. attribute:: world_to_camera
-
- This camera's world to camera transform. (read-only).
-
- :type: 4x4 Matrix [[float]]
-
- .. note::
-
- Regenerated every frame from the camera's position and orientation.
-
- .. note::
-
- This is camera_to_world inverted.
-
- .. attribute:: useViewport
-
- True when the camera is used as a viewport, set True to enable a viewport for this camera.
-
- :type: boolean
-
- .. method:: sphereInsideFrustum(centre, radius)
-
- Tests the given sphere against the view frustum.
-
- :arg centre: The centre of the sphere (in world coordinates.)
- :type centre: list [x, y, z]
- :arg radius: the radius of the sphere
- :type radius: float
- :return: :data:`~bge.types.KX_Camera.INSIDE`, :data:`~bge.types.KX_Camera.OUTSIDE` or :data:`~bge.types.KX_Camera.INTERSECT`
- :rtype: integer
-
- .. note::
-
- When the camera is first initialized the result will be invalid because the projection matrix has not been set.
-
- .. code-block:: python
-
- from bge import logic
- cont = logic.getCurrentController()
- cam = cont.owner
-
- # A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]
- if (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):
- # Sphere is inside frustum !
- # Do something useful !
- else:
- # Sphere is outside frustum
-
- .. method:: boxInsideFrustum(box)
-
- Tests the given box against the view frustum.
-
- :arg box: Eight (8) corner points of the box (in world coordinates.)
- :type box: list of lists
- :return: :data:`~bge.types.KX_Camera.INSIDE`, :data:`~bge.types.KX_Camera.OUTSIDE` or :data:`~bge.types.KX_Camera.INTERSECT`
-
- .. note::
-
- When the camera is first initialized the result will be invalid because the projection matrix has not been set.
-
- .. code-block:: python
-
- from bge import logic
- cont = logic.getCurrentController()
- cam = cont.owner
-
- # Box to test...
- box = []
- box.append([-1.0, -1.0, -1.0])
- box.append([-1.0, -1.0, 1.0])
- box.append([-1.0, 1.0, -1.0])
- box.append([-1.0, 1.0, 1.0])
- box.append([ 1.0, -1.0, -1.0])
- box.append([ 1.0, -1.0, 1.0])
- box.append([ 1.0, 1.0, -1.0])
- box.append([ 1.0, 1.0, 1.0])
-
- if (cam.boxInsideFrustum(box) != cam.OUTSIDE):
- # Box is inside/intersects frustum !
- # Do something useful !
- else:
- # Box is outside the frustum !
-
- .. method:: pointInsideFrustum(point)
-
- Tests the given point against the view frustum.
-
- :arg point: The point to test (in world coordinates.)
- :type point: 3D Vector
- :return: True if the given point is inside this camera's viewing frustum.
- :rtype: boolean
-
- .. note::
-
- When the camera is first initialized the result will be invalid because the projection matrix has not been set.
-
- .. code-block:: python
-
- from bge import logic
- cont = logic.getCurrentController()
- cam = cont.owner
-
- # Test point [0.0, 0.0, 0.0]
- if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
- # Point is inside frustum !
- # Do something useful !
- else:
- # Box is outside the frustum !
-
- .. method:: getCameraToWorld()
-
- Returns the camera-to-world transform.
-
- :return: the camera-to-world transform matrix.
- :rtype: matrix (4x4 list)
-
- .. method:: getWorldToCamera()
-
- Returns the world-to-camera transform.
-
- This returns the inverse matrix of getCameraToWorld().
-
- :return: the world-to-camera transform matrix.
- :rtype: matrix (4x4 list)
-
- .. method:: setOnTop()
-
- Set this cameras viewport ontop of all other viewport.
-
- .. method:: setViewport(left, bottom, right, top)
-
- Sets the region of this viewport on the screen in pixels.
-
- Use :data:`bge.render.getWindowHeight` and :data:`bge.render.getWindowWidth` to calculate values relative to the entire display.
-
- :arg left: left pixel coordinate of this viewport
- :type left: integer
- :arg bottom: bottom pixel coordinate of this viewport
- :type bottom: integer
- :arg right: right pixel coordinate of this viewport
- :type right: integer
- :arg top: top pixel coordinate of this viewport
- :type top: integer
-
- .. method:: getScreenPosition(object)
-
- Gets the position of an object projected on screen space.
-
- .. code-block:: python
-
- # For an object in the middle of the screen, coord = [0.5, 0.5]
- coord = camera.getScreenPosition(object)
-
- :arg object: object name or list [x, y, z]
- :type object: :class:`KX_GameObject` or 3D Vector
- :return: the object's position in screen coordinates.
- :rtype: list [x, y]
-
- .. method:: getScreenVect(x, y)
-
- Gets the vector from the camera position in the screen coordinate direction.
-
- :arg x: X Axis
- :type x: float
- :arg y: Y Axis
- :type y: float
- :rtype: 3D Vector
- :return: The vector from screen coordinate.
-
- .. code-block:: python
-
- # Gets the vector of the camera front direction:
- m_vect = camera.getScreenVect(0.5, 0.5)
-
- .. method:: getScreenRay(x, y, dist=inf, property=None)
-
- Look towards a screen coordinate (x, y) and find first object hit within dist that matches prop.
- The ray is similar to KX_GameObject->rayCastTo.
-
- :arg x: X Axis
- :type x: float
- :arg y: Y Axis
- :type y: float
- :arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
- :type dist: float
- :arg property: property name that object must have; can be omitted => detect any object
- :type property: string
- :rtype: :class:`KX_GameObject`
- :return: the first object hit or None if no object or object does not match prop
-
- .. code-block:: python
-
- # Gets an object with a property "wall" in front of the camera within a distance of 100:
- target = camera.getScreenRay(0.5, 0.5, 100, "wall")
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_CameraActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_CameraActuator.rst
deleted file mode 100644
index bc5efed4b08..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_CameraActuator.rst
+++ /dev/null
@@ -1,47 +0,0 @@
-KX_CameraActuator(SCA_IActuator)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_CameraActuator(SCA_IActuator)
-
- Applies changes to a camera.
-
- .. attribute:: damping
-
- strength of of the camera following movement.
-
- :type: float
-
- .. attribute:: axis
-
- The camera axis (0, 1, 2) for positive ``XYZ``, (3, 4, 5) for negative ``XYZ``.
-
- :type: int
-
- .. attribute:: min
-
- minimum distance to the target object maintained by the actuator.
-
- :type: float
-
- .. attribute:: max
-
- maximum distance to stay from the target object.
-
- :type: float
-
- .. attribute:: height
-
- height to stay above the target object.
-
- :type: float
-
- .. attribute:: object
-
- the object this actuator tracks.
-
- :type: :class:`KX_GameObject` or None
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst b/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst
deleted file mode 100644
index adff6e0a2ad..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst
+++ /dev/null
@@ -1,45 +0,0 @@
-KX_CharacterWrapper(PyObjectPlus)
-=================================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: KX_CharacterWrapper(PyObjectPlus)
-
- A wrapper to expose character physics options.
-
- .. attribute:: onGround
-
- Whether or not the character is on the ground. (read-only)
-
- :type: boolean
-
- .. attribute:: gravity
-
- The gravity value used for the character.
-
- :type: float
-
- .. attribute:: maxJumps
-
- The maximum number of jumps a character can perform before having to touch the ground. By default this is set to 1. 2 allows for a double jump, etc.
-
- :type: int in [0, 255], default 1
-
- .. attribute:: jumpCount
-
- The current jump count. This can be used to have different logic for a single jump versus a double jump. For example, a different animation for the second jump.
-
- :type: int
-
- .. attribute:: walkDirection
-
- The speed and direction the character is traveling in using world coordinates. This should be used instead of applyMovement() to properly move the character.
-
- :type: Vector((x, y, z))
-
- .. method:: jump()
-
- The character jumps based on it's jump speed.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ConstraintActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_ConstraintActuator.rst
deleted file mode 100644
index 498990449fe..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_ConstraintActuator.rst
+++ /dev/null
@@ -1,78 +0,0 @@
-KX_ConstraintActuator(SCA_IActuator)
-====================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_ConstraintActuator(SCA_IActuator)
-
- A constraint actuator limits the position, rotation, distance or orientation of an object.
-
- .. attribute:: damp
-
- Time constant of the constraint expressed in frame (not use by Force field constraint).
-
- :type: integer
-
- .. attribute:: rotDamp
-
- Time constant for the rotation expressed in frame (only for the distance constraint), 0 = use damp for rotation as well.
-
- :type: integer
-
- .. attribute:: direction
-
- The reference direction in world coordinate for the orientation constraint.
-
- :type: 3-tuple of float: (x, y, z)
-
- .. attribute:: option
-
- Binary combination of :ref:`these constants <constraint-actuator-option>`
-
- :type: integer
-
- .. attribute:: time
-
- activation time of the actuator. The actuator disables itself after this many frame. If set to 0, the actuator is not limited in time.
-
- :type: integer
-
- .. attribute:: propName
-
- the name of the property or material for the ray detection of the distance constraint.
-
- :type: string
-
- .. attribute:: min
-
- The lower bound of the constraint. For the rotation and orientation constraint, it represents radiant.
-
- :type: float
-
- .. attribute:: distance
-
- the target distance of the distance constraint.
-
- :type: float
-
- .. attribute:: max
-
- the upper bound of the constraint. For rotation and orientation constraints, it represents radiant.
-
- :type: float
-
- .. attribute:: rayLength
-
- the length of the ray of the distance constraint.
-
- :type: float
-
- .. attribute:: limit
-
- type of constraint. Use one of the :ref:`these constants <constraint-actuator-limit>`
-
- :type: integer.
-
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ConstraintWrapper.rst b/doc/python_api/rst/bge_types/bge.types.KX_ConstraintWrapper.rst
deleted file mode 100644
index d9f03395c34..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_ConstraintWrapper.rst
+++ /dev/null
@@ -1,143 +0,0 @@
-KX_ConstraintWrapper(PyObjectPlus)
-==================================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: KX_ConstraintWrapper(PyObjectPlus)
-
- KX_ConstraintWrapper
-
- .. method:: getConstraintId(val)
-
- Returns the contraint ID
-
- :return: the constraint ID
- :rtype: integer
-
- .. method:: setParam(axis, value0, value1)
-
- Set the contraint limits
-
- :arg axis:
- :type axis: integer
-
- .. note::
- * Lowerlimit == Upperlimit -> axis is locked
- * Lowerlimit > Upperlimit -> axis is free
- * Lowerlimit < Upperlimit -> axis it limited in that range
-
- For PHY_LINEHINGE_CONSTRAINT = 2 or PHY_ANGULAR_CONSTRAINT = 3:
-
- axis = 3 is a constraint limit, with low/high limit value
- * 3: X axis angle
-
- :arg value0 (min): Set the minimum limit of the axis
- :type value0: float
- :arg value1 (max): Set the maximum limit of the axis
- :type value1: float
-
- For PHY_CONE_TWIST_CONSTRAINT = 4:
-
- axis = 3..5 are constraint limits, high limit values
- * 3: X axis angle
- * 4: Y axis angle
- * 5: Z axis angle
-
- :arg value0 (min): Set the minimum limit of the axis
- :type value0: float
- :arg value1 (max): Set the maximum limit of the axis
- :type value1: float
-
- For PHY_GENERIC_6DOF_CONSTRAINT = 12:
-
- axis = 0..2 are constraint limits, with low/high limit value
- * 0: X axis position
- * 1: Y axis position
- * 2: Z axis position
-
- axis = 3..5 are relative constraint (Euler) angles in radians
- * 3: X axis angle
- * 4: Y axis angle
- * 5: Z axis angle
-
- :arg value0 (min): Set the minimum limit of the axis
- :type value0: float
- :arg value1 (max): Set the maximum limit of the axis
- :type value1: float
-
- axis = 6..8 are translational motors, with value0=target velocity, value1 = max motor force
- * 6: X axis position
- * 7: Y axis position
- * 8: Z axis position
-
- axis = 9..11 are rotational motors, with value0=target velocity, value1 = max motor force
- * 9: X axis angle
- * 10: Y axis angle
- * 11: Z axis angle
-
- :arg value0 (speed): Set the linear velocity of the axis
- :type value0: float Range: -10,000.00 to 10,000.00
- :arg value1 (force): Set the maximum force limit of the axis
- :type value1: float Range: -10,000.00 to 10,000.00
-
- axis = 12..14 are for linear springs on each of the position of freedom
- * 12: X axis position
- * 13: Y axis position
- * 14: Z axis position
-
- axis = 15..17 are for angular springs on each of the angle of freedom in radians
- * 15: X axis angle
- * 16: Y axis angle
- * 17: Z axis angle
-
- :arg value0 (stiffness): Set the stiffness of the spring
- :type value0: float
- :arg value1 (damping): Tendency of the spring to return to it's original position
- :type value1: float
- 1.0 = springs back to original position (no damping)
- 0.0 = don't springs back
-
- .. method:: getParam(axis)
-
- Get the contraint position or euler angle of a generic 6DOF constraint
-
- :arg axis:
- :type axis: integer
-
- axis = 0..2 are linear constraint values
- * 0: X axis position
- * 1: Y axis position
- * 2: Z axis position
-
- :return: position
- :rtype: float
-
- axis = 3..5 are relative constraint (Euler) angles in radians
- * 3: X axis angle
- * 4: Y axis angle
- * 5: Z axis angle
-
- :return: angle
- :rtype: float
-
- .. attribute:: constraint_id
-
- Returns the contraint ID (read only)
-
- :type: integer
-
- .. attribute:: constraint_type
-
- Returns the contraint type (read only)
-
- :type: integer
-
- - :class:`~bge.constraints.POINTTOPOINT_CONSTRAINT`
- - :class:`~bge.constraints.LINEHINGE_CONSTRAINT`
- - :class:`~bge.constraints.ANGULAR_CONSTRAINT`
- - :class:`~bge.constraints.CONETWIST_CONSTRAINT`
- - :class:`~bge.constraints.VEHICLE_CONSTRAINT`
- - :class:`~bge.constraints.GENERIC_6DOF_CONSTRAINT`
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_FontObject.rst b/doc/python_api/rst/bge_types/bge.types.KX_FontObject.rst
deleted file mode 100644
index ca35ff49a08..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_FontObject.rst
+++ /dev/null
@@ -1,32 +0,0 @@
-KX_FontObject(KX_GameObject)
-============================
-
-.. module:: bge.types
-
-base class --- :class:`KX_GameObject`
-
-.. class:: KX_FontObject(KX_GameObject)
-
- A Font object.
-
- .. code-block:: python
-
- # Display a message about the exit key using a Font object.
- import bge
-
- co = bge.logic.getCurrentController()
- font = co.owner
-
- exit_key = bge.events.EventToString(bge.logic.getExitKey())
-
- if exit_key.endswith("KEY"):
- exit_key = exit_key[:-3]
-
- font.text = "Press key '%s' to quit the game." % exit_key
-
- .. attribute:: text
-
- The text displayed by this Font object.
-
- :type: string
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_GameActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_GameActuator.rst
deleted file mode 100644
index 54702c5318d..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_GameActuator.rst
+++ /dev/null
@@ -1,23 +0,0 @@
-KX_GameActuator(SCA_IActuator)
-==============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_GameActuator(SCA_IActuator)
-
- The game actuator loads a new .blend file, restarts the current .blend file or quits the game.
-
- .. attribute:: fileName
-
- the new .blend file to load.
-
- :type: string
-
- .. attribute:: mode
-
- The mode of this actuator. Can be on of :ref:`these constants <game-actuator>`
-
- :type: Int
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst b/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
deleted file mode 100644
index c5729fd5b19..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst
+++ /dev/null
@@ -1,1013 +0,0 @@
-KX_GameObject(SCA_IObject)
-==========================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IObject`
-
-.. class:: KX_GameObject(SCA_IObject)
-
- All game objects are derived from this class.
-
- Properties assigned to game objects are accessible as attributes of this class.
-
- .. note::
-
- Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError,
- if an object may have been removed since last accessing it use the :data:`invalid` attribute to check.
-
- KX_GameObject can be subclassed to extend functionality. For example:
-
- .. code-block:: python
-
- import bge
-
- class CustomGameObject(bge.types.KX_GameObject):
- RATE = 0.05
-
- def __init__(self, old_owner):
- # "old_owner" can just be ignored. At this point, "self" is
- # already the object in the scene, and "old_owner" has been
- # destroyed.
-
- # New attributes can be defined - but we could also use a game
- # property, like "self['rate']".
- self.rate = CustomGameObject.RATE
-
- def update(self):
- self.worldPosition.z += self.rate
-
- # switch direction
- if self.worldPosition.z > 1.0:
- self.rate = -CustomGameObject.RATE
- elif self.worldPosition.z < 0.0:
- self.rate = CustomGameObject.RATE
-
- # Called first
- def mutate(cont):
- old_object = cont.owner
- mutated_object = CustomGameObject(cont.owner)
-
- # After calling the constructor above, references to the old object
- # should not be used.
- assert(old_object is not mutated_object)
- assert(old_object.invalid)
- assert(mutated_object is cont.owner)
-
- # Called later - note we are now working with the mutated object.
- def update(cont):
- cont.owner.update()
-
- When subclassing objects other than empties and meshes, the specific type
- should be used - e.g. inherit from :class:`BL_ArmatureObject` when the object
- to mutate is an armature.
-
- .. attribute:: name
-
- The object's name. (read-only).
-
- :type: string
-
- .. attribute:: mass
-
- The object's mass
-
- :type: float
-
- .. note::
-
- The object must have a physics controller for the mass to be applied, otherwise the mass value will be returned as 0.0.
-
- .. attribute:: isSuspendDynamics
-
- The object's dynamic state (read-only).
-
- :type: boolean
-
- .. seealso:: :py:meth:`suspendDynamics` and :py:meth:`restoreDynamics` allow you to change the state.
-
- .. attribute:: linearDamping
-
- The object's linear damping, also known as translational damping. Can be set simultaneously with angular damping using the :py:meth:`setDamping` method.
-
- :type: float between 0 and 1 inclusive.
-
- .. note::
-
- The object must have a physics controller for the linear damping to be applied, otherwise the value will be returned as 0.0.
-
- .. attribute:: angularDamping
-
- The object's angular damping, also known as rotationation damping. Can be set simultaneously with linear damping using the :py:meth:`setDamping` method.
-
- :type: float between 0 and 1 inclusive.
-
- .. note::
-
- The object must have a physics controller for the angular damping to be applied, otherwise the value will be returned as 0.0.
-
-
- .. attribute:: linVelocityMin
-
- Enforces the object keeps moving at a minimum velocity.
-
- :type: float
-
- .. note::
-
- Applies to dynamic and rigid body objects only.
-
- .. note::
-
- A value of 0.0 disables this option.
-
- .. note::
-
- While objects are stationary the minimum velocity will not be applied.
-
- .. attribute:: linVelocityMax
-
- Clamp the maximum linear velocity to prevent objects moving beyond a set speed.
-
- :type: float
-
- .. note::
-
- Applies to dynamic and rigid body objects only.
-
- .. note::
-
- A value of 0.0 disables this option (rather than setting it stationary).
-
- .. attribute:: angularVelocityMin
-
- Enforces the object keeps rotating at a minimum velocity. A value of 0.0 disables this.
-
- :type: non-negative float
-
- .. note::
-
- Applies to dynamic and rigid body objects only.
- While objects are stationary the minimum velocity will not be applied.
-
-
- .. attribute:: angularVelocityMax
-
- Clamp the maximum angular velocity to prevent objects rotating beyond a set speed.
- A value of 0.0 disables clamping; it does not stop rotation.
-
- :type: non-negative float
-
- .. note::
-
- Applies to dynamic and rigid body objects only.
-
- .. attribute:: localInertia
-
- the object's inertia vector in local coordinates. Read only.
-
- :type: Vector((ix, iy, iz))
-
- .. attribute:: parent
-
- The object's parent object. (read-only).
-
- :type: :class:`KX_GameObject` or None
-
- .. attribute:: groupMembers
-
- Returns the list of group members if the object is a group object (dupli group instance), otherwise None is returned.
-
- :type: :class:`CListValue` of :class:`KX_GameObject` or None
-
- .. attribute:: groupObject
-
- Returns the group object (dupli group instance) that the object belongs to or None if the object is not part of a group.
-
- :type: :class:`KX_GameObject` or None
-
- .. attribute:: collisionGroup
-
- The object's collision group.
-
- :type: bitfield
-
- .. attribute:: collisionMask
-
- The object's collision mask.
-
- :type: bitfield
-
- .. attribute:: collisionCallbacks
-
- A list of functions to be called when a collision occurs.
-
- :type: list of functions and/or methods
-
- Callbacks should either accept one argument `(object)`, or three
- arguments `(object, point, normal)`. For simplicity, per
- colliding object only the first collision point is reported.
-
- .. code-block:: python
-
- # Function form
- def callback_three(object, point, normal):
- print('Hit by %r at %s with normal %s' % (object.name, point, normal))
-
- def callback_one(object):
- print('Hit by %r' % object.name)
-
- def register_callback(controller):
- controller.owner.collisionCallbacks.append(callback_three)
- controller.owner.collisionCallbacks.append(callback_one)
-
-
- # Method form
- class YourGameEntity(bge.types.KX_GameObject):
- def __init__(self, old_owner):
- self.collisionCallbacks.append(self.on_collision_three)
- self.collisionCallbacks.append(self.on_collision_one)
-
- def on_collision_three(self, object, point, normal):
- print('Hit by %r at %s with normal %s' % (object.name, point, normal))
-
- def on_collision_one(self, object):
- print('Hit by %r' % object.name)
-
- .. note::
- For backward compatibility, a callback with variable number of
- arguments (using `*args`) will be passed only the `object`
- argument. Only when there is more than one fixed argument (not
- counting `self` for methods) will the three-argument form be
- used.
-
- .. attribute:: scene
-
- The object's scene. (read-only).
-
- :type: :class:`KX_Scene` or None
-
- .. attribute:: visible
-
- visibility flag.
-
- :type: boolean
-
- .. note::
-
- Game logic will still run for invisible objects.
-
- .. attribute:: record_animation
-
- Record animation for this object.
-
- :type: boolean
-
- .. attribute:: color
-
- The object color of the object. [r, g, b, a]
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: occlusion
-
- occlusion capability flag.
-
- :type: boolean
-
- .. attribute:: position
-
- The object's position. [x, y, z] On write: local position, on read: world position
-
- .. deprecated:: use :data:`localPosition` and :data:`worldPosition`.
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: orientation
-
- The object's orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector. On write: local orientation, on read: world orientation
-
- .. deprecated:: use :data:`localOrientation` and :data:`worldOrientation`.
-
- :type: :class:`mathutils.Matrix`
-
- .. attribute:: scaling
-
- The object's scaling factor. [sx, sy, sz] On write: local scaling, on read: world scaling
-
- .. deprecated:: use :data:`localScale` and :data:`worldScale`.
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: localOrientation
-
- The object's local orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
-
- :type: :class:`mathutils.Matrix`
-
- .. attribute:: worldOrientation
-
- The object's world orientation. 3x3 Matrix.
-
- :type: :class:`mathutils.Matrix`
-
- .. attribute:: localScale
-
- The object's local scaling factor. [sx, sy, sz]
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: worldScale
-
- The object's world scaling factor. [sx, sy, sz]
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: localPosition
-
- The object's local position. [x, y, z]
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: worldPosition
-
- The object's world position. [x, y, z]
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: localTransform
-
- The object's local space transform matrix. 4x4 Matrix.
-
- :type: :class:`mathutils.Matrix`
-
- .. attribute:: worldTransform
-
- The object's world space transform matrix. 4x4 Matrix.
-
- :type: :class:`mathutils.Matrix`
-
- .. attribute:: localLinearVelocity
-
- The object's local linear velocity. [x, y, z]
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: worldLinearVelocity
-
- The object's world linear velocity. [x, y, z]
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: localAngularVelocity
-
- The object's local angular velocity. [x, y, z]
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: worldAngularVelocity
-
- The object's world angular velocity. [x, y, z]
-
- :type: :class:`mathutils.Vector`
-
- .. attribute:: timeOffset
-
- adjust the slowparent delay at runtime.
-
- :type: float
-
- .. attribute:: state
-
- the game object's state bitmask, using the first 30 bits, one bit must always be set.
-
- :type: int
-
- .. attribute:: meshes
-
- a list meshes for this object.
-
- :type: list of :class:`KX_MeshProxy`
-
- .. note::
-
- Most objects use only 1 mesh.
-
- .. note::
-
- Changes to this list will not update the KX_GameObject.
-
- .. attribute:: sensors
-
- a sequence of :class:`SCA_ISensor` objects with string/index lookups and iterator support.
-
- :type: list
-
- .. note::
-
- This attribute is experimental and may be removed (but probably wont be).
-
- .. note::
-
- Changes to this list will not update the KX_GameObject.
-
- .. attribute:: controllers
-
- a sequence of :class:`SCA_IController` objects with string/index lookups and iterator support.
-
- :type: list of :class:`SCA_ISensor`
-
- .. note::
-
- This attribute is experimental and may be removed (but probably wont be).
-
- .. note::
-
- Changes to this list will not update the KX_GameObject.
-
- .. attribute:: actuators
-
- a list of :class:`SCA_IActuator` with string/index lookups and iterator support.
-
- :type: list
-
- .. note::
-
- This attribute is experemental and may be removed (but probably wont be).
-
- .. note::
-
- Changes to this list will not update the KX_GameObject.
-
- .. attribute:: attrDict
-
- get the objects internal python attribute dictionary for direct (faster) access.
-
- :type: dict
-
- .. attribute:: children
-
- direct children of this object, (read-only).
-
- :type: :class:`CListValue` of :class:`KX_GameObject`'s
-
- .. attribute:: childrenRecursive
-
- all children of this object including children's children, (read-only).
-
- :type: :class:`CListValue` of :class:`KX_GameObject`'s
-
- .. attribute:: life
-
- The number of seconds until the object ends, assumes 50fps.
- (when added with an add object actuator), (read-only).
-
- :type: float
-
- .. attribute:: debug
-
- If true, the object's debug properties will be displayed on screen.
-
- :type: boolean
-
- .. attribute:: debugRecursive
-
- If true, the object's and children's debug properties will be displayed on screen.
-
- :type: boolean
-
- .. attribute:: currentLodLevel
-
- The index of the level of detail (LOD) currently used by this object (read-only).
-
- :type: int
-
- .. method:: endObject()
-
- Delete this object, can be used in place of the EndObject Actuator.
-
- The actual removal of the object from the scene is delayed.
-
- .. method:: replaceMesh(mesh, useDisplayMesh=True, usePhysicsMesh=False)
-
- Replace the mesh of this object with a new mesh. This works the same was as the actuator.
-
- :arg mesh: mesh to replace or the meshes name.
- :type mesh: :class:`MeshProxy` or string
- :arg useDisplayMesh: when enabled the display mesh will be replaced (optional argument).
- :type useDisplayMesh: boolean
- :arg usePhysicsMesh: when enabled the physics mesh will be replaced (optional argument).
- :type usePhysicsMesh: boolean
-
- .. method:: setVisible(visible, recursive)
-
- Sets the game object's visible flag.
-
- :arg visible: the visible state to set.
- :type visible: boolean
- :arg recursive: optional argument to set all childrens visibility flag too.
- :type recursive: boolean
-
- .. method:: setOcclusion(occlusion, recursive)
-
- Sets the game object's occlusion capability.
-
- :arg occlusion: the state to set the occlusion to.
- :type occlusion: boolean
- :arg recursive: optional argument to set all childrens occlusion flag too.
- :type recursive: boolean
-
- .. method:: alignAxisToVect(vect, axis=2, factor=1.0)
-
- Aligns any of the game object's axis along the given vector.
-
-
- :arg vect: a vector to align the axis.
- :type vect: 3D vector
- :arg axis: The axis you want to align
-
- * 0: X axis
- * 1: Y axis
- * 2: Z axis
-
- :type axis: integer
- :arg factor: Only rotate a feaction of the distance to the target vector (0.0 - 1.0)
- :type factor: float
-
- .. method:: getAxisVect(vect)
-
- Returns the axis vector rotates by the object's worldspace orientation.
- This is the equivalent of multiplying the vector by the orientation matrix.
-
- :arg vect: a vector to align the axis.
- :type vect: 3D Vector
- :return: The vector in relation to the objects rotation.
- :rtype: 3d vector.
-
- .. method:: applyMovement(movement, local=False)
-
- Sets the game object's movement.
-
- :arg movement: movement vector.
- :type movement: 3D Vector
- :arg local:
- * False: you get the "global" movement ie: relative to world orientation.
- * True: you get the "local" movement ie: relative to object orientation.
- :arg local: boolean
-
- .. method:: applyRotation(rotation, local=False)
-
- Sets the game object's rotation.
-
- :arg rotation: rotation vector.
- :type rotation: 3D Vector
- :arg local:
- * False: you get the "global" rotation ie: relative to world orientation.
- * True: you get the "local" rotation ie: relative to object orientation.
- :arg local: boolean
-
- .. method:: applyForce(force, local=False)
-
- Sets the game object's force.
-
- This requires a dynamic object.
-
- :arg force: force vector.
- :type force: 3D Vector
- :arg local:
- * False: you get the "global" force ie: relative to world orientation.
- * True: you get the "local" force ie: relative to object orientation.
- :type local: boolean
-
- .. method:: applyTorque(torque, local=False)
-
- Sets the game object's torque.
-
- This requires a dynamic object.
-
- :arg torque: torque vector.
- :type torque: 3D Vector
- :arg local:
- * False: you get the "global" torque ie: relative to world orientation.
- * True: you get the "local" torque ie: relative to object orientation.
- :type local: boolean
-
- .. method:: getLinearVelocity(local=False)
-
- Gets the game object's linear velocity.
-
- This method returns the game object's velocity through it's center of mass, ie no angular velocity component.
-
- :arg local:
- * False: you get the "global" velocity ie: relative to world orientation.
- * True: you get the "local" velocity ie: relative to object orientation.
- :type local: boolean
- :return: the object's linear velocity.
- :rtype: Vector((vx, vy, vz))
-
- .. method:: setLinearVelocity(velocity, local=False)
-
- Sets the game object's linear velocity.
-
- This method sets game object's velocity through it's center of mass,
- ie no angular velocity component.
-
- This requires a dynamic object.
-
- :arg velocity: linear velocity vector.
- :type velocity: 3D Vector
- :arg local:
- * False: you get the "global" velocity ie: relative to world orientation.
- * True: you get the "local" velocity ie: relative to object orientation.
- :type local: boolean
-
- .. method:: getAngularVelocity(local=False)
-
- Gets the game object's angular velocity.
-
- :arg local:
- * False: you get the "global" velocity ie: relative to world orientation.
- * True: you get the "local" velocity ie: relative to object orientation.
- :type local: boolean
- :return: the object's angular velocity.
- :rtype: Vector((vx, vy, vz))
-
- .. method:: setAngularVelocity(velocity, local=False)
-
- Sets the game object's angular velocity.
-
- This requires a dynamic object.
-
- :arg velocity: angular velocity vector.
- :type velocity: boolean
- :arg local:
- * False: you get the "global" velocity ie: relative to world orientation.
- * True: you get the "local" velocity ie: relative to object orientation.
-
- .. method:: getVelocity(point=(0, 0, 0))
-
- Gets the game object's velocity at the specified point.
-
- Gets the game object's velocity at the specified point, including angular
- components.
-
- :arg point: optional point to return the velocity for, in local coordinates.
- :type point: 3D Vector
- :return: the velocity at the specified point.
- :rtype: Vector((vx, vy, vz))
-
- .. method:: getReactionForce()
-
- Gets the game object's reaction force.
-
- The reaction force is the force applied to this object over the last simulation timestep.
- This also includes impulses, eg from collisions.
-
- :return: the reaction force of this object.
- :rtype: Vector((fx, fy, fz))
-
- .. note::
-
- This is not implimented at the moment.
-
- .. method:: applyImpulse(point, impulse, local=False)
-
- Applies an impulse to the game object.
-
- This will apply the specified impulse to the game object at the specified point.
- If point != position, applyImpulse will also change the object's angular momentum.
- Otherwise, only linear momentum will change.
-
- :arg point: the point to apply the impulse to (in world or local coordinates)
- :type point: point [ix, iy, iz] the point to apply the impulse to (in world or local coordinates)
- :arg impulse: impulse vector.
- :type impulse: 3D Vector
- :arg local:
- * False: you get the "global" impulse ie: relative to world coordinates with world orientation.
- * True: you get the "local" impulse ie: relative to local coordinates with object orientation.
- :type local: boolean
-
- .. method:: setDamping(linear_damping, angular_damping)
-
- Sets both the :py:attr:`linearDamping` and :py:attr:`angularDamping` simultaneously. This is more efficient than setting both properties individually.
-
- :arg linear_damping: Linear ("translational") damping factor.
- :type linear_damping: float ∈ [0, 1]
- :arg angular_damping: Angular ("rotational") damping factor.
- :type angular_damping: float ∈ [0, 1]
-
- .. method:: suspendDynamics([ghost])
-
- Suspends physics for this object.
-
- :arg ghost: When set to `True`, collisions with the object will be ignored, similar to the "ghost" checkbox in
- Blender. When `False` (the default), the object becomes static but still collide with other objects.
- :type ghost: bool
-
- .. seealso:: :py:attr:`isSuspendDynamics` allows you to inspect whether the object is in a suspended state.
-
- .. method:: restoreDynamics()
-
- Resumes physics for this object. Also reinstates collisions; the object will no longer be a ghost.
-
- .. note::
-
- The objects linear velocity will be applied from when the dynamics were suspended.
-
- .. method:: enableRigidBody()
-
- Enables rigid body physics for this object.
-
- Rigid body physics allows the object to roll on collisions.
-
- .. method:: disableRigidBody()
-
- Disables rigid body physics for this object.
-
- .. method:: setParent(parent, compound=True, ghost=True)
-
- Sets this object's parent.
- Control the shape status with the optional compound and ghost parameters:
-
- In that case you can control if it should be ghost or not:
-
- :arg parent: new parent object.
- :type parent: :class:`KX_GameObject`
- :arg compound: whether the shape should be added to the parent compound shape.
-
- * True: the object shape should be added to the parent compound shape.
- * False: the object should keep its individual shape.
-
- :type compound: boolean
- :arg ghost: whether the object should be ghost while parented.
-
- * True: if the object should be made ghost while parented.
- * False: if the object should be solid while parented.
-
- :type ghost: boolean
-
- .. note::
-
- If the object type is sensor, it stays ghost regardless of ghost parameter
-
- .. method:: removeParent()
-
- Removes this objects parent.
-
- .. method:: getPhysicsId()
-
- Returns the user data object associated with this game object's physics controller.
-
- .. method:: getPropertyNames()
-
- Gets a list of all property names.
-
- :return: All property names for this object.
- :rtype: list
-
- .. method:: getDistanceTo(other)
-
- :arg other: a point or another :class:`KX_GameObject` to measure the distance to.
- :type other: :class:`KX_GameObject` or list [x, y, z]
- :return: distance to another object or point.
- :rtype: float
-
- .. method:: getVectTo(other)
-
- Returns the vector and the distance to another object or point.
- The vector is normalized unless the distance is 0, in which a zero length vector is returned.
-
- :arg other: a point or another :class:`KX_GameObject` to get the vector and distance to.
- :type other: :class:`KX_GameObject` or list [x, y, z]
- :return: (distance, globalVector(3), localVector(3))
- :rtype: 3-tuple (float, 3-tuple (x, y, z), 3-tuple (x, y, z))
-
- .. method:: rayCastTo(other, dist, prop)
-
- Look towards another point/object and find first object hit within dist that matches prop.
-
- The ray is always casted from the center of the object, ignoring the object itself.
- The ray is casted towards the center of another object or an explicit [x, y, z] point.
- Use rayCast() if you need to retrieve the hit point
-
- :arg other: [x, y, z] or object towards which the ray is casted
- :type other: :class:`KX_GameObject` or 3-tuple
- :arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
- :type dist: float
- :arg prop: property name that object must have; can be omitted => detect any object
- :type prop: string
- :return: the first object hit or None if no object or object does not match prop
- :rtype: :class:`KX_GameObject`
-
- .. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly, mask)
-
- Look from a point/object to another point/object and find first object hit within dist that matches prop.
- if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None, None, None) if no hit.
- if poly is 1, returns a 4-tuple with in addition a :class:`KX_PolyProxy` as 4th element.
- if poly is 2, returns a 5-tuple with in addition a 2D vector with the UV mapping of the hit point as 5th element.
-
- .. code-block:: python
-
- # shoot along the axis gun-gunAim (gunAim should be collision-free)
- obj, point, normal = gun.rayCast(gunAim, None, 50)
- if obj:
- # do something
- pass
-
- The face parameter determines the orientation of the normal.
-
- * 0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
- * 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
-
- The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
- The prop and xray parameters interact as follow.
-
- * prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
- * prop off, xray on : idem.
- * prop on, xray off: return closest hit if it matches prop, no hit otherwise.
- * prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
-
- The :class:`KX_PolyProxy` 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
- If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
-
- The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
-
- :arg objto: [x, y, z] or object to which the ray is casted
- :type objto: :class:`KX_GameObject` or 3-tuple
- :arg objfrom: [x, y, z] or object from which the ray is casted; None or omitted => use self object center
- :type objfrom: :class:`KX_GameObject` or 3-tuple or None
- :arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
- :type dist: float
- :arg prop: property name that object must have; can be omitted or "" => detect any object
- :type prop: string
- :arg face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
- :type face: integer
- :arg xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
- :type xray: integer
- :arg poly: polygon option: 0, 1 or 2 to return a 3-, 4- or 5-tuple with information on the face hit.
-
- * 0 or omitted: return value is a 3-tuple (object, hitpoint, hitnormal) or (None, None, None) if no hit
- * 1: return value is a 4-tuple and the 4th element is a :class:`KX_PolyProxy` or None if no hit or the object doesn't use a mesh collision shape.
- * 2: return value is a 5-tuple and the 5th element is a 2-tuple (u, v) with the UV mapping of the hit point or None if no hit, or the object doesn't use a mesh collision shape, or doesn't have a UV mapping.
-
- :type poly: integer
- :arg mask: collision mask: The collision mask (16 layers mapped to a 16-bit integer) is combined with each object's collision group, to hit only a subset of the objects in the scene. Only those objects for which ``collisionGroup & mask`` is true can be hit.
- :type mask: bitfield
- :return: (object, hitpoint, hitnormal) or (object, hitpoint, hitnormal, polygon) or (object, hitpoint, hitnormal, polygon, hituv).
-
- * object, hitpoint and hitnormal are None if no hit.
- * polygon is valid only if the object is valid and is a static object, a dynamic object using mesh collision shape or a soft body object, otherwise it is None
- * hituv is valid only if polygon is valid and the object has a UV mapping, otherwise it is None
-
- :rtype:
-
- * 3-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz))
- * or 4-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz), :class:`KX_PolyProxy`)
- * or 5-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz), :class:`KX_PolyProxy`, 2-tuple (u, v))
-
- .. note::
-
- The ray ignores the object on which the method is called. It is casted from/to object center or explicit [x, y, z] points.
-
- .. method:: setCollisionMargin(margin)
-
- Set the objects collision margin.
-
- :arg margin: the collision margin distance in blender units.
- :type margin: float
-
- .. note::
-
- If this object has no physics controller (a physics ID of zero), this function will raise RuntimeError.
-
- .. method:: sendMessage(subject, body="", to="")
-
- Sends a message.
-
- :arg subject: The subject of the message
- :type subject: string
- :arg body: The body of the message (optional)
- :type body: string
- :arg to: The name of the object to send the message to (optional)
- :type to: string
-
- .. method:: reinstancePhysicsMesh(gameObject, meshObject)
-
- Updates the physics system with the changed mesh.
-
- If no arguments are given the physics mesh will be re-created from the first mesh assigned to the game object.
-
- :arg gameObject: optional argument, set the physics shape from this gameObjets mesh.
- :type gameObject: string, :class:`KX_GameObject` or None
- :arg meshObject: optional argument, set the physics shape from this mesh.
- :type meshObject: string, :class:`MeshProxy` or None
-
- :return: True if reinstance succeeded, False if it failed.
- :rtype: boolean
-
- .. note::
-
- If this object has instances the other instances will be updated too.
-
- .. note::
-
- The gameObject argument has an advantage that it can convert from a mesh with modifiers applied (such as the Subdivision Surface modifier).
-
- .. warning::
-
- Only triangle mesh type objects are supported currently (not convex hull)
-
- .. warning::
-
- If the object is a part of a compound object it will fail (parent or child)
-
- .. warning::
-
- Rebuilding the physics mesh can be slow, running many times per second will give a performance hit.
-
- .. method:: get(key, default=None)
-
- Return the value matching key, or the default value if its not found.
- :return: The key value or a default.
-
- .. method:: playAction(name, start_frame, end_frame, layer=0, priority=0, blendin=0, play_mode=KX_ACTION_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0, blend_mode=KX_ACTION_BLEND_BLEND)
-
- Plays an action.
-
- :arg name: the name of the action
- :type name: string
- :arg start: the start frame of the action
- :type start: float
- :arg end: the end frame of the action
- :type end: float
- :arg layer: the layer the action will play in (actions in different layers are added/blended together)
- :type layer: integer
- :arg priority: only play this action if there isn't an action currently playing in this layer with a higher (lower number) priority
- :type priority: integer
- :arg blendin: the amount of blending between this animation and the previous one on this layer
- :type blendin: float
- :arg play_mode: the play mode
- :type play_mode: one of :ref:`these constants <gameobject-playaction-mode>`
- :arg layer_weight: how much of the previous layer to use for blending
- :type layer_weight: float
- :arg ipo_flags: flags for the old IPO behaviors (force, etc)
- :type ipo_flags: int bitfield
- :arg speed: the playback speed of the action as a factor (1.0 = normal speed, 2.0 = 2x speed, etc)
- :type speed: float
- :arg blend_mode: how to blend this layer with previous layers
- :type blend_mode: one of :ref:`these constants <gameobject-playaction-blend>`
-
- .. method:: stopAction(layer=0)
-
- Stop playing the action on the given layer.
-
- :arg layer: The layer to stop playing.
- :type layer: integer
-
- .. method:: getActionFrame(layer=0)
-
- Gets the current frame of the action playing in the supplied layer.
-
- :arg layer: The layer that you want to get the frame from.
- :type layer: integer
-
- :return: The current frame of the action
- :rtype: float
-
- .. method:: getActionName(layer=0)
-
- Gets the name of the current action playing in the supplied layer.
-
- :arg layer: The layer that you want to get the action name from.
- :type layer: integer
-
- :return: The name of the current action
- :rtype: string
-
- .. method:: setActionFrame(frame, layer=0)
-
- Set the current frame of the action playing in the supplied layer.
-
- :arg layer: The layer where you want to set the frame
- :type layer: integer
- :arg frame: The frame to set the action to
- :type frame: float
-
- .. method:: isPlayingAction(layer=0)
-
- Checks to see if there is an action playing in the given layer.
-
- :arg layer: The layer to check for a playing action.
- :type layer: integer
-
- :return: Whether or not the action is playing
- :rtype: boolean
-
- .. method:: addDebugProperty (name, debug = True)
-
- Adds a single debug property to the debug list.
-
- :arg name: name of the property that added to the debug list.
- :type name: string
- :arg debug: the debug state.
- :type debug: boolean
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_LibLoadStatus.rst b/doc/python_api/rst/bge_types/bge.types.KX_LibLoadStatus.rst
deleted file mode 100644
index a37b4dad585..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_LibLoadStatus.rst
+++ /dev/null
@@ -1,51 +0,0 @@
-KX_LibLoadStatus(PyObjectPlus)
-==============================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: KX_LibLoadStatus(PyObjectPlus)
-
- An object providing information about a LibLoad() operation.
-
- .. code-block:: python
-
- # Print a message when an async LibLoad is done
- import bge
-
- def finished_cb(status):
- print("Library (%s) loaded in %.2fms." % (status.libraryName, status.timeTaken))
-
- bge.logic.LibLoad('myblend.blend', 'Scene', async=True).onFinish = finished_cb
-
- .. attribute:: onFinish
-
- A callback that gets called when the lib load is done.
-
- :type: callable
-
- .. attribute:: finished
-
- The current status of the lib load.
-
- :type: boolean
-
- .. attribute:: progress
-
- The current progress of the lib load as a normalized value from 0.0 to 1.0.
-
- :type: float
-
- .. attribute:: libraryName
-
- The name of the library being loaded (the first argument to LibLoad).
-
- :type: string
-
- .. attribute:: timeTaken
-
- The amount of time, in seconds, the lib load took (0 until the operation is complete).
-
- :type: float
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_LightObject.rst b/doc/python_api/rst/bge_types/bge.types.KX_LightObject.rst
deleted file mode 100644
index 6748df13873..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_LightObject.rst
+++ /dev/null
@@ -1,164 +0,0 @@
-KX_LightObject(KX_GameObject)
-=============================
-
-.. module:: bge.types
-
-base class --- :class:`KX_GameObject`
-
-.. class:: KX_LightObject(KX_GameObject)
-
- A Light object.
-
- .. code-block:: python
-
- # Turn on a red alert light.
- import bge
-
- co = bge.logic.getCurrentController()
- light = co.owner
-
- light.energy = 1.0
- light.color = [1.0, 0.0, 0.0]
-
- .. data:: SPOT
-
- A spot light source. See attribute :data:`type`
-
- .. data:: SUN
-
- A point light source with no attenuation. See attribute :data:`type`
-
- .. data:: NORMAL
-
- A point light source. See attribute :data:`type`
-
- .. attribute:: type
-
- The type of light - must be SPOT, SUN or NORMAL
-
- .. attribute:: layer
-
- The layer mask that this light affects object on.
-
- :type: bitfield
-
- .. attribute:: energy
-
- The brightness of this light.
-
- :type: float
-
- .. attribute:: shadowClipStart
-
- The shadowmap clip start, below which objects will not generate shadows.
-
- :type: float (read only)
-
- .. attribute:: shadowClipEnd
-
- The shadowmap clip end, beyond which objects will not generate shadows.
-
- :type: float (read only)
-
- .. attribute:: shadowFrustumSize
-
- Size of the frustum used for creating the shadowmap.
-
- :type: float (read only)
-
- .. attribute:: shadowBindId
-
- The OpenGL shadow texture bind number/id.
-
- :type: int (read only)
-
- .. attribute:: shadowMapType
-
- The shadow shadow map type (0 -> Simple; 1 -> Variance)
-
- :type: int (read only)
-
- .. attribute:: shadowBias
-
- The shadow buffer sampling bias.
-
- :type: float (read only)
-
- .. attribute:: shadowBleedBias
-
- The bias for reducing light-bleed on variance shadow maps.
-
- :type: float (read only)
-
- .. attribute:: useShadow
-
- Returns True if the light has Shadow option activated, else returns False.
-
- :type: boolean (read only)
-
- .. attribute:: shadowColor
-
- The color of this light shadows. Black = (0.0, 0.0, 0.0), White = (1.0, 1.0, 1.0).
-
- :type: :class:`mathutils.Color` (read only)
-
- .. attribute:: shadowMatrix
-
- Matrix that converts a vector in camera space to shadow buffer depth space.
-
- Computed as:
- mat4_perspective_to_depth * mat4_lamp_to_perspective * mat4_world_to_lamp * mat4_cam_to_world.
-
- mat4_perspective_to_depth is a fixed matrix defined as follow:
-
- 0.5 0.0 0.0 0.5
- 0.0 0.5 0.0 0.5
- 0.0 0.0 0.5 0.5
- 0.0 0.0 0.0 1.0
-
- .. note:
-
- There is one matrix of that type per lamp casting shadow in the scene.
-
- :type: Matrix4x4 (read only)
-
- .. attribute:: distance
-
- The maximum distance this light can illuminate. (SPOT and NORMAL lights only).
-
- :type: float
-
- .. attribute:: color
-
- The color of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
-
- :type: list [r, g, b]
-
- .. attribute:: lin_attenuation
-
- The linear component of this light's attenuation. (SPOT and NORMAL lights only).
-
- :type: float
-
- .. attribute:: quad_attenuation
-
- The quadratic component of this light's attenuation (SPOT and NORMAL lights only).
-
- :type: float
-
- .. attribute:: spotsize
-
- The cone angle of the spot light, in degrees (SPOT lights only).
-
- :type: float in [0 - 180].
-
- .. attribute:: spotblend
-
- Specifies the intensity distribution of the spot light (SPOT lights only).
-
- :type: float in [0 - 1]
-
- .. note::
-
- Higher values result in a more focused light source.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_MeshProxy.rst b/doc/python_api/rst/bge_types/bge.types.KX_MeshProxy.rst
deleted file mode 100644
index 13fb3263a59..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_MeshProxy.rst
+++ /dev/null
@@ -1,134 +0,0 @@
-KX_MeshProxy(SCA_IObject)
-=========================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IObject`
-
-.. class:: KX_MeshProxy(SCA_IObject)
-
- A mesh object.
-
- You can only change the vertex properties of a mesh object, not the mesh topology.
-
- To use mesh objects effectively, you should know a bit about how the game engine handles them.
-
- #. Mesh Objects are converted from Blender at scene load.
- #. The Converter groups polygons by Material. This means they can be sent to the renderer efficiently. A material holds:
-
- #. The texture.
- #. The Blender material.
- #. The Tile properties
- #. The face properties - (From the "Texture Face" panel)
- #. Transparency & z sorting
- #. Light layer
- #. Polygon shape (triangle/quad)
- #. Game Object
-
- #. Vertices will be split by face if necessary. Vertices can only be shared between faces if:
-
- #. They are at the same position
- #. UV coordinates are the same
- #. Their normals are the same (both polygons are "Set Smooth")
- #. They are the same color, for example: a cube has 24 vertices: 6 faces with 4 vertices per face.
-
- The correct method of iterating over every :class:`KX_VertexProxy` in a game object
-
- .. code-block:: python
-
- from bge import logic
-
- cont = logic.getCurrentController()
- object = cont.owner
-
- for mesh in object.meshes:
- for m_index in range(len(mesh.materials)):
- for v_index in range(mesh.getVertexArrayLength(m_index)):
- vertex = mesh.getVertex(m_index, v_index)
- # Do something with vertex here...
- # ... eg: color the vertex red.
- vertex.color = [1.0, 0.0, 0.0, 1.0]
-
- .. attribute:: materials
-
- :type: list of :class:`KX_BlenderMaterial` type
-
- .. attribute:: numPolygons
-
- :type: integer
-
- .. attribute:: numMaterials
-
- :type: integer
-
- .. method:: getMaterialName(matid)
-
- Gets the name of the specified material.
-
- :arg matid: the specified material.
- :type matid: integer
- :return: the attached material name.
- :rtype: string
-
- .. method:: getTextureName(matid)
-
- Gets the name of the specified material's texture.
-
- :arg matid: the specified material
- :type matid: integer
- :return: the attached material's texture name.
- :rtype: string
-
- .. method:: getVertexArrayLength(matid)
-
- Gets the length of the vertex array associated with the specified material.
-
- There is one vertex array for each material.
-
- :arg matid: the specified material
- :type matid: integer
- :return: the number of verticies in the vertex array.
- :rtype: integer
-
- .. method:: getVertex(matid, index)
-
- Gets the specified vertex from the mesh object.
-
- :arg matid: the specified material
- :type matid: integer
- :arg index: the index into the vertex array.
- :type index: integer
- :return: a vertex object.
- :rtype: :class:`KX_VertexProxy`
-
- .. method:: getPolygon(index)
-
- Gets the specified polygon from the mesh.
-
- :arg index: polygon number
- :type index: integer
- :return: a polygon object.
- :rtype: :class:`KX_PolyProxy`
-
- .. method:: transform(matid, matrix)
-
- Transforms the vertices of a mesh.
-
- :arg matid: material index, -1 transforms all.
- :type matid: integer
- :arg matrix: transformation matrix.
- :type matrix: 4x4 matrix [[float]]
-
- .. method:: transformUV(matid, matrix, uv_index=-1, uv_index_from=-1)
-
- Transforms the vertices UV's of a mesh.
-
- :arg matid: material index, -1 transforms all.
- :type matid: integer
- :arg matrix: transformation matrix.
- :type matrix: 4x4 matrix [[float]]
- :arg uv_index: optional uv index, -1 for all, otherwise 0 or 1.
- :type uv_index: integer
- :arg uv_index_from: optional uv index to copy from, -1 to transform the current uv.
- :type uv_index_from: integer
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_MouseActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_MouseActuator.rst
deleted file mode 100644
index cc3ce49d0a5..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_MouseActuator.rst
+++ /dev/null
@@ -1,103 +0,0 @@
-KX_MouseActuator(SCA_IActuator)
-====================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_MouseActuator(SCA_IActuator)
-
- The mouse actuator gives control over the visibility of the mouse cursor and rotates the parent object according to mouse movement.
-
- .. method:: reset()
-
- Undoes the rotation caused by the mouse actuator.
-
- .. attribute:: visible
-
- The visibility of the mouse cursor.
-
- :type: boolean
-
- .. attribute:: use_axis_x
-
- Mouse movement along the x axis effects object rotation.
-
- :type: boolean
-
- .. attribute:: use_axis_y
-
- Mouse movement along the y axis effects object rotation.
-
- :type: boolean
-
- .. attribute:: threshold
-
- Amount of movement from the mouse required before rotation is triggered.
-
- :type: list (vector of 2 floats)
-
- The values in the list should be between 0.0 and 0.5.
-
- .. attribute:: reset_x
-
- Mouse is locked to the center of the screen on the x axis.
-
- :type: boolean
-
- .. attribute:: reset_y
-
- Mouse is locked to the center of the screen on the y axis.
-
- :type: boolean
-
- .. attribute:: object_axis
-
- The object's 3D axis to rotate with the mouse movement. ([x, y])
-
- :type: list (vector of 2 integers from 0 to 2)
-
- * KX_ACT_MOUSE_OBJECT_AXIS_X
- * KX_ACT_MOUSE_OBJECT_AXIS_Y
- * KX_ACT_MOUSE_OBJECT_AXIS_Z
-
- .. attribute:: local_x
-
- Rotation caused by mouse movement along the x axis is local.
-
- :type: boolean
-
- .. attribute:: local_y
-
- Rotation caused by mouse movement along the y axis is local.
-
- :type: boolean
-
- .. attribute:: sensitivity
-
- The amount of rotation caused by mouse movement along the x and y axis.
-
- :type: list (vector of 2 floats)
-
- Negative values invert the rotation.
-
- .. attribute:: limit_x
-
- The minimum and maximum angle of rotation caused by mouse movement along the x axis in degrees.
- limit_x[0] is minimum, limit_x[1] is maximum.
-
- :type: list (vector of 2 floats)
-
- .. attribute:: limit_y
-
- The minimum and maximum angle of rotation caused by mouse movement along the y axis in degrees.
- limit_y[0] is minimum, limit_y[1] is maximum.
-
- :type: list (vector of 2 floats)
-
- .. attribute:: angle
-
- The current rotational offset caused by the mouse actuator in degrees.
-
- :type: list (vector of 2 floats)
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_MouseFocusSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_MouseFocusSensor.rst
deleted file mode 100644
index 0600a4b5aae..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_MouseFocusSensor.rst
+++ /dev/null
@@ -1,83 +0,0 @@
-KX_MouseFocusSensor(SCA_MouseSensor)
-====================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_MouseSensor`
-
-.. class:: KX_MouseFocusSensor(SCA_MouseSensor)
-
- The mouse focus sensor detects when the mouse is over the current game object.
-
- The mouse focus sensor works by transforming the mouse coordinates from 2d device
- space to 3d space then raycasting away from the camera.
-
- .. attribute:: raySource
-
- The worldspace source of the ray (the view position).
-
- :type: list (vector of 3 floats)
-
- .. attribute:: rayTarget
-
- The worldspace target of the ray.
-
- :type: list (vector of 3 floats)
-
- .. attribute:: rayDirection
-
- The :data:`rayTarget` - :class:`raySource` normalized.
-
- :type: list (normalized vector of 3 floats)
-
- .. attribute:: hitObject
-
- the last object the mouse was over.
-
- :type: :class:`KX_GameObject` or None
-
- .. attribute:: hitPosition
-
- The worldspace position of the ray intersecton.
-
- :type: list (vector of 3 floats)
-
- .. attribute:: hitNormal
-
- the worldspace normal from the face at point of intersection.
-
- :type: list (normalized vector of 3 floats)
-
- .. attribute:: hitUV
-
- the UV coordinates at the point of intersection.
-
- :type: list (vector of 2 floats)
-
- If the object has no UV mapping, it returns [0, 0].
-
- The UV coordinates are not normalized, they can be < 0 or > 1 depending on the UV mapping.
-
- .. attribute:: usePulseFocus
-
- When enabled, moving the mouse over a different object generates a pulse. (only used when the 'Mouse Over Any' sensor option is set).
-
- :type: boolean
-
- .. attribute:: useXRay
-
- If enabled it allows the sensor to see through game objects that don't have the selected property or material.
-
- :type: boolean
-
- .. attribute:: propName
-
- The property or material the sensor is looking for.
-
- :type: string
-
- .. attribute:: useMaterial
-
- Determines if the sensor is looking for a property or material. KX_True = Find material; KX_False = Find property.
-
- :type: boolean
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_NavMeshObject.rst b/doc/python_api/rst/bge_types/bge.types.KX_NavMeshObject.rst
deleted file mode 100644
index 5c73d0aa1d3..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_NavMeshObject.rst
+++ /dev/null
@@ -1,47 +0,0 @@
-KX_NavMeshObject(KX_GameObject)
-===============================
-
-.. module:: bge.types
-
-base class --- :class:`KX_GameObject`
-
-.. class:: KX_NavMeshObject(KX_GameObject)
-
- Python interface for using and controlling navigation meshes.
-
- .. method:: findPath(start, goal)
-
- Finds the path from start to goal points.
-
- :arg start: the start point
- :arg start: 3D Vector
- :arg goal: the goal point
- :arg start: 3D Vector
- :return: a path as a list of points
- :rtype: list of points
-
- .. method:: raycast(start, goal)
-
- Raycast from start to goal points.
-
- :arg start: the start point
- :arg start: 3D Vector
- :arg goal: the goal point
- :arg start: 3D Vector
- :return: the hit factor
- :rtype: float
-
- .. method:: draw(mode)
-
- Draws a debug mesh for the navigation mesh.
-
- :arg mode: the drawing mode (one of :ref:`these constants <navmesh-draw-mode>`)
- :arg mode: integer
- :return: None
-
- .. method:: rebuild()
-
- Rebuild the navigation mesh.
-
- :return: None
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_NearSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_NearSensor.rst
deleted file mode 100644
index 995e645b979..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_NearSensor.rst
+++ /dev/null
@@ -1,23 +0,0 @@
-KX_NearSensor(KX_TouchSensor)
-=============================
-
-.. module:: bge.types
-
-base class --- :class:`KX_TouchSensor`
-
-.. class:: KX_NearSensor(KX_TouchSensor)
-
- A near sensor is a specialised form of touch sensor.
-
- .. attribute:: distance
-
- The near sensor activates when an object is within this distance.
-
- :type: float
-
- .. attribute:: resetDistance
-
- The near sensor deactivates when the object exceeds this distance.
-
- :type: float
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageActuator.rst
deleted file mode 100644
index b8dcd01fe43..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageActuator.rst
+++ /dev/null
@@ -1,35 +0,0 @@
-KX_NetworkMessageActuator(SCA_IActuator)
-========================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_NetworkMessageActuator(SCA_IActuator)
-
- Message Actuator
-
- .. attribute:: propName
-
- Messages will only be sent to objects with the given property name.
-
- :type: string
-
- .. attribute:: subject
-
- The subject field of the message.
-
- :type: string
-
- .. attribute:: body
-
- The body of the message.
-
- :type: string
-
- .. attribute:: usePropBody
-
- Send a property instead of a regular body message.
-
- :type: boolean
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageSensor.rst
deleted file mode 100644
index a6b1082a4fe..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageSensor.rst
+++ /dev/null
@@ -1,38 +0,0 @@
-KX_NetworkMessageSensor(SCA_ISensor)
-====================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: KX_NetworkMessageSensor(SCA_ISensor)
-
- The Message Sensor logic brick.
-
- Currently only loopback (local) networks are supported.
-
- .. attribute:: subject
-
- The subject the sensor is looking for.
-
- :type: string
-
- .. attribute:: frameMessageCount
-
- The number of messages received since the last frame. (read-only).
-
- :type: integer
-
- .. attribute:: subjects
-
- The list of message subjects received. (read-only).
-
- :type: list of strings
-
- .. attribute:: bodies
-
- The list of message bodies received. (read-only).
-
- :type: list of strings
-
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst
deleted file mode 100644
index 347b000be3d..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst
+++ /dev/null
@@ -1,129 +0,0 @@
-KX_ObjectActuator(SCA_IActuator)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_ObjectActuator(SCA_IActuator)
-
- The object actuator ("Motion Actuator") applies force, torque, displacement, angular displacement,
- velocity, or angular velocity to an object.
- Servo control allows to regulate force to achieve a certain speed target.
-
- .. attribute:: force
-
- The force applied by the actuator.
-
- :type: Vector((x, y, z))
-
- .. attribute:: useLocalForce
-
- A flag specifying if the force is local.
-
- :type: boolean
-
- .. attribute:: torque
-
- The torque applied by the actuator.
-
- :type: Vector((x, y, z))
-
- .. attribute:: useLocalTorque
-
- A flag specifying if the torque is local.
-
- :type: boolean
-
- .. attribute:: dLoc
-
- The displacement vector applied by the actuator.
-
- :type: Vector((x, y, z))
-
- .. attribute:: useLocalDLoc
-
- A flag specifying if the dLoc is local.
-
- :type: boolean
-
- .. attribute:: dRot
-
- The angular displacement vector applied by the actuator
-
- :type: Vector((x, y, z))
-
- .. note::
-
- Since the displacement is applied every frame, you must adjust the displacement based on the frame rate, or you game experience will depend on the player's computer speed.
-
- .. attribute:: useLocalDRot
-
- A flag specifying if the dRot is local.
-
- :type: boolean
-
- .. attribute:: linV
-
- The linear velocity applied by the actuator.
-
- :type: Vector((x, y, z))
-
- .. attribute:: useLocalLinV
-
- A flag specifying if the linear velocity is local.
-
- :type: boolean
-
- .. note::
-
- This is the target speed for servo controllers.
-
- .. attribute:: angV
-
- The angular velocity applied by the actuator.
-
- :type: Vector((x, y, z))
-
- .. attribute:: useLocalAngV
-
- A flag specifying if the angular velocity is local.
-
- :type: boolean
-
- .. attribute:: damping
-
- The damping parameter of the servo controller.
-
- :type: short
-
- .. attribute:: forceLimitX
-
- The min/max force limit along the X axis and activates or deactivates the limits in the servo controller.
-
- :type: list [min(float), max(float), bool]
-
- .. attribute:: forceLimitY
-
- The min/max force limit along the Y axis and activates or deactivates the limits in the servo controller.
-
- :type: list [min(float), max(float), bool]
-
- .. attribute:: forceLimitZ
-
- The min/max force limit along the Z axis and activates or deactivates the limits in the servo controller.
-
- :type: list [min(float), max(float), bool]
-
- .. attribute:: pid
-
- The PID coefficients of the servo controller.
-
- :type: list of floats [proportional, integral, derivate]
-
- .. attribute:: reference
-
- The object that is used as reference to compute the velocity for the servo controller.
-
- :type: :class:`KX_GameObject` or None
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ParentActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_ParentActuator.rst
deleted file mode 100644
index 77dcb907d6a..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_ParentActuator.rst
+++ /dev/null
@@ -1,38 +0,0 @@
-KX_ParentActuator(SCA_IActuator)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_ParentActuator(SCA_IActuator)
-
- The parent actuator can set or remove an objects parent object.
-
- .. attribute:: object
-
- the object this actuator sets the parent too.
-
- :type: :class:`KX_GameObject` or None
-
- .. attribute:: mode
-
- The mode of this actuator.
-
- :type: integer from 0 to 1.
-
- .. attribute:: compound
-
- Whether the object shape should be added to the parent compound shape when parenting.
-
- Effective only if the parent is already a compound shape.
-
- :type: boolean
-
- .. attribute:: ghost
-
- Whether the object should be made ghost when parenting
- Effective only if the shape is not added to the parent compound shape.
-
- :type: boolean
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_PolyProxy.rst b/doc/python_api/rst/bge_types/bge.types.KX_PolyProxy.rst
deleted file mode 100644
index f43cf62eec1..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_PolyProxy.rst
+++ /dev/null
@@ -1,139 +0,0 @@
-KX_PolyProxy(SCA_IObject)
-=========================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IObject`
-
-.. class:: KX_PolyProxy(SCA_IObject)
-
- A polygon holds the index of the vertex forming the poylgon.
-
- Note:
- The polygon attributes are read-only, you need to retrieve the vertex proxy if you want
- to change the vertex settings.
-
- .. attribute:: material_name
-
- The name of polygon material, empty if no material.
-
- :type: string
-
- .. attribute:: material
-
- The material of the polygon.
-
- :type: :class:`KX_BlenderMaterial`
-
- .. attribute:: texture_name
-
- The texture name of the polygon.
-
- :type: string
-
- .. attribute:: material_id
-
- The material index of the polygon, use this to retrieve vertex proxy from mesh proxy.
-
- :type: integer
-
- .. attribute:: v1
-
- vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
-
- :type: integer
-
- .. attribute:: v2
-
- vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
-
- :type: integer
-
- .. attribute:: v3
-
- vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
-
- :type: integer
-
- .. attribute:: v4
-
- Vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
- Use this to retrieve vertex proxy from mesh proxy.
-
- :type: integer
-
- .. attribute:: visible
-
- visible state of the polygon: 1=visible, 0=invisible.
-
- :type: integer
-
- .. attribute:: collide
-
- collide state of the polygon: 1=receives collision, 0=collision free.
-
- :type: integer
-
- .. method:: getMaterialName()
-
- Returns the polygon material name with MA prefix
-
- :return: material name
- :rtype: string
-
- .. method:: getMaterial()
-
- :return: The polygon material
- :rtype: :class:`KX_BlenderMaterial`
-
- .. method:: getTextureName()
-
- :return: The texture name
- :rtype: string
-
- .. method:: getMaterialIndex()
-
- Returns the material bucket index of the polygon.
- This index and the ones returned by getVertexIndex() are needed to retrieve the vertex proxy from :class:`MeshProxy`.
-
- :return: the material index in the mesh
- :rtype: integer
-
- .. method:: getNumVertex()
-
- Returns the number of vertex of the polygon.
-
- :return: number of vertex, 3 or 4.
- :rtype: integer
-
- .. method:: isVisible()
-
- Returns whether the polygon is visible or not
-
- :return: 0=invisible, 1=visible
- :rtype: boolean
-
- .. method:: isCollider()
-
- Returns whether the polygon is receives collision or not
-
- :return: 0=collision free, 1=receives collision
- :rtype: integer
-
- .. method:: getVertexIndex(vertex)
-
- Returns the mesh vertex index of a polygon vertex
- This index and the one returned by getMaterialIndex() are needed to retrieve the vertex proxy from :class:`MeshProxy`.
-
- :arg vertex: index of the vertex in the polygon: 0->3
- :arg vertex: integer
- :return: mesh vertex index
- :rtype: integer
-
- .. method:: getMesh()
-
- Returns a mesh proxy
-
- :return: mesh proxy
- :rtype: :class:`MeshProxy`
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_RadarSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_RadarSensor.rst
deleted file mode 100644
index 4274c1142f4..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_RadarSensor.rst
+++ /dev/null
@@ -1,44 +0,0 @@
-KX_RadarSensor(KX_NearSensor)
-=============================
-
-.. module:: bge.types
-
-base class --- :class:`KX_NearSensor`
-
-.. class:: KX_RadarSensor(KX_NearSensor)
-
- Radar sensor is a near sensor with a conical sensor object.
-
- .. attribute:: coneOrigin
-
- The origin of the cone with which to test. The origin is in the middle of the cone. (read-only).
-
- :type: list of floats [x, y, z]
-
- .. attribute:: coneTarget
-
- The center of the bottom face of the cone with which to test. (read-only).
-
- :type: list of floats [x, y, z]
-
- .. attribute:: distance
-
- The height of the cone with which to test.
-
- :type: float
-
- .. attribute:: angle
-
- The angle of the cone (in degrees) with which to test.
-
- :type: float
-
- .. attribute:: axis
-
- The axis on which the radar cone is cast.
-
- :type: integer from 0 to 5
-
- KX_RADAR_AXIS_POS_X, KX_RADAR_AXIS_POS_Y, KX_RADAR_AXIS_POS_Z,
- KX_RADAR_AXIS_NEG_X, KX_RADAR_AXIS_NEG_Y, KX_RADAR_AXIS_NEG_Z
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst
deleted file mode 100644
index f182a84409f..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst
+++ /dev/null
@@ -1,78 +0,0 @@
-KX_RaySensor(SCA_ISensor)
-=========================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: KX_RaySensor(SCA_ISensor)
-
- A ray sensor detects the first object in a given direction.
-
- .. attribute:: propName
-
- The property the ray is looking for.
-
- :type: string
-
- .. attribute:: range
-
- The distance of the ray.
-
- :type: float
-
- .. attribute:: useMaterial
-
- Whether or not to look for a material (false = property).
-
- :type: boolean
-
- .. attribute:: useXRay
-
- Whether or not to use XRay.
-
- :type: boolean
-
- .. attribute:: hitObject
-
- The game object that was hit by the ray. (read-only).
-
- :type: :class:`KX_GameObject`
-
- .. attribute:: hitPosition
-
- The position (in worldcoordinates) where the object was hit by the ray. (read-only).
-
- :type: list [x, y, z]
-
- .. attribute:: hitNormal
-
- The normal (in worldcoordinates) of the object at the location where the object was hit by the ray. (read-only).
-
- :type: list [x, y, z]
-
- .. attribute:: hitMaterial
-
- The material of the object in the face hit by the ray. (read-only).
-
- :type: string
-
- .. attribute:: rayDirection
-
- The direction from the ray (in worldcoordinates). (read-only).
-
- :type: list [x, y, z]
-
- .. attribute:: axis
-
- The axis the ray is pointing on.
-
- :type: integer from 0 to 5
-
- * KX_RAY_AXIS_POS_X
- * KX_RAY_AXIS_POS_Y
- * KX_RAY_AXIS_POS_Z
- * KX_RAY_AXIS_NEG_X
- * KX_RAY_AXIS_NEG_Y
- * KX_RAY_AXIS_NEG_Z
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SCA_AddObjectActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SCA_AddObjectActuator.rst
deleted file mode 100644
index fecc863909d..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_SCA_AddObjectActuator.rst
+++ /dev/null
@@ -1,55 +0,0 @@
-KX_SCA_AddObjectActuator(SCA_IActuator)
-=======================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_SCA_AddObjectActuator(SCA_IActuator)
-
- Edit Object Actuator (in Add Object Mode)
-
- .. warning::
-
- An Add Object actuator will be ignored if at game start, the linked object doesn't exist (or is empty) or the linked object is in an active layer.
-
- .. code-block:: none
-
- Error: GameObject 'Name' has a AddObjectActuator 'ActuatorName' without object (in 'nonactive' layer)
-
- .. attribute:: object
-
- the object this actuator adds.
-
- :type: :class:`KX_GameObject` or None
-
- .. attribute:: objectLastCreated
-
- the last added object from this actuator (read-only).
-
- :type: :class:`KX_GameObject` or None
-
- .. attribute:: time
-
- the lifetime of added objects, in frames. Set to 0 to disable automatic deletion.
-
- :type: integer
-
- .. attribute:: linearVelocity
-
- the initial linear velocity of added objects.
-
- :type: list [vx, vy, vz]
-
- .. attribute:: angularVelocity
-
- the initial angular velocity of added objects.
-
- :type: list [vx, vy, vz]
-
- .. method:: instantAddObject()
-
- adds the object without needing to calling SCA_PythonController.activate()
-
- .. note:: Use objectLastCreated to get the newly created object.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SCA_DynamicActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SCA_DynamicActuator.rst
deleted file mode 100644
index 055c4098253..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_SCA_DynamicActuator.rst
+++ /dev/null
@@ -1,29 +0,0 @@
-KX_SCA_DynamicActuator(SCA_IActuator)
-=====================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_SCA_DynamicActuator(SCA_IActuator)
-
- Dynamic Actuator.
-
- .. attribute:: mode
-
- :type: integer
-
- the type of operation of the actuator, 0-4
-
- * KX_DYN_RESTORE_DYNAMICS(0)
- * KX_DYN_DISABLE_DYNAMICS(1)
- * KX_DYN_ENABLE_RIGID_BODY(2)
- * KX_DYN_DISABLE_RIGID_BODY(3)
- * KX_DYN_SET_MASS(4)
-
- .. attribute:: mass
-
- the mass value for the KX_DYN_SET_MASS operation.
-
- :type: float
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SCA_EndObjectActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SCA_EndObjectActuator.rst
deleted file mode 100644
index 8d9221febb0..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_SCA_EndObjectActuator.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-KX_SCA_EndObjectActuator(SCA_IActuator)
-=======================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_SCA_EndObjectActuator(SCA_IActuator)
-
- Edit Object Actuator (in End Object mode)
-
- This actuator has no python methods.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SCA_ReplaceMeshActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SCA_ReplaceMeshActuator.rst
deleted file mode 100644
index 137c63ea829..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_SCA_ReplaceMeshActuator.rst
+++ /dev/null
@@ -1,89 +0,0 @@
-KX_SCA_ReplaceMeshActuator(SCA_IActuator)
-=========================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_SCA_ReplaceMeshActuator(SCA_IActuator)
-
- Edit Object actuator, in Replace Mesh mode.
-
- .. warning::
-
- Replace mesh actuators will be ignored if at game start, the named mesh doesn't exist.
-
- This will generate a warning in the console
-
- .. code-block:: none
-
- Error: GameObject 'Name' ReplaceMeshActuator 'ActuatorName' without object
-
- .. code-block:: python
-
- # Level-of-detail
- # Switch a game object's mesh based on its depth in the camera view.
- # +----------+ +-----------+ +-------------------------------------+
- # | Always +-----+ Python +-----+ Edit Object (Replace Mesh) LOD.Mesh |
- # +----------+ +-----------+ +-------------------------------------+
- from bge import logic
-
- # List detail meshes here
- # Mesh (name, near, far)
- # Meshes overlap so that they don't 'pop' when on the edge of the distance.
- meshes = ((".Hi", 0.0, -20.0),
- (".Med", -15.0, -50.0),
- (".Lo", -40.0, -100.0)
- )
-
- cont = logic.getCurrentController()
- object = cont.owner
- actuator = cont.actuators["LOD." + obj.name]
- camera = logic.getCurrentScene().active_camera
-
- def Depth(pos, plane):
- return pos[0]*plane[0] + pos[1]*plane[1] + pos[2]*plane[2] + plane[3]
-
- # Depth is negative and decreasing further from the camera
- depth = Depth(object.position, camera.world_to_camera[2])
-
- newmesh = None
- curmesh = None
- # Find the lowest detail mesh for depth
- for mesh in meshes:
- if depth < mesh[1] and depth > mesh[2]:
- newmesh = mesh
- if "ME" + object.name + mesh[0] == actuator.getMesh():
- curmesh = mesh
-
- if newmesh != None and "ME" + object.name + newmesh[0] != actuator.mesh:
- # The mesh is a different mesh - switch it.
- # Check the current mesh is not a better fit.
- if curmesh == None or curmesh[1] < depth or curmesh[2] > depth:
- actuator.mesh = object.name + newmesh[0]
- cont.activate(actuator)
-
- .. attribute:: mesh
-
- :class:`MeshProxy` or the name of the mesh that will replace the current one.
-
- Set to None to disable actuator.
-
- :type: :class:`MeshProxy` or None if no mesh is set
-
- .. attribute:: useDisplayMesh
-
- when true the displayed mesh is replaced.
-
- :type: boolean
-
- .. attribute:: usePhysicsMesh
-
- when true the physics mesh is replaced.
-
- :type: boolean
-
- .. method:: instantReplaceMesh()
-
- Immediately replace mesh without delay.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_Scene.rst b/doc/python_api/rst/bge_types/bge.types.KX_Scene.rst
deleted file mode 100644
index 5bd8e3a77de..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_Scene.rst
+++ /dev/null
@@ -1,186 +0,0 @@
-KX_Scene(PyObjectPlus)
-======================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: KX_Scene(PyObjectPlus)
-
- An active scene that gives access to objects, cameras, lights and scene attributes.
-
- The activity culling stuff is supposed to disable logic bricks when their owner gets too far
- from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows
- what it does!
-
- .. code-block:: python
-
- from bge import logic
-
- # get the scene
- scene = logic.getCurrentScene()
-
- # print all the objects in the scene
- for object in scene.objects:
- print(object.name)
-
- # get an object named 'Cube'
- object = scene.objects["Cube"]
-
- # get the first object in the scene.
- object = scene.objects[0]
-
- .. code-block:: python
-
- # Get the depth of an object in the camera view.
- from bge import logic
-
- object = logic.getCurrentController().owner
- cam = logic.getCurrentScene().active_camera
-
- # Depth is negative and decreasing further from the camera
- depth = object.position[0]*cam.world_to_camera[2][0] + object.position[1]*cam.world_to_camera[2][1] + object.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
-
- @bug: All attributes are read only at the moment.
-
- .. attribute:: name
-
- The scene's name, (read-only).
-
- :type: string
-
- .. attribute:: objects
-
- A list of objects in the scene, (read-only).
-
- :type: :class:`CListValue` of :class:`KX_GameObject`
-
- .. attribute:: objectsInactive
-
- A list of objects on background layers (used for the addObject actuator), (read-only).
-
- :type: :class:`CListValue` of :class:`KX_GameObject`
-
- .. attribute:: lights
-
- A list of lights in the scene, (read-only).
-
- :type: :class:`CListValue` of :class:`KX_LightObject`
-
- .. attribute:: cameras
-
- A list of cameras in the scene, (read-only).
-
- :type: :class:`CListValue` of :class:`KX_Camera`
-
- .. attribute:: active_camera
-
- The current active camera.
-
- :type: :class:`KX_Camera`
-
- .. note::
-
- This can be set directly from python to avoid using the :class:`KX_SceneActuator`.
-
- .. attribute:: world
-
- The current active world, (read-only).
-
- :type: :class:`KX_WorldInfo`
-
- .. attribute:: suspended
-
- True if the scene is suspended, (read-only).
-
- :type: boolean
-
- .. attribute:: activity_culling
-
- True if the scene is activity culling.
-
- :type: boolean
-
- .. attribute:: activity_culling_radius
-
- The distance outside which to do activity culling. Measured in manhattan distance.
-
- :type: float
-
- .. attribute:: dbvt_culling
-
- True when Dynamic Bounding box Volume Tree is set (read-only).
-
- :type: boolean
-
- .. attribute:: pre_draw
-
- A list of callables to be run before the render step.
-
- :type: list
-
- .. attribute:: post_draw
-
- A list of callables to be run after the render step.
-
- :type: list
-
- .. attribute:: pre_draw_setup
-
- A list of callables to be run before the drawing setup (i.e., before the model view and projection matrices are computed).
-
- :type: list
-
- .. attribute:: gravity
-
- The scene gravity using the world x, y and z axis.
-
- :type: Vector((gx, gy, gz))
-
- .. method:: addObject(object, reference, time=0)
-
- Adds an object to the scene like the Add Object Actuator would.
-
- :arg object: The (name of the) object to add.
- :type object: :class:`KX_GameObject` or string
- :arg reference: The (name of the) object which position, orientation, and scale to copy (optional), if the object to add is a light and there is not reference the light's layer will be the same that the active layer in the blender scene.
- :type reference: :class:`KX_GameObject` or string
- :arg time: The lifetime of the added object, in frames. A time of 0 means the object will last forever (optional).
- :type time: integer
- :return: The newly added object.
- :rtype: :class:`KX_GameObject`
-
- .. method:: end()
-
- Removes the scene from the game.
-
- .. method:: restart()
-
- Restarts the scene.
-
- .. method:: replace(scene)
-
- Replaces this scene with another one.
-
- :arg scene: The name of the scene to replace this scene with.
- :type scene: string
- :return: True if the scene exists and was scheduled for addition, False otherwise.
- :rtype: boolean
-
- .. method:: suspend()
-
- Suspends this scene.
-
- .. method:: resume()
-
- Resume this scene.
-
- .. method:: get(key, default=None)
-
- Return the value matching key, or the default value if its not found.
- :return: The key value or a default.
-
- .. method:: drawObstacleSimulation()
-
- Draw debug visualization of obstacle simulation.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SceneActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SceneActuator.rst
deleted file mode 100644
index 9d073ff5b19..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_SceneActuator.rst
+++ /dev/null
@@ -1,49 +0,0 @@
-KX_SceneActuator(SCA_IActuator)
-===============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_SceneActuator(SCA_IActuator)
-
- Scene Actuator logic brick.
-
- .. warning::
-
- Scene actuators that use a scene name will be ignored if at game start, the named scene doesn't exist or is empty
-
- This will generate a warning in the console:
-
- .. code-block:: none
-
- Error: GameObject 'Name' has a SceneActuator 'ActuatorName' (SetScene) without scene
-
- .. attribute:: scene
-
- the name of the scene to change to/overlay/underlay/remove/suspend/resume.
-
- :type: string
-
- .. attribute:: camera
-
- the camera to change to.
-
- :type: :class:`KX_Camera` on read, string or :class:`KX_Camera` on write
-
- .. note::
-
- When setting the attribute, you can use either a :class:`KX_Camera` or the name of the camera.
-
- .. attribute:: useRestart
-
- Set flag to True to restart the sene.
-
- :type: boolean
-
- .. attribute:: mode
-
- The mode of the actuator.
-
- :type: integer from 0 to 5.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SoundActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SoundActuator.rst
deleted file mode 100644
index aa85bd663b8..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_SoundActuator.rst
+++ /dev/null
@@ -1,115 +0,0 @@
-KX_SoundActuator(SCA_IActuator)
-===============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_SoundActuator(SCA_IActuator)
-
- Sound Actuator.
-
- The :data:`startSound`, :data:`pauseSound` and :data:`stopSound` do not require the actuator to be activated - they act instantly provided that the actuator has been activated once at least.
-
- .. attribute:: volume
-
- The volume (gain) of the sound.
-
- :type: float
-
- .. attribute:: time
-
- The current position in the audio stream (in seconds).
-
- :type: float
-
- .. attribute:: pitch
-
- The pitch of the sound.
-
- :type: float
-
- .. attribute:: mode
-
- The operation mode of the actuator. Can be one of :ref:`these constants<logic-sound-actuator>`
-
- :type: integer
-
- .. attribute:: sound
-
- The sound the actuator should play.
-
- :type: Audaspace factory
-
- .. attribute:: is3D
-
- Whether or not the actuator should be using 3D sound. (read-only)
-
- :type: boolean
-
- .. attribute:: volume_maximum
-
- The maximum gain of the sound, no matter how near it is.
-
- :type: float
-
- .. attribute:: volume_minimum
-
- The minimum gain of the sound, no matter how far it is away.
-
- :type: float
-
- .. attribute:: distance_reference
-
- The distance where the sound has a gain of 1.0.
-
- :type: float
-
- .. attribute:: distance_maximum
-
- The maximum distance at which you can hear the sound.
-
- :type: float
-
- .. attribute:: attenuation
-
- The influence factor on volume depending on distance.
-
- :type: float
-
- .. attribute:: cone_angle_inner
-
- The angle of the inner cone.
-
- :type: float
-
- .. attribute:: cone_angle_outer
-
- The angle of the outer cone.
-
- :type: float
-
- .. attribute:: cone_volume_outer
-
- The gain outside the outer cone (the gain in the outer cone will be interpolated between this value and the normal gain in the inner cone).
-
- :type: float
-
- .. method:: startSound()
-
- Starts the sound.
-
- :return: None
-
- .. method:: pauseSound()
-
- Pauses the sound.
-
- :return: None
-
- .. method:: stopSound()
-
- Stops the sound.
-
- :return: None
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_StateActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_StateActuator.rst
deleted file mode 100644
index c9d08457cc6..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_StateActuator.rst
+++ /dev/null
@@ -1,29 +0,0 @@
-KX_StateActuator(SCA_IActuator)
-===============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_StateActuator(SCA_IActuator)
-
- State actuator changes the state mask of parent object.
-
- .. attribute:: operation
-
- Type of bit operation to be applied on object state mask.
-
- You can use one of :ref:`these constants <state-actuator-operation>`
-
- :type: integer
-
- .. attribute:: mask
-
- Value that defines the bits that will be modified by the operation.
-
- The bits that are 1 in the mask will be updated in the object state.
-
- The bits that are 0 are will be left unmodified expect for the Copy operation which copies the mask to the object state.
-
- :type: integer
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SteeringActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SteeringActuator.rst
deleted file mode 100644
index f0ce248f069..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_SteeringActuator.rst
+++ /dev/null
@@ -1,71 +0,0 @@
-KX_SteeringActuator(SCA_IActuator)
-==================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_SteeringActuator(SCA_IActuator)
-
- Steering Actuator for navigation.
-
- .. attribute:: behavior
-
- The steering behavior to use.
-
- :type: one of :ref:`these constants <logic-steering-actuator>`
-
- .. attribute:: velocity
-
- Velocity magnitude
-
- :type: float
-
- .. attribute:: acceleration
-
- Max acceleration
-
- :type: float
-
- .. attribute:: turnspeed
-
- Max turn speed
-
- :type: float
-
- .. attribute:: distance
-
- Relax distance
-
- :type: float
-
- .. attribute:: target
-
- Target object
-
- :type: :class:`KX_GameObject`
-
- .. attribute:: navmesh
-
- Navigation mesh
-
- :type: :class:`KX_GameObject`
-
- .. attribute:: selfterminated
-
- Terminate when target is reached
-
- :type: boolean
-
- .. attribute:: enableVisualization
-
- Enable debug visualization
-
- :type: boolean
-
- .. attribute:: pathUpdatePeriod
-
- Path update period
-
- :type: int
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst
deleted file mode 100644
index 876d14bc6c8..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst
+++ /dev/null
@@ -1,47 +0,0 @@
-KX_TouchSensor(SCA_ISensor)
-===========================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: KX_TouchSensor(SCA_ISensor)
-
- Touch sensor detects collisions between objects.
-
- .. attribute:: propName
-
- The property or material to collide with.
-
- :type: string
-
- .. attribute:: useMaterial
-
- Determines if the sensor is looking for a property or material. KX_True = Find material; KX_False = Find property.
-
- :type: boolean
-
- .. attribute:: usePulseCollision
-
- When enabled, changes to the set of colliding objects generate a pulse.
-
- :type: boolean
-
- .. attribute:: hitObject
-
- The last collided object. (read-only).
-
- :type: :class:`KX_GameObject` or None
-
- .. attribute:: hitObjectList
-
- A list of colliding objects. (read-only).
-
- :type: :class:`CListValue` of :class:`KX_GameObject`
-
- .. attribute:: hitMaterial
-
- The material of the object in the face hit by the ray. (read-only).
-
- :type: string
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_TrackToActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_TrackToActuator.rst
deleted file mode 100644
index 5b5c5d0c0db..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_TrackToActuator.rst
+++ /dev/null
@@ -1,61 +0,0 @@
-KX_TrackToActuator(SCA_IActuator)
-=================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_TrackToActuator(SCA_IActuator)
-
- Edit Object actuator in Track To mode.
-
- .. warning::
-
- Track To Actuators will be ignored if at game start, the object to track to is invalid.
-
- This will generate a warning in the console:
-
- .. code-block:: none
-
- GameObject 'Name' no object in EditObjectActuator 'ActuatorName'
-
- .. attribute:: object
-
- the object this actuator tracks.
-
- :type: :class:`KX_GameObject` or None
-
- .. attribute:: time
-
- the time in frames with which to delay the tracking motion.
-
- :type: integer
-
- .. attribute:: use3D
-
- the tracking motion to use 3D.
-
- :type: boolean
-
- .. attribute:: upAxis
-
- The axis that points upward.
-
- :type: integer from 0 to 2
-
- * KX_TRACK_UPAXIS_POS_X
- * KX_TRACK_UPAXIS_POS_Y
- * KX_TRACK_UPAXIS_POS_Z
-
- .. attribute:: trackAxis
-
- The axis that points to the target object.
-
- :type: integer from 0 to 5
-
- * KX_TRACK_TRAXIS_POS_X
- * KX_TRACK_TRAXIS_POS_Y
- * KX_TRACK_TRAXIS_POS_Z
- * KX_TRACK_TRAXIS_NEG_X
- * KX_TRACK_TRAXIS_NEG_Y
- * KX_TRACK_TRAXIS_NEG_Z
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_VehicleWrapper.rst b/doc/python_api/rst/bge_types/bge.types.KX_VehicleWrapper.rst
deleted file mode 100644
index 631075363ca..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_VehicleWrapper.rst
+++ /dev/null
@@ -1,166 +0,0 @@
-KX_VehicleWrapper(PyObjectPlus)
-===============================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: KX_VehicleWrapper(PyObjectPlus)
-
- KX_VehicleWrapper
-
- TODO - description
-
- .. method:: addWheel(wheel, attachPos, downDir, axleDir, suspensionRestLength, wheelRadius, hasSteering)
-
- Add a wheel to the vehicle
-
- :arg wheel: The object to use as a wheel.
- :type wheel: :class:`KX_GameObject` or a :class:`KX_GameObject` name
- :arg attachPos: The position to attach the wheel, relative to the chassis object center.
- :type attachPos: vector of 3 floats
- :arg downDir: The direction vector pointing down to where the vehicle should collide with the floor.
- :type downDir: vector of 3 floats
- :arg axleDir: The axis the wheel rotates around, relative to the chassis.
- :type axleDir: vector of 3 floats
- :arg suspensionRestLength: The length of the suspension when no forces are being applied.
- :type suspensionRestLength: float
- :arg wheelRadius: The radius of the wheel (half the diameter).
- :type wheelRadius: float
- :arg hasSteering: True if the wheel should turn with steering, typically used in front wheels.
- :type hasSteering: boolean
-
-
- .. method:: applyBraking(force, wheelIndex)
-
- Apply a braking force to the specified wheel
-
- :arg force: the brake force
- :type force: float
-
- :arg wheelIndex: index of the wheel where the force needs to be applied
- :type wheelIndex: integer
-
-
- .. method:: applyEngineForce(force, wheelIndex)
-
- Apply an engine force to the specified wheel
-
- :arg force: the engine force
- :type force: float
-
- :arg wheelIndex: index of the wheel where the force needs to be applied
- :type wheelIndex: integer
-
-
- .. method:: getConstraintId()
-
- Get the constraint ID
-
- :return: the constraint id
- :rtype: integer
-
- .. method:: getConstraintType()
-
- Returns the constraint type.
-
- :return: constraint type
- :rtype: integer
-
- .. method:: getNumWheels()
-
- Returns the number of wheels.
-
- :return: the number of wheels for this vehicle
- :rtype: integer
-
- .. method:: getWheelOrientationQuaternion(wheelIndex)
-
- Returns the wheel orientation as a quaternion.
-
- :arg wheelIndex: the wheel index
- :type wheelIndex: integer
-
- :return: TODO Description
- :rtype: TODO - type should be quat as per method name but from the code it looks like a matrix
-
- .. method:: getWheelPosition(wheelIndex)
-
- Returns the position of the specified wheel
-
- :arg wheelIndex: the wheel index
- :type wheelIndex: integer
- :return: position vector
- :rtype: list[x, y, z]
-
- .. method:: getWheelRotation(wheelIndex)
-
- Returns the rotation of the specified wheel
-
- :arg wheelIndex: the wheel index
- :type wheelIndex: integer
-
- :return: the wheel rotation
- :rtype: float
-
- .. method:: setRollInfluence(rollInfluece, wheelIndex)
-
- Set the specified wheel's roll influence.
- The higher the roll influence the more the vehicle will tend to roll over in corners.
-
- :arg rollInfluece: the wheel roll influence
- :type rollInfluece: float
-
- :arg wheelIndex: the wheel index
- :type wheelIndex: integer
-
- .. method:: setSteeringValue(steering, wheelIndex)
-
- Set the specified wheel's steering
-
- :arg steering: the wheel steering
- :type steering: float
-
- :arg wheelIndex: the wheel index
- :type wheelIndex: integer
-
- .. method:: setSuspensionCompression(compression, wheelIndex)
-
- Set the specified wheel's compression
-
- :arg compression: the wheel compression
- :type compression: float
-
- :arg wheelIndex: the wheel index
- :type wheelIndex: integer
-
- .. method:: setSuspensionDamping(damping, wheelIndex)
-
- Set the specified wheel's damping
-
- :arg damping: the wheel damping
- :type damping: float
-
- :arg wheelIndex: the wheel index
- :type wheelIndex: integer
-
- .. method:: setSuspensionStiffness(stiffness, wheelIndex)
-
- Set the specified wheel's stiffness
-
- :arg stiffness: the wheel stiffness
- :type stiffness: float
-
- :arg wheelIndex: the wheel index
- :type wheelIndex: integer
-
- .. method:: setTyreFriction(friction, wheelIndex)
-
- Set the specified wheel's tyre friction
-
- :arg friction: the tyre friction
- :type friction: float
-
- :arg wheelIndex: the wheel index
- :type wheelIndex: integer
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_VertexProxy.rst b/doc/python_api/rst/bge_types/bge.types.KX_VertexProxy.rst
deleted file mode 100644
index 73d692770d6..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_VertexProxy.rst
+++ /dev/null
@@ -1,209 +0,0 @@
-KX_VertexProxy(SCA_IObject)
-===========================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IObject`
-
-.. class:: KX_VertexProxy(SCA_IObject)
-
- A vertex holds position, UV, color and normal information.
-
- Note:
- The physics simulation is NOT currently updated - physics will not respond
- to changes in the vertex position.
-
- .. attribute:: XYZ
-
- The position of the vertex.
-
- :type: Vector((x, y, z))
-
- .. attribute:: UV
-
- The texture coordinates of the vertex.
-
- :type: Vector((u, v))
-
- .. attribute:: normal
-
- The normal of the vertex.
-
- :type: Vector((nx, ny, nz))
-
- .. attribute:: color
-
- The color of the vertex.
-
- :type: Vector((r, g, b, a))
-
- Black = [0.0, 0.0, 0.0, 1.0], White = [1.0, 1.0, 1.0, 1.0]
-
- .. attribute:: x
-
- The x coordinate of the vertex.
-
- :type: float
-
- .. attribute:: y
-
- The y coordinate of the vertex.
-
- :type: float
-
- .. attribute:: z
-
- The z coordinate of the vertex.
-
- :type: float
-
- .. attribute:: u
-
- The u texture coordinate of the vertex.
-
- :type: float
-
- .. attribute:: v
-
- The v texture coordinate of the vertex.
-
- :type: float
-
- .. attribute:: u2
-
- The second u texture coordinate of the vertex.
-
- :type: float
-
- .. attribute:: v2
-
- The second v texture coordinate of the vertex.
-
- :type: float
-
- .. attribute:: r
-
- The red component of the vertex color. 0.0 <= r <= 1.0.
-
- :type: float
-
- .. attribute:: g
-
- The green component of the vertex color. 0.0 <= g <= 1.0.
-
- :type: float
-
- .. attribute:: b
-
- The blue component of the vertex color. 0.0 <= b <= 1.0.
-
- :type: float
-
- .. attribute:: a
-
- The alpha component of the vertex color. 0.0 <= a <= 1.0.
-
- :type: float
-
- .. method:: getXYZ()
-
- Gets the position of this vertex.
-
- :return: this vertexes position in local coordinates.
- :rtype: Vector((x, y, z))
-
- .. method:: setXYZ(pos)
-
- Sets the position of this vertex.
-
- :type: Vector((x, y, z))
-
- :arg pos: the new position for this vertex in local coordinates.
-
- .. method:: getUV()
-
- Gets the UV (texture) coordinates of this vertex.
-
- :return: this vertexes UV (texture) coordinates.
- :rtype: Vector((u, v))
-
- .. method:: setUV(uv)
-
- Sets the UV (texture) coordinates of this vertex.
-
- :type: Vector((u, v))
-
- .. method:: getUV2()
-
- Gets the 2nd UV (texture) coordinates of this vertex.
-
- :return: this vertexes UV (texture) coordinates.
- :rtype: Vector((u, v))
-
- .. method:: setUV2(uv, unit)
-
- Sets the 2nd UV (texture) coordinates of this vertex.
-
- :type: Vector((u, v))
-
- :arg unit: optional argument, FLAT==1, SECOND_UV==2, defaults to SECOND_UV
- :arg unit: integer
-
- .. method:: getRGBA()
-
- Gets the color of this vertex.
-
- The color is represented as four bytes packed into an integer value. The color is
- packed as RGBA.
-
- Since Python offers no way to get each byte without shifting, you must use the struct module to
- access color in an machine independent way.
-
- Because of this, it is suggested you use the r, g, b and a attributes or the color attribute instead.
-
- .. code-block:: python
-
- import struct;
- col = struct.unpack('4B', struct.pack('I', v.getRGBA()))
- # col = (r, g, b, a)
- # black = ( 0, 0, 0, 255)
- # white = (255, 255, 255, 255)
-
- :return: packed color. 4 byte integer with one byte per color channel in RGBA format.
- :rtype: integer
-
- .. method:: setRGBA(col)
-
- Sets the color of this vertex.
-
- See getRGBA() for the format of col, and its relevant problems. Use the r, g, b and a attributes
- or the color attribute instead.
-
- setRGBA() also accepts a four component list as argument col. The list represents the color as [r, g, b, a]
- with black = [0.0, 0.0, 0.0, 1.0] and white = [1.0, 1.0, 1.0, 1.0]
-
- .. code-block:: python
-
- v.setRGBA(0xff0000ff) # Red
- v.setRGBA(0xff00ff00) # Green on little endian, transparent purple on big endian
- v.setRGBA([1.0, 0.0, 0.0, 1.0]) # Red
- v.setRGBA([0.0, 1.0, 0.0, 1.0]) # Green on all platforms.
-
- :arg col: the new color of this vertex in packed RGBA format.
- :type col: integer or list [r, g, b, a]
-
- .. method:: getNormal()
-
- Gets the normal vector of this vertex.
-
- :return: normalized normal vector.
- :rtype: Vector((nx, ny, nz))
-
- .. method:: setNormal(normal)
-
- Sets the normal vector of this vertex.
-
- :type: sequence of floats [r, g, b]
-
- :arg normal: the new normal of this vertex.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_VisibilityActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_VisibilityActuator.rst
deleted file mode 100644
index 4beb6539e0e..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_VisibilityActuator.rst
+++ /dev/null
@@ -1,29 +0,0 @@
-KX_VisibilityActuator(SCA_IActuator)
-====================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: KX_VisibilityActuator(SCA_IActuator)
-
- Visibility Actuator.
-
- .. attribute:: visibility
-
- whether the actuator makes its parent object visible or invisible.
-
- :type: boolean
-
- .. attribute:: useOcclusion
-
- whether the actuator makes its parent object an occluder or not.
-
- :type: boolean
-
- .. attribute:: useRecursion
-
- whether the visibility/occlusion should be propagated to all children of the object.
-
- :type: boolean
-
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst b/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst
deleted file mode 100644
index 1501d85b86c..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst
+++ /dev/null
@@ -1,79 +0,0 @@
-KX_WorldInfo(PyObjectPlus)
-=============================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: KX_WorldInfo(PyObjectPlus)
-
- A world object.
-
- .. code-block:: python
-
- # Set the mist color to red.
- import bge
-
- sce = bge.logic.getCurrentScene()
-
- sce.world.mistColor = [1.0, 0.0, 0.0]
-
- .. data:: KX_MIST_QUADRATIC
-
- Type of quadratic attenuation used to fade mist.
-
- .. data:: KX_MIST_LINEAR
-
- Type of linear attenuation used to fade mist.
-
- .. data:: KX_MIST_INV_QUADRATIC
-
- Type of inverse quadratic attenuation used to fade mist.
-
- .. attribute:: mistEnable
-
- Return the state of the mist.
-
- :type: bool
-
- .. attribute:: mistStart
-
- The mist start point.
-
- :type: float
-
- .. attribute:: mistDistance
-
- The mist distance fom the start point to reach 100% mist.
-
- :type: float
-
- .. attribute:: mistIntensity
-
- The mist intensity.
-
- :type: float
-
- .. attribute:: mistType
-
- The type of mist - must be KX_MIST_QUADRATIC, KX_MIST_LINEAR or KX_MIST_INV_QUADRATIC
-
- .. attribute:: mistColor
-
- The color of the mist. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
- Mist and background color sould always set to the same color.
-
- :type: :class:`mathutils.Color`
-
- .. attribute:: backgroundColor
-
- The color of the background. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
- Mist and background color sould always set to the same color.
-
- :type: :class:`mathutils.Color`
-
- .. attribute:: ambientColor
-
- The color of the ambient light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
-
- :type: :class:`mathutils.Color`
diff --git a/doc/python_api/rst/bge_types/bge.types.PyObjectPlus.rst b/doc/python_api/rst/bge_types/bge.types.PyObjectPlus.rst
deleted file mode 100644
index e035f457a96..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.PyObjectPlus.rst
+++ /dev/null
@@ -1,21 +0,0 @@
-PyObjectPlus
-============
-
-.. module:: bge.types
-
-.. class:: PyObjectPlus
-
- PyObjectPlus base class of most other types in the Game Engine.
-
- .. attribute:: invalid
-
- Test if the object has been freed by the game engine and is no longer valid.
-
- Normally this is not a problem but when storing game engine data in the GameLogic module,
- KX_Scenes or other KX_GameObjects its possible to hold a reference to invalid data.
- Calling an attribute or method on an invalid object will raise a SystemError.
-
- The invalid attribute allows testing for this case without exception handling.
-
- :type: boolean
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_2DFilterActuator.rst b/doc/python_api/rst/bge_types/bge.types.SCA_2DFilterActuator.rst
deleted file mode 100644
index 0a6c5fc9025..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_2DFilterActuator.rst
+++ /dev/null
@@ -1,49 +0,0 @@
-SCA_2DFilterActuator(SCA_IActuator)
-===================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: SCA_2DFilterActuator(SCA_IActuator)
-
- Create, enable and disable 2D filters.
-
- The following properties don't have an immediate effect.
- You must active the actuator to get the result.
- The actuator is not persistent: it automatically stops itself after setting up the filter
- but the filter remains active. To stop a filter you must activate the actuator with 'type'
- set to :data:`~bge.logic.RAS_2DFILTER_DISABLED` or :data:`~bge.logic.RAS_2DFILTER_NOFILTER`.
-
- .. attribute:: shaderText
-
- shader source code for custom shader.
-
- :type: string
-
- .. attribute:: disableMotionBlur
-
- action on motion blur: 0=enable, 1=disable.
-
- :type: integer
-
- .. attribute:: mode
-
- Type of 2D filter, use one of :ref:`these constants <Two-D-FilterActuator-mode>`.
-
- :type: integer
-
- .. attribute:: passNumber
-
- order number of filter in the stack of 2D filters. Filters are executed in increasing order of passNb.
-
- Only be one filter can be defined per passNb.
-
- :type: integer (0-100)
-
- .. attribute:: value
-
- argument for motion blur filter.
-
- :type: float (0.0-100.0)
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ANDController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ANDController.rst
deleted file mode 100644
index 0942f715231..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_ANDController.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-SCA_ANDController(SCA_IController)
-==================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IController`
-
-.. class:: SCA_ANDController(SCA_IController)
-
- An AND controller activates only when all linked sensors are activated.
-
- There are no special python methods for this controller.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ActuatorSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ActuatorSensor.rst
deleted file mode 100644
index 54916389298..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_ActuatorSensor.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-SCA_ActuatorSensor(SCA_ISensor)
-===============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: SCA_ActuatorSensor(SCA_ISensor)
-
- Actuator sensor detect change in actuator state of the parent object.
- It generates a positive pulse if the corresponding actuator is activated
- and a negative pulse if the actuator is deactivated.
-
- .. attribute:: actuator
-
- the name of the actuator that the sensor is monitoring.
-
- :type: string
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_AlwaysSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_AlwaysSensor.rst
deleted file mode 100644
index a217b114d62..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_AlwaysSensor.rst
+++ /dev/null
@@ -1,11 +0,0 @@
-SCA_AlwaysSensor(SCA_ISensor)
-=============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: SCA_AlwaysSensor(SCA_ISensor)
-
- This sensor is always activated.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_DelaySensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_DelaySensor.rst
deleted file mode 100644
index ce2b8e52eec..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_DelaySensor.rst
+++ /dev/null
@@ -1,39 +0,0 @@
-SCA_DelaySensor(SCA_ISensor)
-============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: SCA_DelaySensor(SCA_ISensor)
-
- The Delay sensor generates positive and negative triggers at precise time,
- expressed in number of frames. The delay parameter defines the length of the initial OFF period. A positive trigger is generated at the end of this period.
-
- The duration parameter defines the length of the ON period following the OFF period.
- There is a negative trigger at the end of the ON period. If duration is 0, the sensor stays ON and there is no negative trigger.
-
- The sensor runs the OFF-ON cycle once unless the repeat option is set: the OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0).
-
- Use :class:`SCA_ISensor.reset` at any time to restart sensor.
-
- .. attribute:: delay
-
- length of the initial OFF period as number of frame, 0 for immediate trigger.
-
- :type: integer.
-
- .. attribute:: duration
-
- length of the ON period in number of frame after the initial OFF period.
-
- If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
-
- :type: integer
-
- .. attribute:: repeat
-
- 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
-
- :type: integer
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_IActuator.rst b/doc/python_api/rst/bge_types/bge.types.SCA_IActuator.rst
deleted file mode 100644
index 1432d5166ef..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_IActuator.rst
+++ /dev/null
@@ -1,11 +0,0 @@
-SCA_IActuator(SCA_ILogicBrick)
-==============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ILogicBrick`
-
-.. class:: SCA_IActuator(SCA_ILogicBrick)
-
- Base class for all actuator logic bricks.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_IController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_IController.rst
deleted file mode 100644
index 5eb225ed329..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_IController.rst
+++ /dev/null
@@ -1,55 +0,0 @@
-SCA_IController(SCA_ILogicBrick)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ILogicBrick`
-
-.. class:: SCA_IController(SCA_ILogicBrick)
-
- Base class for all controller logic bricks.
-
- .. attribute:: state
-
- The controllers state bitmask. This can be used with the GameObject's state to test if the controller is active.
-
- :type: int bitmask
-
- .. attribute:: sensors
-
- A list of sensors linked to this controller.
-
- :type: sequence supporting index/string lookups and iteration.
-
- .. note::
-
- The sensors are not necessarily owned by the same object.
-
- .. note::
-
- When objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
-
- .. attribute:: actuators
-
- A list of actuators linked to this controller.
-
- :type: sequence supporting index/string lookups and iteration.
-
- .. note::
-
- The sensors are not necessarily owned by the same object.
-
- .. note::
-
- When objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
-
- .. attribute:: useHighPriority
-
- When set the controller executes always before all other controllers that dont have this set.
-
- :type: boolen
-
- .. note::
-
- Order of execution between high priority controllers is not guaranteed.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ILogicBrick.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ILogicBrick.rst
deleted file mode 100644
index 5ed44c4bb38..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_ILogicBrick.rst
+++ /dev/null
@@ -1,29 +0,0 @@
-SCA_ILogicBrick(CValue)
-=======================
-
-.. module:: bge.types
-
-base class --- :class:`CValue`
-
-.. class:: SCA_ILogicBrick(CValue)
-
- Base class for all logic bricks.
-
- .. attribute:: executePriority
-
- This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
-
- :type: executePriority: int
-
- .. attribute:: owner
-
- The game object this logic brick is attached to (read-only).
-
- :type: :class:`KX_GameObject` or None in exceptional cases.
-
- .. attribute:: name
-
- The name of this logic brick (read-only).
-
- :type: string
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_IObject.rst b/doc/python_api/rst/bge_types/bge.types.SCA_IObject.rst
deleted file mode 100644
index 22065944542..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_IObject.rst
+++ /dev/null
@@ -1,11 +0,0 @@
-SCA_IObject(CValue)
-===================
-
-.. module:: bge.types
-
-base class --- :class:`CValue`
-
-.. class:: SCA_IObject(CValue)
-
- This class has no python functions
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ISensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ISensor.rst
deleted file mode 100644
index af444fb9e65..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_ISensor.rst
+++ /dev/null
@@ -1,101 +0,0 @@
-SCA_ISensor(SCA_ILogicBrick)
-============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ILogicBrick`
-
-.. class:: SCA_ISensor(SCA_ILogicBrick)
-
- Base class for all sensor logic bricks.
-
- .. attribute:: usePosPulseMode
-
- Flag to turn positive pulse mode on and off.
-
- :type: boolean
-
- .. attribute:: useNegPulseMode
-
- Flag to turn negative pulse mode on and off.
-
- :type: boolean
-
- .. attribute:: frequency
-
- The frequency for pulse mode sensors. (Deprecated: use SCA_ISensor.skippedTicks)
-
- :type: integer
-
- .. attribute:: skippedTicks
-
- Number of logic ticks skipped between 2 active pulses
-
- :type: integer
-
- .. attribute:: level
-
- level Option whether to detect level or edge transition when entering a state.
- It makes a difference only in case of logic state transition (state actuator).
- A level detector will immediately generate a pulse, negative or positive
- depending on the sensor condition, as soon as the state is activated.
- A edge detector will wait for a state change before generating a pulse.
- note: mutually exclusive with :data:`tap`, enabling will disable :data:`tap`.
-
- :type: boolean
-
- .. attribute:: tap
-
- When enabled only sensors that are just activated will send a positive event,
- after this they will be detected as negative by the controllers.
- This will make a key thats held act as if its only tapped for an instant.
- note: mutually exclusive with :data:`level`, enabling will disable :data:`level`.
-
- :type: boolean
-
- .. attribute:: invert
-
- Flag to set if this sensor activates on positive or negative events.
-
- :type: boolean
-
- .. attribute:: triggered
-
- True if this sensor brick is in a positive state. (read-only).
-
- :type: boolean
-
- .. attribute:: positive
-
- True if this sensor brick is in a positive state. (read-only).
-
- :type: boolean
-
- .. attribute:: pos_ticks
-
- The number of ticks since the last positive pulse (read-only).
-
- :type: int
-
- .. attribute:: neg_ticks
-
- The number of ticks since the last negative pulse (read-only).
-
- :type: int
-
- .. attribute:: status
-
- The status of the sensor (read-only): can be one of :ref:`these constants<sensor-status>`.
-
- :type: int
-
- .. note::
-
- This convenient attribute combines the values of triggered and positive attributes.
-
- .. method:: reset()
-
- Reset sensor internal state, effect depends on the type of sensor and settings.
-
- The sensor is put in its initial state as if it was just activated.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_JoystickSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_JoystickSensor.rst
deleted file mode 100644
index 5b6628f60be..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_JoystickSensor.rst
+++ /dev/null
@@ -1,133 +0,0 @@
-SCA_JoystickSensor(SCA_ISensor)
-===============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: SCA_JoystickSensor(SCA_ISensor)
-
- This sensor detects player joystick events.
-
- .. attribute:: axisValues
-
- The state of the joysticks axis as a list of values :data:`numAxis` long. (read-only).
-
- :type: list of ints.
-
- Each specifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
- The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
-
- * left:[-32767, 0, ...]
- * right:[32767, 0, ...]
- * up:[0, -32767, ...]
- * down:[0, 32767, ...]
-
- .. attribute:: axisSingle
-
- like :data:`axisValues` but returns a single axis value that is set by the sensor. (read-only).
-
- :type: integer
-
- .. note::
-
- Only use this for "Single Axis" type sensors otherwise it will raise an error.
-
- .. attribute:: hatValues
-
- The state of the joysticks hats as a list of values :data:`numHats` long. (read-only).
-
- :type: list of ints
-
- Each specifying the direction of the hat from 1 to 12, 0 when inactive.
-
- Hat directions are as follows...
-
- * 0:None
- * 1:Up
- * 2:Right
- * 4:Down
- * 8:Left
- * 3:Up - Right
- * 6:Down - Right
- * 12:Down - Left
- * 9:Up - Left
-
- .. attribute:: hatSingle
-
- Like :data:`hatValues` but returns a single hat direction value that is set by the sensor. (read-only).
-
- :type: integer
-
- .. attribute:: numAxis
-
- The number of axes for the joystick at this index. (read-only).
-
- :type: integer
-
- .. attribute:: numButtons
-
- The number of buttons for the joystick at this index. (read-only).
-
- :type: integer
-
- .. attribute:: numHats
-
- The number of hats for the joystick at this index. (read-only).
-
- :type: integer
-
- .. attribute:: connected
-
- True if a joystick is connected at this joysticks index. (read-only).
-
- :type: boolean
-
- .. attribute:: index
-
- The joystick index to use (from 0 to 7). The first joystick is always 0.
-
- :type: integer
-
- .. attribute:: threshold
-
- Axis threshold. Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
-
- :type: integer
-
- .. attribute:: button
-
- The button index the sensor reacts to (first button = 0). When the "All Events" toggle is set, this option has no effect.
-
- :type: integer
-
- .. attribute:: axis
-
- The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection]
-
- * axisIndex: the axis index to use when detecting axis movement, 1=primary directional control, 2=secondary directional control.
- * axisDirection: 0=right, 1=up, 2=left, 3=down.
-
- :type: [integer, integer]
-
- .. attribute:: hat
-
- The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection]
-
- * hatIndex: the hat index to use when detecting hat movement, 1=primary hat, 2=secondary hat (4 max).
- * hatDirection: 1-12.
-
- :type: [integer, integer]
-
- .. method:: getButtonActiveList()
-
- :return: A list containing the indicies of the currently pressed buttons.
- :rtype: list
-
- .. method:: getButtonStatus(buttonIndex)
-
- :arg buttonIndex: the button index, 0=first button
- :type buttonIndex: integer
- :return: The current pressed state of the specified button.
- :rtype: boolean
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_KeyboardSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_KeyboardSensor.rst
deleted file mode 100644
index 91613068ad0..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_KeyboardSensor.rst
+++ /dev/null
@@ -1,64 +0,0 @@
-SCA_KeyboardSensor(SCA_ISensor)
-===============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: SCA_KeyboardSensor(SCA_ISensor)
-
- A keyboard sensor detects player key presses.
-
- See module :mod:`bge.events` for keycode values.
-
- .. attribute:: key
-
- The key code this sensor is looking for.
-
- :type: keycode from :mod:`bge.events` module
-
- .. attribute:: hold1
-
- The key code for the first modifier this sensor is looking for.
-
- :type: keycode from :mod:`bge.events` module
-
- .. attribute:: hold2
-
- The key code for the second modifier this sensor is looking for.
-
- :type: keycode from :mod:`bge.events` module
-
- .. attribute:: toggleProperty
-
- The name of the property that indicates whether or not to log keystrokes as a string.
-
- :type: string
-
- .. attribute:: targetProperty
-
- The name of the property that receives keystrokes in case in case a string is logged.
-
- :type: string
-
- .. attribute:: useAllKeys
-
- Flag to determine whether or not to accept all keys.
-
- :type: boolean
-
- .. attribute:: events
-
- a list of pressed keys that have either been pressed, or just released, or are active this frame. (read-only).
-
- :type: list [[:ref:`keycode<keyboard-keys>`, :ref:`status<input-status>`], ...]
-
- .. method:: getKeyStatus(keycode)
-
- Get the status of a key.
-
- :arg keycode: The code that represents the key you want to get the state of, use one of :ref:`these constants<keyboard-keys>`
- :type keycode: integer
- :return: The state of the given key, can be one of :ref:`these constants<input-status>`
- :rtype: int
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_MouseSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_MouseSensor.rst
deleted file mode 100644
index bbc695e4cbf..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_MouseSensor.rst
+++ /dev/null
@@ -1,39 +0,0 @@
-SCA_MouseSensor(SCA_ISensor)
-============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: SCA_MouseSensor(SCA_ISensor)
-
- Mouse Sensor logic brick.
-
- .. attribute:: position
-
- current [x, y] coordinates of the mouse, in frame coordinates (pixels).
-
- :type: [integer, interger]
-
- .. attribute:: mode
-
- sensor mode.
-
- :type: integer
-
- * KX_MOUSESENSORMODE_LEFTBUTTON(1)
- * KX_MOUSESENSORMODE_MIDDLEBUTTON(2)
- * KX_MOUSESENSORMODE_RIGHTBUTTON(3)
- * KX_MOUSESENSORMODE_WHEELUP(4)
- * KX_MOUSESENSORMODE_WHEELDOWN(5)
- * KX_MOUSESENSORMODE_MOVEMENT(6)
-
- .. method:: getButtonStatus(button)
-
- Get the mouse button status.
-
- :arg button: The code that represents the key you want to get the state of, use one of :ref:`these constants<mouse-keys>`
- :type button: int
- :return: The state of the given key, can be one of :ref:`these constants<input-status>`
- :rtype: int
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_NANDController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_NANDController.rst
deleted file mode 100644
index 4bd67fb22ee..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_NANDController.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-SCA_NANDController(SCA_IController)
-===================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IController`
-
-.. class:: SCA_NANDController(SCA_IController)
-
- An NAND controller activates when all linked sensors are not active.
-
- There are no special python methods for this controller.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_NORController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_NORController.rst
deleted file mode 100644
index 5a567c84ece..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_NORController.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-SCA_NORController(SCA_IController)
-==================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IController`
-
-.. class:: SCA_NORController(SCA_IController)
-
- An NOR controller activates only when all linked sensors are de-activated.
-
- There are no special python methods for this controller.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ORController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ORController.rst
deleted file mode 100644
index ed57b0dbaf2..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_ORController.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-SCA_ORController(SCA_IController)
-=================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IController`
-
-.. class:: SCA_ORController(SCA_IController)
-
- An OR controller activates when any connected sensor activates.
-
- There are no special python methods for this controller.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PropertyActuator.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PropertyActuator.rst
deleted file mode 100644
index 36a4ea7fefe..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_PropertyActuator.rst
+++ /dev/null
@@ -1,29 +0,0 @@
-SCA_PropertyActuator(SCA_IActuator)
-===================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: SCA_PropertyActuator(SCA_IActuator)
-
- Property Actuator
-
- .. attribute:: propName
-
- the property on which to operate.
-
- :type: string
-
- .. attribute:: value
-
- the value with which the actuator operates.
-
- :type: string
-
- .. attribute:: mode
-
- TODO - add constants to game logic dict!.
-
- :type: integer
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PropertySensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PropertySensor.rst
deleted file mode 100644
index 3c41e4679db..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_PropertySensor.rst
+++ /dev/null
@@ -1,41 +0,0 @@
-SCA_PropertySensor(SCA_ISensor)
-===============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: SCA_PropertySensor(SCA_ISensor)
-
- Activates when the game object property matches.
-
- .. attribute:: mode
-
- Type of check on the property. Can be one of :ref:`these constants <logic-property-sensor>`
-
- :type: integer.
-
- .. attribute:: propName
-
- the property the sensor operates.
-
- :type: string
-
- .. attribute:: value
-
- the value with which the sensor compares to the value of the property.
-
- :type: string
-
- .. attribute:: min
-
- the minimum value of the range used to evaluate the property when in interval mode.
-
- :type: string
-
- .. attribute:: max
-
- the maximum value of the range used to evaluate the property when in interval mode.
-
- :type: string
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PythonController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PythonController.rst
deleted file mode 100644
index 7b5619106ed..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_PythonController.rst
+++ /dev/null
@@ -1,54 +0,0 @@
-SCA_PythonController(SCA_IController)
-=====================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IController`
-
-.. class:: SCA_PythonController(SCA_IController)
-
- A Python controller uses a Python script to activate it's actuators,
- based on it's sensors.
-
- .. attribute:: owner
-
- The object the controller is attached to.
-
- :type: :class:`KX_GameObject`
-
- .. attribute:: script
-
- The value of this variable depends on the execution methid.
-
- * When 'Script' execution mode is set this value contains the entire python script as a single string (not the script name as you might expect) which can be modified to run different scripts.
- * When 'Module' execution mode is set this value will contain a single line string - module name and function "module.func" or "package.modile.func" where the module names are python textblocks or external scripts.
-
- :type: string
-
- .. note::
-
- Once this is set the script name given for warnings will remain unchanged.
-
- .. attribute:: mode
-
- the execution mode for this controller (read-only).
-
- * Script: 0, Execite the :data:`script` as a python code.
- * Module: 1, Execite the :data:`script` as a module and function.
-
- :type: integer
-
- .. method:: activate(actuator)
-
- Activates an actuator attached to this controller.
-
- :arg actuator: The actuator to operate on.
- :type actuator: actuator or the actuator name as a string
-
- .. method:: deactivate(actuator)
-
- Deactivates an actuator attached to this controller.
-
- :arg actuator: The actuator to operate on.
- :type actuator: actuator or the actuator name as a string
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PythonJoystick.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PythonJoystick.rst
deleted file mode 100644
index bcec751929d..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_PythonJoystick.rst
+++ /dev/null
@@ -1,77 +0,0 @@
-SCA_PythonJoystick(PyObjectPlus)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: SCA_PythonJoystick(PyObjectPlus)
-
- A Python interface to a joystick.
-
- .. attribute:: name
-
- The name assigned to the joystick by the operating system. (read-only)
-
- :type: string
-
- .. attribute:: activeButtons
-
- A list of active button values. (read-only)
-
- :type: list
-
- .. attribute:: axisValues
-
- The state of the joysticks axis as a list of values :data:`numAxis` long. (read-only).
-
- :type: list of ints.
-
- Each specifying the value of an axis between -1.0 and 1.0
- depending on how far the axis is pushed, 0 for nothing.
- The first 2 values are used by most joysticks and gamepads for directional control.
- 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
-
- * left:[-1.0, 0.0, ...]
- * right:[1.0, 0.0, ...]
- * up:[0.0, -1.0, ...]
- * down:[0.0, 1.0, ...]
-
- .. attribute:: hatValues
-
- The state of the joysticks hats as a list of values :data:`numHats` long. (read-only).
-
- :type: list of ints
-
- Each specifying the direction of the hat from 1 to 12, 0 when inactive.
-
- Hat directions are as follows...
-
- * 0:None
- * 1:Up
- * 2:Right
- * 4:Down
- * 8:Left
- * 3:Up - Right
- * 6:Down - Right
- * 12:Down - Left
- * 9:Up - Left
-
- .. attribute:: numAxis
-
- The number of axes for the joystick at this index. (read-only).
-
- :type: integer
-
- .. attribute:: numButtons
-
- The number of buttons for the joystick at this index. (read-only).
-
- :type: integer
-
- .. attribute:: numHats
-
- The number of hats for the joystick at this index. (read-only).
-
- :type: integer
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PythonKeyboard.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PythonKeyboard.rst
deleted file mode 100644
index 7511f6724d8..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_PythonKeyboard.rst
+++ /dev/null
@@ -1,37 +0,0 @@
-SCA_PythonKeyboard(PyObjectPlus)
-================================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: SCA_PythonKeyboard(PyObjectPlus)
-
- The current keyboard.
-
- .. attribute:: events
-
- A dictionary containing the status of each keyboard event or key. (read-only).
-
- :type: dictionary {:ref:`keycode<keyboard-keys>`::ref:`status<input-status>`, ...}
-
- .. attribute:: active_events
-
- A dictionary containing the status of only the active keyboard events or keys. (read-only).
-
- :type: dictionary {:ref:`keycode<keyboard-keys>`::ref:`status<input-status>`, ...}
-
-
- .. method:: getClipboard()
-
- Gets the clipboard text.
-
- :rtype: string
-
- .. method:: setClipboard(text)
-
- Sets the clipboard text.
-
- :arg text: New clipboard text
- :type text: string
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PythonMouse.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PythonMouse.rst
deleted file mode 100644
index 5dfa78d3942..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_PythonMouse.rst
+++ /dev/null
@@ -1,35 +0,0 @@
-SCA_PythonMouse(PyObjectPlus)
-=============================
-
-.. module:: bge.types
-
-base class --- :class:`PyObjectPlus`
-
-.. class:: SCA_PythonMouse(PyObjectPlus)
-
- The current mouse.
-
- .. attribute:: events
-
- a dictionary containing the status of each mouse event. (read-only).
-
- :type: dictionary {:ref:`keycode<mouse-keys>`::ref:`status<input-status>`, ...}
-
- .. attribute:: active_events
-
- a dictionary containing the status of only the active mouse events. (read-only).
-
- :type: dictionary {:ref:`keycode<mouse-keys>`::ref:`status<input-status>`, ...}
-
- .. attribute:: position
-
- The normalized x and y position of the mouse cursor.
-
- :type: tuple (x, y)
-
- .. attribute:: visible
-
- The visibility of the mouse cursor.
-
- :type: boolean
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_RandomActuator.rst b/doc/python_api/rst/bge_types/bge.types.SCA_RandomActuator.rst
deleted file mode 100644
index 68357229262..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_RandomActuator.rst
+++ /dev/null
@@ -1,127 +0,0 @@
-SCA_RandomActuator(SCA_IActuator)
-=================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IActuator`
-
-.. class:: SCA_RandomActuator(SCA_IActuator)
-
- Random Actuator
-
- .. attribute:: seed
-
- Seed of the random number generator.
-
- :type: integer.
-
- Equal seeds produce equal series. If the seed is 0, the generator will produce the same value on every call.
-
- .. attribute:: para1
-
- the first parameter of the active distribution.
-
- :type: float, read-only.
-
- Refer to the documentation of the generator types for the meaning of this value.
-
- .. attribute:: para2
-
- the second parameter of the active distribution.
-
- :type: float, read-only
-
- Refer to the documentation of the generator types for the meaning of this value.
-
- .. attribute:: distribution
-
- Distribution type. (read-only). Can be one of :ref:`these constants <logic-random-distributions>`
-
- :type: integer
-
- .. attribute:: propName
-
- the name of the property to set with the random value.
-
- :type: string
-
- If the generator and property types do not match, the assignment is ignored.
-
- .. method:: setBoolConst(value)
-
- Sets this generator to produce a constant boolean value.
-
- :arg value: The value to return.
- :type value: boolean
-
- .. method:: setBoolUniform()
-
- Sets this generator to produce a uniform boolean distribution.
-
- The generator will generate True or False with 50% chance.
-
- .. method:: setBoolBernouilli(value)
-
- Sets this generator to produce a Bernouilli distribution.
-
- :arg value: Specifies the proportion of False values to produce.
-
- * 0.0: Always generate True
- * 1.0: Always generate False
- :type value: float
-
- .. method:: setIntConst(value)
-
- Sets this generator to always produce the given value.
-
- :arg value: the value this generator produces.
- :type value: integer
-
- .. method:: setIntUniform(lower_bound, upper_bound)
-
- Sets this generator to produce a random value between the given lower and
- upper bounds (inclusive).
-
- :type lower_bound: integer
- :type upper_bound: integer
-
- .. method:: setIntPoisson(value)
-
- Generate a Poisson-distributed number.
-
- This performs a series of Bernouilli tests with parameter value.
- It returns the number of tries needed to achieve succes.
-
- :type value: float
-
- .. method:: setFloatConst(value)
-
- Always generate the given value.
-
- :type value: float
-
- .. method:: setFloatUniform(lower_bound, upper_bound)
-
- Generates a random float between lower_bound and upper_bound with a
- uniform distribution.
-
- :type lower_bound: float
- :type upper_bound: float
-
- .. method:: setFloatNormal(mean, standard_deviation)
-
- Generates a random float from the given normal distribution.
-
- :arg mean: The mean (average) value of the generated numbers
- :type mean: float
- :arg standard_deviation: The standard deviation of the generated numbers.
- :type standard_deviation: float
-
- .. method:: setFloatNegativeExponential(half_life)
-
- Generate negative-exponentially distributed numbers.
-
- The half-life 'time' is characterized by half_life.
-
- :type half_life: float
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_RandomSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_RandomSensor.rst
deleted file mode 100644
index 05e61ccf118..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_RandomSensor.rst
+++ /dev/null
@@ -1,23 +0,0 @@
-SCA_RandomSensor(SCA_ISensor)
-=============================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_ISensor`
-
-.. class:: SCA_RandomSensor(SCA_ISensor)
-
- This sensor activates randomly.
-
- .. attribute:: lastDraw
-
- The seed of the random number generator.
-
- :type: integer
-
- .. attribute:: seed
-
- The seed of the random number generator.
-
- :type: integer
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_XNORController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_XNORController.rst
deleted file mode 100644
index d0235f29a20..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_XNORController.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-SCA_XNORController(SCA_IController)
-===================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IController`
-
-.. class:: SCA_XNORController(SCA_IController)
-
- An XNOR controller activates when all linked sensors are the same (activated or inative).
-
- There are no special python methods for this controller.
-
diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_XORController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_XORController.rst
deleted file mode 100644
index 98ccf142f63..00000000000
--- a/doc/python_api/rst/bge_types/bge.types.SCA_XORController.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-SCA_XORController(SCA_IController)
-==================================
-
-.. module:: bge.types
-
-base class --- :class:`SCA_IController`
-
-.. class:: SCA_XORController(SCA_IController)
-
- An XOR controller activates when there is the input is mixed, but not when all are on or off.
-
- There are no special python methods for this controller.
-
diff --git a/doc/python_api/rst/change_log.rst b/doc/python_api/rst/change_log.rst
index 21c7cf96135..905294d0f88 100644
--- a/doc/python_api/rst/change_log.rst
+++ b/doc/python_api/rst/change_log.rst
@@ -54,19 +54,6 @@ Removed
* **network_render**
-bpy.types.GameObjectSettings
-----------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.GameObjectSettings.use_material_physics_fh`
-
-Removed
-^^^^^^^
-
-* **use_material_physics**
-
bpy.types.SplinePoints
----------------------
@@ -219,15 +206,6 @@ Renamed
* **viscosity_omega** -> :class:`bpy.types.SPHFluidSettings.linear_viscosity`
-bpy.types.ConstraintActuator
-----------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.ConstraintActuator.direction_axis_pos`
-* :class:`bpy.types.ConstraintActuator.fh_force`
-
Removed
^^^^^^^
@@ -679,14 +657,6 @@ Removed
* **use_branching**
* **use_symmetric_branching**
-bpy.types.SceneGameData
------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameData.show_mouse`
-
bpy.types.MaterialPhysics
-------------------------
@@ -863,14 +833,6 @@ Added
* :class:`bpy.types.SpaceTextEditor.use_match_case`
-bpy.types.CameraActuator
-------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.CameraActuator.damping`
-
bpy.types.Property
------------------
@@ -903,15 +865,6 @@ Added
* :class:`bpy.types.Image.resolution`
-bpy.types.SceneGameData
------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameData.use_glsl_color_management`
-
-
2.58 to 2.59
============
@@ -1070,20 +1023,6 @@ Removed
* **use_object_color**
* **use_blend_shared**
-Moved
-^^^^^
-
-* **hide** -> :class:`bpy.types.Material.game_settings.invisible`
-* **use_collision** -> :class:`bpy.types.Material.game_settings.physics`
-* **use_light** -> :class:`bpy.types.Material.game_settings.use_shadeless`
-* **use_twoside** -> :class:`bpy.types.Material.game_settings.backface_culling`
-* **use_bitmap_text** -> :class:`bpy.types.Material.game_settings.text`
-* **blend_type** -> :class:`bpy.types.Material.game_settings.alpha_blend`
-* **use_alpha_sort** -> :class:`bpy.types.Material.game_settings.alpha_blend`
-* **use_billboard** -> :class:`bpy.types.Material.game_settings.face_orientation`
-* **use_halo** -> :class:`bpy.types.Material.game_settings.face_orientation`
-* **use_shadow_cast** -> :class:`bpy.types.Material.game_settings.face_orientation`
-
.. Automatically Generated, 2.59 -> r40804!
bpy.types.RenderSettings
@@ -1148,15 +1087,6 @@ Added
* :class:`bpy.types.Armature.deform_method`
-bpy.types.GameObjectSettings
-----------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.GameObjectSettings.obstacle_radius`
-* :class:`bpy.types.GameObjectSettings.use_obstacle_create`
-
bpy.types.BlendData
-------------------
@@ -1360,14 +1290,6 @@ Added
* :class:`bpy.types.MovieSequence.stream_index`
-bpy.types.Material
-------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.Material.game_settings`
-
bpy.types.Object
----------------
@@ -1409,19 +1331,6 @@ Added
* :class:`bpy.types.DopeSheet.show_datablock_filters`
* :class:`bpy.types.DopeSheet.show_speakers`
-bpy.types.ActionActuator
-------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.ActionActuator.apply_to_children`
-* :class:`bpy.types.ActionActuator.layer`
-* :class:`bpy.types.ActionActuator.layer_weight`
-* :class:`bpy.types.ActionActuator.use_additive`
-* :class:`bpy.types.ActionActuator.use_force`
-* :class:`bpy.types.ActionActuator.use_local`
-
bpy.types.VertexGroup
---------------------
@@ -1470,19 +1379,6 @@ Added
* :class:`bpy.types.ParticleSettings.adaptive_subframes`
* :class:`bpy.types.ParticleSettings.courant_target`
-bpy.types.SceneGameData
------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameData.level_height`
-* :class:`bpy.types.SceneGameData.obstacle_simulation`
-* :class:`bpy.types.SceneGameData.recast_data`
-* :class:`bpy.types.SceneGameData.restrict_animation_updates`
-* :class:`bpy.types.SceneGameData.show_obstacle_simulation`
-
-
2.60 to 2.61
============
@@ -2156,24 +2052,6 @@ Added
* :class:`bpy.types.DomainFluidSettings.frame_offset`
* :class:`bpy.types.DomainFluidSettings.simulation_rate`
-bpy.types.SceneGameData
------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameData.exit_key`
-* :class:`bpy.types.SceneGameData.samples`
-* :class:`bpy.types.SceneGameData.use_desktop`
-
-bpy.types.Sensor
-----------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.Sensor.controllers`
-
bpy.types.Scene
---------------
@@ -2182,14 +2060,6 @@ Removed
* **collada_export**
-bpy.types.Controller
---------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.Controller.actuators`
-
bpy.types.SceneRenderLayer
--------------------------
@@ -2498,14 +2368,6 @@ Added
* :class:`bpy.types.ParticleSettings.use_rotations`
-bpy.types.SceneGameData
------------------------
-
-Renamed
-^^^^^^^
-
-* **dome_tesselation** -> :class:`bpy.types.SceneGameData.dome_tessellation`
-
bpy.types.RegionView3D
----------------------
@@ -2635,14 +2497,6 @@ Renamed
* **location** -> :class:`bpy.types.TexMapping.translation`
-bpy.types.ArmatureActuator
---------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.ArmatureActuator.influence`
-
bpy.types.ThemeTextEditor
-------------------------
@@ -2780,17 +2634,6 @@ Added
* :class:`bpy.types.ThemeView3D.bone_pose_active`
* :class:`bpy.types.ThemeView3D.skin_root`
-bpy.types.GameObjectSettings
-----------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.GameObjectSettings.fall_speed`
-* :class:`bpy.types.GameObjectSettings.jump_speed`
-* :class:`bpy.types.GameObjectSettings.step_height`
-
-
bpy.types.BlendData
-------------------
@@ -3065,16 +2908,6 @@ Added
* :class:`bpy.types.ParticleSettings.use_scale_dupli`
-bpy.types.SceneGameData
------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameData.deactivation_angular_threshold`
-* :class:`bpy.types.SceneGameData.deactivation_linear_threshold`
-* :class:`bpy.types.SceneGameData.deactivation_time`
-
bpy.types.SoundSequence
-----------------------
@@ -3519,14 +3352,6 @@ Added
* :class:`bpy.types.GlowSequence.input_1`
* :class:`bpy.types.GlowSequence.input_count`
-bpy.types.MouseSensor
----------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.MouseSensor.use_pulse`
-
bpy.types.MovieSequence
-----------------------
@@ -4116,15 +3941,6 @@ Removed
* **use_outflow**
-bpy.types.GameObjectSettings
-----------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.GameObjectSettings.collision_group`
-* :class:`bpy.types.GameObjectSettings.collision_mask`
-
bpy.types.SpaceView3D
---------------------
@@ -4660,15 +4476,6 @@ Function Arguments
* :class:`bpy.types.Object.to_mesh` (scene, apply_modifiers, settings, calc_tessface), *was (scene, apply_modifiers, settings)*
-bpy.types.SceneGameData
------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameData.raster_storage`
-* :class:`bpy.types.SceneGameData.use_material_caching`
-
bpy.types.CyclesRenderSettings
------------------------------
@@ -4760,15 +4567,6 @@ Added
* :class:`bpy.types.CompositorNodeTree.use_groupnode_buffer`
-bpy.types.ObjectActuator
-------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.ObjectActuator.use_add_character_location`
-* :class:`bpy.types.ObjectActuator.use_character_jump`
-
bpy.types.Bone
--------------
@@ -5102,14 +4900,6 @@ Added
* :class:`bpy.types.LoopColors.remove`
-bpy.types.SceneGameData
------------------------
-
-Renamed
-^^^^^^^
-
-* **restrict_animation_updates** -> :class:`bpy.types.SceneGameData.use_restrict_animation_updates`
-
bpy.types.NodeSocket
--------------------
@@ -5943,14 +5733,6 @@ Added
2.68 to 2.69
============
-bpy.types.ActionActuator
-------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.ActionActuator.blend_mode`
-
bpy.types.ColorManagedViewSettings
----------------------------------
@@ -6180,14 +5962,6 @@ Added
* :class:`bpy.types.RenderLayer.use_pass_subsurface_direct`
* :class:`bpy.types.RenderLayer.use_pass_subsurface_indirect`
-bpy.types.SceneGameData
------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameData.vsync`
-
bpy.types.SceneRenderLayer
--------------------------
@@ -6344,14 +6118,6 @@ Removed
* **raycasting_algorithm**
-bpy.types.GameObjectSettings
-----------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.GameObjectSettings.use_record_animation`
-
bpy.types.Armature
------------------
@@ -6963,14 +6729,6 @@ Removed
2.70 to 2.71
============
-bpy.types.Actuator
-------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.Actuator.active`
-
bpy.types.BlendDataLineStyles
-----------------------------
@@ -7010,14 +6768,6 @@ Added
* :class:`bpy.types.TransformConstraint.to_min_z_rot`
* :class:`bpy.types.TransformConstraint.to_min_z_scale`
-bpy.types.Controller
---------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.Controller.active`
-
bpy.types.FCurve
----------------
@@ -7225,14 +6975,6 @@ Added
* :class:`bpy.types.RenderSettings.bake`
-bpy.types.Sensor
-----------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.Sensor.active`
-
bpy.types.SequenceElements
--------------------------
@@ -7343,15 +7085,6 @@ Function Arguments
2.71 to 2.72
============
-bpy.types.EditObjectActuator
-----------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.EditObjectActuator.track_axis`
-* :class:`bpy.types.EditObjectActuator.up_axis`
-
bpy.types.BlendData
-------------------
@@ -7643,17 +7376,6 @@ Added
* :class:`bpy.types.RenderSettings.preview_start_resolution`
* :class:`bpy.types.RenderSettings.use_render_cache`
-bpy.types.MouseSensor
----------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.MouseSensor.material`
-* :class:`bpy.types.MouseSensor.property`
-* :class:`bpy.types.MouseSensor.use_material`
-* :class:`bpy.types.MouseSensor.use_x_ray`
-
bpy.types.SpaceUVEditor
-----------------------
@@ -8009,14 +7731,6 @@ Added
2.73 to 2.74
============
-bpy.types.SteeringActuator
---------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SteeringActuator.lock_z_velocity`
-
bpy.types.BackgroundImage
-------------------------
@@ -8847,28 +8561,6 @@ Function Arguments
* :class:`bpy.types.RenderSettings.frame_path` (frame, preview, view), *was (frame)*
-bpy.types.SceneGameData
------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameData.scene_hysteresis_percentage`
-* :class:`bpy.types.SceneGameData.use_scene_hysteresis`
-
-bpy.types.Sensor
-----------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.Sensor.tick_skip`
-
-Removed
-^^^^^^^
-
-* **frequency**
-
bpy.types.EffectSequence
------------------------
@@ -9077,15 +8769,6 @@ Added
* :class:`bpy.types.FileSelectParams.use_filter_blendid`
* :class:`bpy.types.FileSelectParams.use_library_browsing`
-bpy.types.GameObjectSettings
-----------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.GameObjectSettings.angular_velocity_max`
-* :class:`bpy.types.GameObjectSettings.angular_velocity_min`
-
bpy.types.ID
------------
@@ -9354,14 +9037,6 @@ Removed
* **thumbnail_size**
-bpy.types.GameObjectSettings
-----------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.GameObjectSettings.jump_max`
-
bpy.types.ID
------------
@@ -10523,22 +10198,6 @@ Added
* :class:`bpy.types.RenderSettings.use_stamp_memory`
* :class:`bpy.types.RenderSettings.use_world_space_shading`
-bpy.types.SceneGameData
------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameData.use_glsl_environment_lighting`
-
-bpy.types.SceneGameRecastData
------------------------------
-
-Added
-^^^^^
-
-* :class:`bpy.types.SceneGameRecastData.partitioning`
-
bpy.types.TextSequence
----------------------
diff --git a/doc/python_api/rst/gpu.rst b/doc/python_api/rst/gpu.rst
index cf639357a31..d4860da4770 100644
--- a/doc/python_api/rst/gpu.rst
+++ b/doc/python_api/rst/gpu.rst
@@ -4,7 +4,7 @@ GPU functions (gpu)
.. module:: gpu
-This module provides access to materials GLSL shaders.
+Functions for GPU offscreen rendering, matrix stacks and selection.
Submodules:
@@ -17,684 +17,4 @@ Submodules:
Intro
=====
-Module to provide functions concerning the GPU implementation in Blender, in particular
-the GLSL shaders that blender generates automatically to render materials in the 3D view
-and in the game engine.
-
-.. warning::
-
- The API provided by this module is subject to change.
- The data exposed by the API are are closely related to Blender's internal GLSL code
- and may change if the GLSL code is modified (e.g. new uniform type).
-
-
-Constants
-=========
-
-GLSL Data Type
---------------
-
-.. _data-type:
-
-Type of GLSL data.
-For shader uniforms, the data type determines which ``glUniform`` function
-variant to use to send the uniform value to the GPU.
-For vertex attributes, the data type determines which ``glVertexAttrib`` function
-variant to use to send the vertex attribute to the GPU.
-
-See export_shader_
-
-.. data:: GPU_DATA_1I
-
- one integer
-
-.. data:: GPU_DATA_1F
-
- one float
-
-.. data:: GPU_DATA_2F
-
- two floats
-
-.. data:: GPU_DATA_3F
-
- three floats
-
-.. data:: GPU_DATA_4F
-
- four floats
-
-.. data:: GPU_DATA_9F
-
- matrix 3x3 in column-major order
-
-.. data:: GPU_DATA_16F
-
- matrix 4x4 in column-major order
-
-.. data:: GPU_DATA_4UB
-
- four unsigned byte
-
-
-GLSL Uniform Types
-------------------
-
-.. _uniform-type:
-
-Constants that specify the type of uniform used in a GLSL shader.
-The uniform type determines the data type, origin and method
-of calculation used by Blender to compute the uniform value.
-
-The calculation of some of the uniforms is based on matrices available in the scene:
-
- .. _mat4_cam_to_world:
- .. _mat4_world_to_cam:
-
- ``mat4_cam_to_world``
- Model matrix of the camera. OpenGL 4x4 matrix that converts
- camera local coordinates to world coordinates. In blender this is obtained from the
- 'matrix_world' attribute of the camera object.
-
- Some uniform will need the *mat4_world_to_cam*
- matrix computed as the inverse of this matrix.
-
- .. _mat4_object_to_world:
- .. _mat4_world_to_object:
-
- ``mat4_object_to_world``
- Model matrix of the object that is being rendered. OpenGL 4x4 matric that converts
- object local coordinates to world coordinates. In blender this is obtained from the
- 'matrix_world' attribute of the object.
-
- Some uniform will need the *mat4_world_to_object* matrix, computed as the inverse of this matrix.
-
- .. _mat4_lamp_to_world:
- .. _mat4_world_to_lamp:
-
- ``mat4_lamp_to_world``
- Model matrix of the lamp lighting the object. OpenGL 4x4 matrix that converts lamp
- local coordinates to world coordinates. In blender this is obtained from the
- 'matrix_world' attribute of the lamp object.
-
- Some uniform will need the *mat4_world_to_lamp* matrix
- computed as the inverse of this matrix.
-
-
-.. note::
-
- Any uniforms used for view projections or transformations (object, lamp matrices for eg),
- can only be set once per frame.
-
-
-GLSL Object Uniforms
-^^^^^^^^^^^^^^^^^^^^
-
-.. note::
-
- - Object transformations and color must be set before drawing the object.
- - There is at most one uniform of these types per shader.
-
-.. data:: GPU_DYNAMIC_OBJECT_VIEWMAT
-
- A matrix that converts world coordinates to camera coordinates (see mat4_world_to_cam_).
-
- :type: matrix4x4
-
-.. data:: GPU_DYNAMIC_OBJECT_MAT
-
- A matrix that converts object coordinates to world coordinates (see mat4_object_to_world_).
-
- :type: matrix4x4
-
-.. data:: GPU_DYNAMIC_OBJECT_VIEWIMAT
-
- The uniform is a 4x4 GL matrix that converts coordinates
- in camera space to world coordinates (see mat4_cam_to_world_).
-
- :type: matrix4x4
-
-.. data:: GPU_DYNAMIC_OBJECT_IMAT
-
- The uniform is a 4x4 GL matrix that converts world coodinates
- to object coordinates (see mat4_world_to_object_).
-
- :type: matrix4x4
-
-.. data:: GPU_DYNAMIC_OBJECT_COLOR
-
- An RGB color + alpha defined at object level.
- Each values between 0.0 and 1.0.
-
- See :class:`bpy.types.Object.color`.
-
- :type: float4
-
-.. data:: GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE
-
- Multiplier for bump-map scaling.
-
- :type: float
-
-
-GLSL Lamp Uniforms
-^^^^^^^^^^^^^^^^^^
-
-.. note::
-
- There is one uniform of that type per lamp lighting the material.
-
-.. data:: GPU_DYNAMIC_LAMP_DYNVEC
-
- Represents the direction of light in camera space.
-
- Computed as:
- mat4_world_to_cam_ * (-vec3_lamp_Z_axis)
-
- .. note::
-
- - The lamp Z axis points to the opposite direction of light.
- - The norm of the vector should be unit length.
-
- :type: float3
-
-.. data:: GPU_DYNAMIC_LAMP_DYNCO
-
- Represents the position of the light in camera space.
-
- Computed as:
- mat4_world_to_cam_ * vec3_lamp_pos
-
- :type: float3
-
-.. data:: GPU_DYNAMIC_LAMP_DYNIMAT
-
- Matrix that converts vector in camera space to lamp space.
-
- Computed as:
- mat4_world_to_lamp_ * mat4_cam_to_world_
-
- :type: matrix4x4
-
-.. data:: GPU_DYNAMIC_LAMP_DYNPERSMAT
-
- Matrix that converts a vector in camera space to shadow buffer depth space.
-
- Computed as:
- mat4_perspective_to_depth_ * mat4_lamp_to_perspective_ * mat4_world_to_lamp_ * mat4_cam_to_world_.
-
- .. _mat4_perspective_to_depth:
-
- ``mat4_perspective_to_depth`` is a fixed matrix defined as follow::
-
- 0.5 0.0 0.0 0.5
- 0.0 0.5 0.0 0.5
- 0.0 0.0 0.5 0.5
- 0.0 0.0 0.0 1.0
-
- .. note::
-
- - There is one uniform of that type per lamp casting shadow in the scene.
-
- :type: matrix4x4
-
-.. data:: GPU_DYNAMIC_LAMP_DYNENERGY
-
- See :class:`bpy.types.Lamp.energy`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_LAMP_DYNCOL
-
- See :class:`bpy.types.Lamp.color`.
-
- :type: float3
-
-.. data:: GPU_DYNAMIC_LAMP_DISTANCE
-
- See :class:`bpy.types.Lamp.distance`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_LAMP_ATT1
-
- See
- :class:`bpy.types.PointLamp.linear_attenuation`,
- :class:`bpy.types.SpotLamp.linear_attenuation`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_LAMP_ATT2
-
- See
- :class:`bpy.types.PointLamp.quadratic_attenuation`,
- :class:`bpy.types.SpotLamp.quadratic_attenuation`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_LAMP_SPOTSIZE
-
- See :class:`bpy.types.SpotLamp.spot_size`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_LAMP_SPOTBLEND
-
- See :class:`bpy.types.SpotLamp.spot_blend`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_LAMP_SPOTSCALE
-
- Represents the SpotLamp local scale.
-
- :type: float2
-
-
-GLSL Sampler Uniforms
-^^^^^^^^^^^^^^^^^^^^^
-
-.. data:: GPU_DYNAMIC_SAMPLER_2DBUFFER
-
- Represents an internal texture used for certain effect
- (color band, etc).
-
- :type: integer
-
-.. data:: GPU_DYNAMIC_SAMPLER_2DIMAGE
-
- Represents a texture loaded from an image file.
-
- :type: integer
-
-.. data:: GPU_DYNAMIC_SAMPLER_2DSHADOW
-
- Represents a texture loaded from a shadow buffer file.
-
- :type: integer
-
-
-GLSL Mist Uniforms
-^^^^^^^^^^^^^^^^^^
-
-.. data:: GPU_DYNAMIC_MIST_ENABLE:
-
- See :class:`bpy.types.WorldMistSettings.use_mist`.
-
- :type: float (0 or 1)
-
-.. data:: GPU_DYNAMIC_MIST_START
-
- See :class:`bpy.types.WorldMistSettings.start`.
-
- :type: float
-
- See :class:`bpy.types.WorldMistSettings.depth`.
-
-.. data:: GPU_DYNAMIC_MIST_DISTANCE
-
- :type: float
-
- See :class:`bpy.types.WorldMistSettings.intensity`.
-
-.. data:: GPU_DYNAMIC_MIST_INTENSITY
-
- :type: float
-
-.. data:: GPU_DYNAMIC_MIST_TYPE
-
- See :class:`bpy.types.WorldMistSettings.falloff`.
-
- :type: float (used as an index into the type)
-
-.. data:: GPU_DYNAMIC_MIST_COLOR
-
-
-GLSL World Uniforms
-^^^^^^^^^^^^^^^^^^^
-
-.. data:: GPU_DYNAMIC_HORIZON_COLOR
-
- See :class:`bpy.types.World.horizon_color`.
-
- :type: float3
-
-.. data:: GPU_DYNAMIC_AMBIENT_COLOR
-
- See :class:`bpy.types.World.ambient_color`.
-
- :type: float3
-
-
-GLSL Material Uniforms
-^^^^^^^^^^^^^^^^^^^^^^
-
-.. data:: GPU_DYNAMIC_MAT_DIFFRGB
-
- See :class:`bpy.types.Material.diffuse_color`.
-
- :type: float3
-
-.. data:: GPU_DYNAMIC_MAT_REF
-
- See :class:`bpy.types.Material.diffuse_intensity`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_MAT_SPECRGB
-
- See :class:`bpy.types.Material.specular_color`.
-
- :type: float3
-
-.. data:: GPU_DYNAMIC_MAT_SPEC
-
- See :class:`bpy.types.Material.specular_intensity`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_MAT_HARD
-
- See :class:`bpy.types.Material.specular_hardness`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_MAT_EMIT
-
- See :class:`bpy.types.Material.emit`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_MAT_AMB
-
- See :class:`bpy.types.Material.ambient`.
-
- :type: float
-
-.. data:: GPU_DYNAMIC_MAT_ALPHA
-
- See :class:`bpy.types.Material.alpha`.
-
- :type: float
-
-
-
-GLSL Attribute Type
--------------------
-
-.. _attribute-type:
-
-Type of the vertex attribute used in the GLSL shader. Determines the mesh custom data
-layer that contains the vertex attribute.
-
-.. data:: CD_MTFACE
-
- Vertex attribute is a UV Map. Data type is vector of 2 float.
-
- There can be more than one attribute of that type, they are differenciated by name.
- In blender, you can retrieve the attribute data with:
-
- .. code-block:: python
-
- mesh.uv_layers[attribute["name"]]
-
-.. data:: CD_MCOL
-
- Vertex attribute is color layer. Data type is vector 4 unsigned byte (RGBA).
-
- There can be more than one attribute of that type, they are differenciated by name.
- In blender you can retrieve the attribute data with:
-
- .. code-block:: python
-
- mesh.vertex_colors[attribute["name"]]
-
-.. data:: CD_ORCO
-
- Vertex attribute is original coordinates. Data type is vector 3 float.
-
- There can be only 1 attribute of that type per shader.
- In blender you can retrieve the attribute data with:
-
- .. code-block:: python
-
- mesh.vertices
-
-.. data:: CD_TANGENT
-
- Vertex attribute is the tangent vector. Data type is vector 4 float.
-
- There can be only 1 attribute of that type per shader.
- There is currently no way to retrieve this attribute data via the RNA API but a standalone
- C function to compute the tangent layer from the other layers can be obtained from
- blender.org.
-
-
-Functions
-=========
-
-.. _export_shader:
-
-.. function:: export_shader(scene,material)
-
- Extracts the GLSL shader producing the visual effect of material in scene for the purpose of
- reusing the shader in an external engine.
-
- This function is meant to be used in material exporter
- so that the GLSL shader can be exported entirely.
-
- The return value is a dictionary containing the
- shader source code and all associated data.
-
- :arg scene: the scene in which the material in rendered.
- :type scene: :class:`bpy.types.Scene`
- :arg material: the material that you want to export the GLSL shader
- :type material: :class:`bpy.types.Material`
- :return: the shader source code and all associated data in a dictionary
- :rtype: dictionary
-
- The dictionary contains the following elements:
-
- - ``["fragment"]``: string
- fragment shader source code.
-
- - ``["vertex"]``: string
- vertex shader source code.
-
- - ``["uniforms"]``: sequence
- list of uniforms used in fragment shader, can be empty list. Each element of the
- sequence is a dictionary with the following elements:
-
- - ``["varname"]``: string
- name of the uniform in the fragment shader. Always of the form 'unf<number>'.
-
- - ``["datatype"]``: integer
- data type of the uniform variable. Can be one of the following:
-
- .. hlist::
- :columns: 2
-
- - :data:`gpu.GPU_DATA_1I` : use ``glUniform1i``
- - :data:`gpu.GPU_DATA_1F` : use ``glUniform1fv``
- - :data:`gpu.GPU_DATA_2F` : use ``glUniform2fv``
- - :data:`gpu.GPU_DATA_3F` : use ``glUniform3fv``
- - :data:`gpu.GPU_DATA_4F` : use ``glUniform4fv``
- - :data:`gpu.GPU_DATA_9F` : use ``glUniformMatrix3fv``
- - :data:`gpu.GPU_DATA_16F` : use ``glUniformMatrix4fv``
-
- - ``["type"]``: integer
- type of uniform, determines the origin and method of calculation. See uniform-type_.
- Depending on the type, more elements will be be present.
-
- - ``["lamp"]``: :class:`bpy.types.Object`
- Reference to the lamp object from which the uniforms value are extracted.
- Set for the following uniforms types:
-
- .. hlist::
- :columns: 2
-
- - :data:`gpu.GPU_DYNAMIC_LAMP_DYNVEC`
- - :data:`gpu.GPU_DYNAMIC_LAMP_DYNCO`
- - :data:`gpu.GPU_DYNAMIC_LAMP_DYNIMAT`
- - :data:`gpu.GPU_DYNAMIC_LAMP_DYNPERSMAT`
- - :data:`gpu.GPU_DYNAMIC_LAMP_DYNENERGY`
- - :data:`gpu.GPU_DYNAMIC_LAMP_DYNCOL`
- - :data:`gpu.GPU_DYNAMIC_SAMPLER_2DSHADOW`
-
- Notes:
-
- - The uniforms
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNVEC`,
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNCO`,
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNIMAT` and
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNPERSMAT`
- refer to the lamp object position and orientation,
- both of can be derived from the object world matrix:
-
- .. code-block:: python
-
- obmat = uniform["lamp"].matrix_world
-
- where obmat is the mat4_lamp_to_world_ matrix of the lamp as a 2 dimensional array,
- the lamp world location location is in ``obmat[3]``.
-
- - The uniform types
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNENERGY` and
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNCOL`
- refer to the lamp data bloc that you get from:
-
- .. code-block:: python
-
- la = uniform["lamp"].data
-
- from which you get ``lamp.energy`` and ``lamp.color``
-
- - Lamp duplication is not supported: if you have duplicated lamps in your scene
- (i.e. lamp that are instantiated by dupligroup, etc), this element will only
- give you a reference to the orignal lamp and you will not know which instance
- of the lamp it is refering too. You can still handle that case in the exporter
- by distributing the uniforms amongst the duplicated lamps.
-
- - ``["image"]``: :class:`bpy.types.Image`
- Reference to the image databloc.
- Set for uniform type
- :data:`gpu.GPU_DYNAMIC_SAMPLER_2DIMAGE`.
- You can get the image data from:
-
- .. code-block:: python
-
- # full path to image file
- uniform["image"].filepath
- # image size as a 2-dimensional array of int
- uniform["image"].size
-
- - ``["texnumber"]``: integer
- Channel number to which the texture is bound when drawing the object.
- Set for uniform types
- :data:`gpu.GPU_DYNAMIC_SAMPLER_2DBUFFER`,
- :data:`gpu.GPU_DYNAMIC_SAMPLER_2DIMAGE` and
- :data:`gpu.GPU_DYNAMIC_SAMPLER_2DSHADOW`.
-
- This is provided for information only: when reusing the shader outside blencer,
- you are free to assign the textures to the channel of your choice and to pass
- that number channel to the GPU in the uniform.
-
- - ``["texpixels"]``: byte array
- texture data for uniform type :data:`gpu.GPU_DYNAMIC_SAMPLER_2DBUFFER`.
- Although the corresponding uniform is a 2D sampler,
- the texture is always a 1D texture of n x 1 pixel.
- The texture size n is provided in ["texsize"] element.
- These texture are only used for computer generated texture (colorband, etc).
- The texture data is provided so that you can make a real image out of it in the exporter.
-
- - ``["texsize"]``: integer
- horizontal size of texture for uniform type :data:`gpu.GPU_DYNAMIC_SAMPLER_2DBUFFER`.
- The texture data is in ["texpixels"].
-
- - ``["attributes"]``: sequence
- list of attributes used in vertex shader, can be empty. Blender doesn't use
- standard attributes except for vertex position and normal. All other vertex
- attributes must be passed using the generic ``glVertexAttrib`` functions.
- The attribute data can be found in the derived mesh custom data using RNA.
- Each element of the sequence is a dictionary containing the following elements:
-
- - ``["varname"]``: string
- name of the uniform in the vertex shader. Always of the form 'att<number>'.
-
- - ``["datatype"]``: integer
- data type of vertex attribute, can be one of the following:
-
- - :data:`gpu.GPU_DATA_2F`: use ``glVertexAttrib2fv``
- - :data:`gpu.GPU_DATA_3F`: use ``glVertexAttrib3fv``
- - :data:`gpu.GPU_DATA_4F`: use ``glVertexAttrib4fv``
- - :data:`gpu.GPU_DATA_4UB`: use ``glVertexAttrib4ubv``
-
- - ``["number"]``: integer
- Generic attribute number. This is provided for information only.
- Blender doesn't use ``glBindAttribLocation`` to place generic attributes at specific location,
- it lets the shader compiler place the attributes automatically and query the
- placement with ``glGetAttribLocation``.
- The result of this placement is returned in this element.
-
- When using this shader in a render engine, you should either use
- ``glBindAttribLocation`` to force the attribute at this location or use
- ``glGetAttribLocation`` to get the placement chosen by the compiler of your GPU.
-
- - ``["type"]``: integer
- type of the mesh custom data from which the vertex attribute is loaded.
- See attribute-type_.
-
- - ``["name"]``: string or integer
- custom data layer name, used for attribute type :data:`gpu.CD_MTFACE` and :data:`gpu.CD_MCOL`.
-
- Example:
-
- .. code-block:: python
-
- import gpu
- # get GLSL shader of material Mat.001 in scene Scene.001
- scene = bpy.data.scenes["Scene.001"]
- material = bpy.data.materials["Mat.001"]
- shader = gpu.export_shader(scene,material)
- # scan the uniform list and find the images used in the shader
- for uniform in shader["uniforms"]:
- if uniform["type"] == gpu.GPU_DYNAMIC_SAMPLER_2DIMAGE:
- print("uniform {0} is using image {1}".format(uniform["varname"], uniform["image"].filepath))
- # scan the attribute list and find the UV Map used in the shader
- for attribute in shader["attributes"]:
- if attribute["type"] == gpu.CD_MTFACE:
- print("attribute {0} is using UV Map {1}".format(attribute["varname"], attribute["name"]))
-
-
-Notes
-=====
-
-.. _mat4_lamp_to_perspective:
-
-#. Calculation of the ``mat4_lamp_to_perspective`` matrix for a spot lamp.
-
- The following pseudo code shows how the ``mat4_lamp_to_perspective`` matrix is computed
- in blender for uniforms of :data:`gpu.GPU_DYNAMIC_LAMP_DYNPERSMAT` type:
-
- .. code-block:: python
-
- # Get the lamp datablock with:
- lamp = bpy.data.objects[uniform["lamp"]].data
-
- # Compute the projection matrix:
- # You will need these lamp attributes:
- # lamp.clipsta : near clip plane in world unit
- # lamp.clipend : far clip plane in world unit
- # lamp.spotsize : angle in degree of the spot light
-
- # The size of the projection plane is computed with the usual formula:
- wsize = lamp.clista * tan(lamp.spotsize/2)
-
- # And the projection matrix:
- mat4_lamp_to_perspective = glFrustum(-wsize, wsize, -wsize, wsize, lamp.clista, lamp.clipend)
-
-#. Creation of the shadow map for a spot lamp.
-
- The shadow map is the depth buffer of a render performed by placing the camera at the
- spot light position. The size of the shadow map is given by the attribute ``lamp.bufsize``:
- shadow map size in pixel, same size in both dimensions.
+Module to provide functions concerning the GPU implementation in Blender.
diff --git a/doc/python_api/rst/info_api_reference.rst b/doc/python_api/rst/info_api_reference.rst
index ab690a8ee06..5d5d38bf18b 100644
--- a/doc/python_api/rst/info_api_reference.rst
+++ b/doc/python_api/rst/info_api_reference.rst
@@ -15,7 +15,7 @@ Reference API Scope
The reference API covers :mod:`bpy.types`, which stores types accessed via :mod:`bpy.context` - *The user context*
or :mod:`bpy.data` - *Blend file data*.
-Other modules such as :mod:`bge`, :mod:`bmesh` and :mod:`aud` are not using Blenders data API
+Other modules such as :mod:`bmesh` and :mod:`aud` are not using Blenders data API
so this document doesn't apply to those modules.
diff --git a/doc/python_api/rst/info_quickstart.rst b/doc/python_api/rst/info_quickstart.rst
index 7a899e040a6..bbedb3f4fd4 100644
--- a/doc/python_api/rst/info_quickstart.rst
+++ b/doc/python_api/rst/info_quickstart.rst
@@ -196,9 +196,9 @@ Example:
# dictionaries can be assigned as long as they only use basic types.
group = bpy.data.groups.new("MyTestGroup")
- group["GameSettings"] = {"foo": 10, "bar": "spam", "baz": {}}
+ group["MySettings"] = {"foo": 10, "bar": "spam", "baz": {}}
- del group["GameSettings"]
+ del group["MySettings"]
Note that these properties can only be assigned basic Python types.
diff --git a/doc/python_api/rst/info_tips_and_tricks.rst b/doc/python_api/rst/info_tips_and_tricks.rst
index 97bc682894a..b7137fcbdea 100644
--- a/doc/python_api/rst/info_tips_and_tricks.rst
+++ b/doc/python_api/rst/info_tips_and_tricks.rst
@@ -231,7 +231,7 @@ There are 2 ways around this:
you could also copy the entire Python installation into Blenders sub-directory,
replacing the one Blender comes with.
This works as long as the Python versions match and the paths are created in the same relative locations.
- Doing this has the advantage that you can redistribute this bundle to others with Blender and/or the game player,
+ Doing this has the advantage that you can redistribute this bundle to others with Blender
including any extensions you rely on.
@@ -280,11 +280,6 @@ The IPython prompt has auto-complete and some useful features that the standard
Admittedly this highlights the lack of any Python debugging support built into Blender, but its still handy to know.
-.. note::
-
- This works in the game engine as well, it can be handy to inspect the state of a running game.
-
-
Advanced
========
diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt
index 54d3275b760..4f8f2ff2b54 100644
--- a/extern/CMakeLists.txt
+++ b/extern/CMakeLists.txt
@@ -63,10 +63,6 @@ if(NOT WITH_SYSTEM_GLEW)
endif()
endif()
-if(WITH_GAMEENGINE)
- add_subdirectory(recastnavigation)
-endif()
-
if(WITH_IMAGE_OPENJPEG AND (NOT WITH_SYSTEM_OPENJPEG))
add_subdirectory(libopenjpeg)
endif()
diff --git a/extern/audaspace/blender_config.cmake b/extern/audaspace/blender_config.cmake
index 5b5440920d0..fb1ef95fee4 100644
--- a/extern/audaspace/blender_config.cmake
+++ b/extern/audaspace/blender_config.cmake
@@ -24,3 +24,7 @@ set(PYTHONLIBS_FOUND TRUE)
set(NUMPY_FOUND TRUE)
set(NUMPY_INCLUDE_DIRS ${PYTHON_NUMPY_INCLUDE_DIRS})
set(SDL_FOUND ${WITH_SDL})
+
+if(WIN32)
+ set(DEFAULT_PLUGIN_PATH "plugins")
+endif()
diff --git a/extern/recastnavigation/CMakeLists.txt b/extern/recastnavigation/CMakeLists.txt
deleted file mode 100644
index 19ac6e9dde8..00000000000
--- a/extern/recastnavigation/CMakeLists.txt
+++ /dev/null
@@ -1,72 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Daniel Genrich
-#
-# ***** END GPL LICENSE BLOCK *****
-
-remove_cc_flag_unsigned_char()
-
-set(INC
- Recast/Include
- Detour/Include
-)
-
-set(INC_SYS
-
-)
-
-set(SRC
- recast-capi.cpp
- recast-capi.h
-
-
- Detour/Source/DetourCommon.cpp
- Detour/Source/DetourNode.cpp
- Detour/Source/DetourStatNavMesh.cpp
- Detour/Source/DetourStatNavMeshBuilder.cpp
- Detour/Source/DetourTileNavMesh.cpp
- Detour/Source/DetourTileNavMeshBuilder.cpp
-
- Detour/Include/DetourCommon.h
- Detour/Include/DetourNode.h
- Detour/Include/DetourStatNavMesh.h
- Detour/Include/DetourStatNavMeshBuilder.h
- Detour/Include/DetourTileNavMesh.h
- Detour/Include/DetourTileNavMeshBuilder.h
-
- Recast/Source/Recast.cpp
- Recast/Source/RecastAlloc.cpp
- Recast/Source/RecastArea.cpp
- Recast/Source/RecastContour.cpp
- Recast/Source/RecastFilter.cpp
- Recast/Source/RecastLayers.cpp
- Recast/Source/RecastMesh.cpp
- Recast/Source/RecastMeshDetail.cpp
- Recast/Source/RecastRasterization.cpp
- Recast/Source/RecastRegion.cpp
-
- Recast/Include/Recast.h
- Recast/Include/RecastAlloc.h
- Recast/Include/RecastAssert.h
-)
-
-blender_add_lib(extern_recastnavigation "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/extern/recastnavigation/Detour/Include/DetourCommon.h b/extern/recastnavigation/Detour/Include/DetourCommon.h
deleted file mode 100644
index d824efc06e4..00000000000
--- a/extern/recastnavigation/Detour/Include/DetourCommon.h
+++ /dev/null
@@ -1,167 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 DETOURCOMMON_H
-#define DETOURCOMMON_H
-
-//////////////////////////////////////////////////////////////////////////////////////////
-
-template<class T> inline void swap(T& a, T& b) { T t = a; a = b; b = t; }
-template<class T> inline T min(T a, T b) { return a < b ? a : b; }
-template<class T> inline T max(T a, T b) { return a > b ? a : b; }
-template<class T> inline T abs(T a) { return a < 0 ? -a : a; }
-template<class T> inline T sqr(T a) { return a*a; }
-template<class T> inline T clamp(T v, T mn, T mx) { return v < mn ? mn : (v > mx ? mx : v); }
-
-inline void vcross(float* dest, const float* v1, const float* v2)
-{
- dest[0] = v1[1]*v2[2] - v1[2]*v2[1];
- dest[1] = v1[2]*v2[0] - v1[0]*v2[2];
- dest[2] = v1[0]*v2[1] - v1[1]*v2[0];
-}
-
-inline float vdot(const float* v1, const float* v2)
-{
- return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
-}
-
-inline void vmad(float* dest, const float* v1, const float* v2, const float s)
-{
- dest[0] = v1[0]+v2[0]*s;
- dest[1] = v1[1]+v2[1]*s;
- dest[2] = v1[2]+v2[2]*s;
-}
-
-inline void vadd(float* dest, const float* v1, const float* v2)
-{
- dest[0] = v1[0]+v2[0];
- dest[1] = v1[1]+v2[1];
- dest[2] = v1[2]+v2[2];
-}
-
-inline void vsub(float* dest, const float* v1, const float* v2)
-{
- dest[0] = v1[0]-v2[0];
- dest[1] = v1[1]-v2[1];
- dest[2] = v1[2]-v2[2];
-}
-
-inline void vmin(float* mn, const float* v)
-{
- mn[0] = min(mn[0], v[0]);
- mn[1] = min(mn[1], v[1]);
- mn[2] = min(mn[2], v[2]);
-}
-
-inline void vmax(float* mx, const float* v)
-{
- mx[0] = max(mx[0], v[0]);
- mx[1] = max(mx[1], v[1]);
- mx[2] = max(mx[2], v[2]);
-}
-
-inline void vcopy(float* dest, const float* a)
-{
- dest[0] = a[0];
- dest[1] = a[1];
- dest[2] = a[2];
-}
-
-inline float vdist(const float* v1, const float* v2)
-{
- float dx = v2[0] - v1[0];
- float dy = v2[1] - v1[1];
- float dz = v2[2] - v1[2];
- return sqrtf(dx*dx + dy*dy + dz*dz);
-}
-
-inline float vdistSqr(const float* v1, const float* v2)
-{
- float dx = v2[0] - v1[0];
- float dy = v2[1] - v1[1];
- float dz = v2[2] - v1[2];
- return dx*dx + dy*dy + dz*dz;
-}
-
-inline void vnormalize(float* v)
-{
- float d = 1.0f / sqrtf(sqr(v[0]) + sqr(v[1]) + sqr(v[2]));
- v[0] *= d;
- v[1] *= d;
- v[2] *= d;
-}
-
-inline bool vequal(const float* p0, const float* p1)
-{
- static const float thr = sqr(1.0f/16384.0f);
- const float d = vdistSqr(p0, p1);
- return d < thr;
-}
-
-inline int nextPow2(int v)
-{
- v--;
- v |= v >> 1;
- v |= v >> 2;
- v |= v >> 4;
- v |= v >> 8;
- v |= v >> 16;
- v++;
- return v;
-}
-
-inline float vdot2D(const float* u, const float* v)
-{
- return u[0]*v[0] + u[2]*v[2];
-}
-
-inline float vperp2D(const float* u, const float* v)
-{
- return u[2]*v[0] - u[0]*v[2];
-}
-
-inline float triArea2D(const float* a, const float* b, const float* c)
-{
- return ((b[0]*a[2] - a[0]*b[2]) + (c[0]*b[2] - b[0]*c[2]) + (a[0]*c[2] - c[0]*a[2])) * 0.5f;
-}
-
-inline bool checkOverlapBox(const unsigned short amin[3], const unsigned short amax[3],
- const unsigned short bmin[3], const unsigned short bmax[3])
-{
- bool overlap = true;
- overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
- overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;
- overlap = (amin[2] > bmax[2] || amax[2] < bmin[2]) ? false : overlap;
- return overlap;
-}
-
-void closestPtPointTriangle(float* closest, const float* p,
- const float* a, const float* b, const float* c);
-
-bool closestHeightPointTriangle(const float* p, const float* a, const float* b, const float* c, float& h);
-
-bool intersectSegmentPoly2D(const float* p0, const float* p1,
- const float* verts, int nverts,
- float& tmin, float& tmax,
- int& segMin, int& segMax);
-
-float distancePtSegSqr2D(const float* pt, const float* p, const float* q, float& t);
-
-void calcPolyCenter(float* tc, const unsigned short* idx, int nidx, const float* verts);
-
-#endif // DETOURCOMMON_H \ No newline at end of file
diff --git a/extern/recastnavigation/Detour/Include/DetourNode.h b/extern/recastnavigation/Detour/Include/DetourNode.h
deleted file mode 100644
index 316d5bf4cf6..00000000000
--- a/extern/recastnavigation/Detour/Include/DetourNode.h
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 DETOURNODE_H
-#define DETOURNODE_H
-
-enum dtNodeFlags
-{
- DT_NODE_OPEN = 0x01,
- DT_NODE_CLOSED = 0x02,
-};
-
-struct dtNode
-{
- float cost;
- float total;
- unsigned int id;
- unsigned int pidx : 30;
- unsigned int flags : 2;
-};
-
-class dtNodePool
-{
-public:
- dtNodePool(int maxNodes, int hashSize);
- ~dtNodePool();
- inline void operator=(const dtNodePool&) {}
- void clear();
- dtNode* getNode(unsigned int id);
- const dtNode* findNode(unsigned int id) const;
-
- inline unsigned int getNodeIdx(const dtNode* node) const
- {
- if (!node) return 0;
- return (unsigned int)(node - m_nodes)+1;
- }
-
- inline dtNode* getNodeAtIdx(unsigned int idx)
- {
- if (!idx) return 0;
- return &m_nodes[idx-1];
- }
-
- inline int getMemUsed() const
- {
- return sizeof(*this) +
- sizeof(dtNode)*m_maxNodes +
- sizeof(unsigned short)*m_maxNodes +
- sizeof(unsigned short)*m_hashSize;
- }
-
-private:
- inline unsigned int hashint(unsigned int a) const
- {
- a += ~(a<<15);
- a ^= (a>>10);
- a += (a<<3);
- a ^= (a>>6);
- a += ~(a<<11);
- a ^= (a>>16);
- return a;
- }
-
- dtNode* m_nodes;
- unsigned short* m_first;
- unsigned short* m_next;
- const int m_maxNodes;
- const int m_hashSize;
- int m_nodeCount;
-};
-
-class dtNodeQueue
-{
-public:
- dtNodeQueue(int n);
- ~dtNodeQueue();
- inline void operator=(dtNodeQueue&) {}
-
- inline void clear()
- {
- m_size = 0;
- }
-
- inline dtNode* top()
- {
- return m_heap[0];
- }
-
- inline dtNode* pop()
- {
- dtNode* result = m_heap[0];
- m_size--;
- trickleDown(0, m_heap[m_size]);
- return result;
- }
-
- inline void push(dtNode* node)
- {
- m_size++;
- bubbleUp(m_size-1, node);
- }
-
- inline void modify(dtNode* node)
- {
- for (int i = 0; i < m_size; ++i)
- {
- if (m_heap[i] == node)
- {
- bubbleUp(i, node);
- return;
- }
- }
- }
-
- inline bool empty() const { return m_size == 0; }
-
- inline int getMemUsed() const
- {
- return sizeof(*this) +
- sizeof(dtNode*)*(m_capacity+1);
- }
-
-
-private:
- void bubbleUp(int i, dtNode* node);
- void trickleDown(int i, dtNode* node);
-
- dtNode** m_heap;
- const int m_capacity;
- int m_size;
-};
-
-
-#endif // DETOURNODE_H \ No newline at end of file
diff --git a/extern/recastnavigation/Detour/Include/DetourStatNavMesh.h b/extern/recastnavigation/Detour/Include/DetourStatNavMesh.h
deleted file mode 100644
index 5a3e04a2074..00000000000
--- a/extern/recastnavigation/Detour/Include/DetourStatNavMesh.h
+++ /dev/null
@@ -1,234 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 DETOURSTATNAVMESH_H
-#define DETOURSTATNAVMESH_H
-
-// Reference to navigation polygon.
-typedef unsigned short dtStatPolyRef;
-
-// Maximum number of vertices per navigation polygon.
-static const int DT_STAT_VERTS_PER_POLYGON = 6;
-
-// Structure holding the navigation polygon data.
-struct dtStatPoly
-{
- unsigned short v[DT_STAT_VERTS_PER_POLYGON]; // Indices to vertices of the poly.
- dtStatPolyRef n[DT_STAT_VERTS_PER_POLYGON]; // Refs to neighbours of the poly.
- unsigned char nv; // Number of vertices.
- unsigned char flags; // Flags (not used).
-};
-
-struct dtStatPolyDetail
-{
- unsigned short vbase; // Offset to detail vertex array.
- unsigned short nverts; // Number of vertices in the detail mesh.
- unsigned short tbase; // Offset to detail triangle array.
- unsigned short ntris; // Number of triangles.
-};
-
-const int DT_STAT_NAVMESH_MAGIC = (('N'<<24) | ('A'<<16) | ('V'<<8) | 'M');
-const int DT_STAT_NAVMESH_VERSION = 3;
-
-struct dtStatBVNode
-{
- unsigned short bmin[3], bmax[3];
- int i;
-};
-
-struct dtStatNavMeshHeader
-{
- int magic;
- int version;
- int npolys;
- int nverts;
- int nnodes;
- int ndmeshes;
- int ndverts;
- int ndtris;
- float cs;
- float bmin[3], bmax[3];
- dtStatPoly* polys;
- float* verts;
- dtStatBVNode* bvtree;
- dtStatPolyDetail* dmeshes;
- float* dverts;
- unsigned char* dtris;
-};
-
-class dtStatNavMesh
-{
-public:
-
- dtStatNavMesh();
- ~dtStatNavMesh();
-
- // Initializes the navmesh with data.
- // Params:
- // data - (in) Pointer to navmesh data.
- // dataSize - (in) size of the navmesh data.
- // ownsData - (in) Flag indicating if the navmesh should own and delete the data.
- bool init(unsigned char* data, int dataSize, bool ownsData);
-
- // Finds the nearest navigation polygon around the center location.
- // Params:
- // center - (in) The center of the search box.
- // extents - (in) The extents of the search box.
- // Returns: Reference identifier for the polygon, or 0 if no polygons found.
- dtStatPolyRef findNearestPoly(const float* center, const float* extents);
-
- // Returns polygons which touch the query box.
- // Params:
- // center - (in) the center of the search box.
- // extents - (in) the extents of the search box.
- // polys - (out) array holding the search result.
- // maxPolys - (in) The max number of polygons the polys array can hold.
- // Returns: Number of polygons in search result array.
- int queryPolygons(const float* center, const float* extents,
- dtStatPolyRef* polys, const int maxPolys);
-
- // Finds path from start polygon to end polygon.
- // If target polygon canno be reached through the navigation graph,
- // the last node on the array is nearest node to the end polygon.
- // Params:
- // startRef - (in) ref to path start polygon.
- // endRef - (in) ref to path end polygon.
- // path - (out) array holding the search result.
- // maxPathSize - (in) The max number of polygons the path array can hold.
- // Returns: Number of polygons in search result array.
- int findPath(dtStatPolyRef startRef, dtStatPolyRef endRef,
- const float* startPos, const float* endPos,
- dtStatPolyRef* path, const int maxPathSize);
-
- // Finds a straight path from start to end locations within the corridor
- // described by the path polygons.
- // Start and end locations will be clamped on the corridor.
- // Params:
- // startPos - (in) Path start location.
- // endPos - (in) Path end location.
- // path - (in) Array of connected polygons describing the corridor.
- // pathSize - (in) Number of polygons in path array.
- // straightPath - (out) Points describing the straight path.
- // maxStraightPathSize - (in) The max number of points the straight path array can hold.
- // Returns: Number of points in the path.
- int findStraightPath(const float* startPos, const float* endPos,
- const dtStatPolyRef* path, const int pathSize,
- float* straightPath, const int maxStraightPathSize);
-
- // Finds intersection againts walls starting from start pos.
- // Params:
- // startRef - (in) ref to the polygon where the start lies.
- // startPos - (in) start position of the query.
- // endPos - (in) end position of the query.
- // t - (out) hit parameter along the segment, 0 if no hit.
- // endRef - (out) ref to the last polygon which was processed.
- // Returns: Number of polygons in path or 0 if failed.
- int raycast(dtStatPolyRef startRef, const float* startPos, const float* endPos,
- float& t, dtStatPolyRef* path, const int pathSize);
-
- // Returns distance to nearest wall from the specified location.
- // Params:
- // centerRef - (in) ref to the polygon where the center lies.
- // centerPos - (in) center if the query circle.
- // maxRadius - (in) max search radius.
- // hitPos - (out) location of the nearest hit.
- // hitNormal - (out) normal of the nearest hit.
- // Returns: Distance to nearest wall from the test location.
- float findDistanceToWall(dtStatPolyRef centerRef, const float* centerPos, float maxRadius,
- float* hitPos, float* hitNormal);
-
- // Finds polygons found along the navigation graph which touch the specified circle.
- // Params:
- // centerRef - (in) ref to the polygon where the center lies.
- // centerPos - (in) center if the query circle
- // radius - (in) radius of the query circle
- // resultRef - (out, opt) refs to the polygons touched by the circle.
- // resultParent - (out, opt) parent of each result polygon.
- // resultCost - (out, opt) search cost at each result polygon.
- // maxResult - (int) maximum capacity of search results.
- // Returns: Number of results.
- int findPolysAround(dtStatPolyRef centerRef, const float* centerPos, float radius,
- dtStatPolyRef* resultRef, dtStatPolyRef* resultParent, float* resultCost,
- const int maxResult);
-
- // Returns closest point on navigation polygon.
- // Params:
- // ref - (in) ref to the polygon.
- // pos - (in) the point to check.
- // closest - (out) closest point.
- // Returns: true if closest point found.
- bool closestPointToPoly(dtStatPolyRef ref, const float* pos, float* closest) const;
-
- // Returns height of the polygon at specified location.
- // Params:
- // ref - (in) ref to the polygon.
- // pos - (in) the point where to locate the height.
- // height - (out) height at the location.
- // Returns: true if oer polygon.
- bool getPolyHeight(dtStatPolyRef ref, const float* pos, float* height) const;
-
- // Returns pointer to a polygon based on ref.
- const dtStatPoly* getPolyByRef(dtStatPolyRef ref) const;
- // Returns polygon index based on ref, or -1 if failed.
- int getPolyIndexByRef(dtStatPolyRef ref) const;
- // Returns number of navigation polygons.
- inline int getPolyCount() const { return m_header ? m_header->npolys : 0; }
- // Rerturns pointer to specified navigation polygon.
- inline const dtStatPoly* getPoly(int i) const { return &m_header->polys[i]; }
- // Returns number of vertices.
- inline int getVertexCount() const { return m_header ? m_header->nverts : 0; }
- // Returns pointer to specified vertex.
- inline const float* getVertex(int i) const { return &m_header->verts[i*3]; }
- // Returns number of navigation polygons details.
- inline int getPolyDetailCount() const { return m_header ? m_header->ndmeshes : 0; }
- // Rerturns pointer to specified navigation polygon detail.
- const dtStatPolyDetail* getPolyDetail(int i) const { return &m_header->dmeshes[i]; }
- // Returns pointer to specified vertex.
- inline const float* getDetailVertex(int i) const { return &m_header->dverts[i*3]; }
- // Returns pointer to specified vertex.
- inline const unsigned char* getDetailTri(int i) const { return &m_header->dtris[i*4]; }
-
- bool isInClosedList(dtStatPolyRef ref) const;
-
- int getMemUsed() const;
-
- inline unsigned char* getData() const { return m_data; }
- inline int getDataSize() const { return m_dataSize; }
- inline const dtStatNavMeshHeader* getHeader() const { return m_header; }
- inline const dtStatBVNode* getBvTreeNodes() const { return m_header ? m_header->bvtree : 0; }
- inline int getBvTreeNodeCount() const { return m_header ? m_header->nnodes : 0; }
-
-private:
-
- // Copies the locations of vertices of a polygon to an array.
- int getPolyVerts(dtStatPolyRef ref, float* verts) const;
- // Returns portal points between two polygons.
- bool getPortalPoints(dtStatPolyRef from, dtStatPolyRef to, float* left, float* right) const;
- // Returns edge mid point between two polygons.
- bool getEdgeMidPoint(dtStatPolyRef from, dtStatPolyRef to, float* mid) const;
-
- unsigned char* m_data;
- int m_dataSize;
-
- dtStatNavMeshHeader* m_header;
-
- class dtNodePool* m_nodePool;
- class dtNodeQueue* m_openList;
-};
-
-#endif // DETOURSTATNAVMESH_H
diff --git a/extern/recastnavigation/Detour/Include/DetourStatNavMeshBuilder.h b/extern/recastnavigation/Detour/Include/DetourStatNavMeshBuilder.h
deleted file mode 100644
index 03c79c429e7..00000000000
--- a/extern/recastnavigation/Detour/Include/DetourStatNavMeshBuilder.h
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 DETOURSTATNAVMESHBUILDER_H
-#define DETOURSTATNAVMESHBUILDER_H
-
-bool dtCreateNavMeshData(const unsigned short* verts, const int nverts,
- const unsigned short* polys, const int npolys, const int nvp,
- const float* bmin, const float* bmax, float cs, float ch,
- const unsigned short* dmeshes, const float* dverts, const int ndverts,
- const unsigned char* dtris, const int ndtris,
- unsigned char** outData, int* outDataSize);
-
-int createBVTree(const unsigned short* verts, const int nverts,
- const unsigned short* polys, const int npolys, const int nvp,
- float cs, float ch, int nnodes, dtStatBVNode* nodes);
-
-#endif // DETOURSTATNAVMESHBUILDER_H \ No newline at end of file
diff --git a/extern/recastnavigation/Detour/Include/DetourTileNavMesh.h b/extern/recastnavigation/Detour/Include/DetourTileNavMesh.h
deleted file mode 100644
index 50ccdd118e8..00000000000
--- a/extern/recastnavigation/Detour/Include/DetourTileNavMesh.h
+++ /dev/null
@@ -1,315 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 DETOURTILENAVMESH_H
-#define DETOURTILENAVMESH_H
-
-// Reference to navigation polygon.
-typedef unsigned int dtTilePolyRef;
-
-// The bits used in the poly ref.
-static const int DT_TILE_REF_SALT_BITS = 12;
-static const int DT_TILE_REF_TILE_BITS = 12;
-static const int DT_TILE_REF_POLY_BITS = 8;
-static const int DT_TILE_REF_SALT_MASK = (1<<DT_TILE_REF_SALT_BITS)-1;
-static const int DT_TILE_REF_TILE_MASK = (1<<DT_TILE_REF_TILE_BITS)-1;
-static const int DT_TILE_REF_POLY_MASK = (1<<DT_TILE_REF_POLY_BITS)-1;
-
-// Maximum number of vertices per navigation polygon.
-static const int DT_TILE_VERTS_PER_POLYGON = 6;
-
-static const int DT_MAX_TILES = 1 << DT_TILE_REF_TILE_BITS;
-static const int DT_MAX_POLYGONS = 1 << DT_TILE_REF_POLY_BITS;
-
-static const int DT_TILE_NAVMESH_MAGIC = (('N'<<24) | ('A'<<16) | ('V'<<8) | 'T');
-static const int DT_TILE_NAVMESH_VERSION = 2;
-
-// Structure holding the navigation polygon data.
-struct dtTilePoly
-{
- unsigned short v[DT_TILE_VERTS_PER_POLYGON]; // Indices to vertices of the poly.
- unsigned short n[DT_TILE_VERTS_PER_POLYGON]; // Refs to neighbours of the poly.
- unsigned short links; // Base index to header 'links' array.
- unsigned char nlinks; // Number of links for
- unsigned char nv; // Number of vertices.
- unsigned char flags; // Flags (not used).
-};
-
-struct dtTilePolyDetail
-{
- unsigned short vbase; // Offset to detail vertex array.
- unsigned short nverts; // Number of vertices in the detail mesh.
- unsigned short tbase; // Offset to detail triangle array.
- unsigned short ntris; // Number of triangles.
-};
-
-// Stucture holding a link to another polygon.
-struct dtTileLink
-{
- dtTilePolyRef ref; // Neighbour reference.
- unsigned short p; // Index to polygon which owns this link.
- unsigned char e; // Index to polygon edge which owns this link.
- unsigned char side; // If boundary link, defines on which side the link is.
- unsigned char bmin, bmax; // If boundary link, defines the sub edge area.
-};
-
-struct dtTileHeader
-{
- int magic; // Magic number, used to identify the data.
- int version; // Data version number.
- int npolys; // Number of polygons in the tile.
- int nverts; // Number of vertices in the tile.
- int nlinks; // Number of links in the tile (will be updated when tile is added).
- int maxlinks; // Number of allocated links.
- int ndmeshes;
- int ndverts;
- int ndtris;
- float bmin[3], bmax[3]; // Bounding box of the tile.
- dtTilePoly* polys; // Pointer to the polygons (will be updated when tile is added).
- float* verts; // Pointer to the vertices (will be updated when tile added).
- dtTileLink* links; // Pointer to the links (will be updated when tile added).
- dtTilePolyDetail* dmeshes;
- float* dverts;
- unsigned char* dtris;
-};
-
-struct dtTile
-{
- int salt; // Counter describing modifications to the tile.
- int x,y; // Grid location of the tile.
- dtTileHeader* header; // Pointer to tile header.
- unsigned char* data; // Pointer to tile data.
- int dataSize; // Size of the tile data.
- bool ownsData; // Flag indicating of the navmesh should release the data.
- dtTile* next; // Next free tile or, next tile in spatial grid.
-};
-
-// Encodes a tile id.
-inline dtTilePolyRef dtEncodeTileId(unsigned int salt, unsigned int it, unsigned int ip)
-{
- return (salt << (DT_TILE_REF_POLY_BITS+DT_TILE_REF_TILE_BITS)) | ((it+1) << DT_TILE_REF_POLY_BITS) | ip;
-}
-
-// Decodes a tile id.
-inline void dtDecodeTileId(dtTilePolyRef ref, unsigned int& salt, unsigned int& it, unsigned int& ip)
-{
- salt = (ref >> (DT_TILE_REF_POLY_BITS+DT_TILE_REF_TILE_BITS)) & DT_TILE_REF_SALT_MASK;
- it = ((ref >> DT_TILE_REF_POLY_BITS) & DT_TILE_REF_TILE_MASK) - 1;
- ip = ref & DT_TILE_REF_POLY_MASK;
-}
-
-static const int DT_TILE_LOOKUP_SIZE = DT_MAX_TILES/4;
-
-class dtTiledNavMesh
-{
-public:
- dtTiledNavMesh();
- ~dtTiledNavMesh();
-
- // Initializes the nav mesh.
- // Params:
- // orig - (in) origin of the nav mesh tile space.
- // tileSiz - (in) size of a tile.
- // portalheight - (in) height of the portal region between tiles.
- // Returns: True if succeed, else false.
- bool init(const float* orig, float tileSize, float portalHeight);
-
- // Adds new tile into the navmesh.
- // The add will fail if the data is in wrong format,
- // there is not enough tiles left, or if there is a tile already at the location.
- // Params:
- // x,y - (in) Location of the new tile.
- // data - (in) Data of the new tile mesh.
- // dataSize - (in) Data size of the new tile mesh.
- // ownsData - (in) Flag indicating if the navmesh should own and delete the data.
- // Returns: True if tile was added, else false.
- bool addTileAt(int x, int y, unsigned char* data, int dataSize, bool ownsData);
-
- // Removes tile at specified location.
- // Params:
- // x,y - (in) Location of the tile to remove.
- // data - (out) Data associated with deleted tile.
- // dataSize - (out) Size of the data associated with deleted tile.
- // Returns: True if remove suceed, else false.
- bool removeTileAt(int x, int y, unsigned char** data, int* dataSize);
-
- // Returns pointer to tile at specified location.
- // Params:
- // x,y - (in) Location of the tile to get.
- // Returns: pointer to tile if tile exists or 0 tile does not exists.
- dtTile* getTileAt(int x, int y);
-
- // Returns pointer to tile in the tile array.
- // Params:
- // i - (in) Index to the tile to retrieve, must be in range [0,DT_MAX_TILES[
- // Returns: Pointer to specified tile.
- dtTile* getTile(int i);
- const dtTile* getTile(int i) const;
-
- // Finds the nearest navigation polygon around the center location.
- // Params:
- // center - (in) The center of the search box.
- // extents - (in) The extents of the search box.
- // Returns: Reference identifier for the polygon, or 0 if no polygons found.
- dtTilePolyRef findNearestPoly(const float* center, const float* extents);
-
- // Returns polygons which touch the query box.
- // Params:
- // center - (in) the center of the search box.
- // extents - (in) the extents of the search box.
- // polys - (out) array holding the search result.
- // maxPolys - (in) The max number of polygons the polys array can hold.
- // Returns: Number of polygons in search result array.
- int queryPolygons(const float* center, const float* extents,
- dtTilePolyRef* polys, const int maxPolys);
-
- // Finds path from start polygon to end polygon.
- // If target polygon canno be reached through the navigation graph,
- // the last node on the array is nearest node to the end polygon.
- // Params:
- // startRef - (in) ref to path start polygon.
- // endRef - (in) ref to path end polygon.
- // path - (out) array holding the search result.
- // maxPathSize - (in) The max number of polygons the path array can hold.
- // Returns: Number of polygons in search result array.
- int findPath(dtTilePolyRef startRef, dtTilePolyRef endRef,
- const float* startPos, const float* endPos,
- dtTilePolyRef* path, const int maxPathSize);
-
- // Finds a straight path from start to end locations within the corridor
- // described by the path polygons.
- // Start and end locations will be clamped on the corridor.
- // Params:
- // startPos - (in) Path start location.
- // endPos - (in) Path end location.
- // path - (in) Array of connected polygons describing the corridor.
- // pathSize - (in) Number of polygons in path array.
- // straightPath - (out) Points describing the straight path.
- // maxStraightPathSize - (in) The max number of points the straight path array can hold.
- // Returns: Number of points in the path.
- int findStraightPath(const float* startPos, const float* endPos,
- const dtTilePolyRef* path, const int pathSize,
- float* straightPath, const int maxStraightPathSize);
-
- // Finds intersection againts walls starting from start pos.
- // Params:
- // startRef - (in) ref to the polygon where the start lies.
- // startPos - (in) start position of the query.
- // endPos - (in) end position of the query.
- // t - (out) hit parameter along the segment, 0 if no hit.
- // endRef - (out) ref to the last polygon which was processed.
- // Returns: Number of polygons in path or 0 if failed.
- int raycast(dtTilePolyRef startRef, const float* startPos, const float* endPos,
- float& t, dtTilePolyRef* path, const int pathSize);
-
- // Returns distance to nearest wall from the specified location.
- // Params:
- // centerRef - (in) ref to the polygon where the center lies.
- // centerPos - (in) center if the query circle.
- // maxRadius - (in) max search radius.
- // hitPos - (out) location of the nearest hit.
- // hitNormal - (out) normal of the nearest hit.
- // Returns: Distance to nearest wall from the test location.
- float findDistanceToWall(dtTilePolyRef centerRef, const float* centerPos, float maxRadius,
- float* hitPos, float* hitNormal);
-
- // Finds polygons found along the navigation graph which touch the specified circle.
- // Params:
- // centerRef - (in) ref to the polygon where the center lies.
- // centerPos - (in) center if the query circle
- // radius - (in) radius of the query circle
- // resultRef - (out, opt) refs to the polygons touched by the circle.
- // resultParent - (out, opt) parent of each result polygon.
- // resultCost - (out, opt) search cost at each result polygon.
- // maxResult - (int) maximum capacity of search results.
- // Returns: Number of results.
- int findPolysAround(dtTilePolyRef centerRef, const float* centerPos, float radius,
- dtTilePolyRef* resultRef, dtTilePolyRef* resultParent, float* resultCost,
- const int maxResult);
-
- // Returns closest point on navigation polygon.
- // Params:
- // ref - (in) ref to the polygon.
- // pos - (in) the point to check.
- // closest - (out) closest point.
- // Returns: true if closest point found.
- bool closestPointToPoly(dtTilePolyRef ref, const float* pos, float* closest) const;
-
- // Returns height of the polygon at specified location.
- // Params:
- // ref - (in) ref to the polygon.
- // pos - (in) the point where to locate the height.
- // height - (out) height at the location.
- // Returns: true if over polygon.
- bool getPolyHeight(dtTilePolyRef ref, const float* pos, float* height) const;
-
- // Returns pointer to a polygon based on ref.
- const dtTilePoly* getPolyByRef(dtTilePolyRef ref) const;
-
- // Returns pointer to a polygon vertices based on ref.
- const float* getPolyVertsByRef(dtTilePolyRef ref) const;
-
- // Returns pointer to a polygon link based on ref.
- const dtTileLink* getPolyLinksByRef(dtTilePolyRef ref) const;
-
-private:
-
- // Returns base id for the tile.
- dtTilePolyRef getTileId(dtTile* tile);
- // Returns neighbour tile based on side.
- dtTile* getNeighbourTileAt(int x, int y, int side);
- // Returns all polygons in neighbour tile based on portal defined by the segment.
- int findConnectingPolys(const float* va, const float* vb,
- dtTile* tile, int side,
- dtTilePolyRef* con, float* conarea, int maxcon);
- // Builds internal polygons links for a tile.
- void buildIntLinks(dtTile* tile);
- // Builds external polygon links for a tile.
- void buildExtLinks(dtTile* tile, dtTile* target, int side);
- // Removes external links at specified side.
- void removeExtLinks(dtTile* tile, int side);
- // Queries polygons within a tile.
- int queryTilePolygons(dtTile* tile, const float* qmin, const float* qmax,
- dtTilePolyRef* polys, const int maxPolys);
-
- float getCost(dtTilePolyRef prev, dtTilePolyRef from, dtTilePolyRef to) const;
- float getFirstCost(const float* pos, dtTilePolyRef from, dtTilePolyRef to) const;
- float getLastCost(dtTilePolyRef from, dtTilePolyRef to, const float* pos) const;
- float getHeuristic(const float* from, const float* to) const;
-
- // Returns portal points between two polygons.
- bool getPortalPoints(dtTilePolyRef from, dtTilePolyRef to, float* left, float* right) const;
- // Returns edge mid point between two polygons.
- bool getEdgeMidPoint(dtTilePolyRef from, dtTilePolyRef to, float* mid) const;
-
- float m_orig[3];
- float m_tileSize;
- float m_portalHeight;
-
- dtTile* m_posLookup[DT_TILE_LOOKUP_SIZE];
- dtTile* m_nextFree;
- dtTile m_tiles[DT_MAX_TILES];
-
- dtTileLink* m_tmpLinks;
- int m_ntmpLinks;
-
- class dtNodePool* m_nodePool;
- class dtNodeQueue* m_openList;
-};
-
-#endif // DETOURTILENAVMESH_H
diff --git a/extern/recastnavigation/Detour/Include/DetourTileNavMeshBuilder.h b/extern/recastnavigation/Detour/Include/DetourTileNavMeshBuilder.h
deleted file mode 100644
index 643dec1edb1..00000000000
--- a/extern/recastnavigation/Detour/Include/DetourTileNavMeshBuilder.h
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 DETOURTILEDNAVMESHBUILDER_H
-#define DETOURTILEDNAVMESHBUILDER_H
-
-bool dtCreateNavMeshTileData(const unsigned short* verts, const int nverts,
- const unsigned short* polys, const int npolys, const int nvp,
- const unsigned short* dmeshes, const float* dverts, const int ndverts,
- const unsigned char* dtris, const int ndtris,
- const float* bmin, const float* bmax, float cs, float ch, int tileSize, int walkableClimb,
- unsigned char** outData, int* outDataSize);
-
-#endif // DETOURTILEDNAVMESHBUILDER_H \ No newline at end of file
diff --git a/extern/recastnavigation/Detour/Source/DetourCommon.cpp b/extern/recastnavigation/Detour/Source/DetourCommon.cpp
deleted file mode 100644
index e55ce5e6351..00000000000
--- a/extern/recastnavigation/Detour/Source/DetourCommon.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 <math.h>
-#include "DetourCommon.h"
-
-void closestPtPointTriangle(float* closest, const float* p,
- const float* a, const float* b, const float* c)
-{
- // Check if P in vertex region outside A
- float ab[3], ac[3], ap[3];
- vsub(ab, b, a);
- vsub(ac, c, a);
- vsub(ap, p, a);
- float d1 = vdot(ab, ap);
- float d2 = vdot(ac, ap);
- if (d1 <= 0.0f && d2 <= 0.0f)
- {
- // barycentric coordinates (1,0,0)
- vcopy(closest, a);
- return;
- }
-
- // Check if P in vertex region outside B
- float bp[3];
- vsub(bp, p, b);
- float d3 = vdot(ab, bp);
- float d4 = vdot(ac, bp);
- if (d3 >= 0.0f && d4 <= d3)
- {
- // barycentric coordinates (0,1,0)
- vcopy(closest, b);
- return;
- }
-
- // Check if P in edge region of AB, if so return projection of P onto AB
- float vc = d1*d4 - d3*d2;
- if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f)
- {
- // barycentric coordinates (1-v,v,0)
- float v = d1 / (d1 - d3);
- closest[0] = a[0] + v * ab[0];
- closest[1] = a[1] + v * ab[1];
- closest[2] = a[2] + v * ab[2];
- return;
- }
-
- // Check if P in vertex region outside C
- float cp[3];
- vsub(cp, p, c);
- float d5 = vdot(ab, cp);
- float d6 = vdot(ac, cp);
- if (d6 >= 0.0f && d5 <= d6)
- {
- // barycentric coordinates (0,0,1)
- vcopy(closest, c);
- return;
- }
-
- // Check if P in edge region of AC, if so return projection of P onto AC
- float vb = d5*d2 - d1*d6;
- if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f)
- {
- // barycentric coordinates (1-w,0,w)
- float w = d2 / (d2 - d6);
- closest[0] = a[0] + w * ac[0];
- closest[1] = a[1] + w * ac[1];
- closest[2] = a[2] + w * ac[2];
- return;
- }
-
- // Check if P in edge region of BC, if so return projection of P onto BC
- float va = d3*d6 - d5*d4;
- if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f)
- {
- // barycentric coordinates (0,1-w,w)
- float w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
- closest[0] = b[0] + w * (c[0] - b[0]);
- closest[1] = b[1] + w * (c[1] - b[1]);
- closest[2] = b[2] + w * (c[2] - b[2]);
- return;
- }
-
- // P inside face region. Compute Q through its barycentric coordinates (u,v,w)
- float denom = 1.0f / (va + vb + vc);
- float v = vb * denom;
- float w = vc * denom;
- closest[0] = a[0] + ab[0] * v + ac[0] * w;
- closest[1] = a[1] + ab[1] * v + ac[1] * w;
- closest[2] = a[2] + ab[2] * v + ac[2] * w;
-}
-
-bool intersectSegmentPoly2D(const float* p0, const float* p1,
- const float* verts, int nverts,
- float& tmin, float& tmax,
- int& segMin, int& segMax)
-{
- static const float EPS = 0.00000001f;
-
- tmin = 0;
- tmax = 1;
- segMin = -1;
- segMax = -1;
-
- float dir[3];
- vsub(dir, p1, p0);
-
- for (int i = 0, j = nverts-1; i < nverts; j=i++)
- {
- float edge[3], diff[3];
- vsub(edge, &verts[i*3], &verts[j*3]);
- vsub(diff, p0, &verts[j*3]);
- float n = vperp2D(edge, diff);
- float d = -vperp2D(edge, dir);
- if (fabs(d) < EPS)
- {
- // S is nearly parallel to this edge
- if (n < 0)
- return false;
- else
- continue;
- }
- float t = n / d;
- if (d < 0)
- {
- // segment S is entering across this edge
- if (t > tmin)
- {
- tmin = t;
- segMin = j;
- // S enters after leaving polygon
- if (tmin > tmax)
- return false;
- }
- }
- else
- {
- // segment S is leaving across this edge
- if (t < tmax)
- {
- tmax = t;
- segMax = j;
- // S leaves before entering polygon
- if (tmax < tmin)
- return false;
- }
- }
- }
-
- return true;
-}
-
-float distancePtSegSqr2D(const float* pt, const float* p, const float* q, float& t)
-{
- float pqx = q[0] - p[0];
- float pqz = q[2] - p[2];
- float dx = pt[0] - p[0];
- float dz = pt[2] - p[2];
- float d = pqx*pqx + pqz*pqz;
- t = pqx*dx + pqz*dz;
- if (d > 0)
- t /= d;
- if (t < 0)
- t = 0;
- else if (t > 1)
- t = 1;
-
- dx = p[0] + t*pqx - pt[0];
- dz = p[2] + t*pqz - pt[2];
-
- return dx*dx + dz*dz;
-}
-
-void calcPolyCenter(float* tc, const unsigned short* idx, int nidx, const float* verts)
-{
- tc[0] = 0.0f;
- tc[1] = 0.0f;
- tc[2] = 0.0f;
- for (int j = 0; j < nidx; ++j)
- {
- const float* v = &verts[idx[j]*3];
- tc[0] += v[0];
- tc[1] += v[1];
- tc[2] += v[2];
- }
- const float s = 1.0f / nidx;
- tc[0] *= s;
- tc[1] *= s;
- tc[2] *= s;
-}
-
-inline float vdot2(const float* a, const float* b)
-{
- return a[0]*b[0] + a[2]*b[2];
-}
-
-#include <stdio.h>
-
-bool closestHeightPointTriangle(const float* p, const float* a, const float* b, const float* c, float& h)
-{
- float v0[3], v1[3], v2[3];
- vsub(v0, c,a);
- vsub(v1, b,a);
- vsub(v2, p,a);
-
- const float dot00 = vdot2(v0, v0);
- const float dot01 = vdot2(v0, v1);
- const float dot02 = vdot2(v0, v2);
- const float dot11 = vdot2(v1, v1);
- const float dot12 = vdot2(v1, v2);
-
- // Compute barycentric coordinates
- float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01);
- float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
- float v = (dot00 * dot12 - dot01 * dot02) * invDenom;
-
- // The (sloppy) epsilon is needed to allow to get height of points which
- // are interpolated along the edges of the triangles.
- static const float EPS = 1e-4f;
-
- // If point lies inside the triangle, return interpolated ycoord.
- if (u >= -EPS && v >= -EPS && (u+v) <= 1+EPS)
- {
- h = a[1] + v0[1]*u + v1[1]*v;
- return true;
- }
-
- return false;
-}
diff --git a/extern/recastnavigation/Detour/Source/DetourNode.cpp b/extern/recastnavigation/Detour/Source/DetourNode.cpp
deleted file mode 100644
index 1a2305fcede..00000000000
--- a/extern/recastnavigation/Detour/Source/DetourNode.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 "DetourNode.h"
-#include <string.h>
-
-//////////////////////////////////////////////////////////////////////////////////////////
-dtNodePool::dtNodePool(int maxNodes, int hashSize) :
-
- m_nodes(0),
- m_first(0),
- m_next(0),
- m_maxNodes(maxNodes),
- m_hashSize(hashSize),
- m_nodeCount(0)
-{
- m_nodes = new dtNode[m_maxNodes];
- m_next = new unsigned short[m_maxNodes];
- m_first = new unsigned short[hashSize];
- memset(m_first, 0xff, sizeof(unsigned short)*m_hashSize);
- memset(m_next, 0xff, sizeof(unsigned short)*m_maxNodes);
-}
-
-dtNodePool::~dtNodePool()
-{
- delete [] m_nodes;
- delete [] m_next;
- delete [] m_first;
-}
-
-void dtNodePool::clear()
-{
- memset(m_first, 0xff, sizeof(unsigned short)*m_hashSize);
- m_nodeCount = 0;
-}
-
-const dtNode* dtNodePool::findNode(unsigned int id) const
-{
- unsigned int bucket = hashint(id) & (m_hashSize-1);
- unsigned short i = m_first[bucket];
- while (i != 0xffff)
- {
- if (m_nodes[i].id == id)
- return &m_nodes[i];
- i = m_next[i];
- }
- return 0;
-}
-
-dtNode* dtNodePool::getNode(unsigned int id)
-{
- unsigned int bucket = hashint(id) & (m_hashSize-1);
- unsigned short i = m_first[bucket];
- dtNode* node = 0;
- while (i != 0xffff)
- {
- if (m_nodes[i].id == id)
- return &m_nodes[i];
- i = m_next[i];
- }
-
- if (m_nodeCount >= m_maxNodes)
- return 0;
-
- i = (unsigned short)m_nodeCount;
- m_nodeCount++;
-
- // Init node
- node = &m_nodes[i];
- node->pidx = 0;
- node->cost = 0;
- node->total = 0;
- node->id = id;
- node->flags = 0;
-
- m_next[i] = m_first[bucket];
- m_first[bucket] = i;
-
- return node;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////////
-dtNodeQueue::dtNodeQueue(int n) :
- m_heap(0),
- m_capacity(n),
- m_size(0)
-{
- m_heap = new dtNode*[m_capacity+1];
-}
-
-dtNodeQueue::~dtNodeQueue()
-{
- delete [] m_heap;
-}
-
-void dtNodeQueue::bubbleUp(int i, dtNode* node)
-{
- int parent = (i-1)/2;
- // note: (index > 0) means there is a parent
- while ((i > 0) && (m_heap[parent]->total > node->total))
- {
- m_heap[i] = m_heap[parent];
- i = parent;
- parent = (i-1)/2;
- }
- m_heap[i] = node;
-}
-
-void dtNodeQueue::trickleDown(int i, dtNode* node)
-{
- int child = (i*2)+1;
- while (child < m_size)
- {
- if (((child+1) < m_size) &&
- (m_heap[child]->total > m_heap[child+1]->total))
- {
- child++;
- }
- m_heap[i] = m_heap[child];
- i = child;
- child = (i*2)+1;
- }
- bubbleUp(i, node);
-}
diff --git a/extern/recastnavigation/Detour/Source/DetourStatNavMesh.cpp b/extern/recastnavigation/Detour/Source/DetourStatNavMesh.cpp
deleted file mode 100644
index a02211816a2..00000000000
--- a/extern/recastnavigation/Detour/Source/DetourStatNavMesh.cpp
+++ /dev/null
@@ -1,876 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 <math.h>
-#include <float.h>
-#include <string.h>
-#include <stdio.h>
-#include "DetourStatNavMesh.h"
-#include "DetourNode.h"
-#include "DetourCommon.h"
-
-
-//////////////////////////////////////////////////////////////////////////////////////////
-dtStatNavMesh::dtStatNavMesh() :
- m_data(0),
- m_dataSize(0),
- m_header(0),
- m_nodePool(0),
- m_openList(0)
-{
-}
-
-dtStatNavMesh::~dtStatNavMesh()
-{
- delete m_nodePool;
- delete m_openList;
- if (m_data)
- delete [] m_data;
-}
-
-bool dtStatNavMesh::init(unsigned char* data, int dataSize, bool ownsData)
-{
- dtStatNavMeshHeader* header = (dtStatNavMeshHeader*)data;
-
- if (header->magic != DT_STAT_NAVMESH_MAGIC)
- return false;
- if (header->version != DT_STAT_NAVMESH_VERSION)
- return false;
-
- const int headerSize = sizeof(dtStatNavMeshHeader);
- const int vertsSize = sizeof(float)*3*header->nverts;
- const int polysSize = sizeof(dtStatPoly)*header->npolys;
- const int nodesSize = sizeof(dtStatBVNode)*header->npolys*2;
- const int detailMeshesSize = sizeof(dtStatPolyDetail)*header->ndmeshes;
- const int detailVertsSize = sizeof(float)*3*header->ndverts;
- const int detailTrisSize = sizeof(unsigned char)*4*header->ndtris;
-
-
- unsigned char* d = data + headerSize;
- header->verts = (float*)d; d += vertsSize;
- header->polys = (dtStatPoly*)d; d += polysSize;
- header->bvtree = (dtStatBVNode*)d; d += nodesSize;
- header->dmeshes = (dtStatPolyDetail*)d; d += detailMeshesSize;
- header->dverts = (float*)d; d += detailVertsSize;
- header->dtris = (unsigned char*)d; d += detailTrisSize;
-
- m_nodePool = new dtNodePool(2048, 256);
- if (!m_nodePool)
- return false;
-
- m_openList = new dtNodeQueue(2048);
- if (!m_openList)
- return false;
-
- if (ownsData)
- {
- m_data = data;
- m_dataSize = dataSize;
- }
-
- m_header = header;
-
- return true;
-}
-
-const dtStatPoly* dtStatNavMesh::getPolyByRef(dtStatPolyRef ref) const
-{
- if (!m_header || ref == 0 || (int)ref > m_header->npolys) return 0;
- return &m_header->polys[ref-1];
-}
-
-int dtStatNavMesh::getPolyIndexByRef(dtStatPolyRef ref) const
-{
- if (!m_header || ref == 0 || (int)ref > m_header->npolys) return -1;
- return (int)ref-1;
-}
-
-int dtStatNavMesh::findPath(dtStatPolyRef startRef, dtStatPolyRef endRef,
- const float* startPos, const float* endPos,
- dtStatPolyRef* path, const int maxPathSize)
-{
- if (!m_header) return 0;
-
- if (!startRef || !endRef)
- return 0;
-
- if (!maxPathSize)
- return 0;
-
- if (startRef == endRef)
- {
- path[0] = startRef;
- return 1;
- }
-
- m_nodePool->clear();
- m_openList->clear();
-
- static const float H_SCALE = 1.1f; // Heuristic scale.
-
- dtNode* startNode = m_nodePool->getNode(startRef);
- startNode->pidx = 0;
- startNode->cost = 0;
- startNode->total = vdist(startPos, endPos) * H_SCALE;
- startNode->id = startRef;
- startNode->flags = DT_NODE_OPEN;
- m_openList->push(startNode);
-
- dtNode* lastBestNode = startNode;
- float lastBestNodeCost = startNode->total;
- while (!m_openList->empty())
- {
- dtNode* bestNode = m_openList->pop();
-
- if (bestNode->id == endRef)
- {
- lastBestNode = bestNode;
- break;
- }
-
- const dtStatPoly* poly = getPoly(bestNode->id-1);
- for (int i = 0; i < (int)poly->nv; ++i)
- {
- dtStatPolyRef neighbour = poly->n[i];
- if (neighbour)
- {
- // Skip parent node.
- if (bestNode->pidx && m_nodePool->getNodeAtIdx(bestNode->pidx)->id == neighbour)
- continue;
-
- dtNode* parent = bestNode;
- dtNode newNode;
- newNode.pidx = m_nodePool->getNodeIdx(parent);
- newNode.id = neighbour;
-
- // Calculate cost.
- float p0[3], p1[3];
- if (!parent->pidx)
- vcopy(p0, startPos);
- else
- getEdgeMidPoint(m_nodePool->getNodeAtIdx(parent->pidx)->id, parent->id, p0);
- getEdgeMidPoint(parent->id, newNode.id, p1);
- newNode.cost = parent->cost + vdist(p0,p1);
- // Special case for last node.
- if (newNode.id == endRef)
- newNode.cost += vdist(p1, endPos);
-
- // Heuristic
- const float h = vdist(p1,endPos)*H_SCALE;
- newNode.total = newNode.cost + h;
-
- dtNode* actualNode = m_nodePool->getNode(newNode.id);
- if (!actualNode)
- continue;
-
- if (!((actualNode->flags & DT_NODE_OPEN) && newNode.total > actualNode->total) &&
- !((actualNode->flags & DT_NODE_CLOSED) && newNode.total > actualNode->total))
- {
- actualNode->flags &= ~DT_NODE_CLOSED;
- actualNode->pidx = newNode.pidx;
- actualNode->cost = newNode.cost;
- actualNode->total = newNode.total;
-
- if (h < lastBestNodeCost)
- {
- lastBestNodeCost = h;
- lastBestNode = actualNode;
- }
-
- if (actualNode->flags & DT_NODE_OPEN)
- {
- m_openList->modify(actualNode);
- }
- else
- {
- actualNode->flags |= DT_NODE_OPEN;
- m_openList->push(actualNode);
- }
- }
- }
- }
- bestNode->flags |= DT_NODE_CLOSED;
- }
-
- // Reverse the path.
- dtNode* prev = 0;
- dtNode* node = lastBestNode;
- do
- {
- dtNode* next = m_nodePool->getNodeAtIdx(node->pidx);
- node->pidx = m_nodePool->getNodeIdx(prev);
- prev = node;
- node = next;
- }
- while (node);
-
- // Store path
- node = prev;
- int n = 0;
- do
- {
- path[n++] = node->id;
- node = m_nodePool->getNodeAtIdx(node->pidx);
- }
- while (node && n < maxPathSize);
-
- return n;
-}
-
-bool dtStatNavMesh::closestPointToPoly(dtStatPolyRef ref, const float* pos, float* closest) const
-{
- int idx = getPolyIndexByRef(ref);
- if (idx == -1)
- return false;
-
- float closestDistSqr = FLT_MAX;
- const dtStatPoly* p = getPoly(idx);
- const dtStatPolyDetail* pd = getPolyDetail(idx);
-
- for (int j = 0; j < pd->ntris; ++j)
- {
- const unsigned char* t = getDetailTri(pd->tbase+j);
- const float* v[3];
- for (int k = 0; k < 3; ++k)
- {
- if (t[k] < p->nv)
- v[k] = getVertex(p->v[t[k]]);
- else
- v[k] = getDetailVertex(pd->vbase+(t[k]-p->nv));
- }
- float pt[3];
- closestPtPointTriangle(pt, pos, v[0], v[1], v[2]);
- float d = vdistSqr(pos, pt);
- if (d < closestDistSqr)
- {
- vcopy(closest, pt);
- closestDistSqr = d;
- }
- }
-
- return true;
-}
-
-bool dtStatNavMesh::getPolyHeight(dtStatPolyRef ref, const float* pos, float* height) const
-{
- int idx = getPolyIndexByRef(ref);
- if (idx == -1)
- return false;
-
- const dtStatPoly* p = getPoly(idx);
- const dtStatPolyDetail* pd = getPolyDetail(idx);
-
- for (int i = 0; i < pd->ntris; ++i)
- {
- const unsigned char* t = getDetailTri(pd->tbase+i);
- const float* v[3];
- for (int j = 0; j < 3; ++j)
- {
- if (t[j] < p->nv)
- v[j] = getVertex(p->v[t[j]]);
- else
- v[j] = getDetailVertex(pd->vbase+(t[j]-p->nv));
- }
- float h;
- if (closestHeightPointTriangle(pos, v[0], v[1], v[2], h))
- {
- if (height)
- *height = h;
- return true;
- }
- }
-
- return false;
-}
-
-int dtStatNavMesh::findStraightPath(const float* startPos, const float* endPos,
- const dtStatPolyRef* path, const int pathSize,
- float* straightPath, const int maxStraightPathSize)
-{
- if (!m_header) return 0;
-
- if (!maxStraightPathSize)
- return 0;
-
- if (!path[0])
- return 0;
-
- int straightPathSize = 0;
-
- float closestStartPos[3];
- if (!closestPointToPoly(path[0], startPos, closestStartPos))
- return 0;
-
- // Add start point.
- vcopy(&straightPath[straightPathSize*3], closestStartPos);
- straightPathSize++;
- if (straightPathSize >= maxStraightPathSize)
- return straightPathSize;
-
- float closestEndPos[3];
- if (!closestPointToPoly(path[pathSize-1], endPos, closestEndPos))
- return 0;
-
- float portalApex[3], portalLeft[3], portalRight[3];
-
- if (pathSize > 1)
- {
- vcopy(portalApex, closestStartPos);
- vcopy(portalLeft, portalApex);
- vcopy(portalRight, portalApex);
- int apexIndex = 0;
- int leftIndex = 0;
- int rightIndex = 0;
-
- for (int i = 0; i < pathSize; ++i)
- {
- float left[3], right[3];
- if (i < pathSize-1)
- {
- // Next portal.
- getPortalPoints(path[i], path[i+1], left, right);
- }
- else
- {
- // End of the path.
- vcopy(left, closestEndPos);
- vcopy(right, closestEndPos);
- }
-
- // Right vertex.
- if (vequal(portalApex, portalRight))
- {
- vcopy(portalRight, right);
- rightIndex = i;
- }
- else
- {
- if (triArea2D(portalApex, portalRight, right) <= 0.0f)
- {
- if (triArea2D(portalApex, portalLeft, right) > 0.0f)
- {
- vcopy(portalRight, right);
- rightIndex = i;
- }
- else
- {
- vcopy(portalApex, portalLeft);
- apexIndex = leftIndex;
-
- if (!vequal(&straightPath[(straightPathSize-1)*3], portalApex))
- {
- vcopy(&straightPath[straightPathSize*3], portalApex);
- straightPathSize++;
- if (straightPathSize >= maxStraightPathSize)
- return straightPathSize;
- }
-
- vcopy(portalLeft, portalApex);
- vcopy(portalRight, portalApex);
- leftIndex = apexIndex;
- rightIndex = apexIndex;
-
- // Restart
- i = apexIndex;
-
- continue;
- }
- }
- }
-
- // Left vertex.
- if (vequal(portalApex, portalLeft))
- {
- vcopy(portalLeft, left);
- leftIndex = i;
- }
- else
- {
- if (triArea2D(portalApex, portalLeft, left) >= 0.0f)
- {
- if (triArea2D(portalApex, portalRight, left) < 0.0f)
- {
- vcopy(portalLeft, left);
- leftIndex = i;
- }
- else
- {
- vcopy(portalApex, portalRight);
- apexIndex = rightIndex;
-
- if (!vequal(&straightPath[(straightPathSize-1)*3], portalApex))
- {
- vcopy(&straightPath[straightPathSize*3], portalApex);
- straightPathSize++;
- if (straightPathSize >= maxStraightPathSize)
- return straightPathSize;
- }
-
- vcopy(portalLeft, portalApex);
- vcopy(portalRight, portalApex);
- leftIndex = apexIndex;
- rightIndex = apexIndex;
-
- // Restart
- i = apexIndex;
-
- continue;
- }
- }
- }
- }
- }
-
- // Add end point.
- vcopy(&straightPath[straightPathSize*3], closestEndPos);
- straightPathSize++;
-
- return straightPathSize;
-}
-
-int dtStatNavMesh::getPolyVerts(dtStatPolyRef ref, float* verts) const
-{
- if (!m_header) return 0;
- const dtStatPoly* poly = getPolyByRef(ref);
- if (!poly) return 0;
- float* v = verts;
- for (int i = 0; i < (int)poly->nv; ++i)
- {
- const float* cv = &m_header->verts[poly->v[i]*3];
- *v++ = cv[0];
- *v++ = cv[1];
- *v++ = cv[2];
- }
- return (int)poly->nv;
-}
-
-int dtStatNavMesh::raycast(dtStatPolyRef centerRef, const float* startPos, const float* endPos,
- float& t, dtStatPolyRef* path, const int pathSize)
-{
- if (!m_header) return 0;
- if (!centerRef) return 0;
-
- /* dtStatPolyRef prevRef = centerRef; */ /* UNUSED */
- dtStatPolyRef curRef = centerRef;
- t = 0;
-
- float verts[DT_STAT_VERTS_PER_POLYGON*3];
- int n = 0;
-
- while (curRef)
- {
- // Cast ray against current polygon.
- int nv = getPolyVerts(curRef, verts);
- if (nv < 3)
- {
- // Hit bad polygon, report hit.
- return n;
- }
-
- float tmin, tmax;
- int segMin, segMax;
- if (!intersectSegmentPoly2D(startPos, endPos, verts, nv, tmin, tmax, segMin, segMax))
- {
- // Could not a polygon, keep the old t and report hit.
- return n;
- }
- // Keep track of furthest t so far.
- if (tmax > t)
- t = tmax;
-
- if (n < pathSize)
- path[n++] = curRef;
-
- // Check the neighbour of this polygon.
- const dtStatPoly* poly = getPolyByRef(curRef);
- dtStatPolyRef nextRef = poly->n[segMax];
- if (!nextRef)
- {
- // No neighbour, we hit a wall.
- return n;
- }
-
- // No hit, advance to neighbour polygon.
- /* prevRef = curRef; */ /* UNUSED */
- curRef = nextRef;
- }
-
- return n;
-}
-
-
-float dtStatNavMesh::findDistanceToWall(dtStatPolyRef centerRef, const float* centerPos, float maxRadius,
- float* hitPos, float* hitNormal)
-{
- if (!m_header) return 0;
- if (!centerRef) return 0;
-
- m_nodePool->clear();
- m_openList->clear();
-
- dtNode* startNode = m_nodePool->getNode(centerRef);
- startNode->pidx = 0;
- startNode->cost = 0;
- startNode->total = 0;
- startNode->id = centerRef;
- startNode->flags = DT_NODE_OPEN;
- m_openList->push(startNode);
-
- float radiusSqr = sqr(maxRadius);
-
- hitNormal[0] = 1;
- hitNormal[1] = 0;
- hitNormal[2] = 0;
-
- while (!m_openList->empty())
- {
- dtNode* bestNode = m_openList->pop();
- const dtStatPoly* poly = getPoly(bestNode->id-1);
-
- // Hit test walls.
- for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++)
- {
- // Skip non-solid edges.
- if (poly->n[j]) continue;
-
- // Calc distance to the edge.
- const float* vj = getVertex(poly->v[j]);
- const float* vi = getVertex(poly->v[i]);
- float tseg;
- float distSqr = distancePtSegSqr2D(centerPos, vj, vi, tseg);
-
- // Edge is too far, skip.
- if (distSqr > radiusSqr)
- continue;
-
- // Hit wall, update radius.
- radiusSqr = distSqr;
- // Calculate hit pos.
- hitPos[0] = vj[0] + (vi[0] - vj[0])*tseg;
- hitPos[1] = vj[1] + (vi[1] - vj[1])*tseg;
- hitPos[2] = vj[2] + (vi[2] - vj[2])*tseg;
- }
-
- // Check to see if the circle expands to one of the neighbours and expand.
- for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++)
- {
- // Skip solid edges.
- if (!poly->n[j]) continue;
-
- // Expand to neighbour if not visited yet.
- dtStatPolyRef neighbour = poly->n[j];
-
- // Skip parent node.
- if (bestNode->pidx && m_nodePool->getNodeAtIdx(bestNode->pidx)->id == neighbour)
- continue;
-
- // Calc distance to the edge.
- const float* vj = getVertex(poly->v[j]);
- const float* vi = getVertex(poly->v[i]);
- float tseg;
- float distSqr = distancePtSegSqr2D(centerPos, vj, vi, tseg);
-
- // Edge is too far, skip.
- if (distSqr > radiusSqr)
- continue;
-
- dtNode* parent = bestNode;
- dtNode newNode;
- newNode.pidx = m_nodePool->getNodeIdx(parent);
- newNode.id = neighbour;
-
- // Cost
- float p0[3], p1[3];
- if (!parent->pidx)
- vcopy(p0, centerPos);
- else
- getEdgeMidPoint(m_nodePool->getNodeAtIdx(parent->pidx)->id, parent->id, p0);
- getEdgeMidPoint(parent->id, newNode.id, p1);
- newNode.total = parent->total + vdist(p0,p1);
-
- dtNode* actualNode = m_nodePool->getNode(newNode.id);
- if (!actualNode)
- continue;
-
- if (!((actualNode->flags & DT_NODE_OPEN) && newNode.total > actualNode->total) &&
- !((actualNode->flags & DT_NODE_CLOSED) && newNode.total > actualNode->total))
- {
- actualNode->flags &= ~DT_NODE_CLOSED;
- actualNode->pidx = newNode.pidx;
- actualNode->total = newNode.total;
-
- if (actualNode->flags & DT_NODE_OPEN)
- {
- m_openList->modify(actualNode);
- }
- else
- {
- actualNode->flags |= DT_NODE_OPEN;
- m_openList->push(actualNode);
- }
- }
- }
- bestNode->flags |= DT_NODE_CLOSED;
- }
-
- // Calc hit normal.
- vsub(hitNormal, centerPos, hitPos);
- vnormalize(hitNormal);
-
- return sqrtf(radiusSqr);
-}
-
-int dtStatNavMesh::findPolysAround(dtStatPolyRef centerRef, const float* centerPos, float radius,
- dtStatPolyRef* resultRef, dtStatPolyRef* resultParent, float* resultCost,
- const int maxResult)
-{
- if (!m_header) return 0;
- if (!centerRef) return 0;
-
- m_nodePool->clear();
- m_openList->clear();
-
- dtNode* startNode = m_nodePool->getNode(centerRef);
- startNode->pidx = 0;
- startNode->cost = 0;
- startNode->total = 0;
- startNode->id = centerRef;
- startNode->flags = DT_NODE_OPEN;
- m_openList->push(startNode);
-
- int n = 0;
- if (n < maxResult)
- {
- if (resultRef)
- resultRef[n] = startNode->id;
- if (resultParent)
- resultParent[n] = 0;
- if (resultCost)
- resultCost[n] = 0;
- ++n;
- }
-
- const float radiusSqr = sqr(radius);
-
- while (!m_openList->empty())
- {
- dtNode* bestNode = m_openList->pop();
- const dtStatPoly* poly = getPoly(bestNode->id-1);
- for (unsigned i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j=i++)
- {
- dtStatPolyRef neighbour = poly->n[j];
-
- if (neighbour)
- {
- // Skip parent node.
- if (bestNode->pidx && m_nodePool->getNodeAtIdx(bestNode->pidx)->id == neighbour)
- continue;
-
- // Calc distance to the edge.
- const float* vj = getVertex(poly->v[j]);
- const float* vi = getVertex(poly->v[i]);
- float tseg;
- float distSqr = distancePtSegSqr2D(centerPos, vj, vi, tseg);
-
- // If the circle is not touching the next polygon, skip it.
- if (distSqr > radiusSqr)
- continue;
-
- dtNode* parent = bestNode;
- dtNode newNode;
- newNode.pidx = m_nodePool->getNodeIdx(parent);
- newNode.id = neighbour;
-
- // Cost
- float p0[3], p1[3];
- if (!parent->pidx)
- vcopy(p0, centerPos);
- else
- getEdgeMidPoint(m_nodePool->getNodeAtIdx(parent->pidx)->id, parent->id, p0);
- getEdgeMidPoint(parent->id, newNode.id, p1);
- newNode.total = parent->total + vdist(p0,p1);
-
- dtNode* actualNode = m_nodePool->getNode(newNode.id);
- if (!actualNode)
- continue;
-
- if (!((actualNode->flags & DT_NODE_OPEN) && newNode.total > actualNode->total) &&
- !((actualNode->flags & DT_NODE_CLOSED) && newNode.total > actualNode->total))
- {
- actualNode->flags &= ~DT_NODE_CLOSED;
- actualNode->pidx = newNode.pidx;
- actualNode->total = newNode.total;
-
- if (actualNode->flags & DT_NODE_OPEN)
- {
- m_openList->modify(actualNode);
- }
- else
- {
- if (n < maxResult)
- {
- if (resultRef)
- resultRef[n] = actualNode->id;
- if (resultParent)
- resultParent[n] = m_nodePool->getNodeAtIdx(actualNode->pidx)->id;
- if (resultCost)
- resultCost[n] = actualNode->total;
- ++n;
- }
- actualNode->flags |= DT_NODE_OPEN;
- m_openList->push(actualNode);
- }
- }
- }
- }
- bestNode->flags |= DT_NODE_CLOSED;
-
- }
-
- return n;
-}
-
-// Returns polygons which are withing certain radius from the query location.
-int dtStatNavMesh::queryPolygons(const float* center, const float* extents,
- dtStatPolyRef* polys, const int maxIds)
-{
- if (!m_header) return 0;
-
- const dtStatBVNode* node = &m_header->bvtree[0];
- const dtStatBVNode* end = &m_header->bvtree[m_header->nnodes];
-
- // Calculate quantized box
- const float ics = 1.0f / m_header->cs;
- unsigned short bmin[3], bmax[3];
- // Clamp query box to world box.
- float minx = clamp(center[0] - extents[0], m_header->bmin[0], m_header->bmax[0]) - m_header->bmin[0];
- float miny = clamp(center[1] - extents[1], m_header->bmin[1], m_header->bmax[1]) - m_header->bmin[1];
- float minz = clamp(center[2] - extents[2], m_header->bmin[2], m_header->bmax[2]) - m_header->bmin[2];
- float maxx = clamp(center[0] + extents[0], m_header->bmin[0], m_header->bmax[0]) - m_header->bmin[0];
- float maxy = clamp(center[1] + extents[1], m_header->bmin[1], m_header->bmax[1]) - m_header->bmin[1];
- float maxz = clamp(center[2] + extents[2], m_header->bmin[2], m_header->bmax[2]) - m_header->bmin[2];
- // Quantize
- bmin[0] = (unsigned short)(ics * minx) & 0xfffe;
- bmin[1] = (unsigned short)(ics * miny) & 0xfffe;
- bmin[2] = (unsigned short)(ics * minz) & 0xfffe;
- bmax[0] = (unsigned short)(ics * maxx + 1) | 1;
- bmax[1] = (unsigned short)(ics * maxy + 1) | 1;
- bmax[2] = (unsigned short)(ics * maxz + 1) | 1;
-
- // Traverse tree
- int n = 0;
- while (node < end)
- {
- bool overlap = checkOverlapBox(bmin, bmax, node->bmin, node->bmax);
- bool isLeafNode = node->i >= 0;
-
- if (isLeafNode && overlap)
- {
- if (n < maxIds)
- {
- polys[n] = (dtStatPolyRef)node->i;
- n++;
- }
- }
-
- if (overlap || isLeafNode)
- node++;
- else
- {
- const int escapeIndex = -node->i;
- node += escapeIndex;
- }
- }
-
- return n;
-}
-
-dtStatPolyRef dtStatNavMesh::findNearestPoly(const float* center, const float* extents)
-{
- if (!m_header) return 0;
-
- // Get nearby polygons from proximity grid.
- dtStatPolyRef polys[128];
- int npolys = queryPolygons(center, extents, polys, 128);
-
- // Find nearest polygon amongst the nearby polygons.
- dtStatPolyRef nearest = 0;
- float nearestDistanceSqr = FLT_MAX;
- for (int i = 0; i < npolys; ++i)
- {
- dtStatPolyRef ref = polys[i];
- float closest[3];
- if (!closestPointToPoly(ref, center, closest))
- continue;
- float d = vdistSqr(center, closest);
- if (d < nearestDistanceSqr)
- {
- nearestDistanceSqr = d;
- nearest = ref;
- }
- }
-
- return nearest;
-}
-
-bool dtStatNavMesh::getPortalPoints(dtStatPolyRef from, dtStatPolyRef to, float* left, float* right) const
-{
- const dtStatPoly* fromPoly = getPolyByRef(from);
- if (!fromPoly)
- return false;
-
- // Find common edge between the polygons and returns the segment end points.
- for (unsigned i = 0, j = (int)fromPoly->nv - 1; i < (int)fromPoly->nv; j = i++)
- {
- unsigned short neighbour = fromPoly->n[j];
- if (neighbour == to)
- {
- vcopy(left, getVertex(fromPoly->v[j]));
- vcopy(right, getVertex(fromPoly->v[i]));
- return true;
- }
- }
-
- return false;
-}
-
-bool dtStatNavMesh::getEdgeMidPoint(dtStatPolyRef from, dtStatPolyRef to, float* mid) const
-{
- float left[3], right[3];
- if (!getPortalPoints(from, to, left,right)) return false;
- mid[0] = (left[0]+right[0])*0.5f;
- mid[1] = (left[1]+right[1])*0.5f;
- mid[2] = (left[2]+right[2])*0.5f;
- return true;
-}
-
-bool dtStatNavMesh::isInClosedList(dtStatPolyRef ref) const
-{
- if (!m_nodePool) return false;
- const dtNode* node = m_nodePool->findNode(ref);
- return node && node->flags & DT_NODE_CLOSED;
-}
-
-int dtStatNavMesh::getMemUsed() const
-{
- if (!m_nodePool || ! m_openList)
- return 0;
- return sizeof(*this) + m_dataSize +
- m_nodePool->getMemUsed() +
- m_openList->getMemUsed();
-}
diff --git a/extern/recastnavigation/Detour/Source/DetourStatNavMeshBuilder.cpp b/extern/recastnavigation/Detour/Source/DetourStatNavMeshBuilder.cpp
deleted file mode 100644
index 2ca455fb53d..00000000000
--- a/extern/recastnavigation/Detour/Source/DetourStatNavMeshBuilder.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include "DetourStatNavMesh.h"
-
-struct BVItem
-{
- unsigned short bmin[3];
- unsigned short bmax[3];
- int i;
-};
-
-static int compareItemX(const void* va, const void* vb)
-{
- const BVItem* a = (const BVItem*)va;
- const BVItem* b = (const BVItem*)vb;
- if (a->bmin[0] < b->bmin[0])
- return -1;
- if (a->bmin[0] > b->bmin[0])
- return 1;
- return 0;
-}
-
-static int compareItemY(const void* va, const void* vb)
-{
- const BVItem* a = (const BVItem*)va;
- const BVItem* b = (const BVItem*)vb;
- if (a->bmin[1] < b->bmin[1])
- return -1;
- if (a->bmin[1] > b->bmin[1])
- return 1;
- return 0;
-}
-
-static int compareItemZ(const void* va, const void* vb)
-{
- const BVItem* a = (const BVItem*)va;
- const BVItem* b = (const BVItem*)vb;
- if (a->bmin[2] < b->bmin[2])
- return -1;
- if (a->bmin[2] > b->bmin[2])
- return 1;
- return 0;
-}
-
-static void calcExtends(BVItem* items, int nitems, int imin, int imax,
- unsigned short* bmin, unsigned short* bmax)
-{
- bmin[0] = items[imin].bmin[0];
- bmin[1] = items[imin].bmin[1];
- bmin[2] = items[imin].bmin[2];
-
- bmax[0] = items[imin].bmax[0];
- bmax[1] = items[imin].bmax[1];
- bmax[2] = items[imin].bmax[2];
-
- for (int i = imin+1; i < imax; ++i)
- {
- const BVItem& it = items[i];
- if (it.bmin[0] < bmin[0]) bmin[0] = it.bmin[0];
- if (it.bmin[1] < bmin[1]) bmin[1] = it.bmin[1];
- if (it.bmin[2] < bmin[2]) bmin[2] = it.bmin[2];
-
- if (it.bmax[0] > bmax[0]) bmax[0] = it.bmax[0];
- if (it.bmax[1] > bmax[1]) bmax[1] = it.bmax[1];
- if (it.bmax[2] > bmax[2]) bmax[2] = it.bmax[2];
- }
-}
-
-inline int longestAxis(unsigned short x, unsigned short y, unsigned short z)
-{
- int axis = 0;
- unsigned short maxVal = x;
- if (y > maxVal)
- {
- axis = 1;
- maxVal = y;
- }
- if (z > maxVal)
- {
- axis = 2;
- maxVal = z;
- }
- return axis;
-}
-
-static void subdivide(BVItem* items, int nitems, int imin, int imax, int& curNode, dtStatBVNode* nodes)
-{
- int inum = imax - imin;
- int icur = curNode;
-
- dtStatBVNode& node = nodes[curNode++];
-
- if (inum == 1)
- {
- // Leaf
- node.bmin[0] = items[imin].bmin[0];
- node.bmin[1] = items[imin].bmin[1];
- node.bmin[2] = items[imin].bmin[2];
-
- node.bmax[0] = items[imin].bmax[0];
- node.bmax[1] = items[imin].bmax[1];
- node.bmax[2] = items[imin].bmax[2];
-
- node.i = items[imin].i;
- }
- else
- {
- // Split
- calcExtends(items, nitems, imin, imax, node.bmin, node.bmax);
-
- int axis = longestAxis(node.bmax[0] - node.bmin[0],
- node.bmax[1] - node.bmin[1],
- node.bmax[2] - node.bmin[2]);
-
- if (axis == 0)
- {
- // Sort along x-axis
- qsort(items+imin, inum, sizeof(BVItem), compareItemX);
- }
- else if (axis == 1)
- {
- // Sort along y-axis
- qsort(items+imin, inum, sizeof(BVItem), compareItemY);
- }
- else
- {
- // Sort along z-axis
- qsort(items+imin, inum, sizeof(BVItem), compareItemZ);
- }
-
- int isplit = imin+inum/2;
-
- // Left
- subdivide(items, nitems, imin, isplit, curNode, nodes);
- // Right
- subdivide(items, nitems, isplit, imax, curNode, nodes);
-
- int iescape = curNode - icur;
- // Negative index means escape.
- node.i = -iescape;
- }
-}
-
-/*static*/ int createBVTree(const unsigned short* verts, const int nverts,
- const unsigned short* polys, const int npolys, const int nvp,
- float cs, float ch,
- int nnodes, dtStatBVNode* nodes)
-{
- // Build tree
- BVItem* items = new BVItem[npolys];
- for (int i = 0; i < npolys; i++)
- {
- BVItem& it = items[i];
- it.i = i+1;
- // Calc polygon bounds.
- const unsigned short* p = &polys[i*nvp*2];
- it.bmin[0] = it.bmax[0] = verts[p[0]*3+0];
- it.bmin[1] = it.bmax[1] = verts[p[0]*3+1];
- it.bmin[2] = it.bmax[2] = verts[p[0]*3+2];
-
- for (int j = 1; j < nvp; ++j)
- {
- if (p[j] == 0xffff) break;
- unsigned short x = verts[p[j]*3+0];
- unsigned short y = verts[p[j]*3+1];
- unsigned short z = verts[p[j]*3+2];
-
- if (x < it.bmin[0]) it.bmin[0] = x;
- if (y < it.bmin[1]) it.bmin[1] = y;
- if (z < it.bmin[2]) it.bmin[2] = z;
-
- if (x > it.bmax[0]) it.bmax[0] = x;
- if (y > it.bmax[1]) it.bmax[1] = y;
- if (z > it.bmax[2]) it.bmax[2] = z;
- }
- // Remap y
- it.bmin[1] = (unsigned short)floorf((float)it.bmin[1]*ch/cs);
- it.bmax[1] = (unsigned short)ceilf((float)it.bmax[1]*ch/cs);
- }
-
- int curNode = 0;
- subdivide(items, npolys, 0, npolys, curNode, nodes);
-
- delete [] items;
-
- return curNode;
-}
-
-
-bool dtCreateNavMeshData(const unsigned short* verts, const int nverts,
- const unsigned short* polys, const int npolys, const int nvp,
- const float* bmin, const float* bmax, float cs, float ch,
- const unsigned short* dmeshes, const float* dverts, const int ndverts,
- const unsigned char* dtris, const int ndtris,
- unsigned char** outData, int* outDataSize)
-{
- if (nvp > DT_STAT_VERTS_PER_POLYGON)
- return false;
- if (nverts >= 0xffff)
- return false;
-
- if (!nverts)
- return false;
- if (!npolys)
- return false;
- if (!dmeshes || !dverts || ! dtris)
- return false;
-
- // Find unique detail vertices.
- int uniqueDetailVerts = 0;
- if (dmeshes)
- {
- for (int i = 0; i < npolys; ++i)
- {
- const unsigned short* p = &polys[i*nvp*2];
- int ndv = dmeshes[i*4+1];
- int nv = 0;
- for (int j = 0; j < nvp; ++j)
- {
- if (p[j] == 0xffff) break;
- nv++;
- }
- ndv -= nv;
- uniqueDetailVerts += ndv;
- }
- }
-
- // Calculate data size
- const int headerSize = sizeof(dtStatNavMeshHeader);
- const int vertsSize = sizeof(float)*3*nverts;
- const int polysSize = sizeof(dtStatPoly)*npolys;
- const int nodesSize = sizeof(dtStatBVNode)*npolys*2;
- const int detailMeshesSize = sizeof(dtStatPolyDetail)*npolys;
- const int detailVertsSize = sizeof(float)*3*uniqueDetailVerts;
- const int detailTrisSize = sizeof(unsigned char)*4*ndtris;
-
- const int dataSize = headerSize + vertsSize + polysSize + nodesSize +
- detailMeshesSize + detailVertsSize + detailTrisSize;
- unsigned char* data = new unsigned char[dataSize];
- if (!data)
- return false;
- memset(data, 0, dataSize);
-
- unsigned char* d = data;
- dtStatNavMeshHeader* header = (dtStatNavMeshHeader*)d; d += headerSize;
- float* navVerts = (float*)d; d += vertsSize;
- dtStatPoly* navPolys = (dtStatPoly*)d; d += polysSize;
- dtStatBVNode* navNodes = (dtStatBVNode*)d; d += nodesSize;
- dtStatPolyDetail* navDMeshes = (dtStatPolyDetail*)d; d += detailMeshesSize;
- float* navDVerts = (float*)d; d += detailVertsSize;
- unsigned char* navDTris = (unsigned char*)d; d += detailTrisSize;
-
- // Store header
- header->magic = DT_STAT_NAVMESH_MAGIC;
- header->version = DT_STAT_NAVMESH_VERSION;
- header->npolys = npolys;
- header->nverts = nverts;
- header->cs = cs;
- header->bmin[0] = bmin[0];
- header->bmin[1] = bmin[1];
- header->bmin[2] = bmin[2];
- header->bmax[0] = bmax[0];
- header->bmax[1] = bmax[1];
- header->bmax[2] = bmax[2];
- header->ndmeshes = dmeshes ? npolys : 0;
- header->ndverts = dmeshes ? uniqueDetailVerts : 0;
- header->ndtris = dmeshes ? ndtris : 0;
-
- // Store vertices
- for (int i = 0; i < nverts; ++i)
- {
- const unsigned short* iv = &verts[i*3];
- float* v = &navVerts[i*3];
- v[0] = bmin[0] + iv[0] * cs;
- v[1] = bmin[1] + iv[1] * ch;
- v[2] = bmin[2] + iv[2] * cs;
- }
-
- // Store polygons
- const unsigned short* src = polys;
- for (int i = 0; i < npolys; ++i)
- {
- dtStatPoly* p = &navPolys[i];
- p->nv = 0;
- for (int j = 0; j < nvp; ++j)
- {
- if (src[j] == 0xffff) break;
- p->v[j] = src[j];
- p->n[j] = src[nvp+j]+1;
- p->nv++;
- }
- src += nvp*2;
- }
-
- header->nnodes = createBVTree(verts, nverts, polys, npolys, nvp,
- cs, ch, npolys*2, navNodes);
-
-
- // Store detail meshes and vertices.
- // The nav polygon vertices are stored as the first vertices on each mesh.
- // We compress the mesh data by skipping them and using the navmesh coordinates.
- unsigned short vbase = 0;
- for (int i = 0; i < npolys; ++i)
- {
- dtStatPolyDetail& dtl = navDMeshes[i];
- const int vb = dmeshes[i*4+0];
- const int ndv = dmeshes[i*4+1];
- const int nv = navPolys[i].nv;
- dtl.vbase = vbase;
- dtl.nverts = ndv-nv;
- dtl.tbase = dmeshes[i*4+2];
- dtl.ntris = dmeshes[i*4+3];
- // Copy vertices except the first 'nv' verts which are equal to nav poly verts.
- if (ndv-nv)
- {
- memcpy(&navDVerts[vbase*3], &dverts[(vb+nv)*3], sizeof(float)*3*(ndv-nv));
- vbase += ndv-nv;
- }
- }
- // Store triangles.
- memcpy(navDTris, dtris, sizeof(unsigned char)*4*ndtris);
-
- *outData = data;
- *outDataSize = dataSize;
-
- return true;
-}
diff --git a/extern/recastnavigation/Detour/Source/DetourTileNavMesh.cpp b/extern/recastnavigation/Detour/Source/DetourTileNavMesh.cpp
deleted file mode 100644
index 0813c7755cc..00000000000
--- a/extern/recastnavigation/Detour/Source/DetourTileNavMesh.cpp
+++ /dev/null
@@ -1,1428 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 <math.h>
-#include <float.h>
-#include <string.h>
-#include <stdio.h>
-#include "DetourTileNavMesh.h"
-#include "DetourNode.h"
-#include "DetourCommon.h"
-
-
-inline int opposite(int side) { return (side+2) & 0x3; }
-
-inline bool overlapBoxes(const float* amin, const float* amax,
- const float* bmin, const float* bmax)
-{
- bool overlap = true;
- overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
- overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;
- overlap = (amin[2] > bmax[2] || amax[2] < bmin[2]) ? false : overlap;
- return overlap;
-}
-
-inline bool overlapRects(const float* amin, const float* amax,
- const float* bmin, const float* bmax)
-{
- bool overlap = true;
- overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
- overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;
- return overlap;
-}
-
-static void calcRect(const float* va, const float* vb,
- float* bmin, float* bmax,
- int side, float padx, float pady)
-{
- if ((side&1) == 0)
- {
- bmin[0] = min(va[2],vb[2]) + padx;
- bmin[1] = min(va[1],vb[1]) - pady;
- bmax[0] = max(va[2],vb[2]) - padx;
- bmax[1] = max(va[1],vb[1]) + pady;
- }
- else
- {
- bmin[0] = min(va[0],vb[0]) + padx;
- bmin[1] = min(va[1],vb[1]) - pady;
- bmax[0] = max(va[0],vb[0]) - padx;
- bmax[1] = max(va[1],vb[1]) + pady;
- }
-}
-
-inline int computeTileHash(int x, int y)
-{
- const unsigned int h1 = 0x8da6b343; // Large multiplicative constants;
- const unsigned int h2 = 0xd8163841; // here arbitrarily chosen primes
- unsigned int n = h1 * x + h2 * y;
- return (int)(n & (DT_TILE_LOOKUP_SIZE-1));
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-dtTiledNavMesh::dtTiledNavMesh() :
- m_tileSize(0),
- m_portalHeight(0),
- m_nextFree(0),
- m_tmpLinks(0),
- m_ntmpLinks(0),
- m_nodePool(0),
- m_openList(0)
-{
-}
-
-dtTiledNavMesh::~dtTiledNavMesh()
-{
- for (int i = 0; i < DT_MAX_TILES; ++i)
- {
- if (m_tiles[i].data && m_tiles[i].dataSize < 0)
- {
- delete [] m_tiles[i].data;
- m_tiles[i].data = 0;
- m_tiles[i].dataSize = 0;
- }
- }
- delete [] m_tmpLinks;
- delete m_nodePool;
- delete m_openList;
-}
-
-bool dtTiledNavMesh::init(const float* orig, float tileSize, float portalHeight)
-{
- vcopy(m_orig, orig);
- m_tileSize = tileSize;
- m_portalHeight = portalHeight;
-
- // Init tiles
- memset(m_tiles, 0, sizeof(dtTile)*DT_MAX_TILES);
- memset(m_posLookup, 0, sizeof(dtTile*)*DT_TILE_LOOKUP_SIZE);
- m_nextFree = 0;
- for (int i = DT_MAX_TILES-1; i >= 0; --i)
- {
- m_tiles[i].next = m_nextFree;
- m_nextFree = &m_tiles[i];
- }
-
- if (!m_nodePool)
- {
- m_nodePool = new dtNodePool(2048, 256);
- if (!m_nodePool)
- return false;
- }
-
- if (!m_openList)
- {
- m_openList = new dtNodeQueue(2048);
- if (!m_openList)
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-int dtTiledNavMesh::findConnectingPolys(const float* va, const float* vb,
- dtTile* tile, int side,
- dtTilePolyRef* con, float* conarea, int maxcon)
-{
- if (!tile) return 0;
- dtTileHeader* h = tile->header;
-
- float amin[2], amax[2];
- calcRect(va,vb, amin,amax, side, 0.01f, m_portalHeight);
-
- // Remove links pointing to 'side' and compact the links array.
- float bmin[2], bmax[2];
- unsigned short m = 0x8000 | (unsigned short)side;
- int n = 0;
-
- dtTilePolyRef base = getTileId(tile);
-
- for (int i = 0; i < h->npolys; ++i)
- {
- dtTilePoly* poly = &h->polys[i];
- for (int j = 0; j < poly->nv; ++j)
- {
- // Skip edges which do not point to the right side.
- if (poly->n[j] != m) continue;
- // Check if the segments touch.
- const float* vc = &h->verts[poly->v[j]*3];
- const float* vd = &h->verts[poly->v[(j+1) % (int)poly->nv]*3];
- calcRect(vc,vd, bmin,bmax, side, 0.01f, m_portalHeight);
- if (!overlapRects(amin,amax, bmin,bmax)) continue;
- // Add return value.
- if (n < maxcon)
- {
- conarea[n*2+0] = max(amin[0], bmin[0]);
- conarea[n*2+1] = min(amax[0], bmax[0]);
- con[n] = base | (unsigned int)i;
- n++;
- }
- break;
- }
- }
- return n;
-}
-
-void dtTiledNavMesh::removeExtLinks(dtTile* tile, int side)
-{
- if (!tile) return;
- dtTileHeader* h = tile->header;
-
- // Remove links pointing to 'side' and compact the links array.
- dtTileLink* pool = m_tmpLinks;
- int nlinks = 0;
- for (int i = 0; i < h->npolys; ++i)
- {
- dtTilePoly* poly = &h->polys[i];
- int plinks = nlinks;
- int nplinks = 0;
- for (int j = 0; j < poly->nlinks; ++j)
- {
- dtTileLink* link = &h->links[poly->links+j];
- if ((int)link->side != side)
- {
- if (nlinks < h->maxlinks)
- {
- dtTileLink* dst = &pool[nlinks++];
- memcpy(dst, link, sizeof(dtTileLink));
- nplinks++;
- }
- }
- }
- poly->links = plinks;
- poly->nlinks = nplinks;
- }
- h->nlinks = nlinks;
- if (h->nlinks)
- memcpy(h->links, m_tmpLinks, sizeof(dtTileLink)*nlinks);
-}
-
-void dtTiledNavMesh::buildExtLinks(dtTile* tile, dtTile* target, int side)
-{
- if (!tile) return;
- dtTileHeader* h = tile->header;
-
- // Remove links pointing to 'side' and compact the links array.
- dtTileLink* pool = m_tmpLinks;
- int nlinks = 0;
- for (int i = 0; i < h->npolys; ++i)
- {
- dtTilePoly* poly = &h->polys[i];
- int plinks = nlinks;
- int nplinks = 0;
- // Copy internal and other external links.
- for (int j = 0; j < poly->nlinks; ++j)
- {
- dtTileLink* link = &h->links[poly->links+j];
- if ((int)link->side != side)
- {
- if (nlinks < h->maxlinks)
- {
- dtTileLink* dst = &pool[nlinks++];
- memcpy(dst, link, sizeof(dtTileLink));
- nplinks++;
- }
- }
- }
- // Create new links.
- unsigned short m = 0x8000 | (unsigned short)side;
- for (int j = 0; j < poly->nv; ++j)
- {
- // Skip edges which do not point to the right side.
- if (poly->n[j] != m) continue;
-
- // Create new links
- const float* va = &h->verts[poly->v[j]*3];
- const float* vb = &h->verts[poly->v[(j+1)%(int)poly->nv]*3];
- dtTilePolyRef nei[4];
- float neia[4*2];
- int nnei = findConnectingPolys(va,vb, target, opposite(side), nei,neia,4);
- for (int k = 0; k < nnei; ++k)
- {
- if (nlinks < h->maxlinks)
- {
- dtTileLink* link = &pool[nlinks++];
- link->ref = nei[k];
- link->p = (unsigned short)i;
- link->e = (unsigned char)j;
- link->side = (unsigned char)side;
-
- // Compress portal limits to a byte value.
- if (side == 0 || side == 2)
- {
- const float lmin = min(va[2], vb[2]);
- const float lmax = max(va[2], vb[2]);
- link->bmin = (unsigned char)(clamp((neia[k*2+0]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
- link->bmax = (unsigned char)(clamp((neia[k*2+1]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
- }
- else
- {
- const float lmin = min(va[0], vb[0]);
- const float lmax = max(va[0], vb[0]);
- link->bmin = (unsigned char)(clamp((neia[k*2+0]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
- link->bmax = (unsigned char)(clamp((neia[k*2+1]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
- }
- nplinks++;
- }
- }
- }
-
- poly->links = plinks;
- poly->nlinks = nplinks;
- }
- h->nlinks = nlinks;
- if (h->nlinks)
- memcpy(h->links, m_tmpLinks, sizeof(dtTileLink)*nlinks);
-}
-
-void dtTiledNavMesh::buildIntLinks(dtTile* tile)
-{
- if (!tile) return;
- dtTileHeader* h = tile->header;
-
- dtTilePolyRef base = getTileId(tile);
- dtTileLink* pool = h->links;
- int nlinks = 0;
- for (int i = 0; i < h->npolys; ++i)
- {
- dtTilePoly* poly = &h->polys[i];
- poly->links = nlinks;
- poly->nlinks = 0;
- for (int j = 0; j < poly->nv; ++j)
- {
- // Skip hard and non-internal edges.
- if (poly->n[j] == 0 || (poly->n[j] & 0x8000)) continue;
-
- if (nlinks < h->maxlinks)
- {
- dtTileLink* link = &pool[nlinks++];
- link->ref = base | (unsigned int)(poly->n[j]-1);
- link->p = (unsigned short)i;
- link->e = (unsigned char)j;
- link->side = 0xff;
- link->bmin = link->bmax = 0;
- poly->nlinks++;
- }
- }
- }
- h->nlinks = nlinks;
-}
-
-bool dtTiledNavMesh::addTileAt(int x, int y, unsigned char* data, int dataSize, bool ownsData)
-{
- if (getTileAt(x,y))
- return false;
- // Make sure there is enough space for new tile.
- if (!m_nextFree)
- return false;
- // Make sure the data is in right format.
- dtTileHeader* header = (dtTileHeader*)data;
- if (header->magic != DT_TILE_NAVMESH_MAGIC)
- return false;
- if (header->version != DT_TILE_NAVMESH_VERSION)
- return false;
-
- // Make sure the tmp link array is large enough.
- if (header->maxlinks > m_ntmpLinks)
- {
- m_ntmpLinks = header->maxlinks;
- delete [] m_tmpLinks;
- m_tmpLinks = 0;
- m_tmpLinks = new dtTileLink[m_ntmpLinks];
- }
- if (!m_tmpLinks)
- return false;
-
- // Allocate a tile.
- dtTile* tile = m_nextFree;
- m_nextFree = tile->next;
- tile->next = 0;
-
- // Insert tile into the position lut.
- int h = computeTileHash(x,y);
- tile->next = m_posLookup[h];
- m_posLookup[h] = tile;
-
- // Patch header pointers.
- const int headerSize = sizeof(dtTileHeader);
- const int vertsSize = sizeof(float)*3*header->nverts;
- const int polysSize = sizeof(dtTilePoly)*header->npolys;
- const int linksSize = sizeof(dtTileLink)*(header->maxlinks);
- const int detailMeshesSize = sizeof(dtTilePolyDetail)*header->ndmeshes;
- const int detailVertsSize = sizeof(float)*3*header->ndverts;
- const int detailTrisSize = sizeof(unsigned char)*4*header->ndtris;
-
- unsigned char* d = data + headerSize;
- header->verts = (float*)d; d += vertsSize;
- header->polys = (dtTilePoly*)d; d += polysSize;
- header->links = (dtTileLink*)d; d += linksSize;
- header->dmeshes = (dtTilePolyDetail*)d; d += detailMeshesSize;
- header->dverts = (float*)d; d += detailVertsSize;
- header->dtris = (unsigned char*)d; d += detailTrisSize;
-
- // Init tile.
- tile->header = header;
- tile->x = x;
- tile->y = y;
- tile->data = data;
- tile->dataSize = dataSize;
- tile->ownsData = ownsData;
-
- buildIntLinks(tile);
-
- // Create connections connections.
- for (int i = 0; i < 4; ++i)
- {
- dtTile* nei = getNeighbourTileAt(x,y,i);
- if (nei)
- {
- buildExtLinks(tile, nei, i);
- buildExtLinks(nei, tile, opposite(i));
- }
- }
-
- return true;
-}
-
-dtTile* dtTiledNavMesh::getTileAt(int x, int y)
-{
- // Find tile based on hash.
- int h = computeTileHash(x,y);
- dtTile* tile = m_posLookup[h];
- while (tile)
- {
- if (tile->x == x && tile->y == y)
- return tile;
- tile = tile->next;
- }
- return 0;
-}
-
-dtTile* dtTiledNavMesh::getTile(int i)
-{
- return &m_tiles[i];
-}
-
-const dtTile* dtTiledNavMesh::getTile(int i) const
-{
- return &m_tiles[i];
-}
-
-dtTile* dtTiledNavMesh::getNeighbourTileAt(int x, int y, int side)
-{
- switch (side)
- {
- case 0: x++; break;
- case 1: y++; break;
- case 2: x--; break;
- case 3: y--; break;
- };
- return getTileAt(x,y);
-}
-
-bool dtTiledNavMesh::removeTileAt(int x, int y, unsigned char** data, int* dataSize)
-{
- // Remove tile from hash lookup.
- int h = computeTileHash(x,y);
- dtTile* prev = 0;
- dtTile* tile = m_posLookup[h];
- while (tile)
- {
- if (tile->x == x && tile->y == y)
- {
- if (prev)
- prev->next = tile->next;
- else
- m_posLookup[h] = tile->next;
- break;
- }
- prev = tile;
- tile = tile->next;
- }
- if (!tile)
- return false;
-
- // Remove connections to neighbour tiles.
- for (int i = 0; i < 4; ++i)
- {
- dtTile* nei = getNeighbourTileAt(x,y,i);
- if (!nei) continue;
- removeExtLinks(nei, opposite(i));
- }
-
-
- // Reset tile.
- if (tile->ownsData)
- {
- // Owns data
- delete [] tile->data;
- tile->data = 0;
- tile->dataSize = 0;
- if (data) *data = 0;
- if (dataSize) *dataSize = 0;
- }
- else
- {
- if (data) *data = tile->data;
- if (dataSize) *dataSize = tile->dataSize;
- }
- tile->header = 0;
- tile->x = tile->y = 0;
- tile->salt++;
-
- // Add to free list.
- tile->next = m_nextFree;
- m_nextFree = tile;
-
- return true;
-}
-
-
-
-bool dtTiledNavMesh::closestPointToPoly(dtTilePolyRef ref, const float* pos, float* closest) const
-{
- unsigned int salt, it, ip;
- dtDecodeTileId(ref, salt, it, ip);
- if (it >= DT_MAX_TILES) return false;
- if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false;
- const dtTileHeader* header = m_tiles[it].header;
-
- if (ip >= (unsigned int)header->npolys) return false;
- const dtTilePoly* poly = &header->polys[ip];
-
- float closestDistSqr = FLT_MAX;
- const dtTilePolyDetail* pd = &header->dmeshes[ip];
-
- for (int j = 0; j < pd->ntris; ++j)
- {
- const unsigned char* t = &header->dtris[(pd->tbase+j)*4];
- const float* v[3];
- for (int k = 0; k < 3; ++k)
- {
- if (t[k] < poly->nv)
- v[k] = &header->verts[poly->v[t[k]]*3];
- else
- v[k] = &header->dverts[(pd->vbase+(t[k]-poly->nv))*3];
- }
- float pt[3];
- closestPtPointTriangle(pt, pos, v[0], v[1], v[2]);
- float d = vdistSqr(pos, pt);
- if (d < closestDistSqr)
- {
- vcopy(closest, pt);
- closestDistSqr = d;
- }
- }
-
- return true;
-}
-
-bool dtTiledNavMesh::getPolyHeight(dtTilePolyRef ref, const float* pos, float* height) const
-{
- unsigned int salt, it, ip;
- dtDecodeTileId(ref, salt, it, ip);
- if (it >= DT_MAX_TILES) return false;
- if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false;
- const dtTileHeader* header = m_tiles[it].header;
-
- if (ip >= (unsigned int)header->npolys) return false;
- const dtTilePoly* poly = &header->polys[ip];
-
- const dtTilePolyDetail* pd = &header->dmeshes[ip];
- for (int j = 0; j < pd->ntris; ++j)
- {
- const unsigned char* t = &header->dtris[(pd->tbase+j)*4];
- const float* v[3];
- for (int k = 0; k < 3; ++k)
- {
- if (t[k] < poly->nv)
- v[k] = &header->verts[poly->v[t[k]]*3];
- else
- v[k] = &header->dverts[(pd->vbase+(t[k]-poly->nv))*3];
- }
- float h;
- if (closestHeightPointTriangle(pos, v[0], v[1], v[2], h))
- {
- if (height)
- *height = h;
- return true;
- }
- }
-
- return false;
-}
-
-
-dtTilePolyRef dtTiledNavMesh::findNearestPoly(const float* center, const float* extents)
-{
- // Get nearby polygons from proximity grid.
- dtTilePolyRef polys[128];
- int npolys = queryPolygons(center, extents, polys, 128);
-
- // Find nearest polygon amongst the nearby polygons.
- dtTilePolyRef nearest = 0;
- float nearestDistanceSqr = FLT_MAX;
- for (int i = 0; i < npolys; ++i)
- {
- dtTilePolyRef ref = polys[i];
- float closest[3];
- if (!closestPointToPoly(ref, center, closest))
- continue;
- float d = vdistSqr(center, closest);
- if (d < nearestDistanceSqr)
- {
- nearestDistanceSqr = d;
- nearest = ref;
- }
- }
-
- return nearest;
-}
-
-dtTilePolyRef dtTiledNavMesh::getTileId(dtTile* tile)
-{
- if (!tile) return 0;
- const unsigned int it = tile - m_tiles;
- return dtEncodeTileId(tile->salt, it, 0);
-}
-
-int dtTiledNavMesh::queryTilePolygons(dtTile* tile,
- const float* qmin, const float* qmax,
- dtTilePolyRef* polys, const int maxPolys)
-{
- float bmin[3], bmax[3];
- const dtTileHeader* header = tile->header;
- int n = 0;
- dtTilePolyRef base = getTileId(tile);
- for (int i = 0; i < header->npolys; ++i)
- {
- // Calc polygon bounds.
- dtTilePoly* p = &header->polys[i];
- const float* v = &header->verts[p->v[0]*3];
- vcopy(bmin, v);
- vcopy(bmax, v);
- for (int j = 1; j < p->nv; ++j)
- {
- v = &header->verts[p->v[j]*3];
- vmin(bmin, v);
- vmax(bmax, v);
- }
- if (overlapBoxes(qmin,qmax, bmin,bmax))
- {
- if (n < maxPolys)
- polys[n++] = base | (dtTilePolyRef)i;
- }
- }
- return n;
-}
-
-int dtTiledNavMesh::queryPolygons(const float* center, const float* extents,
- dtTilePolyRef* polys, const int maxPolys)
-{
- float bmin[3], bmax[3];
- bmin[0] = center[0] - extents[0];
- bmin[1] = center[1] - extents[1];
- bmin[2] = center[2] - extents[2];
-
- bmax[0] = center[0] + extents[0];
- bmax[1] = center[1] + extents[1];
- bmax[2] = center[2] + extents[2];
-
- // Find tiles the query touches.
- const int minx = (int)floorf((bmin[0]-m_orig[0]) / m_tileSize);
- const int maxx = (int)ceilf((bmax[0]-m_orig[0]) / m_tileSize);
-
- const int miny = (int)floorf((bmin[2]-m_orig[2]) / m_tileSize);
- const int maxy = (int)ceilf((bmax[2]-m_orig[2]) / m_tileSize);
-
- int n = 0;
- for (int y = miny; y < maxy; ++y)
- {
- for (int x = minx; x < maxx; ++x)
- {
- dtTile* tile = getTileAt(x,y);
- if (!tile) continue;
- n += queryTilePolygons(tile, bmin, bmax, polys+n, maxPolys-n);
- if (n >= maxPolys) return n;
- }
- }
-
- return n;
-}
-
-int dtTiledNavMesh::findPath(dtTilePolyRef startRef, dtTilePolyRef endRef,
- const float* startPos, const float* endPos,
- dtTilePolyRef* path, const int maxPathSize)
-{
- if (!startRef || !endRef)
- return 0;
-
- if (!maxPathSize)
- return 0;
-
- if (!getPolyByRef(startRef) || !getPolyByRef(endRef))
- return 0;
-
- if (startRef == endRef)
- {
- path[0] = startRef;
- return 1;
- }
-
- if (!m_nodePool || !m_openList)
- return 0;
-
- m_nodePool->clear();
- m_openList->clear();
-
- static const float H_SCALE = 1.1f; // Heuristic scale.
-
- dtNode* startNode = m_nodePool->getNode(startRef);
- startNode->pidx = 0;
- startNode->cost = 0;
- startNode->total = vdist(startPos, endPos) * H_SCALE;
- startNode->id = startRef;
- startNode->flags = DT_NODE_OPEN;
- m_openList->push(startNode);
-
- dtNode* lastBestNode = startNode;
- float lastBestNodeCost = startNode->total;
- while (!m_openList->empty())
- {
- dtNode* bestNode = m_openList->pop();
-
- if (bestNode->id == endRef)
- {
- lastBestNode = bestNode;
- break;
- }
-
- // Get poly and tile.
- unsigned int salt, it, ip;
- dtDecodeTileId(bestNode->id, salt, it, ip);
- // The API input has been cheked already, skip checking internal data.
- const dtTileHeader* header = m_tiles[it].header;
- const dtTilePoly* poly = &header->polys[ip];
-
- for (int i = 0; i < poly->nlinks; ++i)
- {
- dtTilePolyRef neighbour = header->links[poly->links+i].ref;
- if (neighbour)
- {
- // Skip parent node.
- if (bestNode->pidx && m_nodePool->getNodeAtIdx(bestNode->pidx)->id == neighbour)
- continue;
-
- dtNode* parent = bestNode;
- dtNode newNode;
- newNode.pidx = m_nodePool->getNodeIdx(parent);
- newNode.id = neighbour;
-
- // Calculate cost.
- float p0[3], p1[3];
- if (!parent->pidx)
- vcopy(p0, startPos);
- else
- getEdgeMidPoint(m_nodePool->getNodeAtIdx(parent->pidx)->id, parent->id, p0);
- getEdgeMidPoint(parent->id, newNode.id, p1);
- newNode.cost = parent->cost + vdist(p0,p1);
- // Special case for last node.
- if (newNode.id == endRef)
- newNode.cost += vdist(p1, endPos);
-
- // Heuristic
- const float h = vdist(p1,endPos)*H_SCALE;
- newNode.total = newNode.cost + h;
-
- dtNode* actualNode = m_nodePool->getNode(newNode.id);
- if (!actualNode)
- continue;
-
- if (!((actualNode->flags & DT_NODE_OPEN) && newNode.total > actualNode->total) &&
- !((actualNode->flags & DT_NODE_CLOSED) && newNode.total > actualNode->total))
- {
- actualNode->flags &= DT_NODE_CLOSED;
- actualNode->pidx = newNode.pidx;
- actualNode->cost = newNode.cost;
- actualNode->total = newNode.total;
-
- if (h < lastBestNodeCost)
- {
- lastBestNodeCost = h;
- lastBestNode = actualNode;
- }
-
- if (actualNode->flags & DT_NODE_OPEN)
- {
- m_openList->modify(actualNode);
- }
- else
- {
- actualNode->flags |= DT_NODE_OPEN;
- m_openList->push(actualNode);
- }
- }
- }
- }
- bestNode->flags |= DT_NODE_CLOSED;
- }
-
- // Reverse the path.
- dtNode* prev = 0;
- dtNode* node = lastBestNode;
- do
- {
- dtNode* next = m_nodePool->getNodeAtIdx(node->pidx);
- node->pidx = m_nodePool->getNodeIdx(prev);
- prev = node;
- node = next;
- }
- while (node);
-
- // Store path
- node = prev;
- int n = 0;
- do
- {
- path[n++] = node->id;
- node = m_nodePool->getNodeAtIdx(node->pidx);
- }
- while (node && n < maxPathSize);
-
- return n;
-}
-
-int dtTiledNavMesh::findStraightPath(const float* startPos, const float* endPos,
- const dtTilePolyRef* path, const int pathSize,
- float* straightPath, const int maxStraightPathSize)
-{
- if (!maxStraightPathSize)
- return 0;
-
- if (!path[0])
- return 0;
-
- int straightPathSize = 0;
-
- float closestStartPos[3];
- if (!closestPointToPoly(path[0], startPos, closestStartPos))
- return 0;
-
- // Add start point.
- vcopy(&straightPath[straightPathSize*3], closestStartPos);
- straightPathSize++;
- if (straightPathSize >= maxStraightPathSize)
- return straightPathSize;
-
- float closestEndPos[3];
- if (!closestPointToPoly(path[pathSize-1], endPos, closestEndPos))
- return 0;
-
- float portalApex[3], portalLeft[3], portalRight[3];
-
- if (pathSize > 1)
- {
- vcopy(portalApex, closestStartPos);
- vcopy(portalLeft, portalApex);
- vcopy(portalRight, portalApex);
- int apexIndex = 0;
- int leftIndex = 0;
- int rightIndex = 0;
-
- for (int i = 0; i < pathSize; ++i)
- {
- float left[3], right[3];
- if (i < pathSize-1)
- {
- // Next portal.
- if (!getPortalPoints(path[i], path[i+1], left, right))
- {
- if (!closestPointToPoly(path[i], endPos, closestEndPos))
- return 0;
- vcopy(&straightPath[straightPathSize*3], closestEndPos);
- straightPathSize++;
- return straightPathSize;
- }
- }
- else
- {
- // End of the path.
- vcopy(left, closestEndPos);
- vcopy(right, closestEndPos);
- }
-
- // Right vertex.
- if (vequal(portalApex, portalRight))
- {
- vcopy(portalRight, right);
- rightIndex = i;
- }
- else
- {
- if (triArea2D(portalApex, portalRight, right) <= 0.0f)
- {
- if (triArea2D(portalApex, portalLeft, right) > 0.0f)
- {
- vcopy(portalRight, right);
- rightIndex = i;
- }
- else
- {
- vcopy(portalApex, portalLeft);
- apexIndex = leftIndex;
-
- if (!vequal(&straightPath[(straightPathSize-1)*3], portalApex))
- {
- vcopy(&straightPath[straightPathSize*3], portalApex);
- straightPathSize++;
- if (straightPathSize >= maxStraightPathSize)
- return straightPathSize;
- }
-
- vcopy(portalLeft, portalApex);
- vcopy(portalRight, portalApex);
- leftIndex = apexIndex;
- rightIndex = apexIndex;
-
- // Restart
- i = apexIndex;
-
- continue;
- }
- }
- }
-
- // Left vertex.
- if (vequal(portalApex, portalLeft))
- {
- vcopy(portalLeft, left);
- leftIndex = i;
- }
- else
- {
- if (triArea2D(portalApex, portalLeft, left) >= 0.0f)
- {
- if (triArea2D(portalApex, portalRight, left) < 0.0f)
- {
- vcopy(portalLeft, left);
- leftIndex = i;
- }
- else
- {
- vcopy(portalApex, portalRight);
- apexIndex = rightIndex;
-
- if (!vequal(&straightPath[(straightPathSize-1)*3], portalApex))
- {
- vcopy(&straightPath[straightPathSize*3], portalApex);
- straightPathSize++;
- if (straightPathSize >= maxStraightPathSize)
- return straightPathSize;
- }
-
- vcopy(portalLeft, portalApex);
- vcopy(portalRight, portalApex);
- leftIndex = apexIndex;
- rightIndex = apexIndex;
-
- // Restart
- i = apexIndex;
-
- continue;
- }
- }
- }
- }
- }
-
- // Add end point.
- vcopy(&straightPath[straightPathSize*3], closestEndPos);
- straightPathSize++;
-
- return straightPathSize;
-}
-
-// Returns portal points between two polygons.
-bool dtTiledNavMesh::getPortalPoints(dtTilePolyRef from, dtTilePolyRef to, float* left, float* right) const
-{
- unsigned int salt, it, ip;
- dtDecodeTileId(from, salt, it, ip);
- if (it >= DT_MAX_TILES) return false;
- if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false;
- if (ip >= (unsigned int)m_tiles[it].header->npolys) return false;
- const dtTileHeader* fromHeader = m_tiles[it].header;
- const dtTilePoly* fromPoly = &fromHeader->polys[ip];
-
- for (int i = 0; i < fromPoly->nlinks; ++i)
- {
- const dtTileLink* link = &fromHeader->links[fromPoly->links+i];
- if (link->ref == to)
- {
- // Find portal vertices.
- const int v0 = fromPoly->v[link->e];
- const int v1 = fromPoly->v[(link->e+1) % fromPoly->nv];
- vcopy(left, &fromHeader->verts[v0*3]);
- vcopy(right, &fromHeader->verts[v1*3]);
- // If the link is at tile boundary, clamp the vertices to
- // the link width.
- if (link->side == 0 || link->side == 2)
- {
- // Unpack portal limits.
- const float smin = min(left[2],right[2]);
- const float smax = max(left[2],right[2]);
- const float s = (smax-smin) / 255.0f;
- const float lmin = smin + link->bmin*s;
- const float lmax = smin + link->bmax*s;
- left[2] = max(left[2],lmin);
- left[2] = min(left[2],lmax);
- right[2] = max(right[2],lmin);
- right[2] = min(right[2],lmax);
- }
- else if (link->side == 1 || link->side == 3)
- {
- // Unpack portal limits.
- const float smin = min(left[0],right[0]);
- const float smax = max(left[0],right[0]);
- const float s = (smax-smin) / 255.0f;
- const float lmin = smin + link->bmin*s;
- const float lmax = smin + link->bmax*s;
- left[0] = max(left[0],lmin);
- left[0] = min(left[0],lmax);
- right[0] = max(right[0],lmin);
- right[0] = min(right[0],lmax);
- }
- return true;
- }
- }
- return false;
-}
-
-// Returns edge mid point between two polygons.
-bool dtTiledNavMesh::getEdgeMidPoint(dtTilePolyRef from, dtTilePolyRef to, float* mid) const
-{
- float left[3], right[3];
- if (!getPortalPoints(from, to, left,right)) return false;
- mid[0] = (left[0]+right[0])*0.5f;
- mid[1] = (left[1]+right[1])*0.5f;
- mid[2] = (left[2]+right[2])*0.5f;
- return true;
-}
-
-int dtTiledNavMesh::raycast(dtTilePolyRef centerRef, const float* startPos, const float* endPos,
- float& t, dtTilePolyRef* path, const int pathSize)
-{
- t = 0;
-
- if (!centerRef || !getPolyByRef(centerRef))
- return 0;
-
- dtTilePolyRef curRef = centerRef;
- float verts[DT_TILE_VERTS_PER_POLYGON*3];
- int n = 0;
-
- while (curRef)
- {
- // Cast ray against current polygon.
-
- // The API input has been cheked already, skip checking internal data.
- unsigned int salt, it, ip;
- dtDecodeTileId(curRef, salt, it, ip);
- const dtTileHeader* header = m_tiles[it].header;
- const dtTilePoly* poly = &header->polys[ip];
-
- // Collect vertices.
- int nv = 0;
- for (int i = 0; i < (int)poly->nv; ++i)
- {
- vcopy(&verts[nv*3], &header->verts[poly->v[i]*3]);
- nv++;
- }
- if (nv < 3)
- {
- // Hit bad polygon, report hit.
- return n;
- }
-
- float tmin, tmax;
- int segMin, segMax;
- if (!intersectSegmentPoly2D(startPos, endPos, verts, nv, tmin, tmax, segMin, segMax))
- {
- // Could not hit the polygon, keep the old t and report hit.
- return n;
- }
- // Keep track of furthest t so far.
- if (tmax > t)
- t = tmax;
-
- if (n < pathSize)
- path[n++] = curRef;
-
- // Follow neighbours.
- dtTilePolyRef nextRef = 0;
- for (int i = 0; i < poly->nlinks; ++i)
- {
- const dtTileLink* link = &header->links[poly->links+i];
- if ((int)link->e == segMax)
- {
- // If the link is internal, just return the ref.
- if (link->side == 0xff)
- {
- nextRef = link->ref;
- break;
- }
-
- // If the link is at tile boundary,
- const int v0 = poly->v[link->e];
- const int v1 = poly->v[(link->e+1) % poly->nv];
- const float* left = &header->verts[v0*3];
- const float* right = &header->verts[v1*3];
-
- // Check that the intersection lies inside the link portal.
- if (link->side == 0 || link->side == 2)
- {
- // Calculate link size.
- const float smin = min(left[2],right[2]);
- const float smax = max(left[2],right[2]);
- const float s = (smax-smin) / 255.0f;
- const float lmin = smin + link->bmin*s;
- const float lmax = smin + link->bmax*s;
- // Find Z intersection.
- float z = startPos[2] + (endPos[2]-startPos[2])*tmax;
- if (z >= lmin && z <= lmax)
- {
- nextRef = link->ref;
- break;
- }
- }
- else if (link->side == 1 || link->side == 3)
- {
- // Calculate link size.
- const float smin = min(left[0],right[0]);
- const float smax = max(left[0],right[0]);
- const float s = (smax-smin) / 255.0f;
- const float lmin = smin + link->bmin*s;
- const float lmax = smin + link->bmax*s;
- // Find X intersection.
- float x = startPos[0] + (endPos[0]-startPos[0])*tmax;
- if (x >= lmin && x <= lmax)
- {
- nextRef = link->ref;
- break;
- }
- }
- }
- }
-
- if (!nextRef)
- {
- // No neighbour, we hit a wall.
- return n;
- }
-
- // No hit, advance to neighbour polygon.
- curRef = nextRef;
- }
-
- return n;
-}
-
-int dtTiledNavMesh::findPolysAround(dtTilePolyRef centerRef, const float* centerPos, float radius,
- dtTilePolyRef* resultRef, dtTilePolyRef* resultParent, float* resultCost,
- const int maxResult)
-{
- if (!centerRef) return 0;
- if (!getPolyByRef(centerRef)) return 0;
- if (!m_nodePool || !m_openList) return 0;
-
- m_nodePool->clear();
- m_openList->clear();
-
- dtNode* startNode = m_nodePool->getNode(centerRef);
- startNode->pidx = 0;
- startNode->cost = 0;
- startNode->total = 0;
- startNode->id = centerRef;
- startNode->flags = DT_NODE_OPEN;
- m_openList->push(startNode);
-
- int n = 0;
- if (n < maxResult)
- {
- if (resultRef)
- resultRef[n] = startNode->id;
- if (resultParent)
- resultParent[n] = 0;
- if (resultCost)
- resultCost[n] = 0;
- ++n;
- }
-
- const float radiusSqr = sqr(radius);
-
- while (!m_openList->empty())
- {
- dtNode* bestNode = m_openList->pop();
-
- // Get poly and tile.
- unsigned int salt, it, ip;
- dtDecodeTileId(bestNode->id, salt, it, ip);
- // The API input has been cheked already, skip checking internal data.
- const dtTileHeader* header = m_tiles[it].header;
- const dtTilePoly* poly = &header->polys[ip];
-
- for (int i = 0; i < poly->nlinks; ++i)
- {
- const dtTileLink* link = &header->links[poly->links+i];
- dtTilePolyRef neighbour = link->ref;
- if (neighbour)
- {
- // Skip parent node.
- if (bestNode->pidx && m_nodePool->getNodeAtIdx(bestNode->pidx)->id == neighbour)
- continue;
-
- // Calc distance to the edge.
- const float* va = &header->verts[poly->v[link->e]*3];
- const float* vb = &header->verts[poly->v[(link->e+1)%poly->nv]*3];
- float tseg;
- float distSqr = distancePtSegSqr2D(centerPos, va, vb, tseg);
-
- // If the circle is not touching the next polygon, skip it.
- if (distSqr > radiusSqr)
- continue;
-
- dtNode* parent = bestNode;
- dtNode newNode;
- newNode.pidx = m_nodePool->getNodeIdx(parent);
- newNode.id = neighbour;
-
- // Cost
- float p0[3], p1[3];
- if (!parent->pidx)
- vcopy(p0, centerPos);
- else
- getEdgeMidPoint(m_nodePool->getNodeAtIdx(parent->pidx)->id, parent->id, p0);
- getEdgeMidPoint(parent->id, newNode.id, p1);
- newNode.total = parent->total + vdist(p0,p1);
-
- dtNode* actualNode = m_nodePool->getNode(newNode.id);
- if (!actualNode)
- continue;
-
- if (!((actualNode->flags & DT_NODE_OPEN) && newNode.total > actualNode->total) &&
- !((actualNode->flags & DT_NODE_CLOSED) && newNode.total > actualNode->total))
- {
- actualNode->flags &= ~DT_NODE_CLOSED;
- actualNode->pidx = newNode.pidx;
- actualNode->total = newNode.total;
-
- if (actualNode->flags & DT_NODE_OPEN)
- {
- m_openList->modify(actualNode);
- }
- else
- {
- if (n < maxResult)
- {
- if (resultRef)
- resultRef[n] = actualNode->id;
- if (resultParent)
- resultParent[n] = m_nodePool->getNodeAtIdx(actualNode->pidx)->id;
- if (resultCost)
- resultCost[n] = actualNode->total;
- ++n;
- }
- actualNode->flags = DT_NODE_OPEN;
- m_openList->push(actualNode);
- }
- }
- }
- }
- }
-
- return n;
-}
-
-float dtTiledNavMesh::findDistanceToWall(dtTilePolyRef centerRef, const float* centerPos, float maxRadius,
- float* hitPos, float* hitNormal)
-{
- if (!centerRef) return 0;
- if (!getPolyByRef(centerRef)) return 0;
- if (!m_nodePool || !m_openList) return 0;
-
- m_nodePool->clear();
- m_openList->clear();
-
- dtNode* startNode = m_nodePool->getNode(centerRef);
- startNode->pidx = 0;
- startNode->cost = 0;
- startNode->total = 0;
- startNode->id = centerRef;
- startNode->flags = DT_NODE_OPEN;
- m_openList->push(startNode);
-
- float radiusSqr = sqr(maxRadius);
-
- while (!m_openList->empty())
- {
- dtNode* bestNode = m_openList->pop();
-
- // Get poly and tile.
- unsigned int salt, it, ip;
- dtDecodeTileId(bestNode->id, salt, it, ip);
- // The API input has been cheked already, skip checking internal data.
- const dtTileHeader* header = m_tiles[it].header;
- const dtTilePoly* poly = &header->polys[ip];
-
- // Hit test walls.
- for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++)
- {
- // Skip non-solid edges.
- if (poly->n[j] & 0x8000)
- {
- // Tile border.
- bool solid = true;
- for (int i = 0; i < poly->nlinks; ++i)
- {
- const dtTileLink* link = &header->links[poly->links+i];
- if (link->e == j && link->ref != 0)
- {
- solid = false;
- break;
- }
- }
- if (!solid) continue;
- }
- else if (poly->n[j])
- {
- // Internal edge
- continue;
- }
-
- // Calc distance to the edge.
- const float* vj = &header->verts[poly->v[j]*3];
- const float* vi = &header->verts[poly->v[i]*3];
- float tseg;
- float distSqr = distancePtSegSqr2D(centerPos, vj, vi, tseg);
-
- // Edge is too far, skip.
- if (distSqr > radiusSqr)
- continue;
-
- // Hit wall, update radius.
- radiusSqr = distSqr;
- // Calculate hit pos.
- hitPos[0] = vj[0] + (vi[0] - vj[0])*tseg;
- hitPos[1] = vj[1] + (vi[1] - vj[1])*tseg;
- hitPos[2] = vj[2] + (vi[2] - vj[2])*tseg;
- }
-
- for (int i = 0; i < poly->nlinks; ++i)
- {
- const dtTileLink* link = &header->links[poly->links+i];
- dtTilePolyRef neighbour = link->ref;
- if (neighbour)
- {
- // Skip parent node.
- if (bestNode->pidx && m_nodePool->getNodeAtIdx(bestNode->pidx)->id == neighbour)
- continue;
-
- // Calc distance to the edge.
- const float* va = &header->verts[poly->v[link->e]*3];
- const float* vb = &header->verts[poly->v[(link->e+1)%poly->nv]*3];
- float tseg;
- float distSqr = distancePtSegSqr2D(centerPos, va, vb, tseg);
-
- // If the circle is not touching the next polygon, skip it.
- if (distSqr > radiusSqr)
- continue;
-
- dtNode* parent = bestNode;
- dtNode newNode;
- newNode.pidx = m_nodePool->getNodeIdx(parent);
- newNode.id = neighbour;
-
- float p0[3], p1[3];
- if (!parent->pidx)
- vcopy(p0, centerPos);
- else
- getEdgeMidPoint(m_nodePool->getNodeAtIdx(parent->pidx)->id, parent->id, p0);
- getEdgeMidPoint(parent->id, newNode.id, p1);
- newNode.total = parent->total + vdist(p0,p1);
-
- dtNode* actualNode = m_nodePool->getNode(newNode.id);
- if (!actualNode)
- continue;
-
- if (!((actualNode->flags & DT_NODE_OPEN) && newNode.total > actualNode->total) &&
- !((actualNode->flags & DT_NODE_CLOSED) && newNode.total > actualNode->total))
- {
- actualNode->flags &= ~DT_NODE_CLOSED;
- actualNode->pidx = newNode.pidx;
- actualNode->total = newNode.total;
-
- if (actualNode->flags & DT_NODE_OPEN)
- {
- m_openList->modify(actualNode);
- }
- else
- {
- actualNode->flags = DT_NODE_OPEN;
- m_openList->push(actualNode);
- }
- }
- }
- }
- }
-
- // Calc hit normal.
- vsub(hitNormal, centerPos, hitPos);
- vnormalize(hitNormal);
-
- return sqrtf(radiusSqr);
-}
-
-const dtTilePoly* dtTiledNavMesh::getPolyByRef(dtTilePolyRef ref) const
-{
- unsigned int salt, it, ip;
- dtDecodeTileId(ref, salt, it, ip);
- if (it >= DT_MAX_TILES) return 0;
- if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return 0;
- if (ip >= (unsigned int)m_tiles[it].header->npolys) return 0;
- return &m_tiles[it].header->polys[ip];
-}
-
-const float* dtTiledNavMesh::getPolyVertsByRef(dtTilePolyRef ref) const
-{
- unsigned int salt, it, ip;
- dtDecodeTileId(ref, salt, it, ip);
- if (it >= DT_MAX_TILES) return 0;
- if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return 0;
- if (ip >= (unsigned int)m_tiles[it].header->npolys) return 0;
- return m_tiles[it].header->verts;
-}
-
-const dtTileLink* dtTiledNavMesh::getPolyLinksByRef(dtTilePolyRef ref) const
-{
- unsigned int salt, it, ip;
- dtDecodeTileId(ref, salt, it, ip);
- if (it >= DT_MAX_TILES) return 0;
- if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return 0;
- if (ip >= (unsigned int)m_tiles[it].header->npolys) return 0;
- return m_tiles[it].header->links;
-}
diff --git a/extern/recastnavigation/Detour/Source/DetourTileNavMeshBuilder.cpp b/extern/recastnavigation/Detour/Source/DetourTileNavMeshBuilder.cpp
deleted file mode 100644
index 95dd34b04f6..00000000000
--- a/extern/recastnavigation/Detour/Source/DetourTileNavMeshBuilder.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-//
-// Copyright (c) 2009 Mikko Mononen memon@inside.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 <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "DetourTileNavMesh.h"
-#include "DetourCommon.h"
-
-bool dtCreateNavMeshTileData(const unsigned short* verts, const int nverts,
- const unsigned short* polys, const int npolys, const int nvp,
- const unsigned short* dmeshes, const float* dverts, const int ndverts,
- const unsigned char* dtris, const int ndtris,
- const float* bmin, const float* bmax, float cs, float ch, int tileSize, int walkableClimb,
- unsigned char** outData, int* outDataSize)
-{
- if (nvp != DT_TILE_VERTS_PER_POLYGON)
- return false;
- if (nverts >= 0xffff)
- return false;
-
- if (!nverts)
- return false;
- if (!npolys)
- return false;
- if (!dmeshes || !dverts || ! dtris)
- return false;
-
- // Find portal edges which are at tile borders.
- int nedges = 0;
- int nportals = 0;
- for (int i = 0; i < npolys; ++i)
- {
- const unsigned short* p = &polys[i*2*nvp];
- for (int j = 0; j < nvp; ++j)
- {
- if (p[j] == 0xffff) break;
- int nj = j+1;
- if (nj >= nvp || p[nj] == 0xffff) nj = 0;
- const unsigned short* va = &verts[p[j]*3];
- const unsigned short* vb = &verts[p[nj]*3];
-
- nedges++;
-
- if (va[0] == tileSize && vb[0] == tileSize)
- nportals++; // x+
- else if (va[2] == tileSize && vb[2] == tileSize)
- nportals++; // z+
- else if (va[0] == 0 && vb[0] == 0)
- nportals++; // x-
- else if (va[2] == 0 && vb[2] == 0)
- nportals++; // z-
- }
- }
-
- const int maxLinks = nedges + nportals*2;
-
-
- // Find unique detail vertices.
- int uniqueDetailVerts = 0;
- if (dmeshes)
- {
- for (int i = 0; i < npolys; ++i)
- {
- const unsigned short* p = &polys[i*nvp*2];
- int ndv = dmeshes[i*4+1];
- int nv = 0;
- for (int j = 0; j < nvp; ++j)
- {
- if (p[j] == 0xffff) break;
- nv++;
- }
- ndv -= nv;
- uniqueDetailVerts += ndv;
- }
- }
-
- // Calculate data size
- const int headerSize = sizeof(dtTileHeader);
- const int vertsSize = sizeof(float)*3*nverts;
- const int polysSize = sizeof(dtTilePoly)*npolys;
- const int linksSize = sizeof(dtTileLink)*maxLinks;
- const int detailMeshesSize = sizeof(dtTilePolyDetail)*npolys;
- const int detailVertsSize = sizeof(float)*3*uniqueDetailVerts;
- const int detailTrisSize = sizeof(unsigned char)*4*ndtris;
-
- const int dataSize = headerSize + vertsSize + polysSize + linksSize +
- detailMeshesSize + detailVertsSize + detailTrisSize;
- unsigned char* data = new unsigned char[dataSize];
- if (!data)
- return false;
- memset(data, 0, dataSize);
-
- unsigned char* d = data;
- dtTileHeader* header = (dtTileHeader*)d; d += headerSize;
- float* navVerts = (float*)d; d += vertsSize;
- dtTilePoly* navPolys = (dtTilePoly*)d; d += polysSize;
- d += linksSize;
- dtTilePolyDetail* navDMeshes = (dtTilePolyDetail*)d; d += detailMeshesSize;
- float* navDVerts = (float*)d; d += detailVertsSize;
- unsigned char* navDTris = (unsigned char*)d; d += detailTrisSize;
-
-
- // Store header
- header->magic = DT_TILE_NAVMESH_MAGIC;
- header->version = DT_TILE_NAVMESH_VERSION;
- header->npolys = npolys;
- header->nverts = nverts;
- header->maxlinks = maxLinks;
- header->bmin[0] = bmin[0];
- header->bmin[1] = bmin[1];
- header->bmin[2] = bmin[2];
- header->bmax[0] = bmax[0];
- header->bmax[1] = bmax[1];
- header->bmax[2] = bmax[2];
- header->ndmeshes = npolys;
- header->ndverts = uniqueDetailVerts;
- header->ndtris = ndtris;
-
- // Store vertices
- for (int i = 0; i < nverts; ++i)
- {
- const unsigned short* iv = &verts[i*3];
- float* v = &navVerts[i*3];
- v[0] = bmin[0] + iv[0] * cs;
- v[1] = bmin[1] + iv[1] * ch;
- v[2] = bmin[2] + iv[2] * cs;
- }
-
- // Store polygons
- const unsigned short* src = polys;
- for (int i = 0; i < npolys; ++i)
- {
- dtTilePoly* p = &navPolys[i];
- p->nv = 0;
- for (int j = 0; j < nvp; ++j)
- {
- if (src[j] == 0xffff) break;
- p->v[j] = src[j];
- p->n[j] = (src[nvp+j]+1) & 0xffff;
- p->nv++;
- }
- src += nvp*2;
- }
-
- // Store portal edges.
- for (int i = 0; i < npolys; ++i)
- {
- dtTilePoly* poly = &navPolys[i];
- for (int j = 0; j < poly->nv; ++j)
- {
- int nj = j+1;
- if (nj >= poly->nv) nj = 0;
-
- const unsigned short* va = &verts[poly->v[j]*3];
- const unsigned short* vb = &verts[poly->v[nj]*3];
-
- if (va[0] == tileSize && vb[0] == tileSize) // x+
- poly->n[j] = 0x8000 | 0;
- else if (va[2] == tileSize && vb[2] == tileSize) // z+
- poly->n[j] = 0x8000 | 1;
- else if (va[0] == 0 && vb[0] == 0) // x-
- poly->n[j] = 0x8000 | 2;
- else if (va[2] == 0 && vb[2] == 0) // z-
- poly->n[j] = 0x8000 | 3;
- }
- }
-
- // Store detail meshes and vertices.
- // The nav polygon vertices are stored as the first vertices on each mesh.
- // We compress the mesh data by skipping them and using the navmesh coordinates.
- unsigned short vbase = 0;
- for (int i = 0; i < npolys; ++i)
- {
- dtTilePolyDetail& dtl = navDMeshes[i];
- const int vb = dmeshes[i*4+0];
- const int ndv = dmeshes[i*4+1];
- const int nv = navPolys[i].nv;
- dtl.vbase = vbase;
- dtl.nverts = ndv-nv;
- dtl.tbase = dmeshes[i*4+2];
- dtl.ntris = dmeshes[i*4+3];
- // Copy vertices except the first 'nv' verts which are equal to nav poly verts.
- if (ndv-nv)
- {
- memcpy(&navDVerts[vbase*3], &dverts[(vb+nv)*3], sizeof(float)*3*(ndv-nv));
- vbase += ndv-nv;
- }
- }
- // Store triangles.
- memcpy(navDTris, dtris, sizeof(unsigned char)*4*ndtris);
-
- *outData = data;
- *outDataSize = dataSize;
-
- return true;
-}
diff --git a/extern/recastnavigation/License.txt b/extern/recastnavigation/License.txt
deleted file mode 100644
index 95f4bfc9654..00000000000
--- a/extern/recastnavigation/License.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-Copyright (c) 2009 Mikko Mononen memon@inside.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.
-
diff --git a/extern/recastnavigation/Readme.txt b/extern/recastnavigation/Readme.txt
deleted file mode 100644
index 0c2f7b1675f..00000000000
--- a/extern/recastnavigation/Readme.txt
+++ /dev/null
@@ -1,120 +0,0 @@
-
-Recast & Detour Version 1.4
-
-
-Recast
-
-Recast is state of the art navigation mesh construction toolset for games.
-
- * It is automatic, which means that you can throw any level geometry
- at it and you will get robust mesh out
- * It is fast which means swift turnaround times for level designers
- * It is open source so it comes with full source and you can
- customize it to your hearts content.
-
-The Recast process starts with constructing a voxel mold from a level geometry
-and then casting a navigation mesh over it. The process consists of three steps,
-building the voxel mold, partitioning the mold into simple regions, peeling off
-the regions as simple polygons.
-
- 1. The voxel mold is build from the input triangle mesh by rasterizing
- the triangles into a multi-layer heightfield. Some simple filters are
- then applied to the mold to prune out locations where the character
- would not be able to move.
- 2. The walkable areas described by the mold are divided into simple
- overlayed 2D regions. The resulting regions have only one non-overlapping
- contour, which simplifies the final step of the process tremendously.
- 3. The navigation polygons are peeled off from the regions by first tracing
- the boundaries and then simplifying them. The resulting polygons are
- finally converted to convex polygons which makes them perfect for
- pathfinding and spatial reasoning about the level.
-
-The toolset code is located in the Recast folder and demo application using the Recast
-toolset is located in the RecastDemo folder.
-
-The project files with this distribution can be compiled with Microsoft Visual C++ 2008
-(you can download it for free) and XCode 3.1.
-
-
-Detour
-
-Recast is accompanied with Detour, path-finding and spatial reasoning toolkit. You can use any navigation mesh with Detour, but of course the data generated with Recast fits perfectly.
-
-Detour offers simple static navigation mesh which is suitable for many simple cases, as well as tiled navigation mesh which allows you to plug in and out pieces of the mesh. The tiled mesh allows to create systems where you stream new navigation data in and out as the player progresses the level, or you may regenerate tiles as the world changes.
-
-
-Latest code available at http://code.google.com/p/recastnavigation/
-
-
---
-
-Release Notes
-
-----------------
-* Recast 1.4
- Released August 24th, 2009
-
-- Added detail height mesh generation (RecastDetailMesh.cpp) for single,
- tiled statmeshes as well as tilemesh.
-- Added feature to contour tracing which detects extra vertices along
- tile edges which should be removed later.
-- Changed the tiled stat mesh preprocess, so that it first generated
- polymeshes per tile and finally combines them.
-- Fixed bug in the GUI code where invisible buttons could be pressed.
-
-----------------
-* Recast 1.31
- Released July 24th, 2009
-
-- Better cost and heuristic functions.
-- Fixed tile navmesh raycast on tile borders.
-
-----------------
-* Recast 1.3
- Released July 14th, 2009
-
-- Added dtTileNavMesh which allows to dynamically add and remove navmesh pieces at runtime.
-- Renamed stat navmesh types to dtStat* (i.e. dtPoly is now dtStatPoly).
-- Moved common code used by tile and stat navmesh to DetourNode.h/cpp and DetourCommon.h/cpp.
-- Refactores the demo code.
-
-----------------
-* Recast 1.2
- Released June 17th, 2009
-
-- Added tiled mesh generation. The tiled generation allows to generate navigation for
- much larger worlds, it removes some of the artifacts that comes from distance fields
- in open areas, and allows later streaming and dynamic runtime generation
-- Improved and added some debug draw modes
-- API change: The helper function rcBuildNavMesh does not exists anymore,
- had to change few internal things to cope with the tiled processing,
- similar API functionality will be added later once the tiled process matures
-- The demo is getting way too complicated, need to split demos
-- Fixed several filtering functions so that the mesh is tighter to the geometry,
- sometimes there could be up error up to tow voxel units close to walls,
- now it should be just one.
-
-----------------
-* Recast 1.1
- Released April 11th, 2009
-
-This is the first release of Detour.
-
-----------------
-* Recast 1.0
- Released March 29th, 2009
-
-This is the first release of Recast.
-
-The process is not always as robust as I would wish. The watershed phase sometimes swallows tiny islands
-which are close to edges. These droppings are handled in rcBuildContours, but the code is not
-particularly robust either.
-
-Another non-robust case is when portal contours (contours shared between two regions) are always
-assumed to be straight. That can lead to overlapping contours specially when the level has
-large open areas.
-
-
-
-Mikko Mononen
-memon@inside.org
diff --git a/extern/recastnavigation/Recast/Include/Recast.h b/extern/recastnavigation/Recast/Include/Recast.h
deleted file mode 100644
index 6f18247d527..00000000000
--- a/extern/recastnavigation/Recast/Include/Recast.h
+++ /dev/null
@@ -1,1194 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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 RECAST_H
-#define RECAST_H
-
-/// The value of PI used by Recast.
-static const float RC_PI = 3.14159265f;
-
-/// Recast log categories.
-/// @see rcContext
-enum rcLogCategory
-{
- RC_LOG_PROGRESS = 1, ///< A progress log entry.
- RC_LOG_WARNING, ///< A warning log entry.
- RC_LOG_ERROR, ///< An error log entry.
-};
-
-/// Recast performance timer categories.
-/// @see rcContext
-enum rcTimerLabel
-{
- /// The user defined total time of the build.
- RC_TIMER_TOTAL,
- /// A user defined build time.
- RC_TIMER_TEMP,
- /// The time to rasterize the triangles. (See: #rcRasterizeTriangle)
- RC_TIMER_RASTERIZE_TRIANGLES,
- /// The time to build the compact heightfield. (See: #rcBuildCompactHeightfield)
- RC_TIMER_BUILD_COMPACTHEIGHTFIELD,
- /// The total time to build the contours. (See: #rcBuildContours)
- RC_TIMER_BUILD_CONTOURS,
- /// The time to trace the boundaries of the contours. (See: #rcBuildContours)
- RC_TIMER_BUILD_CONTOURS_TRACE,
- /// The time to simplify the contours. (See: #rcBuildContours)
- RC_TIMER_BUILD_CONTOURS_SIMPLIFY,
- /// The time to filter ledge spans. (See: #rcFilterLedgeSpans)
- RC_TIMER_FILTER_BORDER,
- /// The time to filter low height spans. (See: #rcFilterWalkableLowHeightSpans)
- RC_TIMER_FILTER_WALKABLE,
- /// The time to apply the median filter. (See: #rcMedianFilterWalkableArea)
- RC_TIMER_MEDIAN_AREA,
- /// The time to filter low obstacles. (See: #rcFilterLowHangingWalkableObstacles)
- RC_TIMER_FILTER_LOW_OBSTACLES,
- /// The time to build the polygon mesh. (See: #rcBuildPolyMesh)
- RC_TIMER_BUILD_POLYMESH,
- /// The time to merge polygon meshes. (See: #rcMergePolyMeshes)
- RC_TIMER_MERGE_POLYMESH,
- /// The time to erode the walkable area. (See: #rcErodeWalkableArea)
- RC_TIMER_ERODE_AREA,
- /// The time to mark a box area. (See: #rcMarkBoxArea)
- RC_TIMER_MARK_BOX_AREA,
- /// The time to mark a cylinder area. (See: #rcMarkCylinderArea)
- RC_TIMER_MARK_CYLINDER_AREA,
- /// The time to mark a convex polygon area. (See: #rcMarkConvexPolyArea)
- RC_TIMER_MARK_CONVEXPOLY_AREA,
- /// The total time to build the distance field. (See: #rcBuildDistanceField)
- RC_TIMER_BUILD_DISTANCEFIELD,
- /// The time to build the distances of the distance field. (See: #rcBuildDistanceField)
- RC_TIMER_BUILD_DISTANCEFIELD_DIST,
- /// The time to blur the distance field. (See: #rcBuildDistanceField)
- RC_TIMER_BUILD_DISTANCEFIELD_BLUR,
- /// The total time to build the regions. (See: #rcBuildRegions, #rcBuildRegionsMonotone)
- RC_TIMER_BUILD_REGIONS,
- /// The total time to apply the watershed algorithm. (See: #rcBuildRegions)
- RC_TIMER_BUILD_REGIONS_WATERSHED,
- /// The time to expand regions while applying the watershed algorithm. (See: #rcBuildRegions)
- RC_TIMER_BUILD_REGIONS_EXPAND,
- /// The time to flood regions while applying the watershed algorithm. (See: #rcBuildRegions)
- RC_TIMER_BUILD_REGIONS_FLOOD,
- /// The time to filter out small regions. (See: #rcBuildRegions, #rcBuildRegionsMonotone)
- RC_TIMER_BUILD_REGIONS_FILTER,
- /// The time to build heightfield layers. (See: #rcBuildHeightfieldLayers)
- RC_TIMER_BUILD_LAYERS,
- /// The time to build the polygon mesh detail. (See: #rcBuildPolyMeshDetail)
- RC_TIMER_BUILD_POLYMESHDETAIL,
- /// The time to merge polygon mesh details. (See: #rcMergePolyMeshDetails)
- RC_TIMER_MERGE_POLYMESHDETAIL,
- /// The maximum number of timers. (Used for iterating timers.)
- RC_MAX_TIMERS
-};
-
-/// Provides an interface for optional logging and performance tracking of the Recast
-/// build process.
-/// @ingroup recast
-class rcContext
-{
-public:
-
- /// Contructor.
- /// @param[in] state TRUE if the logging and performance timers should be enabled. [Default: true]
- inline rcContext(bool state = true) : m_logEnabled(state), m_timerEnabled(state) {}
- virtual ~rcContext() {}
-
- /// Enables or disables logging.
- /// @param[in] state TRUE if logging should be enabled.
- inline void enableLog(bool state) { m_logEnabled = state; }
-
- /// Clears all log entries.
- inline void resetLog() { if (m_logEnabled) doResetLog(); }
-
- /// Logs a message.
- /// @param[in] category The category of the message.
- /// @param[in] format The message.
- void log(const rcLogCategory category, const char* format, ...);
-
- /// Enables or disables the performance timers.
- /// @param[in] state TRUE if timers should be enabled.
- inline void enableTimer(bool state) { m_timerEnabled = state; }
-
- /// Clears all peformance timers. (Resets all to unused.)
- inline void resetTimers() { if (m_timerEnabled) doResetTimers(); }
-
- /// Starts the specified performance timer.
- /// @param label The category of the timer.
- inline void startTimer(const rcTimerLabel label) { if (m_timerEnabled) doStartTimer(label); }
-
- /// Stops the specified performance timer.
- /// @param label The category of the timer.
- inline void stopTimer(const rcTimerLabel label) { if (m_timerEnabled) doStopTimer(label); }
-
- /// Returns the total accumulated time of the specified performance timer.
- /// @param label The category of the timer.
- /// @return The accumulated time of the timer, or -1 if timers are disabled or the timer has never been started.
- inline int getAccumulatedTime(const rcTimerLabel label) const { return m_timerEnabled ? doGetAccumulatedTime(label) : -1; }
-
-protected:
-
- /// Clears all log entries.
- virtual void doResetLog() {}
-
- /// Logs a message.
- /// @param[in] category The category of the message.
- /// @param[in] msg The formatted message.
- /// @param[in] len The length of the formatted message.
- virtual void doLog(const rcLogCategory /*category*/, const char* /*msg*/, const int /*len*/) {}
-
- /// Clears all timers. (Resets all to unused.)
- virtual void doResetTimers() {}
-
- /// Starts the specified performance timer.
- /// @param[in] label The category of timer.
- virtual void doStartTimer(const rcTimerLabel /*label*/) {}
-
- /// Stops the specified performance timer.
- /// @param[in] label The category of the timer.
- virtual void doStopTimer(const rcTimerLabel /*label*/) {}
-
- /// Returns the total accumulated time of the specified performance timer.
- /// @param[in] label The category of the timer.
- /// @return The accumulated time of the timer, or -1 if timers are disabled or the timer has never been started.
- virtual int doGetAccumulatedTime(const rcTimerLabel /*label*/) const { return -1; }
-
- /// True if logging is enabled.
- bool m_logEnabled;
-
- /// True if the performance timers are enabled.
- bool m_timerEnabled;
-};
-
-/// A helper to first start a timer and then stop it when this helper goes out of scope.
-/// @see rcContext
-class rcScopedTimer
-{
-public:
- /// Constructs an instance and starts the timer.
- /// @param[in] ctx The context to use.
- /// @param[in] label The category of the timer.
- inline rcScopedTimer(rcContext* ctx, const rcTimerLabel label) : m_ctx(ctx), m_label(label) { m_ctx->startTimer(m_label); }
- inline ~rcScopedTimer() { m_ctx->stopTimer(m_label); }
-
-private:
- // Explicitly disabled copy constructor and copy assignment operator.
- rcScopedTimer(const rcScopedTimer&);
- rcScopedTimer& operator=(const rcScopedTimer&);
-
- rcContext* const m_ctx;
- const rcTimerLabel m_label;
-};
-
-/// Specifies a configuration to use when performing Recast builds.
-/// @ingroup recast
-struct rcConfig
-{
- /// The width of the field along the x-axis. [Limit: >= 0] [Units: vx]
- int width;
-
- /// The height of the field along the z-axis. [Limit: >= 0] [Units: vx]
- int height;
-
- /// The width/height size of tile's on the xz-plane. [Limit: >= 0] [Units: vx]
- int tileSize;
-
- /// The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx]
- int borderSize;
-
- /// The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
- float cs;
-
- /// The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
- float ch;
-
- /// The minimum bounds of the field's AABB. [(x, y, z)] [Units: wu]
- float bmin[3];
-
- /// The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu]
- float bmax[3];
-
- /// The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
- float walkableSlopeAngle;
-
- /// Minimum floor to 'ceiling' height that will still allow the floor area to
- /// be considered walkable. [Limit: >= 3] [Units: vx]
- int walkableHeight;
-
- /// Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
- int walkableClimb;
-
- /// The distance to erode/shrink the walkable area of the heightfield away from
- /// obstructions. [Limit: >=0] [Units: vx]
- int walkableRadius;
-
- /// The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
- int maxEdgeLen;
-
- /// The maximum distance a simplfied contour's border edges should deviate
- /// the original raw contour. [Limit: >=0] [Units: vx]
- float maxSimplificationError;
-
- /// The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
- int minRegionArea;
-
- /// Any regions with a span count smaller than this value will, if possible,
- /// be merged with larger regions. [Limit: >=0] [Units: vx]
- int mergeRegionArea;
-
- /// The maximum number of vertices allowed for polygons generated during the
- /// contour to polygon conversion process. [Limit: >= 3]
- int maxVertsPerPoly;
-
- /// Sets the sampling distance to use when generating the detail mesh.
- /// (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
- float detailSampleDist;
-
- /// The maximum distance the detail mesh surface should deviate from heightfield
- /// data. (For height detail only.) [Limit: >=0] [Units: wu]
- float detailSampleMaxError;
-};
-
-/// Defines the number of bits allocated to rcSpan::smin and rcSpan::smax.
-static const int RC_SPAN_HEIGHT_BITS = 13;
-/// Defines the maximum value for rcSpan::smin and rcSpan::smax.
-static const int RC_SPAN_MAX_HEIGHT = (1 << RC_SPAN_HEIGHT_BITS) - 1;
-
-/// The number of spans allocated per span spool.
-/// @see rcSpanPool
-static const int RC_SPANS_PER_POOL = 2048;
-
-/// Represents a span in a heightfield.
-/// @see rcHeightfield
-struct rcSpan
-{
- unsigned int smin : RC_SPAN_HEIGHT_BITS; ///< The lower limit of the span. [Limit: < #smax]
- unsigned int smax : RC_SPAN_HEIGHT_BITS; ///< The upper limit of the span. [Limit: <= #RC_SPAN_MAX_HEIGHT]
- unsigned int area : 6; ///< The area id assigned to the span.
- rcSpan* next; ///< The next span higher up in column.
-};
-
-/// A memory pool used for quick allocation of spans within a heightfield.
-/// @see rcHeightfield
-struct rcSpanPool
-{
- rcSpanPool* next; ///< The next span pool.
- rcSpan items[RC_SPANS_PER_POOL]; ///< Array of spans in the pool.
-};
-
-/// A dynamic heightfield representing obstructed space.
-/// @ingroup recast
-struct rcHeightfield
-{
- int width; ///< The width of the heightfield. (Along the x-axis in cell units.)
- int height; ///< The height of the heightfield. (Along the z-axis in cell units.)
- float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
- float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
- float cs; ///< The size of each cell. (On the xz-plane.)
- float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
- rcSpan** spans; ///< Heightfield of spans (width*height).
- rcSpanPool* pools; ///< Linked list of span pools.
- rcSpan* freelist; ///< The next free span.
-};
-
-/// Provides information on the content of a cell column in a compact heightfield.
-struct rcCompactCell
-{
- unsigned int index : 24; ///< Index to the first span in the column.
- unsigned int count : 8; ///< Number of spans in the column.
-};
-
-/// Represents a span of unobstructed space within a compact heightfield.
-struct rcCompactSpan
-{
- unsigned short y; ///< The lower extent of the span. (Measured from the heightfield's base.)
- unsigned short reg; ///< The id of the region the span belongs to. (Or zero if not in a region.)
- unsigned int con : 24; ///< Packed neighbor connection data.
- unsigned int h : 8; ///< The height of the span. (Measured from #y.)
-};
-
-/// A compact, static heightfield representing unobstructed space.
-/// @ingroup recast
-struct rcCompactHeightfield
-{
- int width; ///< The width of the heightfield. (Along the x-axis in cell units.)
- int height; ///< The height of the heightfield. (Along the z-axis in cell units.)
- int spanCount; ///< The number of spans in the heightfield.
- int walkableHeight; ///< The walkable height used during the build of the field. (See: rcConfig::walkableHeight)
- int walkableClimb; ///< The walkable climb used during the build of the field. (See: rcConfig::walkableClimb)
- int borderSize; ///< The AABB border size used during the build of the field. (See: rcConfig::borderSize)
- unsigned short maxDistance; ///< The maximum distance value of any span within the field.
- unsigned short maxRegions; ///< The maximum region id of any span within the field.
- float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
- float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
- float cs; ///< The size of each cell. (On the xz-plane.)
- float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
- rcCompactCell* cells; ///< Array of cells. [Size: #width*#height]
- rcCompactSpan* spans; ///< Array of spans. [Size: #spanCount]
- unsigned short* dist; ///< Array containing border distance data. [Size: #spanCount]
- unsigned char* areas; ///< Array containing area id data. [Size: #spanCount]
-};
-
-/// Represents a heightfield layer within a layer set.
-/// @see rcHeightfieldLayerSet
-struct rcHeightfieldLayer
-{
- float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
- float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
- float cs; ///< The size of each cell. (On the xz-plane.)
- float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
- int width; ///< The width of the heightfield. (Along the x-axis in cell units.)
- int height; ///< The height of the heightfield. (Along the z-axis in cell units.)
- int minx; ///< The minimum x-bounds of usable data.
- int maxx; ///< The maximum x-bounds of usable data.
- int miny; ///< The minimum y-bounds of usable data. (Along the z-axis.)
- int maxy; ///< The maximum y-bounds of usable data. (Along the z-axis.)
- int hmin; ///< The minimum height bounds of usable data. (Along the y-axis.)
- int hmax; ///< The maximum height bounds of usable data. (Along the y-axis.)
- unsigned char* heights; ///< The heightfield. [Size: width * height]
- unsigned char* areas; ///< Area ids. [Size: Same as #heights]
- unsigned char* cons; ///< Packed neighbor connection information. [Size: Same as #heights]
-};
-
-/// Represents a set of heightfield layers.
-/// @ingroup recast
-/// @see rcAllocHeightfieldLayerSet, rcFreeHeightfieldLayerSet
-struct rcHeightfieldLayerSet
-{
- rcHeightfieldLayer* layers; ///< The layers in the set. [Size: #nlayers]
- int nlayers; ///< The number of layers in the set.
-};
-
-/// Represents a simple, non-overlapping contour in field space.
-struct rcContour
-{
- int* verts; ///< Simplified contour vertex and connection data. [Size: 4 * #nverts]
- int nverts; ///< The number of vertices in the simplified contour.
- int* rverts; ///< Raw contour vertex and connection data. [Size: 4 * #nrverts]
- int nrverts; ///< The number of vertices in the raw contour.
- unsigned short reg; ///< The region id of the contour.
- unsigned char area; ///< The area id of the contour.
-};
-
-/// Represents a group of related contours.
-/// @ingroup recast
-struct rcContourSet
-{
- rcContour* conts; ///< An array of the contours in the set. [Size: #nconts]
- int nconts; ///< The number of contours in the set.
- float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
- float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
- float cs; ///< The size of each cell. (On the xz-plane.)
- float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
- int width; ///< The width of the set. (Along the x-axis in cell units.)
- int height; ///< The height of the set. (Along the z-axis in cell units.)
- int borderSize; ///< The AABB border size used to generate the source data from which the contours were derived.
- float maxError; ///< The max edge error that this contour set was simplified with.
-};
-
-/// Represents a polygon mesh suitable for use in building a navigation mesh.
-/// @ingroup recast
-struct rcPolyMesh
-{
- unsigned short* verts; ///< The mesh vertices. [Form: (x, y, z) * #nverts]
- unsigned short* polys; ///< Polygon and neighbor data. [Length: #maxpolys * 2 * #nvp]
- unsigned short* regs; ///< The region id assigned to each polygon. [Length: #maxpolys]
- unsigned short* flags; ///< The user defined flags for each polygon. [Length: #maxpolys]
- unsigned char* areas; ///< The area id assigned to each polygon. [Length: #maxpolys]
- int nverts; ///< The number of vertices.
- int npolys; ///< The number of polygons.
- int maxpolys; ///< The number of allocated polygons.
- int nvp; ///< The maximum number of vertices per polygon.
- float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
- float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
- float cs; ///< The size of each cell. (On the xz-plane.)
- float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
- int borderSize; ///< The AABB border size used to generate the source data from which the mesh was derived.
- float maxEdgeError; ///< The max error of the polygon edges in the mesh.
-};
-
-/// Contains triangle meshes that represent detailed height data associated
-/// with the polygons in its associated polygon mesh object.
-/// @ingroup recast
-struct rcPolyMeshDetail
-{
- unsigned int* meshes; ///< The sub-mesh data. [Size: 4*#nmeshes]
- float* verts; ///< The mesh vertices. [Size: 3*#nverts]
- unsigned char* tris; ///< The mesh triangles. [Size: 4*#ntris]
- int nmeshes; ///< The number of sub-meshes defined by #meshes.
- int nverts; ///< The number of vertices in #verts.
- int ntris; ///< The number of triangles in #tris.
-};
-
-/// @name Allocation Functions
-/// Functions used to allocate and de-allocate Recast objects.
-/// @see rcAllocSetCustom
-/// @{
-
-/// Allocates a heightfield object using the Recast allocator.
-/// @return A heightfield that is ready for initialization, or null on failure.
-/// @ingroup recast
-/// @see rcCreateHeightfield, rcFreeHeightField
-rcHeightfield* rcAllocHeightfield();
-
-/// Frees the specified heightfield object using the Recast allocator.
-/// @param[in] hf A heightfield allocated using #rcAllocHeightfield
-/// @ingroup recast
-/// @see rcAllocHeightfield
-void rcFreeHeightField(rcHeightfield* hf);
-
-/// Allocates a compact heightfield object using the Recast allocator.
-/// @return A compact heightfield that is ready for initialization, or null on failure.
-/// @ingroup recast
-/// @see rcBuildCompactHeightfield, rcFreeCompactHeightfield
-rcCompactHeightfield* rcAllocCompactHeightfield();
-
-/// Frees the specified compact heightfield object using the Recast allocator.
-/// @param[in] chf A compact heightfield allocated using #rcAllocCompactHeightfield
-/// @ingroup recast
-/// @see rcAllocCompactHeightfield
-void rcFreeCompactHeightfield(rcCompactHeightfield* chf);
-
-/// Allocates a heightfield layer set using the Recast allocator.
-/// @return A heightfield layer set that is ready for initialization, or null on failure.
-/// @ingroup recast
-/// @see rcBuildHeightfieldLayers, rcFreeHeightfieldLayerSet
-rcHeightfieldLayerSet* rcAllocHeightfieldLayerSet();
-
-/// Frees the specified heightfield layer set using the Recast allocator.
-/// @param[in] lset A heightfield layer set allocated using #rcAllocHeightfieldLayerSet
-/// @ingroup recast
-/// @see rcAllocHeightfieldLayerSet
-void rcFreeHeightfieldLayerSet(rcHeightfieldLayerSet* lset);
-
-/// Allocates a contour set object using the Recast allocator.
-/// @return A contour set that is ready for initialization, or null on failure.
-/// @ingroup recast
-/// @see rcBuildContours, rcFreeContourSet
-rcContourSet* rcAllocContourSet();
-
-/// Frees the specified contour set using the Recast allocator.
-/// @param[in] cset A contour set allocated using #rcAllocContourSet
-/// @ingroup recast
-/// @see rcAllocContourSet
-void rcFreeContourSet(rcContourSet* cset);
-
-/// Allocates a polygon mesh object using the Recast allocator.
-/// @return A polygon mesh that is ready for initialization, or null on failure.
-/// @ingroup recast
-/// @see rcBuildPolyMesh, rcFreePolyMesh
-rcPolyMesh* rcAllocPolyMesh();
-
-/// Frees the specified polygon mesh using the Recast allocator.
-/// @param[in] pmesh A polygon mesh allocated using #rcAllocPolyMesh
-/// @ingroup recast
-/// @see rcAllocPolyMesh
-void rcFreePolyMesh(rcPolyMesh* pmesh);
-
-/// Allocates a detail mesh object using the Recast allocator.
-/// @return A detail mesh that is ready for initialization, or null on failure.
-/// @ingroup recast
-/// @see rcBuildPolyMeshDetail, rcFreePolyMeshDetail
-rcPolyMeshDetail* rcAllocPolyMeshDetail();
-
-/// Frees the specified detail mesh using the Recast allocator.
-/// @param[in] dmesh A detail mesh allocated using #rcAllocPolyMeshDetail
-/// @ingroup recast
-/// @see rcAllocPolyMeshDetail
-void rcFreePolyMeshDetail(rcPolyMeshDetail* dmesh);
-
-/// @}
-
-/// Heighfield border flag.
-/// If a heightfield region ID has this bit set, then the region is a border
-/// region and its spans are considered unwalkable.
-/// (Used during the region and contour build process.)
-/// @see rcCompactSpan::reg
-static const unsigned short RC_BORDER_REG = 0x8000;
-
-/// Polygon touches multiple regions.
-/// If a polygon has this region ID it was merged with or created
-/// from polygons of different regions during the polymesh
-/// build step that removes redundant border vertices.
-/// (Used during the polymesh and detail polymesh build processes)
-/// @see rcPolyMesh::regs
-static const unsigned short RC_MULTIPLE_REGS = 0;
-
-/// Border vertex flag.
-/// If a region ID has this bit set, then the associated element lies on
-/// a tile border. If a contour vertex's region ID has this bit set, the
-/// vertex will later be removed in order to match the segments and vertices
-/// at tile boundaries.
-/// (Used during the build process.)
-/// @see rcCompactSpan::reg, #rcContour::verts, #rcContour::rverts
-static const int RC_BORDER_VERTEX = 0x10000;
-
-/// Area border flag.
-/// If a region ID has this bit set, then the associated element lies on
-/// the border of an area.
-/// (Used during the region and contour build process.)
-/// @see rcCompactSpan::reg, #rcContour::verts, #rcContour::rverts
-static const int RC_AREA_BORDER = 0x20000;
-
-/// Contour build flags.
-/// @see rcBuildContours
-enum rcBuildContoursFlags
-{
- RC_CONTOUR_TESS_WALL_EDGES = 0x01, ///< Tessellate solid (impassable) edges during contour simplification.
- RC_CONTOUR_TESS_AREA_EDGES = 0x02, ///< Tessellate edges between areas during contour simplification.
-};
-
-/// Applied to the region id field of contour vertices in order to extract the region id.
-/// The region id field of a vertex may have several flags applied to it. So the
-/// fields value can't be used directly.
-/// @see rcContour::verts, rcContour::rverts
-static const int RC_CONTOUR_REG_MASK = 0xffff;
-
-/// An value which indicates an invalid index within a mesh.
-/// @note This does not necessarily indicate an error.
-/// @see rcPolyMesh::polys
-static const unsigned short RC_MESH_NULL_IDX = 0xffff;
-
-/// Represents the null area.
-/// When a data element is given this value it is considered to no longer be
-/// assigned to a usable area. (E.g. It is unwalkable.)
-static const unsigned char RC_NULL_AREA = 0;
-
-/// The default area id used to indicate a walkable polygon.
-/// This is also the maximum allowed area id, and the only non-null area id
-/// recognized by some steps in the build process.
-static const unsigned char RC_WALKABLE_AREA = 63;
-
-/// The value returned by #rcGetCon if the specified direction is not connected
-/// to another span. (Has no neighbor.)
-static const int RC_NOT_CONNECTED = 0x3f;
-
-/// @name General helper functions
-/// @{
-
-/// Used to ignore a function parameter. VS complains about unused parameters
-/// and this silences the warning.
-/// @param [in] _ Unused parameter
-template<class T> void rcIgnoreUnused(const T&) { }
-
-/// Swaps the values of the two parameters.
-/// @param[in,out] a Value A
-/// @param[in,out] b Value B
-template<class T> inline void rcSwap(T& a, T& b) { T t = a; a = b; b = t; }
-
-/// Returns the minimum of two values.
-/// @param[in] a Value A
-/// @param[in] b Value B
-/// @return The minimum of the two values.
-template<class T> inline T rcMin(T a, T b) { return a < b ? a : b; }
-
-/// Returns the maximum of two values.
-/// @param[in] a Value A
-/// @param[in] b Value B
-/// @return The maximum of the two values.
-template<class T> inline T rcMax(T a, T b) { return a > b ? a : b; }
-
-/// Returns the absolute value.
-/// @param[in] a The value.
-/// @return The absolute value of the specified value.
-template<class T> inline T rcAbs(T a) { return a < 0 ? -a : a; }
-
-/// Returns the square of the value.
-/// @param[in] a The value.
-/// @return The square of the value.
-template<class T> inline T rcSqr(T a) { return a*a; }
-
-/// Clamps the value to the specified range.
-/// @param[in] v The value to clamp.
-/// @param[in] mn The minimum permitted return value.
-/// @param[in] mx The maximum permitted return value.
-/// @return The value, clamped to the specified range.
-template<class T> inline T rcClamp(T v, T mn, T mx) { return v < mn ? mn : (v > mx ? mx : v); }
-
-/// Returns the square root of the value.
-/// @param[in] x The value.
-/// @return The square root of the vlaue.
-float rcSqrt(float x);
-
-/// @}
-/// @name Vector helper functions.
-/// @{
-
-/// Derives the cross product of two vectors. (@p v1 x @p v2)
-/// @param[out] dest The cross product. [(x, y, z)]
-/// @param[in] v1 A Vector [(x, y, z)]
-/// @param[in] v2 A vector [(x, y, z)]
-inline void rcVcross(float* dest, const float* v1, const float* v2)
-{
- dest[0] = v1[1]*v2[2] - v1[2]*v2[1];
- dest[1] = v1[2]*v2[0] - v1[0]*v2[2];
- dest[2] = v1[0]*v2[1] - v1[1]*v2[0];
-}
-
-/// Derives the dot product of two vectors. (@p v1 . @p v2)
-/// @param[in] v1 A Vector [(x, y, z)]
-/// @param[in] v2 A vector [(x, y, z)]
-/// @return The dot product.
-inline float rcVdot(const float* v1, const float* v2)
-{
- return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
-}
-
-/// Performs a scaled vector addition. (@p v1 + (@p v2 * @p s))
-/// @param[out] dest The result vector. [(x, y, z)]
-/// @param[in] v1 The base vector. [(x, y, z)]
-/// @param[in] v2 The vector to scale and add to @p v1. [(x, y, z)]
-/// @param[in] s The amount to scale @p v2 by before adding to @p v1.
-inline void rcVmad(float* dest, const float* v1, const float* v2, const float s)
-{
- dest[0] = v1[0]+v2[0]*s;
- dest[1] = v1[1]+v2[1]*s;
- dest[2] = v1[2]+v2[2]*s;
-}
-
-/// Performs a vector addition. (@p v1 + @p v2)
-/// @param[out] dest The result vector. [(x, y, z)]
-/// @param[in] v1 The base vector. [(x, y, z)]
-/// @param[in] v2 The vector to add to @p v1. [(x, y, z)]
-inline void rcVadd(float* dest, const float* v1, const float* v2)
-{
- dest[0] = v1[0]+v2[0];
- dest[1] = v1[1]+v2[1];
- dest[2] = v1[2]+v2[2];
-}
-
-/// Performs a vector subtraction. (@p v1 - @p v2)
-/// @param[out] dest The result vector. [(x, y, z)]
-/// @param[in] v1 The base vector. [(x, y, z)]
-/// @param[in] v2 The vector to subtract from @p v1. [(x, y, z)]
-inline void rcVsub(float* dest, const float* v1, const float* v2)
-{
- dest[0] = v1[0]-v2[0];
- dest[1] = v1[1]-v2[1];
- dest[2] = v1[2]-v2[2];
-}
-
-/// Selects the minimum value of each element from the specified vectors.
-/// @param[in,out] mn A vector. (Will be updated with the result.) [(x, y, z)]
-/// @param[in] v A vector. [(x, y, z)]
-inline void rcVmin(float* mn, const float* v)
-{
- mn[0] = rcMin(mn[0], v[0]);
- mn[1] = rcMin(mn[1], v[1]);
- mn[2] = rcMin(mn[2], v[2]);
-}
-
-/// Selects the maximum value of each element from the specified vectors.
-/// @param[in,out] mx A vector. (Will be updated with the result.) [(x, y, z)]
-/// @param[in] v A vector. [(x, y, z)]
-inline void rcVmax(float* mx, const float* v)
-{
- mx[0] = rcMax(mx[0], v[0]);
- mx[1] = rcMax(mx[1], v[1]);
- mx[2] = rcMax(mx[2], v[2]);
-}
-
-/// Performs a vector copy.
-/// @param[out] dest The result. [(x, y, z)]
-/// @param[in] v The vector to copy. [(x, y, z)]
-inline void rcVcopy(float* dest, const float* v)
-{
- dest[0] = v[0];
- dest[1] = v[1];
- dest[2] = v[2];
-}
-
-/// Returns the distance between two points.
-/// @param[in] v1 A point. [(x, y, z)]
-/// @param[in] v2 A point. [(x, y, z)]
-/// @return The distance between the two points.
-inline float rcVdist(const float* v1, const float* v2)
-{
- float dx = v2[0] - v1[0];
- float dy = v2[1] - v1[1];
- float dz = v2[2] - v1[2];
- return rcSqrt(dx*dx + dy*dy + dz*dz);
-}
-
-/// Returns the square of the distance between two points.
-/// @param[in] v1 A point. [(x, y, z)]
-/// @param[in] v2 A point. [(x, y, z)]
-/// @return The square of the distance between the two points.
-inline float rcVdistSqr(const float* v1, const float* v2)
-{
- float dx = v2[0] - v1[0];
- float dy = v2[1] - v1[1];
- float dz = v2[2] - v1[2];
- return dx*dx + dy*dy + dz*dz;
-}
-
-/// Normalizes the vector.
-/// @param[in,out] v The vector to normalize. [(x, y, z)]
-inline void rcVnormalize(float* v)
-{
- float d = 1.0f / rcSqrt(rcSqr(v[0]) + rcSqr(v[1]) + rcSqr(v[2]));
- v[0] *= d;
- v[1] *= d;
- v[2] *= d;
-}
-
-/// @}
-/// @name Heightfield Functions
-/// @see rcHeightfield
-/// @{
-
-/// Calculates the bounding box of an array of vertices.
-/// @ingroup recast
-/// @param[in] verts An array of vertices. [(x, y, z) * @p nv]
-/// @param[in] nv The number of vertices in the @p verts array.
-/// @param[out] bmin The minimum bounds of the AABB. [(x, y, z)] [Units: wu]
-/// @param[out] bmax The maximum bounds of the AABB. [(x, y, z)] [Units: wu]
-void rcCalcBounds(const float* verts, int nv, float* bmin, float* bmax);
-
-/// Calculates the grid size based on the bounding box and grid cell size.
-/// @ingroup recast
-/// @param[in] bmin The minimum bounds of the AABB. [(x, y, z)] [Units: wu]
-/// @param[in] bmax The maximum bounds of the AABB. [(x, y, z)] [Units: wu]
-/// @param[in] cs The xz-plane cell size. [Limit: > 0] [Units: wu]
-/// @param[out] w The width along the x-axis. [Limit: >= 0] [Units: vx]
-/// @param[out] h The height along the z-axis. [Limit: >= 0] [Units: vx]
-void rcCalcGridSize(const float* bmin, const float* bmax, float cs, int* w, int* h);
-
-/// Initializes a new heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in,out] hf The allocated heightfield to initialize.
-/// @param[in] width The width of the field along the x-axis. [Limit: >= 0] [Units: vx]
-/// @param[in] height The height of the field along the z-axis. [Limit: >= 0] [Units: vx]
-/// @param[in] bmin The minimum bounds of the field's AABB. [(x, y, z)] [Units: wu]
-/// @param[in] bmax The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu]
-/// @param[in] cs The xz-plane cell size to use for the field. [Limit: > 0] [Units: wu]
-/// @param[in] ch The y-axis cell size to use for field. [Limit: > 0] [Units: wu]
-/// @returns True if the operation completed successfully.
-bool rcCreateHeightfield(rcContext* ctx, rcHeightfield& hf, int width, int height,
- const float* bmin, const float* bmax,
- float cs, float ch);
-
-/// Sets the area id of all triangles with a slope below the specified value
-/// to #RC_WALKABLE_AREA.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] walkableSlopeAngle The maximum slope that is considered walkable.
-/// [Limits: 0 <= value < 90] [Units: Degrees]
-/// @param[in] verts The vertices. [(x, y, z) * @p nv]
-/// @param[in] nv The number of vertices.
-/// @param[in] tris The triangle vertex indices. [(vertA, vertB, vertC) * @p nt]
-/// @param[in] nt The number of triangles.
-/// @param[out] areas The triangle area ids. [Length: >= @p nt]
-void rcMarkWalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, const float* verts, int nv,
- const int* tris, int nt, unsigned char* areas);
-
-/// Sets the area id of all triangles with a slope greater than or equal to the specified value to #RC_NULL_AREA.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] walkableSlopeAngle The maximum slope that is considered walkable.
-/// [Limits: 0 <= value < 90] [Units: Degrees]
-/// @param[in] verts The vertices. [(x, y, z) * @p nv]
-/// @param[in] nv The number of vertices.
-/// @param[in] tris The triangle vertex indices. [(vertA, vertB, vertC) * @p nt]
-/// @param[in] nt The number of triangles.
-/// @param[out] areas The triangle area ids. [Length: >= @p nt]
-void rcClearUnwalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, const float* verts, int nv,
- const int* tris, int nt, unsigned char* areas);
-
-/// Adds a span to the specified heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in,out] hf An initialized heightfield.
-/// @param[in] x The width index where the span is to be added.
-/// [Limits: 0 <= value < rcHeightfield::width]
-/// @param[in] y The height index where the span is to be added.
-/// [Limits: 0 <= value < rcHeightfield::height]
-/// @param[in] smin The minimum height of the span. [Limit: < @p smax] [Units: vx]
-/// @param[in] smax The maximum height of the span. [Limit: <= #RC_SPAN_MAX_HEIGHT] [Units: vx]
-/// @param[in] area The area id of the span. [Limit: <= #RC_WALKABLE_AREA)
-/// @param[in] flagMergeThr The merge theshold. [Limit: >= 0] [Units: vx]
-/// @returns True if the operation completed successfully.
-bool rcAddSpan(rcContext* ctx, rcHeightfield& hf, const int x, const int y,
- const unsigned short smin, const unsigned short smax,
- const unsigned char area, const int flagMergeThr);
-
-/// Rasterizes a triangle into the specified heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] v0 Triangle vertex 0 [(x, y, z)]
-/// @param[in] v1 Triangle vertex 1 [(x, y, z)]
-/// @param[in] v2 Triangle vertex 2 [(x, y, z)]
-/// @param[in] area The area id of the triangle. [Limit: <= #RC_WALKABLE_AREA]
-/// @param[in,out] solid An initialized heightfield.
-/// @param[in] flagMergeThr The distance where the walkable flag is favored over the non-walkable flag.
-/// [Limit: >= 0] [Units: vx]
-/// @returns True if the operation completed successfully.
-bool rcRasterizeTriangle(rcContext* ctx, const float* v0, const float* v1, const float* v2,
- const unsigned char area, rcHeightfield& solid,
- const int flagMergeThr = 1);
-
-/// Rasterizes an indexed triangle mesh into the specified heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] verts The vertices. [(x, y, z) * @p nv]
-/// @param[in] nv The number of vertices.
-/// @param[in] tris The triangle indices. [(vertA, vertB, vertC) * @p nt]
-/// @param[in] areas The area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]
-/// @param[in] nt The number of triangles.
-/// @param[in,out] solid An initialized heightfield.
-/// @param[in] flagMergeThr The distance where the walkable flag is favored over the non-walkable flag.
-/// [Limit: >= 0] [Units: vx]
-/// @returns True if the operation completed successfully.
-bool rcRasterizeTriangles(rcContext* ctx, const float* verts, const int nv,
- const int* tris, const unsigned char* areas, const int nt,
- rcHeightfield& solid, const int flagMergeThr = 1);
-
-/// Rasterizes an indexed triangle mesh into the specified heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] verts The vertices. [(x, y, z) * @p nv]
-/// @param[in] nv The number of vertices.
-/// @param[in] tris The triangle indices. [(vertA, vertB, vertC) * @p nt]
-/// @param[in] areas The area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]
-/// @param[in] nt The number of triangles.
-/// @param[in,out] solid An initialized heightfield.
-/// @param[in] flagMergeThr The distance where the walkable flag is favored over the non-walkable flag.
-/// [Limit: >= 0] [Units: vx]
-/// @returns True if the operation completed successfully.
-bool rcRasterizeTriangles(rcContext* ctx, const float* verts, const int nv,
- const unsigned short* tris, const unsigned char* areas, const int nt,
- rcHeightfield& solid, const int flagMergeThr = 1);
-
-/// Rasterizes triangles into the specified heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] verts The triangle vertices. [(ax, ay, az, bx, by, bz, cx, by, cx) * @p nt]
-/// @param[in] areas The area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]
-/// @param[in] nt The number of triangles.
-/// @param[in,out] solid An initialized heightfield.
-/// @param[in] flagMergeThr The distance where the walkable flag is favored over the non-walkable flag.
-/// [Limit: >= 0] [Units: vx]
-/// @returns True if the operation completed successfully.
-bool rcRasterizeTriangles(rcContext* ctx, const float* verts, const unsigned char* areas, const int nt,
- rcHeightfield& solid, const int flagMergeThr = 1);
-
-/// Marks non-walkable spans as walkable if their maximum is within @p walkableClimp of a walkable neihbor.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] walkableClimb Maximum ledge height that is considered to still be traversable.
-/// [Limit: >=0] [Units: vx]
-/// @param[in,out] solid A fully built heightfield. (All spans have been added.)
-void rcFilterLowHangingWalkableObstacles(rcContext* ctx, const int walkableClimb, rcHeightfield& solid);
-
-/// Marks spans that are ledges as not-walkable.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] walkableHeight Minimum floor to 'ceiling' height that will still allow the floor area to
-/// be considered walkable. [Limit: >= 3] [Units: vx]
-/// @param[in] walkableClimb Maximum ledge height that is considered to still be traversable.
-/// [Limit: >=0] [Units: vx]
-/// @param[in,out] solid A fully built heightfield. (All spans have been added.)
-void rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight,
- const int walkableClimb, rcHeightfield& solid);
-
-/// Marks walkable spans as not walkable if the clearence above the span is less than the specified height.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] walkableHeight Minimum floor to 'ceiling' height that will still allow the floor area to
-/// be considered walkable. [Limit: >= 3] [Units: vx]
-/// @param[in,out] solid A fully built heightfield. (All spans have been added.)
-void rcFilterWalkableLowHeightSpans(rcContext* ctx, int walkableHeight, rcHeightfield& solid);
-
-/// Returns the number of spans contained in the specified heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] hf An initialized heightfield.
-/// @returns The number of spans in the heightfield.
-int rcGetHeightFieldSpanCount(rcContext* ctx, rcHeightfield& hf);
-
-/// @}
-/// @name Compact Heightfield Functions
-/// @see rcCompactHeightfield
-/// @{
-
-/// Builds a compact heightfield representing open space, from a heightfield representing solid space.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] walkableHeight Minimum floor to 'ceiling' height that will still allow the floor area
-/// to be considered walkable. [Limit: >= 3] [Units: vx]
-/// @param[in] walkableClimb Maximum ledge height that is considered to still be traversable.
-/// [Limit: >=0] [Units: vx]
-/// @param[in] hf The heightfield to be compacted.
-/// @param[out] chf The resulting compact heightfield. (Must be pre-allocated.)
-/// @returns True if the operation completed successfully.
-bool rcBuildCompactHeightfield(rcContext* ctx, const int walkableHeight, const int walkableClimb,
- rcHeightfield& hf, rcCompactHeightfield& chf);
-
-/// Erodes the walkable area within the heightfield by the specified radius.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] radius The radius of erosion. [Limits: 0 < value < 255] [Units: vx]
-/// @param[in,out] chf The populated compact heightfield to erode.
-/// @returns True if the operation completed successfully.
-bool rcErodeWalkableArea(rcContext* ctx, int radius, rcCompactHeightfield& chf);
-
-/// Applies a median filter to walkable area types (based on area id), removing noise.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in,out] chf A populated compact heightfield.
-/// @returns True if the operation completed successfully.
-bool rcMedianFilterWalkableArea(rcContext* ctx, rcCompactHeightfield& chf);
-
-/// Applies an area id to all spans within the specified bounding box. (AABB)
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] bmin The minimum of the bounding box. [(x, y, z)]
-/// @param[in] bmax The maximum of the bounding box. [(x, y, z)]
-/// @param[in] areaId The area id to apply. [Limit: <= #RC_WALKABLE_AREA]
-/// @param[in,out] chf A populated compact heightfield.
-void rcMarkBoxArea(rcContext* ctx, const float* bmin, const float* bmax, unsigned char areaId,
- rcCompactHeightfield& chf);
-
-/// Applies the area id to the all spans within the specified convex polygon.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] verts The vertices of the polygon [Fomr: (x, y, z) * @p nverts]
-/// @param[in] nverts The number of vertices in the polygon.
-/// @param[in] hmin The height of the base of the polygon.
-/// @param[in] hmax The height of the top of the polygon.
-/// @param[in] areaId The area id to apply. [Limit: <= #RC_WALKABLE_AREA]
-/// @param[in,out] chf A populated compact heightfield.
-void rcMarkConvexPolyArea(rcContext* ctx, const float* verts, const int nverts,
- const float hmin, const float hmax, unsigned char areaId,
- rcCompactHeightfield& chf);
-
-/// Helper function to offset voncex polygons for rcMarkConvexPolyArea.
-/// @ingroup recast
-/// @param[in] verts The vertices of the polygon [Form: (x, y, z) * @p nverts]
-/// @param[in] nverts The number of vertices in the polygon.
-/// @param[out] outVerts The offset vertices (should hold up to 2 * @p nverts) [Form: (x, y, z) * return value]
-/// @param[in] maxOutVerts The max number of vertices that can be stored to @p outVerts.
-/// @returns Number of vertices in the offset polygon or 0 if too few vertices in @p outVerts.
-int rcOffsetPoly(const float* verts, const int nverts, const float offset,
- float* outVerts, const int maxOutVerts);
-
-/// Applies the area id to all spans within the specified cylinder.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] pos The center of the base of the cylinder. [Form: (x, y, z)]
-/// @param[in] r The radius of the cylinder.
-/// @param[in] h The height of the cylinder.
-/// @param[in] areaId The area id to apply. [Limit: <= #RC_WALKABLE_AREA]
-/// @param[in,out] chf A populated compact heightfield.
-void rcMarkCylinderArea(rcContext* ctx, const float* pos,
- const float r, const float h, unsigned char areaId,
- rcCompactHeightfield& chf);
-
-/// Builds the distance field for the specified compact heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in,out] chf A populated compact heightfield.
-/// @returns True if the operation completed successfully.
-bool rcBuildDistanceField(rcContext* ctx, rcCompactHeightfield& chf);
-
-/// Builds region data for the heightfield using watershed partitioning.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in,out] chf A populated compact heightfield.
-/// @param[in] borderSize The size of the non-navigable border around the heightfield.
-/// [Limit: >=0] [Units: vx]
-/// @param[in] minRegionArea The minimum number of cells allowed to form isolated island areas.
-/// [Limit: >=0] [Units: vx].
-/// @param[in] mergeRegionArea Any regions with a span count smaller than this value will, if possible,
-/// be merged with larger regions. [Limit: >=0] [Units: vx]
-/// @returns True if the operation completed successfully.
-bool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,
- const int borderSize, const int minRegionArea, const int mergeRegionArea);
-
-/// Builds region data for the heightfield by partitioning the heightfield in non-overlapping layers.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in,out] chf A populated compact heightfield.
-/// @param[in] borderSize The size of the non-navigable border around the heightfield.
-/// [Limit: >=0] [Units: vx]
-/// @param[in] minRegionArea The minimum number of cells allowed to form isolated island areas.
-/// [Limit: >=0] [Units: vx].
-/// @returns True if the operation completed successfully.
-bool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,
- const int borderSize, const int minRegionArea);
-
-/// Builds region data for the heightfield using simple monotone partitioning.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in,out] chf A populated compact heightfield.
-/// @param[in] borderSize The size of the non-navigable border around the heightfield.
-/// [Limit: >=0] [Units: vx]
-/// @param[in] minRegionArea The minimum number of cells allowed to form isolated island areas.
-/// [Limit: >=0] [Units: vx].
-/// @param[in] mergeRegionArea Any regions with a span count smaller than this value will, if possible,
-/// be merged with larger regions. [Limit: >=0] [Units: vx]
-/// @returns True if the operation completed successfully.
-bool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,
- const int borderSize, const int minRegionArea, const int mergeRegionArea);
-
-/// Sets the neighbor connection data for the specified direction.
-/// @param[in] s The span to update.
-/// @param[in] dir The direction to set. [Limits: 0 <= value < 4]
-/// @param[in] i The index of the neighbor span.
-inline void rcSetCon(rcCompactSpan& s, int dir, int i)
-{
- const unsigned int shift = (unsigned int)dir*6;
- unsigned int con = s.con;
- s.con = (con & ~(0x3f << shift)) | (((unsigned int)i & 0x3f) << shift);
-}
-
-/// Gets neighbor connection data for the specified direction.
-/// @param[in] s The span to check.
-/// @param[in] dir The direction to check. [Limits: 0 <= value < 4]
-/// @return The neighbor connection data for the specified direction,
-/// or #RC_NOT_CONNECTED if there is no connection.
-inline int rcGetCon(const rcCompactSpan& s, int dir)
-{
- const unsigned int shift = (unsigned int)dir*6;
- return (s.con >> shift) & 0x3f;
-}
-
-/// Gets the standard width (x-axis) offset for the specified direction.
-/// @param[in] dir The direction. [Limits: 0 <= value < 4]
-/// @return The width offset to apply to the current cell position to move
-/// in the direction.
-inline int rcGetDirOffsetX(int dir)
-{
- static const int offset[4] = { -1, 0, 1, 0, };
- return offset[dir&0x03];
-}
-
-/// Gets the standard height (z-axis) offset for the specified direction.
-/// @param[in] dir The direction. [Limits: 0 <= value < 4]
-/// @return The height offset to apply to the current cell position to move
-/// in the direction.
-inline int rcGetDirOffsetY(int dir)
-{
- static const int offset[4] = { 0, 1, 0, -1 };
- return offset[dir&0x03];
-}
-
-/// Gets the direction for the specified offset. One of x and y should be 0.
-/// @param[in] x The x offset. [Limits: -1 <= value <= 1]
-/// @param[in] y The y offset. [Limits: -1 <= value <= 1]
-/// @return The direction that represents the offset.
-inline int rcGetDirForOffset(int x, int y)
-{
- static const int dirs[5] = { 3, 0, -1, 2, 1 };
- return dirs[((y+1)<<1)+x];
-}
-
-/// @}
-/// @name Layer, Contour, Polymesh, and Detail Mesh Functions
-/// @see rcHeightfieldLayer, rcContourSet, rcPolyMesh, rcPolyMeshDetail
-/// @{
-
-/// Builds a layer set from the specified compact heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] chf A fully built compact heightfield.
-/// @param[in] borderSize The size of the non-navigable border around the heightfield. [Limit: >=0]
-/// [Units: vx]
-/// @param[in] walkableHeight Minimum floor to 'ceiling' height that will still allow the floor area
-/// to be considered walkable. [Limit: >= 3] [Units: vx]
-/// @param[out] lset The resulting layer set. (Must be pre-allocated.)
-/// @returns True if the operation completed successfully.
-bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
- const int borderSize, const int walkableHeight,
- rcHeightfieldLayerSet& lset);
-
-/// Builds a contour set from the region outlines in the provided compact heightfield.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] chf A fully built compact heightfield.
-/// @param[in] maxError The maximum distance a simplfied contour's border edges should deviate
-/// the original raw contour. [Limit: >=0] [Units: wu]
-/// @param[in] maxEdgeLen The maximum allowed length for contour edges along the border of the mesh.
-/// [Limit: >=0] [Units: vx]
-/// @param[out] cset The resulting contour set. (Must be pre-allocated.)
-/// @param[in] buildFlags The build flags. (See: #rcBuildContoursFlags)
-/// @returns True if the operation completed successfully.
-bool rcBuildContours(rcContext* ctx, rcCompactHeightfield& chf,
- const float maxError, const int maxEdgeLen,
- rcContourSet& cset, const int buildFlags = RC_CONTOUR_TESS_WALL_EDGES);
-
-/// Builds a polygon mesh from the provided contours.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] cset A fully built contour set.
-/// @param[in] nvp The maximum number of vertices allowed for polygons generated during the
-/// contour to polygon conversion process. [Limit: >= 3]
-/// @param[out] mesh The resulting polygon mesh. (Must be re-allocated.)
-/// @returns True if the operation completed successfully.
-bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMesh& mesh);
-
-/// Merges multiple polygon meshes into a single mesh.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] meshes An array of polygon meshes to merge. [Size: @p nmeshes]
-/// @param[in] nmeshes The number of polygon meshes in the meshes array.
-/// @param[in] mesh The resulting polygon mesh. (Must be pre-allocated.)
-/// @returns True if the operation completed successfully.
-bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, rcPolyMesh& mesh);
-
-/// Builds a detail mesh from the provided polygon mesh.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] mesh A fully built polygon mesh.
-/// @param[in] chf The compact heightfield used to build the polygon mesh.
-/// @param[in] sampleDist Sets the distance to use when samping the heightfield. [Limit: >=0] [Units: wu]
-/// @param[in] sampleMaxError The maximum distance the detail mesh surface should deviate from
-/// heightfield data. [Limit: >=0] [Units: wu]
-/// @param[out] dmesh The resulting detail mesh. (Must be pre-allocated.)
-/// @returns True if the operation completed successfully.
-bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompactHeightfield& chf,
- const float sampleDist, const float sampleMaxError,
- rcPolyMeshDetail& dmesh);
-
-/// Copies the poly mesh data from src to dst.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] src The source mesh to copy from.
-/// @param[out] dst The resulting detail mesh. (Must be pre-allocated, must be empty mesh.)
-/// @returns True if the operation completed successfully.
-bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst);
-
-/// Merges multiple detail meshes into a single detail mesh.
-/// @ingroup recast
-/// @param[in,out] ctx The build context to use during the operation.
-/// @param[in] meshes An array of detail meshes to merge. [Size: @p nmeshes]
-/// @param[in] nmeshes The number of detail meshes in the meshes array.
-/// @param[out] mesh The resulting detail mesh. (Must be pre-allocated.)
-/// @returns True if the operation completed successfully.
-bool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int nmeshes, rcPolyMeshDetail& mesh);
-
-bool buildMeshAdjacency(unsigned short* polys, const int npolys, const int nverts, const int vertsPerPoly);
-
-/// @}
-
-#endif // RECAST_H
-
-///////////////////////////////////////////////////////////////////////////
-
-// Due to the large amount of detail documentation for this file,
-// the content normally located at the end of the header file has been separated
-// out to a file in /Docs/Extern.
diff --git a/extern/recastnavigation/Recast/Include/RecastAlloc.h b/extern/recastnavigation/Recast/Include/RecastAlloc.h
deleted file mode 100644
index f1608fb5537..00000000000
--- a/extern/recastnavigation/Recast/Include/RecastAlloc.h
+++ /dev/null
@@ -1,147 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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 RECASTALLOC_H
-#define RECASTALLOC_H
-
-#include <stddef.h>
-
-/// Provides hint values to the memory allocator on how long the
-/// memory is expected to be used.
-enum rcAllocHint
-{
- RC_ALLOC_PERM, ///< Memory will persist after a function call.
- RC_ALLOC_TEMP ///< Memory used temporarily within a function.
-};
-
-/// A memory allocation function.
-// @param[in] size The size, in bytes of memory, to allocate.
-// @param[in] rcAllocHint A hint to the allocator on how long the memory is expected to be in use.
-// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
-/// @see rcAllocSetCustom
-typedef void* (rcAllocFunc)(size_t size, rcAllocHint hint);
-
-/// A memory deallocation function.
-/// @param[in] ptr A pointer to a memory block previously allocated using #rcAllocFunc.
-/// @see rcAllocSetCustom
-typedef void (rcFreeFunc)(void* ptr);
-
-/// Sets the base custom allocation functions to be used by Recast.
-/// @param[in] allocFunc The memory allocation function to be used by #rcAlloc
-/// @param[in] freeFunc The memory de-allocation function to be used by #rcFree
-void rcAllocSetCustom(rcAllocFunc *allocFunc, rcFreeFunc *freeFunc);
-
-/// Allocates a memory block.
-/// @param[in] size The size, in bytes of memory, to allocate.
-/// @param[in] hint A hint to the allocator on how long the memory is expected to be in use.
-/// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
-/// @see rcFree
-void* rcAlloc(size_t size, rcAllocHint hint);
-
-/// Deallocates a memory block.
-/// @param[in] ptr A pointer to a memory block previously allocated using #rcAlloc.
-/// @see rcAlloc
-void rcFree(void* ptr);
-
-
-/// A simple dynamic array of integers.
-class rcIntArray
-{
- int* m_data;
- int m_size, m_cap;
-
- void doResize(int n);
-
- // Explicitly disabled copy constructor and copy assignment operator.
- rcIntArray(const rcIntArray&);
- rcIntArray& operator=(const rcIntArray&);
-
-public:
- /// Constructs an instance with an initial array size of zero.
- rcIntArray() : m_data(0), m_size(0), m_cap(0) {}
-
- /// Constructs an instance initialized to the specified size.
- /// @param[in] n The initial size of the integer array.
- rcIntArray(int n) : m_data(0), m_size(0), m_cap(0) { resize(n); }
- ~rcIntArray() { rcFree(m_data); }
-
- /// Specifies the new size of the integer array.
- /// @param[in] n The new size of the integer array.
- void resize(int n)
- {
- if (n > m_cap)
- doResize(n);
-
- m_size = n;
- }
-
- /// Push the specified integer onto the end of the array and increases the size by one.
- /// @param[in] item The new value.
- void push(int item) { resize(m_size+1); m_data[m_size-1] = item; }
-
- /// Returns the value at the end of the array and reduces the size by one.
- /// @return The value at the end of the array.
- int pop()
- {
- if (m_size > 0)
- m_size--;
-
- return m_data[m_size];
- }
-
- /// The value at the specified array index.
- /// @warning Does not provide overflow protection.
- /// @param[in] i The index of the value.
- const int& operator[](int i) const { return m_data[i]; }
-
- /// The value at the specified array index.
- /// @warning Does not provide overflow protection.
- /// @param[in] i The index of the value.
- int& operator[](int i) { return m_data[i]; }
-
- /// The current size of the integer array.
- int size() const { return m_size; }
-};
-
-/// A simple helper class used to delete an array when it goes out of scope.
-/// @note This class is rarely if ever used by the end user.
-template<class T> class rcScopedDelete
-{
- T* ptr;
- inline T* operator=(T* p);
-public:
-
- /// Constructs an instance with a null pointer.
- inline rcScopedDelete() : ptr(0) {}
-
- /// Constructs an instance with the specified pointer.
- /// @param[in] p An pointer to an allocated array.
- inline rcScopedDelete(T* p) : ptr(p) {}
- inline ~rcScopedDelete() { rcFree(ptr); }
-
- /// The root array pointer.
- /// @return The root array pointer.
- inline operator T*() { return ptr; }
-
-private:
- // Explicitly disabled copy constructor and copy assignment operator.
- rcScopedDelete(const rcScopedDelete&);
- rcScopedDelete& operator=(const rcScopedDelete&);
-};
-
-#endif
diff --git a/extern/recastnavigation/Recast/Include/RecastAssert.h b/extern/recastnavigation/Recast/Include/RecastAssert.h
deleted file mode 100644
index 2aca0d9a14f..00000000000
--- a/extern/recastnavigation/Recast/Include/RecastAssert.h
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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 RECASTASSERT_H
-#define RECASTASSERT_H
-
-// Note: This header file's only purpose is to include define assert.
-// Feel free to change the file and include your own implementation instead.
-
-#ifdef NDEBUG
-// From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
-# define rcAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)
-#else
-# include <assert.h>
-# define rcAssert assert
-#endif
-
-#endif // RECASTASSERT_H
diff --git a/extern/recastnavigation/Recast/Source/Recast.cpp b/extern/recastnavigation/Recast/Source/Recast.cpp
deleted file mode 100644
index 46bc8b7810d..00000000000
--- a/extern/recastnavigation/Recast/Source/Recast.cpp
+++ /dev/null
@@ -1,487 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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 <float.h>
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include "Recast.h"
-#include "RecastAlloc.h"
-#include "RecastAssert.h"
-
-float rcSqrt(float x)
-{
- return sqrtf(x);
-}
-
-/// @class rcContext
-/// @par
-///
-/// This class does not provide logging or timer functionality on its
-/// own. Both must be provided by a concrete implementation
-/// by overriding the protected member functions. Also, this class does not
-/// provide an interface for extracting log messages. (Only adding them.)
-/// So concrete implementations must provide one.
-///
-/// If no logging or timers are required, just pass an instance of this
-/// class through the Recast build process.
-///
-
-/// @par
-///
-/// Example:
-/// @code
-/// // Where ctx is an instance of rcContext and filepath is a char array.
-/// ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Could not load '%s'", filepath);
-/// @endcode
-void rcContext::log(const rcLogCategory category, const char* format, ...)
-{
- if (!m_logEnabled)
- return;
- static const int MSG_SIZE = 512;
- char msg[MSG_SIZE];
- va_list ap;
- va_start(ap, format);
- int len = vsnprintf(msg, MSG_SIZE, format, ap);
- if (len >= MSG_SIZE)
- {
- len = MSG_SIZE-1;
- msg[MSG_SIZE-1] = '\0';
- }
- va_end(ap);
- doLog(category, msg, len);
-}
-
-rcHeightfield* rcAllocHeightfield()
-{
- rcHeightfield* hf = (rcHeightfield*)rcAlloc(sizeof(rcHeightfield), RC_ALLOC_PERM);
- memset(hf, 0, sizeof(rcHeightfield));
- return hf;
-}
-
-void rcFreeHeightField(rcHeightfield* hf)
-{
- if (!hf) return;
- // Delete span array.
- rcFree(hf->spans);
- // Delete span pools.
- while (hf->pools)
- {
- rcSpanPool* next = hf->pools->next;
- rcFree(hf->pools);
- hf->pools = next;
- }
- rcFree(hf);
-}
-
-rcCompactHeightfield* rcAllocCompactHeightfield()
-{
- rcCompactHeightfield* chf = (rcCompactHeightfield*)rcAlloc(sizeof(rcCompactHeightfield), RC_ALLOC_PERM);
- memset(chf, 0, sizeof(rcCompactHeightfield));
- return chf;
-}
-
-void rcFreeCompactHeightfield(rcCompactHeightfield* chf)
-{
- if (!chf) return;
- rcFree(chf->cells);
- rcFree(chf->spans);
- rcFree(chf->dist);
- rcFree(chf->areas);
- rcFree(chf);
-}
-
-
-rcHeightfieldLayerSet* rcAllocHeightfieldLayerSet()
-{
- rcHeightfieldLayerSet* lset = (rcHeightfieldLayerSet*)rcAlloc(sizeof(rcHeightfieldLayerSet), RC_ALLOC_PERM);
- memset(lset, 0, sizeof(rcHeightfieldLayerSet));
- return lset;
-}
-
-void rcFreeHeightfieldLayerSet(rcHeightfieldLayerSet* lset)
-{
- if (!lset) return;
- for (int i = 0; i < lset->nlayers; ++i)
- {
- rcFree(lset->layers[i].heights);
- rcFree(lset->layers[i].areas);
- rcFree(lset->layers[i].cons);
- }
- rcFree(lset->layers);
- rcFree(lset);
-}
-
-
-rcContourSet* rcAllocContourSet()
-{
- rcContourSet* cset = (rcContourSet*)rcAlloc(sizeof(rcContourSet), RC_ALLOC_PERM);
- memset(cset, 0, sizeof(rcContourSet));
- return cset;
-}
-
-void rcFreeContourSet(rcContourSet* cset)
-{
- if (!cset) return;
- for (int i = 0; i < cset->nconts; ++i)
- {
- rcFree(cset->conts[i].verts);
- rcFree(cset->conts[i].rverts);
- }
- rcFree(cset->conts);
- rcFree(cset);
-}
-
-rcPolyMesh* rcAllocPolyMesh()
-{
- rcPolyMesh* pmesh = (rcPolyMesh*)rcAlloc(sizeof(rcPolyMesh), RC_ALLOC_PERM);
- memset(pmesh, 0, sizeof(rcPolyMesh));
- return pmesh;
-}
-
-void rcFreePolyMesh(rcPolyMesh* pmesh)
-{
- if (!pmesh) return;
- rcFree(pmesh->verts);
- rcFree(pmesh->polys);
- rcFree(pmesh->regs);
- rcFree(pmesh->flags);
- rcFree(pmesh->areas);
- rcFree(pmesh);
-}
-
-rcPolyMeshDetail* rcAllocPolyMeshDetail()
-{
- rcPolyMeshDetail* dmesh = (rcPolyMeshDetail*)rcAlloc(sizeof(rcPolyMeshDetail), RC_ALLOC_PERM);
- memset(dmesh, 0, sizeof(rcPolyMeshDetail));
- return dmesh;
-}
-
-void rcFreePolyMeshDetail(rcPolyMeshDetail* dmesh)
-{
- if (!dmesh) return;
- rcFree(dmesh->meshes);
- rcFree(dmesh->verts);
- rcFree(dmesh->tris);
- rcFree(dmesh);
-}
-
-void rcCalcBounds(const float* verts, int nv, float* bmin, float* bmax)
-{
- // Calculate bounding box.
- rcVcopy(bmin, verts);
- rcVcopy(bmax, verts);
- for (int i = 1; i < nv; ++i)
- {
- const float* v = &verts[i*3];
- rcVmin(bmin, v);
- rcVmax(bmax, v);
- }
-}
-
-void rcCalcGridSize(const float* bmin, const float* bmax, float cs, int* w, int* h)
-{
- *w = (int)((bmax[0] - bmin[0])/cs+0.5f);
- *h = (int)((bmax[2] - bmin[2])/cs+0.5f);
-}
-
-/// @par
-///
-/// See the #rcConfig documentation for more information on the configuration parameters.
-///
-/// @see rcAllocHeightfield, rcHeightfield
-bool rcCreateHeightfield(rcContext* ctx, rcHeightfield& hf, int width, int height,
- const float* bmin, const float* bmax,
- float cs, float ch)
-{
- rcIgnoreUnused(ctx);
-
- hf.width = width;
- hf.height = height;
- rcVcopy(hf.bmin, bmin);
- rcVcopy(hf.bmax, bmax);
- hf.cs = cs;
- hf.ch = ch;
- hf.spans = (rcSpan**)rcAlloc(sizeof(rcSpan*)*hf.width*hf.height, RC_ALLOC_PERM);
- if (!hf.spans)
- return false;
- memset(hf.spans, 0, sizeof(rcSpan*)*hf.width*hf.height);
- return true;
-}
-
-static void calcTriNormal(const float* v0, const float* v1, const float* v2, float* norm)
-{
- float e0[3], e1[3];
- rcVsub(e0, v1, v0);
- rcVsub(e1, v2, v0);
- rcVcross(norm, e0, e1);
- rcVnormalize(norm);
-}
-
-/// @par
-///
-/// Only sets the area id's for the walkable triangles. Does not alter the
-/// area id's for unwalkable triangles.
-///
-/// See the #rcConfig documentation for more information on the configuration parameters.
-///
-/// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles
-void rcMarkWalkableTriangles(rcContext* ctx, const float walkableSlopeAngle,
- const float* verts, int /*nv*/,
- const int* tris, int nt,
- unsigned char* areas)
-{
- rcIgnoreUnused(ctx);
-
- const float walkableThr = cosf(walkableSlopeAngle/180.0f*RC_PI);
-
- float norm[3];
-
- for (int i = 0; i < nt; ++i)
- {
- const int* tri = &tris[i*3];
- calcTriNormal(&verts[tri[0]*3], &verts[tri[1]*3], &verts[tri[2]*3], norm);
- // Check if the face is walkable.
- if (norm[1] > walkableThr)
- areas[i] = RC_WALKABLE_AREA;
- }
-}
-
-/// @par
-///
-/// Only sets the area id's for the unwalkable triangles. Does not alter the
-/// area id's for walkable triangles.
-///
-/// See the #rcConfig documentation for more information on the configuration parameters.
-///
-/// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles
-void rcClearUnwalkableTriangles(rcContext* ctx, const float walkableSlopeAngle,
- const float* verts, int /*nv*/,
- const int* tris, int nt,
- unsigned char* areas)
-{
- rcIgnoreUnused(ctx);
-
- const float walkableThr = cosf(walkableSlopeAngle/180.0f*RC_PI);
-
- float norm[3];
-
- for (int i = 0; i < nt; ++i)
- {
- const int* tri = &tris[i*3];
- calcTriNormal(&verts[tri[0]*3], &verts[tri[1]*3], &verts[tri[2]*3], norm);
- // Check if the face is walkable.
- if (norm[1] <= walkableThr)
- areas[i] = RC_NULL_AREA;
- }
-}
-
-int rcGetHeightFieldSpanCount(rcContext* ctx, rcHeightfield& hf)
-{
- rcIgnoreUnused(ctx);
-
- const int w = hf.width;
- const int h = hf.height;
- int spanCount = 0;
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- for (rcSpan* s = hf.spans[x + y*w]; s; s = s->next)
- {
- if (s->area != RC_NULL_AREA)
- spanCount++;
- }
- }
- }
- return spanCount;
-}
-
-/// @par
-///
-/// This is just the beginning of the process of fully building a compact heightfield.
-/// Various filters may be applied, then the distance field and regions built.
-/// E.g: #rcBuildDistanceField and #rcBuildRegions
-///
-/// See the #rcConfig documentation for more information on the configuration parameters.
-///
-/// @see rcAllocCompactHeightfield, rcHeightfield, rcCompactHeightfield, rcConfig
-bool rcBuildCompactHeightfield(rcContext* ctx, const int walkableHeight, const int walkableClimb,
- rcHeightfield& hf, rcCompactHeightfield& chf)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_BUILD_COMPACTHEIGHTFIELD);
-
- const int w = hf.width;
- const int h = hf.height;
- const int spanCount = rcGetHeightFieldSpanCount(ctx, hf);
-
- // Fill in header.
- chf.width = w;
- chf.height = h;
- chf.spanCount = spanCount;
- chf.walkableHeight = walkableHeight;
- chf.walkableClimb = walkableClimb;
- chf.maxRegions = 0;
- rcVcopy(chf.bmin, hf.bmin);
- rcVcopy(chf.bmax, hf.bmax);
- chf.bmax[1] += walkableHeight*hf.ch;
- chf.cs = hf.cs;
- chf.ch = hf.ch;
- chf.cells = (rcCompactCell*)rcAlloc(sizeof(rcCompactCell)*w*h, RC_ALLOC_PERM);
- if (!chf.cells)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildCompactHeightfield: Out of memory 'chf.cells' (%d)", w*h);
- return false;
- }
- memset(chf.cells, 0, sizeof(rcCompactCell)*w*h);
- chf.spans = (rcCompactSpan*)rcAlloc(sizeof(rcCompactSpan)*spanCount, RC_ALLOC_PERM);
- if (!chf.spans)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildCompactHeightfield: Out of memory 'chf.spans' (%d)", spanCount);
- return false;
- }
- memset(chf.spans, 0, sizeof(rcCompactSpan)*spanCount);
- chf.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*spanCount, RC_ALLOC_PERM);
- if (!chf.areas)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildCompactHeightfield: Out of memory 'chf.areas' (%d)", spanCount);
- return false;
- }
- memset(chf.areas, RC_NULL_AREA, sizeof(unsigned char)*spanCount);
-
- const int MAX_HEIGHT = 0xffff;
-
- // Fill in cells and spans.
- int idx = 0;
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcSpan* s = hf.spans[x + y*w];
- // If there are no spans at this cell, just leave the data to index=0, count=0.
- if (!s) continue;
- rcCompactCell& c = chf.cells[x+y*w];
- c.index = idx;
- c.count = 0;
- while (s)
- {
- if (s->area != RC_NULL_AREA)
- {
- const int bot = (int)s->smax;
- const int top = s->next ? (int)s->next->smin : MAX_HEIGHT;
- chf.spans[idx].y = (unsigned short)rcClamp(bot, 0, 0xffff);
- chf.spans[idx].h = (unsigned char)rcClamp(top - bot, 0, 0xff);
- chf.areas[idx] = s->area;
- idx++;
- c.count++;
- }
- s = s->next;
- }
- }
- }
-
- // Find neighbour connections.
- const int MAX_LAYERS = RC_NOT_CONNECTED-1;
- int tooHighNeighbour = 0;
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- rcCompactSpan& s = chf.spans[i];
-
- for (int dir = 0; dir < 4; ++dir)
- {
- rcSetCon(s, dir, RC_NOT_CONNECTED);
- const int nx = x + rcGetDirOffsetX(dir);
- const int ny = y + rcGetDirOffsetY(dir);
- // First check that the neighbour cell is in bounds.
- if (nx < 0 || ny < 0 || nx >= w || ny >= h)
- continue;
-
- // Iterate over all neighbour spans and check if any of the is
- // accessible from current cell.
- const rcCompactCell& nc = chf.cells[nx+ny*w];
- for (int k = (int)nc.index, nk = (int)(nc.index+nc.count); k < nk; ++k)
- {
- const rcCompactSpan& ns = chf.spans[k];
- const int bot = rcMax(s.y, ns.y);
- const int top = rcMin(s.y+s.h, ns.y+ns.h);
-
- // Check that the gap between the spans is walkable,
- // and that the climb height between the gaps is not too high.
- if ((top - bot) >= walkableHeight && rcAbs((int)ns.y - (int)s.y) <= walkableClimb)
- {
- // Mark direction as walkable.
- const int lidx = k - (int)nc.index;
- if (lidx < 0 || lidx > MAX_LAYERS)
- {
- tooHighNeighbour = rcMax(tooHighNeighbour, lidx);
- continue;
- }
- rcSetCon(s, dir, lidx);
- break;
- }
- }
-
- }
- }
- }
- }
-
- if (tooHighNeighbour > MAX_LAYERS)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildCompactHeightfield: Heightfield has too many layers %d (max: %d)",
- tooHighNeighbour, MAX_LAYERS);
- }
-
- return true;
-}
-
-/*
-static int getHeightfieldMemoryUsage(const rcHeightfield& hf)
-{
- int size = 0;
- size += sizeof(hf);
- size += hf.width * hf.height * sizeof(rcSpan*);
-
- rcSpanPool* pool = hf.pools;
- while (pool)
- {
- size += (sizeof(rcSpanPool) - sizeof(rcSpan)) + sizeof(rcSpan)*RC_SPANS_PER_POOL;
- pool = pool->next;
- }
- return size;
-}
-
-static int getCompactHeightFieldMemoryusage(const rcCompactHeightfield& chf)
-{
- int size = 0;
- size += sizeof(rcCompactHeightfield);
- size += sizeof(rcCompactSpan) * chf.spanCount;
- size += sizeof(rcCompactCell) * chf.width * chf.height;
- return size;
-}
-*/
diff --git a/extern/recastnavigation/Recast/Source/RecastAlloc.cpp b/extern/recastnavigation/Recast/Source/RecastAlloc.cpp
deleted file mode 100644
index ee1039f2f4f..00000000000
--- a/extern/recastnavigation/Recast/Source/RecastAlloc.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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 <stdlib.h>
-#include <string.h>
-#include "RecastAlloc.h"
-
-static void *rcAllocDefault(size_t size, rcAllocHint)
-{
- return malloc(size);
-}
-
-static void rcFreeDefault(void *ptr)
-{
- free(ptr);
-}
-
-static rcAllocFunc* sRecastAllocFunc = rcAllocDefault;
-static rcFreeFunc* sRecastFreeFunc = rcFreeDefault;
-
-/// @see rcAlloc, rcFree
-void rcAllocSetCustom(rcAllocFunc *allocFunc, rcFreeFunc *freeFunc)
-{
- sRecastAllocFunc = allocFunc ? allocFunc : rcAllocDefault;
- sRecastFreeFunc = freeFunc ? freeFunc : rcFreeDefault;
-}
-
-/// @see rcAllocSetCustom
-void* rcAlloc(size_t size, rcAllocHint hint)
-{
- return sRecastAllocFunc(size, hint);
-}
-
-/// @par
-///
-/// @warning This function leaves the value of @p ptr unchanged. So it still
-/// points to the same (now invalid) location, and not to null.
-///
-/// @see rcAllocSetCustom
-void rcFree(void* ptr)
-{
- if (ptr)
- sRecastFreeFunc(ptr);
-}
-
-/// @class rcIntArray
-///
-/// While it is possible to pre-allocate a specific array size during
-/// construction or by using the #resize method, certain methods will
-/// automatically resize the array as needed.
-///
-/// @warning The array memory is not initialized to zero when the size is
-/// manually set during construction or when using #resize.
-
-/// @par
-///
-/// Using this method ensures the array is at least large enough to hold
-/// the specified number of elements. This can improve performance by
-/// avoiding auto-resizing during use.
-void rcIntArray::doResize(int n)
-{
- if (!m_cap) m_cap = n;
- while (m_cap < n) m_cap *= 2;
- int* newData = (int*)rcAlloc(m_cap*sizeof(int), RC_ALLOC_TEMP);
- if (m_size && newData) memcpy(newData, m_data, m_size*sizeof(int));
- rcFree(m_data);
- m_data = newData;
-}
-
diff --git a/extern/recastnavigation/Recast/Source/RecastArea.cpp b/extern/recastnavigation/Recast/Source/RecastArea.cpp
deleted file mode 100644
index 97139cf996a..00000000000
--- a/extern/recastnavigation/Recast/Source/RecastArea.cpp
+++ /dev/null
@@ -1,591 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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 <float.h>
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "Recast.h"
-#include "RecastAlloc.h"
-#include "RecastAssert.h"
-
-/// @par
-///
-/// Basically, any spans that are closer to a boundary or obstruction than the specified radius
-/// are marked as unwalkable.
-///
-/// This method is usually called immediately after the heightfield has been built.
-///
-/// @see rcCompactHeightfield, rcBuildCompactHeightfield, rcConfig::walkableRadius
-bool rcErodeWalkableArea(rcContext* ctx, int radius, rcCompactHeightfield& chf)
-{
- rcAssert(ctx);
-
- const int w = chf.width;
- const int h = chf.height;
-
- rcScopedTimer timer(ctx, RC_TIMER_ERODE_AREA);
-
- unsigned char* dist = (unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP);
- if (!dist)
- {
- ctx->log(RC_LOG_ERROR, "erodeWalkableArea: Out of memory 'dist' (%d).", chf.spanCount);
- return false;
- }
-
- // Init distance.
- memset(dist, 0xff, sizeof(unsigned char)*chf.spanCount);
-
- // Mark boundary cells.
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- if (chf.areas[i] == RC_NULL_AREA)
- {
- dist[i] = 0;
- }
- else
- {
- const rcCompactSpan& s = chf.spans[i];
- int nc = 0;
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int nx = x + rcGetDirOffsetX(dir);
- const int ny = y + rcGetDirOffsetY(dir);
- const int nidx = (int)chf.cells[nx+ny*w].index + rcGetCon(s, dir);
- if (chf.areas[nidx] != RC_NULL_AREA)
- {
- nc++;
- }
- }
- }
- // At least one missing neighbour.
- if (nc != 4)
- dist[i] = 0;
- }
- }
- }
- }
-
- unsigned char nd;
-
- // Pass 1
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
-
- if (rcGetCon(s, 0) != RC_NOT_CONNECTED)
- {
- // (-1,0)
- const int ax = x + rcGetDirOffsetX(0);
- const int ay = y + rcGetDirOffsetY(0);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);
- const rcCompactSpan& as = chf.spans[ai];
- nd = (unsigned char)rcMin((int)dist[ai]+2, 255);
- if (nd < dist[i])
- dist[i] = nd;
-
- // (-1,-1)
- if (rcGetCon(as, 3) != RC_NOT_CONNECTED)
- {
- const int aax = ax + rcGetDirOffsetX(3);
- const int aay = ay + rcGetDirOffsetY(3);
- const int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 3);
- nd = (unsigned char)rcMin((int)dist[aai]+3, 255);
- if (nd < dist[i])
- dist[i] = nd;
- }
- }
- if (rcGetCon(s, 3) != RC_NOT_CONNECTED)
- {
- // (0,-1)
- const int ax = x + rcGetDirOffsetX(3);
- const int ay = y + rcGetDirOffsetY(3);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);
- const rcCompactSpan& as = chf.spans[ai];
- nd = (unsigned char)rcMin((int)dist[ai]+2, 255);
- if (nd < dist[i])
- dist[i] = nd;
-
- // (1,-1)
- if (rcGetCon(as, 2) != RC_NOT_CONNECTED)
- {
- const int aax = ax + rcGetDirOffsetX(2);
- const int aay = ay + rcGetDirOffsetY(2);
- const int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 2);
- nd = (unsigned char)rcMin((int)dist[aai]+3, 255);
- if (nd < dist[i])
- dist[i] = nd;
- }
- }
- }
- }
- }
-
- // Pass 2
- for (int y = h-1; y >= 0; --y)
- {
- for (int x = w-1; x >= 0; --x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
-
- if (rcGetCon(s, 2) != RC_NOT_CONNECTED)
- {
- // (1,0)
- const int ax = x + rcGetDirOffsetX(2);
- const int ay = y + rcGetDirOffsetY(2);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 2);
- const rcCompactSpan& as = chf.spans[ai];
- nd = (unsigned char)rcMin((int)dist[ai]+2, 255);
- if (nd < dist[i])
- dist[i] = nd;
-
- // (1,1)
- if (rcGetCon(as, 1) != RC_NOT_CONNECTED)
- {
- const int aax = ax + rcGetDirOffsetX(1);
- const int aay = ay + rcGetDirOffsetY(1);
- const int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 1);
- nd = (unsigned char)rcMin((int)dist[aai]+3, 255);
- if (nd < dist[i])
- dist[i] = nd;
- }
- }
- if (rcGetCon(s, 1) != RC_NOT_CONNECTED)
- {
- // (0,1)
- const int ax = x + rcGetDirOffsetX(1);
- const int ay = y + rcGetDirOffsetY(1);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 1);
- const rcCompactSpan& as = chf.spans[ai];
- nd = (unsigned char)rcMin((int)dist[ai]+2, 255);
- if (nd < dist[i])
- dist[i] = nd;
-
- // (-1,1)
- if (rcGetCon(as, 0) != RC_NOT_CONNECTED)
- {
- const int aax = ax + rcGetDirOffsetX(0);
- const int aay = ay + rcGetDirOffsetY(0);
- const int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 0);
- nd = (unsigned char)rcMin((int)dist[aai]+3, 255);
- if (nd < dist[i])
- dist[i] = nd;
- }
- }
- }
- }
- }
-
- const unsigned char thr = (unsigned char)(radius*2);
- for (int i = 0; i < chf.spanCount; ++i)
- if (dist[i] < thr)
- chf.areas[i] = RC_NULL_AREA;
-
- rcFree(dist);
-
- return true;
-}
-
-static void insertSort(unsigned char* a, const int n)
-{
- int i, j;
- for (i = 1; i < n; i++)
- {
- const unsigned char value = a[i];
- for (j = i - 1; j >= 0 && a[j] > value; j--)
- a[j+1] = a[j];
- a[j+1] = value;
- }
-}
-
-/// @par
-///
-/// This filter is usually applied after applying area id's using functions
-/// such as #rcMarkBoxArea, #rcMarkConvexPolyArea, and #rcMarkCylinderArea.
-///
-/// @see rcCompactHeightfield
-bool rcMedianFilterWalkableArea(rcContext* ctx, rcCompactHeightfield& chf)
-{
- rcAssert(ctx);
-
- const int w = chf.width;
- const int h = chf.height;
-
- rcScopedTimer timer(ctx, RC_TIMER_MEDIAN_AREA);
-
- unsigned char* areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP);
- if (!areas)
- {
- ctx->log(RC_LOG_ERROR, "medianFilterWalkableArea: Out of memory 'areas' (%d).", chf.spanCount);
- return false;
- }
-
- // Init distance.
- memset(areas, 0xff, sizeof(unsigned char)*chf.spanCount);
-
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- if (chf.areas[i] == RC_NULL_AREA)
- {
- areas[i] = chf.areas[i];
- continue;
- }
-
- unsigned char nei[9];
- for (int j = 0; j < 9; ++j)
- nei[j] = chf.areas[i];
-
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
- if (chf.areas[ai] != RC_NULL_AREA)
- nei[dir*2+0] = chf.areas[ai];
-
- const rcCompactSpan& as = chf.spans[ai];
- const int dir2 = (dir+1) & 0x3;
- if (rcGetCon(as, dir2) != RC_NOT_CONNECTED)
- {
- const int ax2 = ax + rcGetDirOffsetX(dir2);
- const int ay2 = ay + rcGetDirOffsetY(dir2);
- const int ai2 = (int)chf.cells[ax2+ay2*w].index + rcGetCon(as, dir2);
- if (chf.areas[ai2] != RC_NULL_AREA)
- nei[dir*2+1] = chf.areas[ai2];
- }
- }
- }
- insertSort(nei, 9);
- areas[i] = nei[4];
- }
- }
- }
-
- memcpy(chf.areas, areas, sizeof(unsigned char)*chf.spanCount);
-
- rcFree(areas);
-
- return true;
-}
-
-/// @par
-///
-/// The value of spacial parameters are in world units.
-///
-/// @see rcCompactHeightfield, rcMedianFilterWalkableArea
-void rcMarkBoxArea(rcContext* ctx, const float* bmin, const float* bmax, unsigned char areaId,
- rcCompactHeightfield& chf)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_MARK_BOX_AREA);
-
- int minx = (int)((bmin[0]-chf.bmin[0])/chf.cs);
- int miny = (int)((bmin[1]-chf.bmin[1])/chf.ch);
- int minz = (int)((bmin[2]-chf.bmin[2])/chf.cs);
- int maxx = (int)((bmax[0]-chf.bmin[0])/chf.cs);
- int maxy = (int)((bmax[1]-chf.bmin[1])/chf.ch);
- int maxz = (int)((bmax[2]-chf.bmin[2])/chf.cs);
-
- if (maxx < 0) return;
- if (minx >= chf.width) return;
- if (maxz < 0) return;
- if (minz >= chf.height) return;
-
- if (minx < 0) minx = 0;
- if (maxx >= chf.width) maxx = chf.width-1;
- if (minz < 0) minz = 0;
- if (maxz >= chf.height) maxz = chf.height-1;
-
- for (int z = minz; z <= maxz; ++z)
- {
- for (int x = minx; x <= maxx; ++x)
- {
- const rcCompactCell& c = chf.cells[x+z*chf.width];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- rcCompactSpan& s = chf.spans[i];
- if ((int)s.y >= miny && (int)s.y <= maxy)
- {
- if (chf.areas[i] != RC_NULL_AREA)
- chf.areas[i] = areaId;
- }
- }
- }
- }
-}
-
-
-static int pointInPoly(int nvert, const float* verts, const float* p)
-{
- int i, j, c = 0;
- for (i = 0, j = nvert-1; i < nvert; j = i++)
- {
- const float* vi = &verts[i*3];
- const float* vj = &verts[j*3];
- if (((vi[2] > p[2]) != (vj[2] > p[2])) &&
- (p[0] < (vj[0]-vi[0]) * (p[2]-vi[2]) / (vj[2]-vi[2]) + vi[0]) )
- c = !c;
- }
- return c;
-}
-
-/// @par
-///
-/// The value of spacial parameters are in world units.
-///
-/// The y-values of the polygon vertices are ignored. So the polygon is effectively
-/// projected onto the xz-plane at @p hmin, then extruded to @p hmax.
-///
-/// @see rcCompactHeightfield, rcMedianFilterWalkableArea
-void rcMarkConvexPolyArea(rcContext* ctx, const float* verts, const int nverts,
- const float hmin, const float hmax, unsigned char areaId,
- rcCompactHeightfield& chf)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_MARK_CONVEXPOLY_AREA);
-
- float bmin[3], bmax[3];
- rcVcopy(bmin, verts);
- rcVcopy(bmax, verts);
- for (int i = 1; i < nverts; ++i)
- {
- rcVmin(bmin, &verts[i*3]);
- rcVmax(bmax, &verts[i*3]);
- }
- bmin[1] = hmin;
- bmax[1] = hmax;
-
- int minx = (int)((bmin[0]-chf.bmin[0])/chf.cs);
- int miny = (int)((bmin[1]-chf.bmin[1])/chf.ch);
- int minz = (int)((bmin[2]-chf.bmin[2])/chf.cs);
- int maxx = (int)((bmax[0]-chf.bmin[0])/chf.cs);
- int maxy = (int)((bmax[1]-chf.bmin[1])/chf.ch);
- int maxz = (int)((bmax[2]-chf.bmin[2])/chf.cs);
-
- if (maxx < 0) return;
- if (minx >= chf.width) return;
- if (maxz < 0) return;
- if (minz >= chf.height) return;
-
- if (minx < 0) minx = 0;
- if (maxx >= chf.width) maxx = chf.width-1;
- if (minz < 0) minz = 0;
- if (maxz >= chf.height) maxz = chf.height-1;
-
-
- // TODO: Optimize.
- for (int z = minz; z <= maxz; ++z)
- {
- for (int x = minx; x <= maxx; ++x)
- {
- const rcCompactCell& c = chf.cells[x+z*chf.width];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- rcCompactSpan& s = chf.spans[i];
- if (chf.areas[i] == RC_NULL_AREA)
- continue;
- if ((int)s.y >= miny && (int)s.y <= maxy)
- {
- float p[3];
- p[0] = chf.bmin[0] + (x+0.5f)*chf.cs;
- p[1] = 0;
- p[2] = chf.bmin[2] + (z+0.5f)*chf.cs;
-
- if (pointInPoly(nverts, verts, p))
- {
- chf.areas[i] = areaId;
- }
- }
- }
- }
- }
-}
-
-int rcOffsetPoly(const float* verts, const int nverts, const float offset,
- float* outVerts, const int maxOutVerts)
-{
- const float MITER_LIMIT = 1.20f;
-
- int n = 0;
-
- for (int i = 0; i < nverts; i++)
- {
- const int a = (i+nverts-1) % nverts;
- const int b = i;
- const int c = (i+1) % nverts;
- const float* va = &verts[a*3];
- const float* vb = &verts[b*3];
- const float* vc = &verts[c*3];
- float dx0 = vb[0] - va[0];
- float dy0 = vb[2] - va[2];
- float d0 = dx0*dx0 + dy0*dy0;
- if (d0 > 1e-6f)
- {
- d0 = 1.0f/rcSqrt(d0);
- dx0 *= d0;
- dy0 *= d0;
- }
- float dx1 = vc[0] - vb[0];
- float dy1 = vc[2] - vb[2];
- float d1 = dx1*dx1 + dy1*dy1;
- if (d1 > 1e-6f)
- {
- d1 = 1.0f/rcSqrt(d1);
- dx1 *= d1;
- dy1 *= d1;
- }
- const float dlx0 = -dy0;
- const float dly0 = dx0;
- const float dlx1 = -dy1;
- const float dly1 = dx1;
- float cross = dx1*dy0 - dx0*dy1;
- float dmx = (dlx0 + dlx1) * 0.5f;
- float dmy = (dly0 + dly1) * 0.5f;
- float dmr2 = dmx*dmx + dmy*dmy;
- bool bevel = dmr2 * MITER_LIMIT*MITER_LIMIT < 1.0f;
- if (dmr2 > 1e-6f)
- {
- const float scale = 1.0f / dmr2;
- dmx *= scale;
- dmy *= scale;
- }
-
- if (bevel && cross < 0.0f)
- {
- if (n+2 >= maxOutVerts)
- return 0;
- float d = (1.0f - (dx0*dx1 + dy0*dy1))*0.5f;
- outVerts[n*3+0] = vb[0] + (-dlx0+dx0*d)*offset;
- outVerts[n*3+1] = vb[1];
- outVerts[n*3+2] = vb[2] + (-dly0+dy0*d)*offset;
- n++;
- outVerts[n*3+0] = vb[0] + (-dlx1-dx1*d)*offset;
- outVerts[n*3+1] = vb[1];
- outVerts[n*3+2] = vb[2] + (-dly1-dy1*d)*offset;
- n++;
- }
- else
- {
- if (n+1 >= maxOutVerts)
- return 0;
- outVerts[n*3+0] = vb[0] - dmx*offset;
- outVerts[n*3+1] = vb[1];
- outVerts[n*3+2] = vb[2] - dmy*offset;
- n++;
- }
- }
-
- return n;
-}
-
-
-/// @par
-///
-/// The value of spacial parameters are in world units.
-///
-/// @see rcCompactHeightfield, rcMedianFilterWalkableArea
-void rcMarkCylinderArea(rcContext* ctx, const float* pos,
- const float r, const float h, unsigned char areaId,
- rcCompactHeightfield& chf)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_MARK_CYLINDER_AREA);
-
- float bmin[3], bmax[3];
- bmin[0] = pos[0] - r;
- bmin[1] = pos[1];
- bmin[2] = pos[2] - r;
- bmax[0] = pos[0] + r;
- bmax[1] = pos[1] + h;
- bmax[2] = pos[2] + r;
- const float r2 = r*r;
-
- int minx = (int)((bmin[0]-chf.bmin[0])/chf.cs);
- int miny = (int)((bmin[1]-chf.bmin[1])/chf.ch);
- int minz = (int)((bmin[2]-chf.bmin[2])/chf.cs);
- int maxx = (int)((bmax[0]-chf.bmin[0])/chf.cs);
- int maxy = (int)((bmax[1]-chf.bmin[1])/chf.ch);
- int maxz = (int)((bmax[2]-chf.bmin[2])/chf.cs);
-
- if (maxx < 0) return;
- if (minx >= chf.width) return;
- if (maxz < 0) return;
- if (minz >= chf.height) return;
-
- if (minx < 0) minx = 0;
- if (maxx >= chf.width) maxx = chf.width-1;
- if (minz < 0) minz = 0;
- if (maxz >= chf.height) maxz = chf.height-1;
-
-
- for (int z = minz; z <= maxz; ++z)
- {
- for (int x = minx; x <= maxx; ++x)
- {
- const rcCompactCell& c = chf.cells[x+z*chf.width];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- rcCompactSpan& s = chf.spans[i];
-
- if (chf.areas[i] == RC_NULL_AREA)
- continue;
-
- if ((int)s.y >= miny && (int)s.y <= maxy)
- {
- const float sx = chf.bmin[0] + (x+0.5f)*chf.cs;
- const float sz = chf.bmin[2] + (z+0.5f)*chf.cs;
- const float dx = sx - pos[0];
- const float dz = sz - pos[2];
-
- if (dx*dx + dz*dz < r2)
- {
- chf.areas[i] = areaId;
- }
- }
- }
- }
- }
-}
diff --git a/extern/recastnavigation/Recast/Source/RecastContour.cpp b/extern/recastnavigation/Recast/Source/RecastContour.cpp
deleted file mode 100644
index 277ab015018..00000000000
--- a/extern/recastnavigation/Recast/Source/RecastContour.cpp
+++ /dev/null
@@ -1,1105 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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.
-//
-
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "Recast.h"
-#include "RecastAlloc.h"
-#include "RecastAssert.h"
-
-
-static int getCornerHeight(int x, int y, int i, int dir,
- const rcCompactHeightfield& chf,
- bool& isBorderVertex)
-{
- const rcCompactSpan& s = chf.spans[i];
- int ch = (int)s.y;
- int dirp = (dir+1) & 0x3;
-
- unsigned int regs[4] = {0,0,0,0};
-
- // Combine region and area codes in order to prevent
- // border vertices which are in between two areas to be removed.
- regs[0] = chf.spans[i].reg | (chf.areas[i] << 16);
-
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);
- const rcCompactSpan& as = chf.spans[ai];
- ch = rcMax(ch, (int)as.y);
- regs[1] = chf.spans[ai].reg | (chf.areas[ai] << 16);
- if (rcGetCon(as, dirp) != RC_NOT_CONNECTED)
- {
- const int ax2 = ax + rcGetDirOffsetX(dirp);
- const int ay2 = ay + rcGetDirOffsetY(dirp);
- const int ai2 = (int)chf.cells[ax2+ay2*chf.width].index + rcGetCon(as, dirp);
- const rcCompactSpan& as2 = chf.spans[ai2];
- ch = rcMax(ch, (int)as2.y);
- regs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16);
- }
- }
- if (rcGetCon(s, dirp) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dirp);
- const int ay = y + rcGetDirOffsetY(dirp);
- const int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dirp);
- const rcCompactSpan& as = chf.spans[ai];
- ch = rcMax(ch, (int)as.y);
- regs[3] = chf.spans[ai].reg | (chf.areas[ai] << 16);
- if (rcGetCon(as, dir) != RC_NOT_CONNECTED)
- {
- const int ax2 = ax + rcGetDirOffsetX(dir);
- const int ay2 = ay + rcGetDirOffsetY(dir);
- const int ai2 = (int)chf.cells[ax2+ay2*chf.width].index + rcGetCon(as, dir);
- const rcCompactSpan& as2 = chf.spans[ai2];
- ch = rcMax(ch, (int)as2.y);
- regs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16);
- }
- }
-
- // Check if the vertex is special edge vertex, these vertices will be removed later.
- for (int j = 0; j < 4; ++j)
- {
- const int a = j;
- const int b = (j+1) & 0x3;
- const int c = (j+2) & 0x3;
- const int d = (j+3) & 0x3;
-
- // The vertex is a border vertex there are two same exterior cells in a row,
- // followed by two interior cells and none of the regions are out of bounds.
- const bool twoSameExts = (regs[a] & regs[b] & RC_BORDER_REG) != 0 && regs[a] == regs[b];
- const bool twoInts = ((regs[c] | regs[d]) & RC_BORDER_REG) == 0;
- const bool intsSameArea = (regs[c]>>16) == (regs[d]>>16);
- const bool noZeros = regs[a] != 0 && regs[b] != 0 && regs[c] != 0 && regs[d] != 0;
- if (twoSameExts && twoInts && intsSameArea && noZeros)
- {
- isBorderVertex = true;
- break;
- }
- }
-
- return ch;
-}
-
-static void walkContour(int x, int y, int i,
- rcCompactHeightfield& chf,
- unsigned char* flags, rcIntArray& points)
-{
- // Choose the first non-connected edge
- unsigned char dir = 0;
- while ((flags[i] & (1 << dir)) == 0)
- dir++;
-
- unsigned char startDir = dir;
- int starti = i;
-
- const unsigned char area = chf.areas[i];
-
- int iter = 0;
- while (++iter < 40000)
- {
- if (flags[i] & (1 << dir))
- {
- // Choose the edge corner
- bool isBorderVertex = false;
- bool isAreaBorder = false;
- int px = x;
- int py = getCornerHeight(x, y, i, dir, chf, isBorderVertex);
- int pz = y;
- switch(dir)
- {
- case 0: pz++; break;
- case 1: px++; pz++; break;
- case 2: px++; break;
- }
- int r = 0;
- const rcCompactSpan& s = chf.spans[i];
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);
- r = (int)chf.spans[ai].reg;
- if (area != chf.areas[ai])
- isAreaBorder = true;
- }
- if (isBorderVertex)
- r |= RC_BORDER_VERTEX;
- if (isAreaBorder)
- r |= RC_AREA_BORDER;
- points.push(px);
- points.push(py);
- points.push(pz);
- points.push(r);
-
- flags[i] &= ~(1 << dir); // Remove visited edges
- dir = (dir+1) & 0x3; // Rotate CW
- }
- else
- {
- int ni = -1;
- const int nx = x + rcGetDirOffsetX(dir);
- const int ny = y + rcGetDirOffsetY(dir);
- const rcCompactSpan& s = chf.spans[i];
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const rcCompactCell& nc = chf.cells[nx+ny*chf.width];
- ni = (int)nc.index + rcGetCon(s, dir);
- }
- if (ni == -1)
- {
- // Should not happen.
- return;
- }
- x = nx;
- y = ny;
- i = ni;
- dir = (dir+3) & 0x3; // Rotate CCW
- }
-
- if (starti == i && startDir == dir)
- {
- break;
- }
- }
-}
-
-static float distancePtSeg(const int x, const int z,
- const int px, const int pz,
- const int qx, const int qz)
-{
- float pqx = (float)(qx - px);
- float pqz = (float)(qz - pz);
- float dx = (float)(x - px);
- float dz = (float)(z - pz);
- float d = pqx*pqx + pqz*pqz;
- float t = pqx*dx + pqz*dz;
- if (d > 0)
- t /= d;
- if (t < 0)
- t = 0;
- else if (t > 1)
- t = 1;
-
- dx = px + t*pqx - x;
- dz = pz + t*pqz - z;
-
- return dx*dx + dz*dz;
-}
-
-static void simplifyContour(rcIntArray& points, rcIntArray& simplified,
- const float maxError, const int maxEdgeLen, const int buildFlags)
-{
- // Add initial points.
- bool hasConnections = false;
- for (int i = 0; i < points.size(); i += 4)
- {
- if ((points[i+3] & RC_CONTOUR_REG_MASK) != 0)
- {
- hasConnections = true;
- break;
- }
- }
-
- if (hasConnections)
- {
- // The contour has some portals to other regions.
- // Add a new point to every location where the region changes.
- for (int i = 0, ni = points.size()/4; i < ni; ++i)
- {
- int ii = (i+1) % ni;
- const bool differentRegs = (points[i*4+3] & RC_CONTOUR_REG_MASK) != (points[ii*4+3] & RC_CONTOUR_REG_MASK);
- const bool areaBorders = (points[i*4+3] & RC_AREA_BORDER) != (points[ii*4+3] & RC_AREA_BORDER);
- if (differentRegs || areaBorders)
- {
- simplified.push(points[i*4+0]);
- simplified.push(points[i*4+1]);
- simplified.push(points[i*4+2]);
- simplified.push(i);
- }
- }
- }
-
- if (simplified.size() == 0)
- {
- // If there is no connections at all,
- // create some initial points for the simplification process.
- // Find lower-left and upper-right vertices of the contour.
- int llx = points[0];
- int lly = points[1];
- int llz = points[2];
- int lli = 0;
- int urx = points[0];
- int ury = points[1];
- int urz = points[2];
- int uri = 0;
- for (int i = 0; i < points.size(); i += 4)
- {
- int x = points[i+0];
- int y = points[i+1];
- int z = points[i+2];
- if (x < llx || (x == llx && z < llz))
- {
- llx = x;
- lly = y;
- llz = z;
- lli = i/4;
- }
- if (x > urx || (x == urx && z > urz))
- {
- urx = x;
- ury = y;
- urz = z;
- uri = i/4;
- }
- }
- simplified.push(llx);
- simplified.push(lly);
- simplified.push(llz);
- simplified.push(lli);
-
- simplified.push(urx);
- simplified.push(ury);
- simplified.push(urz);
- simplified.push(uri);
- }
-
- // Add points until all raw points are within
- // error tolerance to the simplified shape.
- const int pn = points.size()/4;
- for (int i = 0; i < simplified.size()/4; )
- {
- int ii = (i+1) % (simplified.size()/4);
-
- int ax = simplified[i*4+0];
- int az = simplified[i*4+2];
- int ai = simplified[i*4+3];
-
- int bx = simplified[ii*4+0];
- int bz = simplified[ii*4+2];
- int bi = simplified[ii*4+3];
-
- // Find maximum deviation from the segment.
- float maxd = 0;
- int maxi = -1;
- int ci, cinc, endi;
-
- // Traverse the segment in lexilogical order so that the
- // max deviation is calculated similarly when traversing
- // opposite segments.
- if (bx > ax || (bx == ax && bz > az))
- {
- cinc = 1;
- ci = (ai+cinc) % pn;
- endi = bi;
- }
- else
- {
- cinc = pn-1;
- ci = (bi+cinc) % pn;
- endi = ai;
- rcSwap(ax, bx);
- rcSwap(az, bz);
- }
-
- // Tessellate only outer edges or edges between areas.
- if ((points[ci*4+3] & RC_CONTOUR_REG_MASK) == 0 ||
- (points[ci*4+3] & RC_AREA_BORDER))
- {
- while (ci != endi)
- {
- float d = distancePtSeg(points[ci*4+0], points[ci*4+2], ax, az, bx, bz);
- if (d > maxd)
- {
- maxd = d;
- maxi = ci;
- }
- ci = (ci+cinc) % pn;
- }
- }
-
-
- // If the max deviation is larger than accepted error,
- // add new point, else continue to next segment.
- if (maxi != -1 && maxd > (maxError*maxError))
- {
- // Add space for the new point.
- simplified.resize(simplified.size()+4);
- const int n = simplified.size()/4;
- for (int j = n-1; j > i; --j)
- {
- simplified[j*4+0] = simplified[(j-1)*4+0];
- simplified[j*4+1] = simplified[(j-1)*4+1];
- simplified[j*4+2] = simplified[(j-1)*4+2];
- simplified[j*4+3] = simplified[(j-1)*4+3];
- }
- // Add the point.
- simplified[(i+1)*4+0] = points[maxi*4+0];
- simplified[(i+1)*4+1] = points[maxi*4+1];
- simplified[(i+1)*4+2] = points[maxi*4+2];
- simplified[(i+1)*4+3] = maxi;
- }
- else
- {
- ++i;
- }
- }
-
- // Split too long edges.
- if (maxEdgeLen > 0 && (buildFlags & (RC_CONTOUR_TESS_WALL_EDGES|RC_CONTOUR_TESS_AREA_EDGES)) != 0)
- {
- for (int i = 0; i < simplified.size()/4; )
- {
- const int ii = (i+1) % (simplified.size()/4);
-
- const int ax = simplified[i*4+0];
- const int az = simplified[i*4+2];
- const int ai = simplified[i*4+3];
-
- const int bx = simplified[ii*4+0];
- const int bz = simplified[ii*4+2];
- const int bi = simplified[ii*4+3];
-
- // Find maximum deviation from the segment.
- int maxi = -1;
- int ci = (ai+1) % pn;
-
- // Tessellate only outer edges or edges between areas.
- bool tess = false;
- // Wall edges.
- if ((buildFlags & RC_CONTOUR_TESS_WALL_EDGES) && (points[ci*4+3] & RC_CONTOUR_REG_MASK) == 0)
- tess = true;
- // Edges between areas.
- if ((buildFlags & RC_CONTOUR_TESS_AREA_EDGES) && (points[ci*4+3] & RC_AREA_BORDER))
- tess = true;
-
- if (tess)
- {
- int dx = bx - ax;
- int dz = bz - az;
- if (dx*dx + dz*dz > maxEdgeLen*maxEdgeLen)
- {
- // Round based on the segments in lexilogical order so that the
- // max tesselation is consistent regardles in which direction
- // segments are traversed.
- const int n = bi < ai ? (bi+pn - ai) : (bi - ai);
- if (n > 1)
- {
- if (bx > ax || (bx == ax && bz > az))
- maxi = (ai + n/2) % pn;
- else
- maxi = (ai + (n+1)/2) % pn;
- }
- }
- }
-
- // If the max deviation is larger than accepted error,
- // add new point, else continue to next segment.
- if (maxi != -1)
- {
- // Add space for the new point.
- simplified.resize(simplified.size()+4);
- const int n = simplified.size()/4;
- for (int j = n-1; j > i; --j)
- {
- simplified[j*4+0] = simplified[(j-1)*4+0];
- simplified[j*4+1] = simplified[(j-1)*4+1];
- simplified[j*4+2] = simplified[(j-1)*4+2];
- simplified[j*4+3] = simplified[(j-1)*4+3];
- }
- // Add the point.
- simplified[(i+1)*4+0] = points[maxi*4+0];
- simplified[(i+1)*4+1] = points[maxi*4+1];
- simplified[(i+1)*4+2] = points[maxi*4+2];
- simplified[(i+1)*4+3] = maxi;
- }
- else
- {
- ++i;
- }
- }
- }
-
- for (int i = 0; i < simplified.size()/4; ++i)
- {
- // The edge vertex flag is take from the current raw point,
- // and the neighbour region is take from the next raw point.
- const int ai = (simplified[i*4+3]+1) % pn;
- const int bi = simplified[i*4+3];
- simplified[i*4+3] = (points[ai*4+3] & (RC_CONTOUR_REG_MASK|RC_AREA_BORDER)) | (points[bi*4+3] & RC_BORDER_VERTEX);
- }
-
-}
-
-static int calcAreaOfPolygon2D(const int* verts, const int nverts)
-{
- int area = 0;
- for (int i = 0, j = nverts-1; i < nverts; j=i++)
- {
- const int* vi = &verts[i*4];
- const int* vj = &verts[j*4];
- area += vi[0] * vj[2] - vj[0] * vi[2];
- }
- return (area+1) / 2;
-}
-
-// TODO: these are the same as in RecastMesh.cpp, consider using the same.
-// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).
-inline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }
-inline int next(int i, int n) { return i+1 < n ? i+1 : 0; }
-
-inline int area2(const int* a, const int* b, const int* c)
-{
- return (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]);
-}
-
-// Exclusive or: true iff exactly one argument is true.
-// The arguments are negated to ensure that they are 0/1
-// values. Then the bitwise Xor operator may apply.
-// (This idea is due to Michael Baldwin.)
-inline bool xorb(bool x, bool y)
-{
- return !x ^ !y;
-}
-
-// Returns true iff c is strictly to the left of the directed
-// line through a to b.
-inline bool left(const int* a, const int* b, const int* c)
-{
- return area2(a, b, c) < 0;
-}
-
-inline bool leftOn(const int* a, const int* b, const int* c)
-{
- return area2(a, b, c) <= 0;
-}
-
-inline bool collinear(const int* a, const int* b, const int* c)
-{
- return area2(a, b, c) == 0;
-}
-
-// Returns true iff ab properly intersects cd: they share
-// a point interior to both segments. The properness of the
-// intersection is ensured by using strict leftness.
-static bool intersectProp(const int* a, const int* b, const int* c, const int* d)
-{
- // Eliminate improper cases.
- if (collinear(a,b,c) || collinear(a,b,d) ||
- collinear(c,d,a) || collinear(c,d,b))
- return false;
-
- return xorb(left(a,b,c), left(a,b,d)) && xorb(left(c,d,a), left(c,d,b));
-}
-
-// Returns T iff (a,b,c) are collinear and point c lies
-// on the closed segement ab.
-static bool between(const int* a, const int* b, const int* c)
-{
- if (!collinear(a, b, c))
- return false;
- // If ab not vertical, check betweenness on x; else on y.
- if (a[0] != b[0])
- return ((a[0] <= c[0]) && (c[0] <= b[0])) || ((a[0] >= c[0]) && (c[0] >= b[0]));
- else
- return ((a[2] <= c[2]) && (c[2] <= b[2])) || ((a[2] >= c[2]) && (c[2] >= b[2]));
-}
-
-// Returns true iff segments ab and cd intersect, properly or improperly.
-static bool intersect(const int* a, const int* b, const int* c, const int* d)
-{
- if (intersectProp(a, b, c, d))
- return true;
- else if (between(a, b, c) || between(a, b, d) ||
- between(c, d, a) || between(c, d, b))
- return true;
- else
- return false;
-}
-
-static bool vequal(const int* a, const int* b)
-{
- return a[0] == b[0] && a[2] == b[2];
-}
-
-static bool intersectSegCountour(const int* d0, const int* d1, int i, int n, const int* verts)
-{
- // For each edge (k,k+1) of P
- for (int k = 0; k < n; k++)
- {
- int k1 = next(k, n);
- // Skip edges incident to i.
- if (i == k || i == k1)
- continue;
- const int* p0 = &verts[k * 4];
- const int* p1 = &verts[k1 * 4];
- if (vequal(d0, p0) || vequal(d1, p0) || vequal(d0, p1) || vequal(d1, p1))
- continue;
-
- if (intersect(d0, d1, p0, p1))
- return true;
- }
- return false;
-}
-
-static bool inCone(int i, int n, const int* verts, const int* pj)
-{
- const int* pi = &verts[i * 4];
- const int* pi1 = &verts[next(i, n) * 4];
- const int* pin1 = &verts[prev(i, n) * 4];
-
- // If P[i] is a convex vertex [ i+1 left or on (i-1,i) ].
- if (leftOn(pin1, pi, pi1))
- return left(pi, pj, pin1) && left(pj, pi, pi1);
- // Assume (i-1,i,i+1) not collinear.
- // else P[i] is reflex.
- return !(leftOn(pi, pj, pi1) && leftOn(pj, pi, pin1));
-}
-
-
-static void removeDegenerateSegments(rcIntArray& simplified)
-{
- // Remove adjacent vertices which are equal on xz-plane,
- // or else the triangulator will get confused.
- int npts = simplified.size()/4;
- for (int i = 0; i < npts; ++i)
- {
- int ni = next(i, npts);
-
- if (vequal(&simplified[i*4], &simplified[ni*4]))
- {
- // Degenerate segment, remove.
- for (int j = i; j < simplified.size()/4-1; ++j)
- {
- simplified[j*4+0] = simplified[(j+1)*4+0];
- simplified[j*4+1] = simplified[(j+1)*4+1];
- simplified[j*4+2] = simplified[(j+1)*4+2];
- simplified[j*4+3] = simplified[(j+1)*4+3];
- }
- simplified.resize(simplified.size()-4);
- npts--;
- }
- }
-}
-
-
-static bool mergeContours(rcContour& ca, rcContour& cb, int ia, int ib)
-{
- const int maxVerts = ca.nverts + cb.nverts + 2;
- int* verts = (int*)rcAlloc(sizeof(int)*maxVerts*4, RC_ALLOC_PERM);
- if (!verts)
- return false;
-
- int nv = 0;
-
- // Copy contour A.
- for (int i = 0; i <= ca.nverts; ++i)
- {
- int* dst = &verts[nv*4];
- const int* src = &ca.verts[((ia+i)%ca.nverts)*4];
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- nv++;
- }
-
- // Copy contour B
- for (int i = 0; i <= cb.nverts; ++i)
- {
- int* dst = &verts[nv*4];
- const int* src = &cb.verts[((ib+i)%cb.nverts)*4];
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- nv++;
- }
-
- rcFree(ca.verts);
- ca.verts = verts;
- ca.nverts = nv;
-
- rcFree(cb.verts);
- cb.verts = 0;
- cb.nverts = 0;
-
- return true;
-}
-
-struct rcContourHole
-{
- rcContour* contour;
- int minx, minz, leftmost;
-};
-
-struct rcContourRegion
-{
- rcContour* outline;
- rcContourHole* holes;
- int nholes;
-};
-
-struct rcPotentialDiagonal
-{
- int vert;
- int dist;
-};
-
-// Finds the lowest leftmost vertex of a contour.
-static void findLeftMostVertex(rcContour* contour, int* minx, int* minz, int* leftmost)
-{
- *minx = contour->verts[0];
- *minz = contour->verts[2];
- *leftmost = 0;
- for (int i = 1; i < contour->nverts; i++)
- {
- const int x = contour->verts[i*4+0];
- const int z = contour->verts[i*4+2];
- if (x < *minx || (x == *minx && z < *minz))
- {
- *minx = x;
- *minz = z;
- *leftmost = i;
- }
- }
-}
-
-static int compareHoles(const void* va, const void* vb)
-{
- const rcContourHole* a = (const rcContourHole*)va;
- const rcContourHole* b = (const rcContourHole*)vb;
- if (a->minx == b->minx)
- {
- if (a->minz < b->minz)
- return -1;
- if (a->minz > b->minz)
- return 1;
- }
- else
- {
- if (a->minx < b->minx)
- return -1;
- if (a->minx > b->minx)
- return 1;
- }
- return 0;
-}
-
-
-static int compareDiagDist(const void* va, const void* vb)
-{
- const rcPotentialDiagonal* a = (const rcPotentialDiagonal*)va;
- const rcPotentialDiagonal* b = (const rcPotentialDiagonal*)vb;
- if (a->dist < b->dist)
- return -1;
- if (a->dist > b->dist)
- return 1;
- return 0;
-}
-
-
-static void mergeRegionHoles(rcContext* ctx, rcContourRegion& region)
-{
- // Sort holes from left to right.
- for (int i = 0; i < region.nholes; i++)
- findLeftMostVertex(region.holes[i].contour, &region.holes[i].minx, &region.holes[i].minz, &region.holes[i].leftmost);
-
- qsort(region.holes, region.nholes, sizeof(rcContourHole), compareHoles);
-
- int maxVerts = region.outline->nverts;
- for (int i = 0; i < region.nholes; i++)
- maxVerts += region.holes[i].contour->nverts;
-
- rcScopedDelete<rcPotentialDiagonal> diags((rcPotentialDiagonal*)rcAlloc(sizeof(rcPotentialDiagonal)*maxVerts, RC_ALLOC_TEMP));
- if (!diags)
- {
- ctx->log(RC_LOG_WARNING, "mergeRegionHoles: Failed to allocated diags %d.", maxVerts);
- return;
- }
-
- rcContour* outline = region.outline;
-
- // Merge holes into the outline one by one.
- for (int i = 0; i < region.nholes; i++)
- {
- rcContour* hole = region.holes[i].contour;
-
- int index = -1;
- int bestVertex = region.holes[i].leftmost;
- for (int iter = 0; iter < hole->nverts; iter++)
- {
- // Find potential diagonals.
- // The 'best' vertex must be in the cone described by 3 cosequtive vertices of the outline.
- // ..o j-1
- // |
- // | * best
- // |
- // j o-----o j+1
- // :
- int ndiags = 0;
- const int* corner = &hole->verts[bestVertex*4];
- for (int j = 0; j < outline->nverts; j++)
- {
- if (inCone(j, outline->nverts, outline->verts, corner))
- {
- int dx = outline->verts[j*4+0] - corner[0];
- int dz = outline->verts[j*4+2] - corner[2];
- diags[ndiags].vert = j;
- diags[ndiags].dist = dx*dx + dz*dz;
- ndiags++;
- }
- }
- // Sort potential diagonals by distance, we want to make the connection as short as possible.
- qsort(diags, ndiags, sizeof(rcPotentialDiagonal), compareDiagDist);
-
- // Find a diagonal that is not intersecting the outline not the remaining holes.
- index = -1;
- for (int j = 0; j < ndiags; j++)
- {
- const int* pt = &outline->verts[diags[j].vert*4];
- bool intersect = intersectSegCountour(pt, corner, diags[i].vert, outline->nverts, outline->verts);
- for (int k = i; k < region.nholes && !intersect; k++)
- intersect |= intersectSegCountour(pt, corner, -1, region.holes[k].contour->nverts, region.holes[k].contour->verts);
- if (!intersect)
- {
- index = diags[j].vert;
- break;
- }
- }
- // If found non-intersecting diagonal, stop looking.
- if (index != -1)
- break;
- // All the potential diagonals for the current vertex were intersecting, try next vertex.
- bestVertex = (bestVertex + 1) % hole->nverts;
- }
-
- if (index == -1)
- {
- ctx->log(RC_LOG_WARNING, "mergeHoles: Failed to find merge points for %p and %p.", region.outline, hole);
- continue;
- }
- if (!mergeContours(*region.outline, *hole, index, bestVertex))
- {
- ctx->log(RC_LOG_WARNING, "mergeHoles: Failed to merge contours %p and %p.", region.outline, hole);
- continue;
- }
- }
-}
-
-
-/// @par
-///
-/// The raw contours will match the region outlines exactly. The @p maxError and @p maxEdgeLen
-/// parameters control how closely the simplified contours will match the raw contours.
-///
-/// Simplified contours are generated such that the vertices for portals between areas match up.
-/// (They are considered mandatory vertices.)
-///
-/// Setting @p maxEdgeLength to zero will disabled the edge length feature.
-///
-/// See the #rcConfig documentation for more information on the configuration parameters.
-///
-/// @see rcAllocContourSet, rcCompactHeightfield, rcContourSet, rcConfig
-bool rcBuildContours(rcContext* ctx, rcCompactHeightfield& chf,
- const float maxError, const int maxEdgeLen,
- rcContourSet& cset, const int buildFlags)
-{
- rcAssert(ctx);
-
- const int w = chf.width;
- const int h = chf.height;
- const int borderSize = chf.borderSize;
-
- rcScopedTimer timer(ctx, RC_TIMER_BUILD_CONTOURS);
-
- rcVcopy(cset.bmin, chf.bmin);
- rcVcopy(cset.bmax, chf.bmax);
- if (borderSize > 0)
- {
- // If the heightfield was build with bordersize, remove the offset.
- const float pad = borderSize*chf.cs;
- cset.bmin[0] += pad;
- cset.bmin[2] += pad;
- cset.bmax[0] -= pad;
- cset.bmax[2] -= pad;
- }
- cset.cs = chf.cs;
- cset.ch = chf.ch;
- cset.width = chf.width - chf.borderSize*2;
- cset.height = chf.height - chf.borderSize*2;
- cset.borderSize = chf.borderSize;
- cset.maxError = maxError;
-
- int maxContours = rcMax((int)chf.maxRegions, 8);
- cset.conts = (rcContour*)rcAlloc(sizeof(rcContour)*maxContours, RC_ALLOC_PERM);
- if (!cset.conts)
- return false;
- cset.nconts = 0;
-
- rcScopedDelete<unsigned char> flags((unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP));
- if (!flags)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'flags' (%d).", chf.spanCount);
- return false;
- }
-
- ctx->startTimer(RC_TIMER_BUILD_CONTOURS_TRACE);
-
- // Mark boundaries.
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- unsigned char res = 0;
- const rcCompactSpan& s = chf.spans[i];
- if (!chf.spans[i].reg || (chf.spans[i].reg & RC_BORDER_REG))
- {
- flags[i] = 0;
- continue;
- }
- for (int dir = 0; dir < 4; ++dir)
- {
- unsigned short r = 0;
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
- r = chf.spans[ai].reg;
- }
- if (r == chf.spans[i].reg)
- res |= (1 << dir);
- }
- flags[i] = res ^ 0xf; // Inverse, mark non connected edges.
- }
- }
- }
-
- ctx->stopTimer(RC_TIMER_BUILD_CONTOURS_TRACE);
-
- rcIntArray verts(256);
- rcIntArray simplified(64);
-
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- if (flags[i] == 0 || flags[i] == 0xf)
- {
- flags[i] = 0;
- continue;
- }
- const unsigned short reg = chf.spans[i].reg;
- if (!reg || (reg & RC_BORDER_REG))
- continue;
- const unsigned char area = chf.areas[i];
-
- verts.resize(0);
- simplified.resize(0);
-
- ctx->startTimer(RC_TIMER_BUILD_CONTOURS_TRACE);
- walkContour(x, y, i, chf, flags, verts);
- ctx->stopTimer(RC_TIMER_BUILD_CONTOURS_TRACE);
-
- ctx->startTimer(RC_TIMER_BUILD_CONTOURS_SIMPLIFY);
- simplifyContour(verts, simplified, maxError, maxEdgeLen, buildFlags);
- removeDegenerateSegments(simplified);
- ctx->stopTimer(RC_TIMER_BUILD_CONTOURS_SIMPLIFY);
-
-
- // Store region->contour remap info.
- // Create contour.
- if (simplified.size()/4 >= 3)
- {
- if (cset.nconts >= maxContours)
- {
- // Allocate more contours.
- // This happens when a region has holes.
- const int oldMax = maxContours;
- maxContours *= 2;
- rcContour* newConts = (rcContour*)rcAlloc(sizeof(rcContour)*maxContours, RC_ALLOC_PERM);
- for (int j = 0; j < cset.nconts; ++j)
- {
- newConts[j] = cset.conts[j];
- // Reset source pointers to prevent data deletion.
- cset.conts[j].verts = 0;
- cset.conts[j].rverts = 0;
- }
- rcFree(cset.conts);
- cset.conts = newConts;
-
- ctx->log(RC_LOG_WARNING, "rcBuildContours: Expanding max contours from %d to %d.", oldMax, maxContours);
- }
-
- rcContour* cont = &cset.conts[cset.nconts++];
-
- cont->nverts = simplified.size()/4;
- cont->verts = (int*)rcAlloc(sizeof(int)*cont->nverts*4, RC_ALLOC_PERM);
- if (!cont->verts)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'verts' (%d).", cont->nverts);
- return false;
- }
- memcpy(cont->verts, &simplified[0], sizeof(int)*cont->nverts*4);
- if (borderSize > 0)
- {
- // If the heightfield was build with bordersize, remove the offset.
- for (int j = 0; j < cont->nverts; ++j)
- {
- int* v = &cont->verts[j*4];
- v[0] -= borderSize;
- v[2] -= borderSize;
- }
- }
-
- cont->nrverts = verts.size()/4;
- cont->rverts = (int*)rcAlloc(sizeof(int)*cont->nrverts*4, RC_ALLOC_PERM);
- if (!cont->rverts)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'rverts' (%d).", cont->nrverts);
- return false;
- }
- memcpy(cont->rverts, &verts[0], sizeof(int)*cont->nrverts*4);
- if (borderSize > 0)
- {
- // If the heightfield was build with bordersize, remove the offset.
- for (int j = 0; j < cont->nrverts; ++j)
- {
- int* v = &cont->rverts[j*4];
- v[0] -= borderSize;
- v[2] -= borderSize;
- }
- }
-
- cont->reg = reg;
- cont->area = area;
- }
- }
- }
- }
-
- // Merge holes if needed.
- if (cset.nconts > 0)
- {
- // Calculate winding of all polygons.
- rcScopedDelete<char> winding((char*)rcAlloc(sizeof(char)*cset.nconts, RC_ALLOC_TEMP));
- if (!winding)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'hole' (%d).", cset.nconts);
- return false;
- }
- int nholes = 0;
- for (int i = 0; i < cset.nconts; ++i)
- {
- rcContour& cont = cset.conts[i];
- // If the contour is wound backwards, it is a hole.
- winding[i] = calcAreaOfPolygon2D(cont.verts, cont.nverts) < 0 ? -1 : 1;
- if (winding[i] < 0)
- nholes++;
- }
-
- if (nholes > 0)
- {
- // Collect outline contour and holes contours per region.
- // We assume that there is one outline and multiple holes.
- const int nregions = chf.maxRegions+1;
- rcScopedDelete<rcContourRegion> regions((rcContourRegion*)rcAlloc(sizeof(rcContourRegion)*nregions, RC_ALLOC_TEMP));
- if (!regions)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'regions' (%d).", nregions);
- return false;
- }
- memset(regions, 0, sizeof(rcContourRegion)*nregions);
-
- rcScopedDelete<rcContourHole> holes((rcContourHole*)rcAlloc(sizeof(rcContourHole)*cset.nconts, RC_ALLOC_TEMP));
- if (!holes)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'holes' (%d).", cset.nconts);
- return false;
- }
- memset(holes, 0, sizeof(rcContourHole)*cset.nconts);
-
- for (int i = 0; i < cset.nconts; ++i)
- {
- rcContour& cont = cset.conts[i];
- // Positively would contours are outlines, negative holes.
- if (winding[i] > 0)
- {
- if (regions[cont.reg].outline)
- ctx->log(RC_LOG_ERROR, "rcBuildContours: Multiple outlines for region %d.", cont.reg);
- regions[cont.reg].outline = &cont;
- }
- else
- {
- regions[cont.reg].nholes++;
- }
- }
- int index = 0;
- for (int i = 0; i < nregions; i++)
- {
- if (regions[i].nholes > 0)
- {
- regions[i].holes = &holes[index];
- index += regions[i].nholes;
- regions[i].nholes = 0;
- }
- }
- for (int i = 0; i < cset.nconts; ++i)
- {
- rcContour& cont = cset.conts[i];
- rcContourRegion& reg = regions[cont.reg];
- if (winding[i] < 0)
- reg.holes[reg.nholes++].contour = &cont;
- }
-
- // Finally merge each regions holes into the outline.
- for (int i = 0; i < nregions; i++)
- {
- rcContourRegion& reg = regions[i];
- if (!reg.nholes) continue;
-
- if (reg.outline)
- {
- mergeRegionHoles(ctx, reg);
- }
- else
- {
- // The region does not have an outline.
- // This can happen if the contour becaomes selfoverlapping because of
- // too aggressive simplification settings.
- ctx->log(RC_LOG_ERROR, "rcBuildContours: Bad outline for region %d, contour simplification is likely too aggressive.", i);
- }
- }
- }
-
- }
-
- return true;
-}
diff --git a/extern/recastnavigation/Recast/Source/RecastFilter.cpp b/extern/recastnavigation/Recast/Source/RecastFilter.cpp
deleted file mode 100644
index 9d3e63c4820..00000000000
--- a/extern/recastnavigation/Recast/Source/RecastFilter.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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.
-//
-
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <stdio.h>
-#include "Recast.h"
-#include "RecastAssert.h"
-
-/// @par
-///
-/// Allows the formation of walkable regions that will flow over low lying
-/// objects such as curbs, and up structures such as stairways.
-///
-/// Two neighboring spans are walkable if: <tt>rcAbs(currentSpan.smax - neighborSpan.smax) < waklableClimb</tt>
-///
-/// @warning Will override the effect of #rcFilterLedgeSpans. So if both filters are used, call
-/// #rcFilterLedgeSpans after calling this filter.
-///
-/// @see rcHeightfield, rcConfig
-void rcFilterLowHangingWalkableObstacles(rcContext* ctx, const int walkableClimb, rcHeightfield& solid)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_FILTER_LOW_OBSTACLES);
-
- const int w = solid.width;
- const int h = solid.height;
-
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- rcSpan* ps = 0;
- bool previousWalkable = false;
- unsigned char previousArea = RC_NULL_AREA;
-
- for (rcSpan* s = solid.spans[x + y*w]; s; ps = s, s = s->next)
- {
- const bool walkable = s->area != RC_NULL_AREA;
- // If current span is not walkable, but there is walkable
- // span just below it, mark the span above it walkable too.
- if (!walkable && previousWalkable)
- {
- if (rcAbs((int)s->smax - (int)ps->smax) <= walkableClimb)
- s->area = previousArea;
- }
- // Copy walkable flag so that it cannot propagate
- // past multiple non-walkable objects.
- previousWalkable = walkable;
- previousArea = s->area;
- }
- }
- }
-}
-
-/// @par
-///
-/// A ledge is a span with one or more neighbors whose maximum is further away than @p walkableClimb
-/// from the current span's maximum.
-/// This method removes the impact of the overestimation of conservative voxelization
-/// so the resulting mesh will not have regions hanging in the air over ledges.
-///
-/// A span is a ledge if: <tt>rcAbs(currentSpan.smax - neighborSpan.smax) > walkableClimb</tt>
-///
-/// @see rcHeightfield, rcConfig
-void rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight, const int walkableClimb,
- rcHeightfield& solid)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_FILTER_BORDER);
-
- const int w = solid.width;
- const int h = solid.height;
- const int MAX_HEIGHT = 0xffff;
-
- // Mark border spans.
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- for (rcSpan* s = solid.spans[x + y*w]; s; s = s->next)
- {
- // Skip non walkable spans.
- if (s->area == RC_NULL_AREA)
- continue;
-
- const int bot = (int)(s->smax);
- const int top = s->next ? (int)(s->next->smin) : MAX_HEIGHT;
-
- // Find neighbours minimum height.
- int minh = MAX_HEIGHT;
-
- // Min and max height of accessible neighbours.
- int asmin = s->smax;
- int asmax = s->smax;
-
- for (int dir = 0; dir < 4; ++dir)
- {
- int dx = x + rcGetDirOffsetX(dir);
- int dy = y + rcGetDirOffsetY(dir);
- // Skip neighbours which are out of bounds.
- if (dx < 0 || dy < 0 || dx >= w || dy >= h)
- {
- minh = rcMin(minh, -walkableClimb - bot);
- continue;
- }
-
- // From minus infinity to the first span.
- rcSpan* ns = solid.spans[dx + dy*w];
- int nbot = -walkableClimb;
- int ntop = ns ? (int)ns->smin : MAX_HEIGHT;
- // Skip neightbour if the gap between the spans is too small.
- if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)
- minh = rcMin(minh, nbot - bot);
-
- // Rest of the spans.
- for (ns = solid.spans[dx + dy*w]; ns; ns = ns->next)
- {
- nbot = (int)ns->smax;
- ntop = ns->next ? (int)ns->next->smin : MAX_HEIGHT;
- // Skip neightbour if the gap between the spans is too small.
- if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)
- {
- minh = rcMin(minh, nbot - bot);
-
- // Find min/max accessible neighbour height.
- if (rcAbs(nbot - bot) <= walkableClimb)
- {
- if (nbot < asmin) asmin = nbot;
- if (nbot > asmax) asmax = nbot;
- }
-
- }
- }
- }
-
- // The current span is close to a ledge if the drop to any
- // neighbour span is less than the walkableClimb.
- if (minh < -walkableClimb)
- {
- s->area = RC_NULL_AREA;
- }
- // If the difference between all neighbours is too large,
- // we are at steep slope, mark the span as ledge.
- else if ((asmax - asmin) > walkableClimb)
- {
- s->area = RC_NULL_AREA;
- }
- }
- }
- }
-}
-
-/// @par
-///
-/// For this filter, the clearance above the span is the distance from the span's
-/// maximum to the next higher span's minimum. (Same grid column.)
-///
-/// @see rcHeightfield, rcConfig
-void rcFilterWalkableLowHeightSpans(rcContext* ctx, int walkableHeight, rcHeightfield& solid)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_FILTER_WALKABLE);
-
- const int w = solid.width;
- const int h = solid.height;
- const int MAX_HEIGHT = 0xffff;
-
- // Remove walkable flag from spans which do not have enough
- // space above them for the agent to stand there.
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- for (rcSpan* s = solid.spans[x + y*w]; s; s = s->next)
- {
- const int bot = (int)(s->smax);
- const int top = s->next ? (int)(s->next->smin) : MAX_HEIGHT;
- if ((top - bot) <= walkableHeight)
- s->area = RC_NULL_AREA;
- }
- }
- }
-}
diff --git a/extern/recastnavigation/Recast/Source/RecastLayers.cpp b/extern/recastnavigation/Recast/Source/RecastLayers.cpp
deleted file mode 100644
index 22a357effa1..00000000000
--- a/extern/recastnavigation/Recast/Source/RecastLayers.cpp
+++ /dev/null
@@ -1,613 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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 <float.h>
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "Recast.h"
-#include "RecastAlloc.h"
-#include "RecastAssert.h"
-
-
-static const int RC_MAX_LAYERS = RC_NOT_CONNECTED;
-static const int RC_MAX_NEIS = 16;
-
-struct rcLayerRegion
-{
- unsigned char layers[RC_MAX_LAYERS];
- unsigned char neis[RC_MAX_NEIS];
- unsigned short ymin, ymax;
- unsigned char layerId; // Layer ID
- unsigned char nlayers; // Layer count
- unsigned char nneis; // Neighbour count
- unsigned char base; // Flag indicating if the region is the base of merged regions.
-};
-
-
-static void addUnique(unsigned char* a, unsigned char& an, unsigned char v)
-{
- const int n = (int)an;
- for (int i = 0; i < n; ++i)
- if (a[i] == v)
- return;
- a[an] = v;
- an++;
-}
-
-static bool contains(const unsigned char* a, const unsigned char an, const unsigned char v)
-{
- const int n = (int)an;
- for (int i = 0; i < n; ++i)
- if (a[i] == v)
- return true;
- return false;
-}
-
-inline bool overlapRange(const unsigned short amin, const unsigned short amax,
- const unsigned short bmin, const unsigned short bmax)
-{
- return (amin > bmax || amax < bmin) ? false : true;
-}
-
-
-
-struct rcLayerSweepSpan
-{
- unsigned short ns; // number samples
- unsigned char id; // region id
- unsigned char nei; // neighbour id
-};
-
-/// @par
-///
-/// See the #rcConfig documentation for more information on the configuration parameters.
-///
-/// @see rcAllocHeightfieldLayerSet, rcCompactHeightfield, rcHeightfieldLayerSet, rcConfig
-bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
- const int borderSize, const int walkableHeight,
- rcHeightfieldLayerSet& lset)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_BUILD_LAYERS);
-
- const int w = chf.width;
- const int h = chf.height;
-
- rcScopedDelete<unsigned char> srcReg((unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP));
- if (!srcReg)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'srcReg' (%d).", chf.spanCount);
- return false;
- }
- memset(srcReg,0xff,sizeof(unsigned char)*chf.spanCount);
-
- const int nsweeps = chf.width;
- rcScopedDelete<rcLayerSweepSpan> sweeps((rcLayerSweepSpan*)rcAlloc(sizeof(rcLayerSweepSpan)*nsweeps, RC_ALLOC_TEMP));
- if (!sweeps)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'sweeps' (%d).", nsweeps);
- return false;
- }
-
-
- // Partition walkable area into monotone regions.
- int prevCount[256];
- unsigned char regId = 0;
-
- for (int y = borderSize; y < h-borderSize; ++y)
- {
- memset(prevCount,0,sizeof(int)*regId);
- unsigned char sweepId = 0;
-
- for (int x = borderSize; x < w-borderSize; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
-
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- if (chf.areas[i] == RC_NULL_AREA) continue;
-
- unsigned char sid = 0xff;
-
- // -x
- if (rcGetCon(s, 0) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(0);
- const int ay = y + rcGetDirOffsetY(0);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);
- if (chf.areas[ai] != RC_NULL_AREA && srcReg[ai] != 0xff)
- sid = srcReg[ai];
- }
-
- if (sid == 0xff)
- {
- sid = sweepId++;
- sweeps[sid].nei = 0xff;
- sweeps[sid].ns = 0;
- }
-
- // -y
- if (rcGetCon(s,3) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(3);
- const int ay = y + rcGetDirOffsetY(3);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);
- const unsigned char nr = srcReg[ai];
- if (nr != 0xff)
- {
- // Set neighbour when first valid neighbour is encoutered.
- if (sweeps[sid].ns == 0)
- sweeps[sid].nei = nr;
-
- if (sweeps[sid].nei == nr)
- {
- // Update existing neighbour
- sweeps[sid].ns++;
- prevCount[nr]++;
- }
- else
- {
- // This is hit if there is nore than one neighbour.
- // Invalidate the neighbour.
- sweeps[sid].nei = 0xff;
- }
- }
- }
-
- srcReg[i] = sid;
- }
- }
-
- // Create unique ID.
- for (int i = 0; i < sweepId; ++i)
- {
- // If the neighbour is set and there is only one continuous connection to it,
- // the sweep will be merged with the previous one, else new region is created.
- if (sweeps[i].nei != 0xff && prevCount[sweeps[i].nei] == (int)sweeps[i].ns)
- {
- sweeps[i].id = sweeps[i].nei;
- }
- else
- {
- if (regId == 255)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Region ID overflow.");
- return false;
- }
- sweeps[i].id = regId++;
- }
- }
-
- // Remap local sweep ids to region ids.
- for (int x = borderSize; x < w-borderSize; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- if (srcReg[i] != 0xff)
- srcReg[i] = sweeps[srcReg[i]].id;
- }
- }
- }
-
- // Allocate and init layer regions.
- const int nregs = (int)regId;
- rcScopedDelete<rcLayerRegion> regs((rcLayerRegion*)rcAlloc(sizeof(rcLayerRegion)*nregs, RC_ALLOC_TEMP));
- if (!regs)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'regs' (%d).", nregs);
- return false;
- }
- memset(regs, 0, sizeof(rcLayerRegion)*nregs);
- for (int i = 0; i < nregs; ++i)
- {
- regs[i].layerId = 0xff;
- regs[i].ymin = 0xffff;
- regs[i].ymax = 0;
- }
-
- // Find region neighbours and overlapping regions.
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
-
- unsigned char lregs[RC_MAX_LAYERS];
- int nlregs = 0;
-
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- const unsigned char ri = srcReg[i];
- if (ri == 0xff) continue;
-
- regs[ri].ymin = rcMin(regs[ri].ymin, s.y);
- regs[ri].ymax = rcMax(regs[ri].ymax, s.y);
-
- // Collect all region layers.
- if (nlregs < RC_MAX_LAYERS)
- lregs[nlregs++] = ri;
-
- // Update neighbours
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
- const unsigned char rai = srcReg[ai];
- if (rai != 0xff && rai != ri && regs[ri].nneis < RC_MAX_NEIS)
- addUnique(regs[ri].neis, regs[ri].nneis, rai);
- }
- }
-
- }
-
- // Update overlapping regions.
- for (int i = 0; i < nlregs-1; ++i)
- {
- for (int j = i+1; j < nlregs; ++j)
- {
- if (lregs[i] != lregs[j])
- {
- rcLayerRegion& ri = regs[lregs[i]];
- rcLayerRegion& rj = regs[lregs[j]];
- addUnique(ri.layers, ri.nlayers, lregs[j]);
- addUnique(rj.layers, rj.nlayers, lregs[i]);
- }
- }
- }
-
- }
- }
-
- // Create 2D layers from regions.
- unsigned char layerId = 0;
-
- static const int MAX_STACK = 64;
- unsigned char stack[MAX_STACK];
- int nstack = 0;
-
- for (int i = 0; i < nregs; ++i)
- {
- rcLayerRegion& root = regs[i];
- // Skip already visited.
- if (root.layerId != 0xff)
- continue;
-
- // Start search.
- root.layerId = layerId;
- root.base = 1;
-
- nstack = 0;
- stack[nstack++] = (unsigned char)i;
-
- while (nstack)
- {
- // Pop front
- rcLayerRegion& reg = regs[stack[0]];
- nstack--;
- for (int j = 0; j < nstack; ++j)
- stack[j] = stack[j+1];
-
- const int nneis = (int)reg.nneis;
- for (int j = 0; j < nneis; ++j)
- {
- const unsigned char nei = reg.neis[j];
- rcLayerRegion& regn = regs[nei];
- // Skip already visited.
- if (regn.layerId != 0xff)
- continue;
- // Skip if the neighbour is overlapping root region.
- if (contains(root.layers, root.nlayers, nei))
- continue;
- // Skip if the height range would become too large.
- const int ymin = rcMin(root.ymin, regn.ymin);
- const int ymax = rcMax(root.ymax, regn.ymax);
- if ((ymax - ymin) >= 255)
- continue;
-
- if (nstack < MAX_STACK)
- {
- // Deepen
- stack[nstack++] = (unsigned char)nei;
-
- // Mark layer id
- regn.layerId = layerId;
- // Merge current layers to root.
- for (int k = 0; k < regn.nlayers; ++k)
- addUnique(root.layers, root.nlayers, regn.layers[k]);
- root.ymin = rcMin(root.ymin, regn.ymin);
- root.ymax = rcMax(root.ymax, regn.ymax);
- }
- }
- }
-
- layerId++;
- }
-
- // Merge non-overlapping regions that are close in height.
- const unsigned short mergeHeight = (unsigned short)walkableHeight * 4;
-
- for (int i = 0; i < nregs; ++i)
- {
- rcLayerRegion& ri = regs[i];
- if (!ri.base) continue;
-
- unsigned char newId = ri.layerId;
-
- for (;;)
- {
- unsigned char oldId = 0xff;
-
- for (int j = 0; j < nregs; ++j)
- {
- if (i == j) continue;
- rcLayerRegion& rj = regs[j];
- if (!rj.base) continue;
-
- // Skip if the regions are not close to each other.
- if (!overlapRange(ri.ymin,ri.ymax+mergeHeight, rj.ymin,rj.ymax+mergeHeight))
- continue;
- // Skip if the height range would become too large.
- const int ymin = rcMin(ri.ymin, rj.ymin);
- const int ymax = rcMax(ri.ymax, rj.ymax);
- if ((ymax - ymin) >= 255)
- continue;
-
- // Make sure that there is no overlap when merging 'ri' and 'rj'.
- bool overlap = false;
- // Iterate over all regions which have the same layerId as 'rj'
- for (int k = 0; k < nregs; ++k)
- {
- if (regs[k].layerId != rj.layerId)
- continue;
- // Check if region 'k' is overlapping region 'ri'
- // Index to 'regs' is the same as region id.
- if (contains(ri.layers,ri.nlayers, (unsigned char)k))
- {
- overlap = true;
- break;
- }
- }
- // Cannot merge of regions overlap.
- if (overlap)
- continue;
-
- // Can merge i and j.
- oldId = rj.layerId;
- break;
- }
-
- // Could not find anything to merge with, stop.
- if (oldId == 0xff)
- break;
-
- // Merge
- for (int j = 0; j < nregs; ++j)
- {
- rcLayerRegion& rj = regs[j];
- if (rj.layerId == oldId)
- {
- rj.base = 0;
- // Remap layerIds.
- rj.layerId = newId;
- // Add overlaid layers from 'rj' to 'ri'.
- for (int k = 0; k < rj.nlayers; ++k)
- addUnique(ri.layers, ri.nlayers, rj.layers[k]);
- // Update height bounds.
- ri.ymin = rcMin(ri.ymin, rj.ymin);
- ri.ymax = rcMax(ri.ymax, rj.ymax);
- }
- }
- }
- }
-
- // Compact layerIds
- unsigned char remap[256];
- memset(remap, 0, 256);
-
- // Find number of unique layers.
- layerId = 0;
- for (int i = 0; i < nregs; ++i)
- remap[regs[i].layerId] = 1;
- for (int i = 0; i < 256; ++i)
- {
- if (remap[i])
- remap[i] = layerId++;
- else
- remap[i] = 0xff;
- }
- // Remap ids.
- for (int i = 0; i < nregs; ++i)
- regs[i].layerId = remap[regs[i].layerId];
-
- // No layers, return empty.
- if (layerId == 0)
- return true;
-
- // Create layers.
- rcAssert(lset.layers == 0);
-
- const int lw = w - borderSize*2;
- const int lh = h - borderSize*2;
-
- // Build contracted bbox for layers.
- float bmin[3], bmax[3];
- rcVcopy(bmin, chf.bmin);
- rcVcopy(bmax, chf.bmax);
- bmin[0] += borderSize*chf.cs;
- bmin[2] += borderSize*chf.cs;
- bmax[0] -= borderSize*chf.cs;
- bmax[2] -= borderSize*chf.cs;
-
- lset.nlayers = (int)layerId;
-
- lset.layers = (rcHeightfieldLayer*)rcAlloc(sizeof(rcHeightfieldLayer)*lset.nlayers, RC_ALLOC_PERM);
- if (!lset.layers)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'layers' (%d).", lset.nlayers);
- return false;
- }
- memset(lset.layers, 0, sizeof(rcHeightfieldLayer)*lset.nlayers);
-
-
- // Store layers.
- for (int i = 0; i < lset.nlayers; ++i)
- {
- unsigned char curId = (unsigned char)i;
-
- rcHeightfieldLayer* layer = &lset.layers[i];
-
- const int gridSize = sizeof(unsigned char)*lw*lh;
-
- layer->heights = (unsigned char*)rcAlloc(gridSize, RC_ALLOC_PERM);
- if (!layer->heights)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'heights' (%d).", gridSize);
- return false;
- }
- memset(layer->heights, 0xff, gridSize);
-
- layer->areas = (unsigned char*)rcAlloc(gridSize, RC_ALLOC_PERM);
- if (!layer->areas)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'areas' (%d).", gridSize);
- return false;
- }
- memset(layer->areas, 0, gridSize);
-
- layer->cons = (unsigned char*)rcAlloc(gridSize, RC_ALLOC_PERM);
- if (!layer->cons)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'cons' (%d).", gridSize);
- return false;
- }
- memset(layer->cons, 0, gridSize);
-
- // Find layer height bounds.
- int hmin = 0, hmax = 0;
- for (int j = 0; j < nregs; ++j)
- {
- if (regs[j].base && regs[j].layerId == curId)
- {
- hmin = (int)regs[j].ymin;
- hmax = (int)regs[j].ymax;
- }
- }
-
- layer->width = lw;
- layer->height = lh;
- layer->cs = chf.cs;
- layer->ch = chf.ch;
-
- // Adjust the bbox to fit the heightfield.
- rcVcopy(layer->bmin, bmin);
- rcVcopy(layer->bmax, bmax);
- layer->bmin[1] = bmin[1] + hmin*chf.ch;
- layer->bmax[1] = bmin[1] + hmax*chf.ch;
- layer->hmin = hmin;
- layer->hmax = hmax;
-
- // Update usable data region.
- layer->minx = layer->width;
- layer->maxx = 0;
- layer->miny = layer->height;
- layer->maxy = 0;
-
- // Copy height and area from compact heightfield.
- for (int y = 0; y < lh; ++y)
- {
- for (int x = 0; x < lw; ++x)
- {
- const int cx = borderSize+x;
- const int cy = borderSize+y;
- const rcCompactCell& c = chf.cells[cx+cy*w];
- for (int j = (int)c.index, nj = (int)(c.index+c.count); j < nj; ++j)
- {
- const rcCompactSpan& s = chf.spans[j];
- // Skip unassigned regions.
- if (srcReg[j] == 0xff)
- continue;
- // Skip of does nto belong to current layer.
- unsigned char lid = regs[srcReg[j]].layerId;
- if (lid != curId)
- continue;
-
- // Update data bounds.
- layer->minx = rcMin(layer->minx, x);
- layer->maxx = rcMax(layer->maxx, x);
- layer->miny = rcMin(layer->miny, y);
- layer->maxy = rcMax(layer->maxy, y);
-
- // Store height and area type.
- const int idx = x+y*lw;
- layer->heights[idx] = (unsigned char)(s.y - hmin);
- layer->areas[idx] = chf.areas[j];
-
- // Check connection.
- unsigned char portal = 0;
- unsigned char con = 0;
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = cx + rcGetDirOffsetX(dir);
- const int ay = cy + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
- unsigned char alid = srcReg[ai] != 0xff ? regs[srcReg[ai]].layerId : 0xff;
- // Portal mask
- if (chf.areas[ai] != RC_NULL_AREA && lid != alid)
- {
- portal |= (unsigned char)(1<<dir);
- // Update height so that it matches on both sides of the portal.
- const rcCompactSpan& as = chf.spans[ai];
- if (as.y > hmin)
- layer->heights[idx] = rcMax(layer->heights[idx], (unsigned char)(as.y - hmin));
- }
- // Valid connection mask
- if (chf.areas[ai] != RC_NULL_AREA && lid == alid)
- {
- const int nx = ax - borderSize;
- const int ny = ay - borderSize;
- if (nx >= 0 && ny >= 0 && nx < lw && ny < lh)
- con |= (unsigned char)(1<<dir);
- }
- }
- }
-
- layer->cons[idx] = (portal << 4) | con;
- }
- }
- }
-
- if (layer->minx > layer->maxx)
- layer->minx = layer->maxx = 0;
- if (layer->miny > layer->maxy)
- layer->miny = layer->maxy = 0;
- }
-
- return true;
-}
diff --git a/extern/recastnavigation/Recast/Source/RecastMesh.cpp b/extern/recastnavigation/Recast/Source/RecastMesh.cpp
deleted file mode 100644
index e762318431f..00000000000
--- a/extern/recastnavigation/Recast/Source/RecastMesh.cpp
+++ /dev/null
@@ -1,1552 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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.
-//
-
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <string.h>
-#include <stdio.h>
-#include "Recast.h"
-#include "RecastAlloc.h"
-#include "RecastAssert.h"
-
-struct rcEdge
-{
- unsigned short vert[2];
- unsigned short polyEdge[2];
- unsigned short poly[2];
-};
-
-/*static*/ bool buildMeshAdjacency(unsigned short* polys, const int npolys,
- const int nverts, const int vertsPerPoly)
-{
- // Based on code by Eric Lengyel from:
- // http://www.terathon.com/code/edges.php
-
- int maxEdgeCount = npolys*vertsPerPoly;
- unsigned short* firstEdge = (unsigned short*)rcAlloc(sizeof(unsigned short)*(nverts + maxEdgeCount), RC_ALLOC_TEMP);
- if (!firstEdge)
- return false;
- unsigned short* nextEdge = firstEdge + nverts;
- int edgeCount = 0;
-
- rcEdge* edges = (rcEdge*)rcAlloc(sizeof(rcEdge)*maxEdgeCount, RC_ALLOC_TEMP);
- if (!edges)
- {
- rcFree(firstEdge);
- return false;
- }
-
- for (int i = 0; i < nverts; i++)
- firstEdge[i] = RC_MESH_NULL_IDX;
-
- for (int i = 0; i < npolys; ++i)
- {
- unsigned short* t = &polys[i*vertsPerPoly*2];
- for (int j = 0; j < vertsPerPoly; ++j)
- {
- if (t[j] == RC_MESH_NULL_IDX) break;
- unsigned short v0 = t[j];
- unsigned short v1 = (j+1 >= vertsPerPoly || t[j+1] == RC_MESH_NULL_IDX) ? t[0] : t[j+1];
- if (v0 < v1)
- {
- rcEdge& edge = edges[edgeCount];
- edge.vert[0] = v0;
- edge.vert[1] = v1;
- edge.poly[0] = (unsigned short)i;
- edge.polyEdge[0] = (unsigned short)j;
- edge.poly[1] = (unsigned short)i;
- edge.polyEdge[1] = 0;
- // Insert edge
- nextEdge[edgeCount] = firstEdge[v0];
- firstEdge[v0] = (unsigned short)edgeCount;
- edgeCount++;
- }
- }
- }
-
- for (int i = 0; i < npolys; ++i)
- {
- unsigned short* t = &polys[i*vertsPerPoly*2];
- for (int j = 0; j < vertsPerPoly; ++j)
- {
- if (t[j] == RC_MESH_NULL_IDX) break;
- unsigned short v0 = t[j];
- unsigned short v1 = (j+1 >= vertsPerPoly || t[j+1] == RC_MESH_NULL_IDX) ? t[0] : t[j+1];
- if (v0 > v1)
- {
- for (unsigned short e = firstEdge[v1]; e != RC_MESH_NULL_IDX; e = nextEdge[e])
- {
- rcEdge& edge = edges[e];
- if (edge.vert[1] == v0 && edge.poly[0] == edge.poly[1])
- {
- edge.poly[1] = (unsigned short)i;
- edge.polyEdge[1] = (unsigned short)j;
- break;
- }
- }
- }
- }
- }
-
- // Store adjacency
- for (int i = 0; i < edgeCount; ++i)
- {
- const rcEdge& e = edges[i];
- if (e.poly[0] != e.poly[1])
- {
- unsigned short* p0 = &polys[e.poly[0]*vertsPerPoly*2];
- unsigned short* p1 = &polys[e.poly[1]*vertsPerPoly*2];
- p0[vertsPerPoly + e.polyEdge[0]] = e.poly[1];
- p1[vertsPerPoly + e.polyEdge[1]] = e.poly[0];
- }
- }
-
- rcFree(firstEdge);
- rcFree(edges);
-
- return true;
-}
-
-
-static const int VERTEX_BUCKET_COUNT = (1<<12);
-
-inline int computeVertexHash(int x, int y, int z)
-{
- const unsigned int h1 = 0x8da6b343; // Large multiplicative constants;
- const unsigned int h2 = 0xd8163841; // here arbitrarily chosen primes
- const unsigned int h3 = 0xcb1ab31f;
- unsigned int n = h1 * x + h2 * y + h3 * z;
- return (int)(n & (VERTEX_BUCKET_COUNT-1));
-}
-
-static unsigned short addVertex(unsigned short x, unsigned short y, unsigned short z,
- unsigned short* verts, int* firstVert, int* nextVert, int& nv)
-{
- int bucket = computeVertexHash(x, 0, z);
- int i = firstVert[bucket];
-
- while (i != -1)
- {
- const unsigned short* v = &verts[i*3];
- if (v[0] == x && (rcAbs(v[1] - y) <= 2) && v[2] == z)
- return (unsigned short)i;
- i = nextVert[i]; // next
- }
-
- // Could not find, create new.
- i = nv; nv++;
- unsigned short* v = &verts[i*3];
- v[0] = x;
- v[1] = y;
- v[2] = z;
- nextVert[i] = firstVert[bucket];
- firstVert[bucket] = i;
-
- return (unsigned short)i;
-}
-
-// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).
-inline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }
-inline int next(int i, int n) { return i+1 < n ? i+1 : 0; }
-
-inline int area2(const int* a, const int* b, const int* c)
-{
- return (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]);
-}
-
-// Exclusive or: true iff exactly one argument is true.
-// The arguments are negated to ensure that they are 0/1
-// values. Then the bitwise Xor operator may apply.
-// (This idea is due to Michael Baldwin.)
-inline bool xorb(bool x, bool y)
-{
- return !x ^ !y;
-}
-
-// Returns true iff c is strictly to the left of the directed
-// line through a to b.
-inline bool left(const int* a, const int* b, const int* c)
-{
- return area2(a, b, c) < 0;
-}
-
-inline bool leftOn(const int* a, const int* b, const int* c)
-{
- return area2(a, b, c) <= 0;
-}
-
-inline bool collinear(const int* a, const int* b, const int* c)
-{
- return area2(a, b, c) == 0;
-}
-
-// Returns true iff ab properly intersects cd: they share
-// a point interior to both segments. The properness of the
-// intersection is ensured by using strict leftness.
-static bool intersectProp(const int* a, const int* b, const int* c, const int* d)
-{
- // Eliminate improper cases.
- if (collinear(a,b,c) || collinear(a,b,d) ||
- collinear(c,d,a) || collinear(c,d,b))
- return false;
-
- return xorb(left(a,b,c), left(a,b,d)) && xorb(left(c,d,a), left(c,d,b));
-}
-
-// Returns T iff (a,b,c) are collinear and point c lies
-// on the closed segement ab.
-static bool between(const int* a, const int* b, const int* c)
-{
- if (!collinear(a, b, c))
- return false;
- // If ab not vertical, check betweenness on x; else on y.
- if (a[0] != b[0])
- return ((a[0] <= c[0]) && (c[0] <= b[0])) || ((a[0] >= c[0]) && (c[0] >= b[0]));
- else
- return ((a[2] <= c[2]) && (c[2] <= b[2])) || ((a[2] >= c[2]) && (c[2] >= b[2]));
-}
-
-// Returns true iff segments ab and cd intersect, properly or improperly.
-static bool intersect(const int* a, const int* b, const int* c, const int* d)
-{
- if (intersectProp(a, b, c, d))
- return true;
- else if (between(a, b, c) || between(a, b, d) ||
- between(c, d, a) || between(c, d, b))
- return true;
- else
- return false;
-}
-
-static bool vequal(const int* a, const int* b)
-{
- return a[0] == b[0] && a[2] == b[2];
-}
-
-// Returns T iff (v_i, v_j) is a proper internal *or* external
-// diagonal of P, *ignoring edges incident to v_i and v_j*.
-static bool diagonalie(int i, int j, int n, const int* verts, int* indices)
-{
- const int* d0 = &verts[(indices[i] & 0x0fffffff) * 4];
- const int* d1 = &verts[(indices[j] & 0x0fffffff) * 4];
-
- // For each edge (k,k+1) of P
- for (int k = 0; k < n; k++)
- {
- int k1 = next(k, n);
- // Skip edges incident to i or j
- if (!((k == i) || (k1 == i) || (k == j) || (k1 == j)))
- {
- const int* p0 = &verts[(indices[k] & 0x0fffffff) * 4];
- const int* p1 = &verts[(indices[k1] & 0x0fffffff) * 4];
-
- if (vequal(d0, p0) || vequal(d1, p0) || vequal(d0, p1) || vequal(d1, p1))
- continue;
-
- if (intersect(d0, d1, p0, p1))
- return false;
- }
- }
- return true;
-}
-
-// Returns true iff the diagonal (i,j) is strictly internal to the
-// polygon P in the neighborhood of the i endpoint.
-static bool inCone(int i, int j, int n, const int* verts, int* indices)
-{
- const int* pi = &verts[(indices[i] & 0x0fffffff) * 4];
- const int* pj = &verts[(indices[j] & 0x0fffffff) * 4];
- const int* pi1 = &verts[(indices[next(i, n)] & 0x0fffffff) * 4];
- const int* pin1 = &verts[(indices[prev(i, n)] & 0x0fffffff) * 4];
-
- // If P[i] is a convex vertex [ i+1 left or on (i-1,i) ].
- if (leftOn(pin1, pi, pi1))
- return left(pi, pj, pin1) && left(pj, pi, pi1);
- // Assume (i-1,i,i+1) not collinear.
- // else P[i] is reflex.
- return !(leftOn(pi, pj, pi1) && leftOn(pj, pi, pin1));
-}
-
-// Returns T iff (v_i, v_j) is a proper internal
-// diagonal of P.
-static bool diagonal(int i, int j, int n, const int* verts, int* indices)
-{
- return inCone(i, j, n, verts, indices) && diagonalie(i, j, n, verts, indices);
-}
-
-
-static bool diagonalieLoose(int i, int j, int n, const int* verts, int* indices)
-{
- const int* d0 = &verts[(indices[i] & 0x0fffffff) * 4];
- const int* d1 = &verts[(indices[j] & 0x0fffffff) * 4];
-
- // For each edge (k,k+1) of P
- for (int k = 0; k < n; k++)
- {
- int k1 = next(k, n);
- // Skip edges incident to i or j
- if (!((k == i) || (k1 == i) || (k == j) || (k1 == j)))
- {
- const int* p0 = &verts[(indices[k] & 0x0fffffff) * 4];
- const int* p1 = &verts[(indices[k1] & 0x0fffffff) * 4];
-
- if (vequal(d0, p0) || vequal(d1, p0) || vequal(d0, p1) || vequal(d1, p1))
- continue;
-
- if (intersectProp(d0, d1, p0, p1))
- return false;
- }
- }
- return true;
-}
-
-static bool inConeLoose(int i, int j, int n, const int* verts, int* indices)
-{
- const int* pi = &verts[(indices[i] & 0x0fffffff) * 4];
- const int* pj = &verts[(indices[j] & 0x0fffffff) * 4];
- const int* pi1 = &verts[(indices[next(i, n)] & 0x0fffffff) * 4];
- const int* pin1 = &verts[(indices[prev(i, n)] & 0x0fffffff) * 4];
-
- // If P[i] is a convex vertex [ i+1 left or on (i-1,i) ].
- if (leftOn(pin1, pi, pi1))
- return leftOn(pi, pj, pin1) && leftOn(pj, pi, pi1);
- // Assume (i-1,i,i+1) not collinear.
- // else P[i] is reflex.
- return !(leftOn(pi, pj, pi1) && leftOn(pj, pi, pin1));
-}
-
-static bool diagonalLoose(int i, int j, int n, const int* verts, int* indices)
-{
- return inConeLoose(i, j, n, verts, indices) && diagonalieLoose(i, j, n, verts, indices);
-}
-
-
-static int triangulate(int n, const int* verts, int* indices, int* tris)
-{
- int ntris = 0;
- int* dst = tris;
-
- // The last bit of the index is used to indicate if the vertex can be removed.
- for (int i = 0; i < n; i++)
- {
- int i1 = next(i, n);
- int i2 = next(i1, n);
- if (diagonal(i, i2, n, verts, indices))
- indices[i1] |= 0x80000000;
- }
-
- while (n > 3)
- {
- int minLen = -1;
- int mini = -1;
- for (int i = 0; i < n; i++)
- {
- int i1 = next(i, n);
- if (indices[i1] & 0x80000000)
- {
- const int* p0 = &verts[(indices[i] & 0x0fffffff) * 4];
- const int* p2 = &verts[(indices[next(i1, n)] & 0x0fffffff) * 4];
-
- int dx = p2[0] - p0[0];
- int dy = p2[2] - p0[2];
- int len = dx*dx + dy*dy;
-
- if (minLen < 0 || len < minLen)
- {
- minLen = len;
- mini = i;
- }
- }
- }
-
- if (mini == -1)
- {
- // We might get here because the contour has overlapping segments, like this:
- //
- // A o-o=====o---o B
- // / |C D| \
- // o o o o
- // : : : :
- // We'll try to recover by loosing up the inCone test a bit so that a diagonal
- // like A-B or C-D can be found and we can continue.
- minLen = -1;
- mini = -1;
- for (int i = 0; i < n; i++)
- {
- int i1 = next(i, n);
- int i2 = next(i1, n);
- if (diagonalLoose(i, i2, n, verts, indices))
- {
- const int* p0 = &verts[(indices[i] & 0x0fffffff) * 4];
- const int* p2 = &verts[(indices[next(i2, n)] & 0x0fffffff) * 4];
- int dx = p2[0] - p0[0];
- int dy = p2[2] - p0[2];
- int len = dx*dx + dy*dy;
-
- if (minLen < 0 || len < minLen)
- {
- minLen = len;
- mini = i;
- }
- }
- }
- if (mini == -1)
- {
- // The contour is messed up. This sometimes happens
- // if the contour simplification is too aggressive.
- return -ntris;
- }
- }
-
- int i = mini;
- int i1 = next(i, n);
- int i2 = next(i1, n);
-
- *dst++ = indices[i] & 0x0fffffff;
- *dst++ = indices[i1] & 0x0fffffff;
- *dst++ = indices[i2] & 0x0fffffff;
- ntris++;
-
- // Removes P[i1] by copying P[i+1]...P[n-1] left one index.
- n--;
- for (int k = i1; k < n; k++)
- indices[k] = indices[k+1];
-
- if (i1 >= n) i1 = 0;
- i = prev(i1,n);
- // Update diagonal flags.
- if (diagonal(prev(i, n), i1, n, verts, indices))
- indices[i] |= 0x80000000;
- else
- indices[i] &= 0x0fffffff;
-
- if (diagonal(i, next(i1, n), n, verts, indices))
- indices[i1] |= 0x80000000;
- else
- indices[i1] &= 0x0fffffff;
- }
-
- // Append the remaining triangle.
- *dst++ = indices[0] & 0x0fffffff;
- *dst++ = indices[1] & 0x0fffffff;
- *dst++ = indices[2] & 0x0fffffff;
- ntris++;
-
- return ntris;
-}
-
-static int countPolyVerts(const unsigned short* p, const int nvp)
-{
- for (int i = 0; i < nvp; ++i)
- if (p[i] == RC_MESH_NULL_IDX)
- return i;
- return nvp;
-}
-
-inline bool uleft(const unsigned short* a, const unsigned short* b, const unsigned short* c)
-{
- return ((int)b[0] - (int)a[0]) * ((int)c[2] - (int)a[2]) -
- ((int)c[0] - (int)a[0]) * ((int)b[2] - (int)a[2]) < 0;
-}
-
-static int getPolyMergeValue(unsigned short* pa, unsigned short* pb,
- const unsigned short* verts, int& ea, int& eb,
- const int nvp)
-{
- const int na = countPolyVerts(pa, nvp);
- const int nb = countPolyVerts(pb, nvp);
-
- // If the merged polygon would be too big, do not merge.
- if (na+nb-2 > nvp)
- return -1;
-
- // Check if the polygons share an edge.
- ea = -1;
- eb = -1;
-
- for (int i = 0; i < na; ++i)
- {
- unsigned short va0 = pa[i];
- unsigned short va1 = pa[(i+1) % na];
- if (va0 > va1)
- rcSwap(va0, va1);
- for (int j = 0; j < nb; ++j)
- {
- unsigned short vb0 = pb[j];
- unsigned short vb1 = pb[(j+1) % nb];
- if (vb0 > vb1)
- rcSwap(vb0, vb1);
- if (va0 == vb0 && va1 == vb1)
- {
- ea = i;
- eb = j;
- break;
- }
- }
- }
-
- // No common edge, cannot merge.
- if (ea == -1 || eb == -1)
- return -1;
-
- // Check to see if the merged polygon would be convex.
- unsigned short va, vb, vc;
-
- va = pa[(ea+na-1) % na];
- vb = pa[ea];
- vc = pb[(eb+2) % nb];
- if (!uleft(&verts[va*3], &verts[vb*3], &verts[vc*3]))
- return -1;
-
- va = pb[(eb+nb-1) % nb];
- vb = pb[eb];
- vc = pa[(ea+2) % na];
- if (!uleft(&verts[va*3], &verts[vb*3], &verts[vc*3]))
- return -1;
-
- va = pa[ea];
- vb = pa[(ea+1)%na];
-
- int dx = (int)verts[va*3+0] - (int)verts[vb*3+0];
- int dy = (int)verts[va*3+2] - (int)verts[vb*3+2];
-
- return dx*dx + dy*dy;
-}
-
-static void mergePolyVerts(unsigned short* pa, unsigned short* pb, int ea, int eb,
- unsigned short* tmp, const int nvp)
-{
- const int na = countPolyVerts(pa, nvp);
- const int nb = countPolyVerts(pb, nvp);
-
- // Merge polygons.
- memset(tmp, 0xff, sizeof(unsigned short)*nvp);
- int n = 0;
- // Add pa
- for (int i = 0; i < na-1; ++i)
- tmp[n++] = pa[(ea+1+i) % na];
- // Add pb
- for (int i = 0; i < nb-1; ++i)
- tmp[n++] = pb[(eb+1+i) % nb];
-
- memcpy(pa, tmp, sizeof(unsigned short)*nvp);
-}
-
-
-static void pushFront(int v, int* arr, int& an)
-{
- an++;
- for (int i = an-1; i > 0; --i) arr[i] = arr[i-1];
- arr[0] = v;
-}
-
-static void pushBack(int v, int* arr, int& an)
-{
- arr[an] = v;
- an++;
-}
-
-static bool canRemoveVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short rem)
-{
- const int nvp = mesh.nvp;
-
- // Count number of polygons to remove.
- int numRemovedVerts = 0;
- int numTouchedVerts = 0;
- int numRemainingEdges = 0;
- for (int i = 0; i < mesh.npolys; ++i)
- {
- unsigned short* p = &mesh.polys[i*nvp*2];
- const int nv = countPolyVerts(p, nvp);
- int numRemoved = 0;
- int numVerts = 0;
- for (int j = 0; j < nv; ++j)
- {
- if (p[j] == rem)
- {
- numTouchedVerts++;
- numRemoved++;
- }
- numVerts++;
- }
- if (numRemoved)
- {
- numRemovedVerts += numRemoved;
- numRemainingEdges += numVerts-(numRemoved+1);
- }
- }
-
- // There would be too few edges remaining to create a polygon.
- // This can happen for example when a tip of a triangle is marked
- // as deletion, but there are no other polys that share the vertex.
- // In this case, the vertex should not be removed.
- if (numRemainingEdges <= 2)
- return false;
-
- // Find edges which share the removed vertex.
- const int maxEdges = numTouchedVerts*2;
- int nedges = 0;
- rcScopedDelete<int> edges((int*)rcAlloc(sizeof(int)*maxEdges*3, RC_ALLOC_TEMP));
- if (!edges)
- {
- ctx->log(RC_LOG_WARNING, "canRemoveVertex: Out of memory 'edges' (%d).", maxEdges*3);
- return false;
- }
-
- for (int i = 0; i < mesh.npolys; ++i)
- {
- unsigned short* p = &mesh.polys[i*nvp*2];
- const int nv = countPolyVerts(p, nvp);
-
- // Collect edges which touches the removed vertex.
- for (int j = 0, k = nv-1; j < nv; k = j++)
- {
- if (p[j] == rem || p[k] == rem)
- {
- // Arrange edge so that a=rem.
- int a = p[j], b = p[k];
- if (b == rem)
- rcSwap(a,b);
-
- // Check if the edge exists
- bool exists = false;
- for (int m = 0; m < nedges; ++m)
- {
- int* e = &edges[m*3];
- if (e[1] == b)
- {
- // Exists, increment vertex share count.
- e[2]++;
- exists = true;
- }
- }
- // Add new edge.
- if (!exists)
- {
- int* e = &edges[nedges*3];
- e[0] = a;
- e[1] = b;
- e[2] = 1;
- nedges++;
- }
- }
- }
- }
-
- // There should be no more than 2 open edges.
- // This catches the case that two non-adjacent polygons
- // share the removed vertex. In that case, do not remove the vertex.
- int numOpenEdges = 0;
- for (int i = 0; i < nedges; ++i)
- {
- if (edges[i*3+2] < 2)
- numOpenEdges++;
- }
- if (numOpenEdges > 2)
- return false;
-
- return true;
-}
-
-static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short rem, const int maxTris)
-{
- const int nvp = mesh.nvp;
-
- // Count number of polygons to remove.
- int numRemovedVerts = 0;
- for (int i = 0; i < mesh.npolys; ++i)
- {
- unsigned short* p = &mesh.polys[i*nvp*2];
- const int nv = countPolyVerts(p, nvp);
- for (int j = 0; j < nv; ++j)
- {
- if (p[j] == rem)
- numRemovedVerts++;
- }
- }
-
- int nedges = 0;
- rcScopedDelete<int> edges((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp*4, RC_ALLOC_TEMP));
- if (!edges)
- {
- ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'edges' (%d).", numRemovedVerts*nvp*4);
- return false;
- }
-
- int nhole = 0;
- rcScopedDelete<int> hole((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));
- if (!hole)
- {
- ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'hole' (%d).", numRemovedVerts*nvp);
- return false;
- }
-
- int nhreg = 0;
- rcScopedDelete<int> hreg((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));
- if (!hreg)
- {
- ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'hreg' (%d).", numRemovedVerts*nvp);
- return false;
- }
-
- int nharea = 0;
- rcScopedDelete<int> harea((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));
- if (!harea)
- {
- ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'harea' (%d).", numRemovedVerts*nvp);
- return false;
- }
-
- for (int i = 0; i < mesh.npolys; ++i)
- {
- unsigned short* p = &mesh.polys[i*nvp*2];
- const int nv = countPolyVerts(p, nvp);
- bool hasRem = false;
- for (int j = 0; j < nv; ++j)
- if (p[j] == rem) hasRem = true;
- if (hasRem)
- {
- // Collect edges which does not touch the removed vertex.
- for (int j = 0, k = nv-1; j < nv; k = j++)
- {
- if (p[j] != rem && p[k] != rem)
- {
- int* e = &edges[nedges*4];
- e[0] = p[k];
- e[1] = p[j];
- e[2] = mesh.regs[i];
- e[3] = mesh.areas[i];
- nedges++;
- }
- }
- // Remove the polygon.
- unsigned short* p2 = &mesh.polys[(mesh.npolys-1)*nvp*2];
- if (p != p2)
- memcpy(p,p2,sizeof(unsigned short)*nvp);
- memset(p+nvp,0xff,sizeof(unsigned short)*nvp);
- mesh.regs[i] = mesh.regs[mesh.npolys-1];
- mesh.areas[i] = mesh.areas[mesh.npolys-1];
- mesh.npolys--;
- --i;
- }
- }
-
- // Remove vertex.
- for (int i = (int)rem; i < mesh.nverts - 1; ++i)
- {
- mesh.verts[i*3+0] = mesh.verts[(i+1)*3+0];
- mesh.verts[i*3+1] = mesh.verts[(i+1)*3+1];
- mesh.verts[i*3+2] = mesh.verts[(i+1)*3+2];
- }
- mesh.nverts--;
-
- // Adjust indices to match the removed vertex layout.
- for (int i = 0; i < mesh.npolys; ++i)
- {
- unsigned short* p = &mesh.polys[i*nvp*2];
- const int nv = countPolyVerts(p, nvp);
- for (int j = 0; j < nv; ++j)
- if (p[j] > rem) p[j]--;
- }
- for (int i = 0; i < nedges; ++i)
- {
- if (edges[i*4+0] > rem) edges[i*4+0]--;
- if (edges[i*4+1] > rem) edges[i*4+1]--;
- }
-
- if (nedges == 0)
- return true;
-
- // Start with one vertex, keep appending connected
- // segments to the start and end of the hole.
- pushBack(edges[0], hole, nhole);
- pushBack(edges[2], hreg, nhreg);
- pushBack(edges[3], harea, nharea);
-
- while (nedges)
- {
- bool match = false;
-
- for (int i = 0; i < nedges; ++i)
- {
- const int ea = edges[i*4+0];
- const int eb = edges[i*4+1];
- const int r = edges[i*4+2];
- const int a = edges[i*4+3];
- bool add = false;
- if (hole[0] == eb)
- {
- // The segment matches the beginning of the hole boundary.
- pushFront(ea, hole, nhole);
- pushFront(r, hreg, nhreg);
- pushFront(a, harea, nharea);
- add = true;
- }
- else if (hole[nhole-1] == ea)
- {
- // The segment matches the end of the hole boundary.
- pushBack(eb, hole, nhole);
- pushBack(r, hreg, nhreg);
- pushBack(a, harea, nharea);
- add = true;
- }
- if (add)
- {
- // The edge segment was added, remove it.
- edges[i*4+0] = edges[(nedges-1)*4+0];
- edges[i*4+1] = edges[(nedges-1)*4+1];
- edges[i*4+2] = edges[(nedges-1)*4+2];
- edges[i*4+3] = edges[(nedges-1)*4+3];
- --nedges;
- match = true;
- --i;
- }
- }
-
- if (!match)
- break;
- }
-
- rcScopedDelete<int> tris((int*)rcAlloc(sizeof(int)*nhole*3, RC_ALLOC_TEMP));
- if (!tris)
- {
- ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'tris' (%d).", nhole*3);
- return false;
- }
-
- rcScopedDelete<int> tverts((int*)rcAlloc(sizeof(int)*nhole*4, RC_ALLOC_TEMP));
- if (!tverts)
- {
- ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'tverts' (%d).", nhole*4);
- return false;
- }
-
- rcScopedDelete<int> thole((int*)rcAlloc(sizeof(int)*nhole, RC_ALLOC_TEMP));
- if (!thole)
- {
- ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'thole' (%d).", nhole);
- return false;
- }
-
- // Generate temp vertex array for triangulation.
- for (int i = 0; i < nhole; ++i)
- {
- const int pi = hole[i];
- tverts[i*4+0] = mesh.verts[pi*3+0];
- tverts[i*4+1] = mesh.verts[pi*3+1];
- tverts[i*4+2] = mesh.verts[pi*3+2];
- tverts[i*4+3] = 0;
- thole[i] = i;
- }
-
- // Triangulate the hole.
- int ntris = triangulate(nhole, &tverts[0], &thole[0], tris);
- if (ntris < 0)
- {
- ntris = -ntris;
- ctx->log(RC_LOG_WARNING, "removeVertex: triangulate() returned bad results.");
- }
-
- // Merge the hole triangles back to polygons.
- rcScopedDelete<unsigned short> polys((unsigned short*)rcAlloc(sizeof(unsigned short)*(ntris+1)*nvp, RC_ALLOC_TEMP));
- if (!polys)
- {
- ctx->log(RC_LOG_ERROR, "removeVertex: Out of memory 'polys' (%d).", (ntris+1)*nvp);
- return false;
- }
- rcScopedDelete<unsigned short> pregs((unsigned short*)rcAlloc(sizeof(unsigned short)*ntris, RC_ALLOC_TEMP));
- if (!pregs)
- {
- ctx->log(RC_LOG_ERROR, "removeVertex: Out of memory 'pregs' (%d).", ntris);
- return false;
- }
- rcScopedDelete<unsigned char> pareas((unsigned char*)rcAlloc(sizeof(unsigned char)*ntris, RC_ALLOC_TEMP));
- if (!pareas)
- {
- ctx->log(RC_LOG_ERROR, "removeVertex: Out of memory 'pareas' (%d).", ntris);
- return false;
- }
-
- unsigned short* tmpPoly = &polys[ntris*nvp];
-
- // Build initial polygons.
- int npolys = 0;
- memset(polys, 0xff, ntris*nvp*sizeof(unsigned short));
- for (int j = 0; j < ntris; ++j)
- {
- int* t = &tris[j*3];
- if (t[0] != t[1] && t[0] != t[2] && t[1] != t[2])
- {
- polys[npolys*nvp+0] = (unsigned short)hole[t[0]];
- polys[npolys*nvp+1] = (unsigned short)hole[t[1]];
- polys[npolys*nvp+2] = (unsigned short)hole[t[2]];
-
- // If this polygon covers multiple region types then
- // mark it as such
- if (hreg[t[0]] != hreg[t[1]] || hreg[t[1]] != hreg[t[2]])
- pregs[npolys] = RC_MULTIPLE_REGS;
- else
- pregs[npolys] = (unsigned short)hreg[t[0]];
-
- pareas[npolys] = (unsigned char)harea[t[0]];
- npolys++;
- }
- }
- if (!npolys)
- return true;
-
- // Merge polygons.
- if (nvp > 3)
- {
- for (;;)
- {
- // Find best polygons to merge.
- int bestMergeVal = 0;
- int bestPa = 0, bestPb = 0, bestEa = 0, bestEb = 0;
-
- for (int j = 0; j < npolys-1; ++j)
- {
- unsigned short* pj = &polys[j*nvp];
- for (int k = j+1; k < npolys; ++k)
- {
- unsigned short* pk = &polys[k*nvp];
- int ea, eb;
- int v = getPolyMergeValue(pj, pk, mesh.verts, ea, eb, nvp);
- if (v > bestMergeVal)
- {
- bestMergeVal = v;
- bestPa = j;
- bestPb = k;
- bestEa = ea;
- bestEb = eb;
- }
- }
- }
-
- if (bestMergeVal > 0)
- {
- // Found best, merge.
- unsigned short* pa = &polys[bestPa*nvp];
- unsigned short* pb = &polys[bestPb*nvp];
- mergePolyVerts(pa, pb, bestEa, bestEb, tmpPoly, nvp);
- if (pregs[bestPa] != pregs[bestPb])
- pregs[bestPa] = RC_MULTIPLE_REGS;
-
- unsigned short* last = &polys[(npolys-1)*nvp];
- if (pb != last)
- memcpy(pb, last, sizeof(unsigned short)*nvp);
- pregs[bestPb] = pregs[npolys-1];
- pareas[bestPb] = pareas[npolys-1];
- npolys--;
- }
- else
- {
- // Could not merge any polygons, stop.
- break;
- }
- }
- }
-
- // Store polygons.
- for (int i = 0; i < npolys; ++i)
- {
- if (mesh.npolys >= maxTris) break;
- unsigned short* p = &mesh.polys[mesh.npolys*nvp*2];
- memset(p,0xff,sizeof(unsigned short)*nvp*2);
- for (int j = 0; j < nvp; ++j)
- p[j] = polys[i*nvp+j];
- mesh.regs[mesh.npolys] = pregs[i];
- mesh.areas[mesh.npolys] = pareas[i];
- mesh.npolys++;
- if (mesh.npolys > maxTris)
- {
- ctx->log(RC_LOG_ERROR, "removeVertex: Too many polygons %d (max:%d).", mesh.npolys, maxTris);
- return false;
- }
- }
-
- return true;
-}
-
-/// @par
-///
-/// @note If the mesh data is to be used to construct a Detour navigation mesh, then the upper
-/// limit must be retricted to <= #DT_VERTS_PER_POLYGON.
-///
-/// @see rcAllocPolyMesh, rcContourSet, rcPolyMesh, rcConfig
-bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMesh& mesh)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_BUILD_POLYMESH);
-
- rcVcopy(mesh.bmin, cset.bmin);
- rcVcopy(mesh.bmax, cset.bmax);
- mesh.cs = cset.cs;
- mesh.ch = cset.ch;
- mesh.borderSize = cset.borderSize;
- mesh.maxEdgeError = cset.maxError;
-
- int maxVertices = 0;
- int maxTris = 0;
- int maxVertsPerCont = 0;
- for (int i = 0; i < cset.nconts; ++i)
- {
- // Skip null contours.
- if (cset.conts[i].nverts < 3) continue;
- maxVertices += cset.conts[i].nverts;
- maxTris += cset.conts[i].nverts - 2;
- maxVertsPerCont = rcMax(maxVertsPerCont, cset.conts[i].nverts);
- }
-
- if (maxVertices >= 0xfffe)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Too many vertices %d.", maxVertices);
- return false;
- }
-
- rcScopedDelete<unsigned char> vflags((unsigned char*)rcAlloc(sizeof(unsigned char)*maxVertices, RC_ALLOC_TEMP));
- if (!vflags)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'vflags' (%d).", maxVertices);
- return false;
- }
- memset(vflags, 0, maxVertices);
-
- mesh.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxVertices*3, RC_ALLOC_PERM);
- if (!mesh.verts)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.verts' (%d).", maxVertices);
- return false;
- }
- mesh.polys = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxTris*nvp*2, RC_ALLOC_PERM);
- if (!mesh.polys)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.polys' (%d).", maxTris*nvp*2);
- return false;
- }
- mesh.regs = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxTris, RC_ALLOC_PERM);
- if (!mesh.regs)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.regs' (%d).", maxTris);
- return false;
- }
- mesh.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*maxTris, RC_ALLOC_PERM);
- if (!mesh.areas)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.areas' (%d).", maxTris);
- return false;
- }
-
- mesh.nverts = 0;
- mesh.npolys = 0;
- mesh.nvp = nvp;
- mesh.maxpolys = maxTris;
-
- memset(mesh.verts, 0, sizeof(unsigned short)*maxVertices*3);
- memset(mesh.polys, 0xff, sizeof(unsigned short)*maxTris*nvp*2);
- memset(mesh.regs, 0, sizeof(unsigned short)*maxTris);
- memset(mesh.areas, 0, sizeof(unsigned char)*maxTris);
-
- rcScopedDelete<int> nextVert((int*)rcAlloc(sizeof(int)*maxVertices, RC_ALLOC_TEMP));
- if (!nextVert)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'nextVert' (%d).", maxVertices);
- return false;
- }
- memset(nextVert, 0, sizeof(int)*maxVertices);
-
- rcScopedDelete<int> firstVert((int*)rcAlloc(sizeof(int)*VERTEX_BUCKET_COUNT, RC_ALLOC_TEMP));
- if (!firstVert)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'firstVert' (%d).", VERTEX_BUCKET_COUNT);
- return false;
- }
- for (int i = 0; i < VERTEX_BUCKET_COUNT; ++i)
- firstVert[i] = -1;
-
- rcScopedDelete<int> indices((int*)rcAlloc(sizeof(int)*maxVertsPerCont, RC_ALLOC_TEMP));
- if (!indices)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'indices' (%d).", maxVertsPerCont);
- return false;
- }
- rcScopedDelete<int> tris((int*)rcAlloc(sizeof(int)*maxVertsPerCont*3, RC_ALLOC_TEMP));
- if (!tris)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'tris' (%d).", maxVertsPerCont*3);
- return false;
- }
- rcScopedDelete<unsigned short> polys((unsigned short*)rcAlloc(sizeof(unsigned short)*(maxVertsPerCont+1)*nvp, RC_ALLOC_TEMP));
- if (!polys)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'polys' (%d).", maxVertsPerCont*nvp);
- return false;
- }
- unsigned short* tmpPoly = &polys[maxVertsPerCont*nvp];
-
- for (int i = 0; i < cset.nconts; ++i)
- {
- rcContour& cont = cset.conts[i];
-
- // Skip null contours.
- if (cont.nverts < 3)
- continue;
-
- // Triangulate contour
- for (int j = 0; j < cont.nverts; ++j)
- indices[j] = j;
-
- int ntris = triangulate(cont.nverts, cont.verts, &indices[0], &tris[0]);
- if (ntris <= 0)
- {
- // Bad triangulation, should not happen.
-/* printf("\tconst float bmin[3] = {%ff,%ff,%ff};\n", cset.bmin[0], cset.bmin[1], cset.bmin[2]);
- printf("\tconst float cs = %ff;\n", cset.cs);
- printf("\tconst float ch = %ff;\n", cset.ch);
- printf("\tconst int verts[] = {\n");
- for (int k = 0; k < cont.nverts; ++k)
- {
- const int* v = &cont.verts[k*4];
- printf("\t\t%d,%d,%d,%d,\n", v[0], v[1], v[2], v[3]);
- }
- printf("\t};\n\tconst int nverts = sizeof(verts)/(sizeof(int)*4);\n");*/
- ctx->log(RC_LOG_WARNING, "rcBuildPolyMesh: Bad triangulation Contour %d.", i);
- ntris = -ntris;
- }
-
- // Add and merge vertices.
- for (int j = 0; j < cont.nverts; ++j)
- {
- const int* v = &cont.verts[j*4];
- indices[j] = addVertex((unsigned short)v[0], (unsigned short)v[1], (unsigned short)v[2],
- mesh.verts, firstVert, nextVert, mesh.nverts);
- if (v[3] & RC_BORDER_VERTEX)
- {
- // This vertex should be removed.
- vflags[indices[j]] = 1;
- }
- }
-
- // Build initial polygons.
- int npolys = 0;
- memset(polys, 0xff, maxVertsPerCont*nvp*sizeof(unsigned short));
- for (int j = 0; j < ntris; ++j)
- {
- int* t = &tris[j*3];
- if (t[0] != t[1] && t[0] != t[2] && t[1] != t[2])
- {
- polys[npolys*nvp+0] = (unsigned short)indices[t[0]];
- polys[npolys*nvp+1] = (unsigned short)indices[t[1]];
- polys[npolys*nvp+2] = (unsigned short)indices[t[2]];
- npolys++;
- }
- }
- if (!npolys)
- continue;
-
- // Merge polygons.
- if (nvp > 3)
- {
- for(;;)
- {
- // Find best polygons to merge.
- int bestMergeVal = 0;
- int bestPa = 0, bestPb = 0, bestEa = 0, bestEb = 0;
-
- for (int j = 0; j < npolys-1; ++j)
- {
- unsigned short* pj = &polys[j*nvp];
- for (int k = j+1; k < npolys; ++k)
- {
- unsigned short* pk = &polys[k*nvp];
- int ea, eb;
- int v = getPolyMergeValue(pj, pk, mesh.verts, ea, eb, nvp);
- if (v > bestMergeVal)
- {
- bestMergeVal = v;
- bestPa = j;
- bestPb = k;
- bestEa = ea;
- bestEb = eb;
- }
- }
- }
-
- if (bestMergeVal > 0)
- {
- // Found best, merge.
- unsigned short* pa = &polys[bestPa*nvp];
- unsigned short* pb = &polys[bestPb*nvp];
- mergePolyVerts(pa, pb, bestEa, bestEb, tmpPoly, nvp);
- unsigned short* lastPoly = &polys[(npolys-1)*nvp];
- if (pb != lastPoly)
- memcpy(pb, lastPoly, sizeof(unsigned short)*nvp);
- npolys--;
- }
- else
- {
- // Could not merge any polygons, stop.
- break;
- }
- }
- }
-
- // Store polygons.
- for (int j = 0; j < npolys; ++j)
- {
- unsigned short* p = &mesh.polys[mesh.npolys*nvp*2];
- unsigned short* q = &polys[j*nvp];
- for (int k = 0; k < nvp; ++k)
- p[k] = q[k];
- mesh.regs[mesh.npolys] = cont.reg;
- mesh.areas[mesh.npolys] = cont.area;
- mesh.npolys++;
- if (mesh.npolys > maxTris)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Too many polygons %d (max:%d).", mesh.npolys, maxTris);
- return false;
- }
- }
- }
-
-
- // Remove edge vertices.
- for (int i = 0; i < mesh.nverts; ++i)
- {
- if (vflags[i])
- {
- if (!canRemoveVertex(ctx, mesh, (unsigned short)i))
- continue;
- if (!removeVertex(ctx, mesh, (unsigned short)i, maxTris))
- {
- // Failed to remove vertex
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Failed to remove edge vertex %d.", i);
- return false;
- }
- // Remove vertex
- // Note: mesh.nverts is already decremented inside removeVertex()!
- // Fixup vertex flags
- for (int j = i; j < mesh.nverts; ++j)
- vflags[j] = vflags[j+1];
- --i;
- }
- }
-
- // Calculate adjacency.
- if (!buildMeshAdjacency(mesh.polys, mesh.npolys, mesh.nverts, nvp))
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Adjacency failed.");
- return false;
- }
-
- // Find portal edges
- if (mesh.borderSize > 0)
- {
- const int w = cset.width;
- const int h = cset.height;
- for (int i = 0; i < mesh.npolys; ++i)
- {
- unsigned short* p = &mesh.polys[i*2*nvp];
- for (int j = 0; j < nvp; ++j)
- {
- if (p[j] == RC_MESH_NULL_IDX) break;
- // Skip connected edges.
- if (p[nvp+j] != RC_MESH_NULL_IDX)
- continue;
- int nj = j+1;
- if (nj >= nvp || p[nj] == RC_MESH_NULL_IDX) nj = 0;
- const unsigned short* va = &mesh.verts[p[j]*3];
- const unsigned short* vb = &mesh.verts[p[nj]*3];
-
- if ((int)va[0] == 0 && (int)vb[0] == 0)
- p[nvp+j] = 0x8000 | 0;
- else if ((int)va[2] == h && (int)vb[2] == h)
- p[nvp+j] = 0x8000 | 1;
- else if ((int)va[0] == w && (int)vb[0] == w)
- p[nvp+j] = 0x8000 | 2;
- else if ((int)va[2] == 0 && (int)vb[2] == 0)
- p[nvp+j] = 0x8000 | 3;
- }
- }
- }
-
- // Just allocate the mesh flags array. The user is resposible to fill it.
- mesh.flags = (unsigned short*)rcAlloc(sizeof(unsigned short)*mesh.npolys, RC_ALLOC_PERM);
- if (!mesh.flags)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.flags' (%d).", mesh.npolys);
- return false;
- }
- memset(mesh.flags, 0, sizeof(unsigned short) * mesh.npolys);
-
- if (mesh.nverts > 0xffff)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: The resulting mesh has too many vertices %d (max %d). Data can be corrupted.", mesh.nverts, 0xffff);
- }
- if (mesh.npolys > 0xffff)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: The resulting mesh has too many polygons %d (max %d). Data can be corrupted.", mesh.npolys, 0xffff);
- }
-
- return true;
-}
-
-/// @see rcAllocPolyMesh, rcPolyMesh
-bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, rcPolyMesh& mesh)
-{
- rcAssert(ctx);
-
- if (!nmeshes || !meshes)
- return true;
-
- rcScopedTimer timer(ctx, RC_TIMER_MERGE_POLYMESH);
-
- mesh.nvp = meshes[0]->nvp;
- mesh.cs = meshes[0]->cs;
- mesh.ch = meshes[0]->ch;
- rcVcopy(mesh.bmin, meshes[0]->bmin);
- rcVcopy(mesh.bmax, meshes[0]->bmax);
-
- int maxVerts = 0;
- int maxPolys = 0;
- int maxVertsPerMesh = 0;
- for (int i = 0; i < nmeshes; ++i)
- {
- rcVmin(mesh.bmin, meshes[i]->bmin);
- rcVmax(mesh.bmax, meshes[i]->bmax);
- maxVertsPerMesh = rcMax(maxVertsPerMesh, meshes[i]->nverts);
- maxVerts += meshes[i]->nverts;
- maxPolys += meshes[i]->npolys;
- }
-
- mesh.nverts = 0;
- mesh.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxVerts*3, RC_ALLOC_PERM);
- if (!mesh.verts)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.verts' (%d).", maxVerts*3);
- return false;
- }
-
- mesh.npolys = 0;
- mesh.polys = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxPolys*2*mesh.nvp, RC_ALLOC_PERM);
- if (!mesh.polys)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.polys' (%d).", maxPolys*2*mesh.nvp);
- return false;
- }
- memset(mesh.polys, 0xff, sizeof(unsigned short)*maxPolys*2*mesh.nvp);
-
- mesh.regs = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxPolys, RC_ALLOC_PERM);
- if (!mesh.regs)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.regs' (%d).", maxPolys);
- return false;
- }
- memset(mesh.regs, 0, sizeof(unsigned short)*maxPolys);
-
- mesh.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*maxPolys, RC_ALLOC_PERM);
- if (!mesh.areas)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.areas' (%d).", maxPolys);
- return false;
- }
- memset(mesh.areas, 0, sizeof(unsigned char)*maxPolys);
-
- mesh.flags = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxPolys, RC_ALLOC_PERM);
- if (!mesh.flags)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.flags' (%d).", maxPolys);
- return false;
- }
- memset(mesh.flags, 0, sizeof(unsigned short)*maxPolys);
-
- rcScopedDelete<int> nextVert((int*)rcAlloc(sizeof(int)*maxVerts, RC_ALLOC_TEMP));
- if (!nextVert)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'nextVert' (%d).", maxVerts);
- return false;
- }
- memset(nextVert, 0, sizeof(int)*maxVerts);
-
- rcScopedDelete<int> firstVert((int*)rcAlloc(sizeof(int)*VERTEX_BUCKET_COUNT, RC_ALLOC_TEMP));
- if (!firstVert)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'firstVert' (%d).", VERTEX_BUCKET_COUNT);
- return false;
- }
- for (int i = 0; i < VERTEX_BUCKET_COUNT; ++i)
- firstVert[i] = -1;
-
- rcScopedDelete<unsigned short> vremap((unsigned short*)rcAlloc(sizeof(unsigned short)*maxVertsPerMesh, RC_ALLOC_PERM));
- if (!vremap)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'vremap' (%d).", maxVertsPerMesh);
- return false;
- }
- memset(vremap, 0, sizeof(unsigned short)*maxVertsPerMesh);
-
- for (int i = 0; i < nmeshes; ++i)
- {
- const rcPolyMesh* pmesh = meshes[i];
-
- const unsigned short ox = (unsigned short)floorf((pmesh->bmin[0]-mesh.bmin[0])/mesh.cs+0.5f);
- const unsigned short oz = (unsigned short)floorf((pmesh->bmin[2]-mesh.bmin[2])/mesh.cs+0.5f);
-
- bool isMinX = (ox == 0);
- bool isMinZ = (oz == 0);
- bool isMaxX = ((unsigned short)floorf((mesh.bmax[0] - pmesh->bmax[0]) / mesh.cs + 0.5f)) == 0;
- bool isMaxZ = ((unsigned short)floorf((mesh.bmax[2] - pmesh->bmax[2]) / mesh.cs + 0.5f)) == 0;
- bool isOnBorder = (isMinX || isMinZ || isMaxX || isMaxZ);
-
- for (int j = 0; j < pmesh->nverts; ++j)
- {
- unsigned short* v = &pmesh->verts[j*3];
- vremap[j] = addVertex(v[0]+ox, v[1], v[2]+oz,
- mesh.verts, firstVert, nextVert, mesh.nverts);
- }
-
- for (int j = 0; j < pmesh->npolys; ++j)
- {
- unsigned short* tgt = &mesh.polys[mesh.npolys*2*mesh.nvp];
- unsigned short* src = &pmesh->polys[j*2*mesh.nvp];
- mesh.regs[mesh.npolys] = pmesh->regs[j];
- mesh.areas[mesh.npolys] = pmesh->areas[j];
- mesh.flags[mesh.npolys] = pmesh->flags[j];
- mesh.npolys++;
- for (int k = 0; k < mesh.nvp; ++k)
- {
- if (src[k] == RC_MESH_NULL_IDX) break;
- tgt[k] = vremap[src[k]];
- }
-
- if (isOnBorder)
- {
- for (int k = mesh.nvp; k < mesh.nvp * 2; ++k)
- {
- if (src[k] & 0x8000 && src[k] != 0xffff)
- {
- unsigned short dir = src[k] & 0xf;
- switch (dir)
- {
- case 0: // Portal x-
- if (isMinX)
- tgt[k] = src[k];
- break;
- case 1: // Portal z+
- if (isMaxZ)
- tgt[k] = src[k];
- break;
- case 2: // Portal x+
- if (isMaxX)
- tgt[k] = src[k];
- break;
- case 3: // Portal z-
- if (isMinZ)
- tgt[k] = src[k];
- break;
- }
- }
- }
- }
- }
- }
-
- // Calculate adjacency.
- if (!buildMeshAdjacency(mesh.polys, mesh.npolys, mesh.nverts, mesh.nvp))
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Adjacency failed.");
- return false;
- }
-
- if (mesh.nverts > 0xffff)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: The resulting mesh has too many vertices %d (max %d). Data can be corrupted.", mesh.nverts, 0xffff);
- }
- if (mesh.npolys > 0xffff)
- {
- ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: The resulting mesh has too many polygons %d (max %d). Data can be corrupted.", mesh.npolys, 0xffff);
- }
-
- return true;
-}
-
-bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst)
-{
- rcAssert(ctx);
-
- // Destination must be empty.
- rcAssert(dst.verts == 0);
- rcAssert(dst.polys == 0);
- rcAssert(dst.regs == 0);
- rcAssert(dst.areas == 0);
- rcAssert(dst.flags == 0);
-
- dst.nverts = src.nverts;
- dst.npolys = src.npolys;
- dst.maxpolys = src.npolys;
- dst.nvp = src.nvp;
- rcVcopy(dst.bmin, src.bmin);
- rcVcopy(dst.bmax, src.bmax);
- dst.cs = src.cs;
- dst.ch = src.ch;
- dst.borderSize = src.borderSize;
- dst.maxEdgeError = src.maxEdgeError;
-
- dst.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.nverts*3, RC_ALLOC_PERM);
- if (!dst.verts)
- {
- ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.verts' (%d).", src.nverts*3);
- return false;
- }
- memcpy(dst.verts, src.verts, sizeof(unsigned short)*src.nverts*3);
-
- dst.polys = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.npolys*2*src.nvp, RC_ALLOC_PERM);
- if (!dst.polys)
- {
- ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.polys' (%d).", src.npolys*2*src.nvp);
- return false;
- }
- memcpy(dst.polys, src.polys, sizeof(unsigned short)*src.npolys*2*src.nvp);
-
- dst.regs = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.npolys, RC_ALLOC_PERM);
- if (!dst.regs)
- {
- ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.regs' (%d).", src.npolys);
- return false;
- }
- memcpy(dst.regs, src.regs, sizeof(unsigned short)*src.npolys);
-
- dst.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*src.npolys, RC_ALLOC_PERM);
- if (!dst.areas)
- {
- ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.areas' (%d).", src.npolys);
- return false;
- }
- memcpy(dst.areas, src.areas, sizeof(unsigned char)*src.npolys);
-
- dst.flags = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.npolys, RC_ALLOC_PERM);
- if (!dst.flags)
- {
- ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.flags' (%d).", src.npolys);
- return false;
- }
- memcpy(dst.flags, src.flags, sizeof(unsigned short)*src.npolys);
-
- return true;
-}
diff --git a/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp b/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp
deleted file mode 100644
index f1270cf2027..00000000000
--- a/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp
+++ /dev/null
@@ -1,1463 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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 <float.h>
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "Recast.h"
-#include "RecastAlloc.h"
-#include "RecastAssert.h"
-
-
-static const unsigned RC_UNSET_HEIGHT = 0xffff;
-
-struct rcHeightPatch
-{
- inline rcHeightPatch() : data(0), xmin(0), ymin(0), width(0), height(0) {}
- inline ~rcHeightPatch() { rcFree(data); }
- unsigned short* data;
- int xmin, ymin, width, height;
-};
-
-
-inline float vdot2(const float* a, const float* b)
-{
- return a[0]*b[0] + a[2]*b[2];
-}
-
-inline float vdistSq2(const float* p, const float* q)
-{
- const float dx = q[0] - p[0];
- const float dy = q[2] - p[2];
- return dx*dx + dy*dy;
-}
-
-inline float vdist2(const float* p, const float* q)
-{
- return sqrtf(vdistSq2(p,q));
-}
-
-inline float vcross2(const float* p1, const float* p2, const float* p3)
-{
- const float u1 = p2[0] - p1[0];
- const float v1 = p2[2] - p1[2];
- const float u2 = p3[0] - p1[0];
- const float v2 = p3[2] - p1[2];
- return u1 * v2 - v1 * u2;
-}
-
-static bool circumCircle(const float* p1, const float* p2, const float* p3,
- float* c, float& r)
-{
- static const float EPS = 1e-6f;
- // Calculate the circle relative to p1, to avoid some precision issues.
- const float v1[3] = {0,0,0};
- float v2[3], v3[3];
- rcVsub(v2, p2,p1);
- rcVsub(v3, p3,p1);
-
- const float cp = vcross2(v1, v2, v3);
- if (fabsf(cp) > EPS)
- {
- const float v1Sq = vdot2(v1,v1);
- const float v2Sq = vdot2(v2,v2);
- const float v3Sq = vdot2(v3,v3);
- c[0] = (v1Sq*(v2[2]-v3[2]) + v2Sq*(v3[2]-v1[2]) + v3Sq*(v1[2]-v2[2])) / (2*cp);
- c[1] = 0;
- c[2] = (v1Sq*(v3[0]-v2[0]) + v2Sq*(v1[0]-v3[0]) + v3Sq*(v2[0]-v1[0])) / (2*cp);
- r = vdist2(c, v1);
- rcVadd(c, c, p1);
- return true;
- }
-
- rcVcopy(c, p1);
- r = 0;
- return false;
-}
-
-static float distPtTri(const float* p, const float* a, const float* b, const float* c)
-{
- float v0[3], v1[3], v2[3];
- rcVsub(v0, c,a);
- rcVsub(v1, b,a);
- rcVsub(v2, p,a);
-
- const float dot00 = vdot2(v0, v0);
- const float dot01 = vdot2(v0, v1);
- const float dot02 = vdot2(v0, v2);
- const float dot11 = vdot2(v1, v1);
- const float dot12 = vdot2(v1, v2);
-
- // Compute barycentric coordinates
- const float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01);
- const float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
- float v = (dot00 * dot12 - dot01 * dot02) * invDenom;
-
- // If point lies inside the triangle, return interpolated y-coord.
- static const float EPS = 1e-4f;
- if (u >= -EPS && v >= -EPS && (u+v) <= 1+EPS)
- {
- const float y = a[1] + v0[1]*u + v1[1]*v;
- return fabsf(y-p[1]);
- }
- return FLT_MAX;
-}
-
-static float distancePtSeg(const float* pt, const float* p, const float* q)
-{
- float pqx = q[0] - p[0];
- float pqy = q[1] - p[1];
- float pqz = q[2] - p[2];
- float dx = pt[0] - p[0];
- float dy = pt[1] - p[1];
- float dz = pt[2] - p[2];
- float d = pqx*pqx + pqy*pqy + pqz*pqz;
- float t = pqx*dx + pqy*dy + pqz*dz;
- if (d > 0)
- t /= d;
- if (t < 0)
- t = 0;
- else if (t > 1)
- t = 1;
-
- dx = p[0] + t*pqx - pt[0];
- dy = p[1] + t*pqy - pt[1];
- dz = p[2] + t*pqz - pt[2];
-
- return dx*dx + dy*dy + dz*dz;
-}
-
-static float distancePtSeg2d(const float* pt, const float* p, const float* q)
-{
- float pqx = q[0] - p[0];
- float pqz = q[2] - p[2];
- float dx = pt[0] - p[0];
- float dz = pt[2] - p[2];
- float d = pqx*pqx + pqz*pqz;
- float t = pqx*dx + pqz*dz;
- if (d > 0)
- t /= d;
- if (t < 0)
- t = 0;
- else if (t > 1)
- t = 1;
-
- dx = p[0] + t*pqx - pt[0];
- dz = p[2] + t*pqz - pt[2];
-
- return dx*dx + dz*dz;
-}
-
-static float distToTriMesh(const float* p, const float* verts, const int /*nverts*/, const int* tris, const int ntris)
-{
- float dmin = FLT_MAX;
- for (int i = 0; i < ntris; ++i)
- {
- const float* va = &verts[tris[i*4+0]*3];
- const float* vb = &verts[tris[i*4+1]*3];
- const float* vc = &verts[tris[i*4+2]*3];
- float d = distPtTri(p, va,vb,vc);
- if (d < dmin)
- dmin = d;
- }
- if (dmin == FLT_MAX) return -1;
- return dmin;
-}
-
-static float distToPoly(int nvert, const float* verts, const float* p)
-{
-
- float dmin = FLT_MAX;
- int i, j, c = 0;
- for (i = 0, j = nvert-1; i < nvert; j = i++)
- {
- const float* vi = &verts[i*3];
- const float* vj = &verts[j*3];
- if (((vi[2] > p[2]) != (vj[2] > p[2])) &&
- (p[0] < (vj[0]-vi[0]) * (p[2]-vi[2]) / (vj[2]-vi[2]) + vi[0]) )
- c = !c;
- dmin = rcMin(dmin, distancePtSeg2d(p, vj, vi));
- }
- return c ? -dmin : dmin;
-}
-
-
-static unsigned short getHeight(const float fx, const float fy, const float fz,
- const float /*cs*/, const float ics, const float ch,
- const int radius, const rcHeightPatch& hp)
-{
- int ix = (int)floorf(fx*ics + 0.01f);
- int iz = (int)floorf(fz*ics + 0.01f);
- ix = rcClamp(ix-hp.xmin, 0, hp.width - 1);
- iz = rcClamp(iz-hp.ymin, 0, hp.height - 1);
- unsigned short h = hp.data[ix+iz*hp.width];
- if (h == RC_UNSET_HEIGHT)
- {
- // Special case when data might be bad.
- // Walk adjacent cells in a spiral up to 'radius', and look
- // for a pixel which has a valid height.
- int x = 1, z = 0, dx = 1, dz = 0;
- int maxSize = radius * 2 + 1;
- int maxIter = maxSize * maxSize - 1;
-
- int nextRingIterStart = 8;
- int nextRingIters = 16;
-
- float dmin = FLT_MAX;
- for (int i = 0; i < maxIter; i++)
- {
- const int nx = ix + x;
- const int nz = iz + z;
-
- if (nx >= 0 && nz >= 0 && nx < hp.width && nz < hp.height)
- {
- const unsigned short nh = hp.data[nx + nz*hp.width];
- if (nh != RC_UNSET_HEIGHT)
- {
- const float d = fabsf(nh*ch - fy);
- if (d < dmin)
- {
- h = nh;
- dmin = d;
- }
- }
- }
-
- // We are searching in a grid which looks approximately like this:
- // __________
- // |2 ______ 2|
- // | |1 __ 1| |
- // | | |__| | |
- // | |______| |
- // |__________|
- // We want to find the best height as close to the center cell as possible. This means that
- // if we find a height in one of the neighbor cells to the center, we don't want to
- // expand further out than the 8 neighbors - we want to limit our search to the closest
- // of these "rings", but the best height in the ring.
- // For example, the center is just 1 cell. We checked that at the entrance to the function.
- // The next "ring" contains 8 cells (marked 1 above). Those are all the neighbors to the center cell.
- // The next one again contains 16 cells (marked 2). In general each ring has 8 additional cells, which
- // can be thought of as adding 2 cells around the "center" of each side when we expand the ring.
- // Here we detect if we are about to enter the next ring, and if we are and we have found
- // a height, we abort the search.
- if (i + 1 == nextRingIterStart)
- {
- if (h != RC_UNSET_HEIGHT)
- break;
-
- nextRingIterStart += nextRingIters;
- nextRingIters += 8;
- }
-
- if ((x == z) || ((x < 0) && (x == -z)) || ((x > 0) && (x == 1 - z)))
- {
- int tmp = dx;
- dx = -dz;
- dz = tmp;
- }
- x += dx;
- z += dz;
- }
- }
- return h;
-}
-
-
-enum EdgeValues
-{
- EV_UNDEF = -1,
- EV_HULL = -2,
-};
-
-static int findEdge(const int* edges, int nedges, int s, int t)
-{
- for (int i = 0; i < nedges; i++)
- {
- const int* e = &edges[i*4];
- if ((e[0] == s && e[1] == t) || (e[0] == t && e[1] == s))
- return i;
- }
- return EV_UNDEF;
-}
-
-static int addEdge(rcContext* ctx, int* edges, int& nedges, const int maxEdges, int s, int t, int l, int r)
-{
- if (nedges >= maxEdges)
- {
- ctx->log(RC_LOG_ERROR, "addEdge: Too many edges (%d/%d).", nedges, maxEdges);
- return EV_UNDEF;
- }
-
- // Add edge if not already in the triangulation.
- int e = findEdge(edges, nedges, s, t);
- if (e == EV_UNDEF)
- {
- int* edge = &edges[nedges*4];
- edge[0] = s;
- edge[1] = t;
- edge[2] = l;
- edge[3] = r;
- return nedges++;
- }
- else
- {
- return EV_UNDEF;
- }
-}
-
-static void updateLeftFace(int* e, int s, int t, int f)
-{
- if (e[0] == s && e[1] == t && e[2] == EV_UNDEF)
- e[2] = f;
- else if (e[1] == s && e[0] == t && e[3] == EV_UNDEF)
- e[3] = f;
-}
-
-static int overlapSegSeg2d(const float* a, const float* b, const float* c, const float* d)
-{
- const float a1 = vcross2(a, b, d);
- const float a2 = vcross2(a, b, c);
- if (a1*a2 < 0.0f)
- {
- float a3 = vcross2(c, d, a);
- float a4 = a3 + a2 - a1;
- if (a3 * a4 < 0.0f)
- return 1;
- }
- return 0;
-}
-
-static bool overlapEdges(const float* pts, const int* edges, int nedges, int s1, int t1)
-{
- for (int i = 0; i < nedges; ++i)
- {
- const int s0 = edges[i*4+0];
- const int t0 = edges[i*4+1];
- // Same or connected edges do not overlap.
- if (s0 == s1 || s0 == t1 || t0 == s1 || t0 == t1)
- continue;
- if (overlapSegSeg2d(&pts[s0*3],&pts[t0*3], &pts[s1*3],&pts[t1*3]))
- return true;
- }
- return false;
-}
-
-static void completeFacet(rcContext* ctx, const float* pts, int npts, int* edges, int& nedges, const int maxEdges, int& nfaces, int e)
-{
- static const float EPS = 1e-5f;
-
- int* edge = &edges[e*4];
-
- // Cache s and t.
- int s,t;
- if (edge[2] == EV_UNDEF)
- {
- s = edge[0];
- t = edge[1];
- }
- else if (edge[3] == EV_UNDEF)
- {
- s = edge[1];
- t = edge[0];
- }
- else
- {
- // Edge already completed.
- return;
- }
-
- // Find best point on left of edge.
- int pt = npts;
- float c[3] = {0,0,0};
- float r = -1;
- for (int u = 0; u < npts; ++u)
- {
- if (u == s || u == t) continue;
- if (vcross2(&pts[s*3], &pts[t*3], &pts[u*3]) > EPS)
- {
- if (r < 0)
- {
- // The circle is not updated yet, do it now.
- pt = u;
- circumCircle(&pts[s*3], &pts[t*3], &pts[u*3], c, r);
- continue;
- }
- const float d = vdist2(c, &pts[u*3]);
- const float tol = 0.001f;
- if (d > r*(1+tol))
- {
- // Outside current circumcircle, skip.
- continue;
- }
- else if (d < r*(1-tol))
- {
- // Inside safe circumcircle, update circle.
- pt = u;
- circumCircle(&pts[s*3], &pts[t*3], &pts[u*3], c, r);
- }
- else
- {
- // Inside epsilon circum circle, do extra tests to make sure the edge is valid.
- // s-u and t-u cannot overlap with s-pt nor t-pt if they exists.
- if (overlapEdges(pts, edges, nedges, s,u))
- continue;
- if (overlapEdges(pts, edges, nedges, t,u))
- continue;
- // Edge is valid.
- pt = u;
- circumCircle(&pts[s*3], &pts[t*3], &pts[u*3], c, r);
- }
- }
- }
-
- // Add new triangle or update edge info if s-t is on hull.
- if (pt < npts)
- {
- // Update face information of edge being completed.
- updateLeftFace(&edges[e*4], s, t, nfaces);
-
- // Add new edge or update face info of old edge.
- e = findEdge(edges, nedges, pt, s);
- if (e == EV_UNDEF)
- addEdge(ctx, edges, nedges, maxEdges, pt, s, nfaces, EV_UNDEF);
- else
- updateLeftFace(&edges[e*4], pt, s, nfaces);
-
- // Add new edge or update face info of old edge.
- e = findEdge(edges, nedges, t, pt);
- if (e == EV_UNDEF)
- addEdge(ctx, edges, nedges, maxEdges, t, pt, nfaces, EV_UNDEF);
- else
- updateLeftFace(&edges[e*4], t, pt, nfaces);
-
- nfaces++;
- }
- else
- {
- updateLeftFace(&edges[e*4], s, t, EV_HULL);
- }
-}
-
-static void delaunayHull(rcContext* ctx, const int npts, const float* pts,
- const int nhull, const int* hull,
- rcIntArray& tris, rcIntArray& edges)
-{
- int nfaces = 0;
- int nedges = 0;
- const int maxEdges = npts*10;
- edges.resize(maxEdges*4);
-
- for (int i = 0, j = nhull-1; i < nhull; j=i++)
- addEdge(ctx, &edges[0], nedges, maxEdges, hull[j],hull[i], EV_HULL, EV_UNDEF);
-
- int currentEdge = 0;
- while (currentEdge < nedges)
- {
- if (edges[currentEdge*4+2] == EV_UNDEF)
- completeFacet(ctx, pts, npts, &edges[0], nedges, maxEdges, nfaces, currentEdge);
- if (edges[currentEdge*4+3] == EV_UNDEF)
- completeFacet(ctx, pts, npts, &edges[0], nedges, maxEdges, nfaces, currentEdge);
- currentEdge++;
- }
-
- // Create tris
- tris.resize(nfaces*4);
- for (int i = 0; i < nfaces*4; ++i)
- tris[i] = -1;
-
- for (int i = 0; i < nedges; ++i)
- {
- const int* e = &edges[i*4];
- if (e[3] >= 0)
- {
- // Left face
- int* t = &tris[e[3]*4];
- if (t[0] == -1)
- {
- t[0] = e[0];
- t[1] = e[1];
- }
- else if (t[0] == e[1])
- t[2] = e[0];
- else if (t[1] == e[0])
- t[2] = e[1];
- }
- if (e[2] >= 0)
- {
- // Right
- int* t = &tris[e[2]*4];
- if (t[0] == -1)
- {
- t[0] = e[1];
- t[1] = e[0];
- }
- else if (t[0] == e[0])
- t[2] = e[1];
- else if (t[1] == e[1])
- t[2] = e[0];
- }
- }
-
- for (int i = 0; i < tris.size()/4; ++i)
- {
- int* t = &tris[i*4];
- if (t[0] == -1 || t[1] == -1 || t[2] == -1)
- {
- ctx->log(RC_LOG_WARNING, "delaunayHull: Removing dangling face %d [%d,%d,%d].", i, t[0],t[1],t[2]);
- t[0] = tris[tris.size()-4];
- t[1] = tris[tris.size()-3];
- t[2] = tris[tris.size()-2];
- t[3] = tris[tris.size()-1];
- tris.resize(tris.size()-4);
- --i;
- }
- }
-}
-
-// Calculate minimum extend of the polygon.
-static float polyMinExtent(const float* verts, const int nverts)
-{
- float minDist = FLT_MAX;
- for (int i = 0; i < nverts; i++)
- {
- const int ni = (i+1) % nverts;
- const float* p1 = &verts[i*3];
- const float* p2 = &verts[ni*3];
- float maxEdgeDist = 0;
- for (int j = 0; j < nverts; j++)
- {
- if (j == i || j == ni) continue;
- float d = distancePtSeg2d(&verts[j*3], p1,p2);
- maxEdgeDist = rcMax(maxEdgeDist, d);
- }
- minDist = rcMin(minDist, maxEdgeDist);
- }
- return rcSqrt(minDist);
-}
-
-// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).
-inline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }
-inline int next(int i, int n) { return i+1 < n ? i+1 : 0; }
-
-static void triangulateHull(const int /*nverts*/, const float* verts, const int nhull, const int* hull, rcIntArray& tris)
-{
- int start = 0, left = 1, right = nhull-1;
-
- // Start from an ear with shortest perimeter.
- // This tends to favor well formed triangles as starting point.
- float dmin = 0;
- for (int i = 0; i < nhull; i++)
- {
- int pi = prev(i, nhull);
- int ni = next(i, nhull);
- const float* pv = &verts[hull[pi]*3];
- const float* cv = &verts[hull[i]*3];
- const float* nv = &verts[hull[ni]*3];
- const float d = vdist2(pv,cv) + vdist2(cv,nv) + vdist2(nv,pv);
- if (d < dmin)
- {
- start = i;
- left = ni;
- right = pi;
- dmin = d;
- }
- }
-
- // Add first triangle
- tris.push(hull[start]);
- tris.push(hull[left]);
- tris.push(hull[right]);
- tris.push(0);
-
- // Triangulate the polygon by moving left or right,
- // depending on which triangle has shorter perimeter.
- // This heuristic was chose emprically, since it seems
- // handle tesselated straight edges well.
- while (next(left, nhull) != right)
- {
- // Check to see if se should advance left or right.
- int nleft = next(left, nhull);
- int nright = prev(right, nhull);
-
- const float* cvleft = &verts[hull[left]*3];
- const float* nvleft = &verts[hull[nleft]*3];
- const float* cvright = &verts[hull[right]*3];
- const float* nvright = &verts[hull[nright]*3];
- const float dleft = vdist2(cvleft, nvleft) + vdist2(nvleft, cvright);
- const float dright = vdist2(cvright, nvright) + vdist2(cvleft, nvright);
-
- if (dleft < dright)
- {
- tris.push(hull[left]);
- tris.push(hull[nleft]);
- tris.push(hull[right]);
- tris.push(0);
- left = nleft;
- }
- else
- {
- tris.push(hull[left]);
- tris.push(hull[nright]);
- tris.push(hull[right]);
- tris.push(0);
- right = nright;
- }
- }
-}
-
-
-inline float getJitterX(const int i)
-{
- return (((i * 0x8da6b343) & 0xffff) / 65535.0f * 2.0f) - 1.0f;
-}
-
-inline float getJitterY(const int i)
-{
- return (((i * 0xd8163841) & 0xffff) / 65535.0f * 2.0f) - 1.0f;
-}
-
-static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
- const float sampleDist, const float sampleMaxError,
- const int heightSearchRadius, const rcCompactHeightfield& chf,
- const rcHeightPatch& hp, float* verts, int& nverts,
- rcIntArray& tris, rcIntArray& edges, rcIntArray& samples)
-{
- static const int MAX_VERTS = 127;
- static const int MAX_TRIS = 255; // Max tris for delaunay is 2n-2-k (n=num verts, k=num hull verts).
- static const int MAX_VERTS_PER_EDGE = 32;
- float edge[(MAX_VERTS_PER_EDGE+1)*3];
- int hull[MAX_VERTS];
- int nhull = 0;
-
- nverts = 0;
-
- for (int i = 0; i < nin; ++i)
- rcVcopy(&verts[i*3], &in[i*3]);
- nverts = nin;
-
- edges.resize(0);
- tris.resize(0);
-
- const float cs = chf.cs;
- const float ics = 1.0f/cs;
-
- // Calculate minimum extents of the polygon based on input data.
- float minExtent = polyMinExtent(verts, nverts);
-
- // Tessellate outlines.
- // This is done in separate pass in order to ensure
- // seamless height values across the ply boundaries.
- if (sampleDist > 0)
- {
- for (int i = 0, j = nin-1; i < nin; j=i++)
- {
- const float* vj = &in[j*3];
- const float* vi = &in[i*3];
- bool swapped = false;
- // Make sure the segments are always handled in same order
- // using lexological sort or else there will be seams.
- if (fabsf(vj[0]-vi[0]) < 1e-6f)
- {
- if (vj[2] > vi[2])
- {
- rcSwap(vj,vi);
- swapped = true;
- }
- }
- else
- {
- if (vj[0] > vi[0])
- {
- rcSwap(vj,vi);
- swapped = true;
- }
- }
- // Create samples along the edge.
- float dx = vi[0] - vj[0];
- float dy = vi[1] - vj[1];
- float dz = vi[2] - vj[2];
- float d = sqrtf(dx*dx + dz*dz);
- int nn = 1 + (int)floorf(d/sampleDist);
- if (nn >= MAX_VERTS_PER_EDGE) nn = MAX_VERTS_PER_EDGE-1;
- if (nverts+nn >= MAX_VERTS)
- nn = MAX_VERTS-1-nverts;
-
- for (int k = 0; k <= nn; ++k)
- {
- float u = (float)k/(float)nn;
- float* pos = &edge[k*3];
- pos[0] = vj[0] + dx*u;
- pos[1] = vj[1] + dy*u;
- pos[2] = vj[2] + dz*u;
- pos[1] = getHeight(pos[0],pos[1],pos[2], cs, ics, chf.ch, heightSearchRadius, hp)*chf.ch;
- }
- // Simplify samples.
- int idx[MAX_VERTS_PER_EDGE] = {0,nn};
- int nidx = 2;
- for (int k = 0; k < nidx-1; )
- {
- const int a = idx[k];
- const int b = idx[k+1];
- const float* va = &edge[a*3];
- const float* vb = &edge[b*3];
- // Find maximum deviation along the segment.
- float maxd = 0;
- int maxi = -1;
- for (int m = a+1; m < b; ++m)
- {
- float dev = distancePtSeg(&edge[m*3],va,vb);
- if (dev > maxd)
- {
- maxd = dev;
- maxi = m;
- }
- }
- // If the max deviation is larger than accepted error,
- // add new point, else continue to next segment.
- if (maxi != -1 && maxd > rcSqr(sampleMaxError))
- {
- for (int m = nidx; m > k; --m)
- idx[m] = idx[m-1];
- idx[k+1] = maxi;
- nidx++;
- }
- else
- {
- ++k;
- }
- }
-
- hull[nhull++] = j;
- // Add new vertices.
- if (swapped)
- {
- for (int k = nidx-2; k > 0; --k)
- {
- rcVcopy(&verts[nverts*3], &edge[idx[k]*3]);
- hull[nhull++] = nverts;
- nverts++;
- }
- }
- else
- {
- for (int k = 1; k < nidx-1; ++k)
- {
- rcVcopy(&verts[nverts*3], &edge[idx[k]*3]);
- hull[nhull++] = nverts;
- nverts++;
- }
- }
- }
- }
-
- // If the polygon minimum extent is small (sliver or small triangle), do not try to add internal points.
- if (minExtent < sampleDist*2)
- {
- triangulateHull(nverts, verts, nhull, hull, tris);
- return true;
- }
-
- // Tessellate the base mesh.
- // We're using the triangulateHull instead of delaunayHull as it tends to
- // create a bit better triangulation for long thing triangles when there
- // are no internal points.
- triangulateHull(nverts, verts, nhull, hull, tris);
-
- if (tris.size() == 0)
- {
- // Could not triangulate the poly, make sure there is some valid data there.
- ctx->log(RC_LOG_WARNING, "buildPolyDetail: Could not triangulate polygon (%d verts).", nverts);
- return true;
- }
-
- if (sampleDist > 0)
- {
- // Create sample locations in a grid.
- float bmin[3], bmax[3];
- rcVcopy(bmin, in);
- rcVcopy(bmax, in);
- for (int i = 1; i < nin; ++i)
- {
- rcVmin(bmin, &in[i*3]);
- rcVmax(bmax, &in[i*3]);
- }
- int x0 = (int)floorf(bmin[0]/sampleDist);
- int x1 = (int)ceilf(bmax[0]/sampleDist);
- int z0 = (int)floorf(bmin[2]/sampleDist);
- int z1 = (int)ceilf(bmax[2]/sampleDist);
- samples.resize(0);
- for (int z = z0; z < z1; ++z)
- {
- for (int x = x0; x < x1; ++x)
- {
- float pt[3];
- pt[0] = x*sampleDist;
- pt[1] = (bmax[1]+bmin[1])*0.5f;
- pt[2] = z*sampleDist;
- // Make sure the samples are not too close to the edges.
- if (distToPoly(nin,in,pt) > -sampleDist/2) continue;
- samples.push(x);
- samples.push(getHeight(pt[0], pt[1], pt[2], cs, ics, chf.ch, heightSearchRadius, hp));
- samples.push(z);
- samples.push(0); // Not added
- }
- }
-
- // Add the samples starting from the one that has the most
- // error. The procedure stops when all samples are added
- // or when the max error is within treshold.
- const int nsamples = samples.size()/4;
- for (int iter = 0; iter < nsamples; ++iter)
- {
- if (nverts >= MAX_VERTS)
- break;
-
- // Find sample with most error.
- float bestpt[3] = {0,0,0};
- float bestd = 0;
- int besti = -1;
- for (int i = 0; i < nsamples; ++i)
- {
- const int* s = &samples[i*4];
- if (s[3]) continue; // skip added.
- float pt[3];
- // The sample location is jittered to get rid of some bad triangulations
- // which are cause by symmetrical data from the grid structure.
- pt[0] = s[0]*sampleDist + getJitterX(i)*cs*0.1f;
- pt[1] = s[1]*chf.ch;
- pt[2] = s[2]*sampleDist + getJitterY(i)*cs*0.1f;
- float d = distToTriMesh(pt, verts, nverts, &tris[0], tris.size()/4);
- if (d < 0) continue; // did not hit the mesh.
- if (d > bestd)
- {
- bestd = d;
- besti = i;
- rcVcopy(bestpt,pt);
- }
- }
- // If the max error is within accepted threshold, stop tesselating.
- if (bestd <= sampleMaxError || besti == -1)
- break;
- // Mark sample as added.
- samples[besti*4+3] = 1;
- // Add the new sample point.
- rcVcopy(&verts[nverts*3],bestpt);
- nverts++;
-
- // Create new triangulation.
- // TODO: Incremental add instead of full rebuild.
- edges.resize(0);
- tris.resize(0);
- delaunayHull(ctx, nverts, verts, nhull, hull, tris, edges);
- }
- }
-
- const int ntris = tris.size()/4;
- if (ntris > MAX_TRIS)
- {
- tris.resize(MAX_TRIS*4);
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Shrinking triangle count from %d to max %d.", ntris, MAX_TRIS);
- }
-
- return true;
-}
-
-static void seedArrayWithPolyCenter(rcContext* ctx, const rcCompactHeightfield& chf,
- const unsigned short* poly, const int npoly,
- const unsigned short* verts, const int bs,
- rcHeightPatch& hp, rcIntArray& array)
-{
- // Note: Reads to the compact heightfield are offset by border size (bs)
- // since border size offset is already removed from the polymesh vertices.
-
- static const int offset[9*2] =
- {
- 0,0, -1,-1, 0,-1, 1,-1, 1,0, 1,1, 0,1, -1,1, -1,0,
- };
-
- // Find cell closest to a poly vertex
- int startCellX = 0, startCellY = 0, startSpanIndex = -1;
- int dmin = RC_UNSET_HEIGHT;
- for (int j = 0; j < npoly && dmin > 0; ++j)
- {
- for (int k = 0; k < 9 && dmin > 0; ++k)
- {
- const int ax = (int)verts[poly[j]*3+0] + offset[k*2+0];
- const int ay = (int)verts[poly[j]*3+1];
- const int az = (int)verts[poly[j]*3+2] + offset[k*2+1];
- if (ax < hp.xmin || ax >= hp.xmin+hp.width ||
- az < hp.ymin || az >= hp.ymin+hp.height)
- continue;
-
- const rcCompactCell& c = chf.cells[(ax+bs)+(az+bs)*chf.width];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni && dmin > 0; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- int d = rcAbs(ay - (int)s.y);
- if (d < dmin)
- {
- startCellX = ax;
- startCellY = az;
- startSpanIndex = i;
- dmin = d;
- }
- }
- }
- }
-
- rcAssert(startSpanIndex != -1);
- // Find center of the polygon
- int pcx = 0, pcy = 0;
- for (int j = 0; j < npoly; ++j)
- {
- pcx += (int)verts[poly[j]*3+0];
- pcy += (int)verts[poly[j]*3+2];
- }
- pcx /= npoly;
- pcy /= npoly;
-
- // Use seeds array as a stack for DFS
- array.resize(0);
- array.push(startCellX);
- array.push(startCellY);
- array.push(startSpanIndex);
-
- int dirs[] = { 0, 1, 2, 3 };
- memset(hp.data, 0, sizeof(unsigned short)*hp.width*hp.height);
- // DFS to move to the center. Note that we need a DFS here and can not just move
- // directly towards the center without recording intermediate nodes, even though the polygons
- // are convex. In very rare we can get stuck due to contour simplification if we do not
- // record nodes.
- int cx = -1, cy = -1, ci = -1;
- while (true)
- {
- if (array.size() < 3)
- {
- ctx->log(RC_LOG_WARNING, "Walk towards polygon center failed to reach center");
- break;
- }
-
- ci = array.pop();
- cy = array.pop();
- cx = array.pop();
-
- if (cx == pcx && cy == pcy)
- break;
-
- // If we are already at the correct X-position, prefer direction
- // directly towards the center in the Y-axis; otherwise prefer
- // direction in the X-axis
- int directDir;
- if (cx == pcx)
- directDir = rcGetDirForOffset(0, pcy > cy ? 1 : -1);
- else
- directDir = rcGetDirForOffset(pcx > cx ? 1 : -1, 0);
-
- // Push the direct dir last so we start with this on next iteration
- rcSwap(dirs[directDir], dirs[3]);
-
- const rcCompactSpan& cs = chf.spans[ci];
- for (int i = 0; i < 4; i++)
- {
- int dir = dirs[i];
- if (rcGetCon(cs, dir) == RC_NOT_CONNECTED)
- continue;
-
- int newX = cx + rcGetDirOffsetX(dir);
- int newY = cy + rcGetDirOffsetY(dir);
-
- int hpx = newX - hp.xmin;
- int hpy = newY - hp.ymin;
- if (hpx < 0 || hpx >= hp.width || hpy < 0 || hpy >= hp.height)
- continue;
-
- if (hp.data[hpx+hpy*hp.width] != 0)
- continue;
-
- hp.data[hpx+hpy*hp.width] = 1;
- array.push(newX);
- array.push(newY);
- array.push((int)chf.cells[(newX+bs)+(newY+bs)*chf.width].index + rcGetCon(cs, dir));
- }
-
- rcSwap(dirs[directDir], dirs[3]);
- }
-
- array.resize(0);
- // getHeightData seeds are given in coordinates with borders
- array.push(cx+bs);
- array.push(cy+bs);
- array.push(ci);
-
- memset(hp.data, 0xff, sizeof(unsigned short)*hp.width*hp.height);
- const rcCompactSpan& cs = chf.spans[ci];
- hp.data[cx-hp.xmin+(cy-hp.ymin)*hp.width] = cs.y;
-}
-
-
-static void push3(rcIntArray& queue, int v1, int v2, int v3)
-{
- queue.resize(queue.size() + 3);
- queue[queue.size() - 3] = v1;
- queue[queue.size() - 2] = v2;
- queue[queue.size() - 1] = v3;
-}
-
-static void getHeightData(rcContext* ctx, const rcCompactHeightfield& chf,
- const unsigned short* poly, const int npoly,
- const unsigned short* verts, const int bs,
- rcHeightPatch& hp, rcIntArray& queue,
- int region)
-{
- // Note: Reads to the compact heightfield are offset by border size (bs)
- // since border size offset is already removed from the polymesh vertices.
-
- queue.resize(0);
- // Set all heights to RC_UNSET_HEIGHT.
- memset(hp.data, 0xff, sizeof(unsigned short)*hp.width*hp.height);
-
- bool empty = true;
-
- // We cannot sample from this poly if it was created from polys
- // of different regions. If it was then it could potentially be overlapping
- // with polys of that region and the heights sampled here could be wrong.
- if (region != RC_MULTIPLE_REGS)
- {
- // Copy the height from the same region, and mark region borders
- // as seed points to fill the rest.
- for (int hy = 0; hy < hp.height; hy++)
- {
- int y = hp.ymin + hy + bs;
- for (int hx = 0; hx < hp.width; hx++)
- {
- int x = hp.xmin + hx + bs;
- const rcCompactCell& c = chf.cells[x + y*chf.width];
- for (int i = (int)c.index, ni = (int)(c.index + c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- if (s.reg == region)
- {
- // Store height
- hp.data[hx + hy*hp.width] = s.y;
- empty = false;
-
- // If any of the neighbours is not in same region,
- // add the current location as flood fill start
- bool border = false;
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax + ay*chf.width].index + rcGetCon(s, dir);
- const rcCompactSpan& as = chf.spans[ai];
- if (as.reg != region)
- {
- border = true;
- break;
- }
- }
- }
- if (border)
- push3(queue, x, y, i);
- break;
- }
- }
- }
- }
- }
-
- // if the polygon does not contain any points from the current region (rare, but happens)
- // or if it could potentially be overlapping polygons of the same region,
- // then use the center as the seed point.
- if (empty)
- seedArrayWithPolyCenter(ctx, chf, poly, npoly, verts, bs, hp, queue);
-
- static const int RETRACT_SIZE = 256;
- int head = 0;
-
- // We assume the seed is centered in the polygon, so a BFS to collect
- // height data will ensure we do not move onto overlapping polygons and
- // sample wrong heights.
- while (head*3 < queue.size())
- {
- int cx = queue[head*3+0];
- int cy = queue[head*3+1];
- int ci = queue[head*3+2];
- head++;
- if (head >= RETRACT_SIZE)
- {
- head = 0;
- if (queue.size() > RETRACT_SIZE*3)
- memmove(&queue[0], &queue[RETRACT_SIZE*3], sizeof(int)*(queue.size()-RETRACT_SIZE*3));
- queue.resize(queue.size()-RETRACT_SIZE*3);
- }
-
- const rcCompactSpan& cs = chf.spans[ci];
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(cs, dir) == RC_NOT_CONNECTED) continue;
-
- const int ax = cx + rcGetDirOffsetX(dir);
- const int ay = cy + rcGetDirOffsetY(dir);
- const int hx = ax - hp.xmin - bs;
- const int hy = ay - hp.ymin - bs;
-
- if ((unsigned int)hx >= (unsigned int)hp.width || (unsigned int)hy >= (unsigned int)hp.height)
- continue;
-
- if (hp.data[hx + hy*hp.width] != RC_UNSET_HEIGHT)
- continue;
-
- const int ai = (int)chf.cells[ax + ay*chf.width].index + rcGetCon(cs, dir);
- const rcCompactSpan& as = chf.spans[ai];
-
- hp.data[hx + hy*hp.width] = as.y;
-
- push3(queue, ax, ay, ai);
- }
- }
-}
-
-static unsigned char getEdgeFlags(const float* va, const float* vb,
- const float* vpoly, const int npoly)
-{
- // Return true if edge (va,vb) is part of the polygon.
- static const float thrSqr = rcSqr(0.001f);
- for (int i = 0, j = npoly-1; i < npoly; j=i++)
- {
- if (distancePtSeg2d(va, &vpoly[j*3], &vpoly[i*3]) < thrSqr &&
- distancePtSeg2d(vb, &vpoly[j*3], &vpoly[i*3]) < thrSqr)
- return 1;
- }
- return 0;
-}
-
-static unsigned char getTriFlags(const float* va, const float* vb, const float* vc,
- const float* vpoly, const int npoly)
-{
- unsigned char flags = 0;
- flags |= getEdgeFlags(va,vb,vpoly,npoly) << 0;
- flags |= getEdgeFlags(vb,vc,vpoly,npoly) << 2;
- flags |= getEdgeFlags(vc,va,vpoly,npoly) << 4;
- return flags;
-}
-
-/// @par
-///
-/// See the #rcConfig documentation for more information on the configuration parameters.
-///
-/// @see rcAllocPolyMeshDetail, rcPolyMesh, rcCompactHeightfield, rcPolyMeshDetail, rcConfig
-bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompactHeightfield& chf,
- const float sampleDist, const float sampleMaxError,
- rcPolyMeshDetail& dmesh)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_BUILD_POLYMESHDETAIL);
-
- if (mesh.nverts == 0 || mesh.npolys == 0)
- return true;
-
- const int nvp = mesh.nvp;
- const float cs = mesh.cs;
- const float ch = mesh.ch;
- const float* orig = mesh.bmin;
- const int borderSize = mesh.borderSize;
- const int heightSearchRadius = rcMax(1, (int)ceilf(mesh.maxEdgeError));
-
- rcIntArray edges(64);
- rcIntArray tris(512);
- rcIntArray arr(512);
- rcIntArray samples(512);
- float verts[256*3];
- rcHeightPatch hp;
- int nPolyVerts = 0;
- int maxhw = 0, maxhh = 0;
-
- rcScopedDelete<int> bounds((int*)rcAlloc(sizeof(int)*mesh.npolys*4, RC_ALLOC_TEMP));
- if (!bounds)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'bounds' (%d).", mesh.npolys*4);
- return false;
- }
- rcScopedDelete<float> poly((float*)rcAlloc(sizeof(float)*nvp*3, RC_ALLOC_TEMP));
- if (!poly)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'poly' (%d).", nvp*3);
- return false;
- }
-
- // Find max size for a polygon area.
- for (int i = 0; i < mesh.npolys; ++i)
- {
- const unsigned short* p = &mesh.polys[i*nvp*2];
- int& xmin = bounds[i*4+0];
- int& xmax = bounds[i*4+1];
- int& ymin = bounds[i*4+2];
- int& ymax = bounds[i*4+3];
- xmin = chf.width;
- xmax = 0;
- ymin = chf.height;
- ymax = 0;
- for (int j = 0; j < nvp; ++j)
- {
- if(p[j] == RC_MESH_NULL_IDX) break;
- const unsigned short* v = &mesh.verts[p[j]*3];
- xmin = rcMin(xmin, (int)v[0]);
- xmax = rcMax(xmax, (int)v[0]);
- ymin = rcMin(ymin, (int)v[2]);
- ymax = rcMax(ymax, (int)v[2]);
- nPolyVerts++;
- }
- xmin = rcMax(0,xmin-1);
- xmax = rcMin(chf.width,xmax+1);
- ymin = rcMax(0,ymin-1);
- ymax = rcMin(chf.height,ymax+1);
- if (xmin >= xmax || ymin >= ymax) continue;
- maxhw = rcMax(maxhw, xmax-xmin);
- maxhh = rcMax(maxhh, ymax-ymin);
- }
-
- hp.data = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxhw*maxhh, RC_ALLOC_TEMP);
- if (!hp.data)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'hp.data' (%d).", maxhw*maxhh);
- return false;
- }
-
- dmesh.nmeshes = mesh.npolys;
- dmesh.nverts = 0;
- dmesh.ntris = 0;
- dmesh.meshes = (unsigned int*)rcAlloc(sizeof(unsigned int)*dmesh.nmeshes*4, RC_ALLOC_PERM);
- if (!dmesh.meshes)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.meshes' (%d).", dmesh.nmeshes*4);
- return false;
- }
-
- int vcap = nPolyVerts+nPolyVerts/2;
- int tcap = vcap*2;
-
- dmesh.nverts = 0;
- dmesh.verts = (float*)rcAlloc(sizeof(float)*vcap*3, RC_ALLOC_PERM);
- if (!dmesh.verts)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.verts' (%d).", vcap*3);
- return false;
- }
- dmesh.ntris = 0;
- dmesh.tris = (unsigned char*)rcAlloc(sizeof(unsigned char)*tcap*4, RC_ALLOC_PERM);
- if (!dmesh.tris)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.tris' (%d).", tcap*4);
- return false;
- }
-
- for (int i = 0; i < mesh.npolys; ++i)
- {
- const unsigned short* p = &mesh.polys[i*nvp*2];
-
- // Store polygon vertices for processing.
- int npoly = 0;
- for (int j = 0; j < nvp; ++j)
- {
- if(p[j] == RC_MESH_NULL_IDX) break;
- const unsigned short* v = &mesh.verts[p[j]*3];
- poly[j*3+0] = v[0]*cs;
- poly[j*3+1] = v[1]*ch;
- poly[j*3+2] = v[2]*cs;
- npoly++;
- }
-
- // Get the height data from the area of the polygon.
- hp.xmin = bounds[i*4+0];
- hp.ymin = bounds[i*4+2];
- hp.width = bounds[i*4+1]-bounds[i*4+0];
- hp.height = bounds[i*4+3]-bounds[i*4+2];
- getHeightData(ctx, chf, p, npoly, mesh.verts, borderSize, hp, arr, mesh.regs[i]);
-
- // Build detail mesh.
- int nverts = 0;
- if (!buildPolyDetail(ctx, poly, npoly,
- sampleDist, sampleMaxError,
- heightSearchRadius, chf, hp,
- verts, nverts, tris,
- edges, samples))
- {
- return false;
- }
-
- // Move detail verts to world space.
- for (int j = 0; j < nverts; ++j)
- {
- verts[j*3+0] += orig[0];
- verts[j*3+1] += orig[1] + chf.ch; // Is this offset necessary?
- verts[j*3+2] += orig[2];
- }
- // Offset poly too, will be used to flag checking.
- for (int j = 0; j < npoly; ++j)
- {
- poly[j*3+0] += orig[0];
- poly[j*3+1] += orig[1];
- poly[j*3+2] += orig[2];
- }
-
- // Store detail submesh.
- const int ntris = tris.size()/4;
-
- dmesh.meshes[i*4+0] = (unsigned int)dmesh.nverts;
- dmesh.meshes[i*4+1] = (unsigned int)nverts;
- dmesh.meshes[i*4+2] = (unsigned int)dmesh.ntris;
- dmesh.meshes[i*4+3] = (unsigned int)ntris;
-
- // Store vertices, allocate more memory if necessary.
- if (dmesh.nverts+nverts > vcap)
- {
- while (dmesh.nverts+nverts > vcap)
- vcap += 256;
-
- float* newv = (float*)rcAlloc(sizeof(float)*vcap*3, RC_ALLOC_PERM);
- if (!newv)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'newv' (%d).", vcap*3);
- return false;
- }
- if (dmesh.nverts)
- memcpy(newv, dmesh.verts, sizeof(float)*3*dmesh.nverts);
- rcFree(dmesh.verts);
- dmesh.verts = newv;
- }
- for (int j = 0; j < nverts; ++j)
- {
- dmesh.verts[dmesh.nverts*3+0] = verts[j*3+0];
- dmesh.verts[dmesh.nverts*3+1] = verts[j*3+1];
- dmesh.verts[dmesh.nverts*3+2] = verts[j*3+2];
- dmesh.nverts++;
- }
-
- // Store triangles, allocate more memory if necessary.
- if (dmesh.ntris+ntris > tcap)
- {
- while (dmesh.ntris+ntris > tcap)
- tcap += 256;
- unsigned char* newt = (unsigned char*)rcAlloc(sizeof(unsigned char)*tcap*4, RC_ALLOC_PERM);
- if (!newt)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'newt' (%d).", tcap*4);
- return false;
- }
- if (dmesh.ntris)
- memcpy(newt, dmesh.tris, sizeof(unsigned char)*4*dmesh.ntris);
- rcFree(dmesh.tris);
- dmesh.tris = newt;
- }
- for (int j = 0; j < ntris; ++j)
- {
- const int* t = &tris[j*4];
- dmesh.tris[dmesh.ntris*4+0] = (unsigned char)t[0];
- dmesh.tris[dmesh.ntris*4+1] = (unsigned char)t[1];
- dmesh.tris[dmesh.ntris*4+2] = (unsigned char)t[2];
- dmesh.tris[dmesh.ntris*4+3] = getTriFlags(&verts[t[0]*3], &verts[t[1]*3], &verts[t[2]*3], poly, npoly);
- dmesh.ntris++;
- }
- }
-
- return true;
-}
-
-/// @see rcAllocPolyMeshDetail, rcPolyMeshDetail
-bool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int nmeshes, rcPolyMeshDetail& mesh)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_MERGE_POLYMESHDETAIL);
-
- int maxVerts = 0;
- int maxTris = 0;
- int maxMeshes = 0;
-
- for (int i = 0; i < nmeshes; ++i)
- {
- if (!meshes[i]) continue;
- maxVerts += meshes[i]->nverts;
- maxTris += meshes[i]->ntris;
- maxMeshes += meshes[i]->nmeshes;
- }
-
- mesh.nmeshes = 0;
- mesh.meshes = (unsigned int*)rcAlloc(sizeof(unsigned int)*maxMeshes*4, RC_ALLOC_PERM);
- if (!mesh.meshes)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'pmdtl.meshes' (%d).", maxMeshes*4);
- return false;
- }
-
- mesh.ntris = 0;
- mesh.tris = (unsigned char*)rcAlloc(sizeof(unsigned char)*maxTris*4, RC_ALLOC_PERM);
- if (!mesh.tris)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.tris' (%d).", maxTris*4);
- return false;
- }
-
- mesh.nverts = 0;
- mesh.verts = (float*)rcAlloc(sizeof(float)*maxVerts*3, RC_ALLOC_PERM);
- if (!mesh.verts)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.verts' (%d).", maxVerts*3);
- return false;
- }
-
- // Merge datas.
- for (int i = 0; i < nmeshes; ++i)
- {
- rcPolyMeshDetail* dm = meshes[i];
- if (!dm) continue;
- for (int j = 0; j < dm->nmeshes; ++j)
- {
- unsigned int* dst = &mesh.meshes[mesh.nmeshes*4];
- unsigned int* src = &dm->meshes[j*4];
- dst[0] = (unsigned int)mesh.nverts+src[0];
- dst[1] = src[1];
- dst[2] = (unsigned int)mesh.ntris+src[2];
- dst[3] = src[3];
- mesh.nmeshes++;
- }
-
- for (int k = 0; k < dm->nverts; ++k)
- {
- rcVcopy(&mesh.verts[mesh.nverts*3], &dm->verts[k*3]);
- mesh.nverts++;
- }
- for (int k = 0; k < dm->ntris; ++k)
- {
- mesh.tris[mesh.ntris*4+0] = dm->tris[k*4+0];
- mesh.tris[mesh.ntris*4+1] = dm->tris[k*4+1];
- mesh.tris[mesh.ntris*4+2] = dm->tris[k*4+2];
- mesh.tris[mesh.ntris*4+3] = dm->tris[k*4+3];
- mesh.ntris++;
- }
- }
-
- return true;
-}
diff --git a/extern/recastnavigation/Recast/Source/RecastRasterization.cpp b/extern/recastnavigation/Recast/Source/RecastRasterization.cpp
deleted file mode 100644
index a4cef749098..00000000000
--- a/extern/recastnavigation/Recast/Source/RecastRasterization.cpp
+++ /dev/null
@@ -1,454 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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.
-//
-
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <stdio.h>
-#include "Recast.h"
-#include "RecastAlloc.h"
-#include "RecastAssert.h"
-
-inline bool overlapBounds(const float* amin, const float* amax, const float* bmin, const float* bmax)
-{
- bool overlap = true;
- overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
- overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;
- overlap = (amin[2] > bmax[2] || amax[2] < bmin[2]) ? false : overlap;
- return overlap;
-}
-
-inline bool overlapInterval(unsigned short amin, unsigned short amax,
- unsigned short bmin, unsigned short bmax)
-{
- if (amax < bmin) return false;
- if (amin > bmax) return false;
- return true;
-}
-
-
-static rcSpan* allocSpan(rcHeightfield& hf)
-{
- // If running out of memory, allocate new page and update the freelist.
- if (!hf.freelist || !hf.freelist->next)
- {
- // Create new page.
- // Allocate memory for the new pool.
- rcSpanPool* pool = (rcSpanPool*)rcAlloc(sizeof(rcSpanPool), RC_ALLOC_PERM);
- if (!pool) return 0;
-
- // Add the pool into the list of pools.
- pool->next = hf.pools;
- hf.pools = pool;
- // Add new items to the free list.
- rcSpan* freelist = hf.freelist;
- rcSpan* head = &pool->items[0];
- rcSpan* it = &pool->items[RC_SPANS_PER_POOL];
- do
- {
- --it;
- it->next = freelist;
- freelist = it;
- }
- while (it != head);
- hf.freelist = it;
- }
-
- // Pop item from in front of the free list.
- rcSpan* it = hf.freelist;
- hf.freelist = hf.freelist->next;
- return it;
-}
-
-static void freeSpan(rcHeightfield& hf, rcSpan* ptr)
-{
- if (!ptr) return;
- // Add the node in front of the free list.
- ptr->next = hf.freelist;
- hf.freelist = ptr;
-}
-
-static bool addSpan(rcHeightfield& hf, const int x, const int y,
- const unsigned short smin, const unsigned short smax,
- const unsigned char area, const int flagMergeThr)
-{
-
- int idx = x + y*hf.width;
-
- rcSpan* s = allocSpan(hf);
- if (!s)
- return false;
- s->smin = smin;
- s->smax = smax;
- s->area = area;
- s->next = 0;
-
- // Empty cell, add the first span.
- if (!hf.spans[idx])
- {
- hf.spans[idx] = s;
- return true;
- }
- rcSpan* prev = 0;
- rcSpan* cur = hf.spans[idx];
-
- // Insert and merge spans.
- while (cur)
- {
- if (cur->smin > s->smax)
- {
- // Current span is further than the new span, break.
- break;
- }
- else if (cur->smax < s->smin)
- {
- // Current span is before the new span advance.
- prev = cur;
- cur = cur->next;
- }
- else
- {
- // Merge spans.
- if (cur->smin < s->smin)
- s->smin = cur->smin;
- if (cur->smax > s->smax)
- s->smax = cur->smax;
-
- // Merge flags.
- if (rcAbs((int)s->smax - (int)cur->smax) <= flagMergeThr)
- s->area = rcMax(s->area, cur->area);
-
- // Remove current span.
- rcSpan* next = cur->next;
- freeSpan(hf, cur);
- if (prev)
- prev->next = next;
- else
- hf.spans[idx] = next;
- cur = next;
- }
- }
-
- // Insert new span.
- if (prev)
- {
- s->next = prev->next;
- prev->next = s;
- }
- else
- {
- s->next = hf.spans[idx];
- hf.spans[idx] = s;
- }
-
- return true;
-}
-
-/// @par
-///
-/// The span addition can be set to favor flags. If the span is merged to
-/// another span and the new @p smax is within @p flagMergeThr units
-/// from the existing span, the span flags are merged.
-///
-/// @see rcHeightfield, rcSpan.
-bool rcAddSpan(rcContext* ctx, rcHeightfield& hf, const int x, const int y,
- const unsigned short smin, const unsigned short smax,
- const unsigned char area, const int flagMergeThr)
-{
- rcAssert(ctx);
-
- if (!addSpan(hf, x, y, smin, smax, area, flagMergeThr))
- {
- ctx->log(RC_LOG_ERROR, "rcAddSpan: Out of memory.");
- return false;
- }
-
- return true;
-}
-
-// divides a convex polygons into two convex polygons on both sides of a line
-static void dividePoly(const float* in, int nin,
- float* out1, int* nout1,
- float* out2, int* nout2,
- float x, int axis)
-{
- float d[12];
- for (int i = 0; i < nin; ++i)
- d[i] = x - in[i*3+axis];
-
- int m = 0, n = 0;
- for (int i = 0, j = nin-1; i < nin; j=i, ++i)
- {
- bool ina = d[j] >= 0;
- bool inb = d[i] >= 0;
- if (ina != inb)
- {
- float s = d[j] / (d[j] - d[i]);
- out1[m*3+0] = in[j*3+0] + (in[i*3+0] - in[j*3+0])*s;
- out1[m*3+1] = in[j*3+1] + (in[i*3+1] - in[j*3+1])*s;
- out1[m*3+2] = in[j*3+2] + (in[i*3+2] - in[j*3+2])*s;
- rcVcopy(out2 + n*3, out1 + m*3);
- m++;
- n++;
- // add the i'th point to the right polygon. Do NOT add points that are on the dividing line
- // since these were already added above
- if (d[i] > 0)
- {
- rcVcopy(out1 + m*3, in + i*3);
- m++;
- }
- else if (d[i] < 0)
- {
- rcVcopy(out2 + n*3, in + i*3);
- n++;
- }
- }
- else // same side
- {
- // add the i'th point to the right polygon. Addition is done even for points on the dividing line
- if (d[i] >= 0)
- {
- rcVcopy(out1 + m*3, in + i*3);
- m++;
- if (d[i] != 0)
- continue;
- }
- rcVcopy(out2 + n*3, in + i*3);
- n++;
- }
- }
-
- *nout1 = m;
- *nout2 = n;
-}
-
-
-
-static bool rasterizeTri(const float* v0, const float* v1, const float* v2,
- const unsigned char area, rcHeightfield& hf,
- const float* bmin, const float* bmax,
- const float cs, const float ics, const float ich,
- const int flagMergeThr)
-{
- const int w = hf.width;
- const int h = hf.height;
- float tmin[3], tmax[3];
- const float by = bmax[1] - bmin[1];
-
- // Calculate the bounding box of the triangle.
- rcVcopy(tmin, v0);
- rcVcopy(tmax, v0);
- rcVmin(tmin, v1);
- rcVmin(tmin, v2);
- rcVmax(tmax, v1);
- rcVmax(tmax, v2);
-
- // If the triangle does not touch the bbox of the heightfield, skip the triagle.
- if (!overlapBounds(bmin, bmax, tmin, tmax))
- return true;
-
- // Calculate the footprint of the triangle on the grid's y-axis
- int y0 = (int)((tmin[2] - bmin[2])*ics);
- int y1 = (int)((tmax[2] - bmin[2])*ics);
- y0 = rcClamp(y0, 0, h-1);
- y1 = rcClamp(y1, 0, h-1);
-
- // Clip the triangle into all grid cells it touches.
- float buf[7*3*4];
- float *in = buf, *inrow = buf+7*3, *p1 = inrow+7*3, *p2 = p1+7*3;
-
- rcVcopy(&in[0], v0);
- rcVcopy(&in[1*3], v1);
- rcVcopy(&in[2*3], v2);
- int nvrow, nvIn = 3;
-
- for (int y = y0; y <= y1; ++y)
- {
- // Clip polygon to row. Store the remaining polygon as well
- const float cz = bmin[2] + y*cs;
- dividePoly(in, nvIn, inrow, &nvrow, p1, &nvIn, cz+cs, 2);
- rcSwap(in, p1);
- if (nvrow < 3) continue;
-
- // find the horizontal bounds in the row
- float minX = inrow[0], maxX = inrow[0];
- for (int i=1; i<nvrow; ++i)
- {
- if (minX > inrow[i*3]) minX = inrow[i*3];
- if (maxX < inrow[i*3]) maxX = inrow[i*3];
- }
- int x0 = (int)((minX - bmin[0])*ics);
- int x1 = (int)((maxX - bmin[0])*ics);
- x0 = rcClamp(x0, 0, w-1);
- x1 = rcClamp(x1, 0, w-1);
-
- int nv, nv2 = nvrow;
-
- for (int x = x0; x <= x1; ++x)
- {
- // Clip polygon to column. store the remaining polygon as well
- const float cx = bmin[0] + x*cs;
- dividePoly(inrow, nv2, p1, &nv, p2, &nv2, cx+cs, 0);
- rcSwap(inrow, p2);
- if (nv < 3) continue;
-
- // Calculate min and max of the span.
- float smin = p1[1], smax = p1[1];
- for (int i = 1; i < nv; ++i)
- {
- smin = rcMin(smin, p1[i*3+1]);
- smax = rcMax(smax, p1[i*3+1]);
- }
- smin -= bmin[1];
- smax -= bmin[1];
- // Skip the span if it is outside the heightfield bbox
- if (smax < 0.0f) continue;
- if (smin > by) continue;
- // Clamp the span to the heightfield bbox.
- if (smin < 0.0f) smin = 0;
- if (smax > by) smax = by;
-
- // Snap the span to the heightfield height grid.
- unsigned short ismin = (unsigned short)rcClamp((int)floorf(smin * ich), 0, RC_SPAN_MAX_HEIGHT);
- unsigned short ismax = (unsigned short)rcClamp((int)ceilf(smax * ich), (int)ismin+1, RC_SPAN_MAX_HEIGHT);
-
- if (!addSpan(hf, x, y, ismin, ismax, area, flagMergeThr))
- return false;
- }
- }
-
- return true;
-}
-
-/// @par
-///
-/// No spans will be added if the triangle does not overlap the heightfield grid.
-///
-/// @see rcHeightfield
-bool rcRasterizeTriangle(rcContext* ctx, const float* v0, const float* v1, const float* v2,
- const unsigned char area, rcHeightfield& solid,
- const int flagMergeThr)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_RASTERIZE_TRIANGLES);
-
- const float ics = 1.0f/solid.cs;
- const float ich = 1.0f/solid.ch;
- if (!rasterizeTri(v0, v1, v2, area, solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr))
- {
- ctx->log(RC_LOG_ERROR, "rcRasterizeTriangle: Out of memory.");
- return false;
- }
-
- return true;
-}
-
-/// @par
-///
-/// Spans will only be added for triangles that overlap the heightfield grid.
-///
-/// @see rcHeightfield
-bool rcRasterizeTriangles(rcContext* ctx, const float* verts, const int /*nv*/,
- const int* tris, const unsigned char* areas, const int nt,
- rcHeightfield& solid, const int flagMergeThr)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_RASTERIZE_TRIANGLES);
-
- const float ics = 1.0f/solid.cs;
- const float ich = 1.0f/solid.ch;
- // Rasterize triangles.
- for (int i = 0; i < nt; ++i)
- {
- const float* v0 = &verts[tris[i*3+0]*3];
- const float* v1 = &verts[tris[i*3+1]*3];
- const float* v2 = &verts[tris[i*3+2]*3];
- // Rasterize.
- if (!rasterizeTri(v0, v1, v2, areas[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr))
- {
- ctx->log(RC_LOG_ERROR, "rcRasterizeTriangles: Out of memory.");
- return false;
- }
- }
-
- return true;
-}
-
-/// @par
-///
-/// Spans will only be added for triangles that overlap the heightfield grid.
-///
-/// @see rcHeightfield
-bool rcRasterizeTriangles(rcContext* ctx, const float* verts, const int /*nv*/,
- const unsigned short* tris, const unsigned char* areas, const int nt,
- rcHeightfield& solid, const int flagMergeThr)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_RASTERIZE_TRIANGLES);
-
- const float ics = 1.0f/solid.cs;
- const float ich = 1.0f/solid.ch;
- // Rasterize triangles.
- for (int i = 0; i < nt; ++i)
- {
- const float* v0 = &verts[tris[i*3+0]*3];
- const float* v1 = &verts[tris[i*3+1]*3];
- const float* v2 = &verts[tris[i*3+2]*3];
- // Rasterize.
- if (!rasterizeTri(v0, v1, v2, areas[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr))
- {
- ctx->log(RC_LOG_ERROR, "rcRasterizeTriangles: Out of memory.");
- return false;
- }
- }
-
- return true;
-}
-
-/// @par
-///
-/// Spans will only be added for triangles that overlap the heightfield grid.
-///
-/// @see rcHeightfield
-bool rcRasterizeTriangles(rcContext* ctx, const float* verts, const unsigned char* areas, const int nt,
- rcHeightfield& solid, const int flagMergeThr)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_RASTERIZE_TRIANGLES);
-
- const float ics = 1.0f/solid.cs;
- const float ich = 1.0f/solid.ch;
- // Rasterize triangles.
- for (int i = 0; i < nt; ++i)
- {
- const float* v0 = &verts[(i*3+0)*3];
- const float* v1 = &verts[(i*3+1)*3];
- const float* v2 = &verts[(i*3+2)*3];
- // Rasterize.
- if (!rasterizeTri(v0, v1, v2, areas[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr))
- {
- ctx->log(RC_LOG_ERROR, "rcRasterizeTriangles: Out of memory.");
- return false;
- }
- }
-
- return true;
-}
diff --git a/extern/recastnavigation/Recast/Source/RecastRegion.cpp b/extern/recastnavigation/Recast/Source/RecastRegion.cpp
deleted file mode 100644
index 54acf4b736b..00000000000
--- a/extern/recastnavigation/Recast/Source/RecastRegion.cpp
+++ /dev/null
@@ -1,1830 +0,0 @@
-//
-// Copyright (c) 2009-2010 Mikko Mononen memon@inside.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 <float.h>
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "Recast.h"
-#include "RecastAlloc.h"
-#include "RecastAssert.h"
-#include <new>
-
-
-static void calculateDistanceField(rcCompactHeightfield& chf, unsigned short* src, unsigned short& maxDist)
-{
- const int w = chf.width;
- const int h = chf.height;
-
- // Init distance and points.
- for (int i = 0; i < chf.spanCount; ++i)
- src[i] = 0xffff;
-
- // Mark boundary cells.
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- const unsigned char area = chf.areas[i];
-
- int nc = 0;
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
- if (area == chf.areas[ai])
- nc++;
- }
- }
- if (nc != 4)
- src[i] = 0;
- }
- }
- }
-
-
- // Pass 1
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
-
- if (rcGetCon(s, 0) != RC_NOT_CONNECTED)
- {
- // (-1,0)
- const int ax = x + rcGetDirOffsetX(0);
- const int ay = y + rcGetDirOffsetY(0);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);
- const rcCompactSpan& as = chf.spans[ai];
- if (src[ai]+2 < src[i])
- src[i] = src[ai]+2;
-
- // (-1,-1)
- if (rcGetCon(as, 3) != RC_NOT_CONNECTED)
- {
- const int aax = ax + rcGetDirOffsetX(3);
- const int aay = ay + rcGetDirOffsetY(3);
- const int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 3);
- if (src[aai]+3 < src[i])
- src[i] = src[aai]+3;
- }
- }
- if (rcGetCon(s, 3) != RC_NOT_CONNECTED)
- {
- // (0,-1)
- const int ax = x + rcGetDirOffsetX(3);
- const int ay = y + rcGetDirOffsetY(3);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);
- const rcCompactSpan& as = chf.spans[ai];
- if (src[ai]+2 < src[i])
- src[i] = src[ai]+2;
-
- // (1,-1)
- if (rcGetCon(as, 2) != RC_NOT_CONNECTED)
- {
- const int aax = ax + rcGetDirOffsetX(2);
- const int aay = ay + rcGetDirOffsetY(2);
- const int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 2);
- if (src[aai]+3 < src[i])
- src[i] = src[aai]+3;
- }
- }
- }
- }
- }
-
- // Pass 2
- for (int y = h-1; y >= 0; --y)
- {
- for (int x = w-1; x >= 0; --x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
-
- if (rcGetCon(s, 2) != RC_NOT_CONNECTED)
- {
- // (1,0)
- const int ax = x + rcGetDirOffsetX(2);
- const int ay = y + rcGetDirOffsetY(2);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 2);
- const rcCompactSpan& as = chf.spans[ai];
- if (src[ai]+2 < src[i])
- src[i] = src[ai]+2;
-
- // (1,1)
- if (rcGetCon(as, 1) != RC_NOT_CONNECTED)
- {
- const int aax = ax + rcGetDirOffsetX(1);
- const int aay = ay + rcGetDirOffsetY(1);
- const int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 1);
- if (src[aai]+3 < src[i])
- src[i] = src[aai]+3;
- }
- }
- if (rcGetCon(s, 1) != RC_NOT_CONNECTED)
- {
- // (0,1)
- const int ax = x + rcGetDirOffsetX(1);
- const int ay = y + rcGetDirOffsetY(1);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 1);
- const rcCompactSpan& as = chf.spans[ai];
- if (src[ai]+2 < src[i])
- src[i] = src[ai]+2;
-
- // (-1,1)
- if (rcGetCon(as, 0) != RC_NOT_CONNECTED)
- {
- const int aax = ax + rcGetDirOffsetX(0);
- const int aay = ay + rcGetDirOffsetY(0);
- const int aai = (int)chf.cells[aax+aay*w].index + rcGetCon(as, 0);
- if (src[aai]+3 < src[i])
- src[i] = src[aai]+3;
- }
- }
- }
- }
- }
-
- maxDist = 0;
- for (int i = 0; i < chf.spanCount; ++i)
- maxDist = rcMax(src[i], maxDist);
-
-}
-
-static unsigned short* boxBlur(rcCompactHeightfield& chf, int thr,
- unsigned short* src, unsigned short* dst)
-{
- const int w = chf.width;
- const int h = chf.height;
-
- thr *= 2;
-
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- const unsigned short cd = src[i];
- if (cd <= thr)
- {
- dst[i] = cd;
- continue;
- }
-
- int d = (int)cd;
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
- d += (int)src[ai];
-
- const rcCompactSpan& as = chf.spans[ai];
- const int dir2 = (dir+1) & 0x3;
- if (rcGetCon(as, dir2) != RC_NOT_CONNECTED)
- {
- const int ax2 = ax + rcGetDirOffsetX(dir2);
- const int ay2 = ay + rcGetDirOffsetY(dir2);
- const int ai2 = (int)chf.cells[ax2+ay2*w].index + rcGetCon(as, dir2);
- d += (int)src[ai2];
- }
- else
- {
- d += cd;
- }
- }
- else
- {
- d += cd*2;
- }
- }
- dst[i] = (unsigned short)((d+5)/9);
- }
- }
- }
- return dst;
-}
-
-
-static bool floodRegion(int x, int y, int i,
- unsigned short level, unsigned short r,
- rcCompactHeightfield& chf,
- unsigned short* srcReg, unsigned short* srcDist,
- rcIntArray& stack)
-{
- const int w = chf.width;
-
- const unsigned char area = chf.areas[i];
-
- // Flood fill mark region.
- stack.resize(0);
- stack.push((int)x);
- stack.push((int)y);
- stack.push((int)i);
- srcReg[i] = r;
- srcDist[i] = 0;
-
- unsigned short lev = level >= 2 ? level-2 : 0;
- int count = 0;
-
- while (stack.size() > 0)
- {
- int ci = stack.pop();
- int cy = stack.pop();
- int cx = stack.pop();
-
- const rcCompactSpan& cs = chf.spans[ci];
-
- // Check if any of the neighbours already have a valid region set.
- unsigned short ar = 0;
- for (int dir = 0; dir < 4; ++dir)
- {
- // 8 connected
- if (rcGetCon(cs, dir) != RC_NOT_CONNECTED)
- {
- const int ax = cx + rcGetDirOffsetX(dir);
- const int ay = cy + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(cs, dir);
- if (chf.areas[ai] != area)
- continue;
- unsigned short nr = srcReg[ai];
- if (nr & RC_BORDER_REG) // Do not take borders into account.
- continue;
- if (nr != 0 && nr != r)
- {
- ar = nr;
- break;
- }
-
- const rcCompactSpan& as = chf.spans[ai];
-
- const int dir2 = (dir+1) & 0x3;
- if (rcGetCon(as, dir2) != RC_NOT_CONNECTED)
- {
- const int ax2 = ax + rcGetDirOffsetX(dir2);
- const int ay2 = ay + rcGetDirOffsetY(dir2);
- const int ai2 = (int)chf.cells[ax2+ay2*w].index + rcGetCon(as, dir2);
- if (chf.areas[ai2] != area)
- continue;
- unsigned short nr2 = srcReg[ai2];
- if (nr2 != 0 && nr2 != r)
- {
- ar = nr2;
- break;
- }
- }
- }
- }
- if (ar != 0)
- {
- srcReg[ci] = 0;
- continue;
- }
-
- count++;
-
- // Expand neighbours.
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(cs, dir) != RC_NOT_CONNECTED)
- {
- const int ax = cx + rcGetDirOffsetX(dir);
- const int ay = cy + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(cs, dir);
- if (chf.areas[ai] != area)
- continue;
- if (chf.dist[ai] >= lev && srcReg[ai] == 0)
- {
- srcReg[ai] = r;
- srcDist[ai] = 0;
- stack.push(ax);
- stack.push(ay);
- stack.push(ai);
- }
- }
- }
- }
-
- return count > 0;
-}
-
-static unsigned short* expandRegions(int maxIter, unsigned short level,
- rcCompactHeightfield& chf,
- unsigned short* srcReg, unsigned short* srcDist,
- unsigned short* dstReg, unsigned short* dstDist,
- rcIntArray& stack,
- bool fillStack)
-{
- const int w = chf.width;
- const int h = chf.height;
-
- if (fillStack)
- {
- // Find cells revealed by the raised level.
- stack.resize(0);
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- if (chf.dist[i] >= level && srcReg[i] == 0 && chf.areas[i] != RC_NULL_AREA)
- {
- stack.push(x);
- stack.push(y);
- stack.push(i);
- }
- }
- }
- }
- }
- else // use cells in the input stack
- {
- // mark all cells which already have a region
- for (int j=0; j<stack.size(); j+=3)
- {
- int i = stack[j+2];
- if (srcReg[i] != 0)
- stack[j+2] = -1;
- }
- }
-
- int iter = 0;
- while (stack.size() > 0)
- {
- int failed = 0;
-
- memcpy(dstReg, srcReg, sizeof(unsigned short)*chf.spanCount);
- memcpy(dstDist, srcDist, sizeof(unsigned short)*chf.spanCount);
-
- for (int j = 0; j < stack.size(); j += 3)
- {
- int x = stack[j+0];
- int y = stack[j+1];
- int i = stack[j+2];
- if (i < 0)
- {
- failed++;
- continue;
- }
-
- unsigned short r = srcReg[i];
- unsigned short d2 = 0xffff;
- const unsigned char area = chf.areas[i];
- const rcCompactSpan& s = chf.spans[i];
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(s, dir) == RC_NOT_CONNECTED) continue;
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
- if (chf.areas[ai] != area) continue;
- if (srcReg[ai] > 0 && (srcReg[ai] & RC_BORDER_REG) == 0)
- {
- if ((int)srcDist[ai]+2 < (int)d2)
- {
- r = srcReg[ai];
- d2 = srcDist[ai]+2;
- }
- }
- }
- if (r)
- {
- stack[j+2] = -1; // mark as used
- dstReg[i] = r;
- dstDist[i] = d2;
- }
- else
- {
- failed++;
- }
- }
-
- // rcSwap source and dest.
- rcSwap(srcReg, dstReg);
- rcSwap(srcDist, dstDist);
-
- if (failed*3 == stack.size())
- break;
-
- if (level > 0)
- {
- ++iter;
- if (iter >= maxIter)
- break;
- }
- }
-
- return srcReg;
-}
-
-
-
-static void sortCellsByLevel(unsigned short startLevel,
- rcCompactHeightfield& chf,
- unsigned short* srcReg,
- unsigned int nbStacks, rcIntArray* stacks,
- unsigned short loglevelsPerStack) // the levels per stack (2 in our case) as a bit shift
-{
- const int w = chf.width;
- const int h = chf.height;
- startLevel = startLevel >> loglevelsPerStack;
-
- for (unsigned int j=0; j<nbStacks; ++j)
- stacks[j].resize(0);
-
- // put all cells in the level range into the appropriate stacks
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- if (chf.areas[i] == RC_NULL_AREA || srcReg[i] != 0)
- continue;
-
- int level = chf.dist[i] >> loglevelsPerStack;
- int sId = startLevel - level;
- if (sId >= (int)nbStacks)
- continue;
- if (sId < 0)
- sId = 0;
-
- stacks[sId].push(x);
- stacks[sId].push(y);
- stacks[sId].push(i);
- }
- }
- }
-}
-
-
-static void appendStacks(rcIntArray& srcStack, rcIntArray& dstStack,
- unsigned short* srcReg)
-{
- for (int j=0; j<srcStack.size(); j+=3)
- {
- int i = srcStack[j+2];
- if ((i < 0) || (srcReg[i] != 0))
- continue;
- dstStack.push(srcStack[j]);
- dstStack.push(srcStack[j+1]);
- dstStack.push(srcStack[j+2]);
- }
-}
-
-struct rcRegion
-{
- inline rcRegion(unsigned short i) :
- spanCount(0),
- id(i),
- areaType(0),
- remap(false),
- visited(false),
- overlap(false),
- connectsToBorder(false),
- ymin(0xffff),
- ymax(0)
- {}
-
- int spanCount; // Number of spans belonging to this region
- unsigned short id; // ID of the region
- unsigned char areaType; // Are type.
- bool remap;
- bool visited;
- bool overlap;
- bool connectsToBorder;
- unsigned short ymin, ymax;
- rcIntArray connections;
- rcIntArray floors;
-};
-
-static void removeAdjacentNeighbours(rcRegion& reg)
-{
- // Remove adjacent duplicates.
- for (int i = 0; i < reg.connections.size() && reg.connections.size() > 1; )
- {
- int ni = (i+1) % reg.connections.size();
- if (reg.connections[i] == reg.connections[ni])
- {
- // Remove duplicate
- for (int j = i; j < reg.connections.size()-1; ++j)
- reg.connections[j] = reg.connections[j+1];
- reg.connections.pop();
- }
- else
- ++i;
- }
-}
-
-static void replaceNeighbour(rcRegion& reg, unsigned short oldId, unsigned short newId)
-{
- bool neiChanged = false;
- for (int i = 0; i < reg.connections.size(); ++i)
- {
- if (reg.connections[i] == oldId)
- {
- reg.connections[i] = newId;
- neiChanged = true;
- }
- }
- for (int i = 0; i < reg.floors.size(); ++i)
- {
- if (reg.floors[i] == oldId)
- reg.floors[i] = newId;
- }
- if (neiChanged)
- removeAdjacentNeighbours(reg);
-}
-
-static bool canMergeWithRegion(const rcRegion& rega, const rcRegion& regb)
-{
- if (rega.areaType != regb.areaType)
- return false;
- int n = 0;
- for (int i = 0; i < rega.connections.size(); ++i)
- {
- if (rega.connections[i] == regb.id)
- n++;
- }
- if (n > 1)
- return false;
- for (int i = 0; i < rega.floors.size(); ++i)
- {
- if (rega.floors[i] == regb.id)
- return false;
- }
- return true;
-}
-
-static void addUniqueFloorRegion(rcRegion& reg, int n)
-{
- for (int i = 0; i < reg.floors.size(); ++i)
- if (reg.floors[i] == n)
- return;
- reg.floors.push(n);
-}
-
-static bool mergeRegions(rcRegion& rega, rcRegion& regb)
-{
- unsigned short aid = rega.id;
- unsigned short bid = regb.id;
-
- // Duplicate current neighbourhood.
- rcIntArray acon;
- acon.resize(rega.connections.size());
- for (int i = 0; i < rega.connections.size(); ++i)
- acon[i] = rega.connections[i];
- rcIntArray& bcon = regb.connections;
-
- // Find insertion point on A.
- int insa = -1;
- for (int i = 0; i < acon.size(); ++i)
- {
- if (acon[i] == bid)
- {
- insa = i;
- break;
- }
- }
- if (insa == -1)
- return false;
-
- // Find insertion point on B.
- int insb = -1;
- for (int i = 0; i < bcon.size(); ++i)
- {
- if (bcon[i] == aid)
- {
- insb = i;
- break;
- }
- }
- if (insb == -1)
- return false;
-
- // Merge neighbours.
- rega.connections.resize(0);
- for (int i = 0, ni = acon.size(); i < ni-1; ++i)
- rega.connections.push(acon[(insa+1+i) % ni]);
-
- for (int i = 0, ni = bcon.size(); i < ni-1; ++i)
- rega.connections.push(bcon[(insb+1+i) % ni]);
-
- removeAdjacentNeighbours(rega);
-
- for (int j = 0; j < regb.floors.size(); ++j)
- addUniqueFloorRegion(rega, regb.floors[j]);
- rega.spanCount += regb.spanCount;
- regb.spanCount = 0;
- regb.connections.resize(0);
-
- return true;
-}
-
-static bool isRegionConnectedToBorder(const rcRegion& reg)
-{
- // Region is connected to border if
- // one of the neighbours is null id.
- for (int i = 0; i < reg.connections.size(); ++i)
- {
- if (reg.connections[i] == 0)
- return true;
- }
- return false;
-}
-
-static bool isSolidEdge(rcCompactHeightfield& chf, unsigned short* srcReg,
- int x, int y, int i, int dir)
-{
- const rcCompactSpan& s = chf.spans[i];
- unsigned short r = 0;
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);
- r = srcReg[ai];
- }
- if (r == srcReg[i])
- return false;
- return true;
-}
-
-static void walkContour(int x, int y, int i, int dir,
- rcCompactHeightfield& chf,
- unsigned short* srcReg,
- rcIntArray& cont)
-{
- int startDir = dir;
- int starti = i;
-
- const rcCompactSpan& ss = chf.spans[i];
- unsigned short curReg = 0;
- if (rcGetCon(ss, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(ss, dir);
- curReg = srcReg[ai];
- }
- cont.push(curReg);
-
- int iter = 0;
- while (++iter < 40000)
- {
- const rcCompactSpan& s = chf.spans[i];
-
- if (isSolidEdge(chf, srcReg, x, y, i, dir))
- {
- // Choose the edge corner
- unsigned short r = 0;
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*chf.width].index + rcGetCon(s, dir);
- r = srcReg[ai];
- }
- if (r != curReg)
- {
- curReg = r;
- cont.push(curReg);
- }
-
- dir = (dir+1) & 0x3; // Rotate CW
- }
- else
- {
- int ni = -1;
- const int nx = x + rcGetDirOffsetX(dir);
- const int ny = y + rcGetDirOffsetY(dir);
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const rcCompactCell& nc = chf.cells[nx+ny*chf.width];
- ni = (int)nc.index + rcGetCon(s, dir);
- }
- if (ni == -1)
- {
- // Should not happen.
- return;
- }
- x = nx;
- y = ny;
- i = ni;
- dir = (dir+3) & 0x3; // Rotate CCW
- }
-
- if (starti == i && startDir == dir)
- {
- break;
- }
- }
-
- // Remove adjacent duplicates.
- if (cont.size() > 1)
- {
- for (int j = 0; j < cont.size(); )
- {
- int nj = (j+1) % cont.size();
- if (cont[j] == cont[nj])
- {
- for (int k = j; k < cont.size()-1; ++k)
- cont[k] = cont[k+1];
- cont.pop();
- }
- else
- ++j;
- }
- }
-}
-
-
-static bool mergeAndFilterRegions(rcContext* ctx, int minRegionArea, int mergeRegionSize,
- unsigned short& maxRegionId,
- rcCompactHeightfield& chf,
- unsigned short* srcReg, rcIntArray& overlaps)
-{
- const int w = chf.width;
- const int h = chf.height;
-
- const int nreg = maxRegionId+1;
- rcRegion* regions = (rcRegion*)rcAlloc(sizeof(rcRegion)*nreg, RC_ALLOC_TEMP);
- if (!regions)
- {
- ctx->log(RC_LOG_ERROR, "mergeAndFilterRegions: Out of memory 'regions' (%d).", nreg);
- return false;
- }
-
- // Construct regions
- for (int i = 0; i < nreg; ++i)
- new(&regions[i]) rcRegion((unsigned short)i);
-
- // Find edge of a region and find connections around the contour.
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- unsigned short r = srcReg[i];
- if (r == 0 || r >= nreg)
- continue;
-
- rcRegion& reg = regions[r];
- reg.spanCount++;
-
- // Update floors.
- for (int j = (int)c.index; j < ni; ++j)
- {
- if (i == j) continue;
- unsigned short floorId = srcReg[j];
- if (floorId == 0 || floorId >= nreg)
- continue;
- if (floorId == r)
- reg.overlap = true;
- addUniqueFloorRegion(reg, floorId);
- }
-
- // Have found contour
- if (reg.connections.size() > 0)
- continue;
-
- reg.areaType = chf.areas[i];
-
- // Check if this cell is next to a border.
- int ndir = -1;
- for (int dir = 0; dir < 4; ++dir)
- {
- if (isSolidEdge(chf, srcReg, x, y, i, dir))
- {
- ndir = dir;
- break;
- }
- }
-
- if (ndir != -1)
- {
- // The cell is at border.
- // Walk around the contour to find all the neighbours.
- walkContour(x, y, i, ndir, chf, srcReg, reg.connections);
- }
- }
- }
- }
-
- // Remove too small regions.
- rcIntArray stack(32);
- rcIntArray trace(32);
- for (int i = 0; i < nreg; ++i)
- {
- rcRegion& reg = regions[i];
- if (reg.id == 0 || (reg.id & RC_BORDER_REG))
- continue;
- if (reg.spanCount == 0)
- continue;
- if (reg.visited)
- continue;
-
- // Count the total size of all the connected regions.
- // Also keep track of the regions connects to a tile border.
- bool connectsToBorder = false;
- int spanCount = 0;
- stack.resize(0);
- trace.resize(0);
-
- reg.visited = true;
- stack.push(i);
-
- while (stack.size())
- {
- // Pop
- int ri = stack.pop();
-
- rcRegion& creg = regions[ri];
-
- spanCount += creg.spanCount;
- trace.push(ri);
-
- for (int j = 0; j < creg.connections.size(); ++j)
- {
- if (creg.connections[j] & RC_BORDER_REG)
- {
- connectsToBorder = true;
- continue;
- }
- rcRegion& neireg = regions[creg.connections[j]];
- if (neireg.visited)
- continue;
- if (neireg.id == 0 || (neireg.id & RC_BORDER_REG))
- continue;
- // Visit
- stack.push(neireg.id);
- neireg.visited = true;
- }
- }
-
- // If the accumulated regions size is too small, remove it.
- // Do not remove areas which connect to tile borders
- // as their size cannot be estimated correctly and removing them
- // can potentially remove necessary areas.
- if (spanCount < minRegionArea && !connectsToBorder)
- {
- // Kill all visited regions.
- for (int j = 0; j < trace.size(); ++j)
- {
- regions[trace[j]].spanCount = 0;
- regions[trace[j]].id = 0;
- }
- }
- }
-
- // Merge too small regions to neighbour regions.
- int mergeCount = 0 ;
- do
- {
- mergeCount = 0;
- for (int i = 0; i < nreg; ++i)
- {
- rcRegion& reg = regions[i];
- if (reg.id == 0 || (reg.id & RC_BORDER_REG))
- continue;
- if (reg.overlap)
- continue;
- if (reg.spanCount == 0)
- continue;
-
- // Check to see if the region should be merged.
- if (reg.spanCount > mergeRegionSize && isRegionConnectedToBorder(reg))
- continue;
-
- // Small region with more than 1 connection.
- // Or region which is not connected to a border at all.
- // Find smallest neighbour region that connects to this one.
- int smallest = 0xfffffff;
- unsigned short mergeId = reg.id;
- for (int j = 0; j < reg.connections.size(); ++j)
- {
- if (reg.connections[j] & RC_BORDER_REG) continue;
- rcRegion& mreg = regions[reg.connections[j]];
- if (mreg.id == 0 || (mreg.id & RC_BORDER_REG) || mreg.overlap) continue;
- if (mreg.spanCount < smallest &&
- canMergeWithRegion(reg, mreg) &&
- canMergeWithRegion(mreg, reg))
- {
- smallest = mreg.spanCount;
- mergeId = mreg.id;
- }
- }
- // Found new id.
- if (mergeId != reg.id)
- {
- unsigned short oldId = reg.id;
- rcRegion& target = regions[mergeId];
-
- // Merge neighbours.
- if (mergeRegions(target, reg))
- {
- // Fixup regions pointing to current region.
- for (int j = 0; j < nreg; ++j)
- {
- if (regions[j].id == 0 || (regions[j].id & RC_BORDER_REG)) continue;
- // If another region was already merged into current region
- // change the nid of the previous region too.
- if (regions[j].id == oldId)
- regions[j].id = mergeId;
- // Replace the current region with the new one if the
- // current regions is neighbour.
- replaceNeighbour(regions[j], oldId, mergeId);
- }
- mergeCount++;
- }
- }
- }
- }
- while (mergeCount > 0);
-
- // Compress region Ids.
- for (int i = 0; i < nreg; ++i)
- {
- regions[i].remap = false;
- if (regions[i].id == 0) continue; // Skip nil regions.
- if (regions[i].id & RC_BORDER_REG) continue; // Skip external regions.
- regions[i].remap = true;
- }
-
- unsigned short regIdGen = 0;
- for (int i = 0; i < nreg; ++i)
- {
- if (!regions[i].remap)
- continue;
- unsigned short oldId = regions[i].id;
- unsigned short newId = ++regIdGen;
- for (int j = i; j < nreg; ++j)
- {
- if (regions[j].id == oldId)
- {
- regions[j].id = newId;
- regions[j].remap = false;
- }
- }
- }
- maxRegionId = regIdGen;
-
- // Remap regions.
- for (int i = 0; i < chf.spanCount; ++i)
- {
- if ((srcReg[i] & RC_BORDER_REG) == 0)
- srcReg[i] = regions[srcReg[i]].id;
- }
-
- // Return regions that we found to be overlapping.
- for (int i = 0; i < nreg; ++i)
- if (regions[i].overlap)
- overlaps.push(regions[i].id);
-
- for (int i = 0; i < nreg; ++i)
- regions[i].~rcRegion();
- rcFree(regions);
-
-
- return true;
-}
-
-
-static void addUniqueConnection(rcRegion& reg, int n)
-{
- for (int i = 0; i < reg.connections.size(); ++i)
- if (reg.connections[i] == n)
- return;
- reg.connections.push(n);
-}
-
-static bool mergeAndFilterLayerRegions(rcContext* ctx, int minRegionArea,
- unsigned short& maxRegionId,
- rcCompactHeightfield& chf,
- unsigned short* srcReg, rcIntArray& /*overlaps*/)
-{
- const int w = chf.width;
- const int h = chf.height;
-
- const int nreg = maxRegionId+1;
- rcRegion* regions = (rcRegion*)rcAlloc(sizeof(rcRegion)*nreg, RC_ALLOC_TEMP);
- if (!regions)
- {
- ctx->log(RC_LOG_ERROR, "mergeAndFilterLayerRegions: Out of memory 'regions' (%d).", nreg);
- return false;
- }
-
- // Construct regions
- for (int i = 0; i < nreg; ++i)
- new(&regions[i]) rcRegion((unsigned short)i);
-
- // Find region neighbours and overlapping regions.
- rcIntArray lregs(32);
- for (int y = 0; y < h; ++y)
- {
- for (int x = 0; x < w; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
-
- lregs.resize(0);
-
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- const unsigned short ri = srcReg[i];
- if (ri == 0 || ri >= nreg) continue;
- rcRegion& reg = regions[ri];
-
- reg.spanCount++;
-
- reg.ymin = rcMin(reg.ymin, s.y);
- reg.ymax = rcMax(reg.ymax, s.y);
-
- // Collect all region layers.
- lregs.push(ri);
-
- // Update neighbours
- for (int dir = 0; dir < 4; ++dir)
- {
- if (rcGetCon(s, dir) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(dir);
- const int ay = y + rcGetDirOffsetY(dir);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
- const unsigned short rai = srcReg[ai];
- if (rai > 0 && rai < nreg && rai != ri)
- addUniqueConnection(reg, rai);
- if (rai & RC_BORDER_REG)
- reg.connectsToBorder = true;
- }
- }
-
- }
-
- // Update overlapping regions.
- for (int i = 0; i < lregs.size()-1; ++i)
- {
- for (int j = i+1; j < lregs.size(); ++j)
- {
- if (lregs[i] != lregs[j])
- {
- rcRegion& ri = regions[lregs[i]];
- rcRegion& rj = regions[lregs[j]];
- addUniqueFloorRegion(ri, lregs[j]);
- addUniqueFloorRegion(rj, lregs[i]);
- }
- }
- }
-
- }
- }
-
- // Create 2D layers from regions.
- unsigned short layerId = 1;
-
- for (int i = 0; i < nreg; ++i)
- regions[i].id = 0;
-
- // Merge montone regions to create non-overlapping areas.
- rcIntArray stack(32);
- for (int i = 1; i < nreg; ++i)
- {
- rcRegion& root = regions[i];
- // Skip already visited.
- if (root.id != 0)
- continue;
-
- // Start search.
- root.id = layerId;
-
- stack.resize(0);
- stack.push(i);
-
- while (stack.size() > 0)
- {
- // Pop front
- rcRegion& reg = regions[stack[0]];
- for (int j = 0; j < stack.size()-1; ++j)
- stack[j] = stack[j+1];
- stack.resize(stack.size()-1);
-
- const int ncons = (int)reg.connections.size();
- for (int j = 0; j < ncons; ++j)
- {
- const int nei = reg.connections[j];
- rcRegion& regn = regions[nei];
- // Skip already visited.
- if (regn.id != 0)
- continue;
- // Skip if the neighbour is overlapping root region.
- bool overlap = false;
- for (int k = 0; k < root.floors.size(); k++)
- {
- if (root.floors[k] == nei)
- {
- overlap = true;
- break;
- }
- }
- if (overlap)
- continue;
-
- // Deepen
- stack.push(nei);
-
- // Mark layer id
- regn.id = layerId;
- // Merge current layers to root.
- for (int k = 0; k < regn.floors.size(); ++k)
- addUniqueFloorRegion(root, regn.floors[k]);
- root.ymin = rcMin(root.ymin, regn.ymin);
- root.ymax = rcMax(root.ymax, regn.ymax);
- root.spanCount += regn.spanCount;
- regn.spanCount = 0;
- root.connectsToBorder = root.connectsToBorder || regn.connectsToBorder;
- }
- }
-
- layerId++;
- }
-
- // Remove small regions
- for (int i = 0; i < nreg; ++i)
- {
- if (regions[i].spanCount > 0 && regions[i].spanCount < minRegionArea && !regions[i].connectsToBorder)
- {
- unsigned short reg = regions[i].id;
- for (int j = 0; j < nreg; ++j)
- if (regions[j].id == reg)
- regions[j].id = 0;
- }
- }
-
- // Compress region Ids.
- for (int i = 0; i < nreg; ++i)
- {
- regions[i].remap = false;
- if (regions[i].id == 0) continue; // Skip nil regions.
- if (regions[i].id & RC_BORDER_REG) continue; // Skip external regions.
- regions[i].remap = true;
- }
-
- unsigned short regIdGen = 0;
- for (int i = 0; i < nreg; ++i)
- {
- if (!regions[i].remap)
- continue;
- unsigned short oldId = regions[i].id;
- unsigned short newId = ++regIdGen;
- for (int j = i; j < nreg; ++j)
- {
- if (regions[j].id == oldId)
- {
- regions[j].id = newId;
- regions[j].remap = false;
- }
- }
- }
- maxRegionId = regIdGen;
-
- // Remap regions.
- for (int i = 0; i < chf.spanCount; ++i)
- {
- if ((srcReg[i] & RC_BORDER_REG) == 0)
- srcReg[i] = regions[srcReg[i]].id;
- }
-
- for (int i = 0; i < nreg; ++i)
- regions[i].~rcRegion();
- rcFree(regions);
-
- return true;
-}
-
-
-
-/// @par
-///
-/// This is usually the second to the last step in creating a fully built
-/// compact heightfield. This step is required before regions are built
-/// using #rcBuildRegions or #rcBuildRegionsMonotone.
-///
-/// After this step, the distance data is available via the rcCompactHeightfield::maxDistance
-/// and rcCompactHeightfield::dist fields.
-///
-/// @see rcCompactHeightfield, rcBuildRegions, rcBuildRegionsMonotone
-bool rcBuildDistanceField(rcContext* ctx, rcCompactHeightfield& chf)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_BUILD_DISTANCEFIELD);
-
- if (chf.dist)
- {
- rcFree(chf.dist);
- chf.dist = 0;
- }
-
- unsigned short* src = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP);
- if (!src)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildDistanceField: Out of memory 'src' (%d).", chf.spanCount);
- return false;
- }
- unsigned short* dst = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP);
- if (!dst)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildDistanceField: Out of memory 'dst' (%d).", chf.spanCount);
- rcFree(src);
- return false;
- }
-
- unsigned short maxDist = 0;
-
- {
- rcScopedTimer timerDist(ctx, RC_TIMER_BUILD_DISTANCEFIELD_DIST);
-
- calculateDistanceField(chf, src, maxDist);
- chf.maxDistance = maxDist;
- }
-
- {
- rcScopedTimer timerBlur(ctx, RC_TIMER_BUILD_DISTANCEFIELD_BLUR);
-
- // Blur
- if (boxBlur(chf, 1, src, dst) != src)
- rcSwap(src, dst);
-
- // Store distance.
- chf.dist = src;
- }
-
- rcFree(dst);
-
- return true;
-}
-
-static void paintRectRegion(int minx, int maxx, int miny, int maxy, unsigned short regId,
- rcCompactHeightfield& chf, unsigned short* srcReg)
-{
- const int w = chf.width;
- for (int y = miny; y < maxy; ++y)
- {
- for (int x = minx; x < maxx; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- if (chf.areas[i] != RC_NULL_AREA)
- srcReg[i] = regId;
- }
- }
- }
-}
-
-
-static const unsigned short RC_NULL_NEI = 0xffff;
-
-struct rcSweepSpan
-{
- unsigned short rid; // row id
- unsigned short id; // region id
- unsigned short ns; // number samples
- unsigned short nei; // neighbour id
-};
-
-/// @par
-///
-/// Non-null regions will consist of connected, non-overlapping walkable spans that form a single contour.
-/// Contours will form simple polygons.
-///
-/// If multiple regions form an area that is smaller than @p minRegionArea, then all spans will be
-/// re-assigned to the zero (null) region.
-///
-/// Partitioning can result in smaller than necessary regions. @p mergeRegionArea helps
-/// reduce unecessarily small regions.
-///
-/// See the #rcConfig documentation for more information on the configuration parameters.
-///
-/// The region data will be available via the rcCompactHeightfield::maxRegions
-/// and rcCompactSpan::reg fields.
-///
-/// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions.
-///
-/// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig
-bool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,
- const int borderSize, const int minRegionArea, const int mergeRegionArea)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_BUILD_REGIONS);
-
- const int w = chf.width;
- const int h = chf.height;
- unsigned short id = 1;
-
- rcScopedDelete<unsigned short> srcReg((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP));
- if (!srcReg)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildRegionsMonotone: Out of memory 'src' (%d).", chf.spanCount);
- return false;
- }
- memset(srcReg,0,sizeof(unsigned short)*chf.spanCount);
-
- const int nsweeps = rcMax(chf.width,chf.height);
- rcScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rcAlloc(sizeof(rcSweepSpan)*nsweeps, RC_ALLOC_TEMP));
- if (!sweeps)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildRegionsMonotone: Out of memory 'sweeps' (%d).", nsweeps);
- return false;
- }
-
-
- // Mark border regions.
- if (borderSize > 0)
- {
- // Make sure border will not overflow.
- const int bw = rcMin(w, borderSize);
- const int bh = rcMin(h, borderSize);
- // Paint regions
- paintRectRegion(0, bw, 0, h, id|RC_BORDER_REG, chf, srcReg); id++;
- paintRectRegion(w-bw, w, 0, h, id|RC_BORDER_REG, chf, srcReg); id++;
- paintRectRegion(0, w, 0, bh, id|RC_BORDER_REG, chf, srcReg); id++;
- paintRectRegion(0, w, h-bh, h, id|RC_BORDER_REG, chf, srcReg); id++;
-
- chf.borderSize = borderSize;
- }
-
- rcIntArray prev(256);
-
- // Sweep one line at a time.
- for (int y = borderSize; y < h-borderSize; ++y)
- {
- // Collect spans from this row.
- prev.resize(id+1);
- memset(&prev[0],0,sizeof(int)*id);
- unsigned short rid = 1;
-
- for (int x = borderSize; x < w-borderSize; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
-
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- if (chf.areas[i] == RC_NULL_AREA) continue;
-
- // -x
- unsigned short previd = 0;
- if (rcGetCon(s, 0) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(0);
- const int ay = y + rcGetDirOffsetY(0);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);
- if ((srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai])
- previd = srcReg[ai];
- }
-
- if (!previd)
- {
- previd = rid++;
- sweeps[previd].rid = previd;
- sweeps[previd].ns = 0;
- sweeps[previd].nei = 0;
- }
-
- // -y
- if (rcGetCon(s,3) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(3);
- const int ay = y + rcGetDirOffsetY(3);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);
- if (srcReg[ai] && (srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai])
- {
- unsigned short nr = srcReg[ai];
- if (!sweeps[previd].nei || sweeps[previd].nei == nr)
- {
- sweeps[previd].nei = nr;
- sweeps[previd].ns++;
- prev[nr]++;
- }
- else
- {
- sweeps[previd].nei = RC_NULL_NEI;
- }
- }
- }
-
- srcReg[i] = previd;
- }
- }
-
- // Create unique ID.
- for (int i = 1; i < rid; ++i)
- {
- if (sweeps[i].nei != RC_NULL_NEI && sweeps[i].nei != 0 &&
- prev[sweeps[i].nei] == (int)sweeps[i].ns)
- {
- sweeps[i].id = sweeps[i].nei;
- }
- else
- {
- sweeps[i].id = id++;
- }
- }
-
- // Remap IDs
- for (int x = borderSize; x < w-borderSize; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
-
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- if (srcReg[i] > 0 && srcReg[i] < rid)
- srcReg[i] = sweeps[srcReg[i]].id;
- }
- }
- }
-
-
- {
- rcScopedTimer timerFilter(ctx, RC_TIMER_BUILD_REGIONS_FILTER);
-
- // Merge regions and filter out small regions.
- rcIntArray overlaps;
- chf.maxRegions = id;
- if (!mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, chf.maxRegions, chf, srcReg, overlaps))
- return false;
-
- // Monotone partitioning does not generate overlapping regions.
- }
-
- // Store the result out.
- for (int i = 0; i < chf.spanCount; ++i)
- chf.spans[i].reg = srcReg[i];
-
- return true;
-}
-
-/// @par
-///
-/// Non-null regions will consist of connected, non-overlapping walkable spans that form a single contour.
-/// Contours will form simple polygons.
-///
-/// If multiple regions form an area that is smaller than @p minRegionArea, then all spans will be
-/// re-assigned to the zero (null) region.
-///
-/// Watershed partitioning can result in smaller than necessary regions, especially in diagonal corridors.
-/// @p mergeRegionArea helps reduce unecessarily small regions.
-///
-/// See the #rcConfig documentation for more information on the configuration parameters.
-///
-/// The region data will be available via the rcCompactHeightfield::maxRegions
-/// and rcCompactSpan::reg fields.
-///
-/// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions.
-///
-/// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig
-bool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,
- const int borderSize, const int minRegionArea, const int mergeRegionArea)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_BUILD_REGIONS);
-
- const int w = chf.width;
- const int h = chf.height;
-
- rcScopedDelete<unsigned short> buf((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount*4, RC_ALLOC_TEMP));
- if (!buf)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildRegions: Out of memory 'tmp' (%d).", chf.spanCount*4);
- return false;
- }
-
- ctx->startTimer(RC_TIMER_BUILD_REGIONS_WATERSHED);
-
- const int LOG_NB_STACKS = 3;
- const int NB_STACKS = 1 << LOG_NB_STACKS;
- rcIntArray lvlStacks[NB_STACKS];
- for (int i=0; i<NB_STACKS; ++i)
- lvlStacks[i].resize(1024);
-
- rcIntArray stack(1024);
- rcIntArray visited(1024);
-
- unsigned short* srcReg = buf;
- unsigned short* srcDist = buf+chf.spanCount;
- unsigned short* dstReg = buf+chf.spanCount*2;
- unsigned short* dstDist = buf+chf.spanCount*3;
-
- memset(srcReg, 0, sizeof(unsigned short)*chf.spanCount);
- memset(srcDist, 0, sizeof(unsigned short)*chf.spanCount);
-
- unsigned short regionId = 1;
- unsigned short level = (chf.maxDistance+1) & ~1;
-
- // TODO: Figure better formula, expandIters defines how much the
- // watershed "overflows" and simplifies the regions. Tying it to
- // agent radius was usually good indication how greedy it could be.
-// const int expandIters = 4 + walkableRadius * 2;
- const int expandIters = 8;
-
- if (borderSize > 0)
- {
- // Make sure border will not overflow.
- const int bw = rcMin(w, borderSize);
- const int bh = rcMin(h, borderSize);
-
- if (regionId > 0xFFFB)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildRegions: Region ID overflow");
- return false;
- }
-
- // Paint regions
- paintRectRegion(0, bw, 0, h, regionId|RC_BORDER_REG, chf, srcReg); regionId++;
- paintRectRegion(w-bw, w, 0, h, regionId|RC_BORDER_REG, chf, srcReg); regionId++;
- paintRectRegion(0, w, 0, bh, regionId|RC_BORDER_REG, chf, srcReg); regionId++;
- paintRectRegion(0, w, h-bh, h, regionId|RC_BORDER_REG, chf, srcReg); regionId++;
-
- chf.borderSize = borderSize;
- }
-
- int sId = -1;
- while (level > 0)
- {
- level = level >= 2 ? level-2 : 0;
- sId = (sId+1) & (NB_STACKS-1);
-
-// ctx->startTimer(RC_TIMER_DIVIDE_TO_LEVELS);
-
- if (sId == 0)
- sortCellsByLevel(level, chf, srcReg, NB_STACKS, lvlStacks, 1);
- else
- appendStacks(lvlStacks[sId-1], lvlStacks[sId], srcReg); // copy left overs from last level
-
-// ctx->stopTimer(RC_TIMER_DIVIDE_TO_LEVELS);
-
- {
- rcScopedTimer timerExpand(ctx, RC_TIMER_BUILD_REGIONS_EXPAND);
-
- // Expand current regions until no empty connected cells found.
- if (expandRegions(expandIters, level, chf, srcReg, srcDist, dstReg, dstDist, lvlStacks[sId], false) != srcReg)
- {
- rcSwap(srcReg, dstReg);
- rcSwap(srcDist, dstDist);
- }
- }
-
- {
- rcScopedTimer timerFloor(ctx, RC_TIMER_BUILD_REGIONS_FLOOD);
-
- // Mark new regions with IDs.
- for (int j = 0; j<lvlStacks[sId].size(); j += 3)
- {
- int x = lvlStacks[sId][j];
- int y = lvlStacks[sId][j+1];
- int i = lvlStacks[sId][j+2];
- if (i >= 0 && srcReg[i] == 0)
- {
- if (floodRegion(x, y, i, level, regionId, chf, srcReg, srcDist, stack))
- {
- if (regionId == 0xFFFF)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildRegions: Region ID overflow");
- return false;
- }
-
- regionId++;
- }
- }
- }
- }
- }
-
- // Expand current regions until no empty connected cells found.
- if (expandRegions(expandIters*8, 0, chf, srcReg, srcDist, dstReg, dstDist, stack, true) != srcReg)
- {
- rcSwap(srcReg, dstReg);
- rcSwap(srcDist, dstDist);
- }
-
- ctx->stopTimer(RC_TIMER_BUILD_REGIONS_WATERSHED);
-
- {
- rcScopedTimer timerFilter(ctx, RC_TIMER_BUILD_REGIONS_FILTER);
-
- // Merge regions and filter out smalle regions.
- rcIntArray overlaps;
- chf.maxRegions = regionId;
- if (!mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, chf.maxRegions, chf, srcReg, overlaps))
- return false;
-
- // If overlapping regions were found during merging, split those regions.
- if (overlaps.size() > 0)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildRegions: %d overlapping regions.", overlaps.size());
- }
- }
-
- // Write the result out.
- for (int i = 0; i < chf.spanCount; ++i)
- chf.spans[i].reg = srcReg[i];
-
- return true;
-}
-
-
-bool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,
- const int borderSize, const int minRegionArea)
-{
- rcAssert(ctx);
-
- rcScopedTimer timer(ctx, RC_TIMER_BUILD_REGIONS);
-
- const int w = chf.width;
- const int h = chf.height;
- unsigned short id = 1;
-
- rcScopedDelete<unsigned short> srcReg((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP));
- if (!srcReg)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildRegionsMonotone: Out of memory 'src' (%d).", chf.spanCount);
- return false;
- }
- memset(srcReg,0,sizeof(unsigned short)*chf.spanCount);
-
- const int nsweeps = rcMax(chf.width,chf.height);
- rcScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rcAlloc(sizeof(rcSweepSpan)*nsweeps, RC_ALLOC_TEMP));
- if (!sweeps)
- {
- ctx->log(RC_LOG_ERROR, "rcBuildRegionsMonotone: Out of memory 'sweeps' (%d).", nsweeps);
- return false;
- }
-
-
- // Mark border regions.
- if (borderSize > 0)
- {
- // Make sure border will not overflow.
- const int bw = rcMin(w, borderSize);
- const int bh = rcMin(h, borderSize);
- // Paint regions
- paintRectRegion(0, bw, 0, h, id|RC_BORDER_REG, chf, srcReg); id++;
- paintRectRegion(w-bw, w, 0, h, id|RC_BORDER_REG, chf, srcReg); id++;
- paintRectRegion(0, w, 0, bh, id|RC_BORDER_REG, chf, srcReg); id++;
- paintRectRegion(0, w, h-bh, h, id|RC_BORDER_REG, chf, srcReg); id++;
-
- chf.borderSize = borderSize;
- }
-
- rcIntArray prev(256);
-
- // Sweep one line at a time.
- for (int y = borderSize; y < h-borderSize; ++y)
- {
- // Collect spans from this row.
- prev.resize(id+1);
- memset(&prev[0],0,sizeof(int)*id);
- unsigned short rid = 1;
-
- for (int x = borderSize; x < w-borderSize; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
-
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- const rcCompactSpan& s = chf.spans[i];
- if (chf.areas[i] == RC_NULL_AREA) continue;
-
- // -x
- unsigned short previd = 0;
- if (rcGetCon(s, 0) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(0);
- const int ay = y + rcGetDirOffsetY(0);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0);
- if ((srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai])
- previd = srcReg[ai];
- }
-
- if (!previd)
- {
- previd = rid++;
- sweeps[previd].rid = previd;
- sweeps[previd].ns = 0;
- sweeps[previd].nei = 0;
- }
-
- // -y
- if (rcGetCon(s,3) != RC_NOT_CONNECTED)
- {
- const int ax = x + rcGetDirOffsetX(3);
- const int ay = y + rcGetDirOffsetY(3);
- const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3);
- if (srcReg[ai] && (srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai])
- {
- unsigned short nr = srcReg[ai];
- if (!sweeps[previd].nei || sweeps[previd].nei == nr)
- {
- sweeps[previd].nei = nr;
- sweeps[previd].ns++;
- prev[nr]++;
- }
- else
- {
- sweeps[previd].nei = RC_NULL_NEI;
- }
- }
- }
-
- srcReg[i] = previd;
- }
- }
-
- // Create unique ID.
- for (int i = 1; i < rid; ++i)
- {
- if (sweeps[i].nei != RC_NULL_NEI && sweeps[i].nei != 0 &&
- prev[sweeps[i].nei] == (int)sweeps[i].ns)
- {
- sweeps[i].id = sweeps[i].nei;
- }
- else
- {
- sweeps[i].id = id++;
- }
- }
-
- // Remap IDs
- for (int x = borderSize; x < w-borderSize; ++x)
- {
- const rcCompactCell& c = chf.cells[x+y*w];
-
- for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
- {
- if (srcReg[i] > 0 && srcReg[i] < rid)
- srcReg[i] = sweeps[srcReg[i]].id;
- }
- }
- }
-
-
- {
- rcScopedTimer timerFilter(ctx, RC_TIMER_BUILD_REGIONS_FILTER);
-
- // Merge monotone regions to layers and remove small regions.
- rcIntArray overlaps;
- chf.maxRegions = id;
- if (!mergeAndFilterLayerRegions(ctx, minRegionArea, chf.maxRegions, chf, srcReg, overlaps))
- return false;
- }
-
-
- // Store the result out.
- for (int i = 0; i < chf.spanCount; ++i)
- chf.spans[i].reg = srcReg[i];
-
- return true;
-}
diff --git a/extern/recastnavigation/readme-blender.txt b/extern/recastnavigation/readme-blender.txt
deleted file mode 100644
index 2a1b2882ce2..00000000000
--- a/extern/recastnavigation/readme-blender.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-The version of Recast is 1.5.0, from:
-https://github.com/recastnavigation/recastnavigation
-Changes made:
- * Recast/Source/RecastMesh.cpp: made buildMeshAdjacency() non-static so it can be used with recast-capi
- * Recast/Include/Recast.h: Added forward declaration for buildMeshAdjacency()
-
-The following additional files were added:
- * recast-capi.cpp
- * recast-capi.h
-These expose a C interface to the Recast library, which has only C++ headers.
-
-The version of Detour is 1.4, from:
-https://code.google.com/archive/p/recastnavigation/downloads
-Changes made:
- * DetourStatNavMesh.h: use more portable definition of DT_STAT_NAVMESH_MAGIC
- * DetourStatNavMesh.cpp: comment out some unused variables to avoid compiler warnings
- * DetourStatNavMeshBuilder.h: add forward declaration for createBVTree
- * DetourStatNavMeshBuilder.cpp: made createBVTree non-static for use with recast-capi
-
-The CMakeLists.txt file has been added, since the original software does not include build files for the libraries.
-
-~rdb
diff --git a/extern/recastnavigation/recast-capi.cpp b/extern/recastnavigation/recast-capi.cpp
deleted file mode 100644
index 1163265722b..00000000000
--- a/extern/recastnavigation/recast-capi.cpp
+++ /dev/null
@@ -1,381 +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) 2011 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Sergey Sharybin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "recast-capi.h"
-
-#include <math.h>
-#include "Recast.h"
-
-static rcContext *sctx;
-
-#define INIT_SCTX() \
- if (sctx == NULL) sctx = new rcContext(false)
-
-int recast_buildMeshAdjacency(unsigned short* polys, const int npolys,
- const int nverts, const int vertsPerPoly)
-{
- return (int) buildMeshAdjacency(polys, npolys, nverts, vertsPerPoly);
-}
-
-void recast_calcBounds(const float *verts, int nv, float *bmin, float *bmax)
-{
- rcCalcBounds(verts, nv, bmin, bmax);
-}
-
-void recast_calcGridSize(const float *bmin, const float *bmax, float cs, int *w, int *h)
-{
- rcCalcGridSize(bmin, bmax, cs, w, h);
-}
-
-struct recast_heightfield *recast_newHeightfield(void)
-{
- return (struct recast_heightfield *) rcAllocHeightfield();
-}
-
-void recast_destroyHeightfield(struct recast_heightfield *heightfield)
-{
- rcFreeHeightField((rcHeightfield *) heightfield);
-}
-
-int recast_createHeightfield(struct recast_heightfield *hf, int width, int height,
- const float *bmin, const float* bmax, float cs, float ch)
-{
- INIT_SCTX();
- return rcCreateHeightfield(sctx, *(rcHeightfield *)hf, width, height, bmin, bmax, cs, ch);
-}
-
-void recast_markWalkableTriangles(const float walkableSlopeAngle,const float *verts, int nv,
- const int *tris, int nt, unsigned char *areas)
-{
- INIT_SCTX();
- rcMarkWalkableTriangles(sctx, walkableSlopeAngle, verts, nv, tris, nt, areas);
-}
-
-void recast_clearUnwalkableTriangles(const float walkableSlopeAngle, const float* verts, int nv,
- const int* tris, int nt, unsigned char* areas)
-{
- INIT_SCTX();
- rcClearUnwalkableTriangles(sctx, walkableSlopeAngle, verts, nv, tris, nt, areas);
-}
-
-int recast_addSpan(struct recast_heightfield *hf, const int x, const int y,
- const unsigned short smin, const unsigned short smax,
- const unsigned char area, const int flagMergeThr)
-{
- INIT_SCTX();
- return rcAddSpan(sctx, *(rcHeightfield *) hf, x, y, smin, smax, area, flagMergeThr);
-}
-
-int recast_rasterizeTriangle(const float *v0, const float *v1, const float *v2,
- const unsigned char area, struct recast_heightfield *solid,
- const int flagMergeThr)
-{
- INIT_SCTX();
- return rcRasterizeTriangle(sctx, v0, v1, v2, area, *(rcHeightfield *) solid, flagMergeThr);
-}
-
-int recast_rasterizeTriangles(const float *verts, const int nv, const int *tris,
- const unsigned char *areas, const int nt, struct recast_heightfield *solid,
- const int flagMergeThr)
-{
- INIT_SCTX();
- return rcRasterizeTriangles(sctx, verts, nv, tris, areas, nt, *(rcHeightfield *) solid, flagMergeThr);
-}
-
-void recast_filterLedgeSpans(const int walkableHeight, const int walkableClimb,
- struct recast_heightfield *solid)
-{
- INIT_SCTX();
- rcFilterLedgeSpans(sctx, walkableHeight, walkableClimb, *(rcHeightfield *) solid);
-}
-
-void recast_filterWalkableLowHeightSpans(int walkableHeight, struct recast_heightfield *solid)
-{
- INIT_SCTX();
- rcFilterWalkableLowHeightSpans(sctx, walkableHeight, *(rcHeightfield *) solid);
-}
-
-void recast_filterLowHangingWalkableObstacles(const int walkableClimb, struct recast_heightfield *solid)
-{
- INIT_SCTX();
- rcFilterLowHangingWalkableObstacles(sctx, walkableClimb, *(rcHeightfield *) solid);
-}
-
-int recast_getHeightFieldSpanCount(struct recast_heightfield *hf)
-{
- INIT_SCTX();
- return rcGetHeightFieldSpanCount(sctx, *(rcHeightfield *) hf);
-}
-
-struct recast_heightfieldLayerSet *recast_newHeightfieldLayerSet(void)
-{
- return (struct recast_heightfieldLayerSet *) rcAllocHeightfieldLayerSet();
-}
-
-void recast_destroyHeightfieldLayerSet(struct recast_heightfieldLayerSet *lset)
-{
- rcFreeHeightfieldLayerSet( (rcHeightfieldLayerSet *) lset);
-}
-
-struct recast_compactHeightfield *recast_newCompactHeightfield(void)
-{
- return (struct recast_compactHeightfield *) rcAllocCompactHeightfield();
-}
-
-void recast_destroyCompactHeightfield(struct recast_compactHeightfield *compactHeightfield)
-{
- rcFreeCompactHeightfield( (rcCompactHeightfield *) compactHeightfield);
-}
-
-int recast_buildCompactHeightfield(const int walkableHeight, const int walkableClimb,
- struct recast_heightfield *hf, struct recast_compactHeightfield *chf)
-{
- INIT_SCTX();
- return rcBuildCompactHeightfield(sctx, walkableHeight, walkableClimb,
- *(rcHeightfield *) hf, *(rcCompactHeightfield *) chf);
-}
-
-int recast_erodeWalkableArea(int radius, struct recast_compactHeightfield *chf)
-{
- INIT_SCTX();
- return rcErodeWalkableArea(sctx, radius, *(rcCompactHeightfield *) chf);
-}
-
-int recast_medianFilterWalkableArea(struct recast_compactHeightfield *chf)
-{
- INIT_SCTX();
- return rcMedianFilterWalkableArea(sctx, *(rcCompactHeightfield *) chf);
-}
-
-void recast_markBoxArea(const float *bmin, const float *bmax, unsigned char areaId,
- struct recast_compactHeightfield *chf)
-{
- INIT_SCTX();
- rcMarkBoxArea(sctx, bmin, bmax, areaId, *(rcCompactHeightfield *) chf);
-}
-
-void recast_markConvexPolyArea(const float* verts, const int nverts,
- const float hmin, const float hmax, unsigned char areaId,
- struct recast_compactHeightfield *chf)
-{
- INIT_SCTX();
- rcMarkConvexPolyArea(sctx, verts, nverts, hmin, hmax, areaId, *(rcCompactHeightfield *) chf);
-}
-
-int recast_offsetPoly(const float* verts, const int nverts,
- const float offset, float *outVerts, const int maxOutVerts)
-{
- return rcOffsetPoly(verts, nverts, offset, outVerts, maxOutVerts);
-}
-
-void recast_markCylinderArea(const float* pos, const float r, const float h,
- unsigned char areaId, struct recast_compactHeightfield *chf)
-{
- INIT_SCTX();
- rcMarkCylinderArea(sctx, pos, r, h, areaId, *(rcCompactHeightfield *) chf);
-}
-
-int recast_buildDistanceField(struct recast_compactHeightfield *chf)
-{
- INIT_SCTX();
- return rcBuildDistanceField(sctx, *(rcCompactHeightfield *) chf);
-}
-
-int recast_buildRegions(struct recast_compactHeightfield *chf,
- const int borderSize, const int minRegionArea, const int mergeRegionArea)
-{
- INIT_SCTX();
- return rcBuildRegions(sctx, *(rcCompactHeightfield *) chf, borderSize,
- minRegionArea, mergeRegionArea);
-}
-
-int recast_buildLayerRegions(struct recast_compactHeightfield *chf,
- const int borderSize, const int minRegionArea)
-{
- INIT_SCTX();
- return rcBuildLayerRegions(sctx, *(rcCompactHeightfield *) chf, borderSize,
- minRegionArea);
-}
-
-int recast_buildRegionsMonotone(struct recast_compactHeightfield *chf,
- const int borderSize, const int minRegionArea, const int mergeRegionArea)
-{
- INIT_SCTX();
- return rcBuildRegionsMonotone(sctx, *(rcCompactHeightfield *) chf, borderSize,
- minRegionArea, mergeRegionArea);
-}
-
-struct recast_contourSet *recast_newContourSet(void)
-{
- return (struct recast_contourSet *) rcAllocContourSet();
-}
-
-void recast_destroyContourSet(struct recast_contourSet *contourSet)
-{
- rcFreeContourSet((rcContourSet *) contourSet);
-}
-
-int recast_buildContours(struct recast_compactHeightfield *chf,
- const float maxError, const int maxEdgeLen, struct recast_contourSet *cset,
- const int buildFlags)
-{
- INIT_SCTX();
- return rcBuildContours(sctx, *(rcCompactHeightfield *) chf, maxError, maxEdgeLen, *(rcContourSet *) cset, buildFlags);
-}
-
-struct recast_polyMesh *recast_newPolyMesh(void)
-{
- return (recast_polyMesh *) rcAllocPolyMesh();
-}
-
-void recast_destroyPolyMesh(struct recast_polyMesh *polyMesh)
-{
- rcFreePolyMesh((rcPolyMesh *) polyMesh);
-}
-
-int recast_buildPolyMesh(struct recast_contourSet *cset, const int nvp, struct recast_polyMesh *mesh)
-{
- INIT_SCTX();
- return rcBuildPolyMesh(sctx, *(rcContourSet *) cset, nvp, *(rcPolyMesh *) mesh);
-}
-
-int recast_mergePolyMeshes(struct recast_polyMesh **meshes, const int nmeshes, struct recast_polyMesh *mesh)
-{
- INIT_SCTX();
- return rcMergePolyMeshes(sctx, (rcPolyMesh **) meshes, nmeshes, *(rcPolyMesh *) mesh);
-}
-
-int recast_copyPolyMesh(const struct recast_polyMesh *src, struct recast_polyMesh *dst)
-{
- INIT_SCTX();
- return rcCopyPolyMesh(sctx, *(const rcPolyMesh *) src, *(rcPolyMesh *) dst);
-}
-
-unsigned short *recast_polyMeshGetVerts(struct recast_polyMesh *mesh, int *nverts)
-{
- rcPolyMesh *pmesh = (rcPolyMesh *)mesh;
-
- if (nverts)
- *nverts = pmesh->nverts;
-
- return pmesh->verts;
-}
-
-void recast_polyMeshGetBoundbox(struct recast_polyMesh *mesh, float *bmin, float *bmax)
-{
- rcPolyMesh *pmesh = (rcPolyMesh *)mesh;
-
- if (bmin) {
- bmin[0] = pmesh->bmin[0];
- bmin[1] = pmesh->bmin[1];
- bmin[2] = pmesh->bmin[2];
- }
-
- if (bmax) {
- bmax[0] = pmesh->bmax[0];
- bmax[1] = pmesh->bmax[1];
- bmax[2] = pmesh->bmax[2];
- }
-}
-
-void recast_polyMeshGetCell(struct recast_polyMesh *mesh, float *cs, float *ch)
-{
- rcPolyMesh *pmesh = (rcPolyMesh *)mesh;
-
- if (cs)
- *cs = pmesh->cs;
-
- if (ch)
- *ch = pmesh->ch;
-}
-
-unsigned short *recast_polyMeshGetPolys(struct recast_polyMesh *mesh, int *npolys, int *nvp)
-{
- rcPolyMesh *pmesh = (rcPolyMesh *)mesh;
-
- if (npolys)
- *npolys = pmesh->npolys;
-
- if (nvp)
- *nvp = pmesh->nvp;
-
- return pmesh->polys;
-}
-
-struct recast_polyMeshDetail *recast_newPolyMeshDetail(void)
-{
- return (struct recast_polyMeshDetail *) rcAllocPolyMeshDetail();
-}
-
-void recast_destroyPolyMeshDetail(struct recast_polyMeshDetail *polyMeshDetail)
-{
- rcFreePolyMeshDetail((rcPolyMeshDetail *) polyMeshDetail);
-}
-
-int recast_buildPolyMeshDetail(const struct recast_polyMesh *mesh, const struct recast_compactHeightfield *chf,
- const float sampleDist, const float sampleMaxError, struct recast_polyMeshDetail *dmesh)
-{
- INIT_SCTX();
- return rcBuildPolyMeshDetail(sctx, *(rcPolyMesh *) mesh, *(rcCompactHeightfield *) chf,
- sampleDist, sampleMaxError, *(rcPolyMeshDetail *) dmesh);
-}
-
-int recast_mergePolyMeshDetails(struct recast_polyMeshDetail **meshes, const int nmeshes, struct recast_polyMeshDetail *mesh)
-{
- INIT_SCTX();
- return rcMergePolyMeshDetails(sctx, (rcPolyMeshDetail **) meshes, nmeshes, *(rcPolyMeshDetail *) mesh);
-}
-
-float *recast_polyMeshDetailGetVerts(struct recast_polyMeshDetail *mesh, int *nverts)
-{
- rcPolyMeshDetail *dmesh = (rcPolyMeshDetail *)mesh;
-
- if (nverts)
- *nverts = dmesh->nverts;
-
- return dmesh->verts;
-}
-
-unsigned char *recast_polyMeshDetailGetTris(struct recast_polyMeshDetail *mesh, int *ntris)
-{
- rcPolyMeshDetail *dmesh = (rcPolyMeshDetail *)mesh;
-
- if (ntris)
- *ntris = dmesh->ntris;
-
- return dmesh->tris;
-}
-
-unsigned int *recast_polyMeshDetailGetMeshes(struct recast_polyMeshDetail *mesh, int *nmeshes)
-{
- rcPolyMeshDetail *dmesh = (rcPolyMeshDetail *)mesh;
-
- if (nmeshes)
- *nmeshes = dmesh->nmeshes;
-
- return dmesh->meshes;
-}
-
diff --git a/extern/recastnavigation/recast-capi.h b/extern/recastnavigation/recast-capi.h
deleted file mode 100644
index 306bf79c167..00000000000
--- a/extern/recastnavigation/recast-capi.h
+++ /dev/null
@@ -1,181 +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) 2011 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Sergey Sharybin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef RECAST_C_API_H
-#define RECAST_C_API_H
-
-// for size_t
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct recast_polyMesh;
-struct recast_polyMeshDetail;
-struct recast_heightfield;
-struct recast_compactHeightfield;
-struct recast_heightfieldLayerSet;
-struct recast_contourSet;
-
-enum recast_BuildContoursFlags
-{
- RECAST_CONTOUR_TESS_WALL_EDGES = 0x01,
- RECAST_CONTOUR_TESS_AREA_EDGES = 0x02,
-};
-
-int recast_buildMeshAdjacency(unsigned short* polys, const int npolys,
- const int nverts, const int vertsPerPoly);
-
-void recast_calcBounds(const float *verts, int nv, float *bmin, float *bmax);
-
-void recast_calcGridSize(const float *bmin, const float *bmax, float cs, int *w, int *h);
-
-struct recast_heightfield *recast_newHeightfield(void);
-
-void recast_destroyHeightfield(struct recast_heightfield *heightfield);
-
-int recast_createHeightfield(struct recast_heightfield *hf, int width, int height,
- const float *bmin, const float* bmax, float cs, float ch);
-
-void recast_markWalkableTriangles(const float walkableSlopeAngle,const float *verts, int nv,
- const int *tris, int nt, unsigned char *areas);
-
-void recast_clearUnwalkableTriangles(const float walkableSlopeAngle, const float* verts, int nv,
- const int* tris, int nt, unsigned char* areas);
-
-int recast_addSpan(struct recast_heightfield *hf, const int x, const int y,
- const unsigned short smin, const unsigned short smax,
- const unsigned char area, const int flagMergeThr);
-
-int recast_rasterizeTriangle(const float* v0, const float* v1, const float* v2,
- const unsigned char area, struct recast_heightfield *solid,
- const int flagMergeThr);
-
-int recast_rasterizeTriangles(const float *verts, const int nv, const int *tris,
- const unsigned char *areas, const int nt, struct recast_heightfield *solid,
- const int flagMergeThr);
-
-void recast_filterLedgeSpans(const int walkableHeight, const int walkableClimb,
- struct recast_heightfield *solid);
-
-void recast_filterWalkableLowHeightSpans(int walkableHeight, struct recast_heightfield *solid);
-
-void recast_filterLowHangingWalkableObstacles(const int walkableClimb, struct recast_heightfield *solid);
-
-int recast_getHeightFieldSpanCount(struct recast_heightfield *hf);
-
-struct recast_heightfieldLayerSet *recast_newHeightfieldLayerSet(void);
-
-void recast_destroyHeightfieldLayerSet(struct recast_heightfieldLayerSet *lset);
-
-struct recast_compactHeightfield *recast_newCompactHeightfield(void);
-
-void recast_destroyCompactHeightfield(struct recast_compactHeightfield *compactHeightfield);
-
-int recast_buildCompactHeightfield(const int walkableHeight, const int walkableClimb,
- struct recast_heightfield *hf, struct recast_compactHeightfield *chf);
-
-int recast_erodeWalkableArea(int radius, struct recast_compactHeightfield *chf);
-
-int recast_medianFilterWalkableArea(struct recast_compactHeightfield *chf);
-
-void recast_markBoxArea(const float *bmin, const float *bmax, unsigned char areaId,
- struct recast_compactHeightfield *chf);
-
-void recast_markConvexPolyArea(const float* verts, const int nverts,
- const float hmin, const float hmax, unsigned char areaId,
- struct recast_compactHeightfield *chf);
-
-int recast_offsetPoly(const float* verts, const int nverts,
- const float offset, float *outVerts, const int maxOutVerts);
-
-void recast_markCylinderArea(const float* pos, const float r, const float h,
- unsigned char areaId, struct recast_compactHeightfield *chf);
-
-int recast_buildDistanceField(struct recast_compactHeightfield *chf);
-
-int recast_buildRegions(struct recast_compactHeightfield *chf,
- const int borderSize, const int minRegionArea, const int mergeRegionArea);
-
-int recast_buildLayerRegions(struct recast_compactHeightfield *chf,
- const int borderSize, const int minRegionArea);
-
-int recast_buildRegionsMonotone(struct recast_compactHeightfield *chf,
- const int borderSize, const int minRegionArea, const int mergeRegionArea);
-
-/* Contour set */
-
-struct recast_contourSet *recast_newContourSet(void);
-
-void recast_destroyContourSet(struct recast_contourSet *contourSet);
-
-int recast_buildContours(struct recast_compactHeightfield *chf,
- const float maxError, const int maxEdgeLen, struct recast_contourSet *cset,
- const int buildFlags);
-
-/* Poly mesh */
-
-struct recast_polyMesh *recast_newPolyMesh(void);
-
-void recast_destroyPolyMesh(struct recast_polyMesh *polyMesh);
-
-int recast_buildPolyMesh(struct recast_contourSet *cset, const int nvp, struct recast_polyMesh *mesh);
-
-int recast_mergePolyMeshes(struct recast_polyMesh **meshes, const int nmeshes, struct recast_polyMesh *mesh);
-
-int recast_copyPolyMesh(const struct recast_polyMesh *src, struct recast_polyMesh *dst);
-
-unsigned short *recast_polyMeshGetVerts(struct recast_polyMesh *mesh, int *nverts);
-
-void recast_polyMeshGetBoundbox(struct recast_polyMesh *mesh, float *bmin, float *bmax);
-
-void recast_polyMeshGetCell(struct recast_polyMesh *mesh, float *cs, float *ch);
-
-unsigned short *recast_polyMeshGetPolys(struct recast_polyMesh *mesh, int *npolys, int *nvp);
-
-/* Poly mesh detail */
-
-struct recast_polyMeshDetail *recast_newPolyMeshDetail(void);
-
-void recast_destroyPolyMeshDetail(struct recast_polyMeshDetail *polyMeshDetail);
-
-int recast_buildPolyMeshDetail(const struct recast_polyMesh *mesh, const struct recast_compactHeightfield *chf,
- const float sampleDist, const float sampleMaxError, struct recast_polyMeshDetail *dmesh);
-
-int recast_mergePolyMeshDetails(struct recast_polyMeshDetail **meshes, const int nmeshes, struct recast_polyMeshDetail *mesh);
-
-float *recast_polyMeshDetailGetVerts(struct recast_polyMeshDetail *mesh, int *nverts);
-
-unsigned char *recast_polyMeshDetailGetTris(struct recast_polyMeshDetail *mesh, int *ntris);
-
-unsigned int *recast_polyMeshDetailGetMeshes(struct recast_polyMeshDetail *mesh, int *nmeshes);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // RECAST_C_API_H
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index 4b3ccfc808a..1a050892836 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -36,10 +36,6 @@ add_subdirectory(glew-mx)
add_subdirectory(eigen)
add_subdirectory(gawain)
-if(WITH_GAMEENGINE_DECKLINK)
- add_subdirectory(decklink)
-endif()
-
if(WITH_AUDASPACE)
add_subdirectory(audaspace)
endif()
@@ -64,10 +60,6 @@ if(WITH_IK_ITASC)
add_subdirectory(itasc)
endif()
-if(WITH_GAMEENGINE)
- add_subdirectory(moto)
-endif()
-
if(WITH_CYCLES)
add_subdirectory(cycles)
endif()
@@ -85,10 +77,8 @@ if(WITH_OPENSUBDIV)
endif()
# only windows needs utf16 converter
-# gpudirect is a runtime interface to the nVidia's DVP driver, only for windows
if(WIN32)
add_subdirectory(utfconv)
- add_subdirectory(gpudirect)
endif()
if(WITH_OPENVDB)
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index 812915e6f95..dc0229e0748 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -29,7 +29,7 @@
#include <assert.h>
/* For 'isatty' to check for color. */
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
# include <unistd.h>
#endif
@@ -454,7 +454,7 @@ static void CLG_ctx_output_set(CLogContext *ctx, void *file_handle)
{
ctx->output_file = file_handle;
ctx->output = fileno(file_handle);
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
ctx->use_color = isatty(ctx->output);
#endif
}
diff --git a/intern/container/CMakeLists.txt b/intern/container/CMakeLists.txt
deleted file mode 100644
index 4743247af26..00000000000
--- a/intern/container/CMakeLists.txt
+++ /dev/null
@@ -1,41 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../guardedalloc
-)
-
-set(INC_SYS
-
-)
-
-set(SRC
- CTR_HashedPtr.h
- CTR_Map.h
-)
-
-# infact nothing to compile!
-blender_add_lib(bf_intern_ctr "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/container/CTR_HashedPtr.h b/intern/container/CTR_HashedPtr.h
deleted file mode 100644
index ee832eee153..00000000000
--- a/intern/container/CTR_HashedPtr.h
+++ /dev/null
@@ -1,62 +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 container/CTR_HashedPtr.h
- * \ingroup ctr
- */
-
-#ifndef __CTR_HASHEDPTR_H__
-#define __CTR_HASHEDPTR_H__
-
-#include <stdlib.h>
-
-inline unsigned int CTR_Hash(void *inDWord)
-{
- size_t key = (size_t)inDWord;
- return (unsigned int)(key ^ (key >> 4));
-}
-
-class CTR_HashedPtr
-{
- void *m_valptr;
-public:
- CTR_HashedPtr(void *val) : m_valptr(val) {
- }
- unsigned int hash() const {
- return CTR_Hash(m_valptr);
- }
- inline friend bool operator ==(const CTR_HashedPtr & rhs, const CTR_HashedPtr & lhs) {
- return rhs.m_valptr == lhs.m_valptr;
- }
- void *getValue() const {
- return m_valptr;
- }
-};
-
-#endif /* __CTR_HASHEDPTR_H__ */
-
diff --git a/intern/container/CTR_Map.h b/intern/container/CTR_Map.h
deleted file mode 100644
index c278fe5330c..00000000000
--- a/intern/container/CTR_Map.h
+++ /dev/null
@@ -1,181 +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 container/CTR_Map.h
- * \ingroup ctr
- */
-
-#ifndef __CTR_MAP_H__
-#define __CTR_MAP_H__
-
-template <class Key, class Value>
-class CTR_Map {
-private:
- struct Entry {
- Entry (Entry *next, Key key, Value value) :
- m_next(next),
- m_key(key),
- m_value(value) {
- }
-
- Entry *m_next;
- Key m_key;
- Value m_value;
- };
-
-public:
- CTR_Map(int num_buckets = 100) : m_num_buckets(num_buckets) {
- m_buckets = new Entry *[num_buckets];
- for (int i = 0; i < num_buckets; ++i) {
- m_buckets[i] = 0;
- }
- }
-
- CTR_Map(const CTR_Map& map)
- {
- m_num_buckets = map.m_num_buckets;
- m_buckets = new Entry *[m_num_buckets];
-
- for (int i = 0; i < m_num_buckets; ++i) {
- m_buckets[i] = 0;
-
- for (Entry *entry = map.m_buckets[i]; entry; entry = entry->m_next) {
- insert(entry->m_key, entry->m_value);
- }
- }
- }
-
- int size()
- {
- int count = 0;
- for (int i = 0; i < m_num_buckets; i++) {
- Entry *bucket = m_buckets[i];
- while (bucket) {
- bucket = bucket->m_next;
- count++;
- }
- }
- return count;
- }
-
- Value *at(int index)
- {
- int count = 0;
- for (int i = 0; i < m_num_buckets; i++) {
- Entry *bucket = m_buckets[i];
- while (bucket) {
- if (count == index) {
- return &bucket->m_value;
- }
- bucket = bucket->m_next;
- count++;
- }
- }
- return 0;
- }
-
- Key *getKey(int index)
- {
- int count = 0;
- for (int i = 0; i < m_num_buckets; i++) {
- Entry *bucket = m_buckets[i];
- while (bucket) {
- if (count == index) {
- return &bucket->m_key;
- }
- bucket = bucket->m_next;
- count++;
- }
- }
- return 0;
- }
-
- void clear()
- {
- for (int i = 0; i < m_num_buckets; ++i) {
- Entry *entry_ptr = m_buckets[i];
-
- while (entry_ptr != 0) {
- Entry *tmp_ptr = entry_ptr->m_next;
- delete entry_ptr;
- entry_ptr = tmp_ptr;
- }
- m_buckets[i] = 0;
- }
- }
-
- ~CTR_Map()
- {
- clear();
- delete[] m_buckets;
- }
-
- void insert(const Key& key, const Value& value)
- {
- Entry *entry_ptr = m_buckets[key.hash() % m_num_buckets];
- while ((entry_ptr != 0) && !(key == entry_ptr->m_key)) {
- entry_ptr = entry_ptr->m_next;
- }
-
- if (entry_ptr != 0) {
- entry_ptr->m_value = value;
- }
- else {
- Entry **bucket = &m_buckets[key.hash() % m_num_buckets];
- *bucket = new Entry(*bucket, key, value);
- }
- }
-
- void remove(const Key& key)
- {
- Entry **entry_ptr = &m_buckets[key.hash() % m_num_buckets];
- while ((*entry_ptr != 0) && !(key == (*entry_ptr)->m_key)) {
- entry_ptr = &(*entry_ptr)->m_next;
- }
-
- if (*entry_ptr != 0) {
- Entry *tmp_ptr = (*entry_ptr)->m_next;
- delete *entry_ptr;
- *entry_ptr = tmp_ptr;
- }
- }
-
- Value *operator[](Key key)
- {
- Entry *bucket = m_buckets[key.hash() % m_num_buckets];
- while ((bucket != 0) && !(key == bucket->m_key)) {
- bucket = bucket->m_next;
- }
- return bucket != 0 ? &bucket->m_value : 0;
- }
-
-private:
- int m_num_buckets;
- Entry **m_buckets;
-};
-
-#endif /* __CTR_MAP_H__ */
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 163131392e3..76564287e3f 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1307,177 +1307,12 @@ class CYCLES_MATERIAL_PT_viewport(CyclesButtonsPanel, Panel):
col.prop(mat, "diffuse_color", text="")
col.prop(mat, "alpha")
- col.separator()
- col.label("Alpha:")
- col.prop(mat.game_settings, "alpha_blend", text="")
-
col = split.column(align=True)
col.label("Specular:")
col.prop(mat, "specular_color", text="")
col.prop(mat, "specular_hardness", text="Hardness")
-class CYCLES_TEXTURE_PT_context(CyclesButtonsPanel, Panel):
- bl_label = ""
- bl_context = "texture"
- bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'CYCLES'}
-
- def draw(self, context):
- layout = self.layout
-
- tex = context.texture
- space = context.space_data
- pin_id = space.pin_id
- use_pin_id = space.use_pin_id
- user = context.texture_user
-
- space.use_limited_texture_context = False
-
- if not (use_pin_id and isinstance(pin_id, bpy.types.Texture)):
- pin_id = None
-
- if not pin_id:
- layout.template_texture_user()
-
- if user or pin_id:
- layout.separator()
-
- split = layout.split(percentage=0.65)
- col = split.column()
-
- if pin_id:
- col.template_ID(space, "pin_id")
- else:
- propname = context.texture_user_property.identifier
- col.template_ID(user, propname, new="texture.new")
-
- if tex:
- split = layout.split(percentage=0.2)
- split.label(text="Type:")
- split.prop(tex, "type", text="")
-
-
-class CYCLES_TEXTURE_PT_node(CyclesButtonsPanel, Panel):
- bl_label = "Node"
- bl_context = "texture"
-
- @classmethod
- def poll(cls, context):
- node = context.texture_node
- return node and CyclesButtonsPanel.poll(context)
-
- def draw(self, context):
- layout = self.layout
-
- node = context.texture_node
- ntree = node.id_data
- layout.template_node_view(ntree, node, None)
-
-
-class CYCLES_TEXTURE_PT_mapping(CyclesButtonsPanel, Panel):
- bl_label = "Mapping"
- bl_context = "texture"
-
- @classmethod
- def poll(cls, context):
- node = context.texture_node
- # TODO(sergey): perform a faster/nicer check?
- return node and hasattr(node, 'texture_mapping') and CyclesButtonsPanel.poll(context)
-
- def draw(self, context):
- layout = self.layout
-
- node = context.texture_node
-
- mapping = node.texture_mapping
-
- layout.prop(mapping, "vector_type", expand=True)
-
- row = layout.row()
-
- row.column().prop(mapping, "translation")
- row.column().prop(mapping, "rotation")
- row.column().prop(mapping, "scale")
-
- layout.label(text="Projection:")
-
- row = layout.row()
- row.prop(mapping, "mapping_x", text="")
- row.prop(mapping, "mapping_y", text="")
- row.prop(mapping, "mapping_z", text="")
-
-
-class CYCLES_TEXTURE_PT_colors(CyclesButtonsPanel, Panel):
- bl_label = "Color"
- bl_context = "texture"
- bl_options = {'DEFAULT_CLOSED'}
-
- @classmethod
- def poll(cls, context):
- # node = context.texture_node
- return False
- # return node and CyclesButtonsPanel.poll(context)
-
- def draw(self, context):
- layout = self.layout
-
- node = context.texture_node
-
- mapping = node.color_mapping
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Blend:")
- col.prop(mapping, "blend_type", text="")
- col.prop(mapping, "blend_factor", text="Factor")
- col.prop(mapping, "blend_color", text="")
-
- col = split.column()
- col.label(text="Adjust:")
- col.prop(mapping, "brightness")
- col.prop(mapping, "contrast")
- col.prop(mapping, "saturation")
-
- layout.separator()
-
- layout.prop(mapping, "use_color_ramp", text="Ramp")
- if mapping.use_color_ramp:
- layout.template_color_ramp(mapping, "color_ramp", expand=True)
-
-
-class CYCLES_PARTICLE_PT_textures(CyclesButtonsPanel, Panel):
- bl_label = "Textures"
- bl_context = "particle"
- bl_options = {'DEFAULT_CLOSED'}
-
- @classmethod
- def poll(cls, context):
- psys = context.particle_system
- return psys and CyclesButtonsPanel.poll(context)
-
- def draw(self, context):
- layout = self.layout
-
- psys = context.particle_system
- part = psys.settings
-
- row = layout.row()
- row.template_list("TEXTURE_UL_texslots", "", part, "texture_slots", part, "active_texture_index", rows=2)
-
- col = row.column(align=True)
- col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
- col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
- col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
-
- if not part.active_texture:
- layout.template_ID(part, "active_texture", new="texture.new")
- else:
- slot = part.texture_slots[part.active_texture_index]
- layout.template_ID(slot, "texture", new="texture.new")
-
-
class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
bl_label = "Bake"
bl_context = "render"
@@ -1490,66 +1325,83 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
scene = context.scene
cscene = scene.cycles
cbk = scene.render.bake
+ rd = scene.render
- layout.operator("object.bake", icon='RENDER_STILL').type = cscene.bake_type
+ if rd.use_bake_multires:
+ layout.operator("object.bake_image", icon='RENDER_STILL')
+ else:
+ layout.operator("object.bake", icon='RENDER_STILL').type = cscene.bake_type
col = layout.column()
- col.prop(cscene, "bake_type")
+ col.prop(rd, "use_bake_multires")
+ if rd.use_bake_multires:
+ col.prop(rd, "bake_type")
- col = layout.column()
+ split = layout.split()
- if cscene.bake_type == 'NORMAL':
- col.prop(cbk, "normal_space", text="Space")
+ col = split.column()
+ col.prop(rd, "bake_margin")
+ col.prop(rd, "use_bake_clear")
- row = col.row(align=True)
- row.label(text="Swizzle:")
- row.prop(cbk, "normal_r", text="")
- row.prop(cbk, "normal_g", text="")
- row.prop(cbk, "normal_b", text="")
+ col = split.column()
+ if rd.bake_type == 'DISPLACEMENT':
+ col.prop(rd, "use_bake_lores_mesh")
+ else:
+ col.prop(cscene, "bake_type")
- elif cscene.bake_type == 'COMBINED':
- row = col.row(align=True)
- row.prop(cbk, "use_pass_direct", toggle=True)
- row.prop(cbk, "use_pass_indirect", toggle=True)
+ col = layout.column()
- split = col.split()
- split.active = cbk.use_pass_direct or cbk.use_pass_indirect
+ if cscene.bake_type == 'NORMAL':
+ col.prop(cbk, "normal_space", text="Space")
- col = split.column()
- col.prop(cbk, "use_pass_diffuse")
- col.prop(cbk, "use_pass_glossy")
- col.prop(cbk, "use_pass_transmission")
+ row = col.row(align=True)
+ row.label(text="Swizzle:")
+ row.prop(cbk, "normal_r", text="")
+ row.prop(cbk, "normal_g", text="")
+ row.prop(cbk, "normal_b", text="")
- col = split.column()
- col.prop(cbk, "use_pass_subsurface")
- col.prop(cbk, "use_pass_ambient_occlusion")
- col.prop(cbk, "use_pass_emit")
+ elif cscene.bake_type == 'COMBINED':
+ row = col.row(align=True)
+ row.prop(cbk, "use_pass_direct", toggle=True)
+ row.prop(cbk, "use_pass_indirect", toggle=True)
- elif cscene.bake_type in {'DIFFUSE', 'GLOSSY', 'TRANSMISSION', 'SUBSURFACE'}:
- row = col.row(align=True)
- row.prop(cbk, "use_pass_direct", toggle=True)
- row.prop(cbk, "use_pass_indirect", toggle=True)
- row.prop(cbk, "use_pass_color", toggle=True)
+ split = col.split()
+ split.active = cbk.use_pass_direct or cbk.use_pass_indirect
- layout.separator()
+ col = split.column()
+ col.prop(cbk, "use_pass_diffuse")
+ col.prop(cbk, "use_pass_glossy")
+ col.prop(cbk, "use_pass_transmission")
- split = layout.split()
+ col = split.column()
+ col.prop(cbk, "use_pass_subsurface")
+ col.prop(cbk, "use_pass_ambient_occlusion")
+ col.prop(cbk, "use_pass_emit")
- col = split.column()
- col.prop(cbk, "margin")
- col.prop(cbk, "use_clear")
+ elif cscene.bake_type in {'DIFFUSE', 'GLOSSY', 'TRANSMISSION', 'SUBSURFACE'}:
+ row = col.row(align=True)
+ row.prop(cbk, "use_pass_direct", toggle=True)
+ row.prop(cbk, "use_pass_indirect", toggle=True)
+ row.prop(cbk, "use_pass_color", toggle=True)
- col = split.column()
- col.prop(cbk, "use_selected_to_active")
- sub = col.column()
- sub.active = cbk.use_selected_to_active
- sub.prop(cbk, "use_cage", text="Cage")
- if cbk.use_cage:
- sub.prop(cbk, "cage_extrusion", text="Extrusion")
- sub.prop_search(cbk, "cage_object", scene, "objects", text="")
- else:
- sub.prop(cbk, "cage_extrusion", text="Ray Distance")
+ layout.separator()
+ split = layout.split()
+
+ col = split.column()
+ col.prop(cbk, "margin")
+ col.prop(cbk, "use_clear")
+
+ col = split.column()
+ col.prop(cbk, "use_selected_to_active")
+ sub = col.column()
+ sub.active = cbk.use_selected_to_active
+ sub.prop(cbk, "use_cage", text="Cage")
+ if cbk.use_cage:
+ sub.prop(cbk, "cage_extrusion", text="Extrusion")
+ sub.prop_search(cbk, "cage_object", scene, "objects", text="")
+ else:
+ sub.prop(cbk, "cage_extrusion", text="Ray Distance")
class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel):
bl_label = "Debug"
@@ -1731,47 +1583,14 @@ def get_panels():
'DATA_PT_falloff_curve',
'DATA_PT_lamp',
'DATA_PT_preview',
- 'DATA_PT_shadow',
'DATA_PT_spot',
- 'DATA_PT_sunsky',
'MATERIAL_PT_context_material',
- 'MATERIAL_PT_diffuse',
- 'MATERIAL_PT_flare',
- 'MATERIAL_PT_halo',
- 'MATERIAL_PT_mirror',
- 'MATERIAL_PT_options',
- 'MATERIAL_PT_pipeline',
'MATERIAL_PT_preview',
- 'MATERIAL_PT_shading',
- 'MATERIAL_PT_shadow',
- 'MATERIAL_PT_specular',
- 'MATERIAL_PT_sss',
- 'MATERIAL_PT_strand',
- 'MATERIAL_PT_transp',
- 'MATERIAL_PT_volume_density',
- 'MATERIAL_PT_volume_integration',
- 'MATERIAL_PT_volume_lighting',
- 'MATERIAL_PT_volume_options',
- 'MATERIAL_PT_volume_shading',
- 'MATERIAL_PT_volume_transp',
'VIEWLAYER_PT_layer_options',
'VIEWLAYER_PT_layer_passes',
'VIEWLAYER_PT_views',
- 'RENDER_PT_antialiasing',
- 'RENDER_PT_bake',
- 'RENDER_PT_motion_blur',
- 'RENDER_PT_performance',
'RENDER_PT_post_processing',
- 'RENDER_PT_shading',
'SCENE_PT_simplify',
- 'TEXTURE_PT_context_texture',
- 'WORLD_PT_ambient_occlusion',
- 'WORLD_PT_environment_lighting',
- 'WORLD_PT_gather',
- 'WORLD_PT_indirect_lighting',
- 'WORLD_PT_mist',
- 'WORLD_PT_preview',
- 'WORLD_PT_world'
}
panels = []
@@ -1819,11 +1638,6 @@ classes = (
CYCLES_MATERIAL_PT_displacement,
CYCLES_MATERIAL_PT_settings,
CYCLES_MATERIAL_PT_viewport,
- CYCLES_TEXTURE_PT_context,
- CYCLES_TEXTURE_PT_node,
- CYCLES_TEXTURE_PT_mapping,
- CYCLES_TEXTURE_PT_colors,
- CYCLES_PARTICLE_PT_textures,
CYCLES_RENDER_PT_bake,
CYCLES_RENDER_PT_debug,
CYCLES_PARTICLE_PT_curve_settings,
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 8eec7c44928..95582b15d63 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -1282,8 +1282,8 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
else {
/* TODO: fix point density to work with new view layer depsgraph */
#if 0
- /* We originally were passing view_layer here but in reality we need a whole EvaluationContext or at the
- * very least a dpesgraph to pass to the RE_point_density_minmax() function.
+ /* We originally were passing view_layer here but in reality we need a
+ * a depsgraph to pass to the RE_point_density_minmax() function.
*/
/* TODO(sergey): Check we're indeed in shader node tree. */
PointerRNA ptr;
diff --git a/intern/decklink/CMakeLists.txt b/intern/decklink/CMakeLists.txt
deleted file mode 100644
index b7727cbc32a..00000000000
--- a/intern/decklink/CMakeLists.txt
+++ /dev/null
@@ -1,58 +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) 2015, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Blender Foundation.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
-)
-
-set(INC_SYS
-)
-
-set(SRC
- DeckLinkAPI.cpp
- DeckLinkAPI.h
-)
-
-if(WIN32)
- list(APPEND SRC
- win/DeckLinkAPI_h.h
- win/DeckLinkAPI_i.c
- )
-endif()
-
-if(UNIX AND NOT APPLE)
- list(APPEND SRC
- linux/DeckLinkAPI.h
- linux/DeckLinkAPIConfiguration.h
- linux/DeckLinkAPIDeckControl.h
- linux/DeckLinkAPIDiscovery.h
- linux/DeckLinkAPIDispatch.cpp
- linux/DeckLinkAPIModes.h
- linux/DeckLinkAPIVersion.h
- linux/DeckLinkAPITypes.h
- linux/LinuxCOM.h
- )
-endif()
-
-blender_add_lib(bf_intern_decklink "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/decklink/DeckLinkAPI.cpp b/intern/decklink/DeckLinkAPI.cpp
deleted file mode 100644
index aff25af70eb..00000000000
--- a/intern/decklink/DeckLinkAPI.cpp
+++ /dev/null
@@ -1,50 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file decklink/DeckLinkAPI.cpp
- * \ingroup decklink
- */
-
-#include "DeckLinkAPI.h"
-
-#ifdef WIN32
-IDeckLinkIterator* BMD_CreateDeckLinkIterator(void)
-{
- HRESULT result;
- IDeckLinkIterator* pDLIterator = NULL;
-
- result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&pDLIterator);
- if (FAILED(result))
- return NULL;
- return pDLIterator;
-}
-#else
-IDeckLinkIterator* BMD_CreateDeckLinkIterator(void)
-{
- return CreateDeckLinkIteratorInstance();
-}
-#endif // WIN32
diff --git a/intern/decklink/DeckLinkAPI.h b/intern/decklink/DeckLinkAPI.h
deleted file mode 100644
index 2a429c18c3c..00000000000
--- a/intern/decklink/DeckLinkAPI.h
+++ /dev/null
@@ -1,56 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file decklink/DeckLinkAPI.h
- * \ingroup decklink
- */
-
-#ifndef __DECKLINKAPI_H__
-#define __DECKLINKAPI_H__
-
-/* Include the OS specific Declink headers */
-
-#ifdef WIN32
-# include <windows.h>
-# include <objbase.h>
-# include <comutil.h>
-# include "win/DeckLinkAPI_h.h"
- typedef unsigned int dl_size_t;
-#elif defined(__APPLE__)
-# error "Decklink not supported in OSX"
-#else
-# include "linux/DeckLinkAPI.h"
- /* Windows COM API uses BOOL, linux uses bool */
-# define BOOL bool
- typedef uint32_t dl_size_t;
-#endif
-
-
-/* OS independent function to get the device iterator */
-IDeckLinkIterator* BMD_CreateDeckLinkIterator(void);
-
-#endif /* __DECKLINKAPI_H__ */
diff --git a/intern/decklink/linux/DeckLinkAPI.h b/intern/decklink/linux/DeckLinkAPI.h
deleted file mode 100644
index 08bfba39994..00000000000
--- a/intern/decklink/linux/DeckLinkAPI.h
+++ /dev/null
@@ -1,767 +0,0 @@
-/* -LICENSE-START-
-** Copyright (c) 2014 Blackmagic Design
-**
-** Permission is hereby granted, free of charge, to any person or organization
-** obtaining a copy of the software and accompanying documentation covered by
-** this license (the "Software") to use, reproduce, display, distribute,
-** execute, and transmit the Software, and to prepare derivative works of the
-** Software, and to permit third-parties to whom the Software is furnished to
-** do so, all subject to the following:
-**
-** The copyright notices in the Software and this entire statement, including
-** the above license grant, this restriction and the following disclaimer,
-** must be included in all copies of the Software, in whole or in part, and
-** all derivative works of the Software, unless such copies or derivative
-** works are solely in the form of machine-executable object code generated by
-** a source language processor.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-** DEALINGS IN THE SOFTWARE.
-** -LICENSE-END-
-*/
-
-#ifndef BMD_DECKLINKAPI_H
-#define BMD_DECKLINKAPI_H
-
-
-#ifndef BMD_CONST
- #if defined(_MSC_VER)
- #define BMD_CONST __declspec(selectany) static const
- #else
- #define BMD_CONST static const
- #endif
-#endif
-
-/* DeckLink API */
-
-#include <stdint.h>
-#include "LinuxCOM.h"
-
-#include "DeckLinkAPITypes.h"
-#include "DeckLinkAPIModes.h"
-#include "DeckLinkAPIDiscovery.h"
-#include "DeckLinkAPIConfiguration.h"
-#include "DeckLinkAPIDeckControl.h"
-
-#define BLACKMAGIC_DECKLINK_API_MAGIC 1
-
-// Type Declarations
-
-
-// Interface ID Declarations
-
-BMD_CONST REFIID IID_IDeckLinkVideoOutputCallback = /* 20AA5225-1958-47CB-820B-80A8D521A6EE */ {0x20,0xAA,0x52,0x25,0x19,0x58,0x47,0xCB,0x82,0x0B,0x80,0xA8,0xD5,0x21,0xA6,0xEE};
-BMD_CONST REFIID IID_IDeckLinkInputCallback = /* DD04E5EC-7415-42AB-AE4A-E80C4DFC044A */ {0xDD,0x04,0xE5,0xEC,0x74,0x15,0x42,0xAB,0xAE,0x4A,0xE8,0x0C,0x4D,0xFC,0x04,0x4A};
-BMD_CONST REFIID IID_IDeckLinkMemoryAllocator = /* B36EB6E7-9D29-4AA8-92EF-843B87A289E8 */ {0xB3,0x6E,0xB6,0xE7,0x9D,0x29,0x4A,0xA8,0x92,0xEF,0x84,0x3B,0x87,0xA2,0x89,0xE8};
-BMD_CONST REFIID IID_IDeckLinkAudioOutputCallback = /* 403C681B-7F46-4A12-B993-2BB127084EE6 */ {0x40,0x3C,0x68,0x1B,0x7F,0x46,0x4A,0x12,0xB9,0x93,0x2B,0xB1,0x27,0x08,0x4E,0xE6};
-BMD_CONST REFIID IID_IDeckLinkIterator = /* 50FB36CD-3063-4B73-BDBB-958087F2D8BA */ {0x50,0xFB,0x36,0xCD,0x30,0x63,0x4B,0x73,0xBD,0xBB,0x95,0x80,0x87,0xF2,0xD8,0xBA};
-BMD_CONST REFIID IID_IDeckLinkAPIInformation = /* 7BEA3C68-730D-4322-AF34-8A7152B532A4 */ {0x7B,0xEA,0x3C,0x68,0x73,0x0D,0x43,0x22,0xAF,0x34,0x8A,0x71,0x52,0xB5,0x32,0xA4};
-BMD_CONST REFIID IID_IDeckLinkOutput = /* CC5C8A6E-3F2F-4B3A-87EA-FD78AF300564 */ {0xCC,0x5C,0x8A,0x6E,0x3F,0x2F,0x4B,0x3A,0x87,0xEA,0xFD,0x78,0xAF,0x30,0x05,0x64};
-BMD_CONST REFIID IID_IDeckLinkInput = /* AF22762B-DFAC-4846-AA79-FA8883560995 */ {0xAF,0x22,0x76,0x2B,0xDF,0xAC,0x48,0x46,0xAA,0x79,0xFA,0x88,0x83,0x56,0x09,0x95};
-BMD_CONST REFIID IID_IDeckLinkVideoFrame = /* 3F716FE0-F023-4111-BE5D-EF4414C05B17 */ {0x3F,0x71,0x6F,0xE0,0xF0,0x23,0x41,0x11,0xBE,0x5D,0xEF,0x44,0x14,0xC0,0x5B,0x17};
-BMD_CONST REFIID IID_IDeckLinkMutableVideoFrame = /* 69E2639F-40DA-4E19-B6F2-20ACE815C390 */ {0x69,0xE2,0x63,0x9F,0x40,0xDA,0x4E,0x19,0xB6,0xF2,0x20,0xAC,0xE8,0x15,0xC3,0x90};
-BMD_CONST REFIID IID_IDeckLinkVideoFrame3DExtensions = /* DA0F7E4A-EDC7-48A8-9CDD-2DB51C729CD7 */ {0xDA,0x0F,0x7E,0x4A,0xED,0xC7,0x48,0xA8,0x9C,0xDD,0x2D,0xB5,0x1C,0x72,0x9C,0xD7};
-BMD_CONST REFIID IID_IDeckLinkVideoInputFrame = /* 05CFE374-537C-4094-9A57-680525118F44 */ {0x05,0xCF,0xE3,0x74,0x53,0x7C,0x40,0x94,0x9A,0x57,0x68,0x05,0x25,0x11,0x8F,0x44};
-BMD_CONST REFIID IID_IDeckLinkVideoFrameAncillary = /* 732E723C-D1A4-4E29-9E8E-4A88797A0004 */ {0x73,0x2E,0x72,0x3C,0xD1,0xA4,0x4E,0x29,0x9E,0x8E,0x4A,0x88,0x79,0x7A,0x00,0x04};
-BMD_CONST REFIID IID_IDeckLinkAudioInputPacket = /* E43D5870-2894-11DE-8C30-0800200C9A66 */ {0xE4,0x3D,0x58,0x70,0x28,0x94,0x11,0xDE,0x8C,0x30,0x08,0x00,0x20,0x0C,0x9A,0x66};
-BMD_CONST REFIID IID_IDeckLinkScreenPreviewCallback = /* B1D3F49A-85FE-4C5D-95C8-0B5D5DCCD438 */ {0xB1,0xD3,0xF4,0x9A,0x85,0xFE,0x4C,0x5D,0x95,0xC8,0x0B,0x5D,0x5D,0xCC,0xD4,0x38};
-BMD_CONST REFIID IID_IDeckLinkGLScreenPreviewHelper = /* 504E2209-CAC7-4C1A-9FB4-C5BB6274D22F */ {0x50,0x4E,0x22,0x09,0xCA,0xC7,0x4C,0x1A,0x9F,0xB4,0xC5,0xBB,0x62,0x74,0xD2,0x2F};
-BMD_CONST REFIID IID_IDeckLinkNotificationCallback = /* B002A1EC-070D-4288-8289-BD5D36E5FF0D */ {0xB0,0x02,0xA1,0xEC,0x07,0x0D,0x42,0x88,0x82,0x89,0xBD,0x5D,0x36,0xE5,0xFF,0x0D};
-BMD_CONST REFIID IID_IDeckLinkNotification = /* 0A1FB207-E215-441B-9B19-6FA1575946C5 */ {0x0A,0x1F,0xB2,0x07,0xE2,0x15,0x44,0x1B,0x9B,0x19,0x6F,0xA1,0x57,0x59,0x46,0xC5};
-BMD_CONST REFIID IID_IDeckLinkAttributes = /* ABC11843-D966-44CB-96E2-A1CB5D3135C4 */ {0xAB,0xC1,0x18,0x43,0xD9,0x66,0x44,0xCB,0x96,0xE2,0xA1,0xCB,0x5D,0x31,0x35,0xC4};
-BMD_CONST REFIID IID_IDeckLinkKeyer = /* 89AFCAF5-65F8-421E-98F7-96FE5F5BFBA3 */ {0x89,0xAF,0xCA,0xF5,0x65,0xF8,0x42,0x1E,0x98,0xF7,0x96,0xFE,0x5F,0x5B,0xFB,0xA3};
-BMD_CONST REFIID IID_IDeckLinkVideoConversion = /* 3BBCB8A2-DA2C-42D9-B5D8-88083644E99A */ {0x3B,0xBC,0xB8,0xA2,0xDA,0x2C,0x42,0xD9,0xB5,0xD8,0x88,0x08,0x36,0x44,0xE9,0x9A};
-BMD_CONST REFIID IID_IDeckLinkDeviceNotificationCallback = /* 4997053B-0ADF-4CC8-AC70-7A50C4BE728F */ {0x49,0x97,0x05,0x3B,0x0A,0xDF,0x4C,0xC8,0xAC,0x70,0x7A,0x50,0xC4,0xBE,0x72,0x8F};
-BMD_CONST REFIID IID_IDeckLinkDiscovery = /* CDBF631C-BC76-45FA-B44D-C55059BC6101 */ {0xCD,0xBF,0x63,0x1C,0xBC,0x76,0x45,0xFA,0xB4,0x4D,0xC5,0x50,0x59,0xBC,0x61,0x01};
-
-/* Enum BMDVideoOutputFlags - Flags to control the output of ancillary data along with video. */
-
-typedef uint32_t BMDVideoOutputFlags;
-enum _BMDVideoOutputFlags {
- bmdVideoOutputFlagDefault = 0,
- bmdVideoOutputVANC = 1 << 0,
- bmdVideoOutputVITC = 1 << 1,
- bmdVideoOutputRP188 = 1 << 2,
- bmdVideoOutputDualStream3D = 1 << 4
-};
-
-/* Enum BMDFrameFlags - Frame flags */
-
-typedef uint32_t BMDFrameFlags;
-enum _BMDFrameFlags {
- bmdFrameFlagDefault = 0,
- bmdFrameFlagFlipVertical = 1 << 0,
-
- /* Flags that are applicable only to instances of IDeckLinkVideoInputFrame */
-
- bmdFrameHasNoInputSource = 1 << 31
-};
-
-/* Enum BMDVideoInputFlags - Flags applicable to video input */
-
-typedef uint32_t BMDVideoInputFlags;
-enum _BMDVideoInputFlags {
- bmdVideoInputFlagDefault = 0,
- bmdVideoInputEnableFormatDetection = 1 << 0,
- bmdVideoInputDualStream3D = 1 << 1
-};
-
-/* Enum BMDVideoInputFormatChangedEvents - Bitmask passed to the VideoInputFormatChanged notification to identify the properties of the input signal that have changed */
-
-typedef uint32_t BMDVideoInputFormatChangedEvents;
-enum _BMDVideoInputFormatChangedEvents {
- bmdVideoInputDisplayModeChanged = 1 << 0,
- bmdVideoInputFieldDominanceChanged = 1 << 1,
- bmdVideoInputColorspaceChanged = 1 << 2
-};
-
-/* Enum BMDDetectedVideoInputFormatFlags - Flags passed to the VideoInputFormatChanged notification to describe the detected video input signal */
-
-typedef uint32_t BMDDetectedVideoInputFormatFlags;
-enum _BMDDetectedVideoInputFormatFlags {
- bmdDetectedVideoInputYCbCr422 = 1 << 0,
- bmdDetectedVideoInputRGB444 = 1 << 1,
- bmdDetectedVideoInputDualStream3D = 1 << 2
-};
-
-/* Enum BMDDeckLinkCapturePassthroughMode - Enumerates whether the video output is electrically connected to the video input or if the clean switching mode is enabled */
-
-typedef uint32_t BMDDeckLinkCapturePassthroughMode;
-enum _BMDDeckLinkCapturePassthroughMode {
- bmdDeckLinkCapturePassthroughModeDirect = /* 'pdir' */ 0x70646972,
- bmdDeckLinkCapturePassthroughModeCleanSwitch = /* 'pcln' */ 0x70636C6E
-};
-
-/* Enum BMDOutputFrameCompletionResult - Frame Completion Callback */
-
-typedef uint32_t BMDOutputFrameCompletionResult;
-enum _BMDOutputFrameCompletionResult {
- bmdOutputFrameCompleted,
- bmdOutputFrameDisplayedLate,
- bmdOutputFrameDropped,
- bmdOutputFrameFlushed
-};
-
-/* Enum BMDReferenceStatus - GenLock input status */
-
-typedef uint32_t BMDReferenceStatus;
-enum _BMDReferenceStatus {
- bmdReferenceNotSupportedByHardware = 1 << 0,
- bmdReferenceLocked = 1 << 1
-};
-
-/* Enum BMDAudioSampleRate - Audio sample rates supported for output/input */
-
-typedef uint32_t BMDAudioSampleRate;
-enum _BMDAudioSampleRate {
- bmdAudioSampleRate48kHz = 48000
-};
-
-/* Enum BMDAudioSampleType - Audio sample sizes supported for output/input */
-
-typedef uint32_t BMDAudioSampleType;
-enum _BMDAudioSampleType {
- bmdAudioSampleType16bitInteger = 16,
- bmdAudioSampleType32bitInteger = 32
-};
-
-/* Enum BMDAudioOutputStreamType - Audio output stream type */
-
-typedef uint32_t BMDAudioOutputStreamType;
-enum _BMDAudioOutputStreamType {
- bmdAudioOutputStreamContinuous,
- bmdAudioOutputStreamContinuousDontResample,
- bmdAudioOutputStreamTimestamped
-};
-
-/* Enum BMDDisplayModeSupport - Output mode supported flags */
-
-typedef uint32_t BMDDisplayModeSupport;
-enum _BMDDisplayModeSupport {
- bmdDisplayModeNotSupported = 0,
- bmdDisplayModeSupported,
- bmdDisplayModeSupportedWithConversion
-};
-
-/* Enum BMDTimecodeFormat - Timecode formats for frame metadata */
-
-typedef uint32_t BMDTimecodeFormat;
-enum _BMDTimecodeFormat {
- bmdTimecodeRP188VITC1 = /* 'rpv1' */ 0x72707631, // RP188 timecode where DBB1 equals VITC1 (line 9)
- bmdTimecodeRP188VITC2 = /* 'rp12' */ 0x72703132, // RP188 timecode where DBB1 equals VITC2 (line 9 for progressive or line 571 for interlaced/PsF)
- bmdTimecodeRP188LTC = /* 'rplt' */ 0x72706C74, // RP188 timecode where DBB1 equals LTC (line 10)
- bmdTimecodeRP188Any = /* 'rp18' */ 0x72703138, // For capture: return the first valid timecode in {VITC1, LTC ,VITC2} - For playback: set the timecode as VITC1
- bmdTimecodeVITC = /* 'vitc' */ 0x76697463,
- bmdTimecodeVITCField2 = /* 'vit2' */ 0x76697432,
- bmdTimecodeSerial = /* 'seri' */ 0x73657269
-};
-
-/* Enum BMDAnalogVideoFlags - Analog video display flags */
-
-typedef uint32_t BMDAnalogVideoFlags;
-enum _BMDAnalogVideoFlags {
- bmdAnalogVideoFlagCompositeSetup75 = 1 << 0,
- bmdAnalogVideoFlagComponentBetacamLevels = 1 << 1
-};
-
-/* Enum BMDAudioOutputAnalogAESSwitch - Audio output Analog/AESEBU switch */
-
-typedef uint32_t BMDAudioOutputAnalogAESSwitch;
-enum _BMDAudioOutputAnalogAESSwitch {
- bmdAudioOutputSwitchAESEBU = /* 'aes ' */ 0x61657320,
- bmdAudioOutputSwitchAnalog = /* 'anlg' */ 0x616E6C67
-};
-
-/* Enum BMDVideoOutputConversionMode - Video/audio conversion mode */
-
-typedef uint32_t BMDVideoOutputConversionMode;
-enum _BMDVideoOutputConversionMode {
- bmdNoVideoOutputConversion = /* 'none' */ 0x6E6F6E65,
- bmdVideoOutputLetterboxDownconversion = /* 'ltbx' */ 0x6C746278,
- bmdVideoOutputAnamorphicDownconversion = /* 'amph' */ 0x616D7068,
- bmdVideoOutputHD720toHD1080Conversion = /* '720c' */ 0x37323063,
- bmdVideoOutputHardwareLetterboxDownconversion = /* 'HWlb' */ 0x48576C62,
- bmdVideoOutputHardwareAnamorphicDownconversion = /* 'HWam' */ 0x4857616D,
- bmdVideoOutputHardwareCenterCutDownconversion = /* 'HWcc' */ 0x48576363,
- bmdVideoOutputHardware720p1080pCrossconversion = /* 'xcap' */ 0x78636170,
- bmdVideoOutputHardwareAnamorphic720pUpconversion = /* 'ua7p' */ 0x75613770,
- bmdVideoOutputHardwareAnamorphic1080iUpconversion = /* 'ua1i' */ 0x75613169,
- bmdVideoOutputHardwareAnamorphic149To720pUpconversion = /* 'u47p' */ 0x75343770,
- bmdVideoOutputHardwareAnamorphic149To1080iUpconversion = /* 'u41i' */ 0x75343169,
- bmdVideoOutputHardwarePillarbox720pUpconversion = /* 'up7p' */ 0x75703770,
- bmdVideoOutputHardwarePillarbox1080iUpconversion = /* 'up1i' */ 0x75703169
-};
-
-/* Enum BMDVideoInputConversionMode - Video input conversion mode */
-
-typedef uint32_t BMDVideoInputConversionMode;
-enum _BMDVideoInputConversionMode {
- bmdNoVideoInputConversion = /* 'none' */ 0x6E6F6E65,
- bmdVideoInputLetterboxDownconversionFromHD1080 = /* '10lb' */ 0x31306C62,
- bmdVideoInputAnamorphicDownconversionFromHD1080 = /* '10am' */ 0x3130616D,
- bmdVideoInputLetterboxDownconversionFromHD720 = /* '72lb' */ 0x37326C62,
- bmdVideoInputAnamorphicDownconversionFromHD720 = /* '72am' */ 0x3732616D,
- bmdVideoInputLetterboxUpconversion = /* 'lbup' */ 0x6C627570,
- bmdVideoInputAnamorphicUpconversion = /* 'amup' */ 0x616D7570
-};
-
-/* Enum BMDVideo3DPackingFormat - Video 3D packing format */
-
-typedef uint32_t BMDVideo3DPackingFormat;
-enum _BMDVideo3DPackingFormat {
- bmdVideo3DPackingSidebySideHalf = /* 'sbsh' */ 0x73627368,
- bmdVideo3DPackingLinebyLine = /* 'lbyl' */ 0x6C62796C,
- bmdVideo3DPackingTopAndBottom = /* 'tabo' */ 0x7461626F,
- bmdVideo3DPackingFramePacking = /* 'frpk' */ 0x6672706B,
- bmdVideo3DPackingLeftOnly = /* 'left' */ 0x6C656674,
- bmdVideo3DPackingRightOnly = /* 'righ' */ 0x72696768
-};
-
-/* Enum BMDIdleVideoOutputOperation - Video output operation when not playing video */
-
-typedef uint32_t BMDIdleVideoOutputOperation;
-enum _BMDIdleVideoOutputOperation {
- bmdIdleVideoOutputBlack = /* 'blac' */ 0x626C6163,
- bmdIdleVideoOutputLastFrame = /* 'lafa' */ 0x6C616661,
- bmdIdleVideoOutputDesktop = /* 'desk' */ 0x6465736B
-};
-
-/* Enum BMDDeckLinkAttributeID - DeckLink Attribute ID */
-
-typedef uint32_t BMDDeckLinkAttributeID;
-enum _BMDDeckLinkAttributeID {
-
- /* Flags */
-
- BMDDeckLinkSupportsInternalKeying = /* 'keyi' */ 0x6B657969,
- BMDDeckLinkSupportsExternalKeying = /* 'keye' */ 0x6B657965,
- BMDDeckLinkSupportsHDKeying = /* 'keyh' */ 0x6B657968,
- BMDDeckLinkSupportsInputFormatDetection = /* 'infd' */ 0x696E6664,
- BMDDeckLinkHasReferenceInput = /* 'hrin' */ 0x6872696E,
- BMDDeckLinkHasSerialPort = /* 'hspt' */ 0x68737074,
- BMDDeckLinkHasAnalogVideoOutputGain = /* 'avog' */ 0x61766F67,
- BMDDeckLinkCanOnlyAdjustOverallVideoOutputGain = /* 'ovog' */ 0x6F766F67,
- BMDDeckLinkHasVideoInputAntiAliasingFilter = /* 'aafl' */ 0x6161666C,
- BMDDeckLinkHasBypass = /* 'byps' */ 0x62797073,
- BMDDeckLinkSupportsDesktopDisplay = /* 'extd' */ 0x65787464,
- BMDDeckLinkSupportsClockTimingAdjustment = /* 'ctad' */ 0x63746164,
- BMDDeckLinkSupportsFullDuplex = /* 'fdup' */ 0x66647570,
- BMDDeckLinkSupportsFullFrameReferenceInputTimingOffset = /* 'frin' */ 0x6672696E,
- BMDDeckLinkSupportsSMPTELevelAOutput = /* 'lvla' */ 0x6C766C61,
- BMDDeckLinkSupportsDualLinkSDI = /* 'sdls' */ 0x73646C73,
- BMDDeckLinkSupportsIdleOutput = /* 'idou' */ 0x69646F75,
-
- /* Integers */
-
- BMDDeckLinkMaximumAudioChannels = /* 'mach' */ 0x6D616368,
- BMDDeckLinkMaximumAnalogAudioChannels = /* 'aach' */ 0x61616368,
- BMDDeckLinkNumberOfSubDevices = /* 'nsbd' */ 0x6E736264,
- BMDDeckLinkSubDeviceIndex = /* 'subi' */ 0x73756269,
- BMDDeckLinkPersistentID = /* 'peid' */ 0x70656964,
- BMDDeckLinkTopologicalID = /* 'toid' */ 0x746F6964,
- BMDDeckLinkVideoOutputConnections = /* 'vocn' */ 0x766F636E,
- BMDDeckLinkVideoInputConnections = /* 'vicn' */ 0x7669636E,
- BMDDeckLinkAudioOutputConnections = /* 'aocn' */ 0x616F636E,
- BMDDeckLinkAudioInputConnections = /* 'aicn' */ 0x6169636E,
- BMDDeckLinkDeviceBusyState = /* 'dbst' */ 0x64627374,
- BMDDeckLinkVideoIOSupport = /* 'vios' */ 0x76696F73, // Returns a BMDVideoIOSupport bit field
-
- /* Floats */
-
- BMDDeckLinkVideoInputGainMinimum = /* 'vigm' */ 0x7669676D,
- BMDDeckLinkVideoInputGainMaximum = /* 'vigx' */ 0x76696778,
- BMDDeckLinkVideoOutputGainMinimum = /* 'vogm' */ 0x766F676D,
- BMDDeckLinkVideoOutputGainMaximum = /* 'vogx' */ 0x766F6778,
-
- /* Strings */
-
- BMDDeckLinkSerialPortDeviceName = /* 'slpn' */ 0x736C706E
-};
-
-/* Enum BMDDeckLinkAPIInformationID - DeckLinkAPI information ID */
-
-typedef uint32_t BMDDeckLinkAPIInformationID;
-enum _BMDDeckLinkAPIInformationID {
- BMDDeckLinkAPIVersion = /* 'vers' */ 0x76657273
-};
-
-/* Enum BMDDeviceBusyState - Current device busy state */
-
-typedef uint32_t BMDDeviceBusyState;
-enum _BMDDeviceBusyState {
- bmdDeviceCaptureBusy = 1 << 0,
- bmdDevicePlaybackBusy = 1 << 1,
- bmdDeviceSerialPortBusy = 1 << 2
-};
-
-/* Enum BMDVideoIOSupport - Device video input/output support */
-
-typedef uint32_t BMDVideoIOSupport;
-enum _BMDVideoIOSupport {
- bmdDeviceSupportsCapture = 1 << 0,
- bmdDeviceSupportsPlayback = 1 << 1
-};
-
-/* Enum BMD3DPreviewFormat - Linked Frame preview format */
-
-typedef uint32_t BMD3DPreviewFormat;
-enum _BMD3DPreviewFormat {
- bmd3DPreviewFormatDefault = /* 'defa' */ 0x64656661,
- bmd3DPreviewFormatLeftOnly = /* 'left' */ 0x6C656674,
- bmd3DPreviewFormatRightOnly = /* 'righ' */ 0x72696768,
- bmd3DPreviewFormatSideBySide = /* 'side' */ 0x73696465,
- bmd3DPreviewFormatTopBottom = /* 'topb' */ 0x746F7062
-};
-
-/* Enum BMDNotifications - Events that can be subscribed through IDeckLinkNotification */
-
-typedef uint32_t BMDNotifications;
-enum _BMDNotifications {
- bmdPreferencesChanged = /* 'pref' */ 0x70726566
-};
-
-#if defined(__cplusplus)
-
-// Forward Declarations
-
-class IDeckLinkVideoOutputCallback;
-class IDeckLinkInputCallback;
-class IDeckLinkMemoryAllocator;
-class IDeckLinkAudioOutputCallback;
-class IDeckLinkIterator;
-class IDeckLinkAPIInformation;
-class IDeckLinkOutput;
-class IDeckLinkInput;
-class IDeckLinkVideoFrame;
-class IDeckLinkMutableVideoFrame;
-class IDeckLinkVideoFrame3DExtensions;
-class IDeckLinkVideoInputFrame;
-class IDeckLinkVideoFrameAncillary;
-class IDeckLinkAudioInputPacket;
-class IDeckLinkScreenPreviewCallback;
-class IDeckLinkGLScreenPreviewHelper;
-class IDeckLinkNotificationCallback;
-class IDeckLinkNotification;
-class IDeckLinkAttributes;
-class IDeckLinkKeyer;
-class IDeckLinkVideoConversion;
-class IDeckLinkDeviceNotificationCallback;
-class IDeckLinkDiscovery;
-
-/* Interface IDeckLinkVideoOutputCallback - Frame completion callback. */
-
-class IDeckLinkVideoOutputCallback : public IUnknown
-{
-public:
- virtual HRESULT ScheduledFrameCompleted (/* in */ IDeckLinkVideoFrame *completedFrame, /* in */ BMDOutputFrameCompletionResult result) = 0;
- virtual HRESULT ScheduledPlaybackHasStopped (void) = 0;
-
-protected:
- virtual ~IDeckLinkVideoOutputCallback () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkInputCallback - Frame arrival callback. */
-
-class IDeckLinkInputCallback : public IUnknown
-{
-public:
- virtual HRESULT VideoInputFormatChanged (/* in */ BMDVideoInputFormatChangedEvents notificationEvents, /* in */ IDeckLinkDisplayMode *newDisplayMode, /* in */ BMDDetectedVideoInputFormatFlags detectedSignalFlags) = 0;
- virtual HRESULT VideoInputFrameArrived (/* in */ IDeckLinkVideoInputFrame* videoFrame, /* in */ IDeckLinkAudioInputPacket* audioPacket) = 0;
-
-protected:
- virtual ~IDeckLinkInputCallback () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkMemoryAllocator - Memory allocator for video frames. */
-
-class IDeckLinkMemoryAllocator : public IUnknown
-{
-public:
- virtual HRESULT AllocateBuffer (/* in */ uint32_t bufferSize, /* out */ void **allocatedBuffer) = 0;
- virtual HRESULT ReleaseBuffer (/* in */ void *buffer) = 0;
-
- virtual HRESULT Commit (void) = 0;
- virtual HRESULT Decommit (void) = 0;
-};
-
-/* Interface IDeckLinkAudioOutputCallback - Optional callback to allow audio samples to be pulled as required. */
-
-class IDeckLinkAudioOutputCallback : public IUnknown
-{
-public:
- virtual HRESULT RenderAudioSamples (/* in */ bool preroll) = 0;
-};
-
-/* Interface IDeckLinkIterator - enumerates installed DeckLink hardware */
-
-class IDeckLinkIterator : public IUnknown
-{
-public:
- virtual HRESULT Next (/* out */ IDeckLink **deckLinkInstance) = 0;
-};
-
-/* Interface IDeckLinkAPIInformation - DeckLinkAPI attribute interface */
-
-class IDeckLinkAPIInformation : public IUnknown
-{
-public:
- virtual HRESULT GetFlag (/* in */ BMDDeckLinkAPIInformationID cfgID, /* out */ bool *value) = 0;
- virtual HRESULT GetInt (/* in */ BMDDeckLinkAPIInformationID cfgID, /* out */ int64_t *value) = 0;
- virtual HRESULT GetFloat (/* in */ BMDDeckLinkAPIInformationID cfgID, /* out */ double *value) = 0;
- virtual HRESULT GetString (/* in */ BMDDeckLinkAPIInformationID cfgID, /* out */ const char **value) = 0;
-
-protected:
- virtual ~IDeckLinkAPIInformation () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkOutput - Created by QueryInterface from IDeckLink. */
-
-class IDeckLinkOutput : public IUnknown
-{
-public:
- virtual HRESULT DoesSupportVideoMode (/* in */ BMDDisplayMode displayMode, /* in */ BMDPixelFormat pixelFormat, /* in */ BMDVideoOutputFlags flags, /* out */ BMDDisplayModeSupport *result, /* out */ IDeckLinkDisplayMode **resultDisplayMode) = 0;
- virtual HRESULT GetDisplayModeIterator (/* out */ IDeckLinkDisplayModeIterator **iterator) = 0;
-
- virtual HRESULT SetScreenPreviewCallback (/* in */ IDeckLinkScreenPreviewCallback *previewCallback) = 0;
-
- /* Video Output */
-
- virtual HRESULT EnableVideoOutput (/* in */ BMDDisplayMode displayMode, /* in */ BMDVideoOutputFlags flags) = 0;
- virtual HRESULT DisableVideoOutput (void) = 0;
-
- virtual HRESULT SetVideoOutputFrameMemoryAllocator (/* in */ IDeckLinkMemoryAllocator *theAllocator) = 0;
- virtual HRESULT CreateVideoFrame (/* in */ int32_t width, /* in */ int32_t height, /* in */ int32_t rowBytes, /* in */ BMDPixelFormat pixelFormat, /* in */ BMDFrameFlags flags, /* out */ IDeckLinkMutableVideoFrame **outFrame) = 0;
- virtual HRESULT CreateAncillaryData (/* in */ BMDPixelFormat pixelFormat, /* out */ IDeckLinkVideoFrameAncillary **outBuffer) = 0;
-
- virtual HRESULT DisplayVideoFrameSync (/* in */ IDeckLinkVideoFrame *theFrame) = 0;
- virtual HRESULT ScheduleVideoFrame (/* in */ IDeckLinkVideoFrame *theFrame, /* in */ BMDTimeValue displayTime, /* in */ BMDTimeValue displayDuration, /* in */ BMDTimeScale timeScale) = 0;
- virtual HRESULT SetScheduledFrameCompletionCallback (/* in */ IDeckLinkVideoOutputCallback *theCallback) = 0;
- virtual HRESULT GetBufferedVideoFrameCount (/* out */ uint32_t *bufferedFrameCount) = 0;
-
- /* Audio Output */
-
- virtual HRESULT EnableAudioOutput (/* in */ BMDAudioSampleRate sampleRate, /* in */ BMDAudioSampleType sampleType, /* in */ uint32_t channelCount, /* in */ BMDAudioOutputStreamType streamType) = 0;
- virtual HRESULT DisableAudioOutput (void) = 0;
-
- virtual HRESULT WriteAudioSamplesSync (/* in */ void *buffer, /* in */ uint32_t sampleFrameCount, /* out */ uint32_t *sampleFramesWritten) = 0;
-
- virtual HRESULT BeginAudioPreroll (void) = 0;
- virtual HRESULT EndAudioPreroll (void) = 0;
- virtual HRESULT ScheduleAudioSamples (/* in */ void *buffer, /* in */ uint32_t sampleFrameCount, /* in */ BMDTimeValue streamTime, /* in */ BMDTimeScale timeScale, /* out */ uint32_t *sampleFramesWritten) = 0;
-
- virtual HRESULT GetBufferedAudioSampleFrameCount (/* out */ uint32_t *bufferedSampleFrameCount) = 0;
- virtual HRESULT FlushBufferedAudioSamples (void) = 0;
-
- virtual HRESULT SetAudioCallback (/* in */ IDeckLinkAudioOutputCallback *theCallback) = 0;
-
- /* Output Control */
-
- virtual HRESULT StartScheduledPlayback (/* in */ BMDTimeValue playbackStartTime, /* in */ BMDTimeScale timeScale, /* in */ double playbackSpeed) = 0;
- virtual HRESULT StopScheduledPlayback (/* in */ BMDTimeValue stopPlaybackAtTime, /* out */ BMDTimeValue *actualStopTime, /* in */ BMDTimeScale timeScale) = 0;
- virtual HRESULT IsScheduledPlaybackRunning (/* out */ bool *active) = 0;
- virtual HRESULT GetScheduledStreamTime (/* in */ BMDTimeScale desiredTimeScale, /* out */ BMDTimeValue *streamTime, /* out */ double *playbackSpeed) = 0;
- virtual HRESULT GetReferenceStatus (/* out */ BMDReferenceStatus *referenceStatus) = 0;
-
- /* Hardware Timing */
-
- virtual HRESULT GetHardwareReferenceClock (/* in */ BMDTimeScale desiredTimeScale, /* out */ BMDTimeValue *hardwareTime, /* out */ BMDTimeValue *timeInFrame, /* out */ BMDTimeValue *ticksPerFrame) = 0;
- virtual HRESULT GetFrameCompletionReferenceTimestamp (/* in */ IDeckLinkVideoFrame *theFrame, /* in */ BMDTimeScale desiredTimeScale, /* out */ BMDTimeValue *frameCompletionTimestamp) = 0;
-
-protected:
- virtual ~IDeckLinkOutput () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkInput - Created by QueryInterface from IDeckLink. */
-
-class IDeckLinkInput : public IUnknown
-{
-public:
- virtual HRESULT DoesSupportVideoMode (/* in */ BMDDisplayMode displayMode, /* in */ BMDPixelFormat pixelFormat, /* in */ BMDVideoInputFlags flags, /* out */ BMDDisplayModeSupport *result, /* out */ IDeckLinkDisplayMode **resultDisplayMode) = 0;
- virtual HRESULT GetDisplayModeIterator (/* out */ IDeckLinkDisplayModeIterator **iterator) = 0;
-
- virtual HRESULT SetScreenPreviewCallback (/* in */ IDeckLinkScreenPreviewCallback *previewCallback) = 0;
-
- /* Video Input */
-
- virtual HRESULT EnableVideoInput (/* in */ BMDDisplayMode displayMode, /* in */ BMDPixelFormat pixelFormat, /* in */ BMDVideoInputFlags flags) = 0;
- virtual HRESULT DisableVideoInput (void) = 0;
- virtual HRESULT GetAvailableVideoFrameCount (/* out */ uint32_t *availableFrameCount) = 0;
- virtual HRESULT SetVideoInputFrameMemoryAllocator (/* in */ IDeckLinkMemoryAllocator *theAllocator) = 0;
-
- /* Audio Input */
-
- virtual HRESULT EnableAudioInput (/* in */ BMDAudioSampleRate sampleRate, /* in */ BMDAudioSampleType sampleType, /* in */ uint32_t channelCount) = 0;
- virtual HRESULT DisableAudioInput (void) = 0;
- virtual HRESULT GetAvailableAudioSampleFrameCount (/* out */ uint32_t *availableSampleFrameCount) = 0;
-
- /* Input Control */
-
- virtual HRESULT StartStreams (void) = 0;
- virtual HRESULT StopStreams (void) = 0;
- virtual HRESULT PauseStreams (void) = 0;
- virtual HRESULT FlushStreams (void) = 0;
- virtual HRESULT SetCallback (/* in */ IDeckLinkInputCallback *theCallback) = 0;
-
- /* Hardware Timing */
-
- virtual HRESULT GetHardwareReferenceClock (/* in */ BMDTimeScale desiredTimeScale, /* out */ BMDTimeValue *hardwareTime, /* out */ BMDTimeValue *timeInFrame, /* out */ BMDTimeValue *ticksPerFrame) = 0;
-
-protected:
- virtual ~IDeckLinkInput () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkVideoFrame - Interface to encapsulate a video frame; can be caller-implemented. */
-
-class IDeckLinkVideoFrame : public IUnknown
-{
-public:
- virtual long GetWidth (void) = 0;
- virtual long GetHeight (void) = 0;
- virtual long GetRowBytes (void) = 0;
- virtual BMDPixelFormat GetPixelFormat (void) = 0;
- virtual BMDFrameFlags GetFlags (void) = 0;
- virtual HRESULT GetBytes (/* out */ void **buffer) = 0;
-
- virtual HRESULT GetTimecode (/* in */ BMDTimecodeFormat format, /* out */ IDeckLinkTimecode **timecode) = 0;
- virtual HRESULT GetAncillaryData (/* out */ IDeckLinkVideoFrameAncillary **ancillary) = 0;
-
-protected:
- virtual ~IDeckLinkVideoFrame () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkMutableVideoFrame - Created by IDeckLinkOutput::CreateVideoFrame. */
-
-class IDeckLinkMutableVideoFrame : public IDeckLinkVideoFrame
-{
-public:
- virtual HRESULT SetFlags (/* in */ BMDFrameFlags newFlags) = 0;
-
- virtual HRESULT SetTimecode (/* in */ BMDTimecodeFormat format, /* in */ IDeckLinkTimecode *timecode) = 0;
- virtual HRESULT SetTimecodeFromComponents (/* in */ BMDTimecodeFormat format, /* in */ uint8_t hours, /* in */ uint8_t minutes, /* in */ uint8_t seconds, /* in */ uint8_t frames, /* in */ BMDTimecodeFlags flags) = 0;
- virtual HRESULT SetAncillaryData (/* in */ IDeckLinkVideoFrameAncillary *ancillary) = 0;
- virtual HRESULT SetTimecodeUserBits (/* in */ BMDTimecodeFormat format, /* in */ BMDTimecodeUserBits userBits) = 0;
-
-protected:
- virtual ~IDeckLinkMutableVideoFrame () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkVideoFrame3DExtensions - Optional interface implemented on IDeckLinkVideoFrame to support 3D frames */
-
-class IDeckLinkVideoFrame3DExtensions : public IUnknown
-{
-public:
- virtual BMDVideo3DPackingFormat Get3DPackingFormat (void) = 0;
- virtual HRESULT GetFrameForRightEye (/* out */ IDeckLinkVideoFrame* *rightEyeFrame) = 0;
-
-protected:
- virtual ~IDeckLinkVideoFrame3DExtensions () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkVideoInputFrame - Provided by the IDeckLinkVideoInput frame arrival callback. */
-
-class IDeckLinkVideoInputFrame : public IDeckLinkVideoFrame
-{
-public:
- virtual HRESULT GetStreamTime (/* out */ BMDTimeValue *frameTime, /* out */ BMDTimeValue *frameDuration, /* in */ BMDTimeScale timeScale) = 0;
- virtual HRESULT GetHardwareReferenceTimestamp (/* in */ BMDTimeScale timeScale, /* out */ BMDTimeValue *frameTime, /* out */ BMDTimeValue *frameDuration) = 0;
-
-protected:
- virtual ~IDeckLinkVideoInputFrame () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkVideoFrameAncillary - Obtained through QueryInterface() on an IDeckLinkVideoFrame object. */
-
-class IDeckLinkVideoFrameAncillary : public IUnknown
-{
-public:
-
- virtual HRESULT GetBufferForVerticalBlankingLine (/* in */ uint32_t lineNumber, /* out */ void **buffer) = 0;
- virtual BMDPixelFormat GetPixelFormat (void) = 0;
- virtual BMDDisplayMode GetDisplayMode (void) = 0;
-
-protected:
- virtual ~IDeckLinkVideoFrameAncillary () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkAudioInputPacket - Provided by the IDeckLinkInput callback. */
-
-class IDeckLinkAudioInputPacket : public IUnknown
-{
-public:
- virtual long GetSampleFrameCount (void) = 0;
- virtual HRESULT GetBytes (/* out */ void **buffer) = 0;
- virtual HRESULT GetPacketTime (/* out */ BMDTimeValue *packetTime, /* in */ BMDTimeScale timeScale) = 0;
-
-protected:
- virtual ~IDeckLinkAudioInputPacket () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkScreenPreviewCallback - Screen preview callback */
-
-class IDeckLinkScreenPreviewCallback : public IUnknown
-{
-public:
- virtual HRESULT DrawFrame (/* in */ IDeckLinkVideoFrame *theFrame) = 0;
-
-protected:
- virtual ~IDeckLinkScreenPreviewCallback () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkGLScreenPreviewHelper - Created with CoCreateInstance(). */
-
-class IDeckLinkGLScreenPreviewHelper : public IUnknown
-{
-public:
-
- /* Methods must be called with OpenGL context set */
-
- virtual HRESULT InitializeGL (void) = 0;
- virtual HRESULT PaintGL (void) = 0;
- virtual HRESULT SetFrame (/* in */ IDeckLinkVideoFrame *theFrame) = 0;
- virtual HRESULT Set3DPreviewFormat (/* in */ BMD3DPreviewFormat previewFormat) = 0;
-
-protected:
- virtual ~IDeckLinkGLScreenPreviewHelper () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkNotificationCallback - DeckLink Notification Callback Interface */
-
-class IDeckLinkNotificationCallback : public IUnknown
-{
-public:
- virtual HRESULT Notify (/* in */ BMDNotifications topic, /* in */ uint64_t param1, /* in */ uint64_t param2) = 0;
-};
-
-/* Interface IDeckLinkNotification - DeckLink Notification interface */
-
-class IDeckLinkNotification : public IUnknown
-{
-public:
- virtual HRESULT Subscribe (/* in */ BMDNotifications topic, /* in */ IDeckLinkNotificationCallback *theCallback) = 0;
- virtual HRESULT Unsubscribe (/* in */ BMDNotifications topic, /* in */ IDeckLinkNotificationCallback *theCallback) = 0;
-};
-
-/* Interface IDeckLinkAttributes - DeckLink Attribute interface */
-
-class IDeckLinkAttributes : public IUnknown
-{
-public:
- virtual HRESULT GetFlag (/* in */ BMDDeckLinkAttributeID cfgID, /* out */ bool *value) = 0;
- virtual HRESULT GetInt (/* in */ BMDDeckLinkAttributeID cfgID, /* out */ int64_t *value) = 0;
- virtual HRESULT GetFloat (/* in */ BMDDeckLinkAttributeID cfgID, /* out */ double *value) = 0;
- virtual HRESULT GetString (/* in */ BMDDeckLinkAttributeID cfgID, /* out */ const char **value) = 0;
-
-protected:
- virtual ~IDeckLinkAttributes () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkKeyer - DeckLink Keyer interface */
-
-class IDeckLinkKeyer : public IUnknown
-{
-public:
- virtual HRESULT Enable (/* in */ bool isExternal) = 0;
- virtual HRESULT SetLevel (/* in */ uint8_t level) = 0;
- virtual HRESULT RampUp (/* in */ uint32_t numberOfFrames) = 0;
- virtual HRESULT RampDown (/* in */ uint32_t numberOfFrames) = 0;
- virtual HRESULT Disable (void) = 0;
-
-protected:
- virtual ~IDeckLinkKeyer () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkVideoConversion - Created with CoCreateInstance(). */
-
-class IDeckLinkVideoConversion : public IUnknown
-{
-public:
- virtual HRESULT ConvertFrame (/* in */ IDeckLinkVideoFrame* srcFrame, /* in */ IDeckLinkVideoFrame* dstFrame) = 0;
-
-protected:
- virtual ~IDeckLinkVideoConversion () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkDeviceNotificationCallback - DeckLink device arrival/removal notification callbacks */
-
-class IDeckLinkDeviceNotificationCallback : public IUnknown
-{
-public:
- virtual HRESULT DeckLinkDeviceArrived (/* in */ IDeckLink* deckLinkDevice) = 0;
- virtual HRESULT DeckLinkDeviceRemoved (/* in */ IDeckLink* deckLinkDevice) = 0;
-
-protected:
- virtual ~IDeckLinkDeviceNotificationCallback () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkDiscovery - DeckLink device discovery */
-
-class IDeckLinkDiscovery : public IUnknown
-{
-public:
- virtual HRESULT InstallDeviceNotifications (/* in */ IDeckLinkDeviceNotificationCallback* deviceNotificationCallback) = 0;
- virtual HRESULT UninstallDeviceNotifications (void) = 0;
-
-protected:
- virtual ~IDeckLinkDiscovery () {} // call Release method to drop reference count
-};
-
-/* Functions */
-
-extern "C" {
-
- IDeckLinkIterator* CreateDeckLinkIteratorInstance (void);
- IDeckLinkDiscovery* CreateDeckLinkDiscoveryInstance (void);
- IDeckLinkAPIInformation* CreateDeckLinkAPIInformationInstance (void);
- IDeckLinkGLScreenPreviewHelper* CreateOpenGLScreenPreviewHelper (void);
- IDeckLinkVideoConversion* CreateVideoConversionInstance (void);
- bool IsDeckLinkAPIPresent (void);
-}
-
-
-#endif // defined(__cplusplus)
-#endif /* defined(BMD_DECKLINKAPI_H) */
diff --git a/intern/decklink/linux/DeckLinkAPIConfiguration.h b/intern/decklink/linux/DeckLinkAPIConfiguration.h
deleted file mode 100644
index 9d5bc9a9e1b..00000000000
--- a/intern/decklink/linux/DeckLinkAPIConfiguration.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -LICENSE-START-
-** Copyright (c) 2014 Blackmagic Design
-**
-** Permission is hereby granted, free of charge, to any person or organization
-** obtaining a copy of the software and accompanying documentation covered by
-** this license (the "Software") to use, reproduce, display, distribute,
-** execute, and transmit the Software, and to prepare derivative works of the
-** Software, and to permit third-parties to whom the Software is furnished to
-** do so, all subject to the following:
-**
-** The copyright notices in the Software and this entire statement, including
-** the above license grant, this restriction and the following disclaimer,
-** must be included in all copies of the Software, in whole or in part, and
-** all derivative works of the Software, unless such copies or derivative
-** works are solely in the form of machine-executable object code generated by
-** a source language processor.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-** DEALINGS IN THE SOFTWARE.
-** -LICENSE-END-
-*/
-
-#ifndef BMD_DECKLINKAPICONFIGURATION_H
-#define BMD_DECKLINKAPICONFIGURATION_H
-
-
-#ifndef BMD_CONST
- #if defined(_MSC_VER)
- #define BMD_CONST __declspec(selectany) static const
- #else
- #define BMD_CONST static const
- #endif
-#endif
-
-// Type Declarations
-
-
-// Interface ID Declarations
-
-BMD_CONST REFIID IID_IDeckLinkConfiguration = /* 1E69FCF6-4203-4936-8076-2A9F4CFD50CB */ {0x1E,0x69,0xFC,0xF6,0x42,0x03,0x49,0x36,0x80,0x76,0x2A,0x9F,0x4C,0xFD,0x50,0xCB};
-
-/* Enum BMDDeckLinkConfigurationID - DeckLink Configuration ID */
-
-typedef uint32_t BMDDeckLinkConfigurationID;
-enum _BMDDeckLinkConfigurationID {
-
- /* Serial port Flags */
-
- bmdDeckLinkConfigSwapSerialRxTx = /* 'ssrt' */ 0x73737274,
-
- /* Video Input/Output Flags */
-
- bmdDeckLinkConfigUse1080pNotPsF = /* 'fpro' */ 0x6670726F,
-
- /* Video Input/Output Integers */
-
- bmdDeckLinkConfigHDMI3DPackingFormat = /* '3dpf' */ 0x33647066,
- bmdDeckLinkConfigBypass = /* 'byps' */ 0x62797073,
- bmdDeckLinkConfigClockTimingAdjustment = /* 'ctad' */ 0x63746164,
-
- /* Audio Input/Output Flags */
-
- bmdDeckLinkConfigAnalogAudioConsumerLevels = /* 'aacl' */ 0x6161636C,
-
- /* Video output flags */
-
- bmdDeckLinkConfigFieldFlickerRemoval = /* 'fdfr' */ 0x66646672,
- bmdDeckLinkConfigHD1080p24ToHD1080i5994Conversion = /* 'to59' */ 0x746F3539,
- bmdDeckLinkConfig444SDIVideoOutput = /* '444o' */ 0x3434346F,
- bmdDeckLinkConfigSingleLinkVideoOutput = /* 'sglo' */ 0x73676C6F,
- bmdDeckLinkConfigBlackVideoOutputDuringCapture = /* 'bvoc' */ 0x62766F63,
- bmdDeckLinkConfigLowLatencyVideoOutput = /* 'llvo' */ 0x6C6C766F,
- bmdDeckLinkConfigDownConversionOnAllAnalogOutput = /* 'caao' */ 0x6361616F,
- bmdDeckLinkConfigSMPTELevelAOutput = /* 'smta' */ 0x736D7461,
-
- /* Video Output Integers */
-
- bmdDeckLinkConfigVideoOutputConnection = /* 'vocn' */ 0x766F636E,
- bmdDeckLinkConfigVideoOutputConversionMode = /* 'vocm' */ 0x766F636D,
- bmdDeckLinkConfigAnalogVideoOutputFlags = /* 'avof' */ 0x61766F66,
- bmdDeckLinkConfigReferenceInputTimingOffset = /* 'glot' */ 0x676C6F74,
- bmdDeckLinkConfigVideoOutputIdleOperation = /* 'voio' */ 0x766F696F,
- bmdDeckLinkConfigDefaultVideoOutputMode = /* 'dvom' */ 0x64766F6D,
- bmdDeckLinkConfigDefaultVideoOutputModeFlags = /* 'dvof' */ 0x64766F66,
-
- /* Video Output Floats */
-
- bmdDeckLinkConfigVideoOutputComponentLumaGain = /* 'oclg' */ 0x6F636C67,
- bmdDeckLinkConfigVideoOutputComponentChromaBlueGain = /* 'occb' */ 0x6F636362,
- bmdDeckLinkConfigVideoOutputComponentChromaRedGain = /* 'occr' */ 0x6F636372,
- bmdDeckLinkConfigVideoOutputCompositeLumaGain = /* 'oilg' */ 0x6F696C67,
- bmdDeckLinkConfigVideoOutputCompositeChromaGain = /* 'oicg' */ 0x6F696367,
- bmdDeckLinkConfigVideoOutputSVideoLumaGain = /* 'oslg' */ 0x6F736C67,
- bmdDeckLinkConfigVideoOutputSVideoChromaGain = /* 'oscg' */ 0x6F736367,
-
- /* Video Input Flags */
-
- bmdDeckLinkConfigVideoInputScanning = /* 'visc' */ 0x76697363, // Applicable to H264 Pro Recorder only
- bmdDeckLinkConfigUseDedicatedLTCInput = /* 'dltc' */ 0x646C7463, // Use timecode from LTC input instead of SDI stream
-
- /* Video Input Integers */
-
- bmdDeckLinkConfigVideoInputConnection = /* 'vicn' */ 0x7669636E,
- bmdDeckLinkConfigAnalogVideoInputFlags = /* 'avif' */ 0x61766966,
- bmdDeckLinkConfigVideoInputConversionMode = /* 'vicm' */ 0x7669636D,
- bmdDeckLinkConfig32PulldownSequenceInitialTimecodeFrame = /* 'pdif' */ 0x70646966,
- bmdDeckLinkConfigVANCSourceLine1Mapping = /* 'vsl1' */ 0x76736C31,
- bmdDeckLinkConfigVANCSourceLine2Mapping = /* 'vsl2' */ 0x76736C32,
- bmdDeckLinkConfigVANCSourceLine3Mapping = /* 'vsl3' */ 0x76736C33,
- bmdDeckLinkConfigCapturePassThroughMode = /* 'cptm' */ 0x6370746D,
-
- /* Video Input Floats */
-
- bmdDeckLinkConfigVideoInputComponentLumaGain = /* 'iclg' */ 0x69636C67,
- bmdDeckLinkConfigVideoInputComponentChromaBlueGain = /* 'iccb' */ 0x69636362,
- bmdDeckLinkConfigVideoInputComponentChromaRedGain = /* 'iccr' */ 0x69636372,
- bmdDeckLinkConfigVideoInputCompositeLumaGain = /* 'iilg' */ 0x69696C67,
- bmdDeckLinkConfigVideoInputCompositeChromaGain = /* 'iicg' */ 0x69696367,
- bmdDeckLinkConfigVideoInputSVideoLumaGain = /* 'islg' */ 0x69736C67,
- bmdDeckLinkConfigVideoInputSVideoChromaGain = /* 'iscg' */ 0x69736367,
-
- /* Audio Input Integers */
-
- bmdDeckLinkConfigAudioInputConnection = /* 'aicn' */ 0x6169636E,
-
- /* Audio Input Floats */
-
- bmdDeckLinkConfigAnalogAudioInputScaleChannel1 = /* 'ais1' */ 0x61697331,
- bmdDeckLinkConfigAnalogAudioInputScaleChannel2 = /* 'ais2' */ 0x61697332,
- bmdDeckLinkConfigAnalogAudioInputScaleChannel3 = /* 'ais3' */ 0x61697333,
- bmdDeckLinkConfigAnalogAudioInputScaleChannel4 = /* 'ais4' */ 0x61697334,
- bmdDeckLinkConfigDigitalAudioInputScale = /* 'dais' */ 0x64616973,
-
- /* Audio Output Integers */
-
- bmdDeckLinkConfigAudioOutputAESAnalogSwitch = /* 'aoaa' */ 0x616F6161,
-
- /* Audio Output Floats */
-
- bmdDeckLinkConfigAnalogAudioOutputScaleChannel1 = /* 'aos1' */ 0x616F7331,
- bmdDeckLinkConfigAnalogAudioOutputScaleChannel2 = /* 'aos2' */ 0x616F7332,
- bmdDeckLinkConfigAnalogAudioOutputScaleChannel3 = /* 'aos3' */ 0x616F7333,
- bmdDeckLinkConfigAnalogAudioOutputScaleChannel4 = /* 'aos4' */ 0x616F7334,
- bmdDeckLinkConfigDigitalAudioOutputScale = /* 'daos' */ 0x64616F73,
-
- /* Device Information Strings */
-
- bmdDeckLinkConfigDeviceInformationLabel = /* 'dila' */ 0x64696C61,
- bmdDeckLinkConfigDeviceInformationSerialNumber = /* 'disn' */ 0x6469736E,
- bmdDeckLinkConfigDeviceInformationCompany = /* 'dico' */ 0x6469636F,
- bmdDeckLinkConfigDeviceInformationPhone = /* 'diph' */ 0x64697068,
- bmdDeckLinkConfigDeviceInformationEmail = /* 'diem' */ 0x6469656D,
- bmdDeckLinkConfigDeviceInformationDate = /* 'dida' */ 0x64696461
-};
-
-// Forward Declarations
-
-class IDeckLinkConfiguration;
-
-/* Interface IDeckLinkConfiguration - DeckLink Configuration interface */
-
-class IDeckLinkConfiguration : public IUnknown
-{
-public:
- virtual HRESULT SetFlag (/* in */ BMDDeckLinkConfigurationID cfgID, /* in */ bool value) = 0;
- virtual HRESULT GetFlag (/* in */ BMDDeckLinkConfigurationID cfgID, /* out */ bool *value) = 0;
- virtual HRESULT SetInt (/* in */ BMDDeckLinkConfigurationID cfgID, /* in */ int64_t value) = 0;
- virtual HRESULT GetInt (/* in */ BMDDeckLinkConfigurationID cfgID, /* out */ int64_t *value) = 0;
- virtual HRESULT SetFloat (/* in */ BMDDeckLinkConfigurationID cfgID, /* in */ double value) = 0;
- virtual HRESULT GetFloat (/* in */ BMDDeckLinkConfigurationID cfgID, /* out */ double *value) = 0;
- virtual HRESULT SetString (/* in */ BMDDeckLinkConfigurationID cfgID, /* in */ const char *value) = 0;
- virtual HRESULT GetString (/* in */ BMDDeckLinkConfigurationID cfgID, /* out */ const char **value) = 0;
- virtual HRESULT WriteConfigurationToPreferences (void) = 0;
-
-protected:
- virtual ~IDeckLinkConfiguration () {} // call Release method to drop reference count
-};
-
-/* Functions */
-
-extern "C" {
-
-
-}
-
-
-#endif /* defined(BMD_DECKLINKAPICONFIGURATION_H) */
diff --git a/intern/decklink/linux/DeckLinkAPIDeckControl.h b/intern/decklink/linux/DeckLinkAPIDeckControl.h
deleted file mode 100644
index b83d013129e..00000000000
--- a/intern/decklink/linux/DeckLinkAPIDeckControl.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/* -LICENSE-START-
-** Copyright (c) 2014 Blackmagic Design
-**
-** Permission is hereby granted, free of charge, to any person or organization
-** obtaining a copy of the software and accompanying documentation covered by
-** this license (the "Software") to use, reproduce, display, distribute,
-** execute, and transmit the Software, and to prepare derivative works of the
-** Software, and to permit third-parties to whom the Software is furnished to
-** do so, all subject to the following:
-**
-** The copyright notices in the Software and this entire statement, including
-** the above license grant, this restriction and the following disclaimer,
-** must be included in all copies of the Software, in whole or in part, and
-** all derivative works of the Software, unless such copies or derivative
-** works are solely in the form of machine-executable object code generated by
-** a source language processor.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-** DEALINGS IN THE SOFTWARE.
-** -LICENSE-END-
-*/
-
-#ifndef BMD_DECKLINKAPIDECKCONTROL_H
-#define BMD_DECKLINKAPIDECKCONTROL_H
-
-
-#ifndef BMD_CONST
- #if defined(_MSC_VER)
- #define BMD_CONST __declspec(selectany) static const
- #else
- #define BMD_CONST static const
- #endif
-#endif
-
-// Type Declarations
-
-
-// Interface ID Declarations
-
-BMD_CONST REFIID IID_IDeckLinkDeckControlStatusCallback = /* 53436FFB-B434-4906-BADC-AE3060FFE8EF */ {0x53,0x43,0x6F,0xFB,0xB4,0x34,0x49,0x06,0xBA,0xDC,0xAE,0x30,0x60,0xFF,0xE8,0xEF};
-BMD_CONST REFIID IID_IDeckLinkDeckControl = /* 8E1C3ACE-19C7-4E00-8B92-D80431D958BE */ {0x8E,0x1C,0x3A,0xCE,0x19,0xC7,0x4E,0x00,0x8B,0x92,0xD8,0x04,0x31,0xD9,0x58,0xBE};
-
-/* Enum BMDDeckControlMode - DeckControl mode */
-
-typedef uint32_t BMDDeckControlMode;
-enum _BMDDeckControlMode {
- bmdDeckControlNotOpened = /* 'ntop' */ 0x6E746F70,
- bmdDeckControlVTRControlMode = /* 'vtrc' */ 0x76747263,
- bmdDeckControlExportMode = /* 'expm' */ 0x6578706D,
- bmdDeckControlCaptureMode = /* 'capm' */ 0x6361706D
-};
-
-/* Enum BMDDeckControlEvent - DeckControl event */
-
-typedef uint32_t BMDDeckControlEvent;
-enum _BMDDeckControlEvent {
- bmdDeckControlAbortedEvent = /* 'abte' */ 0x61627465, // This event is triggered when a capture or edit-to-tape operation is aborted.
-
- /* Export-To-Tape events */
-
- bmdDeckControlPrepareForExportEvent = /* 'pfee' */ 0x70666565, // This event is triggered a few frames before reaching the in-point. IDeckLinkInput::StartScheduledPlayback() should be called at this point.
- bmdDeckControlExportCompleteEvent = /* 'exce' */ 0x65786365, // This event is triggered a few frames after reaching the out-point. At this point, it is safe to stop playback.
-
- /* Capture events */
-
- bmdDeckControlPrepareForCaptureEvent = /* 'pfce' */ 0x70666365, // This event is triggered a few frames before reaching the in-point. The serial timecode attached to IDeckLinkVideoInputFrames is now valid.
- bmdDeckControlCaptureCompleteEvent = /* 'ccev' */ 0x63636576 // This event is triggered a few frames after reaching the out-point.
-};
-
-/* Enum BMDDeckControlVTRControlState - VTR Control state */
-
-typedef uint32_t BMDDeckControlVTRControlState;
-enum _BMDDeckControlVTRControlState {
- bmdDeckControlNotInVTRControlMode = /* 'nvcm' */ 0x6E76636D,
- bmdDeckControlVTRControlPlaying = /* 'vtrp' */ 0x76747270,
- bmdDeckControlVTRControlRecording = /* 'vtrr' */ 0x76747272,
- bmdDeckControlVTRControlStill = /* 'vtra' */ 0x76747261,
- bmdDeckControlVTRControlShuttleForward = /* 'vtsf' */ 0x76747366,
- bmdDeckControlVTRControlShuttleReverse = /* 'vtsr' */ 0x76747372,
- bmdDeckControlVTRControlJogForward = /* 'vtjf' */ 0x76746A66,
- bmdDeckControlVTRControlJogReverse = /* 'vtjr' */ 0x76746A72,
- bmdDeckControlVTRControlStopped = /* 'vtro' */ 0x7674726F
-};
-
-/* Enum BMDDeckControlStatusFlags - Deck Control status flags */
-
-typedef uint32_t BMDDeckControlStatusFlags;
-enum _BMDDeckControlStatusFlags {
- bmdDeckControlStatusDeckConnected = 1 << 0,
- bmdDeckControlStatusRemoteMode = 1 << 1,
- bmdDeckControlStatusRecordInhibited = 1 << 2,
- bmdDeckControlStatusCassetteOut = 1 << 3
-};
-
-/* Enum BMDDeckControlExportModeOpsFlags - Export mode flags */
-
-typedef uint32_t BMDDeckControlExportModeOpsFlags;
-enum _BMDDeckControlExportModeOpsFlags {
- bmdDeckControlExportModeInsertVideo = 1 << 0,
- bmdDeckControlExportModeInsertAudio1 = 1 << 1,
- bmdDeckControlExportModeInsertAudio2 = 1 << 2,
- bmdDeckControlExportModeInsertAudio3 = 1 << 3,
- bmdDeckControlExportModeInsertAudio4 = 1 << 4,
- bmdDeckControlExportModeInsertAudio5 = 1 << 5,
- bmdDeckControlExportModeInsertAudio6 = 1 << 6,
- bmdDeckControlExportModeInsertAudio7 = 1 << 7,
- bmdDeckControlExportModeInsertAudio8 = 1 << 8,
- bmdDeckControlExportModeInsertAudio9 = 1 << 9,
- bmdDeckControlExportModeInsertAudio10 = 1 << 10,
- bmdDeckControlExportModeInsertAudio11 = 1 << 11,
- bmdDeckControlExportModeInsertAudio12 = 1 << 12,
- bmdDeckControlExportModeInsertTimeCode = 1 << 13,
- bmdDeckControlExportModeInsertAssemble = 1 << 14,
- bmdDeckControlExportModeInsertPreview = 1 << 15,
- bmdDeckControlUseManualExport = 1 << 16
-};
-
-/* Enum BMDDeckControlError - Deck Control error */
-
-typedef uint32_t BMDDeckControlError;
-enum _BMDDeckControlError {
- bmdDeckControlNoError = /* 'noer' */ 0x6E6F6572,
- bmdDeckControlModeError = /* 'moer' */ 0x6D6F6572,
- bmdDeckControlMissedInPointError = /* 'mier' */ 0x6D696572,
- bmdDeckControlDeckTimeoutError = /* 'dter' */ 0x64746572,
- bmdDeckControlCommandFailedError = /* 'cfer' */ 0x63666572,
- bmdDeckControlDeviceAlreadyOpenedError = /* 'dalo' */ 0x64616C6F,
- bmdDeckControlFailedToOpenDeviceError = /* 'fder' */ 0x66646572,
- bmdDeckControlInLocalModeError = /* 'lmer' */ 0x6C6D6572,
- bmdDeckControlEndOfTapeError = /* 'eter' */ 0x65746572,
- bmdDeckControlUserAbortError = /* 'uaer' */ 0x75616572,
- bmdDeckControlNoTapeInDeckError = /* 'nter' */ 0x6E746572,
- bmdDeckControlNoVideoFromCardError = /* 'nvfc' */ 0x6E766663,
- bmdDeckControlNoCommunicationError = /* 'ncom' */ 0x6E636F6D,
- bmdDeckControlBufferTooSmallError = /* 'btsm' */ 0x6274736D,
- bmdDeckControlBadChecksumError = /* 'chks' */ 0x63686B73,
- bmdDeckControlUnknownError = /* 'uner' */ 0x756E6572
-};
-
-// Forward Declarations
-
-class IDeckLinkDeckControlStatusCallback;
-class IDeckLinkDeckControl;
-
-/* Interface IDeckLinkDeckControlStatusCallback - Deck control state change callback. */
-
-class IDeckLinkDeckControlStatusCallback : public IUnknown
-{
-public:
- virtual HRESULT TimecodeUpdate (/* in */ BMDTimecodeBCD currentTimecode) = 0;
- virtual HRESULT VTRControlStateChanged (/* in */ BMDDeckControlVTRControlState newState, /* in */ BMDDeckControlError error) = 0;
- virtual HRESULT DeckControlEventReceived (/* in */ BMDDeckControlEvent event, /* in */ BMDDeckControlError error) = 0;
- virtual HRESULT DeckControlStatusChanged (/* in */ BMDDeckControlStatusFlags flags, /* in */ uint32_t mask) = 0;
-
-protected:
- virtual ~IDeckLinkDeckControlStatusCallback () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkDeckControl - Deck Control main interface */
-
-class IDeckLinkDeckControl : public IUnknown
-{
-public:
- virtual HRESULT Open (/* in */ BMDTimeScale timeScale, /* in */ BMDTimeValue timeValue, /* in */ bool timecodeIsDropFrame, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT Close (/* in */ bool standbyOn) = 0;
- virtual HRESULT GetCurrentState (/* out */ BMDDeckControlMode *mode, /* out */ BMDDeckControlVTRControlState *vtrControlState, /* out */ BMDDeckControlStatusFlags *flags) = 0;
- virtual HRESULT SetStandby (/* in */ bool standbyOn) = 0;
- virtual HRESULT SendCommand (/* in */ uint8_t *inBuffer, /* in */ uint32_t inBufferSize, /* out */ uint8_t *outBuffer, /* out */ uint32_t *outDataSize, /* in */ uint32_t outBufferSize, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT Play (/* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT Stop (/* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT TogglePlayStop (/* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT Eject (/* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT GoToTimecode (/* in */ BMDTimecodeBCD timecode, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT FastForward (/* in */ bool viewTape, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT Rewind (/* in */ bool viewTape, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT StepForward (/* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT StepBack (/* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT Jog (/* in */ double rate, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT Shuttle (/* in */ double rate, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT GetTimecodeString (/* out */ const char **currentTimeCode, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT GetTimecode (/* out */ IDeckLinkTimecode **currentTimecode, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT GetTimecodeBCD (/* out */ BMDTimecodeBCD *currentTimecode, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT SetPreroll (/* in */ uint32_t prerollSeconds) = 0;
- virtual HRESULT GetPreroll (/* out */ uint32_t *prerollSeconds) = 0;
- virtual HRESULT SetExportOffset (/* in */ int32_t exportOffsetFields) = 0;
- virtual HRESULT GetExportOffset (/* out */ int32_t *exportOffsetFields) = 0;
- virtual HRESULT GetManualExportOffset (/* out */ int32_t *deckManualExportOffsetFields) = 0;
- virtual HRESULT SetCaptureOffset (/* in */ int32_t captureOffsetFields) = 0;
- virtual HRESULT GetCaptureOffset (/* out */ int32_t *captureOffsetFields) = 0;
- virtual HRESULT StartExport (/* in */ BMDTimecodeBCD inTimecode, /* in */ BMDTimecodeBCD outTimecode, /* in */ BMDDeckControlExportModeOpsFlags exportModeOps, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT StartCapture (/* in */ bool useVITC, /* in */ BMDTimecodeBCD inTimecode, /* in */ BMDTimecodeBCD outTimecode, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT GetDeviceID (/* out */ uint16_t *deviceId, /* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT Abort (void) = 0;
- virtual HRESULT CrashRecordStart (/* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT CrashRecordStop (/* out */ BMDDeckControlError *error) = 0;
- virtual HRESULT SetCallback (/* in */ IDeckLinkDeckControlStatusCallback *callback) = 0;
-
-protected:
- virtual ~IDeckLinkDeckControl () {} // call Release method to drop reference count
-};
-
-/* Functions */
-
-extern "C" {
-
-
-}
-
-
-#endif /* defined(BMD_DECKLINKAPIDECKCONTROL_H) */
diff --git a/intern/decklink/linux/DeckLinkAPIDiscovery.h b/intern/decklink/linux/DeckLinkAPIDiscovery.h
deleted file mode 100644
index 424d9d54b39..00000000000
--- a/intern/decklink/linux/DeckLinkAPIDiscovery.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -LICENSE-START-
-** Copyright (c) 2014 Blackmagic Design
-**
-** Permission is hereby granted, free of charge, to any person or organization
-** obtaining a copy of the software and accompanying documentation covered by
-** this license (the "Software") to use, reproduce, display, distribute,
-** execute, and transmit the Software, and to prepare derivative works of the
-** Software, and to permit third-parties to whom the Software is furnished to
-** do so, all subject to the following:
-**
-** The copyright notices in the Software and this entire statement, including
-** the above license grant, this restriction and the following disclaimer,
-** must be included in all copies of the Software, in whole or in part, and
-** all derivative works of the Software, unless such copies or derivative
-** works are solely in the form of machine-executable object code generated by
-** a source language processor.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-** DEALINGS IN THE SOFTWARE.
-** -LICENSE-END-
-*/
-
-#ifndef BMD_DECKLINKAPIDISCOVERY_H
-#define BMD_DECKLINKAPIDISCOVERY_H
-
-
-#ifndef BMD_CONST
- #if defined(_MSC_VER)
- #define BMD_CONST __declspec(selectany) static const
- #else
- #define BMD_CONST static const
- #endif
-#endif
-
-// Type Declarations
-
-
-// Interface ID Declarations
-
-BMD_CONST REFIID IID_IDeckLink = /* C418FBDD-0587-48ED-8FE5-640F0A14AF91 */ {0xC4,0x18,0xFB,0xDD,0x05,0x87,0x48,0xED,0x8F,0xE5,0x64,0x0F,0x0A,0x14,0xAF,0x91};
-
-// Forward Declarations
-
-class IDeckLink;
-
-/* Interface IDeckLink - represents a DeckLink device */
-
-class IDeckLink : public IUnknown
-{
-public:
- virtual HRESULT GetModelName (/* out */ const char **modelName) = 0;
- virtual HRESULT GetDisplayName (/* out */ const char **displayName) = 0;
-
-protected:
- virtual ~IDeckLink () {} // call Release method to drop reference count
-};
-
-/* Functions */
-
-extern "C" {
-
-
-}
-
-
-#endif /* defined(BMD_DECKLINKAPIDISCOVERY_H) */
diff --git a/intern/decklink/linux/DeckLinkAPIDispatch.cpp b/intern/decklink/linux/DeckLinkAPIDispatch.cpp
deleted file mode 100644
index 3cf53f109ac..00000000000
--- a/intern/decklink/linux/DeckLinkAPIDispatch.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/* -LICENSE-START-
-** Copyright (c) 2009 Blackmagic Design
-**
-** Permission is hereby granted, free of charge, to any person or organization
-** obtaining a copy of the software and accompanying documentation covered by
-** this license (the "Software") to use, reproduce, display, distribute,
-** execute, and transmit the Software, and to prepare derivative works of the
-** Software, and to permit third-parties to whom the Software is furnished to
-** do so, all subject to the following:
-**
-** The copyright notices in the Software and this entire statement, including
-** the above license grant, this restriction and the following disclaimer,
-** must be included in all copies of the Software, in whole or in part, and
-** all derivative works of the Software, unless such copies or derivative
-** works are solely in the form of machine-executable object code generated by
-** a source language processor.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-** DEALINGS IN THE SOFTWARE.
-** -LICENSE-END-
-**/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <pthread.h>
-#include <dlfcn.h>
-#include <ctype.h>
-
-#include "DeckLinkAPI.h"
-
-#define kDeckLinkAPI_Name "libDeckLinkAPI.so"
-#define KDeckLinkPreviewAPI_Name "libDeckLinkPreviewAPI.so"
-
-typedef IDeckLinkIterator* (*CreateIteratorFunc)(void);
-typedef IDeckLinkAPIInformation* (*CreateAPIInformationFunc)(void);
-typedef IDeckLinkGLScreenPreviewHelper* (*CreateOpenGLScreenPreviewHelperFunc)(void);
-typedef IDeckLinkVideoConversion* (*CreateVideoConversionInstanceFunc)(void);
-typedef IDeckLinkDiscovery* (*CreateDeckLinkDiscoveryInstanceFunc)(void);
-
-static pthread_once_t gDeckLinkOnceControl = PTHREAD_ONCE_INIT;
-static pthread_once_t gPreviewOnceControl = PTHREAD_ONCE_INIT;
-
-static bool gLoadedDeckLinkAPI = false;
-
-static CreateIteratorFunc gCreateIteratorFunc = NULL;
-static CreateAPIInformationFunc gCreateAPIInformationFunc = NULL;
-static CreateOpenGLScreenPreviewHelperFunc gCreateOpenGLPreviewFunc = NULL;
-static CreateVideoConversionInstanceFunc gCreateVideoConversionFunc = NULL;
-static CreateDeckLinkDiscoveryInstanceFunc gCreateDeckLinkDiscoveryFunc = NULL;
-
-static void InitDeckLinkAPI (void)
-{
- void *libraryHandle;
-
- libraryHandle = dlopen(kDeckLinkAPI_Name, RTLD_NOW|RTLD_GLOBAL);
- if (!libraryHandle)
- {
- fprintf(stderr, "%s\n", dlerror());
- return;
- }
-
- gLoadedDeckLinkAPI = true;
-
- gCreateIteratorFunc = (CreateIteratorFunc)dlsym(libraryHandle, "CreateDeckLinkIteratorInstance_0002");
- if (!gCreateIteratorFunc)
- fprintf(stderr, "%s\n", dlerror());
- gCreateAPIInformationFunc = (CreateAPIInformationFunc)dlsym(libraryHandle, "CreateDeckLinkAPIInformationInstance_0001");
- if (!gCreateAPIInformationFunc)
- fprintf(stderr, "%s\n", dlerror());
- gCreateVideoConversionFunc = (CreateVideoConversionInstanceFunc)dlsym(libraryHandle, "CreateVideoConversionInstance_0001");
- if (!gCreateVideoConversionFunc)
- fprintf(stderr, "%s\n", dlerror());
- gCreateDeckLinkDiscoveryFunc = (CreateDeckLinkDiscoveryInstanceFunc)dlsym(libraryHandle, "CreateDeckLinkDiscoveryInstance_0001");
- if (!gCreateDeckLinkDiscoveryFunc)
- fprintf(stderr, "%s\n", dlerror());
-}
-
-static void InitDeckLinkPreviewAPI (void)
-{
- void *libraryHandle;
-
- libraryHandle = dlopen(KDeckLinkPreviewAPI_Name, RTLD_NOW|RTLD_GLOBAL);
- if (!libraryHandle)
- {
- fprintf(stderr, "%s\n", dlerror());
- return;
- }
- gCreateOpenGLPreviewFunc = (CreateOpenGLScreenPreviewHelperFunc)dlsym(libraryHandle, "CreateOpenGLScreenPreviewHelper_0001");
- if (!gCreateOpenGLPreviewFunc)
- fprintf(stderr, "%s\n", dlerror());
-}
-
-bool IsDeckLinkAPIPresent (void)
-{
- // If the DeckLink API dynamic library was successfully loaded, return this knowledge to the caller
- return gLoadedDeckLinkAPI;
-}
-
-IDeckLinkIterator* CreateDeckLinkIteratorInstance (void)
-{
- pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
-
- if (gCreateIteratorFunc == NULL)
- return NULL;
- return gCreateIteratorFunc();
-}
-
-IDeckLinkAPIInformation* CreateDeckLinkAPIInformationInstance (void)
-{
- pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
-
- if (gCreateAPIInformationFunc == NULL)
- return NULL;
- return gCreateAPIInformationFunc();
-}
-
-IDeckLinkGLScreenPreviewHelper* CreateOpenGLScreenPreviewHelper (void)
-{
- pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
- pthread_once(&gPreviewOnceControl, InitDeckLinkPreviewAPI);
-
- if (gCreateOpenGLPreviewFunc == NULL)
- return NULL;
- return gCreateOpenGLPreviewFunc();
-}
-
-IDeckLinkVideoConversion* CreateVideoConversionInstance (void)
-{
- pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
-
- if (gCreateVideoConversionFunc == NULL)
- return NULL;
- return gCreateVideoConversionFunc();
-}
-
-IDeckLinkDiscovery* CreateDeckLinkDiscoveryInstance (void)
-{
- pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
-
- if (gCreateDeckLinkDiscoveryFunc == NULL)
- return NULL;
- return gCreateDeckLinkDiscoveryFunc();
-}
diff --git a/intern/decklink/linux/DeckLinkAPIModes.h b/intern/decklink/linux/DeckLinkAPIModes.h
deleted file mode 100644
index 394d68c3078..00000000000
--- a/intern/decklink/linux/DeckLinkAPIModes.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/* -LICENSE-START-
-** Copyright (c) 2014 Blackmagic Design
-**
-** Permission is hereby granted, free of charge, to any person or organization
-** obtaining a copy of the software and accompanying documentation covered by
-** this license (the "Software") to use, reproduce, display, distribute,
-** execute, and transmit the Software, and to prepare derivative works of the
-** Software, and to permit third-parties to whom the Software is furnished to
-** do so, all subject to the following:
-**
-** The copyright notices in the Software and this entire statement, including
-** the above license grant, this restriction and the following disclaimer,
-** must be included in all copies of the Software, in whole or in part, and
-** all derivative works of the Software, unless such copies or derivative
-** works are solely in the form of machine-executable object code generated by
-** a source language processor.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-** DEALINGS IN THE SOFTWARE.
-** -LICENSE-END-
-*/
-
-#ifndef BMD_DECKLINKAPIMODES_H
-#define BMD_DECKLINKAPIMODES_H
-
-
-#ifndef BMD_CONST
- #if defined(_MSC_VER)
- #define BMD_CONST __declspec(selectany) static const
- #else
- #define BMD_CONST static const
- #endif
-#endif
-
-// Type Declarations
-
-
-// Interface ID Declarations
-
-BMD_CONST REFIID IID_IDeckLinkDisplayModeIterator = /* 9C88499F-F601-4021-B80B-032E4EB41C35 */ {0x9C,0x88,0x49,0x9F,0xF6,0x01,0x40,0x21,0xB8,0x0B,0x03,0x2E,0x4E,0xB4,0x1C,0x35};
-BMD_CONST REFIID IID_IDeckLinkDisplayMode = /* 3EB2C1AB-0A3D-4523-A3AD-F40D7FB14E78 */ {0x3E,0xB2,0xC1,0xAB,0x0A,0x3D,0x45,0x23,0xA3,0xAD,0xF4,0x0D,0x7F,0xB1,0x4E,0x78};
-
-/* Enum BMDDisplayMode - Video display modes */
-
-typedef uint32_t BMDDisplayMode;
-enum _BMDDisplayMode {
-
- /* SD Modes */
-
- bmdModeNTSC = /* 'ntsc' */ 0x6E747363,
- bmdModeNTSC2398 = /* 'nt23' */ 0x6E743233, // 3:2 pulldown
- bmdModePAL = /* 'pal ' */ 0x70616C20,
- bmdModeNTSCp = /* 'ntsp' */ 0x6E747370,
- bmdModePALp = /* 'palp' */ 0x70616C70,
-
- /* HD 1080 Modes */
-
- bmdModeHD1080p2398 = /* '23ps' */ 0x32337073,
- bmdModeHD1080p24 = /* '24ps' */ 0x32347073,
- bmdModeHD1080p25 = /* 'Hp25' */ 0x48703235,
- bmdModeHD1080p2997 = /* 'Hp29' */ 0x48703239,
- bmdModeHD1080p30 = /* 'Hp30' */ 0x48703330,
- bmdModeHD1080i50 = /* 'Hi50' */ 0x48693530,
- bmdModeHD1080i5994 = /* 'Hi59' */ 0x48693539,
- bmdModeHD1080i6000 = /* 'Hi60' */ 0x48693630, // N.B. This _really_ is 60.00 Hz.
- bmdModeHD1080p50 = /* 'Hp50' */ 0x48703530,
- bmdModeHD1080p5994 = /* 'Hp59' */ 0x48703539,
- bmdModeHD1080p6000 = /* 'Hp60' */ 0x48703630, // N.B. This _really_ is 60.00 Hz.
-
- /* HD 720 Modes */
-
- bmdModeHD720p50 = /* 'hp50' */ 0x68703530,
- bmdModeHD720p5994 = /* 'hp59' */ 0x68703539,
- bmdModeHD720p60 = /* 'hp60' */ 0x68703630,
-
- /* 2k Modes */
-
- bmdMode2k2398 = /* '2k23' */ 0x326B3233,
- bmdMode2k24 = /* '2k24' */ 0x326B3234,
- bmdMode2k25 = /* '2k25' */ 0x326B3235,
-
- /* DCI Modes (output only) */
-
- bmdMode2kDCI2398 = /* '2d23' */ 0x32643233,
- bmdMode2kDCI24 = /* '2d24' */ 0x32643234,
- bmdMode2kDCI25 = /* '2d25' */ 0x32643235,
-
- /* 4k Modes */
-
- bmdMode4K2160p2398 = /* '4k23' */ 0x346B3233,
- bmdMode4K2160p24 = /* '4k24' */ 0x346B3234,
- bmdMode4K2160p25 = /* '4k25' */ 0x346B3235,
- bmdMode4K2160p2997 = /* '4k29' */ 0x346B3239,
- bmdMode4K2160p30 = /* '4k30' */ 0x346B3330,
- bmdMode4K2160p50 = /* '4k50' */ 0x346B3530,
- bmdMode4K2160p5994 = /* '4k59' */ 0x346B3539,
- bmdMode4K2160p60 = /* '4k60' */ 0x346B3630,
-
- /* DCI Modes (output only) */
-
- bmdMode4kDCI2398 = /* '4d23' */ 0x34643233,
- bmdMode4kDCI24 = /* '4d24' */ 0x34643234,
- bmdMode4kDCI25 = /* '4d25' */ 0x34643235,
-
- /* Special Modes */
-
- bmdModeUnknown = /* 'iunk' */ 0x69756E6B
-};
-
-/* Enum BMDFieldDominance - Video field dominance */
-
-typedef uint32_t BMDFieldDominance;
-enum _BMDFieldDominance {
- bmdUnknownFieldDominance = 0,
- bmdLowerFieldFirst = /* 'lowr' */ 0x6C6F7772,
- bmdUpperFieldFirst = /* 'uppr' */ 0x75707072,
- bmdProgressiveFrame = /* 'prog' */ 0x70726F67,
- bmdProgressiveSegmentedFrame = /* 'psf ' */ 0x70736620
-};
-
-/* Enum BMDPixelFormat - Video pixel formats supported for output/input */
-
-typedef uint32_t BMDPixelFormat;
-enum _BMDPixelFormat {
- bmdFormat8BitYUV = /* '2vuy' */ 0x32767579,
- bmdFormat10BitYUV = /* 'v210' */ 0x76323130,
- bmdFormat8BitARGB = 32,
- bmdFormat8BitBGRA = /* 'BGRA' */ 0x42475241,
- bmdFormat10BitRGB = /* 'r210' */ 0x72323130, // Big-endian RGB 10-bit per component with SMPTE video levels (64-960). Packed as 2:10:10:10
- bmdFormat12BitRGB = /* 'R12B' */ 0x52313242, // Big-endian RGB 12-bit per component with full range (0-4095). Packed as 12-bit per component
- bmdFormat12BitRGBLE = /* 'R12L' */ 0x5231324C, // Little-endian RGB 12-bit per component with full range (0-4095). Packed as 12-bit per component
- bmdFormat10BitRGBXLE = /* 'R10l' */ 0x5231306C, // Little-endian 10-bit RGB with SMPTE video levels (64-940)
- bmdFormat10BitRGBX = /* 'R10b' */ 0x52313062 // Big-endian 10-bit RGB with SMPTE video levels (64-940)
-};
-
-/* Enum BMDDisplayModeFlags - Flags to describe the characteristics of an IDeckLinkDisplayMode. */
-
-typedef uint32_t BMDDisplayModeFlags;
-enum _BMDDisplayModeFlags {
- bmdDisplayModeSupports3D = 1 << 0,
- bmdDisplayModeColorspaceRec601 = 1 << 1,
- bmdDisplayModeColorspaceRec709 = 1 << 2
-};
-
-// Forward Declarations
-
-class IDeckLinkDisplayModeIterator;
-class IDeckLinkDisplayMode;
-
-/* Interface IDeckLinkDisplayModeIterator - enumerates over supported input/output display modes. */
-
-class IDeckLinkDisplayModeIterator : public IUnknown
-{
-public:
- virtual HRESULT Next (/* out */ IDeckLinkDisplayMode **deckLinkDisplayMode) = 0;
-
-protected:
- virtual ~IDeckLinkDisplayModeIterator () {} // call Release method to drop reference count
-};
-
-/* Interface IDeckLinkDisplayMode - represents a display mode */
-
-class IDeckLinkDisplayMode : public IUnknown
-{
-public:
- virtual HRESULT GetName (/* out */ const char **name) = 0;
- virtual BMDDisplayMode GetDisplayMode (void) = 0;
- virtual long GetWidth (void) = 0;
- virtual long GetHeight (void) = 0;
- virtual HRESULT GetFrameRate (/* out */ BMDTimeValue *frameDuration, /* out */ BMDTimeScale *timeScale) = 0;
- virtual BMDFieldDominance GetFieldDominance (void) = 0;
- virtual BMDDisplayModeFlags GetFlags (void) = 0;
-
-protected:
- virtual ~IDeckLinkDisplayMode () {} // call Release method to drop reference count
-};
-
-/* Functions */
-
-extern "C" {
-
-
-}
-
-
-#endif /* defined(BMD_DECKLINKAPIMODES_H) */
diff --git a/intern/decklink/linux/DeckLinkAPITypes.h b/intern/decklink/linux/DeckLinkAPITypes.h
deleted file mode 100644
index 55e015f2a3c..00000000000
--- a/intern/decklink/linux/DeckLinkAPITypes.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -LICENSE-START-
-** Copyright (c) 2014 Blackmagic Design
-**
-** Permission is hereby granted, free of charge, to any person or organization
-** obtaining a copy of the software and accompanying documentation covered by
-** this license (the "Software") to use, reproduce, display, distribute,
-** execute, and transmit the Software, and to prepare derivative works of the
-** Software, and to permit third-parties to whom the Software is furnished to
-** do so, all subject to the following:
-**
-** The copyright notices in the Software and this entire statement, including
-** the above license grant, this restriction and the following disclaimer,
-** must be included in all copies of the Software, in whole or in part, and
-** all derivative works of the Software, unless such copies or derivative
-** works are solely in the form of machine-executable object code generated by
-** a source language processor.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-** DEALINGS IN THE SOFTWARE.
-** -LICENSE-END-
-*/
-
-#ifndef BMD_DECKLINKAPITYPES_H
-#define BMD_DECKLINKAPITYPES_H
-
-
-#ifndef BMD_CONST
- #if defined(_MSC_VER)
- #define BMD_CONST __declspec(selectany) static const
- #else
- #define BMD_CONST static const
- #endif
-#endif
-
-// Type Declarations
-
-typedef int64_t BMDTimeValue;
-typedef int64_t BMDTimeScale;
-typedef uint32_t BMDTimecodeBCD;
-typedef uint32_t BMDTimecodeUserBits;
-
-// Interface ID Declarations
-
-BMD_CONST REFIID IID_IDeckLinkTimecode = /* BC6CFBD3-8317-4325-AC1C-1216391E9340 */ {0xBC,0x6C,0xFB,0xD3,0x83,0x17,0x43,0x25,0xAC,0x1C,0x12,0x16,0x39,0x1E,0x93,0x40};
-
-/* Enum BMDTimecodeFlags - Timecode flags */
-
-typedef uint32_t BMDTimecodeFlags;
-enum _BMDTimecodeFlags {
- bmdTimecodeFlagDefault = 0,
- bmdTimecodeIsDropFrame = 1 << 0,
- bmdTimecodeFieldMark = 1 << 1
-};
-
-/* Enum BMDVideoConnection - Video connection types */
-
-typedef uint32_t BMDVideoConnection;
-enum _BMDVideoConnection {
- bmdVideoConnectionSDI = 1 << 0,
- bmdVideoConnectionHDMI = 1 << 1,
- bmdVideoConnectionOpticalSDI = 1 << 2,
- bmdVideoConnectionComponent = 1 << 3,
- bmdVideoConnectionComposite = 1 << 4,
- bmdVideoConnectionSVideo = 1 << 5
-};
-
-/* Enum BMDAudioConnection - Audio connection types */
-
-typedef uint32_t BMDAudioConnection;
-enum _BMDAudioConnection {
- bmdAudioConnectionEmbedded = 1 << 0,
- bmdAudioConnectionAESEBU = 1 << 1,
- bmdAudioConnectionAnalog = 1 << 2,
- bmdAudioConnectionAnalogXLR = 1 << 3,
- bmdAudioConnectionAnalogRCA = 1 << 4
-};
-
-// Forward Declarations
-
-class IDeckLinkTimecode;
-
-/* Interface IDeckLinkTimecode - Used for video frame timecode representation. */
-
-class IDeckLinkTimecode : public IUnknown
-{
-public:
- virtual BMDTimecodeBCD GetBCD (void) = 0;
- virtual HRESULT GetComponents (/* out */ uint8_t *hours, /* out */ uint8_t *minutes, /* out */ uint8_t *seconds, /* out */ uint8_t *frames) = 0;
- virtual HRESULT GetString (/* out */ const char **timecode) = 0;
- virtual BMDTimecodeFlags GetFlags (void) = 0;
- virtual HRESULT GetTimecodeUserBits (/* out */ BMDTimecodeUserBits *userBits) = 0;
-
-protected:
- virtual ~IDeckLinkTimecode () {} // call Release method to drop reference count
-};
-
-/* Functions */
-
-extern "C" {
-
-
-}
-
-
-#endif /* defined(BMD_DECKLINKAPITYPES_H) */
diff --git a/intern/decklink/linux/DeckLinkAPIVersion.h b/intern/decklink/linux/DeckLinkAPIVersion.h
deleted file mode 100644
index cfcc701c427..00000000000
--- a/intern/decklink/linux/DeckLinkAPIVersion.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -LICENSE-START-
- * ** Copyright (c) 2014 Blackmagic Design
- * **
- * ** Permission is hereby granted, free of charge, to any person or organization
- * ** obtaining a copy of the software and accompanying documentation covered by
- * ** this license (the "Software") to use, reproduce, display, distribute,
- * ** execute, and transmit the Software, and to prepare derivative works of the
- * ** Software, and to permit third-parties to whom the Software is furnished to
- * ** do so, all subject to the following:
- * **
- * ** The copyright notices in the Software and this entire statement, including
- * ** the above license grant, this restriction and the following disclaimer,
- * ** must be included in all copies of the Software, in whole or in part, and
- * ** all derivative works of the Software, unless such copies or derivative
- * ** works are solely in the form of machine-executable object code generated by
- * ** a source language processor.
- * **
- * ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * ** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
- * ** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
- * ** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
- * ** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * ** DEALINGS IN THE SOFTWARE.
- * ** -LICENSE-END-
- * */
-
-/* DeckLinkAPIVersion.h */
-
-#ifndef __DeckLink_API_Version_h__
-#define __DeckLink_API_Version_h__
-
-#define BLACKMAGIC_DECKLINK_API_VERSION 0x0a040000
-#define BLACKMAGIC_DECKLINK_API_VERSION_STRING "10.4"
-
-#endif // __DeckLink_API_Version_h__
-
diff --git a/intern/decklink/linux/LinuxCOM.h b/intern/decklink/linux/LinuxCOM.h
deleted file mode 100644
index ee783bbd58f..00000000000
--- a/intern/decklink/linux/LinuxCOM.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -LICENSE-START-
-** Copyright (c) 2009 Blackmagic Design
-**
-** Permission is hereby granted, free of charge, to any person or organization
-** obtaining a copy of the software and accompanying documentation covered by
-** this license (the "Software") to use, reproduce, display, distribute,
-** execute, and transmit the Software, and to prepare derivative works of the
-** Software, and to permit third-parties to whom the Software is furnished to
-** do so, all subject to the following:
-**
-** The copyright notices in the Software and this entire statement, including
-** the above license grant, this restriction and the following disclaimer,
-** must be included in all copies of the Software, in whole or in part, and
-** all derivative works of the Software, unless such copies or derivative
-** works are solely in the form of machine-executable object code generated by
-** a source language processor.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-** DEALINGS IN THE SOFTWARE.
-** -LICENSE-END-
-*/
-
-#ifndef __LINUX_COM_H_
-#define __LINUX_COM_H_
-
-struct REFIID
-{
- unsigned char byte0;
- unsigned char byte1;
- unsigned char byte2;
- unsigned char byte3;
- unsigned char byte4;
- unsigned char byte5;
- unsigned char byte6;
- unsigned char byte7;
- unsigned char byte8;
- unsigned char byte9;
- unsigned char byte10;
- unsigned char byte11;
- unsigned char byte12;
- unsigned char byte13;
- unsigned char byte14;
- unsigned char byte15;
-};
-
-typedef REFIID CFUUIDBytes;
-#define CFUUIDGetUUIDBytes(x) x
-
-#define _HRESULT_DEFINED
-typedef int HRESULT;
-typedef unsigned long ULONG;
-typedef void *LPVOID;
-
-#define SUCCEEDED(Status) ((HRESULT)(Status) >= 0)
-#define FAILED(Status) ((HRESULT)(Status)<0)
-
-#define IS_ERROR(Status) ((unsigned long)(Status) >> 31 == SEVERITY_ERROR)
-#define HRESULT_CODE(hr) ((hr) & 0xFFFF)
-#define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
-#define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1)
-#define SEVERITY_SUCCESS 0
-#define SEVERITY_ERROR 1
-
-#define MAKE_HRESULT(sev,fac,code) ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
-
-#define S_OK ((HRESULT)0x00000000L)
-#define S_FALSE ((HRESULT)0x00000001L)
-#define E_UNEXPECTED ((HRESULT)0x8000FFFFL)
-#define E_NOTIMPL ((HRESULT)0x80000001L)
-#define E_OUTOFMEMORY ((HRESULT)0x80000002L)
-#define E_INVALIDARG ((HRESULT)0x80000003L)
-#define E_NOINTERFACE ((HRESULT)0x80000004L)
-#define E_POINTER ((HRESULT)0x80000005L)
-#define E_HANDLE ((HRESULT)0x80000006L)
-#define E_ABORT ((HRESULT)0x80000007L)
-#define E_FAIL ((HRESULT)0x80000008L)
-#define E_ACCESSDENIED ((HRESULT)0x80000009L)
-
-#define STDMETHODCALLTYPE
-
-#define IID_IUnknown (REFIID){0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}
-#define IUnknownUUID IID_IUnknown
-
-#ifdef __cplusplus
-class IUnknown
-{
- public:
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) = 0;
- virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0;
- virtual ULONG STDMETHODCALLTYPE Release(void) = 0;
-};
-#endif
-
-#endif
-
diff --git a/intern/decklink/win/DeckLinkAPI_h.h b/intern/decklink/win/DeckLinkAPI_h.h
deleted file mode 100644
index 1bd80b6dc95..00000000000
--- a/intern/decklink/win/DeckLinkAPI_h.h
+++ /dev/null
@@ -1,13323 +0,0 @@
-
-
-/* this ALWAYS GENERATED file contains the definitions for the interfaces */
-
-
- /* File created by MIDL compiler version 8.00.0603 */
-/* at Mon Apr 13 20:57:05 2015
- */
-/* Compiler settings for ..\..\include\DeckLinkAPI.idl:
- Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.00.0603
- protocol : dce , ms_ext, c_ext, robust
- error checks: allocation ref bounds_check enum stub_data
- VC __declspec() decoration level:
- __declspec(uuid()), __declspec(selectany), __declspec(novtable)
- DECLSPEC_UUID(), MIDL_INTERFACE()
-*/
-/* @@MIDL_FILE_HEADING( ) */
-
-#pragma warning( disable: 4049 ) /* more than 64k source lines */
-
-
-/* verify that the <rpcndr.h> version is high enough to compile this file*/
-#ifndef __REQUIRED_RPCNDR_H_VERSION__
-#define __REQUIRED_RPCNDR_H_VERSION__ 475
-#endif
-
-#include "rpc.h"
-#include "rpcndr.h"
-
-#ifndef __RPCNDR_H_VERSION__
-#error this stub requires an updated version of <rpcndr.h>
-#endif // __RPCNDR_H_VERSION__
-
-
-#ifndef __DeckLinkAPI_h_h__
-#define __DeckLinkAPI_h_h__
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once
-#endif
-
-/* Forward Declarations */
-
-#ifndef __IDeckLinkTimecode_FWD_DEFINED__
-#define __IDeckLinkTimecode_FWD_DEFINED__
-typedef interface IDeckLinkTimecode IDeckLinkTimecode;
-
-#endif /* __IDeckLinkTimecode_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayModeIterator_FWD_DEFINED__
-#define __IDeckLinkDisplayModeIterator_FWD_DEFINED__
-typedef interface IDeckLinkDisplayModeIterator IDeckLinkDisplayModeIterator;
-
-#endif /* __IDeckLinkDisplayModeIterator_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayMode_FWD_DEFINED__
-#define __IDeckLinkDisplayMode_FWD_DEFINED__
-typedef interface IDeckLinkDisplayMode IDeckLinkDisplayMode;
-
-#endif /* __IDeckLinkDisplayMode_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLink_FWD_DEFINED__
-#define __IDeckLink_FWD_DEFINED__
-typedef interface IDeckLink IDeckLink;
-
-#endif /* __IDeckLink_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkConfiguration_FWD_DEFINED__
-#define __IDeckLinkConfiguration_FWD_DEFINED__
-typedef interface IDeckLinkConfiguration IDeckLinkConfiguration;
-
-#endif /* __IDeckLinkConfiguration_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeckControlStatusCallback_FWD_DEFINED__
-#define __IDeckLinkDeckControlStatusCallback_FWD_DEFINED__
-typedef interface IDeckLinkDeckControlStatusCallback IDeckLinkDeckControlStatusCallback;
-
-#endif /* __IDeckLinkDeckControlStatusCallback_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeckControl_FWD_DEFINED__
-#define __IDeckLinkDeckControl_FWD_DEFINED__
-typedef interface IDeckLinkDeckControl IDeckLinkDeckControl;
-
-#endif /* __IDeckLinkDeckControl_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingDeviceNotificationCallback_FWD_DEFINED__
-#define __IBMDStreamingDeviceNotificationCallback_FWD_DEFINED__
-typedef interface IBMDStreamingDeviceNotificationCallback IBMDStreamingDeviceNotificationCallback;
-
-#endif /* __IBMDStreamingDeviceNotificationCallback_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingH264InputCallback_FWD_DEFINED__
-#define __IBMDStreamingH264InputCallback_FWD_DEFINED__
-typedef interface IBMDStreamingH264InputCallback IBMDStreamingH264InputCallback;
-
-#endif /* __IBMDStreamingH264InputCallback_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingDiscovery_FWD_DEFINED__
-#define __IBMDStreamingDiscovery_FWD_DEFINED__
-typedef interface IBMDStreamingDiscovery IBMDStreamingDiscovery;
-
-#endif /* __IBMDStreamingDiscovery_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingVideoEncodingMode_FWD_DEFINED__
-#define __IBMDStreamingVideoEncodingMode_FWD_DEFINED__
-typedef interface IBMDStreamingVideoEncodingMode IBMDStreamingVideoEncodingMode;
-
-#endif /* __IBMDStreamingVideoEncodingMode_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingMutableVideoEncodingMode_FWD_DEFINED__
-#define __IBMDStreamingMutableVideoEncodingMode_FWD_DEFINED__
-typedef interface IBMDStreamingMutableVideoEncodingMode IBMDStreamingMutableVideoEncodingMode;
-
-#endif /* __IBMDStreamingMutableVideoEncodingMode_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingVideoEncodingModePresetIterator_FWD_DEFINED__
-#define __IBMDStreamingVideoEncodingModePresetIterator_FWD_DEFINED__
-typedef interface IBMDStreamingVideoEncodingModePresetIterator IBMDStreamingVideoEncodingModePresetIterator;
-
-#endif /* __IBMDStreamingVideoEncodingModePresetIterator_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingDeviceInput_FWD_DEFINED__
-#define __IBMDStreamingDeviceInput_FWD_DEFINED__
-typedef interface IBMDStreamingDeviceInput IBMDStreamingDeviceInput;
-
-#endif /* __IBMDStreamingDeviceInput_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingH264NALPacket_FWD_DEFINED__
-#define __IBMDStreamingH264NALPacket_FWD_DEFINED__
-typedef interface IBMDStreamingH264NALPacket IBMDStreamingH264NALPacket;
-
-#endif /* __IBMDStreamingH264NALPacket_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingAudioPacket_FWD_DEFINED__
-#define __IBMDStreamingAudioPacket_FWD_DEFINED__
-typedef interface IBMDStreamingAudioPacket IBMDStreamingAudioPacket;
-
-#endif /* __IBMDStreamingAudioPacket_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingMPEG2TSPacket_FWD_DEFINED__
-#define __IBMDStreamingMPEG2TSPacket_FWD_DEFINED__
-typedef interface IBMDStreamingMPEG2TSPacket IBMDStreamingMPEG2TSPacket;
-
-#endif /* __IBMDStreamingMPEG2TSPacket_FWD_DEFINED__ */
-
-
-#ifndef __IBMDStreamingH264NALParser_FWD_DEFINED__
-#define __IBMDStreamingH264NALParser_FWD_DEFINED__
-typedef interface IBMDStreamingH264NALParser IBMDStreamingH264NALParser;
-
-#endif /* __IBMDStreamingH264NALParser_FWD_DEFINED__ */
-
-
-#ifndef __CBMDStreamingDiscovery_FWD_DEFINED__
-#define __CBMDStreamingDiscovery_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CBMDStreamingDiscovery CBMDStreamingDiscovery;
-#else
-typedef struct CBMDStreamingDiscovery CBMDStreamingDiscovery;
-#endif /* __cplusplus */
-
-#endif /* __CBMDStreamingDiscovery_FWD_DEFINED__ */
-
-
-#ifndef __CBMDStreamingH264NALParser_FWD_DEFINED__
-#define __CBMDStreamingH264NALParser_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CBMDStreamingH264NALParser CBMDStreamingH264NALParser;
-#else
-typedef struct CBMDStreamingH264NALParser CBMDStreamingH264NALParser;
-#endif /* __cplusplus */
-
-#endif /* __CBMDStreamingH264NALParser_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoOutputCallback_FWD_DEFINED__
-#define __IDeckLinkVideoOutputCallback_FWD_DEFINED__
-typedef interface IDeckLinkVideoOutputCallback IDeckLinkVideoOutputCallback;
-
-#endif /* __IDeckLinkVideoOutputCallback_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkInputCallback_FWD_DEFINED__
-#define __IDeckLinkInputCallback_FWD_DEFINED__
-typedef interface IDeckLinkInputCallback IDeckLinkInputCallback;
-
-#endif /* __IDeckLinkInputCallback_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkMemoryAllocator_FWD_DEFINED__
-#define __IDeckLinkMemoryAllocator_FWD_DEFINED__
-typedef interface IDeckLinkMemoryAllocator IDeckLinkMemoryAllocator;
-
-#endif /* __IDeckLinkMemoryAllocator_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkAudioOutputCallback_FWD_DEFINED__
-#define __IDeckLinkAudioOutputCallback_FWD_DEFINED__
-typedef interface IDeckLinkAudioOutputCallback IDeckLinkAudioOutputCallback;
-
-#endif /* __IDeckLinkAudioOutputCallback_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkIterator_FWD_DEFINED__
-#define __IDeckLinkIterator_FWD_DEFINED__
-typedef interface IDeckLinkIterator IDeckLinkIterator;
-
-#endif /* __IDeckLinkIterator_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkAPIInformation_FWD_DEFINED__
-#define __IDeckLinkAPIInformation_FWD_DEFINED__
-typedef interface IDeckLinkAPIInformation IDeckLinkAPIInformation;
-
-#endif /* __IDeckLinkAPIInformation_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_FWD_DEFINED__
-#define __IDeckLinkOutput_FWD_DEFINED__
-typedef interface IDeckLinkOutput IDeckLinkOutput;
-
-#endif /* __IDeckLinkOutput_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_FWD_DEFINED__
-#define __IDeckLinkInput_FWD_DEFINED__
-typedef interface IDeckLinkInput IDeckLinkInput;
-
-#endif /* __IDeckLinkInput_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrame_FWD_DEFINED__
-#define __IDeckLinkVideoFrame_FWD_DEFINED__
-typedef interface IDeckLinkVideoFrame IDeckLinkVideoFrame;
-
-#endif /* __IDeckLinkVideoFrame_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkMutableVideoFrame_FWD_DEFINED__
-#define __IDeckLinkMutableVideoFrame_FWD_DEFINED__
-typedef interface IDeckLinkMutableVideoFrame IDeckLinkMutableVideoFrame;
-
-#endif /* __IDeckLinkMutableVideoFrame_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrame3DExtensions_FWD_DEFINED__
-#define __IDeckLinkVideoFrame3DExtensions_FWD_DEFINED__
-typedef interface IDeckLinkVideoFrame3DExtensions IDeckLinkVideoFrame3DExtensions;
-
-#endif /* __IDeckLinkVideoFrame3DExtensions_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoInputFrame_FWD_DEFINED__
-#define __IDeckLinkVideoInputFrame_FWD_DEFINED__
-typedef interface IDeckLinkVideoInputFrame IDeckLinkVideoInputFrame;
-
-#endif /* __IDeckLinkVideoInputFrame_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrameAncillary_FWD_DEFINED__
-#define __IDeckLinkVideoFrameAncillary_FWD_DEFINED__
-typedef interface IDeckLinkVideoFrameAncillary IDeckLinkVideoFrameAncillary;
-
-#endif /* __IDeckLinkVideoFrameAncillary_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkAudioInputPacket_FWD_DEFINED__
-#define __IDeckLinkAudioInputPacket_FWD_DEFINED__
-typedef interface IDeckLinkAudioInputPacket IDeckLinkAudioInputPacket;
-
-#endif /* __IDeckLinkAudioInputPacket_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkScreenPreviewCallback_FWD_DEFINED__
-#define __IDeckLinkScreenPreviewCallback_FWD_DEFINED__
-typedef interface IDeckLinkScreenPreviewCallback IDeckLinkScreenPreviewCallback;
-
-#endif /* __IDeckLinkScreenPreviewCallback_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkGLScreenPreviewHelper_FWD_DEFINED__
-#define __IDeckLinkGLScreenPreviewHelper_FWD_DEFINED__
-typedef interface IDeckLinkGLScreenPreviewHelper IDeckLinkGLScreenPreviewHelper;
-
-#endif /* __IDeckLinkGLScreenPreviewHelper_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDX9ScreenPreviewHelper_FWD_DEFINED__
-#define __IDeckLinkDX9ScreenPreviewHelper_FWD_DEFINED__
-typedef interface IDeckLinkDX9ScreenPreviewHelper IDeckLinkDX9ScreenPreviewHelper;
-
-#endif /* __IDeckLinkDX9ScreenPreviewHelper_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkNotificationCallback_FWD_DEFINED__
-#define __IDeckLinkNotificationCallback_FWD_DEFINED__
-typedef interface IDeckLinkNotificationCallback IDeckLinkNotificationCallback;
-
-#endif /* __IDeckLinkNotificationCallback_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkNotification_FWD_DEFINED__
-#define __IDeckLinkNotification_FWD_DEFINED__
-typedef interface IDeckLinkNotification IDeckLinkNotification;
-
-#endif /* __IDeckLinkNotification_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkAttributes_FWD_DEFINED__
-#define __IDeckLinkAttributes_FWD_DEFINED__
-typedef interface IDeckLinkAttributes IDeckLinkAttributes;
-
-#endif /* __IDeckLinkAttributes_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkKeyer_FWD_DEFINED__
-#define __IDeckLinkKeyer_FWD_DEFINED__
-typedef interface IDeckLinkKeyer IDeckLinkKeyer;
-
-#endif /* __IDeckLinkKeyer_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoConversion_FWD_DEFINED__
-#define __IDeckLinkVideoConversion_FWD_DEFINED__
-typedef interface IDeckLinkVideoConversion IDeckLinkVideoConversion;
-
-#endif /* __IDeckLinkVideoConversion_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeviceNotificationCallback_FWD_DEFINED__
-#define __IDeckLinkDeviceNotificationCallback_FWD_DEFINED__
-typedef interface IDeckLinkDeviceNotificationCallback IDeckLinkDeviceNotificationCallback;
-
-#endif /* __IDeckLinkDeviceNotificationCallback_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDiscovery_FWD_DEFINED__
-#define __IDeckLinkDiscovery_FWD_DEFINED__
-typedef interface IDeckLinkDiscovery IDeckLinkDiscovery;
-
-#endif /* __IDeckLinkDiscovery_FWD_DEFINED__ */
-
-
-#ifndef __CDeckLinkIterator_FWD_DEFINED__
-#define __CDeckLinkIterator_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CDeckLinkIterator CDeckLinkIterator;
-#else
-typedef struct CDeckLinkIterator CDeckLinkIterator;
-#endif /* __cplusplus */
-
-#endif /* __CDeckLinkIterator_FWD_DEFINED__ */
-
-
-#ifndef __CDeckLinkAPIInformation_FWD_DEFINED__
-#define __CDeckLinkAPIInformation_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CDeckLinkAPIInformation CDeckLinkAPIInformation;
-#else
-typedef struct CDeckLinkAPIInformation CDeckLinkAPIInformation;
-#endif /* __cplusplus */
-
-#endif /* __CDeckLinkAPIInformation_FWD_DEFINED__ */
-
-
-#ifndef __CDeckLinkGLScreenPreviewHelper_FWD_DEFINED__
-#define __CDeckLinkGLScreenPreviewHelper_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CDeckLinkGLScreenPreviewHelper CDeckLinkGLScreenPreviewHelper;
-#else
-typedef struct CDeckLinkGLScreenPreviewHelper CDeckLinkGLScreenPreviewHelper;
-#endif /* __cplusplus */
-
-#endif /* __CDeckLinkGLScreenPreviewHelper_FWD_DEFINED__ */
-
-
-#ifndef __CDeckLinkDX9ScreenPreviewHelper_FWD_DEFINED__
-#define __CDeckLinkDX9ScreenPreviewHelper_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CDeckLinkDX9ScreenPreviewHelper CDeckLinkDX9ScreenPreviewHelper;
-#else
-typedef struct CDeckLinkDX9ScreenPreviewHelper CDeckLinkDX9ScreenPreviewHelper;
-#endif /* __cplusplus */
-
-#endif /* __CDeckLinkDX9ScreenPreviewHelper_FWD_DEFINED__ */
-
-
-#ifndef __CDeckLinkVideoConversion_FWD_DEFINED__
-#define __CDeckLinkVideoConversion_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CDeckLinkVideoConversion CDeckLinkVideoConversion;
-#else
-typedef struct CDeckLinkVideoConversion CDeckLinkVideoConversion;
-#endif /* __cplusplus */
-
-#endif /* __CDeckLinkVideoConversion_FWD_DEFINED__ */
-
-
-#ifndef __CDeckLinkDiscovery_FWD_DEFINED__
-#define __CDeckLinkDiscovery_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CDeckLinkDiscovery CDeckLinkDiscovery;
-#else
-typedef struct CDeckLinkDiscovery CDeckLinkDiscovery;
-#endif /* __cplusplus */
-
-#endif /* __CDeckLinkDiscovery_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkConfiguration_v10_2_FWD_DEFINED__
-#define __IDeckLinkConfiguration_v10_2_FWD_DEFINED__
-typedef interface IDeckLinkConfiguration_v10_2 IDeckLinkConfiguration_v10_2;
-
-#endif /* __IDeckLinkConfiguration_v10_2_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_v9_9_FWD_DEFINED__
-#define __IDeckLinkOutput_v9_9_FWD_DEFINED__
-typedef interface IDeckLinkOutput_v9_9 IDeckLinkOutput_v9_9;
-
-#endif /* __IDeckLinkOutput_v9_9_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_v9_2_FWD_DEFINED__
-#define __IDeckLinkInput_v9_2_FWD_DEFINED__
-typedef interface IDeckLinkInput_v9_2 IDeckLinkInput_v9_2;
-
-#endif /* __IDeckLinkInput_v9_2_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeckControlStatusCallback_v8_1_FWD_DEFINED__
-#define __IDeckLinkDeckControlStatusCallback_v8_1_FWD_DEFINED__
-typedef interface IDeckLinkDeckControlStatusCallback_v8_1 IDeckLinkDeckControlStatusCallback_v8_1;
-
-#endif /* __IDeckLinkDeckControlStatusCallback_v8_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeckControl_v8_1_FWD_DEFINED__
-#define __IDeckLinkDeckControl_v8_1_FWD_DEFINED__
-typedef interface IDeckLinkDeckControl_v8_1 IDeckLinkDeckControl_v8_1;
-
-#endif /* __IDeckLinkDeckControl_v8_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLink_v8_0_FWD_DEFINED__
-#define __IDeckLink_v8_0_FWD_DEFINED__
-typedef interface IDeckLink_v8_0 IDeckLink_v8_0;
-
-#endif /* __IDeckLink_v8_0_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkIterator_v8_0_FWD_DEFINED__
-#define __IDeckLinkIterator_v8_0_FWD_DEFINED__
-typedef interface IDeckLinkIterator_v8_0 IDeckLinkIterator_v8_0;
-
-#endif /* __IDeckLinkIterator_v8_0_FWD_DEFINED__ */
-
-
-#ifndef __CDeckLinkIterator_v8_0_FWD_DEFINED__
-#define __CDeckLinkIterator_v8_0_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CDeckLinkIterator_v8_0 CDeckLinkIterator_v8_0;
-#else
-typedef struct CDeckLinkIterator_v8_0 CDeckLinkIterator_v8_0;
-#endif /* __cplusplus */
-
-#endif /* __CDeckLinkIterator_v8_0_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeckControl_v7_9_FWD_DEFINED__
-#define __IDeckLinkDeckControl_v7_9_FWD_DEFINED__
-typedef interface IDeckLinkDeckControl_v7_9 IDeckLinkDeckControl_v7_9;
-
-#endif /* __IDeckLinkDeckControl_v7_9_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayModeIterator_v7_6_FWD_DEFINED__
-#define __IDeckLinkDisplayModeIterator_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkDisplayModeIterator_v7_6 IDeckLinkDisplayModeIterator_v7_6;
-
-#endif /* __IDeckLinkDisplayModeIterator_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayMode_v7_6_FWD_DEFINED__
-#define __IDeckLinkDisplayMode_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkDisplayMode_v7_6 IDeckLinkDisplayMode_v7_6;
-
-#endif /* __IDeckLinkDisplayMode_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_v7_6_FWD_DEFINED__
-#define __IDeckLinkOutput_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkOutput_v7_6 IDeckLinkOutput_v7_6;
-
-#endif /* __IDeckLinkOutput_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_v7_6_FWD_DEFINED__
-#define __IDeckLinkInput_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkInput_v7_6 IDeckLinkInput_v7_6;
-
-#endif /* __IDeckLinkInput_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkTimecode_v7_6_FWD_DEFINED__
-#define __IDeckLinkTimecode_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkTimecode_v7_6 IDeckLinkTimecode_v7_6;
-
-#endif /* __IDeckLinkTimecode_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrame_v7_6_FWD_DEFINED__
-#define __IDeckLinkVideoFrame_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkVideoFrame_v7_6 IDeckLinkVideoFrame_v7_6;
-
-#endif /* __IDeckLinkVideoFrame_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkMutableVideoFrame_v7_6_FWD_DEFINED__
-#define __IDeckLinkMutableVideoFrame_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkMutableVideoFrame_v7_6 IDeckLinkMutableVideoFrame_v7_6;
-
-#endif /* __IDeckLinkMutableVideoFrame_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoInputFrame_v7_6_FWD_DEFINED__
-#define __IDeckLinkVideoInputFrame_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkVideoInputFrame_v7_6 IDeckLinkVideoInputFrame_v7_6;
-
-#endif /* __IDeckLinkVideoInputFrame_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkScreenPreviewCallback_v7_6_FWD_DEFINED__
-#define __IDeckLinkScreenPreviewCallback_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkScreenPreviewCallback_v7_6 IDeckLinkScreenPreviewCallback_v7_6;
-
-#endif /* __IDeckLinkScreenPreviewCallback_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkGLScreenPreviewHelper_v7_6_FWD_DEFINED__
-#define __IDeckLinkGLScreenPreviewHelper_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkGLScreenPreviewHelper_v7_6 IDeckLinkGLScreenPreviewHelper_v7_6;
-
-#endif /* __IDeckLinkGLScreenPreviewHelper_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoConversion_v7_6_FWD_DEFINED__
-#define __IDeckLinkVideoConversion_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkVideoConversion_v7_6 IDeckLinkVideoConversion_v7_6;
-
-#endif /* __IDeckLinkVideoConversion_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkConfiguration_v7_6_FWD_DEFINED__
-#define __IDeckLinkConfiguration_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkConfiguration_v7_6 IDeckLinkConfiguration_v7_6;
-
-#endif /* __IDeckLinkConfiguration_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoOutputCallback_v7_6_FWD_DEFINED__
-#define __IDeckLinkVideoOutputCallback_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkVideoOutputCallback_v7_6 IDeckLinkVideoOutputCallback_v7_6;
-
-#endif /* __IDeckLinkVideoOutputCallback_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkInputCallback_v7_6_FWD_DEFINED__
-#define __IDeckLinkInputCallback_v7_6_FWD_DEFINED__
-typedef interface IDeckLinkInputCallback_v7_6 IDeckLinkInputCallback_v7_6;
-
-#endif /* __IDeckLinkInputCallback_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __CDeckLinkGLScreenPreviewHelper_v7_6_FWD_DEFINED__
-#define __CDeckLinkGLScreenPreviewHelper_v7_6_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CDeckLinkGLScreenPreviewHelper_v7_6 CDeckLinkGLScreenPreviewHelper_v7_6;
-#else
-typedef struct CDeckLinkGLScreenPreviewHelper_v7_6 CDeckLinkGLScreenPreviewHelper_v7_6;
-#endif /* __cplusplus */
-
-#endif /* __CDeckLinkGLScreenPreviewHelper_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __CDeckLinkVideoConversion_v7_6_FWD_DEFINED__
-#define __CDeckLinkVideoConversion_v7_6_FWD_DEFINED__
-
-#ifdef __cplusplus
-typedef class CDeckLinkVideoConversion_v7_6 CDeckLinkVideoConversion_v7_6;
-#else
-typedef struct CDeckLinkVideoConversion_v7_6 CDeckLinkVideoConversion_v7_6;
-#endif /* __cplusplus */
-
-#endif /* __CDeckLinkVideoConversion_v7_6_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkInputCallback_v7_3_FWD_DEFINED__
-#define __IDeckLinkInputCallback_v7_3_FWD_DEFINED__
-typedef interface IDeckLinkInputCallback_v7_3 IDeckLinkInputCallback_v7_3;
-
-#endif /* __IDeckLinkInputCallback_v7_3_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_v7_3_FWD_DEFINED__
-#define __IDeckLinkOutput_v7_3_FWD_DEFINED__
-typedef interface IDeckLinkOutput_v7_3 IDeckLinkOutput_v7_3;
-
-#endif /* __IDeckLinkOutput_v7_3_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_v7_3_FWD_DEFINED__
-#define __IDeckLinkInput_v7_3_FWD_DEFINED__
-typedef interface IDeckLinkInput_v7_3 IDeckLinkInput_v7_3;
-
-#endif /* __IDeckLinkInput_v7_3_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoInputFrame_v7_3_FWD_DEFINED__
-#define __IDeckLinkVideoInputFrame_v7_3_FWD_DEFINED__
-typedef interface IDeckLinkVideoInputFrame_v7_3 IDeckLinkVideoInputFrame_v7_3;
-
-#endif /* __IDeckLinkVideoInputFrame_v7_3_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayModeIterator_v7_1_FWD_DEFINED__
-#define __IDeckLinkDisplayModeIterator_v7_1_FWD_DEFINED__
-typedef interface IDeckLinkDisplayModeIterator_v7_1 IDeckLinkDisplayModeIterator_v7_1;
-
-#endif /* __IDeckLinkDisplayModeIterator_v7_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayMode_v7_1_FWD_DEFINED__
-#define __IDeckLinkDisplayMode_v7_1_FWD_DEFINED__
-typedef interface IDeckLinkDisplayMode_v7_1 IDeckLinkDisplayMode_v7_1;
-
-#endif /* __IDeckLinkDisplayMode_v7_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrame_v7_1_FWD_DEFINED__
-#define __IDeckLinkVideoFrame_v7_1_FWD_DEFINED__
-typedef interface IDeckLinkVideoFrame_v7_1 IDeckLinkVideoFrame_v7_1;
-
-#endif /* __IDeckLinkVideoFrame_v7_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoInputFrame_v7_1_FWD_DEFINED__
-#define __IDeckLinkVideoInputFrame_v7_1_FWD_DEFINED__
-typedef interface IDeckLinkVideoInputFrame_v7_1 IDeckLinkVideoInputFrame_v7_1;
-
-#endif /* __IDeckLinkVideoInputFrame_v7_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkAudioInputPacket_v7_1_FWD_DEFINED__
-#define __IDeckLinkAudioInputPacket_v7_1_FWD_DEFINED__
-typedef interface IDeckLinkAudioInputPacket_v7_1 IDeckLinkAudioInputPacket_v7_1;
-
-#endif /* __IDeckLinkAudioInputPacket_v7_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoOutputCallback_v7_1_FWD_DEFINED__
-#define __IDeckLinkVideoOutputCallback_v7_1_FWD_DEFINED__
-typedef interface IDeckLinkVideoOutputCallback_v7_1 IDeckLinkVideoOutputCallback_v7_1;
-
-#endif /* __IDeckLinkVideoOutputCallback_v7_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkInputCallback_v7_1_FWD_DEFINED__
-#define __IDeckLinkInputCallback_v7_1_FWD_DEFINED__
-typedef interface IDeckLinkInputCallback_v7_1 IDeckLinkInputCallback_v7_1;
-
-#endif /* __IDeckLinkInputCallback_v7_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_v7_1_FWD_DEFINED__
-#define __IDeckLinkOutput_v7_1_FWD_DEFINED__
-typedef interface IDeckLinkOutput_v7_1 IDeckLinkOutput_v7_1;
-
-#endif /* __IDeckLinkOutput_v7_1_FWD_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_v7_1_FWD_DEFINED__
-#define __IDeckLinkInput_v7_1_FWD_DEFINED__
-typedef interface IDeckLinkInput_v7_1 IDeckLinkInput_v7_1;
-
-#endif /* __IDeckLinkInput_v7_1_FWD_DEFINED__ */
-
-
-/* header files for imported files */
-#include "unknwn.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-
-
-#ifndef __DeckLinkAPI_LIBRARY_DEFINED__
-#define __DeckLinkAPI_LIBRARY_DEFINED__
-
-/* library DeckLinkAPI */
-/* [helpstring][version][uuid] */
-
-typedef LONGLONG BMDTimeValue;
-
-typedef LONGLONG BMDTimeScale;
-
-typedef unsigned int BMDTimecodeBCD;
-
-typedef unsigned int BMDTimecodeUserBits;
-
-typedef unsigned int BMDTimecodeFlags;
-#if 0
-typedef enum _BMDTimecodeFlags BMDTimecodeFlags;
-
-#endif
-/* [v1_enum] */
-enum _BMDTimecodeFlags
- {
- bmdTimecodeFlagDefault = 0,
- bmdTimecodeIsDropFrame = ( 1 << 0 ) ,
- bmdTimecodeFieldMark = ( 1 << 1 )
- } ;
-typedef /* [v1_enum] */
-enum _BMDVideoConnection
- {
- bmdVideoConnectionSDI = ( 1 << 0 ) ,
- bmdVideoConnectionHDMI = ( 1 << 1 ) ,
- bmdVideoConnectionOpticalSDI = ( 1 << 2 ) ,
- bmdVideoConnectionComponent = ( 1 << 3 ) ,
- bmdVideoConnectionComposite = ( 1 << 4 ) ,
- bmdVideoConnectionSVideo = ( 1 << 5 )
- } BMDVideoConnection;
-
-typedef /* [v1_enum] */
-enum _BMDAudioConnection
- {
- bmdAudioConnectionEmbedded = ( 1 << 0 ) ,
- bmdAudioConnectionAESEBU = ( 1 << 1 ) ,
- bmdAudioConnectionAnalog = ( 1 << 2 ) ,
- bmdAudioConnectionAnalogXLR = ( 1 << 3 ) ,
- bmdAudioConnectionAnalogRCA = ( 1 << 4 )
- } BMDAudioConnection;
-
-
-typedef unsigned int BMDDisplayModeFlags;
-#if 0
-typedef enum _BMDDisplayModeFlags BMDDisplayModeFlags;
-
-#endif
-typedef /* [v1_enum] */
-enum _BMDDisplayMode
- {
- bmdModeNTSC = 0x6e747363,
- bmdModeNTSC2398 = 0x6e743233,
- bmdModePAL = 0x70616c20,
- bmdModeNTSCp = 0x6e747370,
- bmdModePALp = 0x70616c70,
- bmdModeHD1080p2398 = 0x32337073,
- bmdModeHD1080p24 = 0x32347073,
- bmdModeHD1080p25 = 0x48703235,
- bmdModeHD1080p2997 = 0x48703239,
- bmdModeHD1080p30 = 0x48703330,
- bmdModeHD1080i50 = 0x48693530,
- bmdModeHD1080i5994 = 0x48693539,
- bmdModeHD1080i6000 = 0x48693630,
- bmdModeHD1080p50 = 0x48703530,
- bmdModeHD1080p5994 = 0x48703539,
- bmdModeHD1080p6000 = 0x48703630,
- bmdModeHD720p50 = 0x68703530,
- bmdModeHD720p5994 = 0x68703539,
- bmdModeHD720p60 = 0x68703630,
- bmdMode2k2398 = 0x326b3233,
- bmdMode2k24 = 0x326b3234,
- bmdMode2k25 = 0x326b3235,
- bmdMode2kDCI2398 = 0x32643233,
- bmdMode2kDCI24 = 0x32643234,
- bmdMode2kDCI25 = 0x32643235,
- bmdMode4K2160p2398 = 0x346b3233,
- bmdMode4K2160p24 = 0x346b3234,
- bmdMode4K2160p25 = 0x346b3235,
- bmdMode4K2160p2997 = 0x346b3239,
- bmdMode4K2160p30 = 0x346b3330,
- bmdMode4K2160p50 = 0x346b3530,
- bmdMode4K2160p5994 = 0x346b3539,
- bmdMode4K2160p60 = 0x346b3630,
- bmdMode4kDCI2398 = 0x34643233,
- bmdMode4kDCI24 = 0x34643234,
- bmdMode4kDCI25 = 0x34643235,
- bmdModeUnknown = 0x69756e6b
- } BMDDisplayMode;
-
-typedef /* [v1_enum] */
-enum _BMDFieldDominance
- {
- bmdUnknownFieldDominance = 0,
- bmdLowerFieldFirst = 0x6c6f7772,
- bmdUpperFieldFirst = 0x75707072,
- bmdProgressiveFrame = 0x70726f67,
- bmdProgressiveSegmentedFrame = 0x70736620
- } BMDFieldDominance;
-
-typedef /* [v1_enum] */
-enum _BMDPixelFormat
- {
- bmdFormat8BitYUV = 0x32767579,
- bmdFormat10BitYUV = 0x76323130,
- bmdFormat8BitARGB = 32,
- bmdFormat8BitBGRA = 0x42475241,
- bmdFormat10BitRGB = 0x72323130,
- bmdFormat12BitRGB = 0x52313242,
- bmdFormat12BitRGBLE = 0x5231324c,
- bmdFormat10BitRGBXLE = 0x5231306c,
- bmdFormat10BitRGBX = 0x52313062
- } BMDPixelFormat;
-
-/* [v1_enum] */
-enum _BMDDisplayModeFlags
- {
- bmdDisplayModeSupports3D = ( 1 << 0 ) ,
- bmdDisplayModeColorspaceRec601 = ( 1 << 1 ) ,
- bmdDisplayModeColorspaceRec709 = ( 1 << 2 )
- } ;
-
-
-#if 0
-#endif
-
-#if 0
-#endif
-typedef /* [v1_enum] */
-enum _BMDDeckLinkConfigurationID
- {
- bmdDeckLinkConfigSwapSerialRxTx = 0x73737274,
- bmdDeckLinkConfigUse1080pNotPsF = 0x6670726f,
- bmdDeckLinkConfigHDMI3DPackingFormat = 0x33647066,
- bmdDeckLinkConfigBypass = 0x62797073,
- bmdDeckLinkConfigClockTimingAdjustment = 0x63746164,
- bmdDeckLinkConfigAnalogAudioConsumerLevels = 0x6161636c,
- bmdDeckLinkConfigFieldFlickerRemoval = 0x66646672,
- bmdDeckLinkConfigHD1080p24ToHD1080i5994Conversion = 0x746f3539,
- bmdDeckLinkConfig444SDIVideoOutput = 0x3434346f,
- bmdDeckLinkConfigSingleLinkVideoOutput = 0x73676c6f,
- bmdDeckLinkConfigBlackVideoOutputDuringCapture = 0x62766f63,
- bmdDeckLinkConfigLowLatencyVideoOutput = 0x6c6c766f,
- bmdDeckLinkConfigDownConversionOnAllAnalogOutput = 0x6361616f,
- bmdDeckLinkConfigSMPTELevelAOutput = 0x736d7461,
- bmdDeckLinkConfigVideoOutputConnection = 0x766f636e,
- bmdDeckLinkConfigVideoOutputConversionMode = 0x766f636d,
- bmdDeckLinkConfigAnalogVideoOutputFlags = 0x61766f66,
- bmdDeckLinkConfigReferenceInputTimingOffset = 0x676c6f74,
- bmdDeckLinkConfigVideoOutputIdleOperation = 0x766f696f,
- bmdDeckLinkConfigDefaultVideoOutputMode = 0x64766f6d,
- bmdDeckLinkConfigDefaultVideoOutputModeFlags = 0x64766f66,
- bmdDeckLinkConfigVideoOutputComponentLumaGain = 0x6f636c67,
- bmdDeckLinkConfigVideoOutputComponentChromaBlueGain = 0x6f636362,
- bmdDeckLinkConfigVideoOutputComponentChromaRedGain = 0x6f636372,
- bmdDeckLinkConfigVideoOutputCompositeLumaGain = 0x6f696c67,
- bmdDeckLinkConfigVideoOutputCompositeChromaGain = 0x6f696367,
- bmdDeckLinkConfigVideoOutputSVideoLumaGain = 0x6f736c67,
- bmdDeckLinkConfigVideoOutputSVideoChromaGain = 0x6f736367,
- bmdDeckLinkConfigVideoInputScanning = 0x76697363,
- bmdDeckLinkConfigUseDedicatedLTCInput = 0x646c7463,
- bmdDeckLinkConfigVideoInputConnection = 0x7669636e,
- bmdDeckLinkConfigAnalogVideoInputFlags = 0x61766966,
- bmdDeckLinkConfigVideoInputConversionMode = 0x7669636d,
- bmdDeckLinkConfig32PulldownSequenceInitialTimecodeFrame = 0x70646966,
- bmdDeckLinkConfigVANCSourceLine1Mapping = 0x76736c31,
- bmdDeckLinkConfigVANCSourceLine2Mapping = 0x76736c32,
- bmdDeckLinkConfigVANCSourceLine3Mapping = 0x76736c33,
- bmdDeckLinkConfigCapturePassThroughMode = 0x6370746d,
- bmdDeckLinkConfigVideoInputComponentLumaGain = 0x69636c67,
- bmdDeckLinkConfigVideoInputComponentChromaBlueGain = 0x69636362,
- bmdDeckLinkConfigVideoInputComponentChromaRedGain = 0x69636372,
- bmdDeckLinkConfigVideoInputCompositeLumaGain = 0x69696c67,
- bmdDeckLinkConfigVideoInputCompositeChromaGain = 0x69696367,
- bmdDeckLinkConfigVideoInputSVideoLumaGain = 0x69736c67,
- bmdDeckLinkConfigVideoInputSVideoChromaGain = 0x69736367,
- bmdDeckLinkConfigAudioInputConnection = 0x6169636e,
- bmdDeckLinkConfigAnalogAudioInputScaleChannel1 = 0x61697331,
- bmdDeckLinkConfigAnalogAudioInputScaleChannel2 = 0x61697332,
- bmdDeckLinkConfigAnalogAudioInputScaleChannel3 = 0x61697333,
- bmdDeckLinkConfigAnalogAudioInputScaleChannel4 = 0x61697334,
- bmdDeckLinkConfigDigitalAudioInputScale = 0x64616973,
- bmdDeckLinkConfigAudioOutputAESAnalogSwitch = 0x616f6161,
- bmdDeckLinkConfigAnalogAudioOutputScaleChannel1 = 0x616f7331,
- bmdDeckLinkConfigAnalogAudioOutputScaleChannel2 = 0x616f7332,
- bmdDeckLinkConfigAnalogAudioOutputScaleChannel3 = 0x616f7333,
- bmdDeckLinkConfigAnalogAudioOutputScaleChannel4 = 0x616f7334,
- bmdDeckLinkConfigDigitalAudioOutputScale = 0x64616f73,
- bmdDeckLinkConfigDeviceInformationLabel = 0x64696c61,
- bmdDeckLinkConfigDeviceInformationSerialNumber = 0x6469736e,
- bmdDeckLinkConfigDeviceInformationCompany = 0x6469636f,
- bmdDeckLinkConfigDeviceInformationPhone = 0x64697068,
- bmdDeckLinkConfigDeviceInformationEmail = 0x6469656d,
- bmdDeckLinkConfigDeviceInformationDate = 0x64696461
- } BMDDeckLinkConfigurationID;
-
-
-typedef unsigned int BMDDeckControlStatusFlags;
-typedef unsigned int BMDDeckControlExportModeOpsFlags;
-#if 0
-typedef enum _BMDDeckControlStatusFlags BMDDeckControlStatusFlags;
-
-typedef enum _BMDDeckControlExportModeOpsFlags BMDDeckControlExportModeOpsFlags;
-
-#endif
-typedef /* [v1_enum] */
-enum _BMDDeckControlMode
- {
- bmdDeckControlNotOpened = 0x6e746f70,
- bmdDeckControlVTRControlMode = 0x76747263,
- bmdDeckControlExportMode = 0x6578706d,
- bmdDeckControlCaptureMode = 0x6361706d
- } BMDDeckControlMode;
-
-typedef /* [v1_enum] */
-enum _BMDDeckControlEvent
- {
- bmdDeckControlAbortedEvent = 0x61627465,
- bmdDeckControlPrepareForExportEvent = 0x70666565,
- bmdDeckControlExportCompleteEvent = 0x65786365,
- bmdDeckControlPrepareForCaptureEvent = 0x70666365,
- bmdDeckControlCaptureCompleteEvent = 0x63636576
- } BMDDeckControlEvent;
-
-typedef /* [v1_enum] */
-enum _BMDDeckControlVTRControlState
- {
- bmdDeckControlNotInVTRControlMode = 0x6e76636d,
- bmdDeckControlVTRControlPlaying = 0x76747270,
- bmdDeckControlVTRControlRecording = 0x76747272,
- bmdDeckControlVTRControlStill = 0x76747261,
- bmdDeckControlVTRControlShuttleForward = 0x76747366,
- bmdDeckControlVTRControlShuttleReverse = 0x76747372,
- bmdDeckControlVTRControlJogForward = 0x76746a66,
- bmdDeckControlVTRControlJogReverse = 0x76746a72,
- bmdDeckControlVTRControlStopped = 0x7674726f
- } BMDDeckControlVTRControlState;
-
-/* [v1_enum] */
-enum _BMDDeckControlStatusFlags
- {
- bmdDeckControlStatusDeckConnected = ( 1 << 0 ) ,
- bmdDeckControlStatusRemoteMode = ( 1 << 1 ) ,
- bmdDeckControlStatusRecordInhibited = ( 1 << 2 ) ,
- bmdDeckControlStatusCassetteOut = ( 1 << 3 )
- } ;
-/* [v1_enum] */
-enum _BMDDeckControlExportModeOpsFlags
- {
- bmdDeckControlExportModeInsertVideo = ( 1 << 0 ) ,
- bmdDeckControlExportModeInsertAudio1 = ( 1 << 1 ) ,
- bmdDeckControlExportModeInsertAudio2 = ( 1 << 2 ) ,
- bmdDeckControlExportModeInsertAudio3 = ( 1 << 3 ) ,
- bmdDeckControlExportModeInsertAudio4 = ( 1 << 4 ) ,
- bmdDeckControlExportModeInsertAudio5 = ( 1 << 5 ) ,
- bmdDeckControlExportModeInsertAudio6 = ( 1 << 6 ) ,
- bmdDeckControlExportModeInsertAudio7 = ( 1 << 7 ) ,
- bmdDeckControlExportModeInsertAudio8 = ( 1 << 8 ) ,
- bmdDeckControlExportModeInsertAudio9 = ( 1 << 9 ) ,
- bmdDeckControlExportModeInsertAudio10 = ( 1 << 10 ) ,
- bmdDeckControlExportModeInsertAudio11 = ( 1 << 11 ) ,
- bmdDeckControlExportModeInsertAudio12 = ( 1 << 12 ) ,
- bmdDeckControlExportModeInsertTimeCode = ( 1 << 13 ) ,
- bmdDeckControlExportModeInsertAssemble = ( 1 << 14 ) ,
- bmdDeckControlExportModeInsertPreview = ( 1 << 15 ) ,
- bmdDeckControlUseManualExport = ( 1 << 16 )
- } ;
-typedef /* [v1_enum] */
-enum _BMDDeckControlError
- {
- bmdDeckControlNoError = 0x6e6f6572,
- bmdDeckControlModeError = 0x6d6f6572,
- bmdDeckControlMissedInPointError = 0x6d696572,
- bmdDeckControlDeckTimeoutError = 0x64746572,
- bmdDeckControlCommandFailedError = 0x63666572,
- bmdDeckControlDeviceAlreadyOpenedError = 0x64616c6f,
- bmdDeckControlFailedToOpenDeviceError = 0x66646572,
- bmdDeckControlInLocalModeError = 0x6c6d6572,
- bmdDeckControlEndOfTapeError = 0x65746572,
- bmdDeckControlUserAbortError = 0x75616572,
- bmdDeckControlNoTapeInDeckError = 0x6e746572,
- bmdDeckControlNoVideoFromCardError = 0x6e766663,
- bmdDeckControlNoCommunicationError = 0x6e636f6d,
- bmdDeckControlBufferTooSmallError = 0x6274736d,
- bmdDeckControlBadChecksumError = 0x63686b73,
- bmdDeckControlUnknownError = 0x756e6572
- } BMDDeckControlError;
-
-
-
-#if 0
-#endif
-typedef /* [v1_enum] */
-enum _BMDStreamingDeviceMode
- {
- bmdStreamingDeviceIdle = 0x69646c65,
- bmdStreamingDeviceEncoding = 0x656e636f,
- bmdStreamingDeviceStopping = 0x73746f70,
- bmdStreamingDeviceUnknown = 0x6d756e6b
- } BMDStreamingDeviceMode;
-
-typedef /* [v1_enum] */
-enum _BMDStreamingEncodingFrameRate
- {
- bmdStreamingEncodedFrameRate50i = 0x65353069,
- bmdStreamingEncodedFrameRate5994i = 0x65353969,
- bmdStreamingEncodedFrameRate60i = 0x65363069,
- bmdStreamingEncodedFrameRate2398p = 0x65323370,
- bmdStreamingEncodedFrameRate24p = 0x65323470,
- bmdStreamingEncodedFrameRate25p = 0x65323570,
- bmdStreamingEncodedFrameRate2997p = 0x65323970,
- bmdStreamingEncodedFrameRate30p = 0x65333070,
- bmdStreamingEncodedFrameRate50p = 0x65353070,
- bmdStreamingEncodedFrameRate5994p = 0x65353970,
- bmdStreamingEncodedFrameRate60p = 0x65363070
- } BMDStreamingEncodingFrameRate;
-
-typedef /* [v1_enum] */
-enum _BMDStreamingEncodingSupport
- {
- bmdStreamingEncodingModeNotSupported = 0,
- bmdStreamingEncodingModeSupported = ( bmdStreamingEncodingModeNotSupported + 1 ) ,
- bmdStreamingEncodingModeSupportedWithChanges = ( bmdStreamingEncodingModeSupported + 1 )
- } BMDStreamingEncodingSupport;
-
-typedef /* [v1_enum] */
-enum _BMDStreamingVideoCodec
- {
- bmdStreamingVideoCodecH264 = 0x48323634
- } BMDStreamingVideoCodec;
-
-typedef /* [v1_enum] */
-enum _BMDStreamingH264Profile
- {
- bmdStreamingH264ProfileHigh = 0x68696768,
- bmdStreamingH264ProfileMain = 0x6d61696e,
- bmdStreamingH264ProfileBaseline = 0x62617365
- } BMDStreamingH264Profile;
-
-typedef /* [v1_enum] */
-enum _BMDStreamingH264Level
- {
- bmdStreamingH264Level12 = 0x6c763132,
- bmdStreamingH264Level13 = 0x6c763133,
- bmdStreamingH264Level2 = 0x6c763220,
- bmdStreamingH264Level21 = 0x6c763231,
- bmdStreamingH264Level22 = 0x6c763232,
- bmdStreamingH264Level3 = 0x6c763320,
- bmdStreamingH264Level31 = 0x6c763331,
- bmdStreamingH264Level32 = 0x6c763332,
- bmdStreamingH264Level4 = 0x6c763420,
- bmdStreamingH264Level41 = 0x6c763431,
- bmdStreamingH264Level42 = 0x6c763432
- } BMDStreamingH264Level;
-
-typedef /* [v1_enum] */
-enum _BMDStreamingH264EntropyCoding
- {
- bmdStreamingH264EntropyCodingCAVLC = 0x45564c43,
- bmdStreamingH264EntropyCodingCABAC = 0x45424143
- } BMDStreamingH264EntropyCoding;
-
-typedef /* [v1_enum] */
-enum _BMDStreamingAudioCodec
- {
- bmdStreamingAudioCodecAAC = 0x41414320
- } BMDStreamingAudioCodec;
-
-typedef /* [v1_enum] */
-enum _BMDStreamingEncodingModePropertyID
- {
- bmdStreamingEncodingPropertyVideoFrameRate = 0x76667274,
- bmdStreamingEncodingPropertyVideoBitRateKbps = 0x76627274,
- bmdStreamingEncodingPropertyH264Profile = 0x68707266,
- bmdStreamingEncodingPropertyH264Level = 0x686c766c,
- bmdStreamingEncodingPropertyH264EntropyCoding = 0x68656e74,
- bmdStreamingEncodingPropertyH264HasBFrames = 0x68426672,
- bmdStreamingEncodingPropertyAudioCodec = 0x61636463,
- bmdStreamingEncodingPropertyAudioSampleRate = 0x61737274,
- bmdStreamingEncodingPropertyAudioChannelCount = 0x61636863,
- bmdStreamingEncodingPropertyAudioBitRateKbps = 0x61627274
- } BMDStreamingEncodingModePropertyID;
-
-
-
-
-
-
-
-
-
-
-
-
-typedef unsigned int BMDFrameFlags;
-typedef unsigned int BMDVideoInputFlags;
-typedef unsigned int BMDVideoInputFormatChangedEvents;
-typedef unsigned int BMDDetectedVideoInputFormatFlags;
-typedef unsigned int BMDDeckLinkCapturePassthroughMode;
-typedef unsigned int BMDAnalogVideoFlags;
-typedef unsigned int BMDDeviceBusyState;
-#if 0
-typedef enum _BMDFrameFlags BMDFrameFlags;
-
-typedef enum _BMDVideoInputFlags BMDVideoInputFlags;
-
-typedef enum _BMDVideoInputFormatChangedEvents BMDVideoInputFormatChangedEvents;
-
-typedef enum _BMDDetectedVideoInputFormatFlags BMDDetectedVideoInputFormatFlags;
-
-typedef enum _BMDDeckLinkCapturePassthroughMode BMDDeckLinkCapturePassthroughMode;
-
-typedef enum _BMDAnalogVideoFlags BMDAnalogVideoFlags;
-
-typedef enum _BMDDeviceBusyState BMDDeviceBusyState;
-
-#endif
-typedef /* [v1_enum] */
-enum _BMDVideoOutputFlags
- {
- bmdVideoOutputFlagDefault = 0,
- bmdVideoOutputVANC = ( 1 << 0 ) ,
- bmdVideoOutputVITC = ( 1 << 1 ) ,
- bmdVideoOutputRP188 = ( 1 << 2 ) ,
- bmdVideoOutputDualStream3D = ( 1 << 4 )
- } BMDVideoOutputFlags;
-
-/* [v1_enum] */
-enum _BMDFrameFlags
- {
- bmdFrameFlagDefault = 0,
- bmdFrameFlagFlipVertical = ( 1 << 0 ) ,
- bmdFrameHasNoInputSource = ( 1 << 31 )
- } ;
-/* [v1_enum] */
-enum _BMDVideoInputFlags
- {
- bmdVideoInputFlagDefault = 0,
- bmdVideoInputEnableFormatDetection = ( 1 << 0 ) ,
- bmdVideoInputDualStream3D = ( 1 << 1 )
- } ;
-/* [v1_enum] */
-enum _BMDVideoInputFormatChangedEvents
- {
- bmdVideoInputDisplayModeChanged = ( 1 << 0 ) ,
- bmdVideoInputFieldDominanceChanged = ( 1 << 1 ) ,
- bmdVideoInputColorspaceChanged = ( 1 << 2 )
- } ;
-/* [v1_enum] */
-enum _BMDDetectedVideoInputFormatFlags
- {
- bmdDetectedVideoInputYCbCr422 = ( 1 << 0 ) ,
- bmdDetectedVideoInputRGB444 = ( 1 << 1 ) ,
- bmdDetectedVideoInputDualStream3D = ( 1 << 2 )
- } ;
-/* [v1_enum] */
-enum _BMDDeckLinkCapturePassthroughMode
- {
- bmdDeckLinkCapturePassthroughModeDirect = 0x70646972,
- bmdDeckLinkCapturePassthroughModeCleanSwitch = 0x70636c6e
- } ;
-typedef /* [v1_enum] */
-enum _BMDOutputFrameCompletionResult
- {
- bmdOutputFrameCompleted = 0,
- bmdOutputFrameDisplayedLate = ( bmdOutputFrameCompleted + 1 ) ,
- bmdOutputFrameDropped = ( bmdOutputFrameDisplayedLate + 1 ) ,
- bmdOutputFrameFlushed = ( bmdOutputFrameDropped + 1 )
- } BMDOutputFrameCompletionResult;
-
-typedef /* [v1_enum] */
-enum _BMDReferenceStatus
- {
- bmdReferenceNotSupportedByHardware = ( 1 << 0 ) ,
- bmdReferenceLocked = ( 1 << 1 )
- } BMDReferenceStatus;
-
-typedef /* [v1_enum] */
-enum _BMDAudioSampleRate
- {
- bmdAudioSampleRate48kHz = 48000
- } BMDAudioSampleRate;
-
-typedef /* [v1_enum] */
-enum _BMDAudioSampleType
- {
- bmdAudioSampleType16bitInteger = 16,
- bmdAudioSampleType32bitInteger = 32
- } BMDAudioSampleType;
-
-typedef /* [v1_enum] */
-enum _BMDAudioOutputStreamType
- {
- bmdAudioOutputStreamContinuous = 0,
- bmdAudioOutputStreamContinuousDontResample = ( bmdAudioOutputStreamContinuous + 1 ) ,
- bmdAudioOutputStreamTimestamped = ( bmdAudioOutputStreamContinuousDontResample + 1 )
- } BMDAudioOutputStreamType;
-
-typedef /* [v1_enum] */
-enum _BMDDisplayModeSupport
- {
- bmdDisplayModeNotSupported = 0,
- bmdDisplayModeSupported = ( bmdDisplayModeNotSupported + 1 ) ,
- bmdDisplayModeSupportedWithConversion = ( bmdDisplayModeSupported + 1 )
- } BMDDisplayModeSupport;
-
-typedef /* [v1_enum] */
-enum _BMDTimecodeFormat
- {
- bmdTimecodeRP188VITC1 = 0x72707631,
- bmdTimecodeRP188VITC2 = 0x72703132,
- bmdTimecodeRP188LTC = 0x72706c74,
- bmdTimecodeRP188Any = 0x72703138,
- bmdTimecodeVITC = 0x76697463,
- bmdTimecodeVITCField2 = 0x76697432,
- bmdTimecodeSerial = 0x73657269
- } BMDTimecodeFormat;
-
-/* [v1_enum] */
-enum _BMDAnalogVideoFlags
- {
- bmdAnalogVideoFlagCompositeSetup75 = ( 1 << 0 ) ,
- bmdAnalogVideoFlagComponentBetacamLevels = ( 1 << 1 )
- } ;
-typedef /* [v1_enum] */
-enum _BMDAudioOutputAnalogAESSwitch
- {
- bmdAudioOutputSwitchAESEBU = 0x61657320,
- bmdAudioOutputSwitchAnalog = 0x616e6c67
- } BMDAudioOutputAnalogAESSwitch;
-
-typedef /* [v1_enum] */
-enum _BMDVideoOutputConversionMode
- {
- bmdNoVideoOutputConversion = 0x6e6f6e65,
- bmdVideoOutputLetterboxDownconversion = 0x6c746278,
- bmdVideoOutputAnamorphicDownconversion = 0x616d7068,
- bmdVideoOutputHD720toHD1080Conversion = 0x37323063,
- bmdVideoOutputHardwareLetterboxDownconversion = 0x48576c62,
- bmdVideoOutputHardwareAnamorphicDownconversion = 0x4857616d,
- bmdVideoOutputHardwareCenterCutDownconversion = 0x48576363,
- bmdVideoOutputHardware720p1080pCrossconversion = 0x78636170,
- bmdVideoOutputHardwareAnamorphic720pUpconversion = 0x75613770,
- bmdVideoOutputHardwareAnamorphic1080iUpconversion = 0x75613169,
- bmdVideoOutputHardwareAnamorphic149To720pUpconversion = 0x75343770,
- bmdVideoOutputHardwareAnamorphic149To1080iUpconversion = 0x75343169,
- bmdVideoOutputHardwarePillarbox720pUpconversion = 0x75703770,
- bmdVideoOutputHardwarePillarbox1080iUpconversion = 0x75703169
- } BMDVideoOutputConversionMode;
-
-typedef /* [v1_enum] */
-enum _BMDVideoInputConversionMode
- {
- bmdNoVideoInputConversion = 0x6e6f6e65,
- bmdVideoInputLetterboxDownconversionFromHD1080 = 0x31306c62,
- bmdVideoInputAnamorphicDownconversionFromHD1080 = 0x3130616d,
- bmdVideoInputLetterboxDownconversionFromHD720 = 0x37326c62,
- bmdVideoInputAnamorphicDownconversionFromHD720 = 0x3732616d,
- bmdVideoInputLetterboxUpconversion = 0x6c627570,
- bmdVideoInputAnamorphicUpconversion = 0x616d7570
- } BMDVideoInputConversionMode;
-
-typedef /* [v1_enum] */
-enum _BMDVideo3DPackingFormat
- {
- bmdVideo3DPackingSidebySideHalf = 0x73627368,
- bmdVideo3DPackingLinebyLine = 0x6c62796c,
- bmdVideo3DPackingTopAndBottom = 0x7461626f,
- bmdVideo3DPackingFramePacking = 0x6672706b,
- bmdVideo3DPackingLeftOnly = 0x6c656674,
- bmdVideo3DPackingRightOnly = 0x72696768
- } BMDVideo3DPackingFormat;
-
-typedef /* [v1_enum] */
-enum _BMDIdleVideoOutputOperation
- {
- bmdIdleVideoOutputBlack = 0x626c6163,
- bmdIdleVideoOutputLastFrame = 0x6c616661,
- bmdIdleVideoOutputDesktop = 0x6465736b
- } BMDIdleVideoOutputOperation;
-
-typedef /* [v1_enum] */
-enum _BMDDeckLinkAttributeID
- {
- BMDDeckLinkSupportsInternalKeying = 0x6b657969,
- BMDDeckLinkSupportsExternalKeying = 0x6b657965,
- BMDDeckLinkSupportsHDKeying = 0x6b657968,
- BMDDeckLinkSupportsInputFormatDetection = 0x696e6664,
- BMDDeckLinkHasReferenceInput = 0x6872696e,
- BMDDeckLinkHasSerialPort = 0x68737074,
- BMDDeckLinkHasAnalogVideoOutputGain = 0x61766f67,
- BMDDeckLinkCanOnlyAdjustOverallVideoOutputGain = 0x6f766f67,
- BMDDeckLinkHasVideoInputAntiAliasingFilter = 0x6161666c,
- BMDDeckLinkHasBypass = 0x62797073,
- BMDDeckLinkSupportsDesktopDisplay = 0x65787464,
- BMDDeckLinkSupportsClockTimingAdjustment = 0x63746164,
- BMDDeckLinkSupportsFullDuplex = 0x66647570,
- BMDDeckLinkSupportsFullFrameReferenceInputTimingOffset = 0x6672696e,
- BMDDeckLinkSupportsSMPTELevelAOutput = 0x6c766c61,
- BMDDeckLinkSupportsDualLinkSDI = 0x73646c73,
- BMDDeckLinkSupportsIdleOutput = 0x69646f75,
- BMDDeckLinkMaximumAudioChannels = 0x6d616368,
- BMDDeckLinkMaximumAnalogAudioChannels = 0x61616368,
- BMDDeckLinkNumberOfSubDevices = 0x6e736264,
- BMDDeckLinkSubDeviceIndex = 0x73756269,
- BMDDeckLinkPersistentID = 0x70656964,
- BMDDeckLinkTopologicalID = 0x746f6964,
- BMDDeckLinkVideoOutputConnections = 0x766f636e,
- BMDDeckLinkVideoInputConnections = 0x7669636e,
- BMDDeckLinkAudioOutputConnections = 0x616f636e,
- BMDDeckLinkAudioInputConnections = 0x6169636e,
- BMDDeckLinkDeviceBusyState = 0x64627374,
- BMDDeckLinkVideoIOSupport = 0x76696f73,
- BMDDeckLinkVideoInputGainMinimum = 0x7669676d,
- BMDDeckLinkVideoInputGainMaximum = 0x76696778,
- BMDDeckLinkVideoOutputGainMinimum = 0x766f676d,
- BMDDeckLinkVideoOutputGainMaximum = 0x766f6778,
- BMDDeckLinkSerialPortDeviceName = 0x736c706e
- } BMDDeckLinkAttributeID;
-
-typedef /* [v1_enum] */
-enum _BMDDeckLinkAPIInformationID
- {
- BMDDeckLinkAPIVersion = 0x76657273
- } BMDDeckLinkAPIInformationID;
-
-/* [v1_enum] */
-enum _BMDDeviceBusyState
- {
- bmdDeviceCaptureBusy = ( 1 << 0 ) ,
- bmdDevicePlaybackBusy = ( 1 << 1 ) ,
- bmdDeviceSerialPortBusy = ( 1 << 2 )
- } ;
-typedef /* [v1_enum] */
-enum _BMDVideoIOSupport
- {
- bmdDeviceSupportsCapture = ( 1 << 0 ) ,
- bmdDeviceSupportsPlayback = ( 1 << 1 )
- } BMDVideoIOSupport;
-
-typedef /* [v1_enum] */
-enum _BMD3DPreviewFormat
- {
- bmd3DPreviewFormatDefault = 0x64656661,
- bmd3DPreviewFormatLeftOnly = 0x6c656674,
- bmd3DPreviewFormatRightOnly = 0x72696768,
- bmd3DPreviewFormatSideBySide = 0x73696465,
- bmd3DPreviewFormatTopBottom = 0x746f7062
- } BMD3DPreviewFormat;
-
-typedef /* [v1_enum] */
-enum _BMDNotifications
- {
- bmdPreferencesChanged = 0x70726566
- } BMDNotifications;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef /* [v1_enum] */
-enum _BMDDeckLinkConfigurationID_v10_2
- {
- bmdDeckLinkConfig3GBpsVideoOutput_v10_2 = 0x33676273
- } BMDDeckLinkConfigurationID_v10_2;
-
-typedef /* [v1_enum] */
-enum _BMDAudioConnection_v10_2
- {
- bmdAudioConnectionEmbedded_v10_2 = 0x656d6264,
- bmdAudioConnectionAESEBU_v10_2 = 0x61657320,
- bmdAudioConnectionAnalog_v10_2 = 0x616e6c67,
- bmdAudioConnectionAnalogXLR_v10_2 = 0x61786c72,
- bmdAudioConnectionAnalogRCA_v10_2 = 0x61726361
- } BMDAudioConnection_v10_2;
-
-
-typedef /* [v1_enum] */
-enum _BMDDeckControlVTRControlState_v8_1
- {
- bmdDeckControlNotInVTRControlMode_v8_1 = 0x6e76636d,
- bmdDeckControlVTRControlPlaying_v8_1 = 0x76747270,
- bmdDeckControlVTRControlRecording_v8_1 = 0x76747272,
- bmdDeckControlVTRControlStill_v8_1 = 0x76747261,
- bmdDeckControlVTRControlSeeking_v8_1 = 0x76747273,
- bmdDeckControlVTRControlStopped_v8_1 = 0x7674726f
- } BMDDeckControlVTRControlState_v8_1;
-
-
-
-typedef /* [v1_enum] */
-enum _BMDVideoConnection_v7_6
- {
- bmdVideoConnectionSDI_v7_6 = 0x73646920,
- bmdVideoConnectionHDMI_v7_6 = 0x68646d69,
- bmdVideoConnectionOpticalSDI_v7_6 = 0x6f707469,
- bmdVideoConnectionComponent_v7_6 = 0x63706e74,
- bmdVideoConnectionComposite_v7_6 = 0x636d7374,
- bmdVideoConnectionSVideo_v7_6 = 0x73766964
- } BMDVideoConnection_v7_6;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EXTERN_C const IID LIBID_DeckLinkAPI;
-
-#ifndef __IDeckLinkTimecode_INTERFACE_DEFINED__
-#define __IDeckLinkTimecode_INTERFACE_DEFINED__
-
-/* interface IDeckLinkTimecode */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkTimecode;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("BC6CFBD3-8317-4325-AC1C-1216391E9340")
- IDeckLinkTimecode : public IUnknown
- {
- public:
- virtual BMDTimecodeBCD STDMETHODCALLTYPE GetBCD( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetComponents(
- /* [out] */ unsigned char *hours,
- /* [out] */ unsigned char *minutes,
- /* [out] */ unsigned char *seconds,
- /* [out] */ unsigned char *frames) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetString(
- /* [out] */ BSTR *timecode) = 0;
-
- virtual BMDTimecodeFlags STDMETHODCALLTYPE GetFlags( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecodeUserBits(
- /* [out] */ BMDTimecodeUserBits *userBits) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkTimecodeVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkTimecode * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkTimecode * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkTimecode * This);
-
- BMDTimecodeBCD ( STDMETHODCALLTYPE *GetBCD )(
- IDeckLinkTimecode * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetComponents )(
- IDeckLinkTimecode * This,
- /* [out] */ unsigned char *hours,
- /* [out] */ unsigned char *minutes,
- /* [out] */ unsigned char *seconds,
- /* [out] */ unsigned char *frames);
-
- HRESULT ( STDMETHODCALLTYPE *GetString )(
- IDeckLinkTimecode * This,
- /* [out] */ BSTR *timecode);
-
- BMDTimecodeFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkTimecode * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecodeUserBits )(
- IDeckLinkTimecode * This,
- /* [out] */ BMDTimecodeUserBits *userBits);
-
- END_INTERFACE
- } IDeckLinkTimecodeVtbl;
-
- interface IDeckLinkTimecode
- {
- CONST_VTBL struct IDeckLinkTimecodeVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkTimecode_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkTimecode_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkTimecode_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkTimecode_GetBCD(This) \
- ( (This)->lpVtbl -> GetBCD(This) )
-
-#define IDeckLinkTimecode_GetComponents(This,hours,minutes,seconds,frames) \
- ( (This)->lpVtbl -> GetComponents(This,hours,minutes,seconds,frames) )
-
-#define IDeckLinkTimecode_GetString(This,timecode) \
- ( (This)->lpVtbl -> GetString(This,timecode) )
-
-#define IDeckLinkTimecode_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkTimecode_GetTimecodeUserBits(This,userBits) \
- ( (This)->lpVtbl -> GetTimecodeUserBits(This,userBits) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkTimecode_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayModeIterator_INTERFACE_DEFINED__
-#define __IDeckLinkDisplayModeIterator_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDisplayModeIterator */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDisplayModeIterator;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("9C88499F-F601-4021-B80B-032E4EB41C35")
- IDeckLinkDisplayModeIterator : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Next(
- /* [out] */ IDeckLinkDisplayMode **deckLinkDisplayMode) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDisplayModeIteratorVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDisplayModeIterator * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDisplayModeIterator * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDisplayModeIterator * This);
-
- HRESULT ( STDMETHODCALLTYPE *Next )(
- IDeckLinkDisplayModeIterator * This,
- /* [out] */ IDeckLinkDisplayMode **deckLinkDisplayMode);
-
- END_INTERFACE
- } IDeckLinkDisplayModeIteratorVtbl;
-
- interface IDeckLinkDisplayModeIterator
- {
- CONST_VTBL struct IDeckLinkDisplayModeIteratorVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDisplayModeIterator_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDisplayModeIterator_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDisplayModeIterator_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDisplayModeIterator_Next(This,deckLinkDisplayMode) \
- ( (This)->lpVtbl -> Next(This,deckLinkDisplayMode) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDisplayModeIterator_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayMode_INTERFACE_DEFINED__
-#define __IDeckLinkDisplayMode_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDisplayMode */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDisplayMode;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("3EB2C1AB-0A3D-4523-A3AD-F40D7FB14E78")
- IDeckLinkDisplayMode : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetName(
- /* [out] */ BSTR *name) = 0;
-
- virtual BMDDisplayMode STDMETHODCALLTYPE GetDisplayMode( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetWidth( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetHeight( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFrameRate(
- /* [out] */ BMDTimeValue *frameDuration,
- /* [out] */ BMDTimeScale *timeScale) = 0;
-
- virtual BMDFieldDominance STDMETHODCALLTYPE GetFieldDominance( void) = 0;
-
- virtual BMDDisplayModeFlags STDMETHODCALLTYPE GetFlags( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDisplayModeVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDisplayMode * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDisplayMode * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDisplayMode * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetName )(
- IDeckLinkDisplayMode * This,
- /* [out] */ BSTR *name);
-
- BMDDisplayMode ( STDMETHODCALLTYPE *GetDisplayMode )(
- IDeckLinkDisplayMode * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkDisplayMode * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkDisplayMode * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetFrameRate )(
- IDeckLinkDisplayMode * This,
- /* [out] */ BMDTimeValue *frameDuration,
- /* [out] */ BMDTimeScale *timeScale);
-
- BMDFieldDominance ( STDMETHODCALLTYPE *GetFieldDominance )(
- IDeckLinkDisplayMode * This);
-
- BMDDisplayModeFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkDisplayMode * This);
-
- END_INTERFACE
- } IDeckLinkDisplayModeVtbl;
-
- interface IDeckLinkDisplayMode
- {
- CONST_VTBL struct IDeckLinkDisplayModeVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDisplayMode_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDisplayMode_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDisplayMode_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDisplayMode_GetName(This,name) \
- ( (This)->lpVtbl -> GetName(This,name) )
-
-#define IDeckLinkDisplayMode_GetDisplayMode(This) \
- ( (This)->lpVtbl -> GetDisplayMode(This) )
-
-#define IDeckLinkDisplayMode_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkDisplayMode_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkDisplayMode_GetFrameRate(This,frameDuration,timeScale) \
- ( (This)->lpVtbl -> GetFrameRate(This,frameDuration,timeScale) )
-
-#define IDeckLinkDisplayMode_GetFieldDominance(This) \
- ( (This)->lpVtbl -> GetFieldDominance(This) )
-
-#define IDeckLinkDisplayMode_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDisplayMode_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLink_INTERFACE_DEFINED__
-#define __IDeckLink_INTERFACE_DEFINED__
-
-/* interface IDeckLink */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLink;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("C418FBDD-0587-48ED-8FE5-640F0A14AF91")
- IDeckLink : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetModelName(
- /* [out] */ BSTR *modelName) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayName(
- /* [out] */ BSTR *displayName) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLink * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLink * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLink * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetModelName )(
- IDeckLink * This,
- /* [out] */ BSTR *modelName);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayName )(
- IDeckLink * This,
- /* [out] */ BSTR *displayName);
-
- END_INTERFACE
- } IDeckLinkVtbl;
-
- interface IDeckLink
- {
- CONST_VTBL struct IDeckLinkVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLink_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLink_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLink_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLink_GetModelName(This,modelName) \
- ( (This)->lpVtbl -> GetModelName(This,modelName) )
-
-#define IDeckLink_GetDisplayName(This,displayName) \
- ( (This)->lpVtbl -> GetDisplayName(This,displayName) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLink_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkConfiguration_INTERFACE_DEFINED__
-#define __IDeckLinkConfiguration_INTERFACE_DEFINED__
-
-/* interface IDeckLinkConfiguration */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkConfiguration;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("1E69FCF6-4203-4936-8076-2A9F4CFD50CB")
- IDeckLinkConfiguration : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE SetFlag(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ BOOL value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFlag(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ BOOL *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetInt(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ LONGLONG value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetInt(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ LONGLONG *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetFloat(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ double value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFloat(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ double *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetString(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ BSTR value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetString(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ BSTR *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE WriteConfigurationToPreferences( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkConfigurationVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkConfiguration * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkConfiguration * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkConfiguration * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetFlag )(
- IDeckLinkConfiguration * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ BOOL value);
-
- HRESULT ( STDMETHODCALLTYPE *GetFlag )(
- IDeckLinkConfiguration * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ BOOL *value);
-
- HRESULT ( STDMETHODCALLTYPE *SetInt )(
- IDeckLinkConfiguration * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ LONGLONG value);
-
- HRESULT ( STDMETHODCALLTYPE *GetInt )(
- IDeckLinkConfiguration * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ LONGLONG *value);
-
- HRESULT ( STDMETHODCALLTYPE *SetFloat )(
- IDeckLinkConfiguration * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ double value);
-
- HRESULT ( STDMETHODCALLTYPE *GetFloat )(
- IDeckLinkConfiguration * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ double *value);
-
- HRESULT ( STDMETHODCALLTYPE *SetString )(
- IDeckLinkConfiguration * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ BSTR value);
-
- HRESULT ( STDMETHODCALLTYPE *GetString )(
- IDeckLinkConfiguration * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ BSTR *value);
-
- HRESULT ( STDMETHODCALLTYPE *WriteConfigurationToPreferences )(
- IDeckLinkConfiguration * This);
-
- END_INTERFACE
- } IDeckLinkConfigurationVtbl;
-
- interface IDeckLinkConfiguration
- {
- CONST_VTBL struct IDeckLinkConfigurationVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkConfiguration_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkConfiguration_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkConfiguration_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkConfiguration_SetFlag(This,cfgID,value) \
- ( (This)->lpVtbl -> SetFlag(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_GetFlag(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFlag(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_SetInt(This,cfgID,value) \
- ( (This)->lpVtbl -> SetInt(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_GetInt(This,cfgID,value) \
- ( (This)->lpVtbl -> GetInt(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_SetFloat(This,cfgID,value) \
- ( (This)->lpVtbl -> SetFloat(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_GetFloat(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFloat(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_SetString(This,cfgID,value) \
- ( (This)->lpVtbl -> SetString(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_GetString(This,cfgID,value) \
- ( (This)->lpVtbl -> GetString(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_WriteConfigurationToPreferences(This) \
- ( (This)->lpVtbl -> WriteConfigurationToPreferences(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkConfiguration_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeckControlStatusCallback_INTERFACE_DEFINED__
-#define __IDeckLinkDeckControlStatusCallback_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDeckControlStatusCallback */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDeckControlStatusCallback;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("53436FFB-B434-4906-BADC-AE3060FFE8EF")
- IDeckLinkDeckControlStatusCallback : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE TimecodeUpdate(
- /* [in] */ BMDTimecodeBCD currentTimecode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE VTRControlStateChanged(
- /* [in] */ BMDDeckControlVTRControlState newState,
- /* [in] */ BMDDeckControlError error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DeckControlEventReceived(
- /* [in] */ BMDDeckControlEvent event,
- /* [in] */ BMDDeckControlError error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DeckControlStatusChanged(
- /* [in] */ BMDDeckControlStatusFlags flags,
- /* [in] */ unsigned int mask) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDeckControlStatusCallbackVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDeckControlStatusCallback * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDeckControlStatusCallback * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDeckControlStatusCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *TimecodeUpdate )(
- IDeckLinkDeckControlStatusCallback * This,
- /* [in] */ BMDTimecodeBCD currentTimecode);
-
- HRESULT ( STDMETHODCALLTYPE *VTRControlStateChanged )(
- IDeckLinkDeckControlStatusCallback * This,
- /* [in] */ BMDDeckControlVTRControlState newState,
- /* [in] */ BMDDeckControlError error);
-
- HRESULT ( STDMETHODCALLTYPE *DeckControlEventReceived )(
- IDeckLinkDeckControlStatusCallback * This,
- /* [in] */ BMDDeckControlEvent event,
- /* [in] */ BMDDeckControlError error);
-
- HRESULT ( STDMETHODCALLTYPE *DeckControlStatusChanged )(
- IDeckLinkDeckControlStatusCallback * This,
- /* [in] */ BMDDeckControlStatusFlags flags,
- /* [in] */ unsigned int mask);
-
- END_INTERFACE
- } IDeckLinkDeckControlStatusCallbackVtbl;
-
- interface IDeckLinkDeckControlStatusCallback
- {
- CONST_VTBL struct IDeckLinkDeckControlStatusCallbackVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDeckControlStatusCallback_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDeckControlStatusCallback_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDeckControlStatusCallback_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDeckControlStatusCallback_TimecodeUpdate(This,currentTimecode) \
- ( (This)->lpVtbl -> TimecodeUpdate(This,currentTimecode) )
-
-#define IDeckLinkDeckControlStatusCallback_VTRControlStateChanged(This,newState,error) \
- ( (This)->lpVtbl -> VTRControlStateChanged(This,newState,error) )
-
-#define IDeckLinkDeckControlStatusCallback_DeckControlEventReceived(This,event,error) \
- ( (This)->lpVtbl -> DeckControlEventReceived(This,event,error) )
-
-#define IDeckLinkDeckControlStatusCallback_DeckControlStatusChanged(This,flags,mask) \
- ( (This)->lpVtbl -> DeckControlStatusChanged(This,flags,mask) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDeckControlStatusCallback_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeckControl_INTERFACE_DEFINED__
-#define __IDeckLinkDeckControl_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDeckControl */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDeckControl;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("8E1C3ACE-19C7-4E00-8B92-D80431D958BE")
- IDeckLinkDeckControl : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Open(
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ BMDTimeValue timeValue,
- /* [in] */ BOOL timecodeIsDropFrame,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Close(
- /* [in] */ BOOL standbyOn) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetCurrentState(
- /* [out] */ BMDDeckControlMode *mode,
- /* [out] */ BMDDeckControlVTRControlState *vtrControlState,
- /* [out] */ BMDDeckControlStatusFlags *flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetStandby(
- /* [in] */ BOOL standbyOn) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SendCommand(
- /* [in] */ unsigned char *inBuffer,
- /* [in] */ unsigned int inBufferSize,
- /* [out] */ unsigned char *outBuffer,
- /* [out] */ unsigned int *outDataSize,
- /* [in] */ unsigned int outBufferSize,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Play(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Stop(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE TogglePlayStop(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Eject(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GoToTimecode(
- /* [in] */ BMDTimecodeBCD timecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FastForward(
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Rewind(
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StepForward(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StepBack(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Jog(
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Shuttle(
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecodeString(
- /* [out] */ BSTR *currentTimeCode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecode(
- /* [out] */ IDeckLinkTimecode **currentTimecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecodeBCD(
- /* [out] */ BMDTimecodeBCD *currentTimecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetPreroll(
- /* [in] */ unsigned int prerollSeconds) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetPreroll(
- /* [out] */ unsigned int *prerollSeconds) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetExportOffset(
- /* [in] */ int exportOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetExportOffset(
- /* [out] */ int *exportOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetManualExportOffset(
- /* [out] */ int *deckManualExportOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCaptureOffset(
- /* [in] */ int captureOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetCaptureOffset(
- /* [out] */ int *captureOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartExport(
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [in] */ BMDDeckControlExportModeOpsFlags exportModeOps,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartCapture(
- /* [in] */ BOOL useVITC,
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDeviceID(
- /* [out] */ unsigned short *deviceId,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Abort( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CrashRecordStart(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CrashRecordStop(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- /* [in] */ IDeckLinkDeckControlStatusCallback *callback) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDeckControlVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDeckControl * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDeckControl * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDeckControl * This);
-
- HRESULT ( STDMETHODCALLTYPE *Open )(
- IDeckLinkDeckControl * This,
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ BMDTimeValue timeValue,
- /* [in] */ BOOL timecodeIsDropFrame,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Close )(
- IDeckLinkDeckControl * This,
- /* [in] */ BOOL standbyOn);
-
- HRESULT ( STDMETHODCALLTYPE *GetCurrentState )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDDeckControlMode *mode,
- /* [out] */ BMDDeckControlVTRControlState *vtrControlState,
- /* [out] */ BMDDeckControlStatusFlags *flags);
-
- HRESULT ( STDMETHODCALLTYPE *SetStandby )(
- IDeckLinkDeckControl * This,
- /* [in] */ BOOL standbyOn);
-
- HRESULT ( STDMETHODCALLTYPE *SendCommand )(
- IDeckLinkDeckControl * This,
- /* [in] */ unsigned char *inBuffer,
- /* [in] */ unsigned int inBufferSize,
- /* [out] */ unsigned char *outBuffer,
- /* [out] */ unsigned int *outDataSize,
- /* [in] */ unsigned int outBufferSize,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Play )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Stop )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *TogglePlayStop )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Eject )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GoToTimecode )(
- IDeckLinkDeckControl * This,
- /* [in] */ BMDTimecodeBCD timecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *FastForward )(
- IDeckLinkDeckControl * This,
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Rewind )(
- IDeckLinkDeckControl * This,
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *StepForward )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *StepBack )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Jog )(
- IDeckLinkDeckControl * This,
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Shuttle )(
- IDeckLinkDeckControl * This,
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecodeString )(
- IDeckLinkDeckControl * This,
- /* [out] */ BSTR *currentTimeCode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkDeckControl * This,
- /* [out] */ IDeckLinkTimecode **currentTimecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecodeBCD )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDTimecodeBCD *currentTimecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *SetPreroll )(
- IDeckLinkDeckControl * This,
- /* [in] */ unsigned int prerollSeconds);
-
- HRESULT ( STDMETHODCALLTYPE *GetPreroll )(
- IDeckLinkDeckControl * This,
- /* [out] */ unsigned int *prerollSeconds);
-
- HRESULT ( STDMETHODCALLTYPE *SetExportOffset )(
- IDeckLinkDeckControl * This,
- /* [in] */ int exportOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *GetExportOffset )(
- IDeckLinkDeckControl * This,
- /* [out] */ int *exportOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *GetManualExportOffset )(
- IDeckLinkDeckControl * This,
- /* [out] */ int *deckManualExportOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *SetCaptureOffset )(
- IDeckLinkDeckControl * This,
- /* [in] */ int captureOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *GetCaptureOffset )(
- IDeckLinkDeckControl * This,
- /* [out] */ int *captureOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *StartExport )(
- IDeckLinkDeckControl * This,
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [in] */ BMDDeckControlExportModeOpsFlags exportModeOps,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *StartCapture )(
- IDeckLinkDeckControl * This,
- /* [in] */ BOOL useVITC,
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetDeviceID )(
- IDeckLinkDeckControl * This,
- /* [out] */ unsigned short *deviceId,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Abort )(
- IDeckLinkDeckControl * This);
-
- HRESULT ( STDMETHODCALLTYPE *CrashRecordStart )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *CrashRecordStop )(
- IDeckLinkDeckControl * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *SetCallback )(
- IDeckLinkDeckControl * This,
- /* [in] */ IDeckLinkDeckControlStatusCallback *callback);
-
- END_INTERFACE
- } IDeckLinkDeckControlVtbl;
-
- interface IDeckLinkDeckControl
- {
- CONST_VTBL struct IDeckLinkDeckControlVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDeckControl_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDeckControl_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDeckControl_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDeckControl_Open(This,timeScale,timeValue,timecodeIsDropFrame,error) \
- ( (This)->lpVtbl -> Open(This,timeScale,timeValue,timecodeIsDropFrame,error) )
-
-#define IDeckLinkDeckControl_Close(This,standbyOn) \
- ( (This)->lpVtbl -> Close(This,standbyOn) )
-
-#define IDeckLinkDeckControl_GetCurrentState(This,mode,vtrControlState,flags) \
- ( (This)->lpVtbl -> GetCurrentState(This,mode,vtrControlState,flags) )
-
-#define IDeckLinkDeckControl_SetStandby(This,standbyOn) \
- ( (This)->lpVtbl -> SetStandby(This,standbyOn) )
-
-#define IDeckLinkDeckControl_SendCommand(This,inBuffer,inBufferSize,outBuffer,outDataSize,outBufferSize,error) \
- ( (This)->lpVtbl -> SendCommand(This,inBuffer,inBufferSize,outBuffer,outDataSize,outBufferSize,error) )
-
-#define IDeckLinkDeckControl_Play(This,error) \
- ( (This)->lpVtbl -> Play(This,error) )
-
-#define IDeckLinkDeckControl_Stop(This,error) \
- ( (This)->lpVtbl -> Stop(This,error) )
-
-#define IDeckLinkDeckControl_TogglePlayStop(This,error) \
- ( (This)->lpVtbl -> TogglePlayStop(This,error) )
-
-#define IDeckLinkDeckControl_Eject(This,error) \
- ( (This)->lpVtbl -> Eject(This,error) )
-
-#define IDeckLinkDeckControl_GoToTimecode(This,timecode,error) \
- ( (This)->lpVtbl -> GoToTimecode(This,timecode,error) )
-
-#define IDeckLinkDeckControl_FastForward(This,viewTape,error) \
- ( (This)->lpVtbl -> FastForward(This,viewTape,error) )
-
-#define IDeckLinkDeckControl_Rewind(This,viewTape,error) \
- ( (This)->lpVtbl -> Rewind(This,viewTape,error) )
-
-#define IDeckLinkDeckControl_StepForward(This,error) \
- ( (This)->lpVtbl -> StepForward(This,error) )
-
-#define IDeckLinkDeckControl_StepBack(This,error) \
- ( (This)->lpVtbl -> StepBack(This,error) )
-
-#define IDeckLinkDeckControl_Jog(This,rate,error) \
- ( (This)->lpVtbl -> Jog(This,rate,error) )
-
-#define IDeckLinkDeckControl_Shuttle(This,rate,error) \
- ( (This)->lpVtbl -> Shuttle(This,rate,error) )
-
-#define IDeckLinkDeckControl_GetTimecodeString(This,currentTimeCode,error) \
- ( (This)->lpVtbl -> GetTimecodeString(This,currentTimeCode,error) )
-
-#define IDeckLinkDeckControl_GetTimecode(This,currentTimecode,error) \
- ( (This)->lpVtbl -> GetTimecode(This,currentTimecode,error) )
-
-#define IDeckLinkDeckControl_GetTimecodeBCD(This,currentTimecode,error) \
- ( (This)->lpVtbl -> GetTimecodeBCD(This,currentTimecode,error) )
-
-#define IDeckLinkDeckControl_SetPreroll(This,prerollSeconds) \
- ( (This)->lpVtbl -> SetPreroll(This,prerollSeconds) )
-
-#define IDeckLinkDeckControl_GetPreroll(This,prerollSeconds) \
- ( (This)->lpVtbl -> GetPreroll(This,prerollSeconds) )
-
-#define IDeckLinkDeckControl_SetExportOffset(This,exportOffsetFields) \
- ( (This)->lpVtbl -> SetExportOffset(This,exportOffsetFields) )
-
-#define IDeckLinkDeckControl_GetExportOffset(This,exportOffsetFields) \
- ( (This)->lpVtbl -> GetExportOffset(This,exportOffsetFields) )
-
-#define IDeckLinkDeckControl_GetManualExportOffset(This,deckManualExportOffsetFields) \
- ( (This)->lpVtbl -> GetManualExportOffset(This,deckManualExportOffsetFields) )
-
-#define IDeckLinkDeckControl_SetCaptureOffset(This,captureOffsetFields) \
- ( (This)->lpVtbl -> SetCaptureOffset(This,captureOffsetFields) )
-
-#define IDeckLinkDeckControl_GetCaptureOffset(This,captureOffsetFields) \
- ( (This)->lpVtbl -> GetCaptureOffset(This,captureOffsetFields) )
-
-#define IDeckLinkDeckControl_StartExport(This,inTimecode,outTimecode,exportModeOps,error) \
- ( (This)->lpVtbl -> StartExport(This,inTimecode,outTimecode,exportModeOps,error) )
-
-#define IDeckLinkDeckControl_StartCapture(This,useVITC,inTimecode,outTimecode,error) \
- ( (This)->lpVtbl -> StartCapture(This,useVITC,inTimecode,outTimecode,error) )
-
-#define IDeckLinkDeckControl_GetDeviceID(This,deviceId,error) \
- ( (This)->lpVtbl -> GetDeviceID(This,deviceId,error) )
-
-#define IDeckLinkDeckControl_Abort(This) \
- ( (This)->lpVtbl -> Abort(This) )
-
-#define IDeckLinkDeckControl_CrashRecordStart(This,error) \
- ( (This)->lpVtbl -> CrashRecordStart(This,error) )
-
-#define IDeckLinkDeckControl_CrashRecordStop(This,error) \
- ( (This)->lpVtbl -> CrashRecordStop(This,error) )
-
-#define IDeckLinkDeckControl_SetCallback(This,callback) \
- ( (This)->lpVtbl -> SetCallback(This,callback) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDeckControl_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingDeviceNotificationCallback_INTERFACE_DEFINED__
-#define __IBMDStreamingDeviceNotificationCallback_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingDeviceNotificationCallback */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingDeviceNotificationCallback;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("F9531D64-3305-4B29-A387-7F74BB0D0E84")
- IBMDStreamingDeviceNotificationCallback : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE StreamingDeviceArrived(
- /* [in] */ IDeckLink *device) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StreamingDeviceRemoved(
- /* [in] */ IDeckLink *device) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StreamingDeviceModeChanged(
- /* [in] */ IDeckLink *device,
- /* [in] */ BMDStreamingDeviceMode mode) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingDeviceNotificationCallbackVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingDeviceNotificationCallback * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingDeviceNotificationCallback * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingDeviceNotificationCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *StreamingDeviceArrived )(
- IBMDStreamingDeviceNotificationCallback * This,
- /* [in] */ IDeckLink *device);
-
- HRESULT ( STDMETHODCALLTYPE *StreamingDeviceRemoved )(
- IBMDStreamingDeviceNotificationCallback * This,
- /* [in] */ IDeckLink *device);
-
- HRESULT ( STDMETHODCALLTYPE *StreamingDeviceModeChanged )(
- IBMDStreamingDeviceNotificationCallback * This,
- /* [in] */ IDeckLink *device,
- /* [in] */ BMDStreamingDeviceMode mode);
-
- END_INTERFACE
- } IBMDStreamingDeviceNotificationCallbackVtbl;
-
- interface IBMDStreamingDeviceNotificationCallback
- {
- CONST_VTBL struct IBMDStreamingDeviceNotificationCallbackVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingDeviceNotificationCallback_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingDeviceNotificationCallback_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingDeviceNotificationCallback_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingDeviceNotificationCallback_StreamingDeviceArrived(This,device) \
- ( (This)->lpVtbl -> StreamingDeviceArrived(This,device) )
-
-#define IBMDStreamingDeviceNotificationCallback_StreamingDeviceRemoved(This,device) \
- ( (This)->lpVtbl -> StreamingDeviceRemoved(This,device) )
-
-#define IBMDStreamingDeviceNotificationCallback_StreamingDeviceModeChanged(This,device,mode) \
- ( (This)->lpVtbl -> StreamingDeviceModeChanged(This,device,mode) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingDeviceNotificationCallback_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingH264InputCallback_INTERFACE_DEFINED__
-#define __IBMDStreamingH264InputCallback_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingH264InputCallback */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingH264InputCallback;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("823C475F-55AE-46F9-890C-537CC5CEDCCA")
- IBMDStreamingH264InputCallback : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE H264NALPacketArrived(
- /* [in] */ IBMDStreamingH264NALPacket *nalPacket) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE H264AudioPacketArrived(
- /* [in] */ IBMDStreamingAudioPacket *audioPacket) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE MPEG2TSPacketArrived(
- /* [in] */ IBMDStreamingMPEG2TSPacket *tsPacket) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE H264VideoInputConnectorScanningChanged( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE H264VideoInputConnectorChanged( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE H264VideoInputModeChanged( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingH264InputCallbackVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingH264InputCallback * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingH264InputCallback * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingH264InputCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *H264NALPacketArrived )(
- IBMDStreamingH264InputCallback * This,
- /* [in] */ IBMDStreamingH264NALPacket *nalPacket);
-
- HRESULT ( STDMETHODCALLTYPE *H264AudioPacketArrived )(
- IBMDStreamingH264InputCallback * This,
- /* [in] */ IBMDStreamingAudioPacket *audioPacket);
-
- HRESULT ( STDMETHODCALLTYPE *MPEG2TSPacketArrived )(
- IBMDStreamingH264InputCallback * This,
- /* [in] */ IBMDStreamingMPEG2TSPacket *tsPacket);
-
- HRESULT ( STDMETHODCALLTYPE *H264VideoInputConnectorScanningChanged )(
- IBMDStreamingH264InputCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *H264VideoInputConnectorChanged )(
- IBMDStreamingH264InputCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *H264VideoInputModeChanged )(
- IBMDStreamingH264InputCallback * This);
-
- END_INTERFACE
- } IBMDStreamingH264InputCallbackVtbl;
-
- interface IBMDStreamingH264InputCallback
- {
- CONST_VTBL struct IBMDStreamingH264InputCallbackVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingH264InputCallback_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingH264InputCallback_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingH264InputCallback_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingH264InputCallback_H264NALPacketArrived(This,nalPacket) \
- ( (This)->lpVtbl -> H264NALPacketArrived(This,nalPacket) )
-
-#define IBMDStreamingH264InputCallback_H264AudioPacketArrived(This,audioPacket) \
- ( (This)->lpVtbl -> H264AudioPacketArrived(This,audioPacket) )
-
-#define IBMDStreamingH264InputCallback_MPEG2TSPacketArrived(This,tsPacket) \
- ( (This)->lpVtbl -> MPEG2TSPacketArrived(This,tsPacket) )
-
-#define IBMDStreamingH264InputCallback_H264VideoInputConnectorScanningChanged(This) \
- ( (This)->lpVtbl -> H264VideoInputConnectorScanningChanged(This) )
-
-#define IBMDStreamingH264InputCallback_H264VideoInputConnectorChanged(This) \
- ( (This)->lpVtbl -> H264VideoInputConnectorChanged(This) )
-
-#define IBMDStreamingH264InputCallback_H264VideoInputModeChanged(This) \
- ( (This)->lpVtbl -> H264VideoInputModeChanged(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingH264InputCallback_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingDiscovery_INTERFACE_DEFINED__
-#define __IBMDStreamingDiscovery_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingDiscovery */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingDiscovery;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("2C837444-F989-4D87-901A-47C8A36D096D")
- IBMDStreamingDiscovery : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE InstallDeviceNotifications(
- /* [in] */ IBMDStreamingDeviceNotificationCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE UninstallDeviceNotifications( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingDiscoveryVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingDiscovery * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingDiscovery * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingDiscovery * This);
-
- HRESULT ( STDMETHODCALLTYPE *InstallDeviceNotifications )(
- IBMDStreamingDiscovery * This,
- /* [in] */ IBMDStreamingDeviceNotificationCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *UninstallDeviceNotifications )(
- IBMDStreamingDiscovery * This);
-
- END_INTERFACE
- } IBMDStreamingDiscoveryVtbl;
-
- interface IBMDStreamingDiscovery
- {
- CONST_VTBL struct IBMDStreamingDiscoveryVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingDiscovery_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingDiscovery_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingDiscovery_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingDiscovery_InstallDeviceNotifications(This,theCallback) \
- ( (This)->lpVtbl -> InstallDeviceNotifications(This,theCallback) )
-
-#define IBMDStreamingDiscovery_UninstallDeviceNotifications(This) \
- ( (This)->lpVtbl -> UninstallDeviceNotifications(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingDiscovery_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingVideoEncodingMode_INTERFACE_DEFINED__
-#define __IBMDStreamingVideoEncodingMode_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingVideoEncodingMode */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingVideoEncodingMode;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("1AB8035B-CD13-458D-B6DF-5E8F7C2141D9")
- IBMDStreamingVideoEncodingMode : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetName(
- /* [out] */ BSTR *name) = 0;
-
- virtual unsigned int STDMETHODCALLTYPE GetPresetID( void) = 0;
-
- virtual unsigned int STDMETHODCALLTYPE GetSourcePositionX( void) = 0;
-
- virtual unsigned int STDMETHODCALLTYPE GetSourcePositionY( void) = 0;
-
- virtual unsigned int STDMETHODCALLTYPE GetSourceWidth( void) = 0;
-
- virtual unsigned int STDMETHODCALLTYPE GetSourceHeight( void) = 0;
-
- virtual unsigned int STDMETHODCALLTYPE GetDestWidth( void) = 0;
-
- virtual unsigned int STDMETHODCALLTYPE GetDestHeight( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFlag(
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ BOOL *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetInt(
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ LONGLONG *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFloat(
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ double *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetString(
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ BSTR *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateMutableVideoEncodingMode(
- /* [out] */ IBMDStreamingMutableVideoEncodingMode **newEncodingMode) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingVideoEncodingModeVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingVideoEncodingMode * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingVideoEncodingMode * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingVideoEncodingMode * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetName )(
- IBMDStreamingVideoEncodingMode * This,
- /* [out] */ BSTR *name);
-
- unsigned int ( STDMETHODCALLTYPE *GetPresetID )(
- IBMDStreamingVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetSourcePositionX )(
- IBMDStreamingVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetSourcePositionY )(
- IBMDStreamingVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetSourceWidth )(
- IBMDStreamingVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetSourceHeight )(
- IBMDStreamingVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetDestWidth )(
- IBMDStreamingVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetDestHeight )(
- IBMDStreamingVideoEncodingMode * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetFlag )(
- IBMDStreamingVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ BOOL *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetInt )(
- IBMDStreamingVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ LONGLONG *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetFloat )(
- IBMDStreamingVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ double *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetString )(
- IBMDStreamingVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ BSTR *value);
-
- HRESULT ( STDMETHODCALLTYPE *CreateMutableVideoEncodingMode )(
- IBMDStreamingVideoEncodingMode * This,
- /* [out] */ IBMDStreamingMutableVideoEncodingMode **newEncodingMode);
-
- END_INTERFACE
- } IBMDStreamingVideoEncodingModeVtbl;
-
- interface IBMDStreamingVideoEncodingMode
- {
- CONST_VTBL struct IBMDStreamingVideoEncodingModeVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingVideoEncodingMode_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingVideoEncodingMode_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingVideoEncodingMode_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingVideoEncodingMode_GetName(This,name) \
- ( (This)->lpVtbl -> GetName(This,name) )
-
-#define IBMDStreamingVideoEncodingMode_GetPresetID(This) \
- ( (This)->lpVtbl -> GetPresetID(This) )
-
-#define IBMDStreamingVideoEncodingMode_GetSourcePositionX(This) \
- ( (This)->lpVtbl -> GetSourcePositionX(This) )
-
-#define IBMDStreamingVideoEncodingMode_GetSourcePositionY(This) \
- ( (This)->lpVtbl -> GetSourcePositionY(This) )
-
-#define IBMDStreamingVideoEncodingMode_GetSourceWidth(This) \
- ( (This)->lpVtbl -> GetSourceWidth(This) )
-
-#define IBMDStreamingVideoEncodingMode_GetSourceHeight(This) \
- ( (This)->lpVtbl -> GetSourceHeight(This) )
-
-#define IBMDStreamingVideoEncodingMode_GetDestWidth(This) \
- ( (This)->lpVtbl -> GetDestWidth(This) )
-
-#define IBMDStreamingVideoEncodingMode_GetDestHeight(This) \
- ( (This)->lpVtbl -> GetDestHeight(This) )
-
-#define IBMDStreamingVideoEncodingMode_GetFlag(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFlag(This,cfgID,value) )
-
-#define IBMDStreamingVideoEncodingMode_GetInt(This,cfgID,value) \
- ( (This)->lpVtbl -> GetInt(This,cfgID,value) )
-
-#define IBMDStreamingVideoEncodingMode_GetFloat(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFloat(This,cfgID,value) )
-
-#define IBMDStreamingVideoEncodingMode_GetString(This,cfgID,value) \
- ( (This)->lpVtbl -> GetString(This,cfgID,value) )
-
-#define IBMDStreamingVideoEncodingMode_CreateMutableVideoEncodingMode(This,newEncodingMode) \
- ( (This)->lpVtbl -> CreateMutableVideoEncodingMode(This,newEncodingMode) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingVideoEncodingMode_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingMutableVideoEncodingMode_INTERFACE_DEFINED__
-#define __IBMDStreamingMutableVideoEncodingMode_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingMutableVideoEncodingMode */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingMutableVideoEncodingMode;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("19BF7D90-1E0A-400D-B2C6-FFC4E78AD49D")
- IBMDStreamingMutableVideoEncodingMode : public IBMDStreamingVideoEncodingMode
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE SetSourceRect(
- /* [in] */ unsigned int posX,
- /* [in] */ unsigned int posY,
- /* [in] */ unsigned int width,
- /* [in] */ unsigned int height) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetDestSize(
- /* [in] */ unsigned int width,
- /* [in] */ unsigned int height) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetFlag(
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [in] */ BOOL value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetInt(
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [in] */ LONGLONG value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetFloat(
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [in] */ double value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetString(
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [in] */ BSTR value) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingMutableVideoEncodingModeVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingMutableVideoEncodingMode * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingMutableVideoEncodingMode * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetName )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [out] */ BSTR *name);
-
- unsigned int ( STDMETHODCALLTYPE *GetPresetID )(
- IBMDStreamingMutableVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetSourcePositionX )(
- IBMDStreamingMutableVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetSourcePositionY )(
- IBMDStreamingMutableVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetSourceWidth )(
- IBMDStreamingMutableVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetSourceHeight )(
- IBMDStreamingMutableVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetDestWidth )(
- IBMDStreamingMutableVideoEncodingMode * This);
-
- unsigned int ( STDMETHODCALLTYPE *GetDestHeight )(
- IBMDStreamingMutableVideoEncodingMode * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetFlag )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ BOOL *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetInt )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ LONGLONG *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetFloat )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ double *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetString )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [out] */ BSTR *value);
-
- HRESULT ( STDMETHODCALLTYPE *CreateMutableVideoEncodingMode )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [out] */ IBMDStreamingMutableVideoEncodingMode **newEncodingMode);
-
- HRESULT ( STDMETHODCALLTYPE *SetSourceRect )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ unsigned int posX,
- /* [in] */ unsigned int posY,
- /* [in] */ unsigned int width,
- /* [in] */ unsigned int height);
-
- HRESULT ( STDMETHODCALLTYPE *SetDestSize )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ unsigned int width,
- /* [in] */ unsigned int height);
-
- HRESULT ( STDMETHODCALLTYPE *SetFlag )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [in] */ BOOL value);
-
- HRESULT ( STDMETHODCALLTYPE *SetInt )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [in] */ LONGLONG value);
-
- HRESULT ( STDMETHODCALLTYPE *SetFloat )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [in] */ double value);
-
- HRESULT ( STDMETHODCALLTYPE *SetString )(
- IBMDStreamingMutableVideoEncodingMode * This,
- /* [in] */ BMDStreamingEncodingModePropertyID cfgID,
- /* [in] */ BSTR value);
-
- END_INTERFACE
- } IBMDStreamingMutableVideoEncodingModeVtbl;
-
- interface IBMDStreamingMutableVideoEncodingMode
- {
- CONST_VTBL struct IBMDStreamingMutableVideoEncodingModeVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingMutableVideoEncodingMode_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingMutableVideoEncodingMode_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingMutableVideoEncodingMode_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingMutableVideoEncodingMode_GetName(This,name) \
- ( (This)->lpVtbl -> GetName(This,name) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetPresetID(This) \
- ( (This)->lpVtbl -> GetPresetID(This) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetSourcePositionX(This) \
- ( (This)->lpVtbl -> GetSourcePositionX(This) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetSourcePositionY(This) \
- ( (This)->lpVtbl -> GetSourcePositionY(This) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetSourceWidth(This) \
- ( (This)->lpVtbl -> GetSourceWidth(This) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetSourceHeight(This) \
- ( (This)->lpVtbl -> GetSourceHeight(This) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetDestWidth(This) \
- ( (This)->lpVtbl -> GetDestWidth(This) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetDestHeight(This) \
- ( (This)->lpVtbl -> GetDestHeight(This) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetFlag(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFlag(This,cfgID,value) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetInt(This,cfgID,value) \
- ( (This)->lpVtbl -> GetInt(This,cfgID,value) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetFloat(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFloat(This,cfgID,value) )
-
-#define IBMDStreamingMutableVideoEncodingMode_GetString(This,cfgID,value) \
- ( (This)->lpVtbl -> GetString(This,cfgID,value) )
-
-#define IBMDStreamingMutableVideoEncodingMode_CreateMutableVideoEncodingMode(This,newEncodingMode) \
- ( (This)->lpVtbl -> CreateMutableVideoEncodingMode(This,newEncodingMode) )
-
-
-#define IBMDStreamingMutableVideoEncodingMode_SetSourceRect(This,posX,posY,width,height) \
- ( (This)->lpVtbl -> SetSourceRect(This,posX,posY,width,height) )
-
-#define IBMDStreamingMutableVideoEncodingMode_SetDestSize(This,width,height) \
- ( (This)->lpVtbl -> SetDestSize(This,width,height) )
-
-#define IBMDStreamingMutableVideoEncodingMode_SetFlag(This,cfgID,value) \
- ( (This)->lpVtbl -> SetFlag(This,cfgID,value) )
-
-#define IBMDStreamingMutableVideoEncodingMode_SetInt(This,cfgID,value) \
- ( (This)->lpVtbl -> SetInt(This,cfgID,value) )
-
-#define IBMDStreamingMutableVideoEncodingMode_SetFloat(This,cfgID,value) \
- ( (This)->lpVtbl -> SetFloat(This,cfgID,value) )
-
-#define IBMDStreamingMutableVideoEncodingMode_SetString(This,cfgID,value) \
- ( (This)->lpVtbl -> SetString(This,cfgID,value) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingMutableVideoEncodingMode_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingVideoEncodingModePresetIterator_INTERFACE_DEFINED__
-#define __IBMDStreamingVideoEncodingModePresetIterator_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingVideoEncodingModePresetIterator */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingVideoEncodingModePresetIterator;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("7AC731A3-C950-4AD0-804A-8377AA51C6C4")
- IBMDStreamingVideoEncodingModePresetIterator : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Next(
- /* [out] */ IBMDStreamingVideoEncodingMode **videoEncodingMode) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingVideoEncodingModePresetIteratorVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingVideoEncodingModePresetIterator * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingVideoEncodingModePresetIterator * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingVideoEncodingModePresetIterator * This);
-
- HRESULT ( STDMETHODCALLTYPE *Next )(
- IBMDStreamingVideoEncodingModePresetIterator * This,
- /* [out] */ IBMDStreamingVideoEncodingMode **videoEncodingMode);
-
- END_INTERFACE
- } IBMDStreamingVideoEncodingModePresetIteratorVtbl;
-
- interface IBMDStreamingVideoEncodingModePresetIterator
- {
- CONST_VTBL struct IBMDStreamingVideoEncodingModePresetIteratorVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingVideoEncodingModePresetIterator_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingVideoEncodingModePresetIterator_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingVideoEncodingModePresetIterator_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingVideoEncodingModePresetIterator_Next(This,videoEncodingMode) \
- ( (This)->lpVtbl -> Next(This,videoEncodingMode) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingVideoEncodingModePresetIterator_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingDeviceInput_INTERFACE_DEFINED__
-#define __IBMDStreamingDeviceInput_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingDeviceInput */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingDeviceInput;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("24B6B6EC-1727-44BB-9818-34FF086ACF98")
- IBMDStreamingDeviceInput : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoInputMode(
- /* [in] */ BMDDisplayMode inputMode,
- /* [out] */ BOOL *result) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetVideoInputModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoInputMode(
- /* [in] */ BMDDisplayMode inputMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetCurrentDetectedVideoInputMode(
- /* [out] */ BMDDisplayMode *detectedMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetVideoEncodingMode(
- /* [out] */ IBMDStreamingVideoEncodingMode **encodingMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetVideoEncodingModePresetIterator(
- /* [in] */ BMDDisplayMode inputMode,
- /* [out] */ IBMDStreamingVideoEncodingModePresetIterator **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoEncodingMode(
- /* [in] */ BMDDisplayMode inputMode,
- /* [in] */ IBMDStreamingVideoEncodingMode *encodingMode,
- /* [out] */ BMDStreamingEncodingSupport *result,
- /* [out] */ IBMDStreamingVideoEncodingMode **changedEncodingMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoEncodingMode(
- /* [in] */ IBMDStreamingVideoEncodingMode *encodingMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartCapture( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopCapture( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- /* [in] */ IUnknown *theCallback) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingDeviceInputVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingDeviceInput * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingDeviceInput * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingDeviceInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoInputMode )(
- IBMDStreamingDeviceInput * This,
- /* [in] */ BMDDisplayMode inputMode,
- /* [out] */ BOOL *result);
-
- HRESULT ( STDMETHODCALLTYPE *GetVideoInputModeIterator )(
- IBMDStreamingDeviceInput * This,
- /* [out] */ IDeckLinkDisplayModeIterator **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoInputMode )(
- IBMDStreamingDeviceInput * This,
- /* [in] */ BMDDisplayMode inputMode);
-
- HRESULT ( STDMETHODCALLTYPE *GetCurrentDetectedVideoInputMode )(
- IBMDStreamingDeviceInput * This,
- /* [out] */ BMDDisplayMode *detectedMode);
-
- HRESULT ( STDMETHODCALLTYPE *GetVideoEncodingMode )(
- IBMDStreamingDeviceInput * This,
- /* [out] */ IBMDStreamingVideoEncodingMode **encodingMode);
-
- HRESULT ( STDMETHODCALLTYPE *GetVideoEncodingModePresetIterator )(
- IBMDStreamingDeviceInput * This,
- /* [in] */ BMDDisplayMode inputMode,
- /* [out] */ IBMDStreamingVideoEncodingModePresetIterator **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoEncodingMode )(
- IBMDStreamingDeviceInput * This,
- /* [in] */ BMDDisplayMode inputMode,
- /* [in] */ IBMDStreamingVideoEncodingMode *encodingMode,
- /* [out] */ BMDStreamingEncodingSupport *result,
- /* [out] */ IBMDStreamingVideoEncodingMode **changedEncodingMode);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoEncodingMode )(
- IBMDStreamingDeviceInput * This,
- /* [in] */ IBMDStreamingVideoEncodingMode *encodingMode);
-
- HRESULT ( STDMETHODCALLTYPE *StartCapture )(
- IBMDStreamingDeviceInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *StopCapture )(
- IBMDStreamingDeviceInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetCallback )(
- IBMDStreamingDeviceInput * This,
- /* [in] */ IUnknown *theCallback);
-
- END_INTERFACE
- } IBMDStreamingDeviceInputVtbl;
-
- interface IBMDStreamingDeviceInput
- {
- CONST_VTBL struct IBMDStreamingDeviceInputVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingDeviceInput_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingDeviceInput_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingDeviceInput_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingDeviceInput_DoesSupportVideoInputMode(This,inputMode,result) \
- ( (This)->lpVtbl -> DoesSupportVideoInputMode(This,inputMode,result) )
-
-#define IBMDStreamingDeviceInput_GetVideoInputModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetVideoInputModeIterator(This,iterator) )
-
-#define IBMDStreamingDeviceInput_SetVideoInputMode(This,inputMode) \
- ( (This)->lpVtbl -> SetVideoInputMode(This,inputMode) )
-
-#define IBMDStreamingDeviceInput_GetCurrentDetectedVideoInputMode(This,detectedMode) \
- ( (This)->lpVtbl -> GetCurrentDetectedVideoInputMode(This,detectedMode) )
-
-#define IBMDStreamingDeviceInput_GetVideoEncodingMode(This,encodingMode) \
- ( (This)->lpVtbl -> GetVideoEncodingMode(This,encodingMode) )
-
-#define IBMDStreamingDeviceInput_GetVideoEncodingModePresetIterator(This,inputMode,iterator) \
- ( (This)->lpVtbl -> GetVideoEncodingModePresetIterator(This,inputMode,iterator) )
-
-#define IBMDStreamingDeviceInput_DoesSupportVideoEncodingMode(This,inputMode,encodingMode,result,changedEncodingMode) \
- ( (This)->lpVtbl -> DoesSupportVideoEncodingMode(This,inputMode,encodingMode,result,changedEncodingMode) )
-
-#define IBMDStreamingDeviceInput_SetVideoEncodingMode(This,encodingMode) \
- ( (This)->lpVtbl -> SetVideoEncodingMode(This,encodingMode) )
-
-#define IBMDStreamingDeviceInput_StartCapture(This) \
- ( (This)->lpVtbl -> StartCapture(This) )
-
-#define IBMDStreamingDeviceInput_StopCapture(This) \
- ( (This)->lpVtbl -> StopCapture(This) )
-
-#define IBMDStreamingDeviceInput_SetCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetCallback(This,theCallback) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingDeviceInput_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingH264NALPacket_INTERFACE_DEFINED__
-#define __IBMDStreamingH264NALPacket_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingH264NALPacket */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingH264NALPacket;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("E260E955-14BE-4395-9775-9F02CC0A9D89")
- IBMDStreamingH264NALPacket : public IUnknown
- {
- public:
- virtual long STDMETHODCALLTYPE GetPayloadSize( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBytes(
- /* [out] */ void **buffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBytesWithSizePrefix(
- /* [out] */ void **buffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayTime(
- /* [in] */ ULONGLONG requestedTimeScale,
- /* [out] */ ULONGLONG *displayTime) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetPacketIndex(
- /* [out] */ unsigned int *packetIndex) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingH264NALPacketVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingH264NALPacket * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingH264NALPacket * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingH264NALPacket * This);
-
- long ( STDMETHODCALLTYPE *GetPayloadSize )(
- IBMDStreamingH264NALPacket * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IBMDStreamingH264NALPacket * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytesWithSizePrefix )(
- IBMDStreamingH264NALPacket * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayTime )(
- IBMDStreamingH264NALPacket * This,
- /* [in] */ ULONGLONG requestedTimeScale,
- /* [out] */ ULONGLONG *displayTime);
-
- HRESULT ( STDMETHODCALLTYPE *GetPacketIndex )(
- IBMDStreamingH264NALPacket * This,
- /* [out] */ unsigned int *packetIndex);
-
- END_INTERFACE
- } IBMDStreamingH264NALPacketVtbl;
-
- interface IBMDStreamingH264NALPacket
- {
- CONST_VTBL struct IBMDStreamingH264NALPacketVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingH264NALPacket_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingH264NALPacket_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingH264NALPacket_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingH264NALPacket_GetPayloadSize(This) \
- ( (This)->lpVtbl -> GetPayloadSize(This) )
-
-#define IBMDStreamingH264NALPacket_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IBMDStreamingH264NALPacket_GetBytesWithSizePrefix(This,buffer) \
- ( (This)->lpVtbl -> GetBytesWithSizePrefix(This,buffer) )
-
-#define IBMDStreamingH264NALPacket_GetDisplayTime(This,requestedTimeScale,displayTime) \
- ( (This)->lpVtbl -> GetDisplayTime(This,requestedTimeScale,displayTime) )
-
-#define IBMDStreamingH264NALPacket_GetPacketIndex(This,packetIndex) \
- ( (This)->lpVtbl -> GetPacketIndex(This,packetIndex) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingH264NALPacket_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingAudioPacket_INTERFACE_DEFINED__
-#define __IBMDStreamingAudioPacket_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingAudioPacket */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingAudioPacket;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("D9EB5902-1AD2-43F4-9E2C-3CFA50B5EE19")
- IBMDStreamingAudioPacket : public IUnknown
- {
- public:
- virtual BMDStreamingAudioCodec STDMETHODCALLTYPE GetCodec( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetPayloadSize( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBytes(
- /* [out] */ void **buffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetPlayTime(
- /* [in] */ ULONGLONG requestedTimeScale,
- /* [out] */ ULONGLONG *playTime) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetPacketIndex(
- /* [out] */ unsigned int *packetIndex) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingAudioPacketVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingAudioPacket * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingAudioPacket * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingAudioPacket * This);
-
- BMDStreamingAudioCodec ( STDMETHODCALLTYPE *GetCodec )(
- IBMDStreamingAudioPacket * This);
-
- long ( STDMETHODCALLTYPE *GetPayloadSize )(
- IBMDStreamingAudioPacket * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IBMDStreamingAudioPacket * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetPlayTime )(
- IBMDStreamingAudioPacket * This,
- /* [in] */ ULONGLONG requestedTimeScale,
- /* [out] */ ULONGLONG *playTime);
-
- HRESULT ( STDMETHODCALLTYPE *GetPacketIndex )(
- IBMDStreamingAudioPacket * This,
- /* [out] */ unsigned int *packetIndex);
-
- END_INTERFACE
- } IBMDStreamingAudioPacketVtbl;
-
- interface IBMDStreamingAudioPacket
- {
- CONST_VTBL struct IBMDStreamingAudioPacketVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingAudioPacket_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingAudioPacket_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingAudioPacket_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingAudioPacket_GetCodec(This) \
- ( (This)->lpVtbl -> GetCodec(This) )
-
-#define IBMDStreamingAudioPacket_GetPayloadSize(This) \
- ( (This)->lpVtbl -> GetPayloadSize(This) )
-
-#define IBMDStreamingAudioPacket_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IBMDStreamingAudioPacket_GetPlayTime(This,requestedTimeScale,playTime) \
- ( (This)->lpVtbl -> GetPlayTime(This,requestedTimeScale,playTime) )
-
-#define IBMDStreamingAudioPacket_GetPacketIndex(This,packetIndex) \
- ( (This)->lpVtbl -> GetPacketIndex(This,packetIndex) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingAudioPacket_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingMPEG2TSPacket_INTERFACE_DEFINED__
-#define __IBMDStreamingMPEG2TSPacket_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingMPEG2TSPacket */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingMPEG2TSPacket;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("91810D1C-4FB3-4AAA-AE56-FA301D3DFA4C")
- IBMDStreamingMPEG2TSPacket : public IUnknown
- {
- public:
- virtual long STDMETHODCALLTYPE GetPayloadSize( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBytes(
- /* [out] */ void **buffer) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingMPEG2TSPacketVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingMPEG2TSPacket * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingMPEG2TSPacket * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingMPEG2TSPacket * This);
-
- long ( STDMETHODCALLTYPE *GetPayloadSize )(
- IBMDStreamingMPEG2TSPacket * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IBMDStreamingMPEG2TSPacket * This,
- /* [out] */ void **buffer);
-
- END_INTERFACE
- } IBMDStreamingMPEG2TSPacketVtbl;
-
- interface IBMDStreamingMPEG2TSPacket
- {
- CONST_VTBL struct IBMDStreamingMPEG2TSPacketVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingMPEG2TSPacket_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingMPEG2TSPacket_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingMPEG2TSPacket_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingMPEG2TSPacket_GetPayloadSize(This) \
- ( (This)->lpVtbl -> GetPayloadSize(This) )
-
-#define IBMDStreamingMPEG2TSPacket_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingMPEG2TSPacket_INTERFACE_DEFINED__ */
-
-
-#ifndef __IBMDStreamingH264NALParser_INTERFACE_DEFINED__
-#define __IBMDStreamingH264NALParser_INTERFACE_DEFINED__
-
-/* interface IBMDStreamingH264NALParser */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IBMDStreamingH264NALParser;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("5867F18C-5BFA-4CCC-B2A7-9DFD140417D2")
- IBMDStreamingH264NALParser : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE IsNALSequenceParameterSet(
- /* [in] */ IBMDStreamingH264NALPacket *nal) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IsNALPictureParameterSet(
- /* [in] */ IBMDStreamingH264NALPacket *nal) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetProfileAndLevelFromSPS(
- /* [in] */ IBMDStreamingH264NALPacket *nal,
- /* [out] */ unsigned int *profileIdc,
- /* [out] */ unsigned int *profileCompatability,
- /* [out] */ unsigned int *levelIdc) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IBMDStreamingH264NALParserVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IBMDStreamingH264NALParser * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IBMDStreamingH264NALParser * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IBMDStreamingH264NALParser * This);
-
- HRESULT ( STDMETHODCALLTYPE *IsNALSequenceParameterSet )(
- IBMDStreamingH264NALParser * This,
- /* [in] */ IBMDStreamingH264NALPacket *nal);
-
- HRESULT ( STDMETHODCALLTYPE *IsNALPictureParameterSet )(
- IBMDStreamingH264NALParser * This,
- /* [in] */ IBMDStreamingH264NALPacket *nal);
-
- HRESULT ( STDMETHODCALLTYPE *GetProfileAndLevelFromSPS )(
- IBMDStreamingH264NALParser * This,
- /* [in] */ IBMDStreamingH264NALPacket *nal,
- /* [out] */ unsigned int *profileIdc,
- /* [out] */ unsigned int *profileCompatability,
- /* [out] */ unsigned int *levelIdc);
-
- END_INTERFACE
- } IBMDStreamingH264NALParserVtbl;
-
- interface IBMDStreamingH264NALParser
- {
- CONST_VTBL struct IBMDStreamingH264NALParserVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IBMDStreamingH264NALParser_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IBMDStreamingH264NALParser_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IBMDStreamingH264NALParser_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IBMDStreamingH264NALParser_IsNALSequenceParameterSet(This,nal) \
- ( (This)->lpVtbl -> IsNALSequenceParameterSet(This,nal) )
-
-#define IBMDStreamingH264NALParser_IsNALPictureParameterSet(This,nal) \
- ( (This)->lpVtbl -> IsNALPictureParameterSet(This,nal) )
-
-#define IBMDStreamingH264NALParser_GetProfileAndLevelFromSPS(This,nal,profileIdc,profileCompatability,levelIdc) \
- ( (This)->lpVtbl -> GetProfileAndLevelFromSPS(This,nal,profileIdc,profileCompatability,levelIdc) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IBMDStreamingH264NALParser_INTERFACE_DEFINED__ */
-
-
-EXTERN_C const CLSID CLSID_CBMDStreamingDiscovery;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("0CAA31F6-8A26-40B0-86A4-BF58DCCA710C")
-CBMDStreamingDiscovery;
-#endif
-
-EXTERN_C const CLSID CLSID_CBMDStreamingH264NALParser;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("7753EFBD-951C-407C-97A5-23C737B73B52")
-CBMDStreamingH264NALParser;
-#endif
-
-#ifndef __IDeckLinkVideoOutputCallback_INTERFACE_DEFINED__
-#define __IDeckLinkVideoOutputCallback_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoOutputCallback */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoOutputCallback;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("20AA5225-1958-47CB-820B-80A8D521A6EE")
- IDeckLinkVideoOutputCallback : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted(
- /* [in] */ IDeckLinkVideoFrame *completedFrame,
- /* [in] */ BMDOutputFrameCompletionResult result) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduledPlaybackHasStopped( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoOutputCallbackVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoOutputCallback * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoOutputCallback * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoOutputCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduledFrameCompleted )(
- IDeckLinkVideoOutputCallback * This,
- /* [in] */ IDeckLinkVideoFrame *completedFrame,
- /* [in] */ BMDOutputFrameCompletionResult result);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduledPlaybackHasStopped )(
- IDeckLinkVideoOutputCallback * This);
-
- END_INTERFACE
- } IDeckLinkVideoOutputCallbackVtbl;
-
- interface IDeckLinkVideoOutputCallback
- {
- CONST_VTBL struct IDeckLinkVideoOutputCallbackVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoOutputCallback_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoOutputCallback_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoOutputCallback_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoOutputCallback_ScheduledFrameCompleted(This,completedFrame,result) \
- ( (This)->lpVtbl -> ScheduledFrameCompleted(This,completedFrame,result) )
-
-#define IDeckLinkVideoOutputCallback_ScheduledPlaybackHasStopped(This) \
- ( (This)->lpVtbl -> ScheduledPlaybackHasStopped(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoOutputCallback_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkInputCallback_INTERFACE_DEFINED__
-#define __IDeckLinkInputCallback_INTERFACE_DEFINED__
-
-/* interface IDeckLinkInputCallback */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkInputCallback;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("DD04E5EC-7415-42AB-AE4A-E80C4DFC044A")
- IDeckLinkInputCallback : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(
- /* [in] */ BMDVideoInputFormatChangedEvents notificationEvents,
- /* [in] */ IDeckLinkDisplayMode *newDisplayMode,
- /* [in] */ BMDDetectedVideoInputFormatFlags detectedSignalFlags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(
- /* [in] */ IDeckLinkVideoInputFrame *videoFrame,
- /* [in] */ IDeckLinkAudioInputPacket *audioPacket) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkInputCallbackVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkInputCallback * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkInputCallback * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkInputCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *VideoInputFormatChanged )(
- IDeckLinkInputCallback * This,
- /* [in] */ BMDVideoInputFormatChangedEvents notificationEvents,
- /* [in] */ IDeckLinkDisplayMode *newDisplayMode,
- /* [in] */ BMDDetectedVideoInputFormatFlags detectedSignalFlags);
-
- HRESULT ( STDMETHODCALLTYPE *VideoInputFrameArrived )(
- IDeckLinkInputCallback * This,
- /* [in] */ IDeckLinkVideoInputFrame *videoFrame,
- /* [in] */ IDeckLinkAudioInputPacket *audioPacket);
-
- END_INTERFACE
- } IDeckLinkInputCallbackVtbl;
-
- interface IDeckLinkInputCallback
- {
- CONST_VTBL struct IDeckLinkInputCallbackVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkInputCallback_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkInputCallback_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkInputCallback_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkInputCallback_VideoInputFormatChanged(This,notificationEvents,newDisplayMode,detectedSignalFlags) \
- ( (This)->lpVtbl -> VideoInputFormatChanged(This,notificationEvents,newDisplayMode,detectedSignalFlags) )
-
-#define IDeckLinkInputCallback_VideoInputFrameArrived(This,videoFrame,audioPacket) \
- ( (This)->lpVtbl -> VideoInputFrameArrived(This,videoFrame,audioPacket) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkInputCallback_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkMemoryAllocator_INTERFACE_DEFINED__
-#define __IDeckLinkMemoryAllocator_INTERFACE_DEFINED__
-
-/* interface IDeckLinkMemoryAllocator */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkMemoryAllocator;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("B36EB6E7-9D29-4AA8-92EF-843B87A289E8")
- IDeckLinkMemoryAllocator : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE AllocateBuffer(
- /* [in] */ unsigned int bufferSize,
- /* [out] */ void **allocatedBuffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(
- /* [in] */ void *buffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Commit( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Decommit( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkMemoryAllocatorVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkMemoryAllocator * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkMemoryAllocator * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkMemoryAllocator * This);
-
- HRESULT ( STDMETHODCALLTYPE *AllocateBuffer )(
- IDeckLinkMemoryAllocator * This,
- /* [in] */ unsigned int bufferSize,
- /* [out] */ void **allocatedBuffer);
-
- HRESULT ( STDMETHODCALLTYPE *ReleaseBuffer )(
- IDeckLinkMemoryAllocator * This,
- /* [in] */ void *buffer);
-
- HRESULT ( STDMETHODCALLTYPE *Commit )(
- IDeckLinkMemoryAllocator * This);
-
- HRESULT ( STDMETHODCALLTYPE *Decommit )(
- IDeckLinkMemoryAllocator * This);
-
- END_INTERFACE
- } IDeckLinkMemoryAllocatorVtbl;
-
- interface IDeckLinkMemoryAllocator
- {
- CONST_VTBL struct IDeckLinkMemoryAllocatorVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkMemoryAllocator_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkMemoryAllocator_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkMemoryAllocator_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkMemoryAllocator_AllocateBuffer(This,bufferSize,allocatedBuffer) \
- ( (This)->lpVtbl -> AllocateBuffer(This,bufferSize,allocatedBuffer) )
-
-#define IDeckLinkMemoryAllocator_ReleaseBuffer(This,buffer) \
- ( (This)->lpVtbl -> ReleaseBuffer(This,buffer) )
-
-#define IDeckLinkMemoryAllocator_Commit(This) \
- ( (This)->lpVtbl -> Commit(This) )
-
-#define IDeckLinkMemoryAllocator_Decommit(This) \
- ( (This)->lpVtbl -> Decommit(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkMemoryAllocator_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkAudioOutputCallback_INTERFACE_DEFINED__
-#define __IDeckLinkAudioOutputCallback_INTERFACE_DEFINED__
-
-/* interface IDeckLinkAudioOutputCallback */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkAudioOutputCallback;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("403C681B-7F46-4A12-B993-2BB127084EE6")
- IDeckLinkAudioOutputCallback : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE RenderAudioSamples(
- /* [in] */ BOOL preroll) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkAudioOutputCallbackVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkAudioOutputCallback * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkAudioOutputCallback * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkAudioOutputCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *RenderAudioSamples )(
- IDeckLinkAudioOutputCallback * This,
- /* [in] */ BOOL preroll);
-
- END_INTERFACE
- } IDeckLinkAudioOutputCallbackVtbl;
-
- interface IDeckLinkAudioOutputCallback
- {
- CONST_VTBL struct IDeckLinkAudioOutputCallbackVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkAudioOutputCallback_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkAudioOutputCallback_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkAudioOutputCallback_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkAudioOutputCallback_RenderAudioSamples(This,preroll) \
- ( (This)->lpVtbl -> RenderAudioSamples(This,preroll) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkAudioOutputCallback_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkIterator_INTERFACE_DEFINED__
-#define __IDeckLinkIterator_INTERFACE_DEFINED__
-
-/* interface IDeckLinkIterator */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkIterator;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("50FB36CD-3063-4B73-BDBB-958087F2D8BA")
- IDeckLinkIterator : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Next(
- /* [out] */ IDeckLink **deckLinkInstance) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkIteratorVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkIterator * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkIterator * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkIterator * This);
-
- HRESULT ( STDMETHODCALLTYPE *Next )(
- IDeckLinkIterator * This,
- /* [out] */ IDeckLink **deckLinkInstance);
-
- END_INTERFACE
- } IDeckLinkIteratorVtbl;
-
- interface IDeckLinkIterator
- {
- CONST_VTBL struct IDeckLinkIteratorVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkIterator_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkIterator_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkIterator_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkIterator_Next(This,deckLinkInstance) \
- ( (This)->lpVtbl -> Next(This,deckLinkInstance) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkIterator_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkAPIInformation_INTERFACE_DEFINED__
-#define __IDeckLinkAPIInformation_INTERFACE_DEFINED__
-
-/* interface IDeckLinkAPIInformation */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkAPIInformation;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("7BEA3C68-730D-4322-AF34-8A7152B532A4")
- IDeckLinkAPIInformation : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetFlag(
- /* [in] */ BMDDeckLinkAPIInformationID cfgID,
- /* [out] */ BOOL *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetInt(
- /* [in] */ BMDDeckLinkAPIInformationID cfgID,
- /* [out] */ LONGLONG *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFloat(
- /* [in] */ BMDDeckLinkAPIInformationID cfgID,
- /* [out] */ double *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetString(
- /* [in] */ BMDDeckLinkAPIInformationID cfgID,
- /* [out] */ BSTR *value) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkAPIInformationVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkAPIInformation * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkAPIInformation * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkAPIInformation * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetFlag )(
- IDeckLinkAPIInformation * This,
- /* [in] */ BMDDeckLinkAPIInformationID cfgID,
- /* [out] */ BOOL *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetInt )(
- IDeckLinkAPIInformation * This,
- /* [in] */ BMDDeckLinkAPIInformationID cfgID,
- /* [out] */ LONGLONG *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetFloat )(
- IDeckLinkAPIInformation * This,
- /* [in] */ BMDDeckLinkAPIInformationID cfgID,
- /* [out] */ double *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetString )(
- IDeckLinkAPIInformation * This,
- /* [in] */ BMDDeckLinkAPIInformationID cfgID,
- /* [out] */ BSTR *value);
-
- END_INTERFACE
- } IDeckLinkAPIInformationVtbl;
-
- interface IDeckLinkAPIInformation
- {
- CONST_VTBL struct IDeckLinkAPIInformationVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkAPIInformation_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkAPIInformation_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkAPIInformation_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkAPIInformation_GetFlag(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFlag(This,cfgID,value) )
-
-#define IDeckLinkAPIInformation_GetInt(This,cfgID,value) \
- ( (This)->lpVtbl -> GetInt(This,cfgID,value) )
-
-#define IDeckLinkAPIInformation_GetFloat(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFloat(This,cfgID,value) )
-
-#define IDeckLinkAPIInformation_GetString(This,cfgID,value) \
- ( (This)->lpVtbl -> GetString(This,cfgID,value) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkAPIInformation_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_INTERFACE_DEFINED__
-#define __IDeckLinkOutput_INTERFACE_DEFINED__
-
-/* interface IDeckLinkOutput */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkOutput;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("CC5C8A6E-3F2F-4B3A-87EA-FD78AF300564")
- IDeckLinkOutput : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoOutputFlags flags,
- /* [out] */ BMDDisplayModeSupport *result,
- /* [out] */ IDeckLinkDisplayMode **resultDisplayMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScreenPreviewCallback(
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoOutput(
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDVideoOutputFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoOutputFrameMemoryAllocator(
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateVideoFrame(
- /* [in] */ int width,
- /* [in] */ int height,
- /* [in] */ int rowBytes,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDFrameFlags flags,
- /* [out] */ IDeckLinkMutableVideoFrame **outFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateAncillaryData(
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [out] */ IDeckLinkVideoFrameAncillary **outBuffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisplayVideoFrameSync(
- /* [in] */ IDeckLinkVideoFrame *theFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleVideoFrame(
- /* [in] */ IDeckLinkVideoFrame *theFrame,
- /* [in] */ BMDTimeValue displayTime,
- /* [in] */ BMDTimeValue displayDuration,
- /* [in] */ BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScheduledFrameCompletionCallback(
- /* [in] */ IDeckLinkVideoOutputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedVideoFrameCount(
- /* [out] */ unsigned int *bufferedFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioOutput(
- /* [in] */ BMDAudioSampleRate sampleRate,
- /* [in] */ BMDAudioSampleType sampleType,
- /* [in] */ unsigned int channelCount,
- /* [in] */ BMDAudioOutputStreamType streamType) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE WriteAudioSamplesSync(
- /* [in] */ void *buffer,
- /* [in] */ unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE BeginAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EndAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleAudioSamples(
- /* [in] */ void *buffer,
- /* [in] */ unsigned int sampleFrameCount,
- /* [in] */ BMDTimeValue streamTime,
- /* [in] */ BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedAudioSampleFrameCount(
- /* [out] */ unsigned int *bufferedSampleFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FlushBufferedAudioSamples( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAudioCallback(
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartScheduledPlayback(
- /* [in] */ BMDTimeValue playbackStartTime,
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ double playbackSpeed) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopScheduledPlayback(
- /* [in] */ BMDTimeValue stopPlaybackAtTime,
- /* [out] */ BMDTimeValue *actualStopTime,
- /* [in] */ BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IsScheduledPlaybackRunning(
- /* [out] */ BOOL *active) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetScheduledStreamTime(
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *streamTime,
- /* [out] */ double *playbackSpeed) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetReferenceStatus(
- /* [out] */ BMDReferenceStatus *referenceStatus) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceClock(
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFrameCompletionReferenceTimestamp(
- /* [in] */ IDeckLinkVideoFrame *theFrame,
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *frameCompletionTimestamp) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkOutputVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkOutput * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkOutput * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkOutput * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkOutput * This,
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoOutputFlags flags,
- /* [out] */ BMDDisplayModeSupport *result,
- /* [out] */ IDeckLinkDisplayMode **resultDisplayMode);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkOutput * This,
- /* [out] */ IDeckLinkDisplayModeIterator **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *SetScreenPreviewCallback )(
- IDeckLinkOutput * This,
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoOutput )(
- IDeckLinkOutput * This,
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDVideoOutputFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoOutput )(
- IDeckLinkOutput * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoOutputFrameMemoryAllocator )(
- IDeckLinkOutput * This,
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator);
-
- HRESULT ( STDMETHODCALLTYPE *CreateVideoFrame )(
- IDeckLinkOutput * This,
- /* [in] */ int width,
- /* [in] */ int height,
- /* [in] */ int rowBytes,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDFrameFlags flags,
- /* [out] */ IDeckLinkMutableVideoFrame **outFrame);
-
- HRESULT ( STDMETHODCALLTYPE *CreateAncillaryData )(
- IDeckLinkOutput * This,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [out] */ IDeckLinkVideoFrameAncillary **outBuffer);
-
- HRESULT ( STDMETHODCALLTYPE *DisplayVideoFrameSync )(
- IDeckLinkOutput * This,
- /* [in] */ IDeckLinkVideoFrame *theFrame);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleVideoFrame )(
- IDeckLinkOutput * This,
- /* [in] */ IDeckLinkVideoFrame *theFrame,
- /* [in] */ BMDTimeValue displayTime,
- /* [in] */ BMDTimeValue displayDuration,
- /* [in] */ BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *SetScheduledFrameCompletionCallback )(
- IDeckLinkOutput * This,
- /* [in] */ IDeckLinkVideoOutputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedVideoFrameCount )(
- IDeckLinkOutput * This,
- /* [out] */ unsigned int *bufferedFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioOutput )(
- IDeckLinkOutput * This,
- /* [in] */ BMDAudioSampleRate sampleRate,
- /* [in] */ BMDAudioSampleType sampleType,
- /* [in] */ unsigned int channelCount,
- /* [in] */ BMDAudioOutputStreamType streamType);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioOutput )(
- IDeckLinkOutput * This);
-
- HRESULT ( STDMETHODCALLTYPE *WriteAudioSamplesSync )(
- IDeckLinkOutput * This,
- /* [in] */ void *buffer,
- /* [in] */ unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *BeginAudioPreroll )(
- IDeckLinkOutput * This);
-
- HRESULT ( STDMETHODCALLTYPE *EndAudioPreroll )(
- IDeckLinkOutput * This);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleAudioSamples )(
- IDeckLinkOutput * This,
- /* [in] */ void *buffer,
- /* [in] */ unsigned int sampleFrameCount,
- /* [in] */ BMDTimeValue streamTime,
- /* [in] */ BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedAudioSampleFrameCount )(
- IDeckLinkOutput * This,
- /* [out] */ unsigned int *bufferedSampleFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *FlushBufferedAudioSamples )(
- IDeckLinkOutput * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetAudioCallback )(
- IDeckLinkOutput * This,
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *StartScheduledPlayback )(
- IDeckLinkOutput * This,
- /* [in] */ BMDTimeValue playbackStartTime,
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ double playbackSpeed);
-
- HRESULT ( STDMETHODCALLTYPE *StopScheduledPlayback )(
- IDeckLinkOutput * This,
- /* [in] */ BMDTimeValue stopPlaybackAtTime,
- /* [out] */ BMDTimeValue *actualStopTime,
- /* [in] */ BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *IsScheduledPlaybackRunning )(
- IDeckLinkOutput * This,
- /* [out] */ BOOL *active);
-
- HRESULT ( STDMETHODCALLTYPE *GetScheduledStreamTime )(
- IDeckLinkOutput * This,
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *streamTime,
- /* [out] */ double *playbackSpeed);
-
- HRESULT ( STDMETHODCALLTYPE *GetReferenceStatus )(
- IDeckLinkOutput * This,
- /* [out] */ BMDReferenceStatus *referenceStatus);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceClock )(
- IDeckLinkOutput * This,
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame);
-
- HRESULT ( STDMETHODCALLTYPE *GetFrameCompletionReferenceTimestamp )(
- IDeckLinkOutput * This,
- /* [in] */ IDeckLinkVideoFrame *theFrame,
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *frameCompletionTimestamp);
-
- END_INTERFACE
- } IDeckLinkOutputVtbl;
-
- interface IDeckLinkOutput
- {
- CONST_VTBL struct IDeckLinkOutputVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkOutput_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkOutput_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkOutput_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkOutput_DoesSupportVideoMode(This,displayMode,pixelFormat,flags,result,resultDisplayMode) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,flags,result,resultDisplayMode) )
-
-#define IDeckLinkOutput_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkOutput_SetScreenPreviewCallback(This,previewCallback) \
- ( (This)->lpVtbl -> SetScreenPreviewCallback(This,previewCallback) )
-
-#define IDeckLinkOutput_EnableVideoOutput(This,displayMode,flags) \
- ( (This)->lpVtbl -> EnableVideoOutput(This,displayMode,flags) )
-
-#define IDeckLinkOutput_DisableVideoOutput(This) \
- ( (This)->lpVtbl -> DisableVideoOutput(This) )
-
-#define IDeckLinkOutput_SetVideoOutputFrameMemoryAllocator(This,theAllocator) \
- ( (This)->lpVtbl -> SetVideoOutputFrameMemoryAllocator(This,theAllocator) )
-
-#define IDeckLinkOutput_CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) \
- ( (This)->lpVtbl -> CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) )
-
-#define IDeckLinkOutput_CreateAncillaryData(This,pixelFormat,outBuffer) \
- ( (This)->lpVtbl -> CreateAncillaryData(This,pixelFormat,outBuffer) )
-
-#define IDeckLinkOutput_DisplayVideoFrameSync(This,theFrame) \
- ( (This)->lpVtbl -> DisplayVideoFrameSync(This,theFrame) )
-
-#define IDeckLinkOutput_ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) \
- ( (This)->lpVtbl -> ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) )
-
-#define IDeckLinkOutput_SetScheduledFrameCompletionCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetScheduledFrameCompletionCallback(This,theCallback) )
-
-#define IDeckLinkOutput_GetBufferedVideoFrameCount(This,bufferedFrameCount) \
- ( (This)->lpVtbl -> GetBufferedVideoFrameCount(This,bufferedFrameCount) )
-
-#define IDeckLinkOutput_EnableAudioOutput(This,sampleRate,sampleType,channelCount,streamType) \
- ( (This)->lpVtbl -> EnableAudioOutput(This,sampleRate,sampleType,channelCount,streamType) )
-
-#define IDeckLinkOutput_DisableAudioOutput(This) \
- ( (This)->lpVtbl -> DisableAudioOutput(This) )
-
-#define IDeckLinkOutput_WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) \
- ( (This)->lpVtbl -> WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) )
-
-#define IDeckLinkOutput_BeginAudioPreroll(This) \
- ( (This)->lpVtbl -> BeginAudioPreroll(This) )
-
-#define IDeckLinkOutput_EndAudioPreroll(This) \
- ( (This)->lpVtbl -> EndAudioPreroll(This) )
-
-#define IDeckLinkOutput_ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) \
- ( (This)->lpVtbl -> ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) )
-
-#define IDeckLinkOutput_GetBufferedAudioSampleFrameCount(This,bufferedSampleFrameCount) \
- ( (This)->lpVtbl -> GetBufferedAudioSampleFrameCount(This,bufferedSampleFrameCount) )
-
-#define IDeckLinkOutput_FlushBufferedAudioSamples(This) \
- ( (This)->lpVtbl -> FlushBufferedAudioSamples(This) )
-
-#define IDeckLinkOutput_SetAudioCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetAudioCallback(This,theCallback) )
-
-#define IDeckLinkOutput_StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) \
- ( (This)->lpVtbl -> StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) )
-
-#define IDeckLinkOutput_StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) \
- ( (This)->lpVtbl -> StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) )
-
-#define IDeckLinkOutput_IsScheduledPlaybackRunning(This,active) \
- ( (This)->lpVtbl -> IsScheduledPlaybackRunning(This,active) )
-
-#define IDeckLinkOutput_GetScheduledStreamTime(This,desiredTimeScale,streamTime,playbackSpeed) \
- ( (This)->lpVtbl -> GetScheduledStreamTime(This,desiredTimeScale,streamTime,playbackSpeed) )
-
-#define IDeckLinkOutput_GetReferenceStatus(This,referenceStatus) \
- ( (This)->lpVtbl -> GetReferenceStatus(This,referenceStatus) )
-
-#define IDeckLinkOutput_GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) \
- ( (This)->lpVtbl -> GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) )
-
-#define IDeckLinkOutput_GetFrameCompletionReferenceTimestamp(This,theFrame,desiredTimeScale,frameCompletionTimestamp) \
- ( (This)->lpVtbl -> GetFrameCompletionReferenceTimestamp(This,theFrame,desiredTimeScale,frameCompletionTimestamp) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkOutput_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_INTERFACE_DEFINED__
-#define __IDeckLinkInput_INTERFACE_DEFINED__
-
-/* interface IDeckLinkInput */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkInput;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("AF22762B-DFAC-4846-AA79-FA8883560995")
- IDeckLinkInput : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoInputFlags flags,
- /* [out] */ BMDDisplayModeSupport *result,
- /* [out] */ IDeckLinkDisplayMode **resultDisplayMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScreenPreviewCallback(
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoInput(
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoInputFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAvailableVideoFrameCount(
- /* [out] */ unsigned int *availableFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoInputFrameMemoryAllocator(
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioInput(
- /* [in] */ BMDAudioSampleRate sampleRate,
- /* [in] */ BMDAudioSampleType sampleType,
- /* [in] */ unsigned int channelCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAvailableAudioSampleFrameCount(
- /* [out] */ unsigned int *availableSampleFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE PauseStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FlushStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- /* [in] */ IDeckLinkInputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceClock(
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkInputVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkInput * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkInput * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkInput * This,
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoInputFlags flags,
- /* [out] */ BMDDisplayModeSupport *result,
- /* [out] */ IDeckLinkDisplayMode **resultDisplayMode);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkInput * This,
- /* [out] */ IDeckLinkDisplayModeIterator **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *SetScreenPreviewCallback )(
- IDeckLinkInput * This,
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoInput )(
- IDeckLinkInput * This,
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoInputFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoInput )(
- IDeckLinkInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetAvailableVideoFrameCount )(
- IDeckLinkInput * This,
- /* [out] */ unsigned int *availableFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoInputFrameMemoryAllocator )(
- IDeckLinkInput * This,
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioInput )(
- IDeckLinkInput * This,
- /* [in] */ BMDAudioSampleRate sampleRate,
- /* [in] */ BMDAudioSampleType sampleType,
- /* [in] */ unsigned int channelCount);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioInput )(
- IDeckLinkInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetAvailableAudioSampleFrameCount )(
- IDeckLinkInput * This,
- /* [out] */ unsigned int *availableSampleFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *StartStreams )(
- IDeckLinkInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *StopStreams )(
- IDeckLinkInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *PauseStreams )(
- IDeckLinkInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *FlushStreams )(
- IDeckLinkInput * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetCallback )(
- IDeckLinkInput * This,
- /* [in] */ IDeckLinkInputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceClock )(
- IDeckLinkInput * This,
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame);
-
- END_INTERFACE
- } IDeckLinkInputVtbl;
-
- interface IDeckLinkInput
- {
- CONST_VTBL struct IDeckLinkInputVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkInput_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkInput_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkInput_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkInput_DoesSupportVideoMode(This,displayMode,pixelFormat,flags,result,resultDisplayMode) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,flags,result,resultDisplayMode) )
-
-#define IDeckLinkInput_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkInput_SetScreenPreviewCallback(This,previewCallback) \
- ( (This)->lpVtbl -> SetScreenPreviewCallback(This,previewCallback) )
-
-#define IDeckLinkInput_EnableVideoInput(This,displayMode,pixelFormat,flags) \
- ( (This)->lpVtbl -> EnableVideoInput(This,displayMode,pixelFormat,flags) )
-
-#define IDeckLinkInput_DisableVideoInput(This) \
- ( (This)->lpVtbl -> DisableVideoInput(This) )
-
-#define IDeckLinkInput_GetAvailableVideoFrameCount(This,availableFrameCount) \
- ( (This)->lpVtbl -> GetAvailableVideoFrameCount(This,availableFrameCount) )
-
-#define IDeckLinkInput_SetVideoInputFrameMemoryAllocator(This,theAllocator) \
- ( (This)->lpVtbl -> SetVideoInputFrameMemoryAllocator(This,theAllocator) )
-
-#define IDeckLinkInput_EnableAudioInput(This,sampleRate,sampleType,channelCount) \
- ( (This)->lpVtbl -> EnableAudioInput(This,sampleRate,sampleType,channelCount) )
-
-#define IDeckLinkInput_DisableAudioInput(This) \
- ( (This)->lpVtbl -> DisableAudioInput(This) )
-
-#define IDeckLinkInput_GetAvailableAudioSampleFrameCount(This,availableSampleFrameCount) \
- ( (This)->lpVtbl -> GetAvailableAudioSampleFrameCount(This,availableSampleFrameCount) )
-
-#define IDeckLinkInput_StartStreams(This) \
- ( (This)->lpVtbl -> StartStreams(This) )
-
-#define IDeckLinkInput_StopStreams(This) \
- ( (This)->lpVtbl -> StopStreams(This) )
-
-#define IDeckLinkInput_PauseStreams(This) \
- ( (This)->lpVtbl -> PauseStreams(This) )
-
-#define IDeckLinkInput_FlushStreams(This) \
- ( (This)->lpVtbl -> FlushStreams(This) )
-
-#define IDeckLinkInput_SetCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetCallback(This,theCallback) )
-
-#define IDeckLinkInput_GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) \
- ( (This)->lpVtbl -> GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkInput_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrame_INTERFACE_DEFINED__
-#define __IDeckLinkVideoFrame_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoFrame */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoFrame;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("3F716FE0-F023-4111-BE5D-EF4414C05B17")
- IDeckLinkVideoFrame : public IUnknown
- {
- public:
- virtual long STDMETHODCALLTYPE GetWidth( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetHeight( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetRowBytes( void) = 0;
-
- virtual BMDPixelFormat STDMETHODCALLTYPE GetPixelFormat( void) = 0;
-
- virtual BMDFrameFlags STDMETHODCALLTYPE GetFlags( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBytes(
- /* [out] */ void **buffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecode(
- /* [in] */ BMDTimecodeFormat format,
- /* [out] */ IDeckLinkTimecode **timecode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAncillaryData(
- /* [out] */ IDeckLinkVideoFrameAncillary **ancillary) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoFrameVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoFrame * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoFrame * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoFrame * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkVideoFrame * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkVideoFrame * This);
-
- long ( STDMETHODCALLTYPE *GetRowBytes )(
- IDeckLinkVideoFrame * This);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkVideoFrame * This);
-
- BMDFrameFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkVideoFrame * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkVideoFrame * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkVideoFrame * This,
- /* [in] */ BMDTimecodeFormat format,
- /* [out] */ IDeckLinkTimecode **timecode);
-
- HRESULT ( STDMETHODCALLTYPE *GetAncillaryData )(
- IDeckLinkVideoFrame * This,
- /* [out] */ IDeckLinkVideoFrameAncillary **ancillary);
-
- END_INTERFACE
- } IDeckLinkVideoFrameVtbl;
-
- interface IDeckLinkVideoFrame
- {
- CONST_VTBL struct IDeckLinkVideoFrameVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoFrame_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoFrame_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoFrame_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoFrame_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkVideoFrame_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkVideoFrame_GetRowBytes(This) \
- ( (This)->lpVtbl -> GetRowBytes(This) )
-
-#define IDeckLinkVideoFrame_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkVideoFrame_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkVideoFrame_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IDeckLinkVideoFrame_GetTimecode(This,format,timecode) \
- ( (This)->lpVtbl -> GetTimecode(This,format,timecode) )
-
-#define IDeckLinkVideoFrame_GetAncillaryData(This,ancillary) \
- ( (This)->lpVtbl -> GetAncillaryData(This,ancillary) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoFrame_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkMutableVideoFrame_INTERFACE_DEFINED__
-#define __IDeckLinkMutableVideoFrame_INTERFACE_DEFINED__
-
-/* interface IDeckLinkMutableVideoFrame */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkMutableVideoFrame;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("69E2639F-40DA-4E19-B6F2-20ACE815C390")
- IDeckLinkMutableVideoFrame : public IDeckLinkVideoFrame
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE SetFlags(
- /* [in] */ BMDFrameFlags newFlags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetTimecode(
- /* [in] */ BMDTimecodeFormat format,
- /* [in] */ IDeckLinkTimecode *timecode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetTimecodeFromComponents(
- /* [in] */ BMDTimecodeFormat format,
- /* [in] */ unsigned char hours,
- /* [in] */ unsigned char minutes,
- /* [in] */ unsigned char seconds,
- /* [in] */ unsigned char frames,
- /* [in] */ BMDTimecodeFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAncillaryData(
- /* [in] */ IDeckLinkVideoFrameAncillary *ancillary) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetTimecodeUserBits(
- /* [in] */ BMDTimecodeFormat format,
- /* [in] */ BMDTimecodeUserBits userBits) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkMutableVideoFrameVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkMutableVideoFrame * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkMutableVideoFrame * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkMutableVideoFrame * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkMutableVideoFrame * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkMutableVideoFrame * This);
-
- long ( STDMETHODCALLTYPE *GetRowBytes )(
- IDeckLinkMutableVideoFrame * This);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkMutableVideoFrame * This);
-
- BMDFrameFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkMutableVideoFrame * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkMutableVideoFrame * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkMutableVideoFrame * This,
- /* [in] */ BMDTimecodeFormat format,
- /* [out] */ IDeckLinkTimecode **timecode);
-
- HRESULT ( STDMETHODCALLTYPE *GetAncillaryData )(
- IDeckLinkMutableVideoFrame * This,
- /* [out] */ IDeckLinkVideoFrameAncillary **ancillary);
-
- HRESULT ( STDMETHODCALLTYPE *SetFlags )(
- IDeckLinkMutableVideoFrame * This,
- /* [in] */ BMDFrameFlags newFlags);
-
- HRESULT ( STDMETHODCALLTYPE *SetTimecode )(
- IDeckLinkMutableVideoFrame * This,
- /* [in] */ BMDTimecodeFormat format,
- /* [in] */ IDeckLinkTimecode *timecode);
-
- HRESULT ( STDMETHODCALLTYPE *SetTimecodeFromComponents )(
- IDeckLinkMutableVideoFrame * This,
- /* [in] */ BMDTimecodeFormat format,
- /* [in] */ unsigned char hours,
- /* [in] */ unsigned char minutes,
- /* [in] */ unsigned char seconds,
- /* [in] */ unsigned char frames,
- /* [in] */ BMDTimecodeFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *SetAncillaryData )(
- IDeckLinkMutableVideoFrame * This,
- /* [in] */ IDeckLinkVideoFrameAncillary *ancillary);
-
- HRESULT ( STDMETHODCALLTYPE *SetTimecodeUserBits )(
- IDeckLinkMutableVideoFrame * This,
- /* [in] */ BMDTimecodeFormat format,
- /* [in] */ BMDTimecodeUserBits userBits);
-
- END_INTERFACE
- } IDeckLinkMutableVideoFrameVtbl;
-
- interface IDeckLinkMutableVideoFrame
- {
- CONST_VTBL struct IDeckLinkMutableVideoFrameVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkMutableVideoFrame_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkMutableVideoFrame_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkMutableVideoFrame_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkMutableVideoFrame_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkMutableVideoFrame_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkMutableVideoFrame_GetRowBytes(This) \
- ( (This)->lpVtbl -> GetRowBytes(This) )
-
-#define IDeckLinkMutableVideoFrame_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkMutableVideoFrame_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkMutableVideoFrame_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IDeckLinkMutableVideoFrame_GetTimecode(This,format,timecode) \
- ( (This)->lpVtbl -> GetTimecode(This,format,timecode) )
-
-#define IDeckLinkMutableVideoFrame_GetAncillaryData(This,ancillary) \
- ( (This)->lpVtbl -> GetAncillaryData(This,ancillary) )
-
-
-#define IDeckLinkMutableVideoFrame_SetFlags(This,newFlags) \
- ( (This)->lpVtbl -> SetFlags(This,newFlags) )
-
-#define IDeckLinkMutableVideoFrame_SetTimecode(This,format,timecode) \
- ( (This)->lpVtbl -> SetTimecode(This,format,timecode) )
-
-#define IDeckLinkMutableVideoFrame_SetTimecodeFromComponents(This,format,hours,minutes,seconds,frames,flags) \
- ( (This)->lpVtbl -> SetTimecodeFromComponents(This,format,hours,minutes,seconds,frames,flags) )
-
-#define IDeckLinkMutableVideoFrame_SetAncillaryData(This,ancillary) \
- ( (This)->lpVtbl -> SetAncillaryData(This,ancillary) )
-
-#define IDeckLinkMutableVideoFrame_SetTimecodeUserBits(This,format,userBits) \
- ( (This)->lpVtbl -> SetTimecodeUserBits(This,format,userBits) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkMutableVideoFrame_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrame3DExtensions_INTERFACE_DEFINED__
-#define __IDeckLinkVideoFrame3DExtensions_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoFrame3DExtensions */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoFrame3DExtensions;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("DA0F7E4A-EDC7-48A8-9CDD-2DB51C729CD7")
- IDeckLinkVideoFrame3DExtensions : public IUnknown
- {
- public:
- virtual BMDVideo3DPackingFormat STDMETHODCALLTYPE Get3DPackingFormat( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFrameForRightEye(
- /* [out] */ IDeckLinkVideoFrame **rightEyeFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoFrame3DExtensionsVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoFrame3DExtensions * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoFrame3DExtensions * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoFrame3DExtensions * This);
-
- BMDVideo3DPackingFormat ( STDMETHODCALLTYPE *Get3DPackingFormat )(
- IDeckLinkVideoFrame3DExtensions * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetFrameForRightEye )(
- IDeckLinkVideoFrame3DExtensions * This,
- /* [out] */ IDeckLinkVideoFrame **rightEyeFrame);
-
- END_INTERFACE
- } IDeckLinkVideoFrame3DExtensionsVtbl;
-
- interface IDeckLinkVideoFrame3DExtensions
- {
- CONST_VTBL struct IDeckLinkVideoFrame3DExtensionsVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoFrame3DExtensions_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoFrame3DExtensions_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoFrame3DExtensions_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoFrame3DExtensions_Get3DPackingFormat(This) \
- ( (This)->lpVtbl -> Get3DPackingFormat(This) )
-
-#define IDeckLinkVideoFrame3DExtensions_GetFrameForRightEye(This,rightEyeFrame) \
- ( (This)->lpVtbl -> GetFrameForRightEye(This,rightEyeFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoFrame3DExtensions_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoInputFrame_INTERFACE_DEFINED__
-#define __IDeckLinkVideoInputFrame_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoInputFrame */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoInputFrame;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("05CFE374-537C-4094-9A57-680525118F44")
- IDeckLinkVideoInputFrame : public IDeckLinkVideoFrame
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetStreamTime(
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration,
- /* [in] */ BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceTimestamp(
- /* [in] */ BMDTimeScale timeScale,
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoInputFrameVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoInputFrame * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoInputFrame * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoInputFrame * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkVideoInputFrame * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkVideoInputFrame * This);
-
- long ( STDMETHODCALLTYPE *GetRowBytes )(
- IDeckLinkVideoInputFrame * This);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkVideoInputFrame * This);
-
- BMDFrameFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkVideoInputFrame * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkVideoInputFrame * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkVideoInputFrame * This,
- /* [in] */ BMDTimecodeFormat format,
- /* [out] */ IDeckLinkTimecode **timecode);
-
- HRESULT ( STDMETHODCALLTYPE *GetAncillaryData )(
- IDeckLinkVideoInputFrame * This,
- /* [out] */ IDeckLinkVideoFrameAncillary **ancillary);
-
- HRESULT ( STDMETHODCALLTYPE *GetStreamTime )(
- IDeckLinkVideoInputFrame * This,
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration,
- /* [in] */ BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceTimestamp )(
- IDeckLinkVideoInputFrame * This,
- /* [in] */ BMDTimeScale timeScale,
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration);
-
- END_INTERFACE
- } IDeckLinkVideoInputFrameVtbl;
-
- interface IDeckLinkVideoInputFrame
- {
- CONST_VTBL struct IDeckLinkVideoInputFrameVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoInputFrame_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoInputFrame_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoInputFrame_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoInputFrame_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkVideoInputFrame_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkVideoInputFrame_GetRowBytes(This) \
- ( (This)->lpVtbl -> GetRowBytes(This) )
-
-#define IDeckLinkVideoInputFrame_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkVideoInputFrame_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkVideoInputFrame_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IDeckLinkVideoInputFrame_GetTimecode(This,format,timecode) \
- ( (This)->lpVtbl -> GetTimecode(This,format,timecode) )
-
-#define IDeckLinkVideoInputFrame_GetAncillaryData(This,ancillary) \
- ( (This)->lpVtbl -> GetAncillaryData(This,ancillary) )
-
-
-#define IDeckLinkVideoInputFrame_GetStreamTime(This,frameTime,frameDuration,timeScale) \
- ( (This)->lpVtbl -> GetStreamTime(This,frameTime,frameDuration,timeScale) )
-
-#define IDeckLinkVideoInputFrame_GetHardwareReferenceTimestamp(This,timeScale,frameTime,frameDuration) \
- ( (This)->lpVtbl -> GetHardwareReferenceTimestamp(This,timeScale,frameTime,frameDuration) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoInputFrame_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrameAncillary_INTERFACE_DEFINED__
-#define __IDeckLinkVideoFrameAncillary_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoFrameAncillary */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoFrameAncillary;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("732E723C-D1A4-4E29-9E8E-4A88797A0004")
- IDeckLinkVideoFrameAncillary : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetBufferForVerticalBlankingLine(
- /* [in] */ unsigned int lineNumber,
- /* [out] */ void **buffer) = 0;
-
- virtual BMDPixelFormat STDMETHODCALLTYPE GetPixelFormat( void) = 0;
-
- virtual BMDDisplayMode STDMETHODCALLTYPE GetDisplayMode( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoFrameAncillaryVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoFrameAncillary * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoFrameAncillary * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoFrameAncillary * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferForVerticalBlankingLine )(
- IDeckLinkVideoFrameAncillary * This,
- /* [in] */ unsigned int lineNumber,
- /* [out] */ void **buffer);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkVideoFrameAncillary * This);
-
- BMDDisplayMode ( STDMETHODCALLTYPE *GetDisplayMode )(
- IDeckLinkVideoFrameAncillary * This);
-
- END_INTERFACE
- } IDeckLinkVideoFrameAncillaryVtbl;
-
- interface IDeckLinkVideoFrameAncillary
- {
- CONST_VTBL struct IDeckLinkVideoFrameAncillaryVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoFrameAncillary_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoFrameAncillary_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoFrameAncillary_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoFrameAncillary_GetBufferForVerticalBlankingLine(This,lineNumber,buffer) \
- ( (This)->lpVtbl -> GetBufferForVerticalBlankingLine(This,lineNumber,buffer) )
-
-#define IDeckLinkVideoFrameAncillary_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkVideoFrameAncillary_GetDisplayMode(This) \
- ( (This)->lpVtbl -> GetDisplayMode(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoFrameAncillary_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkAudioInputPacket_INTERFACE_DEFINED__
-#define __IDeckLinkAudioInputPacket_INTERFACE_DEFINED__
-
-/* interface IDeckLinkAudioInputPacket */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkAudioInputPacket;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("E43D5870-2894-11DE-8C30-0800200C9A66")
- IDeckLinkAudioInputPacket : public IUnknown
- {
- public:
- virtual long STDMETHODCALLTYPE GetSampleFrameCount( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBytes(
- /* [out] */ void **buffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetPacketTime(
- /* [out] */ BMDTimeValue *packetTime,
- /* [in] */ BMDTimeScale timeScale) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkAudioInputPacketVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkAudioInputPacket * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkAudioInputPacket * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkAudioInputPacket * This);
-
- long ( STDMETHODCALLTYPE *GetSampleFrameCount )(
- IDeckLinkAudioInputPacket * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkAudioInputPacket * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetPacketTime )(
- IDeckLinkAudioInputPacket * This,
- /* [out] */ BMDTimeValue *packetTime,
- /* [in] */ BMDTimeScale timeScale);
-
- END_INTERFACE
- } IDeckLinkAudioInputPacketVtbl;
-
- interface IDeckLinkAudioInputPacket
- {
- CONST_VTBL struct IDeckLinkAudioInputPacketVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkAudioInputPacket_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkAudioInputPacket_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkAudioInputPacket_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkAudioInputPacket_GetSampleFrameCount(This) \
- ( (This)->lpVtbl -> GetSampleFrameCount(This) )
-
-#define IDeckLinkAudioInputPacket_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IDeckLinkAudioInputPacket_GetPacketTime(This,packetTime,timeScale) \
- ( (This)->lpVtbl -> GetPacketTime(This,packetTime,timeScale) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkAudioInputPacket_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkScreenPreviewCallback_INTERFACE_DEFINED__
-#define __IDeckLinkScreenPreviewCallback_INTERFACE_DEFINED__
-
-/* interface IDeckLinkScreenPreviewCallback */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkScreenPreviewCallback;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("B1D3F49A-85FE-4C5D-95C8-0B5D5DCCD438")
- IDeckLinkScreenPreviewCallback : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DrawFrame(
- /* [in] */ IDeckLinkVideoFrame *theFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkScreenPreviewCallbackVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkScreenPreviewCallback * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkScreenPreviewCallback * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkScreenPreviewCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *DrawFrame )(
- IDeckLinkScreenPreviewCallback * This,
- /* [in] */ IDeckLinkVideoFrame *theFrame);
-
- END_INTERFACE
- } IDeckLinkScreenPreviewCallbackVtbl;
-
- interface IDeckLinkScreenPreviewCallback
- {
- CONST_VTBL struct IDeckLinkScreenPreviewCallbackVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkScreenPreviewCallback_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkScreenPreviewCallback_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkScreenPreviewCallback_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkScreenPreviewCallback_DrawFrame(This,theFrame) \
- ( (This)->lpVtbl -> DrawFrame(This,theFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkScreenPreviewCallback_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkGLScreenPreviewHelper_INTERFACE_DEFINED__
-#define __IDeckLinkGLScreenPreviewHelper_INTERFACE_DEFINED__
-
-/* interface IDeckLinkGLScreenPreviewHelper */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkGLScreenPreviewHelper;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("504E2209-CAC7-4C1A-9FB4-C5BB6274D22F")
- IDeckLinkGLScreenPreviewHelper : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE InitializeGL( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE PaintGL( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetFrame(
- /* [in] */ IDeckLinkVideoFrame *theFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Set3DPreviewFormat(
- /* [in] */ BMD3DPreviewFormat previewFormat) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkGLScreenPreviewHelperVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkGLScreenPreviewHelper * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkGLScreenPreviewHelper * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkGLScreenPreviewHelper * This);
-
- HRESULT ( STDMETHODCALLTYPE *InitializeGL )(
- IDeckLinkGLScreenPreviewHelper * This);
-
- HRESULT ( STDMETHODCALLTYPE *PaintGL )(
- IDeckLinkGLScreenPreviewHelper * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetFrame )(
- IDeckLinkGLScreenPreviewHelper * This,
- /* [in] */ IDeckLinkVideoFrame *theFrame);
-
- HRESULT ( STDMETHODCALLTYPE *Set3DPreviewFormat )(
- IDeckLinkGLScreenPreviewHelper * This,
- /* [in] */ BMD3DPreviewFormat previewFormat);
-
- END_INTERFACE
- } IDeckLinkGLScreenPreviewHelperVtbl;
-
- interface IDeckLinkGLScreenPreviewHelper
- {
- CONST_VTBL struct IDeckLinkGLScreenPreviewHelperVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkGLScreenPreviewHelper_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkGLScreenPreviewHelper_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkGLScreenPreviewHelper_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkGLScreenPreviewHelper_InitializeGL(This) \
- ( (This)->lpVtbl -> InitializeGL(This) )
-
-#define IDeckLinkGLScreenPreviewHelper_PaintGL(This) \
- ( (This)->lpVtbl -> PaintGL(This) )
-
-#define IDeckLinkGLScreenPreviewHelper_SetFrame(This,theFrame) \
- ( (This)->lpVtbl -> SetFrame(This,theFrame) )
-
-#define IDeckLinkGLScreenPreviewHelper_Set3DPreviewFormat(This,previewFormat) \
- ( (This)->lpVtbl -> Set3DPreviewFormat(This,previewFormat) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkGLScreenPreviewHelper_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDX9ScreenPreviewHelper_INTERFACE_DEFINED__
-#define __IDeckLinkDX9ScreenPreviewHelper_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDX9ScreenPreviewHelper */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDX9ScreenPreviewHelper;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("2094B522-D1A1-40C0-9AC7-1C012218EF02")
- IDeckLinkDX9ScreenPreviewHelper : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Initialize(
- /* [in] */ void *device) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Render(
- /* [in] */ RECT *rc) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetFrame(
- /* [in] */ IDeckLinkVideoFrame *theFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Set3DPreviewFormat(
- /* [in] */ BMD3DPreviewFormat previewFormat) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDX9ScreenPreviewHelperVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDX9ScreenPreviewHelper * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDX9ScreenPreviewHelper * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDX9ScreenPreviewHelper * This);
-
- HRESULT ( STDMETHODCALLTYPE *Initialize )(
- IDeckLinkDX9ScreenPreviewHelper * This,
- /* [in] */ void *device);
-
- HRESULT ( STDMETHODCALLTYPE *Render )(
- IDeckLinkDX9ScreenPreviewHelper * This,
- /* [in] */ RECT *rc);
-
- HRESULT ( STDMETHODCALLTYPE *SetFrame )(
- IDeckLinkDX9ScreenPreviewHelper * This,
- /* [in] */ IDeckLinkVideoFrame *theFrame);
-
- HRESULT ( STDMETHODCALLTYPE *Set3DPreviewFormat )(
- IDeckLinkDX9ScreenPreviewHelper * This,
- /* [in] */ BMD3DPreviewFormat previewFormat);
-
- END_INTERFACE
- } IDeckLinkDX9ScreenPreviewHelperVtbl;
-
- interface IDeckLinkDX9ScreenPreviewHelper
- {
- CONST_VTBL struct IDeckLinkDX9ScreenPreviewHelperVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDX9ScreenPreviewHelper_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDX9ScreenPreviewHelper_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDX9ScreenPreviewHelper_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDX9ScreenPreviewHelper_Initialize(This,device) \
- ( (This)->lpVtbl -> Initialize(This,device) )
-
-#define IDeckLinkDX9ScreenPreviewHelper_Render(This,rc) \
- ( (This)->lpVtbl -> Render(This,rc) )
-
-#define IDeckLinkDX9ScreenPreviewHelper_SetFrame(This,theFrame) \
- ( (This)->lpVtbl -> SetFrame(This,theFrame) )
-
-#define IDeckLinkDX9ScreenPreviewHelper_Set3DPreviewFormat(This,previewFormat) \
- ( (This)->lpVtbl -> Set3DPreviewFormat(This,previewFormat) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDX9ScreenPreviewHelper_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkNotificationCallback_INTERFACE_DEFINED__
-#define __IDeckLinkNotificationCallback_INTERFACE_DEFINED__
-
-/* interface IDeckLinkNotificationCallback */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkNotificationCallback;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("b002a1ec-070d-4288-8289-bd5d36e5ff0d")
- IDeckLinkNotificationCallback : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Notify(
- /* [in] */ BMDNotifications topic,
- /* [in] */ ULONGLONG param1,
- /* [in] */ ULONGLONG param2) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkNotificationCallbackVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkNotificationCallback * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkNotificationCallback * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkNotificationCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *Notify )(
- IDeckLinkNotificationCallback * This,
- /* [in] */ BMDNotifications topic,
- /* [in] */ ULONGLONG param1,
- /* [in] */ ULONGLONG param2);
-
- END_INTERFACE
- } IDeckLinkNotificationCallbackVtbl;
-
- interface IDeckLinkNotificationCallback
- {
- CONST_VTBL struct IDeckLinkNotificationCallbackVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkNotificationCallback_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkNotificationCallback_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkNotificationCallback_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkNotificationCallback_Notify(This,topic,param1,param2) \
- ( (This)->lpVtbl -> Notify(This,topic,param1,param2) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkNotificationCallback_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkNotification_INTERFACE_DEFINED__
-#define __IDeckLinkNotification_INTERFACE_DEFINED__
-
-/* interface IDeckLinkNotification */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkNotification;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("0a1fb207-e215-441b-9b19-6fa1575946c5")
- IDeckLinkNotification : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Subscribe(
- /* [in] */ BMDNotifications topic,
- /* [in] */ IDeckLinkNotificationCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Unsubscribe(
- /* [in] */ BMDNotifications topic,
- /* [in] */ IDeckLinkNotificationCallback *theCallback) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkNotificationVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkNotification * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkNotification * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkNotification * This);
-
- HRESULT ( STDMETHODCALLTYPE *Subscribe )(
- IDeckLinkNotification * This,
- /* [in] */ BMDNotifications topic,
- /* [in] */ IDeckLinkNotificationCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *Unsubscribe )(
- IDeckLinkNotification * This,
- /* [in] */ BMDNotifications topic,
- /* [in] */ IDeckLinkNotificationCallback *theCallback);
-
- END_INTERFACE
- } IDeckLinkNotificationVtbl;
-
- interface IDeckLinkNotification
- {
- CONST_VTBL struct IDeckLinkNotificationVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkNotification_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkNotification_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkNotification_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkNotification_Subscribe(This,topic,theCallback) \
- ( (This)->lpVtbl -> Subscribe(This,topic,theCallback) )
-
-#define IDeckLinkNotification_Unsubscribe(This,topic,theCallback) \
- ( (This)->lpVtbl -> Unsubscribe(This,topic,theCallback) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkNotification_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkAttributes_INTERFACE_DEFINED__
-#define __IDeckLinkAttributes_INTERFACE_DEFINED__
-
-/* interface IDeckLinkAttributes */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkAttributes;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("ABC11843-D966-44CB-96E2-A1CB5D3135C4")
- IDeckLinkAttributes : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetFlag(
- /* [in] */ BMDDeckLinkAttributeID cfgID,
- /* [out] */ BOOL *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetInt(
- /* [in] */ BMDDeckLinkAttributeID cfgID,
- /* [out] */ LONGLONG *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFloat(
- /* [in] */ BMDDeckLinkAttributeID cfgID,
- /* [out] */ double *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetString(
- /* [in] */ BMDDeckLinkAttributeID cfgID,
- /* [out] */ BSTR *value) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkAttributesVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkAttributes * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkAttributes * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkAttributes * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetFlag )(
- IDeckLinkAttributes * This,
- /* [in] */ BMDDeckLinkAttributeID cfgID,
- /* [out] */ BOOL *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetInt )(
- IDeckLinkAttributes * This,
- /* [in] */ BMDDeckLinkAttributeID cfgID,
- /* [out] */ LONGLONG *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetFloat )(
- IDeckLinkAttributes * This,
- /* [in] */ BMDDeckLinkAttributeID cfgID,
- /* [out] */ double *value);
-
- HRESULT ( STDMETHODCALLTYPE *GetString )(
- IDeckLinkAttributes * This,
- /* [in] */ BMDDeckLinkAttributeID cfgID,
- /* [out] */ BSTR *value);
-
- END_INTERFACE
- } IDeckLinkAttributesVtbl;
-
- interface IDeckLinkAttributes
- {
- CONST_VTBL struct IDeckLinkAttributesVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkAttributes_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkAttributes_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkAttributes_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkAttributes_GetFlag(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFlag(This,cfgID,value) )
-
-#define IDeckLinkAttributes_GetInt(This,cfgID,value) \
- ( (This)->lpVtbl -> GetInt(This,cfgID,value) )
-
-#define IDeckLinkAttributes_GetFloat(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFloat(This,cfgID,value) )
-
-#define IDeckLinkAttributes_GetString(This,cfgID,value) \
- ( (This)->lpVtbl -> GetString(This,cfgID,value) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkAttributes_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkKeyer_INTERFACE_DEFINED__
-#define __IDeckLinkKeyer_INTERFACE_DEFINED__
-
-/* interface IDeckLinkKeyer */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkKeyer;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("89AFCAF5-65F8-421E-98F7-96FE5F5BFBA3")
- IDeckLinkKeyer : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Enable(
- /* [in] */ BOOL isExternal) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetLevel(
- /* [in] */ unsigned char level) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE RampUp(
- /* [in] */ unsigned int numberOfFrames) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE RampDown(
- /* [in] */ unsigned int numberOfFrames) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Disable( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkKeyerVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkKeyer * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkKeyer * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkKeyer * This);
-
- HRESULT ( STDMETHODCALLTYPE *Enable )(
- IDeckLinkKeyer * This,
- /* [in] */ BOOL isExternal);
-
- HRESULT ( STDMETHODCALLTYPE *SetLevel )(
- IDeckLinkKeyer * This,
- /* [in] */ unsigned char level);
-
- HRESULT ( STDMETHODCALLTYPE *RampUp )(
- IDeckLinkKeyer * This,
- /* [in] */ unsigned int numberOfFrames);
-
- HRESULT ( STDMETHODCALLTYPE *RampDown )(
- IDeckLinkKeyer * This,
- /* [in] */ unsigned int numberOfFrames);
-
- HRESULT ( STDMETHODCALLTYPE *Disable )(
- IDeckLinkKeyer * This);
-
- END_INTERFACE
- } IDeckLinkKeyerVtbl;
-
- interface IDeckLinkKeyer
- {
- CONST_VTBL struct IDeckLinkKeyerVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkKeyer_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkKeyer_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkKeyer_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkKeyer_Enable(This,isExternal) \
- ( (This)->lpVtbl -> Enable(This,isExternal) )
-
-#define IDeckLinkKeyer_SetLevel(This,level) \
- ( (This)->lpVtbl -> SetLevel(This,level) )
-
-#define IDeckLinkKeyer_RampUp(This,numberOfFrames) \
- ( (This)->lpVtbl -> RampUp(This,numberOfFrames) )
-
-#define IDeckLinkKeyer_RampDown(This,numberOfFrames) \
- ( (This)->lpVtbl -> RampDown(This,numberOfFrames) )
-
-#define IDeckLinkKeyer_Disable(This) \
- ( (This)->lpVtbl -> Disable(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkKeyer_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoConversion_INTERFACE_DEFINED__
-#define __IDeckLinkVideoConversion_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoConversion */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoConversion;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("3BBCB8A2-DA2C-42D9-B5D8-88083644E99A")
- IDeckLinkVideoConversion : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE ConvertFrame(
- /* [in] */ IDeckLinkVideoFrame *srcFrame,
- /* [in] */ IDeckLinkVideoFrame *dstFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoConversionVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoConversion * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoConversion * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoConversion * This);
-
- HRESULT ( STDMETHODCALLTYPE *ConvertFrame )(
- IDeckLinkVideoConversion * This,
- /* [in] */ IDeckLinkVideoFrame *srcFrame,
- /* [in] */ IDeckLinkVideoFrame *dstFrame);
-
- END_INTERFACE
- } IDeckLinkVideoConversionVtbl;
-
- interface IDeckLinkVideoConversion
- {
- CONST_VTBL struct IDeckLinkVideoConversionVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoConversion_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoConversion_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoConversion_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoConversion_ConvertFrame(This,srcFrame,dstFrame) \
- ( (This)->lpVtbl -> ConvertFrame(This,srcFrame,dstFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoConversion_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeviceNotificationCallback_INTERFACE_DEFINED__
-#define __IDeckLinkDeviceNotificationCallback_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDeviceNotificationCallback */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDeviceNotificationCallback;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("4997053B-0ADF-4CC8-AC70-7A50C4BE728F")
- IDeckLinkDeviceNotificationCallback : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DeckLinkDeviceArrived(
- /* [in] */ IDeckLink *deckLinkDevice) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DeckLinkDeviceRemoved(
- /* [in] */ IDeckLink *deckLinkDevice) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDeviceNotificationCallbackVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDeviceNotificationCallback * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDeviceNotificationCallback * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDeviceNotificationCallback * This);
-
- HRESULT ( STDMETHODCALLTYPE *DeckLinkDeviceArrived )(
- IDeckLinkDeviceNotificationCallback * This,
- /* [in] */ IDeckLink *deckLinkDevice);
-
- HRESULT ( STDMETHODCALLTYPE *DeckLinkDeviceRemoved )(
- IDeckLinkDeviceNotificationCallback * This,
- /* [in] */ IDeckLink *deckLinkDevice);
-
- END_INTERFACE
- } IDeckLinkDeviceNotificationCallbackVtbl;
-
- interface IDeckLinkDeviceNotificationCallback
- {
- CONST_VTBL struct IDeckLinkDeviceNotificationCallbackVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDeviceNotificationCallback_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDeviceNotificationCallback_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDeviceNotificationCallback_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDeviceNotificationCallback_DeckLinkDeviceArrived(This,deckLinkDevice) \
- ( (This)->lpVtbl -> DeckLinkDeviceArrived(This,deckLinkDevice) )
-
-#define IDeckLinkDeviceNotificationCallback_DeckLinkDeviceRemoved(This,deckLinkDevice) \
- ( (This)->lpVtbl -> DeckLinkDeviceRemoved(This,deckLinkDevice) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDeviceNotificationCallback_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDiscovery_INTERFACE_DEFINED__
-#define __IDeckLinkDiscovery_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDiscovery */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDiscovery;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("CDBF631C-BC76-45FA-B44D-C55059BC6101")
- IDeckLinkDiscovery : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE InstallDeviceNotifications(
- /* [in] */ IDeckLinkDeviceNotificationCallback *deviceNotificationCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE UninstallDeviceNotifications( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDiscoveryVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDiscovery * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDiscovery * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDiscovery * This);
-
- HRESULT ( STDMETHODCALLTYPE *InstallDeviceNotifications )(
- IDeckLinkDiscovery * This,
- /* [in] */ IDeckLinkDeviceNotificationCallback *deviceNotificationCallback);
-
- HRESULT ( STDMETHODCALLTYPE *UninstallDeviceNotifications )(
- IDeckLinkDiscovery * This);
-
- END_INTERFACE
- } IDeckLinkDiscoveryVtbl;
-
- interface IDeckLinkDiscovery
- {
- CONST_VTBL struct IDeckLinkDiscoveryVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDiscovery_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDiscovery_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDiscovery_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDiscovery_InstallDeviceNotifications(This,deviceNotificationCallback) \
- ( (This)->lpVtbl -> InstallDeviceNotifications(This,deviceNotificationCallback) )
-
-#define IDeckLinkDiscovery_UninstallDeviceNotifications(This) \
- ( (This)->lpVtbl -> UninstallDeviceNotifications(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDiscovery_INTERFACE_DEFINED__ */
-
-
-EXTERN_C const CLSID CLSID_CDeckLinkIterator;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("1F2E109A-8F4F-49E4-9203-135595CB6FA5")
-CDeckLinkIterator;
-#endif
-
-EXTERN_C const CLSID CLSID_CDeckLinkAPIInformation;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("263CA19F-ED09-482E-9F9D-84005783A237")
-CDeckLinkAPIInformation;
-#endif
-
-EXTERN_C const CLSID CLSID_CDeckLinkGLScreenPreviewHelper;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("F63E77C7-B655-4A4A-9AD0-3CA85D394343")
-CDeckLinkGLScreenPreviewHelper;
-#endif
-
-EXTERN_C const CLSID CLSID_CDeckLinkDX9ScreenPreviewHelper;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("CC010023-E01D-4525-9D59-80C8AB3DC7A0")
-CDeckLinkDX9ScreenPreviewHelper;
-#endif
-
-EXTERN_C const CLSID CLSID_CDeckLinkVideoConversion;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("7DBBBB11-5B7B-467D-AEA4-CEA468FD368C")
-CDeckLinkVideoConversion;
-#endif
-
-EXTERN_C const CLSID CLSID_CDeckLinkDiscovery;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("1073A05C-D885-47E9-B3C6-129B3F9F648B")
-CDeckLinkDiscovery;
-#endif
-
-#ifndef __IDeckLinkConfiguration_v10_2_INTERFACE_DEFINED__
-#define __IDeckLinkConfiguration_v10_2_INTERFACE_DEFINED__
-
-/* interface IDeckLinkConfiguration_v10_2 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkConfiguration_v10_2;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("C679A35B-610C-4D09-B748-1D0478100FC0")
- IDeckLinkConfiguration_v10_2 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE SetFlag(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ BOOL value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFlag(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ BOOL *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetInt(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ LONGLONG value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetInt(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ LONGLONG *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetFloat(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ double value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFloat(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ double *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetString(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ BSTR value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetString(
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ BSTR *value) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE WriteConfigurationToPreferences( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkConfiguration_v10_2Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkConfiguration_v10_2 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkConfiguration_v10_2 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkConfiguration_v10_2 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetFlag )(
- IDeckLinkConfiguration_v10_2 * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ BOOL value);
-
- HRESULT ( STDMETHODCALLTYPE *GetFlag )(
- IDeckLinkConfiguration_v10_2 * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ BOOL *value);
-
- HRESULT ( STDMETHODCALLTYPE *SetInt )(
- IDeckLinkConfiguration_v10_2 * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ LONGLONG value);
-
- HRESULT ( STDMETHODCALLTYPE *GetInt )(
- IDeckLinkConfiguration_v10_2 * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ LONGLONG *value);
-
- HRESULT ( STDMETHODCALLTYPE *SetFloat )(
- IDeckLinkConfiguration_v10_2 * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ double value);
-
- HRESULT ( STDMETHODCALLTYPE *GetFloat )(
- IDeckLinkConfiguration_v10_2 * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ double *value);
-
- HRESULT ( STDMETHODCALLTYPE *SetString )(
- IDeckLinkConfiguration_v10_2 * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [in] */ BSTR value);
-
- HRESULT ( STDMETHODCALLTYPE *GetString )(
- IDeckLinkConfiguration_v10_2 * This,
- /* [in] */ BMDDeckLinkConfigurationID cfgID,
- /* [out] */ BSTR *value);
-
- HRESULT ( STDMETHODCALLTYPE *WriteConfigurationToPreferences )(
- IDeckLinkConfiguration_v10_2 * This);
-
- END_INTERFACE
- } IDeckLinkConfiguration_v10_2Vtbl;
-
- interface IDeckLinkConfiguration_v10_2
- {
- CONST_VTBL struct IDeckLinkConfiguration_v10_2Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkConfiguration_v10_2_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkConfiguration_v10_2_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkConfiguration_v10_2_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkConfiguration_v10_2_SetFlag(This,cfgID,value) \
- ( (This)->lpVtbl -> SetFlag(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_v10_2_GetFlag(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFlag(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_v10_2_SetInt(This,cfgID,value) \
- ( (This)->lpVtbl -> SetInt(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_v10_2_GetInt(This,cfgID,value) \
- ( (This)->lpVtbl -> GetInt(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_v10_2_SetFloat(This,cfgID,value) \
- ( (This)->lpVtbl -> SetFloat(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_v10_2_GetFloat(This,cfgID,value) \
- ( (This)->lpVtbl -> GetFloat(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_v10_2_SetString(This,cfgID,value) \
- ( (This)->lpVtbl -> SetString(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_v10_2_GetString(This,cfgID,value) \
- ( (This)->lpVtbl -> GetString(This,cfgID,value) )
-
-#define IDeckLinkConfiguration_v10_2_WriteConfigurationToPreferences(This) \
- ( (This)->lpVtbl -> WriteConfigurationToPreferences(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkConfiguration_v10_2_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_v9_9_INTERFACE_DEFINED__
-#define __IDeckLinkOutput_v9_9_INTERFACE_DEFINED__
-
-/* interface IDeckLinkOutput_v9_9 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkOutput_v9_9;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("A3EF0963-0862-44ED-92A9-EE89ABF431C7")
- IDeckLinkOutput_v9_9 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoOutputFlags flags,
- /* [out] */ BMDDisplayModeSupport *result,
- /* [out] */ IDeckLinkDisplayMode **resultDisplayMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScreenPreviewCallback(
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoOutput(
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDVideoOutputFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoOutputFrameMemoryAllocator(
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateVideoFrame(
- /* [in] */ int width,
- /* [in] */ int height,
- /* [in] */ int rowBytes,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDFrameFlags flags,
- /* [out] */ IDeckLinkMutableVideoFrame **outFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateAncillaryData(
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [out] */ IDeckLinkVideoFrameAncillary **outBuffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisplayVideoFrameSync(
- /* [in] */ IDeckLinkVideoFrame *theFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleVideoFrame(
- /* [in] */ IDeckLinkVideoFrame *theFrame,
- /* [in] */ BMDTimeValue displayTime,
- /* [in] */ BMDTimeValue displayDuration,
- /* [in] */ BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScheduledFrameCompletionCallback(
- /* [in] */ IDeckLinkVideoOutputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedVideoFrameCount(
- /* [out] */ unsigned int *bufferedFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioOutput(
- /* [in] */ BMDAudioSampleRate sampleRate,
- /* [in] */ BMDAudioSampleType sampleType,
- /* [in] */ unsigned int channelCount,
- /* [in] */ BMDAudioOutputStreamType streamType) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE WriteAudioSamplesSync(
- /* [in] */ void *buffer,
- /* [in] */ unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE BeginAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EndAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleAudioSamples(
- /* [in] */ void *buffer,
- /* [in] */ unsigned int sampleFrameCount,
- /* [in] */ BMDTimeValue streamTime,
- /* [in] */ BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedAudioSampleFrameCount(
- /* [out] */ unsigned int *bufferedSampleFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FlushBufferedAudioSamples( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAudioCallback(
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartScheduledPlayback(
- /* [in] */ BMDTimeValue playbackStartTime,
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ double playbackSpeed) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopScheduledPlayback(
- /* [in] */ BMDTimeValue stopPlaybackAtTime,
- /* [out] */ BMDTimeValue *actualStopTime,
- /* [in] */ BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IsScheduledPlaybackRunning(
- /* [out] */ BOOL *active) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetScheduledStreamTime(
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *streamTime,
- /* [out] */ double *playbackSpeed) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetReferenceStatus(
- /* [out] */ BMDReferenceStatus *referenceStatus) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceClock(
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkOutput_v9_9Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkOutput_v9_9 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkOutput_v9_9 * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoOutputFlags flags,
- /* [out] */ BMDDisplayModeSupport *result,
- /* [out] */ IDeckLinkDisplayMode **resultDisplayMode);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkOutput_v9_9 * This,
- /* [out] */ IDeckLinkDisplayModeIterator **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *SetScreenPreviewCallback )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoOutput )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDVideoOutputFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoOutput )(
- IDeckLinkOutput_v9_9 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoOutputFrameMemoryAllocator )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator);
-
- HRESULT ( STDMETHODCALLTYPE *CreateVideoFrame )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ int width,
- /* [in] */ int height,
- /* [in] */ int rowBytes,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDFrameFlags flags,
- /* [out] */ IDeckLinkMutableVideoFrame **outFrame);
-
- HRESULT ( STDMETHODCALLTYPE *CreateAncillaryData )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [out] */ IDeckLinkVideoFrameAncillary **outBuffer);
-
- HRESULT ( STDMETHODCALLTYPE *DisplayVideoFrameSync )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ IDeckLinkVideoFrame *theFrame);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleVideoFrame )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ IDeckLinkVideoFrame *theFrame,
- /* [in] */ BMDTimeValue displayTime,
- /* [in] */ BMDTimeValue displayDuration,
- /* [in] */ BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *SetScheduledFrameCompletionCallback )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ IDeckLinkVideoOutputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedVideoFrameCount )(
- IDeckLinkOutput_v9_9 * This,
- /* [out] */ unsigned int *bufferedFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioOutput )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ BMDAudioSampleRate sampleRate,
- /* [in] */ BMDAudioSampleType sampleType,
- /* [in] */ unsigned int channelCount,
- /* [in] */ BMDAudioOutputStreamType streamType);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioOutput )(
- IDeckLinkOutput_v9_9 * This);
-
- HRESULT ( STDMETHODCALLTYPE *WriteAudioSamplesSync )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ void *buffer,
- /* [in] */ unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *BeginAudioPreroll )(
- IDeckLinkOutput_v9_9 * This);
-
- HRESULT ( STDMETHODCALLTYPE *EndAudioPreroll )(
- IDeckLinkOutput_v9_9 * This);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleAudioSamples )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ void *buffer,
- /* [in] */ unsigned int sampleFrameCount,
- /* [in] */ BMDTimeValue streamTime,
- /* [in] */ BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedAudioSampleFrameCount )(
- IDeckLinkOutput_v9_9 * This,
- /* [out] */ unsigned int *bufferedSampleFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *FlushBufferedAudioSamples )(
- IDeckLinkOutput_v9_9 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetAudioCallback )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *StartScheduledPlayback )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ BMDTimeValue playbackStartTime,
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ double playbackSpeed);
-
- HRESULT ( STDMETHODCALLTYPE *StopScheduledPlayback )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ BMDTimeValue stopPlaybackAtTime,
- /* [out] */ BMDTimeValue *actualStopTime,
- /* [in] */ BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *IsScheduledPlaybackRunning )(
- IDeckLinkOutput_v9_9 * This,
- /* [out] */ BOOL *active);
-
- HRESULT ( STDMETHODCALLTYPE *GetScheduledStreamTime )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *streamTime,
- /* [out] */ double *playbackSpeed);
-
- HRESULT ( STDMETHODCALLTYPE *GetReferenceStatus )(
- IDeckLinkOutput_v9_9 * This,
- /* [out] */ BMDReferenceStatus *referenceStatus);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceClock )(
- IDeckLinkOutput_v9_9 * This,
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame);
-
- END_INTERFACE
- } IDeckLinkOutput_v9_9Vtbl;
-
- interface IDeckLinkOutput_v9_9
- {
- CONST_VTBL struct IDeckLinkOutput_v9_9Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkOutput_v9_9_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkOutput_v9_9_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkOutput_v9_9_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkOutput_v9_9_DoesSupportVideoMode(This,displayMode,pixelFormat,flags,result,resultDisplayMode) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,flags,result,resultDisplayMode) )
-
-#define IDeckLinkOutput_v9_9_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkOutput_v9_9_SetScreenPreviewCallback(This,previewCallback) \
- ( (This)->lpVtbl -> SetScreenPreviewCallback(This,previewCallback) )
-
-#define IDeckLinkOutput_v9_9_EnableVideoOutput(This,displayMode,flags) \
- ( (This)->lpVtbl -> EnableVideoOutput(This,displayMode,flags) )
-
-#define IDeckLinkOutput_v9_9_DisableVideoOutput(This) \
- ( (This)->lpVtbl -> DisableVideoOutput(This) )
-
-#define IDeckLinkOutput_v9_9_SetVideoOutputFrameMemoryAllocator(This,theAllocator) \
- ( (This)->lpVtbl -> SetVideoOutputFrameMemoryAllocator(This,theAllocator) )
-
-#define IDeckLinkOutput_v9_9_CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) \
- ( (This)->lpVtbl -> CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) )
-
-#define IDeckLinkOutput_v9_9_CreateAncillaryData(This,pixelFormat,outBuffer) \
- ( (This)->lpVtbl -> CreateAncillaryData(This,pixelFormat,outBuffer) )
-
-#define IDeckLinkOutput_v9_9_DisplayVideoFrameSync(This,theFrame) \
- ( (This)->lpVtbl -> DisplayVideoFrameSync(This,theFrame) )
-
-#define IDeckLinkOutput_v9_9_ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) \
- ( (This)->lpVtbl -> ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) )
-
-#define IDeckLinkOutput_v9_9_SetScheduledFrameCompletionCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetScheduledFrameCompletionCallback(This,theCallback) )
-
-#define IDeckLinkOutput_v9_9_GetBufferedVideoFrameCount(This,bufferedFrameCount) \
- ( (This)->lpVtbl -> GetBufferedVideoFrameCount(This,bufferedFrameCount) )
-
-#define IDeckLinkOutput_v9_9_EnableAudioOutput(This,sampleRate,sampleType,channelCount,streamType) \
- ( (This)->lpVtbl -> EnableAudioOutput(This,sampleRate,sampleType,channelCount,streamType) )
-
-#define IDeckLinkOutput_v9_9_DisableAudioOutput(This) \
- ( (This)->lpVtbl -> DisableAudioOutput(This) )
-
-#define IDeckLinkOutput_v9_9_WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) \
- ( (This)->lpVtbl -> WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) )
-
-#define IDeckLinkOutput_v9_9_BeginAudioPreroll(This) \
- ( (This)->lpVtbl -> BeginAudioPreroll(This) )
-
-#define IDeckLinkOutput_v9_9_EndAudioPreroll(This) \
- ( (This)->lpVtbl -> EndAudioPreroll(This) )
-
-#define IDeckLinkOutput_v9_9_ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) \
- ( (This)->lpVtbl -> ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) )
-
-#define IDeckLinkOutput_v9_9_GetBufferedAudioSampleFrameCount(This,bufferedSampleFrameCount) \
- ( (This)->lpVtbl -> GetBufferedAudioSampleFrameCount(This,bufferedSampleFrameCount) )
-
-#define IDeckLinkOutput_v9_9_FlushBufferedAudioSamples(This) \
- ( (This)->lpVtbl -> FlushBufferedAudioSamples(This) )
-
-#define IDeckLinkOutput_v9_9_SetAudioCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetAudioCallback(This,theCallback) )
-
-#define IDeckLinkOutput_v9_9_StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) \
- ( (This)->lpVtbl -> StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) )
-
-#define IDeckLinkOutput_v9_9_StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) \
- ( (This)->lpVtbl -> StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) )
-
-#define IDeckLinkOutput_v9_9_IsScheduledPlaybackRunning(This,active) \
- ( (This)->lpVtbl -> IsScheduledPlaybackRunning(This,active) )
-
-#define IDeckLinkOutput_v9_9_GetScheduledStreamTime(This,desiredTimeScale,streamTime,playbackSpeed) \
- ( (This)->lpVtbl -> GetScheduledStreamTime(This,desiredTimeScale,streamTime,playbackSpeed) )
-
-#define IDeckLinkOutput_v9_9_GetReferenceStatus(This,referenceStatus) \
- ( (This)->lpVtbl -> GetReferenceStatus(This,referenceStatus) )
-
-#define IDeckLinkOutput_v9_9_GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) \
- ( (This)->lpVtbl -> GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkOutput_v9_9_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_v9_2_INTERFACE_DEFINED__
-#define __IDeckLinkInput_v9_2_INTERFACE_DEFINED__
-
-/* interface IDeckLinkInput_v9_2 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkInput_v9_2;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("6D40EF78-28B9-4E21-990D-95BB7750A04F")
- IDeckLinkInput_v9_2 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoInputFlags flags,
- /* [out] */ BMDDisplayModeSupport *result,
- /* [out] */ IDeckLinkDisplayMode **resultDisplayMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScreenPreviewCallback(
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoInput(
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoInputFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAvailableVideoFrameCount(
- /* [out] */ unsigned int *availableFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioInput(
- /* [in] */ BMDAudioSampleRate sampleRate,
- /* [in] */ BMDAudioSampleType sampleType,
- /* [in] */ unsigned int channelCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAvailableAudioSampleFrameCount(
- /* [out] */ unsigned int *availableSampleFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE PauseStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FlushStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- /* [in] */ IDeckLinkInputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceClock(
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkInput_v9_2Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkInput_v9_2 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkInput_v9_2 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkInput_v9_2 * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkInput_v9_2 * This,
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoInputFlags flags,
- /* [out] */ BMDDisplayModeSupport *result,
- /* [out] */ IDeckLinkDisplayMode **resultDisplayMode);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkInput_v9_2 * This,
- /* [out] */ IDeckLinkDisplayModeIterator **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *SetScreenPreviewCallback )(
- IDeckLinkInput_v9_2 * This,
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoInput )(
- IDeckLinkInput_v9_2 * This,
- /* [in] */ BMDDisplayMode displayMode,
- /* [in] */ BMDPixelFormat pixelFormat,
- /* [in] */ BMDVideoInputFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoInput )(
- IDeckLinkInput_v9_2 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetAvailableVideoFrameCount )(
- IDeckLinkInput_v9_2 * This,
- /* [out] */ unsigned int *availableFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioInput )(
- IDeckLinkInput_v9_2 * This,
- /* [in] */ BMDAudioSampleRate sampleRate,
- /* [in] */ BMDAudioSampleType sampleType,
- /* [in] */ unsigned int channelCount);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioInput )(
- IDeckLinkInput_v9_2 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetAvailableAudioSampleFrameCount )(
- IDeckLinkInput_v9_2 * This,
- /* [out] */ unsigned int *availableSampleFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *StartStreams )(
- IDeckLinkInput_v9_2 * This);
-
- HRESULT ( STDMETHODCALLTYPE *StopStreams )(
- IDeckLinkInput_v9_2 * This);
-
- HRESULT ( STDMETHODCALLTYPE *PauseStreams )(
- IDeckLinkInput_v9_2 * This);
-
- HRESULT ( STDMETHODCALLTYPE *FlushStreams )(
- IDeckLinkInput_v9_2 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetCallback )(
- IDeckLinkInput_v9_2 * This,
- /* [in] */ IDeckLinkInputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceClock )(
- IDeckLinkInput_v9_2 * This,
- /* [in] */ BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame);
-
- END_INTERFACE
- } IDeckLinkInput_v9_2Vtbl;
-
- interface IDeckLinkInput_v9_2
- {
- CONST_VTBL struct IDeckLinkInput_v9_2Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkInput_v9_2_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkInput_v9_2_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkInput_v9_2_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkInput_v9_2_DoesSupportVideoMode(This,displayMode,pixelFormat,flags,result,resultDisplayMode) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,flags,result,resultDisplayMode) )
-
-#define IDeckLinkInput_v9_2_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkInput_v9_2_SetScreenPreviewCallback(This,previewCallback) \
- ( (This)->lpVtbl -> SetScreenPreviewCallback(This,previewCallback) )
-
-#define IDeckLinkInput_v9_2_EnableVideoInput(This,displayMode,pixelFormat,flags) \
- ( (This)->lpVtbl -> EnableVideoInput(This,displayMode,pixelFormat,flags) )
-
-#define IDeckLinkInput_v9_2_DisableVideoInput(This) \
- ( (This)->lpVtbl -> DisableVideoInput(This) )
-
-#define IDeckLinkInput_v9_2_GetAvailableVideoFrameCount(This,availableFrameCount) \
- ( (This)->lpVtbl -> GetAvailableVideoFrameCount(This,availableFrameCount) )
-
-#define IDeckLinkInput_v9_2_EnableAudioInput(This,sampleRate,sampleType,channelCount) \
- ( (This)->lpVtbl -> EnableAudioInput(This,sampleRate,sampleType,channelCount) )
-
-#define IDeckLinkInput_v9_2_DisableAudioInput(This) \
- ( (This)->lpVtbl -> DisableAudioInput(This) )
-
-#define IDeckLinkInput_v9_2_GetAvailableAudioSampleFrameCount(This,availableSampleFrameCount) \
- ( (This)->lpVtbl -> GetAvailableAudioSampleFrameCount(This,availableSampleFrameCount) )
-
-#define IDeckLinkInput_v9_2_StartStreams(This) \
- ( (This)->lpVtbl -> StartStreams(This) )
-
-#define IDeckLinkInput_v9_2_StopStreams(This) \
- ( (This)->lpVtbl -> StopStreams(This) )
-
-#define IDeckLinkInput_v9_2_PauseStreams(This) \
- ( (This)->lpVtbl -> PauseStreams(This) )
-
-#define IDeckLinkInput_v9_2_FlushStreams(This) \
- ( (This)->lpVtbl -> FlushStreams(This) )
-
-#define IDeckLinkInput_v9_2_SetCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetCallback(This,theCallback) )
-
-#define IDeckLinkInput_v9_2_GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) \
- ( (This)->lpVtbl -> GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkInput_v9_2_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeckControlStatusCallback_v8_1_INTERFACE_DEFINED__
-#define __IDeckLinkDeckControlStatusCallback_v8_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDeckControlStatusCallback_v8_1 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDeckControlStatusCallback_v8_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("E5F693C1-4283-4716-B18F-C1431521955B")
- IDeckLinkDeckControlStatusCallback_v8_1 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE TimecodeUpdate(
- /* [in] */ BMDTimecodeBCD currentTimecode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE VTRControlStateChanged(
- /* [in] */ BMDDeckControlVTRControlState_v8_1 newState,
- /* [in] */ BMDDeckControlError error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DeckControlEventReceived(
- /* [in] */ BMDDeckControlEvent event,
- /* [in] */ BMDDeckControlError error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DeckControlStatusChanged(
- /* [in] */ BMDDeckControlStatusFlags flags,
- /* [in] */ unsigned int mask) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDeckControlStatusCallback_v8_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDeckControlStatusCallback_v8_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDeckControlStatusCallback_v8_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDeckControlStatusCallback_v8_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *TimecodeUpdate )(
- IDeckLinkDeckControlStatusCallback_v8_1 * This,
- /* [in] */ BMDTimecodeBCD currentTimecode);
-
- HRESULT ( STDMETHODCALLTYPE *VTRControlStateChanged )(
- IDeckLinkDeckControlStatusCallback_v8_1 * This,
- /* [in] */ BMDDeckControlVTRControlState_v8_1 newState,
- /* [in] */ BMDDeckControlError error);
-
- HRESULT ( STDMETHODCALLTYPE *DeckControlEventReceived )(
- IDeckLinkDeckControlStatusCallback_v8_1 * This,
- /* [in] */ BMDDeckControlEvent event,
- /* [in] */ BMDDeckControlError error);
-
- HRESULT ( STDMETHODCALLTYPE *DeckControlStatusChanged )(
- IDeckLinkDeckControlStatusCallback_v8_1 * This,
- /* [in] */ BMDDeckControlStatusFlags flags,
- /* [in] */ unsigned int mask);
-
- END_INTERFACE
- } IDeckLinkDeckControlStatusCallback_v8_1Vtbl;
-
- interface IDeckLinkDeckControlStatusCallback_v8_1
- {
- CONST_VTBL struct IDeckLinkDeckControlStatusCallback_v8_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDeckControlStatusCallback_v8_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDeckControlStatusCallback_v8_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDeckControlStatusCallback_v8_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDeckControlStatusCallback_v8_1_TimecodeUpdate(This,currentTimecode) \
- ( (This)->lpVtbl -> TimecodeUpdate(This,currentTimecode) )
-
-#define IDeckLinkDeckControlStatusCallback_v8_1_VTRControlStateChanged(This,newState,error) \
- ( (This)->lpVtbl -> VTRControlStateChanged(This,newState,error) )
-
-#define IDeckLinkDeckControlStatusCallback_v8_1_DeckControlEventReceived(This,event,error) \
- ( (This)->lpVtbl -> DeckControlEventReceived(This,event,error) )
-
-#define IDeckLinkDeckControlStatusCallback_v8_1_DeckControlStatusChanged(This,flags,mask) \
- ( (This)->lpVtbl -> DeckControlStatusChanged(This,flags,mask) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDeckControlStatusCallback_v8_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDeckControl_v8_1_INTERFACE_DEFINED__
-#define __IDeckLinkDeckControl_v8_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDeckControl_v8_1 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDeckControl_v8_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("522A9E39-0F3C-4742-94EE-D80DE335DA1D")
- IDeckLinkDeckControl_v8_1 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Open(
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ BMDTimeValue timeValue,
- /* [in] */ BOOL timecodeIsDropFrame,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Close(
- /* [in] */ BOOL standbyOn) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetCurrentState(
- /* [out] */ BMDDeckControlMode *mode,
- /* [out] */ BMDDeckControlVTRControlState_v8_1 *vtrControlState,
- /* [out] */ BMDDeckControlStatusFlags *flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetStandby(
- /* [in] */ BOOL standbyOn) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SendCommand(
- /* [in] */ unsigned char *inBuffer,
- /* [in] */ unsigned int inBufferSize,
- /* [out] */ unsigned char *outBuffer,
- /* [out] */ unsigned int *outDataSize,
- /* [in] */ unsigned int outBufferSize,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Play(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Stop(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE TogglePlayStop(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Eject(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GoToTimecode(
- /* [in] */ BMDTimecodeBCD timecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FastForward(
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Rewind(
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StepForward(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StepBack(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Jog(
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Shuttle(
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecodeString(
- /* [out] */ BSTR *currentTimeCode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecode(
- /* [out] */ IDeckLinkTimecode **currentTimecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecodeBCD(
- /* [out] */ BMDTimecodeBCD *currentTimecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetPreroll(
- /* [in] */ unsigned int prerollSeconds) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetPreroll(
- /* [out] */ unsigned int *prerollSeconds) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetExportOffset(
- /* [in] */ int exportOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetExportOffset(
- /* [out] */ int *exportOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetManualExportOffset(
- /* [out] */ int *deckManualExportOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCaptureOffset(
- /* [in] */ int captureOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetCaptureOffset(
- /* [out] */ int *captureOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartExport(
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [in] */ BMDDeckControlExportModeOpsFlags exportModeOps,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartCapture(
- /* [in] */ BOOL useVITC,
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDeviceID(
- /* [out] */ unsigned short *deviceId,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Abort( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CrashRecordStart(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CrashRecordStop(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- /* [in] */ IDeckLinkDeckControlStatusCallback_v8_1 *callback) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDeckControl_v8_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDeckControl_v8_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDeckControl_v8_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *Open )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ BMDTimeValue timeValue,
- /* [in] */ BOOL timecodeIsDropFrame,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Close )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ BOOL standbyOn);
-
- HRESULT ( STDMETHODCALLTYPE *GetCurrentState )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDDeckControlMode *mode,
- /* [out] */ BMDDeckControlVTRControlState_v8_1 *vtrControlState,
- /* [out] */ BMDDeckControlStatusFlags *flags);
-
- HRESULT ( STDMETHODCALLTYPE *SetStandby )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ BOOL standbyOn);
-
- HRESULT ( STDMETHODCALLTYPE *SendCommand )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ unsigned char *inBuffer,
- /* [in] */ unsigned int inBufferSize,
- /* [out] */ unsigned char *outBuffer,
- /* [out] */ unsigned int *outDataSize,
- /* [in] */ unsigned int outBufferSize,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Play )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Stop )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *TogglePlayStop )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Eject )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GoToTimecode )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ BMDTimecodeBCD timecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *FastForward )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Rewind )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *StepForward )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *StepBack )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Jog )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Shuttle )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecodeString )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BSTR *currentTimeCode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ IDeckLinkTimecode **currentTimecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecodeBCD )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDTimecodeBCD *currentTimecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *SetPreroll )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ unsigned int prerollSeconds);
-
- HRESULT ( STDMETHODCALLTYPE *GetPreroll )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ unsigned int *prerollSeconds);
-
- HRESULT ( STDMETHODCALLTYPE *SetExportOffset )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ int exportOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *GetExportOffset )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ int *exportOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *GetManualExportOffset )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ int *deckManualExportOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *SetCaptureOffset )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ int captureOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *GetCaptureOffset )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ int *captureOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *StartExport )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [in] */ BMDDeckControlExportModeOpsFlags exportModeOps,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *StartCapture )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ BOOL useVITC,
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetDeviceID )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ unsigned short *deviceId,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Abort )(
- IDeckLinkDeckControl_v8_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *CrashRecordStart )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *CrashRecordStop )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *SetCallback )(
- IDeckLinkDeckControl_v8_1 * This,
- /* [in] */ IDeckLinkDeckControlStatusCallback_v8_1 *callback);
-
- END_INTERFACE
- } IDeckLinkDeckControl_v8_1Vtbl;
-
- interface IDeckLinkDeckControl_v8_1
- {
- CONST_VTBL struct IDeckLinkDeckControl_v8_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDeckControl_v8_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDeckControl_v8_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDeckControl_v8_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDeckControl_v8_1_Open(This,timeScale,timeValue,timecodeIsDropFrame,error) \
- ( (This)->lpVtbl -> Open(This,timeScale,timeValue,timecodeIsDropFrame,error) )
-
-#define IDeckLinkDeckControl_v8_1_Close(This,standbyOn) \
- ( (This)->lpVtbl -> Close(This,standbyOn) )
-
-#define IDeckLinkDeckControl_v8_1_GetCurrentState(This,mode,vtrControlState,flags) \
- ( (This)->lpVtbl -> GetCurrentState(This,mode,vtrControlState,flags) )
-
-#define IDeckLinkDeckControl_v8_1_SetStandby(This,standbyOn) \
- ( (This)->lpVtbl -> SetStandby(This,standbyOn) )
-
-#define IDeckLinkDeckControl_v8_1_SendCommand(This,inBuffer,inBufferSize,outBuffer,outDataSize,outBufferSize,error) \
- ( (This)->lpVtbl -> SendCommand(This,inBuffer,inBufferSize,outBuffer,outDataSize,outBufferSize,error) )
-
-#define IDeckLinkDeckControl_v8_1_Play(This,error) \
- ( (This)->lpVtbl -> Play(This,error) )
-
-#define IDeckLinkDeckControl_v8_1_Stop(This,error) \
- ( (This)->lpVtbl -> Stop(This,error) )
-
-#define IDeckLinkDeckControl_v8_1_TogglePlayStop(This,error) \
- ( (This)->lpVtbl -> TogglePlayStop(This,error) )
-
-#define IDeckLinkDeckControl_v8_1_Eject(This,error) \
- ( (This)->lpVtbl -> Eject(This,error) )
-
-#define IDeckLinkDeckControl_v8_1_GoToTimecode(This,timecode,error) \
- ( (This)->lpVtbl -> GoToTimecode(This,timecode,error) )
-
-#define IDeckLinkDeckControl_v8_1_FastForward(This,viewTape,error) \
- ( (This)->lpVtbl -> FastForward(This,viewTape,error) )
-
-#define IDeckLinkDeckControl_v8_1_Rewind(This,viewTape,error) \
- ( (This)->lpVtbl -> Rewind(This,viewTape,error) )
-
-#define IDeckLinkDeckControl_v8_1_StepForward(This,error) \
- ( (This)->lpVtbl -> StepForward(This,error) )
-
-#define IDeckLinkDeckControl_v8_1_StepBack(This,error) \
- ( (This)->lpVtbl -> StepBack(This,error) )
-
-#define IDeckLinkDeckControl_v8_1_Jog(This,rate,error) \
- ( (This)->lpVtbl -> Jog(This,rate,error) )
-
-#define IDeckLinkDeckControl_v8_1_Shuttle(This,rate,error) \
- ( (This)->lpVtbl -> Shuttle(This,rate,error) )
-
-#define IDeckLinkDeckControl_v8_1_GetTimecodeString(This,currentTimeCode,error) \
- ( (This)->lpVtbl -> GetTimecodeString(This,currentTimeCode,error) )
-
-#define IDeckLinkDeckControl_v8_1_GetTimecode(This,currentTimecode,error) \
- ( (This)->lpVtbl -> GetTimecode(This,currentTimecode,error) )
-
-#define IDeckLinkDeckControl_v8_1_GetTimecodeBCD(This,currentTimecode,error) \
- ( (This)->lpVtbl -> GetTimecodeBCD(This,currentTimecode,error) )
-
-#define IDeckLinkDeckControl_v8_1_SetPreroll(This,prerollSeconds) \
- ( (This)->lpVtbl -> SetPreroll(This,prerollSeconds) )
-
-#define IDeckLinkDeckControl_v8_1_GetPreroll(This,prerollSeconds) \
- ( (This)->lpVtbl -> GetPreroll(This,prerollSeconds) )
-
-#define IDeckLinkDeckControl_v8_1_SetExportOffset(This,exportOffsetFields) \
- ( (This)->lpVtbl -> SetExportOffset(This,exportOffsetFields) )
-
-#define IDeckLinkDeckControl_v8_1_GetExportOffset(This,exportOffsetFields) \
- ( (This)->lpVtbl -> GetExportOffset(This,exportOffsetFields) )
-
-#define IDeckLinkDeckControl_v8_1_GetManualExportOffset(This,deckManualExportOffsetFields) \
- ( (This)->lpVtbl -> GetManualExportOffset(This,deckManualExportOffsetFields) )
-
-#define IDeckLinkDeckControl_v8_1_SetCaptureOffset(This,captureOffsetFields) \
- ( (This)->lpVtbl -> SetCaptureOffset(This,captureOffsetFields) )
-
-#define IDeckLinkDeckControl_v8_1_GetCaptureOffset(This,captureOffsetFields) \
- ( (This)->lpVtbl -> GetCaptureOffset(This,captureOffsetFields) )
-
-#define IDeckLinkDeckControl_v8_1_StartExport(This,inTimecode,outTimecode,exportModeOps,error) \
- ( (This)->lpVtbl -> StartExport(This,inTimecode,outTimecode,exportModeOps,error) )
-
-#define IDeckLinkDeckControl_v8_1_StartCapture(This,useVITC,inTimecode,outTimecode,error) \
- ( (This)->lpVtbl -> StartCapture(This,useVITC,inTimecode,outTimecode,error) )
-
-#define IDeckLinkDeckControl_v8_1_GetDeviceID(This,deviceId,error) \
- ( (This)->lpVtbl -> GetDeviceID(This,deviceId,error) )
-
-#define IDeckLinkDeckControl_v8_1_Abort(This) \
- ( (This)->lpVtbl -> Abort(This) )
-
-#define IDeckLinkDeckControl_v8_1_CrashRecordStart(This,error) \
- ( (This)->lpVtbl -> CrashRecordStart(This,error) )
-
-#define IDeckLinkDeckControl_v8_1_CrashRecordStop(This,error) \
- ( (This)->lpVtbl -> CrashRecordStop(This,error) )
-
-#define IDeckLinkDeckControl_v8_1_SetCallback(This,callback) \
- ( (This)->lpVtbl -> SetCallback(This,callback) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDeckControl_v8_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLink_v8_0_INTERFACE_DEFINED__
-#define __IDeckLink_v8_0_INTERFACE_DEFINED__
-
-/* interface IDeckLink_v8_0 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLink_v8_0;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("62BFF75D-6569-4E55-8D4D-66AA03829ABC")
- IDeckLink_v8_0 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetModelName(
- /* [out] */ BSTR *modelName) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLink_v8_0Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLink_v8_0 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLink_v8_0 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLink_v8_0 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetModelName )(
- IDeckLink_v8_0 * This,
- /* [out] */ BSTR *modelName);
-
- END_INTERFACE
- } IDeckLink_v8_0Vtbl;
-
- interface IDeckLink_v8_0
- {
- CONST_VTBL struct IDeckLink_v8_0Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLink_v8_0_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLink_v8_0_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLink_v8_0_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLink_v8_0_GetModelName(This,modelName) \
- ( (This)->lpVtbl -> GetModelName(This,modelName) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLink_v8_0_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkIterator_v8_0_INTERFACE_DEFINED__
-#define __IDeckLinkIterator_v8_0_INTERFACE_DEFINED__
-
-/* interface IDeckLinkIterator_v8_0 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkIterator_v8_0;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("74E936FC-CC28-4A67-81A0-1E94E52D4E69")
- IDeckLinkIterator_v8_0 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Next(
- /* [out] */ IDeckLink_v8_0 **deckLinkInstance) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkIterator_v8_0Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkIterator_v8_0 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkIterator_v8_0 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkIterator_v8_0 * This);
-
- HRESULT ( STDMETHODCALLTYPE *Next )(
- IDeckLinkIterator_v8_0 * This,
- /* [out] */ IDeckLink_v8_0 **deckLinkInstance);
-
- END_INTERFACE
- } IDeckLinkIterator_v8_0Vtbl;
-
- interface IDeckLinkIterator_v8_0
- {
- CONST_VTBL struct IDeckLinkIterator_v8_0Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkIterator_v8_0_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkIterator_v8_0_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkIterator_v8_0_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkIterator_v8_0_Next(This,deckLinkInstance) \
- ( (This)->lpVtbl -> Next(This,deckLinkInstance) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkIterator_v8_0_INTERFACE_DEFINED__ */
-
-
-EXTERN_C const CLSID CLSID_CDeckLinkIterator_v8_0;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("D9EDA3B3-2887-41FA-B724-017CF1EB1D37")
-CDeckLinkIterator_v8_0;
-#endif
-
-#ifndef __IDeckLinkDeckControl_v7_9_INTERFACE_DEFINED__
-#define __IDeckLinkDeckControl_v7_9_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDeckControl_v7_9 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDeckControl_v7_9;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("A4D81043-0619-42B7-8ED6-602D29041DF7")
- IDeckLinkDeckControl_v7_9 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Open(
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ BMDTimeValue timeValue,
- /* [in] */ BOOL timecodeIsDropFrame,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Close(
- /* [in] */ BOOL standbyOn) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetCurrentState(
- /* [out] */ BMDDeckControlMode *mode,
- /* [out] */ BMDDeckControlVTRControlState *vtrControlState,
- /* [out] */ BMDDeckControlStatusFlags *flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetStandby(
- /* [in] */ BOOL standbyOn) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Play(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Stop(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE TogglePlayStop(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Eject(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GoToTimecode(
- /* [in] */ BMDTimecodeBCD timecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FastForward(
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Rewind(
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StepForward(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StepBack(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Jog(
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Shuttle(
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecodeString(
- /* [out] */ BSTR *currentTimeCode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecode(
- /* [out] */ IDeckLinkTimecode **currentTimecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecodeBCD(
- /* [out] */ BMDTimecodeBCD *currentTimecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetPreroll(
- /* [in] */ unsigned int prerollSeconds) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetPreroll(
- /* [out] */ unsigned int *prerollSeconds) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetExportOffset(
- /* [in] */ int exportOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetExportOffset(
- /* [out] */ int *exportOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetManualExportOffset(
- /* [out] */ int *deckManualExportOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCaptureOffset(
- /* [in] */ int captureOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetCaptureOffset(
- /* [out] */ int *captureOffsetFields) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartExport(
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [in] */ BMDDeckControlExportModeOpsFlags exportModeOps,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartCapture(
- /* [in] */ BOOL useVITC,
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDeviceID(
- /* [out] */ unsigned short *deviceId,
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Abort( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CrashRecordStart(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CrashRecordStop(
- /* [out] */ BMDDeckControlError *error) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- /* [in] */ IDeckLinkDeckControlStatusCallback *callback) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDeckControl_v7_9Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDeckControl_v7_9 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDeckControl_v7_9 * This);
-
- HRESULT ( STDMETHODCALLTYPE *Open )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ BMDTimeScale timeScale,
- /* [in] */ BMDTimeValue timeValue,
- /* [in] */ BOOL timecodeIsDropFrame,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Close )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ BOOL standbyOn);
-
- HRESULT ( STDMETHODCALLTYPE *GetCurrentState )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDDeckControlMode *mode,
- /* [out] */ BMDDeckControlVTRControlState *vtrControlState,
- /* [out] */ BMDDeckControlStatusFlags *flags);
-
- HRESULT ( STDMETHODCALLTYPE *SetStandby )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ BOOL standbyOn);
-
- HRESULT ( STDMETHODCALLTYPE *Play )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Stop )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *TogglePlayStop )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Eject )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GoToTimecode )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ BMDTimecodeBCD timecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *FastForward )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Rewind )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ BOOL viewTape,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *StepForward )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *StepBack )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Jog )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Shuttle )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ double rate,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecodeString )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BSTR *currentTimeCode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ IDeckLinkTimecode **currentTimecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecodeBCD )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDTimecodeBCD *currentTimecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *SetPreroll )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ unsigned int prerollSeconds);
-
- HRESULT ( STDMETHODCALLTYPE *GetPreroll )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ unsigned int *prerollSeconds);
-
- HRESULT ( STDMETHODCALLTYPE *SetExportOffset )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ int exportOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *GetExportOffset )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ int *exportOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *GetManualExportOffset )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ int *deckManualExportOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *SetCaptureOffset )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ int captureOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *GetCaptureOffset )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ int *captureOffsetFields);
-
- HRESULT ( STDMETHODCALLTYPE *StartExport )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [in] */ BMDDeckControlExportModeOpsFlags exportModeOps,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *StartCapture )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ BOOL useVITC,
- /* [in] */ BMDTimecodeBCD inTimecode,
- /* [in] */ BMDTimecodeBCD outTimecode,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *GetDeviceID )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ unsigned short *deviceId,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *Abort )(
- IDeckLinkDeckControl_v7_9 * This);
-
- HRESULT ( STDMETHODCALLTYPE *CrashRecordStart )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *CrashRecordStop )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [out] */ BMDDeckControlError *error);
-
- HRESULT ( STDMETHODCALLTYPE *SetCallback )(
- IDeckLinkDeckControl_v7_9 * This,
- /* [in] */ IDeckLinkDeckControlStatusCallback *callback);
-
- END_INTERFACE
- } IDeckLinkDeckControl_v7_9Vtbl;
-
- interface IDeckLinkDeckControl_v7_9
- {
- CONST_VTBL struct IDeckLinkDeckControl_v7_9Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDeckControl_v7_9_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDeckControl_v7_9_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDeckControl_v7_9_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDeckControl_v7_9_Open(This,timeScale,timeValue,timecodeIsDropFrame,error) \
- ( (This)->lpVtbl -> Open(This,timeScale,timeValue,timecodeIsDropFrame,error) )
-
-#define IDeckLinkDeckControl_v7_9_Close(This,standbyOn) \
- ( (This)->lpVtbl -> Close(This,standbyOn) )
-
-#define IDeckLinkDeckControl_v7_9_GetCurrentState(This,mode,vtrControlState,flags) \
- ( (This)->lpVtbl -> GetCurrentState(This,mode,vtrControlState,flags) )
-
-#define IDeckLinkDeckControl_v7_9_SetStandby(This,standbyOn) \
- ( (This)->lpVtbl -> SetStandby(This,standbyOn) )
-
-#define IDeckLinkDeckControl_v7_9_Play(This,error) \
- ( (This)->lpVtbl -> Play(This,error) )
-
-#define IDeckLinkDeckControl_v7_9_Stop(This,error) \
- ( (This)->lpVtbl -> Stop(This,error) )
-
-#define IDeckLinkDeckControl_v7_9_TogglePlayStop(This,error) \
- ( (This)->lpVtbl -> TogglePlayStop(This,error) )
-
-#define IDeckLinkDeckControl_v7_9_Eject(This,error) \
- ( (This)->lpVtbl -> Eject(This,error) )
-
-#define IDeckLinkDeckControl_v7_9_GoToTimecode(This,timecode,error) \
- ( (This)->lpVtbl -> GoToTimecode(This,timecode,error) )
-
-#define IDeckLinkDeckControl_v7_9_FastForward(This,viewTape,error) \
- ( (This)->lpVtbl -> FastForward(This,viewTape,error) )
-
-#define IDeckLinkDeckControl_v7_9_Rewind(This,viewTape,error) \
- ( (This)->lpVtbl -> Rewind(This,viewTape,error) )
-
-#define IDeckLinkDeckControl_v7_9_StepForward(This,error) \
- ( (This)->lpVtbl -> StepForward(This,error) )
-
-#define IDeckLinkDeckControl_v7_9_StepBack(This,error) \
- ( (This)->lpVtbl -> StepBack(This,error) )
-
-#define IDeckLinkDeckControl_v7_9_Jog(This,rate,error) \
- ( (This)->lpVtbl -> Jog(This,rate,error) )
-
-#define IDeckLinkDeckControl_v7_9_Shuttle(This,rate,error) \
- ( (This)->lpVtbl -> Shuttle(This,rate,error) )
-
-#define IDeckLinkDeckControl_v7_9_GetTimecodeString(This,currentTimeCode,error) \
- ( (This)->lpVtbl -> GetTimecodeString(This,currentTimeCode,error) )
-
-#define IDeckLinkDeckControl_v7_9_GetTimecode(This,currentTimecode,error) \
- ( (This)->lpVtbl -> GetTimecode(This,currentTimecode,error) )
-
-#define IDeckLinkDeckControl_v7_9_GetTimecodeBCD(This,currentTimecode,error) \
- ( (This)->lpVtbl -> GetTimecodeBCD(This,currentTimecode,error) )
-
-#define IDeckLinkDeckControl_v7_9_SetPreroll(This,prerollSeconds) \
- ( (This)->lpVtbl -> SetPreroll(This,prerollSeconds) )
-
-#define IDeckLinkDeckControl_v7_9_GetPreroll(This,prerollSeconds) \
- ( (This)->lpVtbl -> GetPreroll(This,prerollSeconds) )
-
-#define IDeckLinkDeckControl_v7_9_SetExportOffset(This,exportOffsetFields) \
- ( (This)->lpVtbl -> SetExportOffset(This,exportOffsetFields) )
-
-#define IDeckLinkDeckControl_v7_9_GetExportOffset(This,exportOffsetFields) \
- ( (This)->lpVtbl -> GetExportOffset(This,exportOffsetFields) )
-
-#define IDeckLinkDeckControl_v7_9_GetManualExportOffset(This,deckManualExportOffsetFields) \
- ( (This)->lpVtbl -> GetManualExportOffset(This,deckManualExportOffsetFields) )
-
-#define IDeckLinkDeckControl_v7_9_SetCaptureOffset(This,captureOffsetFields) \
- ( (This)->lpVtbl -> SetCaptureOffset(This,captureOffsetFields) )
-
-#define IDeckLinkDeckControl_v7_9_GetCaptureOffset(This,captureOffsetFields) \
- ( (This)->lpVtbl -> GetCaptureOffset(This,captureOffsetFields) )
-
-#define IDeckLinkDeckControl_v7_9_StartExport(This,inTimecode,outTimecode,exportModeOps,error) \
- ( (This)->lpVtbl -> StartExport(This,inTimecode,outTimecode,exportModeOps,error) )
-
-#define IDeckLinkDeckControl_v7_9_StartCapture(This,useVITC,inTimecode,outTimecode,error) \
- ( (This)->lpVtbl -> StartCapture(This,useVITC,inTimecode,outTimecode,error) )
-
-#define IDeckLinkDeckControl_v7_9_GetDeviceID(This,deviceId,error) \
- ( (This)->lpVtbl -> GetDeviceID(This,deviceId,error) )
-
-#define IDeckLinkDeckControl_v7_9_Abort(This) \
- ( (This)->lpVtbl -> Abort(This) )
-
-#define IDeckLinkDeckControl_v7_9_CrashRecordStart(This,error) \
- ( (This)->lpVtbl -> CrashRecordStart(This,error) )
-
-#define IDeckLinkDeckControl_v7_9_CrashRecordStop(This,error) \
- ( (This)->lpVtbl -> CrashRecordStop(This,error) )
-
-#define IDeckLinkDeckControl_v7_9_SetCallback(This,callback) \
- ( (This)->lpVtbl -> SetCallback(This,callback) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDeckControl_v7_9_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayModeIterator_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkDisplayModeIterator_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDisplayModeIterator_v7_6 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDisplayModeIterator_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("455D741F-1779-4800-86F5-0B5D13D79751")
- IDeckLinkDisplayModeIterator_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Next(
- /* [out] */ IDeckLinkDisplayMode_v7_6 **deckLinkDisplayMode) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDisplayModeIterator_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDisplayModeIterator_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDisplayModeIterator_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDisplayModeIterator_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *Next )(
- IDeckLinkDisplayModeIterator_v7_6 * This,
- /* [out] */ IDeckLinkDisplayMode_v7_6 **deckLinkDisplayMode);
-
- END_INTERFACE
- } IDeckLinkDisplayModeIterator_v7_6Vtbl;
-
- interface IDeckLinkDisplayModeIterator_v7_6
- {
- CONST_VTBL struct IDeckLinkDisplayModeIterator_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDisplayModeIterator_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDisplayModeIterator_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDisplayModeIterator_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDisplayModeIterator_v7_6_Next(This,deckLinkDisplayMode) \
- ( (This)->lpVtbl -> Next(This,deckLinkDisplayMode) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDisplayModeIterator_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayMode_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkDisplayMode_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDisplayMode_v7_6 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDisplayMode_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("87451E84-2B7E-439E-A629-4393EA4A8550")
- IDeckLinkDisplayMode_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetName(
- /* [out] */ BSTR *name) = 0;
-
- virtual BMDDisplayMode STDMETHODCALLTYPE GetDisplayMode( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetWidth( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetHeight( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFrameRate(
- /* [out] */ BMDTimeValue *frameDuration,
- /* [out] */ BMDTimeScale *timeScale) = 0;
-
- virtual BMDFieldDominance STDMETHODCALLTYPE GetFieldDominance( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDisplayMode_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDisplayMode_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDisplayMode_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDisplayMode_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetName )(
- IDeckLinkDisplayMode_v7_6 * This,
- /* [out] */ BSTR *name);
-
- BMDDisplayMode ( STDMETHODCALLTYPE *GetDisplayMode )(
- IDeckLinkDisplayMode_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkDisplayMode_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkDisplayMode_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetFrameRate )(
- IDeckLinkDisplayMode_v7_6 * This,
- /* [out] */ BMDTimeValue *frameDuration,
- /* [out] */ BMDTimeScale *timeScale);
-
- BMDFieldDominance ( STDMETHODCALLTYPE *GetFieldDominance )(
- IDeckLinkDisplayMode_v7_6 * This);
-
- END_INTERFACE
- } IDeckLinkDisplayMode_v7_6Vtbl;
-
- interface IDeckLinkDisplayMode_v7_6
- {
- CONST_VTBL struct IDeckLinkDisplayMode_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDisplayMode_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDisplayMode_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDisplayMode_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDisplayMode_v7_6_GetName(This,name) \
- ( (This)->lpVtbl -> GetName(This,name) )
-
-#define IDeckLinkDisplayMode_v7_6_GetDisplayMode(This) \
- ( (This)->lpVtbl -> GetDisplayMode(This) )
-
-#define IDeckLinkDisplayMode_v7_6_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkDisplayMode_v7_6_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkDisplayMode_v7_6_GetFrameRate(This,frameDuration,timeScale) \
- ( (This)->lpVtbl -> GetFrameRate(This,frameDuration,timeScale) )
-
-#define IDeckLinkDisplayMode_v7_6_GetFieldDominance(This) \
- ( (This)->lpVtbl -> GetFieldDominance(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDisplayMode_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkOutput_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkOutput_v7_6 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkOutput_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("29228142-EB8C-4141-A621-F74026450955")
- IDeckLinkOutput_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator_v7_6 **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScreenPreviewCallback(
- /* [in] */ IDeckLinkScreenPreviewCallback_v7_6 *previewCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoOutput(
- BMDDisplayMode displayMode,
- BMDVideoOutputFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoOutputFrameMemoryAllocator(
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateVideoFrame(
- int width,
- int height,
- int rowBytes,
- BMDPixelFormat pixelFormat,
- BMDFrameFlags flags,
- /* [out] */ IDeckLinkMutableVideoFrame_v7_6 **outFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateAncillaryData(
- BMDPixelFormat pixelFormat,
- /* [out] */ IDeckLinkVideoFrameAncillary **outBuffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisplayVideoFrameSync(
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleVideoFrame(
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame,
- BMDTimeValue displayTime,
- BMDTimeValue displayDuration,
- BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScheduledFrameCompletionCallback(
- /* [in] */ IDeckLinkVideoOutputCallback_v7_6 *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedVideoFrameCount(
- /* [out] */ unsigned int *bufferedFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioOutput(
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount,
- BMDAudioOutputStreamType streamType) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE WriteAudioSamplesSync(
- /* [in] */ void *buffer,
- unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE BeginAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EndAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleAudioSamples(
- /* [in] */ void *buffer,
- unsigned int sampleFrameCount,
- BMDTimeValue streamTime,
- BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedAudioSampleFrameCount(
- /* [out] */ unsigned int *bufferedSampleFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FlushBufferedAudioSamples( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAudioCallback(
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartScheduledPlayback(
- BMDTimeValue playbackStartTime,
- BMDTimeScale timeScale,
- double playbackSpeed) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopScheduledPlayback(
- BMDTimeValue stopPlaybackAtTime,
- /* [out] */ BMDTimeValue *actualStopTime,
- BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IsScheduledPlaybackRunning(
- /* [out] */ BOOL *active) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetScheduledStreamTime(
- BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *streamTime,
- /* [out] */ double *playbackSpeed) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceClock(
- BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkOutput_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkOutput_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkOutput_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkOutput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkOutput_v7_6 * This,
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkOutput_v7_6 * This,
- /* [out] */ IDeckLinkDisplayModeIterator_v7_6 **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *SetScreenPreviewCallback )(
- IDeckLinkOutput_v7_6 * This,
- /* [in] */ IDeckLinkScreenPreviewCallback_v7_6 *previewCallback);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoOutput )(
- IDeckLinkOutput_v7_6 * This,
- BMDDisplayMode displayMode,
- BMDVideoOutputFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoOutput )(
- IDeckLinkOutput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoOutputFrameMemoryAllocator )(
- IDeckLinkOutput_v7_6 * This,
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator);
-
- HRESULT ( STDMETHODCALLTYPE *CreateVideoFrame )(
- IDeckLinkOutput_v7_6 * This,
- int width,
- int height,
- int rowBytes,
- BMDPixelFormat pixelFormat,
- BMDFrameFlags flags,
- /* [out] */ IDeckLinkMutableVideoFrame_v7_6 **outFrame);
-
- HRESULT ( STDMETHODCALLTYPE *CreateAncillaryData )(
- IDeckLinkOutput_v7_6 * This,
- BMDPixelFormat pixelFormat,
- /* [out] */ IDeckLinkVideoFrameAncillary **outBuffer);
-
- HRESULT ( STDMETHODCALLTYPE *DisplayVideoFrameSync )(
- IDeckLinkOutput_v7_6 * This,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleVideoFrame )(
- IDeckLinkOutput_v7_6 * This,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame,
- BMDTimeValue displayTime,
- BMDTimeValue displayDuration,
- BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *SetScheduledFrameCompletionCallback )(
- IDeckLinkOutput_v7_6 * This,
- /* [in] */ IDeckLinkVideoOutputCallback_v7_6 *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedVideoFrameCount )(
- IDeckLinkOutput_v7_6 * This,
- /* [out] */ unsigned int *bufferedFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioOutput )(
- IDeckLinkOutput_v7_6 * This,
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount,
- BMDAudioOutputStreamType streamType);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioOutput )(
- IDeckLinkOutput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *WriteAudioSamplesSync )(
- IDeckLinkOutput_v7_6 * This,
- /* [in] */ void *buffer,
- unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *BeginAudioPreroll )(
- IDeckLinkOutput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *EndAudioPreroll )(
- IDeckLinkOutput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleAudioSamples )(
- IDeckLinkOutput_v7_6 * This,
- /* [in] */ void *buffer,
- unsigned int sampleFrameCount,
- BMDTimeValue streamTime,
- BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedAudioSampleFrameCount )(
- IDeckLinkOutput_v7_6 * This,
- /* [out] */ unsigned int *bufferedSampleFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *FlushBufferedAudioSamples )(
- IDeckLinkOutput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetAudioCallback )(
- IDeckLinkOutput_v7_6 * This,
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *StartScheduledPlayback )(
- IDeckLinkOutput_v7_6 * This,
- BMDTimeValue playbackStartTime,
- BMDTimeScale timeScale,
- double playbackSpeed);
-
- HRESULT ( STDMETHODCALLTYPE *StopScheduledPlayback )(
- IDeckLinkOutput_v7_6 * This,
- BMDTimeValue stopPlaybackAtTime,
- /* [out] */ BMDTimeValue *actualStopTime,
- BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *IsScheduledPlaybackRunning )(
- IDeckLinkOutput_v7_6 * This,
- /* [out] */ BOOL *active);
-
- HRESULT ( STDMETHODCALLTYPE *GetScheduledStreamTime )(
- IDeckLinkOutput_v7_6 * This,
- BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *streamTime,
- /* [out] */ double *playbackSpeed);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceClock )(
- IDeckLinkOutput_v7_6 * This,
- BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame);
-
- END_INTERFACE
- } IDeckLinkOutput_v7_6Vtbl;
-
- interface IDeckLinkOutput_v7_6
- {
- CONST_VTBL struct IDeckLinkOutput_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkOutput_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkOutput_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkOutput_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkOutput_v7_6_DoesSupportVideoMode(This,displayMode,pixelFormat,result) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,result) )
-
-#define IDeckLinkOutput_v7_6_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkOutput_v7_6_SetScreenPreviewCallback(This,previewCallback) \
- ( (This)->lpVtbl -> SetScreenPreviewCallback(This,previewCallback) )
-
-#define IDeckLinkOutput_v7_6_EnableVideoOutput(This,displayMode,flags) \
- ( (This)->lpVtbl -> EnableVideoOutput(This,displayMode,flags) )
-
-#define IDeckLinkOutput_v7_6_DisableVideoOutput(This) \
- ( (This)->lpVtbl -> DisableVideoOutput(This) )
-
-#define IDeckLinkOutput_v7_6_SetVideoOutputFrameMemoryAllocator(This,theAllocator) \
- ( (This)->lpVtbl -> SetVideoOutputFrameMemoryAllocator(This,theAllocator) )
-
-#define IDeckLinkOutput_v7_6_CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) \
- ( (This)->lpVtbl -> CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) )
-
-#define IDeckLinkOutput_v7_6_CreateAncillaryData(This,pixelFormat,outBuffer) \
- ( (This)->lpVtbl -> CreateAncillaryData(This,pixelFormat,outBuffer) )
-
-#define IDeckLinkOutput_v7_6_DisplayVideoFrameSync(This,theFrame) \
- ( (This)->lpVtbl -> DisplayVideoFrameSync(This,theFrame) )
-
-#define IDeckLinkOutput_v7_6_ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) \
- ( (This)->lpVtbl -> ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) )
-
-#define IDeckLinkOutput_v7_6_SetScheduledFrameCompletionCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetScheduledFrameCompletionCallback(This,theCallback) )
-
-#define IDeckLinkOutput_v7_6_GetBufferedVideoFrameCount(This,bufferedFrameCount) \
- ( (This)->lpVtbl -> GetBufferedVideoFrameCount(This,bufferedFrameCount) )
-
-#define IDeckLinkOutput_v7_6_EnableAudioOutput(This,sampleRate,sampleType,channelCount,streamType) \
- ( (This)->lpVtbl -> EnableAudioOutput(This,sampleRate,sampleType,channelCount,streamType) )
-
-#define IDeckLinkOutput_v7_6_DisableAudioOutput(This) \
- ( (This)->lpVtbl -> DisableAudioOutput(This) )
-
-#define IDeckLinkOutput_v7_6_WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) \
- ( (This)->lpVtbl -> WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) )
-
-#define IDeckLinkOutput_v7_6_BeginAudioPreroll(This) \
- ( (This)->lpVtbl -> BeginAudioPreroll(This) )
-
-#define IDeckLinkOutput_v7_6_EndAudioPreroll(This) \
- ( (This)->lpVtbl -> EndAudioPreroll(This) )
-
-#define IDeckLinkOutput_v7_6_ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) \
- ( (This)->lpVtbl -> ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) )
-
-#define IDeckLinkOutput_v7_6_GetBufferedAudioSampleFrameCount(This,bufferedSampleFrameCount) \
- ( (This)->lpVtbl -> GetBufferedAudioSampleFrameCount(This,bufferedSampleFrameCount) )
-
-#define IDeckLinkOutput_v7_6_FlushBufferedAudioSamples(This) \
- ( (This)->lpVtbl -> FlushBufferedAudioSamples(This) )
-
-#define IDeckLinkOutput_v7_6_SetAudioCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetAudioCallback(This,theCallback) )
-
-#define IDeckLinkOutput_v7_6_StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) \
- ( (This)->lpVtbl -> StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) )
-
-#define IDeckLinkOutput_v7_6_StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) \
- ( (This)->lpVtbl -> StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) )
-
-#define IDeckLinkOutput_v7_6_IsScheduledPlaybackRunning(This,active) \
- ( (This)->lpVtbl -> IsScheduledPlaybackRunning(This,active) )
-
-#define IDeckLinkOutput_v7_6_GetScheduledStreamTime(This,desiredTimeScale,streamTime,playbackSpeed) \
- ( (This)->lpVtbl -> GetScheduledStreamTime(This,desiredTimeScale,streamTime,playbackSpeed) )
-
-#define IDeckLinkOutput_v7_6_GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) \
- ( (This)->lpVtbl -> GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkOutput_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkInput_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkInput_v7_6 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkInput_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("300C135A-9F43-48E2-9906-6D7911D93CF1")
- IDeckLinkInput_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator_v7_6 **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScreenPreviewCallback(
- /* [in] */ IDeckLinkScreenPreviewCallback_v7_6 *previewCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoInput(
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- BMDVideoInputFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAvailableVideoFrameCount(
- /* [out] */ unsigned int *availableFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioInput(
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAvailableAudioSampleFrameCount(
- /* [out] */ unsigned int *availableSampleFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE PauseStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FlushStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- /* [in] */ IDeckLinkInputCallback_v7_6 *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceClock(
- BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkInput_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkInput_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkInput_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkInput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkInput_v7_6 * This,
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkInput_v7_6 * This,
- /* [out] */ IDeckLinkDisplayModeIterator_v7_6 **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *SetScreenPreviewCallback )(
- IDeckLinkInput_v7_6 * This,
- /* [in] */ IDeckLinkScreenPreviewCallback_v7_6 *previewCallback);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoInput )(
- IDeckLinkInput_v7_6 * This,
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- BMDVideoInputFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoInput )(
- IDeckLinkInput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetAvailableVideoFrameCount )(
- IDeckLinkInput_v7_6 * This,
- /* [out] */ unsigned int *availableFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioInput )(
- IDeckLinkInput_v7_6 * This,
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioInput )(
- IDeckLinkInput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetAvailableAudioSampleFrameCount )(
- IDeckLinkInput_v7_6 * This,
- /* [out] */ unsigned int *availableSampleFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *StartStreams )(
- IDeckLinkInput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *StopStreams )(
- IDeckLinkInput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *PauseStreams )(
- IDeckLinkInput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *FlushStreams )(
- IDeckLinkInput_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetCallback )(
- IDeckLinkInput_v7_6 * This,
- /* [in] */ IDeckLinkInputCallback_v7_6 *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceClock )(
- IDeckLinkInput_v7_6 * This,
- BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *hardwareTime,
- /* [out] */ BMDTimeValue *timeInFrame,
- /* [out] */ BMDTimeValue *ticksPerFrame);
-
- END_INTERFACE
- } IDeckLinkInput_v7_6Vtbl;
-
- interface IDeckLinkInput_v7_6
- {
- CONST_VTBL struct IDeckLinkInput_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkInput_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkInput_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkInput_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkInput_v7_6_DoesSupportVideoMode(This,displayMode,pixelFormat,result) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,result) )
-
-#define IDeckLinkInput_v7_6_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkInput_v7_6_SetScreenPreviewCallback(This,previewCallback) \
- ( (This)->lpVtbl -> SetScreenPreviewCallback(This,previewCallback) )
-
-#define IDeckLinkInput_v7_6_EnableVideoInput(This,displayMode,pixelFormat,flags) \
- ( (This)->lpVtbl -> EnableVideoInput(This,displayMode,pixelFormat,flags) )
-
-#define IDeckLinkInput_v7_6_DisableVideoInput(This) \
- ( (This)->lpVtbl -> DisableVideoInput(This) )
-
-#define IDeckLinkInput_v7_6_GetAvailableVideoFrameCount(This,availableFrameCount) \
- ( (This)->lpVtbl -> GetAvailableVideoFrameCount(This,availableFrameCount) )
-
-#define IDeckLinkInput_v7_6_EnableAudioInput(This,sampleRate,sampleType,channelCount) \
- ( (This)->lpVtbl -> EnableAudioInput(This,sampleRate,sampleType,channelCount) )
-
-#define IDeckLinkInput_v7_6_DisableAudioInput(This) \
- ( (This)->lpVtbl -> DisableAudioInput(This) )
-
-#define IDeckLinkInput_v7_6_GetAvailableAudioSampleFrameCount(This,availableSampleFrameCount) \
- ( (This)->lpVtbl -> GetAvailableAudioSampleFrameCount(This,availableSampleFrameCount) )
-
-#define IDeckLinkInput_v7_6_StartStreams(This) \
- ( (This)->lpVtbl -> StartStreams(This) )
-
-#define IDeckLinkInput_v7_6_StopStreams(This) \
- ( (This)->lpVtbl -> StopStreams(This) )
-
-#define IDeckLinkInput_v7_6_PauseStreams(This) \
- ( (This)->lpVtbl -> PauseStreams(This) )
-
-#define IDeckLinkInput_v7_6_FlushStreams(This) \
- ( (This)->lpVtbl -> FlushStreams(This) )
-
-#define IDeckLinkInput_v7_6_SetCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetCallback(This,theCallback) )
-
-#define IDeckLinkInput_v7_6_GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) \
- ( (This)->lpVtbl -> GetHardwareReferenceClock(This,desiredTimeScale,hardwareTime,timeInFrame,ticksPerFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkInput_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkTimecode_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkTimecode_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkTimecode_v7_6 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkTimecode_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("EFB9BCA6-A521-44F7-BD69-2332F24D9EE6")
- IDeckLinkTimecode_v7_6 : public IUnknown
- {
- public:
- virtual BMDTimecodeBCD STDMETHODCALLTYPE GetBCD( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetComponents(
- /* [out] */ unsigned char *hours,
- /* [out] */ unsigned char *minutes,
- /* [out] */ unsigned char *seconds,
- /* [out] */ unsigned char *frames) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetString(
- /* [out] */ BSTR *timecode) = 0;
-
- virtual BMDTimecodeFlags STDMETHODCALLTYPE GetFlags( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkTimecode_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkTimecode_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkTimecode_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkTimecode_v7_6 * This);
-
- BMDTimecodeBCD ( STDMETHODCALLTYPE *GetBCD )(
- IDeckLinkTimecode_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetComponents )(
- IDeckLinkTimecode_v7_6 * This,
- /* [out] */ unsigned char *hours,
- /* [out] */ unsigned char *minutes,
- /* [out] */ unsigned char *seconds,
- /* [out] */ unsigned char *frames);
-
- HRESULT ( STDMETHODCALLTYPE *GetString )(
- IDeckLinkTimecode_v7_6 * This,
- /* [out] */ BSTR *timecode);
-
- BMDTimecodeFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkTimecode_v7_6 * This);
-
- END_INTERFACE
- } IDeckLinkTimecode_v7_6Vtbl;
-
- interface IDeckLinkTimecode_v7_6
- {
- CONST_VTBL struct IDeckLinkTimecode_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkTimecode_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkTimecode_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkTimecode_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkTimecode_v7_6_GetBCD(This) \
- ( (This)->lpVtbl -> GetBCD(This) )
-
-#define IDeckLinkTimecode_v7_6_GetComponents(This,hours,minutes,seconds,frames) \
- ( (This)->lpVtbl -> GetComponents(This,hours,minutes,seconds,frames) )
-
-#define IDeckLinkTimecode_v7_6_GetString(This,timecode) \
- ( (This)->lpVtbl -> GetString(This,timecode) )
-
-#define IDeckLinkTimecode_v7_6_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkTimecode_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrame_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkVideoFrame_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoFrame_v7_6 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoFrame_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("A8D8238E-6B18-4196-99E1-5AF717B83D32")
- IDeckLinkVideoFrame_v7_6 : public IUnknown
- {
- public:
- virtual long STDMETHODCALLTYPE GetWidth( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetHeight( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetRowBytes( void) = 0;
-
- virtual BMDPixelFormat STDMETHODCALLTYPE GetPixelFormat( void) = 0;
-
- virtual BMDFrameFlags STDMETHODCALLTYPE GetFlags( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBytes(
- /* [out] */ void **buffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetTimecode(
- BMDTimecodeFormat format,
- /* [out] */ IDeckLinkTimecode_v7_6 **timecode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAncillaryData(
- /* [out] */ IDeckLinkVideoFrameAncillary **ancillary) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoFrame_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoFrame_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoFrame_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoFrame_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkVideoFrame_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkVideoFrame_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetRowBytes )(
- IDeckLinkVideoFrame_v7_6 * This);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkVideoFrame_v7_6 * This);
-
- BMDFrameFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkVideoFrame_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkVideoFrame_v7_6 * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkVideoFrame_v7_6 * This,
- BMDTimecodeFormat format,
- /* [out] */ IDeckLinkTimecode_v7_6 **timecode);
-
- HRESULT ( STDMETHODCALLTYPE *GetAncillaryData )(
- IDeckLinkVideoFrame_v7_6 * This,
- /* [out] */ IDeckLinkVideoFrameAncillary **ancillary);
-
- END_INTERFACE
- } IDeckLinkVideoFrame_v7_6Vtbl;
-
- interface IDeckLinkVideoFrame_v7_6
- {
- CONST_VTBL struct IDeckLinkVideoFrame_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoFrame_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoFrame_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoFrame_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoFrame_v7_6_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkVideoFrame_v7_6_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkVideoFrame_v7_6_GetRowBytes(This) \
- ( (This)->lpVtbl -> GetRowBytes(This) )
-
-#define IDeckLinkVideoFrame_v7_6_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkVideoFrame_v7_6_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkVideoFrame_v7_6_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IDeckLinkVideoFrame_v7_6_GetTimecode(This,format,timecode) \
- ( (This)->lpVtbl -> GetTimecode(This,format,timecode) )
-
-#define IDeckLinkVideoFrame_v7_6_GetAncillaryData(This,ancillary) \
- ( (This)->lpVtbl -> GetAncillaryData(This,ancillary) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoFrame_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkMutableVideoFrame_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkMutableVideoFrame_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkMutableVideoFrame_v7_6 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkMutableVideoFrame_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("46FCEE00-B4E6-43D0-91C0-023A7FCEB34F")
- IDeckLinkMutableVideoFrame_v7_6 : public IDeckLinkVideoFrame_v7_6
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE SetFlags(
- BMDFrameFlags newFlags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetTimecode(
- BMDTimecodeFormat format,
- /* [in] */ IDeckLinkTimecode_v7_6 *timecode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetTimecodeFromComponents(
- BMDTimecodeFormat format,
- unsigned char hours,
- unsigned char minutes,
- unsigned char seconds,
- unsigned char frames,
- BMDTimecodeFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAncillaryData(
- /* [in] */ IDeckLinkVideoFrameAncillary *ancillary) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkMutableVideoFrame_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkMutableVideoFrame_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkMutableVideoFrame_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkMutableVideoFrame_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkMutableVideoFrame_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkMutableVideoFrame_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetRowBytes )(
- IDeckLinkMutableVideoFrame_v7_6 * This);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkMutableVideoFrame_v7_6 * This);
-
- BMDFrameFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkMutableVideoFrame_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkMutableVideoFrame_v7_6 * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkMutableVideoFrame_v7_6 * This,
- BMDTimecodeFormat format,
- /* [out] */ IDeckLinkTimecode_v7_6 **timecode);
-
- HRESULT ( STDMETHODCALLTYPE *GetAncillaryData )(
- IDeckLinkMutableVideoFrame_v7_6 * This,
- /* [out] */ IDeckLinkVideoFrameAncillary **ancillary);
-
- HRESULT ( STDMETHODCALLTYPE *SetFlags )(
- IDeckLinkMutableVideoFrame_v7_6 * This,
- BMDFrameFlags newFlags);
-
- HRESULT ( STDMETHODCALLTYPE *SetTimecode )(
- IDeckLinkMutableVideoFrame_v7_6 * This,
- BMDTimecodeFormat format,
- /* [in] */ IDeckLinkTimecode_v7_6 *timecode);
-
- HRESULT ( STDMETHODCALLTYPE *SetTimecodeFromComponents )(
- IDeckLinkMutableVideoFrame_v7_6 * This,
- BMDTimecodeFormat format,
- unsigned char hours,
- unsigned char minutes,
- unsigned char seconds,
- unsigned char frames,
- BMDTimecodeFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *SetAncillaryData )(
- IDeckLinkMutableVideoFrame_v7_6 * This,
- /* [in] */ IDeckLinkVideoFrameAncillary *ancillary);
-
- END_INTERFACE
- } IDeckLinkMutableVideoFrame_v7_6Vtbl;
-
- interface IDeckLinkMutableVideoFrame_v7_6
- {
- CONST_VTBL struct IDeckLinkMutableVideoFrame_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkMutableVideoFrame_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkMutableVideoFrame_v7_6_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_GetRowBytes(This) \
- ( (This)->lpVtbl -> GetRowBytes(This) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_GetTimecode(This,format,timecode) \
- ( (This)->lpVtbl -> GetTimecode(This,format,timecode) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_GetAncillaryData(This,ancillary) \
- ( (This)->lpVtbl -> GetAncillaryData(This,ancillary) )
-
-
-#define IDeckLinkMutableVideoFrame_v7_6_SetFlags(This,newFlags) \
- ( (This)->lpVtbl -> SetFlags(This,newFlags) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_SetTimecode(This,format,timecode) \
- ( (This)->lpVtbl -> SetTimecode(This,format,timecode) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_SetTimecodeFromComponents(This,format,hours,minutes,seconds,frames,flags) \
- ( (This)->lpVtbl -> SetTimecodeFromComponents(This,format,hours,minutes,seconds,frames,flags) )
-
-#define IDeckLinkMutableVideoFrame_v7_6_SetAncillaryData(This,ancillary) \
- ( (This)->lpVtbl -> SetAncillaryData(This,ancillary) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkMutableVideoFrame_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoInputFrame_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkVideoInputFrame_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoInputFrame_v7_6 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoInputFrame_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("9A74FA41-AE9F-47AC-8CF4-01F42DD59965")
- IDeckLinkVideoInputFrame_v7_6 : public IDeckLinkVideoFrame_v7_6
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetStreamTime(
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration,
- BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceTimestamp(
- BMDTimeScale timeScale,
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoInputFrame_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoInputFrame_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoInputFrame_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoInputFrame_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkVideoInputFrame_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkVideoInputFrame_v7_6 * This);
-
- long ( STDMETHODCALLTYPE *GetRowBytes )(
- IDeckLinkVideoInputFrame_v7_6 * This);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkVideoInputFrame_v7_6 * This);
-
- BMDFrameFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkVideoInputFrame_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkVideoInputFrame_v7_6 * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkVideoInputFrame_v7_6 * This,
- BMDTimecodeFormat format,
- /* [out] */ IDeckLinkTimecode_v7_6 **timecode);
-
- HRESULT ( STDMETHODCALLTYPE *GetAncillaryData )(
- IDeckLinkVideoInputFrame_v7_6 * This,
- /* [out] */ IDeckLinkVideoFrameAncillary **ancillary);
-
- HRESULT ( STDMETHODCALLTYPE *GetStreamTime )(
- IDeckLinkVideoInputFrame_v7_6 * This,
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration,
- BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceTimestamp )(
- IDeckLinkVideoInputFrame_v7_6 * This,
- BMDTimeScale timeScale,
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration);
-
- END_INTERFACE
- } IDeckLinkVideoInputFrame_v7_6Vtbl;
-
- interface IDeckLinkVideoInputFrame_v7_6
- {
- CONST_VTBL struct IDeckLinkVideoInputFrame_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoInputFrame_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoInputFrame_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoInputFrame_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoInputFrame_v7_6_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkVideoInputFrame_v7_6_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkVideoInputFrame_v7_6_GetRowBytes(This) \
- ( (This)->lpVtbl -> GetRowBytes(This) )
-
-#define IDeckLinkVideoInputFrame_v7_6_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkVideoInputFrame_v7_6_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkVideoInputFrame_v7_6_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IDeckLinkVideoInputFrame_v7_6_GetTimecode(This,format,timecode) \
- ( (This)->lpVtbl -> GetTimecode(This,format,timecode) )
-
-#define IDeckLinkVideoInputFrame_v7_6_GetAncillaryData(This,ancillary) \
- ( (This)->lpVtbl -> GetAncillaryData(This,ancillary) )
-
-
-#define IDeckLinkVideoInputFrame_v7_6_GetStreamTime(This,frameTime,frameDuration,timeScale) \
- ( (This)->lpVtbl -> GetStreamTime(This,frameTime,frameDuration,timeScale) )
-
-#define IDeckLinkVideoInputFrame_v7_6_GetHardwareReferenceTimestamp(This,timeScale,frameTime,frameDuration) \
- ( (This)->lpVtbl -> GetHardwareReferenceTimestamp(This,timeScale,frameTime,frameDuration) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoInputFrame_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkScreenPreviewCallback_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkScreenPreviewCallback_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkScreenPreviewCallback_v7_6 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkScreenPreviewCallback_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("373F499D-4B4D-4518-AD22-6354E5A5825E")
- IDeckLinkScreenPreviewCallback_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DrawFrame(
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkScreenPreviewCallback_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkScreenPreviewCallback_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkScreenPreviewCallback_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkScreenPreviewCallback_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *DrawFrame )(
- IDeckLinkScreenPreviewCallback_v7_6 * This,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame);
-
- END_INTERFACE
- } IDeckLinkScreenPreviewCallback_v7_6Vtbl;
-
- interface IDeckLinkScreenPreviewCallback_v7_6
- {
- CONST_VTBL struct IDeckLinkScreenPreviewCallback_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkScreenPreviewCallback_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkScreenPreviewCallback_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkScreenPreviewCallback_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkScreenPreviewCallback_v7_6_DrawFrame(This,theFrame) \
- ( (This)->lpVtbl -> DrawFrame(This,theFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkScreenPreviewCallback_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkGLScreenPreviewHelper_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkGLScreenPreviewHelper_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkGLScreenPreviewHelper_v7_6 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkGLScreenPreviewHelper_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("BA575CD9-A15E-497B-B2C2-F9AFE7BE4EBA")
- IDeckLinkGLScreenPreviewHelper_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE InitializeGL( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE PaintGL( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetFrame(
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkGLScreenPreviewHelper_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkGLScreenPreviewHelper_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkGLScreenPreviewHelper_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkGLScreenPreviewHelper_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *InitializeGL )(
- IDeckLinkGLScreenPreviewHelper_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *PaintGL )(
- IDeckLinkGLScreenPreviewHelper_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetFrame )(
- IDeckLinkGLScreenPreviewHelper_v7_6 * This,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame);
-
- END_INTERFACE
- } IDeckLinkGLScreenPreviewHelper_v7_6Vtbl;
-
- interface IDeckLinkGLScreenPreviewHelper_v7_6
- {
- CONST_VTBL struct IDeckLinkGLScreenPreviewHelper_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkGLScreenPreviewHelper_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkGLScreenPreviewHelper_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkGLScreenPreviewHelper_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkGLScreenPreviewHelper_v7_6_InitializeGL(This) \
- ( (This)->lpVtbl -> InitializeGL(This) )
-
-#define IDeckLinkGLScreenPreviewHelper_v7_6_PaintGL(This) \
- ( (This)->lpVtbl -> PaintGL(This) )
-
-#define IDeckLinkGLScreenPreviewHelper_v7_6_SetFrame(This,theFrame) \
- ( (This)->lpVtbl -> SetFrame(This,theFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkGLScreenPreviewHelper_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoConversion_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkVideoConversion_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoConversion_v7_6 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoConversion_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("3EB504C9-F97D-40FE-A158-D407D48CB53B")
- IDeckLinkVideoConversion_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE ConvertFrame(
- /* [in] */ IDeckLinkVideoFrame_v7_6 *srcFrame,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *dstFrame) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoConversion_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoConversion_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoConversion_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoConversion_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *ConvertFrame )(
- IDeckLinkVideoConversion_v7_6 * This,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *srcFrame,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *dstFrame);
-
- END_INTERFACE
- } IDeckLinkVideoConversion_v7_6Vtbl;
-
- interface IDeckLinkVideoConversion_v7_6
- {
- CONST_VTBL struct IDeckLinkVideoConversion_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoConversion_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoConversion_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoConversion_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoConversion_v7_6_ConvertFrame(This,srcFrame,dstFrame) \
- ( (This)->lpVtbl -> ConvertFrame(This,srcFrame,dstFrame) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoConversion_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkConfiguration_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkConfiguration_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkConfiguration_v7_6 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkConfiguration_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("B8EAD569-B764-47F0-A73F-AE40DF6CBF10")
- IDeckLinkConfiguration_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetConfigurationValidator(
- /* [out] */ IDeckLinkConfiguration_v7_6 **configObject) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE WriteConfigurationToPreferences( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoOutputFormat(
- /* [in] */ BMDVideoConnection_v7_6 videoOutputConnection) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IsVideoOutputActive(
- /* [in] */ BMDVideoConnection_v7_6 videoOutputConnection,
- /* [out] */ BOOL *active) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAnalogVideoOutputFlags(
- /* [in] */ BMDAnalogVideoFlags analogVideoFlags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAnalogVideoOutputFlags(
- /* [out] */ BMDAnalogVideoFlags *analogVideoFlags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableFieldFlickerRemovalWhenPaused(
- /* [in] */ BOOL enable) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IsEnabledFieldFlickerRemovalWhenPaused(
- /* [out] */ BOOL *enabled) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Set444And3GBpsVideoOutput(
- /* [in] */ BOOL enable444VideoOutput,
- /* [in] */ BOOL enable3GbsOutput) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Get444And3GBpsVideoOutput(
- /* [out] */ BOOL *is444VideoOutputEnabled,
- /* [out] */ BOOL *threeGbsOutputEnabled) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoOutputConversionMode(
- /* [in] */ BMDVideoOutputConversionMode conversionMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetVideoOutputConversionMode(
- /* [out] */ BMDVideoOutputConversionMode *conversionMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Set_HD1080p24_to_HD1080i5994_Conversion(
- /* [in] */ BOOL enable) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Get_HD1080p24_to_HD1080i5994_Conversion(
- /* [out] */ BOOL *enabled) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoInputFormat(
- /* [in] */ BMDVideoConnection_v7_6 videoInputFormat) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetVideoInputFormat(
- /* [out] */ BMDVideoConnection_v7_6 *videoInputFormat) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAnalogVideoInputFlags(
- /* [in] */ BMDAnalogVideoFlags analogVideoFlags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAnalogVideoInputFlags(
- /* [out] */ BMDAnalogVideoFlags *analogVideoFlags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoInputConversionMode(
- /* [in] */ BMDVideoInputConversionMode conversionMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetVideoInputConversionMode(
- /* [out] */ BMDVideoInputConversionMode *conversionMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetBlackVideoOutputDuringCapture(
- /* [in] */ BOOL blackOutInCapture) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBlackVideoOutputDuringCapture(
- /* [out] */ BOOL *blackOutInCapture) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Set32PulldownSequenceInitialTimecodeFrame(
- /* [in] */ unsigned int aFrameTimecode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Get32PulldownSequenceInitialTimecodeFrame(
- /* [out] */ unsigned int *aFrameTimecode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVancSourceLineMapping(
- /* [in] */ unsigned int activeLine1VANCsource,
- /* [in] */ unsigned int activeLine2VANCsource,
- /* [in] */ unsigned int activeLine3VANCsource) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetVancSourceLineMapping(
- /* [out] */ unsigned int *activeLine1VANCsource,
- /* [out] */ unsigned int *activeLine2VANCsource,
- /* [out] */ unsigned int *activeLine3VANCsource) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAudioInputFormat(
- /* [in] */ BMDAudioConnection_v10_2 audioInputFormat) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAudioInputFormat(
- /* [out] */ BMDAudioConnection_v10_2 *audioInputFormat) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkConfiguration_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkConfiguration_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkConfiguration_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetConfigurationValidator )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ IDeckLinkConfiguration_v7_6 **configObject);
-
- HRESULT ( STDMETHODCALLTYPE *WriteConfigurationToPreferences )(
- IDeckLinkConfiguration_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoOutputFormat )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BMDVideoConnection_v7_6 videoOutputConnection);
-
- HRESULT ( STDMETHODCALLTYPE *IsVideoOutputActive )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BMDVideoConnection_v7_6 videoOutputConnection,
- /* [out] */ BOOL *active);
-
- HRESULT ( STDMETHODCALLTYPE *SetAnalogVideoOutputFlags )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BMDAnalogVideoFlags analogVideoFlags);
-
- HRESULT ( STDMETHODCALLTYPE *GetAnalogVideoOutputFlags )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BMDAnalogVideoFlags *analogVideoFlags);
-
- HRESULT ( STDMETHODCALLTYPE *EnableFieldFlickerRemovalWhenPaused )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BOOL enable);
-
- HRESULT ( STDMETHODCALLTYPE *IsEnabledFieldFlickerRemovalWhenPaused )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BOOL *enabled);
-
- HRESULT ( STDMETHODCALLTYPE *Set444And3GBpsVideoOutput )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BOOL enable444VideoOutput,
- /* [in] */ BOOL enable3GbsOutput);
-
- HRESULT ( STDMETHODCALLTYPE *Get444And3GBpsVideoOutput )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BOOL *is444VideoOutputEnabled,
- /* [out] */ BOOL *threeGbsOutputEnabled);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoOutputConversionMode )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BMDVideoOutputConversionMode conversionMode);
-
- HRESULT ( STDMETHODCALLTYPE *GetVideoOutputConversionMode )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BMDVideoOutputConversionMode *conversionMode);
-
- HRESULT ( STDMETHODCALLTYPE *Set_HD1080p24_to_HD1080i5994_Conversion )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BOOL enable);
-
- HRESULT ( STDMETHODCALLTYPE *Get_HD1080p24_to_HD1080i5994_Conversion )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BOOL *enabled);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoInputFormat )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BMDVideoConnection_v7_6 videoInputFormat);
-
- HRESULT ( STDMETHODCALLTYPE *GetVideoInputFormat )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BMDVideoConnection_v7_6 *videoInputFormat);
-
- HRESULT ( STDMETHODCALLTYPE *SetAnalogVideoInputFlags )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BMDAnalogVideoFlags analogVideoFlags);
-
- HRESULT ( STDMETHODCALLTYPE *GetAnalogVideoInputFlags )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BMDAnalogVideoFlags *analogVideoFlags);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoInputConversionMode )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BMDVideoInputConversionMode conversionMode);
-
- HRESULT ( STDMETHODCALLTYPE *GetVideoInputConversionMode )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BMDVideoInputConversionMode *conversionMode);
-
- HRESULT ( STDMETHODCALLTYPE *SetBlackVideoOutputDuringCapture )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BOOL blackOutInCapture);
-
- HRESULT ( STDMETHODCALLTYPE *GetBlackVideoOutputDuringCapture )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BOOL *blackOutInCapture);
-
- HRESULT ( STDMETHODCALLTYPE *Set32PulldownSequenceInitialTimecodeFrame )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ unsigned int aFrameTimecode);
-
- HRESULT ( STDMETHODCALLTYPE *Get32PulldownSequenceInitialTimecodeFrame )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ unsigned int *aFrameTimecode);
-
- HRESULT ( STDMETHODCALLTYPE *SetVancSourceLineMapping )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ unsigned int activeLine1VANCsource,
- /* [in] */ unsigned int activeLine2VANCsource,
- /* [in] */ unsigned int activeLine3VANCsource);
-
- HRESULT ( STDMETHODCALLTYPE *GetVancSourceLineMapping )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ unsigned int *activeLine1VANCsource,
- /* [out] */ unsigned int *activeLine2VANCsource,
- /* [out] */ unsigned int *activeLine3VANCsource);
-
- HRESULT ( STDMETHODCALLTYPE *SetAudioInputFormat )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [in] */ BMDAudioConnection_v10_2 audioInputFormat);
-
- HRESULT ( STDMETHODCALLTYPE *GetAudioInputFormat )(
- IDeckLinkConfiguration_v7_6 * This,
- /* [out] */ BMDAudioConnection_v10_2 *audioInputFormat);
-
- END_INTERFACE
- } IDeckLinkConfiguration_v7_6Vtbl;
-
- interface IDeckLinkConfiguration_v7_6
- {
- CONST_VTBL struct IDeckLinkConfiguration_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkConfiguration_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkConfiguration_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkConfiguration_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkConfiguration_v7_6_GetConfigurationValidator(This,configObject) \
- ( (This)->lpVtbl -> GetConfigurationValidator(This,configObject) )
-
-#define IDeckLinkConfiguration_v7_6_WriteConfigurationToPreferences(This) \
- ( (This)->lpVtbl -> WriteConfigurationToPreferences(This) )
-
-#define IDeckLinkConfiguration_v7_6_SetVideoOutputFormat(This,videoOutputConnection) \
- ( (This)->lpVtbl -> SetVideoOutputFormat(This,videoOutputConnection) )
-
-#define IDeckLinkConfiguration_v7_6_IsVideoOutputActive(This,videoOutputConnection,active) \
- ( (This)->lpVtbl -> IsVideoOutputActive(This,videoOutputConnection,active) )
-
-#define IDeckLinkConfiguration_v7_6_SetAnalogVideoOutputFlags(This,analogVideoFlags) \
- ( (This)->lpVtbl -> SetAnalogVideoOutputFlags(This,analogVideoFlags) )
-
-#define IDeckLinkConfiguration_v7_6_GetAnalogVideoOutputFlags(This,analogVideoFlags) \
- ( (This)->lpVtbl -> GetAnalogVideoOutputFlags(This,analogVideoFlags) )
-
-#define IDeckLinkConfiguration_v7_6_EnableFieldFlickerRemovalWhenPaused(This,enable) \
- ( (This)->lpVtbl -> EnableFieldFlickerRemovalWhenPaused(This,enable) )
-
-#define IDeckLinkConfiguration_v7_6_IsEnabledFieldFlickerRemovalWhenPaused(This,enabled) \
- ( (This)->lpVtbl -> IsEnabledFieldFlickerRemovalWhenPaused(This,enabled) )
-
-#define IDeckLinkConfiguration_v7_6_Set444And3GBpsVideoOutput(This,enable444VideoOutput,enable3GbsOutput) \
- ( (This)->lpVtbl -> Set444And3GBpsVideoOutput(This,enable444VideoOutput,enable3GbsOutput) )
-
-#define IDeckLinkConfiguration_v7_6_Get444And3GBpsVideoOutput(This,is444VideoOutputEnabled,threeGbsOutputEnabled) \
- ( (This)->lpVtbl -> Get444And3GBpsVideoOutput(This,is444VideoOutputEnabled,threeGbsOutputEnabled) )
-
-#define IDeckLinkConfiguration_v7_6_SetVideoOutputConversionMode(This,conversionMode) \
- ( (This)->lpVtbl -> SetVideoOutputConversionMode(This,conversionMode) )
-
-#define IDeckLinkConfiguration_v7_6_GetVideoOutputConversionMode(This,conversionMode) \
- ( (This)->lpVtbl -> GetVideoOutputConversionMode(This,conversionMode) )
-
-#define IDeckLinkConfiguration_v7_6_Set_HD1080p24_to_HD1080i5994_Conversion(This,enable) \
- ( (This)->lpVtbl -> Set_HD1080p24_to_HD1080i5994_Conversion(This,enable) )
-
-#define IDeckLinkConfiguration_v7_6_Get_HD1080p24_to_HD1080i5994_Conversion(This,enabled) \
- ( (This)->lpVtbl -> Get_HD1080p24_to_HD1080i5994_Conversion(This,enabled) )
-
-#define IDeckLinkConfiguration_v7_6_SetVideoInputFormat(This,videoInputFormat) \
- ( (This)->lpVtbl -> SetVideoInputFormat(This,videoInputFormat) )
-
-#define IDeckLinkConfiguration_v7_6_GetVideoInputFormat(This,videoInputFormat) \
- ( (This)->lpVtbl -> GetVideoInputFormat(This,videoInputFormat) )
-
-#define IDeckLinkConfiguration_v7_6_SetAnalogVideoInputFlags(This,analogVideoFlags) \
- ( (This)->lpVtbl -> SetAnalogVideoInputFlags(This,analogVideoFlags) )
-
-#define IDeckLinkConfiguration_v7_6_GetAnalogVideoInputFlags(This,analogVideoFlags) \
- ( (This)->lpVtbl -> GetAnalogVideoInputFlags(This,analogVideoFlags) )
-
-#define IDeckLinkConfiguration_v7_6_SetVideoInputConversionMode(This,conversionMode) \
- ( (This)->lpVtbl -> SetVideoInputConversionMode(This,conversionMode) )
-
-#define IDeckLinkConfiguration_v7_6_GetVideoInputConversionMode(This,conversionMode) \
- ( (This)->lpVtbl -> GetVideoInputConversionMode(This,conversionMode) )
-
-#define IDeckLinkConfiguration_v7_6_SetBlackVideoOutputDuringCapture(This,blackOutInCapture) \
- ( (This)->lpVtbl -> SetBlackVideoOutputDuringCapture(This,blackOutInCapture) )
-
-#define IDeckLinkConfiguration_v7_6_GetBlackVideoOutputDuringCapture(This,blackOutInCapture) \
- ( (This)->lpVtbl -> GetBlackVideoOutputDuringCapture(This,blackOutInCapture) )
-
-#define IDeckLinkConfiguration_v7_6_Set32PulldownSequenceInitialTimecodeFrame(This,aFrameTimecode) \
- ( (This)->lpVtbl -> Set32PulldownSequenceInitialTimecodeFrame(This,aFrameTimecode) )
-
-#define IDeckLinkConfiguration_v7_6_Get32PulldownSequenceInitialTimecodeFrame(This,aFrameTimecode) \
- ( (This)->lpVtbl -> Get32PulldownSequenceInitialTimecodeFrame(This,aFrameTimecode) )
-
-#define IDeckLinkConfiguration_v7_6_SetVancSourceLineMapping(This,activeLine1VANCsource,activeLine2VANCsource,activeLine3VANCsource) \
- ( (This)->lpVtbl -> SetVancSourceLineMapping(This,activeLine1VANCsource,activeLine2VANCsource,activeLine3VANCsource) )
-
-#define IDeckLinkConfiguration_v7_6_GetVancSourceLineMapping(This,activeLine1VANCsource,activeLine2VANCsource,activeLine3VANCsource) \
- ( (This)->lpVtbl -> GetVancSourceLineMapping(This,activeLine1VANCsource,activeLine2VANCsource,activeLine3VANCsource) )
-
-#define IDeckLinkConfiguration_v7_6_SetAudioInputFormat(This,audioInputFormat) \
- ( (This)->lpVtbl -> SetAudioInputFormat(This,audioInputFormat) )
-
-#define IDeckLinkConfiguration_v7_6_GetAudioInputFormat(This,audioInputFormat) \
- ( (This)->lpVtbl -> GetAudioInputFormat(This,audioInputFormat) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkConfiguration_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoOutputCallback_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkVideoOutputCallback_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoOutputCallback_v7_6 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoOutputCallback_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("E763A626-4A3C-49D1-BF13-E7AD3692AE52")
- IDeckLinkVideoOutputCallback_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted(
- /* [in] */ IDeckLinkVideoFrame_v7_6 *completedFrame,
- /* [in] */ BMDOutputFrameCompletionResult result) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduledPlaybackHasStopped( void) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoOutputCallback_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoOutputCallback_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoOutputCallback_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoOutputCallback_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduledFrameCompleted )(
- IDeckLinkVideoOutputCallback_v7_6 * This,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *completedFrame,
- /* [in] */ BMDOutputFrameCompletionResult result);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduledPlaybackHasStopped )(
- IDeckLinkVideoOutputCallback_v7_6 * This);
-
- END_INTERFACE
- } IDeckLinkVideoOutputCallback_v7_6Vtbl;
-
- interface IDeckLinkVideoOutputCallback_v7_6
- {
- CONST_VTBL struct IDeckLinkVideoOutputCallback_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoOutputCallback_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoOutputCallback_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoOutputCallback_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoOutputCallback_v7_6_ScheduledFrameCompleted(This,completedFrame,result) \
- ( (This)->lpVtbl -> ScheduledFrameCompleted(This,completedFrame,result) )
-
-#define IDeckLinkVideoOutputCallback_v7_6_ScheduledPlaybackHasStopped(This) \
- ( (This)->lpVtbl -> ScheduledPlaybackHasStopped(This) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoOutputCallback_v7_6_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkInputCallback_v7_6_INTERFACE_DEFINED__
-#define __IDeckLinkInputCallback_v7_6_INTERFACE_DEFINED__
-
-/* interface IDeckLinkInputCallback_v7_6 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkInputCallback_v7_6;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("31D28EE7-88B6-4CB1-897A-CDBF79A26414")
- IDeckLinkInputCallback_v7_6 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(
- /* [in] */ BMDVideoInputFormatChangedEvents notificationEvents,
- /* [in] */ IDeckLinkDisplayMode_v7_6 *newDisplayMode,
- /* [in] */ BMDDetectedVideoInputFormatFlags detectedSignalFlags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(
- /* [in] */ IDeckLinkVideoInputFrame_v7_6 *videoFrame,
- /* [in] */ IDeckLinkAudioInputPacket *audioPacket) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkInputCallback_v7_6Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkInputCallback_v7_6 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkInputCallback_v7_6 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkInputCallback_v7_6 * This);
-
- HRESULT ( STDMETHODCALLTYPE *VideoInputFormatChanged )(
- IDeckLinkInputCallback_v7_6 * This,
- /* [in] */ BMDVideoInputFormatChangedEvents notificationEvents,
- /* [in] */ IDeckLinkDisplayMode_v7_6 *newDisplayMode,
- /* [in] */ BMDDetectedVideoInputFormatFlags detectedSignalFlags);
-
- HRESULT ( STDMETHODCALLTYPE *VideoInputFrameArrived )(
- IDeckLinkInputCallback_v7_6 * This,
- /* [in] */ IDeckLinkVideoInputFrame_v7_6 *videoFrame,
- /* [in] */ IDeckLinkAudioInputPacket *audioPacket);
-
- END_INTERFACE
- } IDeckLinkInputCallback_v7_6Vtbl;
-
- interface IDeckLinkInputCallback_v7_6
- {
- CONST_VTBL struct IDeckLinkInputCallback_v7_6Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkInputCallback_v7_6_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkInputCallback_v7_6_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkInputCallback_v7_6_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkInputCallback_v7_6_VideoInputFormatChanged(This,notificationEvents,newDisplayMode,detectedSignalFlags) \
- ( (This)->lpVtbl -> VideoInputFormatChanged(This,notificationEvents,newDisplayMode,detectedSignalFlags) )
-
-#define IDeckLinkInputCallback_v7_6_VideoInputFrameArrived(This,videoFrame,audioPacket) \
- ( (This)->lpVtbl -> VideoInputFrameArrived(This,videoFrame,audioPacket) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkInputCallback_v7_6_INTERFACE_DEFINED__ */
-
-
-EXTERN_C const CLSID CLSID_CDeckLinkGLScreenPreviewHelper_v7_6;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("D398CEE7-4434-4CA3-9BA6-5AE34556B905")
-CDeckLinkGLScreenPreviewHelper_v7_6;
-#endif
-
-EXTERN_C const CLSID CLSID_CDeckLinkVideoConversion_v7_6;
-
-#ifdef __cplusplus
-
-class DECLSPEC_UUID("FFA84F77-73BE-4FB7-B03E-B5E44B9F759B")
-CDeckLinkVideoConversion_v7_6;
-#endif
-
-#ifndef __IDeckLinkInputCallback_v7_3_INTERFACE_DEFINED__
-#define __IDeckLinkInputCallback_v7_3_INTERFACE_DEFINED__
-
-/* interface IDeckLinkInputCallback_v7_3 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkInputCallback_v7_3;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("FD6F311D-4D00-444B-9ED4-1F25B5730AD0")
- IDeckLinkInputCallback_v7_3 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(
- /* [in] */ BMDVideoInputFormatChangedEvents notificationEvents,
- /* [in] */ IDeckLinkDisplayMode_v7_6 *newDisplayMode,
- /* [in] */ BMDDetectedVideoInputFormatFlags detectedSignalFlags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(
- /* [in] */ IDeckLinkVideoInputFrame_v7_3 *videoFrame,
- /* [in] */ IDeckLinkAudioInputPacket *audioPacket) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkInputCallback_v7_3Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkInputCallback_v7_3 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkInputCallback_v7_3 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkInputCallback_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *VideoInputFormatChanged )(
- IDeckLinkInputCallback_v7_3 * This,
- /* [in] */ BMDVideoInputFormatChangedEvents notificationEvents,
- /* [in] */ IDeckLinkDisplayMode_v7_6 *newDisplayMode,
- /* [in] */ BMDDetectedVideoInputFormatFlags detectedSignalFlags);
-
- HRESULT ( STDMETHODCALLTYPE *VideoInputFrameArrived )(
- IDeckLinkInputCallback_v7_3 * This,
- /* [in] */ IDeckLinkVideoInputFrame_v7_3 *videoFrame,
- /* [in] */ IDeckLinkAudioInputPacket *audioPacket);
-
- END_INTERFACE
- } IDeckLinkInputCallback_v7_3Vtbl;
-
- interface IDeckLinkInputCallback_v7_3
- {
- CONST_VTBL struct IDeckLinkInputCallback_v7_3Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkInputCallback_v7_3_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkInputCallback_v7_3_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkInputCallback_v7_3_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkInputCallback_v7_3_VideoInputFormatChanged(This,notificationEvents,newDisplayMode,detectedSignalFlags) \
- ( (This)->lpVtbl -> VideoInputFormatChanged(This,notificationEvents,newDisplayMode,detectedSignalFlags) )
-
-#define IDeckLinkInputCallback_v7_3_VideoInputFrameArrived(This,videoFrame,audioPacket) \
- ( (This)->lpVtbl -> VideoInputFrameArrived(This,videoFrame,audioPacket) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkInputCallback_v7_3_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_v7_3_INTERFACE_DEFINED__
-#define __IDeckLinkOutput_v7_3_INTERFACE_DEFINED__
-
-/* interface IDeckLinkOutput_v7_3 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkOutput_v7_3;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("271C65E3-C323-4344-A30F-D908BCB20AA3")
- IDeckLinkOutput_v7_3 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator_v7_6 **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScreenPreviewCallback(
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoOutput(
- BMDDisplayMode displayMode,
- BMDVideoOutputFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoOutputFrameMemoryAllocator(
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateVideoFrame(
- int width,
- int height,
- int rowBytes,
- BMDPixelFormat pixelFormat,
- BMDFrameFlags flags,
- /* [out] */ IDeckLinkMutableVideoFrame_v7_6 **outFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateAncillaryData(
- BMDPixelFormat pixelFormat,
- /* [out] */ IDeckLinkVideoFrameAncillary **outBuffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisplayVideoFrameSync(
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleVideoFrame(
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame,
- BMDTimeValue displayTime,
- BMDTimeValue displayDuration,
- BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScheduledFrameCompletionCallback(
- /* [in] */ IDeckLinkVideoOutputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedVideoFrameCount(
- /* [out] */ unsigned int *bufferedFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioOutput(
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount,
- BMDAudioOutputStreamType streamType) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE WriteAudioSamplesSync(
- /* [in] */ void *buffer,
- unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE BeginAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EndAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleAudioSamples(
- /* [in] */ void *buffer,
- unsigned int sampleFrameCount,
- BMDTimeValue streamTime,
- BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedAudioSampleFrameCount(
- /* [out] */ unsigned int *bufferedSampleFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FlushBufferedAudioSamples( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAudioCallback(
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartScheduledPlayback(
- BMDTimeValue playbackStartTime,
- BMDTimeScale timeScale,
- double playbackSpeed) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopScheduledPlayback(
- BMDTimeValue stopPlaybackAtTime,
- /* [out] */ BMDTimeValue *actualStopTime,
- BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IsScheduledPlaybackRunning(
- /* [out] */ BOOL *active) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceClock(
- BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *elapsedTimeSinceSchedulerBegan) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkOutput_v7_3Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkOutput_v7_3 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkOutput_v7_3 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkOutput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkOutput_v7_3 * This,
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkOutput_v7_3 * This,
- /* [out] */ IDeckLinkDisplayModeIterator_v7_6 **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *SetScreenPreviewCallback )(
- IDeckLinkOutput_v7_3 * This,
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoOutput )(
- IDeckLinkOutput_v7_3 * This,
- BMDDisplayMode displayMode,
- BMDVideoOutputFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoOutput )(
- IDeckLinkOutput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoOutputFrameMemoryAllocator )(
- IDeckLinkOutput_v7_3 * This,
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator);
-
- HRESULT ( STDMETHODCALLTYPE *CreateVideoFrame )(
- IDeckLinkOutput_v7_3 * This,
- int width,
- int height,
- int rowBytes,
- BMDPixelFormat pixelFormat,
- BMDFrameFlags flags,
- /* [out] */ IDeckLinkMutableVideoFrame_v7_6 **outFrame);
-
- HRESULT ( STDMETHODCALLTYPE *CreateAncillaryData )(
- IDeckLinkOutput_v7_3 * This,
- BMDPixelFormat pixelFormat,
- /* [out] */ IDeckLinkVideoFrameAncillary **outBuffer);
-
- HRESULT ( STDMETHODCALLTYPE *DisplayVideoFrameSync )(
- IDeckLinkOutput_v7_3 * This,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleVideoFrame )(
- IDeckLinkOutput_v7_3 * This,
- /* [in] */ IDeckLinkVideoFrame_v7_6 *theFrame,
- BMDTimeValue displayTime,
- BMDTimeValue displayDuration,
- BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *SetScheduledFrameCompletionCallback )(
- IDeckLinkOutput_v7_3 * This,
- /* [in] */ IDeckLinkVideoOutputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedVideoFrameCount )(
- IDeckLinkOutput_v7_3 * This,
- /* [out] */ unsigned int *bufferedFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioOutput )(
- IDeckLinkOutput_v7_3 * This,
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount,
- BMDAudioOutputStreamType streamType);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioOutput )(
- IDeckLinkOutput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *WriteAudioSamplesSync )(
- IDeckLinkOutput_v7_3 * This,
- /* [in] */ void *buffer,
- unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *BeginAudioPreroll )(
- IDeckLinkOutput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *EndAudioPreroll )(
- IDeckLinkOutput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleAudioSamples )(
- IDeckLinkOutput_v7_3 * This,
- /* [in] */ void *buffer,
- unsigned int sampleFrameCount,
- BMDTimeValue streamTime,
- BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedAudioSampleFrameCount )(
- IDeckLinkOutput_v7_3 * This,
- /* [out] */ unsigned int *bufferedSampleFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *FlushBufferedAudioSamples )(
- IDeckLinkOutput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetAudioCallback )(
- IDeckLinkOutput_v7_3 * This,
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *StartScheduledPlayback )(
- IDeckLinkOutput_v7_3 * This,
- BMDTimeValue playbackStartTime,
- BMDTimeScale timeScale,
- double playbackSpeed);
-
- HRESULT ( STDMETHODCALLTYPE *StopScheduledPlayback )(
- IDeckLinkOutput_v7_3 * This,
- BMDTimeValue stopPlaybackAtTime,
- /* [out] */ BMDTimeValue *actualStopTime,
- BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *IsScheduledPlaybackRunning )(
- IDeckLinkOutput_v7_3 * This,
- /* [out] */ BOOL *active);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceClock )(
- IDeckLinkOutput_v7_3 * This,
- BMDTimeScale desiredTimeScale,
- /* [out] */ BMDTimeValue *elapsedTimeSinceSchedulerBegan);
-
- END_INTERFACE
- } IDeckLinkOutput_v7_3Vtbl;
-
- interface IDeckLinkOutput_v7_3
- {
- CONST_VTBL struct IDeckLinkOutput_v7_3Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkOutput_v7_3_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkOutput_v7_3_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkOutput_v7_3_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkOutput_v7_3_DoesSupportVideoMode(This,displayMode,pixelFormat,result) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,result) )
-
-#define IDeckLinkOutput_v7_3_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkOutput_v7_3_SetScreenPreviewCallback(This,previewCallback) \
- ( (This)->lpVtbl -> SetScreenPreviewCallback(This,previewCallback) )
-
-#define IDeckLinkOutput_v7_3_EnableVideoOutput(This,displayMode,flags) \
- ( (This)->lpVtbl -> EnableVideoOutput(This,displayMode,flags) )
-
-#define IDeckLinkOutput_v7_3_DisableVideoOutput(This) \
- ( (This)->lpVtbl -> DisableVideoOutput(This) )
-
-#define IDeckLinkOutput_v7_3_SetVideoOutputFrameMemoryAllocator(This,theAllocator) \
- ( (This)->lpVtbl -> SetVideoOutputFrameMemoryAllocator(This,theAllocator) )
-
-#define IDeckLinkOutput_v7_3_CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) \
- ( (This)->lpVtbl -> CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) )
-
-#define IDeckLinkOutput_v7_3_CreateAncillaryData(This,pixelFormat,outBuffer) \
- ( (This)->lpVtbl -> CreateAncillaryData(This,pixelFormat,outBuffer) )
-
-#define IDeckLinkOutput_v7_3_DisplayVideoFrameSync(This,theFrame) \
- ( (This)->lpVtbl -> DisplayVideoFrameSync(This,theFrame) )
-
-#define IDeckLinkOutput_v7_3_ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) \
- ( (This)->lpVtbl -> ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) )
-
-#define IDeckLinkOutput_v7_3_SetScheduledFrameCompletionCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetScheduledFrameCompletionCallback(This,theCallback) )
-
-#define IDeckLinkOutput_v7_3_GetBufferedVideoFrameCount(This,bufferedFrameCount) \
- ( (This)->lpVtbl -> GetBufferedVideoFrameCount(This,bufferedFrameCount) )
-
-#define IDeckLinkOutput_v7_3_EnableAudioOutput(This,sampleRate,sampleType,channelCount,streamType) \
- ( (This)->lpVtbl -> EnableAudioOutput(This,sampleRate,sampleType,channelCount,streamType) )
-
-#define IDeckLinkOutput_v7_3_DisableAudioOutput(This) \
- ( (This)->lpVtbl -> DisableAudioOutput(This) )
-
-#define IDeckLinkOutput_v7_3_WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) \
- ( (This)->lpVtbl -> WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) )
-
-#define IDeckLinkOutput_v7_3_BeginAudioPreroll(This) \
- ( (This)->lpVtbl -> BeginAudioPreroll(This) )
-
-#define IDeckLinkOutput_v7_3_EndAudioPreroll(This) \
- ( (This)->lpVtbl -> EndAudioPreroll(This) )
-
-#define IDeckLinkOutput_v7_3_ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) \
- ( (This)->lpVtbl -> ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) )
-
-#define IDeckLinkOutput_v7_3_GetBufferedAudioSampleFrameCount(This,bufferedSampleFrameCount) \
- ( (This)->lpVtbl -> GetBufferedAudioSampleFrameCount(This,bufferedSampleFrameCount) )
-
-#define IDeckLinkOutput_v7_3_FlushBufferedAudioSamples(This) \
- ( (This)->lpVtbl -> FlushBufferedAudioSamples(This) )
-
-#define IDeckLinkOutput_v7_3_SetAudioCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetAudioCallback(This,theCallback) )
-
-#define IDeckLinkOutput_v7_3_StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) \
- ( (This)->lpVtbl -> StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) )
-
-#define IDeckLinkOutput_v7_3_StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) \
- ( (This)->lpVtbl -> StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) )
-
-#define IDeckLinkOutput_v7_3_IsScheduledPlaybackRunning(This,active) \
- ( (This)->lpVtbl -> IsScheduledPlaybackRunning(This,active) )
-
-#define IDeckLinkOutput_v7_3_GetHardwareReferenceClock(This,desiredTimeScale,elapsedTimeSinceSchedulerBegan) \
- ( (This)->lpVtbl -> GetHardwareReferenceClock(This,desiredTimeScale,elapsedTimeSinceSchedulerBegan) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkOutput_v7_3_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_v7_3_INTERFACE_DEFINED__
-#define __IDeckLinkInput_v7_3_INTERFACE_DEFINED__
-
-/* interface IDeckLinkInput_v7_3 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkInput_v7_3;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("4973F012-9925-458C-871C-18774CDBBECB")
- IDeckLinkInput_v7_3 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator_v7_6 **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScreenPreviewCallback(
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoInput(
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- BMDVideoInputFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAvailableVideoFrameCount(
- /* [out] */ unsigned int *availableFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioInput(
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAvailableAudioSampleFrameCount(
- /* [out] */ unsigned int *availableSampleFrameCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE PauseStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FlushStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- /* [in] */ IDeckLinkInputCallback_v7_3 *theCallback) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkInput_v7_3Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkInput_v7_3 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkInput_v7_3 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkInput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkInput_v7_3 * This,
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkInput_v7_3 * This,
- /* [out] */ IDeckLinkDisplayModeIterator_v7_6 **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *SetScreenPreviewCallback )(
- IDeckLinkInput_v7_3 * This,
- /* [in] */ IDeckLinkScreenPreviewCallback *previewCallback);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoInput )(
- IDeckLinkInput_v7_3 * This,
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- BMDVideoInputFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoInput )(
- IDeckLinkInput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetAvailableVideoFrameCount )(
- IDeckLinkInput_v7_3 * This,
- /* [out] */ unsigned int *availableFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioInput )(
- IDeckLinkInput_v7_3 * This,
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioInput )(
- IDeckLinkInput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetAvailableAudioSampleFrameCount )(
- IDeckLinkInput_v7_3 * This,
- /* [out] */ unsigned int *availableSampleFrameCount);
-
- HRESULT ( STDMETHODCALLTYPE *StartStreams )(
- IDeckLinkInput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *StopStreams )(
- IDeckLinkInput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *PauseStreams )(
- IDeckLinkInput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *FlushStreams )(
- IDeckLinkInput_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetCallback )(
- IDeckLinkInput_v7_3 * This,
- /* [in] */ IDeckLinkInputCallback_v7_3 *theCallback);
-
- END_INTERFACE
- } IDeckLinkInput_v7_3Vtbl;
-
- interface IDeckLinkInput_v7_3
- {
- CONST_VTBL struct IDeckLinkInput_v7_3Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkInput_v7_3_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkInput_v7_3_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkInput_v7_3_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkInput_v7_3_DoesSupportVideoMode(This,displayMode,pixelFormat,result) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,result) )
-
-#define IDeckLinkInput_v7_3_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkInput_v7_3_SetScreenPreviewCallback(This,previewCallback) \
- ( (This)->lpVtbl -> SetScreenPreviewCallback(This,previewCallback) )
-
-#define IDeckLinkInput_v7_3_EnableVideoInput(This,displayMode,pixelFormat,flags) \
- ( (This)->lpVtbl -> EnableVideoInput(This,displayMode,pixelFormat,flags) )
-
-#define IDeckLinkInput_v7_3_DisableVideoInput(This) \
- ( (This)->lpVtbl -> DisableVideoInput(This) )
-
-#define IDeckLinkInput_v7_3_GetAvailableVideoFrameCount(This,availableFrameCount) \
- ( (This)->lpVtbl -> GetAvailableVideoFrameCount(This,availableFrameCount) )
-
-#define IDeckLinkInput_v7_3_EnableAudioInput(This,sampleRate,sampleType,channelCount) \
- ( (This)->lpVtbl -> EnableAudioInput(This,sampleRate,sampleType,channelCount) )
-
-#define IDeckLinkInput_v7_3_DisableAudioInput(This) \
- ( (This)->lpVtbl -> DisableAudioInput(This) )
-
-#define IDeckLinkInput_v7_3_GetAvailableAudioSampleFrameCount(This,availableSampleFrameCount) \
- ( (This)->lpVtbl -> GetAvailableAudioSampleFrameCount(This,availableSampleFrameCount) )
-
-#define IDeckLinkInput_v7_3_StartStreams(This) \
- ( (This)->lpVtbl -> StartStreams(This) )
-
-#define IDeckLinkInput_v7_3_StopStreams(This) \
- ( (This)->lpVtbl -> StopStreams(This) )
-
-#define IDeckLinkInput_v7_3_PauseStreams(This) \
- ( (This)->lpVtbl -> PauseStreams(This) )
-
-#define IDeckLinkInput_v7_3_FlushStreams(This) \
- ( (This)->lpVtbl -> FlushStreams(This) )
-
-#define IDeckLinkInput_v7_3_SetCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetCallback(This,theCallback) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkInput_v7_3_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoInputFrame_v7_3_INTERFACE_DEFINED__
-#define __IDeckLinkVideoInputFrame_v7_3_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoInputFrame_v7_3 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoInputFrame_v7_3;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("CF317790-2894-11DE-8C30-0800200C9A66")
- IDeckLinkVideoInputFrame_v7_3 : public IDeckLinkVideoFrame_v7_6
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetStreamTime(
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration,
- BMDTimeScale timeScale) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoInputFrame_v7_3Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoInputFrame_v7_3 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoInputFrame_v7_3 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoInputFrame_v7_3 * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkVideoInputFrame_v7_3 * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkVideoInputFrame_v7_3 * This);
-
- long ( STDMETHODCALLTYPE *GetRowBytes )(
- IDeckLinkVideoInputFrame_v7_3 * This);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkVideoInputFrame_v7_3 * This);
-
- BMDFrameFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkVideoInputFrame_v7_3 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkVideoInputFrame_v7_3 * This,
- /* [out] */ void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetTimecode )(
- IDeckLinkVideoInputFrame_v7_3 * This,
- BMDTimecodeFormat format,
- /* [out] */ IDeckLinkTimecode_v7_6 **timecode);
-
- HRESULT ( STDMETHODCALLTYPE *GetAncillaryData )(
- IDeckLinkVideoInputFrame_v7_3 * This,
- /* [out] */ IDeckLinkVideoFrameAncillary **ancillary);
-
- HRESULT ( STDMETHODCALLTYPE *GetStreamTime )(
- IDeckLinkVideoInputFrame_v7_3 * This,
- /* [out] */ BMDTimeValue *frameTime,
- /* [out] */ BMDTimeValue *frameDuration,
- BMDTimeScale timeScale);
-
- END_INTERFACE
- } IDeckLinkVideoInputFrame_v7_3Vtbl;
-
- interface IDeckLinkVideoInputFrame_v7_3
- {
- CONST_VTBL struct IDeckLinkVideoInputFrame_v7_3Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoInputFrame_v7_3_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoInputFrame_v7_3_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoInputFrame_v7_3_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoInputFrame_v7_3_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkVideoInputFrame_v7_3_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkVideoInputFrame_v7_3_GetRowBytes(This) \
- ( (This)->lpVtbl -> GetRowBytes(This) )
-
-#define IDeckLinkVideoInputFrame_v7_3_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkVideoInputFrame_v7_3_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkVideoInputFrame_v7_3_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IDeckLinkVideoInputFrame_v7_3_GetTimecode(This,format,timecode) \
- ( (This)->lpVtbl -> GetTimecode(This,format,timecode) )
-
-#define IDeckLinkVideoInputFrame_v7_3_GetAncillaryData(This,ancillary) \
- ( (This)->lpVtbl -> GetAncillaryData(This,ancillary) )
-
-
-#define IDeckLinkVideoInputFrame_v7_3_GetStreamTime(This,frameTime,frameDuration,timeScale) \
- ( (This)->lpVtbl -> GetStreamTime(This,frameTime,frameDuration,timeScale) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoInputFrame_v7_3_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayModeIterator_v7_1_INTERFACE_DEFINED__
-#define __IDeckLinkDisplayModeIterator_v7_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDisplayModeIterator_v7_1 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDisplayModeIterator_v7_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("B28131B6-59AC-4857-B5AC-CD75D5883E2F")
- IDeckLinkDisplayModeIterator_v7_1 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE Next(
- /* [out] */ IDeckLinkDisplayMode_v7_1 **deckLinkDisplayMode) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDisplayModeIterator_v7_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDisplayModeIterator_v7_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDisplayModeIterator_v7_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDisplayModeIterator_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *Next )(
- IDeckLinkDisplayModeIterator_v7_1 * This,
- /* [out] */ IDeckLinkDisplayMode_v7_1 **deckLinkDisplayMode);
-
- END_INTERFACE
- } IDeckLinkDisplayModeIterator_v7_1Vtbl;
-
- interface IDeckLinkDisplayModeIterator_v7_1
- {
- CONST_VTBL struct IDeckLinkDisplayModeIterator_v7_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDisplayModeIterator_v7_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDisplayModeIterator_v7_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDisplayModeIterator_v7_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDisplayModeIterator_v7_1_Next(This,deckLinkDisplayMode) \
- ( (This)->lpVtbl -> Next(This,deckLinkDisplayMode) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDisplayModeIterator_v7_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkDisplayMode_v7_1_INTERFACE_DEFINED__
-#define __IDeckLinkDisplayMode_v7_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkDisplayMode_v7_1 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkDisplayMode_v7_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("AF0CD6D5-8376-435E-8433-54F9DD530AC3")
- IDeckLinkDisplayMode_v7_1 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetName(
- /* [out] */ BSTR *name) = 0;
-
- virtual BMDDisplayMode STDMETHODCALLTYPE GetDisplayMode( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetWidth( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetHeight( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetFrameRate(
- /* [out] */ BMDTimeValue *frameDuration,
- /* [out] */ BMDTimeScale *timeScale) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkDisplayMode_v7_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkDisplayMode_v7_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkDisplayMode_v7_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkDisplayMode_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetName )(
- IDeckLinkDisplayMode_v7_1 * This,
- /* [out] */ BSTR *name);
-
- BMDDisplayMode ( STDMETHODCALLTYPE *GetDisplayMode )(
- IDeckLinkDisplayMode_v7_1 * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkDisplayMode_v7_1 * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkDisplayMode_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetFrameRate )(
- IDeckLinkDisplayMode_v7_1 * This,
- /* [out] */ BMDTimeValue *frameDuration,
- /* [out] */ BMDTimeScale *timeScale);
-
- END_INTERFACE
- } IDeckLinkDisplayMode_v7_1Vtbl;
-
- interface IDeckLinkDisplayMode_v7_1
- {
- CONST_VTBL struct IDeckLinkDisplayMode_v7_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkDisplayMode_v7_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkDisplayMode_v7_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkDisplayMode_v7_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkDisplayMode_v7_1_GetName(This,name) \
- ( (This)->lpVtbl -> GetName(This,name) )
-
-#define IDeckLinkDisplayMode_v7_1_GetDisplayMode(This) \
- ( (This)->lpVtbl -> GetDisplayMode(This) )
-
-#define IDeckLinkDisplayMode_v7_1_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkDisplayMode_v7_1_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkDisplayMode_v7_1_GetFrameRate(This,frameDuration,timeScale) \
- ( (This)->lpVtbl -> GetFrameRate(This,frameDuration,timeScale) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkDisplayMode_v7_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoFrame_v7_1_INTERFACE_DEFINED__
-#define __IDeckLinkVideoFrame_v7_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoFrame_v7_1 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoFrame_v7_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("333F3A10-8C2D-43CF-B79D-46560FEEA1CE")
- IDeckLinkVideoFrame_v7_1 : public IUnknown
- {
- public:
- virtual long STDMETHODCALLTYPE GetWidth( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetHeight( void) = 0;
-
- virtual long STDMETHODCALLTYPE GetRowBytes( void) = 0;
-
- virtual BMDPixelFormat STDMETHODCALLTYPE GetPixelFormat( void) = 0;
-
- virtual BMDFrameFlags STDMETHODCALLTYPE GetFlags( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBytes(
- void **buffer) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoFrame_v7_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoFrame_v7_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoFrame_v7_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoFrame_v7_1 * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkVideoFrame_v7_1 * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkVideoFrame_v7_1 * This);
-
- long ( STDMETHODCALLTYPE *GetRowBytes )(
- IDeckLinkVideoFrame_v7_1 * This);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkVideoFrame_v7_1 * This);
-
- BMDFrameFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkVideoFrame_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkVideoFrame_v7_1 * This,
- void **buffer);
-
- END_INTERFACE
- } IDeckLinkVideoFrame_v7_1Vtbl;
-
- interface IDeckLinkVideoFrame_v7_1
- {
- CONST_VTBL struct IDeckLinkVideoFrame_v7_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoFrame_v7_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoFrame_v7_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoFrame_v7_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoFrame_v7_1_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkVideoFrame_v7_1_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkVideoFrame_v7_1_GetRowBytes(This) \
- ( (This)->lpVtbl -> GetRowBytes(This) )
-
-#define IDeckLinkVideoFrame_v7_1_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkVideoFrame_v7_1_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkVideoFrame_v7_1_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoFrame_v7_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoInputFrame_v7_1_INTERFACE_DEFINED__
-#define __IDeckLinkVideoInputFrame_v7_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoInputFrame_v7_1 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoInputFrame_v7_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("C8B41D95-8848-40EE-9B37-6E3417FB114B")
- IDeckLinkVideoInputFrame_v7_1 : public IDeckLinkVideoFrame_v7_1
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE GetFrameTime(
- BMDTimeValue *frameTime,
- BMDTimeValue *frameDuration,
- BMDTimeScale timeScale) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoInputFrame_v7_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoInputFrame_v7_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoInputFrame_v7_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoInputFrame_v7_1 * This);
-
- long ( STDMETHODCALLTYPE *GetWidth )(
- IDeckLinkVideoInputFrame_v7_1 * This);
-
- long ( STDMETHODCALLTYPE *GetHeight )(
- IDeckLinkVideoInputFrame_v7_1 * This);
-
- long ( STDMETHODCALLTYPE *GetRowBytes )(
- IDeckLinkVideoInputFrame_v7_1 * This);
-
- BMDPixelFormat ( STDMETHODCALLTYPE *GetPixelFormat )(
- IDeckLinkVideoInputFrame_v7_1 * This);
-
- BMDFrameFlags ( STDMETHODCALLTYPE *GetFlags )(
- IDeckLinkVideoInputFrame_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkVideoInputFrame_v7_1 * This,
- void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetFrameTime )(
- IDeckLinkVideoInputFrame_v7_1 * This,
- BMDTimeValue *frameTime,
- BMDTimeValue *frameDuration,
- BMDTimeScale timeScale);
-
- END_INTERFACE
- } IDeckLinkVideoInputFrame_v7_1Vtbl;
-
- interface IDeckLinkVideoInputFrame_v7_1
- {
- CONST_VTBL struct IDeckLinkVideoInputFrame_v7_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoInputFrame_v7_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoInputFrame_v7_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoInputFrame_v7_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoInputFrame_v7_1_GetWidth(This) \
- ( (This)->lpVtbl -> GetWidth(This) )
-
-#define IDeckLinkVideoInputFrame_v7_1_GetHeight(This) \
- ( (This)->lpVtbl -> GetHeight(This) )
-
-#define IDeckLinkVideoInputFrame_v7_1_GetRowBytes(This) \
- ( (This)->lpVtbl -> GetRowBytes(This) )
-
-#define IDeckLinkVideoInputFrame_v7_1_GetPixelFormat(This) \
- ( (This)->lpVtbl -> GetPixelFormat(This) )
-
-#define IDeckLinkVideoInputFrame_v7_1_GetFlags(This) \
- ( (This)->lpVtbl -> GetFlags(This) )
-
-#define IDeckLinkVideoInputFrame_v7_1_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-
-#define IDeckLinkVideoInputFrame_v7_1_GetFrameTime(This,frameTime,frameDuration,timeScale) \
- ( (This)->lpVtbl -> GetFrameTime(This,frameTime,frameDuration,timeScale) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoInputFrame_v7_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkAudioInputPacket_v7_1_INTERFACE_DEFINED__
-#define __IDeckLinkAudioInputPacket_v7_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkAudioInputPacket_v7_1 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkAudioInputPacket_v7_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("C86DE4F6-A29F-42E3-AB3A-1363E29F0788")
- IDeckLinkAudioInputPacket_v7_1 : public IUnknown
- {
- public:
- virtual long STDMETHODCALLTYPE GetSampleCount( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBytes(
- void **buffer) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetAudioPacketTime(
- BMDTimeValue *packetTime,
- BMDTimeScale timeScale) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkAudioInputPacket_v7_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkAudioInputPacket_v7_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkAudioInputPacket_v7_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkAudioInputPacket_v7_1 * This);
-
- long ( STDMETHODCALLTYPE *GetSampleCount )(
- IDeckLinkAudioInputPacket_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetBytes )(
- IDeckLinkAudioInputPacket_v7_1 * This,
- void **buffer);
-
- HRESULT ( STDMETHODCALLTYPE *GetAudioPacketTime )(
- IDeckLinkAudioInputPacket_v7_1 * This,
- BMDTimeValue *packetTime,
- BMDTimeScale timeScale);
-
- END_INTERFACE
- } IDeckLinkAudioInputPacket_v7_1Vtbl;
-
- interface IDeckLinkAudioInputPacket_v7_1
- {
- CONST_VTBL struct IDeckLinkAudioInputPacket_v7_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkAudioInputPacket_v7_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkAudioInputPacket_v7_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkAudioInputPacket_v7_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkAudioInputPacket_v7_1_GetSampleCount(This) \
- ( (This)->lpVtbl -> GetSampleCount(This) )
-
-#define IDeckLinkAudioInputPacket_v7_1_GetBytes(This,buffer) \
- ( (This)->lpVtbl -> GetBytes(This,buffer) )
-
-#define IDeckLinkAudioInputPacket_v7_1_GetAudioPacketTime(This,packetTime,timeScale) \
- ( (This)->lpVtbl -> GetAudioPacketTime(This,packetTime,timeScale) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkAudioInputPacket_v7_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkVideoOutputCallback_v7_1_INTERFACE_DEFINED__
-#define __IDeckLinkVideoOutputCallback_v7_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkVideoOutputCallback_v7_1 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkVideoOutputCallback_v7_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("EBD01AFA-E4B0-49C6-A01D-EDB9D1B55FD9")
- IDeckLinkVideoOutputCallback_v7_1 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted(
- /* [in] */ IDeckLinkVideoFrame_v7_1 *completedFrame,
- /* [in] */ BMDOutputFrameCompletionResult result) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkVideoOutputCallback_v7_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkVideoOutputCallback_v7_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkVideoOutputCallback_v7_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkVideoOutputCallback_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduledFrameCompleted )(
- IDeckLinkVideoOutputCallback_v7_1 * This,
- /* [in] */ IDeckLinkVideoFrame_v7_1 *completedFrame,
- /* [in] */ BMDOutputFrameCompletionResult result);
-
- END_INTERFACE
- } IDeckLinkVideoOutputCallback_v7_1Vtbl;
-
- interface IDeckLinkVideoOutputCallback_v7_1
- {
- CONST_VTBL struct IDeckLinkVideoOutputCallback_v7_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkVideoOutputCallback_v7_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkVideoOutputCallback_v7_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkVideoOutputCallback_v7_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkVideoOutputCallback_v7_1_ScheduledFrameCompleted(This,completedFrame,result) \
- ( (This)->lpVtbl -> ScheduledFrameCompleted(This,completedFrame,result) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkVideoOutputCallback_v7_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkInputCallback_v7_1_INTERFACE_DEFINED__
-#define __IDeckLinkInputCallback_v7_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkInputCallback_v7_1 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkInputCallback_v7_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("7F94F328-5ED4-4E9F-9729-76A86BDC99CC")
- IDeckLinkInputCallback_v7_1 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(
- /* [in] */ IDeckLinkVideoInputFrame_v7_1 *videoFrame,
- /* [in] */ IDeckLinkAudioInputPacket_v7_1 *audioPacket) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkInputCallback_v7_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkInputCallback_v7_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkInputCallback_v7_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkInputCallback_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *VideoInputFrameArrived )(
- IDeckLinkInputCallback_v7_1 * This,
- /* [in] */ IDeckLinkVideoInputFrame_v7_1 *videoFrame,
- /* [in] */ IDeckLinkAudioInputPacket_v7_1 *audioPacket);
-
- END_INTERFACE
- } IDeckLinkInputCallback_v7_1Vtbl;
-
- interface IDeckLinkInputCallback_v7_1
- {
- CONST_VTBL struct IDeckLinkInputCallback_v7_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkInputCallback_v7_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkInputCallback_v7_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkInputCallback_v7_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkInputCallback_v7_1_VideoInputFrameArrived(This,videoFrame,audioPacket) \
- ( (This)->lpVtbl -> VideoInputFrameArrived(This,videoFrame,audioPacket) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkInputCallback_v7_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkOutput_v7_1_INTERFACE_DEFINED__
-#define __IDeckLinkOutput_v7_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkOutput_v7_1 */
-/* [helpstring][local][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkOutput_v7_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("AE5B3E9B-4E1E-4535-B6E8-480FF52F6CE5")
- IDeckLinkOutput_v7_1 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator_v7_1 **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoOutput(
- BMDDisplayMode displayMode) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoOutputFrameMemoryAllocator(
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateVideoFrame(
- int width,
- int height,
- int rowBytes,
- BMDPixelFormat pixelFormat,
- BMDFrameFlags flags,
- IDeckLinkVideoFrame_v7_1 **outFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE CreateVideoFrameFromBuffer(
- void *buffer,
- int width,
- int height,
- int rowBytes,
- BMDPixelFormat pixelFormat,
- BMDFrameFlags flags,
- IDeckLinkVideoFrame_v7_1 **outFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisplayVideoFrameSync(
- IDeckLinkVideoFrame_v7_1 *theFrame) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleVideoFrame(
- IDeckLinkVideoFrame_v7_1 *theFrame,
- BMDTimeValue displayTime,
- BMDTimeValue displayDuration,
- BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetScheduledFrameCompletionCallback(
- /* [in] */ IDeckLinkVideoOutputCallback_v7_1 *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioOutput(
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioOutput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE WriteAudioSamplesSync(
- void *buffer,
- unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE BeginAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EndAudioPreroll( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ScheduleAudioSamples(
- void *buffer,
- unsigned int sampleFrameCount,
- BMDTimeValue streamTime,
- BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedAudioSampleFrameCount(
- /* [out] */ unsigned int *bufferedSampleCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE FlushBufferedAudioSamples( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetAudioCallback(
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartScheduledPlayback(
- BMDTimeValue playbackStartTime,
- BMDTimeScale timeScale,
- double playbackSpeed) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopScheduledPlayback(
- BMDTimeValue stopPlaybackAtTime,
- BMDTimeValue *actualStopTime,
- BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetHardwareReferenceClock(
- BMDTimeScale desiredTimeScale,
- BMDTimeValue *elapsedTimeSinceSchedulerBegan) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkOutput_v7_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkOutput_v7_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkOutput_v7_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkOutput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkOutput_v7_1 * This,
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkOutput_v7_1 * This,
- /* [out] */ IDeckLinkDisplayModeIterator_v7_1 **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoOutput )(
- IDeckLinkOutput_v7_1 * This,
- BMDDisplayMode displayMode);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoOutput )(
- IDeckLinkOutput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetVideoOutputFrameMemoryAllocator )(
- IDeckLinkOutput_v7_1 * This,
- /* [in] */ IDeckLinkMemoryAllocator *theAllocator);
-
- HRESULT ( STDMETHODCALLTYPE *CreateVideoFrame )(
- IDeckLinkOutput_v7_1 * This,
- int width,
- int height,
- int rowBytes,
- BMDPixelFormat pixelFormat,
- BMDFrameFlags flags,
- IDeckLinkVideoFrame_v7_1 **outFrame);
-
- HRESULT ( STDMETHODCALLTYPE *CreateVideoFrameFromBuffer )(
- IDeckLinkOutput_v7_1 * This,
- void *buffer,
- int width,
- int height,
- int rowBytes,
- BMDPixelFormat pixelFormat,
- BMDFrameFlags flags,
- IDeckLinkVideoFrame_v7_1 **outFrame);
-
- HRESULT ( STDMETHODCALLTYPE *DisplayVideoFrameSync )(
- IDeckLinkOutput_v7_1 * This,
- IDeckLinkVideoFrame_v7_1 *theFrame);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleVideoFrame )(
- IDeckLinkOutput_v7_1 * This,
- IDeckLinkVideoFrame_v7_1 *theFrame,
- BMDTimeValue displayTime,
- BMDTimeValue displayDuration,
- BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *SetScheduledFrameCompletionCallback )(
- IDeckLinkOutput_v7_1 * This,
- /* [in] */ IDeckLinkVideoOutputCallback_v7_1 *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioOutput )(
- IDeckLinkOutput_v7_1 * This,
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioOutput )(
- IDeckLinkOutput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *WriteAudioSamplesSync )(
- IDeckLinkOutput_v7_1 * This,
- void *buffer,
- unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *BeginAudioPreroll )(
- IDeckLinkOutput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *EndAudioPreroll )(
- IDeckLinkOutput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *ScheduleAudioSamples )(
- IDeckLinkOutput_v7_1 * This,
- void *buffer,
- unsigned int sampleFrameCount,
- BMDTimeValue streamTime,
- BMDTimeScale timeScale,
- /* [out] */ unsigned int *sampleFramesWritten);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedAudioSampleFrameCount )(
- IDeckLinkOutput_v7_1 * This,
- /* [out] */ unsigned int *bufferedSampleCount);
-
- HRESULT ( STDMETHODCALLTYPE *FlushBufferedAudioSamples )(
- IDeckLinkOutput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetAudioCallback )(
- IDeckLinkOutput_v7_1 * This,
- /* [in] */ IDeckLinkAudioOutputCallback *theCallback);
-
- HRESULT ( STDMETHODCALLTYPE *StartScheduledPlayback )(
- IDeckLinkOutput_v7_1 * This,
- BMDTimeValue playbackStartTime,
- BMDTimeScale timeScale,
- double playbackSpeed);
-
- HRESULT ( STDMETHODCALLTYPE *StopScheduledPlayback )(
- IDeckLinkOutput_v7_1 * This,
- BMDTimeValue stopPlaybackAtTime,
- BMDTimeValue *actualStopTime,
- BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *GetHardwareReferenceClock )(
- IDeckLinkOutput_v7_1 * This,
- BMDTimeScale desiredTimeScale,
- BMDTimeValue *elapsedTimeSinceSchedulerBegan);
-
- END_INTERFACE
- } IDeckLinkOutput_v7_1Vtbl;
-
- interface IDeckLinkOutput_v7_1
- {
- CONST_VTBL struct IDeckLinkOutput_v7_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkOutput_v7_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkOutput_v7_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkOutput_v7_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkOutput_v7_1_DoesSupportVideoMode(This,displayMode,pixelFormat,result) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,result) )
-
-#define IDeckLinkOutput_v7_1_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkOutput_v7_1_EnableVideoOutput(This,displayMode) \
- ( (This)->lpVtbl -> EnableVideoOutput(This,displayMode) )
-
-#define IDeckLinkOutput_v7_1_DisableVideoOutput(This) \
- ( (This)->lpVtbl -> DisableVideoOutput(This) )
-
-#define IDeckLinkOutput_v7_1_SetVideoOutputFrameMemoryAllocator(This,theAllocator) \
- ( (This)->lpVtbl -> SetVideoOutputFrameMemoryAllocator(This,theAllocator) )
-
-#define IDeckLinkOutput_v7_1_CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) \
- ( (This)->lpVtbl -> CreateVideoFrame(This,width,height,rowBytes,pixelFormat,flags,outFrame) )
-
-#define IDeckLinkOutput_v7_1_CreateVideoFrameFromBuffer(This,buffer,width,height,rowBytes,pixelFormat,flags,outFrame) \
- ( (This)->lpVtbl -> CreateVideoFrameFromBuffer(This,buffer,width,height,rowBytes,pixelFormat,flags,outFrame) )
-
-#define IDeckLinkOutput_v7_1_DisplayVideoFrameSync(This,theFrame) \
- ( (This)->lpVtbl -> DisplayVideoFrameSync(This,theFrame) )
-
-#define IDeckLinkOutput_v7_1_ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) \
- ( (This)->lpVtbl -> ScheduleVideoFrame(This,theFrame,displayTime,displayDuration,timeScale) )
-
-#define IDeckLinkOutput_v7_1_SetScheduledFrameCompletionCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetScheduledFrameCompletionCallback(This,theCallback) )
-
-#define IDeckLinkOutput_v7_1_EnableAudioOutput(This,sampleRate,sampleType,channelCount) \
- ( (This)->lpVtbl -> EnableAudioOutput(This,sampleRate,sampleType,channelCount) )
-
-#define IDeckLinkOutput_v7_1_DisableAudioOutput(This) \
- ( (This)->lpVtbl -> DisableAudioOutput(This) )
-
-#define IDeckLinkOutput_v7_1_WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) \
- ( (This)->lpVtbl -> WriteAudioSamplesSync(This,buffer,sampleFrameCount,sampleFramesWritten) )
-
-#define IDeckLinkOutput_v7_1_BeginAudioPreroll(This) \
- ( (This)->lpVtbl -> BeginAudioPreroll(This) )
-
-#define IDeckLinkOutput_v7_1_EndAudioPreroll(This) \
- ( (This)->lpVtbl -> EndAudioPreroll(This) )
-
-#define IDeckLinkOutput_v7_1_ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) \
- ( (This)->lpVtbl -> ScheduleAudioSamples(This,buffer,sampleFrameCount,streamTime,timeScale,sampleFramesWritten) )
-
-#define IDeckLinkOutput_v7_1_GetBufferedAudioSampleFrameCount(This,bufferedSampleCount) \
- ( (This)->lpVtbl -> GetBufferedAudioSampleFrameCount(This,bufferedSampleCount) )
-
-#define IDeckLinkOutput_v7_1_FlushBufferedAudioSamples(This) \
- ( (This)->lpVtbl -> FlushBufferedAudioSamples(This) )
-
-#define IDeckLinkOutput_v7_1_SetAudioCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetAudioCallback(This,theCallback) )
-
-#define IDeckLinkOutput_v7_1_StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) \
- ( (This)->lpVtbl -> StartScheduledPlayback(This,playbackStartTime,timeScale,playbackSpeed) )
-
-#define IDeckLinkOutput_v7_1_StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) \
- ( (This)->lpVtbl -> StopScheduledPlayback(This,stopPlaybackAtTime,actualStopTime,timeScale) )
-
-#define IDeckLinkOutput_v7_1_GetHardwareReferenceClock(This,desiredTimeScale,elapsedTimeSinceSchedulerBegan) \
- ( (This)->lpVtbl -> GetHardwareReferenceClock(This,desiredTimeScale,elapsedTimeSinceSchedulerBegan) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkOutput_v7_1_INTERFACE_DEFINED__ */
-
-
-#ifndef __IDeckLinkInput_v7_1_INTERFACE_DEFINED__
-#define __IDeckLinkInput_v7_1_INTERFACE_DEFINED__
-
-/* interface IDeckLinkInput_v7_1 */
-/* [helpstring][uuid][object] */
-
-
-EXTERN_C const IID IID_IDeckLinkInput_v7_1;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("2B54EDEF-5B32-429F-BA11-BB990596EACD")
- IDeckLinkInput_v7_1 : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE DoesSupportVideoMode(
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetDisplayModeIterator(
- /* [out] */ IDeckLinkDisplayModeIterator_v7_1 **iterator) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableVideoInput(
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- BMDVideoInputFlags flags) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableVideoInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnableAudioInput(
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE DisableAudioInput( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE ReadAudioSamples(
- void *buffer,
- unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesRead,
- /* [out] */ BMDTimeValue *audioPacketTime,
- BMDTimeScale timeScale) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE GetBufferedAudioSampleFrameCount(
- /* [out] */ unsigned int *bufferedSampleCount) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StartStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE StopStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE PauseStreams( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE SetCallback(
- /* [in] */ IDeckLinkInputCallback_v7_1 *theCallback) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IDeckLinkInput_v7_1Vtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IDeckLinkInput_v7_1 * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IDeckLinkInput_v7_1 * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IDeckLinkInput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *DoesSupportVideoMode )(
- IDeckLinkInput_v7_1 * This,
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- /* [out] */ BMDDisplayModeSupport *result);
-
- HRESULT ( STDMETHODCALLTYPE *GetDisplayModeIterator )(
- IDeckLinkInput_v7_1 * This,
- /* [out] */ IDeckLinkDisplayModeIterator_v7_1 **iterator);
-
- HRESULT ( STDMETHODCALLTYPE *EnableVideoInput )(
- IDeckLinkInput_v7_1 * This,
- BMDDisplayMode displayMode,
- BMDPixelFormat pixelFormat,
- BMDVideoInputFlags flags);
-
- HRESULT ( STDMETHODCALLTYPE *DisableVideoInput )(
- IDeckLinkInput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *EnableAudioInput )(
- IDeckLinkInput_v7_1 * This,
- BMDAudioSampleRate sampleRate,
- BMDAudioSampleType sampleType,
- unsigned int channelCount);
-
- HRESULT ( STDMETHODCALLTYPE *DisableAudioInput )(
- IDeckLinkInput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *ReadAudioSamples )(
- IDeckLinkInput_v7_1 * This,
- void *buffer,
- unsigned int sampleFrameCount,
- /* [out] */ unsigned int *sampleFramesRead,
- /* [out] */ BMDTimeValue *audioPacketTime,
- BMDTimeScale timeScale);
-
- HRESULT ( STDMETHODCALLTYPE *GetBufferedAudioSampleFrameCount )(
- IDeckLinkInput_v7_1 * This,
- /* [out] */ unsigned int *bufferedSampleCount);
-
- HRESULT ( STDMETHODCALLTYPE *StartStreams )(
- IDeckLinkInput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *StopStreams )(
- IDeckLinkInput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *PauseStreams )(
- IDeckLinkInput_v7_1 * This);
-
- HRESULT ( STDMETHODCALLTYPE *SetCallback )(
- IDeckLinkInput_v7_1 * This,
- /* [in] */ IDeckLinkInputCallback_v7_1 *theCallback);
-
- END_INTERFACE
- } IDeckLinkInput_v7_1Vtbl;
-
- interface IDeckLinkInput_v7_1
- {
- CONST_VTBL struct IDeckLinkInput_v7_1Vtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IDeckLinkInput_v7_1_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IDeckLinkInput_v7_1_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IDeckLinkInput_v7_1_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IDeckLinkInput_v7_1_DoesSupportVideoMode(This,displayMode,pixelFormat,result) \
- ( (This)->lpVtbl -> DoesSupportVideoMode(This,displayMode,pixelFormat,result) )
-
-#define IDeckLinkInput_v7_1_GetDisplayModeIterator(This,iterator) \
- ( (This)->lpVtbl -> GetDisplayModeIterator(This,iterator) )
-
-#define IDeckLinkInput_v7_1_EnableVideoInput(This,displayMode,pixelFormat,flags) \
- ( (This)->lpVtbl -> EnableVideoInput(This,displayMode,pixelFormat,flags) )
-
-#define IDeckLinkInput_v7_1_DisableVideoInput(This) \
- ( (This)->lpVtbl -> DisableVideoInput(This) )
-
-#define IDeckLinkInput_v7_1_EnableAudioInput(This,sampleRate,sampleType,channelCount) \
- ( (This)->lpVtbl -> EnableAudioInput(This,sampleRate,sampleType,channelCount) )
-
-#define IDeckLinkInput_v7_1_DisableAudioInput(This) \
- ( (This)->lpVtbl -> DisableAudioInput(This) )
-
-#define IDeckLinkInput_v7_1_ReadAudioSamples(This,buffer,sampleFrameCount,sampleFramesRead,audioPacketTime,timeScale) \
- ( (This)->lpVtbl -> ReadAudioSamples(This,buffer,sampleFrameCount,sampleFramesRead,audioPacketTime,timeScale) )
-
-#define IDeckLinkInput_v7_1_GetBufferedAudioSampleFrameCount(This,bufferedSampleCount) \
- ( (This)->lpVtbl -> GetBufferedAudioSampleFrameCount(This,bufferedSampleCount) )
-
-#define IDeckLinkInput_v7_1_StartStreams(This) \
- ( (This)->lpVtbl -> StartStreams(This) )
-
-#define IDeckLinkInput_v7_1_StopStreams(This) \
- ( (This)->lpVtbl -> StopStreams(This) )
-
-#define IDeckLinkInput_v7_1_PauseStreams(This) \
- ( (This)->lpVtbl -> PauseStreams(This) )
-
-#define IDeckLinkInput_v7_1_SetCallback(This,theCallback) \
- ( (This)->lpVtbl -> SetCallback(This,theCallback) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IDeckLinkInput_v7_1_INTERFACE_DEFINED__ */
-
-#endif /* __DeckLinkAPI_LIBRARY_DEFINED__ */
-
-/* Additional Prototypes for ALL interfaces */
-
-/* end of Additional Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
diff --git a/intern/decklink/win/DeckLinkAPI_i.c b/intern/decklink/win/DeckLinkAPI_i.c
deleted file mode 100644
index a13d486aae8..00000000000
--- a/intern/decklink/win/DeckLinkAPI_i.c
+++ /dev/null
@@ -1,343 +0,0 @@
-
-
-/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */
-
-/* link this file in with the server and any clients */
-
-
- /* File created by MIDL compiler version 8.00.0603 */
-/* at Mon Apr 13 20:57:05 2015
- */
-/* Compiler settings for ..\..\include\DeckLinkAPI.idl:
- Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.00.0603
- protocol : dce , ms_ext, c_ext, robust
- error checks: allocation ref bounds_check enum stub_data
- VC __declspec() decoration level:
- __declspec(uuid()), __declspec(selectany), __declspec(novtable)
- DECLSPEC_UUID(), MIDL_INTERFACE()
-*/
-/* @@MIDL_FILE_HEADING( ) */
-
-#pragma warning( disable: 4049 ) /* more than 64k source lines */
-
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-
-#include <rpc.h>
-#include <rpcndr.h>
-
-#ifdef _MIDL_USE_GUIDDEF_
-
-#ifndef INITGUID
-#define INITGUID
-#include <guiddef.h>
-#undef INITGUID
-#else
-#include <guiddef.h>
-#endif
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
- DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
-
-#else // !_MIDL_USE_GUIDDEF_
-
-#ifndef __IID_DEFINED__
-#define __IID_DEFINED__
-
-typedef struct _IID
-{
- unsigned long x;
- unsigned short s1;
- unsigned short s2;
- unsigned char c[8];
-} IID;
-
-#endif // __IID_DEFINED__
-
-#ifndef CLSID_DEFINED
-#define CLSID_DEFINED
-typedef IID CLSID;
-#endif // CLSID_DEFINED
-
-#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
- const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
-
-#endif !_MIDL_USE_GUIDDEF_
-
-MIDL_DEFINE_GUID(IID, LIBID_DeckLinkAPI,0xD864517A,0xEDD5,0x466D,0x86,0x7D,0xC8,0x19,0xF1,0xC0,0x52,0xBB);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkTimecode,0xBC6CFBD3,0x8317,0x4325,0xAC,0x1C,0x12,0x16,0x39,0x1E,0x93,0x40);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDisplayModeIterator,0x9C88499F,0xF601,0x4021,0xB8,0x0B,0x03,0x2E,0x4E,0xB4,0x1C,0x35);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDisplayMode,0x3EB2C1AB,0x0A3D,0x4523,0xA3,0xAD,0xF4,0x0D,0x7F,0xB1,0x4E,0x78);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLink,0xC418FBDD,0x0587,0x48ED,0x8F,0xE5,0x64,0x0F,0x0A,0x14,0xAF,0x91);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkConfiguration,0x1E69FCF6,0x4203,0x4936,0x80,0x76,0x2A,0x9F,0x4C,0xFD,0x50,0xCB);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDeckControlStatusCallback,0x53436FFB,0xB434,0x4906,0xBA,0xDC,0xAE,0x30,0x60,0xFF,0xE8,0xEF);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDeckControl,0x8E1C3ACE,0x19C7,0x4E00,0x8B,0x92,0xD8,0x04,0x31,0xD9,0x58,0xBE);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingDeviceNotificationCallback,0xF9531D64,0x3305,0x4B29,0xA3,0x87,0x7F,0x74,0xBB,0x0D,0x0E,0x84);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingH264InputCallback,0x823C475F,0x55AE,0x46F9,0x89,0x0C,0x53,0x7C,0xC5,0xCE,0xDC,0xCA);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingDiscovery,0x2C837444,0xF989,0x4D87,0x90,0x1A,0x47,0xC8,0xA3,0x6D,0x09,0x6D);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingVideoEncodingMode,0x1AB8035B,0xCD13,0x458D,0xB6,0xDF,0x5E,0x8F,0x7C,0x21,0x41,0xD9);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingMutableVideoEncodingMode,0x19BF7D90,0x1E0A,0x400D,0xB2,0xC6,0xFF,0xC4,0xE7,0x8A,0xD4,0x9D);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingVideoEncodingModePresetIterator,0x7AC731A3,0xC950,0x4AD0,0x80,0x4A,0x83,0x77,0xAA,0x51,0xC6,0xC4);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingDeviceInput,0x24B6B6EC,0x1727,0x44BB,0x98,0x18,0x34,0xFF,0x08,0x6A,0xCF,0x98);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingH264NALPacket,0xE260E955,0x14BE,0x4395,0x97,0x75,0x9F,0x02,0xCC,0x0A,0x9D,0x89);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingAudioPacket,0xD9EB5902,0x1AD2,0x43F4,0x9E,0x2C,0x3C,0xFA,0x50,0xB5,0xEE,0x19);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingMPEG2TSPacket,0x91810D1C,0x4FB3,0x4AAA,0xAE,0x56,0xFA,0x30,0x1D,0x3D,0xFA,0x4C);
-
-
-MIDL_DEFINE_GUID(IID, IID_IBMDStreamingH264NALParser,0x5867F18C,0x5BFA,0x4CCC,0xB2,0xA7,0x9D,0xFD,0x14,0x04,0x17,0xD2);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CBMDStreamingDiscovery,0x0CAA31F6,0x8A26,0x40B0,0x86,0xA4,0xBF,0x58,0xDC,0xCA,0x71,0x0C);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CBMDStreamingH264NALParser,0x7753EFBD,0x951C,0x407C,0x97,0xA5,0x23,0xC7,0x37,0xB7,0x3B,0x52);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoOutputCallback,0x20AA5225,0x1958,0x47CB,0x82,0x0B,0x80,0xA8,0xD5,0x21,0xA6,0xEE);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkInputCallback,0xDD04E5EC,0x7415,0x42AB,0xAE,0x4A,0xE8,0x0C,0x4D,0xFC,0x04,0x4A);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkMemoryAllocator,0xB36EB6E7,0x9D29,0x4AA8,0x92,0xEF,0x84,0x3B,0x87,0xA2,0x89,0xE8);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkAudioOutputCallback,0x403C681B,0x7F46,0x4A12,0xB9,0x93,0x2B,0xB1,0x27,0x08,0x4E,0xE6);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkIterator,0x50FB36CD,0x3063,0x4B73,0xBD,0xBB,0x95,0x80,0x87,0xF2,0xD8,0xBA);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkAPIInformation,0x7BEA3C68,0x730D,0x4322,0xAF,0x34,0x8A,0x71,0x52,0xB5,0x32,0xA4);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkOutput,0xCC5C8A6E,0x3F2F,0x4B3A,0x87,0xEA,0xFD,0x78,0xAF,0x30,0x05,0x64);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkInput,0xAF22762B,0xDFAC,0x4846,0xAA,0x79,0xFA,0x88,0x83,0x56,0x09,0x95);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoFrame,0x3F716FE0,0xF023,0x4111,0xBE,0x5D,0xEF,0x44,0x14,0xC0,0x5B,0x17);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkMutableVideoFrame,0x69E2639F,0x40DA,0x4E19,0xB6,0xF2,0x20,0xAC,0xE8,0x15,0xC3,0x90);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoFrame3DExtensions,0xDA0F7E4A,0xEDC7,0x48A8,0x9C,0xDD,0x2D,0xB5,0x1C,0x72,0x9C,0xD7);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoInputFrame,0x05CFE374,0x537C,0x4094,0x9A,0x57,0x68,0x05,0x25,0x11,0x8F,0x44);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoFrameAncillary,0x732E723C,0xD1A4,0x4E29,0x9E,0x8E,0x4A,0x88,0x79,0x7A,0x00,0x04);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkAudioInputPacket,0xE43D5870,0x2894,0x11DE,0x8C,0x30,0x08,0x00,0x20,0x0C,0x9A,0x66);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkScreenPreviewCallback,0xB1D3F49A,0x85FE,0x4C5D,0x95,0xC8,0x0B,0x5D,0x5D,0xCC,0xD4,0x38);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkGLScreenPreviewHelper,0x504E2209,0xCAC7,0x4C1A,0x9F,0xB4,0xC5,0xBB,0x62,0x74,0xD2,0x2F);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDX9ScreenPreviewHelper,0x2094B522,0xD1A1,0x40C0,0x9A,0xC7,0x1C,0x01,0x22,0x18,0xEF,0x02);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkNotificationCallback,0xb002a1ec,0x070d,0x4288,0x82,0x89,0xbd,0x5d,0x36,0xe5,0xff,0x0d);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkNotification,0x0a1fb207,0xe215,0x441b,0x9b,0x19,0x6f,0xa1,0x57,0x59,0x46,0xc5);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkAttributes,0xABC11843,0xD966,0x44CB,0x96,0xE2,0xA1,0xCB,0x5D,0x31,0x35,0xC4);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkKeyer,0x89AFCAF5,0x65F8,0x421E,0x98,0xF7,0x96,0xFE,0x5F,0x5B,0xFB,0xA3);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoConversion,0x3BBCB8A2,0xDA2C,0x42D9,0xB5,0xD8,0x88,0x08,0x36,0x44,0xE9,0x9A);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDeviceNotificationCallback,0x4997053B,0x0ADF,0x4CC8,0xAC,0x70,0x7A,0x50,0xC4,0xBE,0x72,0x8F);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDiscovery,0xCDBF631C,0xBC76,0x45FA,0xB4,0x4D,0xC5,0x50,0x59,0xBC,0x61,0x01);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CDeckLinkIterator,0x1F2E109A,0x8F4F,0x49E4,0x92,0x03,0x13,0x55,0x95,0xCB,0x6F,0xA5);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CDeckLinkAPIInformation,0x263CA19F,0xED09,0x482E,0x9F,0x9D,0x84,0x00,0x57,0x83,0xA2,0x37);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CDeckLinkGLScreenPreviewHelper,0xF63E77C7,0xB655,0x4A4A,0x9A,0xD0,0x3C,0xA8,0x5D,0x39,0x43,0x43);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CDeckLinkDX9ScreenPreviewHelper,0xCC010023,0xE01D,0x4525,0x9D,0x59,0x80,0xC8,0xAB,0x3D,0xC7,0xA0);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CDeckLinkVideoConversion,0x7DBBBB11,0x5B7B,0x467D,0xAE,0xA4,0xCE,0xA4,0x68,0xFD,0x36,0x8C);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CDeckLinkDiscovery,0x1073A05C,0xD885,0x47E9,0xB3,0xC6,0x12,0x9B,0x3F,0x9F,0x64,0x8B);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkConfiguration_v10_2,0xC679A35B,0x610C,0x4D09,0xB7,0x48,0x1D,0x04,0x78,0x10,0x0F,0xC0);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkOutput_v9_9,0xA3EF0963,0x0862,0x44ED,0x92,0xA9,0xEE,0x89,0xAB,0xF4,0x31,0xC7);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkInput_v9_2,0x6D40EF78,0x28B9,0x4E21,0x99,0x0D,0x95,0xBB,0x77,0x50,0xA0,0x4F);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDeckControlStatusCallback_v8_1,0xE5F693C1,0x4283,0x4716,0xB1,0x8F,0xC1,0x43,0x15,0x21,0x95,0x5B);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDeckControl_v8_1,0x522A9E39,0x0F3C,0x4742,0x94,0xEE,0xD8,0x0D,0xE3,0x35,0xDA,0x1D);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLink_v8_0,0x62BFF75D,0x6569,0x4E55,0x8D,0x4D,0x66,0xAA,0x03,0x82,0x9A,0xBC);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkIterator_v8_0,0x74E936FC,0xCC28,0x4A67,0x81,0xA0,0x1E,0x94,0xE5,0x2D,0x4E,0x69);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CDeckLinkIterator_v8_0,0xD9EDA3B3,0x2887,0x41FA,0xB7,0x24,0x01,0x7C,0xF1,0xEB,0x1D,0x37);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDeckControl_v7_9,0xA4D81043,0x0619,0x42B7,0x8E,0xD6,0x60,0x2D,0x29,0x04,0x1D,0xF7);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDisplayModeIterator_v7_6,0x455D741F,0x1779,0x4800,0x86,0xF5,0x0B,0x5D,0x13,0xD7,0x97,0x51);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDisplayMode_v7_6,0x87451E84,0x2B7E,0x439E,0xA6,0x29,0x43,0x93,0xEA,0x4A,0x85,0x50);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkOutput_v7_6,0x29228142,0xEB8C,0x4141,0xA6,0x21,0xF7,0x40,0x26,0x45,0x09,0x55);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkInput_v7_6,0x300C135A,0x9F43,0x48E2,0x99,0x06,0x6D,0x79,0x11,0xD9,0x3C,0xF1);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkTimecode_v7_6,0xEFB9BCA6,0xA521,0x44F7,0xBD,0x69,0x23,0x32,0xF2,0x4D,0x9E,0xE6);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoFrame_v7_6,0xA8D8238E,0x6B18,0x4196,0x99,0xE1,0x5A,0xF7,0x17,0xB8,0x3D,0x32);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkMutableVideoFrame_v7_6,0x46FCEE00,0xB4E6,0x43D0,0x91,0xC0,0x02,0x3A,0x7F,0xCE,0xB3,0x4F);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoInputFrame_v7_6,0x9A74FA41,0xAE9F,0x47AC,0x8C,0xF4,0x01,0xF4,0x2D,0xD5,0x99,0x65);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkScreenPreviewCallback_v7_6,0x373F499D,0x4B4D,0x4518,0xAD,0x22,0x63,0x54,0xE5,0xA5,0x82,0x5E);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkGLScreenPreviewHelper_v7_6,0xBA575CD9,0xA15E,0x497B,0xB2,0xC2,0xF9,0xAF,0xE7,0xBE,0x4E,0xBA);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoConversion_v7_6,0x3EB504C9,0xF97D,0x40FE,0xA1,0x58,0xD4,0x07,0xD4,0x8C,0xB5,0x3B);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkConfiguration_v7_6,0xB8EAD569,0xB764,0x47F0,0xA7,0x3F,0xAE,0x40,0xDF,0x6C,0xBF,0x10);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoOutputCallback_v7_6,0xE763A626,0x4A3C,0x49D1,0xBF,0x13,0xE7,0xAD,0x36,0x92,0xAE,0x52);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkInputCallback_v7_6,0x31D28EE7,0x88B6,0x4CB1,0x89,0x7A,0xCD,0xBF,0x79,0xA2,0x64,0x14);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CDeckLinkGLScreenPreviewHelper_v7_6,0xD398CEE7,0x4434,0x4CA3,0x9B,0xA6,0x5A,0xE3,0x45,0x56,0xB9,0x05);
-
-
-MIDL_DEFINE_GUID(CLSID, CLSID_CDeckLinkVideoConversion_v7_6,0xFFA84F77,0x73BE,0x4FB7,0xB0,0x3E,0xB5,0xE4,0x4B,0x9F,0x75,0x9B);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkInputCallback_v7_3,0xFD6F311D,0x4D00,0x444B,0x9E,0xD4,0x1F,0x25,0xB5,0x73,0x0A,0xD0);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkOutput_v7_3,0x271C65E3,0xC323,0x4344,0xA3,0x0F,0xD9,0x08,0xBC,0xB2,0x0A,0xA3);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkInput_v7_3,0x4973F012,0x9925,0x458C,0x87,0x1C,0x18,0x77,0x4C,0xDB,0xBE,0xCB);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoInputFrame_v7_3,0xCF317790,0x2894,0x11DE,0x8C,0x30,0x08,0x00,0x20,0x0C,0x9A,0x66);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDisplayModeIterator_v7_1,0xB28131B6,0x59AC,0x4857,0xB5,0xAC,0xCD,0x75,0xD5,0x88,0x3E,0x2F);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkDisplayMode_v7_1,0xAF0CD6D5,0x8376,0x435E,0x84,0x33,0x54,0xF9,0xDD,0x53,0x0A,0xC3);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoFrame_v7_1,0x333F3A10,0x8C2D,0x43CF,0xB7,0x9D,0x46,0x56,0x0F,0xEE,0xA1,0xCE);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoInputFrame_v7_1,0xC8B41D95,0x8848,0x40EE,0x9B,0x37,0x6E,0x34,0x17,0xFB,0x11,0x4B);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkAudioInputPacket_v7_1,0xC86DE4F6,0xA29F,0x42E3,0xAB,0x3A,0x13,0x63,0xE2,0x9F,0x07,0x88);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkVideoOutputCallback_v7_1,0xEBD01AFA,0xE4B0,0x49C6,0xA0,0x1D,0xED,0xB9,0xD1,0xB5,0x5F,0xD9);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkInputCallback_v7_1,0x7F94F328,0x5ED4,0x4E9F,0x97,0x29,0x76,0xA8,0x6B,0xDC,0x99,0xCC);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkOutput_v7_1,0xAE5B3E9B,0x4E1E,0x4535,0xB6,0xE8,0x48,0x0F,0xF5,0x2F,0x6C,0xE5);
-
-
-MIDL_DEFINE_GUID(IID, IID_IDeckLinkInput_v7_1,0x2B54EDEF,0x5B32,0x429F,0xBA,0x11,0xBB,0x99,0x05,0x96,0xEA,0xCD);
-
-#undef MIDL_DEFINE_GUID
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
diff --git a/intern/gawain/gawain/gwn_imm_util.h b/intern/gawain/gawain/gwn_imm_util.h
index 730bd7c1a3c..5d17ec50669 100644
--- a/intern/gawain/gawain/gwn_imm_util.h
+++ b/intern/gawain/gawain/gwn_imm_util.h
@@ -16,3 +16,7 @@
// caller is reponsible for vertex format & shader
void immRectf(unsigned pos, float x1, float y1, float x2, float y2);
void immRecti(unsigned pos, int x1, int y1, int x2, int y2);
+
+// Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GWN_PRIM_TRIS.
+void immRectf_fast_with_color(unsigned pos, unsigned col, float x1, float y1, float x2, float y2, const float color[4]);
+void immRecti_fast_with_color(unsigned pos, unsigned col, int x1, int y1, int x2, int y2, const float color[4]);
diff --git a/intern/gawain/gawain/gwn_shader_interface.h b/intern/gawain/gawain/gwn_shader_interface.h
index 3be2831e539..150b3b4fcc0 100644
--- a/intern/gawain/gawain/gwn_shader_interface.h
+++ b/intern/gawain/gawain/gwn_shader_interface.h
@@ -36,6 +36,7 @@ typedef enum {
GWN_UNIFORM_COLOR, // vec4 color
GWN_UNIFORM_EYE, // vec3 eye
+ GWN_UNIFORM_CALLID, // int callId
GWN_UNIFORM_CUSTOM, // custom uniform, not one of the above built-ins
diff --git a/intern/gawain/src/gwn_imm_util.c b/intern/gawain/src/gwn_imm_util.c
index 45d8a7036e8..a8d2b05c8a3 100644
--- a/intern/gawain/src/gwn_imm_util.c
+++ b/intern/gawain/src/gwn_imm_util.c
@@ -33,6 +33,40 @@ void immRecti(unsigned pos, int x1, int y1, int x2, int y2)
immEnd();
}
+void immRectf_fast_with_color(unsigned pos, unsigned col, float x1, float y1, float x2, float y2, const float color[4])
+ {
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x1, y1);
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x2, y1);
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x2, y2);
+
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x1, y1);
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x2, y2);
+ immAttrib4fv(col, color);
+ immVertex2f(pos, x1, y2);
+ }
+
+void immRecti_fast_with_color(unsigned pos, unsigned col, int x1, int y1, int x2, int y2, const float color[4])
+ {
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x1, y1);
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x2, y1);
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x2, y2);
+
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x1, y1);
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x2, y2);
+ immAttrib4fv(col, color);
+ immVertex2i(pos, x1, y2);
+ }
+
#if 0 // more complete version in case we want that
void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
{
diff --git a/intern/gawain/src/gwn_immediate.c b/intern/gawain/src/gwn_immediate.c
index 0e57aefebe2..006af0abe01 100644
--- a/intern/gawain/src/gwn_immediate.c
+++ b/intern/gawain/src/gwn_immediate.c
@@ -275,7 +275,7 @@ Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_ct)
imm.buffer_bytes_mapped = GWN_vertbuf_size_get(verts);
imm.vertex_data = verts->data;
- imm.batch = GWN_batch_create(prim_type, verts, NULL);
+ imm.batch = GWN_batch_create_ex(prim_type, verts, NULL, GWN_BATCH_OWNS_VBO);
imm.batch->phase = GWN_BATCH_BUILDING;
return imm.batch;
diff --git a/intern/gawain/src/gwn_shader_interface.c b/intern/gawain/src/gwn_shader_interface.c
index e92cabec12f..95c18cf1d39 100644
--- a/intern/gawain/src/gwn_shader_interface.c
+++ b/intern/gawain/src/gwn_shader_interface.c
@@ -48,6 +48,7 @@ static const char* BuiltinUniform_name(Gwn_UniformBuiltin u)
[GWN_UNIFORM_COLOR] = "color",
[GWN_UNIFORM_EYE] = "eye",
+ [GWN_UNIFORM_CALLID] = "callId",
[GWN_UNIFORM_CUSTOM] = NULL,
[GWN_NUM_UNIFORMS] = NULL,
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 056b5536ab0..ccc90e363b7 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -396,12 +396,12 @@ GHOST_TSuccess GHOST_SystemWin32::disposeContext(GHOST_IContext *context)
bool GHOST_SystemWin32::processEvents(bool waitForEvent)
{
MSG msg;
- bool anyProcessed = false;
+ bool hasEventHandled = false;
do {
GHOST_TimerManager *timerMgr = getTimerManager();
- if (waitForEvent && !::PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) {
+ if (waitForEvent && !::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
#if 1
::Sleep(1);
#else
@@ -420,20 +420,26 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent)
}
if (timerMgr->fireTimers(getMilliSeconds())) {
- anyProcessed = true;
+ hasEventHandled = true;
}
// Process all the events waiting for us
- while (::PeekMessageW(&msg, 0, 0, 0, PM_REMOVE) != 0) {
+ while (::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE) != 0) {
// TranslateMessage doesn't alter the message, and doesn't change our raw keyboard data.
// Needed for MapVirtualKey or if we ever need to get chars from wm_ime_char or similar.
::TranslateMessage(&msg);
::DispatchMessageW(&msg);
- anyProcessed = true;
}
- } while (waitForEvent && !anyProcessed);
- return anyProcessed;
+ if (hasEventHandled == false) {
+ // Check if we have events handled by the system
+ // (for example the `GHOST_kEventWindowClose`).
+ hasEventHandled = m_eventManager->getNumEvents() != 0;
+ }
+
+ } while (waitForEvent && !hasEventHandled);
+
+ return hasEventHandled;
}
diff --git a/intern/gpudirect/CMakeLists.txt b/intern/gpudirect/CMakeLists.txt
deleted file mode 100644
index 88c09a663b8..00000000000
--- a/intern/gpudirect/CMakeLists.txt
+++ /dev/null
@@ -1,41 +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) 2015, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Blender Foundation.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- # XXX, bad level include!
- ../../source/blender/blenlib
-)
-
-set(INC_SYS
- ${GLEW_INCLUDE_PATH}
-)
-
-set(SRC
- dvpapi.cpp
- dvpapi.h
-)
-
-blender_add_lib(bf_intern_gpudirect "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/gpudirect/dvpapi.cpp b/intern/gpudirect/dvpapi.cpp
deleted file mode 100644
index 56b58e0a348..00000000000
--- a/intern/gpudirect/dvpapi.cpp
+++ /dev/null
@@ -1,147 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gpudirect/dvpapi.c
- * \ingroup gpudirect
- */
-
-#ifdef WIN32
-
-#include <stdlib.h>
-#include "dvpapi.h"
-
-extern "C" {
-#include "BLI_dynlib.h"
-}
-
-#define KDVPAPI_Name "dvp.dll"
-
-typedef DVPStatus (DVPAPIENTRY * PFNDVPINITGLCONTEXT) (uint32_t flags);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPCLOSEGLCONTEXT) (void);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPGETLIBRARYVERSION)(uint32_t *major, uint32_t *minor);
-
-static uint32_t __dvpMajorVersion = 0;
-static uint32_t __dvpMinorVersion = 0;
-static PFNDVPGETLIBRARYVERSION __dvpGetLibrayVersion = NULL;
-static PFNDVPINITGLCONTEXT __dvpInitGLContext = NULL;
-static PFNDVPCLOSEGLCONTEXT __dvpCloseGLContext = NULL;
-PFNDVPBEGIN __dvpBegin = NULL;
-PFNDVPEND __dvpEnd = NULL;
-PFNDVPCREATEBUFFER __dvpCreateBuffer = NULL;
-PFNDVPDESTROYBUFFER __dvpDestroyBuffer = NULL;
-PFNDVPFREEBUFFER __dvpFreeBuffer = NULL;
-PFNDVPMEMCPYLINED __dvpMemcpyLined = NULL;
-PFNDVPMEMCPY __dvpMemcpy = NULL;
-PFNDVPIMPORTSYNCOBJECT __dvpImportSyncObject = NULL;
-PFNDVPFREESYNCOBJECT __dvpFreeSyncObject = NULL;
-PFNDVPMAPBUFFERENDAPI __dvpMapBufferEndAPI = NULL;
-PFNDVPMAPBUFFERWAITDVP __dvpMapBufferWaitDVP = NULL;
-PFNDVPMAPBUFFERENDDVP __dvpMapBufferEndDVP = NULL;
-PFNDVPMAPBUFFERWAITAPI __dvpMapBufferWaitAPI = NULL;
-PFNDVPBINDTOGLCTX __dvpBindToGLCtx = NULL;
-PFNDVPGETREQUIREDCONSTANTSGLCTX __dvpGetRequiredConstantsGLCtx = NULL;
-PFNDVPCREATEGPUTEXTUREGL __dvpCreateGPUTextureGL = NULL;
-PFNDVPUNBINDFROMGLCTX __dvpUnbindFromGLCtx = NULL;
-
-static DynamicLibrary *__dvpLibrary = NULL;
-
-DVPStatus dvpGetLibrayVersion(uint32_t *major, uint32_t *minor)
-{
- if (!__dvpLibrary)
- return DVP_STATUS_ERROR;
- *major = __dvpMajorVersion;
- *minor = __dvpMinorVersion;
- return DVP_STATUS_OK;
-}
-
-DVPStatus dvpInitGLContext(uint32_t flags)
-{
- DVPStatus status;
- if (!__dvpLibrary) {
- __dvpLibrary = BLI_dynlib_open(KDVPAPI_Name);
- if (!__dvpLibrary) {
- return DVP_STATUS_ERROR;
- }
-// "?dvpInitGLContext@@YA?AW4DVPStatus@@I@Z";
- __dvpInitGLContext = (PFNDVPINITGLCONTEXT)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpInitGLContext@@YA?AW4DVPStatus@@I@Z");
- __dvpCloseGLContext = (PFNDVPCLOSEGLCONTEXT)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpCloseGLContext@@YA?AW4DVPStatus@@XZ");
- __dvpGetLibrayVersion = (PFNDVPGETLIBRARYVERSION)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpGetLibrayVersion@@YA?AW4DVPStatus@@PEAI0@Z");
- __dvpBegin = (PFNDVPBEGIN)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpBegin@@YA?AW4DVPStatus@@XZ");
- __dvpEnd = (PFNDVPEND)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpEnd@@YA?AW4DVPStatus@@XZ");
- __dvpCreateBuffer = (PFNDVPCREATEBUFFER)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpCreateBuffer@@YA?AW4DVPStatus@@PEAUDVPSysmemBufferDescRec@@PEA_K@Z");
- __dvpDestroyBuffer = (PFNDVPDESTROYBUFFER)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpDestroyBuffer@@YA?AW4DVPStatus@@_K@Z");
- __dvpFreeBuffer = (PFNDVPFREEBUFFER)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpFreeBuffer@@YA?AW4DVPStatus@@_K@Z");
- __dvpMemcpyLined = (PFNDVPMEMCPYLINED)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMemcpyLined@@YA?AW4DVPStatus@@_K0I000III@Z");
- __dvpMemcpy = (PFNDVPMEMCPY)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMemcpy2D@@YA?AW4DVPStatus@@_K0I000IIIII@Z");
- __dvpImportSyncObject = (PFNDVPIMPORTSYNCOBJECT)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpImportSyncObject@@YA?AW4DVPStatus@@PEAUDVPSyncObjectDescRec@@PEA_K@Z");
- __dvpFreeSyncObject = (PFNDVPFREESYNCOBJECT)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpFreeSyncObject@@YA?AW4DVPStatus@@_K@Z");
- __dvpMapBufferEndAPI = (PFNDVPMAPBUFFERENDAPI)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMapBufferEndAPI@@YA?AW4DVPStatus@@_K@Z");
- __dvpMapBufferWaitDVP = (PFNDVPMAPBUFFERWAITDVP)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMapBufferWaitDVP@@YA?AW4DVPStatus@@_K@Z");
- __dvpMapBufferEndDVP = (PFNDVPMAPBUFFERENDDVP)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMapBufferEndDVP@@YA?AW4DVPStatus@@_K@Z");
- __dvpMapBufferWaitAPI = (PFNDVPMAPBUFFERWAITAPI)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMapBufferWaitAPI@@YA?AW4DVPStatus@@_K@Z");
- __dvpBindToGLCtx = (PFNDVPBINDTOGLCTX)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpBindToGLCtx@@YA?AW4DVPStatus@@_K@Z");
- __dvpGetRequiredConstantsGLCtx = (PFNDVPGETREQUIREDCONSTANTSGLCTX)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpGetRequiredConstantsGLCtx@@YA?AW4DVPStatus@@PEAI00000@Z");
- __dvpCreateGPUTextureGL = (PFNDVPCREATEGPUTEXTUREGL)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpCreateGPUTextureGL@@YA?AW4DVPStatus@@IPEA_K@Z");
- __dvpUnbindFromGLCtx = (PFNDVPUNBINDFROMGLCTX)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpUnbindFromGLCtx@@YA?AW4DVPStatus@@_K@Z");
- if (!__dvpInitGLContext ||
- !__dvpCloseGLContext ||
- !__dvpGetLibrayVersion ||
- !__dvpBegin ||
- !__dvpEnd ||
- !__dvpCreateBuffer ||
- !__dvpDestroyBuffer ||
- !__dvpFreeBuffer ||
- !__dvpMemcpyLined ||
- !__dvpMemcpy ||
- !__dvpImportSyncObject ||
- !__dvpFreeSyncObject ||
- !__dvpMapBufferEndAPI ||
- !__dvpMapBufferWaitDVP ||
- !__dvpMapBufferEndDVP ||
- !__dvpMapBufferWaitAPI ||
- !__dvpBindToGLCtx ||
- !__dvpGetRequiredConstantsGLCtx ||
- !__dvpCreateGPUTextureGL ||
- !__dvpUnbindFromGLCtx)
- {
- return DVP_STATUS_ERROR;
- }
- // check that the library version is what we want
- if ((status = __dvpGetLibrayVersion(&__dvpMajorVersion, &__dvpMinorVersion)) != DVP_STATUS_OK)
- return status;
- if (__dvpMajorVersion != DVP_MAJOR_VERSION || __dvpMinorVersion < DVP_MINOR_VERSION)
- return DVP_STATUS_ERROR;
- }
- return (!__dvpInitGLContext) ? DVP_STATUS_ERROR : __dvpInitGLContext(flags);
-}
-
-DVPStatus dvpCloseGLContext(void)
-{
- return (!__dvpCloseGLContext) ? DVP_STATUS_ERROR : __dvpCloseGLContext();
-}
-
-#endif // WIN32
diff --git a/intern/gpudirect/dvpapi.h b/intern/gpudirect/dvpapi.h
deleted file mode 100644
index cafc4e862ae..00000000000
--- a/intern/gpudirect/dvpapi.h
+++ /dev/null
@@ -1,667 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gpudirect/dvpapi.h
- * \ingroup gpudirect
- */
-
-#ifndef __DVPAPI_H__
-#define __DVPAPI_H__
-
-#ifdef WIN32
-
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "GL/glew.h"
-
-#if defined(__GNUC__) && __GNUC__>=4
-# define DVPAPI extern __attribute__ ((visibility("default")))
-#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-# define DVPAPI extern __global
-#else
-# define DVPAPI extern
-#endif
-
-#define DVPAPIENTRY
-#define DVP_MAJOR_VERSION 1
-#define DVP_MINOR_VERSION 63
-
-typedef uint64_t DVPBufferHandle;
-typedef uint64_t DVPSyncObjectHandle;
-
-typedef enum {
- DVP_STATUS_OK = 0,
- DVP_STATUS_INVALID_PARAMETER = 1,
- DVP_STATUS_UNSUPPORTED = 2,
- DVP_STATUS_END_ENUMERATION = 3,
- DVP_STATUS_INVALID_DEVICE = 4,
- DVP_STATUS_OUT_OF_MEMORY = 5,
- DVP_STATUS_INVALID_OPERATION = 6,
- DVP_STATUS_TIMEOUT = 7,
- DVP_STATUS_INVALID_CONTEXT = 8,
- DVP_STATUS_INVALID_RESOURCE_TYPE = 9,
- DVP_STATUS_INVALID_FORMAT_OR_TYPE = 10,
- DVP_STATUS_DEVICE_UNINITIALIZED = 11,
- DVP_STATUS_UNSIGNALED = 12,
- DVP_STATUS_SYNC_ERROR = 13,
- DVP_STATUS_SYNC_STILL_BOUND = 14,
- DVP_STATUS_ERROR = -1,
-} DVPStatus;
-
-// Pixel component formats stored in the system memory buffer
-// analogous to those defined in the OpenGL API, except for
-// DVP_BUFFER and the DVP_CUDA_* types. DVP_BUFFER provides
-// an unspecified format type to allow for general interpretation
-// of the bytes at a later stage (in GPU shader). Note that not
-// all paths will achieve optimal speeds due to lack of HW support
-// for the transformation. The CUDA types are to be used when
-// copying to/from a system memory buffer from-to a CUDA array, as the
-// CUDA array implies a memory layout that matches the array.
-typedef enum {
- DVP_BUFFER, // Buffer treated as a raw buffer
- // and copied directly into GPU buffer
- // without any interpretation of the
- // stored bytes.
- DVP_DEPTH_COMPONENT,
- DVP_RGBA,
- DVP_BGRA,
- DVP_RED,
- DVP_GREEN,
- DVP_BLUE,
- DVP_ALPHA,
- DVP_RGB,
- DVP_BGR,
- DVP_LUMINANCE,
- DVP_LUMINANCE_ALPHA,
- DVP_CUDA_1_CHANNEL,
- DVP_CUDA_2_CHANNELS,
- DVP_CUDA_4_CHANNELS,
- DVP_RGBA_INTEGER,
- DVP_BGRA_INTEGER,
- DVP_RED_INTEGER,
- DVP_GREEN_INTEGER,
- DVP_BLUE_INTEGER,
- DVP_ALPHA_INTEGER,
- DVP_RGB_INTEGER,
- DVP_BGR_INTEGER,
- DVP_LUMINANCE_INTEGER,
- DVP_LUMINANCE_ALPHA_INTEGER,
-} DVPBufferFormats;
-
-// Possible pixel component storage types for system memory buffers
-typedef enum {
- DVP_UNSIGNED_BYTE,
- DVP_BYTE,
- DVP_UNSIGNED_SHORT,
- DVP_SHORT,
- DVP_UNSIGNED_INT,
- DVP_INT,
- DVP_FLOAT,
- DVP_HALF_FLOAT,
- DVP_UNSIGNED_BYTE_3_3_2,
- DVP_UNSIGNED_BYTE_2_3_3_REV,
- DVP_UNSIGNED_SHORT_5_6_5,
- DVP_UNSIGNED_SHORT_5_6_5_REV,
- DVP_UNSIGNED_SHORT_4_4_4_4,
- DVP_UNSIGNED_SHORT_4_4_4_4_REV,
- DVP_UNSIGNED_SHORT_5_5_5_1,
- DVP_UNSIGNED_SHORT_1_5_5_5_REV,
- DVP_UNSIGNED_INT_8_8_8_8,
- DVP_UNSIGNED_INT_8_8_8_8_REV,
- DVP_UNSIGNED_INT_10_10_10_2,
- DVP_UNSIGNED_INT_2_10_10_10_REV,
-} DVPBufferTypes;
-
-// System memory descriptor describing the size and storage formats
-// of the buffer
-typedef struct DVPSysmemBufferDescRec {
- uint32_t width; // Buffer Width
- uint32_t height; // Buffer Height
- uint32_t stride; // Stride
- uint32_t size; // Specifies the surface size if
- // format == DVP_BUFFER
- DVPBufferFormats format; // see enum above
- DVPBufferTypes type; // see enum above
- void *bufAddr; // Buffer memory address
-} DVPSysmemBufferDesc;
-
-// Flags specified at sync object creation:
-// ----------------------------------------
-// Tells the implementation to use events wherever
-// possible instead of software spin loops. Note if HW
-// wait operations are supported by the implementation
-// then events will not be used in the dvpMemcpy*
-// functions. In such a case, events may still be used
-// in dvpSyncObjClientWait* functions.
-#define DVP_SYNC_OBJECT_FLAGS_USE_EVENTS 0x00000001
-
-typedef struct DVPSyncObjectDescRec {
- uint32_t *sem; // Location to write semaphore value
- uint32_t flags; // See above DVP_SYNC_OBJECT_FLAGS_* bits
- DVPStatus (*externalClientWaitFunc) (DVPSyncObjectHandle sync,
- uint32_t value,
- bool GEQ, // If true then the function should wait for the sync value to be
- // greater than or equal to the value parameter. Otherwise just a
- // straight forward equality comparison should be performed.
- uint64_t timeout);
- // If non-null, externalClientWaitFunc allows the DVP library
- // to call the application to wait for a sync object to be
- // released. This allows the application to create events,
- // which can be triggered on device interrupts instead of
- // using spin loops inside the DVP library. Upon succeeding
- // the function must return DVP_STATUS_OK, non-zero for failure
- // and DVP_STATUS_TIMEOUT on timeout. The externalClientWaitFunc should
- // not alter the current GL or CUDA context state
-} DVPSyncObjectDesc;
-
-// Time used when event timeouts should be ignored
-#define DVP_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
-
-typedef DVPStatus (DVPAPIENTRY * PFNDVPBEGIN) (void);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPEND) (void);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPCREATEBUFFER)(DVPSysmemBufferDesc *desc, DVPBufferHandle *hBuf);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPDESTROYBUFFER)(DVPBufferHandle hBuf);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPFREEBUFFER)(DVPBufferHandle gpuBufferHandle);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPMEMCPYLINED)(DVPBufferHandle srcBuffer,
- DVPSyncObjectHandle srcSync,
- uint32_t srcAcquireValue,
- uint64_t timeout,
- DVPBufferHandle dstBuffer,
- DVPSyncObjectHandle dstSync,
- uint32_t dstReleaseValue,
- uint32_t startingLine,
- uint32_t numberOfLines);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPMEMCPY)(DVPBufferHandle srcBuffer,
- DVPSyncObjectHandle srcSync,
- uint32_t srcAcquireValue,
- uint64_t timeout,
- DVPBufferHandle dstBuffer,
- DVPSyncObjectHandle dstSync,
- uint32_t dstReleaseValue,
- uint32_t srcOffset,
- uint32_t dstOffset,
- uint32_t count);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPIMPORTSYNCOBJECT)(DVPSyncObjectDesc *desc,
- DVPSyncObjectHandle *syncObject);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPFREESYNCOBJECT)(DVPSyncObjectHandle syncObject);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPGETREQUIREDCONSTANTSGLCTX)(uint32_t *bufferAddrAlignment,
- uint32_t *bufferGPUStrideAlignment,
- uint32_t *semaphoreAddrAlignment,
- uint32_t *semaphoreAllocSize,
- uint32_t *semaphorePayloadOffset,
- uint32_t *semaphorePayloadSize);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPBINDTOGLCTX)(DVPBufferHandle hBuf);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPUNBINDFROMGLCTX)(DVPBufferHandle hBuf);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPMAPBUFFERENDAPI)(DVPBufferHandle gpuBufferHandle);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPMAPBUFFERWAITDVP)(DVPBufferHandle gpuBufferHandle);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPMAPBUFFERENDDVP)(DVPBufferHandle gpuBufferHandle);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPMAPBUFFERWAITAPI)(DVPBufferHandle gpuBufferHandle);
-typedef DVPStatus (DVPAPIENTRY * PFNDVPCREATEGPUTEXTUREGL)(GLuint texID,
- DVPBufferHandle *bufferHandle);
-
-// Flags supplied to the dvpInit* functions:
-//
-// DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT is only supported for OpenGL
-// contexts and is the only supported flag for CUDA. It allows for
-// certain cases to be optimized by sharing the context
-// of the application for the DVP operations. This removes the
-// need to do certain synchronizations. See issue 5 for parallel
-// issues. When used, the app's GL context must be current for all calls
-// to the DVP library.
-// the DVP library.
-#define DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT 0x000000001
-
-//------------------------------------------------------------------------
-// Function: dvpInitGLContext
-//
-// To be called before any DVP resources are allocated.
-// This call allows for specification of flags that may
-// change the way DVP operations are performed. See above
-// for the list of flags.
-//
-// The OpenGL context must be current at time of call.
-//
-// Parameters: flags[IN] - Buffer description structure
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-extern DVPStatus dvpInitGLContext(uint32_t flags);
-
-//------------------------------------------------------------------------
-// Function: dvpCloseGLContext
-//
-// Function to be called when app closes to allow freeing
-// of any DVP library allocated resources.
-//
-// The OpenGL context must be current at time of call.
-//
-// Parameters: none
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-extern DVPStatus dvpCloseGLContext();
-
-//------------------------------------------------------------------------
-// Function: dvpGetLibrayVersion
-//
-// Description: Returns the current version of the library
-//
-// Parameters: major[OUT] - returned major version
-// minor[OUT] - returned minor version
-//
-// Returns: DVP_STATUS_OK
-//------------------------------------------------------------------------
-extern DVPStatus dvpGetLibrayVersion(uint32_t *major, uint32_t *minor);
-
-//------------------------------------------------------------------------
-// Function: dvpBegin
-//
-// Description: dvpBegin must be called before any combination of DVP
-// function calls dvpMemCpy*, dvpMapBufferWaitDVP,
-// dvpSyncObjClientWait*, and dvpMapBufferEndDVP. After
-// the last of these functions has been called is dvpEnd
-// must be called. This allows for more efficient batched
-// DVP operations.
-//
-// Parameters: none
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-#define dvpBegin DVPAPI_GET_FUN(__dvpBegin)
-
-//------------------------------------------------------------------------
-// Function: dvpEnd
-//
-// Description: dvpEnd signals the end of a batch of DVP function calls
-// that began with dvpBegin
-//
-// Parameters: none
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-#define dvpEnd DVPAPI_GET_FUN(__dvpEnd)
-
-
-//------------------------------------------------------------------------
-// Function: dvpCreateBuffer
-//
-// Description: Create a DVP buffer using system memory, wrapping a user
-// passed pointer. The pointer must be aligned
-// to values returned by dvpGetRequiredAlignments*
-//
-// Parameters: desc[IN] - Buffer description structure
-// hBuf[OUT] - DVP Buffer handle
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-#define dvpCreateBuffer DVPAPI_GET_FUN(__dvpCreateBuffer)
-
-
-//------------------------------------------------------------------------
-// Function: dvpDestroyBuffer
-//
-// Description: Destroy a previously created DVP buffer.
-//
-// Parameters: hBuf[IN] - DVP Buffer handle
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-#define dvpDestroyBuffer DVPAPI_GET_FUN(__dvpDestroyBuffer)
-
-//------------------------------------------------------------------------
-// Function: dvpFreeBuffer
-//
-// Description: dvpFreeBuffer frees the DVP buffer reference
-//
-// Parameters: gpuBufferHandle[IN] - DVP Buffer handle
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-#define dvpFreeBuffer DVPAPI_GET_FUN(__dvpFreeBuffer)
-
-//------------------------------------------------------------------------
-// Function: dvpMemcpyLined
-//
-// Description: dvpMemcpyLined provides buffer copies between a
-// DVP sysmem buffer and a graphics API texture (as opposed to
-// a buffer type). Other buffer types (such
-// as graphics API buffers) return DVP_STATUS_INVALID_PARAMETER.
-//
-// In addition, see "dvpMemcpy* general comments" above.
-//
-// Parameters: srcBuffer[IN] - src buffer handle
-// srcSync[IN] - sync to acquire on before transfer
-// srcAcquireValue[IN] - value to acquire on before transfer
-// timeout[IN] - time out value in nanoseconds.
-// dstBuffer[IN] - src buffer handle
-// dstSync[IN] - sync to release on transfer completion
-// dstReleaseValue[IN] - value to release on completion
-// startingLine[IN] - starting line of buffer
-// numberOfLines[IN] - number of lines to copy
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//
-// GL state effected: The following GL state may be altered by this
-// function (not relevant if no GL source or destination
-// is used):
-// -GL_PACK_SKIP_ROWS, GL_PACK_SKIP_PIXELS,
-// GL_PACK_ROW_LENGTH
-// -The buffer bound to GL_PIXEL_PACK_BUFFER
-// -The current bound framebuffer (GL_FRAMEBUFFER_EXT)
-// -GL_UNPACK_SKIP_ROWS, GL_UNPACK_SKIP_PIXELS,
-// GL_UNPACK_ROW_LENGTH
-// -The buffer bound to GL_PIXEL_UNPACK_BUFFER
-// -The texture bound to GL_TEXTURE_2D
-//------------------------------------------------------------------------
-#define dvpMemcpyLined DVPAPI_GET_FUN(__dvpMemcpyLined)
-
-
-//------------------------------------------------------------------------
-// Function: dvpMemcpy
-//
-// Description: dvpMemcpy provides buffer copies between a
-// DVP sysmem buffer and a graphics API pure buffer (as
-// opposed to a texture type). Other buffer types (such
-// as graphics API textures) return
-// DVP_STATUS_INVALID_PARAMETER.
-//
-// The start address of the srcBuffer is given by srcOffset
-// and the dstBuffer start address is given by dstOffset.
-//
-// In addition, see "dvpMemcpy* general comments" above.
-//
-// Parameters: srcBuffer[IN] - src buffer handle
-// srcSync[IN] - sync to acquire on before transfer
-// srcAcquireValue[IN] - value to acquire on before transfer
-// timeout[IN] - time out value in nanoseconds.
-// dstBuffer[IN] - src buffer handle
-// dstSync[IN] - sync to release on completion
-// dstReleaseValue[IN] - value to release on completion
-// uint32_t srcOffset[IN] - byte offset of srcBuffer
-// uint32_t dstOffset[IN] - byte offset of dstBuffer
-// uint32_t count[IN] - number of bytes to copy
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//
-// GL state effected: The following GL state may be altered by this
-// function (not relevant if no GL source or destination
-// is used):
-// - The buffer bound to GL_COPY_WRITE_BUFFER
-// - The buffer bound to GL_COPY_READ_BUFFER
-//
-//------------------------------------------------------------------------
-#define dvpMemcpy DVPAPI_GET_FUN(__dvpMemcpy)
-
-//------------------------------------------------------------------------
-// Function: dvpImportSyncObject
-//
-// Description: dvpImportSyncObject creates a DVPSyncObject from the
-// DVPSyncObjectDesc. Note that a sync object is not
-// supported for copy operations targeting different APIs.
-// This means, for example, it is illegal to call dvpMemCpy*
-// for source or target GL texture with sync object A and
-// then later use that same sync object in dvpMemCpy*
-// operation for a source or target CUDA buffer. The same
-// semaphore memory can still be used for two different sync
-// objects.
-//
-// Parameters: desc[IN] - data describing the sync object
-// syncObject[OUT] - handle to sync object
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-#define dvpImportSyncObject DVPAPI_GET_FUN(__dvpImportSyncObject)
-
-//------------------------------------------------------------------------
-// Function: dvpFreeSyncObject
-//
-// Description: dvpFreeSyncObject waits for any outstanding releases on
-// this sync object before freeing the resources allocated for
-// the specified sync object. The application must make sure
-// any outstanding acquire operations have already been
-// completed.
-//
-// If OpenGL is being used and the app's GL context is being
-// shared (via the DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT flag),
-// then dvpFreeSyncObject needs to be called while each context,
-// on which the sync object was used, is current. If
-// DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT is used and there are out
-// standing contexts from which this sync object must be free'd
-// then dvpFreeSyncObject will return DVP_STATUS_SYNC_STILL_BOUND.
-//
-// Parameters: syncObject[IN] - handle to sync object to be free'd
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-// DVP_STATUS_SYNC_STILL_BOUND
-//------------------------------------------------------------------------
-#define dvpFreeSyncObject DVPAPI_GET_FUN(__dvpFreeSyncObject)
-
-
-//------------------------------------------------------------------------
-// Function: dvpMapBufferEndAPI
-//
-// Description: Tells DVP to setup a signal for this buffer in the
-// callers API context or device. The signal follows all
-// previous API operations up to this point and, thus,
-// allows subsequent DVP calls to know when then this buffer
-// is ready for use within the DVP library. This function
-// would be followed by a call to dvpMapBufferWaitDVP to
-// synchronize rendering in the API stream and the DVP
-// stream.
-//
-// If OpenGL or CUDA is used, the OpenGL/CUDA context
-// must be current at time of call.
-//
-// The use of dvpMapBufferEndAPI is NOT recommended for
-// CUDA synchronisation, as it is more optimal to use a
-// applcation CUDA stream in conjunction with
-// dvpMapBufferEndCUDAStream. This allows the driver to
-// do optimisations, such as parllelise the copy operations
-// and compute.
-//
-// This must be called outside the dvpBegin/dvpEnd pair. In
-// addition, this call is not thread safe and must be called
-// from or fenced against the rendering thread associated with
-// the context or device.
-//
-// Parameters: gpuBufferHandle[IN] - buffer to track
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-// DVP_STATUS_UNSIGNALED - returned if the API is
-// unable to place a signal in the API context queue
-//------------------------------------------------------------------------
-#define dvpMapBufferEndAPI DVPAPI_GET_FUN(__dvpMapBufferEndAPI)
-
-//------------------------------------------------------------------------
-// Function: dvpMapBufferEndAPI
-//
-// Description: Tells DVP to setup a signal for this buffer in the
-// callers API context or device. The signal follows all
-// previous API operations up to this point and, thus,
-// allows subsequent DVP calls to know when then this buffer
-// is ready for use within the DVP library. This function
-// would be followed by a call to dvpMapBufferWaitDVP to
-// synchronize rendering in the API stream and the DVP
-// stream.
-//
-// If OpenGL or CUDA is used, the OpenGL/CUDA context
-// must be current at time of call.
-//
-// The use of dvpMapBufferEndAPI is NOT recommended for
-// CUDA synchronisation, as it is more optimal to use a
-// applcation CUDA stream in conjunction with
-// dvpMapBufferEndCUDAStream. This allows the driver to
-// do optimisations, such as parllelise the copy operations
-// and compute.
-//
-// This must be called outside the dvpBegin/dvpEnd pair. In
-// addition, this call is not thread safe and must be called
-// from or fenced against the rendering thread associated with
-// the context or device.
-//
-// Parameters: gpuBufferHandle[IN] - buffer to track
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-// DVP_STATUS_UNSIGNALED - returned if the API is
-// unable to place a signal in the API context queue
-//------------------------------------------------------------------------
-#define dvpMapBufferEndAPI DVPAPI_GET_FUN(__dvpMapBufferEndAPI)
-
-//------------------------------------------------------------------------
-// Function: dvpMapBufferWaitDVP
-//
-// Description: Tells DVP to make the DVP stream wait for a previous
-// signal triggered by a dvpMapBufferEndAPI call.
-//
-// This must be called inside the dvpBegin/dvpEnd pair.
-//
-// Parameters: gpuBufferHandle[IN] - buffer to track
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-#define dvpMapBufferWaitDVP DVPAPI_GET_FUN(__dvpMapBufferWaitDVP)
-
-//------------------------------------------------------------------------
-// Function: dvpMapBufferEndDVP
-//
-// Description: Tells DVP to setup a signal for this buffer after
-// DVP operations are complete. The signal allows
-// the API to know when then this buffer is
-// ready for use within a API stream. This function would
-// be followed by a call to dvpMapBufferWaitAPI to
-// synchronize copies in the DVP stream and the API
-// rendering stream.
-//
-// This must be called inside the dvpBegin/dvpEnd pair.
-//
-// Parameters: gpuBufferHandle[IN] - buffer to track
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-#define dvpMapBufferEndDVP DVPAPI_GET_FUN(__dvpMapBufferEndDVP)
-
-//------------------------------------------------------------------------
-// Function: dvpMapBufferWaitAPI
-//
-// Description: Tells DVP to make the current API context or device to
-// wait for a previous signal triggered by a
-// dvpMapBufferEndDVP call.
-//
-// The use of dvpMapBufferWaitCUDAStream is NOT recommended for
-// CUDA synchronisation, as it is more optimal to use a
-// applcation CUDA stream in conjunction with
-// dvpMapBufferEndCUDAStream. This allows the driver to
-// do optimisations, such as parllelise the copy operations
-// and compute.
-//
-// If OpenGL or CUDA is used, the OpenGL/CUDA context
-// must be current at time of call.
-//
-// This must be called outside the dvpBegin/dvpEnd pair. In
-// addition, this call is not thread safe and must be called
-// from or fenced against the rendering thread associated with
-// the context or device.
-//
-// Parameters: gpuBufferHandle[IN] - buffer to track
-//
-// Returns: DVP_STATUS_OK
-// DVP_STATUS_INVALID_PARAMETER
-// DVP_STATUS_ERROR
-//------------------------------------------------------------------------
-#define dvpMapBufferWaitAPI DVPAPI_GET_FUN(__dvpMapBufferWaitAPI)
-
-//------------------------------------------------------------------------
-// If the multiple GL contexts used in the application access the same
-// sysmem buffers, then application must create those GL contexts with
-// display list shared.
-//------------------------------------------------------------------------
-#define dvpBindToGLCtx DVPAPI_GET_FUN(__dvpBindToGLCtx)
-#define dvpGetRequiredConstantsGLCtx DVPAPI_GET_FUN(__dvpGetRequiredConstantsGLCtx)
-#define dvpCreateGPUTextureGL DVPAPI_GET_FUN(__dvpCreateGPUTextureGL)
-#define dvpUnbindFromGLCtx DVPAPI_GET_FUN(__dvpUnbindFromGLCtx)
-
-
-DVPAPI PFNDVPBEGIN __dvpBegin;
-DVPAPI PFNDVPEND __dvpEnd;
-DVPAPI PFNDVPCREATEBUFFER __dvpCreateBuffer;
-DVPAPI PFNDVPDESTROYBUFFER __dvpDestroyBuffer;
-DVPAPI PFNDVPFREEBUFFER __dvpFreeBuffer;
-DVPAPI PFNDVPMEMCPYLINED __dvpMemcpyLined;
-DVPAPI PFNDVPMEMCPY __dvpMemcpy;
-DVPAPI PFNDVPIMPORTSYNCOBJECT __dvpImportSyncObject;
-DVPAPI PFNDVPFREESYNCOBJECT __dvpFreeSyncObject;
-DVPAPI PFNDVPMAPBUFFERENDAPI __dvpMapBufferEndAPI;
-DVPAPI PFNDVPMAPBUFFERWAITDVP __dvpMapBufferWaitDVP;
-DVPAPI PFNDVPMAPBUFFERENDDVP __dvpMapBufferEndDVP;
-DVPAPI PFNDVPMAPBUFFERWAITAPI __dvpMapBufferWaitAPI;
-
-
-//------------------------------------------------------------------------
-// If the multiple GL contexts used in the application access the same
-// sysmem buffers, then application must create those GL contexts with
-// display list shared.
-//------------------------------------------------------------------------
-DVPAPI PFNDVPBINDTOGLCTX __dvpBindToGLCtx;
-DVPAPI PFNDVPGETREQUIREDCONSTANTSGLCTX __dvpGetRequiredConstantsGLCtx;
-DVPAPI PFNDVPCREATEGPUTEXTUREGL __dvpCreateGPUTextureGL;
-DVPAPI PFNDVPUNBINDFROMGLCTX __dvpUnbindFromGLCtx;
-
-#define DVPAPI_GET_FUN(x) x
-
-#endif // WIN32
-
-#endif // __DVPAPI_H__
-
diff --git a/intern/moto/CMakeLists.txt b/intern/moto/CMakeLists.txt
deleted file mode 100644
index d17181c6809..00000000000
--- a/intern/moto/CMakeLists.txt
+++ /dev/null
@@ -1,77 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- include
-)
-
-set(INC_SYS
-
-)
-
-set(SRC
- intern/MT_Assert.cpp
- intern/MT_CmMatrix4x4.cpp
- intern/MT_Matrix3x3.cpp
- intern/MT_Matrix4x4.cpp
- intern/MT_Point3.cpp
- intern/MT_Quaternion.cpp
- intern/MT_Transform.cpp
- intern/MT_Vector2.cpp
- intern/MT_Vector3.cpp
- intern/MT_Vector4.cpp
- intern/MT_random.cpp
-
- include/MT_CmMatrix4x4.h
- include/MT_Matrix3x3.h
- include/MT_Matrix4x4.h
- include/MT_MinMax.h
- include/MT_Optimize.h
- include/MT_Point2.h
- include/MT_Point3.h
- include/MT_Quaternion.h
- include/MT_Scalar.h
- include/MT_Stream.h
- include/MT_Transform.h
- include/MT_Tuple2.h
- include/MT_Tuple3.h
- include/MT_Tuple4.h
- include/MT_Vector2.h
- include/MT_Vector3.h
- include/MT_Vector4.h
- include/MT_assert.h
- include/MT_random.h
-
- include/MT_Matrix3x3.inl
- include/MT_Matrix4x4.inl
- include/MT_Point2.inl
- include/MT_Point3.inl
- include/MT_Quaternion.inl
- include/MT_Vector2.inl
- include/MT_Vector3.inl
- include/MT_Vector4.inl
-)
-
-blender_add_lib(bf_intern_moto "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/moto/include/MT_CmMatrix4x4.h b/intern/moto/include/MT_CmMatrix4x4.h
deleted file mode 100644
index 53fdd41fb28..00000000000
--- a/intern/moto/include/MT_CmMatrix4x4.h
+++ /dev/null
@@ -1,148 +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 moto/include/MT_CmMatrix4x4.h
- * \ingroup moto
- */
-
-
-#ifndef INCLUDED_MT_CmMatrix4x4
-#define INCLUDED_MT_CmMatrix4x4
-
-/**
- * A 4x4 matrix. This is an OpenGl style matrix (column major) meaning
- * that the vector {m[0][0],m[0][1],m[0][2],m[0][3]} is the first column of
- * the matrix , the same as what you get if you transform {1,0,0,0}.
- * This makes it easy to transform stuff to OpenGl. Please note that the
- * the other MoTo matrices are row major.
- *
- * This class should be deprecated in favour of the more consistent
- * MT_Matrix4x4. Please do not start using this class.
- */
-
-#include "MT_Scalar.h"
-
-class MT_Point3;
-class MT_Vector3;
-
-class MT_CmMatrix4x4
-{
-
-public :
-
- MT_CmMatrix4x4(
- const MT_Scalar value[4][4]
- );
-
- MT_CmMatrix4x4(
- );
-
-
- MT_CmMatrix4x4(
- const MT_Scalar value[16]
- );
-
- MT_CmMatrix4x4(
- const MT_CmMatrix4x4 & other
- );
-
- MT_CmMatrix4x4(
- const MT_Point3& orig,
- const MT_Vector3& dir,
- const MT_Vector3 up
- );
-
- void
- Identity(
- );
-
- void
- SetMatrix(
- const MT_CmMatrix4x4 & other
- );
-
- MT_Scalar*
- getPointer(
- );
-
- const
- MT_Scalar*
- getPointer(
- ) const;
-
- void
- setElem(
- int pos,
- MT_Scalar newvalue
- );
-
- MT_Vector3
- GetRight(
- ) const;
-
- MT_Vector3
- GetUp(
- ) const;
-
- MT_Vector3
- GetDir(
- ) const;
-
- MT_Point3
- GetPos(
- ) const;
-
- void
- SetPos(
- const MT_Vector3 & v
- );
-
- MT_Scalar&
- operator (
- ) (int row,int col) { return m_V[col][row]; }
-
- static
- MT_CmMatrix4x4
- Perspective(
- MT_Scalar inLeft,
- MT_Scalar inRight,
- MT_Scalar inBottom,
- MT_Scalar inTop,
- MT_Scalar inNear,
- MT_Scalar inFar
- );
-
-protected:
- union
- {
- MT_Scalar m_V[4][4];
- MT_Scalar m_Vflat[16];
- };
-};
-
-#endif //MT_CmMatrix4x4
-
diff --git a/intern/moto/include/MT_Matrix3x3.h b/intern/moto/include/MT_Matrix3x3.h
deleted file mode 100644
index 6f965f59069..00000000000
--- a/intern/moto/include/MT_Matrix3x3.h
+++ /dev/null
@@ -1,276 +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 moto/include/MT_Matrix3x3.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_MATRIX3X3_H
-#define MT_MATRIX3X3_H
-
-#include <MT_assert.h>
-
-#include "MT_Vector3.h"
-#include "MT_Quaternion.h"
-
-class MT_Matrix3x3 {
-public:
- MT_Matrix3x3() {}
- MT_Matrix3x3(const float *m) { setValue(m); }
- MT_Matrix3x3(const double *m) { setValue(m); }
- MT_Matrix3x3(const MT_Quaternion& q) { setRotation(q); }
-
- MT_Matrix3x3(const MT_Quaternion& q, const MT_Vector3& s) {
- setRotation(q);
- scale(s[0], s[1], s[2]);
- }
-
- MT_Matrix3x3(const MT_Vector3& euler) { setEuler(euler); }
- MT_Matrix3x3(const MT_Vector3& euler, const MT_Vector3& s) {
- setEuler(euler);
- scale(s[0], s[1], s[2]);
- }
-
- MT_Matrix3x3(MT_Scalar xx, MT_Scalar xy, MT_Scalar xz,
- MT_Scalar yx, MT_Scalar yy, MT_Scalar yz,
- MT_Scalar zx, MT_Scalar zy, MT_Scalar zz) {
- setValue(xx, xy, xz,
- yx, yy, yz,
- zx, zy, zz);
- }
-
- MT_Vector3& operator[](int i) { return m_el[i]; }
- const MT_Vector3& operator[](int i) const { return m_el[i]; }
-
- MT_Vector3 getColumn(int i) const {
- return MT_Vector3(m_el[0][i], m_el[1][i], m_el[2][i]);
- }
-
- void setColumn(int i, const MT_Vector3& v) {
- m_el[0][i] = v[0];
- m_el[1][i] = v[1];
- m_el[2][i] = v[2];
- }
-
- void setRow(int i, const MT_Vector3& v) {
- m_el[i][0] = v[0];
- m_el[i][1] = v[1];
- m_el[i][2] = v[2];
- }
-
- void setValue(const float *m) {
- m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m++;
- m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m++;
- m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m;
- }
-
- void setValue(const double *m) {
- m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m++;
- m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m++;
- m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m;
- }
-
- void setValue3x3(const float *m) {
- m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++;
- m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++;
- m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m;
- }
-
- void setValue3x3(const double *m) {
- m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++;
- m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++;
- m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m;
- }
-
- void setValue(MT_Scalar xx, MT_Scalar xy, MT_Scalar xz,
- MT_Scalar yx, MT_Scalar yy, MT_Scalar yz,
- MT_Scalar zx, MT_Scalar zy, MT_Scalar zz) {
- m_el[0][0] = xx; m_el[0][1] = xy; m_el[0][2] = xz;
- m_el[1][0] = yx; m_el[1][1] = yy; m_el[1][2] = yz;
- m_el[2][0] = zx; m_el[2][1] = zy; m_el[2][2] = zz;
- }
-
- void setRotation(const MT_Quaternion& q) {
- MT_Scalar d = q.length2();
- MT_assert(!MT_fuzzyZero2(d));
- MT_Scalar s = MT_Scalar(2.0f) / d;
- MT_Scalar xs = q[0] * s, ys = q[1] * s, zs = q[2] * s;
- MT_Scalar wx = q[3] * xs, wy = q[3] * ys, wz = q[3] * zs;
- MT_Scalar xx = q[0] * xs, xy = q[0] * ys, xz = q[0] * zs;
- MT_Scalar yy = q[1] * ys, yz = q[1] * zs, zz = q[2] * zs;
- setValue(MT_Scalar(1.0f) - (yy + zz), xy - wz , xz + wy,
- xy + wz , MT_Scalar(1.0f) - (xx + zz), yz - wx,
- xz - wy , yz + wx, MT_Scalar(1.0f) - (xx + yy));
- }
-
- /**
- * setEuler
- * @param euler a const reference to a MT_Vector3 of euler angles
- * These angles are used to produce a rotation matrix. The euler
- * angles are applied in ZYX order. I.e a vector is first rotated
- * about X then Y and then Z
- **/
-
- void setEuler(const MT_Vector3& euler) {
- MT_Scalar ci = cosf(euler[0]);
- MT_Scalar cj = cosf(euler[1]);
- MT_Scalar ch = cosf(euler[2]);
- MT_Scalar si = sinf(euler[0]);
- MT_Scalar sj = sinf(euler[1]);
- MT_Scalar sh = sinf(euler[2]);
- MT_Scalar cc = ci * ch;
- MT_Scalar cs = ci * sh;
- MT_Scalar sc = si * ch;
- MT_Scalar ss = si * sh;
-
- setValue(cj * ch, sj * sc - cs, sj * cc + ss,
- cj * sh, sj * ss + cc, sj * cs - sc,
- -sj, cj * si, cj * ci);
- }
-
- void getEuler(MT_Scalar& yaw, MT_Scalar& pitch, MT_Scalar& roll) const
- {
- if (m_el[2][0] != -1.0f && m_el[2][0] != 1.0f) {
- pitch = MT_Scalar(-asinf(m_el[2][0]));
- yaw = MT_Scalar(atan2f(m_el[2][1] / cosf(pitch), m_el[2][2] / cosf(pitch)));
- roll = MT_Scalar(atan2f(m_el[1][0] / cosf(pitch), m_el[0][0] / cosf(pitch)));
- }
- else {
- roll = MT_Scalar(0);
- if (m_el[2][0] == -1.0f) {
- pitch = (float)MT_PI / 2.0f;
- yaw = MT_Scalar(atan2f(m_el[0][1], m_el[0][2]));
- }
- else {
- pitch = (float)-MT_PI / 2.0f;
- yaw = MT_Scalar(atan2f(m_el[0][1], m_el[0][2]));
- }
- }
- }
-
- void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z) {
- m_el[0][0] *= x; m_el[0][1] *= y; m_el[0][2] *= z;
- m_el[1][0] *= x; m_el[1][1] *= y; m_el[1][2] *= z;
- m_el[2][0] *= x; m_el[2][1] *= y; m_el[2][2] *= z;
- }
-
- MT_Matrix3x3 scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z) const {
- return MT_Matrix3x3(m_el[0][0] * x, m_el[0][1] * y, m_el[0][2] * z,
- m_el[1][0] * x, m_el[1][1] * y, m_el[1][2] * z,
- m_el[2][0] * x, m_el[2][1] * y, m_el[2][2] * z);
- }
-
- void setIdentity() {
- setValue(MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f),
- MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f),
- MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f));
- }
-
- void getValue(float *m) const {
- *m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0]; *m++ = (float) 0.0f;
- *m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1]; *m++ = (float) 0.0f;
- *m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2]; *m = (float) 0.0f;
- }
-
- void getValue(double *m) const {
- *m++ = m_el[0][0]; *m++ = m_el[1][0]; *m++ = m_el[2][0]; *m++ = 0.0;
- *m++ = m_el[0][1]; *m++ = m_el[1][1]; *m++ = m_el[2][1]; *m++ = 0.0;
- *m++ = m_el[0][2]; *m++ = m_el[1][2]; *m++ = m_el[2][2]; *m = 0.0;
- }
-
- void getValue3x3(float *m) const {
- *m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0];
- *m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1];
- *m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2];
- }
-
- void getValue3x3(double *m) const {
- *m++ = m_el[0][0]; *m++ = m_el[1][0]; *m++ = m_el[2][0];
- *m++ = m_el[0][1]; *m++ = m_el[1][1]; *m++ = m_el[2][1];
- *m++ = m_el[0][2]; *m++ = m_el[1][2]; *m++ = m_el[2][2];
- }
-
- MT_Quaternion getRotation() const;
-
- MT_Matrix3x3& operator*=(const MT_Matrix3x3& m);
-
- MT_Scalar tdot(int c, const MT_Vector3& v) const {
- return m_el[0][c] * v[0] + m_el[1][c] * v[1] + m_el[2][c] * v[2];
- }
-
- MT_Scalar cofac(int r1, int c1, int r2, int c2) const {
- return m_el[r1][c1] * m_el[r2][c2] - m_el[r1][c2] * m_el[r2][c1];
- }
-
- MT_Scalar determinant() const;
- MT_Matrix3x3 adjoint() const;
-
- MT_Matrix3x3 absolute() const;
-
- MT_Matrix3x3 transposed() const;
- void transpose();
-
- MT_Matrix3x3 inverse() const;
- void invert();
-
-protected:
-
- MT_Vector3 m_el[3];
-};
-
-MT_Vector3 operator*(const MT_Matrix3x3& m, const MT_Vector3& v);
-MT_Vector3 operator*(const MT_Vector3& v, const MT_Matrix3x3& m);
-MT_Matrix3x3 operator*(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2);
-
-MT_Matrix3x3 MT_multTransposeLeft(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2);
-MT_Matrix3x3 MT_multTransposeRight(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2);
-
-inline MT_OStream& operator<<(MT_OStream& os, const MT_Matrix3x3& m) {
- return os << m[0] << GEN_endl << m[1] << GEN_endl << m[2] << GEN_endl;
-}
-
-#ifdef GEN_INLINED
-#include "MT_Matrix3x3.inl"
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Matrix3x3.inl b/intern/moto/include/MT_Matrix3x3.inl
deleted file mode 100644
index 614e4f93a81..00000000000
--- a/intern/moto/include/MT_Matrix3x3.inl
+++ /dev/null
@@ -1,128 +0,0 @@
-#include "MT_Optimize.h"
-
-GEN_INLINE MT_Quaternion MT_Matrix3x3::getRotation() const {
- static int next[3] = { 1, 2, 0 };
-
- MT_Quaternion result;
-
- MT_Scalar trace = m_el[0][0] + m_el[1][1] + m_el[2][2];
-
- if (trace > 0.0f)
- {
- MT_Scalar s = sqrtf(trace + MT_Scalar(1.0f));
- result[3] = s * MT_Scalar(0.5f);
- s = MT_Scalar(0.5f) / s;
-
- result[0] = (m_el[2][1] - m_el[1][2]) * s;
- result[1] = (m_el[0][2] - m_el[2][0]) * s;
- result[2] = (m_el[1][0] - m_el[0][1]) * s;
- }
- else
- {
- int i = 0;
- if (m_el[1][1] > m_el[0][0])
- i = 1;
- if (m_el[2][2] > m_el[i][i])
- i = 2;
-
- int j = next[i];
- int k = next[j];
-
- MT_Scalar s = sqrtf(m_el[i][i] - m_el[j][j] - m_el[k][k] + MT_Scalar(1.0f));
-
- result[i] = s * MT_Scalar(0.5f);
-
- s = MT_Scalar(0.5f) / s;
-
- result[3] = (m_el[k][j] - m_el[j][k]) * s;
- result[j] = (m_el[j][i] + m_el[i][j]) * s;
- result[k] = (m_el[k][i] + m_el[i][k]) * s;
- }
- return result;
-}
-
-GEN_INLINE MT_Matrix3x3& MT_Matrix3x3::operator*=(const MT_Matrix3x3& m) {
- setValue(m.tdot(0, m_el[0]), m.tdot(1, m_el[0]), m.tdot(2, m_el[0]),
- m.tdot(0, m_el[1]), m.tdot(1, m_el[1]), m.tdot(2, m_el[1]),
- m.tdot(0, m_el[2]), m.tdot(1, m_el[2]), m.tdot(2, m_el[2]));
- return *this;
-}
-
-GEN_INLINE MT_Scalar MT_Matrix3x3::determinant() const {
- return MT_triple((*this)[0], (*this)[1], (*this)[2]);
-}
-
-GEN_INLINE MT_Matrix3x3 MT_Matrix3x3::absolute() const {
- return
- MT_Matrix3x3(MT_abs(m_el[0][0]), MT_abs(m_el[0][1]), MT_abs(m_el[0][2]),
- MT_abs(m_el[1][0]), MT_abs(m_el[1][1]), MT_abs(m_el[1][2]),
- MT_abs(m_el[2][0]), MT_abs(m_el[2][1]), MT_abs(m_el[2][2]));
-}
-
-GEN_INLINE MT_Matrix3x3 MT_Matrix3x3::transposed() const {
- return MT_Matrix3x3(m_el[0][0], m_el[1][0], m_el[2][0],
- m_el[0][1], m_el[1][1], m_el[2][1],
- m_el[0][2], m_el[1][2], m_el[2][2]);
-}
-
-GEN_INLINE void MT_Matrix3x3::transpose() {
- *this = transposed();
-}
-
-GEN_INLINE MT_Matrix3x3 MT_Matrix3x3::adjoint() const {
- return
- MT_Matrix3x3(cofac(1, 1, 2, 2), cofac(0, 2, 2, 1), cofac(0, 1, 1, 2),
- cofac(1, 2, 2, 0), cofac(0, 0, 2, 2), cofac(0, 2, 1, 0),
- cofac(1, 0, 2, 1), cofac(0, 1, 2, 0), cofac(0, 0, 1, 1));
-}
-
-GEN_INLINE MT_Matrix3x3 MT_Matrix3x3::inverse() const {
- MT_Vector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1));
- MT_Scalar det = MT_dot((*this)[0], co);
- MT_assert(!MT_fuzzyZero2(det));
- MT_Scalar s = MT_Scalar(1.0f) / det;
- return
- MT_Matrix3x3(co[0] * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s,
- co[1] * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s,
- co[2] * s, cofac(0, 1, 2, 0) * s, cofac(0, 0, 1, 1) * s);
-}
-
-GEN_INLINE void MT_Matrix3x3::invert() {
- *this = inverse();
-}
-
-GEN_INLINE MT_Vector3 operator*(const MT_Matrix3x3& m, const MT_Vector3& v) {
- return MT_Vector3(MT_dot(m[0], v), MT_dot(m[1], v), MT_dot(m[2], v));
-}
-
-GEN_INLINE MT_Vector3 operator*(const MT_Vector3& v, const MT_Matrix3x3& m) {
- return MT_Vector3(m.tdot(0, v), m.tdot(1, v), m.tdot(2, v));
-}
-
-GEN_INLINE MT_Matrix3x3 operator*(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2) {
- return
- MT_Matrix3x3(m2.tdot(0, m1[0]), m2.tdot(1, m1[0]), m2.tdot(2, m1[0]),
- m2.tdot(0, m1[1]), m2.tdot(1, m1[1]), m2.tdot(2, m1[1]),
- m2.tdot(0, m1[2]), m2.tdot(1, m1[2]), m2.tdot(2, m1[2]));
-}
-
-GEN_INLINE MT_Matrix3x3 MT_multTransposeLeft(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2) {
- return MT_Matrix3x3(
- m1[0][0] * m2[0][0] + m1[1][0] * m2[1][0] + m1[2][0] * m2[2][0],
- m1[0][0] * m2[0][1] + m1[1][0] * m2[1][1] + m1[2][0] * m2[2][1],
- m1[0][0] * m2[0][2] + m1[1][0] * m2[1][2] + m1[2][0] * m2[2][2],
- m1[0][1] * m2[0][0] + m1[1][1] * m2[1][0] + m1[2][1] * m2[2][0],
- m1[0][1] * m2[0][1] + m1[1][1] * m2[1][1] + m1[2][1] * m2[2][1],
- m1[0][1] * m2[0][2] + m1[1][1] * m2[1][2] + m1[2][1] * m2[2][2],
- m1[0][2] * m2[0][0] + m1[1][2] * m2[1][0] + m1[2][2] * m2[2][0],
- m1[0][2] * m2[0][1] + m1[1][2] * m2[1][1] + m1[2][2] * m2[2][1],
- m1[0][2] * m2[0][2] + m1[1][2] * m2[1][2] + m1[2][2] * m2[2][2]);
-}
-
-GEN_INLINE MT_Matrix3x3 MT_multTransposeRight(const MT_Matrix3x3& m1, const MT_Matrix3x3& m2) {
- return
- MT_Matrix3x3(m1[0].dot(m2[0]), m1[0].dot(m2[1]), m1[0].dot(m2[2]),
- m1[1].dot(m2[0]), m1[1].dot(m2[1]), m1[1].dot(m2[2]),
- m1[2].dot(m2[0]), m1[2].dot(m2[1]), m1[2].dot(m2[2]));
-
-}
diff --git a/intern/moto/include/MT_Matrix4x4.h b/intern/moto/include/MT_Matrix4x4.h
deleted file mode 100644
index 2ecac81ea6f..00000000000
--- a/intern/moto/include/MT_Matrix4x4.h
+++ /dev/null
@@ -1,262 +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 moto/include/MT_Matrix4x4.h
- * \ingroup moto
- */
-
-
-/**
-
- * Copyright (C) 2001 NaN Technologies B.V.
- * A 4x4 matrix compatible with other stuff.
- */
-
-#ifndef MT_MATRIX4X4_H
-#define MT_MATRIX4X4_H
-
-#include <MT_assert.h>
-
-#include "MT_Vector4.h"
-#include "MT_Transform.h"
-
-// Row-major 4x4 matrix
-
-class MT_Matrix4x4 {
-public:
- /**
- * Empty contructor.
- */
- MT_Matrix4x4() {}
- /**
- * Initialize all fields with the values pointed at by m. A
- * contigous block of 16 values is read. */
- MT_Matrix4x4(const float *m) { setValue(m); }
- /**
- * Initialize all fields with the values pointed at by m. A
- * contigous block of 16 values is read. */
- MT_Matrix4x4(const double *m) { setValue(m); }
-
- /**
- * Initialise with these 16 explicit values.
- */
- MT_Matrix4x4(MT_Scalar xx, MT_Scalar xy, MT_Scalar xz, MT_Scalar xw,
- MT_Scalar yx, MT_Scalar yy, MT_Scalar yz, MT_Scalar yw,
- MT_Scalar zx, MT_Scalar zy, MT_Scalar zz, MT_Scalar zw,
- MT_Scalar wx, MT_Scalar wy, MT_Scalar wz, MT_Scalar ww) {
- setValue(xx, xy, xz, xw,
- yx, yy, yz, yw,
- zx, zy, zz, zw,
- wx, wy, wz, ww);
- }
-
- /**
- * Initialize from an MT_Transform.
- */
- MT_Matrix4x4(const MT_Transform &t) {
-
- const MT_Matrix3x3 &basis = t.getBasis();
- const MT_Vector3 &origin = t.getOrigin();
-
- setValue(
- basis[0][0],basis[0][1],basis[0][2],origin[0],
- basis[1][0],basis[1][1],basis[1][2],origin[1],
- basis[2][0],basis[2][1],basis[2][2],origin[2],
- MT_Scalar(0.0f),MT_Scalar(0.0f),MT_Scalar(0.0f),MT_Scalar(1.0f)
- );
- }
-
- /**
- * Get the i-th row.
- */
- MT_Vector4& operator[](int i) { return m_el[i]; }
- /**
- * Get the i-th row.
- */
- const MT_Vector4& operator[](int i) const { return m_el[i]; }
-
- /**
- * Set the matrix to the values pointer at by m. A contiguous
- * block of 16 values is copied. */
- void setValue(const float *m) {
- m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m_el[3][0] = *m++;
- m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m_el[3][1] = *m++;
- m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m++; m_el[3][2] = *m++;
- m_el[0][3] = *m++; m_el[1][3] = *m++; m_el[2][3] = *m++; m_el[3][3] = *m;
- }
-
- /**
- * Set the matrix to the values pointer at by m. A contiguous
- * block of 16 values is copied.
- */
- void setValue(const double *m) {
- m_el[0][0] = *m++; m_el[1][0] = *m++; m_el[2][0] = *m++; m_el[3][0] = *m++;
- m_el[0][1] = *m++; m_el[1][1] = *m++; m_el[2][1] = *m++; m_el[3][1] = *m++;
- m_el[0][2] = *m++; m_el[1][2] = *m++; m_el[2][2] = *m++; m_el[3][2] = *m++;
- m_el[0][3] = *m++; m_el[1][3] = *m++; m_el[2][3] = *m++; m_el[3][3] = *m;
- }
-
- /**
- * Set the matrix to these 16 explicit values.
- */
- void setValue(MT_Scalar xx, MT_Scalar xy, MT_Scalar xz, MT_Scalar xw,
- MT_Scalar yx, MT_Scalar yy, MT_Scalar yz, MT_Scalar yw,
- MT_Scalar zx, MT_Scalar zy, MT_Scalar zz, MT_Scalar zw,
- MT_Scalar wx, MT_Scalar wy, MT_Scalar wz, MT_Scalar ww) {
- m_el[0][0] = xx; m_el[0][1] = xy; m_el[0][2] = xz; m_el[0][3] = xw;
- m_el[1][0] = yx; m_el[1][1] = yy; m_el[1][2] = yz; m_el[1][3] = yw;
- m_el[2][0] = zx; m_el[2][1] = zy; m_el[2][2] = zz; m_el[2][3] = zw;
- m_el[3][0] = wx; m_el[3][1] = wy; m_el[3][2] = wz; m_el[3][3] = ww;
- }
-
- /**
- * Scale the columns of this matrix with x, y, z, w respectively.
- */
- void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) {
- m_el[0][0] *= x; m_el[0][1] *= y; m_el[0][2] *= z; m_el[0][3] *= w;
- m_el[1][0] *= x; m_el[1][1] *= y; m_el[1][2] *= z; m_el[1][3] *= w;
- m_el[2][0] *= x; m_el[2][1] *= y; m_el[2][2] *= z; m_el[2][3] *= w;
- m_el[3][0] *= x; m_el[3][1] *= y; m_el[3][2] *= z; m_el[3][3] *= w;
- }
-
- /**
- * Scale the rows of this matrix with x, y, z, w respectively.
- */
- void tscale(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) {
- m_el[0][0] *= x; m_el[1][0] *= y; m_el[2][0] *= z; m_el[3][0] *= w;
- m_el[0][1] *= x; m_el[1][1] *= y; m_el[2][1] *= z; m_el[3][1] *= w;
- m_el[0][2] *= x; m_el[1][2] *= y; m_el[2][2] *= z; m_el[3][2] *= w;
- m_el[0][3] *= x; m_el[1][3] *= y; m_el[2][3] *= z; m_el[3][3] *= w;
- }
-
- /**
- * Return a column-scaled version of this matrix.
- */
- MT_Matrix4x4 scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) const {
- return MT_Matrix4x4(m_el[0][0] * x, m_el[0][1] * y, m_el[0][2] * z, m_el[0][3] * w,
- m_el[1][0] * x, m_el[1][1] * y, m_el[1][2] * z, m_el[1][3] * w,
- m_el[2][0] * x, m_el[2][1] * y, m_el[2][2] * z, m_el[2][3] * w,
- m_el[3][0] * x, m_el[3][1] * y, m_el[3][2] * z, m_el[3][3] * w);
- }
-
- /**
- * Set this matrix to I.
- */
- void setIdentity() {
- setValue(MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f),
- MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f),
- MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f),
- MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f));
- }
-
- /**
- * Read the element from row i, column j.
- */
- float getElement(int i, int j) {
- return (float) m_el[i][j];
- }
-
- /**
- * Copy the contents to a contiguous block of 16 floats.
- */
- void getValue(float *m) const {
- *m++ = (float) m_el[0][0]; *m++ = (float) m_el[1][0]; *m++ = (float) m_el[2][0]; *m++ = (float) m_el[3][0];
- *m++ = (float) m_el[0][1]; *m++ = (float) m_el[1][1]; *m++ = (float) m_el[2][1]; *m++ = (float) m_el[3][1];
- *m++ = (float) m_el[0][2]; *m++ = (float) m_el[1][2]; *m++ = (float) m_el[2][2]; *m++ = (float) m_el[3][2];
- *m++ = (float) m_el[0][3]; *m++ = (float) m_el[1][3]; *m++ = (float) m_el[2][3]; *m = (float) m_el[3][3];
- }
-
- /**
- * Copy the contents to a contiguous block of 16 doubles.
- */
- void getValue(double *m) const {
- *m++ = m_el[0][0]; *m++ = m_el[1][0]; *m++ = m_el[2][0]; *m++ = m_el[3][0];
- *m++ = m_el[0][1]; *m++ = m_el[1][1]; *m++ = m_el[2][1]; *m++ = m_el[3][1];
- *m++ = m_el[0][2]; *m++ = m_el[1][2]; *m++ = m_el[2][2]; *m++ = m_el[3][2];
- *m++ = m_el[0][3]; *m++ = m_el[1][3]; *m++ = m_el[2][3]; *m = m_el[3][3];
- }
-
- /**
- * Left-multiply this matrix with the argument.
- */
- MT_Matrix4x4& operator*=(const MT_Matrix4x4& m);
-
- /**
- * Left-multiply column c with row vector c.
- */
- MT_Scalar tdot(int c, const MT_Vector4& v) const {
- return m_el[0][c] * v[0]
- + m_el[1][c] * v[1]
- + m_el[2][c] * v[2]
- + m_el[3][c] * v[3];
- }
-
- /* I'll postpone this for now... - nzc*/
-/* MT_Scalar determinant() const; */
-/* MT_Matrix4x4 adjoint() const; */
-/* MT_Matrix4x4 inverse() const; */
-
- MT_Matrix4x4 absolute() const;
-
- MT_Matrix4x4 transposed() const;
- void transpose();
-
- MT_Matrix4x4 inverse() const;
- void invert();
-
-protected:
- /**
- * Access with [row index][column index]
- */
- MT_Vector4 m_el[4];
-};
-
-/* These multiplicators do exactly what you ask from them: they
- * multiply in the indicated order. */
-MT_Vector4 operator*(const MT_Matrix4x4& m, const MT_Vector4& v);
-MT_Vector4 operator*(const MT_Vector4& v, const MT_Matrix4x4& m);
-MT_Matrix4x4 operator*(const MT_Matrix4x4& m1, const MT_Matrix4x4& m2);
-
-/* MT_Matrix4x4 MT_multTransposeLeft(const MT_Matrix4x4& m1, const MT_Matrix4x4& m2); */
-/* MT_Matrix4x4 MT_multTransposeRight(const MT_Matrix4x4& m1, const MT_Matrix4x4& m2); */
-
-inline MT_OStream& operator<<(MT_OStream& os, const MT_Matrix4x4& m) {
- return os << m[0] << GEN_endl
- << m[1] << GEN_endl
- << m[2] << GEN_endl
- << m[3] << GEN_endl;
-
-
-
-}
-
-#ifdef GEN_INLINED
-#include "MT_Matrix4x4.inl"
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Matrix4x4.inl b/intern/moto/include/MT_Matrix4x4.inl
deleted file mode 100644
index fb72af1f9bf..00000000000
--- a/intern/moto/include/MT_Matrix4x4.inl
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "MT_Optimize.h"
-
-/*
- * This is a supposedly faster inverter than the cofactor
- * computation. It uses an LU decomposition sort of thing. */
-GEN_INLINE void MT_Matrix4x4::invert() {
- /* normalize row 0 */
-
- int i,j,k;
-
- for (i=1; i < 4; i++) m_el[0][i] /= m_el[0][0];
- for (i=1; i < 4; i++) {
- for (j=i; j < 4; j++) { // do a column of L
- MT_Scalar sum = 0.0f;
- for (k = 0; k < i; k++)
- sum += m_el[j][k] * m_el[k][i];
- m_el[j][i] -= sum;
- }
- if (i == 3) continue;
- for (j=i+1; j < 4; j++) { // do a row of U
- MT_Scalar sum = 0.0f;
- for (k = 0; k < i; k++)
- sum += m_el[i][k]*m_el[k][j];
- m_el[i][j] =
- (m_el[i][j]-sum) / m_el[i][i];
- }
- }
- for (i = 0; i < 4; i++ ) // invert L
- for (j = i; j < 4; j++ ) {
- MT_Scalar x = 1.0f;
- if ( i != j ) {
- x = 0.0f;
- for (k = i; k < j; k++ )
- x -= m_el[j][k]*m_el[k][i];
- }
- m_el[j][i] = x / m_el[j][j];
- }
- for (i = 0; i < 4; i++ ) // invert U
- for (j = i; j < 4; j++ ) {
- if ( i == j ) continue;
- MT_Scalar sum = 0.0f;
- for (k = i; k < j; k++ )
- sum += m_el[k][j]*( (i==k) ? 1.0f : m_el[i][k] );
- m_el[i][j] = -sum;
- }
- for (i = 0; i < 4; i++ ) // final inversion
- for (j = 0; j < 4; j++ ) {
- MT_Scalar sum = 0.0f;
- for (k = ((i>j)?i:j); k < 4; k++ )
- sum += ((j==k)?1.0f:m_el[j][k])*m_el[k][i];
- m_el[j][i] = sum;
- }
-}
-
-GEN_INLINE MT_Matrix4x4 MT_Matrix4x4::inverse() const
-{
- MT_Matrix4x4 invmat = *this;
-
- invmat.invert();
-
- return invmat;
-}
-
-GEN_INLINE MT_Matrix4x4& MT_Matrix4x4::operator*=(const MT_Matrix4x4& m)
-{
- setValue(m.tdot(0, m_el[0]), m.tdot(1, m_el[0]), m.tdot(2, m_el[0]), m.tdot(3, m_el[0]),
- m.tdot(0, m_el[1]), m.tdot(1, m_el[1]), m.tdot(2, m_el[1]), m.tdot(3, m_el[1]),
- m.tdot(0, m_el[2]), m.tdot(1, m_el[2]), m.tdot(2, m_el[2]), m.tdot(3, m_el[2]),
- m.tdot(0, m_el[3]), m.tdot(1, m_el[3]), m.tdot(2, m_el[3]), m.tdot(3, m_el[3]));
- return *this;
-
-}
-
-GEN_INLINE MT_Vector4 operator*(const MT_Matrix4x4& m, const MT_Vector4& v) {
- return MT_Vector4(MT_dot(m[0], v), MT_dot(m[1], v), MT_dot(m[2], v), MT_dot(m[3], v));
-}
-
-GEN_INLINE MT_Vector4 operator*(const MT_Vector4& v, const MT_Matrix4x4& m) {
- return MT_Vector4(m.tdot(0, v), m.tdot(1, v), m.tdot(2, v), m.tdot(3, v));
-}
-
-GEN_INLINE MT_Matrix4x4 operator*(const MT_Matrix4x4& m1, const MT_Matrix4x4& m2) {
- return
- MT_Matrix4x4(m2.tdot(0, m1[0]), m2.tdot(1, m1[0]), m2.tdot(2, m1[0]), m2.tdot(3, m1[0]),
- m2.tdot(0, m1[1]), m2.tdot(1, m1[1]), m2.tdot(2, m1[1]), m2.tdot(3, m1[1]),
- m2.tdot(0, m1[2]), m2.tdot(1, m1[2]), m2.tdot(2, m1[2]), m2.tdot(3, m1[2]),
- m2.tdot(0, m1[3]), m2.tdot(1, m1[3]), m2.tdot(2, m1[3]), m2.tdot(3, m1[3]));
-}
-
-
-GEN_INLINE MT_Matrix4x4 MT_Matrix4x4::transposed() const {
- return MT_Matrix4x4(m_el[0][0], m_el[1][0], m_el[2][0], m_el[3][0],
- m_el[0][1], m_el[1][1], m_el[2][1], m_el[3][1],
- m_el[0][2], m_el[1][2], m_el[2][2], m_el[3][2],
- m_el[0][3], m_el[1][3], m_el[2][3], m_el[3][3]);
-}
-
-GEN_INLINE void MT_Matrix4x4::transpose() {
- *this = transposed();
-}
-
-GEN_INLINE MT_Matrix4x4 MT_Matrix4x4::absolute() const {
- return
- MT_Matrix4x4(MT_abs(m_el[0][0]), MT_abs(m_el[0][1]), MT_abs(m_el[0][2]), MT_abs(m_el[0][3]),
- MT_abs(m_el[1][0]), MT_abs(m_el[1][1]), MT_abs(m_el[1][2]), MT_abs(m_el[1][3]),
- MT_abs(m_el[2][0]), MT_abs(m_el[2][1]), MT_abs(m_el[2][2]), MT_abs(m_el[2][3]),
- MT_abs(m_el[3][0]), MT_abs(m_el[3][1]), MT_abs(m_el[3][2]), MT_abs(m_el[3][3]));
-}
diff --git a/intern/moto/include/MT_MinMax.h b/intern/moto/include/MT_MinMax.h
deleted file mode 100644
index 42e689f45a4..00000000000
--- a/intern/moto/include/MT_MinMax.h
+++ /dev/null
@@ -1,71 +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 moto/include/MT_MinMax.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_MINMAX_H
-#define MT_MINMAX_H
-
-template <class T>
-inline const T& MT_min(const T& a, const T& b) {
- return b < a ? b : a;
-}
-
-template <class T>
-inline const T& MT_max(const T& a, const T& b) {
- return a < b ? b : a;
-}
-
-template <class T>
-inline void MT_set_min(T& a, const T& b) {
- if (a > b) a = b;
-}
-
-template <class T>
-inline void MT_set_max(T& a, const T& b) {
- if (a < b) a = b;
-}
-
-#endif
-
diff --git a/intern/moto/include/MT_Optimize.h b/intern/moto/include/MT_Optimize.h
deleted file mode 100644
index e16bab1ecf9..00000000000
--- a/intern/moto/include/MT_Optimize.h
+++ /dev/null
@@ -1,43 +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 moto/include/MT_Optimize.h
- * \ingroup moto
- */
-
-
-#ifndef GEN_OPTIMIZE_H
-#define GEN_OPTIMIZE_H
-
-#ifdef GEN_INLINED
-#define GEN_INLINE inline
-#else
-#define GEN_INLINE
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Point2.h b/intern/moto/include/MT_Point2.h
deleted file mode 100644
index 587379b21f4..00000000000
--- a/intern/moto/include/MT_Point2.h
+++ /dev/null
@@ -1,83 +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 moto/include/MT_Point2.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_POINT2_H
-#define MT_POINT2_H
-
-#include "MT_Vector2.h"
-
-class MT_Point2 : public MT_Vector2 {
-public:
- MT_Point2() {}
- MT_Point2(const float *v2) : MT_Vector2(v2) {}
- MT_Point2(const double *v2) : MT_Vector2(v2) {}
- MT_Point2(MT_Scalar x2, MT_Scalar y2) : MT_Vector2(x2, y2) {}
-
- MT_Point2& operator+=(const MT_Vector2& v);
- MT_Point2& operator-=(const MT_Vector2& v);
- MT_Point2& operator=(const MT_Vector2& v);
-
- MT_Scalar distance(const MT_Point2& p) const;
- MT_Scalar distance2(const MT_Point2& p) const;
-
- MT_Point2 lerp(const MT_Point2& p, MT_Scalar t) const;
-};
-
-MT_Point2 operator+(const MT_Point2& p, const MT_Vector2& v);
-MT_Point2 operator-(const MT_Point2& p, const MT_Vector2& v);
-MT_Vector2 operator-(const MT_Point2& p1, const MT_Point2& p2);
-
-MT_Scalar MT_distance(const MT_Point2& p1, const MT_Point2& p2);
-MT_Scalar MT_distance2(const MT_Point2& p1, const MT_Point2& p2);
-
-MT_Point2 MT_lerp(const MT_Point2& p1, const MT_Point2& p2, MT_Scalar t);
-
-#ifdef GEN_INLINED
-#include "MT_Point2.inl"
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Point2.inl b/intern/moto/include/MT_Point2.inl
deleted file mode 100644
index ec09a3260e2..00000000000
--- a/intern/moto/include/MT_Point2.inl
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "MT_Optimize.h"
-
-GEN_INLINE MT_Point2& MT_Point2::operator+=(const MT_Vector2& v) {
- m_co[0] += v[0]; m_co[1] += v[1];
- return *this;
-}
-
-GEN_INLINE MT_Point2& MT_Point2::operator-=(const MT_Vector2& v) {
- m_co[0] -= v[0]; m_co[1] -= v[1];
- return *this;
-}
-
-GEN_INLINE MT_Point2& MT_Point2::operator=(const MT_Vector2& v) {
- m_co[0] = v[0]; m_co[1] = v[1];
- return *this;
-}
-
-GEN_INLINE MT_Scalar MT_Point2::distance(const MT_Point2& p) const {
- return (p - *this).length();
-}
-
-GEN_INLINE MT_Scalar MT_Point2::distance2(const MT_Point2& p) const {
- return (p - *this).length2();
-}
-
-GEN_INLINE MT_Point2 MT_Point2::lerp(const MT_Point2& p, MT_Scalar t) const {
- return MT_Point2(m_co[0] + (p[0] - m_co[0]) * t,
- m_co[1] + (p[1] - m_co[1]) * t);
-}
-
-GEN_INLINE MT_Point2 operator+(const MT_Point2& p, const MT_Vector2& v) {
- return MT_Point2(p[0] + v[0], p[1] + v[1]);
-}
-
-GEN_INLINE MT_Point2 operator-(const MT_Point2& p, const MT_Vector2& v) {
- return MT_Point2(p[0] - v[0], p[1] - v[1]);
-}
-
-GEN_INLINE MT_Vector2 operator-(const MT_Point2& p1, const MT_Point2& p2) {
- return MT_Vector2(p1[0] - p2[0], p1[1] - p2[1]);
-}
-
-GEN_INLINE MT_Scalar MT_distance(const MT_Point2& p1, const MT_Point2& p2) {
- return p1.distance(p2);
-}
-
-GEN_INLINE MT_Scalar MT_distance2(const MT_Point2& p1, const MT_Point2& p2) {
- return p1.distance2(p2);
-}
-
-GEN_INLINE MT_Point2 MT_lerp(const MT_Point2& p1, const MT_Point2& p2, MT_Scalar t) {
- return p1.lerp(p2, t);
-}
-
diff --git a/intern/moto/include/MT_Point3.h b/intern/moto/include/MT_Point3.h
deleted file mode 100644
index f19b2e2f324..00000000000
--- a/intern/moto/include/MT_Point3.h
+++ /dev/null
@@ -1,84 +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 moto/include/MT_Point3.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_POINT_H
-#define MT_POINT_H
-
-#include "MT_Vector3.h"
-
-class MT_Point3 : public MT_Vector3 {
-public:
- MT_Point3() {}
- MT_Point3(const float *v) : MT_Vector3(v) {}
- MT_Point3(const double *v) : MT_Vector3(v) {}
- MT_Point3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) : MT_Vector3(xx, yy, zz) {}
-
- MT_Point3& operator+=(const MT_Vector3& v);
- MT_Point3& operator-=(const MT_Vector3& v);
- MT_Point3& operator=(const MT_Vector3& v);
- MT_Point3& operator=(const MT_Point3& v);
-
- MT_Scalar distance(const MT_Point3& p) const;
- MT_Scalar distance2(const MT_Point3& p) const;
-
- MT_Point3 lerp(const MT_Point3& p, MT_Scalar t) const;
-};
-
-MT_Point3 operator+(const MT_Point3& p, const MT_Vector3& v);
-MT_Point3 operator-(const MT_Point3& p, const MT_Vector3& v);
-MT_Vector3 operator-(const MT_Point3& p1, const MT_Point3& p2);
-
-MT_Scalar MT_distance(const MT_Point3& p1, const MT_Point3& p2);
-MT_Scalar MT_distance2(const MT_Point3& p1, const MT_Point3& p2);
-
-MT_Point3 MT_lerp(const MT_Point3& p1, const MT_Point3& p2, MT_Scalar t);
-
-#ifdef GEN_INLINED
-#include "MT_Point3.inl"
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Point3.inl b/intern/moto/include/MT_Point3.inl
deleted file mode 100644
index 081a8195694..00000000000
--- a/intern/moto/include/MT_Point3.inl
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "MT_Optimize.h"
-
-GEN_INLINE MT_Point3& MT_Point3::operator+=(const MT_Vector3& v) {
- m_co[0] += v[0]; m_co[1] += v[1]; m_co[2] += v[2];
- return *this;
-}
-
-GEN_INLINE MT_Point3& MT_Point3::operator-=(const MT_Vector3& v) {
- m_co[0] -= v[0]; m_co[1] -= v[1]; m_co[2] -= v[2];
- return *this;
-}
-
-GEN_INLINE MT_Point3& MT_Point3::operator=(const MT_Vector3& v) {
- m_co[0] = v[0]; m_co[1] = v[1]; m_co[2] = v[2];
- return *this;
-}
-
-GEN_INLINE MT_Point3& MT_Point3::operator=(const MT_Point3& v) {
- m_co[0] = v[0]; m_co[1] = v[1]; m_co[2] = v[2];
- return *this;
-}
-
-GEN_INLINE MT_Scalar MT_Point3::distance(const MT_Point3& p) const {
- return (p - *this).length();
-}
-
-GEN_INLINE MT_Scalar MT_Point3::distance2(const MT_Point3& p) const {
- return (p - *this).length2();
-}
-
-GEN_INLINE MT_Point3 MT_Point3::lerp(const MT_Point3& p, MT_Scalar t) const {
- return MT_Point3(m_co[0] + (p[0] - m_co[0]) * t,
- m_co[1] + (p[1] - m_co[1]) * t,
- m_co[2] + (p[2] - m_co[2]) * t);
-}
-
-GEN_INLINE MT_Point3 operator+(const MT_Point3& p, const MT_Vector3& v) {
- return MT_Point3(p[0] + v[0], p[1] + v[1], p[2] + v[2]);
-}
-
-GEN_INLINE MT_Point3 operator-(const MT_Point3& p, const MT_Vector3& v) {
- return MT_Point3(p[0] - v[0], p[1] - v[1], p[2] - v[2]);
-}
-
-GEN_INLINE MT_Vector3 operator-(const MT_Point3& p1, const MT_Point3& p2) {
- return MT_Vector3(p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]);
-}
-
-GEN_INLINE MT_Scalar MT_distance(const MT_Point3& p1, const MT_Point3& p2) {
- return p1.distance(p2);
-}
-
-GEN_INLINE MT_Scalar MT_distance2(const MT_Point3& p1, const MT_Point3& p2) {
- return p1.distance2(p2);
-}
-
-GEN_INLINE MT_Point3 MT_lerp(const MT_Point3& p1, const MT_Point3& p2, MT_Scalar t) {
- return p1.lerp(p2, t);
-}
diff --git a/intern/moto/include/MT_Quaternion.h b/intern/moto/include/MT_Quaternion.h
deleted file mode 100644
index 6aabb1f2ed4..00000000000
--- a/intern/moto/include/MT_Quaternion.h
+++ /dev/null
@@ -1,114 +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 moto/include/MT_Quaternion.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_QUATERNION_H
-#define MT_QUATERNION_H
-
-#include <MT_assert.h>
-
-#include "MT_Vector3.h"
-#include "MT_Vector4.h"
-
-class MT_Quaternion : public MT_Vector4 {
-public:
- MT_Quaternion() {}
- MT_Quaternion(const MT_Vector4& v) : MT_Vector4(v) {}
- MT_Quaternion(const float v[4]) : MT_Vector4(v) {}
- MT_Quaternion(const double v[4]) : MT_Vector4(v) {}
- MT_Quaternion(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) :
- MT_Vector4(xx, yy, zz, ww) {}
- MT_Quaternion(const MT_Vector3& axis, MT_Scalar mt_angle) {
- setRotation(axis, mt_angle);
- }
- MT_Quaternion(MT_Scalar yaw, MT_Scalar pitch, MT_Scalar roll) {
- setEuler(yaw, pitch, roll);
- }
-
- void setRotation(const MT_Vector3& axis, MT_Scalar mt_angle) {
- MT_Scalar d = axis.length();
- MT_assert(!MT_fuzzyZero(d));
- MT_Scalar s = sinf(mt_angle * MT_Scalar(0.5f)) / d;
- setValue(axis[0] * s, axis[1] * s, axis[2] * s,
- cosf(mt_angle * MT_Scalar(0.5f)));
- }
-
- void setEuler(MT_Scalar yaw, MT_Scalar pitch, MT_Scalar roll) {
- MT_Scalar cosYaw = cosf(yaw * MT_Scalar(0.5f));
- MT_Scalar sinYaw = sinf(yaw * MT_Scalar(0.5f));
- MT_Scalar cosPitch = cosf(pitch * MT_Scalar(0.5f));
- MT_Scalar sinPitch = sinf(pitch * MT_Scalar(0.5f));
- MT_Scalar cosRoll = cosf(roll * MT_Scalar(0.5f));
- MT_Scalar sinRoll = sinf(roll * MT_Scalar(0.5f));
- setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw,
- cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw,
- sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw,
- cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw);
- }
-
- MT_Quaternion& operator*=(const MT_Quaternion& q);
-
- void conjugate();
- MT_Quaternion conjugate() const;
-
- void invert();
- MT_Quaternion inverse() const;
-
- MT_Scalar angle(const MT_Quaternion& q) const;
- MT_Quaternion slerp(const MT_Quaternion& q, const MT_Scalar& t) const;
-
- static MT_Quaternion random();
-};
-
-MT_Quaternion operator*(const MT_Quaternion& q1, const MT_Quaternion& q2);
-MT_Quaternion operator*(const MT_Quaternion& q, const MT_Vector3& w);
-MT_Quaternion operator*(const MT_Vector3& w, const MT_Quaternion& q);
-
-#ifdef GEN_INLINED
-#include "MT_Quaternion.inl"
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Quaternion.inl b/intern/moto/include/MT_Quaternion.inl
deleted file mode 100644
index 8fe71b7b214..00000000000
--- a/intern/moto/include/MT_Quaternion.inl
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "MT_Optimize.h"
-
-GEN_INLINE MT_Quaternion& MT_Quaternion::operator*=(const MT_Quaternion& q) {
- setValue(m_co[3] * q[0] + m_co[0] * q[3] + m_co[1] * q[2] - m_co[2] * q[1],
- m_co[3] * q[1] + m_co[1] * q[3] + m_co[2] * q[0] - m_co[0] * q[2],
- m_co[3] * q[2] + m_co[2] * q[3] + m_co[0] * q[1] - m_co[1] * q[0],
- m_co[3] * q[3] - m_co[0] * q[0] - m_co[1] * q[1] - m_co[2] * q[2]);
- return *this;
-}
-
-GEN_INLINE void MT_Quaternion::conjugate() {
- m_co[0] = -m_co[0]; m_co[1] = -m_co[1]; m_co[2] = -m_co[2];
-}
-
-GEN_INLINE MT_Quaternion MT_Quaternion::conjugate() const {
- return MT_Quaternion(-m_co[0], -m_co[1], -m_co[2], m_co[3]);
-}
-
-GEN_INLINE void MT_Quaternion::invert() {
- conjugate();
- *this /= length2();
-}
-
-GEN_INLINE MT_Quaternion MT_Quaternion::inverse() const {
- return conjugate() / length2();
-}
-
-// From: "Uniform Random Rotations", Ken Shoemake, Graphics Gems III,
-// pg. 124-132
-GEN_INLINE MT_Quaternion MT_Quaternion::random() {
- MT_Scalar x0 = MT_random();
- MT_Scalar r1 = sqrtf(MT_Scalar(1.0f) - x0), r2 = sqrtf(x0);
- MT_Scalar t1 = (float)MT_2_PI * MT_random(), t2 = (float)MT_2_PI * MT_random();
- MT_Scalar c1 = cosf(t1), s1 = sinf(t1);
- MT_Scalar c2 = cosf(t2), s2 = sinf(t2);
- return MT_Quaternion(s1 * r1, c1 * r1, s2 * r2, c2 * r2);
-}
-
-GEN_INLINE MT_Quaternion operator*(const MT_Quaternion& q1,
- const MT_Quaternion& q2) {
- return MT_Quaternion(q1[3] * q2[0] + q1[0] * q2[3] + q1[1] * q2[2] - q1[2] * q2[1],
- q1[3] * q2[1] + q1[1] * q2[3] + q1[2] * q2[0] - q1[0] * q2[2],
- q1[3] * q2[2] + q1[2] * q2[3] + q1[0] * q2[1] - q1[1] * q2[0],
- q1[3] * q2[3] - q1[0] * q2[0] - q1[1] * q2[1] - q1[2] * q2[2]);
-}
-
-GEN_INLINE MT_Quaternion operator*(const MT_Quaternion& q, const MT_Vector3& w)
-{
- return MT_Quaternion( q[3] * w[0] + q[1] * w[2] - q[2] * w[1],
- q[3] * w[1] + q[2] * w[0] - q[0] * w[2],
- q[3] * w[2] + q[0] * w[1] - q[1] * w[0],
- -q[0] * w[0] - q[1] * w[1] - q[2] * w[2]);
-}
-
-GEN_INLINE MT_Quaternion operator*(const MT_Vector3& w, const MT_Quaternion& q)
-{
- return MT_Quaternion( w[0] * q[3] + w[1] * q[2] - w[2] * q[1],
- w[1] * q[3] + w[2] * q[0] - w[0] * q[2],
- w[2] * q[3] + w[0] * q[1] - w[1] * q[0],
- -w[0] * q[0] - w[1] * q[1] - w[2] * q[2]);
-}
-
-GEN_INLINE MT_Scalar MT_Quaternion::angle(const MT_Quaternion& q) const
-{
- MT_Scalar s = sqrtf(length2() * q.length2());
- assert(s != MT_Scalar(0.0f));
-
- s = dot(q) / s;
-
- s = MT_clamp(s, -1.0f, 1.0f);
-
- return acosf(s);
-}
-
-GEN_INLINE MT_Quaternion MT_Quaternion::slerp(const MT_Quaternion& q, const MT_Scalar& t) const
-{
- MT_Scalar d, s0, s1;
- MT_Scalar s = dot(q);
- bool neg = (s < 0.0f);
-
- if (neg)
- s = -s;
- if ((1.0f - s) > 0.0001f)
- {
- MT_Scalar theta = acosf(s);
- d = MT_Scalar(1.0f) / sinf(theta);
- s0 = sinf((MT_Scalar(1.0f) - t) * theta);
- s1 = sinf(t * theta);
- }
- else
- {
- d = MT_Scalar(1.0f);
- s0 = MT_Scalar(1.0f) - t;
- s1 = t;
- }
- if (neg)
- s1 = -s1;
- return d*(*this * s0 + q * s1);
-}
-
diff --git a/intern/moto/include/MT_Scalar.h b/intern/moto/include/MT_Scalar.h
deleted file mode 100644
index 94723f4d7ec..00000000000
--- a/intern/moto/include/MT_Scalar.h
+++ /dev/null
@@ -1,96 +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 moto/include/MT_Scalar.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_SCALAR_H
-#define MT_SCALAR_H
-
-#include <math.h>
-#include <float.h>
-
-#include "MT_random.h"
-
-typedef float MT_Scalar;
-
-
-const MT_Scalar MT_DEGS_PER_RAD(57.29577951308232286465);
-const MT_Scalar MT_RADS_PER_DEG(0.01745329251994329547);
-const MT_Scalar MT_PI(3.14159265358979323846);
-const MT_Scalar MT_2_PI(6.28318530717958623200);
-const MT_Scalar MT_EPSILON(1.0e-10);
-const MT_Scalar MT_EPSILON2(1.0e-20);
-const MT_Scalar MT_INFINITY(1.0e38);
-
-inline int MT_sign(MT_Scalar x) {
- return x < 0.0f ? -1 : x > 0.0f ? 1 : 0;
-}
-
-inline MT_Scalar MT_abs(MT_Scalar x) { return fabs(x); }
-
-inline bool MT_fuzzyZero(MT_Scalar x) { return MT_abs(x) < (float)MT_EPSILON; }
-inline bool MT_fuzzyZero2(MT_Scalar x) { return MT_abs(x) < (float)MT_EPSILON2; }
-
-inline MT_Scalar MT_radians(MT_Scalar x) {
- return x * (float)MT_RADS_PER_DEG;
-}
-
-inline MT_Scalar MT_degrees(MT_Scalar x) {
- return x * (float)MT_DEGS_PER_RAD;
-}
-
-inline MT_Scalar MT_random() {
- return MT_Scalar(MT_rand()) / MT_Scalar(MT_RAND_MAX);
-}
-
-inline MT_Scalar MT_clamp(const MT_Scalar x, const MT_Scalar min, const MT_Scalar max)
-{
- if (x < min)
- return min;
- else if (x > max)
- return max;
- return x;
-}
-#endif
-
diff --git a/intern/moto/include/MT_Stream.h b/intern/moto/include/MT_Stream.h
deleted file mode 100644
index 42861e6c099..00000000000
--- a/intern/moto/include/MT_Stream.h
+++ /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 moto/include/MT_Stream.h
- * \ingroup moto
- */
-
-
-#ifndef GEN_STREAM_H
-#define GEN_STREAM_H
-
-#ifdef __CUSTOM_STREAM
-
-class MT_OStream
-{
-public:
- inline MT_OStream& operator<<(double);
- inline MT_OStream& operator<<(int);
- inline MT_OStream& operator<<(char*);
-};
-
-const char GEN_endl = '\n';
-
-#else
-
-#include <iostream>
-
-typedef std::ostream MT_OStream;
-
-inline MT_OStream& GEN_endl(MT_OStream& os) { return std::endl(os); }
-
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Transform.h b/intern/moto/include/MT_Transform.h
deleted file mode 100644
index 9c23482925c..00000000000
--- a/intern/moto/include/MT_Transform.h
+++ /dev/null
@@ -1,190 +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 moto/include/MT_Transform.h
- * \ingroup moto
- */
-
-
-/*
-
- MoTo - 3D Motion Toolkit
- Copyright (C) 2000 Gino van den Bergen <gino@acm.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- 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 GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef MT_TRANSFORM_H
-#define MT_TRANSFORM_H
-
-#include "MT_Point3.h"
-#include "MT_Matrix3x3.h"
-
-class MT_Transform {
-public:
- MT_Transform() {}
- MT_Transform(const float *m) { setValue(m); }
- MT_Transform(const double *m) { setValue(m); }
- MT_Transform(const MT_Point3& p, const MT_Quaternion& q)
- : m_type(IDENTITY)
- {
- setOrigin(p);
- setRotation(q);
- }
-
- MT_Transform(const MT_Point3& p, const MT_Matrix3x3& m)
- : m_type(IDENTITY)
- {
- setOrigin(p);
- setBasis(m);
- }
-
- static MT_Transform Identity()
- {
- MT_Transform t;
- t.setIdentity();
- return t;
- }
-
-
- MT_Point3 operator()(const MT_Point3& p) const {
- return MT_Point3(MT_dot(m_basis[0], p) + m_origin[0],
- MT_dot(m_basis[1], p) + m_origin[1],
- MT_dot(m_basis[2], p) + m_origin[2]);
- }
-
- MT_Vector3 operator()(const MT_Vector3& p) const {
- return MT_Vector3(MT_dot(m_basis[0], p) + m_origin[0],
- MT_dot(m_basis[1], p) + m_origin[1],
- MT_dot(m_basis[2], p) + m_origin[2]);
- }
-
- MT_Point3 operator*(const MT_Point3& p) const {
- return (*this)(p);
- }
-
- MT_Vector3 operator*(const MT_Vector3& p) const {
- return (*this)(p);
- }
-
-
- MT_Matrix3x3& getBasis() { return m_basis; }
- const MT_Matrix3x3& getBasis() const { return m_basis; }
- MT_Point3& getOrigin() { return m_origin; }
- const MT_Point3& getOrigin() const { return m_origin; }
- MT_Quaternion getRotation() const { return m_basis.getRotation(); }
-
- void setValue(const float *m);
- void setValue(const double *m);
-
- void setOrigin(const MT_Point3& origin) {
- m_origin = origin;
- m_type |= TRANSLATION;
- }
-
- void setBasis(const MT_Matrix3x3& basis) {
- m_basis = basis;
- m_type |= LINEAR;
- }
-
- void setRotation(const MT_Quaternion& q) {
- m_basis.setRotation(q);
- m_type &= ~SCALING;
- m_type |= ROTATION;
- }
-
- void getValue(float *m) const;
- void getValue(double *m) const;
-
- void setIdentity();
-
- MT_Transform& operator*=(const MT_Transform& t);
-
- /**
- * Translate the origin of the transform according to the vector.
- * @param v The vector to translate over. The vector is specified
- * in the coordinate system of the transform itself.
- */
- void translate(const MT_Vector3& v);
- void rotate(const MT_Quaternion& q);
- void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z);
-
- void invert(const MT_Transform& t);
- void mult(const MT_Transform& t1, const MT_Transform& t2);
- void multInverseLeft(const MT_Transform& t1, const MT_Transform& t2);
-
-private:
- enum {
- IDENTITY = 0x00,
- TRANSLATION = 0x01,
- ROTATION = 0x02,
- RIGID = TRANSLATION | ROTATION,
- SCALING = 0x04,
- LINEAR = ROTATION | SCALING,
- AFFINE = TRANSLATION | LINEAR
- };
-
- MT_Transform(const MT_Matrix3x3& basis, const MT_Point3& origin,
- unsigned int type) {
- setValue(basis, origin, type);
- }
-
- void setValue(const MT_Matrix3x3& basis, const MT_Point3& origin,
- unsigned int type) {
- m_basis = basis;
- m_origin = origin;
- m_type = type;
- }
-
- friend MT_Transform operator*(const MT_Transform& t1, const MT_Transform& t2);
-
- MT_Matrix3x3 m_basis;
- MT_Point3 m_origin;
- unsigned int m_type;
-};
-
-inline MT_Transform operator*(const MT_Transform& t1, const MT_Transform& t2) {
- return MT_Transform(t1.m_basis * t2.m_basis,
- t1(t2.m_origin),
- t1.m_type | t2.m_type);
-}
-
-#endif
-
diff --git a/intern/moto/include/MT_Tuple2.h b/intern/moto/include/MT_Tuple2.h
deleted file mode 100644
index 465b31a6781..00000000000
--- a/intern/moto/include/MT_Tuple2.h
+++ /dev/null
@@ -1,111 +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 moto/include/MT_Tuple2.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_Tuple2_H
-#define MT_Tuple2_H
-
-#include "MT_Stream.h"
-#include "MT_Scalar.h"
-
-class MT_Tuple2 {
-public:
- MT_Tuple2() {}
- MT_Tuple2(const float *vv) { setValue(vv); }
- MT_Tuple2(const double *vv) { setValue(vv); }
- MT_Tuple2(MT_Scalar xx, MT_Scalar yy) { setValue(xx, yy); }
-
- MT_Scalar& operator[](int i) { return m_co[i]; }
- const MT_Scalar& operator[](int i) const { return m_co[i]; }
-
- MT_Scalar& x() { return m_co[0]; }
- const MT_Scalar& x() const { return m_co[0]; }
-
- MT_Scalar& y() { return m_co[1]; }
- const MT_Scalar& y() const { return m_co[1]; }
-
- MT_Scalar& u() { return m_co[0]; }
- const MT_Scalar& u() const { return m_co[0]; }
-
- MT_Scalar& v() { return m_co[1]; }
- const MT_Scalar& v() const { return m_co[1]; }
-
- MT_Scalar *getValue() { return m_co; }
- const MT_Scalar *getValue() const { return m_co; }
-
- void getValue(float *vv) const {
- vv[0] = (float) m_co[0]; vv[1] = (float) m_co[1];
- }
-
- void getValue(double *vv) const {
- vv[0] = m_co[0]; vv[1] = m_co[1];
- }
-
- void setValue(const float *vv) {
- m_co[0] = vv[0]; m_co[1] = vv[1];
- }
-
- void setValue(const double *vv) {
- m_co[0] = vv[0]; m_co[1] = vv[1];
- }
-
- void setValue(MT_Scalar xx, MT_Scalar yy) {
- m_co[0] = xx; m_co[1] = yy;
- }
-
-protected:
- MT_Scalar m_co[2];
-};
-
-inline bool operator==(const MT_Tuple2& t1, const MT_Tuple2& t2) {
- return t1[0] == t2[0] && t1[1] == t2[1];
-}
-
-inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple2& t) {
- return os << t[0] << ' ' << t[1];
-}
-
-#endif
-
diff --git a/intern/moto/include/MT_Tuple3.h b/intern/moto/include/MT_Tuple3.h
deleted file mode 100644
index ddd8ed724ca..00000000000
--- a/intern/moto/include/MT_Tuple3.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 moto/include/MT_Tuple3.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_TUPLE3_H
-#define MT_TUPLE3_H
-
-#include "MT_Stream.h"
-#include "MT_Scalar.h"
-
-class MT_Tuple3 {
-public:
- MT_Tuple3() {}
- MT_Tuple3(const float *v) { setValue(v); }
- MT_Tuple3(const double *v) { setValue(v); }
- MT_Tuple3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) { setValue(xx, yy, zz); }
-
- MT_Scalar& operator[](int i) { return m_co[i]; }
- const MT_Scalar& operator[](int i) const { return m_co[i]; }
-
- MT_Scalar& x() { return m_co[0]; }
- const MT_Scalar& x() const { return m_co[0]; }
-
- MT_Scalar& y() { return m_co[1]; }
- const MT_Scalar& y() const { return m_co[1]; }
-
- MT_Scalar& z() { return m_co[2]; }
- const MT_Scalar& z() const { return m_co[2]; }
-
- MT_Scalar *getValue() { return m_co; }
- const MT_Scalar *getValue() const { return m_co; }
-
- void getValue(float *v) const {
- v[0] = float(m_co[0]);
- v[1] = float(m_co[1]);
- v[2] = float(m_co[2]);
- }
-
- void getValue(double *v) const {
- v[0] = double(m_co[0]);
- v[1] = double(m_co[1]);
- v[2] = double(m_co[2]);
- }
-
- void setValue(const float *v) {
- m_co[0] = MT_Scalar(v[0]);
- m_co[1] = MT_Scalar(v[1]);
- m_co[2] = MT_Scalar(v[2]);
- }
-
- void setValue(const double *v) {
- m_co[0] = MT_Scalar(v[0]);
- m_co[1] = MT_Scalar(v[1]);
- m_co[2] = MT_Scalar(v[2]);
- }
-
- void setValue(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) {
- m_co[0] = xx; m_co[1] = yy; m_co[2] = zz;
- }
-
-protected:
- MT_Scalar m_co[3];
-};
-
-inline bool operator==(const MT_Tuple3& t1, const MT_Tuple3& t2) {
- return t1[0] == t2[0] && t1[1] == t2[1] && t1[2] == t2[2];
-}
-
-inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple3& t) {
- return os << t[0] << ' ' << t[1] << ' ' << t[2];
-}
-
-#endif
-
diff --git a/intern/moto/include/MT_Tuple4.h b/intern/moto/include/MT_Tuple4.h
deleted file mode 100644
index aa3b60f1c9b..00000000000
--- a/intern/moto/include/MT_Tuple4.h
+++ /dev/null
@@ -1,126 +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 moto/include/MT_Tuple4.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_TUPLE4_H
-#define MT_TUPLE4_H
-
-#include "MT_Stream.h"
-#include "MT_Scalar.h"
-
-class MT_Tuple4 {
-public:
- MT_Tuple4() {}
- MT_Tuple4(const float *v) { setValue(v); }
- MT_Tuple4(const double *v) { setValue(v); }
- MT_Tuple4(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) {
- setValue(xx, yy, zz, ww);
- }
-
- MT_Scalar& operator[](int i) { return m_co[i]; }
- const MT_Scalar& operator[](int i) const { return m_co[i]; }
-
- MT_Scalar& x() { return m_co[0]; }
- const MT_Scalar& x() const { return m_co[0]; }
-
- MT_Scalar& y() { return m_co[1]; }
- const MT_Scalar& y() const { return m_co[1]; }
-
- MT_Scalar& z() { return m_co[2]; }
- const MT_Scalar& z() const { return m_co[2]; }
-
- MT_Scalar& w() { return m_co[3]; }
- const MT_Scalar& w() const { return m_co[3]; }
-
- MT_Scalar *getValue() { return m_co; }
- const MT_Scalar *getValue() const { return m_co; }
-
-
- void getValue(float *v) const {
- v[0] = float(m_co[0]);
- v[1] = float(m_co[1]);
- v[2] = float(m_co[2]);
- v[3] = float(m_co[3]);
- }
-
- void getValue(double *v) const {
- v[0] = double(m_co[0]);
- v[1] = double(m_co[1]);
- v[2] = double(m_co[2]);
- v[3] = double(m_co[3]);
- }
-
- void setValue(const float *v) {
- m_co[0] = MT_Scalar(v[0]);
- m_co[1] = MT_Scalar(v[1]);
- m_co[2] = MT_Scalar(v[2]);
- m_co[3] = MT_Scalar(v[3]);
- }
-
- void setValue(const double *v) {
- m_co[0] = MT_Scalar(v[0]);
- m_co[1] = MT_Scalar(v[1]);
- m_co[2] = MT_Scalar(v[2]);
- m_co[3] = MT_Scalar(v[3]);
- }
-
- void setValue(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) {
- m_co[0] = xx; m_co[1] = yy; m_co[2] = zz; m_co[3] = ww;
- }
-
-protected:
- MT_Scalar m_co[4];
-};
-
-inline bool operator==(const MT_Tuple4& t1, const MT_Tuple4& t2) {
- return t1[0] == t2[0] && t1[1] == t2[1] && t1[2] == t2[2] && t1[3] == t2[3];
-}
-
-inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple4& t) {
- return os << t[0] << ' ' << t[1] << ' ' << t[2] << ' ' << t[3];
-}
-
-#endif
-
diff --git a/intern/moto/include/MT_Vector2.h b/intern/moto/include/MT_Vector2.h
deleted file mode 100644
index 8b8f2478ce3..00000000000
--- a/intern/moto/include/MT_Vector2.h
+++ /dev/null
@@ -1,114 +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 moto/include/MT_Vector2.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_VECTOR2_H
-#define MT_VECTOR2_H
-
-#include <MT_assert.h>
-#include "MT_Tuple2.h"
-
-class MT_Vector2 : public MT_Tuple2 {
-public:
- MT_Vector2() {}
- MT_Vector2(const float *v2) : MT_Tuple2(v2) {}
- MT_Vector2(const double *v2) : MT_Tuple2(v2) {}
- MT_Vector2(MT_Scalar xx, MT_Scalar yy) : MT_Tuple2(xx, yy) {}
-
- MT_Vector2& operator+=(const MT_Vector2& v);
- MT_Vector2& operator-=(const MT_Vector2& v);
- MT_Vector2& operator*=(MT_Scalar s);
- MT_Vector2& operator/=(MT_Scalar s);
-
- MT_Scalar dot(const MT_Vector2& v) const;
-
- MT_Scalar length2() const;
- MT_Scalar length() const;
-
- MT_Vector2 absolute() const;
-
- void normalize();
- MT_Vector2 normalized() const;
-
- void scale(MT_Scalar x, MT_Scalar y);
- MT_Vector2 scaled(MT_Scalar x, MT_Scalar y) const;
-
- bool fuzzyZero() const;
-
- MT_Scalar angle(const MT_Vector2& v) const;
- MT_Vector2 cross(const MT_Vector2& v) const;
- MT_Scalar triple(const MT_Vector2& v1, const MT_Vector2& v2) const;
-
- int closestAxis() const;
-
- static MT_Vector2 random();
-};
-
-MT_Vector2 operator+(const MT_Vector2& v1, const MT_Vector2& v2);
-MT_Vector2 operator-(const MT_Vector2& v1, const MT_Vector2& v2);
-MT_Vector2 operator-(const MT_Vector2& v);
-MT_Vector2 operator*(const MT_Vector2& v, MT_Scalar s);
-MT_Vector2 operator*(MT_Scalar s, const MT_Vector2& v);
-MT_Vector2 operator/(const MT_Vector2& v, MT_Scalar s);
-
-MT_Scalar MT_dot(const MT_Vector2& v1, const MT_Vector2& v2);
-
-MT_Scalar MT_length2(const MT_Vector2& v);
-MT_Scalar MT_length(const MT_Vector2& v);
-
-bool MT_fuzzyZero(const MT_Vector2& v);
-bool MT_fuzzyEqual(const MT_Vector2& v1, const MT_Vector2& v2);
-
-MT_Scalar MT_angle(const MT_Vector2& v1, const MT_Vector2& v2);
-MT_Vector2 MT_cross(const MT_Vector2& v1, const MT_Vector2& v2);
-MT_Scalar MT_triple(const MT_Vector2& v1, const MT_Vector2& v2,
- const MT_Vector2& v3);
-
-#ifdef GEN_INLINED
-#include "MT_Vector2.inl"
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Vector2.inl b/intern/moto/include/MT_Vector2.inl
deleted file mode 100644
index ed16025e733..00000000000
--- a/intern/moto/include/MT_Vector2.inl
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "MT_Optimize.h"
-
-GEN_INLINE MT_Vector2& MT_Vector2::operator+=(const MT_Vector2& vv) {
- m_co[0] += vv[0]; m_co[1] += vv[1];
- return *this;
-}
-
-GEN_INLINE MT_Vector2& MT_Vector2::operator-=(const MT_Vector2& vv) {
- m_co[0] -= vv[0]; m_co[1] -= vv[1];
- return *this;
-}
-
-GEN_INLINE MT_Vector2& MT_Vector2::operator*=(MT_Scalar s) {
- m_co[0] *= s; m_co[1] *= s;
- return *this;
-}
-
-GEN_INLINE MT_Vector2& MT_Vector2::operator/=(MT_Scalar s) {
- MT_assert(!MT_fuzzyZero(s));
- return *this *= 1.0f / s;
-}
-
-GEN_INLINE MT_Vector2 operator+(const MT_Vector2& v1, const MT_Vector2& v2) {
- return MT_Vector2(v1[0] + v2[0], v1[1] + v2[1]);
-}
-
-GEN_INLINE MT_Vector2 operator-(const MT_Vector2& v1, const MT_Vector2& v2) {
- return MT_Vector2(v1[0] - v2[0], v1[1] - v2[1]);
-}
-
-GEN_INLINE MT_Vector2 operator-(const MT_Vector2& v) {
- return MT_Vector2(-v[0], -v[1]);
-}
-
-GEN_INLINE MT_Vector2 operator*(const MT_Vector2& v, MT_Scalar s) {
- return MT_Vector2(v[0] * s, v[1] * s);
-}
-
-GEN_INLINE MT_Vector2 operator*(MT_Scalar s, const MT_Vector2& v) { return v * s; }
-
-GEN_INLINE MT_Vector2 operator/(const MT_Vector2& v, MT_Scalar s) {
- MT_assert(!MT_fuzzyZero(s));
- return v * (1.0f / s);
-}
-
-GEN_INLINE MT_Scalar MT_Vector2::dot(const MT_Vector2& vv) const {
- return m_co[0] * vv[0] + m_co[1] * vv[1];
-}
-
-GEN_INLINE MT_Scalar MT_Vector2::length2() const { return dot(*this); }
-GEN_INLINE MT_Scalar MT_Vector2::length() const { return sqrtf(length2()); }
-
-GEN_INLINE MT_Vector2 MT_Vector2::absolute() const {
- return MT_Vector2(MT_abs(m_co[0]), MT_abs(m_co[1]));
-}
-
-GEN_INLINE bool MT_Vector2::fuzzyZero() const { return MT_fuzzyZero2(length2()); }
-
-GEN_INLINE void MT_Vector2::normalize() { *this /= length(); }
-GEN_INLINE MT_Vector2 MT_Vector2::normalized() const { return *this / length(); }
-
-GEN_INLINE void MT_Vector2::scale(MT_Scalar xx, MT_Scalar yy) {
- m_co[0] *= xx; m_co[1] *= yy;
-}
-
-GEN_INLINE MT_Vector2 MT_Vector2::scaled(MT_Scalar xx, MT_Scalar yy) const {
- return MT_Vector2(m_co[0] * xx, m_co[1] * yy);
-}
-
-GEN_INLINE MT_Scalar MT_Vector2::angle(const MT_Vector2& vv) const {
- MT_Scalar s = sqrtf(length2() * vv.length2());
- MT_assert(!MT_fuzzyZero(s));
- return acosf(dot(vv) / s);
-}
-
-
-GEN_INLINE MT_Scalar MT_dot(const MT_Vector2& v1, const MT_Vector2& v2) {
- return v1.dot(v2);
-}
-
-GEN_INLINE MT_Scalar MT_length2(const MT_Vector2& v) { return v.length2(); }
-GEN_INLINE MT_Scalar MT_length(const MT_Vector2& v) { return v.length(); }
-
-GEN_INLINE bool MT_fuzzyZero(const MT_Vector2& v) { return v.fuzzyZero(); }
-GEN_INLINE bool MT_fuzzyEqual(const MT_Vector2& v1, const MT_Vector2& v2) {
- return MT_fuzzyZero(v1 - v2);
-}
-
-GEN_INLINE MT_Scalar MT_angle(const MT_Vector2& v1, const MT_Vector2& v2) { return v1.angle(v2); }
diff --git a/intern/moto/include/MT_Vector3.h b/intern/moto/include/MT_Vector3.h
deleted file mode 100644
index 545ca1fad0b..00000000000
--- a/intern/moto/include/MT_Vector3.h
+++ /dev/null
@@ -1,120 +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 moto/include/MT_Vector3.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_VECTOR3_H
-#define MT_VECTOR3_H
-
-#include <MT_assert.h>
-#include "MT_Tuple3.h"
-
-class MT_Vector3 : public MT_Tuple3 {
-public:
- MT_Vector3() {}
- MT_Vector3(const float *v) : MT_Tuple3(v) {}
- MT_Vector3(const double *v) : MT_Tuple3(v) {}
- MT_Vector3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) : MT_Tuple3(xx, yy, zz) {}
-
- MT_Vector3& operator+=(const MT_Vector3& v);
- MT_Vector3& operator-=(const MT_Vector3& v);
- MT_Vector3& operator*=(MT_Scalar s);
- MT_Vector3& operator/=(MT_Scalar s);
-
- MT_Scalar dot(const MT_Vector3& v) const;
-
- MT_Scalar length2() const;
- MT_Scalar length() const;
-
- MT_Vector3 absolute() const;
-
- void noiseGate(MT_Scalar threshold);
-
- void normalize();
- MT_Vector3 normalized() const;
- MT_Vector3 safe_normalized() const;
- MT_Vector3 safe_normalized_vec(MT_Vector3 vecnormalized) const;
-
- void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z);
- MT_Vector3 scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z) const;
-
- bool fuzzyZero() const;
-
- MT_Scalar angle(const MT_Vector3& v) const;
- MT_Vector3 cross(const MT_Vector3& v) const;
- MT_Scalar triple(const MT_Vector3& v1, const MT_Vector3& v2) const;
-
- int closestAxis() const;
-
- static MT_Vector3 random();
-};
-
-MT_Vector3 operator+(const MT_Vector3& v1, const MT_Vector3& v2);
-MT_Vector3 operator-(const MT_Vector3& v1, const MT_Vector3& v2);
-MT_Vector3 operator-(const MT_Vector3& v);
-MT_Vector3 operator*(const MT_Vector3& v, MT_Scalar s);
-MT_Vector3 operator*(MT_Scalar s, const MT_Vector3& v);
-MT_Vector3 operator/(const MT_Vector3& v, MT_Scalar s);
-
-MT_Vector3 operator*(const MT_Vector3& v1, const MT_Vector3& v2);
-
-MT_Scalar MT_dot(const MT_Vector3& v1, const MT_Vector3& v2);
-
-MT_Scalar MT_length2(const MT_Vector3& v);
-MT_Scalar MT_length(const MT_Vector3& v);
-
-bool MT_fuzzyZero(const MT_Vector3& v);
-bool MT_fuzzyEqual(const MT_Vector3& v1, const MT_Vector3& v2);
-
-MT_Scalar MT_angle(const MT_Vector3& v1, const MT_Vector3& v2);
-MT_Vector3 MT_cross(const MT_Vector3& v1, const MT_Vector3& v2);
-MT_Scalar MT_triple(const MT_Vector3& v1, const MT_Vector3& v2,
- const MT_Vector3& v3);
-
-#ifdef GEN_INLINED
-#include "MT_Vector3.inl"
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Vector3.inl b/intern/moto/include/MT_Vector3.inl
deleted file mode 100644
index 7994bf7c55c..00000000000
--- a/intern/moto/include/MT_Vector3.inl
+++ /dev/null
@@ -1,141 +0,0 @@
-#include "MT_Optimize.h"
-
-GEN_INLINE MT_Vector3& MT_Vector3::operator+=(const MT_Vector3& v) {
- m_co[0] += v[0]; m_co[1] += v[1]; m_co[2] += v[2];
- return *this;
-}
-
-GEN_INLINE MT_Vector3& MT_Vector3::operator-=(const MT_Vector3& v) {
- m_co[0] -= v[0]; m_co[1] -= v[1]; m_co[2] -= v[2];
- return *this;
-}
-
-GEN_INLINE MT_Vector3& MT_Vector3::operator*=(MT_Scalar s) {
- m_co[0] *= s; m_co[1] *= s; m_co[2] *= s;
- return *this;
-}
-
-GEN_INLINE MT_Vector3& MT_Vector3::operator/=(MT_Scalar s) {
- MT_assert(!MT_fuzzyZero(s));
- return *this *= MT_Scalar(1.0f) / s;
-}
-
-GEN_INLINE MT_Vector3 operator+(const MT_Vector3& v1, const MT_Vector3& v2) {
- return MT_Vector3(v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]);
-}
-
-GEN_INLINE MT_Vector3 operator-(const MT_Vector3& v1, const MT_Vector3& v2) {
- return MT_Vector3(v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]);
-}
-
-GEN_INLINE MT_Vector3 operator-(const MT_Vector3& v) {
- return MT_Vector3(-v[0], -v[1], -v[2]);
-}
-
-GEN_INLINE MT_Vector3 operator*(const MT_Vector3& v, MT_Scalar s) {
- return MT_Vector3(v[0] * s, v[1] * s, v[2] * s);
-}
-
-GEN_INLINE MT_Vector3 operator*(MT_Scalar s, const MT_Vector3& v) { return v * s; }
-
-GEN_INLINE MT_Vector3 operator/(const MT_Vector3& v, MT_Scalar s) {
- MT_assert(!MT_fuzzyZero(s));
- return v * (MT_Scalar(1.0f) / s);
-}
-
-GEN_INLINE MT_Vector3 operator*(const MT_Vector3& v1, const MT_Vector3& v2) {
- return MT_Vector3(v1[0] * v2[0], v1[1] * v2[1], v1[2] * v2[2]);
-}
-
-GEN_INLINE MT_Scalar MT_Vector3::dot(const MT_Vector3& v) const {
- return m_co[0] * v[0] + m_co[1] * v[1] + m_co[2] * v[2];
-}
-
-GEN_INLINE MT_Scalar MT_Vector3::length2() const { return dot(*this); }
-GEN_INLINE MT_Scalar MT_Vector3::length() const { return sqrtf(length2()); }
-
-GEN_INLINE MT_Vector3 MT_Vector3::absolute() const {
- return MT_Vector3(MT_abs(m_co[0]), MT_abs(m_co[1]), MT_abs(m_co[2]));
-}
-
-GEN_INLINE bool MT_Vector3::fuzzyZero() const {
- return MT_fuzzyZero(length2());
-}
-
-GEN_INLINE void MT_Vector3::noiseGate(MT_Scalar threshold) {
- if (length2() < threshold) {
- setValue(MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f));
- }
-}
-
-GEN_INLINE void MT_Vector3::normalize() { *this /= length(); }
-GEN_INLINE MT_Vector3 MT_Vector3::normalized() const { return *this / length(); }
-GEN_INLINE MT_Vector3 MT_Vector3::safe_normalized() const {
- MT_Scalar len = length();
- return MT_fuzzyZero(len) ?
- MT_Vector3(MT_Scalar(1.0f), MT_Scalar(0.0f), MT_Scalar(0.0f)) :
- *this / len;
-}
-
-GEN_INLINE MT_Vector3 MT_Vector3::safe_normalized_vec(MT_Vector3 vecnormalized) const {
- MT_Scalar len = length();
- return MT_fuzzyZero(len) ?
- vecnormalized :
- *this / len;
-}
-
-GEN_INLINE void MT_Vector3::scale(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) {
- m_co[0] *= xx; m_co[1] *= yy; m_co[2] *= zz;
-}
-
-GEN_INLINE MT_Vector3 MT_Vector3::scaled(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) const {
- return MT_Vector3(m_co[0] * xx, m_co[1] * yy, m_co[2] * zz);
-}
-
-GEN_INLINE MT_Scalar MT_Vector3::angle(const MT_Vector3& v) const {
- MT_Scalar s = sqrtf(length2() * v.length2());
- MT_assert(!MT_fuzzyZero(s));
- return acosf(dot(v) / s);
-}
-
-GEN_INLINE MT_Vector3 MT_Vector3::cross(const MT_Vector3& v) const {
- return MT_Vector3(m_co[1] * v[2] - m_co[2] * v[1],
- m_co[2] * v[0] - m_co[0] * v[2],
- m_co[0] * v[1] - m_co[1] * v[0]);
-}
-
-GEN_INLINE MT_Scalar MT_Vector3::triple(const MT_Vector3& v1, const MT_Vector3& v2) const {
- return m_co[0] * (v1[1] * v2[2] - v1[2] * v2[1]) +
- m_co[1] * (v1[2] * v2[0] - v1[0] * v2[2]) +
- m_co[2] * (v1[0] * v2[1] - v1[1] * v2[0]);
-}
-
-GEN_INLINE int MT_Vector3::closestAxis() const {
- MT_Vector3 a = absolute();
- return a[0] < a[1] ? (a[1] < a[2] ? 2 : 1) : (a[0] < a[2] ? 2 : 0);
-}
-
-GEN_INLINE MT_Vector3 MT_Vector3::random() {
- MT_Scalar z = MT_Scalar(2.0f) * MT_random() - MT_Scalar(1.0f);
- MT_Scalar r = sqrtf(MT_Scalar(1.0f) - z * z);
- MT_Scalar t = (float)MT_2_PI * MT_random();
- return MT_Vector3(r * cosf(t), r * sinf(t), z);
-}
-
-GEN_INLINE MT_Scalar MT_dot(const MT_Vector3& v1, const MT_Vector3& v2) {
- return v1.dot(v2);
-}
-
-GEN_INLINE MT_Scalar MT_length2(const MT_Vector3& v) { return v.length2(); }
-GEN_INLINE MT_Scalar MT_length(const MT_Vector3& v) { return v.length(); }
-
-GEN_INLINE bool MT_fuzzyZero(const MT_Vector3& v) { return v.fuzzyZero(); }
-GEN_INLINE bool MT_fuzzyEqual(const MT_Vector3& v1, const MT_Vector3& v2) {
- return MT_fuzzyZero(v1 - v2);
-}
-
-GEN_INLINE MT_Scalar MT_angle(const MT_Vector3& v1, const MT_Vector3& v2) { return v1.angle(v2); }
-GEN_INLINE MT_Vector3 MT_cross(const MT_Vector3& v1, const MT_Vector3& v2) { return v1.cross(v2); }
-GEN_INLINE MT_Scalar MT_triple(const MT_Vector3& v1, const MT_Vector3& v2, const MT_Vector3& v3) {
- return v1.triple(v2, v3);
-}
diff --git a/intern/moto/include/MT_Vector4.h b/intern/moto/include/MT_Vector4.h
deleted file mode 100644
index 440bf9b84f1..00000000000
--- a/intern/moto/include/MT_Vector4.h
+++ /dev/null
@@ -1,103 +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 moto/include/MT_Vector4.h
- * \ingroup moto
- */
-
-
-/*
-
- * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Gino van den Bergen makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifndef MT_VECTOR4_H
-#define MT_VECTOR4_H
-
-#include <MT_assert.h>
-
-#include "MT_Tuple4.h"
-
-class MT_Vector4 : public MT_Tuple4 {
-public:
- MT_Vector4() {}
- MT_Vector4(const float *v) : MT_Tuple4(v) {}
- MT_Vector4(const double *v) : MT_Tuple4(v) {}
- MT_Vector4(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) :
- MT_Tuple4(xx, yy, zz, ww) {}
-
- MT_Vector4& operator+=(const MT_Vector4& v);
- MT_Vector4& operator-=(const MT_Vector4& v);
- MT_Vector4& operator*=(MT_Scalar s);
- MT_Vector4& operator/=(MT_Scalar s);
-
- MT_Scalar dot(const MT_Vector4& v) const;
-
- MT_Scalar length2() const;
- MT_Scalar length() const;
-
- MT_Vector4 absolute() const;
-
- void normalize();
- MT_Vector4 normalized() const;
-
- void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w);
- MT_Vector4 scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z, MT_Scalar w) const;
-
- bool fuzzyZero() const;
-};
-
-MT_Vector4 operator+(const MT_Vector4& v1, const MT_Vector4& v2);
-MT_Vector4 operator-(const MT_Vector4& v1, const MT_Vector4& v2);
-MT_Vector4 operator-(const MT_Vector4& v);
-MT_Vector4 operator*(const MT_Vector4& v, MT_Scalar s);
-MT_Vector4 operator*(MT_Scalar s, const MT_Vector4& v);
-MT_Vector4 operator/(const MT_Vector4& v, MT_Scalar s);
-
-MT_Scalar MT_dot(const MT_Vector4& v1, const MT_Vector4& v2);
-
-MT_Scalar MT_length2(const MT_Vector4& v);
-MT_Scalar MT_length(const MT_Vector4& v);
-
-bool MT_fuzzyZero(const MT_Vector4& v);
-bool MT_fuzzyEqual(const MT_Vector4& v1, const MT_Vector4& v2);
-
-#ifdef GEN_INLINED
-#include "MT_Vector4.inl"
-#endif
-
-#endif
-
diff --git a/intern/moto/include/MT_Vector4.inl b/intern/moto/include/MT_Vector4.inl
deleted file mode 100644
index 5b6e6766416..00000000000
--- a/intern/moto/include/MT_Vector4.inl
+++ /dev/null
@@ -1,80 +0,0 @@
-#include "MT_Optimize.h"
-
-GEN_INLINE MT_Vector4& MT_Vector4::operator+=(const MT_Vector4& v) {
- m_co[0] += v[0]; m_co[1] += v[1]; m_co[2] += v[2]; m_co[3] += v[3];
- return *this;
-}
-
-GEN_INLINE MT_Vector4& MT_Vector4::operator-=(const MT_Vector4& v) {
- m_co[0] -= v[0]; m_co[1] -= v[1]; m_co[2] -= v[2]; m_co[3] -= v[3];
- return *this;
-}
-
-GEN_INLINE MT_Vector4& MT_Vector4::operator*=(MT_Scalar s) {
- m_co[0] *= s; m_co[1] *= s; m_co[2] *= s; m_co[3] *= s;
- return *this;
-}
-
-GEN_INLINE MT_Vector4& MT_Vector4::operator/=(MT_Scalar s) {
- MT_assert(!MT_fuzzyZero(s));
- return *this *= MT_Scalar(1.0f) / s;
-}
-
-GEN_INLINE MT_Vector4 operator+(const MT_Vector4& v1, const MT_Vector4& v2) {
- return MT_Vector4(v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2], v1[3] + v2[3]);
-}
-
-GEN_INLINE MT_Vector4 operator-(const MT_Vector4& v1, const MT_Vector4& v2) {
- return MT_Vector4(v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2], v1[3] - v2[3]);
-}
-
-GEN_INLINE MT_Vector4 operator-(const MT_Vector4& v) {
- return MT_Vector4(-v[0], -v[1], -v[2], -v[3]);
-}
-
-GEN_INLINE MT_Vector4 operator*(const MT_Vector4& v, MT_Scalar s) {
- return MT_Vector4(v[0] * s, v[1] * s, v[2] * s, v[3] * s);
-}
-
-GEN_INLINE MT_Vector4 operator*(MT_Scalar s, const MT_Vector4& v) { return v * s; }
-
-GEN_INLINE MT_Vector4 operator/(const MT_Vector4& v, MT_Scalar s) {
- MT_assert(!MT_fuzzyZero(s));
- return v * (MT_Scalar(1.0f) / s);
-}
-
-GEN_INLINE MT_Scalar MT_Vector4::dot(const MT_Vector4& v) const {
- return m_co[0] * v[0] + m_co[1] * v[1] + m_co[2] * v[2] + m_co[3] * v[3];
-}
-
-GEN_INLINE MT_Scalar MT_Vector4::length2() const { return MT_dot(*this, *this); }
-GEN_INLINE MT_Scalar MT_Vector4::length() const { return sqrtf(length2()); }
-
-GEN_INLINE MT_Vector4 MT_Vector4::absolute() const {
- return MT_Vector4(MT_abs(m_co[0]), MT_abs(m_co[1]), MT_abs(m_co[2]), MT_abs(m_co[3]));
-}
-
-GEN_INLINE void MT_Vector4::scale(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) {
- m_co[0] *= xx; m_co[1] *= yy; m_co[2] *= zz; m_co[3] *= ww;
-}
-
-GEN_INLINE MT_Vector4 MT_Vector4::scaled(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) const {
- return MT_Vector4(m_co[0] * xx, m_co[1] * yy, m_co[2] * zz, m_co[3] * ww);
-}
-
-GEN_INLINE bool MT_Vector4::fuzzyZero() const { return MT_fuzzyZero2(length2()); }
-
-GEN_INLINE void MT_Vector4::normalize() { *this /= length(); }
-GEN_INLINE MT_Vector4 MT_Vector4::normalized() const { return *this / length(); }
-
-GEN_INLINE MT_Scalar MT_dot(const MT_Vector4& v1, const MT_Vector4& v2) {
- return v1.dot(v2);
-}
-
-GEN_INLINE MT_Scalar MT_length2(const MT_Vector4& v) { return v.length2(); }
-GEN_INLINE MT_Scalar MT_length(const MT_Vector4& v) { return v.length(); }
-
-GEN_INLINE bool MT_fuzzyZero(const MT_Vector4& v) { return v.fuzzyZero(); }
-GEN_INLINE bool MT_fuzzyEqual(const MT_Vector4& v1, const MT_Vector4& v2) {
- return MT_fuzzyZero(v1 - v2);
-}
diff --git a/intern/moto/include/MT_assert.h b/intern/moto/include/MT_assert.h
deleted file mode 100644
index 256397036de..00000000000
--- a/intern/moto/include/MT_assert.h
+++ /dev/null
@@ -1,103 +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 moto/include/MT_assert.h
- * \ingroup moto
- */
-
-
-#ifndef MT_ASSERT_H
-#define MT_ASSERT_H
-
-#include <signal.h>
-#include <stdlib.h>
-#include <assert.h>
-
-
-// So it can be used from C
-#ifdef __cplusplus
-#define MT_CDECL extern "C"
-#else
-#define MT_CDECL
-#endif
-
-// Ask the user if they wish to abort/break, ignore, or ignore for good.
-// file, line, predicate form the message to ask, *do_assert should be set
-// to 0 to ignore.
-// returns 1 to break, false to ignore
-MT_CDECL int MT_QueryAssert(const char *file, int line, const char *predicate, int *do_assert);
-
-
-#if !defined(DEBUG)
-#define MT_assert(predicate) ((void)0)
-#define BREAKPOINT() ((void)0)
-#else
-
-// BREAKPOINT() will cause a break into the debugger
-#if defined(__i386) && defined(__GNUC__)
-// gcc on intel...
-#define BREAKPOINT() \
-asm("int $3")
-#elif defined(_MSC_VER)
-// Visual C++ (on Intel)
-#define BREAKPOINT() \
-{ _asm int 3 }
-#elif defined(SIGTRAP)
-// POSIX compatible...
-#define BREAKPOINT() \
-raise(SIGTRAP);
-#else
-// FIXME: Don't know how to do a decent break!
-// Add some code for your cpu type, or get a posix
-// system.
-// abort instead
-#define BREAKPOINT() \
-abort();
-#endif /* breakpoint */
-
-
-#if defined(_WIN32) && !defined(__GNUC__)
-#define MT_assert(predicate) assert(predicate)
-#else
-
-
-
-// Abort the program if predicate is not true
-#define MT_assert(predicate) \
-{ \
- static int do_assert = 1; \
- if (!(predicate) && MT_QueryAssert(__FILE__, __LINE__, #predicate, &do_assert)) \
- { \
- BREAKPOINT(); \
- } \
-}
-#endif /* windows */
-
-#endif /* !defined(DEBUG) */
-
-#endif
-
diff --git a/intern/moto/include/MT_random.h b/intern/moto/include/MT_random.h
deleted file mode 100644
index 735316278d6..00000000000
--- a/intern/moto/include/MT_random.h
+++ /dev/null
@@ -1,44 +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 moto/include/MT_random.h
- * \ingroup moto
- */
-
-
-#ifndef MT_RANDOM_H
-#define MT_RANDOM_H
-
-#include <limits.h>
-
-#define MT_RAND_MAX UINT_MAX
-
-extern void MT_srand(unsigned int);
-extern unsigned int MT_rand();
-
-#endif
-
diff --git a/intern/moto/intern/MT_Assert.cpp b/intern/moto/intern/MT_Assert.cpp
deleted file mode 100644
index 9279b70afec..00000000000
--- a/intern/moto/intern/MT_Assert.cpp
+++ /dev/null
@@ -1,68 +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 moto/intern/MT_Assert.cpp
- * \ingroup moto
- */
-
-
-#include <stdio.h>
-
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
-#include "MT_assert.h"
-
-#ifdef _MSC_VER
-#ifndef snprintf
- #define snprintf _snprintf
-#endif
-#endif
-
-// Query the user if they want to break/abort the program, ignore the assert, or ignore all future
-// occurance of the assert.
-int MT_QueryAssert(const char *file, int line, const char *predicate, int *do_assert)
-{
-#ifdef _WIN32
- if (*do_assert)
- {
- char buffer[1024];
- snprintf(buffer, 1024, "ASSERT %s:%d: %s failed.\nWould you like to debug? (Cancel = ignore)", file, line, predicate);
- int result = MessageBox(NULL, buffer, "ASSERT failed.", MB_YESNOCANCEL|MB_ICONERROR);
- if (result == IDCANCEL)
- {
- *do_assert = 0;
- return 0;
- }
-
- return result == IDYES;
- }
-#endif
- printf("ASSERT %s:%d: %s failed.\n", file, line, predicate);
- return *do_assert;
-}
diff --git a/intern/moto/intern/MT_CmMatrix4x4.cpp b/intern/moto/intern/MT_CmMatrix4x4.cpp
deleted file mode 100644
index 38c93b92761..00000000000
--- a/intern/moto/intern/MT_CmMatrix4x4.cpp
+++ /dev/null
@@ -1,206 +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 moto/intern/MT_CmMatrix4x4.cpp
- * \ingroup moto
- */
-
-
-#include "MT_CmMatrix4x4.h"
-#include "MT_Vector3.h"
-#include "MT_Point3.h"
-
-
-MT_CmMatrix4x4::MT_CmMatrix4x4()
-{
- Identity();
-}
-
-
-
-MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_Scalar value[4][4])
-{
- for (int i=0;i<4;i++)
- {
- for (int j=0;j<4;j++)
- m_V[i][j] = value[i][j];
- }
-}
-
-
-
-MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_Scalar value[16])
-{
- for (int i=0;i<16;i++)
- m_Vflat[i] = value[i];
-}
-
-
-
-MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_CmMatrix4x4& other)
-{
- SetMatrix(other);
-}
-
-
-
-MT_CmMatrix4x4::MT_CmMatrix4x4(const MT_Point3& orig,
- const MT_Vector3& dir,
- const MT_Vector3 up)
-{
- MT_Vector3 z = -(dir.normalized());
- MT_Vector3 x = (up.cross(z)).normalized();
- MT_Vector3 y = (z.cross(x));
-
- m_V[0][0] = x.x();
- m_V[0][1] = y.x();
- m_V[0][2] = z.x();
- m_V[0][3] = 0.0f;
-
- m_V[1][0] = x.y();
- m_V[1][1] = y.y();
- m_V[1][2] = z.y();
- m_V[1][3] = 0.0f;
-
- m_V[2][0] = x.z();
- m_V[2][1] = y.z();
- m_V[2][2] = z.z();
- m_V[2][3] = 0.0f;
-
- m_V[3][0] = orig.x();//0.0f;
- m_V[3][1] = orig.y();//0.0f;
- m_V[3][2] = orig.z();//0.0f;
- m_V[3][3] = 1.0f;
-
- //Translate(-orig);
-}
-
-
-
-MT_Vector3 MT_CmMatrix4x4::GetRight() const
-{
- return MT_Vector3(m_V[0][0], m_V[0][1], m_V[0][2]);
-}
-
-
-
-MT_Vector3 MT_CmMatrix4x4::GetUp() const
-{
- return MT_Vector3(m_V[1][0], m_V[1][1], m_V[1][2]);
-}
-
-
-
-MT_Vector3 MT_CmMatrix4x4::GetDir() const
-{
- return MT_Vector3(m_V[2][0], m_V[2][1], m_V[2][2]);
-}
-
-
-
-MT_Point3 MT_CmMatrix4x4::GetPos() const
-{
- return MT_Point3(m_V[3][0], m_V[3][1], m_V[3][2]);
-}
-
-
-
-void MT_CmMatrix4x4::Identity()
-{
- for (int i=0; i<4; i++)
- {
- for (int j=0; j<4; j++)
- m_V[i][j] = (i==j?1.0f:0.0f);
- }
-}
-
-
-
-void MT_CmMatrix4x4::SetMatrix(const MT_CmMatrix4x4& other)
-{
- for (int i=0; i<16; i++)
- m_Vflat[i] = other.m_Vflat[i];
-}
-
-
-
-MT_Scalar* MT_CmMatrix4x4::getPointer()
-{
- return &m_V[0][0];
-}
-
-
-
-const MT_Scalar* MT_CmMatrix4x4::getPointer() const
-{
- return &m_V[0][0];
-}
-
-
-
-void MT_CmMatrix4x4::setElem(int pos,MT_Scalar newvalue)
-{
- m_Vflat[pos] = newvalue;
-}
-
-MT_CmMatrix4x4 MT_CmMatrix4x4::Perspective(
- MT_Scalar inLeft,
- MT_Scalar inRight,
- MT_Scalar inBottom,
- MT_Scalar inTop,
- MT_Scalar inNear,
- MT_Scalar inFar
-){
-
- MT_CmMatrix4x4 mat;
-
- // Column 0
- mat(0, 0) = -(2.0f*inNear) / (inRight-inLeft);
- mat(1, 0) = 0.0f;
- mat(2, 0) = 0.0f;
- mat(3, 0) = 0.0f;
-
- // Column 1
- mat(0, 1) = 0.0f;
- mat(1, 1) = (2.0f*inNear) / (inTop-inBottom);
- mat(2, 1) = 0.0f;
- mat(3, 1) = 0.0f;
-
- // Column 2
- mat(0, 2) = (inRight+inLeft) / (inRight-inLeft);
- mat(1, 2) = (inTop+inBottom) / (inTop-inBottom);
- mat(2, 2) = -(inFar+inNear) / (inFar-inNear);
- mat(3, 2) = -1.0f;
-
- // Column 3
- mat(0, 3) = 0.0f;
- mat(1, 3) = 0.0f;
- mat(2, 3) = -(2.0f*inFar*inNear) / (inFar-inNear);
- mat(3, 3) = 0.0f;
-
- return mat;
-}
diff --git a/intern/moto/intern/MT_Matrix3x3.cpp b/intern/moto/intern/MT_Matrix3x3.cpp
deleted file mode 100644
index fd33b3e1d39..00000000000
--- a/intern/moto/intern/MT_Matrix3x3.cpp
+++ /dev/null
@@ -1,38 +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 moto/intern/MT_Matrix3x3.cpp
- * \ingroup moto
- */
-
-
-#include "MT_Matrix3x3.h"
-
-
-#ifndef GEN_INLINED
-#include "MT_Matrix3x3.inl"
-#endif
diff --git a/intern/moto/intern/MT_Matrix4x4.cpp b/intern/moto/intern/MT_Matrix4x4.cpp
deleted file mode 100644
index 41d49538212..00000000000
--- a/intern/moto/intern/MT_Matrix4x4.cpp
+++ /dev/null
@@ -1,38 +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 moto/intern/MT_Matrix4x4.cpp
- * \ingroup moto
- */
-
-
-#include "MT_Matrix4x4.h"
-
-
-#ifndef GEN_INLINED
-#include "MT_Matrix4x4.inl"
-#endif
diff --git a/intern/moto/intern/MT_Quaternion.cpp b/intern/moto/intern/MT_Quaternion.cpp
deleted file mode 100644
index a2b634fced5..00000000000
--- a/intern/moto/intern/MT_Quaternion.cpp
+++ /dev/null
@@ -1,38 +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 moto/intern/MT_Quaternion.cpp
- * \ingroup moto
- */
-
-
-#include "MT_Quaternion.h"
-
-
-#ifndef GEN_INLINED
-#include "MT_Quaternion.inl"
-#endif
diff --git a/intern/moto/intern/MT_Transform.cpp b/intern/moto/intern/MT_Transform.cpp
deleted file mode 100644
index 49a75b78e46..00000000000
--- a/intern/moto/intern/MT_Transform.cpp
+++ /dev/null
@@ -1,139 +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 moto/intern/MT_Transform.cpp
- * \ingroup moto
- */
-
-
-/*
-
- MOTTO - 3D Motion Toolkit
- Copyright (C) 2000 Gino van den Bergen <gino@acm.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- 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 GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "MT_Transform.h"
-
-void MT_Transform::setValue(const float *m) {
- m_basis.setValue(m);
- m_origin.setValue(&m[12]);
- m_type = AFFINE;
-}
-
-void MT_Transform::setValue(const double *m) {
- m_basis.setValue(m);
- m_origin.setValue(&m[12]);
- m_type = AFFINE;
-}
-
-void MT_Transform::getValue(float *m) const {
- m_basis.getValue(m);
- m_origin.getValue(&m[12]);
- m[15] = 1.0f;
-}
-
-void MT_Transform::getValue(double *m) const {
- m_basis.getValue(m);
- m_origin.getValue(&m[12]);
- m[15] = 1.0;
-}
-
-MT_Transform& MT_Transform::operator*=(const MT_Transform& t) {
- m_origin += m_basis * t.m_origin;
- m_basis *= t.m_basis;
- m_type |= t.m_type;
- return *this;
-}
-
-void MT_Transform::translate(const MT_Vector3& v) {
- m_origin += m_basis * v;
- m_type |= TRANSLATION;
-}
-
-void MT_Transform::rotate(const MT_Quaternion& q) {
- m_basis *= MT_Matrix3x3(q);
- m_type |= ROTATION;
-}
-
-void MT_Transform::scale(MT_Scalar x, MT_Scalar y, MT_Scalar z) {
- m_basis.scale(x, y, z);
- m_type |= SCALING;
-}
-
-void MT_Transform::setIdentity() {
- m_basis.setIdentity();
- m_origin.setValue(MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(0.0f));
- m_type = IDENTITY;
-}
-
-void MT_Transform::invert(const MT_Transform& t) {
- m_basis = t.m_type & SCALING ?
- t.m_basis.inverse() :
- t.m_basis.transposed();
- m_origin.setValue(-MT_dot(m_basis[0], t.m_origin),
- -MT_dot(m_basis[1], t.m_origin),
- -MT_dot(m_basis[2], t.m_origin));
- m_type = t.m_type;
-}
-
-void MT_Transform::mult(const MT_Transform& t1, const MT_Transform& t2) {
- m_basis = t1.m_basis * t2.m_basis;
- m_origin = t1(t2.m_origin);
- m_type = t1.m_type | t2.m_type;
-}
-
-void MT_Transform::multInverseLeft(const MT_Transform& t1, const MT_Transform& t2) {
- MT_Vector3 v = t2.m_origin - t1.m_origin;
- if (t1.m_type & SCALING) {
- MT_Matrix3x3 inv = t1.m_basis.inverse();
- m_basis = inv * t2.m_basis;
- m_origin = inv * v;
- }
- else {
- m_basis = MT_multTransposeLeft(t1.m_basis, t2.m_basis);
- m_origin = v * t1.m_basis;
- }
- m_type = t1.m_type | t2.m_type;
-}
-
-
-
diff --git a/intern/moto/intern/MT_Vector2.cpp b/intern/moto/intern/MT_Vector2.cpp
deleted file mode 100644
index 3c0b0a08f1f..00000000000
--- a/intern/moto/intern/MT_Vector2.cpp
+++ /dev/null
@@ -1,38 +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 moto/intern/MT_Vector2.cpp
- * \ingroup moto
- */
-
-
-#include "MT_Vector2.h"
-
-
-#ifndef GEN_INLINED
-#include "MT_Vector2.inl"
-#endif
diff --git a/intern/moto/intern/MT_Vector3.cpp b/intern/moto/intern/MT_Vector3.cpp
deleted file mode 100644
index a90551dd0a8..00000000000
--- a/intern/moto/intern/MT_Vector3.cpp
+++ /dev/null
@@ -1,38 +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 moto/intern/MT_Vector3.cpp
- * \ingroup moto
- */
-
-
-#include "MT_Vector3.h"
-
-
-#ifndef GEN_INLINED
-#include "MT_Vector3.inl"
-#endif
diff --git a/intern/moto/intern/MT_Vector4.cpp b/intern/moto/intern/MT_Vector4.cpp
deleted file mode 100644
index b41ec03754d..00000000000
--- a/intern/moto/intern/MT_Vector4.cpp
+++ /dev/null
@@ -1,38 +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 moto/intern/MT_Vector4.cpp
- * \ingroup moto
- */
-
-
-#include "MT_Vector4.h"
-
-
-#ifndef GEN_INLINED
-#include "MT_Vector4.inl"
-#endif
diff --git a/intern/moto/intern/MT_random.cpp b/intern/moto/intern/MT_random.cpp
deleted file mode 100644
index ab191008d28..00000000000
--- a/intern/moto/intern/MT_random.cpp
+++ /dev/null
@@ -1,143 +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 moto/intern/MT_random.cpp
- * \ingroup moto
- */
-
-
-/* A C-program for MT19937: Real number version */
-
-/* genrand() generates one pseudorandom real number (double) */
-/* which is uniformly distributed on [0,1]-interval, for each */
-/* call. sgenrand(seed) set initial values to the working area */
-/* of 624 words. Before genrand(), sgenrand(seed) must be */
-/* called once. (seed is any 32-bit integer except for 0). */
-/* Integer generator is obtained by modifying two lines. */
-/* Coded by Takuji Nishimura, considering the suggestions by */
-/* Topher Cooper and Marc Rieffel in July-Aug. 1997. */
-
-/* This library is free software; you can redistribute it and/or */
-/* modify it under the terms of the GNU Library General Public */
-/* License as published by the Free Software Foundation; either */
-/* version 2 of the License, or (at your option) any later */
-/* version. */
-/* 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 GNU Library General Public License for more details. */
-/* You should have received a copy of the GNU Library General */
-/* Public License along with this library; if not, write to the */
-/* Free Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA */
-/* 02110-1301, USA */
-
-/* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. */
-/* When you use this, send an email to: matumoto@math.keio.ac.jp */
-/* with an appropriate reference to your work. */
-
-#include "MT_random.h"
-
-/* Period parameters */
-#define N 624
-#define M 397
-#define MATRIX_A 0x9908b0df /* constant vector a */
-#define UPPER_MASK 0x80000000 /* most significant w-r bits */
-#define LOWER_MASK 0x7fffffff /* least significant r bits */
-
-/* Tempering parameters */
-#define TEMPERING_MASK_B 0x9d2c5680
-#define TEMPERING_MASK_C 0xefc60000
-#define TEMPERING_SHIFT_U(y) (y >> 11)
-#define TEMPERING_SHIFT_S(y) (y << 7)
-#define TEMPERING_SHIFT_T(y) (y << 15)
-#define TEMPERING_SHIFT_L(y) (y >> 18)
-
-static unsigned int mt[N]; /* the array for the state vector */
-static int mti = N+1; /* mti==N+1 means mt[N] is not initialized */
-
-/* initializing the array with a NONZERO seed */
-void MT_srand(unsigned int seed)
-{
- /* setting initial seeds to mt[N] using */
- /* the generator Line 25 of Table 1 in */
- /* [KNUTH 1981, The Art of Computer Programming */
- /* Vol. 2 (2nd Ed.), pp102] */
- mt[0] = seed & 0xffffffff;
- for (mti = 1; mti < N; mti++)
- mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
-}
-
-unsigned int MT_rand()
-{
- static unsigned int mag01[2] = { 0x0, MATRIX_A };
- /* mag01[x] = x * MATRIX_A for x=0,1 */
-
- unsigned int y;
-
- if (mti >= N) { /* generate N words at one time */
- int kk;
-
- if (mti == N+1) /* if sgenrand() has not been called, */
- MT_srand(4357); /* a default initial seed is used */
-
- for (kk = 0; kk < N - M; kk++) {
- y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
- mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1];
- }
- for (; kk < N-1; kk++) {
- y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
- mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1];
- }
- y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK);
- mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1];
-
- mti = 0;
- }
-
- y = mt[mti++];
- y ^= TEMPERING_SHIFT_U(y);
- y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B;
- y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
- y ^= TEMPERING_SHIFT_L(y);
-
- return y;
-}
-
-#undef N
-#undef M
-#undef MATRIX_A
-#undef UPPER_MASK
-#undef LOWER_MASK
-
-/* Tempering parameters */
-#undef TEMPERING_MASK_B
-#undef TEMPERING_MASK_C
-#undef TEMPERING_SHIFT_U
-#undef TEMPERING_SHIFT_S
-#undef TEMPERING_SHIFT_T
-#undef TEMPERING_SHIFT_L
-
diff --git a/intern/string/CMakeLists.txt b/intern/string/CMakeLists.txt
index ddadfc61bee..055bafdb157 100644
--- a/intern/string/CMakeLists.txt
+++ b/intern/string/CMakeLists.txt
@@ -34,7 +34,6 @@ set(INC_SYS
set(SRC
intern/STR_String.cpp
- STR_HashedString.h
STR_String.h
)
diff --git a/intern/string/STR_HashedString.h b/intern/string/STR_HashedString.h
deleted file mode 100644
index ce790f398a0..00000000000
--- a/intern/string/STR_HashedString.h
+++ /dev/null
@@ -1,158 +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 string/STR_HashedString.h
- * \ingroup string
- *
- * Copyright (C) 2001 NaN Technologies B.V.
- * This file was formerly known as: GEN_StdString.cpp.
- * \date November, 14, 2001
- */
-
-#ifndef __STR_HASHEDSTRING_H__
-#define __STR_HASHEDSTRING_H__
-
-#include "STR_String.h"
-
-/* copied from 'BLI_compiler_attrs.h' */
-/* Use to suppress '-Wimplicit-fallthrough' (in place of 'break'). */
-#if defined(__GNUC__) && (__GNUC__ >= 7) /* gcc7.0+ only */
-#define ATTR_FALLTHROUGH __attribute__((fallthrough))
-#else
-#define ATTR_FALLTHROUGH ((void)0)
-#endif
-
-
-// Hash Mix utility function, by Bob Jenkins - Mix 3 32-bit values reversibly
-//
-// - If gHashMix() is run forward or backward, at least 32 bits in a,b,c have at
-// least 1/4 probability of changing.
-//
-// - If gHashMix() is run forward, every bit of c will change between 1/3 and
-// 2/3 of the time.
-//
-static inline void STR_gHashMix(dword& a, dword& b, dword& c)
-{
- a -= b; a -= c; a ^= (c >> 13);
- b -= c; b -= a; b ^= (a << 8);
- c -= a; c -= b; c ^= (b >> 13);
- a -= b; a -= c; a ^= (c >> 12);
- b -= c; b -= a; b ^= (a << 16);
- c -= a; c -= b; c ^= (b >> 5);
- a -= b; a -= c; a ^= (c >> 3);
- b -= c; b -= a; b ^= (a << 10);
- c -= a; c -= b; c ^= (b >> 15);
-}
-
-//
-// Fast Hashable<int32> functionality
-// http://www.concentric.net/~Ttwang/tech/inthash.htm
-//
-static inline dword STR_gHash(dword inDWord)
-{
- dword key = inDWord;
- key += ~(key << 16);
- key ^= (key >> 5);
- key += (key << 3);
- key ^= (key >> 13);
- key += ~(key << 9);
- key ^= (key >> 17);
- return key;
-}
-
-enum { GOLDEN_RATIO = 0x9e3779b9 }; /* arbitrary value to initialize hash funtion, well not so arbitrary
- * as this value is taken from the pigs library (Orange Games/Lost Boys) */
-
-
-
-static dword STR_gHash(const void *in, int len, dword init_val)
-{
- unsigned int length = len;
- dword a = (dword)GOLDEN_RATIO;
- dword b = (dword)GOLDEN_RATIO;
- dword c = init_val; /* the previous hash value */
- byte *p_in = (byte *)in;
-
- // Do the largest part of the key
- while (length >= 12)
- {
- a += (p_in[0] + ((dword)p_in[1] << 8) + ((dword)p_in[2] << 16) + ((dword)p_in[3] << 24));
- b += (p_in[4] + ((dword)p_in[5] << 8) + ((dword)p_in[6] << 16) + ((dword)p_in[7] << 24));
- c += (p_in[8] + ((dword)p_in[9] << 8) + ((dword)p_in[10] << 16) + ((dword)p_in[11] << 24));
- STR_gHashMix(a, b, c);
- p_in += 12; length -= 12;
- }
-
- // Handle the last 11 bytes
- c += len;
- switch (length) {
- case 11: c += ((dword)p_in[10] << 24); ATTR_FALLTHROUGH;
- case 10: c += ((dword)p_in[9] << 16); ATTR_FALLTHROUGH;
- case 9: c += ((dword)p_in[8] << 8); ATTR_FALLTHROUGH; /* the first byte of c is reserved for the length */
- case 8: b += ((dword)p_in[7] << 24); ATTR_FALLTHROUGH;
- case 7: b += ((dword)p_in[6] << 16); ATTR_FALLTHROUGH;
- case 6: b += ((dword)p_in[5] << 8); ATTR_FALLTHROUGH;
- case 5: b += p_in[4]; ATTR_FALLTHROUGH;
- case 4: a += ((dword)p_in[3] << 24); ATTR_FALLTHROUGH;
- case 3: a += ((dword)p_in[2] << 16); ATTR_FALLTHROUGH;
- case 2: a += ((dword)p_in[1] << 8); ATTR_FALLTHROUGH;
- case 1: a += p_in[0];
- }
- STR_gHashMix(a, b, c);
-
- return c;
-}
-
-
-
-
-class STR_HashedString : public STR_String
-{
-public:
- STR_HashedString() : STR_String(), m_Hashed(false) {}
- STR_HashedString(const char *str) : STR_String(str), m_Hashed(false) {}
- STR_HashedString(const STR_String &str) : STR_String(str), m_Hashed(false) {}
-
- inline dword hash(dword init = 0) const
- {
- if (!m_Hashed)
- {
- const char *str = *this;
- int length = this->Length();
- m_CachedHash = STR_gHash(str, length, init);
- m_Hashed = true;
- }
- return m_CachedHash;
- }
-
-private:
- mutable bool m_Hashed;
- mutable dword m_CachedHash;
-};
-
-#endif //__STR_HASHEDSTRING_H__
-
diff --git a/release/datafiles/locale b/release/datafiles/locale
-Subproject 469c949d1ca882be19daa128842f813b72a944d
+Subproject d3349b42856d00c278f72f2a5909a6c96b9cdb5
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject c88411ff7776a2db5d6ef6117a1b2faa42a9561
+Subproject 8f2fd7e23f0b5ce023440182f51c40e88d66332
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
-Subproject 310578043dec1aae382eb6a447ae1d103792d7e
+Subproject 34a27a42d781d80f9f1833bad8cc5b2abcac293
diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py
index b00b30a9a21..c2b23f017fe 100644
--- a/release/scripts/freestyle/modules/parameter_editor.py
+++ b/release/scripts/freestyle/modules/parameter_editor.py
@@ -1538,16 +1538,9 @@ def process(layer_name, lineset_name):
raise RuntimeError("No Thickness modifier with type", type(m), m)
# -- Textures -- #
has_tex = False
- if scene.view_render.use_shading_nodes:
- if linestyle.use_nodes and linestyle.node_tree:
- shaders_list.append(BlenderTextureShader(linestyle.node_tree))
- has_tex = True
- else:
- if linestyle.use_texture:
- textures = tuple(BlenderTextureShader(slot) for slot in linestyle.texture_slots if slot is not None)
- if textures:
- shaders_list.extend(textures)
- has_tex = True
+ if linestyle.use_nodes and linestyle.node_tree:
+ shaders_list.append(BlenderTextureShader(linestyle.node_tree))
+ has_tex = True
if has_tex:
shaders_list.append(StrokeTextureStepShader(linestyle.texture_spacing))
diff --git a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
index 2ce8385f714..ad25283a3fc 100644
--- a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
+++ b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
@@ -589,7 +589,6 @@ class SpellChecker:
"yuv", "yuva",
# Blender acronyms
- "bge",
"bli",
"bpy",
"bvh",
diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py
index d3d9255123b..a549395597b 100644
--- a/release/scripts/modules/bpy/ops.py
+++ b/release/scripts/modules/bpy/ops.py
@@ -145,10 +145,10 @@ class BPyOpsSubModOp:
return C_dict, C_exec, C_undo
@staticmethod
- def _scene_update(context):
- scene = context.scene
- if scene: # None in background mode
- scene.update()
+ def _view_layer_update(context):
+ view_layer = context.view_layer
+ if view_layer: # None in background mode
+ view_layer.update()
else:
import bpy
for scene in bpy.data.scenes:
@@ -180,7 +180,10 @@ class BPyOpsSubModOp:
wm = context.window_manager
# run to account for any rna values the user changes.
- BPyOpsSubModOp._scene_update(context)
+ # NOTE: We only update active vew layer, since that's what
+ # operators are supposed to operate on. There might be some
+ # corner cases when operator need a full scene update though.
+ BPyOpsSubModOp._view_layer_update(context)
if args:
C_dict, C_exec, C_undo = BPyOpsSubModOp._parse_args(args)
@@ -189,7 +192,7 @@ class BPyOpsSubModOp:
ret = op_call(self.idname_py(), None, kw)
if 'FINISHED' in ret and context.window_manager == wm:
- BPyOpsSubModOp._scene_update(context)
+ BPyOpsSubModOp._view_layer_update(context)
return ret
diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py
index 9d206afb2c5..b0e4d65a3ce 100644
--- a/release/scripts/modules/bpy_extras/keyconfig_utils.py
+++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py
@@ -99,7 +99,6 @@ KM_HIERARCHY = [
('SequencerCommon', 'SEQUENCE_EDITOR', 'WINDOW', []),
('SequencerPreview', 'SEQUENCE_EDITOR', 'WINDOW', []),
]),
- ('Logic Editor', 'LOGIC_EDITOR', 'WINDOW', []),
('File Browser', 'FILE_BROWSER', 'WINDOW', [
('File Browser Main', 'FILE_BROWSER', 'WINDOW', []),
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 5387af46d9d..511fc7e8d1e 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -517,15 +517,6 @@ class Text(bpy_types.ID):
self.clear()
self.write(string)
- @property
- def users_logic(self):
- """Logic bricks that use this text"""
- import bpy
- return tuple(obj for obj in bpy.data.objects
- if self in [cont.text for cont in obj.game.controllers
- if cont.type == 'PYTHON']
- )
-
# values are module: [(cls, path, line), ...]
TypeMap = {}
diff --git a/release/scripts/presets/keyconfig/3dsmax.py b/release/scripts/presets/keyconfig/3dsmax.py
index a4288377b82..d65ecaa9204 100644
--- a/release/scripts/presets/keyconfig/3dsmax.py
+++ b/release/scripts/presets/keyconfig/3dsmax.py
@@ -33,9 +33,6 @@ kmi = km.keymap_items.new('wm.call_menu', 'NDOF_BUTTON_MENU', 'PRESS')
kmi.properties.name = 'USERPREF_MT_ndof_settings'
kmi = km.keymap_items.new('wm.context_set_enum', 'F2', 'PRESS', shift=True)
kmi.properties.data_path = 'area.type'
-kmi.properties.value = 'LOGIC_EDITOR'
-kmi = km.keymap_items.new('wm.context_set_enum', 'F3', 'PRESS', shift=True, ctrl=True)
-kmi.properties.data_path = 'area.type'
kmi.properties.value = 'NODE_EDITOR'
kmi = km.keymap_items.new('wm.context_set_enum', 'F4', 'PRESS', shift=True)
kmi.properties.data_path = 'area.type'
@@ -294,7 +291,6 @@ kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True)
kmi.properties.data_path = 'tool_settings.proportional_edit_falloff'
kmi = km.keymap_items.new('wm.context_toggle', 'O', 'PRESS')
kmi.properties.data_path = 'tool_settings.use_proportional_edit_objects'
-kmi = km.keymap_items.new('view3d.game_start', 'P', 'PRESS', shift=True, ctrl=True, alt=True)
kmi = km.keymap_items.new('object.select_all', 'A', 'PRESS', ctrl=True)
kmi.properties.action = 'INVERT'
kmi = km.keymap_items.new('object.select_linked', 'L', 'PRESS', shift=True)
@@ -2282,17 +2278,6 @@ kmi.properties.value_2 = 'CONNECTED'
# Map Armature
km = kc.keymaps.new('Armature', space_type='EMPTY', region_type='WINDOW', modal=False)
-kmi = km.keymap_items.new('sketch.delete', 'X', 'PRESS')
-kmi = km.keymap_items.new('sketch.delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('sketch.finish_stroke', 'RIGHTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('sketch.cancel_stroke', 'ESC', 'PRESS')
-kmi = km.keymap_items.new('sketch.gesture', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('sketch.draw_stroke', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('sketch.draw_stroke', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi.properties.snap = True
-kmi = km.keymap_items.new('sketch.draw_preview', 'MOUSEMOVE', 'ANY')
-kmi = km.keymap_items.new('sketch.draw_preview', 'MOUSEMOVE', 'ANY', ctrl=True)
-kmi.properties.snap = True
kmi = km.keymap_items.new('armature.hide', 'H', 'PRESS')
kmi.properties.unselected = False
kmi = km.keymap_items.new('armature.hide', 'H', 'PRESS', shift=True)
diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py
index 3075e0bd009..09371e75950 100644
--- a/release/scripts/presets/keyconfig/maya.py
+++ b/release/scripts/presets/keyconfig/maya.py
@@ -33,9 +33,6 @@ kmi = km.keymap_items.new('wm.call_menu', 'NDOF_BUTTON_MENU', 'PRESS')
kmi.properties.name = 'USERPREF_MT_ndof_settings'
kmi = km.keymap_items.new('wm.context_set_enum', 'F2', 'PRESS', shift=True)
kmi.properties.data_path = 'area.type'
-kmi.properties.value = 'LOGIC_EDITOR'
-kmi = km.keymap_items.new('wm.context_set_enum', 'F3', 'PRESS', shift=True)
-kmi.properties.data_path = 'area.type'
kmi.properties.value = 'NODE_EDITOR'
kmi = km.keymap_items.new('wm.context_set_enum', 'F4', 'PRESS', shift=True)
kmi.properties.data_path = 'area.type'
@@ -773,17 +770,6 @@ kmi.properties.value_2 = 'CONNECTED'
# Map Armature
km = kc.keymaps.new('Armature', space_type='EMPTY', region_type='WINDOW', modal=False)
-kmi = km.keymap_items.new('sketch.delete', 'BACK_SPACE', 'PRESS')
-kmi = km.keymap_items.new('sketch.delete', 'DEL', 'PRESS')
-kmi = km.keymap_items.new('sketch.finish_stroke', 'RIGHTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('sketch.cancel_stroke', 'ESC', 'PRESS')
-kmi = km.keymap_items.new('sketch.gesture', 'LEFTMOUSE', 'PRESS', shift=True)
-kmi = km.keymap_items.new('sketch.draw_stroke', 'LEFTMOUSE', 'PRESS')
-kmi = km.keymap_items.new('sketch.draw_stroke', 'LEFTMOUSE', 'PRESS', ctrl=True)
-kmi.properties.snap = True
-kmi = km.keymap_items.new('sketch.draw_preview', 'MOUSEMOVE', 'ANY')
-kmi = km.keymap_items.new('sketch.draw_preview', 'MOUSEMOVE', 'ANY', ctrl=True)
-kmi.properties.snap = True
kmi = km.keymap_items.new('armature.hide', 'H', 'PRESS', ctrl=True)
kmi.properties.unselected = False
kmi = km.keymap_items.new('armature.hide', 'H', 'PRESS', alt=True)
diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py
index 27cc118d99d..70334fb0f23 100644
--- a/release/scripts/startup/bl_operators/object_quick_effects.py
+++ b/release/scripts/startup/bl_operators/object_quick_effects.py
@@ -364,88 +364,38 @@ class QuickSmoke(Operator):
# Setup material
- # Cycles
- if context.scene.view_render.use_shading_nodes or context.view_render.use_shading_nodes:
- bpy.ops.object.material_slot_add()
-
- mat = bpy.data.materials.new("Smoke Domain Material")
- obj.material_slots[0].material = mat
-
- # Make sure we use nodes
- mat.use_nodes = True
-
- # Set node variables and clear the default nodes
- tree = mat.node_tree
- nodes = tree.nodes
- links = tree.links
-
- nodes.clear()
+ # Cycles and Eevee
+ bpy.ops.object.material_slot_add()
- # Create shader nodes
+ mat = bpy.data.materials.new("Smoke Domain Material")
+ obj.material_slots[0].material = mat
- # Material output
- node_out = nodes.new(type='ShaderNodeOutputMaterial')
- node_out.location = grid_location(6, 1)
+ # Make sure we use nodes
+ mat.use_nodes = True
- # Add Principled Volume
- node_principled = nodes.new(type='ShaderNodeVolumePrincipled')
- node_principled.location = grid_location(4, 1)
- links.new(node_principled.outputs["Volume"],
- node_out.inputs["Volume"])
+ # Set node variables and clear the default nodes
+ tree = mat.node_tree
+ nodes = tree.nodes
+ links = tree.links
- node_principled.inputs["Density"].default_value = 5.0
+ nodes.clear()
- if self.style in {'FIRE', 'BOTH'}:
- node_principled.inputs["Blackbody Intensity"].default_value = 1.0
+ # Create shader nodes
- # Blender Internal
- else:
- # create a volume material with a voxel data texture for the domain
- bpy.ops.object.material_slot_add()
-
- mat = bpy.data.materials.new("Smoke Domain Material")
- obj.material_slots[0].material = mat
- mat.type = 'VOLUME'
- mat.volume.density = 0
- mat.volume.density_scale = 5
- mat.volume.step_size = 0.1
-
- tex = bpy.data.textures.new("Smoke Density", 'VOXEL_DATA')
- tex.voxel_data.domain_object = obj
- tex.voxel_data.interpolation = 'TRICUBIC_BSPLINE'
-
- tex_slot = mat.texture_slots.add()
- tex_slot.texture = tex
- tex_slot.texture_coords = 'ORCO'
- tex_slot.use_map_color_emission = False
- tex_slot.use_map_density = True
- tex_slot.use_map_color_reflection = True
-
- # for fire add a second texture for flame emission
- mat.volume.emission_color = Vector((0.0, 0.0, 0.0))
- tex = bpy.data.textures.new("Flame", 'VOXEL_DATA')
- tex.voxel_data.domain_object = obj
- tex.voxel_data.smoke_data_type = 'SMOKEFLAME'
- tex.voxel_data.interpolation = 'TRICUBIC_BSPLINE'
- tex.use_color_ramp = True
+ # Material output
+ node_out = nodes.new(type='ShaderNodeOutputMaterial')
+ node_out.location = grid_location(6, 1)
- tex_slot = mat.texture_slots.add()
- tex_slot.texture = tex
- tex_slot.texture_coords = 'ORCO'
+ # Add Principled Volume
+ node_principled = nodes.new(type='ShaderNodeVolumePrincipled')
+ node_principled.location = grid_location(4, 1)
+ links.new(node_principled.outputs["Volume"],
+ node_out.inputs["Volume"])
- # add color ramp for flame color
- ramp = tex.color_ramp
- # dark orange
- elem = ramp.elements.new(0.333)
- elem.color = (0.2, 0.03, 0.0, 1.0)
+ node_principled.inputs["Density"].default_value = 5.0
- # yellow glow
- elem = ramp.elements.new(0.666)
- elem.color = (1, 0.65, 0.25, 1.0)
-
- mat.texture_slots[1].use_map_density = True
- mat.texture_slots[1].use_map_emission = True
- mat.texture_slots[1].emission_factor = 5
+ if self.style in {'FIRE', 'BOTH'}:
+ node_principled.inputs["Blackbody Intensity"].default_value = 1.0
return {'FINISHED'}
@@ -547,13 +497,33 @@ class QuickFluid(Operator):
mat = bpy.data.materials.new("Fluid Domain Material")
obj.material_slots[0].material = mat
- mat.specular_intensity = 1
- mat.specular_hardness = 100
- mat.use_transparency = True
- mat.alpha = 0.0
- mat.transparency_method = 'RAYTRACE'
- mat.raytrace_transparency.ior = 1.33
- mat.raytrace_transparency.depth = 4
+ # Make sure we use nodes
+ mat.use_nodes = True
+
+ # Set node variables and clear the default nodes
+ tree = mat.node_tree
+ nodes = tree.nodes
+ links = tree.links
+
+ nodes.clear()
+
+ # Create shader nodes
+
+ # Material output
+ node_out = nodes.new(type='ShaderNodeOutputMaterial')
+ node_out.location = grid_location(6, 1)
+
+ # Add Glass
+ node_glass = nodes.new(type='ShaderNodeBsdfGlass')
+ node_glass.location = grid_location(4, 1)
+ links.new(node_glass.outputs["BSDF"], node_out.inputs["Surface"])
+ node_glass.inputs["IOR"].default_value = 1.33
+
+ # Add Absorption
+ node_absorption = nodes.new(type='ShaderNodeVolumeAbsorption')
+ node_absorption.location = grid_location(4, 2)
+ links.new(node_absorption.outputs["Volume"], node_out.inputs["Volume"])
+ node_absorption.inputs["Color"].default_value = (0.8, 0.9, 1.0, 1.0)
if self.start_baking:
bpy.ops.fluid.bake('INVOKE_DEFAULT')
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index c696c38dac6..b06d054e15f 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -318,34 +318,6 @@ class AddPresetSafeAreas(AddPresetBase, Operator):
preset_subdir = "safe_areas"
-class AddPresetSSS(AddPresetBase, Operator):
- """Add or remove a Subsurface Scattering Preset"""
- bl_idname = "material.sss_preset_add"
- bl_label = "Add SSS Preset"
- preset_menu = "MATERIAL_MT_sss_presets"
-
- preset_defines = [
- ("material = "
- "bpy.context.material.active_node_material "
- "if bpy.context.material.active_node_material "
- "else bpy.context.material")
- ]
-
- preset_values = [
- "material.subsurface_scattering.back",
- "material.subsurface_scattering.color",
- "material.subsurface_scattering.color_factor",
- "material.subsurface_scattering.error_threshold",
- "material.subsurface_scattering.front",
- "material.subsurface_scattering.ior",
- "material.subsurface_scattering.radius",
- "material.subsurface_scattering.scale",
- "material.subsurface_scattering.texture_factor",
- ]
-
- preset_subdir = "sss"
-
-
class AddPresetCloth(AddPresetBase, Operator):
"""Add or remove a Cloth Preset"""
bl_idname = "cloth.preset_add"
@@ -695,7 +667,6 @@ classes = (
AddPresetNodeColor,
AddPresetOperator,
AddPresetRender,
- AddPresetSSS,
AddPresetSafeAreas,
AddPresetSunSky,
AddPresetTrackingCamera,
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 1bbb3e9883e..84857170f27 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -1089,6 +1089,11 @@ rna_use_soft_limits = BoolProperty(
name="Use Soft Limits",
)
+rna_is_overridable_static = BoolProperty(
+ name="Is Statically Overridable",
+ default=False,
+ )
+
class WM_OT_properties_edit(Operator):
bl_idname = "wm.properties_edit"
@@ -1102,6 +1107,7 @@ class WM_OT_properties_edit(Operator):
min = rna_min
max = rna_max
use_soft_limits = rna_use_soft_limits
+ is_overridable_static = rna_is_overridable_static
soft_min = rna_min
soft_max = rna_max
description = StringProperty(
@@ -1154,6 +1160,9 @@ class WM_OT_properties_edit(Operator):
# print(exec_str)
exec(exec_str)
+ exec_str = "item.property_overridable_static_set('[\"%s\"]', %s)" % (prop, self.is_overridable_static)
+ exec(exec_str)
+
rna_idprop_ui_prop_update(item, prop)
self._last_prop[:] = [prop]
@@ -1281,7 +1290,9 @@ class WM_OT_properties_edit(Operator):
row.prop(self, "min")
row.prop(self, "max")
- layout.prop(self, "use_soft_limits")
+ row = layout.row()
+ row.prop(self, "use_soft_limits")
+ row.prop(self, "is_overridable_static")
row = layout.row(align=True)
row.enabled = self.use_soft_limits
@@ -1492,54 +1503,6 @@ class WM_OT_copy_prev_settings(Operator):
return {'CANCELLED'}
-class WM_OT_blenderplayer_start(Operator):
- """Launch the blender-player with the current blend-file"""
- bl_idname = "wm.blenderplayer_start"
- bl_label = "Start Game In Player"
-
- def execute(self, context):
- import os
- import sys
- import subprocess
-
- gs = context.scene.game_settings
-
- # these remain the same every execution
- blender_bin_path = bpy.app.binary_path
- blender_bin_dir = os.path.dirname(blender_bin_path)
- ext = os.path.splitext(blender_bin_path)[-1]
- player_path = os.path.join(blender_bin_dir, "blenderplayer" + ext)
- # done static vars
-
- if sys.platform == "darwin":
- player_path = os.path.join(blender_bin_dir, "../../../blenderplayer.app/Contents/MacOS/blenderplayer")
-
- if not os.path.exists(player_path):
- self.report({'ERROR'}, "Player path: %r not found" % player_path)
- return {'CANCELLED'}
-
- filepath = bpy.data.filepath + '~' if bpy.data.is_saved else os.path.join(bpy.app.tempdir, "game.blend")
- bpy.ops.wm.save_as_mainfile('EXEC_DEFAULT', filepath=filepath, copy=True)
-
- # start the command line call with the player path
- args = [player_path]
-
- # 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),
- ])
-
- # finish the call with the path to the blend file
- args.append(filepath)
-
- subprocess.call(args)
- os.remove(filepath)
- return {'FINISHED'}
-
-
class WM_OT_keyconfig_test(Operator):
"""Test key-config for conflicts"""
bl_idname = "wm.keyconfig_test"
@@ -2375,7 +2338,6 @@ classes = (
WM_OT_app_template_install,
WM_OT_appconfig_activate,
WM_OT_appconfig_default,
- WM_OT_blenderplayer_start,
WM_OT_context_collection_boolean_set,
WM_OT_context_cycle_array,
WM_OT_context_cycle_enum,
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 62ce0712915..0728698baf4 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -44,7 +44,6 @@ _modules = [
"properties_data_lightprobe",
"properties_data_speaker",
"properties_data_workspace",
- "properties_game",
"properties_hair",
"properties_mask_common",
"properties_material",
@@ -80,7 +79,6 @@ _modules = [
"space_graph",
"space_image",
"space_info",
- "space_logic",
"space_nla",
"space_node",
"space_outliner",
@@ -88,6 +86,7 @@ _modules = [
"space_sequencer",
"space_text",
"space_time",
+ "space_topbar",
"space_userpref",
"space_view3d",
"space_view3d_toolbar",
diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index e48df3a0a61..2d032e7f95d 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -65,7 +65,7 @@ class COLLECTION_PT_clay_settings(CollectionButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- return context.view_render.engine in cls.COMPAT_ENGINES
+ return context.engine in cls.COMPAT_ENGINES
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py
index 413636d005b..12f862d92a1 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -65,11 +65,6 @@ class DATA_PT_skeleton(ArmatureButtonsPanel, Panel):
col.label(text="Protected Layers:")
col.prop(arm, "layers_protected", text="")
- if context.engine == 'BLENDER_GAME':
- col = layout.column()
- col.label(text="Deform:")
- col.prop(arm, "deform_method", expand=True)
-
class DATA_PT_display(ArmatureButtonsPanel, Panel):
bl_label = "Display"
@@ -328,7 +323,7 @@ class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from
class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object.data"
_property_type = bpy.types.Armature
diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py
index f0ef0032059..e1763e363ae 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -433,7 +433,7 @@ class BONE_PT_deform(BoneButtonsPanel, Panel):
class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_property_type = bpy.types.Bone, bpy.types.EditBone, bpy.types.PoseBone
@property
diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py
index 0d0fc96550d..58cbcec25ca 100644
--- a/release/scripts/startup/bl_ui/properties_data_camera.py
+++ b/release/scripts/startup/bl_ui/properties_data_camera.py
@@ -37,7 +37,7 @@ class CAMERA_MT_presets(Menu):
bl_label = "Camera Presets"
preset_subdir = "camera"
preset_operator = "script.execute_preset"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
draw = Menu.draw_preset
@@ -45,14 +45,14 @@ class SAFE_AREAS_MT_presets(Menu):
bl_label = "Camera Presets"
preset_subdir = "safe_areas"
preset_operator = "script.execute_preset"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
draw = Menu.draw_preset
class DATA_PT_context_camera(CameraButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -72,7 +72,7 @@ class DATA_PT_context_camera(CameraButtonsPanel, Panel):
class DATA_PT_lens(CameraButtonsPanel, Panel):
bl_label = "Lens"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -147,11 +147,11 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
- view_render = context.scene.view_render
+ render = context.scene.render
st = context.camera.stereo
cam = context.camera
- is_spherical_stereo = cam.type != 'ORTHO' and view_render.use_spherical_stereo
+ is_spherical_stereo = cam.type != 'ORTHO' and render.use_spherical_stereo
use_spherical_stereo = is_spherical_stereo and st.use_spherical_stereo
col = layout.column()
@@ -183,7 +183,7 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
class DATA_PT_camera(CameraButtonsPanel, Panel):
bl_label = "Camera"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -217,7 +217,7 @@ class DATA_PT_camera(CameraButtonsPanel, Panel):
class DATA_PT_camera_dof(CameraButtonsPanel, Panel):
bl_label = "Depth of Field"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -258,7 +258,7 @@ class DATA_PT_camera_dof(CameraButtonsPanel, Panel):
class DATA_PT_camera_background_image(CameraButtonsPanel, Panel):
bl_label = "Background Images"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw_header(self, context):
cam = context.camera
@@ -358,7 +358,7 @@ class DATA_PT_camera_background_image(CameraButtonsPanel, Panel):
class DATA_PT_camera_display(CameraButtonsPanel, Panel):
bl_label = "Display"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -388,7 +388,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, Panel):
class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel):
bl_label = "Safe Areas"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw_header(self, context):
cam = context.camera
@@ -404,7 +404,7 @@ class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel):
class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object.data"
_property_type = bpy.types.Camera
diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py
index 6fb147007e6..00edc6403f9 100644
--- a/release/scripts/startup/bl_ui/properties_data_curve.py
+++ b/release/scripts/startup/bl_ui/properties_data_curve.py
@@ -136,7 +136,7 @@ class DATA_PT_shape_curve(CurveButtonsPanel, Panel):
class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -427,7 +427,7 @@ class DATA_PT_text_boxes(CurveButtonsPanelText, Panel):
class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object.data"
_property_type = bpy.types.Curve
diff --git a/release/scripts/startup/bl_ui/properties_data_lamp.py b/release/scripts/startup/bl_ui/properties_data_lamp.py
index 9ee17d808cf..892ca26189d 100644
--- a/release/scripts/startup/bl_ui/properties_data_lamp.py
+++ b/release/scripts/startup/bl_ui/properties_data_lamp.py
@@ -26,7 +26,7 @@ class LAMP_MT_sunsky_presets(Menu):
bl_label = "Sun & Sky Presets"
preset_subdir = "sunsky"
preset_operator = "script.execute_preset"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
draw = Menu.draw_preset
@@ -44,7 +44,7 @@ class DataButtonsPanel:
class DATA_PT_context_lamp(DataButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -55,20 +55,15 @@ class DATA_PT_context_lamp(DataButtonsPanel, Panel):
split = layout.split(percentage=0.65)
- texture_count = len(lamp.texture_slots.keys())
-
if ob:
split.template_ID(ob, "data")
elif lamp:
split.template_ID(space, "pin_id")
- if texture_count != 0:
- split.label(text=str(texture_count), icon='TEXTURE')
-
class DATA_PT_preview(DataButtonsPanel, Panel):
bl_label = "Preview"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
self.layout.template_preview(context.lamp)
@@ -76,7 +71,7 @@ class DATA_PT_preview(DataButtonsPanel, Panel):
class DATA_PT_lamp(DataButtonsPanel, Panel):
bl_label = "Lamp"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY'}
def draw(self, context):
layout = self.layout
@@ -111,17 +106,11 @@ class DATA_PT_lamp(DataButtonsPanel, Panel):
sub.prop(lamp, "linear_coefficient", text="Linear")
sub.prop(lamp, "quadratic_coefficient", text="Quadratic")
- col.prop(lamp, "use_sphere")
-
if lamp.type == 'AREA':
col.prop(lamp, "distance")
- col.prop(lamp, "gamma")
col = split.column()
- col.prop(lamp, "use_negative")
- col.prop(lamp, "use_own_layer", text="This Layer Only")
- col.prop(lamp, "use_specular")
- col.prop(lamp, "use_diffuse")
+ col.label()
class DATA_PT_EEVEE_lamp(DataButtonsPanel, Panel):
@@ -154,202 +143,7 @@ class DATA_PT_EEVEE_lamp(DataButtonsPanel, Panel):
sub.prop(lamp, "size_y", text="Size Y")
col = split.column()
- col.prop(lamp, "use_specular")
- col.prop(lamp, "use_diffuse")
- col.separator()
-
- if lamp.type in {'POINT', 'SPOT', 'AREA'}:
- col.prop(lamp, "use_sphere")
- col = col.column()
- col.active = lamp.use_sphere
- col.prop(lamp, "distance")
-
-
-class DATA_PT_sunsky(DataButtonsPanel, Panel):
- bl_label = "Sky & Atmosphere"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- lamp = context.lamp
- engine = context.engine
- return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- lamp = context.lamp.sky
-
- row = layout.row(align=True)
- row.prop(lamp, "use_sky")
- row.menu("LAMP_MT_sunsky_presets", text=bpy.types.LAMP_MT_sunsky_presets.bl_label)
- row.operator("lamp.sunsky_preset_add", text="", icon='ZOOMIN')
- row.operator("lamp.sunsky_preset_add", text="", icon='ZOOMOUT').remove_active = True
-
- row = layout.row()
- row.active = lamp.use_sky or lamp.use_atmosphere
- row.prop(lamp, "atmosphere_turbidity", text="Turbidity")
-
- split = layout.split()
-
- col = split.column()
- col.active = lamp.use_sky
- col.label(text="Blending:")
- sub = col.column()
- sub.prop(lamp, "sky_blend_type", text="")
- sub.prop(lamp, "sky_blend", text="Factor")
-
- col.label(text="Color Space:")
- sub = col.column()
- sub.row().prop(lamp, "sky_color_space", expand=True)
- sub.prop(lamp, "sky_exposure", text="Exposure")
-
- col = split.column()
- col.active = lamp.use_sky
- col.label(text="Horizon:")
- sub = col.column()
- sub.prop(lamp, "horizon_brightness", text="Brightness")
- sub.prop(lamp, "spread", text="Spread")
-
- col.label(text="Sun:")
- sub = col.column()
- sub.prop(lamp, "sun_brightness", text="Brightness")
- sub.prop(lamp, "sun_size", text="Size")
- sub.prop(lamp, "backscattered_light", slider=True, text="Back Light")
-
- layout.separator()
-
- layout.prop(lamp, "use_atmosphere")
-
- split = layout.split()
-
- col = split.column()
- col.active = lamp.use_atmosphere
- col.label(text="Intensity:")
- col.prop(lamp, "sun_intensity", text="Sun")
- col.prop(lamp, "atmosphere_distance_factor", text="Distance")
-
- col = split.column()
- col.active = lamp.use_atmosphere
- col.label(text="Scattering:")
- sub = col.column(align=True)
- sub.prop(lamp, "atmosphere_inscattering", slider=True, text="Inscattering")
- sub.prop(lamp, "atmosphere_extinction", slider=True, text="Extinction")
-
-
-class DATA_PT_shadow(DataButtonsPanel, Panel):
- bl_label = "Shadow"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- lamp = context.lamp
- engine = context.engine
- return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- lamp = context.lamp
-
- layout.row().prop(lamp, "shadow_method", expand=True)
-
- if lamp.shadow_method == 'NOSHADOW' and lamp.type == 'AREA':
- split = layout.split()
-
- col = split.column()
- col.label(text="Form Factor Sampling:")
-
- sub = col.row(align=True)
-
- if lamp.shape == 'SQUARE':
- sub.prop(lamp, "shadow_ray_samples_x", text="Samples")
- elif lamp.shape == 'RECTANGLE':
- sub.prop(lamp, "shadow_ray_samples_x", text="Samples X")
- sub.prop(lamp, "shadow_ray_samples_y", text="Samples Y")
-
- if lamp.shadow_method != 'NOSHADOW':
- split = layout.split()
-
- col = split.column()
- col.prop(lamp, "shadow_color", text="")
-
- col = split.column()
- col.prop(lamp, "use_shadow_layer", text="This Layer Only")
- col.prop(lamp, "use_only_shadow")
-
- if lamp.shadow_method == 'RAY_SHADOW':
- split = layout.split()
-
- col = split.column()
- col.label(text="Sampling:")
-
- if lamp.type in {'POINT', 'SUN', 'SPOT'}:
- sub = col.row()
-
- sub.prop(lamp, "shadow_ray_samples", text="Samples")
- sub.prop(lamp, "shadow_soft_size", text="Soft Size")
-
- elif lamp.type == 'AREA':
- sub = col.row(align=True)
-
- if lamp.shape == 'SQUARE':
- sub.prop(lamp, "shadow_ray_samples_x", text="Samples")
- elif lamp.shape == 'RECTANGLE':
- sub.prop(lamp, "shadow_ray_samples_x", text="Samples X")
- sub.prop(lamp, "shadow_ray_samples_y", text="Samples Y")
-
- col.row().prop(lamp, "shadow_ray_sample_method", expand=True)
-
- if lamp.shadow_ray_sample_method == 'ADAPTIVE_QMC':
- layout.prop(lamp, "shadow_adaptive_threshold", text="Threshold")
-
- if lamp.type == 'AREA' and lamp.shadow_ray_sample_method == 'CONSTANT_JITTERED':
- row = layout.row()
- row.prop(lamp, "use_umbra")
- row.prop(lamp, "use_dither")
- row.prop(lamp, "use_jitter")
-
- elif lamp.shadow_method == 'BUFFER_SHADOW':
- col = layout.column()
- col.label(text="Buffer Type:")
- col.row().prop(lamp, "shadow_buffer_type", expand=True)
-
- if lamp.shadow_buffer_type in {'REGULAR', 'HALFWAY', 'DEEP'}:
- split = layout.split()
-
- col = split.column()
- col.label(text="Filter Type:")
- col.prop(lamp, "shadow_filter_type", text="")
- sub = col.column(align=True)
- sub.prop(lamp, "shadow_buffer_soft", text="Soft")
- sub.prop(lamp, "shadow_buffer_bias", text="Bias")
-
- col = split.column()
- col.label(text="Sample Buffers:")
- col.prop(lamp, "shadow_sample_buffers", text="")
- sub = col.column(align=True)
- sub.prop(lamp, "shadow_buffer_size", text="Size")
- sub.prop(lamp, "shadow_buffer_samples", text="Samples")
- if lamp.shadow_buffer_type == 'DEEP':
- col.prop(lamp, "compression_threshold")
-
- elif lamp.shadow_buffer_type == 'IRREGULAR':
- layout.prop(lamp, "shadow_buffer_bias", text="Bias")
-
- split = layout.split()
-
- col = split.column()
- col.prop(lamp, "use_auto_clip_start", text="Autoclip Start")
- sub = col.column()
- sub.active = not lamp.use_auto_clip_start
- sub.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
-
- col = split.column()
- col.prop(lamp, "use_auto_clip_end", text="Autoclip End")
- sub = col.column()
- sub.active = not lamp.use_auto_clip_end
- sub.prop(lamp, "shadow_buffer_clip_end", text="Clip End")
+ col.label()
class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
@@ -417,7 +211,7 @@ class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
class DATA_PT_area(DataButtonsPanel, Panel):
bl_label = "Area Shape"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY'}
@classmethod
def poll(cls, context):
@@ -443,7 +237,7 @@ class DATA_PT_area(DataButtonsPanel, Panel):
class DATA_PT_spot(DataButtonsPanel, Panel):
bl_label = "Spot Shape"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY'}
@classmethod
def poll(cls, context):
@@ -504,7 +298,7 @@ class DATA_PT_spot(DataButtonsPanel, Panel):
class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
bl_label = "Falloff Curve"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -520,7 +314,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object.data"
_property_type = bpy.types.Lamp
@@ -531,8 +325,6 @@ classes = (
DATA_PT_preview,
DATA_PT_lamp,
DATA_PT_EEVEE_lamp,
- DATA_PT_sunsky,
- DATA_PT_shadow,
DATA_PT_EEVEE_shadow,
DATA_PT_area,
DATA_PT_spot,
diff --git a/release/scripts/startup/bl_ui/properties_data_lattice.py b/release/scripts/startup/bl_ui/properties_data_lattice.py
index 34cb323a8cb..c309642e8bc 100644
--- a/release/scripts/startup/bl_ui/properties_data_lattice.py
+++ b/release/scripts/startup/bl_ui/properties_data_lattice.py
@@ -78,7 +78,7 @@ class DATA_PT_lattice(DataButtonsPanel, Panel):
class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object.data"
_property_type = bpy.types.Lattice
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 9f927fe3368..a9a47d268d2 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -24,7 +24,7 @@ from rna_prop_ui import PropertyPanel
class MESH_MT_vertex_group_specials(Menu):
bl_label = "Vertex Group Specials"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -48,7 +48,7 @@ class MESH_MT_vertex_group_specials(Menu):
class MESH_MT_shape_key_specials(Menu):
bl_label = "Shape Key Specials"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -137,7 +137,7 @@ class MeshButtonsPanel:
class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -154,7 +154,7 @@ class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
class DATA_PT_normals(MeshButtonsPanel, Panel):
bl_label = "Normals"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -175,7 +175,7 @@ class DATA_PT_normals(MeshButtonsPanel, Panel):
class DATA_PT_texture_space(MeshButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -194,7 +194,7 @@ class DATA_PT_texture_space(MeshButtonsPanel, Panel):
class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
bl_label = "Vertex Groups"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -241,7 +241,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
class DATA_PT_face_maps(MeshButtonsPanel, Panel):
bl_label = "Face Maps"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -282,7 +282,7 @@ class DATA_PT_face_maps(MeshButtonsPanel, Panel):
class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
bl_label = "Shape Keys"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -375,7 +375,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
bl_label = "UV Maps"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -394,7 +394,7 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
bl_label = "Vertex Colors"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -414,7 +414,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
class DATA_PT_customdata(MeshButtonsPanel, Panel):
bl_label = "Geometry Data"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -440,7 +440,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel):
class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object.data"
_property_type = bpy.types.Mesh
diff --git a/release/scripts/startup/bl_ui/properties_data_metaball.py b/release/scripts/startup/bl_ui/properties_data_metaball.py
index e771caf49e3..5095fac40ca 100644
--- a/release/scripts/startup/bl_ui/properties_data_metaball.py
+++ b/release/scripts/startup/bl_ui/properties_data_metaball.py
@@ -76,7 +76,7 @@ class DATA_PT_metaball(DataButtonsPanel, Panel):
class DATA_PT_mball_texture_space(DataButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -131,7 +131,7 @@ class DATA_PT_metaball_element(DataButtonsPanel, Panel):
class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object.data"
_property_type = bpy.types.MetaBall
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 940631d3524..99900915265 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -711,11 +711,15 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
def PARTICLE_INSTANCE(self, layout, ob, md):
layout.prop(md, "object")
- layout.prop(md, "particle_system_index", text="Particle System")
+ if md.object:
+ layout.prop_search(md, "particle_system", md.object, "particle_systems", text="Particle System")
+ else:
+ layout.prop(md, "particle_system_index", text="Particle System")
split = layout.split()
col = split.column()
col.label(text="Create From:")
+ layout.prop(md, "space", text="")
col.prop(md, "use_normal")
col.prop(md, "use_children")
col.prop(md, "use_size")
@@ -726,6 +730,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "show_unborn")
col.prop(md, "show_dead")
+ row = layout.row(align=True)
+ row.prop(md, "particle_amount", text="Amount")
+ row.prop(md, "particle_offset", text="Offset")
+
layout.separator()
layout.prop(md, "use_path", text="Create Along Paths")
@@ -737,8 +745,16 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "use_preserve_shape")
col = split.column()
- col.prop(md, "position", slider=True)
- col.prop(md, "random_position", text="Random", slider=True)
+ col2 = col.column(align=True)
+ col2.prop(md, "position", slider=True)
+ col2.prop(md, "random_position", text="Random", slider=True)
+ col2 = col.column(align=True)
+ col2.prop(md, "rotation", slider=True)
+ col2.prop(md, "random_rotation", text="Random", slider=True)
+
+ col = layout.column()
+ col.prop_search(md, "index_layer_name", ob.data, "vertex_colors", text="Index Layer")
+ col.prop_search(md, "value_layer_name", ob.data, "vertex_colors", text="Value Layer")
def PARTICLE_SYSTEM(self, layout, ob, md):
layout.label(text="Settings can be found inside the Particle context")
@@ -935,7 +951,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col = split.column()
scene = context.scene
- engine = scene.view_render.engine
+ engine = context.engine
show_adaptive_options = (
engine == 'CYCLES' and md == ob.modifiers[-1] and
scene.cycles.feature_set == 'EXPERIMENTAL'
@@ -998,17 +1014,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
def UV_PROJECT(self, layout, ob, md):
split = layout.split()
-
col = split.column()
- col.label(text="Image:")
- col.prop(md, "image", text="")
-
- col = split.column()
- col.label(text="UV Map:")
- col.prop_search(md, "uv_layer", ob.data, "uv_layers", text="")
+ col.prop_search(md, "uv_layer", ob.data, "uv_layers")
+ col.separator()
- split = layout.split()
- col = split.column()
col.prop(md, "projector_count", text="Projectors")
for proj in md.projectors:
col.prop(proj, "object", text="")
diff --git a/release/scripts/startup/bl_ui/properties_data_speaker.py b/release/scripts/startup/bl_ui/properties_data_speaker.py
index 769efb96b38..c317f906ba5 100644
--- a/release/scripts/startup/bl_ui/properties_data_speaker.py
+++ b/release/scripts/startup/bl_ui/properties_data_speaker.py
@@ -36,7 +36,7 @@ class DataButtonsPanel:
class DATA_PT_context_speaker(DataButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -117,7 +117,7 @@ class DATA_PT_cone(DataButtonsPanel, Panel):
class DATA_PT_custom_props_speaker(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object.data"
_property_type = bpy.types.Speaker
diff --git a/release/scripts/startup/bl_ui/properties_data_workspace.py b/release/scripts/startup/bl_ui/properties_data_workspace.py
index c699fac7dd2..e6ac4ab7477 100644
--- a/release/scripts/startup/bl_ui/properties_data_workspace.py
+++ b/release/scripts/startup/bl_ui/properties_data_workspace.py
@@ -51,15 +51,11 @@ class WORKSPACE_PT_workspace(WorkSpaceButtonsPanel, Panel):
window = context.window
workspace = context.workspace
scene = context.scene
- view_render = workspace.view_render
layout.enabled = not workspace.use_scene_settings
layout.template_search(window, "view_layer", scene, "view_layers")
- if view_render.has_multiple_engines:
- layout.prop(view_render, "engine", text="")
-
class WORKSPACE_PT_owner_ids(WorkSpaceButtonsPanel, Panel):
bl_label = "Workspace Add-ons"
diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py
index d9f28040b16..84ebb21c703 100644
--- a/release/scripts/startup/bl_ui/properties_freestyle.py
+++ b/release/scripts/startup/bl_ui/properties_freestyle.py
@@ -33,13 +33,13 @@ class RenderFreestyleButtonsPanel:
def poll(cls, context):
scene = context.scene
with_freestyle = bpy.app.build_options.freestyle
- return scene and with_freestyle and(scene.view_render.engine in cls.COMPAT_ENGINES)
+ return scene and with_freestyle and(context.engine in cls.COMPAT_ENGINES)
class RENDER_PT_freestyle(RenderFreestyleButtonsPanel, Panel):
bl_label = "Freestyle"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_header(self, context):
rd = context.scene.render
@@ -75,7 +75,7 @@ class ViewLayerFreestyleButtonsPanel:
with_freestyle = bpy.app.build_options.freestyle
return (scene and with_freestyle and rd.use_freestyle and
- scene.view_layers.active and(scene.view_render.engine in cls.COMPAT_ENGINES))
+ scene.view_layers.active and(context.engine in cls.COMPAT_ENGINES))
class ViewLayerFreestyleEditorButtonsPanel(ViewLayerFreestyleButtonsPanel):
@@ -111,7 +111,7 @@ class RENDER_MT_lineset_specials(Menu):
class VIEWLAYER_PT_freestyle(ViewLayerFreestyleButtonsPanel, Panel):
bl_label = "Freestyle"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -167,7 +167,7 @@ class VIEWLAYER_PT_freestyle(ViewLayerFreestyleButtonsPanel, Panel):
class VIEWLAYER_PT_freestyle_lineset(ViewLayerFreestyleEditorButtonsPanel, Panel):
bl_label = "Freestyle Line Set"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_edge_type_buttons(self, box, lineset, edge_type):
# property names
@@ -185,7 +185,6 @@ class VIEWLAYER_PT_freestyle_lineset(ViewLayerFreestyleEditorButtonsPanel, Panel
scene = context.scene
rd = scene.render
- view_render = scene.view_render
view_layer = scene.view_layers.active
freestyle = view_layer.freestyle_settings
@@ -262,7 +261,7 @@ class VIEWLAYER_PT_freestyle_lineset(ViewLayerFreestyleEditorButtonsPanel, Panel
class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Panel):
bl_label = "Freestyle Line Style"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_modifier_box_header(self, box, modifier):
row = box.row()
@@ -782,10 +781,7 @@ class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Pan
layout.separator()
row = layout.row()
- if view_render.use_shading_nodes:
- row.prop(linestyle, "use_nodes")
- else:
- row.prop(linestyle, "use_texture")
+ row.prop(linestyle, "use_nodes")
row.prop(linestyle, "texture_spacing", text="Spacing Along Stroke")
row = layout.row()
@@ -813,13 +809,13 @@ class MaterialFreestyleButtonsPanel:
material = context.material
with_freestyle = bpy.app.build_options.freestyle
return with_freestyle and material and scene and scene.render.use_freestyle and \
- (scene.view_render.engine in cls.COMPAT_ENGINES)
+ (context.engine in cls.COMPAT_ENGINES)
class MATERIAL_PT_freestyle_line(MaterialFreestyleButtonsPanel, Panel):
bl_label = "Freestyle Line"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py
deleted file mode 100644
index eb2d3d49e61..00000000000
--- a/release/scripts/startup/bl_ui/properties_game.py
+++ /dev/null
@@ -1,879 +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 #####
-
-# <pep8 compliant>
-import bpy
-from bpy.types import Panel, Menu
-
-
-class PhysicsButtonsPanel:
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "physics"
-
-
-class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel):
- bl_label = "Physics"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- ob = context.active_object
- view_render = context.scene.view_render
- return ob and ob.game and (view_render.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- ob = context.active_object
- game = ob.game
- soft = ob.game.soft_body
-
- layout.prop(game, "physics_type")
- layout.separator()
-
- physics_type = game.physics_type
-
- if physics_type == 'CHARACTER':
- layout.prop(game, "use_actor")
- layout.prop(ob, "hide_render", text="Invisible") # out of place but useful
- layout.prop(game, "step_height", slider=True)
- layout.prop(game, "jump_speed")
- layout.prop(game, "fall_speed")
- layout.prop(game, "jump_max")
-
- elif physics_type in {'DYNAMIC', 'RIGID_BODY'}:
- split = layout.split()
-
- col = split.column()
- col.prop(game, "use_actor")
- col.prop(game, "use_ghost")
- col.prop(ob, "hide_render", text="Invisible") # out of place but useful
-
- col = split.column()
- col.prop(game, "use_material_physics_fh")
- col.prop(game, "use_rotate_from_normal")
- col.prop(game, "use_sleep")
-
- layout.separator()
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Attributes:")
- col.prop(game, "mass")
- col.prop(game, "radius")
- col.prop(game, "form_factor")
-
- col = split.column()
- sub = col.column()
- sub.prop(game, "use_anisotropic_friction")
- subsub = sub.column()
- subsub.active = game.use_anisotropic_friction
- subsub.prop(game, "friction_coefficients", text="", slider=True)
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Linear Velocity:")
- sub = col.column(align=True)
- sub.prop(game, "velocity_min", text="Minimum")
- sub.prop(game, "velocity_max", text="Maximum")
- col.label(text="Angular Velocity:")
- sub = col.column(align=True)
- sub.prop(game, "angular_velocity_min", text="Minimum")
- sub.prop(game, "angular_velocity_max", text="Maximum")
-
- col = split.column()
- col.label(text="Damping:")
- sub = col.column(align=True)
- sub.prop(game, "damping", text="Translation", slider=True)
- sub.prop(game, "rotation_damping", text="Rotation", slider=True)
-
- layout.separator()
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Lock Translation:")
- col.prop(game, "lock_location_x", text="X")
- col.prop(game, "lock_location_y", text="Y")
- col.prop(game, "lock_location_z", text="Z")
-
- if physics_type == 'RIGID_BODY':
- col = split.column()
- col.label(text="Lock Rotation:")
- col.prop(game, "lock_rotation_x", text="X")
- col.prop(game, "lock_rotation_y", text="Y")
- col.prop(game, "lock_rotation_z", text="Z")
-
- elif physics_type == 'SOFT_BODY':
- col = layout.column()
- col.prop(game, "use_actor")
- col.prop(game, "use_ghost")
- col.prop(ob, "hide_render", text="Invisible")
-
- layout.separator()
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Attributes:")
- col.prop(game, "mass")
- # disabled in the code
- # col.prop(soft, "weld_threshold")
- col.prop(soft, "location_iterations")
- col.prop(soft, "linear_stiffness", slider=True)
- col.prop(soft, "dynamic_friction", slider=True)
- col.prop(soft, "collision_margin", slider=True)
- col.prop(soft, "use_bending_constraints", text="Bending Constraints")
-
- col = split.column()
- col.prop(soft, "use_shape_match")
- sub = col.column()
- sub.active = soft.use_shape_match
- sub.prop(soft, "shape_threshold", slider=True)
-
- col.separator()
-
- col.label(text="Cluster Collision:")
- col.prop(soft, "use_cluster_rigid_to_softbody")
- col.prop(soft, "use_cluster_soft_to_softbody")
- sub = col.column()
- sub.active = (soft.use_cluster_rigid_to_softbody or soft.use_cluster_soft_to_softbody)
- sub.prop(soft, "cluster_iterations", text="Iterations")
-
- elif physics_type == 'STATIC':
- col = layout.column()
- col.prop(game, "use_actor")
- col.prop(game, "use_ghost")
- col.prop(game, "use_record_animation")
- col.prop(ob, "hide_render", text="Invisible")
-
- layout.separator()
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Attributes:")
- col.prop(game, "radius")
-
- col = split.column()
- sub = col.column()
- sub.prop(game, "use_anisotropic_friction")
- subsub = sub.column()
- subsub.active = game.use_anisotropic_friction
- subsub.prop(game, "friction_coefficients", text="", slider=True)
-
- elif physics_type == 'SENSOR':
- col = layout.column()
- col.prop(game, "use_actor", text="Detect Actors")
- col.prop(ob, "hide_render", text="Invisible")
-
- elif physics_type in {'INVISIBLE', 'NO_COLLISION', 'OCCLUDER'}:
- layout.prop(ob, "hide_render", text="Invisible")
-
- elif physics_type == 'NAVMESH':
- layout.operator("mesh.navmesh_face_copy")
- layout.operator("mesh.navmesh_face_add")
-
- layout.separator()
-
- layout.operator("mesh.navmesh_reset")
- layout.operator("mesh.navmesh_clear")
-
-
-class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, Panel):
- bl_label = "Collision Bounds"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- game = context.object.game
- view_render = context.scene.view_render
- return (view_render.engine in cls.COMPAT_ENGINES) \
- and (game.physics_type in {'SENSOR', 'STATIC', 'DYNAMIC', 'RIGID_BODY', 'CHARACTER', 'SOFT_BODY'})
-
- def draw_header(self, context):
- game = context.active_object.game
-
- self.layout.prop(game, "use_collision_bounds", text="")
-
- def draw(self, context):
- layout = self.layout
-
- game = context.active_object.game
- split = layout.split()
- split.active = game.use_collision_bounds
-
- col = split.column()
- col.prop(game, "collision_bounds_type", text="Bounds")
-
- row = col.row()
- row.prop(game, "collision_margin", text="Margin", slider=True)
-
- sub = row.row()
- sub.active = game.physics_type not in {'SOFT_BODY', 'CHARACTER'}
- sub.prop(game, "use_collision_compound", text="Compound")
-
- layout.separator()
- split = layout.split()
- col = split.column()
- col.prop(game, "collision_group")
- col = split.column()
- col.prop(game, "collision_mask")
-
-
-class PHYSICS_PT_game_obstacles(PhysicsButtonsPanel, Panel):
- bl_label = "Create Obstacle"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- game = context.object.game
- view_render = context.scene.view_render
- return (view_render.engine in cls.COMPAT_ENGINES) \
- and (game.physics_type in {'SENSOR', 'STATIC', 'DYNAMIC', 'RIGID_BODY', 'SOFT_BODY', 'CHARACTER', 'NO_COLLISION'})
-
- def draw_header(self, context):
- game = context.active_object.game
-
- self.layout.prop(game, "use_obstacle_create", text="")
-
- def draw(self, context):
- layout = self.layout
-
- game = context.active_object.game
-
- layout.active = game.use_obstacle_create
-
- row = layout.row()
- row.prop(game, "obstacle_radius", text="Radius")
- row.label()
-
-
-class RenderButtonsPanel:
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "render"
-
- @classmethod
- def poll(cls, context):
- view_render = context.scene.view_render
- return (view_render.engine in cls.COMPAT_ENGINES)
-
-
-class RENDER_PT_embedded(RenderButtonsPanel, Panel):
- bl_label = "Embedded Player"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- view_render = context.scene.view_render
-
- row = layout.row()
- row.operator("view3d.game_start", text="Start")
- row = layout.row()
- row.label(text="Resolution:")
- row = layout.row(align=True)
- row.prop(rd, "resolution_x", slider=False, text="X")
- row.prop(rd, "resolution_y", slider=False, text="Y")
-
-
-class RENDER_PT_game_player(RenderButtonsPanel, Panel):
- bl_label = "Standalone Player"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- def draw(self, context):
- import sys
- layout = self.layout
- not_osx = sys.platform != "darwin"
-
- gs = context.scene.game_settings
-
- row = layout.row()
- row.operator("wm.blenderplayer_start", text="Start")
- row = layout.row()
- row.label(text="Resolution:")
- row = layout.row(align=True)
- row.active = not_osx or not gs.show_fullscreen
- row.prop(gs, "resolution_x", slider=False, text="X")
- row.prop(gs, "resolution_y", slider=False, text="Y")
- row = layout.row()
- col = row.column()
- col.prop(gs, "show_fullscreen")
-
- if not_osx:
- col = row.column()
- col.prop(gs, "use_desktop")
- col.active = gs.show_fullscreen
-
- col = layout.column()
- col.label(text="Quality:")
- col.prop(gs, "samples")
- col = layout.column(align=True)
- col.prop(gs, "depth", text="Bit Depth", slider=False)
- col.prop(gs, "frequency", text="Refresh Rate", slider=False)
-
-
-class RENDER_PT_game_stereo(RenderButtonsPanel, Panel):
- bl_label = "Stereo"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- gs = context.scene.game_settings
- stereo_mode = gs.stereo
-
- # stereo options:
- layout.row().prop(gs, "stereo", expand=True)
-
- # stereo:
- if stereo_mode == 'STEREO':
- layout.prop(gs, "stereo_mode")
- layout.prop(gs, "stereo_eye_separation")
-
- # dome:
- elif stereo_mode == 'DOME':
- layout.prop(gs, "dome_mode", text="Dome Type")
-
- dome_type = gs.dome_mode
-
- split = layout.split()
-
- if dome_type in {'FISHEYE', 'TRUNCATED_REAR', 'TRUNCATED_FRONT'}:
- col = split.column()
- col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True)
- col.prop(gs, "dome_angle", slider=True)
-
- col = split.column()
- col.prop(gs, "dome_tessellation", text="Tessellation")
- col.prop(gs, "dome_tilt")
-
- elif dome_type == 'PANORAM_SPH':
- col = split.column()
- col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True)
-
- col = split.column()
- col.prop(gs, "dome_tessellation", text="Tessellation")
-
- else: # cube map
- col = split.column()
- col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True)
-
- col = split.column()
-
- layout.prop(gs, "dome_text")
-
-
-class RENDER_PT_game_shading(RenderButtonsPanel, Panel):
- bl_label = "Shading"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- gs = context.scene.game_settings
-
- layout.row().prop(gs, "material_mode", expand=True)
-
- if gs.material_mode == 'GLSL':
- split = layout.split()
-
- col = split.column()
- col.prop(gs, "use_glsl_lights", text="Lights")
- col.prop(gs, "use_glsl_shaders", text="Shaders")
- col.prop(gs, "use_glsl_shadows", text="Shadows")
- col.prop(gs, "use_glsl_environment_lighting", text="Environment Lighting")
-
- col = split.column()
- col.prop(gs, "use_glsl_ramps", text="Ramps")
- col.prop(gs, "use_glsl_nodes", text="Nodes")
- col.prop(gs, "use_glsl_extra_textures", text="Extra Textures")
-
-
-class RENDER_PT_game_system(RenderButtonsPanel, Panel):
- bl_label = "System"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- gs = context.scene.game_settings
- col = layout.column()
- row = col.row()
- col = row.column()
- col.prop(gs, "use_frame_rate")
- col.prop(gs, "use_restrict_animation_updates")
- col = row.column()
- col.prop(gs, "use_material_caching")
-
- row = layout.row()
- row.prop(gs, "vsync")
-
- row = layout.row()
- row.prop(gs, "raster_storage")
-
- row = layout.row()
- row.label("Exit Key")
- row.prop(gs, "exit_key", text="", event=True)
-
-
-class RENDER_PT_game_display(RenderButtonsPanel, Panel):
- bl_label = "Display"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- gs = context.scene.game_settings
-
- layout.prop(context.scene.render, "fps", text="Animation Frame Rate", slider=False)
-
- flow = layout.column_flow()
- flow.prop(gs, "show_debug_properties", text="Debug Properties")
- flow.prop(gs, "show_framerate_profile", text="Framerate and Profile")
- flow.prop(gs, "show_physics_visualization", text="Physics Visualization")
- flow.prop(gs, "use_deprecation_warnings")
- flow.prop(gs, "show_mouse", text="Mouse Cursor")
-
- col = layout.column()
- col.label(text="Framing:")
- col.row().prop(gs, "frame_type", expand=True)
- if gs.frame_type == 'LETTERBOX':
- col.prop(gs, "frame_color", text="")
-
-
-class SceneButtonsPanel:
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "scene"
-
-
-class SCENE_PT_game_physics(SceneButtonsPanel, Panel):
- bl_label = "Physics"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- scene = context.scene
- return (scene.view_render.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- gs = context.scene.game_settings
-
- layout.prop(gs, "physics_engine", text="Engine")
- if gs.physics_engine != 'NONE':
- layout.prop(gs, "physics_gravity", text="Gravity")
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Physics Steps:")
- sub = col.column(align=True)
- sub.prop(gs, "physics_step_max", text="Max")
- sub.prop(gs, "physics_step_sub", text="Substeps")
- col.prop(gs, "fps", text="FPS")
-
- col = split.column()
- col.label(text="Logic Steps:")
- col.prop(gs, "logic_step_max", text="Max")
-
- col = layout.column()
- col.label(text="Physics Deactivation:")
- sub = col.row(align=True)
- sub.prop(gs, "deactivation_linear_threshold", text="Linear Threshold")
- sub.prop(gs, "deactivation_angular_threshold", text="Angular Threshold")
- sub = col.row()
- sub.prop(gs, "deactivation_time", text="Time")
-
- col = layout.column()
- col.prop(gs, "use_occlusion_culling", text="Occlusion Culling")
- sub = col.column()
- sub.active = gs.use_occlusion_culling
- sub.prop(gs, "occlusion_culling_resolution", text="Resolution")
-
- else:
- split = layout.split()
-
- col = split.column()
- col.label(text="Physics Steps:")
- col.prop(gs, "fps", text="FPS")
-
- col = split.column()
- col.label(text="Logic Steps:")
- col.prop(gs, "logic_step_max", text="Max")
-
-
-class SCENE_PT_game_physics_obstacles(SceneButtonsPanel, Panel):
- bl_label = "Obstacle Simulation"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- scene = context.scene
- return (scene.view_render.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- gs = context.scene.game_settings
-
- layout.prop(gs, "obstacle_simulation", text="Type")
- if gs.obstacle_simulation != 'NONE':
- layout.prop(gs, "level_height")
- layout.prop(gs, "show_obstacle_simulation")
-
-
-class SCENE_PT_game_navmesh(SceneButtonsPanel, Panel):
- bl_label = "Navigation Mesh"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- scene = context.scene
- return (scene and scene.view_render.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- rd = context.scene.game_settings.recast_data
-
- layout.operator("mesh.navmesh_make", text="Build Navigation Mesh")
-
- col = layout.column()
- col.label(text="Rasterization:")
- row = col.row()
- row.prop(rd, "cell_size")
- row.prop(rd, "cell_height")
-
- col = layout.column()
- col.label(text="Agent:")
- split = col.split()
-
- col = split.column()
- col.prop(rd, "agent_height", text="Height")
- col.prop(rd, "agent_radius", text="Radius")
-
- col = split.column()
- col.prop(rd, "slope_max")
- col.prop(rd, "climb_max")
-
- col = layout.column()
- col.label(text="Region:")
- row = col.row()
- row.prop(rd, "region_min_size")
- if rd.partitioning != 'LAYERS':
- row.prop(rd, "region_merge_size")
-
- col = layout.column()
- col.prop(rd, "partitioning")
-
- col = layout.column()
- col.label(text="Polygonization:")
- split = col.split()
-
- col = split.column()
- col.prop(rd, "edge_max_len")
- col.prop(rd, "edge_max_error")
-
- split.prop(rd, "verts_per_poly")
-
- col = layout.column()
- col.label(text="Detail Mesh:")
- row = col.row()
- row.prop(rd, "sample_dist")
- row.prop(rd, "sample_max_error")
-
-
-class SCENE_PT_game_hysteresis(SceneButtonsPanel, Panel):
- bl_label = "Level of Detail"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- scene = context.scene
- return (scene and scene.view_render.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
- gs = context.scene.game_settings
-
- row = layout.row()
- row.prop(gs, "use_scene_hysteresis", text="Hysteresis")
- row = layout.row()
- row.active = gs.use_scene_hysteresis
- row.prop(gs, "scene_hysteresis_percentage", text="")
-
-
-class WorldButtonsPanel:
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "world"
-
-
-class WORLD_PT_game_context_world(WorldButtonsPanel, Panel):
- bl_label = ""
- bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- view_render = context.scene.view_render
- return (context.scene) and (view_render.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- scene = context.scene
- world = context.world
- space = context.space_data
-
- split = layout.split(percentage=0.65)
- if scene:
- split.template_ID(scene, "world", new="world.new")
- elif world:
- split.template_ID(space, "pin_id")
-
-
-class WORLD_PT_game_world(WorldButtonsPanel, Panel):
- bl_label = "World"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- scene = context.scene
- return (scene.world and scene.view_render.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- world = context.world
-
- row = layout.row()
- row.column().prop(world, "horizon_color")
- row.column().prop(world, "zenith_color")
- row.column().prop(world, "ambient_color")
-
-
-class WORLD_PT_game_environment_lighting(WorldButtonsPanel, Panel):
- bl_label = "Environment Lighting"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- scene = context.scene
- return (scene.world and scene.view_render.engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- light = context.world.light_settings
- self.layout.prop(light, "use_environment_light", text="")
-
- def draw(self, context):
- layout = self.layout
-
- light = context.world.light_settings
-
- layout.active = light.use_environment_light
-
- split = layout.split()
- split.prop(light, "environment_energy", text="Energy")
- split.prop(light, "environment_color", text="")
-
-
-class WORLD_PT_game_mist(WorldButtonsPanel, Panel):
- bl_label = "Mist"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- scene = context.scene
- return (scene.world and scene.view_render.engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- world = context.world
-
- self.layout.prop(world.mist_settings, "use_mist", text="")
-
- def draw(self, context):
- layout = self.layout
-
- world = context.world
-
- layout.active = world.mist_settings.use_mist
-
- layout.prop(world.mist_settings, "falloff")
-
- row = layout.row(align=True)
- row.prop(world.mist_settings, "start")
- row.prop(world.mist_settings, "depth")
-
- layout.prop(world.mist_settings, "intensity", text="Minimum Intensity")
-
-
-class DataButtonsPanel:
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "data"
-
-
-class DATA_PT_shadow_game(DataButtonsPanel, Panel):
- bl_label = "Shadow"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- COMPAT_LIGHTS = {'SPOT', 'SUN'}
- lamp = context.lamp
- engine = context.engine
- return (lamp and lamp.type in COMPAT_LIGHTS) and (engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- lamp = context.lamp
-
- self.layout.prop(lamp, "use_shadow", text="")
-
- def draw(self, context):
- layout = self.layout
-
- lamp = context.lamp
-
- layout.active = lamp.use_shadow
-
- split = layout.split()
-
- col = split.column()
- col.prop(lamp, "shadow_color", text="")
- if lamp.type == 'SUN':
- col.prop(lamp, "show_shadow_box")
-
- col = split.column()
- col.prop(lamp, "use_shadow_layer", text="This Layer Only")
- col.prop(lamp, "use_only_shadow")
-
- col = layout.column()
- col.label("Buffer Type:")
- col.prop(lamp, "ge_shadow_buffer_type", text="", toggle=True)
- col.label("Quality:")
- col = layout.column(align=True)
- col.prop(lamp, "shadow_buffer_size", text="Size")
- col.prop(lamp, "shadow_buffer_bias", text="Bias")
- col.prop(lamp, "shadow_buffer_bleed_bias", text="Bleed Bias")
-
- row = layout.row()
- row.label("Clipping:")
- row = layout.row(align=True)
- row.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
- row.prop(lamp, "shadow_buffer_clip_end", text="Clip End")
-
- if lamp.type == 'SUN':
- row = layout.row()
- row.prop(lamp, "shadow_frustum_size", text="Frustum Size")
-
-
-class ObjectButtonsPanel:
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "object"
-
-
-class OBJECT_MT_lod_tools(Menu):
- bl_label = "Level Of Detail Tools"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator("object.lod_by_name", text="Set By Name")
- layout.operator("object.lod_generate", text="Generate")
- layout.operator("object.lod_clear_all", text="Clear All", icon='PANEL_CLOSE')
-
-
-class OBJECT_PT_levels_of_detail(ObjectButtonsPanel, Panel):
- bl_label = "Levels of Detail"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- return context.engine in cls.COMPAT_ENGINES
-
- def draw(self, context):
- layout = self.layout
- ob = context.object
- gs = context.scene.game_settings
-
- col = layout.column()
-
- for i, level in enumerate(ob.lod_levels):
- if i == 0:
- continue
- box = col.box()
- row = box.row()
- row.prop(level, "object", text="")
- row.operator("object.lod_remove", text="", icon='PANEL_CLOSE').index = i
-
- row = box.row()
- row.prop(level, "distance")
- row = row.row(align=True)
- row.prop(level, "use_mesh", text="")
- row.prop(level, "use_material", text="")
-
- row = box.row()
- row.active = gs.use_scene_hysteresis
- row.prop(level, "use_object_hysteresis", text="Hysteresis Override")
- row = box.row()
- row.active = gs.use_scene_hysteresis and level.use_object_hysteresis
- row.prop(level, "object_hysteresis_percentage", text="")
-
- row = col.row(align=True)
- row.operator("object.lod_add", text="Add", icon='ZOOMIN')
- row.menu("OBJECT_MT_lod_tools", text="", icon='TRIA_DOWN')
-
-
-classes = (
- PHYSICS_PT_game_physics,
- PHYSICS_PT_game_collision_bounds,
- PHYSICS_PT_game_obstacles,
- RENDER_PT_embedded,
- RENDER_PT_game_player,
- RENDER_PT_game_stereo,
- RENDER_PT_game_shading,
- RENDER_PT_game_system,
- RENDER_PT_game_display,
- SCENE_PT_game_physics,
- SCENE_PT_game_physics_obstacles,
- SCENE_PT_game_navmesh,
- SCENE_PT_game_hysteresis,
- WORLD_PT_game_context_world,
- WORLD_PT_game_world,
- WORLD_PT_game_environment_lighting,
- WORLD_PT_game_mist,
- DATA_PT_shadow_game,
- OBJECT_MT_lod_tools,
- OBJECT_PT_levels_of_detail,
-)
-
-if __name__ == "__main__": # only for live edit.
- from bpy.utils import register_class
- for cls in classes:
- register_class(cls)
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index edbe6816e5b..13c783ad024 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -23,42 +23,6 @@ from rna_prop_ui import PropertyPanel
from bpy.app.translations import pgettext_iface as iface_
from bpy_extras.node_utils import find_node_input, find_output_node
-def active_node_mat(mat):
- # TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
- # which settings from node-materials are used
- if mat is not None:
- mat_node = mat.active_node_material
- if mat_node:
- return mat_node
- else:
- return mat
-
- return None
-
-
-def check_material(mat):
- if mat is not None:
- if mat.use_nodes:
- if mat.active_node_material is not None:
- return True
- return False
- return True
- return False
-
-
-def simple_material(mat):
- if (mat is not None) and (not mat.use_nodes):
- return True
- return False
-
-
-class MATERIAL_MT_sss_presets(Menu):
- bl_label = "SSS Presets"
- preset_subdir = "sss"
- preset_operator = "script.execute_preset"
- draw = Menu.draw_preset
-
-
class MATERIAL_MT_specials(Menu):
bl_label = "Material Specials"
@@ -82,12 +46,6 @@ class MATERIAL_UL_matslots(UIList):
layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
else:
layout.label(text="", icon_value=icon)
- if ma and not context.view_render.use_shading_nodes:
- manode = ma.active_node_material
- if manode:
- layout.label(text=iface_("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode))
- elif ma.use_nodes:
- layout.label(text="Node <none>")
elif self.layout_type == 'GRID':
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
@@ -104,951 +62,16 @@ class MaterialButtonsPanel:
return context.material and (context.engine in cls.COMPAT_ENGINES)
-class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
- bl_label = ""
- bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- # An exception, don't call the parent poll func because
- # this manages materials for all engine types
-
- engine = context.engine
- return (context.material or context.object) and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- mat = context.material
- ob = context.object
- slot = context.material_slot
- space = context.space_data
-
- if ob:
- is_sortable = (len(ob.material_slots) > 1)
-
- rows = 1
- if is_sortable:
- rows = 4
-
- row = layout.row()
-
- row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
-
- col = row.column(align=True)
- col.operator("object.material_slot_add", icon='ZOOMIN', text="")
- col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
-
- col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
-
- if is_sortable:
- col.separator()
-
- col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
- col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
-
- if ob.mode == 'EDIT':
- row = layout.row(align=True)
- row.operator("object.material_slot_assign", text="Assign")
- row.operator("object.material_slot_select", text="Select")
- row.operator("object.material_slot_deselect", text="Deselect")
-
- split = layout.split(percentage=0.65)
-
- if ob:
- split.template_ID(ob, "active_material", new="material.new")
- row = split.row()
- if mat:
- row.prop(mat, "use_nodes", icon='NODETREE', text="")
-
- if slot:
- row.prop(slot, "link", text="")
- else:
- row.label()
- elif mat:
- split.template_ID(space, "pin_id")
- split.separator()
-
- if mat:
- layout.row().prop(mat, "type", expand=True)
- if mat.use_nodes:
- row = layout.row()
- row.label(text="", icon='NODETREE')
- if mat.active_node_material:
- row.prop(mat.active_node_material, "name", text="")
- else:
- row.label(text="No material node selected")
-
-
class MATERIAL_PT_preview(MaterialButtonsPanel, Panel):
bl_label = "Preview"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
def draw(self, context):
self.layout.template_preview(context.material)
-class MATERIAL_PT_pipeline(MaterialButtonsPanel, Panel):
- bl_label = "Render Pipeline Options"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return mat and (not simple_material(mat)) and (mat.type in {'SURFACE', 'WIRE', 'VOLUME'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self. layout
-
- mat = context.material
- mat_type = mat.type in {'SURFACE', 'WIRE'}
-
- row = layout.row()
- row.active = mat_type
- row.prop(mat, "use_transparency")
- sub = row.column()
- sub.prop(mat, "offset_z")
-
- sub.active = mat_type and mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY'
-
- row = layout.row()
- row.active = mat.use_transparency or not mat_type
- row.prop(mat, "transparency_method", expand=True)
-
- layout.separator()
-
- split = layout.split()
- col = split.column()
-
- col.prop(mat, "use_raytrace")
- col.prop(mat, "use_full_oversampling")
- sub = col.column()
- sub.active = mat_type
- sub.prop(mat, "use_sky")
- sub.prop(mat, "invert_z")
- col.prop(mat, "pass_index")
-
- col = split.column()
- col.active = mat_type
-
- col.prop(mat, "use_cast_shadows", text="Cast")
- col.prop(mat, "use_cast_shadows_only", text="Cast Only")
- col.prop(mat, "use_cast_buffer_shadows")
- sub = col.column()
- sub.active = mat.use_cast_buffer_shadows
- sub.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
- col.prop(mat, "use_cast_approximate")
-
-
-class MATERIAL_PT_diffuse(MaterialButtonsPanel, Panel):
- bl_label = "Diffuse"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- mat = active_node_mat(context.material)
-
- split = layout.split()
-
- col = split.column()
- col.prop(mat, "diffuse_color", text="")
- sub = col.column()
- sub.active = (not mat.use_shadeless)
- sub.prop(mat, "diffuse_intensity", text="Intensity")
-
- col = split.column()
- col.active = (not mat.use_shadeless)
- col.prop(mat, "diffuse_shader", text="")
- col.prop(mat, "use_diffuse_ramp", text="Ramp")
-
- col = layout.column()
- col.active = (not mat.use_shadeless)
- if mat.diffuse_shader == 'OREN_NAYAR':
- col.prop(mat, "roughness")
- elif mat.diffuse_shader == 'MINNAERT':
- col.prop(mat, "darkness")
- elif mat.diffuse_shader == 'TOON':
- row = col.row()
- row.prop(mat, "diffuse_toon_size", text="Size")
- row.prop(mat, "diffuse_toon_smooth", text="Smooth")
- elif mat.diffuse_shader == 'FRESNEL':
- row = col.row()
- row.prop(mat, "diffuse_fresnel", text="Fresnel")
- row.prop(mat, "diffuse_fresnel_factor", text="Factor")
-
- if mat.use_diffuse_ramp:
- col = layout.column()
- col.active = (not mat.use_shadeless)
- col.separator()
- col.template_color_ramp(mat, "diffuse_ramp", expand=True)
- col.separator()
-
- row = col.row()
- row.prop(mat, "diffuse_ramp_input", text="Input")
- row.prop(mat, "diffuse_ramp_blend", text="Blend")
-
- col.prop(mat, "diffuse_ramp_factor", text="Factor")
-
-
-class MATERIAL_PT_specular(MaterialButtonsPanel, Panel):
- bl_label = "Specular"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- mat = active_node_mat(context.material)
-
- layout.active = (not mat.use_shadeless)
-
- split = layout.split()
-
- col = split.column()
- col.prop(mat, "specular_color", text="")
- col.prop(mat, "specular_intensity", text="Intensity")
-
- col = split.column()
- col.prop(mat, "specular_shader", text="")
- col.prop(mat, "use_specular_ramp", text="Ramp")
-
- col = layout.column()
- if mat.specular_shader in {'COOKTORR', 'PHONG'}:
- col.prop(mat, "specular_hardness", text="Hardness")
- elif mat.specular_shader == 'BLINN':
- row = col.row()
- row.prop(mat, "specular_hardness", text="Hardness")
- row.prop(mat, "specular_ior", text="IOR")
- elif mat.specular_shader == 'WARDISO':
- col.prop(mat, "specular_slope", text="Slope")
- elif mat.specular_shader == 'TOON':
- row = col.row()
- row.prop(mat, "specular_toon_size", text="Size")
- row.prop(mat, "specular_toon_smooth", text="Smooth")
-
- if mat.use_specular_ramp:
- layout.separator()
- layout.template_color_ramp(mat, "specular_ramp", expand=True)
- layout.separator()
-
- row = layout.row()
- row.prop(mat, "specular_ramp_input", text="Input")
- row.prop(mat, "specular_ramp_blend", text="Blend")
-
- layout.prop(mat, "specular_ramp_factor", text="Factor")
-
-
-class MATERIAL_PT_shading(MaterialButtonsPanel, Panel):
- bl_label = "Shading"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- mat = active_node_mat(context.material)
-
- if mat.type in {'SURFACE', 'WIRE'}:
- split = layout.split()
-
- col = split.column()
- sub = col.column()
- sub.active = not mat.use_shadeless
- sub.prop(mat, "emit")
- sub.prop(mat, "ambient")
- sub = col.column()
- sub.prop(mat, "translucency")
-
- col = split.column()
- col.prop(mat, "use_shadeless")
- sub = col.column()
- sub.active = not mat.use_shadeless
- sub.prop(mat, "use_tangent_shading")
- sub.prop(mat, "use_cubic")
-
-
-class MATERIAL_PT_transp(MaterialButtonsPanel, Panel):
- bl_label = "Transparency"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- mat = context.material
-
- if simple_material(mat):
- self.layout.prop(mat, "use_transparency", text="")
-
- def draw(self, context):
- layout = self.layout
-
- base_mat = context.material
- mat = active_node_mat(context.material)
- rayt = mat.raytrace_transparency
-
- if simple_material(base_mat):
- row = layout.row()
- row.active = mat.use_transparency
- row.prop(mat, "transparency_method", expand=True)
-
- split = layout.split()
- split.active = base_mat.use_transparency
-
- col = split.column()
- col.prop(mat, "alpha")
- row = col.row()
- row.active = (base_mat.transparency_method != 'MASK') and (not mat.use_shadeless)
- row.prop(mat, "specular_alpha", text="Specular")
-
- col = split.column()
- col.active = (not mat.use_shadeless)
- col.prop(rayt, "fresnel")
- sub = col.column()
- sub.active = (rayt.fresnel > 0.0)
- sub.prop(rayt, "fresnel_factor", text="Blend")
-
- if base_mat.transparency_method == 'RAYTRACE':
- layout.separator()
- split = layout.split()
- split.active = base_mat.use_transparency
-
- col = split.column()
- col.prop(rayt, "ior")
- col.prop(rayt, "filter")
- col.prop(rayt, "falloff")
- col.prop(rayt, "depth_max")
- col.prop(rayt, "depth")
-
- col = split.column()
- col.label(text="Gloss:")
- col.prop(rayt, "gloss_factor", text="Amount")
- sub = col.column()
- sub.active = rayt.gloss_factor < 1.0
- sub.prop(rayt, "gloss_threshold", text="Threshold")
- sub.prop(rayt, "gloss_samples", text="Samples")
-
-
-class MATERIAL_PT_mirror(MaterialButtonsPanel, Panel):
- bl_label = "Mirror"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- raym = active_node_mat(context.material).raytrace_mirror
-
- self.layout.prop(raym, "use", text="")
-
- def draw(self, context):
- layout = self.layout
-
- mat = active_node_mat(context.material)
- raym = mat.raytrace_mirror
-
- layout.active = raym.use
-
- split = layout.split()
-
- col = split.column()
- col.prop(raym, "reflect_factor")
- col.prop(mat, "mirror_color", text="")
-
- col = split.column()
- col.prop(raym, "fresnel")
- sub = col.column()
- sub.active = (raym.fresnel > 0.0)
- sub.prop(raym, "fresnel_factor", text="Blend")
-
- split = layout.split()
-
- col = split.column()
- col.separator()
- col.prop(raym, "depth")
- col.prop(raym, "distance", text="Max Dist")
- col.separator()
- sub = col.split(percentage=0.4)
- sub.active = (raym.distance > 0.0)
- sub.label(text="Fade To:")
- sub.prop(raym, "fade_to", text="")
-
- col = split.column()
- col.label(text="Gloss:")
- col.prop(raym, "gloss_factor", text="Amount")
- sub = col.column()
- sub.active = (raym.gloss_factor < 1.0)
- sub.prop(raym, "gloss_threshold", text="Threshold")
- sub.prop(raym, "gloss_samples", text="Samples")
- sub.prop(raym, "gloss_anisotropic", text="Anisotropic")
-
-
-class MATERIAL_PT_sss(MaterialButtonsPanel, Panel):
- bl_label = "Subsurface Scattering"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- mat = active_node_mat(context.material)
- sss = mat.subsurface_scattering
-
- self.layout.active = (not mat.use_shadeless)
- self.layout.prop(sss, "use", text="")
-
- def draw(self, context):
- layout = self.layout
-
- mat = active_node_mat(context.material)
- sss = mat.subsurface_scattering
-
- layout.active = (sss.use) and (not mat.use_shadeless)
-
- row = layout.row().split()
- sub = row.row(align=True).split(align=True, percentage=0.75)
- sub.menu("MATERIAL_MT_sss_presets", text=bpy.types.MATERIAL_MT_sss_presets.bl_label)
- sub.operator("material.sss_preset_add", text="", icon='ZOOMIN')
- sub.operator("material.sss_preset_add", text="", icon='ZOOMOUT').remove_active = True
-
- split = layout.split()
-
- col = split.column()
- col.prop(sss, "ior")
- col.prop(sss, "scale")
- col.prop(sss, "color", text="")
- col.prop(sss, "radius", text="RGB Radius", expand=True)
-
- col = split.column()
- sub = col.column(align=True)
- sub.label(text="Blend:")
- sub.prop(sss, "color_factor", text="Color")
- sub.prop(sss, "texture_factor", text="Texture")
- sub.label(text="Scattering Weight:")
- sub.prop(sss, "front")
- sub.prop(sss, "back")
- col.separator()
- col.prop(sss, "error_threshold", text="Error")
-
-
-class MATERIAL_PT_halo(MaterialButtonsPanel, Panel):
- bl_label = "Halo"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- mat = context.material # don't use node material
- halo = mat.halo
-
- def number_but(layout, toggle, number, name, color):
- row = layout.row(align=True)
- row.prop(halo, toggle, text="")
- sub = row.column(align=True)
- sub.active = getattr(halo, toggle)
- sub.prop(halo, number, text=name, translate=False)
- if not color == "":
- sub.prop(mat, color, text="")
-
- split = layout.split()
-
- col = split.column()
- col.prop(mat, "alpha")
- col.prop(mat, "diffuse_color", text="")
- col.prop(halo, "seed")
-
- col = split.column()
- col.prop(halo, "size")
- col.prop(halo, "hardness")
- col.prop(halo, "add")
-
- layout.label(text="Options:")
-
- split = layout.split()
- col = split.column()
- col.prop(halo, "use_texture")
- col.prop(halo, "use_vertex_normal")
- col.prop(halo, "use_extreme_alpha")
- col.prop(halo, "use_shaded")
- col.prop(halo, "use_soft")
-
- col = split.column()
- number_but(col, "use_ring", "ring_count", iface_("Rings"), "mirror_color")
- number_but(col, "use_lines", "line_count", iface_("Lines"), "specular_color")
- number_but(col, "use_star", "star_tip_count", iface_("Star Tips"), "")
-
-
-class MATERIAL_PT_flare(MaterialButtonsPanel, Panel):
- bl_label = "Flare"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- halo = context.material.halo
-
- self.layout.prop(halo, "use_flare_mode", text="")
-
- def draw(self, context):
- layout = self.layout
-
- mat = context.material # don't use node material
- halo = mat.halo
-
- layout.active = halo.use_flare_mode
-
- split = layout.split()
-
- col = split.column()
- col.prop(halo, "flare_size", text="Size")
- col.prop(halo, "flare_boost", text="Boost")
- col.prop(halo, "flare_seed", text="Seed")
-
- col = split.column()
- col.prop(halo, "flare_subflare_count", text="Subflares")
- col.prop(halo, "flare_subflare_size", text="Subsize")
-
-
-class MATERIAL_PT_game_settings(MaterialButtonsPanel, Panel):
- bl_label = "Game Settings"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- return context.material and (context.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
- game = context.material.game_settings # don't use node material
-
- row = layout.row()
- row.prop(game, "use_backface_culling")
- row.prop(game, "invisible")
- row.prop(game, "text")
-
- row = layout.row()
- row.label(text="Alpha Blend:")
- row.label(text="Face Orientation:")
- row = layout.row()
- row.prop(game, "alpha_blend", text="")
- row.prop(game, "face_orientation", text="")
-
-
-class MATERIAL_PT_physics(MaterialButtonsPanel, Panel):
- bl_label = "Physics"
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- def draw_header(self, context):
- game = context.material.game_settings
- self.layout.prop(game, "physics", text="")
-
- @classmethod
- def poll(cls, context):
- return context.material and (context.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
- layout.active = context.material.game_settings.physics
-
- phys = context.material.physics # don't use node material
-
- split = layout.split()
- row = split.row()
- row.prop(phys, "friction")
- row.prop(phys, "elasticity", slider=True)
-
- row = layout.row()
- row.label(text="Force Field:")
-
- row = layout.row()
- row.prop(phys, "fh_force")
- row.prop(phys, "fh_damping", slider=True)
-
- row = layout.row()
- row.prop(phys, "fh_distance")
- row.prop(phys, "use_fh_normal")
-
-
-class MATERIAL_PT_strand(MaterialButtonsPanel, Panel):
- bl_label = "Strand"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return mat and (mat.type in {'SURFACE', 'WIRE', 'HALO'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- mat = context.material # don't use node material
- tan = mat.strand
-
- split = layout.split()
-
- col = split.column()
- sub = col.column(align=True)
- sub.label(text="Size:")
- sub.prop(tan, "root_size", text="Root")
- sub.prop(tan, "tip_size", text="Tip")
- sub.prop(tan, "size_min", text="Minimum")
- sub.prop(tan, "use_blender_units")
- sub = col.column()
- sub.active = (not mat.use_shadeless)
- sub.prop(tan, "use_tangent_shading")
- col.prop(tan, "shape")
-
- col = split.column()
- col.label(text="Shading:")
- col.prop(tan, "width_fade")
- ob = context.object
- if ob and ob.type == 'MESH':
- col.prop_search(tan, "uv_layer", ob.data, "uv_layers", text="")
- else:
- col.prop(tan, "uv_layer", text="")
- col.separator()
- sub = col.column()
- sub.active = (not mat.use_shadeless)
- sub.label("Surface diffuse:")
- sub = col.column()
- sub.prop(tan, "blend_distance", text="Distance")
-
-
-class MATERIAL_PT_options(MaterialButtonsPanel, Panel):
- bl_label = "Options"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- base_mat = context.material
- mat = active_node_mat(base_mat)
-
- split = layout.split()
-
- col = split.column()
- if simple_material(base_mat):
- col.prop(mat, "use_raytrace")
- col.prop(mat, "use_full_oversampling")
- col.prop(mat, "use_sky")
- col.prop(mat, "use_mist")
- if simple_material(base_mat):
- col.prop(mat, "invert_z")
- sub = col.row()
- sub.prop(mat, "offset_z")
- sub.active = mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY'
- sub = col.column(align=True)
- sub.label(text="Light Group:")
- sub.prop(mat, "light_group", text="")
- row = sub.row(align=True)
- row.active = bool(mat.light_group)
- row.prop(mat, "use_light_group_exclusive", text="Exclusive")
- row.prop(mat, "use_light_group_local", text="Local")
-
- col = split.column()
- col.prop(mat, "use_vertex_color_paint")
- col.prop(mat, "use_vertex_color_light")
- col.prop(mat, "use_object_color")
- col.prop(mat, "use_uv_project")
- if simple_material(base_mat):
- col.prop(mat, "pass_index")
-
- col.label("Edit Image")
- col.template_ID(mat, "edit_image")
-
-
-class MATERIAL_PT_shadow(MaterialButtonsPanel, Panel):
- bl_label = "Shadow"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- base_mat = context.material
- mat = active_node_mat(base_mat)
-
- split = layout.split()
-
- col = split.column()
- col.prop(mat, "use_shadows", text="Receive")
- col.prop(mat, "use_transparent_shadows", text="Receive Transparent")
- col.prop(mat, "use_only_shadow", text="Shadows Only")
- sub = col.column()
- sub.active = mat.use_only_shadow
- sub.prop(mat, "shadow_only_type", text="")
-
- if not simple_material(base_mat):
- col = split.column()
-
- col.prop(mat, "use_ray_shadow_bias", text="Auto Ray Bias")
- sub = col.column()
- sub.active = (not mat.use_ray_shadow_bias)
- sub.prop(mat, "shadow_ray_bias", text="Ray Bias")
-
- if simple_material(base_mat):
- col = split.column()
-
- col.prop(mat, "use_cast_shadows", text="Cast")
- col.prop(mat, "use_cast_shadows_only", text="Cast Only")
- col.prop(mat, "use_cast_buffer_shadows")
- sub = col.column()
- sub.active = mat.use_cast_buffer_shadows
- if simple_material(base_mat):
- sub.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
- sub.prop(mat, "shadow_buffer_bias", text="Buffer Bias")
- if simple_material(base_mat):
- col.prop(mat, "use_cast_approximate")
-
-
-class MATERIAL_PT_transp_game(MaterialButtonsPanel, Panel):
- bl_label = "Transparency"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- mat = context.material
-
- if simple_material(mat):
- self.layout.prop(mat, "use_transparency", text="")
-
- def draw(self, context):
- layout = self.layout
- base_mat = context.material
- mat = active_node_mat(base_mat)
-
- layout.active = mat.use_transparency
-
- if simple_material(base_mat):
- row = layout.row()
- row.prop(mat, "transparency_method", expand=True)
-
- layout.prop(mat, "alpha")
- layout.prop(mat, "specular_alpha", text="Specular")
-
-
-class VolumeButtonsPanel:
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "material"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return mat and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
-
-
-class MATERIAL_PT_volume_density(VolumeButtonsPanel, Panel):
- bl_label = "Density"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw(self, context):
- layout = self.layout
-
- vol = context.material.volume # don't use node material
-
- row = layout.row()
- row.prop(vol, "density")
- row.prop(vol, "density_scale")
-
-
-class MATERIAL_PT_volume_shading(VolumeButtonsPanel, Panel):
- bl_label = "Shading"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw(self, context):
- layout = self.layout
-
- vol = context.material.volume # don't use node material
-
- split = layout.split()
-
- col = split.column()
- col.prop(vol, "scattering")
- col.prop(vol, "asymmetry")
- col.prop(vol, "transmission_color")
-
- col = split.column()
- sub = col.column(align=True)
- sub.prop(vol, "emission")
- sub.prop(vol, "emission_color", text="")
- sub = col.column(align=True)
- sub.prop(vol, "reflection")
- sub.prop(vol, "reflection_color", text="")
-
-
-class MATERIAL_PT_volume_lighting(VolumeButtonsPanel, Panel):
- bl_label = "Lighting"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw(self, context):
- layout = self.layout
-
- vol = context.material.volume # don't use node material
-
- split = layout.split()
-
- col = split.column()
- col.prop(vol, "light_method", text="")
-
- col = split.column()
-
- if vol.light_method == 'SHADED':
- col.prop(vol, "use_external_shadows")
- col.prop(vol, "use_light_cache")
- sub = col.column()
- sub.active = vol.use_light_cache
- sub.prop(vol, "cache_resolution")
- elif vol.light_method in {'MULTIPLE_SCATTERING', 'SHADED_PLUS_MULTIPLE_SCATTERING'}:
- sub = col.column()
- sub.enabled = True
- sub.active = False
- sub.label("Light Cache Enabled")
- col.prop(vol, "cache_resolution")
-
- sub = col.column(align=True)
- sub.prop(vol, "ms_diffusion")
- sub.prop(vol, "ms_spread")
- sub.prop(vol, "ms_intensity")
-
-
-class MATERIAL_PT_volume_transp(VolumeButtonsPanel, Panel):
- bl_label = "Transparency"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return mat and simple_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- mat = context.material # don't use node material
-
- layout.row().prop(mat, "transparency_method", expand=True)
-
-
-class MATERIAL_PT_volume_integration(VolumeButtonsPanel, Panel):
- bl_label = "Integration"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw(self, context):
- layout = self.layout
-
- vol = context.material.volume # don't use node material
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Step Calculation:")
- col.prop(vol, "step_method", text="")
- col = col.column(align=True)
- col.prop(vol, "step_size")
-
- col = split.column()
- col.label()
- col.prop(vol, "depth_threshold")
-
-
-class MATERIAL_PT_volume_options(VolumeButtonsPanel, Panel):
- bl_label = "Options"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
- bl_options = {'DEFAULT_CLOSED'}
-
- @classmethod
- def poll(cls, context):
- mat = context.material
- engine = context.engine
- return check_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- layout = self.layout
-
- mat = active_node_mat(context.material)
-
- split = layout.split()
-
- col = split.column()
- if simple_material(context.material):
- col.prop(mat, "use_raytrace")
- col.prop(mat, "use_full_oversampling")
- col.prop(mat, "use_mist")
-
- col = split.column()
- col.label(text="Light Group:")
- col.prop(mat, "light_group", text="")
- row = col.row()
- row.active = bool(mat.light_group)
- row.prop(mat, "use_light_group_exclusive", text="Exclusive")
-
-
class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
_context_path = "material"
_property_type = bpy.types.Material
@@ -1193,32 +216,9 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
classes = (
- MATERIAL_MT_sss_presets,
MATERIAL_MT_specials,
MATERIAL_UL_matslots,
- MATERIAL_PT_context_material,
MATERIAL_PT_preview,
- MATERIAL_PT_pipeline,
- MATERIAL_PT_diffuse,
- MATERIAL_PT_specular,
- MATERIAL_PT_shading,
- MATERIAL_PT_transp,
- MATERIAL_PT_mirror,
- MATERIAL_PT_sss,
- MATERIAL_PT_halo,
- MATERIAL_PT_flare,
- MATERIAL_PT_game_settings,
- MATERIAL_PT_physics,
- MATERIAL_PT_strand,
- MATERIAL_PT_options,
- MATERIAL_PT_shadow,
- MATERIAL_PT_transp_game,
- MATERIAL_PT_volume_density,
- MATERIAL_PT_volume_shading,
- MATERIAL_PT_volume_lighting,
- MATERIAL_PT_volume_transp,
- MATERIAL_PT_volume_integration,
- MATERIAL_PT_volume_options,
MATERIAL_PT_custom_props,
EEVEE_MATERIAL_PT_context_material,
EEVEE_MATERIAL_PT_surface,
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index c6899eec408..2d2ab4623e0 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -161,11 +161,10 @@ class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
split = layout.split()
- if context.engine != 'BLENDER_GAME':
- col = split.column()
- col.label(text="Tracking Axes:")
- col.prop(ob, "track_axis", text="Axis")
- col.prop(ob, "up_axis", text="Up Axis")
+ col = split.column()
+ col.label(text="Tracking Axes:")
+ col.prop(ob, "track_axis", text="Axis")
+ col.prop(ob, "up_axis", text="Up Axis")
col = split.column()
col.prop(ob, "use_slow_parent")
@@ -359,7 +358,7 @@ class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit fr
class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object"
_property_type = bpy.types.Object
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index fcfaf29521b..b6f7cfe3e84 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -66,7 +66,7 @@ def particle_get_settings(context):
class PARTICLE_MT_specials(Menu):
bl_label = "Particle Specials"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -86,7 +86,7 @@ class PARTICLE_MT_hair_dynamics_presets(Menu):
bl_label = "Hair Dynamics Presets"
preset_subdir = "hair_dynamics"
preset_operator = "script.execute_preset"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
draw = Menu.draw_preset
@@ -131,7 +131,7 @@ class PARTICLE_UL_particle_systems(bpy.types.UIList):
class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -141,10 +141,6 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
- if context.engine == 'BLENDER_GAME':
- layout.label("Not available in the Game Engine")
- return
-
ob = context.object
psys = context.particle_system
part = 0
@@ -1400,6 +1396,38 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
# row.prop(psys, "invert_vertex_group_field", text="")
+class PARTICLE_PT_textures(ParticleButtonsPanel, Panel):
+ bl_label = "Textures"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ if context.particle_system is None:
+ return False
+ return particle_panel_poll(cls, context)
+
+ def draw(self, context):
+ layout = self.layout
+
+ psys = context.particle_system
+ part = psys.settings
+
+ row = layout.row()
+ row.template_list("TEXTURE_UL_texslots", "", part, "texture_slots", part, "active_texture_index", rows=2)
+
+ col = row.column(align=True)
+ col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
+ col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
+ col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
+
+ if not part.active_texture:
+ layout.template_ID(part, "active_texture", new="texture.new")
+ else:
+ slot = part.texture_slots[part.active_texture_index]
+ layout.template_ID(slot, "texture", new="texture.new")
+
+
class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "particle_system.settings"
@@ -1424,6 +1452,7 @@ classes = (
PARTICLE_PT_field_weights,
PARTICLE_PT_force_fields,
PARTICLE_PT_vertexgroups,
+ PARTICLE_PT_textures,
PARTICLE_PT_custom_props,
)
diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index 351418c9d23..e0d0327324b 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -45,13 +45,12 @@ class PhysicButtonsPanel:
@classmethod
def poll(cls, context):
ob = context.object
- view_render = context.scene.view_render
- return (ob and ob.type == 'MESH') and (view_render.engine in cls.COMPAT_ENGINES) and (context.cloth)
+ return (ob and ob.type == 'MESH') and (context.engine in cls.COMPAT_ENGINES) and (context.cloth)
class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
bl_label = "Cloth"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -135,7 +134,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
bl_label = "Cloth Cache"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
md = context.cloth
@@ -145,7 +144,7 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
bl_label = "Cloth Collision"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_header(self, context):
cloth = context.cloth.collision_settings
@@ -185,7 +184,7 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
bl_label = "Cloth Stiffness Scaling"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_header(self, context):
cloth = context.cloth.settings
@@ -218,7 +217,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
class PHYSICS_PT_cloth_sewing(PhysicButtonsPanel, Panel):
bl_label = "Cloth Sewing Springs"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_header(self, context):
cloth = context.cloth.settings
@@ -252,7 +251,7 @@ class PHYSICS_PT_cloth_sewing(PhysicButtonsPanel, Panel):
class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Cloth Field Weights"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
cloth = context.cloth.settings
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index 15c8bd68d10..3615f8be48c 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -30,8 +30,7 @@ class PhysicButtonsPanel:
@classmethod
def poll(cls, context):
- view_render = context.scene.view_render
- return (context.object) and view_render.engine in cls.COMPAT_ENGINES
+ return (context.object) and context.engine in cls.COMPAT_ENGINES
def physics_add(self, layout, md, name, type, typeicon, toggles):
diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index 7fc1c01279d..476a448f978 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -55,13 +55,12 @@ class PhysicButtonsPanel:
@classmethod
def poll(cls, context):
ob = context.object
- view_render = context.scene.view_render
- return (ob and ob.type == 'MESH') and view_render.engine in cls.COMPAT_ENGINES and context.dynamic_paint
+ return (ob and ob.type == 'MESH') and context.engine in cls.COMPAT_ENGINES and context.dynamic_paint
class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -109,7 +108,6 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
elif md.ui_type == 'BRUSH':
brush = md.brush_settings
- use_shading_nodes = context.view_render.use_shading_nodes
if brush is None:
layout.operator("dpaint.type_toggle", text="Add Brush").type = 'BRUSH'
@@ -124,27 +122,18 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
col.prop(brush, "paint_wetness", text="Wetness")
col = split.column()
- if not use_shading_nodes:
- sub = col.column()
- sub.active = (brush.paint_source != 'PARTICLE_SYSTEM')
- sub.prop(brush, "use_material")
- if brush.use_material and brush.paint_source != 'PARTICLE_SYSTEM' and not use_shading_nodes:
- col.prop(brush, "material", text="")
- col.prop(brush, "paint_alpha", text="Alpha Factor")
- else:
- col.prop(brush, "paint_color", text="")
- col.prop(brush, "paint_alpha", text="Alpha")
+ col.prop(brush, "paint_color", text="")
+ col.prop(brush, "paint_alpha", text="Alpha")
class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint Advanced"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
- view_render = context.scene.view_render
- return md and md.ui_type == 'CANVAS' and md.canvas_settings and md.canvas_settings.canvas_surfaces.active and view_render.engine in cls.COMPAT_ENGINES
+ return md and md.ui_type == 'CANVAS' and md.canvas_settings and md.canvas_settings.canvas_surfaces.active and context.engine in cls.COMPAT_ENGINES
def draw(self, context):
layout = self.layout
@@ -215,18 +204,17 @@ class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint Output"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
- view_render = context.scene.view_render
if not (md and md.ui_type == 'CANVAS' and md.canvas_settings):
return 0
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
return (surface and
(not (surface.surface_format == 'VERTEX' and (surface.surface_type in {'DISPLACE', 'WAVE'}))) and
- (view_render.engine in cls.COMPAT_ENGINES))
+ (context.engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
@@ -309,16 +297,15 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint Initial Color"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
- view_render = context.scene.view_render
if not (md and md.ui_type == 'CANVAS' and md.canvas_settings):
return 0
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
- return (surface and surface.surface_type == 'PAINT') and (view_render.engine in cls.COMPAT_ENGINES)
+ return (surface and surface.surface_type == 'PAINT') and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -346,16 +333,15 @@ class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_effects(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint Effects"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
- view_render = context.scene.view_render
if not (md and md.ui_type == 'CANVAS' and md.canvas_settings):
return False
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
- return (surface and surface.surface_type == 'PAINT') and (view_render.engine in cls.COMPAT_ENGINES)
+ return (surface and surface.surface_type == 'PAINT') and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -396,18 +382,17 @@ class PHYSICS_PT_dp_effects(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint Cache"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
- view_render = context.scene.view_render
return (md and
md.ui_type == 'CANVAS' and
md.canvas_settings and
md.canvas_settings.canvas_surfaces.active and
md.canvas_settings.canvas_surfaces.active.is_cache_user and
- (view_render.engine in cls.COMPAT_ENGINES))
+ (context.engine in cls.COMPAT_ENGINES))
def draw(self, context):
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
@@ -418,13 +403,12 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint Source"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
- view_render = context.scene.view_render
- return md and md.ui_type == 'BRUSH' and md.brush_settings and (view_render.engine in cls.COMPAT_ENGINES)
+ return md and md.ui_type == 'BRUSH' and md.brush_settings and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -472,13 +456,12 @@ class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint Velocity"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
- view_render = context.scene.view_render
- return md and md.ui_type == 'BRUSH' and md.brush_settings and (view_render.engine in cls.COMPAT_ENGINES)
+ return md and md.ui_type == 'BRUSH' and md.brush_settings and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -509,13 +492,12 @@ class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_brush_wave(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint Waves"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
- view_render = context.scene.view_render
- return md and md.ui_type == 'BRUSH' and md.brush_settings and (view_render.engine in cls.COMPAT_ENGINES)
+ return md and md.ui_type == 'BRUSH' and md.brush_settings and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py
index aee93f840be..3e3a2145682 100644
--- a/release/scripts/startup/bl_ui/properties_physics_field.py
+++ b/release/scripts/startup/bl_ui/properties_physics_field.py
@@ -33,8 +33,7 @@ class PhysicButtonsPanel:
@classmethod
def poll(cls, context):
- view_render = context.scene.view_render
- return (context.object) and (view_render.engine in cls.COMPAT_ENGINES)
+ return (context.object) and (context.engine in cls.COMPAT_ENGINES)
class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
@@ -44,8 +43,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
- view_render = context.scene.view_render
- return (view_render.engine in cls.COMPAT_ENGINES) and (ob.field) and (ob.field.type != 'NONE')
+ return (context.engine in cls.COMPAT_ENGINES) and (ob.field) and (ob.field.type != 'NONE')
def draw(self, context):
layout = self.layout
@@ -182,8 +180,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
- view_render = context.scene.view_render
- return (ob and ob.type == 'MESH') and (view_render.engine in cls.COMPAT_ENGINES) and (context.collision)
+ return (ob and ob.type == 'MESH') and (context.engine in cls.COMPAT_ENGINES) and (context.collision)
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 61ca23be4bc..93f1d28e536 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -37,13 +37,12 @@ class PhysicButtonsPanel:
@classmethod
def poll(cls, context):
ob = context.object
- view_render = context.scene.view_render
- return (ob and ob.type == 'MESH') and view_render.engine in cls.COMPAT_ENGINES and (context.fluid)
+ return (ob and ob.type == 'MESH') and context.engine in cls.COMPAT_ENGINES and (context.fluid)
class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
bl_label = "Fluid"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -206,13 +205,12 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel):
bl_label = "Fluid World"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.fluid
- view_render = context.scene.view_render
- return md and md.settings and (md.settings.type == 'DOMAIN') and view_render.engine in cls.COMPAT_ENGINES
+ return md and md.settings and (md.settings.type == 'DOMAIN') and context.engine in cls.COMPAT_ENGINES
def draw(self, context):
layout = self.layout
@@ -260,13 +258,12 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel):
class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, Panel):
bl_label = "Fluid Boundary"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.fluid
- view_render = context.scene.view_render
- return md and md.settings and (md.settings.type == 'DOMAIN') and view_render.engine in cls.COMPAT_ENGINES
+ return md and md.settings and (md.settings.type == 'DOMAIN') and context.engine in cls.COMPAT_ENGINES
def draw(self, context):
layout = self.layout
@@ -291,13 +288,12 @@ class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, Panel):
class PHYSICS_PT_domain_particles(PhysicButtonsPanel, Panel):
bl_label = "Fluid Particles"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
md = context.fluid
- view_render = context.scene.view_render
- return md and md.settings and (md.settings.type == 'DOMAIN') and view_render.engine in cls.COMPAT_ENGINES
+ return md and md.settings and (md.settings.type == 'DOMAIN') and context.engine in cls.COMPAT_ENGINES
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
index 21453ff3642..817b0ab76ed 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -29,7 +29,7 @@ class PHYSICS_PT_rigidbody_panel:
class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Rigid Body"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -56,7 +56,7 @@ class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Rigid Body Collisions"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -101,7 +101,7 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Rigid Body Dynamics"
bl_default_closed = True
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
index a9b30c3b388..aca989fd0ba 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
@@ -29,13 +29,12 @@ class PHYSICS_PT_rigidbody_constraint_panel:
class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Rigid Body Constraint"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
ob = context.object
- view_render = context.scene.view_render
- return (ob and ob.rigid_body_constraint and view_render.engine in cls.COMPAT_ENGINES)
+ return (ob and ob.rigid_body_constraint and context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index d02bee3a0fa..ddb898c7881 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -34,8 +34,7 @@ class PhysicButtonsPanel:
@classmethod
def poll(cls, context):
ob = context.object
- view_render = context.scene.view_render
- return (ob and ob.type == 'MESH') and (view_render.engine in cls.COMPAT_ENGINES) and (context.smoke)
+ return (ob and ob.type == 'MESH') and (context.engine in cls.COMPAT_ENGINES) and (context.smoke)
class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
@@ -242,8 +241,7 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
md = context.smoke
- view_render = context.scene.view_render
- return md and (md.smoke_type == 'DOMAIN') and (view_render.engine in cls.COMPAT_ENGINES)
+ return md and (md.smoke_type == 'DOMAIN') and (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
md = context.smoke.domain_settings
@@ -282,8 +280,7 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
md = context.smoke
- view_render = context.scene.view_render
- return md and (md.smoke_type == 'DOMAIN') and (view_render.engine in cls.COMPAT_ENGINES)
+ return md and (md.smoke_type == 'DOMAIN') and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -311,8 +308,7 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
md = context.smoke
- view_render = context.scene.view_render
- return md and (md.smoke_type == 'DOMAIN') and (view_render.engine in cls.COMPAT_ENGINES)
+ return md and (md.smoke_type == 'DOMAIN') and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -348,8 +344,7 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
md = context.smoke
- view_render = context.scene.view_render
- return md and (md.smoke_type == 'DOMAIN') and (view_render.engine in cls.COMPAT_ENGINES)
+ return md and (md.smoke_type == 'DOMAIN') and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
domain = context.smoke.domain_settings
@@ -363,8 +358,7 @@ class PHYSICS_PT_smoke_display_settings(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
md = context.smoke
- view_render = context.scene.view_render
- return md and (md.smoke_type == 'DOMAIN') and (not view_render.use_game_engine)
+ return md and (md.smoke_type == 'DOMAIN')
def draw(self, context):
domain = context.smoke.domain_settings
diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py
index 718f552cf33..86b9a95e294 100644
--- a/release/scripts/startup/bl_ui/properties_physics_softbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py
@@ -41,13 +41,12 @@ class PhysicButtonsPanel:
@classmethod
def poll(cls, context):
ob = context.object
- view_render = context.scene.view_render
- return ob and ob.type in COMPAT_OB_TYPES and view_render.engine in cls.COMPAT_ENGINES and context.soft_body
+ return ob and ob.type in COMPAT_OB_TYPES and context.engine in cls.COMPAT_ENGINES and context.soft_body
class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
bl_label = "Soft Body"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -77,7 +76,7 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Cache"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
md = context.soft_body
@@ -87,7 +86,7 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Goal"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -127,7 +126,7 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Edges"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -177,7 +176,7 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Self Collision"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -206,7 +205,7 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel):
class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Solver"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -239,7 +238,7 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel):
class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Field Weights"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
md = context.soft_body
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 15b175617d6..dbdf6bb3609 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -51,8 +51,7 @@ class RenderButtonsPanel:
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
class RENDER_PT_context(Panel):
@@ -70,10 +69,10 @@ class RENDER_PT_context(Panel):
layout = self.layout
scene = context.scene
- view_render = scene.view_render
+ rd = scene.render
- if view_render.has_multiple_engines:
- layout.prop(view_render, "engine", text="")
+ if rd.has_multiple_engines:
+ layout.prop(rd, "engine", text="")
class RENDER_PT_render(RenderButtonsPanel, Panel):
@@ -194,131 +193,6 @@ class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
subrow.prop(rd, "frame_map_new", text="New")
-class RENDER_PT_antialiasing(RenderButtonsPanel, Panel):
- bl_label = "Anti-Aliasing"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw_header(self, context):
- rd = context.scene.render
-
- self.layout.prop(rd, "use_antialiasing", text="")
-
- def draw(self, context):
- layout = self.layout
-
- rd = context.scene.render
- layout.active = rd.use_antialiasing
-
- split = layout.split()
-
- col = split.column()
- col.row().prop(rd, "antialiasing_samples", expand=True)
- sub = col.row()
- sub.prop(rd, "use_full_sample")
-
- col = split.column()
- col.prop(rd, "pixel_filter_type", text="")
- col.prop(rd, "filter_size", text="Size")
-
-
-class RENDER_PT_motion_blur(RenderButtonsPanel, Panel):
- bl_label = "Sampled Motion Blur"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- scene = context.scene
- rd = scene.render
- view_render = scene.view_render
- return not rd.use_full_sample and (view_render.engine in cls.COMPAT_ENGINES)
-
- def draw_header(self, context):
- rd = context.scene.render
-
- self.layout.prop(rd, "use_motion_blur", text="")
-
- def draw(self, context):
- layout = self.layout
-
- rd = context.scene.render
- layout.active = rd.use_motion_blur
-
- row = layout.row()
- row.prop(rd, "motion_blur_samples")
- row.prop(rd, "motion_blur_shutter")
-
-
-class RENDER_PT_shading(RenderButtonsPanel, Panel):
- bl_label = "Shading"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw(self, context):
- layout = self.layout
-
- rd = context.scene.render
-
- split = layout.split()
-
- col = split.column()
- col.prop(rd, "use_textures", text="Textures")
- col.prop(rd, "use_shadows", text="Shadows")
- col.prop(rd, "use_sss", text="Subsurface Scattering")
- col.prop(rd, "use_envmaps", text="Environment Map")
-
- col = split.column()
- col.prop(rd, "use_raytrace", text="Ray Tracing")
- col.prop(rd, "alpha_mode", text="Alpha")
- col.prop(rd, "use_world_space_shading", text="World Space Shading")
-
-
-class RENDER_PT_performance(RenderButtonsPanel, Panel):
- bl_label = "Performance"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw(self, context):
- layout = self.layout
-
- rd = context.scene.render
-
- split = layout.split()
-
- col = split.column(align=True)
- col.label(text="Threads:")
- col.row(align=True).prop(rd, "threads_mode", expand=True)
- sub = col.column(align=True)
- sub.enabled = rd.threads_mode == 'FIXED'
- sub.prop(rd, "threads")
-
- col.label(text="Tile Size:")
- col.prop(rd, "tile_x", text="X")
- col.prop(rd, "tile_y", text="Y")
-
- col.separator()
- col.prop(rd, "preview_start_resolution")
- col.prop(rd, "preview_pixel_size", text="")
-
- col = split.column()
- col.label(text="Memory:")
- sub = col.column()
- sub.enabled = not rd.use_full_sample
- sub.prop(rd, "use_save_buffers")
- sub = col.column()
- sub.active = rd.use_compositing
- sub.prop(rd, "use_free_image_textures")
- sub = col.column()
- sub.active = rd.use_raytrace
- sub.label(text="Acceleration Structure:")
- sub.prop(rd, "raytrace_method", text="")
- if rd.raytrace_method == 'OCTREE':
- sub.prop(rd, "octree_resolution", text="Resolution")
- else:
- sub.prop(rd, "use_instances", text="Instances")
- sub.prop(rd, "use_local_coords", text="Local Coordinates")
-
-
class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
bl_label = "Post Processing"
bl_options = {'DEFAULT_CLOSED'}
@@ -337,7 +211,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
split.prop(rd, "dither_intensity", text="Dither", slider=True)
- if context.scene.view_render.engine == 'BLENDER_EEVEE':
+ if context.engine == 'BLENDER_EEVEE':
return
layout.separator()
@@ -441,7 +315,7 @@ class RENDER_PT_output(RenderButtonsPanel, Panel):
class RENDER_PT_encoding(RenderButtonsPanel, Panel):
bl_label = "Encoding"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -520,77 +394,6 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel):
col.prop(ffmpeg, "packetsize", text="Packet Size")
-class RENDER_PT_bake(RenderButtonsPanel, Panel):
- bl_label = "Bake"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- rd = context.scene.render
-
- layout.operator("object.bake_image", icon='RENDER_STILL')
-
- layout.prop(rd, "bake_type")
-
- multires_bake = False
- if rd.bake_type in ['NORMALS', 'DISPLACEMENT', 'DERIVATIVE', 'AO']:
- layout.prop(rd, "use_bake_multires")
- multires_bake = rd.use_bake_multires
-
- if not multires_bake:
- if rd.bake_type == 'NORMALS':
- layout.prop(rd, "bake_normal_space")
- elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
- layout.prop(rd, "use_bake_normalize")
-
- # col.prop(rd, "bake_aa_mode")
- # col.prop(rd, "use_bake_antialiasing")
-
- layout.separator()
-
- split = layout.split()
-
- col = split.column()
- col.prop(rd, "use_bake_to_vertex_color")
- sub = col.column()
- sub.active = not rd.use_bake_to_vertex_color
- sub.prop(rd, "use_bake_clear")
- sub.prop(rd, "bake_margin")
- sub.prop(rd, "bake_quad_split", text="Split")
-
- col = split.column()
- col.prop(rd, "use_bake_selected_to_active")
- sub = col.column()
- sub.active = rd.use_bake_selected_to_active
- sub.prop(rd, "bake_distance")
- sub.prop(rd, "bake_bias")
- else:
- split = layout.split()
-
- col = split.column()
- col.prop(rd, "use_bake_clear")
- col.prop(rd, "bake_margin")
-
- if rd.bake_type == 'DISPLACEMENT':
- col = split.column()
- col.prop(rd, "use_bake_lores_mesh")
-
- if rd.bake_type == 'AO':
- col = split.column()
- col.prop(rd, "bake_bias")
- col.prop(rd, "bake_samples")
-
- if rd.bake_type == 'DERIVATIVE':
- row = layout.row()
- row.prop(rd, "use_bake_user_scale", text="")
-
- sub = row.column()
- sub.active = rd.use_bake_user_scale
- sub.prop(rd, "bake_user_scale", text="User Scale")
-
-
class RENDER_PT_clay_layer_settings(RenderButtonsPanel, Panel):
bl_label = "Clay Layer Settings"
COMPAT_ENGINES = {'BLENDER_CLAY'}
@@ -631,8 +434,7 @@ class RENDER_PT_eevee_ambient_occlusion(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -660,8 +462,7 @@ class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -686,8 +487,7 @@ class RENDER_PT_eevee_depth_of_field(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -712,8 +512,7 @@ class RENDER_PT_eevee_bloom(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -742,8 +541,7 @@ class RENDER_PT_eevee_volumetric(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -776,8 +574,7 @@ class RENDER_PT_eevee_subsurface_scattering(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -802,8 +599,7 @@ class RENDER_PT_eevee_screen_space_reflections(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -833,8 +629,7 @@ class RENDER_PT_eevee_shadows(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -854,8 +649,7 @@ class RENDER_PT_eevee_sampling(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -865,6 +659,7 @@ class RENDER_PT_eevee_sampling(RenderButtonsPanel, Panel):
col = layout.column()
col.prop(props, "taa_samples")
col.prop(props, "taa_render_samples")
+ col.prop(props, "taa_reprojection")
class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
@@ -874,8 +669,7 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -895,8 +689,7 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -919,15 +712,10 @@ classes = (
RENDER_PT_context,
RENDER_PT_render,
RENDER_PT_dimensions,
- RENDER_PT_antialiasing,
- RENDER_PT_motion_blur,
- RENDER_PT_shading,
- RENDER_PT_performance,
RENDER_PT_post_processing,
RENDER_PT_stamp,
RENDER_PT_output,
RENDER_PT_encoding,
- RENDER_PT_bake,
RENDER_PT_clay_layer_settings,
RENDER_PT_clay_collection_settings,
RENDER_PT_eevee_sampling,
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index e8f25ea891b..094f2a9dc31 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -60,13 +60,12 @@ class SceneButtonsPanel:
@classmethod
def poll(cls, context):
- view_render = context.scene.view_render
- return context.scene and (view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
class SCENE_PT_scene(SceneButtonsPanel, Panel):
bl_label = "Scene"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -75,13 +74,12 @@ class SCENE_PT_scene(SceneButtonsPanel, Panel):
layout.prop(scene, "camera")
layout.prop(scene, "background_set", text="Background")
- if context.engine != 'BLENDER_GAME':
- layout.prop(scene, "active_clip", text="Active Clip")
+ layout.prop(scene, "active_clip", text="Active Clip")
class SCENE_PT_unit(SceneButtonsPanel, Panel):
bl_label = "Units"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -166,7 +164,7 @@ class SceneKeyingSetsPanel:
class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
bl_label = "Keying Sets"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -199,7 +197,7 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
bl_label = "Active Keying Set"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -256,7 +254,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
class SCENE_PT_color_management(SceneButtonsPanel, Panel):
bl_label = "Color Management"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -281,7 +279,7 @@ class SCENE_PT_color_management(SceneButtonsPanel, Panel):
class SCENE_PT_audio(SceneButtonsPanel, Panel):
bl_label = "Audio"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -310,7 +308,7 @@ class SCENE_PT_audio(SceneButtonsPanel, Panel):
class SCENE_PT_physics(SceneButtonsPanel, Panel):
bl_label = "Gravity"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw_header(self, context):
self.layout.prop(context.scene, "use_gravity", text="")
@@ -327,12 +325,11 @@ class SCENE_PT_physics(SceneButtonsPanel, Panel):
class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
bl_label = "Rigid Body World"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -373,13 +370,12 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel):
bl_label = "Rigid Body Cache"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
scene = context.scene
- view_render = scene.view_render
- return scene and scene.rigidbody_world and (view_render.engine in cls.COMPAT_ENGINES)
+ return scene and scene.rigidbody_world and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
scene = context.scene
@@ -391,13 +387,12 @@ class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel):
class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
bl_label = "Rigid Body Field Weights"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
- view_render = context.scene.view_render
scene = context.scene
- return scene and scene.rigidbody_world and (view_render.engine in cls.COMPAT_ENGINES)
+ return scene and scene.rigidbody_world and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
scene = context.scene
@@ -432,13 +427,10 @@ class SCENE_PT_simplify(SceneButtonsPanel, Panel):
col.label(text="Render:")
col.prop(rd, "simplify_subdivision_render", text="Subdivision")
col.prop(rd, "simplify_child_particles_render", text="Child Particles")
- col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
- col.prop(rd, "simplify_ao_sss", text="AO and SSS")
- col.prop(rd, "use_simplify_triangulate")
class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "scene"
_property_type = bpy.types.Scene
diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index 38a7fff8ed3..aa3227e0b72 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -23,12 +23,9 @@ from bpy.types import Menu, Panel, UIList
from bpy.types import (
Brush,
FreestyleLineStyle,
- Lamp,
- Material,
Object,
ParticleSettings,
Texture,
- World,
)
from rna_prop_ui import PropertyPanel
@@ -38,7 +35,7 @@ from .properties_paint_common import brush_texture_settings
class TEXTURE_MT_specials(Menu):
bl_label = "Texture Specials"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
@@ -47,22 +44,9 @@ class TEXTURE_MT_specials(Menu):
layout.operator("texture.slot_paste", icon='PASTEDOWN')
-class TEXTURE_MT_envmap_specials(Menu):
- bl_label = "Environment Map Specials"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator("texture.envmap_save", icon='IMAGEFILE')
- layout.operator("texture.envmap_clear", icon='FILE_REFRESH')
- layout.operator("texture.envmap_clear_all", icon='FILE_REFRESH')
-
-
class TEXTURE_UL_texslots(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
- # assert(isinstance(item, bpy.types.MaterialTextureSlot)
ma = data
slot = item
tex = slot.texture if slot else None
@@ -71,29 +55,11 @@ class TEXTURE_UL_texslots(UIList):
layout.prop(tex, "name", text="", emboss=False, icon_value=icon)
else:
layout.label(text="", icon_value=icon)
- if tex and isinstance(item, bpy.types.MaterialTextureSlot):
- layout.prop(ma, "use_textures", text="", index=index)
elif self.layout_type == 'GRID':
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
-
-from .properties_material import active_node_mat
-
-
def context_tex_datablock(context):
- idblock = context.material
- if idblock:
- return active_node_mat(idblock)
-
- idblock = context.lamp
- if idblock:
- return idblock
-
- idblock = context.world
- if idblock:
- return idblock
-
idblock = context.brush
if idblock:
return idblock
@@ -108,151 +74,138 @@ def context_tex_datablock(context):
return idblock
-def id_tex_datablock(bid):
- if isinstance(bid, Object):
- if bid.type == 'LAMP':
- return bid.data
- return bid.active_material
-
- return bid
-
-
class TextureButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "texture"
+
+class TEXTURE_PT_preview(TextureButtonsPanel, Panel):
+ bl_label = "Preview"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
@classmethod
def poll(cls, context):
tex = context.texture
return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES)
+ def draw(self, context):
+ layout = self.layout
+
+ tex = context.texture
+ slot = getattr(context, "texture_slot", None)
+ idblock = context_tex_datablock(context)
+
+ if idblock:
+ layout.template_preview(tex, parent=idblock, slot=slot)
+ else:
+ layout.template_preview(tex, slot=slot)
+
+ # Show Alpha Button for Brush Textures, see #29502
+ idblock = context_tex_datablock(context)
+ if isinstance(idblock, Brush):
+ layout.prop(tex, "use_preview_alpha")
-class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
+class TEXTURE_PT_context(TextureButtonsPanel, Panel):
bl_label = ""
+ bl_context = "texture"
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- engine = context.engine
- # if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")):
- # return False
- return ((context.material or
- context.world or
- context.lamp or
- context.texture or
- context.line_style or
- context.particle_system or
- isinstance(context.space_data.pin_id, ParticleSettings) or
- context.texture_user) and
- (engine in cls.COMPAT_ENGINES))
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
- slot = getattr(context, "texture_slot", None)
- node = getattr(context, "texture_node", None)
- space = context.space_data
tex = context.texture
- idblock = context_tex_datablock(context)
+ space = context.space_data
pin_id = space.pin_id
+ use_pin_id = space.use_pin_id
+ user = context.texture_user
- space.use_limited_texture_context = True
-
- if space.use_pin_id and not isinstance(pin_id, Texture):
- idblock = id_tex_datablock(pin_id)
- pin_id = None
-
- if not space.use_pin_id:
- layout.row().prop(space, "texture_context", expand=True)
+ if not (use_pin_id and isinstance(pin_id, bpy.types.Texture)):
pin_id = None
- if space.texture_context == 'OTHER':
- if not pin_id:
- layout.template_texture_user()
- user = context.texture_user
- if user or pin_id:
- layout.separator()
+ if not pin_id:
+ layout.template_texture_user()
- row = layout.row()
+ if user or pin_id:
+ layout.separator()
- if pin_id:
- row.template_ID(space, "pin_id")
- else:
- propname = context.texture_user_property.identifier
- row.template_ID(user, propname, new="texture.new")
-
- if tex:
- split = layout.split(percentage=0.2)
- if tex.use_nodes:
- if slot:
- split.label(text="Output:")
- split.prop(slot, "output_node", text="")
- else:
- split.label(text="Type:")
- split.prop(tex, "type", text="")
- return
-
- tex_collection = (pin_id is None) and (node is None) and (not isinstance(idblock, Brush))
-
- if tex_collection:
- row = layout.row()
+ split = layout.split(percentage=0.65)
+ col = split.column()
- row.template_list("TEXTURE_UL_texslots", "", idblock, "texture_slots",
- idblock, "active_texture_index", rows=2)
-
- col = row.column(align=True)
- col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
- col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
- col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
-
- if tex_collection:
- layout.template_ID(idblock, "active_texture", new="texture.new")
- elif node:
- layout.template_ID(node, "texture", new="texture.new")
- elif idblock:
- layout.template_ID(idblock, "texture", new="texture.new")
-
- if pin_id:
- layout.template_ID(space, "pin_id")
-
- if tex:
- split = layout.split(percentage=0.2)
- if tex.use_nodes:
- if slot:
- split.label(text="Output:")
- split.prop(slot, "output_node", text="")
+ if pin_id:
+ col.template_ID(space, "pin_id")
else:
+ propname = context.texture_user_property.identifier
+ col.template_ID(user, propname, new="texture.new")
+
+ if tex:
+ split = layout.split(percentage=0.2)
split.label(text="Type:")
split.prop(tex, "type", text="")
-class TEXTURE_PT_preview(TextureButtonsPanel, Panel):
- bl_label = "Preview"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+class TEXTURE_PT_node(TextureButtonsPanel, Panel):
+ bl_label = "Node"
+ bl_context = "texture"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ node = context.texture_node
+ return node and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
- tex = context.texture
- slot = getattr(context, "texture_slot", None)
- idblock = context_tex_datablock(context)
+ node = context.texture_node
+ ntree = node.id_data
+ layout.template_node_view(ntree, node, None)
- if idblock:
- layout.template_preview(tex, parent=idblock, slot=slot)
- else:
- layout.template_preview(tex, slot=slot)
- # Show Alpha Button for Brush Textures, see #29502
- if context.space_data.texture_context == 'BRUSH':
- layout.prop(tex, "use_preview_alpha")
+class TEXTURE_PT_node_mapping(TextureButtonsPanel, Panel):
+ bl_label = "Mapping"
+ bl_context = "texture"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ node = context.texture_node
+ # TODO(sergey): perform a faster/nicer check?
+ return node and hasattr(node, 'texture_mapping') and (context.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+
+ node = context.texture_node
+
+ mapping = node.texture_mapping
+
+ layout.prop(mapping, "vector_type", expand=True)
+
+ row = layout.row()
+
+ row.column().prop(mapping, "translation")
+ row.column().prop(mapping, "rotation")
+ row.column().prop(mapping, "scale")
+
+ layout.label(text="Projection:")
+
+ row = layout.row()
+ row.prop(mapping, "mapping_x", text="")
+ row.prop(mapping, "mapping_y", text="")
+ row.prop(mapping, "mapping_z", text="")
class TEXTURE_PT_colors(TextureButtonsPanel, Panel):
bl_label = "Colors"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
+
+ @classmethod
+ def poll(cls, context):
+ tex = context.texture
+ return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -281,23 +234,6 @@ class TEXTURE_PT_colors(TextureButtonsPanel, Panel):
col = layout.column()
col.prop(tex, "use_clamp", text="Clamp")
-# Texture Slot Panels #
-
-
-class TextureSlotPanel(TextureButtonsPanel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- if not hasattr(context, "texture_slot"):
- return False
-
- engine = context.engine
- return TextureButtonsPanel.poll(cls, context) and (engine in cls.COMPAT_ENGINES)
-
-
-# Texture Type Panels #
-
class TextureTypePanel(TextureButtonsPanel):
@@ -311,7 +247,7 @@ class TextureTypePanel(TextureButtonsPanel):
class TEXTURE_PT_clouds(TextureTypePanel, Panel):
bl_label = "Clouds"
tex_type = 'CLOUDS'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -335,7 +271,7 @@ class TEXTURE_PT_clouds(TextureTypePanel, Panel):
class TEXTURE_PT_wood(TextureTypePanel, Panel):
bl_label = "Wood"
tex_type = 'WOOD'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -364,7 +300,7 @@ class TEXTURE_PT_wood(TextureTypePanel, Panel):
class TEXTURE_PT_marble(TextureTypePanel, Panel):
bl_label = "Marble"
tex_type = 'MARBLE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -391,7 +327,7 @@ class TEXTURE_PT_marble(TextureTypePanel, Panel):
class TEXTURE_PT_magic(TextureTypePanel, Panel):
bl_label = "Magic"
tex_type = 'MAGIC'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -406,7 +342,7 @@ class TEXTURE_PT_magic(TextureTypePanel, Panel):
class TEXTURE_PT_blend(TextureTypePanel, Panel):
bl_label = "Blend"
tex_type = 'BLEND'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -424,7 +360,7 @@ class TEXTURE_PT_blend(TextureTypePanel, Panel):
class TEXTURE_PT_stucci(TextureTypePanel, Panel):
bl_label = "Stucci"
tex_type = 'STUCCI'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -444,7 +380,7 @@ class TEXTURE_PT_stucci(TextureTypePanel, Panel):
class TEXTURE_PT_image(TextureTypePanel, Panel):
bl_label = "Image"
tex_type = 'IMAGE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -471,15 +407,9 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, Panel):
bl_label = "Image Sampling"
bl_options = {'DEFAULT_CLOSED'}
tex_type = 'IMAGE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
- if context.engine == 'BLENDER_GAME':
- self.draw_bge(context)
- else:
- self.draw_bi(context)
-
- def draw_bi(self, context):
layout = self.layout
idblock = context_tex_datablock(context)
@@ -500,17 +430,6 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, Panel):
col = split.column()
- # Only for Material based textures, not for Lamp/World...
- if slot and isinstance(idblock, Material):
- col.prop(tex, "use_normal_map")
- row = col.row()
- row.active = tex.use_normal_map
- row.prop(slot, "normal_map_space", text="")
-
- row = col.row()
- row.active = not tex.use_normal_map
- row.prop(tex, "use_derivative_map")
-
col.prop(tex, "use_mipmap")
row = col.row()
row.active = tex.use_mipmap
@@ -519,39 +438,12 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, Panel):
texture_filter_common(tex, col)
- def draw_bge(self, context):
- layout = self.layout
-
- idblock = context_tex_datablock(context)
- tex = context.texture
- slot = getattr(context, "texture_slot", None)
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Alpha:")
- col.prop(tex, "use_calculate_alpha", text="Calculate")
- col.prop(tex, "invert_alpha", text="Invert")
-
- col = split.column()
-
- # Only for Material based textures, not for Lamp/World...
- if slot and isinstance(idblock, Material):
- col.prop(tex, "use_normal_map")
- row = col.row()
- row.active = tex.use_normal_map
- row.prop(slot, "normal_map_space", text="")
-
- row = col.row()
- row.active = not tex.use_normal_map
- row.prop(tex, "use_derivative_map")
-
class TEXTURE_PT_image_mapping(TextureTypePanel, Panel):
bl_label = "Image Mapping"
bl_options = {'DEFAULT_CLOSED'}
tex_type = 'IMAGE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -603,62 +495,10 @@ class TEXTURE_PT_image_mapping(TextureTypePanel, Panel):
col.prop(tex, "crop_max_y", text="Y")
-class TEXTURE_PT_envmap(TextureTypePanel, Panel):
- bl_label = "Environment Map"
- tex_type = 'ENVIRONMENT_MAP'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- tex = context.texture
- env = tex.environment_map
-
- row = layout.row()
- row.prop(env, "source", expand=True)
- row.menu("TEXTURE_MT_envmap_specials", icon='DOWNARROW_HLT', text="")
-
- if env.source == 'IMAGE_FILE':
- layout.template_ID(tex, "image", open="image.open")
- layout.template_image(tex, "image", tex.image_user, compact=True)
- else:
- layout.prop(env, "mapping")
- if env.mapping == 'PLANE':
- layout.prop(env, "zoom")
- layout.prop(env, "viewpoint_object")
-
- split = layout.split()
-
- col = split.column()
- col.prop(env, "layers_ignore")
- col.prop(env, "resolution")
- col.prop(env, "depth")
-
- col = split.column(align=True)
-
- col.label(text="Clipping:")
- col.prop(env, "clip_start", text="Start")
- col.prop(env, "clip_end", text="End")
-
-
-class TEXTURE_PT_envmap_sampling(TextureTypePanel, Panel):
- bl_label = "Environment Map Sampling"
- bl_options = {'DEFAULT_CLOSED'}
- tex_type = 'ENVIRONMENT_MAP'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- tex = context.texture
-
- texture_filter_common(tex, layout)
-
-
class TEXTURE_PT_musgrave(TextureTypePanel, Panel):
bl_label = "Musgrave"
tex_type = 'MUSGRAVE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -694,7 +534,7 @@ class TEXTURE_PT_musgrave(TextureTypePanel, Panel):
class TEXTURE_PT_voronoi(TextureTypePanel, Panel):
bl_label = "Voronoi"
tex_type = 'VORONOI'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -730,7 +570,7 @@ class TEXTURE_PT_voronoi(TextureTypePanel, Panel):
class TEXTURE_PT_distortednoise(TextureTypePanel, Panel):
bl_label = "Distorted Noise"
tex_type = 'DISTORTED_NOISE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
@@ -749,180 +589,20 @@ class TEXTURE_PT_distortednoise(TextureTypePanel, Panel):
split.prop(tex, "nabla")
-class TEXTURE_PT_voxeldata(TextureButtonsPanel, Panel):
- bl_label = "Voxel Data"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- tex = context.texture
- engine = context.engine
- return tex and (tex.type == 'VOXEL_DATA' and (engine in cls.COMPAT_ENGINES))
-
- def draw(self, context):
- layout = self.layout
-
- tex = context.texture
- vd = tex.voxel_data
-
- layout.prop(vd, "file_format")
- if vd.file_format in {'BLENDER_VOXEL', 'RAW_8BIT'}:
- layout.prop(vd, "filepath")
- if vd.file_format == 'RAW_8BIT':
- layout.prop(vd, "resolution")
- elif vd.file_format == 'SMOKE':
- layout.prop(vd, "domain_object")
- layout.prop(vd, "smoke_data_type")
- elif vd.file_format == 'HAIR':
- layout.prop(vd, "domain_object")
- layout.prop(vd, "hair_data_type")
- elif vd.file_format == 'IMAGE_SEQUENCE':
- layout.template_ID(tex, "image", open="image.open")
- layout.template_image(tex, "image", tex.image_user, compact=True)
- # layout.prop(vd, "frame_duration")
-
- if vd.file_format in {'BLENDER_VOXEL', 'RAW_8BIT'}:
- layout.prop(vd, "use_still_frame")
- row = layout.row()
- row.active = vd.use_still_frame
- row.prop(vd, "still_frame")
-
- layout.prop(vd, "interpolation")
- layout.prop(vd, "extension")
- layout.prop(vd, "intensity")
-
-
-class TEXTURE_PT_pointdensity(TextureButtonsPanel, Panel):
- bl_label = "Point Density"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- @classmethod
- def poll(cls, context):
- tex = context.texture
- engine = context.engine
- return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
-
- def draw(self, context):
- layout = self.layout
-
- tex = context.texture
- pd = tex.point_density
-
- layout.row().prop(pd, "point_source", expand=True)
-
- split = layout.split()
-
- col = split.column()
- if pd.point_source == 'PARTICLE_SYSTEM':
- col.label(text="Object:")
- col.prop(pd, "object", text="")
-
- sub = col.column()
- sub.enabled = bool(pd.object)
- if pd.object:
- sub.label(text="System:")
- sub.prop_search(pd, "particle_system", pd.object, "particle_systems", text="")
- sub.label(text="Cache:")
- sub.prop(pd, "particle_cache_space", text="")
- else:
- col.label(text="Object:")
- col.prop(pd, "object", text="")
- col.label(text="Cache:")
- col.prop(pd, "vertex_cache_space", text="")
-
- col.separator()
-
- col.label(text="Color Source:")
- if pd.point_source == 'PARTICLE_SYSTEM':
- col.prop(pd, "particle_color_source", text="")
- if pd.particle_color_source in {'PARTICLE_SPEED', 'PARTICLE_VELOCITY'}:
- col.prop(pd, "speed_scale")
- if pd.particle_color_source in {'PARTICLE_SPEED', 'PARTICLE_AGE'}:
- layout.template_color_ramp(pd, "color_ramp", expand=True)
- else:
- col.prop(pd, "vertex_color_source", text="")
- if pd.vertex_color_source == 'VERTEX_COLOR':
- if pd.object and pd.object.data:
- col.prop_search(pd, "vertex_attribute_name", pd.object.data, "vertex_colors", text="")
- if pd.vertex_color_source == 'VERTEX_WEIGHT':
- if pd.object:
- col.prop_search(pd, "vertex_attribute_name", pd.object, "vertex_groups", text="")
- layout.template_color_ramp(pd, "color_ramp", expand=True)
-
- col = split.column()
- col.label()
- col.prop(pd, "radius")
- col.label(text="Falloff:")
- col.prop(pd, "falloff", text="")
- if pd.falloff == 'SOFT':
- col.prop(pd, "falloff_soft")
- if pd.falloff == 'PARTICLE_VELOCITY':
- col.prop(pd, "falloff_speed_scale")
-
- col.prop(pd, "use_falloff_curve")
-
- if pd.use_falloff_curve:
- col = layout.column()
- col.label(text="Falloff Curve")
- col.template_curve_mapping(pd, "falloff_curve", brush=False)
-
-
-class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, Panel):
- bl_label = "Turbulence"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+class TextureSlotPanel(TextureButtonsPanel):
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
- tex = context.texture
- engine = context.engine
- return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
-
- def draw_header(self, context):
- pd = context.texture.point_density
-
- self.layout.prop(pd, "use_turbulence", text="")
-
- def draw(self, context):
- layout = self.layout
-
- tex = context.texture
- pd = tex.point_density
- layout.active = pd.use_turbulence
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Influence:")
- col.prop(pd, "turbulence_influence", text="")
- col.label(text="Noise Basis:")
- col.prop(pd, "noise_basis", text="")
-
- col = split.column()
- col.label()
- col.prop(pd, "turbulence_scale")
- col.prop(pd, "turbulence_depth")
- col.prop(pd, "turbulence_strength")
-
-
-class TEXTURE_PT_ocean(TextureTypePanel, Panel):
- bl_label = "Ocean"
- tex_type = 'OCEAN'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
-
- def draw(self, context):
- layout = self.layout
-
- tex = context.texture
- ot = tex.ocean
+ if not hasattr(context, "texture_slot"):
+ return False
- col = layout.column()
- col.prop(ot, "ocean_object")
- col.prop(ot, "output")
+ return (context.engine in cls.COMPAT_ENGINES)
class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
bl_label = "Mapping"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -993,31 +673,6 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
row.prop(tex, "mapping_y", text="")
row.prop(tex, "mapping_z", text="")
- elif isinstance(idblock, Material):
- split = layout.split(percentage=0.3)
- split.label(text="Projection:")
- split.prop(tex, "mapping", text="")
-
- split = layout.split()
-
- col = split.column()
- if tex.texture_coords in {'ORCO', 'UV'}:
- col.prop(tex, "use_from_dupli")
- if (idblock.type == 'VOLUME' and tex.texture_coords == 'ORCO'):
- col.prop(tex, "use_map_to_bounds")
- elif tex.texture_coords == 'OBJECT':
- col.prop(tex, "use_from_original")
- if (idblock.type == 'VOLUME'):
- col.prop(tex, "use_map_to_bounds")
- else:
- col.label()
-
- col = split.column()
- row = col.row()
- row.prop(tex, "mapping_x", text="")
- row.prop(tex, "mapping_y", text="")
- row.prop(tex, "mapping_z", text="")
-
row = layout.row()
row.column().prop(tex, "offset")
row.column().prop(tex, "scale")
@@ -1025,7 +680,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
class TEXTURE_PT_influence(TextureSlotPanel, Panel):
bl_label = "Influence"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
@@ -1055,101 +710,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel):
sub.prop(tex, factor, text=name, slider=True)
return sub # XXX, temp. use_map_normal needs to override.
- if isinstance(idblock, Material):
- if idblock.type in {'SURFACE', 'WIRE'}:
- split = layout.split()
-
- col = split.column()
- col.label(text="Diffuse:")
- factor_but(col, "use_map_diffuse", "diffuse_factor", "Intensity")
- factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
- factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
- factor_but(col, "use_map_translucency", "translucency_factor", "Translucency")
-
- col.label(text="Specular:")
- factor_but(col, "use_map_specular", "specular_factor", "Intensity")
- factor_but(col, "use_map_color_spec", "specular_color_factor", "Color")
- factor_but(col, "use_map_hardness", "hardness_factor", "Hardness")
-
- col = split.column()
- col.label(text="Shading:")
- factor_but(col, "use_map_ambient", "ambient_factor", "Ambient")
- factor_but(col, "use_map_emit", "emit_factor", "Emit")
- factor_but(col, "use_map_mirror", "mirror_factor", "Mirror")
- factor_but(col, "use_map_raymir", "raymir_factor", "Ray Mirror")
-
- col.label(text="Geometry:")
- # XXX replace 'or' when displacement is fixed to not rely on normal influence value.
- sub_tmp = factor_but(col, "use_map_normal", "normal_factor", "Normal")
- sub_tmp.active = (tex.use_map_normal or tex.use_map_displacement)
- # END XXX
-
- factor_but(col, "use_map_warp", "warp_factor", "Warp")
- factor_but(col, "use_map_displacement", "displacement_factor", "Displace")
-
- #~ sub = col.column()
- #~ sub.active = tex.use_map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror
- #~ sub.prop(tex, "default_value", text="Amount", slider=True)
- elif idblock.type == 'HALO':
- layout.label(text="Halo:")
-
- split = layout.split()
-
- col = split.column()
- factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
- factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
-
- col = split.column()
- factor_but(col, "use_map_raymir", "raymir_factor", "Size")
- factor_but(col, "use_map_hardness", "hardness_factor", "Hardness")
- factor_but(col, "use_map_translucency", "translucency_factor", "Add")
- elif idblock.type == 'VOLUME':
- layout.label(text="Volume:")
-
- split = layout.split()
-
- col = split.column()
- factor_but(col, "use_map_density", "density_factor", "Density")
- factor_but(col, "use_map_emission", "emission_factor", "Emission")
- factor_but(col, "use_map_scatter", "scattering_factor", "Scattering")
- factor_but(col, "use_map_reflect", "reflection_factor", "Reflection")
-
- col = split.column()
- col.label(text=" ")
- factor_but(col, "use_map_color_emission", "emission_color_factor", "Emission Color")
- factor_but(col, "use_map_color_transmission", "transmission_color_factor", "Transmission Color")
- factor_but(col, "use_map_color_reflection", "reflection_color_factor", "Reflection Color")
-
- layout.label(text="Geometry:")
-
- split = layout.split()
-
- col = split.column()
- factor_but(col, "use_map_warp", "warp_factor", "Warp")
-
- col = split.column()
- factor_but(col, "use_map_displacement", "displacement_factor", "Displace")
-
- elif isinstance(idblock, Lamp):
- split = layout.split()
-
- col = split.column()
- factor_but(col, "use_map_color", "color_factor", "Color")
-
- col = split.column()
- factor_but(col, "use_map_shadow", "shadow_factor", "Shadow")
-
- elif isinstance(idblock, World):
- split = layout.split()
-
- col = split.column()
- factor_but(col, "use_map_blend", "blend_factor", "Blend")
- factor_but(col, "use_map_horizon", "horizon_factor", "Horizon")
-
- col = split.column()
- factor_but(col, "use_map_zenith_up", "zenith_up_factor", "Zenith Up")
- factor_but(col, "use_map_zenith_down", "zenith_down_factor", "Zenith Down")
- elif isinstance(idblock, ParticleSettings):
+ if isinstance(idblock, ParticleSettings):
split = layout.split()
col = split.column()
@@ -1203,47 +764,26 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel):
col.prop(tex, "invert", text="Negative")
col.prop(tex, "use_stencil")
- if isinstance(idblock, Material) or isinstance(idblock, World):
- col.prop(tex, "default_value", text="DVar", slider=True)
-
- if isinstance(idblock, Material):
- layout.label(text="Bump Mapping:")
-
- # only show bump settings if activated but not for normal-map images
- row = layout.row()
-
- sub = row.row()
- sub.active = (
- (tex.use_map_normal or tex.use_map_warp) and
- not (tex.texture.type == 'IMAGE' and
- (tex.texture.use_normal_map or tex.texture.use_derivative_map))
- )
- sub.prop(tex, "bump_method", text="Method")
-
- # the space setting is supported for: derivative-maps + bump-maps
- # (DEFAULT,BEST_QUALITY), not for normal-maps
- sub = row.row()
- sub.active = (
- (tex.use_map_normal or tex.use_map_warp) and
- not (tex.texture.type == 'IMAGE' and tex.texture.use_normal_map) and
- ((tex.bump_method in {'BUMP_LOW_QUALITY', 'BUMP_MEDIUM_QUALITY', 'BUMP_BEST_QUALITY'}) or
- (tex.texture.type == 'IMAGE' and tex.texture.use_derivative_map))
- )
- sub.prop(tex, "bump_objectspace", text="Space")
-
class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
_context_path = "texture"
_property_type = Texture
+ @classmethod
+ def poll(cls, context):
+ return context.texture and (context.engine in cls.COMPAT_ENGINES)
+
classes = (
TEXTURE_MT_specials,
- TEXTURE_MT_envmap_specials,
TEXTURE_UL_texslots,
- TEXTURE_PT_context_texture,
TEXTURE_PT_preview,
+ TEXTURE_PT_context,
+ TEXTURE_PT_node,
+ TEXTURE_PT_node_mapping,
+ TEXTURE_PT_mapping,
+ TEXTURE_PT_influence,
TEXTURE_PT_colors,
TEXTURE_PT_clouds,
TEXTURE_PT_wood,
@@ -1254,17 +794,9 @@ classes = (
TEXTURE_PT_image,
TEXTURE_PT_image_sampling,
TEXTURE_PT_image_mapping,
- TEXTURE_PT_envmap,
- TEXTURE_PT_envmap_sampling,
TEXTURE_PT_musgrave,
TEXTURE_PT_voronoi,
TEXTURE_PT_distortednoise,
- TEXTURE_PT_voxeldata,
- TEXTURE_PT_pointdensity,
- TEXTURE_PT_pointdensity_turbulence,
- TEXTURE_PT_ocean,
- TEXTURE_PT_mapping,
- TEXTURE_PT_influence,
TEXTURE_PT_custom_props,
)
diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py
index 4d61aacbf22..2b80c857f97 100644
--- a/release/scripts/startup/bl_ui/properties_view_layer.py
+++ b/release/scripts/startup/bl_ui/properties_view_layer.py
@@ -29,8 +29,7 @@ class ViewLayerButtonsPanel:
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
class VIEWLAYER_UL_viewlayers(UIList):
@@ -48,18 +47,13 @@ class VIEWLAYER_UL_viewlayers(UIList):
class VIEWLAYER_PT_layers(ViewLayerButtonsPanel, Panel):
bl_label = "Layer List"
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
def draw(self, context):
layout = self.layout
scene = context.scene
rd = scene.render
- view_render = scene.view_render
-
- if view_render.engine == 'BLENDER_GAME':
- layout.label("Not available in the Game Engine")
- return
row = layout.row()
col = row.column()
@@ -137,8 +131,7 @@ class VIEWLAYER_PT_clay_settings(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -158,8 +151,7 @@ class VIEWLAYER_PT_eevee_ambient_occlusion(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -191,8 +183,7 @@ class VIEWLAYER_PT_eevee_motion_blur(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -221,8 +212,7 @@ class VIEWLAYER_PT_eevee_depth_of_field(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -251,8 +241,7 @@ class VIEWLAYER_PT_eevee_bloom(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -285,8 +274,7 @@ class VIEWLAYER_PT_eevee_volumetric(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -323,8 +311,7 @@ class VIEWLAYER_PT_eevee_subsurface_scattering(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -354,8 +341,7 @@ class VIEWLAYER_PT_eevee_screen_space_reflections(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
@@ -389,8 +375,7 @@ class VIEWLAYER_PT_eevee_shadows(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -412,8 +397,7 @@ class VIEWLAYER_PT_eevee_sampling(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -425,6 +409,7 @@ class VIEWLAYER_PT_eevee_sampling(ViewLayerButtonsPanel, Panel):
col = layout.column()
col.template_override_property(layer_props, scene_props, "taa_samples")
col.template_override_property(layer_props, scene_props, "taa_render_samples")
+ col.template_override_property(layer_props, scene_props, "taa_reprojection")
class VIEWLAYER_PT_eevee_indirect_lighting(ViewLayerButtonsPanel, Panel):
@@ -434,8 +419,7 @@ class VIEWLAYER_PT_eevee_indirect_lighting(ViewLayerButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- scene = context.scene
- return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
+ return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py
index 48eed9acb3a..1ec2d4774e8 100644
--- a/release/scripts/startup/bl_ui/properties_world.py
+++ b/release/scripts/startup/bl_ui/properties_world.py
@@ -41,8 +41,7 @@ class WORLD_PT_context_world(WorldButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- view_render = context.scene.view_render
- return view_render.engine in cls.COMPAT_ENGINES
+ return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -51,197 +50,12 @@ class WORLD_PT_context_world(WorldButtonsPanel, Panel):
world = context.world
space = context.space_data
- texture_count = world and len(world.texture_slots.keys())
-
split = layout.split(percentage=0.85)
if scene:
split.template_ID(scene, "world", new="world.new")
elif world:
split.template_ID(space, "pin_id")
- if texture_count:
- split.label(text=str(texture_count), icon='TEXTURE')
-
-
-class WORLD_PT_preview(WorldButtonsPanel, Panel):
- bl_label = "Preview"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- return (context.world) and (context.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- self.layout.template_preview(context.world)
-
-
-class WORLD_PT_world(WorldButtonsPanel, Panel):
- bl_label = "World"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw(self, context):
- layout = self.layout
-
- world = context.world
-
- row = layout.row()
- row.prop(world, "use_sky_paper")
- row.prop(world, "use_sky_blend")
- row.prop(world, "use_sky_real")
-
- row = layout.row()
- row.column().prop(world, "horizon_color")
- col = row.column()
- col.prop(world, "zenith_color")
- col.active = world.use_sky_blend
- row.column().prop(world, "ambient_color")
-
- row = layout.row()
- row.prop(world, "exposure")
- row.prop(world, "color_range")
-
-
-class WORLD_PT_ambient_occlusion(WorldButtonsPanel, Panel):
- bl_label = "Ambient Occlusion"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw_header(self, context):
- light = context.world.light_settings
- self.layout.prop(light, "use_ambient_occlusion", text="")
-
- def draw(self, context):
- layout = self.layout
-
- light = context.world.light_settings
-
- layout.active = light.use_ambient_occlusion
-
- split = layout.split()
- split.prop(light, "ao_factor", text="Factor")
- split.prop(light, "ao_blend_type", text="")
-
-
-class WORLD_PT_environment_lighting(WorldButtonsPanel, Panel):
- bl_label = "Environment Lighting"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw_header(self, context):
- light = context.world.light_settings
- self.layout.prop(light, "use_environment_light", text="")
-
- def draw(self, context):
- layout = self.layout
-
- light = context.world.light_settings
-
- layout.active = light.use_environment_light
-
- split = layout.split()
- split.prop(light, "environment_energy", text="Energy")
- split.prop(light, "environment_color", text="")
-
-
-class WORLD_PT_indirect_lighting(WorldButtonsPanel, Panel):
- bl_label = "Indirect Lighting"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw_header(self, context):
- light = context.world.light_settings
- self.layout.prop(light, "use_indirect_light", text="")
-
- def draw(self, context):
- layout = self.layout
-
- light = context.world.light_settings
-
- layout.active = light.use_indirect_light and light.gather_method == 'APPROXIMATE'
-
- split = layout.split()
- split.prop(light, "indirect_factor", text="Factor")
- split.prop(light, "indirect_bounces", text="Bounces")
-
- if light.gather_method == 'RAYTRACE':
- layout.label(text="Only works with Approximate gather method")
-
-
-class WORLD_PT_gather(WorldButtonsPanel, Panel):
- bl_label = "Gather"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw(self, context):
- layout = self.layout
-
- light = context.world.light_settings
-
- layout.active = light.use_ambient_occlusion or light.use_environment_light or light.use_indirect_light
-
- layout.row().prop(light, "gather_method", expand=True)
-
- split = layout.split()
-
- col = split.column()
- col.label(text="Attenuation:")
- if light.gather_method == 'RAYTRACE':
- col.prop(light, "distance")
- col.prop(light, "use_falloff")
- sub = col.row()
- sub.active = light.use_falloff
- sub.prop(light, "falloff_strength", text="Strength")
-
- if light.gather_method == 'RAYTRACE':
- col = split.column()
-
- col.label(text="Sampling:")
- col.prop(light, "sample_method", text="")
-
- sub = col.column()
- sub.prop(light, "samples")
-
- if light.sample_method == 'ADAPTIVE_QMC':
- sub.prop(light, "threshold")
- sub.prop(light, "adapt_to_speed", slider=True)
- elif light.sample_method == 'CONSTANT_JITTERED':
- sub.prop(light, "bias")
-
- if light.gather_method == 'APPROXIMATE':
- col = split.column()
-
- col.label(text="Sampling:")
- col.prop(light, "passes")
- col.prop(light, "error_threshold", text="Error")
- col.prop(light, "use_cache")
- col.prop(light, "correction")
-
-
-class WORLD_PT_mist(WorldButtonsPanel, Panel):
- bl_label = "Mist"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- def draw_header(self, context):
- world = context.world
-
- self.layout.prop(world.mist_settings, "use_mist", text="")
-
- def draw(self, context):
- layout = self.layout
-
- world = context.world
-
- layout.active = world.mist_settings.use_mist
-
- split = layout.split()
-
- col = split.column()
- col.prop(world.mist_settings, "intensity")
- col.prop(world.mist_settings, "start")
-
- col = split.column()
- col.prop(world.mist_settings, "depth")
- col.prop(world.mist_settings, "height")
-
- layout.prop(world.mist_settings, "falloff")
-
class EEVEE_WORLD_PT_mist(WorldButtonsPanel, Panel):
bl_label = "Mist Pass"
@@ -271,7 +85,7 @@ class EEVEE_WORLD_PT_mist(WorldButtonsPanel, Panel):
class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_EEVEE'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
_context_path = "world"
_property_type = bpy.types.World
@@ -312,13 +126,6 @@ class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel):
classes = (
WORLD_PT_context_world,
- WORLD_PT_preview,
- WORLD_PT_world,
- WORLD_PT_ambient_occlusion,
- WORLD_PT_environment_lighting,
- WORLD_PT_indirect_lighting,
- WORLD_PT_gather,
- WORLD_PT_mist,
WORLD_PT_custom_props,
EEVEE_WORLD_PT_surface,
EEVEE_WORLD_PT_mist,
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 371ab088190..1b8582ba8f2 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -20,6 +20,7 @@
import bpy
from bpy.types import Header, Menu
+from .space_time import *
#######################################
@@ -114,14 +115,35 @@ class DOPESHEET_HT_header(Header):
layout = self.layout
st = context.space_data
- toolsettings = context.tool_settings
row = layout.row(align=True)
row.template_header()
+
+ # XXX: perhaps our mode menu can be retired eventually when we get editor submodes in the main menu?
+ layout.prop(st, "mode", text="")
- DOPESHEET_MT_editor_menus.draw_collapsible(context, layout)
+ if st.mode == 'TIMELINE':
+ TIME_MT_editor_menus.draw_collapsible(context, layout)
+ TIME_HT_editor_buttons.draw_header(context, layout)
+ else:
+ DOPESHEET_MT_editor_menus.draw_collapsible(context, layout)
+ DOPESHEET_HT_editor_buttons.draw_header(context, layout)
- layout.prop(st, "mode", text="")
+
+# Header for "normal" dopesheet editor modes (e.g. Dope Sheet, Action, Shape Keys, etc.)
+# XXX: Temporary, until we have editor submodes in the actual editors menu
+class DOPESHEET_HT_editor_buttons(Header):
+ bl_idname = "DOPESHEET_HT_editor_buttons"
+ bl_space_type = 'DOPESHEET_EDITOR'
+ bl_label = ""
+
+ def draw(self, context):
+ pass
+
+ @staticmethod
+ def draw_header(context, layout):
+ st = context.space_data
+ toolsettings = context.tool_settings
if st.mode in {'ACTION', 'SHAPEKEY'}:
row = layout.row(align=True)
@@ -451,6 +473,7 @@ class DOPESHEET_MT_delete(Menu):
classes = (
DOPESHEET_HT_header,
+ DOPESHEET_HT_editor_buttons,
DOPESHEET_MT_editor_menus,
DOPESHEET_MT_view,
DOPESHEET_MT_select,
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 123e95c013c..1877e299d70 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -614,50 +614,6 @@ class IMAGE_PT_image_properties(Panel):
layout.template_image(sima, "image", iuser, multiview=True)
-class IMAGE_PT_game_properties(Panel):
- bl_space_type = 'IMAGE_EDITOR'
- bl_region_type = 'UI'
- bl_label = "Game Properties"
-
- @classmethod
- def poll(cls, context):
- sima = context.space_data
- # display even when not in game mode because these settings effect the 3d view
- return (sima and sima.image and not sima.show_maskedit) # and (view_render.engine == 'BLENDER_GAME')
-
- def draw(self, context):
- layout = self.layout
-
- sima = context.space_data
- ima = sima.image
-
- split = layout.split()
- col = split.column()
- col.prop(ima, "use_animation")
- sub = col.column(align=True)
- sub.active = ima.use_animation
- sub.prop(ima, "frame_start", text="Start")
- sub.prop(ima, "frame_end", text="End")
- sub.prop(ima, "fps", text="Speed")
-
- col = split.column()
- col.prop(ima, "use_tiles")
- sub = col.column(align=True)
- sub.active = ima.use_tiles or ima.use_animation
- sub.prop(ima, "tiles_x", text="X")
- sub.prop(ima, "tiles_y", text="Y")
-
- split = layout.split()
- col = split.column()
- col.label(text="Clamp:")
- col.prop(ima, "use_clamp_x", text="X")
- col.prop(ima, "use_clamp_y", text="Y")
-
- col = split.column()
- col.label(text="Mapping:")
- col.prop(ima, "mapping", expand=True)
-
-
class IMAGE_PT_view_properties(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
@@ -1363,7 +1319,6 @@ classes = (
IMAGE_PT_active_mask_spline,
IMAGE_PT_active_mask_point,
IMAGE_PT_image_properties,
- IMAGE_PT_game_properties,
IMAGE_PT_view_properties,
IMAGE_PT_tools_transform_uvs,
IMAGE_PT_tools_align_uvs,
diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index cbe6449d1df..5460a8d44b2 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -26,362 +26,13 @@ class INFO_HT_header(Header):
def draw(self, context):
layout = self.layout
+ layout.template_header()
- window = context.window
- workspace = context.workspace
- screen = context.screen
- scene = context.scene
- layer = context.view_layer
- view_render = workspace.view_render
-
- row = layout.row(align=True)
- row.template_header()
-
- INFO_MT_editor_menus.draw_collapsible(context, layout)
-
- layout.separator()
-
- if screen.show_fullscreen:
- layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
- layout.separator()
- else:
- layout.template_ID(window, "workspace", new="workspace.workspace_add_menu", unlink="workspace.workspace_delete")
- layout.template_search_preview(window, "screen", workspace, "screens", new="screen.new", unlink="screen.delete", rows=2, cols=6)
-
- if layer.objects.active:
- act_mode_item = bpy.types.Object.bl_rna.properties["mode"].enum_items[layer.objects.active.mode]
- layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon)
-
- row = layout.row()
- row.active = not workspace.use_scene_settings
- # Active workspace view-layer is retrieved through window, not through workspace.
- row.template_search(window, "view_layer", scene, "view_layers")
-
- if view_render.has_multiple_engines:
- row.prop(view_render, "engine", text="")
-
- layout.separator()
-
- layout.template_ID(window, "scene", new="scene.new", unlink="scene.delete")
-
- layout.separator()
-
- layout.template_running_jobs()
-
- layout.template_reports_banner()
-
- row = layout.row(align=True)
-
- if bpy.app.autoexec_fail is True and bpy.app.autoexec_fail_quiet is False:
- row.label("Auto-run disabled", icon='ERROR')
- if bpy.data.is_saved:
- props = row.operator("wm.revert_mainfile", icon='SCREEN_BACK', text="Reload Trusted")
- props.use_scripts = True
-
- row.operator("script.autoexec_warn_clear", text="Ignore")
-
- # include last so text doesn't push buttons out of the header
- row.label(bpy.app.autoexec_fail_message)
- return
-
- row.operator("wm.splash", text="", icon='BLENDER', emboss=False)
- row.label(text=scene.statistics(context.view_layer), translate=False)
-
-
-class INFO_MT_editor_menus(Menu):
- bl_idname = "INFO_MT_editor_menus"
- bl_label = ""
-
- def draw(self, context):
- self.draw_menus(self.layout, context)
-
- @staticmethod
- def draw_menus(layout, context):
- view_render = context.view_render
-
- layout.menu("INFO_MT_file")
-
- if view_render.use_game_engine:
- layout.menu("INFO_MT_game")
- else:
- layout.menu("INFO_MT_render")
-
- layout.menu("INFO_MT_window")
- layout.menu("INFO_MT_help")
-
-
-class INFO_MT_file(Menu):
- bl_label = "File"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator_context = 'INVOKE_AREA'
- layout.operator("wm.read_homefile", text="New", icon='NEW')
- layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
- layout.menu("INFO_MT_file_open_recent", icon='OPEN_RECENT')
- layout.operator("wm.revert_mainfile", icon='FILE_REFRESH')
- layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
- layout.operator("wm.recover_auto_save", text="Recover Auto Save...", icon='RECOVER_AUTO')
-
- layout.separator()
-
- layout.operator_context = 'EXEC_AREA' if context.blend_data.is_saved else 'INVOKE_AREA'
- layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK')
-
- layout.operator_context = 'INVOKE_AREA'
- layout.operator("wm.save_as_mainfile", text="Save As...", icon='SAVE_AS')
- layout.operator_context = 'INVOKE_AREA'
- layout.operator("wm.save_as_mainfile", text="Save Copy...", icon='SAVE_COPY').copy = True
-
- layout.separator()
-
- layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
-
- layout.operator_context = 'INVOKE_AREA'
- layout.operator("wm.save_homefile", icon='SAVE_PREFS')
- layout.operator("wm.read_factory_settings", icon='LOAD_FACTORY')
-
- if any(bpy.utils.app_template_paths()):
- app_template = context.user_preferences.app_template
- if app_template:
- layout.operator(
- "wm.read_factory_settings",
- text="Load Factory Template Settings",
- icon='LOAD_FACTORY',
- ).app_template = app_template
- del app_template
-
- layout.menu("USERPREF_MT_app_templates", icon='FILE_BLEND')
-
- layout.separator()
-
- layout.operator_context = 'INVOKE_AREA'
- layout.operator("wm.link", text="Link", icon='LINK_BLEND')
- layout.operator("wm.append", text="Append", icon='APPEND_BLEND')
- layout.menu("INFO_MT_file_previews")
-
- layout.separator()
-
- layout.menu("INFO_MT_file_import", icon='IMPORT')
- layout.menu("INFO_MT_file_export", icon='EXPORT')
-
- layout.separator()
-
- layout.menu("INFO_MT_file_external_data", icon='EXTERNAL_DATA')
- layout.operator("wm.blend_strings_utf8_validate", icon='FILE_BLEND')
-
- layout.separator()
-
- layout.operator_context = 'EXEC_AREA'
- if bpy.data.is_dirty and context.user_preferences.view.use_quit_dialog:
- layout.operator_context = 'INVOKE_SCREEN' # quit dialog
- layout.operator("wm.quit_blender", text="Quit", icon='QUIT')
-
-
-class INFO_MT_file_import(Menu):
- bl_idname = "INFO_MT_file_import"
- bl_label = "Import"
-
- def draw(self, context):
- if bpy.app.build_options.collada:
- self.layout.operator("wm.collada_import", text="Collada (Default) (.dae)")
- if bpy.app.build_options.alembic:
- self.layout.operator("wm.alembic_import", text="Alembic (.abc)")
-
-
-class INFO_MT_file_export(Menu):
- bl_idname = "INFO_MT_file_export"
- bl_label = "Export"
-
- def draw(self, context):
- if bpy.app.build_options.collada:
- self.layout.operator("wm.collada_export", text="Collada (Default) (.dae)")
- if bpy.app.build_options.alembic:
- self.layout.operator("wm.alembic_export", text="Alembic (.abc)")
-
-
-class INFO_MT_file_external_data(Menu):
- bl_label = "External Data"
-
- def draw(self, context):
- layout = self.layout
-
- icon = 'CHECKBOX_HLT' if bpy.data.use_autopack else 'CHECKBOX_DEHLT'
- layout.operator("file.autopack_toggle", icon=icon)
-
- layout.separator()
-
- pack_all = layout.row()
- pack_all.operator("file.pack_all")
- pack_all.active = not bpy.data.use_autopack
-
- unpack_all = layout.row()
- unpack_all.operator("file.unpack_all")
- unpack_all.active = not bpy.data.use_autopack
-
- layout.separator()
-
- layout.operator("file.make_paths_relative")
- layout.operator("file.make_paths_absolute")
- layout.operator("file.report_missing_files")
- layout.operator("file.find_missing_files")
-
-
-class INFO_MT_file_previews(Menu):
- bl_label = "Data Previews"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator("wm.previews_ensure")
- layout.operator("wm.previews_batch_generate")
-
- layout.separator()
-
- layout.operator("wm.previews_clear")
- layout.operator("wm.previews_batch_clear")
-
-
-class INFO_MT_game(Menu):
- bl_label = "Game"
-
- def draw(self, context):
- layout = self.layout
-
- gs = context.scene.game_settings
-
- layout.operator("view3d.game_start")
-
- layout.separator()
-
- layout.prop(gs, "show_debug_properties")
- layout.prop(gs, "show_framerate_profile")
- layout.prop(gs, "show_physics_visualization")
- layout.prop(gs, "use_deprecation_warnings")
- layout.prop(gs, "use_animation_record")
- layout.separator()
- layout.prop(gs, "use_auto_start")
-
-
-class INFO_MT_render(Menu):
- bl_label = "Render"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator("render.render", text="Render Image", icon='RENDER_STILL').use_viewport = True
- props = layout.operator("render.render", text="Render Animation", icon='RENDER_ANIMATION')
- props.animation = True
- props.use_viewport = True
-
- layout.separator()
-
- layout.operator("render.opengl", text="OpenGL Render Image")
- layout.operator("render.opengl", text="OpenGL Render Animation").animation = True
- layout.menu("INFO_MT_opengl_render")
-
- layout.separator()
-
- layout.operator("render.view_show")
- layout.operator("render.play_rendered_anim", icon='PLAY')
-
-
-class INFO_MT_opengl_render(Menu):
- bl_label = "OpenGL Render Options"
-
- def draw(self, context):
- layout = self.layout
-
- rd = context.scene.render
- layout.prop(rd, "use_antialiasing")
- layout.prop(rd, "use_full_sample")
-
- layout.prop_menu_enum(rd, "antialiasing_samples")
- layout.prop_menu_enum(rd, "alpha_mode")
-
-
-class INFO_MT_window(Menu):
- bl_label = "Window"
-
- def draw(self, context):
- import sys
-
- layout = self.layout
-
- layout.operator("wm.window_new")
- layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER')
-
- layout.separator()
-
- layout.operator("screen.screenshot")
- layout.operator("screen.screencast")
-
- if sys.platform[:3] == "win":
- layout.separator()
- layout.operator("wm.console_toggle", icon='CONSOLE')
-
- if context.scene.render.use_multiview:
- layout.separator()
- layout.operator("wm.set_stereo_3d", icon='CAMERA_STEREO')
-
-
-class INFO_MT_help(Menu):
- bl_label = "Help"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator(
- "wm.url_open", text="Manual", icon='HELP',
- ).url = "https://docs.blender.org/manual/en/dev/"
- layout.operator(
- "wm.url_open", text="Release Log", icon='URL',
- ).url = "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/%d.%d" % bpy.app.version[:2]
- layout.separator()
-
- layout.operator(
- "wm.url_open", text="Blender Website", icon='URL',
- ).url = "https://www.blender.org"
- layout.operator(
- "wm.url_open", text="Blender Store", icon='URL',
- ).url = "https://store.blender.org"
- layout.operator(
- "wm.url_open", text="Developer Community", icon='URL',
- ).url = "https://www.blender.org/get-involved/"
- layout.operator(
- "wm.url_open", text="User Community", icon='URL',
- ).url = "https://www.blender.org/support/user-community"
- layout.separator()
- layout.operator(
- "wm.url_open", text="Report a Bug", icon='URL',
- ).url = "https://developer.blender.org/maniphest/task/edit/form/1"
- 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("wm.splash", icon='BLENDER')
-
+ # Empty for now until info editor gets turned into log editor
+ pass
classes = (
INFO_HT_header,
- INFO_MT_editor_menus,
- INFO_MT_file,
- INFO_MT_file_import,
- INFO_MT_file_export,
- INFO_MT_file_external_data,
- INFO_MT_file_previews,
- INFO_MT_game,
- INFO_MT_render,
- INFO_MT_opengl_render,
- INFO_MT_window,
- INFO_MT_help,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_logic.py b/release/scripts/startup/bl_ui/space_logic.py
deleted file mode 100644
index b552181f491..00000000000
--- a/release/scripts/startup/bl_ui/space_logic.py
+++ /dev/null
@@ -1,145 +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 #####
-
-# <pep8 compliant>
-import bpy
-from bpy.types import Header, Menu, Panel
-
-
-class LOGIC_PT_properties(Panel):
- bl_space_type = 'LOGIC_EDITOR'
- bl_region_type = 'UI'
- bl_label = "Properties"
-
- @classmethod
- def poll(cls, context):
- ob = context.active_object
- return ob and ob.game
-
- def draw(self, context):
- layout = self.layout
-
- ob = context.active_object
- game = ob.game
- is_font = (ob.type == 'FONT')
-
- if is_font:
- prop_index = game.properties.find("Text")
- if prop_index != -1:
- layout.operator("object.game_property_remove", text="Remove Text Game Property", icon='X').index = prop_index
- row = layout.row()
- sub = row.row()
- sub.enabled = 0
- prop = game.properties[prop_index]
- sub.prop(prop, "name", text="")
- row.prop(prop, "type", text="")
- # get the property from the body, not the game property
- # note, don't do this - it's too slow and body can potentially be a really long string.
- #~ row.prop(ob.data, "body", text="")
- row.label("See Text Object")
- else:
- props = layout.operator("object.game_property_new", text="Add Text Game Property", icon='ZOOMIN')
- props.name = "Text"
- props.type = 'STRING'
-
- props = layout.operator("object.game_property_new", text="Add Game Property", icon='ZOOMIN')
- props.name = ""
-
- for i, prop in enumerate(game.properties):
-
- if is_font and i == prop_index:
- continue
-
- box = layout.box()
- row = box.row()
- row.prop(prop, "name", text="")
- row.prop(prop, "type", text="")
- row.prop(prop, "value", text="")
- row.prop(prop, "show_debug", text="", toggle=True, icon='INFO')
- sub = row.row(align=True)
- props = sub.operator("object.game_property_move", text="", icon='TRIA_UP')
- props.index = i
- props.direction = 'UP'
- props = sub.operator("object.game_property_move", text="", icon='TRIA_DOWN')
- props.index = i
- props.direction = 'DOWN'
- row.operator("object.game_property_remove", text="", icon='X', emboss=False).index = i
-
-
-class LOGIC_MT_logicbricks_add(Menu):
- bl_label = "Add"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator_menu_enum("logic.sensor_add", "type", text="Sensor")
- layout.operator_menu_enum("logic.controller_add", "type", text="Controller")
- layout.operator_menu_enum("logic.actuator_add", "type", text="Actuator")
-
-
-class LOGIC_HT_header(Header):
- bl_space_type = 'LOGIC_EDITOR'
-
- def draw(self, context):
- layout = self.layout.row(align=True)
-
- layout.template_header()
-
- LOGIC_MT_editor_menus.draw_collapsible(context, layout)
-
-
-class LOGIC_MT_editor_menus(Menu):
- bl_idname = "LOGIC_MT_editor_menus"
- bl_label = ""
-
- def draw(self, context):
- self.draw_menus(self.layout, context)
-
- @staticmethod
- def draw_menus(layout, context):
- layout.menu("LOGIC_MT_view")
- layout.menu("LOGIC_MT_logicbricks_add")
-
-
-class LOGIC_MT_view(Menu):
- bl_label = "View"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator("logic.properties", icon='MENU_PANEL')
-
- layout.separator()
-
- layout.operator("screen.area_dupli")
- layout.operator("screen.screen_full_area")
- layout.operator("screen.screen_full_area", text="Toggle Fullscreen Area").use_hide_panels = True
-
-
-classes = (
- LOGIC_PT_properties,
- LOGIC_MT_logicbricks_add,
- LOGIC_HT_header,
- LOGIC_MT_editor_menus,
- LOGIC_MT_view,
-)
-
-if __name__ == "__main__": # only for live edit.
- from bpy.utils import register_class
- for cls in classes:
- register_class(cls)
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 2f98585f538..f97c88be0ad 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -51,14 +51,12 @@ class NODE_HT_header(Header):
NODE_MT_editor_menus.draw_collapsible(context, layout)
layout.prop(snode, "tree_type", text="", expand=True)
- use_shading_nodes = scene.view_render.use_shading_nodes or context.view_render.use_shading_nodes
if snode.tree_type == 'ShaderNodeTree':
- if use_shading_nodes:
- layout.prop(snode, "shader_type", text="", expand=True)
+ layout.prop(snode, "shader_type", text="", expand=True)
ob = context.object
- if (not use_shading_nodes or snode.shader_type == 'OBJECT') and ob:
+ if snode.shader_type == 'OBJECT' and ob:
row = layout.row()
# disable material slot buttons when pinned, cannot find correct slot within id_from (#36589)
row.enabled = not snode.pin
@@ -69,18 +67,18 @@ class NODE_HT_header(Header):
if id_from and ob.type != 'LAMP':
row.template_ID(id_from, "active_material", new="material.new")
- # Don't show "Use Nodes" Button when Engine is BI for Lamps
- if snode_id and not (use_shading_nodes == 0 and ob.type == 'LAMP'):
+ # No shader nodes for Eevee lamps
+ if snode_id and not (context.engine == 'BLENDER_EEVEE' and ob.type == 'LAMP'):
layout.prop(snode_id, "use_nodes")
- if use_shading_nodes and snode.shader_type == 'WORLD':
+ if snode.shader_type == 'WORLD':
row = layout.row()
row.enabled = not snode.pin
row.template_ID(scene, "world", new="world.new")
if snode_id:
row.prop(snode_id, "use_nodes")
- if use_shading_nodes and snode.shader_type == 'LINESTYLE':
+ if snode.shader_type == 'LINESTYLE':
view_layer = context.scene.view_layers.active
lineset = view_layer.freestyle_settings.linesets.active
if lineset is not None:
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 0697cf8e56b..ca9c4465116 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -1288,7 +1288,7 @@ class SEQUENCER_PT_grease_pencil_tools(GreasePencilToolsPanel, SequencerButtonsP
class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
_context_path = "scene.sequence_editor.active_strip"
_property_type = (bpy.types.Sequence,)
bl_category = "Strip"
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py
index 9026a93aa99..c1c73c35258 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -21,23 +21,23 @@ import bpy
from bpy.types import Header, Menu
-class TIME_HT_header(Header):
- bl_space_type = 'TIMELINE'
+# Header buttons for timeline header (play, etc.)
+class TIME_HT_editor_buttons(Header):
+ bl_idname = "TIME_HT_editor_buttons"
+ bl_space_type = 'DOPESHEET_EDITOR'
+ bl_label = ""
def draw(self, context):
- layout = self.layout
+ pass
+ @staticmethod
+ def draw_header(context, layout):
scene = context.scene
toolsettings = context.tool_settings
screen = context.screen
userprefs = context.user_preferences
row = layout.row(align=True)
- row.template_header()
-
- TIME_MT_editor_menus.draw_collapsible(context, layout)
-
- 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)
@@ -191,8 +191,8 @@ class TIME_MT_frame(Menu):
layout.operator("anim.previewrange_clear")
layout.operator("anim.previewrange_set")
layout.separator()
- layout.operator("time.end_frame_set")
- layout.operator("time.start_frame_set")
+ layout.operator("anim.end_frame_set")
+ layout.operator("anim.start_frame_set")
layout.separator()
@@ -271,7 +271,7 @@ def marker_menu_generic(layout):
classes = (
- TIME_HT_header,
+ TIME_HT_editor_buttons,
TIME_MT_editor_menus,
TIME_MT_marker,
TIME_MT_view,
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 88816a3ea9f..d08c7cd8815 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -53,11 +53,11 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
# for reuse
_tools_transform = (
- ("Translate", None,
+ ("Translate", "TRANSFORM_WGT_manipulator",
(("transform.translate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),)),
- ("Rotate", None,
+ ("Rotate", "TRANSFORM_WGT_manipulator",
(("transform.rotate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),)),
- ("Scale", None,
+ ("Scale", "TRANSFORM_WGT_manipulator",
(("transform.resize", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),)),
("Scale Cage", "VIEW3D_WGT_xform_cage", None),
None,
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
new file mode 100644
index 00000000000..d9af1eb2efa
--- /dev/null
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -0,0 +1,397 @@
+# ##### 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 #####
+
+# <pep8 compliant>
+import bpy
+from bpy.types import Header, Menu, Panel
+
+
+class TOPBAR_HT_upper_bar(Header):
+ bl_space_type = 'TOPBAR'
+
+ def draw(self, context):
+ region = context.region
+
+ if region.alignment == 'RIGHT':
+ self.draw_right(context)
+ else:
+ self.draw_left(context)
+
+ def draw_left(self, context):
+ layout = self.layout
+
+ window = context.window
+ screen = context.screen
+
+ layout.operator("wm.splash", text="", icon='BLENDER', emboss=False)
+
+ INFO_MT_editor_menus.draw_collapsible(context, layout)
+
+ layout.separator()
+
+ if not screen.show_fullscreen:
+ layout.template_ID_tabs(window, "workspace", new="workspace.workspace_add_menu", unlink="workspace.workspace_delete")
+ else:
+ layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
+
+ layout.separator()
+
+ layout.template_running_jobs()
+
+ layout.template_reports_banner()
+
+ row = layout.row(align=True)
+
+ if bpy.app.autoexec_fail is True and bpy.app.autoexec_fail_quiet is False:
+ row.label("Auto-run disabled", icon='ERROR')
+ if bpy.data.is_saved:
+ props = row.operator("wm.revert_mainfile", icon='SCREEN_BACK', text="Reload Trusted")
+ props.use_scripts = True
+
+ row.operator("script.autoexec_warn_clear", text="Ignore")
+
+ # include last so text doesn't push buttons out of the header
+ row.label(bpy.app.autoexec_fail_message)
+ return
+
+ def draw_right(self, context):
+ layout = self.layout
+
+ window = context.window
+ scene = window.scene
+
+ # Active workspace view-layer is retrieved through window, not through workspace.
+ layout.template_ID(window, "scene", new="scene.new", unlink="scene.delete")
+ layout.template_search(window, "view_layer", scene, "view_layers")
+
+
+class TOPBAR_HT_lower_bar(Header):
+ bl_space_type = 'TOPBAR'
+ bl_region_type = 'WINDOW'
+
+ def draw(self, context):
+ layout = self.layout
+ region = context.region
+
+ if region.alignment == 'LEFT':
+ self.draw_left(context)
+ elif region.alignment == 'RIGHT':
+ self.draw_right(context)
+ else:
+ # WITH_REDO_REGION_REMOVAL:
+ # layout.template_operator_redo_props()
+ pass
+
+ def draw_left(self, context):
+ layout = self.layout
+ layer = context.view_layer
+ object = layer.objects.active
+ object_mode = 'OBJECT' if object is None else object.mode
+ act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[object_mode]
+ layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon)
+
+ def draw_right(self, context):
+ layout = self.layout
+
+ # Placeholder
+ layout.operator("ed.undo_history", text="...")
+
+
+class INFO_MT_editor_menus(Menu):
+ bl_idname = "INFO_MT_editor_menus"
+ bl_label = ""
+
+ def draw(self, context):
+ self.draw_menus(self.layout, context)
+
+ @staticmethod
+ def draw_menus(layout, context):
+ layout.menu("INFO_MT_file")
+
+ layout.menu("INFO_MT_render")
+
+ layout.menu("INFO_MT_window")
+ layout.menu("INFO_MT_help")
+
+
+class INFO_MT_file(Menu):
+ bl_label = "File"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator_context = 'INVOKE_AREA'
+ layout.operator("wm.read_homefile", text="New", icon='NEW')
+ layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
+ layout.menu("INFO_MT_file_open_recent", icon='OPEN_RECENT')
+ layout.operator("wm.revert_mainfile", icon='FILE_REFRESH')
+ layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
+ layout.operator("wm.recover_auto_save", text="Recover Auto Save...", icon='RECOVER_AUTO')
+
+ layout.separator()
+
+ layout.operator_context = 'EXEC_AREA' if context.blend_data.is_saved else 'INVOKE_AREA'
+ layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK')
+
+ layout.operator_context = 'INVOKE_AREA'
+ layout.operator("wm.save_as_mainfile", text="Save As...", icon='SAVE_AS')
+ layout.operator_context = 'INVOKE_AREA'
+ layout.operator("wm.save_as_mainfile", text="Save Copy...", icon='SAVE_COPY').copy = True
+
+ layout.separator()
+
+ layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
+
+ layout.operator_context = 'INVOKE_AREA'
+ layout.operator("wm.save_homefile", icon='SAVE_PREFS')
+ layout.operator("wm.read_factory_settings", icon='LOAD_FACTORY')
+
+ layout.separator()
+
+ layout.operator_context = 'INVOKE_AREA'
+ layout.operator("wm.link", text="Link", icon='LINK_BLEND')
+ layout.operator("wm.append", text="Append", icon='APPEND_BLEND')
+ layout.menu("INFO_MT_file_previews")
+
+ layout.separator()
+
+ layout.menu("INFO_MT_file_import", icon='IMPORT')
+ layout.menu("INFO_MT_file_export", icon='EXPORT')
+
+ layout.separator()
+
+ layout.menu("INFO_MT_file_external_data", icon='EXTERNAL_DATA')
+
+ layout.separator()
+
+ layout.operator_context = 'EXEC_AREA'
+ if bpy.data.is_dirty and context.user_preferences.view.use_quit_dialog:
+ layout.operator_context = 'INVOKE_SCREEN' # quit dialog
+ layout.operator("wm.quit_blender", text="Quit", icon='QUIT')
+
+
+class INFO_MT_file_import(Menu):
+ bl_idname = "INFO_MT_file_import"
+ bl_label = "Import"
+
+ def draw(self, context):
+ if bpy.app.build_options.collada:
+ self.layout.operator("wm.collada_import", text="Collada (Default) (.dae)")
+ if bpy.app.build_options.alembic:
+ self.layout.operator("wm.alembic_import", text="Alembic (.abc)")
+
+
+class INFO_MT_file_export(Menu):
+ bl_idname = "INFO_MT_file_export"
+ bl_label = "Export"
+
+ def draw(self, context):
+ if bpy.app.build_options.collada:
+ self.layout.operator("wm.collada_export", text="Collada (Default) (.dae)")
+ if bpy.app.build_options.alembic:
+ self.layout.operator("wm.alembic_export", text="Alembic (.abc)")
+
+
+class INFO_MT_file_external_data(Menu):
+ bl_label = "External Data"
+
+ def draw(self, context):
+ layout = self.layout
+
+ icon = 'CHECKBOX_HLT' if bpy.data.use_autopack else 'CHECKBOX_DEHLT'
+ layout.operator("file.autopack_toggle", icon=icon)
+
+ layout.separator()
+
+ pack_all = layout.row()
+ pack_all.operator("file.pack_all")
+ pack_all.active = not bpy.data.use_autopack
+
+ unpack_all = layout.row()
+ unpack_all.operator("file.unpack_all")
+ unpack_all.active = not bpy.data.use_autopack
+
+ layout.separator()
+
+ layout.operator("file.make_paths_relative")
+ layout.operator("file.make_paths_absolute")
+ layout.operator("file.report_missing_files")
+ layout.operator("file.find_missing_files")
+
+
+class INFO_MT_file_previews(Menu):
+ bl_label = "Data Previews"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator("wm.previews_ensure")
+ layout.operator("wm.previews_batch_generate")
+
+ layout.separator()
+
+ layout.operator("wm.previews_clear")
+ layout.operator("wm.previews_batch_clear")
+
+
+class INFO_MT_game(Menu):
+ bl_label = "Game"
+
+ def draw(self, context):
+ layout = self.layout
+
+ gs = context.scene.game_settings
+
+ layout.operator("view3d.game_start")
+
+ layout.separator()
+
+ layout.prop(gs, "show_debug_properties")
+ layout.prop(gs, "show_framerate_profile")
+ layout.prop(gs, "show_physics_visualization")
+ layout.prop(gs, "use_deprecation_warnings")
+ layout.prop(gs, "use_animation_record")
+ layout.separator()
+ layout.prop(gs, "use_auto_start")
+
+
+class INFO_MT_render(Menu):
+ bl_label = "Render"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator("render.render", text="Render Image", icon='RENDER_STILL').use_viewport = True
+ props = layout.operator("render.render", text="Render Animation", icon='RENDER_ANIMATION')
+ props.animation = True
+ props.use_viewport = True
+
+ layout.separator()
+
+ layout.operator("render.opengl", text="OpenGL Render Image")
+ layout.operator("render.opengl", text="OpenGL Render Animation").animation = True
+ layout.menu("INFO_MT_opengl_render")
+
+ layout.separator()
+
+ layout.operator("render.view_show")
+ layout.operator("render.play_rendered_anim", icon='PLAY')
+
+
+class INFO_MT_opengl_render(Menu):
+ bl_label = "OpenGL Render Options"
+
+ def draw(self, context):
+ layout = self.layout
+
+ rd = context.scene.render
+ layout.prop(rd, "use_antialiasing")
+ layout.prop(rd, "use_full_sample")
+
+ layout.prop_menu_enum(rd, "antialiasing_samples")
+ layout.prop_menu_enum(rd, "alpha_mode")
+
+
+class INFO_MT_window(Menu):
+ bl_label = "Window"
+
+ def draw(self, context):
+ import sys
+
+ layout = self.layout
+
+ layout.operator("wm.window_new")
+ layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER')
+
+ layout.separator()
+
+ layout.operator("screen.screenshot")
+ layout.operator("screen.screencast")
+
+ if sys.platform[:3] == "win":
+ layout.separator()
+ layout.operator("wm.console_toggle", icon='CONSOLE')
+
+ if context.scene.render.use_multiview:
+ layout.separator()
+ layout.operator("wm.set_stereo_3d", icon='CAMERA_STEREO')
+
+
+class INFO_MT_help(Menu):
+ bl_label = "Help"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator(
+ "wm.url_open", text="Manual", icon='HELP',
+ ).url = "https://docs.blender.org/manual/en/dev/"
+ layout.operator(
+ "wm.url_open", text="Release Log", icon='URL',
+ ).url = "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/%d.%d" % bpy.app.version[:2]
+ layout.separator()
+
+ layout.operator(
+ "wm.url_open", text="Blender Website", icon='URL',
+ ).url = "https://www.blender.org"
+ layout.operator(
+ "wm.url_open", text="Blender Store", icon='URL',
+ ).url = "https://store.blender.org"
+ layout.operator(
+ "wm.url_open", text="Developer Community", icon='URL',
+ ).url = "https://www.blender.org/get-involved/"
+ layout.operator(
+ "wm.url_open", text="User Community", icon='URL',
+ ).url = "https://www.blender.org/support/user-community"
+ layout.separator()
+ layout.operator(
+ "wm.url_open", text="Report a Bug", icon='URL',
+ ).url = "https://developer.blender.org/maniphest/task/edit/form/1"
+ 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("wm.splash", icon='BLENDER')
+
+
+classes = (
+ TOPBAR_HT_upper_bar,
+ TOPBAR_HT_lower_bar,
+ INFO_MT_editor_menus,
+ INFO_MT_file,
+ INFO_MT_file_import,
+ INFO_MT_file_export,
+ INFO_MT_file_external_data,
+ INFO_MT_file_previews,
+ INFO_MT_game,
+ INFO_MT_render,
+ INFO_MT_opengl_render,
+ INFO_MT_window,
+ INFO_MT_help,
+)
+
+if __name__ == "__main__": # only for live edit.
+ from bpy.utils import register_class
+ for cls in classes:
+ register_class(cls)
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 3449280f862..9afda6b77bf 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -520,7 +520,6 @@ class USERPREF_PT_system(Panel):
col = colsplit.column()
col.label(text="OpenGL:")
col.prop(system, "gl_clip_alpha", slider=True)
- col.prop(system, "use_mipmaps")
col.prop(system, "use_gpu_mipmap")
col.prop(system, "use_16bit_textures")
@@ -854,6 +853,9 @@ class USERPREF_PT_theme(Panel):
col.label(text="List Item:")
self._theme_widget_style(col, ui.wcol_list_item)
+ col.label(text="Tab:")
+ self._theme_widget_style(col, ui.wcol_tab)
+
ui_state = theme.user_interface.wcol_state
col.label(text="State:")
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 101afa3bcd9..e601dcde7b2 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1455,10 +1455,6 @@ class VIEW3D_MT_object(Menu):
layout.separator()
- layout.menu("VIEW3D_MT_object_game")
-
- layout.separator()
-
layout.operator_menu_enum("object.convert", "target")
@@ -1567,54 +1563,40 @@ class VIEW3D_MT_object_specials(Menu):
lamp = obj.data
layout.operator_context = 'INVOKE_REGION_WIN'
- use_shading_nodes = context.view_render.use_shading_nodes
-
- if use_shading_nodes:
- emission_node = None
- if lamp.node_tree:
- for node in lamp.node_tree.nodes:
- if getattr(node, "type", None) == 'EMISSION':
- emission_node = node
- break
-
- if emission_node is not None:
- props = layout.operator("wm.context_modal_mouse", text="Strength")
- props.data_path_iter = "selected_editable_objects"
- props.data_path_item = "data.node_tree" \
- ".nodes[\"" + emission_node.name + "\"]" \
- ".inputs[\"Strength\"].default_value"
- props.header_text = "Lamp Strength: %.3f"
- props.input_scale = 0.1
-
- if lamp.type == 'AREA':
- props = layout.operator("wm.context_modal_mouse", text="Size X")
- props.data_path_iter = "selected_editable_objects"
- props.data_path_item = "data.size"
- props.header_text = "Lamp Size X: %.3f"
- if lamp.shape == 'RECTANGLE':
- props = layout.operator("wm.context_modal_mouse", text="Size Y")
- props.data_path_iter = "selected_editable_objects"
- props.data_path_item = "data.size_y"
- props.header_text = "Lamp Size Y: %.3f"
+ emission_node = None
+ if lamp.node_tree:
+ for node in lamp.node_tree.nodes:
+ if getattr(node, "type", None) == 'EMISSION':
+ emission_node = node
+ break
- elif lamp.type in {'SPOT', 'POINT', 'SUN'}:
- props = layout.operator("wm.context_modal_mouse", text="Size")
- props.data_path_iter = "selected_editable_objects"
- props.data_path_item = "data.shadow_soft_size"
- props.header_text = "Lamp Size: %.3f"
- else:
- props = layout.operator("wm.context_modal_mouse", text="Energy")
+ if emission_node is not None:
+ props = layout.operator("wm.context_modal_mouse", text="Strength")
props.data_path_iter = "selected_editable_objects"
- props.data_path_item = "data.energy"
- props.header_text = "Lamp Energy: %.3f"
+ props.data_path_item = "data.node_tree" \
+ ".nodes[\"" + emission_node.name + "\"]" \
+ ".inputs[\"Strength\"].default_value"
+ props.header_text = "Lamp Strength: %.3f"
+ props.input_scale = 0.1
- if lamp.type in {'SPOT', 'AREA', 'POINT'}:
- props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
+ if lamp.type == 'AREA':
+ props = layout.operator("wm.context_modal_mouse", text="Size X")
+ props.data_path_iter = "selected_editable_objects"
+ props.data_path_item = "data.size"
+ props.header_text = "Lamp Size X: %.3f"
+
+ if lamp.shape == 'RECTANGLE':
+ props = layout.operator("wm.context_modal_mouse", text="Size Y")
props.data_path_iter = "selected_editable_objects"
- props.data_path_item = "data.distance"
- props.input_scale = 0.1
- props.header_text = "Lamp Falloff Distance: %.1f"
+ props.data_path_item = "data.size_y"
+ props.header_text = "Lamp Size Y: %.3f"
+
+ elif lamp.type in {'SPOT', 'POINT', 'SUN'}:
+ props = layout.operator("wm.context_modal_mouse", text="Size")
+ props.data_path_iter = "selected_editable_objects"
+ props.data_path_item = "data.shadow_soft_size"
+ props.header_text = "Lamp Size: %.3f"
if lamp.type == 'SPOT':
layout.separator()
@@ -1630,19 +1612,6 @@ class VIEW3D_MT_object_specials(Menu):
props.input_scale = -0.01
props.header_text = "Spot Blend: %.2f"
- if not use_shading_nodes:
- props = layout.operator("wm.context_modal_mouse", text="Clip Start")
- props.data_path_iter = "selected_editable_objects"
- props.data_path_item = "data.shadow_buffer_clip_start"
- props.input_scale = 0.05
- props.header_text = "Clip Start: %.2f"
-
- props = layout.operator("wm.context_modal_mouse", text="Clip End")
- props.data_path_iter = "selected_editable_objects"
- props.data_path_item = "data.shadow_buffer_clip_end"
- props.input_scale = 0.05
- props.header_text = "Clip End: %.2f"
-
layout.separator()
props = layout.operator("object.isolate_type_render")
@@ -1825,26 +1794,6 @@ class VIEW3D_MT_make_links(Menu):
layout.operator("object.join_uvs") # stupid place to add this!
-class VIEW3D_MT_object_game(Menu):
- bl_label = "Game"
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
- layout.operator("object.game_physics_copy", text="Copy Physics Properties")
-
- layout.separator()
-
- layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
- layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
- layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
-
- layout.separator()
-
- layout.operator("object.game_property_clear")
-
-
class VIEW3D_MT_brush(Menu):
bl_label = "Brush"
@@ -3535,6 +3484,8 @@ class VIEW3D_PT_view3d_display(Panel):
col.prop(view, "show_outline_selected")
col.prop(view, "show_all_objects_origin")
col.prop(view, "show_relationship_lines")
+ col.prop(view, "show_face_orientation_overlay")
+ col.prop(view, "show_random_object_colors")
col = layout.column()
col.active = display_all
@@ -3792,11 +3743,11 @@ class VIEW3D_PT_transform_orientations(Panel):
def draw(self, context):
layout = self.layout
- view = context.space_data
- orientation = view.current_orientation
+ scene = context.scene
+ orientation = scene.current_orientation
row = layout.row(align=True)
- row.prop(view, "transform_orientation", text="")
+ row.prop(scene, "transform_orientation", text="")
row.operator("transform.create_orientation", text="", icon='ZOOMIN')
if orientation:
@@ -3805,63 +3756,6 @@ class VIEW3D_PT_transform_orientations(Panel):
row.operator("transform.delete_orientation", text="", icon='X')
-class VIEW3D_PT_etch_a_ton(Panel):
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_label = "Skeleton Sketching"
- bl_options = {'DEFAULT_CLOSED'}
-
- @classmethod
- def poll(cls, context):
- scene = context.space_data
- ob = context.active_object
- return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
-
- def draw_header(self, context):
- layout = self.layout
- toolsettings = context.scene.tool_settings
-
- layout.prop(toolsettings, "use_bone_sketching", text="")
-
- def draw(self, context):
- layout = self.layout
-
- toolsettings = context.scene.tool_settings
-
- col = layout.column()
-
- col.prop(toolsettings, "use_etch_quick")
- col.prop(toolsettings, "use_etch_overdraw")
-
- col.separator()
-
- col.prop(toolsettings, "etch_convert_mode")
-
- if toolsettings.etch_convert_mode == 'LENGTH':
- col.prop(toolsettings, "etch_length_limit")
- elif toolsettings.etch_convert_mode == 'ADAPTIVE':
- col.prop(toolsettings, "etch_adaptive_limit")
- elif toolsettings.etch_convert_mode == 'FIXED':
- col.prop(toolsettings, "etch_subdivision_number")
- elif toolsettings.etch_convert_mode == 'RETARGET':
- col.prop(toolsettings, "etch_template")
- col.prop(toolsettings, "etch_roll_mode")
-
- col.separator()
-
- colsub = col.column(align=True)
- colsub.prop(toolsettings, "use_etch_autoname")
- sub = colsub.column(align=True)
- sub.enabled = not toolsettings.use_etch_autoname
- sub.prop(toolsettings, "etch_number")
- sub.prop(toolsettings, "etch_side")
-
- col.separator()
-
- col.operator("sketch.convert", text="Convert to Bones")
- col.operator("sketch.delete", text="Delete Strokes")
-
-
class VIEW3D_PT_context_properties(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
@@ -3965,7 +3859,6 @@ classes = (
VIEW3D_MT_object_quick_effects,
VIEW3D_MT_make_single_user,
VIEW3D_MT_make_links,
- VIEW3D_MT_object_game,
VIEW3D_MT_brush,
VIEW3D_MT_brush_paint_modes,
VIEW3D_MT_paint_vertex,
@@ -4040,7 +3933,6 @@ classes = (
VIEW3D_PT_view3d_meshstatvis,
VIEW3D_PT_view3d_curvedisplay,
VIEW3D_PT_transform_orientations,
- VIEW3D_PT_etch_a_ton,
VIEW3D_PT_context_properties,
)
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index c4da0566236..67bf99d04c8 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -342,7 +342,6 @@ class VIEW3D_PT_tools_meshedit(View3DPanel, Panel):
row = col.row(align=True)
row.operator("transform.edge_slide", text="Slide Edge")
row.operator("transform.vert_slide", text="Vertex")
- col.operator("mesh.noise")
col.operator("mesh.vertices_smooth")
col.operator("transform.vertex_random")
@@ -1200,9 +1199,6 @@ class TEXTURE_UL_texpaintslots(UIList):
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.prop(item, "name", text="", emboss=False, icon_value=icon)
- if (not mat.use_nodes) and context.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
- mtex_index = mat.texture_paint_slots[index].index
- layout.prop(mat, "use_textures", text="", index=mtex_index)
elif self.layout_type == 'GRID':
layout.alignment = 'CENTER'
layout.label(text="")
@@ -1263,16 +1259,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
else:
slot = None
- if (not mat.use_nodes) and context.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
- row = col.row(align=True)
- row.operator_menu_enum("paint.add_texture_paint_slot", "type")
- row.operator("paint.delete_texture_paint_slot", text="", icon='X')
-
- if slot:
- col.prop(mat.texture_slots[slot.index], "blend_type")
- col.separator()
-
- if slot and slot.index != -1:
+ if slot and slot.valid:
col.label("UV Map:")
col.prop_search(slot, "uv_layer", ob.data, "uv_layers", text="")
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index bb3eb1a7856..0d283d39af7 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -43,18 +43,10 @@ class CompositorNodeCategory(SortedNodeCategory):
return (context.space_data.tree_type == 'CompositorNodeTree')
-class ShaderNewNodeCategory(SortedNodeCategory):
+class ShaderNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
- return (context.space_data.tree_type == 'ShaderNodeTree' and
- context.view_render.use_shading_nodes)
-
-
-class ShaderOldNodeCategory(SortedNodeCategory):
- @classmethod
- def poll(cls, context):
- return (context.space_data.tree_type == 'ShaderNodeTree' and
- not context.view_render.use_shading_nodes)
+ return (context.space_data.tree_type == 'ShaderNodeTree')
class TextureNodeCategory(SortedNodeCategory):
@@ -142,11 +134,11 @@ def object_shader_nodes_poll(context):
def cycles_shader_nodes_poll(context):
- return context.view_render.engine == 'CYCLES'
+ return context.engine == 'CYCLES'
def eevee_shader_nodes_poll(context):
- return context.view_render.engine == 'BLENDER_EEVEE'
+ return context.engine == 'BLENDER_EEVEE'
def eevee_cycles_shader_nodes_poll(context):
@@ -172,59 +164,8 @@ def object_eevee_cycles_shader_nodes_poll(context):
# All standard node categories currently used in nodes.
shader_node_categories = [
- # Shader Nodes
- ShaderOldNodeCategory("SH_INPUT", "Input", items=[
- NodeItem("ShaderNodeMaterial"),
- NodeItem("ShaderNodeCameraData"),
- NodeItem("ShaderNodeFresnel"),
- NodeItem("ShaderNodeLayerWeight"),
- NodeItem("ShaderNodeLampData"),
- NodeItem("ShaderNodeValue"),
- NodeItem("ShaderNodeRGB"),
- NodeItem("ShaderNodeTexture"),
- NodeItem("ShaderNodeGeometry"),
- NodeItem("ShaderNodeExtendedMaterial"),
- NodeItem("ShaderNodeParticleInfo"),
- NodeItem("ShaderNodeObjectInfo"),
- NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
- ]),
- ShaderOldNodeCategory("SH_OUTPUT", "Output", items=[
- NodeItem("ShaderNodeOutput"),
- NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
- ]),
- ShaderOldNodeCategory("SH_OP_COLOR", "Color", items=[
- NodeItem("ShaderNodeMixRGB"),
- NodeItem("ShaderNodeRGBCurve"),
- NodeItem("ShaderNodeInvert"),
- NodeItem("ShaderNodeHueSaturation"),
- NodeItem("ShaderNodeGamma"),
- ]),
- ShaderOldNodeCategory("SH_OP_VECTOR", "Vector", items=[
- NodeItem("ShaderNodeNormal"),
- NodeItem("ShaderNodeMapping"),
- NodeItem("ShaderNodeVectorCurve"),
- NodeItem("ShaderNodeVectorTransform"),
- NodeItem("ShaderNodeNormalMap"),
- ]),
- ShaderOldNodeCategory("SH_CONVERTOR", "Converter", items=[
- NodeItem("ShaderNodeValToRGB"),
- NodeItem("ShaderNodeRGBToBW"),
- NodeItem("ShaderNodeMath"),
- NodeItem("ShaderNodeVectorMath"),
- NodeItem("ShaderNodeSqueeze"),
- NodeItem("ShaderNodeSeparateRGB"),
- NodeItem("ShaderNodeCombineRGB"),
- NodeItem("ShaderNodeSeparateHSV"),
- NodeItem("ShaderNodeCombineHSV"),
- ]),
- ShaderOldNodeCategory("SH_GROUP", "Group", items=node_group_items),
- ShaderOldNodeCategory("SH_LAYOUT", "Layout", items=[
- NodeItem("NodeFrame"),
- NodeItem("NodeReroute"),
- ]),
-
- # New Shader Nodes (Cycles)
- ShaderNewNodeCategory("SH_NEW_INPUT", "Input", items=[
+ # Shader Nodes (Cycles and Eevee)
+ ShaderNodeCategory("SH_NEW_INPUT", "Input", items=[
NodeItem("ShaderNodeTexCoord"),
NodeItem("ShaderNodeAttribute"),
NodeItem("ShaderNodeLightPath"),
@@ -244,14 +185,14 @@ shader_node_categories = [
NodeItem("ShaderNodeUVAlongStroke", poll=line_style_shader_nodes_poll),
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
]),
- ShaderNewNodeCategory("SH_NEW_OUTPUT", "Output", items=[
+ ShaderNodeCategory("SH_NEW_OUTPUT", "Output", items=[
NodeItem("ShaderNodeOutputMaterial", poll=object_eevee_cycles_shader_nodes_poll),
NodeItem("ShaderNodeOutputLamp", poll=object_cycles_shader_nodes_poll),
NodeItem("ShaderNodeOutputWorld", poll=world_shader_nodes_poll),
NodeItem("ShaderNodeOutputLineStyle", poll=line_style_shader_nodes_poll),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
]),
- ShaderNewNodeCategory("SH_NEW_SHADER", "Shader", items=[
+ ShaderNodeCategory("SH_NEW_SHADER", "Shader", items=[
NodeItem("ShaderNodeMixShader", poll=eevee_cycles_shader_nodes_poll),
NodeItem("ShaderNodeAddShader", poll=eevee_cycles_shader_nodes_poll),
NodeItem("ShaderNodeBsdfDiffuse", poll=object_eevee_cycles_shader_nodes_poll),
@@ -275,7 +216,7 @@ shader_node_categories = [
NodeItem("ShaderNodeVolumePrincipled"),
NodeItem("ShaderNodeEeveeSpecular", poll=object_eevee_shader_nodes_poll),
]),
- ShaderNewNodeCategory("SH_NEW_TEXTURE", "Texture", items=[
+ ShaderNodeCategory("SH_NEW_TEXTURE", "Texture", items=[
NodeItem("ShaderNodeTexImage"),
NodeItem("ShaderNodeTexEnvironment"),
NodeItem("ShaderNodeTexSky"),
@@ -289,7 +230,7 @@ shader_node_categories = [
NodeItem("ShaderNodeTexBrick"),
NodeItem("ShaderNodeTexPointDensity"),
]),
- ShaderNewNodeCategory("SH_NEW_OP_COLOR", "Color", items=[
+ ShaderNodeCategory("SH_NEW_OP_COLOR", "Color", items=[
NodeItem("ShaderNodeMixRGB"),
NodeItem("ShaderNodeRGBCurve"),
NodeItem("ShaderNodeInvert"),
@@ -298,7 +239,7 @@ shader_node_categories = [
NodeItem("ShaderNodeGamma"),
NodeItem("ShaderNodeBrightContrast"),
]),
- ShaderNewNodeCategory("SH_NEW_OP_VECTOR", "Vector", items=[
+ ShaderNodeCategory("SH_NEW_OP_VECTOR", "Vector", items=[
NodeItem("ShaderNodeMapping"),
NodeItem("ShaderNodeBump"),
NodeItem("ShaderNodeDisplacement"),
@@ -308,7 +249,7 @@ shader_node_categories = [
NodeItem("ShaderNodeVectorCurve"),
NodeItem("ShaderNodeVectorTransform"),
]),
- ShaderNewNodeCategory("SH_NEW_CONVERTOR", "Converter", items=[
+ ShaderNodeCategory("SH_NEW_CONVERTOR", "Converter", items=[
NodeItem("ShaderNodeMath"),
NodeItem("ShaderNodeValToRGB"),
NodeItem("ShaderNodeRGBToBW"),
@@ -322,11 +263,11 @@ shader_node_categories = [
NodeItem("ShaderNodeWavelength"),
NodeItem("ShaderNodeBlackbody"),
]),
- ShaderNewNodeCategory("SH_NEW_SCRIPT", "Script", items=[
+ ShaderNodeCategory("SH_NEW_SCRIPT", "Script", items=[
NodeItem("ShaderNodeScript"),
]),
- ShaderNewNodeCategory("SH_NEW_GROUP", "Group", items=node_group_items),
- ShaderNewNodeCategory("SH_NEW_LAYOUT", "Layout", items=[
+ ShaderNodeCategory("SH_NEW_GROUP", "Group", items=node_group_items),
+ ShaderNodeCategory("SH_NEW_LAYOUT", "Layout", items=[
NodeItem("NodeFrame"),
NodeItem("NodeReroute"),
]),
diff --git a/release/scripts/templates_py/gamelogic.py b/release/scripts/templates_py/gamelogic.py
deleted file mode 100644
index e589ad43e63..00000000000
--- a/release/scripts/templates_py/gamelogic.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# This script must be assigned to a python controller
-# where it can access the object that owns it and the sensors/actuators that it connects to.
-
-import bge
-
-# support for Vector(), Matrix() types and advanced functions like Matrix.Scale(...) and Matrix.Rotation(...)
-# import mathutils
-
-# for functions like getWindowWidth(), getWindowHeight()
-# import Rasterizer
-
-
-def main():
- cont = bge.logic.getCurrentController()
-
- # The KX_GameObject that owns this controller.
- own = cont.owner
-
- # for scripts that deal with spacial logic
- own_pos = own.worldPosition
-
- # Some example functions, remove to write your own script.
- # check for a positive sensor, will run on any object without errors.
- print("Logic info for KX_GameObject", own.name)
- input = False
-
- for sens in cont.sensors:
- # The sensor can be on another object, we may want to use it
- own_sens = sens.owner
- print(" sensor:", sens.name, end=" ")
- if sens.positive:
- print("(true)")
- input = True
- else:
- print("(false)")
-
- for actu in cont.actuators:
- # The actuator can be on another object, we may want to use it
- own_actu = actu.owner
- print(" actuator:", actu.name)
-
- # This runs the actuator or turns it off
- # note that actuators will continue to run unless explicitly turned off.
- if input:
- cont.activate(actu)
- else:
- cont.deactivate(actu)
-
- # Its also good practice to get sensors and actuators by name
- # rather then index so any changes to their order wont break the script.
-
- # sens_key = cont.sensors["key_sensor"]
- # actu_motion = cont.actuators["motion"]
-
- # Loop through all other objects in the scene
- sce = bge.logic.getCurrentScene()
- print("Scene Objects:", sce.name)
- for ob in sce.objects:
- print(" ", ob.name, ob.worldPosition)
-
- # Example where collision objects are checked for their properties
- # adding to our objects "life" property
- """
- actu_collide = cont.sensors["collision_sens"]
- for ob in actu_collide.hitObjectList:
- # Check to see the object has this property
- if "life" in ob:
- own["life"] += ob["life"]
- ob["life"] = 0
- print(own["life"])
- """
-
-main()
diff --git a/release/scripts/templates_py/gamelogic_module.py b/release/scripts/templates_py/gamelogic_module.py
deleted file mode 100644
index 88c8cf0d75b..00000000000
--- a/release/scripts/templates_py/gamelogic_module.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# This module can be accessed by a python controller with
-# its execution method set to 'Module'
-# * Set the module string to "gamelogic_module.main" (without quotes)
-# * When renaming the script it MUST have a .py extension
-# * External text modules are supported as long as they are at
-# the same location as the blendfile or one of its libraries.
-
-import bge
-
-# variables defined here will only be set once when the
-# module is first imported. Set object specific vars
-# inside the function if you intend to use the module
-# with multiple objects.
-
-
-def main(cont):
- own = cont.owner
-
- sens = cont.sensors['mySensor']
- actu = cont.actuators['myActuator']
-
- if sens.positive:
- cont.activate(actu)
- else:
- cont.deactivate(actu)
-
-# dont call main(bge.logic.getCurrentController()), the py controller will
diff --git a/release/scripts/templates_py/gamelogic_simple.py b/release/scripts/templates_py/gamelogic_simple.py
deleted file mode 100644
index dbfcf948b18..00000000000
--- a/release/scripts/templates_py/gamelogic_simple.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import bge
-
-
-def main():
-
- cont = bge.logic.getCurrentController()
- own = cont.owner
-
- sens = cont.sensors['mySensor']
- actu = cont.actuators['myActuator']
-
- if sens.positive:
- cont.activate(actu)
- else:
- cont.deactivate(actu)
-
-main()
diff --git a/release/scripts/templates_py/ui_list_simple.py b/release/scripts/templates_py/ui_list_simple.py
index e911a0dd236..79c14c17c7e 100644
--- a/release/scripts/templates_py/ui_list_simple.py
+++ b/release/scripts/templates_py/ui_list_simple.py
@@ -28,18 +28,6 @@ class MATERIAL_UL_matslots_example(bpy.types.UIList):
layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
else:
layout.label(text="", translate=False, icon_value=icon)
- # And now we can add other UI stuff...
- # Here, we add nodes info if this material uses (old!) shading nodes.
- if ma and not context.scene.render.use_shading_nodes:
- manode = ma.active_node_material
- if manode:
- # The static method UILayout.icon returns the integer value of the icon ID "computed" for the given
- # RNA object.
- layout.label(text="Node %s" % manode.name, translate=False, icon_value=layout.icon(manode))
- elif ma.use_nodes:
- layout.label(text="Node <none>", translate=False)
- else:
- layout.label(text="")
# 'GRID' layout type should be as compact as possible (typically a single icon!).
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 4e4724771f3..f9260ecebc5 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -29,7 +29,3 @@ endif()
add_subdirectory(blender)
-if(WITH_GAMEENGINE)
- add_subdirectory(gameengine)
-endif()
-
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 8a93e9c94d6..b88e5e88cfe 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -26,7 +26,6 @@
set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_ID.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_action_types.h
- ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_actuator_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_anim_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_armature_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_boid_types.h
@@ -36,7 +35,6 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_cloth_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_color_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_constraint_types.h
- ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_controller_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_curve_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_customdata_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_defs.h
@@ -74,12 +72,10 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_outliner_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_packedFile_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_particle_types.h
- ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_property_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_rigidbody_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_scene_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_screen_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sdna_types.h
- ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sensor_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sequence_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_smoke_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sound_types.h
diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc
index aa5d77ce4ec..4c91b9a6252 100644
--- a/source/blender/alembic/intern/abc_camera.cc
+++ b/source/blender/alembic/intern/abc_camera.cc
@@ -49,13 +49,13 @@ using Alembic::AbcGeom::kWrapExisting;
/* ************************************************************************** */
-AbcCameraWriter::AbcCameraWriter(EvaluationContext *eval_ctx,
+AbcCameraWriter::AbcCameraWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
OCamera camera(parent->alembicXform(), m_name, m_time_sampling);
m_camera_schema = camera.getSchema();
diff --git a/source/blender/alembic/intern/abc_camera.h b/source/blender/alembic/intern/abc_camera.h
index 772b7a6aec6..a839ca947ca 100644
--- a/source/blender/alembic/intern/abc_camera.h
+++ b/source/blender/alembic/intern/abc_camera.h
@@ -35,7 +35,7 @@ class AbcCameraWriter : public AbcObjectWriter {
Alembic::AbcGeom::OFloatProperty m_eye_separation;
public:
- AbcCameraWriter(EvaluationContext *eval_ctx,
+ AbcCameraWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index 5328c471093..41c1dacabc0 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -71,13 +71,13 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */
-AbcCurveWriter::AbcCurveWriter(EvaluationContext *eval_ctx,
+AbcCurveWriter::AbcCurveWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
OCurves curves(parent->alembicXform(), m_name, m_time_sampling);
m_schema = curves.getSchema();
diff --git a/source/blender/alembic/intern/abc_curves.h b/source/blender/alembic/intern/abc_curves.h
index 73cc8b35e27..1e7180bbb1f 100644
--- a/source/blender/alembic/intern/abc_curves.h
+++ b/source/blender/alembic/intern/abc_curves.h
@@ -36,7 +36,7 @@ class AbcCurveWriter : public AbcObjectWriter {
Alembic::AbcGeom::OCurvesSchema::Sample m_sample;
public:
- AbcCurveWriter(EvaluationContext *eval_ctx,
+ AbcCurveWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc
index ed5b59d08e2..16c3f7f4e86 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -168,7 +168,7 @@ static bool export_object(const ExportSettings * const settings, const Base * co
/* ************************************************************************** */
-AbcExporter::AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene,
+AbcExporter::AbcExporter(Main *bmain, Scene *scene, ViewLayer *view_layer,
Depsgraph *depsgraph,
const char *filename, ExportSettings &settings)
: m_bmain(bmain)
@@ -176,8 +176,8 @@ AbcExporter::AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene,
, m_filename(filename)
, m_trans_sampling_index(0)
, m_shape_sampling_index(0)
- , m_eval_ctx(eval_ctx)
, m_scene(scene)
+ , m_view_layer(view_layer)
, m_depsgraph(depsgraph)
, m_writer(NULL)
{}
@@ -253,13 +253,13 @@ void AbcExporter::getFrameSet(unsigned int nr_of_samples,
}
}
-void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
+void AbcExporter::operator()(float &progress, bool &was_canceled)
{
std::string scene_name;
- if (bmain->name[0] != '\0') {
+ if (m_bmain->name[0] != '\0') {
char scene_file_name[FILE_MAX];
- BLI_strncpy(scene_file_name, bmain->name, FILE_MAX);
+ BLI_strncpy(scene_file_name, m_bmain->name, FILE_MAX);
scene_name = scene_file_name;
}
else {
@@ -298,8 +298,8 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
OBox3dProperty archive_bounds_prop = Alembic::AbcGeom::CreateOArchiveBounds(m_writer->archive(), m_trans_sampling_index);
- createTransformWritersHierarchy(bmain->eval_ctx);
- createShapeWriters(bmain->eval_ctx);
+ createTransformWritersHierarchy(m_depsgraph);
+ createShapeWriters(m_depsgraph);
/* Make a list of frames to export. */
@@ -332,7 +332,7 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
const double frame = *begin;
/* 'frame' is offset by start frame, so need to cancel the offset. */
- setCurrentFrame(bmain, frame);
+ setCurrentFrame(m_bmain, frame);
if (shape_frames.count(frame) != 0) {
for (int i = 0, e = m_shapes.size(); i != e; ++i) {
@@ -361,7 +361,7 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
}
}
-void AbcExporter::createTransformWritersHierarchy(EvaluationContext *eval_ctx)
+void AbcExporter::createTransformWritersHierarchy(Depsgraph *depsgraph)
{
for (Base *base = static_cast<Base *>(m_settings.view_layer->object_bases.first); base; base = base->next) {
Object *ob = base->object;
@@ -374,13 +374,13 @@ void AbcExporter::createTransformWritersHierarchy(EvaluationContext *eval_ctx)
/* We do not export transforms for objects of these classes. */
break;
default:
- exploreTransform(eval_ctx, base, ob->parent, NULL);
+ exploreTransform(depsgraph, base, ob->parent, NULL);
}
}
}
}
-void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent)
+void AbcExporter::exploreTransform(Depsgraph *depsgraph, Base *ob_base, Object *parent, Object *dupliObParent)
{
Object *ob = ob_base->object;
@@ -391,10 +391,10 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
}
if (object_type_is_exportable(m_scene, ob)) {
- createTransformWriter(eval_ctx, ob, parent, dupliObParent);
+ createTransformWriter(depsgraph, ob, parent, dupliObParent);
}
- ListBase *lb = object_duplilist(eval_ctx, m_scene, ob);
+ ListBase *lb = object_duplilist(depsgraph, m_scene, ob);
if (lb) {
Base fake_base = *ob_base; // copy flags (like selection state) from the real object.
@@ -415,7 +415,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
dupli_parent = (dupli_ob->parent) ? dupli_ob->parent : ob;
fake_base.object = dupli_ob;
- exploreTransform(eval_ctx, &fake_base, dupli_parent, ob);
+ exploreTransform(depsgraph, &fake_base, dupli_parent, ob);
}
}
}
@@ -423,7 +423,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
free_object_duplilist(lb);
}
-AbcTransformWriter * AbcExporter::createTransformWriter(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent)
+AbcTransformWriter * AbcExporter::createTransformWriter(Depsgraph *depsgraph, Object *ob, Object *parent, Object *dupliObParent)
{
/* An object should not be its own parent, or we'll get infinite loops. */
BLI_assert(ob != parent);
@@ -458,29 +458,29 @@ AbcTransformWriter * AbcExporter::createTransformWriter(EvaluationContext *eval_
* return the parent's AbcTransformWriter pointer. */
if (parent->parent) {
if (parent == dupliObParent) {
- parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, NULL);
+ parent_writer = createTransformWriter(depsgraph, parent, parent->parent, NULL);
}
else {
- parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, dupliObParent);
+ parent_writer = createTransformWriter(depsgraph, parent, parent->parent, dupliObParent);
}
}
else if (parent == dupliObParent) {
if (dupliObParent->parent == NULL) {
- parent_writer = createTransformWriter(eval_ctx, parent, NULL, NULL);
+ parent_writer = createTransformWriter(depsgraph, parent, NULL, NULL);
}
else {
- parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent->parent, dupliObParent->parent);
+ parent_writer = createTransformWriter(depsgraph, parent, dupliObParent->parent, dupliObParent->parent);
}
}
else {
- parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent, dupliObParent);
+ parent_writer = createTransformWriter(depsgraph, parent, dupliObParent, dupliObParent);
}
BLI_assert(parent_writer);
alembic_parent = parent_writer->alembicXform();
}
- my_writer = new AbcTransformWriter(eval_ctx, ob, alembic_parent, parent_writer,
+ my_writer = new AbcTransformWriter(depsgraph, ob, alembic_parent, parent_writer,
m_trans_sampling_index, m_settings);
/* When flattening, the matrix of the dupliobject has to be added. */
@@ -492,14 +492,14 @@ AbcTransformWriter * AbcExporter::createTransformWriter(EvaluationContext *eval_
return my_writer;
}
-void AbcExporter::createShapeWriters(EvaluationContext *eval_ctx)
+void AbcExporter::createShapeWriters(Depsgraph *depsgraph)
{
for (Base *base = static_cast<Base *>(m_settings.view_layer->object_bases.first); base; base = base->next) {
- exploreObject(eval_ctx, base, NULL);
+ exploreObject(depsgraph, base, NULL);
}
}
-void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent)
+void AbcExporter::exploreObject(Depsgraph *depsgraph, Base *ob_base, Object *dupliObParent)
{
/* If an object isn't exported itself, its duplilist shouldn't be
* exported either. */
@@ -510,7 +510,7 @@ void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Obje
createShapeWriter(ob_base, dupliObParent);
Object *ob = ob_base->object;
- ListBase *lb = object_duplilist(eval_ctx, m_scene, ob);
+ ListBase *lb = object_duplilist(depsgraph, m_scene, ob);
if (lb) {
Base fake_base = *ob_base; // copy flags (like selection state) from the real object.
@@ -525,7 +525,7 @@ void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Obje
}
if (link->type == OB_DUPLIGROUP) {
fake_base.object = link->ob;
- exploreObject(eval_ctx, &fake_base, ob);
+ exploreObject(depsgraph, &fake_base, ob);
}
}
}
@@ -548,10 +548,10 @@ void AbcExporter::createParticleSystemsWriters(Object *ob, AbcTransformWriter *x
if (m_settings.export_hair && psys->part->type == PART_HAIR) {
m_settings.export_child_hairs = true;
- m_shapes.push_back(new AbcHairWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+ m_shapes.push_back(new AbcHairWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
}
else if (m_settings.export_particles && psys->part->type == PART_EMITTER) {
- m_shapes.push_back(new AbcPointsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+ m_shapes.push_back(new AbcPointsWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
}
}
}
@@ -591,7 +591,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcMeshWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcMeshWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_SURF:
@@ -602,7 +602,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcNurbsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcNurbsWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_CURVE:
@@ -613,7 +613,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcCurveWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcCurveWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_CAMERA:
@@ -621,7 +621,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
Camera *cam = static_cast<Camera *>(ob->data);
if (cam->type == CAM_PERSP) {
- m_shapes.push_back(new AbcCameraWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcCameraWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
}
break;
@@ -634,7 +634,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
}
m_shapes.push_back(new AbcMBallWriter(
- m_bmain, m_eval_ctx, m_scene, ob, xform,
+ m_bmain, m_depsgraph, m_scene, ob, xform,
m_shape_sampling_index, m_settings));
break;
}
diff --git a/source/blender/alembic/intern/abc_exporter.h b/source/blender/alembic/intern/abc_exporter.h
index 9c9c21af12f..0a32a28adca 100644
--- a/source/blender/alembic/intern/abc_exporter.h
+++ b/source/blender/alembic/intern/abc_exporter.h
@@ -34,7 +34,6 @@ class AbcObjectWriter;
class AbcTransformWriter;
class ArchiveWriter;
-struct EvaluationContext;
struct Depsgraph;
struct Main;
struct Object;
@@ -93,8 +92,8 @@ class AbcExporter {
unsigned int m_trans_sampling_index, m_shape_sampling_index;
- EvaluationContext *m_eval_ctx;
Scene *m_scene;
+ ViewLayer *m_view_layer;
Depsgraph *m_depsgraph;
ArchiveWriter *m_writer;
@@ -106,12 +105,12 @@ class AbcExporter {
std::vector<AbcObjectWriter *> m_shapes;
public:
- AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene,
+ AbcExporter(Main *bmain, Scene *scene, ViewLayer *view_layer,
Depsgraph *depsgraph,
const char *filename, ExportSettings &settings);
~AbcExporter();
- void operator()(Main *bmain, float &progress, bool &was_canceled);
+ void operator()(float &progress, bool &was_canceled);
protected:
void getShutterSamples(unsigned int nr_of_samples,
@@ -122,11 +121,11 @@ protected:
private:
Alembic::Abc::TimeSamplingPtr createTimeSampling(double step);
- void createTransformWritersHierarchy(EvaluationContext *eval_ctx);
- AbcTransformWriter * createTransformWriter(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent);
- void exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent);
- void exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent);
- void createShapeWriters(EvaluationContext *eval_ctx);
+ void createTransformWritersHierarchy(Depsgraph *depsgraph);
+ AbcTransformWriter * createTransformWriter(Depsgraph *depsgraph, Object *ob, Object *parent, Object *dupliObParent);
+ void exploreTransform(Depsgraph *depsgraph, Base *ob_base, Object *parent, Object *dupliObParent);
+ void exploreObject(Depsgraph *depsgraph, Base *ob_base, Object *dupliObParent);
+ void createShapeWriters(Depsgraph *depsgraph);
void createShapeWriter(Base *ob_base, Object *dupliObParent);
void createParticleSystemsWriters(Object *ob, AbcTransformWriter *xform);
diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc
index 2579aa3cc36..b31a185e39b 100644
--- a/source/blender/alembic/intern/abc_hair.cc
+++ b/source/blender/alembic/intern/abc_hair.cc
@@ -49,14 +49,14 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */
-AbcHairWriter::AbcHairWriter(EvaluationContext *eval_ctx,
+AbcHairWriter::AbcHairWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
ParticleSystem *psys)
- : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
, m_uv_warning_shown(false)
{
m_psys = psys;
@@ -77,7 +77,7 @@ void AbcHairWriter::do_write()
return;
}
- DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH);
+ DerivedMesh *dm = mesh_create_derived_render(m_depsgraph, m_scene, m_object, CD_MASK_MESH);
DM_ensure_tessface(dm);
std::vector<Imath::V3f> verts;
@@ -165,7 +165,7 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
psys_interpolate_uvs(tface, face->v4, pa->fuv, r_uv);
uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1]));
- psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, normal, NULL, NULL, NULL, NULL);
+ psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, normal, NULL, NULL, NULL);
copy_yup_from_zup(tmp_nor.getValue(), normal);
norm_values.push_back(tmp_nor);
@@ -253,8 +253,9 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm,
path = cache[p];
if (part->from == PART_FROM_FACE &&
- part->childtype != PART_CHILD_PARTICLES &&
- mtface) {
+ part->childtype != PART_CHILD_PARTICLES &&
+ mtface)
+ {
const int num = pc->num;
if (num < 0) {
ABC_LOG(m_settings.logger)
@@ -272,7 +273,7 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm,
psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv);
uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1]));
- psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, tmpnor, NULL, NULL, NULL, NULL);
+ psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, tmpnor, NULL, NULL, NULL);
/* Convert Z-up to Y-up. */
norm_values.push_back(Imath::V3f(tmpnor[0], tmpnor[2], -tmpnor[1]));
diff --git a/source/blender/alembic/intern/abc_hair.h b/source/blender/alembic/intern/abc_hair.h
index 8190c449205..5627f7726e6 100644
--- a/source/blender/alembic/intern/abc_hair.h
+++ b/source/blender/alembic/intern/abc_hair.h
@@ -40,7 +40,7 @@ class AbcHairWriter : public AbcObjectWriter {
bool m_uv_warning_shown;
public:
- AbcHairWriter(EvaluationContext *eval_ctx,
+ AbcHairWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
diff --git a/source/blender/alembic/intern/abc_mball.cc b/source/blender/alembic/intern/abc_mball.cc
index f1aa25c8f70..1df55712abe 100644
--- a/source/blender/alembic/intern/abc_mball.cc
+++ b/source/blender/alembic/intern/abc_mball.cc
@@ -42,13 +42,13 @@ extern "C" {
AbcMBallWriter::AbcMBallWriter(
Main *bmain,
- EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
, m_bmain(bmain)
{
m_is_animated = isAnimated();
@@ -58,7 +58,7 @@ AbcMBallWriter::AbcMBallWriter(
sizeof(CurveCache),
"CurveCache for AbcMBallWriter");
- m_mesh_writer = new AbcMeshWriter(eval_ctx, scene, m_mesh_ob, parent,
+ m_mesh_writer = new AbcMeshWriter(depsgraph, scene, m_mesh_ob, parent,
time_sampling, settings);
m_mesh_writer->setIsAnimated(m_is_animated);
}
@@ -97,13 +97,11 @@ void AbcMBallWriter::do_write()
id_us_min(&tmpmesh->id);
ListBase disp = {NULL, NULL};
- /* TODO(sergey): This is gonna to work for until EvaluationContext
+ /* TODO(sergey): This is gonna to work for until Depsgraph
* only contains for_render flag. As soon as CoW is
* implemented, this is to be rethinked.
*/
- EvaluationContext eval_ctx;
- DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_RENDER);
- BKE_displist_make_mball_forRender(&eval_ctx, m_scene, m_object, &disp);
+ BKE_displist_make_mball_forRender(m_depsgraph, m_scene, m_object, &disp);
BKE_mesh_from_metaball(&disp, tmpmesh);
BKE_displist_free(&disp);
diff --git a/source/blender/alembic/intern/abc_mball.h b/source/blender/alembic/intern/abc_mball.h
index e657711059e..19bf7dc054d 100644
--- a/source/blender/alembic/intern/abc_mball.h
+++ b/source/blender/alembic/intern/abc_mball.h
@@ -42,7 +42,7 @@ class AbcMBallWriter : public AbcObjectWriter {
public:
AbcMBallWriter(
Main *bmain,
- EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index c2c99e2b11f..52d14f84728 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -286,13 +286,13 @@ static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob)
/* ************************************************************************** */
-AbcMeshWriter::AbcMeshWriter(EvaluationContext *eval_ctx,
+AbcMeshWriter::AbcMeshWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
m_is_animated = isAnimated();
m_subsurf_mod = NULL;
@@ -525,7 +525,7 @@ DerivedMesh *AbcMeshWriter::getFinalMesh()
m_subsurf_mod->mode |= eModifierMode_DisableTemporary;
}
- DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH);
+ DerivedMesh *dm = mesh_create_derived_render(m_depsgraph, m_scene, m_object, CD_MASK_MESH);
if (m_subsurf_mod) {
m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary;
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index a08b7352d16..c57123cda4c 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -50,7 +50,7 @@ class AbcMeshWriter : public AbcObjectWriter {
bool m_is_subd;
public:
- AbcMeshWriter(EvaluationContext *eval_ctx,
+ AbcMeshWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc
index 0532191a28d..1f042d0bafc 100644
--- a/source/blender/alembic/intern/abc_nurbs.cc
+++ b/source/blender/alembic/intern/abc_nurbs.cc
@@ -60,13 +60,13 @@ using Alembic::AbcGeom::ONuPatchSchema;
/* ************************************************************************** */
-AbcNurbsWriter::AbcNurbsWriter(EvaluationContext *eval_ctx,
+AbcNurbsWriter::AbcNurbsWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
m_is_animated = isAnimated();
diff --git a/source/blender/alembic/intern/abc_nurbs.h b/source/blender/alembic/intern/abc_nurbs.h
index 3d20c5c60bb..d2422345c3f 100644
--- a/source/blender/alembic/intern/abc_nurbs.h
+++ b/source/blender/alembic/intern/abc_nurbs.h
@@ -32,7 +32,7 @@ class AbcNurbsWriter : public AbcObjectWriter {
bool m_is_animated;
public:
- AbcNurbsWriter(EvaluationContext *eval_ctx,
+ AbcNurbsWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index 98ebcf6debb..85bda9aa8eb 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -58,7 +58,7 @@ using Alembic::AbcGeom::OStringProperty;
/* ************************************************************************** */
-AbcObjectWriter::AbcObjectWriter(EvaluationContext *eval_ctx,
+AbcObjectWriter::AbcObjectWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
uint32_t time_sampling,
@@ -66,7 +66,7 @@ AbcObjectWriter::AbcObjectWriter(EvaluationContext *eval_ctx,
AbcObjectWriter *parent)
: m_object(ob)
, m_settings(settings)
- , m_eval_ctx(eval_ctx)
+ , m_depsgraph(depsgraph)
, m_scene(scene)
, m_time_sampling(time_sampling)
, m_first_frame(true)
@@ -291,7 +291,8 @@ Alembic::AbcGeom::IXform AbcObjectReader::xform()
/* The archive's top object can be recognised by not having a parent. */
if (abc_parent.getParent()
- && IXform::matches(abc_parent.getMetaData())) {
+ && IXform::matches(abc_parent.getMetaData()))
+ {
return IXform(abc_parent, Alembic::AbcGeom::kWrapExisting);
}
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index 6aa6224f8d5..d41088bdcad 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -44,7 +44,7 @@ protected:
Object *m_object;
ExportSettings &m_settings;
- EvaluationContext *m_eval_ctx;
+ Depsgraph *m_depsgraph;
Scene *m_scene;
uint32_t m_time_sampling;
@@ -57,7 +57,7 @@ protected:
std::string m_name;
public:
- AbcObjectWriter(EvaluationContext *eval_ctx,
+ AbcObjectWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc
index feb2eff5b9d..6f52ccec4a7 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -58,14 +58,14 @@ using Alembic::AbcGeom::OPointsSchema;
/* ************************************************************************** */
-AbcPointsWriter::AbcPointsWriter(EvaluationContext *eval_ctx,
+AbcPointsWriter::AbcPointsWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
ParticleSystem *psys)
- : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
m_psys = psys;
@@ -87,7 +87,7 @@ void AbcPointsWriter::do_write()
ParticleKey state;
ParticleSimulationData sim;
- sim.eval_ctx = m_eval_ctx;
+ sim.depsgraph = m_depsgraph;
sim.scene = m_scene;
sim.ob = m_object;
sim.psys = m_psys;
diff --git a/source/blender/alembic/intern/abc_points.h b/source/blender/alembic/intern/abc_points.h
index b60f1997aa8..1ac8792ede1 100644
--- a/source/blender/alembic/intern/abc_points.h
+++ b/source/blender/alembic/intern/abc_points.h
@@ -38,7 +38,7 @@ class AbcPointsWriter : public AbcObjectWriter {
ParticleSystem *m_psys;
public:
- AbcPointsWriter(EvaluationContext *eval_ctx,
+ AbcPointsWriter(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
diff --git a/source/blender/alembic/intern/abc_transform.cc b/source/blender/alembic/intern/abc_transform.cc
index 0a1480e62b0..e5da367b9a9 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -57,13 +57,13 @@ static bool has_parent_camera(Object *ob)
/* ************************************************************************** */
-AbcTransformWriter::AbcTransformWriter(EvaluationContext *eval_ctx,
+AbcTransformWriter::AbcTransformWriter(Depsgraph *depsgraph,
Object *ob,
const OObject &abc_parent,
AbcTransformWriter *parent,
unsigned int time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(eval_ctx, NULL, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, NULL, ob, time_sampling, settings, parent)
, m_proxy_from(NULL)
{
m_is_animated = hasAnimation(m_object);
diff --git a/source/blender/alembic/intern/abc_transform.h b/source/blender/alembic/intern/abc_transform.h
index e82765cb169..ce4b28ea236 100644
--- a/source/blender/alembic/intern/abc_transform.h
+++ b/source/blender/alembic/intern/abc_transform.h
@@ -44,7 +44,7 @@ public:
Object *m_proxy_from;
public:
- AbcTransformWriter(EvaluationContext *eval_ctx,
+ AbcTransformWriter(Depsgraph *depsgraph,
Object *ob,
const Alembic::AbcGeom::OObject &abc_parent,
AbcTransformWriter *parent,
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index cb01efb2cf4..75b4063f3c4 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -230,7 +230,6 @@ static void find_iobject(const IObject &object, IObject &ret,
}
struct ExportJobData {
- EvaluationContext eval_ctx;
Scene *scene;
ViewLayer *view_layer;
Depsgraph *depsgraph;
@@ -265,12 +264,13 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
try {
Scene *scene = data->scene;
- AbcExporter exporter(data->bmain, &data->eval_ctx, scene, data->depsgraph, data->filename, data->settings);
+ ViewLayer *view_layer = data->view_layer;
+ AbcExporter exporter(data->bmain, scene, view_layer, data->depsgraph, data->filename, data->settings);
const int orig_frame = CFRA;
data->was_canceled = false;
- exporter(data->bmain, *data->progress, data->was_canceled);
+ exporter(*data->progress, data->was_canceled);
if (CFRA != orig_frame) {
CFRA = orig_frame;
@@ -314,8 +314,6 @@ bool ABC_export(
{
ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData"));
- CTX_data_eval_ctx(C, &job->eval_ctx);
-
job->scene = scene;
job->view_layer = CTX_data_view_layer(C);
job->depsgraph = CTX_data_depsgraph(C);
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 96854db66dd..d0589f6546e 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -100,8 +100,7 @@ KerningCacheBLF *blf_kerning_cache_new(FontBLF *font)
GlyphBLF *g_prev = blf_glyph_search(font->glyph_cache, j);
FT_Vector delta = {.x = 0, .y = 0};
- if (FT_Get_Kerning(font->face, g_prev->idx, g->idx, kc->mode,
- &delta) == 0) {
+ if (FT_Get_Kerning(font->face, g_prev->idx, g->idx, kc->mode, &delta) == 0) {
kc->table[i][j] = (int)delta.x >> 6;
}
else {
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 4ae11b5cca5..74416bcd18f 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -95,10 +95,9 @@ struct KeyBlock;
struct ModifierData;
struct MCol;
struct ColorBand;
+struct Depsgraph;
struct GPUVertexAttribs;
-struct GPUDrawObject;
struct PBVH;
-struct EvaluationContext;
/* number of sub-elements each mesh element has (for interpolation) */
#define SUB_ELEMS_VERT 0
@@ -127,34 +126,6 @@ typedef enum DerivedMeshType {
DM_TYPE_CCGDM
} DerivedMeshType;
-typedef enum DMDrawOption {
- /* the element is hidden or otherwise non-drawable */
- DM_DRAW_OPTION_SKIP = 0,
- /* normal drawing */
- DM_DRAW_OPTION_NORMAL = 1,
- /* draw, but don't set the color from mcol */
- DM_DRAW_OPTION_NO_MCOL = 2,
- /* used in drawMappedFaces, use GL stipple for the face */
- DM_DRAW_OPTION_STIPPLE = 3,
-} DMDrawOption;
-
-/* Drawing callback types */
-typedef int (*DMSetMaterial)(int mat_nr, void *attribs);
-typedef int (*DMCompareDrawOptions)(void *userData, int cur_index, int next_index);
-typedef void (*DMSetDrawInterpOptions)(void *userData, int index, float t);
-typedef DMDrawOption (*DMSetDrawOptions)(void *userData, int index);
-
-typedef enum DMDrawFlag {
- DM_DRAW_USE_COLORS = (1 << 0),
- DM_DRAW_ALWAYS_SMOOTH = (1 << 1),
- DM_DRAW_USE_ACTIVE_UV = (1 << 2),
- DM_DRAW_USE_TEXPAINT_UV = (1 << 3),
- DM_DRAW_SKIP_HIDDEN = (1 << 4),
- DM_DRAW_SKIP_SELECT = (1 << 5),
- DM_DRAW_SELECT_USE_EDITMODE = (1 << 6),
- DM_DRAW_NEED_NORMALS = (1 << 7)
-} DMDrawFlag;
-
typedef enum DMForeachFlag {
DM_FOREACH_NOP = 0,
DM_FOREACH_USE_NORMAL = (1 << 0), /* foreachMappedVert, foreachMappedLoop, foreachMappedFaceCenter */
@@ -163,14 +134,9 @@ typedef enum DMForeachFlag {
typedef enum DMDirtyFlag {
/* dm has valid tessellated faces, but tessellated CDDATA need to be updated. */
DM_DIRTY_TESS_CDLAYERS = 1 << 0,
- /* One of the MCOL layers have been updated, force updating of GPUDrawObject's colors buffer.
- * This is necessary with modern, VBO draw code, as e.g. in vpaint mode me->mcol may be updated
- * without actually rebuilding dm (hence by default keeping same GPUDrawObject, and same colors
- * buffer, which prevents update during a stroke!). */
- DM_DIRTY_MCOL_UPDATE_DRAW = 1 << 1,
/* check this with modifier dependsOnNormals callback to see if normals need recalculation */
- DM_DIRTY_NORMALS = 1 << 2,
+ DM_DIRTY_NORMALS = 1 << 1,
} DMDirtyFlag;
typedef struct DerivedMesh DerivedMesh;
@@ -181,9 +147,7 @@ struct DerivedMesh {
int needsFree; /* checked on ->release, is set to 0 for cached results */
int deformedOnly; /* set by modifier stack if only deformed from original */
BVHCache *bvhCache;
- struct GPUDrawObject *drawObject;
DerivedMeshType type;
- float auto_bump_scale;
DMDirtyFlag dirty;
int totmat; /* total materials. Will be valid only before object drawing. */
struct Material **mat; /* material array. Will be valid only before object drawing */
@@ -383,98 +347,6 @@ struct DerivedMesh {
*/
struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm);
- /* Drawing Operations */
-
- /** Draw all vertices as bgl points (no options) */
- void (*drawVerts)(DerivedMesh *dm);
-
- /** Draw all edges as lines (no options)
- *
- * Also called for *final* editmode DerivedMeshes
- */
- void (*drawEdges)(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges);
-
- /** Draw all loose edges (edges w/ no adjoining faces) */
- void (*drawLooseEdges)(DerivedMesh *dm);
-
- /** Draw all faces
- * o Set face normal or vertex normal based on inherited face flag
- * o Use inherited face material index to call setMaterial
- * o Only if setMaterial returns true
- *
- * Also called for *final* editmode DerivedMeshes
- */
- void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4],
- bool fast, DMSetMaterial setMaterial);
-
- /** Draw all faces with GLSL materials
- * o setMaterial is called for every different material nr
- * o Only if setMaterial returns true
- */
- void (*drawFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial);
-
- /** Draw mapped faces (no color, or texture)
- * - Only if !setDrawOptions or
- * setDrawOptions(userData, mapped-face-index, r_drawSmooth)
- * returns true
- *
- * If drawSmooth is set to true then vertex normals should be set and
- * glShadeModel called with GL_SMOOTH. Otherwise the face normal should
- * be set and glShadeModel called with GL_FLAT.
- *
- * The setDrawOptions is allowed to not set drawSmooth (for example, when
- * lighting is disabled), in which case the implementation should draw as
- * smooth shaded.
- */
- void (*drawMappedFaces)(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMSetMaterial setMaterial,
- DMCompareDrawOptions compareDrawOptions,
- void *userData,
- DMDrawFlag flag);
-
- /** Draw mapped faces with GLSL materials
- * - setMaterial is called for every different material nr
- * - setDrawOptions is called for every face
- * - Only if setMaterial and setDrawOptions return true
- */
- void (*drawMappedFacesGLSL)(DerivedMesh *dm,
- DMSetMaterial setMaterial,
- DMSetDrawOptions setDrawOptions,
- void *userData);
-
- /** Draw mapped edges as lines
- * - Only if !setDrawOptions or setDrawOptions(userData, mapped-edge)
- * returns true
- */
- void (*drawMappedEdges)(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- void *userData);
-
- /** Draw mapped edges as lines with interpolation values
- * - Only if !setDrawOptions or
- * setDrawOptions(userData, mapped-edge, mapped-v0, mapped-v1, t)
- * returns true
- *
- * NOTE: This routine is optional!
- */
- void (*drawMappedEdgesInterp)(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMSetDrawInterpOptions setDrawInterpOptions,
- void *userData);
-
- /** Draw all faces with materials
- * - setMaterial is called for every different material nr
- * - setFace is called to verify if a face must be hidden
- */
- void (*drawMappedFacesMat)(DerivedMesh *dm,
- void (*setMaterial)(void *userData, int matnr, void *attribs),
- bool (*setFace)(void *userData, int index), void *userData);
-
- struct GPUDrawObject *(*gpuObjectNew)(DerivedMesh *dm);
- void (*copy_gpu_data)(DerivedMesh *dm, int type, void *varray_p,
- const int *mat_orig_to_new, const void *user_data);
-
/** Release reference to the DerivedMesh. This function decides internally
* if the DerivedMesh will be freed, or cached for later use. */
void (*release)(DerivedMesh *dm);
@@ -660,18 +532,18 @@ void mesh_get_mapped_verts_coords(DerivedMesh *dm, float (*r_cos)[3], const int
/* */
DerivedMesh *mesh_get_derived_final(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_get_derived_deform(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_for_modifier(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
struct ModifierData *md, int build_shapekey_layers);
DerivedMesh *mesh_create_derived_render(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, CustomDataMask dataMask);
DerivedMesh *getEditDerivedBMesh(
@@ -679,37 +551,30 @@ DerivedMesh *getEditDerivedBMesh(
float (*vertexCos)[3]);
DerivedMesh *mesh_create_derived_index_render(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, CustomDataMask dataMask, int index);
/* same as above but wont use render settings */
DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
DerivedMesh *mesh_create_derived_view(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_no_deform(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, float (*vertCos)[3],
CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_no_deform_render(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, float (*vertCos)[3],
CustomDataMask dataMask);
-/* for gameengine */
-DerivedMesh *mesh_create_derived_no_virtual(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
- float (*vertCos)[3], CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_physics(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
- float (*vertCos)[3], CustomDataMask dataMask);
DerivedMesh *editbmesh_get_derived_base(
struct Object *ob, struct BMEditMesh *em, CustomDataMask data_mask);
DerivedMesh *editbmesh_get_derived_cage(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *,
struct BMEditMesh *em, CustomDataMask dataMask);
DerivedMesh *editbmesh_get_derived_cage_and_final(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *,
struct BMEditMesh *em, CustomDataMask dataMask,
DerivedMesh **r_final);
@@ -718,7 +583,7 @@ DerivedMesh *object_get_derived_final(struct Object *ob, const bool for_render);
float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, DerivedMesh *dm);
void makeDerivedMesh(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
CustomDataMask dataMask, const bool build_shapekey_layers);
void weight_to_rgb(float r_rgb[3], const float weight);
@@ -763,9 +628,6 @@ void DM_vertex_attributes_from_gpu(
DerivedMesh *dm,
struct GPUVertexAttribs *gattribs, DMVertexAttribs *attribs);
-void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert, int loop);
-void DM_draw_attrib_vertex_uniforms(const DMVertexAttribs *attribs);
-
void DM_calc_tangents_names_from_gpu(
const struct GPUVertexAttribs *gattribs,
char (*tangent_names)[MAX_NAME], int *tangent_names_count);
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index f7ebe85bcef..e42a37cd444 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -163,9 +163,6 @@ struct bPoseChannel *BKE_pose_channel_get_mirrored(const struct bPose *pose, con
bool BKE_pose_channels_is_valid(const struct bPose *pose);
#endif
-/* Copy the data from the action-pose (src) into the pose */
-void extract_pose_from_pose(struct bPose *pose, const struct bPose *src);
-
/* sets constraint flags */
void BKE_pose_update_constraint_flags(struct bPose *pose);
@@ -211,6 +208,22 @@ void BKE_pose_rest(struct bPose *pose);
/* Tag pose for recalc. Also tag all related data to be recalc. */
void BKE_pose_tag_recalc(struct Main *bmain, struct bPose *pose);
+/* context.selected_pose_bones */
+#define FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN(_ob, _pchan) \
+ for (bPoseChannel *_pchan = (_ob)->pose->chanbase.first; _pchan; _pchan = _pchan->next) { \
+ if (PBONE_VISIBLE(((bArmature *)(_ob)->data), (_pchan)->bone) && ((_pchan)->bone->flag & BONE_SELECTED)) {
+#define FOREACH_PCHAN_SELECTED_IN_OBJECT_END \
+ } \
+ } ((void)0)
+/* context.visible_pose_bones */
+#define FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN(_ob, _pchan) \
+ for (bPoseChannel *_pchan = (_ob)->pose->chanbase.first; _pchan; _pchan = _pchan->next) { \
+ if (PBONE_VISIBLE(((bArmature *)(_ob)->data), (_pchan)->bone)) {
+#define FOREACH_PCHAN_VISIBLE_IN_OBJECT_END \
+ } \
+ } ((void)0)
+
+
#ifdef __cplusplus
};
#endif
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index 30a7bdb0a27..0fb83162459 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -32,7 +32,7 @@
* \author nzc
* \since March 2001
*/
-struct EvaluationContext;
+struct Depsgraph;
struct Path;
struct Object;
struct Scene;
@@ -54,7 +54,7 @@ void animviz_free_motionpath(struct bMotionPath *mpath);
struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan);
void animviz_get_object_motionpaths(struct Object *ob, ListBase *targets);
-void animviz_calc_motionpaths(struct EvaluationContext *eval_ctx, struct Main *bmain, struct Scene *scene, ListBase *targets);
+void animviz_calc_motionpaths(struct Depsgraph *depsgraph, struct Main *bmain, struct Scene *scene, ListBase *targets);
/* ---------------------------------------------------- */
/* Curve Paths */
@@ -66,8 +66,8 @@ int where_on_path(struct Object *ob, float ctime, float vec[4], float dir[3], fl
/* ---------------------------------------------------- */
/* Dupli-Geometry */
-struct ListBase *object_duplilist_ex(const struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob, bool update);
-struct ListBase *object_duplilist(const struct EvaluationContext *eval_ctx, struct Scene *sce, struct Object *ob);
+struct ListBase *object_duplilist_ex(struct Depsgraph *depsgraph, struct Scene *sce, struct Object *ob, bool update);
+struct ListBase *object_duplilist(struct Depsgraph *depsgraph, struct Scene *sce, struct Object *ob);
void free_object_duplilist(struct ListBase *lb);
int count_duplilist(struct Object *ob);
@@ -81,7 +81,7 @@ typedef struct DupliApplyData {
DupliExtraData *extra;
} DupliApplyData;
-DupliApplyData *duplilist_apply(const struct EvaluationContext *eval_ctx, struct Object *ob, struct Scene *scene, struct ListBase *duplilist);
+DupliApplyData *duplilist_apply(struct Depsgraph *depsgraph, struct Object *ob, struct Scene *scene, struct ListBase *duplilist);
void duplilist_restore(struct ListBase *duplilist, DupliApplyData *apply_data);
void duplilist_free_apply_data(DupliApplyData *apply_data);
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index d95b4a838b8..fe4a145b7b3 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -200,10 +200,10 @@ void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction *act,
/* ------------ Evaluation API --------------- */
-struct EvaluationContext;
+struct Depsgraph;
-void BKE_animsys_eval_animdata(const struct EvaluationContext *eval_ctx, struct ID *id);
-void BKE_animsys_eval_driver(const struct EvaluationContext *eval_ctx, struct ID *id, struct FCurve *fcurve);
+void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id);
+void BKE_animsys_eval_driver(struct Depsgraph *depsgraph, struct ID *id, struct FCurve *fcurve);
/* ************************************* */
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index bf37224c85f..e286c1248c0 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -35,7 +35,7 @@
struct bPose;
struct Bone;
-struct EvaluationContext;
+struct Depsgraph;
struct GHash;
struct Main;
struct bArmature;
@@ -100,8 +100,8 @@ void BKE_armature_where_is(struct bArmature *arm);
void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion);
void BKE_pose_clear_pointers(struct bPose *pose);
void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm);
-void BKE_pose_where_is(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
-void BKE_pose_where_is_bone(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
+void BKE_pose_where_is(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
+void BKE_pose_where_is_bone(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan);
/* get_objectspace_bone_matrix has to be removed still */
@@ -118,7 +118,7 @@ void BKE_armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc
void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], float pose_mat[4][4], float arm_mat[4][4]);
-void BKE_armature_mat_pose_to_bone_ex(const struct EvaluationContext *eval_ctx, struct Object *ob, struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
+void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph, struct Object *ob, struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat);
void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat);
@@ -166,46 +166,46 @@ struct bPoseChannel *BKE_armature_splineik_solver_find_root(
void BKE_pose_splineik_init_tree(struct Scene *scene, struct Object *ob, float ctime);
void BKE_splineik_execute_tree(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
-void BKE_pose_eval_init(const struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_init(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
-void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_init_ik(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
-void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_bone(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
int pchan_index);
-void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx,
+void BKE_pose_constraints_evaluate(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
int pchan_index);
-void BKE_pose_bone_done(const struct EvaluationContext *eval_ctx,
+void BKE_pose_bone_done(struct Depsgraph *depsgraph,
struct Object *ob,
int pchan_index);
-void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx,
+void BKE_pose_iktree_evaluate(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
int rootchan_index);
-void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx,
+void BKE_pose_splineik_evaluate(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
int rootchan_index);
-void BKE_pose_eval_flush(const struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_flush(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
-void BKE_pose_eval_proxy_copy(const struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_proxy_copy(struct Depsgraph *depsgraph,
struct Object *ob);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 901f9e6d3ac..a28c3cef199 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -28,7 +28,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 5
+#define BLENDER_SUBVERSION 9
/* Several breakages with 270, e.g. constraint deg vs rad */
#define BLENDER_MINVERSION 270
#define BLENDER_MINSUBVERSION 6
diff --git a/source/blender/blenkernel/BKE_bullet.h b/source/blender/blenkernel/BKE_bullet.h
deleted file mode 100644
index dc522d1b22c..00000000000
--- a/source/blender/blenkernel/BKE_bullet.h
+++ /dev/null
@@ -1,44 +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) Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __BKE_BULLET_H__
-#define __BKE_BULLET_H__
-
-/** \file BKE_bullet.h
- * \ingroup bke
- */
-
-struct BulletSoftBody;
-
-
-/* allocates and initializes general main data */
-extern struct BulletSoftBody *bsbNew(void);
-
-/* frees internal data and softbody itself */
-extern void bsbFree(struct BulletSoftBody *sb);
-
-#endif
-
diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h
index d5bf2177f71..c647dd3cc0f 100644
--- a/source/blender/blenkernel/BKE_camera.h
+++ b/source/blender/blenkernel/BKE_camera.h
@@ -93,11 +93,6 @@ typedef struct CameraParams {
float clipsta;
float clipend;
- /* fields */
- int use_fields;
- int field_second;
- int field_odd;
-
/* computed viewplane */
float ycor;
float viewdx;
@@ -114,7 +109,7 @@ typedef struct CameraParams {
void BKE_camera_params_init(CameraParams *params);
void BKE_camera_params_from_object(CameraParams *params, const struct Object *camera);
-void BKE_camera_params_from_view3d(CameraParams *params, const struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d);
+void BKE_camera_params_from_view3d(CameraParams *params, struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d);
void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy);
void BKE_camera_params_compute_matrix(CameraParams *params);
@@ -130,6 +125,7 @@ void BKE_camera_view_frame(
float r_vec[4][3]);
bool BKE_camera_view_frame_fit_to_scene(
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct ViewLayer *view_layer, struct Object *camera_ob,
float r_co[3], float *r_scale);
bool BKE_camera_view_frame_fit_to_coords(
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 8923edacb07..94daf615054 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -41,7 +41,7 @@ struct MFace;
struct DerivedMesh;
struct ClothModifierData;
struct CollisionModifierData;
-struct EvaluationContext;
+struct Depsgraph;
#define DO_INLINE MALWAYS_INLINE
@@ -227,7 +227,7 @@ void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders);
void cloth_free_modifier_extern (struct ClothModifierData *clmd );
void cloth_free_modifier (struct ClothModifierData *clmd );
void cloth_init (struct ClothModifierData *clmd );
-void clothModifier_do(struct ClothModifierData *clmd, const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]);
+void clothModifier_do(struct ClothModifierData *clmd, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]);
int cloth_uses_vgroup(struct ClothModifierData *clmd);
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index cf7e2908360..54ddb61d922 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -40,7 +40,7 @@ struct ListBase;
struct Object;
struct Scene;
struct bPoseChannel;
-struct EvaluationContext;
+struct Depsgraph;
/* ---------------------------------------------------------------------------- */
#ifdef __cplusplus
@@ -103,7 +103,7 @@ typedef struct bConstraintTypeInfo {
/* evaluation */
/* set the ct->matrix for the given constraint target (at the given ctime) */
- void (*get_target_matrix)(const struct EvaluationContext *eval_ctx, struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime);
+ void (*get_target_matrix)(struct Depsgraph *depsgraph, struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime);
/* evaluate the constraint for the given time */
void (*evaluate_constraint)(struct bConstraint *con, struct bConstraintOb *cob, struct ListBase *targets);
} bConstraintTypeInfo;
@@ -148,10 +148,10 @@ void BKE_constraints_clear_evalob(struct bConstraintOb *cob);
void BKE_constraint_mat_convertspace(
struct Object *ob, struct bPoseChannel *pchan, float mat[4][4], short from, short to, const bool keep_scale);
-void BKE_constraint_target_matrix_get(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct bConstraint *con,
+void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph, struct Scene *scene, struct bConstraint *con,
int n, short ownertype, void *ownerdata, float mat[4][4], float ctime);
-void BKE_constraint_targets_for_solving_get(const struct EvaluationContext *eval_ctx, struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
-void BKE_constraints_solve(const struct EvaluationContext *eval_ctx, struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
+void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph, struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
+void BKE_constraints_solve(struct Depsgraph *depsgraph, struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 947ed7cd600..067f986cb93 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -75,7 +75,6 @@ struct SpaceText;
struct SpaceImage;
struct SpaceClip;
struct ID;
-struct EvaluationContext;
#include "DNA_object_enums.h"
@@ -173,14 +172,13 @@ struct SpaceFile *CTX_wm_space_file(const bContext *C);
struct SpaceSeq *CTX_wm_space_seq(const bContext *C);
struct SpaceOops *CTX_wm_space_outliner(const bContext *C);
struct SpaceNla *CTX_wm_space_nla(const bContext *C);
-struct SpaceTime *CTX_wm_space_time(const bContext *C);
struct SpaceNode *CTX_wm_space_node(const bContext *C);
-struct SpaceLogic *CTX_wm_space_logic(const bContext *C);
struct SpaceIpo *CTX_wm_space_graph(const bContext *C);
struct SpaceAction *CTX_wm_space_action(const bContext *C);
struct SpaceInfo *CTX_wm_space_info(const bContext *C);
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C);
struct SpaceClip *CTX_wm_space_clip(const bContext *C);
+struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C);
void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm);
void CTX_wm_window_set(bContext *C, struct wmWindow *win);
@@ -246,6 +244,10 @@ void CTX_data_list_add(bContextDataResult *result, void *data);
BLI_freelistN(&ctx_data_list); \
} (void)0
+#define CTX_DATA_BEGIN_WITH_ID(C, Type, instance, member, Type_id, instance_id) \
+ CTX_DATA_BEGIN(C, Type, instance, member) \
+ Type_id instance_id = ctx_link->ptr.id.data; \
+
int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBase *));
#define CTX_DATA_COUNT(C, member) \
@@ -258,7 +260,6 @@ struct Scene *CTX_data_scene(const bContext *C);
struct LayerCollection *CTX_data_layer_collection(const bContext *C);
struct SceneCollection *CTX_data_scene_collection(const bContext *C);
struct ViewLayer *CTX_data_view_layer(const bContext *C);
-struct ViewRender *CTX_data_view_render(const bContext *C);
struct RenderEngineType *CTX_data_engine_type(const bContext *C);
struct ToolSettings *CTX_data_tool_settings(const bContext *C);
@@ -322,8 +323,6 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list);
struct Depsgraph *CTX_data_depsgraph(const bContext *C);
-void CTX_data_eval_ctx(const bContext *C, struct EvaluationContext *eval_ctx);
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_crazyspace.h b/source/blender/blenkernel/BKE_crazyspace.h
index 31542cd6f8a..e9745ed50fa 100644
--- a/source/blender/blenkernel/BKE_crazyspace.h
+++ b/source/blender/blenkernel/BKE_crazyspace.h
@@ -38,24 +38,24 @@ struct Scene;
struct Object;
struct BMEditMesh;
struct Mesh;
-struct EvaluationContext;
+struct Depsgraph;
/* crazyspace.c */
float (*BKE_crazyspace_get_mapped_editverts(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *obedit))[3];
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *obedit))[3];
void BKE_crazyspace_set_quats_editmesh(
struct BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4],
const bool use_select);
void BKE_crazyspace_set_quats_mesh(
struct Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4]);
int BKE_crazyspace_get_first_deform_matrices_editbmesh(
- const struct EvaluationContext *eval_ctx, struct Scene *, struct Object *, struct BMEditMesh *em,
+ struct Depsgraph *depsgraph, struct Scene *, struct Object *, struct BMEditMesh *em,
float (**deformmats)[3][3], float (**deformcos)[3]);
int BKE_sculpt_get_first_deform_matrices(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
float (**deformmats)[3][3], float (**deformcos)[3]);
void BKE_crazyspace_build_sculpt(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
float (**deformmats)[3][3], float (**deformcos)[3]);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index fbd05552255..975cea7364d 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -36,7 +36,7 @@
struct BezTriple;
struct Curve;
struct EditNurb;
-struct EvaluationContext;
+struct Depsgraph;
struct GHash;
struct ListBase;
struct Main;
@@ -123,13 +123,13 @@ void BKE_curve_editNurb_keyIndex_free(struct GHash **keyindex);
void BKE_curve_editNurb_free(struct Curve *cu);
struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu);
-float *BKE_curve_make_orco(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, int *r_numVerts);
+float *BKE_curve_make_orco(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, int *r_numVerts);
float *BKE_curve_surf_make_orco(struct Object *ob);
void BKE_curve_bevelList_free(struct ListBase *bev);
void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render);
void BKE_curve_bevel_make(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *disp,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *disp,
const bool for_render, const bool use_render_resolution);
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
@@ -218,7 +218,7 @@ void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles);
/* **** Depsgraph evaluation **** */
void BKE_curve_eval_geometry(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Curve *curve);
/* Draw Cache */
diff --git a/source/blender/blenkernel/BKE_data_transfer.h b/source/blender/blenkernel/BKE_data_transfer.h
index d5f0313ca64..6559f9a954f 100644
--- a/source/blender/blenkernel/BKE_data_transfer.h
+++ b/source/blender/blenkernel/BKE_data_transfer.h
@@ -38,11 +38,11 @@ extern "C" {
#include "BKE_customdata.h"
+struct Depsgraph;
struct Object;
struct Scene;
struct SpaceTransform;
struct ReportList;
-struct EvaluationContext;
/* Warning, those def are stored in files (TransferData modifier), *DO NOT* modify those values. */
enum {
@@ -130,12 +130,12 @@ enum {
};
void BKE_object_data_transfer_layout(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob_src,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob_src,
struct Object *ob_dst, const int data_types, const bool use_delete,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX]);
bool BKE_object_data_transfer_mesh(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_create,
const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
struct SpaceTransform *space_transform, const bool auto_transform,
@@ -144,7 +144,7 @@ bool BKE_object_data_transfer_mesh(
const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
struct ReportList *reports);
bool BKE_object_data_transfer_dm(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_dst,
const int data_types, bool use_create,
const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index c2229976dd9..09e9b667369 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -60,8 +60,8 @@ enum {
struct Scene;
struct Object;
struct ListBase;
+struct Depsgraph;
struct DerivedMesh;
-struct EvaluationContext;
/* used for curves, nurbs, mball, importing */
typedef struct DispList {
@@ -87,28 +87,28 @@ void BKE_displist_free(struct ListBase *lb);
bool BKE_displist_has_faces(struct ListBase *lb);
void BKE_displist_make_surf(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
struct DerivedMesh **r_dm_final, const bool for_render, const bool for_orco, const bool use_render_resolution);
void BKE_displist_make_curveTypes(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, const bool for_orco);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const bool for_orco);
void BKE_displist_make_curveTypes_forRender(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
struct DerivedMesh **r_dm_final, const bool for_orco, const bool use_render_resolution);
void BKE_displist_make_curveTypes_forOrco(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
void BKE_displist_make_mball(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_displist_make_mball_forRender(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4);
void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, const float normal_proj[3], const bool flipnormal);
-float BKE_displist_calc_taper(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *taperobj, int cur, int tot);
+float BKE_displist_calc_taper(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *taperobj, int cur, int tot);
/* add Orco layer to the displist object which has got derived mesh and return orco */
float *BKE_displist_make_orco(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final,
const bool for_render, const bool use_render_resolution);
void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index 21c900a7f0d..8f795bc7535 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -27,9 +27,9 @@
* \ingroup bke
*/
+struct Depsgraph;
struct Scene;
struct ViewLayer;
-struct EvaluationContext;
/* Actual surface point */
typedef struct PaintSurfaceData {
@@ -62,7 +62,7 @@ typedef struct PaintWavePoint {
short state;
} PaintWavePoint;
-struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, const struct EvaluationContext *eval_ctx, struct Scene *scene,
+struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, struct DerivedMesh *dm);
void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd);
void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tsmd);
@@ -86,7 +86,7 @@ struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings
/* image sequence baking */
int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, short *do_update);
-int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cObject, int frame);
+int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *cObject, int frame);
void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer);
/* PaintPoint state */
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h
index af1aeff230f..5e456fea64f 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -40,7 +40,7 @@ struct Mesh;
struct Scene;
struct DerivedMesh;
struct MeshStatVis;
-struct EvaluationContext;
+struct Depsgraph;
/**
* This structure is used for mesh edit-mode.
@@ -100,6 +100,6 @@ void BKE_editmesh_statvis_calc(BMEditMesh *em, struct DerivedMesh *dm,
const struct MeshStatVis *statvis);
float (*BKE_editmesh_vertexCos_get(
- const struct EvaluationContext *eval_ctx, struct BMEditMesh *em, struct Scene *scene, int *r_numVerts))[3];
+ struct Depsgraph *depsgraph, struct BMEditMesh *em, struct Scene *scene, int *r_numVerts))[3];
#endif /* __BKE_EDITMESH_H__ */
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index 6fa19d4aaf6..914dd650493 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -44,7 +44,7 @@ struct Group;
struct ParticleSimulationData;
struct ParticleData;
struct ParticleKey;
-struct EvaluationContext;
+struct Depsgraph;
struct EffectorWeights *BKE_add_effector_weights(struct Group *group);
struct PartDeflect *object_add_collision_fields(int type);
@@ -94,7 +94,7 @@ typedef struct EffectorData {
typedef struct EffectorCache {
struct EffectorCache *next, *prev;
- const struct EvaluationContext *eval_ctx;
+ struct Depsgraph *depsgraph;
struct Scene *scene;
struct Object *ob;
struct ParticleSystem *psys;
@@ -113,10 +113,10 @@ typedef struct EffectorCache {
void free_partdeflect(struct PartDeflect *pd);
struct ListBase *pdInitEffectors(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src,
struct EffectorWeights *weights, bool for_simulation);
void pdEndEffectors(struct ListBase **effectors);
-void pdPrecalculateEffectors(const struct EvaluationContext *eval_ctx, struct ListBase *effectors);
+void pdPrecalculateEffectors(struct Depsgraph *depsgraph, struct ListBase *effectors);
void pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse);
void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point);
diff --git a/source/blender/blenkernel/BKE_fluidsim.h b/source/blender/blenkernel/BKE_fluidsim.h
index 4ec58b2a0e5..8e04fe2c23a 100644
--- a/source/blender/blenkernel/BKE_fluidsim.h
+++ b/source/blender/blenkernel/BKE_fluidsim.h
@@ -36,11 +36,11 @@ struct Object;
struct Scene;
struct FluidsimSettings;
struct MVert;
-struct EvaluationContext;
+struct Depsgraph;
/* old interface */
-void initElbeemMesh(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+void initElbeemMesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
int *numVertices, float **vertices,
int *numTriangles, int **triangles,
int useGlobalCoords, int modifierIndex);
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index c1b437661c5..e184fd3796b 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -102,7 +102,6 @@ typedef struct Global {
/* G.f */
#define G_RENDER_OGL (1 << 0)
#define G_SWAP_EXCHANGE (1 << 1)
-/* also uses G_FILE_AUTOPLAY */
/* #define G_RENDER_SHADOW (1 << 3) */ /* temp flag, removed */
#define G_BACKBUFSEL (1 << 4)
#define G_PICKSEL (1 << 5)
@@ -154,16 +153,6 @@ enum {
#define G_AUTOPACK (1 << 0)
#define G_FILE_COMPRESS (1 << 1)
-#define G_FILE_AUTOPLAY (1 << 2)
-
-#ifdef DNA_DEPRECATED_ALLOW
-#define G_FILE_ENABLE_ALL_FRAMES (1 << 3) /* deprecated */
-#define G_FILE_SHOW_DEBUG_PROPS (1 << 4) /* deprecated */
-#define G_FILE_SHOW_FRAMERATE (1 << 5) /* deprecated */
-/* #define G_FILE_SHOW_PROFILE (1 << 6) */ /* deprecated */
-/* #define G_FILE_LOCK (1 << 7) */ /* deprecated */
-/* #define G_FILE_SIGN (1 << 8) */ /* deprecated */
-#endif /* DNA_DEPRECATED_ALLOW */
#define G_FILE_USERPREFS (1 << 9)
#define G_FILE_NO_UI (1 << 10)
diff --git a/source/blender/blenkernel/BKE_groom.h b/source/blender/blenkernel/BKE_groom.h
index e88513b5480..ef15223dd45 100644
--- a/source/blender/blenkernel/BKE_groom.h
+++ b/source/blender/blenkernel/BKE_groom.h
@@ -32,7 +32,7 @@
* \ingroup bke
*/
-struct EvaluationContext;
+struct Depsgraph;
struct Groom;
struct GroomBundle;
struct Main;
@@ -80,7 +80,7 @@ void BKE_groom_hair_update_guide_curves(struct Groom *groom);
/* === Depsgraph evaluation === */
-void BKE_groom_eval_geometry(const struct EvaluationContext *eval_ctx, struct Groom *groom);
+void BKE_groom_eval_geometry(struct Depsgraph *depsgraph, struct Groom *groom);
/* === Draw Cache === */
diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h
index a842bec7609..0195d1f1243 100644
--- a/source/blender/blenkernel/BKE_group.h
+++ b/source/blender/blenkernel/BKE_group.h
@@ -34,7 +34,7 @@
*/
struct Base;
-struct EvaluationContext;
+struct Depsgraph;
struct Group;
struct Main;
struct Object;
@@ -53,11 +53,11 @@ bool BKE_group_object_exists(struct Group *group, struct Object *ob);
bool BKE_group_object_cyclic_check(struct Main *bmain, struct Object *object, struct Group *group);
bool BKE_group_is_animated(struct Group *group, struct Object *parent);
-void BKE_group_handle_recalc_and_update(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *parent, struct Group *group);
+void BKE_group_handle_recalc_and_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *parent, struct Group *group);
/* Dependency graph evaluation. */
-void BKE_group_eval_view_layers(const struct EvaluationContext *eval_ctx,
+void BKE_group_eval_view_layers(struct Depsgraph *depsgraph,
struct Group *group);
/* Helper macros. */
diff --git a/source/blender/blenkernel/BKE_hair.h b/source/blender/blenkernel/BKE_hair.h
index be526233ac6..3c5ba7803a4 100644
--- a/source/blender/blenkernel/BKE_hair.h
+++ b/source/blender/blenkernel/BKE_hair.h
@@ -40,6 +40,7 @@ struct HairFollicle;
struct HairPattern;
struct HairSystem;
struct HairDrawSettings;
+struct HairGuideData;
struct DerivedMesh;
struct MeshSample;
struct Object;
diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.h
index a9ca5cc8bbb..47cac895645 100644
--- a/source/blender/blenkernel/BKE_icons.h
+++ b/source/blender/blenkernel/BKE_icons.h
@@ -36,13 +36,39 @@
typedef void (*DrawInfoFreeFP)(void *drawinfo);
+enum {
+ /** ID preview: obj is #ID. */
+ ICON_DATA_ID = 0,
+ /** Preview: obj is #PreviewImage */
+ ICON_DATA_PREVIEW,
+ /** 2D triangles: obj is #Icon_Geom */
+ ICON_DATA_GEOM,
+};
+
struct Icon {
void *drawinfo;
+ /**
+ * Data defined by #obj_type
+ * \note for #ICON_DATA_GEOM the memory is owned by the icon,
+ * could be made into a flag if we want that to be optional.
+ */
void *obj;
- short type;
+ char obj_type;
+ /** Internal use only. */
+ char flag;
+ /** #ID_Type or 0 when not used for ID preview. */
+ short id_type;
DrawInfoFreeFP drawinfo_free;
};
+/** Used for #ICON_DATA_GEOM, assigned to #Icon.obj. */
+struct Icon_Geom {
+ int icon_id;
+ int coords_len;
+ const unsigned char (*coords)[2];
+ const unsigned char (*colors)[4];
+};
+
typedef struct Icon Icon;
struct PreviewImage;
@@ -57,6 +83,8 @@ int BKE_icon_id_ensure(struct ID *id);
int BKE_icon_preview_ensure(struct ID *id, struct PreviewImage *preview);
+int BKE_icon_geom_ensure(struct Icon_Geom *geom);
+
/* retrieve icon for id */
struct Icon *BKE_icon_get(const int icon_id);
@@ -67,7 +95,8 @@ void BKE_icon_set(const int icon_id, struct Icon *icon);
/* remove icon and free data if library object becomes invalid */
void BKE_icon_id_delete(struct ID *id);
-void BKE_icon_delete(const int icon_id);
+bool BKE_icon_delete(const int icon_id);
+bool BKE_icon_delete_unmanaged(const int icon_id);
/* report changes - icon needs to be recalculated */
void BKE_icon_changed(const int icon_id);
@@ -75,6 +104,9 @@ void BKE_icon_changed(const int icon_id);
/* free all icons */
void BKE_icons_free(void);
+/* free all icons marked for deferred deletion */
+void BKE_icons_deferred_free(void);
+
/* free the preview image for use in list */
void BKE_previewimg_freefunc(void *link);
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index 1cdf193f054..1e3921747a5 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -43,7 +43,7 @@ struct Scene;
struct DerivedMesh;
struct BPoint;
struct MDeformVert;
-struct EvaluationContext;
+struct Depsgraph;
void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
void BKE_lattice_init(struct Lattice *lt);
@@ -79,7 +79,7 @@ void armature_deform_verts(struct Object *armOb, struct Object *target,
float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3];
void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]);
-void BKE_lattice_modifiers_calc(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *lattice);
struct BPoint *BKE_lattice_active_point_get(struct Lattice *lt);
@@ -101,9 +101,9 @@ void BKE_lattice_bitmap_from_flag(struct Lattice *lt, unsigned int *bitmap, cons
/* **** Depsgraph evaluation **** */
-struct EvaluationContext;
+struct Depsgraph;
-void BKE_lattice_eval_geometry(const struct EvaluationContext *eval_ctx,
+void BKE_lattice_eval_geometry(struct Depsgraph *depsgraph,
struct Lattice *latt);
/* Draw Cache */
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 9c06ae4f40d..79b61b7c965 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -42,7 +42,7 @@ extern "C" {
#define ROOT_PROP "root"
struct Base;
-struct EvaluationContext;
+struct Depsgraph;
struct Group;
struct ID;
struct IDProperty;
@@ -169,67 +169,116 @@ void BKE_collection_engine_property_value_set_bool(struct IDProperty *props, con
/* evaluation */
-void BKE_layer_eval_view_layer(const struct EvaluationContext *eval_ctx,
- struct ID *owner_id,
- struct ViewLayer *view_layer);
+void BKE_layer_eval_view_layer(
+ struct Depsgraph *depsgraph,
+ struct ID *owner_id,
+ struct ViewLayer *view_layer);
-void BKE_layer_eval_view_layer_indexed(const struct EvaluationContext *eval_ctx,
- struct ID *owner_id,
- int view_layer_index);
+void BKE_layer_eval_view_layer_indexed(
+ struct Depsgraph *depsgraph,
+ struct ID *owner_id,
+ int view_layer_index);
/* iterators */
-void BKE_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
-void BKE_selected_objects_iterator_next(BLI_Iterator *iter);
-void BKE_selected_objects_iterator_end(BLI_Iterator *iter);
+void BKE_view_layer_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
+void BKE_view_layer_selected_objects_iterator_next(BLI_Iterator *iter);
+void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *iter);
+
+void BKE_view_layer_visible_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
+void BKE_view_layer_visible_objects_iterator_next(BLI_Iterator *iter);
+void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *iter);
-void BKE_visible_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
-void BKE_visible_objects_iterator_next(BLI_Iterator *iter);
-void BKE_visible_objects_iterator_end(BLI_Iterator *iter);
+struct ObjectsInModeIteratorData {
+ int object_mode;
+ struct ViewLayer *view_layer;
+ struct Base *base_active;
+};
+
+void BKE_view_layer_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
+void BKE_view_layer_renderable_objects_iterator_next(BLI_Iterator *iter);
+void BKE_view_layer_renderable_objects_iterator_end(BLI_Iterator *iter);
-void BKE_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
-void BKE_renderable_objects_iterator_next(BLI_Iterator *iter);
-void BKE_renderable_objects_iterator_end(BLI_Iterator *iter);
+void BKE_view_layer_bases_in_mode_iterator_begin(BLI_Iterator *iter, void *data_in);
+void BKE_view_layer_bases_in_mode_iterator_next(BLI_Iterator *iter);
+void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *iter);
-void BKE_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in);
-void BKE_selected_bases_iterator_next(BLI_Iterator *iter);
-void BKE_selected_bases_iterator_end(BLI_Iterator *iter);
+void BKE_view_layer_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in);
+void BKE_view_layer_selected_bases_iterator_next(BLI_Iterator *iter);
+void BKE_view_layer_selected_bases_iterator_end(BLI_Iterator *iter);
-void BKE_visible_bases_iterator_begin(BLI_Iterator *iter, void *data_in);
-void BKE_visible_bases_iterator_next(BLI_Iterator *iter);
-void BKE_visible_bases_iterator_end(BLI_Iterator *iter);
+void BKE_view_layer_visible_bases_iterator_begin(BLI_Iterator *iter, void *data_in);
+void BKE_view_layer_visible_bases_iterator_next(BLI_Iterator *iter);
+void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
#define FOREACH_SELECTED_OBJECT_BEGIN(view_layer, _instance) \
- ITER_BEGIN(BKE_selected_objects_iterator_begin, \
- BKE_selected_objects_iterator_next, \
- BKE_selected_objects_iterator_end, \
+ ITER_BEGIN(BKE_view_layer_selected_objects_iterator_begin, \
+ BKE_view_layer_selected_objects_iterator_next, \
+ BKE_view_layer_selected_objects_iterator_end, \
view_layer, Object *, _instance)
#define FOREACH_SELECTED_OBJECT_END \
ITER_END
#define FOREACH_VISIBLE_OBJECT_BEGIN(view_layer, _instance) \
- ITER_BEGIN(BKE_visible_objects_iterator_begin, \
- BKE_visible_objects_iterator_next, \
- BKE_visible_objects_iterator_end, \
+ ITER_BEGIN(BKE_view_layer_visible_objects_iterator_begin, \
+ BKE_view_layer_visible_objects_iterator_next, \
+ BKE_view_layer_visible_objects_iterator_end, \
view_layer, Object *, _instance)
#define FOREACH_VISIBLE_OBJECT_END \
ITER_END
-#define FOREACH_SELECTED_BASE_BEGIN(view_layer, _instance) \
- ITER_BEGIN(BKE_selected_bases_iterator_begin, \
- BKE_selected_bases_iterator_next, \
- BKE_selected_bases_iterator_end, \
+
+#define FOREACH_BASE_IN_MODE_BEGIN(_view_layer, _object_mode, _instance) \
+{ \
+ struct ObjectsInModeIteratorData data_ = { \
+ .object_mode = _object_mode, \
+ .view_layer = _view_layer, \
+ .base_active = _view_layer->basact, \
+ }; \
+ ITER_BEGIN(BKE_view_layer_bases_in_mode_iterator_begin, \
+ BKE_view_layer_bases_in_mode_iterator_next, \
+ BKE_view_layer_bases_in_mode_iterator_end, \
+ &data_, Base *, _instance)
+
+#define FOREACH_BASE_IN_MODE_END \
+ ITER_END; \
+} ((void)0)
+
+#define FOREACH_BASE_IN_EDIT_MODE_BEGIN(_view_layer, _instance) \
+ FOREACH_BASE_IN_MODE_BEGIN(_view_layer, OB_MODE_EDIT, _instance)
+
+#define FOREACH_BASE_IN_EDIT_MODE_END \
+ FOREACH_BASE_IN_MODE_END
+
+#define FOREACH_OBJECT_IN_MODE_BEGIN(_view_layer, _object_mode, _instance) \
+ FOREACH_BASE_IN_MODE_BEGIN(_view_layer, _object_mode, _base) { \
+ Object *_instance = _base->object;
+
+#define FOREACH_OBJECT_IN_MODE_END \
+ } FOREACH_BASE_IN_MODE_END
+
+#define FOREACH_OBJECT_IN_EDIT_MODE_BEGIN(_view_layer, _instance) \
+ FOREACH_BASE_IN_EDIT_MODE_BEGIN(_view_layer, _base) { \
+ Object *_instance = _base->object;
+
+#define FOREACH_OBJECT_IN_EDIT_MODE_END \
+ } FOREACH_BASE_IN_EDIT_MODE_END
+
+#define FOREACH_SELECTED_BASE_BEGIN(view_layer, _instance) \
+ ITER_BEGIN(BKE_view_layer_selected_bases_iterator_begin, \
+ BKE_view_layer_selected_bases_iterator_next, \
+ BKE_view_layer_selected_bases_iterator_end, \
view_layer, Base *, _instance)
-#define FOREACH_SELECTED_BASE_END \
+#define FOREACH_SELECTED_BASE_END \
ITER_END
#define FOREACH_VISIBLE_BASE_BEGIN(view_layer, _instance) \
- ITER_BEGIN(BKE_visible_bases_iterator_begin, \
- BKE_visible_bases_iterator_next, \
- BKE_visible_bases_iterator_end, \
+ ITER_BEGIN(BKE_view_layer_visible_bases_iterator_begin, \
+ BKE_view_layer_visible_bases_iterator_next, \
+ BKE_view_layer_visible_bases_iterator_end, \
view_layer, Base *, _instance)
#define FOREACH_VISIBLE_BASE_END \
@@ -254,9 +303,9 @@ void BKE_visible_bases_iterator_end(BLI_Iterator *iter);
void *data_in; \
\
if (flag == SELECT) { \
- func_begin = &BKE_selected_objects_iterator_begin; \
- func_next = &BKE_selected_objects_iterator_next; \
- func_end = &BKE_selected_objects_iterator_end; \
+ func_begin = &BKE_view_layer_selected_objects_iterator_begin; \
+ func_next = &BKE_view_layer_selected_objects_iterator_next; \
+ func_end = &BKE_view_layer_selected_objects_iterator_end; \
data_in = (view_layer); \
} \
else { \
@@ -286,12 +335,12 @@ struct ObjectsRenderableIteratorData {
#define FOREACH_OBJECT_RENDERABLE_BEGIN(scene_, _instance) \
{ \
- struct ObjectsRenderableIteratorData data_ = { \
+ struct ObjectsRenderableIteratorData data_ = { \
.scene = (scene_), \
}; \
- ITER_BEGIN(BKE_renderable_objects_iterator_begin, \
- BKE_renderable_objects_iterator_next, \
- BKE_renderable_objects_iterator_end, \
+ ITER_BEGIN(BKE_view_layer_renderable_objects_iterator_begin, \
+ BKE_view_layer_renderable_objects_iterator_next, \
+ BKE_view_layer_renderable_objects_iterator_end, \
&data_, Object *, _instance)
@@ -299,6 +348,70 @@ struct ObjectsRenderableIteratorData {
ITER_END; \
} ((void)0)
+
+/* layer_utils.c */
+
+struct ObjectsInModeParams {
+ int object_mode;
+ uint no_dup_data : 1;
+
+ bool (*filter_fn)(struct Object *ob, void *user_data);
+ void *filter_userdata;
+};
+
+Base **BKE_view_layer_array_from_bases_in_mode_params(
+ struct ViewLayer *view_layer, uint *r_len,
+ const struct ObjectsInModeParams *params);
+
+struct Object **BKE_view_layer_array_from_objects_in_mode_params(
+ struct ViewLayer *view_layer, uint *len,
+ const struct ObjectsInModeParams *params);
+
+#define BKE_view_layer_array_from_objects_in_mode(view_layer, r_len, ...) \
+ BKE_view_layer_array_from_objects_in_mode_params( \
+ view_layer, r_len, \
+ &(const struct ObjectsInModeParams)__VA_ARGS__)
+
+#define BKE_view_layer_array_from_bases_in_mode(view_layer, r_len, ...) \
+ BKE_view_layer_array_from_bases_in_mode_params( \
+ view_layer, r_len, \
+ &(const struct ObjectsInModeParams)__VA_ARGS__)
+
+bool BKE_view_layer_filter_edit_mesh_has_uvs(struct Object *ob, void *user_data);
+bool BKE_view_layer_filter_edit_mesh_has_edges(struct Object *ob, void *user_data);
+
+/* Utility macros that wrap common args (add more as needed). */
+
+#define BKE_view_layer_array_from_objects_in_edit_mode(view_layer, r_len) \
+ BKE_view_layer_array_from_objects_in_mode( \
+ view_layer, r_len, { \
+ .object_mode = OB_MODE_EDIT});
+
+#define BKE_view_layer_array_from_bases_in_edit_mode(view_layer, r_len) \
+ BKE_view_layer_array_from_bases_in_mode( \
+ view_layer, r_len, { \
+ .object_mode = OB_MODE_EDIT});
+
+#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, r_len) \
+ BKE_view_layer_array_from_objects_in_mode( \
+ view_layer, r_len, { \
+ .object_mode = OB_MODE_EDIT, \
+ .no_dup_data = true});
+
+#define BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, r_len) \
+ BKE_view_layer_array_from_bases_in_mode( \
+ view_layer, r_len, { \
+ .object_mode = OB_MODE_EDIT, \
+ .no_dup_data = true});
+
+#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, r_len) \
+ BKE_view_layer_array_from_objects_in_mode( \
+ view_layer, r_len, { \
+ .object_mode = OB_MODE_EDIT, \
+ .no_dup_data = true, \
+ .filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs});
+
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_library_override.h b/source/blender/blenkernel/BKE_library_override.h
index 35672cb5ded..6f32d565562 100644
--- a/source/blender/blenkernel/BKE_library_override.h
+++ b/source/blender/blenkernel/BKE_library_override.h
@@ -65,8 +65,8 @@ void BKE_override_static_property_operation_delete(
bool BKE_override_static_status_check_local(struct ID *local);
bool BKE_override_static_status_check_reference(struct ID *local);
-bool BKE_override_static_operations_create(struct ID *local);
-void BKE_main_override_static_operations_create(struct Main *bmain);
+bool BKE_override_static_operations_create(struct ID *local, const bool force_auto);
+void BKE_main_override_static_operations_create(struct Main *bmain, const bool force_auto);
void BKE_override_static_update(struct Main *bmain, struct ID *local);
void BKE_main_override_static_update(struct Main *bmain);
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 3e767e85142..39e6b575c80 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -48,7 +48,7 @@
extern "C" {
#endif
-struct EvaluationContext;
+struct Depsgraph;
struct Library;
struct MainLock;
struct GHash;
@@ -131,9 +131,6 @@ typedef struct Main {
char id_tag_update[MAX_LIBARRAY];
- /* Evaluation context used by viewport */
- struct EvaluationContext *eval_ctx;
-
/* Must be generated, used and freed by same code - never assume this is valid data unless you know
* when, who and how it was created.
* Used by code doing a lot of remapping etc. at once to speed things up. */
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index 8b9fea071b0..976ee5b2691 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -32,7 +32,7 @@
* \ingroup bke
*/
-struct EvaluationContext;
+struct Depsgraph;
struct ImageUser;
struct Image;
struct ListBase;
@@ -236,8 +236,8 @@ float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct Mas
void BKE_mask_layer_evaluate_animation(struct MaskLayer *masklay, const float ctime);
void BKE_mask_layer_evaluate_deform(struct MaskLayer *masklay, const float ctime);
-void BKE_mask_eval_animation(struct EvaluationContext *eval_ctx, struct Mask *mask);
-void BKE_mask_eval_update(struct EvaluationContext *eval_ctx, struct Mask *mask);
+void BKE_mask_eval_animation(struct Depsgraph *depsgraph, struct Mask *mask);
+void BKE_mask_eval_update(struct Depsgraph *depsgraph, struct Mask *mask);
/* mask_rasterize.c */
struct MaskRasterHandle;
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index f4c98fc0aea..43f36618c19 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -87,10 +87,6 @@ short BKE_object_material_slot_find_index(struct Object *ob, struct Material *ma
bool BKE_object_material_slot_add(struct Object *ob);
bool BKE_object_material_slot_remove(struct Object *ob);
-struct Image *BKE_object_material_edit_image_get(struct Object *ob, short mat_nr);
-struct Image **BKE_object_material_edit_image_get_array(struct Object *ob);
-bool BKE_object_material_edit_image_set(struct Object *ob, short mat_nr, struct Image *image);
-
void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma);
void BKE_texpaint_slots_refresh_object(struct Scene *scene, struct Object *ob);
@@ -101,13 +97,6 @@ struct Material *BKE_material_pop_id(struct Main *bmain, struct ID *id, int inde
void BKE_material_clear_id(struct Main *bmain, struct ID *id, bool update_data);
/* rendering */
-void init_render_material(struct Material *, int, float *);
-void init_render_materials(struct Main *, int r_mode, float *amd, bool do_default_material);
-void end_render_material(struct Material *);
-void end_render_materials(struct Main *);
-
-bool material_in_material(struct Material *parmat, struct Material *mat);
-
void ramp_blend(int type, float r_col[3], const float fac, const float col[3]);
/* copy/paste */
@@ -118,9 +107,9 @@ void paste_matcopybuf(struct Material *ma);
/* Evaluation. */
-struct EvaluationContext;
+struct Depsgraph;
-void BKE_material_eval(const struct EvaluationContext *eval_ctx, struct Material *material);
+void BKE_material_eval(struct Depsgraph *depsgraph, struct Material *material);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index d4776d890d2..b05a35e614f 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -32,6 +32,7 @@
* \since March 2001
* \author nzc
*/
+struct Depsgraph;
struct Main;
struct MetaBall;
struct Object;
@@ -71,9 +72,9 @@ void BKE_mball_select_swap(struct MetaBall *mb);
/* **** Depsgraph evaluation **** */
-struct EvaluationContext;
+struct Depsgraph;
-void BKE_mball_eval_geometry(const struct EvaluationContext *eval_ctx,
+void BKE_mball_eval_geometry(struct Depsgraph *depsgraph,
struct MetaBall *mball);
/* Draw Cache */
diff --git a/source/blender/blenkernel/BKE_mball_tessellate.h b/source/blender/blenkernel/BKE_mball_tessellate.h
index 40cdc80e280..df652df177d 100644
--- a/source/blender/blenkernel/BKE_mball_tessellate.h
+++ b/source/blender/blenkernel/BKE_mball_tessellate.h
@@ -23,12 +23,12 @@
/** \file BKE_mball_tessellate.h
* \ingroup bke
*/
-struct EvaluationContext;
+struct Depsgraph;
struct Object;
struct Scene;
void BKE_mball_polygonize(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, struct ListBase *dispbase);
void BKE_mball_cubeTable_free(void);
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 79d72206903..e2265ae855e 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -34,8 +34,8 @@
struct ID;
struct BMeshCreateParams;
struct BoundBox;
+struct Depsgraph;
struct EdgeHash;
-struct EvaluationContext;
struct ListBase;
struct LinkNode;
struct BLI_Stack;
@@ -119,7 +119,7 @@ void BKE_mesh_from_nurbs_displist(
struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name);
void BKE_mesh_from_nurbs(struct Object *ob);
void BKE_mesh_to_curve_nurblist(struct DerivedMesh *dm, struct ListBase *nurblist, const int edge_users_test);
-void BKE_mesh_to_curve(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void BKE_mesh_to_curve(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_mesh_material_index_remove(struct Mesh *me, short index);
void BKE_mesh_material_index_clear(struct Mesh *me);
void BKE_mesh_material_remap(struct Mesh *me, const unsigned int *remap, unsigned int remap_len);
@@ -140,7 +140,7 @@ float (*BKE_mesh_vertexCos_get(const struct Mesh *me, int *r_numVerts))[3];
void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals);
-struct Mesh *BKE_mesh_new_from_object(const struct EvaluationContext *eval_ctx, struct Main *bmain, struct Scene *sce, struct Object *ob,
+struct Mesh *BKE_mesh_new_from_object(struct Depsgraph *depsgraph, struct Main *bmain, struct Scene *sce, struct Object *ob,
int apply_modifiers, int calc_tessface, int calc_undeformed);
/* vertex level transformations & checks (no derived mesh) */
@@ -442,7 +442,7 @@ void BKE_mesh_calc_edges(struct Mesh *mesh, bool update, const bool select);
/* **** Depsgraph evaluation **** */
-void BKE_mesh_eval_geometry(const struct EvaluationContext *eval_ctx,
+void BKE_mesh_eval_geometry(struct Depsgraph *depsgraph,
struct Mesh *mesh);
/* Draw Cache */
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 329defbc77c..c81c0f7c4c0 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -33,8 +33,8 @@
#include "BKE_customdata.h"
struct ID;
+struct Depsgraph;
struct DerivedMesh;
-struct EvaluationContext;
struct Object;
struct Scene;
struct ViewLayer;
@@ -163,25 +163,25 @@ typedef struct ModifierTypeInfo {
* the object it can obtain it from the derivedData argument if non-NULL,
* and otherwise the ob argument.
*/
- void (*deformVerts)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ void (*deformVerts)(struct ModifierData *md, struct Depsgraph *depsgraph,
struct Object *ob, struct DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag flag);
/* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */
- void (*deformMatrices)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ void (*deformMatrices)(struct ModifierData *md, struct Depsgraph *depsgraph,
struct Object *ob, struct DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
/* Like deformVerts but called during editmode (for supporting modifiers)
*/
- void (*deformVertsEM)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ void (*deformVertsEM)(struct ModifierData *md, struct Depsgraph *depsgraph,
struct Object *ob, struct BMEditMesh *editData,
struct DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts);
/* Set deform matrix per vertex for crazyspace correction */
- void (*deformMatricesEM)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ void (*deformMatricesEM)(struct ModifierData *md, struct Depsgraph *depsgraph,
struct Object *ob, struct BMEditMesh *editData,
struct DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
@@ -207,7 +207,7 @@ typedef struct ModifierTypeInfo {
* The modifier may reuse the derivedData argument (i.e. return it in
* modified form), but must not release it.
*/
- struct DerivedMesh *(*applyModifier)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct DerivedMesh *(*applyModifier)(struct ModifierData *md, struct Depsgraph *depsgraph,
struct Object *ob, struct DerivedMesh *derivedData,
ModifierApplyFlag flag);
@@ -218,7 +218,7 @@ typedef struct ModifierTypeInfo {
* are expected from editmode objects. The same qualifications regarding
* derivedData apply as for applyModifier.
*/
- struct DerivedMesh *(*applyModifierEM)(struct ModifierData *md, const struct EvaluationContext *eval_ctx,
+ struct DerivedMesh *(*applyModifierEM)(struct ModifierData *md, struct Depsgraph *depsgraph,
struct Object *ob, struct BMEditMesh *editData,
struct DerivedMesh *derivedData, ModifierApplyFlag flag);
@@ -422,24 +422,24 @@ const char *modifier_path_relbase(struct Object *ob);
/* wrappers for modifier callbacks */
struct DerivedMesh *modwrap_applyModifier(
- ModifierData *md, const struct EvaluationContext *eval_ctx,
+ ModifierData *md, struct Depsgraph *depsgraph,
struct Object *ob, struct DerivedMesh *dm,
ModifierApplyFlag flag);
struct DerivedMesh *modwrap_applyModifierEM(
- ModifierData *md, const struct EvaluationContext *eval_ctx,
+ ModifierData *md, struct Depsgraph *depsgraph,
struct Object *ob, struct BMEditMesh *em,
struct DerivedMesh *dm,
ModifierApplyFlag flag);
void modwrap_deformVerts(
- ModifierData *md, const struct EvaluationContext *eval_ctx,
+ ModifierData *md, struct Depsgraph *depsgraph,
struct Object *ob, struct DerivedMesh *dm,
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag flag);
void modwrap_deformVertsEM(
- ModifierData *md, const struct EvaluationContext *eval_ctx, struct Object *ob,
+ ModifierData *md, struct Depsgraph *depsgraph, struct Object *ob,
struct BMEditMesh *em, struct DerivedMesh *dm,
float (*vertexCos)[3], int numVerts);
diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h
index 818f79ad8ac..5b5ebbf035c 100644
--- a/source/blender/blenkernel/BKE_movieclip.h
+++ b/source/blender/blenkernel/BKE_movieclip.h
@@ -32,7 +32,7 @@
* \author Sergey Sharybin
*/
-struct EvaluationContext;
+struct Depsgraph;
struct ImBuf;
struct Main;
struct MovieClip;
@@ -85,7 +85,7 @@ bool BKE_movieclip_has_cached_frame(struct MovieClip *clip, struct MovieClipUser
bool BKE_movieclip_put_frame_if_possible(struct MovieClip *clip, struct MovieClipUser *user, struct ImBuf *ibuf);
/* Evaluaiton. */
-void BKE_movieclip_eval_update(struct EvaluationContext *eval_ctx, struct MovieClip *clip);
+void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, struct MovieClip *clip);
/* cacheing flags */
#define MOVIECLIP_CACHE_SKIP (1 << 0)
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index 761bb7e8acb..10bc367e909 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -33,8 +33,8 @@
*/
enum MultiresModifiedFlags;
+struct Depsgraph;
struct DerivedMesh;
-struct EvaluationContext;
struct MDisps;
struct Mesh;
struct ModifierData;
@@ -81,18 +81,18 @@ struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm,
struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene,
struct ModifierData *lastmd);
struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first);
-struct DerivedMesh *get_multires_dm(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
+struct DerivedMesh *get_multires_dm(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob);
void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction);
void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob);
void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple);
void multiresModifier_sync_levels_ex(
struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst);
-int multiresModifier_reshape(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
+int multiresModifier_reshape(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *dst, struct Object *src);
-int multiresModifier_reshapeFromDM(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDM(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob, struct DerivedMesh *srcdm);
-int multiresModifier_reshapeFromDeformMod(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDeformMod(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob, struct ModifierData *md);
void multires_stitch_grids(struct Object *);
@@ -110,8 +110,8 @@ void multires_free(struct Multires *mr);
void multires_load_old(struct Object *ob, struct Mesh *me);
void multires_load_old_250(struct Mesh *);
-void multiresModifier_scale_disp(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
-void multiresModifier_prepare_join(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *to_ob);
+void multiresModifier_scale_disp(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
+void multiresModifier_prepare_join(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct Object *to_ob);
int multires_mdisp_corners(struct MDisps *s);
diff --git a/source/blender/blenkernel/BKE_navmesh_conversion.h b/source/blender/blenkernel/BKE_navmesh_conversion.h
deleted file mode 100644
index 3be363f4d7b..00000000000
--- a/source/blender/blenkernel/BKE_navmesh_conversion.h
+++ /dev/null
@@ -1,67 +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 *****
- */
-
-#ifndef __BKE_NAVMESH_CONVERSION_H__
-#define __BKE_NAVMESH_CONVERSION_H__
-
-/** \file BKE_navmesh_conversion.h
- * \ingroup bke
- */
-
-struct DerivedMesh;
-
-/* navmesh_conversion.c */
-int buildNavMeshDataByDerivedMesh(struct DerivedMesh *dm, int *vertsPerPoly,
- int *nverts, float **verts,
- int *ndtris, unsigned short **dtris,
- int *npolys, unsigned short **dmeshes,
- unsigned short **polys, int **dtrisToPolysMap,
- int **dtrisToTrisMap, int **trisToFacesMap);
-
-int buildRawVertIndicesData(struct DerivedMesh *dm, int *nverts, float **verts,
- int *ntris, unsigned short **tris, int **trisToFacesMap,
- int **recastData);
-
-int buildNavMeshData(const int nverts, const float *verts,
- const int ntris, const unsigned short *tris,
- const int *recastData, const int *trisToFacesMap,
- int *ndtris, unsigned short **dtris,
- int *npolys, unsigned short **dmeshes, unsigned short **polys,
- int *vertsPerPoly, int **dtrisToPolysMap, int **dtrisToTrisMap);
-
-int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
- unsigned short *polys, const unsigned short *dmeshes,
- const float *verts, const unsigned short *dtris,
- const int *dtrisToPolysMap);
-
-int polyNumVerts(const unsigned short *p, const int vertsPerPoly);
-int polyIsConvex(const unsigned short *p, const int vertsPerPoly, const float *verts);
-int polyFindVertex(const unsigned short *p, const int vertsPerPoly, unsigned short vertexIdx);
-float distPointToSegmentSq(const float *point, const float *a, const float *b);
-
-
-#endif /* NAVMESH_CONVERSION_H */
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 6427a87a182..d85f4095eb9 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -283,7 +283,7 @@ typedef struct bNodeTreeType {
/* callbacks */
void (*free_cache)(struct bNodeTree *ntree);
void (*free_node_cache)(struct bNodeTree *ntree, struct bNode *node);
- void (*foreach_nodeclass)(struct ViewRender *view_render, void *calldata, bNodeClassCallback func); /* iteration over all node classes */
+ void (*foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func); /* iteration over all node classes */
/* Check visibility in the node editor */
int (*poll)(const struct bContext *C, struct bNodeTreeType *ntreetype);
/* Select a node tree from the context */
@@ -498,7 +498,6 @@ struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree);
void nodeUpdate(struct bNodeTree *ntree, struct bNode *node);
bool nodeUpdateID(struct bNodeTree *ntree, struct ID *id);
void nodeUpdateInternalLinks(struct bNodeTree *ntree, struct bNode *node);
-void nodeSynchronizeID(struct bNode *node, bool copy_to_id);
int nodeSocketIsHidden(struct bNodeSocket *sock);
void ntreeTagUsedSockets(struct bNodeTree *ntree);
@@ -702,24 +701,22 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, c
/* -------------------------------------------------------------------- */
/** \name Shader Nodes
* \{ */
-struct ShadeInput;
-struct ShadeResult;
/* note: types are needed to restore callbacks, don't change values */
/* range 1 - 100 is reserved for common nodes */
/* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
-#define SH_NODE_OUTPUT 1
+//#define SH_NODE_OUTPUT 1
-#define SH_NODE_MATERIAL 100
+//#define SH_NODE_MATERIAL 100
#define SH_NODE_RGB 101
#define SH_NODE_VALUE 102
#define SH_NODE_MIX_RGB 103
#define SH_NODE_VALTORGB 104
#define SH_NODE_RGBTOBW 105
-#define SH_NODE_TEXTURE 106
+//#define SH_NODE_TEXTURE 106
#define SH_NODE_NORMAL 107
-#define SH_NODE_GEOMETRY 108
+//#define SH_NODE_GEOMETRY 108
#define SH_NODE_MAPPING 109
#define SH_NODE_CURVE_VEC 110
#define SH_NODE_CURVE_RGB 111
@@ -727,7 +724,7 @@ struct ShadeResult;
#define SH_NODE_MATH 115
#define SH_NODE_VECT_MATH 116
#define SH_NODE_SQUEEZE 117
-#define SH_NODE_MATERIAL_EXT 118
+//#define SH_NODE_MATERIAL_EXT 118
#define SH_NODE_INVERT 119
#define SH_NODE_SEPRGB 120
#define SH_NODE_COMBRGB 121
@@ -813,12 +810,7 @@ struct ShadeResult;
struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree);
void ntreeShaderEndExecTree(struct bNodeTreeExec *exec);
-bool ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
-void ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short *texco, int *mode);
-
-/* switch material render loop */
-extern void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *);
-void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
+bool ntreeShaderExecTree(struct bNodeTree *ntree, int thread);
void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat, short compatibility);
void ntreeGPUMaterialDomain(struct bNodeTree *ntree, bool *has_surface_output, bool *has_volume_output);
@@ -1051,7 +1043,7 @@ struct bNodeTreeExec *ntreeTexBeginExecTree(struct bNodeTree *ntree);
void ntreeTexEndExecTree(struct bNodeTreeExec *exec);
int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target,
float coord[3], float dxt[3], float dyt[3], int osatex, const short thread,
- struct Tex *tex, short which_output, int cfra, int preview, struct ShadeInput *shi, struct MTex *mtex);
+ struct Tex *tex, short which_output, int cfra, int preview, struct MTex *mtex);
/** \} */
void init_nodesystem(void);
@@ -1060,12 +1052,12 @@ void free_nodesystem(void);
/* -------------------------------------------------------------------- */
/* evaluation support, */
-struct EvaluationContext;
+struct Depsgraph;
void BKE_nodetree_copy_default_values(struct bNodeTree *ntree_dst,
const struct bNodeTree *ntree_src);
-void BKE_nodetree_shading_params_eval(const struct EvaluationContext *eval_ctx,
+void BKE_nodetree_shading_params_eval(struct Depsgraph *depsgraph,
struct bNodeTree *ntree_dst,
const struct bNodeTree *ntree_src);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index c698db2e8f5..1d28d7f52c7 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -36,14 +36,13 @@ extern "C" {
#include "BLI_compiler_attrs.h"
struct Base;
-struct EvaluationContext;
+struct Depsgraph;
struct Scene;
struct ViewLayer;
struct Object;
struct BoundBox;
struct View3D;
struct SoftBody;
-struct BulletSoftBody;
struct MovieClip;
struct Main;
struct RigidBodyWorld;
@@ -53,17 +52,15 @@ struct ModifierData;
#include "DNA_object_enums.h"
void BKE_object_workob_clear(struct Object *workob);
-void BKE_object_workob_calc_parent(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *workob);
+void BKE_object_workob_calc_parent(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct Object *workob);
void BKE_object_transform_copy(struct Object *ob_tar, const struct Object *ob_src);
struct SoftBody *copy_softbody(const struct SoftBody *sb, const int flag);
-struct BulletSoftBody *copy_bulletsoftbody(const struct BulletSoftBody *sb, const int flag);
struct ParticleSystem *BKE_object_copy_particlesystem(struct ParticleSystem *psys, const int flag);
void BKE_object_copy_particlesystems(struct Object *ob_dst, const struct Object *ob_src, const int flag);
void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src);
void BKE_object_free_particlesystems(struct Object *ob);
void BKE_object_free_softbody(struct Object *ob);
-void BKE_object_free_bulletsoftbody(struct Object *ob);
void BKE_object_free_curve_cache(struct Object *ob);
void BKE_object_free(struct Object *ob);
@@ -83,7 +80,9 @@ void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
bool BKE_object_exists_check(const struct Object *obtest);
bool BKE_object_is_in_editmode(const struct Object *ob);
bool BKE_object_is_in_editmode_vgroup(const struct Object *ob);
+bool BKE_object_is_in_editmode_and_selected(const struct Object *ob);
bool BKE_object_is_in_wpaint_select_vert(const struct Object *ob);
+bool BKE_object_has_mode_data(const struct Object *ob, eObjectMode object_mode);
typedef enum eObjectVisibilityCheck {
OB_VISIBILITY_CHECK_FOR_VIEWPORT,
@@ -111,14 +110,6 @@ void *BKE_object_obdata_add_from_type(
int type, const char *name)
ATTR_NONNULL(1);
-void BKE_object_lod_add(struct Object *ob);
-void BKE_object_lod_sort(struct Object *ob);
-bool BKE_object_lod_remove(struct Object *ob, int level);
-void BKE_object_lod_update(struct Object *ob, const float camera_position[3]);
-bool BKE_object_lod_is_usable(struct Object *ob, struct ViewLayer *view_layer);
-struct Object *BKE_object_lod_meshob_get(struct Object *ob, struct ViewLayer *view_layer);
-struct Object *BKE_object_lod_matob_get(struct Object *ob, struct ViewLayer *view_layer);
-
void BKE_object_copy_data(struct Main *bmain, struct Object *ob_dst, const struct Object *ob_src, const int flag);
struct Object *BKE_object_copy(struct Main *bmain, const struct Object *ob);
void BKE_object_make_local(struct Main *bmain, struct Object *ob, const bool lib_local);
@@ -140,18 +131,26 @@ bool BKE_object_pose_context_check(const struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);
struct Object *BKE_object_pose_armature_get_visible(struct Object *ob, struct ViewLayer *view_layer);
+struct Object **BKE_object_pose_array_get_ex(struct ViewLayer *view_layer, unsigned int *r_objects_len, bool unique);
+struct Object **BKE_object_pose_array_get_unique(struct ViewLayer *view_layer, unsigned int *r_objects_len);
+struct Object **BKE_object_pose_array_get(struct ViewLayer *view_layer, unsigned int *r_objects_len);
+
+struct Base **BKE_object_pose_base_array_get_ex(struct ViewLayer *view_layer, unsigned int *r_bases_len, bool unique);
+struct Base **BKE_object_pose_base_array_get_unique(struct ViewLayer *view_layer, unsigned int *r_bases_len);
+struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, unsigned int *r_bases_len);
+
void BKE_object_get_parent_matrix(
struct Scene *scene, struct Object *ob,
struct Object *par, float parentmat[4][4]);
void BKE_object_where_is_calc(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_object_where_is_calc_ex(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct RigidBodyWorld *rbw,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct RigidBodyWorld *rbw,
struct Object *ob, float r_originmat[3][3]);
void BKE_object_where_is_calc_time(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime);
void BKE_object_where_is_calc_time_ex(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime,
struct RigidBodyWorld *rbw, float r_originmat[3][3]);
void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]);
@@ -169,13 +168,15 @@ void BKE_object_empty_draw_type_set(struct Object *ob, const int value);
void BKE_object_boundbox_flag(struct Object *ob, int flag, const bool set);
void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden);
bool BKE_object_minmax_dupli(
- struct Scene *scene, struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
+ float r_min[3], float r_max[3], const bool use_hidden);
/* sometimes min-max isn't enough, we need to loop over each point */
void BKE_object_foreach_display_point(
struct Object *ob, float obmat[4][4],
void (*func_cb)(const float[3], void *), void *user_data);
void BKE_scene_foreach_display_point(
+ struct Depsgraph *depsgraph,
struct Scene *scene,
struct ViewLayer *view_layer,
void (*func_cb)(const float[3], void *), void *user_data);
@@ -205,60 +206,61 @@ void BKE_object_tfm_protected_restore(
/* Dependency graph evaluation callbacks. */
void BKE_object_eval_local_transform(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Object *ob);
void BKE_object_eval_parent(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
void BKE_object_eval_constraints(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
-void BKE_object_eval_done(const struct EvaluationContext *eval_ctx, struct Object *ob);
+void BKE_object_eval_done(struct Depsgraph *depsgraph, struct Object *ob);
bool BKE_object_eval_proxy_copy(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Object *object);
void BKE_object_eval_uber_transform(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Object *ob);
void BKE_object_eval_uber_data(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
void BKE_object_eval_cloth(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *object);
void BKE_object_eval_transform_all(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *object);
void BKE_object_eval_update_shading(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Object *object);
void BKE_object_data_select_update(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct ID *object_data);
void BKE_object_eval_flush_base_flags(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
+ struct Scene *scene, const int view_layer_index,
struct Object *object, int base_index,
const bool is_from_set);
void BKE_object_handle_data_update(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
void BKE_object_handle_update(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob);
void BKE_object_handle_update_ex(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob,
struct RigidBodyWorld *rbw,
const bool do_proxy_update);
@@ -314,7 +316,7 @@ struct KDTree *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
bool BKE_object_modifier_use_time(struct Object *ob, struct ModifierData *md);
bool BKE_object_modifier_update_subframe(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
bool update_mesh, int parent_recursion, float frame, int type);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index fa67c07395d..717f4c4f6e8 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -58,7 +58,7 @@ struct StrokeCache;
struct Tex;
struct ImagePool;
struct UnifiedPaintSettings;
-struct EvaluationContext;
+struct Depsgraph;
enum eOverlayFlags;
@@ -236,9 +236,8 @@ typedef struct SculptSession {
struct MDeformVert *dvert_prev;
} wpaint;
- //struct {
- //ToDo: identify sculpt-only fields
- //} sculpt;
+ /* TODO: identify sculpt-only fields */
+ // struct { ... } sculpt;
} mode;
int mode_type;
@@ -252,7 +251,7 @@ void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss);
void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
void BKE_sculpt_update_mesh_elements(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Sculpt *sd, struct Object *ob,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Sculpt *sd, struct Object *ob,
bool need_pmap, bool need_mask);
struct MultiresModifierData *BKE_sculpt_multires_active(struct Scene *scene, struct Object *ob);
int BKE_sculpt_mask_layers_ensure(struct Object *ob,
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index dd563617674..abbdeee2749 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -63,7 +63,7 @@ struct RNG;
struct BVHTreeRay;
struct BVHTreeRayHit;
struct EdgeHash;
-struct EvaluationContext;
+struct Depsgraph;
struct ViewLayer;
#define PARTICLE_COLLISION_MAX_COLLISIONS 10
@@ -80,7 +80,7 @@ struct ViewLayer;
/* common stuff that many particle functions need */
typedef struct ParticleSimulationData {
- const struct EvaluationContext *eval_ctx;
+ struct Depsgraph *depsgraph;
struct Scene *scene;
struct Object *ob;
struct ParticleSystem *psys;
@@ -324,7 +324,7 @@ void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int tim
CustomDataMask psys_emitter_customdata_mask(struct ParticleSystem *psys);
void psys_particle_on_emitter(struct ParticleSystemModifierData *psmd, int distr, int index, int index_dmcache,
float fuv[4], float foffset, float vec[3], float nor[3],
- float utan[3], float vtan[3], float orco[3], float ornor[3]);
+ float utan[3], float vtan[3], float orco[3]);
struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct ParticleSystem *psys);
struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, const char *name);
@@ -341,9 +341,9 @@ void psys_reset(struct ParticleSystem *psys, int mode);
void psys_find_parents(struct ParticleSimulationData *sim, const bool use_render_params);
void psys_cache_paths(struct ParticleSimulationData *sim, float cfra, const bool use_render_params);
-void psys_cache_edit_paths(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, const bool use_render_params);
+void psys_cache_edit_paths(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, const bool use_render_params);
void psys_cache_child_paths(struct ParticleSimulationData *sim, float cfra, const bool editupdate, const bool use_render_params);
-int do_guides(const struct EvaluationContext *eval_ctx, struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int pa_num, float time);
+int do_guides(struct Depsgraph *depsgraph, struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int pa_num, float time);
void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors);
float psys_get_timestep(struct ParticleSimulationData *sim);
float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime);
@@ -356,7 +356,7 @@ void BKE_particlesettings_clump_curve_init(struct ParticleSettings *part);
void BKE_particlesettings_rough_curve_init(struct ParticleSettings *part);
void BKE_particlesettings_twist_curve_init(struct ParticleSettings *part);
void psys_apply_child_modifiers(struct ParticleThreadContext *ctx, struct ListBase *modifiers,
- struct ChildParticle *cpa, struct ParticleTexture *ptex, const float orco[3], const float ornor[3], float hairmat[4][4],
+ struct ChildParticle *cpa, struct ParticleTexture *ptex, const float orco[3], float hairmat[4][4],
struct ParticleCacheKey *keys, struct ParticleCacheKey *parent_keys, const float parent_orco[3]);
void psys_sph_init(struct ParticleSimulationData *sim, struct SPHData *sphdata);
@@ -376,7 +376,7 @@ void psys_tasks_create(struct ParticleThreadContext *ctx, int startpart, int end
void psys_tasks_free(struct ParticleTask *tasks, int numtasks);
void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]);
-void psys_apply_hair_lattice(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
+void psys_apply_hair_lattice(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
/* particle_system.c */
struct ParticleSystem *psys_get_target_system(struct Object *ob, struct ParticleTarget *pt);
@@ -391,7 +391,7 @@ void psys_check_boid_data(struct ParticleSystem *psys);
void psys_get_birth_coords(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra);
-void particle_system_update(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
+void particle_system_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
/* Callback format for performing operations on ID-pointers for particle systems */
typedef void (*ParticleSystemIDFunc)(struct ParticleSystem *psys, struct ID **idpoin, void *userdata, int cb_flag);
@@ -422,7 +422,7 @@ float *psys_cache_vgroup(struct DerivedMesh *dm, struct ParticleSystem *psys, in
void psys_get_texture(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleTexture *ptex, int event, float cfra);
void psys_interpolate_face(struct MVert *mvert, struct MFace *mface, struct MTFace *tface,
float (*orcodata)[3], float w[4], float vec[3], float nor[3], float utan[3], float vtan[3],
- float orco[3], float ornor[3]);
+ float orco[3]);
float psys_particle_value_from_verts(struct DerivedMesh *dm, short from, struct ParticleData *pa, float *values);
void psys_get_from_key(struct ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time);
int psys_get_index_on_dm(struct ParticleSystem *psys, struct DerivedMesh *dm, ParticleData *pa, int *mapindex, float mapfw[4]);
@@ -431,7 +431,7 @@ int psys_get_index_on_dm(struct ParticleSystem *psys, struct DerivedMesh *dm, Pa
void BKE_psys_collision_neartest_cb(void *userdata, int index, const struct BVHTreeRay *ray, struct BVHTreeRayHit *hit);
void psys_particle_on_dm(struct DerivedMesh *dm_final, int from, int index, int index_dmcache,
const float fw[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3],
- float orco[3], float ornor[3]);
+ float orco[3]);
/* particle_system.c */
void distribute_particles(struct ParticleSimulationData *sim, int from);
@@ -455,9 +455,9 @@ float psys_get_current_display_percentage(struct ParticleSystem *psys, const boo
/* **** Depsgraph evaluation **** */
-struct EvaluationContext;
+struct Depsgraph;
-void BKE_particle_system_eval_init(const struct EvaluationContext *eval_ctx,
+void BKE_particle_system_eval_init(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 5f37aa25de7..c18288de1bc 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -129,10 +129,6 @@ bool BKE_pbvh_node_find_nearest_to_ray(
/* Drawing */
-void BKE_pbvh_node_draw(PBVHNode *node, void *data);
-void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
- int (*setMaterial)(int matnr, void *attribs), bool wireframe, bool fast);
-void BKE_pbvh_draw_BB(PBVH *bvh);
void BKE_pbvh_draw_cb(
PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast,
void (*draw_fn)(void *user_data, struct Gwn_Batch *batch), void *user_data);
@@ -225,7 +221,7 @@ struct GSet *BKE_pbvh_bmesh_node_faces(PBVHNode *node);
void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node);
void BKE_pbvh_bmesh_after_stroke(PBVH *bvh);
-/* Update Normals/Bounding Box/Draw Buffers/Redraw and clear flags */
+/* Update Normals/Bounding Box/Redraw and clear flags */
void BKE_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]);
void BKE_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]);
diff --git a/source/blender/blenkernel/BKE_property.h b/source/blender/blenkernel/BKE_property.h
deleted file mode 100644
index c787e8e8ed1..00000000000
--- a/source/blender/blenkernel/BKE_property.h
+++ /dev/null
@@ -1,53 +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 *****
- */
-#ifndef __BKE_PROPERTY_H__
-#define __BKE_PROPERTY_H__
-
-/** \file BKE_property.h
- * \ingroup bke
- */
-
-struct bProperty;
-struct ListBase;
-struct Object;
-
-void BKE_bproperty_free(struct bProperty *prop);
-void BKE_bproperty_free_list(struct ListBase *lb);
-struct bProperty *BKE_bproperty_copy(const struct bProperty *prop);
-void BKE_bproperty_copy_list(struct ListBase *lbn, const struct ListBase *lbo);
-void BKE_bproperty_init(struct bProperty *prop);
-struct bProperty *BKE_bproperty_new(int type);
-void BKE_bproperty_unique(struct bProperty *first, struct bProperty *prop, int force);
-struct bProperty *BKE_bproperty_object_get(struct Object *ob, const char *name);
-void BKE_bproperty_object_set(struct Object *ob, struct bProperty *propc);
-// int BKE_bproperty_cmp(struct bProperty *prop, const char *str);
-void BKE_bproperty_set(struct bProperty *prop, const char *str);
-void BKE_bproperty_add(struct bProperty *prop, const char *str);
-/* should really be called '_get_valstr()' or '_as_string()' */
-void BKE_bproperty_set_valstr(struct bProperty *prop, char str[MAX_PROPSTRING]);
-
-#endif
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 6aa43665427..016a531db95 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -37,7 +37,7 @@
struct RigidBodyWorld;
struct RigidBodyOb;
-struct EvaluationContext;
+struct Depsgraph;
struct Scene;
struct Object;
@@ -100,19 +100,19 @@ void BKE_rigidbody_aftertrans_update(struct Object *ob, float loc[3], float rot[
void BKE_rigidbody_sync_transforms(struct RigidBodyWorld *rbw, struct Object *ob, float ctime);
bool BKE_rigidbody_check_sim_running(struct RigidBodyWorld *rbw, float ctime);
void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw);
-void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, struct Scene *scene, float ctime);
-void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, struct Scene *scene, float ctime);
+void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, struct Scene *scene, float ctime);
+void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, struct Scene *scene, float ctime);
/* -------------------- */
/* Depsgraph evaluation */
-void BKE_rigidbody_rebuild_sim(const struct EvaluationContext *eval_ctx,
+void BKE_rigidbody_rebuild_sim(struct Depsgraph *depsgraph,
struct Scene *scene);
-void BKE_rigidbody_eval_simulation(const struct EvaluationContext *eval_ctx,
+void BKE_rigidbody_eval_simulation(struct Depsgraph *depsgraph,
struct Scene *scene);
-void BKE_rigidbody_object_sync_transforms(const struct EvaluationContext *eval_ctx,
+void BKE_rigidbody_object_sync_transforms(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_sca.h b/source/blender/blenkernel/BKE_sca.h
deleted file mode 100644
index 35bcd91a9b1..00000000000
--- a/source/blender/blenkernel/BKE_sca.h
+++ /dev/null
@@ -1,92 +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 *****
- */
-#ifndef __BKE_SCA_H__
-#define __BKE_SCA_H__
-
-/** \file BKE_sca.h
- * \ingroup bke
- */
-
-struct Main;
-struct Object;
-struct bSensor;
-struct bController;
-struct bActuator;
-
-void link_logicbricks(void **poin, void ***ppoin, short *tot, short size);
-void unlink_logicbricks(void **poin, void ***ppoin, short *tot);
-
-void unlink_controller(struct bController *cont);
-void unlink_controllers(struct ListBase *lb);
-void free_controller(struct bController *cont);
-void free_controllers(struct ListBase *lb);
-
-void unlink_actuator(struct bActuator *act);
-void unlink_actuators(struct ListBase *lb);
-void free_actuator(struct bActuator *act);
-void free_actuators(struct ListBase *lb);
-
-void free_sensor(struct bSensor *sens);
-void free_sensors(struct ListBase *lb);
-struct bSensor *copy_sensor(struct bSensor *sens, const int flag);
-void copy_sensors(struct ListBase *lbn, const struct ListBase *lbo, const int flag);
-void init_sensor(struct bSensor *sens);
-struct bSensor *new_sensor(int type);
-struct bController *copy_controller(struct bController *cont, const int flag);
-void copy_controllers(struct ListBase *lbn, const struct ListBase *lbo, const int flag);
-void init_controller(struct bController *cont);
-struct bController *new_controller(int type);
-struct bActuator *copy_actuator(struct bActuator *act, const int flag);
-void copy_actuators(struct ListBase *lbn, const struct ListBase *lbo, const int flag);
-void init_actuator(struct bActuator *act);
-struct bActuator *new_actuator(int type);
-void clear_sca_new_poins_ob(struct Object *ob);
-void clear_sca_new_poins(void);
-void set_sca_new_poins_ob(struct Object *ob);
-void set_sca_new_poins(void);
-
-void BKE_sca_logic_links_remap(struct Main *bmain, struct Object *ob_old, struct Object *ob_new);
-void BKE_sca_logic_copy(struct Object *ob_new, const struct Object *ob, const int flag);
-
-void sca_move_sensor(struct bSensor *sens_to_move, struct Object *ob, int move_up);
-void sca_move_controller(struct bController *cont_to_move, struct Object *ob, int move_up);
-void sca_move_actuator(struct bActuator *act_to_move, struct Object *ob, int move_up);
-
-/* Callback format for performing operations on ID-pointers for sensors/controllers/actuators. */
-typedef void (*SCASensorIDFunc)(struct bSensor *sensor, struct ID **idpoin, void *userdata, int cb_flag);
-typedef void (*SCAControllerIDFunc)(struct bController *controller, struct ID **idpoin, void *userdata, int cb_flag);
-typedef void (*SCAActuatorIDFunc)(struct bActuator *actuator, struct ID **idpoin, void *userdata, int cb_flag);
-
-void BKE_sca_sensors_id_loop(struct ListBase *senslist, SCASensorIDFunc func, void *userdata);
-void BKE_sca_controllers_id_loop(struct ListBase *contlist, SCAControllerIDFunc func, void *userdata);
-void BKE_sca_actuators_id_loop(struct ListBase *atclist, SCAActuatorIDFunc func, void *userdata);
-
-
-const char *sca_state_name_get(Object *ob, short bit);
-
-#endif
-
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 4a97cb763dc..bdbed9ab6aa 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -39,7 +39,6 @@ extern "C" {
struct AviCodecData;
struct Depsgraph;
-struct EvaluationContext;
struct Main;
struct Object;
struct RenderData;
@@ -49,6 +48,7 @@ struct ViewLayer;
struct UnitSettings;
struct ViewRender;
struct WorkSpace;
+struct TransformOrientation;
typedef enum eSceneCopyMethod {
SCE_COPY_NEW = 0,
@@ -100,7 +100,7 @@ typedef struct SceneBaseIter {
} SceneBaseIter;
int BKE_scene_base_iter_next(
- const struct EvaluationContext *eval_ctx, struct SceneBaseIter *iter,
+ struct Depsgraph *depsgraph, struct SceneBaseIter *iter,
struct Scene **scene, int val, struct Base **base, struct Object **ob);
void BKE_scene_base_flag_to_objects(struct ViewLayer *view_layer);
@@ -151,17 +151,12 @@ bool BKE_scene_remove_render_view(struct Scene *scene, struct SceneRenderView *s
/* render profile */
int get_render_subsurf_level(const struct RenderData *r, int level, bool for_render);
int get_render_child_particle_number(const struct RenderData *r, int num, bool for_render);
-int get_render_shadow_samples(const struct RenderData *r, int samples);
-float get_render_aosss_error(const struct RenderData *r, float error);
-bool BKE_scene_use_new_shading_nodes(const struct Scene *scene);
bool BKE_scene_use_shading_nodes_custom(struct Scene *scene);
-bool BKE_scene_use_world_space_shading(struct Scene *scene);
bool BKE_scene_use_spherical_stereo(struct Scene *scene);
-bool BKE_scene_uses_blender_internal(const struct Scene *scene);
-bool BKE_scene_uses_blender_game(const struct Scene *scene);
bool BKE_scene_uses_blender_eevee(const struct Scene *scene);
+bool BKE_scene_uses_cycles(const struct Scene *scene);
void BKE_scene_disable_color_management(struct Scene *scene);
bool BKE_scene_check_color_management_enabled(const struct Scene *scene);
@@ -174,20 +169,6 @@ int BKE_render_preview_pixel_size(const struct RenderData *r);
/**********************************/
-struct ViewRender *BKE_viewrender_get(struct Scene *scene, struct WorkSpace *workspace);
-void BKE_viewrender_init(struct ViewRender *view_render);
-void BKE_viewrender_free(struct ViewRender *view_render);
-void BKE_viewrender_copy(struct ViewRender *view_render_dst, const struct ViewRender *view_render_src);
-bool BKE_viewrender_use_new_shading_nodes(const struct ViewRender *view_render);
-bool BKE_viewrender_use_shading_nodes_custom(const struct ViewRender *view_render);
-bool BKE_viewrender_use_world_space_shading(const struct ViewRender *view_render);
-bool BKE_viewrender_use_spherical_stereo(const struct ViewRender *view_render);
-bool BKE_viewrender_uses_blender_internal(const struct ViewRender *view_render);
-bool BKE_viewrender_uses_blender_game(const struct ViewRender *view_render);
-bool BKE_viewrender_uses_blender_eevee(const struct ViewRender *view_render);
-
-/**********************************/
-
double BKE_scene_unit_scale(const struct UnitSettings *unit, const int unit_type, double value);
/* multiview */
@@ -214,6 +195,13 @@ void BKE_scene_free_depsgraph_hash(struct Scene *scene);
struct Depsgraph *BKE_scene_get_depsgraph(struct Scene *scene, struct ViewLayer *view_layer, bool allocate);
+void BKE_scene_transform_orientation_remove(
+ struct Scene *scene, struct TransformOrientation *orientation);
+struct TransformOrientation *BKE_scene_transform_orientation_find(
+ const struct Scene *scene, const int index);
+int BKE_scene_transform_orientation_get_index(
+ const struct Scene *scene, const struct TransformOrientation *orientation);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index fd6b3d20fb7..2a25120ba8d 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -41,6 +41,7 @@ struct Menu;
struct Panel;
struct Scene;
struct ScrArea;
+struct ScrVert;
struct SpaceType;
struct TransformOrientation;
struct View3D;
@@ -57,6 +58,7 @@ struct wmWindowManager;
struct WorkSpace;
struct GPUFXSettings;
struct wmMsgBus;
+struct ScrAreaMap;
#include "BLI_compiler_attrs.h"
@@ -243,6 +245,7 @@ typedef struct HeaderType {
char idname[BKE_ST_MAXNAME]; /* unique name */
int space_type;
+ int region_type;
/* draw entirely, view changes should be handled here */
void (*draw)(const struct bContext *, struct Header *);
@@ -324,9 +327,6 @@ void BKE_screen_manipulator_tag_refresh(struct bScreen *sc);
void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
void BKE_screen_view3d_scene_sync(struct bScreen *sc, struct Scene *scene);
-void BKE_screen_transform_orientation_remove(
- const struct bScreen *screen, const struct WorkSpace *workspace,
- const struct TransformOrientation *orientation) ATTR_NONNULL();
bool BKE_screen_is_fullscreen_area(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BKE_screen_is_used(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
@@ -336,7 +336,15 @@ float BKE_screen_view3d_zoom_from_fac(float zoomfac);
/* screen */
void BKE_screen_free(struct bScreen *sc);
+void BKE_screen_area_map_free(struct ScrAreaMap *area_map) ATTR_NONNULL();
unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene);
+struct ScrEdge *BKE_screen_find_edge(struct bScreen *sc, struct ScrVert *v1, struct ScrVert *v2);
+void BKE_screen_sort_scrvert(struct ScrVert **v1, struct ScrVert **v2);
+void BKE_screen_remove_double_scrverts(struct bScreen *sc);
+void BKE_screen_remove_double_scredges(struct bScreen *sc);
+void BKE_screen_remove_unused_scredges(struct bScreen *sc);
+void BKE_screen_remove_unused_scrverts(struct bScreen *sc);
+
#endif
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 21f3f344e64..cd173ef33ce 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -31,7 +31,7 @@
*/
struct bContext;
-struct EvaluationContext;
+struct Depsgraph;
struct StripColorBalance;
struct Editing;
struct GSet;
@@ -93,12 +93,12 @@ void BKE_sequence_iterator_end(SeqIterator *iter);
}
typedef struct SeqRenderData {
- struct EvaluationContext *eval_ctx;
struct Main *bmain;
struct Scene *scene;
int rectx;
int recty;
int preview_render_size;
+ int for_render;
int motion_blur_samples;
float motion_blur_shutter;
bool skip_cache;
@@ -113,8 +113,9 @@ typedef struct SeqRenderData {
} SeqRenderData;
void BKE_sequencer_new_render_data(
- struct EvaluationContext *eval_ctx, struct Main *bmain, struct Scene *scene,
+ struct Main *bmain, struct Scene *scene,
int rectx, int recty, int preview_render_size,
+ int for_render,
SeqRenderData *r_context);
int BKE_sequencer_cmp_time_startdisp(const void *a, const void *b);
@@ -435,10 +436,10 @@ enum {
};
typedef struct ImBuf *(*SequencerDrawView)(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
- struct ViewLayer *view_layer, struct RenderEngineType *engine_type,
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ int drawtype,
struct Object *camera, int width, int height,
- unsigned int flag, unsigned int draw_flags, int drawtype, int alpha_mode,
+ unsigned int flag, unsigned int draw_flags, int alpha_mode,
int samples, const char *viewname,
struct GPUOffScreen *ofs, char err_out[256]);
extern SequencerDrawView sequencer_view3d_cb;
diff --git a/source/blender/blenkernel/BKE_sketch.h b/source/blender/blenkernel/BKE_sketch.h
deleted file mode 100644
index 9b9c125fbe6..00000000000
--- a/source/blender/blenkernel/BKE_sketch.h
+++ /dev/null
@@ -1,149 +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.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __BKE_SKETCH_H__
-#define __BKE_SKETCH_H__
-
-/** \file BKE_sketch.h
- * \ingroup bke
- */
-
-typedef enum SK_PType {
- PT_CONTINUOUS,
- PT_EXACT,
-} SK_PType;
-
-typedef enum SK_PMode {
- PT_SNAP,
- PT_PROJECT,
-} SK_PMode;
-
-typedef struct SK_Point {
- float p[3];
- short p2d[2];
- float no[3];
- float size;
- SK_PType type;
- SK_PMode mode;
-} SK_Point;
-
-typedef struct SK_Stroke {
- struct SK_Stroke *next, *prev;
-
- SK_Point *points;
- int nb_points;
- int buf_size;
- int selected;
-} SK_Stroke;
-
-#define SK_OVERDRAW_LIMIT 5
-
-typedef struct SK_Overdraw {
- SK_Stroke *target;
- int start, end;
- int count;
-} SK_Overdraw;
-
-#define SK_Stroke_BUFFER_INIT_SIZE 20
-
-typedef struct SK_DrawData {
- int mval[2];
- int previous_mval[2];
- SK_PType type;
-} SK_DrawData;
-
-typedef struct SK_Intersection {
- struct SK_Intersection *next, *prev;
- SK_Stroke *stroke;
- int before;
- int after;
- int gesture_index;
- float p[3];
- float lambda; /* used for sorting intersection points */
-} SK_Intersection;
-
-typedef struct SK_Sketch {
- ListBase strokes;
- SK_Stroke *active_stroke;
- SK_Stroke *gesture;
- SK_Point next_point;
- SK_Overdraw over;
-} SK_Sketch;
-
-
-typedef struct SK_Gesture {
- SK_Stroke *stk;
- SK_Stroke *segments;
-
- ListBase intersections;
- ListBase self_intersections;
-
- int nb_self_intersections;
- int nb_intersections;
- int nb_segments;
-} SK_Gesture;
-
-
-/************************************************/
-
-void freeSketch(SK_Sketch *sketch);
-SK_Sketch *createSketch(void);
-
-void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk);
-
-void sk_freeStroke(SK_Stroke *stk);
-SK_Stroke *sk_createStroke(void);
-
-SK_Point *sk_lastStrokePoint(SK_Stroke *stk);
-
-void sk_allocStrokeBuffer(SK_Stroke *stk);
-void sk_shrinkStrokeBuffer(SK_Stroke *stk);
-void sk_growStrokeBuffer(SK_Stroke *stk);
-void sk_growStrokeBufferN(SK_Stroke *stk, int n);
-
-void sk_replaceStrokePoint(SK_Stroke *stk, SK_Point *pt, int n);
-void sk_insertStrokePoint(SK_Stroke *stk, SK_Point *pt, int n);
-void sk_appendStrokePoint(SK_Stroke *stk, SK_Point *pt);
-void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, int end);
-
-void sk_trimStroke(SK_Stroke *stk, int start, int end);
-void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], float p_end[3]);
-void sk_polygonizeStroke(SK_Stroke *stk, int start, int end);
-void sk_flattenStroke(SK_Stroke *stk, int start, int end);
-void sk_reverseStroke(SK_Stroke *stk);
-
-void sk_filterLastContinuousStroke(SK_Stroke *stk);
-void sk_filterStroke(SK_Stroke *stk, int start, int end);
-
-void sk_initPoint(SK_Point *pt, SK_DrawData *dd, const float no[3]);
-void sk_copyPoint(SK_Point *dst, SK_Point *src);
-
-int sk_stroke_filtermval(SK_DrawData *dd);
-void sk_endContinuousStroke(SK_Stroke *stk);
-
-void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk);
-
-void sk_initDrawData(SK_DrawData *dd, const int mval[2]);
-
-void sk_deleteSelectedStrokes(SK_Sketch *sketch);
-void sk_selectAllSketch(SK_Sketch *sketch, int mode);
-
-#endif
diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h
index 64d70e8e209..82bfe56b0ab 100644
--- a/source/blender/blenkernel/BKE_smoke.h
+++ b/source/blender/blenkernel/BKE_smoke.h
@@ -35,7 +35,7 @@
typedef float (*bresenham_callback)(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
-struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, const struct EvaluationContext *eval_ctx,
+struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob, struct DerivedMesh *dm);
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index e2255bdb779..c7bf876a414 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -31,10 +31,10 @@
* \ingroup bke
*/
+struct Depsgraph;
struct Object;
struct Scene;
struct SoftBody;
-struct EvaluationContext;
typedef struct BodyPoint {
float origS[3], origE[3], origT[3], pos[3], vec[3], force[3];
@@ -60,7 +60,7 @@ extern void sbFree(struct SoftBody *sb);
extern void sbFreeSimulation(struct SoftBody *sb);
/* do one simul step, reading and writing vertex locs from given array */
-extern void sbObjectStep(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+extern void sbObjectStep(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
float framnr, float (*vertexCos)[3], int numVerts);
/* makes totally fresh start situation, resets time */
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h
index 98db06752c8..b53af3cec53 100644
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@ -44,8 +44,6 @@ struct TextUndoBuf;
void BKE_text_free_lines (struct Text *text);
void BKE_text_free (struct Text *text);
-void txt_set_undostate (int u);
-int txt_get_undostate (void);
void BKE_text_init(struct Text *ta);
struct Text *BKE_text_add (struct Main *bmain, const char *name);
int txt_extended_ascii_as_utf8(char **str);
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 4e98852c995..ed6aa3f6af9 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -40,7 +40,6 @@ extern "C" {
struct bNode;
struct Brush;
struct ColorBand;
-struct EnvMap;
struct FreestyleLineStyle;
struct ImagePool;
struct Lamp;
@@ -53,7 +52,6 @@ struct PointDensity;
struct Tex;
struct TexMapping;
struct TexResult;
-struct VoxelData;
struct World;
/* in ColorBand struct */
@@ -76,27 +74,17 @@ struct MTex *BKE_texture_mtex_add_id(struct ID *id, int slot);
// void autotexname(struct Tex *tex);
struct Tex *give_current_object_texture(struct Object *ob);
-struct Tex *give_current_material_texture(struct Material *ma);
-struct Tex *give_current_lamp_texture(struct Lamp *la);
struct Tex *give_current_linestyle_texture(struct FreestyleLineStyle *linestyle);
-struct Tex *give_current_world_texture(struct World *world);
struct Tex *give_current_brush_texture(struct Brush *br);
struct Tex *give_current_particle_texture(struct ParticleSettings *part);
-struct bNode *give_current_material_texture_node(struct Material *ma);
-
bool give_active_mtex(struct ID *id, struct MTex ***mtex_ar, short *act);
void set_active_mtex(struct ID *id, short act);
void set_current_brush_texture(struct Brush *br, struct Tex *tex);
-void set_current_world_texture(struct World *wo, struct Tex *tex);
-void set_current_material_texture(struct Material *ma, struct Tex *tex);
-void set_current_lamp_texture(struct Lamp *la, struct Tex *tex);
void set_current_linestyle_texture(struct FreestyleLineStyle *linestyle, struct Tex *tex);
void set_current_particle_texture(struct ParticleSettings *part, struct Tex *tex);
-bool has_current_material_texture(struct Material *ma);
-
struct TexMapping *BKE_texture_mapping_add(int type);
void BKE_texture_mapping_default(struct TexMapping *texmap, int type);
void BKE_texture_mapping_init(struct TexMapping *texmap);
@@ -104,26 +92,12 @@ void BKE_texture_mapping_init(struct TexMapping *texmap);
struct ColorMapping *BKE_texture_colormapping_add(void);
void BKE_texture_colormapping_default(struct ColorMapping *colormap);
-void BKE_texture_envmap_free_data(struct EnvMap *env);
-void BKE_texture_envmap_free(struct EnvMap *env);
-struct EnvMap *BKE_texture_envmap_add(void);
-struct EnvMap *BKE_texture_envmap_copy(const struct EnvMap *env, const int flag);
-
void BKE_texture_pointdensity_init_data(struct PointDensity *pd);
void BKE_texture_pointdensity_free_data(struct PointDensity *pd);
void BKE_texture_pointdensity_free(struct PointDensity *pd);
struct PointDensity *BKE_texture_pointdensity_add(void);
struct PointDensity *BKE_texture_pointdensity_copy(const struct PointDensity *pd, const int flag);
-void BKE_texture_voxeldata_free_data(struct VoxelData *vd);
-void BKE_texture_voxeldata_free(struct VoxelData *vd);
-struct VoxelData *BKE_texture_voxeldata_add(void);
-struct VoxelData *BKE_texture_voxeldata_copy(struct VoxelData *vd);
-
-void BKE_texture_ocean_free(struct OceanTex *ot);
-struct OceanTex *BKE_texture_ocean_add(void);
-struct OceanTex *BKE_texture_ocean_copy(const struct OceanTex *ot, const int flag);
-
bool BKE_texture_dependsOnTime(const struct Tex *texture);
bool BKE_texture_is_image_user(const struct Tex *tex);
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 5da87de1cc9..13302caa09d 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -47,7 +47,6 @@ struct MovieDistortion;
struct Camera;
struct Object;
struct Scene;
-struct EvaluationContext;
struct rcti;
/* **** Common functions **** */
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 32a9bcbec61..5dee6b8c44f 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -28,7 +28,6 @@
#include "BLI_compiler_attrs.h"
struct bScreen;
-struct EvaluationContext;
struct Main;
struct Scene;
struct TransformOrientation;
@@ -63,13 +62,6 @@ void BKE_workspace_view_layer_remove_references(
const struct Main *bmain,
const struct ViewLayer *view_layer) ATTR_NONNULL();
-void BKE_workspace_transform_orientation_remove(
- struct WorkSpace *workspace, struct TransformOrientation *orientation) ATTR_NONNULL();
-struct TransformOrientation *BKE_workspace_transform_orientation_find(
- const struct WorkSpace *workspace, const int index) ATTR_NONNULL();
-int BKE_workspace_transform_orientation_get_index(
- const struct WorkSpace *workspace, const struct TransformOrientation *orientation) ATTR_NONNULL();
-
struct WorkSpaceLayout *BKE_workspace_layout_find(
const struct WorkSpace *workspace, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
struct WorkSpaceLayout *BKE_workspace_layout_find_global(
@@ -97,7 +89,6 @@ void BKE_workspace_active_screen_set(
struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct bScreen *screen) SETTER_ATTRS;
struct Base *BKE_workspace_active_base_get(const struct WorkSpace *workspace, const struct Scene *scene);
-struct ListBase *BKE_workspace_transform_orientations_get(struct WorkSpace *workspace) GETTER_ATTRS;
struct ViewLayer *BKE_workspace_view_layer_get(
const struct WorkSpace *workspace,
const struct Scene *scene) GETTER_ATTRS;
@@ -118,8 +109,6 @@ struct WorkSpaceLayout *BKE_workspace_hook_layout_for_workspace_get(
void BKE_workspace_hook_layout_for_workspace_set(
struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct WorkSpaceLayout *layout) ATTR_NONNULL();
-struct ViewRender *BKE_workspace_view_render_get(struct WorkSpace *workspace) GETTER_ATTRS;
-
/* flags */
bool BKE_workspace_use_scene_settings_get(const struct WorkSpace *workspace) GETTER_ATTRS;
void BKE_workspace_use_scene_settings_set(struct WorkSpace *workspace, bool value) SETTER_ATTRS;
diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h
index b45d7a7e6ec..fe8aa8694af 100644
--- a/source/blender/blenkernel/BKE_world.h
+++ b/source/blender/blenkernel/BKE_world.h
@@ -46,9 +46,9 @@ void BKE_world_make_local(struct Main *bmain, struct World *wrld, const bool lib
/* Evaluation. */
-struct EvaluationContext;
+struct Depsgraph;
-void BKE_world_eval(const struct EvaluationContext *eval_ctx, struct World *world);
+void BKE_world_eval(struct Depsgraph *depsgraph, struct World *world);
#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index b6250ad86f4..e287ab7174d 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -82,7 +82,6 @@ set(SRC
intern/boids.c
intern/bpath.c
intern/brush.c
- intern/bullet.c
intern/bvhutils.c
intern/cachefile.c
intern/camera.c
@@ -169,12 +168,11 @@ set(SRC
intern/pbvh.c
intern/pbvh_bmesh.c
intern/pointcache.c
- intern/property.c
intern/layer.c
+ intern/layer_utils.c
intern/lightprobe.c
intern/report.c
intern/rigidbody.c
- intern/sca.c
intern/scene.c
intern/screen.c
intern/seqcache.c
@@ -182,7 +180,6 @@ set(SRC
intern/seqmodifier.c
intern/sequencer.c
intern/shrinkwrap.c
- intern/sketch.c
intern/smoke.c
intern/softbody.c
intern/sound.c
@@ -224,7 +221,6 @@ set(SRC
BKE_boids.h
BKE_bpath.h
BKE_brush.h
- BKE_bullet.h
BKE_bvhutils.h
BKE_cachefile.h
BKE_camera.h
@@ -298,17 +294,14 @@ set(SRC
BKE_particle.h
BKE_pbvh.h
BKE_pointcache.h
- BKE_property.h
BKE_layer.h
BKE_lightprobe.h
BKE_report.h
BKE_rigidbody.h
- BKE_sca.h
BKE_scene.h
BKE_screen.h
BKE_sequencer.h
BKE_shrinkwrap.h
- BKE_sketch.h
BKE_smoke.h
BKE_softbody.h
BKE_sound.h
@@ -495,18 +488,6 @@ if(WITH_LZMA)
add_definitions(-DWITH_LZMA)
endif()
-if(WITH_GAMEENGINE)
- list(APPEND INC_SYS
- ../../../extern/recastnavigation
- )
- list(APPEND SRC
- intern/navmesh_conversion.c
- BKE_navmesh_conversion.h
- )
-
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
if(WITH_LIBMV)
add_definitions(-DWITH_LIBMV)
endif()
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 916e11dbd46..648af413bbe 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -70,20 +70,12 @@
#include "BKE_deform.h"
#include "BKE_global.h" /* For debug flag, DM_update_tessface_data() func. */
-#ifdef WITH_GAMEENGINE
-#include "BKE_navmesh_conversion.h"
-static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
-#endif
-
#include "BLI_sys_types.h" /* for intptr_t support */
-#include "GPU_buffers.h"
-#include "GPU_shader.h"
-#include "GPU_immediate.h"
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#ifdef WITH_OPENSUBDIV
-# include "DEG_depsgraph.h"
-# include "DEG_depsgraph_query.h"
# include "DNA_userdef_types.h"
#endif
@@ -352,7 +344,6 @@ void DM_init(
DM_init_funcs(dm);
dm->needsFree = 1;
- dm->auto_bump_scale = -1.0f;
dm->dirty = 0;
/* don't use CustomData_reset(...); because we dont want to touch customdata */
@@ -409,7 +400,6 @@ int DM_release(DerivedMesh *dm)
{
if (dm->needsFree) {
bvhcache_free(&dm->bvhCache);
- GPU_drawobject_free(dm);
CustomData_free(&dm->vertData, dm->numVertData);
CustomData_free(&dm->edgeData, dm->numEdgeData);
CustomData_free(&dm->faceData, dm->numTessFaceData);
@@ -1148,7 +1138,7 @@ DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
}
DerivedMesh *mesh_create_derived_for_modifier(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob,
ModifierData *md, int build_shapekey_layers)
{
Mesh *me = ob->data;
@@ -1174,7 +1164,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
int numVerts;
float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
- modwrap_deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, 0);
+ modwrap_deformVerts(md, depsgraph, ob, NULL, deformedVerts, numVerts, 0);
dm = mesh_create_derived(me, deformedVerts);
if (build_shapekey_layers)
@@ -1188,7 +1178,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
if (build_shapekey_layers)
add_shapekey_layers(tdm, me, ob);
- dm = modwrap_applyModifier(md, eval_ctx, ob, tdm, 0);
+ dm = modwrap_applyModifier(md, depsgraph, ob, tdm, 0);
ASSERT_IS_VALID_DM(dm);
if (tdm != dm) tdm->release(tdm);
@@ -1745,15 +1735,8 @@ static void dm_ensure_display_normals(DerivedMesh *dm)
}
}
-/**
- * new value for useDeform -1 (hack for the gameengine):
- *
- * - apply only the modifier stack of the object, skipping the virtual modifiers,
- * - don't apply the key
- * - apply deform modifiers and input vertexco
- */
static void mesh_calc_modifiers(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (*inputVertexCos)[3],
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
const bool useRenderParams, int useDeform,
const bool need_mapping, CustomDataMask dataMask,
const int index, const bool useCache, const bool build_shapekey_layers,
@@ -1771,7 +1754,6 @@ static void mesh_calc_modifiers(
int numVerts = me->totvert;
const int required_mode = useRenderParams ? eModifierMode_Render : eModifierMode_Realtime;
bool isPrevDeform = false;
- const bool skipVirtualArmature = (useDeform < 0);
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
const bool has_multires = (mmd && mmd->sculptlvl != 0);
bool multires_applied = false;
@@ -1805,17 +1787,7 @@ static void mesh_calc_modifiers(
if (useDeform)
deform_app_flags |= MOD_APPLY_USECACHE;
- if (!skipVirtualArmature) {
- firstmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
- }
- else {
- /* game engine exception */
- firstmd = ob->modifiers.first;
- if (firstmd && firstmd->type == eModifierType_Armature)
- firstmd = firstmd->next;
- }
-
- md = firstmd;
+ md = firstmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
modifiers_clearErrors(ob);
@@ -1864,7 +1836,7 @@ static void mesh_calc_modifiers(
if (!deformedVerts)
deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
- modwrap_deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, deform_app_flags);
+ modwrap_deformVerts(md, depsgraph, ob, NULL, deformedVerts, numVerts, deform_app_flags);
}
else {
break;
@@ -2005,7 +1977,7 @@ static void mesh_calc_modifiers(
}
}
- modwrap_deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, deform_app_flags);
+ modwrap_deformVerts(md, depsgraph, ob, dm, deformedVerts, numVerts, deform_app_flags);
}
else {
DerivedMesh *ndm;
@@ -2080,7 +2052,7 @@ static void mesh_calc_modifiers(
}
}
- ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, app_flags);
+ ndm = modwrap_applyModifier(md, depsgraph, ob, dm, app_flags);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2107,7 +2079,7 @@ static void mesh_calc_modifiers(
(mti->requiredDataMask ?
mti->requiredDataMask(ob, md) : 0));
- ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifier(md, depsgraph, ob, orcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2125,7 +2097,7 @@ static void mesh_calc_modifiers(
nextmask &= ~CD_MASK_CLOTH_ORCO;
DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX);
- ndm = modwrap_applyModifier(md, eval_ctx, ob, clothorcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifier(md, depsgraph, ob, clothorcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2245,20 +2217,6 @@ static void mesh_calc_modifiers(
CustomData_free_layers(&finaldm->loopData, CD_NORMAL, finaldm->numLoopData);
}
-#ifdef WITH_GAMEENGINE
- /* NavMesh - this is a hack but saves having a NavMesh modifier */
- if ((ob->gameflag & OB_NAVMESH) && (finaldm->type == DM_TYPE_CDDM)) {
- DerivedMesh *tdm;
- tdm = navmesh_dm_createNavMeshForVisualization(finaldm);
- if (finaldm != tdm) {
- finaldm->release(finaldm);
- finaldm = tdm;
- }
-
- DM_ensure_tessface(finaldm);
- }
-#endif /* WITH_GAMEENGINE */
-
*r_final = finaldm;
if (orcodm)
@@ -2308,7 +2266,7 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *
}
static void editbmesh_calc_modifiers(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob,
BMEditMesh *em, CustomDataMask dataMask,
/* return args */
DerivedMesh **r_cage, DerivedMesh **r_final)
@@ -2396,9 +2354,9 @@ static void editbmesh_calc_modifiers(
}
if (mti->deformVertsEM)
- modwrap_deformVertsEM(md, eval_ctx, ob, em, dm, deformedVerts, numVerts);
+ modwrap_deformVertsEM(md, depsgraph, ob, em, dm, deformedVerts, numVerts);
else
- modwrap_deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, 0);
+ modwrap_deformVerts(md, depsgraph, ob, dm, deformedVerts, numVerts, 0);
}
else {
DerivedMesh *ndm;
@@ -2443,10 +2401,10 @@ static void editbmesh_calc_modifiers(
DM_set_only_copy(orcodm, mask | CD_MASK_ORIGINDEX);
if (mti->applyModifierEM) {
- ndm = modwrap_applyModifierEM(md, eval_ctx, ob, em, orcodm, MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifierEM(md, depsgraph, ob, em, orcodm, MOD_APPLY_ORCO);
}
else {
- ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifier(md, depsgraph, ob, orcodm, MOD_APPLY_ORCO);
}
ASSERT_IS_VALID_DM(ndm);
@@ -2471,9 +2429,9 @@ static void editbmesh_calc_modifiers(
}
if (mti->applyModifierEM)
- ndm = modwrap_applyModifierEM(md, eval_ctx, ob, em, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
+ ndm = modwrap_applyModifierEM(md, depsgraph, ob, em, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
else
- ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
+ ndm = modwrap_applyModifier(md, depsgraph, ob, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2609,7 +2567,7 @@ static void editbmesh_calc_modifiers(
* we'll be using GPU backend of OpenSubdiv. This is so
* playback performance is kept as high as possible.
*/
-static bool calc_modifiers_skip_orco(const EvaluationContext *eval_ctx,
+static bool calc_modifiers_skip_orco(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
bool use_render_params)
@@ -2626,7 +2584,7 @@ static bool calc_modifiers_skip_orco(const EvaluationContext *eval_ctx,
else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
return false;
}
- else if ((DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
+ else if ((DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
return false;
}
SubsurfModifierData *smd = (SubsurfModifierData *)last_md;
@@ -2638,7 +2596,7 @@ static bool calc_modifiers_skip_orco(const EvaluationContext *eval_ctx,
#endif
static void mesh_build_data(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask,
const bool build_shapekey_layers, const bool need_mapping)
{
BLI_assert(ob->type == OB_MESH);
@@ -2647,13 +2605,13 @@ static void mesh_build_data(
BKE_object_sculpt_modifiers_changed(ob);
#ifdef WITH_OPENSUBDIV
- if (calc_modifiers_skip_orco(eval_ctx, scene, ob, false)) {
+ if (calc_modifiers_skip_orco(depsgraph, scene, ob, false)) {
dataMask &= ~(CD_MASK_ORCO | CD_MASK_PREVIEW_MCOL);
}
#endif
mesh_calc_modifiers(
- eval_ctx, scene, ob, NULL, false, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
+ depsgraph, scene, ob, NULL, false, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
true,
&ob->derivedDeform, &ob->derivedFinal);
@@ -2668,14 +2626,14 @@ static void mesh_build_data(
/* create PBVH immediately (would be created on the fly too,
* but this avoids waiting on first stroke) */
- BKE_sculpt_update_mesh_elements(eval_ctx, scene, scene->toolsettings->sculpt, ob, false, false);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
}
BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS));
}
static void editbmesh_build_data(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
{
BKE_object_free_derived_caches(obedit);
@@ -2684,13 +2642,13 @@ static void editbmesh_build_data(
BKE_editmesh_free_derivedmesh(em);
#ifdef WITH_OPENSUBDIV
- if (calc_modifiers_skip_orco(eval_ctx, scene, obedit, false)) {
+ if (calc_modifiers_skip_orco(depsgraph, scene, obedit, false)) {
dataMask &= ~(CD_MASK_ORCO | CD_MASK_PREVIEW_MCOL);
}
#endif
editbmesh_calc_modifiers(
- eval_ctx, scene, obedit, em, dataMask,
+ depsgraph, scene, obedit, em, dataMask,
&em->derivedCage, &em->derivedFinal);
DM_set_object_boundbox(obedit, em->derivedFinal);
@@ -2702,10 +2660,9 @@ static void editbmesh_build_data(
BLI_assert(!(em->derivedFinal->dirty & DM_DIRTY_NORMALS));
}
-static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *r_need_mapping)
+static CustomDataMask object_get_datamask(const Depsgraph *depsgraph, Object *ob, bool *r_need_mapping)
{
- /* TODO(sergey): Avoid this linear list lookup. */
- ViewLayer *view_layer = BKE_view_layer_context_active_PLACEHOLDER(scene);
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
Object *actob = view_layer->basact ? view_layer->basact->object : NULL;
CustomDataMask mask = ob->customdata_mask;
@@ -2743,85 +2700,85 @@ static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *
}
void makeDerivedMesh(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BMEditMesh *em,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, BMEditMesh *em,
CustomDataMask dataMask, const bool build_shapekey_layers)
{
bool need_mapping;
- dataMask |= object_get_datamask(scene, ob, &need_mapping);
+ dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
if (em) {
- editbmesh_build_data(eval_ctx, scene, ob, em, dataMask);
+ editbmesh_build_data(depsgraph, scene, ob, em, dataMask);
}
else {
- mesh_build_data(eval_ctx, scene, ob, dataMask, build_shapekey_layers, need_mapping);
+ mesh_build_data(depsgraph, scene, ob, dataMask, build_shapekey_layers, need_mapping);
}
}
/***/
DerivedMesh *mesh_get_derived_final(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
bool need_mapping;
- dataMask |= object_get_datamask(scene, ob, &need_mapping);
+ dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
if (!ob->derivedFinal ||
((dataMask & ob->lastDataMask) != dataMask) ||
(need_mapping != ob->lastNeedMapping))
{
- mesh_build_data(eval_ctx, scene, ob, dataMask, false, need_mapping);
+ mesh_build_data(depsgraph, scene, ob, dataMask, false, need_mapping);
}
if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); }
return ob->derivedFinal;
}
-DerivedMesh *mesh_get_derived_deform(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_get_derived_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
bool need_mapping;
- dataMask |= object_get_datamask(scene, ob, &need_mapping);
+ dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
if (!ob->derivedDeform ||
((dataMask & ob->lastDataMask) != dataMask) ||
(need_mapping != ob->lastNeedMapping))
{
- mesh_build_data(eval_ctx, scene, ob, dataMask, false, need_mapping);
+ mesh_build_data(depsgraph, scene, ob, dataMask, false, need_mapping);
}
return ob->derivedDeform;
}
-DerivedMesh *mesh_create_derived_render(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_render(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
- eval_ctx, scene, ob, NULL, true, 1, false, dataMask, -1, false, false, false,
+ depsgraph, scene, ob, NULL, true, 1, false, dataMask, -1, false, false, false,
NULL, &final);
return final;
}
-DerivedMesh *mesh_create_derived_index_render(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask, int index)
+DerivedMesh *mesh_create_derived_index_render(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask, int index)
{
DerivedMesh *final;
mesh_calc_modifiers(
- eval_ctx, scene, ob, NULL, true, 1, false, dataMask, index, false, false, false,
+ depsgraph, scene, ob, NULL, true, 1, false, dataMask, index, false, false, false,
NULL, &final);
return final;
}
DerivedMesh *mesh_create_derived_view(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
Object *ob, CustomDataMask dataMask)
{
DerivedMesh *final;
@@ -2833,7 +2790,7 @@ DerivedMesh *mesh_create_derived_view(
ob->transflag |= OB_NO_PSYS_UPDATE;
mesh_calc_modifiers(
- eval_ctx, scene, ob, NULL, false, 1, false, dataMask, -1, false, false, false,
+ depsgraph, scene, ob, NULL, false, 1, false, dataMask, -1, false, false, false,
NULL, &final);
ob->transflag &= ~OB_NO_PSYS_UPDATE;
@@ -2842,53 +2799,27 @@ DerivedMesh *mesh_create_derived_view(
}
DerivedMesh *mesh_create_derived_no_deform(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
- float (*vertCos)[3], CustomDataMask dataMask)
-{
- DerivedMesh *final;
-
- mesh_calc_modifiers(
- eval_ctx, scene, ob, vertCos, false, 0, false, dataMask, -1, false, false, false,
- NULL, &final);
-
- return final;
-}
-
-DerivedMesh *mesh_create_derived_no_virtual(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
- float (*vertCos)[3], CustomDataMask dataMask)
-{
- DerivedMesh *final;
-
- mesh_calc_modifiers(
- eval_ctx, scene, ob, vertCos, false, -1, false, dataMask, -1, false, false, false,
- NULL, &final);
-
- return final;
-}
-
-DerivedMesh *mesh_create_derived_physics(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob,
float (*vertCos)[3], CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
- eval_ctx, scene, ob, vertCos, false, -1, true, dataMask, -1, false, false, false,
+ depsgraph, scene, ob, vertCos, false, 0, false, dataMask, -1, false, false, false,
NULL, &final);
return final;
}
DerivedMesh *mesh_create_derived_no_deform_render(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
Object *ob, float (*vertCos)[3],
CustomDataMask dataMask)
{
DerivedMesh *final;
mesh_calc_modifiers(
- eval_ctx, scene, ob, vertCos, true, 0, false, dataMask, -1, false, false, false,
+ depsgraph, scene, ob, vertCos, true, 0, false, dataMask, -1, false, false, false,
NULL, &final);
return final;
@@ -2897,7 +2828,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(
/***/
DerivedMesh *editbmesh_get_derived_cage_and_final(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em,
+ struct Depsgraph *depsgraph, Scene *scene, Object *obedit, BMEditMesh *em,
CustomDataMask dataMask,
/* return args */
DerivedMesh **r_final)
@@ -2905,12 +2836,12 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- dataMask |= object_get_datamask(scene, obedit, NULL);
+ dataMask |= object_get_datamask(depsgraph, obedit, NULL);
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
{
- editbmesh_build_data(eval_ctx, scene, obedit, em, dataMask);
+ editbmesh_build_data(depsgraph, scene, obedit, em, dataMask);
}
*r_final = em->derivedFinal;
@@ -2919,18 +2850,18 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
}
DerivedMesh *editbmesh_get_derived_cage(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em,
+ struct Depsgraph *depsgraph, Scene *scene, Object *obedit, BMEditMesh *em,
CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- dataMask |= object_get_datamask(scene, obedit, NULL);
+ dataMask |= object_get_datamask(depsgraph, obedit, NULL);
if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
{
- editbmesh_build_data(eval_ctx, scene, obedit, em, dataMask);
+ editbmesh_build_data(depsgraph, scene, obedit, em, dataMask);
}
return em->derivedCage;
@@ -3065,21 +2996,6 @@ void mesh_get_mapped_verts_coords(DerivedMesh *dm, float (*r_cos)[3], const int
}
}
-/* ******************* GLSL ******************** */
-
-void DM_calc_tangents_names_from_gpu(
- const GPUVertexAttribs *gattribs,
- char (*tangent_names)[MAX_NAME], int *r_tangent_names_count)
-{
- int count = 0;
- for (int b = 0; b < gattribs->totlayer; b++) {
- if (gattribs->layer[b].type == CD_TANGENT) {
- strcpy(tangent_names[count++], gattribs->layer[b].name);
- }
- }
- *r_tangent_names_count = count;
-}
-
void DM_add_named_tangent_layer_for_uv(
CustomData *uv_data, CustomData *tan_data, int numLoopData,
const char *layer_name)
@@ -3113,397 +3029,6 @@ void DM_calc_loop_tangents(
&dm->tangent_mask);
}
-void DM_calc_auto_bump_scale(DerivedMesh *dm)
-{
- /* int totvert = dm->getNumVerts(dm); */ /* UNUSED */
- int totface = dm->getNumTessFaces(dm);
-
- MVert *mvert = dm->getVertArray(dm);
- MFace *mface = dm->getTessFaceArray(dm);
- MTFace *mtface = dm->getTessFaceDataArray(dm, CD_MTFACE);
-
- if (mtface) {
- double dsum = 0.0;
- int nr_accumulated = 0;
- int f;
-
- for (f = 0; f < totface; f++) {
- {
- float *verts[4], *tex_coords[4];
- const int nr_verts = mface[f].v4 != 0 ? 4 : 3;
- bool is_degenerate;
- int i;
-
- verts[0] = mvert[mface[f].v1].co; verts[1] = mvert[mface[f].v2].co; verts[2] = mvert[mface[f].v3].co;
- tex_coords[0] = mtface[f].uv[0]; tex_coords[1] = mtface[f].uv[1]; tex_coords[2] = mtface[f].uv[2];
- if (nr_verts == 4) {
- verts[3] = mvert[mface[f].v4].co;
- tex_coords[3] = mtface[f].uv[3];
- }
-
- /* discard degenerate faces */
- is_degenerate = 0;
- if (equals_v3v3(verts[0], verts[1]) ||
- equals_v3v3(verts[0], verts[2]) ||
- equals_v3v3(verts[1], verts[2]) ||
- equals_v2v2(tex_coords[0], tex_coords[1]) ||
- equals_v2v2(tex_coords[0], tex_coords[2]) ||
- equals_v2v2(tex_coords[1], tex_coords[2]))
- {
- is_degenerate = 1;
- }
-
- /* verify last vertex as well if this is a quad */
- if (is_degenerate == 0 && nr_verts == 4) {
- if (equals_v3v3(verts[3], verts[0]) ||
- equals_v3v3(verts[3], verts[1]) ||
- equals_v3v3(verts[3], verts[2]) ||
- equals_v2v2(tex_coords[3], tex_coords[0]) ||
- equals_v2v2(tex_coords[3], tex_coords[1]) ||
- equals_v2v2(tex_coords[3], tex_coords[2]))
- {
- is_degenerate = 1;
- }
-
- /* verify the winding is consistent */
- if (is_degenerate == 0) {
- float prev_edge[2];
- bool is_signed = 0;
- sub_v2_v2v2(prev_edge, tex_coords[0], tex_coords[3]);
-
- i = 0;
- while (is_degenerate == 0 && i < 4) {
- float cur_edge[2], signed_area;
- sub_v2_v2v2(cur_edge, tex_coords[(i + 1) & 0x3], tex_coords[i]);
- signed_area = cross_v2v2(prev_edge, cur_edge);
-
- if (i == 0) {
- is_signed = (signed_area < 0.0f) ? 1 : 0;
- }
- else if ((is_signed != 0) != (signed_area < 0.0f)) {
- is_degenerate = 1;
- }
-
- if (is_degenerate == 0) {
- copy_v2_v2(prev_edge, cur_edge);
- i++;
- }
- }
- }
- }
-
- /* proceed if not a degenerate face */
- if (is_degenerate == 0) {
- int nr_tris_to_pile = 0;
- /* quads split at shortest diagonal */
- int offs = 0; /* initial triangulation is 0,1,2 and 0, 2, 3 */
- if (nr_verts == 4) {
- float pos_len_diag0, pos_len_diag1;
-
- pos_len_diag0 = len_squared_v3v3(verts[2], verts[0]);
- pos_len_diag1 = len_squared_v3v3(verts[3], verts[1]);
-
- if (pos_len_diag1 < pos_len_diag0) {
- offs = 1; // alter split
- }
- else if (pos_len_diag0 == pos_len_diag1) { /* do UV check instead */
- float tex_len_diag0, tex_len_diag1;
-
- tex_len_diag0 = len_squared_v2v2(tex_coords[2], tex_coords[0]);
- tex_len_diag1 = len_squared_v2v2(tex_coords[3], tex_coords[1]);
-
- if (tex_len_diag1 < tex_len_diag0) {
- offs = 1; /* alter split */
- }
- }
- }
- nr_tris_to_pile = nr_verts - 2;
- if (nr_tris_to_pile == 1 || nr_tris_to_pile == 2) {
- const int indices[6] = {offs + 0, offs + 1, offs + 2, offs + 0, offs + 2, (offs + 3) & 0x3 };
- int t;
- for (t = 0; t < nr_tris_to_pile; t++) {
- float f2x_area_uv;
- const float *p0 = verts[indices[t * 3 + 0]];
- const float *p1 = verts[indices[t * 3 + 1]];
- const float *p2 = verts[indices[t * 3 + 2]];
-
- float edge_t0[2], edge_t1[2];
- sub_v2_v2v2(edge_t0, tex_coords[indices[t * 3 + 1]], tex_coords[indices[t * 3 + 0]]);
- sub_v2_v2v2(edge_t1, tex_coords[indices[t * 3 + 2]], tex_coords[indices[t * 3 + 0]]);
-
- f2x_area_uv = fabsf(cross_v2v2(edge_t0, edge_t1));
- if (f2x_area_uv > FLT_EPSILON) {
- float norm[3], v0[3], v1[3], f2x_surf_area, fsurf_ratio;
- sub_v3_v3v3(v0, p1, p0);
- sub_v3_v3v3(v1, p2, p0);
- cross_v3_v3v3(norm, v0, v1);
-
- f2x_surf_area = len_v3(norm);
- fsurf_ratio = f2x_surf_area / f2x_area_uv; /* tri area divided by texture area */
-
- nr_accumulated++;
- dsum += (double)(fsurf_ratio);
- }
- }
- }
- }
- }
- }
-
- /* finalize */
- {
- const float avg_area_ratio = (nr_accumulated > 0) ? ((float)(dsum / nr_accumulated)) : 1.0f;
- const float use_as_render_bump_scale = sqrtf(avg_area_ratio); // use width of average surface ratio as your bump scale
- dm->auto_bump_scale = use_as_render_bump_scale;
- }
- }
- else {
- dm->auto_bump_scale = 1.0f;
- }
-}
-
-void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, DMVertexAttribs *attribs)
-{
- CustomData *vdata, *ldata;
- int a, b, layer;
- const bool is_editmesh = (dm->type == DM_TYPE_EDITBMESH);
-
- /* From the layers requested by the GLSL shader, figure out which ones are
- * actually available for this derivedmesh, and retrieve the pointers */
-
- memset(attribs, 0, sizeof(DMVertexAttribs));
-
- vdata = &dm->vertData;
- ldata = dm->getLoopDataLayout(dm);
-
- /* calc auto bump scale if necessary */
- if (dm->auto_bump_scale <= 0.0f)
- DM_calc_auto_bump_scale(dm);
-
- char tangent_names[MAX_MTFACE][MAX_NAME];
- int tangent_names_count;
- /* Add a tangent layer/layers. */
- DM_calc_tangents_names_from_gpu(gattribs, tangent_names, &tangent_names_count);
-
- if (tangent_names_count)
- dm->calcLoopTangents(dm, false, (const char (*)[MAX_NAME])tangent_names, tangent_names_count);
-
- for (b = 0; b < gattribs->totlayer; b++) {
- int type = gattribs->layer[b].type;
- layer = -1;
- if (type == CD_AUTO_FROM_NAME) {
- /* We need to deduct what exact layer is used.
- *
- * We do it based on the specified name.
- */
- if (gattribs->layer[b].name[0]) {
- layer = CustomData_get_named_layer_index(ldata, CD_MLOOPUV, gattribs->layer[b].name);
- type = CD_MTFACE;
- if (layer == -1) {
- layer = CustomData_get_named_layer_index(ldata, CD_MLOOPCOL, gattribs->layer[b].name);
- type = CD_MCOL;
- }
- if (layer == -1) {
- layer = CustomData_get_named_layer_index(&dm->loopData, CD_TANGENT, gattribs->layer[b].name);
- type = CD_TANGENT;
- }
- if (layer == -1) {
- continue;
- }
- }
- else {
- /* Fall back to the UV layer, which matches old behavior. */
- type = CD_MTFACE;
- }
- }
- if (type == CD_MTFACE) {
- /* uv coordinates */
- if (layer == -1) {
- if (gattribs->layer[b].name[0])
- layer = CustomData_get_named_layer_index(ldata, CD_MLOOPUV, gattribs->layer[b].name);
- else
- layer = CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
- }
-
- a = attribs->tottface++;
-
- if (layer != -1) {
- attribs->tface[a].array = is_editmesh ? NULL : ldata->layers[layer].data;
- attribs->tface[a].em_offset = ldata->layers[layer].offset;
- }
- 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_info_index = gattribs->layer[b].glinfoindoex;
- attribs->tface[a].gl_texco = gattribs->layer[b].gltexco;
- }
- else if (type == CD_MCOL) {
- if (layer == -1) {
- if (gattribs->layer[b].name[0])
- layer = CustomData_get_named_layer_index(ldata, CD_MLOOPCOL, gattribs->layer[b].name);
- else
- layer = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL);
- }
-
- a = attribs->totmcol++;
-
- if (layer != -1) {
- attribs->mcol[a].array = is_editmesh ? NULL : ldata->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;
- }
- else {
- attribs->mcol[a].array = NULL;
- attribs->mcol[a].em_offset = -1;
- }
-
- attribs->mcol[a].gl_index = gattribs->layer[b].glindex;
- attribs->mcol[a].gl_info_index = gattribs->layer[b].glinfoindoex;
- }
- else if (type == CD_TANGENT) {
- /* note, even with 'is_editmesh' this uses the derived-meshes loop data */
- if (layer == -1) {
- if (gattribs->layer[b].name[0])
- layer = CustomData_get_named_layer_index(&dm->loopData, CD_TANGENT, gattribs->layer[b].name);
- else
- layer = CustomData_get_active_layer_index(&dm->loopData, CD_TANGENT);
- }
-
- a = attribs->tottang++;
-
- if (layer != -1) {
- attribs->tang[a].array = dm->loopData.layers[layer].data;
- attribs->tang[a].em_offset = dm->loopData.layers[layer].offset;
- }
- else {
- attribs->tang[a].array = NULL;
- attribs->tang[a].em_offset = -1;
- }
-
- attribs->tang[a].gl_index = gattribs->layer[b].glindex;
- attribs->tang[a].gl_info_index = gattribs->layer[b].glinfoindoex;
- }
- else if (type == CD_ORCO) {
- /* original coordinates */
- if (layer == -1) {
- layer = CustomData_get_layer_index(vdata, CD_ORCO);
- }
- attribs->totorco = 1;
-
- if (layer != -1) {
- attribs->orco.array = vdata->layers[layer].data;
- attribs->orco.em_offset = vdata->layers[layer].offset;
- }
- 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;
- attribs->orco.gl_info_index = gattribs->layer[b].glinfoindoex;
- }
- }
-}
-
-/**
- * Set vertex shader attribute inputs for a particular tessface vert
- *
- * \param a: tessface index
- * \param index: vertex index
- * \param vert: corner index (0, 1, 2, 3)
- * \param loop: absolute loop corner index
- */
-void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert, int loop)
-{
- const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- int b;
-
- UNUSED_VARS(a, vert);
-
- /* 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
- glVertexAttrib3fv(attribs->orco.gl_index, orco);
- }
-
- /* uv texture coordinates */
- for (b = 0; b < attribs->tottface; b++) {
- const float *uv;
-
- if (attribs->tface[b].array) {
- const MLoopUV *mloopuv = &attribs->tface[b].array[loop];
- uv = mloopuv->uv;
- }
- else {
- uv = zero;
- }
-
- if (attribs->tface[b].gl_texco)
- glTexCoord2fv(uv);
- else
- glVertexAttrib2fv(attribs->tface[b].gl_index, uv);
- }
-
- /* vertex colors */
- for (b = 0; b < attribs->totmcol; b++) {
- GLfloat col[4];
-
- if (attribs->mcol[b].array) {
- const MLoopCol *cp = &attribs->mcol[b].array[loop];
- rgba_uchar_to_float(col, &cp->r);
- }
- else {
- zero_v4(col);
- }
-
- glVertexAttrib4fv(attribs->mcol[b].gl_index, col);
- }
-
- /* tangent for normal mapping */
- for (b = 0; b < attribs->tottang; b++) {
- if (attribs->tang[b].array) {
- /*const*/ float (*array)[4] = attribs->tang[b].array;
- const float *tang = (array) ? array[loop] : zero;
- glVertexAttrib4fv(attribs->tang[b].gl_index, tang);
- }
- }
-}
-
-void DM_draw_attrib_vertex_uniforms(const DMVertexAttribs *attribs)
-{
- int i;
- if (attribs->totorco) {
- if (attribs->orco.gl_info_index != -1) {
- glUniform1i(attribs->orco.gl_info_index, 0);
- }
- }
- for (i = 0; i < attribs->tottface; i++) {
- if (attribs->tface[i].gl_info_index != -1) {
- glUniform1i(attribs->tface[i].gl_info_index, 0);
- }
- }
- for (i = 0; i < attribs->totmcol; i++) {
- if (attribs->mcol[i].gl_info_index != -1) {
- glUniform1i(attribs->mcol[i].gl_info_index, GPU_ATTR_INFO_SRGB);
- }
- }
-
- for (i = 0; i < attribs->tottang; i++) {
- if (attribs->tang[i].gl_info_index != -1) {
- glUniform1i(attribs->tang[i].gl_info_index, 0);
- }
- }
-}
-
/* Set object's bounding box based on DerivedMesh min/max data */
void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
{
@@ -3520,178 +3045,6 @@ void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
ob->bb->flag &= ~BOUNDBOX_DIRTY;
}
-/* --- NAVMESH (begin) --- */
-#ifdef WITH_GAMEENGINE
-
-/* BMESH_TODO, navmesh is not working right currently
- * All tools set this as MPoly data, but derived mesh currently draws from MFace (tessface)
- *
- * Proposed solution, rather then copy CD_RECAST into the MFace array,
- * use ORIGINDEX to get the original poly index and then get the CD_RECAST
- * data from the original me->mpoly layer. - campbell
- */
-
-
-BLI_INLINE int navmesh_bit(int a, int b)
-{
- return (a & (1 << b)) >> b;
-}
-
-BLI_INLINE void navmesh_intToCol(int i, float col[3])
-{
- int r = navmesh_bit(i, 0) + navmesh_bit(i, 3) * 2 + 1;
- int g = navmesh_bit(i, 1) + navmesh_bit(i, 4) * 2 + 1;
- int b = navmesh_bit(i, 2) + navmesh_bit(i, 5) * 2 + 1;
- col[0] = 1 - r * 63.0f / 255.0f;
- col[1] = 1 - g * 63.0f / 255.0f;
- col[2] = 1 - b * 63.0f / 255.0f;
-}
-
-static void navmesh_drawColored(DerivedMesh *dm)
-{
- MVert *mvert = (MVert *)CustomData_get_layer(&dm->vertData, CD_MVERT);
- MFace *mface = (MFace *)CustomData_get_layer(&dm->faceData, CD_MFACE);
- int *polygonIdx = (int *)CustomData_get_layer(&dm->polyData, CD_RECAST);
- float col[3];
-
- if (!polygonIdx)
- return;
-
-#if 0
- //UI_ThemeColor(TH_WIRE);
- glLineWidth(2.0);
- dm->drawEdges(dm, 0, 1);
-#endif
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- /* Note: batch drawing API would let us share vertices */
- immBeginAtMost(GWN_PRIM_TRIS, dm->numTessFaceData * 6);
- for (int a = 0; a < dm->numTessFaceData; a++, mface++) {
- int pi = polygonIdx[a];
- if (pi <= 0) {
- zero_v3(col);
- }
- else {
- navmesh_intToCol(pi, col);
- }
-
- immSkipAttrib(color);
- immVertex3fv(pos, mvert[mface->v1].co);
- immSkipAttrib(color);
- immVertex3fv(pos, mvert[mface->v2].co);
- immAttrib3fv(color, col);
- immVertex3fv(pos, mvert[mface->v3].co);
-
- if (mface->v4) {
- /* this tess face is a quad, so draw the other triangle */
- immSkipAttrib(color);
- immVertex3fv(pos, mvert[mface->v1].co);
- immSkipAttrib(color);
- immVertex3fv(pos, mvert[mface->v3].co);
- immAttrib3fv(color, col);
- immVertex3fv(pos, mvert[mface->v4].co);
- }
- }
- immEnd();
- immUnbindProgram();
-}
-
-static void navmesh_DM_drawFacesSolid(
- DerivedMesh *dm,
- float (*partial_redraw_planes)[4],
- bool UNUSED(fast), DMSetMaterial UNUSED(setMaterial))
-{
- UNUSED_VARS(partial_redraw_planes);
-
- //drawFacesSolid_original(dm, partial_redraw_planes, fast, setMaterial);
- navmesh_drawColored(dm);
-}
-
-static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm)
-{
- DerivedMesh *result;
- int maxFaces = dm->getNumPolys(dm);
- int *recastData;
- int vertsPerPoly = 0, nverts = 0, ndtris = 0, npolys = 0;
- float *verts = NULL;
- unsigned short *dtris = NULL, *dmeshes = NULL, *polys = NULL;
- int *dtrisToPolysMap = NULL, *dtrisToTrisMap = NULL, *trisToFacesMap = NULL;
- int res;
-
- result = CDDM_copy(dm);
- if (!CustomData_has_layer(&result->polyData, CD_RECAST)) {
- int *sourceRecastData = (int *)CustomData_get_layer(&dm->polyData, CD_RECAST);
- if (sourceRecastData) {
- CustomData_add_layer_named(&result->polyData, CD_RECAST, CD_DUPLICATE,
- sourceRecastData, maxFaces, "recastData");
- }
- }
- recastData = (int *)CustomData_get_layer(&result->polyData, CD_RECAST);
-
- /* note: This is not good design! - really should not be doing this */
- result->drawFacesSolid = navmesh_DM_drawFacesSolid;
-
-
- /* process mesh */
- res = buildNavMeshDataByDerivedMesh(dm, &vertsPerPoly, &nverts, &verts, &ndtris, &dtris,
- &npolys, &dmeshes, &polys, &dtrisToPolysMap, &dtrisToTrisMap,
- &trisToFacesMap);
- if (res) {
- size_t polyIdx;
-
- /* invalidate concave polygon */
- for (polyIdx = 0; polyIdx < (size_t)npolys; polyIdx++) {
- unsigned short *poly = &polys[polyIdx * 2 * vertsPerPoly];
- if (!polyIsConvex(poly, vertsPerPoly, verts)) {
- /* set negative polygon idx to all faces */
- unsigned short *dmesh = &dmeshes[4 * polyIdx];
- unsigned short tbase = dmesh[2];
- unsigned short tnum = dmesh[3];
- unsigned short ti;
-
- for (ti = 0; ti < tnum; ti++) {
- unsigned short triidx = dtrisToTrisMap[tbase + ti];
- unsigned short faceidx = trisToFacesMap[triidx];
- if (recastData[faceidx] > 0) {
- recastData[faceidx] = -recastData[faceidx];
- }
- }
- }
- }
- }
- else {
- printf("Navmesh: Unable to generate valid Navmesh");
- }
-
- /* clean up */
- if (verts != NULL)
- MEM_freeN(verts);
- if (dtris != NULL)
- MEM_freeN(dtris);
- if (dmeshes != NULL)
- MEM_freeN(dmeshes);
- if (polys != NULL)
- MEM_freeN(polys);
- if (dtrisToPolysMap != NULL)
- MEM_freeN(dtrisToPolysMap);
- if (dtrisToTrisMap != NULL)
- MEM_freeN(dtrisToTrisMap);
- if (trisToFacesMap != NULL)
- MEM_freeN(trisToFacesMap);
-
- return result;
-}
-
-#endif /* WITH_GAMEENGINE */
-
-/* --- NAVMESH (end) --- */
-
-
void DM_init_origspace(DerivedMesh *dm)
{
const float default_osf[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index acb2db8d7ad..7cceec2c08f 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -500,7 +500,7 @@ bPoseChannel *BKE_pose_channel_active(Object *ob)
}
/**
- * \see #ED_armature_bone_get_mirrored (edit-mode, matching function)
+ * \see #ED_armature_ebone_get_mirrored (edit-mode, matching function)
*/
bPoseChannel *BKE_pose_channel_get_mirrored(const bPose *pose, const char *name)
{
@@ -855,39 +855,6 @@ void BKE_pose_free(bPose *pose)
BKE_pose_free_ex(pose, true);
}
-static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan)
-{
- bConstraint *pcon, *con;
-
- copy_v3_v3(pchan->loc, chan->loc);
- copy_v3_v3(pchan->size, chan->size);
- copy_v3_v3(pchan->eul, chan->eul);
- copy_v3_v3(pchan->rotAxis, chan->rotAxis);
- pchan->rotAngle = chan->rotAngle;
- copy_qt_qt(pchan->quat, chan->quat);
- pchan->rotmode = chan->rotmode;
- copy_m4_m4(pchan->chan_mat, (float(*)[4])chan->chan_mat);
- copy_m4_m4(pchan->pose_mat, (float(*)[4])chan->pose_mat);
- pchan->flag = chan->flag;
-
- pchan->roll1 = chan->roll1;
- pchan->roll2 = chan->roll2;
- pchan->curveInX = chan->curveInX;
- pchan->curveInY = chan->curveInY;
- pchan->curveOutX = chan->curveOutX;
- pchan->curveOutY = chan->curveOutY;
- pchan->ease1 = chan->ease1;
- pchan->ease2 = chan->ease2;
- pchan->scaleIn = chan->scaleIn;
- pchan->scaleOut = chan->scaleOut;
-
- con = chan->constraints.first;
- for (pcon = pchan->constraints.first; pcon && con; pcon = pcon->next, con = con->next) {
- pcon->enforce = con->enforce;
- pcon->headtail = con->headtail;
- }
-}
-
/**
* Copy the internal members of each pose channel including constraints
* and ID-Props, used when duplicating bones in editmode.
@@ -1329,25 +1296,6 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
/* ************** Pose Management Tools ****************** */
-/* Copy the data from the action-pose (src) into the pose */
-/* both args are assumed to be valid */
-/* exported to game engine */
-/* Note! this assumes both poses are aligned, this isn't always true when dealing with user poses */
-void extract_pose_from_pose(bPose *pose, const bPose *src)
-{
- const bPoseChannel *schan;
- bPoseChannel *pchan = pose->chanbase.first;
-
- if (pose == src) {
- printf("extract_pose_from_pose source and target are the same\n");
- return;
- }
-
- for (schan = src->chanbase.first; (schan && pchan); schan = schan->next, pchan = pchan->next) {
- copy_pose_channel_data(pchan, schan);
- }
-}
-
/* for do_all_pose_actions, clears the pose. Now also exported for proxy and tools */
void BKE_pose_rest(bPose *pose)
{
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 0b964145c7f..1541d39938d 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -340,7 +340,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
* - recalc: whether we need to
*/
/* TODO: include reports pointer? */
- void animviz_calc_motionpaths(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, ListBase *targets)
+ void animviz_calc_motionpaths(Depsgraph *depsgraph, Main *bmain, Scene *scene, ListBase *targets)
{
MPathTarget *mpt;
int sfra, efra;
@@ -367,7 +367,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
/* calculate path over requested range */
for (CFRA = sfra; CFRA <= efra; CFRA++) {
/* update relevant data for new frame */
- motionpaths_calc_update_scene(bmain, eval_ctx->depsgraph);
+ motionpaths_calc_update_scene(bmain, depsgraph);
/* perform baking for targets */
motionpaths_calc_bake_targets(scene, targets);
@@ -375,7 +375,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
/* reset original environment */
CFRA = cfra;
- motionpaths_calc_update_scene(bmain, eval_ctx->depsgraph);
+ motionpaths_calc_update_scene(bmain, depsgraph);
/* clear recalc flags from targets */
for (mpt = targets->first; mpt; mpt = mpt->next) {
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index ecdb180d2ed..924179d5b83 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -70,6 +70,7 @@
#include "BKE_texture.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
@@ -77,8 +78,6 @@
#include "atomic_ops.h"
-#include "DEG_depsgraph.h"
-
/* ***************************************** */
/* AnimData API */
@@ -603,36 +602,8 @@ char *BKE_animdata_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *p
Object *ob = CTX_data_active_object(C);
if (ob && id) {
- /* only id-types which can be remapped to go through objects should be considered */
- switch (GS(id->name)) {
- case ID_TE: /* textures */
- {
- Material *ma = give_current_material(ob, ob->actcol);
- Tex *tex = give_current_material_texture(ma);
-
- /* assumes: texture will only be shown if it is active material's active texture it's ok */
- if ((ID *)tex == id) {
- char name_esc_ma[(sizeof(ma->id.name) - 2) * 2];
- char name_esc_tex[(sizeof(tex->id.name) - 2) * 2];
-
- BLI_strescape(name_esc_ma, ma->id.name + 2, sizeof(name_esc_ma));
- BLI_strescape(name_esc_tex, tex->id.name + 2, sizeof(name_esc_tex));
-
- /* create new path */
- // TODO: use RNA path functions to construct step by step instead?
- // FIXME: maybe this isn't even needed anymore...
- path = BLI_sprintfN("material_slots[\"%s\"].material.texture_slots[\"%s\"].texture.%s",
- name_esc_ma, name_esc_tex, basepath);
-
- /* free old one */
- if (basepath != base_path)
- MEM_freeN(basepath);
- }
- break;
- }
- default:
- break;
- }
+ /* TODO: after material textures were removed, this function serves
+ * no purpose anymore, but could be used again so was not removed. */
/* fix RNA pointer, as we've now changed the ID root by changing the paths */
if (basepath != path) {
@@ -2881,14 +2852,15 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
/* ************** */
/* Evaluation API */
-void BKE_animsys_eval_animdata(const EvaluationContext *eval_ctx, ID *id)
+void BKE_animsys_eval_animdata(Depsgraph *depsgraph, ID *id)
{
+ float ctime = DEG_get_ctime(depsgraph);
AnimData *adt = BKE_animdata_from_id(id);
Scene *scene = NULL; /* XXX: this is only needed for flushing RNA updates,
* which should get handled as part of the dependency graph instead...
*/
- DEG_debug_print_eval_time(__func__, id->name, id, eval_ctx->ctime);
- BKE_animsys_evaluate_animdata(scene, id, adt, eval_ctx->ctime, ADT_RECALC_ANIM);
+ DEG_debug_print_eval_time(__func__, id->name, id, ctime);
+ BKE_animsys_evaluate_animdata(scene, id, adt, ctime, ADT_RECALC_ANIM);
}
/* TODO(sergey): This is slow lookup of driver from CoW datablock.
@@ -2909,7 +2881,7 @@ static FCurve *find_driver_from_evaluated_id(ID *id, FCurve *fcu)
return BLI_findlink(&adt_cow->drivers, fcu_index);
}
-void BKE_animsys_eval_driver(const EvaluationContext *eval_ctx,
+void BKE_animsys_eval_driver(Depsgraph *depsgraph,
ID *id,
FCurve *fcu)
{
@@ -2937,7 +2909,8 @@ void BKE_animsys_eval_driver(const EvaluationContext *eval_ctx,
PathResolvedRNA anim_rna;
if (animsys_store_rna_setting(&id_ptr, NULL, fcu->rna_path, fcu->array_index, &anim_rna)) {
- const float curval = calculate_fcurve(&anim_rna, fcu, eval_ctx->ctime);
+ const float ctime = DEG_get_ctime(depsgraph);
+ const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
ok = animsys_write_rna_setting(&anim_rna, curval);
}
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 0a8c97ff175..d1b02695c35 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -73,7 +73,6 @@
#include "BKE_scene.h"
#include "BIK_api.h"
-#include "BKE_sketch.h"
/* **************** Generic Functions, data level *************** */
@@ -135,12 +134,6 @@ void BKE_armature_free(bArmature *arm)
MEM_freeN(arm->edbo);
arm->edbo = NULL;
}
-
- /* free sketch */
- if (arm->sketch) {
- freeSketch(arm->sketch);
- arm->sketch = NULL;
- }
}
void BKE_armature_make_local(Main *bmain, bArmature *arm, const bool lib_local)
@@ -204,7 +197,6 @@ void BKE_armature_copy_data(Main *UNUSED(bmain), bArmature *arm_dst, const bArma
arm_dst->edbo = NULL;
arm_dst->act_edbone = NULL;
- arm_dst->sketch = NULL;
}
bArmature *BKE_armature_copy(Main *bmain, const bArmature *arm)
@@ -1462,13 +1454,13 @@ void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], fl
copy_v3_v3(outloc, nLocMat[3]);
}
-void BKE_armature_mat_pose_to_bone_ex(const struct EvaluationContext *eval_ctx, Object *ob, bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
+void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph, Object *ob, bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
{
bPoseChannel work_pchan = *pchan;
/* recalculate pose matrix with only parent transformations,
* bone loc/sca/rot is ignored, scene and frame are not used. */
- BKE_pose_where_is_bone(eval_ctx, NULL, ob, &work_pchan, 0.0f, false);
+ BKE_pose_where_is_bone(depsgraph, NULL, ob, &work_pchan, 0.0f, false);
/* find the matrix, need to remove the bone transforms first so this is
* calculated as a matrix to set rather then a difference ontop of whats
@@ -2196,7 +2188,7 @@ void BKE_pose_where_is_bone_tail(bPoseChannel *pchan)
* 'do_extra': when zero skips loc/size/rot, constraints and strip modifiers.
*/
void BKE_pose_where_is_bone(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
Object *ob, bPoseChannel *pchan, float ctime, bool do_extra)
{
/* This gives a chan_mat with actions (ipos) results. */
@@ -2236,7 +2228,7 @@ void BKE_pose_where_is_bone(
cob = BKE_constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
/* Solve PoseChannel's Constraints */
- BKE_constraints_solve(eval_ctx, &pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
+ BKE_constraints_solve(depsgraph, &pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
/* cleanup after Constraint Solving
* - applies matrix back to pchan, and frees temporary struct used
@@ -2258,7 +2250,7 @@ void BKE_pose_where_is_bone(
/* This only reads anim data from channels, and writes to channels */
/* This is the only function adding poses */
-void BKE_pose_where_is(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
{
bArmature *arm;
Bone *bone;
@@ -2297,7 +2289,7 @@ void BKE_pose_where_is(const struct EvaluationContext *eval_ctx, Scene *scene, O
}
/* 2a. construct the IK tree (standard IK) */
- BIK_initialize_tree(eval_ctx, scene, ob, ctime);
+ BIK_initialize_tree(depsgraph, scene, ob, ctime);
/* 2b. construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able
@@ -2309,15 +2301,15 @@ void BKE_pose_where_is(const struct EvaluationContext *eval_ctx, Scene *scene, O
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* 4a. if we find an IK root, we handle it separated */
if (pchan->flag & POSE_IKTREE) {
- BIK_execute_tree(eval_ctx, scene, ob, pchan, ctime);
+ BIK_execute_tree(depsgraph, scene, ob, pchan, ctime);
}
/* 4b. if we find a Spline IK root, we handle it separated too */
else if (pchan->flag & POSE_IKSPLINE) {
- BKE_splineik_execute_tree(eval_ctx, scene, ob, pchan, ctime);
+ BKE_splineik_execute_tree(depsgraph, scene, ob, pchan, ctime);
}
/* 5. otherwise just call the normal solver */
else if (!(pchan->flag & POSE_DONE)) {
- BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(depsgraph, scene, ob, pchan, ctime, 1);
}
}
/* 6. release the IK tree */
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 29baaff32ba..e626ed42062 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -116,7 +116,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
#if 0
/* only happens on reload file, but violates depsgraph still... fix! */
if (ELEM(NULL, ikData->tar->curve_cache, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
- BKE_displist_make_curveTypes(eval_ctx, scene, ikData->tar, 0);
+ BKE_displist_make_curveTypes(depsgraph, scene, ikData->tar, 0);
/* path building may fail in EditMode after removing verts [#33268]*/
if (ELEM(NULL, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
@@ -266,7 +266,7 @@ static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
/* Evaluate spline IK for a given bone */
static void splineik_evaluate_bone(
- const struct EvaluationContext *eval_ctx, tSplineIK_Tree *tree, Scene *scene, Object *ob, bPoseChannel *pchan,
+ struct Depsgraph *depsgraph, tSplineIK_Tree *tree, Scene *scene, Object *ob, bPoseChannel *pchan,
int index, float ctime)
{
bSplineIKConstraint *ikData = tree->ikData;
@@ -274,7 +274,7 @@ static void splineik_evaluate_bone(
float splineVec[3], scaleFac, radius = 1.0f;
/* firstly, calculate the bone matrix the standard way, since this is needed for roll control */
- BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(depsgraph, scene, ob, pchan, ctime, 1);
copy_v3_v3(poseHead, pchan->pose_head);
copy_v3_v3(poseTail, pchan->pose_tail);
@@ -516,7 +516,7 @@ static void splineik_evaluate_bone(
}
/* Evaluate the chain starting from the nominated bone */
-static void splineik_execute_tree(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
+static void splineik_execute_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
{
tSplineIK_Tree *tree;
@@ -530,7 +530,7 @@ static void splineik_execute_tree(const struct EvaluationContext *eval_ctx, Scen
*/
for (i = tree->chainlen - 1; i >= 0; i--) {
bPoseChannel *pchan = tree->chain[i];
- splineik_evaluate_bone(eval_ctx, tree, scene, ob, pchan, i, ctime);
+ splineik_evaluate_bone(depsgraph, tree, scene, ob, pchan, i, ctime);
}
/* free the tree info specific to SplineIK trees now */
@@ -550,10 +550,10 @@ void BKE_pose_splineik_init_tree(Scene *scene, Object *ob, float ctime)
}
void BKE_splineik_execute_tree(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
Object *ob, bPoseChannel *pchan_root, float ctime)
{
- splineik_execute_tree(eval_ctx, scene, ob, pchan_root, ctime);
+ splineik_execute_tree(depsgraph, scene, ob, pchan_root, ctime);
}
/* *************** Depsgraph evaluation callbacks ************ */
@@ -567,7 +567,7 @@ BLI_INLINE bPoseChannel *pose_pchan_get_indexed(Object *ob, int pchan_index)
return pose->chan_array[pchan_index];
}
-void BKE_pose_eval_init(const struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_eval_init(struct Depsgraph *UNUSED(depsgraph),
Scene *UNUSED(scene),
Object *ob)
{
@@ -597,7 +597,7 @@ void BKE_pose_eval_init(const struct EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_init_ik(struct Depsgraph *depsgraph,
Scene *scene,
Object *ob)
{
@@ -609,7 +609,7 @@ void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx,
return;
}
/* construct the IK tree (standard IK) */
- BIK_initialize_tree(eval_ctx, scene, ob, ctime);
+ BIK_initialize_tree(depsgraph, scene, ob, ctime);
/* construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able
* to function in conjunction with standard IK
@@ -617,7 +617,7 @@ void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx,
BKE_pose_splineik_init_tree(scene, ob, ctime);
}
-void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx,
+void BKE_pose_eval_bone(struct Depsgraph *depsgraph,
Scene *scene,
Object *ob,
int pchan_index)
@@ -647,14 +647,14 @@ void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx,
if ((pchan->flag & POSE_DONE) == 0) {
/* TODO(sergey): Use time source node for time. */
float ctime = BKE_scene_frame_get(scene); /* not accurate... */
- BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(depsgraph, scene, ob, pchan, ctime, 1);
}
}
}
}
}
-void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx,
+void BKE_pose_constraints_evaluate(struct Depsgraph *depsgraph,
Scene *scene,
Object *ob,
int pchan_index)
@@ -672,12 +672,12 @@ void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx,
else {
if ((pchan->flag & POSE_DONE) == 0) {
float ctime = BKE_scene_frame_get(scene); /* not accurate... */
- BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(depsgraph, scene, ob, pchan, ctime, 1);
}
}
}
-void BKE_pose_bone_done(const struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_bone_done(struct Depsgraph *UNUSED(depsgraph),
struct Object *ob,
int pchan_index)
{
@@ -690,7 +690,7 @@ void BKE_pose_bone_done(const struct EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx,
+void BKE_pose_iktree_evaluate(struct Depsgraph *depsgraph,
Scene *scene,
Object *ob,
int rootchan_index)
@@ -704,10 +704,10 @@ void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx,
if (arm->flag & ARM_RESTPOS) {
return;
}
- BIK_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
+ BIK_execute_tree(depsgraph, scene, ob, rootchan, ctime);
}
-void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx,
+void BKE_pose_splineik_evaluate(struct Depsgraph *depsgraph,
Scene *scene,
Object *ob,
int rootchan_index)
@@ -722,10 +722,10 @@ void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx,
if (arm->flag & ARM_RESTPOS) {
return;
}
- BKE_splineik_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
+ BKE_splineik_execute_tree(depsgraph, scene, ob, rootchan, ctime);
}
-void BKE_pose_eval_flush(const struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_eval_flush(struct Depsgraph *UNUSED(depsgraph),
Scene *scene,
Object *ob)
{
@@ -744,7 +744,7 @@ void BKE_pose_eval_flush(const struct EvaluationContext *UNUSED(eval_ctx),
pose->chan_array = NULL;
}
-void BKE_pose_eval_proxy_copy(const struct EvaluationContext *UNUSED(eval_ctx), Object *ob)
+void BKE_pose_eval_proxy_copy(struct Depsgraph *UNUSED(depsgraph), Object *ob)
{
BLI_assert(ID_IS_LINKED(ob) && ob->proxy_from != NULL);
DEG_debug_print_eval(__func__, ob->id.name, ob);
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 8d61b6723c6..74e6c996329 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -578,7 +578,7 @@ WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepat
bool BKE_blendfile_workspace_config_write(Main *bmain, const char *filepath, ReportList *reports)
{
- int fileflags = G.fileflags & ~(G_FILE_NO_UI | G_FILE_AUTOPLAY | G_FILE_HISTORY);
+ int fileflags = G.fileflags & ~(G_FILE_NO_UI | G_FILE_HISTORY);
bool retval = false;
BKE_blendfile_write_partial_begin(bmain);
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index f440ce711ff..eb5cdd02fe5 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -132,7 +132,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
if (eff == NULL && gabr->ob) {
memset(&temp_eff, 0, sizeof(EffectorCache));
temp_eff.ob = gabr->ob;
- temp_eff.eval_ctx = bbd->sim->eval_ctx;
+ temp_eff.depsgraph = bbd->sim->depsgraph;
temp_eff.scene = bbd->sim->scene;
eff = &temp_eff;
get_effector_data(eff, &efd, &epoint, 0);
@@ -162,8 +162,10 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
copy_v3_v3(bbd->goal_nor, efd.nor);
}
}
- else if (rule->type == eBoidRuleType_Avoid && bpa->data.mode == eBoidMode_Climbing &&
- priority > 2.0f * gabr->fear_factor) {
+ else if ((rule->type == eBoidRuleType_Avoid) &&
+ (bpa->data.mode == eBoidMode_Climbing) &&
+ (priority > 2.0f * gabr->fear_factor))
+ {
/* detach from surface and try to fly away from danger */
negate_v3_v3(efd.vec_to_point, bpa->gravity);
}
@@ -1107,7 +1109,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
/* jump to go faster */
if (jump == 0 && val.jump_speed > val.max_speed && bbd->wanted_speed > val.max_speed) {
-
+ /* pass */
}
if (jump) {
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index e9a8de4469d..259c5189896 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -580,14 +580,6 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
}
break;
}
- case ID_TE:
- {
- Tex *tex = (Tex *)id;
- if (tex->type == TEX_VOXELDATA && TEX_VD_IS_SOURCE_PATH(tex->vd->file_format)) {
- rewrite_path_fixed(tex->vd->source_path, visit_cb, absbase, bpath_user_data);
- }
- break;
- }
case ID_SCE:
{
Scene *scene = (Scene *)id;
diff --git a/source/blender/blenkernel/intern/bullet.c b/source/blender/blenkernel/intern/bullet.c
deleted file mode 100644
index c16c0f7af31..00000000000
--- a/source/blender/blenkernel/intern/bullet.c
+++ /dev/null
@@ -1,99 +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) Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/blenkernel/intern/bullet.c
- * \ingroup bke
- */
-
-
-#include "MEM_guardedalloc.h"
-
-/* types */
-#include "DNA_object_force_types.h" /* here is the softbody struct */
-
-#include "BKE_bullet.h"
-
-
-/* ************ Object level, exported functions *************** */
-
-/* allocates and initializes general main data */
-BulletSoftBody *bsbNew(void)
-{
- BulletSoftBody *bsb;
-
- bsb = MEM_callocN(sizeof(BulletSoftBody), "bulletsoftbody");
-
- bsb->flag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT;
- bsb->linStiff = 0.5f;
- bsb->angStiff = 1.0f;
- bsb->volume = 1.0f;
-
-
- bsb->viterations = 0;
- bsb->piterations = 2;
- bsb->diterations = 0;
- bsb->citerations = 4;
-
- bsb->kSRHR_CL = 0.1f;
- bsb->kSKHR_CL = 1.f;
- bsb->kSSHR_CL = 0.5f;
- bsb->kSR_SPLT_CL = 0.5f;
-
- bsb->kSK_SPLT_CL = 0.5f;
- bsb->kSS_SPLT_CL = 0.5f;
- bsb->kVCF = 1;
- bsb->kDP = 0;
-
- bsb->kDG = 0;
- bsb->kLF = 0;
- bsb->kPR = 0;
- bsb->kVC = 0;
-
- bsb->kDF = 0.2f;
- bsb->kMT = 0.05;
- bsb->kCHR = 1.0f;
- bsb->kKHR = 0.1f;
-
- bsb->kSHR = 1.0f;
- bsb->kAHR = 0.7f;
-
- bsb->collisionflags = 0;
- //bsb->collisionflags = OB_BSB_COL_CL_RS + OB_BSB_COL_CL_SS;
- bsb->numclusteriterations = 64;
- bsb->welding = 0.f;
-
- return bsb;
-}
-
-/* frees all */
-void bsbFree(BulletSoftBody *bsb)
-{
- /* no internal data yet */
- MEM_freeN(bsb);
-}
-
-
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 8c4bced1563..2c5cdc39ebc 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -259,7 +259,7 @@ void BKE_camera_params_from_object(CameraParams *params, const Object *ob)
}
}
-void BKE_camera_params_from_view3d(CameraParams *params, const Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d)
+void BKE_camera_params_from_view3d(CameraParams *params, Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d)
{
/* common */
params->lens = v3d->lens;
@@ -304,10 +304,7 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win
float pixsize, viewfac, sensor_size, dx, dy;
int sensor_fit;
- /* fields rendering */
params->ycor = yasp / xasp;
- if (params->use_fields)
- params->ycor *= 2.0f;
if (params->is_ortho) {
/* orthographic camera */
@@ -349,18 +346,6 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win
viewplane.xmax += dx;
viewplane.ymax += dy;
- /* fields offset */
- if (params->field_second) {
- if (params->field_odd) {
- viewplane.ymin -= 0.5f * params->ycor;
- viewplane.ymax -= 0.5f * params->ycor;
- }
- else {
- viewplane.ymin += 0.5f * params->ycor;
- viewplane.ymax += 0.5f * params->ycor;
- }
- }
-
/* the window matrix is used for clipping, and not changed during OSA steps */
/* using an offset of +0.5 here would give clip errors on edges */
viewplane.xmin *= pixsize;
@@ -664,7 +649,7 @@ static bool camera_frame_fit_calc_from_data(
/* don't move the camera, just yield the fit location */
/* r_scale only valid/useful for ortho cameras */
bool BKE_camera_view_frame_fit_to_scene(
- Scene *scene, ViewLayer *view_layer, Object *camera_ob, float r_co[3], float *r_scale)
+ Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, Object *camera_ob, float r_co[3], float *r_scale)
{
CameraParams params;
CameraViewFrameData data_cb;
@@ -675,7 +660,7 @@ bool BKE_camera_view_frame_fit_to_scene(
camera_frame_fit_data_init(scene, camera_ob, &params, &data_cb);
/* run callback on all visible points */
- BKE_scene_foreach_display_point(scene, view_layer, camera_to_frame_view_cb, &data_cb);
+ BKE_scene_foreach_display_point(depsgraph, scene, view_layer, camera_to_frame_view_cb, &data_cb);
return camera_frame_fit_calc_from_data(&params, &data_cb, r_co, r_scale);
}
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index a6c6d360769..33540c8746b 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -57,13 +57,6 @@
#include "MEM_guardedalloc.h"
-#include "GPU_buffers.h"
-#include "GPU_draw.h"
-#include "GPU_glew.h"
-#include "GPU_immediate.h"
-#include "GPU_shader.h"
-#include "GPU_basic_shader.h"
-
#include <string.h>
#include <limits.h>
#include <math.h>
@@ -339,1329 +332,6 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
return cddm->pbvh;
}
-/* update vertex normals so that drawing smooth faces works during sculpt
- * TODO: proper fix is to support the pbvh in all drawing modes */
-static void cdDM_update_normals_from_pbvh(DerivedMesh *dm)
-{
- CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
- float (*face_nors)[3];
-
- /* Some callbacks do not use optimal PBVH draw, so needs all the
- * possible data (like normals) to be copied from PBVH back to DM.
- *
- * This is safe to do if PBVH and DM are representing the same mesh,
- * which could be wrong when modifiers are enabled for sculpt.
- * So here we only doing update when there's no modifiers applied
- * during sculpt.
- *
- * It's safe to do nothing if there are modifiers, because in this
- * case modifier stack is re-constructed from scratch on every
- * update.
- */
- if (!cddm->pbvh_draw) {
- return;
- }
-
- face_nors = CustomData_get_layer(&dm->polyData, CD_NORMAL);
-
- BKE_pbvh_update(cddm->pbvh, PBVH_UpdateNormals, face_nors);
-}
-
-static void cdDM_drawVerts(DerivedMesh *dm)
-{
- GPU_vertex_setup(dm);
- if (dm->drawObject->tot_loop_verts)
- glDrawArrays(GL_POINTS, 0, dm->drawObject->tot_loop_verts);
- else
- glDrawArrays(GL_POINTS, 0, dm->drawObject->tot_loose_point);
- GPU_buffers_unbind();
-}
-
-static void cdDM_drawEdges(DerivedMesh *dm, bool UNUSED(drawLooseEdges), bool UNUSED(drawAllEdges))
-{
- CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
-
- if (cddm->pbvh && cddm->pbvh_draw &&
- BKE_pbvh_type(cddm->pbvh) == PBVH_BMESH)
- {
- BKE_pbvh_draw(cddm->pbvh, NULL, NULL, NULL, true, false);
-
- return;
- }
-
- MVert *vert = cddm->mvert;
- MEdge *edge = cddm->medge;
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- /* NOTE: This is active object color, which is not really perfect.
- * But we can't query color set by glColor() :(
- */
- float color[4] = {1.0f, 0.667f, 0.251f, 1.0f};
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4fv(color);
-
- const int chunk_size = 1024;
- const int num_chunks = (dm->numEdgeData + chunk_size - 1) / chunk_size;
-
- for (int chunk = 0; chunk < num_chunks; ++chunk) {
- const int num_current_edges = (chunk < num_chunks - 1)
- ? chunk_size
- : dm->numEdgeData - chunk_size * (num_chunks - 1);
- immBeginAtMost(GWN_PRIM_LINES, num_current_edges * 2);
- for (int i = 0; i < num_current_edges; i++, edge++) {
- immVertex3fv(pos, vert[edge->v1].co);
- immVertex3fv(pos, vert[edge->v2].co);
- }
- immEnd();
- }
-
- immUnbindProgram();
-}
-
-static void cdDM_drawLooseEdges(DerivedMesh *dm)
-{
- int start;
- int count;
-
- GPU_edge_setup(dm);
-
- start = (dm->drawObject->loose_edge_offset * 2);
- count = (dm->drawObject->totedge - dm->drawObject->loose_edge_offset) * 2;
-
- if (count) {
- GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, start, count);
- }
-
- GPU_buffers_unbind();
-}
-
-static void cdDM_drawFacesSolid(
- DerivedMesh *dm,
- float (*partial_redraw_planes)[4],
- bool fast, DMSetMaterial setMaterial)
-{
- UNUSED_VARS(partial_redraw_planes, fast, setMaterial);
- CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
- int a;
-
- if (cddm->pbvh) {
- if (cddm->pbvh_draw && BKE_pbvh_has_faces(cddm->pbvh)) {
- float (*face_nors)[3] = CustomData_get_layer(&dm->polyData, CD_NORMAL);
-
- BKE_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors,
- setMaterial, false, false);
- return;
- }
- }
-
- const MVert *mvert = cddm->mvert;
- const MLoop *mloop = cddm->mloop;
- const MPoly *mpoly = cddm->mpoly;
- const int num_looptris = dm->getNumLoopTri(dm);
- const MLoopTri *looptri = dm->getLoopTriArray(dm);
- const float (*nors)[3] = dm->getPolyDataArray(dm, CD_NORMAL);
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int nor = GWN_vertformat_attr_add(format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- float color[4] = {0.8f, 0.8f, 0.8f, 1.0f};
- const float light_vec[3] = {0.0f, 0.0f, 1.0f};
-
- immBindBuiltinProgram(GPU_SHADER_SIMPLE_LIGHTING);
- immUniformColor4fv(color);
- immUniform3fv("light", light_vec);
-
- const int chunk_size = 1024;
- const int num_chunks = (num_looptris + chunk_size - 1) / chunk_size;
-
- for (int chunk = 0; chunk < num_chunks; ++chunk) {
- const int num_current_looptris = (chunk < num_chunks - 1)
- ? chunk_size
- : num_looptris - chunk_size * (num_chunks - 1);
-
- immBeginAtMost(GWN_PRIM_TRIS, num_current_looptris * 3);
-
- for (a = 0; a < num_current_looptris; a++, looptri++) {
- const MPoly *mp = &mpoly[looptri->poly];
- const bool smoothnormal = (lnors != NULL) || (mp->flag & ME_SMOOTH);
- const unsigned int vtri[3] = {mloop[looptri->tri[0]].v,
- mloop[looptri->tri[1]].v,
- mloop[looptri->tri[2]].v};
- const unsigned int *ltri = looptri->tri;
- float normals[3][3];
- if (!smoothnormal) {
- if (nors != NULL) {
- copy_v3_v3(normals[0], nors[looptri->poly]);
- }
- else {
- normal_tri_v3(normals[0],
- mvert[vtri[0]].co,
- mvert[vtri[1]].co,
- mvert[vtri[2]].co);
- }
- copy_v3_v3(normals[1], normals[0]);
- copy_v3_v3(normals[2], normals[0]);
- }
- else if (lnors != NULL) {
- copy_v3_v3(normals[0], lnors[ltri[0]]);
- copy_v3_v3(normals[1], lnors[ltri[1]]);
- copy_v3_v3(normals[2], lnors[ltri[2]]);
- }
- else {
- normal_short_to_float_v3(normals[0], mvert[vtri[0]].no);
- normal_short_to_float_v3(normals[1], mvert[vtri[1]].no);
- normal_short_to_float_v3(normals[2], mvert[vtri[2]].no);
- }
-
- immAttrib3fv(nor, normals[0]);
- immVertex3fv(pos, mvert[vtri[0]].co);
- immAttrib3fv(nor, normals[1]);
- immVertex3fv(pos, mvert[vtri[1]].co);
- immAttrib3fv(nor, normals[2]);
- immVertex3fv(pos, mvert[vtri[2]].co);
- }
- immEnd();
- }
-
- immUnbindProgram();
-}
-
-static void cdDM_drawMappedFaces(
- DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMSetMaterial setMaterial,
- DMCompareDrawOptions compareDrawOptions,
- void *userData, DMDrawFlag flag)
-{
- CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
- const MPoly *mpoly = cddm->mpoly;
- const MLoopCol *mloopcol = NULL;
- const bool use_colors = (flag & DM_DRAW_USE_COLORS) != 0;
- const bool use_hide = (flag & DM_DRAW_SKIP_HIDDEN) != 0;
- int colType;
- int i, j;
- int start_element = 0, tot_element, tot_drawn;
- int totpoly;
- int tot_tri_elem;
- int mat_index;
- GPUBuffer *findex_buffer = NULL;
-
- const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
-
- if (cddm->pbvh) {
- if (G.debug_value == 14)
- BKE_pbvh_draw_BB(cddm->pbvh);
- }
-
- /* fist, setup common buffers */
- GPU_vertex_setup(dm);
- GPU_triangle_setup(dm);
-
- totpoly = dm->getNumPolys(dm);
-
- /* if we do selection, fill the selection buffer color */
- if (G.f & G_BACKBUFSEL) {
- if (!(flag & DM_DRAW_SKIP_SELECT)) {
- Mesh *me = NULL;
- BMesh *bm = NULL;
- unsigned int *fi_map;
-
- if (flag & DM_DRAW_SELECT_USE_EDITMODE)
- bm = userData;
- else
- me = userData;
-
- findex_buffer = GPU_buffer_alloc(dm->drawObject->tot_loop_verts * sizeof(int));
- fi_map = GPU_buffer_lock(findex_buffer, GPU_BINDING_ARRAY);
-
- if (fi_map) {
- for (i = 0; i < totpoly; i++, mpoly++) {
- int selcol = 0xFFFFFFFF;
- const int orig = (index_mp_to_orig) ? index_mp_to_orig[i] : i;
- bool is_hidden;
-
- if (orig != ORIGINDEX_NONE) {
- if (use_hide) {
- if (flag & DM_DRAW_SELECT_USE_EDITMODE) {
- BMFace *efa = BM_face_at_index(bm, orig);
- is_hidden = BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0;
- }
- else {
- is_hidden = (me->mpoly[orig].flag & ME_HIDE) != 0;
- }
-
- if (!is_hidden) {
- GPU_select_index_get(orig + 1, &selcol);
- }
- }
- else {
- GPU_select_index_get(orig + 1, &selcol);
- }
- }
-
- for (j = 0; j < mpoly->totloop; j++)
- fi_map[start_element++] = selcol;
- }
-
- start_element = 0;
- mpoly = cddm->mpoly;
-
- GPU_buffer_unlock(findex_buffer, GPU_BINDING_ARRAY);
- GPU_buffer_bind_as_color(findex_buffer);
- }
- }
- }
- else {
- GPU_normal_setup(dm);
-
- if (use_colors) {
- colType = CD_TEXTURE_MLOOPCOL;
- mloopcol = DM_get_loop_data_layer(dm, colType);
- if (!mloopcol) {
- colType = CD_PREVIEW_MLOOPCOL;
- mloopcol = DM_get_loop_data_layer(dm, colType);
- }
- if (!mloopcol) {
- colType = CD_MLOOPCOL;
- mloopcol = DM_get_loop_data_layer(dm, colType);
- }
-
- if (use_colors && mloopcol) {
- GPU_color_setup(dm, colType);
- }
- }
- }
-
- tot_tri_elem = dm->drawObject->tot_triangle_point;
-
- if (tot_tri_elem == 0) {
- /* avoid buffer problems in following code */
- }
- else if (setDrawOptions == NULL) {
- /* just draw the entire face array */
- GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, 0, tot_tri_elem);
- }
- else {
- for (mat_index = 0; mat_index < dm->drawObject->totmaterial; mat_index++) {
- GPUBufferMaterial *bufmat = dm->drawObject->materials + mat_index;
- DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
- int next_actualFace = bufmat->polys[0];
- totpoly = use_hide ? bufmat->totvisiblepolys : bufmat->totpolys;
-
- tot_element = 0;
- start_element = 0;
- tot_drawn = 0;
-
- if (setMaterial)
- draw_option = setMaterial(bufmat->mat_nr + 1, NULL);
-
- if (draw_option != DM_DRAW_OPTION_SKIP) {
- DMDrawOption last_draw_option = DM_DRAW_OPTION_NORMAL;
-
- for (i = 0; i < totpoly; i++) {
- int actualFace = next_actualFace;
- int flush = 0;
- int tot_tri_verts;
-
- draw_option = DM_DRAW_OPTION_NORMAL;
-
- if (i != totpoly - 1)
- next_actualFace = bufmat->polys[i + 1];
-
- if (setDrawOptions) {
- const int orig = (index_mp_to_orig) ? index_mp_to_orig[actualFace] : actualFace;
-
- if (orig != ORIGINDEX_NONE) {
- draw_option = setDrawOptions(userData, orig);
- }
- }
-
- /* Goal is to draw as long of a contiguous triangle
- * array as possible, so draw when we hit either an
- * invisible triangle or at the end of the array */
-
- /* flush buffer if current triangle isn't drawable or it's last triangle... */
- flush = (draw_option != last_draw_option) || (i == totpoly - 1);
-
- if (!flush && compareDrawOptions) {
- flush |= compareDrawOptions(userData, actualFace, next_actualFace) == 0;
- }
-
- tot_tri_verts = ME_POLY_TRI_TOT(&mpoly[actualFace]) * 3;
- tot_element += tot_tri_verts;
-
- if (flush) {
- if (draw_option != DM_DRAW_OPTION_SKIP) {
- tot_drawn += tot_tri_verts;
-
- if (last_draw_option != draw_option) {
- if (draw_option == DM_DRAW_OPTION_STIPPLE) {
- GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR);
- GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE);
- }
- else {
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- }
- }
- }
-
- if (tot_drawn) {
- GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, bufmat->start + start_element, tot_drawn);
- tot_drawn = 0;
- }
-
- last_draw_option = draw_option;
- start_element = tot_element;
- }
- else {
- if (draw_option != DM_DRAW_OPTION_SKIP) {
- tot_drawn += tot_tri_verts;
- }
- else {
- start_element = tot_element;
- }
- }
- }
- }
- }
- }
-
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
-
- GPU_buffers_unbind();
-
- if (findex_buffer)
- GPU_buffer_free(findex_buffer);
-
-}
-
-static void cddm_draw_attrib_vertex(
- DMVertexAttribs *attribs, const MVert *mvert, int a, int index, int loop, int vert,
- const float *lnor, const bool smoothnormal)
-{
- DM_draw_attrib_vertex(attribs, a, index, vert, loop);
-
- /* vertex normal */
- if (lnor) {
- glNormal3fv(lnor);
- }
- else if (smoothnormal) {
- glNormal3sv(mvert[index].no);
- }
-
- /* vertex coordinate */
- glVertex3fv(mvert[index].co);
-}
-
-typedef struct {
- DMVertexAttribs attribs;
- int numdata;
-
- GPUAttrib datatypes[GPU_MAX_ATTRIB]; /* TODO, messing up when switching materials many times - [#21056]*/
-} GPUMaterialConv;
-
-static void cdDM_drawMappedFacesGLSL(
- DerivedMesh *dm,
- DMSetMaterial setMaterial,
- DMSetDrawOptions setDrawOptions,
- void *userData)
-{
- CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
- GPUVertexAttribs gattribs;
- const MVert *mvert = cddm->mvert;
- const MPoly *mpoly = cddm->mpoly;
- const MLoop *mloop = cddm->mloop;
- const MLoopTri *lt = dm->getLoopTriArray(dm);
- const int tottri = dm->getNumLoopTri(dm);
- /* MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */
- const float (*nors)[3] = dm->getPolyDataArray(dm, CD_NORMAL);
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
- const int totpoly = dm->getNumPolys(dm);
- const short dm_totmat = dm->totmat;
- int a, b, matnr, new_matnr;
- bool do_draw;
- int orig;
-
- const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
-
- /* TODO: same as for solid draw, not entirely correct, but works fine for now,
- * will skip using textures (dyntopo currently destroys UV anyway) and
- * works fine for matcap
- */
- if (cddm->pbvh) {
- if (cddm->pbvh_draw &&
- BKE_pbvh_type(cddm->pbvh) == PBVH_BMESH &&
- BKE_pbvh_has_faces(cddm->pbvh))
- {
- setMaterial(1, &gattribs);
- BKE_pbvh_draw(cddm->pbvh, NULL, NULL, NULL, false, false);
- return;
- }
- else {
- cdDM_update_normals_from_pbvh(dm);
- }
- }
-
- matnr = -1;
- do_draw = false;
-
- if (setDrawOptions != NULL) {
- DMVertexAttribs attribs;
- DEBUG_VBO("Using legacy code. cdDM_drawMappedFacesGLSL\n");
- memset(&attribs, 0, sizeof(attribs));
-
- glBegin(GL_TRIANGLES);
-
- for (a = 0; a < tottri; a++, lt++) {
- const MPoly *mp = &mpoly[lt->poly];
- const unsigned int vtri[3] = {mloop[lt->tri[0]].v, mloop[lt->tri[1]].v, mloop[lt->tri[2]].v};
- const unsigned int *ltri = lt->tri;
- const float *ln1 = NULL, *ln2 = NULL, *ln3 = NULL;
- const bool smoothnormal = lnors || (mp->flag & ME_SMOOTH);
- new_matnr = mp->mat_nr;
-
- if (new_matnr != matnr) {
- glEnd();
-
- matnr = new_matnr;
- do_draw = setMaterial(matnr + 1, &gattribs);
- if (do_draw) {
- DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
- DM_draw_attrib_vertex_uniforms(&attribs);
- }
-
- glBegin(GL_TRIANGLES);
- }
-
- if (!do_draw) {
- continue;
- }
- else /* if (setDrawOptions) */ {
- orig = (index_mp_to_orig) ? index_mp_to_orig[lt->poly] : lt->poly;
-
- if (orig == ORIGINDEX_NONE) {
- /* since the material is set by setMaterial(), faces with no
- * origin can be assumed to be generated by a modifier */
-
- /* continue */
- }
- else if (setDrawOptions(userData, orig) == DM_DRAW_OPTION_SKIP)
- continue;
- }
-
- if (!smoothnormal) {
- if (nors) {
- glNormal3fv(nors[lt->poly]);
- }
- else {
- /* TODO ideally a normal layer should always be available */
- float nor[3];
- normal_tri_v3(nor, mvert[vtri[0]].co, mvert[vtri[1]].co, mvert[vtri[2]].co);
- glNormal3fv(nor);
- }
- }
- else if (lnors) {
- ln1 = lnors[ltri[0]];
- ln2 = lnors[ltri[1]];
- ln3 = lnors[ltri[2]];
- }
-
- cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[0], ltri[0], 0, ln1, smoothnormal);
- cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[1], ltri[1], 1, ln2, smoothnormal);
- cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[2], ltri[2], 2, ln3, smoothnormal);
- }
- glEnd();
- }
- else {
- GPUMaterialConv *matconv;
- int offset;
- int *mat_orig_to_new;
- int tot_active_mat;
- GPUBuffer *buffer = NULL;
- unsigned char *varray;
- size_t max_element_size = 0;
- int tot_loops = 0;
-
- GPU_vertex_setup(dm);
- GPU_normal_setup(dm);
- GPU_triangle_setup(dm);
-
- tot_active_mat = dm->drawObject->totmaterial;
-
- matconv = MEM_calloc_arrayN(tot_active_mat, sizeof(*matconv),
- "cdDM_drawMappedFacesGLSL.matconv");
- mat_orig_to_new = MEM_malloc_arrayN(dm->totmat, sizeof(*mat_orig_to_new),
- "cdDM_drawMappedFacesGLSL.mat_orig_to_new");
-
- /* part one, check what attributes are needed per material */
- for (a = 0; a < tot_active_mat; a++) {
- new_matnr = dm->drawObject->materials[a].mat_nr;
-
- /* map from original material index to new
- * GPUBufferMaterial index */
- mat_orig_to_new[new_matnr] = a;
- do_draw = setMaterial(new_matnr + 1, &gattribs);
-
- if (do_draw) {
- int numdata = 0;
- DM_vertex_attributes_from_gpu(dm, &gattribs, &matconv[a].attribs);
-
- if (matconv[a].attribs.totorco && matconv[a].attribs.orco.array) {
- matconv[a].datatypes[numdata].index = matconv[a].attribs.orco.gl_index;
- matconv[a].datatypes[numdata].info_index = matconv[a].attribs.orco.gl_info_index;
- matconv[a].datatypes[numdata].size = 3;
- matconv[a].datatypes[numdata].type = GL_FLOAT;
- numdata++;
- }
- for (b = 0; b < matconv[a].attribs.tottface; b++) {
- if (matconv[a].attribs.tface[b].array) {
- matconv[a].datatypes[numdata].index = matconv[a].attribs.tface[b].gl_index;
- matconv[a].datatypes[numdata].info_index = matconv[a].attribs.tface[b].gl_info_index;
- matconv[a].datatypes[numdata].size = 2;
- matconv[a].datatypes[numdata].type = GL_FLOAT;
- numdata++;
- }
- }
- for (b = 0; b < matconv[a].attribs.totmcol; b++) {
- if (matconv[a].attribs.mcol[b].array) {
- matconv[a].datatypes[numdata].index = matconv[a].attribs.mcol[b].gl_index;
- matconv[a].datatypes[numdata].info_index = matconv[a].attribs.mcol[b].gl_info_index;
- matconv[a].datatypes[numdata].size = 4;
- matconv[a].datatypes[numdata].type = GL_UNSIGNED_BYTE;
- numdata++;
- }
- }
- for (b = 0; b < matconv[a].attribs.tottang; b++) {
- if (matconv[a].attribs.tang[b].array) {
- matconv[a].datatypes[numdata].index = matconv[a].attribs.tang[b].gl_index;
- matconv[a].datatypes[numdata].info_index = matconv[a].attribs.tang[b].gl_info_index;
- matconv[a].datatypes[numdata].size = 4;
- matconv[a].datatypes[numdata].type = GL_FLOAT;
- numdata++;
- }
- }
- if (numdata != 0) {
- matconv[a].numdata = numdata;
- max_element_size = max_ii(GPU_attrib_element_size(matconv[a].datatypes, numdata), max_element_size);
- }
- }
- }
-
- /* part two, generate and fill the arrays with the data */
- if (max_element_size > 0) {
- buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts);
-
- varray = GPU_buffer_lock_stream(buffer, GPU_BINDING_ARRAY);
- if (varray == NULL) {
- GPU_buffers_unbind();
- GPU_buffer_free(buffer);
- MEM_freeN(mat_orig_to_new);
- MEM_freeN(matconv);
- fprintf(stderr, "Out of memory, can't draw object\n");
- return;
- }
-
- for (a = 0; a < totpoly; a++, mpoly++) {
- const short mat_nr = ME_MAT_NR_TEST(mpoly->mat_nr, dm_totmat);
- int j;
- int i = mat_orig_to_new[mat_nr];
- offset = tot_loops * max_element_size;
-
- if (matconv[i].numdata != 0) {
- if (matconv[i].attribs.totorco && matconv[i].attribs.orco.array) {
- for (j = 0; j < mpoly->totloop; j++)
- copy_v3_v3((float *)&varray[offset + j * max_element_size],
- (float *)matconv[i].attribs.orco.array[mloop[mpoly->loopstart + j].v]);
- offset += sizeof(float) * 3;
- }
- for (b = 0; b < matconv[i].attribs.tottface; b++) {
- if (matconv[i].attribs.tface[b].array) {
- const MLoopUV *mloopuv = matconv[i].attribs.tface[b].array;
- for (j = 0; j < mpoly->totloop; j++)
- copy_v2_v2((float *)&varray[offset + j * max_element_size], mloopuv[mpoly->loopstart + j].uv);
- offset += sizeof(float) * 2;
- }
- }
- for (b = 0; b < matconv[i].attribs.totmcol; b++) {
- if (matconv[i].attribs.mcol[b].array) {
- const MLoopCol *mloopcol = matconv[i].attribs.mcol[b].array;
- for (j = 0; j < mpoly->totloop; j++)
- copy_v4_v4_uchar(&varray[offset + j * max_element_size], &mloopcol[mpoly->loopstart + j].r);
- offset += sizeof(unsigned char) * 4;
- }
- }
- for (b = 0; b < matconv[i].attribs.tottang; b++) {
- if (matconv[i].attribs.tottang && matconv[i].attribs.tang[b].array) {
- const float (*looptang)[4] = (const float (*)[4])matconv[i].attribs.tang[b].array;
- for (j = 0; j < mpoly->totloop; j++)
- copy_v4_v4((float *)&varray[offset + j * max_element_size], looptang[mpoly->loopstart + j]);
- offset += sizeof(float) * 4;
- }
- }
- }
-
- tot_loops += mpoly->totloop;
- }
- GPU_buffer_unlock(buffer, GPU_BINDING_ARRAY);
- }
-
- for (a = 0; a < tot_active_mat; a++) {
- new_matnr = dm->drawObject->materials[a].mat_nr;
-
- do_draw = setMaterial(new_matnr + 1, &gattribs);
-
- if (do_draw) {
- if (matconv[a].numdata) {
- GPU_interleaved_attrib_setup(buffer, matconv[a].datatypes, matconv[a].numdata, max_element_size);
- }
- GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES,
- dm->drawObject->materials[a].start, dm->drawObject->materials[a].totelements);
- if (matconv[a].numdata) {
- GPU_interleaved_attrib_unbind();
- }
- }
- }
-
- GPU_buffers_unbind();
- if (buffer)
- GPU_buffer_free(buffer);
-
- MEM_freeN(mat_orig_to_new);
- MEM_freeN(matconv);
- }
-}
-
-static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
-{
- dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
-}
-
-static void cdDM_drawMappedFacesMat(
- DerivedMesh *dm,
- void (*setMaterial)(void *userData, int matnr, void *attribs),
- bool (*setFace)(void *userData, int index), void *userData)
-{
- CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
- GPUVertexAttribs gattribs;
- DMVertexAttribs attribs;
- MVert *mvert = cddm->mvert;
- const MPoly *mpoly = cddm->mpoly;
- const MLoop *mloop = cddm->mloop;
- const MLoopTri *lt = dm->getLoopTriArray(dm);
- const int tottri = dm->getNumLoopTri(dm);
- const float (*nors)[3] = dm->getPolyDataArray(dm, CD_NORMAL);
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
- int a, matnr, new_matnr;
- int orig;
-
- const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
-
- /* TODO: same as for solid draw, not entirely correct, but works fine for now,
- * will skip using textures (dyntopo currently destroys UV anyway) and
- * works fine for matcap
- */
-
- if (cddm->pbvh) {
- if (cddm->pbvh_draw &&
- BKE_pbvh_type(cddm->pbvh) == PBVH_BMESH &&
- BKE_pbvh_has_faces(cddm->pbvh))
- {
- setMaterial(userData, 1, &gattribs);
- BKE_pbvh_draw(cddm->pbvh, NULL, NULL, NULL, false, false);
- return;
- }
- else {
- cdDM_update_normals_from_pbvh(dm);
- }
- }
-
- matnr = -1;
-
- memset(&attribs, 0, sizeof(attribs));
-
- glBegin(GL_TRIANGLES);
-
- for (a = 0; a < tottri; a++, lt++) {
- const MPoly *mp = &mpoly[lt->poly];
- const unsigned int vtri[3] = {mloop[lt->tri[0]].v, mloop[lt->tri[1]].v, mloop[lt->tri[2]].v};
- const unsigned int *ltri = lt->tri;
- const bool smoothnormal = lnors || (mp->flag & ME_SMOOTH);
- const float *ln1 = NULL, *ln2 = NULL, *ln3 = NULL;
-
- /* material */
- new_matnr = mp->mat_nr + 1;
-
- if (new_matnr != matnr) {
- glEnd();
-
- setMaterial(userData, matnr = new_matnr, &gattribs);
- DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
- DM_draw_attrib_vertex_uniforms(&attribs);
-
- glBegin(GL_TRIANGLES);
- }
-
- /* skipping faces */
- if (setFace) {
- orig = (index_mp_to_orig) ? index_mp_to_orig[lt->poly] : lt->poly;
-
- if (orig != ORIGINDEX_NONE && !setFace(userData, orig))
- continue;
- }
-
- /* smooth normal */
- if (!smoothnormal) {
- if (nors) {
- glNormal3fv(nors[lt->poly]);
- }
- else {
- /* TODO ideally a normal layer should always be available */
- float nor[3];
- normal_tri_v3(nor, mvert[vtri[0]].co, mvert[vtri[1]].co, mvert[vtri[2]].co);
- glNormal3fv(nor);
- }
- }
- else if (lnors) {
- ln1 = lnors[ltri[0]];
- ln2 = lnors[ltri[1]];
- ln3 = lnors[ltri[2]];
- }
-
- /* vertices */
- cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[0], ltri[0], 0, ln1, smoothnormal);
- cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[1], ltri[1], 1, ln2, smoothnormal);
- cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[2], ltri[2], 2, ln3, smoothnormal);
- }
- glEnd();
-}
-
-static void cdDM_drawMappedEdges(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, void *userData)
-{
- CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
- MVert *vert = cddm->mvert;
- MEdge *edge = cddm->medge;
- int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
-
- glBegin(GL_LINES);
- for (i = 0; i < dm->numEdgeData; i++, edge++) {
- if (index) {
- orig = *index++;
- if (setDrawOptions && orig == ORIGINDEX_NONE) continue;
- }
- else
- orig = i;
-
- if (!setDrawOptions || (setDrawOptions(userData, orig) != DM_DRAW_OPTION_SKIP)) {
- glVertex3fv(vert[edge->v1].co);
- glVertex3fv(vert[edge->v2].co);
- }
- }
- glEnd();
-}
-
-typedef struct FaceCount {
- unsigned int i_visible;
- unsigned int i_hidden;
- unsigned int i_tri_visible;
- unsigned int i_tri_hidden;
-} FaceCount;
-
-static void cdDM_buffer_copy_triangles(
- DerivedMesh *dm, unsigned int *varray,
- const int *mat_orig_to_new)
-{
- GPUBufferMaterial *gpumat, *gpumaterials = dm->drawObject->materials;
- int i, j, start;
-
- const int gpu_totmat = dm->drawObject->totmaterial;
- const short dm_totmat = dm->totmat;
- const MPoly *mpoly = dm->getPolyArray(dm);
- const MLoopTri *lt = dm->getLoopTriArray(dm);
- const int totpoly = dm->getNumPolys(dm);
-
- FaceCount *fc = MEM_malloc_arrayN(gpu_totmat, sizeof(*fc), "gpumaterial.facecount");
-
- for (i = 0; i < gpu_totmat; i++) {
- fc[i].i_visible = 0;
- fc[i].i_tri_visible = 0;
- fc[i].i_hidden = gpumaterials[i].totpolys - 1;
- fc[i].i_tri_hidden = gpumaterials[i].totelements - 1;
- }
-
- for (i = 0; i < totpoly; i++) {
- const short mat_nr = ME_MAT_NR_TEST(mpoly[i].mat_nr, dm_totmat);
- int tottri = ME_POLY_TRI_TOT(&mpoly[i]);
- int mati = mat_orig_to_new[mat_nr];
- gpumat = gpumaterials + mati;
-
- if (mpoly[i].flag & ME_HIDE) {
- for (j = 0; j < tottri; j++, lt++) {
- start = gpumat->start + fc[mati].i_tri_hidden;
- /* v1 v2 v3 */
- varray[start--] = lt->tri[2];
- varray[start--] = lt->tri[1];
- varray[start--] = lt->tri[0];
- fc[mati].i_tri_hidden -= 3;
- }
- gpumat->polys[fc[mati].i_hidden--] = i;
- }
- else {
- for (j = 0; j < tottri; j++, lt++) {
- start = gpumat->start + fc[mati].i_tri_visible;
- /* v1 v2 v3 */
- varray[start++] = lt->tri[0];
- varray[start++] = lt->tri[1];
- varray[start++] = lt->tri[2];
- fc[mati].i_tri_visible += 3;
- }
- gpumat->polys[fc[mati].i_visible++] = i;
- }
- }
-
- /* set the visible polygons */
- for (i = 0; i < gpu_totmat; i++) {
- gpumaterials[i].totvisiblepolys = fc[i].i_visible;
- }
-
- MEM_freeN(fc);
-}
-
-static void cdDM_buffer_copy_vertex(
- DerivedMesh *dm, float *varray)
-{
- const MVert *mvert;
- const MPoly *mpoly;
- const MLoop *mloop;
-
- int i, j, start, totpoly;
-
- mvert = dm->getVertArray(dm);
- mpoly = dm->getPolyArray(dm);
- mloop = dm->getLoopArray(dm);
- totpoly = dm->getNumPolys(dm);
-
- start = 0;
-
- for (i = 0; i < totpoly; i++, mpoly++) {
- for (j = 0; j < mpoly->totloop; j++) {
- copy_v3_v3(&varray[start], mvert[mloop[mpoly->loopstart + j].v].co);
- start += 3;
- }
- }
-
- /* copy loose points */
- j = dm->drawObject->tot_loop_verts * 3;
- for (i = 0; i < dm->drawObject->totvert; i++) {
- if (dm->drawObject->vert_points[i].point_index >= dm->drawObject->tot_loop_verts) {
- copy_v3_v3(&varray[j], mvert[i].co);
- j += 3;
- }
- }
-}
-
-static void cdDM_buffer_copy_normal(
- DerivedMesh *dm, short *varray)
-{
- CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
- int i, j, totpoly;
- int start;
-
- const float (*nors)[3] = dm->getPolyDataArray(dm, CD_NORMAL);
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
-
- const MVert *mvert;
- const MPoly *mpoly;
- const MLoop *mloop;
-
- mvert = dm->getVertArray(dm);
- mpoly = dm->getPolyArray(dm);
- mloop = dm->getLoopArray(dm);
- totpoly = dm->getNumPolys(dm);
-
- /* we are in sculpt mode, disable loop normals (since they won't get updated) */
- if (cddm->pbvh)
- lnors = NULL;
-
- start = 0;
- for (i = 0; i < totpoly; i++, mpoly++) {
- const bool smoothnormal = (mpoly->flag & ME_SMOOTH) != 0;
-
- if (lnors) {
- /* Copy loop normals */
- for (j = 0; j < mpoly->totloop; j++, start += 4) {
- normal_float_to_short_v3(&varray[start], lnors[mpoly->loopstart + j]);
- }
- }
- else if (smoothnormal) {
- /* Copy vertex normal */
- for (j = 0; j < mpoly->totloop; j++, start += 4) {
- copy_v3_v3_short(&varray[start], mvert[mloop[mpoly->loopstart + j].v].no);
- }
- }
- else {
- /* Copy cached OR calculated face normal */
- short f_no_s[3];
-
- if (nors) {
- normal_float_to_short_v3(f_no_s, nors[i]);
- }
- else {
- float f_no[3];
- BKE_mesh_calc_poly_normal(mpoly, &mloop[mpoly->loopstart], mvert, f_no);
- normal_float_to_short_v3(f_no_s, f_no);
- }
-
- for (j = 0; j < mpoly->totloop; j++, start += 4) {
- copy_v3_v3_short(&varray[start], f_no_s);
- }
- }
- }
-}
-
-static void cdDM_buffer_copy_uv(
- DerivedMesh *dm, float *varray)
-{
- int i, j, totpoly;
- int start;
-
- const MPoly *mpoly;
- const MLoopUV *mloopuv;
-
- if ((mloopuv = DM_get_loop_data_layer(dm, CD_MLOOPUV)) == NULL) {
- return;
- }
-
- mpoly = dm->getPolyArray(dm);
- totpoly = dm->getNumPolys(dm);
-
- start = 0;
- for (i = 0; i < totpoly; i++, mpoly++) {
- for (j = 0; j < mpoly->totloop; j++) {
- copy_v2_v2(&varray[start], mloopuv[mpoly->loopstart + j].uv);
- start += 2;
- }
- }
-}
-
-static void cdDM_buffer_copy_uv_texpaint(
- DerivedMesh *dm, float *varray)
-{
- int i, j, totpoly;
- int start;
-
- const MPoly *mpoly;
-
- int totmaterial = dm->totmat;
- const MLoopUV **uv_base;
- const MLoopUV *uv_stencil_base;
- int stencil;
-
- totpoly = dm->getNumPolys(dm);
-
- /* should have been checked for before, reassert */
- BLI_assert(DM_get_loop_data_layer(dm, CD_MLOOPUV));
- uv_base = MEM_malloc_arrayN(totmaterial, sizeof(*uv_base), "texslots");
-
- for (i = 0; i < totmaterial; i++) {
- uv_base[i] = DM_paint_uvlayer_active_get(dm, i);
- }
-
- stencil = CustomData_get_stencil_layer(&dm->loopData, CD_MLOOPUV);
- uv_stencil_base = CustomData_get_layer_n(&dm->loopData, CD_MLOOPUV, stencil);
-
- mpoly = dm->getPolyArray(dm);
- start = 0;
-
- for (i = 0; i < totpoly; i++, mpoly++) {
- int mat_i = mpoly->mat_nr;
-
- for (j = 0; j < mpoly->totloop; j++) {
- copy_v2_v2(&varray[start], uv_base[mat_i][mpoly->loopstart + j].uv);
- copy_v2_v2(&varray[start + 2], uv_stencil_base[mpoly->loopstart + j].uv);
- start += 4;
- }
- }
-
- MEM_freeN((void *)uv_base);
-}
-
-/* treat varray_ as an array of MCol, four MCol's per face */
-static void cdDM_buffer_copy_mcol(
- DerivedMesh *dm, unsigned char *varray,
- const void *user_data)
-{
- int i, j, totpoly;
- int start;
-
- const MLoopCol *mloopcol = user_data;
- const MPoly *mpoly = dm->getPolyArray(dm);
-
- totpoly = dm->getNumPolys(dm);
-
- start = 0;
-
- for (i = 0; i < totpoly; i++, mpoly++) {
- for (j = 0; j < mpoly->totloop; j++) {
- copy_v4_v4_uchar(&varray[start], &mloopcol[mpoly->loopstart + j].r);
- start += 4;
- }
- }
-}
-
-static void cdDM_buffer_copy_edge(
- DerivedMesh *dm, unsigned int *varray)
-{
- MEdge *medge, *medge_base;
- int i, totedge, iloose, inorm, iloosehidden, inormhidden;
- int tot_loose_hidden = 0, tot_loose = 0;
- int tot_hidden = 0, tot = 0;
-
- medge_base = medge = dm->getEdgeArray(dm);
- totedge = dm->getNumEdges(dm);
-
- for (i = 0; i < totedge; i++, medge++) {
- if (medge->flag & ME_EDGEDRAW) {
- if (medge->flag & ME_LOOSEEDGE) tot_loose++;
- else tot++;
- }
- else {
- if (medge->flag & ME_LOOSEEDGE) tot_loose_hidden++;
- else tot_hidden++;
- }
- }
-
- inorm = 0;
- inormhidden = tot;
- iloose = tot + tot_hidden;
- iloosehidden = iloose + tot_loose;
-
- medge = medge_base;
- for (i = 0; i < totedge; i++, medge++) {
- if (medge->flag & ME_EDGEDRAW) {
- if (medge->flag & ME_LOOSEEDGE) {
- varray[iloose * 2] = dm->drawObject->vert_points[medge->v1].point_index;
- varray[iloose * 2 + 1] = dm->drawObject->vert_points[medge->v2].point_index;
- iloose++;
- }
- else {
- varray[inorm * 2] = dm->drawObject->vert_points[medge->v1].point_index;
- varray[inorm * 2 + 1] = dm->drawObject->vert_points[medge->v2].point_index;
- inorm++;
- }
- }
- else {
- if (medge->flag & ME_LOOSEEDGE) {
- varray[iloosehidden * 2] = dm->drawObject->vert_points[medge->v1].point_index;
- varray[iloosehidden * 2 + 1] = dm->drawObject->vert_points[medge->v2].point_index;
- iloosehidden++;
- }
- else {
- varray[inormhidden * 2] = dm->drawObject->vert_points[medge->v1].point_index;
- varray[inormhidden * 2 + 1] = dm->drawObject->vert_points[medge->v2].point_index;
- inormhidden++;
- }
- }
- }
-
- dm->drawObject->tot_loose_edge_drawn = tot_loose;
- dm->drawObject->loose_edge_offset = tot + tot_hidden;
- dm->drawObject->tot_edge_drawn = tot;
-}
-
-static void cdDM_buffer_copy_uvedge(
- DerivedMesh *dm, float *varray)
-{
- int i, j, totpoly;
- int start;
- const MLoopUV *mloopuv;
- const MPoly *mpoly = dm->getPolyArray(dm);
-
- if ((mloopuv = DM_get_loop_data_layer(dm, CD_MLOOPUV)) == NULL) {
- return;
- }
-
- totpoly = dm->getNumPolys(dm);
- start = 0;
-
- for (i = 0; i < totpoly; i++, mpoly++) {
- for (j = 0; j < mpoly->totloop; j++) {
- copy_v2_v2(&varray[start], mloopuv[mpoly->loopstart + j].uv);
- copy_v2_v2(&varray[start + 2], mloopuv[mpoly->loopstart + (j + 1) % mpoly->totloop].uv);
- start += 4;
- }
- }
-}
-
-static void cdDM_copy_gpu_data(
- DerivedMesh *dm, int type, void *varray_p,
- const int *mat_orig_to_new, const void *user_data)
-{
- /* 'varray_p' cast is redundant but include for self-documentation */
- switch (type) {
- case GPU_BUFFER_VERTEX:
- cdDM_buffer_copy_vertex(dm, (float *)varray_p);
- break;
- case GPU_BUFFER_NORMAL:
- cdDM_buffer_copy_normal(dm, (short *)varray_p);
- break;
- case GPU_BUFFER_COLOR:
- cdDM_buffer_copy_mcol(dm, (unsigned char *)varray_p, user_data);
- break;
- case GPU_BUFFER_UV:
- cdDM_buffer_copy_uv(dm, (float *)varray_p);
- break;
- case GPU_BUFFER_UV_TEXPAINT:
- cdDM_buffer_copy_uv_texpaint(dm, (float *)varray_p);
- break;
- case GPU_BUFFER_EDGE:
- cdDM_buffer_copy_edge(dm, (unsigned int *)varray_p);
- break;
- case GPU_BUFFER_UVEDGE:
- cdDM_buffer_copy_uvedge(dm, (float *)varray_p);
- break;
- case GPU_BUFFER_TRIANGLES:
- cdDM_buffer_copy_triangles(dm, (unsigned int *)varray_p, mat_orig_to_new);
- break;
- default:
- break;
- }
-}
-
-/* add a new point to the list of points related to a particular
- * vertex */
-#ifdef USE_GPU_POINT_LINK
-
-static void cdDM_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, int point_index)
-{
- GPUVertPointLink *lnk;
-
- lnk = &gdo->vert_points[vert_index];
-
- /* if first link is in use, add a new link at the end */
- if (lnk->point_index != -1) {
- /* get last link */
- for (; lnk->next; lnk = lnk->next) ;
-
- /* add a new link from the pool */
- lnk = lnk->next = &gdo->vert_points_mem[gdo->vert_points_usage];
- gdo->vert_points_usage++;
- }
-
- lnk->point_index = point_index;
-}
-
-#else
-
-static void cdDM_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, int point_index)
-{
- GPUVertPointLink *lnk;
- lnk = &gdo->vert_points[vert_index];
- if (lnk->point_index == -1) {
- lnk->point_index = point_index;
- }
-}
-
-#endif /* USE_GPU_POINT_LINK */
-
-/* for each vertex, build a list of points related to it; these lists
- * are stored in an array sized to the number of vertices */
-static void cdDM_drawobject_init_vert_points(
- GPUDrawObject *gdo,
- const MPoly *mpoly, const MLoop *mloop,
- int tot_poly)
-{
- int i;
- int tot_loops = 0;
-
- /* allocate the array and space for links */
- gdo->vert_points = MEM_malloc_arrayN(gdo->totvert, sizeof(GPUVertPointLink),
- "GPUDrawObject.vert_points");
-#ifdef USE_GPU_POINT_LINK
- gdo->vert_points_mem = MEM_calloc_arrayN(gdo->totvert, sizeof(GPUVertPointLink),
- "GPUDrawObject.vert_points_mem");
- gdo->vert_points_usage = 0;
-#endif
-
- /* -1 indicates the link is not yet used */
- for (i = 0; i < gdo->totvert; i++) {
-#ifdef USE_GPU_POINT_LINK
- gdo->vert_points[i].link = NULL;
-#endif
- gdo->vert_points[i].point_index = -1;
- }
-
- for (i = 0; i < tot_poly; i++) {
- int j;
- const MPoly *mp = &mpoly[i];
-
- /* assign unique indices to vertices of the mesh */
- for (j = 0; j < mp->totloop; j++) {
- cdDM_drawobject_add_vert_point(gdo, mloop[mp->loopstart + j].v, tot_loops + j);
- }
- tot_loops += mp->totloop;
- }
-
- /* map any unused vertices to loose points */
- for (i = 0; i < gdo->totvert; i++) {
- if (gdo->vert_points[i].point_index == -1) {
- gdo->vert_points[i].point_index = gdo->tot_loop_verts + gdo->tot_loose_point;
- gdo->tot_loose_point++;
- }
- }
-}
-
-/* see GPUDrawObject's structure definition for a description of the
- * data being initialized here */
-static GPUDrawObject *cdDM_GPUobject_new(DerivedMesh *dm)
-{
- GPUDrawObject *gdo;
- const MPoly *mpoly;
- const MLoop *mloop;
- const short dm_totmat = dm->totmat;
- GPUBufferMaterial *mat_info;
- int i, totloops, totpolys;
-
- /* object contains at least one material (default included) so zero means uninitialized dm */
- BLI_assert(dm_totmat != 0);
-
- mpoly = dm->getPolyArray(dm);
- mloop = dm->getLoopArray(dm);
-
- totpolys = dm->getNumPolys(dm);
- totloops = dm->getNumLoops(dm);
-
- /* get the number of points used by each material, treating
- * each quad as two triangles */
- mat_info = MEM_calloc_arrayN(dm_totmat, sizeof(*mat_info), "GPU_drawobject_new.mat_orig_to_new");
-
- for (i = 0; i < totpolys; i++) {
- const short mat_nr = ME_MAT_NR_TEST(mpoly[i].mat_nr, dm_totmat);
- mat_info[mat_nr].totpolys++;
- mat_info[mat_nr].totelements += 3 * ME_POLY_TRI_TOT(&mpoly[i]);
- mat_info[mat_nr].totloops += mpoly[i].totloop;
- }
- /* create the GPUDrawObject */
- gdo = MEM_callocN(sizeof(GPUDrawObject), "GPUDrawObject");
- gdo->totvert = dm->getNumVerts(dm);
- gdo->totedge = dm->getNumEdges(dm);
-
- GPU_buffer_material_finalize(gdo, mat_info, dm_totmat);
-
- gdo->tot_loop_verts = totloops;
-
- /* store total number of points used for triangles */
- gdo->tot_triangle_point = poly_to_tri_count(totpolys, totloops) * 3;
-
- cdDM_drawobject_init_vert_points(gdo, mpoly, mloop, totpolys);
-
- return gdo;
-}
-
static void cdDM_foreachMappedVert(
DerivedMesh *dm,
void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]),
@@ -1885,21 +555,6 @@ static CDDerivedMesh *cdDM_create(const char *desc)
dm->getPBVH = cdDM_getPBVH;
dm->getPolyMap = cdDM_getPolyMap;
- dm->drawVerts = cdDM_drawVerts;
-
- dm->drawEdges = cdDM_drawEdges;
- dm->drawLooseEdges = cdDM_drawLooseEdges;
- dm->drawMappedEdges = cdDM_drawMappedEdges;
-
- dm->drawFacesSolid = cdDM_drawFacesSolid;
- dm->drawFacesGLSL = cdDM_drawFacesGLSL;
- dm->drawMappedFaces = cdDM_drawMappedFaces;
- dm->drawMappedFacesGLSL = cdDM_drawMappedFacesGLSL;
- dm->drawMappedFacesMat = cdDM_drawMappedFacesMat;
-
- dm->gpuObjectNew = cdDM_GPUobject_new;
- dm->copy_gpu_data = cdDM_copy_gpu_data;
-
dm->foreachMappedVert = cdDM_foreachMappedVert;
dm->foreachMappedEdge = cdDM_foreachMappedEdge;
dm->foreachMappedLoop = cdDM_foreachMappedLoop;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 339dcc4a62e..976b8965fa2 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -347,7 +347,7 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
return 1;
}
-static int do_step_cloth(const struct EvaluationContext *eval_ctx, Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
+static int do_step_cloth(struct Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
{
ClothVertex *verts = NULL;
Cloth *cloth;
@@ -372,7 +372,7 @@ static int do_step_cloth(const struct EvaluationContext *eval_ctx, Object *ob, C
mul_m4_v3(ob->obmat, verts->xconst);
}
- effectors = pdInitEffectors(eval_ctx, clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true);
+ effectors = pdInitEffectors(depsgraph, clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true);
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH )
cloth_update_verts ( ob, clmd, result );
@@ -402,7 +402,7 @@ static int do_step_cloth(const struct EvaluationContext *eval_ctx, Object *ob, C
/************************************************
* clothModifier_do - main simulation function
************************************************/
-void clothModifier_do(ClothModifierData *clmd, const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3])
+void clothModifier_do(ClothModifierData *clmd, struct Depsgraph *depsgraph, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3])
{
PointCache *cache;
PTCacheID pid;
@@ -458,7 +458,8 @@ void clothModifier_do(ClothModifierData *clmd, const struct EvaluationContext *e
cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, can_simulate);
if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED ||
- (!can_simulate && cache_result == PTCACHE_READ_OLD)) {
+ (!can_simulate && cache_result == PTCACHE_READ_OLD))
+ {
BKE_cloth_solver_set_positions(clmd);
cloth_to_object (ob, clmd, vertexCos);
@@ -489,7 +490,7 @@ void clothModifier_do(ClothModifierData *clmd, const struct EvaluationContext *e
/* do simulation */
BKE_ptcache_validate(cache, framenr);
- if (!do_step_cloth(eval_ctx, ob, clmd, dm, framenr)) {
+ if (!do_step_cloth(depsgraph, ob, clmd, dm, framenr)) {
BKE_ptcache_invalidate(cache);
}
else
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index b070ccdd4eb..b58028b4a5d 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -684,7 +684,7 @@ static bConstraintTypeInfo CTI_CONSTRNAME = {
/* This function should be used for the get_target_matrix member of all
* constraints that are not picky about what happens to their target matrix.
*/
-static void default_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
+static void default_get_tarmat(struct Depsgraph *UNUSED(depsgraph), bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
{
if (VALID_CONS_TARGET(ct))
constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->flag, con->headtail);
@@ -1153,7 +1153,7 @@ static void kinematic_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
}
}
-static void kinematic_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void kinematic_get_tarmat(struct Depsgraph *UNUSED(depsgraph), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
bKinematicConstraint *data = con->data;
@@ -1240,7 +1240,7 @@ static void followpath_flush_tars(bConstraint *con, ListBase *list, bool no_copy
}
}
-static void followpath_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx),
+static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
bConstraint *con, bConstraintOb *UNUSED(cob),
bConstraintTarget *ct, float UNUSED(ctime))
{
@@ -2019,7 +2019,7 @@ static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userd
}
/* Whether this approach is maintained remains to be seen (aligorith) */
-static void pycon_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx),
+static void pycon_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
bConstraint *con, bConstraintOb *UNUSED(cob),
bConstraintTarget *ct, float UNUSED(ctime))
{
@@ -2135,7 +2135,7 @@ static void actcon_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
}
}
-static void actcon_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void actcon_get_tarmat(struct Depsgraph *UNUSED(depsgraph), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
bActionConstraint *data = con->data;
@@ -2630,7 +2630,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* if soft-distance is enabled, start fading once owner is dist+softdist from the target */
else if (data->flag & LIMITDIST_USESOFT) {
if (dist <= (data->dist + data->soft)) {
-
+ /* pass */
}
}
}
@@ -3028,66 +3028,6 @@ static bConstraintTypeInfo CTI_MINMAX = {
minmax_evaluate /* evaluate */
};
-/* ------- RigidBody Joint ---------- */
-
-static void rbj_new_data(void *cdata)
-{
- bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)cdata;
-
- /* removed code which set target of this constraint */
- data->type = 1;
-}
-
-static void rbj_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
-{
- bRigidBodyJointConstraint *data = con->data;
-
- /* target only */
- func(con, (ID **)&data->tar, false, userdata);
- func(con, (ID **)&data->child, false, userdata);
-}
-
-static int rbj_get_tars(bConstraint *con, ListBase *list)
-{
- if (con && list) {
- bRigidBodyJointConstraint *data = con->data;
- bConstraintTarget *ct;
-
- /* standard target-getting macro for single-target constraints without subtargets */
- SINGLETARGETNS_GET_TARS(con, data->tar, ct, list);
-
- return 1;
- }
-
- return 0;
-}
-
-static void rbj_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
-{
- if (con && list) {
- bRigidBodyJointConstraint *data = con->data;
- bConstraintTarget *ct = list->first;
-
- /* the following macro is used for all standard single-target constraints */
- SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, no_copy);
- }
-}
-
-static bConstraintTypeInfo CTI_RIGIDBODYJOINT = {
- CONSTRAINT_TYPE_RIGIDBODYJOINT, /* type */
- sizeof(bRigidBodyJointConstraint), /* size */
- "Rigid Body Joint", /* name */
- "bRigidBodyJointConstraint", /* struct name */
- NULL, /* free data */
- rbj_id_looper, /* id looper */
- NULL, /* copy data */
- rbj_new_data, /* new data */
- rbj_get_tars, /* get constraint targets */
- rbj_flush_tars, /* flush constraint targets */
- default_get_tarmat, /* get target matrix */
- NULL /* evaluate - this is not solved here... is just an interface for game-engine */
-};
-
/* -------- Clamp To ---------- */
static void clampto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
@@ -3124,7 +3064,7 @@ static void clampto_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
}
}
-static void clampto_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx),
+static void clampto_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
bConstraint *UNUSED(con), bConstraintOb *UNUSED(cob),
bConstraintTarget *ct, float UNUSED(ctime))
{
@@ -3461,7 +3401,7 @@ static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, bool no_copy
}
-static void shrinkwrap_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void shrinkwrap_get_tarmat(struct Depsgraph *UNUSED(depsgraph), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
@@ -3793,7 +3733,7 @@ static void splineik_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
}
}
-static void splineik_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx),
+static void splineik_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
bConstraint *UNUSED(con), bConstraintOb *UNUSED(cob),
bConstraintTarget *ct, float UNUSED(ctime))
{
@@ -4438,7 +4378,7 @@ static void constraints_init_typeinfo(void)
constraintsTypeInfo[14] = &CTI_DISTLIMIT; /* Limit Distance Constraint */
constraintsTypeInfo[15] = &CTI_STRETCHTO; /* StretchTo Constaint */
constraintsTypeInfo[16] = &CTI_MINMAX; /* Floor Constraint */
- constraintsTypeInfo[17] = &CTI_RIGIDBODYJOINT; /* RigidBody Constraint */
+ /* constraintsTypeInfo[17] = &CTI_RIGIDBODYJOINT; */ /* RigidBody Constraint - Deprecated */
constraintsTypeInfo[18] = &CTI_CLAMPTO; /* ClampTo Constraint */
constraintsTypeInfo[19] = &CTI_TRANSFORM; /* Transformation Constraint */
constraintsTypeInfo[20] = &CTI_SHRINKWRAP; /* Shrinkwrap Constraint */
@@ -4845,7 +4785,7 @@ bool BKE_constraints_proxylocked_owner(Object *ob, bPoseChannel *pchan)
* None of the actual calculations of the matrices should be done here! Also, this function is
* not to be used by any new constraints, particularly any that have multiple targets.
*/
-void BKE_constraint_target_matrix_get(const struct EvaluationContext *eval_ctx, Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
+void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph, Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
{
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
@@ -4896,7 +4836,7 @@ void BKE_constraint_target_matrix_get(const struct EvaluationContext *eval_ctx,
if (ct) {
if (cti->get_target_matrix)
- cti->get_target_matrix(eval_ctx, con, cob, ct, ctime);
+ cti->get_target_matrix(depsgraph, con, cob, ct, ctime);
copy_m4_m4(mat, ct->matrix);
}
@@ -4912,7 +4852,7 @@ void BKE_constraint_target_matrix_get(const struct EvaluationContext *eval_ctx,
}
/* Get the list of targets required for solving a constraint */
-void BKE_constraint_targets_for_solving_get(const struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
+void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph, bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
{
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
@@ -4930,7 +4870,7 @@ void BKE_constraint_targets_for_solving_get(const struct EvaluationContext *eval
*/
if (cti->get_target_matrix) {
for (ct = targets->first; ct; ct = ct->next)
- cti->get_target_matrix(eval_ctx, con, cob, ct, ctime);
+ cti->get_target_matrix(depsgraph, con, cob, ct, ctime);
}
else {
for (ct = targets->first; ct; ct = ct->next)
@@ -4947,7 +4887,7 @@ void BKE_constraint_targets_for_solving_get(const struct EvaluationContext *eval
* BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and
* after running this function, to sort out cob
*/
-void BKE_constraints_solve(const struct EvaluationContext *eval_ctx, ListBase *conlist, bConstraintOb *cob, float ctime)
+void BKE_constraints_solve(struct Depsgraph *depsgraph, ListBase *conlist, bConstraintOb *cob, float ctime)
{
bConstraint *con;
float oldmat[4][4];
@@ -4982,7 +4922,7 @@ void BKE_constraints_solve(const struct EvaluationContext *eval_ctx, ListBase *c
BKE_constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace, false);
/* prepare targets for constraint solving */
- BKE_constraint_targets_for_solving_get(eval_ctx, con, cob, &targets, ctime);
+ BKE_constraint_targets_for_solving_get(depsgraph, con, cob, &targets, ctime);
/* Solve the constraint and put result in cob->matrix */
cti->evaluate_constraint(con, cob, &targets);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 809db09eb86..385e7014903 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -775,14 +775,6 @@ struct SpaceNla *CTX_wm_space_nla(const bContext *C)
return NULL;
}
-struct SpaceTime *CTX_wm_space_time(const bContext *C)
-{
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_TIME)
- return sa->spacedata.first;
- return NULL;
-}
-
struct SpaceNode *CTX_wm_space_node(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
@@ -791,14 +783,6 @@ struct SpaceNode *CTX_wm_space_node(const bContext *C)
return NULL;
}
-struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
-{
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_LOGIC)
- return sa->spacedata.first;
- return NULL;
-}
-
struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
@@ -839,6 +823,14 @@ struct SpaceClip *CTX_wm_space_clip(const bContext *C)
return NULL;
}
+struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ if (sa && sa->spacetype == SPACE_TOPBAR)
+ return sa->spacedata.first;
+ return NULL;
+}
+
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
{
C->wm.manager = wm;
@@ -938,24 +930,10 @@ ViewLayer *CTX_data_view_layer(const bContext *C)
}
}
-ViewRender *CTX_data_view_render(const bContext *C)
-{
- ViewRender *view_render;
-
- if (ctx_data_pointer_verify(C, "view_render", (void *)&view_render)) {
- return view_render;
- }
- else {
- Scene *scene = CTX_data_scene(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
- return BKE_viewrender_get(scene, workspace);
- }
-}
-
RenderEngineType *CTX_data_engine_type(const bContext *C)
{
- ViewRender *view_render = CTX_data_view_render(C);
- return RE_engines_find(view_render->engine_id);
+ Scene *scene = CTX_data_scene(C);
+ return RE_engines_find(scene->r.engine);
}
/**
@@ -1269,15 +1247,3 @@ Depsgraph *CTX_data_depsgraph(const bContext *C)
ViewLayer *view_layer = CTX_data_view_layer(C);
return BKE_scene_get_depsgraph(scene, view_layer, true);
}
-
-void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx)
-{
- BLI_assert(C != NULL);
-
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- DEG_evaluation_context_init_from_scene(
- eval_ctx,
- scene, view_layer,
- DAG_EVAL_VIEWPORT);
-}
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index d2ffbbcf27b..f5795444b7d 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -100,7 +100,7 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
/* disable subsurf temporal, get mapped cos, and enable it */
float (*BKE_crazyspace_get_mapped_editverts(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit))[3]
+ struct Depsgraph *depsgraph, Scene *scene, Object *obedit))[3]
{
Mesh *me = obedit->data;
DerivedMesh *dm;
@@ -110,13 +110,13 @@ float (*BKE_crazyspace_get_mapped_editverts(
/* disable subsurf temporal, get mapped cos, and enable it */
if (modifiers_disable_subsurf_temporary(obedit)) {
/* need to make new derivemesh */
- makeDerivedMesh(eval_ctx, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, false);
+ makeDerivedMesh(depsgraph, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, false);
}
/* now get the cage */
vertexcos = MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map");
- dm = editbmesh_get_derived_cage(eval_ctx, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
+ dm = editbmesh_get_derived_cage(depsgraph, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
mesh_get_mapped_verts_coords(dm, vertexcos, nverts);
@@ -252,7 +252,7 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me, float (*origcos)[3], float (*mapped
/** returns an array of deform matrices for crazyspace correction, and the
* number of modifiers left */
int BKE_crazyspace_get_first_deform_matrices_editbmesh(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BMEditMesh *em,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, BMEditMesh *em,
float (**deformmats)[3][3], float (**deformcos)[3])
{
ModifierData *md;
@@ -292,7 +292,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
unit_m3(defmats[a]);
}
- mti->deformMatricesEM(md, eval_ctx, ob, em, dm, deformedVerts, defmats,
+ mti->deformMatricesEM(md, depsgraph, ob, em, dm, deformedVerts, defmats,
numVerts);
}
else
@@ -313,7 +313,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
}
int BKE_sculpt_get_first_deform_matrices(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
{
ModifierData *md;
@@ -350,7 +350,7 @@ int BKE_sculpt_get_first_deform_matrices(
unit_m3(defmats[a]);
}
- if (mti->deformMatrices) mti->deformMatrices(md, eval_ctx, ob, dm, deformedVerts, defmats, numVerts);
+ if (mti->deformMatrices) mti->deformMatrices(md, depsgraph, ob, dm, deformedVerts, defmats, numVerts);
else break;
}
}
@@ -373,9 +373,9 @@ int BKE_sculpt_get_first_deform_matrices(
return numleft;
}
-void BKE_crazyspace_build_sculpt(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
{
- int totleft = BKE_sculpt_get_first_deform_matrices(eval_ctx, scene, ob, deformmats, deformcos);
+ int totleft = BKE_sculpt_get_first_deform_matrices(depsgraph, scene, ob, deformmats, deformcos);
if (totleft) {
/* there are deformation modifier which doesn't support deformation matrices
@@ -400,7 +400,7 @@ void BKE_crazyspace_build_sculpt(const struct EvaluationContext *eval_ctx, Scene
if (mti->deformMatrices && !deformed)
continue;
- mti->deformVerts(md, eval_ctx, ob, NULL, deformedVerts, me->totvert, 0);
+ mti->deformVerts(md, depsgraph, ob, NULL, deformedVerts, me->totvert, 0);
deformed = 1;
}
}
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 0c4dbdf7763..661ffdbcd27 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -1624,7 +1624,7 @@ float *BKE_curve_surf_make_orco(Object *ob)
/* NOTE: This routine is tied to the order of vertex
* built by displist and as passed to the renderer.
*/
-float *BKE_curve_make_orco(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, int *r_numVerts)
+float *BKE_curve_make_orco(Depsgraph *depsgraph, Scene *scene, Object *ob, int *r_numVerts)
{
Curve *cu = ob->data;
DispList *dl;
@@ -1632,7 +1632,7 @@ float *BKE_curve_make_orco(const EvaluationContext *eval_ctx, Scene *scene, Obje
float *fp, *coord_array;
ListBase disp = {NULL, NULL};
- BKE_displist_make_curveTypes_forOrco(eval_ctx, scene, ob, &disp);
+ BKE_displist_make_curveTypes_forOrco(depsgraph, scene, ob, &disp);
numVerts = 0;
for (dl = disp.first; dl; dl = dl->next) {
@@ -1724,7 +1724,7 @@ float *BKE_curve_make_orco(const EvaluationContext *eval_ctx, Scene *scene, Obje
/* ***************** BEVEL ****************** */
void BKE_curve_bevel_make(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *disp,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *disp,
const bool for_render, const bool use_render_resolution)
{
DispList *dl, *dlnew;
@@ -1749,7 +1749,7 @@ void BKE_curve_bevel_make(
facy = cu->bevobj->size[1];
if (for_render) {
- BKE_displist_make_curveTypes_forRender(eval_ctx, scene, cu->bevobj, &bevdisp, NULL, false, use_render_resolution);
+ BKE_displist_make_curveTypes_forRender(depsgraph, scene, cu->bevobj, &bevdisp, NULL, false, use_render_resolution);
dl = bevdisp.first;
}
else if (cu->bevobj->curve_cache) {
@@ -5255,7 +5255,7 @@ void BKE_curve_rect_from_textbox(const struct Curve *cu, const struct TextBox *t
/* **** Depsgraph evaluation **** */
-void BKE_curve_eval_geometry(const EvaluationContext *UNUSED(eval_ctx),
+void BKE_curve_eval_geometry(Depsgraph *UNUSED(depsgraph),
Curve *curve)
{
DEG_debug_print_eval(__func__, curve->id.name, curve);
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 00b8063110d..0451031c5b8 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -107,7 +107,7 @@ bool BKE_object_data_transfer_get_dttypes_capacity(
}
switch (dtdata_type) {
- /* Vertex data */
+ /* Vertex data */
case DT_TYPE_MDEFORMVERT:
*r_advanced_mixing = true;
*r_threshold = true;
@@ -120,7 +120,7 @@ bool BKE_object_data_transfer_get_dttypes_capacity(
case DT_TYPE_BWEIGHT_VERT:
ret = true;
break;
- /* Edge data */
+ /* Edge data */
case DT_TYPE_SHARP_EDGE:
*r_threshold = true;
ret = true;
@@ -139,7 +139,7 @@ bool BKE_object_data_transfer_get_dttypes_capacity(
*r_threshold = true;
ret = true;
break;
- /* Loop/Poly data */
+ /* Loop/Poly data */
case DT_TYPE_UV:
ret = true;
break;
@@ -1010,7 +1010,7 @@ static bool data_transfer_layersmapping_generate(
* to get (as much as possible) exact copy of source data layout.
*/
void BKE_object_data_transfer_layout(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX])
{
@@ -1028,7 +1028,7 @@ void BKE_object_data_transfer_layout(
/* Get source DM.*/
dm_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types);
- dm_src = mesh_get_derived_final(eval_ctx, scene, ob_src, dm_src_mask);
+ dm_src = mesh_get_derived_final(depsgraph, scene, ob_src, dm_src_mask);
if (!dm_src) {
return;
}
@@ -1086,7 +1086,7 @@ void BKE_object_data_transfer_layout(
}
bool BKE_object_data_transfer_dm(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst,
const int data_types, bool use_create, const int map_vert_mode, const int map_edge_mode,
const int map_loop_mode, const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform,
const float max_distance, const float ray_radius, const float islands_handling_precision,
@@ -1150,7 +1150,7 @@ bool BKE_object_data_transfer_dm(
* Also, we need to make a local copy of dm_src, otherwise we may end with concurrent creation
* of data in it (multi-threaded evaluation of the modifier stack, see T46672).
*/
- dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(eval_ctx, scene, ob_src, dm_src_mask);
+ dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(depsgraph, scene, ob_src, dm_src_mask);
if (!dm_src) {
return changed;
}
@@ -1458,7 +1458,7 @@ bool BKE_object_data_transfer_dm(
}
bool BKE_object_data_transfer_mesh(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, const int data_types,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, Object *ob_dst, const int data_types,
const bool use_create, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode,
const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform,
const float max_distance, const float ray_radius, const float islands_handling_precision,
@@ -1467,7 +1467,7 @@ bool BKE_object_data_transfer_mesh(
ReportList *reports)
{
return BKE_object_data_transfer_dm(
- eval_ctx, scene, ob_src, ob_dst, NULL, data_types, use_create,
+ depsgraph, scene, ob_src, ob_dst, NULL, data_types, use_create,
map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode,
space_transform, auto_transform,
max_distance, ray_radius, islands_handling_precision,
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index ffa4e652056..e74e540fab9 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -681,7 +681,7 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis
* - first point left, last point right
* - based on subdivided points in original curve, not on points in taper curve (still)
*/
-static float displist_calc_taper(const EvaluationContext *eval_ctx, Scene *scene, Object *taperobj, float fac)
+static float displist_calc_taper(Depsgraph *depsgraph, Scene *scene, Object *taperobj, float fac)
{
DispList *dl;
@@ -690,7 +690,7 @@ static float displist_calc_taper(const EvaluationContext *eval_ctx, Scene *scene
dl = taperobj->curve_cache ? taperobj->curve_cache->disp.first : NULL;
if (dl == NULL) {
- BKE_displist_make_curveTypes(eval_ctx, scene, taperobj, 0);
+ BKE_displist_make_curveTypes(depsgraph, scene, taperobj, 0);
dl = taperobj->curve_cache->disp.first;
}
if (dl) {
@@ -721,14 +721,14 @@ static float displist_calc_taper(const EvaluationContext *eval_ctx, Scene *scene
return 1.0;
}
-float BKE_displist_calc_taper(const EvaluationContext *eval_ctx, Scene *scene, Object *taperobj, int cur, int tot)
+float BKE_displist_calc_taper(Depsgraph *depsgraph, Scene *scene, Object *taperobj, int cur, int tot)
{
float fac = ((float)cur) / (float)(tot - 1);
- return displist_calc_taper(eval_ctx, scene, taperobj, fac);
+ return displist_calc_taper(depsgraph, scene, taperobj, fac);
}
-void BKE_displist_make_mball(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void BKE_displist_make_mball(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
if (!ob || ob->type != OB_MBALL)
return;
@@ -741,7 +741,7 @@ void BKE_displist_make_mball(const EvaluationContext *eval_ctx, Scene *scene, Ob
ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for MBall");
}
- BKE_mball_polygonize(eval_ctx, scene, ob, &ob->curve_cache->disp);
+ BKE_mball_polygonize(depsgraph, scene, ob, &ob->curve_cache->disp);
BKE_mball_texspace_calc(ob);
object_deform_mball(ob, &ob->curve_cache->disp);
@@ -751,9 +751,9 @@ void BKE_displist_make_mball(const EvaluationContext *eval_ctx, Scene *scene, Ob
}
}
-void BKE_displist_make_mball_forRender(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
+void BKE_displist_make_mball_forRender(Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase)
{
- BKE_mball_polygonize(eval_ctx, scene, ob, dispbase);
+ BKE_mball_polygonize(depsgraph, scene, ob, dispbase);
BKE_mball_texspace_calc(ob);
object_deform_mball(ob, dispbase);
@@ -802,7 +802,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob,
}
static void curve_calc_modifiers_pre(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *nurb,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *nurb,
const bool for_render, const bool use_render_resolution)
{
VirtualModifierData virtualModifierData;
@@ -860,7 +860,7 @@ static void curve_calc_modifiers_pre(
deformedVerts = BKE_curve_nurbs_vertexCos_get(nurb, &numVerts);
}
- mti->deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, app_flag);
+ mti->deformVerts(md, depsgraph, ob, NULL, deformedVerts, numVerts, app_flag);
if (md == pretessellatePoint)
break;
@@ -913,7 +913,7 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3])
}
static void curve_calc_modifiers_post(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *nurb,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *nurb,
ListBase *dispbase, DerivedMesh **r_dm_final,
const bool for_render, const bool use_render_resolution)
{
@@ -969,14 +969,14 @@ static void curve_calc_modifiers_post(
dm->getVertCos(dm, vertCos);
}
- mti->deformVerts(md, eval_ctx, ob, dm, vertCos, totvert, appf);
+ mti->deformVerts(md, depsgraph, ob, dm, vertCos, totvert, appf);
}
else {
if (!vertCos) {
vertCos = displist_get_allverts(dispbase, &totvert);
}
- mti->deformVerts(md, eval_ctx, ob, NULL, vertCos, totvert, appf);
+ mti->deformVerts(md, depsgraph, ob, NULL, vertCos, totvert, appf);
}
}
else {
@@ -1018,7 +1018,7 @@ static void curve_calc_modifiers_post(
if (useCache)
appf |= MOD_APPLY_USECACHE;
- ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, appf);
+ ndm = modwrap_applyModifier(md, depsgraph, ob, dm, appf);
if (ndm) {
/* Modifier returned a new derived mesh */
@@ -1095,13 +1095,13 @@ static void displist_surf_indices(DispList *dl)
}
}
-static DerivedMesh *create_orco_dm(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+static DerivedMesh *create_orco_dm(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
DerivedMesh *dm;
ListBase disp = {NULL, NULL};
/* OrcoDM should be created from underformed disp lists */
- BKE_displist_make_curveTypes_forOrco(eval_ctx, scene, ob, &disp);
+ BKE_displist_make_curveTypes_forOrco(depsgraph, scene, ob, &disp);
dm = CDDM_from_curve_displist(ob, &disp);
BKE_displist_free(&disp);
@@ -1140,7 +1140,7 @@ static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
}
static void curve_calc_orcodm(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm_final,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, DerivedMesh *dm_final,
const bool for_render, const bool use_render_resolution)
{
/* this function represents logic of mesh's orcodm calculation
@@ -1178,7 +1178,7 @@ static void curve_calc_orcodm(
* This means we can create ORCO DM in advance and assume it's
* never NULL.
*/
- orcodm = create_orco_dm(eval_ctx, scene, ob);
+ orcodm = create_orco_dm(depsgraph, scene, ob);
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1190,7 +1190,7 @@ static void curve_calc_orcodm(
if (mti->type != eModifierTypeType_Constructive)
continue;
- ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, app_flag);
+ ndm = modwrap_applyModifier(md, depsgraph, ob, orcodm, app_flag);
if (ndm) {
/* if the modifier returned a new dm, release the old one */
@@ -1208,7 +1208,7 @@ static void curve_calc_orcodm(
}
void BKE_displist_make_surf(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
DerivedMesh **r_dm_final,
const bool for_render, const bool for_orco, const bool use_render_resolution)
{
@@ -1227,7 +1227,7 @@ void BKE_displist_make_surf(
}
if (!for_orco)
- curve_calc_modifiers_pre(eval_ctx, scene, ob, &nubase, for_render, use_render_resolution);
+ curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render, use_render_resolution);
for (nu = nubase.first; nu; nu = nu->next) {
if ((for_render || nu->hide == 0) && BKE_nurb_check_valid_uv(nu)) {
@@ -1294,7 +1294,7 @@ void BKE_displist_make_surf(
if (!for_orco) {
BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
- curve_calc_modifiers_post(eval_ctx, scene, ob, &nubase, dispbase, r_dm_final,
+ curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_dm_final,
for_render, use_render_resolution);
}
@@ -1521,7 +1521,7 @@ static void calc_bevfac_mapping(Curve *cu, BevList *bl, Nurb *nu,
}
static void do_makeDispListCurveTypes(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
DerivedMesh **r_dm_final,
const bool for_render, const bool for_orco, const bool use_render_resolution)
{
@@ -1531,7 +1531,7 @@ static void do_makeDispListCurveTypes(
if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
if (ob->type == OB_SURF) {
- BKE_displist_make_surf(eval_ctx, scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution);
+ BKE_displist_make_surf(depsgraph, scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution);
}
else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
ListBase dlbev;
@@ -1556,12 +1556,12 @@ static void do_makeDispListCurveTypes(
}
if (!for_orco)
- curve_calc_modifiers_pre(eval_ctx, scene, ob, &nubase, for_render, use_render_resolution);
+ curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render, use_render_resolution);
BKE_curve_bevelList_make(ob, &nubase, for_render != false);
/* If curve has no bevel will return nothing */
- BKE_curve_bevel_make(eval_ctx, scene, ob, &dlbev, for_render, use_render_resolution);
+ BKE_curve_bevel_make(depsgraph, scene, ob, &dlbev, for_render, use_render_resolution);
/* no bevel or extrude, and no width correction? */
if (!dlbev.first && cu->width == 1.0f) {
@@ -1696,7 +1696,7 @@ static void do_makeDispListCurveTypes(
taper_fac -= (1.0f - lastblend) / len;
}
- fac = displist_calc_taper(eval_ctx, scene, cu->taperobj, taper_fac);
+ fac = displist_calc_taper(depsgraph, scene, cu->taperobj, taper_fac);
}
if (bevp->split_tag) {
@@ -1749,7 +1749,7 @@ static void do_makeDispListCurveTypes(
if (!for_orco) {
if ((cu->flag & CU_PATH) ||
- DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH)
+ DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH)
{
calc_curvepath(ob, &nubase);
}
@@ -1757,7 +1757,7 @@ static void do_makeDispListCurveTypes(
if (!for_orco) {
BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
- curve_calc_modifiers_post(eval_ctx, scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
+ curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
}
if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
@@ -1768,7 +1768,7 @@ static void do_makeDispListCurveTypes(
}
}
-void BKE_displist_make_curveTypes(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, const bool for_orco)
+void BKE_displist_make_curveTypes(Depsgraph *depsgraph, Scene *scene, Object *ob, const bool for_orco)
{
ListBase *dispbase;
@@ -1786,13 +1786,13 @@ void BKE_displist_make_curveTypes(const EvaluationContext *eval_ctx, Scene *scen
dispbase = &(ob->curve_cache->disp);
- do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
+ do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
boundbox_displist_object(ob);
}
void BKE_displist_make_curveTypes_forRender(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
DerivedMesh **r_dm_final, const bool for_orco,
const bool use_render_resolution)
{
@@ -1800,22 +1800,22 @@ void BKE_displist_make_curveTypes_forRender(
ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
}
- do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
+ do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
}
void BKE_displist_make_curveTypes_forOrco(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
+ Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase)
{
if (ob->curve_cache == NULL) {
ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
}
- do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, NULL, 1, 1, 1);
+ do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, NULL, 1, 1, 1);
}
/* add Orco layer to the displist object which has got derived mesh and return orco */
float *BKE_displist_make_orco(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm_final,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, DerivedMesh *dm_final,
const bool for_render,
const bool use_render_resolution)
{
@@ -1825,7 +1825,7 @@ float *BKE_displist_make_orco(
dm_final = ob->derivedFinal;
if (!dm_final->getVertDataArray(dm_final, CD_ORCO)) {
- curve_calc_orcodm(eval_ctx, scene, ob, dm_final, for_render, use_render_resolution);
+ curve_calc_orcodm(depsgraph, scene, ob, dm_final, for_render, use_render_resolution);
}
orco = dm_final->getVertDataArray(dm_final, CD_ORCO);
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index ee678dd4c41..27840af291b 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -75,6 +75,7 @@
#include "BKE_scene.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
/* for image output */
#include "IMB_imbuf_types.h"
@@ -530,11 +531,6 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, const ViewLayer *
return flags;
}
-static int brush_usesMaterial(const DynamicPaintBrushSettings *brush, const Scene *scene)
-{
- return ((brush->flags & MOD_DPAINT_USE_MATERIAL) && (!BKE_scene_use_new_shading_nodes(scene)));
-}
-
/* check whether two bounds intersect */
static bool boundsIntersect(Bounds3D *b1, Bounds3D *b2)
{
@@ -1095,7 +1091,6 @@ bool dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, str
brush->flags = MOD_DPAINT_ABS_ALPHA | MOD_DPAINT_RAMP_ALPHA;
brush->collision = MOD_DPAINT_COL_VOLUME;
- brush->mat = NULL;
brush->r = 0.15f;
brush->g = 0.4f;
brush->b = 0.8f;
@@ -1235,7 +1230,6 @@ void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct Dyn
t_brush->flags = brush->flags;
t_brush->collision = brush->collision;
- t_brush->mat = brush->mat;
t_brush->r = brush->r;
t_brush->g = brush->g;
t_brush->b = brush->b;
@@ -2065,7 +2059,7 @@ static void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMe
* Updates derived mesh copy and processes dynamic paint step / caches.
*/
static void dynamicPaint_frameUpdate(
- DynamicPaintModifierData *pmd, const struct EvaluationContext *eval_ctx, Scene *scene,
+ DynamicPaintModifierData *pmd, struct Depsgraph *depsgraph, Scene *scene,
Object *ob, DerivedMesh *dm)
{
if (pmd->canvas) {
@@ -2129,7 +2123,7 @@ static void dynamicPaint_frameUpdate(
else if (can_simulate) {
/* calculate surface frame */
canvas->flags |= MOD_DPAINT_BAKING;
- dynamicPaint_calculateFrame(surface, eval_ctx, scene, ob, current_frame);
+ dynamicPaint_calculateFrame(surface, depsgraph, scene, ob, current_frame);
canvas->flags &= ~MOD_DPAINT_BAKING;
/* restore canvas derivedmesh if required */
@@ -2149,14 +2143,14 @@ static void dynamicPaint_frameUpdate(
/* Modifier call. Processes dynamic paint modifier step. */
DerivedMesh *dynamicPaint_Modifier_do(
- DynamicPaintModifierData *pmd, const struct EvaluationContext *eval_ctx, Scene *scene,
+ DynamicPaintModifierData *pmd, struct Depsgraph *depsgraph, Scene *scene,
Object *ob, DerivedMesh *dm)
{
if (pmd->canvas) {
DerivedMesh *ret;
/* Update canvas data for a new frame */
- dynamicPaint_frameUpdate(pmd, eval_ctx, scene, ob, dm);
+ dynamicPaint_frameUpdate(pmd, depsgraph, scene, ob, dm);
/* Return output mesh */
ret = dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -2165,7 +2159,7 @@ DerivedMesh *dynamicPaint_Modifier_do(
}
else {
/* Update canvas data for a new frame */
- dynamicPaint_frameUpdate(pmd, eval_ctx, scene, ob, dm);
+ dynamicPaint_frameUpdate(pmd, depsgraph, scene, ob, dm);
/* Return output mesh */
return dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -3335,91 +3329,6 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam
}
-/***************************** Material / Texture Sampling ******************************/
-
-/* stores a copy of required materials to allow doing adjustments
- * without interfering the render/preview */
-typedef struct BrushMaterials {
- Material *mat;
- Material **ob_mats;
- int tot;
-} BrushMaterials;
-
-/* Initialize materials for brush object:
- * Calculates inverse matrices for linked objects, updates
- * volume caches etc. */
-static void dynamicPaint_updateBrushMaterials(const EvaluationContext *eval_ctx, Object *brushOb, Material *ui_mat, Scene *scene, BrushMaterials *bMats)
-{
- /* Calculate inverse transformation matrix
- * for this object */
- invert_m4_m4(brushOb->imat, brushOb->obmat);
- copy_m4_m4(brushOb->imat_ren, brushOb->imat);
-
- /* Now process every material linked to this brush object */
- if ((ui_mat == NULL) && brushOb->mat && brushOb->totcol) {
- int i, tot = (*give_totcolp(brushOb));
-
- /* allocate material pointer array */
- if (tot) {
- bMats->ob_mats = MEM_callocN(sizeof(Material *) * (tot), "BrushMaterials");
- for (i = 0; i < tot; i++) {
- bMats->ob_mats[i] = RE_sample_material_init(eval_ctx, give_current_material(brushOb, (i + 1)), scene);
- }
- }
- bMats->tot = tot;
- }
- else {
- bMats->mat = RE_sample_material_init(eval_ctx, ui_mat, scene);
- }
-}
-
-/* free all data allocated by dynamicPaint_updateBrushMaterials() */
-static void dynamicPaint_freeBrushMaterials(BrushMaterials *bMats)
-{
- /* Now process every material linked to this brush object */
- if (bMats->ob_mats) {
- int i;
- for (i = 0; i < bMats->tot; i++) {
- RE_sample_material_free(bMats->ob_mats[i]);
- }
- MEM_freeN(bMats->ob_mats);
- }
- else if (bMats->mat) {
- RE_sample_material_free(bMats->mat);
- }
-}
-
-/*
- * Get material diffuse color and alpha (including linked textures) in given coordinates
- */
-static void dynamicPaint_doMaterialTex(
- const BrushMaterials *bMats, float color[3], float *alpha, Object *brushOb,
- const float volume_co[3], const float surface_co[3],
- int triIndex, DerivedMesh *orcoDm)
-{
- Material *mat = bMats->mat;
-
- const MLoopTri *mlooptri = orcoDm->getLoopTriArray(orcoDm);
- const MPoly *mpoly = orcoDm->getPolyArray(orcoDm);
-
- /* If no material defined, use the one assigned to the mesh face */
- if (mat == NULL) {
- if (bMats->ob_mats) {
- int mat_nr = mpoly[mlooptri[triIndex].poly].mat_nr;
- if (mat_nr >= (*give_totcolp(brushOb)))
- return;
- mat = bMats->ob_mats[mat_nr];
- if (mat == NULL)
- return; /* No material assigned */
- }
- else {
- return;
- }
- }
- RE_sample_material_color(mat, color, alpha, volume_co, surface_co, triIndex, orcoDm, brushOb);
-}
-
-
/***************************** Ray / Nearest Point Utils ******************************/
@@ -3740,7 +3649,7 @@ static void dynamic_paint_brush_velocity_compute_cb(
}
static void dynamicPaint_brushMeshCalculateVelocity(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
{
float prev_obmat[4][4];
@@ -3763,7 +3672,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
scene->r.subframe = prev_sfra;
BKE_object_modifier_update_subframe(
- eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+ depsgraph, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
dm_p = CDDM_copy(brush->dm);
numOfVerts_p = dm_p->getNumVerts(dm_p);
mvert_p = dm_p->getVertArray(dm_p);
@@ -3774,7 +3683,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
scene->r.subframe = cur_sfra;
BKE_object_modifier_update_subframe(
- eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+ depsgraph, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
dm_c = brush->dm;
numOfVerts_c = dm_c->getNumVerts(dm_c);
mvert_c = dm_p->getVertArray(dm_c);
@@ -3805,7 +3714,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
}
/* calculate velocity for object center point */
-static void dynamicPaint_brushObjectCalculateVelocity(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
+static void dynamicPaint_brushObjectCalculateVelocity(struct Depsgraph *depsgraph, Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
{
float prev_obmat[4][4];
float cur_loc[3] = {0.0f}, prev_loc[3] = {0.0f};
@@ -3824,14 +3733,14 @@ static void dynamicPaint_brushObjectCalculateVelocity(const struct EvaluationCon
scene->r.cfra = prev_fra;
scene->r.subframe = prev_sfra;
BKE_object_modifier_update_subframe(
- eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+ depsgraph, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
copy_m4_m4(prev_obmat, ob->obmat);
/* current frame dm */
scene->r.cfra = cur_fra;
scene->r.subframe = cur_sfra;
BKE_object_modifier_update_subframe(
- eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
+ depsgraph, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
/* calculate speed */
mul_m4_v3(prev_obmat, prev_loc);
@@ -3845,7 +3754,6 @@ typedef struct DynamicPaintPaintData {
const DynamicPaintSurface *surface;
const DynamicPaintBrushSettings *brush;
Object *brushOb;
- const BrushMaterials *bMats;
const Scene *scene;
const float timescale;
const int c_index;
@@ -3882,14 +3790,10 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
VolumeGrid *grid = bData->grid;
const DynamicPaintBrushSettings *brush = data->brush;
- Object *brushOb = data->brushOb;
- const BrushMaterials *bMats = data->bMats;
- const Scene *scene = data->scene;
const float timescale = data->timescale;
const int c_index = data->c_index;
- DerivedMesh *dm = data->dm;
const MVert *mvert = data->mvert;
const MLoop *mloop = data->mloop;
const MLoopTri *mlooptri = data->mlooptri;
@@ -4149,13 +4053,6 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
sampleColor[1] = brush->g;
sampleColor[2] = brush->b;
- /* Get material+textures color on hit point if required */
- if (brush_usesMaterial(brush, scene)) {
- dynamicPaint_doMaterialTex(bMats, sampleColor, &alpha_factor, brushOb,
- bData->realCoord[bData->s_pos[index] + ss].v,
- hitCoord, hitTri, dm);
- }
-
/* Sample proximity colorband if required */
if ((hit_found == HIT_PROXIMITY) &&
(brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP))
@@ -4203,10 +4100,9 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
}
}
-static int dynamicPaint_paintMesh(const struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface,
+static int dynamicPaint_paintMesh(struct Depsgraph *depsgraph, DynamicPaintSurface *surface,
DynamicPaintBrushSettings *brush,
Object *brushOb,
- BrushMaterials *bMats,
Scene *scene,
float timescale)
{
@@ -4219,7 +4115,7 @@ static int dynamicPaint_paintMesh(const struct EvaluationContext *eval_ctx, Dyna
const MLoop *mloop = NULL;
if (brush->flags & MOD_DPAINT_USES_VELOCITY)
- dynamicPaint_brushMeshCalculateVelocity(eval_ctx, scene, brushOb, brush, &brushVelocity, timescale);
+ dynamicPaint_brushMeshCalculateVelocity(depsgraph, scene, brushOb, brush, &brushVelocity, timescale);
if (!brush->dm)
return 0;
@@ -4284,7 +4180,7 @@ static int dynamicPaint_paintMesh(const struct EvaluationContext *eval_ctx, Dyna
/* loop through cell points and process brush */
DynamicPaintPaintData data = {
.surface = surface,
- .brush = brush, .brushOb = brushOb, .bMats = bMats,
+ .brush = brush, .brushOb = brushOb,
.scene = scene, .timescale = timescale, .c_index = c_index,
.dm = dm, .mvert = mvert, .mloop = mloop, .mlooptri = mlooptri,
.brush_radius = brush_radius, .avg_brushNor = avg_brushNor, .brushVelocity = brushVelocity,
@@ -4609,13 +4505,9 @@ static void dynamic_paint_paint_single_point_cb_ex(
const PaintBakeData *bData = sData->bData;
const DynamicPaintBrushSettings *brush = data->brush;
- Object *brushOb = data->brushOb;
- const BrushMaterials *bMats = data->bMats;
- const Scene *scene = data->scene;
const float timescale = data->timescale;
- const MVert *mvert = data->mvert;
const float brush_radius = data->brush_radius;
const Vec3f *brushVelocity = data->brushVelocity;
@@ -4644,17 +4536,6 @@ static void dynamic_paint_paint_single_point_cb_ex(
float depth = 0.0f;
float velocity_val = 0.0f;
- /* material */
- if (brush_usesMaterial(brush, scene)) {
- float alpha_factor = 1.0f;
- float hit_coord[3];
- /* use dummy coord of first vertex */
- mul_v3_m4v3(hit_coord, brushOb->obmat, mvert[0].co);
-
- dynamicPaint_doMaterialTex(bMats, paintColor, &alpha_factor, brushOb,
- bData->realCoord[bData->s_pos[index]].v, hit_coord, 0, brush->dm);
- }
-
/* color ramp */
if (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP &&
BKE_colorband_evaluate(brush->paint_ramp, (1.0f - strength), colorband))
@@ -4692,11 +4573,9 @@ static void dynamic_paint_paint_single_point_cb_ex(
paintColor[2] = colorband[2];
}
else {
- if (!brush_usesMaterial(brush, scene)) {
- paintColor[0] = brush->r;
- paintColor[1] = brush->g;
- paintColor[2] = brush->b;
- }
+ paintColor[0] = brush->r;
+ paintColor[1] = brush->g;
+ paintColor[2] = brush->b;
}
}
else if (ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WAVE)) {
@@ -4709,15 +4588,15 @@ static void dynamic_paint_paint_single_point_cb_ex(
}
static int dynamicPaint_paintSinglePoint(
- const struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
- Object *brushOb, BrushMaterials *bMats, Scene *scene, float timescale)
+ struct Depsgraph *depsgraph, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
+ Object *brushOb, Scene *scene, float timescale)
{
PaintSurfaceData *sData = surface->data;
float brush_radius = brush->paint_distance * surface->radius_scale;
Vec3f brushVel;
if (brush->flags & MOD_DPAINT_USES_VELOCITY)
- dynamicPaint_brushObjectCalculateVelocity(eval_ctx, scene, brushOb, &brushVel, timescale);
+ dynamicPaint_brushObjectCalculateVelocity(depsgraph, scene, brushOb, &brushVel, timescale);
const MVert *mvert = brush->dm->getVertArray(brush->dm);
@@ -4726,7 +4605,7 @@ static int dynamicPaint_paintSinglePoint(
*/
DynamicPaintPaintData data = {
.surface = surface,
- .brush = brush, .brushOb = brushOb, .bMats = bMats,
+ .brush = brush, .brushOb = brushOb,
.scene = scene, .timescale = timescale,
.mvert = mvert,
.brush_radius = brush_radius, .brushVelocity = &brushVel,
@@ -5039,7 +4918,7 @@ static void dynamic_paint_prepare_effect_cb(
}
static int dynamicPaint_prepareEffectStep(
- const struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface, Scene *scene, Object *ob, float **force, float timescale)
+ struct Depsgraph *depsgraph, DynamicPaintSurface *surface, Scene *scene, Object *ob, float **force, float timescale)
{
double average_force = 0.0f;
float shrink_speed = 0.0f, spread_speed = 0.0f;
@@ -5050,7 +4929,7 @@ static int dynamicPaint_prepareEffectStep(
/* Init force data if required */
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) {
- ListBase *effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, surface->effector_weights, true);
+ ListBase *effectors = pdInitEffectors(depsgraph, scene, ob, NULL, surface->effector_weights, true);
/* allocate memory for force data (dir vector + strength) */
*force = MEM_mallocN(sData->total_points * 4 * sizeof(float), "PaintEffectForces");
@@ -6007,7 +5886,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Vie
/*
* Do Dynamic Paint step. Paints scene brush objects of current state/frame to the surface.
*/
-static int dynamicPaint_doStep(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
+static int dynamicPaint_doStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
{
PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData;
@@ -6035,7 +5914,7 @@ static int dynamicPaint_doStep(const struct EvaluationContext *eval_ctx, Scene *
Base *base = NULL;
Object *brushObj = NULL;
ModifierData *md = NULL;
- ViewLayer *view_layer = eval_ctx->view_layer;
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
/* backup current scene frame */
int scene_frame = scene->r.cfra;
@@ -6067,7 +5946,6 @@ static int dynamicPaint_doStep(const struct EvaluationContext *eval_ctx, Scene *
/* make sure we're dealing with a brush */
if (pmd2->brush) {
DynamicPaintBrushSettings *brush = pmd2->brush;
- BrushMaterials bMats = {NULL};
/* calculate brush speed vectors if required */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && brush->flags & MOD_DPAINT_DO_SMUDGE) {
@@ -6082,40 +5960,35 @@ static int dynamicPaint_doStep(const struct EvaluationContext *eval_ctx, Scene *
/* update object data on this subframe */
if (subframe) {
scene_setSubframe(scene, subframe);
- BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
+ BKE_object_modifier_update_subframe(depsgraph, scene, brushObj, true, SUBFRAME_RECURSION,
BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
}
- /* Prepare materials if required */
- if (brush_usesMaterial(brush, scene))
- dynamicPaint_updateBrushMaterials(eval_ctx, brushObj, brush->mat, scene, &bMats);
+
/* Apply brush on the surface depending on it's collision type */
- if (brush->psys && brush->psys->part &&
- ELEM(brush->psys->part->type, PART_EMITTER, PART_FLUID) &&
- psys_check_enabled(brushObj, brush->psys, G.is_rendering))
- {
- /* Paint a particle system */
- BKE_animsys_evaluate_animdata(scene, &brush->psys->part->id, brush->psys->part->adt,
- BKE_scene_frame_get(scene), ADT_RECALC_ANIM);
- dynamicPaint_paintParticles(surface, brush->psys, brush, timescale);
- }
+ if (brush->psys && brush->psys->part &&
+ ELEM(brush->psys->part->type, PART_EMITTER, PART_FLUID) &&
+ psys_check_enabled(brushObj, brush->psys, G.is_rendering))
+ {
+ /* Paint a particle system */
+ BKE_animsys_evaluate_animdata(scene, &brush->psys->part->id, brush->psys->part->adt,
+ BKE_scene_frame_get(scene), ADT_RECALC_ANIM);
+ dynamicPaint_paintParticles(surface, brush->psys, brush, timescale);
+ }
/* Object center distance: */
if (brush->collision == MOD_DPAINT_COL_POINT && brushObj != ob) {
- dynamicPaint_paintSinglePoint(eval_ctx, surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale);
+ dynamicPaint_paintSinglePoint(depsgraph, surface, brushObj->loc, brush, brushObj, scene, timescale);
}
/* Mesh volume/proximity: */
else if (brushObj != ob) {
- dynamicPaint_paintMesh(eval_ctx, surface, brush, brushObj, &bMats, scene, timescale);
+ dynamicPaint_paintMesh(depsgraph, surface, brush, brushObj, scene, timescale);
}
- /* free temp material data */
- if (brush_usesMaterial(brush, scene))
- dynamicPaint_freeBrushMaterials(&bMats);
/* reset object to it's original state */
if (subframe) {
scene->r.cfra = scene_frame;
scene->r.subframe = scene_subframe;
- BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
+ BKE_object_modifier_update_subframe(depsgraph, scene, brushObj, true, SUBFRAME_RECURSION,
BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
}
@@ -6150,7 +6023,7 @@ static int dynamicPaint_doStep(const struct EvaluationContext *eval_ctx, Scene *
return setError(canvas, N_("Not enough free memory"));
/* Prepare effects and get number of required steps */
- steps = dynamicPaint_prepareEffectStep(eval_ctx, surface, scene, ob, &force, timescale);
+ steps = dynamicPaint_prepareEffectStep(depsgraph, surface, scene, ob, &force, timescale);
for (s = 0; s < steps; s++) {
dynamicPaint_doEffectStep(surface, force, prevPoint, timescale, (float)steps);
}
@@ -6175,7 +6048,7 @@ static int dynamicPaint_doStep(const struct EvaluationContext *eval_ctx, Scene *
* Calculate a single frame and included subframes for surface
*/
int dynamicPaint_calculateFrame(
- DynamicPaintSurface *surface, const struct EvaluationContext *eval_ctx,
+ DynamicPaintSurface *surface, struct Depsgraph *depsgraph,
Scene *scene, Object *cObject, int frame)
{
float timescale = 1.0f;
@@ -6185,7 +6058,8 @@ int dynamicPaint_calculateFrame(
dynamicPaint_applySurfaceDisplace(surface, surface->canvas->dm);
/* update bake data */
- dynamicPaint_generateBakeData(surface, eval_ctx->view_layer, cObject);
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
+ dynamicPaint_generateBakeData(surface, view_layer, cObject);
/* don't do substeps for first frame */
if (surface->substeps && (frame != surface->start_frame)) {
@@ -6194,10 +6068,10 @@ int dynamicPaint_calculateFrame(
for (st = 1; st <= surface->substeps; st++) {
float subframe = ((float) st) / (surface->substeps + 1);
- if (!dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, subframe))
+ if (!dynamicPaint_doStep(depsgraph, scene, cObject, surface, timescale, subframe))
return 0;
}
}
- return dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, 0.0f);
+ return dynamicPaint_doStep(depsgraph, scene, cObject, surface, timescale, 0.0f);
}
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index 2018962eb62..1e211d1c4af 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -59,13 +59,6 @@
#include "MEM_guardedalloc.h"
-#include "GPU_glew.h"
-#include "GPU_buffers.h"
-#include "GPU_shader.h"
-#include "GPU_basic_shader.h"
-
-static void bmdm_get_tri_colpreview(BMLoop *ls[3], MLoopCol *lcol[3], unsigned char(*color_vert_array)[4]);
-
typedef struct EditDerivedBMesh {
DerivedMesh dm;
@@ -370,90 +363,6 @@ static void emDM_foreachMappedEdge(
}
}
-static void emDM_drawMappedEdges(
- DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- void *userData)
-{
- EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
- BMesh *bm = bmdm->em->bm;
- BMEdge *eed;
- BMIter iter;
- int i;
-
- if (bmdm->vertexCos) {
-
- BM_mesh_elem_index_ensure(bm, BM_VERT);
-
- glBegin(GL_LINES);
- BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) {
- if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) {
- glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]);
- glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]);
- }
- }
- glEnd();
- }
- else {
- glBegin(GL_LINES);
- BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) {
- if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) {
- glVertex3fv(eed->v1->co);
- glVertex3fv(eed->v2->co);
- }
- }
- glEnd();
- }
-}
-static void emDM_drawEdges(
- DerivedMesh *dm,
- bool UNUSED(drawLooseEdges),
- bool UNUSED(drawAllEdges))
-{
- emDM_drawMappedEdges(dm, NULL, NULL);
-}
-
-static void emDM_drawMappedEdgesInterp(
- DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMSetDrawInterpOptions setDrawInterpOptions,
- void *userData)
-{
- EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
- BMesh *bm = bmdm->em->bm;
- BMEdge *eed;
- BMIter iter;
- int i;
-
- if (bmdm->vertexCos) {
-
- BM_mesh_elem_index_ensure(bm, BM_VERT);
-
- glBegin(GL_LINES);
- BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) {
- if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) {
- setDrawInterpOptions(userData, i, 0.0);
- glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]);
- setDrawInterpOptions(userData, i, 1.0);
- glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]);
- }
- }
- glEnd();
- }
- else {
- glBegin(GL_LINES);
- BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) {
- if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) {
- setDrawInterpOptions(userData, i, 0.0);
- glVertex3fv(eed->v1->co);
- setDrawInterpOptions(userData, i, 1.0);
- glVertex3fv(eed->v2->co);
- }
- }
- glEnd();
- }
-}
-
static void emDM_foreachMappedLoop(
DerivedMesh *dm,
void (*func)(void *userData, int vertex_index, int face_index, const float co[3], const float no[3]),
@@ -526,571 +435,6 @@ static void emDM_foreachMappedFaceCenter(
}
}
-static void emDM_drawMappedFaces(
- DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMSetMaterial setMaterial,
- /* currently unused -- each original face is handled separately */
- DMCompareDrawOptions UNUSED(compareDrawOptions),
- void *userData,
- DMDrawFlag flag)
-{
- EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
- BMEditMesh *em = bmdm->em;
- BMesh *bm = em->bm;
- BMFace *efa;
- struct BMLoop *(*looptris)[3] = bmdm->em->looptris;
- const int tottri = bmdm->em->tottri;
- DMDrawOption draw_option;
- int i;
- const int skip_normals = !(flag & DM_DRAW_NEED_NORMALS);
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
- MLoopCol *lcol[3] = {NULL} /* , dummylcol = {0} */;
- unsigned char(*color_vert_array)[4] = em->derivedVertColor;
- unsigned char(*color_face_array)[4] = em->derivedFaceColor;
- bool has_vcol_preview = (color_vert_array != NULL) && !skip_normals;
- bool has_fcol_preview = (color_face_array != NULL) && !skip_normals;
- bool has_vcol_any = has_vcol_preview;
-
- /* GL_ZERO is used to detect if drawing has started or not */
- GLenum poly_prev = GL_ZERO;
- GLenum shade_prev = GL_ZERO;
- DMDrawOption draw_option_prev = DM_DRAW_OPTION_SKIP;
-
- /* call again below is ok */
- if (has_vcol_preview) {
- BM_mesh_elem_index_ensure(bm, BM_VERT);
- }
- if (has_fcol_preview) {
- BM_mesh_elem_index_ensure(bm, BM_FACE);
- }
- if (has_vcol_preview || has_fcol_preview) {
- flag |= DM_DRAW_ALWAYS_SMOOTH;
- /* weak, this logic should really be moved higher up */
- setMaterial = NULL;
- }
-
- if (bmdm->vertexCos) {
- short prev_mat_nr = -1;
-
- /* add direct access */
- const float (*vertexCos)[3] = bmdm->vertexCos;
- const float (*vertexNos)[3];
- const float (*polyNos)[3];
-
- if (skip_normals) {
- vertexNos = NULL;
- polyNos = NULL;
- }
- else {
- emDM_ensureVertNormals(bmdm);
- emDM_ensurePolyNormals(bmdm);
- vertexNos = bmdm->vertexNos;
- polyNos = bmdm->polyNos;
- }
-
- BM_mesh_elem_index_ensure(bm, lnors ? BM_VERT | BM_FACE | BM_LOOP : BM_VERT | BM_FACE);
-
- for (i = 0; i < tottri; i++) {
- BMLoop **ltri = looptris[i];
- int drawSmooth;
-
- efa = ltri[0]->f;
- drawSmooth = lnors || ((flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH));
-
- draw_option = (!setDrawOptions ?
- DM_DRAW_OPTION_NORMAL :
- setDrawOptions(userData, BM_elem_index_get(efa)));
- if (draw_option != DM_DRAW_OPTION_SKIP) {
- const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */
-
- if (draw_option_prev != draw_option) {
- if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) {
- if (poly_prev != GL_ZERO) glEnd();
- poly_prev = GL_ZERO; /* force glBegin */
-
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- }
- draw_option_prev = draw_option;
- }
-
-
- if (efa->mat_nr != prev_mat_nr) {
- if (setMaterial) {
- if (poly_prev != GL_ZERO) glEnd();
- poly_prev = GL_ZERO; /* force glBegin */
-
- setMaterial(efa->mat_nr + 1, NULL);
- }
- prev_mat_nr = efa->mat_nr;
- }
-
- if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */
-
- if (poly_prev != GL_ZERO) glEnd();
- poly_prev = GL_ZERO; /* force glBegin */
-
- GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR);
- GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE);
- }
-
- if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array);
- else if (has_fcol_preview) glColor3ubv((const GLubyte *)&(color_face_array[BM_elem_index_get(efa)]));
- if (skip_normals) {
- if (poly_type != poly_prev) {
- if (poly_prev != GL_ZERO) glEnd();
- glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */
- }
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
- }
- else {
- const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT;
- if (shade_type != shade_prev) {
- if (poly_prev != GL_ZERO) glEnd();
- glShadeModel((shade_prev = shade_type)); /* same as below but switch shading */
- glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */
- }
- if (poly_type != poly_prev) {
- if (poly_prev != GL_ZERO) glEnd();
- glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */
- }
-
- if (!drawSmooth) {
- glNormal3fv(polyNos[BM_elem_index_get(efa)]);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
- }
- else {
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
- else glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]);
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
- else glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]);
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
- else glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
- }
- }
- }
- }
- }
- else {
- short prev_mat_nr = -1;
-
- BM_mesh_elem_index_ensure(bm, lnors ? BM_FACE | BM_LOOP : BM_FACE);
-
- for (i = 0; i < tottri; i++) {
- BMLoop **ltri = looptris[i];
- int drawSmooth;
-
- efa = ltri[0]->f;
- drawSmooth = lnors || ((flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH));
-
- draw_option = (setDrawOptions ?
- setDrawOptions(userData, BM_elem_index_get(efa)) :
- DM_DRAW_OPTION_NORMAL);
-
- if (draw_option != DM_DRAW_OPTION_SKIP) {
- const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */
-
- if (draw_option_prev != draw_option) {
- if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) {
- if (poly_prev != GL_ZERO) glEnd();
- poly_prev = GL_ZERO; /* force glBegin */
-
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- }
- draw_option_prev = draw_option;
- }
-
- if (efa->mat_nr != prev_mat_nr) {
- if (setMaterial) {
- if (poly_prev != GL_ZERO) glEnd();
- poly_prev = GL_ZERO; /* force glBegin */
-
- setMaterial(efa->mat_nr + 1, NULL);
- }
- prev_mat_nr = efa->mat_nr;
- }
-
- if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */
-
- if (poly_prev != GL_ZERO) glEnd();
- poly_prev = GL_ZERO; /* force glBegin */
-
- GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR);
- GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE);
- }
-
- if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array);
- else if (has_fcol_preview) glColor3ubv((const GLubyte *)&(color_face_array[BM_elem_index_get(efa)]));
-
- if (skip_normals) {
- if (poly_type != poly_prev) {
- if (poly_prev != GL_ZERO) glEnd();
- glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */
- }
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- glVertex3fv(ltri[0]->v->co);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- glVertex3fv(ltri[1]->v->co);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- glVertex3fv(ltri[2]->v->co);
- }
- else {
- const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT;
- if (shade_type != shade_prev) {
- if (poly_prev != GL_ZERO) glEnd();
- glShadeModel((shade_prev = shade_type)); /* same as below but switch shading */
- glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */
- }
- if (poly_type != poly_prev) {
- if (poly_prev != GL_ZERO) glEnd();
- glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */
- }
-
- if (!drawSmooth) {
- glNormal3fv(efa->no);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- glVertex3fv(ltri[0]->v->co);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- glVertex3fv(ltri[1]->v->co);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- glVertex3fv(ltri[2]->v->co);
- }
- else {
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
- else glNormal3fv(ltri[0]->v->no);
- glVertex3fv(ltri[0]->v->co);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
- else glNormal3fv(ltri[1]->v->no);
- glVertex3fv(ltri[1]->v->co);
- if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
- else glNormal3fv(ltri[2]->v->no);
- glVertex3fv(ltri[2]->v->co);
- }
- }
- }
- }
- }
-
- /* if non zero we know a face was rendered */
- if (poly_prev != GL_ZERO) glEnd();
-
- if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) {
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- }
-
- if (shade_prev == GL_FLAT) {
- glShadeModel(GL_SMOOTH);
- }
-}
-
-static void bmdm_get_tri_colpreview(BMLoop *ls[3], MLoopCol *lcol[3], unsigned char(*color_vert_array)[4])
-{
- lcol[0] = (MLoopCol *)color_vert_array[BM_elem_index_get(ls[0]->v)];
- lcol[1] = (MLoopCol *)color_vert_array[BM_elem_index_get(ls[1]->v)];
- lcol[2] = (MLoopCol *)color_vert_array[BM_elem_index_get(ls[2]->v)];
-}
-
-/**
- * \note
- *
- * For UV's:
- * const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset);
- *
- * This is intentionally different to calling:
- * CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPUV, i);
- *
- * ... because the material may use layer names to select different UV's
- * see: [#34378]
- */
-static void emdm_pass_attrib_vertex_glsl(const DMVertexAttribs *attribs, const BMLoop *loop)
-{
- BMVert *eve = loop->v;
- int i;
- const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-
- if (attribs->totorco) {
- 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
- glVertexAttrib3fv(attribs->orco.gl_index, orco);
- }
- for (i = 0; i < attribs->tottface; i++) {
- 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
- glVertexAttrib2fv(attribs->tface[i].gl_index, uv);
- }
- for (i = 0; i < attribs->totmcol; i++) {
- float col[4];
- if (attribs->mcol[i].em_offset != -1) {
- const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset);
- rgba_uchar_to_float(col, &cp->r);
- }
- else {
- col[0] = 0.0f; col[1] = 0.0f; col[2] = 0.0f; col[3] = 0.0f;
- }
- glVertexAttrib4fv(attribs->mcol[i].gl_index, col);
- }
-
- for (i = 0; i < attribs->tottang; i++) {
- const float *tang;
- if (attribs->tang[i].em_offset != -1) {
- tang = attribs->tang[i].array[BM_elem_index_get(loop)];
- }
- else {
- tang = zero;
- }
- glVertexAttrib4fv(attribs->tang[i].gl_index, tang);
- }
-}
-
-static void emDM_drawMappedFacesGLSL(
- DerivedMesh *dm,
- DMSetMaterial setMaterial,
- DMSetDrawOptions setDrawOptions,
- void *userData)
-{
- EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
- BMEditMesh *em = bmdm->em;
- BMesh *bm = em->bm;
- struct BMLoop *(*looptris)[3] = em->looptris;
- /* add direct access */
- const float (*vertexCos)[3] = bmdm->vertexCos;
- const float (*vertexNos)[3];
- const float (*polyNos)[3];
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
-
- BMFace *efa;
- DMVertexAttribs attribs;
- GPUVertexAttribs gattribs;
-
- int i, matnr, new_matnr, fi;
- bool do_draw;
-
- do_draw = false;
- matnr = -1;
-
- memset(&attribs, 0, sizeof(attribs));
-
- emDM_ensureVertNormals(bmdm);
- emDM_ensurePolyNormals(bmdm);
- vertexNos = bmdm->vertexNos;
- polyNos = bmdm->polyNos;
-
- BM_mesh_elem_index_ensure(bm, (BM_VERT | BM_FACE) | (lnors ? BM_LOOP : 0));
-
- for (i = 0; i < em->tottri; i++) {
- BMLoop **ltri = looptris[i];
- int drawSmooth;
-
- efa = ltri[0]->f;
-
- if (setDrawOptions && (setDrawOptions(userData, BM_elem_index_get(efa)) == DM_DRAW_OPTION_SKIP))
- continue;
-
- /* material */
- new_matnr = efa->mat_nr + 1;
- if (new_matnr != matnr) {
- if (matnr != -1)
- glEnd();
-
- do_draw = setMaterial(matnr = new_matnr, &gattribs);
- if (do_draw) {
- DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
- DM_draw_attrib_vertex_uniforms(&attribs);
- if (UNLIKELY(attribs.tottang && bm->elem_index_dirty & BM_LOOP)) {
- BM_mesh_elem_index_ensure(bm, BM_LOOP);
- }
- }
-
- glBegin(GL_TRIANGLES);
- }
-
- if (do_draw) {
-
- /* draw face */
- drawSmooth = lnors || BM_elem_flag_test(efa, BM_ELEM_SMOOTH);
-
- if (!drawSmooth) {
- if (vertexCos) {
- glNormal3fv(polyNos[BM_elem_index_get(efa)]);
- for (fi = 0; fi < 3; fi++) {
- emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]);
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[fi]->v)]);
- }
- }
- else {
- glNormal3fv(efa->no);
- for (fi = 0; fi < 3; fi++) {
- emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]);
- glVertex3fv(ltri[fi]->v->co);
- }
- }
- }
- else {
- if (vertexCos) {
- for (fi = 0; fi < 3; fi++) {
- const int j = BM_elem_index_get(ltri[fi]->v);
- emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]);
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]);
- else glNormal3fv(vertexNos[j]);
- glVertex3fv(vertexCos[j]);
- }
- }
- else {
- for (fi = 0; fi < 3; fi++) {
- emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]);
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]);
- else glNormal3fv(ltri[fi]->v->no);
- glVertex3fv(ltri[fi]->v->co);
- }
- }
- }
- }
- }
-
- if (matnr != -1) {
- glEnd();
- }
-}
-
-static void emDM_drawFacesGLSL(
- DerivedMesh *dm,
- int (*setMaterial)(int matnr, void *attribs))
-{
- dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
-}
-
-static void emDM_drawMappedFacesMat(
- DerivedMesh *dm,
- void (*setMaterial)(void *userData, int matnr, void *attribs),
- bool (*setFace)(void *userData, int index), void *userData)
-{
- EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
- BMEditMesh *em = bmdm->em;
- BMesh *bm = em->bm;
- struct BMLoop *(*looptris)[3] = em->looptris;
- const float (*vertexCos)[3] = bmdm->vertexCos;
- const float (*vertexNos)[3];
- const float (*polyNos)[3];
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
- BMFace *efa;
- DMVertexAttribs attribs = {{{NULL}}};
- GPUVertexAttribs gattribs;
- int i, matnr, new_matnr, fi;
-
- matnr = -1;
-
- emDM_ensureVertNormals(bmdm);
- emDM_ensurePolyNormals(bmdm);
-
- vertexNos = bmdm->vertexNos;
- polyNos = bmdm->polyNos;
-
- BM_mesh_elem_index_ensure(bm, (BM_VERT | BM_FACE) | (lnors ? BM_LOOP : 0));
-
- for (i = 0; i < em->tottri; i++) {
- BMLoop **ltri = looptris[i];
- int drawSmooth;
-
- efa = ltri[0]->f;
-
- /* face hiding */
- if (setFace && !setFace(userData, BM_elem_index_get(efa)))
- continue;
-
- /* material */
- new_matnr = efa->mat_nr + 1;
- if (new_matnr != matnr) {
- if (matnr != -1)
- glEnd();
-
- setMaterial(userData, matnr = new_matnr, &gattribs);
- DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
- if (UNLIKELY(attribs.tottang && bm->elem_index_dirty & BM_LOOP)) {
- BM_mesh_elem_index_ensure(bm, BM_LOOP);
- }
-
- glBegin(GL_TRIANGLES);
- }
-
- /* draw face */
- drawSmooth = lnors || BM_elem_flag_test(efa, BM_ELEM_SMOOTH);
-
- if (!drawSmooth) {
- if (vertexCos) {
- glNormal3fv(polyNos[BM_elem_index_get(efa)]);
- for (fi = 0; fi < 3; fi++) {
- emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]);
- glVertex3fv(vertexCos[BM_elem_index_get(ltri[fi]->v)]);
- }
- }
- else {
- glNormal3fv(efa->no);
- for (fi = 0; fi < 3; fi++) {
- emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]);
- glVertex3fv(ltri[fi]->v->co);
- }
- }
- }
- else {
- if (vertexCos) {
- for (fi = 0; fi < 3; fi++) {
- const int j = BM_elem_index_get(ltri[fi]->v);
- emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]);
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]);
- else glNormal3fv(vertexNos[j]);
- glVertex3fv(vertexCos[j]);
- }
- }
- else {
- for (fi = 0; fi < 3; fi++) {
- emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]);
- if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]);
- else glNormal3fv(ltri[fi]->v->no);
- glVertex3fv(ltri[fi]->v->co);
- }
- }
- }
- }
-
- if (matnr != -1) {
- glEnd();
- }
-}
-
static void emDM_getMinMax(DerivedMesh *dm, float r_min[3], float r_max[3])
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
@@ -1660,14 +1004,6 @@ DerivedMesh *getEditDerivedBMesh(
bmdm->dm.foreachMappedEdge = emDM_foreachMappedEdge;
bmdm->dm.foreachMappedFaceCenter = emDM_foreachMappedFaceCenter;
- bmdm->dm.drawEdges = emDM_drawEdges;
- bmdm->dm.drawMappedEdges = emDM_drawMappedEdges;
- bmdm->dm.drawMappedEdgesInterp = emDM_drawMappedEdgesInterp;
- bmdm->dm.drawMappedFaces = emDM_drawMappedFaces;
- bmdm->dm.drawMappedFacesGLSL = emDM_drawMappedFacesGLSL;
- bmdm->dm.drawMappedFacesMat = emDM_drawMappedFacesMat;
- bmdm->dm.drawFacesGLSL = emDM_drawFacesGLSL;
-
bmdm->dm.release = emDM_release;
bmdm->vertexCos = (const float (*)[3])vertexCos;
@@ -2176,14 +1512,14 @@ static void cage_mapped_verts_callback(
}
}
-float (*BKE_editmesh_vertexCos_get(const struct EvaluationContext *eval_ctx, BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
+float (*BKE_editmesh_vertexCos_get(struct Depsgraph *depsgraph, BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
{
DerivedMesh *cage, *final;
BLI_bitmap *visit_bitmap;
struct CageUserData data;
float (*cos_cage)[3];
- cage = editbmesh_get_derived_cage_and_final(eval_ctx, scene, em->ob, em, CD_MASK_BAREMESH, &final);
+ cage = editbmesh_get_derived_cage_and_final(depsgraph, scene, em->ob, em, CD_MASK_BAREMESH, &final);
cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage");
/* when initializing cage verts, we only want the first cage coordinate for each vertex,
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c
index c95da3b2569..b63ab276b14 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -89,11 +89,13 @@ BMEditMesh *BKE_editmesh_from_object(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
/* sanity check */
+#if 0 /* disable in mutlti-object edit. */
#ifndef NDEBUG
if (((Mesh *)ob->data)->edit_btmesh) {
BLI_assert(((Mesh *)ob->data)->edit_btmesh->ob == ob);
}
#endif
+#endif
return ((Mesh *)ob->data)->edit_btmesh;
}
diff --git a/source/blender/blenkernel/intern/editmesh_bvh.c b/source/blender/blenkernel/intern/editmesh_bvh.c
index 2927354241c..e68f11f6274 100644
--- a/source/blender/blenkernel/intern/editmesh_bvh.c
+++ b/source/blender/blenkernel/intern/editmesh_bvh.c
@@ -547,4 +547,4 @@ BVHTreeOverlap *BKE_bmbvh_overlap(const BMBVHTree *bmtree_a, const BMBVHTree *bm
data.epsilon = max_ff(BLI_bvhtree_get_epsilon(bmtree_a->tree), BLI_bvhtree_get_epsilon(bmtree_b->tree));
return BLI_bvhtree_overlap(bmtree_a->tree, bmtree_b->tree, r_overlap_tot, bmbvh_overlap_cb, &data);
-} \ No newline at end of file
+}
diff --git a/source/blender/blenkernel/intern/editmesh_tangent.c b/source/blender/blenkernel/intern/editmesh_tangent.c
index f725a1793b4..9e8b4fa8782 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -428,4 +428,4 @@ void BKE_editmesh_loop_tangent_calc(
} /* else tangent has been built from orco */
}
-/** \} */ \ No newline at end of file
+/** \} */
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index b54093555f5..8bdc74edffd 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -74,6 +74,7 @@
#include "BKE_smoke.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "RE_render_ext.h"
#include "RE_shader_ext.h"
@@ -148,10 +149,10 @@ void free_partdeflect(PartDeflect *pd)
MEM_freeN(pd);
}
-static EffectorCache *new_effector_cache(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
+static EffectorCache *new_effector_cache(struct Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
{
EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache");
- eff->eval_ctx = eval_ctx;
+ eff->depsgraph = depsgraph;
eff->scene = scene;
eff->ob = ob;
eff->psys = psys;
@@ -159,7 +160,7 @@ static EffectorCache *new_effector_cache(const struct EvaluationContext *eval_ct
eff->frame = -1;
return eff;
}
-static void add_object_to_effectors(ListBase **effectors, const struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation)
+static void add_object_to_effectors(ListBase **effectors, struct Depsgraph *depsgraph, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation)
{
EffectorCache *eff = NULL;
@@ -177,14 +178,14 @@ static void add_object_to_effectors(ListBase **effectors, const struct Evaluatio
if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
- eff = new_effector_cache(eval_ctx, scene, ob, NULL, ob->pd);
+ eff = new_effector_cache(depsgraph, scene, ob, NULL, ob->pd);
/* make sure imat is up to date */
invert_m4_m4(ob->imat, ob->obmat);
BLI_addtail(*effectors, eff);
}
-static void add_particles_to_effectors(ListBase **effectors, const struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
+static void add_particles_to_effectors(ListBase **effectors, struct Depsgraph *depsgraph, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
{
ParticleSettings *part= psys->part;
@@ -198,20 +199,20 @@ static void add_particles_to_effectors(ListBase **effectors, const struct Evalua
if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
- BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd));
+ BLI_addtail(*effectors, new_effector_cache(depsgraph, scene, ob, psys, part->pd));
}
if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) {
if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
- BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd2));
+ BLI_addtail(*effectors, new_effector_cache(depsgraph, scene, ob, psys, part->pd2));
}
}
/* returns ListBase handle with objects taking part in the effecting */
ListBase *pdInitEffectors(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, ParticleSystem *psys_src,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, ParticleSystem *psys_src,
EffectorWeights *weights, bool for_simulation)
{
ViewLayer *view_layer;
@@ -222,11 +223,11 @@ ListBase *pdInitEffectors(
view_layer = weights->group->view_layer;
}
/* TODO(mai): the check for view_layer shouldnt be needed, remove when render engine api is updated for this */
- else if (eval_ctx && eval_ctx->view_layer) {
- view_layer = eval_ctx->view_layer;
+ else if (depsgraph && DEG_get_evaluated_view_layer(depsgraph)) {
+ view_layer = DEG_get_evaluated_view_layer(depsgraph);
}
else {
- /* eval_ctx is NULL during deg build */
+ /* depsgraph is NULL during deg build */
view_layer = BKE_view_layer_context_active_PLACEHOLDER(scene);
}
@@ -236,20 +237,20 @@ ListBase *pdInitEffectors(
}
if (base->object->pd && base->object->pd->forcefield) {
- add_object_to_effectors(&effectors, eval_ctx, scene, weights, base->object, ob_src, for_simulation);
+ add_object_to_effectors(&effectors, depsgraph, scene, weights, base->object, ob_src, for_simulation);
}
if (base->object->particlesystem.first) {
ParticleSystem *psys= base->object->particlesystem.first;
for (; psys; psys=psys->next) {
- add_particles_to_effectors(&effectors, eval_ctx, scene, weights, base->object, psys, psys_src, for_simulation);
+ add_particles_to_effectors(&effectors, depsgraph, scene, weights, base->object, psys, psys_src, for_simulation);
}
}
}
if (for_simulation) {
- pdPrecalculateEffectors(eval_ctx, effectors);
+ pdPrecalculateEffectors(depsgraph, effectors);
}
return effectors;
@@ -271,7 +272,7 @@ void pdEndEffectors(ListBase **effectors)
}
}
-static void precalculate_effector(const struct EvaluationContext *eval_ctx, EffectorCache *eff)
+static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *eff)
{
unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra);
if (!eff->pd->rng)
@@ -283,7 +284,7 @@ static void precalculate_effector(const struct EvaluationContext *eval_ctx, Effe
Curve *cu= eff->ob->data;
if (cu->flag & CU_PATH) {
if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL)
- BKE_displist_make_curveTypes(eval_ctx, eff->scene, eff->ob, 0);
+ BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, 0);
if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) {
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
@@ -304,19 +305,19 @@ static void precalculate_effector(const struct EvaluationContext *eval_ctx, Effe
if (eff->ob) {
float old_vel[3];
- BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra - 1.0f);
+ BKE_object_where_is_calc_time(depsgraph, eff->scene, eff->ob, cfra - 1.0f);
copy_v3_v3(old_vel, eff->ob->obmat[3]);
- BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra);
+ BKE_object_where_is_calc_time(depsgraph, eff->scene, eff->ob, cfra);
sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
}
}
-void pdPrecalculateEffectors(const struct EvaluationContext *eval_ctx, ListBase *effectors)
+void pdPrecalculateEffectors(struct Depsgraph *depsgraph, ListBase *effectors)
{
if (effectors) {
EffectorCache *eff = effectors->first;
for (; eff; eff=eff->next)
- precalculate_effector(eval_ctx, eff);
+ precalculate_effector(depsgraph, eff);
}
}
@@ -507,28 +508,28 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU
falloff=0.0f;
else {
switch (eff->pd->falloff) {
- case PFIELD_FALL_SPHERE:
- falloff*= falloff_func_dist(eff->pd, efd->distance);
- break;
-
- case PFIELD_FALL_TUBE:
- falloff*= falloff_func_dist(eff->pd, ABS(fac));
- if (falloff == 0.0f)
+ case PFIELD_FALL_SPHERE:
+ falloff*= falloff_func_dist(eff->pd, efd->distance);
break;
- madd_v3_v3v3fl(temp, efd->vec_to_point2, efd->nor, -fac);
- r_fac= len_v3(temp);
- falloff*= falloff_func_rad(eff->pd, r_fac);
- break;
- case PFIELD_FALL_CONE:
- falloff*= falloff_func_dist(eff->pd, ABS(fac));
- if (falloff == 0.0f)
+ case PFIELD_FALL_TUBE:
+ falloff*= falloff_func_dist(eff->pd, ABS(fac));
+ if (falloff == 0.0f)
+ break;
+
+ madd_v3_v3v3fl(temp, efd->vec_to_point2, efd->nor, -fac);
+ r_fac= len_v3(temp);
+ falloff*= falloff_func_rad(eff->pd, r_fac);
break;
+ case PFIELD_FALL_CONE:
+ falloff*= falloff_func_dist(eff->pd, ABS(fac));
+ if (falloff == 0.0f)
+ break;
- r_fac= RAD2DEGF(saacos(fac/len_v3(efd->vec_to_point)));
- falloff*= falloff_func_rad(eff->pd, r_fac);
+ r_fac= RAD2DEGF(saacos(fac/len_v3(efd->vec_to_point)));
+ falloff*= falloff_func_rad(eff->pd, r_fac);
- break;
+ break;
}
}
@@ -615,7 +616,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
}
else {
ParticleSimulationData sim= {NULL};
- sim.eval_ctx = eff->eval_ctx;
+ sim.depsgraph = eff->depsgraph;
sim.scene= eff->scene;
sim.ob= eff->ob;
sim.psys= eff->psys;
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index d0d3317b477..c79b2bb4aee 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -64,7 +64,7 @@
// file handling
//-------------------------------------------------------------------------------
-void initElbeemMesh(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+void initElbeemMesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
int *numVertices, float **vertices,
int *numTriangles, int **triangles,
int useGlobalCoords, int modifierIndex)
@@ -77,7 +77,7 @@ void initElbeemMesh(const struct EvaluationContext *eval_ctx, struct Scene *scen
float *verts;
int *tris;
- dm = mesh_create_derived_index_render(eval_ctx, scene, ob, CD_MASK_BAREMESH, modifierIndex);
+ dm = mesh_create_derived_index_render(depsgraph, scene, ob, CD_MASK_BAREMESH, modifierIndex);
mvert = dm->getVertArray(dm);
mloop = dm->getLoopArray(dm);
diff --git a/source/blender/blenkernel/intern/groom.c b/source/blender/blenkernel/intern/groom.c
index 0a63a1aaaf0..5e1ca3a37b3 100644
--- a/source/blender/blenkernel/intern/groom.c
+++ b/source/blender/blenkernel/intern/groom.c
@@ -823,7 +823,7 @@ void BKE_groom_curve_cache_clear(Groom *groom)
/* === Depsgraph evaluation === */
-void BKE_groom_eval_geometry(const EvaluationContext *UNUSED(eval_ctx), Groom *groom)
+void BKE_groom_eval_geometry(struct Depsgraph *UNUSED(depsgraph), Groom *groom)
{
if (G.debug & G_DEBUG_DEPSGRAPH) {
printf("%s on %s\n", __func__, groom->id.name);
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 7566d370c45..ae031d21b88 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -334,7 +334,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode)
* you can draw everything, leaves tags in objects to signal it needs further updating */
/* note: does not work for derivedmesh and render... it recreates all again in convertblender.c */
-void BKE_group_handle_recalc_and_update(const struct EvaluationContext *eval_ctx, Scene *scene, Object *UNUSED(parent), Group *group)
+void BKE_group_handle_recalc_and_update(struct Depsgraph *depsgraph, Scene *scene, Object *UNUSED(parent), Group *group)
{
#if 0 /* warning, isn't clearing the recalc flag on the object which causes it to run all the time,
* not just on frame change.
@@ -354,7 +354,7 @@ void BKE_group_handle_recalc_and_update(const struct EvaluationContext *eval_ctx
go->ob->recalc = go->recalc;
group_replaces_nla(parent, go->ob, 's');
- BKE_object_handle_update(eval_ctx, scene, go->ob);
+ BKE_object_handle_update(depsgraph, scene, go->ob);
group_replaces_nla(parent, go->ob, 'e');
/* leave recalc tags in case group members are in normal scene */
@@ -372,7 +372,7 @@ void BKE_group_handle_recalc_and_update(const struct EvaluationContext *eval_ctx
FOREACH_GROUP_OBJECT_BEGIN(group, object)
{
if (object->id.recalc & ID_RECALC_ALL) {
- BKE_object_handle_update(eval_ctx, scene, object);
+ BKE_object_handle_update(depsgraph, scene, object);
}
}
FOREACH_GROUP_OBJECT_END;
@@ -381,9 +381,9 @@ void BKE_group_handle_recalc_and_update(const struct EvaluationContext *eval_ctx
/* ******** Dependency graph evaluation ******** */
-void BKE_group_eval_view_layers(const struct EvaluationContext *eval_ctx,
+void BKE_group_eval_view_layers(struct Depsgraph *depsgraph,
Group *group)
{
DEG_debug_print_eval(__func__, group->id.name, group);
- BKE_layer_eval_view_layer(eval_ctx, &group->id, group->view_layer);
+ BKE_layer_eval_view_layer(depsgraph, &group->id, group->view_layer);
}
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index f3ff2c4425a..7097b349125 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -49,7 +49,9 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
+#include "BLI_linklist_lockfree.h"
#include "BLI_string.h"
+#include "BLI_threads.h"
#include "BKE_icons.h"
#include "BKE_global.h" /* only for G.background test */
@@ -62,6 +64,14 @@
#include "IMB_imbuf_types.h"
#include "IMB_thumbs.h"
+/**
+ * Only allow non-managed icons to be removed (by Python for eg).
+ * Previews & ID's have their own functions to remove icons.
+ */
+enum {
+ ICON_FLAG_MANAGED = (1 << 0),
+};
+
/* GLOBALS */
static GHash *gIcons = NULL;
@@ -72,11 +82,25 @@ static int gFirstIconId = 1;
static GHash *gCachedPreviews = NULL;
+/* Queue of icons for deferred deletion. */
+typedef struct DeferredIconDeleteNode {
+ struct DeferredIconDeleteNode *next;
+ int icon_id;
+} DeferredIconDeleteNode;
+static LockfreeLinkList g_icon_delete_queue;
+
static void icon_free(void *val)
{
Icon *icon = val;
if (icon) {
+ if (icon->obj_type == ICON_DATA_GEOM) {
+ struct Icon_Geom *obj = icon->obj;
+ MEM_freeN((void *)obj->coords);
+ MEM_freeN((void *)obj->colors);
+ MEM_freeN(icon->obj);
+ }
+
if (icon->drawinfo_free) {
icon->drawinfo_free(icon->drawinfo);
}
@@ -87,10 +111,27 @@ static void icon_free(void *val)
}
}
+static void icon_free_data(Icon *icon)
+{
+ if (icon->obj_type == ICON_DATA_ID) {
+ ((ID *)(icon->obj))->icon_id = 0;
+ }
+ else if (icon->obj_type == ICON_DATA_PREVIEW) {
+ ((PreviewImage *)(icon->obj))->icon_id = 0;
+ }
+ else if (icon->obj_type == ICON_DATA_GEOM) {
+ ((struct Icon_Geom *)(icon->obj))->icon_id = 0;
+ }
+ else {
+ BLI_assert(0);
+ }
+}
+
/* create an id for a new icon and make sure that ids from deleted icons get reused
* after the integer number range is used up */
static int get_next_free_id(void)
{
+ BLI_assert(BLI_thread_is_main());
int startId = gFirstIconId;
/* if we haven't used up the int number range, we just return the next int */
@@ -111,11 +152,15 @@ static int get_next_free_id(void)
void BKE_icons_init(int first_dyn_id)
{
+ BLI_assert(BLI_thread_is_main());
+
gNextIconId = first_dyn_id;
gFirstIconId = first_dyn_id;
- if (!gIcons)
+ if (!gIcons) {
gIcons = BLI_ghash_int_new(__func__);
+ BLI_linklist_lockfree_init(&g_icon_delete_queue);
+ }
if (!gCachedPreviews) {
gCachedPreviews = BLI_ghash_str_new(__func__);
@@ -124,6 +169,8 @@ void BKE_icons_init(int first_dyn_id)
void BKE_icons_free(void)
{
+ BLI_assert(BLI_thread_is_main());
+
if (gIcons) {
BLI_ghash_free(gIcons, NULL, icon_free);
gIcons = NULL;
@@ -133,6 +180,22 @@ void BKE_icons_free(void)
BLI_ghash_free(gCachedPreviews, MEM_freeN, BKE_previewimg_freefunc);
gCachedPreviews = NULL;
}
+
+ BLI_linklist_lockfree_free(&g_icon_delete_queue, MEM_freeN);
+}
+
+void BKE_icons_deferred_free(void)
+{
+ BLI_assert(BLI_thread_is_main());
+
+ for (DeferredIconDeleteNode *node =
+ (DeferredIconDeleteNode *)BLI_linklist_lockfree_begin(&g_icon_delete_queue);
+ node != NULL;
+ node = node->next)
+ {
+ BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(node->icon_id), NULL, icon_free);
+ }
+ BLI_linklist_lockfree_clear(&g_icon_delete_queue, MEM_freeN);
}
static PreviewImage *previewimg_create_ex(size_t deferred_data_size)
@@ -435,6 +498,8 @@ void BKE_previewimg_ensure(PreviewImage *prv, const int size)
void BKE_icon_changed(const int icon_id)
{
+ BLI_assert(BLI_thread_is_main());
+
Icon *icon = NULL;
if (!icon_id || G.background) return;
@@ -443,7 +508,8 @@ void BKE_icon_changed(const int icon_id)
if (icon) {
/* We *only* expect ID-tied icons here, not non-ID icon/preview! */
- BLI_assert(icon->type != 0);
+ BLI_assert(icon->id_type != 0);
+ BLI_assert(icon->obj_type == ICON_DATA_ID);
/* Do not enforce creation of previews for valid ID types using BKE_previewimg_id_ensure() here ,
* we only want to ensure *existing* preview images are properly tagged as changed/invalid, that's all. */
@@ -460,20 +526,31 @@ void BKE_icon_changed(const int icon_id)
}
}
-static int icon_id_ensure_create_icon(struct ID *id)
+static Icon *icon_create(int icon_id, int obj_type, void *obj)
{
- Icon *new_icon = NULL;
+ Icon *new_icon = MEM_mallocN(sizeof(Icon), __func__);
- new_icon = MEM_mallocN(sizeof(Icon), __func__);
-
- new_icon->obj = id;
- new_icon->type = GS(id->name);
+ new_icon->obj_type = obj_type;
+ new_icon->obj = obj;
+ new_icon->id_type = 0;
+ new_icon->flag = 0;
/* next two lines make sure image gets created */
new_icon->drawinfo = NULL;
new_icon->drawinfo_free = NULL;
- BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(id->icon_id), new_icon);
+ BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(icon_id), new_icon);
+
+ return new_icon;
+}
+
+static int icon_id_ensure_create_icon(struct ID *id)
+{
+ BLI_assert(BLI_thread_is_main());
+
+ Icon *icon = icon_create(id->icon_id, ICON_DATA_ID, id);
+ icon->id_type = GS(id->name);
+ icon->flag = ICON_FLAG_MANAGED;
return id->icon_id;
}
@@ -508,8 +585,6 @@ int BKE_icon_id_ensure(struct ID *id)
*/
int BKE_icon_preview_ensure(ID *id, PreviewImage *preview)
{
- Icon *new_icon = NULL;
-
if (!preview || G.background)
return 0;
@@ -540,22 +615,32 @@ int BKE_icon_preview_ensure(ID *id, PreviewImage *preview)
return icon_id_ensure_create_icon(id);
}
- new_icon = MEM_mallocN(sizeof(Icon), __func__);
+ Icon *icon = icon_create(preview->icon_id, ICON_DATA_PREVIEW, preview);
+ icon->flag = ICON_FLAG_MANAGED;
- new_icon->obj = preview;
- new_icon->type = 0; /* Special, tags as non-ID icon/preview. */
+ return preview->icon_id;
+}
- /* next two lines make sure image gets created */
- new_icon->drawinfo = NULL;
- new_icon->drawinfo_free = NULL;
+int BKE_icon_geom_ensure(struct Icon_Geom *geom)
+{
+ BLI_assert(BLI_thread_is_main());
- BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(preview->icon_id), new_icon);
+ if (geom->icon_id) {
+ return geom->icon_id;
+ }
- return preview->icon_id;
+ geom->icon_id = get_next_free_id();
+
+ icon_create(geom->icon_id, ICON_DATA_GEOM, geom);
+ /* Not managed for now, we may want this to be configurable per icon). */
+
+ return geom->icon_id;
}
Icon *BKE_icon_get(const int icon_id)
{
+ BLI_assert(BLI_thread_is_main());
+
Icon *icon = NULL;
icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
@@ -570,6 +655,8 @@ Icon *BKE_icon_get(const int icon_id)
void BKE_icon_set(const int icon_id, struct Icon *icon)
{
+ BLI_assert(BLI_thread_is_main());
+
void **val_p;
if (BLI_ghash_ensure_p(gIcons, SET_INT_IN_POINTER(icon_id), &val_p)) {
@@ -580,32 +667,71 @@ void BKE_icon_set(const int icon_id, struct Icon *icon)
*val_p = icon;
}
-void BKE_icon_id_delete(struct ID *id)
+static void icon_add_to_deferred_delete_queue(int icon_id)
{
- if (!id->icon_id) return; /* no icon defined for library object */
+ DeferredIconDeleteNode *node =
+ MEM_mallocN(sizeof(DeferredIconDeleteNode), __func__);
+ node->icon_id = icon_id;
+ BLI_linklist_lockfree_insert(&g_icon_delete_queue,
+ (LockfreeLinkNode *)node);
+}
- BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(id->icon_id), NULL, icon_free);
+void BKE_icon_id_delete(struct ID *id)
+{
+ const int icon_id = id->icon_id;
+ if (!icon_id) return; /* no icon defined for library object */
id->icon_id = 0;
+
+ if (!BLI_thread_is_main()) {
+ icon_add_to_deferred_delete_queue(icon_id);
+ return;
+ }
+
+ BKE_icons_deferred_free();
+ BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(icon_id), NULL, icon_free);
}
/**
* Remove icon and free data.
*/
-void BKE_icon_delete(const int icon_id)
+bool BKE_icon_delete(const int icon_id)
{
- Icon *icon;
+ if (icon_id == 0) {
+ /* no icon defined for library object */
+ return false;
+ }
- if (!icon_id) return; /* no icon defined for library object */
+ Icon *icon = BLI_ghash_popkey(gIcons, SET_INT_IN_POINTER(icon_id), NULL);
+ if (icon) {
+ icon_free_data(icon);
+ icon_free(icon);
+ return true;
+ }
+ else {
+ return false;
+ }
+}
- icon = BLI_ghash_popkey(gIcons, SET_INT_IN_POINTER(icon_id), NULL);
+bool BKE_icon_delete_unmanaged(const int icon_id)
+{
+ if (icon_id == 0) {
+ /* no icon defined for library object */
+ return false;
+ }
+ Icon *icon = BLI_ghash_popkey(gIcons, SET_INT_IN_POINTER(icon_id), NULL);
if (icon) {
- if (icon->type) {
- ((ID *)(icon->obj))->icon_id = 0;
+ if (UNLIKELY(icon->flag & ICON_FLAG_MANAGED)) {
+ BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(icon_id), icon);
+ return false;
}
else {
- ((PreviewImage *)(icon->obj))->icon_id = 0;
+ icon_free_data(icon);
+ icon_free(icon);
+ return true;
}
- icon_free(icon);
+ }
+ else {
+ return false;
}
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 28245f9a4d8..50b1756ff87 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -370,7 +370,6 @@ static void image_init(Image *ima, short source, short type)
ima->ok = IMA_OK;
- ima->xrep = ima->yrep = 1;
ima->aspx = ima->aspy = 1.0;
ima->gen_x = 1024; ima->gen_y = 1024;
ima->gen_type = IMA_GENTYPE_GRID;
@@ -473,12 +472,10 @@ void BKE_image_copy_data(Main *UNUSED(bmain), Image *ima_dst, const Image *ima_s
BLI_listbase_clear(&ima_dst->anims);
- ima_dst->totbind = 0;
for (int i = 0; i < TEXTARGET_COUNT; i++) {
ima_dst->bindcode[i] = 0;
ima_dst->gputexture[i] = NULL;
}
- ima_dst->repbind = NULL;
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
BKE_previewimg_id_copy(&ima_dst->id, &ima_src->id);
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index fcbc25ebad5..941c7eb2a87 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -46,7 +46,6 @@
/* since we have versioning code here */
#define DNA_DEPRECATED_ALLOW
-#include "DNA_actuator_types.h"
#include "DNA_anim_types.h"
#include "DNA_constraint_types.h"
#include "DNA_camera_types.h"
@@ -146,17 +145,6 @@ static AdrBit2Path ob_layer_bits[] = {
{(1 << 19), "layers", 19}
};
-/* Material mode */
-static AdrBit2Path ma_mode_bits[] = {
-// {MA_TRACEBLE, "traceable", 0},
-// {MA_SHADOW, "shadow", 0},
-// {MA_SHLESS, "shadeless", 0},
-// ...
- {MA_RAYTRANSP, "transparency", 0},
- {MA_RAYMIRROR, "raytrace_mirror.enabled", 0},
-// {MA_HALO, "type", MA_TYPE_HALO}
-};
-
/* ----------------- */
/* quick macro for returning the appropriate array for adrcode_bitmaps_to_paths() */
@@ -173,9 +161,6 @@ static AdrBit2Path *adrcode_bitmaps_to_paths(int blocktype, int adrcode, int *to
if ((blocktype == ID_OB) && (adrcode == OB_LAY)) {
RET_ABP(ob_layer_bits);
}
- else if ((blocktype == ID_MA) && (adrcode == MA_MODE)) {
- RET_ABP(ma_mode_bits);
- }
// XXX TODO: add other types...
/* Normal curve */
@@ -1768,23 +1753,6 @@ void do_versions_ipos_to_animato(Main *main)
ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL);
id_us_min(&ob->ipo->id);
ob->ipo = NULL;
-
- {
- /* If we have any empty action actuators, assume they were
- * converted IPO Actuators using the object IPO */
- bActuator *act;
- bActionActuator *aa;
-
- for (act = ob->actuators.first; act; act = act->next) {
- /* Any actuators set to ACT_IPO at this point are actually Action Actuators that
- * need this converted IPO to finish converting the actuator. */
- if (act->type == ACT_IPO) {
- aa = (bActionActuator *)act->data;
- aa->act = ob->adt->action;
- act->type = ACT_ACTION;
- }
- }
- }
}
}
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index bf36c437d60..75abd10f52d 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -72,35 +72,14 @@ void BKE_lamp_init(Lamp *la)
la->samp = 3;
la->bias = 1.0f;
la->soft = 3.0f;
- la->compressthresh = 0.05f;
- la->ray_samp = la->ray_sampy = la->ray_sampz = 1;
la->area_size = la->area_sizey = la->area_sizez = 0.1f;
la->buffers = 1;
- la->buftype = LA_SHADBUF_HALFWAY;
- la->ray_samp_method = LA_SAMP_HALTON;
- la->adapt_thresh = 0.001f;
la->preview = NULL;
la->falloff_type = LA_FALLOFF_INVSQUARE;
la->coeff_const = 1.0f;
la->coeff_lin = 0.0f;
la->coeff_quad = 0.0f;
la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
- la->sun_effect_type = 0;
- la->horizon_brightness = 1.0;
- la->spread = 1.0;
- la->sun_brightness = 1.0;
- la->sun_size = 1.0;
- la->backscattered_light = 1.0f;
- la->atm_turbidity = 2.0f;
- la->atm_inscattering_factor = 1.0f;
- la->atm_extinction_factor = 1.0f;
- la->atm_distance_factor = 1.0f;
- la->sun_intensity = 1.0f;
- la->skyblendtype = MA_RAMP_ADD;
- la->skyblendfac = 1.0f;
- la->sky_colorspace = BLI_XYZ_CIE;
- la->sky_exposure = 1.0f;
- la->shadow_frustum_size = 10.0f;
la->cascade_max_dist = 1000.0f;
la->cascade_count = 4;
la->cascade_exponent = 0.8f;
@@ -134,13 +113,6 @@ Lamp *BKE_lamp_add(Main *bmain, const char *name)
*/
void BKE_lamp_copy_data(Main *bmain, Lamp *la_dst, const Lamp *la_src, const int flag)
{
- for (int a = 0; a < MAX_MTEX; a++) {
- if (la_dst->mtex[a]) {
- la_dst->mtex[a] = MEM_mallocN(sizeof(*la_dst->mtex[a]), __func__);
- *la_dst->mtex[a] = *la_src->mtex[a];
- }
- }
-
la_dst->curfalloff = curvemapping_copy(la_src->curfalloff);
if (la_src->nodetree) {
@@ -173,18 +145,8 @@ Lamp *BKE_lamp_localize(Lamp *la)
*
* ... Once f*** nodes are fully converted to that too :( */
- Lamp *lan;
- int a;
-
- lan = BKE_libblock_copy_nolib(&la->id, false);
+ Lamp *lan = BKE_libblock_copy_nolib(&la->id, false);
- for (a = 0; a < MAX_MTEX; a++) {
- if (lan->mtex[a]) {
- lan->mtex[a] = MEM_mallocN(sizeof(MTex), __func__);
- memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
- }
- }
-
lan->curfalloff = curvemapping_copy(la->curfalloff);
if (la->nodetree)
@@ -202,12 +164,6 @@ void BKE_lamp_make_local(Main *bmain, Lamp *la, const bool lib_local)
void BKE_lamp_free(Lamp *la)
{
- int a;
-
- for (a = 0; a < MAX_MTEX; a++) {
- MEM_SAFE_FREE(la->mtex[a]);
- }
-
BKE_animdata_free((ID *)la, false);
curvemapping_free(la->curfalloff);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index c41ad78977e..b9e6e0e8fa9 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -1026,7 +1026,7 @@ void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3])
}
}
-void BKE_lattice_modifiers_calc(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
{
Lattice *lt = ob->data;
VirtualModifierData virtualModifierData;
@@ -1053,7 +1053,7 @@ void BKE_lattice_modifiers_calc(const struct EvaluationContext *eval_ctx, Scene
if (mti->type != eModifierTypeType_OnlyDeform) continue;
if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts);
- mti->deformVerts(md, eval_ctx, ob, NULL, vertexCos, numVerts, 0);
+ mti->deformVerts(md, depsgraph, ob, NULL, vertexCos, numVerts, 0);
}
/* always displist to make this work like derivedmesh */
@@ -1227,7 +1227,7 @@ void BKE_lattice_translate(Lattice *lt, float offset[3], bool do_keys)
/* **** Depsgraph evaluation **** */
-void BKE_lattice_eval_geometry(const struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_lattice_eval_geometry(struct Depsgraph *UNUSED(depsgraph),
Lattice *UNUSED(latt))
{
}
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 50c7dc0c02f..15585d852b9 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -26,6 +26,7 @@
#include <string.h>
+#include "BLI_array.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
@@ -41,8 +42,7 @@
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_workspace.h"
-
-#include "DEG_depsgraph.h"
+#include "BKE_object.h"
#include "DNA_group_types.h"
#include "DNA_ID.h"
@@ -53,6 +53,9 @@
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
#include "DRW_engine.h"
#include "MEM_guardedalloc.h"
@@ -2032,9 +2035,14 @@ void BKE_view_layer_engine_settings_validate_layer(ViewLayer *view_layer)
IDP_MergeGroup(view_layer->properties, root_reference.view_layer, false);
}
-/* ---------------------------------------------------------------------- */
+/** \} */
+
/* Iterators */
+/* -------------------------------------------------------------------- */
+/** \name Private Iterator Helpers
+ * \{ */
+
static void object_bases_iterator_begin(BLI_Iterator *iter, void *data_in, const int flag)
{
ViewLayer *view_layer = data_in;
@@ -2090,67 +2098,96 @@ static void objects_iterator_next(BLI_Iterator *iter, const int flag)
}
}
-void BKE_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
+/* -------------------------------------------------------------------- */
+/** \name BKE_view_layer_selected_objects_iterator
+ * See: #FOREACH_SELECTED_OBJECT_BEGIN
+ * \{ */
+
+void BKE_view_layer_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
{
objects_iterator_begin(iter, data_in, BASE_SELECTED);
}
-void BKE_selected_objects_iterator_next(BLI_Iterator *iter)
+void BKE_view_layer_selected_objects_iterator_next(BLI_Iterator *iter)
{
objects_iterator_next(iter, BASE_SELECTED);
}
-void BKE_selected_objects_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *UNUSED(iter))
{
/* do nothing */
}
-void BKE_visible_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name BKE_view_layer_selected_objects_iterator
+ * \{ */
+
+void BKE_view_layer_visible_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
{
objects_iterator_begin(iter, data_in, BASE_VISIBLED);
}
-void BKE_visible_objects_iterator_next(BLI_Iterator *iter)
+void BKE_view_layer_visible_objects_iterator_next(BLI_Iterator *iter)
{
objects_iterator_next(iter, BASE_VISIBLED);
}
-void BKE_visible_objects_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *UNUSED(iter))
{
/* do nothing */
}
-void BKE_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name BKE_view_layer_selected_bases_iterator
+ * \{ */
+
+void BKE_view_layer_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in)
{
object_bases_iterator_begin(iter, data_in, BASE_SELECTED);
}
-void BKE_selected_bases_iterator_next(BLI_Iterator *iter)
+void BKE_view_layer_selected_bases_iterator_next(BLI_Iterator *iter)
{
object_bases_iterator_next(iter, BASE_SELECTED);
}
-void BKE_selected_bases_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_selected_bases_iterator_end(BLI_Iterator *UNUSED(iter))
{
/* do nothing */
}
-void BKE_visible_bases_iterator_begin(BLI_Iterator *iter, void *data_in)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name BKE_view_layer_visible_bases_iterator
+ * \{ */
+
+void BKE_view_layer_visible_bases_iterator_begin(BLI_Iterator *iter, void *data_in)
{
object_bases_iterator_begin(iter, data_in, BASE_VISIBLED);
}
-void BKE_visible_bases_iterator_next(BLI_Iterator *iter)
+void BKE_view_layer_visible_bases_iterator_next(BLI_Iterator *iter)
{
object_bases_iterator_next(iter, BASE_VISIBLED);
}
-void BKE_visible_bases_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *UNUSED(iter))
{
/* do nothing */
}
-void BKE_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name BKE_view_layer_renderable_objects_iterator
+ * \{ */
+
+void BKE_view_layer_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
{
struct ObjectsRenderableIteratorData *data = data_in;
@@ -2172,10 +2209,10 @@ void BKE_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
data->iter.set = NULL;
iter->data = data_in;
- BKE_renderable_objects_iterator_next(iter);
+ BKE_view_layer_renderable_objects_iterator_next(iter);
}
-void BKE_renderable_objects_iterator_next(BLI_Iterator *iter)
+void BKE_view_layer_renderable_objects_iterator_next(BLI_Iterator *iter)
{
/* Set it early in case we need to exit and we are running from within a loop. */
iter->skip = true;
@@ -2230,11 +2267,68 @@ void BKE_renderable_objects_iterator_next(BLI_Iterator *iter)
iter->valid = false;
}
-void BKE_renderable_objects_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_renderable_objects_iterator_end(BLI_Iterator *UNUSED(iter))
{
/* Do nothing - iter->data was static allocated, we can't free it. */
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name BKE_view_layer_bases_in_mode_iterator
+ * \{ */
+
+void BKE_view_layer_bases_in_mode_iterator_begin(BLI_Iterator *iter, void *data_in)
+{
+ struct ObjectsInModeIteratorData *data = data_in;
+ Base *base = data->base_active;
+
+ /* when there are no objects */
+ if (base == NULL) {
+ iter->valid = false;
+ return;
+ }
+ iter->data = data_in;
+ iter->current = base;
+}
+
+void BKE_view_layer_bases_in_mode_iterator_next(BLI_Iterator *iter)
+{
+ struct ObjectsInModeIteratorData *data = iter->data;
+ Base *base = iter->current;
+
+ if (base == data->base_active) {
+ /* first step */
+ base = data->view_layer->object_bases.first;
+ if (base == data->base_active) {
+ base = base->next;
+ }
+ }
+ else {
+ base = base->next;
+ }
+
+ while (base) {
+ if ((base->flag & BASE_SELECTED) != 0 &&
+ (base->object->type == data->base_active->object->type) &&
+ (base != data->base_active) &&
+ (base->object->mode & data->object_mode))
+ {
+ iter->current = base;
+ return;
+ }
+ base = base->next;
+ }
+ iter->valid = false;
+}
+
+void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *UNUSED(iter))
+{
+ /* do nothing */
+}
+
+/** \} */
+
/* Evaluation */
/**
@@ -2285,13 +2379,13 @@ static const char *collection_type_lookup[] =
* \note We can't use layer_collection->flag because of 3 level nesting (where parent is visible, but not grand-parent)
* So layer_collection->flag_evaluated is expected to be up to date with layer_collection->flag.
*/
-static bool layer_collection_visible_get(const EvaluationContext *eval_ctx, LayerCollection *layer_collection)
+static bool layer_collection_visible_get(Depsgraph *depsgraph, LayerCollection *layer_collection)
{
if (layer_collection->flag_evaluated & COLLECTION_DISABLED) {
return false;
}
- if (eval_ctx->mode == DAG_EVAL_VIEWPORT) {
+ if (DEG_get_mode(depsgraph) == DAG_EVAL_VIEWPORT) {
return (layer_collection->flag_evaluated & COLLECTION_VIEWPORT) != 0;
}
else {
@@ -2299,7 +2393,7 @@ static bool layer_collection_visible_get(const EvaluationContext *eval_ctx, Laye
}
}
-static void layer_eval_layer_collection(const EvaluationContext *eval_ctx,
+static void layer_eval_layer_collection(Depsgraph *depsgraph,
LayerCollection *layer_collection,
LayerCollection *parent_layer_collection)
{
@@ -2320,7 +2414,7 @@ static void layer_eval_layer_collection(const EvaluationContext *eval_ctx,
layer_collection->flag_evaluated = layer_collection->flag;
if (parent_layer_collection != NULL) {
- if (layer_collection_visible_get(eval_ctx, parent_layer_collection) == false) {
+ if (layer_collection_visible_get(depsgraph, parent_layer_collection) == false) {
layer_collection->flag_evaluated |= COLLECTION_DISABLED;
}
@@ -2331,7 +2425,7 @@ static void layer_eval_layer_collection(const EvaluationContext *eval_ctx,
}
}
- const bool is_visible = layer_collection_visible_get(eval_ctx, layer_collection);
+ const bool is_visible = layer_collection_visible_get(depsgraph, layer_collection);
const bool is_selectable = is_visible && ((layer_collection->flag_evaluated & COLLECTION_SELECTABLE) != 0);
/* overrides */
@@ -2378,7 +2472,7 @@ static void layer_eval_layer_collection_post(ViewLayer *view_layer)
}
}
-static void layer_eval_collections_recurse(const EvaluationContext *eval_ctx,
+static void layer_eval_collections_recurse(Depsgraph *depsgraph,
ListBase *layer_collections,
LayerCollection *parent_layer_collection)
{
@@ -2386,27 +2480,27 @@ static void layer_eval_collections_recurse(const EvaluationContext *eval_ctx,
layer_collection != NULL;
layer_collection = layer_collection->next)
{
- layer_eval_layer_collection(eval_ctx,
+ layer_eval_layer_collection(depsgraph,
layer_collection,
parent_layer_collection);
- layer_eval_collections_recurse(eval_ctx,
+ layer_eval_collections_recurse(depsgraph,
&layer_collection->layer_collections,
layer_collection);
}
}
-void BKE_layer_eval_view_layer(const struct EvaluationContext *eval_ctx,
+void BKE_layer_eval_view_layer(struct Depsgraph *depsgraph,
struct ID *owner_id,
ViewLayer *view_layer)
{
layer_eval_layer_collection_pre(owner_id, view_layer);
- layer_eval_collections_recurse(eval_ctx,
+ layer_eval_collections_recurse(depsgraph,
&view_layer->layer_collections,
NULL);
layer_eval_layer_collection_post(view_layer);
}
-void BKE_layer_eval_view_layer_indexed(const struct EvaluationContext *eval_ctx,
+void BKE_layer_eval_view_layer_indexed(struct Depsgraph *depsgraph,
struct ID *owner_id,
int view_layer_index)
{
@@ -2415,7 +2509,7 @@ void BKE_layer_eval_view_layer_indexed(const struct EvaluationContext *eval_ctx,
Scene *scene = (Scene *)owner_id;
ViewLayer *view_layer = BLI_findlink(&scene->view_layers, view_layer_index);
BLI_assert(view_layer != NULL);
- BKE_layer_eval_view_layer(eval_ctx, owner_id, view_layer);
+ BKE_layer_eval_view_layer(depsgraph, owner_id, view_layer);
}
/**
diff --git a/source/blender/blenkernel/intern/layer_utils.c b/source/blender/blenkernel/intern/layer_utils.c
new file mode 100644
index 00000000000..94bac8a33d6
--- /dev/null
+++ b/source/blender/blenkernel/intern/layer_utils.c
@@ -0,0 +1,125 @@
+/*
+ * ***** 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 blender/blenkernel/intern/layer_utils.c
+ * \ingroup bke
+ */
+
+#include <string.h>
+
+#include "BLI_array.h"
+#include "BLI_listbase.h"
+
+#include "BKE_collection.h"
+#include "BKE_editmesh.h"
+#include "BKE_layer.h"
+
+#include "DNA_ID.h"
+#include "DNA_layer_types.h"
+#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_scene_types.h"
+
+#include "MEM_guardedalloc.h"
+
+Base **BKE_view_layer_array_from_bases_in_mode_params(
+ ViewLayer *view_layer, uint *r_len,
+ const struct ObjectsInModeParams *params)
+{
+ if (params->no_dup_data) {
+ FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) {
+ ID *id = base_iter->object->data;
+ if (id) {
+ id->tag |= LIB_TAG_DOIT;
+ }
+ } FOREACH_BASE_IN_MODE_END;
+ }
+
+ Base **base_array = NULL;
+ BLI_array_declare(base_array);
+
+ FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) {
+ if (params->filter_fn) {
+ if (!params->filter_fn(base_iter->object, params->filter_userdata)) {
+ continue;
+ }
+ }
+ if (params->no_dup_data) {
+ ID *id = base_iter->object->data;
+ if (id) {
+ if (id->tag & LIB_TAG_DOIT) {
+ id->tag &= ~LIB_TAG_DOIT;
+ }
+ else {
+ continue;
+ }
+ }
+ }
+ BLI_array_append(base_array, base_iter);
+ } FOREACH_BASE_IN_MODE_END;
+
+ if (base_array != NULL) {
+ base_array = MEM_reallocN(base_array, sizeof(*base_array) * BLI_array_len(base_array));
+ }
+ *r_len = BLI_array_len(base_array);
+ return base_array;
+}
+
+Object **BKE_view_layer_array_from_objects_in_mode_params(
+ ViewLayer *view_layer, uint *r_len,
+ const struct ObjectsInModeParams *params)
+{
+ Base **base_array = BKE_view_layer_array_from_bases_in_mode_params(
+ view_layer, r_len, params);
+ if (base_array != NULL) {
+ for (uint i = 0; i < *r_len; i++) {
+ ((Object **)base_array)[i] = base_array[i]->object;
+ }
+ }
+ return (Object **)base_array;
+}
+
+bool BKE_view_layer_filter_edit_mesh_has_uvs(Object *ob, void *UNUSED(user_data))
+{
+ if (ob->type == OB_MESH) {
+ Mesh *me = ob->data;
+ BMEditMesh *em = me->edit_btmesh;
+ if (em != NULL) {
+ if (CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV) != -1) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool BKE_view_layer_filter_edit_mesh_has_edges(Object *ob, void *UNUSED(user_data))
+{
+ if (ob->type == OB_MESH) {
+ Mesh *me = ob->data;
+ BMEditMesh *em = me->edit_btmesh;
+ if (em != NULL) {
+ if (em->bm->totedge != 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index f7f0991238f..6ff4a29d403 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1481,7 +1481,6 @@ void BKE_library_free(Library *lib)
Main *BKE_main_new(void)
{
Main *bmain = MEM_callocN(sizeof(Main), "new main");
- bmain->eval_ctx = DEG_evaluation_context_new(DAG_EVAL_VIEWPORT);
bmain->lock = MEM_mallocN(sizeof(SpinLock), "main lock");
BLI_spin_init((SpinLock *)bmain->lock);
return bmain;
@@ -1556,7 +1555,6 @@ void BKE_main_free(Main *mainvar)
BLI_spin_end((SpinLock *)mainvar->lock);
MEM_freeN(mainvar->lock);
- DEG_evaluation_context_free(mainvar->eval_ctx);
MEM_freeN(mainvar);
}
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 8b8658921b5..625af190bbc 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -86,7 +86,7 @@ IDOverrideStatic *BKE_override_static_init(ID *local_id, ID *reference_id)
local_id->override_static = MEM_callocN(sizeof(*local_id->override_static), __func__);
local_id->override_static->reference = reference_id;
id_us_plus(local_id->override_static->reference);
- local_id->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
+ local_id->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
/* TODO do we want to add tag or flag to referee to mark it as such? */
return local_id->override_static;
}
@@ -125,7 +125,7 @@ void BKE_override_static_copy(ID *dst_id, const ID *src_id)
bke_override_property_copy(op_dst, op_src);
}
- dst_id->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
+ dst_id->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
}
/** Clear any overriding data from given \a override. */
@@ -445,7 +445,7 @@ bool BKE_override_static_status_check_local(ID *local)
&rnaptr_local, &rnaptr_reference, NULL, local->override_static,
RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE | RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN, NULL))
{
- local->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
+ local->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
return false;
}
@@ -474,12 +474,12 @@ bool BKE_override_static_status_check_reference(ID *local)
BLI_assert(GS(local->name) == GS(reference->name));
- if (reference->override_static && (reference->tag & LIB_TAG_OVERRIDESTATIC_OK) == 0) {
+ if (reference->override_static && (reference->tag & LIB_TAG_OVERRIDESTATIC_REFOK) == 0) {
if (!BKE_override_static_status_check_reference(reference)) {
/* If reference is also override of another data-block, and its status is not OK,
* then this override is not OK either.
* Note that this should only happen when reloading libraries... */
- local->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
+ local->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
return false;
}
}
@@ -492,7 +492,7 @@ bool BKE_override_static_status_check_reference(ID *local)
&rnaptr_local, &rnaptr_reference, NULL, local->override_static,
RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN, NULL))
{
- local->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
+ local->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
return false;
}
@@ -510,14 +510,14 @@ bool BKE_override_static_status_check_reference(ID *local)
* all properties in depth (all overridable ones at least). Generating diff values and applying overrides
* are much cheaper.
*
- * \return true is new overriding op was created, or some local data was reset. */
-bool BKE_override_static_operations_create(ID *local)
+ * \return true if new overriding op was created, or some local data was reset. */
+bool BKE_override_static_operations_create(ID *local, const bool force_auto)
{
BLI_assert(local->override_static != NULL);
const bool is_template = (local->override_static->reference == NULL);
bool ret = false;
- if (!is_template && local->flag & LIB_OVERRIDE_STATIC_AUTO) {
+ if (!is_template && (force_auto || local->flag & LIB_OVERRIDE_STATIC_AUTO)) {
PointerRNA rnaptr_local, rnaptr_reference;
RNA_id_pointer_create(local, &rnaptr_local);
RNA_id_pointer_create(local->override_static->reference, &rnaptr_reference);
@@ -545,7 +545,7 @@ bool BKE_override_static_operations_create(ID *local)
}
/** Check all overrides from given \a bmain and create/update overriding operations as needed. */
-void BKE_main_override_static_operations_create(Main *bmain)
+void BKE_main_override_static_operations_create(Main *bmain, const bool force_auto)
{
ListBase *lbarray[MAX_LIBARRAY];
int base_count, i;
@@ -557,9 +557,11 @@ void BKE_main_override_static_operations_create(Main *bmain)
ID *id;
for (id = lb->first; id; id = id->next) {
- /* TODO Maybe we could also add an 'override update' tag e.g. when tagging for DEG update? */
- if (id->lib == NULL && id->override_static != NULL && id->override_static->reference != NULL && (id->flag & LIB_OVERRIDE_STATIC_AUTO)) {
- BKE_override_static_operations_create(id);
+ if (force_auto ||
+ (ID_IS_STATIC_OVERRIDE_AUTO(id) && (id->tag & LIB_TAG_OVERRIDESTATIC_AUTOREFRESH)))
+ {
+ BKE_override_static_operations_create(id, force_auto);
+ id->tag &= ~LIB_TAG_OVERRIDESTATIC_AUTOREFRESH;
}
}
}
@@ -573,7 +575,7 @@ void BKE_override_static_update(Main *bmain, ID *local)
}
/* Recursively do 'ancestors' overrides first, if any. */
- if (local->override_static->reference->override_static && (local->override_static->reference->tag & LIB_TAG_OVERRIDESTATIC_OK) == 0) {
+ if (local->override_static->reference->override_static && (local->override_static->reference->tag & LIB_TAG_OVERRIDESTATIC_REFOK) == 0) {
BKE_override_static_update(bmain, local->override_static->reference);
}
@@ -624,7 +626,7 @@ void BKE_override_static_update(Main *bmain, ID *local)
local->override_static->storage = NULL;
}
- local->tag |= LIB_TAG_OVERRIDESTATIC_OK;
+ local->tag |= LIB_TAG_OVERRIDESTATIC_REFOK;
/* Full rebuild of Depsgraph! */
DEG_on_visible_update(bmain, true); /* XXX Is this actual valid replacement for old DAG_relations_tag_update(bmain) ? */
@@ -686,7 +688,7 @@ ID *BKE_override_static_operations_store_start(OverrideStaticStorage *override_s
}
/* Forcefully ensure we know about all needed override operations. */
- BKE_override_static_operations_create(local);
+ BKE_override_static_operations_create(local, false);
ID *storage_id;
#ifdef DEBUG_OVERRIDE_TIMEIT
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 953db6f3cb0..3bd94b9ab47 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -31,13 +31,11 @@
#include "MEM_guardedalloc.h"
-#include "DNA_actuator_types.h"
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_brush_types.h"
#include "DNA_camera_types.h"
#include "DNA_constraint_types.h"
-#include "DNA_controller_types.h"
#include "DNA_groom_types.h"
#include "DNA_group_types.h"
#include "DNA_gpencil_types.h"
@@ -56,7 +54,6 @@
#include "DNA_lightprobe_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
-#include "DNA_sensor_types.h"
#include "DNA_sequence_types.h"
#include "DNA_screen_types.h"
#include "DNA_speaker_types.h"
@@ -85,7 +82,6 @@
#include "BKE_node.h"
#include "BKE_particle.h"
#include "BKE_rigidbody.h"
-#include "BKE_sca.h"
#include "BKE_sequencer.h"
#include "BKE_tracking.h"
#include "BKE_workspace.h"
@@ -220,33 +216,6 @@ static void library_foreach_particlesystemsObjectLooper(
FOREACH_FINALIZE_VOID;
}
-static void library_foreach_sensorsObjectLooper(
- bSensor *UNUSED(sensor), ID **id_pointer, void *user_data, int cb_flag)
-{
- LibraryForeachIDData *data = (LibraryForeachIDData *) user_data;
- FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag);
-
- FOREACH_FINALIZE_VOID;
-}
-
-static void library_foreach_controllersObjectLooper(
- bController *UNUSED(controller), ID **id_pointer, void *user_data, int cb_flag)
-{
- LibraryForeachIDData *data = (LibraryForeachIDData *) user_data;
- FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag);
-
- FOREACH_FINALIZE_VOID;
-}
-
-static void library_foreach_actuatorsObjectLooper(
- bActuator *UNUSED(actuator), ID **id_pointer, void *user_data, int cb_flag)
-{
- LibraryForeachIDData *data = (LibraryForeachIDData *) user_data;
- FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pointer, cb_flag);
-
- FOREACH_FINALIZE_VOID;
-}
-
static void library_foreach_nla_strip(LibraryForeachIDData *data, NlaStrip *strip)
{
NlaStrip *substrip;
@@ -477,8 +446,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
}
if (toolsett) {
- CALLBACK_INVOKE(toolsett->skgen_template, IDWALK_CB_NOP);
-
CALLBACK_INVOKE(toolsett->particle.scene, IDWALK_CB_NOP);
CALLBACK_INVOKE(toolsett->particle.object, IDWALK_CB_NOP);
CALLBACK_INVOKE(toolsett->particle.shape_object, IDWALK_CB_NOP);
@@ -507,8 +474,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
BKE_rigidbody_world_id_loop(scene->rigidbody_world, library_foreach_rigidbodyworldSceneLooper, &data);
}
- CALLBACK_INVOKE(scene->gm.dome.warptext, IDWALK_CB_NOP);
-
break;
}
@@ -606,10 +571,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
CALLBACK_INVOKE(object->soft->effector_weights->group, IDWALK_CB_NOP);
}
}
-
- BKE_sca_sensors_id_loop(&object->sensors, library_foreach_sensorsObjectLooper, &data);
- BKE_sca_controllers_id_loop(&object->controllers, library_foreach_controllersObjectLooper, &data);
- BKE_sca_actuators_id_loop(&object->actuators, library_foreach_actuatorsObjectLooper, &data);
break;
}
@@ -670,17 +631,10 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
case ID_MA:
{
Material *material = (Material *) id;
- for (i = 0; i < MAX_MTEX; i++) {
- if (material->mtex[i]) {
- library_foreach_mtex(&data, material->mtex[i]);
- }
- }
if (material->nodetree) {
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
library_foreach_ID_as_subdata_link((ID **)&material->nodetree, callback, user_data, flag, &data);
}
- CALLBACK_INVOKE(material->group, IDWALK_CB_USER);
- CALLBACK_INVOKE(material->edit_image, IDWALK_CB_USER);
if (material->texpaintslot != NULL) {
CALLBACK_INVOKE(material->texpaintslot->ima, IDWALK_CB_NOP);
}
@@ -695,16 +649,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
library_foreach_ID_as_subdata_link((ID **)&texture->nodetree, callback, user_data, flag, &data);
}
CALLBACK_INVOKE(texture->ima, IDWALK_CB_USER);
- if (texture->env) {
- CALLBACK_INVOKE(texture->env->object, IDWALK_CB_NOP);
- CALLBACK_INVOKE(texture->env->ima, IDWALK_CB_USER);
- }
- if (texture->pd)
- CALLBACK_INVOKE(texture->pd->object, IDWALK_CB_NOP);
- if (texture->vd)
- CALLBACK_INVOKE(texture->vd->object, IDWALK_CB_NOP);
- if (texture->ot)
- CALLBACK_INVOKE(texture->ot->object, IDWALK_CB_NOP);
break;
}
@@ -718,11 +662,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
case ID_LA:
{
Lamp *lamp = (Lamp *) id;
- for (i = 0; i < MAX_MTEX; i++) {
- if (lamp->mtex[i]) {
- library_foreach_mtex(&data, lamp->mtex[i]);
- }
- }
if (lamp->nodetree) {
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
library_foreach_ID_as_subdata_link((ID **)&lamp->nodetree, callback, user_data, flag, &data);
@@ -747,11 +686,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
case ID_WO:
{
World *world = (World *) id;
- for (i = 0; i < MAX_MTEX; i++) {
- if (world->mtex[i]) {
- library_foreach_mtex(&data, world->mtex[i]);
- }
- }
if (world->nodetree) {
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
library_foreach_ID_as_subdata_link((ID **)&world->nodetree, callback, user_data, flag, &data);
@@ -1092,7 +1026,7 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
#if 0
return ELEM(id_type_used, ID_ME, ID_CU, ID_MB, ID_LT, ID_SPK, ID_AR, ID_LA, ID_CA, /* obdata */
ID_OB, ID_MA, ID_GD, ID_GR, ID_TE, ID_PA, ID_TXT, ID_SO, ID_MC, ID_IM, ID_AC
- /* + constraints, modifiers and game logic ID types... */);
+ /* + constraints and modifiers ... */);
#else
return true;
#endif
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 2c6df24f762..d2d97404c45 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -106,7 +106,6 @@
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_lightprobe.h"
-#include "BKE_sca.h"
#include "BKE_speaker.h"
#include "BKE_sound.h"
#include "BKE_screen.h"
@@ -508,10 +507,6 @@ ATTR_NONNULL(1) static void libblock_remap_data(
}
}
- if (old_id && GS(old_id->name) == ID_OB) {
- BKE_sca_logic_links_remap(bmain, (Object *)old_id, (Object *)new_id);
- }
-
/* XXX We may not want to always 'transfer' fakeuser from old to new id... Think for now it's desired behavior
* though, we can always add an option (flag) to control this later if needed. */
if (old_id && (old_id->flag & LIB_FAKEUSER)) {
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index 61c136d2c4f..651bcddc84a 100644
--- a/source/blender/blenkernel/intern/mask_evaluate.c
+++ b/source/blender/blenkernel/intern/mask_evaluate.c
@@ -40,11 +40,13 @@
#include "BLI_math.h"
#include "DNA_mask_types.h"
+#include "DNA_object_types.h"
#include "BKE_curve.h"
#include "BKE_mask.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
{
@@ -896,24 +898,26 @@ void BKE_mask_layer_evaluate_deform(MaskLayer *masklay, const float ctime)
}
}
-void BKE_mask_eval_animation(struct EvaluationContext *eval_ctx, Mask *mask)
+void BKE_mask_eval_animation(struct Depsgraph *depsgraph, Mask *mask)
{
+ float ctime = DEG_get_ctime(depsgraph);
DEG_debug_print_eval(__func__, mask->id.name, mask);
for (MaskLayer *mask_layer = mask->masklayers.first;
mask_layer != NULL;
mask_layer = mask_layer->next)
{
- BKE_mask_layer_evaluate_animation(mask_layer, eval_ctx->ctime);
+ BKE_mask_layer_evaluate_animation(mask_layer, ctime);
}
}
-void BKE_mask_eval_update(struct EvaluationContext *eval_ctx, Mask *mask)
+void BKE_mask_eval_update(struct Depsgraph *depsgraph, Mask *mask)
{
+ float ctime = DEG_get_ctime(depsgraph);
DEG_debug_print_eval(__func__, mask->id.name, mask);
for (MaskLayer *mask_layer = mask->masklayers.first;
mask_layer != NULL;
mask_layer = mask_layer->next)
{
- BKE_mask_layer_evaluate_deform(mask_layer, eval_ctx->ctime);
+ BKE_mask_layer_evaluate_deform(mask_layer, ctime);
}
}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 2971f56c775..39ad95e9183 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -89,17 +89,8 @@ void init_def_material(void)
/** Free (or release) any data used by this material (does not free the material itself). */
void BKE_material_free(Material *ma)
{
- int a;
-
BKE_animdata_free((ID *)ma, false);
- for (a = 0; a < MAX_MTEX; a++) {
- MEM_SAFE_FREE(ma->mtex[a]);
- }
-
- MEM_SAFE_FREE(ma->ramp_col);
- MEM_SAFE_FREE(ma->ramp_spec);
-
/* Free gpu material before the ntree */
GPU_material_free(&ma->gpumaterial);
@@ -120,94 +111,16 @@ void BKE_material_init(Material *ma)
{
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ma, id));
- ma->r = ma->g = ma->b = ma->ref = 0.8;
+ ma->r = ma->g = ma->b = 0.8;
ma->specr = ma->specg = ma->specb = 1.0;
- ma->mirr = ma->mirg = ma->mirb = 1.0;
- ma->spectra = 1.0;
- ma->amb = 1.0;
ma->alpha = 1.0;
- ma->spec = ma->hasize = 0.5;
- ma->har = 50;
- ma->starc = ma->ringc = 4;
- ma->linec = 12;
- ma->flarec = 1;
- ma->flaresize = ma->subsize = 1.0;
- ma->flareboost = 1;
- ma->seed2 = 6;
- ma->friction = 0.5;
- ma->refrac = 4.0;
- ma->roughness = 0.5;
- ma->param[0] = 0.5;
- ma->param[1] = 0.1;
- ma->param[2] = 0.5;
- ma->param[3] = 0.1;
- ma->rms = 0.1;
- ma->darkness = 1.0;
-
- ma->strand_sta = ma->strand_end = 1.0f;
-
- ma->ang = 1.0;
- ma->ray_depth = 2;
- ma->ray_depth_tra = 2;
- ma->fresnel_mir = 0.0;
- ma->fresnel_tra = 0.0;
- ma->fresnel_tra_i = 1.25;
- ma->fresnel_mir_i = 1.25;
- ma->tx_limit = 0.0;
- ma->tx_falloff = 1.0;
- ma->shad_alpha = 1.0f;
- ma->vcol_alpha = 0;
-
- ma->gloss_mir = ma->gloss_tra = 1.0;
- ma->samp_gloss_mir = ma->samp_gloss_tra = 18;
- ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005;
- ma->dist_mir = 0.0;
- ma->fadeto_mir = MA_RAYMIR_FADETOSKY;
+ ma->spec = 0.5;
+
+ ma->gloss_mir = 1.0;
- ma->rampfac_col = 1.0;
- ma->rampfac_spec = 1.0;
ma->pr_lamp = 3; /* two lamps, is bits */
ma->pr_type = MA_SPHERE;
- ma->sss_radius[0] = 1.0f;
- ma->sss_radius[1] = 1.0f;
- ma->sss_radius[2] = 1.0f;
- ma->sss_col[0] = 1.0f;
- ma->sss_col[1] = 1.0f;
- ma->sss_col[2] = 1.0f;
- ma->sss_error = 0.05f;
- ma->sss_scale = 0.1f;
- ma->sss_ior = 1.3f;
- ma->sss_colfac = 1.0f;
- ma->sss_texfac = 0.0f;
- ma->sss_front = 1.0f;
- ma->sss_back = 1.0f;
-
- ma->vol.density = 1.0f;
- ma->vol.emission = 0.0f;
- ma->vol.scattering = 1.0f;
- ma->vol.reflection = 1.0f;
- ma->vol.transmission_col[0] = ma->vol.transmission_col[1] = ma->vol.transmission_col[2] = 1.0f;
- ma->vol.reflection_col[0] = ma->vol.reflection_col[1] = ma->vol.reflection_col[2] = 1.0f;
- ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f;
- ma->vol.density_scale = 1.0f;
- ma->vol.depth_cutoff = 0.01f;
- ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED;
- ma->vol.stepsize = 0.2f;
- ma->vol.shade_type = MA_VOL_SHADE_SHADED;
- ma->vol.shadeflag |= MA_VOL_PRECACHESHADING;
- ma->vol.precache_resolution = 50;
- ma->vol.ms_spread = 0.2f;
- ma->vol.ms_diff = 1.f;
- ma->vol.ms_intensity = 1.f;
-
- ma->game.flag = GEMAT_BACKCULL;
- ma->game.alpha_blend = 0;
- ma->game.face_orientation = 0;
-
- ma->mode = MA_TRACEBLE | MA_SHADBUF | MA_SHADOW | MA_RAYBIAS | MA_TANGENT_STR | MA_ZTRANSP;
- ma->mode2 = MA_CASTSHADOW;
- ma->shade_flag = MA_APPROX_OCCLUSION;
ma->preview = NULL;
ma->alpha_threshold = 0.5f;
@@ -234,20 +147,6 @@ Material *BKE_material_add(Main *bmain, const char *name)
*/
void BKE_material_copy_data(Main *bmain, Material *ma_dst, const Material *ma_src, const int flag)
{
- for (int a = 0; a < MAX_MTEX; a++) {
- if (ma_src->mtex[a]) {
- ma_dst->mtex[a] = MEM_mallocN(sizeof(*ma_dst->mtex[a]), __func__);
- *ma_dst->mtex[a] = *ma_src->mtex[a];
- }
- }
-
- if (ma_src->ramp_col) {
- ma_dst->ramp_col = MEM_dupallocN(ma_src->ramp_col);
- }
- if (ma_src->ramp_spec) {
- ma_dst->ramp_spec = MEM_dupallocN(ma_src->ramp_spec);
- }
-
if (ma_src->nodetree) {
/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
* (see BKE_libblock_copy_ex()). */
@@ -288,21 +187,9 @@ Material *BKE_material_localize(Material *ma)
* ... Once f*** nodes are fully converted to that too :( */
Material *man;
- int a;
man = BKE_libblock_copy_nolib(&ma->id, false);
- /* no increment for texture ID users, in previewrender.c it prevents decrement */
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- man->mtex[a] = MEM_mallocN(sizeof(MTex), "copymaterial");
- memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
- }
- }
-
- if (ma->ramp_col) man->ramp_col = MEM_dupallocN(ma->ramp_col);
- if (ma->ramp_spec) man->ramp_spec = MEM_dupallocN(ma->ramp_spec);
-
man->texpaintslot = NULL;
man->preview = NULL;
@@ -945,221 +832,6 @@ bool BKE_object_material_slot_add(Object *ob)
return true;
}
-static void do_init_render_material(Material *ma, int r_mode, float *amb)
-{
- MTex *mtex;
- int a, needuv = 0, needtang = 0;
-
- if (ma->flarec == 0) ma->flarec = 1;
-
- /* add all texcoflags from mtex, texco and mapto were cleared in advance */
- for (a = 0; a < MAX_MTEX; a++) {
-
- /* separate tex switching */
- if (ma->septex & (1 << a)) continue;
-
- mtex = ma->mtex[a];
- if (mtex && mtex->tex && (mtex->tex->type | (mtex->tex->use_nodes && mtex->tex->nodetree) )) {
-
- ma->texco |= mtex->texco;
- ma->mapto |= mtex->mapto;
-
- /* always get derivatives for these textures */
- if (ELEM(mtex->tex->type, TEX_IMAGE, TEX_ENVMAP)) ma->texco |= TEXCO_OSA;
- else if (mtex->texflag & (MTEX_COMPAT_BUMP | MTEX_3TAP_BUMP | MTEX_5TAP_BUMP | MTEX_BICUBIC_BUMP)) ma->texco |= TEXCO_OSA;
-
- if (ma->texco & (TEXCO_ORCO | TEXCO_REFL | TEXCO_NORM | TEXCO_STRAND | TEXCO_STRESS)) needuv = 1;
- else if (ma->texco & (TEXCO_GLOB | TEXCO_UV | TEXCO_OBJECT | TEXCO_SPEED)) needuv = 1;
- else if (ma->texco & (TEXCO_LAVECTOR | TEXCO_VIEW)) needuv = 1;
-
- if ((ma->mapto & MAP_NORM) && (mtex->normapspace == MTEX_NSPACE_TANGENT))
- needtang = 1;
- }
- }
-
- if (needtang) ma->mode |= MA_NORMAP_TANG;
- else ma->mode &= ~MA_NORMAP_TANG;
-
- if (ma->mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) {
- needuv = 1;
- if (r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */
- }
- if (needuv) ma->texco |= NEED_UV;
-
- /* since the raytracer doesnt recalc O structs for each ray, we have to preset them all */
- if (r_mode & R_RAYTRACE) {
- if ((ma->mode & (MA_RAYMIRROR | MA_SHADOW_TRA)) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) {
- ma->texco |= NEED_UV | TEXCO_ORCO | TEXCO_REFL | TEXCO_NORM;
- if (r_mode & R_OSA) ma->texco |= TEXCO_OSA;
- }
- }
-
- if (amb) {
- ma->ambr = ma->amb * amb[0];
- ma->ambg = ma->amb * amb[1];
- ma->ambb = ma->amb * amb[2];
- }
-
- /* local group override */
- if ((ma->shade_flag & MA_GROUP_LOCAL) && ma->id.lib && ma->group && ma->group->id.lib) {
- Group *group;
-
- for (group = G.main->group.first; group; group = group->id.next) {
- if (!ID_IS_LINKED(group) && STREQ(group->id.name, ma->group->id.name)) {
- ma->group = group;
- }
- }
- }
-}
-
-static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode, float *amb)
-{
- bNode *node;
-
- /* parses the geom+tex nodes */
- ntreeShaderGetTexcoMode(ntree, r_mode, &basemat->texco, &basemat->mode_l);
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->id) {
- if (GS(node->id->name) == ID_MA) {
- Material *ma = (Material *)node->id;
- if (ma != basemat) {
- do_init_render_material(ma, r_mode, amb);
- basemat->texco |= ma->texco;
- }
-
- basemat->mode_l |= ma->mode & ~(MA_MODE_PIPELINE | MA_SHLESS);
- basemat->mode2_l |= ma->mode2 & ~MA_MODE2_PIPELINE;
- /* basemat only considered shadeless if all node materials are too */
- if (!(ma->mode & MA_SHLESS))
- basemat->mode_l &= ~MA_SHLESS;
-
- if (ma->strand_surfnor > 0.0f)
- basemat->mode_l |= MA_STR_SURFDIFF;
- }
- else if (node->type == NODE_GROUP)
- init_render_nodetree((bNodeTree *)node->id, basemat, r_mode, amb);
- }
- else if (node->typeinfo->type == SH_NODE_NORMAL_MAP) {
- basemat->mode2_l |= MA_TANGENT_CONCRETE;
- NodeShaderNormalMap *nm = node->storage;
- bool taken_into_account = false;
- for (int i = 0; i < basemat->nmap_tangent_names_count; i++) {
- if (STREQ(basemat->nmap_tangent_names[i], nm->uv_map)) {
- taken_into_account = true;
- break;
- }
- }
- if (!taken_into_account) {
- BLI_assert(basemat->nmap_tangent_names_count < MAX_MTFACE + 1);
- strcpy(basemat->nmap_tangent_names[basemat->nmap_tangent_names_count++], nm->uv_map);
- }
- }
- }
-}
-
-void init_render_material(Material *mat, int r_mode, float *amb)
-{
-
- do_init_render_material(mat, r_mode, amb);
-
- if (mat->nodetree && mat->use_nodes) {
- /* mode_l will take the pipeline options from the main material, and the or-ed
- * result of non-pipeline options from the nodes. shadeless is an exception,
- * mode_l will have it set when all node materials are shadeless. */
- mat->mode_l = (mat->mode & MA_MODE_PIPELINE) | MA_SHLESS;
- mat->mode2_l = mat->mode2 & MA_MODE2_PIPELINE;
- mat->nmap_tangent_names_count = 0;
- init_render_nodetree(mat->nodetree, mat, r_mode, amb);
-
- if (!mat->nodetree->execdata)
- mat->nodetree->execdata = ntreeShaderBeginExecTree(mat->nodetree);
- }
- else {
- mat->mode_l = mat->mode;
- mat->mode2_l = mat->mode2;
-
- if (mat->strand_surfnor > 0.0f)
- mat->mode_l |= MA_STR_SURFDIFF;
- }
-}
-
-void init_render_materials(Main *bmain, int r_mode, float *amb, bool do_default_material)
-{
- Material *ma;
-
- /* clear these flags before going over materials, to make sure they
- * are cleared only once, otherwise node materials contained in other
- * node materials can go wrong */
- for (ma = bmain->mat.first; ma; ma = ma->id.next) {
- if (ma->id.us) {
- ma->texco = 0;
- ma->mapto = 0;
- }
- }
-
- /* two steps, first initialize, then or the flags for layers */
- for (ma = bmain->mat.first; ma; ma = ma->id.next) {
- /* is_used flag comes back in convertblender.c */
- ma->flag &= ~MA_IS_USED;
- if (ma->id.us)
- init_render_material(ma, r_mode, amb);
- }
-
- if (do_default_material) {
- init_render_material(&defmaterial, r_mode, amb);
- }
-}
-
-/* only needed for nodes now */
-void end_render_material(Material *mat)
-{
- if (mat && mat->nodetree && mat->use_nodes) {
- if (mat->nodetree->execdata)
- ntreeShaderEndExecTree(mat->nodetree->execdata);
- }
-}
-
-void end_render_materials(Main *bmain)
-{
- Material *ma;
- for (ma = bmain->mat.first; ma; ma = ma->id.next)
- if (ma->id.us)
- end_render_material(ma);
-}
-
-static bool material_in_nodetree(bNodeTree *ntree, Material *mat)
-{
- bNode *node;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->id) {
- if (GS(node->id->name) == ID_MA) {
- if (node->id == (ID *)mat) {
- return true;
- }
- }
- else if (node->type == NODE_GROUP) {
- if (material_in_nodetree((bNodeTree *)node->id, mat)) {
- return true;
- }
- }
- }
- }
-
- return false;
-}
-
-bool material_in_material(Material *parmat, Material *mat)
-{
- if (parmat == mat)
- return true;
- else if (parmat->nodetree && parmat->use_nodes)
- return material_in_nodetree(parmat->nodetree, mat);
- else
- return false;
-}
-
-
/* ****************** */
bool BKE_object_material_slot_remove(Object *ob)
@@ -1251,13 +923,6 @@ bool BKE_object_material_slot_remove(Object *ob)
return true;
}
-static bool get_mtex_slot_valid_texpaint(struct MTex *mtex)
-{
- return (mtex && (mtex->texco == TEXCO_UV) &&
- mtex->tex && (mtex->tex->type == TEX_IMAGE) &&
- mtex->tex->ima);
-}
-
static bNode *nodetree_uv_node_recursive(bNode *node)
{
bNode *inode;
@@ -1280,21 +945,9 @@ static bNode *nodetree_uv_node_recursive(bNode *node)
void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
{
- MTex **mtex;
short count = 0;
- short index = 0, i;
+ short index = 0;
- bool use_nodes = BKE_scene_use_new_shading_nodes(scene);
- bool is_bi = BKE_scene_uses_blender_internal(scene) || BKE_scene_uses_blender_game(scene);
-
- /* XXX, for 2.8 testing & development its useful to have non Cycles/BI engines use material nodes
- * In the future we may have some way to check this which each engine can define.
- * For now use material slots for Clay/Eevee.
- * - Campbell */
- if (!(use_nodes || is_bi)) {
- is_bi = true;
- }
-
if (!ma)
return;
@@ -1310,88 +963,50 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
return;
}
- if (use_nodes || ma->use_nodes) {
- bNode *node, *active_node;
-
- if (!(ma->nodetree)) {
- ma->paint_active_slot = 0;
- ma->paint_clone_slot = 0;
- return;
- }
+ bNode *node, *active_node;
- for (node = ma->nodetree->nodes.first; node; node = node->next) {
- if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id)
- count++;
- }
+ if (!(ma->nodetree)) {
+ ma->paint_active_slot = 0;
+ ma->paint_clone_slot = 0;
+ return;
+ }
- if (count == 0) {
- ma->paint_active_slot = 0;
- ma->paint_clone_slot = 0;
- return;
- }
- ma->texpaintslot = MEM_callocN(sizeof(*ma->texpaintslot) * count, "texpaint_slots");
-
- active_node = nodeGetActiveTexture(ma->nodetree);
-
- for (node = ma->nodetree->nodes.first; node; node = node->next) {
- if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
- if (active_node == node)
- ma->paint_active_slot = index;
- ma->texpaintslot[index].ima = (Image *)node->id;
-
- /* for new renderer, we need to traverse the treeback in search of a UV node */
- if (use_nodes) {
- bNode *uvnode = nodetree_uv_node_recursive(node);
-
- if (uvnode) {
- NodeShaderUVMap *storage = (NodeShaderUVMap *)uvnode->storage;
- ma->texpaintslot[index].uvname = storage->uv_map;
- /* set a value to index so UI knows that we have a valid pointer for the mesh */
- ma->texpaintslot[index].index = 0;
- }
- else {
- /* just invalidate the index here so UV map does not get displayed on the UI */
- ma->texpaintslot[index].index = -1;
- }
- }
- else {
- ma->texpaintslot[index].index = -1;
- }
- index++;
- }
- }
+ for (node = ma->nodetree->nodes.first; node; node = node->next) {
+ if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id)
+ count++;
}
- else if (is_bi) {
- for (mtex = ma->mtex, i = 0; i < MAX_MTEX; i++, mtex++) {
- if (get_mtex_slot_valid_texpaint(*mtex)) {
- count++;
- }
- }
- if (count == 0) {
- ma->paint_active_slot = 0;
- ma->paint_clone_slot = 0;
- return;
- }
+ if (count == 0) {
+ ma->paint_active_slot = 0;
+ ma->paint_clone_slot = 0;
+ return;
+ }
+ ma->texpaintslot = MEM_callocN(sizeof(*ma->texpaintslot) * count, "texpaint_slots");
- ma->texpaintslot = MEM_callocN(sizeof(*ma->texpaintslot) * count, "texpaint_slots");
+ active_node = nodeGetActiveTexture(ma->nodetree);
- for (mtex = ma->mtex, i = 0; i < MAX_MTEX; i++, mtex++) {
- if (get_mtex_slot_valid_texpaint(*mtex)) {
- ma->texpaintslot[index].ima = (*mtex)->tex->ima;
- ma->texpaintslot[index].uvname = (*mtex)->uvname;
- ma->texpaintslot[index].index = i;
-
- index++;
+ for (node = ma->nodetree->nodes.first; node; node = node->next) {
+ if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
+ if (active_node == node)
+ ma->paint_active_slot = index;
+ ma->texpaintslot[index].ima = (Image *)node->id;
+
+ /* for new renderer, we need to traverse the treeback in search of a UV node */
+ bNode *uvnode = nodetree_uv_node_recursive(node);
+
+ if (uvnode) {
+ NodeShaderUVMap *storage = (NodeShaderUVMap *)uvnode->storage;
+ ma->texpaintslot[index].uvname = storage->uv_map;
+ /* set a value to index so UI knows that we have a valid pointer for the mesh */
+ ma->texpaintslot[index].valid = true;
+ }
+ else {
+ /* just invalidate the index here so UV map does not get displayed on the UI */
+ ma->texpaintslot[index].valid = false;
}
+ index++;
}
}
- else {
- ma->paint_active_slot = 0;
- ma->paint_clone_slot = 0;
- return;
- }
-
ma->tot_slots = count;
@@ -1647,21 +1262,6 @@ void clear_matcopybuf(void)
void free_matcopybuf(void)
{
- int a;
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (matcopybuf.mtex[a]) {
- MEM_freeN(matcopybuf.mtex[a]);
- matcopybuf.mtex[a] = NULL;
- }
- }
-
- if (matcopybuf.ramp_col) MEM_freeN(matcopybuf.ramp_col);
- if (matcopybuf.ramp_spec) MEM_freeN(matcopybuf.ramp_spec);
-
- matcopybuf.ramp_col = NULL;
- matcopybuf.ramp_spec = NULL;
-
if (matcopybuf.nodetree) {
ntreeFreeTree(matcopybuf.nodetree);
MEM_freeN(matcopybuf.nodetree);
@@ -1673,22 +1273,11 @@ void free_matcopybuf(void)
void copy_matcopybuf(Material *ma)
{
- int a;
- MTex *mtex;
-
if (matcopied)
free_matcopybuf();
memcpy(&matcopybuf, ma, sizeof(Material));
- if (matcopybuf.ramp_col) matcopybuf.ramp_col = MEM_dupallocN(matcopybuf.ramp_col);
- if (matcopybuf.ramp_spec) matcopybuf.ramp_spec = MEM_dupallocN(matcopybuf.ramp_spec);
- for (a = 0; a < MAX_MTEX; a++) {
- mtex = matcopybuf.mtex[a];
- if (mtex) {
- matcopybuf.mtex[a] = MEM_dupallocN(mtex);
- }
- }
matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, G.main, false);
matcopybuf.preview = NULL;
BLI_listbase_clear(&matcopybuf.gpumaterial);
@@ -1698,22 +1287,10 @@ void copy_matcopybuf(Material *ma)
void paste_matcopybuf(Material *ma)
{
- int a;
- MTex *mtex;
ID id;
if (matcopied == 0)
return;
- /* free current mat */
- if (ma->ramp_col) MEM_freeN(ma->ramp_col);
- if (ma->ramp_spec) MEM_freeN(ma->ramp_spec);
- for (a = 0; a < MAX_MTEX; a++) {
- mtex = ma->mtex[a];
- if (mtex && mtex->tex)
- id_us_min(&mtex->tex->id);
- if (mtex)
- MEM_freeN(mtex);
- }
/* Free gpu material before the ntree */
GPU_material_free(&ma->gpumaterial);
@@ -1727,57 +1304,10 @@ void paste_matcopybuf(Material *ma)
memcpy(ma, &matcopybuf, sizeof(Material));
(ma->id) = id;
- if (matcopybuf.ramp_col) ma->ramp_col = MEM_dupallocN(matcopybuf.ramp_col);
- if (matcopybuf.ramp_spec) ma->ramp_spec = MEM_dupallocN(matcopybuf.ramp_spec);
-
- for (a = 0; a < MAX_MTEX; a++) {
- mtex = ma->mtex[a];
- if (mtex) {
- ma->mtex[a] = MEM_dupallocN(mtex);
- if (mtex->tex) {
- /* first check this is in main (we may have loaded another file) [#35500] */
- if (BLI_findindex(&G.main->tex, mtex->tex) != -1) {
- id_us_plus((ID *)mtex->tex);
- }
- else {
- ma->mtex[a]->tex = NULL;
- }
- }
- }
- }
-
ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, G.main, false);
}
-struct Image *BKE_object_material_edit_image_get(Object *ob, short mat_nr)
-{
- Material *ma = give_current_material(ob, mat_nr + 1);
- return ma ? ma->edit_image : NULL;
-}
-
-struct Image **BKE_object_material_edit_image_get_array(Object *ob)
-{
- Image **image_array = MEM_mallocN(sizeof(Material *) * ob->totcol, __func__);
- for (int i = 0; i < ob->totcol; i++) {
- image_array[i] = BKE_object_material_edit_image_get(ob, i);
- }
- return image_array;
-}
-
-bool BKE_object_material_edit_image_set(Object *ob, short mat_nr, Image *image)
-{
- Material *ma = give_current_material(ob, mat_nr + 1);
- if (ma) {
- /* both may be NULL */
- id_us_min((ID *)ma->edit_image);
- ma->edit_image = image;
- id_us_plus((ID *)ma->edit_image);
- return true;
- }
- return false;
-}
-
-void BKE_material_eval(const struct EvaluationContext *UNUSED(eval_ctx), Material *material)
+void BKE_material_eval(struct Depsgraph *UNUSED(depsgraph), Material *material)
{
DEG_debug_print_eval(__func__, material->id.name, material);
if ((BLI_listbase_is_empty(&material->gpumaterial) == false)) {
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index cc801b2d8c3..47f15e99b5f 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -329,12 +329,14 @@ void BKE_mball_properties_copy(Scene *scene, Object *active_object)
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
SceneBaseIter iter;
- struct EvaluationContext *eval_ctx = G.main->eval_ctx;
BLI_split_name_num(basisname, &basisnr, active_object->id.name + 2, '.');
- BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 0, NULL, NULL);
- while (BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 1, &base, &ob)) {
+ /* Pass depsgraph as NULL, which means we will not expand into
+ * duplis unlike when we generate the mball. Expanding duplis
+ * would not be compatible when editing multiple view layers. */
+ BKE_scene_base_iter_next(NULL, &iter, &sce_iter, 0, NULL, NULL);
+ while (BKE_scene_base_iter_next(NULL, &iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob != active_object) {
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
@@ -541,7 +543,7 @@ void BKE_mball_select_swap(struct MetaBall *mb)
/* **** Depsgraph evaluation **** */
-void BKE_mball_eval_geometry(const struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_mball_eval_geometry(struct Depsgraph *UNUSED(depsgraph),
MetaBall *UNUSED(mball))
{
}
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index 5e63b5c1607..0f13618c76a 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -53,6 +53,7 @@
#include "BKE_mball_tessellate.h" /* own include */
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "BLI_strict_flags.h"
@@ -1056,7 +1057,7 @@ static void polygonize(PROCESS *process)
* Iterates over ALL objects in the scene and all of its sets, including
* making all duplis(not only metas). Copies metas to mainb array.
* Computes bounding boxes for building BVH. */
-static void init_meta(const EvaluationContext *eval_ctx, PROCESS *process, Scene *scene, Object *ob)
+static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Object *ob)
{
Scene *sce_iter = scene;
Base *base;
@@ -1075,8 +1076,8 @@ static void init_meta(const EvaluationContext *eval_ctx, PROCESS *process, Scene
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
/* make main array */
- BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 0, NULL, NULL);
- while (BKE_scene_base_iter_next(eval_ctx, &iter, &sce_iter, 1, &base, &bob)) {
+ BKE_scene_base_iter_next(depsgraph, &iter, &sce_iter, 0, NULL, NULL);
+ while (BKE_scene_base_iter_next(depsgraph, &iter, &sce_iter, 1, &base, &bob)) {
if (bob->type == OB_MBALL) {
zero_size = 0;
ml = NULL;
@@ -1233,12 +1234,13 @@ static void init_meta(const EvaluationContext *eval_ctx, PROCESS *process, Scene
}
}
-void BKE_mball_polygonize(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
+void BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase)
{
MetaBall *mb;
DispList *dl;
unsigned int a;
PROCESS process = {0};
+ bool is_render = DEG_get_mode(depsgraph) == DAG_EVAL_RENDER;
mb = ob->data;
@@ -1249,10 +1251,10 @@ void BKE_mball_polygonize(const EvaluationContext *eval_ctx, Scene *scene, Objec
else if (process.thresh < 0.1f) process.converge_res = 4;
else process.converge_res = 2;
- if ((eval_ctx->mode != DAG_EVAL_RENDER) && (mb->flag == MB_UPDATE_NEVER)) return;
+ if (is_render && (mb->flag == MB_UPDATE_NEVER)) return;
if ((G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_FAST) return;
- if (eval_ctx->mode == DAG_EVAL_RENDER) {
+ if (is_render) {
process.size = mb->rendersize;
}
else {
@@ -1267,7 +1269,7 @@ void BKE_mball_polygonize(const EvaluationContext *eval_ctx, Scene *scene, Objec
process.pgn_elements = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "Metaball memarena");
/* initialize all mainb (MetaElems) */
- init_meta(eval_ctx, &process, scene, ob);
+ init_meta(depsgraph, &process, scene, ob);
if (process.totelem > 0) {
build_bvh_spatial(&process, &process.metaball_bvh, 0, process.totelem, &process.allbb);
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index af92422f4c3..d5a87058ecb 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1142,7 +1142,7 @@ int BKE_mesh_nurbs_displist_to_mdata(
MLoopUV *mloopuv = NULL;
MEdge *medge;
const float *data;
- int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totvlak = 0;
+ int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totpoly = 0;
int p1, p2, p3, p4, *index;
const bool conv_polys = ((CU_DO_2DFILL(cu) == false) || /* 2d polys are filled with DL_INDEX3 displists */
(ob->type == OB_SURF)); /* surf polys are never filled */
@@ -1164,14 +1164,14 @@ int BKE_mesh_nurbs_displist_to_mdata(
int tot;
totvert += dl->parts * dl->nr;
tot = (dl->parts - 1 + ((dl->flag & DL_CYCL_V) == 2)) * (dl->nr - 1 + (dl->flag & DL_CYCL_U));
- totvlak += tot;
+ totpoly += tot;
totloop += tot * 4;
}
else if (dl->type == DL_INDEX3) {
int tot;
totvert += dl->nr;
tot = dl->parts;
- totvlak += tot;
+ totpoly += tot;
totloop += tot * 3;
}
dl = dl->next;
@@ -1185,11 +1185,11 @@ int BKE_mesh_nurbs_displist_to_mdata(
*r_allvert = mvert = MEM_calloc_arrayN(totvert, sizeof(MVert), "nurbs_init mvert");
*r_alledge = medge = MEM_calloc_arrayN(totedge, sizeof(MEdge), "nurbs_init medge");
- *r_allloop = mloop = MEM_calloc_arrayN(totvlak, 4 * sizeof(MLoop), "nurbs_init mloop"); // totloop
- *r_allpoly = mpoly = MEM_calloc_arrayN(totvlak, sizeof(MPoly), "nurbs_init mloop");
+ *r_allloop = mloop = MEM_calloc_arrayN(totpoly, 4 * sizeof(MLoop), "nurbs_init mloop"); // totloop
+ *r_allpoly = mpoly = MEM_calloc_arrayN(totpoly, sizeof(MPoly), "nurbs_init mloop");
if (r_alluv)
- *r_alluv = mloopuv = MEM_calloc_arrayN(totvlak, 4 * sizeof(MLoopUV), "nurbs_init mloopuv");
+ *r_alluv = mloopuv = MEM_calloc_arrayN(totpoly, 4 * sizeof(MLoopUV), "nurbs_init mloopuv");
/* verts and faces */
vertcount = 0;
@@ -1368,13 +1368,14 @@ int BKE_mesh_nurbs_displist_to_mdata(
dl = dl->next;
}
-
- if (totvlak) {
- make_edges_mdata_extend(r_alledge, &totedge,
- *r_allpoly, *r_allloop, totvlak);
+
+ if (totpoly) {
+ make_edges_mdata_extend(
+ r_alledge, &totedge,
+ *r_allpoly, *r_allloop, totpoly);
}
- *r_totpoly = totvlak;
+ *r_totpoly = totpoly;
*r_totloop = totloop;
*r_totedge = totedge;
*r_totvert = totvert;
@@ -1643,10 +1644,10 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e
}
}
-void BKE_mesh_to_curve(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void BKE_mesh_to_curve(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
/* make new mesh data from the original copy */
- DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_MESH);
+ DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_MESH);
ListBase nurblist = {NULL, NULL};
bool needsFree = false;
@@ -2428,13 +2429,13 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
/* settings: 1 - preview, 2 - render */
Mesh *BKE_mesh_new_from_object(
- const EvaluationContext *eval_ctx, Main *bmain, Scene *sce, Object *ob,
+ Depsgraph *depsgraph, Main *bmain, Scene *sce, Object *ob,
int apply_modifiers, int calc_tessface, int calc_undeformed)
{
Mesh *tmpmesh;
Curve *tmpcu = NULL, *copycu;
int i;
- const bool render = (DEG_get_mode(eval_ctx->depsgraph) == DAG_EVAL_RENDER);
+ const bool render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
const bool cage = !apply_modifiers;
bool do_mat_id_data_us = true;
@@ -2487,7 +2488,7 @@ Mesh *BKE_mesh_new_from_object(
copycu->editnurb = tmpcu->editnurb;
/* get updated display list, and convert to a mesh */
- BKE_displist_make_curveTypes_forRender(eval_ctx, sce, tmpobj, &dispbase, &derivedFinal, false, render);
+ BKE_displist_make_curveTypes_forRender(depsgraph, sce, tmpobj, &dispbase, &derivedFinal, false, render);
copycu->editfont = NULL;
copycu->editnurb = NULL;
@@ -2536,7 +2537,7 @@ Mesh *BKE_mesh_new_from_object(
if (render) {
ListBase disp = {NULL, NULL};
- BKE_displist_make_mball_forRender(eval_ctx, sce, ob, &disp);
+ BKE_displist_make_mball_forRender(depsgraph, sce, ob, &disp);
BKE_mesh_from_metaball(&disp, tmpmesh);
BKE_displist_free(&disp);
}
@@ -2575,9 +2576,9 @@ Mesh *BKE_mesh_new_from_object(
/* Write the display mesh into the dummy mesh */
if (render)
- dm = mesh_create_derived_render(eval_ctx, sce, ob, mask);
+ dm = mesh_create_derived_render(depsgraph, sce, ob, mask);
else
- dm = mesh_create_derived_view(eval_ctx, sce, ob, mask);
+ dm = mesh_create_derived_view(depsgraph, sce, ob, mask);
tmpmesh = BKE_mesh_add(bmain, ((ID *)ob->data)->name + 2);
DM_to_mesh(dm, tmpmesh, ob, mask, true);
@@ -2668,7 +2669,7 @@ Mesh *BKE_mesh_new_from_object(
/* **** Depsgraph evaluation **** */
-void BKE_mesh_eval_geometry(const EvaluationContext *UNUSED(eval_ctx),
+void BKE_mesh_eval_geometry(Depsgraph *UNUSED(depsgraph),
Mesh *mesh)
{
DEG_debug_print_eval(__func__, mesh->id.name, mesh);
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index 77288bd672e..05a5a5e8703 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -472,7 +472,8 @@ void BKE_mesh_calc_loop_tangent_step_0(
const CustomData *loopData, bool calc_active_tangent,
const char (*tangent_names)[MAX_NAME], int tangent_names_count,
bool *rcalc_act, bool *rcalc_ren, int *ract_uv_n, int *rren_uv_n,
- char *ract_uv_name, char *rren_uv_name, short *rtangent_mask) {
+ char *ract_uv_name, char *rren_uv_name, short *rtangent_mask)
+{
/* Active uv in viewport */
int layer_index = CustomData_get_layer_index(loopData, CD_MLOOPUV);
*ract_uv_n = CustomData_get_active_layer(loopData, CD_MLOOPUV);
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 5eb5272f3e5..c15ae9e4a7c 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -786,7 +786,7 @@ void modifier_path_init(char *path, int path_maxlen, const char *name)
/* wrapper around ModifierTypeInfo.applyModifier that ensures valid normals */
struct DerivedMesh *modwrap_applyModifier(
- ModifierData *md, const struct EvaluationContext *eval_ctx,
+ ModifierData *md, struct Depsgraph *depsgraph,
Object *ob, struct DerivedMesh *dm,
ModifierApplyFlag flag)
{
@@ -796,11 +796,11 @@ struct DerivedMesh *modwrap_applyModifier(
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- return mti->applyModifier(md, eval_ctx, ob, dm, flag);
+ return mti->applyModifier(md, depsgraph, ob, dm, flag);
}
struct DerivedMesh *modwrap_applyModifierEM(
- ModifierData *md, const struct EvaluationContext *eval_ctx,
+ ModifierData *md, struct Depsgraph *depsgraph,
Object *ob, struct BMEditMesh *em,
DerivedMesh *dm,
ModifierApplyFlag flag)
@@ -811,11 +811,11 @@ struct DerivedMesh *modwrap_applyModifierEM(
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- return mti->applyModifierEM(md, eval_ctx, ob, em, dm, flag);
+ return mti->applyModifierEM(md, depsgraph, ob, em, dm, flag);
}
void modwrap_deformVerts(
- ModifierData *md, const struct EvaluationContext *eval_ctx,
+ ModifierData *md, struct Depsgraph *depsgraph,
Object *ob, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag flag)
@@ -826,11 +826,11 @@ void modwrap_deformVerts(
if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- mti->deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, flag);
+ mti->deformVerts(md, depsgraph, ob, dm, vertexCos, numVerts, flag);
}
void modwrap_deformVertsEM(
- ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
+ ModifierData *md, struct Depsgraph *depsgraph, Object *ob,
struct BMEditMesh *em, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts)
{
@@ -840,6 +840,6 @@ void modwrap_deformVertsEM(
if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- mti->deformVertsEM(md, eval_ctx, ob, em, dm, vertexCos, numVerts);
+ mti->deformVertsEM(md, depsgraph, ob, em, dm, vertexCos, numVerts);
}
/* end modifier callback wrappers */
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 9ed715d7591..36a5a60635a 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -1609,7 +1609,7 @@ bool BKE_movieclip_put_frame_if_possible(MovieClip *clip,
return result;
}
-void BKE_movieclip_eval_update(struct EvaluationContext *UNUSED(eval_ctx), MovieClip *clip)
+void BKE_movieclip_eval_update(struct Depsgraph *UNUSED(depsgraph), MovieClip *clip)
{
DEG_debug_print_eval(__func__, clip->id.name, clip);
BKE_tracking_dopesheet_tag_update(&clip->tracking);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 55f11604710..edba03dd707 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -277,14 +277,14 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
return mdisps;
}
-DerivedMesh *get_multires_dm(const struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd, Object *ob)
+DerivedMesh *get_multires_dm(struct Depsgraph *depsgraph, Scene *scene, MultiresModifierData *mmd, Object *ob)
{
ModifierData *md = (ModifierData *)mmd;
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- DerivedMesh *tdm = mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *tdm = mesh_get_derived_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
DerivedMesh *dm;
- dm = mti->applyModifier(md, eval_ctx, ob, tdm, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY);
+ dm = mti->applyModifier(md, depsgraph, ob, tdm, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY);
if (dm == tdm) {
dm = CDDM_copy(tdm);
}
@@ -398,10 +398,10 @@ void multires_force_render_update(Object *ob)
multires_force_update(ob);
}
-int multiresModifier_reshapeFromDM(const struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDM(struct Depsgraph *depsgraph, Scene *scene, MultiresModifierData *mmd,
Object *ob, DerivedMesh *srcdm)
{
- DerivedMesh *mrdm = get_multires_dm(eval_ctx, scene, mmd, ob);
+ DerivedMesh *mrdm = get_multires_dm(depsgraph, scene, mmd, ob);
if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) {
multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm));
@@ -420,13 +420,13 @@ int multiresModifier_reshapeFromDM(const struct EvaluationContext *eval_ctx, Sce
}
/* Returns 1 on success, 0 if the src's totvert doesn't match */
-int multiresModifier_reshape(const struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd, Object *dst, Object *src)
+int multiresModifier_reshape(struct Depsgraph *depsgraph, Scene *scene, MultiresModifierData *mmd, Object *dst, Object *src)
{
- DerivedMesh *srcdm = mesh_get_derived_final(eval_ctx, scene, src, CD_MASK_BAREMESH);
- return multiresModifier_reshapeFromDM(eval_ctx, scene, mmd, dst, srcdm);
+ DerivedMesh *srcdm = mesh_get_derived_final(depsgraph, scene, src, CD_MASK_BAREMESH);
+ return multiresModifier_reshapeFromDM(depsgraph, scene, mmd, dst, srcdm);
}
-int multiresModifier_reshapeFromDeformMod(const struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd,
+int multiresModifier_reshapeFromDeformMod(struct Depsgraph *depsgraph, Scene *scene, MultiresModifierData *mmd,
Object *ob, ModifierData *md)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -438,12 +438,12 @@ int multiresModifier_reshapeFromDeformMod(const struct EvaluationContext *eval_c
return 0;
/* Create DerivedMesh for deformation modifier */
- dm = get_multires_dm(eval_ctx, scene, mmd, ob);
+ dm = get_multires_dm(depsgraph, scene, mmd, ob);
numVerts = dm->getNumVerts(dm);
deformedVerts = MEM_malloc_arrayN(numVerts, sizeof(float[3]), "multiresReshape_deformVerts");
dm->getVertCos(dm, deformedVerts);
- mti->deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, 0);
+ mti->deformVerts(md, depsgraph, ob, dm, deformedVerts, numVerts, 0);
ndm = CDDM_copy(dm);
CDDM_apply_vert_coords(ndm, deformedVerts);
@@ -452,7 +452,7 @@ int multiresModifier_reshapeFromDeformMod(const struct EvaluationContext *eval_c
dm->release(dm);
/* Reshaping */
- result = multiresModifier_reshapeFromDM(eval_ctx, scene, mmd, ob, ndm);
+ result = multiresModifier_reshapeFromDM(depsgraph, scene, mmd, ob, ndm);
/* Cleanup */
ndm->release(ndm);
@@ -2275,7 +2275,7 @@ static void multires_apply_smat_cb(
}
}
-static void multires_apply_smat(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float smat[3][3])
+static void multires_apply_smat(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float smat[3][3])
{
DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL;
CCGElem **gridData, **subGridData;
@@ -2300,10 +2300,10 @@ static void multires_apply_smat(const struct EvaluationContext *eval_ctx, Scene
high_mmd.lvl = high_mmd.totlvl;
/* unscaled multires with applied displacement */
- subdm = get_multires_dm(eval_ctx, scene, &high_mmd, ob);
+ subdm = get_multires_dm(depsgraph, scene, &high_mmd, ob);
/* prepare scaled CDDM to create ccgDN */
- cddm = mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ cddm = mesh_get_derived_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
totvert = cddm->getNumVerts(cddm);
vertCos = MEM_malloc_arrayN(totvert, sizeof(*vertCos), "multiresScale vertCos");
@@ -2364,17 +2364,17 @@ int multires_mdisp_corners(MDisps *s)
return 0;
}
-void multiresModifier_scale_disp(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void multiresModifier_scale_disp(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
{
float smat[3][3];
/* object's scale matrix */
BKE_object_scale_to_mat3(ob, smat);
- multires_apply_smat(eval_ctx, scene, ob, smat);
+ multires_apply_smat(depsgraph, scene, ob, smat);
}
-void multiresModifier_prepare_join(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *to_ob)
+void multiresModifier_prepare_join(struct Depsgraph *depsgraph, Scene *scene, Object *ob, Object *to_ob)
{
float smat[3][3], tmat[3][3], mat[3][3];
multires_sync_levels(scene, to_ob, ob);
@@ -2385,7 +2385,7 @@ void multiresModifier_prepare_join(const struct EvaluationContext *eval_ctx, Sce
BKE_object_scale_to_mat3(ob, smat);
mul_m3_m3m3(mat, smat, tmat);
- multires_apply_smat(eval_ctx, scene, ob, mat);
+ multires_apply_smat(depsgraph, scene, ob, mat);
}
/* update multires data after topology changing */
diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c
deleted file mode 100644
index 35bcca52f63..00000000000
--- a/source/blender/blenkernel/intern/navmesh_conversion.c
+++ /dev/null
@@ -1,502 +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 blender/blenkernel/intern/navmesh_conversion.c
- * \ingroup bke
- */
-
-#include <math.h>
-#include <stdlib.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_meshdata_types.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_math.h"
-#include "BLI_sort.h"
-
-#include "BKE_navmesh_conversion.h"
-#include "BKE_cdderivedmesh.h"
-
-#include "recast-capi.h"
-
-BLI_INLINE float area2(const float *a, const float *b, const float *c)
-{
- return (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]);
-}
-
-BLI_INLINE int left(const float *a, const float *b, const float *c)
-{
- return area2(a, b, c) < 0;
-}
-
-int polyNumVerts(const unsigned short *p, const int vertsPerPoly)
-{
- int i, nv = 0;
- for (i = 0; i < vertsPerPoly; i++) {
- if (p[i] == 0xffff)
- break;
- nv++;
- }
- return nv;
-}
-
-int polyIsConvex(const unsigned short *p, const int vertsPerPoly, const float *verts)
-{
- int j, nv = polyNumVerts(p, vertsPerPoly);
- if (nv < 3)
- return 0;
- for (j = 0; j < nv; j++) {
- const float *v = &verts[3 * p[j]];
- const float *v_next = &verts[3 * p[(j + 1) % nv]];
- const float *v_prev = &verts[3 * p[(nv + j - 1) % nv]];
- if (!left(v_prev, v, v_next))
- return 0;
-
- }
- return 1;
-}
-
-/* XXX, could replace with #dist_to_line_segment_v3(), or add a squared version */
-float distPointToSegmentSq(const float point[3], const float a[3], const float b[3])
-{
- float abx[3], dx[3];
- float d, t;
-
- sub_v3_v3v3(abx, b, a);
- sub_v3_v3v3(dx, point, a);
-
- d = abx[0] * abx[0] + abx[2] * abx[2];
- t = abx[0] * dx[0] + abx[2] * dx[2];
-
- if (d > 0.0f)
- t /= d;
- if (t < 0.0f)
- t = 0.0f;
- else if (t > 1.0f)
- t = 1.0f;
- dx[0] = a[0] + t * abx[0] - point[0];
- dx[2] = a[2] + t * abx[2] - point[2];
-
- return dx[0] * dx[0] + dx[2] * dx[2];
-}
-
-int buildRawVertIndicesData(DerivedMesh *dm, int *nverts_r, float **verts_r,
- int *ntris_r, unsigned short **tris_r, int **trisToFacesMap_r,
- int **recastData)
-{
- int vi, fi, triIdx;
- int nverts, ntris;
- int *trisToFacesMap;
- float *verts;
- unsigned short *tris, *tri;
- int nfaces;
- MFace *faces;
-
- nverts = dm->getNumVerts(dm);
- if (nverts >= 0xffff) {
- printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff);
- return 0;
- }
- if (nverts == 0) {
- printf("Converting navmesh: Error! There are no vertices!\n");
- return 0;
- }
-
- verts = MEM_mallocN(sizeof(float[3]) * nverts, "buildRawVertIndicesData verts");
- dm->getVertCos(dm, (float(*)[3])verts);
-
- /* flip coordinates */
- for (vi = 0; vi < nverts; vi++) {
- SWAP(float, verts[3 * vi + 1], verts[3 * vi + 2]);
- }
-
- /* calculate number of tris */
- dm->recalcTessellation(dm);
- nfaces = dm->getNumTessFaces(dm);
- if (nfaces == 0) {
- printf("Converting navmesh: Error! There are %i vertices, but no faces!\n", nverts);
- return 0;
- }
-
- faces = dm->getTessFaceArray(dm);
- ntris = nfaces;
- for (fi = 0; fi < nfaces; fi++) {
- MFace *face = &faces[fi];
- if (face->v4)
- ntris++;
- }
-
- /* copy and transform to triangles (reorder on the run) */
- trisToFacesMap = MEM_callocN(sizeof(int) * ntris, "buildRawVertIndicesData trisToFacesMap");
- tris = MEM_callocN(sizeof(unsigned short) * 3 * ntris, "buildRawVertIndicesData tris");
- tri = tris;
- triIdx = 0;
- for (fi = 0; fi < nfaces; fi++) {
- MFace *face = &faces[fi];
- tri[3 * triIdx + 0] = (unsigned short) face->v1;
- tri[3 * triIdx + 1] = (unsigned short) face->v3;
- tri[3 * triIdx + 2] = (unsigned short) face->v2;
- trisToFacesMap[triIdx++] = fi;
- if (face->v4) {
- tri[3 * triIdx + 0] = (unsigned short) face->v1;
- tri[3 * triIdx + 1] = (unsigned short) face->v4;
- tri[3 * triIdx + 2] = (unsigned short) face->v3;
- trisToFacesMap[triIdx++] = fi;
- }
- }
-
- /* carefully, recast data is just reference to data in derived mesh */
- *recastData = (int *)CustomData_get_layer(&dm->polyData, CD_RECAST);
-
- *nverts_r = nverts;
- *verts_r = verts;
- *ntris_r = ntris;
- *tris_r = tris;
- *trisToFacesMap_r = trisToFacesMap;
-
- return 1;
-}
-
-int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys,
- unsigned short *polys, const unsigned short *dmeshes,
- const float *verts, const unsigned short *dtris,
- const int *dtrisToPolysMap)
-{
- int polyidx;
- int capacity = vertsPerPoly;
- unsigned short *newPoly = MEM_callocN(sizeof(unsigned short) * capacity, "buildPolygonsByDetailedMeshes newPoly");
- memset(newPoly, 0xff, sizeof(unsigned short) * capacity);
-
- for (polyidx = 0; polyidx < npolys; polyidx++) {
- size_t i;
- int j, k;
- int nv = 0;
- /* search border */
- int tri, btri = -1;
- int edge, bedge = -1;
- int dtrisNum = dmeshes[polyidx * 4 + 3];
- int dtrisBase = dmeshes[polyidx * 4 + 2];
- unsigned char *traversedTris = MEM_callocN(sizeof(unsigned char) * dtrisNum, "buildPolygonsByDetailedMeshes traversedTris");
- unsigned short *adjustedPoly;
- int adjustedNv;
- int allBorderTraversed;
-
- for (j = 0; j < dtrisNum && btri == -1; j++) {
- int curpolytri = dtrisBase + j;
- for (k = 0; k < 3; k++) {
- unsigned short neighbortri = dtris[curpolytri * 3 * 2 + 3 + k];
- if (neighbortri == 0xffff || dtrisToPolysMap[neighbortri] != polyidx + 1) {
- btri = curpolytri;
- bedge = k;
- break;
- }
- }
- }
- if (btri == -1 || bedge == -1) {
- /* can't find triangle with border edge */
- MEM_freeN(traversedTris);
- MEM_freeN(newPoly);
-
- return 0;
- }
-
- newPoly[nv++] = dtris[btri * 3 * 2 + bedge];
- tri = btri;
- edge = (bedge + 1) % 3;
- traversedTris[tri - dtrisBase] = 1;
- while (tri != btri || edge != bedge) {
- int neighbortri = dtris[tri * 3 * 2 + 3 + edge];
- if (neighbortri == 0xffff || dtrisToPolysMap[neighbortri] != polyidx + 1) {
- if (nv == capacity) {
- unsigned short *newPolyBig;
- capacity += vertsPerPoly;
- newPolyBig = MEM_callocN(sizeof(unsigned short) * capacity, "buildPolygonsByDetailedMeshes newPolyBig");
- memset(newPolyBig, 0xff, sizeof(unsigned short) * capacity);
- memcpy(newPolyBig, newPoly, sizeof(unsigned short) * nv);
- MEM_freeN(newPoly);
- newPoly = newPolyBig;
- }
- newPoly[nv++] = dtris[tri * 3 * 2 + edge];
- /* move to next edge */
- edge = (edge + 1) % 3;
- }
- else {
- /* move to next tri */
- int twinedge = -1;
- for (k = 0; k < 3; k++) {
- if (dtris[neighbortri * 3 * 2 + 3 + k] == tri) {
- twinedge = k;
- break;
- }
- }
- if (twinedge == -1) {
- printf("Converting navmesh: Error! Can't find neighbor edge - invalid adjacency info\n");
- MEM_freeN(traversedTris);
- goto returnLabel;
- }
- tri = neighbortri;
- edge = (twinedge + 1) % 3;
- traversedTris[tri - dtrisBase] = 1;
- }
- }
-
- adjustedPoly = MEM_callocN(sizeof(unsigned short) * nv, "buildPolygonsByDetailedMeshes adjustedPoly");
- adjustedNv = 0;
- for (i = 0; i < nv; i++) {
- unsigned short prev = newPoly[(nv + i - 1) % nv];
- unsigned short cur = newPoly[i];
- unsigned short next = newPoly[(i + 1) % nv];
- float distSq = distPointToSegmentSq(&verts[3 * cur], &verts[3 * prev], &verts[3 * next]);
- static const float tolerance = 0.001f;
- if (distSq > tolerance)
- adjustedPoly[adjustedNv++] = cur;
- }
- memcpy(newPoly, adjustedPoly, adjustedNv * sizeof(unsigned short));
- MEM_freeN(adjustedPoly);
- nv = adjustedNv;
-
- allBorderTraversed = 1;
- for (i = 0; i < dtrisNum; i++) {
- if (traversedTris[i] == 0) {
- /* check whether it has border edges */
- int curpolytri = dtrisBase + i;
- for (k = 0; k < 3; k++) {
- unsigned short neighbortri = dtris[curpolytri * 3 * 2 + 3 + k];
- if (neighbortri == 0xffff || dtrisToPolysMap[neighbortri] != polyidx + 1) {
- allBorderTraversed = 0;
- break;
- }
- }
- }
- }
-
- if (nv <= vertsPerPoly && allBorderTraversed) {
- for (i = 0; i < nv; i++) {
- polys[polyidx * vertsPerPoly * 2 + i] = newPoly[i];
- }
- }
-
- MEM_freeN(traversedTris);
- }
-
-returnLabel:
- MEM_freeN(newPoly);
-
- return 1;
-}
-
-struct SortContext {
- const int *recastData;
- const int *trisToFacesMap;
-};
-
-static int compareByData(const void *a, const void *b, void *ctx)
-{
- return (((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int *)a]] -
- ((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int *)b]]);
-}
-
-int buildNavMeshData(const int nverts, const float *verts,
- const int ntris, const unsigned short *tris,
- const int *recastData, const int *trisToFacesMap,
- int *ndtris_r, unsigned short **dtris_r,
- int *npolys_r, unsigned short **dmeshes_r, unsigned short **polys_r,
- int *vertsPerPoly_r, int **dtrisToPolysMap_r, int **dtrisToTrisMap_r)
-
-{
- int *trisMapping;
- int i;
- struct SortContext context;
- int validTriStart, prevPolyIdx, curPolyIdx, newPolyIdx, prevpolyidx;
- unsigned short *dmesh;
-
- int ndtris, npolys, vertsPerPoly;
- unsigned short *dtris, *dmeshes, *polys;
- int *dtrisToPolysMap, *dtrisToTrisMap;
-
- if (!recastData) {
- printf("Converting navmesh: Error! Can't find recast custom data\n");
- return 0;
- }
-
- trisMapping = MEM_callocN(sizeof(int) * ntris, "buildNavMeshData trisMapping");
-
- /* sort the triangles by polygon idx */
- for (i = 0; i < ntris; i++)
- trisMapping[i] = i;
- context.recastData = recastData;
- context.trisToFacesMap = trisToFacesMap;
- BLI_qsort_r(trisMapping, ntris, sizeof(int), compareByData, &context);
-
- /* search first valid triangle - triangle of convex polygon */
- validTriStart = -1;
- for (i = 0; i < ntris; i++) {
- if (recastData[trisToFacesMap[trisMapping[i]]] > 0) {
- validTriStart = i;
- break;
- }
- }
-
- if (validTriStart < 0) {
- printf("Converting navmesh: Error! No valid polygons in mesh\n");
- MEM_freeN(trisMapping);
- return 0;
- }
-
- ndtris = ntris - validTriStart;
- /* fill dtris to faces mapping */
- dtrisToTrisMap = MEM_callocN(sizeof(int) * ndtris, "buildNavMeshData dtrisToTrisMap");
- memcpy(dtrisToTrisMap, &trisMapping[validTriStart], ndtris * sizeof(int));
- MEM_freeN(trisMapping);
-
- /* create detailed mesh triangles - copy only valid triangles
- * and reserve memory for adjacency info */
- dtris = MEM_callocN(sizeof(unsigned short) * 3 * 2 * ndtris, "buildNavMeshData dtris");
- memset(dtris, 0xff, sizeof(unsigned short) * 3 * 2 * ndtris);
- for (i = 0; i < ndtris; i++) {
- memcpy(dtris + 3 * 2 * i, tris + 3 * dtrisToTrisMap[i], sizeof(unsigned short) * 3);
- }
-
- /* create new recast data corresponded to dtris and renumber for continuous indices */
- prevPolyIdx = -1;
- newPolyIdx = 0;
- dtrisToPolysMap = MEM_callocN(sizeof(int) * ndtris, "buildNavMeshData dtrisToPolysMap");
- for (i = 0; i < ndtris; i++) {
- curPolyIdx = recastData[trisToFacesMap[dtrisToTrisMap[i]]];
- if (curPolyIdx != prevPolyIdx) {
- newPolyIdx++;
- prevPolyIdx = curPolyIdx;
- }
- dtrisToPolysMap[i] = newPolyIdx;
- }
-
-
- /* build adjacency info for detailed mesh triangles */
- if (!recast_buildMeshAdjacency(dtris, ndtris, nverts, 3)) {
- printf("Converting navmesh: Error! Unable to build mesh adjacency information\n");
- MEM_freeN(trisMapping);
- MEM_freeN(dtrisToPolysMap);
- return 0;
- }
-
- /* create detailed mesh description for each navigation polygon */
- npolys = dtrisToPolysMap[ndtris - 1];
- dmeshes = MEM_callocN(sizeof(unsigned short) * npolys * 4, "buildNavMeshData dmeshes");
- memset(dmeshes, 0, npolys * 4 * sizeof(unsigned short));
- dmesh = NULL;
- prevpolyidx = 0;
- for (i = 0; i < ndtris; i++) {
- int curpolyidx = dtrisToPolysMap[i];
- if (curpolyidx != prevpolyidx) {
- if (curpolyidx != prevpolyidx + 1) {
- printf("Converting navmesh: Error! Wrong order of detailed mesh faces\n");
- goto fail;
- }
- dmesh = dmesh == NULL ? dmeshes : dmesh + 4;
- dmesh[2] = (unsigned short)i; /* tbase */
- dmesh[3] = 0; /* tnum */
- prevpolyidx = curpolyidx;
- }
- dmesh[3]++;
- }
-
- /* create navigation polygons */
- vertsPerPoly = 6;
- polys = MEM_callocN(sizeof(unsigned short) * npolys * vertsPerPoly * 2, "buildNavMeshData polys");
- memset(polys, 0xff, sizeof(unsigned short) * vertsPerPoly * 2 * npolys);
-
- if (!buildPolygonsByDetailedMeshes(vertsPerPoly, npolys, polys, dmeshes, verts, dtris, dtrisToPolysMap)) {
- printf("Converting navmesh: Error! Unable to build polygons from detailed mesh\n");
- goto fail;
- }
-
- *ndtris_r = ndtris;
- *npolys_r = npolys;
- *vertsPerPoly_r = vertsPerPoly;
- *dtris_r = dtris;
- *dmeshes_r = dmeshes;
- *polys_r = polys;
- *dtrisToPolysMap_r = dtrisToPolysMap;
- *dtrisToTrisMap_r = dtrisToTrisMap;
-
- return 1;
-
-fail:
- MEM_freeN(dmeshes);
- MEM_freeN(dtrisToPolysMap);
- MEM_freeN(dtrisToTrisMap);
- return 0;
-}
-
-
-int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
- int *nverts, float **verts,
- int *ndtris, unsigned short **dtris,
- int *npolys, unsigned short **dmeshes,
- unsigned short **polys, int **dtrisToPolysMap,
- int **dtrisToTrisMap, int **trisToFacesMap)
-{
- int res;
- int ntris = 0, *recastData = NULL;
- unsigned short *tris = NULL;
-
- res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData);
- if (!res) {
- printf("Converting navmesh: Error! Can't get raw vertices and indices from mesh\n");
- goto exit;
- }
-
- res = buildNavMeshData(*nverts, *verts, ntris, tris, recastData, *trisToFacesMap,
- ndtris, dtris, npolys, dmeshes, polys, vertsPerPoly,
- dtrisToPolysMap, dtrisToTrisMap);
- if (!res) {
- printf("Converting navmesh: Error! Can't build navmesh data from mesh\n");
- goto exit;
- }
-
-exit:
- if (tris)
- MEM_freeN(tris);
-
- return res;
-}
-
-int polyFindVertex(const unsigned short *p, const int vertsPerPoly, unsigned short vertexIdx)
-{
- int i, res = -1;
- for (i = 0; i < vertsPerPoly; i++) {
- if (p[i] == 0xffff)
- break;
- if (p[i] == vertexIdx) {
- res = i;
- break;
- }
- }
- return res;
-}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 41b7cd1f48e..def8ea1d239 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -3120,77 +3120,6 @@ void nodeUpdateInternalLinks(bNodeTree *ntree, bNode *node)
}
-/* nodes that use ID data get synced with local data */
-void nodeSynchronizeID(bNode *node, bool copy_to_id)
-{
- if (node->id == NULL) return;
-
- if (ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) {
- bNodeSocket *sock;
- Material *ma = (Material *)node->id;
- int a;
- short check_flags = SOCK_UNAVAIL;
-
- if (!copy_to_id)
- check_flags |= SOCK_HIDDEN;
-
- /* hrmf, case in loop isn't super fast, but we don't edit 100s of material at same time either! */
- for (a = 0, sock = node->inputs.first; sock; sock = sock->next, a++) {
- if (!(sock->flag & check_flags)) {
- if (copy_to_id) {
- switch (a) {
- case MAT_IN_COLOR:
- copy_v3_v3(&ma->r, ((bNodeSocketValueRGBA *)sock->default_value)->value); break;
- case MAT_IN_SPEC:
- copy_v3_v3(&ma->specr, ((bNodeSocketValueRGBA *)sock->default_value)->value); break;
- case MAT_IN_REFL:
- ma->ref = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
- case MAT_IN_MIR:
- copy_v3_v3(&ma->mirr, ((bNodeSocketValueRGBA *)sock->default_value)->value); break;
- case MAT_IN_AMB:
- ma->amb = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
- case MAT_IN_EMIT:
- ma->emit = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
- case MAT_IN_SPECTRA:
- ma->spectra = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
- case MAT_IN_RAY_MIRROR:
- ma->ray_mirror = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
- case MAT_IN_ALPHA:
- ma->alpha = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
- case MAT_IN_TRANSLUCENCY:
- ma->translucency = ((bNodeSocketValueFloat *)sock->default_value)->value; break;
- }
- }
- else {
- switch (a) {
- case MAT_IN_COLOR:
- copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, &ma->r); break;
- case MAT_IN_SPEC:
- copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, &ma->specr); break;
- case MAT_IN_REFL:
- ((bNodeSocketValueFloat *)sock->default_value)->value = ma->ref; break;
- case MAT_IN_MIR:
- copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, &ma->mirr); break;
- case MAT_IN_AMB:
- ((bNodeSocketValueFloat *)sock->default_value)->value = ma->amb; break;
- case MAT_IN_EMIT:
- ((bNodeSocketValueFloat *)sock->default_value)->value = ma->emit; break;
- case MAT_IN_SPECTRA:
- ((bNodeSocketValueFloat *)sock->default_value)->value = ma->spectra; break;
- case MAT_IN_RAY_MIRROR:
- ((bNodeSocketValueFloat *)sock->default_value)->value = ma->ray_mirror; break;
- case MAT_IN_ALPHA:
- ((bNodeSocketValueFloat *)sock->default_value)->value = ma->alpha; break;
- case MAT_IN_TRANSLUCENCY:
- ((bNodeSocketValueFloat *)sock->default_value)->value = ma->translucency; break;
- }
- }
- }
- }
- }
-}
-
-
/* ************* node type access ********** */
void nodeLabel(bNodeTree *ntree, bNode *node, char *label, int maxlen)
@@ -3555,10 +3484,7 @@ static void registerShaderNodes(void)
{
register_node_type_sh_group();
- register_node_type_sh_output();
- register_node_type_sh_material();
register_node_type_sh_camera();
- register_node_type_sh_lamp();
register_node_type_sh_gamma();
register_node_type_sh_brightcontrast();
register_node_type_sh_value();
@@ -3569,9 +3495,7 @@ static void registerShaderNodes(void)
register_node_type_sh_mix_rgb();
register_node_type_sh_valtorgb();
register_node_type_sh_rgbtobw();
- register_node_type_sh_texture();
register_node_type_sh_normal();
- register_node_type_sh_geom();
register_node_type_sh_mapping();
register_node_type_sh_curve_vec();
register_node_type_sh_curve_rgb();
@@ -3579,7 +3503,6 @@ static void registerShaderNodes(void)
register_node_type_sh_vect_math();
register_node_type_sh_vect_transform();
register_node_type_sh_squeeze();
- register_node_type_sh_material_ext();
register_node_type_sh_invert();
register_node_type_sh_seprgb();
register_node_type_sh_combrgb();
@@ -3869,7 +3792,7 @@ void BKE_nodetree_copy_default_values(bNodeTree *ntree_dst,
}
}
-void BKE_nodetree_shading_params_eval(const struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_nodetree_shading_params_eval(struct Depsgraph *UNUSED(depsgraph),
bNodeTree *ntree_dst,
const bNodeTree *ntree_src)
{
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 2cb4356a52a..188ef97e1ea 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -60,7 +60,6 @@
#include "DNA_world_types.h"
#include "DNA_object_types.h"
#include "DNA_lightprobe_types.h"
-#include "DNA_property_types.h"
#include "DNA_rigidbody_types.h"
#include "BLI_blenlib.h"
@@ -79,7 +78,6 @@
#include "BKE_idprop.h"
#include "BKE_armature.h"
#include "BKE_action.h"
-#include "BKE_bullet.h"
#include "BKE_deform.h"
#include "BKE_DerivedMesh.h"
#include "BKE_animsys.h"
@@ -111,9 +109,7 @@
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_lightprobe.h"
-#include "BKE_property.h"
#include "BKE_rigidbody.h"
-#include "BKE_sca.h"
#include "BKE_scene.h"
#include "BKE_sequencer.h"
#include "BKE_speaker.h"
@@ -138,8 +134,6 @@
#include "CCGSubSurf.h"
#include "atomic_ops.h"
-#include "GPU_lamp.h"
-
/* Vertex parent modifies original BMesh which is not safe for threading.
* Ideally such a modification should be handled as a separate DAG update
* callback for mesh datablock, but for until it is actually supported use
@@ -178,14 +172,6 @@ void BKE_object_free_softbody(Object *ob)
}
}
-void BKE_object_free_bulletsoftbody(Object *ob)
-{
- if (ob->bsoft) {
- bsbFree(ob->bsoft);
- ob->bsoft = NULL;
- }
-}
-
void BKE_object_free_curve_cache(Object *ob)
{
if (ob->curve_cache) {
@@ -445,11 +431,6 @@ void BKE_object_free(Object *ob)
animviz_free_motionpath(ob->mpath);
ob->mpath = NULL;
}
- BKE_bproperty_free_list(&ob->prop);
-
- free_sensors(&ob->sensors);
- free_controllers(&ob->controllers);
- free_actuators(&ob->actuators);
BKE_constraints_free_ex(&ob->constraints, false);
@@ -461,11 +442,6 @@ void BKE_object_free(Object *ob)
sbFree(ob->soft);
ob->soft = NULL;
}
- if (ob->bsoft) {
- bsbFree(ob->bsoft);
- ob->bsoft = NULL;
- }
- GPU_lamp_free(ob);
for (ObjectEngineData *oed = ob->drawdata.first; oed; oed = oed->next) {
if (oed->free != NULL) {
@@ -544,6 +520,15 @@ bool BKE_object_is_in_editmode(const Object *ob)
return false;
}
+bool BKE_object_is_in_editmode_and_selected(const Object *ob)
+{
+ if ((ob->base_flag & BASE_SELECTED) && (BKE_object_is_in_editmode(ob))) {
+ return true;
+ }
+ return false;
+}
+
+
bool BKE_object_is_in_editmode_vgroup(const Object *ob)
{
return (OB_TYPE_SUPPORT_VGROUP(ob->type) &&
@@ -562,6 +547,36 @@ bool BKE_object_is_in_wpaint_select_vert(const Object *ob)
return false;
}
+bool BKE_object_has_mode_data(const struct Object *ob, eObjectMode object_mode)
+{
+ if (object_mode & OB_MODE_EDIT) {
+ if (BKE_object_is_in_editmode(ob)) {
+ return true;
+ }
+ }
+ else if (object_mode & OB_MODE_VERTEX_PAINT) {
+ if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_VERTEX_PAINT)) {
+ return true;
+ }
+ }
+ else if (object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_WEIGHT_PAINT)) {
+ return true;
+ }
+ }
+ else if (object_mode & OB_MODE_SCULPT) {
+ if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_SCULPT)) {
+ return true;
+ }
+ }
+ else if (object_mode & OB_MODE_POSE) {
+ if (ob->pose != NULL) {
+ return true;
+ }
+ }
+ return false;
+}
+
/**
* Return if the object is visible, as evaluated by depsgraph
*/
@@ -699,23 +714,6 @@ void BKE_object_init(Object *ob)
ob->dupsta = 1; ob->dupend = 100;
ob->dupfacesca = 1.0;
- /* Game engine defaults*/
- ob->mass = ob->inertia = 1.0f;
- ob->formfactor = 0.4f;
- ob->damping = 0.04f;
- ob->rdamping = 0.1f;
- ob->anisotropicFriction[0] = 1.0f;
- ob->anisotropicFriction[1] = 1.0f;
- ob->anisotropicFriction[2] = 1.0f;
- ob->gameflag = OB_PROP | OB_COLLISION;
- ob->margin = 0.04f;
- ob->init_state = 1;
- ob->state = 1;
- ob->obstacleRad = 1.0f;
- ob->step_height = 0.15f;
- ob->jump_speed = 10.0f;
- ob->fall_speed = 55.0f;
- ob->max_jumps = 1;
ob->col_group = 0x01;
ob->col_mask = 0xffff;
ob->preview = NULL;
@@ -811,139 +809,6 @@ Object *BKE_object_add_from(
return ob;
}
-#ifdef WITH_GAMEENGINE
-
-void BKE_object_lod_add(Object *ob)
-{
- LodLevel *lod = MEM_callocN(sizeof(LodLevel), "LoD Level");
- LodLevel *last = ob->lodlevels.last;
-
- /* If the lod list is empty, initialize it with the base lod level */
- if (!last) {
- LodLevel *base = MEM_callocN(sizeof(LodLevel), "Base LoD Level");
- BLI_addtail(&ob->lodlevels, base);
- base->flags = OB_LOD_USE_MESH | OB_LOD_USE_MAT;
- base->source = ob;
- base->obhysteresis = 10;
- last = ob->currentlod = base;
- }
-
- lod->distance = last->distance + 25.0f;
- lod->obhysteresis = 10;
- lod->flags = OB_LOD_USE_MESH | OB_LOD_USE_MAT;
-
- BLI_addtail(&ob->lodlevels, lod);
-}
-
-static int lod_cmp(const void *a, const void *b)
-{
- const LodLevel *loda = a;
- const LodLevel *lodb = b;
-
- if (loda->distance < lodb->distance) return -1;
- return loda->distance > lodb->distance;
-}
-
-void BKE_object_lod_sort(Object *ob)
-{
- BLI_listbase_sort(&ob->lodlevels, lod_cmp);
-}
-
-bool BKE_object_lod_remove(Object *ob, int level)
-{
- LodLevel *rem;
-
- if (level < 1 || level > BLI_listbase_count(&ob->lodlevels) - 1)
- return false;
-
- rem = BLI_findlink(&ob->lodlevels, level);
-
- if (rem == ob->currentlod) {
- ob->currentlod = rem->prev;
- }
-
- BLI_remlink(&ob->lodlevels, rem);
- MEM_freeN(rem);
-
- /* If there are no user defined lods, remove the base lod as well */
- if (BLI_listbase_is_single(&ob->lodlevels)) {
- LodLevel *base = ob->lodlevels.first;
- BLI_remlink(&ob->lodlevels, base);
- MEM_freeN(base);
- ob->currentlod = NULL;
- }
-
- return true;
-}
-
-static LodLevel *lod_level_select(Object *ob, const float camera_position[3])
-{
- LodLevel *current = ob->currentlod;
- float dist_sq;
-
- if (!current) return NULL;
-
- dist_sq = len_squared_v3v3(ob->obmat[3], camera_position);
-
- if (dist_sq < SQUARE(current->distance)) {
- /* check for higher LoD */
- while (current->prev && dist_sq < SQUARE(current->distance)) {
- current = current->prev;
- }
- }
- else {
- /* check for lower LoD */
- while (current->next && dist_sq > SQUARE(current->next->distance)) {
- current = current->next;
- }
- }
-
- return current;
-}
-
-bool BKE_object_lod_is_usable(Object *ob, ViewLayer *view_layer)
-{
- bool active = (view_layer) ? ob == OBACT(view_layer) : false;
- return (ob->mode == OB_MODE_OBJECT || !active);
-}
-
-void BKE_object_lod_update(Object *ob, const float camera_position[3])
-{
- LodLevel *cur_level = ob->currentlod;
- LodLevel *new_level = lod_level_select(ob, camera_position);
-
- if (new_level != cur_level) {
- ob->currentlod = new_level;
- }
-}
-
-static Object *lod_ob_get(Object *ob, ViewLayer *view_layer, int flag)
-{
- LodLevel *current = ob->currentlod;
-
- if (!current || !BKE_object_lod_is_usable(ob, view_layer))
- return ob;
-
- while (current->prev && (!(current->flags & flag) || !current->source || current->source->type != OB_MESH)) {
- current = current->prev;
- }
-
- return current->source;
-}
-
-struct Object *BKE_object_lod_meshob_get(Object *ob, ViewLayer *view_layer)
-{
- return lod_ob_get(ob, view_layer, OB_LOD_USE_MESH);
-}
-
-struct Object *BKE_object_lod_matob_get(Object *ob, ViewLayer *view_layer)
-{
- return lod_ob_get(ob, view_layer, OB_LOD_USE_MAT);
-}
-
-#endif /* WITH_GAMEENGINE */
-
-
SoftBody *copy_softbody(const SoftBody *sb, const int flag)
{
SoftBody *sbn;
@@ -989,17 +854,6 @@ SoftBody *copy_softbody(const SoftBody *sb, const int flag)
return sbn;
}
-BulletSoftBody *copy_bulletsoftbody(const BulletSoftBody *bsb, const int UNUSED(flag))
-{
- BulletSoftBody *bsbn;
-
- if (bsb == NULL)
- return NULL;
- bsbn = MEM_dupallocN(bsb);
- /* no pointer in this structure yet */
- return bsbn;
-}
-
ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys, const int flag)
{
ParticleSystem *psysn;
@@ -1210,6 +1064,83 @@ Object *BKE_object_pose_armature_get_visible(Object *ob, ViewLayer *view_layer)
}
return NULL;
}
+
+/**
+ * Access pose array with special check to get pose object when in weight paint mode.
+ */
+Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, uint *r_objects_len, bool unique)
+{
+ Object *ob_active = OBACT(view_layer);
+ Object *ob_pose = BKE_object_pose_armature_get(ob_active);
+ Object **objects = NULL;
+ if (ob_pose == ob_active) {
+ objects = BKE_view_layer_array_from_objects_in_mode(
+ view_layer, r_objects_len, {
+ .object_mode = OB_MODE_POSE,
+ .no_dup_data = unique});
+ }
+ else if (ob_pose != NULL) {
+ *r_objects_len = 1;
+ objects = MEM_mallocN(sizeof(*objects), __func__);
+ objects[0] = ob_pose;
+ }
+ else {
+ *r_objects_len = 0;
+ objects = MEM_mallocN(0, __func__);
+ }
+ return objects;
+}
+Object **BKE_object_pose_array_get_unique(ViewLayer *view_layer, uint *r_objects_len)
+{
+ return BKE_object_pose_array_get_ex(view_layer, r_objects_len, true);
+}
+Object **BKE_object_pose_array_get(ViewLayer *view_layer, uint *r_objects_len)
+{
+ return BKE_object_pose_array_get_ex(view_layer, r_objects_len, false);
+}
+
+Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, uint *r_bases_len, bool unique)
+{
+ Base *base_active = BASACT(view_layer);
+ Object *ob_pose = base_active ? BKE_object_pose_armature_get(base_active->object) : NULL;
+ Base *base_pose = NULL;
+ Base **bases = NULL;
+
+ if (base_active) {
+ if (ob_pose == base_active->object) {
+ base_pose = base_active;
+ }
+ else {
+ base_pose = BKE_view_layer_base_find(view_layer, ob_pose);
+ }
+ }
+
+ if (base_active && (base_pose == base_active)) {
+ bases = BKE_view_layer_array_from_bases_in_mode(
+ view_layer, r_bases_len, {
+ .object_mode = OB_MODE_POSE,
+ .no_dup_data = unique});
+ }
+ else if (base_pose != NULL) {
+ *r_bases_len = 1;
+ bases = MEM_mallocN(sizeof(*bases), __func__);
+ bases[0] = base_pose;
+ }
+ else {
+ *r_bases_len = 0;
+ bases = MEM_mallocN(0, __func__);
+ }
+ return bases;
+}
+Base **BKE_object_pose_base_array_get_unique(ViewLayer *view_layer, uint *r_bases_len)
+{
+ return BKE_object_pose_base_array_get_ex(view_layer, r_bases_len, true);
+}
+Base **BKE_object_pose_base_array_get(ViewLayer *view_layer, uint *r_bases_len)
+{
+ return BKE_object_pose_base_array_get_ex(view_layer, r_bases_len, false);
+}
+
void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)
{
copy_v3_v3(ob_tar->loc, ob_src->loc);
@@ -1256,11 +1187,6 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
BLI_addtail(&ob_dst->modifiers, nmd);
}
- BLI_listbase_clear(&ob_dst->prop);
- BKE_bproperty_copy_list(&ob_dst->prop, &ob_src->prop);
-
- BKE_sca_logic_copy(ob_dst, ob_src, flag_subdata);
-
if (ob_src->pose) {
copy_object_pose(ob_dst, ob_src, flag_subdata);
/* backwards compat... non-armatures can get poses in older files? */
@@ -1281,7 +1207,6 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_
}
}
ob_dst->soft = copy_softbody(ob_src->soft, flag_subdata);
- ob_dst->bsoft = copy_bulletsoftbody(ob_src->bsoft, flag_subdata);
ob_dst->rigidbody_object = BKE_rigidbody_copy_object(ob_src, flag_subdata);
ob_dst->rigidbody_constraint = BKE_rigidbody_copy_constraint(ob_src, flag_subdata);
@@ -1803,7 +1728,7 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
if (scene == NULL) {
return false;
}
- BKE_displist_make_curveTypes(eval_ctx, scene, par, 0);
+ BKE_displist_make_curveTypes(depsgraph, scene, par, 0);
}
#endif
@@ -2187,7 +2112,7 @@ static bool where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat
/* note, scene is the active scene while actual_scene is the scene the object resides in */
void BKE_object_where_is_calc_time_ex(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime,
RigidBodyWorld *rbw, float r_originmat[3][3])
{
if (ob == NULL) return;
@@ -2223,7 +2148,7 @@ void BKE_object_where_is_calc_time_ex(
if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
bConstraintOb *cob;
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
- BKE_constraints_solve(eval_ctx, &ob->constraints, cob, ctime);
+ BKE_constraints_solve(depsgraph, &ob->constraints, cob, ctime);
BKE_constraints_clear_evalob(cob);
}
@@ -2232,9 +2157,9 @@ void BKE_object_where_is_calc_time_ex(
else ob->transflag &= ~OB_NEG_SCALE;
}
-void BKE_object_where_is_calc_time(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime)
+void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
{
- BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, ctime, NULL, NULL);
+ BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, ctime, NULL, NULL);
}
/* get object transformation matrix without recalculating dependencies and
@@ -2259,17 +2184,17 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
}
}
-void BKE_object_where_is_calc_ex(const EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
+void BKE_object_where_is_calc_ex(Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
{
- BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
+ BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
}
-void BKE_object_where_is_calc(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void BKE_object_where_is_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
- BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
+ BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
}
/* for calculation of the inverse parent transform, only used for editor */
-void BKE_object_workob_calc_parent(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *workob)
+void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *ob, Object *workob)
{
BKE_object_workob_clear(workob);
@@ -2291,7 +2216,7 @@ void BKE_object_workob_calc_parent(const EvaluationContext *eval_ctx, Scene *sce
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
- BKE_object_where_is_calc(eval_ctx, scene, workob);
+ BKE_object_where_is_calc(depsgraph, scene, workob);
}
/* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */
@@ -2547,7 +2472,7 @@ void BKE_object_empty_draw_type_set(Object *ob, const int value)
}
}
-bool BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_max[3], const bool use_hidden)
+bool BKE_object_minmax_dupli(Depsgraph *depsgraph, Scene *scene, Object *ob, float r_min[3], float r_max[3], const bool use_hidden)
{
bool ok = false;
if ((ob->transflag & OB_DUPLI) == 0) {
@@ -2556,7 +2481,7 @@ bool BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_m
else {
ListBase *lb;
DupliObject *dob;
- lb = object_duplilist(G.main->eval_ctx, scene, ob);
+ lb = object_duplilist(depsgraph, scene, ob);
for (dob = lb->first; dob; dob = dob->next) {
if ((use_hidden == false) && (dob->no_draw != 0)) {
/* pass */
@@ -2616,7 +2541,7 @@ void BKE_object_foreach_display_point(
}
void BKE_scene_foreach_display_point(
- Scene *scene, ViewLayer *view_layer,
+ Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer,
void (*func_cb)(const float[3], void *), void *user_data)
{
Base *base;
@@ -2633,7 +2558,7 @@ void BKE_scene_foreach_display_point(
ListBase *lb;
DupliObject *dob;
- lb = object_duplilist(G.main->eval_ctx, scene, ob);
+ lb = object_duplilist(depsgraph, scene, ob);
for (dob = lb->first; dob; dob = dob->next) {
if (dob->no_draw == 0) {
BKE_object_foreach_display_point(dob->ob, dob->mat, func_cb, user_data);
@@ -2656,7 +2581,7 @@ typedef struct ObTfmBack {
float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */
float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */
float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */
- float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */
+ float imat[4][4]; /* inverse matrix of 'obmat' for during render, temporally: ipokeys of transform */
} ObTfmBack;
void *BKE_object_tfm_backup(Object *ob)
@@ -2713,7 +2638,7 @@ bool BKE_object_parent_loop_check(const Object *par, const Object *ob)
return BKE_object_parent_loop_check(par->parent, ob);
}
-static void object_handle_update_proxy(const EvaluationContext *eval_ctx,
+static void object_handle_update_proxy(Depsgraph *depsgraph,
Scene *scene,
Object *object,
const bool do_proxy_update)
@@ -2730,7 +2655,7 @@ static void object_handle_update_proxy(const EvaluationContext *eval_ctx,
if (object->proxy_group == NULL) {
if (do_proxy_update) {
// printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name);
- BKE_object_handle_update(eval_ctx, scene, object->proxy);
+ BKE_object_handle_update(depsgraph, scene, object->proxy);
}
}
}
@@ -2743,7 +2668,7 @@ static void object_handle_update_proxy(const EvaluationContext *eval_ctx,
/* the main object update call, for object matrix, constraints, keys and displist (modifiers) */
/* requires flags to be set! */
/* Ideally we shouldn't have to pass the rigid body world, but need bigger restructuring to avoid id */
-void BKE_object_handle_update_ex(const EvaluationContext *eval_ctx,
+void BKE_object_handle_update_ex(Depsgraph *depsgraph,
Scene *scene, Object *ob,
RigidBodyWorld *rbw,
const bool do_proxy_update)
@@ -2754,7 +2679,7 @@ void BKE_object_handle_update_ex(const EvaluationContext *eval_ctx,
(object_data != NULL) ? ((object_data->recalc & ID_RECALC_ALL) != 0)
: 0;
if (!recalc_object && ! recalc_data) {
- object_handle_update_proxy(eval_ctx, scene, ob, do_proxy_update);
+ object_handle_update_proxy(depsgraph, scene, ob, do_proxy_update);
return;
}
/* Speed optimization for animation lookups. */
@@ -2782,18 +2707,18 @@ void BKE_object_handle_update_ex(const EvaluationContext *eval_ctx,
printf("recalcob %s\n", ob->id.name + 2);
}
/* Handle proxy copy for target. */
- if (!BKE_object_eval_proxy_copy(eval_ctx, ob)) {
- BKE_object_where_is_calc_ex(eval_ctx, scene, rbw, ob, NULL);
+ if (!BKE_object_eval_proxy_copy(depsgraph, ob)) {
+ BKE_object_where_is_calc_ex(depsgraph, scene, rbw, ob, NULL);
}
}
if (recalc_data) {
- BKE_object_handle_data_update(eval_ctx, scene, ob);
+ BKE_object_handle_data_update(depsgraph, scene, ob);
}
ob->id.recalc &= ID_RECALC_ALL;
- object_handle_update_proxy(eval_ctx, scene, ob, do_proxy_update);
+ object_handle_update_proxy(depsgraph, scene, ob, do_proxy_update);
}
/* WARNING: "scene" here may not be the scene object actually resides in.
@@ -2801,9 +2726,9 @@ void BKE_object_handle_update_ex(const EvaluationContext *eval_ctx,
* e.g. "scene" <-- set 1 <-- set 2 ("ob" lives here) <-- set 3 <-- ... <-- set n
* rigid bodies depend on their world so use BKE_object_handle_update_ex() to also pass along the corrent rigid body world
*/
-void BKE_object_handle_update(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void BKE_object_handle_update(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
- BKE_object_handle_update_ex(eval_ctx, scene, ob, NULL, true);
+ BKE_object_handle_update_ex(depsgraph, scene, ob, NULL, true);
}
void BKE_object_sculpt_modifiers_changed(Object *ob)
@@ -3721,7 +3646,7 @@ static void object_cacheIgnoreClear(Object *ob, int state)
* Avoid calling this in new code unless there is a very good reason for it!
*/
bool BKE_object_modifier_update_subframe(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update_mesh,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, bool update_mesh,
int parent_recursion, float frame, int type)
{
ModifierData *md = modifiers_findByType(ob, (ModifierType)type);
@@ -3745,8 +3670,8 @@ bool BKE_object_modifier_update_subframe(
if (parent_recursion) {
int recursion = parent_recursion - 1;
bool no_update = false;
- if (ob->parent) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->parent, 0, recursion, frame, type);
- if (ob->track) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->track, 0, recursion, frame, type);
+ if (ob->parent) no_update |= BKE_object_modifier_update_subframe(depsgraph, scene, ob->parent, 0, recursion, frame, type);
+ if (ob->track) no_update |= BKE_object_modifier_update_subframe(depsgraph, scene, ob->track, 0, recursion, frame, type);
/* skip subframe if object is parented
* to vertex of a dynamic paint canvas */
@@ -3763,7 +3688,7 @@ bool BKE_object_modifier_update_subframe(
cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar)
- BKE_object_modifier_update_subframe(eval_ctx, scene, ct->tar, 0, recursion, frame, type);
+ BKE_object_modifier_update_subframe(depsgraph, scene, ct->tar, 0, recursion, frame, type);
}
/* free temp targets */
if (cti->flush_constraint_targets)
@@ -3780,11 +3705,11 @@ bool BKE_object_modifier_update_subframe(
/* ignore cache clear during subframe updates
* to not mess up cache validity */
object_cacheIgnoreClear(ob, 1);
- BKE_object_handle_update(G.main->eval_ctx, scene, ob);
+ BKE_object_handle_update(depsgraph, scene, ob);
object_cacheIgnoreClear(ob, 0);
}
else
- BKE_object_where_is_calc_time(eval_ctx, scene, ob, frame);
+ BKE_object_where_is_calc_time(depsgraph, scene, ob, frame);
/* for curve following objects, parented curve has to be updated too */
if (ob->type == OB_CURVE) {
@@ -3795,7 +3720,7 @@ bool BKE_object_modifier_update_subframe(
if (ob->type == OB_ARMATURE) {
bArmature *arm = ob->data;
BKE_animsys_evaluate_animdata(scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM);
- BKE_pose_where_is(eval_ctx, scene, ob);
+ BKE_pose_where_is(depsgraph, scene, ob);
}
return false;
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 1b976fef166..eafd2d95cf1 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -63,6 +63,7 @@
#include "BKE_anim.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "BLI_strict_flags.h"
#include "BLI_hash.h"
@@ -70,7 +71,7 @@
/* Dupli-Geometry */
typedef struct DupliContext {
- const EvaluationContext *eval_ctx;
+ Depsgraph *depsgraph;
bool do_update;
bool animated;
Group *group; /* XXX child objects are selected from this group if set, could be nicer */
@@ -98,13 +99,13 @@ typedef struct DupliGenerator {
static const DupliGenerator *get_dupli_generator(const DupliContext *ctx);
/* create initial context for root object */
-static void init_context(DupliContext *r_ctx, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, float space_mat[4][4], bool update)
+static void init_context(DupliContext *r_ctx, Depsgraph *depsgraph, Scene *scene, Object *ob, float space_mat[4][4], bool update)
{
- r_ctx->eval_ctx = eval_ctx;
+ r_ctx->depsgraph = depsgraph;
r_ctx->scene = scene;
- r_ctx->view_layer = eval_ctx->view_layer;
+ r_ctx->view_layer = DEG_get_evaluated_view_layer(depsgraph);
/* don't allow BKE_object_handle_update for viewport during render, can crash */
- r_ctx->do_update = update && !(G.is_rendering && eval_ctx->mode != DAG_EVAL_RENDER);
+ r_ctx->do_update = update && !(G.is_rendering && DEG_get_mode(depsgraph) != DAG_EVAL_RENDER);
r_ctx->animated = false;
r_ctx->group = NULL;
@@ -310,7 +311,7 @@ static void make_duplis_group(const DupliContext *ctx)
if (ctx->do_update) {
/* note: update is optional because we don't always need object
* transformations to be correct. Also fixes bug [#29616]. */
- BKE_group_handle_recalc_and_update(ctx->eval_ctx, ctx->scene, ob, group);
+ BKE_group_handle_recalc_and_update(ctx->depsgraph, ctx->scene, ob, group);
}
animated = BKE_group_is_animated(group, ob);
@@ -383,7 +384,7 @@ static void make_duplis_frames(const DupliContext *ctx)
* However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine!
*/
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
- BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, (float)scene->r.cfra);
+ BKE_object_where_is_calc_time(ctx->depsgraph, scene, ob, (float)scene->r.cfra);
make_dupli(ctx, ob, ob->obmat, scene->r.cfra, false, false, NULL);
}
@@ -397,7 +398,7 @@ static void make_duplis_frames(const DupliContext *ctx)
scene->r.cfra = cfrao;
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
- BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, (float)scene->r.cfra);
+ BKE_object_where_is_calc_time(ctx->depsgraph, scene, ob, (float)scene->r.cfra);
/* but, to make sure unkeyed object transforms are still sane,
* let's copy object's original data back over
@@ -519,7 +520,7 @@ static void make_duplis_verts(const DupliContext *ctx)
{
Scene *scene = ctx->scene;
Object *parent = ctx->object;
- bool use_texcoords = ELEM(ctx->eval_ctx->mode, DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
+ bool use_texcoords = ELEM(DEG_get_mode(ctx->depsgraph), DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
VertexDupliData vdd;
vdd.ctx = ctx;
@@ -531,14 +532,14 @@ static void make_duplis_verts(const DupliContext *ctx)
BMEditMesh *em = BKE_editmesh_from_object(parent);
CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO : CD_MASK_BAREMESH);
- if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) {
- vdd.dm = mesh_create_derived_render(ctx->eval_ctx, scene, parent, dm_mask);
+ if (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER) {
+ vdd.dm = mesh_create_derived_render(ctx->depsgraph, scene, parent, dm_mask);
}
else if (em) {
- vdd.dm = editbmesh_get_derived_cage(ctx->eval_ctx, scene, parent, em, dm_mask);
+ vdd.dm = editbmesh_get_derived_cage(ctx->depsgraph, scene, parent, em, dm_mask);
}
else {
- vdd.dm = mesh_get_derived_final(ctx->eval_ctx, scene, parent, dm_mask);
+ vdd.dm = mesh_get_derived_final(ctx->depsgraph, scene, parent, dm_mask);
}
vdd.edit_btmesh = me->edit_btmesh;
@@ -723,7 +724,7 @@ static void make_child_duplis_faces(const DupliContext *ctx, void *userdata, Obj
float (*orco)[3] = fdd->orco;
MLoopUV *mloopuv = fdd->mloopuv;
int a, totface = fdd->totface;
- bool use_texcoords = ELEM(ctx->eval_ctx->mode, DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
+ bool use_texcoords = ELEM(DEG_get_mode(ctx->depsgraph), DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
float child_imat[4][4];
DupliObject *dob;
@@ -789,7 +790,7 @@ static void make_duplis_faces(const DupliContext *ctx)
{
Scene *scene = ctx->scene;
Object *parent = ctx->object;
- bool use_texcoords = ELEM(ctx->eval_ctx->mode, DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
+ bool use_texcoords = ELEM(DEG_get_mode(ctx->depsgraph), DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
FaceDupliData fdd;
fdd.use_scale = ((parent->transflag & OB_DUPLIFACES_SCALE) != 0);
@@ -799,14 +800,14 @@ static void make_duplis_faces(const DupliContext *ctx)
BMEditMesh *em = BKE_editmesh_from_object(parent);
CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO | CD_MASK_MLOOPUV : CD_MASK_BAREMESH);
- if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) {
- fdd.dm = mesh_create_derived_render(ctx->eval_ctx, scene, parent, dm_mask);
+ if (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER) {
+ fdd.dm = mesh_create_derived_render(ctx->depsgraph, scene, parent, dm_mask);
}
else if (em) {
- fdd.dm = editbmesh_get_derived_cage(ctx->eval_ctx, scene, parent, em, dm_mask);
+ fdd.dm = editbmesh_get_derived_cage(ctx->depsgraph, scene, parent, em, dm_mask);
}
else {
- fdd.dm = mesh_get_derived_final(ctx->eval_ctx, scene, parent, dm_mask);
+ fdd.dm = mesh_get_derived_final(ctx->depsgraph, scene, parent, dm_mask);
}
if (use_texcoords) {
@@ -841,8 +842,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
{
Scene *scene = ctx->scene;
Object *par = ctx->object;
- bool for_render = ctx->eval_ctx->mode == DAG_EVAL_RENDER;
- bool use_texcoords = ELEM(ctx->eval_ctx->mode, DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
+ bool for_render = DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER;
+ bool use_texcoords = ELEM(DEG_get_mode(ctx->depsgraph), DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
Object *ob = NULL, **oblist = NULL, obcopy, *obcopylist = NULL;
DupliObject *dob;
@@ -857,7 +858,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
float (*obmat)[4];
int a, b, hair = 0;
int totpart, totchild, totgroup = 0 /*, pa_num */;
- const bool dupli_type_hack = !BKE_scene_use_new_shading_nodes(scene);
int no_draw_flag = PARS_UNEXIST;
@@ -868,7 +868,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
if (part == NULL)
return;
- if (!psys_check_enabled(par, psys, (ctx->eval_ctx->mode == DAG_EVAL_RENDER)))
+ if (!psys_check_enabled(par, psys, (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER)))
return;
if (!for_render)
@@ -883,7 +883,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
if ((for_render || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
ParticleSimulationData sim = {NULL};
- sim.eval_ctx = ctx->eval_ctx;
+ sim.depsgraph = ctx->depsgraph;
sim.scene = scene;
sim.ob = par;
sim.psys = psys;
@@ -924,7 +924,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
/* gather list of objects or single object */
if (part->ren_as == PART_DRAW_GR) {
if (ctx->do_update) {
- BKE_group_handle_recalc_and_update(ctx->eval_ctx, scene, par, part->dup_group);
+ BKE_group_handle_recalc_and_update(ctx->depsgraph, scene, par, part->dup_group);
}
if (part->draw & PART_DRAW_COUNT_GR) {
@@ -1086,7 +1086,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
}
else {
/* to give ipos in object correct offset */
- BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, ctime - pa_time);
+ BKE_object_where_is_calc_time(ctx->depsgraph, scene, ob, ctime - pa_time);
copy_v3_v3(vec, obmat[3]);
obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
@@ -1131,10 +1131,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
dob->particle_system = psys;
if (use_texcoords)
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
- /* XXX blender internal needs this to be set to dupligroup to render
- * groups correctly, but we don't want this hack for cycles */
- if (dupli_type_hack && ctx->group)
- dob->type = OB_DUPLIGROUP;
}
}
@@ -1190,7 +1186,7 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
return NULL;
/* Should the dupli's be generated for this object? - Respect restrict flags */
- if (ctx->eval_ctx->mode == DAG_EVAL_RENDER ? (restrictflag & OB_RESTRICT_RENDER) : (restrictflag & OB_RESTRICT_VIEW))
+ if (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER ? (restrictflag & OB_RESTRICT_RENDER) : (restrictflag & OB_RESTRICT_VIEW))
return NULL;
if (transflag & OB_DUPLIPARTS) {
@@ -1222,11 +1218,11 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
/* ---- ListBase dupli container implementation ---- */
/* Returns a list of DupliObject */
-ListBase *object_duplilist_ex(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update)
+ListBase *object_duplilist_ex(Depsgraph *depsgraph, Scene *scene, Object *ob, bool update)
{
ListBase *duplilist = MEM_callocN(sizeof(ListBase), "duplilist");
DupliContext ctx;
- init_context(&ctx, eval_ctx, scene, ob, NULL, update);
+ init_context(&ctx, depsgraph, scene, ob, NULL, update);
if (ctx.gen) {
ctx.duplilist = duplilist;
ctx.gen->make_duplis(&ctx);
@@ -1237,9 +1233,9 @@ ListBase *object_duplilist_ex(const EvaluationContext *eval_ctx, Scene *scene, O
/* note: previously updating was always done, this is why it defaults to be on
* but there are likely places it can be called without updating */
-ListBase *object_duplilist(const EvaluationContext *eval_ctx, Scene *sce, Object *ob)
+ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob)
{
- return object_duplilist_ex(eval_ctx, sce, ob, true);
+ return object_duplilist_ex(depsgraph, sce, ob, true);
}
void free_object_duplilist(ListBase *lb)
@@ -1286,7 +1282,7 @@ int count_duplilist(Object *ob)
return 1;
}
-DupliApplyData *duplilist_apply(const EvaluationContext *eval_ctx, Object *ob, Scene *scene, ListBase *duplilist)
+DupliApplyData *duplilist_apply(Depsgraph *depsgraph, Object *ob, Scene *scene, ListBase *duplilist)
{
DupliApplyData *apply_data = NULL;
int num_objects = BLI_listbase_count(duplilist);
@@ -1302,7 +1298,7 @@ DupliApplyData *duplilist_apply(const EvaluationContext *eval_ctx, Object *ob, S
for (dob = duplilist->first, i = 0; dob; dob = dob->next, ++i) {
/* make sure derivedmesh is calculated once, before drawing */
if (scene && !(dob->ob->transflag & OB_DUPLICALCDERIVED) && dob->ob->type == OB_MESH) {
- mesh_get_derived_final(eval_ctx, scene, dob->ob, scene->customdata_mask);
+ mesh_get_derived_final(depsgraph, scene, dob->ob, scene->customdata_mask);
dob->ob->transflag |= OB_DUPLICALCDERIVED;
}
}
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 10ccc9fb672..98c10d89978 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -64,10 +64,12 @@
#include "BKE_groom.h"
#include "MEM_guardedalloc.h"
+
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
-void BKE_object_eval_local_transform(const EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_eval_local_transform(Depsgraph *UNUSED(depsgraph),
Object *ob)
{
DEG_debug_print_eval(__func__, ob->id.name, ob);
@@ -78,7 +80,7 @@ void BKE_object_eval_local_transform(const EvaluationContext *UNUSED(eval_ctx),
/* Evaluate parent */
/* NOTE: based on solve_parenting(), but with the cruft stripped out */
-void BKE_object_eval_parent(const EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_eval_parent(Depsgraph *UNUSED(depsgraph),
Scene *scene,
Object *ob)
{
@@ -110,7 +112,7 @@ void BKE_object_eval_parent(const EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_object_eval_constraints(const EvaluationContext *eval_ctx,
+void BKE_object_eval_constraints(Depsgraph *depsgraph,
Scene *scene,
Object *ob)
{
@@ -129,11 +131,11 @@ void BKE_object_eval_constraints(const EvaluationContext *eval_ctx,
*
*/
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
- BKE_constraints_solve(eval_ctx, &ob->constraints, cob, ctime);
+ BKE_constraints_solve(depsgraph, &ob->constraints, cob, ctime);
BKE_constraints_clear_evalob(cob);
}
-void BKE_object_eval_done(const EvaluationContext *UNUSED(eval_ctx), Object *ob)
+void BKE_object_eval_done(Depsgraph *UNUSED(depsgraph), Object *ob)
{
DEG_debug_print_eval(__func__, ob->id.name, ob);
@@ -143,7 +145,7 @@ void BKE_object_eval_done(const EvaluationContext *UNUSED(eval_ctx), Object *ob)
}
void BKE_object_handle_data_update(
- const EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Scene *scene,
Object *ob)
{
@@ -173,19 +175,27 @@ void BKE_object_handle_data_update(
switch (ob->type) {
case OB_MESH:
{
+#if 0
BMEditMesh *em = (ob->mode & OB_MODE_EDIT) ? BKE_editmesh_from_object(ob) : NULL;
+#else
+ BMEditMesh *em = (ob->mode & OB_MODE_EDIT) ? ((Mesh *)ob->data)->edit_btmesh : NULL;
+ if (em && em->ob != ob) {
+ em = NULL;
+ }
+#endif
+
uint64_t data_mask = scene->customdata_mask | CD_MASK_BAREMESH;
#ifdef WITH_FREESTYLE
/* make sure Freestyle edge/face marks appear in DM for render (see T40315) */
- if (eval_ctx->mode != DAG_EVAL_VIEWPORT) {
+ if (DEG_get_mode(depsgraph) != DAG_EVAL_VIEWPORT) {
data_mask |= CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
}
#endif
if (em) {
- makeDerivedMesh(eval_ctx, scene, ob, em, data_mask, false); /* was CD_MASK_BAREMESH */
+ makeDerivedMesh(depsgraph, scene, ob, em, data_mask, false); /* was CD_MASK_BAREMESH */
}
else {
- makeDerivedMesh(eval_ctx, scene, ob, NULL, data_mask, false);
+ makeDerivedMesh(depsgraph, scene, ob, NULL, data_mask, false);
}
break;
}
@@ -197,22 +207,22 @@ void BKE_object_handle_data_update(
}
}
else {
- BKE_pose_where_is(eval_ctx, scene, ob);
+ BKE_pose_where_is(depsgraph, scene, ob);
}
break;
case OB_MBALL:
- BKE_displist_make_mball(eval_ctx, scene, ob);
+ BKE_displist_make_mball(depsgraph, scene, ob);
break;
case OB_CURVE:
case OB_SURF:
case OB_FONT:
- BKE_displist_make_curveTypes(eval_ctx, scene, ob, 0);
+ BKE_displist_make_curveTypes(depsgraph, scene, ob, 0);
break;
case OB_LATTICE:
- BKE_lattice_modifiers_calc(eval_ctx, scene, ob);
+ BKE_lattice_modifiers_calc(depsgraph, scene, ob);
break;
case OB_EMPTY:
@@ -224,6 +234,7 @@ void BKE_object_handle_data_update(
/* particles */
if (!(ob->mode & OB_MODE_EDIT) && ob->particlesystem.first) {
+ const bool use_render_params = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
ParticleSystem *tpsys, *psys;
DerivedMesh *dm;
ob->transflag &= ~OB_DUPLIPARTS;
@@ -234,16 +245,16 @@ void BKE_object_handle_data_update(
psys_changed_type(ob, psys);
}
- if (psys_check_enabled(ob, psys, eval_ctx->mode == DAG_EVAL_RENDER)) {
+ if (psys_check_enabled(ob, psys, use_render_params)) {
/* check use of dupli objects here */
- if (psys->part && (psys->part->draw_as == PART_DRAW_REND || eval_ctx->mode == DAG_EVAL_RENDER) &&
+ if (psys->part && (psys->part->draw_as == PART_DRAW_REND || use_render_params) &&
((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob) ||
(psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group)))
{
ob->transflag |= OB_DUPLIPARTS;
}
- particle_system_update(eval_ctx, scene, ob, psys, (eval_ctx->mode == DAG_EVAL_RENDER));
+ particle_system_update(depsgraph, scene, ob, psys, use_render_params);
psys = psys->next;
}
else if (psys->flag & PSYS_DELETE) {
@@ -256,12 +267,12 @@ void BKE_object_handle_data_update(
psys = psys->next;
}
- if (eval_ctx->mode == DAG_EVAL_RENDER && ob->transflag & OB_DUPLIPARTS) {
+ if (use_render_params && ob->transflag & OB_DUPLIPARTS) {
/* this is to make sure we get render level duplis in groups:
* the derivedmesh must be created before init_render_mesh,
* since object_duplilist does dupliparticles before that */
CustomDataMask data_mask = CD_MASK_BAREMESH | CD_MASK_MFACE | CD_MASK_MTFACE | CD_MASK_MCOL;
- dm = mesh_create_derived_render(eval_ctx, scene, ob, data_mask);
+ dm = mesh_create_derived_render(depsgraph, scene, ob, data_mask);
dm->release(dm);
for (psys = ob->particlesystem.first; psys; psys = psys->next)
@@ -272,7 +283,7 @@ void BKE_object_handle_data_update(
/* quick cache removed */
}
-bool BKE_object_eval_proxy_copy(const EvaluationContext *UNUSED(eval_ctx),
+bool BKE_object_eval_proxy_copy(Depsgraph *UNUSED(depsgraph),
Object *object)
{
/* Handle proxy copy for target, */
@@ -296,18 +307,18 @@ bool BKE_object_eval_proxy_copy(const EvaluationContext *UNUSED(eval_ctx),
return false;
}
-void BKE_object_eval_uber_transform(const EvaluationContext *eval_ctx, Object *object)
+void BKE_object_eval_uber_transform(Depsgraph *depsgraph, Object *object)
{
- BKE_object_eval_proxy_copy(eval_ctx, object);
+ BKE_object_eval_proxy_copy(depsgraph, object);
}
-void BKE_object_eval_uber_data(const EvaluationContext *eval_ctx,
+void BKE_object_eval_uber_data(Depsgraph *depsgraph,
Scene *scene,
Object *ob)
{
DEG_debug_print_eval(__func__, ob->id.name, ob);
BLI_assert(ob->type != OB_ARMATURE);
- BKE_object_handle_data_update(eval_ctx, scene, ob);
+ BKE_object_handle_data_update(depsgraph, scene, ob);
switch (ob->type) {
case OB_MESH:
@@ -382,7 +393,7 @@ void BKE_object_eval_uber_data(const EvaluationContext *eval_ctx,
}
}
-void BKE_object_eval_cloth(const EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_eval_cloth(Depsgraph *UNUSED(depsgraph),
Scene *scene,
Object *object)
{
@@ -390,23 +401,23 @@ void BKE_object_eval_cloth(const EvaluationContext *UNUSED(eval_ctx),
BKE_ptcache_object_reset(scene, object, PTCACHE_RESET_DEPSGRAPH);
}
-void BKE_object_eval_transform_all(const EvaluationContext *eval_ctx,
+void BKE_object_eval_transform_all(Depsgraph *depsgraph,
Scene *scene,
Object *object)
{
/* This mimics full transform update chain from new depsgraph. */
- BKE_object_eval_local_transform(eval_ctx, object);
+ BKE_object_eval_local_transform(depsgraph, object);
if (object->parent != NULL) {
- BKE_object_eval_parent(eval_ctx, scene, object);
+ BKE_object_eval_parent(depsgraph, scene, object);
}
if (!BLI_listbase_is_empty(&object->constraints)) {
- BKE_object_eval_constraints(eval_ctx, scene, object);
+ BKE_object_eval_constraints(depsgraph, scene, object);
}
- BKE_object_eval_uber_transform(eval_ctx, object);
- BKE_object_eval_done(eval_ctx, object);
+ BKE_object_eval_uber_transform(depsgraph, object);
+ BKE_object_eval_done(depsgraph, object);
}
-void BKE_object_eval_update_shading(const EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_eval_update_shading(Depsgraph *UNUSED(depsgraph),
Object *object)
{
DEG_debug_print_eval(__func__, object->id.name, object);
@@ -415,7 +426,7 @@ void BKE_object_eval_update_shading(const EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_object_data_select_update(const EvaluationContext *UNUSED(eval_ctx),
+void BKE_object_data_select_update(Depsgraph *UNUSED(depsgraph),
struct ID *object_data)
{
DEG_debug_print_eval(__func__, object_data->name, object_data);
@@ -441,10 +452,15 @@ void BKE_object_data_select_update(const EvaluationContext *UNUSED(eval_ctx),
}
}
-void BKE_object_eval_flush_base_flags(const EvaluationContext *eval_ctx,
- Object *object, int base_index, bool is_from_set)
+void BKE_object_eval_flush_base_flags(Depsgraph *UNUSED(depsgraph),
+ Scene *scene, const int view_layer_index,
+ Object *object, int base_index,
+ const bool is_from_set)
{
- ViewLayer *view_layer = eval_ctx->view_layer;
+ /* TODO(sergey): Avoid list lookup. */
+ BLI_assert(view_layer_index >= 0);
+ ViewLayer *view_layer = BLI_findlink(&scene->view_layers, view_layer_index);
+ BLI_assert(view_layer != NULL);
BLI_assert(view_layer->object_bases_array != NULL);
BLI_assert(base_index >= 0);
BLI_assert(base_index < MEM_allocN_len(view_layer->object_bases_array) / sizeof(Base *));
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 20375fe6953..ed1d9519046 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -881,7 +881,7 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
* \param need_mask So the DerivedMesh thats returned has mask data
*/
void BKE_sculpt_update_mesh_elements(
- const EvaluationContext *eval_ctx, Scene *scene, Sculpt *sd, Object *ob,
+ Depsgraph *depsgraph, Scene *scene, Sculpt *sd, Object *ob,
bool need_pmap, bool need_mask)
{
DerivedMesh *dm;
@@ -921,7 +921,7 @@ void BKE_sculpt_update_mesh_elements(
ss->kb = (mmd == NULL) ? BKE_keyblock_from_object(ob) : NULL;
- dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
/* VWPaint require mesh info for loop lookup, so require sculpt mode here */
if (mmd && ob->mode & OB_MODE_SCULPT) {
@@ -956,7 +956,7 @@ void BKE_sculpt_update_mesh_elements(
ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL);
- BKE_crazyspace_build_sculpt(eval_ctx, scene, ob, &ss->deform_imats, &ss->deform_cos);
+ BKE_crazyspace_build_sculpt(depsgraph, scene, ob, &ss->deform_imats, &ss->deform_cos);
BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
for (a = 0; a < me->totvert; ++a) {
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 713d523cb1e..1edeedab817 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -252,7 +252,7 @@ struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData
{
struct LatticeDeformData *lattice_deform_data = NULL;
- if (psys_in_edit_mode(sim->eval_ctx->depsgraph, sim->psys) == 0) {
+ if (psys_in_edit_mode(sim->depsgraph, sim->psys) == 0) {
Object *lattice = NULL;
ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys);
int mode = G.is_rendering ? eModifierMode_Render : eModifierMode_Realtime;
@@ -291,7 +291,7 @@ void psys_enable_all(Object *ob)
bool psys_in_edit_mode(Depsgraph *depsgraph, ParticleSystem *psys)
{
- ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
const bool use_render_params = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
return (view_layer->basact &&
@@ -1031,7 +1031,7 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach
/* interpolate a location on a face based on face coordinates */
void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*orcodata)[3],
float w[4], float vec[3], float nor[3], float utan[3], float vtan[3],
- float orco[3], float ornor[3])
+ float orco[3])
{
float *v1 = 0, *v2 = 0, *v3 = 0, *v4 = 0;
float e1[3], e2[3], s1, s2, t1, t2;
@@ -1129,21 +1129,13 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
o4 = orcodata[mface->v4];
interp_v3_v3v3v3v3(orco, o1, o2, o3, o4, w);
-
- if (ornor)
- normal_quad_v3(ornor, o1, o2, o3, o4);
}
else {
interp_v3_v3v3v3(orco, o1, o2, o3, w);
-
- if (ornor)
- normal_tri_v3(ornor, o1, o2, o3);
}
}
else {
copy_v3_v3(orco, vec);
- if (ornor && nor)
- copy_v3_v3(ornor, nor);
}
}
}
@@ -1428,7 +1420,7 @@ int psys_get_index_on_dm(ParticleSystem *psys, DerivedMesh *dm, ParticleData *pa
/* interprets particle data to get a point on a mesh in object space */
void psys_particle_on_dm(DerivedMesh *dm_final, int from, int index, int index_dmcache,
const float fw[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3],
- float orco[3], float ornor[3])
+ float orco[3])
{
float tmpnor[3], mapfw[4];
float (*orcodata)[3];
@@ -1438,7 +1430,6 @@ void psys_particle_on_dm(DerivedMesh *dm_final, int from, int index, int index_d
if (vec) { vec[0] = vec[1] = vec[2] = 0.0; }
if (nor) { nor[0] = nor[1] = 0.0; nor[2] = 1.0; }
if (orco) { orco[0] = orco[1] = orco[2] = 0.0; }
- if (ornor) { ornor[0] = ornor[1] = 0.0; ornor[2] = 1.0; }
if (utan) { utan[0] = utan[1] = utan[2] = 0.0; }
if (vtan) { vtan[0] = vtan[1] = vtan[2] = 0.0; }
@@ -1464,11 +1455,6 @@ void psys_particle_on_dm(DerivedMesh *dm_final, int from, int index, int index_d
}
}
- if (ornor) {
- dm_final->getVertNo(dm_final, mapindex, ornor);
- normalize_v3(ornor);
- }
-
if (utan && vtan) {
utan[0] = utan[1] = utan[2] = 0.0f;
vtan[0] = vtan[1] = vtan[2] = 0.0f;
@@ -1487,7 +1473,7 @@ void psys_particle_on_dm(DerivedMesh *dm_final, int from, int index, int index_d
mtface += mapindex;
if (from == PART_FROM_VOLUME) {
- psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, tmpnor, utan, vtan, orco, ornor);
+ psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, tmpnor, utan, vtan, orco);
if (nor)
copy_v3_v3(nor, tmpnor);
@@ -1496,7 +1482,7 @@ void psys_particle_on_dm(DerivedMesh *dm_final, int from, int index, int index_d
add_v3_v3(vec, tmpnor);
}
else
- psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, nor, utan, vtan, orco, ornor);
+ psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, nor, utan, vtan, orco);
}
}
@@ -1532,7 +1518,7 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys)
/* ready for future use */
static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index),
float *UNUSED(fuv), float vec[3], float nor[3], float utan[3], float vtan[3],
- float orco[3], float ornor[3])
+ float orco[3])
{
/* TODO */
float zerovec[3] = {0.0f, 0.0f, 0.0f};
@@ -1551,9 +1537,6 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index),
if (orco) {
copy_v3_v3(orco, zerovec);
}
- if (ornor) {
- copy_v3_v3(ornor, zerovec);
- }
}
/************************************************/
/* Particles on emitter */
@@ -1596,7 +1579,7 @@ CustomDataMask psys_emitter_customdata_mask(ParticleSystem *psys)
void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int index, int index_dmcache,
float fuv[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3],
- float orco[3], float ornor[3])
+ float orco[3])
{
if (psmd && psmd->dm_final) {
if (psmd->psys->part->distr == PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) {
@@ -1608,10 +1591,10 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int in
return;
}
/* we cant use the num_dmcache */
- psys_particle_on_dm(psmd->dm_final, from, index, index_dmcache, fuv, foffset, vec, nor, utan, vtan, orco, ornor);
+ psys_particle_on_dm(psmd->dm_final, from, index, index_dmcache, fuv, foffset, vec, nor, utan, vtan, orco);
}
else
- psys_particle_on_shape(from, index, fuv, vec, nor, utan, vtan, orco, ornor);
+ psys_particle_on_shape(from, index, fuv, vec, nor, utan, vtan, orco);
}
/************************************************/
@@ -1633,7 +1616,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
return;
LOOP_PARTICLES {
- psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, state.co, 0, 0, 0, 0, 0);
+ psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, state.co, 0, 0, 0, 0);
mul_m4_v3(sim->ob->obmat, state.co);
mul_mat3_m4_v3(sim->ob->obmat, state.vel);
@@ -1659,7 +1642,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
}
}
-int do_guides(const EvaluationContext *eval_ctx, ParticleSettings *part, ListBase *effectors, ParticleKey *state, int index, float time)
+int do_guides(Depsgraph *depsgraph, ParticleSettings *part, ListBase *effectors, ParticleKey *state, int index, float time)
{
CurveMapping *clumpcurve = (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve : NULL;
CurveMapping *roughcurve = (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve : NULL;
@@ -1722,7 +1705,7 @@ int do_guides(const EvaluationContext *eval_ctx, ParticleSettings *part, ListBas
/* curve taper */
if (cu->taperobj)
- mul_v3_fl(vec_to_point, BKE_displist_calc_taper(eval_ctx, eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100));
+ mul_v3_fl(vec_to_point, BKE_displist_calc_taper(depsgraph, eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100));
else { /* curve size*/
if (cu->flag & CU_PATH_RADIUS) {
@@ -1872,7 +1855,7 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
tree = BLI_kdtree_new(totparent);
for (p = 0, cpa = sim->psys->child; p < totparent; p++, cpa++) {
- psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0);
+ psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco);
/* Check if particle doesn't exist because of texture influence. Insert only existing particles into kdtree. */
get_cpa_texture(sim->psmd->dm_final, psys, part, psys->particles + cpa->pa[0], p, cpa->num, cpa->fuv, orco, &ptex, PAMAP_DENS | PAMAP_CHILD, psys->cfra);
@@ -1885,7 +1868,7 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
BLI_kdtree_balance(tree);
for (; p < totchild; p++, cpa++) {
- psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0);
+ psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco);
cpa->parent = BLI_kdtree_find_nearest(tree, orco, NULL);
}
@@ -1905,7 +1888,7 @@ static bool psys_thread_context_init_path(
psys_thread_context_init(ctx, sim);
/*---start figuring out what is actually wanted---*/
- if (psys_in_edit_mode(sim->eval_ctx->depsgraph, psys)) {
+ if (psys_in_edit_mode(sim->depsgraph, psys)) {
ParticleEditSettings *pset = &scene->toolsettings->particle;
if ((use_render_params == 0) && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0)
@@ -2002,11 +1985,11 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
ParticleSystem *psys = ctx->sim.psys;
ParticleSettings *part = psys->part;
ParticleCacheKey **cache = psys->childcache;
- ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.eval_ctx->depsgraph, psys) && psys->edit ? psys->edit->pathcache : psys->pathcache;
+ ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.depsgraph, psys) && psys->edit ? psys->edit->pathcache : psys->pathcache;
ParticleCacheKey *child, *key[4];
ParticleTexture ptex;
float *cpa_fuv = 0, *par_rot = 0, rot[4];
- float orco[3], ornor[3], hairmat[4][4], dvec[3], off1[4][3], off2[4][3];
+ float orco[3], hairmat[4][4], dvec[3], off1[4][3], off2[4][3];
float eff_length, eff_vec[3], weight[4];
int k, cpa_num;
short cpa_from;
@@ -2102,7 +2085,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
cpa_fuv = cpa->fuv;
cpa_from = PART_FROM_FACE;
- psys_particle_on_emitter(ctx->sim.psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, ornor, 0, 0, orco, 0);
+ psys_particle_on_emitter(ctx->sim.psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, 0, 0, orco, 0);
mul_m4_v3(ob->obmat, co);
@@ -2144,7 +2127,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
cpa_num = 0;
cpa_fuv = pa->fuv;
- psys_particle_on_emitter(ctx->sim.psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa_fuv, pa->foffset, co, ornor, 0, 0, orco, 0);
+ psys_particle_on_emitter(ctx->sim.psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa_fuv, pa->foffset, co, 0, 0, orco, 0);
psys_mat_hair_to_global(ob, ctx->sim.psmd->dm_final, psys->part->from, pa, hairmat);
}
@@ -2252,9 +2235,9 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
BLI_listbase_clear(&modifiers);
psys_particle_on_emitter(ctx->sim.psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset,
- par_co, NULL, NULL, NULL, par_orco, NULL);
+ par_co, NULL, NULL, NULL, par_orco);
- psys_apply_child_modifiers(ctx, &modifiers, cpa, &ptex, orco, ornor, hairmat, child_keys, par, par_orco);
+ psys_apply_child_modifiers(ctx, &modifiers, cpa, &ptex, orco, hairmat, child_keys, par, par_orco);
}
else
zero_v3(par_orco);
@@ -2426,7 +2409,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
return;
#if 0 /* TODO(mai): something is very wrong with these conditionals, they dont make sense and the cache isnt updating */
- if (psys_in_edit_mode(sim->eval_ctx->depsgraph, psys))
+ if (psys_in_edit_mode(sim->depsgraph, psys))
if ((psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0)
return;
#endif
@@ -2547,7 +2530,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT) == 0) {
for (k = 0, ca = cache[p]; k <= segments; k++, ca++)
/* ca is safe to cast, since only co and vel are used */
- do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, (ParticleKey *)ca, p, (float)k / (float)segments);
+ do_guides(sim->depsgraph, sim->psys->part, sim->psys->effectors, (ParticleKey *)ca, p, (float)k / (float)segments);
}
/* lattices have to be calculated separately to avoid mixups between effector calculations */
@@ -2595,7 +2578,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if (vg_length)
MEM_freeN(vg_length);
}
-void psys_cache_edit_paths(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, PTCacheEdit *edit, float cfra, const bool use_render_params)
+void psys_cache_edit_paths(Depsgraph *depsgraph, Scene *scene, Object *ob, PTCacheEdit *edit, float cfra, const bool use_render_params)
{
ParticleCacheKey *ca, **cache = edit->pathcache;
ParticleEditSettings *pset = &scene->toolsettings->particle;
@@ -2623,7 +2606,7 @@ void psys_cache_edit_paths(const EvaluationContext *eval_ctx, Scene *scene, Obje
if (!cache || edit->totpoint != edit->totcached) {
/* clear out old and create new empty path cache */
- psys_free_path_cache(edit->psys, edit);
+ psys_free_path_cache(NULL, edit);
cache = edit->pathcache = psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, segments + 1);
/* set flag for update (child particles check this too) */
@@ -2796,7 +2779,7 @@ void psys_cache_edit_paths(const EvaluationContext *eval_ctx, Scene *scene, Obje
if (psys) {
ParticleSimulationData sim = {0};
- sim.eval_ctx = eval_ctx;
+ sim.depsgraph = depsgraph;
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -2933,7 +2916,7 @@ void psys_mat_hair_to_object(Object *UNUSED(ob), DerivedMesh *dm, short from, Pa
}
psys_face_mat(0, dm, pa, hairmat, 0);
- psys_particle_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, 0, 0);
+ psys_particle_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, 0);
copy_v3_v3(hairmat[3], vec);
}
@@ -2942,7 +2925,7 @@ void psys_mat_hair_to_orco(Object *ob, DerivedMesh *dm, short from, ParticleData
float vec[3], orco[3];
psys_face_mat(ob, dm, pa, hairmat, 1);
- psys_particle_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, orco, 0);
+ psys_particle_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, orco);
/* see psys_face_mat for why this function is called */
if (DM_get_vert_data_layer(dm, CD_ORIGINDEX))
@@ -3447,7 +3430,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
/* no break, failed to get uv's, so let's try orco's */
ATTR_FALLTHROUGH;
case TEXCO_ORCO:
- psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, 0, 0, 0, texvec, 0);
+ psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, 0, 0, 0, texvec);
if (me->bb == NULL || (me->bb->flag & BOUNDBOX_DIRTY)) {
BKE_mesh_texspace_calc(me);
@@ -3545,10 +3528,17 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED
ParticleSettings *part = psys->part;
float size; // time XXX
- if (part->childtype == PART_CHILD_FACES)
- size = part->size;
- else
+ if (part->childtype == PART_CHILD_FACES) {
+ int w = 0;
+ size = 0.0;
+ while (w < 4 && cpa->pa[w] >= 0) {
+ size += cpa->w[w] * (psys->particles + cpa->pa[w])->size;
+ w++;
+ }
+ }
+ else {
size = psys->particles[cpa->parent].size;
+ }
size *= part->childsize;
@@ -3636,7 +3626,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE);
/* pind.dm disabled in editmode means we don't get effectors taken into
* account when subdividing for instance */
- pind.dm = psys_in_edit_mode(sim->eval_ctx->depsgraph, psys) ? NULL : psys->hair_out_dm;
+ pind.dm = psys_in_edit_mode(sim->depsgraph, psys) ? NULL : psys->hair_out_dm;
init_particle_interpolation(sim->ob, psys, pa, &pind);
do_particle_interpolation(psys, p, pa, t, &pind, state);
@@ -3651,7 +3641,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
mul_mat3_m4_v3(hairmat, state->vel);
if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE) == 0) {
- do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, state, p, state->time);
+ do_guides(sim->depsgraph, sim->psys->part, sim->psys->effectors, state, p, state->time);
/* TODO: proper velocity handling */
}
@@ -3702,7 +3692,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
cpa_fuv = cpa->fuv;
cpa_from = PART_FROM_FACE;
- psys_particle_on_emitter(psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, 0, 0, 0, orco, 0);
+ psys_particle_on_emitter(psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, 0, 0, 0, orco);
/* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
//copy_v3_v3(cpa_1st, co);
@@ -3711,7 +3701,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
pa = psys->particles + cpa->parent;
- psys_particle_on_emitter(psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, par_co, 0, 0, 0, par_orco, 0);
+ psys_particle_on_emitter(psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, par_co, 0, 0, 0, par_orco);
if (part->type == PART_HAIR)
psys_mat_hair_to_global(sim->ob, sim->psmd->dm_final, psys->part->from, pa, hairmat);
else
@@ -3731,9 +3721,9 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
cpa_num = pa->num;
cpa_fuv = pa->fuv;
- psys_particle_on_emitter(psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, par_co, 0, 0, 0, par_orco, 0);
+ psys_particle_on_emitter(psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, par_co, 0, 0, 0, par_orco);
if (part->type == PART_HAIR) {
- psys_particle_on_emitter(psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa_fuv, pa->foffset, co, 0, 0, 0, orco, 0);
+ psys_particle_on_emitter(psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa_fuv, pa->foffset, co, 0, 0, 0, orco);
psys_mat_hair_to_global(sim->ob, sim->psmd->dm_final, psys->part->from, pa, hairmat);
}
else {
@@ -4018,7 +4008,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part,
psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv);
}
- psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, loc, 0, 0, 0, orco, 0);
+ psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, loc, 0, 0, 0, orco);
return;
}
else {
@@ -4049,7 +4039,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part,
}
}
- psys_particle_on_emitter(psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, 0, 0, 0, orco, 0);
+ psys_particle_on_emitter(psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, 0, 0, 0, orco);
}
void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa, ChildParticle *cpa, ParticleCacheKey *cache, float mat[4][4], float *scale)
@@ -4067,9 +4057,9 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
pa = psys->particles + cpa->pa[0];
if (pa)
- psys_particle_on_emitter(psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, nor, 0, 0, 0, 0);
+ psys_particle_on_emitter(psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, nor, 0, 0, 0);
else
- psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, loc, nor, 0, 0, 0, 0);
+ psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, loc, nor, 0, 0, 0);
if (psys->part->rotmode == PART_ROT_VEL) {
transpose_m3_m4(nmat, ob->imat);
@@ -4201,10 +4191,10 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
madd_v3_v3fl(center, yvec, bb->offset[1]);
}
-void psys_apply_hair_lattice(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys)
+void psys_apply_hair_lattice(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys)
{
ParticleSimulationData sim = {0};
- sim.eval_ctx = eval_ctx;
+ sim.depsgraph = depsgraph;
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c
index c2640e9b9e2..7cfad93224d 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -39,40 +39,6 @@
#include "particle_private.h"
-struct Material;
-
-static void get_strand_normal(Material *ma, const float surfnor[3], float surfdist, float nor[3])
-{
- float cross[3], nstrand[3], vnor[3], blend;
-
- if (!((ma->mode & MA_STR_SURFDIFF) || (ma->strand_surfnor > 0.0f)))
- return;
-
- if (ma->mode & MA_STR_SURFDIFF) {
- cross_v3_v3v3(cross, surfnor, nor);
- cross_v3_v3v3(nstrand, nor, cross);
-
- blend = dot_v3v3(nstrand, surfnor);
- CLAMP(blend, 0.0f, 1.0f);
-
- interp_v3_v3v3(vnor, nstrand, surfnor, blend);
- normalize_v3(vnor);
- }
- else {
- copy_v3_v3(vnor, nor);
- }
-
- if (ma->strand_surfnor > 0.0f) {
- if (ma->strand_surfnor > surfdist) {
- blend = (ma->strand_surfnor - surfdist) / ma->strand_surfnor;
- interp_v3_v3v3(vnor, vnor, surfnor, blend);
- normalize_v3(vnor);
- }
- }
-
- copy_v3_v3(nor, vnor);
-}
-
/* ------------------------------------------------------------------------- */
typedef struct ParticlePathIterator {
@@ -320,7 +286,7 @@ static bool check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *k
}
void psys_apply_child_modifiers(ParticleThreadContext *ctx, struct ListBase *modifiers,
- ChildParticle *cpa, ParticleTexture *ptex, const float orco[3], const float ornor[3], float hairmat[4][4],
+ ChildParticle *cpa, ParticleTexture *ptex, const float orco[3], float hairmat[4][4],
ParticleCacheKey *keys, ParticleCacheKey *parent_keys, const float parent_orco[3])
{
struct ParticleSettings *part = ctx->sim.psys->part;
@@ -389,9 +355,6 @@ void psys_apply_child_modifiers(ParticleThreadContext *ctx, struct ListBase *mod
if (k >= 2) {
sub_v3_v3v3((key-1)->vel, key->co, (key-2)->co);
mul_v3_fl((key-1)->vel, 0.5);
-
- if (ma && draw_col_ma)
- get_strand_normal(ma, ornor, cur_length, (key-1)->vel);
}
if (use_length_check && k > 0) {
@@ -413,7 +376,6 @@ void psys_apply_child_modifiers(ParticleThreadContext *ctx, struct ListBase *mod
if (ma && draw_col_ma) {
copy_v3_v3(key->col, &ma->r);
- get_strand_normal(ma, ornor, cur_length, key->vel);
}
}
}
@@ -816,7 +778,7 @@ void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx,
if (part->flag & PART_CHILD_EFFECT)
/* state is safe to cast, since only co and vel are used */
- guided = do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, (ParticleKey *)state, cpa->parent, t);
+ guided = do_guides(sim->depsgraph, sim->psys->part, sim->psys->effectors, (ParticleKey *)state, cpa->parent, t);
if (guided == 0) {
float orco_offset[3];
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index c261b0dc22c..bf21e18f4b9 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -240,10 +240,12 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
if (mface->v4 && (!intersects_tri || from==PART_FROM_VOLUME)) {
copy_v3_v3(v4, mvert[mface->v4].co);
- if (isect_ray_tri_watertight_v3(co1,
- &isect_precalc,
- v1, v3, v4,
- &lambda, NULL)) {
+ if (isect_ray_tri_watertight_v3(
+ co1,
+ &isect_precalc,
+ v1, v3, v4,
+ &lambda, NULL))
+ {
if (from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else
@@ -572,7 +574,7 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
/* experimental */
tot=dm->getNumTessFaces(dm);
- psys_interpolate_face(mvert,mface,0,0,pa->fuv,co,nor,0,0,0,0);
+ psys_interpolate_face(mvert,mface,0,0,pa->fuv,co,nor,0,0,0);
normalize_v3(nor);
negate_v3(nor);
@@ -659,7 +661,7 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
int parent[10];
float pweight[10];
- psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1,NULL);
+ psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1);
BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1);
maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
@@ -772,7 +774,7 @@ static void distribute_invalid(ParticleSimulationData *sim, int from)
{
Scene *scene = sim->scene;
ParticleSystem *psys = sim->psys;
- const bool use_render_params = (DEG_get_mode(sim->eval_ctx->depsgraph) == DAG_EVAL_RENDER);
+ const bool use_render_params = (DEG_get_mode(sim->depsgraph) == DAG_EVAL_RENDER);
if (from == PART_FROM_CHILD) {
ChildParticle *cpa;
@@ -840,7 +842,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
psys_thread_context_init(ctx, sim);
- const bool use_render_params = (DEG_get_mode(sim->eval_ctx->depsgraph) == DAG_EVAL_RENDER);
+ const bool use_render_params = (DEG_get_mode(sim->depsgraph) == DAG_EVAL_RENDER);
/* First handle special cases */
if (from == PART_FROM_CHILD) {
@@ -888,7 +890,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
tree=BLI_kdtree_new(totpart);
for (p=0,pa=psys->particles; p<totpart; p++,pa++) {
- psys_particle_on_dm(dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,NULL);
+ psys_particle_on_dm(dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco);
BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco, 1, 1);
BLI_kdtree_insert(tree, p, orco);
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index ffe6617d561..af1fa74b25f 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -96,6 +96,9 @@
#include "RE_shader_ext.h"
+/* FIXME: BAD LEVEL CALL. */
+#include "../../editors/include/ED_particle.h"
+
/* fluid sim particle import */
#ifdef WITH_MOD_FLUID
#include "DNA_object_fluidsim_types.h"
@@ -536,18 +539,20 @@ static void initialize_particle_texture(ParticleSimulationData *sim, ParticleDat
psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
switch (part->type) {
- case PART_EMITTER:
- if (ptex.exist < psys_frand(psys, p+125))
- pa->flag |= PARS_UNEXIST;
- pa->time = part->sta + (part->end - part->sta)*ptex.time;
- break;
- case PART_HAIR:
- if (ptex.exist < psys_frand(psys, p+125))
- pa->flag |= PARS_UNEXIST;
- pa->time = 0.f;
- break;
- case PART_FLUID:
- break;
+ case PART_EMITTER:
+ if (ptex.exist < psys_frand(psys, p + 125)) {
+ pa->flag |= PARS_UNEXIST;
+ }
+ pa->time = part->sta + (part->end - part->sta)*ptex.time;
+ break;
+ case PART_HAIR:
+ if (ptex.exist < psys_frand(psys, p + 125)) {
+ pa->flag |= PARS_UNEXIST;
+ }
+ pa->time = 0.f;
+ break;
+ case PART_FLUID:
+ break;
}
}
@@ -700,9 +705,9 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
/* get birth location from object */
if (use_tangents)
- psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0);
+ psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0);
else
- psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0);
+ psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0);
/* get possible textural influence */
psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra);
@@ -986,14 +991,14 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
}
/* recursively evaluate emitter parent anim at cfra */
-static void evaluate_emitter_anim(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float cfra)
+static void evaluate_emitter_anim(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float cfra)
{
if (ob->parent)
- evaluate_emitter_anim(eval_ctx, scene, ob->parent, cfra);
+ evaluate_emitter_anim(depsgraph, scene, ob->parent, cfra);
/* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
- BKE_object_where_is_calc_time(eval_ctx, scene, ob, cfra);
+ BKE_object_where_is_calc_time(depsgraph, scene, ob, cfra);
}
/* sets particle to the emitter surface with initial velocity & rotation */
@@ -1007,7 +1012,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* get precise emitter matrix if particle is born */
if (part->type != PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
- evaluate_emitter_anim(sim->eval_ctx, sim->scene, sim->ob, pa->time);
+ evaluate_emitter_anim(sim->depsgraph, sim->scene, sim->ob, pa->time);
psys->flag |= PSYS_OB_ANIM_RESTORE;
}
@@ -1060,8 +1065,10 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
pa->dietime = pa->time + pa->lifetime;
- if (sim->psys->pointcache && sim->psys->pointcache->flag & PTCACHE_BAKED &&
- sim->psys->pointcache->mem_cache.first) {
+ if ((sim->psys->pointcache) &&
+ (sim->psys->pointcache->flag & PTCACHE_BAKED) &&
+ (sim->psys->pointcache->mem_cache.first))
+ {
float dietime = psys_get_dietime_from_cache(sim->psys->pointcache, p);
pa->dietime = MIN2(pa->dietime, dietime);
}
@@ -1139,7 +1146,7 @@ static void set_keyed_keys(ParticleSimulationData *sim)
int totpart = psys->totpart, k, totkeys = psys->totkeyed;
int keyed_flag = 0;
- ksim.eval_ctx = sim->eval_ctx;
+ ksim.depsgraph = sim->depsgraph;
ksim.scene = sim->scene;
/* no proper targets so let's clear and bail out */
@@ -1301,7 +1308,7 @@ void psys_update_particle_tree(ParticleSystem *psys, float cfra)
static void psys_update_effectors(ParticleSimulationData *sim)
{
pdEndEffectors(&sim->psys->effectors);
- sim->psys->effectors = pdInitEffectors(sim->eval_ctx, sim->scene, sim->ob, sim->psys,
+ sim->psys->effectors = pdInitEffectors(sim->depsgraph, sim->scene, sim->ob, sim->psys,
sim->psys->part->effector_weights, true);
precalc_guides(sim, sim->psys->effectors);
}
@@ -2122,7 +2129,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
tkey.time=pa->state.time;
if (part->type != PART_HAIR) {
- if (do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, &tkey, p, time)) {
+ if (do_guides(sim->depsgraph, sim->psys->part, sim->psys->effectors, &tkey, p, time)) {
copy_v3_v3(pa->state.co,tkey.co);
/* guides don't produce valid velocity */
sub_v3_v3v3(pa->state.vel, tkey.co, pa->prev_state.co);
@@ -2902,9 +2909,7 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons
{
ParticleSystem *psys = sim->psys;
ParticleSettings *part = psys->part;
-#if 0
ParticleEditSettings *pset = &sim->scene->toolsettings->particle;
-#endif
int distr=0, alloc=0, skip=0;
if ((psys->part->childtype && psys->totchild != psys_get_tot_child(sim->scene, psys, use_render_params)) || psys->recalc&PSYS_RECALC_RESET)
@@ -2940,14 +2945,14 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons
else if (psys->pointcache->flag & PTCACHE_BAKING)
skip = 1; /* no need to cache paths while baking dynamics */
-#if 0 /* TODO(mai): something is very wrong with these conditionals, they dont make sense and the cache isnt updating */
- else if (psys_in_edit_mode(sim->eval_ctx->depsgraph, psys)) {
+ else if (psys_in_edit_mode(sim->depsgraph, psys)) {
if ((pset->flag & PE_DRAW_PART)==0)
skip = 1;
+#if 0 /* TODO(mai): something is very wrong with these conditionals, they dont make sense and the cache isnt updating */
else if (part->childtype==0 && (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0)
skip = 1; /* in edit mode paths are needed for child particles and dynamic hair */
- }
#endif
+ }
}
@@ -3209,7 +3214,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
psys->hair_out_dm = CDDM_copy(psys->hair_in_dm);
psys->hair_out_dm->getVertCos(psys->hair_out_dm, deformedVerts);
- clothModifier_do(psys->clmd, sim->eval_ctx, sim->scene, sim->ob, psys->hair_in_dm, deformedVerts);
+ clothModifier_do(psys->clmd, sim->depsgraph, sim->scene, sim->ob, psys->hair_in_dm, deformedVerts);
CDDM_apply_vert_coords(psys->hair_out_dm, deformedVerts);
@@ -3692,11 +3697,11 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* Note that we could avoid copying sphdata for each thread here (it's only read here),
* but doubt this would gain us anything except confusion... */
{
- ParallelRangeSettings settings;
- BLI_parallel_range_settings_defaults(&settings);
- settings.use_threading = (psys->totpart > 100);
- settings.userdata_chunk = &sphdata;
- settings.userdata_chunk_size = sizeof(sphdata);
+ ParallelRangeSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.use_threading = (psys->totpart > 100);
+ settings.userdata_chunk = &sphdata;
+ settings.userdata_chunk_size = sizeof(sphdata);
BLI_task_parallel_range(
0, psys->totpart,
&task_data,
@@ -3706,11 +3711,11 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* do global forces & effectors */
{
- ParallelRangeSettings settings;
- BLI_parallel_range_settings_defaults(&settings);
- settings.use_threading = (psys->totpart > 100);
- settings.userdata_chunk = &sphdata;
- settings.userdata_chunk_size = sizeof(sphdata);
+ ParallelRangeSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.use_threading = (psys->totpart > 100);
+ settings.userdata_chunk = &sphdata;
+ settings.userdata_chunk_size = sizeof(sphdata);
BLI_task_parallel_range(
0, psys->totpart,
&task_data,
@@ -4209,7 +4214,7 @@ static int hair_needs_recalc(ParticleSystem *psys)
/* main particle update call, checks that things are ok on the large scale and
* then advances in to actual particle calculations depending on particle type */
-void particle_system_update(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys, const bool use_render_params)
+void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, const bool use_render_params)
{
ParticleSimulationData sim= {0};
ParticleSettings *part = psys->part;
@@ -4223,7 +4228,7 @@ void particle_system_update(const struct EvaluationContext *eval_ctx, Scene *sce
cfra= BKE_scene_frame_get(scene);
- sim.eval_ctx = eval_ctx;
+ sim.depsgraph = depsgraph;
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -4370,7 +4375,7 @@ void particle_system_update(const struct EvaluationContext *eval_ctx, Scene *sce
/* make sure emitter is left at correct time (particle emission can change this) */
if (psys->flag & PSYS_OB_ANIM_RESTORE) {
- evaluate_emitter_anim(eval_ctx, scene, ob, cfra);
+ evaluate_emitter_anim(depsgraph, scene, ob, cfra);
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
}
@@ -4380,6 +4385,22 @@ void particle_system_update(const struct EvaluationContext *eval_ctx, Scene *sce
/* save matrix for duplicators, at rendertime the actual dupliobject's matrix is used so don't update! */
invert_m4_m4(psys->imat, ob->obmat);
+ if (ob->mode & OB_MODE_PARTICLE_EDIT && ob == OBACT(DEG_get_evaluated_view_layer(depsgraph))) {
+ PTCacheEdit *edit = PE_create_current(depsgraph, scene, ob);
+
+ if (edit && edit->psys == psys) {
+ if (edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED) {
+ PE_update_object(depsgraph, scene, ob, 0);
+ }
+
+ /* create path and child path cache if it doesn't exist already */
+ if (edit->pathcache == NULL) {
+ psys_cache_edit_paths(depsgraph, scene, ob, edit, DEG_get_ctime(depsgraph), DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
+
+ }
+ }
+ }
+
BKE_particle_batch_cache_dirty(psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
}
@@ -4411,7 +4432,7 @@ void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func,
/* **** Depsgraph evaluation **** */
-void BKE_particle_system_eval_init(const struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_particle_system_eval_init(struct Depsgraph *UNUSED(depsgraph),
Scene *scene,
Object *ob)
{
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 14e0cfa75b5..7b53c5f8811 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1186,20 +1186,6 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
}
}
-void BKE_pbvh_draw_BB(PBVH *bvh)
-{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- for (int a = 0; a < bvh->totnode; a++) {
- PBVHNode *node = &bvh->nodes[a];
-
- GPU_pbvh_BB_draw(node->vb.bmin, node->vb.bmax, ((node->flag & PBVH_Leaf) != 0), pos);
- }
-
- immUnbindProgram();
-}
-
static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag)
{
int update = 0;
@@ -2008,24 +1994,6 @@ bool BKE_pbvh_node_find_nearest_to_ray(
return hit;
}
-typedef struct {
- DMSetMaterial setMaterial;
- bool wireframe;
- bool fast;
-} PBVHNodeDrawData;
-
-void BKE_pbvh_node_draw(PBVHNode *node, void *data_v)
-{
- PBVHNodeDrawData *data = data_v;
-
- if (!(node->flag & PBVH_FullyHidden)) {
- GPU_pbvh_buffers_draw(node->draw_buffers,
- data->setMaterial,
- data->wireframe,
- data->fast);
- }
-}
-
typedef enum {
ISECT_INSIDE,
ISECT_OUTSIDE,
@@ -2094,6 +2062,8 @@ static void pbvh_node_check_diffuse_changed(PBVH *bvh, PBVHNode *node)
node->flag |= PBVH_UpdateDrawBuffers;
}
+/* TODO: not needed anymore in 2.8? */
+#if 0
static void pbvh_node_check_mask_changed(PBVH *bvh, PBVHNode *node)
{
if (!node->draw_buffers) {
@@ -2103,38 +2073,7 @@ static void pbvh_node_check_mask_changed(PBVH *bvh, PBVHNode *node)
node->flag |= PBVH_UpdateDrawBuffers;
}
}
-
-void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*fnors)[3],
- DMSetMaterial setMaterial, bool wireframe, bool fast)
-{
- PBVHNodeDrawData draw_data = {setMaterial, wireframe, fast};
- PBVHNode **nodes;
- int totnode;
-
- for (int a = 0; a < bvh->totnode; a++) {
- pbvh_node_check_diffuse_changed(bvh, &bvh->nodes[a]);
- pbvh_node_check_mask_changed(bvh, &bvh->nodes[a]);
- }
-
- BKE_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers),
- &nodes, &totnode);
-
- pbvh_update_normals(bvh, nodes, totnode, fnors);
- pbvh_update_draw_buffers(bvh, nodes, totnode);
-
- if (nodes) MEM_freeN(nodes);
-
- if (planes) {
- BKE_pbvh_search_callback(bvh, BKE_pbvh_node_planes_contain_AABB,
- planes, BKE_pbvh_node_draw, &draw_data);
- }
- else {
- BKE_pbvh_search_callback(bvh, NULL, NULL, BKE_pbvh_node_draw, &draw_data);
- }
-
- if (G.debug_value == 14)
- BKE_pbvh_draw_BB(bvh);
-}
+#endif
struct PBVHNodeDrawCallbackData {
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 50314daa014..3ab17b083db 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -441,9 +441,9 @@ static void ptcache_particle_extra_write(void *psys_v, PTCacheMem *pm, int UNUSE
PTCacheExtra *extra = NULL;
if (psys->part->phystype == PART_PHYS_FLUID &&
- psys->part->fluid && psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS &&
- psys->tot_fluidsprings && psys->fluid_springs) {
-
+ psys->part->fluid && psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS &&
+ psys->tot_fluidsprings && psys->fluid_springs)
+ {
extra = MEM_callocN(sizeof(PTCacheExtra), "Point cache: fluid extra data");
extra->type = BPHYS_EXTRA_FLUID_SPRINGS;
@@ -790,8 +790,9 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
/* check if resolution has changed */
if (sds->res[0] != ch_res[0] ||
- sds->res[1] != ch_res[1] ||
- sds->res[2] != ch_res[2]) {
+ sds->res[1] != ch_res[1] ||
+ sds->res[2] != ch_res[2])
+ {
if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN)
reallocate = 1;
else
@@ -2214,8 +2215,8 @@ static void ptcache_data_copy(void *from[], void *to[])
{
int i;
for (i=0; i<BPHYS_TOT_DATA; i++) {
- /* note, durian file 03.4b_comp crashes if to[i] is not tested
- * its NULL, not sure if this should be fixed elsewhere but for now its needed */
+ /* note, durian file 03.4b_comp crashes if to[i] is not tested
+ * its NULL, not sure if this should be fixed elsewhere but for now its needed */
if (from[i] && to[i])
memcpy(to[i], from[i], ptcache_data_size[i]);
}
diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c
deleted file mode 100644
index b163f623d21..00000000000
--- a/source/blender/blenkernel/intern/property.c
+++ /dev/null
@@ -1,267 +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): ton roosendaal
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/blenkernel/intern/property.c
- * \ingroup bke
- *
- * This module deals with bProperty only,
- * they are used on blender objects in the game engine
- * (where they get converted into C++ classes - CValue and subclasses)
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_property_types.h"
-#include "DNA_object_types.h"
-
-#include "BLI_blenlib.h"
-
-#include "BKE_property.h"
-
-void BKE_bproperty_free(bProperty *prop)
-{
-
- if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
- MEM_freeN(prop);
-
-}
-
-void BKE_bproperty_free_list(ListBase *lb)
-{
- bProperty *prop;
-
- while ((prop = BLI_pophead(lb))) {
- BKE_bproperty_free(prop);
- }
-}
-
-bProperty *BKE_bproperty_copy(const bProperty *prop)
-{
- bProperty *propn;
-
- propn = MEM_dupallocN(prop);
- if (prop->poin && prop->poin != &prop->data) {
- propn->poin = MEM_dupallocN(prop->poin);
- }
- else {
- propn->poin = &propn->data;
- }
-
- return propn;
-}
-
-void BKE_bproperty_copy_list(ListBase *lbn, const ListBase *lbo)
-{
- bProperty *prop, *propn;
- BKE_bproperty_free_list(lbn); /* in case we are copying to an object with props */
- prop = lbo->first;
- while (prop) {
- propn = BKE_bproperty_copy(prop);
- BLI_addtail(lbn, propn);
- prop = prop->next;
- }
-
-
-}
-
-void BKE_bproperty_init(bProperty *prop)
-{
- /* also use when property changes type */
-
- if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
- prop->poin = NULL;
-
- prop->data = 0;
-
- switch (prop->type) {
- case GPROP_BOOL:
- case GPROP_INT:
- case GPROP_FLOAT:
- case GPROP_TIME:
- prop->poin = &prop->data;
- break;
- case GPROP_STRING:
- prop->poin = MEM_callocN(MAX_PROPSTRING, "property string");
- break;
- }
-}
-
-
-bProperty *BKE_bproperty_new(int type)
-{
- bProperty *prop;
-
- prop = MEM_callocN(sizeof(bProperty), "property");
- prop->type = type;
-
- BKE_bproperty_init(prop);
-
- strcpy(prop->name, "prop");
-
- return prop;
-}
-
-
-bProperty *BKE_bproperty_object_get(Object *ob, const char *name)
-{
- return BLI_findstring(&ob->prop, name, offsetof(bProperty, name));
-}
-
-void BKE_bproperty_object_set(Object *ob, bProperty *propc)
-{
- bProperty *prop;
- prop = BKE_bproperty_object_get(ob, propc->name);
- if (prop) {
- BLI_remlink(&ob->prop, prop);
- BKE_bproperty_free(prop);
- }
- BLI_addtail(&ob->prop, BKE_bproperty_copy(propc));
-}
-
-/* negative: prop is smaller
- * positive: prop is larger
- */
-#if 0 /* UNUSED */
-int BKE_bproperty_cmp(bProperty *prop, const char *str)
-{
-// extern int Gdfra; /* sector.c */
- float fvalue, ftest;
-
- switch (prop->type) {
- case GPROP_BOOL:
- if (BLI_strcasecmp(str, "true") == 0) {
- if (prop->data == 1) return 0;
- else return 1;
- }
- else if (BLI_strcasecmp(str, "false") == 0) {
- if (prop->data == 0) return 0;
- else return 1;
- }
- /* no break, do GPROP_int too! */
-
- case GPROP_INT:
- return prop->data - atoi(str);
-
- case GPROP_FLOAT:
- case GPROP_TIME:
- /* WARNING: untested for GPROP_TIME
- * function isn't used currently */
- fvalue = *((float *)&prop->data);
- ftest = (float)atof(str);
- if (fvalue > ftest) return 1;
- else if (fvalue < ftest) return -1;
- return 0;
-
- case GPROP_STRING:
- return strcmp(prop->poin, str);
- }
-
- return 0;
-}
-#endif
-
-void BKE_bproperty_set(bProperty *prop, const char *str)
-{
-// extern int Gdfra; /* sector.c */
-
- switch (prop->type) {
- case GPROP_BOOL:
- if (BLI_strcasecmp(str, "true") == 0) prop->data = 1;
- else if (BLI_strcasecmp(str, "false") == 0) prop->data = 0;
- else prop->data = (atoi(str) != 0);
- break;
- case GPROP_INT:
- prop->data = atoi(str);
- break;
- case GPROP_FLOAT:
- case GPROP_TIME:
- *((float *)&prop->data) = (float)atof(str);
- break;
- case GPROP_STRING:
- strcpy(prop->poin, str); /* TODO - check size? */
- break;
- }
-
-}
-
-void BKE_bproperty_add(bProperty *prop, const char *str)
-{
-// extern int Gdfra; /* sector.c */
-
- switch (prop->type) {
- case GPROP_BOOL:
- case GPROP_INT:
- prop->data += atoi(str);
- break;
- case GPROP_FLOAT:
- case GPROP_TIME:
- *((float *)&prop->data) += (float)atof(str);
- break;
- case GPROP_STRING:
- /* strcpy(prop->poin, str); */
- break;
- }
-}
-
-/* reads value of property, sets it in chars in str */
-void BKE_bproperty_set_valstr(bProperty *prop, char str[MAX_PROPSTRING])
-{
-// extern int Gdfra; /* sector.c */
-
- if (str == NULL) return;
-
- switch (prop->type) {
- case GPROP_BOOL:
- case GPROP_INT:
- sprintf(str, "%d", prop->data);
- break;
- case GPROP_FLOAT:
- case GPROP_TIME:
- sprintf(str, "%f", *((float *)&prop->data));
- break;
- case GPROP_STRING:
- BLI_strncpy(str, prop->poin, MAX_PROPSTRING);
- break;
- }
-}
-
-#if 0 /* UNUSED */
-void cp_property(bProperty *prop1, bProperty *prop2)
-{
- char str[128];
-
- BKE_bproperty_set_valstr(prop2, str);
-
- BKE_bproperty_set(prop1, str);
-}
-#endif
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index ff521260993..fdeba7186e8 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1024,8 +1024,8 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
rbo->lin_sleep_thresh = 0.4f; /* 0.4 is half of Bullet default */
rbo->ang_sleep_thresh = 0.5f; /* 0.5 is half of Bullet default */
- rbo->lin_damping = 0.04f; /* 0.04 is game engine default */
- rbo->ang_damping = 0.1f; /* 0.1 is game engine default */
+ rbo->lin_damping = 0.04f;
+ rbo->ang_damping = 0.1f;
rbo->col_groups = 1;
@@ -1237,7 +1237,7 @@ static void rigidbody_update_sim_world(Scene *scene, RigidBodyWorld *rbw)
rigidbody_update_ob_array(rbw);
}
-static void rigidbody_update_sim_ob(const struct EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo)
+static void rigidbody_update_sim_ob(struct Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo)
{
float loc[3];
float rot[4];
@@ -1285,7 +1285,7 @@ static void rigidbody_update_sim_ob(const struct EvaluationContext *eval_ctx, Sc
ListBase *effectors;
/* get effectors present in the group specified by effector_weights */
- effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, effector_weights, true);
+ effectors = pdInitEffectors(depsgraph, scene, ob, NULL, effector_weights, true);
if (effectors) {
float eff_force[3] = {0.0f, 0.0f, 0.0f};
float eff_loc[3], eff_vel[3];
@@ -1326,7 +1326,7 @@ static void rigidbody_update_sim_ob(const struct EvaluationContext *eval_ctx, Sc
*
* \param rebuild Rebuild entire simulation
*/
-static void rigidbody_update_simulation(const struct EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, bool rebuild)
+static void rigidbody_update_simulation(struct Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, bool rebuild)
{
/* update world */
if (rebuild)
@@ -1359,7 +1359,7 @@ static void rigidbody_update_simulation(const struct EvaluationContext *eval_ctx
/* validate that we've got valid object set up here... */
RigidBodyOb *rbo = ob->rigidbody_object;
/* update transformation matrix of the object so we don't get a frame of lag for simple animations */
- BKE_object_where_is_calc(eval_ctx, scene, ob);
+ BKE_object_where_is_calc(depsgraph, scene, ob);
if (rbo == NULL) {
/* Since this object is included in the sim group but doesn't have
@@ -1393,7 +1393,7 @@ static void rigidbody_update_simulation(const struct EvaluationContext *eval_ctx
}
/* update simulation object... */
- rigidbody_update_sim_ob(eval_ctx, scene, rbw, ob, rbo);
+ rigidbody_update_sim_ob(depsgraph, scene, rbw, ob, rbo);
}
}
FOREACH_GROUP_OBJECT_END;
@@ -1407,7 +1407,7 @@ static void rigidbody_update_simulation(const struct EvaluationContext *eval_ctx
/* validate that we've got valid object set up here... */
RigidBodyCon *rbc = ob->rigidbody_constraint;
/* update transformation matrix of the object so we don't get a frame of lag for simple animations */
- BKE_object_where_is_calc(eval_ctx, scene, ob);
+ BKE_object_where_is_calc(depsgraph, scene, ob);
if (rbc == NULL) {
/* Since this object is included in the group but doesn't have
@@ -1563,7 +1563,7 @@ void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw)
/* Rebuild rigid body world */
/* NOTE: this needs to be called before frame update to work correctly */
-void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime)
+void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, Scene *scene, float ctime)
{
RigidBodyWorld *rbw = scene->rigidbody_world;
PointCache *cache;
@@ -1582,7 +1582,7 @@ void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene
if (ctime == startframe + 1 && rbw->ltime == startframe) {
if (cache->flag & PTCACHE_OUTDATED) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
- rigidbody_update_simulation(eval_ctx, scene, rbw, true);
+ rigidbody_update_simulation(depsgraph, scene, rbw, true);
BKE_ptcache_validate(cache, (int)ctime);
cache->last_exact = 0;
cache->flag &= ~PTCACHE_REDO_NEEDED;
@@ -1591,7 +1591,7 @@ void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene
}
/* Run RigidBody simulation for the specified physics world */
-void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime)
+void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, Scene *scene, float ctime)
{
float timestep;
RigidBodyWorld *rbw = scene->rigidbody_world;
@@ -1636,7 +1636,7 @@ void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene
}
/* update and validate simulation */
- rigidbody_update_simulation(eval_ctx, scene, rbw, false);
+ rigidbody_update_simulation(depsgraph, scene, rbw, false);
/* calculate how much time elapsed since last step in seconds */
timestep = 1.0f / (float)FPS * (ctime - rbw->ltime) * rbw->time_scale;
@@ -1680,8 +1680,8 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime)
void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle) {}
bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float ctime) { return false; }
void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw) {}
-void BKE_rigidbody_rebuild_world(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime) {}
-void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene *scene, float ctime) {}
+void BKE_rigidbody_rebuild_world(struct Depsgraph *depsgraph, Scene *scene, float ctime) {}
+void BKE_rigidbody_do_simulation(struct Depsgraph *depsgraph, Scene *scene, float ctime) {}
#ifdef __GNUC__
# pragma GCC diagnostic pop
@@ -1692,29 +1692,29 @@ void BKE_rigidbody_do_simulation(const struct EvaluationContext *eval_ctx, Scene
/* -------------------- */
/* Depsgraph evaluation */
-void BKE_rigidbody_rebuild_sim(const struct EvaluationContext *eval_ctx,
+void BKE_rigidbody_rebuild_sim(struct Depsgraph *depsgraph,
Scene *scene)
{
float ctime = BKE_scene_frame_get(scene);
DEG_debug_print_eval_time(__func__, scene->id.name, scene, ctime);
/* rebuild sim data (i.e. after resetting to start of timeline) */
if (BKE_scene_check_rigidbody_active(scene)) {
- BKE_rigidbody_rebuild_world(eval_ctx, scene, ctime);
+ BKE_rigidbody_rebuild_world(depsgraph, scene, ctime);
}
}
-void BKE_rigidbody_eval_simulation(const struct EvaluationContext *eval_ctx,
+void BKE_rigidbody_eval_simulation(struct Depsgraph *depsgraph,
Scene *scene)
{
float ctime = BKE_scene_frame_get(scene);
DEG_debug_print_eval_time(__func__, scene->id.name, scene, ctime);
/* evaluate rigidbody sim */
if (BKE_scene_check_rigidbody_active(scene)) {
- BKE_rigidbody_do_simulation(eval_ctx, scene, ctime);
+ BKE_rigidbody_do_simulation(depsgraph, scene, ctime);
}
}
-void BKE_rigidbody_object_sync_transforms(const struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_rigidbody_object_sync_transforms(struct Depsgraph *UNUSED(depsgraph),
Scene *scene,
Object *ob)
{
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
deleted file mode 100644
index fb81ed4d47f..00000000000
--- a/source/blender/blenkernel/intern/sca.c
+++ /dev/null
@@ -1,1179 +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 *****
- * these all are linked to objects (listbase)
- * all data is 'direct data', not Blender lib data.
- */
-
-/** \file blender/blenkernel/intern/sca.c
- * \ingroup bke
- */
-
-
-#include <stdio.h>
-#include <string.h>
-#include <float.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_controller_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_object_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_ghash.h"
-#include "BLI_math.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_library.h"
-#include "BKE_library_query.h"
-#include "BKE_sca.h"
-
-/* ******************* SENSORS ************************ */
-
-void free_sensor(bSensor *sens)
-{
- if (sens->links) MEM_freeN(sens->links);
- if (sens->data) MEM_freeN(sens->data);
- MEM_freeN(sens);
-
-}
-
-void free_sensors(ListBase *lb)
-{
- bSensor *sens;
-
- while ((sens = BLI_pophead(lb))) {
- free_sensor(sens);
- }
-}
-
-bSensor *copy_sensor(bSensor *sens, const int UNUSED(flag))
-{
- bSensor *sensn;
-
- sensn= MEM_dupallocN(sens);
- sensn->flag |= SENS_NEW;
- if (sens->data) {
- sensn->data= MEM_dupallocN(sens->data);
- }
-
- if (sens->links) sensn->links= MEM_dupallocN(sens->links);
-
- return sensn;
-}
-
-void copy_sensors(ListBase *lbn, const ListBase *lbo, const int flag)
-{
- bSensor *sens, *sensn;
-
- lbn->first= lbn->last= NULL;
- sens= lbo->first;
- while (sens) {
- sensn= copy_sensor(sens, flag);
- BLI_addtail(lbn, sensn);
- sens= sens->next;
- }
-}
-
-void init_sensor(bSensor *sens)
-{
- /* also use when sensor changes type */
- bNearSensor *ns;
- bMouseSensor *ms;
- bJoystickSensor *js;
- bRaySensor *rs;
-
- if (sens->data) MEM_freeN(sens->data);
- sens->data= NULL;
- sens->pulse = 0;
-
- switch (sens->type) {
- case SENS_ALWAYS:
- sens->pulse = 0;
- break;
- case SENS_NEAR:
- ns=sens->data= MEM_callocN(sizeof(bNearSensor), "nearsens");
- ns->dist= 1.0;
- ns->resetdist= 2.0;
- break;
- case SENS_KEYBOARD:
- sens->data= MEM_callocN(sizeof(bKeyboardSensor), "keysens");
- break;
- case SENS_PROPERTY:
- sens->data= MEM_callocN(sizeof(bPropertySensor), "propsens");
- break;
- case SENS_ARMATURE:
- sens->data= MEM_callocN(sizeof(bArmatureSensor), "armsens");
- break;
- case SENS_ACTUATOR:
- sens->data= MEM_callocN(sizeof(bActuatorSensor), "actsens");
- break;
- case SENS_DELAY:
- sens->data= MEM_callocN(sizeof(bDelaySensor), "delaysens");
- break;
- case SENS_MOUSE:
- ms=sens->data= MEM_callocN(sizeof(bMouseSensor), "mousesens");
- ms->type= 1; // LEFTMOUSE workaround because Mouse Sensor types enum starts in 1
- break;
- case SENS_COLLISION:
- sens->data= MEM_callocN(sizeof(bCollisionSensor), "colsens");
- break;
- case SENS_RADAR:
- sens->data= MEM_callocN(sizeof(bRadarSensor), "radarsens");
- break;
- case SENS_RANDOM:
- sens->data= MEM_callocN(sizeof(bRandomSensor), "randomsens");
- break;
- case SENS_RAY:
- sens->data= MEM_callocN(sizeof(bRaySensor), "raysens");
- rs = sens->data;
- rs->range = 0.01f;
- break;
- case SENS_MESSAGE:
- sens->data= MEM_callocN(sizeof(bMessageSensor), "messagesens");
- break;
- case SENS_JOYSTICK:
- sens->data= MEM_callocN(sizeof(bJoystickSensor), "joysticksens");
- js= sens->data;
- js->hatf = SENS_JOY_HAT_UP;
- js->axis = 1;
- js->hat = 1;
- break;
- default:
- ; /* this is very severe... I cannot make any memory for this */
- /* logic brick... */
- }
-}
-
-bSensor *new_sensor(int type)
-{
- bSensor *sens;
-
- sens= MEM_callocN(sizeof(bSensor), "Sensor");
- sens->type= type;
- sens->flag= SENS_SHOW;
-
- init_sensor(sens);
-
- strcpy(sens->name, "sensor");
-// XXX make_unique_prop_names(sens->name);
-
- return sens;
-}
-
-/* ******************* CONTROLLERS ************************ */
-
-void unlink_controller(bController *cont)
-{
- bSensor *sens;
- Object *ob;
-
- /* check for controller pointers in sensors */
- ob= G.main->object.first;
- while (ob) {
- sens= ob->sensors.first;
- while (sens) {
- unlink_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks);
- sens= sens->next;
- }
- ob= ob->id.next;
- }
-}
-
-void unlink_controllers(ListBase *lb)
-{
- bController *cont;
-
- for (cont= lb->first; cont; cont= cont->next)
- unlink_controller(cont);
-}
-
-void free_controller(bController *cont)
-{
- if (cont->links) MEM_freeN(cont->links);
-
- /* the controller itself */
- if (cont->data) MEM_freeN(cont->data);
- MEM_freeN(cont);
-
-}
-
-void free_controllers(ListBase *lb)
-{
- bController *cont;
-
- while ((cont = BLI_pophead(lb))) {
- if (cont->slinks)
- MEM_freeN(cont->slinks);
- free_controller(cont);
- }
-}
-
-bController *copy_controller(bController *cont, const int UNUSED(flag))
-{
- bController *contn;
-
- cont->mynew=contn= MEM_dupallocN(cont);
- contn->flag |= CONT_NEW;
- if (cont->data) {
- contn->data= MEM_dupallocN(cont->data);
- }
-
- if (cont->links) contn->links= MEM_dupallocN(cont->links);
- contn->slinks= NULL;
- contn->totslinks= 0;
-
- return contn;
-}
-
-void copy_controllers(ListBase *lbn, const ListBase *lbo, const int flag)
-{
- bController *cont, *contn;
-
- lbn->first= lbn->last= NULL;
- cont= lbo->first;
- while (cont) {
- contn= copy_controller(cont, flag);
- BLI_addtail(lbn, contn);
- cont= cont->next;
- }
-}
-
-void init_controller(bController *cont)
-{
- /* also use when controller changes type, leave actuators... */
-
- if (cont->data) MEM_freeN(cont->data);
- cont->data= NULL;
-
- switch (cont->type) {
- case CONT_EXPRESSION:
- cont->data= MEM_callocN(sizeof(bExpressionCont), "expcont");
- break;
- case CONT_PYTHON:
- cont->data= MEM_callocN(sizeof(bPythonCont), "pycont");
- break;
- }
-}
-
-bController *new_controller(int type)
-{
- bController *cont;
-
- cont= MEM_callocN(sizeof(bController), "Controller");
- cont->type= type;
- cont->flag= CONT_SHOW;
-
- init_controller(cont);
-
- strcpy(cont->name, "cont");
-// XXX make_unique_prop_names(cont->name);
-
- return cont;
-}
-
-/* ******************* ACTUATORS ************************ */
-
-void unlink_actuator(bActuator *act)
-{
- bController *cont;
- Object *ob;
-
- /* check for actuator pointers in controllers */
- ob= G.main->object.first;
- while (ob) {
- cont= ob->controllers.first;
- while (cont) {
- unlink_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks);
- cont= cont->next;
- }
- ob= ob->id.next;
- }
-}
-
-void unlink_actuators(ListBase *lb)
-{
- bActuator *act;
-
- for (act= lb->first; act; act= act->next)
- unlink_actuator(act);
-}
-
-void free_actuator(bActuator *act)
-{
- if (act->data) {
- switch (act->type) {
- case ACT_ACTION:
- case ACT_SHAPEACTION:
- {
- bActionActuator *aa = (bActionActuator *)act->data;
- if (aa->act)
- id_us_min((ID *)aa->act);
- break;
- }
- case ACT_SOUND:
- {
- bSoundActuator *sa = (bSoundActuator *) act->data;
- if (sa->sound)
- id_us_min((ID *)sa->sound);
- break;
- }
- }
-
- MEM_freeN(act->data);
- }
- MEM_freeN(act);
-}
-
-void free_actuators(ListBase *lb)
-{
- bActuator *act;
-
- while ((act = BLI_pophead(lb))) {
- free_actuator(act);
- }
-}
-
-bActuator *copy_actuator(bActuator *act, const int flag)
-{
- bActuator *actn;
-
- act->mynew=actn= MEM_dupallocN(act);
- actn->flag |= ACT_NEW;
- if (act->data) {
- actn->data= MEM_dupallocN(act->data);
- }
-
- switch (act->type) {
- case ACT_ACTION:
- case ACT_SHAPEACTION:
- {
- bActionActuator *aa = (bActionActuator *)act->data;
- if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
- id_us_plus((ID *)aa->act);
- }
- break;
- }
- case ACT_SOUND:
- {
- bSoundActuator *sa = (bSoundActuator *)act->data;
- if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
- id_us_plus((ID *)sa->sound);
- }
- break;
- }
- }
- return actn;
-}
-
-void copy_actuators(ListBase *lbn, const ListBase *lbo, const int flag)
-{
- bActuator *act, *actn;
-
- lbn->first= lbn->last= NULL;
- act= lbo->first;
- while (act) {
- actn= copy_actuator(act, flag);
- BLI_addtail(lbn, actn);
- act= act->next;
- }
-}
-
-void init_actuator(bActuator *act)
-{
- /* also use when actuator changes type */
- bCameraActuator *ca;
- bObjectActuator *oa;
- bRandomActuator *ra;
- bSoundActuator *sa;
- bSteeringActuator *sta;
- bArmatureActuator *arma;
- bMouseActuator *ma;
- bEditObjectActuator *eoa;
-
- if (act->data) MEM_freeN(act->data);
- act->data= NULL;
-
- switch (act->type) {
- case ACT_ACTION:
- case ACT_SHAPEACTION:
- act->data= MEM_callocN(sizeof(bActionActuator), "actionact");
- break;
- case ACT_SOUND:
- sa = act->data= MEM_callocN(sizeof(bSoundActuator), "soundact");
- sa->volume = 1.0f;
- sa->sound3D.rolloff_factor = 1.0f;
- sa->sound3D.reference_distance = 1.0f;
- sa->sound3D.max_gain = 1.0f;
- sa->sound3D.cone_inner_angle = DEG2RADF(360.0f);
- sa->sound3D.cone_outer_angle = DEG2RADF(360.0f);
- sa->sound3D.max_distance = FLT_MAX;
- break;
- case ACT_OBJECT:
- act->data= MEM_callocN(sizeof(bObjectActuator), "objectact");
- oa= act->data;
- oa->flag= 15;
- break;
- case ACT_PROPERTY:
- act->data= MEM_callocN(sizeof(bPropertyActuator), "propact");
- break;
- case ACT_CAMERA:
- act->data= MEM_callocN(sizeof(bCameraActuator), "camact");
- ca = act->data;
- ca->axis = OB_POSX;
- ca->damping = 1.0/32.0;
- break;
- case ACT_EDIT_OBJECT:
- act->data= MEM_callocN(sizeof(bEditObjectActuator), "editobact");
- eoa = act->data;
- eoa->upflag= ACT_TRACK_UP_Z;
- eoa->trackflag= ACT_TRACK_TRAXIS_Y;
- break;
- case ACT_CONSTRAINT:
- act->data= MEM_callocN(sizeof(bConstraintActuator), "cons act");
- break;
- case ACT_SCENE:
- act->data= MEM_callocN(sizeof(bSceneActuator), "scene act");
- break;
- case ACT_GROUP:
- act->data= MEM_callocN(sizeof(bGroupActuator), "group act");
- break;
- case ACT_RANDOM:
- act->data= MEM_callocN(sizeof(bRandomActuator), "random act");
- ra=act->data;
- ra->float_arg_1 = 0.1f;
- break;
- case ACT_MESSAGE:
- act->data= MEM_callocN(sizeof(bMessageActuator), "message act");
- break;
- case ACT_GAME:
- act->data= MEM_callocN(sizeof(bGameActuator), "game act");
- break;
- case ACT_VISIBILITY:
- act->data= MEM_callocN(sizeof(bVisibilityActuator), "visibility act");
- break;
- case ACT_2DFILTER:
- act->data = MEM_callocN(sizeof( bTwoDFilterActuator ), "2d filter act");
- break;
- case ACT_PARENT:
- act->data = MEM_callocN(sizeof( bParentActuator ), "parent act");
- break;
- case ACT_STATE:
- act->data = MEM_callocN(sizeof( bStateActuator ), "state act");
- break;
- case ACT_ARMATURE:
- act->data = MEM_callocN(sizeof( bArmatureActuator ), "armature act");
- arma = act->data;
- arma->influence = 1.f;
- break;
- case ACT_STEERING:
- act->data = MEM_callocN(sizeof( bSteeringActuator), "steering act");
- sta = act->data;
- sta->acceleration = 3.f;
- sta->turnspeed = 120.f;
- sta->dist = 1.f;
- sta->velocity= 3.f;
- sta->flag = ACT_STEERING_AUTOMATICFACING | ACT_STEERING_LOCKZVEL;
- sta->facingaxis = 1;
- break;
- case ACT_MOUSE:
- ma = act->data = MEM_callocN(sizeof( bMouseActuator ), "mouse act");
- ma->flag = ACT_MOUSE_VISIBLE|ACT_MOUSE_USE_AXIS_X|ACT_MOUSE_USE_AXIS_Y|ACT_MOUSE_RESET_X|ACT_MOUSE_RESET_Y|ACT_MOUSE_LOCAL_Y;
- ma->sensitivity[0] = ma->sensitivity[1] = 2.f;
- ma->object_axis[0] = ACT_MOUSE_OBJECT_AXIS_Z;
- ma->object_axis[1] = ACT_MOUSE_OBJECT_AXIS_X;
- ma->limit_y[0] = DEG2RADF(-90.0f);
- ma->limit_y[1] = DEG2RADF(90.0f);
- break;
- default:
- ; /* this is very severe... I cannot make any memory for this */
- /* logic brick... */
- }
-}
-
-bActuator *new_actuator(int type)
-{
- bActuator *act;
-
- act= MEM_callocN(sizeof(bActuator), "Actuator");
- act->type= type;
- act->flag= ACT_SHOW;
-
- init_actuator(act);
-
- strcpy(act->name, "act");
-// XXX make_unique_prop_names(act->name);
-
- return act;
-}
-
-/* ******************** GENERAL ******************* */
-void clear_sca_new_poins_ob(Object *ob)
-{
- bSensor *sens;
- bController *cont;
- bActuator *act;
-
- sens= ob->sensors.first;
- while (sens) {
- sens->flag &= ~SENS_NEW;
- sens= sens->next;
- }
- cont= ob->controllers.first;
- while (cont) {
- cont->mynew= NULL;
- cont->flag &= ~CONT_NEW;
- cont= cont->next;
- }
- act= ob->actuators.first;
- while (act) {
- act->mynew= NULL;
- act->flag &= ~ACT_NEW;
- act= act->next;
- }
-}
-
-void clear_sca_new_poins(void)
-{
- Object *ob;
-
- ob= G.main->object.first;
- while (ob) {
- clear_sca_new_poins_ob(ob);
- ob= ob->id.next;
- }
-}
-
-void set_sca_new_poins_ob(Object *ob)
-{
- bSensor *sens;
- bController *cont;
- bActuator *act;
- int a;
-
- sens= ob->sensors.first;
- while (sens) {
- if (sens->flag & SENS_NEW) {
- for (a=0; a<sens->totlinks; a++) {
- if (sens->links[a] && sens->links[a]->mynew)
- sens->links[a] = sens->links[a]->mynew;
- }
- }
- sens= sens->next;
- }
-
- cont= ob->controllers.first;
- while (cont) {
- if (cont->flag & CONT_NEW) {
- for (a=0; a<cont->totlinks; a++) {
- if ( cont->links[a] && cont->links[a]->mynew)
- cont->links[a] = cont->links[a]->mynew;
- }
- }
- cont= cont->next;
- }
-
-
- act= ob->actuators.first;
- while (act) {
- if (act->flag & ACT_NEW) {
- if (act->type==ACT_EDIT_OBJECT) {
- bEditObjectActuator *eoa= act->data;
- ID_NEW_REMAP(eoa->ob);
- }
- else if (act->type==ACT_SCENE) {
- bSceneActuator *sca= act->data;
- ID_NEW_REMAP(sca->camera);
- }
- else if (act->type==ACT_CAMERA) {
- bCameraActuator *ca= act->data;
- ID_NEW_REMAP(ca->ob);
- }
- else if (act->type==ACT_OBJECT) {
- bObjectActuator *oa= act->data;
- ID_NEW_REMAP(oa->reference);
- }
- else if (act->type==ACT_MESSAGE) {
- bMessageActuator *ma= act->data;
- ID_NEW_REMAP(ma->toObject);
- }
- else if (act->type==ACT_PARENT) {
- bParentActuator *para = act->data;
- ID_NEW_REMAP(para->ob);
- }
- else if (act->type==ACT_ARMATURE) {
- bArmatureActuator *aa = act->data;
- ID_NEW_REMAP(aa->target);
- ID_NEW_REMAP(aa->subtarget);
- }
- else if (act->type==ACT_PROPERTY) {
- bPropertyActuator *pa= act->data;
- ID_NEW_REMAP(pa->ob);
- }
- else if (act->type==ACT_STEERING) {
- bSteeringActuator *sta = act->data;
- ID_NEW_REMAP(sta->navmesh);
- ID_NEW_REMAP(sta->target);
- }
- }
- act= act->next;
- }
-}
-
-
-void set_sca_new_poins(void)
-{
- Object *ob;
-
- ob= G.main->object.first;
- while (ob) {
- set_sca_new_poins_ob(ob);
- ob= ob->id.next;
- }
-}
-
-/**
- * Try to remap logic links to new object... Very, *very* weak.
- */
-/* XXX Logick bricks... I don't have words to say what I think about this behavior.
- * They have silent hidden ugly inter-objects dependencies (a sensor can link into any other
- * object's controllers, and same between controllers and actuators, without *any* explicit reference
- * to data-block involved).
- * This is bad, bad, bad!!!
- * ...and forces us to add yet another very ugly hack to get remapping with logic bricks working. */
-void BKE_sca_logic_links_remap(Main *bmain, Object *ob_old, Object *ob_new)
-{
- if (ob_new == NULL || (ob_old->controllers.first == NULL && ob_old->actuators.first == NULL)) {
- /* Nothing to do here... */
- return;
- }
-
- GHash *controllers_map = ob_old->controllers.first ?
- BLI_ghash_ptr_new_ex(__func__, BLI_listbase_count(&ob_old->controllers)) : NULL;
- GHash *actuators_map = ob_old->actuators.first ?
- BLI_ghash_ptr_new_ex(__func__, BLI_listbase_count(&ob_old->actuators)) : NULL;
-
- /* We try to remap old controllers/actuators to new ones - in a very basic way. */
- for (bController *cont_old = ob_old->controllers.first, *cont_new = ob_new->controllers.first;
- cont_old;
- cont_old = cont_old->next)
- {
- bController *cont_new2 = cont_new;
-
- if (cont_old->mynew != NULL) {
- cont_new2 = cont_old->mynew;
- if (!(cont_new2 == cont_new || BLI_findindex(&ob_new->controllers, cont_new2) >= 0)) {
- cont_new2 = NULL;
- }
- }
- else if (cont_new && cont_old->type != cont_new->type) {
- cont_new2 = NULL;
- }
-
- BLI_ghash_insert(controllers_map, cont_old, cont_new2);
-
- if (cont_new) {
- cont_new = cont_new->next;
- }
- }
-
- for (bActuator *act_old = ob_old->actuators.first, *act_new = ob_new->actuators.first;
- act_old;
- act_old = act_old->next)
- {
- bActuator *act_new2 = act_new;
-
- if (act_old->mynew != NULL) {
- act_new2 = act_old->mynew;
- if (!(act_new2 == act_new || BLI_findindex(&ob_new->actuators, act_new2) >= 0)) {
- act_new2 = NULL;
- }
- }
- else if (act_new && act_old->type != act_new->type) {
- act_new2 = NULL;
- }
-
- BLI_ghash_insert(actuators_map, act_old, act_new2);
-
- if (act_new) {
- act_new = act_new->next;
- }
- }
-
- for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
- if (controllers_map != NULL) {
- for (bSensor *sens = ob->sensors.first; sens; sens = sens->next) {
- for (int a = 0; a < sens->totlinks; a++) {
- if (sens->links[a]) {
- bController *old_link = sens->links[a];
- bController **new_link_p = (bController **)BLI_ghash_lookup_p(controllers_map, old_link);
-
- if (new_link_p == NULL) {
- /* old_link is *not* in map's keys (i.e. not to any ob_old->controllers),
- * which means we ignore it totally here. */
- }
- else if (*new_link_p == NULL) {
- unlink_logicbricks((void **)&old_link, (void ***)&(sens->links), &sens->totlinks);
- a--;
- }
- else {
- sens->links[a] = *new_link_p;
- }
- }
- }
- }
- }
-
- if (actuators_map != NULL) {
- for (bController *cont = ob->controllers.first; cont; cont = cont->next) {
- for (int a = 0; a < cont->totlinks; a++) {
- if (cont->links[a]) {
- bActuator *old_link = cont->links[a];
- bActuator **new_link_p = (bActuator **)BLI_ghash_lookup_p(actuators_map, old_link);
-
- if (new_link_p == NULL) {
- /* old_link is *not* in map's keys (i.e. not to any ob_old->actuators),
- * which means we ignore it totally here. */
- }
- else if (*new_link_p == NULL) {
- unlink_logicbricks((void **)&old_link, (void ***)&(cont->links), &cont->totlinks);
- a--;
- }
- else {
- cont->links[a] = *new_link_p;
- }
- }
- }
- }
- }
- }
-
- if (controllers_map) {
- BLI_ghash_free(controllers_map, NULL, NULL);
- }
- if (actuators_map) {
- BLI_ghash_free(actuators_map, NULL, NULL);
- }
-}
-
-/**
- * Handle the copying of logic data into a new object, including internal logic links update.
- * External links (links between logic bricks of different objects) must be handled separately.
- */
-void BKE_sca_logic_copy(Object *ob_new, const Object *ob, const int flag)
-{
- copy_sensors(&ob_new->sensors, &ob->sensors, flag);
- copy_controllers(&ob_new->controllers, &ob->controllers, flag);
- copy_actuators(&ob_new->actuators, &ob->actuators, flag);
-
- for (bSensor *sens = ob_new->sensors.first; sens; sens = sens->next) {
- if (sens->flag & SENS_NEW) {
- for (int a = 0; a < sens->totlinks; a++) {
- if (sens->links[a] && sens->links[a]->mynew) {
- sens->links[a] = sens->links[a]->mynew;
- }
- }
- }
- }
-
- for (bController *cont = ob_new->controllers.first; cont; cont = cont->next) {
- if (cont->flag & CONT_NEW) {
- for (int a = 0; a < cont->totlinks; a++) {
- if (cont->links[a] && cont->links[a]->mynew) {
- cont->links[a] = cont->links[a]->mynew;
- }
- }
- }
- }
-}
-
-/* ******************** INTERFACE ******************* */
-void sca_move_sensor(bSensor *sens_to_move, Object *ob, int move_up)
-{
- bSensor *sens, *tmp;
-
- int val;
- val = move_up ? 1 : 2;
-
- /* make sure this sensor belongs to this object */
- sens= ob->sensors.first;
- while (sens) {
- if (sens == sens_to_move) break;
- sens= sens->next;
- }
- if (!sens) return;
-
- /* move up */
- if (val == 1 && sens->prev) {
- for (tmp=sens->prev; tmp; tmp=tmp->prev) {
- if (tmp->flag & SENS_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&ob->sensors, sens);
- BLI_insertlinkbefore(&ob->sensors, tmp, sens);
- }
- }
- /* move down */
- else if (val == 2 && sens->next) {
- for (tmp=sens->next; tmp; tmp=tmp->next) {
- if (tmp->flag & SENS_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&ob->sensors, sens);
- BLI_insertlinkafter(&ob->sensors, tmp, sens);
- }
- }
-}
-
-void sca_move_controller(bController *cont_to_move, Object *ob, int move_up)
-{
- bController *cont, *tmp;
-
- int val;
- val = move_up ? 1 : 2;
-
- /* make sure this controller belongs to this object */
- cont= ob->controllers.first;
- while (cont) {
- if (cont == cont_to_move) break;
- cont= cont->next;
- }
- if (!cont) return;
-
- /* move up */
- if (val == 1 && cont->prev) {
- /* locate the controller that has the same state mask but is earlier in the list */
- tmp = cont->prev;
- while (tmp) {
- if (tmp->state_mask & cont->state_mask)
- break;
- tmp = tmp->prev;
- }
- if (tmp) {
- BLI_remlink(&ob->controllers, cont);
- BLI_insertlinkbefore(&ob->controllers, tmp, cont);
- }
- }
-
- /* move down */
- else if (val == 2 && cont->next) {
- tmp = cont->next;
- while (tmp) {
- if (tmp->state_mask & cont->state_mask)
- break;
- tmp = tmp->next;
- }
- BLI_remlink(&ob->controllers, cont);
- BLI_insertlinkafter(&ob->controllers, tmp, cont);
- }
-}
-
-void sca_move_actuator(bActuator *act_to_move, Object *ob, int move_up)
-{
- bActuator *act, *tmp;
- int val;
-
- val = move_up ? 1 : 2;
-
- /* make sure this actuator belongs to this object */
- act= ob->actuators.first;
- while (act) {
- if (act == act_to_move) break;
- act= act->next;
- }
- if (!act) return;
-
- /* move up */
- if (val == 1 && act->prev) {
- /* locate the first visible actuators before this one */
- for (tmp = act->prev; tmp; tmp=tmp->prev) {
- if (tmp->flag & ACT_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&ob->actuators, act);
- BLI_insertlinkbefore(&ob->actuators, tmp, act);
- }
- }
- /* move down */
- else if (val == 2 && act->next) {
- /* locate the first visible actuators after this one */
- for (tmp=act->next; tmp; tmp=tmp->next) {
- if (tmp->flag & ACT_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&ob->actuators, act);
- BLI_insertlinkafter(&ob->actuators, tmp, act);
- }
- }
-}
-
-void link_logicbricks(void **poin, void ***ppoin, short *tot, short size)
-{
- void **old_links= NULL;
-
- int ibrick;
-
- /* check if the bricks are already linked */
- for (ibrick=0; ibrick < *tot; ibrick++) {
- if ((*ppoin)[ibrick] == *poin)
- return;
- }
-
- if (*ppoin) {
- old_links= *ppoin;
-
- (*tot) ++;
- *ppoin = MEM_callocN((*tot)*size, "new link");
-
- for (ibrick=0; ibrick < *(tot) - 1; ibrick++) {
- (*ppoin)[ibrick] = old_links[ibrick];
- }
- (*ppoin)[ibrick] = *poin;
-
- if (old_links) MEM_freeN(old_links);
- }
- else {
- (*tot) = 1;
- *ppoin = MEM_callocN((*tot)*size, "new link");
- (*ppoin)[0] = *poin;
- }
-}
-
-void unlink_logicbricks(void **poin, void ***ppoin, short *tot)
-{
- int ibrick, removed;
-
- removed= 0;
- for (ibrick=0; ibrick < *tot; ibrick++) {
- if (removed) (*ppoin)[ibrick - removed] = (*ppoin)[ibrick];
- else if ((*ppoin)[ibrick] == *poin) removed = 1;
- }
-
- if (removed) {
- (*tot) --;
-
- if (*tot == 0) {
- MEM_freeN(*ppoin);
- (*ppoin)= NULL;
- }
- return;
- }
-}
-
-void BKE_sca_sensors_id_loop(ListBase *senslist, SCASensorIDFunc func, void *userdata)
-{
- bSensor *sensor;
-
- for (sensor = senslist->first; sensor; sensor = sensor->next) {
- func(sensor, (ID **)&sensor->ob, userdata, IDWALK_CB_NOP);
-
- switch (sensor->type) {
- case SENS_TOUCH: /* DEPRECATED */
- {
- bTouchSensor *ts = sensor->data;
- func(sensor, (ID **)&ts->ma, userdata, IDWALK_CB_NOP);
- break;
- }
- case SENS_MESSAGE:
- {
- bMessageSensor *ms = sensor->data;
- func(sensor, (ID **)&ms->fromObject, userdata, IDWALK_CB_NOP);
- break;
- }
- case SENS_ALWAYS:
- case SENS_NEAR:
- case SENS_KEYBOARD:
- case SENS_PROPERTY:
- case SENS_MOUSE:
- case SENS_COLLISION:
- case SENS_RADAR:
- case SENS_RANDOM:
- case SENS_RAY:
- case SENS_JOYSTICK:
- case SENS_ACTUATOR:
- case SENS_DELAY:
- case SENS_ARMATURE:
- default:
- break;
- }
- }
-}
-
-void BKE_sca_controllers_id_loop(ListBase *contlist, SCAControllerIDFunc func, void *userdata)
-{
- bController *controller;
-
- for (controller = contlist->first; controller; controller = controller->next) {
- switch (controller->type) {
- case CONT_PYTHON:
- {
- bPythonCont *pc = controller->data;
- func(controller, (ID **)&pc->text, userdata, IDWALK_CB_NOP);
- break;
- }
- case CONT_LOGIC_AND:
- case CONT_LOGIC_OR:
- case CONT_EXPRESSION:
- case CONT_LOGIC_NAND:
- case CONT_LOGIC_NOR:
- case CONT_LOGIC_XOR:
- case CONT_LOGIC_XNOR:
- default:
- break;
- }
- }
-}
-
-void BKE_sca_actuators_id_loop(ListBase *actlist, SCAActuatorIDFunc func, void *userdata)
-{
- bActuator *actuator;
-
- for (actuator = actlist->first; actuator; actuator = actuator->next) {
- func(actuator, (ID **)&actuator->ob, userdata, IDWALK_CB_NOP);
-
- switch (actuator->type) {
- case ACT_ADD_OBJECT: /* DEPRECATED */
- {
- bAddObjectActuator *aoa = actuator->data;
- func(actuator, (ID **)&aoa->ob, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_ACTION:
- {
- bActionActuator *aa = actuator->data;
- func(actuator, (ID **)&aa->act, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_SOUND:
- {
- bSoundActuator *sa = actuator->data;
- func(actuator, (ID **)&sa->sound, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_EDIT_OBJECT:
- {
- bEditObjectActuator *eoa = actuator->data;
- func(actuator, (ID **)&eoa->ob, userdata, IDWALK_CB_NOP);
- func(actuator, (ID **)&eoa->me, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_SCENE:
- {
- bSceneActuator *sa = actuator->data;
- func(actuator, (ID **)&sa->scene, userdata, IDWALK_CB_NOP);
- func(actuator, (ID **)&sa->camera, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_PROPERTY:
- {
- bPropertyActuator *pa = actuator->data;
- func(actuator, (ID **)&pa->ob, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_OBJECT:
- {
- bObjectActuator *oa = actuator->data;
- func(actuator, (ID **)&oa->reference, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_CAMERA:
- {
- bCameraActuator *ca = actuator->data;
- func(actuator, (ID **)&ca->ob, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_MESSAGE:
- {
- bMessageActuator *ma = actuator->data;
- func(actuator, (ID **)&ma->toObject, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_2DFILTER:
- {
- bTwoDFilterActuator *tdfa = actuator->data;
- func(actuator, (ID **)&tdfa->text, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_PARENT:
- {
- bParentActuator *pa = actuator->data;
- func(actuator, (ID **)&pa->ob, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_ARMATURE:
- {
- bArmatureActuator *aa = actuator->data;
- func(actuator, (ID **)&aa->target, userdata, IDWALK_CB_NOP);
- func(actuator, (ID **)&aa->subtarget, userdata, IDWALK_CB_NOP);
- break;
- }
- case ACT_STEERING:
- {
- bSteeringActuator *sa = actuator->data;
- func(actuator, (ID **)&sa->target, userdata, IDWALK_CB_NOP);
- func(actuator, (ID **)&sa->navmesh, userdata, IDWALK_CB_NOP);
- break;
- }
- /* Note: some types seems to be non-implemented? ACT_LAMP, ACT_MATERIAL... */
- case ACT_LAMP:
- case ACT_MATERIAL:
- case ACT_END_OBJECT: /* DEPRECATED */
- case ACT_CONSTRAINT:
- case ACT_GROUP:
- case ACT_RANDOM:
- case ACT_GAME:
- case ACT_VISIBILITY:
- case ACT_SHAPEACTION:
- case ACT_STATE:
- case ACT_MOUSE:
- default:
- break;
- }
- }
-}
-
-const char *sca_state_name_get(Object *ob, short bit)
-{
- bController *cont;
- unsigned int mask;
-
- mask = (1<<bit);
- cont = ob->controllers.first;
- while (cont) {
- if (cont->state_mask & mask) {
- return cont->name;
- }
- cont = cont->next;
- }
- return NULL;
-}
-
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 9a7c10d31de..91ff3c15502 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -111,10 +111,9 @@
#include "bmesh.h"
-const char *RE_engine_id_BLENDER_RENDER = "BLENDER_RENDER";
-const char *RE_engine_id_BLENDER_GAME = "BLENDER_GAME";
const char *RE_engine_id_BLENDER_CLAY = "BLENDER_CLAY";
const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
+const char *RE_engine_id_BLENDER_WORKBENCH = "BLENDER_WORKBENCH";
const char *RE_engine_id_CYCLES = "CYCLES";
void free_avicodecdata(AviCodecData *acd)
@@ -272,6 +271,7 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
}
BLI_duplicatelist(&(sce_dst->markers), &(sce_src->markers));
+ BLI_duplicatelist(&(sce_dst->transform_spaces), &(sce_src->transform_spaces));
BLI_duplicatelist(&(sce_dst->r.views), &(sce_src->r.views));
BKE_keyingsets_copy(&(sce_dst->keyingsets), &(sce_src->keyingsets));
@@ -350,7 +350,6 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
sce_copy->r.views = rv;
sce_copy->unit = sce->unit;
sce_copy->physics_settings = sce->physics_settings;
- sce_copy->gm = sce->gm;
sce_copy->audio = sce->audio;
if (sce->id.properties)
@@ -493,6 +492,7 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
}
BLI_freelistN(&sce->markers);
+ BLI_freelistN(&sce->transform_spaces);
BLI_freelistN(&sce->r.views);
BKE_toolsettings_free(sce->toolsettings);
@@ -553,7 +553,7 @@ void BKE_scene_init(Scene *sce)
sce->lay = sce->layact = 1;
- sce->r.mode = R_GAMMA | R_OSA | R_SHADOW | R_SSS | R_ENVMAP | R_RAYTRACE;
+ sce->r.mode = R_OSA;
sce->r.cfra = 1;
sce->r.sfra = 1;
sce->r.efra = 250;
@@ -564,8 +564,6 @@ void BKE_scene_init(Scene *sce)
sce->r.yasp = 1;
sce->r.tilex = 256;
sce->r.tiley = 256;
- sce->r.mblur_samples = 1;
- sce->r.filtertype = R_FILTER_MITCH;
sce->r.size = 50;
sce->r.im_format.planes = R_IMF_PLANES_RGBA;
@@ -581,8 +579,6 @@ void BKE_scene_init(Scene *sce)
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,
* images would look in the same way as in current blender
@@ -591,18 +587,9 @@ void BKE_scene_init(Scene *sce)
*/
sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT;
- sce->r.gauss = 1.5f;
-
- /* deprecated but keep for upwards compat */
- sce->r.postgamma = 1.0;
- sce->r.posthue = 0.0;
- sce->r.postsat = 1.0;
-
- sce->r.bake_mode = 1; /* prevent to include render stuff here */
+ sce->r.bake_mode = 0;
sce->r.bake_filter = 16;
- sce->r.bake_osa = 5;
sce->r.bake_flag = R_BAKE_CLEAR;
- sce->r.bake_normal_space = R_BAKE_SPACE_TANGENT;
sce->r.bake_samples = 256;
sce->r.bake_biasdist = 0.001;
@@ -630,7 +617,6 @@ void BKE_scene_init(Scene *sce)
sce->r.fg_stamp[3] = 1.0f;
sce->r.bg_stamp[0] = sce->r.bg_stamp[1] = sce->r.bg_stamp[2] = 0.0f;
sce->r.bg_stamp[3] = 0.25f;
- sce->r.raytrace_options = R_RAYTRACE_USE_INSTANCES;
sce->r.seq_prev_type = OB_SOLID;
sce->r.seq_rend_type = OB_SOLID;
@@ -640,8 +626,6 @@ void BKE_scene_init(Scene *sce)
sce->r.simplify_subsurf = 6;
sce->r.simplify_particles = 1.0f;
- sce->r.simplify_shadowsamples = 16;
- sce->r.simplify_aosss = 1.0f;
sce->r.border.xmin = 0.0f;
sce->r.border.ymin = 0.0f;
@@ -675,21 +659,6 @@ void BKE_scene_init(Scene *sce)
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;
- sce->toolsettings->skgen_angle_limit = 45.0f;
- sce->toolsettings->skgen_length_ratio = 1.3f;
- sce->toolsettings->skgen_length_limit = 1.5f;
- sce->toolsettings->skgen_correlation_limit = 0.98f;
- sce->toolsettings->skgen_symmetry_limit = 0.1f;
- sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
- sce->toolsettings->skgen_postpro_passes = 1;
- sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL | SKGEN_FILTER_EXTERNAL | SKGEN_FILTER_SMART | SKGEN_HARMONIC | SKGEN_SUB_CORRELATION | SKGEN_STICK_TO_EMBEDDING;
- sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
- sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
- sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
-
sce->toolsettings->curve_paint_settings.curve_type = CU_BEZIER;
sce->toolsettings->curve_paint_settings.flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
sce->toolsettings->curve_paint_settings.error_threshold = 8;
@@ -743,7 +712,7 @@ void BKE_scene_init(Scene *sce)
sce->r.ffcodecdata.audio_bitrate = 192;
sce->r.ffcodecdata.audio_channels = 2;
- BKE_viewrender_init(&sce->view_render);
+ BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(sce->r.engine));
sce->audio.distance_model = 2.0f;
sce->audio.doppler_factor = 1.0f;
@@ -766,59 +735,6 @@ void BKE_scene_init(Scene *sce)
srv = sce->r.views.last;
BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
- /* game data */
- sce->gm.stereoflag = STEREO_NOSTEREO;
- sce->gm.stereomode = STEREO_ANAGLYPH;
- sce->gm.eyeseparation = 0.10;
-
- sce->gm.dome.angle = 180;
- sce->gm.dome.mode = DOME_FISHEYE;
- sce->gm.dome.res = 4;
- sce->gm.dome.resbuf = 1.0f;
- sce->gm.dome.tilt = 0;
-
- sce->gm.xplay = 640;
- sce->gm.yplay = 480;
- sce->gm.freqplay = 60;
- sce->gm.depth = 32;
-
- sce->gm.gravity = 9.8f;
- sce->gm.physicsEngine = WOPHY_BULLET;
- sce->gm.mode = 32; //XXX ugly harcoding, still not sure we should drop mode. 32 == 1 << 5 == use_occlusion_culling
- sce->gm.occlusionRes = 128;
- sce->gm.ticrate = 60;
- sce->gm.maxlogicstep = 5;
- sce->gm.physubstep = 1;
- sce->gm.maxphystep = 5;
- sce->gm.lineardeactthreshold = 0.8f;
- sce->gm.angulardeactthreshold = 1.0f;
- sce->gm.deactivationtime = 0.0f;
-
- sce->gm.flag = 0;
- sce->gm.matmode = GAME_MAT_MULTITEX;
-
- sce->gm.obstacleSimulation = OBSTSIMULATION_NONE;
- sce->gm.levelHeight = 2.f;
-
- sce->gm.recastData.cellsize = 0.3f;
- sce->gm.recastData.cellheight = 0.2f;
- sce->gm.recastData.agentmaxslope = M_PI_4;
- sce->gm.recastData.agentmaxclimb = 0.9f;
- sce->gm.recastData.agentheight = 2.0f;
- sce->gm.recastData.agentradius = 0.6f;
- sce->gm.recastData.edgemaxlen = 12.0f;
- sce->gm.recastData.edgemaxerror = 1.3f;
- sce->gm.recastData.regionminsize = 8.f;
- sce->gm.recastData.regionmergesize = 20.f;
- sce->gm.recastData.vertsperpoly = 6;
- sce->gm.recastData.detailsampledist = 6.0f;
- sce->gm.recastData.detailsamplemaxerror = 1.0f;
-
- sce->gm.lodflag = SCE_LOD_USE_HYST;
- sce->gm.scehysteresis = 10;
-
- sce->gm.exitkey = 218; // Blender key code for ESC
-
BKE_sound_create_scene(sce);
/* color management */
@@ -889,6 +805,8 @@ void BKE_scene_init(Scene *sce)
sce->toolsettings->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
sce->toolsettings->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
+ sce->orientation_index_custom = -1;
+
/* Master Collection */
sce->collection = MEM_callocN(sizeof(SceneCollection), "Master Collection");
BLI_strncpy(sce->collection->name, "Master Collection", sizeof(sce->collection->name));
@@ -995,7 +913,7 @@ Scene *BKE_scene_set_name(Main *bmain, const char *name)
/* Used by metaballs, return *all* objects (including duplis) existing in the scene (including scene's sets) */
int BKE_scene_base_iter_next(
- const EvaluationContext *eval_ctx, SceneBaseIter *iter,
+ Depsgraph *depsgraph, SceneBaseIter *iter,
Scene **scene, int val, Base **base, Object **ob)
{
bool run_again = true;
@@ -1014,7 +932,9 @@ int BKE_scene_base_iter_next(
/* the first base */
if (iter->phase == F_START) {
- ViewLayer *view_layer = eval_ctx->view_layer;
+ ViewLayer *view_layer = (depsgraph) ?
+ DEG_get_evaluated_view_layer(depsgraph) :
+ BKE_view_layer_from_scene_get(*scene);
*base = view_layer->object_bases.first;
if (*base) {
*ob = (*base)->object;
@@ -1062,12 +982,12 @@ int BKE_scene_base_iter_next(
}
else {
if (iter->phase != F_DUPLI) {
- if ( (*base)->object->transflag & OB_DUPLI) {
+ if (depsgraph && (*base)->object->transflag & OB_DUPLI) {
/* groups cannot be duplicated for mballs yet,
* this enters eternal loop because of
* makeDispListMBall getting called inside of group_duplilist */
if ((*base)->object->dup_group == NULL) {
- iter->duplilist = object_duplilist_ex(eval_ctx, (*scene), (*base)->object, false);
+ iter->duplilist = object_duplilist_ex(depsgraph, (*scene), (*base)->object, false);
iter->dupob = iter->duplilist->first;
@@ -1328,21 +1248,19 @@ static bool check_rendered_viewport_visible(Main *bmain)
wmWindow *window;
for (window = wm->windows.first; window != NULL; window = window->next) {
const bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook);
- WorkSpace *workspace = BKE_workspace_active_get(window->workspace_hook);
Scene *scene = window->scene;
- ViewRender *view_render = BKE_viewrender_get(scene, workspace);
- ScrArea *area;
- RenderEngineType *type = RE_engines_find(view_render->engine_id);
- if ((type->draw_engine != NULL) || (type->render_to_view == NULL)) {
+ RenderEngineType *type = RE_engines_find(scene->r.engine);
+
+ if (type->draw_engine || !type->render_to_view) {
continue;
}
- const bool use_legacy = (type->flag & RE_USE_LEGACY_PIPELINE) != 0;
- for (area = screen->areabase.first; area != NULL; area = area->next) {
+
+ for (ScrArea *area = screen->areabase.first; area != NULL; area = area->next) {
View3D *v3d = area->spacedata.first;
if (area->spacetype != SPACE_VIEW3D) {
continue;
}
- if (v3d->drawtype == OB_RENDER || !use_legacy) {
+ if (v3d->drawtype == OB_RENDER) {
return true;
}
}
@@ -1350,7 +1268,7 @@ static bool check_rendered_viewport_visible(Main *bmain)
return false;
}
-/* TODO(campbell): shouldn't we be able to use 'eval_ctx->view_layer' here?
+/* TODO(campbell): shouldn't we be able to use 'DEG_get_view_layer' here?
* Currently this is NULL on load, so don't. */
static void prepare_mesh_for_viewport_render(
Main *bmain, const ViewLayer *view_layer)
@@ -1522,22 +1440,6 @@ int get_render_child_particle_number(const RenderData *r, int num, bool for_rend
}
}
-int get_render_shadow_samples(const RenderData *r, int samples)
-{
- if ((r->mode & R_SIMPLIFY) && samples > 0)
- return min_ii(r->simplify_shadowsamples, samples);
- else
- return samples;
-}
-
-float get_render_aosss_error(const RenderData *r, float error)
-{
- if (r->mode & R_SIMPLIFY)
- return ((1.0f - r->simplify_aosss) * 10.0f + 1.0f) * error;
- else
- return error;
-}
-
/**
* Helper function for the SETLOOPER and SETLOOPER_VIEW_LAYER macros
*
@@ -1575,41 +1477,26 @@ next_set:
return NULL;
}
-bool BKE_scene_use_new_shading_nodes(const Scene *scene)
-{
- return BKE_viewrender_use_new_shading_nodes(&scene->view_render);
-}
-
bool BKE_scene_use_shading_nodes_custom(Scene *scene)
{
- return BKE_viewrender_use_shading_nodes_custom(&scene->view_render);
-}
-
-bool BKE_scene_use_world_space_shading(Scene *scene)
-{
- RenderEngineType *type = RE_engines_find(scene->view_render.engine_id);
- return ((scene->r.mode & R_USE_WS_SHADING) ||
- (type && (type->flag & RE_USE_SHADING_NODES)));
+ RenderEngineType *type = RE_engines_find(scene->r.engine);
+ return (type && type->flag & RE_USE_SHADING_NODES_CUSTOM);
}
bool BKE_scene_use_spherical_stereo(Scene *scene)
{
- return BKE_viewrender_use_spherical_stereo(&scene->view_render);
+ RenderEngineType *type = RE_engines_find(scene->r.engine);
+ return (type && type->flag & RE_USE_SPHERICAL_STEREO);
}
-bool BKE_scene_uses_blender_internal(const Scene *scene)
+bool BKE_scene_uses_blender_eevee(const Scene *scene)
{
- return BKE_viewrender_uses_blender_internal(&scene->view_render);
+ return STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE);
}
-bool BKE_scene_uses_blender_game(const Scene *scene)
+bool BKE_scene_uses_cycles(const Scene *scene)
{
- return BKE_viewrender_uses_blender_game(&scene->view_render);
-}
-
-bool BKE_scene_uses_blender_eevee(const Scene *scene)
-{
- return BKE_viewrender_uses_blender_eevee(&scene->view_render);
+ return STREQ(scene->r.engine, RE_engine_id_CYCLES);
}
void BKE_scene_base_flag_to_objects(ViewLayer *view_layer)
@@ -1714,81 +1601,6 @@ int BKE_render_preview_pixel_size(const RenderData *r)
return r->preview_pixel_size;
}
-/* ***************************************************** */
-/* render engine settings */
-
-ViewRender *BKE_viewrender_get(Scene *scene, WorkSpace *workspace)
-{
- if (workspace == NULL || BKE_workspace_use_scene_settings_get(workspace)) {
- return &scene->view_render;
- }
- return BKE_workspace_view_render_get(workspace);
-}
-
-/**
- * Initialize a static created struct for WorkSpace and Scene to store the viewport
- * related drawing data.
- */
-void BKE_viewrender_init(ViewRender *view_render)
-{
- BLI_strncpy(view_render->engine_id, RE_engine_id_BLENDER_EEVEE, sizeof(view_render->engine_id));
-}
-
-/**
- * Do not free ViewRender itself since it's not even allocated.
- */
-void BKE_viewrender_free(ViewRender *UNUSED(view_render))
-{
- /* Do nothing. */
-}
-
-/**
- * Copy used by libblock copying.
- */
-void BKE_viewrender_copy(ViewRender *to, const ViewRender *from)
-{
- *to = *from;
-}
-
-bool BKE_viewrender_use_new_shading_nodes(const ViewRender *view_render)
-{
- RenderEngineType *type = RE_engines_find(view_render->engine_id);
- return (type && type->flag & RE_USE_SHADING_NODES);
-}
-
-bool BKE_viewrender_use_shading_nodes_custom(const ViewRender *view_render)
-{
- RenderEngineType *type = RE_engines_find(view_render->engine_id);
- return (type && type->flag & RE_USE_SHADING_NODES_CUSTOM);
-}
-
-bool BKE_viewrender_use_spherical_stereo(const ViewRender *view_render)
-{
- const char *engine_id = view_render->engine_id;
- RenderEngineType *type = RE_engines_find(engine_id);
- return (type && type->flag & RE_USE_SPHERICAL_STEREO);
-}
-
-bool BKE_viewrender_uses_blender_internal(const ViewRender *view_render)
-{
- const char *engine_id = view_render->engine_id;
- return STREQ(engine_id, RE_engine_id_BLENDER_RENDER);
-}
-
-bool BKE_viewrender_uses_blender_game(const ViewRender *view_render)
-{
- const char *engine_id = view_render->engine_id;
- return STREQ(engine_id, RE_engine_id_BLENDER_GAME);
-}
-
-bool BKE_viewrender_uses_blender_eevee(const ViewRender *view_render)
-{
- const char *engine_id = view_render->engine_id;
- return STREQ(engine_id, RE_engine_id_BLENDER_EEVEE);
-}
-
-/* ***************************************************** */
-
/* Apply the needed correction factor to value, based on unit_type (only length-related are affected currently)
* and unit->scale_length.
*/
@@ -2197,3 +2009,36 @@ Depsgraph *BKE_scene_get_depsgraph(Scene *scene,
}
return depsgraph;
}
+
+/* -------------------------------------------------------------------- */
+/** \name Scene Orientation
+ * \{ */
+
+void BKE_scene_transform_orientation_remove(
+ Scene *scene, TransformOrientation *orientation)
+{
+ const int orientation_index = BKE_scene_transform_orientation_get_index(scene, orientation);
+ if (scene->orientation_index_custom == orientation_index) {
+ /* could also use orientation_index-- */
+ scene->orientation_type = V3D_MANIP_GLOBAL;
+ scene->orientation_index_custom = -1;
+ }
+ BLI_freelinkN(&scene->transform_spaces, orientation);
+}
+
+TransformOrientation *BKE_scene_transform_orientation_find(
+ const Scene *scene, const int index)
+{
+ return BLI_findlink(&scene->transform_spaces, index);
+}
+
+/**
+ * \return the index that \a orientation has within \a scene's transform-orientation list or -1 if not found.
+ */
+int BKE_scene_transform_orientation_get_index(
+ const Scene *scene, const TransformOrientation *orientation)
+{
+ return BLI_findindex(&scene->transform_spaces, orientation);
+}
+
+/** \} */
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index c1b3a4ae0c8..77f7b5f847e 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -397,6 +397,7 @@ void BKE_screen_area_free(ScrArea *sa)
for (ar = sa->regionbase.first; ar; ar = ar->next)
BKE_area_region_free(st, ar);
+ MEM_SAFE_FREE(sa->global);
BLI_freelistN(&sa->regionbase);
BKE_spacedata_freelist(&sa->spacedata);
@@ -404,10 +405,21 @@ void BKE_screen_area_free(ScrArea *sa)
BLI_freelistN(&sa->actionzones);
}
+void BKE_screen_area_map_free(ScrAreaMap *area_map)
+{
+ for (ScrArea *area = area_map->areabase.first, *area_next; area; area = area_next) {
+ area_next = area->next;
+ BKE_screen_area_free(area);
+ }
+
+ BLI_freelistN(&area_map->vertbase);
+ BLI_freelistN(&area_map->edgebase);
+ BLI_freelistN(&area_map->areabase);
+}
+
/** Free (or release) any data used by this screen (does not free the screen itself). */
void BKE_screen_free(bScreen *sc)
{
- ScrArea *sa, *san;
ARegion *ar;
/* No animdata here. */
@@ -416,18 +428,11 @@ void BKE_screen_free(bScreen *sc)
BKE_area_region_free(NULL, ar);
BLI_freelistN(&sc->regionbase);
-
- for (sa = sc->areabase.first; sa; sa = san) {
- san = sa->next;
- BKE_screen_area_free(sa);
- }
-
- BLI_freelistN(&sc->vertbase);
- BLI_freelistN(&sc->edgebase);
- BLI_freelistN(&sc->areabase);
+
+ BKE_screen_area_map_free(AREAMAP_FROM_SCREEN(sc));
BKE_previewimg_free(&sc->preview);
-
+
/* Region and timer are freed by the window manager. */
MEM_SAFE_FREE(sc->tool_tip);
}
@@ -451,6 +456,174 @@ unsigned int BKE_screen_visible_layers(bScreen *screen, Scene *scene)
return layer;
}
+
+/* ***************** Screen edges & verts ***************** */
+
+ScrEdge *BKE_screen_find_edge(bScreen *sc, ScrVert *v1, ScrVert *v2)
+{
+ ScrEdge *se;
+
+ BKE_screen_sort_scrvert(&v1, &v2);
+ for (se = sc->edgebase.first; se; se = se->next) {
+ if (se->v1 == v1 && se->v2 == v2) {
+ return se;
+ }
+ }
+
+ return NULL;
+}
+
+void BKE_screen_sort_scrvert(ScrVert **v1, ScrVert **v2)
+{
+ ScrVert *tmp;
+
+ if (*v1 > *v2) {
+ tmp = *v1;
+ *v1 = *v2;
+ *v2 = tmp;
+ }
+}
+
+void BKE_screen_remove_double_scrverts(bScreen *sc)
+{
+ ScrVert *v1, *verg;
+ ScrEdge *se;
+ ScrArea *sa;
+
+ verg = sc->vertbase.first;
+ while (verg) {
+ if (verg->newv == NULL) { /* !!! */
+ v1 = verg->next;
+ while (v1) {
+ if (v1->newv == NULL) { /* !?! */
+ if (v1->vec.x == verg->vec.x && v1->vec.y == verg->vec.y) {
+ /* printf("doublevert\n"); */
+ v1->newv = verg;
+ }
+ }
+ v1 = v1->next;
+ }
+ }
+ verg = verg->next;
+ }
+
+ /* replace pointers in edges and faces */
+ se = sc->edgebase.first;
+ while (se) {
+ if (se->v1->newv) se->v1 = se->v1->newv;
+ if (se->v2->newv) se->v2 = se->v2->newv;
+ /* edges changed: so.... */
+ BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
+ se = se->next;
+ }
+ sa = sc->areabase.first;
+ while (sa) {
+ if (sa->v1->newv) sa->v1 = sa->v1->newv;
+ if (sa->v2->newv) sa->v2 = sa->v2->newv;
+ if (sa->v3->newv) sa->v3 = sa->v3->newv;
+ if (sa->v4->newv) sa->v4 = sa->v4->newv;
+ sa = sa->next;
+ }
+
+ /* remove */
+ verg = sc->vertbase.first;
+ while (verg) {
+ v1 = verg->next;
+ if (verg->newv) {
+ BLI_remlink(&sc->vertbase, verg);
+ MEM_freeN(verg);
+ }
+ verg = v1;
+ }
+
+}
+
+void BKE_screen_remove_double_scredges(bScreen *sc)
+{
+ ScrEdge *verg, *se, *sn;
+
+ /* compare */
+ verg = sc->edgebase.first;
+ while (verg) {
+ se = verg->next;
+ while (se) {
+ sn = se->next;
+ if (verg->v1 == se->v1 && verg->v2 == se->v2) {
+ BLI_remlink(&sc->edgebase, se);
+ MEM_freeN(se);
+ }
+ se = sn;
+ }
+ verg = verg->next;
+ }
+}
+
+void BKE_screen_remove_unused_scredges(bScreen *sc)
+{
+ ScrEdge *se, *sen;
+ ScrArea *sa;
+ int a = 0;
+
+ /* sets flags when edge is used in area */
+ sa = sc->areabase.first;
+ while (sa) {
+ se = BKE_screen_find_edge(sc, sa->v1, sa->v2);
+ if (se == NULL) printf("error: area %d edge 1 doesn't exist\n", a);
+ else se->flag = 1;
+ se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
+ if (se == NULL) printf("error: area %d edge 2 doesn't exist\n", a);
+ else se->flag = 1;
+ se = BKE_screen_find_edge(sc, sa->v3, sa->v4);
+ if (se == NULL) printf("error: area %d edge 3 doesn't exist\n", a);
+ else se->flag = 1;
+ se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
+ if (se == NULL) printf("error: area %d edge 4 doesn't exist\n", a);
+ else se->flag = 1;
+ sa = sa->next;
+ a++;
+ }
+ se = sc->edgebase.first;
+ while (se) {
+ sen = se->next;
+ if (se->flag == 0) {
+ BLI_remlink(&sc->edgebase, se);
+ MEM_freeN(se);
+ }
+ else {
+ se->flag = 0;
+ }
+ se = sen;
+ }
+}
+
+void BKE_screen_remove_unused_scrverts(bScreen *sc)
+{
+ ScrVert *sv, *svn;
+ ScrEdge *se;
+
+ /* we assume edges are ok */
+
+ se = sc->edgebase.first;
+ while (se) {
+ se->v1->flag = 1;
+ se->v2->flag = 1;
+ se = se->next;
+ }
+
+ sv = sc->vertbase.first;
+ while (sv) {
+ svn = sv->next;
+ if (sv->flag == 0) {
+ BLI_remlink(&sc->vertbase, sv);
+ MEM_freeN(sv);
+ }
+ else {
+ sv->flag = 0;
+ }
+ sv = svn;
+ }
+}
+
/* ***************** Utilities ********************** */
/* Find a region of the specified type from the given area */
@@ -644,26 +817,6 @@ void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene)
}
}
-void BKE_screen_transform_orientation_remove(
- const bScreen *screen, const WorkSpace *workspace, const TransformOrientation *orientation)
-{
- const int orientation_index = BKE_workspace_transform_orientation_get_index(workspace, orientation);
-
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
-
- if (v3d->custom_orientation_index == orientation_index) {
- /* could also use orientation_index-- */
- v3d->twmode = V3D_MANIP_GLOBAL;
- v3d->custom_orientation_index = -1;
- }
- }
- }
- }
-}
-
/* magic zoom calculation, no idea what
* it signifies, if you find out, tell me! -zr
*/
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 49f120de250..176d1224979 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1767,12 +1767,13 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
if (output != output) output = 1;
if (wipe->forward) output = 1 - output;
break;
- /* BOX WIPE IS NOT WORKING YET */
+ /* BOX WIPE IS NOT WORKING YET */
/* case DO_CROSS_WIPE: */
/* BOX WIPE IS NOT WORKING YET */
#if 0
case DO_BOX_WIPE:
- if (invert) facf0 = 1 - facf0;
+ if (!wipe->forward)
+ facf0 = 1.0f - facf0; /* Go the other direction */
width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0));
hwidth = (float)width / 2.0;
@@ -1790,22 +1791,23 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
if (b2 < b1 && b2 < b3) {
if (hwidth < pointdist)
- output = in_band(wipezone, hwidth, hyp, facf0, 0, 1);
+ output = in_band(hwidth, hyp, 0, 1);
}
else if (b2 > b1 && b2 > b3) {
if (hwidth < pointdist)
- output = in_band(wipezone, hwidth, hyp2, facf0, 0, 1);
+ output = in_band(hwidth, hyp2, 0, 1);
}
else {
if (hyp < hwidth && hyp2 > hwidth)
- output = in_band(wipezone, hwidth, hyp, facf0, 1, 1);
+ output = in_band(hwidth, hyp, 1, 1);
else if (hyp > hwidth && hyp2 < hwidth)
- output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1);
+ output = in_band(hwidth, hyp2, 1, 1);
else
- output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1);
+ output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1);
}
- if (invert) facf0 = 1 - facf0;
+ if (!wipe->forward)
+ facf0 = 1.0f - facf0; /* Go the other direction */
angle = -1 / angle;
b1 = posy / 2 - (-angle) * posx / 2;
b3 = (yo - posy / 2) - (-angle) * (xo - posx / 2);
@@ -1816,19 +1818,19 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
if (b2 < b1 && b2 < b3) {
if (hwidth < pointdist)
- output *= in_band(wipezone, hwidth, hyp, facf0, 0, 1);
+ output *= in_band(hwidth, hyp, 0, 1);
}
else if (b2 > b1 && b2 > b3) {
if (hwidth < pointdist)
- output *= in_band(wipezone, hwidth, hyp2, facf0, 0, 1);
+ output *= in_band(hwidth, hyp2, 0, 1);
}
else {
if (hyp < hwidth && hyp2 > hwidth)
- output *= in_band(wipezone, hwidth, hyp, facf0, 1, 1);
+ output *= in_band(hwidth, hyp, 1, 1);
else if (hyp > hwidth && hyp2 < hwidth)
- output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1);
+ output *= in_band(hwidth, hyp2, 1, 1);
else
- output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1);
+ output *= in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1);
}
break;
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 58b83a754d8..974c2faeadf 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -76,6 +76,7 @@
#include "BKE_idprop.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
@@ -592,17 +593,16 @@ void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixe
/*********************** sequencer pipeline functions *************************/
void BKE_sequencer_new_render_data(
- EvaluationContext *eval_ctx,
Main *bmain, Scene *scene, int rectx, int recty,
- int preview_render_size,
+ int preview_render_size, int for_render,
SeqRenderData *r_context)
{
- r_context->eval_ctx = eval_ctx;
r_context->bmain = bmain;
r_context->scene = scene;
r_context->rectx = rectx;
r_context->recty = recty;
r_context->preview_render_size = preview_render_size;
+ r_context->for_render = for_render;
r_context->motion_blur_samples = 0;
r_context->motion_blur_shutter = 0;
r_context->skip_cache = false;
@@ -2035,9 +2035,10 @@ void BKE_sequencer_proxy_rebuild(SeqIndexBuildContext *context, short *stop, sho
/* fail safe code */
BKE_sequencer_new_render_data(
- bmain->eval_ctx, bmain, context->scene,
+ bmain, context->scene,
(scene->r.size * (float) scene->r.xsch) / 100.0f + 0.5f,
(scene->r.size * (float) scene->r.ysch) / 100.0f + 0.5f, 100,
+ false,
&render_context);
render_context.skip_cache = true;
@@ -2757,17 +2758,12 @@ static ImBuf *seq_render_effect_strip_impl(
if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) {
sh.get_default_fac(seq, cfra, &fac, &facf);
-
- if ((scene->r.mode & R_FIELDS) == 0)
- facf = fac;
+ facf = fac;
}
else {
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "effect_fader", 0, NULL);
if (fcu) {
fac = facf = evaluate_fcurve(fcu, cfra);
- if (scene->r.mode & R_FIELDS) {
- facf = evaluate_fcurve(fcu, cfra + 0.5f);
- }
}
else {
fac = facf = seq->effect_fader;
@@ -3332,14 +3328,14 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
context->scene->r.seq_prev_type = 3 /* == OB_SOLID */;
/* opengl offscreen render */
- RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
BKE_scene_graph_update_for_newframe(depsgraph, context->bmain);
ibuf = sequencer_view3d_cb(
/* set for OpenGL render (NULL when scrubbing) */
- context->eval_ctx, scene, view_layer, engine_type,
+ depsgraph, scene,
+ context->scene->r.seq_prev_type,
camera, width, height, IB_rect,
- draw_flags, context->scene->r.seq_prev_type,
+ draw_flags,
scene->r.alphamode, context->gpu_samples, viewname,
context->gpu_offscreen, err_out);
if (ibuf == NULL) {
@@ -3362,7 +3358,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
* When rendering from command line renderer is called from main thread, in this
* case it's always safe to render scene here
*/
- if (!is_thread_main || is_rendering == false || is_background || context->eval_ctx->mode == DAG_EVAL_RENDER) {
+ if (!is_thread_main || is_rendering == false || is_background || context->for_render) {
if (re == NULL)
re = RE_NewSceneRender(scene);
diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c
deleted file mode 100644
index 6f5c264f658..00000000000
--- a/source/blender/blenkernel/intern/sketch.c
+++ /dev/null
@@ -1,555 +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.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/blenkernel/intern/sketch.c
- * \ingroup bke
- */
-
-
-#include <string.h>
-#include <math.h>
-#include <float.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_sketch.h"
-
-
-#include "DNA_userdef_types.h"
-
-void freeSketch(SK_Sketch *sketch)
-{
- SK_Stroke *stk, *next;
-
- for (stk = sketch->strokes.first; stk; stk = next) {
- next = stk->next;
-
- sk_freeStroke(stk);
- }
-
- MEM_freeN(sketch);
-}
-
-SK_Sketch *createSketch(void)
-{
- SK_Sketch *sketch;
-
- sketch = MEM_callocN(sizeof(SK_Sketch), "SK_Sketch");
-
- sketch->active_stroke = NULL;
- sketch->gesture = NULL;
-
- BLI_listbase_clear(&sketch->strokes);
-
- return sketch;
-}
-
-void sk_initPoint(SK_Point *pt, SK_DrawData *dd, const float no[3])
-{
- if (no) {
- normalize_v3_v3(pt->no, no);
- }
- else {
- pt->no[0] = 0.0f;
- pt->no[1] = 0.0f;
- pt->no[2] = 1.0f;
- }
- pt->p2d[0] = dd->mval[0];
- pt->p2d[1] = dd->mval[1];
-
- pt->size = 0.0f;
- pt->type = PT_CONTINUOUS;
- pt->mode = PT_SNAP;
- /* more init code here */
-}
-
-void sk_copyPoint(SK_Point *dst, SK_Point *src)
-{
- memcpy(dst, src, sizeof(SK_Point));
-}
-
-void sk_allocStrokeBuffer(SK_Stroke *stk)
-{
- stk->points = MEM_callocN(sizeof(SK_Point) * stk->buf_size, "SK_Point buffer");
-}
-
-void sk_freeStroke(SK_Stroke *stk)
-{
- MEM_freeN(stk->points);
- MEM_freeN(stk);
-}
-
-SK_Stroke *sk_createStroke(void)
-{
- SK_Stroke *stk;
-
- stk = MEM_callocN(sizeof(SK_Stroke), "SK_Stroke");
-
- stk->selected = 0;
- stk->nb_points = 0;
- stk->buf_size = SK_Stroke_BUFFER_INIT_SIZE;
-
- sk_allocStrokeBuffer(stk);
-
- return stk;
-}
-
-void sk_shrinkStrokeBuffer(SK_Stroke *stk)
-{
- if (stk->nb_points < stk->buf_size) {
- SK_Point *old_points = stk->points;
-
- stk->buf_size = stk->nb_points;
-
- sk_allocStrokeBuffer(stk);
-
- memcpy(stk->points, old_points, sizeof(SK_Point) * stk->nb_points);
-
- MEM_freeN(old_points);
- }
-}
-
-void sk_growStrokeBuffer(SK_Stroke *stk)
-{
- if (stk->nb_points == stk->buf_size) {
- SK_Point *old_points = stk->points;
-
- stk->buf_size *= 2;
-
- sk_allocStrokeBuffer(stk);
-
- memcpy(stk->points, old_points, sizeof(SK_Point) * stk->nb_points);
-
- MEM_freeN(old_points);
- }
-}
-
-void sk_growStrokeBufferN(SK_Stroke *stk, int n)
-{
- if (stk->nb_points + n > stk->buf_size) {
- SK_Point *old_points = stk->points;
-
- while (stk->nb_points + n > stk->buf_size) {
- stk->buf_size *= 2;
- }
-
- sk_allocStrokeBuffer(stk);
-
- memcpy(stk->points, old_points, sizeof(SK_Point) * stk->nb_points);
-
- MEM_freeN(old_points);
- }
-}
-
-
-void sk_replaceStrokePoint(SK_Stroke *stk, SK_Point *pt, int n)
-{
- memcpy(stk->points + n, pt, sizeof(SK_Point));
-}
-
-void sk_insertStrokePoint(SK_Stroke *stk, SK_Point *pt, int n)
-{
- int size = stk->nb_points - n;
-
- sk_growStrokeBuffer(stk);
-
- memmove(stk->points + n + 1, stk->points + n, size * sizeof(SK_Point));
-
- memcpy(stk->points + n, pt, sizeof(SK_Point));
-
- stk->nb_points++;
-}
-
-void sk_appendStrokePoint(SK_Stroke *stk, SK_Point *pt)
-{
- sk_growStrokeBuffer(stk);
-
- memcpy(stk->points + stk->nb_points, pt, sizeof(SK_Point));
-
- stk->nb_points++;
-}
-
-void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, int end)
-{
- int size = end - start;
-
- sk_growStrokeBufferN(stk, len - size);
-
- if (len != size) {
- int tail_size = stk->nb_points - end;
-
- memmove(stk->points + start + len, stk->points + end, tail_size * sizeof(SK_Point));
- }
-
- memcpy(stk->points + start, pts, len * sizeof(SK_Point));
-
- stk->nb_points += len - size;
-}
-
-void sk_trimStroke(SK_Stroke *stk, int start, int end)
-{
- int size = end - start + 1;
-
- if (start > 0) {
- memmove(stk->points, stk->points + start, size * sizeof(SK_Point));
- }
-
- stk->nb_points = size;
-}
-
-void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], float p_end[3])
-{
- SK_Point pt1, pt2;
- SK_Point *prev, *next;
- float delta_p[3];
- int i, total;
-
- total = end - start;
-
- sub_v3_v3v3(delta_p, p_end, p_start);
-
- prev = stk->points + start;
- next = stk->points + end;
-
- copy_v3_v3(pt1.p, p_start);
- copy_v3_v3(pt1.no, prev->no);
- pt1.mode = prev->mode;
- pt1.type = prev->type;
-
- copy_v3_v3(pt2.p, p_end);
- copy_v3_v3(pt2.no, next->no);
- pt2.mode = next->mode;
- pt2.type = next->type;
-
- sk_insertStrokePoint(stk, &pt1, start + 1); /* insert after start */
- sk_insertStrokePoint(stk, &pt2, end + 1); /* insert before end (since end was pushed back already) */
-
- for (i = 1; i < total; i++) {
- float delta = (float)i / (float)total;
- float *p = stk->points[start + 1 + i].p;
-
- mul_v3_v3fl(p, delta_p, delta);
- add_v3_v3(p, p_start);
- }
-}
-
-void sk_polygonizeStroke(SK_Stroke *stk, int start, int end)
-{
- int offset;
- int i;
-
- /* find first exact points outside of range */
- for (; start > 0; start--) {
- if (stk->points[start].type == PT_EXACT) {
- break;
- }
- }
-
- for (; end < stk->nb_points - 1; end++) {
- if (stk->points[end].type == PT_EXACT) {
- break;
- }
- }
-
- offset = start + 1;
-
- for (i = start + 1; i < end; i++) {
- if (stk->points[i].type == PT_EXACT) {
- if (offset != i) {
- memcpy(stk->points + offset, stk->points + i, sizeof(SK_Point));
- }
-
- offset++;
- }
- }
-
- /* some points were removes, move end of array */
- if (offset < end) {
- int size = stk->nb_points - end;
- memmove(stk->points + offset, stk->points + end, size * sizeof(SK_Point));
- stk->nb_points = offset + size;
- }
-}
-
-void sk_flattenStroke(SK_Stroke *stk, int start, int end)
-{
- float normal[3], distance[3];
- float limit;
- int i, total;
-
- total = end - start + 1;
-
- copy_v3_v3(normal, stk->points[start].no);
-
- sub_v3_v3v3(distance, stk->points[end].p, stk->points[start].p);
- project_v3_v3v3(normal, distance, normal);
- limit = normalize_v3(normal);
-
- for (i = 1; i < total - 1; i++) {
- float d = limit * i / total;
- float offset[3];
- float *p = stk->points[start + i].p;
-
- sub_v3_v3v3(distance, p, stk->points[start].p);
- project_v3_v3v3(distance, distance, normal);
-
- copy_v3_v3(offset, normal);
- mul_v3_fl(offset, d);
-
- sub_v3_v3(p, distance);
- add_v3_v3(p, offset);
- }
-}
-
-void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk)
-{
- if (sketch->active_stroke == stk) {
- sketch->active_stroke = NULL;
- }
-
- BLI_remlink(&sketch->strokes, stk);
- sk_freeStroke(stk);
-}
-
-void sk_reverseStroke(SK_Stroke *stk)
-{
- SK_Point *old_points = stk->points;
- int i = 0;
-
- sk_allocStrokeBuffer(stk);
-
- for (i = 0; i < stk->nb_points; i++) {
- sk_copyPoint(stk->points + i, old_points + stk->nb_points - 1 - i);
- }
-
- MEM_freeN(old_points);
-}
-
-
-/* Ramer-Douglas-Peucker algorithm for line simplification */
-void sk_filterStroke(SK_Stroke *stk, int start, int end)
-{
- SK_Point *old_points = stk->points;
- int nb_points = stk->nb_points;
- char *marked = NULL;
- char work;
- int i;
-
- if (start == -1) {
- start = 0;
- end = stk->nb_points - 1;
- }
-
- sk_allocStrokeBuffer(stk);
- stk->nb_points = 0;
-
- /* adding points before range */
- for (i = 0; i < start; i++) {
- sk_appendStrokePoint(stk, old_points + i);
- }
-
- marked = MEM_callocN(nb_points, "marked array");
- marked[start] = 1;
- marked[end] = 1;
-
- work = 1;
-
- /* while still reducing */
- while (work) {
- int ls, le;
- work = 0;
-
- ls = start;
- le = start + 1;
-
- /* while not over interval */
- while (ls < end) {
- int max_i = 0;
- short v1[2];
- float max_dist = 16; /* more than 4 pixels */
-
- /* find the next marked point */
- while (marked[le] == 0) {
- le++;
- }
-
- /* perpendicular vector to ls-le */
- v1[1] = old_points[le].p2d[0] - old_points[ls].p2d[0];
- v1[0] = old_points[ls].p2d[1] - old_points[le].p2d[1];
-
-
- for (i = ls + 1; i < le; i++) {
- float mul;
- float dist;
- short v2[2];
-
- v2[0] = old_points[i].p2d[0] - old_points[ls].p2d[0];
- v2[1] = old_points[i].p2d[1] - old_points[ls].p2d[1];
-
- if (v2[0] == 0 && v2[1] == 0) {
- continue;
- }
-
- mul = (float)(v1[0] * v2[0] + v1[1] * v2[1]) / (float)(v2[0] * v2[0] + v2[1] * v2[1]);
-
- dist = mul * mul * (v2[0] * v2[0] + v2[1] * v2[1]);
-
- if (dist > max_dist) {
- max_dist = dist;
- max_i = i;
- }
- }
-
- if (max_i != 0) {
- work = 1;
- marked[max_i] = 1;
- }
-
- ls = le;
- le = ls + 1;
- }
- }
-
-
- /* adding points after range */
- for (i = start; i <= end; i++) {
- if (marked[i]) {
- sk_appendStrokePoint(stk, old_points + i);
- }
- }
-
- MEM_freeN(marked);
-
- /* adding points after range */
- for (i = end + 1; i < nb_points; i++) {
- sk_appendStrokePoint(stk, old_points + i);
- }
-
- MEM_freeN(old_points);
-
- sk_shrinkStrokeBuffer(stk);
-}
-
-
-void sk_filterLastContinuousStroke(SK_Stroke *stk)
-{
- int start, end;
-
- end = stk->nb_points - 1;
-
- for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) {
- /* nothing to do here*/
- }
-
- if (end - start > 1) {
- sk_filterStroke(stk, start, end);
- }
-}
-
-SK_Point *sk_lastStrokePoint(SK_Stroke *stk)
-{
- SK_Point *pt = NULL;
-
- if (stk->nb_points > 0) {
- pt = stk->points + (stk->nb_points - 1);
- }
-
- return pt;
-}
-
-void sk_endContinuousStroke(SK_Stroke *stk)
-{
- stk->points[stk->nb_points - 1].type = PT_EXACT;
-}
-
-void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk)
-{
- if (stk) {
- memcpy(&(sketch->next_point), &(stk->points[stk->nb_points - 1]), sizeof(SK_Point));
- }
-}
-
-int sk_stroke_filtermval(SK_DrawData *dd)
-{
- int retval = 0;
- if (ABS(dd->mval[0] - dd->previous_mval[0]) + ABS(dd->mval[1] - dd->previous_mval[1]) > U.gp_manhattendist) {
- retval = 1;
- }
-
- return retval;
-}
-
-void sk_initDrawData(SK_DrawData *dd, const int mval[2])
-{
- dd->mval[0] = mval[0];
- dd->mval[1] = mval[1];
- dd->previous_mval[0] = -1;
- dd->previous_mval[1] = -1;
- dd->type = PT_EXACT;
-}
-
-
-void sk_deleteSelectedStrokes(SK_Sketch *sketch)
-{
- SK_Stroke *stk, *next;
-
- for (stk = sketch->strokes.first; stk; stk = next) {
- next = stk->next;
-
- if (stk->selected == 1) {
- sk_removeStroke(sketch, stk);
- }
- }
-}
-
-void sk_selectAllSketch(SK_Sketch *sketch, int mode)
-{
- SK_Stroke *stk = NULL;
-
- if (mode == -1) {
- for (stk = sketch->strokes.first; stk; stk = stk->next) {
- stk->selected = 0;
- }
- }
- else if (mode == 0) {
- for (stk = sketch->strokes.first; stk; stk = stk->next) {
- stk->selected = 1;
- }
- }
- else if (mode == 1) {
- int selected = 1;
-
- for (stk = sketch->strokes.first; stk; stk = stk->next) {
- selected &= stk->selected;
- }
-
- selected ^= 1;
-
- for (stk = sketch->strokes.first; stk; stk = stk->next) {
- stk->selected = selected;
- }
- }
-}
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 9215d56eb30..f99bd773ebc 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -83,6 +83,7 @@
#include "BKE_texture.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "RE_shader_ext.h"
@@ -127,7 +128,7 @@ void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(s
void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity),
int *UNUSED(border_colli), float *UNUSED(burning_rate), float *UNUSED(flame_smoke), float *UNUSED(flame_smoke_color),
float *UNUSED(flame_vorticity), float *UNUSED(flame_ignition_temp), float *UNUSED(flame_max_temp)) {}
-struct DerivedMesh *smokeModifier_do(SmokeModifierData *UNUSED(smd), const struct EvaluationContext *UNUSED(eval_ctx), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) { return NULL; }
+struct DerivedMesh *smokeModifier_do(SmokeModifierData *UNUSED(smd), struct Depsgraph *UNUSED(depsgraph), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) { return NULL; }
float smoke_get_velocity_at(struct Object *UNUSED(ob), float UNUSED(position[3]), float UNUSED(velocity[3])) { return 0.0f; }
#endif /* WITH_SMOKE */
@@ -1107,8 +1108,9 @@ static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int hires_mult
/* initialize with first input if in range */
if (x >= em1.min[0] && x < em1.max[0] &&
- y >= em1.min[1] && y < em1.max[1] &&
- z >= em1.min[2] && z < em1.max[2]) {
+ y >= em1.min[1] && y < em1.max[1] &&
+ z >= em1.min[2] && z < em1.max[2])
+ {
int index_in = smoke_get_index(x - em1.min[0], em1.res[0], y - em1.min[1], em1.res[1], z - em1.min[2]);
/* values */
@@ -1120,8 +1122,9 @@ static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int hires_mult
/* apply second input if in range */
if (x >= em2->min[0] && x < em2->max[0] &&
- y >= em2->min[1] && y < em2->max[1] &&
- z >= em2->min[2] && z < em2->max[2]) {
+ y >= em2->min[1] && y < em2->max[1] &&
+ z >= em2->min[2] && z < em2->max[2])
+ {
int index_in = smoke_get_index(x - em2->min[0], em2->res[0], y - em2->min[1], em2->res[1], z - em2->min[2]);
/* values */
@@ -1151,8 +1154,9 @@ static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int hires_mult
/* initialize with first input if in range */
if (x >= em1.hmin[0] && x < em1.hmax[0] &&
- y >= em1.hmin[1] && y < em1.hmax[1] &&
- z >= em1.hmin[2] && z < em1.hmax[2]) {
+ y >= em1.hmin[1] && y < em1.hmax[1] &&
+ z >= em1.hmin[2] && z < em1.hmax[2])
+ {
int index_in = smoke_get_index(x - em1.hmin[0], em1.hres[0], y - em1.hmin[1], em1.hres[1], z - em1.hmin[2]);
/* values */
output->influence_high[index_out] = em1.influence_high[index_in];
@@ -1160,8 +1164,9 @@ static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int hires_mult
/* apply second input if in range */
if (x >= em2->hmin[0] && x < em2->hmax[0] &&
- y >= em2->hmin[1] && y < em2->hmax[1] &&
- z >= em2->hmin[2] && z < em2->hmax[2]) {
+ y >= em2->hmin[1] && y < em2->hmax[1] &&
+ z >= em2->hmin[2] && z < em2->hmax[2])
+ {
int index_in = smoke_get_index(x - em2->hmin[0], em2->hres[0], y - em2->hmin[1], em2->hres[1], z - em2->hmin[2]);
/* values */
@@ -2102,7 +2107,7 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value
}
}
-static void update_flowsfluids(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt)
+static void update_flowsfluids(struct Depsgraph *depsgraph, Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt)
{
Object **flowobjs = NULL;
EmissionMap *emaps = NULL;
@@ -2209,7 +2214,7 @@ static void update_flowsfluids(const struct EvaluationContext *eval_ctx, Scene *
else { /* MOD_SMOKE_FLOW_SOURCE_MESH */
/* update flow object frame */
BLI_mutex_lock(&object_update_lock);
- BKE_object_modifier_update_subframe(eval_ctx, scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke);
+ BKE_object_modifier_update_subframe(depsgraph, scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke);
BLI_mutex_unlock(&object_update_lock);
/* apply flow */
@@ -2521,12 +2526,12 @@ static void update_effectors_task_cb(
}
}
-static void update_effectors(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeDomainSettings *sds, float UNUSED(dt))
+static void update_effectors(struct Depsgraph *depsgraph, Scene *scene, Object *ob, SmokeDomainSettings *sds, float UNUSED(dt))
{
ListBase *effectors;
/* make sure smoke flow influence is 0.0f */
sds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f;
- effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, sds->effector_weights, true);
+ effectors = pdInitEffectors(depsgraph, scene, ob, NULL, sds->effector_weights, true);
if (effectors) {
// precalculate wind forces
@@ -2556,7 +2561,7 @@ static void update_effectors(const struct EvaluationContext *eval_ctx, Scene *sc
pdEndEffectors(&effectors);
}
-static void step(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
+static void step(struct Depsgraph *depsgraph, Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
{
SmokeDomainSettings *sds = smd->domain;
/* stability values copied from wturbulence.cpp */
@@ -2626,11 +2631,11 @@ static void step(const struct EvaluationContext *eval_ctx, Scene *scene, Object
for (substep = 0; substep < totalSubsteps; substep++)
{
// calc animated obstacle velocities
- update_flowsfluids(eval_ctx, scene, ob, sds, dtSubdiv);
+ update_flowsfluids(depsgraph, scene, ob, sds, dtSubdiv);
update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps);
if (sds->total_cells > 1) {
- update_effectors(eval_ctx, scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt
+ update_effectors(depsgraph, scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt
smoke_step(sds->fluid, gravity, dtSubdiv);
}
}
@@ -2724,7 +2729,7 @@ static DerivedMesh *createDomainGeometry(SmokeDomainSettings *sds, Object *ob)
}
static void smokeModifier_process(
- SmokeModifierData *smd, const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
+ SmokeModifierData *smd, struct Depsgraph *depsgraph, Scene *scene, Object *ob, DerivedMesh *dm)
{
if ((smd->type & MOD_SMOKE_TYPE_FLOW))
{
@@ -2845,11 +2850,11 @@ static void smokeModifier_process(
}
- step(eval_ctx, scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base);
+ step(depsgraph, scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base);
}
// create shadows before writing cache so they get stored
- smoke_calc_transparency(sds, eval_ctx->view_layer);
+ smoke_calc_transparency(sds, DEG_get_evaluated_view_layer(depsgraph));
if (sds->wt && sds->total_cells > 1) {
smoke_turbulence_step(sds->wt, sds->fluid);
@@ -2867,13 +2872,13 @@ static void smokeModifier_process(
}
struct DerivedMesh *smokeModifier_do(
- SmokeModifierData *smd, const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
+ SmokeModifierData *smd, struct Depsgraph *depsgraph, Scene *scene, Object *ob, DerivedMesh *dm)
{
/* lock so preview render does not read smoke data while it gets modified */
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE);
- smokeModifier_process(smd, eval_ctx, scene, ob, dm);
+ smokeModifier_process(smd, depsgraph, scene, ob, dm);
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
BLI_rw_mutex_unlock(smd->domain->fluid_mutex);
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 1fb95bd3115..0af400796a4 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -83,6 +83,7 @@ variables on the UI for now
#include "BKE_scene.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "PIL_time.h"
@@ -662,11 +663,13 @@ static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *count
notthis = bs->v2;
}
else {
- if (v0 == bs->v2) {
- bpo = sb->bpoint+bs->v1;
- notthis = bs->v1;
- }
- else {printf("oops we should not get here - add_2nd_order_springs");}
+ if (v0 == bs->v2) {
+ bpo = sb->bpoint+bs->v1;
+ notthis = bs->v1;
+ }
+ else {
+ printf("oops we should not get here - add_2nd_order_springs");
+ }
}
if (bpo) {/* so now we have a 2nd order humpdidump */
for (c=bpo->nofsprings;c>0;c--) {
@@ -1522,12 +1525,12 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
}
-static void scan_for_ext_spring_forces(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float timenow)
+static void scan_for_ext_spring_forces(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float timenow)
{
SoftBody *sb = ob->soft;
ListBase *do_effector = NULL;
- do_effector = pdInitEffectors(eval_ctx, scene, ob, NULL, sb->effector_weights, true);
+ do_effector = pdInitEffectors(depsgraph, scene, ob, NULL, sb->effector_weights, true);
_scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector);
pdEndEffectors(&do_effector);
}
@@ -1539,7 +1542,7 @@ static void *exec_scan_for_ext_spring_forces(void *data)
return NULL;
}
-static void sb_sfesf_threads_run(const struct EvaluationContext *eval_ctx, Scene *scene, struct Object *ob, float timenow, int totsprings, int *UNUSED(ptr_to_break_func(void)))
+static void sb_sfesf_threads_run(struct Depsgraph *depsgraph, Scene *scene, struct Object *ob, float timenow, int totsprings, int *UNUSED(ptr_to_break_func(void)))
{
ListBase *do_effector = NULL;
ListBase threads;
@@ -1547,7 +1550,7 @@ static void sb_sfesf_threads_run(const struct EvaluationContext *eval_ctx, Scene
int i, totthread, left, dec;
int lowsprings =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
- do_effector= pdInitEffectors(eval_ctx, scene, ob, NULL, ob->soft->effector_weights, true);
+ do_effector= pdInitEffectors(depsgraph, scene, ob, NULL, ob->soft->effector_weights, true);
/* figure the number of threads while preventing pretty pointless threading overhead */
totthread= BKE_scene_num_threads(scene);
@@ -1955,12 +1958,12 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
/* intitialize */
if (sb) {
- /* check conditions for various options */
- /* +++ could be done on object level to squeeze out the last bits of it */
- do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
- do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
- do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
- /* --- could be done on object level to squeeze out the last bits of it */
+ /* check conditions for various options */
+ /* +++ could be done on object level to squeeze out the last bits of it */
+ do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
+ do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
+ do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
+ /* --- could be done on object level to squeeze out the last bits of it */
}
else {
printf("Error expected a SB here\n");
@@ -2205,7 +2208,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t
MEM_freeN(sb_threads);
}
-static void softbody_calc_forcesEx(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float forcetime, float timenow)
+static void softbody_calc_forcesEx(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float forcetime, float timenow)
{
/* rule we never alter free variables :bp->vec bp->pos in here !
* this will ruin adaptive stepsize AKA heun! (BM)
@@ -2221,7 +2224,7 @@ static void softbody_calc_forcesEx(const struct EvaluationContext *eval_ctx, Sce
/* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */
/* check conditions for various options */
- do_deflector= query_external_colliders(eval_ctx->view_layer, sb->collision_group);
+ do_deflector= query_external_colliders(DEG_get_evaluated_view_layer(depsgraph), sb->collision_group);
/* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
@@ -2230,10 +2233,10 @@ static void softbody_calc_forcesEx(const struct EvaluationContext *eval_ctx, Sce
/* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
if (do_springcollision || do_aero)
- sb_sfesf_threads_run(eval_ctx, scene, ob, timenow, sb->totspring, NULL);
+ sb_sfesf_threads_run(depsgraph, scene, ob, timenow, sb->totspring, NULL);
/* after spring scan because it uses Effoctors too */
- do_effector= pdInitEffectors(eval_ctx, scene, ob, NULL, sb->effector_weights, true);
+ do_effector= pdInitEffectors(depsgraph, scene, ob, NULL, sb->effector_weights, true);
if (do_deflector) {
float defforce[3];
@@ -2250,11 +2253,11 @@ static void softbody_calc_forcesEx(const struct EvaluationContext *eval_ctx, Sce
}
-static void softbody_calc_forces(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float forcetime, float timenow)
+static void softbody_calc_forces(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float forcetime, float timenow)
{
/* redirection to the new threaded Version */
if (!(G.debug_value & 0x10)) { // 16
- softbody_calc_forcesEx(eval_ctx, scene, ob, forcetime, timenow);
+ softbody_calc_forcesEx(depsgraph, scene, ob, forcetime, timenow);
return;
}
else {
@@ -2285,7 +2288,7 @@ static void softbody_calc_forces(const struct EvaluationContext *eval_ctx, Scene
}
/* check conditions for various options */
- do_deflector= query_external_colliders(eval_ctx->view_layer, sb->collision_group);
+ do_deflector= query_external_colliders(DEG_get_evaluated_view_layer(depsgraph), sb->collision_group);
do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
@@ -2293,9 +2296,9 @@ static void softbody_calc_forces(const struct EvaluationContext *eval_ctx, Scene
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
/* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
- if (do_springcollision || do_aero) scan_for_ext_spring_forces(eval_ctx, scene, ob, timenow);
+ if (do_springcollision || do_aero) scan_for_ext_spring_forces(depsgraph, scene, ob, timenow);
/* after spring scan because it uses Effoctors too */
- do_effector= pdInitEffectors(eval_ctx, scene, ob, NULL, ob->soft->effector_weights, true);
+ do_effector= pdInitEffectors(depsgraph, scene, ob, NULL, ob->soft->effector_weights, true);
if (do_deflector) {
float defforce[3];
@@ -2755,7 +2758,7 @@ static void apply_spring_memory(Object *ob)
l = len_v3v3(bp1->pos, bp2->pos);
r = bs->len/l;
if (( r > 1.05f) || (r < 0.95f)) {
- bs->len = ((100.0f - b) * bs->len + b*l)/100.0f;
+ bs->len = ((100.0f - b) * bs->len + b*l)/100.0f;
}
}
}
@@ -2803,10 +2806,10 @@ static void springs_from_mesh(Object *ob)
sb= ob->soft;
if (me && sb) {
- /* using bp->origS as a container for spring calcualtions here
- * will be overwritten sbObjectStep() to receive
- * actual modifier stack positions
- */
+ /* using bp->origS as a container for spring calcualtions here
+ * will be overwritten sbObjectStep() to receive
+ * actual modifier stack positions
+ */
if (me->totvert) {
bp= ob->soft->bpoint;
for (a=0; a<me->totvert; a++, bp++) {
@@ -3469,20 +3472,20 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
SB_estimate_transform(ob, NULL, NULL, NULL);
}
switch (ob->type) {
- case OB_MESH:
- if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob);
- break;
- case OB_LATTICE:
- break;
- case OB_CURVE:
- case OB_SURF:
- break;
- default:
- break;
+ case OB_MESH:
+ if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob);
+ break;
+ case OB_LATTICE:
+ break;
+ case OB_CURVE:
+ case OB_SURF:
+ break;
+ default:
+ break;
}
}
-static void softbody_step(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SoftBody *sb, float dtime)
+static void softbody_step(struct Depsgraph *depsgraph, Scene *scene, Object *ob, SoftBody *sb, float dtime)
{
/* the simulator */
float forcetime;
@@ -3496,11 +3499,13 @@ static void softbody_step(const struct EvaluationContext *eval_ctx, Scene *scene
*/
if (dtime < 0 || dtime > 10.5f) return;
- ccd_update_deflector_hash(eval_ctx->view_layer, sb->collision_group, ob, sb->scratch->colliderhash);
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
+
+ ccd_update_deflector_hash(view_layer, sb->collision_group, ob, sb->scratch->colliderhash);
if (sb->scratch->needstobuildcollider) {
- if (query_external_colliders(eval_ctx->view_layer, sb->collision_group)) {
- ccd_build_deflector_hash(eval_ctx->view_layer, sb->collision_group, ob, sb->scratch->colliderhash);
+ if (query_external_colliders(view_layer, sb->collision_group)) {
+ ccd_build_deflector_hash(view_layer, sb->collision_group, ob, sb->scratch->colliderhash);
}
sb->scratch->needstobuildcollider=0;
}
@@ -3530,12 +3535,12 @@ static void softbody_step(const struct EvaluationContext *eval_ctx, Scene *scene
sb->scratch->flag &= ~SBF_DOFUZZY;
/* do predictive euler step */
- softbody_calc_forces(eval_ctx, scene, ob, forcetime, timedone/dtime);
+ softbody_calc_forces(depsgraph, scene, ob, forcetime, timedone/dtime);
softbody_apply_forces(ob, forcetime, 1, NULL, mid_flags);
/* crop new slope values to do averaged slope step */
- softbody_calc_forces(eval_ctx, scene, ob, forcetime, timedone/dtime);
+ softbody_calc_forces(depsgraph, scene, ob, forcetime, timedone/dtime);
softbody_apply_forces(ob, forcetime, 2, &err, mid_flags);
softbody_apply_goalsnap(ob);
@@ -3616,7 +3621,7 @@ static void softbody_step(const struct EvaluationContext *eval_ctx, Scene *scene
}
/* simulates one step. framenr is in frames */
-void sbObjectStep(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
+void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
{
SoftBody *sb= ob->soft;
PointCache *cache;
@@ -3697,7 +3702,8 @@ void sbObjectStep(const struct EvaluationContext *eval_ctx, Scene *scene, Object
cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, can_simulate);
if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED ||
- (!can_simulate && cache_result == PTCACHE_READ_OLD)) {
+ (!can_simulate && cache_result == PTCACHE_READ_OLD))
+ {
softbody_to_object(ob, vertexCos, numVerts, sb->local);
BKE_ptcache_validate(cache, framenr);
@@ -3731,7 +3737,7 @@ void sbObjectStep(const struct EvaluationContext *eval_ctx, Scene *scene, Object
dtime = framedelta*timescale;
/* do simulation */
- softbody_step(eval_ctx, scene, ob, sb, dtime);
+ softbody_step(depsgraph, scene, ob, sb, dtime);
softbody_to_object(ob, vertexCos, numVerts, 0);
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 9280341b4e4..ed23078a9d8 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -77,12 +77,6 @@
# include "BLI_array.h"
#endif
-#include "GPU_draw.h"
-#include "GPU_glew.h"
-#include "GPU_buffers.h"
-#include "GPU_shader.h"
-#include "GPU_basic_shader.h"
-
#include "CCGSubSurf.h"
#ifdef WITH_OPENSUBDIV
@@ -1775,47 +1769,7 @@ static void ccgDM_foreachMappedLoop(
}
}
-static void ccgDM_drawVerts(DerivedMesh *dm)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- int edgeSize = ccgSubSurf_getEdgeSize(ss);
- int gridSize = ccgSubSurf_getGridSize(ss);
- CCGVertIterator vi;
- CCGEdgeIterator ei;
- CCGFaceIterator fi;
-
- glBegin(GL_POINTS);
- for (ccgSubSurf_initVertIterator(ss, &vi); !ccgVertIterator_isStopped(&vi); ccgVertIterator_next(&vi)) {
- CCGVert *v = ccgVertIterator_getCurrent(&vi);
- glVertex3fv(ccgSubSurf_getVertData(ss, v));
- }
-
- for (ccgSubSurf_initEdgeIterator(ss, &ei); !ccgEdgeIterator_isStopped(&ei); ccgEdgeIterator_next(&ei)) {
- CCGEdge *e = ccgEdgeIterator_getCurrent(&ei);
- int x;
-
- for (x = 1; x < edgeSize - 1; x++)
- glVertex3fv(ccgSubSurf_getEdgeData(ss, e, x));
- }
-
- for (ccgSubSurf_initFaceIterator(ss, &fi); !ccgFaceIterator_isStopped(&fi); ccgFaceIterator_next(&fi)) {
- CCGFace *f = ccgFaceIterator_getCurrent(&fi);
- int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
-
- glVertex3fv(ccgSubSurf_getFaceCenterData(f));
- for (S = 0; S < numVerts; S++)
- for (x = 1; x < gridSize - 1; x++)
- glVertex3fv(ccgSubSurf_getFaceGridEdgeData(ss, f, S, x));
- for (S = 0; S < numVerts; S++)
- for (y = 1; y < gridSize - 1; y++)
- for (x = 1; x < gridSize - 1; x++)
- glVertex3fv(ccgSubSurf_getFaceGridData(ss, f, S, x, y));
- }
- glEnd();
-}
-
-static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
+static void UNUSED_FUNCTION(ccgdm_pbvh_update)(CCGDerivedMesh *ccgdm)
{
if (ccgdm->pbvh && ccgDM_use_grid_pbvh(ccgdm)) {
CCGFace **faces;
@@ -1830,1925 +1784,6 @@ static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
}
}
-static void ccgDM_drawEdges(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges)
-{
- GPUDrawObject *gdo;
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
-
-#ifdef WITH_OPENSUBDIV
- if (ccgdm->useGpuBackend) {
- /* TODO(sergey): We currently only support all edges drawing. */
- if (ccgSubSurf_prepareGLMesh(ccgdm->ss, true, -1)) {
- ccgSubSurf_drawGLMesh(ccgdm->ss, false, -1, -1);
- }
- return;
- }
-#endif
-
- ccgdm_pbvh_update(ccgdm);
-
-/* old debug feature for edges, unsupported for now */
-#if 0
- int useAging = 0;
-
- if (!(G.f & G_BACKBUFSEL)) {
- CCGSubSurf *ss = ccgdm->ss;
- ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL);
-
- /* it needs some way to upload this to VBO now */
- if (useAging) {
- int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4;
- glColor3ub(0, ageCol > 0 ? ageCol : 0, 0);
- }
- }
-#endif
-
- GPU_edge_setup(dm);
- gdo = dm->drawObject;
- if (gdo->edges && gdo->points) {
- if (drawAllEdges && drawLooseEdges) {
- GPU_buffer_draw_elements(gdo->edges, GL_LINES, 0, (gdo->totedge - gdo->totinterior) * 2);
- }
- else if (drawAllEdges) {
- GPU_buffer_draw_elements(gdo->edges, GL_LINES, 0, gdo->loose_edge_offset * 2);
- }
- else {
- GPU_buffer_draw_elements(gdo->edges, GL_LINES, 0, gdo->tot_edge_drawn * 2);
- GPU_buffer_draw_elements(gdo->edges, GL_LINES, gdo->loose_edge_offset * 2, gdo->tot_loose_edge_drawn * 2);
- }
- }
-
- if (gdo->edges && ccgdm->drawInteriorEdges) {
- GPU_buffer_draw_elements(gdo->edges, GL_LINES, gdo->interior_offset * 2, gdo->totinterior * 2);
- }
- GPU_buffers_unbind();
-}
-
-static void ccgDM_drawLooseEdges(DerivedMesh *dm)
-{
- int start;
- int count;
-
-#ifdef WITH_OPENSUBDIV
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- if (ccgdm->useGpuBackend) {
- /* TODO(sergey): Needs implementation. */
- return;
- }
-#endif
-
- GPU_edge_setup(dm);
-
- start = (dm->drawObject->loose_edge_offset * 2);
- count = (dm->drawObject->interior_offset - dm->drawObject->loose_edge_offset) * 2;
-
- if (count) {
- GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, start, count);
- }
-
- GPU_buffers_unbind();
-}
-
-static void ccgDM_NormalFast(float *a, float *b, float *c, float *d, float no[3])
-{
- float a_cX = c[0] - a[0], a_cY = c[1] - a[1], a_cZ = c[2] - a[2];
- float b_dX = d[0] - b[0], b_dY = d[1] - b[1], b_dZ = d[2] - b[2];
-
- no[0] = b_dY * a_cZ - b_dZ * a_cY;
- no[1] = b_dZ * a_cX - b_dX * a_cZ;
- no[2] = b_dX * a_cY - b_dY * a_cX;
-
- normalize_v3(no);
-}
-
-
-static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
-{
- float a_cX = c[0] - a[0], a_cY = c[1] - a[1], a_cZ = c[2] - a[2];
- float b_dX = d[0] - b[0], b_dY = d[1] - b[1], b_dZ = d[2] - b[2];
- float no[3];
-
- no[0] = b_dY * a_cZ - b_dZ * a_cY;
- no[1] = b_dZ * a_cX - b_dX * a_cZ;
- no[2] = b_dX * a_cY - b_dY * a_cX;
-
- normalize_v3(no); /* we no longer rely on GL_NORMALIZE */
-
- glNormal3fv(no);
-}
-
-/* Only used by non-editmesh types */
-static void ccgDM_buffer_copy_normal(
- DerivedMesh *dm, short *varray)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
- int gridSize = ccgSubSurf_getGridSize(ss);
- int gridFaces = gridSize - 1;
- DMFlagMat *faceFlags = ccgdm->faceFlags;
- int i, totface = ccgSubSurf_getNumFaces(ss);
- int shademodel;
- int start = 0;
-
- /* we are in sculpt mode, disable loop normals (since they won't get updated) */
- if (ccgdm->pbvh)
- lnors = NULL;
-
- CCG_key_top_level(&key, ss);
-
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
- int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- const float (*ln)[3] = NULL;
-
- if (faceFlags) {
- shademodel = (lnors || (faceFlags[index].flag & ME_SMOOTH)) ? GL_SMOOTH : GL_FLAT;
- }
- else {
- shademodel = GL_SMOOTH;
- }
-
- if (lnors) {
- ln = lnors;
- lnors += gridFaces * gridFaces * numVerts * 4;
- }
-
- for (S = 0; S < numVerts; S++) {
- CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
-
- if (ln) {
- /* Can't use quad strips here... */
- for (y = 0; y < gridFaces; y ++) {
- for (x = 0; x < gridFaces; x ++) {
- normal_float_to_short_v3(&varray[start + 0], ln[0]);
- normal_float_to_short_v3(&varray[start + 4], ln[3]);
- normal_float_to_short_v3(&varray[start + 8], ln[2]);
- normal_float_to_short_v3(&varray[start + 12], ln[1]);
-
- start += 16;
- ln += 4;
- }
- }
- }
- else if (shademodel == GL_SMOOTH) {
- for (y = 0; y < gridFaces; y ++) {
- for (x = 0; x < gridFaces; x ++) {
- float *a = CCG_grid_elem_no(&key, faceGridData, x, y );
- float *b = CCG_grid_elem_no(&key, faceGridData, x + 1, y);
- float *c = CCG_grid_elem_no(&key, faceGridData, x + 1, y + 1);
- float *d = CCG_grid_elem_no(&key, faceGridData, x, y + 1);
-
- normal_float_to_short_v3(&varray[start], a);
- normal_float_to_short_v3(&varray[start + 4], b);
- normal_float_to_short_v3(&varray[start + 8], c);
- normal_float_to_short_v3(&varray[start + 12], d);
-
- start += 16;
- }
- }
- }
- else {
- for (y = 0; y < gridFaces; y ++) {
- for (x = 0; x < gridFaces; x ++) {
- float f_no[3];
- short f_no_s[3];
-
- float *a = CCG_grid_elem_co(&key, faceGridData, x, y );
- float *b = CCG_grid_elem_co(&key, faceGridData, x + 1, y );
- float *c = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
- float *d = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
-
- ccgDM_NormalFast(a, b, c, d, f_no);
- normal_float_to_short_v3(f_no_s, f_no);
-
- copy_v3_v3_short(&varray[start], f_no_s);
- copy_v3_v3_short(&varray[start + 4], f_no_s);
- copy_v3_v3_short(&varray[start + 8], f_no_s);
- copy_v3_v3_short(&varray[start + 12], f_no_s);
-
- start += 16;
- }
- }
- }
- }
- }
-}
-
-typedef struct FaceCount {
- unsigned int i_visible;
- unsigned int i_hidden;
- unsigned int i_tri_visible;
- unsigned int i_tri_hidden;
-} FaceCount;
-
-
-/* Only used by non-editmesh types */
-static void ccgDM_buffer_copy_triangles(
- DerivedMesh *dm, unsigned int *varray,
- const int *mat_orig_to_new)
-{
- GPUBufferMaterial *gpumat, *gpumaterials = dm->drawObject->materials;
- const int gpu_totmat = dm->drawObject->totmaterial;
- const short dm_totmat = dm->totmat;
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- int gridSize = ccgSubSurf_getGridSize(ss);
- int gridFaces = gridSize - 1;
- DMFlagMat *faceFlags = ccgdm->faceFlags;
- int i, totface = ccgSubSurf_getNumFaces(ss);
- short mat_nr = -1;
- int start;
- int totloops = 0;
- FaceCount *fc = MEM_mallocN(sizeof(*fc) * gpu_totmat, "gpumaterial.facecount");
-
- CCG_key_top_level(&key, ss);
-
- for (i = 0; i < gpu_totmat; i++) {
- fc[i].i_visible = 0;
- fc[i].i_tri_visible = 0;
- fc[i].i_hidden = gpumaterials[i].totpolys - 1;
- fc[i].i_tri_hidden = gpumaterials[i].totelements - 1;
- }
-
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
- int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- bool is_hidden;
- int mati;
-
- if (faceFlags) {
- mat_nr = ME_MAT_NR_TEST(faceFlags[index].mat_nr, dm_totmat);
- is_hidden = (faceFlags[index].flag & ME_HIDE) != 0;
- }
- else {
- mat_nr = 0;
- is_hidden = false;
- }
- mati = mat_orig_to_new[mat_nr];
- gpumat = dm->drawObject->materials + mati;
-
- if (is_hidden) {
- for (S = 0; S < numVerts; S++) {
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- start = gpumat->start + fc[mati].i_tri_hidden;
-
- varray[start--] = totloops;
- varray[start--] = totloops + 2;
- varray[start--] = totloops + 3;
-
- varray[start--] = totloops;
- varray[start--] = totloops + 1;
- varray[start--] = totloops + 2;
-
- fc[mati].i_tri_hidden -= 6;
-
- totloops += 4;
- }
- }
- }
- gpumat->polys[fc[mati].i_hidden--] = i;
- }
- else {
- for (S = 0; S < numVerts; S++) {
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- start = gpumat->start + fc[mati].i_tri_visible;
-
- varray[start++] = totloops + 3;
- varray[start++] = totloops + 2;
- varray[start++] = totloops;
-
- varray[start++] = totloops + 2;
- varray[start++] = totloops + 1;
- varray[start++] = totloops;
-
- fc[mati].i_tri_visible += 6;
-
- totloops += 4;
- }
- }
- }
- gpumat->polys[fc[mati].i_visible++] = i;
- }
- }
-
- /* set the visible polygons */
- for (i = 0; i < gpu_totmat; i++) {
- gpumaterials[i].totvisiblepolys = fc[i].i_visible;
- }
-
- MEM_freeN(fc);
-}
-
-
-/* Only used by non-editmesh types */
-static void ccgDM_buffer_copy_vertex(
- DerivedMesh *dm, void *varray_p)
-{
- float *varray = varray_p;
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- int gridSize = ccgSubSurf_getGridSize(ss);
- int gridFaces = gridSize - 1;
- int i, totface = ccgSubSurf_getNumFaces(ss);
- int totedge = ccgSubSurf_getNumEdges(ss);
- int start = 0;
- int edgeSize = ccgSubSurf_getEdgeSize(ss);
-
- CCG_key_top_level(&key, ss);
-
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
-
- for (S = 0; S < numVerts; S++) {
- CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- float *a = CCG_grid_elem_co(&key, faceGridData, x, y);
- float *b = CCG_grid_elem_co(&key, faceGridData, x + 1, y);
- float *c = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
- float *d = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
-
- copy_v3_v3(&varray[start], a);
- copy_v3_v3(&varray[start + 3], b);
- copy_v3_v3(&varray[start + 6], c);
- copy_v3_v3(&varray[start + 9], d);
-
- start += 12;
- }
- }
- }
- }
-
- /* upload loose points */
- for (i = 0; i < totedge; i++) {
- CCGEdge *e = ccgdm->edgeMap[i].edge;
- CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
-
- if (!ccgSubSurf_getEdgeNumFaces(e)) {
- int j = 0;
- for (j = 0; j < edgeSize; j++) {
- copy_v3_v3(&varray[start], CCG_elem_offset_co(&key, edgeData, j));
- start += 3;
- }
- }
- }
-}
-
-/* Only used by non-editmesh types */
-static void ccgDM_buffer_copy_color(
- DerivedMesh *dm, unsigned char *varray,
- const void *user_data)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- const unsigned char *mloopcol = user_data;
- int gridSize = ccgSubSurf_getGridSize(ss);
- int gridFaces = gridSize - 1;
- int i, totface = ccgSubSurf_getNumFaces(ss);
- int start = 0;
- int iface = 0;
-
- CCG_key_top_level(&key, ss);
-
-
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
-
- for (S = 0; S < numVerts; S++) {
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- copy_v4_v4_uchar(&varray[start + 0], &mloopcol[iface * 16 + 0]);
- copy_v4_v4_uchar(&varray[start + 4], &mloopcol[iface * 16 + 12]);
- copy_v4_v4_uchar(&varray[start + 8], &mloopcol[iface * 16 + 8]);
- copy_v4_v4_uchar(&varray[start + 12], &mloopcol[iface * 16 + 4]);
-
- start += 16;
- iface++;
- }
- }
- }
- }
-}
-
-static void ccgDM_buffer_copy_uv(
- DerivedMesh *dm, void *varray_p)
-{
- float *varray = varray_p;
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- MLoopUV *mloopuv = DM_get_loop_data_layer(dm, CD_MLOOPUV);
- int gridSize = ccgSubSurf_getGridSize(ss);
- int gridFaces = gridSize - 1;
- int i, totface = ccgSubSurf_getNumFaces(ss);
- int start = 0;
-
- CCG_key_top_level(&key, ss);
-
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
-
- for (S = 0; S < numVerts; S++) {
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- copy_v2_v2(&varray[start + 0], mloopuv[0].uv);
- copy_v2_v2(&varray[start + 2], mloopuv[3].uv);
- copy_v2_v2(&varray[start + 4], mloopuv[2].uv);
- copy_v2_v2(&varray[start + 6], mloopuv[1].uv);
-
- mloopuv += 4;
- start += 8;
- }
- }
- }
- }
-}
-
-static void ccgDM_buffer_copy_uv_texpaint(
- DerivedMesh *dm, float *varray)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- int gridSize = ccgSubSurf_getGridSize(ss);
- int gridFaces = gridSize - 1;
- int i, totface = ccgSubSurf_getNumFaces(ss);
- int start = 0;
- DMFlagMat *faceFlags = ccgdm->faceFlags;
- int dm_totmat = dm->totmat;
- MLoopUV **mloopuv_base;
- MLoopUV *stencil_base;
- int stencil;
-
- CCG_key_top_level(&key, ss);
-
- /* should have been checked for before, reassert */
- BLI_assert(DM_get_loop_data_layer(dm, CD_MLOOPUV));
- mloopuv_base = MEM_mallocN(dm_totmat * sizeof(*mloopuv_base), "texslots");
-
- for (i = 0; i < dm_totmat; i++) {
- mloopuv_base[i] = DM_paint_uvlayer_active_get(dm, i);
- }
-
- stencil = CustomData_get_stencil_layer(&dm->loopData, CD_MLOOPUV);
- stencil_base = CustomData_get_layer_n(&dm->loopData, CD_MLOOPUV, stencil);
-
- start = 0;
-
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
- int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- int matnr;
-
- if (faceFlags) {
- matnr = faceFlags[index].mat_nr;
- }
- else {
- matnr = 0;
- }
-
- for (S = 0; S < numVerts; S++) {
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- /* divide by 4, gives us current loop-index */
- unsigned int i_ml = start / 4;
- copy_v2_v2(&varray[start + 0], mloopuv_base[matnr][i_ml + 0].uv);
- copy_v2_v2(&varray[start + 2], stencil_base[i_ml + 0].uv);
- copy_v2_v2(&varray[start + 4], mloopuv_base[matnr][i_ml + 3].uv);
- copy_v2_v2(&varray[start + 6], stencil_base[i_ml + 3].uv);
- copy_v2_v2(&varray[start + 8], mloopuv_base[matnr][i_ml + 2].uv);
- copy_v2_v2(&varray[start + 10], stencil_base[i_ml + 2].uv);
- copy_v2_v2(&varray[start + 12], mloopuv_base[matnr][i_ml + 1].uv);
- copy_v2_v2(&varray[start + 14], stencil_base[i_ml + 1].uv);
- start += 16;
- }
- }
- }
- }
-
- MEM_freeN(mloopuv_base);
-}
-
-static void ccgDM_buffer_copy_uvedge(
- DerivedMesh *dm, float *varray)
-{
- int i, totpoly;
- int start;
- const MLoopUV *mloopuv;
-#ifndef USE_LOOP_LAYOUT_FAST
- const MPoly *mpoly = dm->getPolyArray(dm);
-#endif
-
- if ((mloopuv = DM_get_loop_data_layer(dm, CD_MLOOPUV)) == NULL) {
- return;
- }
-
- totpoly = dm->getNumPolys(dm);
- start = 0;
-
-#ifndef USE_LOOP_LAYOUT_FAST
- for (i = 0; i < totpoly; i++, mpoly++) {
- for (j = 0; j < mpoly->totloop; j++) {
- copy_v2_v2(&varray[start], mloopuv[mpoly->loopstart + j].uv);
- copy_v2_v2(&varray[start + 2], mloopuv[mpoly->loopstart + (j + 1) % mpoly->totloop].uv);
- start += 4;
- }
- }
-#else
- for (i = 0; i < totpoly; i++) {
- copy_v2_v2(&varray[start + 0], mloopuv[(i * 4) + 0].uv);
- copy_v2_v2(&varray[start + 2], mloopuv[(i * 4) + 1].uv);
-
- copy_v2_v2(&varray[start + 4], mloopuv[(i * 4) + 1].uv);
- copy_v2_v2(&varray[start + 6], mloopuv[(i * 4) + 2].uv);
-
- copy_v2_v2(&varray[start + 8], mloopuv[(i * 4) + 2].uv);
- copy_v2_v2(&varray[start + 10], mloopuv[(i * 4) + 3].uv);
-
- copy_v2_v2(&varray[start + 12], mloopuv[(i * 4) + 3].uv);
- copy_v2_v2(&varray[start + 14], mloopuv[(i * 4) + 0].uv);
-
- start += 16;
- }
-#endif
-}
-
-static void ccgDM_buffer_copy_edge(
- DerivedMesh *dm, unsigned int *varray)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- /* getEdgeSuze returns num of verts, edges is one less */
- int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss) - 1;
- int totedge = ccgSubSurf_getNumEdges(ss);
- int grid_face_side = ccgSubSurf_getGridSize(ss) - 1;
- int totface = ccgSubSurf_getNumFaces(ss);
- unsigned int index_start;
- unsigned int tot_interior = 0;
- unsigned int grid_tot_face = grid_face_side * grid_face_side;
-
- unsigned int iloose, inorm, iloosehidden, inormhidden;
- unsigned int tot_loose_hidden = 0, tot_loose = 0;
- unsigned int tot_hidden = 0, tot = 0;
- unsigned int iloosevert;
- /* int tot_interior = 0; */
-
- /* first, handle hidden/loose existing edges, then interior edges */
- for (j = 0; j < totedge; j++) {
- CCGEdge *e = ccgdm->edgeMap[j].edge;
-
- if (ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW)) {
- if (!ccgSubSurf_getEdgeNumFaces(e)) tot_loose_hidden++;
- else tot_hidden++;
- }
- else {
- if (!ccgSubSurf_getEdgeNumFaces(e)) tot_loose++;
- else tot++;
- }
- }
-
- inorm = 0;
- inormhidden = tot * edgeSize;
- iloose = (tot + tot_hidden) * edgeSize;
- iloosehidden = (tot + tot_hidden + tot_loose) * edgeSize;
- iloosevert = dm->drawObject->tot_loop_verts;
-
- /* part one, handle all normal edges */
- for (j = 0; j < totedge; j++) {
- CCGFace *f;
- int fhandle = 0;
- int totvert = 0;
- unsigned int S = 0;
- CCGEdge *e = ccgdm->edgeMap[j].edge;
- bool isloose = !ccgSubSurf_getEdgeNumFaces(e);
-
- if (!isloose) {
- CCGVert *v1, *v2;
- CCGVert *ev1 = ccgSubSurf_getEdgeVert0(e);
- CCGVert *ev2 = ccgSubSurf_getEdgeVert1(e);
-
- f = ccgSubSurf_getEdgeFace(e, 0);
- fhandle = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- totvert = ccgSubSurf_getFaceNumVerts(f);
-
- /* find the index of vertices in the face */
- for (i = 0; i < totvert; i++) {
- v1 = ccgSubSurf_getFaceVert(f, i);
- v2 = ccgSubSurf_getFaceVert(f, (i + 1) % totvert);
-
- if ((ev1 == v1 && ev2 == v2) || (ev1 == v2 && ev2 == v1)) {
- S = i;
- break;
- }
- }
- }
-
- if (ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW)) {
- if (isloose) {
- for (i = 0; i < edgeSize; i++) {
- varray[iloosehidden * 2] = iloosevert;
- varray[iloosehidden * 2 + 1] = iloosevert + 1;
- iloosehidden++;
- iloosevert++;
- }
- /* we are through with this loose edge and moving to the next, so increase by one */
- iloosevert++;
- }
- else {
- index_start = ccgdm->faceMap[fhandle].startFace;
-
- for (i = 0; i < grid_face_side; i++) {
- varray[inormhidden * 2] = (index_start + S * grid_tot_face + i * grid_face_side + grid_face_side - 1) * 4 + 1;
- varray[inormhidden * 2 + 1] = (index_start + S * grid_tot_face + i * grid_face_side + grid_face_side - 1) * 4 + 2;
- varray[inormhidden * 2 + 2] = (index_start + ((S + 1) % totvert) * grid_tot_face + grid_face_side * (grid_face_side - 1) + i) * 4 + 2;
- varray[inormhidden * 2 + 3] = (index_start + ((S + 1) % totvert) * grid_tot_face + grid_face_side * (grid_face_side - 1) + i) * 4 + 3;
- inormhidden += 2;
- }
- }
- }
- else {
- if (isloose) {
- for (i = 0; i < edgeSize; i++) {
- varray[iloose * 2] = iloosevert;
- varray[iloose * 2 + 1] = iloosevert + 1;
- iloose++;
- iloosevert++;
- }
- /* we are through with this loose edge and moving to the next, so increase by one */
- iloosevert++;
- }
- else {
- index_start = ccgdm->faceMap[fhandle].startFace;
-
- for (i = 0; i < grid_face_side; i++) {
- varray[inorm * 2] = (index_start + S * grid_tot_face + i * grid_face_side + grid_face_side - 1) * 4 + 1;
- varray[inorm * 2 + 1] = (index_start + S * grid_tot_face + i * grid_face_side + grid_face_side - 1) * 4 + 2;
- varray[inorm * 2 + 2] = (index_start + ((S + 1) % totvert) * grid_tot_face + grid_face_side * (grid_face_side - 1) + i) * 4 + 2;
- varray[inorm * 2 + 3] = (index_start + ((S + 1) % totvert) * grid_tot_face + grid_face_side * (grid_face_side - 1) + i) * 4 + 3;
- inorm += 2;
- }
- }
- }
- }
-
- /* part two, handle interior edges */
- inorm = totedge * grid_face_side * 2;
-
- index_start = 0;
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- unsigned int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
-
- for (S = 0; S < numVerts; S++) {
- for (x = 1; x < grid_face_side; x++) {
- for (y = 0; y < grid_face_side; y++) {
- unsigned int tmp = (index_start + x * grid_face_side + y) * 4;
- varray[inorm * 2] = tmp;
- varray[inorm * 2 + 1] = tmp + 1;
- inorm++;
- }
- }
- for (x = 0; x < grid_face_side; x++) {
- for (y = 0; y < grid_face_side; y++) {
- unsigned int tmp = (index_start + x * grid_face_side + y) * 4;
- varray[inorm * 2] = tmp + 3;
- varray[inorm * 2 + 1] = tmp;
- inorm++;
- }
- }
-
- tot_interior += grid_face_side * (2 * grid_face_side - 1);
- index_start += grid_tot_face;
- }
- }
-
- dm->drawObject->tot_loose_edge_drawn = tot_loose * edgeSize;
- dm->drawObject->loose_edge_offset = (tot + tot_hidden) * edgeSize;
- dm->drawObject->tot_edge_drawn = tot * edgeSize;
-
- dm->drawObject->interior_offset = totedge * edgeSize;
- dm->drawObject->totinterior = tot_interior;
-}
-
-static void ccgDM_copy_gpu_data(
- DerivedMesh *dm, int type, void *varray_p,
- const int *mat_orig_to_new, const void *user_data)
-{
- /* 'varray_p' cast is redundant but include for self-documentation */
- switch (type) {
- case GPU_BUFFER_VERTEX:
- ccgDM_buffer_copy_vertex(dm, (float *)varray_p);
- break;
- case GPU_BUFFER_NORMAL:
- ccgDM_buffer_copy_normal(dm, (short *)varray_p);
- break;
- case GPU_BUFFER_UV:
- ccgDM_buffer_copy_uv(dm, (float *)varray_p);
- break;
- case GPU_BUFFER_UV_TEXPAINT:
- ccgDM_buffer_copy_uv_texpaint(dm, (float *)varray_p);
- break;
- case GPU_BUFFER_COLOR:
- ccgDM_buffer_copy_color(dm, (unsigned char *)varray_p, user_data);
- break;
- case GPU_BUFFER_UVEDGE:
- ccgDM_buffer_copy_uvedge(dm, (float *)varray_p);
- break;
- case GPU_BUFFER_EDGE:
- ccgDM_buffer_copy_edge(dm, (unsigned int *)varray_p);
- break;
- case GPU_BUFFER_TRIANGLES:
- ccgDM_buffer_copy_triangles(dm, (unsigned int *)varray_p, mat_orig_to_new);
- break;
- default:
- break;
- }
-}
-
-static GPUDrawObject *ccgDM_GPUObjectNew(DerivedMesh *dm)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- GPUDrawObject *gdo;
- DMFlagMat *faceFlags = ccgdm->faceFlags;
- int gridFaces = ccgSubSurf_getGridSize(ss) - 1;
- const short dm_totmat = (faceFlags) ? dm->totmat : 1;
- GPUBufferMaterial *matinfo;
- int i;
- unsigned int tot_internal_edges = 0;
- int edgeVerts = ccgSubSurf_getEdgeSize(ss);
- int edgeSize = edgeVerts - 1;
-
- int totedge = ccgSubSurf_getNumEdges(ss);
- int totface = ccgSubSurf_getNumFaces(ss);
-
- /* object contains at least one material (default included) so zero means uninitialized dm */
- BLI_assert(dm_totmat != 0);
-
- matinfo = MEM_callocN(sizeof(*matinfo) * dm_totmat, "GPU_drawobject_new.mat_orig_to_new");
-
- if (faceFlags) {
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- int numVerts = ccgSubSurf_getFaceNumVerts(f);
- int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- const short new_matnr = ME_MAT_NR_TEST(faceFlags[index].mat_nr, dm_totmat);
- matinfo[new_matnr].totelements += numVerts * gridFaces * gridFaces * 6;
- matinfo[new_matnr].totloops += numVerts * gridFaces * gridFaces * 4;
- matinfo[new_matnr].totpolys++;
- tot_internal_edges += numVerts * gridFaces * (2 * gridFaces - 1);
- }
- }
- else {
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- int numVerts = ccgSubSurf_getFaceNumVerts(f);
- matinfo[0].totelements += numVerts * gridFaces * gridFaces * 6;
- matinfo[0].totloops += numVerts * gridFaces * gridFaces * 4;
- matinfo[0].totpolys++;
- tot_internal_edges += numVerts * gridFaces * (2 * gridFaces - 1);
- }
- }
-
- /* create the GPUDrawObject */
- gdo = MEM_callocN(sizeof(GPUDrawObject), "GPUDrawObject");
- gdo->totvert = 0; /* used to count indices, doesn't really matter for ccgsubsurf */
- gdo->totedge = (totedge * edgeSize + tot_internal_edges);
-
- GPU_buffer_material_finalize(gdo, matinfo, dm_totmat);
-
- /* store total number of points used for triangles */
- gdo->tot_triangle_point = ccgSubSurf_getNumFinalFaces(ss) * 6;
- gdo->tot_loop_verts = ccgSubSurf_getNumFinalFaces(ss) * 4;
-
- /* finally, count loose points */
- for (i = 0; i < totedge; i++) {
- CCGEdge *e = ccgdm->edgeMap[i].edge;
-
- if (!ccgSubSurf_getEdgeNumFaces(e))
- gdo->tot_loose_point += edgeVerts;
- }
-
- return gdo;
-}
-
-/* Only used by non-editmesh types */
-static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], bool fast, DMSetMaterial setMaterial)
-{
- int a;
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
-
- ccgdm_pbvh_update(ccgdm);
-
- if (ccgdm->pbvh && ccgdm->multires.mmd) {
- if (BKE_pbvh_has_faces(ccgdm->pbvh)) {
- BKE_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL,
- setMaterial, false, fast);
- }
-
- return;
- }
-
-#ifdef WITH_OPENSUBDIV
- if (ccgdm->useGpuBackend) {
- CCGSubSurf *ss = ccgdm->ss;
- const DMFlagMat *faceFlags = ccgdm->faceFlags;
- const int level = ccgSubSurf_getSubdivisionLevels(ss);
- const int face_side = 1 << level;
- const int grid_side = 1 << (level - 1);
- const int face_patches = face_side * face_side;
- const int grid_patches = grid_side * grid_side;
- const int num_base_faces = ccgSubSurf_getNumGLMeshBaseFaces(ss);
- int i, current_patch = 0;
- int mat_nr = -1;
- bool draw_smooth = false;
- int start_draw_patch = -1, num_draw_patches = 0;
- if (UNLIKELY(ccgSubSurf_prepareGLMesh(ss, setMaterial != NULL, -1) == false)) {
- return;
- }
- if (setMaterial == NULL) {
- ccgSubSurf_drawGLMesh(ss,
- true,
- -1,
- -1);
- return;
- }
- for (i = 0; i < num_base_faces; ++i) {
- const int num_face_verts = ccgSubSurf_getNumGLMeshBaseFaceVerts(ss, i);
- const int num_patches = (num_face_verts == 4) ? face_patches
- : num_face_verts * grid_patches;
- int new_matnr;
- bool new_draw_smooth;
- if (faceFlags) {
- new_draw_smooth = (faceFlags[i].flag & ME_SMOOTH);
- new_matnr = (faceFlags[i].mat_nr + 1);
- }
- else {
- new_draw_smooth = true;
- new_matnr = 1;
- }
- if (new_draw_smooth != draw_smooth || new_matnr != mat_nr) {
- if (num_draw_patches != 0) {
- bool do_draw = setMaterial(mat_nr, NULL);
- if (do_draw) {
- glShadeModel(draw_smooth ? GL_SMOOTH : GL_FLAT);
- ccgSubSurf_drawGLMesh(ss,
- true,
- start_draw_patch,
- num_draw_patches);
- }
- }
- start_draw_patch = current_patch;
- num_draw_patches = num_patches;
- mat_nr = new_matnr;
- draw_smooth = new_draw_smooth;
- }
- else {
- num_draw_patches += num_patches;
- }
- current_patch += num_patches;
- }
- if (num_draw_patches != 0) {
- bool do_draw = setMaterial(mat_nr, NULL);
- if (do_draw) {
- glShadeModel(draw_smooth ? GL_SMOOTH : GL_FLAT);
- ccgSubSurf_drawGLMesh(ss,
- true,
- start_draw_patch,
- num_draw_patches);
- }
- }
- glShadeModel(GL_SMOOTH);
- return;
- }
-#endif
-
- GPU_vertex_setup(dm);
- GPU_normal_setup(dm);
- GPU_triangle_setup(dm);
- for (a = 0; a < dm->drawObject->totmaterial; a++) {
- if (!setMaterial || setMaterial(dm->drawObject->materials[a].mat_nr + 1, NULL)) {
- GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, dm->drawObject->materials[a].start,
- dm->drawObject->materials[a].totelements);
- }
- }
- GPU_buffers_unbind();
-}
-
-typedef struct {
- DMVertexAttribs attribs;
- int numdata;
-
- GPUAttrib datatypes[GPU_MAX_ATTRIB]; /* TODO, messing up when switching materials many times - [#21056]*/
-} GPUMaterialConv;
-
-/* Only used by non-editmesh types */
-static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
- DMSetMaterial setMaterial,
- DMSetDrawOptions setDrawOptions,
- void *userData)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- GPUVertexAttribs gattribs;
- int a, b;
- const DMFlagMat *faceFlags = ccgdm->faceFlags;
- unsigned char *varray;
- size_t max_element_size = 0;
- int tot_loops = 0;
- int totpoly = ccgSubSurf_getNumFaces(ss);
- int gridSize = ccgSubSurf_getGridSize(ss);
- int gridFaces = gridSize - 1;
- int edgeSize = ccgSubSurf_getEdgeSize(ss);
-
-#ifdef WITH_OPENSUBDIV
- if (ccgdm->useGpuBackend) {
- const int level = ccgSubSurf_getSubdivisionLevels(ss);
- const int face_side = 1 << level;
- const int grid_side = 1 << (level - 1);
- const int face_patches = face_side * face_side;
- const int grid_patches = grid_side * grid_side;
- const int num_base_faces = ccgSubSurf_getNumGLMeshBaseFaces(ss);
- int i, current_patch = 0;
- int mat_nr = -1;
- bool draw_smooth = false;
- int start_draw_patch = -1, num_draw_patches = 0;
- GPU_draw_update_fvar_offset(dm);
- if (UNLIKELY(ccgSubSurf_prepareGLMesh(ss, false, -1) == false)) {
- return;
- }
- for (i = 0; i < num_base_faces; ++i) {
- const int num_face_verts = ccgSubSurf_getNumGLMeshBaseFaceVerts(ss, i);
- const int num_patches = (num_face_verts == 4) ? face_patches
- : num_face_verts * grid_patches;
- int new_matnr;
- bool new_draw_smooth;
-
- if (faceFlags) {
- new_draw_smooth = (faceFlags[i].flag & ME_SMOOTH);
- new_matnr = (faceFlags[i].mat_nr + 1);
- }
- else {
- new_draw_smooth = true;
- new_matnr = 1;
- }
- if (new_draw_smooth != draw_smooth || new_matnr != mat_nr) {
- if (num_draw_patches != 0) {
- bool do_draw = setMaterial(mat_nr, &gattribs);
- if (do_draw) {
- glShadeModel(draw_smooth ? GL_SMOOTH : GL_FLAT);
- ccgSubSurf_drawGLMesh(ss,
- true,
- start_draw_patch,
- num_draw_patches);
- }
- }
- start_draw_patch = current_patch;
- num_draw_patches = num_patches;
- mat_nr = new_matnr;
- draw_smooth = new_draw_smooth;
- }
- else {
- num_draw_patches += num_patches;
- }
- current_patch += num_patches;
- }
- if (num_draw_patches != 0) {
- bool do_draw = setMaterial(mat_nr, &gattribs);
- if (do_draw) {
- glShadeModel(draw_smooth ? GL_SMOOTH : GL_FLAT);
- ccgSubSurf_drawGLMesh(ss,
- true,
- start_draw_patch,
- num_draw_patches);
- }
- }
- glShadeModel(GL_SMOOTH);
- return;
- }
-#endif
-
- CCG_key_top_level(&key, ss);
- ccgdm_pbvh_update(ccgdm);
-
- if (setDrawOptions != NULL) {
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
- DMVertexAttribs attribs = {{{NULL}}};
- int i;
- int matnr = -1;
- int do_draw = 0;
-
-#define PASSATTRIB(dx, dy, vert) { \
- if (attribs.totorco) \
- index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \
- else \
- index = 0; \
- DM_draw_attrib_vertex(&attribs, a, index, vert, ((a) * 4) + vert); \
- DM_draw_attrib_vertex_uniforms(&attribs); \
-} (void)0
-
- totpoly = ccgSubSurf_getNumFaces(ss);
- for (a = 0, i = 0; i < totpoly; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- const float (*ln)[3] = NULL;
- int S, x, y, drawSmooth;
- int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- int origIndex = ccgDM_getFaceMapIndex(ss, f);
-
- int numVerts = ccgSubSurf_getFaceNumVerts(f);
- int new_matnr;
-
- if (faceFlags) {
- drawSmooth = (lnors || (faceFlags[index].flag & ME_SMOOTH));
- new_matnr = faceFlags[index].mat_nr + 1;
- }
- else {
- drawSmooth = 1;
- new_matnr = 1;
- }
-
- if (lnors) {
- ln = lnors;
- lnors += (gridFaces * gridFaces * numVerts) * 4;
- }
-
- if (new_matnr != matnr) {
- do_draw = setMaterial(matnr = new_matnr, &gattribs);
- if (do_draw)
- DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
- }
-
- if (!do_draw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) &&
- (setDrawOptions(userData, origIndex) == DM_DRAW_OPTION_SKIP)))
- {
- a += gridFaces * gridFaces * numVerts;
- continue;
- }
-
- glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
- for (S = 0; S < numVerts; S++) {
- CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
- CCGElem *vda, *vdb;
-
- if (ln) {
- glBegin(GL_QUADS);
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- float *aco = CCG_grid_elem_co(&key, faceGridData, x, y);
- float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y);
- float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
- float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
-
- PASSATTRIB(0, 1, 1);
- glNormal3fv(ln[1]);
- glVertex3fv(dco);
- PASSATTRIB(1, 1, 2);
- glNormal3fv(ln[2]);
- glVertex3fv(cco);
- PASSATTRIB(1, 0, 3);
- glNormal3fv(ln[3]);
- glVertex3fv(bco);
- PASSATTRIB(0, 0, 0);
- glNormal3fv(ln[0]);
- glVertex3fv(aco);
-
- ln += 4;
- a++;
- }
- }
- glEnd();
- }
- else if (drawSmooth) {
- for (y = 0; y < gridFaces; y++) {
- glBegin(GL_QUAD_STRIP);
- for (x = 0; x < gridFaces; x++) {
- vda = CCG_grid_elem(&key, faceGridData, x, y + 0);
- vdb = CCG_grid_elem(&key, faceGridData, x, y + 1);
-
- PASSATTRIB(0, 0, 0);
- glNormal3fv(CCG_elem_no(&key, vda));
- glVertex3fv(CCG_elem_co(&key, vda));
-
- PASSATTRIB(0, 1, 1);
- glNormal3fv(CCG_elem_no(&key, vdb));
- glVertex3fv(CCG_elem_co(&key, vdb));
-
- if (x != gridFaces - 1)
- a++;
- }
-
- vda = CCG_grid_elem(&key, faceGridData, x, y + 0);
- vdb = CCG_grid_elem(&key, faceGridData, x, y + 1);
-
- PASSATTRIB(0, 0, 3);
- glNormal3fv(CCG_elem_no(&key, vda));
- glVertex3fv(CCG_elem_co(&key, vda));
-
- PASSATTRIB(0, 1, 2);
- glNormal3fv(CCG_elem_no(&key, vdb));
- glVertex3fv(CCG_elem_co(&key, vdb));
-
- glEnd();
-
- a++;
- }
- }
- else {
- glBegin(GL_QUADS);
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- float *aco = CCG_grid_elem_co(&key, faceGridData, x, y);
- float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y);
- float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
- float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
-
- ccgDM_glNormalFast(aco, bco, cco, dco);
-
- PASSATTRIB(0, 1, 1);
- glVertex3fv(dco);
- PASSATTRIB(1, 1, 2);
- glVertex3fv(cco);
- PASSATTRIB(1, 0, 3);
- glVertex3fv(bco);
- PASSATTRIB(0, 0, 0);
- glVertex3fv(aco);
-
- a++;
- }
- }
- glEnd();
- }
- }
- }
-
- glShadeModel(GL_SMOOTH);
-#undef PASSATTRIB
- }
- else {
- GPUMaterialConv *matconv;
- size_t offset;
- int *mat_orig_to_new;
- int tot_active_mat;
- GPUBuffer *buffer = NULL;
-
- GPU_vertex_setup(dm);
- GPU_normal_setup(dm);
- GPU_triangle_setup(dm);
-
- tot_active_mat = dm->drawObject->totmaterial;
-
- matconv = MEM_callocN(sizeof(*matconv) * tot_active_mat,
- "cdDM_drawMappedFacesGLSL.matconv");
- mat_orig_to_new = MEM_mallocN(sizeof(*mat_orig_to_new) * dm->totmat,
- "cdDM_drawMappedFacesGLSL.mat_orig_to_new");
-
- /* part one, check what attributes are needed per material */
- for (a = 0; a < tot_active_mat; a++) {
- int new_matnr;
- int do_draw;
-
- new_matnr = dm->drawObject->materials[a].mat_nr;
-
- /* map from original material index to new
- * GPUBufferMaterial index */
- mat_orig_to_new[new_matnr] = a;
- do_draw = setMaterial(new_matnr + 1, &gattribs);
-
- if (do_draw) {
- int numdata = 0;
- DM_vertex_attributes_from_gpu(dm, &gattribs, &matconv[a].attribs);
-
- if (matconv[a].attribs.totorco && matconv[a].attribs.orco.array) {
- matconv[a].datatypes[numdata].index = matconv[a].attribs.orco.gl_index;
- matconv[a].datatypes[numdata].info_index = matconv[a].attribs.orco.gl_info_index;
- matconv[a].datatypes[numdata].size = 3;
- matconv[a].datatypes[numdata].type = GL_FLOAT;
- numdata++;
- }
- for (b = 0; b < matconv[a].attribs.tottface; b++) {
- if (matconv[a].attribs.tface[b].array) {
- matconv[a].datatypes[numdata].index = matconv[a].attribs.tface[b].gl_index;
- matconv[a].datatypes[numdata].info_index = matconv[a].attribs.tface[b].gl_info_index;
- matconv[a].datatypes[numdata].size = 2;
- matconv[a].datatypes[numdata].type = GL_FLOAT;
- numdata++;
- }
- }
- for (b = 0; b < matconv[a].attribs.totmcol; b++) {
- if (matconv[a].attribs.mcol[b].array) {
- matconv[a].datatypes[numdata].index = matconv[a].attribs.mcol[b].gl_index;
- matconv[a].datatypes[numdata].info_index = matconv[a].attribs.mcol[b].gl_info_index;
- matconv[a].datatypes[numdata].size = 4;
- matconv[a].datatypes[numdata].type = GL_UNSIGNED_BYTE;
- numdata++;
- }
- }
- for (b = 0; b < matconv[a].attribs.tottang; b++) {
- if (matconv[a].attribs.tottang && matconv[a].attribs.tang[b].array) {
- matconv[a].datatypes[numdata].index = matconv[a].attribs.tang[b].gl_index;
- matconv[a].datatypes[numdata].info_index = matconv[a].attribs.tang[b].gl_info_index;
- matconv[a].datatypes[numdata].size = 4;
- matconv[a].datatypes[numdata].type = GL_FLOAT;
- numdata++;
- }
- }
- if (numdata != 0) {
- matconv[a].numdata = numdata;
- max_element_size = max_ii(GPU_attrib_element_size(matconv[a].datatypes, numdata), max_element_size);
- }
- }
- }
-
- /* part two, generate and fill the arrays with the data */
- if (max_element_size > 0) {
- buffer = GPU_buffer_alloc(max_element_size * dm->drawObject->tot_loop_verts);
-
- varray = GPU_buffer_lock_stream(buffer, GPU_BINDING_ARRAY);
- if (varray == NULL) {
- GPU_buffers_unbind();
- GPU_buffer_free(buffer);
- MEM_freeN(mat_orig_to_new);
- MEM_freeN(matconv);
- fprintf(stderr, "Out of memory, can't draw object\n");
- return;
- }
-
- for (a = 0; a < totpoly; a++) {
- CCGFace *f = ccgdm->faceMap[a].face;
- int orig_index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
- int i;
-
- if (faceFlags) {
- i = mat_orig_to_new[faceFlags[orig_index].mat_nr];
- }
- else {
- i = mat_orig_to_new[0];
- }
-
- if (matconv[i].numdata != 0) {
- for (S = 0; S < numVerts; S++) {
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
-
- offset = tot_loops * max_element_size;
-
- if (matconv[i].attribs.totorco && matconv[i].attribs.orco.array) {
- int index;
-
- index = getFaceIndex(ss, f, S, x, y, edgeSize, gridSize);
- copy_v3_v3((float *)&varray[offset],
- (float *)matconv[i].attribs.orco.array[index]);
- index = getFaceIndex(ss, f, S, x + 1, y, edgeSize, gridSize);
- copy_v3_v3((float *)&varray[offset + max_element_size],
- (float *)matconv[i].attribs.orco.array[index]);
- index = getFaceIndex(ss, f, S, x + 1, y + 1, edgeSize, gridSize);
- copy_v3_v3((float *)&varray[offset + 2 * max_element_size],
- (float *)matconv[i].attribs.orco.array[index]);
- index = getFaceIndex(ss, f, S, x, y + 1, edgeSize, gridSize);
- copy_v3_v3((float *)&varray[offset + 3 * max_element_size],
- (float *)matconv[i].attribs.orco.array[index]);
-
- offset += sizeof(float) * 3;
- }
- for (b = 0; b < matconv[i].attribs.tottface; b++) {
- if (matconv[i].attribs.tface[b].array) {
- const MLoopUV *mloopuv = matconv[i].attribs.tface[b].array + tot_loops;
-
- copy_v2_v2((float *)&varray[offset], mloopuv[0].uv);
- copy_v2_v2((float *)&varray[offset + max_element_size], mloopuv[3].uv);
- copy_v2_v2((float *)&varray[offset + 2 * max_element_size], mloopuv[2].uv);
- copy_v2_v2((float *)&varray[offset + 3 * max_element_size], mloopuv[1].uv);
-
- offset += sizeof(float) * 2;
- }
- }
- for (b = 0; b < matconv[i].attribs.totmcol; b++) {
- if (matconv[i].attribs.mcol[b].array) {
- const MLoopCol *mloopcol = matconv[i].attribs.mcol[b].array + tot_loops;
-
- copy_v4_v4_uchar(&varray[offset], &mloopcol[0].r);
- copy_v4_v4_uchar(&varray[offset + max_element_size], &mloopcol[3].r);
- copy_v4_v4_uchar(&varray[offset + 2 * max_element_size], &mloopcol[2].r);
- copy_v4_v4_uchar(&varray[offset + 3 * max_element_size], &mloopcol[1].r);
-
- offset += sizeof(unsigned char) * 4;
- }
- }
- for (b = 0; b < matconv[i].attribs.tottang; b++) {
- if (matconv[i].attribs.tottang && matconv[i].attribs.tang[b].array) {
- const float (*looptang)[4] = (const float (*)[4])matconv[i].attribs.tang[b].array + tot_loops;
-
- copy_v4_v4((float *)&varray[offset], looptang[0]);
- copy_v4_v4((float *)&varray[offset + max_element_size], looptang[3]);
- copy_v4_v4((float *)&varray[offset + 2 * max_element_size], looptang[2]);
- copy_v4_v4((float *)&varray[offset + 3 * max_element_size], looptang[1]);
-
- offset += sizeof(float) * 4;
- }
- }
-
- tot_loops += 4;
- }
- }
- }
- }
- else {
- tot_loops += 4 * numVerts * gridFaces * gridFaces;
- }
- }
- GPU_buffer_unlock(buffer, GPU_BINDING_ARRAY);
- }
-
- for (a = 0; a < tot_active_mat; a++) {
- int new_matnr;
- int do_draw;
-
- new_matnr = dm->drawObject->materials[a].mat_nr;
-
- do_draw = setMaterial(new_matnr + 1, &gattribs);
-
- if (do_draw) {
- if (matconv[a].numdata) {
- GPU_interleaved_attrib_setup(buffer, matconv[a].datatypes, matconv[a].numdata, max_element_size);
- }
- GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES,
- dm->drawObject->materials[a].start, dm->drawObject->materials[a].totelements);
- if (matconv[a].numdata) {
- GPU_interleaved_attrib_unbind();
- }
- }
- }
-
- GPU_buffers_unbind();
- if (buffer)
- GPU_buffer_free(buffer);
-
- MEM_freeN(mat_orig_to_new);
- MEM_freeN(matconv);
- }
-}
-
-static void ccgDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
-{
- dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
-}
-
-/* Only used by non-editmesh types */
-static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
- void (*setMaterial)(void *userData, int matnr, void *attribs),
- bool (*setFace)(void *userData, int index), void *userData)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- GPUVertexAttribs gattribs;
- DMVertexAttribs attribs = {{{NULL}}};
- int gridSize = ccgSubSurf_getGridSize(ss);
- int gridFaces = gridSize - 1;
- int edgeSize = ccgSubSurf_getEdgeSize(ss);
- DMFlagMat *faceFlags = ccgdm->faceFlags;
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
- int a, i, numVerts, matnr, totface;
-
-#ifdef WITH_OPENSUBDIV
- if (ccgdm->useGpuBackend) {
- const int level = ccgSubSurf_getSubdivisionLevels(ss);
- const int face_side = 1 << level;
- const int grid_side = 1 << (level - 1);
- const int face_patches = face_side * face_side;
- const int grid_patches = grid_side * grid_side;
- const int num_base_faces = ccgSubSurf_getNumGLMeshBaseFaces(ss);
- int current_patch = 0;
- int mat_nr = -1;
- bool draw_smooth = false;
- int start_draw_patch = -1, num_draw_patches = 0;
- GPU_draw_update_fvar_offset(dm);
- if (UNLIKELY(ccgSubSurf_prepareGLMesh(ss, true, -1) == false)) {
- return;
- }
- for (i = 0; i < num_base_faces; ++i) {
- const int num_face_verts = ccgSubSurf_getNumGLMeshBaseFaceVerts(ss, i);
- const int num_patches = (num_face_verts == 4) ? face_patches
- : num_face_verts * grid_patches;
- int new_matnr;
- bool new_draw_smooth;
-
- if (faceFlags) {
- new_draw_smooth = (faceFlags[i].flag & ME_SMOOTH);
- new_matnr = (faceFlags[i].mat_nr + 1);
- }
- else {
- new_draw_smooth = true;
- new_matnr = 1;
- }
- if (new_draw_smooth != draw_smooth || new_matnr != mat_nr) {
- if (num_draw_patches != 0) {
- setMaterial(userData, mat_nr, &gattribs);
- glShadeModel(draw_smooth ? GL_SMOOTH : GL_FLAT);
- ccgSubSurf_drawGLMesh(ss,
- true,
- start_draw_patch,
- num_draw_patches);
- }
- start_draw_patch = current_patch;
- num_draw_patches = num_patches;
- mat_nr = new_matnr;
- draw_smooth = new_draw_smooth;
- }
- else {
- num_draw_patches += num_patches;
- }
- current_patch += num_patches;
- }
- if (num_draw_patches != 0) {
- setMaterial(userData, mat_nr, &gattribs);
- glShadeModel(draw_smooth ? GL_SMOOTH : GL_FLAT);
- ccgSubSurf_drawGLMesh(ss,
- true,
- start_draw_patch,
- num_draw_patches);
- }
- glShadeModel(GL_SMOOTH);
- return;
- }
-#endif
-
- CCG_key_top_level(&key, ss);
- ccgdm_pbvh_update(ccgdm);
-
- matnr = -1;
-
-#define PASSATTRIB(dx, dy, vert) { \
- if (attribs.totorco) \
- index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \
- else \
- index = 0; \
- DM_draw_attrib_vertex(&attribs, a, index, vert, ((a) * 4) + vert); \
- DM_draw_attrib_vertex_uniforms(&attribs); \
-} (void)0
-
- totface = ccgSubSurf_getNumFaces(ss);
- for (a = 0, i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- const float (*ln)[3] = NULL;
- int S, x, y, drawSmooth;
- int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- int origIndex = ccgDM_getFaceMapIndex(ss, f);
- int new_matnr;
-
- numVerts = ccgSubSurf_getFaceNumVerts(f);
-
- /* get flags */
- if (faceFlags) {
- drawSmooth = (lnors || (faceFlags[index].flag & ME_SMOOTH));
- new_matnr = faceFlags[index].mat_nr + 1;
- }
- else {
- drawSmooth = 1;
- new_matnr = 1;
- }
-
- if (lnors) {
- ln = lnors;
- lnors += (gridFaces * gridFaces * numVerts) * 4;
- }
-
- /* material */
- if (new_matnr != matnr) {
- setMaterial(userData, matnr = new_matnr, &gattribs);
- DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
- }
-
- /* face hiding */
- if ((setFace && (origIndex != ORIGINDEX_NONE) && !setFace(userData, origIndex))) {
- a += gridFaces * gridFaces * numVerts;
- continue;
- }
-
- /* draw face*/
- glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
- for (S = 0; S < numVerts; S++) {
- CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
- CCGElem *vda, *vdb;
-
- if (ln) {
- glBegin(GL_QUADS);
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- float *aco = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
- float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0);
- float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
- float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
-
- PASSATTRIB(0, 1, 1);
- glNormal3fv(ln[1]);
- glVertex3fv(dco);
- PASSATTRIB(1, 1, 2);
- glNormal3fv(ln[2]);
- glVertex3fv(cco);
- PASSATTRIB(1, 0, 3);
- glNormal3fv(ln[3]);
- glVertex3fv(bco);
- PASSATTRIB(0, 0, 0);
- glNormal3fv(ln[0]);
- glVertex3fv(aco);
-
- ln += 4;
- a++;
- }
- }
- glEnd();
- }
- else if (drawSmooth) {
- for (y = 0; y < gridFaces; y++) {
- glBegin(GL_QUAD_STRIP);
- for (x = 0; x < gridFaces; x++) {
- vda = CCG_grid_elem(&key, faceGridData, x, y);
- vdb = CCG_grid_elem(&key, faceGridData, x, y + 1);
-
- PASSATTRIB(0, 0, 0);
- glNormal3fv(CCG_elem_no(&key, vda));
- glVertex3fv(CCG_elem_co(&key, vda));
-
- PASSATTRIB(0, 1, 1);
- glNormal3fv(CCG_elem_no(&key, vdb));
- glVertex3fv(CCG_elem_co(&key, vdb));
-
- if (x != gridFaces - 1)
- a++;
- }
-
- vda = CCG_grid_elem(&key, faceGridData, x, y + 0);
- vdb = CCG_grid_elem(&key, faceGridData, x, y + 1);
-
- PASSATTRIB(0, 0, 3);
- glNormal3fv(CCG_elem_no(&key, vda));
- glVertex3fv(CCG_elem_co(&key, vda));
-
- PASSATTRIB(0, 1, 2);
- glNormal3fv(CCG_elem_no(&key, vdb));
- glVertex3fv(CCG_elem_co(&key, vdb));
-
- glEnd();
-
- a++;
- }
- }
- else {
- glBegin(GL_QUADS);
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- float *aco = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
- float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0);
- float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
- float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
-
- ccgDM_glNormalFast(aco, bco, cco, dco);
-
- PASSATTRIB(0, 1, 1);
- glVertex3fv(dco);
- PASSATTRIB(1, 1, 2);
- glVertex3fv(cco);
- PASSATTRIB(1, 0, 3);
- glVertex3fv(bco);
- PASSATTRIB(0, 0, 0);
- glVertex3fv(aco);
-
- a++;
- }
- }
- glEnd();
- }
- }
- }
-
- glShadeModel(GL_SMOOTH);
-#undef PASSATTRIB
-}
-
-static void ccgDM_drawMappedFaces(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMSetMaterial setMaterial,
- DMCompareDrawOptions compareDrawOptions,
- void *userData, DMDrawFlag flag)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- MLoopCol *mloopcol = NULL;
- const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
- int i, gridSize = ccgSubSurf_getGridSize(ss);
- DMFlagMat *faceFlags = ccgdm->faceFlags;
- int useColors = flag & DM_DRAW_USE_COLORS;
- int gridFaces = gridSize - 1, totface;
- int prev_mat_nr = -1;
-
- if (ccgdm->pbvh) {
- if (G.debug_value == 14)
- BKE_pbvh_draw_BB(ccgdm->pbvh);
- }
-
-#ifdef WITH_OPENSUBDIV
- if (ccgdm->useGpuBackend) {
- int new_matnr;
- bool draw_smooth, do_draw = true;
- if (setDrawOptions == NULL) {
- /* TODO(sergey): This is for cases when vertex colors or weights
- * are visualising. Currently we don't have CD layers for this data
- * and here we only make it so there's no garbage displayed.
- *
- * In the future we'll either need to have CD for this data or pass
- * this data as face-varying or vertex-varying data in OSD mesh.
- */
- glColor3f(0.8f, 0.8f, 0.8f);
- }
- if (UNLIKELY(ccgSubSurf_prepareGLMesh(ss, true, -1) == false)) {
- return;
- }
- if (faceFlags) {
- draw_smooth = (faceFlags[0].flag & ME_SMOOTH);
- new_matnr = (faceFlags[0].mat_nr + 1);
- }
- else {
- draw_smooth = true;
- new_matnr = 1;
- }
- if (setMaterial) {
- setMaterial(new_matnr, NULL);
- }
- if (setDrawOptions) {
- if (setDrawOptions(userData, 0) == DM_DRAW_OPTION_SKIP) {
- do_draw = false;
- }
- }
- if (do_draw) {
- glShadeModel(draw_smooth ? GL_SMOOTH : GL_FLAT);
- ccgSubSurf_drawGLMesh(ss, true, -1, -1);
- glShadeModel(GL_SMOOTH);
- }
- return;
- }
-#endif
-
- CCG_key_top_level(&key, ss);
-
- /* currently unused -- each original face is handled separately */
- (void)compareDrawOptions;
-
- if (useColors) {
- mloopcol = dm->getLoopDataArray(dm, CD_PREVIEW_MLOOPCOL);
- if (!mloopcol)
- mloopcol = dm->getLoopDataArray(dm, CD_MLOOPCOL);
- }
-
- totface = ccgSubSurf_getNumFaces(ss);
- for (i = 0; i < totface; i++) {
- CCGFace *f = ccgdm->faceMap[i].face;
- int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
- int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
- int origIndex;
- unsigned char *cp = NULL;
- const float (*ln)[3] = NULL;
-
- origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
-
- if (flag & DM_DRAW_ALWAYS_SMOOTH) drawSmooth = 1;
- else if (faceFlags) drawSmooth = (lnors || (faceFlags[origIndex].flag & ME_SMOOTH));
- else drawSmooth = 1;
-
- if (mloopcol) {
- cp = (unsigned char *)mloopcol;
- mloopcol += gridFaces * gridFaces * numVerts * 4;
- }
-
- if (lnors) {
- ln = lnors;
- lnors += (gridFaces * gridFaces * numVerts) * 4;
- }
-
- {
- DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
-
- if (setMaterial) {
- int mat_nr = faceFlags ? faceFlags[origIndex].mat_nr + 1 : 1;
-
- if (mat_nr != prev_mat_nr) {
- setMaterial(mat_nr, NULL); /* XXX, no faceFlags no material */
- prev_mat_nr = mat_nr;
- }
- }
-
- if (setDrawOptions && (index != ORIGINDEX_NONE))
- draw_option = setDrawOptions(userData, index);
-
- if (draw_option != DM_DRAW_OPTION_SKIP) {
- if (draw_option == DM_DRAW_OPTION_STIPPLE) {
- GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR);
- GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE);
- }
-
- for (S = 0; S < numVerts; S++) {
- CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
- if (ln) {
- glBegin(GL_QUADS);
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- float *a = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
- float *b = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0);
- float *c = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
- float *d = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
-
- if (cp) glColor4ubv(&cp[4]);
- glNormal3fv(ln[1]);
- glVertex3fv(d);
- if (cp) glColor4ubv(&cp[8]);
- glNormal3fv(ln[2]);
- glVertex3fv(c);
- if (cp) glColor4ubv(&cp[12]);
- glNormal3fv(ln[3]);
- glVertex3fv(b);
- if (cp) glColor4ubv(&cp[0]);
- glNormal3fv(ln[0]);
- glVertex3fv(a);
-
- if (cp) cp += 16;
- ln += 4;
- }
- }
- glEnd();
- }
- else if (drawSmooth) {
- for (y = 0; y < gridFaces; y++) {
- CCGElem *a, *b;
- glBegin(GL_QUAD_STRIP);
- for (x = 0; x < gridFaces; x++) {
- a = CCG_grid_elem(&key, faceGridData, x, y + 0);
- b = CCG_grid_elem(&key, faceGridData, x, y + 1);
-
- if (cp) glColor4ubv(&cp[0]);
- glNormal3fv(CCG_elem_no(&key, a));
- glVertex3fv(CCG_elem_co(&key, a));
- if (cp) glColor4ubv(&cp[4]);
- glNormal3fv(CCG_elem_no(&key, b));
- glVertex3fv(CCG_elem_co(&key, b));
-
- if (x != gridFaces - 1) {
- if (cp) cp += 16;
- }
- }
-
- a = CCG_grid_elem(&key, faceGridData, x, y + 0);
- b = CCG_grid_elem(&key, faceGridData, x, y + 1);
-
- if (cp) glColor4ubv(&cp[12]);
- glNormal3fv(CCG_elem_no(&key, a));
- glVertex3fv(CCG_elem_co(&key, a));
- if (cp) glColor4ubv(&cp[8]);
- glNormal3fv(CCG_elem_no(&key, b));
- glVertex3fv(CCG_elem_co(&key, b));
-
- if (cp) cp += 16;
-
- glEnd();
- }
- }
- else {
- glBegin(GL_QUADS);
- for (y = 0; y < gridFaces; y++) {
- for (x = 0; x < gridFaces; x++) {
- float *a = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
- float *b = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0);
- float *c = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
- float *d = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
-
- ccgDM_glNormalFast(a, b, c, d);
-
- if (cp) glColor4ubv(&cp[4]);
- glVertex3fv(d);
- if (cp) glColor4ubv(&cp[8]);
- glVertex3fv(c);
- if (cp) glColor4ubv(&cp[12]);
- glVertex3fv(b);
- if (cp) glColor4ubv(&cp[0]);
- glVertex3fv(a);
-
- if (cp) cp += 16;
- }
- }
- glEnd();
- }
- }
- if (draw_option == DM_DRAW_OPTION_STIPPLE)
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- }
- }
- }
-}
-
-static void ccgDM_drawMappedEdges(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- void *userData)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGEdgeIterator ei;
- CCGKey key;
- int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss);
-
-#ifdef WITH_OPENSUBDIV
- if (ccgdm->useGpuBackend) {
- /* TODO(sergey): Only draw edges from base mesh. */
- if (ccgSubSurf_prepareGLMesh(ccgdm->ss, true, -1)) {
- if (!setDrawOptions || (setDrawOptions(userData, 0) != DM_DRAW_OPTION_SKIP)) {
- ccgSubSurf_drawGLMesh(ccgdm->ss, false, -1, -1);
- }
- }
- return;
- }
-#endif
-
- CCG_key_top_level(&key, ss);
- ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL);
-
- for (ccgSubSurf_initEdgeIterator(ss, &ei); !ccgEdgeIterator_isStopped(&ei); ccgEdgeIterator_next(&ei)) {
- CCGEdge *e = ccgEdgeIterator_getCurrent(&ei);
- CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
- int index = ccgDM_getEdgeMapIndex(ss, e);
-
- glBegin(GL_LINE_STRIP);
- if (index != -1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
- if (useAging && !(G.f & G_BACKBUFSEL)) {
- int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4;
- glColor3ub(0, ageCol > 0 ? ageCol : 0, 0);
- }
-
- for (i = 0; i < edgeSize - 1; i++) {
- glVertex3fv(CCG_elem_offset_co(&key, edgeData, i));
- glVertex3fv(CCG_elem_offset_co(&key, edgeData, i + 1));
- }
- }
- glEnd();
- }
-}
-
-static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm,
- DMSetDrawOptions setDrawOptions,
- DMSetDrawInterpOptions setDrawInterpOptions,
- void *userData)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGKey key;
- CCGEdgeIterator ei;
- int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss);
-
-#ifdef WITH_OPENSUBDIV
- if (ccgdm->useGpuBackend) {
- BLI_assert(!"Not currently supported");
- return;
- }
-#endif
-
- CCG_key_top_level(&key, ss);
- ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL);
-
- for (ccgSubSurf_initEdgeIterator(ss, &ei); !ccgEdgeIterator_isStopped(&ei); ccgEdgeIterator_next(&ei)) {
- CCGEdge *e = ccgEdgeIterator_getCurrent(&ei);
- CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
- int index = ccgDM_getEdgeMapIndex(ss, e);
-
- glBegin(GL_LINE_STRIP);
- if (index != -1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) {
- for (i = 0; i < edgeSize; i++) {
- setDrawInterpOptions(userData, index, (float) i / (edgeSize - 1));
-
- if (useAging && !(G.f & G_BACKBUFSEL)) {
- int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4;
- glColor3ub(0, ageCol > 0 ? ageCol : 0, 0);
- }
-
- glVertex3fv(CCG_elem_offset_co(&key, edgeData, i));
- }
- }
- glEnd();
- }
-}
-
static void ccgDM_foreachMappedFaceCenter(
DerivedMesh *dm,
void (*func)(void *userData, int index, const float co[3], const float no[3]),
@@ -4433,20 +2468,6 @@ static void set_default_ccgdm_callbacks(CCGDerivedMesh *ccgdm)
ccgdm->dm.foreachMappedLoop = ccgDM_foreachMappedLoop;
ccgdm->dm.foreachMappedFaceCenter = ccgDM_foreachMappedFaceCenter;
- ccgdm->dm.drawVerts = ccgDM_drawVerts;
- ccgdm->dm.drawEdges = ccgDM_drawEdges;
- ccgdm->dm.drawLooseEdges = ccgDM_drawLooseEdges;
- ccgdm->dm.drawFacesSolid = ccgDM_drawFacesSolid;
- ccgdm->dm.drawFacesGLSL = ccgDM_drawFacesGLSL;
- ccgdm->dm.drawMappedFaces = ccgDM_drawMappedFaces;
- ccgdm->dm.drawMappedFacesGLSL = ccgDM_drawMappedFacesGLSL;
- ccgdm->dm.drawMappedFacesMat = ccgDM_drawMappedFacesMat;
-
- ccgdm->dm.drawMappedEdgesInterp = ccgDM_drawMappedEdgesInterp;
- ccgdm->dm.drawMappedEdges = ccgDM_drawMappedEdges;
- ccgdm->dm.gpuObjectNew = ccgDM_GPUObjectNew;
- ccgdm->dm.copy_gpu_data = ccgDM_copy_gpu_data;
-
ccgdm->dm.release = ccgDM_release;
}
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index cd9b8ae339d..3892b2f0546 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -47,8 +47,6 @@
#include "BLI_fileops.h"
#include "DNA_constraint_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
@@ -174,18 +172,12 @@ static void txt_make_dirty(Text *text);
/***/
-static unsigned char undoing;
-
-/* allow to switch off undoing externally */
-void txt_set_undostate(int u)
-{
- undoing = u;
-}
-
-int txt_get_undostate(void)
-{
- return undoing;
-}
+/**
+ * Set to true when undoing (so we don't generate undo steps while undoing).
+ *
+ * Also use to disable undo entirely.
+ */
+static bool undoing;
/**
* \note caller must handle `undo_buf` and `compiled` members.
@@ -525,29 +517,26 @@ void BKE_text_make_local(Main *bmain, Text *text, const bool lib_local)
void BKE_text_clear(Text *text, TextUndoBuf *utxt) /* called directly from rna */
{
- int oldstate;
-
- if (utxt) {
- oldstate = txt_get_undostate();
- }
- txt_set_undostate(utxt != NULL);
+ const bool undoing_orig = undoing;
+ undoing = (utxt == NULL);
txt_sel_all(text);
txt_delete_sel(text, utxt);
- txt_set_undostate(oldstate);
+ undoing = undoing_orig;
txt_make_dirty(text);
}
void BKE_text_write(Text *text, TextUndoBuf *utxt, const char *str) /* called directly from rna */
{
- int oldstate;
+ const bool undoing_orig = undoing;
+ undoing = (utxt == NULL);
- oldstate = txt_get_undostate();
txt_insert_buf(text, utxt, str);
txt_move_eof(text, 0);
- txt_set_undostate(oldstate);
+
+ undoing = undoing_orig;
txt_make_dirty(text);
}
@@ -1395,7 +1384,8 @@ char *txt_sel_to_buf(Text *text)
void txt_insert_buf(Text *text, TextUndoBuf *utxt, const char *in_buffer)
{
- int l = 0, u, len;
+ const bool undoing_orig = undoing;
+ int l = 0, len;
size_t i = 0, j;
TextLine *add;
char *buffer;
@@ -1408,41 +1398,44 @@ void txt_insert_buf(Text *text, TextUndoBuf *utxt, const char *in_buffer)
buffer = BLI_strdupn(in_buffer, len);
len += txt_extended_ascii_as_utf8(&buffer);
- if (!undoing) txt_undo_add_blockop(text, utxt, UNDO_IBLOCK, buffer);
-
- u = undoing;
- undoing = 1;
+ if (!undoing) {
+ txt_undo_add_blockop(text, utxt, UNDO_IBLOCK, buffer);
+ }
+ undoing = true;
/* Read the first line (or as close as possible */
- while (buffer[i] && buffer[i] != '\n')
+ while (buffer[i] && buffer[i] != '\n') {
txt_add_raw_char(text, utxt, BLI_str_utf8_as_unicode_step(buffer, &i));
+ }
- if (buffer[i] == '\n') txt_split_curline(text, utxt);
- else { undoing = u; MEM_freeN(buffer); return; }
- i++;
+ if (buffer[i] == '\n') {
+ txt_split_curline(text, utxt);
+ i++;
- while (i < len) {
- l = 0;
+ while (i < len) {
+ l = 0;
- while (buffer[i] && buffer[i] != '\n') {
- i++; l++;
- }
-
- if (buffer[i] == '\n') {
- add = txt_new_linen(buffer + (i - l), l);
- BLI_insertlinkbefore(&text->lines, text->curl, add);
- i++;
- }
- else {
- for (j = i - l; j < i && j < len; )
- txt_add_raw_char(text, utxt, BLI_str_utf8_as_unicode_step(buffer, &j));
- break;
+ while (buffer[i] && buffer[i] != '\n') {
+ i++;
+ l++;
+ }
+
+ if (buffer[i] == '\n') {
+ add = txt_new_linen(buffer + (i - l), l);
+ BLI_insertlinkbefore(&text->lines, text->curl, add);
+ i++;
+ }
+ else {
+ for (j = i - l; j < i && j < len; ) {
+ txt_add_raw_char(text, utxt, BLI_str_utf8_as_unicode_step(buffer, &j));
+ }
+ break;
+ }
}
}
-
- MEM_freeN(buffer);
- undoing = u;
+ MEM_freeN(buffer);
+ undoing = undoing_orig;
}
/******************/
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 250408642bb..2bf2fa7807b 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -44,9 +44,7 @@
#include "DNA_key_types.h"
#include "DNA_object_types.h"
-#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
-#include "DNA_world_types.h"
#include "DNA_brush_types.h"
#include "DNA_node_types.h"
#include "DNA_color_types.h"
@@ -213,22 +211,6 @@ void BKE_texture_free(Tex *tex)
}
MEM_SAFE_FREE(tex->coba);
- if (tex->env) {
- BKE_texture_envmap_free(tex->env);
- tex->env = NULL;
- }
- if (tex->pd) {
- BKE_texture_pointdensity_free(tex->pd);
- tex->pd = NULL;
- }
- if (tex->vd) {
- BKE_texture_voxeldata_free(tex->vd);
- tex->vd = NULL;
- }
- if (tex->ot) {
- BKE_texture_ocean_free(tex->ot);
- tex->ot = NULL;
- }
BKE_icon_id_delete((ID *)tex);
BKE_previewimg_free(&tex->preview);
@@ -285,30 +267,6 @@ void BKE_texture_default(Tex *tex)
tex->vn_distm = 0;
tex->vn_coltype = 0;
- if (tex->env) {
- tex->env->stype = ENV_ANIM;
- tex->env->clipsta = 0.1;
- tex->env->clipend = 100;
- tex->env->cuberes = 512;
- tex->env->depth = 0;
- }
-
- if (tex->pd) {
- tex->pd->radius = 0.3f;
- tex->pd->falloff_type = TEX_PD_FALLOFF_STD;
- }
-
- if (tex->vd) {
- tex->vd->resol[0] = tex->vd->resol[1] = tex->vd->resol[2] = 0;
- tex->vd->interp_type = TEX_VD_LINEAR;
- tex->vd->file_format = TEX_VD_SMOKE;
- }
-
- if (tex->ot) {
- tex->ot->output = TEX_OCN_DISPLACEMENT;
- tex->ot->object = NULL;
- }
-
tex->iuser.fie_ima = 2;
tex->iuser.ok = 1;
tex->iuser.frames = 100;
@@ -319,26 +277,6 @@ void BKE_texture_default(Tex *tex)
void BKE_texture_type_set(Tex *tex, int type)
{
- switch (type) {
-
- case TEX_VOXELDATA:
- if (tex->vd == NULL)
- tex->vd = BKE_texture_voxeldata_add();
- break;
- case TEX_POINTDENSITY:
- if (tex->pd == NULL)
- tex->pd = BKE_texture_pointdensity_add();
- break;
- case TEX_ENVMAP:
- if (tex->env == NULL)
- tex->env = BKE_texture_envmap_add();
- break;
- case TEX_OCEAN:
- if (tex->ot == NULL)
- tex->ot = BKE_texture_ocean_add();
- break;
- }
-
tex->type = type;
}
@@ -476,10 +414,6 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot)
MEM_freeN(mtex_ar[slot]);
mtex_ar[slot] = NULL;
}
- else if (GS(id->name) == ID_MA) {
- /* Reset this slot's ON/OFF toggle, for materials, when slot was empty. */
- ((Material *)id)->septex &= ~(1 << slot);
- }
mtex_ar[slot] = BKE_texture_mtex_add();
@@ -498,9 +432,6 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot)
*/
void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const int flag)
{
- /* We never handle usercount here for own data. */
- const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
-
if (!BKE_texture_is_image_user(tex_src)) {
tex_dst->ima = NULL;
}
@@ -508,19 +439,6 @@ void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const
if (tex_dst->coba) {
tex_dst->coba = MEM_dupallocN(tex_dst->coba);
}
- if (tex_dst->env) {
- tex_dst->env = BKE_texture_envmap_copy(tex_dst->env, flag_subdata);
- }
- if (tex_dst->pd) {
- tex_dst->pd = BKE_texture_pointdensity_copy(tex_dst->pd, flag_subdata);
- }
- if (tex_dst->vd) {
- tex_dst->vd = MEM_dupallocN(tex_dst->vd);
- }
- if (tex_dst->ot) {
- tex_dst->ot = BKE_texture_ocean_copy(tex_dst->ot, flag_subdata);
- }
-
if (tex_src->nodetree) {
if (tex_src->nodetree->execdata) {
ntreeTexEndExecTree(tex_src->nodetree->execdata);
@@ -562,19 +480,6 @@ Tex *BKE_texture_localize(Tex *tex)
/* image texture: BKE_texture_free also doesn't decrease */
if (texn->coba) texn->coba = MEM_dupallocN(texn->coba);
- if (texn->env) {
- texn->env = BKE_texture_envmap_copy(texn->env, LIB_ID_CREATE_NO_USER_REFCOUNT);
- id_us_min(&texn->env->ima->id);
- }
- if (texn->pd) texn->pd = BKE_texture_pointdensity_copy(texn->pd, LIB_ID_CREATE_NO_USER_REFCOUNT);
- if (texn->vd) {
- texn->vd = MEM_dupallocN(texn->vd);
- if (texn->vd->dataset)
- texn->vd->dataset = MEM_dupallocN(texn->vd->dataset);
- }
- if (texn->ot) {
- texn->ot = BKE_texture_ocean_copy(tex->ot, LIB_ID_CREATE_NO_USER_REFCOUNT);
- }
texn->preview = NULL;
@@ -593,64 +498,6 @@ void BKE_texture_make_local(Main *bmain, Tex *tex, const bool lib_local)
BKE_id_make_local_generic(bmain, &tex->id, true, lib_local);
}
-Tex *give_current_object_texture(Object *ob)
-{
- Material *ma, *node_ma;
- Tex *tex = NULL;
-
- if (ob == NULL) return NULL;
- if (ob->totcol == 0 && !(ob->type == OB_LAMP)) return NULL;
-
- if (ob->type == OB_LAMP) {
- tex = give_current_lamp_texture(ob->data);
- }
- else {
- ma = give_current_material(ob, ob->actcol);
-
- if ((node_ma = give_node_material(ma)))
- ma = node_ma;
-
- tex = give_current_material_texture(ma);
- }
-
- return tex;
-}
-
-Tex *give_current_lamp_texture(Lamp *la)
-{
- MTex *mtex = NULL;
- Tex *tex = NULL;
-
- if (la) {
- mtex = la->mtex[(int)(la->texact)];
- if (mtex) tex = mtex->tex;
- }
-
- return tex;
-}
-
-void set_current_lamp_texture(Lamp *la, Tex *newtex)
-{
- int act = la->texact;
-
- if (la->mtex[act] && la->mtex[act]->tex)
- id_us_min(&la->mtex[act]->tex->id);
-
- if (newtex) {
- if (!la->mtex[act]) {
- la->mtex[act] = BKE_texture_mtex_add();
- la->mtex[act]->texco = TEXCO_GLOB;
- }
-
- la->mtex[act]->tex = newtex;
- id_us_plus(&newtex->id);
- }
- else if (la->mtex[act]) {
- MEM_freeN(la->mtex[act]);
- la->mtex[act] = NULL;
- }
-}
-
Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle)
{
MTex *mtex = NULL;
@@ -686,55 +533,9 @@ void set_current_linestyle_texture(FreestyleLineStyle *linestyle, Tex *newtex)
}
}
-bNode *give_current_material_texture_node(Material *ma)
-{
- if (ma && ma->use_nodes && ma->nodetree)
- return nodeGetActiveID(ma->nodetree, ID_TE);
-
- return NULL;
-}
-
-Tex *give_current_material_texture(Material *ma)
-{
- MTex *mtex = NULL;
- Tex *tex = NULL;
- bNode *node;
-
- if (ma && ma->use_nodes && ma->nodetree) {
- /* first check texture, then material, this works together
- * with a hack that clears the active ID flag for textures on
- * making a material node active */
- node = nodeGetActiveID(ma->nodetree, ID_TE);
-
- if (node) {
- tex = (Tex *)node->id;
- ma = NULL;
- }
- }
-
- if (ma) {
- mtex = ma->mtex[(int)(ma->texact)];
- if (mtex) tex = mtex->tex;
- }
-
- return tex;
-}
-
bool give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
{
switch (GS(id->name)) {
- case ID_MA:
- *mtex_ar = ((Material *)id)->mtex;
- if (act) *act = (((Material *)id)->texact);
- break;
- case ID_WO:
- *mtex_ar = ((World *)id)->mtex;
- if (act) *act = (((World *)id)->texact);
- break;
- case ID_LA:
- *mtex_ar = ((Lamp *)id)->mtex;
- if (act) *act = (((Lamp *)id)->texact);
- break;
case ID_LS:
*mtex_ar = ((FreestyleLineStyle *)id)->mtex;
if (act) *act = (((FreestyleLineStyle *)id)->texact);
@@ -758,15 +559,6 @@ void set_active_mtex(ID *id, short act)
else if (act >= MAX_MTEX) act = MAX_MTEX - 1;
switch (GS(id->name)) {
- case ID_MA:
- ((Material *)id)->texact = act;
- break;
- case ID_WO:
- ((World *)id)->texact = act;
- break;
- case ID_LA:
- ((Lamp *)id)->texact = act;
- break;
case ID_LS:
((FreestyleLineStyle *)id)->texact = act;
break;
@@ -778,100 +570,6 @@ void set_active_mtex(ID *id, short act)
}
}
-void set_current_material_texture(Material *ma, Tex *newtex)
-{
- Tex *tex = NULL;
- bNode *node;
-
- if ((ma->use_nodes && ma->nodetree) &&
- (node = nodeGetActiveID(ma->nodetree, ID_TE)))
- {
- tex = (Tex *)node->id;
- id_us_min(&tex->id);
- if (newtex) {
- node->id = &newtex->id;
- id_us_plus(&newtex->id);
- }
- else {
- node->id = NULL;
- }
- }
- else {
- int act = (int)ma->texact;
-
- tex = (ma->mtex[act]) ? ma->mtex[act]->tex : NULL;
- id_us_min(&tex->id);
-
- if (newtex) {
- if (!ma->mtex[act]) {
- ma->mtex[act] = BKE_texture_mtex_add();
- /* Reset this slot's ON/OFF toggle, for materials, when slot was empty. */
- ma->septex &= ~(1 << act);
- /* For volumes the default UV texture coordinates are not available. */
- if (ma->material_type == MA_TYPE_VOLUME) {
- ma->mtex[act]->texco = TEXCO_ORCO;
- }
- }
-
- ma->mtex[act]->tex = newtex;
- id_us_plus(&newtex->id);
- }
- else if (ma->mtex[act]) {
- MEM_freeN(ma->mtex[act]);
- ma->mtex[act] = NULL;
- }
- }
-}
-
-bool has_current_material_texture(Material *ma)
-{
- bNode *node;
-
- if (ma && ma->use_nodes && ma->nodetree) {
- node = nodeGetActiveID(ma->nodetree, ID_TE);
-
- if (node)
- return true;
- }
-
- return (ma != NULL);
-}
-
-Tex *give_current_world_texture(World *world)
-{
- MTex *mtex = NULL;
- Tex *tex = NULL;
-
- if (!world) return NULL;
-
- mtex = world->mtex[(int)(world->texact)];
- if (mtex) tex = mtex->tex;
-
- return tex;
-}
-
-void set_current_world_texture(World *wo, Tex *newtex)
-{
- int act = wo->texact;
-
- if (wo->mtex[act] && wo->mtex[act]->tex)
- id_us_min(&wo->mtex[act]->tex->id);
-
- if (newtex) {
- if (!wo->mtex[act]) {
- wo->mtex[act] = BKE_texture_mtex_add();
- wo->mtex[act]->texco = TEXCO_VIEW;
- }
-
- wo->mtex[act]->tex = newtex;
- id_us_plus(&newtex->id);
- }
- else if (wo->mtex[act]) {
- MEM_freeN(wo->mtex[act]);
- wo->mtex[act] = NULL;
- }
-}
-
Tex *give_current_brush_texture(Brush *br)
{
return br->mtex.tex;
@@ -926,65 +624,6 @@ void set_current_particle_texture(ParticleSettings *part, Tex *newtex)
/* ------------------------------------------------------------------------- */
-EnvMap *BKE_texture_envmap_add(void)
-{
- EnvMap *env;
-
- env = MEM_callocN(sizeof(EnvMap), "envmap");
- env->type = ENV_CUBE;
- env->stype = ENV_ANIM;
- env->clipsta = 0.1;
- env->clipend = 100.0;
- env->cuberes = 512;
- env->viewscale = 0.5;
-
- return env;
-}
-
-/* ------------------------------------------------------------------------- */
-
-EnvMap *BKE_texture_envmap_copy(const EnvMap *env, const int flag)
-{
- EnvMap *envn;
- int a;
-
- envn = MEM_dupallocN(env);
- envn->ok = 0;
- for (a = 0; a < 6; a++) {
- envn->cube[a] = NULL;
- }
- if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
- id_us_plus((ID *)envn->ima);
- }
-
- return envn;
-}
-
-/* ------------------------------------------------------------------------- */
-
-void BKE_texture_envmap_free_data(EnvMap *env)
-{
- unsigned int part;
-
- for (part = 0; part < 6; part++) {
- if (env->cube[part])
- IMB_freeImBuf(env->cube[part]);
- env->cube[part] = NULL;
- }
- env->ok = 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-void BKE_texture_envmap_free(EnvMap *env)
-{
-
- BKE_texture_envmap_free_data(env);
- MEM_freeN(env);
-
-}
-
-/* ------------------------------------------------------------------------- */
void BKE_texture_pointdensity_init_data(PointDensity *pd)
{
@@ -1057,77 +696,8 @@ void BKE_texture_pointdensity_free(PointDensity *pd)
BKE_texture_pointdensity_free_data(pd);
MEM_freeN(pd);
}
-
/* ------------------------------------------------------------------------- */
-void BKE_texture_voxeldata_free_data(VoxelData *vd)
-{
- if (vd->dataset) {
- MEM_freeN(vd->dataset);
- vd->dataset = NULL;
- }
-
-}
-
-void BKE_texture_voxeldata_free(VoxelData *vd)
-{
- BKE_texture_voxeldata_free_data(vd);
- MEM_freeN(vd);
-}
-
-VoxelData *BKE_texture_voxeldata_add(void)
-{
- VoxelData *vd;
-
- vd = MEM_callocN(sizeof(VoxelData), "voxeldata");
- vd->dataset = NULL;
- vd->resol[0] = vd->resol[1] = vd->resol[2] = 1;
- vd->interp_type = TEX_VD_LINEAR;
- vd->file_format = TEX_VD_SMOKE;
- vd->int_multiplier = 1.0;
- vd->extend = TEX_CLIP;
- vd->object = NULL;
- vd->cachedframe = -1;
- vd->ok = 0;
-
- return vd;
-}
-
-VoxelData *BKE_texture_voxeldata_copy(VoxelData *vd)
-{
- VoxelData *vdn;
-
- vdn = MEM_dupallocN(vd);
- vdn->dataset = NULL;
-
- return vdn;
-}
-
-/* ------------------------------------------------------------------------- */
-
-OceanTex *BKE_texture_ocean_add(void)
-{
- OceanTex *ot;
-
- ot = MEM_callocN(sizeof(struct OceanTex), "ocean texture");
- ot->output = TEX_OCN_DISPLACEMENT;
- ot->object = NULL;
-
- return ot;
-}
-
-OceanTex *BKE_texture_ocean_copy(const OceanTex *ot, const int UNUSED(flag))
-{
- OceanTex *otn = MEM_dupallocN(ot);
-
- return otn;
-}
-
-void BKE_texture_ocean_free(struct OceanTex *ot)
-{
- MEM_freeN(ot);
-}
-
/**
* \returns true if this texture can use its #Texture.ima (even if its NULL)
*/
@@ -1138,15 +708,6 @@ bool BKE_texture_is_image_user(const struct Tex *tex)
{
return true;
}
- case TEX_ENVMAP:
- {
- if (tex->env) {
- if (tex->env->stype == ENV_LOAD) {
- return true;
- }
- }
- break;
- }
}
return false;
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index fd62650e898..62710240109 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -387,6 +387,9 @@ UndoStep *BKE_undosys_step_push_init(UndoStack *ustack, bContext *C, const char
return BKE_undosys_step_push_init_with_type(ustack, C, name, ut);
}
+/**
+ * \param C: Can be NULL from some callers if their encoding function doesn't need it
+ */
bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char *name, const UndoType *ut)
{
UNDO_NESTED_ASSERT(false);
@@ -395,7 +398,7 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char
/* Might not be final place for this to be called - probably only want to call it from some
* undo handlers, not all of them? */
- BKE_main_override_static_operations_create(CTX_data_main(C));
+ BKE_main_override_static_operations_create(G.main, false);
/* Remove all undos after (also when 'ustack->step_active == NULL'). */
while (ustack->steps.last != ustack->step_active) {
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index afceea9dd5f..8de62f82c1b 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -171,9 +171,6 @@ void BKE_workspace_free(WorkSpace *workspace)
BLI_freelistN(&workspace->owner_ids);
BLI_freelistN(&workspace->layouts);
- BLI_freelistN(&workspace->transform_orientations);
-
- BKE_viewrender_free(&workspace->view_render);
}
/**
@@ -272,31 +269,6 @@ void BKE_workspace_view_layer_remove_references(
}
}
-void BKE_workspace_transform_orientation_remove(
- WorkSpace *workspace, TransformOrientation *orientation)
-{
- for (WorkSpaceLayout *layout = workspace->layouts.first; layout; layout = layout->next) {
- BKE_screen_transform_orientation_remove(BKE_workspace_layout_screen_get(layout), workspace, orientation);
- }
-
- BLI_freelinkN(&workspace->transform_orientations, orientation);
-}
-
-TransformOrientation *BKE_workspace_transform_orientation_find(
- const WorkSpace *workspace, const int index)
-{
- return BLI_findlink(&workspace->transform_orientations, index);
-}
-
-/**
- * \return the index that \a orientation has within \a workspace's transform-orientation list or -1 if not found.
- */
-int BKE_workspace_transform_orientation_get_index(
- const WorkSpace *workspace, const TransformOrientation *orientation)
-{
- return BLI_findindex(&workspace->transform_orientations, orientation);
-}
-
WorkSpaceLayout *BKE_workspace_layout_find(
const WorkSpace *workspace, const bScreen *screen)
{
@@ -423,11 +395,6 @@ Base *BKE_workspace_active_base_get(const WorkSpace *workspace, const Scene *sce
return view_layer->basact;
}
-ListBase *BKE_workspace_transform_orientations_get(WorkSpace *workspace)
-{
- return &workspace->transform_orientations;
-}
-
ViewLayer *BKE_workspace_view_layer_get(const WorkSpace *workspace, const Scene *scene)
{
return workspace_relation_get_data_matching_parent(&workspace->scene_viewlayer_relations, scene);
@@ -473,14 +440,6 @@ void BKE_workspace_hook_layout_for_workspace_set(
workspace_relation_ensure_updated(&workspace->hook_layout_relations, hook, layout);
}
-/**
- * Get the render engine of a workspace, to be used in the viewport.
- */
-ViewRender *BKE_workspace_view_render_get(WorkSpace *workspace)
-{
- return &workspace->view_render;
-}
-
/* Flags */
bool BKE_workspace_use_scene_settings_get(const WorkSpace *workspace)
{
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index e87e84736c8..15bf01d2049 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -58,14 +58,8 @@
/** Free (or release) any data used by this world (does not free the world itself). */
void BKE_world_free(World *wrld)
{
- int a;
-
BKE_animdata_free((ID *)wrld, false);
- for (a = 0; a < MAX_MTEX; a++) {
- MEM_SAFE_FREE(wrld->mtex[a]);
- }
-
/* is no lib link block, but world extension */
if (wrld->nodetree) {
ntreeFreeTree(wrld->nodetree);
@@ -86,23 +80,9 @@ void BKE_world_init(World *wrld)
wrld->horr = 0.05f;
wrld->horg = 0.05f;
wrld->horb = 0.05f;
- wrld->zenr = 0.01f;
- wrld->zeng = 0.01f;
- wrld->zenb = 0.01f;
- wrld->skytype = 0;
-
- wrld->exp = 0.0f;
- wrld->exposure = wrld->range = 1.0f;
wrld->aodist = 10.0f;
- wrld->aosamp = 5;
wrld->aoenergy = 1.0f;
- wrld->ao_env_energy = 1.0f;
- wrld->ao_indirect_energy = 1.0f;
- wrld->ao_indirect_bounces = 1;
- wrld->aobias = 0.05f;
- wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
- wrld->ao_approx_error = 0.25f;
wrld->preview = NULL;
wrld->miststa = 5.0f;
@@ -130,12 +110,6 @@ World *BKE_world_add(Main *bmain, const char *name)
*/
void BKE_world_copy_data(Main *bmain, World *wrld_dst, const World *wrld_src, const int flag)
{
- for (int a = 0; a < MAX_MTEX; a++) {
- if (wrld_src->mtex[a]) {
- wrld_dst->mtex[a] = MEM_dupallocN(wrld_src->mtex[a]);
- }
- }
-
if (wrld_src->nodetree) {
/* Note: nodetree is *not* in bmain, however this specific case is handled at lower level
* (see BKE_libblock_copy_ex()). */
@@ -169,17 +143,9 @@ World *BKE_world_localize(World *wrld)
* ... Once f*** nodes are fully converted to that too :( */
World *wrldn;
- int a;
wrldn = BKE_libblock_copy_nolib(&wrld->id, false);
- for (a = 0; a < MAX_MTEX; a++) {
- if (wrld->mtex[a]) {
- wrldn->mtex[a] = MEM_mallocN(sizeof(MTex), __func__);
- memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
- }
- }
-
if (wrld->nodetree)
wrldn->nodetree = ntreeLocalize(wrld->nodetree);
@@ -195,7 +161,7 @@ void BKE_world_make_local(Main *bmain, World *wrld, const bool lib_local)
BKE_id_make_local_generic(bmain, &wrld->id, true, lib_local);
}
-void BKE_world_eval(const struct EvaluationContext *UNUSED(eval_ctx), World *world)
+void BKE_world_eval(struct Depsgraph *UNUSED(depsgraph), World *world)
{
if (G.debug & G_DEBUG_DEPSGRAPH_EVAL) {
printf("%s on %s (%p)\n", __func__, world->id.name, world);
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 0a2527bafd2..39174620961 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -326,10 +326,6 @@ static int write_video_frame(FFMpegContext *context, RenderData *rd, int cfra, A
frame->pts = cfra;
- if (rd->mode & R_FIELDS) {
- frame->top_field_first = ((rd->mode & R_ODDFIELD) != 0);
- }
-
ret = avcodec_encode_video2(c, &packet, frame, &got_output);
if (ret >= 0 && got_output) {
@@ -685,13 +681,6 @@ static AVStream *alloc_video_stream(FFMpegContext *context, RenderData *rd, int
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
- /* Determine whether we are encoding interlaced material or not */
- if (rd->mode & R_FIELDS) {
- PRINT("Encoding interlaced video\n");
- c->flags |= CODEC_FLAG_INTERLACED_DCT;
- c->flags |= CODEC_FLAG_INTERLACED_ME;
- }
-
/* xasp & yasp got float lately... */
st->sample_aspect_ratio = c->sample_aspect_ratio = av_d2q(((double) rd->xasp / (double) rd->yasp), 255);
diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h
index be53d1f603b..adc7bf5af6b 100644
--- a/source/blender/blenlib/BLI_callbacks.h
+++ b/source/blender/blenlib/BLI_callbacks.h
@@ -49,8 +49,6 @@ typedef enum {
BLI_CB_EVT_LOAD_POST,
BLI_CB_EVT_SAVE_PRE,
BLI_CB_EVT_SAVE_POST,
- BLI_CB_EVT_GAME_PRE,
- BLI_CB_EVT_GAME_POST,
BLI_CB_EVT_VERSION_UPDATE,
BLI_CB_EVT_TOT
} eCbEvent;
diff --git a/source/blender/blenlib/BLI_graph.h b/source/blender/blenlib/BLI_graph.h
deleted file mode 100644
index 7936f5a6fab..00000000000
--- a/source/blender/blenlib/BLI_graph.h
+++ /dev/null
@@ -1,185 +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) 2008 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Joshua Leung
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __BLI_GRAPH_H__
-#define __BLI_GRAPH_H__
-
-/** \file BLI_graph.h
- * \ingroup bli
- */
-
-#include "DNA_listBase.h"
-
-struct BGraph;
-struct BNode;
-struct BArc;
-
-struct RadialArc;
-
-typedef void (*FreeArc)(struct BArc *);
-typedef void (*FreeNode)(struct BNode *);
-typedef void (*RadialSymmetry)(struct BNode *root_node, struct RadialArc *ring, int total);
-typedef void (*AxialSymmetry)(struct BNode *root_node, struct BNode *node1, struct BNode *node2, struct BArc *arc1, struct BArc *arc2);
-
-/* IF YOU MODIFY THOSE TYPES, YOU NEED TO UPDATE ALL THOSE THAT "INHERIT" FROM THEM
- *
- * RigGraph, ReebGraph
- *
- * */
-
-typedef struct BGraph {
- ListBase arcs;
- ListBase nodes;
-
- float length;
-
- /* function pointer to deal with custom fonctionnality */
- FreeArc free_arc;
- FreeNode free_node;
- RadialSymmetry radial_symmetry;
- AxialSymmetry axial_symmetry;
-} BGraph;
-
-typedef struct BNode {
- void *next, *prev;
- float p[3];
- int flag;
-
- int degree;
- struct BArc **arcs;
-
- int subgraph_index;
-
- int symmetry_level;
- int symmetry_flag;
- float symmetry_axis[3];
-} BNode;
-
-typedef struct BArc {
- void *next, *prev;
- struct BNode *head, *tail;
- int flag;
-
- float length;
-
- int symmetry_level;
- int symmetry_group;
- int symmetry_flag;
-} BArc;
-
-struct BArcIterator;
-
-void *IT_head(void *iter);
-void *IT_tail(void *iter);
-void *IT_peek(void *iter, int n);
-void *IT_next(void *iter);
-void *IT_nextN(void *iter, int n);
-void *IT_previous(void *iter);
-int IT_stopped(void *iter);
-
-typedef void * (*HeadFct)(void *iter);
-typedef void * (*TailFct)(void *iter);
-typedef void * (*PeekFct)(void *iter, int n);
-typedef void * (*NextFct)(void *iter);
-typedef void * (*NextNFct)(void *iter, int n);
-typedef void * (*PreviousFct)(void *iter);
-typedef int (*StoppedFct)(void *iter);
-
-typedef struct BArcIterator {
- HeadFct head;
- TailFct tail;
- PeekFct peek;
- NextFct next;
- NextNFct nextN;
- PreviousFct previous;
- StoppedFct stopped;
-
- float *p, *no;
- float size;
-
- int length;
- int index;
-} BArcIterator;
-
-/* Helper structure for radial symmetry */
-typedef struct RadialArc {
- struct BArc *arc;
- float n[3]; /* normalized vector joining the nodes of the arc */
-} RadialArc;
-
-BNode *BLI_otherNode(BArc *arc, BNode *node);
-
-void BLI_freeNode(BGraph *graph, BNode *node);
-void BLI_removeNode(BGraph *graph, BNode *node);
-
-void BLI_removeArc(BGraph *graph, BArc *arc);
-
-void BLI_flagNodes(BGraph *graph, int flag);
-void BLI_flagArcs(BGraph *graph, int flag);
-
-bool BLI_hasAdjacencyList(BGraph *rg);
-void BLI_buildAdjacencyList(BGraph *rg);
-void BLI_rebuildAdjacencyListForNode(BGraph *rg, BNode *node);
-void BLI_freeAdjacencyList(BGraph *rg);
-
-int BLI_FlagSubgraphs(BGraph *graph);
-void BLI_ReflagSubgraph(BGraph *graph, int old_subgraph, int new_subgraph);
-
-#define SHAPE_RADIX 10 /* each shape level is encoded this base */
-
-int BLI_subtreeShape(BGraph *graph, BNode *node, BArc *rootArc, int include_root);
-float BLI_subtreeLength(BNode *node);
-void BLI_calcGraphLength(BGraph *graph);
-
-void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced);
-void BLI_replaceNodeInArc(BGraph *graph, BArc *arc, BNode *node_src, BNode *node_replaced);
-void BLI_removeDoubleNodes(BGraph *graph, float limit);
-BNode *BLI_FindNodeByPosition(BGraph *graph, const float p[3], const float limit);
-
-BArc *BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v);
-
-bool BLI_isGraphCyclic(BGraph *graph);
-
-/*------------ Symmetry handling ------------*/
-void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit);
-
-void BLI_mirrorAlongAxis(float v[3], float center[3], float axis[3]);
-
-/* BNode symmetry flags */
-#define SYM_TOPOLOGICAL 1
-#define SYM_PHYSICAL 2
-
-/* the following two are exclusive */
-#define SYM_AXIAL 4
-#define SYM_RADIAL 8
-
-/* BArc symmetry flags
- *
- * axial symmetry sides */
-#define SYM_SIDE_POSITIVE 1
-#define SYM_SIDE_NEGATIVE 2
-/* Anything higher is the order in radial symmetry */
-#define SYM_SIDE_RADIAL 3
-
-#endif /*__BLI_GRAPH_H__*/
diff --git a/source/blender/blenlib/BLI_linklist_lockfree.h b/source/blender/blenlib/BLI_linklist_lockfree.h
new file mode 100644
index 00000000000..7e7400361e3
--- /dev/null
+++ b/source/blender/blenlib/BLI_linklist_lockfree.h
@@ -0,0 +1,88 @@
+/*
+ * ***** 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) 2018 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BLI_LINKLIST_LOCKFREE_H__
+#define __BLI_LINKLIST_LOCKFREE_H__
+
+/** \file BLI_linklist_lockfree.h
+ * \ingroup bli
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct LockfreeLinkNode {
+ struct LockfreeLinkNode *next;
+ /* NOTE: "Subclass" this structure to add custom-defined data. */
+} LockfreeLinkNode;
+
+typedef struct LockfreeLinkList {
+ /* We keep a dummy node at the beginning of the list all the time.
+ * This allows us to make sure head and tail pointers are always
+ * valid, and saves from annoying exception cases in insert().
+ */
+ LockfreeLinkNode dummy_node;
+ /* NOTE: This fields might point to a dummy node. */
+ LockfreeLinkNode *head, *tail;
+} LockfreeLinkList;
+
+typedef void (*LockfreeeLinkNodeFreeFP)(void *link);
+
+/* ************************************************************************** */
+/* NOTE: These functions are NOT safe for use from threads. */
+/* NOTE: !!! I REPEAT: DO NOT USE THEM WITHOUT EXTERNAL LOCK !!! */
+
+/* Make list ready for lock-free access. */
+void BLI_linklist_lockfree_init(LockfreeLinkList *list);
+
+/* Completely free the whole list, it is NOT re-usable after this. */
+void BLI_linklist_lockfree_free(LockfreeLinkList *list,
+ LockfreeeLinkNodeFreeFP free_func);
+
+/* Remove all the elements from the list, keep it usable for further
+ * inserts.
+ */
+void BLI_linklist_lockfree_clear(LockfreeLinkList *list,
+ LockfreeeLinkNodeFreeFP free_func);
+
+
+/* Begin iteration of lock-free linked list, starting with a
+ * first user=defined node. Will ignore the dummy node.
+ */
+LockfreeLinkNode *BLI_linklist_lockfree_begin(LockfreeLinkList *list);
+
+
+/* ************************************************************************** */
+/* NOTE: These functions are safe for use from threads. */
+
+void BLI_linklist_lockfree_insert(LockfreeLinkList *list,
+ LockfreeLinkNode *node);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BLI_LINKLIST_H__ */
diff --git a/source/blender/blenlib/BLI_utildefines_stack.h b/source/blender/blenlib/BLI_utildefines_stack.h
index 15b0029e727..224add91504 100644
--- a/source/blender/blenlib/BLI_utildefines_stack.h
+++ b/source/blender/blenlib/BLI_utildefines_stack.h
@@ -77,13 +77,13 @@
SWAP(typeof(stack_a), stack_a, stack_b); \
SWAP(unsigned int, _##stack_a##_index, _##stack_b##_index); \
_STACK_SWAP_TOTALLOC(stack_a, stack_b); \
- } ((void)0)
+} ((void)0)
#else
#define STACK_SWAP(stack_a, stack_b) { \
SWAP(void *, stack_a, stack_b); \
SWAP(unsigned int, _##stack_a##_index, _##stack_b##_index); \
_STACK_SWAP_TOTALLOC(stack_a, stack_b); \
- } ((void)0)
+} ((void)0)
#endif
#endif /* __BLI_UTILDEFINES_STACK_H__ */
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 5bcf4303a84..31abf258d0f 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -50,6 +50,7 @@ set(SRC
intern/BLI_kdopbvh.c
intern/BLI_kdtree.c
intern/BLI_linklist.c
+ intern/BLI_linklist_lockfree.c
intern/BLI_memarena.c
intern/BLI_memiter.c
intern/BLI_mempool.c
@@ -70,7 +71,6 @@ set(SRC
intern/fileops.c
intern/fnmatch.c
intern/freetypefont.c
- intern/graph.c
intern/gsqueue.c
intern/hash_md5.c
intern/hash_mm2a.c
@@ -153,7 +153,6 @@ set(SRC
BLI_fileops_types.h
BLI_fnmatch.h
BLI_ghash.h
- BLI_graph.h
BLI_gsqueue.h
BLI_hash.h
BLI_hash_md5.h
@@ -165,7 +164,7 @@ set(SRC
BLI_kdtree.h
BLI_lasso_2d.h
BLI_link_utils.h
- BLI_linklist.h
+ BLI_linklist_lockfree.h
BLI_linklist_stack.h
BLI_listbase.h
BLI_math.h
diff --git a/source/blender/blenlib/intern/BLI_linklist_lockfree.c b/source/blender/blenlib/intern/BLI_linklist_lockfree.c
new file mode 100644
index 00000000000..ef93ce3619f
--- /dev/null
+++ b/source/blender/blenlib/intern/BLI_linklist_lockfree.c
@@ -0,0 +1,91 @@
+/*
+ * ***** 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) 2018 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenlib/intern/BLI_linklist_lockfree.c
+ * \ingroup bli
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_linklist_lockfree.h"
+#include "BLI_strict_flags.h"
+
+#include "atomic_ops.h"
+
+void BLI_linklist_lockfree_init(LockfreeLinkList *list)
+{
+ list->dummy_node.next = NULL;
+ list->head = list->tail = &list->dummy_node;
+}
+
+void BLI_linklist_lockfree_free(LockfreeLinkList *list,
+ LockfreeeLinkNodeFreeFP free_func)
+{
+ if (free_func != NULL) {
+ /* NOTE: We start from a first user-added node. */
+ LockfreeLinkNode *node = list->head->next;
+ while (node != NULL) {
+ LockfreeLinkNode *node_next = node->next;
+ free_func(node);
+ node = node_next;
+ }
+ }
+}
+
+void BLI_linklist_lockfree_clear(LockfreeLinkList *list,
+ LockfreeeLinkNodeFreeFP free_func)
+{
+ BLI_linklist_lockfree_free(list, free_func);
+ BLI_linklist_lockfree_init(list);
+}
+
+void BLI_linklist_lockfree_insert(LockfreeLinkList *list,
+ LockfreeLinkNode *node)
+{
+ /* Based on:
+ *
+ * John D. Valois
+ * Implementing Lock-Free Queues
+ *
+ * http://people.csail.mit.edu/bushl2/rpi/portfolio/lockfree-grape/documents/lock-free-linked-lists.pdf
+ */
+ bool keep_working;
+ LockfreeLinkNode *tail_node;
+ node->next = NULL;
+ do {
+ tail_node = list->tail;
+ keep_working =
+ (atomic_cas_ptr((void **)&tail_node->next, NULL, node) != NULL);
+ if (keep_working) {
+ atomic_cas_ptr((void **)&list->tail, tail_node, tail_node->next);
+ }
+ } while (keep_working);
+ atomic_cas_ptr((void **)&list->tail, tail_node, node);
+}
+
+LockfreeLinkNode *BLI_linklist_lockfree_begin(LockfreeLinkList *list)
+{
+ return list->head->next;
+}
diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c
deleted file mode 100644
index 911e8aae340..00000000000
--- a/source/blender/blenlib/intern/graph.c
+++ /dev/null
@@ -1,1016 +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.
- *
- * Contributor(s): Martin Poirier
- *
- * ***** END GPL LICENSE BLOCK *****
- * graph.c: Common graph interface and methods
- */
-
-/** \file blender/blenlib/intern/graph.c
- * \ingroup bli
- */
-
-#include <float.h>
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_listbase.h"
-#include "BLI_graph.h"
-#include "BLI_math.h"
-
-
-static void testRadialSymmetry(BGraph *graph, BNode *root_node, RadialArc *ring, int total, float axis[3], float limit, int group);
-
-static void handleAxialSymmetry(BGraph *graph, BNode *root_node, int depth, float axis[3], float limit);
-static void testAxialSymmetry(BGraph *graph, BNode *root_node, BNode *node1, BNode *node2, BArc *arc1, BArc *arc2, float axis[3], float limit, int group);
-static void flagAxialSymmetry(BNode *root_node, BNode *end_node, BArc *arc, int group);
-
-void BLI_freeNode(BGraph *graph, BNode *node)
-{
- if (node->arcs) {
- MEM_freeN(node->arcs);
- }
-
- if (graph->free_node) {
- graph->free_node(node);
- }
-}
-
-void BLI_removeNode(BGraph *graph, BNode *node)
-{
- BLI_freeNode(graph, node);
- BLI_freelinkN(&graph->nodes, node);
-}
-
-BNode *BLI_otherNode(BArc *arc, BNode *node)
-{
- return (arc->head == node) ? arc->tail : arc->head;
-}
-
-void BLI_removeArc(BGraph *graph, BArc *arc)
-{
- if (graph->free_arc) {
- graph->free_arc(arc);
- }
-
- BLI_freelinkN(&graph->arcs, arc);
-}
-
-void BLI_flagNodes(BGraph *graph, int flag)
-{
- BNode *node;
-
- for (node = graph->nodes.first; node; node = node->next) {
- node->flag = flag;
- }
-}
-
-void BLI_flagArcs(BGraph *graph, int flag)
-{
- BArc *arc;
-
- for (arc = graph->arcs.first; arc; arc = arc->next) {
- arc->flag = flag;
- }
-}
-
-static void addArcToNodeAdjacencyList(BNode *node, BArc *arc)
-{
- node->arcs[node->flag] = arc;
- node->flag++;
-}
-
-void BLI_buildAdjacencyList(BGraph *graph)
-{
- BNode *node;
- BArc *arc;
-
- for (node = graph->nodes.first; node; node = node->next) {
- if (node->arcs != NULL) {
- MEM_freeN(node->arcs);
- }
-
- node->arcs = MEM_callocN((node->degree) * sizeof(BArc *), "adjacency list");
-
- /* temporary use to indicate the first index available in the lists */
- node->flag = 0;
- }
-
- for (arc = graph->arcs.first; arc; arc = arc->next) {
- addArcToNodeAdjacencyList(arc->head, arc);
- addArcToNodeAdjacencyList(arc->tail, arc);
- }
-
- for (node = graph->nodes.first; node; node = node->next) {
- if (node->degree != node->flag) {
- printf("error in node [%p]. Added only %i arcs out of %i\n", (void *)node, node->flag, node->degree);
- }
- }
-}
-
-void BLI_rebuildAdjacencyListForNode(BGraph *graph, BNode *node)
-{
- BArc *arc;
-
- if (node->arcs != NULL) {
- MEM_freeN(node->arcs);
- }
-
- node->arcs = MEM_callocN((node->degree) * sizeof(BArc *), "adjacency list");
-
- /* temporary use to indicate the first index available in the lists */
- node->flag = 0;
-
- for (arc = graph->arcs.first; arc; arc = arc->next) {
- if (arc->head == node) {
- addArcToNodeAdjacencyList(arc->head, arc);
- }
- else if (arc->tail == node) {
- addArcToNodeAdjacencyList(arc->tail, arc);
- }
- }
-
- if (node->degree != node->flag) {
- printf("error in node [%p]. Added only %i arcs out of %i\n", (void *)node, node->flag, node->degree);
- }
-}
-
-void BLI_freeAdjacencyList(BGraph *graph)
-{
- BNode *node;
-
- for (node = graph->nodes.first; node; node = node->next) {
- if (node->arcs != NULL) {
- MEM_freeN(node->arcs);
- node->arcs = NULL;
- }
- }
-}
-
-bool BLI_hasAdjacencyList(BGraph *graph)
-{
- BNode *node;
-
- for (node = graph->nodes.first; node; node = node->next) {
- if (node->arcs == NULL) {
- return false;
- }
- }
-
- return true;
-}
-
-void BLI_replaceNodeInArc(BGraph *graph, BArc *arc, BNode *node_src, BNode *node_replaced)
-{
- if (arc->head == node_replaced) {
- arc->head = node_src;
- node_src->degree++;
- }
-
- if (arc->tail == node_replaced) {
- arc->tail = node_src;
- node_src->degree++;
- }
-
- if (arc->head == arc->tail) {
- node_src->degree -= 2;
-
- graph->free_arc(arc);
- BLI_freelinkN(&graph->arcs, arc);
- }
-
- if (node_replaced->degree == 0) {
- BLI_removeNode(graph, node_replaced);
- }
-}
-
-void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced)
-{
- BArc *arc, *next_arc;
-
- for (arc = graph->arcs.first; arc; arc = next_arc) {
- next_arc = arc->next;
-
- if (arc->head == node_replaced) {
- arc->head = node_src;
- node_replaced->degree--;
- node_src->degree++;
- }
-
- if (arc->tail == node_replaced) {
- arc->tail = node_src;
- node_replaced->degree--;
- node_src->degree++;
- }
-
- if (arc->head == arc->tail) {
- node_src->degree -= 2;
-
- graph->free_arc(arc);
- BLI_freelinkN(&graph->arcs, arc);
- }
- }
-
- if (node_replaced->degree == 0) {
- BLI_removeNode(graph, node_replaced);
- }
-}
-
-void BLI_removeDoubleNodes(BGraph *graph, float limit)
-{
- const float limit_sq = limit * limit;
- BNode *node_src, *node_replaced;
-
- for (node_src = graph->nodes.first; node_src; node_src = node_src->next) {
- for (node_replaced = graph->nodes.first; node_replaced; node_replaced = node_replaced->next) {
- if (node_replaced != node_src && len_squared_v3v3(node_replaced->p, node_src->p) <= limit_sq) {
- BLI_replaceNode(graph, node_src, node_replaced);
- }
- }
- }
-
-}
-
-BNode *BLI_FindNodeByPosition(BGraph *graph, const float p[3], const float limit)
-{
- const float limit_sq = limit * limit;
- BNode *closest_node = NULL, *node;
- float min_distance = 0.0f;
-
- for (node = graph->nodes.first; node; node = node->next) {
- float distance = len_squared_v3v3(p, node->p);
- if (distance <= limit_sq && (closest_node == NULL || distance < min_distance)) {
- closest_node = node;
- min_distance = distance;
- }
- }
-
- return closest_node;
-}
-/************************************* SUBGRAPH DETECTION **********************************************/
-
-static void flagSubgraph(BNode *node, int subgraph)
-{
- if (node->subgraph_index == 0) {
- BArc *arc;
- int i;
-
- node->subgraph_index = subgraph;
-
- for (i = 0; i < node->degree; i++) {
- arc = node->arcs[i];
- flagSubgraph(BLI_otherNode(arc, node), subgraph);
- }
- }
-}
-
-int BLI_FlagSubgraphs(BGraph *graph)
-{
- BNode *node;
- int subgraph = 0;
-
- if (BLI_hasAdjacencyList(graph) == 0) {
- BLI_buildAdjacencyList(graph);
- }
-
- for (node = graph->nodes.first; node; node = node->next) {
- node->subgraph_index = 0;
- }
-
- for (node = graph->nodes.first; node; node = node->next) {
- if (node->subgraph_index == 0) {
- subgraph++;
- flagSubgraph(node, subgraph);
- }
- }
-
- return subgraph;
-}
-
-void BLI_ReflagSubgraph(BGraph *graph, int old_subgraph, int new_subgraph)
-{
- BNode *node;
-
- for (node = graph->nodes.first; node; node = node->next) {
- if (node->flag == old_subgraph) {
- node->flag = new_subgraph;
- }
- }
-}
-
-/*************************************** CYCLE DETECTION ***********************************************/
-
-static bool detectCycle(BNode *node, BArc *src_arc)
-{
- bool value = false;
-
- if (node->flag == 0) {
- int i;
-
- /* mark node as visited */
- node->flag = 1;
-
- for (i = 0; i < node->degree && value == 0; i++) {
- BArc *arc = node->arcs[i];
-
- /* don't go back on the source arc */
- if (arc != src_arc) {
- value = detectCycle(BLI_otherNode(arc, node), arc);
- }
- }
- }
- else {
- value = true;
- }
-
- return value;
-}
-
-bool BLI_isGraphCyclic(BGraph *graph)
-{
- BNode *node;
- bool value = false;
-
- /* NEED TO CHECK IF ADJACENCY LIST EXIST */
-
- /* Mark all nodes as not visited */
- BLI_flagNodes(graph, 0);
-
- /* detectCycles in subgraphs */
- for (node = graph->nodes.first; node && value == false; node = node->next) {
- /* only for nodes in subgraphs that haven't been visited yet */
- if (node->flag == 0) {
- value = value || detectCycle(node, NULL);
- }
- }
-
- return value;
-}
-
-BArc *BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v)
-{
- BArc *nextArc;
-
- for (nextArc = graph->arcs.first; nextArc; nextArc = nextArc->next) {
- if (arc != nextArc && (nextArc->head == v || nextArc->tail == v)) {
- break;
- }
- }
-
- return nextArc;
-}
-
-/*********************************** GRAPH AS TREE FUNCTIONS *******************************************/
-
-static int subtreeShape(BNode *node, BArc *rootArc, int include_root)
-{
- int depth = 0;
-
- node->flag = 1;
-
- if (include_root) {
- BNode *newNode = BLI_otherNode(rootArc, node);
- return subtreeShape(newNode, rootArc, 0);
- }
- else {
- /* Base case, no arcs leading away */
- if (node->arcs == NULL || *(node->arcs) == NULL) {
- return 0;
- }
- else {
- int i;
-
- for (i = 0; i < node->degree; i++) {
- BArc *arc = node->arcs[i];
- BNode *newNode = BLI_otherNode(arc, node);
-
- /* stop immediate and cyclic backtracking */
- if (arc != rootArc && newNode->flag == 0) {
- depth += subtreeShape(newNode, arc, 0);
- }
- }
- }
-
- return SHAPE_RADIX * depth + 1;
- }
-}
-
-int BLI_subtreeShape(BGraph *graph, BNode *node, BArc *rootArc, int include_root)
-{
- BLI_flagNodes(graph, 0);
- return subtreeShape(node, rootArc, include_root);
-}
-
-float BLI_subtreeLength(BNode *node)
-{
- float length = 0;
- int i;
-
- node->flag = 0; /* flag node as visited */
-
- for (i = 0; i < node->degree; i++) {
- BArc *arc = node->arcs[i];
- BNode *other_node = BLI_otherNode(arc, node);
-
- if (other_node->flag != 0) {
- float subgraph_length = arc->length + BLI_subtreeLength(other_node);
- length = MAX2(length, subgraph_length);
- }
- }
-
- return length;
-}
-
-void BLI_calcGraphLength(BGraph *graph)
-{
- float length = 0;
- int nb_subgraphs;
- int i;
-
- nb_subgraphs = BLI_FlagSubgraphs(graph);
-
- for (i = 1; i <= nb_subgraphs; i++) {
- BNode *node;
-
- for (node = graph->nodes.first; node; node = node->next) {
- /* start on an external node of the subgraph */
- if (node->subgraph_index == i && node->degree == 1) {
- float subgraph_length = BLI_subtreeLength(node);
- length = MAX2(length, subgraph_length);
- break;
- }
- }
- }
-
- graph->length = length;
-}
-
-/********************************* SYMMETRY DETECTION **************************************************/
-
-static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level, float limit);
-
-void BLI_mirrorAlongAxis(float v[3], float center[3], float axis[3])
-{
- float dv[3], pv[3];
-
- sub_v3_v3v3(dv, v, center);
- project_v3_v3v3(pv, dv, axis);
- mul_v3_fl(pv, -2);
- add_v3_v3(v, pv);
-}
-
-static void testRadialSymmetry(BGraph *graph, BNode *root_node, RadialArc *ring, int total, float axis[3], float limit, int group)
-{
- const float limit_sq = limit * limit;
- int symmetric = 1;
- int i;
-
- /* sort ring by angle */
- for (i = 0; i < total - 1; i++) {
- float minAngle = FLT_MAX;
- int minIndex = -1;
- int j;
-
- for (j = i + 1; j < total; j++) {
- float angle = dot_v3v3(ring[i].n, ring[j].n);
-
- /* map negative values to 1..2 */
- if (angle < 0) {
- angle = 1 - angle;
- }
-
- if (angle < minAngle) {
- minIndex = j;
- minAngle = angle;
- }
- }
-
- /* swap if needed */
- if (minIndex != i + 1) {
- RadialArc tmp;
- tmp = ring[i + 1];
- ring[i + 1] = ring[minIndex];
- ring[minIndex] = tmp;
- }
- }
-
- for (i = 0; i < total && symmetric; i++) {
- BNode *node1, *node2;
- float tangent[3];
- float normal[3];
- float p[3];
- int j = (i + 1) % total; /* next arc in the circular list */
-
- add_v3_v3v3(tangent, ring[i].n, ring[j].n);
- cross_v3_v3v3(normal, tangent, axis);
-
- node1 = BLI_otherNode(ring[i].arc, root_node);
- node2 = BLI_otherNode(ring[j].arc, root_node);
-
- copy_v3_v3(p, node2->p);
- BLI_mirrorAlongAxis(p, root_node->p, normal);
-
- /* check if it's within limit before continuing */
- if (len_squared_v3v3(node1->p, p) > limit_sq) {
- symmetric = 0;
- }
-
- }
-
- if (symmetric) {
- /* mark node as symmetric physically */
- copy_v3_v3(root_node->symmetry_axis, axis);
- root_node->symmetry_flag |= SYM_PHYSICAL;
- root_node->symmetry_flag |= SYM_RADIAL;
-
- /* FLAG SYMMETRY GROUP */
- for (i = 0; i < total; i++) {
- ring[i].arc->symmetry_group = group;
- ring[i].arc->symmetry_flag = SYM_SIDE_RADIAL + i;
- }
-
- if (graph->radial_symmetry) {
- graph->radial_symmetry(root_node, ring, total);
- }
- }
-}
-
-static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, float axis[3], float limit)
-{
- RadialArc *ring = NULL;
- RadialArc *unit;
- int total = 0;
- int group;
- int first;
- int i;
-
- /* mark topological symmetry */
- root_node->symmetry_flag |= SYM_TOPOLOGICAL;
-
- /* total the number of arcs in the symmetry ring */
- for (i = 0; i < root_node->degree; i++) {
- BArc *connectedArc = root_node->arcs[i];
-
- /* depth is store as a negative in flag. symmetry level is positive */
- if (connectedArc->symmetry_level == -depth) {
- total++;
- }
- }
-
- ring = MEM_callocN(sizeof(RadialArc) * total, "radial symmetry ring");
- unit = ring;
-
- /* fill in the ring */
- for (i = 0; i < root_node->degree; i++) {
- BArc *connectedArc = root_node->arcs[i];
-
- /* depth is store as a negative in flag. symmetry level is positive */
- if (connectedArc->symmetry_level == -depth) {
- BNode *otherNode = BLI_otherNode(connectedArc, root_node);
- float vec[3];
-
- unit->arc = connectedArc;
-
- /* project the node to node vector on the symmetry plane */
- sub_v3_v3v3(unit->n, otherNode->p, root_node->p);
- project_v3_v3v3(vec, unit->n, axis);
- sub_v3_v3v3(unit->n, unit->n, vec);
-
- normalize_v3(unit->n);
-
- unit++;
- }
- }
-
- /* sort ring by arc length
- * using a rather bogus insertion sort
- * but rings will never get too big to matter
- * */
- for (i = 0; i < total; i++) {
- int j;
-
- for (j = i - 1; j >= 0; j--) {
- BArc *arc1, *arc2;
-
- arc1 = ring[j].arc;
- arc2 = ring[j + 1].arc;
-
- if (arc1->length > arc2->length) {
- /* swap with smaller */
- RadialArc tmp;
-
- tmp = ring[j + 1];
- ring[j + 1] = ring[j];
- ring[j] = tmp;
- }
- else {
- break;
- }
- }
- }
-
- /* Dispatch to specific symmetry tests */
- first = 0;
- group = 0;
-
- for (i = 1; i < total; i++) {
- int dispatch = 0;
- int last = i - 1;
-
- if (fabsf(ring[first].arc->length - ring[i].arc->length) > limit) {
- dispatch = 1;
- }
-
- /* if not dispatching already and on last arc
- * Dispatch using current arc as last
- */
- if (dispatch == 0 && i == total - 1) {
- last = i;
- dispatch = 1;
- }
-
- if (dispatch) {
- int sub_total = last - first + 1;
-
- group += 1;
-
- if (sub_total == 1) {
- group -= 1; /* not really a group so decrement */
- /* NOTHING TO DO */
- }
- else if (sub_total == 2) {
- BArc *arc1, *arc2;
- BNode *node1, *node2;
-
- arc1 = ring[first].arc;
- arc2 = ring[last].arc;
-
- node1 = BLI_otherNode(arc1, root_node);
- node2 = BLI_otherNode(arc2, root_node);
-
- testAxialSymmetry(graph, root_node, node1, node2, arc1, arc2, axis, limit, group);
- }
- else if (sub_total != total) /* allocate a new sub ring if needed */ {
- RadialArc *sub_ring = MEM_callocN(sizeof(RadialArc) * sub_total, "radial symmetry ring");
- int sub_i;
-
- /* fill in the sub ring */
- for (sub_i = 0; sub_i < sub_total; sub_i++) {
- sub_ring[sub_i] = ring[first + sub_i];
- }
-
- testRadialSymmetry(graph, root_node, sub_ring, sub_total, axis, limit, group);
-
- MEM_freeN(sub_ring);
- }
- else if (sub_total == total) {
- testRadialSymmetry(graph, root_node, ring, total, axis, limit, group);
- }
-
- first = i;
- }
- }
-
-
- MEM_freeN(ring);
-}
-
-static void flagAxialSymmetry(BNode *root_node, BNode *end_node, BArc *arc, int group)
-{
- float vec[3];
-
- arc->symmetry_group = group;
-
- sub_v3_v3v3(vec, end_node->p, root_node->p);
-
- if (dot_v3v3(vec, root_node->symmetry_axis) < 0) {
- arc->symmetry_flag |= SYM_SIDE_NEGATIVE;
- }
- else {
- arc->symmetry_flag |= SYM_SIDE_POSITIVE;
- }
-}
-
-static void testAxialSymmetry(BGraph *graph, BNode *root_node, BNode *node1, BNode *node2, BArc *arc1, BArc *arc2, float axis[3], float limit, int group)
-{
- const float limit_sq = limit * limit;
- float nor[3], vec[3], p[3];
-
- sub_v3_v3v3(p, node1->p, root_node->p);
- cross_v3_v3v3(nor, p, axis);
-
- sub_v3_v3v3(p, root_node->p, node2->p);
- cross_v3_v3v3(vec, p, axis);
- add_v3_v3(vec, nor);
-
- cross_v3_v3v3(nor, vec, axis);
-
- if (fabsf(nor[0]) > fabsf(nor[1]) && fabsf(nor[0]) > fabsf(nor[2]) && nor[0] < 0) {
- negate_v3(nor);
- }
- else if (fabsf(nor[1]) > fabsf(nor[0]) && fabsf(nor[1]) > fabsf(nor[2]) && nor[1] < 0) {
- negate_v3(nor);
- }
- else if (fabsf(nor[2]) > fabsf(nor[1]) && fabsf(nor[2]) > fabsf(nor[0]) && nor[2] < 0) {
- negate_v3(nor);
- }
-
- /* mirror node2 along axis */
- copy_v3_v3(p, node2->p);
- BLI_mirrorAlongAxis(p, root_node->p, nor);
-
- /* check if it's within limit before continuing */
- if (len_squared_v3v3(node1->p, p) <= limit_sq) {
- /* mark node as symmetric physically */
- copy_v3_v3(root_node->symmetry_axis, nor);
- root_node->symmetry_flag |= SYM_PHYSICAL;
- root_node->symmetry_flag |= SYM_AXIAL;
-
- /* flag side on arcs */
- flagAxialSymmetry(root_node, node1, arc1, group);
- flagAxialSymmetry(root_node, node2, arc2, group);
-
- if (graph->axial_symmetry) {
- graph->axial_symmetry(root_node, node1, node2, arc1, arc2);
- }
- }
- else {
- /* NOT SYMMETRIC */
- }
-}
-
-static void handleAxialSymmetry(BGraph *graph, BNode *root_node, int depth, float axis[3], float limit)
-{
- BArc *arc1 = NULL, *arc2 = NULL;
- BNode *node1 = NULL, *node2 = NULL;
- int i;
-
- /* mark topological symmetry */
- root_node->symmetry_flag |= SYM_TOPOLOGICAL;
-
- for (i = 0; i < root_node->degree; i++) {
- BArc *connectedArc = root_node->arcs[i];
-
- /* depth is store as a negative in flag. symmetry level is positive */
- if (connectedArc->symmetry_level == -depth) {
- if (arc1 == NULL) {
- arc1 = connectedArc;
- node1 = BLI_otherNode(arc1, root_node);
- }
- else {
- arc2 = connectedArc;
- node2 = BLI_otherNode(arc2, root_node);
- break; /* Can stop now, the two arcs have been found */
- }
- }
- }
-
- /* shouldn't happen, but just to be sure */
- if (node1 == NULL || node2 == NULL) {
- return;
- }
-
- testAxialSymmetry(graph, root_node, node1, node2, arc1, arc2, axis, limit, 1);
-}
-
-static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int level, float limit)
-{
- float axis[3] = {0, 0, 0};
- int count = 0;
- int i;
-
- /* count the number of branches in this symmetry group
- * and determinate the axis of symmetry
- */
- for (i = 0; i < node->degree; i++) {
- BArc *connectedArc = node->arcs[i];
-
- /* depth is store as a negative in flag. symmetry level is positive */
- if (connectedArc->symmetry_level == -depth) {
- count++;
- }
- /* If arc is on the axis */
- else if (connectedArc->symmetry_level == level) {
- add_v3_v3(axis, connectedArc->head->p);
- sub_v3_v3v3(axis, axis, connectedArc->tail->p);
- }
- }
-
- normalize_v3(axis);
-
- /* Split between axial and radial symmetry */
- if (count == 2) {
- handleAxialSymmetry(graph, node, depth, axis, limit);
- }
- else {
- handleRadialSymmetry(graph, node, depth, axis, limit);
- }
-
- /* markdown secondary symetries */
- for (i = 0; i < node->degree; i++) {
- BArc *connectedArc = node->arcs[i];
-
- if (connectedArc->symmetry_level == -depth) {
- /* markdown symmetry for branches corresponding to the depth */
- markdownSymmetryArc(graph, connectedArc, node, level + 1, limit);
- }
- }
-}
-
-static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level, float limit)
-{
- int i;
-
- /* if arc is null, we start straight from a node */
- if (arc) {
- arc->symmetry_level = level;
-
- node = BLI_otherNode(arc, node);
- }
-
- for (i = 0; i < node->degree; i++) {
- BArc *connectedArc = node->arcs[i];
-
- if (connectedArc != arc) {
- BNode *connectedNode = BLI_otherNode(connectedArc, node);
-
- /* symmetry level is positive value, negative values is subtree depth */
- connectedArc->symmetry_level = -BLI_subtreeShape(graph, connectedNode, connectedArc, 0);
- }
- }
-
- arc = NULL;
-
- for (i = 0; i < node->degree; i++) {
- int issymmetryAxis = 0;
- BArc *connectedArc = node->arcs[i];
-
- /* only arcs not already marked as symetric */
- if (connectedArc->symmetry_level < 0) {
- int j;
-
- /* true by default */
- issymmetryAxis = 1;
-
- for (j = 0; j < node->degree; j++) {
- BArc *otherArc = node->arcs[j];
-
- /* different arc, same depth */
- if (otherArc != connectedArc && otherArc->symmetry_level == connectedArc->symmetry_level) {
- /* not on the symmetry axis */
- issymmetryAxis = 0;
- break;
- }
- }
- }
-
- /* arc could be on the symmetry axis */
- if (issymmetryAxis == 1) {
- /* no arc as been marked previously, keep this one */
- if (arc == NULL) {
- arc = connectedArc;
- }
- else if (connectedArc->symmetry_level < arc->symmetry_level) {
- /* go with more complex subtree as symmetry arc */
- arc = connectedArc;
- }
- }
- }
-
- /* go down the arc continuing the symmetry axis */
- if (arc) {
- markdownSymmetryArc(graph, arc, node, level, limit);
- }
-
-
- /* secondary symmetry */
- for (i = 0; i < node->degree; i++) {
- BArc *connectedArc = node->arcs[i];
-
- /* only arcs not already marked as symetric and is not the next arc on the symmetry axis */
- if (connectedArc->symmetry_level < 0) {
- /* subtree depth is store as a negative value in the symmetry */
- markdownSecondarySymmetry(graph, node, -connectedArc->symmetry_level, level, limit);
- }
- }
-}
-
-void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit)
-{
- BNode *node;
- BArc *arc;
-
- if (root_node == NULL) {
- return;
- }
-
- if (BLI_isGraphCyclic(graph)) {
- return;
- }
-
- /* mark down all arcs as non-symetric */
- BLI_flagArcs(graph, 0);
-
- /* mark down all nodes as not on the symmetry axis */
- BLI_flagNodes(graph, 0);
-
- node = root_node;
-
- /* sanity check REMOVE ME */
- if (node->degree > 0) {
- arc = node->arcs[0];
-
- if (node->degree == 1) {
- markdownSymmetryArc(graph, arc, node, 1, limit);
- }
- else {
- markdownSymmetryArc(graph, NULL, node, 1, limit);
- }
-
-
-
- /* mark down non-symetric arcs */
- for (arc = graph->arcs.first; arc; arc = arc->next) {
- if (arc->symmetry_level < 0) {
- arc->symmetry_level = 0;
- }
- else {
- /* mark down nodes with the lowest level symmetry axis */
- if (arc->head->symmetry_level == 0 || arc->head->symmetry_level > arc->symmetry_level) {
- arc->head->symmetry_level = arc->symmetry_level;
- }
- if (arc->tail->symmetry_level == 0 || arc->tail->symmetry_level > arc->symmetry_level) {
- arc->tail->symmetry_level = arc->symmetry_level;
- }
- }
- }
- }
-}
-
-void *IT_head(void *arg)
-{
- BArcIterator *iter = (BArcIterator *)arg;
- return iter->head(iter);
-}
-
-void *IT_tail(void *arg)
-{
- BArcIterator *iter = (BArcIterator *)arg;
- return iter->tail(iter);
-}
-
-void *IT_peek(void *arg, int n)
-{
- BArcIterator *iter = (BArcIterator *)arg;
-
- if (iter->index + n < 0) {
- return iter->head(iter);
- }
- else if (iter->index + n >= iter->length) {
- return iter->tail(iter);
- }
- else {
- return iter->peek(iter, n);
- }
-}
-
-void *IT_next(void *arg)
-{
- BArcIterator *iter = (BArcIterator *)arg;
- return iter->next(iter);
-}
-
-void *IT_nextN(void *arg, int n)
-{
- BArcIterator *iter = (BArcIterator *)arg;
- return iter->nextN(iter, n);
-}
-
-void *IT_previous(void *arg)
-{
- BArcIterator *iter = (BArcIterator *)arg;
- return iter->previous(iter);
-}
-
-int IT_stopped(void *arg)
-{
- BArcIterator *iter = (BArcIterator *)arg;
- return iter->stopped(iter);
-}
diff --git a/source/blender/blenloader/BLO_runtime.h b/source/blender/blenloader/BLO_runtime.h
index 0a5a7d3a660..c119ea95f66 100644
--- a/source/blender/blenloader/BLO_runtime.h
+++ b/source/blender/blenloader/BLO_runtime.h
@@ -38,11 +38,14 @@ extern "C" {
#endif
struct BlendFileData;
+struct Main;
struct ReportList;
int BLO_is_a_runtime(const char *file);
struct BlendFileData *BLO_read_runtime(const char *file, struct ReportList *reports);
+bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 61d1aa18b3c..f42336a2c7a 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -47,6 +47,7 @@ set(INC_SYS
)
set(SRC
+ intern/blend_validate.c
intern/readblenentry.c
intern/readfile.c
intern/runtime.c
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
new file mode 100644
index 00000000000..d155fcfaa0d
--- /dev/null
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -0,0 +1,151 @@
+/*
+ * ***** 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): Bastien Montagne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/blenloader/intern/blend_validate.c
+ * \ingroup blenloader
+ *
+ * Utils to check/validate a Main is in sane state, only checks relations between datablocks and libraries for now.
+ *
+ * \note Does not *fix* anything, only reports found errors.
+ *
+ */
+
+#include <string.h> // for strrchr strncmp strstr
+
+#include "BLI_utildefines.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_linklist.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_sdna_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+
+#include "BLO_readfile.h"
+#include "BLO_runtime.h"
+
+#include "readfile.h"
+
+/* Does not fix anything, but checks that all linked data-blocks are still valid (i.e. pointing to the right library). */
+bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports)
+{
+ ListBase mainlist;
+ bool is_valid = true;
+
+ BKE_main_lock(bmain);
+
+ blo_split_main(&mainlist, bmain);
+
+ ListBase *lbarray[MAX_LIBARRAY];
+ int i = set_listbasepointers(bmain, lbarray);
+ while (i--) {
+ for (ID *id = lbarray[i]->first; id != NULL; id = id->next) {
+ if (id->lib != NULL) {
+ is_valid = false;
+ BKE_reportf(reports, RPT_ERROR,
+ "ID %s is in local database while being linked from library %s!\n", id->name, id->lib->name);
+ }
+ }
+ }
+
+ for (Main *curmain = bmain->next; curmain != NULL; curmain = curmain->next) {
+ Library *curlib = curmain->curlib;
+ if (curlib == NULL) {
+ BKE_reportf(reports, RPT_ERROR,
+ "Library database with NULL library datablock!\n");
+ continue;
+ }
+
+ BKE_library_filepath_set(curlib, curlib->name);
+ BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath, reports);
+
+ if (bh == NULL) {
+ continue;
+ }
+
+ i = set_listbasepointers(curmain, lbarray);
+ while (i--) {
+ ID *id = lbarray[i]->first;
+ if (id == NULL) {
+ continue;
+ }
+
+ if (GS(id->name) == ID_LI) {
+ is_valid = false;
+ BKE_reportf(reports, RPT_ERROR,
+ "Library ID %s in library %s, this should not happen!\n", id->name, curlib->name);
+ continue;
+ }
+
+ int totnames = 0;
+ LinkNode *names = BLO_blendhandle_get_datablock_names(bh, GS(id->name), &totnames);
+ for (; id != NULL; id = id->next) {
+ if (id->lib == NULL) {
+ is_valid = false;
+ BKE_reportf(reports, RPT_ERROR,
+ "ID %s has NULL lib pointer while being in library %s!\n", id->name, curlib->name);
+ continue;
+ }
+ if (id->lib != curlib) {
+ is_valid = false;
+ BKE_reportf(reports, RPT_ERROR,
+ "ID %s has mismatched lib pointer!\n", id->name);
+ continue;
+ }
+
+ LinkNode *name = names;
+ for (; name; name = name->next) {
+ char *str_name = (char *)name->link;
+ if (id->name[2] == str_name[0] && STREQ(str_name, id->name + 2)) {
+ break;
+ }
+ }
+
+ if (name == NULL) {
+ is_valid = false;
+ BKE_reportf(reports, RPT_ERROR,
+ "ID %s not found in library %s anymore!\n", id->name, id->lib->name);
+ continue;
+ }
+ }
+
+ BLI_linklist_free(names, free);
+ }
+
+ BLO_blendhandle_close(bh);
+ }
+
+ blo_join_main(&mainlist);
+
+ BLI_assert(BLI_listbase_is_single(&mainlist));
+ BLI_assert(mainlist.first == (void *)bmain);
+
+ BKE_main_unlock(bmain);
+
+ return is_valid;
+}
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 73109413271..8d90a11f5d9 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -282,7 +282,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
else if (BKE_idcode_is_valid(bhead->code)) {
if (BKE_idcode_is_linkable(bhead->code)) {
const char *str = BKE_idcode_to_name(bhead->code);
-
+
if (BLI_gset_add(gathered, (void *)str)) {
BLI_linklist_prepend(&names, strdup(str));
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2f11797cddd..77884ccfa01 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -61,12 +61,10 @@
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_brush_types.h"
#include "DNA_camera_types.h"
#include "DNA_cachefile_types.h"
#include "DNA_cloth_types.h"
-#include "DNA_controller_types.h"
#include "DNA_constraint_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_effect_types.h"
@@ -93,12 +91,10 @@
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
#include "DNA_lightprobe_types.h"
-#include "DNA_property_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
-#include "DNA_sensor_types.h"
#include "DNA_sdna_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
@@ -154,7 +150,6 @@
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_report.h"
-#include "BKE_sca.h" // for init_actuator
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
@@ -569,6 +564,10 @@ void blo_split_main(ListBase *mainlist, Main *main)
ListBase *lbarray[MAX_LIBARRAY];
i = set_listbasepointers(main, lbarray);
while (i--) {
+ ID *id = lbarray[i]->first;
+ if (id == NULL || GS(id->name) == ID_LI) {
+ continue; /* no ID_LI datablock should ever be linked anyway, but just in case, better be explicit. */
+ }
split_libdata(lbarray[i], lib_main_array, lib_main_array_len);
}
@@ -2909,7 +2908,6 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
link_list(fd, BKE_workspace_layouts_get(workspace));
link_list(fd, &workspace->hook_layout_relations);
link_list(fd, &workspace->scene_viewlayer_relations);
- link_list(fd, BKE_workspace_transform_orientations_get(workspace));
link_list(fd, &workspace->owner_ids);
for (WorkSpaceDataRelation *relation = workspace->hook_layout_relations.first;
@@ -3564,7 +3562,6 @@ static void direct_link_armature(FileData *fd, bArmature *arm)
link_list(fd, &arm->bonebase);
arm->edbo = NULL;
- arm->sketch = NULL;
arm->adt = newdataadr(fd, arm->adt);
direct_link_animdata(fd, arm->adt);
@@ -3622,14 +3619,6 @@ static void lib_link_lamp(FileData *fd, Main *main)
IDP_LibLinkProperty(la->id.properties, fd);
lib_link_animdata(fd, &la->id, la->adt);
- for (int a = 0; a < MAX_MTEX; a++) {
- MTex *mtex = la->mtex[a];
- if (mtex) {
- mtex->tex = newlibadr_us(fd, la->id.lib, mtex->tex);
- mtex->object = newlibadr(fd, la->id.lib, mtex->object);
- }
- }
-
la->ipo = newlibadr_us(fd, la->id.lib, la->ipo); // XXX deprecated - old animation system
if (la->nodetree) {
@@ -3644,15 +3633,9 @@ static void lib_link_lamp(FileData *fd, Main *main)
static void direct_link_lamp(FileData *fd, Lamp *la)
{
- int a;
-
la->adt = newdataadr(fd, la->adt);
direct_link_animdata(fd, la->adt);
- for (a=0; a<MAX_MTEX; a++) {
- la->mtex[a] = newdataadr(fd, la->mtex[a]);
- }
-
la->curfalloff = newdataadr(fd, la->curfalloff);
if (la->curfalloff)
direct_link_curvemapping(fd, la->curfalloff);
@@ -3791,14 +3774,6 @@ static void lib_link_world(FileData *fd, Main *main)
wrld->ipo = newlibadr_us(fd, wrld->id.lib, wrld->ipo); // XXX deprecated - old animation system
- for (int a = 0; a < MAX_MTEX; a++) {
- MTex *mtex = wrld->mtex[a];
- if (mtex) {
- mtex->tex = newlibadr_us(fd, wrld->id.lib, mtex->tex);
- mtex->object = newlibadr(fd, wrld->id.lib, mtex->object);
- }
- }
-
if (wrld->nodetree) {
lib_link_ntree(fd, &wrld->id, wrld->nodetree);
wrld->nodetree->id.lib = wrld->id.lib;
@@ -3811,15 +3786,9 @@ static void lib_link_world(FileData *fd, Main *main)
static void direct_link_world(FileData *fd, World *wrld)
{
- int a;
-
wrld->adt = newdataadr(fd, wrld->adt);
direct_link_animdata(fd, wrld->adt);
- for (a = 0; a < MAX_MTEX; a++) {
- wrld->mtex[a] = newdataadr(fd, wrld->mtex[a]);
- }
-
wrld->nodetree = newdataadr(fd, wrld->nodetree);
if (wrld->nodetree) {
direct_link_id(fd, &wrld->nodetree->id);
@@ -3875,8 +3844,8 @@ static void direct_link_text(FileData *fd, Text *text)
#if 0
if (text->flags & TXT_ISEXT) {
BKE_text_reload(text);
- }
- /* else { */
+ }
+ /* else { */
#endif
link_list(fd, &text->lines);
@@ -3931,8 +3900,6 @@ static void direct_link_image(FileData *fd, Image *ima)
}
ima->rr = NULL;
}
-
- ima->repbind = NULL;
/* undo system, try to restore render buffers */
if (fd->imamap) {
@@ -4073,14 +4040,6 @@ static void lib_link_texture(FileData *fd, Main *main)
tex->ima = newlibadr_us(fd, tex->id.lib, tex->ima);
tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo); // XXX deprecated - old animation system
- if (tex->env)
- tex->env->object = newlibadr(fd, tex->id.lib, tex->env->object);
- if (tex->pd)
- tex->pd->object = newlibadr(fd, tex->id.lib, tex->pd->object);
- if (tex->vd)
- tex->vd->object = newlibadr(fd, tex->id.lib, tex->vd->object);
- if (tex->ot)
- tex->ot->object = newlibadr(fd, tex->id.lib, tex->ot->object);
if (tex->nodetree) {
lib_link_ntree(fd, &tex->id, tex->nodetree);
@@ -4098,35 +4057,7 @@ static void direct_link_texture(FileData *fd, Tex *tex)
direct_link_animdata(fd, tex->adt);
tex->coba = newdataadr(fd, tex->coba);
- tex->env = newdataadr(fd, tex->env);
- if (tex->env) {
- tex->env->ima = NULL;
- memset(tex->env->cube, 0, 6 * sizeof(void *));
- tex->env->ok= 0;
- }
- tex->pd = newdataadr(fd, tex->pd);
- if (tex->pd) {
- tex->pd->point_tree = NULL;
- tex->pd->coba = newdataadr(fd, tex->pd->coba);
- tex->pd->falloff_curve = newdataadr(fd, tex->pd->falloff_curve);
- if (tex->pd->falloff_curve) {
- direct_link_curvemapping(fd, tex->pd->falloff_curve);
- }
- tex->pd->point_data = NULL; /* runtime data */
- }
-
- tex->vd = newdataadr(fd, tex->vd);
- if (tex->vd) {
- tex->vd->dataset = NULL;
- tex->vd->ok = 0;
- }
- else {
- if (tex->type == TEX_VOXELDATA)
- tex->vd = MEM_callocN(sizeof(VoxelData), "direct_link_texture VoxelData");
- }
-
- tex->ot = newdataadr(fd, tex->ot);
-
+
tex->nodetree = newdataadr(fd, tex->nodetree);
if (tex->nodetree) {
direct_link_id(fd, &tex->nodetree->id);
@@ -4150,15 +4081,6 @@ static void lib_link_material(FileData *fd, Main *main)
lib_link_animdata(fd, &ma->id, ma->adt);
ma->ipo = newlibadr_us(fd, ma->id.lib, ma->ipo); // XXX deprecated - old animation system
- ma->group = newlibadr_us(fd, ma->id.lib, ma->group);
-
- for (int a = 0; a < MAX_MTEX; a++) {
- MTex *mtex = ma->mtex[a];
- if (mtex) {
- mtex->tex = newlibadr_us(fd, ma->id.lib, mtex->tex);
- mtex->object = newlibadr(fd, ma->id.lib, mtex->object);
- }
- }
if (ma->nodetree) {
lib_link_ntree(fd, &ma->id, ma->nodetree);
@@ -4172,18 +4094,10 @@ static void lib_link_material(FileData *fd, Main *main)
static void direct_link_material(FileData *fd, Material *ma)
{
- int a;
-
ma->adt = newdataadr(fd, ma->adt);
direct_link_animdata(fd, ma->adt);
- for (a = 0; a < MAX_MTEX; a++) {
- ma->mtex[a] = newdataadr(fd, ma->mtex[a]);
- }
ma->texpaintslot = NULL;
-
- ma->ramp_col = newdataadr(fd, ma->ramp_col);
- ma->ramp_spec = newdataadr(fd, ma->ramp_spec);
ma->nodetree = newdataadr(fd, ma->nodetree);
if (ma->nodetree) {
@@ -4982,144 +4896,7 @@ static void lib_link_object(FileData *fd, Main *main)
paf->group = newlibadr_us(fd, ob->id.lib, paf->group);
}
}
-
- for (bSensor *sens = ob->sensors.first; sens; sens = sens->next) {
- for (a = 0; a < sens->totlinks; a++)
- sens->links[a] = newglobadr(fd, sens->links[a]);
- if (sens->type == SENS_MESSAGE) {
- bMessageSensor *ms = sens->data;
- ms->fromObject =
- newlibadr(fd, ob->id.lib, ms->fromObject);
- }
- }
-
- for (bController *cont = ob->controllers.first; cont; cont = cont->next) {
- for (a=0; a < cont->totlinks; a++)
- cont->links[a] = newglobadr(fd, cont->links[a]);
-
- if (cont->type == CONT_PYTHON) {
- bPythonCont *pc = cont->data;
- pc->text = newlibadr(fd, ob->id.lib, pc->text);
- }
- cont->slinks = NULL;
- cont->totslinks = 0;
- }
-
- for (bActuator *act = ob->actuators.first; act; act = act->next) {
- switch (act->type) {
- case ACT_SOUND:
- {
- bSoundActuator *sa = act->data;
- sa->sound = newlibadr_us(fd, ob->id.lib, sa->sound);
- break;
- }
- case ACT_GAME:
- /* bGameActuator *ga= act->data; */
- break;
- case ACT_CAMERA:
- {
- bCameraActuator *ca = act->data;
- ca->ob = newlibadr(fd, ob->id.lib, ca->ob);
- break;
- }
- /* leave this one, it's obsolete but necessary to read for conversion */
- case ACT_ADD_OBJECT:
- {
- bAddObjectActuator *eoa = act->data;
- if (eoa)
- eoa->ob = newlibadr(fd, ob->id.lib, eoa->ob);
- break;
- }
- case ACT_OBJECT:
- {
- bObjectActuator *oa = act->data;
- if (oa == NULL) {
- init_actuator(act);
- }
- else {
- oa->reference = newlibadr(fd, ob->id.lib, oa->reference);
- }
- break;
- }
- case ACT_EDIT_OBJECT:
- {
- bEditObjectActuator *eoa = act->data;
- if (eoa == NULL) {
- init_actuator(act);
- }
- else {
- eoa->ob = newlibadr(fd, ob->id.lib, eoa->ob);
- eoa->me = newlibadr(fd, ob->id.lib, eoa->me);
- }
- break;
- }
- case ACT_SCENE:
- {
- bSceneActuator *sa = act->data;
- sa->camera = newlibadr(fd, ob->id.lib, sa->camera);
- sa->scene = newlibadr(fd, ob->id.lib, sa->scene);
- break;
- }
- case ACT_ACTION:
- {
- bActionActuator *aa = act->data;
- aa->act = newlibadr_us(fd, ob->id.lib, aa->act);
- break;
- }
- case ACT_SHAPEACTION:
- {
- bActionActuator *aa = act->data;
- aa->act = newlibadr_us(fd, ob->id.lib, aa->act);
- break;
- }
- case ACT_PROPERTY:
- {
- bPropertyActuator *pa = act->data;
- pa->ob = newlibadr(fd, ob->id.lib, pa->ob);
- break;
- }
- case ACT_MESSAGE:
- {
- bMessageActuator *ma = act->data;
- ma->toObject = newlibadr(fd, ob->id.lib, ma->toObject);
- break;
- }
- case ACT_2DFILTER:
- {
- bTwoDFilterActuator *_2dfa = act->data;
- _2dfa->text = newlibadr(fd, ob->id.lib, _2dfa->text);
- break;
- }
- case ACT_PARENT:
- {
- bParentActuator *parenta = act->data;
- parenta->ob = newlibadr(fd, ob->id.lib, parenta->ob);
- break;
- }
- case ACT_STATE:
- /* bStateActuator *statea = act->data; */
- break;
- case ACT_ARMATURE:
- {
- bArmatureActuator *arma= act->data;
- arma->target = newlibadr(fd, ob->id.lib, arma->target);
- arma->subtarget = newlibadr(fd, ob->id.lib, arma->subtarget);
- break;
- }
- case ACT_STEERING:
- {
- bSteeringActuator *steeringa = act->data;
- steeringa->target = newlibadr(fd, ob->id.lib, steeringa->target);
- steeringa->navmesh = newlibadr(fd, ob->id.lib, steeringa->navmesh);
- break;
- }
- case ACT_MOUSE:
- /* bMouseActuator *moa = act->data; */
- break;
- }
- }
-
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
@@ -5573,10 +5350,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
static void direct_link_object(FileData *fd, Object *ob)
{
PartEff *paf;
- bProperty *prop;
- bSensor *sens;
- bController *cont;
- bActuator *act;
/* weak weak... this was only meant as draw flag, now is used in give_base_to_objects too */
ob->flag &= ~OB_FROMGROUP;
@@ -5698,7 +5471,6 @@ static void direct_link_object(FileData *fd, Object *ob)
direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, 0);
}
- ob->bsoft = newdataadr(fd, ob->bsoft);
ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */
ob->rigidbody_object = newdataadr(fd, ob->rigidbody_object);
@@ -5717,44 +5489,9 @@ static void direct_link_object(FileData *fd, Object *ob)
link_list(fd, &ob->particlesystem);
direct_link_particlesystems(fd, &ob->particlesystem);
-
- link_list(fd, &ob->prop);
- for (prop = ob->prop.first; prop; prop = prop->next) {
- prop->poin = newdataadr(fd, prop->poin);
- if (prop->poin == NULL)
- prop->poin = &prop->data;
- }
-
- link_list(fd, &ob->sensors);
- for (sens = ob->sensors.first; sens; sens = sens->next) {
- sens->data = newdataadr(fd, sens->data);
- sens->links = newdataadr(fd, sens->links);
- test_pointer_array(fd, (void **)&sens->links);
- }
direct_link_constraints(fd, &ob->constraints);
- link_glob_list(fd, &ob->controllers);
- if (ob->init_state) {
- /* if a known first state is specified, set it so that the game will start ok */
- ob->state = ob->init_state;
- }
- else if (!ob->state) {
- ob->state = 1;
- }
- for (cont = ob->controllers.first; cont; cont = cont->next) {
- cont->data = newdataadr(fd, cont->data);
- cont->links = newdataadr(fd, cont->links);
- test_pointer_array(fd, (void **)&cont->links);
- if (cont->state_mask == 0)
- cont->state_mask = 1;
- }
-
- link_glob_list(fd, &ob->actuators);
- for (act = ob->actuators.first; act; act = act->next) {
- act->data = newdataadr(fd, act->data);
- }
-
link_list(fd, &ob->hooks);
while (ob->hooks.first) {
ObHook *hook = ob->hooks.first;
@@ -5977,8 +5714,6 @@ static void lib_link_scene(FileData *fd, Main *main)
sce->toolsettings->imapaint.canvas =
newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.canvas);
- sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template);
-
sce->toolsettings->particle.shape_object = newlibadr(fd, sce->id.lib, sce->toolsettings->particle.shape_object);
for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy_next) {
@@ -6073,9 +5808,6 @@ static void lib_link_scene(FileData *fd, Main *main)
fls->group = newlibadr_us(fd, sce->id.lib, fls->group);
}
}
- /*Game Settings: Dome Warp Text*/
- sce->gm.dome.warptext = newlibadr(fd, sce->id.lib, sce->gm.dome.warptext);
-
/* Motion Tracking */
sce->clip = newlibadr_us(fd, sce->id.lib, sce->clip);
@@ -6476,7 +6208,7 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
}
link_list(fd, &(sce->markers));
- link_list(fd, &(sce->transform_spaces)); /* only for old files */
+ link_list(fd, &(sce->transform_spaces));
link_list(fd, &(sce->r.layers));
link_list(fd, &(sce->r.views));
@@ -6547,6 +6279,597 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
direct_link_workspace_link_scene_data(fd, sce, &bmain->workspaces);
}
+/* ****************** READ GREASE PENCIL ***************** */
+
+/* relink's grease pencil data's refs */
+static void lib_link_gpencil(FileData *fd, Main *main)
+{
+ for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
+ if (gpd->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(gpd->id.properties, fd);
+ lib_link_animdata(fd, &gpd->id, gpd->adt);
+
+ gpd->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
+}
+
+/* relinks grease-pencil data - used for direct_link and old file linkage */
+static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
+{
+ bGPDlayer *gpl;
+ bGPDframe *gpf;
+ bGPDstroke *gps;
+ bGPDpalette *palette;
+
+ /* we must firstly have some grease-pencil data to link! */
+ if (gpd == NULL)
+ return;
+
+ /* relink animdata */
+ gpd->adt = newdataadr(fd, gpd->adt);
+ direct_link_animdata(fd, gpd->adt);
+
+ /* relink palettes */
+ link_list(fd, &gpd->palettes);
+ for (palette = gpd->palettes.first; palette; palette = palette->next) {
+ link_list(fd, &palette->colors);
+ }
+
+ /* relink layers */
+ link_list(fd, &gpd->layers);
+
+ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* parent */
+ gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent);
+ /* relink frames */
+ link_list(fd, &gpl->frames);
+ gpl->actframe = newdataadr(fd, gpl->actframe);
+
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ /* relink strokes (and their points) */
+ link_list(fd, &gpf->strokes);
+
+ for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ gps->points = newdataadr(fd, gps->points);
+
+ /* the triangulation is not saved, so need to be recalculated */
+ gps->triangles = NULL;
+ gps->tot_triangles = 0;
+ gps->flag |= GP_STROKE_RECALC_CACHES;
+ /* the color pointer is not saved, so need to be recalculated using the color name */
+ gps->palcolor = NULL;
+ gps->flag |= GP_STROKE_RECALC_COLOR;
+ }
+ }
+ }
+}
+
+/* *********** READ AREA **************** */
+
+static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
+{
+ Panel *pa;
+ uiList *ui_list;
+
+ link_list(fd, &ar->panels);
+
+ for (pa = ar->panels.first; pa; pa = pa->next) {
+ pa->paneltab = newdataadr(fd, pa->paneltab);
+ pa->runtime_flag = 0;
+ pa->activedata = NULL;
+ pa->type = NULL;
+ }
+
+ link_list(fd, &ar->panels_category_active);
+
+ link_list(fd, &ar->ui_lists);
+
+ for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) {
+ ui_list->type = NULL;
+ ui_list->dyn_data = NULL;
+ ui_list->properties = newdataadr(fd, ui_list->properties);
+ IDP_DirectLinkGroup_OrFree(&ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+
+ link_list(fd, &ar->ui_previews);
+
+ if (spacetype == SPACE_EMPTY) {
+ /* unkown space type, don't leak regiondata */
+ ar->regiondata = NULL;
+ }
+ else {
+ ar->regiondata = newdataadr(fd, ar->regiondata);
+ if (ar->regiondata) {
+ if (spacetype == SPACE_VIEW3D) {
+ RegionView3D *rv3d = ar->regiondata;
+
+ rv3d->localvd = newdataadr(fd, rv3d->localvd);
+ rv3d->clipbb = newdataadr(fd, rv3d->clipbb);
+
+ rv3d->depths = NULL;
+ rv3d->gpuoffscreen = NULL;
+ rv3d->render_engine = NULL;
+ rv3d->sms = NULL;
+ rv3d->smooth_timer = NULL;
+ rv3d->compositor = NULL;
+ rv3d->viewport = NULL;
+ }
+ }
+ }
+
+ ar->v2d.tab_offset = NULL;
+ ar->v2d.tab_num = 0;
+ ar->v2d.tab_cur = 0;
+ ar->v2d.sms = NULL;
+ BLI_listbase_clear(&ar->panels_category);
+ BLI_listbase_clear(&ar->handlers);
+ BLI_listbase_clear(&ar->uiblocks);
+ ar->headerstr = NULL;
+ ar->visible = 0;
+ ar->type = NULL;
+ ar->swap = 0;
+ ar->do_draw = 0;
+ ar->manipulator_map = NULL;
+ ar->regiontimer = NULL;
+ memset(&ar->drawrct, 0, sizeof(ar->drawrct));
+}
+
+static void direct_link_area(FileData *fd, ScrArea *area)
+{
+ SpaceLink *sl;
+ ARegion *ar;
+
+ link_list(fd, &(area->spacedata));
+ link_list(fd, &(area->regionbase));
+
+ BLI_listbase_clear(&area->handlers);
+ area->type = NULL; /* spacetype callbacks */
+ area->region_active_win = -1;
+
+ area->global = newdataadr(fd, area->global);
+
+ /* if we do not have the spacetype registered we cannot
+ * free it, so don't allocate any new memory for such spacetypes. */
+ if (!BKE_spacetype_exists(area->spacetype)) {
+ area->spacetype = SPACE_EMPTY;
+ }
+
+ for (ar = area->regionbase.first; ar; ar = ar->next) {
+ direct_link_region(fd, ar, area->spacetype);
+ }
+
+ /* accident can happen when read/save new file with older version */
+ /* 2.50: we now always add spacedata for info */
+ if (area->spacedata.first == NULL) {
+ SpaceInfo *sinfo= MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
+ area->spacetype= sinfo->spacetype= SPACE_INFO;
+ BLI_addtail(&area->spacedata, sinfo);
+ }
+ /* add local view3d too */
+ else if (area->spacetype == SPACE_VIEW3D) {
+ blo_do_versions_view3d_split_250(area->spacedata.first, &area->regionbase);
+ }
+
+ /* incase we set above */
+ area->butspacetype = area->spacetype;
+
+ for (sl = area->spacedata.first; sl; sl = sl->next) {
+ link_list(fd, &(sl->regionbase));
+
+ /* if we do not have the spacetype registered we cannot
+ * free it, so don't allocate any new memory for such spacetypes. */
+ if (!BKE_spacetype_exists(sl->spacetype))
+ sl->spacetype = SPACE_EMPTY;
+
+ for (ar = sl->regionbase.first; ar; ar = ar->next)
+ direct_link_region(fd, ar, sl->spacetype);
+
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d= (View3D*) sl;
+
+ v3d->flag |= V3D_INVALID_BACKBUF;
+
+ if (v3d->gpd) {
+ v3d->gpd = newdataadr(fd, v3d->gpd);
+ direct_link_gpencil(fd, v3d->gpd);
+ }
+ v3d->localvd = newdataadr(fd, v3d->localvd);
+ BLI_listbase_clear(&v3d->afterdraw_transp);
+ BLI_listbase_clear(&v3d->afterdraw_xray);
+ BLI_listbase_clear(&v3d->afterdraw_xraytransp);
+ v3d->properties_storage = NULL;
+ v3d->defmaterial = NULL;
+
+ /* render can be quite heavy, set to solid on load */
+ if (v3d->drawtype == OB_RENDER)
+ v3d->drawtype = OB_SOLID;
+ v3d->prev_drawtype = OB_SOLID;
+
+ if (v3d->fx_settings.dof)
+ v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof);
+ if (v3d->fx_settings.ssao)
+ v3d->fx_settings.ssao = newdataadr(fd, v3d->fx_settings.ssao);
+
+ blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
+ }
+ else if (sl->spacetype == SPACE_IPO) {
+ SpaceIpo *sipo = (SpaceIpo *)sl;
+
+ sipo->ads = newdataadr(fd, sipo->ads);
+ BLI_listbase_clear(&sipo->ghostCurves);
+ }
+ else if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *snla = (SpaceNla *)sl;
+
+ snla->ads = newdataadr(fd, snla->ads);
+ }
+ else if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOops *soops = (SpaceOops *) sl;
+
+ /* use newdataadr_no_us and do not free old memory avoiding double
+ * frees and use of freed memory. this could happen because of a
+ * bug fixed in revision 58959 where the treestore memory address
+ * was not unique */
+ TreeStore *ts = newdataadr_no_us(fd, soops->treestore);
+ soops->treestore = NULL;
+ if (ts) {
+ TreeStoreElem *elems = newdataadr_no_us(fd, ts->data);
+
+ soops->treestore = BLI_mempool_create(sizeof(TreeStoreElem), ts->usedelem,
+ 512, BLI_MEMPOOL_ALLOW_ITER);
+ if (ts->usedelem && elems) {
+ int i;
+ for (i = 0; i < ts->usedelem; i++) {
+ TreeStoreElem *new_elem = BLI_mempool_alloc(soops->treestore);
+ *new_elem = elems[i];
+ }
+ }
+ /* we only saved what was used */
+ soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
+ }
+ soops->treehash = NULL;
+ soops->tree.first = soops->tree.last= NULL;
+ }
+ else if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+
+ sima->iuser.scene = NULL;
+ sima->iuser.ok = 1;
+ sima->scopes.waveform_1 = NULL;
+ sima->scopes.waveform_2 = NULL;
+ sima->scopes.waveform_3 = NULL;
+ sima->scopes.vecscope = NULL;
+ sima->scopes.ok = 0;
+
+ /* WARNING: gpencil data is no longer stored directly in sima after 2.5
+ * so sacrifice a few old files for now to avoid crashes with new files!
+ * committed: r28002 */
+#if 0
+ sima->gpd = newdataadr(fd, sima->gpd);
+ if (sima->gpd)
+ direct_link_gpencil(fd, sima->gpd);
+#endif
+ }
+ else if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+
+ if (snode->gpd) {
+ snode->gpd = newdataadr(fd, snode->gpd);
+ direct_link_gpencil(fd, snode->gpd);
+ }
+
+ link_list(fd, &snode->treepath);
+ snode->edittree = NULL;
+ snode->iofsd = NULL;
+ BLI_listbase_clear(&snode->linkdrag);
+ }
+ else if (sl->spacetype == SPACE_TEXT) {
+ SpaceText *st= (SpaceText *)sl;
+
+ st->drawcache = NULL;
+ st->scroll_accum[0] = 0.0f;
+ st->scroll_accum[1] = 0.0f;
+ }
+ else if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ /* grease pencil data is not a direct data and can't be linked from direct_link*
+ * functions, it should be linked from lib_link* functions instead
+ *
+ * otherwise it'll lead to lost grease data on open because it'll likely be
+ * read from file after all other users of grease pencil and newdataadr would
+ * simple return NULL here (sergey)
+ */
+#if 0
+ if (sseq->gpd) {
+ sseq->gpd = newdataadr(fd, sseq->gpd);
+ direct_link_gpencil(fd, sseq->gpd);
+ }
+#endif
+ sseq->scopes.reference_ibuf = NULL;
+ sseq->scopes.zebra_ibuf = NULL;
+ sseq->scopes.waveform_ibuf = NULL;
+ sseq->scopes.sep_waveform_ibuf = NULL;
+ sseq->scopes.vector_ibuf = NULL;
+ sseq->scopes.histogram_ibuf = NULL;
+ sseq->compositor = NULL;
+ }
+ else if (sl->spacetype == SPACE_BUTS) {
+ SpaceButs *sbuts = (SpaceButs *)sl;
+
+ sbuts->path= NULL;
+ sbuts->texuser= NULL;
+ sbuts->mainbo = sbuts->mainb;
+ sbuts->mainbuser = sbuts->mainb;
+ }
+ else if (sl->spacetype == SPACE_CONSOLE) {
+ SpaceConsole *sconsole = (SpaceConsole *)sl;
+ ConsoleLine *cl, *cl_next;
+
+ link_list(fd, &sconsole->scrollback);
+ link_list(fd, &sconsole->history);
+
+ //for (cl= sconsole->scrollback.first; cl; cl= cl->next)
+ // cl->line= newdataadr(fd, cl->line);
+
+ /* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
+ * from left to right. the right-most expression sets the result of the comma
+ * expression as a whole*/
+ for (cl = sconsole->history.first; cl; cl = cl_next) {
+ cl_next = cl->next;
+ cl->line = newdataadr(fd, cl->line);
+ if (cl->line) {
+ /* the allocted length is not written, so reset here */
+ cl->len_alloc = cl->len + 1;
+ }
+ else {
+ BLI_remlink(&sconsole->history, cl);
+ MEM_freeN(cl);
+ }
+ }
+ }
+ else if (sl->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)sl;
+
+ /* this sort of info is probably irrelevant for reloading...
+ * plus, it isn't saved to files yet!
+ */
+ sfile->folders_prev = sfile->folders_next = NULL;
+ sfile->files = NULL;
+ sfile->layout = NULL;
+ sfile->op = NULL;
+ sfile->previews_timer = NULL;
+ sfile->params = newdataadr(fd, sfile->params);
+ }
+ else if (sl->spacetype == SPACE_CLIP) {
+ SpaceClip *sclip = (SpaceClip *)sl;
+
+ sclip->scopes.track_search = NULL;
+ sclip->scopes.track_preview = NULL;
+ sclip->scopes.ok = 0;
+ }
+ }
+
+ BLI_listbase_clear(&area->actionzones);
+
+ area->v1 = newdataadr(fd, area->v1);
+ area->v2 = newdataadr(fd, area->v2);
+ area->v3 = newdataadr(fd, area->v3);
+ area->v4 = newdataadr(fd, area->v4);
+}
+
+static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
+{
+ area->full = newlibadr(fd, parent_id->lib, area->full);
+
+ for (SpaceLink *sl = area->spacedata.first; sl; sl= sl->next) {
+ switch (sl->spacetype) {
+ case SPACE_VIEW3D:
+ {
+ View3D *v3d = (View3D*) sl;
+
+ v3d->camera= newlibadr(fd, parent_id->lib, v3d->camera);
+ v3d->ob_centre= newlibadr(fd, parent_id->lib, v3d->ob_centre);
+
+ if (v3d->localvd) {
+ v3d->localvd->camera = newlibadr(fd, parent_id->lib, v3d->localvd->camera);
+ }
+ break;
+ }
+ case SPACE_IPO:
+ {
+ SpaceIpo *sipo = (SpaceIpo *)sl;
+ bDopeSheet *ads = sipo->ads;
+
+ if (ads) {
+ ads->source = newlibadr(fd, parent_id->lib, ads->source);
+ ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
+ }
+ break;
+ }
+ case SPACE_BUTS:
+ {
+ SpaceButs *sbuts = (SpaceButs *)sl;
+ sbuts->pinid = newlibadr(fd, parent_id->lib, sbuts->pinid);
+ if (sbuts->pinid == NULL) {
+ sbuts->flag &= ~SB_PIN_CONTEXT;
+ }
+ break;
+ }
+ case SPACE_FILE:
+ break;
+ case SPACE_ACTION:
+ {
+ SpaceAction *saction = (SpaceAction *)sl;
+ bDopeSheet *ads = &saction->ads;
+
+ if (ads) {
+ ads->source = newlibadr(fd, parent_id->lib, ads->source);
+ ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
+ }
+
+ saction->action = newlibadr(fd, parent_id->lib, saction->action);
+ break;
+ }
+ case SPACE_IMAGE:
+ {
+ SpaceImage *sima = (SpaceImage *)sl;
+
+ sima->image = newlibadr_real_us(fd, parent_id->lib, sima->image);
+ sima->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sima->mask_info.mask);
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so fingers crossed this works fine!
+ */
+ sima->gpd = newlibadr_us(fd, parent_id->lib, sima->gpd);
+ break;
+ }
+ case SPACE_SEQ:
+ {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so fingers crossed this works fine!
+ */
+ sseq->gpd = newlibadr_us(fd, parent_id->lib, sseq->gpd);
+ break;
+ }
+ case SPACE_NLA:
+ {
+ SpaceNla *snla= (SpaceNla *)sl;
+ bDopeSheet *ads= snla->ads;
+
+ if (ads) {
+ ads->source = newlibadr(fd, parent_id->lib, ads->source);
+ ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
+ }
+ break;
+ }
+ case SPACE_TEXT:
+ {
+ SpaceText *st= (SpaceText *)sl;
+
+ st->text= newlibadr(fd, parent_id->lib, st->text);
+ break;
+ }
+ case SPACE_SCRIPT:
+ {
+ SpaceScript *scpt = (SpaceScript *)sl;
+ /*scpt->script = NULL; - 2.45 set to null, better re-run the script */
+ if (scpt->script) {
+ scpt->script = newlibadr(fd, parent_id->lib, scpt->script);
+ if (scpt->script) {
+ SCRIPT_SET_NULL(scpt->script);
+ }
+ }
+ break;
+ }
+ case SPACE_OUTLINER:
+ {
+ SpaceOops *so= (SpaceOops *)sl;
+ so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id);
+
+ if (so->treestore) {
+ TreeStoreElem *tselem;
+ BLI_mempool_iter iter;
+
+ BLI_mempool_iternew(so->treestore, &iter);
+ while ((tselem = BLI_mempool_iterstep(&iter))) {
+ tselem->id = newlibadr(fd, NULL, tselem->id);
+ }
+ if (so->treehash) {
+ /* rebuild hash table, because it depends on ids too */
+ so->storeflag |= SO_TREESTORE_REBUILD;
+ }
+ }
+ break;
+ }
+ case SPACE_NODE:
+ {
+ SpaceNode *snode = (SpaceNode *)sl;
+ bNodeTreePath *path, *path_next;
+ bNodeTree *ntree;
+
+ /* node tree can be stored locally in id too, link this first */
+ snode->id = newlibadr(fd, parent_id->lib, snode->id);
+ snode->from = newlibadr(fd, parent_id->lib, snode->from);
+
+ ntree = snode->id ? ntreeFromID(snode->id) : NULL;
+ snode->nodetree = ntree ? ntree : newlibadr_us(fd, parent_id->lib, snode->nodetree);
+
+ for (path = snode->treepath.first; path; path = path->next) {
+ if (path == snode->treepath.first) {
+ /* first nodetree in path is same as snode->nodetree */
+ path->nodetree = snode->nodetree;
+ }
+ else
+ path->nodetree = newlibadr_us(fd, parent_id->lib, path->nodetree);
+
+ if (!path->nodetree)
+ break;
+ }
+
+ /* remaining path entries are invalid, remove */
+ for (; path; path = path_next) {
+ path_next = path->next;
+
+ BLI_remlink(&snode->treepath, path);
+ MEM_freeN(path);
+ }
+
+ /* edittree is just the last in the path,
+ * set this directly since the path may have been shortened above */
+ if (snode->treepath.last) {
+ path = snode->treepath.last;
+ snode->edittree = path->nodetree;
+ }
+ else {
+ snode->edittree = NULL;
+ }
+ break;
+ }
+ case SPACE_CLIP:
+ {
+ SpaceClip *sclip = (SpaceClip *)sl;
+ sclip->clip = newlibadr_real_us(fd, parent_id->lib, sclip->clip);
+ sclip->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sclip->mask_info.mask);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+}
+
+/**
+ * \return false on error.
+ */
+static bool direct_link_area_map(FileData *fd, ScrAreaMap *area_map)
+{
+ link_list(fd, &area_map->vertbase);
+ link_list(fd, &area_map->edgebase);
+ link_list(fd, &area_map->areabase);
+ for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
+ direct_link_area(fd, area);
+ }
+
+ /* edges */
+ for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
+ se->v1 = newdataadr(fd, se->v1);
+ se->v2 = newdataadr(fd, se->v2);
+ BKE_screen_sort_scrvert(&se->v1, &se->v2);
+
+ if (se->v1 == NULL) {
+ BLI_remlink(&area_map->edgebase, se);
+
+ return false;
+ }
+ }
+
+ return true;
+}
+
/* ************ READ WM ***************** */
static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
@@ -6563,6 +6886,8 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
/* we need to restore a pointer to this later when reading workspaces, so store in global oldnew-map */
oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0);
+ direct_link_area_map(fd, &win->global_areas);
+
win->ghostwin = NULL;
win->gwnctx = NULL;
win->eventstate = NULL;
@@ -6634,75 +6959,13 @@ static void lib_link_windowmanager(FileData *fd, Main *main)
win->scene = newlibadr(fd, wm->id.lib, win->scene);
/* deprecated, but needed for versioning (will be NULL'ed then) */
win->screen = newlibadr(fd, NULL, win->screen);
- }
-
- wm->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
-}
-
-/* ****************** READ GREASE PENCIL ***************** */
-
-/* relink's grease pencil data's refs */
-static void lib_link_gpencil(FileData *fd, Main *main)
-{
- for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
- if (gpd->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(gpd->id.properties, fd);
- lib_link_animdata(fd, &gpd->id, gpd->adt);
-
- gpd->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
-}
-
-/* relinks grease-pencil data - used for direct_link and old file linkage */
-static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
-{
- bGPDlayer *gpl;
- bGPDframe *gpf;
- bGPDstroke *gps;
- bGPDpalette *palette;
-
- /* we must firstly have some grease-pencil data to link! */
- if (gpd == NULL)
- return;
-
- /* relink animdata */
- gpd->adt = newdataadr(fd, gpd->adt);
- direct_link_animdata(fd, gpd->adt);
-
- /* relink palettes */
- link_list(fd, &gpd->palettes);
- for (palette = gpd->palettes.first; palette; palette = palette->next) {
- link_list(fd, &palette->colors);
- }
-
- /* relink layers */
- link_list(fd, &gpd->layers);
- for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* parent */
- gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent);
- /* relink frames */
- link_list(fd, &gpl->frames);
- gpl->actframe = newdataadr(fd, gpl->actframe);
-
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- /* relink strokes (and their points) */
- link_list(fd, &gpf->strokes);
-
- for (gps = gpf->strokes.first; gps; gps = gps->next) {
- gps->points = newdataadr(fd, gps->points);
-
- /* the triangulation is not saved, so need to be recalculated */
- gps->triangles = NULL;
- gps->tot_triangles = 0;
- gps->flag |= GP_STROKE_RECALC_CACHES;
- /* the color pointer is not saved, so need to be recalculated using the color name */
- gps->palcolor = NULL;
- gps->flag |= GP_STROKE_RECALC_COLOR;
+ for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ lib_link_area(fd, &wm->id, area);
+ }
}
+
+ wm->id.tag &= ~LIB_TAG_NEED_LINK;
}
}
}
@@ -6725,194 +6988,8 @@ static void lib_link_screen(FileData *fd, Main *main)
sc->tool_tip = NULL;
sc->scrubbing = false;
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- sa->full = newlibadr(fd, sc->id.lib, sa->full);
-
- for (SpaceLink *sl = sa->spacedata.first; sl; sl= sl->next) {
- switch (sl->spacetype) {
- case SPACE_VIEW3D:
- {
- View3D *v3d = (View3D*) sl;
-
- v3d->camera= newlibadr(fd, sc->id.lib, v3d->camera);
- v3d->ob_centre= newlibadr(fd, sc->id.lib, v3d->ob_centre);
-
- if (v3d->localvd) {
- v3d->localvd->camera = newlibadr(fd, sc->id.lib, v3d->localvd->camera);
- }
- break;
- }
- case SPACE_IPO:
- {
- SpaceIpo *sipo = (SpaceIpo *)sl;
- bDopeSheet *ads = sipo->ads;
-
- if (ads) {
- ads->source = newlibadr(fd, sc->id.lib, ads->source);
- ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp);
- }
- break;
- }
- case SPACE_BUTS:
- {
- SpaceButs *sbuts = (SpaceButs *)sl;
- sbuts->pinid = newlibadr(fd, sc->id.lib, sbuts->pinid);
- if (sbuts->pinid == NULL) {
- sbuts->flag &= ~SB_PIN_CONTEXT;
- }
- break;
- }
- case SPACE_FILE:
- break;
- case SPACE_ACTION:
- {
- SpaceAction *saction = (SpaceAction *)sl;
- bDopeSheet *ads = &saction->ads;
-
- if (ads) {
- ads->source = newlibadr(fd, sc->id.lib, ads->source);
- ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp);
- }
-
- saction->action = newlibadr(fd, sc->id.lib, saction->action);
- break;
- }
- case SPACE_IMAGE:
- {
- SpaceImage *sima = (SpaceImage *)sl;
-
- sima->image = newlibadr_real_us(fd, sc->id.lib, sima->image);
- sima->mask_info.mask = newlibadr_real_us(fd, sc->id.lib, sima->mask_info.mask);
-
- /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
- * so fingers crossed this works fine!
- */
- sima->gpd = newlibadr_us(fd, sc->id.lib, sima->gpd);
- break;
- }
- case SPACE_SEQ:
- {
- SpaceSeq *sseq = (SpaceSeq *)sl;
-
- /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
- * so fingers crossed this works fine!
- */
- sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd);
- break;
- }
- case SPACE_NLA:
- {
- SpaceNla *snla= (SpaceNla *)sl;
- bDopeSheet *ads= snla->ads;
-
- if (ads) {
- ads->source = newlibadr(fd, sc->id.lib, ads->source);
- ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp);
- }
- break;
- }
- case SPACE_TEXT:
- {
- SpaceText *st= (SpaceText *)sl;
-
- st->text= newlibadr(fd, sc->id.lib, st->text);
- break;
- }
- case SPACE_SCRIPT:
- {
- SpaceScript *scpt = (SpaceScript *)sl;
- /*scpt->script = NULL; - 2.45 set to null, better re-run the script */
- if (scpt->script) {
- scpt->script = newlibadr(fd, sc->id.lib, scpt->script);
- if (scpt->script) {
- SCRIPT_SET_NULL(scpt->script);
- }
- }
- break;
- }
- case SPACE_OUTLINER:
- {
- SpaceOops *so= (SpaceOops *)sl;
- so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id);
-
- if (so->treestore) {
- TreeStoreElem *tselem;
- BLI_mempool_iter iter;
-
- BLI_mempool_iternew(so->treestore, &iter);
- while ((tselem = BLI_mempool_iterstep(&iter))) {
- tselem->id = newlibadr(fd, NULL, tselem->id);
- }
- if (so->treehash) {
- /* rebuild hash table, because it depends on ids too */
- so->storeflag |= SO_TREESTORE_REBUILD;
- }
- }
- break;
- }
- case SPACE_NODE:
- {
- SpaceNode *snode = (SpaceNode *)sl;
- bNodeTreePath *path, *path_next;
- bNodeTree *ntree;
-
- /* node tree can be stored locally in id too, link this first */
- snode->id = newlibadr(fd, sc->id.lib, snode->id);
- snode->from = newlibadr(fd, sc->id.lib, snode->from);
-
- ntree = snode->id ? ntreeFromID(snode->id) : NULL;
- snode->nodetree = ntree ? ntree : newlibadr_us(fd, sc->id.lib, snode->nodetree);
-
- for (path = snode->treepath.first; path; path = path->next) {
- if (path == snode->treepath.first) {
- /* first nodetree in path is same as snode->nodetree */
- path->nodetree = snode->nodetree;
- }
- else
- path->nodetree = newlibadr_us(fd, sc->id.lib, path->nodetree);
-
- if (!path->nodetree)
- break;
- }
-
- /* remaining path entries are invalid, remove */
- for (; path; path = path_next) {
- path_next = path->next;
-
- BLI_remlink(&snode->treepath, path);
- MEM_freeN(path);
- }
-
- /* edittree is just the last in the path,
- * set this directly since the path may have been shortened above */
- if (snode->treepath.last) {
- path = snode->treepath.last;
- snode->edittree = path->nodetree;
- }
- else {
- snode->edittree = NULL;
- }
- break;
- }
- case SPACE_CLIP:
- {
- SpaceClip *sclip = (SpaceClip *)sl;
-
- sclip->clip = newlibadr_real_us(fd, sc->id.lib, sclip->clip);
- sclip->mask_info.mask = newlibadr_real_us(fd, sc->id.lib, sclip->mask_info.mask);
- break;
- }
- case SPACE_LOGIC:
- {
- SpaceLogic *slogic = (SpaceLogic *)sl;
-
- slogic->gpd = newlibadr_us(fd, sc->id.lib, slogic->gpd);
- break;
- }
- default:
- break;
- }
- }
+ for (ScrArea *area = sc->areabase.first; area; area = area->next) {
+ lib_link_area(fd, &sc->id, area);
}
sc->id.tag &= ~LIB_TAG_NEED_LINK;
}
@@ -7264,11 +7341,6 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main
sclip->scopes.ok = 0;
}
- else if (sl->spacetype == SPACE_LOGIC) {
- SpaceLogic *slogic = (SpaceLogic *)sl;
-
- slogic->gpd = restore_pointer_by_name(id_map, (ID *)slogic->gpd, USER_REAL);
- }
}
}
}
@@ -7317,74 +7389,6 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene
BKE_main_idmap_destroy(id_map);
}
-static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
-{
- Panel *pa;
- uiList *ui_list;
-
- link_list(fd, &ar->panels);
-
- for (pa = ar->panels.first; pa; pa = pa->next) {
- pa->paneltab = newdataadr(fd, pa->paneltab);
- pa->runtime_flag = 0;
- pa->activedata = NULL;
- pa->type = NULL;
- }
-
- link_list(fd, &ar->panels_category_active);
-
- link_list(fd, &ar->ui_lists);
-
- for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) {
- ui_list->type = NULL;
- ui_list->dyn_data = NULL;
- ui_list->properties = newdataadr(fd, ui_list->properties);
- IDP_DirectLinkGroup_OrFree(&ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- }
-
- link_list(fd, &ar->ui_previews);
-
- if (spacetype == SPACE_EMPTY) {
- /* unkown space type, don't leak regiondata */
- ar->regiondata = NULL;
- }
- else {
- ar->regiondata = newdataadr(fd, ar->regiondata);
- if (ar->regiondata) {
- if (spacetype == SPACE_VIEW3D) {
- RegionView3D *rv3d = ar->regiondata;
-
- rv3d->localvd = newdataadr(fd, rv3d->localvd);
- rv3d->clipbb = newdataadr(fd, rv3d->clipbb);
-
- rv3d->depths = NULL;
- rv3d->gpuoffscreen = NULL;
- rv3d->render_engine = NULL;
- rv3d->sms = NULL;
- rv3d->smooth_timer = NULL;
- rv3d->compositor = NULL;
- rv3d->viewport = NULL;
- }
- }
- }
-
- ar->v2d.tab_offset = NULL;
- ar->v2d.tab_num = 0;
- ar->v2d.tab_cur = 0;
- ar->v2d.sms = NULL;
- BLI_listbase_clear(&ar->panels_category);
- BLI_listbase_clear(&ar->handlers);
- BLI_listbase_clear(&ar->uiblocks);
- ar->headerstr = NULL;
- ar->visible = 0;
- ar->type = NULL;
- ar->swap = 0;
- ar->do_draw = 0;
- ar->manipulator_map = NULL;
- ar->regiontimer = NULL;
- memset(&ar->drawrct, 0, sizeof(ar->drawrct));
-}
-
/* for the saved 2.50 files without regiondata */
/* and as patch for 2.48 and older */
void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
@@ -7405,22 +7409,14 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
}
/* this was not initialized correct always */
- if (v3d->twtype == 0)
- v3d->twtype = V3D_MANIP_TRANSLATE;
if (v3d->gridsubdiv == 0)
v3d->gridsubdiv = 10;
}
static bool direct_link_screen(FileData *fd, bScreen *sc)
{
- ScrArea *sa;
- ScrVert *sv;
- ScrEdge *se;
bool wrong_id = false;
- link_list(fd, &(sc->vertbase));
- link_list(fd, &(sc->edgebase));
- link_list(fd, &(sc->areabase));
sc->regionbase.first = sc->regionbase.last= NULL;
sc->context = NULL;
sc->active_region = NULL;
@@ -7428,274 +7424,11 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
sc->preview = direct_link_preview_image(fd, sc->preview);
- /* edges */
- for (se = sc->edgebase.first; se; se = se->next) {
- se->v1 = newdataadr(fd, se->v1);
- se->v2 = newdataadr(fd, se->v2);
- if ((intptr_t)se->v1 > (intptr_t)se->v2) {
- sv = se->v1;
- se->v1 = se->v2;
- se->v2 = sv;
- }
-
- if (se->v1 == NULL) {
- printf("Error reading Screen %s... removing it.\n", sc->id.name+2);
- BLI_remlink(&sc->edgebase, se);
- wrong_id = true;
- }
+ if (!direct_link_area_map(fd, AREAMAP_FROM_SCREEN(sc))) {
+ printf("Error reading Screen %s... removing it.\n", sc->id.name + 2);
+ wrong_id = true;
}
-
- /* areas */
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- ARegion *ar;
-
- link_list(fd, &(sa->spacedata));
- link_list(fd, &(sa->regionbase));
-
- BLI_listbase_clear(&sa->handlers);
- sa->type = NULL; /* spacetype callbacks */
- sa->region_active_win = -1;
-
- /* if we do not have the spacetype registered (game player), we cannot
- * free it, so don't allocate any new memory for such spacetypes. */
- if (!BKE_spacetype_exists(sa->spacetype))
- sa->spacetype = SPACE_EMPTY;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- direct_link_region(fd, ar, sa->spacetype);
-
- /* accident can happen when read/save new file with older version */
- /* 2.50: we now always add spacedata for info */
- if (sa->spacedata.first==NULL) {
- SpaceInfo *sinfo= MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
- sa->spacetype= sinfo->spacetype= SPACE_INFO;
- BLI_addtail(&sa->spacedata, sinfo);
- }
- /* add local view3d too */
- else if (sa->spacetype == SPACE_VIEW3D)
- blo_do_versions_view3d_split_250(sa->spacedata.first, &sa->regionbase);
- /* incase we set above */
- sa->butspacetype = sa->spacetype;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- link_list(fd, &(sl->regionbase));
-
- /* if we do not have the spacetype registered (game player), we cannot
- * free it, so don't allocate any new memory for such spacetypes. */
- if (!BKE_spacetype_exists(sl->spacetype))
- sl->spacetype = SPACE_EMPTY;
-
- for (ar = sl->regionbase.first; ar; ar = ar->next)
- direct_link_region(fd, ar, sl->spacetype);
-
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d= (View3D*) sl;
- v3d->flag |= V3D_INVALID_BACKBUF;
-
- if (v3d->gpd) {
- v3d->gpd = newdataadr(fd, v3d->gpd);
- direct_link_gpencil(fd, v3d->gpd);
- }
- v3d->localvd = newdataadr(fd, v3d->localvd);
- BLI_listbase_clear(&v3d->afterdraw_transp);
- BLI_listbase_clear(&v3d->afterdraw_xray);
- BLI_listbase_clear(&v3d->afterdraw_xraytransp);
- v3d->properties_storage = NULL;
- v3d->defmaterial = NULL;
-
- /* render can be quite heavy, set to solid on load */
- if (v3d->drawtype == OB_RENDER)
- v3d->drawtype = OB_SOLID;
- v3d->prev_drawtype = OB_SOLID;
-
- if (v3d->fx_settings.dof)
- v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof);
- if (v3d->fx_settings.ssao)
- v3d->fx_settings.ssao = newdataadr(fd, v3d->fx_settings.ssao);
-
- blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
- }
- else if (sl->spacetype == SPACE_IPO) {
- SpaceIpo *sipo = (SpaceIpo *)sl;
-
- sipo->ads = newdataadr(fd, sipo->ads);
- BLI_listbase_clear(&sipo->ghostCurves);
- }
- else if (sl->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)sl;
-
- snla->ads = newdataadr(fd, snla->ads);
- }
- else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOops *soops = (SpaceOops *) sl;
-
- /* use newdataadr_no_us and do not free old memory avoiding double
- * frees and use of freed memory. this could happen because of a
- * bug fixed in revision 58959 where the treestore memory address
- * was not unique */
- TreeStore *ts = newdataadr_no_us(fd, soops->treestore);
- soops->treestore = NULL;
- if (ts) {
- TreeStoreElem *elems = newdataadr_no_us(fd, ts->data);
-
- soops->treestore = BLI_mempool_create(sizeof(TreeStoreElem), ts->usedelem,
- 512, BLI_MEMPOOL_ALLOW_ITER);
- if (ts->usedelem && elems) {
- int i;
- for (i = 0; i < ts->usedelem; i++) {
- TreeStoreElem *new_elem = BLI_mempool_alloc(soops->treestore);
- *new_elem = elems[i];
- }
- }
- /* we only saved what was used */
- soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
- }
- soops->treehash = NULL;
- soops->tree.first = soops->tree.last= NULL;
- }
- else if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
-
- sima->iuser.scene = NULL;
- sima->iuser.ok = 1;
- sima->scopes.waveform_1 = NULL;
- sima->scopes.waveform_2 = NULL;
- sima->scopes.waveform_3 = NULL;
- sima->scopes.vecscope = NULL;
- sima->scopes.ok = 0;
-
- /* WARNING: gpencil data is no longer stored directly in sima after 2.5
- * so sacrifice a few old files for now to avoid crashes with new files!
- * committed: r28002 */
-#if 0
- sima->gpd = newdataadr(fd, sima->gpd);
- if (sima->gpd)
- direct_link_gpencil(fd, sima->gpd);
-#endif
- }
- else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
-
- if (snode->gpd) {
- snode->gpd = newdataadr(fd, snode->gpd);
- direct_link_gpencil(fd, snode->gpd);
- }
-
- link_list(fd, &snode->treepath);
- snode->edittree = NULL;
- snode->iofsd = NULL;
- BLI_listbase_clear(&snode->linkdrag);
- }
- else if (sl->spacetype == SPACE_TEXT) {
- SpaceText *st= (SpaceText *)sl;
-
- st->drawcache = NULL;
- st->scroll_accum[0] = 0.0f;
- st->scroll_accum[1] = 0.0f;
- }
- else if (sl->spacetype == SPACE_TIME) {
- SpaceTime *stime = (SpaceTime *)sl;
- BLI_listbase_clear(&stime->caches);
- }
- else if (sl->spacetype == SPACE_LOGIC) {
- SpaceLogic *slogic = (SpaceLogic *)sl;
-
- /* XXX: this is new stuff, which shouldn't be directly linking to gpd... */
- if (slogic->gpd) {
- slogic->gpd = newdataadr(fd, slogic->gpd);
- direct_link_gpencil(fd, slogic->gpd);
- }
- }
- else if (sl->spacetype == SPACE_SEQ) {
- SpaceSeq *sseq = (SpaceSeq *)sl;
-
- /* grease pencil data is not a direct data and can't be linked from direct_link*
- * functions, it should be linked from lib_link* functions instead
- *
- * otherwise it'll lead to lost grease data on open because it'll likely be
- * read from file after all other users of grease pencil and newdataadr would
- * simple return NULL here (sergey)
- */
-#if 0
- if (sseq->gpd) {
- sseq->gpd = newdataadr(fd, sseq->gpd);
- direct_link_gpencil(fd, sseq->gpd);
- }
-#endif
- sseq->scopes.reference_ibuf = NULL;
- sseq->scopes.zebra_ibuf = NULL;
- sseq->scopes.waveform_ibuf = NULL;
- sseq->scopes.sep_waveform_ibuf = NULL;
- sseq->scopes.vector_ibuf = NULL;
- sseq->scopes.histogram_ibuf = NULL;
- sseq->compositor = NULL;
- }
- else if (sl->spacetype == SPACE_BUTS) {
- SpaceButs *sbuts = (SpaceButs *)sl;
-
- sbuts->path= NULL;
- sbuts->texuser= NULL;
- sbuts->mainbo = sbuts->mainb;
- sbuts->mainbuser = sbuts->mainb;
- }
- else if (sl->spacetype == SPACE_CONSOLE) {
- SpaceConsole *sconsole = (SpaceConsole *)sl;
- ConsoleLine *cl, *cl_next;
-
- link_list(fd, &sconsole->scrollback);
- link_list(fd, &sconsole->history);
-
- //for (cl= sconsole->scrollback.first; cl; cl= cl->next)
- // cl->line= newdataadr(fd, cl->line);
-
- /* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
- * from left to right. the right-most expression sets the result of the comma
- * expression as a whole*/
- for (cl = sconsole->history.first; cl; cl = cl_next) {
- cl_next = cl->next;
- cl->line = newdataadr(fd, cl->line);
- if (cl->line) {
- /* the allocted length is not written, so reset here */
- cl->len_alloc = cl->len + 1;
- }
- else {
- BLI_remlink(&sconsole->history, cl);
- MEM_freeN(cl);
- }
- }
- }
- else if (sl->spacetype == SPACE_FILE) {
- SpaceFile *sfile = (SpaceFile *)sl;
-
- /* this sort of info is probably irrelevant for reloading...
- * plus, it isn't saved to files yet!
- */
- sfile->folders_prev = sfile->folders_next = NULL;
- sfile->files = NULL;
- sfile->layout = NULL;
- sfile->op = NULL;
- sfile->previews_timer = NULL;
- sfile->params = newdataadr(fd, sfile->params);
- }
- else if (sl->spacetype == SPACE_CLIP) {
- SpaceClip *sclip = (SpaceClip *)sl;
-
- sclip->scopes.track_search = NULL;
- sclip->scopes.track_preview = NULL;
- sclip->scopes.ok = 0;
- }
- }
-
- BLI_listbase_clear(&sa->actionzones);
-
- sa->v1 = newdataadr(fd, sa->v1);
- sa->v2 = newdataadr(fd, sa->v2);
- sa->v3 = newdataadr(fd, sa->v3);
- sa->v4 = newdataadr(fd, sa->v4);
- }
-
return wrong_id;
}
@@ -7976,7 +7709,7 @@ static void direct_link_moviePlaneTracks(FileData *fd, ListBase *plane_tracks_ba
int i;
plane_track->point_tracks = newdataadr(fd, plane_track->point_tracks);
- test_pointer_array(fd, (void**)&plane_track->point_tracks);
+ test_pointer_array(fd, (void **)&plane_track->point_tracks);
for (i = 0; i < plane_track->point_tracksnr; i++) {
plane_track->point_tracks[i] = newdataadr(fd, plane_track->point_tracks[i]);
}
@@ -9660,15 +9393,6 @@ static void expand_brush(FileData *fd, Main *mainvar, Brush *brush)
static void expand_material(FileData *fd, Main *mainvar, Material *ma)
{
- int a;
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- expand_doit(fd, mainvar, ma->mtex[a]->tex);
- expand_doit(fd, mainvar, ma->mtex[a]->object);
- }
- }
-
expand_doit(fd, mainvar, ma->ipo); // XXX deprecated - old animation system
if (ma->adt)
@@ -9676,26 +9400,10 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma)
if (ma->nodetree)
expand_nodetree(fd, mainvar, ma->nodetree);
-
- if (ma->group)
- expand_doit(fd, mainvar, ma->group);
-
- if (ma->edit_image) {
- expand_doit(fd, mainvar, ma->edit_image);
- }
}
static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la)
{
- int a;
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (la->mtex[a]) {
- expand_doit(fd, mainvar, la->mtex[a]->tex);
- expand_doit(fd, mainvar, la->mtex[a]->object);
- }
- }
-
expand_doit(fd, mainvar, la->ipo); // XXX deprecated - old animation system
if (la->adt)
@@ -9717,15 +9425,6 @@ static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt)
static void expand_world(FileData *fd, Main *mainvar, World *wrld)
{
- int a;
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (wrld->mtex[a]) {
- expand_doit(fd, mainvar, wrld->mtex[a]->tex);
- expand_doit(fd, mainvar, wrld->mtex[a]->object);
- }
- }
-
expand_doit(fd, mainvar, wrld->ipo); // XXX deprecated - old animation system
if (wrld->adt)
@@ -9862,9 +9561,6 @@ static void expand_object_expandModifiers(
static void expand_object(FileData *fd, Main *mainvar, Object *ob)
{
ParticleSystem *psys;
- bSensor *sens;
- bController *cont;
- bActuator *act;
bActionStrip *strip;
PartEff *paf;
int a;
@@ -9921,84 +9617,6 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
for (psys = ob->particlesystem.first; psys; psys = psys->next)
expand_doit(fd, mainvar, psys->part);
- for (sens = ob->sensors.first; sens; sens = sens->next) {
- if (sens->type == SENS_MESSAGE) {
- bMessageSensor *ms = sens->data;
- expand_doit(fd, mainvar, ms->fromObject);
- }
- }
-
- for (cont = ob->controllers.first; cont; cont = cont->next) {
- if (cont->type == CONT_PYTHON) {
- bPythonCont *pc = cont->data;
- expand_doit(fd, mainvar, pc->text);
- }
- }
-
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_SOUND) {
- bSoundActuator *sa = act->data;
- expand_doit(fd, mainvar, sa->sound);
- }
- else if (act->type == ACT_CAMERA) {
- bCameraActuator *ca = act->data;
- expand_doit(fd, mainvar, ca->ob);
- }
- else if (act->type == ACT_EDIT_OBJECT) {
- bEditObjectActuator *eoa = act->data;
- if (eoa) {
- expand_doit(fd, mainvar, eoa->ob);
- expand_doit(fd, mainvar, eoa->me);
- }
- }
- else if (act->type == ACT_OBJECT) {
- bObjectActuator *oa = act->data;
- expand_doit(fd, mainvar, oa->reference);
- }
- else if (act->type == ACT_ADD_OBJECT) {
- bAddObjectActuator *aoa = act->data;
- expand_doit(fd, mainvar, aoa->ob);
- }
- else if (act->type == ACT_SCENE) {
- bSceneActuator *sa = act->data;
- expand_doit(fd, mainvar, sa->camera);
- expand_doit(fd, mainvar, sa->scene);
- }
- else if (act->type == ACT_2DFILTER) {
- bTwoDFilterActuator *tdfa = act->data;
- expand_doit(fd, mainvar, tdfa->text);
- }
- else if (act->type == ACT_ACTION) {
- bActionActuator *aa = act->data;
- expand_doit(fd, mainvar, aa->act);
- }
- else if (act->type == ACT_SHAPEACTION) {
- bActionActuator *aa = act->data;
- expand_doit(fd, mainvar, aa->act);
- }
- else if (act->type == ACT_PROPERTY) {
- bPropertyActuator *pa = act->data;
- expand_doit(fd, mainvar, pa->ob);
- }
- else if (act->type == ACT_MESSAGE) {
- bMessageActuator *ma = act->data;
- expand_doit(fd, mainvar, ma->toObject);
- }
- else if (act->type==ACT_PARENT) {
- bParentActuator *pa = act->data;
- expand_doit(fd, mainvar, pa->ob);
- }
- else if (act->type == ACT_ARMATURE) {
- bArmatureActuator *arma = act->data;
- expand_doit(fd, mainvar, arma->target);
- }
- else if (act->type == ACT_STEERING) {
- bSteeringActuator *sta = act->data;
- expand_doit(fd, mainvar, sta->target);
- expand_doit(fd, mainvar, sta->navmesh);
- }
- }
-
if (ob->pd) {
expand_doit(fd, mainvar, ob->pd->tex);
expand_doit(fd, mainvar, ob->pd->f_source);
@@ -10108,9 +9726,6 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
}
}
- if (sce->r.dometext)
- expand_doit(fd, mainvar, sce->gm.dome.warptext);
-
if (sce->gpd)
expand_doit(fd, mainvar, sce->gpd);
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index f5a4a33860f..2610f57f124 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -39,7 +39,6 @@
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_brush_types.h"
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
@@ -84,7 +83,6 @@
#include "BKE_sequencer.h"
#include "BKE_texture.h"
#include "BKE_sound.h"
-#include "BKE_sca.h"
#include "NOD_socket.h"
@@ -287,19 +285,6 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
//ar->v2d.flag |= V2D_IS_INITIALISED;
}
break;
- case SPACE_TIME:
- {
- SpaceTime *stime = (SpaceTime *)sl;
- memcpy(&ar->v2d, &stime->v2d, sizeof(View2D));
-
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
- ar->v2d.keepofs |= V2D_LOCKOFS_Y;
- ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
- ar->v2d.tot.ymin = ar->v2d.cur.ymin = -10.0;
- ar->v2d.min[1] = ar->v2d.max[1] = 20.0;
- }
- break;
case SPACE_IPO:
{
SpaceIpo *sipo = (SpaceIpo *)sl;
@@ -517,70 +502,6 @@ static void do_versions_gpencil_2_50(Main *main, bScreen *screen)
}
}
-static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype)
-{
- MTex *mtex;
- float varfac, colfac;
- int a, neg;
-
- if (!mtex_array)
- return;
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (mtex_array[a]) {
- mtex = mtex_array[a];
-
- neg = mtex->maptoneg;
- varfac = mtex->varfac;
- colfac = mtex->colfac;
-
- if (neg & MAP_DISP) mtex->dispfac = -mtex->dispfac;
- if (neg & MAP_NORM) mtex->norfac = -mtex->norfac;
- if (neg & MAP_WARP) mtex->warpfac = -mtex->warpfac;
-
- mtex->colspecfac = (neg & MAP_COLSPEC)? -colfac: colfac;
- mtex->mirrfac = (neg & MAP_COLMIR)? -colfac: colfac;
- mtex->alphafac = (neg & MAP_ALPHA)? -varfac: varfac;
- mtex->difffac = (neg & MAP_REF)? -varfac: varfac;
- mtex->specfac = (neg & MAP_SPEC)? -varfac: varfac;
- mtex->emitfac = (neg & MAP_EMIT)? -varfac: varfac;
- mtex->hardfac = (neg & MAP_HAR)? -varfac: varfac;
- mtex->raymirrfac = (neg & MAP_RAYMIRR)? -varfac: varfac;
- mtex->translfac = (neg & MAP_TRANSLU)? -varfac: varfac;
- mtex->ambfac = (neg & MAP_AMB)? -varfac: varfac;
- mtex->colemitfac = (neg & MAP_EMISSION_COL)? -colfac: colfac;
- mtex->colreflfac = (neg & MAP_REFLECTION_COL)? -colfac: colfac;
- mtex->coltransfac = (neg & MAP_TRANSMISSION_COL)? -colfac: colfac;
- mtex->densfac = (neg & MAP_DENSITY)? -varfac: varfac;
- mtex->scatterfac = (neg & MAP_SCATTERING)? -varfac: varfac;
- mtex->reflfac = (neg & MAP_REFLECTION)? -varfac: varfac;
-
- mtex->timefac = (neg & MAP_PA_TIME)? -varfac: varfac;
- mtex->lengthfac = (neg & MAP_PA_LENGTH)? -varfac: varfac;
- mtex->clumpfac = (neg & MAP_PA_CLUMP)? -varfac: varfac;
- mtex->kinkfac = (neg & MAP_PA_KINK)? -varfac: varfac;
- mtex->roughfac = (neg & MAP_PA_ROUGH)? -varfac: varfac;
- mtex->padensfac = (neg & MAP_PA_DENS)? -varfac: varfac;
- mtex->lifefac = (neg & MAP_PA_LIFE)? -varfac: varfac;
- mtex->sizefac = (neg & MAP_PA_SIZE)? -varfac: varfac;
- mtex->ivelfac = (neg & MAP_PA_IVEL)? -varfac: varfac;
-
- mtex->shadowfac = (neg & LAMAP_SHAD)? -colfac: colfac;
-
- mtex->zenupfac = (neg & WOMAP_ZENUP)? -colfac: colfac;
- mtex->zendownfac = (neg & WOMAP_ZENDOWN)? -colfac: colfac;
- mtex->blendfac = (neg & WOMAP_BLEND)? -varfac: varfac;
-
- if (idtype == ID_MA)
- mtex->colfac = (neg & MAP_COL)? -colfac: colfac;
- else if (idtype == ID_LA)
- mtex->colfac = (neg & LAMAP_COL)? -colfac: colfac;
- else if (idtype == ID_WO)
- mtex->colfac = (neg & WOMAP_HORIZ)? -colfac: colfac;
- }
- }
-}
-
static void do_version_mdef_250(Main *main)
{
Object *ob;
@@ -610,13 +531,7 @@ static void do_version_constraints_radians_degrees_250(ListBase *lb)
bConstraint *con;
for (con = lb->first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) {
- bRigidBodyJointConstraint *data = con->data;
- data->axX *= (float)(M_PI / 180.0);
- data->axY *= (float)(M_PI / 180.0);
- data->axZ *= (float)(M_PI / 180.0);
- }
- else if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = con->data;
data->poleangle *= (float)(M_PI / 180.0);
}
@@ -750,8 +665,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
bSound *sound;
Sequence *seq;
- bActuator *act;
- int a;
for (sound = main->sound.first; sound; sound = sound->id.next) {
if (sound->newpackedfile) {
@@ -760,33 +673,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- for (ob = main->object.first; ob; ob = ob->id.next) {
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_SOUND) {
- bSoundActuator *sAct = (bSoundActuator*) act->data;
- if (sAct->sound) {
- sound = blo_do_versions_newlibadr(fd, lib, sAct->sound);
- sAct->flag = (sound->flags & SOUND_FLAGS_3D) ? ACT_SND_3D_SOUND : 0;
- sAct->pitch = sound->pitch;
- sAct->volume = sound->volume;
- sAct->sound3D.reference_distance = sound->distance;
- sAct->sound3D.max_gain = sound->max_gain;
- sAct->sound3D.min_gain = sound->min_gain;
- sAct->sound3D.rolloff_factor = sound->attenuation;
- }
- else {
- sAct->sound3D.reference_distance = 1.0f;
- sAct->volume = 1.0f;
- sAct->sound3D.max_gain = 1.0f;
- sAct->sound3D.rolloff_factor = 1.0f;
- }
- sAct->sound3D.cone_inner_angle = 360.0f;
- sAct->sound3D.cone_outer_angle = 360.0f;
- sAct->sound3D.max_distance = FLT_MAX;
- }
- }
- }
-
for (scene = main->scene.first; scene; scene = scene->id.next) {
if (scene->ed && scene->ed->seqbasep) {
SEQ_BEGIN (scene->ed, seq)
@@ -823,15 +709,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
for (ma = main->mat.first; ma; ma = ma->id.next) {
if (ma->nodetree && ma->nodetree->id.name[0] == '\0')
strcpy(ma->nodetree->id.name, "NTShader Nodetree");
-
- /* which_output 0 is now "not specified" */
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- tx = blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex);
- if (tx && tx->use_nodes)
- ma->mtex[a]->which_output++;
- }
- }
}
/* and composite trees */
@@ -917,7 +794,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) {
Object *ob;
- Material *ma;
Tex *tex;
Scene *sce;
ToolSettings *ts;
@@ -963,61 +839,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
tex->afmax = 8;
}
- for (ma = main->mat.first; ma; ma = ma->id.next) {
- int a;
-
- if (ma->mode & MA_WIRE) {
- ma->material_type = MA_TYPE_WIRE;
- ma->mode &= ~MA_WIRE;
- }
-
- if (ma->mode & MA_HALO) {
- ma->material_type = MA_TYPE_HALO;
- ma->mode &= ~MA_HALO;
- }
-
- if (ma->mode & (MA_ZTRANSP|MA_RAYTRANSP)) {
- ma->mode |= MA_TRANSP;
- }
- else {
- /* ma->mode |= MA_ZTRANSP; */ /* leave ztransp as is even if its not used [#28113] */
- ma->mode &= ~MA_TRANSP;
- }
-
- /* set new bump for unused slots */
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- tex = ma->mtex[a]->tex;
- if (!tex) {
- ma->mtex[a]->texflag |= MTEX_3TAP_BUMP;
- ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE;
- }
- else {
- tex = (Tex*) blo_do_versions_newlibadr(fd, ma->id.lib, tex);
- if (tex && tex->type == 0) { /* invalid type */
- ma->mtex[a]->texflag |= MTEX_3TAP_BUMP;
- ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE;
- }
- }
- }
- }
-
- /* volume rendering settings */
- if (ma->vol.stepsize < 0.0001f) {
- ma->vol.density = 1.0f;
- ma->vol.emission = 0.0f;
- ma->vol.scattering = 1.0f;
- ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f;
- ma->vol.density_scale = 1.0f;
- ma->vol.depth_cutoff = 0.01f;
- ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED;
- ma->vol.stepsize = 0.2f;
- ma->vol.shade_type = MA_VOL_SHADE_SHADED;
- ma->vol.shadeflag |= MA_VOL_PRECACHESHADING;
- ma->vol.precache_resolution = 50;
- }
- }
-
for (sce = main->scene.first; sce; sce = sce->id.next) {
ts = sce->toolsettings;
if (ts->normalsize == 0.0f || !ts->uv_selectmode || ts->vgroup_weight == 0.0f) {
@@ -1034,93 +855,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
ts->uv_selectmode = UV_SELECT_VERTEX;
ts->vgroup_weight = 1.0f;
}
-
- /* Game Settings */
- /* Dome */
- sce->gm.dome.angle = sce->r.domeangle;
- sce->gm.dome.mode = sce->r.domemode;
- sce->gm.dome.res = sce->r.domeres;
- sce->gm.dome.resbuf = sce->r.domeresbuf;
- sce->gm.dome.tilt = sce->r.dometilt;
- sce->gm.dome.warptext = sce->r.dometext;
-
- /* Stand Alone */
- sce->gm.playerflag |= (sce->r.fullscreen ? GAME_PLAYER_FULLSCREEN : 0);
- sce->gm.xplay = sce->r.xplay;
- sce->gm.yplay = sce->r.yplay;
- sce->gm.freqplay = sce->r.freqplay;
- sce->gm.depth = sce->r.depth;
- sce->gm.attrib = sce->r.attrib;
-
- /* Stereo */
- sce->gm.stereomode = sce->r.stereomode;
- /* reassigning stereomode NO_STEREO and DOME to a separeted flag*/
- if (sce->gm.stereomode == 1) { // 1 = STEREO_NOSTEREO
- sce->gm.stereoflag = STEREO_NOSTEREO;
- sce->gm.stereomode = STEREO_ANAGLYPH;
- }
- else if (sce->gm.stereomode == 8) { // 8 = STEREO_DOME
- sce->gm.stereoflag = STEREO_DOME;
- sce->gm.stereomode = STEREO_ANAGLYPH;
- }
- else
- sce->gm.stereoflag = STEREO_ENABLED;
-
- /* Framing */
- sce->gm.framing = sce->framing;
- sce->gm.xplay = sce->r.xplay;
- sce->gm.yplay = sce->r.yplay;
- sce->gm.freqplay = sce->r.freqplay;
- sce->gm.depth = sce->r.depth;
-
- /* Physic (previously stored in world) */
- sce->gm.gravity =9.8f;
- sce->gm.physicsEngine = WOPHY_BULLET; /* Bullet by default */
- sce->gm.mode = WO_DBVT_CULLING; /* DBVT culling by default */
- sce->gm.occlusionRes = 128;
- sce->gm.ticrate = 60;
- sce->gm.maxlogicstep = 5;
- sce->gm.physubstep = 1;
- sce->gm.maxphystep = 5;
}
}
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) {
- Scene *sce;
Object *ob;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- if (fd->fileflags & G_FILE_ENABLE_ALL_FRAMES)
- sce->gm.flag |= GAME_ENABLE_ALL_FRAMES;
- if (fd->fileflags & G_FILE_SHOW_DEBUG_PROPS)
- sce->gm.flag |= GAME_SHOW_DEBUG_PROPS;
- if (fd->fileflags & G_FILE_SHOW_FRAMERATE)
- sce->gm.flag |= GAME_SHOW_FRAMERATE;
- if (fd->fileflags & G_FILE_SHOW_PHYSICS)
- sce->gm.flag |= GAME_SHOW_PHYSICS;
- if (fd->fileflags & G_FILE_GLSL_NO_SHADOWS)
- sce->gm.flag |= GAME_GLSL_NO_SHADOWS;
- if (fd->fileflags & G_FILE_GLSL_NO_SHADERS)
- sce->gm.flag |= GAME_GLSL_NO_SHADERS;
- if (fd->fileflags & G_FILE_GLSL_NO_RAMPS)
- sce->gm.flag |= GAME_GLSL_NO_RAMPS;
- if (fd->fileflags & G_FILE_GLSL_NO_NODES)
- sce->gm.flag |= GAME_GLSL_NO_NODES;
- if (fd->fileflags & G_FILE_GLSL_NO_EXTRA_TEX)
- sce->gm.flag |= GAME_GLSL_NO_EXTRA_TEX;
- if (fd->fileflags & G_FILE_GLSL_NO_ENV_LIGHTING)
- sce->gm.flag |= GAME_GLSL_NO_ENV_LIGHTING;
- if (fd->fileflags & G_FILE_IGNORE_DEPRECATION_WARNINGS)
- sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS;
-
- if (fd->fileflags & G_FILE_GAME_MAT_GLSL)
- sce->gm.matmode = GAME_MAT_GLSL;
- else if (fd->fileflags & G_FILE_GAME_MAT)
- sce->gm.matmode = GAME_MAT_MULTITEX;
- else
- sce->gm.matmode = GAME_MAT_TEXFACE;
- }
-
for (ob = main->object.first; ob; ob = ob->id.next) {
if (ob->flag & 8192) // OB_POSEMODE = 8192
ob->mode |= OB_MODE_POSE;
@@ -1130,10 +870,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 4)) {
Scene *sce;
Object *ob;
- Material *ma;
- Lamp *la;
- World *wo;
- Tex *tex;
ParticleSettings *part;
bool do_gravity = false;
@@ -1151,27 +887,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
ob->rotmode = ROT_MODE_EUL;
}
- for (ma = main->mat.first; ma; ma = ma->id.next) {
- if (ma->vol.reflection == 0.f) {
- ma->vol.reflection = 1.f;
- ma->vol.transmission_col[0] = ma->vol.transmission_col[1] = ma->vol.transmission_col[2] = 1.0f;
- ma->vol.reflection_col[0] = ma->vol.reflection_col[1] = ma->vol.reflection_col[2] = 1.0f;
- }
-
- do_version_mtex_factor_2_50(ma->mtex, ID_MA);
- }
-
- for (la = main->lamp.first; la; la = la->id.next)
- do_version_mtex_factor_2_50(la->mtex, ID_LA);
-
- for (wo = main->world.first; wo; wo = wo->id.next)
- do_version_mtex_factor_2_50(wo->mtex, ID_WO);
-
- for (tex = main->tex.first; tex; tex = tex->id.next)
- if (tex->vd)
- if (tex->vd->extend == 0)
- tex->vd->extend = TEX_CLIP;
-
for (sce = main->scene.first; sce; sce = sce->id.next) {
if (sce->audio.main == 0.0f)
sce->audio.main = 1.0f;
@@ -1232,7 +947,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 6)) {
Object *ob;
- Lamp *la;
/* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */
for (ob = main->object.first; ob; ob = ob->id.next) {
@@ -1250,9 +964,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
}
-
- for (la = main->lamp.first; la; la = la->id.next)
- la->compressthresh = 0.05f;
}
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 7)) {
@@ -1321,8 +1032,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
while (sce) {
if (sce->r.frame_step == 0)
sce->r.frame_step = 1;
- if (sce->r.mblur_samples == 0)
- sce->r.mblur_samples = sce->r.osa;
if (sce->ed && sce->ed->seqbase.first) {
do_versions_seq_unique_name_all_strips(sce, &sce->ed->seqbase);
@@ -1379,7 +1088,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
if (main->versionfile == 250) {
Scene *sce = main->scene.first;
Material *ma = main->mat.first;
- World *wo = main->world.first;
Tex *tex = main->tex.first;
int i, convert = 0;
@@ -1397,26 +1105,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
if (convert) {
while (ma) {
- if (ma->ramp_col) {
- ColorBand *band = (ColorBand *)ma->ramp_col;
- for (i = 0; i < band->tot; i++) {
- CBData *data = band->data + i;
- srgb_to_linearrgb_v3_v3(&data->r, &data->r);
- }
- }
-
- if (ma->ramp_spec) {
- ColorBand *band = (ColorBand *)ma->ramp_spec;
- for (i = 0; i < band->tot; i++) {
- CBData *data = band->data + i;
- srgb_to_linearrgb_v3_v3(&data->r, &data->r);
- }
- }
-
srgb_to_linearrgb_v3_v3(&ma->r, &ma->r);
srgb_to_linearrgb_v3_v3(&ma->specr, &ma->specr);
- srgb_to_linearrgb_v3_v3(&ma->mirr, &ma->mirr);
- srgb_to_linearrgb_v3_v3(ma->sss_col, ma->sss_col);
ma = ma->id.next;
}
@@ -1430,13 +1120,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
tex = tex->id.next;
}
-
- while (wo) {
- srgb_to_linearrgb_v3_v3(&wo->ambr, &wo->ambr);
- srgb_to_linearrgb_v3_v3(&wo->horr, &wo->horr);
- srgb_to_linearrgb_v3_v3(&wo->zenr, &wo->zenr);
- wo = wo->id.next;
- }
}
}
}
@@ -1565,15 +1248,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 12)) {
- Scene *sce;
Object *ob;
Brush *brush;
- Material *ma;
-
- /* game engine changes */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- sce->gm.eyeseparation = 0.10f;
- }
/* anim viz changes */
for (ob = main->object.first; ob; ob = ob->id.next) {
@@ -1655,14 +1331,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
BKE_texture_mtex_default(&brush->mtex);
BKE_texture_mtex_default(&brush->mask_mtex);
}
-
- for (ma = main->mat.first; ma; ma = ma->id.next) {
- if (ma->vol.ms_spread < 0.0001f) {
- ma->vol.ms_spread = 0.2f;
- ma->vol.ms_diff = 1.f;
- ma->vol.ms_intensity = 1.f;
- }
- }
}
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) {
@@ -1721,41 +1389,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 15)) {
- World *wo;
- Material *ma;
-
- /* ambient default from 0.5f to 1.0f */
- for (ma = main->mat.first; ma; ma = ma->id.next)
- ma->amb *= 2.0f;
-
- for (wo = main->world.first; wo; wo = wo->id.next) {
- /* ao splitting into ao/env/indirect */
- wo->ao_env_energy = wo->aoenergy;
- wo->aoenergy = 1.0f;
-
- if (wo->ao_indirect_bounces == 0)
- wo->ao_indirect_bounces = 1;
- else
- wo->mode |= WO_INDIRECT_LIGHT;
-
- if (wo->aomix == WO_AOSUB)
- wo->ao_env_energy = -wo->ao_env_energy;
- else if (wo->aomix == WO_AOADDSUB)
- wo->mode |= WO_AMB_OCC;
-
- wo->aomix = WO_AOMUL;
-
- /* ambient default from 0.5f to 1.0f */
- mul_v3_fl(&wo->ambr, 0.5f);
- wo->ao_env_energy *= 0.5f;
- }
- }
-
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17)) {
Scene *sce;
Sequence *seq;
- Material *ma;
/* initialize to sane default so toggling on border shows something */
for (sce = main->scene.first; sce; sce = sce->id.next) {
@@ -1787,10 +1423,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
pset->brush[a].strength /= 100.0f;
}
- for (ma = main->mat.first; ma; ma = ma->id.next)
- if (ma->mode & MA_TRACEBLE)
- ma->shade_flag |= MA_APPROX_OCCLUSION;
-
/* sequencer changes */
{
bScreen *screen;
@@ -1968,14 +1600,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
}
- else if (sl->spacetype == SPACE_TIME) {
- SpaceTime *stime = (SpaceTime *) sl;
-
- /* enable all cache display */
- stime->cache_display |= TIME_CACHE_DISPLAY;
- stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES);
- stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT);
- }
}
}
}
@@ -2195,7 +1819,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
Brush *br;
ParticleSettings *part;
bScreen *sc;
- Object *ob;
for (br = main->brush.first; br; br = br->id.next) {
if (br->ob_mode == 0)
@@ -2235,41 +1858,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
}
-
- /* fix rotation actuators for objects so they use real angles (radians)
- * since before blender went opensource this strange scalar was used: (1 / 0.02) * 2 * math.pi/360 */
- for (ob = main->object.first; ob; ob = ob->id.next) {
- bActuator *act = ob->actuators.first;
- while (act) {
- if (act->type == ACT_OBJECT) {
- /* multiply velocity with 50 in old files */
- bObjectActuator *oa = act->data;
- mul_v3_fl(oa->drot, 0.8726646259971648f);
- }
- act = act->next;
- }
- }
- }
-
- /* init facing axis property of steering actuators */
- {
- Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- bActuator *act;
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_STEERING) {
- bSteeringActuator *stact = act->data;
- if (stact == NULL) {//HG1
- init_actuator(act);
- }
- else {
- if (stact->facingaxis == 0) {
- stact->facingaxis = 1;
- }
- }
- }
- }
- }
}
if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) {
@@ -2428,27 +2016,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
Brush *brush;
Object *ob;
ParticleSettings *part;
- Material *mat;
- int tex_nr, transp_tex;
-
- for (mat = main->mat.first; mat; mat = mat->id.next) {
- if (!(mat->mode & MA_TRANSP) && !(mat->material_type & MA_TYPE_VOLUME)) {
- transp_tex = 0;
-
- for (tex_nr = 0; tex_nr < MAX_MTEX; tex_nr++) {
- if (!mat->mtex[tex_nr])
- continue;
- if (mat->mtex[tex_nr]->mapto & MAP_ALPHA)
- transp_tex = 1;
- }
-
- /* weak! material alpha could be animated */
- if (mat->alpha < 1.0f || mat->fresnel_tra > 0.0f || transp_tex) {
- mat->mode |= MA_TRANSP;
- mat->mode &= ~(MA_ZTRANSP|MA_RAYTRANSP);
- }
- }
- }
/* redraws flag in SpaceTime has been moved to Screen level */
for (sc = main->screen.first; sc; sc = sc->id.next) {
@@ -2542,41 +2109,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
{
- /* Initialize texture point density curve falloff */
- Tex *tex;
- for (tex = main->tex.first; tex; tex = tex->id.next) {
- if (tex->pd) {
- if (tex->pd->falloff_speed_scale == 0.0f)
- tex->pd->falloff_speed_scale = 100.0f;
-
- if (!tex->pd->falloff_curve) {
- tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1);
-
- tex->pd->falloff_curve->preset = CURVE_PRESET_LINE;
- tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
- curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
- curvemapping_changed(tex->pd->falloff_curve, false);
- }
- }
- }
- }
-
- {
- /* add default value for behind strength of camera actuator */
- Object *ob;
- bActuator *act;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_CAMERA) {
- bCameraActuator *ba = act->data;
-
- ba->damping = 1.0/32.0;
- }
- }
- }
- }
-
- {
ParticleSettings *part;
for (part = main->particle.first; part; part = part->id.next) {
/* Initialize particle billboard scale */
@@ -2667,50 +2199,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
}
-
- {
- /* convert fcurve and shape action actuators to action actuators */
- Object *ob;
- bActuator *act;
- bIpoActuator *ia;
- bActionActuator *aa;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_IPO) {
- /* Create the new actuator */
- ia = act->data;
- aa = MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version");
-
- /* Copy values */
- aa->type = ia->type;
- aa->flag = ia->flag;
- aa->sta = ia->sta;
- aa->end = ia->end;
- BLI_strncpy(aa->name, ia->name, sizeof(aa->name));
- BLI_strncpy(aa->frameProp, ia->frameProp, sizeof(aa->frameProp));
- if (ob->adt)
- aa->act = ob->adt->action;
-
- /* Get rid of the old actuator */
- MEM_freeN(ia);
-
- /* Assign the new actuator */
- act->data = aa;
- act->type = act->otype = ACT_ACTION;
-
- /* Fix for converting 2.4x files: if we don't have an action, but we have an
- * object IPO, then leave the actuator as an IPO actuator for now and let the
- * IPO conversion code handle it */
- if (ob->ipo && !aa->act)
- act->type = ACT_IPO;
- }
- else if (act->type == ACT_SHAPEACTION) {
- act->type = act->otype = ACT_ACTION;
- }
- }
- }
- }
}
if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 2)) {
@@ -2758,41 +2246,5 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
part->time_flag &= ~PART_TIME_AUTOSF;
}
}
-
- {
- /* set defaults for obstacle avoidance, recast data */
- Scene *sce;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- if (sce->gm.levelHeight == 0.f)
- sce->gm.levelHeight = 2.f;
-
- if (sce->gm.recastData.cellsize == 0.0f)
- sce->gm.recastData.cellsize = 0.3f;
- if (sce->gm.recastData.cellheight == 0.0f)
- sce->gm.recastData.cellheight = 0.2f;
- if (sce->gm.recastData.agentmaxslope == 0.0f)
- sce->gm.recastData.agentmaxslope = (float)M_PI/4;
- if (sce->gm.recastData.agentmaxclimb == 0.0f)
- sce->gm.recastData.agentmaxclimb = 0.9f;
- if (sce->gm.recastData.agentheight == 0.0f)
- sce->gm.recastData.agentheight = 2.0f;
- if (sce->gm.recastData.agentradius == 0.0f)
- sce->gm.recastData.agentradius = 0.6f;
- if (sce->gm.recastData.edgemaxlen == 0.0f)
- sce->gm.recastData.edgemaxlen = 12.0f;
- if (sce->gm.recastData.edgemaxerror == 0.0f)
- sce->gm.recastData.edgemaxerror = 1.3f;
- if (sce->gm.recastData.regionminsize == 0.0f)
- sce->gm.recastData.regionminsize = 8.f;
- if (sce->gm.recastData.regionmergesize == 0.0f)
- sce->gm.recastData.regionmergesize = 20.f;
- if (sce->gm.recastData.vertsperpoly<3)
- sce->gm.recastData.vertsperpoly = 6;
- if (sce->gm.recastData.detailsampledist == 0.0f)
- sce->gm.recastData.detailsampledist = 6.0f;
- if (sce->gm.recastData.detailsamplemaxerror == 0.0f)
- sce->gm.recastData.detailsamplemaxerror = 1.0f;
- }
- }
}
}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index f7301fe4664..4049912b586 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -31,7 +31,6 @@
#define DNA_DEPRECATED_ALLOW
#include "DNA_anim_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_brush_types.h"
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
@@ -43,11 +42,9 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_fluidsim_types.h"
#include "DNA_object_types.h"
-#include "DNA_property_types.h"
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
-#include "DNA_sensor_types.h"
#include "DNA_sdna_types.h"
#include "DNA_smoke_types.h"
#include "DNA_space_types.h"
@@ -67,7 +64,6 @@
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
-#include "BKE_property.h" // for BKE_bproperty_object_get
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
@@ -432,25 +428,6 @@ static void do_versions_nodetree_frame_2_64_6(bNodeTree *ntree)
}
}
-static void do_version_logic_264(ListBase *regionbase)
-{
- ARegion *ar;
-
- /* view settings for logic changed */
- for (ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.keeptot == 0) {
- ar->v2d.maxzoom = 1.5f;
-
- ar->v2d.keepzoom = V2D_KEEPZOOM | V2D_LIMITZOOM | V2D_KEEPASPECT;
- ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
- ar->v2d.align = V2D_ALIGN_NO_POS_Y | V2D_ALIGN_NO_NEG_X;
- ar->v2d.keepofs = V2D_KEEPOFS_Y;
- }
- }
- }
-}
-
static void do_versions_affine_tracker_track(MovieTrackingTrack *track)
{
int i;
@@ -900,14 +877,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
{
- /* Initialize BGE exit key to esc key */
- Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
- if (!scene->gm.exitkey)
- scene->gm.exitkey = 218; // Blender key code for ESC
- }
- }
- {
MovieClip *clip;
Object *ob;
@@ -943,45 +912,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
- {
- /* Warn the user if he is using ["Text"] properties for Font objects */
- Object *ob;
- bProperty *prop;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- if (ob->type == OB_FONT) {
- prop = BKE_bproperty_object_get(ob, "Text");
- if (prop) {
- blo_reportf_wrap(fd->reports, RPT_WARNING,
- TIP_("Game property name conflict in object '%s': text objects reserve the "
- "['Text'] game property to change their content through logic bricks"),
- ob->id.name + 2);
- }
- }
- }
- }
}
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 2)) {
{
- /* convert Camera Actuator values to defines */
- Object *ob;
- bActuator *act;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_CAMERA) {
- bCameraActuator *ba = act->data;
-
- if (ba->axis == (float) 'x') ba->axis = OB_POSX;
- else if (ba->axis == (float)'y') ba->axis = OB_POSY;
- /* don't do an if/else to avoid imediate subversion bump*/
-// ba->axis=((ba->axis == (float)'x') ? OB_POSX_X : OB_POSY);
- }
- }
- }
- }
-
- {
/* convert deprecated sculpt_paint_unified_* fields to
* UnifiedPaintSettings */
Scene *scene;
@@ -1222,15 +1156,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 4)) {
- Lamp *la;
Camera *cam;
Curve *cu;
- for (la = main->lamp.first; la; la = la->id.next) {
- if (la->shadow_frustum_size == 0.0f)
- la->shadow_frustum_size = 10.0f;
- }
-
for (cam = main->camera.first; cam; cam = cam->id.next) {
if (cam->flag & CAM_PANORAMA) {
cam->type = CAM_PANO;
@@ -1316,19 +1244,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
-
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 8)) {
- /* set new deactivation values for game settings */
- Scene *sce;
-
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- /* Game Settings */
- sce->gm.lineardeactthreshold = 0.8f;
- sce->gm.angulardeactthreshold = 1.0f;
- sce->gm.deactivationtime = 2.0f;
- }
- }
-
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 9)) {
FOREACH_NODETREE(main, ntree, id) {
if (ntree->type == NTREE_SHADER) {
@@ -1420,14 +1335,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 12)) {
- Material *ma;
-
- for (ma = main->mat.first; ma; ma = ma->id.next)
- if (ma->strand_widthfade == 2.0f)
- ma->strand_widthfade = 0.0f;
- }
-
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 13)) {
FOREACH_NODETREE(main, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
@@ -1574,20 +1481,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- /* remove texco */
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 21)) {
- Material *ma;
- for (ma = main->mat.first; ma; ma = ma->id.next) {
- int a;
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- if (ma->mtex[a]->texco == TEXCO_STICKY_) {
- ma->mtex[a]->texco = TEXCO_UV;
- }
- }
- }
- }
-
{
Mesh *me;
for (me = main->mesh.first; me; me = me->id.next) {
@@ -1738,24 +1632,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
} FOREACH_NODETREE_END
}
- if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 6)) {
- bScreen *sc;
-
- for (sc = main->screen.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- if ( sa->spacetype == SPACE_LOGIC)
- do_version_logic_264(&sa->regionbase);
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_LOGIC)
- do_version_logic_264(&sl->regionbase);
- }
- }
- }
- }
-
if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) {
/* convert tiles size from resolution and number of tiles */
{
@@ -1763,17 +1639,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
for (scene = main->scene.first; scene; scene = scene->id.next) {
if (scene->r.tilex == 0 || scene->r.tiley == 1) {
- if (scene->r.xparts && scene->r.yparts) {
- /* scene could be set for panoramic rendering, so clamp with the
- * lowest possible tile size value
- */
- scene->r.tilex = max_ii(scene->r.xsch * scene->r.size / scene->r.xparts / 100, 8);
- scene->r.tiley = max_ii(scene->r.ysch * scene->r.size / scene->r.yparts / 100, 8);
- }
- else {
- /* happens when mixing using current trunk and previous release */
- scene->r.tilex = scene->r.tiley = 64;
- }
+ scene->r.tilex = scene->r.tiley = 64;
}
}
}
@@ -1809,17 +1675,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (main->versionfile < 265) {
- Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- if (ob->step_height == 0.0f) {
- ob->step_height = 0.15f;
- ob->jump_speed = 10.0f;
- ob->fall_speed = 55.0f;
- }
- }
- }
-
if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 3)) {
bScreen *sc;
for (sc = main->screen.first; sc; sc = sc->id.next) {
@@ -1870,7 +1725,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
for (scene = main->scene.first; scene; scene = scene->id.next) {
Sequence *seq;
- bool set_premul = false;
SEQ_BEGIN (scene->ed, seq)
{
@@ -1885,24 +1739,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
if (scene->r.bake_samples == 0)
scene->r.bake_samples = 256;
-
- if (scene->world) {
- World *world = blo_do_versions_newlibadr(fd, scene->id.lib, scene->world);
-
- if (world && is_zero_v3(&world->horr)) {
- if ((world->skytype & WO_SKYBLEND) == 0 || is_zero_v3(&world->zenr)) {
- set_premul = true;
- }
- }
- }
- else
- set_premul = true;
-
- if (set_premul) {
- printf("2.66 versioning fix: replacing black sky with premultiplied alpha for scene %s\n",
- scene->id.name + 2);
- scene->r.alphamode = R_ALPHAPREMUL;
- }
}
for (Image *image = main->image.first; image; image = image->id.next) {
@@ -2335,32 +2171,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- bSensor *sens;
- bTouchSensor *ts;
- bCollisionSensor *cs;
- Material *ma;
-
- for (sens = ob->sensors.first; sens; sens = sens->next) {
- if (sens->type == SENS_TOUCH) {
- ts = sens->data;
- cs = MEM_callocN(sizeof(bCollisionSensor), "touch -> collision sensor do_version");
-
- if (ts->ma) {
- ma = blo_do_versions_newlibadr(fd, ob->id.lib, ts->ma);
- BLI_strncpy(cs->materialName, ma->id.name + 2, sizeof(cs->materialName));
- }
-
- cs->mode = SENS_COLLISION_MATERIAL;
-
- MEM_freeN(ts);
-
- sens->data = cs;
- sens->type = sens->otype = SENS_COLLISION;
- }
- }
- }
}
if (!MAIN_VERSION_ATLEAST(main, 268, 5)) {
@@ -2514,10 +2324,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
if (ts->sculpt)
ts->sculpt->flags |= SCULPT_DYNTOPO_SUBDIVIDE;
- /* single texture mode removed from game engine */
- if (scene->gm.matmode == GAME_MAT_TEXFACE)
- scene->gm.matmode = GAME_MAT_MULTITEX;
-
/* 'Increment' mode disabled for nodes, use true grid snapping instead */
if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT)
scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
@@ -2544,8 +2350,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
for (ob = main->object.first; ob; ob = ob->id.next) {
ModifierData *md;
- bSensor *bs;
- bActuator *ba;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_EdgeSplit) {
@@ -2557,28 +2361,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
bmd->bevel_angle = DEG2RADF(bmd->bevel_angle);
}
}
-
- for (bs = ob->sensors.first; bs; bs = bs->next) {
- if (bs->type == SENS_RADAR) {
- bRadarSensor *brs = bs->data;
- brs->angle = DEG2RADF(brs->angle);
- }
- }
-
- for (ba = ob->actuators.first; ba; ba = ba->next) {
- if (ba->type == ACT_CONSTRAINT) {
- bConstraintActuator *bca = ba->data;
- if (bca->type == ACT_CONST_TYPE_ORI) {
- bca->minloc[0] = DEG2RADF(bca->minloc[0]);
- bca->maxloc[0] = DEG2RADF(bca->maxloc[0]);
- }
- }
- else if (ba->type == ACT_SOUND) {
- bSoundActuator *bsa = ba->data;
- bsa->sound3D.cone_outer_angle = DEG2RADF(bsa->sound3D.cone_outer_angle);
- bsa->sound3D.cone_inner_angle = DEG2RADF(bsa->sound3D.cone_inner_angle);
- }
- }
}
for (scene = main->scene.first; scene; scene = scene->id.next) {
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 7228c3522f0..cd34f10d8a9 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -52,7 +52,6 @@
#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
#include "DNA_linestyle_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_view3d_types.h"
#include "DNA_smoke_types.h"
#include "DNA_rigidbody_types.h"
@@ -406,7 +405,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!MAIN_VERSION_ATLEAST(main, 270, 1)) {
- Scene *sce;
Object *ob;
/* Update Transform constraint (another deg -> rad stuff). */
@@ -421,12 +419,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
-
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- if (sce->r.raytrace_structure == R_RAYSTRUCTURE_BLIBVH) {
- sce->r.raytrace_structure = R_RAYSTRUCTURE_AUTO;
- }
- }
}
if (!MAIN_VERSION_ATLEAST(main, 270, 2)) {
@@ -489,13 +481,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!MAIN_VERSION_ATLEAST(main, 271, 0)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Material", "int", "mode2")) {
- Material *ma;
-
- for (ma = main->mat.first; ma; ma = ma->id.next)
- ma->mode2 = MA_CASTSHADOW;
- }
-
if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) {
Scene *sce;
@@ -554,29 +539,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- if (!MAIN_VERSION_ATLEAST(main, 271, 2)) {
- /* init up & track axis property of trackto actuators */
- Object *ob;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- bActuator *act;
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_EDIT_OBJECT) {
- bEditObjectActuator *eoact = act->data;
- eoact->trackflag = ob->trackflag;
- /* if trackflag is pointing +-Z axis then upflag should point Y axis.
- * Rest of trackflag cases, upflag should be point z axis */
- if ((ob->trackflag == OB_POSZ) || (ob->trackflag == OB_NEGZ)) {
- eoact->upflag = 1;
- }
- else {
- eoact->upflag = 2;
- }
- }
- }
- }
- }
-
if (!MAIN_VERSION_ATLEAST(main, 271, 3)) {
Brush *br;
@@ -857,40 +819,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
-
- if (!DNA_struct_elem_find(fd->filesdna, "GameData", "int", "scehysteresis")) {
- Scene *scene;
- for (scene = main->scene.first; scene; scene = scene->id.next) {
- scene->gm.scehysteresis = 10;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(main, 274, 2)) {
- FOREACH_NODETREE(main, ntree, id) {
- bNode *node;
- bNodeSocket *sock;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == SH_NODE_MATERIAL) {
- for (sock = node->inputs.first; sock; sock = sock->next) {
- if (STREQ(sock->name, "Refl")) {
- BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
- }
- }
- }
- else if (node->type == SH_NODE_MATERIAL_EXT) {
- for (sock = node->outputs.first; sock; sock = sock->next) {
- if (STREQ(sock->name, "Refl")) {
- BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
- }
- else if (STREQ(sock->name, "Ray Mirror")) {
- BLI_strncpy(sock->name, "Reflectivity", sizeof(sock->name));
- }
- }
- }
- }
- } FOREACH_NODETREE_END
}
if (!MAIN_VERSION_ATLEAST(main, 274, 4)) {
@@ -1092,16 +1020,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
#undef LA_YF_PHOTON
}
-
- {
- Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- if (ob->body_type == OB_BODY_TYPE_CHARACTER && (ob->gameflag & OB_BOUNDS) && ob->collision_boundtype == OB_BOUND_TRIANGLE_MESH) {
- ob->boundtype = ob->collision_boundtype = OB_BOUND_BOX;
- }
- }
- }
-
}
if (!MAIN_VERSION_ATLEAST(main, 276, 3)) {
@@ -1212,12 +1130,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
else
gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
}
-
- if (!DNA_struct_elem_find(fd->filesdna, "Object", "unsigned char", "max_jumps")) {
- for (Object *ob = main->object.first; ob; ob = ob->id.next) {
- ob->max_jumps = 1;
- }
- }
}
if (!MAIN_VERSION_ATLEAST(main, 276, 5)) {
ListBase *lbarray[MAX_LIBARRAY];
@@ -1834,6 +1746,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
scene->r.ffcodecdata.ffmpeg_preset = preset;
}
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ParticleInstanceModifierData", "float", "particle_amount")) {
+ for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_ParticleInstance) {
+ ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
+ pimd->space = eParticleInstanceSpace_World;
+ pimd->particle_amount = 1.0f;
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 50b7f736a67..4a22c935b68 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -29,6 +29,7 @@
#define DNA_DEPRECATED_ALLOW
#include <string.h>
+#include <float.h>
#include "BLI_listbase.h"
#include "BLI_mempool.h"
@@ -38,6 +39,7 @@
#include "DNA_object_types.h"
#include "DNA_camera_types.h"
+#include "DNA_constraint_types.h"
#include "DNA_gpu_types.h"
#include "DNA_group_types.h"
#include "DNA_lamp_types.h"
@@ -53,6 +55,7 @@
#include "DNA_workspace_types.h"
#include "BKE_collection.h"
+#include "BKE_constraint.h"
#include "BKE_customdata.h"
#include "BKE_freestyle.h"
#include "BKE_group.h"
@@ -63,6 +66,7 @@
#include "BKE_node.h"
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "BKE_screen.h"
#include "BKE_workspace.h"
#include "BLO_readfile.h"
@@ -93,7 +97,6 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
Scene *scene = screen->scene;
WorkSpace *workspace;
ViewLayer *layer = BKE_view_layer_from_scene_get(scene);
- ListBase *transform_orientations;
if (screen_parent) {
/* fullscreen with "Back to Previous" option, don't create
@@ -106,17 +109,6 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
}
BKE_workspace_layout_add(workspace, screen, screen->id.name + 2);
BKE_workspace_view_layer_set(workspace, layer, scene);
-
-#ifdef WITH_CLAY_ENGINE
- BLI_strncpy(workspace->view_render.engine_id, RE_engine_id_BLENDER_CLAY,
- sizeof(workspace->view_render.engine_id));
-#else
- BLI_strncpy(workspace->view_render.engine_id, RE_engine_id_BLENDER_EEVEE,
- sizeof(workspace->view_render.engine_id));
-#endif
-
- transform_orientations = BKE_workspace_transform_orientations_get(workspace);
- BLI_duplicatelist(transform_orientations, &scene->transform_spaces);
}
}
@@ -314,7 +306,7 @@ void do_versions_after_linking_280(Main *main)
scene->active_view_layer = 0;
/* Handle legacy render layers. */
- if (!BKE_scene_uses_blender_game(scene)) {
+ {
for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
ViewLayer *view_layer = BKE_view_layer_add(scene, srl->name);
@@ -419,15 +411,6 @@ void do_versions_after_linking_280(Main *main)
scene->active_view_layer = scene->r.actlay;
}
}
- else {
- for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
- if (srl->prop) {
- IDP_FreeProperty(srl->prop);
- MEM_freeN(srl->prop);
- }
- BKE_freestyle_config_free(&srl->freestyleConfig, true);
- }
- }
BLI_freelistN(&scene->r.layers);
ViewLayer *view_layer = BKE_view_layer_add(scene, "Viewport");
@@ -686,16 +669,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
{
if (!MAIN_VERSION_ATLEAST(main, 280, 0)) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
- if (STREQ(scene->r.engine, RE_engine_id_BLENDER_RENDER)) {
-#ifdef WITH_CLAY_ENGINE
- BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_CLAY, sizeof(scene->r.engine));
-#else
- BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
-#endif
- }
- }
-
if (!DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers")) {
for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
/* Master Collection */
@@ -757,25 +730,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!MAIN_VERSION_ATLEAST(main, 280, 2)) {
- if (!DNA_struct_elem_find(fd->filesdna, "View3D", "short", "custom_orientation_index")) {
- for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (v3d->twmode >= V3D_MANIP_CUSTOM) {
- v3d->custom_orientation_index = v3d->twmode - V3D_MANIP_CUSTOM;
- v3d->twmode = V3D_MANIP_CUSTOM;
- }
- else {
- v3d->custom_orientation_index = -1;
- }
- }
- }
- }
- }
- }
-
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "cascade_max_dist")) {
for (Lamp *la = main->lamp.first; la; la = la->id.next) {
la->cascade_max_dist = 1000.0f;
@@ -858,17 +812,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
printf("You need to combine transparency and emission shaders to the converted Principled shader nodes.\n");
}
- if (!DNA_struct_elem_find(fd->filesdna, "Scene", "ViewRender", "view_render")) {
- for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
- BLI_strncpy_utf8(scene->view_render.engine_id, scene->r.engine,
- sizeof(scene->view_render.engine_id));
- }
-
- for (WorkSpace *workspace = main->workspaces.first; workspace; workspace = workspace->id.next) {
- BKE_viewrender_init(&workspace->view_render);
- }
- }
-
if ((DNA_struct_elem_find(fd->filesdna, "ViewLayer", "FreestyleConfig", "freestyle_config") == false) &&
DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers"))
{
@@ -900,7 +843,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
- {
+ if (!MAIN_VERSION_ATLEAST(main, 280, 6)) {
if (DNA_struct_elem_find(fd->filesdna, "SpaceOops", "int", "filter") == false) {
bScreen *sc;
ScrArea *sa;
@@ -930,13 +873,134 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
- }
- {
if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "intensity")) {
for (LightProbe *probe = main->lightprobe.first; probe; probe = probe->id.next) {
probe->intensity = 1.0f;
}
}
+
+ for (Object *ob = main->object.first; ob; ob = ob->id.next) {
+ bConstraint *con, *con_next;
+ con = ob->constraints.first;
+ while (con) {
+ con_next = con->next;
+ if (con->type == 17) { /* CONSTRAINT_TYPE_RIGIDBODYJOINT */
+ BLI_remlink(&ob->constraints, con);
+ BKE_constraint_free_data(con);
+ MEM_freeN(con);
+ }
+ con = con_next;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "Scene", "int", "orientation_index_custom")) {
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ scene->orientation_index_custom = -1;
+ }
+ }
+
+ for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->drawtype_lighting = V3D_LIGHTING_STUDIO;
+
+ /* Assume (demo) files written with 2.8 want to show
+ * Eevee renders in the viewport. */
+ if (MAIN_VERSION_ATLEAST(main, 280, 0)) {
+ v3d->drawtype = OB_MATERIAL;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(main, 280, 7)) {
+ /* Render engine storage moved elsewhere and back during 2.8
+ * development, we assume any files saved in 2.8 had Eevee set
+ * as scene render engine. */
+ if (MAIN_VERSION_ATLEAST(main, 280, 0)) {
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+ }
+ }
}
+
+ if (!MAIN_VERSION_ATLEAST(main, 280, 8)) {
+ /* Blender Internal removal */
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ if (STREQ(scene->r.engine, "BLENDER_RENDER") ||
+ STREQ(scene->r.engine, "BLENDER_GAME")) {
+ BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+ }
+
+ scene->r.bake_mode = 0;
+ }
+
+ for (Tex *tex = main->tex.first; tex; tex = tex->id.next) {
+ /* Removed envmap, pointdensity, voxeldata, ocean textures. */
+ if (ELEM(tex->type, 10, 14, 15, 16)) {
+ tex->type = 0;
+ }
+ }
+ }
+
+ if (!DNA_struct_find(fd->filesdna, "SpaceTopBar")) {
+ /* Remove info editor, but only if at the top of the window. */
+ for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ /* Calculate window width/height from screen vertices */
+ int win_width = 0, win_height = 0;
+ for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) {
+ win_width = MAX2(win_width, vert->vec.x);
+ win_height = MAX2(win_height, vert->vec.y);
+ }
+
+ for (ScrArea *area = screen->areabase.first, *area_next; area; area = area_next) {
+ area_next = area->next;
+
+ if (area->spacetype == SPACE_INFO) {
+ if ((area->v2->vec.y == win_height) && (area->v1->vec.x == 0) && (area->v4->vec.x == win_width)) {
+ BKE_screen_area_free(area);
+
+ BLI_remlink(&screen->areabase, area);
+
+ BKE_screen_remove_double_scredges(screen);
+ BKE_screen_remove_unused_scredges(screen);
+ BKE_screen_remove_unused_scrverts(screen);
+
+ MEM_freeN(area);
+ }
+ }
+ /* AREA_TEMP_INFO is deprecated from now on, it should only be set for info areas
+ * which are deleted above, so don't need to unset it. Its slot/bit can be reused */
+ }
+ }
+ }
+
+#ifdef WITH_REDO_REGION_REMOVAL
+ if (!MAIN_VERSION_ATLEAST(main, 280, TO_BE_DETERMINED)) {
+ /* Remove tool property regions. */
+ for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+
+ for (ARegion *region = regionbase->first, *region_next; region; region = region_next) {
+ region_next = region->next;
+
+ if (region->regiontype == RGN_TYPE_TOOL_PROPS) {
+ BKE_area_region_free(NULL, region);
+ BLI_freelinkN(regionbase, region);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index b09c7d77e59..1e27ab64f48 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -104,7 +104,6 @@ static void update_defaults_startup_workspaces(Main *bmain)
if (STREQ(workspace->id.name + 2, "Default")) {
/* don't rename within iterator, renaming causes listbase to be re-sorted */
workspace_default = workspace;
- BKE_viewrender_init(&workspace->view_render);
}
else {
BKE_workspace_remove(bmain, workspace);
@@ -122,7 +121,7 @@ static void update_defaults_startup_workspaces(Main *bmain)
void BLO_update_defaults_startup_blend(Main *bmain)
{
for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
- BLI_strncpy(scene->view_render.engine_id, RE_engine_id_BLENDER_EEVEE, sizeof(scene->view_render.engine_id));
+ BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
scene->r.im_format.planes = R_IMF_PLANES_RGBA;
scene->r.im_format.compress = 15;
@@ -210,9 +209,6 @@ void BLO_update_defaults_startup_blend(Main *bmain)
pset->brush[PE_BRUSH_CUT].strength = 1.0f;
}
- scene->gm.lodflag |= SCE_LOD_USE_HYST;
- scene->gm.scehysteresis = 10;
-
scene->r.ffcodecdata.audio_mixrate = 48000;
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index b8744b71812..57530c6a004 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -45,7 +45,6 @@
#define DNA_DEPRECATED_ALLOW
#include "DNA_armature_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_camera_types.h"
#include "DNA_constraint_types.h"
#include "DNA_effect_types.h"
@@ -60,10 +59,8 @@
#include "DNA_node_types.h"
#include "DNA_object_fluidsim_types.h"
#include "DNA_object_types.h"
-#include "DNA_property_types.h"
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
-#include "DNA_sensor_types.h"
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
#include "DNA_sound_types.h"
@@ -90,7 +87,6 @@
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
-#include "BKE_property.h" // for BKE_bproperty_object_get
#include "BKE_scene.h"
#include "BKE_sequencer.h"
@@ -128,38 +124,6 @@ static void vcol_to_fcol(Mesh *me)
me->mcol = (MCol *)mcolmain;
}
-static int map_223_keybd_code_to_224_keybd_code(int code)
-{
- switch (code) {
- case 312:
- return 311; /* F12KEY */
- case 159:
- return 161; /* PADSLASHKEY */
- case 161:
- return 150; /* PAD0 */
- case 154:
- return 151; /* PAD1 */
- case 150:
- return 152; /* PAD2 */
- case 155:
- return 153; /* PAD3 */
- case 151:
- return 154; /* PAD4 */
- case 156:
- return 155; /* PAD5 */
- case 152:
- return 156; /* PAD6 */
- case 157:
- return 157; /* PAD7 */
- case 153:
- return 158; /* PAD8 */
- case 158:
- return 159; /* PAD9 */
- default:
- return code;
- }
-}
-
static void do_version_bone_head_tail_237(Bone *bone)
{
Bone *child;
@@ -248,12 +212,6 @@ static void ntree_version_242(bNodeTree *ntree)
}
}
}
- else if (ntree->type == NTREE_SHADER) {
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->type == SH_NODE_GEOMETRY && node->storage == NULL)
- node->storage = MEM_callocN(sizeof(NodeGeometry), "NodeGeometry");
- }
-
}
static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree)
@@ -561,15 +519,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 102) {
- /* init halo's at 1.0 */
- Material *ma = main->mat.first;
- while (ma) {
- ma->add = 1.0;
- ma = ma->id.next;
- }
- }
-
if (main->versionfile <= 103) {
/* new variable in object: colbits */
Object *ob = main->object.first;
@@ -621,11 +570,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
if (main->versionfile <= 107) {
Object *ob;
- Scene *sce = main->scene.first;
- while (sce) {
- sce->r.mode |= R_GAMMA;
- sce = sce->id.next;
- }
ob = main->object.first;
while (ob) {
if (ob->dt == 0)
@@ -657,17 +601,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 113) {
- Material *ma = main->mat.first;
- while (ma) {
- if (ma->flaresize == 0.0f)
- ma->flaresize = 1.0f;
- ma->subsize = 1.0f;
- ma->flareboost = 1.0f;
- ma = ma->id.next;
- }
- }
-
if (main->versionfile <= 134) {
Tex *tex = main->tex.first;
while (tex) {
@@ -832,131 +765,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 191) {
- Object *ob = main->object.first;
- Material *ma = main->mat.first;
-
- /* let faces have default add factor of 0.0 */
- while (ma) {
- if (!(ma->mode & MA_HALO))
- ma->add = 0.0;
- ma = ma->id.next;
- }
-
- while (ob) {
- ob->mass = 1.0f;
- ob->damping = 0.1f;
- /*ob->quat[1] = 1.0f;*/ /* quats arnt used yet */
- ob = ob->id.next;
- }
- }
-
- if (main->versionfile <= 193) {
- Object *ob = main->object.first;
- while (ob) {
- ob->inertia = 1.0f;
- ob->rdamping = 0.1f;
- ob = ob->id.next;
- }
- }
-
- if (main->versionfile <= 200) {
- Object *ob = main->object.first;
- while (ob) {
- ob->scaflag = ob->gameflag & (OB_DO_FH|OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS);
- /* 64 is do_fh */
- ob->gameflag &= ~(OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS);
- ob = ob->id.next;
- }
- }
-
- if (main->versionfile <= 201) {
- /* add-object + end-object are joined to edit-object actuator */
- Object *ob = main->object.first;
- bProperty *prop;
- bActuator *act;
- bIpoActuator *ia;
- bEditObjectActuator *eoa;
- bAddObjectActuator *aoa;
- while (ob) {
- act = ob->actuators.first;
- while (act) {
- if (act->type == ACT_IPO) {
- ia = act->data;
- prop = BKE_bproperty_object_get(ob, ia->name);
- if (prop) {
- ia->type = ACT_IPO_FROM_PROP;
- }
- }
- else if (act->type == ACT_ADD_OBJECT) {
- aoa = act->data;
- eoa = MEM_callocN(sizeof(bEditObjectActuator), "edit ob act");
- eoa->type = ACT_EDOB_ADD_OBJECT;
- eoa->ob = aoa->ob;
- eoa->time = aoa->time;
- MEM_freeN(aoa);
- act->data = eoa;
- act->type = act->otype = ACT_EDIT_OBJECT;
- }
- else if (act->type == ACT_END_OBJECT) {
- eoa = MEM_callocN(sizeof(bEditObjectActuator), "edit ob act");
- eoa->type = ACT_EDOB_END_OBJECT;
- act->data = eoa;
- act->type = act->otype = ACT_EDIT_OBJECT;
- }
- act = act->next;
- }
- ob = ob->id.next;
- }
- }
-
- if (main->versionfile <= 202) {
- /* add-object and end-object are joined to edit-object
- * actuator */
- Object *ob = main->object.first;
- bActuator *act;
- bObjectActuator *oa;
- while (ob) {
- act = ob->actuators.first;
- while (act) {
- if (act->type == ACT_OBJECT) {
- oa = act->data;
- oa->flag &= ~(ACT_TORQUE_LOCAL|ACT_DROT_LOCAL); /* this actuator didn't do local/glob rot before */
- }
- act = act->next;
- }
- ob = ob->id.next;
- }
- }
-
if (main->versionfile <= 204) {
- /* patches for new physics */
- Object *ob = main->object.first;
- bActuator *act;
- bObjectActuator *oa;
bSound *sound;
- while (ob) {
-
- /* please check this for demo20 files like
- * original Egypt levels etc. converted
- * rotation factor of 50 is not workable */
- act = ob->actuators.first;
- while (act) {
- if (act->type == ACT_OBJECT) {
- oa = act->data;
-
- oa->forceloc[0] *= 25.0f;
- oa->forceloc[1] *= 25.0f;
- oa->forceloc[2] *= 25.0f;
-
- oa->forcerot[0] *= 10.0f;
- oa->forcerot[1] *= 10.0f;
- oa->forcerot[2] *= 10.0f;
- }
- act = act->next;
- }
- ob = ob->id.next;
- }
sound = main->sound.first;
while (sound) {
@@ -967,120 +777,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 205) {
- /* patches for new physics */
- Object *ob = main->object.first;
- bActuator *act;
- bSensor *sens;
- bEditObjectActuator *oa;
- bRaySensor *rs;
- bCollisionSensor *cs;
- while (ob) {
- /* Set anisotropic friction off for old objects,
- * values to 1.0. */
- ob->gameflag &= ~OB_ANISOTROPIC_FRICTION;
- ob->anisotropicFriction[0] = 1.0;
- ob->anisotropicFriction[1] = 1.0;
- ob->anisotropicFriction[2] = 1.0;
-
- act = ob->actuators.first;
- while (act) {
- if (act->type == ACT_EDIT_OBJECT) {
- /* Zero initial velocity for newly
- * added objects */
- oa = act->data;
- oa->linVelocity[0] = 0.0;
- oa->linVelocity[1] = 0.0;
- oa->linVelocity[2] = 0.0;
- oa->localflag = 0;
- }
- act = act->next;
- }
-
- sens = ob->sensors.first;
- while (sens) {
- /* Extra fields for radar sensors. */
- if (sens->type == SENS_RADAR) {
- bRadarSensor *s = sens->data;
- s->range = 10000.0;
- }
-
- /* Pulsing: defaults for new sensors. */
- if (sens->type != SENS_ALWAYS) {
- sens->pulse = 0;
- sens->freq = 0;
- }
- else {
- sens->pulse = 1;
- }
-
- /* Invert: off. */
- sens->invert = 0;
-
- /* Collision and ray: default = trigger
- * on property. The material field can
- * remain empty. */
- if (sens->type == SENS_COLLISION) {
- cs = (bCollisionSensor*) sens->data;
- cs->mode = 0;
- }
- if (sens->type == SENS_RAY) {
- rs = (bRaySensor*) sens->data;
- rs->mode = 0;
- }
- sens = sens->next;
- }
- ob = ob->id.next;
- }
- /* have to check the exact multiplier */
- }
-
- if (main->versionfile <= 211) {
- /* Render setting: per scene, the applicable gamma value
- * can be set. Default is 1.0, which means no
- * correction. */
- bActuator *act;
- bObjectActuator *oa;
- Object *ob;
-
- /* added alpha in obcolor */
- ob = main->object.first;
- while (ob) {
- ob->col[3] = 1.0;
- ob = ob->id.next;
- }
-
- /* added alpha in obcolor */
- ob = main->object.first;
- while (ob) {
- act = ob->actuators.first;
- while (act) {
- if (act->type == ACT_OBJECT) {
- /* multiply velocity with 50 in old files */
- oa = act->data;
- if (fabsf(oa->linearvelocity[0]) >= 0.01f)
- oa->linearvelocity[0] *= 50.0f;
- if (fabsf(oa->linearvelocity[1]) >= 0.01f)
- oa->linearvelocity[1] *= 50.0f;
- if (fabsf(oa->linearvelocity[2]) >= 0.01f)
- oa->linearvelocity[2] *= 50.0f;
- if (fabsf(oa->angularvelocity[0]) >= 0.01f)
- oa->angularvelocity[0] *= 50.0f;
- if (fabsf(oa->angularvelocity[1]) >= 0.01f)
- oa->angularvelocity[1] *= 50.0f;
- if (fabsf(oa->angularvelocity[2]) >= 0.01f)
- oa->angularvelocity[2] *= 50.0f;
- }
- act = act->next;
- }
- ob = ob->id.next;
- }
- }
-
if (main->versionfile <= 212) {
bSound *sound;
- bProperty *prop;
- Object *ob;
Mesh *me;
sound = main->sound.first;
@@ -1097,21 +795,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
sound = sound->id.next;
}
- ob = main->object.first;
-
- while (ob) {
- prop = ob->prop.first;
- while (prop) {
- if (prop->type == GPROP_TIME) {
- // convert old GPROP_TIME values from int to float
- *((float *)&prop->data) = (float) prop->data;
- }
-
- prop = prop->next;
- }
- ob = ob->id.next;
- }
-
/* me->subdiv changed to reflect the actual reparametization
* better, and smeshes were removed - if it was a smesh make
* it a subsurf, and reset the subdiv level because subsurf
@@ -1134,29 +817,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
if (main->versionfile <= 220) {
- Object *ob;
Mesh *me;
- ob = main->object.first;
-
- /* adapt form factor in order to get the 'old' physics
- * behavior back...
- */
-
- while (ob) {
- /* in future, distinguish between different
- * object bounding shapes
- */
- ob->formfactor = 0.4f;
- /* patch form factor, note that inertia equiv radius
- * of a rotation symmetrical obj
- */
- if (ob->inertia != 1.0f) {
- ob->formfactor /= ob->inertia * ob->inertia;
- }
- ob = ob->id.next;
- }
-
/* Began using alpha component of vertex colors, but
* old file vertex colors are undefined, reset them
* to be fully opaque. -zr
@@ -1186,61 +848,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 221) {
- Scene *sce = main->scene.first;
-
- /* new variables for std-alone player and runtime */
- while (sce) {
- sce->r.xplay = 640;
- sce->r.yplay = 480;
- sce->r.freqplay = 60;
-
- sce = sce->id.next;
- }
-
- }
-
- if (main->versionfile <= 222) {
- Scene *sce = main->scene.first;
-
- /* new variables for std-alone player and runtime */
- while (sce) {
- sce->r.depth = 32;
-
- sce = sce->id.next;
- }
- }
-
if (main->versionfile <= 223) {
VFont *vf;
- Image *ima;
- Object *ob;
-
for (vf = main->vfont.first; vf; vf = vf->id.next) {
if (STREQ(vf->name + strlen(vf->name) - 6, ".Bfont")) {
strcpy(vf->name, FO_BUILTIN_NAME);
}
}
-
- /* Old textures animate at 25 FPS */
- for (ima = main->image.first; ima; ima = ima->id.next) {
- ima->animspeed = 25;
- }
-
- /* Zr remapped some keyboard codes to be linear (stupid zr) */
- for (ob = main->object.first; ob; ob = ob->id.next) {
- bSensor *sens;
-
- for (sens = ob->sensors.first; sens; sens = sens->next) {
- if (sens->type == SENS_KEYBOARD) {
- bKeyboardSensor *ks = sens->data;
-
- ks->key = map_223_keybd_code_to_224_keybd_code(ks->key);
- ks->qual = map_223_keybd_code_to_224_keybd_code(ks->qual);
- ks->qual2 = map_223_keybd_code_to_224_keybd_code(ks->qual2);
- }
- }
- }
}
if (main->versionfile <= 224) {
@@ -1284,17 +898,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile <= 225) {
- World *wo;
- /* Use Sumo for old games */
- for (wo = main->world.first; wo; wo = wo->id.next) {
- wo->physicsEngine = 2;
- }
- }
-
if (main->versionfile <= 227) {
Scene *sce;
- Material *ma;
bScreen *sc;
Object *ob;
@@ -1347,17 +952,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
for (sce = main->scene.first; sce; sce = sce->id.next) {
sce->audio.mixrate = 48000;
sce->audio.flag |= AUDIO_SCRUB;
- sce->r.mode |= R_ENVMAP;
- }
-
- /* init new shader vars */
- for (ma = main->mat.first; ma; ma = ma->id.next) {
- ma->refrac = 4.0f;
- ma->roughness = 0.5f;
- ma->param[0] = 0.5f;
- ma->param[1] = 0.1f;
- ma->param[2] = 0.1f;
- ma->param[3] = 0.05f;
}
/* patch for old wrong max view2d settings, allows zooming out more */
@@ -1382,7 +976,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
if (main->versionfile <= 228) {
- Scene *sce;
bScreen *sc;
Object *ob;
@@ -1428,10 +1021,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
ob = ob->id.next;
}
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- sce->r.mode |= R_ENVMAP;
- }
-
/* convert old mainb values for new button panels */
for (sc = main->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
@@ -1469,9 +1058,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
sbuts->mainb = CONTEXT_SCENE;
//sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_RENDER;
}
- else if (sbuts->mainb == BUTS_GAME) {
- sbuts->mainb = CONTEXT_LOGIC;
- }
else if (sbuts->mainb == BUTS_FPAINT) {
sbuts->mainb = CONTEXT_EDITING;
}
@@ -1554,57 +1140,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
if (main->versionfile <= 231) {
- Material *ma = main->mat.first;
bScreen *sc = main->screen.first;
- Scene *sce;
- Lamp *la;
- World *wrld;
-
- /* introduction of raytrace */
- while (ma) {
- if (ma->fresnel_tra_i == 0.0f)
- ma->fresnel_tra_i = 1.25f;
- if (ma->fresnel_mir_i == 0.0f)
- ma->fresnel_mir_i = 1.25f;
-
- ma->ang = 1.0;
- ma->ray_depth = 2;
- ma->ray_depth_tra = 2;
- ma->fresnel_tra = 0.0;
- ma->fresnel_mir = 0.0;
-
- ma = ma->id.next;
- }
- sce = main->scene.first;
- while (sce) {
- if (sce->r.gauss == 0.0f)
- sce->r.gauss = 1.0f;
- sce = sce->id.next;
- }
- la = main->lamp.first;
- while (la) {
- if (la->k == 0.0f) la->k = 1.0;
- if (la->ray_samp == 0)
- la->ray_samp = 1;
- if (la->ray_sampy == 0)
- la->ray_sampy = 1;
- if (la->ray_sampz == 0)
- la->ray_sampz = 1;
- if (la->area_size == 0.0f)
- la->area_size = 1.0f;
- if (la->area_sizey == 0.0f)
- la->area_sizey = 1.0f;
- if (la->area_sizez == 0.0f)
- la->area_sizez = 1.0f;
- la = la->id.next;
- }
- wrld = main->world.first;
- while (wrld) {
- if (wrld->range == 0.0f) {
- wrld->range = 1.0f / wrld->exposure;
- }
- wrld = wrld->id.next;
- }
/* new bit flags for showing/hiding grid floor and axes */
@@ -1635,7 +1171,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
Tex *tex = main->tex.first;
World *wrld = main->world.first;
bScreen *sc;
- Scene *sce;
while (tex) {
if ((tex->flag & (TEX_CHECKER_ODD+TEX_CHECKER_EVEN))==0) {
@@ -1662,10 +1197,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
while (wrld) {
if (wrld->aodist == 0.0f) {
wrld->aodist = 10.0f;
- wrld->aobias = 0.05f;
}
- if (wrld->aosamp == 0)
- wrld->aosamp = 5;
if (wrld->aoenergy == 0.0f)
wrld->aoenergy = 1.0f;
wrld = wrld->id.next;
@@ -1690,13 +1222,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
}
- sce = main->scene.first;
- while (sce) {
- if (sce->r.ocres == 0)
- sce->r.ocres = 64;
- sce = sce->id.next;
- }
-
}
if (main->versionfile <= 233) {
@@ -1705,10 +1230,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
/* Object *ob = main->object.first; */
while (ma) {
- if (ma->rampfac_col == 0.0f)
- ma->rampfac_col = 1.0;
- if (ma->rampfac_spec == 0.0f)
- ma->rampfac_spec = 1.0;
if (ma->pr_lamp == 0)
ma->pr_lamp = 3;
ma = ma->id.next;
@@ -1729,15 +1250,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
if (main->versionfile <= 234) {
- World *wo;
bScreen *sc;
- /* force sumo engine to be active */
- for (wo = main->world.first; wo; wo = wo->id.next) {
- if (wo->physicsEngine == 0)
- wo->physicsEngine = 2;
- }
-
for (sc = main->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
@@ -1786,8 +1300,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
if (main->versionfile <= 236) {
Object *ob;
Camera *cam = main->camera.first;
- Material *ma;
- bScreen *sc;
while (cam) {
if (cam->ortho_scale == 0.0f) {
@@ -1797,29 +1309,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
cam = cam->id.next;
}
- /* set manipulator type */
/* force oops draw if depgraph was set*/
/* set time line var */
- for (sc = main->screen.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *) sl;
- if (v3d->twtype == 0)
- v3d->twtype = V3D_MANIP_TRANSLATE;
- }
- }
- }
- }
- /* init new shader vars */
- for (ma = main->mat.first; ma; ma = ma->id.next) {
- if (ma->darkness == 0.0f) {
- ma->rms = 0.1f;
- ma->darkness = 1.0f;
- }
- }
/* softbody init new vars */
for (ob = main->object.first; ob; ob = ob->id.next) {
@@ -2048,7 +1539,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
Object *ob;
Scene *sce = main->scene.first;
Camera *cam = main->camera.first;
- Material *ma = main->mat.first;
int set_passepartout = 0;
/* deformflag is local in modifier now */
@@ -2081,11 +1571,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
set_passepartout = 1;
sce->r.scemode &= ~R_PASSEPARTOUT;
}
- /* gauss is filter variable now */
- if (sce->r.mode & R_GAUSS) {
- sce->r.filtertype = R_FILTER_GAUSS;
- sce->r.mode &= ~R_GAUSS;
- }
}
for (; cam; cam = cam->id.next) {
@@ -2100,36 +1585,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
if (!(cam->passepartalpha))
cam->passepartalpha = 0.2f;
}
-
- for (; ma; ma = ma->id.next) {
- if (ma->strand_sta == 0.0f) {
- ma->strand_sta = ma->strand_end = 1.0f;
- ma->mode |= MA_TANGENT_STR;
- }
- if (ma->mode & MA_TRACEBLE)
- ma->mode |= MA_SHADBUF;
- }
}
if (main->versionfile <= 241) {
Object *ob;
- Tex *tex;
Scene *sce;
- World *wo;
Lamp *la;
- Material *ma;
bArmature *arm;
bNodeTree *ntree;
- for (wo = main->world.first; wo; wo = wo->id.next) {
- /* Migrate to Bullet for games, except for the NaN versions */
- /* People can still explicitly choose for Sumo (after 2.42 is out) */
- if (main->versionfile > 225)
- wo->physicsEngine = WOPHY_BULLET;
- if (WO_AODIST == wo->aomode)
- wo->aocolor = WO_AOPLAIN;
- }
-
/* updating layers still */
for (arm = main->armature.first; arm; arm = arm->id.next) {
bone_version_239(&arm->bonebase);
@@ -2140,11 +1604,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
if (sce->audio.mixrate == 0)
sce->audio.mixrate = 48000;
- if (sce->r.xparts <2 )
- sce->r.xparts = 4;
- if (sce->r.yparts < 2)
- sce->r.yparts = 4;
-
/* We don't add default layer since blender2.8 because the layers
* are now in Scene->view_layers and a default layer is created in
* the doversion later on.
@@ -2166,20 +1625,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
sce->toolsettings->uvcalc_flag = UVCALC_FILLHOLES;
sce->toolsettings->unwrapper = 1;
}
-
- if (sce->r.mode & R_PANORAMA) {
- /* all these checks to ensure saved files between released versions keep working... */
- if (sce->r.xsch < sce->r.ysch) {
- Object *obc = blo_do_versions_newlibadr(fd, lib, sce->camera);
- if (obc && obc->type == OB_CAMERA) {
- Camera *cam = blo_do_versions_newlibadr(fd, lib, obc->data);
- if (cam->lens >= 10.0f) {
- sce->r.xsch *= sce->r.xparts;
- cam->lens *= (float)sce->r.ysch / (float)sce->r.xsch;
- }
- }
- }
- }
}
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
@@ -2189,12 +1634,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
if (la->buffers == 0)
la->buffers = 1;
- for (tex = main->tex.first; tex; tex = tex->id.next) {
- if (tex->env && tex->env->viewscale == 0.0f)
- tex->env->viewscale = 1.0f;
- //tex->imaflag |= TEX_GAUSS_MIP;
- }
-
/* for empty drawsize and drawtype */
for (ob = main->object.first; ob; ob = ob->id.next) {
if (ob->empty_drawsize == 0.0f) {
@@ -2203,21 +1642,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- for (ma = main->mat.first; ma; ma = ma->id.next) {
- /* stucci returns intensity from now on */
- int a;
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a] && ma->mtex[a]->tex) {
- tex = blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex);
- if (tex && tex->type == TEX_STUCCI)
- ma->mtex[a]->mapto &= ~(MAP_COL|MAP_SPEC|MAP_REF);
- }
- }
- /* transmissivity defaults */
- if (ma->tx_falloff == 0.0f)
- ma->tx_falloff = 1.0f;
- }
-
/* during 2.41 images with this name were used for viewer node output, lets fix that */
if (main->versionfile == 241) {
Image *ima;
@@ -2387,8 +1811,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
for (ma = main->mat.first; ma; ma = ma->id.next) {
- if (ma->shad_alpha == 0.0f)
- ma->shad_alpha = 1.0f;
if (ma->nodetree)
ntree_version_242(ma->nodetree);
}
@@ -2466,7 +1888,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
for (sce = main->scene.first; sce; sce = sce->id.next) {
sce->r.bake_mode = 1; /* prevent to include render stuff here */
sce->r.bake_filter = 16;
- sce->r.bake_osa = 5;
sce->r.bake_flag = R_BAKE_CLEAR;
}
}
@@ -2474,32 +1895,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
if (main->versionfile <= 243) {
Object *ob = main->object.first;
- Material *ma;
-
- for (ma = main->mat.first; ma; ma = ma->id.next) {
- if (ma->sss_scale == 0.0f) {
- ma->sss_radius[0] = 1.0f;
- ma->sss_radius[1] = 1.0f;
- ma->sss_radius[2] = 1.0f;
- ma->sss_col[0] = 0.8f;
- ma->sss_col[1] = 0.8f;
- ma->sss_col[2] = 0.8f;
- ma->sss_error = 0.05f;
- ma->sss_scale = 0.1f;
- ma->sss_ior = 1.3f;
- ma->sss_colfac = 1.0f;
- ma->sss_texfac = 0.0f;
- }
- if (ma->sss_front == 0 && ma->sss_back == 0) {
- ma->sss_front = 1.0f;
- ma->sss_back = 1.0f;
- }
- if (ma->sss_col[0] == 0 && ma->sss_col[1] == 0 && ma->sss_col[2] == 0) {
- ma->sss_col[0] = ma->r;
- ma->sss_col[1] = ma->g;
- ma->sss_col[2] = ma->b;
- }
- }
for (; ob; ob = ob->id.next) {
bDeformGroup *curdef;
@@ -2547,15 +1942,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
if (main->versionfile <= 244) {
- Scene *sce;
bScreen *sc;
- Lamp *la;
- World *wrld;
if (main->versionfile != 244 || main->subversionfile < 2) {
- for (sce = main->scene.first; sce; sce = sce->id.next)
- sce->r.mode |= R_SSS;
-
/* correct older action editors - incorrect scrolling */
for (sc = main->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
@@ -2578,28 +1967,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
}
-
- if (main->versionfile != 244 || main->subversionfile < 3) {
- /* constraints recode version patch used to be here. Moved to 245 now... */
-
- for (wrld = main->world.first; wrld; wrld = wrld->id.next) {
- if (wrld->mode & WO_AMB_OCC)
- wrld->ao_samp_method = WO_AOSAMP_CONSTANT;
- else
- wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
-
- wrld->ao_adapt_thresh = 0.005f;
- }
-
- for (la = main->lamp.first; la; la = la->id.next) {
- if (la->type == LA_AREA)
- la->ray_samp_method = LA_SAMP_CONSTANT;
- else
- la->ray_samp_method = LA_SAMP_HALTON;
-
- la->adapt_thresh = 0.001f;
- }
- }
}
if (main->versionfile <= 245) {
@@ -2609,7 +1976,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
Lamp *la;
Material *ma;
ParticleSettings *part;
- World *wrld;
Mesh *me;
bNodeTree *ntree;
Tex *tex;
@@ -2741,10 +2107,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
if (main->versionfile != 245 || main->subversionfile < 1) {
for (la = main->lamp.first; la; la = la->id.next) {
- if (la->mode & LA_QUAD)
- la->falloff_type = LA_FALLOFF_SLIDERS;
- else
- la->falloff_type = LA_FALLOFF_INVLINEAR;
+ la->falloff_type = LA_FALLOFF_INVLINEAR;
if (la->curfalloff == NULL) {
la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
@@ -2754,17 +2117,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
for (ma = main->mat.first; ma; ma = ma->id.next) {
- if (ma->samp_gloss_mir == 0) {
- ma->gloss_mir = ma->gloss_tra = 1.0f;
- ma->aniso_gloss_mir = 1.0f;
- ma->samp_gloss_mir = ma->samp_gloss_tra = 18;
- ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005f;
- ma->dist_mir = 0.0f;
- ma->fadeto_mir = MA_RAYMIR_FADETOSKY;
+ if (ma->gloss_mir == 0.0f) {
+ ma->gloss_mir = 1.0f;
}
-
- if (ma->strand_min == 0.0f)
- ma->strand_min = 1.0f;
}
for (part = main->particle.first; part; part = part->id.next) {
@@ -2772,26 +2127,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
part->ren_child_nbr = part->child_nbr;
}
- for (wrld = main->world.first; wrld; wrld = wrld->id.next) {
- if (wrld->ao_approx_error == 0.0f)
- wrld->ao_approx_error = 0.25f;
- }
-
for (sce = main->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree)
ntree_version_245(fd, lib, sce->nodetree);
- if (sce->r.simplify_shadowsamples == 0) {
+ if (sce->r.simplify_subsurf == 0) {
sce->r.simplify_subsurf = 6;
sce->r.simplify_particles = 1.0f;
- sce->r.simplify_shadowsamples = 16;
- sce->r.simplify_aosss = 1.0f;
- }
-
- if (sce->r.cineongamma == 0) {
- sce->r.cineonblack = 95;
- sce->r.cineonwhite = 685;
- sce->r.cineongamma = 1.7f;
}
}
@@ -2819,22 +2161,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- /* sanity check for skgen */
- {
- Scene *sce;
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] ||
- sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] ||
- sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2])
- {
- sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
- sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
- sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
- }
- }
- }
-
-
if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) {
Image *ima;
@@ -3071,16 +2397,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
}
- if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 9)) {
- Material *ma;
- int a;
-
- for (ma = main->mat.first; ma; ma = ma->id.next)
- if (ma->mode & MA_NORMAP_TANG)
- for (a = 0; a < MAX_MTEX; a++)
- if (ma->mtex[a] && ma->mtex[a]->tex)
- ma->mtex[a]->normapspace = MTEX_NSPACE_TANGENT;
- }
if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) {
Object *ob;
@@ -3163,25 +2479,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
idproperties_fix_group_lengths(main->particle);
}
- /* sun/sky */
- if (main->versionfile < 246) {
- Object *ob;
- bActuator *act;
-
- /* dRot actuator change direction in 2.46 */
- for (ob = main->object.first; ob; ob = ob->id.next) {
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_OBJECT) {
- bObjectActuator *ba = act->data;
-
- ba->drot[0] = -ba->drot[0];
- ba->drot[1] = -ba->drot[1];
- ba->drot[2] = -ba->drot[2];
- }
- }
- }
- }
-
/* convert fluids to modifier */
if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
Object *ob;
@@ -3211,33 +2508,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)) {
- Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- ob->gameflag |= OB_COLLISION;
- ob->margin = 0.06f;
- }
- }
-
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)) {
- Object *ob;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- /* Starting from subversion 3, ACTOR is a separate feature.
- * Before it was conditioning all the other dynamic flags */
- if (!(ob->gameflag & OB_ACTOR))
- ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE);
- /* suitable default for older files */
- }
- }
-
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 5)) {
- Lamp *la = main->lamp.first;
- for (; la; la = la->id.next) {
- la->skyblendtype = MA_RAMP_ADD;
- la->skyblendfac = 1.0f;
- }
- }
-
/* set the curve radius interpolation to 2.47 default - easy */
if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 6)) {
Curve *cu;
@@ -3261,72 +2531,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- /* direction constraint actuators were always local in previous version */
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 7)) {
- bActuator *act;
- Object *ob;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_CONSTRAINT) {
- bConstraintActuator *coa = act->data;
- if (coa->type == ACT_CONST_TYPE_DIST) {
- coa->flag |= ACT_CONST_LOCAL;
- }
- }
- }
- }
- }
-
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) {
- Lamp *la = main->lamp.first;
- for (; la; la = la->id.next) {
- la->sky_exposure = 1.0f;
- }
- }
-
- /* BGE message actuators needed OB prefix, very confusing */
- if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) {
- bActuator *act;
- Object *ob;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- for (act = ob->actuators.first; act; act = act->next) {
- if (act->type == ACT_MESSAGE) {
- bMessageActuator *msgAct = (bMessageActuator *) act->data;
-
- if (BLI_strnlen(msgAct->toPropName, 3) > 2) {
- /* strip first 2 chars, would have only worked if these were OB anyway */
- memmove(msgAct->toPropName, msgAct->toPropName + 2, sizeof(msgAct->toPropName) - 2);
- }
- else {
- msgAct->toPropName[0] = '\0';
- }
- }
- }
- }
- }
-
- if (main->versionfile < 248) {
- Lamp *la;
-
- for (la = main->lamp.first; la; la = la->id.next) {
- if (la->atm_turbidity == 0.0f) {
- la->sun_effect_type = 0;
- la->horizon_brightness = 1.0f;
- la->spread = 1.0f;
- la->sun_brightness = 1.0f;
- la->sun_size = 1.0f;
- la->backscattered_light = 1.0f;
- la->atm_turbidity = 2.0f;
- la->atm_inscattering_factor = 1.0f;
- la->atm_extinction_factor = 1.0f;
- la->atm_distance_factor = 1.0f;
- la->sun_intensity = 1.0f;
- }
- }
- }
-
if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) {
Scene *sce;
@@ -3334,31 +2538,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
for (sce = main->scene.first; sce; sce = sce->id.next) {
sce->toolsettings->imapaint.seam_bleed = 2;
sce->toolsettings->imapaint.normal_angle = 80;
-
- /* initialize skeleton generation toolsettings */
- sce->toolsettings->skgen_resolution = 250;
- sce->toolsettings->skgen_threshold_internal = 0.1f;
- sce->toolsettings->skgen_threshold_external = 0.1f;
- sce->toolsettings->skgen_angle_limit = 30.0f;
- sce->toolsettings->skgen_length_ratio = 1.3f;
- sce->toolsettings->skgen_length_limit = 1.5f;
- sce->toolsettings->skgen_correlation_limit = 0.98f;
- sce->toolsettings->skgen_symmetry_limit = 0.1f;
- sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
- sce->toolsettings->skgen_postpro_passes = 3;
- sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_SUB_CORRELATION|SKGEN_HARMONIC;
- sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
- sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
- sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
-
-
- sce->toolsettings->skgen_retarget_angle_weight = 1.0f;
- sce->toolsettings->skgen_retarget_length_weight = 1.0f;
- sce->toolsettings->skgen_retarget_distance_weight = 1.0f;
-
- /* Skeleton Sketching */
- sce->toolsettings->bone_sketching = 0;
- sce->toolsettings->skgen_retarget_roll = SK_RETARGET_ROLL_VIEW;
}
}
@@ -3400,60 +2579,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) {
- Object *ob;
-
- /* Adjustments needed after Bullets update */
- for (ob = main->object.first; ob; ob = ob->id.next) {
- ob->damping *= 0.635f;
- ob->rdamping = 0.1f + (0.8f * ob->rdamping);
- }
- }
-
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 4)) {
- Scene *sce;
- World *wrld;
-
- /* Dome (Fisheye) default parameters */
- for (sce = main->scene.first; sce; sce = sce->id.next) {
- sce->r.domeangle = 180;
- sce->r.domemode = 1;
- sce->r.domeres = 4;
- sce->r.domeresbuf = 1.0f;
- sce->r.dometilt = 0;
- }
- /* DBVT culling by default */
- for (wrld = main->world.first; wrld; wrld = wrld->id.next) {
- wrld->mode |= WO_DBVT_CULLING;
- wrld->occlusionRes = 128;
- }
- }
-
- if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) {
- Object *ob;
- World *wrld;
- for (ob = main->object.first; ob; ob = ob->id.next) {
- if (ob->parent) {
- /* check if top parent has compound shape set and if yes, set this object
- * to compound shaper as well (was the behavior before, now it's optional) */
- Object *parent = blo_do_versions_newlibadr(fd, lib, ob->parent);
- while (parent && parent != ob && parent->parent != NULL) {
- parent = blo_do_versions_newlibadr(fd, lib, parent->parent);
- }
- if (parent) {
- if (parent->gameflag & OB_CHILD)
- ob->gameflag |= OB_CHILD;
- }
- }
- }
- for (wrld = main->world.first; wrld; wrld = wrld->id.next) {
- wrld->ticrate = 60;
- wrld->maxlogicstep = 5;
- wrld->physubstep = 1;
- wrld->maxphystep = 5;
- }
- }
-
/* correct introduce of seed for wind force */
if (main->versionfile < 249 && main->subversionfile < 1) {
Object *ob;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 580d821be5b..6f03f519ef5 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -109,13 +109,11 @@
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_brush_types.h"
#include "DNA_cachefile_types.h"
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
#include "DNA_constraint_types.h"
-#include "DNA_controller_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_genfile.h"
#include "DNA_groom_types.h"
@@ -138,12 +136,10 @@
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
#include "DNA_lightprobe_types.h"
-#include "DNA_property_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
-#include "DNA_sensor_types.h"
#include "DNA_smoke_types.h"
#include "DNA_space_types.h"
#include "DNA_screen_types.h"
@@ -192,6 +188,7 @@
#include "BLO_writefile.h"
#include "BLO_readfile.h"
+#include "BLO_runtime.h"
#include "BLO_undofile.h"
#include "BLO_blend_defs.h"
@@ -1468,180 +1465,6 @@ static void write_particlesystems(WriteData *wd, ListBase *particles)
}
}
-static void write_properties(WriteData *wd, ListBase *lb)
-{
- bProperty *prop;
-
- prop = lb->first;
- while (prop) {
- writestruct(wd, DATA, bProperty, 1, prop);
-
- if (prop->poin && prop->poin != &prop->data) {
- writedata(wd, DATA, MEM_allocN_len(prop->poin), prop->poin);
- }
-
- prop = prop->next;
- }
-}
-
-static void write_sensors(WriteData *wd, ListBase *lb)
-{
- bSensor *sens;
-
- sens = lb->first;
- while (sens) {
- writestruct(wd, DATA, bSensor, 1, sens);
-
- writedata(wd, DATA, sizeof(void *) * sens->totlinks, sens->links);
-
- switch (sens->type) {
- case SENS_NEAR:
- writestruct(wd, DATA, bNearSensor, 1, sens->data);
- break;
- case SENS_MOUSE:
- writestruct(wd, DATA, bMouseSensor, 1, sens->data);
- break;
- case SENS_KEYBOARD:
- writestruct(wd, DATA, bKeyboardSensor, 1, sens->data);
- break;
- case SENS_PROPERTY:
- writestruct(wd, DATA, bPropertySensor, 1, sens->data);
- break;
- case SENS_ARMATURE:
- writestruct(wd, DATA, bArmatureSensor, 1, sens->data);
- break;
- case SENS_ACTUATOR:
- writestruct(wd, DATA, bActuatorSensor, 1, sens->data);
- break;
- case SENS_DELAY:
- writestruct(wd, DATA, bDelaySensor, 1, sens->data);
- break;
- case SENS_COLLISION:
- writestruct(wd, DATA, bCollisionSensor, 1, sens->data);
- break;
- case SENS_RADAR:
- writestruct(wd, DATA, bRadarSensor, 1, sens->data);
- break;
- case SENS_RANDOM:
- writestruct(wd, DATA, bRandomSensor, 1, sens->data);
- break;
- case SENS_RAY:
- writestruct(wd, DATA, bRaySensor, 1, sens->data);
- break;
- case SENS_MESSAGE:
- writestruct(wd, DATA, bMessageSensor, 1, sens->data);
- break;
- case SENS_JOYSTICK:
- writestruct(wd, DATA, bJoystickSensor, 1, sens->data);
- break;
- default:
- ; /* error: don't know how to write this file */
- }
-
- sens = sens->next;
- }
-}
-
-static void write_controllers(WriteData *wd, ListBase *lb)
-{
- bController *cont;
-
- cont = lb->first;
- while (cont) {
- writestruct(wd, DATA, bController, 1, cont);
-
- writedata(wd, DATA, sizeof(void *) * cont->totlinks, cont->links);
-
- switch (cont->type) {
- case CONT_EXPRESSION:
- writestruct(wd, DATA, bExpressionCont, 1, cont->data);
- break;
- case CONT_PYTHON:
- writestruct(wd, DATA, bPythonCont, 1, cont->data);
- break;
- default:
- ; /* error: don't know how to write this file */
- }
-
- cont = cont->next;
- }
-}
-
-static void write_actuators(WriteData *wd, ListBase *lb)
-{
- bActuator *act;
-
- act = lb->first;
- while (act) {
- writestruct(wd, DATA, bActuator, 1, act);
-
- switch (act->type) {
- case ACT_ACTION:
- case ACT_SHAPEACTION:
- writestruct(wd, DATA, bActionActuator, 1, act->data);
- break;
- case ACT_SOUND:
- writestruct(wd, DATA, bSoundActuator, 1, act->data);
- break;
- case ACT_OBJECT:
- writestruct(wd, DATA, bObjectActuator, 1, act->data);
- break;
- case ACT_PROPERTY:
- writestruct(wd, DATA, bPropertyActuator, 1, act->data);
- break;
- case ACT_CAMERA:
- writestruct(wd, DATA, bCameraActuator, 1, act->data);
- break;
- case ACT_CONSTRAINT:
- writestruct(wd, DATA, bConstraintActuator, 1, act->data);
- break;
- case ACT_EDIT_OBJECT:
- writestruct(wd, DATA, bEditObjectActuator, 1, act->data);
- break;
- case ACT_SCENE:
- writestruct(wd, DATA, bSceneActuator, 1, act->data);
- break;
- case ACT_GROUP:
- writestruct(wd, DATA, bGroupActuator, 1, act->data);
- break;
- case ACT_RANDOM:
- writestruct(wd, DATA, bRandomActuator, 1, act->data);
- break;
- case ACT_MESSAGE:
- writestruct(wd, DATA, bMessageActuator, 1, act->data);
- break;
- case ACT_GAME:
- writestruct(wd, DATA, bGameActuator, 1, act->data);
- break;
- case ACT_VISIBILITY:
- writestruct(wd, DATA, bVisibilityActuator, 1, act->data);
- break;
- case ACT_2DFILTER:
- writestruct(wd, DATA, bTwoDFilterActuator, 1, act->data);
- break;
- case ACT_PARENT:
- writestruct(wd, DATA, bParentActuator, 1, act->data);
- break;
- case ACT_STATE:
- writestruct(wd, DATA, bStateActuator, 1, act->data);
- break;
- case ACT_ARMATURE:
- writestruct(wd, DATA, bArmatureActuator, 1, act->data);
- break;
- case ACT_STEERING:
- writestruct(wd, DATA, bSteeringActuator, 1, act->data);
- break;
- case ACT_MOUSE:
- writestruct(wd, DATA, bMouseActuator, 1, act->data);
- break;
- default:
- ; /* error: don't know how to write this file */
- }
-
- act = act->next;
- }
-}
-
static void write_motionpath(WriteData *wd, bMotionPath *mpath)
{
/* sanity checks */
@@ -1980,10 +1803,6 @@ static void write_object(WriteData *wd, Object *ob)
writedata(wd, DATA, sizeof(void *) * ob->totcol, ob->mat);
writedata(wd, DATA, sizeof(char) * ob->totcol, ob->matbits);
/* write_effects(wd, &ob->effect); */ /* not used anymore */
- write_properties(wd, &ob->prop);
- write_sensors(wd, &ob->sensors);
- write_controllers(wd, &ob->controllers);
- write_actuators(wd, &ob->actuators);
if (ob->type == OB_ARMATURE) {
bArmature *arm = ob->data;
@@ -2004,7 +1823,6 @@ static void write_object(WriteData *wd, Object *ob)
write_pointcaches(wd, &ob->soft->ptcaches);
writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights);
}
- writestruct(wd, DATA, BulletSoftBody, 1, ob->bsoft);
if (ob->rigidbody_object) {
/* TODO: if any extra data is added to handle duplis, will need separate function then */
@@ -2486,24 +2304,6 @@ static void write_texture(WriteData *wd, Tex *tex)
if (tex->coba) {
writestruct(wd, DATA, ColorBand, 1, tex->coba);
}
- if (tex->type == TEX_ENVMAP && tex->env) {
- writestruct(wd, DATA, EnvMap, 1, tex->env);
- }
- if (tex->type == TEX_POINTDENSITY && tex->pd) {
- writestruct(wd, DATA, PointDensity, 1, tex->pd);
- if (tex->pd->coba) {
- writestruct(wd, DATA, ColorBand, 1, tex->pd->coba);
- }
- if (tex->pd->falloff_curve) {
- write_curvemapping(wd, tex->pd->falloff_curve);
- }
- }
- if (tex->type == TEX_VOXELDATA) {
- writestruct(wd, DATA, VoxelData, 1, tex->vd);
- }
- if (tex->type == TEX_OCEAN && tex->ot) {
- writestruct(wd, DATA, OceanTex, 1, tex->ot);
- }
/* nodetree is integral part of texture, no libdata */
if (tex->nodetree) {
@@ -2526,19 +2326,6 @@ static void write_material(WriteData *wd, Material *ma)
write_animdata(wd, ma->adt);
}
- for (int a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- writestruct(wd, DATA, MTex, 1, ma->mtex[a]);
- }
- }
-
- if (ma->ramp_col) {
- writestruct(wd, DATA, ColorBand, 1, ma->ramp_col);
- }
- if (ma->ramp_spec) {
- writestruct(wd, DATA, ColorBand, 1, ma->ramp_spec);
- }
-
/* nodetree is integral part of material, no libdata */
if (ma->nodetree) {
writestruct(wd, DATA, bNodeTree, 1, ma->nodetree);
@@ -2560,12 +2347,6 @@ static void write_world(WriteData *wd, World *wrld)
write_animdata(wd, wrld->adt);
}
- for (int a = 0; a < MAX_MTEX; a++) {
- if (wrld->mtex[a]) {
- writestruct(wd, DATA, MTex, 1, wrld->mtex[a]);
- }
- }
-
/* nodetree is integral part of world, no libdata */
if (wrld->nodetree) {
writestruct(wd, DATA, bNodeTree, 1, wrld->nodetree);
@@ -2587,13 +2368,6 @@ static void write_lamp(WriteData *wd, Lamp *la)
write_animdata(wd, la->adt);
}
- /* direct data */
- for (int a = 0; a < MAX_MTEX; a++) {
- if (la->mtex[a]) {
- writestruct(wd, DATA, MTex, 1, la->mtex[a]);
- }
- }
-
if (la->curfalloff) {
write_curvemapping(wd, la->curfalloff);
}
@@ -2857,6 +2631,11 @@ static void write_scene(WriteData *wd, Scene *sce)
writestruct(wd, DATA, TimeMarker, 1, marker);
}
+ /* writing dynamic list of TransformOrientations to the blend file */
+ for (TransformOrientation *ts = sce->transform_spaces.first; ts; ts = ts->next) {
+ writestruct(wd, DATA, TransformOrientation, 1, ts);
+ }
+
/* writing MultiView to the blend file */
for (SceneRenderView *srv = sce->r.views.first; srv; srv = srv->next) {
writestruct(wd, DATA, SceneRenderView, 1, srv);
@@ -2926,25 +2705,6 @@ static void write_gpencil(WriteData *wd, bGPdata *gpd)
}
}
-static void write_windowmanager(WriteData *wd, wmWindowManager *wm)
-{
- writestruct(wd, ID_WM, wmWindowManager, 1, wm);
- write_iddata(wd, &wm->id);
-
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
-
- /* update deprecated screen member (for so loading in 2.7x uses the correct screen) */
- win->screen = BKE_workspace_active_screen_get(win->workspace_hook);
-
- writestruct(wd, DATA, wmWindow, 1, win);
- writestruct(wd, DATA, WorkSpaceInstanceHook, 1, win->workspace_hook);
- writestruct(wd, DATA, Stereo3dFormat, 1, win->stereo3d_format);
-
- /* data is written, clear deprecated data again */
- win->screen = NULL;
- }
-}
-
static void write_region(WriteData *wd, ARegion *ar, int spacetype)
{
writestruct(wd, DATA, ARegion, 1, ar);
@@ -3025,169 +2785,198 @@ static void write_soops(WriteData *wd, SpaceOops *so)
}
}
-static void write_screen(WriteData *wd, bScreen *sc)
+static void write_area_regions(WriteData *wd, ScrArea *area)
{
- /* write LibData */
- /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
- writestruct(wd, ID_SCRN, bScreen, 1, sc);
- write_iddata(wd, &sc->id);
+ for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ write_region(wd, region, area->spacetype);
- write_previews(wd, sc->preview);
+ for (Panel *pa = region->panels.first; pa; pa = pa->next) {
+ writestruct(wd, DATA, Panel, 1, pa);
+ }
- /* direct data */
- for (ScrVert *sv = sc->vertbase.first; sv; sv = sv->next) {
- writestruct(wd, DATA, ScrVert, 1, sv);
- }
+ for (PanelCategoryStack *pc_act = region->panels_category_active.first; pc_act; pc_act = pc_act->next) {
+ writestruct(wd, DATA, PanelCategoryStack, 1, pc_act);
+ }
- for (ScrEdge *se = sc->edgebase.first; se; se = se->next) {
- writestruct(wd, DATA, ScrEdge, 1, se);
+ for (uiList *ui_list = region->ui_lists.first; ui_list; ui_list = ui_list->next) {
+ write_uilist(wd, ui_list);
+ }
+
+ for (uiPreview *ui_preview = region->ui_previews.first; ui_preview; ui_preview = ui_preview->next) {
+ writestruct(wd, DATA, uiPreview, 1, ui_preview);
+ }
}
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- Panel *pa;
- uiList *ui_list;
- uiPreview *ui_preview;
- PanelCategoryStack *pc_act;
- ARegion *ar;
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ for (ARegion *region = sl->regionbase.first; region; region = region->next) {
+ write_region(wd, region, sl->spacetype);
+ }
- writestruct(wd, DATA, ScrArea, 1, sa);
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ writestruct(wd, DATA, View3D, 1, v3d);
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- write_region(wd, ar, sa->spacetype);
+ if (v3d->localvd) {
+ writestruct(wd, DATA, View3D, 1, v3d->localvd);
+ }
- for (pa = ar->panels.first; pa; pa = pa->next) {
- writestruct(wd, DATA, Panel, 1, pa);
+ if (v3d->fx_settings.ssao) {
+ writestruct(wd, DATA, GPUSSAOSettings, 1, v3d->fx_settings.ssao);
+ }
+ if (v3d->fx_settings.dof) {
+ writestruct(wd, DATA, GPUDOFSettings, 1, v3d->fx_settings.dof);
}
+ }
+ else if (sl->spacetype == SPACE_IPO) {
+ SpaceIpo *sipo = (SpaceIpo *)sl;
+ ListBase tmpGhosts = sipo->ghostCurves;
- for (pc_act = ar->panels_category_active.first; pc_act; pc_act = pc_act->next) {
- writestruct(wd, DATA, PanelCategoryStack, 1, pc_act);
+ /* temporarily disable ghost curves when saving */
+ sipo->ghostCurves.first = sipo->ghostCurves.last = NULL;
+
+ writestruct(wd, DATA, SpaceIpo, 1, sl);
+ if (sipo->ads) {
+ writestruct(wd, DATA, bDopeSheet, 1, sipo->ads);
}
- for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) {
- write_uilist(wd, ui_list);
+ /* reenable ghost curves */
+ sipo->ghostCurves = tmpGhosts;
+ }
+ else if (sl->spacetype == SPACE_BUTS) {
+ writestruct(wd, DATA, SpaceButs, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)sl;
+
+ writestruct(wd, DATA, SpaceFile, 1, sl);
+ if (sfile->params) {
+ writestruct(wd, DATA, FileSelectParams, 1, sfile->params);
}
+ }
+ else if (sl->spacetype == SPACE_SEQ) {
+ writestruct(wd, DATA, SpaceSeq, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOops *so = (SpaceOops *)sl;
+ write_soops(wd, so);
+ }
+ else if (sl->spacetype == SPACE_IMAGE) {
+ writestruct(wd, DATA, SpaceImage, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_TEXT) {
+ writestruct(wd, DATA, SpaceText, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_SCRIPT) {
+ SpaceScript *scr = (SpaceScript *)sl;
+ scr->but_refs = NULL;
+ writestruct(wd, DATA, SpaceScript, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_ACTION) {
+ writestruct(wd, DATA, SpaceAction, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *snla = (SpaceNla *)sl;
- for (ui_preview = ar->ui_previews.first; ui_preview; ui_preview = ui_preview->next) {
- writestruct(wd, DATA, uiPreview, 1, ui_preview);
+ writestruct(wd, DATA, SpaceNla, 1, snla);
+ if (snla->ads) {
+ writestruct(wd, DATA, bDopeSheet, 1, snla->ads);
}
}
+ else if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+ bNodeTreePath *path;
+ writestruct(wd, DATA, SpaceNode, 1, snode);
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- for (ar = sl->regionbase.first; ar; ar = ar->next) {
- write_region(wd, ar, sl->spacetype);
+ for (path = snode->treepath.first; path; path = path->next) {
+ writestruct(wd, DATA, bNodeTreePath, 1, path);
}
+ }
+ else if (sl->spacetype == SPACE_CONSOLE) {
+ SpaceConsole *con = (SpaceConsole *)sl;
+ ConsoleLine *cl;
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- writestruct(wd, DATA, View3D, 1, v3d);
+ for (cl = con->history.first; cl; cl = cl->next) {
+ /* 'len_alloc' is invalid on write, set from 'len' on read */
+ writestruct(wd, DATA, ConsoleLine, 1, cl);
+ writedata(wd, DATA, cl->len + 1, cl->line);
+ }
+ writestruct(wd, DATA, SpaceConsole, 1, sl);
+ }
+#ifdef WITH_TOPBAR_WRITING
+ else if (sl->spacetype == SPACE_TOPBAR) {
+ writestruct(wd, DATA, SpaceTopBar, 1, sl);
+ }
+#endif
+ else if (sl->spacetype == SPACE_USERPREF) {
+ writestruct(wd, DATA, SpaceUserPref, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_CLIP) {
+ writestruct(wd, DATA, SpaceClip, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_INFO) {
+ writestruct(wd, DATA, SpaceInfo, 1, sl);
+ }
+ }
+}
- if (v3d->localvd) {
- writestruct(wd, DATA, View3D, 1, v3d->localvd);
- }
+static void write_area_map(WriteData *wd, ScrAreaMap *area_map)
+{
+ writelist(wd, DATA, ScrVert, &area_map->vertbase);
+ writelist(wd, DATA, ScrEdge, &area_map->edgebase);
+ for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
+ writestruct(wd, DATA, ScrArea, 1, area);
- if (v3d->fx_settings.ssao) {
- writestruct(wd, DATA, GPUSSAOSettings, 1, v3d->fx_settings.ssao);
- }
- if (v3d->fx_settings.dof) {
- writestruct(wd, DATA, GPUDOFSettings, 1, v3d->fx_settings.dof);
- }
- }
- else if (sl->spacetype == SPACE_IPO) {
- SpaceIpo *sipo = (SpaceIpo *)sl;
- ListBase tmpGhosts = sipo->ghostCurves;
+#ifdef WITH_TOPBAR_WRITING
+ writestruct(wd, DATA, ScrGlobalAreaData, 1, area->global);
+#endif
- /* temporarily disable ghost curves when saving */
- sipo->ghostCurves.first = sipo->ghostCurves.last = NULL;
+ write_area_regions(wd, area);
+ }
+}
- writestruct(wd, DATA, SpaceIpo, 1, sl);
- if (sipo->ads) {
- writestruct(wd, DATA, bDopeSheet, 1, sipo->ads);
- }
+static void write_windowmanager(WriteData *wd, wmWindowManager *wm)
+{
+ writestruct(wd, ID_WM, wmWindowManager, 1, wm);
+ write_iddata(wd, &wm->id);
- /* reenable ghost curves */
- sipo->ghostCurves = tmpGhosts;
- }
- else if (sl->spacetype == SPACE_BUTS) {
- writestruct(wd, DATA, SpaceButs, 1, sl);
- }
- else if (sl->spacetype == SPACE_FILE) {
- SpaceFile *sfile = (SpaceFile *)sl;
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+#ifndef WITH_TOPBAR_WRITING
+ /* Don't write global areas yet, while we make changes to them. */
+ ScrAreaMap global_areas = win->global_areas;
+ memset(&win->global_areas, 0, sizeof(win->global_areas));
+#endif
- writestruct(wd, DATA, SpaceFile, 1, sl);
- if (sfile->params) {
- writestruct(wd, DATA, FileSelectParams, 1, sfile->params);
- }
- }
- else if (sl->spacetype == SPACE_SEQ) {
- writestruct(wd, DATA, SpaceSeq, 1, sl);
- }
- else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOops *so = (SpaceOops *)sl;
- write_soops(wd, so);
- }
- else if (sl->spacetype == SPACE_IMAGE) {
- writestruct(wd, DATA, SpaceImage, 1, sl);
- }
- else if (sl->spacetype == SPACE_TEXT) {
- writestruct(wd, DATA, SpaceText, 1, sl);
- }
- else if (sl->spacetype == SPACE_SCRIPT) {
- SpaceScript *scr = (SpaceScript *)sl;
- scr->but_refs = NULL;
- writestruct(wd, DATA, SpaceScript, 1, sl);
- }
- else if (sl->spacetype == SPACE_ACTION) {
- writestruct(wd, DATA, SpaceAction, 1, sl);
- }
- else if (sl->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)sl;
+ /* update deprecated screen member (for so loading in 2.7x uses the correct screen) */
+ win->screen = BKE_workspace_active_screen_get(win->workspace_hook);
- writestruct(wd, DATA, SpaceNla, 1, snla);
- if (snla->ads) {
- writestruct(wd, DATA, bDopeSheet, 1, snla->ads);
- }
- }
- else if (sl->spacetype == SPACE_TIME) {
- writestruct(wd, DATA, SpaceTime, 1, sl);
- }
- else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
- bNodeTreePath *path;
- writestruct(wd, DATA, SpaceNode, 1, snode);
+ writestruct(wd, DATA, wmWindow, 1, win);
+ writestruct(wd, DATA, WorkSpaceInstanceHook, 1, win->workspace_hook);
+ writestruct(wd, DATA, Stereo3dFormat, 1, win->stereo3d_format);
- for (path = snode->treepath.first; path; path = path->next) {
- writestruct(wd, DATA, bNodeTreePath, 1, path);
- }
- }
- else if (sl->spacetype == SPACE_LOGIC) {
- writestruct(wd, DATA, SpaceLogic, 1, sl);
- }
- else if (sl->spacetype == SPACE_CONSOLE) {
- SpaceConsole *con = (SpaceConsole *)sl;
- ConsoleLine *cl;
-
- for (cl = con->history.first; cl; cl = cl->next) {
- /* 'len_alloc' is invalid on write, set from 'len' on read */
- writestruct(wd, DATA, ConsoleLine, 1, cl);
- writedata(wd, DATA, cl->len + 1, cl->line);
- }
- writestruct(wd, DATA, SpaceConsole, 1, sl);
+#ifdef WITH_TOPBAR_WRITING
+ write_area_map(wd, &win->global_areas);
+#else
+ win->global_areas = global_areas;
+#endif
- }
- else if (sl->spacetype == SPACE_USERPREF) {
- writestruct(wd, DATA, SpaceUserPref, 1, sl);
- }
- else if (sl->spacetype == SPACE_CLIP) {
- writestruct(wd, DATA, SpaceClip, 1, sl);
- }
- else if (sl->spacetype == SPACE_INFO) {
- writestruct(wd, DATA, SpaceInfo, 1, sl);
- }
- }
+ /* data is written, clear deprecated data again */
+ win->screen = NULL;
}
}
+static void write_screen(WriteData *wd, bScreen *sc)
+{
+ /* write LibData */
+ /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
+ writestruct(wd, ID_SCRN, bScreen, 1, sc);
+ write_iddata(wd, &sc->id);
+
+ write_previews(wd, sc->preview);
+
+ /* direct data */
+ write_area_map(wd, AREAMAP_FROM_SCREEN(sc));
+}
+
static void write_bone(WriteData *wd, Bone *bone)
{
/* PATCH for upward compatibility after 2.37+ armature recode */
@@ -3838,14 +3627,12 @@ static void write_cachefile(WriteData *wd, CacheFile *cache_file)
static void write_workspace(WriteData *wd, WorkSpace *workspace)
{
ListBase *layouts = BKE_workspace_layouts_get(workspace);
- ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace);
writestruct(wd, ID_WS, WorkSpace, 1, workspace);
writelist(wd, DATA, WorkSpaceLayout, layouts);
writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations);
writelist(wd, DATA, WorkSpaceDataRelation, &workspace->scene_viewlayer_relations);
writelist(wd, DATA, wmOwnerID, &workspace->owner_ids);
- writelist(wd, DATA, TransformOrientation, transform_orientations);
}
static void write_groom(WriteData *wd, Groom *groom)
@@ -4306,6 +4093,11 @@ bool BLO_write_file(
void *path_list_backup = NULL;
const int path_list_flag = (BKE_BPATH_TRAVERSE_SKIP_LIBRARY | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE);
+ if (G.debug & G_DEBUG_IO && mainvar->lock != NULL) {
+ BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *BEFORE* save to disk.");
+ BLO_main_validate_libraries(mainvar, reports);
+ }
+
/* open temporary file, so we preserve the original in case we crash */
BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
@@ -4390,6 +4182,11 @@ bool BLO_write_file(
return 0;
}
+ if (G.debug & G_DEBUG_IO && mainvar->lock != NULL) {
+ BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *AFTER* save to disk.");
+ BLO_main_validate_libraries(mainvar, reports);
+ }
+
return 1;
}
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 9e03c28ba1b..8071637d95e 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -1160,7 +1160,7 @@ void bmesh_edit_end(BMesh *bm, BMOpTypeFlag type_flag)
}
}
-void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
+void BM_mesh_elem_index_ensure_ex(BMesh *bm, const char htype, int elem_offset[4])
{
const char htype_needed = bm->elem_index_dirty & htype;
@@ -1173,15 +1173,15 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
}
if (htype & BM_VERT) {
- if (bm->elem_index_dirty & BM_VERT) {
+ if ((bm->elem_index_dirty & BM_VERT) || (elem_offset && elem_offset[0])) {
BMIter iter;
BMElem *ele;
- int index;
- BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, index) {
- BM_elem_index_set(ele, index); /* set_ok */
+ int index = elem_offset ? elem_offset[0] : 0;
+ BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_elem_index_set(ele, index++); /* set_ok */
}
- BLI_assert(index == bm->totvert);
+ BLI_assert(elem_offset || index == bm->totvert);
}
else {
// printf("%s: skipping vert index calc!\n", __func__);
@@ -1189,15 +1189,15 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
}
if (htype & BM_EDGE) {
- if (bm->elem_index_dirty & BM_EDGE) {
+ if ((bm->elem_index_dirty & BM_EDGE) || (elem_offset && elem_offset[1])) {
BMIter iter;
BMElem *ele;
- int index;
- BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, index) {
- BM_elem_index_set(ele, index); /* set_ok */
+ int index = elem_offset ? elem_offset[1] : 0;
+ BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
+ BM_elem_index_set(ele, index++); /* set_ok */
}
- BLI_assert(index == bm->totedge);
+ BLI_assert(elem_offset || index == bm->totedge);
}
else {
// printf("%s: skipping edge index calc!\n", __func__);
@@ -1205,19 +1205,19 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
}
if (htype & (BM_FACE | BM_LOOP)) {
- if (bm->elem_index_dirty & (BM_FACE | BM_LOOP)) {
+ if ((bm->elem_index_dirty & (BM_FACE | BM_LOOP)) || (elem_offset && (elem_offset[2] || elem_offset[3]))) {
BMIter iter;
BMElem *ele;
const bool update_face = (htype & BM_FACE) && (bm->elem_index_dirty & BM_FACE);
const bool update_loop = (htype & BM_LOOP) && (bm->elem_index_dirty & BM_LOOP);
- int index;
- int index_loop = 0;
+ int index_loop = elem_offset ? elem_offset[2] : 0;
+ int index = elem_offset ? elem_offset[3] : 0;
- BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, index) {
+ BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
if (update_face) {
- BM_elem_index_set(ele, index); /* set_ok */
+ BM_elem_index_set(ele, index++); /* set_ok */
}
if (update_loop) {
@@ -1230,9 +1230,9 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
}
}
- BLI_assert(index == bm->totface);
+ BLI_assert(elem_offset || !update_face || index == bm->totface);
if (update_loop) {
- BLI_assert(index_loop == bm->totloop);
+ BLI_assert(elem_offset || !update_loop || index_loop == bm->totloop);
}
}
else {
@@ -1242,6 +1242,37 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
finally:
bm->elem_index_dirty &= ~htype;
+ if (elem_offset) {
+ if (htype & BM_VERT) {
+ elem_offset[0] += bm->totvert;
+ if (elem_offset[0] != bm->totvert) {
+ bm->elem_index_dirty |= BM_VERT;
+ }
+ }
+ if (htype & BM_EDGE) {
+ elem_offset[1] += bm->totedge;
+ if (elem_offset[1] != bm->totedge) {
+ bm->elem_index_dirty |= BM_EDGE;
+ }
+ }
+ if (htype & BM_LOOP) {
+ elem_offset[2] += bm->totloop;
+ if (elem_offset[2] != bm->totloop) {
+ bm->elem_index_dirty |= BM_LOOP;
+ }
+ }
+ if (htype & BM_FACE) {
+ elem_offset[3] += bm->totface;
+ if (elem_offset[3] != bm->totface) {
+ bm->elem_index_dirty |= BM_FACE;
+ }
+ }
+ }
+}
+
+void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
+{
+ BM_mesh_elem_index_ensure_ex(bm, htype, NULL);
}
diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h
index 10f024423aa..3ebe6535a8b 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -60,6 +60,7 @@ void BM_edges_sharp_from_angle_set(BMesh *bm, const float split_angle);
void bmesh_edit_begin(BMesh *bm, const BMOpTypeFlag type_flag);
void bmesh_edit_end(BMesh *bm, const BMOpTypeFlag type_flag);
+void BM_mesh_elem_index_ensure_ex(BMesh *bm, const char htype, int elem_offset[4]);
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,
@@ -119,7 +120,7 @@ extern const BMAllocTemplate bm_mesh_chunksize_default;
(dm)->getNumEdges(dm), \
(dm)->getNumLoops(dm), \
(dm)->getNumPolys(dm), \
- }
+}
#define _VA_BMALLOC_TEMPLATE_FROM_DM_2(dm_a, dm_b) { \
(CHECK_TYPE_INLINE(dm_a, DerivedMesh *), \
CHECK_TYPE_INLINE(dm_b, DerivedMesh *), \
@@ -127,7 +128,7 @@ extern const BMAllocTemplate bm_mesh_chunksize_default;
(dm_a)->getNumEdges(dm_a) + (dm_b)->getNumEdges(dm_b), \
(dm_a)->getNumLoops(dm_a) + (dm_b)->getNumLoops(dm_b), \
(dm_a)->getNumPolys(dm_a) + (dm_b)->getNumPolys(dm_b), \
- }
+}
#define BMALLOC_TEMPLATE_FROM_DM(...) VA_NARGS_CALL_OVERLOAD(_VA_BMALLOC_TEMPLATE_FROM_DM_, __VA_ARGS__)
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 37a4fb5c29c..d98d69ed40f 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -112,7 +112,7 @@ static BMOpDefine bmo_smooth_vert_def = {
{"use_axis_x", BMO_OP_SLOT_BOOL}, /* smooth vertices along X axis */
{"use_axis_y", BMO_OP_SLOT_BOOL}, /* smooth vertices along Y axis */
{"use_axis_z", BMO_OP_SLOT_BOOL}, /* smooth vertices along Z axis */
- {{'\0'}},
+ {{'\0'}},
},
{{{'\0'}}}, /* no output */
bmo_smooth_vert_exec,
@@ -135,7 +135,7 @@ static BMOpDefine bmo_smooth_laplacian_vert_def = {
{"use_y", BMO_OP_SLOT_BOOL}, /* Smooth object along Y axis */
{"use_z", BMO_OP_SLOT_BOOL}, /* Smooth object along Z axis */
{"preserve_volume", BMO_OP_SLOT_BOOL}, /* Apply volume preservation after smooth */
- {{'\0'}},
+ {{'\0'}},
},
{{{'\0'}}}, /* no output */
bmo_smooth_laplacian_vert_exec,
@@ -839,7 +839,7 @@ static BMOpDefine bmo_bmesh_to_mesh_def = {
"bmesh_to_mesh",
/* slots_in */
{
- /* pointer to a mesh structure to fill in */
+ /* pointer to a mesh structure to fill in */
{"mesh", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_MESH}},
/* pointer to an object structure */
{"object", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_OBJECT}},
@@ -860,7 +860,7 @@ static BMOpDefine bmo_mesh_to_bmesh_def = {
"mesh_to_bmesh",
/* slots_in */
{
- /* pointer to a Mesh structure */
+ /* pointer to a Mesh structure */
{"mesh", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_MESH}},
/* pointer to an Object structure */
{"object", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_OBJECT}},
@@ -1337,7 +1337,7 @@ static BMOpDefine bmo_duplicate_def = {
{"face_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"boundary_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"isovert_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
- {{'\0'}},
+ {{'\0'}},
},
bmo_duplicate_exec,
(BMO_OPTYPE_FLAG_NORMALS_CALC |
diff --git a/source/blender/bmesh/operators/bmo_offset_edgeloops.c b/source/blender/bmesh/operators/bmo_offset_edgeloops.c
index 269f933f27f..d54efc27124 100644
--- a/source/blender/bmesh/operators/bmo_offset_edgeloops.c
+++ b/source/blender/bmesh/operators/bmo_offset_edgeloops.c
@@ -242,6 +242,7 @@ void bmo_offset_edgeloops_exec(BMesh *bm, BMOperator *op)
#if 0
else if (BM_elem_index_get(l->prev->v) == -1) {
if (BM_elem_index_get(l->next->next->v) == -1) {
+ /* pass */
}
}
#endif
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 2f692cb0f33..439f48897f6 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -38,7 +38,7 @@ bool AnimationExporter::exportAnimations(Scene *sce)
{
bool has_animations = hasAnimations(sce);
if (has_animations) {
- this->eval_ctx = eval_ctx;
+ this->depsgraph = depsgraph;
this->scene = sce;
openLibrary();
@@ -215,7 +215,7 @@ void AnimationExporter::export_sampled_matrix_animation(Object *ob, std::vector<
for (std::vector<float>::iterator ctime = ctimes.begin(); ctime != ctimes.end(); ++ctime) {
float fmat[4][4];
- bc_update_scene(eval_ctx, scene, *ctime);
+ bc_update_scene(depsgraph, scene, *ctime);
BKE_object_matrix_local_get(ob, fmat);
if (this->export_settings->limit_precision)
bc_sanitize_mat(fmat, 6);
@@ -247,7 +247,7 @@ void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::ve
float fsize[3];
float feul[3];
- bc_update_scene(eval_ctx, scene, *ctime);
+ bc_update_scene(depsgraph, scene, *ctime);
BKE_object_matrix_local_get(ob, fmat);
mat4_decompose(floc, fquat, fsize, fmat);
quat_to_eul(feul, fquat);
@@ -722,7 +722,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
if (flag & ARM_RESTPOS) {
arm->flag &= ~ARM_RESTPOS;
- BKE_pose_where_is(eval_ctx, scene, ob_arm);
+ BKE_pose_where_is(depsgraph, scene, ob_arm);
}
if (fra.size()) {
@@ -731,7 +731,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
if (flag & ARM_RESTPOS)
arm->flag = flag;
- BKE_pose_where_is(eval_ctx, scene, ob_arm);
+ BKE_pose_where_is(depsgraph, scene, ob_arm);
}
void AnimationExporter::dae_baked_animation(std::vector<float> &fra, Object *ob_arm, Bone *bone)
@@ -1022,7 +1022,7 @@ void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime)
if (obtar) {
BKE_animsys_evaluate_animdata(scene, &obtar->id, obtar->adt, ctime, ADT_RECALC_ANIM);
- BKE_object_where_is_calc_time(this->eval_ctx, scene, obtar, ctime);
+ BKE_object_where_is_calc_time(this->depsgraph, scene, obtar, ctime);
}
}
@@ -1030,7 +1030,7 @@ void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime)
cti->flush_constraint_targets(con, &targets, 1);
}
}
- BKE_object_where_is_calc_time(this->eval_ctx, scene, ob, ctime);
+ BKE_object_where_is_calc_time(this->depsgraph, scene, ob, ctime);
}
/*
@@ -1316,16 +1316,16 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
float frame = *it;
float ctime = BKE_scene_frame_get_from_ctime(scene, frame);
- bc_update_scene(eval_ctx, scene, ctime);
+ bc_update_scene(depsgraph, scene, ctime);
if (is_bone_animation) {
if (pchan->flag & POSE_CHAIN) {
enable_fcurves(ob->adt->action, NULL);
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
- BKE_pose_where_is(eval_ctx, scene, ob);
+ BKE_pose_where_is(depsgraph, scene, ob);
}
else {
- BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
+ BKE_pose_where_is_bone(depsgraph, scene, ob, pchan, ctime, 1);
}
// compute bone local mat
@@ -1843,7 +1843,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
// exit rest position
if (flag & ARM_RESTPOS) {
arm->flag &= ~ARM_RESTPOS;
- BKE_pose_where_is(eval_ctx, scene, ob_arm);
+ BKE_pose_where_is(depsgraph, scene, ob_arm);
}
//v array will hold all values which will be exported.
if (fra.size()) {
@@ -1873,7 +1873,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
// restore restpos
if (flag & ARM_RESTPOS)
arm->flag = flag;
- BKE_pose_where_is(eval_ctx, scene, ob_arm);
+ BKE_pose_where_is(depsgraph, scene, ob_arm);
}
void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan)
@@ -1898,7 +1898,7 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i
BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM);
- BKE_pose_where_is_bone(eval_ctx, scene, ob_arm, pchan, ctime, 1);
+ BKE_pose_where_is_bone(depsgraph, scene, ob_arm, pchan, ctime, 1);
// compute bone local mat
if (bone->parent) {
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index d2216c04ee5..2ed0a92d89c 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -79,20 +79,20 @@ extern "C"
#include <vector>
#include <algorithm> // std::find
-struct EvaluationContext;
+struct Depsgraph;
class AnimationExporter: COLLADASW::LibraryAnimations
{
private:
Scene *scene;
- EvaluationContext *eval_ctx;
+ Depsgraph *depsgraph;
COLLADASW::StreamWriter *sw;
public:
- AnimationExporter(EvaluationContext *eval_ctx, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings):
- eval_ctx(eval_ctx),
+ AnimationExporter(Depsgraph *depsgraph, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings):
COLLADASW::LibraryAnimations(sw),
+ depsgraph(depsgraph),
export_settings(export_settings)
{
this->sw = sw;
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index b12ecb50e32..f37b0ee1319 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -81,7 +81,7 @@ void AnimationImporter::add_bezt(FCurve *fcu, float frame, float value, eBezTrip
bez.ipo = ipo; /* use default interpolation mode here... */
bez.f1 = bez.f2 = bez.f3 = SELECT;
bez.h1 = bez.h2 = HD_AUTO;
- insert_bezt_fcurve(fcu, &bez, 0);
+ insert_bezt_fcurve(fcu, &bez, INSERTKEY_NOFLAGS);
calchandles_fcurve(fcu);
}
@@ -148,7 +148,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
// bez.ipo = U.ipo_new; /* use default interpolation mode here... */
bez.f1 = bez.f2 = bez.f3 = SELECT;
- insert_bezt_fcurve(fcu, &bez, 0);
+ insert_bezt_fcurve(fcu, &bez, INSERTKEY_NOFLAGS);
}
calchandles_fcurve(fcu);
@@ -566,14 +566,16 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
}
case COLLADAFW::Transformation::MATRIX:
- /*{
- COLLADAFW::Matrix *mat = (COLLADAFW::Matrix*)transform;
- COLLADABU::Math::Matrix4 mat4 = mat->getMatrix();
- switch (binding->animationClass) {
- case COLLADAFW::AnimationList::TRANSFORM:
-
- }
- }*/
+#if 0
+ {
+ COLLADAFW::Matrix *mat = (COLLADAFW::Matrix*)transform;
+ COLLADABU::Math::Matrix4 mat4 = mat->getMatrix();
+ switch (binding->animationClass) {
+ case COLLADAFW::AnimationList::TRANSFORM:
+
+ }
+ }
+#endif
unused_fcurve(curves);
break;
case COLLADAFW::Transformation::SKEW:
@@ -1751,7 +1753,8 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
if (type != COLLADAFW::Transformation::ROTATE &&
type != COLLADAFW::Transformation::SCALE &&
type != COLLADAFW::Transformation::TRANSLATE &&
- type != COLLADAFW::Transformation::MATRIX) {
+ type != COLLADAFW::Transformation::MATRIX)
+ {
fprintf(stderr, "animation of transformation %d is not supported yet\n", type);
return false;
}
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index fbceb6e077f..5e349535610 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -62,7 +62,7 @@ ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSett
}
// write bone nodes
-void ArmatureExporter::add_armature_bones(const EvaluationContext *eval_ctx, Object *ob_arm,
+void ArmatureExporter::add_armature_bones(Depsgraph *depsgraph, Object *ob_arm,
Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects)
{
@@ -77,7 +77,7 @@ void ArmatureExporter::add_armature_bones(const EvaluationContext *eval_ctx, Obj
for (Bone *bone = (Bone *)armature->bonebase.first; bone; bone = bone->next) {
// start from root bones
if (!bone->parent)
- add_bone_node(eval_ctx, bone, ob_arm, sce, se, child_objects);
+ add_bone_node(depsgraph, bone, ob_arm, sce, se, child_objects);
}
if (!is_edited) {
@@ -157,7 +157,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
#endif
// parent_mat is armature-space
-void ArmatureExporter::add_bone_node(const EvaluationContext *eval_ctx, Bone *bone, Object *ob_arm, Scene *sce,
+void ArmatureExporter::add_bone_node(Depsgraph *depsgraph, Bone *bone, Object *ob_arm, Scene *sce,
SceneExporter *se,
std::list<Object *>& child_objects)
{
@@ -231,7 +231,7 @@ void ArmatureExporter::add_bone_node(const EvaluationContext *eval_ctx, Bone *bo
mul_m4_m4m4((*i)->parentinv, temp, (*i)->parentinv);
}
- se->writeNodes(eval_ctx, *i, sce);
+ se->writeNodes(depsgraph, *i, sce);
copy_m4_m4((*i)->parentinv, backup_parinv);
child_objects.erase(i++);
@@ -240,13 +240,13 @@ void ArmatureExporter::add_bone_node(const EvaluationContext *eval_ctx, Bone *bo
}
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- add_bone_node(eval_ctx, child, ob_arm, sce, se, child_objects);
+ add_bone_node(depsgraph, child, ob_arm, sce, se, child_objects);
}
node.end();
}
else {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- add_bone_node(eval_ctx, child, ob_arm, sce, se, child_objects);
+ add_bone_node(depsgraph, child, ob_arm, sce, se, child_objects);
}
}
}
diff --git a/source/blender/collada/ArmatureExporter.h b/source/blender/collada/ArmatureExporter.h
index a3ed97c3a43..17c02d637e8 100644
--- a/source/blender/collada/ArmatureExporter.h
+++ b/source/blender/collada/ArmatureExporter.h
@@ -60,7 +60,7 @@ public:
ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
// write bone nodes
- void add_armature_bones(const struct EvaluationContext *eval_ctx, Object *ob_arm, Scene *sce, SceneExporter *se,
+ void add_armature_bones(struct Depsgraph *depsgraph, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects);
bool add_instance_controller(Object *ob);
@@ -85,7 +85,7 @@ private:
// Scene, SceneExporter and the list of child_objects
// are required for writing bone parented objects
- void add_bone_node(const struct EvaluationContext *eval_ctx, Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se,
+ void add_bone_node(struct Depsgraph *depsgraph, Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects);
void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node);
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index b2794b3bd23..f24688479af 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -104,7 +104,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
it = std::find(finished_joints.begin(), finished_joints.end(), node);
if (it != finished_joints.end()) return chain_length;
- EditBone *bone = ED_armature_edit_bone_add(arm, (char *)bc_get_joint_name(node));
+ EditBone *bone = ED_armature_ebone_add(arm, bc_get_joint_name(node));
totbone++;
/*
@@ -636,8 +636,8 @@ Object *ArmatureImporter::create_armature_bones(SkinInfo& skin)
}
void ArmatureImporter::set_pose(Object *ob_arm, COLLADAFW::Node *root_node, const char *parentname, float parent_mat[4][4])
-{
- char *bone_name = (char *) bc_get_joint_name(root_node);
+{
+ const char *bone_name = bc_get_joint_name(root_node);
float mat[4][4];
float obmat[4][4];
diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp
index f32cb624f78..f6dbc965b42 100644
--- a/source/blender/collada/ControllerExporter.cpp
+++ b/source/blender/collada/ControllerExporter.cpp
@@ -104,9 +104,9 @@ bool ControllerExporter::add_instance_controller(Object *ob)
return true;
}
-void ControllerExporter::export_controllers(const struct EvaluationContext *eval_ctx, Scene *sce)
+void ControllerExporter::export_controllers(struct Depsgraph *depsgraph, Scene *sce)
{
- this->eval_ctx = eval_ctx;
+ this->depsgraph = depsgraph;
scene = sce;
openLibrary();
@@ -198,7 +198,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
bool use_instantiation = this->export_settings->use_object_instantiation;
Mesh *me;
- me = bc_get_mesh_copy(eval_ctx, scene,
+ me = bc_get_mesh_copy(depsgraph, scene,
ob,
this->export_settings->export_mesh_type,
this->export_settings->apply_modifiers,
@@ -300,7 +300,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key)
bool use_instantiation = this->export_settings->use_object_instantiation;
Mesh *me;
- me = bc_get_mesh_copy(eval_ctx, scene,
+ me = bc_get_mesh_copy(depsgraph, scene,
ob,
this->export_settings->export_mesh_type,
this->export_settings->apply_modifiers,
@@ -495,7 +495,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
// put armature in rest position
if (!(arm->flag & ARM_RESTPOS)) {
arm->flag |= ARM_RESTPOS;
- BKE_pose_where_is(eval_ctx, scene, ob_arm);
+ BKE_pose_where_is(depsgraph, scene, ob_arm);
}
for (bDeformGroup *def = (bDeformGroup *)defbase->first; def; def = def->next) {
@@ -543,7 +543,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
// back from rest positon
if (!(flag & ARM_RESTPOS)) {
arm->flag = flag;
- BKE_pose_where_is(eval_ctx, scene, ob_arm);
+ BKE_pose_where_is(depsgraph, scene, ob_arm);
}
source.finish();
diff --git a/source/blender/collada/ControllerExporter.h b/source/blender/collada/ControllerExporter.h
index a1d46c5aafb..e13d7c7ebea 100644
--- a/source/blender/collada/ControllerExporter.h
+++ b/source/blender/collada/ControllerExporter.h
@@ -54,7 +54,7 @@
#include "BKE_key.h"
-struct EvaluationContext;
+struct Depsgraph;
class SceneExporter;
class ControllerExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
@@ -66,12 +66,12 @@ public:
bool add_instance_controller(Object *ob);
- void export_controllers(const struct EvaluationContext *eval_ctx, Scene *sce);
+ void export_controllers(struct Depsgraph *depsgraph, Scene *sce);
void operator()(Object *ob);
private:
- const struct EvaluationContext *eval_ctx;
+ struct Depsgraph *depsgraph;
Scene *scene;
UnitConverter converter;
const ExportSettings *export_settings;
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index 04af73f2406..a66c4db7b4d 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -71,7 +71,6 @@ extern "C"
#include "DNA_mesh_types.h"
#include "DNA_image_types.h"
#include "DNA_material_types.h"
-#include "DNA_texture_types.h"
#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_curve_types.h"
@@ -152,8 +151,8 @@ char *bc_CustomData_get_active_layer_name(const CustomData *data, int type)
return data->layers[layer_index].name;
}
-DocumentExporter::DocumentExporter(EvaluationContext *eval_ctx, const ExportSettings *export_settings) :
- eval_ctx(eval_ctx),
+DocumentExporter::DocumentExporter(Depsgraph *depsgraph, const ExportSettings *export_settings) :
+ depsgraph(depsgraph),
export_settings(export_settings) {
}
@@ -288,7 +287,7 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
// <library_geometries>
if (bc_has_object_type(export_set, OB_MESH)) {
GeometryExporter ge(writer, this->export_settings);
- ge.exportGeom(eval_ctx, sce);
+ ge.exportGeom(depsgraph, sce);
}
// <library_controllers>
@@ -296,7 +295,7 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
ControllerExporter controller_exporter(writer, this->export_settings);
if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys)
{
- controller_exporter.export_controllers(eval_ctx, sce);
+ controller_exporter.export_controllers(depsgraph, sce);
}
// <library_visual_scenes>
@@ -305,10 +304,10 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
if (this->export_settings->include_animations) {
// <library_animations>
- AnimationExporter ae(eval_ctx, writer, this->export_settings);
+ AnimationExporter ae(depsgraph, writer, this->export_settings);
ae.exportAnimations(sce);
}
- se.exportScene(eval_ctx, sce);
+ se.exportScene(depsgraph, sce);
// <scene>
std::string scene_name(translate_id(id_name(sce)));
diff --git a/source/blender/collada/DocumentExporter.h b/source/blender/collada/DocumentExporter.h
index 68e1523fbee..c98f82e68b4 100644
--- a/source/blender/collada/DocumentExporter.h
+++ b/source/blender/collada/DocumentExporter.h
@@ -39,13 +39,13 @@ struct Scene;
class DocumentExporter
{
public:
- DocumentExporter(EvaluationContext *eval_ctx, const ExportSettings *export_settings);
+ DocumentExporter(Depsgraph *depsgraph, const ExportSettings *export_settings);
int exportCurrentScene(Scene *sce);
void exportScenes(const char *filename);
private:
+ Depsgraph *depsgraph;
const ExportSettings *export_settings;
- EvaluationContext *eval_ctx;
};
#endif
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 97b11f72509..d50c4bb23c4 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -62,7 +62,6 @@ extern "C" {
#include "BKE_layer.h"
#include "BKE_lamp.h"
#include "BKE_library.h"
-#include "BKE_texture.h"
#include "BKE_fcurve.h"
#include "BKE_scene.h"
#include "BKE_global.h"
@@ -544,8 +543,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
// maybe join multiple <instance_...> meshes into 1, and link object with it? not sure...
// <instance_geometry>
while (geom_done < geom.getCount()) {
- ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map,
- material_texture_mapping_map);
+ ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map);
if (ob == NULL) {
report_unknown_reference(*node, "instance_mesh");
}
@@ -585,7 +583,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
}
while (controller_done < controller.getCount()) {
COLLADAFW::InstanceGeometry *geometry = (COLLADAFW::InstanceGeometry *)controller[controller_done];
- ob = mesh_importer.create_mesh_object(node, geometry, true, uid_material_map, material_texture_mapping_map);
+ ob = mesh_importer.create_mesh_object(node, geometry, true, uid_material_map);
if (ob == NULL) {
report_unknown_reference(*node, "instance_controller");
}
@@ -765,102 +763,74 @@ bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat)
return true;
}
-// create mtex, create texture, set texture image
-MTex *DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::Texture &ctex, Material *ma,
- int i, TexIndexTextureArrayMap &texindex_texarray_map)
-{
- COLLADAFW::SamplerPointerArray& samp_array = ef->getSamplerPointerArray();
- COLLADAFW::Sampler *sampler = samp_array[ctex.getSamplerId()];
-
- const COLLADAFW::UniqueId& ima_uid = sampler->getSourceImage();
-
- if (uid_image_map.find(ima_uid) == uid_image_map.end()) {
- fprintf(stderr, "Couldn't find an image by UID.\n");
- return NULL;
- }
-
- ma->mtex[i] = BKE_texture_mtex_add();
- ma->mtex[i]->texco = TEXCO_UV;
- ma->mtex[i]->tex = BKE_texture_add(G.main, "Texture");
- ma->mtex[i]->tex->type = TEX_IMAGE;
- ma->mtex[i]->tex->ima = uid_image_map[ima_uid];
-
- texindex_texarray_map[ctex.getTextureMapId()].push_back(ma->mtex[i]);
-
- return ma->mtex[i];
-}
-
void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Material *ma)
{
COLLADAFW::EffectCommon::ShaderType shader = ef->getShaderType();
+
+ // TODO: add back texture and extended material parameter support
// blinn
if (shader == COLLADAFW::EffectCommon::SHADER_BLINN) {
+#if 0
ma->spec_shader = MA_SPEC_BLINN;
ma->spec = ef->getShininess().getFloatValue();
+#endif
}
// phong
else if (shader == COLLADAFW::EffectCommon::SHADER_PHONG) {
+#if 0
ma->spec_shader = MA_SPEC_PHONG;
ma->har = ef->getShininess().getFloatValue();
+#endif
}
// lambert
else if (shader == COLLADAFW::EffectCommon::SHADER_LAMBERT) {
+#if 0
ma->diff_shader = MA_DIFF_LAMBERT;
+#endif
}
// default - lambert
else {
+#if 0
ma->diff_shader = MA_DIFF_LAMBERT;
fprintf(stderr, "Current shader type is not supported, default to lambert.\n");
+#endif
}
// reflectivity
ma->ray_mirror = ef->getReflectivity().getFloatValue();
// index of refraction
+#if 0
ma->ang = ef->getIndexOfRefraction().getFloatValue();
+#endif
- int i = 0;
COLLADAFW::Color col;
- MTex *mtex = NULL;
- TexIndexTextureArrayMap texindex_texarray_map;
// DIFFUSE
// color
if (ef->getDiffuse().isColor()) {
- /* too high intensity can create artefacts (fireflies)
- So here we take care that intensity is set to 0.8 wherever possible
- */
col = ef->getDiffuse().getColor();
- ma->ref = max_ffff(col.getRed(), col.getGreen(), col.getBlue(), 0.8);
- ma->r = col.getRed() / ma->ref;
- ma->g = col.getGreen() / ma->ref;
- ma->b = col.getBlue() / ma->ref;
+ ma->r = col.getRed();
+ ma->g = col.getGreen();
+ ma->b = col.getBlue();
}
// texture
else if (ef->getDiffuse().isTexture()) {
+#if 0
COLLADAFW::Texture ctex = ef->getDiffuse().getTexture();
- mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
- if (mtex != NULL) {
- mtex->mapto = MAP_COL;
- ma->texact = (int)i;
- i++;
- }
+#endif
}
// AMBIENT
// color
if (ef->getAmbient().isColor()) {
+#if 0
col = ef->getAmbient().getColor();
- ma->ambr = col.getRed();
- ma->ambg = col.getGreen();
- ma->ambb = col.getBlue();
+#endif
}
// texture
else if (ef->getAmbient().isTexture()) {
+#if 0
COLLADAFW::Texture ctex = ef->getAmbient().getTexture();
- mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
- if (mtex != NULL) {
- mtex->mapto = MAP_AMB;
- i++;
- }
+#endif
}
// SPECULAR
// color
@@ -872,29 +842,22 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
}
// texture
else if (ef->getSpecular().isTexture()) {
+#if 0
COLLADAFW::Texture ctex = ef->getSpecular().getTexture();
- mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
- if (mtex != NULL) {
- mtex->mapto = MAP_SPEC;
- i++;
- }
+#endif
}
// REFLECTIVE
// color
if (ef->getReflective().isColor()) {
+#if 0
col = ef->getReflective().getColor();
- ma->mirr = col.getRed();
- ma->mirg = col.getGreen();
- ma->mirb = col.getBlue();
+#endif
}
// texture
else if (ef->getReflective().isTexture()) {
+#if 0
COLLADAFW::Texture ctex = ef->getReflective().getTexture();
- mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
- if (mtex != NULL) {
- mtex->mapto = MAP_REF;
- i++;
- }
+#endif
}
// EMISSION
@@ -905,40 +868,31 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
}
// texture
else if (ef->getEmission().isTexture()) {
+#if 0
COLLADAFW::Texture ctex = ef->getEmission().getTexture();
- mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
- if (mtex != NULL) {
- mtex->mapto = MAP_EMIT;
- i++;
- }
+#endif
}
// TRANSPARENT
// color
if (ef->getOpacity().isColor()) {
+#if 0
col = ef->getTransparent().getColor();
float alpha = ef->getTransparency().getFloatValue();
if (col.isValid()) {
alpha *= col.getAlpha(); // Assuming A_ONE opaque mode
}
if (col.isValid() || alpha < 1.0) {
- ma->alpha = alpha;
- ma->mode |= MA_ZTRANSP | MA_TRANSP;
+ ...
}
+#endif
}
// texture
else if (ef->getOpacity().isTexture()) {
+#if 0
COLLADAFW::Texture ctex = ef->getOpacity().getTexture();
- mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
- if (mtex != NULL) {
- mtex->mapto = MAP_ALPHA;
- i++;
- ma->spectra = ma->alpha = 0;
- ma->mode |= MA_ZTRANSP | MA_TRANSP;
- }
+#endif
}
-
- material_texture_mapping_map[ma] = texindex_texarray_map;
}
/** When this method is called, the writer must write the effect.
@@ -1185,7 +1139,6 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
et->setData("spotsize", &(lamp->spotsize));
lamp->spotsize = DEG2RADF(lamp->spotsize);
et->setData("spotblend", &(lamp->spotblend));
- et->setData("halo_intensity", &(lamp->haint));
et->setData("att1", &(lamp->att1));
et->setData("att2", &(lamp->att2));
et->setData("falloff_type", &(lamp->falloff_type));
@@ -1193,38 +1146,12 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
et->setData("clipend", &(lamp->clipend));
et->setData("bias", &(lamp->bias));
et->setData("soft", &(lamp->soft));
- et->setData("compressthresh", &(lamp->compressthresh));
et->setData("bufsize", &(lamp->bufsize));
- et->setData("samp", &(lamp->samp));
et->setData("buffers", &(lamp->buffers));
- et->setData("filtertype", &(lamp->filtertype));
- et->setData("bufflag", &(lamp->bufflag));
- et->setData("buftype", &(lamp->buftype));
- et->setData("ray_samp", &(lamp->ray_samp));
- et->setData("ray_sampy", &(lamp->ray_sampy));
- et->setData("ray_sampz", &(lamp->ray_sampz));
- et->setData("ray_samp_type", &(lamp->ray_samp_type));
et->setData("area_shape", &(lamp->area_shape));
et->setData("area_size", &(lamp->area_size));
et->setData("area_sizey", &(lamp->area_sizey));
et->setData("area_sizez", &(lamp->area_sizez));
- et->setData("adapt_thresh", &(lamp->adapt_thresh));
- et->setData("ray_samp_method", &(lamp->ray_samp_method));
- et->setData("shadhalostep", &(lamp->shadhalostep));
- et->setData("sun_effect_type", &(lamp->shadhalostep));
- et->setData("skyblendtype", &(lamp->skyblendtype));
- et->setData("horizon_brightness", &(lamp->horizon_brightness));
- et->setData("spread", &(lamp->spread));
- et->setData("sun_brightness", &(lamp->sun_brightness));
- et->setData("sun_size", &(lamp->sun_size));
- et->setData("backscattered_light", &(lamp->backscattered_light));
- et->setData("sun_intensity", &(lamp->sun_intensity));
- et->setData("atm_turbidity", &(lamp->atm_turbidity));
- et->setData("atm_extinction_factor", &(lamp->atm_extinction_factor));
- et->setData("atm_distance_factor", &(lamp->atm_distance_factor));
- et->setData("skyblendfac", &(lamp->skyblendfac));
- et->setData("sky_exposure", &(lamp->sky_exposure));
- et->setData("sky_colorspace", &(lamp->sky_colorspace));
}
else {
float constatt = light->getConstantAttenuation().getValue();
@@ -1288,7 +1215,6 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
{
/* our sun is very strong, so pick a smaller energy level */
lamp->type = LA_SUN;
- lamp->mode |= LA_NO_SPEC;
}
break;
case COLLADAFW::Light::POINT_LIGHT:
diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h
index fd61f3a68da..758caef7e60 100644
--- a/source/blender/collada/DocumentImporter.h
+++ b/source/blender/collada/DocumentImporter.h
@@ -77,7 +77,6 @@ public:
Object* create_instance_node(Object*, COLLADAFW::Node*, COLLADAFW::Node*, Scene*, bool);
void create_constraints(ExtraTags *et, Object *ob);
std::vector<Object *> *write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool);
- MTex* create_texture(COLLADAFW::EffectCommon*, COLLADAFW::Texture&, Material*, int, TexIndexTextureArrayMap&);
void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*);
void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*);
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index 5e2b00be82a..dbcdfd01a9c 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -41,7 +41,6 @@
extern "C" {
#include "DNA_mesh_types.h"
- #include "DNA_texture_types.h"
#include "DNA_world_types.h"
#include "BKE_collection.h"
@@ -95,127 +94,27 @@ void EffectsExporter::exportEffects(Scene *sce)
}
}
-void EffectsExporter::writeBlinn(COLLADASW::EffectProfile &ep, Material *ma)
-{
- COLLADASW::ColorOrTexture cot;
- ep.setShaderType(COLLADASW::EffectProfile::BLINN);
- // shininess
- ep.setShininess(ma->har, false, "shininess");
- // specular
- cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
- ep.setSpecular(cot, false, "specular");
-}
-
void EffectsExporter::writeLambert(COLLADASW::EffectProfile &ep, Material *ma)
{
COLLADASW::ColorOrTexture cot;
ep.setShaderType(COLLADASW::EffectProfile::LAMBERT);
}
-void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma)
-{
- COLLADASW::ColorOrTexture cot;
- ep.setShaderType(COLLADASW::EffectProfile::PHONG);
- // shininess
- ep.setShininess(ma->har, false, "shininess");
- // specular
- cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
- ep.setSpecular(cot, false, "specular");
-}
-
-void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep,
- std::string &key,
- COLLADASW::Sampler *sampler,
- MTex *t, Image *ima,
- std::string &uvname ) {
-
- // Image not set for texture
- if (!ima) return;
-
- // color
- if (t->mapto & MAP_COL) {
- ep.setDiffuse(createTexture(ima, uvname, sampler), false, "diffuse");
- }
- // ambient
- if (t->mapto & MAP_AMB) {
- ep.setAmbient(createTexture(ima, uvname, sampler), false, "ambient");
- }
- // specular
- if (t->mapto & (MAP_SPEC | MAP_COLSPEC)) {
- ep.setSpecular(createTexture(ima, uvname, sampler), false, "specular");
- }
- // emission
- if (t->mapto & MAP_EMIT) {
- ep.setEmission(createTexture(ima, uvname, sampler), false, "emission");
- }
- // reflective
- if (t->mapto & MAP_REF) {
- ep.setReflective(createTexture(ima, uvname, sampler));
- }
- // alpha
- if (t->mapto & MAP_ALPHA) {
- ep.setTransparent(createTexture(ima, uvname, sampler));
- }
- // extension:
- // Normal map --> Must be stored with <extra> tag as different technique,
- // since COLLADA doesn't support normal maps, even in current COLLADA 1.5.
- if (t->mapto & MAP_NORM) {
- COLLADASW::Texture texture(key);
- texture.setTexcoord(uvname);
- texture.setSampler(*sampler);
- // technique FCOLLADA, with the <bump> tag, is most likely the best understood,
- // most widespread de-facto standard.
- texture.setProfileName("FCOLLADA");
- texture.setChildElementName("bump");
- ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture));
- }
-}
-
void EffectsExporter::operator()(Material *ma, Object *ob)
{
- // create a list of indices to textures of type TEX_IMAGE
- std::vector<int> tex_indices;
- if (this->export_settings->include_material_textures)
- createTextureIndices(ma, tex_indices);
+ // TODO: add back texture and extended material parameter support
openEffect(translate_id(id_name(ma)) + "-effect");
COLLADASW::EffectProfile ep(mSW);
ep.setProfileType(COLLADASW::EffectProfile::COMMON);
ep.openProfile();
- // set shader type - one of three blinn, phong or lambert
- if (ma->spec > 0.0f) {
- if (ma->spec_shader == MA_SPEC_BLINN) {
- writeBlinn(ep, ma);
- }
- else {
- // \todo figure out handling of all spec+diff shader combos blender has, for now write phong
- // for now set phong in case spec shader is not blinn
- writePhong(ep, ma);
- }
- }
- else {
- if (ma->diff_shader == MA_DIFF_LAMBERT) {
- writeLambert(ep, ma);
- }
- else {
- // \todo figure out handling of all spec+diff shader combos blender has, for now write phong
- writePhong(ep, ma);
- }
- }
+ writeLambert(ep, ma);
- // index of refraction
- if (ma->mode & MA_RAYTRANSP) {
- ep.setIndexOfRefraction(ma->ang, false, "index_of_refraction");
- }
- else {
- ep.setIndexOfRefraction(1.0f, false, "index_of_refraction");
- }
-
COLLADASW::ColorOrTexture cot;
// transparency
- if (ma->mode & MA_TRANSP) {
+ if (ma->alpha != 1.0f) {
// Tod: because we are in A_ONE mode transparency is calculated like this:
cot = getcol(1.0f, 1.0f, 1.0f, ma->alpha);
ep.setTransparent(cot);
@@ -223,34 +122,14 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
}
// emission
+#if 0
cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f);
- ep.setEmission(cot, false, "emission");
+#endif
- // diffuse multiplied by diffuse intensity
- cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f);
+ // diffuse
+ cot = getcol(ma->r, ma->g, ma->b, 1.0f);
ep.setDiffuse(cot, false, "diffuse");
- // ambient
- /* ma->ambX is calculated only on render, so lets do it here manually and not rely on ma->ambX. */
- if (this->scene->world)
- cot = getcol(this->scene->world->ambr * ma->amb, this->scene->world->ambg * ma->amb, this->scene->world->ambb * ma->amb, 1.0f);
- else
- cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f);
-
- ep.setAmbient(cot, false, "ambient");
-
- // reflective, reflectivity
- if (ma->mode & MA_RAYMIRROR) {
- cot = getcol(ma->mirr, ma->mirg, ma->mirb, 1.0f);
- ep.setReflective(cot);
- ep.setReflectivity(ma->ray_mirror);
- }
- // else {
- // cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
- // ep.setReflective(cot);
- // ep.setReflectivity(ma->spec);
- // }
-
// specular
if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) {
cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f);
@@ -259,6 +138,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
// XXX make this more readable if possible
+#if 0
// create <sampler> and <surface> for each image
COLLADASW::Sampler samplers[MAX_MTEX];
//COLLADASW::Surface surfaces[MAX_MTEX];
@@ -309,6 +189,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
b++;
}
}
+#endif
// used as fallback when MTex->uvname is "" (this is pretty common)
// it is indeed the correct value to use in that case
@@ -316,6 +197,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
// write textures
// XXX very slow
+#if 0
for (a = 0; a < tex_indices.size(); a++) {
MTex *t = ma->mtex[tex_indices[a]];
Image *ima = t->tex->ima;
@@ -331,6 +213,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i];
writeTextures(ep, key, sampler, t, ima, uvname);
}
+#endif
// performs the actual writing
ep.addProfileElements();
@@ -371,20 +254,3 @@ COLLADASW::ColorOrTexture EffectsExporter::getcol(float r, float g, float b, flo
COLLADASW::ColorOrTexture cot(color);
return cot;
}
-
-//returns the array of mtex indices which have image
-//need this for exporting textures
-void EffectsExporter::createTextureIndices(Material *ma, std::vector<int> &indices)
-{
- indices.clear();
-
- for (int a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a] &&
- ma->mtex[a]->tex &&
- ma->mtex[a]->tex->type == TEX_IMAGE &&
- ma->mtex[a]->texco == TEXCO_UV)
- {
- indices.push_back(a);
- }
- }
-}
diff --git a/source/blender/collada/EffectExporter.h b/source/blender/collada/EffectExporter.h
index d20cbfdfe0b..eac428ae330 100644
--- a/source/blender/collada/EffectExporter.h
+++ b/source/blender/collada/EffectExporter.h
@@ -58,12 +58,7 @@ public:
COLLADASW::ColorOrTexture getcol(float r, float g, float b, float a);
private:
- /** Fills the array of mtex indices which have image. Used for exporting images. */
- void createTextureIndices(Material *ma, std::vector<int> &indices);
-
- void writeBlinn(COLLADASW::EffectProfile &ep, Material *ma);
void writeLambert(COLLADASW::EffectProfile &ep, Material *ma);
- void writePhong(COLLADASW::EffectProfile &ep, Material *ma);
void writeTextures(COLLADASW::EffectProfile &ep,
std::string &key,
COLLADASW::Sampler *sampler,
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index 8dbee607b01..87b47353596 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -57,11 +57,11 @@ GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSett
{
}
-void GeometryExporter::exportGeom(const struct EvaluationContext *eval_ctx, Scene *sce)
+void GeometryExporter::exportGeom(struct Depsgraph *depsgraph, Scene *sce)
{
openLibrary();
- mEvalCtx = eval_ctx;
+ mDepsgraph = depsgraph;
mScene = sce;
GeometryFunctor gf;
gf.forEachMeshObjectInExportSet<GeometryExporter>(sce, *this, this->export_settings->export_set);
@@ -77,7 +77,7 @@ void GeometryExporter::operator()(Object *ob)
#endif
bool use_instantiation = this->export_settings->use_object_instantiation;
- Mesh *me = bc_get_mesh_copy(mEvalCtx, mScene,
+ Mesh *me = bc_get_mesh_copy(mDepsgraph, mScene,
ob,
this->export_settings->export_mesh_type,
this->export_settings->apply_modifiers,
diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h
index 7527195fdd8..88420b4ad2f 100644
--- a/source/blender/collada/GeometryExporter.h
+++ b/source/blender/collada/GeometryExporter.h
@@ -46,7 +46,7 @@
#include "BKE_key.h"
-struct EvaluationContext;
+struct Depsgraph;
extern Object *bc_get_highest_selected_ancestor_or_self(Object *ob);
@@ -74,13 +74,13 @@ class GeometryExporter : COLLADASW::LibraryGeometries
Normal n;
- const struct EvaluationContext *mEvalCtx;
+ struct Depsgraph *mDepsgraph;
Scene *mScene;
public:
GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
- void exportGeom(const struct EvaluationContext *eval_ctx, Scene *sce);
+ void exportGeom(struct Depsgraph *depsgraph, Scene *sce);
void operator()(Object *ob);
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp
index 3cdc013c137..657037a869a 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -164,12 +164,7 @@ bool ImagesExporter::hasImages(Scene *sce)
// no material, but check all of the slots
if (!ma) continue;
- int b;
- for (b = 0; b < MAX_MTEX; b++) {
- MTex *mtex = ma->mtex[b];
- if (mtex && mtex->tex && mtex->tex->ima) return true;
- }
-
+ // TODO: find image textures in shader nodes
}
}
return false;
@@ -191,13 +186,6 @@ void ImagesExporter::exportImages(Scene *sce)
void ImagesExporter::operator()(Material *ma, Object *ob)
{
- int a;
- bool use_texture_copies = this->export_settings->use_texture_copies;
- for (a = 0; a < MAX_MTEX; a++) {
- MTex *mtex = ma->mtex[a];
- if (mtex && mtex->tex && mtex->tex->ima) {
- Image *image = mtex->tex->ima;
- export_UV_Image(image, use_texture_copies);
- }
- }
+ // bool use_texture_copies = this->export_settings->use_texture_copies;
+ // TODO call export_UV_Image for every image in shader nodes
}
diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp
index 71371d280df..d96d590597a 100644
--- a/source/blender/collada/InstanceWriter.cpp
+++ b/source/blender/collada/InstanceWriter.cpp
@@ -32,9 +32,9 @@
#include "COLLADASWInstanceMaterial.h"
extern "C" {
- #include "BKE_customdata.h"
- #include "BKE_material.h"
- #include "DNA_mesh_types.h"
+#include "BKE_customdata.h"
+#include "BKE_material.h"
+#include "DNA_mesh_types.h"
}
#include "InstanceWriter.h"
diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
index ff50abfedae..d17941574d7 100644
--- a/source/blender/collada/LightExporter.cpp
+++ b/source/blender/collada/LightExporter.cpp
@@ -149,7 +149,6 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
cla.addExtraTechniqueParameter("blender", "dist", la->dist, "blender_dist");
cla.addExtraTechniqueParameter("blender", "spotsize", RAD2DEGF(la->spotsize));
cla.addExtraTechniqueParameter("blender", "spotblend", la->spotblend);
- cla.addExtraTechniqueParameter("blender", "halo_intensity", la->haint, "blnder_halo_intensity");
cla.addExtraTechniqueParameter("blender", "att1", la->att1);
cla.addExtraTechniqueParameter("blender", "att2", la->att2);
// \todo figure out how we can have falloff curve supported here
@@ -158,38 +157,13 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
cla.addExtraTechniqueParameter("blender", "clipend", la->clipend);
cla.addExtraTechniqueParameter("blender", "bias", la->bias);
cla.addExtraTechniqueParameter("blender", "soft", la->soft);
- cla.addExtraTechniqueParameter("blender", "compressthresh", la->compressthresh);
cla.addExtraTechniqueParameter("blender", "bufsize", la->bufsize);
cla.addExtraTechniqueParameter("blender", "samp", la->samp);
cla.addExtraTechniqueParameter("blender", "buffers", la->buffers);
- cla.addExtraTechniqueParameter("blender", "filtertype", la->filtertype);
- cla.addExtraTechniqueParameter("blender", "bufflag", la->bufflag);
- cla.addExtraTechniqueParameter("blender", "buftype", la->buftype);
- cla.addExtraTechniqueParameter("blender", "ray_samp", la->ray_samp);
- cla.addExtraTechniqueParameter("blender", "ray_sampy", la->ray_sampy);
- cla.addExtraTechniqueParameter("blender", "ray_sampz", la->ray_sampz);
- cla.addExtraTechniqueParameter("blender", "ray_samp_type", la->ray_samp_type);
cla.addExtraTechniqueParameter("blender", "area_shape", la->area_shape);
cla.addExtraTechniqueParameter("blender", "area_size", la->area_size);
cla.addExtraTechniqueParameter("blender", "area_sizey", la->area_sizey);
cla.addExtraTechniqueParameter("blender", "area_sizez", la->area_sizez);
- cla.addExtraTechniqueParameter("blender", "adapt_thresh", la->adapt_thresh);
- cla.addExtraTechniqueParameter("blender", "ray_samp_method", la->ray_samp_method);
- cla.addExtraTechniqueParameter("blender", "shadhalostep", la->shadhalostep);
- cla.addExtraTechniqueParameter("blender", "sun_effect_type", la->shadhalostep);
- cla.addExtraTechniqueParameter("blender", "skyblendtype", la->skyblendtype);
- cla.addExtraTechniqueParameter("blender", "horizon_brightness", la->horizon_brightness);
- cla.addExtraTechniqueParameter("blender", "spread", la->spread);
- cla.addExtraTechniqueParameter("blender", "sun_brightness", la->sun_brightness);
- cla.addExtraTechniqueParameter("blender", "sun_size", la->sun_size);
- cla.addExtraTechniqueParameter("blender", "backscattered_light", la->backscattered_light);
- cla.addExtraTechniqueParameter("blender", "sun_intensity", la->sun_intensity);
- cla.addExtraTechniqueParameter("blender", "atm_turbidity", la->atm_turbidity);
- cla.addExtraTechniqueParameter("blender", "atm_extinction_factor", la->atm_extinction_factor);
- cla.addExtraTechniqueParameter("blender", "atm_distance_factor", la->atm_distance_factor);
- cla.addExtraTechniqueParameter("blender", "skyblendfac", la->skyblendfac);
- cla.addExtraTechniqueParameter("blender", "sky_exposure", la->sky_exposure);
- cla.addExtraTechniqueParameter("blender", "sky_colorspace", la->sky_colorspace);
return true;
}
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index ec1b14a3855..10b9745a6b9 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -705,8 +705,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
}
if (collada_meshtype == COLLADAFW::MeshPrimitive::POLYLIST ||
- collada_meshtype == COLLADAFW::MeshPrimitive::POLYGONS ||
- collada_meshtype == COLLADAFW::MeshPrimitive::TRIANGLES) {
+ collada_meshtype == COLLADAFW::MeshPrimitive::POLYGONS ||
+ collada_meshtype == COLLADAFW::MeshPrimitive::TRIANGLES)
+ {
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
unsigned int start_index = 0;
@@ -878,48 +879,6 @@ std::string *MeshImporter::get_geometry_name(const std::string &mesh_name)
return NULL;
}
-MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture,
- Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map,
- MTex *color_texture)
-{
- const COLLADAFW::TextureMapId texture_index = ctexture.getTextureMapId();
- size_t setindex = ctexture.getSetIndex();
- std::string uvname = ctexture.getSemantic();
-
- if (setindex == -1) return NULL;
-
- const CustomData *data = &me->fdata;
- int layer_index = CustomData_get_layer_index(data, CD_MTFACE);
-
- if (layer_index == -1) return NULL;
-
- CustomDataLayer *cdl = &data->layers[layer_index + setindex];
-
- /* set uvname to bind_vertex_input semantic */
- BLI_strncpy(cdl->name, uvname.c_str(), sizeof(cdl->name));
-
- if (texindex_texarray_map.find(texture_index) == texindex_texarray_map.end()) {
-
- fprintf(stderr, "Cannot find texture array by texture index.\n");
- return color_texture;
- }
-
- std::vector<MTex *> textures = texindex_texarray_map[texture_index];
-
- std::vector<MTex *>::iterator it;
-
- for (it = textures.begin(); it != textures.end(); it++) {
-
- MTex *texture = *it;
-
- if (texture) {
- BLI_strncpy(texture->uvname, uvname.c_str(), sizeof(texture->uvname));
- if (texture->mapto == MAP_COL) color_texture = texture;
- }
- }
- return color_texture;
-}
-
/**
* this function checks if both objects have the same
* materials assigned to Object (in the same order)
@@ -1057,10 +1016,8 @@ void MeshImporter::assign_material_to_geom(
COLLADAFW::MaterialBinding cmaterial,
std::map<COLLADAFW::UniqueId, Material *>& uid_material_map,
Object *ob, const COLLADAFW::UniqueId *geom_uid,
- std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index)
+ short mat_index)
{
- MTex *color_texture = NULL;
- Mesh *me = (Mesh *)ob->data;
const COLLADAFW::UniqueId& ma_uid = cmaterial.getReferencedMaterial();
// do we know this material?
@@ -1080,17 +1037,6 @@ void MeshImporter::assign_material_to_geom(
ob->actcol=0;
assign_material(ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT);
- COLLADAFW::TextureCoordinateBindingArray& tex_array =
- cmaterial.getTextureCoordinateBindingArray();
- TexIndexTextureArrayMap texindex_texarray_map = material_texture_mapping_map[ma];
- unsigned int i;
- // loop through <bind_vertex_inputs>
- for (i = 0; i < tex_array.getCount(); i++) {
-
- color_texture = assign_textures_to_uvlayer(tex_array[i], me, texindex_texarray_map,
- color_texture);
- }
-
MaterialIdPrimitiveArrayMap& mat_prim_map = geom_uid_mat_mapping_map[*geom_uid];
COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId();
@@ -1105,7 +1051,7 @@ void MeshImporter::assign_material_to_geom(
Primitive& prim = *it;
MPoly *mpoly = prim.mpoly;
- for (i = 0; i < prim.totpoly; i++, mpoly++) {
+ for (int i = 0; i < prim.totpoly; i++, mpoly++) {
mpoly->mat_nr = mat_index;
}
}
@@ -1114,8 +1060,7 @@ void MeshImporter::assign_material_to_geom(
Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom,
bool isController,
- std::map<COLLADAFW::UniqueId, Material *>& uid_material_map,
- std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map)
+ std::map<COLLADAFW::UniqueId, Material *>& uid_material_map)
{
const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId();
@@ -1172,7 +1117,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
if (mat_array[i].getReferencedMaterial().isValid()) {
assign_material_to_geom(
mat_array[i], uid_material_map, ob, geom_uid,
- material_texture_mapping_map, i);
+ i);
}
else {
fprintf(stderr, "invalid referenced material for %s\n", mat_array[i].getName().c_str());
diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h
index f57f57e07a7..09b3005d795 100644
--- a/source/blender/collada/MeshImporter.h
+++ b/source/blender/collada/MeshImporter.h
@@ -51,7 +51,6 @@ extern "C" {
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "DNA_texture_types.h"
}
@@ -167,23 +166,18 @@ public:
virtual Mesh *get_mesh_by_geom_uid(const COLLADAFW::UniqueId& geom_uid);
- MTex *assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture,
- Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map,
- MTex *color_texture);
-
void optimize_material_assignements();
void assign_material_to_geom(
COLLADAFW::MaterialBinding cmaterial,
std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
Object *ob, const COLLADAFW::UniqueId *geom_uid,
- std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index);
+ short mat_index);
Object *create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom,
bool isController,
- std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
- std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map);
+ std::map<COLLADAFW::UniqueId, Material*>& uid_material_map);
// create a mesh storing a pointer in a map so it can be retrieved later by geometry UID
bool write_geometry(const COLLADAFW::Geometry* geom);
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index f24c104892d..a1d542daa14 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -39,17 +39,17 @@ SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm,
{
}
-void SceneExporter::exportScene(const EvaluationContext *eval_ctx, Scene *sce)
+void SceneExporter::exportScene(Depsgraph *depsgraph, Scene *sce)
{
// <library_visual_scenes> <visual_scene>
std::string id_naming = id_name(sce);
openVisualScene(translate_id(id_naming), id_naming);
- exportHierarchy(eval_ctx, sce);
+ exportHierarchy(depsgraph, sce);
closeVisualScene();
closeLibrary();
}
-void SceneExporter::exportHierarchy(const EvaluationContext *eval_ctx, Scene *sce)
+void SceneExporter::exportHierarchy(Depsgraph *depsgraph, Scene *sce)
{
LinkNode *node;
std::vector<Object *> base_objects;
@@ -81,13 +81,13 @@ void SceneExporter::exportHierarchy(const EvaluationContext *eval_ctx, Scene *sc
Object *ob = base_objects[index];
if (bc_is_marked(ob)) {
bc_remove_mark(ob);
- writeNodes(eval_ctx, ob, sce);
+ writeNodes(depsgraph, ob, sce);
}
}
}
-void SceneExporter::writeNodes(const EvaluationContext *eval_ctx, Object *ob, Scene *sce)
+void SceneExporter::writeNodes(Depsgraph *depsgraph, Object *ob, Scene *sce)
{
// Add associated armature first if available
bool armature_exported = false;
@@ -96,7 +96,7 @@ void SceneExporter::writeNodes(const EvaluationContext *eval_ctx, Object *ob, Sc
armature_exported = bc_is_in_Export_set(this->export_settings->export_set, ob_arm);
if (armature_exported && bc_is_marked(ob_arm)) {
bc_remove_mark(ob_arm);
- writeNodes(eval_ctx, ob_arm, sce);
+ writeNodes(depsgraph, ob_arm, sce);
armature_exported = true;
}
}
@@ -155,7 +155,7 @@ void SceneExporter::writeNodes(const EvaluationContext *eval_ctx, Object *ob, Sc
// <instance_controller>
else if (ob->type == OB_ARMATURE) {
- arm_exporter->add_armature_bones(eval_ctx, ob, sce, this, child_objects);
+ arm_exporter->add_armature_bones(depsgraph, ob, sce, this, child_objects);
}
// <instance_camera>
@@ -234,7 +234,7 @@ void SceneExporter::writeNodes(const EvaluationContext *eval_ctx, Object *ob, Sc
for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
if (bc_is_marked(*i)) {
bc_remove_mark(*i);
- writeNodes(eval_ctx, *i, sce);
+ writeNodes(depsgraph, *i, sce);
}
}
diff --git a/source/blender/collada/SceneExporter.h b/source/blender/collada/SceneExporter.h
index 3e3c15b836f..c330aa81e91 100644
--- a/source/blender/collada/SceneExporter.h
+++ b/source/blender/collada/SceneExporter.h
@@ -96,12 +96,12 @@ class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter,
{
public:
SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings);
- void exportScene(const EvaluationContext *eval_ctx, Scene *sce);
+ void exportScene(Depsgraph *depsgraph, Scene *sce);
private:
friend class ArmatureExporter;
- void exportHierarchy(const struct EvaluationContext *eval_ctx, Scene *sce);
- void writeNodes(const struct EvaluationContext *eval_ctx, Object *ob, Scene *sce);
+ void exportHierarchy(struct Depsgraph *depsgraph, Scene *sce);
+ void writeNodes(struct Depsgraph *depsgraph, Object *ob, Scene *sce);
ArmatureExporter *arm_exporter;
const ExportSettings *export_settings;
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index 84817d76073..1fb54e99147 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -26,8 +26,10 @@
*/
-#include "BKE_object.h"
#include "BLI_math.h"
+#include "BLI_sys_types.h"
+
+#include "BKE_object.h"
#include "TransformWriter.h"
diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp
index 64e3a4c36ce..5def6638df6 100644
--- a/source/blender/collada/collada.cpp
+++ b/source/blender/collada/collada.cpp
@@ -39,6 +39,7 @@ extern "C"
#include "BKE_scene.h"
#include "BKE_context.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
/* make dummy file */
#include "BLI_fileops.h"
@@ -50,11 +51,11 @@ int collada_import(bContext *C, ImportSettings *import_settings)
return (imp.import())? 1:0;
}
-int collada_export(EvaluationContext *eval_ctx,
+int collada_export(Depsgraph *depsgraph,
Scene *sce,
ExportSettings *export_settings)
{
- ViewLayer *view_layer = eval_ctx->view_layer;
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
int includeFilter = OB_REL_NONE;
if (export_settings->include_armatures) includeFilter |= OB_REL_MOD_ARMATURE;
@@ -78,7 +79,7 @@ int collada_export(EvaluationContext *eval_ctx,
bc_bubble_sort_by_Object_name(export_settings->export_set);
}
- DocumentExporter exporter(eval_ctx, export_settings);
+ DocumentExporter exporter(depsgraph, export_settings);
int status = exporter.exportCurrentScene(sce);
BLI_linklist_free(export_settings->export_set, NULL);
diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h
index f95fca03b65..5cf526af1f2 100644
--- a/source/blender/collada/collada.h
+++ b/source/blender/collada/collada.h
@@ -41,9 +41,9 @@ extern "C" {
#include "RNA_types.h"
struct bContext;
+struct Depsgraph;
struct Scene;
struct ViewLayer;
-struct EvaluationContext;
/*
* both return 1 on success, 0 on error
@@ -52,7 +52,7 @@ int collada_import(struct bContext *C,
ImportSettings *import_settings);
-int collada_export(struct EvaluationContext *eval_ctx,
+int collada_export(struct Depsgraph *depsgraph,
struct Scene *sce,
ExportSettings *export_settings);
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index cc18cea662a..778ead55c8d 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -65,6 +65,7 @@ extern "C" {
}
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "collada_utils.h"
#include "ExportSettings.h"
@@ -96,11 +97,9 @@ int bc_test_parent_loop(Object *par, Object *ob)
int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
{
Object workob;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *sce = CTX_data_scene(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (!par || bc_test_parent_loop(par, ob))
return false;
@@ -112,7 +111,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
if (is_parent_space) {
float mat[4][4];
// calc par->obmat
- BKE_object_where_is_calc(&eval_ctx, sce, par);
+ BKE_object_where_is_calc(depsgraph, sce, par);
// move child obmat into world space
mul_m4_m4m4(mat, par->obmat, ob->obmat);
@@ -123,7 +122,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
// compute parentinv
- BKE_object_workob_calc_parent(&eval_ctx, sce, ob, &workob);
+ BKE_object_workob_calc_parent(depsgraph, sce, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
@@ -148,18 +147,12 @@ Main *bc_get_main()
return G.main;
}
-EvaluationContext *bc_get_evaluation_context()
-{
- Main *bmain = G.main;
- return bmain->eval_ctx;
-}
-
-void bc_update_scene(EvaluationContext *eval_ctx, Scene *scene, float ctime)
+void bc_update_scene(Depsgraph *depsgraph, Scene *scene, float ctime)
{
BKE_scene_frame_set(scene, ctime);
Main *bmain = bc_get_main();
- BKE_scene_graph_update_for_newframe(eval_ctx, eval_ctx->depsgraph, bmain, scene, eval_ctx->view_layer);
+ BKE_scene_graph_update_for_newframe(depsgraph, bmain);
}
Object *bc_add_object(Scene *scene, ViewLayer *view_layer, int type, const char *name)
@@ -179,7 +172,7 @@ Object *bc_add_object(Scene *scene, ViewLayer *view_layer, int type, const char
return ob;
}
-Mesh *bc_get_mesh_copy(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate)
+Mesh *bc_get_mesh_copy(struct Depsgraph *depsgraph, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate)
{
Mesh *tmpmesh;
CustomDataMask mask = CD_MASK_MESH;
@@ -189,12 +182,12 @@ Mesh *bc_get_mesh_copy(const struct EvaluationContext *eval_ctx, Scene *scene, O
switch (export_mesh_type) {
case BC_MESH_TYPE_VIEW:
{
- dm = mesh_create_derived_view(eval_ctx, scene, ob, mask);
+ dm = mesh_create_derived_view(depsgraph, scene, ob, mask);
break;
}
case BC_MESH_TYPE_RENDER:
{
- dm = mesh_create_derived_render(eval_ctx, scene, ob, mask);
+ dm = mesh_create_derived_render(depsgraph, scene, ob, mask);
break;
}
}
@@ -769,17 +762,17 @@ float bc_get_property(Bone *bone, std::string key, float def)
IDProperty *property = bc_get_IDProperty(bone, key);
if (property) {
switch (property->type) {
- case IDP_INT:
- result = (float)(IDP_Int(property));
- break;
- case IDP_FLOAT:
- result = (float)(IDP_Float(property));
- break;
- case IDP_DOUBLE:
- result = (float)(IDP_Double(property));
- break;
- default:
- result = def;
+ case IDP_INT:
+ result = (float)(IDP_Int(property));
+ break;
+ case IDP_FLOAT:
+ result = (float)(IDP_Float(property));
+ break;
+ case IDP_DOUBLE:
+ result = (float)(IDP_Double(property));
+ break;
+ default:
+ result = def;
}
}
return result;
@@ -959,127 +952,3 @@ std::string bc_get_uvlayer_name(Mesh *me, int layer)
}
return "";
}
-
-#if 0
-/**********************************************************************
-*
-* Return the list of Mesh objects with assigned UVtextures and Images
-* Note: We need to create artificaial materials for each of them
-*
-***********************************************************************/
-std::set<Object *> bc_getUVTexturedObjects(Scene *sce, bool all_uv_layers)
-{
- std::set <Object *> UVObjects;
- Base *base = (Base *)sce->base.first;
-
- while (base) {
- Object *ob = base->object;
- bool has_uvimage = false;
- if (ob->type == OB_MESH) {
- Mesh *me = (Mesh *)ob->data;
- int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY);
-
- for (int i = 0; i < me->pdata.totlayer && !has_uvimage; i++) {
- if (all_uv_layers || active_uv_layer == i)
- {
- if (me->pdata.layers[i].type == CD_MTEXPOLY) {
- MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data;
- MPoly *mpoly = me->mpoly;
- for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) {
-
- Image *ima = txface->tpage;
- if (ima != NULL) {
- has_uvimage = true;
- break;
- }
- }
- }
- }
- }
-
- if (has_uvimage) {
- UVObjects.insert(ob);
- }
- }
- base = base->next;
- }
- return UVObjects;
-}
-
-/**********************************************************************
-*
-* Return the list of UV Texture images from all exported Mesh Items
-* Note: We need to create one artificial material for each Image.
-*
-***********************************************************************/
-std::set<Image *> bc_getUVImages(Scene *sce, bool all_uv_layers)
-{
- std::set <Image *> UVImages;
- Base *base = (Base *)sce->base.first;
-
- while (base) {
- Object *ob = base->object;
- bool has_uvimage = false;
- if (ob->type == OB_MESH) {
- Mesh *me = (Mesh *)ob->data;
- int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY);
-
- for (int i = 0; i < me->pdata.totlayer && !has_uvimage; i++) {
- if (all_uv_layers || active_uv_layer == i)
- {
- if (me->pdata.layers[i].type == CD_MTEXPOLY) {
- MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data;
- MPoly *mpoly = me->mpoly;
- for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) {
-
- Image *ima = txface->tpage;
- if (ima != NULL) {
- if (UVImages.find(ima) == UVImages.end())
- UVImages.insert(ima);
- }
- }
- }
- }
- }
- }
- base = base->next;
- }
- return UVImages;
-}
-
-/**********************************************************************
-*
-* Return the list of UV Texture images for the given Object
-* Note: We need to create one artificial material for each Image.
-*
-***********************************************************************/
-std::set<Image *> bc_getUVImages(Object *ob, bool all_uv_layers)
-{
- std::set <Image *> UVImages;
-
- bool has_uvimage = false;
- if (ob->type == OB_MESH) {
- Mesh *me = (Mesh *)ob->data;
- int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY);
-
- for (int i = 0; i < me->pdata.totlayer && !has_uvimage; i++) {
- if (all_uv_layers || active_uv_layer == i)
- {
- if (me->pdata.layers[i].type == CD_MTEXPOLY) {
- MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data;
- MPoly *mpoly = me->mpoly;
- for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) {
-
- Image *ima = txface->tpage;
- if (ima != NULL) {
- if (UVImages.find(ima) == UVImages.end())
- UVImages.insert(ima);
- }
- }
- }
- }
- }
- }
- return UVImages;
-}
-#endif
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index 52767557397..89765375afb 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -60,20 +60,20 @@ extern "C" {
#include "ExportSettings.h"
#include "collada_internal.h"
-struct EvaluationContext;
+struct Depsgraph;
typedef std::map<COLLADAFW::TextureMapId, std::vector<MTex *> > TexIndexTextureArrayMap;
extern Scene *bc_get_scene(bContext *C);
extern Main *bc_get_main();
-extern EvaluationContext *bc_get_evaluation_context();
-extern void bc_update_scene(EvaluationContext *eval_ctx, Scene *scene, float ctime);
+extern Depsgraph *bc_get_depsgraph();
+extern void bc_update_scene(Depsgraph *depsgraph, Scene *scene, float ctime);
extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index);
extern int bc_test_parent_loop(Object *par, Object *ob);
extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space = true);
extern Object *bc_add_object(Scene *scene, ViewLayer *view_layer, int type, const char *name);
-extern Mesh *bc_get_mesh_copy(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate);
+extern Mesh *bc_get_mesh_copy(struct Depsgraph *depsgraph, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate);
extern Object *bc_get_assigned_armature(Object *ob);
extern Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob);
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index fe13f3d60a2..241ae20ce33 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -152,31 +152,31 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
const RenderData *rd = this->m_rd;
if (rd->mode & R_BORDER && rd->mode & R_CROP) {
- /*!
- When using cropped render result, need to re-position area of interest,
- so it'll natch bounds of render border within frame. By default, canvas
- will be centered between full frame and cropped frame, so we use such
- scheme to map cropped coordinates to full-frame coordinates
-
- ^ Y
- | Width
- +------------------------------------------------+
- | |
- | |
- | Centered canvas, we map coordinate from it |
- | +------------------+ |
- | | | | H
- | | | | e
- | +------------------+ . Center | | i
- | | | | | | g
- | | | | | | h
- | |....dx.... +------|-----------+ | t
- | | . dy | |
- | +------------------+ |
- | Render border, we map coordinates to it |
- | | X
- +------------------------------------------------+---->
- Full frame
+ /**
+ * When using cropped render result, need to re-position area of interest,
+ * so it'll natch bounds of render border within frame. By default, canvas
+ * will be centered between full frame and cropped frame, so we use such
+ * scheme to map cropped coordinates to full-frame coordinates
+ *
+ * ^ Y
+ * | Width
+ * +------------------------------------------------+
+ * | |
+ * | |
+ * | Centered canvas, we map coordinate from it |
+ * | +------------------+ |
+ * | | | | H
+ * | | | | e
+ * | +------------------+ . Center | | i
+ * | | | | | | g
+ * | | | | | | h
+ * | |....dx.... +------|-----------+ | t
+ * | | . dy | |
+ * | +------------------+ |
+ * | Render border, we map coordinates to it |
+ * | | X
+ * +------------------------------------------------+---->
+ * Full frame
*/
int full_width = rd->xsch * rd->size / 100;
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index bccfe025089..9c04e74a7da 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -24,20 +24,20 @@
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
extern "C" {
- #include "BLI_jitter_2d.h"
+#include "BLI_jitter_2d.h"
}
#include "COM_VectorBlurOperation.h"
/* Defined */
-#define PASS_VECTOR_MAX 10000.0f
+#define PASS_VECTOR_MAX 10000.0f
/* Forward declarations */
struct ZSpan;
struct DrawBufPixel;
void zbuf_accumulate_vecblur(
- NodeBlurData *nbd, int xsize, int ysize, float *newrect,
- const float *imgrect, float *vecbufrect, const float *zbufrect);
+ NodeBlurData *nbd, int xsize, int ysize, float *newrect,
+ const float *imgrect, float *vecbufrect, const float *zbufrect);
void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop);
void zbuf_free_span(ZSpan *zspan);
void antialias_tagbuf(int xsize, int ysize, char *rectmove);
@@ -70,7 +70,7 @@ void VectorBlurOperation::initExecution()
void VectorBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- float *buffer = (float *) data;
+ float *buffer = (float *)data;
int index = (y * this->getWidth() + x) * COM_NUM_CHANNELS_COLOR;
copy_v4_v4(output, &buffer[index]);
}
@@ -148,7 +148,7 @@ typedef struct ZSpan {
float zmulx, zmuly, zofsx, zofsy;
int *rectz;
- DrawBufPixel* rectdraw;
+ DrawBufPixel *rectdraw;
float clipcrop;
} ZSpan;
@@ -158,13 +158,13 @@ void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop)
{
memset(zspan, 0, sizeof(ZSpan));
- zspan->rectx= rectx;
- zspan->recty= recty;
+ zspan->rectx = rectx;
+ zspan->recty = recty;
- zspan->span1= (float*)MEM_mallocN(recty*sizeof(float), "zspan");
- zspan->span2= (float*)MEM_mallocN(recty*sizeof(float), "zspan");
+ zspan->span1 = (float *)MEM_mallocN(recty * sizeof(float), "zspan");
+ zspan->span2 = (float *)MEM_mallocN(recty * sizeof(float), "zspan");
- zspan->clipcrop= clipcrop;
+ zspan->clipcrop = clipcrop;
}
void zbuf_free_span(ZSpan *zspan)
@@ -172,16 +172,16 @@ void zbuf_free_span(ZSpan *zspan)
if (zspan) {
if (zspan->span1) MEM_freeN(zspan->span1);
if (zspan->span2) MEM_freeN(zspan->span2);
- zspan->span1= zspan->span2= NULL;
+ zspan->span1 = zspan->span2 = NULL;
}
}
/* reset range for clipping */
static void zbuf_init_span(ZSpan *zspan)
{
- zspan->miny1= zspan->miny2= zspan->recty+1;
- zspan->maxy1= zspan->maxy2= -1;
- zspan->minp1= zspan->maxp1= zspan->minp2= zspan->maxp2= NULL;
+ zspan->miny1 = zspan->miny2 = zspan->recty + 1;
+ zspan->maxy1 = zspan->maxy2 = -1;
+ zspan->minp1 = zspan->maxp1 = zspan->minp2 = zspan->maxp2 = NULL;
}
static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
@@ -191,30 +191,30 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
float xx1, dx0, xs0;
int y, my0, my2;
- if (v1[1]<v2[1]) {
- minv= v1; maxv= v2;
+ if (v1[1] < v2[1]) {
+ minv = v1; maxv = v2;
}
else {
- minv= v2; maxv= v1;
+ minv = v2; maxv = v1;
}
- my0= ceil(minv[1]);
- my2= floor(maxv[1]);
+ my0 = ceil(minv[1]);
+ my2 = floor(maxv[1]);
- if (my2<0 || my0>= zspan->recty) return;
+ if (my2 < 0 || my0 >= zspan->recty) return;
/* clip top */
- if (my2>=zspan->recty) my2= zspan->recty-1;
+ if (my2 >= zspan->recty) my2 = zspan->recty - 1;
/* clip bottom */
- if (my0<0) my0= 0;
+ if (my0 < 0) my0 = 0;
- if (my0>my2) return;
+ if (my0 > my2) return;
/* if (my0>my2) should still fill in, that way we get spans that skip nicely */
- xx1= maxv[1]-minv[1];
- if (xx1>FLT_EPSILON) {
- dx0= (minv[0]-maxv[0])/xx1;
- xs0= dx0*(minv[1]-my2) + minv[0];
+ xx1 = maxv[1] - minv[1];
+ if (xx1 > FLT_EPSILON) {
+ dx0 = (minv[0] - maxv[0]) / xx1;
+ xs0 = dx0 * (minv[1] - my2) + minv[0];
}
else {
dx0 = 0.0f;
@@ -223,43 +223,43 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
/* empty span */
if (zspan->maxp1 == NULL) {
- span= zspan->span1;
+ span = zspan->span1;
}
- else { /* does it complete left span? */
- if ( maxv == zspan->minp1 || minv==zspan->maxp1) {
- span= zspan->span1;
+ else { /* does it complete left span? */
+ if (maxv == zspan->minp1 || minv == zspan->maxp1) {
+ span = zspan->span1;
}
else {
- span= zspan->span2;
+ span = zspan->span2;
}
}
- if (span==zspan->span1) {
+ if (span == zspan->span1) {
// printf("left span my0 %d my2 %d\n", my0, my2);
- if (zspan->minp1==NULL || zspan->minp1[1] > minv[1] ) {
- zspan->minp1= minv;
+ if (zspan->minp1 == NULL || zspan->minp1[1] > minv[1]) {
+ zspan->minp1 = minv;
}
- if (zspan->maxp1==NULL || zspan->maxp1[1] < maxv[1] ) {
- zspan->maxp1= maxv;
+ if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) {
+ zspan->maxp1 = maxv;
}
- if (my0<zspan->miny1) zspan->miny1= my0;
- if (my2>zspan->maxy1) zspan->maxy1= my2;
+ if (my0 < zspan->miny1) zspan->miny1 = my0;
+ if (my2 > zspan->maxy1) zspan->maxy1 = my2;
}
else {
// printf("right span my0 %d my2 %d\n", my0, my2);
- if (zspan->minp2==NULL || zspan->minp2[1] > minv[1] ) {
- zspan->minp2= minv;
+ if (zspan->minp2 == NULL || zspan->minp2[1] > minv[1]) {
+ zspan->minp2 = minv;
}
- if (zspan->maxp2==NULL || zspan->maxp2[1] < maxv[1] ) {
- zspan->maxp2= maxv;
+ if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) {
+ zspan->maxp2 = maxv;
}
- if (my0<zspan->miny2) zspan->miny2= my0;
- if (my2>zspan->maxy2) zspan->maxy2= my2;
+ if (my0 < zspan->miny2) zspan->miny2 = my0;
+ if (my2 > zspan->maxy2) zspan->maxy2 = my2;
}
- for (y=my2; y>=my0; y--, xs0+= dx0) {
+ for (y = my2; y >= my0; y--, xs0 += dx0) {
/* xs0 is the xcoord! */
- span[y]= xs0;
+ span[y] = xs0;
}
}
@@ -292,79 +292,79 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float
zbuf_add_to_span(zspan, v4, v1);
/* clipped */
- if (zspan->minp2==NULL || zspan->maxp2==NULL) return;
+ if (zspan->minp2 == NULL || zspan->maxp2 == NULL) return;
my0 = max_ii(zspan->miny1, zspan->miny2);
my2 = min_ii(zspan->maxy1, zspan->maxy2);
// printf("my %d %d\n", my0, my2);
- if (my2<my0) return;
+ if (my2 < my0) return;
/* ZBUF DX DY, in floats still */
- x1= v1[0]- v2[0];
- x2= v2[0]- v3[0];
- y1= v1[1]- v2[1];
- y2= v2[1]- v3[1];
- z1= v1[2]- v2[2];
- z2= v2[2]- v3[2];
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
- z0= x1*y2-y1*x2;
+ x1 = v1[0] - v2[0];
+ x2 = v2[0] - v3[0];
+ y1 = v1[1] - v2[1];
+ y2 = v2[1] - v3[1];
+ z1 = v1[2] - v2[2];
+ z2 = v2[2] - v3[2];
+ x0 = y1 * z2 - z1 * y2;
+ y0 = z1 * x2 - x1 * z2;
+ z0 = x1 * y2 - y1 * x2;
- if (z0==0.0f) return;
+ if (z0 == 0.0f) return;
- xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
+ xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + v1[2];
- zxd= -(double)x0/(double)z0;
- zyd= -(double)y0/(double)z0;
- zy0= ((double)my2)*zyd + (double)xx1;
+ zxd = -(double)x0 / (double)z0;
+ zyd = -(double)y0 / (double)z0;
+ zy0 = ((double)my2) * zyd + (double)xx1;
/* start-offset in rect */
- rectx= zspan->rectx;
- rectzofs= (float *)(zspan->rectz + rectx*my2);
- rectpofs= ((DrawBufPixel *)zspan->rectdraw) + rectx*my2;
+ rectx = zspan->rectx;
+ rectzofs = (float *)(zspan->rectz + rectx * my2);
+ rectpofs = ((DrawBufPixel *)zspan->rectdraw) + rectx * my2;
/* correct span */
- sn1= (my0 + my2)/2;
+ sn1 = (my0 + my2) / 2;
if (zspan->span1[sn1] < zspan->span2[sn1]) {
- span1= zspan->span1+my2;
- span2= zspan->span2+my2;
+ span1 = zspan->span1 + my2;
+ span2 = zspan->span2 + my2;
}
else {
- span1= zspan->span2+my2;
- span2= zspan->span1+my2;
+ span1 = zspan->span2 + my2;
+ span2 = zspan->span1 + my2;
}
- for (y=my2; y>=my0; y--, span1--, span2--) {
+ for (y = my2; y >= my0; y--, span1--, span2--) {
- sn1= floor(*span1);
- sn2= floor(*span2);
+ sn1 = floor(*span1);
+ sn2 = floor(*span2);
sn1++;
- if (sn2>=rectx) sn2= rectx-1;
- if (sn1<0) sn1= 0;
+ if (sn2 >= rectx) sn2 = rectx - 1;
+ if (sn1 < 0) sn1 = 0;
- if (sn2>=sn1) {
- zverg= (double)sn1*zxd + zy0;
- rz= rectzofs+sn1;
- rp= rectpofs+sn1;
- x= sn2-sn1;
+ if (sn2 >= sn1) {
+ zverg = (double)sn1 * zxd + zy0;
+ rz = rectzofs + sn1;
+ rp = rectpofs + sn1;
+ x = sn2 - sn1;
- while (x>=0) {
+ while (x >= 0) {
if (zverg < (double)*rz) {
- *rz= zverg;
- *rp= *col;
+ *rz = zverg;
+ *rp = *col;
}
- zverg+= zxd;
+ zverg += zxd;
rz++;
rp++;
x--;
}
}
- zy0-=zyd;
- rectzofs-= rectx;
- rectpofs-= rectx;
+ zy0 -= zyd;
+ rectzofs -= rectx;
+ rectpofs -= rectx;
}
}
@@ -377,43 +377,43 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
int a, x, y, step;
/* 1: tag pixels to be candidate for AA */
- for (y=2; y<ysize; y++) {
+ for (y = 2; y < ysize; y++) {
/* setup rows */
- row1= rectmove + (y-2)*xsize;
- row2= row1 + xsize;
- row3= row2 + xsize;
- for (x=2; x<xsize; x++, row1++, row2++, row3++) {
+ row1 = rectmove + (y - 2) * xsize;
+ row2 = row1 + xsize;
+ row3 = row2 + xsize;
+ for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
if (row2[1]) {
- if (row2[0]==0 || row2[2]==0 || row1[1]==0 || row3[1]==0)
- row2[1]= 128;
+ if (row2[0] == 0 || row2[2] == 0 || row1[1] == 0 || row3[1] == 0)
+ row2[1] = 128;
}
}
}
/* 2: evaluate horizontal scanlines and calculate alphas */
- row1= rectmove;
- for (y=0; y<ysize; y++) {
+ row1 = rectmove;
+ for (y = 0; y < ysize; y++) {
row1++;
- for (x=1; x<xsize; x++, row1++) {
- if (row1[0]==128 && row1[1]==128) {
+ for (x = 1; x < xsize; x++, row1++) {
+ if (row1[0] == 128 && row1[1] == 128) {
/* find previous color and next color and amount of steps to blend */
- prev= row1[-1];
- step= 1;
- while (x+step<xsize && row1[step]==128)
+ prev = row1[-1];
+ step = 1;
+ while (x + step < xsize && row1[step] == 128)
step++;
- if (x+step!=xsize) {
+ if (x + step != xsize) {
/* now we can blend values */
- next= row1[step];
+ next = row1[step];
/* note, prev value can be next value, but we do this loop to clear 128 then */
- for (a=0; a<step; a++) {
+ for (a = 0; a < step; a++) {
int fac, mfac;
- fac= ((a+1)<<8)/(step+1);
- mfac= 255-fac;
+ fac = ((a + 1) << 8) / (step + 1);
+ mfac = 255 - fac;
- row1[a]= (prev*mfac + next*fac)>>8;
+ row1[a] = (prev * mfac + next * fac) >> 8;
}
}
}
@@ -422,28 +422,28 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
/* 3: evaluate vertical scanlines and calculate alphas */
/* use for reading a copy of the original tagged buffer */
- for (x=0; x<xsize; x++) {
- row1= rectmove + x+xsize;
+ for (x = 0; x < xsize; x++) {
+ row1 = rectmove + x + xsize;
- for (y=1; y<ysize; y++, row1+=xsize) {
- if (row1[0]==128 && row1[xsize]==128) {
+ for (y = 1; y < ysize; y++, row1 += xsize) {
+ if (row1[0] == 128 && row1[xsize] == 128) {
/* find previous color and next color and amount of steps to blend */
- prev= row1[-xsize];
- step= 1;
- while (y+step<ysize && row1[step*xsize]==128)
+ prev = row1[-xsize];
+ step = 1;
+ while (y + step < ysize && row1[step * xsize] == 128)
step++;
- if (y+step!=ysize) {
+ if (y + step != ysize) {
/* now we can blend values */
- next= row1[step*xsize];
+ next = row1[step * xsize];
/* note, prev value can be next value, but we do this loop to clear 128 then */
- for (a=0; a<step; a++) {
+ for (a = 0; a < step; a++) {
int fac, mfac;
- fac= ((a+1)<<8)/(step+1);
- mfac= 255-fac;
+ fac = ((a + 1) << 8) / (step + 1);
+ mfac = 255 - fac;
- row1[a*xsize]= (prev*mfac + next*fac)>>8;
+ row1[a * xsize] = (prev * mfac + next * fac) >> 8;
}
}
}
@@ -451,15 +451,15 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
}
/* last: pixels with 0 we fill in zbuffer, with 1 we skip for mask */
- for (y=2; y<ysize; y++) {
+ for (y = 2; y < ysize; y++) {
/* setup rows */
- row1= rectmove + (y-2)*xsize;
- row2= row1 + xsize;
- row3= row2 + xsize;
- for (x=2; x<xsize; x++, row1++, row2++, row3++) {
- if (row2[1]==0) {
- if (row2[0]>1 || row2[2]>1 || row1[1]>1 || row3[1]>1)
- row2[1]= 1;
+ row1 = rectmove + (y - 2) * xsize;
+ row2 = row1 + xsize;
+ row3 = row2 + xsize;
+ for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
+ if (row2[1] == 0) {
+ if (row2[0] > 1 || row2[2] > 1 || row1[1] > 1 || row3[1] > 1)
+ row2[1] = 1;
}
}
}
@@ -473,32 +473,32 @@ static void quad_bezier_2d(float *result, float *v1, float *v2, float *ipodata)
{
float p1[2], p2[2], p3[2];
- p3[0]= -v2[0];
- p3[1]= -v2[1];
+ p3[0] = -v2[0];
+ p3[1] = -v2[1];
- p1[0]= v1[0];
- p1[1]= v1[1];
+ p1[0] = v1[0];
+ p1[1] = v1[1];
/* official formula 2*p2 - 0.5*p1 - 0.5*p3 */
- p2[0]= -0.5f*p1[0] - 0.5f*p3[0];
- p2[1]= -0.5f*p1[1] - 0.5f*p3[1];
+ p2[0] = -0.5f * p1[0] - 0.5f * p3[0];
+ p2[1] = -0.5f * p1[1] - 0.5f * p3[1];
- result[0]= ipodata[0]*p1[0] + ipodata[1]*p2[0] + ipodata[2]*p3[0];
- result[1]= ipodata[0]*p1[1] + ipodata[1]*p2[1] + ipodata[2]*p3[1];
+ result[0] = ipodata[0] * p1[0] + ipodata[1] * p2[0] + ipodata[2] * p3[0];
+ result[1] = ipodata[0] * p1[1] + ipodata[1] * p2[1] + ipodata[2] * p3[1];
}
static void set_quad_bezier_ipo(float fac, float *data)
{
- float mfac= (1.0f-fac);
+ float mfac = (1.0f - fac);
- data[0]= mfac*mfac;
- data[1]= 2.0f*mfac*fac;
- data[2]= fac*fac;
+ data[0] = mfac * mfac;
+ data[1] = 2.0f * mfac * fac;
+ data[2] = fac * fac;
}
void zbuf_accumulate_vecblur(
- NodeBlurData *nbd, int xsize, int ysize, float *newrect,
- const float *imgrect, float *vecbufrect, const float *zbufrect)
+ NodeBlurData *nbd, int xsize, int ysize, float *newrect,
+ const float *imgrect, float *vecbufrect, const float *zbufrect)
{
ZSpan zspan;
DrawBufPixel *rectdraw, *dr;
@@ -506,64 +506,64 @@ void zbuf_accumulate_vecblur(
float v1[3], v2[3], v3[3], v4[3], fx, fy;
const float *dimg, *dz, *ro;
float *rectvz, *dvz, *dvec1, *dvec2, *dz1, *dz2, *rectz;
- float *minvecbufrect= NULL, *rectweight, *rw, *rectmax, *rm;
- float maxspeedsq= (float)nbd->maxspeed*nbd->maxspeed;
- int y, x, step, maxspeed=nbd->maxspeed, samples= nbd->samples;
- int tsktsk= 0;
- static int firsttime= 1;
+ float *minvecbufrect = NULL, *rectweight, *rw, *rectmax, *rm;
+ float maxspeedsq = (float)nbd->maxspeed * nbd->maxspeed;
+ int y, x, step, maxspeed = nbd->maxspeed, samples = nbd->samples;
+ int tsktsk = 0;
+ static int firsttime = 1;
char *rectmove, *dm;
zbuf_alloc_span(&zspan, xsize, ysize, 1.0f);
- zspan.zmulx= ((float)xsize)/2.0f;
- zspan.zmuly= ((float)ysize)/2.0f;
- zspan.zofsx= 0.0f;
- zspan.zofsy= 0.0f;
+ zspan.zmulx = ((float)xsize) / 2.0f;
+ zspan.zmuly = ((float)ysize) / 2.0f;
+ zspan.zofsx = 0.0f;
+ zspan.zofsy = 0.0f;
/* the buffers */
- rectz= (float*)MEM_mapallocN(sizeof(float)*xsize*ysize, "zbuf accum");
- zspan.rectz= (int *)rectz;
+ rectz = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "zbuf accum");
+ zspan.rectz = (int *)rectz;
- rectmove= (char*)MEM_mapallocN(xsize*ysize, "rectmove");
- rectdraw= (DrawBufPixel*)MEM_mapallocN(sizeof(DrawBufPixel)*xsize*ysize, "rect draw");
- zspan.rectdraw= rectdraw;
+ rectmove = (char *)MEM_mapallocN(xsize * ysize, "rectmove");
+ rectdraw = (DrawBufPixel *)MEM_mapallocN(sizeof(DrawBufPixel) * xsize * ysize, "rect draw");
+ zspan.rectdraw = rectdraw;
- rectweight= (float*)MEM_mapallocN(sizeof(float)*xsize*ysize, "rect weight");
- rectmax= (float*)MEM_mapallocN(sizeof(float)*xsize*ysize, "rect max");
+ rectweight = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "rect weight");
+ rectmax = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "rect max");
/* debug... check if PASS_VECTOR_MAX still is in buffers */
- dvec1= vecbufrect;
- for (x= 4*xsize*ysize; x>0; x--, dvec1++) {
- if (dvec1[0]==PASS_VECTOR_MAX) {
- dvec1[0]= 0.0f;
- tsktsk= 1;
+ dvec1 = vecbufrect;
+ for (x = 4 * xsize * ysize; x > 0; x--, dvec1++) {
+ if (dvec1[0] == PASS_VECTOR_MAX) {
+ dvec1[0] = 0.0f;
+ tsktsk = 1;
}
}
if (tsktsk) printf("Found uninitialized speed in vector buffer... fixed.\n");
/* min speed? then copy speedbuffer to recalculate speed vectors */
if (nbd->minspeed) {
- float minspeed= (float)nbd->minspeed;
- float minspeedsq= minspeed*minspeed;
+ float minspeed = (float)nbd->minspeed;
+ float minspeedsq = minspeed * minspeed;
- minvecbufrect= (float*)MEM_mapallocN(4*sizeof(float)*xsize*ysize, "minspeed buf");
+ minvecbufrect = (float *)MEM_mapallocN(4 * sizeof(float) * xsize * ysize, "minspeed buf");
- dvec1= vecbufrect;
- dvec2= minvecbufrect;
- for (x= 2*xsize*ysize; x>0; x--, dvec1+=2, dvec2+=2) {
- if (dvec1[0]==0.0f && dvec1[1]==0.0f) {
- dvec2[0]= dvec1[0];
- dvec2[1]= dvec1[1];
+ dvec1 = vecbufrect;
+ dvec2 = minvecbufrect;
+ for (x = 2 * xsize * ysize; x > 0; x--, dvec1 += 2, dvec2 += 2) {
+ if (dvec1[0] == 0.0f && dvec1[1] == 0.0f) {
+ dvec2[0] = dvec1[0];
+ dvec2[1] = dvec1[1];
}
else {
- float speedsq= dvec1[0]*dvec1[0] + dvec1[1]*dvec1[1];
+ float speedsq = dvec1[0] * dvec1[0] + dvec1[1] * dvec1[1];
if (speedsq <= minspeedsq) {
- dvec2[0]= 0.0f;
- dvec2[1]= 0.0f;
+ dvec2[0] = 0.0f;
+ dvec2[1] = 0.0f;
}
else {
speedsq = 1.0f - minspeed / sqrtf(speedsq);
- dvec2[0]= speedsq*dvec1[0];
- dvec2[1]= speedsq*dvec1[1];
+ dvec2[0] = speedsq * dvec1[0];
+ dvec2[1] = speedsq * dvec1[1];
}
}
}
@@ -571,75 +571,75 @@ void zbuf_accumulate_vecblur(
}
/* make vertex buffer with averaged speed and zvalues */
- rectvz= (float*)MEM_mapallocN(4*sizeof(float)*(xsize+1)*(ysize+1), "vertices");
- dvz= rectvz;
- for (y=0; y<=ysize; y++) {
+ rectvz = (float *)MEM_mapallocN(4 * sizeof(float) * (xsize + 1) * (ysize + 1), "vertices");
+ dvz = rectvz;
+ for (y = 0; y <= ysize; y++) {
- if (y==0)
- dvec1= vecbufrect + 4*y*xsize;
+ if (y == 0)
+ dvec1 = vecbufrect + 4 * y * xsize;
else
- dvec1= vecbufrect + 4*(y-1)*xsize;
+ dvec1 = vecbufrect + 4 * (y - 1) * xsize;
- if (y==ysize)
- dvec2= vecbufrect + 4*(y-1)*xsize;
+ if (y == ysize)
+ dvec2 = vecbufrect + 4 * (y - 1) * xsize;
else
- dvec2= vecbufrect + 4*y*xsize;
+ dvec2 = vecbufrect + 4 * y * xsize;
- for (x=0; x<=xsize; x++) {
+ for (x = 0; x <= xsize; x++) {
/* two vectors, so a step loop */
- for (step=0; step<2; step++, dvec1+=2, dvec2+=2, dvz+=2) {
+ for (step = 0; step < 2; step++, dvec1 += 2, dvec2 += 2, dvz += 2) {
/* average on minimal speed */
- int div= 0;
+ int div = 0;
- if (x!=0) {
- if (dvec1[-4]!=0.0f || dvec1[-3]!=0.0f) {
- dvz[0]= dvec1[-4];
- dvz[1]= dvec1[-3];
+ if (x != 0) {
+ if (dvec1[-4] != 0.0f || dvec1[-3] != 0.0f) {
+ dvz[0] = dvec1[-4];
+ dvz[1] = dvec1[-3];
div++;
}
- if (dvec2[-4]!=0.0f || dvec2[-3]!=0.0f) {
- if (div==0) {
- dvz[0]= dvec2[-4];
- dvz[1]= dvec2[-3];
+ if (dvec2[-4] != 0.0f || dvec2[-3] != 0.0f) {
+ if (div == 0) {
+ dvz[0] = dvec2[-4];
+ dvz[1] = dvec2[-3];
div++;
}
- else if ( (ABS(dvec2[-4]) + ABS(dvec2[-3]))< (ABS(dvz[0]) + ABS(dvz[1])) ) {
- dvz[0]= dvec2[-4];
- dvz[1]= dvec2[-3];
+ else if ( (ABS(dvec2[-4]) + ABS(dvec2[-3])) < (ABS(dvz[0]) + ABS(dvz[1])) ) {
+ dvz[0] = dvec2[-4];
+ dvz[1] = dvec2[-3];
}
}
}
- if (x!=xsize) {
- if (dvec1[0]!=0.0f || dvec1[1]!=0.0f) {
- if (div==0) {
- dvz[0]= dvec1[0];
- dvz[1]= dvec1[1];
+ if (x != xsize) {
+ if (dvec1[0] != 0.0f || dvec1[1] != 0.0f) {
+ if (div == 0) {
+ dvz[0] = dvec1[0];
+ dvz[1] = dvec1[1];
div++;
}
- else if ( (ABS(dvec1[0]) + ABS(dvec1[1]))< (ABS(dvz[0]) + ABS(dvz[1])) ) {
- dvz[0]= dvec1[0];
- dvz[1]= dvec1[1];
+ else if ( (ABS(dvec1[0]) + ABS(dvec1[1])) < (ABS(dvz[0]) + ABS(dvz[1])) ) {
+ dvz[0] = dvec1[0];
+ dvz[1] = dvec1[1];
}
}
- if (dvec2[0]!=0.0f || dvec2[1]!=0.0f) {
- if (div==0) {
- dvz[0]= dvec2[0];
- dvz[1]= dvec2[1];
+ if (dvec2[0] != 0.0f || dvec2[1] != 0.0f) {
+ if (div == 0) {
+ dvz[0] = dvec2[0];
+ dvz[1] = dvec2[1];
}
- else if ( (ABS(dvec2[0]) + ABS(dvec2[1]))< (ABS(dvz[0]) + ABS(dvz[1])) ) {
- dvz[0]= dvec2[0];
- dvz[1]= dvec2[1];
+ else if ( (ABS(dvec2[0]) + ABS(dvec2[1])) < (ABS(dvz[0]) + ABS(dvz[1])) ) {
+ dvz[0] = dvec2[0];
+ dvz[1] = dvec2[1];
}
}
}
if (maxspeed) {
- float speedsq= dvz[0]*dvz[0] + dvz[1]*dvz[1];
+ float speedsq = dvz[0] * dvz[0] + dvz[1] * dvz[1];
if (speedsq > maxspeedsq) {
speedsq = (float)maxspeed / sqrtf(speedsq);
- dvz[0]*= speedsq;
- dvz[1]*= speedsq;
+ dvz[0] *= speedsq;
+ dvz[1] *= speedsq;
}
}
}
@@ -647,117 +647,117 @@ void zbuf_accumulate_vecblur(
}
/* set border speeds to keep border speeds on border */
- dz1= rectvz;
- dz2= rectvz+4*(ysize)*(xsize+1);
- for (x=0; x<=xsize; x++, dz1+=4, dz2+=4) {
- dz1[1]= 0.0f;
- dz2[1]= 0.0f;
- dz1[3]= 0.0f;
- dz2[3]= 0.0f;
+ dz1 = rectvz;
+ dz2 = rectvz + 4 * (ysize) * (xsize + 1);
+ for (x = 0; x <= xsize; x++, dz1 += 4, dz2 += 4) {
+ dz1[1] = 0.0f;
+ dz2[1] = 0.0f;
+ dz1[3] = 0.0f;
+ dz2[3] = 0.0f;
}
- dz1= rectvz;
- dz2= rectvz+4*(xsize);
- for (y=0; y<=ysize; y++, dz1+=4*(xsize+1), dz2+=4*(xsize+1)) {
- dz1[0]= 0.0f;
- dz2[0]= 0.0f;
- dz1[2]= 0.0f;
- dz2[2]= 0.0f;
+ dz1 = rectvz;
+ dz2 = rectvz + 4 * (xsize);
+ for (y = 0; y <= ysize; y++, dz1 += 4 * (xsize + 1), dz2 += 4 * (xsize + 1)) {
+ dz1[0] = 0.0f;
+ dz2[0] = 0.0f;
+ dz1[2] = 0.0f;
+ dz2[2] = 0.0f;
}
/* tag moving pixels, only these faces we draw */
- dm= rectmove;
- dvec1= vecbufrect;
- for (x=xsize*ysize; x>0; x--, dm++, dvec1+=4) {
- if ((dvec1[0]!=0.0f || dvec1[1]!=0.0f || dvec1[2]!=0.0f || dvec1[3]!=0.0f))
- *dm= 255;
+ dm = rectmove;
+ dvec1 = vecbufrect;
+ for (x = xsize * ysize; x > 0; x--, dm++, dvec1 += 4) {
+ if ((dvec1[0] != 0.0f || dvec1[1] != 0.0f || dvec1[2] != 0.0f || dvec1[3] != 0.0f))
+ *dm = 255;
}
antialias_tagbuf(xsize, ysize, rectmove);
/* has to become static, the init-jit calls a random-seed, screwing up texture noise node */
if (firsttime) {
- firsttime= 0;
+ firsttime = 0;
BLI_jitter_init(jit, 256);
}
- memset(newrect, 0, sizeof(float)*xsize*ysize*4);
+ memset(newrect, 0, sizeof(float) * xsize * ysize * 4);
/* accumulate */
- samples/= 2;
- for (step= 1; step<=samples; step++) {
- float speedfac= 0.5f*nbd->fac*(float)step/(float)(samples+1);
+ samples /= 2;
+ for (step = 1; step <= samples; step++) {
+ float speedfac = 0.5f * nbd->fac * (float)step / (float)(samples + 1);
int side;
- for (side=0; side<2; side++) {
+ for (side = 0; side < 2; side++) {
float blendfac, ipodata[4];
/* clear zbuf, if we draw future we fill in not moving pixels */
if (0)
- for (x= xsize*ysize-1; x>=0; x--) rectz[x]= 10e16;
+ for (x = xsize * ysize - 1; x >= 0; x--) rectz[x] = 10e16;
else
- for (x= xsize*ysize-1; x>=0; x--) {
- if (rectmove[x]==0)
- rectz[x]= zbufrect[x];
+ for (x = xsize * ysize - 1; x >= 0; x--) {
+ if (rectmove[x] == 0)
+ rectz[x] = zbufrect[x];
else
- rectz[x]= 10e16;
+ rectz[x] = 10e16;
}
/* clear drawing buffer */
- for (x= xsize*ysize-1; x>=0; x--) rectdraw[x].colpoin= NULL;
+ for (x = xsize * ysize - 1; x >= 0; x--) rectdraw[x].colpoin = NULL;
- dimg= imgrect;
- dm= rectmove;
- dz= zbufrect;
- dz1= rectvz;
- dz2= rectvz + 4*(xsize + 1);
+ dimg = imgrect;
+ dm = rectmove;
+ dz = zbufrect;
+ dz1 = rectvz;
+ dz2 = rectvz + 4 * (xsize + 1);
if (side) {
- if (nbd->curved==0) {
- dz1+= 2;
- dz2+= 2;
+ if (nbd->curved == 0) {
+ dz1 += 2;
+ dz2 += 2;
}
- speedfac= -speedfac;
+ speedfac = -speedfac;
}
- set_quad_bezier_ipo(0.5f + 0.5f*speedfac, ipodata);
+ set_quad_bezier_ipo(0.5f + 0.5f * speedfac, ipodata);
- for (fy= -0.5f+jit[step & 255][0], y=0; y<ysize; y++, fy+=1.0f) {
- for (fx= -0.5f+jit[step & 255][1], x=0; x<xsize; x++, fx+=1.0f, dimg+=4, dz1+=4, dz2+=4, dm++, dz++) {
- if (*dm>1) {
+ for (fy = -0.5f + jit[step & 255][0], y = 0; y < ysize; y++, fy += 1.0f) {
+ for (fx = -0.5f + jit[step & 255][1], x = 0; x < xsize; x++, fx += 1.0f, dimg += 4, dz1 += 4, dz2 += 4, dm++, dz++) {
+ if (*dm > 1) {
float jfx = fx + 0.5f;
float jfy = fy + 0.5f;
DrawBufPixel col;
/* make vertices */
- if (nbd->curved) { /* curved */
- quad_bezier_2d(v1, dz1, dz1+2, ipodata);
- v1[0]+= jfx; v1[1]+= jfy; v1[2]= *dz;
+ if (nbd->curved) { /* curved */
+ quad_bezier_2d(v1, dz1, dz1 + 2, ipodata);
+ v1[0] += jfx; v1[1] += jfy; v1[2] = *dz;
- quad_bezier_2d(v2, dz1+4, dz1+4+2, ipodata);
- v2[0]+= jfx+1.0f; v2[1]+= jfy; v2[2]= *dz;
+ quad_bezier_2d(v2, dz1 + 4, dz1 + 4 + 2, ipodata);
+ v2[0] += jfx + 1.0f; v2[1] += jfy; v2[2] = *dz;
- quad_bezier_2d(v3, dz2+4, dz2+4+2, ipodata);
- v3[0]+= jfx+1.0f; v3[1]+= jfy+1.0f; v3[2]= *dz;
+ quad_bezier_2d(v3, dz2 + 4, dz2 + 4 + 2, ipodata);
+ v3[0] += jfx + 1.0f; v3[1] += jfy + 1.0f; v3[2] = *dz;
- quad_bezier_2d(v4, dz2, dz2+2, ipodata);
- v4[0]+= jfx; v4[1]+= jfy+1.0f; v4[2]= *dz;
+ quad_bezier_2d(v4, dz2, dz2 + 2, ipodata);
+ v4[0] += jfx; v4[1] += jfy + 1.0f; v4[2] = *dz;
}
else {
- v1[0]= speedfac*dz1[0]+jfx; v1[1]= speedfac*dz1[1]+jfy; v1[2]= *dz;
- v2[0]= speedfac*dz1[4]+jfx+1.0f; v2[1]= speedfac*dz1[5]+jfy; v2[2]= *dz;
- v3[0]= speedfac*dz2[4]+jfx+1.0f; v3[1]= speedfac*dz2[5]+jfy+1.0f; v3[2]= *dz;
- v4[0]= speedfac*dz2[0]+jfx; v4[1]= speedfac*dz2[1]+jfy+1.0f; v4[2]= *dz;
+ ARRAY_SET_ITEMS(v1, speedfac * dz1[0] + jfx, speedfac * dz1[1] + jfy, *dz);
+ ARRAY_SET_ITEMS(v2, speedfac * dz1[4] + jfx + 1.0f, speedfac * dz1[5] + jfy, *dz);
+ ARRAY_SET_ITEMS(v3, speedfac * dz2[4] + jfx + 1.0f, speedfac * dz2[5] + jfy + 1.0f, *dz);
+ ARRAY_SET_ITEMS(v4, speedfac * dz2[0] + jfx, speedfac * dz2[1] + jfy + 1.0f, *dz);
}
- if (*dm==255) col.alpha= 1.0f;
- else if (*dm<2) col.alpha= 0.0f;
- else col.alpha= ((float)*dm)/255.0f;
- col.colpoin= dimg;
+ if (*dm == 255) col.alpha = 1.0f;
+ else if (*dm < 2) col.alpha = 0.0f;
+ else col.alpha = ((float)*dm) / 255.0f;
+ col.colpoin = dimg;
zbuf_fill_in_rgba(&zspan, &col, v1, v2, v3, v4);
}
}
- dz1+=4;
- dz2+=4;
+ dz1 += 4;
+ dz2 += 4;
}
/* blend with a falloff. this fixes the ugly effect you get with
@@ -767,43 +767,43 @@ void zbuf_accumulate_vecblur(
* we don't know what is behind it so we don't do that. this hack
* overestimates the contribution of foreground pixels but looks a
* bit better without a sudden cutoff. */
- blendfac= ((samples - step)/(float)samples);
+ blendfac = ((samples - step) / (float)samples);
/* smoothstep to make it look a bit nicer as well */
- blendfac= 3.0f*pow(blendfac, 2.0f) - 2.0f*pow(blendfac, 3.0f);
+ blendfac = 3.0f * pow(blendfac, 2.0f) - 2.0f * pow(blendfac, 3.0f);
/* accum */
- rw= rectweight;
- rm= rectmax;
- for (dr= rectdraw, dz2=newrect, x= xsize*ysize-1; x>=0; x--, dr++, dz2+=4, rw++, rm++) {
+ rw = rectweight;
+ rm = rectmax;
+ for (dr = rectdraw, dz2 = newrect, x = xsize * ysize - 1; x >= 0; x--, dr++, dz2 += 4, rw++, rm++) {
if (dr->colpoin) {
- float bfac= dr->alpha*blendfac;
+ float bfac = dr->alpha * blendfac;
- dz2[0] += bfac*dr->colpoin[0];
- dz2[1] += bfac*dr->colpoin[1];
- dz2[2] += bfac*dr->colpoin[2];
- dz2[3] += bfac*dr->colpoin[3];
+ dz2[0] += bfac * dr->colpoin[0];
+ dz2[1] += bfac * dr->colpoin[1];
+ dz2[2] += bfac * dr->colpoin[2];
+ dz2[3] += bfac * dr->colpoin[3];
*rw += bfac;
- *rm= MAX2(*rm, bfac);
+ *rm = MAX2(*rm, bfac);
}
}
}
}
/* blend between original images and accumulated image */
- rw= rectweight;
- rm= rectmax;
- ro= imgrect;
- dm= rectmove;
- for (dz2=newrect, x= xsize*ysize-1; x>=0; x--, dz2+=4, ro+=4, rw++, rm++, dm++) {
+ rw = rectweight;
+ rm = rectmax;
+ ro = imgrect;
+ dm = rectmove;
+ for (dz2 = newrect, x = xsize * ysize - 1; x >= 0; x--, dz2 += 4, ro += 4, rw++, rm++, dm++) {
float mfac = *rm;
- float fac = (*rw == 0.0f)? 0.0f: mfac/(*rw);
+ float fac = (*rw == 0.0f) ? 0.0f : mfac / (*rw);
float nfac = 1.0f - mfac;
- dz2[0]= fac*dz2[0] + nfac*ro[0];
- dz2[1]= fac*dz2[1] + nfac*ro[1];
- dz2[2]= fac*dz2[2] + nfac*ro[2];
- dz2[3]= fac*dz2[3] + nfac*ro[3];
+ dz2[0] = fac * dz2[0] + nfac * ro[0];
+ dz2[1] = fac * dz2[1] + nfac * ro[1];
+ dz2[2] = fac * dz2[2] + nfac * ro[2];
+ dz2[3] = fac * dz2[3] + nfac * ro[3];
}
MEM_freeN(rectz);
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 4760c88cdbd..b30c99cbc0e 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -60,7 +60,6 @@ typedef struct Depsgraph Depsgraph;
/* ------------------------------------------------ */
-struct EvaluationContext;
struct Main;
struct PointerRNA;
@@ -75,19 +74,6 @@ typedef enum eEvaluationMode {
DAG_EVAL_RENDER = 2, /* evaluate for render purposes */
} eEvaluationMode;
-/* Dependency graph evaluation context
- *
- * This structure stores all the local dependency graph data,
- * which is needed for it's evaluation,
- */
-typedef struct EvaluationContext {
- eEvaluationMode mode;
- float ctime;
-
- struct Depsgraph *depsgraph;
- struct ViewLayer *view_layer;
-} EvaluationContext;
-
/* DagNode->eval_flags */
enum {
/* Regardless to curve->path animation flag path is to be evaluated anyway,
@@ -203,37 +189,6 @@ void DEG_ids_check_recalc(struct Main *bmain,
/* ************************************************ */
/* Evaluation Engine API */
-/* Evaluation Context ---------------------------- */
-
-/* Create new evaluation context. */
-struct EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode);
-
-/* Initialize evaluation context.
- * Used by the areas which currently overrides the context or doesn't have
- * access to a proper one.
- */
-void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx,
- eEvaluationMode mode);
-void DEG_evaluation_context_init_from_scene(
- struct EvaluationContext *eval_ctx,
- struct Scene *scene,
- struct ViewLayer *view_layer,
- eEvaluationMode mode);
-
-void DEG_evaluation_context_init_from_view_layer_for_render(
- struct EvaluationContext *eval_ctx,
- struct Depsgraph *depsgraph,
- struct Scene *scene,
- struct ViewLayer *view_layer);
-
-void DEG_evaluation_context_init_from_depsgraph(
- struct EvaluationContext *eval_ctx,
- struct Depsgraph *depsgraph,
- eEvaluationMode mode);
-
-/* Free evaluation context. */
-void DEG_evaluation_context_free(struct EvaluationContext *eval_ctx);
-
/* Graph Evaluation ----------------------------- */
/* Frame changed recalculation entry point
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 334b15cc638..3460cbf7c91 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -42,7 +42,6 @@ struct Depsgraph;
struct CacheFile;
struct EffectorWeights;
-struct EvaluationContext;
struct Group;
struct Main;
struct ModifierData;
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index ceba87338a0..508714db218 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -85,6 +85,13 @@ struct Object *DEG_get_evaluated_object(const struct Depsgraph *depsgraph,
struct ID *DEG_get_evaluated_id(const struct Depsgraph *depsgraph,
struct ID *id);
+
+/* Get original version of object for given evaluated one. */
+struct Object *DEG_get_original_object(struct Object *object);
+
+/* Get original version of given evaluated ID datablock. */
+struct ID *DEG_get_original_id(struct ID *id);
+
/* ************************ DEG iterators ********************* */
enum {
@@ -106,7 +113,6 @@ typedef struct DEGObjectIterData {
int flag;
struct Scene *scene;
- struct EvaluationContext eval_ctx;
int visibility_check; /* eObjectVisibilityCheck. */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 994674f95fe..1179d05e834 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -172,7 +172,7 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
ComponentDepsNode *comp_cow =
id_node->add_component(DEG_NODE_TYPE_COPY_ON_WRITE);
OperationDepsNode *op_cow = comp_cow->add_operation(
- function_bind(deg_evaluate_copy_on_write, _1, graph_, id_node),
+ function_bind(deg_evaluate_copy_on_write, _1, id_node),
DEG_OPCODE_COPY_ON_WRITE,
"", -1);
graph_->operations.push_back(op_cow);
@@ -384,6 +384,43 @@ void DepsgraphNodeBuilder::end_build()
}
}
+void DepsgraphNodeBuilder::build_id(ID* id) {
+ if (id == NULL) {
+ return;
+ }
+ switch (GS(id->name)) {
+ case ID_GR:
+ build_group((Group *)id);
+ break;
+ case ID_OB:
+ build_object(-1, (Object *)id, DEG_ID_LINKED_INDIRECTLY);
+ break;
+ case ID_NT:
+ build_nodetree((bNodeTree *)id);
+ break;
+ case ID_MA:
+ build_material((Material *)id);
+ break;
+ case ID_TE:
+ build_texture((Tex *)id);
+ break;
+ case ID_IM:
+ build_image((Image *)id);
+ break;
+ case ID_WO:
+ build_world((World *)id);
+ break;
+ case ID_MSK:
+ build_mask((Mask *)id);
+ break;
+ case ID_MC:
+ build_movieclip((MovieClip *)id);
+ break;
+ default:
+ fprintf(stderr, "Unhandled ID %s\n", id->name);
+ }
+}
+
void DepsgraphNodeBuilder::build_group(Group *group)
{
if (built_map_.checkIsBuiltAndTag(group)) {
@@ -491,13 +528,16 @@ void DepsgraphNodeBuilder::build_object_flags(
if (base_index == -1) {
return;
}
- /* TODO(sergey): Is this really best component to be used? */
+ Scene *scene_cow = get_cow_datablock(scene_);
Object *object_cow = get_cow_datablock(object);
const bool is_from_set = (linked_state == DEG_ID_LINKED_VIA_SET);
+ /* TODO(sergey): Is this really best component to be used? */
add_operation_node(&object->id,
DEG_NODE_TYPE_LAYER_COLLECTIONS,
function_bind(BKE_object_eval_flush_base_flags,
_1,
+ scene_cow,
+ view_layer_index_,
object_cow, base_index,
is_from_set),
DEG_OPCODE_OBJECT_BASE_FLAGS);
@@ -701,6 +741,7 @@ void DepsgraphNodeBuilder::build_driver_variables(ID * id, FCurve *fcurve)
LISTBASE_FOREACH (DriverVar *, dvar, &fcurve->driver->variables) {
DRIVER_TARGETS_USED_LOOPER(dvar)
{
+ build_id(dtar->id);
build_driver_id_property(dtar->id, dtar->rna_path);
}
DRIVER_TARGETS_LOOPER_END
@@ -748,8 +789,6 @@ void DepsgraphNodeBuilder::build_world(World *world)
_1,
get_cow_datablock(world)),
DEG_OPCODE_WORLD_UPDATE);
- /* textures */
- build_texture_stack(world->mtex);
/* world's nodetree */
if (world->nodetree != NULL) {
build_nodetree(world->nodetree);
@@ -1167,8 +1206,6 @@ void DepsgraphNodeBuilder::build_lamp(Object *object)
DEG_OPCODE_PARAMETERS_EVAL);
/* lamp's nodetree */
build_nodetree(lamp->nodetree);
- /* textures */
- build_texture_stack(lamp->mtex);
}
void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
@@ -1256,24 +1293,10 @@ void DepsgraphNodeBuilder::build_material(Material *material)
DEG_OPCODE_MATERIAL_UPDATE);
/* Material animation. */
build_animdata(&material->id);
- /* Textures. */
- build_texture_stack(material->mtex);
/* Material's nodetree. */
build_nodetree(material->nodetree);
}
-/* Texture-stack attached to some shading datablock */
-void DepsgraphNodeBuilder::build_texture_stack(MTex **texture_stack)
-{
- /* for now assume that all texture-stacks have same number of max items */
- for (int i = 0; i < MAX_MTEX; i++) {
- MTex *mtex = texture_stack[i];
- if (mtex && mtex->tex) {
- build_texture(mtex->tex);
- }
- }
-}
-
/* Recursively build graph for texture */
void DepsgraphNodeBuilder::build_texture(Tex *texture)
{
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index c933e139758..483e0c266a9 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -158,6 +158,7 @@ struct DepsgraphNodeBuilder {
const char *name = "",
int name_tag = -1);
+ void build_id(ID* id);
void build_view_layer(Scene *scene,
ViewLayer *view_layer,
eDepsNode_LinkedState_Type linked_state);
@@ -195,7 +196,6 @@ struct DepsgraphNodeBuilder {
void build_nodetree(bNodeTree *ntree);
void build_material(Material *ma);
void build_texture(Tex *tex);
- void build_texture_stack(MTex **texture_stack);
void build_image(Image *image);
void build_world(World *world);
void build_compositor(Scene *scene);
@@ -234,6 +234,7 @@ protected:
/* State which demotes currently built entities. */
Scene *scene_;
ViewLayer *view_layer_;
+ int view_layer_index_;
GHash *cow_id_hash_;
BuilderMap built_map_;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
index 390619aeeaa..750b0054ee5 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
@@ -70,6 +70,8 @@ void DepsgraphNodeBuilder::build_view_layer(
ViewLayer *view_layer,
eDepsNode_LinkedState_Type linked_state)
{
+ view_layer_index_ = BLI_findindex(&scene->view_layers, view_layer);
+ BLI_assert(view_layer_index_ != -1);
/* Scene ID block. */
add_id_node(&scene->id);
/* Time source. */
@@ -134,14 +136,12 @@ void DepsgraphNodeBuilder::build_view_layer(
build_movieclip(clip);
}
/* Collections. */
- int view_layer_index = BLI_findindex(&scene->view_layers, view_layer);
- BLI_assert(view_layer_index != -1);
add_operation_node(&scene->id,
DEG_NODE_TYPE_LAYER_COLLECTIONS,
function_bind(BKE_layer_eval_view_layer_indexed,
_1,
&scene_cow->id,
- view_layer_index),
+ view_layer_index_),
DEG_OPCODE_VIEW_LAYER_EVAL);
/* Parameters evaluation for scene relations mainly. */
add_operation_node(&scene->id,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 7da2c4f54a1..668d533ebd7 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1262,8 +1262,6 @@ void DepsgraphRelationBuilder::build_world(World *world)
}
build_animdata(&world->id);
/* TODO: other settings? */
- /* textures */
- build_texture_stack(world->mtex);
/* world's nodetree */
if (world->nodetree != NULL) {
build_nodetree(world->nodetree);
@@ -1815,8 +1813,6 @@ void DepsgraphRelationBuilder::build_lamp(Object *object)
ComponentKey nodetree_key(&lamp->nodetree->id, DEG_NODE_TYPE_SHADING);
add_relation(nodetree_key, lamp_parameters_key, "NTree->Lamp Parameters");
}
- /* textures */
- build_texture_stack(lamp->mtex);
if (DEG_depsgraph_use_copy_on_write()) {
/* Make sure copy on write of lamp data is always properly updated for
@@ -1898,8 +1894,6 @@ void DepsgraphRelationBuilder::build_material(Material *material)
}
/* animation */
build_animdata(&material->id);
- /* textures */
- build_texture_stack(material->mtex);
/* material's nodetree */
if (material->nodetree != NULL) {
build_nodetree(material->nodetree);
@@ -1925,17 +1919,6 @@ void DepsgraphRelationBuilder::build_texture(Tex *texture)
build_nodetree(texture->nodetree);
}
-/* Texture-stack attached to some shading datablock */
-void DepsgraphRelationBuilder::build_texture_stack(MTex **texture_stack)
-{
- /* for now assume that all texture-stacks have same number of max items */
- for (int i = 0; i < MAX_MTEX; i++) {
- MTex *mtex = texture_stack[i];
- if (mtex && mtex->tex)
- build_texture(mtex->tex);
- }
-}
-
void DepsgraphRelationBuilder::build_compositor(Scene *scene)
{
/* For now, just a plain wrapper? */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 4ddad462a5a..cfad5930ff8 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -244,7 +244,6 @@ struct DepsgraphRelationBuilder
void build_nodetree(bNodeTree *ntree);
void build_material(Material *ma);
void build_texture(Tex *tex);
- void build_texture_stack(MTex **texture_stack);
void build_compositor(Scene *scene);
void build_gpencil(bGPdata *gpd);
void build_cachefile(CacheFile *cache_file);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
index 85f465efb82..c97fa3b3a5a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
@@ -126,9 +126,6 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_la
ViewLayer *set_view_layer = BKE_view_layer_from_scene_get(scene->set);
build_view_layer(scene->set, set_view_layer);
}
-
- BLI_assert(graph_->scene == scene);
- BLI_assert(graph_->view_layer == view_layer);
}
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index c7f53b51374..ecd3d5361f8 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -206,6 +206,9 @@ void DEG_graph_build_from_view_layer(Depsgraph *graph,
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1);
+ BLI_assert(deg_graph->scene == scene);
+ BLI_assert(deg_graph->view_layer == view_layer);
+
/* TODO(sergey): This is a bit tricky, but ensures that all the data
* is evaluated properly when depsgraph is becoming "visible".
*
@@ -272,6 +275,19 @@ void DEG_graph_tag_relations_update(Depsgraph *graph)
{
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
deg_graph->need_update = true;
+ /* NOTE: When relations are updated, it's quite possible that
+ * we've got new bases in the scene. This means, we need to
+ * re-create flat array of bases in view layer.
+ *
+ * TODO(sergey): Try to make it so we don't flush updates
+ * to the whole depsgraph.
+ */
+ {
+ DEG::IDDepsNode *id_node = deg_graph->find_id_node(&deg_graph->scene->id);
+ if (id_node != NULL) {
+ id_node->tag_update(deg_graph);
+ }
+ }
}
/* Create or update relations in the specified graph. */
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc
index ac92d440bbe..edb6600f3e0 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -55,76 +55,6 @@ extern "C" {
#include "intern/depsgraph.h"
-/* ****************** */
-/* Evaluation Context */
-
-/* Create new evaluation context. */
-EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode)
-{
- EvaluationContext *eval_ctx =
- (EvaluationContext *)MEM_callocN(sizeof(EvaluationContext),
- "EvaluationContext");
- DEG_evaluation_context_init(eval_ctx, mode);
- return eval_ctx;
-}
-
-/**
- * Initialize evaluation context.
- * Used by the areas which currently overrides the context or doesn't have
- * access to a proper one.
- */
-void DEG_evaluation_context_init(EvaluationContext *eval_ctx,
- eEvaluationMode mode)
-{
- eval_ctx->mode = mode;
-}
-
-void DEG_evaluation_context_init_from_scene(
- EvaluationContext *eval_ctx,
- Scene *scene,
- ViewLayer *view_layer,
- eEvaluationMode mode)
-{
- DEG_evaluation_context_init(eval_ctx, mode);
- eval_ctx->depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
- eval_ctx->view_layer = view_layer;
- eval_ctx->ctime = BKE_scene_frame_get(scene);
-}
-
-void DEG_evaluation_context_init_from_view_layer_for_render(
- EvaluationContext *eval_ctx,
- Depsgraph *depsgraph,
- Scene *scene,
- ViewLayer *view_layer)
-{
- /* ViewLayer may come from a copy of scene.viewlayers, we need to find the original though. */
- ViewLayer *view_layer_original = (ViewLayer *)BLI_findstring(&scene->view_layers, view_layer->name, offsetof(ViewLayer, name));
- BLI_assert(view_layer_original != NULL);
-
- DEG_evaluation_context_init(eval_ctx, DAG_EVAL_RENDER);
- eval_ctx->ctime = BKE_scene_frame_get(scene);
- eval_ctx->depsgraph = depsgraph;
- eval_ctx->view_layer = view_layer_original;
-}
-
-void DEG_evaluation_context_init_from_depsgraph(
- EvaluationContext *eval_ctx,
- Depsgraph *depsgraph,
- eEvaluationMode mode)
-{
- Scene *scene = DEG_get_evaluated_scene(depsgraph);
- DEG_evaluation_context_init(eval_ctx, mode);
- eval_ctx->ctime = (float)scene->r.cfra + scene->r.subframe;
- eval_ctx->depsgraph = depsgraph;
- eval_ctx->view_layer = DEG_get_evaluated_view_layer(depsgraph);
-}
-
-/* Free evaluation context. */
-void DEG_evaluation_context_free(EvaluationContext *eval_ctx)
-{
- MEM_freeN(eval_ctx);
-}
-
/* Evaluate all nodes tagged for updating. */
void DEG_evaluate_on_refresh(Depsgraph *graph)
{
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 6f0ba26c8f7..63eb1f18281 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -151,6 +151,9 @@ Object *DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
{
+ if (id == NULL) {
+ return NULL;
+ }
/* TODO(sergey): This is a duplicate of Depsgraph::get_cow_id(),
* but here we never do assert, since we don't know nature of the
* incoming ID datablock.
@@ -163,3 +166,19 @@ ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
return id_node->id_cow;
}
+Object *DEG_get_original_object(Object *object)
+{
+ return (Object *)DEG_get_original_id(&object->id);
+}
+
+ID *DEG_get_original_id(ID *id)
+{
+ if (id == NULL) {
+ return NULL;
+ }
+ if (id->orig_id == NULL) {
+ return id;
+ }
+ BLI_assert((id->tag & LIB_TAG_COPY_ON_WRITE) != 0);
+ return (ID *)id->orig_id;
+}
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
index 61f1ccdd2a0..c610e7fc500 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
@@ -187,7 +187,7 @@ static void DEG_iterator_objects_step(BLI_Iterator *iter, DEG::IDDepsNode *id_no
(object->transflag & OB_DUPLI))
{
data->dupli_parent = object;
- data->dupli_list = object_duplilist(&data->eval_ctx, data->scene, object);
+ data->dupli_list = object_duplilist(data->graph, data->scene, object);
data->dupli_object_next = (DupliObject *)data->dupli_list->first;
if (BKE_object_is_visible(object, (eObjectVisibilityCheck)data->visibility_check) == false) {
return;
@@ -209,13 +209,10 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
return;
}
- /* TODO(sergey): What evaluation type we want here? */
- /* TODO(dfelinto): Get rid of evaluation context here, it's only used to do
- * direct dupli-objects update in group.c. Which is terribly bad, and all
- * objects are expected to be evaluated already. */
- DEG_evaluation_context_init(&data->eval_ctx, DAG_EVAL_VIEWPORT);
- data->eval_ctx.depsgraph = depsgraph;
- data->eval_ctx.view_layer = DEG_get_evaluated_view_layer(depsgraph);
+ /* TODO: Calling this forces the scene datablock to be expanded,
+ * otherwise we get crashes on load with copy-on-write. There may
+ * be a better solution for this. */
+ DEG_get_evaluated_view_layer(depsgraph);
iter->data = data;
data->dupli_parent = NULL;
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 2091d597ffa..e2c813530e9 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -411,7 +411,7 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
}
deg_graph_id_tag_legacy_compat(bmain, id, (eDepsgraph_Tag)0);
}
- id->recalc |= flag;
+ id->recalc |= (flag & PSYS_RECALC);
int current_flag = flag;
while (current_flag != 0) {
eDepsgraph_Tag tag =
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index d6c410347f6..6d328b399e0 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -49,8 +49,8 @@ struct bAction;
struct ChannelDriver;
struct ModifierData;
struct PointerRNA;
-struct EvaluationContext;
struct FCurve;
+struct Depsgraph;
namespace DEG {
@@ -61,7 +61,7 @@ using std::max;
/* Evaluation Operation for atomic operation */
// XXX: move this to another header that can be exposed?
-typedef function<void(struct EvaluationContext *)> DepsEvalOperationCb;
+typedef function<void(struct ::Depsgraph *)> DepsEvalOperationCb;
/* Metatype of Nodes - The general "level" in the graph structure
* the node serves.
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index d40e3e85979..4dd3842070e 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -69,7 +69,6 @@ static void schedule_children(TaskPool *pool,
const int thread_id);
struct DepsgraphEvalState {
- EvaluationContext *eval_ctx;
Depsgraph *graph;
bool do_stats;
};
@@ -86,11 +85,11 @@ static void deg_task_run_func(TaskPool *pool,
/* Perform operation. */
if (state->do_stats) {
const double start_time = PIL_check_seconds_timer();
- node->evaluate(state->eval_ctx);
+ node->evaluate((::Depsgraph*)state->graph);
node->stats.current_time += PIL_check_seconds_timer() - start_time;
}
else {
- node->evaluate(state->eval_ctx);
+ node->evaluate((::Depsgraph*)state->graph);
}
/* Schedule children. */
BLI_task_pool_delayed_push_begin(pool, thread_id);
@@ -229,21 +228,20 @@ static void schedule_children(TaskPool *pool,
*/
void deg_evaluate_on_refresh(Depsgraph *graph)
{
- /* Set time for the current graph evaluation context. */
- TimeSourceDepsNode *time_src = graph->find_time_source();
/* Nothing to update, early out. */
if (BLI_gset_len(graph->entry_tags) == 0) {
return;
}
const bool do_time_debug = ((G.debug & G_DEBUG_DEPSGRAPH_TIME) != 0);
const double start_time = do_time_debug ? PIL_check_seconds_timer() : 0;
- /* Set up evaluation context. */
- EvaluationContext eval_ctx;
- DEG_evaluation_context_init_from_depsgraph(&eval_ctx, (::Depsgraph*)graph, graph->mode);
- eval_ctx.ctime = time_src->cfra;
+
+ /* TODO: Calling this forces the scene datablock to be expanded,
+ * otherwise we get crashes on load with copy-on-write. There may
+ * be a better solution for this. */
+ DEG_get_evaluated_view_layer((const ::Depsgraph*)graph);
+
/* Set up evaluation state. */
DepsgraphEvalState state;
- state.eval_ctx = &eval_ctx;
state.graph = graph;
state.do_stats = do_time_debug;
/* Set up task scheduler and pull for threaded evaluation. */
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.h b/source/blender/depsgraph/intern/eval/deg_eval.h
index 0fb60e8f779..a8f5f7c145f 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval.h
@@ -32,8 +32,6 @@
#pragma once
-struct EvaluationContext;
-
namespace DEG {
struct Depsgraph;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 1d2169f5ec4..f6a37c49d32 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -649,7 +649,9 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
* everything is done by node tree update function which
* only copies socket values.
*/
- const int ignore_flag = (ID_RECALC_DRAW | ID_RECALC_ANIMATION);
+ const int ignore_flag = (ID_RECALC_DRAW |
+ ID_RECALC_ANIMATION |
+ ID_RECALC_COPY_ON_WRITE);
if ((id_cow->recalc & ~ignore_flag) == 0) {
return id_cow;
}
@@ -781,10 +783,10 @@ void deg_free_copy_on_write_datablock(ID *id_cow)
id_cow->name[0] = '\0';
}
-void deg_evaluate_copy_on_write(const EvaluationContext * /*eval_ctx*/,
- const Depsgraph *depsgraph,
+void deg_evaluate_copy_on_write(struct ::Depsgraph *graph,
const IDDepsNode *id_node)
{
+ const DEG::Depsgraph *depsgraph = reinterpret_cast<const DEG::Depsgraph *>(graph);
DEBUG_PRINT("%s on %s\n", __func__, id_node->id_orig->name);
if (id_node->id_orig == &depsgraph->scene->id) {
/* NOTE: This is handled by eval_ctx setup routines, which
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
index a2b57cb7198..8fca90e9f5b 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
@@ -32,7 +32,6 @@
#include <stddef.h>
-struct EvaluationContext;
struct ID;
/* Unkomment this to have verbose log about original and CoW pointers
@@ -47,6 +46,8 @@ struct ID;
# define DEG_COW_PRINT(format, ...)
#endif
+struct Depsgraph;
+
namespace DEG {
struct Depsgraph;
@@ -79,8 +80,7 @@ void deg_free_copy_on_write_datablock(struct ID *id_cow);
/* Callback function for depsgraph operation node which ensures copy-on-write
* datablock is ready for use by further evaluation routines.
*/
-void deg_evaluate_copy_on_write(const struct EvaluationContext *eval_ctx,
- const struct Depsgraph *depsgraph,
+void deg_evaluate_copy_on_write(struct ::Depsgraph *depsgraph,
const struct IDDepsNode *id_node);
/* Check that given ID is propely expanded and does not have any shallow
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index f7f55610d22..60fde1e69ee 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -241,6 +241,10 @@ void flush_editors_id_update(Main *bmain,
/* Inform editors. */
if (deg_copy_on_write_is_expanded(id_cow)) {
deg_editors_id_update(update_ctx, id_cow);
+ /* ID may need to get its auto-override operations refreshed. */
+ if (ID_IS_STATIC_OVERRIDE_AUTO(id_orig)) {
+ id_orig->tag |= LIB_TAG_OVERRIDESTATIC_AUTOREFRESH;
+ }
/* Inform draw engines that something was changed. */
flush_engine_data_update(id_cow);
}
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index b8009cc0a7f..5b6461f950e 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -39,8 +39,6 @@ struct ID;
struct bPoseChannel;
struct GHash;
-struct EvaluationContext;
-
namespace DEG {
struct Depsgraph;
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 1529ee7022e..94b30e1eed3 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -84,6 +84,7 @@ set(SRC
modes/edit_surface_mode.c
modes/edit_text_mode.c
modes/object_mode.c
+ modes/overlay_mode.c
modes/paint_texture_mode.c
modes/paint_vertex_mode.c
modes/paint_weight_mode.c
@@ -108,6 +109,10 @@ set(SRC
engines/eevee/eevee_subsurface.c
engines/eevee/eevee_temporal_sampling.c
engines/eevee/eevee_volumes.c
+ engines/workbench/workbench_engine.c
+ engines/workbench/workbench_materials.c
+ engines/workbench/solid_flat_mode.c
+ engines/workbench/solid_studio_mode.c
engines/external/external_engine.c
DRW_engine.h
@@ -174,6 +179,7 @@ data_to_c_simple(engines/eevee/shaders/effect_dof_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_downsample_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_downsample_cube_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_gtao_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/effect_velocity_resolve_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_minmaxz_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_mist_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_motion_blur_frag.glsl SRC)
@@ -186,7 +192,6 @@ data_to_c_simple(engines/eevee/shaders/lightprobe_planar_downsample_vert.glsl SR
data_to_c_simple(engines/eevee/shaders/prepass_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/prepass_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_frag.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/shadow_geom.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_store_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_copy_frag.glsl SRC)
@@ -209,6 +214,12 @@ data_to_c_simple(engines/eevee/shaders/volumetric_resolve_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/volumetric_scatter_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/volumetric_integration_frag.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/solid_flat_frag.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/solid_studio_frag.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_diffuse_lib.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_vert.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_studio_vert.glsl SRC)
+
data_to_c_simple(modes/shaders/common_globals_lib.glsl SRC)
data_to_c_simple(modes/shaders/common_view_lib.glsl SRC)
data_to_c_simple(modes/shaders/common_fxaa_lib.glsl SRC)
@@ -232,11 +243,14 @@ data_to_c_simple(modes/shaders/edit_lattice_overlay_frag.glsl SRC)
data_to_c_simple(modes/shaders/edit_lattice_overlay_loosevert_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_normals_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_normals_geom.glsl SRC)
+data_to_c_simple(modes/shaders/overlay_face_orientation_frag.glsl SRC)
+data_to_c_simple(modes/shaders/overlay_face_orientation_vert.glsl SRC)
data_to_c_simple(modes/shaders/object_empty_image_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_empty_image_vert.glsl SRC)
data_to_c_simple(modes/shaders/object_outline_resolve_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_outline_expand_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_outline_detect_frag.glsl SRC)
+data_to_c_simple(modes/shaders/object_outline_prepass_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_grid_frag.glsl SRC)
data_to_c_simple(modes/shaders/object_grid_vert.glsl SRC)
data_to_c_simple(modes/shaders/object_lightprobe_grid_vert.glsl SRC)
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index 171b9111bac..2e0a0881928 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -31,6 +31,9 @@
#include "BKE_icons.h"
#include "BKE_idprop.h"
#include "BKE_main.h"
+#include "BKE_particle.h"
+
+#include "DNA_particle_types.h"
#include "GPU_shader.h"
@@ -81,6 +84,7 @@ typedef struct BASIC_PrivateData {
#ifdef USE_DEPTH
DRWShadingGroup *depth_shgrp;
DRWShadingGroup *depth_shgrp_cull;
+ DRWShadingGroup *depth_shgrp_hair;
#endif
DRWShadingGroup *color_shgrp;
} BASIC_PrivateData; /* Transient data */
@@ -115,7 +119,7 @@ static void basic_cache_init(void *vedata)
#ifdef USE_DEPTH
/* Depth Pass */
{
- psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+ psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WIRE);
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
psl->depth_pass_cull = DRW_pass_create(
@@ -139,6 +143,26 @@ static void basic_cache_populate(void *vedata, Object *ob)
if (!DRW_object_is_renderable(ob))
return;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+
+ if (ob != draw_ctx->object_edit) {
+ for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
+ if (psys_check_enabled(ob, psys, false)) {
+ ParticleSettings *part = psys->part;
+ int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
+
+ if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
+ draw_as = PART_DRAW_DOT;
+ }
+
+ if (draw_as == PART_DRAW_PATH) {
+ struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(psys, NULL);
+ DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL);
+ }
+ }
+ }
+ }
+
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
bool do_cull = false; /* TODO (we probably wan't to take this from the viewport?) */
diff --git a/source/blender/draw/engines/clay/clay_engine.c b/source/blender/draw/engines/clay/clay_engine.c
index 4976cd01d11..0b0549e0782 100644
--- a/source/blender/draw/engines/clay/clay_engine.c
+++ b/source/blender/draw/engines/clay/clay_engine.c
@@ -587,7 +587,7 @@ static DRWShadingGroup *CLAY_shgroup_deferred_shading_create(DRWPass *pass, CLAY
DRW_shgroup_uniform_block(grp, "material_block", sldata->mat_ubo);
DRW_shgroup_uniform_block(grp, "matcaps_block", sldata->matcaps_ubo);
/* TODO put in ubo */
- DRW_shgroup_uniform_mat4(grp, "WinMatrix", (float *)g_data->winmat);
+ DRW_shgroup_uniform_mat4(grp, "WinMatrix", g_data->winmat);
DRW_shgroup_uniform_vec2(grp, "invscreenres", DRW_viewport_invert_size_get(), 1);
DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)g_data->viewvecs, 3);
DRW_shgroup_uniform_vec4(grp, "ssao_params", g_data->ssao_params, 1);
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index 977eb14a1bb..ccb61d3e328 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -27,6 +27,10 @@
#include "DRW_render.h"
+#include "BKE_global.h" /* for G.debug_value */
+
+#include "BLI_string_utils.h"
+
#include "eevee_private.h"
#include "GPU_texture.h"
#include "GPU_extensions.h"
@@ -46,6 +50,9 @@ static struct {
struct GPUShader *downsample_sh;
struct GPUShader *downsample_cube_sh;
+ /* Velocity Resolve */
+ struct GPUShader *velocity_resolve_sh;
+
/* Theses are just references, not actually allocated */
struct GPUTexture *depth_src;
struct GPUTexture *color_src;
@@ -54,6 +61,10 @@ static struct {
float cube_texel_size;
} e_data = {NULL}; /* Engine data */
+extern char datatoc_common_uniforms_lib_glsl[];
+extern char datatoc_common_view_lib_glsl[];
+extern char datatoc_bsdf_common_lib_glsl[];
+extern char datatoc_effect_velocity_resolve_frag_glsl[];
extern char datatoc_effect_minmaxz_frag_glsl[];
extern char datatoc_effect_downsample_frag_glsl[];
extern char datatoc_effect_downsample_cube_frag_glsl[];
@@ -62,6 +73,16 @@ extern char datatoc_lightprobe_geom_glsl[];
static void eevee_create_shader_downsample(void)
{
+ char *frag_str = BLI_string_joinN(
+ datatoc_common_uniforms_lib_glsl,
+ datatoc_common_view_lib_glsl,
+ datatoc_bsdf_common_lib_glsl,
+ datatoc_effect_velocity_resolve_frag_glsl);
+
+ e_data.velocity_resolve_sh = DRW_shader_create_fullscreen(frag_str, NULL);
+
+ MEM_freeN(frag_str);
+
e_data.downsample_sh = DRW_shader_create_fullscreen(datatoc_effect_downsample_frag_glsl, NULL);
e_data.downsample_cube_sh = DRW_shader_create(
datatoc_lightprobe_vert_glsl,
@@ -110,6 +131,8 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
ViewLayer *view_layer = draw_ctx->view_layer;
const float *viewport_size = DRW_viewport_size_get();
+ int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]};
+
/* Shaders */
if (!e_data.downsample_sh) {
eevee_create_shader_downsample();
@@ -122,6 +145,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
effects = stl->effects;
effects->enabled_effects = 0;
+ effects->enabled_effects |= (G.debug_value == 9) ? EFFECT_VELOCITY_BUFFER : 0;
effects->enabled_effects |= EEVEE_motion_blur_init(sldata, vedata, camera);
effects->enabled_effects |= EEVEE_bloom_init(sldata, vedata);
effects->enabled_effects |= EEVEE_depth_of_field_init(sldata, vedata, camera);
@@ -163,9 +187,9 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
/**
* MinMax Pyramid
*/
- int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
- size[0] = max_ii(size[0] / 2, 1);
- size[1] = max_ii(size[1] / 2, 1);
+ int size[2];
+ size[0] = max_ii(size_fs[0] / 2, 1);
+ size[1] = max_ii(size_fs[1] / 2, 1);
if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) {
/* Intel gpu seems to have problem rendering to only depth format */
@@ -197,8 +221,6 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
* Normal buffer for deferred passes.
*/
if ((effects->enabled_effects & EFFECT_NORMAL_BUFFER) != 0) {
- int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]};
-
effects->ssr_normal_input = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], DRW_TEX_RG_16,
&draw_engine_eevee_type);
@@ -209,6 +231,42 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
}
/**
+ * Motion vector buffer for correct TAA / motion blur.
+ */
+ if ((effects->enabled_effects & EFFECT_VELOCITY_BUFFER) != 0) {
+ /* TODO use RG16_UNORM */
+ effects->velocity_tx = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], DRW_TEX_RG_32,
+ &draw_engine_eevee_type);
+
+ /* TODO output objects velocity during the mainpass. */
+ // GPU_framebuffer_texture_attach(fbl->main_fb, effects->velocity_tx, 1, 0);
+
+ GPU_framebuffer_ensure_config(&fbl->velocity_resolve_fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE(effects->velocity_tx)
+ });
+ }
+ else {
+ effects->velocity_tx = NULL;
+ }
+
+ /**
+ * Setup depth double buffer.
+ */
+ if ((effects->enabled_effects & EFFECT_DEPTH_DOUBLE_BUFFER) != 0) {
+ DRW_texture_ensure_fullscreen_2D(&txl->depth_double_buffer, DRW_TEX_DEPTH_24_STENCIL_8, 0);
+
+ GPU_framebuffer_ensure_config(&fbl->double_buffer_depth_fb, {
+ GPU_ATTACHMENT_TEXTURE(txl->depth_double_buffer)
+ });
+ }
+ else {
+ /* Cleanup to release memory */
+ DRW_TEXTURE_FREE_SAFE(txl->depth_double_buffer);
+ GPU_FRAMEBUFFER_FREE_SAFE(fbl->double_buffer_depth_fb);
+ }
+
+ /**
* Setup double buffer so we can access last frame as it was before post processes.
*/
if ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0) {
@@ -235,6 +293,8 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_EffectsInfo *effects = stl->effects;
int downsample_write = DRW_STATE_WRITE_DEPTH;
/* Intel gpu seems to have problem rendering to only depth format.
@@ -291,6 +351,17 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &e_data.depth_src);
DRW_shgroup_call_add(grp, quad, NULL);
}
+
+ if ((effects->enabled_effects & EFFECT_VELOCITY_BUFFER) != 0) {
+ /* This pass compute camera motions to the non moving objects. */
+ psl->velocity_resolve = DRW_pass_create("Velocity Resolve", DRW_STATE_WRITE_COLOR);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.velocity_resolve_sh, psl->velocity_resolve);
+ DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &e_data.depth_src);
+ DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
+ DRW_shgroup_uniform_mat4(grp, "currPersinv", effects->velocity_curr_persinv);
+ DRW_shgroup_uniform_mat4(grp, "pastPersmat", effects->velocity_past_persmat);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
}
#if 0 /* Not required for now */
@@ -401,11 +472,21 @@ void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, GPUTexture *texture_src, i
void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
{
+ EEVEE_PassList *psl = vedata->psl;
EEVEE_TextureList *txl = vedata->txl;
EEVEE_FramebufferList *fbl = vedata->fbl;
EEVEE_StorageList *stl = vedata->stl;
EEVEE_EffectsInfo *effects = stl->effects;
+ /* First resolve the velocity. */
+ if ((effects->enabled_effects & EFFECT_VELOCITY_BUFFER) != 0) {
+ DRW_viewport_matrix_get(effects->velocity_curr_persinv, DRW_MAT_PERSINV);
+
+ GPU_framebuffer_bind(fbl->velocity_resolve_fb);
+ DRW_draw_pass(psl->velocity_resolve);
+ }
+ DRW_viewport_matrix_get(effects->velocity_past_persmat, DRW_MAT_PERS);
+
/* only once per frame after the first post process */
effects->swap_double_buffer = ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0);
@@ -423,7 +504,7 @@ void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
/* Save the final texture and framebuffer for final transformation or read. */
effects->final_tx = effects->source_buffer;
- effects->final_fb = (effects->target_buffer != fbl->main_fb) ? fbl->main_fb : fbl->effect_fb;
+ effects->final_fb = (effects->target_buffer != fbl->main_color_fb) ? fbl->main_fb : fbl->effect_fb;
/* If no post processes is enabled, buffers are still not swapped, do it now. */
SWAP_DOUBLE_BUFFERS();
@@ -448,6 +529,8 @@ void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
void EEVEE_effects_free(void)
{
+ DRW_SHADER_FREE_SAFE(e_data.velocity_resolve_sh);
+
DRW_SHADER_FREE_SAFE(e_data.downsample_sh);
DRW_SHADER_FREE_SAFE(e_data.downsample_cube_sh);
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 276f23c7cf7..2c459f5ae3b 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -204,12 +204,18 @@ static void eevee_draw_background(void *vedata)
double offset[3] = {0.0, 0.0, 0.0};
double r[3];
+ bool taa_use_reprojection = (stl->effects->enabled_effects & EFFECT_TAA_REPROJECT) != 0;
+
if (DRW_state_is_image_render() ||
+ taa_use_reprojection ||
((stl->effects->enabled_effects & EFFECT_TAA) != 0))
{
- BLI_halton_3D(primes, offset, stl->effects->taa_current_sample, r);
+ int samp = taa_use_reprojection
+ ? stl->effects->taa_reproject_sample + 1
+ : stl->effects->taa_current_sample;
+ BLI_halton_3D(primes, offset, samp, r);
EEVEE_update_noise(psl, fbl, r);
- EEVEE_volumes_set_jitter(sldata, stl->effects->taa_current_sample - 1);
+ EEVEE_volumes_set_jitter(sldata, samp - 1);
EEVEE_materials_init(sldata, stl, fbl);
}
/* Copy previous persmat to UBO data */
@@ -217,7 +223,8 @@ static void eevee_draw_background(void *vedata)
if (((stl->effects->enabled_effects & EFFECT_TAA) != 0) &&
(stl->effects->taa_current_sample > 1) &&
- !DRW_state_is_image_render())
+ !DRW_state_is_image_render() &&
+ !taa_use_reprojection)
{
DRW_viewport_matrix_override_set(stl->effects->overide_persmat, DRW_MAT_PERS);
DRW_viewport_matrix_override_set(stl->effects->overide_persinv, DRW_MAT_PERSINV);
@@ -333,6 +340,9 @@ static void eevee_draw_background(void *vedata)
case 8:
if (effects->sss_data) DRW_transform_to_display(effects->sss_data);
break;
+ case 9:
+ if (effects->velocity_tx) DRW_transform_to_display(effects->velocity_tx);
+ break;
default:
break;
}
@@ -434,6 +444,7 @@ static void eevee_view_layer_settings_create(RenderEngine *UNUSED(engine), IDPro
BKE_collection_engine_property_add_int(props, "taa_samples", 16);
BKE_collection_engine_property_add_int(props, "taa_render_samples", 64);
+ BKE_collection_engine_property_add_bool(props, "taa_reprojection", true);
BKE_collection_engine_property_add_bool(props, "sss_enable", false);
BKE_collection_engine_property_add_int(props, "sss_samples", 7);
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index 7496142a26e..86c9b9c850b 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -44,7 +44,6 @@ static struct {
} e_data = {NULL}; /* Engine data */
extern char datatoc_shadow_vert_glsl[];
-extern char datatoc_shadow_geom_glsl[];
extern char datatoc_shadow_frag_glsl[];
extern char datatoc_shadow_store_frag_glsl[];
extern char datatoc_shadow_copy_frag_glsl[];
@@ -106,7 +105,7 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata)
if (!e_data.shadow_sh) {
e_data.shadow_sh = DRW_shader_create(
- datatoc_shadow_vert_glsl, datatoc_shadow_geom_glsl, datatoc_shadow_frag_glsl, NULL);
+ datatoc_shadow_vert_glsl, NULL, datatoc_shadow_frag_glsl, NULL);
}
if (!sldata->lamps) {
@@ -287,8 +286,7 @@ void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
psl->shadow_pass = DRW_pass_create("Shadow Pass", state);
- DRWShadingGroup *grp = stl->g_data->shadow_shgrp = DRW_shgroup_create(e_data.shadow_sh, psl->shadow_pass);
- DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
+ stl->g_data->shadow_shgrp = DRW_shgroup_create(e_data.shadow_sh, psl->shadow_pass);
}
}
@@ -387,30 +385,26 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob)
/* Add a shadow caster to the shadowpasses */
void EEVEE_lights_cache_shcaster_add(
- EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob)
+ EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob)
{
- DRW_shgroup_call_object_instances_add(
+ DRW_shgroup_call_object_add(
stl->g_data->shadow_shgrp,
- geom, ob,
- &sldata->lamps->shadow_instance_count);
+ geom, ob);
}
void EEVEE_lights_cache_shcaster_material_add(
- EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl, struct GPUMaterial *gpumat,
- struct Gwn_Batch *geom, struct Object *ob, float (*obmat)[4], float *alpha_threshold)
+ EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_PassList *psl, struct GPUMaterial *gpumat,
+ struct Gwn_Batch *geom, struct Object *ob, float *alpha_threshold)
{
/* TODO / PERF : reuse the same shading group for objects with the same material */
DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, psl->shadow_pass);
if (grp == NULL) return;
- DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
- DRW_shgroup_uniform_mat4(grp, "ShadowModelMatrix", (float *)obmat);
-
if (alpha_threshold != NULL)
DRW_shgroup_uniform_float(grp, "alphaThreshold", alpha_threshold, 1);
- DRW_shgroup_call_object_instances_add(grp, geom, ob, &sldata->lamps->shadow_instance_count);
+ DRW_shgroup_call_object_add(grp, geom, ob);
}
/* Make that object update shadow casting lamps inside its influence bounding box. */
@@ -719,7 +713,6 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE
}
/* Lamps Matrices */
- float (*viewmat)[4], projmat[4][4];
int sh_nbr = 1; /* TODO : MSM */
int cascade_nbr = la->cascade_count;
@@ -730,10 +723,10 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE
/* obmat = Object Space > World Space */
/* viewmat = World Space > View Space */
- invert_m4_m4(sh_data->clipmat.mat[DRW_MAT_VIEW], ob->obmat);
- viewmat = sh_data->clipmat.mat[DRW_MAT_VIEW];
+ float (*viewmat)[4] = sh_data->viewmat;
+ invert_m4_m4(viewmat, ob->obmat);
normalize_m4(viewmat);
- invert_m4_m4(sh_data->clipmat.mat[DRW_MAT_VIEWINV], viewmat);
+ invert_m4_m4(sh_data->viewinv, viewmat);
/* The technique consists into splitting
* the view frustum into several sub-frustum
@@ -833,8 +826,8 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE
cascade_data->split_start[0] = LERP(la->cascade_fade, cascade_data->split_end[cascade_nbr - 1], prev_split);
/* For each cascade */
- rctf rect_clip, rect_cascade;
for (int c = 0; c < cascade_nbr; ++c) {
+ float (*projmat)[4] = sh_data->projmat[c];
/* Given 8 frustum corners */
float corners[8][3] = {
/* Near Cap */
@@ -877,32 +870,17 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE
add_v2_v2(center, shadow_texco);
/* Expand the projection to cover frustum range */
+ rctf rect_cascade;
BLI_rctf_init_pt_radius(&rect_cascade, center, sh_data->radius[c]);
orthographic_m4(projmat,
rect_cascade.xmin, rect_cascade.xmax,
rect_cascade.ymin, rect_cascade.ymax,
la->clipsta, la->clipend);
- if (c == 0) {
- memcpy(&rect_clip, &rect_cascade, sizeof(rect_clip));
- }
- else {
- BLI_rctf_union(&rect_clip, &rect_cascade);
- }
-
mul_m4_m4m4(sh_data->viewprojmat[c], projmat, viewmat);
mul_m4_m4m4(cascade_data->shadowmat[c], texcomat, sh_data->viewprojmat[c]);
}
- /* Clipping mats */
- orthographic_m4(sh_data->clipmat.mat[DRW_MAT_WIN],
- rect_clip.xmin, rect_clip.xmax,
- rect_clip.ymin, rect_clip.ymax,
- la->clipsta, la->clipend);
- mul_m4_m4m4(sh_data->clipmat.mat[DRW_MAT_PERS], sh_data->clipmat.mat[DRW_MAT_WIN], viewmat);
- invert_m4_m4(sh_data->clipmat.mat[DRW_MAT_WININV], sh_data->clipmat.mat[DRW_MAT_WIN]);
- invert_m4_m4(sh_data->clipmat.mat[DRW_MAT_PERSINV], sh_data->clipmat.mat[DRW_MAT_PERS]);
-
ubo_data->bias = 0.05f * la->bias;
ubo_data->near = la->clipsta;
ubo_data->far = la->clipend;
@@ -1004,37 +982,6 @@ void EEVEE_lights_update(EEVEE_ViewLayerData *sldata)
}
}
-static void eevee_shadows_cube_culling_frustum(EEVEE_ShadowRender *srd)
-{
- float persmat[4][4], persinv[4][4];
- float viewmat[4][4], viewinv[4][4];
- float winmat[4][4], wininv[4][4];
- orthographic_m4(winmat, -srd->clip_far, srd->clip_far, -srd->clip_far, srd->clip_far, -srd->clip_far, srd->clip_far);
- DRW_viewport_matrix_override_set(winmat, DRW_MAT_WIN);
-
- invert_m4_m4(wininv, winmat);
- DRW_viewport_matrix_override_set(wininv, DRW_MAT_WININV);
-
- unit_m4(viewmat);
- negate_v3_v3(viewmat[3], srd->position);
- DRW_viewport_matrix_override_set(viewmat, DRW_MAT_VIEW);
-
- unit_m4(viewinv);
- copy_v3_v3(viewinv[3], srd->position);
- DRW_viewport_matrix_override_set(viewinv, DRW_MAT_VIEWINV);
-
- mul_m4_m4m4(persmat, winmat, viewmat);
- DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS);
-
- invert_m4_m4(persinv, persmat);
- DRW_viewport_matrix_override_set(persinv, DRW_MAT_PERSINV);
-}
-
-static void eevee_shadows_cascade_culling_frustum(EEVEE_ShadowCascadeData *evscd)
-{
- DRW_viewport_matrix_override_set_all(&evscd->clipmat);
-}
-
/* this refresh lamps shadow buffers */
void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
{
@@ -1058,32 +1005,45 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
continue;
}
+ DRWMatrixState render_mats;
+ float (*winmat)[4] = render_mats.mat[DRW_MAT_WIN];
+ float (*viewmat)[4] = render_mats.mat[DRW_MAT_VIEW];
+ float (*persmat)[4] = render_mats.mat[DRW_MAT_PERS];
+
EEVEE_ShadowRender *srd = &linfo->shadow_render_data;
EEVEE_ShadowCubeData *evscd = &led->data.scd;
- float cube_projmat[4][4];
- float cube_viewmat[4][4];
- perspective_m4(cube_projmat, -la->clipsta, la->clipsta, -la->clipsta, la->clipsta, la->clipsta, la->clipend);
- unit_m4(cube_viewmat);
+ perspective_m4(winmat, -la->clipsta, la->clipsta, -la->clipsta, la->clipsta, la->clipsta, la->clipend);
srd->clip_near = la->clipsta;
srd->clip_far = la->clipend;
copy_v3_v3(srd->position, ob->obmat[3]);
- negate_v3_v3(cube_viewmat[3], srd->position);
- for (int j = 0; j < 6; j++) {
- mul_m4_m4m4(srd->viewmat[j], cubefacemat[j], cube_viewmat);
- mul_m4_m4m4(srd->shadowmat[j], cube_projmat, srd->viewmat[j]);
- }
DRW_uniformbuffer_update(sldata->shadow_render_ubo, srd);
- eevee_shadows_cube_culling_frustum(srd);
-
/* Render shadow cube */
- linfo->shadow_instance_count = 6;
- GPU_framebuffer_bind(sldata->shadow_cube_target_fb);
- GPU_framebuffer_clear_depth(sldata->shadow_cube_target_fb, 1.0f);
- DRW_draw_pass(psl->shadow_pass);
+ /* Render 6 faces separatly: seems to be faster for the general case.
+ * The only time it's more beneficial is when the CPU culling overhead
+ * outweight the instancing overhead. which is rarelly the case. */
+ for (int j = 0; j < 6; j++) {
+ /* TODO optimize */
+ float tmp[4][4];
+ unit_m4(tmp);
+ negate_v3_v3(tmp[3], srd->position);
+ mul_m4_m4m4(viewmat, cubefacemat[j], tmp);
+ mul_m4_m4m4(persmat, winmat, viewmat);
+ invert_m4_m4(render_mats.mat[DRW_MAT_WININV], winmat);
+ invert_m4_m4(render_mats.mat[DRW_MAT_VIEWINV], viewmat);
+ invert_m4_m4(render_mats.mat[DRW_MAT_PERSINV], persmat);
+
+ DRW_viewport_matrix_override_set_all(&render_mats);
+
+ GPU_framebuffer_texture_cubeface_attach(sldata->shadow_cube_target_fb,
+ sldata->shadow_cube_target, 0, j, 0);
+ GPU_framebuffer_bind(sldata->shadow_cube_target_fb);
+ GPU_framebuffer_clear_depth(sldata->shadow_cube_target_fb, 1.0f);
+ DRW_draw_pass(psl->shadow_pass);
+ }
/* 0.001f is arbitrary, but it should be relatively small so that filter size is not too big. */
float filter_texture_size = la->soft * 0.001f;
@@ -1143,22 +1103,39 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl)
EEVEE_ShadowCascadeData *evscd = &led->data.scad;
EEVEE_ShadowRender *srd = &linfo->shadow_render_data;
+ DRWMatrixState render_mats;
+ float (*winmat)[4] = render_mats.mat[DRW_MAT_WIN];
+ float (*viewmat)[4] = render_mats.mat[DRW_MAT_VIEW];
+ float (*persmat)[4] = render_mats.mat[DRW_MAT_PERS];
+
eevee_shadow_cascade_setup(ob, linfo, led);
srd->clip_near = la->clipsta;
srd->clip_far = la->clipend;
- for (int j = 0; j < la->cascade_count; ++j) {
- copy_m4_m4(srd->shadowmat[j], evscd->viewprojmat[j]);
- }
+
DRW_uniformbuffer_update(sldata->shadow_render_ubo, &linfo->shadow_render_data);
- eevee_shadows_cascade_culling_frustum(evscd);
+ copy_m4_m4(viewmat, evscd->viewmat);
+ invert_m4_m4(render_mats.mat[DRW_MAT_VIEWINV], viewmat);
/* Render shadow cascades */
- linfo->shadow_instance_count = la->cascade_count;
- GPU_framebuffer_bind(sldata->shadow_cascade_target_fb);
- GPU_framebuffer_clear_depth(sldata->shadow_cascade_target_fb, 1.0);
- DRW_draw_pass(psl->shadow_pass);
+ /* Render cascade separatly: seems to be faster for the general case.
+ * The only time it's more beneficial is when the CPU culling overhead
+ * outweight the instancing overhead. which is rarelly the case. */
+ for (int j = 0; j < la->cascade_count; j++) {
+ copy_m4_m4(winmat, evscd->projmat[j]);
+ copy_m4_m4(persmat, evscd->viewprojmat[j]);
+ invert_m4_m4(render_mats.mat[DRW_MAT_WININV], winmat);
+ invert_m4_m4(render_mats.mat[DRW_MAT_PERSINV], persmat);
+
+ DRW_viewport_matrix_override_set_all(&render_mats);
+
+ GPU_framebuffer_texture_layer_attach(sldata->shadow_cascade_target_fb,
+ sldata->shadow_cascade_target, 0, j, 0);
+ GPU_framebuffer_bind(sldata->shadow_cascade_target_fb);
+ GPU_framebuffer_clear_depth(sldata->shadow_cascade_target_fb, 1.0f);
+ DRW_draw_pass(psl->shadow_pass);
+ }
/* TODO: OPTI: Filter all cascade in one/two draw call */
for (linfo->current_shadow_cascade = 0;
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index d146fda5373..33ea7c4b1e7 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -52,7 +52,6 @@
/* *********** STATIC *********** */
static struct {
- char *shadow_shader_lib;
char *frag_shader_lib;
char *volume_shader_lib;
@@ -97,7 +96,6 @@ extern char datatoc_lit_surface_vert_glsl[];
extern char datatoc_raytrace_lib_glsl[];
extern char datatoc_ssr_lib_glsl[];
extern char datatoc_shadow_vert_glsl[];
-extern char datatoc_shadow_geom_glsl[];
extern char datatoc_lightprobe_geom_glsl[];
extern char datatoc_lightprobe_vert_glsl[];
extern char datatoc_background_vert_glsl[];
@@ -467,7 +465,7 @@ static void eevee_init_util_texture(void)
/* Copy blue noise in 3rd layer */
for (int i = 0; i < 64 * 64; i++) {
texels_layer[i][0] = blue_noise[i][0];
- texels_layer[i][1] = blue_noise[i][1];
+ texels_layer[i][1] = blue_noise[i][2];
texels_layer[i][2] = cosf(blue_noise[i][1] * 2.0f * M_PI);
texels_layer[i][3] = sinf(blue_noise[i][1] * 2.0f * M_PI);
}
@@ -546,7 +544,8 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, E
{
if (!e_data.frag_shader_lib) {
/* Shaders */
- e_data.shadow_shader_lib = BLI_string_joinN(
+ e_data.frag_shader_lib = BLI_string_joinN(
+ datatoc_common_view_lib_glsl,
datatoc_common_uniforms_lib_glsl,
datatoc_bsdf_common_lib_glsl,
datatoc_bsdf_sampling_lib_glsl,
@@ -570,10 +569,6 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, E
datatoc_lit_surface_frag_glsl,
datatoc_volumetric_lib_glsl);
- e_data.frag_shader_lib = BLI_string_joinN(
- datatoc_common_view_lib_glsl,
- e_data.shadow_shader_lib);
-
e_data.volume_shader_lib = BLI_string_joinN(
datatoc_common_view_lib_glsl,
datatoc_common_uniforms_lib_glsl,
@@ -792,13 +787,13 @@ struct GPUMaterial *EEVEE_material_mesh_depth_get(
char *defines = eevee_get_defines(options);
char *frag_str = BLI_string_joinN(
- (is_shadow) ? e_data.shadow_shader_lib : e_data.frag_shader_lib,
+ e_data.frag_shader_lib,
datatoc_prepass_frag_glsl);
mat = DRW_shader_create_from_material(
scene, ma, engine, options,
(is_shadow) ? datatoc_shadow_vert_glsl : datatoc_lit_surface_vert_glsl,
- (is_shadow) ? datatoc_shadow_geom_glsl : NULL,
+ NULL,
frag_str,
defines);
@@ -1634,11 +1629,11 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
break;
case MA_BS_CLIP:
gpumat = EEVEE_material_mesh_depth_get(scene, ma, false, true);
- EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, ob->obmat, &ma->alpha_threshold);
+ EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, &ma->alpha_threshold);
break;
case MA_BS_HASHED:
gpumat = EEVEE_material_mesh_depth_get(scene, ma, true, true);
- EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, ob->obmat, NULL);
+ EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, NULL);
break;
case MA_BS_NONE:
default:
@@ -1690,7 +1685,7 @@ void EEVEE_materials_free(void)
for (int i = 0; i < VAR_MAT_MAX; ++i) {
DRW_SHADER_FREE_SAFE(e_data.default_lit[i]);
}
- MEM_SAFE_FREE(e_data.shadow_shader_lib);
+ MEM_SAFE_FREE(e_data.frag_shader_lib);
MEM_SAFE_FREE(e_data.frag_shader_lib);
MEM_SAFE_FREE(e_data.volume_shader_lib);
DRW_SHADER_FREE_SAFE(e_data.default_prepass_sh);
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 9b19163c8d7..31f3986a1fb 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -68,16 +68,13 @@ static void eevee_motion_blur_camera_get_matrix_at_time(
cam_cpy.data = &camdata_cpy;
const DRWContextState *draw_ctx = DRW_context_state_get();
- /* We will be modifying time, so we create copy of eval_ctx. */
- EvaluationContext eval_ctx = draw_ctx->eval_ctx;
- eval_ctx.ctime = time;
/* Past matrix */
/* FIXME : This is a temporal solution that does not take care of parent animations */
/* Recalc Anim manualy */
BKE_animsys_evaluate_animdata(scene, &cam_cpy.id, cam_cpy.adt, time, ADT_RECALC_ALL);
BKE_animsys_evaluate_animdata(scene, &camdata_cpy.id, camdata_cpy.adt, time, ADT_RECALC_ALL);
- BKE_object_where_is_calc_time(&eval_ctx, scene, &cam_cpy, time);
+ BKE_object_where_is_calc_time(draw_ctx->depsgraph, scene, &cam_cpy, time);
/* Compute winmat */
CameraParams params;
@@ -188,8 +185,8 @@ void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
DRWShadingGroup *grp = DRW_shgroup_create(e_data.motion_blur_sh, psl->motion_blur);
DRW_shgroup_uniform_int(grp, "samples", &effects->motion_blur_samples, 1);
- DRW_shgroup_uniform_mat4(grp, "currInvViewProjMatrix", (float *)effects->current_ndc_to_world);
- DRW_shgroup_uniform_mat4(grp, "pastViewProjMatrix", (float *)effects->past_world_to_ndc);
+ DRW_shgroup_uniform_mat4(grp, "currInvViewProjMatrix", effects->current_ndc_to_world);
+ DRW_shgroup_uniform_mat4(grp, "pastViewProjMatrix", effects->past_world_to_ndc);
DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &effects->source_buffer);
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
DRW_shgroup_call_add(grp, quad, NULL);
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index d203fadc073..5947def7a88 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -185,6 +185,7 @@ typedef struct EEVEE_PassList {
struct DRWPass *sss_accum_ps;
struct DRWPass *color_downsample_ps;
struct DRWPass *color_downsample_cube_ps;
+ struct DRWPass *velocity_resolve;
struct DRWPass *taa_resolve;
/* HiZ */
@@ -236,6 +237,7 @@ typedef struct EEVEE_FramebufferList {
struct GPUFrameBuffer *refract_fb;
struct GPUFrameBuffer *mist_accum_fb;
struct GPUFrameBuffer *ao_accum_fb;
+ struct GPUFrameBuffer *velocity_resolve_fb;
struct GPUFrameBuffer *update_noise_fb;
@@ -313,8 +315,6 @@ typedef struct EEVEE_ShadowCascade {
} EEVEE_ShadowCascade;
typedef struct EEVEE_ShadowRender {
- float shadowmat[6][4][4]; /* World->Lamp->NDC : used to render the shadow map. 6 frustum for cubemap shadow */
- float viewmat[6][4][4]; /* World->Lamp : used to render the shadow map. 6 viewmat for cubemap shadow */
float position[3], pad;
float cube_texel_size;
float stored_texel_size;
@@ -483,6 +483,9 @@ typedef enum EEVEE_EffectsFlag {
EFFECT_POST_BUFFER = (1 << 9), /* Not really an effect but a feature */
EFFECT_NORMAL_BUFFER = (1 << 10), /* Not really an effect but a feature */
EFFECT_SSS = (1 << 11),
+ EFFECT_VELOCITY_BUFFER = (1 << 12), /* Not really an effect but a feature */
+ EFFECT_TAA_REPROJECT = (1 << 13), /* should be mutually exclusive with EFFECT_TAA */
+ EFFECT_DEPTH_DOUBLE_BUFFER = (1 << 14), /* Not really an effect but a feature */
} EEVEE_EffectsFlag;
typedef struct EEVEE_EffectsInfo {
@@ -506,6 +509,7 @@ typedef struct EEVEE_EffectsInfo {
struct GPUTexture *ssr_hit_output;
struct GPUTexture *ssr_pdf_output;
/* Temporal Anti Aliasing */
+ int taa_reproject_sample;
int taa_current_sample;
int taa_render_sample;
int taa_total_sample;
@@ -525,6 +529,10 @@ typedef struct EEVEE_EffectsInfo {
float current_ndc_to_world[4][4];
float past_world_to_ndc[4][4];
int motion_blur_samples;
+ /* Velocity Pass */
+ float velocity_curr_persinv[4][4];
+ float velocity_past_persmat[4][4];
+ struct GPUTexture *velocity_tx; /* Texture from pool */
/* Depth Of Field */
float dof_near_far[2];
float dof_params[3];
@@ -676,7 +684,8 @@ typedef struct EEVEE_ShadowCubeData {
typedef struct EEVEE_ShadowCascadeData {
short light_id, shadow_id, cascade_id, layer_id;
float viewprojmat[MAX_CASCADE_NUM][4][4]; /* World->Lamp->NDC : used for rendering the shadow map. */
- DRWMatrixState clipmat; /* Override matrices used for clipping. */
+ float projmat[MAX_CASCADE_NUM][4][4];
+ float viewmat[4][4], viewinv[4][4];
float radius[MAX_CASCADE_NUM];
} EEVEE_ShadowCascadeData;
@@ -811,7 +820,7 @@ void EEVEE_lights_cache_shcaster_add(
void EEVEE_lights_cache_shcaster_material_add(
EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl,
struct GPUMaterial *gpumat, struct Gwn_Batch *geom, struct Object *ob,
- float (*obmat)[4], float *alpha_threshold);
+ float *alpha_threshold);
void EEVEE_lights_cache_shcaster_object_add(EEVEE_ViewLayerData *sldata, struct Object *ob);
void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata);
void EEVEE_lights_update(EEVEE_ViewLayerData *sldata);
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c
index 130999adb39..6d9824f7ca9 100644
--- a/source/blender/draw/engines/eevee/eevee_render.c
+++ b/source/blender/draw/engines/eevee/eevee_render.c
@@ -256,8 +256,8 @@ static void eevee_render_result_normal(
}
float fenc[2];
- fenc[0] = rp->rect[i+0] * 4.0f - 2.0f;
- fenc[1] = rp->rect[i+1] * 4.0f - 2.0f;
+ fenc[0] = rp->rect[i + 0] * 4.0f - 2.0f;
+ fenc[1] = rp->rect[i + 1] * 4.0f - 2.0f;
float f = dot_v2v2(fenc, fenc);
float g = sqrtf(1.0f - f / 4.0f);
@@ -288,6 +288,7 @@ static void eevee_render_result_z(
if ((view_layer->passflag & SCE_PASS_Z) != 0) {
RenderPass *rp = RE_pass_find_by_name(rl, RE_PASSNAME_Z, viewname);
+ GPU_framebuffer_bind(vedata->fbl->main_fb);
GPU_framebuffer_read_depth(vedata->fbl->main_fb,
rect->xmin, rect->ymin,
BLI_rcti_size_x(rect), BLI_rcti_size_y(rect),
@@ -359,7 +360,7 @@ static void eevee_render_result_occlusion(
/* This is the accumulated color. Divide by the number of samples. */
for (int i = 0; i < rp->rectx * rp->recty * 3; i += 3) {
- rp->rect[i] = rp->rect[i + 1] = rp->rect[i+2] = min_ff(1.0f, rp->rect[i] / (float)render_samples);
+ rp->rect[i] = rp->rect[i + 1] = rp->rect[i + 2] = min_ff(1.0f, rp->rect[i] / (float)render_samples);
}
}
}
@@ -482,7 +483,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
char info[42];
- BLI_snprintf(info, sizeof(info), "Rendering %u / %u samples", render_samples+1, tot_sample);
+ BLI_snprintf(info, sizeof(info), "Rendering %u / %u samples", render_samples + 1, tot_sample);
RE_engine_update_stats(engine, NULL, info);
/* Refresh Shadows */
diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
index acc1bff6331..98a4371eb4c 100644
--- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
@@ -27,7 +27,10 @@
#include "DRW_render.h"
+#include "ED_screen.h"
+
#include "BLI_rand.h"
+#include "BLI_string_utils.h"
#include "eevee_private.h"
#include "GPU_texture.h"
@@ -37,16 +40,29 @@
static struct {
/* Temporal Anti Aliasing */
struct GPUShader *taa_resolve_sh;
+ struct GPUShader *taa_resolve_reproject_sh;
/* Pixel filter table: Only blackman-harris for now. */
float inverted_cdf[FILTER_CDF_TABLE_SIZE];
} e_data = {NULL}; /* Engine data */
+extern char datatoc_common_uniforms_lib_glsl[];
+extern char datatoc_common_view_lib_glsl[];
+extern char datatoc_bsdf_common_lib_glsl[];
extern char datatoc_effect_temporal_aa_glsl[];
static void eevee_create_shader_temporal_sampling(void)
{
- e_data.taa_resolve_sh = DRW_shader_create_fullscreen(datatoc_effect_temporal_aa_glsl, NULL);
+ char *frag_str = BLI_string_joinN(
+ datatoc_common_uniforms_lib_glsl,
+ datatoc_common_view_lib_glsl,
+ datatoc_bsdf_common_lib_glsl,
+ datatoc_effect_temporal_aa_glsl);
+
+ e_data.taa_resolve_sh = DRW_shader_create_fullscreen(frag_str, NULL);
+ e_data.taa_resolve_reproject_sh = DRW_shader_create_fullscreen(frag_str, "#define USE_REPROJECTION\n");
+
+ MEM_freeN(frag_str);
}
static float UNUSED_FUNCTION(filter_box)(float UNUSED(x))
@@ -159,10 +175,15 @@ void EEVEE_temporal_sampling_matrices_calc(
int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
{
EEVEE_StorageList *stl = vedata->stl;
- EEVEE_FramebufferList *fbl = vedata->fbl;
- EEVEE_TextureList *txl = vedata->txl;
+ // EEVEE_FramebufferList *fbl = vedata->fbl;
+ // EEVEE_TextureList *txl = vedata->txl;
EEVEE_EffectsInfo *effects = stl->effects;
+ if (!e_data.taa_resolve_sh) {
+ eevee_create_shader_temporal_sampling();
+ eevee_create_cdf_table_temporal_sampling();
+ }
+
/* Reset for each "redraw". When rendering using ogl render,
* we accumulate the redraw inside the drawing loop in eevee_draw_background().
* But we do NOT accumulate between "redraw" (as in full draw manager drawloop)
@@ -173,6 +194,14 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
ViewLayer *view_layer = draw_ctx->view_layer;
IDProperty *props = BKE_view_layer_engine_evaluated_get(view_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_EEVEE);
+ int repro_flag = 0;
+ if (!DRW_state_is_image_render() &&
+ BKE_collection_engine_property_value_get_bool(props, "taa_reprojection"))
+ {
+ repro_flag = EFFECT_TAA_REPROJECT | EFFECT_VELOCITY_BUFFER | EFFECT_DEPTH_DOUBLE_BUFFER | EFFECT_DOUBLE_BUFFER | EFFECT_POST_BUFFER;
+ effects->taa_reproject_sample = ((effects->taa_reproject_sample + 1) % 16);
+ }
+
if ((BKE_collection_engine_property_value_get_int(props, "taa_samples") != 1 &&
/* FIXME the motion blur camera evaluation is tagging view_updated
* thus making the TAA always reset and never stopping rendering. */
@@ -181,17 +210,17 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
{
float persmat[4][4], viewmat[4][4];
- if (!e_data.taa_resolve_sh) {
- eevee_create_shader_temporal_sampling();
- eevee_create_cdf_table_temporal_sampling();
- }
-
/* Until we support reprojection, we need to make sure
* that the history buffer contains correct information. */
bool view_is_valid = stl->g_data->valid_double_buffer;
view_is_valid = view_is_valid && (stl->g_data->view_updated == false);
+ if (draw_ctx->evil_C != NULL) {
+ struct wmWindowManager *wm = CTX_wm_manager(draw_ctx->evil_C);
+ view_is_valid = view_is_valid && (ED_screen_animation_no_scrub(wm) == NULL);
+ }
+
effects->taa_total_sample = BKE_collection_engine_property_value_get_int(props, "taa_samples");
MAX2(effects->taa_total_sample, 0);
@@ -215,6 +244,7 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
/* OGL render already jitter the camera. */
if (!DRW_state_is_image_render()) {
effects->taa_current_sample += 1;
+ repro_flag = 0;
double ht_point[2];
double ht_offset[2] = {0.0, 0.0};
@@ -238,42 +268,54 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
effects->taa_current_sample = 1;
}
- DRW_texture_ensure_fullscreen_2D(&txl->depth_double_buffer, DRW_TEX_DEPTH_24_STENCIL_8, 0);
-
- GPU_framebuffer_ensure_config(&fbl->double_buffer_depth_fb, {
- GPU_ATTACHMENT_TEXTURE(txl->depth_double_buffer)
- });
-
- return EFFECT_TAA | EFFECT_DOUBLE_BUFFER | EFFECT_POST_BUFFER;
+ return repro_flag | EFFECT_TAA | EFFECT_DOUBLE_BUFFER | EFFECT_DEPTH_DOUBLE_BUFFER | EFFECT_POST_BUFFER;
}
effects->taa_current_sample = 1;
- /* Cleanup to release memory */
- DRW_TEXTURE_FREE_SAFE(txl->depth_double_buffer);
- GPU_FRAMEBUFFER_FREE_SAFE(fbl->double_buffer_depth_fb);
-
- return 0;
+ return repro_flag;
}
-void EEVEE_temporal_sampling_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
+void EEVEE_temporal_sampling_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
EEVEE_StorageList *stl = vedata->stl;
EEVEE_TextureList *txl = vedata->txl;
EEVEE_EffectsInfo *effects = stl->effects;
- if ((effects->enabled_effects & EFFECT_TAA) != 0) {
+ if ((effects->enabled_effects & (EFFECT_TAA | EFFECT_TAA_REPROJECT)) != 0) {
+ struct GPUShader *sh = (effects->enabled_effects & EFFECT_TAA_REPROJECT)
+ ? e_data.taa_resolve_reproject_sh
+ : e_data.taa_resolve_sh;
+
psl->taa_resolve = DRW_pass_create("Temporal AA Resolve", DRW_STATE_WRITE_COLOR);
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.taa_resolve_sh, psl->taa_resolve);
+ DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->taa_resolve);
- DRW_shgroup_uniform_texture_ref(grp, "historyBuffer", &txl->color_double_buffer);
+ DRW_shgroup_uniform_texture_ref(grp, "colorHistoryBuffer", &txl->color_double_buffer);
DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &txl->color);
- DRW_shgroup_uniform_float(grp, "alpha", &effects->taa_alpha, 1);
+
+ if (effects->enabled_effects & EFFECT_TAA_REPROJECT) {
+ // DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ DRW_shgroup_uniform_texture_ref(grp, "velocityBuffer", &effects->velocity_tx);
+ DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
+ }
+ else {
+ DRW_shgroup_uniform_float(grp, "alpha", &effects->taa_alpha, 1);
+ }
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
}
+/* Special Swap */
+#define SWAP_BUFFER_TAA() do { \
+ SWAP(struct GPUFrameBuffer *, fbl->effect_fb, fbl->double_buffer_fb); \
+ SWAP(struct GPUFrameBuffer *, fbl->effect_color_fb, fbl->double_buffer_color_fb); \
+ SWAP(GPUTexture *, txl->color_post, txl->color_double_buffer); \
+ effects->swap_double_buffer = false; \
+ effects->source_buffer = txl->color_double_buffer; \
+ effects->target_buffer = fbl->main_color_fb; \
+} while (0);
+
void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
@@ -282,8 +324,8 @@ void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata)
EEVEE_StorageList *stl = vedata->stl;
EEVEE_EffectsInfo *effects = stl->effects;
- if ((effects->enabled_effects & EFFECT_TAA) != 0) {
- if (effects->taa_current_sample != 1) {
+ if ((effects->enabled_effects & (EFFECT_TAA | EFFECT_TAA_REPROJECT)) != 0) {
+ if ((effects->enabled_effects & EFFECT_TAA) != 0 && effects->taa_current_sample != 1) {
if (DRW_state_is_image_render()) {
/* See EEVEE_temporal_sampling_init() for more details. */
effects->taa_alpha = 1.0f / (float)(effects->taa_render_sample);
@@ -300,19 +342,24 @@ void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata)
GPU_framebuffer_blit(fbl->double_buffer_depth_fb, 0, fbl->main_fb, 0, GPU_DEPTH_BIT);
}
- /* Special Swap */
- SWAP(struct GPUFrameBuffer *, fbl->effect_fb, fbl->double_buffer_fb);
- SWAP(struct GPUFrameBuffer *, fbl->effect_color_fb, fbl->double_buffer_color_fb);
- SWAP(GPUTexture *, txl->color_post, txl->color_double_buffer);
- effects->swap_double_buffer = false;
- effects->source_buffer = txl->color_double_buffer;
- effects->target_buffer = fbl->main_color_fb;
+ SWAP_BUFFER_TAA();
}
else {
- /* Save the depth buffer for the next frame.
- * This saves us from doing anything special
- * in the other mode engines. */
if (!DRW_state_is_image_render()) {
+ /* Do reprojection for noise reduction */
+ /* TODO : do AA jitter if in only render view. */
+ if ((effects->enabled_effects & EFFECT_TAA_REPROJECT) != 0 &&
+ stl->g_data->valid_double_buffer)
+ {
+ GPU_framebuffer_bind(fbl->effect_color_fb);
+ DRW_draw_pass(psl->taa_resolve);
+
+ SWAP_BUFFER_TAA();
+ }
+
+ /* Save the depth buffer for the next frame.
+ * This saves us from doing anything special
+ * in the other mode engines. */
GPU_framebuffer_blit(fbl->main_fb, 0, fbl->double_buffer_depth_fb, 0, GPU_DEPTH_BIT);
}
}
@@ -330,10 +377,10 @@ void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata)
}
}
}
-
}
void EEVEE_temporal_sampling_free(void)
{
DRW_SHADER_FREE_SAFE(e_data.taa_resolve_sh);
+ DRW_SHADER_FREE_SAFE(e_data.taa_resolve_reproject_sh);
}
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index 408015addd4..17e7a71a0b3 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -478,7 +478,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
BKE_mesh_texspace_get_reference((struct Mesh *)ob->data, NULL, &texcoloc, NULL, &texcosize);
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
- DRW_shgroup_uniform_mat4(grp, "volumeObjectMatrix", (float *)ob->imat);
+ DRW_shgroup_uniform_mat4(grp, "volumeObjectMatrix", ob->imat);
DRW_shgroup_uniform_vec3(grp, "volumeOrcoLoc", texcoloc, 1);
DRW_shgroup_uniform_vec3(grp, "volumeOrcoSize", texcosize, 1);
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index 77c873c1503..9f4f508d6fd 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -8,37 +8,6 @@
#define LUT_SIZE 64
-#ifdef SHADOW_SHADER
-layout(std140) uniform shadow_render_block {
- mat4 ShadowMatrix[6];
- mat4 FaceViewMatrix[6];
- vec4 lampPosition;
- float cubeTexelSize;
- float storedTexelSize;
- float nearClip;
- float farClip;
- int shadowSampleCount;
- float shadowInvSampleCount;
-};
-
-flat in int shFace; /* Shadow layer we are rendering to. */
-
-/* Replacing viewBlock */
-#define ViewMatrix FaceViewMatrix[shFace]
-#define ViewProjectionMatrix ShadowMatrix[shFace]
-/* TODO optimize */
-#define ProjectionMatrix \
-mat4(vec4(1.0, 0.0, 0.0, 0.0), \
- vec4(0.0, 1.0, 0.0, 0.0), \
- vec4(0.0, 0.0, -(farClip + nearClip) / (farClip - nearClip), -1.0), \
- vec4(0.0, 0.0, (-2.0 * farClip * nearClip) / (farClip - nearClip), 0.0))
-
-#define ViewMatrixInverse inverse(ViewMatrix)
-#define ViewProjectionMatrixInverse inverse(ViewProjectionMatrix)
-#define ProjectionMatrixInverse inverse(ProjectionMatrix)
-#define CameraTexCoFactors vec4(1.0f, 1.0f, 0.0f, 0.0f)
-#endif
-
/* Buffers */
uniform sampler2D colorBuffer;
uniform sampler2D depthBuffer;
@@ -126,6 +95,30 @@ vec3 project_point(mat4 m, vec3 v) {
return tmp.xyz / tmp.w;
}
+#define min3(a, b, c) min(a, min(b, c))
+#define min4(a, b, c, d) min(a, min3(b, c, d))
+#define min5(a, b, c, d, e) min(a, min4(b, c, d, e))
+#define min6(a, b, c, d, e, f) min(a, min5(b, c, d, e, f))
+#define min7(a, b, c, d, e, f, g) min(a, min6(b, c, d, e, f, g))
+#define min8(a, b, c, d, e, f, g, h) min(a, min7(b, c, d, e, f, g, h))
+#define min9(a, b, c, d, e, f, g, h, i) min(a, min8(b, c, d, e, f, g, h, i))
+
+#define max3(a, b, c) max(a, max(b, c))
+#define max4(a, b, c, d) max(a, max3(b, c, d))
+#define max5(a, b, c, d, e) max(a, max4(b, c, d, e))
+#define max6(a, b, c, d, e, f) max(a, max5(b, c, d, e, f))
+#define max7(a, b, c, d, e, f, g) max(a, max6(b, c, d, e, f, g))
+#define max8(a, b, c, d, e, f, g, h) max(a, max7(b, c, d, e, f, g, h))
+#define max9(a, b, c, d, e, f, g, h, i) max(a, max8(b, c, d, e, f, g, h, i))
+
+#define avg3(a, b, c) (a + b + c) * (1.0 / 3.0)
+#define avg4(a, b, c, d) (a + b + c + d) * (1.0 / 4.0)
+#define avg5(a, b, c, d, e) (a + b + c + d + e) * (1.0 / 5.0)
+#define avg6(a, b, c, d, e, f) (a + b + c + d + e + f) * (1.0 / 6.0)
+#define avg7(a, b, c, d, e, f, g) (a + b + c + d + e + f + g) * (1.0 / 7.0)
+#define avg8(a, b, c, d, e, f, g, h) (a + b + c + d + e + f + g + h) * (1.0 / 8.0)
+#define avg9(a, b, c, d, e, f, g, h, i) (a + b + c + d + e + f + g + h + i) * (1.0 / 9.0)
+
float min_v2(vec2 v) { return min(v.x, v.y); }
float min_v3(vec3 v) { return min(v.x, min(v.y, v.z)); }
float max_v2(vec2 v) { return max(v.x, v.y); }
@@ -283,6 +276,7 @@ void make_orthonormal_basis(vec3 N, out vec3 T, out vec3 B)
}
/* ---- Opengl Depth conversion ---- */
+
float linear_depth(bool is_persp, float z, float zf, float zn)
{
if (is_persp) {
diff --git a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
index 05fef73b159..c11dbdd59ad 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
@@ -4,6 +4,8 @@
* Adapted from http://rastergrid.com/blog/2010/10/hierarchical-z-map-based-occlusion-culling/
**/
+#extension GL_ARB_texture_gather : enable
+
#ifdef LAYERED
uniform sampler2DArray depthBuffer;
uniform int depthLayer;
@@ -12,15 +14,21 @@ uniform sampler2D depthBuffer;
#endif
#ifdef LAYERED
-#define sampleLowerMip(t) texelFetch(depthBuffer, ivec3(t, depthLayer), 0).r
+# define sampleLowerMip(t) texelFetch(depthBuffer, ivec3(t, depthLayer), 0).r
+# define gatherLowerMip(t) textureGather(depthBuffer, vec3(t, depthLayer))
#else
-#define sampleLowerMip(t) texelFetch(depthBuffer, t, 0).r
+# define sampleLowerMip(t) texelFetch(depthBuffer, t, 0).r
+# define gatherLowerMip(t) textureGather(depthBuffer, t)
#endif
#ifdef MIN_PASS
-#define minmax(a, b) min(a, b)
+#define minmax2(a, b) min(a, b)
+#define minmax3(a, b, c) min(min(a, b), c)
+#define minmax4(a, b, c, d) min(min(min(a, b), c), d)
#else /* MAX_PASS */
-#define minmax(a, b) max(a, b)
+#define minmax2(a, b) max(a, b)
+#define minmax3(a, b, c) max(max(a, b), c)
+#define minmax4(a, b, c, d) max(max(max(a, b), c), d)
#endif
/* On some AMD card / driver conbination, it is needed otherwise,
@@ -38,32 +46,45 @@ void main()
texelPos *= 2;
#endif
+#ifdef COPY_DEPTH
float val = sampleLowerMip(texelPos);
-#ifndef COPY_DEPTH
- float val2 = sampleLowerMip(texelPos + ivec2(1, 0));
- float val3 = sampleLowerMip(texelPos + ivec2(1, 1));
- float val4 = sampleLowerMip(texelPos + ivec2(0, 1));
- val = minmax(val, val2);
- val = minmax(val, val3);
- val = minmax(val, val4);
+#else
+ vec4 samp;
+# ifdef GL_ARB_texture_gather
+ samp = gatherLowerMip(vec2(texelPos) / vec2(mipsize));
+# else
+ samp.x = sampleLowerMip(texelPos);
+ samp.y = sampleLowerMip(texelPos + ivec2(1, 0));
+ samp.z = sampleLowerMip(texelPos + ivec2(1, 1));
+ samp.w = sampleLowerMip(texelPos + ivec2(0, 1));
+# endif
+
+ float val = minmax4(samp.x, samp.y, samp.z, samp.w);
/* if we are reducing an odd-width texture then fetch the edge texels */
if (((mipsize.x & 1) != 0) && (texelPos.x == mipsize.x - 3)) {
/* if both edges are odd, fetch the top-left corner texel */
if (((mipsize.y & 1) != 0) && (texelPos.y == mipsize.y - 3)) {
- val = minmax(val, sampleLowerMip(texelPos + ivec2(2, 2)));
+ samp.x = sampleLowerMip(texelPos + ivec2(2, 2));
+ val = minmax2(val, samp.x);
}
- float val2 = sampleLowerMip(texelPos + ivec2(2, 0));
- float val3 = sampleLowerMip(texelPos + ivec2(2, 1));
- val = minmax(val, val2);
- val = minmax(val, val3);
+# ifdef GL_ARB_texture_gather
+ samp = gatherLowerMip((vec2(texelPos) + vec2(1.0, 0.0)) / vec2(mipsize));
+# else
+ samp.y = sampleLowerMip(texelPos + ivec2(2, 0));
+ samp.z = sampleLowerMip(texelPos + ivec2(2, 1));
+# endif
+ val = minmax3(val, samp.y, samp.z);
}
/* if we are reducing an odd-height texture then fetch the edge texels */
if (((mipsize.y & 1) != 0) && (texelPos.y == mipsize.y - 3)) {
- float val2 = sampleLowerMip(texelPos + ivec2(0, 2));
- float val3 = sampleLowerMip(texelPos + ivec2(1, 2));
- val = minmax(val, val2);
- val = minmax(val, val3);
+# ifdef GL_ARB_texture_gather
+ samp = gatherLowerMip((vec2(texelPos) + vec2(0.0, 1.0)) / vec2(mipsize));
+# else
+ samp.x = sampleLowerMip(texelPos + ivec2(0, 2));
+ samp.y = sampleLowerMip(texelPos + ivec2(1, 2));
+# endif
+ val = minmax3(val, samp.x, samp.y);
}
#endif
diff --git a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
index f3df1864317..b3b94b0a391 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
@@ -1,14 +1,102 @@
-uniform sampler2D colorBuffer;
-uniform sampler2D historyBuffer;
-uniform float alpha;
+uniform sampler2D colorHistoryBuffer;
+uniform sampler2D velocityBuffer;
out vec4 FragColor;
+#ifdef USE_REPROJECTION
+
+/**
+ * Adapted from https://casual-effects.com/g3d/G3D10/data-files/shader/Film/Film_temporalAA.pix
+ * which is adapted from https://github.com/gokselgoktas/temporal-anti-aliasing/blob/master/Assets/Resources/Shaders/TemporalAntiAliasing.cginc
+ * which is adapted from https://github.com/playdeadgames/temporal
+ * Optimization by Stubbesaurus and epsilon adjustment to avoid division by zero.
+ *
+ * This can cause 3x3 blocks of color when there is a thin edge of a similar color that
+ * is varying in intensity.
+ */
+vec3 clip_to_aabb(vec3 color, vec3 minimum, vec3 maximum, vec3 average)
+{
+ /* note: only clips towards aabb center (but fast!) */
+ vec3 center = 0.5 * (maximum + minimum);
+ vec3 extents = 0.5 * (maximum - minimum);
+ vec3 dist = color - center;
+ vec3 ts = abs(extents) / max(abs(dist), vec3(0.0001));
+ float t = saturate(min_v3(ts));
+ return center + dist * t;
+}
+
+/**
+ * Vastly based on https://github.com/playdeadgames/temporal
+ */
+void main()
+{
+ ivec2 texel = ivec2(gl_FragCoord.xy);
+ float depth = texelFetch(depthBuffer, texel, 0).r;
+ vec2 motion = texelFetch(velocityBuffer, texel, 0).rg;
+
+ /* Compute pixel position in previous frame. */
+ vec2 screen_res = vec2(textureSize(colorBuffer, 0).xy);
+ vec2 uv = gl_FragCoord.xy / screen_res;
+ vec2 uv_history = uv - motion;
+
+ ivec2 texel_history = ivec2(uv_history * screen_res);
+ vec4 color_history = textureLod(colorHistoryBuffer, uv_history, 0.0);
+
+ /* Color bounding box clamping. 3x3 neighborhood. */
+ vec4 c02 = texelFetchOffset(colorBuffer, texel, 0, ivec2(-1, 1));
+ vec4 c12 = texelFetchOffset(colorBuffer, texel, 0, ivec2( 0, 1));
+ vec4 c22 = texelFetchOffset(colorBuffer, texel, 0, ivec2( 1, 1));
+ vec4 c01 = texelFetchOffset(colorBuffer, texel, 0, ivec2(-1, 0));
+ vec4 c11 = texelFetchOffset(colorBuffer, texel, 0, ivec2( 0, 0));
+ vec4 c21 = texelFetchOffset(colorBuffer, texel, 0, ivec2( 1, 0));
+ vec4 c00 = texelFetchOffset(colorBuffer, texel, 0, ivec2(-1, -1));
+ vec4 c10 = texelFetchOffset(colorBuffer, texel, 0, ivec2( 0, -1));
+ vec4 c20 = texelFetchOffset(colorBuffer, texel, 0, ivec2( 1, -1));
+
+ vec4 color = c11;
+
+ /* AABB minmax */
+ vec4 min_col = min9(c02, c12, c22, c01, c11, c21, c00, c10, c20);
+ vec4 max_col = max9(c02, c12, c22, c01, c11, c21, c00, c10, c20);
+ vec4 avg_col = avg9(c02, c12, c22, c01, c11, c21, c00, c10, c20);
+
+ /* bias the color aabb toward the center (rounding the shape) */
+ vec4 min_center = min5(c12, c01, c11, c21, c10);
+ vec4 max_center = max5(c12, c01, c11, c21, c10);
+ vec4 avg_center = avg5(c12, c01, c11, c21, c10);
+ min_col = (min_col + min_center) * 0.5;
+ max_col = (max_col + max_center) * 0.5;
+ avg_col = (avg_col + avg_center) * 0.5;
+
+ /* Clip color toward the center of the neighborhood colors AABB box. */
+ color_history.rgb = clip_to_aabb(color_history.rgb, min_col.rgb, max_col.rgb, avg_col.rgb);
+
+ /* Luminance weighting. */
+ /* TODO correct luminance */
+ float lum0 = dot(color.rgb, vec3(0.333));
+ float lum1 = dot(color_history.rgb, vec3(0.333));
+ float diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));
+ float weight = 1.0 - diff;
+ float alpha = mix(0.04, 0.12, weight * weight);
+
+ color_history = mix(color_history, color, alpha);
+
+ bool out_of_view = any(greaterThanEqual(abs(uv_history - 0.5), vec2(0.5)));
+ color_history = (out_of_view) ? color : color_history;
+
+ FragColor = color_history;
+}
+
+#else
+
+uniform float alpha;
+
void main()
{
- /* TODO History buffer Reprojection */
- vec4 history = texelFetch(historyBuffer, ivec2(gl_FragCoord.xy), 0).rgba;
- vec4 color = texelFetch(colorBuffer, ivec2(gl_FragCoord.xy), 0).rgba;
- FragColor = mix(history, color, alpha);
-} \ No newline at end of file
+ ivec2 texel = ivec2(gl_FragCoord.xy);
+ vec4 color = texelFetch(colorBuffer, texel, 0);
+ vec4 color_history = texelFetch(colorHistoryBuffer, texel, 0);
+ FragColor = mix(color_history, color, alpha);
+}
+#endif \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
new file mode 100644
index 00000000000..9c118277212
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
@@ -0,0 +1,19 @@
+
+uniform mat4 currPersinv;
+uniform mat4 pastPersmat;
+
+out vec2 outData;
+
+void main()
+{
+ /* Extract pixel motion vector from camera movement. */
+ ivec2 texel = ivec2(gl_FragCoord.xy);
+ vec2 uv = gl_FragCoord.xy / vec2(textureSize(depthBuffer, 0).xy);
+
+ float depth = texelFetch(depthBuffer, texel, 0).r;
+
+ vec3 world_position = project_point(currPersinv, vec3(uv, depth) * 2.0 - 1.0);
+ vec2 uv_history = project_point(pastPersmat, world_position).xy * 0.5 + 0.5;
+
+ outData = uv - uv_history;
+}
diff --git a/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl b/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
index 1c7956bb807..ae7cae9c4bb 100644
--- a/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
@@ -204,7 +204,6 @@ float light_visibility(LightData ld, vec3 W,
make_orthonormal_basis(L.xyz / L.w, T, B);
vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
- /* WATCH THIS : This still seems to have correlation artifacts for low samples. */
rand.zw *= fast_sqrt(rand.y) * data.sh_contact_spread;
/* We use the full l_vector.xyz so that the spread is minimize
@@ -309,7 +308,6 @@ vec3 light_translucent(LightData ld, vec3 W, vec3 N, vec4 l_vector, float scale)
make_orthonormal_basis(L.xyz / L.w, T, B);
vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
- /* WATCH THIS : This still seems to have correlation artifacts for low samples. */
rand.zw *= fast_sqrt(rand.y) * data.sh_blur;
/* We use the full l_vector.xyz so that the spread is minimize
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl
index 67b0fc2bdfc..4ae22b480f1 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl
@@ -2,8 +2,6 @@
* to linear depth (or other storage method) and doing a 3x3 box filter. */
layout(std140) uniform shadow_render_block {
- mat4 ShadowMatrix[6];
- mat4 FaceViewMatrix[6];
vec4 lampPosition;
float cubeTexelSize;
float storedTexelSize;
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl b/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl
deleted file mode 100644
index ea51fa73a65..00000000000
--- a/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl
+++ /dev/null
@@ -1,53 +0,0 @@
-
-layout(std140) uniform shadow_render_block {
- mat4 ShadowMatrix[6];
- mat4 FaceViewMatrix[6];
- vec4 lampPosition;
- float cubeTexelSize;
- float storedTexelSize;
- float nearClip;
- float farClip;
- int shadowSampleCount;
- float shadowInvSampleCount;
-};
-
-layout(triangles) in;
-layout(triangle_strip, max_vertices=3) out;
-
-in vec4 vPos[];
-flat in int face[];
-
-#ifdef MESH_SHADER
-in vec3 vNor[];
-#endif
-
-out vec3 worldPosition;
-#ifdef MESH_SHADER
-out vec3 viewPosition; /* Required. otherwise generate linking error. */
-out vec3 worldNormal; /* Required. otherwise generate linking error. */
-out vec3 viewNormal; /* Required. otherwise generate linking error. */
-flat out int shFace;
-#else
-int shFace;
-#endif
-
-void main() {
- shFace = face[0];
- gl_Layer = shFace;
-
- for (int v = 0; v < 3; ++v) {
- gl_Position = ShadowMatrix[shFace] * vPos[v];
- worldPosition = vPos[v].xyz;
-#ifdef MESH_SHADER
- worldNormal = vNor[v];
- viewPosition = (FaceViewMatrix[shFace] * vec4(worldPosition, 1.0)).xyz;
- viewNormal = (FaceViewMatrix[shFace] * vec4(worldNormal, 0.0)).xyz;
-#ifdef ATTRIB
- pass_attrib(v);
-#endif
-#endif
- EmitVertex();
- }
-
- EndPrimitive();
-} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
index 0fc7e4c9396..b40155be454 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
@@ -1,7 +1,5 @@
layout(std140) uniform shadow_render_block {
- mat4 ShadowMatrix[6];
- mat4 FaceViewMatrix[6];
vec4 lampPosition;
float cubeTexelSize;
float storedTexelSize;
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
index 29cbcfdd6e4..9fa57b8e136 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
@@ -1,29 +1,33 @@
-uniform mat4 ModelMatrix;
+uniform mat4 ModelViewProjectionMatrix;
#ifdef MESH_SHADER
+uniform mat4 ModelMatrix;
+uniform mat4 ModelViewMatrix;
uniform mat3 WorldNormalMatrix;
+# ifndef ATTRIB
+uniform mat3 NormalMatrix;
+# endif
#endif
in vec3 pos;
-#ifdef MESH_SHADER
in vec3 nor;
-#endif
-out vec4 vPos;
#ifdef MESH_SHADER
-out vec3 vNor;
+out vec3 worldPosition;
+out vec3 viewPosition;
+out vec3 worldNormal;
+out vec3 viewNormal;
#endif
-flat out int face;
-
void main() {
- vPos = ModelMatrix * vec4(pos, 1.0);
- face = gl_InstanceID;
-
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
#ifdef MESH_SHADER
- vNor = WorldNormalMatrix * nor;
+ viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
+ worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
+ viewNormal = normalize(NormalMatrix * nor);
+ worldNormal = normalize(WorldNormalMatrix * nor);
#ifdef ATTRIB
pass_attrib(pos);
#endif
#endif
-}
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl b/source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl
index 13ffe02eb0d..2907f25782f 100644
--- a/source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl
@@ -8,11 +8,11 @@ out vec4 FragColor;
void main(void)
{
- vec2 blue_noise = texelFetch(blueNoise, ivec2(gl_FragCoord.xy), 0).xy;
+ vec3 blue_noise = texelFetch(blueNoise, ivec2(gl_FragCoord.xy), 0).xyz;
float noise = fract(blue_noise.y + offsets.z);
FragColor.x = fract(blue_noise.x + offsets.x);
- FragColor.y = fract(blue_noise.y + offsets.y);
+ FragColor.y = fract(blue_noise.z + offsets.y);
FragColor.z = cos(noise * M_2PI);
FragColor.w = sin(noise * M_2PI);
}
diff --git a/source/blender/draw/engines/workbench/shaders/solid_flat_frag.glsl b/source/blender/draw/engines/workbench/shaders/solid_flat_frag.glsl
new file mode 100644
index 00000000000..3a6700bdadc
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/solid_flat_frag.glsl
@@ -0,0 +1,8 @@
+uniform vec3 color;
+
+out vec4 fragColor;
+
+void main()
+{
+ fragColor = vec4(color, 1.0);
+}
diff --git a/source/blender/draw/engines/workbench/shaders/solid_studio_frag.glsl b/source/blender/draw/engines/workbench/shaders/solid_studio_frag.glsl
new file mode 100644
index 00000000000..96e65e2919e
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/solid_studio_frag.glsl
@@ -0,0 +1,29 @@
+uniform vec3 color;
+uniform vec3 light_direction = vec3(0.0, 0.0, 1.0);
+
+uniform vec3 world_diffuse_light_xp = vec3(0.5, 0.5, 0.6);
+uniform vec3 world_diffuse_light_xn = vec3(0.5, 0.5, 0.6);
+uniform vec3 world_diffuse_light_yp = vec3(0.5, 0.5, 0.6);
+uniform vec3 world_diffuse_light_yn = vec3(0.5, 0.5, 0.6);
+uniform vec3 world_diffuse_light_zp = vec3(0.8, 0.8, 0.8);
+uniform vec3 world_diffuse_light_zn = vec3(0.0, 0.0, 0.0);
+
+in vec3 normal_viewport;
+out vec4 fragColor;
+#define USE_WORLD_DIFFUSE
+#define AMBIENT_COLOR vec3(0.2, 0.2, 0.2)
+
+void main()
+{
+
+#ifdef USE_WORLD_DIFFUSE
+ vec3 diffuse_light_color = get_world_diffuse_light(normal_viewport, world_diffuse_light_xp, world_diffuse_light_xn, world_diffuse_light_yp, world_diffuse_light_yn, world_diffuse_light_zp, world_diffuse_light_zn);
+ vec3 shaded_color = (AMBIENT_COLOR + diffuse_light_color) * color;
+
+#else
+ float intensity = lambert_diffuse(light_direction, normal_viewport);
+ vec3 shaded_color = color * intensity;
+
+#endif
+ fragColor = vec4(shaded_color, 1.0);
+}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_diffuse_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_diffuse_lib.glsl
new file mode 100644
index 00000000000..22a55a386f7
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_diffuse_lib.glsl
@@ -0,0 +1,21 @@
+float normalized_dot(vec3 v1, vec3 v2)
+{
+ return max(0.0, dot(v1, v2));
+}
+
+float lambert_diffuse(vec3 light_direction, vec3 surface_normal)
+{
+ return normalized_dot(light_direction, surface_normal);
+}
+
+vec3 get_world_diffuse_light(vec3 N, vec3 xp, vec3 xn, vec3 yp, vec3 yn, vec3 zp, vec3 zn)
+{
+ vec3 result = vec3(0.0, 0.0, 0.0);
+ result = mix(result, xp, normalized_dot(vec3( 1.0, 0.0, 0.0), N));
+ result = mix(result, xn, normalized_dot(vec3(-1.0, 0.0, 0.0), N));
+ result = mix(result, yp, normalized_dot(vec3( 0.0, 1.0, 0.0), N));
+ result = mix(result, yn, normalized_dot(vec3( 0.0, -1.0, 0.0), N));
+ result = mix(result, zp, normalized_dot(vec3( 0.0, 0.0, 1.0), N));
+ result = mix(result, zn, normalized_dot(vec3( 0.0, 0.0, -1.0), N));
+ return result;
+} \ No newline at end of file
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_studio_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_studio_vert.glsl
new file mode 100644
index 00000000000..2da5deabfc2
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_studio_vert.glsl
@@ -0,0 +1,13 @@
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat3 NormalMatrix;
+
+in vec3 pos;
+in vec3 nor;
+
+out vec3 normal_viewport;
+
+void main()
+{
+ normal_viewport = normalize(NormalMatrix * nor);
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_vert.glsl
new file mode 100644
index 00000000000..97639f03734
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_vert.glsl
@@ -0,0 +1,8 @@
+uniform mat4 ModelViewProjectionMatrix;
+
+in vec3 pos;
+
+void main()
+{
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+}
diff --git a/source/blender/draw/engines/workbench/solid_flat_mode.c b/source/blender/draw/engines/workbench/solid_flat_mode.c
new file mode 100644
index 00000000000..e98783446d6
--- /dev/null
+++ b/source/blender/draw/engines/workbench/solid_flat_mode.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2016, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file solid_flat_mode.c
+ * \ingroup draw_engine
+ *
+ * Simple engine for drawing color and/or depth.
+ * When we only need simple flat shaders.
+ */
+
+#include "DRW_render.h"
+
+#include "GPU_shader.h"
+
+#include "workbench_private.h"
+/* Functions */
+
+static void workbench_solid_flat_engine_init(void *UNUSED(vedata))
+{
+ workbench_materials_engine_init();
+}
+
+static void workbench_solid_flat_cache_init(void *vedata)
+{
+ WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
+ WORKBENCH_PassList *psl = data->psl;
+ WORKBENCH_StorageList *stl = data->stl;
+
+ if (!stl->g_data) {
+ /* Alloc transient pointers */
+ stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
+ }
+
+ /* Depth Pass */
+ {
+ int state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ psl->depth_pass = DRW_pass_create("Depth Pass", state);
+ }
+
+ /* Solid Pass */
+ {
+ int state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL;
+ psl->solid_pass = DRW_pass_create("Solid Pass", state);
+ }
+
+ workbench_materials_cache_init(data);
+}
+
+
+static void workbench_solid_flat_cache_populate(void *vedata, Object *ob)
+{
+ WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
+ workbench_materials_solid_cache_populate(data, ob);
+}
+
+static void workbench_solid_flat_cache_finish(void *UNUSED(vedata))
+{
+}
+
+static void workbench_solid_flat_draw_scene(void *vedata)
+{
+ WORKBENCH_Data *data = (WORKBENCH_Data *)vedata;
+ WORKBENCH_PassList *psl = data->psl;
+
+ DRW_draw_pass(psl->depth_pass);
+ DRW_draw_pass(psl->solid_pass);
+
+ workbench_materials_draw_scene_finish(data);
+}
+
+static void workbench_solid_flat_engine_free(void)
+{
+ workbench_materials_engine_free();
+}
+
+static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data);
+
+DrawEngineType draw_engine_workbench_solid_flat = {
+ NULL, NULL,
+ N_("Workbench"),
+ &workbench_data_size,
+ &workbench_solid_flat_engine_init,
+ &workbench_solid_flat_engine_free,
+ &workbench_solid_flat_cache_init,
+ &workbench_solid_flat_cache_populate,
+ &workbench_solid_flat_cache_finish,
+ NULL,
+ &workbench_solid_flat_draw_scene,
+ NULL,
+ NULL,
+ NULL,
+};
diff --git a/source/blender/draw/engines/workbench/solid_studio_mode.c b/source/blender/draw/engines/workbench/solid_studio_mode.c
new file mode 100644
index 00000000000..046ad38fa91
--- /dev/null
+++ b/source/blender/draw/engines/workbench/solid_studio_mode.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file solid_studio_mode.c
+ * \ingroup draw_engine
+ *
+ * Simple engine for drawing color and/or depth.
+ * When we only need simple studio shaders.
+ */
+
+#include "DRW_render.h"
+
+#include "GPU_shader.h"
+
+#include "workbench_private.h"
+
+/* Functions */
+
+static void workbench_solid_studio_engine_init(void *UNUSED(vedata))
+{
+ workbench_materials_engine_init();
+}
+
+static void workbench_solid_studio_cache_init(void *vedata)
+{
+
+ WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
+ WORKBENCH_PassList *psl = data->psl;
+ WORKBENCH_StorageList *stl = data->stl;
+
+ if (!stl->g_data) {
+ /* Alloc transient pointers */
+ stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
+ }
+
+ /* Depth Pass */
+ {
+ int state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ psl->depth_pass = DRW_pass_create("Depth Pass", state);
+ }
+
+ /* Solid Pass */
+ {
+ int state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL;
+ psl->solid_pass = DRW_pass_create("Solid Pass", state);
+ }
+ workbench_materials_cache_init(data);
+}
+
+static void workbench_solid_studio_cache_populate(void *vedata, Object *ob)
+{
+ WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
+ workbench_materials_solid_cache_populate(data, ob);
+}
+
+static void workbench_solid_studio_cache_finish(void *UNUSED(vedata))
+{
+}
+
+static void workbench_solid_studio_draw_scene(void *vedata)
+{
+ WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
+ WORKBENCH_PassList *psl = data->psl;
+
+ DRW_draw_pass(psl->depth_pass);
+ DRW_draw_pass(psl->solid_pass);
+
+ workbench_materials_draw_scene_finish(data);
+}
+
+static void workbench_solid_studio_engine_free(void)
+{
+ workbench_materials_engine_free();
+}
+
+static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data);
+
+DrawEngineType draw_engine_workbench_solid_studio = {
+ NULL, NULL,
+ N_("Workbench"),
+ &workbench_data_size,
+ &workbench_solid_studio_engine_init,
+ &workbench_solid_studio_engine_free,
+ &workbench_solid_studio_cache_init,
+ &workbench_solid_studio_cache_populate,
+ &workbench_solid_studio_cache_finish,
+ NULL,
+ &workbench_solid_studio_draw_scene,
+ NULL,
+ NULL,
+ NULL,
+};
+
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c
new file mode 100644
index 00000000000..c93ff5cb2e9
--- /dev/null
+++ b/source/blender/draw/engines/workbench/workbench_engine.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file workbench_engine.c
+ * \ingroup draw_engine
+ *
+ * Simple engine for drawing color and/or depth.
+ * When we only need simple flat shaders.
+ */
+
+#include "DRW_render.h"
+
+#include "BKE_icons.h"
+#include "BKE_idprop.h"
+#include "BKE_main.h"
+
+#include "GPU_shader.h"
+
+#include "workbench_engine.h"
+#include "workbench_private.h"
+/* Shaders */
+
+#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
+
+
+/* Functions */
+
+static void workbench_layer_collection_settings_create(RenderEngine *UNUSED(engine), IDProperty *props)
+{
+ BLI_assert(props &&
+ props->type == IDP_GROUP &&
+ props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
+}
+
+/* Note: currently unused, we may want to register so we can see this when debugging the view. */
+
+RenderEngineType DRW_engine_viewport_workbench_type = {
+ NULL, NULL,
+ WORKBENCH_ENGINE, N_("Workbench"), RE_INTERNAL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, &workbench_layer_collection_settings_create, NULL,
+ &draw_engine_workbench_solid_flat,
+ {NULL, NULL, NULL}
+};
+
+
+#undef WORKBENCH_ENGINE
diff --git a/intern/moto/intern/MT_Point3.cpp b/source/blender/draw/engines/workbench/workbench_engine.h
index 48003a8e60b..306579880ca 100644
--- a/intern/moto/intern/MT_Point3.cpp
+++ b/source/blender/draw/engines/workbench/workbench_engine.h
@@ -1,5 +1,5 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
+ * Copyright 2016, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -15,24 +15,19 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
+ * Contributor(s): Blender Institute
*
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file moto/intern/MT_Point3.cpp
- * \ingroup moto
+/** \file workbench_engine.h
+ * \ingroup draw_engine
*/
+#ifndef __WORKBENCH_ENGINE_H__
+#define __WORKBENCH_ENGINE_H__
-#include "MT_Point3.h"
-
+extern DrawEngineType draw_engine_workbench_solid_flat;
+extern DrawEngineType draw_engine_workbench_solid_studio;
+extern RenderEngineType DRW_engine_viewport_workbench_type;
-#ifndef GEN_INLINED
-#include "MT_Point3.inl"
-#endif
+#endif /* __WORKBENCH_ENGINE_H__ */
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
new file mode 100644
index 00000000000..f9646deca8e
--- /dev/null
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2016, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file workbench_materials.c
+ * \ingroup draw_engine
+ */
+
+#include "workbench_private.h"
+#include "GPU_shader.h"
+
+/* *********** STATIC *********** */
+static struct {
+ struct GPUShader *depth_sh;
+
+ /* Solid flat mode */
+ struct GPUShader *solid_flat_sh;
+
+ /* Solid studio mode */
+ struct GPUShader *solid_studio_sh;
+
+} e_data = {NULL};
+
+/* Shaders */
+extern char datatoc_solid_flat_frag_glsl[];
+extern char datatoc_solid_studio_frag_glsl[];
+extern char datatoc_workbench_vert_glsl[];
+extern char datatoc_workbench_studio_vert_glsl[];
+extern char datatoc_workbench_diffuse_lib_glsl[];
+
+/* Functions */
+static uint get_material_hash(const float color[3])
+{
+ uint r = (uint)(color[0] * 512);
+ uint g = (uint)(color[1] * 512);
+ uint b = (uint)(color[2] * 512);
+
+ return r + g * 4096 + b * 4096 * 4096;
+}
+
+static void get_material_solid_color(WORKBENCH_PrivateData *wpd, Object *ob, float *color)
+{
+ if (wpd->drawtype_options & V3D_DRAWOPTION_RANDOMIZE) {
+ unsigned int obhash = BLI_ghashutil_strhash(ob->id.name);
+ cpack_to_rgb(obhash, &color[0], &color[1], &color[2]);
+
+ } else {
+ copy_v3_v3(color, ob->col);
+ }
+}
+
+void workbench_materials_engine_init(void)
+{
+ if (!e_data.depth_sh) {
+ /* Depth pass */
+ e_data.depth_sh = DRW_shader_create_3D_depth_only();
+
+ /* Solid flat */
+ e_data.solid_flat_sh = DRW_shader_create(datatoc_workbench_vert_glsl, NULL, datatoc_solid_flat_frag_glsl, "\n");
+ e_data.solid_studio_sh = DRW_shader_create(datatoc_workbench_studio_vert_glsl, NULL, datatoc_solid_studio_frag_glsl, datatoc_workbench_diffuse_lib_glsl);
+ }
+}
+
+void workbench_materials_engine_free()
+{
+ DRW_SHADER_FREE_SAFE(e_data.solid_flat_sh);
+ DRW_SHADER_FREE_SAFE(e_data.solid_studio_sh);
+
+}
+
+void workbench_materials_draw_scene_finish(WORKBENCH_Data *vedata)
+{
+ WORKBENCH_StorageList *stl = vedata->stl;
+ WORKBENCH_PrivateData *wpd = stl->g_data;
+
+ BLI_ghash_free(wpd->material_hash, NULL, MEM_freeN);
+}
+
+
+void workbench_materials_cache_init(WORKBENCH_Data *vedata)
+{
+ WORKBENCH_StorageList *stl = vedata->stl;
+ WORKBENCH_PassList *psl = vedata->psl;
+ WORKBENCH_PrivateData *wpd = stl->g_data;
+
+ const DRWContextState *DCS = DRW_context_state_get();
+
+ wpd->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
+ wpd->material_hash = BLI_ghash_ptr_new("Workbench material_hash");
+
+ View3D *v3d = DCS->v3d;
+ if (v3d) {
+#if 0
+ /* TODO: switch implementation when OB_TEXTURE is implemented */
+ switch (v3d->drawtype) {
+ default:
+ case OB_SOLID:
+ wpd->drawtype_lighting = v3d->drawtype_lighting;
+ break;
+ }
+#else
+ wpd->drawtype_lighting = v3d->drawtype_lighting;
+ wpd->drawtype_options = v3d->drawtype_options;
+#endif
+ }
+ else {
+ wpd->drawtype_lighting = V3D_LIGHTING_STUDIO;
+ wpd->drawtype_options = 0;
+ }
+}
+
+void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
+{
+ WORKBENCH_StorageList *stl = vedata->stl;
+ WORKBENCH_PassList *psl = vedata->psl;
+ WORKBENCH_PrivateData *wpd = stl->g_data;
+
+ if (!DRW_object_is_renderable(ob))
+ return;
+
+ struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ WORKBENCH_MaterialData *material;
+ if (geom) {
+ /* Depth */
+ DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
+
+ /* Solid */
+ GPUShader *shader = wpd->drawtype_lighting == V3D_LIGHTING_FLAT?e_data.solid_flat_sh:e_data.solid_studio_sh;
+
+ float color[3];
+ get_material_solid_color(wpd, ob, color);
+ unsigned int hash = get_material_hash(color);
+
+ material = BLI_ghash_lookup(wpd->material_hash, SET_UINT_IN_POINTER(hash));
+ if (material == NULL) {
+ material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), "WORKBENCH_MaterialData");
+ material->shgrp = DRW_shgroup_create(shader, psl->solid_pass);
+ copy_v3_v3(material->color, color);
+ DRW_shgroup_uniform_vec3(material->shgrp, "color", material->color, 1);
+ BLI_ghash_insert(wpd->material_hash, SET_UINT_IN_POINTER(hash), material);
+ }
+
+ DRW_shgroup_call_add(material->shgrp, geom, ob->obmat);
+ }
+
+}
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
new file mode 100644
index 00000000000..1bae8f3a53b
--- /dev/null
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2016, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file workbench_private.h
+ * \ingroup draw_engine
+ */
+
+#ifndef __WORKBENCH_PRIVATE_H__
+#define __WORKBENCH_PRIVATE_H__
+
+
+#include "DRW_render.h"
+#include "DNA_view3d_types.h"
+
+#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
+
+
+typedef struct WORKBENCH_StorageList {
+ struct WORKBENCH_PrivateData *g_data;
+} WORKBENCH_StorageList;
+
+typedef struct WORKBENCH_PassList {
+ struct DRWPass *depth_pass;
+ struct DRWPass *solid_pass;
+} WORKBENCH_PassList;
+
+typedef struct WORKBENCH_Data {
+ void *engine_type;
+ DRWViewportEmptyList *fbl;
+ DRWViewportEmptyList *txl;
+ WORKBENCH_PassList *psl;
+ WORKBENCH_StorageList *stl;
+} WORKBENCH_Data;
+
+typedef struct WORKBENCH_PrivateData {
+ DRWShadingGroup *depth_shgrp;
+
+ DRWShadingGroup *shadeless_shgrp;
+
+ struct GHash *material_hash;
+ short drawtype_lighting;
+ short drawtype_options;
+} WORKBENCH_PrivateData; /* Transient data */
+
+typedef struct WORKBENCH_MaterialData {
+ /* Solid color */
+ float color[3];
+
+ /* Linked shgroup for drawing */
+ DRWShadingGroup *shgrp;
+} WORKBENCH_MaterialData;
+
+
+/* workbench_engine.c */
+void workbench_solid_materials_init(void);
+void workbench_solid_materials_cache_init(WORKBENCH_Data *vedata);
+void workbench_solid_materials_cache_populate(WORKBENCH_Data *vedata, Object *ob);
+void workbench_solid_materials_cache_finish(WORKBENCH_Data *vedata);
+void workbench_solid_materials_draw_scene(WORKBENCH_Data *vedata);
+void workbench_solid_materials_free(void);
+
+/* workbench_materials.c */
+void workbench_materials_engine_init(void);
+void workbench_materials_engine_free(void);
+void workbench_materials_draw_scene_finish(WORKBENCH_Data *vedata);
+void workbench_materials_cache_init(WORKBENCH_Data *vedata);
+void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob);
+
+#endif
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 60e855108f9..17537e295a6 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -187,6 +187,7 @@ typedef enum {
DRW_TEX_R_8,
DRW_TEX_R_16,
DRW_TEX_R_16I,
+ DRW_TEX_R_16U,
DRW_TEX_R_32,
DRW_TEX_DEPTH_16,
DRW_TEX_DEPTH_24,
@@ -376,8 +377,10 @@ void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const
void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize);
void DRW_shgroup_uniform_ivec2(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize);
void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize);
-void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float *value);
-void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float *value);
+void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float (*value)[3]);
+void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float (*value)[4]);
+/* Store value instead of referencing it. */
+void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value);
/* Passes */
DRWPass *DRW_pass_create(const char *name, DRWState state);
@@ -404,7 +407,7 @@ typedef struct DRWMatrixState {
void DRW_viewport_init(const bContext *C);
void DRW_viewport_matrix_get(float mat[4][4], DRWViewportMatrixType type);
void DRW_viewport_matrix_get_all(DRWMatrixState *state);
-void DRW_viewport_matrix_override_set(float mat[4][4], DRWViewportMatrixType type);
+void DRW_viewport_matrix_override_set(const float mat[4][4], DRWViewportMatrixType type);
void DRW_viewport_matrix_override_set_all(DRWMatrixState *state);
void DRW_viewport_matrix_override_unset(DRWViewportMatrixType type);
void DRW_viewport_matrix_override_unset_all(void);
@@ -506,7 +509,6 @@ typedef struct DRWContextState {
struct RenderEngineType *engine_type;
- EvaluationContext eval_ctx;
struct Depsgraph *depsgraph;
eObjectMode object_mode;
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index c14fe70e0c3..fe87e7f17fd 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -1228,7 +1228,7 @@ static void draw_armature_edit(Object *ob)
const bool show_text = DRW_state_show_text();
- for (eBone = arm->edbo->first, index = 0; eBone; eBone = eBone->next, index++) {
+ for (eBone = arm->edbo->first, index = ob->select_color; eBone; eBone = eBone->next, index += 0x10000) {
if (eBone->layer & arm->layer) {
if ((eBone->flag & BONE_HIDDEN_A) == 0) {
const int select_id = is_select ? index : (unsigned int)-1;
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index f7a82c6d0c5..bad860967ef 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -132,7 +132,7 @@ typedef struct MeshRenderData {
MEdge *medge;
MLoop *mloop;
MPoly *mpoly;
- float (*orco)[3];
+ float (*orco)[3]; /* vertex coordinates normalized to bounding box */
MDeformVert *dvert;
MLoopUV *mloopuv;
MLoopCol *mloopcol;
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 0530d05c199..d7e8a6b71df 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -46,6 +46,8 @@
#include "GPU_batch.h"
+#include "DEG_depsgraph_query.h"
+
#include "draw_cache_impl.h" /* own include */
static void particle_batch_cache_clear(ParticleSystem *psys);
@@ -466,7 +468,7 @@ static void particle_batch_cache_ensure_pos(Object *object, ParticleSystem *psys
ParticleSimulationData sim = {NULL};
const DRWContextState *draw_ctx = DRW_context_state_get();
- sim.eval_ctx = &draw_ctx->eval_ctx;
+ sim.depsgraph = draw_ctx->depsgraph;
sim.scene = draw_ctx->scene;
sim.ob = object;
sim.psys = psys;
@@ -494,7 +496,7 @@ static void particle_batch_cache_ensure_pos(Object *object, ParticleSystem *psys
GWN_vertbuf_data_alloc(cache->pos, psys->totpart);
for (curr_point = 0, i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) {
- state.time = draw_ctx->eval_ctx.ctime;
+ state.time = DEG_get_ctime(draw_ctx->depsgraph);
if (!psys_get_particle_state(&sim, curr_point, &state, 0)) {
continue;
}
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 8d23688959c..765e3f05848 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -162,6 +162,7 @@ static struct {
struct Gwn_VertFormat *instance_screen_aligned;
struct Gwn_VertFormat *instance_scaled;
struct Gwn_VertFormat *instance_sized;
+ struct Gwn_VertFormat *instance_outline;
struct Gwn_VertFormat *instance;
struct Gwn_VertFormat *instance_camera;
struct Gwn_VertFormat *instance_distance_lines;
@@ -332,6 +333,22 @@ DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom)
return grp;
}
+DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct Gwn_Batch *geom, int *baseid)
+{
+ GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE);
+
+ DRW_shgroup_instance_format(g_formats.instance_outline, {
+ {"callId" , DRW_ATTRIB_INT, 1},
+ {"size" , DRW_ATTRIB_FLOAT, 1},
+ {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ });
+
+ DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_outline);
+ DRW_shgroup_uniform_int(grp, "baseId", baseid, 1);
+
+ return grp;
+}
+
DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom)
{
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_CAMERA);
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index 3d498cba8b6..ce223d4dd27 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -119,6 +119,7 @@ struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct
struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct Gwn_Batch *geom);
struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct Gwn_Batch *geom);
struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
+struct DRWShadingGroup *shgroup_instance_outline(struct DRWPass *pass, struct Gwn_Batch *geom, int *baseid);
struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index ee73a2ba2c6..350d4a0c20d 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -297,13 +297,13 @@ static DRWInstanceData *drw_instance_data_create(
BLI_assert(attrib_size > 0);
/* Push to linked list. */
- if (idatalist->idata_head[attrib_size-1] == NULL) {
- idatalist->idata_head[attrib_size-1] = idata;
+ if (idatalist->idata_head[attrib_size - 1] == NULL) {
+ idatalist->idata_head[attrib_size - 1] = idata;
}
else {
- idatalist->idata_tail[attrib_size-1]->next = idata;
+ idatalist->idata_tail[attrib_size - 1]->next = idata;
}
- idatalist->idata_tail[attrib_size-1] = idata;
+ idatalist->idata_tail[attrib_size - 1] = idata;
return idata;
}
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 752fc52b9b7..218ddf60d99 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -76,6 +76,7 @@
#include "engines/clay/clay_engine.h"
#include "engines/eevee/eevee_engine.h"
#include "engines/basic/basic_engine.h"
+#include "engines/workbench/workbench_engine.h"
#include "engines/external/external_engine.h"
#include "../../../intern/gawain/gawain/gwn_context.h"
@@ -350,16 +351,6 @@ static void drw_viewport_cache_resize(void)
DRW_instance_data_list_resize(DST.idatalist);
}
-static void drw_state_eval_ctx_init(DRWManager *dst)
-{
- DRWContextState *draw_ctx = &dst->draw_ctx;
- DEG_evaluation_context_init_from_scene(
- &draw_ctx->eval_ctx,
- draw_ctx->scene,
- draw_ctx->view_layer,
- DST.options.is_scene_render ? DAG_EVAL_RENDER : DAG_EVAL_VIEWPORT);
-}
-
/* Not a viewport variable, we could split this out. */
static void drw_context_state_init(void)
{
@@ -388,8 +379,6 @@ static void drw_context_state_init(void)
else {
DST.draw_ctx.object_pose = NULL;
}
-
- drw_state_eval_ctx_init(&DST);
}
/* It also stores viewport variable to an immutable place: DST
@@ -507,7 +496,7 @@ static void drw_viewport_var_init(void)
void DRW_viewport_matrix_get(float mat[4][4], DRWViewportMatrixType type)
{
BLI_assert(type >= 0 && type < DRW_MAT_COUNT);
- BLI_assert(((DST.override_mat & (1 << type)) != 0)|| DST.draw_ctx.rv3d != NULL); /* Can't use this in render mode. */
+ BLI_assert(((DST.override_mat & (1 << type)) != 0) || DST.draw_ctx.rv3d != NULL); /* Can't use this in render mode. */
copy_m4_m4(mat, DST.view_data.matstate.mat[type]);
}
@@ -517,7 +506,7 @@ void DRW_viewport_matrix_get_all(DRWMatrixState *state)
memcpy(state, DST.view_data.matstate.mat, sizeof(DRWMatrixState));
}
-void DRW_viewport_matrix_override_set(float mat[4][4], DRWViewportMatrixType type)
+void DRW_viewport_matrix_override_set(const float mat[4][4], DRWViewportMatrixType type)
{
BLI_assert(type < DRW_MAT_COUNT);
copy_m4_m4(DST.view_data.matstate.mat[type], mat);
@@ -906,15 +895,36 @@ static void drw_engines_enable_external(void)
/* TODO revisit this when proper layering is implemented */
/* Gather all draw engines needed and store them in DST.enabled_engines
* That also define the rendering order of engines */
-static void drw_engines_enable_from_engine(RenderEngineType *engine_type)
+static void drw_engines_enable_from_engine(RenderEngineType *engine_type, int drawtype, int drawtype_lighting)
{
- /* TODO layers */
- if (engine_type->draw_engine != NULL) {
- use_drw_engine(engine_type->draw_engine);
- }
+ switch (drawtype) {
+ case OB_WIRE:
+ break;
- if ((engine_type->flag & RE_INTERNAL) == 0) {
- drw_engines_enable_external();
+ case OB_SOLID:
+ if (drawtype_lighting == V3D_LIGHTING_FLAT) {
+ use_drw_engine(&draw_engine_workbench_solid_flat);
+
+ }
+ else if (drawtype_lighting == V3D_LIGHTING_STUDIO) {
+ use_drw_engine(&draw_engine_workbench_solid_studio);
+
+ }
+ break;
+
+ case OB_TEXTURE:
+ case OB_MATERIAL:
+ case OB_RENDER:
+ default:
+ /* TODO layers */
+ if (engine_type->draw_engine != NULL) {
+ use_drw_engine(engine_type->draw_engine);
+ }
+
+ if ((engine_type->flag & RE_INTERNAL) == 0) {
+ drw_engines_enable_external();
+ }
+ break;
}
}
@@ -977,6 +987,11 @@ static void drw_engines_enable_from_mode(int mode)
}
}
+static void drw_engines_enable_from_overlays(int draw_overlays) {
+ if (draw_overlays) {
+ use_drw_engine(&draw_engine_overlay_type);
+ }
+}
/**
* Use for select and depth-drawing.
*/
@@ -989,10 +1004,14 @@ static void drw_engines_enable(ViewLayer *view_layer, RenderEngineType *engine_t
{
Object *obact = OBACT(view_layer);
const int mode = CTX_data_mode_enum_ex(DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode);
+ View3D * v3d = DST.draw_ctx.v3d;
+ const int drawtype = v3d->drawtype;
+ const int drawtype_lighting = v3d->drawtype_lighting;
- drw_engines_enable_from_engine(engine_type);
+ drw_engines_enable_from_engine(engine_type, drawtype, drawtype_lighting);
if (DRW_state_draw_support()) {
+ drw_engines_enable_from_overlays(v3d->overlays);
drw_engines_enable_from_object_mode();
drw_engines_enable_from_mode(mode);
}
@@ -1125,15 +1144,15 @@ void DRW_notify_id_update(const DRWUpdateContext *update_ctx, ID *id)
* for each relevant engine / mode engine. */
void DRW_draw_view(const bContext *C)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
- RenderEngineType *engine_type = CTX_data_engine_type(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype);
/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
- DRW_draw_render_loop_ex(eval_ctx.depsgraph, engine_type, ar, v3d, C);
+ DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, C);
}
/**
@@ -1294,7 +1313,7 @@ void DRW_draw_render_loop(
drw_state_prepare_clean_for_draw(&DST);
Scene *scene = DEG_get_evaluated_scene(depsgraph);
- RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype);
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, NULL);
}
@@ -1453,8 +1472,8 @@ static void draw_select_framebuffer_setup(const rcti *rect)
/* If size mismatch recreate the texture. */
if ((g_select_buffer.texture_depth != NULL) &&
- ((GPU_texture_width(g_select_buffer.texture_depth) != BLI_rcti_size_x(rect)) ||
- (GPU_texture_height(g_select_buffer.texture_depth) != BLI_rcti_size_y(rect))))
+ ((GPU_texture_width(g_select_buffer.texture_depth) != BLI_rcti_size_x(rect)) ||
+ (GPU_texture_height(g_select_buffer.texture_depth) != BLI_rcti_size_y(rect))))
{
GPU_texture_free(g_select_buffer.texture_depth);
g_select_buffer.texture_depth = NULL;
@@ -1489,7 +1508,7 @@ void DRW_draw_select_loop(
DRW_SelectPassFn select_pass_fn, void *select_pass_user_data)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
- RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
Object *obact = OBACT(view_layer);
Object *obedit = OBEDIT_FROM_OBACT(obact);
@@ -1557,7 +1576,14 @@ void DRW_draw_select_loop(
drw_engines_cache_init();
if (use_obedit) {
+#if 0
drw_engines_cache_populate(obact);
+#else
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, obact->mode, ob_iter) {
+ drw_engines_cache_populate(ob_iter);
+ }
+ FOREACH_OBJECT_IN_MODE_END;
+#endif
}
else {
DEG_OBJECT_ITER_BEGIN(
@@ -1674,7 +1700,7 @@ void DRW_draw_depth_loop(
ARegion *ar, View3D *v3d)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
- RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->drawtype);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
RegionView3D *rv3d = ar->regiondata;
@@ -1926,6 +1952,10 @@ void DRW_engines_register(void)
RE_engines_register(NULL, &DRW_engine_viewport_clay_type);
#endif
RE_engines_register(NULL, &DRW_engine_viewport_eevee_type);
+ RE_engines_register(NULL, &DRW_engine_viewport_workbench_type);
+
+ DRW_engine_register(&draw_engine_workbench_solid_flat);
+ DRW_engine_register(&draw_engine_workbench_solid_studio);
DRW_engine_register(&draw_engine_object_type);
DRW_engine_register(&draw_engine_edit_armature_type);
@@ -1936,6 +1966,7 @@ void DRW_engines_register(void)
DRW_engine_register(&draw_engine_edit_metaball_type);
DRW_engine_register(&draw_engine_edit_surface_type);
DRW_engine_register(&draw_engine_edit_text_type);
+ DRW_engine_register(&draw_engine_overlay_type);
DRW_engine_register(&draw_engine_paint_texture_type);
DRW_engine_register(&draw_engine_paint_vertex_type);
DRW_engine_register(&draw_engine_paint_weight_type);
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index dd7e84f67d4..fd75405f346 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -157,6 +157,7 @@ typedef enum {
DRW_UNIFORM_SHORT_TO_INT,
DRW_UNIFORM_SHORT_TO_FLOAT,
DRW_UNIFORM_INT,
+ DRW_UNIFORM_INT_COPY,
DRW_UNIFORM_FLOAT,
DRW_UNIFORM_TEXTURE,
DRW_UNIFORM_TEXTURE_PERSIST,
@@ -222,6 +223,7 @@ struct DRWShadingGroup {
int normalworld;
int orcotexfac;
int eye;
+ int callid;
uint16_t matflag; /* Matrices needed, same as DRWCall.flag */
#ifndef NDEBUG
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index ae7854b436c..31f6108f7e0 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -201,14 +201,20 @@ void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT, value, 3, arraysize);
}
-void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float *value)
+void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float (*value)[3])
{
- drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 9, 1);
+ drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, (float *)value, 9, 1);
}
-void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float *value)
+void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float (*value)[4])
{
- drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 16, 1);
+ drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, (float *)value, 16, 1);
+}
+
+/* Stores the int instead of a pointer. */
+void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
+{
+ drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, SET_INT_IN_POINTER(value), 1, 1);
}
/** \} */
@@ -498,6 +504,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_WORLDNORMAL);
shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_ORCO);
shgroup->eye = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_EYE);
+ shgroup->callid = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_CALLID);
shgroup->matflag = 0;
if (shgroup->modelinverse > -1)
@@ -630,10 +637,10 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct
/* Should already be in the material ubo. */
break;
case GPU_MAT3:
- DRW_shgroup_uniform_mat3(grp, input->shadername, (float *)input->dynamicvec);
+ DRW_shgroup_uniform_mat3(grp, input->shadername, (float (*)[3])input->dynamicvec);
break;
case GPU_MAT4:
- DRW_shgroup_uniform_mat4(grp, input->shadername, (float *)input->dynamicvec);
+ DRW_shgroup_uniform_mat4(grp, input->shadername, (float (*)[4])input->dynamicvec);
break;
default:
break;
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index e69a1026815..ff29d7d7f3d 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -384,100 +384,53 @@ void DRW_state_clip_planes_reset(void)
/** \name Clipping (DRW_clipping)
* \{ */
-/* Extract the 8 corners (world space).
+/* Extract the 8 corners from a Projection Matrix.
* Although less accurate, this solution can be simplified as follows:
- *
* BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const float[3]){1.0f, 1.0f, 1.0f});
- * for (int i = 0; i < 8; i++) {mul_project_m4_v3(viewprojinv, bbox.vec[i]);}
+ * for (int i = 0; i < 8; i++) {mul_project_m4_v3(projinv, bbox.vec[i]);}
*/
-static void draw_frustum_boundbox_calc(const float (*projmat)[4], const float (*viewinv)[4], BoundBox *r_bbox)
+static void draw_frustum_boundbox_calc(const float(*projmat)[4], BoundBox *r_bbox)
{
- float screenvecs[3][3], loc[3], near, far, w_half, h_half;
+ float near, far, left, right, bottom, top;
bool is_persp = projmat[3][3] == 0.0f;
- copy_m3_m4(screenvecs, viewinv);
- copy_v3_v3(loc, viewinv[3]);
-
- /* get the values of the minimum and maximum clipping planes distances
- * and half the width and height of the nearplane rectangle. */
- if (is_persp) {
- near = projmat[3][2] / (projmat[2][2] - 1.0f);
- far = projmat[3][2] / (projmat[2][2] + 1.0f);
- w_half = near / projmat[0][0];
- h_half = near / projmat[1][1];
- }
- else {
- near = (projmat[3][2] + 1.0f) / projmat[2][2];
- far = (projmat[3][2] - 1.0f) / projmat[2][2];
- w_half = 1.0f / projmat[0][0];
- h_half = 1.0f / projmat[1][1];
- }
-
- /* With vectors aligned to the screen, reconstruct
- * the near plane from the dimensions obtained earlier. */
- float mid[3], hor[3], ver[3];
- mul_v3_v3fl(hor, screenvecs[0], w_half);
- mul_v3_v3fl(ver, screenvecs[1], h_half);
- madd_v3_v3v3fl(mid, loc, screenvecs[2], -near);
- /* The case below is for non-symmetric frustum. */
if (is_persp) {
- madd_v3_v3fl(mid, hor, projmat[2][0]);
- madd_v3_v3fl(mid, ver, projmat[2][1]);
+ near = projmat[3][2] / (projmat[2][2] - 1.0f);
+ far = projmat[3][2] / (projmat[2][2] + 1.0f);
+ left = near * (projmat[2][0] - 1.0f) / projmat[0][0];
+ right = near * (projmat[2][0] + 1.0f) / projmat[0][0];
+ bottom = near * (projmat[2][1] - 1.0f) / projmat[1][1];
+ top = near * (projmat[2][1] + 1.0f) / projmat[1][1];
}
else {
- madd_v3_v3fl(mid, hor, projmat[3][0]);
- madd_v3_v3fl(mid, ver, projmat[3][1]);
+ near = ( projmat[3][2] + 1.0f) / projmat[2][2];
+ far = ( projmat[3][2] - 1.0f) / projmat[2][2];
+ left = (-projmat[3][0] - 1.0f) / projmat[0][0];
+ right = (-projmat[3][0] + 1.0f) / projmat[0][0];
+ bottom = (-projmat[3][1] - 1.0f) / projmat[1][1];
+ top = (-projmat[3][1] + 1.0f) / projmat[1][1];
}
- r_bbox->vec[0][0] = mid[0] - ver[0] - hor[0];
- r_bbox->vec[0][1] = mid[1] - ver[1] - hor[1];
- r_bbox->vec[0][2] = mid[2] - ver[2] - hor[2];
-
- r_bbox->vec[3][0] = mid[0] + ver[0] - hor[0];
- r_bbox->vec[3][1] = mid[1] + ver[1] - hor[1];
- r_bbox->vec[3][2] = mid[2] + ver[2] - hor[2];
-
- r_bbox->vec[7][0] = mid[0] + ver[0] + hor[0];
- r_bbox->vec[7][1] = mid[1] + ver[1] + hor[1];
- r_bbox->vec[7][2] = mid[2] + ver[2] + hor[2];
-
- r_bbox->vec[4][0] = mid[0] - ver[0] + hor[0];
- r_bbox->vec[4][1] = mid[1] - ver[1] + hor[1];
- r_bbox->vec[4][2] = mid[2] - ver[2] + hor[2];
+ r_bbox->vec[0][2] = r_bbox->vec[3][2] = r_bbox->vec[7][2] = r_bbox->vec[4][2] = -near;
+ r_bbox->vec[0][0] = r_bbox->vec[3][0] = left;
+ r_bbox->vec[4][0] = r_bbox->vec[7][0] = right;
+ r_bbox->vec[0][1] = r_bbox->vec[4][1] = bottom;
+ r_bbox->vec[7][1] = r_bbox->vec[3][1] = top;
/* Get the coordinates of the far plane. */
if (is_persp) {
float sca_far = far / near;
- mid[0] = mid[0] + (mid[0] - loc[0]) * sca_far;
- mid[1] = mid[1] + (mid[1] - loc[1]) * sca_far;
- mid[2] = mid[2] + (mid[2] - loc[2]) * sca_far;
-
- mul_v3_fl(hor, sca_far);
- mul_v3_fl(ver, sca_far);
- }
- else {
- madd_v3_v3v3fl(mid, loc, screenvecs[2], -far);
-
- /* Non-symmetric frustum. */
- madd_v3_v3fl(mid, hor, projmat[3][0]);
- madd_v3_v3fl(mid, ver, projmat[3][1]);
+ left *= sca_far;
+ bottom *= sca_far;
+ right *= sca_far;
+ top *= sca_far;
}
- r_bbox->vec[1][0] = mid[0] - ver[0] - hor[0];
- r_bbox->vec[1][1] = mid[1] - ver[1] - hor[1];
- r_bbox->vec[1][2] = mid[2] - ver[2] - hor[2];
-
- r_bbox->vec[2][0] = mid[0] + ver[0] - hor[0];
- r_bbox->vec[2][1] = mid[1] + ver[1] - hor[1];
- r_bbox->vec[2][2] = mid[2] + ver[2] - hor[2];
-
- r_bbox->vec[6][0] = mid[0] + ver[0] + hor[0];
- r_bbox->vec[6][1] = mid[1] + ver[1] + hor[1];
- r_bbox->vec[6][2] = mid[2] + ver[2] + hor[2];
-
- r_bbox->vec[5][0] = mid[0] - ver[0] + hor[0];
- r_bbox->vec[5][1] = mid[1] - ver[1] + hor[1];
- r_bbox->vec[5][2] = mid[2] - ver[2] + hor[2];
+ r_bbox->vec[1][2] = r_bbox->vec[2][2] = r_bbox->vec[6][2] = r_bbox->vec[5][2] = -far;
+ r_bbox->vec[1][0] = r_bbox->vec[2][0] = left;
+ r_bbox->vec[6][0] = r_bbox->vec[5][0] = right;
+ r_bbox->vec[1][1] = r_bbox->vec[5][1] = bottom;
+ r_bbox->vec[2][1] = r_bbox->vec[6][1] = top;
}
static void draw_clipping_setup_from_view(void)
@@ -492,18 +445,29 @@ static void draw_clipping_setup_from_view(void)
/* Extract Clipping Planes */
BoundBox bbox;
- draw_frustum_boundbox_calc(projmat, viewinv, &bbox);
+#if 0 /* It has accuracy problems. */
+ BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const float[3]){1.0f, 1.0f, 1.0f});
+ for (int i = 0; i < 8; i++) {
+ mul_project_m4_v3(projinv, bbox.vec[i]);
+ }
+#else
+ draw_frustum_boundbox_calc(projmat, &bbox);
+#endif
+ /* Transform into world space. */
+ for (int i = 0; i < 8; i++) {
+ mul_m4_v3(viewinv, bbox.vec[i]);
+ }
/* Compute clip planes using the world space frustum corners. */
for (int p = 0; p < 6; p++) {
int q, r;
switch (p) {
- case 0: q=1; r=2; break;
- case 1: q=0; r=5; break;
- case 2: q=1; r=5; break;
- case 3: q=2; r=6; break;
- case 4: q=0; r=3; break;
- default: q=4; r=7; break;
+ case 0: q = 1; r = 2; break;
+ case 1: q = 0; r = 5; break;
+ case 2: q = 1; r = 5; break;
+ case 3: q = 2; r = 6; break;
+ case 4: q = 0; r = 3; break;
+ default: q = 4; r = 7; break;
}
if (DST.frontface == GL_CW) {
SWAP(int, q, r);
@@ -520,9 +484,6 @@ static void draw_clipping_setup_from_view(void)
float *nearpoint = bbox.vec[0];
float *farpoint = bbox.vec[6];
- mul_project_m4_v3(projinv, nearpoint);
- mul_project_m4_v3(projinv, farpoint);
-
/* just use median point */
mid_v3_v3v3(bsphere->center, farpoint, nearpoint);
bsphere->radius = len_v3v3(bsphere->center, farpoint);
@@ -546,7 +507,6 @@ static void draw_clipping_setup_from_view(void)
float h_sq = len_squared_v3v3(mid_min, mid_max);
float fac = (4 * h_sq + b_sq - a_sq) / (8 * h_sq);
- BLI_assert(fac >= 0.0f);
/* The goal is to get the smallest sphere,
* not the sphere that passes through each corner */
@@ -613,8 +573,8 @@ static void draw_clipping_setup_from_view(void)
/* the big formula, it simplifies to (F-N)/(2(e-s)) for the symmetric case */
z = (F-N) / (2.0f * (e-s + c*(f-n)));
- bsphere->center[0] = farcenter[0] * z/e;
- bsphere->center[1] = farcenter[1] * z/e;
+ bsphere->center[0] = farcenter[0] * z / e;
+ bsphere->center[1] = farcenter[1] * z / e;
bsphere->center[2] = z;
bsphere->radius = len_v3v3(bsphere->center, farpoint);
@@ -913,7 +873,12 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
case DRW_UNIFORM_SHORT_TO_INT:
val = (int)*((short *)uni->value);
GPU_shader_uniform_vector_int(
- shgroup->shader, uni->location, uni->length, uni->arraysize, (int *)&val);
+ shgroup->shader, uni->location, uni->length, uni->arraysize, &val);
+ break;
+ case DRW_UNIFORM_INT_COPY:
+ val = GET_INT_FROM_POINTER(uni->value);
+ GPU_shader_uniform_vector_int(
+ shgroup->shader, uni->location, uni->length, uni->arraysize, &val);
break;
case DRW_UNIFORM_SHORT_TO_FLOAT:
fval = (float)*((short *)uni->value);
@@ -1003,7 +968,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
# define GPU_SELECT_LOAD_IF_PICKSEL_LIST_END(start, count)
# define GPU_SELECT_LOAD_IF_PICKSEL_LIST(_shgroup, _start, _count) \
_start = 0; \
- _count = _shgroup->interface.instance_count;
+ _count = _shgroup->instance_count;
#endif
@@ -1045,6 +1010,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
}
else {
bool prev_neg_scale = false;
+ int callid = 0;
for (DRWCall *call = shgroup->calls.first; call; call = call->next) {
/* OPTI/IDEA(clem): Do this preparation in another thread. */
@@ -1053,6 +1019,12 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
if ((call->state->flag & DRW_CALL_CULLED) != 0)
continue;
+ /* XXX small exception/optimisation for outline rendering. */
+ if (shgroup->callid != -1) {
+ GPU_shader_uniform_vector_int(shgroup->shader, shgroup->callid, 1, 1, &callid);
+ callid += 1;
+ }
+
/* Negative scale objects */
bool neg_scale = call->state->flag & DRW_CALL_NEGSCALE;
if (neg_scale != prev_neg_scale) {
@@ -1114,6 +1086,9 @@ static void drw_update_view(void)
static void drw_draw_pass_ex(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group)
{
+ if (start_group == NULL)
+ return;
+
DST.shader = NULL;
BLI_assert(DST.buffer_finish_called && "DRW_render_instance_buffer_finish had not been called before drawing");
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 814109ee1e9..06a579c2208 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -90,7 +90,7 @@ static void drw_deferred_shader_free(DRWDeferredShader *dsh)
static void drw_deferred_shader_queue_free(ListBase *queue)
{
DRWDeferredShader *dsh;
- while((dsh = BLI_pophead(queue))) {
+ while ((dsh = BLI_pophead(queue))) {
drw_deferred_shader_free(dsh);
}
}
@@ -352,8 +352,7 @@ GPUMaterial *DRW_shader_create_from_world(
if (mat == NULL) {
mat = GPU_material_from_nodetree(
- scene, wo->nodetree, &wo->gpumaterial, engine_type, options,
- vert, geom, frag_lib, defines, true);
+ scene, wo->nodetree, &wo->gpumaterial, engine_type, options);
}
drw_deferred_shader_add(mat, vert, geom, frag_lib, defines);
@@ -372,8 +371,7 @@ GPUMaterial *DRW_shader_create_from_material(
if (mat == NULL) {
mat = GPU_material_from_nodetree(
- scene, ma->nodetree, &ma->gpumaterial, engine_type, options,
- vert, geom, frag_lib, defines, true);
+ scene, ma->nodetree, &ma->gpumaterial, engine_type, options);
}
drw_deferred_shader_add(mat, vert, geom, frag_lib, defines);
diff --git a/source/blender/draw/intern/draw_manager_texture.c b/source/blender/draw/intern/draw_manager_texture.c
index 65856a6bf5c..f083e399ac2 100644
--- a/source/blender/draw/intern/draw_manager_texture.c
+++ b/source/blender/draw/intern/draw_manager_texture.c
@@ -36,6 +36,7 @@ void drw_texture_get_format(
* Generally they are multiple of 16bit. */
case DRW_TEX_R_16:
case DRW_TEX_R_16I:
+ case DRW_TEX_R_16U:
case DRW_TEX_R_32:
case DRW_TEX_RG_8:
case DRW_TEX_RG_16:
@@ -72,6 +73,7 @@ void drw_texture_get_format(
case DRW_TEX_R_8: *r_data_type = GPU_R8; break;
case DRW_TEX_R_16: *r_data_type = GPU_R16F; break;
case DRW_TEX_R_16I: *r_data_type = GPU_R16I; break;
+ case DRW_TEX_R_16U: *r_data_type = GPU_R16UI; break;
case DRW_TEX_R_32: *r_data_type = GPU_R32F; break;
#if 0
case DRW_TEX_RGB_8: *r_data_type = GPU_RGB8; break;
diff --git a/source/blender/draw/modes/draw_mode_engines.h b/source/blender/draw/modes/draw_mode_engines.h
index e0f50312c7f..c33c0648d27 100644
--- a/source/blender/draw/modes/draw_mode_engines.h
+++ b/source/blender/draw/modes/draw_mode_engines.h
@@ -41,5 +41,6 @@ extern DrawEngineType draw_engine_paint_weight_type;
extern DrawEngineType draw_engine_particle_type;
extern DrawEngineType draw_engine_pose_type;
extern DrawEngineType draw_engine_sculpt_type;
+extern DrawEngineType draw_engine_overlay_type;
#endif /* __DRAW_MODE_ENGINES_H__ */
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c
index 73a4fb1e9e6..b33ebd8ba60 100644
--- a/source/blender/draw/modes/edit_curve_mode.c
+++ b/source/blender/draw/modes/edit_curve_mode.c
@@ -28,6 +28,8 @@
#include "DNA_curve_types.h"
+#include "BKE_object.h"
+
/* If builtin shaders are needed */
#include "GPU_shader.h"
#include "GPU_batch.h"
@@ -233,7 +235,12 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob)
UNUSED_VARS(psl, stl);
if (ob->type == OB_CURVE) {
- if (ob == draw_ctx->object_edit) {
+#if 0
+ if (ob == draw_ctx->object_edit)
+#else
+ if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode_and_selected(ob))
+#endif
+ {
Curve *cu = ob->data;
/* Get geometry cache */
struct Gwn_Batch *geom;
diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c
index 0268f4eb453..e8628711ffd 100644
--- a/source/blender/draw/modes/edit_lattice_mode.c
+++ b/source/blender/draw/modes/edit_lattice_mode.c
@@ -26,6 +26,8 @@
#include "DRW_engine.h"
#include "DRW_render.h"
+#include "BKE_object.h"
+
/* If builtin shaders are needed */
#include "GPU_shader.h"
@@ -192,7 +194,7 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob)
UNUSED_VARS(psl);
if (ob->type == OB_LATTICE) {
- if (ob == draw_ctx->object_edit) {
+ if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode_and_selected(ob)) {
/* Get geometry cache */
struct Gwn_Batch *geom;
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index 4bd69941809..c465fa38f04 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -37,6 +37,8 @@
#include "edit_mesh_mode_intern.h" /* own include */
+#include "BKE_object.h"
+
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
extern struct GlobalsUboStorage ts; /* draw_common.c */
@@ -448,7 +450,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
struct Gwn_Batch *geom;
if (ob->type == OB_MESH) {
- if (ob == draw_ctx->object_edit) {
+ if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode_and_selected(ob)) {
const Mesh *me = ob->data;
IDProperty *ces_mode_ed = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_EDIT, "");
bool do_occlude_wire = BKE_collection_engine_property_value_get_bool(ces_mode_ed, "show_occlude_wire");
diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c
index bcabeef5bc3..f7b7113a4d6 100644
--- a/source/blender/draw/modes/edit_metaball_mode.c
+++ b/source/blender/draw/modes/edit_metaball_mode.c
@@ -28,6 +28,7 @@
#include "DNA_meta_types.h"
+#include "BKE_object.h"
#include "BKE_mball.h"
/* If builtin shaders are needed */
@@ -171,7 +172,7 @@ static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
DRWShadingGroup *group = stl->g_data->group;
- if (ob == draw_ctx->object_edit) {
+ if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode_and_selected(ob)) {
MetaBall *mb = ob->data;
const bool is_select = DRW_state_is_select();
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 52db4092fbc..ee710e4643f 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -42,6 +42,8 @@
#include "BIF_gl.h"
+#include "BLI_string_utils.h"
+
#include "BKE_anim.h"
#include "BKE_camera.h"
#include "BKE_curve.h"
@@ -73,6 +75,7 @@ extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
extern struct GPUTexture *globals_ramp; /* draw_common.c */
extern GlobalsUboStorage ts;
+extern char datatoc_object_outline_prepass_frag_glsl[];
extern char datatoc_object_outline_resolve_frag_glsl[];
extern char datatoc_object_outline_detect_frag_glsl[];
extern char datatoc_object_outline_expand_frag_glsl[];
@@ -87,6 +90,7 @@ extern char datatoc_object_particle_dot_frag_glsl[];
extern char datatoc_common_globals_lib_glsl[];
extern char datatoc_common_fxaa_lib_glsl[];
extern char datatoc_gpu_shader_flat_color_frag_glsl[];
+extern char datatoc_gpu_shader_flat_id_frag_glsl[];
extern char datatoc_common_fullscreen_vert_glsl[];
extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
@@ -210,8 +214,17 @@ typedef struct OBJECT_PrivateData {
DRWShadingGroup *outlines_transform;
/* Lightprobes */
- DRWShadingGroup *lightprobes_cube;
- DRWShadingGroup *lightprobes_planar;
+ DRWShadingGroup *lightprobes_cube_select;
+ DRWShadingGroup *lightprobes_cube_select_group;
+ DRWShadingGroup *lightprobes_cube_active;
+ DRWShadingGroup *lightprobes_cube_active_group;
+ DRWShadingGroup *lightprobes_cube_transform;
+
+ DRWShadingGroup *lightprobes_planar_select;
+ DRWShadingGroup *lightprobes_planar_select_group;
+ DRWShadingGroup *lightprobes_planar_active;
+ DRWShadingGroup *lightprobes_planar_active_group;
+ DRWShadingGroup *lightprobes_planar_transform;
/* Wire */
DRWShadingGroup *wire;
@@ -232,6 +245,18 @@ typedef struct OBJECT_PrivateData {
/* Hair Systems */
DRWShadingGroup *hair_verts;
DRWShadingGroup *hair_edges;
+
+ /* Outlines id offset */
+ int id_ofs_active;
+ int id_ofs_active_group;
+ int id_ofs_select;
+ int id_ofs_select_group;
+ int id_ofs_transform;
+ int id_ofs_prb_active;
+ int id_ofs_prb_active_group;
+ int id_ofs_prb_select;
+ int id_ofs_prb_select_group;
+ int id_ofs_prb_transform;
} OBJECT_PrivateData; /* Transient data */
static struct {
@@ -241,6 +266,7 @@ static struct {
struct Gwn_VertFormat *empty_image_wire_format;
/* fullscreen shaders */
+ GPUShader *outline_prepass_sh;
GPUShader *outline_resolve_sh;
GPUShader *outline_resolve_aa_sh;
GPUShader *outline_detect_sh;
@@ -268,6 +294,7 @@ static struct {
bool draw_grid;
/* Temp buffer textures */
struct GPUTexture *outlines_depth_tx;
+ struct GPUTexture *outlines_id_tx;
struct GPUTexture *outlines_color_tx;
struct GPUTexture *outlines_blur_tx;
} e_data = {NULL}; /* Engine data */
@@ -297,14 +324,20 @@ static void OBJECT_engine_init(void *vedata)
if (DRW_state_is_fbo()) {
e_data.outlines_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_DEPTH_24,
&draw_engine_object_type);
- e_data.outlines_color_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RGBA_8,
- &draw_engine_object_type);
+ /* XXX TODO DRW_TEX_R_16U can overflow, it would cause no harm
+ * (only bad colored or missing outlines) but we should
+ * use 32bits only if the scene have that many objects */
+ e_data.outlines_id_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_R_16U,
+ &draw_engine_object_type);
GPU_framebuffer_ensure_config(&fbl->outlines_fb, {
GPU_ATTACHMENT_TEXTURE(e_data.outlines_depth_tx),
- GPU_ATTACHMENT_TEXTURE(e_data.outlines_color_tx)
+ GPU_ATTACHMENT_TEXTURE(e_data.outlines_id_tx)
});
+ e_data.outlines_color_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RGBA_8,
+ &draw_engine_object_type);
+
GPU_framebuffer_ensure_config(&fbl->expand_fb, {
GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(e_data.outlines_color_tx)
@@ -319,68 +352,60 @@ static void OBJECT_engine_init(void *vedata)
});
}
+ /* Shaders */
if (!e_data.outline_resolve_sh) {
+ /* Outline */
+ e_data.outline_prepass_sh = DRW_shader_create_3D(datatoc_object_outline_prepass_frag_glsl, NULL);
+
e_data.outline_resolve_sh = DRW_shader_create_fullscreen(datatoc_object_outline_resolve_frag_glsl, NULL);
- }
- if (!e_data.outline_resolve_aa_sh) {
e_data.outline_resolve_aa_sh = DRW_shader_create_with_lib(
datatoc_common_fullscreen_vert_glsl, NULL,
datatoc_object_outline_resolve_frag_glsl,
datatoc_common_fxaa_lib_glsl,
"#define FXAA_ALPHA\n"
"#define USE_FXAA\n");
- }
- if (!e_data.outline_detect_sh) {
- e_data.outline_detect_sh = DRW_shader_create_fullscreen(datatoc_object_outline_detect_frag_glsl, NULL);
- }
+ e_data.outline_detect_sh = DRW_shader_create_with_lib(
+ datatoc_common_fullscreen_vert_glsl, NULL,
+ datatoc_object_outline_detect_frag_glsl,
+ datatoc_common_globals_lib_glsl,
+ "#extension GL_ARB_texture_gather : enable\n");
- if (!e_data.outline_fade_sh) {
e_data.outline_fade_sh = DRW_shader_create_fullscreen(datatoc_object_outline_expand_frag_glsl, NULL);
- }
- if (!e_data.object_empty_image_sh) {
+ /* Empty images */
e_data.object_empty_image_sh = DRW_shader_create_with_lib(
datatoc_object_empty_image_vert_glsl, NULL,
datatoc_object_empty_image_frag_glsl,
datatoc_common_globals_lib_glsl, NULL);
- }
- if (!e_data.object_empty_image_wire_sh) {
e_data.object_empty_image_wire_sh = DRW_shader_create_with_lib(
datatoc_object_empty_image_vert_glsl, NULL,
datatoc_object_empty_image_frag_glsl,
datatoc_common_globals_lib_glsl,
"#define USE_WIRE\n");
- }
- if (!e_data.grid_sh) {
+ /* Grid */
e_data.grid_sh = DRW_shader_create_with_lib(
datatoc_object_grid_vert_glsl, NULL,
datatoc_object_grid_frag_glsl,
datatoc_common_globals_lib_glsl, NULL);
- }
- if (!e_data.part_prim_sh) {
+ /* Particles */
e_data.part_prim_sh = DRW_shader_create(
datatoc_object_particle_prim_vert_glsl, NULL, datatoc_gpu_shader_flat_color_frag_glsl, NULL);
- }
- if (!e_data.part_axis_sh) {
e_data.part_axis_sh = DRW_shader_create(
datatoc_object_particle_prim_vert_glsl, NULL, datatoc_gpu_shader_flat_color_frag_glsl,
"#define USE_AXIS\n");
- }
- if (!e_data.part_dot_sh) {
e_data.part_dot_sh = DRW_shader_create(
datatoc_object_particle_dot_vert_glsl, NULL, datatoc_object_particle_dot_frag_glsl, NULL);
- }
- if (!e_data.lightprobe_grid_sh) {
+ /* Lightprobes */
e_data.lightprobe_grid_sh = DRW_shader_create(
- datatoc_object_lightprobe_grid_vert_glsl, NULL, datatoc_gpu_shader_uniform_color_frag_glsl, NULL);
+ datatoc_object_lightprobe_grid_vert_glsl, NULL, datatoc_gpu_shader_flat_id_frag_glsl, NULL);
}
{
@@ -567,6 +592,7 @@ static void OBJECT_engine_free(void)
MEM_SAFE_FREE(e_data.particle_format);
MEM_SAFE_FREE(e_data.empty_image_format);
MEM_SAFE_FREE(e_data.empty_image_wire_format);
+ DRW_SHADER_FREE_SAFE(e_data.outline_prepass_sh);
DRW_SHADER_FREE_SAFE(e_data.outline_resolve_sh);
DRW_SHADER_FREE_SAFE(e_data.outline_resolve_aa_sh);
DRW_SHADER_FREE_SAFE(e_data.outline_detect_sh);
@@ -580,10 +606,10 @@ static void OBJECT_engine_free(void)
DRW_SHADER_FREE_SAFE(e_data.lightprobe_grid_sh);
}
-static DRWShadingGroup *shgroup_outline(DRWPass *pass, const float col[4], GPUShader *sh)
+static DRWShadingGroup *shgroup_outline(DRWPass *pass, const int *ofs, GPUShader *sh)
{
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
- DRW_shgroup_uniform_vec4(grp, "color", col, 1);
+ DRW_shgroup_uniform_int(grp, "baseId", ofs, 1);
return grp;
}
@@ -606,16 +632,95 @@ static DRWShadingGroup *shgroup_points(DRWPass *pass, const float col[4], GPUSha
return grp;
}
+static int *shgroup_theme_id_to_probe_outline_counter(
+ OBJECT_StorageList *stl, int theme_id)
+{
+ switch (theme_id) {
+ case TH_ACTIVE:
+ return &stl->g_data->id_ofs_prb_active;
+ case TH_SELECT:
+ return &stl->g_data->id_ofs_prb_select;
+ case TH_GROUP:
+ return &stl->g_data->id_ofs_prb_select_group;
+ case TH_GROUP_ACTIVE:
+ return &stl->g_data->id_ofs_prb_active_group;
+ case TH_TRANSFORM:
+ default:
+ return &stl->g_data->id_ofs_prb_transform;
+ }
+}
+
+static int *shgroup_theme_id_to_outline_counter(
+ OBJECT_StorageList *stl, int theme_id)
+{
+ switch (theme_id) {
+ case TH_ACTIVE:
+ return &stl->g_data->id_ofs_active;
+ case TH_SELECT:
+ return &stl->g_data->id_ofs_select;
+ case TH_GROUP:
+ return &stl->g_data->id_ofs_select_group;
+ case TH_GROUP_ACTIVE:
+ return &stl->g_data->id_ofs_active_group;
+ case TH_TRANSFORM:
+ default:
+ return &stl->g_data->id_ofs_transform;
+ }
+}
+
+static DRWShadingGroup *shgroup_theme_id_to_probe_planar_outline_shgrp(
+ OBJECT_StorageList *stl, int theme_id)
+{
+ /* does not increment counter */
+ switch (theme_id) {
+ case TH_ACTIVE:
+ return stl->g_data->lightprobes_planar_active;
+ case TH_SELECT:
+ return stl->g_data->lightprobes_planar_select;
+ case TH_GROUP:
+ return stl->g_data->lightprobes_planar_select_group;
+ case TH_GROUP_ACTIVE:
+ return stl->g_data->lightprobes_planar_active_group;
+ case TH_TRANSFORM:
+ default:
+ return stl->g_data->lightprobes_planar_transform;
+ }
+}
+
+static DRWShadingGroup *shgroup_theme_id_to_probe_cube_outline_shgrp(
+ OBJECT_StorageList *stl, int theme_id)
+{
+ /* does not increment counter */
+ switch (theme_id) {
+ case TH_ACTIVE:
+ return stl->g_data->lightprobes_cube_active;
+ case TH_SELECT:
+ return stl->g_data->lightprobes_cube_select;
+ case TH_GROUP:
+ return stl->g_data->lightprobes_cube_select_group;
+ case TH_GROUP_ACTIVE:
+ return stl->g_data->lightprobes_cube_active_group;
+ case TH_TRANSFORM:
+ default:
+ return stl->g_data->lightprobes_cube_transform;
+ }
+}
+
static DRWShadingGroup *shgroup_theme_id_to_outline_or(
OBJECT_StorageList *stl, int theme_id, DRWShadingGroup *fallback)
{
+ int *counter = shgroup_theme_id_to_outline_counter(stl, theme_id);
+ *counter += 1;
+
switch (theme_id) {
case TH_ACTIVE:
return stl->g_data->outlines_active;
case TH_SELECT:
return stl->g_data->outlines_select;
- case TH_GROUP_ACTIVE:
+ case TH_GROUP:
return stl->g_data->outlines_select_group;
+ case TH_GROUP_ACTIVE:
+ return stl->g_data->outlines_active_group;
case TH_TRANSFORM:
return stl->g_data->outlines_transform;
default:
@@ -631,8 +736,10 @@ static DRWShadingGroup *shgroup_theme_id_to_wire_or(
return stl->g_data->wire_active;
case TH_SELECT:
return stl->g_data->wire_select;
- case TH_GROUP_ACTIVE:
+ case TH_GROUP:
return stl->g_data->wire_select_group;
+ case TH_GROUP_ACTIVE:
+ return stl->g_data->wire_active_group;
case TH_TRANSFORM:
return stl->g_data->wire_transform;
default:
@@ -648,8 +755,10 @@ static DRWShadingGroup *shgroup_theme_id_to_point_or(
return stl->g_data->points_active;
case TH_SELECT:
return stl->g_data->points_select;
- case TH_GROUP_ACTIVE:
+ case TH_GROUP:
return stl->g_data->points_select_group;
+ case TH_GROUP_ACTIVE:
+ return stl->g_data->points_active_group;
case TH_TRANSFORM:
return stl->g_data->points_transform;
default:
@@ -726,10 +835,10 @@ static void DRW_shgroup_empty_image(
if (tex) {
DRW_shgroup_instance_format(e_data.empty_image_format, {
- {"objectColor" , DRW_ATTRIB_FLOAT, 4},
- {"size" , DRW_ATTRIB_FLOAT, 1},
- {"offset" , DRW_ATTRIB_FLOAT, 2},
- {"InstanceModelMatrix" , DRW_ATTRIB_FLOAT, 16},
+ {"objectColor", DRW_ATTRIB_FLOAT, 4},
+ {"size", DRW_ATTRIB_FLOAT, 1},
+ {"offset", DRW_ATTRIB_FLOAT, 2},
+ {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
});
struct Gwn_Batch *geom = DRW_cache_image_plane_get();
@@ -746,10 +855,10 @@ static void DRW_shgroup_empty_image(
{
DRW_shgroup_instance_format(e_data.empty_image_wire_format, {
- {"objectColor" , DRW_ATTRIB_FLOAT, 4},
- {"size" , DRW_ATTRIB_FLOAT, 1},
- {"offset" , DRW_ATTRIB_FLOAT, 2},
- {"InstanceModelMatrix" , DRW_ATTRIB_FLOAT, 16}
+ {"objectColor", DRW_ATTRIB_FLOAT, 4},
+ {"size", DRW_ATTRIB_FLOAT, 1},
+ {"offset", DRW_ATTRIB_FLOAT, 2},
+ {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
});
struct Gwn_Batch *geom = DRW_cache_image_plane_wire_get();
@@ -785,39 +894,66 @@ static void OBJECT_cache_init(void *vedata)
OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ OBJECT_PrivateData *g_data;
+ /* TODO : use dpi setting for enabling the second pass */
+ const bool do_outline_expand = false;
if (!stl->g_data) {
/* Alloc transient pointers */
stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
}
+ g_data = stl->g_data;
+
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WIRE;
psl->outlines = DRW_pass_create("Outlines Depth Pass", state);
- GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
+ GPUShader *sh = e_data.outline_prepass_sh;
/* Select */
- stl->g_data->outlines_select = shgroup_outline(psl->outlines, ts.colorSelect, sh);
- stl->g_data->outlines_select_group = shgroup_outline(psl->outlines, ts.colorGroupActive, sh);
+ g_data->outlines_select = shgroup_outline(psl->outlines, &g_data->id_ofs_select, sh);
+ g_data->outlines_select_group = shgroup_outline(psl->outlines, &g_data->id_ofs_select_group, sh);
/* Transform */
- stl->g_data->outlines_transform = shgroup_outline(psl->outlines, ts.colorTransform, sh);
+ g_data->outlines_transform = shgroup_outline(psl->outlines, &g_data->id_ofs_transform, sh);
/* Active */
- stl->g_data->outlines_active = shgroup_outline(psl->outlines, ts.colorActive, sh);
- stl->g_data->outlines_active_group = shgroup_outline(psl->outlines, ts.colorGroupActive, sh);
+ g_data->outlines_active = shgroup_outline(psl->outlines, &g_data->id_ofs_active, sh);
+ g_data->outlines_active_group = shgroup_outline(psl->outlines, &g_data->id_ofs_active_group, sh);
+
+ g_data->id_ofs_select = 0;
+ g_data->id_ofs_select_group = 0;
+ g_data->id_ofs_active = 0;
+ g_data->id_ofs_active_group = 0;
+ g_data->id_ofs_transform = 0;
}
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
- psl->lightprobes = DRW_pass_create("Object Probe Pass", state);
+ DRWPass *pass = psl->lightprobes = DRW_pass_create("Object Probe Pass", state);
+ struct Gwn_Batch *sphere = DRW_cache_sphere_get();
+ struct Gwn_Batch *quad = DRW_cache_quad_get();
/* Cubemap */
- stl->g_data->lightprobes_cube = shgroup_instance(psl->lightprobes, DRW_cache_sphere_get());
+ g_data->lightprobes_cube_select = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_select);
+ g_data->lightprobes_cube_select_group = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_select_group);
+ g_data->lightprobes_cube_active = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_active);
+ g_data->lightprobes_cube_active_group = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_active_group);
+ g_data->lightprobes_cube_transform = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_transform);
/* Planar */
- stl->g_data->lightprobes_planar = shgroup_instance(psl->lightprobes, DRW_cache_quad_get());
+ g_data->lightprobes_planar_select = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_select);
+ g_data->lightprobes_planar_select_group = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_select_group);
+ g_data->lightprobes_planar_active = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_active);
+ g_data->lightprobes_planar_active_group = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_active_group);
+ g_data->lightprobes_planar_transform = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_transform);
+
+ g_data->id_ofs_prb_select = 0;
+ g_data->id_ofs_prb_select_group = 0;
+ g_data->id_ofs_prb_active = 0;
+ g_data->id_ofs_prb_active_group = 0;
+ g_data->id_ofs_prb_transform = 0;
}
{
@@ -831,25 +967,29 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_search = DRW_pass_create("Outlines Detect Pass", state);
DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_detect_sh, psl->outlines_search);
- DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_color_tx);
+ DRW_shgroup_uniform_texture_ref(grp, "outlineId", &e_data.outlines_id_tx);
DRW_shgroup_uniform_texture_ref(grp, "outlineDepth", &e_data.outlines_depth_tx);
DRW_shgroup_uniform_texture_ref(grp, "sceneDepth", &dtxl->depth);
+ DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
DRW_shgroup_uniform_float(grp, "alphaOcclu", &alphaOcclu, 1);
+ DRW_shgroup_uniform_int(grp, "idOffsets", &stl->g_data->id_ofs_active, 5);
DRW_shgroup_call_add(grp, quad, NULL);
psl->outlines_expand = DRW_pass_create("Outlines Expand Pass", state);
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_expand);
DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_blur_tx);
- DRW_shgroup_uniform_bool(grp, "doExpand", &bTrue, 1);
+ DRW_shgroup_uniform_bool(grp, "doExpand", (do_outline_expand) ? &bTrue : &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
psl->outlines_bleed = DRW_pass_create("Outlines Bleed Pass", state);
- grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_bleed);
- DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_color_tx);
- DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
- DRW_shgroup_call_add(grp, quad, NULL);
+ if (do_outline_expand) {
+ grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_bleed);
+ DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_color_tx);
+ DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
}
{
@@ -857,9 +997,10 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_resolve = DRW_pass_create("Outlines Resolve Pass", state);
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ GPUTexture **outline_tx = (do_outline_expand) ? &e_data.outlines_blur_tx : &e_data.outlines_color_tx;
DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_aa_sh, psl->outlines_resolve);
- DRW_shgroup_uniform_texture_ref(grp, "outlineBluredColor", &e_data.outlines_blur_tx);
+ DRW_shgroup_uniform_texture_ref(grp, "outlineBluredColor", outline_tx);
DRW_shgroup_uniform_vec2(grp, "rcpDimensions", e_data.inv_viewport_size, 1);
DRW_shgroup_call_add(grp, quad, NULL);
}
@@ -1253,11 +1394,9 @@ static void DRW_shgroup_lamp(OBJECT_StorageList *stl, Object *ob, ViewLayer *vie
/* First circle */
DRW_shgroup_call_dynamic_add(stl->g_data->lamp_circle, ob->obmat[3], color);
- /* draw dashed outer circle if shadow is on. remember some lamps can't have certain shadows! */
+ /* draw dashed outer circle for shadow */
if (la->type != LA_HEMI) {
- if ((la->mode & LA_SHAD_RAY) || ((la->mode & LA_SHAD_BUF) && (la->type == LA_SPOT))) {
- DRW_shgroup_call_dynamic_add(stl->g_data->lamp_circle_shadow, ob->obmat[3], color);
- }
+ DRW_shgroup_call_dynamic_add(stl->g_data->lamp_circle_shadow, ob->obmat[3], color);
}
/* Distance */
@@ -1593,7 +1732,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl
static float one = 1.0f;
LightProbe *prb = (LightProbe *)ob->data;
bool do_outlines = ((ob->base_flag & BASE_SELECTED) != 0);
- DRW_object_wire_theme_get(ob, view_layer, &color);
+ int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color);
OBJECT_LightProbeEngineData *prb_data =
(OBJECT_LightProbeEngineData *)DRW_object_engine_data_ensure(
@@ -1604,6 +1743,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl
NULL);
if ((DRW_state_is_select() || do_outlines) && ((prb->flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0)) {
+ int *call_id = shgroup_theme_id_to_probe_outline_counter(stl, theme_id);
if (prb->type == LIGHTPROBE_TYPE_GRID) {
/* Update transforms */
@@ -1640,7 +1780,8 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl
prb_data->cell_count = prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z;
DRWShadingGroup *grp = DRW_shgroup_create(e_data.lightprobe_grid_sh, psl->lightprobes);
- DRW_shgroup_uniform_vec4(grp, "color", color, 1);
+ DRW_shgroup_uniform_int_copy(grp, "call_id", *call_id);
+ DRW_shgroup_uniform_int(grp, "baseId", call_id, 1); /* that's correct */
DRW_shgroup_uniform_vec3(grp, "corner", prb_data->corner, 1);
DRW_shgroup_uniform_vec3(grp, "increment_x", prb_data->increment_x, 1);
DRW_shgroup_uniform_vec3(grp, "increment_y", prb_data->increment_y, 1);
@@ -1653,12 +1794,18 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl
prb_data->draw_size = prb->data_draw_size * 0.1f;
unit_m4(prb_data->probe_cube_mat);
copy_v3_v3(prb_data->probe_cube_mat[3], ob->obmat[3]);
- DRW_shgroup_call_dynamic_add(stl->g_data->lightprobes_cube, color, &prb_data->draw_size, prb_data->probe_cube_mat);
+
+ DRWShadingGroup *grp = shgroup_theme_id_to_probe_cube_outline_shgrp(stl, theme_id);
+ DRW_shgroup_call_dynamic_add(grp, call_id, &prb_data->draw_size, prb_data->probe_cube_mat);
}
else {
prb_data->draw_size = 1.0f;
- DRW_shgroup_call_dynamic_add(stl->g_data->lightprobes_planar, color, &prb_data->draw_size, ob->obmat);
+
+ DRWShadingGroup *grp = shgroup_theme_id_to_probe_planar_outline_shgrp(stl, theme_id);
+ DRW_shgroup_call_dynamic_add(grp, call_id, &prb_data->draw_size, ob->obmat);
}
+
+ *call_id += 1;
}
switch (prb->type) {
@@ -2101,14 +2248,41 @@ static void OBJECT_draw_scene(void *vedata)
OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
OBJECT_FramebufferList *fbl = ((OBJECT_Data *)vedata)->fbl;
+ OBJECT_PrivateData *g_data = stl->g_data;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+
+ int id_ct_select = g_data->id_ofs_select;
+ int id_ct_select_group = g_data->id_ofs_select_group;
+ int id_ct_active = g_data->id_ofs_active;
+ int id_ct_active_group = g_data->id_ofs_active_group;
+ int id_ct_transform = g_data->id_ofs_transform;
+
+ int id_ct_prb_select = g_data->id_ofs_prb_select;
+ int id_ct_prb_select_group = g_data->id_ofs_prb_select_group;
+ int id_ct_prb_active = g_data->id_ofs_prb_active;
+ int id_ct_prb_active_group = g_data->id_ofs_prb_active_group;
+ int id_ct_prb_transform = g_data->id_ofs_prb_transform;
+
+ int outline_calls = id_ct_select + id_ct_select_group + id_ct_active + id_ct_active_group + id_ct_transform;
+ outline_calls += id_ct_prb_select + id_ct_prb_select_group + id_ct_prb_active + id_ct_prb_active_group + id_ct_prb_transform;
float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- if (DRW_state_is_fbo()) {
+ if (DRW_state_is_fbo() && outline_calls > 0) {
DRW_stats_group_start("Outlines");
-
+
+ g_data->id_ofs_active = 1;
+ g_data->id_ofs_active_group = g_data->id_ofs_active + id_ct_active + id_ct_prb_active + 1;
+ g_data->id_ofs_select = g_data->id_ofs_active_group + id_ct_active_group + id_ct_prb_active_group + 1;
+ g_data->id_ofs_select_group = g_data->id_ofs_select + id_ct_select + id_ct_prb_select + 1;
+ g_data->id_ofs_transform = g_data->id_ofs_select_group + id_ct_select_group + id_ct_prb_select_group + 1;
+
+ g_data->id_ofs_prb_active = g_data->id_ofs_active + id_ct_active;
+ g_data->id_ofs_prb_active_group = g_data->id_ofs_active_group + id_ct_active_group;
+ g_data->id_ofs_prb_select = g_data->id_ofs_select + id_ct_select;
+ g_data->id_ofs_prb_select_group = g_data->id_ofs_select_group + id_ct_select_group;
+ g_data->id_ofs_prb_transform = g_data->id_ofs_transform + id_ct_transform;
+
/* Render filled polygon on a separate framebuffer */
GPU_framebuffer_bind(fbl->outlines_fb);
GPU_framebuffer_clear_color_depth(fbl->outlines_fb, clearcol, 1.0f);
@@ -2155,11 +2329,12 @@ static void OBJECT_draw_scene(void *vedata)
if (e_data.draw_grid) {
GPU_framebuffer_bind(dfbl->color_only_fb);
DRW_draw_pass(psl->grid);
- GPU_framebuffer_texture_attach(dfbl->default_fb, dtxl->depth, 0, 0);
}
/* Combine with scene buffer last */
- DRW_draw_pass(psl->outlines_resolve);
+ if (outline_calls > 0) {
+ DRW_draw_pass(psl->outlines_resolve);
+ }
}
/* This has to be freed only after drawing empties! */
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
new file mode 100644
index 00000000000..59e34ee7ba9
--- /dev/null
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2016, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file overlay_mode.c
+ * \ingroup draw_engine
+ */
+
+#include "DRW_render.h"
+
+#include "GPU_shader.h"
+#include "DNA_view3d_types.h"
+
+/* Structures */
+typedef struct OVERLAY_StorageList {
+ struct OVERLAY_PrivateData *g_data;
+} OVERLAY_StorageList;
+
+typedef struct OVERLAY_PassList {
+ struct DRWPass *face_orientation_pass;
+} OVERLAY_PassList;
+
+typedef struct OVERLAY_Data {
+ void *engine_type;
+ DRWViewportEmptyList *fbl;
+ DRWViewportEmptyList *txl;
+ OVERLAY_PassList *psl;
+ OVERLAY_StorageList *stl;
+} OVERLAY_Data;
+
+typedef struct OVERLAY_PrivateData {
+ DRWShadingGroup *face_orientation_shgrp;
+ int overlays;
+} OVERLAY_PrivateData; /* Transient data */
+
+typedef struct OVERLAY_MaterialData {
+ /* Solid color */
+ float color[3];
+
+ /* Linked shgroup for drawing */
+ DRWShadingGroup *shgrp;
+} OVERLAY_MaterialData;
+
+/* *********** STATIC *********** */
+static struct {
+ /* Face orientation shader */
+ struct GPUShader *face_orientation_sh;
+
+} e_data = {NULL};
+
+/* Shaders */
+extern char datatoc_overlay_face_orientation_frag_glsl[];
+extern char datatoc_overlay_face_orientation_vert_glsl[];
+
+
+/* Functions */
+static void overlay_engine_init(void *UNUSED(vedata))
+{
+ if (!e_data.face_orientation_sh) {
+ /* Face orientation */
+ e_data.face_orientation_sh = DRW_shader_create(datatoc_overlay_face_orientation_vert_glsl, NULL, datatoc_overlay_face_orientation_frag_glsl, "\n");
+ }
+}
+
+static void overlay_cache_init(void *vedata)
+{
+
+ OVERLAY_Data * data = (OVERLAY_Data *)vedata;
+ OVERLAY_PassList *psl = data->psl;
+ OVERLAY_StorageList *stl = data->stl;
+
+ const DRWContextState *DCS = DRW_context_state_get();
+
+ if (!stl->g_data) {
+ /* Alloc transient pointers */
+ stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
+ }
+
+ View3D *v3d = DCS->v3d;
+ int bm_face_orientation = DRW_STATE_ADDITIVE;
+ if (v3d) {
+ stl->g_data->overlays = v3d->overlays;
+
+ /*
+ Solid flat/studio lighting gives strange results when blending with the defaults.
+ */
+ if (v3d->drawtype == OB_SOLID) {
+ bm_face_orientation = DRW_STATE_BLEND;
+ }
+ }
+ else {
+ stl->g_data->overlays = 0;
+ }
+
+ /* Face Orientation Pass */
+ if (stl->g_data->overlays & V3D_OVERLAY_FACE_ORIENTATION)
+ {
+ int state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | bm_face_orientation;
+ psl->face_orientation_pass = DRW_pass_create("Face Orientation", state);
+ stl->g_data->face_orientation_shgrp = DRW_shgroup_create(e_data.face_orientation_sh, psl->face_orientation_pass);
+ }
+}
+
+static void overlay_cache_populate(void *vedata, Object *ob)
+{
+ OVERLAY_Data * data = (OVERLAY_Data *)vedata;
+ OVERLAY_StorageList *stl = data->stl;
+ OVERLAY_PrivateData *pd = stl->g_data;
+
+ if (!DRW_object_is_renderable(ob))
+ return;
+
+ struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ if (geom) {
+ /* Face Orientation */
+ if (stl->g_data->overlays & V3D_OVERLAY_FACE_ORIENTATION) {
+ DRW_shgroup_call_add(pd->face_orientation_shgrp, geom, ob->obmat);
+ }
+ }
+}
+
+static void overlay_cache_finish(void *UNUSED(vedata))
+{
+}
+
+static void overlay_draw_scene(void *vedata)
+{
+ OVERLAY_Data * data = (OVERLAY_Data *)vedata;
+ OVERLAY_PassList *psl = data->psl;
+
+ DRW_draw_pass(psl->face_orientation_pass);
+}
+
+static void overlay_engine_free(void)
+{
+ DRW_SHADER_FREE_SAFE(e_data.face_orientation_sh);
+}
+
+static const DrawEngineDataSize overlay_data_size = DRW_VIEWPORT_DATA_SIZE(OVERLAY_Data);
+
+DrawEngineType draw_engine_overlay_type = {
+ NULL, NULL,
+ N_("OverlayEngine"),
+ &overlay_data_size,
+ &overlay_engine_init,
+ &overlay_engine_free,
+ &overlay_cache_init,
+ &overlay_cache_populate,
+ &overlay_cache_finish,
+ NULL,
+ &overlay_draw_scene,
+ NULL,
+ NULL,
+ NULL,
+};
+
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 749c3e71368..1d3d31ab54d 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -139,7 +139,9 @@ bool DRW_pose_mode_armature(Object *ob, Object *active_ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
/* Pode armature is handled by pose mode engine. */
- if ((ob == active_ob) && ((draw_ctx->object_mode & OB_MODE_POSE) != 0)) {
+ if (((ob == active_ob) || (ob->base_flag & BASE_SELECTED)) &&
+ ((draw_ctx->object_mode & OB_MODE_POSE) != 0))
+ {
return true;
}
diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c
index 65f4653591f..4fb4464df06 100644
--- a/source/blender/draw/modes/sculpt_mode.c
+++ b/source/blender/draw/modes/sculpt_mode.c
@@ -202,7 +202,7 @@ static void SCULPT_cache_populate(void *vedata, Object *ob)
* but this avoids waiting on first stroke) */
Scene *scene = draw_ctx->scene;
- BKE_sculpt_update_mesh_elements(&draw_ctx->eval_ctx, scene, scene->toolsettings->sculpt, ob, false, false);
+ BKE_sculpt_update_mesh_elements(draw_ctx->depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
}
PBVH *pbvh = ob->sculpt->pbvh;
diff --git a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl
index b47b3ee1cf4..85a656df906 100644
--- a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl
+++ b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl
@@ -11,6 +11,11 @@ uniform vec3 increment_x;
uniform vec3 increment_y;
uniform vec3 increment_z;
+uniform int call_id; /* we don't want the builtin callId which would be 0. */
+uniform int baseId;
+
+flat out uint finalId;
+
void main()
{
vec3 ls_cell_location;
@@ -25,4 +30,6 @@ void main()
increment_z * ls_cell_location.z);
gl_Position = ViewProjectionMatrix * vec4(pos * 0.02 * sphere_size + ws_cell_location, 1.0);
+
+ finalId = uint(baseId + call_id);
} \ No newline at end of file
diff --git a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
index dc0ea938436..771b6bcdc2e 100644
--- a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
@@ -3,77 +3,87 @@ in vec4 uvcoordsvar;
out vec4 FragColor;
-uniform sampler2D outlineColor;
+uniform usampler2D outlineId;
uniform sampler2D outlineDepth;
uniform sampler2D sceneDepth;
+uniform int idOffsets[5];
+
uniform float alphaOcclu;
uniform vec2 viewportSize;
-void search_outline(ivec2 uv, vec4 ref_col, inout bool ref_occlu, inout bool outline)
+vec4 convert_id_to_color(int id)
{
- if (!outline) {
- vec4 color = texelFetch(outlineColor, uv, 0).rgba;
- if (color != ref_col) {
- outline = true;
- }
- else {
- float depth = texelFetch(outlineDepth, uv, 0).r;
- float scene_depth = texelFetch(sceneDepth, uv, 0).r;
- bool occlu = (depth > scene_depth);
-
- if (occlu != ref_occlu && !ref_occlu) {
- outline = true;
- }
- }
+ if (id == 0) {
+ return vec4(0.0);
+ }
+ if (id < idOffsets[1]) {
+ return colorActive;
+ }
+ else if (id < idOffsets[2]) {
+ return colorGroupActive;
+ }
+ else if (id < idOffsets[3]) {
+ return colorSelect;
+ }
+ else if (id < idOffsets[4]) {
+ return colorGroup;
+ }
+ else {
+ return colorTransform;
}
}
void main()
{
- ivec2 uv = ivec2(gl_FragCoord.xy);
-
- vec4 color[4];
- /* Idea : Use a 16bit ID to identify the color
- * and store the colors in a UBO. And fetch all ids
- * for discontinuity check with one textureGather \o/ */
- vec4 ref_col = texelFetch(outlineColor, uv, 0).rgba;
- color[0] = texelFetchOffset(outlineColor, uv, 0, ivec2( 1, 0)).rgba;
- color[1] = texelFetchOffset(outlineColor, uv, 0, ivec2( 0, 1)).rgba;
- color[2] = texelFetchOffset(outlineColor, uv, 0, ivec2(-1, 0)).rgba;
- color[3] = texelFetchOffset(outlineColor, uv, 0, ivec2( 0, -1)).rgba;
-
- /* TODO GATHER */
- vec4 depths;
- float depth = texelFetch(outlineDepth, uv, 0).r;
- depths.x = texelFetchOffset(outlineDepth, uv, 0, ivec2( 1, 0)).r;
- depths.y = texelFetchOffset(outlineDepth, uv, 0, ivec2( 0, 1)).r;
- depths.z = texelFetchOffset(outlineDepth, uv, 0, ivec2(-1, 0)).r;
- depths.w = texelFetchOffset(outlineDepth, uv, 0, ivec2( 0, -1)).r;
-
- vec4 scene_depths;
- float scene_depth = texelFetch(sceneDepth, uv, 0).r;
- scene_depths.x = texelFetchOffset(sceneDepth, uv, 0, ivec2( 1, 0)).r;
- scene_depths.y = texelFetchOffset(sceneDepth, uv, 0, ivec2( 0, 1)).r;
- scene_depths.z = texelFetchOffset(sceneDepth, uv, 0, ivec2(-1, 0)).r;
- scene_depths.w = texelFetchOffset(sceneDepth, uv, 0, ivec2( 0, -1)).r;
-
- bool ref_occlu = (depth > scene_depth);
- bool outline = false;
-
-#if 1
- bvec4 occlu = (!ref_occlu) ? notEqual(greaterThan(depths, scene_depths), bvec4(ref_occlu)) : bvec4(false);
- outline = (!outline) ? (color[0] != ref_col) || occlu.x : true;
- outline = (!outline) ? (color[1] != ref_col) || occlu.y : true;
- outline = (!outline) ? (color[2] != ref_col) || occlu.z : true;
- outline = (!outline) ? (color[3] != ref_col) || occlu.w : true;
+ ivec2 texel = ivec2(gl_FragCoord.xy);
+
+#ifdef GL_ARB_texture_gather
+ vec2 texel_size = 1.0 / vec2(textureSize(outlineId, 0).xy);
+ vec2 uv1 = ceil(gl_FragCoord.xy) * texel_size - texel_size;
+ vec2 uv2 = ceil(gl_FragCoord.xy) * texel_size;
+
+ /* Samples order is CW starting from top left. */
+ uvec4 tmp1 = textureGather(outlineId, uv1);
+ uvec4 tmp2 = textureGather(outlineId, uv2);
+
+ uint ref_id = tmp1.y;
+ uvec4 id = uvec4(tmp1.xz, tmp2.xz);
#else
- search_outline(uv + ivec2( 1, 0), ref_col, ref_occlu, outline);
- search_outline(uv + ivec2( 0, 1), ref_col, ref_occlu, outline);
- search_outline(uv + ivec2(-1, 0), ref_col, ref_occlu, outline);
- search_outline(uv + ivec2( 0, -1), ref_col, ref_occlu, outline);
+ uvec4 id;
+ uint ref_id = texelFetch(outlineId, texel, 0).r;
+ id.x = texelFetchOffset(outlineId, texel, 0, ivec2(-1, 0)).r;
+ id.y = texelFetchOffset(outlineId, texel, 0, ivec2( 0, -1)).r;
+ id.z = texelFetchOffset(outlineId, texel, 0, ivec2( 0, 1)).r;
+ id.w = texelFetchOffset(outlineId, texel, 0, ivec2( 1, 0)).r;
#endif
- FragColor = ref_col;
- FragColor.a *= (outline) ? (ref_occlu) ? alphaOcclu : 1.0 : 0.0;
+ bool outline = any(notEqual(id, uvec4(ref_id)));
+
+ ivec2 depth_texel = texel;
+ /* If texel is an outline but has no valid id ...
+ * replace id and depth texel by a valid one.
+ * This keeps the outline thickness consistent everywhere. */
+ if (ref_id == 0u && outline) {
+ depth_texel = (id.x != 0u) ? texel + ivec2(-1, 0) : depth_texel;
+ depth_texel = (id.y != 0u) ? texel + ivec2( 0, -1) : depth_texel;
+ depth_texel = (id.z != 0u) ? texel + ivec2( 0, 1) : depth_texel;
+ depth_texel = (id.w != 0u) ? texel + ivec2( 1, 0) : depth_texel;
+
+ ref_id = (id.x != 0u) ? id.x : ref_id;
+ ref_id = (id.y != 0u) ? id.y : ref_id;
+ ref_id = (id.z != 0u) ? id.z : ref_id;
+ ref_id = (id.w != 0u) ? id.w : ref_id;
+ }
+
+ float ref_depth = texelFetch(outlineDepth, depth_texel, 0).r;
+ float scene_depth = texelFetch(sceneDepth, depth_texel, 0).r;
+
+ /* Avoid bad cases of zfighting for occlusion only. */
+ const float epsilon = 3.0 / 8388608.0;
+ bool occluded = (ref_depth > scene_depth + epsilon);
+
+ FragColor = convert_id_to_color(int(ref_id));
+ FragColor.a *= (occluded) ? alphaOcclu : 1.0;
+ FragColor.a = (outline) ? FragColor.a : 0.0;
}
diff --git a/source/blender/draw/modes/shaders/object_outline_prepass_frag.glsl b/source/blender/draw/modes/shaders/object_outline_prepass_frag.glsl
new file mode 100644
index 00000000000..776adb787ad
--- /dev/null
+++ b/source/blender/draw/modes/shaders/object_outline_prepass_frag.glsl
@@ -0,0 +1,10 @@
+uniform int callId;
+uniform int baseId;
+
+/* using uint because 16bit uint can contain more ids than int. */
+out uint outId;
+
+void main()
+{
+ outId = uint(baseId + callId);
+}
diff --git a/source/blender/draw/modes/shaders/overlay_face_orientation_frag.glsl b/source/blender/draw/modes/shaders/overlay_face_orientation_frag.glsl
new file mode 100644
index 00000000000..21ed07683f0
--- /dev/null
+++ b/source/blender/draw/modes/shaders/overlay_face_orientation_frag.glsl
@@ -0,0 +1,10 @@
+uniform vec3 color_towards = vec3(0.0, 0.0, 1.0);
+uniform vec3 color_outwards = vec3(1.0, 0.0, 0.0);
+
+out vec4 fragColor;
+
+
+void main()
+{
+ fragColor = vec4(gl_FrontFacing ? color_towards: color_outwards, 1.0);
+}
diff --git a/source/blender/draw/modes/shaders/overlay_face_orientation_vert.glsl b/source/blender/draw/modes/shaders/overlay_face_orientation_vert.glsl
new file mode 100644
index 00000000000..d8a72f28eee
--- /dev/null
+++ b/source/blender/draw/modes/shaders/overlay_face_orientation_vert.glsl
@@ -0,0 +1,7 @@
+uniform mat4 ModelViewProjectionMatrix;
+in vec3 pos;
+
+void main()
+{
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+}
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt
index e626636e1ab..57a46aecfdc 100644
--- a/source/blender/editors/CMakeLists.txt
+++ b/source/blender/editors/CMakeLists.txt
@@ -50,14 +50,13 @@ if(WITH_BLENDER)
add_subdirectory(space_graph)
add_subdirectory(space_image)
add_subdirectory(space_info)
- add_subdirectory(space_logic)
add_subdirectory(space_nla)
add_subdirectory(space_node)
add_subdirectory(space_outliner)
add_subdirectory(space_script)
add_subdirectory(space_sequencer)
add_subdirectory(space_text)
- add_subdirectory(space_time)
+ add_subdirectory(space_topbar)
add_subdirectory(space_userpref)
add_subdirectory(space_view3d)
add_subdirectory(transform)
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 4af8089ffea..36402b82cbf 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2817,7 +2817,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* deselect all other channels */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan) ED_pose_de_selectall(ob, SEL_DESELECT, false);
+ if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false);
/* only select channels in group and group itself */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next)
@@ -2827,7 +2827,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
else {
/* select group by itself */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan) ED_pose_de_selectall(ob, SEL_DESELECT, false);
+ if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false);
agrp->flag |= AGRP_SELECTED;
}
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 9a07eaf896c..623a3e82ecc 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -167,7 +167,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+ immUniformThemeColorShadeAlpha(TH_ANIM_ACTIVE, -25, -30);
+ //immUniformColor4f(0.8f, 0.44f, 0.1f, 0.2f); /* XXX: Fix this hardcoded color (anim_active) */
/* only draw two separate 'curtains' if there's no overlap between them */
if (PSFRA < PEFRA + end_frame_width) {
@@ -185,6 +186,55 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
}
/* *************************************************** */
+/* SCENE FRAME RANGE */
+
+/* Draw frame range guides (for scene frame range) in background */
+// TODO: Should we still show these when preview range is enabled?
+void ANIM_draw_framerange(Scene *scene, View2D *v2d)
+{
+ /* Don't draw frame range when preview range is enabled.
+ * Otherwise we get nasty/confusing visual conflicts
+ */
+ if (PRVRANGEON) {
+ return;
+ }
+
+ /* draw darkened area outside of active timeline frame range */
+ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+
+ Gwn_VertFormat *format = immVertexFormat();
+ unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformThemeColorShadeAlpha(TH_BACK, -25, -100);
+
+ if (SFRA < EFRA) {
+ immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
+ immRectf(pos, (float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ }
+ else {
+ immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ }
+
+ glDisable(GL_BLEND);
+
+ /* thin lines where the actual frames are */
+ immUniformThemeColorShade(TH_BACK, -60);
+
+ immBegin(GWN_PRIM_LINES, 4);
+
+ immVertex2f(pos, (float)SFRA, v2d->cur.ymin);
+ immVertex2f(pos, (float)SFRA, v2d->cur.ymax);
+
+ immVertex2f(pos, (float)EFRA, v2d->cur.ymin);
+ immVertex2f(pos, (float)EFRA, v2d->cur.ymax);
+
+ immEnd();
+ immUnbindProgram();
+}
+
+/* *************************************************** */
/* NLA-MAPPING UTILITIES (required for drawing and also editing keyframes) */
/* Obtain the AnimData block providing NLA-mapping for the given channel (if applicable) */
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 85bcfb603cd..dec41248053 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -230,6 +230,7 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
ac->mode = saction->mode;
return true;
}
+
case SACTCONT_DOPESHEET: /* DopeSheet */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
@@ -240,6 +241,16 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
ac->mode = saction->mode;
return true;
+ case SACTCONT_TIMELINE: /* Timeline */
+ /* update scene-pointer (no need to check for pinning yet, as not implemented) */
+ saction->ads.source = (ID *)ac->scene;
+
+ ac->datatype = ANIMCONT_TIMELINE;
+ ac->data = &saction->ads;
+
+ ac->mode = saction->mode;
+ return true;
+
default: /* unhandled yet */
ac->datatype = ANIMCONT_NONE;
ac->data = NULL;
@@ -2062,24 +2073,6 @@ static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data,
return 0;
switch (GS(owner_id->name)) {
- case ID_MA:
- {
- Material *ma = (Material *)owner_id;
- mtex = (MTex **)(&ma->mtex);
- break;
- }
- case ID_LA:
- {
- Lamp *la = (Lamp *)owner_id;
- mtex = (MTex **)(&la->mtex);
- break;
- }
- case ID_WO:
- {
- World *wo = (World *)owner_id;
- mtex = (MTex **)(&wo->mtex);
- break;
- }
case ID_PA:
{
ParticleSettings *part = (ParticleSettings *)owner_id;
@@ -3262,6 +3255,15 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F
}
+ /* Timeline Mode - Basically the same as dopesheet, except we only have the summary for now */
+ case ANIMCONT_TIMELINE:
+ {
+ /* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
+ break;
+ }
+
/* Special/Internal Use */
case ANIMCONT_CHANNEL: /* animation channel */
{
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index e43735c51fb..b31c1aa0b4d 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -570,11 +570,10 @@ static int ed_markers_poll_markers_exist(bContext *C)
static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, const wmEvent *event,
int (*invoke_func)(bContext *, wmOperator *, const wmEvent *))
{
- ScrArea *sa = CTX_wm_area(C);
int retval = OPERATOR_PASS_THROUGH;
-
+
/* removed check for Y coord of event, keymap has bounbox now */
-
+
/* allow operator to run now */
if (invoke_func)
retval = invoke_func(C, op, event);
@@ -582,15 +581,13 @@ static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, const wm
retval = op->type->exec(C, op);
else
BKE_report(op->reports, RPT_ERROR, "Programming error: operator does not actually have code to do anything!");
-
- /* return status modifications - for now, make this spacetype dependent as above */
- if (sa->spacetype != SPACE_TIME) {
- /* unless successful, must add "pass-through" to let normal operator's have a chance at tackling this event */
- if ((retval & (OPERATOR_FINISHED | OPERATOR_INTERFACE)) == 0) {
- retval |= OPERATOR_PASS_THROUGH;
- }
+
+
+ /* unless successful, must add "pass-through" to let normal operator's have a chance at tackling this event */
+ if ((retval & (OPERATOR_FINISHED | OPERATOR_INTERFACE)) == 0) {
+ retval |= OPERATOR_PASS_THROUGH;
}
-
+
return retval;
}
@@ -690,8 +687,7 @@ typedef struct MarkerMove {
static bool ed_marker_move_use_time(MarkerMove *mm)
{
- if (((mm->slink->spacetype == SPACE_TIME) && !(((SpaceTime *)mm->slink)->flag & TIME_DRAWFRAMES)) ||
- ((mm->slink->spacetype == SPACE_SEQ) && !(((SpaceSeq *)mm->slink)->flag & SEQ_DRAWFRAMES)) ||
+ if (((mm->slink->spacetype == SPACE_SEQ) && !(((SpaceSeq *)mm->slink)->flag & SEQ_DRAWFRAMES)) ||
((mm->slink->spacetype == SPACE_ACTION) && (((SpaceAction *)mm->slink)->flag & SACTION_DRAWTIME)) ||
((mm->slink->spacetype == SPACE_IPO) && !(((SpaceIpo *)mm->slink)->flag & SIPO_DRAWTIME)) ||
((mm->slink->spacetype == SPACE_NLA) && !(((SpaceNla *)mm->slink)->flag & SNLA_DRAWTIME)))
@@ -935,10 +931,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even
mm->evtx = event->x;
fac = ((float)(event->x - mm->firstx) * dx);
- if (mm->slink->spacetype == SPACE_TIME)
- apply_keyb_grid(event->shift, event->ctrl, &fac, 0.0, FPS, 0.1 * FPS, 0);
- else
- apply_keyb_grid(event->shift, event->ctrl, &fac, 0.0, 1.0, 0.1, 0 /*was: U.flag & USER_AUTOGRABGRID*/);
+ apply_keyb_grid(event->shift, event->ctrl, &fac, 0.0, 1.0, 0.1, 0 /*was: U.flag & USER_AUTOGRABGRID*/);
RNA_int_set(op->ptr, "frames", (int)fac);
ed_marker_move_apply(C, op);
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index f22c8c5b403..eace5af4701 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -75,7 +75,7 @@ static int change_frame_poll(bContext *C)
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
*/
if (sa) {
- if (ELEM(sa->spacetype, SPACE_TIME, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
return true;
}
else if (sa->spacetype == SPACE_IPO) {
@@ -86,7 +86,7 @@ static int change_frame_poll(bContext *C)
}
}
- CTX_wm_operator_poll_msg_set(C, "Expected an timeline/animation area to be active");
+ CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
return false;
}
@@ -276,6 +276,116 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
+
+/* ****************** Start/End Frame Operators *******************************/
+
+static int anim_set_end_frames_poll(bContext *C)
+{
+ ScrArea *sa = CTX_wm_area(C);
+
+ /* XXX temp? prevent changes during render */
+ if (G.is_rendering) return false;
+
+ /* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
+ * this shouldn't show up in 3D editor (or others without 2D timeline view) via search
+ */
+ if (sa) {
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
+ return true;
+ }
+ }
+
+ CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
+ return false;
+}
+
+static int anim_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+ int frame;
+
+ if (scene == NULL)
+ return OPERATOR_CANCELLED;
+
+ frame = CFRA;
+
+ /* if Preview Range is defined, set the 'start' frame for that */
+ if (PRVRANGEON)
+ scene->r.psfra = frame;
+ else
+ scene->r.sfra = frame;
+
+ if (PEFRA < frame) {
+ if (PRVRANGEON)
+ scene->r.pefra = frame;
+ else
+ scene->r.efra = frame;
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+static void ANIM_OT_start_frame_set(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set Start Frame";
+ ot->idname = "ANIM_OT_start_frame_set";
+ ot->description = "Set the start frame";
+
+ /* api callbacks */
+ ot->exec = anim_set_sfra_exec;
+ ot->poll = anim_set_end_frames_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
+static int anim_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+ int frame;
+
+ if (scene == NULL)
+ return OPERATOR_CANCELLED;
+
+ frame = CFRA;
+
+ /* if Preview Range is defined, set the 'end' frame for that */
+ if (PRVRANGEON)
+ scene->r.pefra = frame;
+ else
+ scene->r.efra = frame;
+
+ if (PSFRA > frame) {
+ if (PRVRANGEON)
+ scene->r.psfra = frame;
+ else
+ scene->r.sfra = frame;
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+static void ANIM_OT_end_frame_set(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set End Frame";
+ ot->idname = "ANIM_OT_end_frame_set";
+ ot->description = "Set the end frame";
+
+ /* api callbacks */
+ ot->exec = anim_set_efra_exec;
+ ot->poll = anim_set_end_frames_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
/* ****************** set preview range operator ****************************/
static int previewrange_define_exec(bContext *C, wmOperator *op)
@@ -383,6 +493,9 @@ void ED_operatortypes_anim(void)
/* Animation Editors only -------------------------- */
WM_operatortype_append(ANIM_OT_change_frame);
+ WM_operatortype_append(ANIM_OT_start_frame_set);
+ WM_operatortype_append(ANIM_OT_end_frame_set);
+
WM_operatortype_append(ANIM_OT_previewrange_set);
WM_operatortype_append(ANIM_OT_previewrange_clear);
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 12803854a42..98ad2041018 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -560,7 +560,6 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
{
const float icon_sz = U.widget_unit * 0.5f * yscale_fac;
const float half_icon_sz = 0.5f * icon_sz;
- const float smaller_sz = 0.35f * icon_sz;
glEnable(GL_BLEND);
@@ -585,24 +584,39 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
copy_v4_v4(unsel_mhcol, unsel_color);
unsel_mhcol[3] *= 0.8f;
- unsigned int pos_id = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- /* NOTE: the tradeoff for changing colors between each draw is dwarfed by the cost of checking validity */
+ unsigned int block_ct = 0;
for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) {
if (actkeyblock_is_valid(ab, keys)) {
- if (ab->flag & ACTKEYBLOCK_FLAG_MOVING_HOLD) {
- /* draw "moving hold" long-keyframe block - slightly smaller */
- immUniformColor4fv(ab->sel ? sel_mhcol : unsel_mhcol);
- immRectf(pos_id, ab->start, ypos - smaller_sz, ab->end, ypos + smaller_sz);
- }
- else {
- /* draw standard long-keyframe block */
- immUniformColor4fv(ab->sel ? sel_color : unsel_color);
- immRectf(pos_id, ab->start, ypos - half_icon_sz, ab->end, ypos + half_icon_sz);
+ block_ct++;
+ }
+ }
+
+ if (block_ct > 0) {
+ Gwn_VertFormat *format = immVertexFormat();
+ unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+
+ immBegin(GWN_PRIM_TRIS, 6 * block_ct);
+ for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) {
+ if (actkeyblock_is_valid(ab, keys)) {
+ if (ab->flag & ACTKEYBLOCK_FLAG_MOVING_HOLD) {
+ /* draw "moving hold" long-keyframe block - slightly smaller */
+ immRectf_fast_with_color(pos_id, color_id,
+ ab->start, ypos - half_icon_sz, ab->end, ypos + half_icon_sz,
+ (ab->sel) ? sel_mhcol : unsel_mhcol);
+ }
+ else {
+ /* draw standard long-keyframe block */
+ immRectf_fast_with_color(pos_id, color_id,
+ ab->start, ypos - half_icon_sz, ab->end, ypos + half_icon_sz,
+ (ab->sel) ? sel_color : unsel_color);
+ }
}
}
+ immEnd();
+ immUnbindProgram();
}
- immUnbindProgram();
}
if (keys) {
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 126e4b5f736..b490ae9c097 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -92,7 +92,7 @@
/* Get the active settings for keyframing settings from context (specifically the given scene) */
short ANIM_get_keyframing_flags(Scene *scene, short incl_mode)
{
- short flag = 0;
+ eInsertKeyFlags flag = INSERTKEY_NOFLAGS;
/* standard flags */
{
@@ -304,7 +304,7 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin
* NOTE: any recalculate of the F-Curve that needs to be done will need to
* be done by the caller.
*/
-int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, short flag)
+int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
{
int i = 0;
@@ -391,11 +391,11 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, short flag)
* adding a new keyframe to a curve, when the keyframe doesn't exist anywhere else yet.
* It returns the index at which the keyframe was added.
*
- * \param keyframe_type: The type of keyframe (eBezTriple_KeyframeTypes)
+ * \param keyframe_type: The type of keyframe (eBezTriple_KeyframeType)
* \param flag: Optional flags (eInsertKeyFlags) for controlling how keys get added
* and/or whether updates get done
*/
-int insert_vert_fcurve(FCurve *fcu, float x, float y, char keyframe_type, short flag)
+int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType keyframe_type, eInsertKeyFlags flag)
{
BezTriple beztr = {{{0}}};
unsigned int oldTot = fcu->totvert;
@@ -883,13 +883,13 @@ static float visualkey_get_value(PointerRNA *ptr, PropertyRNA *prop, int array_i
* Use this when validation of necessary animation data is not necessary, since an RNA-pointer to the necessary
* data being keyframed, and a pointer to the F-Curve to use have both been provided.
*
- * keytype is the "keyframe type" (eBezTriple_KeyframeTypes), as shown in the Dope Sheet.
+ * keytype is the "keyframe type" (eBezTriple_KeyframeType), as shown in the Dope Sheet.
*
* The flag argument is used for special settings that alter the behavior of
* the keyframe insertion. These include the 'visual' keyframing modes, quick refresh,
* and extra keyframe filtering.
*/
-bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, char keytype, short flag)
+bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag)
{
float curval = 0.0f;
@@ -1008,7 +1008,7 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr
*
* index of -1 keys all array indices
*/
-short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, char keytype, short flag)
+short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag)
{
PointerRNA id_ptr, ptr;
PropertyRNA *prop = NULL;
@@ -1131,7 +1131,7 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra)
return false;
}
-short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short UNUSED(flag))
+short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eInsertKeyFlags UNUSED(flag))
{
AnimData *adt = BKE_animdata_from_id(id);
PointerRNA id_ptr, ptr;
@@ -1220,7 +1220,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
* The flag argument is used for special settings that alter the behavior of
* the keyframe deletion. These include the quick refresh options.
*/
-static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, short UNUSED(flag))
+static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, eInsertKeyFlags UNUSED(flag))
{
AnimData *adt = BKE_animdata_from_id(id);
PointerRNA id_ptr, ptr;
@@ -1769,7 +1769,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
short success = 0;
int index;
const bool all = RNA_boolean_get(op->ptr, "all");
- short flag = 0;
+ eInsertKeyFlags flag = INSERTKEY_NOFLAGS;
+
/* flags for inserting keyframes */
flag = ANIM_get_keyframing_flags(scene, 1);
diff --git a/source/blender/editors/armature/BIF_generate.h b/source/blender/editors/armature/BIF_generate.h
deleted file mode 100644
index 71109574fe0..00000000000
--- a/source/blender/editors/armature/BIF_generate.h
+++ /dev/null
@@ -1,49 +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 blender/editors/armature/BIF_generate.h
- * \ingroup edarmature
- */
-
-
-#ifndef __BIF_GENERATE_H__
-#define __BIF_GENERATE_H__
-
-struct ToolSettings;
-struct EditBone;
-struct BArcIterator;
-struct bArmature;
-struct ListBase;
-
-typedef int (NextSubdivisionFunc)(struct ToolSettings *, struct BArcIterator *, int, int, float[3], float[3]);
-
-float calcArcCorrelation(struct BArcIterator *iter, int start, int end, float v0[3], float n[3]);
-
-int nextFixedSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]);
-int nextLengthSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]);
-int nextAdaptativeSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]);
-
-struct EditBone *subdivideArcBy(struct ToolSettings *toolsettings, struct bArmature *arm, ListBase *editbones, struct BArcIterator *iter,
- float invmat[4][4], float tmat[3][3], NextSubdivisionFunc next_subdividion);
-
-void setBoneRollFromNormal(struct EditBone *bone, const float no[3], float invmat[4][4], float tmat[3][3]);
-
-
-#endif /* __BIF_GENERATE_H__ */
diff --git a/source/blender/editors/armature/BIF_retarget.h b/source/blender/editors/armature/BIF_retarget.h
deleted file mode 100644
index aa56f847f00..00000000000
--- a/source/blender/editors/armature/BIF_retarget.h
+++ /dev/null
@@ -1,171 +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 blender/editors/armature/BIF_retarget.h
- * \ingroup edarmature
- */
-
-#ifndef __BIF_RETARGET_H__
-#define __BIF_RETARGET_H__
-
-#include "DNA_listBase.h"
-
-#include "BLI_graph.h"
-#include "BLI_ghash.h"
-#include "BLI_task.h"
-#include "BLI_threads.h"
-
-#include "reeb.h"
-
-struct Object;
-struct bArmature;
-struct bContext;
-
-struct EditBone;
-
-struct RigGraph;
-struct RigNode;
-struct RigArc;
-struct RigEdge;
-
-#define USE_THREADS
-
-typedef struct RigGraph {
- ListBase arcs;
- ListBase nodes;
-
- float length;
-
- FreeArc free_arc;
- FreeNode free_node;
- RadialSymmetry radial_symmetry;
- AxialSymmetry axial_symmetry;
- /*********************************/
-
- int flag;
-
- ListBase controls;
- ListBase *editbones;
-
- struct RigNode *head;
- ReebGraph *link_mesh;
-
-
- TaskScheduler *task_scheduler;
- TaskPool *task_pool;
-
- GHash *bones_map; /* map of editbones by name */
- GHash *controls_map; /* map of rigcontrols by bone pointer */
-
- struct Object *ob;
-} RigGraph;
-
-typedef struct RigNode {
- void *next, *prev;
- float p[3];
- int flag;
-
- int degree;
- struct BArc **arcs;
-
- int subgraph_index;
-
- int symmetry_level;
- int symmetry_flag;
- float symmetry_axis[3];
- /*********************************/
-
- ReebNode *link_mesh;
-} RigNode;
-
-typedef struct RigArc {
- void *next, *prev;
- RigNode *head, *tail;
- int flag;
-
- float length;
-
- int symmetry_level;
- int symmetry_group;
- int symmetry_flag;
- /*********************************/
-
- ListBase edges;
- int count;
- ReebArc *link_mesh;
-} RigArc;
-
-typedef struct RigEdge {
- struct RigEdge *next, *prev;
- float head[3], tail[3];
- float length;
- float angle; /* angle to next edge */
- float up_angle; /* angle between up_axis and the joint normal (defined as Previous edge CrossProduct Current edge */
- struct EditBone *bone;
- float up_axis[3];
-} RigEdge;
-
-/* Graph flags */
-#define RIG_FREE_BONELIST 1
-
-/* Control flags */
-#define RIG_CTRL_HEAD_DONE 1
-#define RIG_CTRL_TAIL_DONE 2
-#define RIG_CTRL_PARENT_DEFORM 4
-#define RIG_CTRL_FIT_ROOT 8
-#define RIG_CTRL_FIT_BONE 16
-
-#define RIG_CTRL_DONE (RIG_CTRL_HEAD_DONE | RIG_CTRL_TAIL_DONE)
-
-/* Control tail flags */
-typedef enum {
- TL_NONE = 0,
- TL_TAIL,
- TL_HEAD
-} LinkTailMode;
-
-typedef struct RigControl {
- struct RigControl *next, *prev;
- float head[3], tail[3];
- struct EditBone *bone;
- struct EditBone *link;
- struct EditBone *link_tail;
- float up_axis[3];
- float offset[3];
- float qrot[4]; /* for dual linked bones, store the rotation of the linked bone for the finalization */
- int flag;
- LinkTailMode tail_mode;
-} RigControl;
-
-void BIF_retargetArc(struct bContext *C, ReebArc *earc, RigGraph *template_rigg);
-RigGraph *RIG_graphFromArmature(const struct bContext *C, struct Object *ob, struct bArmature *arm);
-int RIG_nbJoints(RigGraph *rg);
-const char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index);
-void RIG_freeRigGraph(BGraph *rg);
-
-/* UNUSED */
-void BIF_retargetArmature(bContext *C);
-void BIF_adjustRetarget(bContext *C);
-/* UNUSED / print funcs */
-void RIG_printArc(struct RigGraph *rg, struct RigArc *arc);
-void RIG_printGraph(struct RigGraph *rg);
-void RIG_printArcBones(struct RigArc *arc);
-
-#endif /* __BIF_RETARGET_H__ */
diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt
index 4301fe6582f..96467ee2c2a 100644
--- a/source/blender/editors/armature/CMakeLists.txt
+++ b/source/blender/editors/armature/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
+ ../../../../intern/clog
../../../../intern/guardedalloc
../../../../intern/eigen
../../../../intern/glew-mx
@@ -46,9 +47,6 @@ set(SRC
armature_select.c
armature_skinning.c
armature_utils.c
- editarmature_generate.c
- editarmature_retarget.c
- editarmature_sketch.c
editarmature_undo.c
meshlaplacian.c
pose_edit.c
@@ -58,13 +56,9 @@ set(SRC
pose_slide.c
pose_transform.c
pose_utils.c
- reeb.c
- BIF_generate.h
- BIF_retarget.h
armature_intern.h
meshlaplacian.h
- reeb.h
)
if(WITH_INTERNATIONAL)
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index bd3ddfe93c6..36dded5ed5e 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -63,12 +63,12 @@
/* default bone add, returns it selected, but without tail set */
/* XXX should be used everywhere, now it mallocs bones still locally in functions */
-EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
+EditBone *ED_armature_ebone_add(bArmature *arm, const char *name)
{
EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
BLI_strncpy(bone->name, name, sizeof(bone->name));
- unique_editbone_name(arm->edbo, bone->name, NULL);
+ ED_armature_ebone_unique_name(arm->edbo, bone->name, NULL);
BLI_addtail(arm->edbo, bone);
@@ -97,15 +97,15 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
return bone;
}
-EditBone *ED_armature_edit_bone_add_primitive(Object *obedit_arm, float length, bool view_aligned)
+EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool view_aligned)
{
bArmature *arm = obedit_arm->data;
EditBone *bone;
- ED_armature_deselect_all(obedit_arm);
+ ED_armature_edit_deselect_all(obedit_arm);
/* Create a bone */
- bone = ED_armature_edit_bone_add(arm, "Bone");
+ bone = ED_armature_ebone_add(arm, "Bone");
arm->act_edbone = bone;
@@ -157,12 +157,12 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
to_root = 1;
}
- ED_armature_deselect_all(obedit);
+ ED_armature_edit_deselect_all(obedit);
/* we re-use code for mirror editing... */
flipbone = NULL;
if (arm->flag & ARM_MIRROR_EDIT)
- flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
+ flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
for (a = 0; a < 2; a++) {
if (a == 1) {
@@ -173,7 +173,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- newbone = ED_armature_edit_bone_add(arm, ebone->name);
+ newbone = ED_armature_ebone_add(arm, ebone->name);
arm->act_edbone = newbone;
if (to_root) {
@@ -205,7 +205,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
}
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -268,7 +268,7 @@ EditBone *add_points_bone(Object *obedit, float head[3], float tail[3])
{
EditBone *ebo;
- ebo = ED_armature_edit_bone_add(obedit->data, "Bone");
+ ebo = ED_armature_ebone_add(obedit->data, "Bone");
copy_v3_v3(ebo->head, head);
copy_v3_v3(ebo->tail, tail);
@@ -333,7 +333,7 @@ void postEditBoneDuplicate(struct ListBase *editbones, Object *ob)
for (EditBone *ebone_src = editbones->first; ebone_src; ebone_src = ebone_src->next) {
EditBone *ebone_dst = ebone_src->temp.ebone;
if (!ebone_dst) {
- ebone_dst = ED_armature_bone_get_mirrored(editbones, ebone_src);
+ ebone_dst = ED_armature_ebone_get_mirrored(editbones, ebone_src);
}
if (ebone_dst) {
BLI_ghash_insert(name_map, ebone_src->name, ebone_dst->name);
@@ -438,7 +438,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
BLI_strncpy(eBone->name, name, sizeof(eBone->name));
}
- unique_editbone_name(editbones, eBone->name, NULL);
+ ED_armature_ebone_unique_name(editbones, eBone->name, NULL);
BLI_addtail(editbones, eBone);
/* copy the ID property */
@@ -487,7 +487,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
const bool do_flip_names = RNA_boolean_get(op->ptr, "do_flip_names");
- ED_armature_sync_selection(arm->edbo); // XXX why is this needed?
+ ED_armature_edit_sync_selection(arm->edbo); // XXX why is this needed?
preEditBoneDuplicate(arm->edbo);
@@ -499,7 +499,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
{
EditBone *ebone;
- ebone = ED_armature_bone_get_mirrored(arm->edbo, ebone_iter);
+ ebone = ED_armature_ebone_get_mirrored(arm->edbo, ebone_iter);
if (ebone) {
ebone->flag |= BONE_SELECTED;
}
@@ -522,7 +522,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
/* Only use flipped name if not yet in use. Otherwise we'd get again inconsistent namings
* (different numbers), better keep default behavior in this case. */
- if (ED_armature_bone_find_name(arm->edbo, new_bone_name_buff) == NULL) {
+ if (ED_armature_ebone_find_name(arm->edbo, new_bone_name_buff) == NULL) {
new_bone_name = new_bone_name_buff;
}
}
@@ -583,7 +583,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
postEditBoneDuplicate(arm->edbo, obedit);
- ED_armature_validate_active(arm);
+ ED_armature_edit_validate_active(arm);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -630,7 +630,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
if (CTX_DATA_COUNT(C, selected_bones) == 0)
return OPERATOR_CANCELLED;
- ED_armature_sync_selection(arm->edbo); // XXX why is this needed?
+ ED_armature_edit_sync_selection(arm->edbo); // XXX why is this needed?
preEditBoneDuplicate(arm->edbo);
@@ -648,7 +648,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
ebone_iter->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
else {
- EditBone *ebone = ED_armature_bone_find_name(arm->edbo, name_flip);
+ EditBone *ebone = ED_armature_ebone_find_name(arm->edbo, name_flip);
if (ebone) {
if ((ebone->flag & BONE_SELECTED) == 0) {
@@ -738,7 +738,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
/* the parent may have been duplicated, if not lookup the mirror parent */
EditBone *ebone_parent =
(ebone_iter->parent->temp.ebone ?
- ebone_iter->parent->temp.ebone : ED_armature_bone_get_mirrored(arm->edbo, ebone_iter->parent));
+ ebone_iter->parent->temp.ebone : ED_armature_ebone_get_mirrored(arm->edbo, ebone_iter->parent));
if (ebone_parent == NULL) {
/* If the mirror lookup failed, (but the current bone has a parent)
@@ -759,7 +759,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
}
}
- transform_armature_mirror_update(obedit);
+ ED_armature_edit_transform_mirror_update(obedit);
/* Selected bones now have their 'temp' pointer set,
* so we don't need this anymore */
@@ -786,7 +786,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
postEditBoneDuplicate(arm->edbo, obedit);
- ED_armature_validate_active(arm);
+ ED_armature_edit_validate_active(arm);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -870,7 +870,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
/* we re-use code for mirror editing... */
flipbone = NULL;
if (arm->flag & ARM_MIRROR_EDIT) {
- flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
+ flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (flipbone) {
forked = 0; // we extrude 2 different bones
if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED))
@@ -944,7 +944,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
else strcat(newbone->name, "_R");
}
}
- unique_editbone_name(arm->edbo, newbone->name, NULL);
+ ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL);
/* Add the new bone to the list */
BLI_addtail(arm->edbo, newbone);
@@ -974,7 +974,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
}
/* Transform the endpoints */
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -1027,10 +1027,10 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
mul_m3_m3m3(totmat, obmat, viewmat);
invert_m3_m3(imat, totmat);
- ED_armature_deselect_all(obedit);
+ ED_armature_edit_deselect_all(obedit);
/* Create a bone */
- bone = ED_armature_edit_bone_add(obedit->data, name);
+ bone = ED_armature_ebone_add(obedit->data, name);
copy_v3_v3(bone->head, curs);
@@ -1074,7 +1074,6 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
static int armature_subdivide_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
- bArmature *arm = obedit->data;
EditBone *newbone, *tbone;
int cuts, i;
@@ -1083,7 +1082,7 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
/* loop over all editable bones */
// XXX the old code did this in reverse order though!
- CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
+ CTX_DATA_BEGIN_WITH_ID(C, EditBone *, ebone, selected_editable_bones, bArmature *, arm)
{
for (i = cuts + 1; i > 1; i--) {
/* compute cut ratio first */
@@ -1118,7 +1117,7 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
newbone->prop = NULL;
- unique_editbone_name(arm->edbo, newbone->name, NULL);
+ ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL);
/* correct parent bones */
for (tbone = arm->edbo->first; tbone; tbone = tbone->next) {
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index bb3c4164fc1..6a94443660b 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -48,6 +48,7 @@
#include "BKE_armature.h"
#include "BKE_constraint.h"
#include "BKE_context.h"
+#include "BKE_layer.h"
#include "BKE_global.h"
#include "BKE_report.h"
#include "BKE_object.h"
@@ -67,7 +68,7 @@
/* ************************** Object Tools Exports ******************************* */
/* NOTE: these functions are exported to the Object module to be called from the tools there */
-void ED_armature_apply_transform(Object *ob, float mat[4][4], const bool do_props)
+void ED_armature_transform_apply(Object *ob, float mat[4][4], const bool do_props)
{
bArmature *arm = ob->data;
@@ -205,7 +206,7 @@ void ED_armature_origin_set(Object *ob, float cursor[3], int centermode, int aro
/* adjust bone roll to align Z axis with vector
* vec is in local space and is normalized
*/
-float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const bool axis_only)
+float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float align_axis[3], const bool axis_only)
{
float mat[3][3], nor[3];
float vec[3], align_axis_proj[3], roll = 0.0f;
@@ -331,7 +332,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
if (axis_flip) negate_v3(cursor_rel);
if (normalize_v3(cursor_rel) != 0.0f) {
- ebone->roll = ED_rollBoneToVector(ebone, cursor_rel, axis_only);
+ ebone->roll = ED_armature_ebone_roll_to_vector(ebone, cursor_rel, axis_only);
}
}
}
@@ -370,13 +371,13 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
if (axis_flip) negate_v3(vec);
if (is_edit) {
- ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only);
+ ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only);
}
/* parentless bones use cross product with child */
if (is_edit_parent) {
if (ebone->parent->parent == NULL) {
- ebone->parent->roll = ED_rollBoneToVector(ebone->parent, vec, axis_only);
+ ebone->parent->roll = ED_armature_ebone_roll_to_vector(ebone->parent, vec, axis_only);
}
}
}
@@ -420,7 +421,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
/* roll func is a callback which assumes that all is well */
- ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only);
+ ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only);
}
}
}
@@ -428,7 +429,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
if (arm->flag & ARM_MIRROR_EDIT) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
- EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone);
+ EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {
ebone->roll = -ebone_mirr->roll;
}
@@ -482,7 +483,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op)
if (arm->flag & ARM_MIRROR_EDIT) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
- EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone);
+ EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {
ebone->roll = -ebone_mirr->roll;
}
@@ -630,25 +631,39 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
/* bone adding between selected joints */
static int armature_fill_bones_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- bArmature *arm = (obedit) ? obedit->data : NULL;
+ Object *obedit_active = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
ListBase points = {NULL, NULL};
EditBone *newbone = NULL;
int count;
+ bool mixed_object_error = false;
/* sanity checks */
- if (ELEM(NULL, obedit, arm))
+ if (ELEM(NULL, obedit_active, obedit_active->data)) {
return OPERATOR_CANCELLED;
+ }
/* loop over all bones, and only consider if visible */
- CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
+ bArmature *arm = NULL;
+ CTX_DATA_BEGIN_WITH_ID(C, EditBone *, ebone, visible_bones, bArmature *, arm_iter)
{
- if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL))
+ bool check = false;
+ if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL)) {
fill_add_joint(ebone, 0, &points);
- if (ebone->flag & BONE_TIPSEL)
+ check = true;
+ }
+ if (ebone->flag & BONE_TIPSEL) {
fill_add_joint(ebone, 1, &points);
+ check = true;
+ }
+
+ if (check) {
+ if (arm && (arm != arm_iter)) {
+ mixed_object_error = true;
+ }
+ arm = arm_iter;
+ }
}
CTX_DATA_END;
@@ -658,12 +673,30 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
* 3+) error (a smarter method involving finding chains needs to be worked out
*/
count = BLI_listbase_count(&points);
-
+
if (count == 0) {
BKE_report(op->reports, RPT_ERROR, "No joints selected");
return OPERATOR_CANCELLED;
}
- else if (count == 1) {
+ else if (mixed_object_error) {
+ BKE_report(op->reports, RPT_ERROR, "Bones for different objects selected");
+ BLI_freelistN(&points);
+ return OPERATOR_CANCELLED;
+ }
+
+ Object *obedit = NULL;
+ {
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_EDIT, ob_iter) {
+ if (ob_iter->data == arm) {
+ obedit = ob_iter;
+ }
+ }
+ FOREACH_OBJECT_IN_MODE_END;
+ }
+ BLI_assert(obedit != NULL);
+
+ if (count == 1) {
EditBonePoint *ebp;
float curs[3];
@@ -771,7 +804,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
}
if (newbone) {
- ED_armature_deselect_all(obedit);
+ ED_armature_edit_deselect_all(obedit);
arm->act_edbone = newbone;
newbone->flag |= BONE_TIPSEL;
}
@@ -883,7 +916,7 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
}
newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED);
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
}
@@ -959,7 +992,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
}
/* updates */
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
return OPERATOR_FINISHED;
@@ -1181,7 +1214,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
- actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone);
+ actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
if (actmirb == NULL)
actmirb = actbone;
}
@@ -1293,7 +1326,7 @@ static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p)
bArmature *arm = arm_p;
EditBone *ebone;
- ebone = ED_armature_bone_find_name(arm->edbo, bone_name);
+ ebone = ED_armature_ebone_find_name(arm->edbo, bone_name);
return (ebone && (ebone->flag & BONE_SELECTED) && (arm->layer & ebone->layer));
}
@@ -1301,38 +1334,49 @@ static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p)
/* only editmode! */
static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
{
- bArmature *arm;
EditBone *curBone, *ebone_next;
- Object *obedit = CTX_data_edit_object(C); // XXX get from context
- bool changed = false;
- arm = obedit->data;
+ bool changed_multi = false;
/* cancel if nothing selected */
if (CTX_DATA_COUNT(C, selected_bones) == 0)
return OPERATOR_CANCELLED;
-
- armature_select_mirrored(arm);
-
- BKE_pose_channels_remove(obedit, armature_delete_ebone_cb, arm);
-
- for (curBone = arm->edbo->first; curBone; curBone = ebone_next) {
- ebone_next = curBone->next;
- if (arm->layer & curBone->layer) {
- if (curBone->flag & BONE_SELECTED) {
- if (curBone == arm->act_edbone) arm->act_edbone = NULL;
- ED_armature_edit_bone_remove(arm, curBone);
- changed = true;
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ bArmature *arm = obedit->data;
+ bool changed = false;
+
+ armature_select_mirrored(arm);
+
+ BKE_pose_channels_remove(obedit, armature_delete_ebone_cb, arm);
+
+ for (curBone = arm->edbo->first; curBone; curBone = ebone_next) {
+ ebone_next = curBone->next;
+ if (arm->layer & curBone->layer) {
+ if (curBone->flag & BONE_SELECTED) {
+ if (curBone == arm->act_edbone) arm->act_edbone = NULL;
+ ED_armature_ebone_remove(arm, curBone);
+ changed = true;
+ }
}
}
+
+ if (changed) {
+ changed_multi = true;
+
+ ED_armature_edit_sync_selection(arm->edbo);
+ BKE_pose_tag_recalc(CTX_data_main(C), obedit->pose);
+
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
+ }
}
-
- if (!changed)
- return OPERATOR_CANCELLED;
-
- ED_armature_sync_selection(arm->edbo);
- BKE_pose_tag_recalc(CTX_data_main(C), obedit->pose);
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
+ if (!changed_multi) {
+ return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -1358,7 +1402,7 @@ static bool armature_dissolve_ebone_cb(const char *bone_name, void *arm_p)
bArmature *arm = arm_p;
EditBone *ebone;
- ebone = ED_armature_bone_find_name(arm->edbo, bone_name);
+ ebone = ED_armature_ebone_find_name(arm->edbo, bone_name);
return (ebone && (ebone->flag & BONE_DONE));
}
@@ -1460,7 +1504,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op))
ebone->parent->rad_tail = ebone->rad_tail;
SET_FLAG_FROM_TEST(ebone->parent->flag, ebone->flag & BONE_TIPSEL, BONE_TIPSEL);
- ED_armature_edit_bone_remove_ex(arm, ebone, false);
+ ED_armature_ebone_remove_ex(arm, ebone, false);
changed = true;
}
}
@@ -1493,7 +1537,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -1538,8 +1582,8 @@ static int armature_hide_exec(bContext *C, wmOperator *op)
}
}
}
- ED_armature_validate_active(arm);
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_validate_active(arm);
+ ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -1581,8 +1625,8 @@ static int armature_reveal_exec(bContext *C, wmOperator *op)
}
}
}
- ED_armature_validate_active(arm);
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_validate_active(arm);
+ ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 0ba720a17d0..7bc8764443f 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -139,18 +139,6 @@ void POSE_OT_quaternions_flip(struct wmOperatorType *ot);
void POSE_OT_bone_layers(struct wmOperatorType *ot);
/* ******************************************************* */
-/* Etch-A-Ton (Skeleton Sketching) Operators */
-
-void SKETCH_OT_gesture(struct wmOperatorType *ot);
-void SKETCH_OT_delete(struct wmOperatorType *ot);
-void SKETCH_OT_draw_stroke(struct wmOperatorType *ot);
-void SKETCH_OT_draw_preview(struct wmOperatorType *ot);
-void SKETCH_OT_finish_stroke(struct wmOperatorType *ot);
-void SKETCH_OT_cancel_stroke(struct wmOperatorType *ot);
-void SKETCH_OT_convert(struct wmOperatorType *ot);
-void SKETCH_OT_select(struct wmOperatorType *ot);
-
-/* ******************************************************* */
/* Pose Tool Utilities (for PoseLib, Pose Sliding, etc.) */
/* pose_utils.c */
@@ -225,7 +213,6 @@ void POSE_OT_propagate(struct wmOperatorType *ot);
*/
EditBone *make_boneList(struct ListBase *edbo, struct ListBase *bones, struct EditBone *parent, struct Bone *actBone);
-bool BIF_sk_selectStroke(struct bContext *C, const int mval[2], const bool extend);
/* duplicate method */
void preEditBoneDuplicate(struct ListBase *editbones);
@@ -248,10 +235,15 @@ void armature_select_mirrored_ex(struct bArmature *arm, const int flag);
void armature_select_mirrored(struct bArmature *arm);
void armature_tag_unselect(struct bArmature *arm);
-void *get_nearest_bone(struct bContext *C, const int xy[2], bool findunsel);
+void *get_nearest_bone(
+ struct bContext *C, const int xy[2], bool findunsel,
+ struct Base **r_base);
+
void *get_bone_from_selectbuffer(
- struct Base *base, struct Object *obedit, const unsigned int *buffer, short hits,
- bool findunsel, bool do_nearest);
+ struct Base **bases, uint bases_len,
+ bool is_editmode, const unsigned int *buffer, short hits,
+ bool findunsel, bool do_nearest,
+ struct Base **r_base);
int bone_looper(struct Object *ob, struct Bone *bone, void *data,
int (*bone_func)(struct Object *, struct Bone *, void *));
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index 52e9e424a85..e8d45f72f89 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -74,11 +74,11 @@
static bool editbone_unique_check(void *arg, const char *name)
{
struct {ListBase *lb; void *bone; } *data = arg;
- EditBone *dupli = ED_armature_bone_find_name(data->lb, name);
+ EditBone *dupli = ED_armature_ebone_find_name(data->lb, name);
return dupli && dupli != data->bone;
}
-void unique_editbone_name(ListBase *edbo, char *name, EditBone *bone)
+void ED_armature_ebone_unique_name(ListBase *edbo, char *name, EditBone *bone)
{
struct {ListBase *lb; void *bone; } data;
data.lb = edbo;
@@ -153,10 +153,10 @@ 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 = ED_armature_bone_find_name(arm->edbo, oldname);
+ EditBone *eBone = ED_armature_ebone_find_name(arm->edbo, oldname);
if (eBone) {
- unique_editbone_name(arm->edbo, newname, NULL);
+ ED_armature_ebone_unique_name(arm->edbo, newname, NULL);
BLI_strncpy(eBone->name, newname, MAXBONENAME);
}
else {
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 5622cd0437d..c9cebadb47d 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -85,16 +85,6 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(ARMATURE_OT_armature_layers);
WM_operatortype_append(ARMATURE_OT_bone_layers);
- /* SKETCH */
- WM_operatortype_append(SKETCH_OT_gesture);
- WM_operatortype_append(SKETCH_OT_delete);
- WM_operatortype_append(SKETCH_OT_draw_stroke);
- WM_operatortype_append(SKETCH_OT_draw_preview);
- WM_operatortype_append(SKETCH_OT_finish_stroke);
- WM_operatortype_append(SKETCH_OT_cancel_stroke);
- WM_operatortype_append(SKETCH_OT_convert);
- WM_operatortype_append(SKETCH_OT_select);
-
/* POSE */
WM_operatortype_append(POSE_OT_hide);
WM_operatortype_append(POSE_OT_reveal);
@@ -203,23 +193,6 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* Armature ------------------------ */
keymap = WM_keymap_find(keyconf, "Armature", 0, 0);
keymap->poll = ED_operator_editarmature;
-
- /* Armature -> Etch-A-Ton ------------------------ */
- WM_keymap_add_item(keymap, "SKETCH_OT_delete", XKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "SKETCH_OT_delete", DELKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "SKETCH_OT_finish_stroke", RIGHTMOUSE, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "SKETCH_OT_cancel_stroke", ESCKEY, KM_PRESS, 0, 0);
- /* Already part of view3d select */
- //WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
-
- /* sketch poll checks mode */
- WM_keymap_add_item(keymap, "SKETCH_OT_gesture", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
- kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
- RNA_boolean_set(kmi->ptr, "snap", true);
- WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, 0, 0);
- kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, KM_CTRL, 0);
- RNA_boolean_set(kmi->ptr, "snap", true);
/* only set in editmode armature, by space_view3d listener */
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index de2611f7092..0dafbf51d74 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -312,10 +312,10 @@ 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 = ED_armature_bone_find_name(curarm->edbo, pchan->name);
+ curbone = ED_armature_ebone_find_name(curarm->edbo, pchan->name);
/* Get new name */
- unique_editbone_name(arm->edbo, curbone->name, NULL);
+ ED_armature_ebone_unique_name(arm->edbo, curbone->name, NULL);
BLI_ghash_insert(afd.names_map, BLI_strdup(pchan->name), curbone->name);
/* Transform the bone */
@@ -528,7 +528,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 = ED_armature_bone_find_name(arm->edbo, pchan->name);
+ curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name);
/* check if bone needs to be removed */
if ( (sel && (curbone->flag & BONE_SELECTED)) ||
@@ -640,7 +640,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
ED_armature_to_edit(obedit->data);
/* parents tips remain selected when connected children are removed. */
- ED_armature_deselect_all(obedit);
+ ED_armature_edit_deselect_all(obedit);
BKE_report(op->reports, RPT_INFO, "Separated bones");
@@ -760,7 +760,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
- actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone);
+ actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
if (actmirb == NULL)
actmirb = actbone;
}
@@ -883,7 +883,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 397691a409b..af0483cf1dc 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -29,6 +29,8 @@
* \ingroup edarmature
*/
+#include "MEM_guardedalloc.h"
+
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -39,7 +41,9 @@
#include "BKE_context.h"
#include "BKE_action.h"
+#include "BKE_object.h"
#include "BKE_report.h"
+#include "BKE_layer.h"
#include "BIF_gl.h"
@@ -63,26 +67,84 @@
/* **************** PoseMode & EditMode Selection Buffer Queries *************************** */
-/* only for opengl selection indices */
-Bone *get_indexed_bone(Object *ob, int index)
+Base *ED_armature_base_and_ebone_from_select_buffer(
+ Base **bases, uint bases_len, int hit, EditBone **r_ebone)
{
- bPoseChannel *pchan;
- if (ob->pose == NULL) return NULL;
- index >>= 16; // bone selection codes use left 2 bytes
-
- pchan = BLI_findlink(&ob->pose->chanbase, index);
- return pchan ? pchan->bone : NULL;
+ const uint hit_object = hit & 0xFFFF;
+ Base *base = NULL;
+ EditBone *ebone = NULL;
+ /* TODO(campbell): optimize, eg: sort & binary search. */
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ if (bases[base_index]->object->select_color == hit_object) {
+ base = bases[base_index];
+ break;
+ }
+ }
+ if (base != NULL) {
+ const uint hit_bone = (hit & ~BONESEL_ANY) >> 16;
+ bArmature *arm = base->object->data;
+ ebone = BLI_findlink(arm->edbo, hit_bone);
+ }
+ *r_ebone = ebone;
+ return base;
+}
+
+Object *ED_armature_object_and_ebone_from_select_buffer(
+ Object **objects, uint objects_len, int hit, EditBone **r_ebone)
+{
+ const uint hit_object = hit & 0xFFFF;
+ Object *ob = NULL;
+ EditBone *ebone = NULL;
+ /* TODO(campbell): optimize, eg: sort & binary search. */
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ if (objects[ob_index]->select_color == hit_object) {
+ ob = objects[ob_index];
+ break;
+ }
+ }
+ if (ob != NULL) {
+ const uint hit_bone = (hit & ~BONESEL_ANY) >> 16;
+ bArmature *arm = ob->data;
+ ebone = BLI_findlink(arm->edbo, hit_bone);
+ }
+ *r_ebone = ebone;
+ return ob;
+}
+
+Base *ED_armature_base_and_bone_from_select_buffer(
+ Base **bases, uint bases_len, int hit, Bone **r_bone)
+{
+ const uint hit_object = hit & 0xFFFF;
+ Base *base = NULL;
+ Bone *bone = NULL;
+ /* TODO(campbell): optimize, eg: sort & binary search. */
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ if (bases[base_index]->object->select_color == hit_object) {
+ base = bases[base_index];
+ break;
+ }
+ }
+ if (base != NULL) {
+ if (base->object->pose != NULL) {
+ const uint hit_bone = (hit & ~BONESEL_ANY) >> 16;
+ bPoseChannel *pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone);;
+ bone = pchan ? pchan->bone : NULL;
+ }
+ }
+ *r_bone = bone;
+ return base;
}
/* See if there are any selected bones in this buffer */
/* only bones from base are checked on */
void *get_bone_from_selectbuffer(
- Base *base, Object *obedit, const unsigned int *buffer, short hits,
- bool findunsel, bool do_nearest)
+ Base **bases, uint bases_len, bool is_editmode, const unsigned int *buffer, short hits,
+ bool findunsel, bool do_nearest, Base **r_base)
{
Bone *bone;
EditBone *ebone;
void *firstunSel = NULL, *firstSel = NULL, *data;
+ Base *firstunSel_base = NULL, *firstSel_base = NULL;
unsigned int hitresult;
short i;
bool takeNext = false;
@@ -93,15 +155,14 @@ void *get_bone_from_selectbuffer(
if (!(hitresult & BONESEL_NOSEL)) {
if (hitresult & BONESEL_ANY) { /* to avoid including objects in selection */
+ Base *base = NULL;
bool sel;
-
+
hitresult &= ~(BONESEL_ANY);
/* Determine what the current bone is */
- if (obedit == NULL || base->object != obedit) {
- /* no singular posemode, so check for correct object */
- if (base->object->select_color == (hitresult & 0xFFFF)) {
- bone = get_indexed_bone(base->object, hitresult);
-
+ if (is_editmode == false) {
+ base = ED_armature_base_and_bone_from_select_buffer(bases, bases_len, hitresult, &bone);
+ if (bone != NULL) {
if (findunsel)
sel = (bone->flag & BONE_SELECTED);
else
@@ -115,14 +176,12 @@ void *get_bone_from_selectbuffer(
}
}
else {
- bArmature *arm = obedit->data;
-
- ebone = BLI_findlink(arm->edbo, hitresult);
+ base = ED_armature_base_and_ebone_from_select_buffer(bases, bases_len, hitresult, &ebone);
if (findunsel)
sel = (ebone->flag & BONE_SELECTED);
else
sel = !(ebone->flag & BONE_SELECTED);
-
+
data = ebone;
}
@@ -131,11 +190,15 @@ void *get_bone_from_selectbuffer(
if (do_nearest) {
if (minsel > buffer[4 * i + 1]) {
firstSel = data;
+ firstSel_base = base;
minsel = buffer[4 * i + 1];
}
}
else {
- if (!firstSel) firstSel = data;
+ if (!firstSel) {
+ firstSel = data;
+ firstSel_base = base;
+ }
takeNext = 1;
}
}
@@ -143,12 +206,19 @@ void *get_bone_from_selectbuffer(
if (do_nearest) {
if (minunsel > buffer[4 * i + 1]) {
firstunSel = data;
+ firstunSel_base = base;
minunsel = buffer[4 * i + 1];
}
}
else {
- if (!firstunSel) firstunSel = data;
- if (takeNext) return data;
+ if (!firstunSel) {
+ firstunSel = data;
+ firstunSel_base = base;
+ }
+ if (takeNext) {
+ *r_base = base;
+ return data;
+ }
}
}
}
@@ -156,34 +226,56 @@ void *get_bone_from_selectbuffer(
}
}
- if (firstunSel)
+ if (firstunSel) {
+ *r_base = firstunSel_base;
return firstunSel;
- else
+ }
+ else {
+ *r_base = firstSel_base;
return firstSel;
+ }
}
/* used by posemode as well editmode */
/* only checks scene->basact! */
/* x and y are mouse coords (area space) */
-void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel)
+void *get_nearest_bone(
+ bContext *C, const int xy[2], bool findunsel,
+ Base **r_base)
{
- EvaluationContext eval_ctx;
ViewContext vc;
rcti rect;
unsigned int buffer[MAXPICKBUF];
short hits;
- CTX_data_eval_ctx(C, &eval_ctx);
ED_view3d_viewcontext_init(C, &vc);
// rect.xmin = ... mouseco!
rect.xmin = rect.xmax = xy[0];
rect.ymin = rect.ymax = xy[1];
- hits = view3d_opengl_select(&eval_ctx, &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
+ hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
+
+ *r_base = NULL;
if (hits > 0) {
- return get_bone_from_selectbuffer(vc.view_layer->basact, vc.obedit, buffer, hits, findunsel, true);
+ uint bases_len = 0;
+ Base **bases;
+
+ if (vc.obedit != NULL) {
+ bases = BKE_view_layer_array_from_bases_in_mode(
+ vc.view_layer, &bases_len, {
+ .object_mode = OB_MODE_EDIT});
+ }
+ else {
+ bases = BKE_object_pose_base_array_get(vc.view_layer, &bases_len);
+ }
+
+ void *bone = get_bone_from_selectbuffer(
+ bases, bases_len, vc.obedit != NULL, buffer, hits, findunsel, true, r_base);
+
+ MEM_freeN(bases);
+ return bone;
}
return NULL;
}
@@ -197,16 +289,17 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
bArmature *arm;
EditBone *bone, *curBone, *next;
const bool extend = RNA_boolean_get(op->ptr, "extend");
- Object *obedit = CTX_data_edit_object(C);
- arm = obedit->data;
view3d_operator_needs_opengl(C);
- bone = get_nearest_bone(C, event->mval, !extend);
+ Base *base = NULL;
+ bone = get_nearest_bone(C, event->mval, !extend, &base);
if (!bone)
return OPERATOR_CANCELLED;
+ arm = base->object->data;
+
/* Select parents */
for (curBone = bone; curBone; curBone = next) {
if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
@@ -247,9 +340,9 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
bone = NULL;
}
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object);
return OPERATOR_FINISHED;
}
@@ -294,44 +387,50 @@ static int selectbuffer_ret_hits_5(unsigned int *buffer, const int hits12, const
/* does bones and points */
/* note that BONE ROOT only gets drawn for root bones (or without IK) */
static EditBone *get_nearest_editbonepoint(
- const EvaluationContext *eval_ctx, ViewContext *vc, const int mval[2],
- ListBase *edbo, bool findunsel, bool use_cycle, int *r_selmask)
+ ViewContext *vc,
+ bool findunsel, bool use_cycle,
+ Base **r_base, int *r_selmask)
{
- bArmature *arm = (bArmature *)vc->obedit->data;
- EditBone *ebone_next_act = arm->act_edbone;
-
- EditBone *ebone;
- rcti rect;
- unsigned int buffer[MAXPICKBUF];
- unsigned int hitresult, besthitresult = BONESEL_NOSEL;
- int i, mindep = 5;
- int hits12, hits5 = 0;
-
- static int last_mval[2] = {-100, -100};
+ uint buffer[MAXPICKBUF];
+ struct {
+ uint hitresult;
+ Base *base;
+ EditBone *ebone;
+ } best = {
+ .hitresult = BONESEL_NOSEL,
+ .base = NULL,
+ .ebone = NULL,
+ };
/* find the bone after the current active bone, so as to bump up its chances in selection.
* this way overlapping bones will cycle selection state as with objects. */
- if (ebone_next_act &&
- EBONE_VISIBLE(arm, ebone_next_act) &&
- ebone_next_act->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL))
+ EditBone *ebone_next_act = ((bArmature *)vc->obedit->data)->act_edbone;
{
- ebone_next_act = ebone_next_act->next ? ebone_next_act->next : arm->edbo->first;
- }
- else {
- ebone_next_act = NULL;
+ bArmature *arm = (bArmature *)vc->obedit->data;
+ if (ebone_next_act &&
+ EBONE_VISIBLE(arm, ebone_next_act) &&
+ ebone_next_act->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL))
+ {
+ ebone_next_act = ebone_next_act->next ? ebone_next_act->next : arm->edbo->first;
+ }
+ else {
+ ebone_next_act = NULL;
+ }
}
bool do_nearest = false;
/* define if we use solid nearest select or not */
if (use_cycle) {
+ static int last_mval[2] = {-100, -100};
+
if (vc->v3d->drawtype > OB_WIRE) {
do_nearest = true;
- if (len_manhattan_v2v2_int(mval, last_mval) < 3) {
+ if (len_manhattan_v2v2_int(vc->mval, last_mval) < 3) {
do_nearest = false;
}
}
- copy_v2_v2_int(last_mval, mval);
+ copy_v2_v2_int(last_mval, vc->mval);
}
else {
if (vc->v3d->drawtype > OB_WIRE) {
@@ -340,52 +439,62 @@ static EditBone *get_nearest_editbonepoint(
}
/* matching logic from 'mixed_bones_object_selectbuffer' */
- const int select_mode = (do_nearest ? VIEW3D_SELECT_PICK_NEAREST : VIEW3D_SELECT_PICK_ALL);
int hits = 0;
/* we _must_ end cache before return, use 'goto cache_end' */
view3d_opengl_select_cache_begin();
- BLI_rcti_init_pt_radius(&rect, mval, 12);
- hits12 = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, &rect, select_mode);
- if (hits12 == 1) {
- hits = selectbuffer_ret_hits_12(buffer, hits12);
- goto cache_end;
- }
- else if (hits12 > 0) {
- int offs;
-
- offs = 4 * hits12;
- BLI_rcti_init_pt_radius(&rect, mval, 5);
- hits5 = view3d_opengl_select(eval_ctx, vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
-
- if (hits5 == 1) {
- hits = selectbuffer_ret_hits_5(buffer, hits12, hits5);
+ {
+ const int select_mode = (do_nearest ? VIEW3D_SELECT_PICK_NEAREST : VIEW3D_SELECT_PICK_ALL);
+ rcti rect;
+ BLI_rcti_init_pt_radius(&rect, vc->mval, 12);
+ const int hits12 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode);
+ if (hits12 == 1) {
+ hits = selectbuffer_ret_hits_12(buffer, hits12);
goto cache_end;
}
+ else if (hits12 > 0) {
+ int offs;
- if (hits5 > 0) { hits = selectbuffer_ret_hits_5(buffer, hits12, hits5); goto cache_end; }
- else { hits = selectbuffer_ret_hits_12(buffer, hits12); goto cache_end; }
+ offs = 4 * hits12;
+ BLI_rcti_init_pt_radius(&rect, vc->mval, 5);
+ const int hits5 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
+
+ if (hits5 == 1) {
+ hits = selectbuffer_ret_hits_5(buffer, hits12, hits5);
+ goto cache_end;
+ }
+
+ if (hits5 > 0) { hits = selectbuffer_ret_hits_5(buffer, hits12, hits5); goto cache_end; }
+ else { hits = selectbuffer_ret_hits_12(buffer, hits12); goto cache_end; }
+ }
}
cache_end:
view3d_opengl_select_cache_end();
+ uint bases_len;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, &bases_len);
+
/* See if there are any selected bones in this group */
if (hits > 0) {
-
if (hits == 1) {
- if (!(buffer[3] & BONESEL_NOSEL))
- besthitresult = buffer[3];
+ if (!(buffer[3] & BONESEL_NOSEL)) {
+ best.hitresult = buffer[3];
+ best.base = ED_armature_base_and_ebone_from_select_buffer(
+ bases, bases_len, best.hitresult, &best.ebone);
+ }
}
else {
- for (i = 0; i < hits; i++) {
- hitresult = buffer[3 + (i * 4)];
+ int dep_min = 5;
+ for (int i = 0; i < hits; i++) {
+ const uint hitresult = buffer[3 + (i * 4)];
if (!(hitresult & BONESEL_NOSEL)) {
+ Base *base = NULL;
+ EditBone *ebone;
+ base = ED_armature_base_and_ebone_from_select_buffer(bases, bases_len, hitresult, &ebone);
+
int dep;
-
- ebone = BLI_findlink(edbo, hitresult & ~BONESEL_ANY);
-
/* clicks on bone points get advantage */
if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) {
/* but also the unselected one */
@@ -418,33 +527,40 @@ cache_end:
dep -= 1;
}
- if (dep < mindep) {
- mindep = dep;
- besthitresult = hitresult;
+ if (dep < dep_min) {
+ dep_min = dep;
+ best.hitresult = hitresult;
+ best.base = base;
+ best.ebone = ebone;
}
}
}
}
-
- if (!(besthitresult & BONESEL_NOSEL)) {
-
- ebone = BLI_findlink(edbo, besthitresult & ~BONESEL_ANY);
-
+
+ if (!(best.hitresult & BONESEL_NOSEL)) {
+ *r_base = best.base;
+
*r_selmask = 0;
- if (besthitresult & BONESEL_ROOT)
+ if (best.hitresult & BONESEL_ROOT) {
*r_selmask |= BONE_ROOTSEL;
- if (besthitresult & BONESEL_TIP)
+ }
+ if (best.hitresult & BONESEL_TIP) {
*r_selmask |= BONE_TIPSEL;
- if (besthitresult & BONESEL_BONE)
+ }
+ if (best.hitresult & BONESEL_BONE) {
*r_selmask |= BONE_SELECTED;
- return ebone;
+ }
+ MEM_freeN(bases);
+ return best.ebone;
}
}
*r_selmask = 0;
+ *r_base = NULL;
+ MEM_freeN(bases);
return NULL;
}
-void ED_armature_deselect_all(Object *obedit)
+void ED_armature_edit_deselect_all(Object *obedit)
{
bArmature *arm = obedit->data;
EditBone *ebone;
@@ -454,7 +570,7 @@ void ED_armature_deselect_all(Object *obedit)
}
}
-void ED_armature_deselect_all_visible(Object *obedit)
+void ED_armature_edit_deselect_all_visible(Object *obedit)
{
bArmature *arm = obedit->data;
EditBone *ebone;
@@ -466,7 +582,24 @@ void ED_armature_deselect_all_visible(Object *obedit)
}
}
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
+}
+
+
+void ED_armature_edit_deselect_all_multi(struct Object **objects, uint objects_len)
+{
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ ED_armature_edit_deselect_all(obedit);
+ }
+}
+
+void ED_armature_edit_deselect_all_visible_multi(struct Object **objects, uint objects_len)
+{
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ ED_armature_edit_deselect_all_visible(obedit);
+ }
}
/* accounts for connected parents */
@@ -481,27 +614,27 @@ static int ebone_select_flag(EditBone *ebone)
}
/* context: editmode armature in view3d */
-bool ED_armature_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
+bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
{
- Object *obedit = CTX_data_edit_object(C);
- bArmature *arm = obedit->data;
- EvaluationContext eval_ctx;
ViewContext vc;
EditBone *nearBone = NULL;
int selmask;
+ Base *basact = NULL;
- CTX_data_eval_ctx(C, &eval_ctx);
ED_view3d_viewcontext_init(C, &vc);
+ vc.mval[0] = mval[0];
+ vc.mval[1] = mval[1];
- if (BIF_sk_selectStroke(C, mval, extend)) {
- return true;
- }
-
- nearBone = get_nearest_editbonepoint(&eval_ctx, &vc, mval, arm->edbo, true, true, &selmask);
+ nearBone = get_nearest_editbonepoint(&vc, true, true, &basact, &selmask);
if (nearBone) {
+ ED_view3d_viewcontext_init_object(&vc, basact->object);
+ bArmature *arm = vc.obedit->data;
if (!extend && !deselect && !toggle) {
- ED_armature_deselect_all(obedit);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len);
+ ED_armature_edit_deselect_all_multi(objects, objects_len);
+ MEM_freeN(objects);
}
/* by definition the non-root connected bones have no root point drawn,
@@ -572,16 +705,21 @@ bool ED_armature_select_pick(bContext *C, const int mval[2], bool extend, bool d
nearBone->flag |= selmask;
}
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
if (nearBone) {
/* then now check for active status */
if (ebone_select_flag(nearBone)) {
arm->act_edbone = nearBone;
}
+
+ if (vc.view_layer->basact != basact) {
+ vc.view_layer->basact = basact;
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, vc.scene);
+ }
}
-
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit);
+
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object);
return true;
}
@@ -716,7 +854,7 @@ static void armature_select_more_less(Object *ob, bool more)
EditBone *ebone;
/* XXX, eventually we shouldn't need this - campbell */
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
/* count bones & store selection state */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
@@ -746,7 +884,7 @@ static void armature_select_more_less(Object *ob, bool more)
ebone->temp.p = NULL;
}
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
}
static int armature_de_select_more_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1151,7 +1289,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
@@ -1207,7 +1345,7 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op)
EditBone *ebone_mirror;
int flag_new = extend ? EBONE_PREV_FLAG_GET(ebone) : 0;
- if ((ebone_mirror = ED_armature_bone_get_mirrored(arm->edbo, ebone)) &&
+ if ((ebone_mirror = ED_armature_ebone_get_mirrored(arm->edbo, ebone)) &&
(EBONE_VISIBLE(arm, ebone_mirror)))
{
const int flag_mirror = EBONE_PREV_FLAG_GET(ebone_mirror);
@@ -1231,7 +1369,7 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op)
arm->act_edbone = ebone_mirror_act;
}
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -1294,17 +1432,23 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const
EditBone *ebone_isect_parent = NULL;
EditBone *ebone_isect_child[2];
bool changed;
+ Base *base_dst = NULL;
view3d_operator_needs_opengl(C);
ebone_src = arm->act_edbone;
- ebone_dst = get_nearest_bone(C, event->mval, false);
+ ebone_dst = get_nearest_bone(C, event->mval, false, &base_dst);
/* fallback to object selection */
if (ELEM(NULL, ebone_src, ebone_dst) || (ebone_src == ebone_dst)) {
return OPERATOR_PASS_THROUGH;
}
+ if (base_dst && base_dst->object != obedit) {
+ /* Disconnected, ignore. */
+ return OPERATOR_CANCELLED;
+ }
+
ebone_isect_child[0] = ebone_src;
ebone_isect_child[1] = ebone_dst;
@@ -1316,7 +1460,7 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const
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))) {
+ else if ((ebone_isect_parent = ED_armature_ebone_find_shared_parent(ebone_isect_child, 2))) {
/* pass */
}
else {
@@ -1351,7 +1495,7 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const
if (changed) {
arm->act_edbone = ebone_dst;
- ED_armature_sync_selection(arm->edbo);
+ ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index 5c8e08a0d89..1722cbd5c5c 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -60,10 +60,6 @@
#include "armature_intern.h"
#include "meshlaplacian.h"
-#if 0
-#include "reeb.h"
-#endif
-
/* ********************************** Bone Skinning *********************************************** */
static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap)
@@ -251,7 +247,7 @@ static void envelope_bone_weighting(
}
static void add_verts_to_dgroups(
- ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *par,
+ ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, Object *par,
int heat, const bool mirror)
{
/* This functions implements the automatic computation of vertex group
@@ -377,7 +373,7 @@ static void add_verts_to_dgroups(
if (wpmode) {
/* if in weight paint mode, use final verts from derivedmesh */
- DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
if (dm->foreachMappedVert) {
mesh_get_mapped_verts_coords(dm, verts, mesh->totvert);
@@ -431,8 +427,8 @@ static void add_verts_to_dgroups(
MEM_freeN(verts);
}
-void create_vgroups_from_armature(
- ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *par,
+void ED_object_vgroup_calc_from_armature(
+ ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, Object *par,
const int mode, const bool mirror)
{
/* Lets try to create some vertex groups
@@ -459,6 +455,6 @@ void create_vgroups_from_armature(
* that are populated with the vertices for which the
* bone is closest.
*/
- add_verts_to_dgroups(reports, eval_ctx, scene, ob, par, (mode == ARM_GROUPS_AUTO), mirror);
+ add_verts_to_dgroups(reports, depsgraph, scene, ob, par, (mode == ARM_GROUPS_AUTO), mirror);
}
}
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index aa0aa0e03ff..ffa8b9f5007 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -54,7 +54,7 @@
/* Validation */
/* Sync selection to parent for connected children */
-void ED_armature_sync_selection(ListBase *edbo)
+void ED_armature_edit_sync_selection(ListBase *edbo)
{
EditBone *ebo;
@@ -76,7 +76,7 @@ void ED_armature_sync_selection(ListBase *edbo)
}
}
-void ED_armature_validate_active(struct bArmature *arm)
+void ED_armature_edit_validate_active(struct bArmature *arm)
{
EditBone *ebone = arm->act_edbone;
@@ -137,7 +137,7 @@ void bone_free(bArmature *arm, EditBone *bone)
/**
* \param clear_connected: When false caller is responsible for keeping the flag in a valid state.
*/
-void ED_armature_edit_bone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_connected)
+void ED_armature_ebone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_connected)
{
EditBone *curBone;
@@ -154,9 +154,9 @@ void ED_armature_edit_bone_remove_ex(bArmature *arm, EditBone *exBone, bool clea
bone_free(arm, exBone);
}
-void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
+void ED_armature_ebone_remove(bArmature *arm, EditBone *exBone)
{
- ED_armature_edit_bone_remove_ex(arm, exBone, true);
+ ED_armature_ebone_remove_ex(arm, exBone, true);
}
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child)
@@ -175,7 +175,7 @@ bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebon
* \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)
+EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot)
{
unsigned int i;
EditBone *ebone_iter;
@@ -255,7 +255,7 @@ void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4])
/**
* Return a pointer to the bone of the given name
*/
-EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name)
+EditBone *ED_armature_ebone_find_name(const ListBase *edbo, const char *name)
{
return BLI_findstring(edbo, name, offsetof(EditBone, name));
}
@@ -267,7 +267,7 @@ EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name)
/**
* \see #BKE_pose_channel_get_mirrored (pose-mode, matching function)
*/
-EditBone *ED_armature_bone_get_mirrored(const ListBase *edbo, EditBone *ebo)
+EditBone *ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo)
{
char name_flip[MAXBONENAME];
@@ -277,7 +277,7 @@ EditBone *ED_armature_bone_get_mirrored(const ListBase *edbo, EditBone *ebo)
BLI_string_flip_side_name(name_flip, ebo->name, false, sizeof(name_flip));
if (!STREQ(name_flip, ebo->name)) {
- return ED_armature_bone_find_name(edbo, name_flip);
+ return ED_armature_ebone_find_name(edbo, name_flip);
}
return NULL;
@@ -297,7 +297,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (arm->layer & curBone->layer) {
if (curBone->flag & flag) {
- ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone);
+ ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
if (ebone_mirr)
ebone_mirr->flag |= (curBone->flag & flag);
}
@@ -326,7 +326,7 @@ void armature_tag_select_mirrored(bArmature *arm)
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (arm->layer & curBone->layer) {
if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) {
- EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone);
+ EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
if (ebone_mirr && (ebone_mirr->flag & BONE_SELECTED) == 0) {
ebone_mirr->flag |= BONE_DONE;
}
@@ -336,7 +336,7 @@ void armature_tag_select_mirrored(bArmature *arm)
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (curBone->flag & BONE_DONE) {
- EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone);
+ EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
curBone->flag |= ebone_mirr->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
}
}
@@ -359,7 +359,7 @@ void armature_tag_unselect(bArmature *arm)
/* if editbone (partial) selected, copy data */
/* context; editmode armature, with mirror editing enabled */
-void transform_armature_mirror_update(Object *obedit)
+void ED_armature_edit_transform_mirror_update(Object *obedit)
{
bArmature *arm = obedit->data;
EditBone *ebo, *eboflip;
@@ -367,7 +367,7 @@ void transform_armature_mirror_update(Object *obedit)
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
/* no layer check, correct mirror is more important */
if (ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) {
- eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo);
+ eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo);
if (eboflip) {
/* we assume X-axis flipping for now */
@@ -437,7 +437,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
eBone = MEM_callocN(sizeof(EditBone), "make_editbone");
/* Copy relevant data from bone to eBone
- * Keep selection logic in sync with ED_armature_sync_selection.
+ * Keep selection logic in sync with ED_armature_edit_sync_selection.
*/
eBone->parent = parent;
BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name));
@@ -716,8 +716,6 @@ void ED_armature_to_edit(bArmature *arm)
ED_armature_edit_free(arm);
arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature");
arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone);
-
-// BIF_freeTemplates(); /* force template update when entering editmode */
}
/* *************************************************************** */
diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c
deleted file mode 100644
index 4eb9e3ecc79..00000000000
--- a/source/blender/editors/armature/editarmature_generate.c
+++ /dev/null
@@ -1,305 +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 blender/editors/armature/editarmature_generate.c
- * \ingroup edarmature
- */
-
-#include "DNA_scene_types.h"
-#include "DNA_armature_types.h"
-
-#include "BLI_math.h"
-#include "BLI_graph.h"
-
-#include "ED_armature.h"
-#include "BIF_generate.h"
-
-void setBoneRollFromNormal(EditBone *bone, const float no[3], float UNUSED(invmat[4][4]), float tmat[3][3])
-{
- if (no != NULL && !is_zero_v3(no)) {
- float normal[3];
-
- copy_v3_v3(normal, no);
- mul_m3_v3(tmat, normal);
-
- bone->roll = ED_rollBoneToVector(bone, normal, false);
- }
-}
-
-float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], float n[3])
-{
- int len = 2 + abs(end - start);
-
- if (len > 2) {
- float avg_t = 0.0f;
- float s_t = 0.0f;
- float s_xyz = 0.0f;
- int i;
-
- /* First pass, calculate average */
- for (i = start; i <= end; i++) {
- float v[3];
-
- IT_peek(iter, i);
- sub_v3_v3v3(v, iter->p, v0);
- avg_t += dot_v3v3(v, n);
- }
-
- avg_t /= dot_v3v3(n, n);
- avg_t += 1.0f; /* adding start (0) and end (1) values */
- avg_t /= len;
-
- /* Second pass, calculate s_xyz and s_t */
- for (i = start; i <= end; i++) {
- float v[3], d[3];
- float dt;
-
- IT_peek(iter, i);
- sub_v3_v3v3(v, iter->p, v0);
- project_v3_v3v3(d, v, n);
- sub_v3_v3(v, d);
-
- dt = len_v3(d) - avg_t;
-
- s_t += dt * dt;
- s_xyz += dot_v3v3(v, v);
- }
-
- /* adding start(0) and end(1) values to s_t */
- s_t += (avg_t * avg_t) + (1 - avg_t) * (1 - avg_t);
-
- return 1.0f - s_xyz / s_t;
- }
- else {
- return 1.0f;
- }
-}
-
-int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int start, int end, float UNUSED(head[3]), float p[3])
-{
- static float stroke_length = 0;
- static float current_length;
- static char n;
- float *v1, *v2;
- float length_threshold;
- int i;
-
- if (stroke_length == 0) {
- current_length = 0;
-
- IT_peek(iter, start);
- v1 = iter->p;
-
- for (i = start + 1; i <= end; i++) {
- IT_peek(iter, i);
- v2 = iter->p;
-
- stroke_length += len_v3v3(v1, v2);
-
- v1 = v2;
- }
-
- n = 0;
- current_length = 0;
- }
-
- n++;
-
- length_threshold = n * stroke_length / toolsettings->skgen_subdivision_number;
-
- IT_peek(iter, start);
- v1 = iter->p;
-
- /* < and not <= because we don't care about end, it is P_EXACT anyway */
- for (i = start + 1; i < end; i++) {
- IT_peek(iter, i);
- v2 = iter->p;
-
- current_length += len_v3v3(v1, v2);
-
- if (current_length >= length_threshold) {
- copy_v3_v3(p, v2);
- return i;
- }
-
- v1 = v2;
- }
-
- stroke_length = 0;
-
- return -1;
-}
-int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int start, int end, float head[3], float p[3])
-{
- float correlation_threshold = toolsettings->skgen_correlation_limit;
- float *start_p;
- float n[3];
- int i;
-
- IT_peek(iter, start);
- start_p = iter->p;
-
- for (i = start + 2; i <= end; i++) {
- /* Calculate normal */
- IT_peek(iter, i);
- sub_v3_v3v3(n, iter->p, head);
-
- if (calcArcCorrelation(iter, start, i, start_p, n) < correlation_threshold) {
- IT_peek(iter, i - 1);
- copy_v3_v3(p, iter->p);
- return i - 1;
- }
- }
-
- return -1;
-}
-
-int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int start, int end, float head[3], float p[3])
-{
- float lengthLimit = toolsettings->skgen_length_limit;
- int same = 1;
- int i;
-
- i = start + 1;
- while (i <= end) {
- float *vec0;
- float *vec1;
-
- IT_peek(iter, i - 1);
- vec0 = iter->p;
-
- IT_peek(iter, i);
- vec1 = iter->p;
-
- /* If lengthLimit hits the current segment */
- if (len_v3v3(vec1, head) > lengthLimit) {
- if (same == 0) {
- float dv[3], off[3];
- float a, b, c, f;
-
- /* Solve quadratic distance equation */
- sub_v3_v3v3(dv, vec1, vec0);
- a = dot_v3v3(dv, dv);
-
- sub_v3_v3v3(off, vec0, head);
- b = 2 * dot_v3v3(dv, off);
-
- c = dot_v3v3(off, off) - (lengthLimit * lengthLimit);
-
- f = (-b + sqrtf(b * b - 4 * a * c)) / (2 * a);
-
- //printf("a %f, b %f, c %f, f %f\n", a, b, c, f);
-
- if (isnan(f) == 0 && f < 1.0f) {
- copy_v3_v3(p, dv);
- mul_v3_fl(p, f);
- add_v3_v3(p, vec0);
- }
- else {
- copy_v3_v3(p, vec1);
- }
- }
- else {
- float dv[3];
-
- sub_v3_v3v3(dv, vec1, vec0);
- normalize_v3(dv);
-
- copy_v3_v3(p, dv);
- mul_v3_fl(p, lengthLimit);
- add_v3_v3(p, head);
- }
-
- return i - 1; /* restart at lower bound */
- }
- else {
- i++;
- same = 0; // Reset same
- }
- }
-
- return -1;
-}
-
-EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *UNUSED(editbones), BArcIterator *iter,
- float invmat[4][4], float tmat[3][3], NextSubdivisionFunc next_subdividion)
-{
- EditBone *lastBone = NULL;
- EditBone *child = NULL;
- EditBone *parent = NULL;
- float *normal = NULL;
- float size_buffer = 1.2;
- int bone_start = 0;
- int end = iter->length;
- int index;
-
- IT_head(iter);
-
- parent = ED_armature_edit_bone_add(arm, "Bone");
- copy_v3_v3(parent->head, iter->p);
-
- if (iter->size > FLT_EPSILON) {
- parent->rad_head = iter->size * size_buffer;
- }
-
- normal = iter->no;
-
- index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
- while (index != -1) {
- IT_peek(iter, index);
-
- child = ED_armature_edit_bone_add(arm, "Bone");
- copy_v3_v3(child->head, parent->tail);
- child->parent = parent;
- child->flag |= BONE_CONNECTED;
-
- if (iter->size > FLT_EPSILON) {
- child->rad_head = iter->size * size_buffer;
- parent->rad_tail = iter->size * size_buffer;
- }
-
- /* going to next bone, fix parent */
- mul_m4_v3(invmat, parent->tail);
- mul_m4_v3(invmat, parent->head);
- setBoneRollFromNormal(parent, normal, invmat, tmat);
-
- parent = child; // new child is next parent
- bone_start = index; // start next bone from current index
-
- normal = iter->no; /* use normal at head, not tail */
-
- index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
- }
-
- iter->tail(iter);
-
- copy_v3_v3(parent->tail, iter->p);
- if (iter->size > FLT_EPSILON) {
- parent->rad_tail = iter->size * size_buffer;
- }
-
- /* fix last bone */
- mul_m4_v3(invmat, parent->tail);
- mul_m4_v3(invmat, parent->head);
- setBoneRollFromNormal(parent, iter->no, invmat, tmat);
- lastBone = parent;
-
- return lastBone;
-}
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
deleted file mode 100644
index 3dd41f25e09..00000000000
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ /dev/null
@@ -1,2640 +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.
- *
- * Contributor(s): Martin Poirier
- *
- * ***** END GPL LICENSE BLOCK *****
- * autoarmature.c: Interface for automagically manipulating armature (retarget, created, ...)
- */
-
-/** \file blender/editors/armature/editarmature_retarget.c
- * \ingroup edarmature
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "PIL_time.h"
-
-#include "DNA_armature_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-
-#include "BKE_constraint.h"
-#include "BKE_armature.h"
-#include "BKE_context.h"
-
-#include "ED_armature.h"
-#include "ED_undo.h"
-
-#include "BIF_retarget.h"
-
-#include "armature_intern.h"
-
-/************ RIG RETARGET DATA STRUCTURES ***************/
-
-typedef struct MemoNode {
- float weight;
- int next;
-} MemoNode;
-
-typedef struct RetargetParam {
- RigGraph *rigg;
- RigArc *iarc;
- RigNode *inode_start;
- bContext *context;
-} RetargetParam;
-
-typedef enum {
- RETARGET_LENGTH,
- RETARGET_AGGRESSIVE
-} RetargetMode;
-
-typedef enum {
- METHOD_BRUTE_FORCE = 0,
- METHOD_MEMOIZE = 1
-} RetargetMethod;
-
-typedef enum {
- ARC_FREE = 0,
- ARC_TAKEN = 1,
- ARC_USED = 2
-} ArcUsageFlags;
-
-static RigGraph *GLOBAL_RIGG = NULL;
-
-/*******************************************************************************************************/
-
-void exec_retargetArctoArc(TaskPool * __restrict pool, void *taskdata, int threadid);
-
-static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second);
-float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]);
-
-/* two levels */
-#define SHAPE_LEVELS (SHAPE_RADIX * SHAPE_RADIX)
-
-/*********************************** EDITBONE UTILS ****************************************************/
-
-static int countEditBoneChildren(ListBase *list, EditBone *parent)
-{
- EditBone *ebone;
- int count = 0;
-
- for (ebone = list->first; ebone; ebone = ebone->next) {
- if (ebone->parent == parent) {
- count++;
- }
- }
-
- return count;
-}
-
-static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n)
-{
- EditBone *ebone;
-
- for (ebone = list->first; ebone; ebone = ebone->next) {
- if (ebone->parent == parent) {
- if (n == 0) {
- return ebone;
- }
- n--;
- }
- }
-
- return NULL;
-}
-
-static void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3])
-{
- float mat[3][3], nor[3];
-
- sub_v3_v3v3(nor, bone->tail, bone->head);
-
- vec_roll_to_mat3(nor, roll, mat);
- copy_v3_v3(up_axis, mat[2]);
-}
-
-static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float qroll[4], float aligned_axis[3])
-{
- float nor[3], new_up_axis[3], x_axis[3], z_axis[3];
-
- copy_v3_v3(new_up_axis, old_up_axis);
- mul_qt_v3(qrot, new_up_axis);
-
- sub_v3_v3v3(nor, bone->tail, bone->head);
-
- cross_v3_v3v3(x_axis, nor, aligned_axis);
- cross_v3_v3v3(z_axis, x_axis, nor);
-
- normalize_v3(new_up_axis);
- normalize_v3(x_axis);
- normalize_v3(z_axis);
-
- if (dot_v3v3(new_up_axis, x_axis) < 0) {
- negate_v3(x_axis);
- }
-
- if (dot_v3v3(new_up_axis, z_axis) < 0) {
- negate_v3(z_axis);
- }
-
- if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) {
- rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */
- return ED_rollBoneToVector(bone, x_axis, false);
- }
- else {
- rotation_between_vecs_to_quat(qroll, new_up_axis, z_axis); /* set roll rotation quat */
- return ED_rollBoneToVector(bone, z_axis, false);
- }
-}
-
-static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float qroll[4], float up_axis[3])
-{
- if (previous == NULL) {
- /* default to up_axis if no previous */
- return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis);
- }
- else {
- float new_up_axis[3];
- float vec_first[3], vec_second[3], normal[3];
-
- if (previous->bone) {
- sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head);
- }
- else if (previous->prev->bone) {
- sub_v3_v3v3(vec_first, edge->bone->head, previous->prev->bone->tail);
- }
- else {
- /* default to up_axis if first bone in the chain is an offset */
- return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis);
- }
-
- sub_v3_v3v3(vec_second, edge->bone->tail, edge->bone->head);
-
- normalize_v3(vec_first);
- normalize_v3(vec_second);
-
- cross_v3_v3v3(normal, vec_first, vec_second);
- normalize_v3(normal);
-
- axis_angle_to_quat(qroll, vec_second, edge->up_angle);
-
- mul_qt_v3(qroll, normal);
-
- copy_v3_v3(new_up_axis, edge->up_axis);
- mul_qt_v3(qrot, new_up_axis);
-
- normalize_v3(new_up_axis);
-
- /* real qroll between normal and up_axis */
- rotation_between_vecs_to_quat(qroll, new_up_axis, normal);
-
- return ED_rollBoneToVector(edge->bone, normal, false);
- }
-}
-
-float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4])
-{
- float new_up_axis[3];
-
- copy_v3_v3(new_up_axis, old_up_axis);
- mul_qt_v3(qrot, new_up_axis);
-
- return ED_rollBoneToVector(bone, new_up_axis, false);
-}
-
-/************************************ DESTRUCTORS ******************************************************/
-
-static void RIG_freeRigArc(BArc *arc)
-{
- BLI_freelistN(&((RigArc *)arc)->edges);
-}
-
-void RIG_freeRigGraph(BGraph *rg)
-{
- RigGraph *rigg = (RigGraph *)rg;
- BNode *node;
- BArc *arc;
-
- BLI_task_pool_free(rigg->task_pool);
- BLI_task_scheduler_free(rigg->task_scheduler);
-
- if (rigg->link_mesh) {
- REEB_freeGraph(rigg->link_mesh);
- }
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RIG_freeRigArc(arc);
- }
- BLI_freelistN(&rg->arcs);
-
- for (node = rg->nodes.first; node; node = node->next) {
- BLI_freeNode(rg, (BNode *)node);
- }
- BLI_freelistN(&rg->nodes);
-
- BLI_freelistN(&rigg->controls);
-
- BLI_ghash_free(rigg->bones_map, NULL, NULL);
- BLI_ghash_free(rigg->controls_map, NULL, NULL);
-
- if (rigg->flag & RIG_FREE_BONELIST) {
- BLI_freelistN(rigg->editbones);
- MEM_freeN(rigg->editbones);
- }
-
- MEM_freeN(rg);
-}
-
-/************************************* ALLOCATORS ******************************************************/
-
-static RigGraph *newRigGraph(void)
-{
- RigGraph *rg;
- int totthread;
-
- rg = MEM_callocN(sizeof(RigGraph), "rig graph");
-
- rg->head = NULL;
-
- rg->bones_map = BLI_ghash_str_new("newRigGraph bones gh");
- rg->controls_map = BLI_ghash_str_new("newRigGraph cont gh");
-
- rg->free_arc = RIG_freeRigArc;
- rg->free_node = NULL;
-
-#ifdef USE_THREADS
- totthread = TASK_SCHEDULER_AUTO_THREADS;
-#else
- totthread = TASK_SCHEDULER_SINGLE_THREAD;
-#endif
-
- rg->task_scheduler = BLI_task_scheduler_create(totthread);
- rg->task_pool = BLI_task_pool_create(rg->task_scheduler, NULL);
-
- return rg;
-}
-
-static RigArc *newRigArc(RigGraph *rg)
-{
- RigArc *arc;
-
- arc = MEM_callocN(sizeof(RigArc), "rig arc");
- arc->count = 0;
- BLI_addtail(&rg->arcs, arc);
-
- return arc;
-}
-
-static RigControl *newRigControl(RigGraph *rg)
-{
- RigControl *ctrl;
-
- ctrl = MEM_callocN(sizeof(RigControl), "rig control");
-
- BLI_addtail(&rg->controls, ctrl);
-
- return ctrl;
-}
-
-static RigNode *newRigNodeHead(RigGraph *rg, RigArc *arc, float p[3])
-{
- RigNode *node;
- node = MEM_callocN(sizeof(RigNode), "rig node");
- BLI_addtail(&rg->nodes, node);
-
- copy_v3_v3(node->p, p);
- node->degree = 1;
- node->arcs = NULL;
-
- arc->head = node;
-
- return node;
-}
-
-static void addRigNodeHead(RigGraph *UNUSED(rg), RigArc *arc, RigNode *node)
-{
- node->degree++;
-
- arc->head = node;
-}
-
-static RigNode *newRigNode(RigGraph *rg, float p[3])
-{
- RigNode *node;
- node = MEM_callocN(sizeof(RigNode), "rig node");
- BLI_addtail(&rg->nodes, node);
-
- copy_v3_v3(node->p, p);
- node->degree = 0;
- node->arcs = NULL;
-
- return node;
-}
-
-static RigNode *newRigNodeTail(RigGraph *rg, RigArc *arc, float p[3])
-{
- RigNode *node = newRigNode(rg, p);
-
- node->degree = 1;
- arc->tail = node;
-
- return node;
-}
-
-static void RIG_appendEdgeToArc(RigArc *arc, RigEdge *edge)
-{
- BLI_addtail(&arc->edges, edge);
-
- if (edge->prev == NULL) {
- copy_v3_v3(edge->head, arc->head->p);
- }
- else {
- RigEdge *last_edge = edge->prev;
- copy_v3_v3(edge->head, last_edge->tail);
- RIG_calculateEdgeAngles(last_edge, edge);
- }
-
- edge->length = len_v3v3(edge->head, edge->tail);
-
- arc->length += edge->length;
-
- arc->count += 1;
-}
-
-static void RIG_addEdgeToArc(RigArc *arc, float tail[3], EditBone *bone)
-{
- RigEdge *edge;
-
- edge = MEM_callocN(sizeof(RigEdge), "rig edge");
-
- copy_v3_v3(edge->tail, tail);
- edge->bone = bone;
-
- if (bone) {
- getEditBoneRollUpAxis(bone, bone->roll, edge->up_axis);
- }
-
- RIG_appendEdgeToArc(arc, edge);
-}
-/************************************** CLONING TEMPLATES **********************************************/
-
-static void renameTemplateBone(char *name, char *template_name, ListBase *editbones, char *side_string, char *num_string)
-{
- int i, j;
-
- for (i = 0, j = 0; i < (MAXBONENAME - 1) && j < (MAXBONENAME - 1) && template_name[i] != '\0'; i++) {
- if (template_name[i] == '&') {
- if (template_name[i + 1] == 'S' || template_name[i + 1] == 's') {
- j += BLI_strncpy_rlen(name + j, side_string, MAXBONENAME);
- i++;
- }
- else if (template_name[i + 1] == 'N' || template_name[i + 1] == 'n') {
- j += BLI_strncpy_rlen(name + j, num_string, MAXBONENAME);
- i++;
- }
- else {
- name[j] = template_name[i];
- j++;
- }
- }
- else {
- name[j] = template_name[i];
- j++;
- }
- }
-
- name[j] = '\0';
-
- unique_editbone_name(editbones, name, NULL);
-}
-
-static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ctrl, GHash *ptr_hash, char *side_string, char *num_string)
-{
- RigControl *ctrl;
- char name[MAXBONENAME];
-
- ctrl = newRigControl(rg);
-
- copy_v3_v3(ctrl->head, src_ctrl->head);
- copy_v3_v3(ctrl->tail, src_ctrl->tail);
- copy_v3_v3(ctrl->up_axis, src_ctrl->up_axis);
- copy_v3_v3(ctrl->offset, src_ctrl->offset);
-
- ctrl->tail_mode = src_ctrl->tail_mode;
- ctrl->flag = src_ctrl->flag;
-
- renameTemplateBone(name, src_ctrl->bone->name, rg->editbones, side_string, num_string);
- ctrl->bone = duplicateEditBoneObjects(src_ctrl->bone, name, rg->editbones, src_rg->ob, rg->ob);
- ctrl->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
- BLI_ghash_insert(ptr_hash, src_ctrl->bone, ctrl->bone);
-
- ctrl->link = src_ctrl->link;
- ctrl->link_tail = src_ctrl->link_tail;
-
- return ctrl;
-}
-
-static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *ptr_hash, char *side_string, char *num_string)
-{
- RigEdge *src_edge;
- RigArc *arc;
-
- arc = newRigArc(rg);
-
- arc->head = BLI_ghash_lookup(ptr_hash, src_arc->head);
- arc->tail = BLI_ghash_lookup(ptr_hash, src_arc->tail);
-
- arc->head->degree++;
- arc->tail->degree++;
-
- arc->length = src_arc->length;
-
- arc->count = src_arc->count;
-
- for (src_edge = src_arc->edges.first; src_edge; src_edge = src_edge->next) {
- RigEdge *edge;
-
- edge = MEM_callocN(sizeof(RigEdge), "rig edge");
-
- copy_v3_v3(edge->head, src_edge->head);
- copy_v3_v3(edge->tail, src_edge->tail);
- copy_v3_v3(edge->up_axis, src_edge->up_axis);
-
- edge->length = src_edge->length;
- edge->angle = src_edge->angle;
- edge->up_angle = src_edge->up_angle;
-
- if (src_edge->bone != NULL) {
- char name[MAXBONENAME];
- renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string);
- edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob);
- edge->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
- BLI_ghash_insert(ptr_hash, src_edge->bone, edge->bone);
- }
-
- BLI_addtail(&arc->edges, edge);
- }
-
- return arc;
-}
-
-static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, char *side_string, char *num_string)
-{
- GHash *ptr_hash;
- RigNode *node;
- RigArc *arc;
- RigControl *ctrl;
- RigGraph *rg;
-
- ptr_hash = BLI_ghash_ptr_new("cloneRigGraph gh");
-
- rg = newRigGraph();
-
- rg->ob = ob;
- rg->editbones = editbones;
-
- preEditBoneDuplicate(rg->editbones); /* prime bones for duplication */
- preEditBoneDuplicate(src->editbones); /* prime bones for duplication */
-
- /* Clone nodes */
- for (node = src->nodes.first; node; node = node->next) {
- RigNode *cloned_node = newRigNode(rg, node->p);
- BLI_ghash_insert(ptr_hash, node, cloned_node);
- }
-
- rg->head = BLI_ghash_lookup(ptr_hash, src->head);
-
- /* Clone arcs */
- for (arc = src->arcs.first; arc; arc = arc->next) {
- cloneArc(rg, src, arc, ptr_hash, side_string, num_string);
- }
-
- /* Clone controls */
- for (ctrl = src->controls.first; ctrl; ctrl = ctrl->next) {
- cloneControl(rg, src, ctrl, ptr_hash, side_string, num_string);
- }
-
- /* Relink bones properly */
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *edge;
-
- for (edge = arc->edges.first; edge; edge = edge->next) {
- if (edge->bone != NULL) {
- EditBone *bone;
-
- updateDuplicateSubtargetObjects(edge->bone, src->editbones, src->ob, rg->ob);
-
- if (edge->bone->parent) {
- bone = BLI_ghash_lookup(ptr_hash, edge->bone->parent);
-
- if (bone != NULL) {
- edge->bone->parent = bone;
- }
- else {
- /* disconnect since parent isn't cloned
- * this will only happen when cloning from selected bones
- * */
- edge->bone->flag &= ~BONE_CONNECTED;
- }
- }
- }
- }
- }
-
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- EditBone *bone;
-
- updateDuplicateSubtargetObjects(ctrl->bone, src->editbones, src->ob, rg->ob);
-
- if (ctrl->bone->parent) {
- bone = BLI_ghash_lookup(ptr_hash, ctrl->bone->parent);
-
- if (bone != NULL) {
- ctrl->bone->parent = bone;
- }
- else {
- /* disconnect since parent isn't cloned
- * this will only happen when cloning from selected bones
- * */
- ctrl->bone->flag &= ~BONE_CONNECTED;
- }
- }
-
- ctrl->link = BLI_ghash_lookup(ptr_hash, ctrl->link);
- ctrl->link_tail = BLI_ghash_lookup(ptr_hash, ctrl->link_tail);
- }
-
- BLI_ghash_free(ptr_hash, NULL, NULL);
-
- return rg;
-}
-
-
-/*******************************************************************************************************/
-
-static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second)
-{
- float vec_first[3], vec_second[3];
-
- sub_v3_v3v3(vec_first, edge_first->tail, edge_first->head);
- sub_v3_v3v3(vec_second, edge_second->tail, edge_second->head);
-
- normalize_v3(vec_first);
- normalize_v3(vec_second);
-
- edge_first->angle = angle_normalized_v3v3(vec_first, vec_second);
-
- if (edge_second->bone != NULL) {
- float normal[3];
-
- cross_v3_v3v3(normal, vec_first, vec_second);
- normalize_v3(normal);
-
- edge_second->up_angle = angle_normalized_v3v3(normal, edge_second->up_axis);
- }
-}
-
-/************************************ CONTROL BONES ****************************************************/
-
-static void RIG_addControlBone(RigGraph *rg, EditBone *bone)
-{
- RigControl *ctrl = newRigControl(rg);
- ctrl->bone = bone;
- copy_v3_v3(ctrl->head, bone->head);
- copy_v3_v3(ctrl->tail, bone->tail);
- getEditBoneRollUpAxis(bone, bone->roll, ctrl->up_axis);
- ctrl->tail_mode = TL_NONE;
-
- BLI_ghash_insert(rg->controls_map, bone->name, ctrl);
-}
-
-static int RIG_parentControl(RigControl *ctrl, EditBone *link)
-{
- if (link) {
- float offset[3];
- int flag = 0;
-
- sub_v3_v3v3(offset, ctrl->bone->head, link->head);
-
- /* if root matches, check for direction too */
- if (dot_v3v3(offset, offset) < 0.0001f) {
- float vbone[3], vparent[3];
-
- flag |= RIG_CTRL_FIT_ROOT;
-
- sub_v3_v3v3(vbone, ctrl->bone->tail, ctrl->bone->head);
- sub_v3_v3v3(vparent, link->tail, link->head);
-
- /* test for opposite direction */
- if (dot_v3v3(vbone, vparent) > 0) {
- float nor[3];
- float len;
-
- cross_v3_v3v3(nor, vbone, vparent);
-
- len = dot_v3v3(nor, nor);
- if (len < 0.0001f) {
- flag |= RIG_CTRL_FIT_BONE;
- }
- }
- }
-
- /* Bail out if old one is automatically better */
- if (flag < ctrl->flag) {
- return 0;
- }
-
- /* if there's already a link
- * overwrite only if new link is higher in the chain */
- if (ctrl->link && flag == ctrl->flag) {
- EditBone *bone = NULL;
-
- for (bone = ctrl->link; bone; bone = bone->parent) {
- /* if link is in the chain, break and use that one */
- if (bone == link) {
- break;
- }
- }
-
- /* not in chain, don't update link */
- if (bone == NULL) {
- return 0;
- }
- }
-
-
- ctrl->link = link;
- ctrl->flag = flag;
-
- copy_v3_v3(ctrl->offset, offset);
-
- return 1;
- }
-
- return 0;
-}
-
-static void RIG_reconnectControlBones(RigGraph *rg)
-{
- RigControl *ctrl;
- bool changed = true;
-
- /* first pass, link to deform bones */
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- bPoseChannel *pchan;
- bConstraint *con;
- int found = 0;
-
- /* DO SOME MAGIC HERE */
- for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- for (con = pchan->constraints.first; con; con = con->next) {
- const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
- ListBase targets = {NULL, NULL};
- bConstraintTarget *ct;
-
- /* constraint targets */
- if (cti && cti->get_constraint_targets) {
- int target_index;
-
- cti->get_constraint_targets(con, &targets);
-
- for (target_index = 0, ct = targets.first; ct; target_index++, ct = ct->next) {
- if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) {
- /* SET bone link to bone corresponding to pchan */
- EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name);
-
- /* Making sure bone is in this armature */
- if (link != NULL) {
- /* for pole targets, link to parent bone instead, if possible */
- if (con->type == CONSTRAINT_TYPE_KINEMATIC && target_index == 1) {
- if (link->parent && BLI_ghash_haskey(rg->bones_map, link->parent->name)) {
- link = link->parent;
- }
- }
-
- found = RIG_parentControl(ctrl, link);
- }
- }
- }
-
- if (cti->flush_constraint_targets)
- cti->flush_constraint_targets(con, &targets, 0);
- }
- }
- }
-
- /* if not found yet, check parent */
- if (found == 0) {
- if (ctrl->bone->parent) {
- /* make sure parent is a deforming bone
- * NULL if not
- * */
- EditBone *link = BLI_ghash_lookup(rg->bones_map, ctrl->bone->parent->name);
-
- found = RIG_parentControl(ctrl, link);
- }
-
- /* check if bone is not superposed on another one */
- {
- RigArc *arc;
- RigArc *best_arc = NULL;
- EditBone *link = NULL;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *edge;
- for (edge = arc->edges.first; edge; edge = edge->next) {
- if (edge->bone) {
- int fit = 0;
-
- fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001f;
- fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001f;
-
- if (fit) {
- /* pick the bone on the arc with the lowest symmetry level
- * means you connect control to the trunk of the skeleton */
- if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level) {
- best_arc = arc;
- link = edge->bone;
- }
- }
- }
- }
- }
-
- found = RIG_parentControl(ctrl, link);
- }
- }
-
- /* if not found yet, check child */
- if (found == 0) {
- RigArc *arc;
- RigArc *best_arc = NULL;
- EditBone *link = NULL;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *edge;
- for (edge = arc->edges.first; edge; edge = edge->next) {
- if (edge->bone && edge->bone->parent == ctrl->bone) {
- /* pick the bone on the arc with the lowest symmetry level
- * means you connect control to the trunk of the skeleton */
- if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level) {
- best_arc = arc;
- link = edge->bone;
- }
- }
- }
- }
-
- found = RIG_parentControl(ctrl, link);
- }
-
- }
-
-
- /* second pass, make chains in control bones */
- while (changed) {
- changed = false;
-
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- /* if control is not linked yet */
- if (ctrl->link == NULL) {
- bPoseChannel *pchan;
- bConstraint *con;
- RigControl *ctrl_parent = NULL;
- RigControl *ctrl_child;
- int found = 0;
-
- if (ctrl->bone->parent) {
- ctrl_parent = BLI_ghash_lookup(rg->controls_map, ctrl->bone->parent->name);
- }
-
- /* check constraints first */
-
- /* DO SOME MAGIC HERE */
- for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- for (con = pchan->constraints.first; con; con = con->next) {
- const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
- ListBase targets = {NULL, NULL};
- bConstraintTarget *ct;
-
- /* constraint targets */
- if (cti && cti->get_constraint_targets) {
- cti->get_constraint_targets(con, &targets);
-
- for (ct = targets.first; ct; ct = ct->next) {
- if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) {
- /* SET bone link to ctrl corresponding to pchan */
- RigControl *link = BLI_ghash_lookup(rg->controls_map, pchan->name);
-
- /* if owner is a control bone, link with it */
- if (link && link->link) {
- RIG_parentControl(ctrl, link->bone);
- found = 1;
- break;
- }
- }
- }
-
- if (cti->flush_constraint_targets)
- cti->flush_constraint_targets(con, &targets, 0);
- }
- }
- }
-
- if (found == 0) {
- /* check if parent is already linked */
- if (ctrl_parent && ctrl_parent->link) {
- RIG_parentControl(ctrl, ctrl_parent->bone);
- changed = true;
- }
- else {
- /* check childs */
- for (ctrl_child = rg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) {
- /* if a child is linked, link to that one */
- if (ctrl_child->link && ctrl_child->bone->parent == ctrl->bone) {
- RIG_parentControl(ctrl, ctrl_child->bone);
- changed = true;
- break;
- }
- }
- }
- }
- }
- }
- }
-
- /* third pass, link control tails */
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- /* fit bone already means full match, so skip those */
- if ((ctrl->flag & RIG_CTRL_FIT_BONE) == 0) {
- GHashIterator ghi;
-
- /* look on deform bones first */
- BLI_ghashIterator_init(&ghi, rg->bones_map);
-
- for (; !BLI_ghashIterator_done(&ghi); BLI_ghashIterator_step(&ghi)) {
- EditBone *bone = (EditBone *)BLI_ghashIterator_getValue(&ghi);
-
- /* don't link with parent */
- if (bone->parent != ctrl->bone) {
- if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01f) {
- ctrl->tail_mode = TL_HEAD;
- ctrl->link_tail = bone;
- break;
- }
- else if (len_v3v3(ctrl->bone->tail, bone->tail) < 0.01f) {
- ctrl->tail_mode = TL_TAIL;
- ctrl->link_tail = bone;
- break;
- }
- }
- }
-
- /* if we haven't found one yet, look in control bones */
- if (ctrl->tail_mode == TL_NONE) {
- }
- }
- }
-
-}
-
-/*******************************************************************************************************/
-
-static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigArc *joined_arc2)
-{
- RigEdge *edge, *next_edge;
-
- /* ignore cases where joint is at start or end */
- if (joined_arc1->head == joined_arc2->head || joined_arc1->tail == joined_arc2->tail) {
- return;
- }
-
- /* swap arcs to make sure arc1 is before arc2 */
- if (joined_arc1->head == joined_arc2->tail) {
- RigArc *tmp = joined_arc1;
- joined_arc1 = joined_arc2;
- joined_arc2 = tmp;
- }
-
- for (edge = joined_arc2->edges.first; edge; edge = next_edge) {
- next_edge = edge->next;
-
- RIG_appendEdgeToArc(joined_arc1, edge);
- }
-
- joined_arc1->tail = joined_arc2->tail;
-
- BLI_listbase_clear(&joined_arc2->edges);
-
- BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2);
-
- BLI_removeNode((BGraph *)rg, (BNode *)node);
-}
-
-static void RIG_removeNormalNodes(RigGraph *rg)
-{
- RigNode *node, *next_node;
-
- for (node = rg->nodes.first; node; node = next_node) {
- next_node = node->next;
-
- if (node->degree == 2) {
- RigArc *arc, *joined_arc1 = NULL, *joined_arc2 = NULL;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- if (arc->head == node || arc->tail == node) {
- if (joined_arc1 == NULL) {
- joined_arc1 = arc;
- }
- else {
- joined_arc2 = arc;
- break;
- }
- }
- }
-
- RIG_joinArcs(rg, node, joined_arc1, joined_arc2);
- }
- }
-}
-
-static void RIG_removeUneededOffsets(RigGraph *rg)
-{
- RigArc *arc;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *first_edge, *last_edge;
-
- first_edge = arc->edges.first;
- last_edge = arc->edges.last;
-
- if (first_edge->bone == NULL) {
- if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001f) {
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
- }
- else if (arc->head->degree == 1) {
- RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001f);
-
- if (new_node) {
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head);
- }
- else {
- RigEdge *next_edge = first_edge->next;
-
- if (next_edge) {
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
-
- copy_v3_v3(arc->head->p, next_edge->head);
- }
- }
- }
- else {
- /* check if all arc connected start with a null edge */
- RigArc *other_arc;
- for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
- if (other_arc != arc) {
- RigEdge *test_edge;
- if (other_arc->head == arc->head) {
- test_edge = other_arc->edges.first;
-
- if (test_edge->bone != NULL) {
- break;
- }
- }
- else if (other_arc->tail == arc->head) {
- test_edge = other_arc->edges.last;
-
- if (test_edge->bone != NULL) {
- break;
- }
- }
- }
- }
-
- if (other_arc == NULL) {
- RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001);
-
- if (new_node) {
- /* remove null edge in other arcs too */
- for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
- if (other_arc != arc) {
- RigEdge *test_edge;
- if (other_arc->head == arc->head) {
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->head);
- test_edge = other_arc->edges.first;
- BLI_remlink(&other_arc->edges, test_edge);
- MEM_freeN(test_edge);
- }
- else if (other_arc->tail == arc->head) {
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->tail);
- test_edge = other_arc->edges.last;
- BLI_remlink(&other_arc->edges, test_edge);
- MEM_freeN(test_edge);
- }
- }
- }
-
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head);
- }
- else {
- RigEdge *next_edge = first_edge->next;
-
- if (next_edge) {
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
-
- copy_v3_v3(arc->head->p, next_edge->head);
-
- /* remove null edge in other arcs too */
- for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
- if (other_arc != arc) {
- RigEdge *test_edge;
- if (other_arc->head == arc->head) {
- test_edge = other_arc->edges.first;
- BLI_remlink(&other_arc->edges, test_edge);
- MEM_freeN(test_edge);
- }
- else if (other_arc->tail == arc->head) {
- test_edge = other_arc->edges.last;
- BLI_remlink(&other_arc->edges, test_edge);
- MEM_freeN(test_edge);
- }
- }
- }
- }
- }
- }
- }
- }
-
- if (last_edge->bone == NULL) {
- if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001f) {
- BLI_remlink(&arc->edges, last_edge);
- MEM_freeN(last_edge);
- }
- else if (arc->tail->degree == 1) {
- RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, last_edge->head, 0.001f);
-
- if (new_node) {
- RigEdge *previous_edge = last_edge->prev;
-
- BLI_remlink(&arc->edges, last_edge);
- MEM_freeN(last_edge);
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->tail);
-
- /* set previous angle to 0, since there's no following edges */
- if (previous_edge) {
- previous_edge->angle = 0;
- }
- }
- else {
- RigEdge *previous_edge = last_edge->prev;
-
- if (previous_edge) {
- BLI_remlink(&arc->edges, last_edge);
- MEM_freeN(last_edge);
-
- copy_v3_v3(arc->tail->p, previous_edge->tail);
- previous_edge->angle = 0;
- }
- }
- }
- }
- }
-}
-
-static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bone, RigNode *starting_node, bool selected)
-{
- EditBone *bone, *last_bone = root_bone;
- RigArc *arc = NULL;
- int contain_head = 0;
-
- for (bone = root_bone; bone; bone = nextEditBoneChild(list, bone, 0)) {
- int nb_children;
-
- if (selected == 0 || (bone->flag & BONE_SELECTED)) {
- if ((bone->flag & BONE_NO_DEFORM) == 0) {
- BLI_ghash_insert(rg->bones_map, bone->name, bone);
-
- if (arc == NULL) {
- arc = newRigArc(rg);
-
- if (starting_node == NULL) {
- starting_node = newRigNodeHead(rg, arc, root_bone->head);
- }
- else {
- addRigNodeHead(rg, arc, starting_node);
- }
- }
-
- if (bone->parent && (bone->flag & BONE_CONNECTED) == 0) {
- RIG_addEdgeToArc(arc, bone->head, NULL);
- }
-
- RIG_addEdgeToArc(arc, bone->tail, bone);
-
- last_bone = bone;
-
- if (STREQ(bone->name, "head")) {
- contain_head = 1;
- }
- }
- else if ((bone->flag & BONE_EDITMODE_LOCKED) == 0) { /* ignore locked bones */
- RIG_addControlBone(rg, bone);
- }
- }
-
- nb_children = countEditBoneChildren(list, bone);
- if (nb_children > 1) {
- RigNode *end_node = NULL;
- int i;
-
- if (arc != NULL) {
- end_node = newRigNodeTail(rg, arc, bone->tail);
- }
- else {
- end_node = newRigNode(rg, bone->tail);
- }
-
- for (i = 0; i < nb_children; i++) {
- root_bone = nextEditBoneChild(list, bone, i);
- RIG_arcFromBoneChain(rg, list, root_bone, end_node, selected);
- }
-
- /* arc ends here, break */
- break;
- }
- }
-
- /* If the loop exited without forking */
- if (arc != NULL && bone == NULL) {
- newRigNodeTail(rg, arc, last_bone->tail);
- }
-
- if (contain_head) {
- rg->head = arc->tail;
- }
-}
-
-/*******************************************************************************************************/
-static void RIG_findHead(RigGraph *rg)
-{
- if (rg->head == NULL) {
- if (BLI_listbase_is_single(&rg->arcs)) {
- RigArc *arc = rg->arcs.first;
-
- rg->head = (RigNode *)arc->head;
- }
- else {
- RigArc *arc;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *edge = arc->edges.last;
-
- if (edge->bone->flag & (BONE_TIPSEL | BONE_SELECTED)) {
- rg->head = arc->tail;
- break;
- }
- }
- }
-
- if (rg->head == NULL) {
- rg->head = rg->nodes.first;
- }
- }
-}
-
-/*******************************************************************************************************/
-
-static void RIG_printNode(RigNode *node, const char name[])
-{
- printf("%s %p %i <%0.3f, %0.3f, %0.3f>\n", name, (void *)node, node->degree, node->p[0], node->p[1], node->p[2]);
-
- if (node->symmetry_flag & SYM_TOPOLOGICAL) {
- if (node->symmetry_flag & SYM_AXIAL)
- printf("Symmetry AXIAL\n");
- else if (node->symmetry_flag & SYM_RADIAL)
- printf("Symmetry RADIAL\n");
-
- print_v3("symmetry axis", node->symmetry_axis);
- }
-}
-
-void RIG_printArcBones(RigArc *arc)
-{
- RigEdge *edge;
-
- for (edge = arc->edges.first; edge; edge = edge->next) {
- if (edge->bone)
- printf("%s ", edge->bone->name);
- else
- printf("---- ");
- }
- printf("\n");
-}
-
-static void RIG_printCtrl(RigControl *ctrl, char *indent)
-{
- char text[128];
-
- printf("%sBone: %s\n", indent, ctrl->bone->name);
- printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!");
-
- BLI_snprintf(text, sizeof(text), "%soffset", indent);
- print_v3(text, ctrl->offset);
-
- printf("%sFlag: %i\n", indent, ctrl->flag);
-}
-
-static void RIG_printLinkedCtrl(RigGraph *rg, EditBone *bone, int tabs)
-{
- RigControl *ctrl;
- char indent[64];
- char *s = indent;
- int i;
-
- for (i = 0; i < tabs; i++) {
- s[0] = '\t';
- s++;
- }
- s[0] = 0;
-
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- if (ctrl->link == bone) {
- RIG_printCtrl(ctrl, indent);
- RIG_printLinkedCtrl(rg, ctrl->bone, tabs + 1);
- }
- }
-}
-
-void RIG_printArc(RigGraph *rg, RigArc *arc)
-{
- RigEdge *edge;
-
- RIG_printNode((RigNode *)arc->head, "head");
-
- for (edge = arc->edges.first; edge; edge = edge->next) {
- printf("\tinner joints %0.3f %0.3f %0.3f\n", edge->tail[0], edge->tail[1], edge->tail[2]);
- printf("\t\tlength %f\n", edge->length);
- printf("\t\tangle %f\n", edge->angle * (float)(180 / M_PI));
- if (edge->bone) {
- printf("\t\t%s\n", edge->bone->name);
- RIG_printLinkedCtrl(rg, edge->bone, 3);
- }
- }
- printf("symmetry level: %i flag: %i group %i\n", arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group);
-
- RIG_printNode((RigNode *)arc->tail, "tail");
-}
-
-void RIG_printGraph(RigGraph *rg)
-{
- RigArc *arc;
-
- printf("---- ARCS ----\n");
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RIG_printArc(rg, arc);
- printf("\n");
- }
-
- if (rg->head) {
- RIG_printNode(rg->head, "HEAD NODE:");
- }
- else {
- printf("HEAD NODE: NONE\n");
- }
-}
-
-/*******************************************************************************************************/
-
-RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
-{
- Object *obedit = CTX_data_edit_object(C);
- Scene *scene = CTX_data_scene(C);
- EditBone *ebone;
- RigGraph *rg;
-
- rg = newRigGraph();
-
- if (obedit == ob) {
- rg->editbones = ((bArmature *)obedit->data)->edbo;
- }
- else {
- rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
- make_boneList(rg->editbones, &arm->bonebase, NULL, NULL);
- rg->flag |= RIG_FREE_BONELIST;
- }
-
- rg->ob = ob;
-
- /* Do the rotations */
- for (ebone = rg->editbones->first; ebone; ebone = ebone->next) {
- if (ebone->parent == NULL) {
- RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0);
- }
- }
-
- BLI_removeDoubleNodes((BGraph *)rg, 0.001);
-
- RIG_removeNormalNodes(rg);
-
- RIG_removeUneededOffsets(rg);
-
- BLI_buildAdjacencyList((BGraph *)rg);
-
- RIG_findHead(rg);
-
- BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
-
- RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
-
- if (BLI_isGraphCyclic((BGraph *)rg)) {
- printf("armature cyclic\n");
- }
-
- return rg;
-}
-
-static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm)
-{
- Object *obedit = CTX_data_edit_object(C);
- Scene *scene = CTX_data_scene(C);
- EditBone *ebone;
- RigGraph *rg;
-
- rg = newRigGraph();
-
- if (obedit == ob) {
- rg->editbones = arm->edbo;
- }
- else {
- rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
- make_boneList(rg->editbones, &arm->bonebase, NULL, NULL);
- rg->flag |= RIG_FREE_BONELIST;
- }
-
- rg->ob = ob;
-
- /* Do the rotations */
- for (ebone = rg->editbones->first; ebone; ebone = ebone->next) {
- if (ebone->parent == NULL) {
- RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1);
- }
- }
-
- BLI_removeDoubleNodes((BGraph *)rg, 0.001);
-
- RIG_removeNormalNodes(rg);
-
- RIG_removeUneededOffsets(rg);
-
- BLI_buildAdjacencyList((BGraph *)rg);
-
- RIG_findHead(rg);
-
- BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
-
- RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
-
- if (BLI_isGraphCyclic((BGraph *)rg)) {
- printf("armature cyclic\n");
- }
-
- return rg;
-}
-/************************************ GENERATING *****************************************************/
-
-#if 0
-static EditBone *add_editbonetolist(char *name, ListBase *list)
-{
- EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
-
- BLI_strncpy(bone->name, name, sizeof(bone->name));
- unique_editbone_name(list, bone->name, NULL);
-
- BLI_addtail(list, bone);
-
- bone->flag |= BONE_TIPSEL;
- bone->weight = 1.0F;
- bone->dist = 0.25F;
- bone->xwidth = 0.1;
- bone->zwidth = 0.1;
- bone->rad_head = 0.10;
- bone->rad_tail = 0.05;
- bone->segments = 1;
- bone->layer = 1; //arm->layer;
-
- /* Bendy-Bone parameters */
- bone->roll1 = 0.0f;
- bone->roll2 = 0.0f;
- bone->curveInX = 0.0f;
- bone->curveInY = 0.0f;
- bone->curveOutX = 0.0f;
- bone->curveOutY = 0.0f;
- bone->ease1 = 1.0f;
- bone->ease2 = 1.0f;
- bone->scaleIn = 1.0f;
- bone->scaleOut = 1.0f;
-
- return bone;
-}
-#endif
-
-#if 0 /* UNUSED */
-static void generateMissingArcsFromNode(RigGraph *rigg, ReebNode *node, int multi_level_limit)
-{
- while (node->multi_level > multi_level_limit && node->link_up)
- {
- node = node->link_up;
- }
-
- while (node->multi_level < multi_level_limit && node->link_down)
- {
- node = node->link_down;
- }
-
- if (node->multi_level == multi_level_limit)
- {
- int i;
-
- for (i = 0; i < node->degree; i++)
- {
- ReebArc *earc = node->arcs[i];
-
- if (earc->flag == ARC_FREE && earc->head == node)
- {
- ReebNode *other = BIF_otherNodeFromIndex(earc, node);
-
- earc->flag = ARC_USED;
-
- //generateBonesForArc(rigg, earc, node, other);
- generateMissingArcsFromNode(rigg, other, multi_level_limit);
- }
- }
- }
-}
-
-static void generateMissingArcs(RigGraph *rigg)
-{
- ReebGraph *reebg;
- int multi_level_limit = 5;
-
- for (reebg = rigg->link_mesh; reebg; reebg = reebg->link_up)
- {
- ReebArc *earc;
-
- for (earc = reebg->arcs.first; earc; earc = earc->next)
- {
- if (earc->flag == ARC_USED)
- {
- generateMissingArcsFromNode(rigg, earc->head, multi_level_limit);
- generateMissingArcsFromNode(rigg, earc->tail, multi_level_limit);
- }
- }
- }
-}
-#endif
-
-/************************************ RETARGETTING *****************************************************/
-
-static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], float tail[3], float qrot[4], float resize);
-
-static void repositionTailControl(RigGraph *rigg, RigControl *ctrl);
-
-static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize)
-{
- if ((ctrl->flag & RIG_CTRL_DONE) == RIG_CTRL_DONE) {
- RigControl *ctrl_child;
-
-#if 0
- printf("CTRL: %s LINK: %s", ctrl->bone->name, ctrl->link->name);
-
- if (ctrl->link_tail)
- {
- printf(" TAIL: %s", ctrl->link_tail->name);
- }
-
- printf("\n");
-#endif
-
- /* if there was a tail link: apply link, recalc resize factor and qrot */
- if (ctrl->tail_mode != TL_NONE) {
- float *tail_vec = NULL;
- float v1[3], v2[3], qtail[4];
-
- if (ctrl->tail_mode == TL_TAIL) {
- tail_vec = ctrl->link_tail->tail;
- }
- else if (ctrl->tail_mode == TL_HEAD) {
- tail_vec = ctrl->link_tail->head;
- }
-
- sub_v3_v3v3(v1, ctrl->bone->tail, ctrl->bone->head);
- sub_v3_v3v3(v2, tail_vec, ctrl->bone->head);
-
- copy_v3_v3(ctrl->bone->tail, tail_vec);
-
- rotation_between_vecs_to_quat(qtail, v1, v2);
- mul_qt_qtqt(ctrl->qrot, qtail, ctrl->qrot);
-
- resize = len_v3(v2) / len_v3v3(ctrl->head, ctrl->tail);
- }
-
- ctrl->bone->roll = rollBoneByQuat(ctrl->bone, ctrl->up_axis, ctrl->qrot);
-
- /* Cascade to connected control bones */
- for (ctrl_child = rigg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) {
- if (ctrl_child->link == ctrl->bone) {
- repositionControl(rigg, ctrl_child, ctrl->bone->head, ctrl->bone->tail, ctrl->qrot, resize);
- }
- if (ctrl_child->link_tail == ctrl->bone) {
- repositionTailControl(rigg, ctrl_child);
- }
- }
- }
-}
-
-static void repositionTailControl(RigGraph *rigg, RigControl *ctrl)
-{
- ctrl->flag |= RIG_CTRL_TAIL_DONE;
-
- finalizeControl(rigg, ctrl, 1); /* resize will be recalculated anyway so we don't need it */
-}
-
-static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], float UNUSED(tail[3]), float qrot[4], float resize)
-{
- float parent_offset[3], tail_offset[3];
-
- copy_v3_v3(parent_offset, ctrl->offset);
- mul_v3_fl(parent_offset, resize);
- mul_qt_v3(qrot, parent_offset);
-
- add_v3_v3v3(ctrl->bone->head, head, parent_offset);
-
- ctrl->flag |= RIG_CTRL_HEAD_DONE;
-
- copy_qt_qt(ctrl->qrot, qrot);
-
- if (ctrl->tail_mode == TL_NONE) {
- sub_v3_v3v3(tail_offset, ctrl->tail, ctrl->head);
- mul_v3_fl(tail_offset, resize);
- mul_qt_v3(qrot, tail_offset);
-
- add_v3_v3v3(ctrl->bone->tail, ctrl->bone->head, tail_offset);
-
- ctrl->flag |= RIG_CTRL_TAIL_DONE;
- }
-
- finalizeControl(rigg, ctrl, resize);
-}
-
-static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec0[3], float vec1[3], float up_axis[3])
-{
- Scene *scene = CTX_data_scene(C);
- EditBone *bone;
- RigControl *ctrl;
- float qrot[4], resize;
- float v1[3], v2[3];
- float l1, l2;
-
- bone = edge->bone;
-
- sub_v3_v3v3(v1, edge->tail, edge->head);
- sub_v3_v3v3(v2, vec1, vec0);
-
- l1 = normalize_v3(v1);
- l2 = normalize_v3(v2);
-
- resize = l2 / l1;
-
- rotation_between_vecs_to_quat(qrot, v1, v2);
-
- copy_v3_v3(bone->head, vec0);
- copy_v3_v3(bone->tail, vec1);
-
- if (!is_zero_v3(up_axis)) {
- float qroll[4];
-
- if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_VIEW) {
- bone->roll = rollBoneByQuatAligned(bone, edge->up_axis, qrot, qroll, up_axis);
- }
- else if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_JOINT) {
- bone->roll = rollBoneByQuatJoint(edge, edge->prev, qrot, qroll, up_axis);
- }
- else {
- unit_qt(qroll);
- }
-
- mul_qt_qtqt(qrot, qroll, qrot);
- }
- else {
- bone->roll = rollBoneByQuat(bone, edge->up_axis, qrot);
- }
-
- for (ctrl = rigg->controls.first; ctrl; ctrl = ctrl->next) {
- if (ctrl->link == bone) {
- repositionControl(rigg, ctrl, vec0, vec1, qrot, resize);
- }
- if (ctrl->link_tail == bone) {
- repositionTailControl(rigg, ctrl);
- }
- }
-}
-
-static RetargetMode detectArcRetargetMode(RigArc *arc);
-static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start);
-
-
-static RetargetMode detectArcRetargetMode(RigArc *iarc)
-{
- RetargetMode mode = RETARGET_AGGRESSIVE;
- ReebArc *earc = iarc->link_mesh;
- RigEdge *edge;
- int large_angle = 0;
- float avg_angle = 0;
- /* float avg_length = 0; */ /* UNUSED */
- int nb_edges = 0;
-
-
- for (edge = iarc->edges.first; edge; edge = edge->next) {
- avg_angle += edge->angle;
- nb_edges++;
- }
-
- avg_angle /= nb_edges - 1; /* -1 because last edge doesn't have an angle */
-
- /* avg_length = iarc->length / nb_edges; */ /* UNUSED */
-
-
- if (nb_edges > 2) {
- for (edge = iarc->edges.first; edge; edge = edge->next) {
- if (fabsf(edge->angle - avg_angle) > (float)(M_PI / 6)) {
- large_angle = 1;
- }
- }
- }
- else if (nb_edges == 2 && avg_angle > 0) {
- large_angle = 1;
- }
-
-
- if (large_angle == 0) {
- mode = RETARGET_LENGTH;
- }
-
- if (earc->bcount <= (iarc->count - 1)) {
- mode = RETARGET_LENGTH;
- }
-
- return mode;
-}
-
-#ifndef USE_THREADS
-static void printMovesNeeded(int *positions, int nb_positions)
-{
- int moves = 0;
- int i;
-
- for (i = 0; i < nb_positions; i++) {
- moves += positions[i] - (i + 1);
- }
-
- printf("%i moves needed\n", moves);
-}
-
-static void printPositions(int *positions, int nb_positions)
-{
- int i;
-
- for (i = 0; i < nb_positions; i++) {
- printf("%i ", positions[i]);
- }
- printf("\n");
-}
-#endif
-
-#define MAX_COST FLT_MAX /* FIX ME */
-
-static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0, int i1, float distance_weight)
-{
- EmbedBucket *bucket = NULL;
- float max_dist = 0;
- float v1[3], v2[3], c[3];
- float v1_inpf;
-
- if (distance_weight > 0) {
- sub_v3_v3v3(v1, vec0, vec1);
-
- v1_inpf = dot_v3v3(v1, v1);
-
- if (v1_inpf > 0) {
- int j;
- for (j = i0 + 1; j < i1 - 1; j++) {
- float dist;
-
- bucket = IT_peek(iter, j);
-
- sub_v3_v3v3(v2, bucket->p, vec1);
-
- cross_v3_v3v3(c, v1, v2);
-
- dist = dot_v3v3(c, c) / v1_inpf;
-
- max_dist = dist > max_dist ? dist : max_dist;
- }
-
- return distance_weight * max_dist;
- }
- else {
- return MAX_COST;
- }
- }
- else {
- return 0;
- }
-}
-
-static float costAngle(float original_angle, float vec_first[3], float vec_second[3], float angle_weight)
-{
- if (angle_weight > 0) {
- float current_angle;
-
- if (!is_zero_v3(vec_first) && !is_zero_v3(vec_second)) {
- current_angle = saacos(dot_v3v3(vec_first, vec_second));
-
- return angle_weight * fabsf(current_angle - original_angle);
- }
- else {
- return angle_weight * (float)M_PI;
- }
- }
- else {
- return 0;
- }
-}
-
-static float costLength(float original_length, float current_length, float length_weight)
-{
- if (current_length == 0) {
- return MAX_COST;
- }
- else {
- float length_ratio = fabsf((current_length - original_length) / original_length);
- return length_weight * length_ratio * length_ratio;
- }
-}
-
-#if 0
-static float calcCostLengthDistance(BArcIterator *iter, float **vec_cache, RigEdge *edge, float *vec1, float *vec2, int i1, int i2)
-{
- float vec[3];
- float length;
-
- sub_v3_v3v3(vec, vec2, vec1);
- length = normalize_v3(vec);
-
- return costLength(edge->length, length) + costDistance(iter, vec1, vec2, i1, i2);
-}
-#endif
-
-static float calcCostAngleLengthDistance(BArcIterator *iter, float **UNUSED(vec_cache), RigEdge *edge,
- float *vec0, float *vec1, float *vec2, int i1, int i2,
- float angle_weight, float length_weight, float distance_weight)
-{
- float vec_second[3], vec_first[3];
- float length2;
- float new_cost = 0;
-
- sub_v3_v3v3(vec_second, vec2, vec1);
- length2 = normalize_v3(vec_second);
-
-
- /* Angle cost */
- if (edge->prev) {
- sub_v3_v3v3(vec_first, vec1, vec0);
- normalize_v3(vec_first);
-
- new_cost += costAngle(edge->prev->angle, vec_first, vec_second, angle_weight);
- }
-
- /* Length cost */
- new_cost += costLength(edge->length, length2, length_weight);
-
- /* Distance cost */
- new_cost += costDistance(iter, vec1, vec2, i1, i2, distance_weight);
-
- return new_cost;
-}
-
-static int indexMemoNode(int nb_positions, int previous, int current, int joints_left)
-{
- return joints_left * nb_positions * nb_positions + current * nb_positions + previous;
-}
-
-static void copyMemoPositions(int *positions, MemoNode *table, int nb_positions, int joints_left)
-{
- int previous = 0, current = 0;
- int i = 0;
-
- for (i = 0; joints_left > 0; joints_left--, i++) {
- MemoNode *node;
- node = table + indexMemoNode(nb_positions, previous, current, joints_left);
-
- positions[i] = node->next;
-
- previous = current;
- current = node->next;
- }
-}
-
-static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_cache,
- int nb_joints, int nb_positions, int previous, int current, RigEdge *edge,
- int joints_left, float angle_weight, float length_weight, float distance_weight)
-{
- MemoNode *node;
- int index = indexMemoNode(nb_positions, previous, current, joints_left);
-
- node = table + index;
-
- if (node->weight != 0) {
- return node;
- }
- else if (joints_left == 0) {
- float *vec0 = vec_cache[previous];
- float *vec1 = vec_cache[current];
- float *vec2 = vec_cache[nb_positions + 1];
-
- node->weight = calcCostAngleLengthDistance(iter, vec_cache, edge, vec0, vec1, vec2, current, iter->length, angle_weight, length_weight, distance_weight);
-
- return node;
- }
- else {
- MemoNode *min_node = NULL;
- float *vec0 = vec_cache[previous];
- float *vec1 = vec_cache[current];
- float min_weight = 0.0f;
- int min_next = 0;
- int next;
-
- for (next = current + 1; next <= nb_positions - (joints_left - 1); next++) {
- MemoNode *next_node;
- float *vec2 = vec_cache[next];
- float weight = 0.0f;
-
- /* ADD WEIGHT OF PREVIOUS - CURRENT - NEXT triple */
- weight = calcCostAngleLengthDistance(iter, vec_cache, edge, vec0, vec1, vec2, current, next, angle_weight, length_weight, distance_weight);
-
- if (weight >= MAX_COST) {
- continue;
- }
-
- /* add node weight */
- next_node = solveJoints(table, iter, vec_cache, nb_joints, nb_positions, current, next, edge->next, joints_left - 1, angle_weight, length_weight, distance_weight);
- weight += next_node->weight;
-
- if (min_node == NULL || weight < min_weight) {
- min_weight = weight;
- min_node = next_node;
- min_next = next;
- }
- }
-
- if (min_node) {
- node->weight = min_weight;
- node->next = min_next;
- return node;
- }
- else {
- node->weight = MAX_COST;
- return node;
- }
- }
-
-}
-
-static int testFlipArc(RigArc *iarc, RigNode *inode_start)
-{
- ReebArc *earc = iarc->link_mesh;
- ReebNode *enode_start = BIF_NodeFromIndex(earc, inode_start->link_mesh);
-
- /* no flip needed if both nodes are the same */
- if ((enode_start == earc->head && inode_start == iarc->head) ||
- (enode_start == earc->tail && inode_start == iarc->tail))
- {
- return 0;
- }
- else {
- return 1;
- }
-}
-
-static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
-{
- ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator *)&arc_iter;
- RigEdge *edge;
- ReebNode *node_start, *node_end;
- ReebArc *earc = iarc->link_mesh;
- float angle_weight = 1.0; // GET FROM CONTEXT
- float length_weight = 1.0;
- float distance_weight = 1.0;
-#ifndef USE_THREADS
- float min_cost = FLT_MAX;
-#endif
- float *vec0, *vec1;
- int *best_positions;
- int nb_edges = BLI_listbase_count(&iarc->edges);
- int nb_joints = nb_edges - 1;
- RetargetMethod method = METHOD_MEMOIZE;
- int i;
-
- if (nb_joints > earc->bcount) {
- printf("NOT ENOUGH BUCKETS!\n");
- return;
- }
-
- best_positions = MEM_callocN(sizeof(int) * nb_joints, "Best positions");
-
- if (testFlipArc(iarc, inode_start)) {
- node_start = earc->tail;
- node_end = earc->head;
- }
- else {
- node_start = earc->head;
- node_end = earc->tail;
- }
-
- /* equal number of joints and potential position, just fill them in */
- if (nb_joints == earc->bcount) {
- /* init with first values */
- for (i = 0; i < nb_joints; i++) {
- best_positions[i] = i + 1;
- }
- }
- if (method == METHOD_MEMOIZE) {
- int nb_positions = earc->bcount;
- int nb_memo_nodes = nb_positions * nb_positions * (nb_joints + 1);
- MemoNode *table = MEM_callocN(nb_memo_nodes * sizeof(MemoNode), "memoization table");
-#ifndef USE_THREADS
- MemoNode *result;
-#endif
- float **positions_cache = MEM_callocN(sizeof(float *) * (nb_positions + 2), "positions cache");
-
- positions_cache[0] = node_start->p;
- positions_cache[nb_positions + 1] = node_end->p;
-
- initArcIterator(iter, earc, node_start);
-
- for (i = 1; i <= nb_positions; i++) {
- EmbedBucket *bucket = IT_peek(iter, i);
- positions_cache[i] = bucket->p;
- }
-
-#ifndef USE_THREADS
- result = solveJoints(table, iter, positions_cache, nb_joints, earc->bcount, 0, 0, iarc->edges.first, nb_joints, angle_weight, length_weight, distance_weight);
- min_cost = result->weight;
-#else
- solveJoints(table, iter, positions_cache, nb_joints, earc->bcount, 0, 0, iarc->edges.first, nb_joints, angle_weight, length_weight, distance_weight);
-#endif
-
- copyMemoPositions(best_positions, table, earc->bcount, nb_joints);
-
- MEM_freeN(table);
- MEM_freeN(positions_cache);
- }
-
- vec0 = node_start->p;
- initArcIterator(iter, earc, node_start);
-
-#ifndef USE_THREADS
- printPositions(best_positions, nb_joints);
- printMovesNeeded(best_positions, nb_joints);
- printf("min_cost %f\n", min_cost);
- printf("buckets: %i\n", earc->bcount);
-#endif
-
- /* set joints to best position */
- for (edge = iarc->edges.first, i = 0;
- edge;
- edge = edge->next, i++)
- {
- float *no = NULL;
- if (i < nb_joints) {
- EmbedBucket *bucket = IT_peek(iter, best_positions[i]);
- vec1 = bucket->p;
- no = bucket->no;
- }
- else {
- vec1 = node_end->p;
- no = node_end->no;
- }
-
- if (edge->bone) {
- repositionBone(C, rigg, edge, vec0, vec1, no);
- }
-
- vec0 = vec1;
- }
-
- MEM_freeN(best_positions);
-}
-
-static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
-{
- ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator *)&arc_iter;
- ReebArc *earc = iarc->link_mesh;
- ReebNode *node_start, *node_end;
- RigEdge *edge;
- EmbedBucket *bucket = NULL;
- float embedding_length = 0;
- float *vec0 = NULL;
- float *vec1 = NULL;
- float *previous_vec = NULL;
-
-
- if (testFlipArc(iarc, inode_start)) {
- node_start = (ReebNode *)earc->tail;
- node_end = (ReebNode *)earc->head;
- }
- else {
- node_start = (ReebNode *)earc->head;
- node_end = (ReebNode *)earc->tail;
- }
-
- initArcIterator(iter, earc, node_start);
-
- bucket = IT_next(iter);
-
- vec0 = node_start->p;
-
- while (bucket != NULL) {
- vec1 = bucket->p;
-
- embedding_length += len_v3v3(vec0, vec1);
-
- vec0 = vec1;
- bucket = IT_next(iter);
- }
-
- embedding_length += len_v3v3(node_end->p, vec1);
-
- /* fit bones */
- initArcIterator(iter, earc, node_start);
-
- bucket = IT_next(iter);
-
- vec0 = node_start->p;
- previous_vec = vec0;
- vec1 = bucket->p;
-
- for (edge = iarc->edges.first; edge; edge = edge->next) {
- float new_bone_length = edge->length / iarc->length * embedding_length;
- float *no = NULL;
- float length = 0;
-
- while (bucket && new_bone_length > length) {
- length += len_v3v3(previous_vec, vec1);
- bucket = IT_next(iter);
- previous_vec = vec1;
- vec1 = bucket->p;
- no = bucket->no;
- }
-
- if (bucket == NULL) {
- vec1 = node_end->p;
- no = node_end->no;
- }
-
- /* no need to move virtual edges (space between unconnected bones) */
- if (edge->bone) {
- repositionBone(C, rigg, edge, vec0, vec1, no);
- }
-
- vec0 = vec1;
- previous_vec = vec1;
- }
-}
-
-static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
-{
- RetargetParam *p = MEM_callocN(sizeof(RetargetParam), "RetargetParam");
-
- p->rigg = rigg;
- p->iarc = iarc;
- p->inode_start = inode_start;
- p->context = C;
-
- BLI_task_pool_push(rigg->task_pool, exec_retargetArctoArc, p, true, TASK_PRIORITY_HIGH);
-}
-
-void exec_retargetArctoArc(TaskPool * __restrict UNUSED(pool), void *taskdata, int UNUSED(threadid))
-{
- RetargetParam *p = (RetargetParam *)taskdata;
- RigGraph *rigg = p->rigg;
- RigArc *iarc = p->iarc;
- bContext *C = p->context;
- RigNode *inode_start = p->inode_start;
- ReebArc *earc = iarc->link_mesh;
-
- if (BLI_listbase_is_single(&iarc->edges)) {
- RigEdge *edge = iarc->edges.first;
-
- if (testFlipArc(iarc, inode_start)) {
- repositionBone(C, rigg, edge, earc->tail->p, earc->head->p, earc->head->no);
- }
- else {
- repositionBone(C, rigg, edge, earc->head->p, earc->tail->p, earc->tail->no);
- }
- }
- else {
- RetargetMode mode = detectArcRetargetMode(iarc);
-
- if (mode == RETARGET_AGGRESSIVE) {
- retargetArctoArcAggresive(C, rigg, iarc, inode_start);
- }
- else {
- retargetArctoArcLength(C, rigg, iarc, inode_start);
- }
- }
-}
-
-static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *top_node)
-{
- ReebNode *enode = top_node;
- ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode);
- int ishape, eshape;
-
- ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
-
- inode->link_mesh = enode;
-
- while (ishape == eshape && enode->link_down) {
- inode->link_mesh = enode;
-
- enode = enode->link_down;
- reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); /* replace with call to link_down once that exists */
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
- }
-}
-
-static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode)
-{
- int i;
-
- for (i = 0; i < enode->degree; i++) {
- ReebArc *earc = (ReebArc *)enode->arcs[i];
-
- if (earc->flag == ARC_FREE) {
- earc->flag = ARC_TAKEN;
-
- if (earc->tail->degree > 1 && earc->tail != end_enode) {
- markMultiResolutionChildArc(end_enode, earc->tail);
- }
- break;
- }
- }
-}
-
-static void markMultiResolutionArc(ReebArc *start_earc)
-{
- if (start_earc->link_up) {
- ReebArc *earc;
- for (earc = start_earc->link_up; earc; earc = earc->link_up) {
- earc->flag = ARC_TAKEN;
-
- if (earc->tail->index != start_earc->tail->index) {
- markMultiResolutionChildArc(earc->tail, earc->tail);
- }
- }
- }
-}
-
-static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc *next_iarc, ReebArc *next_earc)
-{
- ReebNode *enode = next_earc->head;
- ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode);
- int ishape, eshape;
-
- ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)start_node, (BArc *)next_iarc, 1) % SHAPE_LEVELS;
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
-
- while (ishape != eshape && next_earc->link_up) {
- next_earc->flag = ARC_TAKEN; // mark previous as taken, to prevent backtrack on lower levels
-
- next_earc = next_earc->link_up;
- reebg = reebg->link_up;
- enode = next_earc->head;
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
- }
-
- next_earc->flag = ARC_USED;
- next_iarc->link_mesh = next_earc;
-
- /* mark all higher levels as taken too */
- markMultiResolutionArc(next_earc);
-// while (next_earc->link_up)
-// {
-// next_earc = next_earc->link_up;
-// next_earc->flag = ARC_TAKEN;
-// }
-}
-
-static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, RigNode *inode)
-{
- ReebNode *enode;
- int ishape, eshape;
-
- enode = reebg->nodes.first;
-
- ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
- eshape = BLI_subtreeShape((BGraph *)rigg->link_mesh, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
-
- while (ishape != eshape && reebg->link_up) {
- reebg = reebg->link_up;
-
- enode = reebg->nodes.first;
-
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
- }
-
- inode->link_mesh = enode;
-}
-
-static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *start_node, RigArc *next_iarc, int root)
-{
- ReebNode *enode = start_node->link_mesh;
- ReebArc *next_earc;
- int symmetry_level = next_iarc->symmetry_level;
- int symmetry_group = next_iarc->symmetry_group;
- int symmetry_flag = next_iarc->symmetry_flag;
- int i;
-
- next_iarc->link_mesh = NULL;
-
-// if (root)
-// {
-// printf("-----------------------\n");
-// printf("MATCHING LIMB\n");
-// RIG_printArcBones(next_iarc);
-// }
-
- for (i = 0; i < enode->degree; i++) {
- next_earc = (ReebArc *)enode->arcs[i];
-
-// if (next_earc->flag == ARC_FREE)
-// {
-// printf("candidate (level %i ?= %i) (flag %i ?= %i) (group %i ?= %i)\n",
-// symmetry_level, next_earc->symmetry_level,
-// symmetry_flag, next_earc->symmetry_flag,
-// symmetry_group, next_earc->symmetry_flag);
-// }
-
- if (next_earc->flag == ARC_FREE &&
- next_earc->symmetry_flag == symmetry_flag &&
- next_earc->symmetry_group == symmetry_group &&
- next_earc->symmetry_level == symmetry_level)
- {
-// printf("CORRESPONDING ARC FOUND\n");
-// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
-
- matchMultiResolutionArc(rigg, start_node, next_iarc, next_earc);
- break;
- }
- }
-
- /* not found, try at higher nodes (lower node might have filtered internal arcs, messing shape of tree */
- if (next_iarc->link_mesh == NULL) {
-// printf("NO CORRESPONDING ARC FOUND - GOING TO HIGHER LEVELS\n");
-
- if (enode->link_up) {
- start_node->link_mesh = enode->link_up;
- findCorrespondingArc(rigg, start_arc, start_node, next_iarc, 0);
- }
- }
-
- /* still not found, print debug info */
- if (root && next_iarc->link_mesh == NULL) {
- start_node->link_mesh = enode; /* linking back with root node */
-
-// printf("NO CORRESPONDING ARC FOUND\n");
-// RIG_printArcBones(next_iarc);
-//
-// printf("ON NODE %i, multilevel %i\n", enode->index, enode->multi_level);
-//
-// printf("LOOKING FOR\n");
-// printf("flag %i -- level %i -- flag %i -- group %i\n", ARC_FREE, symmetry_level, symmetry_flag, symmetry_group);
-//
-// printf("CANDIDATES\n");
-// for (i = 0; i < enode->degree; i++)
-// {
-// next_earc = (ReebArc *)enode->arcs[i];
-// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
-// }
-
- /* Emergency matching */
- for (i = 0; i < enode->degree; i++) {
- next_earc = (ReebArc *)enode->arcs[i];
-
- if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level) {
-// printf("USING:\n");
-// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
- matchMultiResolutionArc(rigg, start_node, next_iarc, next_earc);
- break;
- }
- }
- }
-
-}
-
-static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, RigNode *start_node)
-{
- RigNode *inode = start_node;
- int i;
-
- /* no start arc on first node */
- if (start_arc) {
- ReebNode *enode = start_node->link_mesh;
- ReebArc *earc = start_arc->link_mesh;
-
- retargetArctoArc(C, rigg, start_arc, start_node);
-
- enode = BIF_otherNodeFromIndex(earc, enode);
- inode = (RigNode *)BLI_otherNode((BArc *)start_arc, (BNode *)inode);
-
- /* match with lowest node with correct shape */
- matchMultiResolutionNode(rigg, inode, enode);
- }
-
- for (i = 0; i < inode->degree; i++) {
- RigArc *next_iarc = (RigArc *)inode->arcs[i];
-
- /* no back tracking */
- if (next_iarc != start_arc) {
- findCorrespondingArc(rigg, start_arc, inode, next_iarc, 1);
- if (next_iarc->link_mesh) {
- retargetSubgraph(C, rigg, next_iarc, inode);
- }
- }
- }
-}
-
-static void finishRetarget(RigGraph *rigg)
-{
- BLI_task_pool_work_and_wait(rigg->task_pool);
-}
-
-static void adjustGraphs(bContext *C, RigGraph *rigg)
-{
- bArmature *arm = rigg->ob->data;
- RigArc *arc;
-
- for (arc = rigg->arcs.first; arc; arc = arc->next) {
- if (arc->link_mesh) {
- retargetArctoArc(C, rigg, arc, arc->head);
- }
- }
-
- finishRetarget(rigg);
-
- /* Turn the list into an armature */
- arm->edbo = rigg->editbones;
- ED_armature_from_edit(arm);
-
- ED_undo_push(C, "Retarget Skeleton");
-}
-
-static void retargetGraphs(bContext *C, RigGraph *rigg)
-{
- bArmature *arm = rigg->ob->data;
- ReebGraph *reebg = rigg->link_mesh;
- RigNode *inode;
-
- /* flag all ReebArcs as free */
- BIF_flagMultiArcs(reebg, ARC_FREE);
-
- /* return to first level */
- inode = rigg->head;
-
- matchMultiResolutionStartingNode(rigg, reebg, inode);
-
- retargetSubgraph(C, rigg, NULL, inode);
-
- //generateMissingArcs(rigg);
-
- finishRetarget(rigg);
-
- /* Turn the list into an armature */
- arm->edbo = rigg->editbones;
- ED_armature_from_edit(arm);
-}
-
-const char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index)
-{
- RigArc *arc = BLI_findlink(&rg->arcs, arc_index);
- RigEdge *iedge;
-
- if (arc == NULL) {
- return "None";
- }
-
- if (bone_index == BLI_listbase_count(&arc->edges)) {
- return "Last joint";
- }
-
- iedge = BLI_findlink(&arc->edges, bone_index);
-
- if (iedge == NULL) {
- return "Done";
- }
-
- if (iedge->bone == NULL) {
- return "Bone offset";
- }
-
- return iedge->bone->name;
-}
-
-int RIG_nbJoints(RigGraph *rg)
-{
- RigArc *arc;
- int total = 0;
-
- total += BLI_listbase_count(&rg->nodes);
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- total += BLI_listbase_count(&arc->edges) - 1; /* -1 because end nodes are already counted */
- }
-
- return total;
-}
-
-static void BIF_freeRetarget(void)
-{
- if (GLOBAL_RIGG) {
- RIG_freeRigGraph((BGraph *)GLOBAL_RIGG);
- GLOBAL_RIGG = NULL;
- }
-}
-
-void BIF_retargetArmature(bContext *C)
-{
- ReebGraph *reebg;
- double start_time, end_time;
- double gstart_time, gend_time;
- double reeb_time, rig_time = 0.0, retarget_time = 0.0, total_time;
-
- gstart_time = start_time = PIL_check_seconds_timer();
-
- reebg = BIF_ReebGraphMultiFromEditMesh(C);
-
- end_time = PIL_check_seconds_timer();
- reeb_time = end_time - start_time;
-
- printf("Reeb Graph created\n");
-
- CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
- {
- Object *ob = base->object;
-
- if (ob->type == OB_ARMATURE) {
- RigGraph *rigg;
- bArmature *arm;
-
- arm = ob->data;
-
- /* Put the armature into editmode */
-
-
- start_time = PIL_check_seconds_timer();
-
- rigg = RIG_graphFromArmature(C, ob, arm);
-
- end_time = PIL_check_seconds_timer();
- rig_time = end_time - start_time;
-
- printf("Armature graph created\n");
-
- //RIG_printGraph(rigg);
-
- rigg->link_mesh = reebg;
-
- printf("retargetting %s\n", ob->id.name);
-
- start_time = PIL_check_seconds_timer();
-
- retargetGraphs(C, rigg);
-
- end_time = PIL_check_seconds_timer();
- retarget_time = end_time - start_time;
-
- BIF_freeRetarget();
-
- GLOBAL_RIGG = rigg;
-
- break; /* only one armature at a time */
- }
- }
- CTX_DATA_END;
-
-
- gend_time = PIL_check_seconds_timer();
-
- total_time = gend_time - gstart_time;
-
- printf("-----------\n");
- printf("runtime: \t%.3f\n", total_time);
- printf("reeb: \t\t%.3f (%.1f%%)\n", reeb_time, reeb_time / total_time * 100);
- printf("rig: \t\t%.3f (%.1f%%)\n", rig_time, rig_time / total_time * 100);
- printf("retarget: \t%.3f (%.1f%%)\n", retarget_time, retarget_time / total_time * 100);
- printf("-----------\n");
-
- ED_undo_push(C, "Retarget Skeleton");
-
- // XXX
-// allqueue(REDRAWVIEW3D, 0);
-}
-
-void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
-{
- Object *obedit = CTX_data_edit_object(C);
- Scene *scene = CTX_data_scene(C);
- bArmature *armedit = obedit->data;
- Object *ob;
- RigGraph *rigg;
- RigArc *iarc;
- char *side_string = scene->toolsettings->skgen_side_string;
- char *num_string = scene->toolsettings->skgen_num_string;
- int free_template = 0;
-
- if (template_rigg) {
- ob = template_rigg->ob;
- }
- else {
- free_template = 1;
- ob = obedit;
- template_rigg = armatureSelectedToGraph(C, ob, ob->data);
- }
-
- if (BLI_listbase_is_empty(&template_rigg->arcs)) {
-// XXX
-// error("No Template and no deforming bones selected");
- return;
- }
-
- rigg = cloneRigGraph(template_rigg, armedit->edbo, obedit, side_string, num_string);
-
- iarc = rigg->arcs.first;
-
- iarc->link_mesh = earc;
- iarc->head->link_mesh = earc->head;
- iarc->tail->link_mesh = earc->tail;
-
- retargetArctoArc(C, rigg, iarc, iarc->head);
-
- finishRetarget(rigg);
-
- /* free template if it comes from the edit armature */
- if (free_template) {
- RIG_freeRigGraph((BGraph *)template_rigg);
- }
- RIG_freeRigGraph((BGraph *)rigg);
-
- ED_armature_validate_active(armedit);
-
-// XXX
-// allqueue(REDRAWVIEW3D, 0);
-}
-
-void BIF_adjustRetarget(bContext *C)
-{
- if (GLOBAL_RIGG) {
- adjustGraphs(C, GLOBAL_RIGG);
- }
-}
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
deleted file mode 100644
index 1f1468a8e41..00000000000
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ /dev/null
@@ -1,2653 +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 blender/editors/armature/editarmature_sketch.c
- * \ingroup edarmature
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_armature_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-
-#include "BKE_context.h"
-#include "BKE_sketch.h"
-#include "BKE_layer.h"
-
-#include "RNA_define.h"
-#include "RNA_access.h"
-
-#include "ED_view3d.h"
-#include "ED_screen.h"
-
-#include "BIF_gl.h"
-#include "ED_armature.h"
-#include "armature_intern.h"
-#include "BIF_retarget.h"
-#include "BIF_generate.h"
-
-#include "ED_transform.h"
-#include "ED_transform_snap_object_context.h"
-
-#include "DEG_depsgraph.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "GPU_select.h"
-#include "GPU_matrix.h"
-#include "GPU_batch.h"
-#include "GPU_immediate.h"
-#include "GPU_immediate_util.h"
-
-typedef int (*GestureDetectFct)(bContext *, SK_Gesture *, SK_Sketch *);
-typedef void (*GestureApplyFct)(bContext *, SK_Gesture *, SK_Sketch *);
-
-typedef struct SK_GestureAction {
- char name[64];
- GestureDetectFct detect;
- GestureApplyFct apply;
-} SK_GestureAction;
-
-#if 0 /* UNUSED 2.5 */
-static SK_Point boneSnap;
-#endif
-
-static int LAST_SNAP_POINT_VALID = 0;
-static float LAST_SNAP_POINT[3];
-
-
-typedef struct SK_StrokeIterator {
- HeadFct head;
- TailFct tail;
- PeekFct peek;
- NextFct next;
- NextNFct nextN;
- PreviousFct previous;
- StoppedFct stopped;
-
- float *p, *no;
- float size;
-
- int length;
- int index;
- /*********************************/
- SK_Stroke *stroke;
- int start;
- int end;
- int stride;
-} SK_StrokeIterator;
-
-/******************** PROTOTYPES ******************************/
-
-void initStrokeIterator(BArcIterator *iter, SK_Stroke *stk, int start, int end);
-
-int sk_detectCutGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-void sk_applyCutGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-int sk_detectTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-void sk_applyTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-int sk_detectCommandGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-void sk_applyCommandGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-int sk_detectDeleteGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-void sk_applyDeleteGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-void sk_applyMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-int sk_detectReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-void sk_applyReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-int sk_detectConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-void sk_applyConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
-
-SK_Sketch *contextSketch(const bContext *c, int create);
-SK_Sketch *viewcontextSketch(ViewContext *vc, int create);
-
-void sk_resetOverdraw(SK_Sketch *sketch);
-int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk);
-
-/******************** GESTURE ACTIONS ******************************/
-
-static SK_GestureAction GESTURE_ACTIONS[] = {
- {"Cut", sk_detectCutGesture, sk_applyCutGesture},
- {"Trim", sk_detectTrimGesture, sk_applyTrimGesture},
- {"Command", sk_detectCommandGesture, sk_applyCommandGesture},
- {"Delete", sk_detectDeleteGesture, sk_applyDeleteGesture},
- {"Merge", sk_detectMergeGesture, sk_applyMergeGesture},
- {"Reverse", sk_detectReverseGesture, sk_applyReverseGesture},
- {"Convert", sk_detectConvertGesture, sk_applyConvertGesture},
- {"", NULL, NULL}
-};
-
-/******************** TEMPLATES UTILS *************************/
-
-static char *TEMPLATES_MENU = NULL;
-static int TEMPLATES_CURRENT = 0;
-static GHash *TEMPLATES_HASH = NULL;
-static RigGraph *TEMPLATE_RIGG = NULL;
-
-void BIF_makeListTemplates(const bContext *C)
-{
- Object *obedit = CTX_data_edit_object(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
- int index = 0;
-
- if (TEMPLATES_HASH != NULL) {
- BLI_ghash_free(TEMPLATES_HASH, NULL, NULL);
- }
-
- TEMPLATES_HASH = BLI_ghash_int_new("makeListTemplates gh");
- TEMPLATES_CURRENT = 0;
-
- FOREACH_OBJECT_BEGIN(view_layer, ob)
- {
- if (ob != obedit && ob->type == OB_ARMATURE) {
- index++;
- BLI_ghash_insert(TEMPLATES_HASH, SET_INT_IN_POINTER(index), ob);
-
- if (ob == ts->skgen_template) {
- TEMPLATES_CURRENT = index;
- }
- }
- }
- FOREACH_OBJECT_END;
-}
-
-#if 0 /* UNUSED */
-const char *BIF_listTemplates(const bContext *UNUSED(C))
-{
- GHashIterator ghi;
- const char *menu_header = IFACE_("Template %t|None %x0|");
- char *p;
- const size_t template_size = (BLI_ghash_len(TEMPLATES_HASH) * 32 + 30);
-
- if (TEMPLATES_MENU != NULL) {
- MEM_freeN(TEMPLATES_MENU);
- }
-
- TEMPLATES_MENU = MEM_callocN(sizeof(char) * template_size, "skeleton template menu");
-
- p = TEMPLATES_MENU;
- p += BLI_strncpy_rlen(p, menu_header, template_size);
-
- BLI_ghashIterator_init(&ghi, TEMPLATES_HASH);
-
- while (!BLI_ghashIterator_done(&ghi)) {
- Object *ob = BLI_ghashIterator_getValue(&ghi);
- int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi));
-
- p += sprintf(p, "|%s %%x%i", ob->id.name + 2, key);
-
- BLI_ghashIterator_step(&ghi);
- }
-
- return TEMPLATES_MENU;
-}
-#endif
-
-int BIF_currentTemplate(const bContext *C)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
-
- if (TEMPLATES_CURRENT == 0 && ts->skgen_template != NULL) {
- GHashIterator ghi;
- BLI_ghashIterator_init(&ghi, TEMPLATES_HASH);
-
- while (!BLI_ghashIterator_done(&ghi)) {
- Object *ob = BLI_ghashIterator_getValue(&ghi);
- int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi));
-
- if (ob == ts->skgen_template) {
- TEMPLATES_CURRENT = key;
- break;
- }
-
- BLI_ghashIterator_step(&ghi);
- }
- }
-
- return TEMPLATES_CURRENT;
-}
-
-static RigGraph *sk_makeTemplateGraph(const bContext *C, Object *ob)
-{
- Object *obedit = CTX_data_edit_object(C);
- if (ob == obedit) {
- return NULL;
- }
-
- if (ob != NULL) {
- if (TEMPLATE_RIGG && TEMPLATE_RIGG->ob != ob) {
- RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG);
- TEMPLATE_RIGG = NULL;
- }
-
- if (TEMPLATE_RIGG == NULL) {
- bArmature *arm;
-
- arm = ob->data;
-
- TEMPLATE_RIGG = RIG_graphFromArmature(C, ob, arm);
- }
- }
-
- return TEMPLATE_RIGG;
-}
-
-int BIF_nbJointsTemplate(const bContext *C)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- RigGraph *rg = sk_makeTemplateGraph(C, ts->skgen_template);
-
- if (rg) {
- return RIG_nbJoints(rg);
- }
- else {
- return -1;
- }
-}
-
-const char *BIF_nameBoneTemplate(const bContext *C)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- SK_Sketch *stk = contextSketch(C, 1);
- RigGraph *rg;
- int index = 0;
-
- if (stk && stk->active_stroke != NULL) {
- index = stk->active_stroke->nb_points;
- }
-
- rg = sk_makeTemplateGraph(C, ts->skgen_template);
-
- if (rg == NULL) {
- return "";
- }
-
- return RIG_nameBone(rg, 0, index);
-}
-
-void BIF_freeTemplates(bContext *UNUSED(C))
-{
- if (TEMPLATES_MENU != NULL) {
- MEM_freeN(TEMPLATES_MENU);
- TEMPLATES_MENU = NULL;
- }
-
- if (TEMPLATES_HASH != NULL) {
- BLI_ghash_free(TEMPLATES_HASH, NULL, NULL);
- TEMPLATES_HASH = NULL;
- }
-
- if (TEMPLATE_RIGG != NULL) {
- RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG);
- TEMPLATE_RIGG = NULL;
- }
-}
-
-void BIF_setTemplate(bContext *C, int index)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- if (index > 0) {
- ts->skgen_template = BLI_ghash_lookup(TEMPLATES_HASH, SET_INT_IN_POINTER(index));
- }
- else {
- ts->skgen_template = NULL;
-
- if (TEMPLATE_RIGG != NULL) {
- RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG);
- }
- TEMPLATE_RIGG = NULL;
- }
-}
-
-/*********************** CONVERSION ***************************/
-
-static void sk_autoname(bContext *C, ReebArc *arc)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- if (ts->skgen_retarget_options & SK_RETARGET_AUTONAME) {
- if (arc == NULL) {
- char *num = ts->skgen_num_string;
- int i = atoi(num);
- i++;
- BLI_snprintf(num, 8, "%i", i);
- }
- else {
- char *side = ts->skgen_side_string;
- int valid = 0;
- int caps = 0;
-
- if (side[0] == '\0') {
- valid = 1;
- }
- else if (STREQ(side, "R") || STREQ(side, "L")) {
- valid = 1;
- caps = 1;
- }
- else if (STREQ(side, "r") || STREQ(side, "l")) {
- valid = 1;
- caps = 0;
- }
-
- if (valid) {
- if (arc->head->p[0] < 0) {
- BLI_snprintf(side, 8, caps ? "R" : "r");
- }
- else {
- BLI_snprintf(side, 8, caps ? "L" : "l");
- }
- }
- }
- }
-}
-
-static ReebNode *sk_pointToNode(SK_Point *pt, float imat[4][4], float tmat[3][3])
-{
- ReebNode *node;
-
- node = MEM_callocN(sizeof(ReebNode), "reeb node");
- copy_v3_v3(node->p, pt->p);
- mul_m4_v3(imat, node->p);
-
- copy_v3_v3(node->no, pt->no);
- mul_m3_v3(tmat, node->no);
-
- return node;
-}
-
-static ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[4][4], float tmat[3][3])
-{
- ReebArc *arc;
- int i;
-
- arc = MEM_callocN(sizeof(ReebArc), "reeb arc");
- arc->head = sk_pointToNode(stk->points, imat, tmat);
- arc->tail = sk_pointToNode(sk_lastStrokePoint(stk), imat, tmat);
-
- arc->bcount = stk->nb_points - 2; /* first and last are nodes, don't count */
- arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "Buckets");
-
- for (i = 0; i < arc->bcount; i++) {
- copy_v3_v3(arc->buckets[i].p, stk->points[i + 1].p);
- mul_m4_v3(imat, arc->buckets[i].p);
-
- copy_v3_v3(arc->buckets[i].no, stk->points[i + 1].no);
- mul_m3_v3(tmat, arc->buckets[i].no);
- }
-
- return arc;
-}
-
-static void sk_retargetStroke(bContext *C, SK_Stroke *stk)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- Object *obedit = CTX_data_edit_object(C);
- float imat[4][4];
- float tmat[3][3];
- ReebArc *arc;
- RigGraph *rg;
-
- invert_m4_m4(imat, obedit->obmat);
- transpose_m3_m4(tmat, obedit->obmat);
-
- arc = sk_strokeToArc(stk, imat, tmat);
-
- sk_autoname(C, arc);
-
- rg = sk_makeTemplateGraph(C, ts->skgen_template);
-
- BIF_retargetArc(C, arc, rg);
-
- sk_autoname(C, NULL);
-
- MEM_freeN(arc->head);
- MEM_freeN(arc->tail);
- REEB_freeArc((BArc *)arc);
-}
-
-/**************************************************************/
-static void sk_cancelStroke(SK_Sketch *sketch)
-{
- if (sketch->active_stroke != NULL) {
- sk_resetOverdraw(sketch);
- sk_removeStroke(sketch, sketch->active_stroke);
- }
-}
-
-
-static float sk_clampPointSize(SK_Point *pt, float size)
-{
- return max_ff(size * pt->size, size / 2);
-}
-
-static void sk_drawPoint(SK_Point *pt, float size, float color[4])
-{
- Gwn_Batch *batch = NULL;
-
- gpuTranslate3fv(pt->p);
-
- gpuPushMatrix();
-
- gpuScaleUniform(sk_clampPointSize(pt, size));
-
- batch = GPU_batch_preset_sphere(0);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
- GWN_batch_uniform_4fv(batch, "color", color);
-
- GWN_batch_draw(batch);
-
- gpuPopMatrix();
-}
-
-static void sk_drawEdge(SK_Point *pt0, SK_Point *pt1, float size, float color[4])
-{
- float vec1[3], vec2[3] = { 0, 0, 1 }, axis[3];
- float angle, length;
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- sub_v3_v3v3(vec1, pt1->p, pt0->p);
- length = normalize_v3(vec1);
- cross_v3_v3v3(axis, vec2, vec1);
-
- if (is_zero_v3(axis)) {
- axis[1] = 1;
- }
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4fv(color);
-
- angle = angle_normalized_v3v3(vec2, vec1);
- gpuRotate3fv(angle * (float)(180.0 / M_PI) + 180.0f, axis);
- imm_draw_cylinder_fill_3d(pos, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8);
-
- immUnbindProgram();
-}
-
-static void sk_drawNormal(SK_Point *pt, float size, float height)
-{
- float vec2[3] = { 0, 0, 1 }, axis[3];
- float angle;
- float color[3] = { 0.0f, 1.0f, 1.0f };
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- gpuPushMatrix();
-
- cross_v3_v3v3(axis, vec2, pt->no);
-
- if (is_zero_v3(axis)) {
- axis[1] = 1;
- }
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4fv(color);
-
- angle = angle_normalized_v3v3(vec2, pt->no);
- gpuRotate3fv(angle * (float)(180.0 / M_PI), axis);
-
- imm_draw_cylinder_fill_3d(pos, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2);
-
- immUnbindProgram();
-
- gpuPopMatrix();
-}
-
-static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end)
-{
- float rgb[3];
- float zero_color[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
- int i;
-
- if (id != -1) {
- GPU_select_load_id(id);
-
- for (i = 0; i < stk->nb_points; i++) {
- gpuPushMatrix();
-
- sk_drawPoint(stk->points + i, 0.1, zero_color);
-
- if (i > 0) {
- sk_drawEdge(stk->points + i - 1, stk->points + i, 0.1, zero_color);
- }
-
- gpuPopMatrix();
- }
-
- }
- else {
- float d_rgb[3] = { 1, 1, 1 };
- float tmp_color[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
-
- copy_v3_v3(rgb, color);
- sub_v3_v3(d_rgb, rgb);
- mul_v3_fl(d_rgb, 1.0f / (float)stk->nb_points);
-
- for (i = 0; i < stk->nb_points; i++) {
- SK_Point *pt = stk->points + i;
-
- gpuPushMatrix();
-
- if (pt->type == PT_EXACT) {
- sk_drawPoint(pt, 0.15, zero_color);
- sk_drawNormal(pt, 0.05, 0.9);
- }
-
- if (i >= start && i <= end) {
- copy_v4_fl4(tmp_color, 0.3f, 0.3f, 0.3f, 1.0f);
- }
- else {
- copy_v4_fl4(tmp_color, rgb[0], rgb[1], rgb[2], 1.0f);
- }
-
- if (pt->type != PT_EXACT) {
- sk_drawPoint(pt, 0.1, tmp_color);
- }
-
- if (i > 0) {
- sk_drawEdge(pt - 1, pt, 0.1, tmp_color);
- }
-
- gpuPopMatrix();
-
- add_v3_v3(rgb, d_rgb);
- }
- }
-
-}
-
-static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *iter, NextSubdivisionFunc next_subdividion)
-{
- SK_Stroke *stk = ((SK_StrokeIterator *)iter)->stroke;
- float head[3], tail[3];
- float color[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
- int bone_start = 0;
- int end = iter->length;
- int index;
-
- iter->head(iter);
- copy_v3_v3(head, iter->p);
-
- index = next_subdividion(toolsettings, iter, bone_start, end, head, tail);
- while (index != -1) {
- SK_Point *pt = stk->points + index;
-
- gpuPushMatrix();
-
- sk_drawPoint(pt, 0.15, color);
-
- sk_drawNormal(pt, 0.05, 0.9);
-
- gpuPopMatrix();
-
- copy_v3_v3(head, tail);
- bone_start = index; // start next bone from current index
-
- index = next_subdividion(toolsettings, iter, bone_start, end, head, tail);
- }
-}
-
-static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk)
-{
- int head_index = -1;
- int i;
-
- if (toolsettings->bone_sketching_convert == SK_CONVERT_RETARGET) {
- return;
- }
-
-
- for (i = 0; i < stk->nb_points; i++) {
- SK_Point *pt = stk->points + i;
-
- if (pt->type == PT_EXACT || i == stk->nb_points - 1) /* stop on exact or on last point */ {
- if (head_index == -1) {
- head_index = i;
- }
- else {
- if (i - head_index > 1) {
- SK_StrokeIterator sk_iter;
- BArcIterator *iter = (BArcIterator *)&sk_iter;
-
- initStrokeIterator(iter, stk, head_index, i);
-
- if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_ADAPTATIVE) {
- drawSubdividedStrokeBy(toolsettings, iter, nextAdaptativeSubdivision);
- }
- else if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_LENGTH) {
- drawSubdividedStrokeBy(toolsettings, iter, nextLengthSubdivision);
- }
- else if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_FIXED) {
- drawSubdividedStrokeBy(toolsettings, iter, nextFixedSubdivision);
- }
-
- }
-
- head_index = i;
- }
- }
- }
-}
-
-static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], float *r_dist_px, int *index, int all_pts)
-{
- ARegion *ar = CTX_wm_region(C);
- SK_Point *pt = NULL;
- int i;
-
- for (i = 0; i < stk->nb_points; i++) {
- if (all_pts || stk->points[i].type == PT_EXACT) {
- short pval[2];
- int pdist;
-
- if (ED_view3d_project_short_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
-
- pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
-
- if (pdist < *r_dist_px) {
- *r_dist_px = pdist;
- pt = stk->points + i;
-
- if (index != NULL) {
- *index = i;
- }
- }
- }
- }
- }
-
- return pt;
-}
-
-#if 0 /* UNUSED 2.5 */
-static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, int mval[2], int *dist)
-{
- ARegion *ar = CTX_wm_region(C);
- SK_Point *pt = NULL;
- EditBone *bone;
-
- for (bone = ebones->first; bone; bone = bone->next)
- {
- float vec[3];
- short pval[2];
- int pdist;
-
- if ((bone->flag & BONE_CONNECTED) == 0)
- {
- copy_v3_v3(vec, bone->head);
- mul_m4_v3(ob->obmat, vec);
- if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
-
- pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
-
- if (pdist < *dist)
- {
- *dist = pdist;
- pt = &boneSnap;
- copy_v3_v3(pt->p, vec);
- pt->type = PT_EXACT;
- }
- }
- }
-
-
- copy_v3_v3(vec, bone->tail);
- mul_m4_v3(ob->obmat, vec);
- if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
-
- pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
-
- if (pdist < *dist)
- {
- *dist = pdist;
- pt = &boneSnap;
- copy_v3_v3(pt->p, vec);
- pt->type = PT_EXACT;
- }
- }
- }
-
- return pt;
-}
-#endif
-
-void sk_resetOverdraw(SK_Sketch *sketch)
-{
- sketch->over.target = NULL;
- sketch->over.start = -1;
- sketch->over.end = -1;
- sketch->over.count = 0;
-}
-
-int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk)
-{
- return sketch->over.target &&
- sketch->over.count >= SK_OVERDRAW_LIMIT &&
- (sketch->over.target == stk || stk == NULL) &&
- (sketch->over.start != -1 || sketch->over.end != -1);
-}
-
-static void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
-{
- if (sketch->over.target == NULL) {
- SK_Stroke *target;
- int closest_index = -1;
- float dist_px = SNAP_MIN_DISTANCE * 2;
-
- for (target = sketch->strokes.first; target; target = target->next) {
- if (target != stk) {
- int index;
-
- SK_Point *spt = sk_snapPointStroke(C, target, dd->mval, &dist_px, &index, 1);
-
- if (spt != NULL) {
- sketch->over.target = target;
- closest_index = index;
- }
- }
- }
-
- if (sketch->over.target != NULL) {
- if (closest_index > -1) {
- if (sk_lastStrokePoint(stk)->type == PT_EXACT) {
- sketch->over.count = SK_OVERDRAW_LIMIT;
- }
- else {
- sketch->over.count++;
- }
- }
-
- if (stk->nb_points == 1) {
- sketch->over.start = closest_index;
- }
- else {
- sketch->over.end = closest_index;
- }
- }
- }
- else if (sketch->over.target != NULL) {
- SK_Point *closest_pt = NULL;
- float dist_px = SNAP_MIN_DISTANCE * 2;
- int index;
-
- closest_pt = sk_snapPointStroke(C, sketch->over.target, dd->mval, &dist_px, &index, 1);
-
- if (closest_pt != NULL) {
- if (sk_lastStrokePoint(stk)->type == PT_EXACT) {
- sketch->over.count = SK_OVERDRAW_LIMIT;
- }
- else {
- sketch->over.count++;
- }
-
- sketch->over.end = index;
- }
- else {
- sketch->over.end = -1;
- }
- }
-}
-
-/* return 1 on reverse needed */
-static int sk_adjustIndexes(SK_Sketch *sketch, int *start, int *end)
-{
- int retval = 0;
-
- *start = sketch->over.start;
- *end = sketch->over.end;
-
- if (*start == -1) {
- *start = 0;
- }
-
- if (*end == -1) {
- *end = sketch->over.target->nb_points - 1;
- }
-
- if (*end < *start) {
- int tmp = *start;
- *start = *end;
- *end = tmp;
- retval = 1;
- }
-
- return retval;
-}
-
-static void sk_endOverdraw(SK_Sketch *sketch)
-{
- SK_Stroke *stk = sketch->active_stroke;
-
- if (sk_hasOverdraw(sketch, NULL)) {
- int start;
- int end;
-
- if (sk_adjustIndexes(sketch, &start, &end)) {
- sk_reverseStroke(stk);
- }
-
- if (stk->nb_points > 1) {
- stk->points->type = sketch->over.target->points[start].type;
- sk_lastStrokePoint(stk)->type = sketch->over.target->points[end].type;
- }
-
- sk_insertStrokePoints(sketch->over.target, stk->points, stk->nb_points, start, end);
-
- sk_removeStroke(sketch, stk);
-
- sk_resetOverdraw(sketch);
- }
-}
-
-
-static void sk_startStroke(SK_Sketch *sketch)
-{
- SK_Stroke *stk = sk_createStroke();
-
- BLI_addtail(&sketch->strokes, stk);
- sketch->active_stroke = stk;
-
- sk_resetOverdraw(sketch);
-}
-
-static void sk_endStroke(bContext *C, SK_Sketch *sketch)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- sk_shrinkStrokeBuffer(sketch->active_stroke);
-
- if (ts->bone_sketching & BONE_SKETCHING_ADJUST) {
- sk_endOverdraw(sketch);
- }
-
- sketch->active_stroke = NULL;
-}
-
-static void sk_updateDrawData(SK_DrawData *dd)
-{
- dd->type = PT_CONTINUOUS;
-
- dd->previous_mval[0] = dd->mval[0];
- dd->previous_mval[1] = dd->mval[1];
-}
-
-static float sk_distanceDepth(bContext *C, float p1[3], float p2[3])
-{
- ARegion *ar = CTX_wm_region(C);
- RegionView3D *rv3d = ar->regiondata;
- float vec[3];
- float distance;
-
- sub_v3_v3v3(vec, p1, p2);
-
- project_v3_v3v3(vec, vec, rv3d->viewinv[2]);
-
- distance = len_v3(vec);
-
- if (dot_v3v3(rv3d->viewinv[2], vec) > 0) {
- distance *= -1;
- }
-
- return distance;
-}
-
-static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float length, float distance)
-{
- ARegion *ar = CTX_wm_region(C);
- ScrArea *sa = CTX_wm_area(C);
- View3D *v3d = sa->spacedata.first;
-
- float progress = 0;
- int i;
-
- progress = len_v3v3(stk->points[start].p, stk->points[start - 1].p);
-
- for (i = start; i <= end; i++) {
- float ray_start[3], ray_normal[3];
- float delta = len_v3v3(stk->points[i].p, stk->points[i + 1].p);
- float pval[2] = {0, 0};
-
- ED_view3d_project_float_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP);
- ED_view3d_win_to_ray(CTX_data_depsgraph(C), ar, v3d, pval, ray_start, ray_normal, false);
-
- mul_v3_fl(ray_normal, distance * progress / length);
- add_v3_v3(stk->points[i].p, ray_normal);
-
- progress += delta;
- }
-}
-
-static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_DrawData *dd)
-{
- ARegion *ar = CTX_wm_region(C);
- /* copied from grease pencil, need fixing */
- SK_Point *last = sk_lastStrokePoint(stk);
- short cval[2];
- float fp[3] = {0, 0, 0};
- float dvec[3];
- float mval_f[2];
- float zfac;
-
- if (last != NULL) {
- copy_v3_v3(fp, last->p);
- }
-
- zfac = ED_view3d_calc_zfac(ar->regiondata, fp, NULL);
-
- if (ED_view3d_project_short_global(ar, fp, cval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- VECSUB2D(mval_f, cval, dd->mval);
- ED_view3d_win_to_delta(ar, mval_f, dvec, zfac);
- sub_v3_v3v3(vec, fp, dvec);
- }
- else {
- zero_v3(vec);
- }
-}
-
-static int sk_getStrokeDrawPoint(bContext *C, SK_Point *pt, SK_Sketch *UNUSED(sketch), SK_Stroke *stk, SK_DrawData *dd)
-{
- pt->type = dd->type;
- pt->mode = PT_PROJECT;
- sk_projectDrawPoint(C, pt->p, stk, dd);
-
- return 1;
-}
-
-static int sk_addStrokeDrawPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
-{
- ARegion *ar = CTX_wm_region(C);
- RegionView3D *rv3d = ar->regiondata;
- SK_Point pt;
-
- sk_initPoint(&pt, dd, rv3d->viewinv[2]);
-
- sk_getStrokeDrawPoint(C, &pt, sketch, stk, dd);
-
- sk_appendStrokePoint(stk, &pt);
-
- return 1;
-}
-
-static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- int point_added = 0;
-
- /* TODO: Since the function `ED_transform_snap_object_context_create_view3d` creates a cache,
- * the ideal would be to call this function only at the beginning of the snap operation,
- * or at the beginning of the operator itself */
- struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), CTX_data_scene(C), CTX_data_view_layer(C), 0,
- CTX_wm_region(C), CTX_wm_view3d(C));
-
- float mvalf[2] = {UNPACK2(dd->mval)};
- float loc[3], dummy_no[3];
-
- if (ts->snap_mode == SCE_SNAP_MODE_VOLUME) {
- float size;
- if (peelObjectsSnapContext(
- snap_context, mvalf,
- &(const struct SnapObjectParams){
- .snap_select = SNAP_NOT_SELECTED,
- .use_object_edit_cage = false,
- },
- (ts->snap_flag & SCE_SNAP_PEEL_OBJECT) != 0,
- loc, dummy_no, &size))
- {
- pt->type = dd->type;
- pt->mode = PT_SNAP;
- pt->size = size / 2;
- copy_v3_v3(pt->p, loc);
-
- point_added = 1;
- }
- }
- else {
- SK_Stroke *snap_stk;
- float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
-
- /* snap to strokes */
- // if (ts->snap_mode == SCE_SNAP_MODE_VERTEX) /* snap all the time to strokes */
- for (snap_stk = sketch->strokes.first; snap_stk; snap_stk = snap_stk->next) {
- SK_Point *spt = NULL;
- if (snap_stk == stk) {
- spt = sk_snapPointStroke(C, snap_stk, dd->mval, &dist_px, NULL, 0);
- }
- else {
- spt = sk_snapPointStroke(C, snap_stk, dd->mval, &dist_px, NULL, 1);
- }
-
- if (spt != NULL) {
- copy_v3_v3(pt->p, spt->p);
- point_added = 1;
- }
- }
-
- /* try to snap to closer object */
- {
- if (ED_transform_snap_object_project_view3d(
- snap_context,
- ts->snap_mode,
- &(const struct SnapObjectParams){
- .snap_select = SNAP_NOT_SELECTED,
- .use_object_edit_cage = false,
- },
- mvalf, &dist_px, NULL,
- loc, dummy_no))
- {
- pt->type = dd->type;
- pt->mode = PT_SNAP;
- copy_v3_v3(pt->p, loc);
-
- point_added = 1;
- }
- }
- }
-
- /* TODO: The ideal would be to call this function only once.
- * At the end of the operator */
- ED_transform_snap_object_context_destroy(snap_context);
- return point_added;
-}
-
-static int sk_addStrokeSnapPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
-{
- int point_added;
- ARegion *ar = CTX_wm_region(C);
- RegionView3D *rv3d = ar->regiondata;
- SK_Point pt;
-
- sk_initPoint(&pt, dd, rv3d->viewinv[2]);
-
- point_added = sk_getStrokeSnapPoint(C, &pt, sketch, stk, dd);
-
- if (point_added) {
- float final_p[3];
- float length, distance;
- int total;
- int i;
-
- copy_v3_v3(final_p, pt.p);
-
- sk_projectDrawPoint(C, pt.p, stk, dd);
- sk_appendStrokePoint(stk, &pt);
-
- /* update all previous point to give smooth Z progresion */
- total = 0;
- length = 0;
- for (i = stk->nb_points - 2; i > 0; i--) {
- length += len_v3v3(stk->points[i].p, stk->points[i + 1].p);
- total++;
- if (stk->points[i].mode == PT_SNAP || stk->points[i].type == PT_EXACT) {
- break;
- }
- }
-
- if (total > 1) {
- distance = sk_distanceDepth(C, final_p, stk->points[i].p);
-
- sk_interpolateDepth(C, stk, i + 1, stk->nb_points - 2, length, distance);
- }
-
- copy_v3_v3(stk->points[stk->nb_points - 1].p, final_p);
-
- point_added = 1;
- }
-
- return point_added;
-}
-
-static void sk_addStrokePoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, const bool snap)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- int point_added = 0;
-
- if (snap) {
- point_added = sk_addStrokeSnapPoint(C, sketch, stk, dd);
- }
-
- if (point_added == 0) {
- point_added = sk_addStrokeDrawPoint(C, sketch, stk, dd);
- }
-
- if (stk == sketch->active_stroke && ts->bone_sketching & BONE_SKETCHING_ADJUST) {
- sk_updateOverdraw(C, sketch, stk, dd);
- }
-}
-
-static void sk_getStrokePoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, const bool snap)
-{
- int point_added = 0;
-
- if (snap) {
- point_added = sk_getStrokeSnapPoint(C, pt, sketch, stk, dd);
- LAST_SNAP_POINT_VALID = 1;
- copy_v3_v3(LAST_SNAP_POINT, pt->p);
- }
- else {
- LAST_SNAP_POINT_VALID = 0;
- }
-
- if (point_added == 0) {
- point_added = sk_getStrokeDrawPoint(C, pt, sketch, stk, dd);
- }
-}
-
-/********************************************/
-
-static void *headPoint(void *arg);
-static void *tailPoint(void *arg);
-static void *nextPoint(void *arg);
-static void *nextNPoint(void *arg, int n);
-static void *peekPoint(void *arg, int n);
-static void *previousPoint(void *arg);
-static int iteratorStopped(void *arg);
-
-static void initIteratorFct(SK_StrokeIterator *iter)
-{
- iter->head = headPoint;
- iter->tail = tailPoint;
- iter->peek = peekPoint;
- iter->next = nextPoint;
- iter->nextN = nextNPoint;
- iter->previous = previousPoint;
- iter->stopped = iteratorStopped;
-}
-
-static SK_Point *setIteratorValues(SK_StrokeIterator *iter, int index)
-{
- SK_Point *pt = NULL;
-
- if (index >= 0 && index < iter->length) {
- pt = &(iter->stroke->points[iter->start + (iter->stride * index)]);
- iter->p = pt->p;
- iter->no = pt->no;
- iter->size = pt->size;
- }
- else {
- iter->p = NULL;
- iter->no = NULL;
- iter->size = 0;
- }
-
- return pt;
-}
-
-void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end)
-{
- SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
-
- initIteratorFct(iter);
- iter->stroke = stk;
-
- if (start < end) {
- iter->start = start + 1;
- iter->end = end - 1;
- iter->stride = 1;
- }
- else {
- iter->start = start - 1;
- iter->end = end + 1;
- iter->stride = -1;
- }
-
- iter->length = iter->stride * (iter->end - iter->start + 1);
-
- iter->index = -1;
-}
-
-
-static void *headPoint(void *arg)
-{
- SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
- SK_Point *result = NULL;
-
- result = &(iter->stroke->points[iter->start - iter->stride]);
- iter->p = result->p;
- iter->no = result->no;
- iter->size = result->size;
-
- return result;
-}
-
-static void *tailPoint(void *arg)
-{
- SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
- SK_Point *result = NULL;
-
- result = &(iter->stroke->points[iter->end + iter->stride]);
- iter->p = result->p;
- iter->no = result->no;
- iter->size = result->size;
-
- return result;
-}
-
-static void *nextPoint(void *arg)
-{
- SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
- SK_Point *result = NULL;
-
- iter->index++;
- if (iter->index < iter->length) {
- result = setIteratorValues(iter, iter->index);
- }
-
- return result;
-}
-
-static void *nextNPoint(void *arg, int n)
-{
- SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
- SK_Point *result = NULL;
-
- iter->index += n;
-
- /* check if passed end */
- if (iter->index < iter->length) {
- result = setIteratorValues(iter, iter->index);
- }
-
- return result;
-}
-
-static void *peekPoint(void *arg, int n)
-{
- SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
- SK_Point *result = NULL;
- int index = iter->index + n;
-
- /* check if passed end */
- if (index < iter->length) {
- result = setIteratorValues(iter, index);
- }
-
- return result;
-}
-
-static void *previousPoint(void *arg)
-{
- SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
- SK_Point *result = NULL;
-
- if (iter->index > 0) {
- iter->index--;
- result = setIteratorValues(iter, iter->index);
- }
-
- return result;
-}
-
-static int iteratorStopped(void *arg)
-{
- SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
-
- if (iter->index >= iter->length) {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-static void sk_convertStroke(bContext *C, SK_Stroke *stk)
-{
- Object *obedit = CTX_data_edit_object(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
- bArmature *arm = obedit->data;
- SK_Point *head;
- EditBone *parent = NULL;
- float invmat[4][4]; /* move in caller function */
- float tmat[3][3];
- int head_index = 0;
- int i;
-
- head = NULL;
-
- invert_m4_m4(invmat, obedit->obmat);
- transpose_m3_m4(tmat, obedit->obmat);
-
- for (i = 0; i < stk->nb_points; i++) {
- SK_Point *pt = stk->points + i;
-
- if (pt->type == PT_EXACT) {
- if (head == NULL) {
- head_index = i;
- head = pt;
- }
- else {
- EditBone *bone = NULL;
- EditBone *new_parent;
-
- if (i - head_index > 1) {
- SK_StrokeIterator sk_iter;
- BArcIterator *iter = (BArcIterator *)&sk_iter;
-
- initStrokeIterator(iter, stk, head_index, i);
-
- if (ts->bone_sketching_convert == SK_CONVERT_CUT_ADAPTATIVE) {
- bone = subdivideArcBy(ts, arm, arm->edbo, iter, invmat, tmat, nextAdaptativeSubdivision);
- }
- else if (ts->bone_sketching_convert == SK_CONVERT_CUT_LENGTH) {
- bone = subdivideArcBy(ts, arm, arm->edbo, iter, invmat, tmat, nextLengthSubdivision);
- }
- else if (ts->bone_sketching_convert == SK_CONVERT_CUT_FIXED) {
- bone = subdivideArcBy(ts, arm, arm->edbo, iter, invmat, tmat, nextFixedSubdivision);
- }
- }
-
- if (bone == NULL) {
- bone = ED_armature_edit_bone_add(arm, "Bone");
-
- copy_v3_v3(bone->head, head->p);
- copy_v3_v3(bone->tail, pt->p);
-
- mul_m4_v3(invmat, bone->head);
- mul_m4_v3(invmat, bone->tail);
- setBoneRollFromNormal(bone, head->no, invmat, tmat);
- }
-
- new_parent = bone;
- bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
-
- /* move to end of chain */
- while (bone->parent != NULL) {
- bone = bone->parent;
- bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
- }
-
- if (parent != NULL) {
- bone->parent = parent;
- bone->flag |= BONE_CONNECTED;
- }
-
- parent = new_parent;
- head_index = i;
- head = pt;
- }
- }
- }
-}
-
-static void sk_convert(bContext *C, SK_Sketch *sketch)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- SK_Stroke *stk;
-
- for (stk = sketch->strokes.first; stk; stk = stk->next) {
- if (stk->selected == 1) {
- if (ts->bone_sketching_convert == SK_CONVERT_RETARGET) {
- sk_retargetStroke(C, stk);
- }
- else {
- sk_convertStroke(C, stk);
- }
-// XXX
-// allqueue(REDRAWBUTSEDIT, 0);
- }
- }
-}
-/******************* GESTURE *************************/
-
-
-/* returns the number of self intersections */
-static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture)
-{
- ARegion *ar = CTX_wm_region(C);
- int added = 0;
- int s_i;
-
- for (s_i = 0; s_i < gesture->nb_points - 1; s_i++) {
- float s_p1[3] = {0, 0, 0};
- float s_p2[3] = {0, 0, 0};
- int g_i;
-
- ED_view3d_project_float_global(ar, gesture->points[s_i].p, s_p1, V3D_PROJ_TEST_NOP);
- ED_view3d_project_float_global(ar, gesture->points[s_i + 1].p, s_p2, V3D_PROJ_TEST_NOP);
-
- /* start checking from second next, because two consecutive cannot intersect */
- for (g_i = s_i + 2; g_i < gesture->nb_points - 1; g_i++) {
- float g_p1[3] = {0, 0, 0};
- float g_p2[3] = {0, 0, 0};
- float vi[3];
- float lambda;
-
- ED_view3d_project_float_global(ar, gesture->points[g_i].p, g_p1, V3D_PROJ_TEST_NOP);
- ED_view3d_project_float_global(ar, gesture->points[g_i + 1].p, g_p2, V3D_PROJ_TEST_NOP);
-
- if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) {
- SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection");
-
- isect->gesture_index = g_i;
- isect->before = s_i;
- isect->after = s_i + 1;
- isect->stroke = gesture;
-
- sub_v3_v3v3(isect->p, gesture->points[s_i + 1].p, gesture->points[s_i].p);
- mul_v3_fl(isect->p, lambda);
- add_v3_v3(isect->p, gesture->points[s_i].p);
-
- BLI_addtail(list, isect);
-
- added++;
- }
- }
- }
-
- return added;
-}
-
-static int cmpIntersections(const void *i1, const void *i2)
-{
- const SK_Intersection *isect1 = i1, *isect2 = i2;
-
- if (isect1->stroke == isect2->stroke) {
- if (isect1->before < isect2->before) {
- return -1;
- }
- else if (isect1->before > isect2->before) {
- return 1;
- }
- else {
- if (isect1->lambda < isect2->lambda) {
- return -1;
- }
- else if (isect1->lambda > isect2->lambda) {
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-
-/* returns the maximum number of intersections per stroke */
-static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Stroke *gesture)
-{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
- ARegion *ar = CTX_wm_region(C);
- ScrArea *sa = CTX_wm_area(C);
- View3D *v3d = sa->spacedata.first;
- SK_Stroke *stk;
- int added = 0;
-
- for (stk = sketch->strokes.first; stk; stk = stk->next) {
- int s_added = 0;
- int s_i;
-
- for (s_i = 0; s_i < stk->nb_points - 1; s_i++) {
- float s_p1[3] = {0, 0, 0};
- float s_p2[3] = {0, 0, 0};
- int g_i;
-
- ED_view3d_project_float_global(ar, stk->points[s_i].p, s_p1, V3D_PROJ_TEST_NOP);
- ED_view3d_project_float_global(ar, stk->points[s_i + 1].p, s_p2, V3D_PROJ_TEST_NOP);
-
- for (g_i = 0; g_i < gesture->nb_points - 1; g_i++) {
- float g_p1[3] = {0, 0, 0};
- float g_p2[3] = {0, 0, 0};
- float vi[3];
- float lambda;
-
- ED_view3d_project_float_global(ar, gesture->points[g_i].p, g_p1, V3D_PROJ_TEST_NOP);
- ED_view3d_project_float_global(ar, gesture->points[g_i + 1].p, g_p2, V3D_PROJ_TEST_NOP);
-
- if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) {
- SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection");
- float ray_start[3], ray_end[3];
- float mval[2];
-
- isect->gesture_index = g_i;
- isect->before = s_i;
- isect->after = s_i + 1;
- isect->stroke = stk;
- isect->lambda = lambda;
-
- mval[0] = vi[0];
- mval[1] = vi[1];
- ED_view3d_win_to_segment(depsgraph, ar, v3d, mval, ray_start, ray_end, true);
-
- isect_line_line_v3(stk->points[s_i].p,
- stk->points[s_i + 1].p,
- ray_start,
- ray_end,
- isect->p,
- vi);
-
- BLI_addtail(list, isect);
-
- s_added++;
- }
- }
- }
-
- added = MAX2(s_added, added);
- }
-
- BLI_listbase_sort(list, cmpIntersections);
-
- return added;
-}
-
-static int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture)
-{
- SK_StrokeIterator sk_iter;
- BArcIterator *iter = (BArcIterator *)&sk_iter;
-
- float CORRELATION_THRESHOLD = 0.99f;
- float *vec;
- int i, j;
-
- sk_appendStrokePoint(segments, &gesture->points[0]);
- vec = segments->points[segments->nb_points - 1].p;
-
- initStrokeIterator(iter, gesture, 0, gesture->nb_points - 1);
-
- for (i = 1, j = 0; i < gesture->nb_points; i++) {
- float n[3];
-
- /* Calculate normal */
- sub_v3_v3v3(n, gesture->points[i].p, vec);
-
- if (calcArcCorrelation(iter, j, i, vec, n) < CORRELATION_THRESHOLD) {
- j = i - 1;
- sk_appendStrokePoint(segments, &gesture->points[j]);
- vec = segments->points[segments->nb_points - 1].p;
- segments->points[segments->nb_points - 1].type = PT_EXACT;
- }
- }
-
- sk_appendStrokePoint(segments, &gesture->points[gesture->nb_points - 1]);
-
- return segments->nb_points - 1;
-}
-
-int sk_detectCutGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- if (gest->nb_segments == 1 && gest->nb_intersections == 1) {
- return 1;
- }
-
- return 0;
-}
-
-void sk_applyCutGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- SK_Intersection *isect;
-
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- SK_Point pt;
-
- pt.type = PT_EXACT;
- pt.mode = PT_PROJECT; /* take mode from neighboring points */
- copy_v3_v3(pt.p, isect->p);
- copy_v3_v3(pt.no, isect->stroke->points[isect->before].no);
-
- sk_insertStrokePoint(isect->stroke, &pt, isect->after);
- }
-}
-
-int sk_detectTrimGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- if (gest->nb_segments == 2 && gest->nb_intersections == 1 && gest->nb_self_intersections == 0) {
- float s1[3], s2[3];
- float angle;
-
- sub_v3_v3v3(s1, gest->segments->points[1].p, gest->segments->points[0].p);
- sub_v3_v3v3(s2, gest->segments->points[2].p, gest->segments->points[1].p);
-
- angle = RAD2DEGF(angle_v2v2(s1, s2));
-
- if (angle > 60 && angle < 120) {
- return 1;
- }
- }
-
- return 0;
-}
-
-void sk_applyTrimGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- SK_Intersection *isect;
- float trim_dir[3];
-
- sub_v3_v3v3(trim_dir, gest->segments->points[2].p, gest->segments->points[1].p);
-
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- SK_Point pt;
- float stroke_dir[3];
-
- pt.type = PT_EXACT;
- pt.mode = PT_PROJECT; /* take mode from neighboring points */
- copy_v3_v3(pt.p, isect->p);
- copy_v3_v3(pt.no, isect->stroke->points[isect->before].no);
-
- sub_v3_v3v3(stroke_dir, isect->stroke->points[isect->after].p, isect->stroke->points[isect->before].p);
-
- /* same direction, trim end */
- if (dot_v3v3(stroke_dir, trim_dir) > 0) {
- sk_replaceStrokePoint(isect->stroke, &pt, isect->after);
- sk_trimStroke(isect->stroke, 0, isect->after);
- }
- /* else, trim start */
- else {
- sk_replaceStrokePoint(isect->stroke, &pt, isect->before);
- sk_trimStroke(isect->stroke, isect->before, isect->stroke->nb_points - 1);
- }
-
- }
-}
-
-int sk_detectCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 1) {
- SK_Intersection *isect, *self_isect;
-
- /* get the last intersection of the first pair */
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- if (isect->stroke == isect->next->stroke) {
- isect = isect->next;
- break;
- }
- }
-
- self_isect = gest->self_intersections.first;
-
- if (isect && isect->gesture_index < self_isect->gesture_index) {
- return 1;
- }
- }
-
- return 0;
-}
-
-void sk_applyCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- SK_Intersection *isect;
- int command = 1;
-
-/* XXX */
-/* command = pupmenu("Action %t|Flatten %x1|Straighten %x2|Polygonize %x3"); */
- if (command < 1) return;
-
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- SK_Intersection *i2;
-
- i2 = isect->next;
-
- if (i2 && i2->stroke == isect->stroke) {
- switch (command) {
- case 1:
- sk_flattenStroke(isect->stroke, isect->before, i2->after);
- break;
- case 2:
- sk_straightenStroke(isect->stroke, isect->before, i2->after, isect->p, i2->p);
- break;
- case 3:
- sk_polygonizeStroke(isect->stroke, isect->before, i2->after);
- break;
- }
-
- isect = i2;
- }
- }
-}
-
-int sk_detectDeleteGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- if (gest->nb_segments == 2 && gest->nb_intersections == 2) {
- float s1[3], s2[3];
- float angle;
-
- sub_v3_v3v3(s1, gest->segments->points[1].p, gest->segments->points[0].p);
- sub_v3_v3v3(s2, gest->segments->points[2].p, gest->segments->points[1].p);
-
- angle = RAD2DEGF(angle_v2v2(s1, s2));
-
- if (angle > 120) {
- return 1;
- }
- }
-
- return 0;
-}
-
-void sk_applyDeleteGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *sketch)
-{
- SK_Intersection *isect;
-
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- /* only delete strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke) {
- isect = isect->next;
-
- sk_removeStroke(sketch, isect->stroke);
- }
- }
-}
-
-int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- ARegion *ar = CTX_wm_region(C);
- if (gest->nb_segments > 2 && gest->nb_intersections == 2) {
- int start_val[2], end_val[2];
- int dist;
-
- if ((ED_view3d_project_int_global(ar, gest->stk->points[0].p, start_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
- (ED_view3d_project_int_global(ar, sk_lastStrokePoint(gest->stk)->p, end_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
- {
- dist = len_manhattan_v2v2_int(start_val, end_val);
-
- /* if gesture is a circle */
- if (dist <= 20) {
- SK_Intersection *isect;
-
- /* check if it circled around an exact point */
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- /* only delete strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke) {
- int start_index, end_index;
- int i;
-
- start_index = MIN2(isect->after, isect->next->after);
- end_index = MAX2(isect->before, isect->next->before);
-
- for (i = start_index; i <= end_index; i++) {
- if (isect->stroke->points[i].type == PT_EXACT) {
- return 1; /* at least one exact point found, stop detect here */
- }
- }
-
- /* skip next */
- isect = isect->next;
- }
- }
- }
- }
- }
-
- return 0;
-}
-
-void sk_applyMergeGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- SK_Intersection *isect;
-
- /* check if it circled around an exact point */
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- /* only merge strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke) {
- int start_index, end_index;
- int i;
-
- start_index = MIN2(isect->after, isect->next->after);
- end_index = MAX2(isect->before, isect->next->before);
-
- for (i = start_index; i <= end_index; i++) {
- /* if exact, switch to continuous */
- if (isect->stroke->points[i].type == PT_EXACT) {
- isect->stroke->points[i].type = PT_CONTINUOUS;
- }
- }
-
- /* skip next */
- isect = isect->next;
- }
- }
-}
-
-int sk_detectReverseGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 0) {
- SK_Intersection *isect;
-
- /* check if it circled around an exact point */
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- /* only delete strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke) {
- float start_v[3], end_v[3];
- float angle;
-
- if (isect->gesture_index < isect->next->gesture_index) {
- sub_v3_v3v3(start_v, isect->p, gest->stk->points[0].p);
- sub_v3_v3v3(end_v, sk_lastStrokePoint(gest->stk)->p, isect->next->p);
- }
- else {
- sub_v3_v3v3(start_v, isect->next->p, gest->stk->points[0].p);
- sub_v3_v3v3(end_v, sk_lastStrokePoint(gest->stk)->p, isect->p);
- }
-
- angle = RAD2DEGF(angle_v2v2(start_v, end_v));
-
- if (angle > 120) {
- return 1;
- }
-
- /* skip next */
- isect = isect->next;
- }
- }
- }
-
- return 0;
-}
-
-void sk_applyReverseGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- SK_Intersection *isect;
-
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- /* only reverse strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke) {
- sk_reverseStroke(isect->stroke);
-
- /* skip next */
- isect = isect->next;
- }
- }
-}
-
-int sk_detectConvertGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
-{
- if (gest->nb_segments == 3 && gest->nb_self_intersections == 1) {
- return 1;
- }
- return 0;
-}
-
-void sk_applyConvertGesture(bContext *C, SK_Gesture *UNUSED(gest), SK_Sketch *sketch)
-{
- sk_convert(C, sketch);
-}
-
-static void sk_initGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
-{
- BLI_listbase_clear(&gest->intersections);
- BLI_listbase_clear(&gest->self_intersections);
-
- gest->segments = sk_createStroke();
- gest->stk = sketch->gesture;
-
- gest->nb_self_intersections = sk_getSelfIntersections(C, &gest->self_intersections, gest->stk);
- gest->nb_intersections = sk_getIntersections(C, &gest->intersections, sketch, gest->stk);
- gest->nb_segments = sk_getSegments(gest->segments, gest->stk);
-}
-
-static void sk_freeGesture(SK_Gesture *gest)
-{
- sk_freeStroke(gest->segments);
- BLI_freelistN(&gest->intersections);
- BLI_freelistN(&gest->self_intersections);
-}
-
-static void sk_applyGesture(bContext *C, SK_Sketch *sketch)
-{
- SK_Gesture gest;
- SK_GestureAction *act;
-
- sk_initGesture(C, &gest, sketch);
-
- /* detect and apply */
- for (act = GESTURE_ACTIONS; act->apply != NULL; act++) {
- if (act->detect(C, &gest, sketch)) {
- act->apply(C, &gest, sketch);
- break;
- }
- }
-
- sk_freeGesture(&gest);
-}
-
-/********************************************/
-
-
-static bool sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], const bool extend)
-{
- EvaluationContext eval_ctx;
- ViewContext vc;
- rcti rect;
- unsigned int buffer[MAXPICKBUF];
- short hits;
-
- CTX_data_eval_ctx(C, &eval_ctx);
- ED_view3d_viewcontext_init(C, &vc);
-
- BLI_rcti_init_pt_radius(&rect, mval, 5);
-
- hits = view3d_opengl_select(&eval_ctx, &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
-
- if (hits > 0) {
- int besthitresult = -1;
-
- if (hits == 1) {
- besthitresult = buffer[3];
- }
- else {
- besthitresult = buffer[3];
- /* loop and get best hit */
- }
-
- if (besthitresult > 0) {
- SK_Stroke *selected_stk = BLI_findlink(&sketch->strokes, besthitresult - 1);
-
- if (extend == 0) {
- sk_selectAllSketch(sketch, -1);
-
- selected_stk->selected = 1;
- }
- else {
- selected_stk->selected ^= 1;
- }
-
-
- }
- return 1;
- }
-
- return 0;
-}
-
-#if 0 /* UNUSED 2.5 */
-static void sk_queueRedrawSketch(SK_Sketch *sketch)
-{
- if (sketch->active_stroke != NULL)
- {
- SK_Point *last = sk_lastStrokePoint(sketch->active_stroke);
-
- if (last != NULL)
- {
-// XXX
-// allqueue(REDRAWVIEW3D, 0);
- }
- }
-}
-#endif
-
-static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch, int with_names)
-{
- ToolSettings *ts = scene->toolsettings;
- SK_Stroke *stk;
-
- glClear(GL_DEPTH_BUFFER_BIT);
- glEnable(GL_DEPTH_TEST);
-
- if (with_names) {
- int id;
- for (id = 1, stk = sketch->strokes.first; stk; id++, stk = stk->next) {
- sk_drawStroke(stk, id, NULL, -1, -1);
- }
-
- GPU_select_load_id(-1);
- }
- else {
- float selected_rgb[3] = { 1, 0, 0 };
- float unselected_rgb[3] = { 1, 0.5, 0 };
- float tmp_color[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
- for (stk = sketch->strokes.first; stk; stk = stk->next) {
- int start = -1;
- int end = -1;
-
- if (sk_hasOverdraw(sketch, stk)) {
- sk_adjustIndexes(sketch, &start, &end);
- }
-
- sk_drawStroke(stk, -1, (stk->selected == 1 ? selected_rgb : unselected_rgb), start, end);
-
- if (stk->selected == 1) {
- sk_drawStrokeSubdivision(ts, stk);
- }
- }
-
- if (sketch->active_stroke != NULL) {
- SK_Point *last = sk_lastStrokePoint(sketch->active_stroke);
-
- if (ts->bone_sketching & BONE_SKETCHING_QUICK) {
- sk_drawStrokeSubdivision(ts, sketch->active_stroke);
- }
-
- if (last != NULL) {
- gpuPushMatrix();
-
- glEnable(GL_BLEND);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- switch (sketch->next_point.mode) {
- case PT_SNAP:
- copy_v4_fl4(tmp_color, 0.0f, 1.0f, 0.0f, 1.0f);
- break;
- case PT_PROJECT:
- copy_v4_fl4(tmp_color, 0.0f, 0.0f, 0.0f, 1.0f);
- break;
- }
-
- sk_drawPoint(&sketch->next_point, 0.1, tmp_color);
-
- copy_v4_fl4(tmp_color, selected_rgb[0], selected_rgb[1], selected_rgb[2], 0.3);
- sk_drawEdge(last, &sketch->next_point, 0.1f, tmp_color);
-
- glDisable(GL_BLEND);
-
- gpuPopMatrix();
- }
- }
- }
-
- glDisable(GL_DEPTH_TEST);
-
- /* only draw gesture in active area */
- if (sketch->gesture != NULL /* && area_is_active_area(G.vd->area) */) {
- float gesture_rgb[3] = { 0, 0.5, 1 };
- sk_drawStroke(sketch->gesture, -1, gesture_rgb, -1, -1);
- }
-}
-
-static int sk_finish_stroke(bContext *C, SK_Sketch *sketch)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
-
- if (sketch->active_stroke != NULL) {
- SK_Stroke *stk = sketch->active_stroke;
-
- sk_endStroke(C, sketch);
-
- if (ts->bone_sketching & BONE_SKETCHING_QUICK) {
- if (ts->bone_sketching_convert == SK_CONVERT_RETARGET) {
- sk_retargetStroke(C, stk);
- }
- else {
- sk_convertStroke(C, stk);
- }
-// XXX
-// BIF_undo_push("Convert Sketch");
- sk_removeStroke(sketch, stk);
-// XXX
-// allqueue(REDRAWBUTSEDIT, 0);
- }
-
-// XXX
-// allqueue(REDRAWVIEW3D, 0);
- return 1;
- }
-
- return 0;
-}
-
-static void sk_start_draw_stroke(SK_Sketch *sketch)
-{
- if (sketch->active_stroke == NULL) {
- sk_startStroke(sketch);
- sk_selectAllSketch(sketch, -1);
-
- sketch->active_stroke->selected = 1;
- }
-}
-
-static void sk_start_draw_gesture(SK_Sketch *sketch)
-{
- sketch->gesture = sk_createStroke();
-}
-
-static int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, bool snap)
-{
- if (sk_stroke_filtermval(dd)) {
- sk_addStrokePoint(C, sketch, stk, dd, snap);
- sk_updateDrawData(dd);
- sk_updateNextPoint(sketch, stk);
-
- return 1;
- }
-
- return 0;
-}
-
-static int ValidSketchViewContext(ViewContext *vc)
-{
- Object *obedit = vc->obedit;
- Scene *scene = vc->scene;
-
- if (obedit &&
- obedit->type == OB_ARMATURE &&
- scene->toolsettings->bone_sketching & BONE_SKETCHING)
- {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-int BDR_drawSketchNames(ViewContext *vc)
-{
- if (ValidSketchViewContext(vc)) {
- SK_Sketch *sketch = viewcontextSketch(vc, 0);
- if (sketch) {
- sk_drawSketch(vc->scene, vc->v3d, sketch, 1);
- return 1;
- }
- }
-
- return 0;
-}
-
-void BDR_drawSketch(const bContext *C)
-{
- if (ED_operator_sketch_mode(C)) {
- SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch) {
- sk_drawSketch(CTX_data_scene(C), CTX_wm_view3d(C), sketch, 0);
- }
- }
-}
-
-static int sketch_delete(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
-{
- SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch) {
- sk_deleteSelectedStrokes(sketch);
-// allqueue(REDRAWVIEW3D, 0);
- }
- WM_event_add_notifier(C, NC_SCREEN | ND_SKETCH | NA_REMOVED, NULL);
- return OPERATOR_FINISHED;
-}
-
-bool BIF_sk_selectStroke(bContext *C, const int mval[2], const bool extend)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- SK_Sketch *sketch = contextSketch(C, 0);
-
- if (sketch != NULL && ts->bone_sketching & BONE_SKETCHING) {
- if (sk_selectStroke(C, sketch, mval, extend)) {
- ED_area_tag_redraw(CTX_wm_area(C));
- return true;
- }
- }
-
- return false;
-}
-
-void BIF_convertSketch(bContext *C)
-{
- if (ED_operator_sketch_full_mode(C)) {
- SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch) {
- sk_convert(C, sketch);
-// BIF_undo_push("Convert Sketch");
-// allqueue(REDRAWVIEW3D, 0);
-// allqueue(REDRAWBUTSEDIT, 0);
- }
- }
-}
-
-void BIF_deleteSketch(bContext *C)
-{
- if (ED_operator_sketch_full_mode(C)) {
- SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch) {
- sk_deleteSelectedStrokes(sketch);
-// BIF_undo_push("Convert Sketch");
-// allqueue(REDRAWVIEW3D, 0);
- }
- }
-}
-
-#if 0
-void BIF_selectAllSketch(bContext *C, int mode)
-{
- if (BIF_validSketchMode(C))
- {
- SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch)
- {
- sk_selectAllSketch(sketch, mode);
-// XXX
-// allqueue(REDRAWVIEW3D, 0);
- }
- }
-}
-#endif
-
-SK_Sketch *contextSketch(const bContext *C, int create)
-{
- Object *obedit = CTX_data_edit_object(C);
- SK_Sketch *sketch = NULL;
-
- if (obedit && obedit->type == OB_ARMATURE) {
- bArmature *arm = obedit->data;
-
- if (arm->sketch == NULL && create) {
- arm->sketch = createSketch();
- }
- sketch = arm->sketch;
- }
-
- return sketch;
-}
-
-SK_Sketch *viewcontextSketch(ViewContext *vc, int create)
-{
- Object *obedit = vc->obedit;
- SK_Sketch *sketch = NULL;
-
- if (obedit && obedit->type == OB_ARMATURE) {
- bArmature *arm = obedit->data;
-
- if (arm->sketch == NULL && create) {
- arm->sketch = createSketch();
- }
- sketch = arm->sketch;
- }
-
- return sketch;
-}
-
-static int sketch_convert(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
-{
- SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch != NULL) {
- sk_convert(C, sketch);
- ED_area_tag_redraw(CTX_wm_area(C));
- }
- return OPERATOR_FINISHED;
-}
-
-static int sketch_cancel_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
-{
- SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch != NULL) {
- sk_cancelStroke(sketch);
- ED_area_tag_redraw(CTX_wm_area(C));
- return OPERATOR_FINISHED;
- }
- return OPERATOR_PASS_THROUGH;
-}
-
-static int sketch_finish(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
-{
- SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch != NULL) {
- if (sk_finish_stroke(C, sketch)) {
- ED_area_tag_redraw(CTX_wm_area(C));
- return OPERATOR_FINISHED;
- }
- }
- return OPERATOR_PASS_THROUGH;
-}
-
-static int sketch_select(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
-{
- SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch) {
- short extend = 0;
- if (sk_selectStroke(C, sketch, event->mval, extend))
- ED_area_tag_redraw(CTX_wm_area(C));
- }
-
- return OPERATOR_FINISHED;
-}
-
-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);
-}
-
-static int sketch_draw_stroke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- const bool snap = RNA_boolean_get(op->ptr, "snap");
- SK_DrawData *dd;
- SK_Sketch *sketch = contextSketch(C, 1);
-
- op->customdata = dd = MEM_callocN(sizeof(SK_DrawData), "SketchDrawData");
- sk_initDrawData(dd, event->mval);
-
- sk_start_draw_stroke(sketch);
-
- sk_draw_stroke(C, sketch, sketch->active_stroke, dd, snap);
-
- WM_event_add_modal_handler(C, op);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-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);
-}
-
-static int sketch_draw_gesture(bContext *C, wmOperator *op, const wmEvent *event)
-{
- const bool snap = RNA_boolean_get(op->ptr, "snap");
- SK_DrawData *dd;
- SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
- sk_cancelStroke(sketch);
-
- op->customdata = dd = MEM_callocN(sizeof(SK_DrawData), "SketchDrawData");
- sk_initDrawData(dd, event->mval);
-
- sk_start_draw_gesture(sketch);
- sk_draw_stroke(C, sketch, sketch->gesture, dd, snap);
-
- WM_event_add_modal_handler(C, op);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-static int sketch_draw_modal(bContext *C, wmOperator *op, const wmEvent *event, short gesture, SK_Stroke *stk)
-{
- bool snap = RNA_boolean_get(op->ptr, "snap");
- SK_DrawData *dd = op->customdata;
- SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
- int retval = OPERATOR_RUNNING_MODAL;
-
- switch (event->type) {
- case LEFTCTRLKEY:
- case RIGHTCTRLKEY:
- snap = event->ctrl != 0;
- RNA_boolean_set(op->ptr, "snap", snap);
- break;
- case MOUSEMOVE:
- case INBETWEEN_MOUSEMOVE:
- dd->mval[0] = event->mval[0];
- dd->mval[1] = event->mval[1];
- sk_draw_stroke(C, sketch, stk, dd, snap);
- ED_area_tag_redraw(CTX_wm_area(C));
- break;
- case ESCKEY:
- op->type->cancel(C, op);
- ED_area_tag_redraw(CTX_wm_area(C));
- retval = OPERATOR_CANCELLED;
- break;
- case LEFTMOUSE:
- if (event->val == KM_RELEASE) {
- if (gesture == 0) {
- sk_endContinuousStroke(stk);
- sk_filterLastContinuousStroke(stk);
- sk_updateNextPoint(sketch, stk);
- ED_area_tag_redraw(CTX_wm_area(C));
- MEM_freeN(op->customdata);
- retval = OPERATOR_FINISHED;
- }
- else {
- sk_endContinuousStroke(stk);
- sk_filterLastContinuousStroke(stk);
-
- if (stk->nb_points > 1) {
- /* apply gesture here */
- sk_applyGesture(C, sketch);
- }
-
- sk_freeStroke(stk);
- sketch->gesture = NULL;
-
- ED_area_tag_redraw(CTX_wm_area(C));
- MEM_freeN(op->customdata);
- retval = OPERATOR_FINISHED;
- }
- }
- break;
- }
-
- return retval;
-}
-
-static int sketch_draw_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
- return sketch_draw_modal(C, op, event, 0, sketch->active_stroke);
-}
-
-static int sketch_draw_gesture_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
- return sketch_draw_modal(C, op, event, 1, sketch->gesture);
-}
-
-static int sketch_draw_preview(bContext *C, wmOperator *op, const wmEvent *event)
-{
- const bool snap = RNA_boolean_get(op->ptr, "snap");
- SK_Sketch *sketch = contextSketch(C, 0);
-
- if (sketch) {
- SK_DrawData dd;
-
- sk_initDrawData(&dd, event->mval);
- sk_getStrokePoint(C, &sketch->next_point, sketch, sketch->active_stroke, &dd, snap);
- ED_area_tag_redraw(CTX_wm_area(C));
- }
-
- return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
-}
-
-/* ============================================== Poll Functions ============================================= */
-
-int ED_operator_sketch_mode_active_stroke(bContext *C)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- SK_Sketch *sketch = contextSketch(C, 0);
-
- if (ts->bone_sketching & BONE_SKETCHING &&
- sketch != NULL &&
- sketch->active_stroke != NULL)
- {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-static int ED_operator_sketch_mode_gesture(bContext *C)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- SK_Sketch *sketch = contextSketch(C, 0);
-
- if (ts->bone_sketching & BONE_SKETCHING &&
- (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0 &&
- sketch != NULL &&
- sketch->active_stroke == NULL)
- {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-int ED_operator_sketch_full_mode(bContext *C)
-{
- Object *obedit = CTX_data_edit_object(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
-
- if (obedit &&
- obedit->type == OB_ARMATURE &&
- ts->bone_sketching & BONE_SKETCHING &&
- (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0)
- {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-int ED_operator_sketch_mode(const bContext *C)
-{
- Object *obedit = CTX_data_edit_object(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
-
- if (obedit &&
- obedit->type == OB_ARMATURE &&
- ts->bone_sketching & BONE_SKETCHING)
- {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-/* ================================================ Operators ================================================ */
-
-void SKETCH_OT_delete(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Delete";
- ot->idname = "SKETCH_OT_delete";
- ot->description = "Delete a sketch stroke";
-
- /* api callbacks */
- ot->invoke = sketch_delete;
-
- ot->poll = ED_operator_sketch_full_mode;
-
- /* flags */
-// ot->flag = OPTYPE_UNDO;
-}
-
-void SKETCH_OT_select(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Select";
- ot->idname = "SKETCH_OT_select";
- ot->description = "Select a sketch stroke";
-
- /* api callbacks */
- ot->invoke = sketch_select;
-
- ot->poll = ED_operator_sketch_full_mode;
-
- /* flags */
-// ot->flag = OPTYPE_UNDO;
-}
-
-void SKETCH_OT_cancel_stroke(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Cancel Stroke";
- ot->idname = "SKETCH_OT_cancel_stroke";
- ot->description = "Cancel the current sketch stroke";
-
- /* api callbacks */
- ot->invoke = sketch_cancel_invoke;
-
- ot->poll = ED_operator_sketch_mode_active_stroke;
-
- /* flags */
-// ot->flag = OPTYPE_UNDO;
-}
-
-void SKETCH_OT_convert(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Convert";
- ot->idname = "SKETCH_OT_convert";
- ot->description = "Convert the selected sketch strokes to bone chains";
-
- /* api callbacks */
- ot->invoke = sketch_convert;
-
- ot->poll = ED_operator_sketch_full_mode;
-
- /* flags */
- ot->flag = OPTYPE_UNDO;
-}
-
-void SKETCH_OT_finish_stroke(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "End Stroke";
- ot->idname = "SKETCH_OT_finish_stroke";
- ot->description = "End and keep the current sketch stroke";
-
- /* api callbacks */
- ot->invoke = sketch_finish;
-
- ot->poll = ED_operator_sketch_mode_active_stroke;
-
- /* flags */
-// ot->flag = OPTYPE_UNDO;
-}
-
-void SKETCH_OT_draw_preview(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Draw Preview";
- ot->idname = "SKETCH_OT_draw_preview";
- ot->description = "Draw preview of current sketch stroke (internal use)";
-
- /* api callbacks */
- ot->invoke = sketch_draw_preview;
-
- ot->poll = ED_operator_sketch_mode_active_stroke;
-
- RNA_def_boolean(ot->srna, "snap", 0, "Snap", "");
-
- /* flags */
-// ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-
-void SKETCH_OT_draw_stroke(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Draw Stroke";
- ot->idname = "SKETCH_OT_draw_stroke";
- ot->description = "Start to draw a sketch stroke";
-
- /* api callbacks */
- ot->invoke = sketch_draw_stroke;
- ot->modal = sketch_draw_stroke_modal;
- ot->cancel = sketch_draw_stroke_cancel;
-
- ot->poll = (int (*)(bContext *))ED_operator_sketch_mode;
-
- RNA_def_boolean(ot->srna, "snap", 0, "Snap", "");
-
- /* flags */
- ot->flag = OPTYPE_BLOCKING; // OPTYPE_REGISTER|OPTYPE_UNDO
-}
-
-void SKETCH_OT_gesture(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Gesture";
- ot->idname = "SKETCH_OT_gesture";
- ot->description = "Start to draw a gesture stroke";
-
- /* api callbacks */
- ot->invoke = sketch_draw_gesture;
- ot->modal = sketch_draw_gesture_modal;
- ot->cancel = sketch_draw_gesture_cancel;
-
- ot->poll = ED_operator_sketch_mode_gesture;
-
- RNA_def_boolean(ot->srna, "snap", 0, "Snap", "");
-
- /* flags */
- ot->flag = OPTYPE_BLOCKING; // OPTYPE_UNDO
-}
-
diff --git a/source/blender/editors/armature/editarmature_undo.c b/source/blender/editors/armature/editarmature_undo.c
index 217de06d99b..f6f97af32b9 100644
--- a/source/blender/editors/armature/editarmature_undo.c
+++ b/source/blender/editors/armature/editarmature_undo.c
@@ -27,26 +27,34 @@
* \ingroup edarmature
*/
+#include "MEM_guardedalloc.h"
+
+
+#include "CLG_log.h"
+
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
-#include "MEM_guardedalloc.h"
-
#include "BLI_math.h"
#include "BLI_array_utils.h"
#include "BKE_context.h"
+#include "BKE_layer.h"
#include "BKE_undo_system.h"
#include "DEG_depsgraph.h"
#include "ED_armature.h"
#include "ED_object.h"
+#include "ED_undo.h"
#include "ED_util.h"
#include "WM_types.h"
#include "WM_api.h"
+/** We only need this locally. */
+static CLG_LogRef LOG = {"ed.undo.armature"};
+
/* -------------------------------------------------------------------- */
/** \name Undo Conversion
* \{ */
@@ -121,13 +129,20 @@ static Object *editarm_object_from_context(bContext *C)
/* -------------------------------------------------------------------- */
/** \name Implements ED Undo System
+ *
+ * \note This is similar for all edit-mode types.
* \{ */
-typedef struct ArmatureUndoStep {
- UndoStep step;
- /* note: will split out into list for multi-object-editmode. */
+typedef struct ArmatureUndoStep_Elem {
+ struct ArmatureUndoStep_Elem *next, *prev;
UndoRefID_Object obedit_ref;
UndoArmature data;
+} ArmatureUndoStep_Elem;
+
+typedef struct ArmatureUndoStep {
+ UndoStep step;
+ ArmatureUndoStep_Elem *elems;
+ uint elems_len;
} ArmatureUndoStep;
static bool armature_undosys_poll(bContext *C)
@@ -138,10 +153,24 @@ static bool armature_undosys_poll(bContext *C)
static bool armature_undosys_step_encode(struct bContext *C, UndoStep *us_p)
{
ArmatureUndoStep *us = (ArmatureUndoStep *)us_p;
- us->obedit_ref.ptr = editarm_object_from_context(C);
- bArmature *arm = us->obedit_ref.ptr->data;
- undoarm_from_editarm(&us->data, arm);
- us->step.data_size = us->data.undo_size;
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
+ us->elems_len = objects_len;
+
+ for (uint i = 0; i < objects_len; i++) {
+ Object *ob = objects[i];
+ ArmatureUndoStep_Elem *elem = &us->elems[i];
+
+ elem->obedit_ref.ptr = ob;
+ bArmature *arm = elem->obedit_ref.ptr->data;
+ undoarm_from_editarm(&elem->data, arm);
+ us->step.data_size += elem->data.undo_size;
+ }
+ MEM_freeN(objects);
return true;
}
@@ -152,24 +181,46 @@ static void armature_undosys_step_decode(struct bContext *C, UndoStep *us_p, int
BLI_assert(armature_undosys_poll(C));
ArmatureUndoStep *us = (ArmatureUndoStep *)us_p;
- Object *obedit = us->obedit_ref.ptr;
- bArmature *arm = obedit->data;
- undoarm_to_editarm(&us->data, arm);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ ArmatureUndoStep_Elem *elem = &us->elems[i];
+ Object *obedit = elem->obedit_ref.ptr;
+ bArmature *arm = obedit->data;
+ if (arm->edbo == NULL) {
+ /* Should never fail, may not crash but can give odd behavior. */
+ CLOG_ERROR(&LOG, "name='%s', failed to enter edit-mode for object '%s', undo state invalid", us_p->name, obedit->id.name);
+ continue;
+ }
+ undoarm_to_editarm(&elem->data, arm);
+ DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ }
+
+ /* The first element is always active */
+ ED_undo_object_set_active_or_warn(CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
}
static void armature_undosys_step_free(UndoStep *us_p)
{
ArmatureUndoStep *us = (ArmatureUndoStep *)us_p;
- undoarm_free_data(&us->data);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ ArmatureUndoStep_Elem *elem = &us->elems[i];
+ undoarm_free_data(&elem->data);
+ }
+ MEM_freeN(us->elems);
}
static void armature_undosys_foreach_ID_ref(
UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
{
ArmatureUndoStep *us = (ArmatureUndoStep *)us_p;
- foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->obedit_ref));
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ ArmatureUndoStep_Elem *elem = &us->elems[i];
+ foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));
+ }
}
/* Export for ED_undo_sys. */
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index 489940007e4..ea7a35a4b0e 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -1636,7 +1636,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa
free_bvhtree_from_mesh(&mdb->bvhdata);
}
-void mesh_deform_bind(
+void ED_mesh_deform_bind_callback(
Scene *scene, MeshDeformModifierData *mmd, DerivedMesh *cagedm,
float *vertexcos, int totvert, float cagemat[4][4])
{
diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h
index 05ade4fc43e..9c4ceacbee6 100644
--- a/source/blender/editors/armature/meshlaplacian.h
+++ b/source/blender/editors/armature/meshlaplacian.h
@@ -68,7 +68,7 @@ void rigid_deform_end(int cancel);
/* Harmonic Coordinates */
-/* mesh_deform_bind(...) defined in ED_armature.h */
+/* ED_mesh_deform_bind_callback(...) defined in ED_armature.h */
#endif
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 520ecc797aa..c1e9346efdd 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -31,6 +31,8 @@
* \ingroup edarmature
*/
+#include "MEM_guardedalloc.h"
+
#include "BLI_math.h"
#include "BLI_blenlib.h"
@@ -39,12 +41,14 @@
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
+#include "BKE_action.h"
#include "BKE_anim.h"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_object.h"
#include "BKE_report.h"
+#include "BKE_layer.h"
#include "DEG_depsgraph.h"
@@ -178,8 +182,7 @@ static bool pose_has_protected_selected(Object *ob, short warn)
void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
{
struct Main *bmain = CTX_data_main(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ListBase targets = {NULL, NULL};
/* set flag to force recalc, then grab the relevant bones to target */
@@ -187,7 +190,7 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
animviz_get_object_motionpaths(ob, &targets);
/* recalculate paths, then free */
- animviz_calc_motionpaths(&eval_ctx, bmain, scene, &targets);
+ animviz_calc_motionpaths(depsgraph, bmain, scene, &targets);
BLI_freelistN(&targets);
}
@@ -1015,7 +1018,6 @@ static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEven
static int armature_bone_layers_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
- bArmature *arm = (ob) ? ob->data : NULL;
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
@@ -1023,7 +1025,7 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op)
RNA_boolean_get_array(op->ptr, "layers", layers);
/* set layers of pchans based on the values set in the operator props */
- CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
+ CTX_DATA_BEGIN_WITH_ID (C, EditBone *, ebone, selected_editable_bones, bArmature *, arm)
{
/* get pointer for pchan, and write flags this way */
RNA_pointer_create((ID *)arm, &RNA_EditBone, ebone, &ptr);
@@ -1059,55 +1061,54 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot)
/* ********************************************** */
/* Show/Hide Bones */
-static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
+static int hide_pose_bone_fn(Object *ob, Bone *bone, void *ptr)
{
bArmature *arm = ob->data;
-
+ const bool hide_select = (bool)GET_INT_FROM_POINTER(ptr);
+ int count = 0;
if (arm->layer & bone->layer) {
- if (bone->flag & BONE_SELECTED) {
+ if (((bone->flag & BONE_SELECTED) != 0) == hide_select) {
bone->flag |= BONE_HIDDEN_P;
+ /* only needed when 'hide_select' is true, but harmless. */
bone->flag &= ~BONE_SELECTED;
- if (arm->act_bone == bone)
+ if (arm->act_bone == bone) {
arm->act_bone = NULL;
+ }
+ count += 1;
}
}
- return 0;
-}
-
-static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
-{
- bArmature *arm = ob->data;
-
- if (arm->layer & bone->layer) {
- /* hrm... typo here? */
- if ((bone->flag & BONE_SELECTED) == 0) {
- bone->flag |= BONE_HIDDEN_P;
- if (arm->act_bone == bone)
- arm->act_bone = NULL;
- }
- }
- return 0;
+ return count;
}
/* active object is armature in posemode, poll checked */
-static int pose_hide_exec(bContext *C, wmOperator *op)
+static int pose_hide_exec(bContext *C, wmOperator *op)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm = ob->data;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len;
+ Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len);
+ bool changed_multi = false;
+
+ const int hide_select = !RNA_boolean_get(op->ptr, "unselected");
+ void *hide_select_p = SET_INT_IN_POINTER(hide_select);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ bArmature *arm = ob_iter->data;
+
+ if (ob_iter->proxy != NULL) {
+ BKE_report(op->reports, RPT_INFO, "Undo of hiding can only be done with Reveal Selected");
+ }
- if (ob->proxy != NULL) {
- BKE_report(op->reports, RPT_INFO, "Undo of hiding can only be done with Reveal Selected");
+ bool changed = bone_looper(ob_iter, arm->bonebase.first, hide_select_p, hide_pose_bone_fn) != 0;
+ if (changed) {
+ changed_multi = true;
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob_iter);
+ }
}
+ MEM_freeN(objects);
- if (RNA_boolean_get(op->ptr, "unselected"))
- bone_looper(ob, arm->bonebase.first, NULL, hide_unselected_pose_bone_cb);
- else
- bone_looper(ob, arm->bonebase.first, NULL, hide_selected_pose_bone_cb);
-
- /* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
- return OPERATOR_FINISHED;
+ return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void POSE_OT_hide(wmOperatorType *ot)
@@ -1133,32 +1134,44 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *data)
const bool select = GET_INT_FROM_POINTER(data);
bArmature *arm = ob->data;
-
+ int count = 0;
if (arm->layer & bone->layer) {
if (bone->flag & BONE_HIDDEN_P) {
if (!(bone->flag & BONE_UNSELECTABLE)) {
SET_FLAG_FROM_TEST(bone->flag, select, BONE_SELECTED);
}
bone->flag &= ~BONE_HIDDEN_P;
+ count += 1;
}
}
-
- return 0;
+
+ return count;
}
/* active object is armature in posemode, poll checked */
-static int pose_reveal_exec(bContext *C, wmOperator *op)
+static int pose_reveal_exec(bContext *C, wmOperator *op)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm = ob->data;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len;
+ Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len);
+ bool changed_multi = false;
const bool select = RNA_boolean_get(op->ptr, "select");
-
- bone_looper(ob, arm->bonebase.first, SET_INT_IN_POINTER(select), show_pose_bone_cb);
-
- /* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+ void *select_p = SET_INT_IN_POINTER(select);
- return OPERATOR_FINISHED;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ bArmature *arm = ob_iter->data;
+
+ bool changed = bone_looper(ob_iter, arm->bonebase.first, select_p, show_pose_bone_cb);
+ if (changed) {
+ changed_multi = true;
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob_iter);
+ }
+ }
+ MEM_freeN(objects);
+
+ return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void POSE_OT_reveal(wmOperatorType *ot)
@@ -1184,27 +1197,34 @@ void POSE_OT_reveal(wmOperatorType *ot)
static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID);
-
- /* loop through all selected pchans, flipping and keying (as needed) */
- CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
- {
- /* only if bone is using quaternion rotation */
- if (pchan->rotmode == ROT_MODE_QUAT) {
- /* quaternions have 720 degree range */
- negate_v4(pchan->quat);
- ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
+ bool changed_multi = false;
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) {
+ bool changed = false;
+ /* loop through all selected pchans, flipping and keying (as needed) */
+ FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) {
+ /* only if bone is using quaternion rotation */
+ if (pchan->rotmode == ROT_MODE_QUAT) {
+ changed = true;
+ /* quaternions have 720 degree range */
+ negate_v4(pchan->quat);
+
+ ED_autokeyframe_pchan(C, scene, ob_iter, pchan, ks);
+ }
+ } FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
+
+ if (changed) {
+ changed_multi = true;
+ /* notifiers and updates */
+ DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob_iter);
}
- }
- CTX_DATA_END;
-
- /* notifiers and updates */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
-
- return OPERATOR_FINISHED;
+ } FOREACH_OBJECT_IN_MODE_END;
+
+ return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void POSE_OT_quaternions_flip(wmOperatorType *ot)
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 54c40621a14..609281a7bf2 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -1080,9 +1080,6 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
static void poselib_preview_apply(bContext *C, wmOperator *op)
{
tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
/* only recalc pose (and its dependencies) if pose has changed */
if (pld->redraw == PL_PREVIEW_REDRAWALL) {
@@ -1107,7 +1104,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
if ((pld->arm->flag & ARM_DELAYDEFORM) == 0)
DEG_id_tag_update(&pld->ob->id, OB_RECALC_DATA); /* sets recalc flags */
else
- BKE_pose_where_is(&eval_ctx, pld->scene, pld->ob);
+ BKE_pose_where_is(CTX_data_depsgraph(C), pld->scene, pld->ob);
}
/* do header print - if interactively previewing */
@@ -1598,9 +1595,6 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
bArmature *arm = pld->arm;
bAction *act = pld->act;
TimeMarker *marker = pld->marker;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
/* redraw the header so that it doesn't show any of our stuff anymore */
ED_area_headerprint(pld->sa, NULL);
@@ -1618,7 +1612,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
if ((arm->flag & ARM_DELAYDEFORM) == 0)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
else
- BKE_pose_where_is(&eval_ctx, scene, ob);
+ BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
}
else if (pld->state == PL_PREVIEW_CONFIRM) {
/* tag poses as appropriate */
@@ -1636,7 +1630,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
//remake_action_ipos(ob->action);
}
else
- BKE_pose_where_is(&eval_ctx, scene, ob);
+ BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
}
/* Request final redraw of the view. */
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index a66cedd8d4f..39dba82aaf1 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -45,6 +45,7 @@
#include "BKE_context.h"
#include "BKE_object.h"
#include "BKE_report.h"
+#include "BKE_layer.h"
#include "DEG_depsgraph.h"
@@ -133,7 +134,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
/* called from editview.c, for mode-less pose selection */
/* assumes scene obact and basact is still on old situation */
-bool ED_do_pose_selectbuffer(
+bool ED_armature_pose_select_pick_with_buffer(
ViewLayer *view_layer, Base *base, const unsigned int *buffer, short hits,
bool extend, bool deselect, bool toggle, bool do_nearest)
{
@@ -145,7 +146,9 @@ bool ED_do_pose_selectbuffer(
Object *ob_act = OBACT(view_layer);
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
- nearBone = get_bone_from_selectbuffer(base, obedit, buffer, hits, 1, do_nearest);
+ /* Callers happen to already get the active base */
+ Base *base_dummy = NULL;
+ nearBone = get_bone_from_selectbuffer(&base, 1, obedit != NULL, buffer, hits, 1, do_nearest, &base_dummy);
/* if the bone cannot be affected, don't do anything */
if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) {
@@ -166,7 +169,12 @@ bool ED_do_pose_selectbuffer(
}
if (!extend && !deselect && !toggle) {
- ED_pose_de_selectall(ob, SEL_DESELECT, true);
+ {
+ uint objects_len = 0;
+ Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len);
+ ED_pose_deselect_all_multi(objects, objects_len, SEL_DESELECT, true);
+ MEM_SAFE_FREE(objects);
+ }
nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
arm->act_bone = nearBone;
}
@@ -220,7 +228,7 @@ bool ED_do_pose_selectbuffer(
/* 'select_mode' is usual SEL_SELECT/SEL_DESELECT/SEL_TOGGLE/SEL_INVERT.
* When true, 'ignore_visibility' makes this func also affect invisible bones (hidden or on hidden layers). */
-void ED_pose_de_selectall(Object *ob, int select_mode, const bool ignore_visibility)
+void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibility)
{
bArmature *arm = ob->data;
bPoseChannel *pchan;
@@ -252,6 +260,43 @@ void ED_pose_de_selectall(Object *ob, int select_mode, const bool ignore_visibil
}
}
+static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility)
+{
+ bArmature *arm = ob->data;
+ for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) {
+ if (pchan->bone->flag & BONE_SELECTED) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+static bool ed_pose_is_any_selected_multi(Object **objects, uint objects_len, bool ignore_visibility)
+{
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ if (ed_pose_is_any_selected(ob_iter, ignore_visibility)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void ED_pose_deselect_all_multi(Object **objects, uint objects_len, int select_mode, const bool ignore_visibility)
+{
+ if (select_mode == SEL_TOGGLE) {
+ select_mode = ed_pose_is_any_selected_multi(
+ objects, objects_len, ignore_visibility) ? SEL_DESELECT : SEL_SELECT;
+ }
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ ED_pose_deselect_all(ob_iter, select_mode, ignore_visibility);
+ }
+}
+
/* ***************** Selections ********************** */
static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
@@ -278,17 +323,18 @@ static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
/* previously known as "selectconnected_posearmature" */
static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm = (bArmature *)ob->data;
Bone *bone, *curBone, *next = NULL;
const bool extend = RNA_boolean_get(op->ptr, "extend");
view3d_operator_needs_opengl(C);
- bone = get_nearest_bone(C, event->mval, !extend);
+ Base *base = NULL;
+ bone = get_nearest_bone(C, event->mval, !extend, &base);
if (!bone)
return OPERATOR_CANCELLED;
+
+ bArmature *arm = base->object->data;
/* Select parents */
for (curBone = bone; curBone; curBone = next) {
@@ -310,14 +356,14 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
/* Select children */
for (curBone = bone->childbase.first; curBone; curBone = next)
- selectconnected_posebonechildren(ob, curBone, extend);
+ selectconnected_posebonechildren(base->object, curBone, extend);
/* updates */
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object);
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
return OPERATOR_FINISHED;
@@ -354,27 +400,31 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
Scene *scene = CTX_data_scene(C);
- Object *ob = ED_object_context(C);
- bArmature *arm = ob->data;
int multipaint = scene->toolsettings->multipaint;
if (action == SEL_TOGGLE) {
action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
}
+
+ Object *ob_prev = NULL;
/* Set the flags */
- CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones)
+ CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob)
{
+ bArmature *arm = ob->data;
pose_do_bone_select(pchan, action);
+
+ if (ob_prev != ob) {
+ /* weightpaint or mask modifiers need depsgraph updates */
+ if (multipaint || (arm->flag & ARM_HAS_VIZ_DEPS)) {
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
+ ob_prev = ob;
+ }
}
CTX_DATA_END;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
-
- /* weightpaint or mask modifiers need depsgraph updates */
- if (multipaint || (arm->flag & ARM_HAS_VIZ_DEPS)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- }
return OPERATOR_FINISHED;
}
@@ -450,13 +500,13 @@ void POSE_OT_select_parent(wmOperatorType *ot)
static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm = (bArmature *)ob->data;
bConstraint *con;
int found = 0;
-
- CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
+ Object *ob_prev = NULL;
+
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob)
{
+ bArmature *arm = ob->data;
if (pchan->bone->flag & BONE_SELECTED) {
for (con = pchan->constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
@@ -472,6 +522,16 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
if ((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) {
pchanc->bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
found = 1;
+
+ if (ob != ob_prev) {
+ /* updates */
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+ if (arm->flag & ARM_HAS_VIZ_DEPS) {
+ /* mask modifier ('armature' mode), etc. */
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
+ ob_prev = ob;
+ }
}
}
}
@@ -487,14 +547,6 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
if (!found)
return OPERATOR_CANCELLED;
- /* updates */
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
- if (arm->flag & ARM_HAS_VIZ_DEPS) {
- /* mask modifier ('armature' mode), etc. */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- }
-
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index c49591be5d1..3b8eda1676d 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -49,6 +49,7 @@
#include "BKE_idprop.h"
#include "BKE_main.h"
#include "BKE_object.h"
+#include "BKE_layer.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
@@ -73,10 +74,8 @@
/* helper for apply_armature_pose2bones - fixes parenting of objects that are bone-parented to armature */
static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Object *armob)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object workob, *ob;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
/* go through all objects in database */
for (ob = G.main->object.first; ob; ob = ob->id.next) {
@@ -87,7 +86,7 @@ static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Objec
*/
BKE_object_apply_mat4(ob, ob->obmat, false, false);
- BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
+ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
}
@@ -96,16 +95,14 @@ static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Objec
/* set the current pose as the restpose */
static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
- EvaluationContext eval_ctx;
bArmature *arm = BKE_armature_from_object(ob);
bPose *pose;
bPoseChannel *pchan;
EditBone *curbone;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* don't check if editmode (should be done by caller) */
if (ob->type != OB_ARMATURE)
return OPERATOR_CANCELLED;
@@ -128,7 +125,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
pose = ob->pose;
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- curbone = ED_armature_bone_find_name(arm->edbo, pchan->name);
+ curbone = ED_armature_ebone_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);
@@ -196,7 +193,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
ED_armature_edit_free(arm);
/* flush positions of posebones */
- BKE_pose_where_is(&eval_ctx, scene, ob);
+ BKE_pose_where_is(depsgraph, scene, ob);
/* fix parenting of objects which are bone-parented */
applyarmature_fix_boneparents(C, scene, ob);
@@ -761,57 +758,72 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
void (*clear_func)(bPoseChannel *), const char default_ksName[])
{
Scene *scene = CTX_data_scene(C);
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- short autokey = 0;
-
+
/* sanity checks */
if (ELEM(NULL, clear_func, default_ksName)) {
BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name");
return OPERATOR_CANCELLED;
}
-
+
+ bool changed_multi = false;
+
/* only clear relevant transforms for selected bones */
- CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
- {
- /* run provided clearing function */
- clear_func(pchan);
-
- /* do auto-keyframing as appropriate */
- if (autokeyframe_cfra_can_key(scene, &ob->id)) {
- /* clear any unkeyed tags */
- if (pchan->bone)
- pchan->bone->flag &= ~BONE_UNKEYED;
-
- /* tag for autokeying later */
- autokey = 1;
- }
- else {
- /* add unkeyed tags */
- if (pchan->bone)
- pchan->bone->flag |= BONE_UNKEYED;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) {
+
+ ListBase dsources = {NULL, NULL};
+
+ bool changed = false;
+ FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) {
+
+ /* run provided clearing function */
+ clear_func(pchan);
+ changed = true;
+
+ /* do auto-keyframing as appropriate */
+ if (autokeyframe_cfra_can_key(scene, &ob_iter->id)) {
+ /* clear any unkeyed tags */
+ if (pchan->bone) {
+ pchan->bone->flag &= ~BONE_UNKEYED;
+ }
+ /* tag for autokeying later */
+ ANIM_relative_keyingset_add_source(&dsources, &ob_iter->id, &RNA_PoseBone, pchan);
+ }
+ else {
+ /* add unkeyed tags */
+ if (pchan->bone) {
+ pchan->bone->flag |= BONE_UNKEYED;
+ }
+ }
+ } FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
+
+ if (changed) {
+ changed_multi = true;
+
+ /* perform autokeying on the bones if needed */
+ if (!BLI_listbase_is_empty(&dsources)) {
+ /* get KeyingSet to use */
+ KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName);
+
+ /* insert keyframes */
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
+
+ /* now recalculate paths */
+ if ((ob_iter->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
+ ED_pose_recalculate_paths(C, scene, ob_iter);
+ }
+
+ BLI_freelistN(&dsources);
+ }
+
+ DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
+
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob_iter);
}
- }
- CTX_DATA_END;
-
- /* perform autokeying on the bones if needed */
- if (autokey) {
- /* get KeyingSet to use */
- KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName);
-
- /* insert keyframes */
- ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
-
- /* now recalculate paths */
- if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS))
- ED_pose_recalculate_paths(C, scene, ob);
- }
-
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ } FOREACH_OBJECT_IN_MODE_END;
- /* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
-
- return OPERATOR_FINISHED;
+ return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
/* --------------- */
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index acb9363cf10..0dc89aa4716 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -183,10 +183,8 @@ void poseAnim_mapping_free(ListBase *pfLinks)
/* helper for apply() / reset() - refresh the data */
void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
bArmature *arm = (bArmature *)ob->data;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
/* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
@@ -195,7 +193,7 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
if ((arm->flag & ARM_DELAYDEFORM) == 0)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
else
- BKE_pose_where_is(&eval_ctx, scene, ob);
+ BKE_pose_where_is(depsgraph, scene, ob);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
deleted file mode 100644
index fda7012e955..00000000000
--- a/source/blender/editors/armature/reeb.c
+++ /dev/null
@@ -1,3201 +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.
- *
- * Contributor(s): Martin Poirier
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/armature/reeb.c
- * \ingroup edarmature
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_edgehash.h"
-#include "BLI_ghash.h"
-
-#include "BKE_context.h"
-
-#include "reeb.h"
-
-#if 0 /* UNUSED 2.5 */
-static ReebGraph *GLOBAL_RG = NULL;
-static ReebGraph *FILTERED_RG = NULL;
-#endif
-
-/*
- * Skeleton generation algorithm based on:
- * "Harmonic Skeleton for Realistic Character Animation"
- * Gregoire Aujay, Franck Hetroy, Francis Lazarus and Christine Depraz
- * SIGGRAPH 2007
- *
- * Reeb graph generation algorithm based on:
- * "Robust On-line Computation of Reeb Graphs: Simplicity and Speed"
- * Valerio Pascucci, Giorgio Scorzelli, Peer-Timo Bremer and Ajith Mascarenhas
- * SIGGRAPH 2007
- *
- * */
-
-#if 0
-#define DEBUG_REEB
-#define DEBUG_REEB_NODE
-#endif
-
-/* place-holders! */
-typedef struct EditEdge {
- void *fake;
-} EditEdge;
-
-typedef struct EditFace {
- void *fake;
-} EditFace;
-/* end place-holders! */
-
-typedef struct VertexData {
- float w; /* weight */
- int i; /* index */
- ReebNode *n;
-} VertexData;
-
-typedef struct EdgeIndex {
- EditEdge **edges;
- int *offset;
-} EdgeIndex;
-
-typedef enum {
- MERGE_LOWER,
- MERGE_HIGHER,
- MERGE_APPEND
-} MergeDirection;
-
-int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1);
-void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection direction);
-int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1);
-EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index);
-void mergeArcFaces(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc);
-void addFacetoArc(ReebArc *arc, EditFace *efa);
-
-void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count);
-void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BArc *barc1, BArc *barc2);
-
-void flipArcBuckets(ReebArc *arc);
-
-
-/***************************************** UTILS **********************************************/
-
-#if 0 /* UNUSED */
-static VertexData *allocVertexData(EditMesh *em)
-{
- VertexData *data;
- EditVert *eve;
- int totvert, index;
-
- totvert = BLI_listbase_count(&em->verts);
-
- data = MEM_callocN(sizeof(VertexData) * totvert, "VertexData");
-
- for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next)
- {
- data[index].i = index;
- data[index].w = 0;
- eve->tmp.p = data + index;
- }
-
- return data;
-}
-
-static int indexData(EditVert *eve)
-{
- return ((VertexData *)eve->tmp.p)->i;
-}
-
-static float weightData(EditVert *eve)
-{
- return ((VertexData *)eve->tmp.p)->w;
-}
-
-static void weightSetData(EditVert *eve, float w)
-{
- ((VertexData *)eve->tmp.p)->w = w;
-}
-
-static ReebNode *nodeData(EditVert *eve)
-{
- return ((VertexData *)eve->tmp.p)->n;
-}
-
-static void nodeSetData(EditVert *eve, ReebNode *n)
-{
- ((VertexData *)eve->tmp.p)->n = n;
-}
-
-#endif
-
-void REEB_freeArc(BArc *barc)
-{
- ReebArc *arc = (ReebArc *)barc;
- BLI_freelistN(&arc->edges);
-
- if (arc->buckets)
- MEM_freeN(arc->buckets);
-
- if (arc->faces)
- BLI_ghash_free(arc->faces, NULL, NULL);
-
- MEM_freeN(arc);
-}
-
-void REEB_freeGraph(ReebGraph *rg)
-{
- ReebArc *arc;
- ReebNode *node;
-
- // free nodes
- for (node = rg->nodes.first; node; node = node->next) {
- BLI_freeNode((BGraph *)rg, (BNode *)node);
- }
- BLI_freelistN(&rg->nodes);
-
- // free arcs
- arc = rg->arcs.first;
- while (arc) {
- ReebArc *next = arc->next;
- REEB_freeArc((BArc *)arc);
- arc = next;
- }
-
- // free edge map
- BLI_edgehash_free(rg->emap, NULL);
-
- /* free linked graph */
- if (rg->link_up) {
- REEB_freeGraph(rg->link_up);
- }
-
- MEM_freeN(rg);
-}
-
-ReebGraph *newReebGraph(void)
-{
- ReebGraph *rg;
- rg = MEM_callocN(sizeof(ReebGraph), "reeb graph");
-
- rg->totnodes = 0;
- rg->emap = BLI_edgehash_new(__func__);
-
-
- rg->free_arc = REEB_freeArc;
- rg->free_node = NULL;
- rg->radial_symmetry = REEB_RadialSymmetry;
- rg->axial_symmetry = REEB_AxialSymmetry;
-
- return rg;
-}
-
-void BIF_flagMultiArcs(ReebGraph *rg, int flag)
-{
- for (; rg; rg = rg->link_up) {
- BLI_flagArcs((BGraph *)rg, flag);
- }
-}
-
-#if 0 /* UNUSED */
-static ReebNode *addNode(ReebGraph *rg, EditVert *eve)
-{
- float weight;
- ReebNode *node = NULL;
-
- weight = weightData(eve);
-
- node = MEM_callocN(sizeof(ReebNode), "reeb node");
-
- node->flag = 0; // clear flag on init
- node->symmetry_level = 0;
- node->arcs = NULL;
- node->degree = 0;
- node->weight = weight;
- node->index = rg->totnodes;
- copy_v3_v3(node->p, eve->co);
-
- BLI_addtail(&rg->nodes, node);
- rg->totnodes++;
-
- nodeSetData(eve, node);
-
- return node;
-}
-
-static ReebNode *copyNode(ReebGraph *rg, ReebNode *node)
-{
- ReebNode *cp_node = NULL;
-
- cp_node = MEM_callocN(sizeof(ReebNode), "reeb node copy");
-
- memcpy(cp_node, node, sizeof(ReebNode));
-
- cp_node->prev = NULL;
- cp_node->next = NULL;
- cp_node->arcs = NULL;
-
- cp_node->link_up = NULL;
- cp_node->link_down = NULL;
-
- BLI_addtail(&rg->nodes, cp_node);
- rg->totnodes++;
-
- return cp_node;
-}
-
-static void relinkNodes(ReebGraph *low_rg, ReebGraph *high_rg)
-{
- ReebNode *low_node, *high_node;
-
- if (low_rg == NULL || high_rg == NULL)
- {
- return;
- }
-
- for (low_node = low_rg->nodes.first; low_node; low_node = low_node->next)
- {
- for (high_node = high_rg->nodes.first; high_node; high_node = high_node->next)
- {
- if (low_node->index == high_node->index)
- {
- high_node->link_down = low_node;
- low_node->link_up = high_node;
- break;
- }
- }
- }
-}
-#endif
-
-ReebNode *BIF_otherNodeFromIndex(ReebArc *arc, ReebNode *node)
-{
- return (arc->head->index == node->index) ? arc->tail : arc->head;
-}
-
-ReebNode *BIF_NodeFromIndex(ReebArc *arc, ReebNode *node)
-{
- return (arc->head->index == node->index) ? arc->head : arc->tail;
-}
-
-ReebNode *BIF_lowestLevelNode(ReebNode *node)
-{
- while (node->link_down) {
- node = node->link_down;
- }
-
- return node;
-}
-
-#if 0 /* UNUSED */
-static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc)
-{
- ReebArc *cp_arc;
- ReebNode *node;
-
- cp_arc = MEM_callocN(sizeof(ReebArc), "reeb arc copy");
-
- memcpy(cp_arc, arc, sizeof(ReebArc));
-
- cp_arc->link_up = arc;
-
- cp_arc->head = NULL;
- cp_arc->tail = NULL;
-
- cp_arc->prev = NULL;
- cp_arc->next = NULL;
-
- cp_arc->edges.first = NULL;
- cp_arc->edges.last = NULL;
-
- /* copy buckets */
- cp_arc->buckets = MEM_callocN(sizeof(EmbedBucket) * cp_arc->bcount, "embed bucket");
- memcpy(cp_arc->buckets, arc->buckets, sizeof(EmbedBucket) * cp_arc->bcount);
-
- /* copy faces map */
- cp_arc->faces = BLI_ghash_ptr_new("copyArc gh");
- mergeArcFaces(rg, cp_arc, arc);
-
- /* find corresponding head and tail */
- for (node = rg->nodes.first; node && (cp_arc->head == NULL || cp_arc->tail == NULL); node = node->next)
- {
- if (node->index == arc->head->index)
- {
- cp_arc->head = node;
- }
- else if (node->index == arc->tail->index)
- {
- cp_arc->tail = node;
- }
- }
-
- BLI_addtail(&rg->arcs, cp_arc);
-
- return cp_arc;
-}
-
-static ReebGraph *copyReebGraph(ReebGraph *rg, int level)
-{
- ReebNode *node;
- ReebArc *arc;
- ReebGraph *cp_rg = newReebGraph();
-
- cp_rg->resolution = rg->resolution;
- cp_rg->length = rg->length;
- cp_rg->link_up = rg;
- cp_rg->multi_level = level;
-
- /* Copy nodes */
- for (node = rg->nodes.first; node; node = node->next)
- {
- ReebNode *cp_node = copyNode(cp_rg, node);
- cp_node->multi_level = level;
- }
-
- /* Copy arcs */
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
- copyArc(cp_rg, arc);
- }
-
- BLI_buildAdjacencyList((BGraph *)cp_rg);
-
- return cp_rg;
-}
-#endif
-
-ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node)
-{
- ReebGraph *multi_rg = rg;
-
- while (multi_rg && multi_rg->multi_level != node->multi_level) {
- multi_rg = multi_rg->link_up;
- }
-
- return multi_rg;
-}
-
-#if 0 /* UNUSED */
-static ReebEdge *copyEdge(ReebEdge *edge)
-{
- ReebEdge *newEdge = NULL;
-
- newEdge = MEM_callocN(sizeof(ReebEdge), "reeb edge");
- memcpy(newEdge, edge, sizeof(ReebEdge));
-
- newEdge->next = NULL;
- newEdge->prev = NULL;
-
- return newEdge;
-}
-
-static void printArc(ReebArc *arc)
-{
- ReebEdge *edge;
- ReebNode *head = (ReebNode *)arc->head;
- ReebNode *tail = (ReebNode *)arc->tail;
- printf("arc: (%i) %f -> (%i) %f\n", head->index, head->weight, tail->index, tail->weight);
-
- for (edge = arc->edges.first; edge; edge = edge->next)
- {
- printf("\tedge (%i, %i)\n", edge->v1->index, edge->v2->index);
- }
-}
-
-static void flipArc(ReebArc *arc)
-{
- ReebNode *tmp;
- tmp = arc->head;
- arc->head = arc->tail;
- arc->tail = tmp;
-
- flipArcBuckets(arc);
-}
-
-#ifdef DEBUG_REEB_NODE
-static void NodeDegreeDecrement(ReebGraph *UNUSED(rg), ReebNode *node)
-{
- node->degree--;
-
-// if (node->degree == 0)
-// {
-// printf("would remove node %i\n", node->index);
-// }
-}
-
-static void NodeDegreeIncrement(ReebGraph *UNUSED(rg), ReebNode *node)
-{
-// if (node->degree == 0)
-// {
-// printf("first connect node %i\n", node->index);
-// }
-
- node->degree++;
-}
-
-#else
-# define NodeDegreeDecrement(rg, node) {node->degree--; } (void)0
-# define NodeDegreeIncrement(rg, node) {node->degree++; } (void)0
-#endif
-
-void repositionNodes(ReebGraph *rg)
-{
- BArc *arc = NULL;
- BNode *node = NULL;
-
- // Reset node positions
- for (node = rg->nodes.first; node; node = node->next) {
- node->p[0] = node->p[1] = node->p[2] = 0;
- }
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- if (((ReebArc *)arc)->bcount > 0) {
- float p[3];
-
- copy_v3_v3(p, ((ReebArc *)arc)->buckets[0].p);
- mul_v3_fl(p, 1.0f / arc->head->degree);
- add_v3_v3(arc->head->p, p);
-
- copy_v3_v3(p, ((ReebArc *)arc)->buckets[((ReebArc *)arc)->bcount - 1].p);
- mul_v3_fl(p, 1.0f / arc->tail->degree);
- add_v3_v3(arc->tail->p, p);
- }
- }
-}
-
-void verifyNodeDegree(ReebGraph *rg)
-{
-#ifdef DEBUG_REEB
- ReebNode *node = NULL;
- ReebArc *arc = NULL;
-
- for (node = rg->nodes.first; node; node = node->next) {
- int count = 0;
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- if (arc->head == node || arc->tail == node) {
- count++;
- }
- }
- if (count != node->degree) {
- printf("degree error in node %i: expected %i got %i\n", node->index, count, node->degree);
- }
- if (node->degree == 0) {
- printf("zero degree node %i with weight %f\n", node->index, node->weight);
- }
- }
-#endif
-}
-
-static void verifyBucketsArc(ReebGraph *UNUSED(rg), ReebArc *arc)
-{
- ReebNode *head = (ReebNode *)arc->head;
- ReebNode *tail = (ReebNode *)arc->tail;
-
- if (arc->bcount > 0) {
- int i;
- for (i = 0; i < arc->bcount; i++) {
- if (arc->buckets[i].nv == 0) {
- printArc(arc);
- printf("count error in bucket %i/%i\n", i + 1, arc->bcount);
- }
- }
-
- if (ceilf(head->weight) != arc->buckets[0].val) {
- printArc(arc);
- printf("alloc error in first bucket: %f should be %f\n", arc->buckets[0].val, ceil(head->weight));
- }
- if (floorf(tail->weight) != arc->buckets[arc->bcount - 1].val) {
- printArc(arc);
- printf("alloc error in last bucket: %f should be %f\n", arc->buckets[arc->bcount - 1].val, floor(tail->weight));
- }
- }
-}
-
-void verifyBuckets(ReebGraph *rg)
-{
-#ifdef DEBUG_REEB
- ReebArc *arc = NULL;
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- verifyBucketsArc(rg, arc);
- }
-#endif
-}
-
-void verifyFaces(ReebGraph *rg)
-{
-#ifdef DEBUG_REEB
- int total = 0;
- ReebArc *arc = NULL;
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- total += BLI_ghash_len(arc->faces);
- }
-
-#endif
-}
-
-void verifyArcs(ReebGraph *rg)
-{
- ReebArc *arc;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- if (arc->head->weight > arc->tail->weight) {
- printf("FLIPPED ARC!\n");
- }
- }
-}
-
-static void verifyMultiResolutionLinks(ReebGraph *rg, int level)
-{
-#ifdef DEBUG_REEB
- ReebGraph *lower_rg = rg->link_up;
-
- if (lower_rg) {
- ReebArc *arc;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- if (BLI_findindex(&lower_rg->arcs, arc->link_up) == -1) {
- printf("missing arc %p for level %i\n", (void *)arc->link_up, level);
- printf("Source arc was ---\n");
- printArc(arc);
-
- arc->link_up = NULL;
- }
- }
-
-
- verifyMultiResolutionLinks(lower_rg, level + 1);
- }
-#endif
-}
-/***************************************** BUCKET UTILS **********************************************/
-
-static void addVertToBucket(EmbedBucket *b, float co[3])
-{
- b->nv++;
- interp_v3_v3v3(b->p, b->p, co, 1.0f / b->nv);
-}
-
-#if 0 /* UNUSED 2.5 */
-static void removeVertFromBucket(EmbedBucket *b, float co[3])
-{
- mul_v3_fl(b->p, (float)b->nv);
- sub_v3_v3(b->p, co);
- b->nv--;
- mul_v3_fl(b->p, 1.0f / (float)b->nv);
-}
-#endif
-
-static void mergeBuckets(EmbedBucket *bDst, EmbedBucket *bSrc)
-{
- if (bDst->nv > 0 && bSrc->nv > 0) {
- bDst->nv += bSrc->nv;
- interp_v3_v3v3(bDst->p, bDst->p, bSrc->p, (float)bSrc->nv / (float)(bDst->nv));
- }
- else if (bSrc->nv > 0) {
- bDst->nv = bSrc->nv;
- copy_v3_v3(bDst->p, bSrc->p);
- }
-}
-
-static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end)
-{
- if (aDst->bcount > 0 && aSrc->bcount > 0) {
- int indexDst = 0, indexSrc = 0;
-
- start = max_fff(start, aDst->buckets[0].val, aSrc->buckets[0].val);
-
- while (indexDst < aDst->bcount && aDst->buckets[indexDst].val < start) {
- indexDst++;
- }
-
- while (indexSrc < aSrc->bcount && aSrc->buckets[indexSrc].val < start) {
- indexSrc++;
- }
-
- for (; indexDst < aDst->bcount &&
- indexSrc < aSrc->bcount &&
- aDst->buckets[indexDst].val <= end &&
- aSrc->buckets[indexSrc].val <= end
-
- ; indexDst++, indexSrc++)
- {
- mergeBuckets(aDst->buckets + indexDst, aSrc->buckets + indexSrc);
- }
- }
-}
-
-void flipArcBuckets(ReebArc *arc)
-{
- int i, j;
-
- for (i = 0, j = arc->bcount - 1; i < j; i++, j--) {
- EmbedBucket tmp;
-
- tmp = arc->buckets[i];
- arc->buckets[i] = arc->buckets[j];
- arc->buckets[j] = tmp;
- }
-}
-
-static int countArcBuckets(ReebArc *arc)
-{
- return (int)(floor(arc->tail->weight) - ceil(arc->head->weight)) + 1;
-}
-
-static void allocArcBuckets(ReebArc *arc)
-{
- int i;
- float start = ceil(arc->head->weight);
- arc->bcount = countArcBuckets(arc);
-
- if (arc->bcount > 0) {
- arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "embed bucket");
-
- for (i = 0; i < arc->bcount; i++) {
- arc->buckets[i].val = start + i;
- }
- }
- else {
- arc->buckets = NULL;
- }
-}
-
-static void resizeArcBuckets(ReebArc *arc)
-{
- EmbedBucket *oldBuckets = arc->buckets;
- int oldBCount = arc->bcount;
-
- if (countArcBuckets(arc) == oldBCount) {
- return;
- }
-
- allocArcBuckets(arc);
-
- if (oldBCount != 0 && arc->bcount != 0) {
- int oldStart = (int)oldBuckets[0].val;
- int oldEnd = (int)oldBuckets[oldBCount - 1].val;
- int newStart = (int)arc->buckets[0].val;
- int newEnd = (int)arc->buckets[arc->bcount - 1].val;
- int oldOffset = 0;
- int newOffset = 0;
- int len;
-
- if (oldStart < newStart) {
- oldOffset = newStart - oldStart;
- }
- else {
- newOffset = oldStart - newStart;
- }
-
- len = MIN2(oldEnd - (oldStart + oldOffset) + 1, newEnd - (newStart - newOffset) + 1);
-
- memcpy(arc->buckets + newOffset, oldBuckets + oldOffset, len * sizeof(EmbedBucket));
- }
-
- if (oldBuckets != NULL) {
- MEM_freeN(oldBuckets);
- }
-}
-
-static void reweightBuckets(ReebArc *arc)
-{
- int i;
- float start = ceil((arc->head)->weight);
-
- if (arc->bcount > 0) {
- for (i = 0; i < arc->bcount; i++) {
- arc->buckets[i].val = start + i;
- }
- }
-}
-
-static void interpolateBuckets(ReebArc *arc, float *start_p, float *end_p, int start_index, int end_index)
-{
- int total;
- int j;
-
- total = end_index - start_index + 2;
-
- for (j = start_index; j <= end_index; j++) {
- EmbedBucket *empty = arc->buckets + j;
- empty->nv = 1;
- interp_v3_v3v3(empty->p, start_p, end_p, (float)(j - start_index + 1) / total);
- }
-}
-
-static void fillArcEmptyBuckets(ReebArc *arc)
-{
- float *start_p, *end_p;
- int start_index = 0, end_index = 0;
- int missing = 0;
- int i;
-
- start_p = arc->head->p;
-
- for (i = 0; i < arc->bcount; i++) {
- EmbedBucket *bucket = arc->buckets + i;
-
- if (missing) {
- if (bucket->nv > 0) {
- missing = 0;
-
- end_p = bucket->p;
- end_index = i - 1;
-
- interpolateBuckets(arc, start_p, end_p, start_index, end_index);
- }
- }
- else {
- if (bucket->nv == 0) {
- missing = 1;
-
- if (i > 0) {
- start_p = arc->buckets[i - 1].p;
- }
- start_index = i;
- }
- }
- }
-
- if (missing) {
- end_p = arc->tail->p;
- end_index = arc->bcount - 1;
-
- interpolateBuckets(arc, start_p, end_p, start_index, end_index);
- }
-}
-
-static void ExtendArcBuckets(ReebArc *arc)
-{
- ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator *)&arc_iter;
- EmbedBucket *last_bucket, *first_bucket;
- float *previous = NULL;
- float average_length = 0, length;
- int padding_head = 0, padding_tail = 0;
-
- if (arc->bcount == 0) {
- return; /* failsafe, shouldn't happen */
- }
-
- initArcIterator(iter, arc, arc->head);
- IT_next(iter);
- previous = iter->p;
-
- for (IT_next(iter);
- IT_stopped(iter) == 0;
- previous = iter->p, IT_next(iter)
- )
- {
- average_length += len_v3v3(previous, iter->p);
- }
- average_length /= (arc->bcount - 1);
-
- first_bucket = arc->buckets;
- last_bucket = arc->buckets + (arc->bcount - 1);
-
- length = len_v3v3(first_bucket->p, arc->head->p);
- if (length > 2 * average_length) {
- padding_head = (int)floor(length / average_length);
- }
-
- length = len_v3v3(last_bucket->p, arc->tail->p);
- if (length > 2 * average_length) {
- padding_tail = (int)floor(length / average_length);
- }
-
- if (padding_head + padding_tail > 0) {
- EmbedBucket *old_buckets = arc->buckets;
-
- arc->buckets = MEM_callocN(sizeof(EmbedBucket) * (padding_head + arc->bcount + padding_tail), "embed bucket");
- memcpy(arc->buckets + padding_head, old_buckets, arc->bcount * sizeof(EmbedBucket));
-
- arc->bcount = padding_head + arc->bcount + padding_tail;
-
- MEM_freeN(old_buckets);
- }
-
- if (padding_head > 0) {
- interpolateBuckets(arc, arc->head->p, first_bucket->p, 0, padding_head);
- }
-
- if (padding_tail > 0) {
- interpolateBuckets(arc, last_bucket->p, arc->tail->p, arc->bcount - padding_tail, arc->bcount - 1);
- }
-}
-
-/* CALL THIS ONLY AFTER FILTERING, SINCE IT MESSES UP WEIGHT DISTRIBUTION */
-static void extendGraphBuckets(ReebGraph *rg)
-{
- ReebArc *arc;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- ExtendArcBuckets(arc);
- }
-}
-
-/**************************************** LENGTH CALCULATIONS ****************************************/
-
-static void calculateArcLength(ReebArc *arc)
-{
- ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator *)&arc_iter;
- float *vec0, *vec1;
-
- arc->length = 0;
-
- initArcIterator(iter, arc, arc->head);
-
- vec0 = arc->head->p;
- vec1 = arc->head->p; /* in case there's no embedding */
-
- while (IT_next(iter)) {
- vec1 = iter->p;
-
- arc->length += len_v3v3(vec0, vec1);
-
- vec0 = vec1;
- }
-
- arc->length += len_v3v3(arc->tail->p, vec1);
-}
-
-static void calculateGraphLength(ReebGraph *rg)
-{
- ReebArc *arc;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- calculateArcLength(arc);
- }
-}
-#endif
-
-/**************************************** SYMMETRY HANDLING ******************************************/
-
-void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count)
-{
- ReebNode *node = (ReebNode *)root_node;
- float axis[3];
- int i;
-
- copy_v3_v3(axis, root_node->symmetry_axis);
-
- /* first pass, merge incrementally */
- for (i = 0; i < count - 1; i++) {
- ReebNode *node1, *node2;
- ReebArc *arc1, *arc2;
- float tangent[3];
- float normal[3];
- int j = i + 1;
-
- add_v3_v3v3(tangent, ring[i].n, ring[j].n);
- cross_v3_v3v3(normal, tangent, axis);
-
- node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node);
- node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node);
-
- arc1 = (ReebArc *)ring[i].arc;
- arc2 = (ReebArc *)ring[j].arc;
-
- /* mirror first node and mix with the second */
- BLI_mirrorAlongAxis(node1->p, root_node->p, normal);
- interp_v3_v3v3(node2->p, node2->p, node1->p, 1.0f / (j + 1));
-
- /* Merge buckets
- * there shouldn't be any null arcs here, but just to be safe
- * */
- if (arc1->bcount > 0 && arc2->bcount > 0) {
- ReebArcIterator arc_iter1, arc_iter2;
- BArcIterator *iter1 = (BArcIterator *)&arc_iter1;
- BArcIterator *iter2 = (BArcIterator *)&arc_iter2;
- EmbedBucket *bucket1 = NULL, *bucket2 = NULL;
-
- initArcIterator(iter1, arc1, (ReebNode *)root_node);
- initArcIterator(iter2, arc2, (ReebNode *)root_node);
-
- bucket1 = IT_next(iter1);
- bucket2 = IT_next(iter2);
-
- /* Make sure they both start at the same value */
- while (bucket1 && bucket2 && bucket1->val < bucket2->val) {
- bucket1 = IT_next(iter1);
- }
-
- while (bucket1 && bucket2 && bucket2->val < bucket1->val) {
- bucket2 = IT_next(iter2);
- }
-
-
- for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
- bucket2->nv += bucket1->nv; /* add counts */
-
- /* mirror on axis */
- BLI_mirrorAlongAxis(bucket1->p, root_node->p, normal);
- /* add bucket2 in bucket1 */
- interp_v3_v3v3(bucket2->p, bucket2->p, bucket1->p, (float)bucket1->nv / (float)(bucket2->nv));
- }
- }
- }
-
- /* second pass, mirror back on previous arcs */
- for (i = count - 1; i > 0; i--) {
- ReebNode *node1, *node2;
- ReebArc *arc1, *arc2;
- float tangent[3];
- float normal[3];
- int j = i - 1;
-
- add_v3_v3v3(tangent, ring[i].n, ring[j].n);
- cross_v3_v3v3(normal, tangent, axis);
-
- node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node);
- node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node);
-
- arc1 = (ReebArc *)ring[i].arc;
- arc2 = (ReebArc *)ring[j].arc;
-
- /* copy first node than mirror */
- copy_v3_v3(node2->p, node1->p);
- BLI_mirrorAlongAxis(node2->p, root_node->p, normal);
-
- /* Copy buckets
- * there shouldn't be any null arcs here, but just to be safe
- * */
- if (arc1->bcount > 0 && arc2->bcount > 0) {
- ReebArcIterator arc_iter1, arc_iter2;
- BArcIterator *iter1 = (BArcIterator *)&arc_iter1;
- BArcIterator *iter2 = (BArcIterator *)&arc_iter2;
- EmbedBucket *bucket1 = NULL, *bucket2 = NULL;
-
- initArcIterator(iter1, arc1, node);
- initArcIterator(iter2, arc2, node);
-
- bucket1 = IT_next(iter1);
- bucket2 = IT_next(iter2);
-
- /* Make sure they both start at the same value */
- while (bucket1 && bucket1->val < bucket2->val) {
- bucket1 = IT_next(iter1);
- }
-
- while (bucket2 && bucket2->val < bucket1->val) {
- bucket2 = IT_next(iter2);
- }
-
-
- for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
- /* copy and mirror back to bucket2 */
- bucket2->nv = bucket1->nv;
- copy_v3_v3(bucket2->p, bucket1->p);
- BLI_mirrorAlongAxis(bucket2->p, node->p, normal);
- }
- }
- }
-}
-
-void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BArc *barc1, BArc *barc2)
-{
- ReebArc *arc1, *arc2;
- float nor[3], p[3];
-
- arc1 = (ReebArc *)barc1;
- arc2 = (ReebArc *)barc2;
-
- copy_v3_v3(nor, root_node->symmetry_axis);
-
- /* mirror node2 along axis */
- copy_v3_v3(p, node2->p);
- BLI_mirrorAlongAxis(p, root_node->p, nor);
-
- /* average with node1 */
- add_v3_v3(node1->p, p);
- mul_v3_fl(node1->p, 0.5f);
-
- /* mirror back on node2 */
- copy_v3_v3(node2->p, node1->p);
- BLI_mirrorAlongAxis(node2->p, root_node->p, nor);
-
- /* Merge buckets
- * there shouldn't be any null arcs here, but just to be safe
- * */
- if (arc1->bcount > 0 && arc2->bcount > 0) {
- ReebArcIterator arc_iter1, arc_iter2;
- BArcIterator *iter1 = (BArcIterator *)&arc_iter1;
- BArcIterator *iter2 = (BArcIterator *)&arc_iter2;
- EmbedBucket *bucket1 = NULL, *bucket2 = NULL;
-
- initArcIterator(iter1, arc1, (ReebNode *)root_node);
- initArcIterator(iter2, arc2, (ReebNode *)root_node);
-
- bucket1 = IT_next(iter1);
- bucket2 = IT_next(iter2);
-
- /* Make sure they both start at the same value */
- while (bucket1 && bucket1->val < bucket2->val) {
- bucket1 = IT_next(iter1);
- }
-
- while (bucket2 && bucket2->val < bucket1->val) {
- bucket2 = IT_next(iter2);
- }
-
-
- for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
- bucket1->nv += bucket2->nv; /* add counts */
-
- /* mirror on axis */
- BLI_mirrorAlongAxis(bucket2->p, root_node->p, nor);
- /* add bucket2 in bucket1 */
- interp_v3_v3v3(bucket1->p, bucket1->p, bucket2->p, (float)bucket2->nv / (float)(bucket1->nv));
-
- /* copy and mirror back to bucket2 */
- bucket2->nv = bucket1->nv;
- copy_v3_v3(bucket2->p, bucket1->p);
- BLI_mirrorAlongAxis(bucket2->p, root_node->p, nor);
- }
- }
-}
-
-/************************************** ADJACENCY LIST *************************************************/
-
-
-/****************************************** SMOOTHING **************************************************/
-
-#if 0 /* UNUSED */
-void postprocessGraph(ReebGraph *rg, char mode)
-{
- ReebArc *arc;
- float fac1 = 0, fac2 = 1, fac3 = 0;
-
- switch (mode)
- {
- case SKGEN_AVERAGE:
- fac1 = fac2 = fac3 = 1.0f / 3.0f;
- break;
- case SKGEN_SMOOTH:
- fac1 = fac3 = 0.25f;
- fac2 = 0.5f;
- break;
- case SKGEN_SHARPEN:
- fac1 = fac3 = -0.25f;
- fac2 = 1.5f;
- break;
- default:
-// XXX
-// error("Unknown post processing mode");
- return;
- }
-
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
- EmbedBucket *buckets = arc->buckets;
- int bcount = arc->bcount;
- int index;
-
- for (index = 1; index < bcount - 1; index++)
- {
- interp_v3_v3v3(buckets[index].p, buckets[index].p, buckets[index - 1].p, fac1 / (fac1 + fac2));
- interp_v3_v3v3(buckets[index].p, buckets[index].p, buckets[index + 1].p, fac3 / (fac1 + fac2 + fac3));
- }
- }
-}
-
-/********************************************SORTING****************************************************/
-
-static int compareNodesWeight(void *vnode1, void *vnode2)
-{
- ReebNode *node1 = (ReebNode *)vnode1;
- ReebNode *node2 = (ReebNode *)vnode2;
-
- if (node1->weight < node2->weight)
- {
- return -1;
- }
- if (node1->weight > node2->weight)
- {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-void sortNodes(ReebGraph *rg)
-{
- BLI_listbase_sort(&rg->nodes, compareNodesWeight);
-}
-
-static int compareArcsWeight(void *varc1, void *varc2)
-{
- ReebArc *arc1 = (ReebArc *)varc1;
- ReebArc *arc2 = (ReebArc *)varc2;
- ReebNode *node1 = (ReebNode *)arc1->head;
- ReebNode *node2 = (ReebNode *)arc2->head;
-
- if (node1->weight < node2->weight)
- {
- return -1;
- }
- if (node1->weight > node2->weight)
- {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-void sortArcs(ReebGraph *rg)
-{
- BLI_listbase_sort(&rg->arcs, compareArcsWeight);
-}
-/******************************************* JOINING ***************************************************/
-
-static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float start_weight)
-{
- ReebNode *node;
- float old_weight;
- float end_weight = start_weight + ABS(arc->tail->weight - arc->head->weight);
- int i;
-
- node = (ReebNode *)BLI_otherNode((BArc *)arc, (BNode *)start_node);
-
- /* prevent backtracking */
- if (node->flag == 1)
- {
- return;
- }
-
- if (arc->tail == start_node)
- {
- flipArc(arc);
- }
-
- start_node->flag = 1;
-
- for (i = 0; i < node->degree; i++)
- {
- ReebArc *next_arc = node->arcs[i];
-
- reweightArc(rg, next_arc, node, end_weight);
- }
-
- /* update only if needed */
- if (arc->head->weight != start_weight || arc->tail->weight != end_weight)
- {
- old_weight = arc->head->weight; /* backup head weight, other arcs need it intact, it will be fixed by the source arc */
-
- arc->head->weight = start_weight;
- arc->tail->weight = end_weight;
-
- reweightBuckets(arc);
- resizeArcBuckets(arc);
- fillArcEmptyBuckets(arc);
-
- arc->head->weight = old_weight;
- }
-}
-
-static void reweightSubgraph(ReebGraph *rg, ReebNode *start_node, float start_weight)
-{
- int i;
-
- BLI_flagNodes((BGraph *)rg, 0);
-
- for (i = 0; i < start_node->degree; i++)
- {
- ReebArc *next_arc = start_node->arcs[i];
-
- reweightArc(rg, next_arc, start_node, start_weight);
- }
- start_node->weight = start_weight;
-}
-
-static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs)
-{
- int joined = 0;
- int subgraph;
-
- for (subgraph = 1; subgraph <= nb_subgraphs; subgraph++)
- {
- ReebNode *start_node, *end_node;
- ReebNode *min_node_start = NULL, *min_node_end = NULL;
- float min_distance = FLT_MAX;
-
- for (start_node = rg->nodes.first; start_node; start_node = start_node->next)
- {
- if (start_node->subgraph_index == subgraph && start_node->degree == 1)
- {
-
- for (end_node = rg->nodes.first; end_node; end_node = end_node->next)
- {
- if (end_node->subgraph_index != subgraph)
- {
- float distance = len_v3v3(start_node->p, end_node->p);
-
- if (distance < threshold && distance < min_distance)
- {
- min_distance = distance;
- min_node_end = end_node;
- min_node_start = start_node;
- }
- }
- }
- }
- }
-
- end_node = min_node_end;
- start_node = min_node_start;
-
- if (end_node && start_node)
- {
- ReebArc *start_arc /* , *end_arc */ /* UNUSED */;
- int merging = 0;
-
- start_arc = start_node->arcs[0];
- /* end_arc = end_node->arcs[0]; */ /* UNUSED */
-
- if (start_arc->tail == start_node)
- {
- reweightSubgraph(rg, end_node, start_node->weight);
-
- start_arc->tail = end_node;
-
- merging = 1;
- }
- else if (start_arc->head == start_node)
- {
- reweightSubgraph(rg, start_node, end_node->weight);
-
- start_arc->head = end_node;
-
- merging = 2;
- }
-
- if (merging)
- {
- BLI_ReflagSubgraph((BGraph *)rg, end_node->flag, subgraph);
-
- resizeArcBuckets(start_arc);
- fillArcEmptyBuckets(start_arc);
-
- NodeDegreeIncrement(rg, end_node);
- BLI_rebuildAdjacencyListForNode((BGraph *)rg, (BNode *)end_node);
-
- BLI_removeNode((BGraph *)rg, (BNode *)start_node);
- }
-
- joined = 1;
- }
- }
-
- return joined;
-}
-
-/* Reweight graph from smallest node, fix fliped arcs */
-static void fixSubgraphsOrientation(ReebGraph *rg, int nb_subgraphs)
-{
- int subgraph;
-
- for (subgraph = 1; subgraph <= nb_subgraphs; subgraph++)
- {
- ReebNode *node;
- ReebNode *start_node = NULL;
-
- for (node = rg->nodes.first; node; node = node->next)
- {
- if (node->subgraph_index == subgraph)
- {
- if (start_node == NULL || node->weight < start_node->weight)
- {
- start_node = node;
- }
- }
- }
-
- if (start_node)
- {
- reweightSubgraph(rg, start_node, start_node->weight);
- }
- }
-}
-
-static int joinSubgraphs(ReebGraph *rg, float threshold)
-{
- int nb_subgraphs;
- int joined = 0;
-
- BLI_buildAdjacencyList((BGraph *)rg);
-
- if (BLI_isGraphCyclic((BGraph *)rg)) {
- /* don't deal with cyclic graphs YET */
- return 0;
- }
-
- /* sort nodes before flagging subgraphs to make sure root node is subgraph 0 */
- sortNodes(rg);
-
- nb_subgraphs = BLI_FlagSubgraphs((BGraph *)rg);
-
- /* Harmonic function can create flipped arcs, take the occasion to fix them */
-// XXX
-// if (G.scene->toolsettings->skgen_options & SKGEN_HARMONIC)
-// {
- fixSubgraphsOrientation(rg, nb_subgraphs);
-// }
-
- if (nb_subgraphs > 1)
- {
- joined |= joinSubgraphsEnds(rg, threshold, nb_subgraphs);
-
- if (joined)
- {
- removeNormalNodes(rg);
- BLI_buildAdjacencyList((BGraph *)rg);
- }
- }
-
- return joined;
-}
-
-/****************************************** FILTERING **************************************************/
-
-static float lengthArc(ReebArc *arc)
-{
-#if 0
- ReebNode *head = (ReebNode *)arc->head;
- ReebNode *tail = (ReebNode *)arc->tail;
-
- return tail->weight - head->weight;
-#else
- return arc->length;
-#endif
-}
-
-static int compareArcs(void *varc1, void *varc2)
-{
- ReebArc *arc1 = (ReebArc *)varc1;
- ReebArc *arc2 = (ReebArc *)varc2;
- float len1 = lengthArc(arc1);
- float len2 = lengthArc(arc2);
-
- if (len1 < len2) {
- return -1;
- }
- if (len1 > len2) {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, ReebArc *srcArc, int merging)
-{
- ReebArc *arc = NULL, *nextArc = NULL;
-
- if (merging) {
- /* first pass, merge buckets for arcs that spawned the two nodes into the source arc*/
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- if (arc->head == srcArc->head && arc->tail == srcArc->tail && arc != srcArc) {
- ReebNode *head = srcArc->head;
- ReebNode *tail = srcArc->tail;
- mergeArcBuckets(srcArc, arc, head->weight, tail->weight);
- }
- }
- }
-
- /* second pass, replace removedNode by newNode, remove arcs that are collapsed in a loop */
- arc = rg->arcs.first;
- while (arc) {
- nextArc = arc->next;
-
- if (arc->head == removedNode || arc->tail == removedNode) {
- if (arc->head == removedNode) {
- arc->head = newNode;
- }
- else {
- arc->tail = newNode;
- }
-
- // Remove looped arcs
- if (arc->head == arc->tail) {
- // v1 or v2 was already newNode, since we're removing an arc, decrement degree
- NodeDegreeDecrement(rg, newNode);
-
- // If it's srcArc, it'll be removed later, so keep it for now
- if (arc != srcArc) {
- BLI_remlink(&rg->arcs, arc);
- REEB_freeArc((BArc *)arc);
- }
- }
- else {
- /* flip arcs that flipped, can happen on diamond shapes, mostly on null arcs */
- if (arc->head->weight > arc->tail->weight) {
- flipArc(arc);
- }
- //newNode->degree++; // incrementing degree since we're adding an arc
- NodeDegreeIncrement(rg, newNode);
- mergeArcFaces(rg, arc, srcArc);
-
- if (merging) {
- ReebNode *head = arc->head;
- ReebNode *tail = arc->tail;
-
- // resize bucket list
- resizeArcBuckets(arc);
- mergeArcBuckets(arc, srcArc, head->weight, tail->weight);
-
- /* update length */
- arc->length += srcArc->length;
- }
- }
- }
-
- arc = nextArc;
- }
-}
-
-void filterNullReebGraph(ReebGraph *rg)
-{
- ReebArc *arc = NULL, *nextArc = NULL;
-
- arc = rg->arcs.first;
- while (arc) {
- nextArc = arc->next;
- // Only collapse arcs too short to have any embed bucket
- if (arc->bcount == 0) {
- ReebNode *newNode = (ReebNode *)arc->head;
- ReebNode *removedNode = (ReebNode *)arc->tail;
- float blend;
-
- blend = (float)newNode->degree / (float)(newNode->degree + removedNode->degree); // blending factors
-
- interp_v3_v3v3(newNode->p, removedNode->p, newNode->p, blend);
-
- filterArc(rg, newNode, removedNode, arc, 0);
-
- // Reset nextArc, it might have changed
- nextArc = arc->next;
-
- BLI_remlink(&rg->arcs, arc);
- REEB_freeArc((BArc *)arc);
-
- BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
- }
-
- arc = nextArc;
- }
-}
-
-static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_internal, float threshold_external)
-{
- ReebArc *arc = NULL, *nextArc = NULL;
- int value = 0;
-
- BLI_listbase_sort(&rg->arcs, compareArcs);
-
- for (arc = rg->arcs.first; arc; arc = nextArc) {
- nextArc = arc->next;
-
- /* Only collapse non-terminal arcs that are shorter than threshold */
- if ((threshold_internal > 0) &&
- (arc->head->degree > 1) &&
- (arc->tail->degree > 1) &&
- (lengthArc(arc) < threshold_internal))
- {
- ReebNode *newNode = NULL;
- ReebNode *removedNode = NULL;
-
- /* Always remove lower node, so arcs don't flip */
- newNode = arc->head;
- removedNode = arc->tail;
-
- filterArc(rg, newNode, removedNode, arc, 1);
-
- // Reset nextArc, it might have changed
- nextArc = arc->next;
-
- BLI_remlink(&rg->arcs, arc);
- REEB_freeArc((BArc *)arc);
-
- BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
- value = 1;
- }
-
- // Only collapse terminal arcs that are shorter than threshold
- else if ((threshold_external > 0) &&
- (arc->head->degree == 1 || arc->tail->degree == 1) &&
- (lengthArc(arc) < threshold_external))
- {
- ReebNode *terminalNode = NULL;
- ReebNode *middleNode = NULL;
- ReebNode *removedNode = NULL;
-
- // Assign terminal and middle nodes
- if (arc->head->degree == 1) {
- terminalNode = arc->head;
- middleNode = arc->tail;
- }
- else {
- terminalNode = arc->tail;
- middleNode = arc->head;
- }
-
- if (middleNode->degree == 2 && middleNode != rg->nodes.first) {
-#if 1
- // If middle node is a normal node, it will be removed later
- // Only if middle node is not the root node
- /* USE THIS IF YOU WANT TO PROLONG ARCS TO THEIR TERMINAL NODES
- * FOR HANDS, THIS IS NOT THE BEST RESULT
- * */
- continue;
-#else
- removedNode = terminalNode;
-
- // removing arc, so we need to decrease the degree of the remaining node
- NodeDegreeDecrement(rg, middleNode);
-#endif
- }
- // Otherwise, just plain remove of the arc
- else {
- removedNode = terminalNode;
-
- // removing arc, so we need to decrease the degree of the remaining node
- NodeDegreeDecrement(rg, middleNode);
- }
-
- // Reset nextArc, it might have changed
- nextArc = arc->next;
-
- BLI_remlink(&rg->arcs, arc);
- REEB_freeArc((BArc *)arc);
-
- BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
- value = 1;
- }
- }
-
- return value;
-}
-
-static int filterCyclesReebGraph(ReebGraph *rg, float UNUSED(distance_threshold))
-{
- ReebArc *arc1, *arc2;
- ReebArc *next2;
- int filtered = 0;
-
- for (arc1 = rg->arcs.first; arc1; arc1 = arc1->next) {
- for (arc2 = arc1->next; arc2; arc2 = next2) {
- next2 = arc2->next;
- if (arc1 != arc2 && arc1->head == arc2->head && arc1->tail == arc2->tail) {
- mergeArcEdges(rg, arc1, arc2, MERGE_APPEND);
- mergeArcFaces(rg, arc1, arc2);
- mergeArcBuckets(arc1, arc2, arc1->head->weight, arc1->tail->weight);
-
- NodeDegreeDecrement(rg, arc1->head);
- NodeDegreeDecrement(rg, arc1->tail);
-
- BLI_remlink(&rg->arcs, arc2);
- REEB_freeArc((BArc *)arc2);
-
- filtered = 1;
- }
- }
- }
-
- return filtered;
-}
-
-int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
-{
- int value = 0;
-#if 0 //XXX
- ReebArc *arc = NULL, *nextArc = NULL;
-
- BLI_listbase_sort(&rg->arcs, compareArcs);
-
-#ifdef DEBUG_REEB
- {
- EditFace *efa;
- for (efa = G.editMesh->faces.first; efa; efa = efa->next) {
- efa->tmp.fp = -1;
- }
- }
-#endif
-
- arc = rg->arcs.first;
- while (arc)
- {
- nextArc = arc->next;
-
- /* need correct normals and center */
- recalc_editnormals();
-
- // Only test terminal arcs
- if (arc->head->degree == 1 || arc->tail->degree == 1)
- {
- GHashIterator ghi;
- int merging = 0;
- int total = BLI_ghash_len(arc->faces);
- float avg_angle = 0;
- float avg_vec[3] = {0, 0, 0};
-
- for (BLI_ghashIterator_init(&ghi, arc->faces);
- BLI_ghashIterator_done(&ghi) == false;
- BLI_ghashIterator_step(&ghi))
- {
- EditFace *efa = BLI_ghashIterator_getValue(&ghi);
-
-#if 0
- ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator *)&arc_iter;
- EmbedBucket *bucket = NULL;
- EmbedBucket *previous = NULL;
- float min_distance = -1;
- float angle = 0;
-
- initArcIterator(iter, arc, arc->head);
-
- bucket = nextBucket(iter);
-
- while (bucket != NULL)
- {
- float *vec0 = NULL;
- float *vec1 = bucket->p;
- float midpoint[3], tangent[3];
- float distance;
-
- /* first bucket. Previous is head */
- if (previous == NULL)
- {
- vec0 = arc->head->p;
- }
- /* Previous is a valid bucket */
- else {
- vec0 = previous->p;
- }
-
- copy_v3_v3(midpoint, vec1);
-
- distance = len_v3v3(midpoint, efa->cent);
-
- if (min_distance == -1 || distance < min_distance)
- {
- min_distance = distance;
-
- sub_v3_v3v3(tangent, vec1, vec0);
- normalize_v3(tangent);
-
- angle = dot_v3v3(tangent, efa->n);
- }
-
- previous = bucket;
- bucket = nextBucket(iter);
- }
-
- avg_angle += saacos(fabs(angle));
-#ifdef DEBUG_REEB
- efa->tmp.fp = saacos(fabs(angle));
-#endif
-#else
- add_v3_v3(avg_vec, efa->n);
-#endif
- }
-
-
-#if 0
- avg_angle /= total;
-#else
- mul_v3_fl(avg_vec, 1.0 / total);
- avg_angle = dot_v3v3(avg_vec, avg_vec);
-#endif
-
- arc->angle = avg_angle;
-
- if (avg_angle > threshold)
- merging = 1;
-
- if (merging) {
- ReebNode *terminalNode = NULL;
- ReebNode *middleNode = NULL;
- ReebNode *newNode = NULL;
- ReebNode *removedNode = NULL;
- int merging = 0;
-
- /* Assign terminal and middle nodes */
- if (arc->head->degree == 1) {
- terminalNode = arc->head;
- middleNode = arc->tail;
- }
- else {
- terminalNode = arc->tail;
- middleNode = arc->head;
- }
-
- /* If middle node is a normal node, merge to terminal node */
- if (middleNode->degree == 2) {
- merging = 1;
- newNode = terminalNode;
- removedNode = middleNode;
- }
- /* Otherwise, just plain remove of the arc */
- else {
- merging = 0;
- newNode = middleNode;
- removedNode = terminalNode;
- }
-
- /* Merging arc */
- if (merging) {
- filterArc(rg, newNode, removedNode, arc, 1);
- }
- else {
- /* removing arc, so we need to decrease the degree of the remaining node
- *newNode->degree--; */
- NodeDegreeDecrement(rg, newNode);
- }
-
- /* Reset nextArc, it might have changed */
- nextArc = arc->next;
-
- BLI_remlink(&rg->arcs, arc);
- REEB_freeArc((BArc *)arc);
-
- BLI_freelinkN(&rg->nodes, removedNode);
- value = 1;
- }
- }
-
- arc = nextArc;
- }
-
-#endif
-
- return value;
-}
-
-static void filterGraph(ReebGraph *rg, short options, float threshold_internal, float threshold_external)
-{
- bool done = true;
-
- calculateGraphLength(rg);
-
- if ((options & SKGEN_FILTER_EXTERNAL) == 0) {
- threshold_external = 0;
- }
-
- if ((options & SKGEN_FILTER_INTERNAL) == 0) {
- threshold_internal = 0;
- }
-
- if (threshold_internal > 0 || threshold_external > 0) {
- /* filter until there's nothing more to do */
- while (done == true) {
- done = false; /* no work done yet */
-
- done = filterInternalExternalReebGraph(rg, threshold_internal, threshold_external);
- }
- }
-
- if (options & SKGEN_FILTER_SMART) {
- filterSmartReebGraph(rg, 0.5);
- filterCyclesReebGraph(rg, 0.5);
- }
-
- repositionNodes(rg);
-
- /* Filtering might have created degree 2 nodes, so remove them */
- removeNormalNodes(rg);
-}
-
-static void finalizeGraph(ReebGraph *rg, char passes, char method)
-{
- int i;
-
- BLI_buildAdjacencyList((BGraph *)rg);
-
- sortNodes(rg);
-
- sortArcs(rg);
-
- for (i = 0; i < passes; i++) {
- postprocessGraph(rg, method);
- }
-
- extendGraphBuckets(rg);
-}
-
-/************************************** WEIGHT SPREADING ***********************************************/
-
-static int compareVerts(const void *a, const void *b)
-{
- EditVert *va = *(EditVert **)a;
- EditVert *vb = *(EditVert **)b;
- int value = 0;
-
- if (weightData(va) < weightData(vb)) {
- value = -1;
- }
- else if (weightData(va) > weightData(vb)) {
- value = 1;
- }
-
- return value;
-}
-
-static void spreadWeight(EditMesh *em)
-{
- EditVert **verts, *eve;
- float lastWeight = 0.0f;
- int totvert = BLI_listbase_count(&em->verts);
- int i;
- int work_needed = 1;
-
- verts = MEM_callocN(sizeof(EditVert *) * totvert, "verts array");
-
- for (eve = em->verts.first, i = 0; eve; eve = eve->next, i++) {
- verts[i] = eve;
- }
-
- while (work_needed == 1) {
- work_needed = 0;
- qsort(verts, totvert, sizeof(EditVert *), compareVerts);
-
- for (i = 0; i < totvert; i++) {
- eve = verts[i];
-
- if (i == 0 || (weightData(eve) - lastWeight) > FLT_EPSILON) {
- lastWeight = weightData(eve);
- }
- else {
- work_needed = 1;
- weightSetData(eve, lastWeight + FLT_EPSILON * 2);
- lastWeight = weightData(eve);
- }
- }
- }
-
- MEM_freeN(verts);
-}
-
-/******************************************** EXPORT ***************************************************/
-
-static void exportNode(FILE *f, const char *text, ReebNode *node)
-{
- fprintf(f, "%s i:%i w:%f d:%i %f %f %f\n", text, node->index, node->weight, node->degree, node->p[0], node->p[1], node->p[2]);
-}
-
-void REEB_exportGraph(ReebGraph *rg, int count)
-{
- ReebArc *arc;
- char filename[128];
- FILE *f;
-
- if (count == -1) {
- strcpy(filename, "test.txt");
- }
- else {
- sprintf(filename, "test%05i.txt", count);
- }
- f = BLI_fopen(filename, "w");
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- int i;
- float p[3];
-
- exportNode(f, "v1", arc->head);
-
- for (i = 0; i < arc->bcount; i++) {
- fprintf(f, "b nv:%i %f %f %f\n", arc->buckets[i].nv, arc->buckets[i].p[0], arc->buckets[i].p[1], arc->buckets[i].p[2]);
- }
-
- add_v3_v3v3(p, arc->tail->p, arc->head->p);
- mul_v3_fl(p, 0.5f);
-
- fprintf(f, "angle %0.3f %0.3f %0.3f %0.3f %i\n", p[0], p[1], p[2], arc->angle, BLI_ghash_len(arc->faces));
- exportNode(f, "v2", arc->tail);
- }
-
- fclose(f);
-}
-
-/***************************************** MAIN ALGORITHM **********************************************/
-
-/* edges alone will create zero degree nodes, use this function to remove them */
-static void removeZeroNodes(ReebGraph *rg)
-{
- ReebNode *node, *next_node;
-
- for (node = rg->nodes.first; node; node = next_node) {
- next_node = node->next;
-
- if (node->degree == 0) {
- BLI_removeNode((BGraph *)rg, (BNode *)node);
- }
- }
-}
-
-void removeNormalNodes(ReebGraph *rg)
-{
- ReebArc *arc, *nextArc;
-
- // Merge degree 2 nodes
- for (arc = rg->arcs.first; arc; arc = nextArc) {
- nextArc = arc->next;
-
- while (arc->head->degree == 2 || arc->tail->degree == 2) {
- // merge at v1
- if (arc->head->degree == 2) {
- ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->head);
-
- /* If arcs are one after the other */
- if (arc->head == connectedArc->tail) {
- /* remove furthest arc */
- if (arc->tail->weight < connectedArc->head->weight) {
- mergeConnectedArcs(rg, arc, connectedArc);
- nextArc = arc->next;
- }
- else {
- mergeConnectedArcs(rg, connectedArc, arc);
- break; /* arc was removed, move to next */
- }
- }
- /* Otherwise, arcs are side by side */
- else {
- /* Don't do anything, we need to keep the lowest node, even if degree 2 */
- break;
- }
- }
-
- /* merge at v2 */
- if (arc->tail->degree == 2) {
- ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->tail);
-
- /* If arcs are one after the other */
- if (arc->tail == connectedArc->head) {
- /* remove furthest arc */
- if (arc->head->weight < connectedArc->tail->weight) {
- mergeConnectedArcs(rg, arc, connectedArc);
- nextArc = arc->next;
- }
- else {
- mergeConnectedArcs(rg, connectedArc, arc);
- break; /* arc was removed, move to next */
- }
- }
- /* Otherwise, arcs are side by side */
- else {
- /* Don't do anything, we need to keep the lowest node, even if degree 2 */
- break;
- }
- }
- }
- }
-
-}
-
-static int edgeEquals(ReebEdge *e1, ReebEdge *e2)
-{
- return (e1->v1 == e2->v1 && e1->v2 == e2->v2);
-}
-
-static ReebArc *nextArcMappedToEdge(ReebArc *arc, ReebEdge *e)
-{
- ReebEdge *nextEdge = NULL;
- ReebEdge *edge = NULL;
- ReebArc *result = NULL;
-
- /* Find the ReebEdge in the edge list */
- for (edge = arc->edges.first; edge && !edgeEquals(edge, e); edge = edge->next) { }
-
- nextEdge = edge->nextEdge;
-
- if (nextEdge != NULL) {
- result = nextEdge->arc;
- }
-
- return result;
-}
-
-void addFacetoArc(ReebArc *arc, EditFace *efa)
-{
- BLI_ghash_insert(arc->faces, efa, efa);
-}
-
-void mergeArcFaces(ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc)
-{
- GHashIterator ghi;
-
- for (BLI_ghashIterator_init(&ghi, aSrc->faces);
- BLI_ghashIterator_done(&ghi) == false;
- BLI_ghashIterator_step(&ghi))
- {
- EditFace *efa = BLI_ghashIterator_getValue(&ghi);
- BLI_ghash_insert(aDst->faces, efa, efa);
- }
-}
-
-void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection direction)
-{
- ReebEdge *e = NULL;
-
- if (direction == MERGE_APPEND) {
- for (e = aSrc->edges.first; e; e = e->next) {
- e->arc = aDst; // Edge is stolen by new arc
- }
-
- BLI_movelisttolist(&aDst->edges, &aSrc->edges);
- }
- else {
- for (e = aSrc->edges.first; e; e = e->next) {
- ReebEdge *newEdge = copyEdge(e);
-
- newEdge->arc = aDst;
-
- BLI_addtail(&aDst->edges, newEdge);
-
- if (direction == MERGE_LOWER) {
- void **p = BLI_edgehash_lookup_p(rg->emap, e->v1->index, e->v2->index);
-
- newEdge->nextEdge = e;
-
- // if edge was the first in the list, point the edit edge to the new reeb edge instead.
- if (*p == e) {
- *p = (void *)newEdge;
- }
- // otherwise, advance in the list until the predecessor is found then insert it there
- else {
- ReebEdge *previous = (ReebEdge *)*p;
-
- while (previous->nextEdge != e) {
- previous = previous->nextEdge;
- }
-
- previous->nextEdge = newEdge;
- }
- }
- else {
- newEdge->nextEdge = e->nextEdge;
- e->nextEdge = newEdge;
- }
- }
- }
-}
-
-// return 1 on full merge
-int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
-{
- int result = 0;
- ReebNode *removedNode = NULL;
-
- a0->length += a1->length;
-
- mergeArcEdges(rg, a0, a1, MERGE_APPEND);
- mergeArcFaces(rg, a0, a1);
-
- // Bring a0 to the combine length of both arcs
- if (a0->tail == a1->head) {
- removedNode = a0->tail;
- a0->tail = a1->tail;
- }
- else if (a0->head == a1->tail) {
- removedNode = a0->head;
- a0->head = a1->head;
- }
-
- resizeArcBuckets(a0);
- // Merge a1 in a0
- mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight);
-
- // remove a1 from graph
- BLI_remlink(&rg->arcs, a1);
- REEB_freeArc((BArc *)a1);
-
- BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
- result = 1;
-
- return result;
-}
-// return 1 on full merge
-int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
-{
- int result = 0;
- /* TRIANGLE POINTS DOWN */
- if (a0->head->weight == a1->head->weight) { /* heads are the same */
- if (a0->tail->weight == a1->tail->weight) { /* tails also the same, arcs can be totally merge together */
- mergeArcEdges(rg, a0, a1, MERGE_APPEND);
- mergeArcFaces(rg, a0, a1);
-
- mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight);
-
- // Adjust node degree
- //a1->head->degree--;
- NodeDegreeDecrement(rg, a1->head);
- //a1->tail->degree--;
- NodeDegreeDecrement(rg, a1->tail);
-
- // remove a1 from graph
- BLI_remlink(&rg->arcs, a1);
-
- REEB_freeArc((BArc *)a1);
- result = 1;
- }
- else if (a0->tail->weight > a1->tail->weight) { /* a1->tail->weight is in the middle */
- mergeArcEdges(rg, a1, a0, MERGE_LOWER);
- mergeArcFaces(rg, a1, a0);
-
- // Adjust node degree
- //a0->head->degree--;
- NodeDegreeDecrement(rg, a0->head);
- //a1->tail->degree++;
- NodeDegreeIncrement(rg, a1->tail);
-
- mergeArcBuckets(a1, a0, a1->head->weight, a1->tail->weight);
- a0->head = a1->tail;
- resizeArcBuckets(a0);
- }
- else { /* a0>n2 is in the middle */
- mergeArcEdges(rg, a0, a1, MERGE_LOWER);
- mergeArcFaces(rg, a0, a1);
-
- // Adjust node degree
- //a1->head->degree--;
- NodeDegreeDecrement(rg, a1->head);
- //a0->tail->degree++;
- NodeDegreeIncrement(rg, a0->tail);
-
- mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight);
- a1->head = a0->tail;
- resizeArcBuckets(a1);
- }
- }
- /* TRIANGLE POINTS UP */
- else if (a0->tail->weight == a1->tail->weight) { /* tails are the same */
- if (a0->head->weight > a1->head->weight) { /* a0->head->weight is in the middle */
- mergeArcEdges(rg, a0, a1, MERGE_HIGHER);
- mergeArcFaces(rg, a0, a1);
-
- // Adjust node degree
- //a1->tail->degree--;
- NodeDegreeDecrement(rg, a1->tail);
- //a0->head->degree++;
- NodeDegreeIncrement(rg, a0->head);
-
- mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight);
- a1->tail = a0->head;
- resizeArcBuckets(a1);
- }
- else { /* a1->head->weight is in the middle */
- mergeArcEdges(rg, a1, a0, MERGE_HIGHER);
- mergeArcFaces(rg, a1, a0);
-
- // Adjust node degree
- //a0->tail->degree--;
- NodeDegreeDecrement(rg, a0->tail);
- //a1->head->degree++;
- NodeDegreeIncrement(rg, a1->head);
-
- mergeArcBuckets(a1, a0, a1->head->weight, a1->tail->weight);
- a0->tail = a1->head;
- resizeArcBuckets(a0);
- }
- }
- else {
- /* Need something here (OR NOT) */
- }
-
- return result;
-}
-
-static void glueByMergeSort(ReebGraph *rg, ReebArc *a0, ReebArc *a1, ReebEdge *e0, ReebEdge *e1)
-{
- int total = 0;
- while (total == 0 && a0 != a1 && a0 != NULL && a1 != NULL) {
- total = mergeArcs(rg, a0, a1);
-
- if (total == 0) // if it wasn't a total merge, go forward {
- if (a0->tail->weight < a1->tail->weight) {
- a0 = nextArcMappedToEdge(a0, e0);
- }
- else {
- a1 = nextArcMappedToEdge(a1, e1);
- }
- }
- }
-}
-
-static void mergePaths(ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2)
-{
- ReebArc *a0, *a1, *a2;
- a0 = e0->arc;
- a1 = e1->arc;
- a2 = e2->arc;
-
- glueByMergeSort(rg, a0, a1, e0, e1);
- glueByMergeSort(rg, a0, a2, e0, e2);
-}
-
-static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
-{
- ReebEdge *edge;
-
- edge = BLI_edgehash_lookup(rg->emap, node1->index, node2->index);
-
- // Only add existing edges that haven't been added yet
- if (edge == NULL) {
- ReebArc *arc;
- ReebNode *v1, *v2;
- float len, offset;
- int i;
-
- arc = MEM_callocN(sizeof(ReebArc), "reeb arc");
- edge = MEM_callocN(sizeof(ReebEdge), "reeb edge");
-
- arc->flag = 0; // clear flag on init
- arc->symmetry_level = 0;
- arc->faces = BLI_ghash_ptr_new("createArc gh");
-
- if (node1->weight <= node2->weight) {
- v1 = node1;
- v2 = node2;
- }
- else {
- v1 = node2;
- v2 = node1;
- }
-
- arc->head = v1;
- arc->tail = v2;
-
- // increase node degree
- //v1->degree++;
- NodeDegreeIncrement(rg, v1);
- //v2->degree++;
- NodeDegreeIncrement(rg, v2);
-
- BLI_edgehash_insert(rg->emap, node1->index, node2->index, edge);
-
- edge->arc = arc;
- edge->nextEdge = NULL;
- edge->v1 = v1;
- edge->v2 = v2;
-
- BLI_addtail(&rg->arcs, arc);
- BLI_addtail(&arc->edges, edge);
-
- /* adding buckets for embedding */
- allocArcBuckets(arc);
-
- offset = arc->head->weight;
- len = arc->tail->weight - arc->head->weight;
-
-#if 0
- /* This is the actual embedding filling described in the paper
- * the problem is that it only works with really dense meshes
- */
- if (arc->bcount > 0)
- {
- addVertToBucket(&(arc->buckets[0]), arc->head->co);
- addVertToBucket(&(arc->buckets[arc->bcount - 1]), arc->tail->co);
- }
-#else
- for (i = 0; i < arc->bcount; i++) {
- float co[3];
- float f = (arc->buckets[i].val - offset) / len;
-
- interp_v3_v3v3(co, v1->p, v2->p, f);
- addVertToBucket(&(arc->buckets[i]), co);
- }
-#endif
-
- }
-
- return edge;
-}
-
-static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNode *n3, EditFace *efa)
-{
- ReebEdge *re1, *re2, *re3;
- ReebEdge *e1, *e2, *e3;
- float len1, len2, len3;
-
- re1 = createArc(rg, n1, n2);
- re2 = createArc(rg, n2, n3);
- re3 = createArc(rg, n3, n1);
-
- addFacetoArc(re1->arc, efa);
- addFacetoArc(re2->arc, efa);
- addFacetoArc(re3->arc, efa);
-
- len1 = (float)fabs(n1->weight - n2->weight);
- len2 = (float)fabs(n2->weight - n3->weight);
- len3 = (float)fabs(n3->weight - n1->weight);
-
- /* The rest of the algorithm assumes that e1 is the longest edge */
-
- if (len1 >= len2 && len1 >= len3) {
- e1 = re1;
- e2 = re2;
- e3 = re3;
- }
- else if (len2 >= len1 && len2 >= len3) {
- e1 = re2;
- e2 = re1;
- e3 = re3;
- }
- else {
- e1 = re3;
- e2 = re2;
- e3 = re1;
- }
-
- /* And e2 is the lowest edge
- * If e3 is lower than e2, swap them
- */
- if (e3->v1->weight < e2->v1->weight) {
- ReebEdge *etmp = e2;
- e2 = e3;
- e3 = etmp;
- }
-
-
- mergePaths(rg, e1, e2, e3);
-}
-
-ReebGraph *generateReebGraph(EditMesh *em, int subdivisions)
-{
- ReebGraph *rg;
- EditVert *eve;
- EditFace *efa;
- int index;
- /*int totvert;*/
-
-#ifdef DEBUG_REEB
- int totfaces;
- int countfaces = 0;
-#endif
-
- rg = newReebGraph();
-
- rg->resolution = subdivisions;
-
- /*totvert = BLI_listbase_count(&em->verts);*/ /*UNUSED*/
-#ifdef DEBUG_REEB
- totfaces = BLI_listbase_count(&em->faces);
-#endif
-
- renormalizeWeight(em, 1.0f);
-
- /* Spread weight to minimize errors */
- spreadWeight(em);
-
- renormalizeWeight(em, (float)rg->resolution);
-
- /* Adding vertice */
- for (index = 0, eve = em->verts.first; eve; eve = eve->next) {
- if (eve->h == 0) {
- addNode(rg, eve);
- eve->f2 = 0;
- index++;
- }
- }
-
- /* Adding face, edge per edge */
- for (efa = em->faces.first; efa; efa = efa->next) {
- if (efa->h == 0) {
- ReebNode *n1, *n2, *n3;
-
- n1 = nodeData(efa->v1);
- n2 = nodeData(efa->v2);
- n3 = nodeData(efa->v3);
-
- addTriangleToGraph(rg, n1, n2, n3, efa);
-
- if (efa->v4) {
- ReebNode *n4 = nodeData(efa->v4);
- addTriangleToGraph(rg, n1, n3, n4, efa);
- }
-#ifdef DEBUG_REEB
- countfaces++;
- if (countfaces % 100 == 0) {
- printf("\rface %i of %i", countfaces, totfaces);
- }
-#endif
- }
- }
-
- printf("\n");
-
- removeZeroNodes(rg);
-
- removeNormalNodes(rg);
-
- return rg;
-}
-
-/***************************************** WEIGHT UTILS **********************************************/
-
-void renormalizeWeight(EditMesh *em, float newmax)
-{
- EditVert *eve;
- float minimum, maximum, range;
-
- if (em == NULL || BLI_listbase_is_empty(&em->verts))
- return;
-
- /* First pass, determine maximum and minimum */
- eve = em->verts.first;
- minimum = weightData(eve);
- maximum = minimum;
- for (; eve; eve = eve->next) {
- maximum = MAX2(maximum, weightData(eve));
- minimum = MIN2(minimum, weightData(eve));
- }
-
- range = maximum - minimum;
-
- /* Normalize weights */
- for (eve = em->verts.first; eve; eve = eve->next) {
- float weight = (weightData(eve) - minimum) / range * newmax;
- weightSetData(eve, weight);
- }
-}
-
-
-int weightFromLoc(EditMesh *em, int axis)
-{
- EditVert *eve;
-
- if (em == NULL || BLI_listbase_is_empty(&em->verts) || axis < 0 || axis > 2)
- return 0;
-
- /* Copy coordinate in weight */
- for (eve = em->verts.first; eve; eve = eve->next) {
- weightSetData(eve, eve->co[axis]);
- }
-
- return 1;
-}
-
-static void addTriangle(LinearSolver *context, EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2, int e3)
-{
- /* Angle opposite e1 */
- float t1 = cotangent_tri_weight_v3(v1->co, v2->co, v3->co) / e2;
-
- /* Angle opposite e2 */
- float t2 = cotangent_tri_weight_v3(v2->co, v3->co, v1->co) / e3;
-
- /* Angle opposite e3 */
- float t3 = cotangent_tri_weight_v3(v3->co, v1->co, v2->co) / e1;
-
- int i1 = indexData(v1);
- int i2 = indexData(v2);
- int i3 = indexData(v3);
-
- EIG_linear_solver_matrix_add(context, i1, i1, t2 + t3);
- EIG_linear_solver_matrix_add(context, i2, i2, t1 + t3);
- EIG_linear_solver_matrix_add(context, i3, i3, t1 + t2);
-
- EIG_linear_solver_matrix_add(context, i1, i2, -t3);
- EIG_linear_solver_matrix_add(context, i2, i1, -t3);
-
- EIG_linear_solver_matrix_add(context, i2, i3, -t1);
- EIG_linear_solver_matrix_add(context, i3, i2, -t1);
-
- EIG_linear_solver_matrix_add(context, i3, i1, -t2);
- EIG_linear_solver_matrix_add(context, i1, i3, -t2);
-}
-
-int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
-{
- LinearSolver *context;
- NLboolean success;
- EditVert *eve;
- EditEdge *eed;
- EditFace *efa;
- int totvert = 0;
- int index;
- int rval;
-
- /* Find local extrema */
- for (eve = em->verts.first; eve; eve = eve->next) {
- totvert++;
- }
-
- /* Solve */
-
- context = EIG_linear_solver_new(, 0, totvert, 1);
-
- /* Find local extrema */
- for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next) {
- if (eve->h == 0) {
- EditEdge *eed;
- int maximum = 1;
- int minimum = 1;
-
- NextEdgeForVert(indexed_edges, -1); /* Reset next edge */
- for (eed = NextEdgeForVert(indexed_edges, index); eed && (maximum || minimum); eed = NextEdgeForVert(indexed_edges, index)) {
- EditVert *eve2;
-
- if (eed->v1 == eve) {
- eve2 = eed->v2;
- }
- else {
- eve2 = eed->v1;
- }
-
- if (eve2->h == 0) {
- /* Adjacent vertex is bigger, not a local maximum */
- if (weightData(eve2) > weightData(eve)) {
- maximum = 0;
- }
- /* Adjacent vertex is smaller, not a local minimum */
- else if (weightData(eve2) < weightData(eve)) {
- minimum = 0;
- }
- }
- }
-
- if (maximum || minimum) {
- float w = weightData(eve);
- eve->f1 = 0;
- EIG_linear_solver_variable_set(context, 0, index, w);
- EIG_linear_solver_variable_lock(context, index);
- }
- else {
- eve->f1 = 1;
- }
- }
- }
-
- /* Zero edge weight */
- for (eed = em->edges.first; eed; eed = eed->next) {
- eed->tmp.l = 0;
- }
-
- /* Add faces count to the edge weight */
- for (efa = em->faces.first; efa; efa = efa->next) {
- if (efa->h == 0) {
- efa->e1->tmp.l++;
- efa->e2->tmp.l++;
- efa->e3->tmp.l++;
-
- if (efa->e4) {
- efa->e4->tmp.l++;
- }
- }
- }
-
- /* Add faces angle to the edge weight */
- for (efa = em->faces.first; efa; efa = efa->next) {
- if (efa->h == 0) {
- if (efa->v4 == NULL) {
- addTriangle(context, efa->v1, efa->v2, efa->v3, efa->e1->tmp.l, efa->e2->tmp.l, efa->e3->tmp.l);
- }
- else {
- addTriangle(context, efa->v1, efa->v2, efa->v3, efa->e1->tmp.l, efa->e2->tmp.l, 2);
- addTriangle(context, efa->v3, efa->v4, efa->v1, efa->e3->tmp.l, efa->e4->tmp.l, 2);
- }
- }
- }
-
- success = EIG_linear_solver_solve(context);
-
- if (success) {
- rval = 1;
- for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next) {
- weightSetData(eve, EIG_linear_solver_variable_get(context, 0, index));
- }
- }
- else {
- rval = 0;
- }
-
- EIG_linear_solver_delete(context);
-
- return rval;
-}
-
-
-EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index)
-{
- static int offset = -1;
-
- /* Reset method, call with NULL mesh pointer */
- if (index == -1) {
- offset = -1;
- return NULL;
- }
-
- /* first pass, start at the head of the list */
- if (offset == -1) {
- offset = indexed_edges->offset[index];
- }
- /* subsequent passes, start on the next edge */
- else {
- offset++;
- }
-
- return indexed_edges->edges[offset];
-}
-
-static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeIndex *indexed_edges)
-{
- Heap *edge_heap;
- EditVert *current_eve = NULL;
- EditEdge *eed = NULL;
- EditEdge *select_eed = NULL;
-
- edge_heap = BLI_heap_new();
-
- current_eve = starting_vert;
-
- /* insert guard in heap, when that is returned, no more edges */
- BLI_heap_insert(edge_heap, FLT_MAX, NULL);
-
- /* Initialize edge flag */
- for (eed = em->edges.first; eed; eed = eed->next) {
- eed->f1 = 0;
- }
-
- while (BLI_heap_len(edge_heap) > 0) {
- float current_weight;
-
- current_eve->f1 = 1; /* mark vertex as selected */
-
- /* Add all new edges connected to current_eve to the list */
- NextEdgeForVert(indexed_edges, -1); // Reset next edge
- for (eed = NextEdgeForVert(indexed_edges, indexData(current_eve)); eed; eed = NextEdgeForVert(indexed_edges, indexData(current_eve))) {
- if (eed->f1 == 0) {
- BLI_heap_insert(edge_heap, weightData(current_eve) + eed->tmp.fp, eed);
- eed->f1 = 1;
- }
- }
-
- /* Find next shortest edge with unselected verts */
- do {
- current_weight = BLI_heap_node_value(BLI_heap_top(edge_heap));
- select_eed = BLI_heap_pop_min(edge_heap);
- } while (select_eed != NULL && select_eed->v1->f1 != 0 && select_eed->v2->f1);
-
- if (select_eed != NULL) {
- select_eed->f1 = 2;
-
- if (select_eed->v1->f1 == 0) /* v1 is the new vertex */ {
- current_eve = select_eed->v1;
- }
- else { /* otherwise, it's v2 */
- current_eve = select_eed->v2;
- }
-
- weightSetData(current_eve, current_weight);
- }
- }
-
- BLI_heap_free(edge_heap, NULL);
-}
-
-static void freeEdgeIndex(EdgeIndex *indexed_edges)
-{
- MEM_freeN(indexed_edges->offset);
- MEM_freeN(indexed_edges->edges);
-}
-
-static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges)
-{
- EditVert *eve;
- EditEdge *eed;
- int totvert = 0;
- int tot_indexed = 0;
- int offset = 0;
-
- totvert = BLI_listbase_count(&em->verts);
-
- indexed_edges->offset = MEM_callocN(totvert * sizeof(int), "EdgeIndex offset");
-
- for (eed = em->edges.first; eed; eed = eed->next) {
- if (eed->v1->h == 0 && eed->v2->h == 0) {
- tot_indexed += 2;
- indexed_edges->offset[indexData(eed->v1)]++;
- indexed_edges->offset[indexData(eed->v2)]++;
- }
- }
-
- tot_indexed += totvert;
-
- indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge *), "EdgeIndex edges");
-
- /* setting vert offsets */
- for (eve = em->verts.first; eve; eve = eve->next) {
- if (eve->h == 0) {
- int d = indexed_edges->offset[indexData(eve)];
- indexed_edges->offset[indexData(eve)] = offset;
- offset += d + 1;
- }
- }
-
- /* adding edges in array */
- for (eed = em->edges.first; eed; eed = eed->next) {
- if (eed->v1->h == 0 && eed->v2->h == 0) {
- int i;
- for (i = indexed_edges->offset[indexData(eed->v1)]; i < tot_indexed; i++) {
- if (indexed_edges->edges[i] == NULL) {
- indexed_edges->edges[i] = eed;
- break;
- }
- }
-
- for (i = indexed_edges->offset[indexData(eed->v2)]; i < tot_indexed; i++) {
- if (indexed_edges->edges[i] == NULL) {
- indexed_edges->edges[i] = eed;
- break;
- }
- }
- }
- }
-}
-
-int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
-{
- EditVert *eve;
- int totedge = 0;
- int totvert = 0;
- int vCount = 0;
-
- totvert = BLI_listbase_count(&em->verts);
-
- if (em == NULL || totvert == 0) {
- return 0;
- }
-
- totedge = BLI_listbase_count(&em->edges);
-
- if (totedge == 0) {
- return 0;
- }
-
- /* Initialize vertice flag and find at least one selected vertex */
- for (eve = em->verts.first; eve; eve = eve->next) {
- eve->f1 = 0;
- if (eve->f & SELECT) {
- vCount = 1;
- }
- }
-
- if (vCount == 0) {
- return 0; /* no selected vert, failure */
- }
- else {
- EditEdge *eed;
- int allDone = 0;
-
- /* Calculate edge weight */
- for (eed = em->edges.first; eed; eed = eed->next) {
- if (eed->v1->h == 0 && eed->v2->h == 0) {
- eed->tmp.fp = len_v3v3(eed->v1->co, eed->v2->co);
- }
- }
-
- /* Apply dijkstra spf for each selected vert */
- for (eve = em->verts.first; eve; eve = eve->next) {
- if (eve->f & SELECT) {
- shortestPathsFromVert(em, eve, indexed_edges);
- }
- }
-
- /* connect unselected islands */
- while (allDone == 0) {
- EditVert *selected_eve = NULL;
- float selected_weight = 0;
- float min_distance = FLT_MAX;
-
- allDone = 1;
-
- for (eve = em->verts.first; eve; eve = eve->next) {
- /* for every vertex visible that hasn't been processed yet */
- if (eve->h == 0 && eve->f1 != 1) {
- EditVert *closest_eve;
-
- /* find the closest processed vertex */
- for (closest_eve = em->verts.first; closest_eve; closest_eve = closest_eve->next) {
- /* vertex is already processed and distance is smaller than current minimum */
- if (closest_eve->f1 == 1) {
- float distance = len_v3v3(closest_eve->co, eve->co);
- if (distance < min_distance) {
- min_distance = distance;
- selected_eve = eve;
- selected_weight = weightData(closest_eve);
- }
- }
- }
- }
- }
-
- if (selected_eve) {
- allDone = 0;
-
- weightSetData(selected_eve, selected_weight + min_distance);
- shortestPathsFromVert(em, selected_eve, indexed_edges);
- }
- }
- }
-
- for (eve = em->verts.first; eve && vCount == 0; eve = eve->next) {
- if (eve->f1 == 0) {
- printf("vertex not reached\n");
- break;
- }
- }
-
- return 1;
-}
-#endif
-
-/****************************************** BUCKET ITERATOR **************************************************/
-
-static void *headNode(void *arg);
-static void *tailNode(void *arg);
-static void *nextBucket(void *arg);
-static void *nextNBucket(void *arg, int n);
-static void *peekBucket(void *arg, int n);
-static void *previousBucket(void *arg);
-static int iteratorStopped(void *arg);
-
-static void initIteratorFct(ReebArcIterator *iter)
-{
- iter->head = headNode;
- iter->tail = tailNode;
- iter->peek = peekBucket;
- iter->next = nextBucket;
- iter->nextN = nextNBucket;
- iter->previous = previousBucket;
- iter->stopped = iteratorStopped;
-}
-
-static void setIteratorValues(ReebArcIterator *iter, EmbedBucket *bucket)
-{
- if (bucket) {
- iter->p = bucket->p;
- iter->no = bucket->no;
- }
- else {
- iter->p = NULL;
- iter->no = NULL;
- }
- iter->size = 0;
-}
-
-void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
-
- initIteratorFct(iter);
- iter->arc = arc;
-
- if (head == arc->head) {
- iter->start = 0;
- iter->end = arc->bcount - 1;
- iter->stride = 1;
- }
- else {
- iter->start = arc->bcount - 1;
- iter->end = 0;
- iter->stride = -1;
- }
-
- iter->length = arc->bcount;
-
- iter->index = -1;
-}
-
-void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNode *head, int start)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
-
- initIteratorFct(iter);
- iter->arc = arc;
-
- if (head == arc->head) {
- iter->start = start;
- iter->end = arc->bcount - 1;
- iter->stride = 1;
- }
- else {
- iter->start = arc->bcount - 1 - start;
- iter->end = 0;
- iter->stride = -1;
- }
-
- iter->index = -1;
-
- iter->length = arc->bcount - start;
-
- if (start >= arc->bcount) {
- iter->start = iter->end; /* stop iterator since it's past its end */
- }
-}
-
-void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
-
- initIteratorFct(iter);
- iter->arc = arc;
-
- iter->start = start;
- iter->end = end;
-
- if (end > start) {
- iter->stride = 1;
- }
- else {
- iter->stride = -1;
- }
-
- iter->index = -1;
-
- iter->length = abs(iter->end - iter->start) + 1;
-}
-
-static void *headNode(void *arg)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
- ReebNode *node;
-
- if (iter->start < iter->end) {
- node = iter->arc->head;
- }
- else {
- node = iter->arc->tail;
- }
-
- iter->p = node->p;
- iter->no = node->no;
- iter->size = 0;
-
- return node;
-}
-
-static void *tailNode(void *arg)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
- ReebNode *node;
-
- if (iter->start < iter->end) {
- node = iter->arc->tail;
- }
- else {
- node = iter->arc->head;
- }
-
- iter->p = node->p;
- iter->no = node->no;
- iter->size = 0;
-
- return node;
-}
-
-static void *nextBucket(void *arg)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
- EmbedBucket *result = NULL;
-
- iter->index++;
-
- if (iter->index < iter->length) {
- result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]);
- }
-
- setIteratorValues(iter, result);
- return result;
-}
-
-static void *nextNBucket(void *arg, int n)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
- EmbedBucket *result = NULL;
-
- iter->index += n;
-
- /* check if passed end */
- if (iter->index < iter->length) {
- result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]);
- }
-
- setIteratorValues(iter, result);
- return result;
-}
-
-static void *peekBucket(void *arg, int n)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
- EmbedBucket *result = NULL;
- int index = iter->index + n;
-
- /* check if passed end */
- if (index < iter->length) {
- result = &(iter->arc->buckets[iter->start + (iter->stride * index)]);
- }
-
- setIteratorValues(iter, result);
- return result;
-}
-
-static void *previousBucket(void *arg)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
- EmbedBucket *result = NULL;
-
- if (iter->index > 0) {
- iter->index--;
- result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]);
- }
-
- setIteratorValues(iter, result);
- return result;
-}
-
-static int iteratorStopped(void *arg)
-{
- ReebArcIterator *iter = (ReebArcIterator *)arg;
-
- if (iter->index >= iter->length) {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-/************************ PUBLIC FUNCTIONS *********************************************/
-
-ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
-{
- (void)C;
- return NULL;
-#if 0
- Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
- EditMesh *em = BKE_mesh_get_editmesh(((Mesh *)obedit->data));
- EdgeIndex indexed_edges;
- VertexData *data;
- ReebGraph *rg = NULL;
- ReebGraph *rgi, *previous;
- int i, nb_levels = REEB_MAX_MULTI_LEVEL;
-
- if (em == NULL)
- return NULL;
-
- data = allocVertexData(em);
-
- buildIndexedEdges(em, &indexed_edges);
-
- if (weightFromDistance(em, &indexed_edges) == 0)
- {
- // XXX error("No selected vertex\n");
- freeEdgeIndex(&indexed_edges);
- return NULL;
- }
-
- renormalizeWeight(em, 1.0f);
-
- if (scene->toolsettings->skgen_options & SKGEN_HARMONIC)
- {
- weightToHarmonic(em, &indexed_edges);
- }
-
- freeEdgeIndex(&indexed_edges);
-
- rg = generateReebGraph(em, scene->toolsettings->skgen_resolution);
-
- /* Remove arcs without embedding */
- filterNullReebGraph(rg);
-
- /* smart filter and loop filter on basic level */
- filterGraph(rg, SKGEN_FILTER_SMART, 0, 0);
-
- repositionNodes(rg);
-
- /* Filtering might have created degree 2 nodes, so remove them */
- removeNormalNodes(rg);
-
- joinSubgraphs(rg, 1.0);
-
- BLI_buildAdjacencyList((BGraph *)rg);
-
- /* calc length before copy, so we have same length on all levels */
- BLI_calcGraphLength((BGraph *)rg);
-
- previous = NULL;
- for (i = 0; i <= nb_levels; i++)
- {
- rgi = rg;
-
- /* don't filter last level */
- if (i > 0)
- {
- float internal_threshold;
- float external_threshold;
-
- /* filter internal progressively in second half only*/
- if (i > nb_levels / 2)
- {
- internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal;
- }
- else {
- internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal * (2 * i / (float)nb_levels);
- }
-
- external_threshold = rg->length * scene->toolsettings->skgen_threshold_external * (i / (float)nb_levels);
-
- filterGraph(rgi, scene->toolsettings->skgen_options, internal_threshold, external_threshold);
- }
-
- if (i < nb_levels)
- {
- rg = copyReebGraph(rgi, i + 1);
- }
-
- finalizeGraph(rgi, scene->toolsettings->skgen_postpro_passes, scene->toolsettings->skgen_postpro);
-
- BLI_markdownSymmetry((BGraph *)rgi, rgi->nodes.first, scene->toolsettings->skgen_symmetry_limit);
-
- if (previous != NULL)
- {
- relinkNodes(rgi, previous);
- }
- previous = rgi;
- }
-
- verifyMultiResolutionLinks(rg, 0);
-
- MEM_freeN(data);
-
- /* no need to load the editmesh back into the object, just
- * free it (avoids ngon conversion issues too going back the other way) */
- free_editMesh(em);
- MEM_freeN(em);
-
- return rg;
-#endif
-}
diff --git a/source/blender/editors/armature/reeb.h b/source/blender/editors/armature/reeb.h
deleted file mode 100644
index a6ef16fed67..00000000000
--- a/source/blender/editors/armature/reeb.h
+++ /dev/null
@@ -1,207 +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.
- *
- * Contributor(s): Martin Poirier
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/armature/reeb.h
- * \ingroup edarmature
- */
-
-
-#ifndef __REEB_H__
-#define __REEB_H__
-
-#define WITH_BF_REEB
-
-#include "DNA_listBase.h"
-
-#include "BLI_graph.h"
-
-struct GHash;
-struct EdgeHash;
-struct ReebArc;
-struct ReebEdge;
-struct ReebNode;
-
-typedef struct ReebGraph {
- ListBase arcs;
- ListBase nodes;
-
- float length;
-
- FreeArc free_arc;
- FreeNode free_node;
- RadialSymmetry radial_symmetry;
- AxialSymmetry axial_symmetry;
- /*********************************/
-
- int resolution;
- int totnodes;
- struct EdgeHash *emap;
- int multi_level;
- struct ReebGraph *link_up; /* for multi resolution filtering, points to higher levels */
-} ReebGraph;
-
-typedef struct EmbedBucket {
- float val;
- int nv;
- float p[3];
- float no[3]; /* if non-null, normal of the bucket */
-} EmbedBucket;
-
-typedef struct ReebNode {
- void *next, *prev;
- float p[3];
- int flag;
-
- int degree;
- struct ReebArc **arcs;
-
- int subgraph_index;
-
- int symmetry_level;
- int symmetry_flag;
- float symmetry_axis[3];
- /*********************************/
-
- float no[3];
-
- int index;
- float weight;
- int multi_level;
- struct ReebNode *link_down; /* for multi resolution filtering, points to lower levels, if present */
- struct ReebNode *link_up;
-} ReebNode;
-
-typedef struct ReebEdge {
- struct ReebEdge *next, *prev;
- struct ReebArc *arc;
- struct ReebNode *v1, *v2;
- struct ReebEdge *nextEdge;
- int flag;
-} ReebEdge;
-
-typedef struct ReebArc {
- void *next, *prev;
- struct ReebNode *head, *tail;
- int flag;
-
- float length;
-
- int symmetry_level;
- int symmetry_group;
- int symmetry_flag;
- /*********************************/
-
- ListBase edges;
- int bcount;
- struct EmbedBucket *buckets;
-
- struct GHash *faces;
- float angle;
- struct ReebArc *link_up; /* for multi resolution filtering, points to higher levels */
-} ReebArc;
-
-typedef struct ReebArcIterator {
- HeadFct head;
- TailFct tail;
- PeekFct peek;
- NextFct next;
- NextNFct nextN;
- PreviousFct previous;
- StoppedFct stopped;
-
- float *p, *no;
- float size;
-
- int length;
- int index;
- /*********************************/
- struct ReebArc *arc;
- int start;
- int end;
- int stride;
-} ReebArcIterator;
-
-#if 0
-struct EditMesh;
-struct EdgeIndex;
-
-int weightToHarmonic(struct EditMesh *em, struct EdgeIndex *indexed_edges);
-int weightFromDistance(struct EditMesh *em, struct EdgeIndex *indexed_edges);
-int weightFromLoc(struct EditMesh *me, int axis);
-//void weightToVCol(struct EditMesh *em, int index);
-void arcToVCol(struct ReebGraph *rg, struct EditMesh *em, int index);
-//void angleToVCol(struct EditMesh *em, int index);
-void renormalizeWeight(struct EditMesh *em, float newmax);
-
-ReebGraph *generateReebGraph(struct EditMesh *me, int subdivisions);
-#endif
-
-ReebGraph *newReebGraph(void);
-
-void initArcIterator(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head);
-void initArcIterator2(BArcIterator *iter, struct ReebArc *arc, int start, int end);
-void initArcIteratorStart(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head, int start);
-
-/* Filtering */
-void filterNullReebGraph(ReebGraph *rg);
-int filterSmartReebGraph(ReebGraph *rg, float threshold);
-
-/* Post-Build processing */
-void repositionNodes(ReebGraph *rg);
-void postprocessGraph(ReebGraph *rg, char mode);
-void removeNormalNodes(ReebGraph *rg);
-
-void sortNodes(ReebGraph *rg);
-void sortArcs(ReebGraph *rg);
-
-/*------------ Sanity check ------------*/
-void verifyBuckets(ReebGraph *rg);
-void verifyFaces(ReebGraph *rg);
-void verifyArcs(ReebGraph *rg);
-void verifyNodeDegree(ReebGraph *rg);
-
-/*********************** PUBLIC *********************************/
-
-#define REEB_MAX_MULTI_LEVEL 10
-
-struct bContext;
-
-ReebGraph *BIF_ReebGraphFromEditMesh(void);
-ReebGraph *BIF_ReebGraphMultiFromEditMesh(struct bContext *C);
-void BIF_flagMultiArcs(ReebGraph *rg, int flag);
-
-void BIF_GlobalReebGraphFromEditMesh(void);
-void BIF_GlobalReebFree(void);
-
-ReebNode *BIF_otherNodeFromIndex(ReebArc *arc, ReebNode *node);
-ReebNode *BIF_NodeFromIndex(ReebArc *arc, ReebNode *node);
-ReebNode *BIF_lowestLevelNode(ReebNode *node);
-
-ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node);
-
-void REEB_freeGraph(ReebGraph *rg);
-void REEB_freeArc(BArc *barc);
-void REEB_exportGraph(ReebGraph *rg, int count);
-void REEB_draw(void);
-
-
-#endif /*__REEB_H__*/
diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt
index 85daa7e44e5..301d333ebdb 100644
--- a/source/blender/editors/curve/CMakeLists.txt
+++ b/source/blender/editors/curve/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
+ ../../../../intern/clog
../../../../intern/guardedalloc
../../../../intern/glew-mx
../../../../extern/curve_fit_nd
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 3ea8592ac3e..5cfdec4d5ad 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -5013,7 +5013,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const float mval[2] = {UNPACK2(event->mval)};
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), vc.scene, vc.view_layer, 0, vc.ar, vc.v3d);
+ CTX_data_main(C), vc.scene, CTX_data_depsgraph(C), 0, vc.ar, vc.v3d);
ED_transform_snap_object_project_view3d_mixed(
snap_context,
@@ -6237,17 +6237,15 @@ static int match_texture_space_poll(bContext *C)
static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *object = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
Curve *curve = (Curve *) object->data;
float min[3], max[3], size[3], loc[3];
int a;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (object->curve_cache == NULL) {
- BKE_displist_make_curveTypes(&eval_ctx, scene, object, false);
+ BKE_displist_make_curveTypes(depsgraph, scene, object, false);
}
INIT_MINMAX(min, max);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 36eb4c6c5bc..056e8a2668c 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -93,7 +93,7 @@ struct StrokeElem {
};
struct CurveDrawData {
- const Depsgraph *depsgraph;
+ Depsgraph *depsgraph;
short init_event_type;
short curve_type;
@@ -1095,13 +1095,10 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if ((cps->depth_mode == CURVE_PAINT_PROJECT_SURFACE) &&
(v3d->drawtype > OB_WIRE))
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* needed or else the draw matrix can be incorrect */
view3d_operator_needs_opengl(C);
- ED_view3d_autodist_init(&eval_ctx, cdd->vc.depsgraph, cdd->vc.ar, cdd->vc.v3d, 0);
+ ED_view3d_autodist_init(cdd->vc.depsgraph, cdd->vc.ar, cdd->vc.v3d, 0);
if (cdd->vc.rv3d->depths) {
cdd->vc.rv3d->depths->damaged = true;
diff --git a/source/blender/editors/curve/editcurve_undo.c b/source/blender/editors/curve/editcurve_undo.c
index 4eb2abaefad..ad17331853b 100644
--- a/source/blender/editors/curve/editcurve_undo.c
+++ b/source/blender/editors/curve/editcurve_undo.c
@@ -22,12 +22,14 @@
* \ingroup edcurve
*/
+#include "MEM_guardedalloc.h"
+
+#include "CLG_log.h"
+
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_anim_types.h"
-#include "MEM_guardedalloc.h"
-
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_array_utils.h"
@@ -35,6 +37,7 @@
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
+#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_animsys.h"
#include "BKE_undo_system.h"
@@ -42,6 +45,7 @@
#include "DEG_depsgraph.h"
#include "ED_object.h"
+#include "ED_undo.h"
#include "ED_util.h"
#include "ED_curve.h"
@@ -50,6 +54,9 @@
#include "curve_intern.h"
+/** We only need this locally. */
+static CLG_LogRef LOG = {"ed.undo.curve"};
+
/* -------------------------------------------------------------------- */
/** \name Undo Conversion
* \{ */
@@ -187,13 +194,19 @@ static Object *editcurve_object_from_context(bContext *C)
/* -------------------------------------------------------------------- */
/** \name Implements ED Undo System
+ *
+ * \note This is similar for all edit-mode types.
* \{ */
-typedef struct CurveUndoStep {
- UndoStep step;
- /* note: will split out into list for multi-object-editmode. */
+typedef struct CurveUndoStep_Elem {
UndoRefID_Object obedit_ref;
UndoCurve data;
+} CurveUndoStep_Elem;
+
+typedef struct CurveUndoStep {
+ UndoStep step;
+ CurveUndoStep_Elem *elems;
+ uint elems_len;
} CurveUndoStep;
static bool curve_undosys_poll(bContext *C)
@@ -205,9 +218,23 @@ static bool curve_undosys_poll(bContext *C)
static bool curve_undosys_step_encode(struct bContext *C, UndoStep *us_p)
{
CurveUndoStep *us = (CurveUndoStep *)us_p;
- us->obedit_ref.ptr = editcurve_object_from_context(C);
- undocurve_from_editcurve(&us->data, us->obedit_ref.ptr->data, us->obedit_ref.ptr->shapenr);
- us->step.data_size = us->data.undo_size;
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
+ us->elems_len = objects_len;
+
+ for (uint i = 0; i < objects_len; i++) {
+ Object *ob = objects[i];
+ CurveUndoStep_Elem *elem = &us->elems[i];
+
+ elem->obedit_ref.ptr = ob;
+ undocurve_from_editcurve(&elem->data, ob->data, ob->shapenr);
+ us->step.data_size += elem->data.undo_size;
+ }
+ MEM_freeN(objects);
return true;
}
@@ -218,23 +245,47 @@ static void curve_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UN
BLI_assert(curve_undosys_poll(C));
CurveUndoStep *us = (CurveUndoStep *)us_p;
- Object *obedit = us->obedit_ref.ptr;
- undocurve_to_editcurve(&us->data, obedit->data, &obedit->shapenr);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ CurveUndoStep_Elem *elem = &us->elems[i];
+ Object *obedit = elem->obedit_ref.ptr;
+ Curve *cu = obedit->data;
+ if (cu->editnurb == NULL) {
+ /* Should never fail, may not crash but can give odd behavior. */
+ CLOG_ERROR(&LOG, "name='%s', failed to enter edit-mode for object '%s', undo state invalid",
+ us_p->name, obedit->id.name);
+ continue;
+ }
+ undocurve_to_editcurve(&elem->data, obedit->data, &obedit->shapenr);
+ DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ }
+
+ /* The first element is always active */
+ ED_undo_object_set_active_or_warn(CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
}
static void curve_undosys_step_free(UndoStep *us_p)
{
CurveUndoStep *us = (CurveUndoStep *)us_p;
- undocurve_free_data(&us->data);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ CurveUndoStep_Elem *elem = &us->elems[i];
+ undocurve_free_data(&elem->data);
+ }
+ MEM_freeN(us->elems);
}
static void curve_undosys_foreach_ID_ref(
UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
{
CurveUndoStep *us = (CurveUndoStep *)us_p;
- foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->obedit_ref));
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ CurveUndoStep_Elem *elem = &us->elems[i];
+ foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));
+ }
}
/* Export for ED_undo_sys. */
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index b72ac8c63c8..a9a8901acc6 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -422,9 +422,9 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
static void txt_add_object(bContext *C, TextLine *firstline, int totline, const float offset[3])
{
Main *bmain = CTX_data_main(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- EvaluationContext eval_ctx;
Curve *cu;
Object *obedit;
Base *base;
@@ -434,15 +434,13 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
int a;
float rot[3] = {0.f, 0.f, 0.f};
- CTX_data_eval_ctx(C, &eval_ctx);
-
obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, NULL);
base = view_layer->basact;
/* seems to assume view align ? TODO - look into this, could be an operator option */
ED_object_base_init_transform(C, base, NULL, rot);
- BKE_object_where_is_calc(&eval_ctx, scene, obedit);
+ BKE_object_where_is_calc(depsgraph, scene, obedit);
add_v3_v3(obedit->loc, offset);
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 942aa861cec..50a6e9125a0 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1672,7 +1672,7 @@ void ED_gpencil_draw_view2d(const bContext *C, bool onlyv2d)
void ED_gpencil_draw_view3d(wmWindowManager *wm,
Scene *scene,
ViewLayer *view_layer,
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
View3D *v3d,
ARegion *ar,
bool only3d)
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 2c3c9f4f9b9..19663b66f92 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1450,7 +1450,7 @@ static void gp_convert_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call */
- uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
void GPENCIL_OT_convert(wmOperatorType *ot)
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 1eee774fd3e..4f9abff292a 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2109,12 +2109,9 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
/* init autodist for geometry projection */
if (mode == GP_REPROJECT_SURFACE) {
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
struct Depsgraph *graph = CTX_data_depsgraph(C);
view3d_region_operator_needs_opengl(CTX_wm_window(C), gsc.ar);
- ED_view3d_autodist_init(&eval_ctx, graph, gsc.ar, CTX_wm_view3d(C), 0);
+ ED_view3d_autodist_init(graph, gsc.ar, CTX_wm_view3d(C), 0);
}
// TODO: For deforming geometry workflow, create new frames?
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 77e5dc8fe5d..ccd47463a9c 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -115,7 +115,6 @@ typedef enum eGPencil_PaintFlags {
* "p" = op->customdata
*/
typedef struct tGPsdata {
- EvaluationContext eval_ctx;
Scene *scene; /* current scene from context */
struct Depsgraph *graph;
@@ -646,7 +645,7 @@ static short gp_stroke_addpoint(
view3d_region_operator_needs_opengl(p->win, p->ar);
ED_view3d_autodist_init(
- &p->eval_ctx, p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+ p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
}
/* convert screen-coordinates to appropriate coordinates (and store them) */
@@ -680,7 +679,7 @@ static short gp_stroke_addpoint(
/* simplify a stroke (in buffer) before storing it
* - applies a reverse Chaikin filter
- * - code adapted from etch-a-ton branch (editarmature_sketch.c)
+ * - code adapted from etch-a-ton branch
*/
static void gp_stroke_simplify(tGPsdata *p)
{
@@ -1247,7 +1246,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) {
View3D *v3d = p->sa->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->ar);
- ED_view3d_autodist_init(&p->eval_ctx, p->graph, p->ar, v3d, 0);
+ ED_view3d_autodist_init(p->graph, p->ar, v3d, 0);
}
}
@@ -1400,7 +1399,6 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
}
/* pass on current scene and window */
- CTX_data_eval_ctx(C, &p->eval_ctx);
p->scene = CTX_data_scene(C);
p->graph = CTX_data_depsgraph(C);
p->win = CTX_wm_window(C);
@@ -1608,7 +1606,7 @@ static void gp_session_cleanup(tGPsdata *p)
}
/* init new stroke */
-static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, const Depsgraph *depsgraph)
+static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Depsgraph *depsgraph)
{
Scene *scene = p->scene;
ToolSettings *ts = scene->toolsettings;
@@ -1815,7 +1813,7 @@ static void gp_paint_strokeend(tGPsdata *p)
/* need to restore the original projection settings before packing up */
view3d_region_operator_needs_opengl(p->win, p->ar);
- ED_view3d_autodist_init(&p->eval_ctx, p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+ ED_view3d_autodist_init(p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
}
/* check if doing eraser or not */
@@ -2055,7 +2053,7 @@ static void gpencil_draw_status_indicators(tGPsdata *p)
/* ------------------------------- */
/* create a new stroke point at the point indicated by the painting context */
-static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, const Depsgraph *depsgraph)
+static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgraph)
{
/* handle drawing/erasing -> test for erasing first */
if (p->paintmode == GP_PAINTMODE_ERASER) {
@@ -2110,7 +2108,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, const Depsgraph *dep
}
/* handle draw event */
-static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, const Depsgraph *depsgraph)
+static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, Depsgraph *depsgraph)
{
tGPsdata *p = op->customdata;
PointerRNA itemptr;
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 94689fb59fa..d7e5b5a92aa 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -542,14 +542,11 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
View3D *v3d = (View3D *)CTX_wm_space_data(C);
RegionView3D *rv3d = ar->regiondata;
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* init 3d depth buffers */
view3d_operator_needs_opengl(C);
view3d_region_operator_needs_opengl(win, ar);
- ED_view3d_autodist_init(&eval_ctx, graph, ar, v3d, 0);
+ ED_view3d_autodist_init(graph, ar, v3d, 0);
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index db141a2ee29..888e9e04636 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -102,7 +102,8 @@ typedef enum eAnimCont_Types {
ANIMCONT_DRIVERS = 6, /* drivers (bDopesheet) */
ANIMCONT_NLA = 7, /* nla (bDopesheet) */
ANIMCONT_CHANNEL = 8, /* animation channel (bAnimListElem) */
- ANIMCONT_MASK = 9 /* mask dopesheet */
+ ANIMCONT_MASK = 9, /* mask dopesheet */
+ ANIMCONT_TIMELINE = 10, /* "timeline" editor (bDopeSheet) */
} eAnimCont_Types;
/* --------------- Channels -------------------- */
@@ -550,6 +551,12 @@ void ANIM_draw_cfra(const struct bContext *C, struct View2D *v2d, short flag);
/* main call to draw preview range curtains */
void ANIM_draw_previewrange(const struct bContext *C, struct View2D *v2d, int end_frame_width);
+
+/* -------------- Frame Range Drawing --------------- */
+
+/* main call to draw normal frame range indicators */
+void ANIM_draw_framerange(struct Scene *scene, struct View2D *v2d);
+
/* ************************************************* */
/* F-MODIFIER TOOLS */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 0dcc4f32e43..8b5886d65f1 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -39,7 +39,7 @@ struct Base;
struct bContext;
struct Bone;
struct bPoseChannel;
-struct EvaluationContext;
+struct Depsgraph;
struct IDProperty;
struct ListBase;
struct MeshDeformModifierData;
@@ -139,29 +139,40 @@ void ED_armature_from_edit(struct bArmature *arm);
void ED_armature_to_edit(struct bArmature *arm);
void ED_armature_edit_free(struct bArmature *arm);
-void ED_armature_deselect_all(struct Object *obedit);
-void ED_armature_deselect_all_visible(struct Object *obedit);
+void ED_armature_edit_deselect_all(struct Object *obedit);
+void ED_armature_edit_deselect_all_visible(struct Object *obedit);
-bool ED_do_pose_selectbuffer(
+void ED_armature_edit_deselect_all_multi(struct Object **objects, uint objects_len);
+void ED_armature_edit_deselect_all_visible_multi(struct Object **objects, uint objects_len);
+
+bool ED_armature_pose_select_pick_with_buffer(
struct ViewLayer *view_layer, struct Base *base, const unsigned int *buffer, short hits,
bool extend, bool deselect, bool toggle, bool do_nearest);
-bool ED_armature_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
+bool ED_armature_edit_select_pick(
+ struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
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 bool axis_only);
-EditBone *ED_armature_bone_find_name(const struct 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);
+float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float new_up_axis[3], const bool axis_only);
+EditBone *ED_armature_ebone_find_name(const struct ListBase *edbo, const char *name);
+EditBone *ED_armature_ebone_get_mirrored(const struct ListBase *edbo, EditBone *ebo);
+void ED_armature_edit_sync_selection(struct ListBase *edbo);
+void ED_armature_edit_validate_active(struct bArmature *arm);
+
+struct Base *ED_armature_base_and_ebone_from_select_buffer(
+ struct Base **bases, uint bases_len, int hit, struct EditBone **r_ebone);
+struct Object *ED_armature_object_and_ebone_from_select_buffer(
+ struct Object **objects, uint objects_len, int hit, struct EditBone **r_ebone);
+
+struct Base *ED_armature_base_and_bone_from_select_buffer(
+ struct Base **bases, uint bases_len, int hit, struct Bone **r_bone);
-EditBone *ED_armature_edit_bone_add_primitive(struct Object *obedit_arm, float length, bool view_aligned);
-EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name);
+EditBone *ED_armature_ebone_add_primitive(struct Object *obedit_arm, float length, bool view_aligned);
+EditBone *ED_armature_ebone_add(struct bArmature *arm, const char *name);
-void ED_armature_edit_bone_remove_ex(struct bArmature *arm, EditBone *exBone, bool clear_connected);
-void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
+void ED_armature_ebone_remove_ex(struct bArmature *arm, EditBone *exBone, bool clear_connected);
+void ED_armature_ebone_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);
+EditBone *ED_armature_ebone_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]);
@@ -169,23 +180,23 @@ void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]);
void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]);
void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]);
-void transform_armature_mirror_update(struct Object *obedit);
+void ED_armature_edit_transform_mirror_update(struct Object *obedit);
void ED_armature_origin_set(struct Object *ob, float cursor[3], int centermode, int around);
void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props);
-void ED_armature_apply_transform(struct Object *ob, float mat[4][4], const bool do_props);
+void ED_armature_transform_apply(struct Object *ob, float mat[4][4], const bool do_props);
void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props);
#define ARM_GROUPS_NAME 1
#define ARM_GROUPS_ENVELOPE 2
#define ARM_GROUPS_AUTO 3
-void create_vgroups_from_armature(
- struct ReportList *reports, const struct EvaluationContext *eval_ctx, struct Scene *scene,
+void ED_object_vgroup_calc_from_armature(
+ struct ReportList *reports, struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, struct Object *par, const int mode, const bool mirror);
/* if bone is already in list, pass it as param to ignore it */
-void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone);
+void ED_armature_ebone_unique_name(struct ListBase *ebones, char *name, EditBone *bone);
void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep);
void ED_armature_bones_flip_names(struct bArmature *arm, struct ListBase *bones_names, const bool do_strip_numbers);
@@ -209,37 +220,19 @@ bool ED_object_posemode_exit_ex(struct Main *bmain, struct Object *ob);
bool ED_object_posemode_exit(struct bContext *C, struct Object *ob);
bool ED_object_posemode_enter_ex(struct Main *bmain, struct Object *ob);
bool ED_object_posemode_enter(struct bContext *C, struct Object *ob);
-void ED_pose_de_selectall(struct Object *ob, int select_mode, const bool ignore_visibility);
+void ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility);
+void ED_pose_deselect_all_multi(struct Object **objects, uint objects_len, int select_mode, const bool ignore_visibility);
void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
void ED_pose_recalculate_paths(struct bContext *C, struct Scene *scene, struct Object *ob);
struct Object *ED_pose_object_from_context(struct bContext *C);
-/* sketch */
-
-int ED_operator_sketch_mode_active_stroke(struct bContext *C);
-int ED_operator_sketch_full_mode(struct bContext *C);
-int ED_operator_sketch_mode(const struct bContext *C);
-
-void BIF_convertSketch(struct bContext *C);
-void BIF_deleteSketch(struct bContext *C);
-void BIF_selectAllSketch(struct bContext *C, int mode); /* -1: deselect, 0: select, 1: toggle */
-
-void BIF_makeListTemplates(const struct bContext *C);
-int BIF_currentTemplate(const struct bContext *C);
-void BIF_freeTemplates(struct bContext *C);
-void BIF_setTemplate(struct bContext *C, int index);
-int BIF_nbJointsTemplate(const struct bContext *C);
-const char *BIF_nameBoneTemplate(const struct bContext *C);
-
-void BDR_drawSketch(const struct bContext *vc);
-int BDR_drawSketchNames(struct ViewContext *vc);
-
/* meshlaplacian.c */
-void mesh_deform_bind(struct Scene *scene,
- struct MeshDeformModifierData *mmd,
- struct DerivedMesh *cagedm,
- float *vertexcos, int totvert, float cagemat[4][4]);
-
+void ED_mesh_deform_bind_callback(
+ struct Scene *scene,
+ struct MeshDeformModifierData *mmd,
+ struct DerivedMesh *cagedm,
+ float *vertexcos, int totvert, float cagemat[4][4]);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/editors/include/ED_buttons.h b/source/blender/editors/include/ED_buttons.h
index 64c16605dec..5cc695b6ce8 100644
--- a/source/blender/editors/include/ED_buttons.h
+++ b/source/blender/editors/include/ED_buttons.h
@@ -27,14 +27,4 @@
#ifndef __ED_BUTTONS_H__
#define __ED_BUTTONS_H__
-#include "BLI_utildefines.h"
-
-/* Used to check whether a given texture context is valid in current context. */
-bool ED_texture_context_check_world(const struct bContext *C);
-bool ED_texture_context_check_material(const struct bContext *C);
-bool ED_texture_context_check_lamp(const struct bContext *C);
-bool ED_texture_context_check_particles(const struct bContext *C);
-bool ED_texture_context_check_linestyle(const struct bContext *C);
-bool ED_texture_context_check_others(const struct bContext *C);
-
#endif /* __ED_BUTTONS_H__ */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 3ea754b242c..57ca1f04c0a 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -153,7 +153,7 @@ void ED_gpencil_draw_view2d(const struct bContext *C, bool onlyv2d);
void ED_gpencil_draw_view3d(struct wmWindowManager *wm,
struct Scene *scene,
struct ViewLayer *view_layer,
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
struct View3D *v3d,
struct ARegion *ar,
bool only3d);
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 4279e3d202c..4e3c92f0dc4 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -54,6 +54,7 @@ struct PointerRNA;
struct PropertyRNA;
struct EnumPropertyItem;
+#include "DNA_anim_types.h"
#include "RNA_types.h"
/* ************ Keyframing Management **************** */
@@ -91,14 +92,14 @@ void update_autoflags_fcurve(struct FCurve *fcu, struct bContext *C, struct Repo
* Use this when validation of necessary animation data isn't necessary as it already
* exists, and there is a beztriple that can be directly copied into the array.
*/
-int insert_bezt_fcurve(struct FCurve *fcu, const struct BezTriple *bezt, short flag);
+int insert_bezt_fcurve(struct FCurve *fcu, const struct BezTriple *bezt, eInsertKeyFlags flag);
/* Main Keyframing API call:
* Use this when validation of necessary animation data isn't necessary as it
* already exists. It will insert a keyframe using the current value being keyframed.
* Returns the index at which a keyframe was added (or -1 if failed)
*/
-int insert_vert_fcurve(struct FCurve *fcu, float x, float y, char keytype, short flag);
+int insert_vert_fcurve(struct FCurve *fcu, float x, float y, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
/* -------- */
@@ -106,7 +107,7 @@ int insert_vert_fcurve(struct FCurve *fcu, float x, float y, char keytype, short
* Use this to insert a keyframe using the current value being keyframed, in the
* nominated F-Curve (no creation of animation data performed). Returns success.
*/
-bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, char keytype, short flag);
+bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
/* -------- */
@@ -114,12 +115,12 @@ bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, s
* Use this to create any necessary animation data, and then insert a keyframe
* using the current value being keyframed, in the relevant place. Returns success.
*/
-short insert_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, char keytype, short flag);
+short insert_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
/* Main Keyframing API call:
* Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case.
*/
-short delete_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag);
+short delete_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eInsertKeyFlags flag);
/* ************ Keying Sets ********************** */
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 3217433204e..787cf7f0524 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -126,7 +126,7 @@ void EDBM_flag_enable_all(struct BMEditMesh *em, const char hflag);
void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag);
bool BMBVH_EdgeVisible(struct BMBVHTree *tree, struct BMEdge *e,
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
struct ARegion *ar, struct View3D *v3d, struct Object *obedit);
/* editmesh_undo.c */
@@ -138,36 +138,36 @@ void EDBM_select_mirrored(
int *r_totmirr, int *r_totfail);
void EDBM_automerge(struct Scene *scene, struct Object *ob, bool update, const char hflag);
-bool EDBM_backbuf_border_init(const struct EvaluationContext *eval_ctx, struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
+bool EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
bool EDBM_backbuf_check(unsigned int index);
void EDBM_backbuf_free(void);
bool EDBM_backbuf_border_mask_init(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, const int mcords[][2], short tot,
+ struct ViewContext *vc, const int mcords[][2], short tot,
short xmin, short ymin, short xmax, short ymax);
-bool EDBM_backbuf_circle_init(const struct EvaluationContext *eval_ctx, struct ViewContext *vc, short xs, short ys, short rads);
+bool EDBM_backbuf_circle_init(struct ViewContext *vc, short xs, short ys, short rads);
struct BMVert *EDBM_vert_find_nearest_ex(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist,
+ struct ViewContext *vc, float *r_dist,
const bool use_select_bias, bool use_cycle);
struct BMVert *EDBM_vert_find_nearest(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist);
+ struct ViewContext *vc, float *r_dist);
struct BMEdge *EDBM_edge_find_nearest_ex(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist,
+ struct ViewContext *vc, float *r_dist,
float *r_dist_center,
const bool use_select_bias, const bool use_cycle,
struct BMEdge **r_eed_zbuf);
struct BMEdge *EDBM_edge_find_nearest(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist);
+ struct ViewContext *vc, float *r_dist);
struct BMFace *EDBM_face_find_nearest_ex(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist,
+ struct ViewContext *vc, float *r_dist,
float *r_dist_center,
const bool use_select_bias, const bool use_cycle,
struct BMFace **r_efa_zbuf);
struct BMFace *EDBM_face_find_nearest(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, float *r_dist);
+ struct ViewContext *vc, float *r_dist);
bool EDBM_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
@@ -204,7 +204,7 @@ void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd
/* editface.c */
void paintface_flush_flags(struct Object *ob, short flag);
bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle);
-int do_paintface_box_select(const struct EvaluationContext *eval_ctx, struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
+int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend);
void paintface_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], const bool select);
bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]);
@@ -340,6 +340,9 @@ struct MDeformVert *ED_mesh_active_dvert_get_em(struct Object *ob, struct BMVert
struct MDeformVert *ED_mesh_active_dvert_get_ob(struct Object *ob, int *r_index);
struct MDeformVert *ED_mesh_active_dvert_get_only(struct Object *ob);
+void EDBM_mesh_stats_multi(struct Object **objects, const uint objects_len, int totelem[3], int totelem_sel[3]);
+void EDBM_mesh_elem_index_ensure_multi(struct Object **objects, const uint objects_len, const char htype);
+
#define ED_MESH_PICK_DEFAULT_VERT_SIZE 50
#define ED_MESH_PICK_DEFAULT_FACE_SIZE 3
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 83119062203..1d35401ebd2 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -57,7 +57,7 @@ struct wmWindowManager;
struct PointerRNA;
struct PropertyRNA;
struct EnumPropertyItem;
-struct EvaluationContext;
+struct Depsgraph;
#include "DNA_object_enums.h"
@@ -124,10 +124,13 @@ enum {
EM_WAITCURSOR = (1 << 1),
EM_DO_UNDO = (1 << 2),
EM_IGNORE_LAYER = (1 << 3),
+ EM_NO_CONTEXT = (1 << 4),
};
void ED_object_editmode_exit_ex(
struct bContext *C, struct Scene *scene, struct Object *obedit, int flag);
void ED_object_editmode_exit(struct bContext *C, int flag);
+
+void ED_object_editmode_enter_ex(struct Scene *scene, struct Object *ob, int flag);
void ED_object_editmode_enter(struct bContext *C, int flag);
bool ED_object_editmode_load(struct Object *obedit);
@@ -135,11 +138,11 @@ bool ED_object_editmode_calc_active_center(struct Object *obedit, const bool sel
void ED_object_vpaintmode_enter_ex(
- const struct EvaluationContext *eval_ctx, struct wmWindowManager *wm,
+ struct Depsgraph *depsgraph, struct wmWindowManager *wm,
struct Scene *scene, struct Object *ob);
void ED_object_vpaintmode_enter(struct bContext *C);
void ED_object_wpaintmode_enter_ex(
- const struct EvaluationContext *eval_ctx, struct wmWindowManager *wm,
+ struct Depsgraph *depsgraph, struct wmWindowManager *wm,
struct Scene *scene, struct Object *ob);
void ED_object_wpaintmode_enter(struct bContext *C);
@@ -149,12 +152,12 @@ void ED_object_wpaintmode_exit_ex(struct Object *ob);
void ED_object_wpaintmode_exit(struct bContext *C);
void ED_object_sculptmode_enter_ex(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob,
struct ReportList *reports);
void ED_object_sculptmode_enter(struct bContext *C, struct ReportList *reports);
void ED_object_sculptmode_exit_ex(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob);
void ED_object_sculptmode_exit(struct bContext *C);
@@ -213,10 +216,10 @@ bool ED_object_mode_generic_enter(
struct bContext *C,
eObjectMode object_mode);
void ED_object_mode_generic_exit(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob);
bool ED_object_mode_generic_has_data(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Object *ob);
bool ED_object_mode_generic_exists(
@@ -238,7 +241,7 @@ int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob,
int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene,
struct ViewLayer *view_layer, struct Object *ob, struct ModifierData *md);
-int ED_object_modifier_apply(struct ReportList *reports, const struct EvaluationContext *eval_ctx, struct Scene *scene,
+int ED_object_modifier_apply(struct ReportList *reports, struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, struct ModifierData *md, int mode);
int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index b3e274a235a..f84015c53ee 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -47,15 +47,15 @@ int PE_start_edit(struct PTCacheEdit *edit);
/* access */
struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob);
-struct PTCacheEdit *PE_create_current(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
-void PE_current_changed(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+struct PTCacheEdit *PE_create_current(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
+void PE_current_changed(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
int PE_minmax(struct Scene *scene, struct ViewLayer *view_layer, float min[3], float max[3]);
struct ParticleEditSettings *PE_settings(struct Scene *scene);
/* update calls */
void PE_hide_keys_time(struct Scene *scene, struct PTCacheEdit *edit, float cfra);
void PE_update_object(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, int useflag);
/* selection tools */
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h
index b7317d75cd4..2615847e90a 100644
--- a/source/blender/editors/include/ED_render.h
+++ b/source/blender/editors/include/ED_render.h
@@ -54,7 +54,6 @@ void ED_render_engine_area_exit(struct Main *bmain, struct ScrArea *sa);
void ED_render_id_flush_update(const struct DEGEditorUpdateContext *update_ctx, struct ID *id);
void ED_render_scene_update(const struct DEGEditorUpdateContext *update_ctx, int updated);
-void ED_viewport_render_kill_jobs(struct wmWindowManager *wm, struct Main *bmain, bool free_database);
struct Scene *ED_render_job_get_scene(const struct bContext *C);
struct Scene *ED_render_job_get_current_scene(const struct bContext *C);
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index ea8a7c217a2..325e34d1660 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -83,6 +83,7 @@ void ED_region_header_init(struct ARegion *ar);
void ED_region_header(const struct bContext *C, struct ARegion *ar);
void ED_region_cursor_set(struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar);
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
+void ED_region_visibility_change_update(struct bContext *C, struct ARegion *ar);
void ED_region_info_draw(struct ARegion *ar, const char *text, float fill_color[4], const bool full_redraw);
void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float fill_color[4], const bool full_redraw);
void ED_region_image_metadata_draw(int x, int y, struct ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy);
@@ -111,6 +112,11 @@ int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *bl
void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);
void ED_area_exit(struct bContext *C, struct ScrArea *sa);
int ED_screen_area_active(const struct bContext *C);
+void ED_screen_global_topbar_area_create(
+ struct wmWindow *win,
+ const struct bScreen *screen);
+void ED_screen_global_areas_create(
+ struct wmWindow *win);
void ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, Scene *scene,
struct WorkSpace *workspace);
void ED_area_tag_redraw(ScrArea *sa);
@@ -123,6 +129,23 @@ void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool s
void ED_area_prevspace(struct bContext *C, ScrArea *sa);
void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2);
int ED_area_headersize(void);
+int ED_area_global_size_y(const ScrArea *area);
+bool ED_area_is_global(const ScrArea *area);
+int ED_region_global_size_y(void);
+
+/** Iterate over all areas visible in the screen (screen as in everything visible in the window, not just bScreen) */
+#define ED_screen_areas_iter(win, screen, area_name) \
+ for (ScrArea *area_name = (win)->global_areas.areabase.first ? \
+ (win)->global_areas.areabase.first : \
+ screen->areabase.first; \
+ area_name != NULL; \
+ area_name = (area_name == (win)->global_areas.areabase.last) ? (screen)->areabase.first : area_name->next)
+#define ED_screen_verts_iter(win, screen, vert_name) \
+ for (ScrVert *vert_name = (win)->global_areas.vertbase.first ? \
+ (win)->global_areas.vertbase.first : \
+ screen->vertbase.first; \
+ vert_name != NULL; \
+ vert_name = (vert_name == (win)->global_areas.vertbase.last) ? (screen)->vertbase.first : vert_name->next)
/* screens */
void ED_screens_initialize(struct wmWindowManager *wm);
@@ -130,6 +153,7 @@ void ED_screen_draw_edges(struct wmWindow *win);
void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2);
void ED_screen_draw_split_preview(struct ScrArea *sa, const int dir, const float fac);
void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
+void ED_screen_ensure_updated(struct wmWindowManager *wm, struct wmWindow *win, struct bScreen *screen);
void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note);
bool ED_screen_change(struct bContext *C, struct bScreen *sc);
void ED_screen_update_after_scene_change(
@@ -157,8 +181,7 @@ struct WorkSpace *ED_workspace_add(
struct Main *bmain,
const char *name,
Scene *scene,
- ViewLayer *act_render_layer,
- struct ViewRender *view_render) ATTR_NONNULL();
+ ViewLayer *act_render_layer) ATTR_NONNULL();
bool ED_workspace_change(
struct WorkSpace *workspace_new,
struct bContext *C,
@@ -220,7 +243,6 @@ int ED_operator_objectmode(struct bContext *C);
int ED_operator_view3d_active(struct bContext *C);
int ED_operator_region_view3d_active(struct bContext *C);
int ED_operator_animview_active(struct bContext *C);
-int ED_operator_timeline_active(struct bContext *C);
int ED_operator_outliner_active(struct bContext *C);
int ED_operator_outliner_active_no_editobject(struct bContext *C);
int ED_operator_file_active(struct bContext *C);
@@ -233,7 +255,6 @@ int ED_operator_sequencer_active(struct bContext *C);
int ED_operator_sequencer_active_editable(struct bContext *C);
int ED_operator_image_active(struct bContext *C);
int ED_operator_nla_active(struct bContext *C);
-int ED_operator_logic_active(struct bContext *C);
int ED_operator_info_active(struct bContext *C);
int ED_operator_console_active(struct bContext *C);
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index d268c578cf2..0cb23514867 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -41,7 +41,6 @@ void ED_spacemacros_init(void);
/* calls for registering default spaces */
void ED_spacetype_outliner(void);
-void ED_spacetype_time(void);
void ED_spacetype_view3d(void);
void ED_spacetype_ipo(void);
void ED_spacetype_image(void);
@@ -58,6 +57,7 @@ void ED_spacetype_logic(void);
void ED_spacetype_console(void);
void ED_spacetype_userpref(void);
void ED_spacetype_clip(void);
+void ED_spacetype_topbar(void);
/* calls for instancing and freeing spacetype static data
* called in WM_init_exit */
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 536f9c22dcd..a6bed6c1ee6 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -130,7 +130,7 @@ void BIF_createTransformOrientation(struct bContext *C, struct ReportList *repor
const char *name, const bool use_view,
const bool activate, const bool overwrite);
void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
-void BIF_selectTransformOrientationValue(struct View3D *v3d, int orientation);
+void BIF_selectTransformOrientationValue(struct Scene *scene, int orientation);
void ED_getTransformOrientationMatrix(const struct bContext *C, float orientation_mat[3][3], const short around);
diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h
index 26cef2599bd..3d778527a59 100644
--- a/source/blender/editors/include/ED_transform_snap_object_context.h
+++ b/source/blender/editors/include/ED_transform_snap_object_context.h
@@ -29,6 +29,7 @@ struct BMVert;
struct BMEdge;
struct BMFace;
+struct Depsgraph;
struct ListBase;
struct Scene;
struct ViewLayer;
@@ -75,9 +76,9 @@ struct SnapObjectParams {
typedef struct SnapObjectContext SnapObjectContext;
SnapObjectContext *ED_transform_snap_object_context_create(
- struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, int flag);
+ struct Main *bmain, struct Scene *scene, struct Depsgraph *depsgraph, int flag);
SnapObjectContext *ED_transform_snap_object_context_create_view3d(
- struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, int flag,
+ struct Main *bmain, struct Scene *scene, struct Depsgraph *depsgraph, int flag,
/* extra args for view3d */
const struct ARegion *ar, const struct View3D *v3d);
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx);
diff --git a/source/blender/editors/include/ED_undo.h b/source/blender/editors/include/ED_undo.h
index b3814ab5899..da8cd95555c 100644
--- a/source/blender/editors/include/ED_undo.h
+++ b/source/blender/editors/include/ED_undo.h
@@ -25,7 +25,10 @@
#ifndef __ED_UNDO_H__
#define __ED_UNDO_H__
+#include "BLI_compiler_attrs.h"
+
struct bContext;
+struct CLG_LogRef;
struct wmOperator;
struct wmOperatorType;
struct UndoStack;
@@ -49,10 +52,24 @@ int ED_undo_operator_repeat(struct bContext *C, struct wmOperator *op);
void ED_undo_operator_repeat_cb(struct bContext *C, void *arg_op, void *arg_unused);
void ED_undo_operator_repeat_cb_evt(struct bContext *C, void *arg_op, int arg_unused);
+#ifdef WITH_REDO_REGION_REMOVAL
+/* Context sanity helpers for operator repeat. */
+typedef struct OperatorRepeatContextHandle OperatorRepeatContextHandle;
+
+const OperatorRepeatContextHandle *ED_operator_repeat_prepare_context(
+ struct bContext *C, struct wmOperator *op) ATTR_WARN_UNUSED_RESULT;
+void ED_operator_repeat_reset_context(
+ struct bContext *C, const OperatorRepeatContextHandle *context_info);
+#endif
+
bool ED_undo_is_valid(const struct bContext *C, const char *undoname);
struct UndoStack *ED_undo_stack_get(void);
+/* helpers */
+void ED_undo_object_set_active_or_warn(
+ struct ViewLayer *view_layer, struct Object *ob, const char *info, struct CLG_LogRef *log);
+
/* undo_system_types.c */
void ED_undosys_type_init(void);
void ED_undosys_type_free(void);
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 2653585dacc..69e80f60d0a 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -31,11 +31,10 @@
#ifndef __ED_UTIL_H__
#define __ED_UTIL_H__
+#include "BLI_compiler_attrs.h"
+
struct bContext;
struct wmOperatorType;
-struct ScrArea;
-struct SpaceLink;
-struct PackedFile;
/* ed_util.c */
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 2a5ad494643..d6e8b6e9504 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -50,8 +50,6 @@ struct wmKeyConfig;
void ED_operatortypes_uvedit(void);
void ED_keymap_uvedit(struct wmKeyConfig *keyconf);
-void ED_uvedit_assign_image(
- struct Main *bmain, struct Scene *scene, struct Object *obedit, struct Image *ima, struct Image *previma);
bool ED_uvedit_minmax(struct Scene *scene, struct Image *ima, struct Object *obedit, float min[2], float max[2]);
bool ED_uvedit_center(Scene *scene, Image *ima, struct Object *obedit, float cent[2], char mode);
void ED_uvedit_select_all(struct BMesh *bm);
@@ -119,17 +117,20 @@ void ED_uvedit_live_unwrap_end(short cancel);
void ED_uvedit_live_unwrap(struct Scene *scene, struct Object *obedit);
void ED_uvedit_pack_islands(
-struct Scene *scene, struct Object *ob, struct BMesh *bm, bool selected, bool correct_aspect, bool do_rotate);
+ struct Scene *scene, struct Object *ob, struct BMesh *bm, bool selected, bool correct_aspect, bool do_rotate);
+void ED_uvedit_pack_islands_multi(
+ struct Scene *scene, struct Object **objects, const uint objects_len,
+ bool selected, bool correct_aspect, bool do_rotate);
void ED_uvedit_unwrap_cube_project(
struct BMesh *bm, float cube_size, bool use_select, const float center[3]);
/* single call up unwrap using scene settings, used for edge tag unwrapping */
-void ED_unwrap_lscm(struct Scene *scene, struct Object *obedit, const short sel);
+void ED_unwrap_lscm(struct Scene *scene, struct Object *obedit, const short sel, const bool pack);
/* uvedit_draw.c */
void ED_image_draw_cursor(
-struct ARegion *ar, const float cursor[2]);
+ struct ARegion *ar, const float cursor[2]);
void ED_uvedit_draw_main(
struct SpaceImage *sima,
struct ARegion *ar, struct Scene *scene, struct ViewLayer *view_layer,
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 1d4fc8891f5..18d939a4800 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -43,7 +43,6 @@ struct BoundBox;
struct Camera;
struct Depsgraph;
struct EditBone;
-struct EvaluationContext;
struct GroomBundle;
struct GroomSection;
struct GroomSectionVertex;
@@ -82,7 +81,6 @@ typedef struct ViewContext {
struct Depsgraph *depsgraph;
struct Scene *scene;
struct ViewLayer *view_layer;
- struct RenderEngineType *engine_type;
struct Object *obact;
struct Object *obedit;
struct ARegion *ar;
@@ -160,20 +158,20 @@ typedef enum {
/* foreach iterators */
void meshobject_foreachScreenVert(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc,
+ struct ViewContext *vc,
void (*func)(void *userData, struct MVert *eve, const float screen_co[2], int index),
void *userData, const eV3DProjTest clip_flag);
void mesh_foreachScreenVert(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc,
+ struct ViewContext *vc,
void (*func)(void *userData, struct BMVert *eve, const float screen_co[2], int index),
void *userData, const eV3DProjTest clip_flag);
void mesh_foreachScreenEdge(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc,
+ struct ViewContext *vc,
void (*func)(void *userData, struct BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2],
int index),
void *userData, const eV3DProjTest clip_flag);
void mesh_foreachScreenFace(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc,
+ struct ViewContext *vc,
void (*func)(void *userData, struct BMFace *efa, const float screen_co[2], int index),
void *userData, const eV3DProjTest clip_flag);
void nurbs_foreachScreenVert(
@@ -241,11 +239,11 @@ float ED_view3d_pixel_size(const struct RegionView3D *rv3d, const float co[3]);
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip);
bool ED_view3d_clip_segment(const struct RegionView3D *rv3d, float ray_start[3], float ray_end[3]);
bool ED_view3d_win_to_ray(
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
const struct ARegion *ar, const struct View3D *v3d, const float mval[2],
float ray_start[3], float ray_normal[3], const bool do_clip);
bool ED_view3d_win_to_ray_ex(
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
const struct ARegion *ar, const struct View3D *v3d, const float mval[2],
float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip);
void ED_view3d_global_to_vector(const struct RegionView3D *rv3d, const float coord[3], float vec[3]);
@@ -260,7 +258,7 @@ void ED_view3d_win_to_3d_int(
void ED_view3d_win_to_delta(const struct ARegion *ar, const float mval[2], float out[3], const float zfac);
void ED_view3d_win_to_origin(const struct ARegion *ar, const float mval[2], float out[3]);
void ED_view3d_win_to_vector(const struct ARegion *ar, const float mval[2], float out[3]);
-bool ED_view3d_win_to_segment(const struct Depsgraph *depsgraph,
+bool ED_view3d_win_to_segment(struct Depsgraph *depsgraph,
const struct ARegion *ar, struct View3D *v3d, const float mval[2],
float r_ray_start[3], float r_ray_end[3], const bool do_clip);
void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]);
@@ -276,28 +274,28 @@ void ED_view3d_dist_range_get(
const struct View3D *v3d,
float r_dist_range[2]);
bool ED_view3d_clip_range_get(
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
const struct View3D *v3d, const struct RegionView3D *rv3d,
float *r_clipsta, float *r_clipend, const bool use_ortho_factor);
bool ED_view3d_viewplane_get(
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
const struct View3D *v3d, const struct RegionView3D *rv3d, int winxi, int winyi,
struct rctf *r_viewplane, float *r_clipsta, float *r_clipend, float *r_pixsize);
void ED_view3d_polygon_offset(const struct RegionView3D *rv3d, const float dist);
void ED_view3d_calc_camera_border(
- const struct Scene *scene, const struct Depsgraph *depsgraph,
+ const struct Scene *scene, struct Depsgraph *depsgraph,
const struct ARegion *ar,
const struct View3D *v3d, const struct RegionView3D *rv3d,
struct rctf *r_viewborder, const bool no_shift);
void ED_view3d_calc_camera_border_size(
- const struct Scene *scene, const struct Depsgraph *depsgraph,
+ const struct Scene *scene, struct Depsgraph *depsgraph,
const struct ARegion *ar,
const struct View3D *v3d, const struct RegionView3D *rv3d,
float r_size[2]);
bool ED_view3d_calc_render_border(
- const struct Scene *scene, const struct Depsgraph *depsgraph,
+ const struct Scene *scene, struct Depsgraph *depsgraph,
struct View3D *v3d,
struct ARegion *ar, struct rcti *rect);
@@ -320,23 +318,23 @@ float ED_view3d_radius_to_dist(
void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned pos);
/* backbuffer select and draw support */
-void ED_view3d_backbuf_validate(const struct EvaluationContext *eval_ctx, struct ViewContext *vc);
+void ED_view3d_backbuf_validate(struct ViewContext *vc);
struct ImBuf *ED_view3d_backbuf_read(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, int xmin, int ymin, int xmax, int ymax);
+ struct ViewContext *vc, int xmin, int ymin, int xmax, int ymax);
unsigned int ED_view3d_backbuf_sample_rect(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, const int mval[2], int size,
+ struct ViewContext *vc, const int mval[2], int size,
unsigned int min, unsigned int max, float *r_dist);
int ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float dist);
unsigned int ED_view3d_backbuf_sample(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, int x, int y);
+ struct ViewContext *vc, int x, int y);
bool ED_view3d_autodist(
- const struct EvaluationContext *eval_ctx, struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d,
+ struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d,
const int mval[2], float mouse_worldloc[3],
const bool alphaoverride, const float fallback_depth_pt[3]);
/* only draw so ED_view3d_autodist_simple can be called many times after */
-void ED_view3d_autodist_init(const struct EvaluationContext *eval_ctx, struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d, int mode);
+void ED_view3d_autodist_init(struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d, int mode);
bool ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
bool ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
bool ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth);
@@ -358,12 +356,13 @@ void view3d_opengl_select_cache_begin(void);
void view3d_opengl_select_cache_end(void);
int view3d_opengl_select(
- const struct EvaluationContext *eval_ctx, struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const struct rcti *input,
+ struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const struct rcti *input,
eV3DSelectMode select_mode);
/* view3d_select.c */
float ED_view3d_select_dist_px(void);
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc);
+void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact);
void view3d_operator_needs_opengl(const struct bContext *C);
void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar);
void view3d_opengl_read_pixels(struct ARegion *ar, int x, int y, int w, int h, int format, int type, void *data);
@@ -390,55 +389,52 @@ int ED_view3d_view_layer_set(int lay, const int *values, int *active);
struct RV3DMatrixStore *ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d);
void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat);
-void ED_draw_object_facemap(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, const float col[4], const int facemap);
+void ED_draw_object_facemap(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const float col[4], const int facemap);
+
+struct RenderEngineType *ED_view3d_engine_type(struct Scene *scene, int drawtype);
bool ED_view3d_context_activate(struct bContext *C);
-void ED_view3d_draw_offscreen_init(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
- struct ViewLayer *view_layer, struct RenderEngineType *engine_type,
- struct View3D *v3d);
void ED_view3d_draw_offscreen(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
- struct ViewLayer *view_layer, struct RenderEngineType *engine_type,
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ int drawtype,
struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
- float winmat[4][4], bool do_bgpic, bool do_sky, bool is_persp, const char *viewname,
+ float winmat[4][4], bool do_sky, bool is_persp, const char *viewname,
struct GPUFXSettings *fx_settings,
struct GPUOffScreen *ofs, struct GPUViewport *viewport);
void ED_view3d_draw_setup_view(
- struct wmWindow *win, const struct EvaluationContext *eval_ctx, struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
+ struct wmWindow *win, struct Depsgraph *depsgraph, struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
float viewmat[4][4], float winmat[4][4], const struct rcti *rect);
enum {
V3D_OFSDRAW_NONE = (0),
- V3D_OFSDRAW_USE_BACKGROUND = (1 << 0),
- V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 1),
+ V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 0),
/* Only works with ED_view3d_draw_offscreen_imbuf_simple(). */
- V3D_OFSDRAW_USE_GPENCIL = (1 << 2),
+ V3D_OFSDRAW_USE_GPENCIL = (1 << 1),
V3D_OFSDRAW_USE_SOLID_TEX = (1 << 2),
V3D_OFSDRAW_USE_CAMERA_DOF = (1 << 3),
};
struct ImBuf *ED_view3d_draw_offscreen_imbuf(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
- struct ViewLayer *view_layer, struct RenderEngineType *engine_type,
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ int drawtype,
struct View3D *v3d, struct ARegion *ar,
int sizex, int sizey, unsigned int flag, unsigned int draw_flags,
int alpha_mode, int samples, const char *viewname,
struct GPUOffScreen *ofs, char err_out[256]);
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
- struct ViewLayer *view_layer, struct RenderEngineType *engine_type,
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ int drawtype,
struct Object *camera, int width, int height,
- unsigned int flag, unsigned int draw_flags, int drawtype, int alpha_mode,
+ unsigned int flag, unsigned int draw_flags, int alpha_mode,
int samples, const char *viewname,
struct GPUOffScreen *ofs, char err_out[256]);
struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, bool do_clip);
void ED_view3d_update_viewmat(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
float viewmat[4][4], float winmat[4][4], const struct rcti *rect);
bool ED_view3d_quat_from_axis_view(const char view, float quat[4]);
char ED_view3d_quat_to_axis_view(const float quat[4], const float epsilon);
@@ -502,7 +498,7 @@ void ED_view3d_id_remap(struct View3D *v3d, const struct ID *old_id, struct ID *
/* view3d_draw_legacy.c */
/* Try avoid using these more move out of legacy. */
void ED_view3d_draw_bgpic_test(
- struct Scene *scene, const struct Depsgraph *depsgraph,
+ struct Scene *scene, struct Depsgraph *depsgraph,
struct ARegion *ar, struct View3D *v3d,
const bool do_foreground, const bool do_camera_frame);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index edf15d02e73..402be964436 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -268,8 +268,6 @@ typedef enum {
UI_BTYPE_SCROLL = (18 << 9),
UI_BTYPE_BLOCK = (19 << 9),
UI_BTYPE_LABEL = (20 << 9),
- UI_BTYPE_LINK = (22 << 9),
- UI_BTYPE_INLINK = (23 << 9),
UI_BTYPE_KEY_EVENT = (24 << 9),
UI_BTYPE_HSVCUBE = (26 << 9),
UI_BTYPE_PULLDOWN = (27 << 9), /* menu (often used in headers), **_MENU /w different draw-type */
@@ -701,18 +699,30 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block, struct wmOperatorType *ot, struct IDP
void *arg, int retval, int icon, int maxlen, int x, int y,
short width, short height, float a1, float a2, const char *tip);
-uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2);
-int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align);
-
-/* Links
- *
- * Game engine logic brick links. Non-functional currently in 2.5,
- * code to handle and draw these is disabled internally. */
-void UI_but_link_set(struct uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to);
+/* For uiDefAutoButsRNA */
+typedef enum {
+ /* Keep current layout for aligning label with property button. */
+ UI_BUT_LABEL_ALIGN_NONE,
+ /* Align label and property button vertically. */
+ UI_BUT_LABEL_ALIGN_COLUMN,
+ /* Split layout into a column for the label and one for property button. */
+ UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
+} eButLabelAlign;
+
+/* Return info for uiDefAutoButsRNA */
+typedef enum {
+ /* Returns when no buttons were added */
+ UI_PROP_BUTS_NONE_ADDED = (1 << 0),
+ /* Returned when any property failed the custom check callback (check_prop) */
+ UI_PROP_BUTS_ANY_FAILED_CHECK = (1 << 1),
+} eAutoPropButsReturn;
-void UI_block_links_compose(uiBlock *block);
-uiBut *UI_block_links_find_inlink(uiBlock *block, void *poin);
+uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2);
+eAutoPropButsReturn uiDefAutoButsRNA(
+ uiLayout *layout, struct PointerRNA *ptr,
+ bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
+ eButLabelAlign label_align, const bool compact);
/* use inside searchfunc to add items */
bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int iconid);
@@ -848,6 +858,7 @@ void UI_exit(void);
#define UI_LAYOUT_ALIGN_CENTER 2
#define UI_LAYOUT_ALIGN_RIGHT 3
+#define UI_ITEM_O_RETURN_PROPS (1 << 0)
#define UI_ITEM_R_EXPAND (1 << 1)
#define UI_ITEM_R_SLIDER (1 << 2)
#define UI_ITEM_R_TOGGLE (1 << 3)
@@ -857,10 +868,15 @@ void UI_exit(void);
#define UI_ITEM_R_NO_BG (1 << 7)
#define UI_ITEM_R_IMMEDIATE (1 << 8)
#define UI_ITEM_O_DEPRESS (1 << 9)
+#define UI_ITEM_R_COMPACT (1 << 10)
-/* uiTemplateOperatorPropertyButs flags */
-#define UI_TEMPLATE_OP_PROPS_SHOW_TITLE 1
-#define UI_TEMPLATE_OP_PROPS_SHOW_EMPTY 2
+
+/* uiLayoutOperatorButs flags */
+enum {
+ UI_TEMPLATE_OP_PROPS_SHOW_TITLE = (1 << 0),
+ UI_TEMPLATE_OP_PROPS_SHOW_EMPTY = (1 << 1),
+ UI_TEMPLATE_OP_PROPS_COMPACT = (1 << 2),
+};
/* used for transp checkers */
#define UI_ALPHA_CHECKER_DARK 100
@@ -943,6 +959,11 @@ void uiTemplateIDBrowse(
void uiTemplateIDPreview(
uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
const char *newop, const char *openop, const char *unlinkop, int rows, int cols, int filter);
+void uiTemplateIDTabs(
+ uiLayout *layout, struct bContext *C,
+ PointerRNA *ptr, const char *propname,
+ const char *newop, const char *openop, const char *unlinkop,
+ int filter);
void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
const char *proptypename, const char *text);
void uiTemplateSearch(
@@ -959,6 +980,9 @@ void uiTemplateSearchPreview(
void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
struct PointerRNA *root_ptr, const char *text);
uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
+#ifdef WITH_REDO_REGION_REMOVAL
+void uiTemplateOperatorRedoProperties(uiLayout *layout, struct bContext *C);
+#endif
uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
struct MTex *slot, const char *preview_id);
@@ -973,8 +997,6 @@ void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char
void uiTemplatePalette(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int color);
void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
PointerRNA *used_ptr, const char *used_propname, int active_layer);
-void uiTemplateGameStates(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
- PointerRNA *used_ptr, const char *used_propname, int active_state);
void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact, int multiview);
void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int color_management);
void uiTemplateImageStereo3d(uiLayout *layout, struct PointerRNA *stereo3d_format_ptr);
@@ -985,9 +1007,10 @@ void uiTemplateImageInfo(uiLayout *layout, struct bContext *C, struct Image *ima
void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
void UI_but_func_operator_search(uiBut *but);
void uiTemplateOperatorSearch(uiLayout *layout);
-void uiTemplateOperatorPropertyButs(const struct bContext *C, uiLayout *layout, struct wmOperator *op,
- bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
- const char label_align, const short flag);
+eAutoPropButsReturn uiTemplateOperatorPropertyButs(
+ const struct bContext *C, uiLayout *layout, struct wmOperator *op,
+ bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
+ const eButLabelAlign label_align, const short flag);
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 7d2837ffe4e..49c9cffdd54 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -51,7 +51,7 @@ typedef enum {
/* use to denote intentionally unset theme color */
#define TH_UNDEFINED -1
-enum {
+typedef enum ThemeColorID {
TH_REDALERT,
TH_THEMEUI,
@@ -308,7 +308,7 @@ enum {
TH_EDGE_BEVEL,
TH_VERTEX_BEVEL
-};
+} ThemeColorID;
/* specific defines per space should have higher define values */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 12ee1ad35a1..a9fdd1678e2 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -51,6 +51,7 @@
#include "BLI_utildefines.h"
+#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_unit.h"
#include "BKE_scene.h"
@@ -80,6 +81,8 @@
#include "IMB_colormanagement.h"
+#include "DEG_depsgraph_query.h"
+
#include "interface_intern.h"
/* avoid unneeded calls to ui_but_value_get */
@@ -507,87 +510,6 @@ static int ui_but_calc_float_precision(uiBut *but, double value)
return UI_calc_float_precision(prec, value);
}
-/* ************** LINK LINE DRAWING ************* */
-
-/* link line drawing is not part of buttons or theme.. so we stick with it here */
-
-static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines, int dashInactiveLines)
-{
- rcti rect;
- float color[4] = {1.0f};
-
- if (line->from == NULL || line->to == NULL) return;
-
- rect.xmin = BLI_rctf_cent_x(&line->from->rect);
- rect.ymin = BLI_rctf_cent_y(&line->from->rect);
- rect.xmax = BLI_rctf_cent_x(&line->to->rect);
- rect.ymax = BLI_rctf_cent_y(&line->to->rect);
-
- if (dashInactiveLines)
- UI_GetThemeColor4fv(TH_GRID, color);
- else if (line->flag & UI_SELECT)
- rgba_float_args_set_ch(color, 100, 100, 100, 255);
- else if (highlightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE)))
- UI_GetThemeColor4fv(TH_TEXT_HI, color);
- else
- rgba_float_args_set_ch(color, 0, 0, 0, 255);
-
- ui_draw_link_bezier(&rect, color);
-}
-
-static void ui_draw_links(uiBlock *block)
-{
- uiBut *but;
- uiLinkLine *line;
-
- /* Draw the gray out lines. Do this first so they appear at the
- * bottom of inactive or active lines.
- * As we go, remember if we see any active or selected lines. */
- bool found_selectline = false;
- bool found_activeline = false;
-
- for (but = block->buttons.first; but; but = but->next) {
- if (but->type == UI_BTYPE_LINK && but->link) {
- for (line = but->link->lines.first; line; line = line->next) {
- if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) {
- if (line->deactive)
- ui_draw_linkline(line, 0, true);
- }
- else
- found_activeline = true;
-
- if ((line->from->flag & UI_SELECT) || (line->to->flag & UI_SELECT))
- found_selectline = true;
- }
- }
- }
-
- /* Draw the inactive lines (lines with neither button being hovered over) */
- for (but = block->buttons.first; but; but = but->next) {
- if (but->type == UI_BTYPE_LINK && but->link) {
- for (line = but->link->lines.first; line; line = line->next) {
- if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) {
- if (!line->deactive)
- ui_draw_linkline(line, 0, false);
- }
- }
- }
- }
-
- /* Draw any active lines (lines with either button being hovered over).
- * Do this last so they appear on top of inactive and gray out lines. */
- if (found_activeline) {
- for (but = block->buttons.first; but; but = but->next) {
- if (but->type == UI_BTYPE_LINK && but->link) {
- for (line = but->link->lines.first; line; line = line->next) {
- if ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))
- ui_draw_linkline(line, !found_selectline, false);
- }
- }
- }
- }
-}
-
/* ************** BLOCK ENDING FUNCTION ************* */
/* NOTE: if but->poin is allocated memory for every defbut, things fail... */
@@ -630,38 +552,6 @@ uiBut *ui_but_find_new(uiBlock *block_new, const uiBut *but_old)
return but_new;
}
-/* oldbut is being inserted in new block, so we use the lines from new button, and replace button pointers */
-static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut)
-{
- uiLinkLine *line;
- uiBut *but;
-
- /* if active button is UI_BTYPE_LINK */
- if (newbut->type == UI_BTYPE_LINK && newbut->link) {
-
- SWAP(uiLink *, oldbut->link, newbut->link);
-
- for (line = oldbut->link->lines.first; line; line = line->next) {
- if (line->to == newbut)
- line->to = oldbut;
- if (line->from == newbut)
- line->from = oldbut;
- }
- }
-
- /* check all other button links */
- for (but = block->buttons.first; but; but = but->next) {
- if (but != newbut && but->type == UI_BTYPE_LINK && but->link) {
- for (line = but->link->lines.first; line; line = line->next) {
- if (line->to == newbut)
- line->to = oldbut;
- if (line->from == newbut)
- line->from = oldbut;
- }
- }
- }
-}
-
/**
* \return true when \a but_p is set (only done for active buttons).
*/
@@ -761,8 +651,6 @@ static bool ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBu
oldbut->a1 = but->a1;
}
- ui_but_update_linklines(block, oldbut, but);
-
if (!BLI_listbase_is_empty(&block->butstore)) {
UI_butstore_register_update(block, oldbut, but);
}
@@ -1305,7 +1193,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
if (block->layouts.first) {
UI_block_layout_resolve(block, NULL, NULL);
}
- ui_block_align_calc(block);
+ ui_block_align_calc(block, CTX_wm_region(C));
if ((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) {
ui_menu_block_set_keyaccels(block); /* could use a different flag to check */
}
@@ -1450,8 +1338,6 @@ void UI_block_draw(const bContext *C, uiBlock *block)
/* restore matrix */
gpuPopProjectionMatrix();
gpuPopMatrix();
-
- ui_draw_links(block);
}
static void ui_block_message_subscribe(ARegion *ar, struct wmMsgBus *mbus, uiBlock *block)
@@ -1534,7 +1420,6 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
break;
case UI_BTYPE_ROW:
case UI_BTYPE_LISTROW:
- case UI_BTYPE_TAB:
UI_GET_BUT_VALUE_INIT(but, *value);
/* support for rna enum buts */
if (but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) {
@@ -1544,6 +1429,18 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
if (*value == (double)but->hardmax) is_push = true;
}
break;
+ case UI_BTYPE_TAB:
+ if (but->rnaprop && but->custom_data) {
+ /* uiBut.custom_data points to data this tab represents (e.g. workspace).
+ * uiBut.rnapoin/prop store an active value (e.g. active workspace). */
+ if (RNA_property_type(but->rnaprop) == PROP_POINTER) {
+ PointerRNA active_ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
+ if (active_ptr.data == but->custom_data) {
+ is_push = true;
+ }
+ }
+ }
+ break;
default:
is_push = -1;
break;
@@ -1570,83 +1467,6 @@ static void ui_but_update_select_flag(uiBut *but, double *value)
}
}
-static uiBut *ui_linkline_find_inlink(uiBlock *block, void *poin)
-{
- uiBut *but;
-
- but = block->buttons.first;
- while (but) {
- if (but->type == UI_BTYPE_INLINK) {
- if (but->poin == poin) return but;
- }
- but = but->next;
- }
- return NULL;
-}
-
-static void ui_linkline_add(ListBase *listb, uiBut *but, uiBut *bt, short deactive)
-{
- uiLinkLine *line;
-
- line = MEM_callocN(sizeof(uiLinkLine), "linkline");
- BLI_addtail(listb, line);
- line->from = but;
- line->to = bt;
- line->deactive = deactive;
-}
-
-uiBut *UI_block_links_find_inlink(uiBlock *block, void *poin)
-{
- return ui_linkline_find_inlink(block, poin);
-}
-
-void UI_block_links_compose(uiBlock *block)
-{
- uiBut *but, *bt;
- uiLink *link;
- void ***ppoin;
- int a;
-
- but = block->buttons.first;
- while (but) {
- if (but->type == UI_BTYPE_LINK) {
- link = but->link;
-
- /* for all pointers in the array */
- if (link) {
- if (link->ppoin) {
- ppoin = link->ppoin;
- for (a = 0; a < *(link->totlink); a++) {
- bt = ui_linkline_find_inlink(block, (*ppoin)[a]);
- if (bt) {
- if ((but->flag & UI_BUT_SCA_LINK_GREY) || (bt->flag & UI_BUT_SCA_LINK_GREY)) {
- ui_linkline_add(&link->lines, but, bt, true);
- }
- else {
- ui_linkline_add(&link->lines, but, bt, false);
- }
-
- }
- }
- }
- else if (link->poin) {
- bt = ui_linkline_find_inlink(block, *link->poin);
- if (bt) {
- if ((but->flag & UI_BUT_SCA_LINK_GREY) || (bt->flag & UI_BUT_SCA_LINK_GREY)) {
- ui_linkline_add(&link->lines, but, bt, true);
- }
- else {
- ui_linkline_add(&link->lines, but, bt, false);
- }
- }
- }
- }
- }
- but = but->next;
- }
-}
-
-
/* ************************************************ */
void UI_block_lock_set(uiBlock *block, bool val, const char *lockstr)
@@ -1663,48 +1483,78 @@ void UI_block_lock_clear(uiBlock *block)
block->lockstr = NULL;
}
-/* *************************************************************** */
-
-void ui_linkline_remove(uiLinkLine *line, uiBut *but)
-{
- uiLink *link;
- int a, b;
-
- BLI_remlink(&but->link->lines, line);
-
- link = line->from->link;
+/* *********************** data get/set ***********************
+ * this either works with the pointed to data, or can work with
+ * an edit override pointer while dragging for example */
- /* are there more pointers allowed? */
- if (link->ppoin) {
-
- if (*(link->totlink) == 1) {
- *(link->totlink) = 0;
- MEM_freeN(*(link->ppoin));
- *(link->ppoin) = NULL;
- }
- else {
- b = 0;
- for (a = 0; a < (*(link->totlink)); a++) {
- if ((*(link->ppoin))[a] != line->to->poin) {
- (*(link->ppoin))[b] = (*(link->ppoin))[a];
- b++;
- }
- }
- (*(link->totlink))--;
+/* Get PointerRNA which will point to a data inside of an evaluated
+ * ID datablock.
+ */
+static PointerRNA ui_but_evaluated_rnapoin_get(uiBut *but)
+{
+ BLI_assert(but->rnaprop != NULL);
+ /* TODO(sergey): evil_C sounds.. EVIL! Any clear way to avoid this? */
+ PointerRNA rnapoin_eval = but->rnapoin;
+ /* If there is no animation or drivers, it doesn't matter if we read value
+ * from evaluated datablock or from original one.
+ *
+ * Reading from original one is much faster, since we don't need to do any
+ * PointerRNA remapping or hash lookup.
+ */
+ if (BKE_animdata_from_id(but->rnapoin.id.data) == NULL) {
+ return rnapoin_eval;
+ }
+ /* Same goes for the properties which can not be animated. */
+ if (!RNA_property_animateable(&but->rnapoin, but->rnaprop)) {
+ return rnapoin_eval;
+ }
+ Depsgraph *depsgraph = CTX_data_depsgraph(but->block->evil_C);
+ /* ID pointer we can always remap, they are inside of depsgraph. */
+ rnapoin_eval.id.data =
+ DEG_get_evaluated_id(depsgraph, rnapoin_eval.id.data);
+ /* Some of ID datablocks do not have their evaluated copy inside
+ * of dependency graph. If it's such datablock, no need to worry about
+ * data pointer.
+ */
+ if (rnapoin_eval.id.data == but->rnapoin.id.data) {
+ return rnapoin_eval;
+ }
+ /* For the data pointer it's getting a bit more involved, since it can
+ * whether be and ID, or can be a property deep inside of ID.
+ *
+ * We start from checking if it's an ID, since that is the less involved
+ * code path, and probably is executed in most of the cases.
+ */
+ if (but->rnapoin.data == but->rnapoin.id.data) {
+ rnapoin_eval.data = DEG_get_evaluated_id(depsgraph, rnapoin_eval.data);
+ return rnapoin_eval;
+ }
+ /* We aren't as lucky as we thought we are :(
+ *
+ * Since we don't know what the property is, we get it's RNA path
+ * relative to the original ID, and then we decent down from evaluated
+ * ID to the same property.
+ *
+ * This seems to be most straightforward way to get sub-data pointers
+ * which can be buried deep inside of ID block.
+ */
+ const char *rna_path =
+ RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
+ if (rna_path != NULL) {
+ PointerRNA id_ptr;
+ RNA_id_pointer_create(rnapoin_eval.id.data, &id_ptr);
+ if (!RNA_path_resolve_full(&id_ptr,
+ rna_path,
+ &rnapoin_eval,
+ NULL, NULL))
+ {
+ /* TODO(sergey): Anything to do here to recover? */
}
+ MEM_freeN((void *)rna_path);
}
- else {
- *(link->poin) = NULL;
- }
-
- MEM_freeN(line);
- //REDRAW
+ return rnapoin_eval;
}
-/* *********************** data get/set ***********************
- * this either works with the pointed to data, or can work with
- * an edit override pointer while dragging for example */
-
/* for buttons pointing to color for example */
void ui_but_v3_get(uiBut *but, float vec[3])
{
@@ -1720,16 +1570,18 @@ void ui_but_v3_get(uiBut *but, float vec[3])
zero_v3(vec);
+ PointerRNA rnapoin_eval = ui_but_evaluated_rnapoin_get(but);
+
if (RNA_property_type(prop) == PROP_FLOAT) {
- int tot = RNA_property_array_length(&but->rnapoin, prop);
+ int tot = RNA_property_array_length(&rnapoin_eval, prop);
BLI_assert(tot > 0);
if (tot == 3) {
- RNA_property_float_get_array(&but->rnapoin, prop, vec);
+ RNA_property_float_get_array(&rnapoin_eval, prop, vec);
}
else {
tot = min_ii(tot, 3);
for (a = 0; a < tot; a++) {
- vec[a] = RNA_property_float_get_index(&but->rnapoin, prop, a);
+ vec[a] = RNA_property_float_get_index(&rnapoin_eval, prop, a);
}
}
}
@@ -1909,27 +1761,29 @@ double ui_but_value_get(uiBut *but)
BLI_assert(but->rnaindex != -1);
+ PointerRNA rnapoin_eval = ui_but_evaluated_rnapoin_get(but);
+
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_check(prop))
- value = RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex);
+ value = RNA_property_boolean_get_index(&rnapoin_eval, prop, but->rnaindex);
else
- value = RNA_property_boolean_get(&but->rnapoin, prop);
+ value = RNA_property_boolean_get(&rnapoin_eval, prop);
break;
case PROP_INT:
if (RNA_property_array_check(prop))
- value = RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex);
+ value = RNA_property_int_get_index(&rnapoin_eval, prop, but->rnaindex);
else
- value = RNA_property_int_get(&but->rnapoin, prop);
+ value = RNA_property_int_get(&rnapoin_eval, prop);
break;
case PROP_FLOAT:
if (RNA_property_array_check(prop))
- value = RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex);
+ value = RNA_property_float_get_index(&rnapoin_eval, prop, but->rnaindex);
else
- value = RNA_property_float_get(&but->rnapoin, prop);
+ value = RNA_property_float_get(&rnapoin_eval, prop);
break;
case PROP_ENUM:
- value = RNA_property_enum_get(&but->rnapoin, prop);
+ value = RNA_property_enum_get(&rnapoin_eval, prop);
break;
default:
value = 0.0;
@@ -2072,7 +1926,7 @@ static bool ui_but_icon_extra_is_visible_text_clear(const uiBut *but)
static bool ui_but_icon_extra_is_visible_search_unlink(const uiBut *but)
{
- BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+ BLI_assert(ELEM(but->type, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TAB));
return ((but->editstr == NULL) &&
(but->drawstr[0] != '\0') &&
(but->flag & UI_BUT_VALUE_CLEAR));
@@ -2115,6 +1969,11 @@ uiButExtraIconType ui_but_icon_extra_get(uiBut *but)
return UI_BUT_ICONEXTRA_EYEDROPPER;
}
break;
+ case UI_BTYPE_TAB:
+ if (ui_but_icon_extra_is_visible_search_unlink(but)) {
+ return UI_BUT_ICONEXTRA_CLEAR;
+ }
+ break;
default:
break;
}
@@ -2228,14 +2087,23 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
*r_use_exp_float = false;
}
- if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
+ if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TAB)) {
PropertyType type;
const char *buf = NULL;
int buf_len;
type = RNA_property_type(but->rnaprop);
- if (type == PROP_STRING) {
+ if ((but->type == UI_BTYPE_TAB) && (but->custom_data)) {
+ StructRNA *ptr_type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop);
+ PointerRNA ptr;
+
+ /* uiBut.custom_data points to data this tab represents (e.g. workspace).
+ * uiBut.rnapoin/prop store an active value (e.g. active workspace). */
+ RNA_pointer_create(but->rnapoin.id.data, ptr_type, but->custom_data, &ptr);
+ buf = RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
+ }
+ else if (type == PROP_STRING) {
/* RNA string */
buf = RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
}
@@ -2271,12 +2139,7 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
MEM_freeN((void *)buf);
}
}
- else if (but->type == UI_BTYPE_TEXT) {
- /* string */
- BLI_strncpy(str, but->poin, maxlen);
- return;
- }
- else if (but->type == UI_BTYPE_SEARCH_MENU) {
+ else if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
/* string */
BLI_strncpy(str, but->poin, maxlen);
return;
@@ -2486,18 +2349,16 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
return true;
}
else if (type == PROP_POINTER) {
- /* RNA pointer */
- PointerRNA ptr, rptr;
- PropertyRNA *prop;
-
if (str[0] == '\0') {
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL);
return true;
}
else {
- ptr = but->rnasearchpoin;
- prop = but->rnasearchprop;
-
+ /* RNA pointer */
+ PointerRNA rptr;
+ PointerRNA ptr = but->rnasearchpoin;
+ PropertyRNA *prop = but->rnasearchprop;
+
if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr))
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
@@ -2519,6 +2380,21 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
}
}
}
+ else if (but->type == UI_BTYPE_TAB) {
+ if (but->rnaprop && but->custom_data) {
+ StructRNA *ptr_type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop);
+ PointerRNA ptr;
+ PropertyRNA *prop;
+
+ /* uiBut.custom_data points to data this tab represents (e.g. workspace).
+ * uiBut.rnapoin/prop store an active value (e.g. active workspace). */
+ RNA_pointer_create(but->rnapoin.id.data, ptr_type, but->custom_data, &ptr);
+ prop = RNA_struct_name_property(ptr_type);
+ if (RNA_property_editable(&ptr, prop)) {
+ RNA_property_string_set(&ptr, prop, str);
+ }
+ }
+ }
else if (but->type == UI_BTYPE_TEXT) {
/* string */
if (!but->poin || (str[0] == '\0')) {
@@ -2713,14 +2589,6 @@ static void ui_set_but_soft_range(uiBut *but)
/* ******************* Free ********************/
-static void ui_free_link(uiLink *link)
-{
- if (link) {
- BLI_freelistN(&link->lines);
- MEM_freeN(link);
- }
-}
-
/* can be called with C==NULL */
static void ui_but_free(const bContext *C, uiBut *but)
{
@@ -2761,7 +2629,6 @@ static void ui_but_free(const bContext *C, uiBut *but)
if (but->str && but->str != but->strdata) {
MEM_freeN(but->str);
}
- ui_free_link(but->link);
if ((but->type == UI_BTYPE_IMAGE) && but->poin) {
IMB_freeImBuf((struct ImBuf *)but->poin);
@@ -3073,6 +2940,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
case UI_BTYPE_TEXT:
case UI_BTYPE_SEARCH_MENU:
+ case UI_BTYPE_TAB:
if (!but->editstr) {
char str[UI_MAX_DRAW_STR];
@@ -3196,6 +3064,16 @@ void ui_block_cm_to_display_space_range(uiBlock *block, float *min, float *max)
*max = max_fff(UNPACK3(pixel));
}
+static uiBut *ui_but_alloc(const eButType type)
+{
+ switch (type) {
+ case UI_BTYPE_TAB:
+ return MEM_callocN(sizeof(uiButTab), "uiButTab");
+ default:
+ return MEM_callocN(sizeof(uiBut), "uiBut");
+ }
+}
+
/**
* \brief ui_def_but is the function that draws many button types
*
@@ -3229,7 +3107,7 @@ static uiBut *ui_def_but(
}
}
- but = MEM_callocN(sizeof(uiBut), "uiBut");
+ but = ui_but_alloc(type & BUTTYPE);
but->type = type & BUTTYPE;
but->pointype = type & UI_BUT_POIN_TYPES;
@@ -4038,19 +3916,6 @@ uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcon
/* END Button containing both string label and icon */
-void UI_but_link_set(uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to)
-{
- uiLink *link;
-
- link = but->link = MEM_callocN(sizeof(uiLink), "new uilink");
-
- link->poin = poin;
- link->ppoin = ppoin;
- link->totlink = tot;
- link->fromcode = from;
- link->tocode = to;
-}
-
/* cruft to make uiBlock and uiBut private */
int UI_blocklist_min_y_get(ListBase *lb)
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c
index 9aeb685a907..1fc38a27303 100644
--- a/source/blender/editors/interface/interface_align.c
+++ b/source/blender/editors/interface/interface_align.c
@@ -320,13 +320,43 @@ static int ui_block_align_butal_cmp(const void *a, const void *b)
return 0;
}
+static void ui_block_align_but_to_region(uiBut *but, const ARegion *region)
+{
+ rctf *rect = &but->rect;
+ const float but_width = BLI_rctf_size_x(rect);
+ const float but_height = BLI_rctf_size_y(rect);
+ const float px = U.pixelsize;
+
+ switch (but->drawflag & UI_BUT_ALIGN) {
+ case UI_BUT_ALIGN_TOP:
+ rect->ymax = region->winy + px;
+ rect->ymin = but->rect.ymax - but_height;
+ break;
+ case UI_BUT_ALIGN_DOWN:
+ rect->ymin = -px;
+ rect->ymax = rect->ymin + but_height;
+ break;
+ case UI_BUT_ALIGN_LEFT:
+ rect->xmin = -px;
+ rect->xmax = rect->xmin + but_width;
+ break;
+ case UI_BUT_ALIGN_RIGHT:
+ rect->xmax = region->winx + px;
+ rect->xmin = rect->xmax - but_width;
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
+}
+
/**
* Compute the alignment of all 'align groups' of buttons in given block.
*
* This is using an order-independent algorithm, i.e. alignment of buttons should be OK regardless of order in which
* they are added to the block.
*/
-void ui_block_align_calc(uiBlock *block)
+void ui_block_align_calc(uiBlock *block, const ARegion *region)
{
uiBut *but;
int num_buttons = 0;
@@ -338,10 +368,17 @@ void ui_block_align_calc(uiBlock *block)
int side;
int i, j;
- /* First loop: we count number of buttons belonging to an align group, and clear their align flag. */
+ /* First loop: we count number of buttons belonging to an align group, and clear their align flag.
+ * Tabs get some special treatment here, they get aligned to region border. */
for (but = block->buttons.first; but; but = but->next) {
- /* Clear old align flags. */
- but->drawflag &= ~UI_BUT_ALIGN_ALL;
+ /* special case: tabs need to be aligned to a region border, drawflag tells which one */
+ if (but->type == UI_BTYPE_TAB) {
+ ui_block_align_but_to_region(but, region);
+ }
+ else {
+ /* Clear old align flags. */
+ but->drawflag &= ~UI_BUT_ALIGN_ALL;
+ }
if (but->alignnr != 0) {
num_buttons++;
diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c
index 6e85d091fdb..fd9c5f1869d 100644
--- a/source/blender/editors/interface/interface_eyedropper_depth.c
+++ b/source/blender/editors/interface/interface_eyedropper_depth.c
@@ -179,9 +179,6 @@ static void depthdropper_depth_sample_pt(bContext *C, DepthDropper *ddr, int mx,
my - ar->winrct.ymin};
float co[3];
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
CTX_wm_area_set(C, sa);
CTX_wm_region_set(C, ar);
@@ -190,7 +187,7 @@ static void depthdropper_depth_sample_pt(bContext *C, DepthDropper *ddr, int mx,
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(&eval_ctx, graph, ar, v3d, mval, co, true, NULL)) {
+ if (ED_view3d_autodist(graph, ar, v3d, mval, co, true, NULL)) {
const float mval_center_fl[2] = {
(float)ar->winx / 2,
(float)ar->winy / 2};
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 11f78967315..9e88c3cbb7f 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -39,9 +39,6 @@
#include "MEM_guardedalloc.h"
#include "DNA_brush_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -117,8 +114,6 @@
#define USE_KEYMAP_ADD_HACK
/* proto */
-static void ui_but_smart_controller_add(bContext *C, uiBut *from, uiBut *to);
-static void ui_but_link_add(bContext *C, uiBut *from, uiBut *to);
static int ui_do_but_EXIT(bContext *C, uiBut *but, struct uiHandleButtonData *data, const wmEvent *event);
static bool ui_but_find_select_in_enum__cmp(const uiBut *but_a, const uiBut *but_b);
static void ui_textedit_string_set(uiBut *but, struct uiHandleButtonData *data, const char *str);
@@ -724,8 +719,7 @@ static void ui_apply_but_undo(uiBut *but)
const char *str = NULL;
/* define which string to use for undo */
- if (ELEM(but->type, UI_BTYPE_LINK, UI_BTYPE_INLINK)) str = "Add button link";
- else if (but->type == UI_BTYPE_MENU) str = but->drawstr;
+ if (but->type == UI_BTYPE_MENU) str = but->drawstr;
else if (but->drawstr[0]) str = but->drawstr;
else str = but->tip;
@@ -937,6 +931,20 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
data->applied = true;
}
+static void ui_apply_but_TAB(bContext *C, uiBut *but, uiHandleButtonData *data)
+{
+ if (data->str) {
+ ui_but_string_set(C, but, data->str);
+ ui_but_update_edited(but);
+ }
+ else {
+ ui_apply_but_func(C, but);
+ }
+
+ data->retval = but->retval;
+ data->applied = true;
+}
+
static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
{
if (data->str) {
@@ -1782,223 +1790,6 @@ static bool ui_but_drag_init(
/* ********************** linklines *********************** */
-static void ui_linkline_remove_active(uiBlock *block)
-{
- uiBut *but;
- uiLink *link;
- uiLinkLine *line, *nline;
- int a, b;
-
- for (but = block->buttons.first; but; but = but->next) {
- if (but->type == UI_BTYPE_LINK && but->link) {
- for (line = but->link->lines.first; line; line = nline) {
- nline = line->next;
-
- if (line->flag & UI_SELECT) {
- BLI_remlink(&but->link->lines, line);
-
- link = line->from->link;
-
- /* are there more pointers allowed? */
- if (link->ppoin) {
-
- if (*(link->totlink) == 1) {
- *(link->totlink) = 0;
- MEM_freeN(*(link->ppoin));
- *(link->ppoin) = NULL;
- }
- else {
- b = 0;
- for (a = 0; a < (*(link->totlink)); a++) {
-
- if ((*(link->ppoin))[a] != line->to->poin) {
- (*(link->ppoin))[b] = (*(link->ppoin))[a];
- b++;
- }
- }
- (*(link->totlink))--;
- }
- }
- else {
- *(link->poin) = NULL;
- }
-
- MEM_freeN(line);
- }
- }
- }
- }
-}
-
-
-static uiLinkLine *ui_but_find_link(uiBut *from, uiBut *to)
-{
- uiLinkLine *line;
- uiLink *link;
-
- link = from->link;
- if (link) {
- for (line = link->lines.first; line; line = line->next) {
- if (line->from == from && line->to == to) {
- return line;
- }
- }
- }
- return NULL;
-}
-
-/* XXX BAD BAD HACK, fixme later **************** */
-/* Try to add an AND Controller between the sensor and the actuator logic bricks and to connect them all */
-static void ui_but_smart_controller_add(bContext *C, uiBut *from, uiBut *to)
-{
- Object *ob = NULL;
- bSensor *sens_iter;
- bActuator *act_to, *act_iter;
- bController *cont;
- bController ***sens_from_links;
- uiBut *tmp_but;
-
- uiLink *link = from->link;
-
- PointerRNA props_ptr, object_ptr;
-
- if (link->ppoin)
- sens_from_links = (bController ***)(link->ppoin);
- else return;
-
- act_to = (bActuator *)(to->poin);
-
- /* (1) get the object */
- CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects)
- {
- for (sens_iter = ob_iter->sensors.first; sens_iter; sens_iter = sens_iter->next) {
- if (&(sens_iter->links) == sens_from_links) {
- ob = ob_iter;
- break;
- }
- }
- if (ob) break;
- } CTX_DATA_END;
-
- if (!ob) return;
-
- /* (2) check if the sensor and the actuator are from the same object */
- for (act_iter = ob->actuators.first; act_iter; act_iter = (bActuator *)act_iter->next) {
- if (act_iter == act_to)
- break;
- }
-
- /* only works if the sensor and the actuator are from the same object */
- if (!act_iter) return;
-
- /* in case the linked controller is not the active one */
- RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
-
- WM_operator_properties_create(&props_ptr, "LOGIC_OT_controller_add");
- RNA_string_set(&props_ptr, "object", ob->id.name + 2);
-
- /* (3) add a new controller */
- if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, &props_ptr) & OPERATOR_FINISHED) {
- cont = (bController *)ob->controllers.last;
- /* Quick fix to make sure we always have an AND controller.
- * It might be nicer to make sure the operator gives us the right one though... */
- cont->type = CONT_LOGIC_AND;
-
- /* (4) link the sensor->controller->actuator */
- tmp_but = MEM_callocN(sizeof(uiBut), "uiBut");
- UI_but_link_set(
- tmp_but, (void **)&cont, (void ***)&(cont->links),
- &cont->totlinks, from->link->tocode, (int)to->hardmin);
- tmp_but->hardmin = from->link->tocode;
- tmp_but->poin = (char *)cont;
-
- tmp_but->type = UI_BTYPE_INLINK;
- ui_but_link_add(C, from, tmp_but);
-
- tmp_but->type = UI_BTYPE_LINK;
- ui_but_link_add(C, tmp_but, to);
-
- /* (5) garbage collection */
- MEM_freeN(tmp_but->link);
- MEM_freeN(tmp_but);
- }
- WM_operator_properties_free(&props_ptr);
-}
-
-static void ui_but_link_add(bContext *C, uiBut *from, uiBut *to)
-{
- /* in 'from' we have to add a link to 'to' */
- uiLink *link;
- uiLinkLine *line;
- void **oldppoin;
- int a;
-
- if ((line = ui_but_find_link(from, to))) {
- line->flag |= UI_SELECT;
- ui_linkline_remove_active(from->block);
- return;
- }
-
- if (from->type == UI_BTYPE_INLINK && to->type == UI_BTYPE_INLINK) {
- return;
- }
- else if (from->type == UI_BTYPE_LINK && to->type == UI_BTYPE_INLINK) {
- if (from->link->tocode != (int)to->hardmin) {
- ui_but_smart_controller_add(C, from, to);
- return;
- }
- }
- else if (from->type == UI_BTYPE_INLINK && to->type == UI_BTYPE_LINK) {
- if (to->link->tocode == (int)from->hardmin) {
- return;
- }
- }
-
- link = from->link;
-
- /* are there more pointers allowed? */
- if (link->ppoin) {
- oldppoin = *(link->ppoin);
-
- (*(link->totlink))++;
- *(link->ppoin) = MEM_callocN(*(link->totlink) * sizeof(void *), "new link");
-
- for (a = 0; a < (*(link->totlink)) - 1; a++) {
- (*(link->ppoin))[a] = oldppoin[a];
- }
- (*(link->ppoin))[a] = to->poin;
-
- if (oldppoin) MEM_freeN(oldppoin);
- }
- else {
- *(link->poin) = to->poin;
- }
-
-}
-
-
-static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data)
-{
- ARegion *ar = CTX_wm_region(C);
- uiBut *bt;
-
- for (bt = but->block->buttons.first; bt; bt = bt->next) {
- if (ui_but_contains_point_px(ar, bt, but->linkto[0] + ar->winrct.xmin, but->linkto[1] + ar->winrct.ymin) )
- break;
- }
- if (bt && bt != but) {
- if (!ELEM(bt->type, UI_BTYPE_LINK, UI_BTYPE_INLINK) || !ELEM(but->type, UI_BTYPE_LINK, UI_BTYPE_INLINK))
- return;
-
- if (but->type == UI_BTYPE_LINK) ui_but_link_add(C, but, bt);
- else ui_but_link_add(C, bt, but);
-
- ui_apply_but_func(C, but);
- data->retval = but->retval;
- }
- data->applied = true;
-}
-
static void ui_apply_but_IMAGE(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
@@ -2115,9 +1906,11 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
break;
case UI_BTYPE_ROW:
case UI_BTYPE_LISTROW:
- case UI_BTYPE_TAB:
ui_apply_but_ROW(C, block, but, data);
break;
+ case UI_BTYPE_TAB:
+ ui_apply_but_TAB(C, but, data);
+ break;
case UI_BTYPE_SCROLL:
case UI_BTYPE_GRIP:
case UI_BTYPE_NUM:
@@ -2153,10 +1946,6 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
case UI_BTYPE_HOTKEY_EVENT:
ui_apply_but_BUT(C, but, data);
break;
- case UI_BTYPE_LINK:
- case UI_BTYPE_INLINK:
- ui_apply_but_LINK(C, but, data);
- break;
case UI_BTYPE_IMAGE:
ui_apply_but_IMAGE(C, but, data);
break;
@@ -3876,18 +3665,6 @@ static int ui_do_but_KEYEVT(
return WM_UI_HANDLER_CONTINUE;
}
-static int ui_do_but_TAB(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
-{
- if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
- button_activate_state(C, but, BUTTON_STATE_EXIT);
- return WM_UI_HANDLER_CONTINUE;
- }
- }
-
- return WM_UI_HANDLER_CONTINUE;
-}
-
static bool ui_but_is_mouse_over_icon_extra(const ARegion *region, uiBut *but, const int mouse_xy[2])
{
int x = mouse_xy[0], y = mouse_xy[1];
@@ -3903,6 +3680,43 @@ static bool ui_but_is_mouse_over_icon_extra(const ARegion *region, uiBut *but, c
return BLI_rcti_isect_pt(&icon_rect, x, y);
}
+static int ui_do_but_TAB(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
+{
+ if (data->state == BUTTON_STATE_HIGHLIGHT) {
+ if ((event->type == LEFTMOUSE) &&
+ ((event->val == KM_DBL_CLICK) || event->ctrl))
+ {
+ button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
+ return WM_UI_HANDLER_BREAK;
+ }
+ else if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && (event->val == KM_CLICK)) {
+ const bool has_icon_extra = ui_but_icon_extra_get(but) == UI_BUT_ICONEXTRA_CLEAR;
+
+ if (has_icon_extra && ui_but_is_mouse_over_icon_extra(data->region, but, &event->x)) {
+ uiButTab *tab = (uiButTab *)but;
+ wmOperatorType *ot_backup = but->optype;
+
+ but->optype = tab->unlink_ot;
+ /* Force calling unlink/delete operator. */
+ ui_apply_but(C, block, but, data, true);
+ but->optype = ot_backup;
+ }
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ return WM_UI_HANDLER_BREAK;
+ }
+ }
+ else if (data->state == BUTTON_STATE_TEXT_EDITING) {
+ ui_do_but_textedit(C, block, but, data, event);
+ return WM_UI_HANDLER_BREAK;
+ }
+ else if (data->state == BUTTON_STATE_TEXT_SELECTING) {
+ ui_do_but_textedit_select(C, block, but, data, event);
+ return WM_UI_HANDLER_BREAK;
+ }
+
+ return WM_UI_HANDLER_CONTINUE;
+}
+
static int ui_do_but_TEX(
bContext *C, uiBlock *block, uiBut *but,
uiHandleButtonData *data, const wmEvent *event)
@@ -6445,35 +6259,6 @@ static int ui_do_but_WAVEFORM(
return WM_UI_HANDLER_CONTINUE;
}
-static int ui_do_but_LINK(
- bContext *C, uiBut *but,
- uiHandleButtonData *data, const wmEvent *event)
-{
- VECCOPY2D(but->linkto, event->mval);
-
- if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
- button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE);
- return WM_UI_HANDLER_BREAK;
- }
- else if (event->type == LEFTMOUSE && but->block->handle) {
- button_activate_state(C, but, BUTTON_STATE_EXIT);
- return WM_UI_HANDLER_BREAK;
- }
- }
- else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
-
- if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
- if (!(but->flag & UI_SELECT))
- data->cancel = true;
- button_activate_state(C, but, BUTTON_STATE_EXIT);
- return WM_UI_HANDLER_BREAK;
- }
- }
-
- return WM_UI_HANDLER_CONTINUE;
-}
-
static bool ui_numedit_but_TRACKPREVIEW(
bContext *C, uiBut *but, uiHandleButtonData *data,
int mx, int my,
@@ -7202,7 +6987,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
retval = ui_do_but_HOTKEYEVT(C, but, data, event);
break;
case UI_BTYPE_TAB:
- retval = ui_do_but_TAB(C, but, data, event);
+ retval = ui_do_but_TAB(C, block, but, data, event);
break;
case UI_BTYPE_BUT_TOGGLE:
case UI_BTYPE_TOGGLE:
@@ -7289,10 +7074,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
case UI_BTYPE_HSVCIRCLE:
retval = ui_do_but_HSVCIRCLE(C, block, but, data, event);
break;
- case UI_BTYPE_LINK:
- case UI_BTYPE_INLINK:
- retval = ui_do_but_LINK(C, but, data, event);
- break;
case UI_BTYPE_TRACK_PREVIEW:
retval = ui_do_but_TRACKPREVIEW(C, block, but, data, event);
break;
@@ -7476,15 +7257,14 @@ bool ui_but_is_active(ARegion *ar)
/* is called by notifier */
void UI_screen_free_active_but(const bContext *C, bScreen *screen)
{
- ScrArea *sa = screen->areabase.first;
-
- for (; sa; sa = sa->next) {
- ARegion *ar = sa->regionbase.first;
- for (; ar; ar = ar->next) {
- uiBut *but = ui_but_find_active_in_region(ar);
+ wmWindow *win = CTX_wm_window(C);
+
+ ED_screen_areas_iter(win, screen, area) {
+ for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ uiBut *but = ui_but_find_active_in_region(region);
if (but) {
uiHandleButtonData *data = but->active;
-
+
if (data->menu == NULL && data->searchbox == NULL)
if (data->state == BUTTON_STATE_HIGHLIGHT)
ui_but_active_free(C, but);
@@ -8520,12 +8300,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
break;
}
case MOUSEMOVE:
- if (ELEM(but->type, UI_BTYPE_LINK, UI_BTYPE_INLINK)) {
- but->flag |= UI_SELECT;
- ui_do_button(C, block, but, event);
- ED_region_tag_redraw(ar);
- }
- else {
+ {
/* deselect the button when moving the mouse away */
/* also de-activate for buttons that only show higlights */
if (ui_but_contains_point_px(ar, but, event->x, event->y)) {
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 682eac6a352..6bcdc2f9266 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -35,6 +35,7 @@
#include "GPU_draw.h"
#include "GPU_matrix.h"
+#include "GPU_batch.h"
#include "GPU_immediate.h"
#include "BLI_blenlib.h"
@@ -98,6 +99,7 @@ typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
#define ICON_TYPE_TEXTURE 1
#define ICON_TYPE_BUFFER 2
#define ICON_TYPE_VECTOR 3
+#define ICON_TYPE_GEOM 4
typedef struct DrawInfo {
int type;
@@ -108,6 +110,9 @@ typedef struct DrawInfo {
VectorDrawFunc func;
} vector;
struct {
+ Gwn_Batch *batch;
+ } geom;
+ struct {
IconImage *image;
} buffer;
struct {
@@ -143,7 +148,7 @@ static DrawInfo *def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs,
new_icon = MEM_callocN(sizeof(Icon), "texicon");
new_icon->obj = NULL; /* icon is not for library object */
- new_icon->type = 0;
+ new_icon->id_type = 0;
di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
di->type = type;
@@ -195,7 +200,7 @@ static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
new_icon = MEM_callocN(sizeof(Icon), "texicon");
new_icon->obj = NULL; /* icon is not for library object */
- new_icon->type = 0;
+ new_icon->id_type = 0;
di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
di->type = ICON_TYPE_VECTOR;
@@ -742,21 +747,64 @@ void UI_icons_free_drawinfo(void *drawinfo)
MEM_freeN(di->data.buffer.image);
}
}
+ else if (di->type == ICON_TYPE_GEOM) {
+ if (di->data.geom.batch) {
+ GWN_BATCH_DISCARD_SAFE(di->data.geom.batch);
+ }
+ }
MEM_freeN(di);
}
}
-static DrawInfo *icon_create_drawinfo(void)
+/**
+ * #Icon.data_type and #Icon.obj
+ */
+static DrawInfo *icon_create_drawinfo(int icon_data_type, void *icon_obj)
{
DrawInfo *di = NULL;
di = MEM_callocN(sizeof(DrawInfo), "di_icon");
- di->type = ICON_TYPE_PREVIEW;
+
+ if (ELEM(icon_data_type, ICON_DATA_ID, ICON_DATA_PREVIEW)) {
+ di->type = ICON_TYPE_PREVIEW;
+ }
+ else if (icon_data_type == ICON_DATA_GEOM) {
+ di->type = ICON_TYPE_GEOM;
+
+ struct Icon_Geom *geom = icon_obj;
+ static Gwn_VertFormat format = {0};
+ static struct { uint pos, color; } attr_id;
+ if (format.attrib_ct == 0) {
+ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_U8, 2, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ attr_id.color = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ }
+ Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo, geom->coords_len * 3);
+ GWN_vertbuf_attr_fill(vbo, attr_id.pos, geom->coords);
+ GWN_vertbuf_attr_fill(vbo, attr_id.color, geom->colors);
+
+ Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO);
+ di->data.geom.batch = batch;
+ }
+ else {
+ BLI_assert(0);
+ }
return di;
}
+static DrawInfo *icon_ensure_drawinfo(Icon *icon)
+{
+ if (icon->drawinfo) {
+ return icon->drawinfo;
+ }
+ DrawInfo *di = icon_create_drawinfo(icon->obj_type, icon->obj);
+ icon->drawinfo = di;
+ icon->drawinfo_free = UI_icons_free_drawinfo;
+ return di;
+}
+
/* note!, returns unscaled by DPI */
int UI_icon_get_width(int icon_id)
{
@@ -771,40 +819,27 @@ int UI_icon_get_width(int icon_id)
return 0;
}
- di = (DrawInfo *)icon->drawinfo;
- if (!di) {
- di = icon_create_drawinfo();
- icon->drawinfo = di;
- }
-
- if (di)
+ di = icon_ensure_drawinfo(icon);
+ if (di) {
return ICON_DEFAULT_WIDTH;
+ }
return 0;
}
int UI_icon_get_height(int icon_id)
{
- Icon *icon = NULL;
- DrawInfo *di = NULL;
-
- icon = BKE_icon_get(icon_id);
-
+ Icon *icon = BKE_icon_get(icon_id);
if (icon == NULL) {
if (G.debug & G_DEBUG)
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return 0;
}
-
- di = (DrawInfo *)icon->drawinfo;
- if (!di) {
- di = icon_create_drawinfo();
- icon->drawinfo = di;
- }
-
- if (di)
+ DrawInfo *di = icon_ensure_drawinfo(icon);
+ if (di) {
return ICON_DEFAULT_HEIGHT;
+ }
return 0;
}
@@ -861,20 +896,13 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi
Icon *icon = BKE_icon_get(icon_id);
if (icon) {
- DrawInfo *di = (DrawInfo *)icon->drawinfo;
-
- if (!di) {
- di = icon_create_drawinfo();
-
- icon->drawinfo = di;
- icon->drawinfo_free = UI_icons_free_drawinfo;
- }
+ DrawInfo *di = icon_ensure_drawinfo(icon);
if (di) {
switch (di->type) {
case ICON_TYPE_PREVIEW:
{
- ID *id = (icon->type != 0) ? icon->obj : NULL;
+ ID *id = (icon->id_type != 0) ? icon->obj : NULL;
PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj;
/* Using jobs for screen previews crashes due to offscreen rendering.
* XXX would be nicer if PreviewImage could store if it supports jobs */
@@ -933,7 +961,7 @@ PreviewImage *UI_icon_to_preview(int icon_id)
DrawInfo *di = (DrawInfo *)icon->drawinfo;
if (di) {
if (di->type == ICON_TYPE_PREVIEW) {
- PreviewImage *prv = (icon->type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj;
+ PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj;
if (prv) {
return BKE_previewimg_copy(prv);
@@ -1028,7 +1056,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
* efficient than simple glUniform calls. */
#define ICON_DRAW_CACHE_SIZE 16
-typedef struct IconDrawCall{
+typedef struct IconDrawCall {
rctf pos;
rctf tex;
float color[4];
@@ -1183,7 +1211,6 @@ static void icon_draw_size(
{
bTheme *btheme = UI_GetTheme();
Icon *icon = NULL;
- DrawInfo *di = NULL;
IconImage *iimg;
const float fdraw_size = (float)draw_size;
int w, h;
@@ -1197,24 +1224,42 @@ static void icon_draw_size(
return;
}
- di = (DrawInfo *)icon->drawinfo;
-
- if (!di) {
- di = icon_create_drawinfo();
-
- icon->drawinfo = di;
- icon->drawinfo_free = UI_icons_free_drawinfo;
- }
-
/* scale width and height according to aspect */
w = (int)(fdraw_size / aspect + 0.5f);
h = (int)(fdraw_size / aspect + 0.5f);
-
+
+ DrawInfo *di = icon_ensure_drawinfo(icon);
+
if (di->type == ICON_TYPE_VECTOR) {
+ /* We need to flush widget base first to ensure correct ordering. */
+ UI_widgetbase_draw_cache_flush();
/* vector icons use the uiBlock transformation, they are not drawn
* with untransformed coordinates like the other icons */
di->data.vector.func((int)x, (int)y, w, h, 1.0f);
}
+ else if (di->type == ICON_TYPE_GEOM) {
+ /* We need to flush widget base first to ensure correct ordering. */
+ UI_widgetbase_draw_cache_flush();
+
+ gpuPushMatrix();
+ gpuTranslate2f(x, y);
+ gpuScale2f(w, h);
+
+ {
+ struct Gwn_Batch *batch = di->data.geom.batch;
+ GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_SMOOTH_COLOR_UNIFORM_ALPHA);
+ GWN_batch_uniform_1f(batch, "alpha", 1.0f / UI_PIXEL_AA_JITTER);
+
+ for (uint i = 0; i < UI_PIXEL_AA_JITTER; i += 1) {
+ gpuTranslate2f(ui_pixel_jitter[i][0] / w, ui_pixel_jitter[i][1] / h);
+ GWN_batch_draw(batch);
+ gpuTranslate2f(-ui_pixel_jitter[i][0] / w, -ui_pixel_jitter[i][1] / h);
+ }
+ GWN_batch_program_use_end(batch);
+ }
+
+ gpuPopMatrix();
+ }
else if (di->type == ICON_TYPE_TEXTURE) {
/* texture image use premul alpha for correct scaling */
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@@ -1235,7 +1280,7 @@ static void icon_draw_size(
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
else if (di->type == ICON_TYPE_PREVIEW) {
- PreviewImage *pi = (icon->type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj;
+ PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj;
if (pi) {
/* no create icon on this level in code */
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 043dfc9fd99..e71f36018e3 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -270,9 +270,6 @@ struct uiBut {
uiButHandleHoldFunc hold_func;
void *hold_argN;
- uiLink *link;
- short linkto[2]; /* region relative coords */
-
const char *tip;
uiButToolTipFunc tip_func;
void *tip_argN;
@@ -333,6 +330,11 @@ struct uiBut {
uiBlock *block;
};
+typedef struct uiButTab {
+ uiBut but;
+ struct wmOperatorType *unlink_ot;
+} uiButTab;
+
typedef struct ColorPicker {
struct ColorPicker *next, *prev;
float color_data[3]; /* colr data may be HSV or HSL for now */
@@ -451,8 +453,6 @@ typedef struct uiSafetyRct {
/* interface.c */
-extern void ui_linkline_remove(uiLinkLine *line, uiBut *but);
-
void ui_fontscale(short *points, float aspect);
extern bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
@@ -721,6 +721,7 @@ enum {
ROUNDBOX_TRIA_SCROLL,
ROUNDBOX_TRIA_MENU,
ROUNDBOX_TRIA_CHECK,
+ ROUNDBOX_TRIA_HOLD_ACTION_ARROW,
ROUNDBOX_TRIA_MAX, /* don't use */
};
@@ -753,6 +754,9 @@ void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *na
/* margin at top of screen for popups */
#define UI_POPUP_MENU_TOP (int)(8 * UI_DPI_FAC)
+#define UI_PIXEL_AA_JITTER 8
+const float ui_pixel_jitter[UI_PIXEL_AA_JITTER][2];
+
/* interface_style.c */
void uiStyleInit(void);
@@ -774,7 +778,7 @@ void ui_layout_list_set_labels_active(uiLayout *layout);
/* interface_align.c */
bool ui_but_can_align(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
-void ui_block_align_calc(uiBlock *block);
+void ui_block_align_calc(uiBlock *block, const ARegion *region);
/* interface_anim.c */
void ui_but_anim_flag(uiBut *but, float cfra);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 969367f485c..7193ad64359 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -392,7 +392,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
static void ui_item_array(
uiLayout *layout, uiBlock *block, const char *name, int icon,
PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int UNUSED(h),
- bool expand, bool slider, bool toggle, bool icon_only)
+ bool expand, bool slider, bool toggle, bool icon_only, bool compact)
{
uiStyle *style = layout->root->style;
uiBut *but;
@@ -541,9 +541,18 @@ static void ui_item_array(
}
for (a = 0; a < len; a++) {
- if (!icon_only) str[0] = RNA_property_array_item_char(prop, a);
- if (boolarr) icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
- but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, w, UI_UNIT_Y);
+ int width_item;
+
+ if (!icon_only) {
+ str[0] = RNA_property_array_item_char(prop, a);
+ }
+ if (boolarr) {
+ icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
+ }
+ width_item = (compact && type == PROP_BOOLEAN) ?
+ min_ii(w, ui_text_icon_width(layout, str, icon, false)) : w;
+
+ but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, width_item, UI_UNIT_Y);
if (slider && but->type == UI_BTYPE_NUM)
but->type = UI_BTYPE_NUM_SLIDER;
if (toggle && but->type == UI_BTYPE_CHECKBOX)
@@ -669,27 +678,38 @@ static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_
RNA_boolean_set(&but->rnapoin, "oskey", (but->modifier_key & KM_OSKEY) != 0);
}
-/* create label + button for RNA property */
-static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h, int flag)
+/**
+ * Create label + button for RNA property
+ *
+ * \param w_hint: For varying width layout, this becomes the label width.
+ * Otherwise it's used to fit both items into it.
+ **/
+static uiBut *ui_item_with_label(
+ uiLayout *layout, uiBlock *block, const char *name, int icon,
+ PointerRNA *ptr, PropertyRNA *prop, int index,
+ int x, int y, int w_hint, int h, int flag)
{
uiLayout *sub;
uiBut *but = NULL;
PropertyType type;
PropertySubType subtype;
- int labelw;
+ int prop_but_width = w_hint;
sub = uiLayoutRow(layout, layout->align);
UI_block_layout_set_current(block, sub);
if (name[0]) {
- /* XXX UI_fontstyle_string_width is not accurate */
-#if 0
- labelw = UI_fontstyle_string_width(fstyle, name);
- CLAMP(labelw, w / 4, 3 * w / 4);
-#endif
- labelw = w / 3;
- uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, labelw, h, NULL, 0.0, 0.0, 0, 0, "");
- w = w - labelw;
+ int w_label;
+
+ if (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
+ /* w_hint is width for label in this case. Use a default width for property button(s) */
+ prop_but_width = UI_UNIT_X * 5;
+ w_label = w_hint;
+ }
+ else {
+ w_label = w_hint / 3;
+ }
+ uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, "");
}
type = RNA_property_type(prop);
@@ -697,14 +717,14 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
UI_block_layout_set_current(block, uiLayoutRow(sub, true));
- but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w - UI_UNIT_X, h);
+ but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, prop_but_width - UI_UNIT_X, h);
/* BUTTONS_OT_file_browse calls UI_context_active_but_prop_get_filebrowser */
uiDefIconButO(block, UI_BTYPE_BUT, subtype == PROP_DIRPATH ? "BUTTONS_OT_directory_browse" : "BUTTONS_OT_file_browse",
WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL);
}
else if (flag & UI_ITEM_R_EVENT) {
- but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL);
+ but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, prop_but_width, h, ptr, prop, index, 0, 0, -1, -1, NULL);
}
else if (flag & UI_ITEM_R_FULL_EVENT) {
if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) {
@@ -712,14 +732,17 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
WM_keymap_item_to_string(ptr->data, false, buf, sizeof(buf));
- but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, w, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
+ but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, prop_but_width, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
UI_but_func_set(but, ui_keymap_but_cb, but, NULL);
if (flag & UI_ITEM_R_IMMEDIATE)
UI_but_flag_enable(but, UI_BUT_IMMEDIATE);
}
}
- else
- but = uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "", icon, x, y, w, h);
+ else {
+ const char *str = (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "";
+ but = uiDefAutoButR(block, ptr, prop, index, str, icon,
+ x, y, prop_but_width, h);
+ }
UI_block_layout_set_current(block, layout);
return but;
@@ -1302,8 +1325,10 @@ void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
/* RNA property items */
static void ui_item_rna_size(
- uiLayout *layout, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop,
- int index, bool icon_only, int *r_w, int *r_h)
+ uiLayout *layout, const char *name, int icon,
+ PointerRNA *ptr, PropertyRNA *prop,
+ int index, bool icon_only, bool compact,
+ int *r_w, int *r_h)
{
PropertyType type;
PropertySubType subtype;
@@ -1329,7 +1354,7 @@ static void ui_item_rna_size(
RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free);
for (item = item_array; item->identifier; item++) {
if (item->identifier[0]) {
- w = max_ii(w, ui_text_icon_width(layout, item->name, item->icon, 0));
+ w = max_ii(w, ui_text_icon_width(layout, item->name, item->icon, compact));
}
}
if (free) {
@@ -1340,12 +1365,13 @@ static void ui_item_rna_size(
if (!w) {
if (type == PROP_ENUM && icon_only) {
- w = ui_text_icon_width(layout, "", ICON_BLANK1, 0);
+ w = ui_text_icon_width(layout, "", ICON_BLANK1, compact);
if (index != RNA_ENUM_VALUE)
w += 0.6f * UI_UNIT_X;
}
else {
- w = ui_text_icon_width(layout, name, icon, 0);
+ /* not compact for float/int buttons, looks too squashed */
+ w = ui_text_icon_width(layout, name, icon, ELEM(type, PROP_FLOAT, PROP_INT) ? false : compact);
}
}
h = UI_UNIT_Y;
@@ -1382,7 +1408,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
PropertyType type;
char namestr[UI_MAX_NAME_STR];
int len, w, h;
- bool slider, toggle, expand, icon_only, no_bg;
+ bool slider, toggle, expand, icon_only, no_bg, compact;
bool is_array;
UI_block_layout_set_current(block, layout);
@@ -1415,7 +1441,12 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
name = ui_item_name_add_colon(name, namestr);
}
else if (type == PROP_ENUM && index != RNA_ENUM_VALUE) {
- name = ui_item_name_add_colon(name, namestr);
+ if (flag & UI_ITEM_R_COMPACT) {
+ name = "";
+ }
+ else {
+ name = ui_item_name_add_colon(name, namestr);
+ }
}
/* menus and pie-menus don't show checkbox without this */
@@ -1443,16 +1474,19 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
expand = (flag & UI_ITEM_R_EXPAND) != 0;
icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
no_bg = (flag & UI_ITEM_R_NO_BG) != 0;
+ compact = (flag & UI_ITEM_R_COMPACT) != 0;
/* get size */
- ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, &w, &h);
+ ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, compact, &w, &h);
if (no_bg)
UI_block_emboss_set(block, UI_EMBOSS_NONE);
/* array property */
if (index == RNA_NO_INDEX && is_array)
- ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only);
+ ui_item_array(
+ layout, block, name, icon, ptr, prop, len, 0, 0, w, h,
+ expand, slider, toggle, icon_only, compact);
/* enum item */
else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
if (icon && name[0] && !icon_only)
@@ -1641,6 +1675,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
/* Pointer RNA button with search */
+
static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA **prop)
{
StructRNA *srna;
@@ -1771,7 +1806,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
/* create button */
block = uiLayoutGetBlock(layout);
- ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, &w, &h);
+ ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, false, &w, &h);
w += UI_UNIT_X; /* X icon needs more space */
but = ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 375027a84d0..8cb2ae92bad 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -70,7 +70,6 @@
#include "BKE_particle.h"
#include "BKE_paint.h"
#include "BKE_report.h"
-#include "BKE_sca.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
@@ -121,7 +120,9 @@ static void template_add_button_search_menu(
if (use_previews) {
ARegion *region = CTX_wm_region(C);
- const bool use_big_size = (region->regiontype != RGN_TYPE_HEADER); /* silly check, could be more generic */
+ ScrArea *area = CTX_wm_area(C);
+ /* XXX ugly top-bar exception */
+ const bool use_big_size = (region->regiontype != RGN_TYPE_HEADER) && (area->spacetype != SPACE_TOPBAR); /* silly check, could be more generic */
/* Ugly exception for screens here, drawing their preview in icon size looks ugly/useless */
const bool use_preview_icon = use_big_size || (id && (GS(id->name) != ID_SCR));
const short width = UI_UNIT_X * (use_big_size ? 6 : 1.6f);
@@ -239,7 +240,7 @@ typedef struct TemplateID {
} TemplateID;
/* Search browse menu, assign */
-static void id_search_call_cb(bContext *C, void *arg_template, void *item)
+static void template_ID_set_property_cb(bContext *C, void *arg_template, void *item)
{
TemplateID *template_ui = (TemplateID *)arg_template;
@@ -380,7 +381,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
}
return template_common_search_menu(
- C, ar, id_search_cb_p, &template_ui, id_search_call_cb, active_item_ptr.data,
+ C, ar, id_search_cb_p, &template_ui, template_ID_set_property_cb, active_item_ptr.data,
template_ui.prv_rows, template_ui.prv_cols);
}
@@ -571,6 +572,68 @@ static const char *template_id_context(StructRNA *type)
}
#endif
+static uiBut *template_id_def_new_but(
+ uiBlock *block, const ID *id, const TemplateID *template_ui, StructRNA *type,
+ const char * const newop, const bool editable, const bool id_open, const bool use_tab_but,
+ int but_height)
+{
+ ID *idfrom = template_ui->ptr.id.data;
+ uiBut *but;
+ const int w = id ? UI_UNIT_X : id_open ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
+ const int but_type = use_tab_but ? UI_BTYPE_TAB : UI_BTYPE_BUT;
+
+ /* i18n markup, does nothing! */
+ BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_DEFAULT,
+ BLT_I18NCONTEXT_ID_SCENE,
+ BLT_I18NCONTEXT_ID_OBJECT,
+ BLT_I18NCONTEXT_ID_MESH,
+ BLT_I18NCONTEXT_ID_CURVE,
+ BLT_I18NCONTEXT_ID_METABALL,
+ BLT_I18NCONTEXT_ID_MATERIAL,
+ BLT_I18NCONTEXT_ID_TEXTURE,
+ BLT_I18NCONTEXT_ID_IMAGE,
+ BLT_I18NCONTEXT_ID_LATTICE,
+ BLT_I18NCONTEXT_ID_LAMP,
+ BLT_I18NCONTEXT_ID_CAMERA,
+ BLT_I18NCONTEXT_ID_WORLD,
+ BLT_I18NCONTEXT_ID_SCREEN,
+ BLT_I18NCONTEXT_ID_TEXT,
+ );
+ BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_ID_SPEAKER,
+ BLT_I18NCONTEXT_ID_SOUND,
+ BLT_I18NCONTEXT_ID_ARMATURE,
+ BLT_I18NCONTEXT_ID_ACTION,
+ BLT_I18NCONTEXT_ID_NODETREE,
+ BLT_I18NCONTEXT_ID_BRUSH,
+ BLT_I18NCONTEXT_ID_PARTICLESETTINGS,
+ BLT_I18NCONTEXT_ID_GPENCIL,
+ BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE,
+ BLT_I18NCONTEXT_ID_WORKSPACE,
+ BLT_I18NCONTEXT_ID_LIGHTPROBE,
+ );
+
+ if (newop) {
+ but = uiDefIconTextButO(block, but_type, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
+ (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, but_height, NULL);
+ UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
+ }
+ else {
+ but = uiDefIconTextBut(block, but_type, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"),
+ 0, 0, w, but_height, NULL, 0, 0, 0, 0, NULL);
+ UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
+ }
+
+ if ((idfrom && idfrom->lib) || !editable) {
+ UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
+
+#ifndef WITH_INTERNATIONAL
+ UNUSED_VARS(type);
+#endif
+
+ return but;
+}
+
static void template_ID(
bContext *C, uiLayout *layout, TemplateID *template_ui, StructRNA *type, int flag,
const char *newop, const char *openop, const char *unlinkop)
@@ -673,51 +736,7 @@ static void template_ID(
}
if (flag & UI_ID_ADD_NEW) {
- int w = id ? UI_UNIT_X : (flag & UI_ID_OPEN) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
-
- /* i18n markup, does nothing! */
- BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_DEFAULT,
- BLT_I18NCONTEXT_ID_SCENE,
- BLT_I18NCONTEXT_ID_OBJECT,
- BLT_I18NCONTEXT_ID_MESH,
- BLT_I18NCONTEXT_ID_CURVE,
- BLT_I18NCONTEXT_ID_METABALL,
- BLT_I18NCONTEXT_ID_MATERIAL,
- BLT_I18NCONTEXT_ID_TEXTURE,
- BLT_I18NCONTEXT_ID_IMAGE,
- BLT_I18NCONTEXT_ID_LATTICE,
- BLT_I18NCONTEXT_ID_LAMP,
- BLT_I18NCONTEXT_ID_CAMERA,
- BLT_I18NCONTEXT_ID_WORLD,
- BLT_I18NCONTEXT_ID_SCREEN,
- BLT_I18NCONTEXT_ID_TEXT,
- );
- BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_ID_SPEAKER,
- BLT_I18NCONTEXT_ID_SOUND,
- BLT_I18NCONTEXT_ID_ARMATURE,
- BLT_I18NCONTEXT_ID_ACTION,
- BLT_I18NCONTEXT_ID_NODETREE,
- BLT_I18NCONTEXT_ID_BRUSH,
- BLT_I18NCONTEXT_ID_PARTICLESETTINGS,
- BLT_I18NCONTEXT_ID_GPENCIL,
- BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE,
- BLT_I18NCONTEXT_ID_WORKSPACE,
- BLT_I18NCONTEXT_ID_LIGHTPROBE,
- );
-
- if (newop) {
- but = uiDefIconTextButO(block, UI_BTYPE_BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
- (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL);
- UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
- }
- else {
- but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"),
- 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
- UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
- }
-
- if ((idfrom && idfrom->lib) || !editable)
- UI_but_flag_enable(but, UI_BUT_DISABLED);
+ template_id_def_new_but(block, id, template_ui, type, newop, editable, flag & UI_ID_OPEN, false, UI_UNIT_X);
}
/* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack.
@@ -786,9 +805,58 @@ static void template_ID(
UI_block_align_end(block);
}
+static void template_ID_tabs(
+ bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag,
+ const char *newop, const char *UNUSED(openop), const char *unlinkop)
+{
+ const ARegion *region = CTX_wm_region(C);
+ const PointerRNA active_ptr = RNA_property_pointer_get(&template->ptr, template->prop);
+ const int but_align = (region->alignment == RGN_ALIGN_TOP) ? UI_BUT_ALIGN_DOWN : UI_BUT_ALIGN_TOP;
+ const int but_height = UI_UNIT_Y * 1.1;
+
+ uiBlock *block = uiLayoutGetBlock(layout);
+ uiStyle *style = UI_style_get_dpi();
+
+
+ for (ID *id = template->idlb->first; id; id = id->next) {
+ wmOperatorType *unlink_ot = WM_operatortype_find(unlinkop, false);
+ const bool is_active = active_ptr.data == id;
+ const unsigned int but_width = UI_fontstyle_string_width(&style->widgetlabel, id->name + 2) + UI_UNIT_X +
+ (is_active ? ICON_DEFAULT_WIDTH_SCALE : 0);
+ uiButTab *tab;
+
+ tab = (uiButTab *)uiDefButR_prop(
+ block, UI_BTYPE_TAB, 0, "", 0, 0, but_width, UI_UNIT_Y * 1.1,
+ &template->ptr, template->prop, 0, 0.0f,
+ sizeof(id->name) - 2, 0.0f, 0.0f, "");
+ UI_but_funcN_set(&tab->but, template_ID_set_property_cb, MEM_dupallocN(template), id);
+ tab->but.custom_data = (void *)id;
+ tab->unlink_ot = unlink_ot;
+
+ if (is_active) {
+ UI_but_flag_enable(&tab->but, UI_BUT_VALUE_CLEAR);
+ }
+ UI_but_drawflag_enable(&tab->but, but_align);
+ }
+
+ if (flag & UI_ID_ADD_NEW) {
+ const bool editable = RNA_property_editable(&template->ptr, template->prop);
+ uiBut *but;
+
+ if (active_ptr.type) {
+ type = active_ptr.type;
+ }
+
+ but = template_id_def_new_but(block, active_ptr.data, template, type, newop, editable, flag & UI_ID_OPEN, true, but_height);
+ UI_but_drawflag_enable(but, but_align);
+ }
+}
+
static void ui_template_id(
- uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
- const char *openop, const char *unlinkop, int flag, int prv_rows, int prv_cols, int filter)
+ uiLayout *layout, bContext *C,
+ PointerRNA *ptr, const char *propname,
+ const char *newop, const char *openop, const char *unlinkop,
+ int flag, int prv_rows, int prv_cols, int filter, bool use_tabs)
{
TemplateID *template_ui;
PropertyRNA *prop;
@@ -829,8 +897,14 @@ static void ui_template_id(
* - template_ID makes a copy of the template data and assigns it to the relevant buttons
*/
if (template_ui->idlb) {
- uiLayoutRow(layout, true);
- template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop);
+ if (use_tabs) {
+ uiLayoutRow(layout, true);
+ template_ID_tabs(C, layout, template_ui, type, flag, newop, openop, unlinkop);
+ }
+ else {
+ uiLayoutRow(layout, true);
+ template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop);
+ }
}
MEM_freeN(template_ui);
@@ -840,23 +914,49 @@ void uiTemplateID(
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
const char *openop, const char *unlinkop, int filter)
{
- ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop,
- UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, 0, 0, filter);
+ ui_template_id(
+ layout, C, ptr, propname,
+ newop, openop, unlinkop,
+ UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
+ 0, 0, filter, false);
}
void uiTemplateIDBrowse(
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
const char *openop, const char *unlinkop, int filter)
{
- ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME, 0, 0, filter);
+ ui_template_id(
+ layout, C, ptr, propname,
+ newop, openop, unlinkop,
+ UI_ID_BROWSE | UI_ID_RENAME,
+ 0, 0, filter, false);
}
void uiTemplateIDPreview(
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
const char *openop, const char *unlinkop, int rows, int cols, int filter)
{
- ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop,
- UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, rows, cols, filter);
+ ui_template_id(
+ layout, C, ptr, propname,
+ newop, openop, unlinkop,
+ UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS,
+ rows, cols, filter, false);
+}
+
+/**
+ * Version of #uiTemplateID using tabs.
+ */
+void uiTemplateIDTabs(
+ uiLayout *layout, bContext *C,
+ PointerRNA *ptr, const char *propname,
+ const char *newop, const char *openop, const char *unlinkop,
+ int filter)
+{
+ ui_template_id(
+ layout, C, ptr, propname,
+ newop, openop, unlinkop,
+ UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
+ 0, 0, filter, true);
}
/************************ ID Chooser Template ***************************/
@@ -1316,8 +1416,7 @@ static uiLayout *draw_modifier(
UI_block_emboss_set(block, UI_EMBOSS_NONE);
/* When Modifier is a simulation, show button to switch to context rather than the delete button. */
if (modifier_can_delete(md) &&
- (!modifier_is_simulation(md) ||
- STREQ(scene->view_render.engine_id, RE_engine_id_BLENDER_GAME)))
+ !modifier_is_simulation(md))
{
uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove");
}
@@ -1431,6 +1530,63 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
return NULL;
}
+
+/************************ Redo Buttons Template *************************/
+
+#ifdef WITH_REDO_REGION_REMOVAL
+static bool template_operator_redo_property_buts_poll(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
+{
+ return (RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED) == 0;
+}
+
+static void template_operator_redo_property_buts_draw(
+ const bContext *C, wmOperator *op,
+ uiLayout *layout, int layout_flags,
+ bool *r_has_advanced)
+{
+ if (op->type->flag & OPTYPE_MACRO) {
+ for (wmOperator *macro_op = op->macro.first; macro_op; macro_op = macro_op->next) {
+ template_operator_redo_property_buts_draw(C, macro_op, layout, layout_flags, r_has_advanced);
+ }
+ }
+ else {
+ /* Might want to make label_align adjustable somehow. */
+ eAutoPropButsReturn return_info = uiTemplateOperatorPropertyButs(
+ C, layout, op, template_operator_redo_property_buts_poll,
+ UI_BUT_LABEL_ALIGN_NONE, layout_flags);
+ if (return_info & UI_PROP_BUTS_ANY_FAILED_CHECK) {
+ *r_has_advanced = true;
+ }
+ }
+}
+
+void uiTemplateOperatorRedoProperties(uiLayout *layout, bContext *C)
+{
+ wmOperator *op = WM_operator_last_redo(C);
+ uiBlock *block = uiLayoutGetBlock(layout);
+
+ if (op == NULL) {
+ return;
+ }
+
+ /* Repeat button with operator name as text. */
+ uiItemFullO(layout, "SCREEN_OT_repeat_last", RNA_struct_ui_name(op->type->srna),
+ ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL);
+
+ if (WM_operator_repeat_check(C, op)) {
+ bool has_advanced = false;
+
+ UI_block_func_set(block, ED_undo_operator_repeat_cb, op, NULL);
+ template_operator_redo_property_buts_draw(C, op, layout, UI_TEMPLATE_OP_PROPS_COMPACT, &has_advanced);
+ UI_block_func_set(block, NULL, NULL, NULL); /* may want to reset to old state instead of NULLing all */
+
+ if (has_advanced) {
+ uiItemO(layout, IFACE_("More..."), ICON_NONE, "SCREEN_OT_redo_last");
+ }
+ }
+}
+#endif
+
/************************ Constraint Template *************************/
#include "DNA_constraint_types.h"
@@ -2927,77 +3083,6 @@ void uiTemplateLayers(
}
}
-void uiTemplateGameStates(
- uiLayout *layout, PointerRNA *ptr, const char *propname,
- PointerRNA *used_ptr, const char *used_propname, int active_state)
-{
- uiLayout *uRow, *uCol;
- PropertyRNA *prop, *used_prop = NULL;
- int groups, cols, states;
- int group, col, state, row;
- int cols_per_group = 5;
- Object *ob = (Object *)ptr->id.data;
-
- prop = RNA_struct_find_property(ptr, propname);
- if (!prop) {
- RNA_warning("states property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
- return;
- }
-
- /* the number of states determines the way we group them
- * - we want 2 rows only (for now)
- * - the number of columns (cols) is the total number of buttons per row
- * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
- * - for now, only split into groups if group will have at least 5 items
- */
- states = RNA_property_array_length(ptr, prop);
- cols = (states / 2) + (states % 2);
- groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group);
-
- if (used_ptr && used_propname) {
- used_prop = RNA_struct_find_property(used_ptr, used_propname);
- if (!used_prop) {
- RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname);
- return;
- }
-
- if (RNA_property_array_length(used_ptr, used_prop) < states)
- used_prop = NULL;
- }
-
- /* layers are laid out going across rows, with the columns being divided into groups */
-
- for (group = 0; group < groups; group++) {
- uCol = uiLayoutColumn(layout, true);
-
- for (row = 0; row < 2; row++) {
- uiBlock *block;
- uiBut *but;
-
- uRow = uiLayoutRow(uCol, true);
- block = uiLayoutGetBlock(uRow);
- state = groups * cols_per_group * row + cols_per_group * group;
-
- /* add layers as toggle buts */
- for (col = 0; (col < cols_per_group) && (state < states); col++, state++) {
- int icon = 0;
- int butlay = 1 << state;
-
- if (active_state & butlay)
- icon = ICON_LAYER_ACTIVE;
- else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, state))
- icon = ICON_LAYER_USED;
-
- but = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop,
- state, 0, 0, -1, -1, sca_state_name_get(ob, state));
- UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state));
- but->type = UI_BTYPE_TOGGLE;
- }
- }
- }
-}
-
-
/************************* List Template **************************/
static void uilist_draw_item_default(
struct uiList *ui_list, struct bContext *UNUSED(C), struct uiLayout *layout,
@@ -3789,11 +3874,14 @@ static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt,
* Draw Operator property buttons for redoing execution with different settings.
* This function does not initialize the layout, functions can be called on the layout before and after.
*/
-void uiTemplateOperatorPropertyButs(
+eAutoPropButsReturn uiTemplateOperatorPropertyButs(
const bContext *C, uiLayout *layout, wmOperator *op,
bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
- const char label_align, const short flag)
+ const eButLabelAlign label_align, const short flag)
{
+ uiBlock *block = uiLayoutGetBlock(layout);
+ eAutoPropButsReturn return_info = 0;
+
if (!op->properties) {
IDPropertyTemplate val = {0};
op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
@@ -3806,14 +3894,14 @@ void uiTemplateOperatorPropertyButs(
/* poll() on this operator may still fail, at the moment there is no nice feedback when this happens
* just fails silently */
if (!WM_operator_repeat_check(C, op)) {
- UI_block_lock_set(uiLayoutGetBlock(layout), true, "Operator can't' redo");
+ UI_block_lock_set(block, true, "Operator can't' redo");
/* XXX, could give some nicer feedback or not show redo panel at all? */
uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE);
}
else {
/* useful for macros where only one of the steps can't be re-done */
- UI_block_lock_clear(uiLayoutGetBlock(layout));
+ UI_block_lock_clear(block);
}
/* menu */
@@ -3822,7 +3910,7 @@ void uiTemplateOperatorPropertyButs(
PointerRNA op_ptr;
uiLayout *row;
- uiLayoutGetBlock(layout)->ui_operator = op;
+ block->ui_operator = op;
row = uiLayoutRow(layout, true);
uiItemM(row, (bContext *)C, "WM_MT_operator_presets", NULL, ICON_NONE);
@@ -3841,19 +3929,19 @@ void uiTemplateOperatorPropertyButs(
op->type->ui((bContext *)C, op);
op->layout = NULL;
- /* UI_LAYOUT_OP_SHOW_EMPTY ignored */
+ /* UI_LAYOUT_OP_SHOW_EMPTY ignored. return_info is ignored too. We could
+ * allow ot.ui callback to return this, but not needed right now. */
}
else {
wmWindowManager *wm = CTX_wm_manager(C);
PointerRNA ptr;
- int empty;
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* main draw call */
- empty = uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0;
+ return_info = uiDefAutoButsRNA(layout, &ptr, check_prop, label_align, (flag & UI_TEMPLATE_OP_PROPS_COMPACT));
- if (empty && (flag & UI_TEMPLATE_OP_PROPS_SHOW_EMPTY)) {
+ if ((return_info & UI_PROP_BUTS_NONE_ADDED) && (flag & UI_TEMPLATE_OP_PROPS_SHOW_EMPTY)) {
uiItemL(layout, IFACE_("No Properties"), ICON_NONE);
}
}
@@ -3863,7 +3951,6 @@ void uiTemplateOperatorPropertyButs(
* but this is not so important if this button is drawn in those cases
* (which isn't all that likely anyway) - campbell */
if (op->properties->len) {
- uiBlock *block;
uiBut *but;
uiLayout *col; /* needed to avoid alignment errors with previous buttons */
@@ -3877,7 +3964,6 @@ void uiTemplateOperatorPropertyButs(
/* set various special settings for buttons */
{
- uiBlock *block = uiLayoutGetBlock(layout);
const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0;
uiBut *but;
@@ -3897,6 +3983,8 @@ void uiTemplateOperatorPropertyButs(
}
}
}
+
+ return return_info;
}
/************************* Running Jobs Template **************************/
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index f0317087ddc..f28da5a666b 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -157,62 +157,72 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
* \a check_prop callback filters functions to avoid drawing certain properties,
* in cases where PROP_HIDDEN flag can't be used for a property.
*/
-int uiDefAutoButsRNA(
+eAutoPropButsReturn uiDefAutoButsRNA(
uiLayout *layout, PointerRNA *ptr,
bool (*check_prop)(PointerRNA *, PropertyRNA *),
- const char label_align)
+ const eButLabelAlign label_align, const bool compact)
{
+ eAutoPropButsReturn return_info = UI_PROP_BUTS_NONE_ADDED;
uiLayout *split, *col;
int flag;
const char *name;
- int tot = 0;
-
- assert(ELEM(label_align, '\0', 'H', 'V'));
RNA_STRUCT_BEGIN (ptr, prop)
{
flag = RNA_property_flag(prop);
- if (flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop) == 0))
+
+ if (flag & PROP_HIDDEN) {
+ continue;
+ }
+ if (check_prop && check_prop(ptr, prop) == 0) {
+ return_info |= UI_PROP_BUTS_ANY_FAILED_CHECK;
continue;
+ }
- if (label_align != '\0') {
- PropertyType type = RNA_property_type(prop);
- const bool is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
+ switch (label_align) {
+ case UI_BUT_LABEL_ALIGN_COLUMN:
+ case UI_BUT_LABEL_ALIGN_SPLIT_COLUMN:
+ {
+ PropertyType type = RNA_property_type(prop);
+ const bool is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
- name = RNA_property_ui_name(prop);
+ name = RNA_property_ui_name(prop);
- if (label_align == 'V') {
- col = uiLayoutColumn(layout, true);
+ if (label_align == UI_BUT_LABEL_ALIGN_COLUMN) {
+ col = uiLayoutColumn(layout, true);
- if (!is_boolean)
- uiItemL(col, name, ICON_NONE);
- }
- else { /* (label_align == 'H') */
- BLI_assert(label_align == 'H');
- split = uiLayoutSplit(layout, 0.5f, false);
+ if (!is_boolean)
+ uiItemL(col, name, ICON_NONE);
+ }
+ else {
+ BLI_assert(label_align == UI_BUT_LABEL_ALIGN_SPLIT_COLUMN);
+ split = uiLayoutSplit(layout, 0.5f, false);
- col = uiLayoutColumn(split, false);
- uiItemL(col, (is_boolean) ? "" : name, ICON_NONE);
- col = uiLayoutColumn(split, false);
- }
+ col = uiLayoutColumn(split, false);
+ uiItemL(col, (is_boolean) ? "" : name, ICON_NONE);
+ col = uiLayoutColumn(split, false);
+ }
- /* may meed to add more cases here.
- * don't override enum flag names */
+ /* may meed to add more cases here.
+ * don't override enum flag names */
- /* name is shown above, empty name for button below */
- name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
- }
- else {
- col = layout;
- name = NULL; /* no smart label alignment, show default name with button */
+ /* name is shown above, empty name for button below */
+ name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
+
+ break;
+ }
+ case UI_BUT_LABEL_ALIGN_NONE:
+ col = layout;
+ name = NULL; /* no smart label alignment, show default name with button */
+ break;
}
- uiItemFullR(col, ptr, prop, -1, 0, 0, name, ICON_NONE);
- tot++;
+ uiItemFullR(col, ptr, prop, -1, 0, compact ? UI_ITEM_R_COMPACT : 0, name, ICON_NONE);
+ return_info &= ~UI_PROP_BUTS_NONE_ADDED;
}
RNA_STRUCT_END;
- return tot;
+ return return_info;
}
/* *** RNA collection search menu *** */
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 5a210d01f27..e5e89260ed5 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -157,13 +157,15 @@ static const float cornervec[WIDGET_CURVE_RESOLU][2] = {
{0.924, 0.617}, {0.98, 0.805}, {1.0, 1.0}
};
-#define WIDGET_AA_JITTER 8
-static const float jit[WIDGET_AA_JITTER][2] = {
+
+const float ui_pixel_jitter[UI_PIXEL_AA_JITTER][2] = {
{ 0.468813, -0.481430}, {-0.155755, -0.352820},
{ 0.219306, -0.238501}, {-0.393286, -0.110949},
{-0.024699, 0.013908}, { 0.343805, 0.147431},
{-0.272855, 0.269918}, { 0.095909, 0.388710}
};
+#define WIDGET_AA_JITTER UI_PIXEL_AA_JITTER
+#define jit ui_pixel_jitter
/* -------------------------------------------------------------------- */
/** \name Shape Preset Data
@@ -221,8 +223,22 @@ static const uint g_shape_preset_hold_action_face[2][3] = {{2, 0, 1}, {3, 5, 4}}
**/
/* offset in triavec[] in shader per type */
-static const int tria_ofs[ROUNDBOX_TRIA_MAX] = {0, 0, 6, 22, 28};
-static const int tria_vcount[ROUNDBOX_TRIA_MAX] = {0, 3, 16, 3, 6};
+static const int tria_ofs[ROUNDBOX_TRIA_MAX] = {
+ [ROUNDBOX_TRIA_NONE] = 0,
+ [ROUNDBOX_TRIA_ARROWS] = 0,
+ [ROUNDBOX_TRIA_SCROLL] = 6,
+ [ROUNDBOX_TRIA_MENU] = 22,
+ [ROUNDBOX_TRIA_CHECK] = 28,
+ [ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 34,
+};
+static const int tria_vcount[ROUNDBOX_TRIA_MAX] = {
+ [ROUNDBOX_TRIA_NONE] = 0,
+ [ROUNDBOX_TRIA_ARROWS] = 3,
+ [ROUNDBOX_TRIA_SCROLL] = 16,
+ [ROUNDBOX_TRIA_MENU] = 3,
+ [ROUNDBOX_TRIA_CHECK] = 6,
+ [ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 3,
+};
static struct {
Gwn_Batch *roundbox_widget[ROUNDBOX_TRIA_MAX];
@@ -288,7 +304,7 @@ static uint32_t set_tria_vertex(
static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32_t last_data)
{
- const int tria_num = (tria == ROUNDBOX_TRIA_CHECK) ? 1 : 2;
+ const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW) ? 1 : 2;
/* for each tria */
for (int t = 0; t < tria_num; ++t) {
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
@@ -315,7 +331,7 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria)
vcount += ((WIDGET_CURVE_RESOLU * 2) * 2) * WIDGET_AA_JITTER; /* emboss */
if (tria) {
vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria1 */
- if (tria != ROUNDBOX_TRIA_CHECK) {
+ if (!ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW)) {
vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria2 */
}
}
@@ -832,6 +848,12 @@ static void shape_preset_init_number_arrows(uiWidgetTrias *tria, const rcti *rec
static void shape_preset_init_hold_action(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
{
+ tria->type = ROUNDBOX_TRIA_HOLD_ACTION_ARROW;
+ /* With the current changes to use batches for widget drawing, the code
+ * below is doing almost nothing effectively. 'where' doesn't work either,
+ * shader is currently hardcoded to work for the button triangle pointing
+ * at the lower right. The same limitation applies to other trias as well.
+ * XXX Should be addressed. */
shape_preset_init_trias_ex(
tria, rect, triasize, where,
g_shape_preset_hold_action_vert, ARRAY_SIZE(g_shape_preset_hold_action_vert),
@@ -1111,8 +1133,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
}
}
- if (wtb->tria1.type != ROUNDBOX_TRIA_NONE)
- {
+ if (wtb->tria1.type != ROUNDBOX_TRIA_NONE) {
tria_col[0] = wcol->item[0];
tria_col[1] = wcol->item[1];
tria_col[2] = wcol->item[2];
@@ -1142,7 +1163,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
/* for each AA step */
immBegin(GWN_PRIM_TRIS, (wtb->tria1.tot + wtb->tria2.tot) * 3 * WIDGET_AA_JITTER);
- if (wtb->tria1.tot){
+ if (wtb->tria1.tot) {
shape_preset_draw_trias_aa(&wtb->tria1, pos);
}
if (wtb->tria2.tot) {
@@ -2268,7 +2289,7 @@ static struct uiWidgetColors wcol_list_item = {
};
struct uiWidgetColors wcol_tab = {
- {255, 255, 255, 255},
+ {60, 60, 60, 255},
{83, 83, 83, 255},
{114, 114, 114, 255},
{90, 90, 90, 255},
@@ -3157,36 +3178,6 @@ bool ui_link_bezier_points(const rcti *rect, float coord_array[][2], int resol)
return true;
}
-#define LINK_RESOL 24
-void ui_draw_link_bezier(const rcti *rect, const float color[4])
-{
- float coord_array[LINK_RESOL + 1][2];
-
- if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
-#if 0 /* unused */
- /* we can reuse the dist variable here to increment the GL curve eval amount*/
- const float dist = 1.0f / (float)LINK_RESOL;
-#endif
- glEnable(GL_BLEND);
- glEnable(GL_LINE_SMOOTH);
-
- immUniformColor4fv(color);
-
- immBegin(GWN_PRIM_LINE_STRIP, LINK_RESOL + 1);
- for (int i = 0; i <= LINK_RESOL; ++i)
- immVertex2fv(pos, coord_array[i]);
- immEnd();
-
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
-
- immUnbindProgram();
- }
-}
-
/* function in use for buttons and for view2d sliders */
void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *slider, int state)
{
@@ -3360,24 +3351,6 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int
rect->xmax += (BLI_rcti_size_x(&rect_prog) / 2);
}
-static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
-{
-
- if (but->flag & UI_SELECT) {
- rcti rectlink;
- float color[4];
-
- UI_GetThemeColor4fv(TH_TEXT_HI, color);
-
- rectlink.xmin = BLI_rcti_cent_x(rect);
- rectlink.ymin = BLI_rcti_cent_y(rect);
- rectlink.xmax = but->linkto[0];
- rectlink.ymax = but->linkto[1];
-
- ui_draw_link_bezier(&rectlink, color);
- }
-}
-
static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
uiWidgetBase wtb, wtb1;
@@ -3859,16 +3832,20 @@ static void widget_roundbut_exec(uiWidgetColors *wcol, rcti *rect, int state, in
widgetbase_draw(&wtb, wcol);
}
-static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
+static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
const uiStyle *style = UI_style_get();
- const float rad = 0.15f * U.widget_unit;
+ const float rad = 0.25f * U.widget_unit;
const int fontid = style->widget.uifont_id;
- const bool is_active = (but->flag & UI_SELECT);
+ const bool is_active = (state & UI_SELECT);
+
+/* Draw shaded outline - Disabled for now, seems incorrect and also looks nicer without it imho ;) */
+//#define USE_TAB_SHADED_HIGHLIGHT
uiWidgetBase wtb;
unsigned char theme_col_tab_highlight[3];
+#ifdef USE_TAB_SHADED_HIGHLIGHT
/* create outline highlight colors */
if (is_active) {
interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner_sel,
@@ -3878,6 +3855,7 @@ static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner,
(unsigned char *)wcol->outline, 0.12f);
}
+#endif
widget_init(&wtb);
@@ -3885,7 +3863,9 @@ static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
round_box_edges(&wtb, roundboxalign, rect, rad);
/* draw inner */
+#ifdef USE_TAB_SHADED_HIGHLIGHT
wtb.draw_outline = 0;
+#endif
widgetbase_draw(&wtb, wcol);
/* We are drawing on top of widget bases. Flush cache. */
@@ -3893,13 +3873,19 @@ static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
UI_widgetbase_draw_cache_flush();
glDisable(GL_BLEND);
+#ifdef USE_TAB_SHADED_HIGHLIGHT
/* draw outline (3d look) */
ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, (unsigned char *)wcol->inner);
+#endif
/* text shadow */
BLF_enable(fontid, BLF_SHADOW);
BLF_shadow(fontid, 3, (const float[4]){1.0f, 1.0f, 1.0f, 0.25f});
BLF_shadow_offset(fontid, 0, -1);
+
+#ifndef USE_TAB_SHADED_HIGHLIGHT
+ UNUSED_VARS(is_active, theme_col_tab_highlight);
+#endif
}
static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect)
@@ -3990,8 +3976,8 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break;
case UI_WTYPE_TAB:
- wt.custom = widget_tab;
wt.wcol_theme = &btheme->tui.wcol_tab;
+ wt.draw = widget_tab;
break;
case UI_WTYPE_TOOLTIP:
@@ -4322,14 +4308,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_LISTBOX:
wt = widget_type(UI_WTYPE_BOX);
break;
-
- case UI_BTYPE_LINK:
- case UI_BTYPE_INLINK:
- wt = widget_type(UI_WTYPE_ICON);
- wt->custom = widget_link;
-
- break;
-
+
case UI_BTYPE_EXTRA:
widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect);
break;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 687b225b838..b7eca4b687f 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -156,18 +156,15 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case SPACE_CONSOLE:
ts = &btheme->tconsole;
break;
- case SPACE_TIME:
- ts = &btheme->ttime;
- break;
case SPACE_NODE:
ts = &btheme->tnode;
break;
- case SPACE_LOGIC:
- ts = &btheme->tlogic;
- break;
case SPACE_CLIP:
ts = &btheme->tclip;
break;
+ case SPACE_TOPBAR:
+ ts = &btheme->ttopbar;
+ break;
default:
ts = &btheme->tv3d;
break;
@@ -1210,10 +1207,6 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tnode.console_output, 223, 202, 53, 255); /* interface nodes */
btheme->tnode.noodle_curving = 5;
- /* space logic */
- btheme->tlogic = btheme->tv3d;
- rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255);
-
/* space clip */
btheme->tclip = btheme->tv3d;
@@ -1232,6 +1225,14 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff);
btheme->tclip.handle_vertex_size = 5;
ui_theme_space_init_handles_color(&btheme->tclip);
+
+ /* space topbar */
+ char tmp[4];
+ btheme->ttopbar = btheme->tv3d;
+ /* swap colors */
+ copy_v4_v4_char(tmp, btheme->ttopbar.header);
+ copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive);
+ copy_v4_v4_char(btheme->ttopbar.back, tmp);
}
void ui_style_init_default(void)
@@ -2104,13 +2105,6 @@ void init_userdef_do_versions(void)
if (btheme->tui.wcol_num.outline[3] == 0)
ui_widget_color_init(&btheme->tui);
-
- /* Logic editor theme, check for alpha==0 is safe, then color was never set */
- if (btheme->tlogic.syntaxn[3] == 0) {
- /* re-uses syntax color storage */
- btheme->tlogic = btheme->tv3d;
- rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255);
- }
rgba_char_args_set_fl(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
@@ -2147,8 +2141,6 @@ void init_userdef_do_versions(void)
strcpy(km->idname, "3D View Generic");
else if (STREQ(km->idname, "EditMesh"))
strcpy(km->idname, "Mesh");
- else if (STREQ(km->idname, "TimeLine"))
- strcpy(km->idname, "Timeline");
else if (STREQ(km->idname, "UVEdit"))
strcpy(km->idname, "UV Editor");
else if (STREQ(km->idname, "Animation_Channels"))
@@ -2791,10 +2783,6 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tnode.gp_vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tnode.gp_vertex_select, 255, 133, 0, 255);
btheme->tnode.gp_vertex_size = 3;
-
- /* Timeline Keyframe Indicators */
- rgba_char_args_set(btheme->ttime.time_keyframe, 0xDD, 0xD7, 0x00, 0xFF);
- rgba_char_args_set(btheme->ttime.time_gp_keyframe, 0xB5, 0xE6, 0x1D, 0xFF);
}
}
@@ -2924,17 +2912,14 @@ void init_userdef_do_versions(void)
U.transopts &= ~(
USER_TR_DEPRECATED_2 | USER_TR_DEPRECATED_3 | USER_TR_DEPRECATED_4 |
USER_TR_DEPRECATED_6 | USER_TR_DEPRECATED_7);
- U.gameflags &= ~(
- USER_GL_RENDER_DEPRECATED_0 | USER_GL_RENDER_DEPRECATED_1 |
- USER_GL_RENDER_DEPRECATED_3 | USER_GL_RENDER_DEPRECATED_4);
U.uiflag |= USER_LOCK_CURSOR_ADJUST;
}
- if (!USER_VERSION_ATLEAST(280, 1)) {
+ if (!USER_VERSION_ATLEAST(280, 9)) {
/* interface_widgets.c */
struct uiWidgetColors wcol_tab = {
- {255, 255, 255, 255},
+ {60, 60, 60, 255},
{83, 83, 83, 255},
{114, 114, 114, 255},
{90, 90, 90, 255},
@@ -2947,15 +2932,36 @@ void init_userdef_do_versions(void)
};
for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
+ char tmp[4];
+
btheme->tui.wcol_tab = wcol_tab;
+ btheme->ttopbar = btheme->tv3d;
+ /* swap colors */
+ copy_v4_v4_char(tmp, btheme->ttopbar.header);
+ copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive);
+ copy_v4_v4_char(btheme->ttopbar.back, tmp);
+ }
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 9)) {
+ /* Timeline removal */
+ for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
+ if (btheme->tipo.anim_active[3] == 0) {
+ rgba_char_args_set(btheme->tipo.anim_active, 204, 112, 26, 102);
+ }
+ if (btheme->tseq.anim_active[3] == 0) {
+ rgba_char_args_set(btheme->tseq.anim_active, 204, 112, 26, 102);
+ }
}
}
/**
* Include next version bump.
- *
- * (keep this block even if it becomes empty).
*/
+ {
+ /* (keep this block even if it becomes empty). */
+ }
+
if (((bTheme *)U.themes.first)->tui.manipulator_hi[3] == 0) {
for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
ui_theme_space_init_manipulator_colors(btheme);
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 4d0d59ae42c..a3cbdb57fed 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -59,8 +59,6 @@
#include "io_collada.h"
-#include "DEG_depsgraph.h"
-
static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
@@ -83,7 +81,6 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *
/* function used for WM_OT_save_mainfile too */
static int wm_collada_export_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
char filepath[FILE_MAX];
int apply_modifiers;
int export_mesh_type;
@@ -113,8 +110,6 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
int export_count;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
@@ -173,7 +168,6 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
ED_object_editmode_load(CTX_data_edit_object(C));
Scene *scene = CTX_data_scene(C);
- CTX_data_eval_ctx(C, &eval_ctx);
ExportSettings export_settings;
@@ -190,6 +184,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
export_settings.sampling_rate = sampling_rate;
export_settings.active_uv_only = active_uv_only != 0;
+ export_settings.include_material_textures = include_material_textures != 0;
export_settings.use_texture_copies = use_texture_copies != 0;
export_settings.triangulate = triangulate != 0;
@@ -205,7 +200,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE;
if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE;
- export_count = collada_export(&eval_ctx,
+ export_count = collada_export(CTX_data_depsgraph(C),
scene,
&export_settings
);
diff --git a/source/blender/editors/lattice/CMakeLists.txt b/source/blender/editors/lattice/CMakeLists.txt
index eaf837cf978..2207e0fa736 100644
--- a/source/blender/editors/lattice/CMakeLists.txt
+++ b/source/blender/editors/lattice/CMakeLists.txt
@@ -27,6 +27,7 @@ set(INC
../../makesrna
../../render/extern/include
../../windowmanager
+ ../../../../intern/clog
../../../../intern/guardedalloc
)
diff --git a/source/blender/editors/lattice/editlattice_undo.c b/source/blender/editors/lattice/editlattice_undo.c
index 58fa08e5aa9..cbd89016b44 100644
--- a/source/blender/editors/lattice/editlattice_undo.c
+++ b/source/blender/editors/lattice/editlattice_undo.c
@@ -33,6 +33,8 @@
#include "MEM_guardedalloc.h"
+#include "CLG_log.h"
+
#include "BLI_utildefines.h"
#include "BLI_array_utils.h"
@@ -42,12 +44,14 @@
#include "DNA_scene_types.h"
#include "BKE_context.h"
+#include "BKE_layer.h"
#include "BKE_undo_system.h"
#include "DEG_depsgraph.h"
#include "ED_object.h"
#include "ED_lattice.h"
+#include "ED_undo.h"
#include "ED_util.h"
#include "WM_types.h"
@@ -55,6 +59,9 @@
#include "lattice_intern.h"
+/** We only need this locally. */
+static CLG_LogRef LOG = {"ed.undo.lattice"};
+
/* -------------------------------------------------------------------- */
/** \name Undo Conversion
* \{ */
@@ -124,13 +131,19 @@ static Object *editlatt_object_from_context(bContext *C)
/* -------------------------------------------------------------------- */
/** \name Implements ED Undo System
+ *
+ * \note This is similar for all edit-mode types.
* \{ */
-typedef struct LatticeUndoStep {
- UndoStep step;
- /* note: will split out into list for multi-object-editmode. */
+typedef struct LatticeUndoStep_Elem {
UndoRefID_Object obedit_ref;
UndoLattice data;
+} LatticeUndoStep_Elem;
+
+typedef struct LatticeUndoStep {
+ UndoStep step;
+ LatticeUndoStep_Elem *elems;
+ uint elems_len;
} LatticeUndoStep;
static bool lattice_undosys_poll(bContext *C)
@@ -141,10 +154,24 @@ static bool lattice_undosys_poll(bContext *C)
static bool lattice_undosys_step_encode(struct bContext *C, UndoStep *us_p)
{
LatticeUndoStep *us = (LatticeUndoStep *)us_p;
- us->obedit_ref.ptr = editlatt_object_from_context(C);
- Lattice *lt = us->obedit_ref.ptr->data;
- undolatt_from_editlatt(&us->data, lt->editlatt);
- us->step.data_size = us->data.undo_size;
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
+ us->elems_len = objects_len;
+
+ for (uint i = 0; i < objects_len; i++) {
+ Object *ob = objects[i];
+ LatticeUndoStep_Elem *elem = &us->elems[i];
+
+ elem->obedit_ref.ptr = ob;
+ Lattice *lt = ob->data;
+ undolatt_from_editlatt(&elem->data, lt->editlatt);
+ us->step.data_size += elem->data.undo_size;
+ }
+ MEM_freeN(objects);
return true;
}
@@ -155,25 +182,47 @@ static void lattice_undosys_step_decode(struct bContext *C, UndoStep *us_p, int
BLI_assert(lattice_undosys_poll(C));
LatticeUndoStep *us = (LatticeUndoStep *)us_p;
- Object *obedit = us->obedit_ref.ptr;
- Lattice *lt = obedit->data;
- EditLatt *editlatt = lt->editlatt;
- undolatt_to_editlatt(&us->data, editlatt);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ LatticeUndoStep_Elem *elem = &us->elems[i];
+ Object *obedit = elem->obedit_ref.ptr;
+ Lattice *lt = obedit->data;
+ if (lt->editlatt == NULL) {
+ /* Should never fail, may not crash but can give odd behavior. */
+ CLOG_ERROR(&LOG, "name='%s', failed to enter edit-mode for object '%s', undo state invalid",
+ us_p->name, obedit->id.name);
+ continue;
+ }
+ undolatt_to_editlatt(&elem->data, lt->editlatt);
+ DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ }
+
+ /* The first element is always active */
+ ED_undo_object_set_active_or_warn(CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
}
static void lattice_undosys_step_free(UndoStep *us_p)
{
LatticeUndoStep *us = (LatticeUndoStep *)us_p;
- undolatt_free_data(&us->data);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ LatticeUndoStep_Elem *elem = &us->elems[i];
+ undolatt_free_data(&elem->data);
+ }
+ MEM_freeN(us->elems);
}
static void lattice_undosys_foreach_ID_ref(
UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
{
LatticeUndoStep *us = (LatticeUndoStep *)us_p;
- foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->obedit_ref));
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ LatticeUndoStep_Elem *elem = &us->elems[i];
+ foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));
+ }
}
/* Export for ED_undo_sys. */
diff --git a/source/blender/editors/manipulator_library/manipulator_library_presets.c b/source/blender/editors/manipulator_library/manipulator_library_presets.c
index 7b8d2104992..cccf484f29d 100644
--- a/source/blender/editors/manipulator_library/manipulator_library_presets.c
+++ b/source/blender/editors/manipulator_library/manipulator_library_presets.c
@@ -139,12 +139,9 @@ void ED_manipulator_draw_preset_facemap(
GPU_select_load_id(select_id);
}
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
gpuPushMatrix();
gpuMultMatrix(ob->obmat);
- ED_draw_object_facemap(&eval_ctx, scene, ob, color, facemap);
+ ED_draw_object_facemap(CTX_data_depsgraph(C), scene, ob, color, facemap);
gpuPopMatrix();
if (is_select) {
diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
index 2991c972f6e..29aff0a1250 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
@@ -191,7 +191,7 @@ static void dial_ghostarc_draw(
}
static void dial_ghostarc_get_angles(
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
const wmManipulator *mpr,
const wmEvent *event,
const ARegion *ar, const View3D *v3d,
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index 3877838ec54..91656bf6bd0 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -32,6 +32,7 @@ set(INC
../../makesrna
../../render/extern/include
../../windowmanager
+ ../../../../intern/clog
../../../../intern/guardedalloc
../../../../intern/glew-mx
)
@@ -67,18 +68,6 @@ set(SRC
mesh_intern.h
)
-if(WITH_GAMEENGINE)
- add_definitions(-DWITH_GAMEENGINE)
-
- list(APPEND INC
- ../../../../extern/recastnavigation
- )
-
- list(APPEND SRC
- mesh_navmesh.c
- )
-endif()
-
if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 1b9ee70ccf5..6d1f478249a 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -51,7 +51,6 @@
#include "WM_types.h"
#include "GPU_draw.h"
-#include "GPU_buffers.h"
/* own include */
@@ -99,11 +98,6 @@ void paintface_flush_flags(Object *ob, short flag)
}
}
- if (flag & ME_HIDE) {
- /* draw-object caches hidden faces, force re-generation T46867 */
- GPU_drawobject_free(dm);
- }
-
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_ALL);
}
@@ -393,7 +387,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
return true;
}
-int do_paintface_box_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, rcti *rect, bool select, bool extend)
+int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool extend)
{
Object *ob = vc->obact;
Mesh *me;
@@ -424,7 +418,7 @@ int do_paintface_box_select(const struct EvaluationContext *eval_ctx, ViewContex
}
}
- ED_view3d_backbuf_validate(eval_ctx, vc);
+ ED_view3d_backbuf_validate(vc);
ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect);
rt = ibuf->rect;
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index c8d33a9cc60..ca5af7a535d 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -87,7 +87,7 @@ typedef struct {
float mcenter[2];
BMBackup mesh_backup;
void *draw_handle_pixel;
- short twtype;
+ short twflag;
short value_mode; /* Which value does mouse movement and numeric input affect? */
float segments; /* Segments as float so smooth mouse pan works in small increments */
} BevelData;
@@ -180,8 +180,8 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
G.moving = G_TRANSFORM_EDIT;
if (v3d) {
- opdata->twtype = v3d->twtype;
- v3d->twtype = 0;
+ opdata->twflag = v3d->twflag;
+ v3d->twflag = 0;
}
}
@@ -254,7 +254,7 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op)
EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);
ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);
if (v3d) {
- v3d->twtype = opdata->twtype;
+ v3d->twflag = opdata->twflag;
}
G.moving = 0;
}
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index 741d16206cd..ac8c1f16477 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -70,7 +70,7 @@ typedef struct {
/* modal only */
BMBackup mesh_backup;
bool is_first;
- short twtype;
+ short twflag;
} BisectData;
static bool mesh_bisect_interactive_calc(
@@ -156,8 +156,8 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* misc other vars */
G.moving = G_TRANSFORM_EDIT;
- opdata->twtype = v3d->twtype;
- v3d->twtype = 0;
+ opdata->twflag = v3d->twflag;
+ v3d->twflag = 0;
/* initialize modal callout */
ED_area_headerprint(CTX_wm_area(C), IFACE_("LMB: Click and drag to draw cut line"));
@@ -169,7 +169,7 @@ static void edbm_bisect_exit(bContext *C, BisectData *opdata)
{
View3D *v3d = CTX_wm_view3d(C);
EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);
- v3d->twtype = opdata->twtype;
+ v3d->twflag = opdata->twflag;
G.moving = 0;
}
@@ -199,7 +199,7 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Setup manipulators */
{
View3D *v3d = CTX_wm_view3d(C);
- if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) {
+ if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) {
WM_manipulator_group_type_ensure("MESH_WGT_bisect");
}
}
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index 41b3ab0079b..2c60df9abe1 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -35,6 +35,7 @@
#include "BLI_math.h"
#include "BLI_listbase.h"
+#include "BKE_layer.h"
#include "BKE_context.h"
#include "BKE_object.h"
#include "BKE_report.h"
@@ -445,12 +446,22 @@ void MESH_OT_extrude_region(wmOperatorType *ot)
static int edbm_extrude_verts_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ if (em->bm->totvertsel == 0) {
+ continue;
+ }
- edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT);
+ edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT);
- EDBM_update_generic(em, true, true);
+ EDBM_update_generic(em, true, true);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -481,12 +492,22 @@ void MESH_OT_extrude_verts_indiv(wmOperatorType *ot)
static int edbm_extrude_edges_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ if (em->bm->totedgesel == 0) {
+ continue;
+ }
- edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT);
+ edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT);
- EDBM_update_generic(em, true, true);
+ EDBM_update_generic(em, true, true);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -517,12 +538,22 @@ void MESH_OT_extrude_edges_indiv(wmOperatorType *ot)
static int edbm_extrude_faces_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ if (em->bm->totfacesel == 0) {
+ continue;
+ }
- edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT);
+ edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT);
- EDBM_update_generic(em, true, true);
+ EDBM_update_generic(em, true, true);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -808,7 +839,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
#ifdef USE_MANIPULATOR
if (ret & OPERATOR_FINISHED) {
/* Setup manipulators */
- if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) {
+ if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) {
WM_manipulator_group_type_ensure("MESH_WGT_spin");
}
}
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index 3833b84b5d2..53ba5e4316f 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -72,7 +72,7 @@ typedef struct {
float mcenter[2];
BMBackup mesh_backup;
void *draw_handle_pixel;
- short twtype;
+ short twflag;
} InsetData;
@@ -152,8 +152,8 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal)
ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL);
G.moving = G_TRANSFORM_EDIT;
if (v3d) {
- opdata->twtype = v3d->twtype;
- v3d->twtype = 0;
+ opdata->twflag = v3d->twflag;
+ v3d->twflag = 0;
}
}
@@ -173,7 +173,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op)
EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);
ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);
if (v3d) {
- v3d->twtype = opdata->twtype;
+ v3d->twflag = opdata->twflag;
}
G.moving = 0;
}
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 0a12291c128..80fed05a0b5 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -161,7 +161,6 @@ typedef struct KnifePosData {
typedef struct KnifeTool_OpData {
ARegion *ar; /* region that knifetool was activated in */
void *draw_handle; /* for drawing preview loop */
- EvaluationContext eval_ctx;
ViewContext vc; /* note: _don't_ use 'mval', instead use the one we define below */
float mval[2]; /* mouse value with snapping applied */
//bContext *C;
@@ -1562,8 +1561,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
}
/* unproject screen line */
- ED_view3d_win_to_segment(kcd->eval_ctx.depsgraph, kcd->ar, kcd->vc.v3d, s1, v1, v3, true);
- ED_view3d_win_to_segment(kcd->eval_ctx.depsgraph, kcd->ar, kcd->vc.v3d, s2, v2, v4, true);
+ ED_view3d_win_to_segment(kcd->vc.depsgraph, kcd->ar, kcd->vc.v3d, s1, v1, v3, true);
+ ED_view3d_win_to_segment(kcd->vc.depsgraph, kcd->ar, kcd->vc.v3d, s2, v2, v4, true);
mul_m4_v3(kcd->ob->imat, v1);
mul_m4_v3(kcd->ob->imat, v2);
@@ -1838,7 +1837,7 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd, float co[3], float
if (!f) {
if (kcd->is_interactive) {
/* try to use backbuffer selection method if ray casting failed */
- f = EDBM_face_find_nearest(&kcd->eval_ctx, &kcd->vc, &dist);
+ f = EDBM_face_find_nearest(&kcd->vc, &dist);
/* cheat for now; just put in the origin instead
* of a true coordinate on the face.
@@ -1961,7 +1960,7 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo
/* check if we're close enough and calculate 'lambda' */
if (kcd->is_angle_snapping) {
- /* if snapping, check we're in bounds */
+ /* if snapping, check we're in bounds */
float sco_snap[2];
isect_line_line_v2_point(kfe->v1->sco, kfe->v2->sco, kcd->prev.mval, kcd->curr.mval, sco_snap);
lambda = line_point_factor_v2(sco_snap, kfe->v1->sco, kfe->v2->sco);
@@ -2519,7 +2518,7 @@ static void knife_recalc_projmat(KnifeTool_OpData *kcd)
mul_v3_mat3_m4v3(kcd->proj_zaxis, kcd->ob->imat, kcd->vc.rv3d->viewinv[2]);
normalize_v3(kcd->proj_zaxis);
- kcd->is_ortho = ED_view3d_clip_range_get(kcd->eval_ctx.depsgraph,
+ kcd->is_ortho = ED_view3d_clip_range_get(kcd->vc.depsgraph,
kcd->vc.v3d, kcd->vc.rv3d,
&kcd->clipsta, &kcd->clipend, true);
}
@@ -2591,7 +2590,7 @@ static void knifetool_init_bmbvh(KnifeTool_OpData *kcd)
{
BM_mesh_elem_index_ensure(kcd->em->bm, BM_VERT);
- kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(&kcd->eval_ctx, kcd->em, kcd->scene, NULL);
+ kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(kcd->vc.depsgraph, kcd->em, kcd->scene, NULL);
kcd->bmbvh = BKE_bmbvh_new_from_editmesh(
kcd->em,
@@ -2625,7 +2624,6 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd,
kcd->ob = obedit;
kcd->ar = CTX_wm_region(C);
- CTX_data_eval_ctx(C, &kcd->eval_ctx);
em_setup_viewcontext(C, &kcd->vc);
kcd->em = BKE_editmesh_from_object(kcd->ob);
@@ -2793,7 +2791,6 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
}
- CTX_data_eval_ctx(C, &kcd->eval_ctx);
em_setup_viewcontext(C, &kcd->vc);
kcd->ar = kcd->vc.ar;
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index c98d22503e1..ba030c42a04 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -60,15 +60,13 @@
static LinkNode *knifeproject_poly_from_object(const bContext *C, Scene *scene, Object *ob, LinkNode *polys)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ARegion *ar = CTX_wm_region(C);
- EvaluationContext eval_ctx;
DerivedMesh *dm;
bool dm_needsFree;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (ob->type == OB_MESH || ob->derivedFinal) {
- dm = ob->derivedFinal ? ob->derivedFinal : mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ dm = ob->derivedFinal ? ob->derivedFinal : mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
dm_needsFree = false;
}
else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 793e5609d31..9817909ba4a 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -555,23 +555,20 @@ static void loopcut_update_edge(RingSelOpData *lcd, BMEdge *e, const int preview
}
}
-static void loopcut_mouse_move(const struct EvaluationContext *eval_ctx, RingSelOpData *lcd, const int previewlines)
+static void loopcut_mouse_move(RingSelOpData *lcd, const int previewlines)
{
float dist = ED_view3d_select_dist_px();
- BMEdge *e = EDBM_edge_find_nearest(eval_ctx, &lcd->vc, &dist);
+ BMEdge *e = EDBM_edge_find_nearest(&lcd->vc, &dist);
loopcut_update_edge(lcd, e, previewlines);
}
/* called by both init() and exec() */
static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
{
- EvaluationContext eval_ctx;
const bool is_interactive = (event != NULL);
Object *obedit = CTX_data_edit_object(C);
RingSelOpData *lcd;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (modifiers_isDeformedByLattice(obedit) || modifiers_isDeformedByArmature(obedit))
BKE_report(op->reports, RPT_WARNING, "Loop cut does not work well on deformed edit mesh display");
@@ -599,7 +596,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
if (is_interactive) {
copy_v2_v2_int(lcd->vc.mval, event->mval);
- loopcut_mouse_move(&eval_ctx, lcd, is_interactive ? 1 : 0);
+ loopcut_mouse_move(lcd, is_interactive ? 1 : 0);
}
else {
const int e_index = RNA_int_get(op->ptr, "edge_index");
@@ -672,14 +669,12 @@ static int loopcut_finish(RingSelOpData *lcd, bContext *C, wmOperator *op)
static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
- EvaluationContext eval_ctx;
RingSelOpData *lcd = op->customdata;
float cuts = lcd->cuts;
float smoothness = lcd->smoothness;
bool show_cuts = false;
const bool has_numinput = hasNumInput(&lcd->num);
- CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &lcd->vc);
lcd->ar = lcd->vc.ar;
@@ -773,7 +768,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
lcd->vc.mval[0] = event->mval[0];
lcd->vc.mval[1] = event->mval[1];
- loopcut_mouse_move(&eval_ctx, lcd, (int)lcd->cuts);
+ loopcut_mouse_move(lcd, (int)lcd->cuts);
ED_region_tag_redraw(lcd->ar);
handled = true;
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index 2ae48bee095..4081e3b0302 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -578,19 +578,19 @@ static bool edbm_shortest_path_pick_ex(
static int edbm_shortest_path_pick_exec(bContext *C, wmOperator *op);
-static BMElem *edbm_elem_find_nearest(const struct EvaluationContext *eval_ctx, ViewContext *vc, const char htype)
+static BMElem *edbm_elem_find_nearest(ViewContext *vc, const char htype)
{
BMEditMesh *em = vc->em;
float dist = ED_view3d_select_dist_px();
if ((em->selectmode & SCE_SELECT_VERTEX) && (htype == BM_VERT)) {
- return (BMElem *)EDBM_vert_find_nearest(eval_ctx, vc, &dist);
+ return (BMElem *)EDBM_vert_find_nearest(vc, &dist);
}
else if ((em->selectmode & SCE_SELECT_EDGE) && (htype == BM_EDGE)) {
- return (BMElem *)EDBM_edge_find_nearest(eval_ctx, vc, &dist);
+ return (BMElem *)EDBM_edge_find_nearest(vc, &dist);
}
else if ((em->selectmode & SCE_SELECT_FACE) && (htype == BM_FACE)) {
- return (BMElem *)EDBM_face_find_nearest(eval_ctx, vc, &dist);
+ return (BMElem *)EDBM_face_find_nearest(vc, &dist);
}
return NULL;
@@ -613,12 +613,10 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
return edbm_shortest_path_pick_exec(C, op);
}
- EvaluationContext eval_ctx;
ViewContext vc;
BMEditMesh *em;
bool track_active = true;
- CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &vc);
copy_v2_v2_int(vc.mval, event->mval);
em = vc.em;
@@ -627,14 +625,14 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
BMElem *ele_src, *ele_dst;
if (!(ele_src = edbm_elem_active_elem_or_face_get(em->bm)) ||
- !(ele_dst = edbm_elem_find_nearest(&eval_ctx, &vc, ele_src->head.htype)))
+ !(ele_dst = edbm_elem_find_nearest(&vc, ele_src->head.htype)))
{
/* special case, toggle edge tags even when we don't have a path */
if (((em->selectmode & SCE_SELECT_EDGE) &&
(vc.scene->toolsettings->edge_mode != EDGE_MODE_SELECT)) &&
/* check if we only have a destination edge */
((ele_src == NULL) &&
- (ele_dst = edbm_elem_find_nearest(&eval_ctx, &vc, BM_EDGE))))
+ (ele_dst = edbm_elem_find_nearest(&vc, BM_EDGE))))
{
ele_src = ele_dst;
track_active = false;
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 87937fd4146..b45db94318b 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -45,6 +45,7 @@
#include "BKE_report.h"
#include "BKE_paint.h"
#include "BKE_editmesh.h"
+#include "BKE_layer.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -212,7 +213,7 @@ static BLI_bitmap *edbm_backbuf_alloc(const int size)
/* reads rect, and builds selection array for quick lookup */
/* returns if all is OK */
bool EDBM_backbuf_border_init(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, short xmin,
+ ViewContext *vc, short xmin,
short ymin, short xmax, short ymax)
{
struct ImBuf *buf;
@@ -223,7 +224,7 @@ bool EDBM_backbuf_border_init(
return false;
}
- buf = ED_view3d_backbuf_read(eval_ctx, vc, xmin, ymin, xmax, ymax);
+ buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
if ((buf == NULL) || (bm_vertoffs == 0)) {
return false;
}
@@ -286,7 +287,7 @@ static void edbm_mask_lasso_px_cb(int x, int x_end, int y, void *user_data)
* - grab again and compare
* returns 'OK'
*/
-bool EDBM_backbuf_border_mask_init(const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax)
+bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax)
{
unsigned int *dr, *dr_mask, *dr_mask_arr;
struct ImBuf *buf;
@@ -303,7 +304,7 @@ bool EDBM_backbuf_border_mask_init(const struct EvaluationContext *eval_ctx, Vie
return false;
}
- buf = ED_view3d_backbuf_read(eval_ctx, vc, xmin, ymin, xmax, ymax);
+ buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
if ((buf == NULL) || (bm_vertoffs == 0)) {
return false;
}
@@ -337,7 +338,7 @@ bool EDBM_backbuf_border_mask_init(const struct EvaluationContext *eval_ctx, Vie
/* circle shaped sample area */
bool EDBM_backbuf_circle_init(
- const struct EvaluationContext *eval_ctx, ViewContext *vc,
+ ViewContext *vc,
short xs, short ys, short rads)
{
struct ImBuf *buf;
@@ -357,7 +358,7 @@ bool EDBM_backbuf_circle_init(
xmin = xs - rads; xmax = xs + rads;
ymin = ys - rads; ymax = ys + rads;
- buf = ED_view3d_backbuf_read(eval_ctx, vc, xmin, ymin, xmax, ymax);
+ buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
if ((buf == NULL) || (bm_vertoffs == 0)) {
return false;
}
@@ -456,7 +457,7 @@ static void findnearestvert__doClosest(void *userData, BMVert *eve, const float
* \param use_cycle Cycle over elements within #FIND_NEAR_CYCLE_THRESHOLD_MIN in order of index.
*/
BMVert *EDBM_vert_find_nearest_ex(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist,
+ ViewContext *vc, float *r_dist,
const bool use_select_bias, bool use_cycle)
{
BMesh *bm = vc->em->bm;
@@ -468,10 +469,10 @@ BMVert *EDBM_vert_find_nearest_ex(
BMVert *eve;
/* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
- ED_view3d_backbuf_validate(eval_ctx, vc);
+ ED_view3d_backbuf_validate(vc);
index = ED_view3d_backbuf_sample_rect(
- eval_ctx, vc, vc->mval, dist_px, bm_wireoffs, 0xFFFFFF, &dist_test);
+ vc, vc->mval, dist_px, bm_wireoffs, 0xFFFFFF, &dist_test);
eve = index ? BM_vert_at_index_find_or_table(bm, index - 1) : NULL;
if (eve) {
@@ -506,7 +507,7 @@ BMVert *EDBM_vert_find_nearest_ex(
data.cycle_index_prev = prev_select_index;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenVert(eval_ctx, vc, findnearestvert__doClosest, &data, clip_flag);
+ mesh_foreachScreenVert(vc, findnearestvert__doClosest, &data, clip_flag);
hit = (data.use_cycle && data.hit_cycle.vert) ? &data.hit_cycle : &data.hit;
*r_dist = hit->dist;
@@ -518,9 +519,9 @@ BMVert *EDBM_vert_find_nearest_ex(
}
}
-BMVert *EDBM_vert_find_nearest(const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist)
+BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist)
{
- return EDBM_vert_find_nearest_ex(eval_ctx, vc, r_dist, false, false);
+ return EDBM_vert_find_nearest_ex(vc, r_dist, false, false);
}
/* find the distance to the edge we already have */
@@ -642,7 +643,7 @@ static void find_nearest_edge__doClosest(
}
BMEdge *EDBM_edge_find_nearest_ex(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist,
+ ViewContext *vc, float *r_dist,
float *r_dist_center,
const bool use_select_bias, const bool use_cycle,
BMEdge **r_eed_zbuf)
@@ -661,12 +662,12 @@ BMEdge *EDBM_edge_find_nearest_ex(
vc->scene->toolsettings->selectmode |= SCE_SELECT_EDGE;
/* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
- ED_view3d_backbuf_validate(eval_ctx, vc);
+ ED_view3d_backbuf_validate(vc);
/* restore `selectmode` */
vc->scene->toolsettings->selectmode = ts_selectmode;
- index = ED_view3d_backbuf_sample_rect(eval_ctx, vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test);
+ index = ED_view3d_backbuf_sample_rect(vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test);
eed = index ? BM_edge_at_index_find_or_table(bm, index - 1) : NULL;
if (r_eed_zbuf) {
@@ -684,7 +685,7 @@ BMEdge *EDBM_edge_find_nearest_ex(
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenEdge(eval_ctx, vc, find_nearest_edge_center__doZBuf, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenEdge(vc, find_nearest_edge_center__doZBuf, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
*r_dist_center = data.dist;
}
@@ -724,7 +725,7 @@ BMEdge *EDBM_edge_find_nearest_ex(
data.cycle_index_prev = prev_select_index;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenEdge(eval_ctx, vc, find_nearest_edge__doClosest, &data, clip_flag);
+ mesh_foreachScreenEdge(vc, find_nearest_edge__doClosest, &data, clip_flag);
hit = (data.use_cycle && data.hit_cycle.edge) ? &data.hit_cycle : &data.hit;
*r_dist = hit->dist;
@@ -740,9 +741,9 @@ BMEdge *EDBM_edge_find_nearest_ex(
}
BMEdge *EDBM_edge_find_nearest(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist)
+ ViewContext *vc, float *r_dist)
{
- return EDBM_edge_find_nearest_ex(eval_ctx, vc, r_dist, NULL, false, false, NULL);
+ return EDBM_edge_find_nearest_ex(vc, r_dist, NULL, false, false, NULL);
}
/* find the distance to the face we already have */
@@ -816,7 +817,7 @@ static void findnearestface__doClosest(void *userData, BMFace *efa, const float
BMFace *EDBM_face_find_nearest_ex(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist,
+ ViewContext *vc, float *r_dist,
float *r_dist_center,
const bool use_select_bias, const bool use_cycle,
BMFace **r_efa_zbuf)
@@ -828,9 +829,9 @@ BMFace *EDBM_face_find_nearest_ex(
unsigned int index;
BMFace *efa;
- ED_view3d_backbuf_validate(eval_ctx, vc);
+ ED_view3d_backbuf_validate(vc);
- index = ED_view3d_backbuf_sample(eval_ctx, vc, vc->mval[0], vc->mval[1]);
+ index = ED_view3d_backbuf_sample(vc, vc->mval[0], vc->mval[1]);
efa = index ? BM_face_at_index_find_or_table(bm, index - 1) : NULL;
if (r_efa_zbuf) {
@@ -848,7 +849,7 @@ BMFace *EDBM_face_find_nearest_ex(
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenFace(eval_ctx, vc, find_nearest_face_center__doZBuf, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenFace(vc, find_nearest_face_center__doZBuf, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
*r_dist_center = data.dist;
}
@@ -886,7 +887,7 @@ BMFace *EDBM_face_find_nearest_ex(
data.cycle_index_prev = prev_select_index;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenFace(eval_ctx, vc, findnearestface__doClosest, &data, clip_flag);
+ mesh_foreachScreenFace(vc, findnearestface__doClosest, &data, clip_flag);
hit = (data.use_cycle && data.hit_cycle.face) ? &data.hit_cycle : &data.hit;
*r_dist = hit->dist;
@@ -901,9 +902,9 @@ BMFace *EDBM_face_find_nearest_ex(
}
}
-BMFace *EDBM_face_find_nearest(const struct EvaluationContext *eval_ctx, ViewContext *vc, float *r_dist)
+BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist)
{
- return EDBM_face_find_nearest_ex(eval_ctx, vc, r_dist, NULL, false, false, NULL);
+ return EDBM_face_find_nearest_ex(vc, r_dist, NULL, false, false, NULL);
}
#undef FIND_NEAR_SELECT_BIAS
@@ -916,8 +917,8 @@ BMFace *EDBM_face_find_nearest(const struct EvaluationContext *eval_ctx, ViewCon
* return 1 if found one
*/
static int unified_findnearest(
- const struct EvaluationContext *eval_ctx, ViewContext *vc,
- BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
+ ViewContext *vc,
+ Base **r_base, BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
{
BMEditMesh *em = vc->em;
static short mval_prev[2] = {-1, -1};
@@ -934,32 +935,70 @@ static int unified_findnearest(
BMEdge *eed = NULL;
BMFace *efa = NULL;
+ /* TODO(campbell): perform selection as one pass
+ * instead of many smaller passes (which doesn't work for zbuf occlusion). */
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc->view_layer, &bases_len);
/* no afterqueue (yet), so we check it now, otherwise the em_xxxofs indices are bad */
- ED_view3d_backbuf_validate(eval_ctx, vc);
if ((dist > 0.0f) && em->selectmode & SCE_SELECT_FACE) {
float dist_center = 0.0f;
float *dist_center_p = (em->selectmode & (SCE_SELECT_EDGE | SCE_SELECT_VERTEX)) ? &dist_center : NULL;
- efa = EDBM_face_find_nearest_ex(eval_ctx, vc, &dist, dist_center_p, true, use_cycle, &efa_zbuf);
- if (efa && dist_center_p) {
- dist = min_ff(dist_margin, dist_center);
- }
+
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Base *base_iter = bases[base_index];
+ Object *obedit = base_iter->object;
+ ED_view3d_viewcontext_init_object(vc, obedit);
+ ED_view3d_backbuf_validate(vc);
+
+ BMFace *efa_test = EDBM_face_find_nearest_ex(vc, &dist, dist_center_p, true, use_cycle, &efa_zbuf);
+ if (efa && dist_center_p) {
+ dist = min_ff(dist_margin, dist_center);
+ }
+ if (efa_test) {
+ *r_base = base_iter;
+ efa = efa_test;
+ }
+ } /* bases */
}
if ((dist > 0.0f) && (em->selectmode & SCE_SELECT_EDGE)) {
float dist_center = 0.0f;
float *dist_center_p = (em->selectmode & SCE_SELECT_VERTEX) ? &dist_center : NULL;
- eed = EDBM_edge_find_nearest_ex(eval_ctx, vc, &dist, dist_center_p, true, use_cycle, &eed_zbuf);
- if (eed && dist_center_p) {
- dist = min_ff(dist_margin, dist_center);
- }
+
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Base *base_iter = bases[base_index];
+ Object *obedit = base_iter->object;
+ ED_view3d_viewcontext_init_object(vc, obedit);
+ ED_view3d_backbuf_validate(vc);
+ BMEdge *eed_test = EDBM_edge_find_nearest_ex(vc, &dist, dist_center_p, true, use_cycle, &eed_zbuf);
+ if (eed && dist_center_p) {
+ dist = min_ff(dist_margin, dist_center);
+ }
+ if (eed_test) {
+ *r_base = base_iter;
+ eed = eed_test;
+ }
+ } /* bases */
}
if ((dist > 0.0f) && em->selectmode & SCE_SELECT_VERTEX) {
- eve = EDBM_vert_find_nearest_ex(eval_ctx, vc, &dist, true, use_cycle);
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Base *base_iter = bases[base_index];
+ Object *obedit = base_iter->object;
+ ED_view3d_viewcontext_init_object(vc, obedit);
+ ED_view3d_backbuf_validate(vc);
+ BMVert *eve_test = EDBM_vert_find_nearest_ex(vc, &dist, true, use_cycle);
+ if (eve_test) {
+ *r_base = base_iter;
+ eve = eve_test;
+ }
+ } /* bases */
}
+ MEM_SAFE_FREE(bases);
+
/* return only one of 3 pointers, for frontbuffer redraws */
if (eve) {
efa = NULL; eed = NULL;
@@ -1601,7 +1640,6 @@ static void mouse_mesh_loop_edge(BMEditMesh *em, BMEdge *eed, bool select, bool
static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, bool ring)
{
- EvaluationContext eval_ctx;
ViewContext vc;
BMEditMesh *em;
BMEdge *eed;
@@ -1611,7 +1649,6 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de
float dist = ED_view3d_select_dist_px() * 0.6666f;
float mvalf[2];
- CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &vc);
mvalf[0] = (float)(vc.mval[0] = mval[0]);
mvalf[1] = (float)(vc.mval[1] = mval[1]);
@@ -1623,12 +1660,12 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de
vc.scene->toolsettings->selectmode |= SCE_SELECT_EDGE;
/* no afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad */
- ED_view3d_backbuf_validate(&eval_ctx, &vc);
+ ED_view3d_backbuf_validate(&vc);
/* restore `selectmode` */
vc.scene->toolsettings->selectmode = ts_selectmode;
- eed = EDBM_edge_find_nearest_ex(&eval_ctx, &vc, &dist, NULL, true, true, NULL);
+ eed = EDBM_edge_find_nearest_ex(&vc, &dist, NULL, true, true, NULL);
if (eed == NULL) {
return false;
}
@@ -1804,27 +1841,43 @@ void MESH_OT_edgering_select(wmOperatorType *ot)
static int edbm_select_all_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- const int action = RNA_enum_get(op->ptr, "action");
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ int action = RNA_enum_get(op->ptr, "action");
+
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ if (action == SEL_TOGGLE) {
+ action = SEL_SELECT;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) {
+ action = SEL_DESELECT;
+ break;
+ }
+ }
+ }
- switch (action) {
- case SEL_TOGGLE:
- EDBM_select_toggle_all(em);
- break;
- case SEL_SELECT:
- EDBM_flag_enable_all(em, BM_ELEM_SELECT);
- break;
- case SEL_DESELECT:
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- break;
- case SEL_INVERT:
- EDBM_select_swap(em);
- EDBM_selectmode_flush(em);
- break;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ switch (action) {
+ case SEL_SELECT:
+ EDBM_flag_enable_all(em, BM_ELEM_SELECT);
+ break;
+ case SEL_DESELECT:
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ break;
+ case SEL_INVERT:
+ EDBM_select_swap(em);
+ EDBM_selectmode_flush(em);
+ break;
+ }
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ MEM_SAFE_FREE(objects);
return OPERATOR_FINISHED;
}
@@ -1894,23 +1947,35 @@ void MESH_OT_select_interior_faces(wmOperatorType *ot)
bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
{
- EvaluationContext eval_ctx;
ViewContext vc;
+
+ Base *basact = NULL;
BMVert *eve = NULL;
BMEdge *eed = NULL;
BMFace *efa = NULL;
/* setup view context for argument to callbacks */
- CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &vc);
vc.mval[0] = mval[0];
vc.mval[1] = mval[1];
- if (unified_findnearest(&eval_ctx, &vc, &eve, &eed, &efa)) {
+ if (unified_findnearest(&vc, &basact, &eve, &eed, &efa)) {
+ ED_view3d_viewcontext_init_object(&vc, basact->object);
/* Deselect everything */
- if (extend == false && deselect == false && toggle == false)
- EDBM_flag_disable_all(vc.em, BM_ELEM_SELECT);
+ if (extend == false && deselect == false && toggle == false) {
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ EDBM_flag_disable_all(BKE_editmesh_from_object(ob_iter), BM_ELEM_SELECT);
+ if (basact->object != ob_iter) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
+ }
+ }
+ MEM_SAFE_FREE(objects);
+ }
if (efa) {
if (extend) {
@@ -2020,7 +2085,14 @@ bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect
}
+ /* Changing active object is handy since it allows us to
+ * switch UV layers, vgroups for eg. */
+ if (vc.view_layer->basact != basact) {
+ vc.view_layer->basact = basact;
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, vc.scene);
+ }
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
+
return true;
}
@@ -2242,6 +2314,7 @@ bool EDBM_selectmode_toggle(
bContext *C, const short selectmode_new,
const int action, const bool use_extend, const bool use_expand)
{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
ToolSettings *ts = CTX_data_tool_settings(C);
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = NULL;
@@ -2255,6 +2328,7 @@ bool EDBM_selectmode_toggle(
return ret;
}
+ bool only_update = false;
switch (action) {
case -1:
/* already set */
@@ -2262,21 +2336,24 @@ bool EDBM_selectmode_toggle(
case 0: /* disable */
/* check we have something to do */
if ((em->selectmode & selectmode_new) == 0) {
- return false;
+ only_update = true;
+ break;
}
em->selectmode &= ~selectmode_new;
break;
case 1: /* enable */
/* check we have something to do */
if ((em->selectmode & selectmode_new) != 0) {
- return false;
+ only_update = true;
+ break;
}
em->selectmode |= selectmode_new;
break;
case 2: /* toggle */
/* can't disable this flag if its the only one set */
if (em->selectmode == selectmode_new) {
- return false;
+ only_update = true;
+ break;
}
em->selectmode ^= selectmode_new;
break;
@@ -2285,10 +2362,30 @@ bool EDBM_selectmode_toggle(
break;
}
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter);
+ if (em_iter != em) {
+ em_iter->selectmode = em->selectmode;
+ }
+ }
+
+ if (only_update) {
+ MEM_SAFE_FREE(objects);
+ return false;
+ }
+
if (use_extend == 0 || em->selectmode == 0) {
if (use_expand) {
const short selmode_max = highest_order_bit_s(ts->selectmode);
- EDBM_selectmode_convert(em, selmode_max, selectmode_new);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter);
+ EDBM_selectmode_convert(em_iter, selmode_max, selectmode_new);
+ }
}
}
@@ -2297,24 +2394,18 @@ bool EDBM_selectmode_toggle(
if (use_extend == 0 || em->selectmode == 0) {
em->selectmode = SCE_SELECT_VERTEX;
}
- ts->selectmode = em->selectmode;
- EDBM_selectmode_set(em);
ret = true;
break;
case SCE_SELECT_EDGE:
if (use_extend == 0 || em->selectmode == 0) {
em->selectmode = SCE_SELECT_EDGE;
}
- ts->selectmode = em->selectmode;
- EDBM_selectmode_set(em);
ret = true;
break;
case SCE_SELECT_FACE:
if (use_extend == 0 || em->selectmode == 0) {
em->selectmode = SCE_SELECT_FACE;
}
- ts->selectmode = em->selectmode;
- EDBM_selectmode_set(em);
ret = true;
break;
default:
@@ -2323,10 +2414,18 @@ bool EDBM_selectmode_toggle(
}
if (ret == true) {
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ ts->selectmode = em->selectmode;
+ em = NULL;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter);
+ EDBM_selectmode_set(em_iter);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
+ }
WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
}
+ MEM_SAFE_FREE(objects);
return ret;
}
@@ -2528,7 +2627,7 @@ static bool select_linked_delimit_test(
* Gets the default from the operator fallback to own last-used value
* (selected based on mode)
*/
-static int select_linked_delimit_default_from_op(wmOperator *op, int select_mode)
+static int select_linked_delimit_default_from_op(wmOperator *op, const int select_mode)
{
static char delimit_last_store[2] = {0, BMO_DELIM_SEAM};
int delimit_last_index = (select_mode & (SCE_SELECT_VERTEX | SCE_SELECT_EDGE)) == 0;
@@ -2594,172 +2693,186 @@ static void select_linked_delimit_end(BMEditMesh *em)
static int edbm_select_linked_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMesh *bm = em->bm;
- BMIter iter;
- BMWalker walker;
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
#ifdef USE_LINKED_SELECT_DEFAULT_HACK
- int delimit = select_linked_delimit_default_from_op(op, em->selectmode);
+ const int delimit_init = select_linked_delimit_default_from_op(op, scene->toolsettings->selectmode);
#else
- int delimit = RNA_enum_get(op->ptr, "delimit");
+ const int delimit_init = RNA_enum_get(op->ptr, "delimit");
#endif
- select_linked_delimit_validate(bm, &delimit);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- if (delimit) {
- select_linked_delimit_begin(em->bm, delimit);
- }
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
- if (em->selectmode & SCE_SELECT_VERTEX) {
- BMVert *v;
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+ BMIter iter;
+ BMWalker walker;
- BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- BM_elem_flag_set(v, BM_ELEM_TAG, BM_elem_flag_test(v, BM_ELEM_SELECT));
- }
+ int delimit = delimit_init;
+
+ select_linked_delimit_validate(bm, &delimit);
- /* exclude all delimited verts */
if (delimit) {
- BMEdge *e;
- BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (!BMO_edge_flag_test(bm, e, BMO_ELE_TAG)) {
- BM_elem_flag_disable(e->v1, BM_ELEM_TAG);
- BM_elem_flag_disable(e->v2, BM_ELEM_TAG);
- }
- }
+ select_linked_delimit_begin(em->bm, delimit);
}
- BMW_init(&walker, em->bm, delimit ? BMW_LOOP_SHELL_WIRE : BMW_VERT_SHELL,
- BMW_MASK_NOP, delimit ? BMO_ELE_TAG : BMW_MASK_NOP, BMW_MASK_NOP,
- BMW_FLAG_TEST_HIDDEN,
- BMW_NIL_LAY);
+ if (em->selectmode & SCE_SELECT_VERTEX) {
+ BMVert *v;
- if (delimit) {
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- BMElem *ele_walk;
- BMW_ITER (ele_walk, &walker, v) {
- if (ele_walk->head.htype == BM_LOOP) {
- BMVert *v_step = ((BMLoop *)ele_walk)->v;
- BM_vert_select_set(em->bm, v_step, true);
- BM_elem_flag_disable(v_step, BM_ELEM_TAG);
- }
- else {
- BMEdge *e_step = (BMEdge *)ele_walk;
- BLI_assert(ele_walk->head.htype == BM_EDGE);
- BM_edge_select_set(em->bm, e_step, true);
- BM_elem_flag_disable(e_step->v1, BM_ELEM_TAG);
- BM_elem_flag_disable(e_step->v2, BM_ELEM_TAG);
+ BM_elem_flag_set(v, BM_ELEM_TAG, BM_elem_flag_test(v, BM_ELEM_SELECT));
+ }
+
+ /* exclude all delimited verts */
+ if (delimit) {
+ BMEdge *e;
+ BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
+ if (!BMO_edge_flag_test(bm, e, BMO_ELE_TAG)) {
+ BM_elem_flag_disable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_disable(e->v2, BM_ELEM_TAG);
+ }
+ }
+ }
+
+ BMW_init(&walker, em->bm, delimit ? BMW_LOOP_SHELL_WIRE : BMW_VERT_SHELL,
+ BMW_MASK_NOP, delimit ? BMO_ELE_TAG : BMW_MASK_NOP, BMW_MASK_NOP,
+ BMW_FLAG_TEST_HIDDEN,
+ BMW_NIL_LAY);
+
+ if (delimit) {
+ BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ BMElem *ele_walk;
+ BMW_ITER (ele_walk, &walker, v) {
+ if (ele_walk->head.htype == BM_LOOP) {
+ BMVert *v_step = ((BMLoop *)ele_walk)->v;
+ BM_vert_select_set(em->bm, v_step, true);
+ BM_elem_flag_disable(v_step, BM_ELEM_TAG);
+ }
+ else {
+ BMEdge *e_step = (BMEdge *)ele_walk;
+ BLI_assert(ele_walk->head.htype == BM_EDGE);
+ BM_edge_select_set(em->bm, e_step, true);
+ BM_elem_flag_disable(e_step->v1, BM_ELEM_TAG);
+ BM_elem_flag_disable(e_step->v2, BM_ELEM_TAG);
+ }
}
}
}
}
- }
- else {
- BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- BMEdge *e_walk;
- BMW_ITER (e_walk, &walker, v) {
- BM_edge_select_set(em->bm, e_walk, true);
- BM_elem_flag_disable(e_walk, BM_ELEM_TAG);
+ else {
+ BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ BMEdge *e_walk;
+ BMW_ITER (e_walk, &walker, v) {
+ BM_edge_select_set(em->bm, e_walk, true);
+ BM_elem_flag_disable(e_walk, BM_ELEM_TAG);
+ }
}
}
}
- }
- BMW_end(&walker);
+ BMW_end(&walker);
- EDBM_selectmode_flush(em);
- }
- else if (em->selectmode & SCE_SELECT_EDGE) {
- BMEdge *e;
+ EDBM_selectmode_flush(em);
+ }
+ else if (em->selectmode & SCE_SELECT_EDGE) {
+ BMEdge *e;
- if (delimit) {
- BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
- BM_elem_flag_set(
- e, BM_ELEM_TAG,
- (BM_elem_flag_test(e, BM_ELEM_SELECT) && BMO_edge_flag_test(bm, e, BMO_ELE_TAG)));
+ if (delimit) {
+ BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
+ BM_elem_flag_set(
+ e, BM_ELEM_TAG,
+ (BM_elem_flag_test(e, BM_ELEM_SELECT) && BMO_edge_flag_test(bm, e, BMO_ELE_TAG)));
+ }
}
- }
- else {
- BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
- BM_elem_flag_set(e, BM_ELEM_TAG, BM_elem_flag_test(e, BM_ELEM_SELECT));
+ else {
+ BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
+ BM_elem_flag_set(e, BM_ELEM_TAG, BM_elem_flag_test(e, BM_ELEM_SELECT));
+ }
}
- }
- BMW_init(&walker, em->bm, delimit ? BMW_LOOP_SHELL_WIRE : BMW_VERT_SHELL,
- BMW_MASK_NOP, delimit ? BMO_ELE_TAG : BMW_MASK_NOP, BMW_MASK_NOP,
- BMW_FLAG_TEST_HIDDEN,
- BMW_NIL_LAY);
-
- if (delimit) {
- BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
- BMElem *ele_walk;
- BMW_ITER (ele_walk, &walker, e) {
- if (ele_walk->head.htype == BM_LOOP) {
- BMLoop *l_step = (BMLoop *)ele_walk;
- BM_edge_select_set(em->bm, l_step->e, true);
- BM_edge_select_set(em->bm, l_step->prev->e, true);
- BM_elem_flag_disable(l_step->e, BM_ELEM_TAG);
- }
- else {
- BMEdge *e_step = (BMEdge *)ele_walk;
- BLI_assert(ele_walk->head.htype == BM_EDGE);
- BM_edge_select_set(em->bm, e_step, true);
- BM_elem_flag_disable(e_step, BM_ELEM_TAG);
+ BMW_init(&walker, em->bm, delimit ? BMW_LOOP_SHELL_WIRE : BMW_VERT_SHELL,
+ BMW_MASK_NOP, delimit ? BMO_ELE_TAG : BMW_MASK_NOP, BMW_MASK_NOP,
+ BMW_FLAG_TEST_HIDDEN,
+ BMW_NIL_LAY);
+
+ if (delimit) {
+ BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ BMElem *ele_walk;
+ BMW_ITER (ele_walk, &walker, e) {
+ if (ele_walk->head.htype == BM_LOOP) {
+ BMLoop *l_step = (BMLoop *)ele_walk;
+ BM_edge_select_set(em->bm, l_step->e, true);
+ BM_edge_select_set(em->bm, l_step->prev->e, true);
+ BM_elem_flag_disable(l_step->e, BM_ELEM_TAG);
+ }
+ else {
+ BMEdge *e_step = (BMEdge *)ele_walk;
+ BLI_assert(ele_walk->head.htype == BM_EDGE);
+ BM_edge_select_set(em->bm, e_step, true);
+ BM_elem_flag_disable(e_step, BM_ELEM_TAG);
+ }
}
}
}
}
- }
- else {
- BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
- BMEdge *e_walk;
- BMW_ITER (e_walk, &walker, e) {
- BM_edge_select_set(em->bm, e_walk, true);
- BM_elem_flag_disable(e_walk, BM_ELEM_TAG);
+ else {
+ BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ BMEdge *e_walk;
+ BMW_ITER (e_walk, &walker, e) {
+ BM_edge_select_set(em->bm, e_walk, true);
+ BM_elem_flag_disable(e_walk, BM_ELEM_TAG);
+ }
}
}
}
- }
-
- BMW_end(&walker);
- EDBM_selectmode_flush(em);
- }
- else {
- BMFace *f;
+ BMW_end(&walker);
- BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- BM_elem_flag_set(f, BM_ELEM_TAG, BM_elem_flag_test(f, BM_ELEM_SELECT));
+ EDBM_selectmode_flush(em);
}
+ else {
+ BMFace *f;
- BMW_init(&walker, bm, BMW_ISLAND,
- BMW_MASK_NOP, delimit ? BMO_ELE_TAG : BMW_MASK_NOP, BMW_MASK_NOP,
- BMW_FLAG_TEST_HIDDEN,
- BMW_NIL_LAY);
+ BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
+ BM_elem_flag_set(f, BM_ELEM_TAG, BM_elem_flag_test(f, BM_ELEM_SELECT));
+ }
- BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(f, BM_ELEM_TAG)) {
- BMFace *f_walk;
- BMW_ITER (f_walk, &walker, f) {
- BM_face_select_set(bm, f_walk, true);
- BM_elem_flag_disable(f_walk, BM_ELEM_TAG);
+ BMW_init(&walker, bm, BMW_ISLAND,
+ BMW_MASK_NOP, delimit ? BMO_ELE_TAG : BMW_MASK_NOP, BMW_MASK_NOP,
+ BMW_FLAG_TEST_HIDDEN,
+ BMW_NIL_LAY);
+
+ BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (BM_elem_flag_test(f, BM_ELEM_TAG)) {
+ BMFace *f_walk;
+ BMW_ITER (f_walk, &walker, f) {
+ BM_face_select_set(bm, f_walk, true);
+ BM_elem_flag_disable(f_walk, BM_ELEM_TAG);
+ }
}
}
+
+ BMW_end(&walker);
}
- BMW_end(&walker);
- }
+ if (delimit) {
+ select_linked_delimit_end(em);
+ }
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- if (delimit) {
- select_linked_delimit_end(em);
}
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ MEM_SAFE_FREE(objects);
return OPERATOR_FINISHED;
}
@@ -2902,11 +3015,8 @@ static void edbm_select_linked_pick_ex(BMEditMesh *em, BMElem *ele, bool sel, in
static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- Object *obedit = CTX_data_edit_object(C);
- EvaluationContext eval_ctx;
ViewContext vc;
- BMEditMesh *em;
- BMesh *bm;
+ Base *basact = NULL;
BMVert *eve;
BMEdge *eed;
BMFace *efa;
@@ -2921,27 +3031,40 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
view3d_operator_needs_opengl(C);
/* setup view context for argument to callbacks */
- CTX_data_eval_ctx(C, &eval_ctx);
em_setup_viewcontext(C, &vc);
- em = vc.em;
- bm = em->bm;
- if (bm->totedge == 0) {
- return OPERATOR_CANCELLED;
+ {
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len);
+ bool has_edges = false;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ ED_view3d_viewcontext_init_object(&vc, ob_iter);
+ if (vc.em->bm->totedge) {
+ has_edges = true;
+ }
+ }
+ MEM_SAFE_FREE(objects);
+ if (has_edges == false) {
+ return OPERATOR_CANCELLED;
+ }
}
vc.mval[0] = event->mval[0];
vc.mval[1] = event->mval[1];
/* return warning! */
- if (unified_findnearest(&eval_ctx, &vc, &eve, &eed, &efa) == 0) {
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ if (unified_findnearest(&vc, &basact, &eve, &eed, &efa) == 0) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, basact->object->data);
return OPERATOR_CANCELLED;
}
+ ED_view3d_viewcontext_init_object(&vc, basact->object);
+ BMEditMesh *em = vc.em;
+ BMesh *bm = em->bm;
#ifdef USE_LINKED_SELECT_DEFAULT_HACK
- int delimit = select_linked_delimit_default_from_op(op, em->selectmode);
+ int delimit = select_linked_delimit_default_from_op(op, vc.scene->toolsettings->selectmode);
#else
int delimit = RNA_enum_get(op->ptr, "delimit");
#endif
@@ -2954,9 +3077,11 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
BM_mesh_elem_index_ensure(bm, ele->head.htype);
index = EDBM_elem_to_index_any(em, ele);
+ /* TODO(MULTI_EDIT), index doesn't know which object,
+ * index selections isn't very common. */
RNA_int_set(op->ptr, "index", index);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, basact->object->data);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index bf70cc3fa7e..371f42e17b3 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -93,10 +93,8 @@
static int edbm_subdivide_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
const int cuts = RNA_int_get(op->ptr, "number_cuts");
- float smooth = RNA_float_get(op->ptr, "smoothness");
+ const float smooth = RNA_float_get(op->ptr, "smoothness");
const float fractal = RNA_float_get(op->ptr, "fractal") / 2.5f;
const float along_normal = RNA_float_get(op->ptr, "fractal_along_normal");
@@ -105,17 +103,35 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op)
{
RNA_enum_set(op->ptr, "quadcorner", SUBD_CORNER_INNERVERT);
}
+ const int quad_corner_type = RNA_enum_get(op->ptr, "quadcorner");
+ const bool use_quad_tri = RNA_boolean_get(op->ptr, "quadtri");
+ const int seed = RNA_int_get(op->ptr, "seed");
- BM_mesh_esubdivide(
- em->bm, BM_ELEM_SELECT,
- smooth, SUBD_FALLOFF_LIN, false,
- fractal, along_normal,
- cuts,
- SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"),
- RNA_boolean_get(op->ptr, "quadtri"), true, false,
- RNA_int_get(op->ptr, "seed"));
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- EDBM_update_generic(em, true, true);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+
+ if (!(em->bm->totedgesel || em->bm->totfacesel)) {
+ continue;
+ }
+
+ BM_mesh_esubdivide(
+ em->bm, BM_ELEM_SELECT,
+ smooth, SUBD_FALLOFF_LIN, false,
+ fractal, along_normal,
+ cuts,
+ SUBDIV_SELECT_ORIG, quad_corner_type,
+ use_quad_tri, true, false,
+ seed);
+
+ EDBM_update_generic(em, true, true);
+ }
+
+ MEM_SAFE_FREE(objects);
return OPERATOR_FINISHED;
}
@@ -326,7 +342,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
ED_view3d_init_mats_rv3d(obedit, ar->regiondata);
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), CTX_data_scene(C), CTX_data_view_layer(C), 0,
+ CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ar, CTX_wm_view3d(C));
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
@@ -367,50 +383,58 @@ enum {
MESH_DELETE_ONLY_FACE = 4,
};
-static void edbm_report_delete_info(ReportList *reports, BMesh *bm, const int totelem[3])
+static void edbm_report_delete_info(ReportList *reports, const int totelem_old[3], const int totelem_new[3])
{
BKE_reportf(reports, RPT_INFO,
"Removed: %d vertices, %d edges, %d faces",
- totelem[0] - bm->totvert, totelem[1] - bm->totedge, totelem[2] - bm->totface);
+ totelem_old[0] - totelem_new[0], totelem_old[1] - totelem_new[1], totelem_old[2] - totelem_new[2]);
}
static int edbm_delete_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- const int type = RNA_enum_get(op->ptr, "type");
+ ViewLayer *view_layer = CTX_data_view_layer(C);
- switch (type) {
- case MESH_DELETE_VERT:
- if (!EDBM_op_callf(em, op, "delete geom=%hv context=%i", BM_ELEM_SELECT, DEL_VERTS)) /* Erase Vertices */
- return OPERATOR_CANCELLED;
- break;
- case MESH_DELETE_EDGE:
- if (!EDBM_op_callf(em, op, "delete geom=%he context=%i", BM_ELEM_SELECT, DEL_EDGES)) /* Erase Edges */
- return OPERATOR_CANCELLED;
- break;
- case MESH_DELETE_FACE:
- if (!EDBM_op_callf(em, op, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES)) /* Erase Faces */
- return OPERATOR_CANCELLED;
- break;
- case MESH_DELETE_EDGE_FACE:
- /* Edges and Faces */
- if (!EDBM_op_callf(em, op, "delete geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES))
- return OPERATOR_CANCELLED;
- break;
- case MESH_DELETE_ONLY_FACE:
- /* Only faces. */
- if (!EDBM_op_callf(em, op, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_ONLYFACES))
- return OPERATOR_CANCELLED;
- break;
- default:
- BLI_assert(0);
- break;
- }
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ const int type = RNA_enum_get(op->ptr, "type");
- EDBM_update_generic(em, true, true);
+ switch (type) {
+ case MESH_DELETE_VERT:
+ if (!EDBM_op_callf(em, op, "delete geom=%hv context=%i", BM_ELEM_SELECT, DEL_VERTS)) /* Erase Vertices */
+ return OPERATOR_CANCELLED;
+ break;
+ case MESH_DELETE_EDGE:
+ if (!EDBM_op_callf(em, op, "delete geom=%he context=%i", BM_ELEM_SELECT, DEL_EDGES)) /* Erase Edges */
+ return OPERATOR_CANCELLED;
+ break;
+ case MESH_DELETE_FACE:
+ if (!EDBM_op_callf(em, op, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES)) /* Erase Faces */
+ return OPERATOR_CANCELLED;
+ break;
+ case MESH_DELETE_EDGE_FACE:
+ /* Edges and Faces */
+ if (!EDBM_op_callf(em, op, "delete geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES))
+ return OPERATOR_CANCELLED;
+ break;
+ case MESH_DELETE_ONLY_FACE:
+ /* Only faces. */
+ if (!EDBM_op_callf(em, op, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_ONLYFACES))
+ return OPERATOR_CANCELLED;
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
+
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+
+ EDBM_update_generic(em, true, true);
+
+ }
return OPERATOR_FINISHED;
}
@@ -467,61 +491,75 @@ static bool bm_face_is_loose(BMFace *f)
static int edbm_delete_loose_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMesh *bm = em->bm;
- BMIter iter;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ int totelem_old_sel[3];
+ int totelem_old[3];
- const bool use_verts = (RNA_boolean_get(op->ptr, "use_verts") && bm->totvertsel);
- const bool use_edges = (RNA_boolean_get(op->ptr, "use_edges") && bm->totedgesel);
- const bool use_faces = (RNA_boolean_get(op->ptr, "use_faces") && bm->totfacesel);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- const int totelem[3] = {bm->totvert, bm->totedge, bm->totface};
+ EDBM_mesh_stats_multi(objects, objects_len, totelem_old, totelem_old_sel);
+ const bool use_verts = (RNA_boolean_get(op->ptr, "use_verts") && totelem_old_sel[0]);
+ const bool use_edges = (RNA_boolean_get(op->ptr, "use_edges") && totelem_old_sel[1]);
+ const bool use_faces = (RNA_boolean_get(op->ptr, "use_faces") && totelem_old_sel[2]);
- BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
- if (use_faces) {
- BMFace *f;
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+ BMIter iter;
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
- BM_elem_flag_set(f, BM_ELEM_TAG, bm_face_is_loose(f));
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
+
+ if (use_faces) {
+ BMFace *f;
+
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+ BM_elem_flag_set(f, BM_ELEM_TAG, bm_face_is_loose(f));
+ }
}
+
+ BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_FACES);
}
- BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_FACES);
- }
+ if (use_edges) {
+ BMEdge *e;
- if (use_edges) {
- BMEdge *e;
-
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
- BM_elem_flag_set(e, BM_ELEM_TAG, BM_edge_is_wire(e));
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
+ BM_elem_flag_set(e, BM_ELEM_TAG, BM_edge_is_wire(e));
+ }
}
- }
- BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_EDGES);
- }
+ BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_EDGES);
+ }
- if (use_verts) {
- BMVert *v;
+ if (use_verts) {
+ BMVert *v;
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
- BM_elem_flag_set(v, BM_ELEM_TAG, (v->e == NULL));
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
+ BM_elem_flag_set(v, BM_ELEM_TAG, (v->e == NULL));
+ }
}
+
+ BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_VERTS);
}
- BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_VERTS);
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+
+ EDBM_update_generic(em, true, true);
}
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ int totelem_new[3];
+ EDBM_mesh_stats_multi(objects, objects_len, totelem_new, NULL);
- EDBM_update_generic(em, true, true);
+ edbm_report_delete_info(op->reports, totelem_old, totelem_new);
- edbm_report_delete_info(op->reports, bm, totelem);
+ MEM_SAFE_FREE(objects);
return OPERATOR_FINISHED;
}
@@ -1437,19 +1475,32 @@ void MESH_OT_vert_connect_nonplanar(wmOperatorType *ot)
static int edbm_face_make_planar_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
const int repeat = RNA_int_get(op->ptr, "repeat");
const float fac = RNA_float_get(op->ptr, "factor");
- if (!EDBM_op_callf(
- em, op, "planar_faces faces=%hf iterations=%i factor=%f",
- BM_ELEM_SELECT, repeat, fac))
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++)
{
- return OPERATOR_CANCELLED;
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ if (em->bm->totfacesel == 0) {
+ continue;
+ }
+
+ if (!EDBM_op_callf(
+ em, op, "planar_faces faces=%hf iterations=%i factor=%f",
+ BM_ELEM_SELECT, repeat, fac))
+ {
+ continue;
+ }
+
+ EDBM_update_generic(em, true, true);
}
+ MEM_freeN(objects);
- EDBM_update_generic(em, true, true);
return OPERATOR_FINISHED;
}
@@ -1524,33 +1575,43 @@ void MESH_OT_edge_split(wmOperatorType *ot)
static int edbm_duplicate_exec(bContext *C, wmOperator *op)
{
- Object *ob = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(ob);
- BMesh *bm = em->bm;
- BMOperator bmop;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- EDBM_op_init(
- em, &bmop, op,
- "duplicate geom=%hvef use_select_history=%b",
- BM_ELEM_SELECT, true);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ if (em->bm->totvertsel == 0) {
+ continue;
+ }
- BMO_op_exec(bm, &bmop);
+ BMOperator bmop;
+ BMesh *bm = em->bm;
- /* de-select all would clear otherwise */
- BM_SELECT_HISTORY_BACKUP(bm);
+ EDBM_op_init(
+ em, &bmop, op,
+ "duplicate geom=%hvef use_select_history=%b",
+ BM_ELEM_SELECT, true);
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ BMO_op_exec(bm, &bmop);
- BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
+ /* de-select all would clear otherwise */
+ BM_SELECT_HISTORY_BACKUP(bm);
- /* rebuild editselection */
- BM_SELECT_HISTORY_RESTORE(bm);
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return OPERATOR_CANCELLED;
- }
+ BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
- EDBM_update_generic(em, true, true);
+ /* rebuild editselection */
+ BM_SELECT_HISTORY_RESTORE(bm);
+
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ continue;
+ }
+ EDBM_update_generic(em, true, true);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -1588,18 +1649,29 @@ void MESH_OT_duplicate(wmOperatorType *ot)
* \{ */
static int edbm_flip_normals_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- if (!EDBM_op_callf(
- em, op, "reverse_faces faces=%hf flip_multires=%b",
- BM_ELEM_SELECT, true))
- {
- return OPERATOR_CANCELLED;
- }
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
- EDBM_update_generic(em, true, false);
+ if (em->bm->totfacesel == 0) {
+ continue;
+ }
+ if (!EDBM_op_callf(
+ em, op, "reverse_faces faces=%hf flip_multires=%b",
+ BM_ELEM_SELECT, true))
+ {
+ continue;
+ }
+
+ EDBM_update_generic(em, true, false);
+ }
+
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -2504,60 +2576,79 @@ void MESH_OT_merge(wmOperatorType *ot)
static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMOperator bmop;
const float threshold = RNA_float_get(op->ptr, "threshold");
const bool use_unselected = RNA_boolean_get(op->ptr, "use_unselected");
- const int totvert_orig = em->bm->totvert;
- int count;
- char htype_select;
+ int count_multi = 0;
- /* avoid loosing selection state (select -> tags) */
- if (em->selectmode & SCE_SELECT_VERTEX) htype_select = BM_VERT;
- else if (em->selectmode & SCE_SELECT_EDGE) htype_select = BM_EDGE;
- else htype_select = BM_FACE;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- /* store selection as tags */
- BM_mesh_elem_hflag_enable_test(em->bm, htype_select, BM_ELEM_TAG, true, true, BM_ELEM_SELECT);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ /* Selection used as target with 'use_unselected'. */
+ if (em->bm->totvertsel == 0) {
+ continue;
+ }
- if (use_unselected) {
- EDBM_op_init(
- em, &bmop, op,
- "automerge verts=%hv dist=%f",
- BM_ELEM_SELECT, threshold);
- BMO_op_exec(em->bm, &bmop);
+ BMOperator bmop;
+ const int totvert_orig = em->bm->totvert;
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return OPERATOR_CANCELLED;
- }
- }
- else {
- EDBM_op_init(
- em, &bmop, op,
- "find_doubles verts=%hv dist=%f",
- BM_ELEM_SELECT, threshold);
- BMO_op_exec(em->bm, &bmop);
+ /* avoid loosing selection state (select -> tags) */
+ char htype_select;
+ if (em->selectmode & SCE_SELECT_VERTEX) htype_select = BM_VERT;
+ else if (em->selectmode & SCE_SELECT_EDGE) htype_select = BM_EDGE;
+ else htype_select = BM_FACE;
- if (!EDBM_op_callf(em, op, "weld_verts targetmap=%S", &bmop, "targetmap.out")) {
- BMO_op_finish(em->bm, &bmop);
- return OPERATOR_CANCELLED;
+ /* store selection as tags */
+ BM_mesh_elem_hflag_enable_test(em->bm, htype_select, BM_ELEM_TAG, true, true, BM_ELEM_SELECT);
+
+
+ if (use_unselected) {
+ EDBM_op_init(
+ em, &bmop, op,
+ "automerge verts=%hv dist=%f",
+ BM_ELEM_SELECT, threshold);
+ BMO_op_exec(em->bm, &bmop);
+
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ continue;
+ }
}
+ else {
+ EDBM_op_init(
+ em, &bmop, op,
+ "find_doubles verts=%hv dist=%f",
+ BM_ELEM_SELECT, threshold);
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return OPERATOR_CANCELLED;
+ BMO_op_exec(em->bm, &bmop);
+
+ if (!EDBM_op_callf(em, op, "weld_verts targetmap=%S", &bmop, "targetmap.out")) {
+ BMO_op_finish(em->bm, &bmop);
+ continue;
+ }
+
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ continue;
+ }
}
- }
- count = totvert_orig - em->bm->totvert;
- BKE_reportf(op->reports, RPT_INFO, "Removed %d vertices", count);
+ const int count = (totvert_orig - em->bm->totvert);
- /* restore selection from tags */
- BM_mesh_elem_hflag_enable_test(em->bm, htype_select, BM_ELEM_SELECT, true, true, BM_ELEM_TAG);
- EDBM_selectmode_flush(em);
+ /* restore selection from tags */
+ BM_mesh_elem_hflag_enable_test(em->bm, htype_select, BM_ELEM_SELECT, true, true, BM_ELEM_TAG);
+ EDBM_selectmode_flush(em);
- EDBM_update_generic(em, true, true);
+ if (count) {
+ count_multi += count;
+ EDBM_update_generic(em, true, true);
+ }
+ }
+ MEM_freeN(objects);
+
+ BKE_reportf(op->reports, RPT_INFO, "Removed %d vertices", count_multi);
return OPERATOR_FINISHED;
}
@@ -4032,30 +4123,40 @@ void MESH_OT_beautify_fill(wmOperatorType *ot)
static int edbm_poke_face_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMOperator bmop;
-
const float offset = RNA_float_get(op->ptr, "offset");
const bool use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset");
const int center_mode = RNA_enum_get(op->ptr, "center_mode");
- EDBM_op_init(em, &bmop, op, "poke faces=%hf offset=%f use_relative_offset=%b center_mode=%i",
- BM_ELEM_SELECT, offset, use_relative_offset, center_mode);
- BMO_op_exec(em->bm, &bmop);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ if (em->bm->totfacesel == 0) {
+ continue;
+ }
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, true);
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
+ BMOperator bmop;
+ EDBM_op_init(em, &bmop, op, "poke faces=%hf offset=%f use_relative_offset=%b center_mode=%i",
+ BM_ELEM_SELECT, offset, use_relative_offset, center_mode);
+ BMO_op_exec(em->bm, &bmop);
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return OPERATOR_CANCELLED;
- }
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- EDBM_mesh_normals_update(em);
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, true);
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
- EDBM_update_generic(em, true, true);
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ continue;
+ }
+
+ EDBM_mesh_normals_update(em);
+
+ EDBM_update_generic(em, true, true);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
@@ -4096,32 +4197,48 @@ void MESH_OT_poke(wmOperatorType *ot)
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 int quad_method = RNA_enum_get(op->ptr, "quad_method");
const int ngon_method = RNA_enum_get(op->ptr, "ngon_method");
- BMOIter oiter;
- BMFace *f;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
- 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);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
- /* select the output */
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
+ if (em->bm->totfacesel == 0) {
+ continue;
+ }
- /* remove the doubles */
- BMO_ITER (f, &oiter, bmop.slots_out, "face_map_double.out", BM_FACE) {
- BM_face_kill(em->bm, f);
- }
+ BMOperator bmop;
+ BMOIter oiter;
+ BMFace *f;
- EDBM_selectmode_flush(em);
+ 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);
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return OPERATOR_CANCELLED;
+ /* select the output */
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
+
+ /* remove the doubles */
+ BMO_ITER (f, &oiter, bmop.slots_out, "face_map_double.out", BM_FACE) {
+ BM_face_kill(em->bm, f);
+ }
+
+ EDBM_selectmode_flush(em);
+
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ continue;
+ }
+
+ EDBM_update_generic(em, true, true);
}
- EDBM_update_generic(em, true, true);
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -4155,52 +4272,68 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot)
static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- bool do_seam, do_sharp, do_uvs, do_vcols, do_materials;
- float angle_face_threshold, angle_shape_threshold;
- PropertyRNA *prop;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
- /* When joining exactly 2 faces, no limit.
- * this is useful for one off joins while editing. */
- prop = RNA_struct_find_property(op->ptr, "face_threshold");
- if ((em->bm->totfacesel == 2) &&
- (RNA_property_is_set(op->ptr, prop) == false))
- {
- angle_face_threshold = DEG2RADF(180.0f);
- }
- else {
- angle_face_threshold = RNA_property_float_get(op->ptr, prop);
- }
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ bool is_face_pair;
- prop = RNA_struct_find_property(op->ptr, "shape_threshold");
- if ((em->bm->totfacesel == 2) &&
- (RNA_property_is_set(op->ptr, prop) == false))
{
- angle_shape_threshold = DEG2RADF(180.0f);
- }
- else {
- angle_shape_threshold = RNA_property_float_get(op->ptr, prop);
+ int totelem_sel[3];
+ EDBM_mesh_stats_multi(objects, objects_len, NULL, totelem_sel);
+ is_face_pair = (totelem_sel[2] == 2);
}
- do_seam = RNA_boolean_get(op->ptr, "seam");
- do_sharp = RNA_boolean_get(op->ptr, "sharp");
- do_uvs = RNA_boolean_get(op->ptr, "uvs");
- do_vcols = RNA_boolean_get(op->ptr, "vcols");
- do_materials = RNA_boolean_get(op->ptr, "materials");
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
- if (!EDBM_op_call_and_selectf(
- em, op,
- "faces.out", true,
- "join_triangles faces=%hf angle_face_threshold=%f angle_shape_threshold=%f "
- "cmp_seam=%b cmp_sharp=%b cmp_uvs=%b cmp_vcols=%b cmp_materials=%b",
- BM_ELEM_SELECT, angle_face_threshold, angle_shape_threshold,
- do_seam, do_sharp, do_uvs, do_vcols, do_materials))
- {
- return OPERATOR_CANCELLED;
- }
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ bool do_seam, do_sharp, do_uvs, do_vcols, do_materials;
+ float angle_face_threshold, angle_shape_threshold;
+ PropertyRNA *prop;
+
+ /* When joining exactly 2 faces, no limit.
+ * this is useful for one off joins while editing. */
+ prop = RNA_struct_find_property(op->ptr, "face_threshold");
+ if (is_face_pair &&
+ (RNA_property_is_set(op->ptr, prop) == false))
+ {
+ angle_face_threshold = DEG2RADF(180.0f);
+ }
+ else {
+ angle_face_threshold = RNA_property_float_get(op->ptr, prop);
+ }
- EDBM_update_generic(em, true, true);
+ prop = RNA_struct_find_property(op->ptr, "shape_threshold");
+ if (is_face_pair &&
+ (RNA_property_is_set(op->ptr, prop) == false))
+ {
+ angle_shape_threshold = DEG2RADF(180.0f);
+ }
+ else {
+ angle_shape_threshold = RNA_property_float_get(op->ptr, prop);
+ }
+
+ do_seam = RNA_boolean_get(op->ptr, "seam");
+ do_sharp = RNA_boolean_get(op->ptr, "sharp");
+ do_uvs = RNA_boolean_get(op->ptr, "uvs");
+ do_vcols = RNA_boolean_get(op->ptr, "vcols");
+ do_materials = RNA_boolean_get(op->ptr, "materials");
+
+ if (!EDBM_op_call_and_selectf(
+ em, op,
+ "faces.out", true,
+ "join_triangles faces=%hf angle_face_threshold=%f angle_shape_threshold=%f "
+ "cmp_seam=%b cmp_sharp=%b cmp_uvs=%b cmp_vcols=%b cmp_materials=%b",
+ BM_ELEM_SELECT, angle_face_threshold, angle_shape_threshold,
+ do_seam, do_sharp, do_uvs, do_vcols, do_materials))
+ {
+ continue;
+ }
+
+ EDBM_update_generic(em, true, true);
+ }
return OPERATOR_FINISHED;
}
@@ -4256,10 +4389,6 @@ void MESH_OT_tris_convert_to_quads(wmOperatorType *ot)
static int edbm_decimate_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMesh *bm = em->bm;
-
const float ratio = RNA_float_get(op->ptr, "ratio");
bool use_vertex_group = RNA_boolean_get(op->ptr, "use_vertex_group");
const float vertex_group_factor = RNA_float_get(op->ptr, "vertex_group_factor");
@@ -4273,95 +4402,108 @@ static int edbm_decimate_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- float *vweights = MEM_mallocN(sizeof(*vweights) * bm->totvert, __func__);
- {
- const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
- const int defbase_act = obedit->actdef - 1;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- if (use_vertex_group && (cd_dvert_offset == -1)) {
- BKE_report(op->reports, RPT_WARNING, "No active vertex group");
- use_vertex_group = false;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+ if (bm->totedgesel == 0) {
+ continue;
}
- BMIter iter;
- BMVert *v;
- int i;
- BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
- float weight = 0.0f;
- if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
- if (use_vertex_group) {
- const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset);
- weight = defvert_find_weight(dv, defbase_act);
- if (invert_vertex_group) {
- weight = 1.0f - weight;
+ float *vweights = MEM_mallocN(sizeof(*vweights) * bm->totvert, __func__);
+ {
+ const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
+ const int defbase_act = obedit->actdef - 1;
+
+ if (use_vertex_group && (cd_dvert_offset == -1)) {
+ BKE_report(op->reports, RPT_WARNING, "No active vertex group");
+ use_vertex_group = false;
+ }
+
+ BMIter iter;
+ BMVert *v;
+ int i;
+ BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
+ float weight = 0.0f;
+ if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
+ if (use_vertex_group) {
+ const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset);
+ weight = defvert_find_weight(dv, defbase_act);
+ if (invert_vertex_group) {
+ weight = 1.0f - weight;
+ }
+ }
+ else {
+ weight = 1.0f;
}
}
- else {
- weight = 1.0f;
- }
- }
- vweights[i] = weight;
- BM_elem_index_set(v, i); /* set_inline */
+ vweights[i] = weight;
+ BM_elem_index_set(v, i); /* set_inline */
+ }
+ bm->elem_index_dirty &= ~BM_VERT;
}
- bm->elem_index_dirty &= ~BM_VERT;
- }
-
- float ratio_adjust;
-
- if ((bm->totface == bm->totfacesel) || (ratio == 0.0f)) {
- ratio_adjust = ratio;
- }
- else {
- /**
- * Calculate a new ratio based on faces that could be remoevd during decimation.
- * needed so 0..1 has a meaningful range when operating on the selection.
- *
- * This doesn't have to be totally accurate,
- * but needs to be greater than the number of selected faces
- */
- int totface_basis = 0;
- int totface_adjacent = 0;
- BMIter iter;
- BMFace *f;
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- /* count faces during decimation, ngons are triangulated */
- const int f_len = f->len > 4 ? (f->len - 2) : 1;
- totface_basis += f_len;
+ float ratio_adjust;
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- if (vweights[BM_elem_index_get(l_iter->v)] != 0.0f) {
- totface_adjacent += f_len;
- break;
- }
- } while ((l_iter = l_iter->next) != l_first);
+ if ((bm->totface == bm->totfacesel) || (ratio == 0.0f)) {
+ ratio_adjust = ratio;
}
+ else {
+ /**
+ * Calculate a new ratio based on faces that could be remoevd during decimation.
+ * needed so 0..1 has a meaningful range when operating on the selection.
+ *
+ * This doesn't have to be totally accurate,
+ * but needs to be greater than the number of selected faces
+ */
+
+ int totface_basis = 0;
+ int totface_adjacent = 0;
+ BMIter iter;
+ BMFace *f;
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ /* count faces during decimation, ngons are triangulated */
+ const int f_len = f->len > 4 ? (f->len - 2) : 1;
+ totface_basis += f_len;
+
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ if (vweights[BM_elem_index_get(l_iter->v)] != 0.0f) {
+ totface_adjacent += f_len;
+ break;
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+ }
- ratio_adjust = ratio;
- ratio_adjust = 1.0f - ratio_adjust;
- ratio_adjust *= (float)totface_adjacent / (float)totface_basis;
- ratio_adjust = 1.0f - ratio_adjust;
- }
+ ratio_adjust = ratio;
+ ratio_adjust = 1.0f - ratio_adjust;
+ ratio_adjust *= (float)totface_adjacent / (float)totface_basis;
+ ratio_adjust = 1.0f - ratio_adjust;
+ }
- BM_mesh_decimate_collapse(
- em->bm, ratio_adjust, vweights, vertex_group_factor, false,
- symmetry_axis, symmetry_eps);
+ BM_mesh_decimate_collapse(
+ em->bm, ratio_adjust, vweights, vertex_group_factor, false,
+ symmetry_axis, symmetry_eps);
- MEM_freeN(vweights);
+ MEM_freeN(vweights);
- {
- short selectmode = em->selectmode;
- if ((selectmode & (SCE_SELECT_VERTEX | SCE_SELECT_EDGE)) == 0) {
- /* ensure we flush edges -> faces */
- selectmode |= SCE_SELECT_EDGE;
+ {
+ short selectmode = em->selectmode;
+ if ((selectmode & (SCE_SELECT_VERTEX | SCE_SELECT_EDGE)) == 0) {
+ /* ensure we flush edges -> faces */
+ selectmode |= SCE_SELECT_EDGE;
+ }
+ EDBM_selectmode_flush_ex(em, selectmode);
}
- EDBM_selectmode_flush_ex(em, selectmode);
+ EDBM_update_generic(em, true, true);
}
-
- EDBM_update_generic(em, true, true);
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -4727,26 +4869,48 @@ void MESH_OT_dissolve_limited(wmOperatorType *ot)
static int edbm_dissolve_degenerate_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ int totelem_old[3] = {0, 0, 0};
+ int totelem_new[3] = {0, 0, 0};
+
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+ totelem_old[0] += bm->totvert;
+ totelem_old[1] += bm->totedge;
+ totelem_old[2] += bm->totface;
+ } /* objects */
+
const float thresh = RNA_float_get(op->ptr, "threshold");
- BMesh *bm = em->bm;
- const int totelem[3] = {bm->totvert, bm->totedge, bm->totface};
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
- if (!EDBM_op_callf(
- em, op,
- "dissolve_degenerate edges=%he dist=%f",
- BM_ELEM_SELECT, thresh))
- {
- return OPERATOR_CANCELLED;
- }
+ if (!EDBM_op_callf(
+ em, op,
+ "dissolve_degenerate edges=%he dist=%f",
+ BM_ELEM_SELECT, thresh))
+ {
+ return OPERATOR_CANCELLED;
+ }
- /* tricky to maintain correct selection here, so just flush up from verts */
- EDBM_select_flush(em);
+ /* tricky to maintain correct selection here, so just flush up from verts */
+ EDBM_select_flush(em);
- EDBM_update_generic(em, true, true);
+ EDBM_update_generic(em, true, true);
- edbm_report_delete_info(op->reports, bm, totelem);
+ totelem_new[0] += bm->totvert;
+ totelem_new[1] += bm->totedge;
+ totelem_new[2] += bm->totface;
+ }
+
+ edbm_report_delete_info(op->reports, totelem_old, totelem_new);
return OPERATOR_FINISHED;
}
@@ -5420,7 +5584,7 @@ static void edbm_sort_elements_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call. */
- uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
void MESH_OT_sort_elements(wmOperatorType *ot)
@@ -5475,84 +5639,6 @@ void MESH_OT_sort_elements(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Noise (Deform Vertices) Operator
- * \{ */
-
-static int edbm_noise_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- Material *ma;
- Tex *tex;
- BMVert *eve;
- BMIter iter;
- const float fac = RNA_float_get(op->ptr, "factor");
-
- if (em == NULL) {
- return OPERATOR_FINISHED;
- }
-
- if ((ma = give_current_material(obedit, obedit->actcol)) == NULL ||
- (tex = give_current_material_texture(ma)) == NULL)
- {
- BKE_report(op->reports, RPT_WARNING, "Mesh has no material or texture assigned");
- return OPERATOR_FINISHED;
- }
-
- if (tex->type == TEX_STUCCI) {
- float b2, vec[3];
- float ofs = tex->turbul / 200.0f;
- BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- b2 = BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2]);
- if (tex->stype) ofs *= (b2 * b2);
- vec[0] = fac * (b2 - BLI_hnoise(tex->noisesize, eve->co[0] + ofs, eve->co[1], eve->co[2]));
- vec[1] = fac * (b2 - BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1] + ofs, eve->co[2]));
- vec[2] = fac * (b2 - BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2] + ofs));
-
- add_v3_v3(eve->co, vec);
- }
- }
- }
- else {
- BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- float tin = 0.0f, dum;
- if (ma->mtex[ma->texact] != NULL) {
- externtex(ma->mtex[ma->texact], eve->co, &tin, &dum, &dum, &dum, &dum, 0, NULL, false, false);
- }
- eve->co[2] += fac * tin;
- }
- }
- }
-
- EDBM_mesh_normals_update(em);
-
- EDBM_update_generic(em, true, false);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_noise(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Noise";
- ot->description = "Use vertex coordinate as texture coordinate";
- ot->idname = "MESH_OT_noise";
-
- /* api callbacks */
- ot->exec = edbm_noise_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_float(ot->srna, "factor", 0.1f, -1e4f, 1e4f, "Factor", "", 0.0f, 1.0f);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Bridge Operator
* \{ */
@@ -5991,30 +6077,42 @@ void MESH_OT_convex_hull(wmOperatorType *ot)
static int mesh_symmetrize_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMOperator bmop;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- const float thresh = RNA_float_get(op->ptr, "threshold");
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
- EDBM_op_init(
- em, &bmop, op,
- "symmetrize input=%hvef direction=%i dist=%f",
- BM_ELEM_SELECT, RNA_enum_get(op->ptr, "direction"), thresh);
- BMO_op_exec(em->bm, &bmop);
+ if (em->bm->totvertsel == 0 ) {
+ continue;
+ }
+ BMOperator bmop;
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ const float thresh = RNA_float_get(op->ptr, "threshold");
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
+ EDBM_op_init(
+ em, &bmop, op,
+ "symmetrize input=%hvef direction=%i dist=%f",
+ BM_ELEM_SELECT, RNA_enum_get(op->ptr, "direction"), thresh);
+ BMO_op_exec(em->bm, &bmop);
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return OPERATOR_CANCELLED;
- }
- else {
- EDBM_update_generic(em, true, true);
- EDBM_selectmode_flush(em);
- return OPERATOR_FINISHED;
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
+
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ continue;
+ }
+ else {
+ EDBM_update_generic(em, true, true);
+ EDBM_selectmode_flush(em);
+ }
}
+ MEM_freeN(objects);
+
+ return OPERATOR_FINISHED;
}
void MESH_OT_symmetrize(struct wmOperatorType *ot)
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index ab7e13117a0..4d4b7a098b0 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -24,9 +24,12 @@
#include "MEM_guardedalloc.h"
+#include "CLG_log.h"
+
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_key_types.h"
+#include "DNA_layer_types.h"
#include "BLI_listbase.h"
#include "BLI_array_utils.h"
@@ -35,6 +38,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_context.h"
#include "BKE_key.h"
+#include "BKE_layer.h"
#include "BKE_mesh.h"
#include "BKE_editmesh.h"
#include "BKE_undo_system.h"
@@ -44,6 +48,7 @@
#include "ED_object.h"
#include "ED_mesh.h"
#include "ED_util.h"
+#include "ED_undo.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -69,6 +74,9 @@
# include "BLI_task.h"
#endif
+/** We only need this locally. */
+static CLG_LogRef LOG = {"ed.undo.mesh"};
+
/* -------------------------------------------------------------------- */
/** \name Undo Conversion
* \{ */
@@ -668,16 +676,21 @@ static Object *editmesh_object_from_context(bContext *C)
/* -------------------------------------------------------------------- */
/** \name Implements ED Undo System
+ *
+ * \note This is similar for all edit-mode types.
* \{ */
+typedef struct MeshUndoStep_Elem {
+ struct MeshUndoStep_Elem *next, *prev;
+ UndoRefID_Object obedit_ref;
+ UndoMesh data;
+} MeshUndoStep_Elem;
+
typedef struct MeshUndoStep {
UndoStep step;
- /* Use for all ID lookups (can be NULL). */
struct UndoIDPtrMap *id_map;
-
- /* note: will split out into list for multi-object-editmode. */
- UndoRefID_Object obedit_ref;
- UndoMesh data;
+ MeshUndoStep_Elem *elems;
+ uint elems_len;
} MeshUndoStep;
static bool mesh_undosys_poll(bContext *C)
@@ -688,10 +701,24 @@ static bool mesh_undosys_poll(bContext *C)
static bool mesh_undosys_step_encode(struct bContext *C, UndoStep *us_p)
{
MeshUndoStep *us = (MeshUndoStep *)us_p;
- us->obedit_ref.ptr = editmesh_object_from_context(C);
- Mesh *me = us->obedit_ref.ptr->data;
- undomesh_from_editmesh(&us->data, me->edit_btmesh, me->key);
- us->step.data_size = us->data.undo_size;
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
+ us->elems_len = objects_len;
+
+ for (uint i = 0; i < objects_len; i++) {
+ Object *ob = objects[i];
+ MeshUndoStep_Elem *elem = &us->elems[i];
+
+ elem->obedit_ref.ptr = ob;
+ Mesh *me = elem->obedit_ref.ptr->data;
+ undomesh_from_editmesh(&elem->data, me->edit_btmesh, me->key);
+ us->step.data_size += elem->data.undo_size;
+ }
+ MEM_freeN(objects);
return true;
}
@@ -702,18 +729,37 @@ static void mesh_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNU
BLI_assert(mesh_undosys_poll(C));
MeshUndoStep *us = (MeshUndoStep *)us_p;
- Object *obedit = us->obedit_ref.ptr;
- Mesh *me = obedit->data;
- BMEditMesh *em = me->edit_btmesh;
- undomesh_to_editmesh(&us->data, em, obedit->data);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ MeshUndoStep_Elem *elem = &us->elems[i];
+ Object *obedit = elem->obedit_ref.ptr;
+ Mesh *me = obedit->data;
+ if (me->edit_btmesh == NULL) {
+ /* Should never fail, may not crash but can give odd behavior. */
+ CLOG_ERROR(&LOG, "name='%s', failed to enter edit-mode for object '%s', undo state invalid",
+ us_p->name, obedit->id.name);
+ continue;
+ }
+ BMEditMesh *em = me->edit_btmesh;
+ undomesh_to_editmesh(&elem->data, em, obedit->data);
+ DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ }
+
+ /* The first element is always active */
+ ED_undo_object_set_active_or_warn(CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
}
static void mesh_undosys_step_free(UndoStep *us_p)
{
MeshUndoStep *us = (MeshUndoStep *)us_p;
- undomesh_free_data(&us->data);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ MeshUndoStep_Elem *elem = &us->elems[i];
+ undomesh_free_data(&elem->data);
+ }
+ MEM_freeN(us->elems);
if (us->id_map != NULL) {
BKE_undosys_ID_map_destroy(us->id_map);
@@ -724,7 +770,12 @@ static void mesh_undosys_foreach_ID_ref(
UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
{
MeshUndoStep *us = (MeshUndoStep *)us_p;
- foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->obedit_ref));
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ MeshUndoStep_Elem *elem = &us->elems[i];
+ foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));
+ }
+
if (us->id_map != NULL) {
BKE_undosys_ID_map_foreach_ID_ref(us->id_map, foreach_ID_ref_fn, user_data);
}
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 3382847c8a4..af4ef00bc25 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -1481,7 +1481,7 @@ static void scale_point(float c1[3], const float p[3], const float s)
}
bool BMBVH_EdgeVisible(struct BMBVHTree *tree, BMEdge *e,
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
ARegion *ar, View3D *v3d, Object *obedit)
{
BMFace *f;
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 69e265f7315..676af4fea5b 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -538,7 +538,6 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot)
static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
Base *base;
@@ -578,8 +577,6 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e
if (me->edit_btmesh == NULL)
return OPERATOR_CANCELLED;
- ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL);
-
if (exitmode) {
EDBM_mesh_load(obedit);
EDBM_mesh_free(me->edit_btmesh);
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index 99342222d52..87a17eb8fd4 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -210,7 +210,6 @@ void MESH_OT_hide(struct wmOperatorType *ot);
void MESH_OT_reveal(struct wmOperatorType *ot);
void MESH_OT_mark_seam(struct wmOperatorType *ot);
void MESH_OT_mark_sharp(struct wmOperatorType *ot);
-void MESH_OT_noise(struct wmOperatorType *ot);
void MESH_OT_flip_normals(struct wmOperatorType *ot);
void MESH_OT_solidify(struct wmOperatorType *ot);
void MESH_OT_knife_cut(struct wmOperatorType *ot);
@@ -254,12 +253,4 @@ void MESH_OT_customdata_custom_splitnormals_clear(struct wmOperatorType *ot);
void MESH_OT_drop_named_image(struct wmOperatorType *ot);
-/* *** mesh_navmesh.c *** */
-void MESH_OT_navmesh_make(struct wmOperatorType *ot);
-void MESH_OT_navmesh_face_copy(struct wmOperatorType *ot);
-void MESH_OT_navmesh_face_add(struct wmOperatorType *ot);
-void MESH_OT_navmesh_reset(struct wmOperatorType *ot);
-void MESH_OT_navmesh_clear(struct wmOperatorType *ot);
-
-
#endif /* __MESH_INTERN_H__ */
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
deleted file mode 100644
index bd2ad21d51c..00000000000
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ /dev/null
@@ -1,738 +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) 2011 by Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Benoit Bolsee,
- * Nick Samarin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/mesh/mesh_navmesh.c
- * \ingroup edmesh
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
-
-#include "BLI_listbase.h"
-#include "BLI_math_vector.h"
-#include "BLI_linklist.h"
-
-#include "BKE_layer.h"
-#include "BKE_library.h"
-#include "BKE_context.h"
-#include "BKE_mesh.h"
-#include "BKE_scene.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_report.h"
-#include "BKE_editmesh.h"
-
-#include "ED_object.h"
-#include "ED_mesh.h"
-#include "ED_screen.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "recast-capi.h"
-
-#include "DEG_depsgraph.h"
-
-#include "mesh_intern.h" /* own include */
-
-
-static void createVertsTrisData(bContext *C, LinkNode *obs,
- int *nverts_r, float **verts_r, int *ntris_r, int **tris_r, unsigned int *r_lay)
-{
- MVert *mvert;
- int nfaces = 0, *tri, i, curnverts, basenverts, curnfaces;
- MFace *mface;
- float co[3], wco[3];
- Object *ob;
- LinkNode *oblink, *dmlink;
- DerivedMesh *dm;
- Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
- LinkNodePair dms_pair = {NULL, NULL};
-
- int nverts, ntris, *tris;
- float *verts;
-
- CTX_data_eval_ctx(C, &eval_ctx);
-
- nverts = 0;
- ntris = 0;
-
- /* calculate number of verts and tris */
- for (oblink = obs; oblink; oblink = oblink->next) {
- ob = (Object *) oblink->link;
- dm = mesh_create_derived_no_virtual(&eval_ctx, scene, ob, NULL, CD_MASK_MESH);
- DM_ensure_tessface(dm);
- BLI_linklist_append(&dms_pair, dm);
-
- nverts += dm->getNumVerts(dm);
- nfaces = dm->getNumTessFaces(dm);
- ntris += nfaces;
-
- /* resolve quad faces */
- mface = dm->getTessFaceArray(dm);
- for (i = 0; i < nfaces; i++) {
- MFace *mf = &mface[i];
- if (mf->v4)
- ntris += 1;
- }
-
- *r_lay |= ob->lay;
- }
- LinkNode *dms = dms_pair.list;
-
- /* create data */
- verts = MEM_mallocN(sizeof(float) * 3 * nverts, "createVertsTrisData verts");
- tris = MEM_mallocN(sizeof(int) * 3 * ntris, "createVertsTrisData faces");
-
- basenverts = 0;
- tri = tris;
- for (oblink = obs, dmlink = dms; oblink && dmlink;
- oblink = oblink->next, dmlink = dmlink->next)
- {
- ob = (Object *) oblink->link;
- dm = (DerivedMesh *) dmlink->link;
-
- curnverts = dm->getNumVerts(dm);
- mvert = dm->getVertArray(dm);
-
- /* copy verts */
- for (i = 0; i < curnverts; i++) {
- MVert *v = &mvert[i];
-
- copy_v3_v3(co, v->co);
- mul_v3_m4v3(wco, ob->obmat, co);
-
- verts[3 * (basenverts + i) + 0] = wco[0];
- verts[3 * (basenverts + i) + 1] = wco[2];
- verts[3 * (basenverts + i) + 2] = wco[1];
- }
-
- /* create tris */
- curnfaces = dm->getNumTessFaces(dm);
- mface = dm->getTessFaceArray(dm);
-
- for (i = 0; i < curnfaces; i++) {
- MFace *mf = &mface[i];
-
- tri[0] = basenverts + mf->v1;
- tri[1] = basenverts + mf->v3;
- tri[2] = basenverts + mf->v2;
- tri += 3;
-
- if (mf->v4) {
- tri[0] = basenverts + mf->v1;
- tri[1] = basenverts + mf->v4;
- tri[2] = basenverts + mf->v3;
- tri += 3;
- }
- }
-
- basenverts += curnverts;
- }
-
- /* release derived mesh */
- for (dmlink = dms; dmlink; dmlink = dmlink->next) {
- dm = (DerivedMesh *) dmlink->link;
- dm->release(dm);
- }
-
- BLI_linklist_free(dms, NULL);
-
- *nverts_r = nverts;
- *verts_r = verts;
- *ntris_r = ntris;
- *tris_r = tris;
-}
-
-static bool buildNavMesh(const RecastData *recastParams, int nverts, float *verts, int ntris, int *tris,
- struct recast_polyMesh **pmesh, struct recast_polyMeshDetail **dmesh,
- ReportList *reports)
-{
- float bmin[3], bmax[3];
- struct recast_heightfield *solid;
- unsigned char *triflags;
- struct recast_compactHeightfield *chf;
- struct recast_contourSet *cset;
- int width, height, walkableHeight, walkableClimb, walkableRadius;
- int minRegionArea, mergeRegionArea, maxEdgeLen;
- float detailSampleDist, detailSampleMaxError;
-
- recast_calcBounds(verts, nverts, bmin, bmax);
-
- /* ** Step 1. Initialize build config ** */
- walkableHeight = (int)ceilf(recastParams->agentheight / recastParams->cellheight);
- walkableClimb = (int)floorf(recastParams->agentmaxclimb / recastParams->cellheight);
- walkableRadius = (int)ceilf(recastParams->agentradius / recastParams->cellsize);
- minRegionArea = (int)(recastParams->regionminsize * recastParams->regionminsize);
- mergeRegionArea = (int)(recastParams->regionmergesize * recastParams->regionmergesize);
- maxEdgeLen = (int)(recastParams->edgemaxlen / recastParams->cellsize);
- detailSampleDist = recastParams->detailsampledist < 0.9f ? 0 :
- recastParams->cellsize * recastParams->detailsampledist;
- detailSampleMaxError = recastParams->cellheight * recastParams->detailsamplemaxerror;
-
- /* Set the area where the navigation will be build. */
- recast_calcGridSize(bmin, bmax, recastParams->cellsize, &width, &height);
-
- /* zero dimensions cause zero alloc later on [#33758] */
- if (width <= 0 || height <= 0) {
- BKE_report(reports, RPT_ERROR, "Object has a width or height of zero");
- return false;
- }
-
- /* ** Step 2: Rasterize input polygon soup ** */
- /* Allocate voxel heightfield where we rasterize our input data to */
- solid = recast_newHeightfield();
-
- if (!recast_createHeightfield(solid, width, height, bmin, bmax, recastParams->cellsize, recastParams->cellheight)) {
- recast_destroyHeightfield(solid);
- BKE_report(reports, RPT_ERROR, "Failed to create height field");
- return false;
- }
-
- /* Allocate array that can hold triangle flags */
- triflags = MEM_callocN(sizeof(unsigned char) * ntris, "buildNavMesh triflags");
-
- /* Find triangles which are walkable based on their slope and rasterize them */
- recast_markWalkableTriangles(RAD2DEGF(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags);
- recast_rasterizeTriangles(verts, nverts, tris, triflags, ntris, solid, 1);
- MEM_freeN(triflags);
-
- /* ** Step 3: Filter walkables surfaces ** */
- recast_filterLowHangingWalkableObstacles(walkableClimb, solid);
- recast_filterLedgeSpans(walkableHeight, walkableClimb, solid);
- recast_filterWalkableLowHeightSpans(walkableHeight, solid);
-
- /* ** Step 4: Partition walkable surface to simple regions ** */
-
- chf = recast_newCompactHeightfield();
- if (!recast_buildCompactHeightfield(walkableHeight, walkableClimb, solid, chf)) {
- recast_destroyHeightfield(solid);
- recast_destroyCompactHeightfield(chf);
-
- BKE_report(reports, RPT_ERROR, "Failed to create compact height field");
- return false;
- }
-
- recast_destroyHeightfield(solid);
- solid = NULL;
-
- if (!recast_erodeWalkableArea(walkableRadius, chf)) {
- recast_destroyCompactHeightfield(chf);
-
- BKE_report(reports, RPT_ERROR, "Failed to erode walkable area");
- return false;
- }
-
- if (recastParams->partitioning == RC_PARTITION_WATERSHED) {
- /* Prepare for region partitioning, by calculating distance field along the walkable surface */
- if (!recast_buildDistanceField(chf)) {
- recast_destroyCompactHeightfield(chf);
-
- BKE_report(reports, RPT_ERROR, "Failed to build distance field");
- return false;
- }
-
- /* Partition the walkable surface into simple regions without holes */
- if (!recast_buildRegions(chf, 0, minRegionArea, mergeRegionArea)) {
- recast_destroyCompactHeightfield(chf);
-
- BKE_report(reports, RPT_ERROR, "Failed to build watershed regions");
- return false;
- }
- }
- else if (recastParams->partitioning == RC_PARTITION_MONOTONE) {
- /* Partition the walkable surface into simple regions without holes */
- /* Monotone partitioning does not need distancefield. */
- if (!recast_buildRegionsMonotone(chf, 0, minRegionArea, mergeRegionArea)) {
- recast_destroyCompactHeightfield(chf);
-
- BKE_report(reports, RPT_ERROR, "Failed to build monotone regions");
- return false;
- }
- }
- else { /* RC_PARTITION_LAYERS */
- /* Partition the walkable surface into simple regions without holes */
- if (!recast_buildLayerRegions(chf, 0, minRegionArea)) {
- recast_destroyCompactHeightfield(chf);
-
- BKE_report(reports, RPT_ERROR, "Failed to build layer regions");
- return false;
- }
- }
-
- /* ** Step 5: Trace and simplify region contours ** */
- /* Create contours */
- cset = recast_newContourSet();
-
- if (!recast_buildContours(chf, recastParams->edgemaxerror, maxEdgeLen, cset, RECAST_CONTOUR_TESS_WALL_EDGES)) {
- recast_destroyCompactHeightfield(chf);
- recast_destroyContourSet(cset);
-
- BKE_report(reports, RPT_ERROR, "Failed to build contours");
- return false;
- }
-
- /* ** Step 6: Build polygons mesh from contours ** */
- *pmesh = recast_newPolyMesh();
- if (!recast_buildPolyMesh(cset, recastParams->vertsperpoly, *pmesh)) {
- recast_destroyCompactHeightfield(chf);
- recast_destroyContourSet(cset);
- recast_destroyPolyMesh(*pmesh);
-
- BKE_report(reports, RPT_ERROR, "Failed to build poly mesh");
- return false;
- }
-
-
- /* ** Step 7: Create detail mesh which allows to access approximate height on each polygon ** */
-
- *dmesh = recast_newPolyMeshDetail();
- if (!recast_buildPolyMeshDetail(*pmesh, chf, detailSampleDist, detailSampleMaxError, *dmesh)) {
- recast_destroyCompactHeightfield(chf);
- recast_destroyContourSet(cset);
- recast_destroyPolyMesh(*pmesh);
- recast_destroyPolyMeshDetail(*dmesh);
-
- BKE_report(reports, RPT_ERROR, "Failed to build poly mesh detail");
- return false;
- }
-
- recast_destroyCompactHeightfield(chf);
- recast_destroyContourSet(cset);
-
- return true;
-}
-
-static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, struct recast_polyMeshDetail *dmesh,
- Base *base, unsigned int lay)
-{
- float co[3], rot[3];
- BMEditMesh *em;
- int i, j, k;
- unsigned short *v;
- int face[3];
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *obedit;
- int createob = base == NULL;
- int nverts, nmeshes, nvp;
- unsigned short *verts, *polys;
- unsigned int *meshes;
- float bmin[3], cs, ch, *dverts;
- unsigned char *tris;
-
- zero_v3(co);
- zero_v3(rot);
-
- if (createob) {
- /* create new object */
- obedit = ED_object_add_type(C, OB_MESH, "Navmesh", co, rot, false, lay);
- }
- else {
- obedit = base->object;
- BKE_view_layer_base_deselect_all(view_layer);
- BKE_view_layer_base_select(view_layer, base);
- copy_v3_v3(obedit->loc, co);
- copy_v3_v3(obedit->rot, rot);
- }
-
- ED_object_editmode_enter(C, EM_DO_UNDO | EM_IGNORE_LAYER);
- em = BKE_editmesh_from_object(obedit);
-
- if (!createob) {
- /* clear */
- EDBM_mesh_clear(em);
- }
-
- /* create verts for polygon mesh */
- verts = recast_polyMeshGetVerts(pmesh, &nverts);
- recast_polyMeshGetBoundbox(pmesh, bmin, NULL);
- recast_polyMeshGetCell(pmesh, &cs, &ch);
-
- for (i = 0; i < nverts; i++) {
- v = &verts[3 * i];
- co[0] = bmin[0] + v[0] * cs;
- co[1] = bmin[1] + v[1] * ch;
- co[2] = bmin[2] + v[2] * cs;
- SWAP(float, co[1], co[2]);
- BM_vert_create(em->bm, co, NULL, BM_CREATE_NOP);
- }
-
- /* create custom data layer to save polygon idx */
- CustomData_add_layer_named(&em->bm->pdata, CD_RECAST, CD_CALLOC, NULL, 0, "createRepresentation recastData");
- CustomData_bmesh_init_pool(&em->bm->pdata, 0, BM_FACE);
-
- /* create verts and faces for detailed mesh */
- meshes = recast_polyMeshDetailGetMeshes(dmesh, &nmeshes);
- polys = recast_polyMeshGetPolys(pmesh, NULL, &nvp);
- dverts = recast_polyMeshDetailGetVerts(dmesh, NULL);
- tris = recast_polyMeshDetailGetTris(dmesh, NULL);
-
- for (i = 0; i < nmeshes; i++) {
- int uniquevbase = em->bm->totvert;
- unsigned int vbase = meshes[4 * i + 0];
- unsigned short ndv = meshes[4 * i + 1];
- unsigned short tribase = meshes[4 * i + 2];
- unsigned short trinum = meshes[4 * i + 3];
- const unsigned short *p = &polys[i * nvp * 2];
- int nv = 0;
-
- for (j = 0; j < nvp; ++j) {
- if (p[j] == 0xffff) break;
- nv++;
- }
-
- /* create unique verts */
- for (j = nv; j < ndv; j++) {
- copy_v3_v3(co, &dverts[3 * (vbase + j)]);
- SWAP(float, co[1], co[2]);
- BM_vert_create(em->bm, co, NULL, BM_CREATE_NOP);
- }
-
- /* need to rebuild entirely because array size changes */
- BM_mesh_elem_table_init(em->bm, BM_VERT);
-
- /* create faces */
- for (j = 0; j < trinum; j++) {
- unsigned char *tri = &tris[4 * (tribase + j)];
- BMFace *newFace;
- int *polygonIdx;
-
- for (k = 0; k < 3; k++) {
- if (tri[k] < nv)
- face[k] = p[tri[k]]; /* shared vertex */
- else
- face[k] = uniquevbase + tri[k] - nv; /* unique vertex */
- }
- newFace = BM_face_create_quad_tri(em->bm,
- 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, BM_CREATE_NOP);
-
- /* set navigation polygon idx to the custom layer */
- polygonIdx = (int *)CustomData_bmesh_get(&em->bm->pdata, newFace->head.data, CD_RECAST);
- *polygonIdx = i + 1; /* add 1 to avoid zero idx */
- }
- }
-
- recast_destroyPolyMesh(pmesh);
- recast_destroyPolyMeshDetail(dmesh);
-
- DEG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-
-
- ED_object_editmode_exit(C, EM_FREEDATA);
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
-
- if (createob) {
- obedit->gameflag &= ~OB_COLLISION;
- obedit->gameflag |= OB_NAVMESH;
- obedit->body_type = OB_BODY_TYPE_NAVMESH;
- }
-
- BKE_mesh_ensure_navmesh(obedit->data);
-
- return obedit;
-}
-
-static int navmesh_create_exec(bContext *C, wmOperator *op)
-{
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- LinkNode *obs = NULL;
- Base *navmeshBase = NULL;
-
- CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
- {
- if (base->object->type == OB_MESH) {
- if (base->object->body_type == OB_BODY_TYPE_NAVMESH) {
- if (!navmeshBase || base == view_layer->basact) {
- navmeshBase = base;
- }
- }
- else {
- BLI_linklist_prepend(&obs, base->object);
- }
- }
- }
- CTX_DATA_END;
-
- if (obs) {
- struct recast_polyMesh *pmesh = NULL;
- struct recast_polyMeshDetail *dmesh = NULL;
- bool ok;
- unsigned int lay = 0;
-
- int nverts = 0, ntris = 0;
- int *tris = NULL;
- float *verts = NULL;
-
- createVertsTrisData(C, obs, &nverts, &verts, &ntris, &tris, &lay);
- BLI_linklist_free(obs, NULL);
- if ((ok = buildNavMesh(&scene->gm.recastData, nverts, verts, ntris, tris, &pmesh, &dmesh, op->reports))) {
- createRepresentation(C, pmesh, dmesh, navmeshBase, lay);
- }
-
- MEM_freeN(verts);
- MEM_freeN(tris);
-
- return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
- }
- else {
- BKE_report(op->reports, RPT_ERROR, "No mesh objects found");
-
- return OPERATOR_CANCELLED;
- }
-}
-
-void MESH_OT_navmesh_make(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Create Navigation Mesh";
- ot->description = "Create navigation mesh for selected objects";
- ot->idname = "MESH_OT_navmesh_make";
-
- /* api callbacks */
- ot->exec = navmesh_create_exec;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int navmesh_face_copy_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
-
- /* do work here */
- BMFace *efa_act = BM_mesh_active_face_get(em->bm, false, false);
-
- if (efa_act) {
- if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) {
- BMFace *efa;
- BMIter iter;
- int targetPolyIdx = *(int *)CustomData_bmesh_get(&em->bm->pdata, efa_act->head.data, CD_RECAST);
- targetPolyIdx = targetPolyIdx >= 0 ? targetPolyIdx : -targetPolyIdx;
-
- if (targetPolyIdx > 0) {
- /* set target poly idx to other selected faces */
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && efa != efa_act) {
- int *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_RECAST);
- *recastDataBlock = targetPolyIdx;
- }
- }
- }
- else {
- BKE_report(op->reports, RPT_ERROR, "Active face has no index set");
- }
- }
- }
-
- DEG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_navmesh_face_copy(struct wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "NavMesh Copy Face Index";
- ot->description = "Copy the index from the active face";
- ot->idname = "MESH_OT_navmesh_face_copy";
-
- /* api callbacks */
- ot->poll = ED_operator_editmesh;
- ot->exec = navmesh_face_copy_exec;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int compare(const void *a, const void *b)
-{
- return (*(int *)a - *(int *)b);
-}
-
-static int findFreeNavPolyIndex(BMEditMesh *em)
-{
- /* construct vector of indices */
- int numfaces = em->bm->totface;
- int *indices = MEM_callocN(sizeof(int) * numfaces, "findFreeNavPolyIndex(indices)");
- BMFace *ef;
- BMIter iter;
- int i, idx = em->bm->totface - 1, freeIdx = 1;
-
- /*XXX this originally went last to first, but that isn't possible anymore*/
- BM_ITER_MESH (ef, &iter, em->bm, BM_FACES_OF_MESH) {
- int polyIdx = *(int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST);
- indices[idx] = polyIdx;
- idx--;
- }
-
- qsort(indices, numfaces, sizeof(int), compare);
-
- /* search first free index */
- freeIdx = 1;
- for (i = 0; i < numfaces; i++) {
- if (indices[i] == freeIdx)
- freeIdx++;
- else if (indices[i] > freeIdx)
- break;
- }
-
- MEM_freeN(indices);
-
- return freeIdx;
-}
-
-static int navmesh_face_add_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMFace *ef;
- BMIter iter;
-
- if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) {
- int targetPolyIdx = findFreeNavPolyIndex(em);
-
- if (targetPolyIdx > 0) {
- /* set target poly idx to selected faces */
- /*XXX this originally went last to first, but that isn't possible anymore*/
-
- BM_ITER_MESH (ef, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(ef, BM_ELEM_SELECT)) {
- int *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST);
- *recastDataBlock = targetPolyIdx;
- }
- }
- }
- }
-
- DEG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_navmesh_face_add(struct wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "NavMesh New Face Index";
- ot->description = "Add a new index and assign it to selected faces";
- ot->idname = "MESH_OT_navmesh_face_add";
-
- /* api callbacks */
- ot->poll = ED_operator_editmesh;
- ot->exec = navmesh_face_add_exec;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int navmesh_obmode_data_poll(bContext *C)
-{
- Object *ob = ED_object_active_context(C);
- if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
- Mesh *me = ob->data;
- return CustomData_has_layer(&me->pdata, CD_RECAST);
- }
- return false;
-}
-
-static int navmesh_obmode_poll(bContext *C)
-{
- Object *ob = ED_object_active_context(C);
- if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
- return true;
- }
- return false;
-}
-
-static int navmesh_reset_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = ED_object_active_context(C);
- Mesh *me = ob->data;
-
- CustomData_free_layers(&me->pdata, CD_RECAST, me->totpoly);
-
- BKE_mesh_ensure_navmesh(me);
-
- DEG_id_tag_update(&me->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, &me->id);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_navmesh_reset(struct wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "NavMesh Reset Index Values";
- ot->description = "Assign a new index to every face";
- ot->idname = "MESH_OT_navmesh_reset";
-
- /* api callbacks */
- ot->poll = navmesh_obmode_poll;
- ot->exec = navmesh_reset_exec;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int navmesh_clear_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = ED_object_active_context(C);
- Mesh *me = ob->data;
-
- CustomData_free_layers(&me->pdata, CD_RECAST, me->totpoly);
-
- DEG_id_tag_update(&me->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, &me->id);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_navmesh_clear(struct wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "NavMesh Clear Data";
- ot->description = "Remove navmesh data from this mesh";
- ot->idname = "MESH_OT_navmesh_clear";
-
- /* api callbacks */
- ot->poll = navmesh_obmode_data_poll;
- ot->exec = navmesh_clear_exec;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index b9920f9deca..6f663ddbf14 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -141,7 +141,6 @@ void ED_operatortypes_mesh(void)
#endif
WM_operatortype_append(MESH_OT_vertices_smooth);
WM_operatortype_append(MESH_OT_vertices_smooth_laplacian);
- WM_operatortype_append(MESH_OT_noise);
WM_operatortype_append(MESH_OT_flip_normals);
WM_operatortype_append(MESH_OT_rip);
WM_operatortype_append(MESH_OT_rip_edge);
@@ -197,14 +196,6 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_bisect);
WM_operatortype_append(MESH_OT_symmetrize);
WM_operatortype_append(MESH_OT_symmetry_snap);
-
-#ifdef WITH_GAMEENGINE
- WM_operatortype_append(MESH_OT_navmesh_make);
- WM_operatortype_append(MESH_OT_navmesh_face_copy);
- WM_operatortype_append(MESH_OT_navmesh_face_add);
- WM_operatortype_append(MESH_OT_navmesh_reset);
- WM_operatortype_append(MESH_OT_navmesh_clear);
-#endif
}
#if 0 /* UNUSED, remove? */
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 531a26a66a8..83458127820 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -60,6 +60,7 @@
#include "BKE_report.h"
#include "BKE_editmesh.h"
#include "BKE_multires.h"
+#include "BKE_layer.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -79,7 +80,7 @@
* return 0 if no join is made (error) and 1 if the join is done */
static void join_mesh_single(
- const EvaluationContext *eval_ctx, Main *bmain, Scene *scene,
+ Depsgraph *depsgraph, Main *bmain, Scene *scene,
Object *ob_dst, Object *ob_src, float imat[4][4],
MVert **mvert_pp, MEdge **medge_pp, MLoop **mloop_pp, MPoly **mpoly_pp,
CustomData *vdata, CustomData *edata, CustomData *ldata, CustomData *pdata,
@@ -207,7 +208,7 @@ static void join_mesh_single(
if (ob_src != ob_dst) {
MultiresModifierData *mmd;
- multiresModifier_prepare_join(eval_ctx, scene, ob_src, ob_dst);
+ multiresModifier_prepare_join(depsgraph, scene, ob_src, ob_dst);
if ((mmd = get_multires_modifier(scene, ob_src, true))) {
ED_object_iter_other(bmain, ob_src, true,
@@ -292,8 +293,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
/* count & check */
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
@@ -489,7 +489,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
* active mesh will remain first ones in new result of the merge, in same order for CD layers, etc. See also T50084.
*/
join_mesh_single(
- &eval_ctx, bmain, scene,
+ depsgraph, bmain, scene,
ob, ob, imat,
&mvert, &medge, &mloop, &mpoly,
&vdata, &edata, &ldata, &pdata,
@@ -506,7 +506,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* only join if this is a mesh */
if (base->object->type == OB_MESH) {
join_mesh_single(
- &eval_ctx, bmain, scene,
+ depsgraph, bmain, scene,
ob, base->object, imat,
&mvert, &medge, &mloop, &mpoly,
&vdata, &edata, &ldata, &pdata,
@@ -606,7 +606,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Mesh *me = (Mesh *)ob->data;
Mesh *selme = NULL;
DerivedMesh *dm = NULL;
@@ -614,8 +614,6 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
KeyBlock *kb;
bool ok = false, nonequal_verts = false;
- CTX_data_eval_ctx(C, &eval_ctx);
-
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
if (base->object == ob) continue;
@@ -657,7 +655,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
selme = (Mesh *)base->object->data;
if (selme->totvert == me->totvert) {
- dm = mesh_get_derived_deform(&eval_ctx, scene, base->object, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_deform(depsgraph, scene, base->object, CD_MASK_BAREMESH);
if (!dm) continue;
@@ -1008,7 +1006,6 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, DerivedMesh *dm)
*/
bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size)
{
- EvaluationContext eval_ctx;
ViewContext vc;
Mesh *me = ob->data;
@@ -1017,7 +1014,6 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int
if (!me || me->totpoly == 0)
return false;
- CTX_data_eval_ctx(C, &eval_ctx);
ED_view3d_viewcontext_init(C, &vc);
if (size) {
@@ -1025,11 +1021,11 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int
* on an edge in the backbuf, we can still select a face */
float dummy_dist;
- *index = ED_view3d_backbuf_sample_rect(&eval_ctx, &vc, mval, size, 1, me->totpoly + 1, &dummy_dist);
+ *index = ED_view3d_backbuf_sample_rect(&vc, mval, size, 1, me->totpoly + 1, &dummy_dist);
}
else {
/* sample only on the exact position */
- *index = ED_view3d_backbuf_sample(&eval_ctx, &vc, mval[0], mval[1]);
+ *index = ED_view3d_backbuf_sample(&vc, mval[0], mval[1]);
}
if ((*index) == 0 || (*index) > (unsigned int)me->totpoly)
@@ -1068,12 +1064,10 @@ static void ed_mesh_pick_face_vert__mpoly_find(
*/
bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size)
{
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
unsigned int poly_index;
Mesh *me = ob->data;
- CTX_data_eval_ctx(C, &eval_ctx);
-
BLI_assert(me && GS(me->id.name) == ID_ME);
if (ED_mesh_pick_face(C, ob, mval, &poly_index, size)) {
@@ -1081,7 +1075,7 @@ 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(&eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
int v_idx_best = ORIGINDEX_NONE;
@@ -1178,12 +1172,9 @@ static void ed_mesh_pick_vert__mapFunc(void *userData, int index, const float co
}
bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size, bool use_zbuf)
{
- EvaluationContext eval_ctx;
ViewContext vc;
Mesh *me = ob->data;
- CTX_data_eval_ctx(C, &eval_ctx);
-
BLI_assert(me && GS(me->id.name) == ID_ME);
if (!me || me->totvert == 0)
@@ -1197,11 +1188,11 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
* on an face in the backbuf, we can still select a vert */
float dummy_dist;
- *index = ED_view3d_backbuf_sample_rect(&eval_ctx, &vc, mval, size, 1, me->totvert + 1, &dummy_dist);
+ *index = ED_view3d_backbuf_sample_rect(&vc, mval, size, 1, me->totvert + 1, &dummy_dist);
}
else {
/* sample only on the exact position */
- *index = ED_view3d_backbuf_sample(&eval_ctx, &vc, mval[0], mval[1]);
+ *index = ED_view3d_backbuf_sample(&vc, mval[0], mval[1]);
}
if ((*index) == 0 || (*index) > (unsigned int)me->totvert)
@@ -1211,7 +1202,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
}
else {
/* derived mesh to find deformed locations */
- DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, vc.scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_final(vc.depsgraph, vc.scene, ob, CD_MASK_BAREMESH);
ARegion *ar = vc.ar;
RegionView3D *rv3d = ar->regiondata;
@@ -1297,3 +1288,47 @@ MDeformVert *ED_mesh_active_dvert_get_only(Object *ob)
return NULL;
}
}
+
+void EDBM_mesh_stats_multi(
+ struct Object **objects, const uint objects_len,
+ int totelem[3], int totelem_sel[3])
+{
+ if (totelem) {
+ totelem[0] = 0;
+ totelem[1] = 0;
+ totelem[2] = 0;
+ }
+ if (totelem_sel) {
+ totelem_sel[0] = 0;
+ totelem_sel[1] = 0;
+ totelem_sel[2] = 0;
+ }
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+ if (totelem) {
+ totelem[0] += bm->totvert;
+ totelem[1] += bm->totedge;
+ totelem[2] += bm->totface;
+ }
+ if (totelem_sel) {
+ totelem_sel[0] += bm->totvertsel;
+ totelem_sel[1] += bm->totedgesel;
+ totelem_sel[2] += bm->totfacesel;
+ }
+ }
+}
+
+
+void EDBM_mesh_elem_index_ensure_multi(Object **objects, const uint objects_len, const char htype)
+{
+ int elem_offset[4] = {0, 0, 0, 0};
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+ BM_mesh_elem_index_ensure_ex(bm, htype, elem_offset);
+ }
+}
diff --git a/source/blender/editors/metaball/CMakeLists.txt b/source/blender/editors/metaball/CMakeLists.txt
index 73f80774716..b0ae3122727 100644
--- a/source/blender/editors/metaball/CMakeLists.txt
+++ b/source/blender/editors/metaball/CMakeLists.txt
@@ -27,6 +27,7 @@ set(INC
../../makesrna
../../render/extern/include
../../windowmanager
+ ../../../../intern/clog
../../../../intern/guardedalloc
)
diff --git a/source/blender/editors/metaball/editmball_undo.c b/source/blender/editors/metaball/editmball_undo.c
index cc461c0c365..7045025e227 100644
--- a/source/blender/editors/metaball/editmball_undo.c
+++ b/source/blender/editors/metaball/editmball_undo.c
@@ -27,6 +27,8 @@
#include "MEM_guardedalloc.h"
+#include "CLG_log.h"
+
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_array_utils.h"
@@ -36,17 +38,22 @@
#include "DNA_object_types.h"
#include "BKE_context.h"
+#include "BKE_layer.h"
#include "BKE_undo_system.h"
#include "DEG_depsgraph.h"
#include "ED_object.h"
#include "ED_mball.h"
+#include "ED_undo.h"
#include "ED_util.h"
#include "WM_types.h"
#include "WM_api.h"
+/** We only need this locally. */
+static CLG_LogRef LOG = {"ed.undo.mball"};
+
/* -------------------------------------------------------------------- */
/** \name Undo Conversion
* \{ */
@@ -130,13 +137,19 @@ static Object *editmball_object_from_context(bContext *C)
/* -------------------------------------------------------------------- */
/** \name Implements ED Undo System
+ *
+ * \note This is similar for all edit-mode types.
* \{ */
-typedef struct MBallUndoStep {
- UndoStep step;
- /* note: will split out into list for multi-object-editmode. */
+typedef struct MBallUndoStep_Elem {
UndoRefID_Object obedit_ref;
UndoMBall data;
+} MBallUndoStep_Elem;
+
+typedef struct MBallUndoStep {
+ UndoStep step;
+ MBallUndoStep_Elem *elems;
+ uint elems_len;
} MBallUndoStep;
static bool mball_undosys_poll(bContext *C)
@@ -147,36 +160,74 @@ static bool mball_undosys_poll(bContext *C)
static bool mball_undosys_step_encode(struct bContext *C, UndoStep *us_p)
{
MBallUndoStep *us = (MBallUndoStep *)us_p;
- us->obedit_ref.ptr = editmball_object_from_context(C);
- MetaBall *mb = us->obedit_ref.ptr->data;
- editmball_from_undomball(&us->data, mb);
- us->step.data_size = us->data.undo_size;
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
+ us->elems_len = objects_len;
+
+ for (uint i = 0; i < objects_len; i++) {
+ Object *ob = objects[i];
+ MBallUndoStep_Elem *elem = &us->elems[i];
+
+ elem->obedit_ref.ptr = ob;
+ MetaBall *mb = ob->data;
+ editmball_from_undomball(&elem->data, mb);
+ us->step.data_size += elem->data.undo_size;
+ }
+ MEM_freeN(objects);
return true;
}
static void mball_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNUSED(dir))
{
+ /* TODO(campbell): undo_system: use low-level API to set mode. */
ED_object_mode_set(C, OB_MODE_EDIT);
+ BLI_assert(mball_undosys_poll(C));
MBallUndoStep *us = (MBallUndoStep *)us_p;
- Object *obedit = us->obedit_ref.ptr;
- MetaBall *mb = obedit->data;
- undomball_to_editmball(&us->data, mb);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ MBallUndoStep_Elem *elem = &us->elems[i];
+ Object *obedit = elem->obedit_ref.ptr;
+ MetaBall *mb = obedit->data;
+ if (mb->editelems == NULL) {
+ /* Should never fail, may not crash but can give odd behavior. */
+ CLOG_ERROR(&LOG, "name='%s', failed to enter edit-mode for object '%s', undo state invalid", us_p->name, obedit->id.name);
+ continue;
+ }
+ undomball_to_editmball(&elem->data, mb);
+ DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ }
+
+ /* The first element is always active */
+ ED_undo_object_set_active_or_warn(CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
}
static void mball_undosys_step_free(UndoStep *us_p)
{
MBallUndoStep *us = (MBallUndoStep *)us_p;
- undomball_free_data(&us->data);
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ MBallUndoStep_Elem *elem = &us->elems[i];
+ undomball_free_data(&elem->data);
+ }
+ MEM_freeN(us->elems);
}
static void mball_undosys_foreach_ID_ref(
UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
{
MBallUndoStep *us = (MBallUndoStep *)us_p;
- foreach_ID_ref_fn(user_data, ((UndoRefID *)&us->obedit_ref));
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ MBallUndoStep_Elem *elem = &us->elems[i];
+ foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));
+ }
}
/* Export for ED_undo_sys. */
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 6dd16b52387..0aea5cb5480 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -587,7 +587,6 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
{
static MetaElem *startelem = NULL;
Object *obedit = CTX_data_edit_object(C);
- EvaluationContext eval_ctx;
ViewContext vc;
MetaBall *mb = (MetaBall *)obedit->data;
MetaElem *ml, *ml_act = NULL;
@@ -595,12 +594,11 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
unsigned int buffer[MAXPICKBUF];
rcti rect;
- CTX_data_eval_ctx(C, &eval_ctx);
ED_view3d_viewcontext_init(C, &vc);
BLI_rcti_init_pt_radius(&rect, mval, 12);
- hits = view3d_opengl_select(&eval_ctx, &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
+ hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
/* does startelem exist? */
ml = mb->editelems->first;
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 646b8137b2d..e25b04668bc 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -50,7 +50,6 @@ set(SRC
object_facemap_ops.c
object_group.c
object_hook.c
- object_lod.c
object_modes.c
object_modifier.c
object_ops.c
@@ -72,10 +71,6 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
-if(WITH_GAMEENGINE)
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 3a12d56d9c2..92a1b56e7e7 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -49,7 +49,6 @@
#include "DNA_lightprobe_types.h"
#include "DNA_scene_types.h"
#include "DNA_vfont_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_gpencil_types.h"
#include "BLI_utildefines.h"
@@ -90,7 +89,6 @@
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_report.h"
-#include "BKE_sca.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_speaker.h"
@@ -119,8 +117,6 @@
#include "UI_resources.h"
-#include "GPU_lamp.h"
-
#include "object_intern.h"
/* this is an exact copy of the define in rna_lamp.c
@@ -225,19 +221,17 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3],
{
Object *ob = base->object;
Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
if (!scene) return;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (loc)
copy_v3_v3(ob->loc, loc);
if (rot)
copy_v3_v3(ob->rot, rot);
- BKE_object_where_is_calc(&eval_ctx, scene, ob);
+ BKE_object_where_is_calc(depsgraph, scene, ob);
}
/* Uses context to figure out transform for primitive.
@@ -444,12 +438,6 @@ Object *ED_object_add_type(
/* more editor stuff */
ED_object_base_init_transform(C, view_layer->basact, loc, rot);
- /* Ignore collisions by default for non-mesh objects */
- if (type != OB_MESH) {
- ob->body_type = OB_BODY_TYPE_NO_COLLISION;
- ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH); /* copied from rna_object.c */
- }
-
/* TODO(sergey): This is weird to manually tag objects for update, better to
* use DEG_id_tag_update here perhaps.
*/
@@ -887,7 +875,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
}
dia = RNA_float_get(op->ptr, "radius");
- ED_armature_edit_bone_add_primitive(obedit, dia, view_aligned);
+ ED_armature_ebone_add_primitive(obedit, dia, view_aligned);
/* userdef */
if (newob && !enter_editmode)
@@ -1066,7 +1054,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op)
la = (Lamp *)ob->data;
la->type = type;
- if (BKE_scene_use_new_shading_nodes(scene)) {
+ if (BKE_scene_uses_cycles(scene)) {
ED_node_shader_default(C, &la->id);
la->use_nodes = true;
}
@@ -1231,17 +1219,6 @@ void OBJECT_OT_speaker_add(wmOperatorType *ot)
/**************************** Delete Object *************************/
-static void object_delete_check_glsl_update(Object *ob)
-{
- /* some objects could affect on GLSL shading, make sure GLSL settings
- * are being tagged to be updated when object is removing from scene
- */
- if (ob->type == OB_LAMP) {
- if (ob->gpulamp.first)
- GPU_lamp_free(ob);
- }
-}
-
/* remove base from a specific scene */
/* note: now unlinks constraints as well */
void ED_object_base_free_and_unlink(Main *bmain, Scene *scene, Object *ob)
@@ -1257,7 +1234,6 @@ void ED_object_base_free_and_unlink(Main *bmain, Scene *scene, Object *ob)
DEG_id_tag_update_ex(bmain, &ob->id, DEG_TAG_BASE_FLAGS_UPDATE);
- object_delete_check_glsl_update(ob);
BKE_collections_object_remove(bmain, &scene->id, ob, true);
}
@@ -1386,8 +1362,6 @@ static void copy_object_set_idnew(bContext *C)
}
CTX_DATA_END;
- set_sca_new_poins();
-
BKE_main_id_clear_newpoins(bmain);
}
@@ -1468,6 +1442,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
{
Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ListBase *lb_duplis;
DupliObject *dob;
GHash *dupli_gh, *parent_gh = NULL;
@@ -1476,7 +1451,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
return;
}
- lb_duplis = object_duplilist(bmain->eval_ctx, scene, base->object);
+ lb_duplis = object_duplilist(depsgraph, scene, base->object);
dupli_gh = BLI_ghash_ptr_new(__func__);
if (use_hierarchy) {
@@ -1540,7 +1515,6 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
/* Remap new object to itself, and clear again newid pointer of orig object. */
BKE_libblock_relink_to_newid(&ob_dst->id);
- set_sca_new_poins_ob(ob_dst);
DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
@@ -1675,32 +1649,28 @@ static const EnumPropertyItem convert_target_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static void convert_ensure_curve_cache(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *ob)
+static void convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
if (ob->curve_cache == NULL) {
/* Force creation. This is normally not needed but on operator
* redo we might end up with an object which isn't evaluated yet.
*/
if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
- BKE_displist_make_curveTypes(eval_ctx, scene, ob, false);
+ BKE_displist_make_curveTypes(depsgraph, scene, ob, false);
}
else if (ob->type == OB_MBALL) {
- BKE_displist_make_mball(bmain->eval_ctx, scene, ob);
+ BKE_displist_make_mball(depsgraph, scene, ob);
}
}
}
-static void curvetomesh(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *ob)
+static void curvetomesh(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
- convert_ensure_curve_cache(eval_ctx, bmain, scene, ob);
+ convert_ensure_curve_cache(depsgraph, scene, ob);
BKE_mesh_from_nurbs(ob); /* also does users */
if (ob->type == OB_MESH) {
BKE_object_free_modifiers(ob, 0);
-
- /* Game engine defaults for mesh objects */
- ob->body_type = OB_BODY_TYPE_STATIC;
- ob->gameflag = OB_PROP | OB_COLLISION;
}
}
@@ -1737,9 +1707,9 @@ static Base *duplibase_for_convert(Main *bmain, Scene *scene, ViewLayer *view_la
static int convert_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- EvaluationContext eval_ctx;
Base *basen = NULL, *basact = NULL;
Object *ob1, *newob, *obact = CTX_data_active_object(C);
DerivedMesh *dm;
@@ -1751,8 +1721,6 @@ static int convert_exec(bContext *C, wmOperator *op)
bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
int a, mballConverted = 0;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* don't forget multiple users! */
{
@@ -1803,7 +1771,6 @@ static int convert_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
uint64_t customdata_mask_prev = scene->customdata_mask;
scene->customdata_mask |= CD_MASK_MESH;
BKE_scene_graph_update_tagged(depsgraph, bmain);
@@ -1847,7 +1814,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = ob;
}
- BKE_mesh_to_curve(&eval_ctx, scene, newob);
+ BKE_mesh_to_curve(depsgraph, scene, newob);
if (newob->type == OB_CURVE) {
BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
@@ -1877,7 +1844,7 @@ static int convert_exec(bContext *C, wmOperator *op)
/* note: get the mesh from the original, not from the copy in some
* cases this doesnt give correct results (when MDEF is used for eg)
*/
- dm = mesh_get_derived_final(&eval_ctx, scene, newob, CD_MASK_MESH);
+ dm = mesh_get_derived_final(depsgraph, scene, newob, CD_MASK_MESH);
DM_to_mesh(dm, newob->data, newob, CD_MASK_MESH, true);
@@ -1949,7 +1916,7 @@ static int convert_exec(bContext *C, wmOperator *op)
BKE_curve_curve_dimension_update(cu);
if (target == OB_MESH) {
- curvetomesh(&eval_ctx, bmain, scene, newob);
+ curvetomesh(depsgraph, scene, newob);
/* meshes doesn't use displist */
BKE_object_free_curve_cache(newob);
@@ -1973,7 +1940,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = ob;
}
- curvetomesh(&eval_ctx, bmain, scene, newob);
+ curvetomesh(depsgraph, scene, newob);
/* meshes doesn't use displist */
BKE_object_free_curve_cache(newob);
@@ -2011,7 +1978,7 @@ static int convert_exec(bContext *C, wmOperator *op)
for (a = 0; a < newob->totcol; a++) id_us_plus((ID *)me->mat[a]);
}
- convert_ensure_curve_cache(&eval_ctx, bmain, scene, baseob);
+ convert_ensure_curve_cache(depsgraph, scene, baseob);
BKE_mesh_from_metaball(&baseob->curve_cache->disp, newob->data);
if (obact->type == OB_MBALL) {
@@ -2318,25 +2285,10 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer
}
if (dupflag & USER_DUP_ACT) {
- bActuator *act;
-
BKE_animdata_copy_id_action((ID *)obn->data, true);
if (key) {
BKE_animdata_copy_id_action((ID *)key, true);
}
-
- /* Update the duplicated action in the action actuators */
- /* XXX TODO this code is all wrong! actact->act is user-refcounted (see readfile.c),
- * and what about other ID pointers of other BGE logic bricks,
- * and since this is object-level, why is it only ran if obdata was duplicated??? -mont29 */
- for (act = obn->actuators.first; act; act = act->next) {
- if (act->type == ACT_ACTION) {
- bActionActuator *actact = (bActionActuator *) act->data;
- if (ob->adt && actact->act == ob->adt->action) {
- actact->act = obn->adt->action;
- }
- }
- }
}
if (dupflag & USER_DUP_MAT) {
@@ -2372,8 +2324,6 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, ViewLayer *view_layer,
Base *basen;
Object *ob;
- clear_sca_new_poins(); /* BGE logic */
-
basen = object_add_duplicate_internal(bmain, scene, view_layer, base->object, dupflag);
if (basen == NULL) {
return NULL;
@@ -2383,7 +2333,6 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, ViewLayer *view_layer,
/* link own references to the newly duplicated data [#26816] */
BKE_libblock_relink_to_newid(&ob->id);
- set_sca_new_poins_ob(ob);
/* DAG_relations_tag_update(bmain); */ /* caller must do */
@@ -2405,8 +2354,6 @@ static int duplicate_exec(bContext *C, wmOperator *op)
const bool linked = RNA_boolean_get(op->ptr, "linked");
int dupflag = (linked) ? 0 : U.dupflag;
- clear_sca_new_poins(); /* BGE logic */
-
CTX_DATA_BEGIN (C, Base *, base, selected_bases)
{
Base *basen = object_add_duplicate_internal(bmain, scene, view_layer, base->object, dupflag);
@@ -2490,8 +2437,6 @@ static int add_named_exec(bContext *C, wmOperator *op)
}
/* prepare dupli */
- clear_sca_new_poins(); /* BGE logic */
-
basen = object_add_duplicate_internal(bmain, scene, view_layer, ob, dupflag);
if (basen == NULL) {
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index a38b9959dab..b10b35618fb 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -79,9 +79,26 @@
#include "ED_object.h"
#include "ED_screen.h"
+#include "ED_uvedit.h"
#include "object_intern.h"
+static Image *bake_object_image_get(Object *ob, int mat_nr)
+{
+ Image *image = NULL;
+ ED_object_get_active_image(ob, mat_nr + 1, &image, NULL, NULL, NULL);
+ return image;
+}
+
+static Image **bake_object_image_get_array(Object *ob)
+{
+ Image **image_array = MEM_mallocN(sizeof(Material *) * ob->totcol, __func__);
+ for (int i = 0; i < ob->totcol; i++) {
+ image_array[i] = bake_object_image_get(ob, i);
+ }
+ return image_array;
+}
+
/* ****************** multires BAKING ********************** */
/* holder of per-object data needed for bake job
@@ -108,8 +125,6 @@ typedef struct {
bool use_lores_mesh; /* Use low-resolution mesh when baking displacement maps */
int number_of_rays; /* Number of rays to be cast when doing AO baking */
float bias; /* Bias between object and start ray point when doing AO baking */
- int raytrace_structure; /* Optimization structure to be used for AO baking */
- int octree_resolution; /* Reslution of octotree when using octotree optimization structure */
int threads; /* Number of threads to be used for baking */
float user_scale; /* User scale used to scale displacement when baking derivative map. */
} MultiresBakeJob;
@@ -167,7 +182,7 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
else {
a = me->totpoly;
while (ok && a--) {
- Image *ima = BKE_object_material_edit_image_get(ob, me->mpoly[a].mat_nr);
+ Image *ima = bake_object_image_get(ob, me->mpoly[a].mat_nr);
if (!ima) {
BKE_report(op->reports, RPT_ERROR, "You should have active texture to use multires baker");
@@ -334,12 +349,12 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
if (scene->r.bake_mode == RE_BAKE_NORMALS) {
clear_flag = CLEAR_TANGENT_NORMAL;
}
- else if (ELEM(scene->r.bake_mode, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE)) {
+ else if (scene->r.bake_mode == RE_BAKE_DISPLACEMENT) {
clear_flag = CLEAR_DISPLACEMENT;
}
{
- Image **ob_image_array = BKE_object_material_edit_image_get_array(ob);
+ Image **ob_image_array = bake_object_image_get_array(ob);
clear_images_poly(ob_image_array, ob->totcol, clear_flag);
MEM_freeN(ob_image_array);
}
@@ -361,14 +376,12 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
bkr.use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH;
bkr.bias = scene->r.bake_biasdist;
bkr.number_of_rays = scene->r.bake_samples;
- bkr.raytrace_structure = scene->r.raytrace_structure;
- bkr.octree_resolution = scene->r.ocres;
bkr.threads = BKE_scene_num_threads(scene);
bkr.user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f;
//bkr.reports= op->reports;
/* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */
- bkr.ob_image.array = BKE_object_material_edit_image_get_array(ob);
+ bkr.ob_image.array = bake_object_image_get_array(ob);
bkr.ob_image.len = ob->totcol;
bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple);
@@ -406,8 +419,6 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
bkj->bake_clear = scene->r.bake_flag & R_BAKE_CLEAR;
bkj->bias = scene->r.bake_biasdist;
bkj->number_of_rays = scene->r.bake_samples;
- bkj->raytrace_structure = scene->r.raytrace_structure;
- bkj->octree_resolution = scene->r.ocres;
bkj->threads = BKE_scene_num_threads(scene);
bkj->user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f;
//bkj->reports = op->reports;
@@ -423,7 +434,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
data = MEM_callocN(sizeof(MultiresBakerJobData), "multiresBaker derivedMesh_data");
- data->ob_image.array = BKE_object_material_edit_image_get_array(ob);
+ data->ob_image.array = bake_object_image_get_array(ob);
data->ob_image.len = ob->totcol;
/* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */
@@ -451,7 +462,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa
if (bkj->mode == RE_BAKE_NORMALS) {
clear_flag = CLEAR_TANGENT_NORMAL;
}
- else if (ELEM(bkj->mode, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE)) {
+ else if (bkj->mode == RE_BAKE_DISPLACEMENT) {
clear_flag = CLEAR_DISPLACEMENT;
}
@@ -488,8 +499,6 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa
bkr.bias = bkj->bias;
bkr.number_of_rays = bkj->number_of_rays;
- bkr.raytrace_structure = bkj->raytrace_structure;
- bkr.octree_resolution = bkj->octree_resolution;
bkr.threads = bkj->threads;
RE_multires_bake_images(&bkr);
@@ -566,203 +575,6 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op)
/* ****************** render BAKING ********************** */
-/* threaded break test */
-static int thread_break(void *UNUSED(arg))
-{
- return G.is_break;
-}
-
-typedef struct BakeRender {
- Render *re;
- Main *main;
- Scene *scene;
- ViewLayer *view_layer;
- struct Object *actob;
- int result, ready;
-
- ReportList *reports;
-
- short *stop;
- short *do_update;
- float *progress;
-
- ListBase threads;
-
- /* backup */
- short prev_wo_amb_occ;
- short prev_r_raytrace;
-
- /* for redrawing */
- ScrArea *sa;
-} BakeRender;
-
-/* use by exec and invoke */
-static int test_bake_internal(bContext *C, ReportList *reports)
-{
- Scene *scene = CTX_data_scene(C);
-
- if ((scene->r.bake_flag & R_BAKE_TO_ACTIVE) && CTX_data_active_object(C) == NULL) {
- BKE_report(reports, RPT_ERROR, "No active object");
- }
- else if (scene->r.bake_mode == RE_BAKE_AO && scene->world == NULL) {
- BKE_report(reports, RPT_ERROR, "No world set up");
- }
- else {
- return 1;
- }
-
- return 0;
-}
-
-static void init_bake_internal(BakeRender *bkr, bContext *C)
-{
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- bScreen *sc = CTX_wm_screen(C);
-
- /* get editmode results */
- ED_object_editmode_load(CTX_data_edit_object(C));
-
- bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; /* can be NULL */
- bkr->main = CTX_data_main(C);
- bkr->scene = scene;
- bkr->view_layer = view_layer;
- bkr->actob = (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT(view_layer) : NULL;
- bkr->re = RE_NewRender("_Bake View_");
-
- if (scene->r.bake_mode == RE_BAKE_AO) {
- /* If raytracing or AO is disabled, switch it on temporarily for baking. */
- bkr->prev_wo_amb_occ = (scene->world->mode & WO_AMB_OCC) != 0;
- scene->world->mode |= WO_AMB_OCC;
- }
- if (scene->r.bake_mode == RE_BAKE_AO || bkr->actob) {
- bkr->prev_r_raytrace = (scene->r.mode & R_RAYTRACE) != 0;
- scene->r.mode |= R_RAYTRACE;
- }
-}
-
-static void finish_bake_internal(BakeRender *bkr)
-{
- Image *ima;
-
- RE_Database_Free(bkr->re);
-
- /* restore raytrace and AO */
- if (bkr->scene->r.bake_mode == RE_BAKE_AO)
- if (bkr->prev_wo_amb_occ == 0)
- bkr->scene->world->mode &= ~WO_AMB_OCC;
-
- if (bkr->scene->r.bake_mode == RE_BAKE_AO || bkr->actob)
- if (bkr->prev_r_raytrace == 0)
- bkr->scene->r.mode &= ~R_RAYTRACE;
-
- /* force OpenGL reload and mipmap recalc */
- if ((bkr->scene->r.bake_flag & R_BAKE_VCOL) == 0) {
- for (ima = G.main->image.first; ima; ima = ima->id.next) {
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
-
- /* some of the images could have been changed during bake,
- * so recreate mipmaps regardless bake result status
- */
- if (ima->ok == IMA_OK_LOADED) {
- if (ibuf) {
- if (ibuf->userflags & IB_BITMAPDIRTY) {
- GPU_free_image(ima);
- imb_freemipmapImBuf(ibuf);
- }
-
- /* invalidate display buffers for changed images */
- if (ibuf->userflags & IB_BITMAPDIRTY)
- ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
- }
- }
-
- /* freed when baking is done, but if its canceled we need to free here */
- if (ibuf) {
- if (ibuf->userdata) {
- BakeImBufuserData *userdata = (BakeImBufuserData *) ibuf->userdata;
- if (userdata->mask_buffer)
- MEM_freeN(userdata->mask_buffer);
- if (userdata->displacement_buffer)
- MEM_freeN(userdata->displacement_buffer);
- MEM_freeN(userdata);
- ibuf->userdata = NULL;
- }
- }
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
- DEG_id_tag_update(&ima->id, 0);
- }
- }
-
- if (bkr->scene->r.bake_flag & R_BAKE_VCOL) {
- /* update all tagged meshes */
- Mesh *me;
- BLI_assert(BLI_thread_is_main());
- for (me = G.main->mesh.first; me; me = me->id.next) {
- if (me->id.tag & LIB_TAG_DOIT) {
- DEG_id_tag_update(&me->id, OB_RECALC_DATA);
- BKE_mesh_tessface_clear(me);
- }
- }
- }
-
-}
-
-static void *do_bake_render(void *bake_v)
-{
- BakeRender *bkr = bake_v;
-
- bkr->result = RE_bake_shade_all_selected(bkr->re, bkr->scene->r.bake_mode, bkr->actob, NULL, bkr->progress);
- bkr->ready = 1;
-
- return NULL;
-}
-
-static void bake_startjob(void *bkv, short *stop, short *do_update, float *progress)
-{
- BakeRender *bkr = bkv;
- Scene *scene = bkr->scene;
- Main *bmain = bkr->main;
-
- bkr->stop = stop;
- bkr->do_update = do_update;
- bkr->progress = progress;
-
- RE_test_break_cb(bkr->re, NULL, thread_break);
- G.is_break = false; /* BKE_blender_test_break uses this global */
-
- RE_Database_Baking(bkr->re, bmain, scene, bkr->view_layer, scene->lay, scene->r.bake_mode, bkr->actob);
-
- /* baking itself is threaded, cannot use test_break in threads. we also update optional imagewindow */
- bkr->result = RE_bake_shade_all_selected(bkr->re, scene->r.bake_mode, bkr->actob, bkr->do_update, bkr->progress);
-}
-
-static void bake_update(void *bkv)
-{
- BakeRender *bkr = bkv;
-
- if (bkr->sa && bkr->sa->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */
- SpaceImage *sima = bkr->sa->spacedata.first;
- if (sima)
- sima->image = RE_bake_shade_get_image();
- }
-}
-
-static void bake_freejob(void *bkv)
-{
- BakeRender *bkr = bkv;
- finish_bake_internal(bkr);
-
- if (bkr->result == BAKE_RESULT_NO_OBJECTS)
- BKE_report(bkr->reports, RPT_ERROR, "No objects or images found to bake to");
- else if (bkr->result == BAKE_RESULT_FEEDBACK_LOOP)
- BKE_report(bkr->reports, RPT_WARNING, "Circular reference in texture stack");
-
- MEM_freeN(bkr);
- G.is_rendering = false;
-}
-
/* catch esc */
static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
@@ -780,7 +592,7 @@ static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const
static bool is_multires_bake(Scene *scene)
{
- if (ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE, RE_BAKE_AO))
+ if (ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_AO))
return scene->r.bake_flag & R_BAKE_MULTIRES;
return 0;
@@ -791,44 +603,7 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, const wmEvent
Scene *scene = CTX_data_scene(C);
int result = OPERATOR_CANCELLED;
- if (is_multires_bake(scene)) {
- result = multiresbake_image_exec(C, op);
- }
- else {
- /* only one render job at a time */
- if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE))
- return OPERATOR_CANCELLED;
-
- if (test_bake_internal(C, op->reports) == 0) {
- return OPERATOR_CANCELLED;
- }
- else {
- BakeRender *bkr = MEM_callocN(sizeof(BakeRender), "render bake");
- wmJob *wm_job;
-
- init_bake_internal(bkr, C);
- bkr->reports = op->reports;
-
- /* setup job */
- 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.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;
- G.is_rendering = true;
-
- WM_jobs_start(CTX_wm_manager(C), wm_job);
-
- WM_cursor_wait(0);
-
- /* add modal handler for ESC */
- WM_event_add_modal_handler(C, op);
- }
-
- result = OPERATOR_RUNNING_MODAL;
- }
+ result = multiresbake_image_exec(C, op);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
@@ -838,56 +613,11 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, const wmEvent
static int bake_image_exec(bContext *C, wmOperator *op)
{
- Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
int result = OPERATOR_CANCELLED;
- if (is_multires_bake(scene)) {
- result = multiresbake_image_exec_locked(C, op);
- }
- else {
- if (test_bake_internal(C, op->reports) == 0) {
- return OPERATOR_CANCELLED;
- }
- else {
- ListBase threads;
- BakeRender bkr = {NULL};
-
- init_bake_internal(&bkr, C);
- bkr.reports = op->reports;
-
- RE_test_break_cb(bkr.re, NULL, thread_break);
- G.is_break = false; /* BKE_blender_test_break uses this global */
-
- RE_Database_Baking(bkr.re, bmain, scene, bkr.view_layer, scene->lay, scene->r.bake_mode,
- (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT(bkr.view_layer) : NULL);
-
- /* baking itself is threaded, cannot use test_break in threads */
- BLI_threadpool_init(&threads, do_bake_render, 1);
- bkr.ready = 0;
- BLI_threadpool_insert(&threads, &bkr);
-
- while (bkr.ready == 0) {
- PIL_sleep_ms(50);
- if (bkr.ready)
- break;
-
- /* used to redraw in 2.4x but this is just for exec in 2.5 */
- if (!G.background)
- BKE_blender_test_break();
- }
- BLI_threadpool_end(&threads);
-
- if (bkr.result == BAKE_RESULT_NO_OBJECTS)
- BKE_report(op->reports, RPT_ERROR, "No valid images found to bake to");
- else if (bkr.result == BAKE_RESULT_FEEDBACK_LOOP)
- BKE_report(op->reports, RPT_ERROR, "Circular reference in texture stack");
-
- finish_bake_internal(&bkr);
-
- result = OPERATOR_FINISHED;
- }
- }
+ BLI_assert(is_multires_bake(scene));
+ result = multiresbake_image_exec_locked(C, op);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 40a49df1657..60533e382e8 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -623,11 +623,11 @@ static size_t initialize_internal_images(BakeImages *bake_images, ReportList *re
}
/* create new mesh with edit mode changes and modifiers applied */
-static Mesh *bake_mesh_new_from_object(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *ob)
+static Mesh *bake_mesh_new_from_object(Depsgraph *depsgraph, Main *bmain, Scene *scene, Object *ob)
{
ED_object_editmode_load(ob);
- Mesh *me = BKE_mesh_new_from_object(eval_ctx, bmain, scene, ob, 1, 0, 0);
+ Mesh *me = BKE_mesh_new_from_object(depsgraph, bmain, scene, ob, 1, 0, 0);
if (me->flag & ME_AUTOSMOOTH) {
BKE_mesh_split_faces(me, true);
}
@@ -645,9 +645,7 @@ static int bake(
const char *custom_cage, const char *filepath, const int width, const int height,
const char *identifier, ScrArea *sa, const char *uv_layer)
{
- EvaluationContext *eval_ctx = DEG_evaluation_context_new(DAG_EVAL_RENDER);
Depsgraph *depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
- DEG_evaluation_context_init_from_view_layer_for_render(eval_ctx, depsgraph, scene, view_layer);
int op_result = OPERATOR_CANCELLED;
bool ok = false;
@@ -795,7 +793,7 @@ static int bake(
BKE_scene_graph_update_tagged(depsgraph, bmain);
/* get the mesh as it arrives in the renderer */
- me_low = bake_mesh_new_from_object(eval_ctx, bmain, scene, ob_low);
+ me_low = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low);
/* populate the pixel array with the face data */
if ((is_selected_to_active && (ob_cage == NULL) && is_cage) == false)
@@ -810,7 +808,7 @@ static int bake(
/* prepare cage mesh */
if (ob_cage) {
- me_cage = bake_mesh_new_from_object(eval_ctx, bmain, scene, ob_cage);
+ me_cage = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_cage);
if ((me_low->totpoly != me_cage->totpoly) || (me_low->totloop != me_cage->totloop)) {
BKE_report(reports, RPT_ERROR,
"Invalid cage object, the cage mesh must have the same number "
@@ -842,7 +840,7 @@ static int bake(
ob_low->modifiers = modifiers_tmp;
/* get the cage mesh as it arrives in the renderer */
- me_cage = bake_mesh_new_from_object(eval_ctx, bmain, scene, ob_low);
+ me_cage = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low);
RE_bake_pixels_populate(me_cage, pixel_array_low, num_pixels, &bake_images, uv_layer);
}
@@ -868,7 +866,7 @@ static int bake(
tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP;
- highpoly[i].me = bake_mesh_new_from_object(eval_ctx, bmain, scene, highpoly[i].ob);
+ highpoly[i].me = bake_mesh_new_from_object(depsgraph, bmain, scene, highpoly[i].ob);
highpoly[i].ob->restrictflag &= ~OB_RESTRICT_RENDER;
/* lowpoly to highpoly transformation matrix */
@@ -971,7 +969,7 @@ cage_cleanup:
md->mode &= ~eModifierMode_Render;
}
- me_nores = bake_mesh_new_from_object(eval_ctx, bmain, scene, ob_low);
+ me_nores = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low);
RE_bake_pixels_populate(me_nores, pixel_array_low, num_pixels, &bake_images, uv_layer);
RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_nores, normal_swizzle, ob_low->obmat);
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 1a20a8db5b3..95778b73e55 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -684,8 +684,6 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
static int stretchto_reset_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_STRETCHTO);
bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL;
@@ -732,8 +730,6 @@ void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot)
static int limitdistance_reset_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_DISTLIMIT);
bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL;
@@ -781,9 +777,7 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot)
static void child_get_inverse_matrix(const bContext *C, Scene *scene, Object *ob, bConstraint *con, float invmat[4][4], const int owner)
{
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
/* nullify inverse matrix first */
unit_m4(invmat);
@@ -810,7 +804,7 @@ static void child_get_inverse_matrix(const bContext *C, Scene *scene, Object *ob
* to use as baseline ("pmat") to derive delta from. This extra calc saves users
* from having pressing "Clear Inverse" first
*/
- BKE_pose_where_is(&eval_ctx, scene, ob);
+ BKE_pose_where_is(depsgraph, scene, ob);
copy_m4_m4(pmat, pchan->pose_mat);
/* 2. knock out constraints starting from this one */
@@ -827,7 +821,7 @@ static void child_get_inverse_matrix(const bContext *C, Scene *scene, Object *ob
}
/* 3. solve pose without disabled constraints */
- BKE_pose_where_is(&eval_ctx, scene, ob);
+ BKE_pose_where_is(depsgraph, scene, ob);
/* 4. determine effect of constraint by removing the newly calculated
* pchan->pose_mat from the original pchan->pose_mat, thus determining
@@ -850,7 +844,7 @@ static void child_get_inverse_matrix(const bContext *C, Scene *scene, Object *ob
}
/* 6. recalculate pose with new inv-mat applied */
- BKE_pose_where_is(&eval_ctx, scene, ob);
+ BKE_pose_where_is(depsgraph, scene, ob);
}
}
if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) {
@@ -861,7 +855,7 @@ static void child_get_inverse_matrix(const bContext *C, Scene *scene, Object *ob
BLI_assert(BLI_findindex(&ob->constraints, con) != -1);
/* use BKE_object_workob_calc_parent to find inverse - just like for normal parenting */
- BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
+ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
invert_m4_m4(invmat, workob.obmat);
}
}
@@ -870,8 +864,6 @@ static void child_get_inverse_matrix(const bContext *C, Scene *scene, Object *ob
/* ChildOf Constraint - set inverse callback */
static int childof_set_inverse_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF);
@@ -923,8 +915,6 @@ void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot)
static int childof_clear_inverse_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF);
bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL;
@@ -972,8 +962,6 @@ void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot)
static int followpath_path_animate_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_FOLLOWPATH);
bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : NULL;
@@ -1098,8 +1086,6 @@ void CONSTRAINT_OT_followpath_path_animate(wmOperatorType *ot)
static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
@@ -1149,8 +1135,6 @@ void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot)
static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL;
@@ -1320,8 +1304,6 @@ void CONSTRAINT_OT_delete(wmOperatorType *ot)
static int constraint_move_down_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, 0);
@@ -1371,8 +1353,6 @@ void CONSTRAINT_OT_move_down(wmOperatorType *ot)
static int constraint_move_up_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, 0);
@@ -1593,8 +1573,6 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot)
/* get the Object and/or PoseChannel to use as target */
static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, bool add)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Object *obact = ED_object_active_context(C);
bPoseChannel *pchanact = BKE_pose_channel_active(obact);
bool only_curve = false, only_mesh = false, only_ob = false;
@@ -1637,11 +1615,6 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
only_ob = true;
add = false;
break;
-
- /* object only - add here is ok? */
- case CONSTRAINT_TYPE_RIGIDBODYJOINT:
- only_ob = true;
- break;
}
/* if the active Object is Armature, and we can search for bones, do so... */
@@ -1673,7 +1646,7 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
/* for armatures in pose mode, look inside the armature for the active bone
* so that we set up cross-armature constraints with less effort
*/
- if ((ob->type == OB_ARMATURE) && (eval_ctx.mode & OB_MODE_POSE) &&
+ if ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE) &&
(!only_curve && !only_mesh))
{
/* just use the active bone, and assume that it is visible + usable */
@@ -1770,10 +1743,6 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
if (type == CONSTRAINT_TYPE_NULL) {
return OPERATOR_CANCELLED;
}
- if ((type == CONSTRAINT_TYPE_RIGIDBODYJOINT) && (list != &ob->constraints)) {
- BKE_report(op->reports, RPT_ERROR, "Rigid Body Joint constraint can only be added to objects");
- return OPERATOR_CANCELLED;
- }
if ((type == CONSTRAINT_TYPE_KINEMATIC) && ((!pchan) || (list != &pchan->constraints))) {
BKE_report(op->reports, RPT_ERROR, "IK constraint can only be added to bones");
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 2daa8652335..d4e8955b38e 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -94,7 +94,6 @@ static const EnumPropertyItem DT_layer_items[] = {
static const EnumPropertyItem *dt_layers_select_src_itemf(
bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
- EvaluationContext eval_ctx;
EnumPropertyItem *item = NULL, tmp_item = {0};
int totitem = 0;
const int data_type = RNA_enum_get(ptr, "data_type");
@@ -103,7 +102,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
return rna_enum_dt_layers_select_src_items;
}
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ACTIVE_SRC);
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC);
@@ -142,7 +141,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
int num_data, i;
/* XXX Is this OK? */
- dm_src = mesh_get_derived_final(&eval_ctx, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV);
+ dm_src = mesh_get_derived_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV);
ldata = dm_src->getLoopDataLayout(dm_src);
num_data = CustomData_number_of_layers(ldata, CD_MLOOPUV);
@@ -165,7 +164,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
int num_data, i;
/* XXX Is this OK? */
- dm_src = mesh_get_derived_final(&eval_ctx, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL);
+ dm_src = mesh_get_derived_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL);
ldata = dm_src->getLoopDataLayout(dm_src);
num_data = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
@@ -347,9 +346,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob_src = ED_object_active_context(C);
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ListBase ctx_objects;
CollectionPointerLink *ctx_ob_dst;
@@ -418,7 +415,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
}
if (BKE_object_data_transfer_mesh(
- &eval_ctx, scene, ob_src, ob_dst, data_type, use_create,
+ depsgraph, scene, ob_src, ob_dst, data_type, use_create,
map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode,
space_transform, use_auto_transform,
max_distance, ray_radius, islands_precision,
@@ -531,7 +528,7 @@ static void data_transfer_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call */
- uiDefAutoButsRNA(layout, &ptr, data_transfer_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, data_transfer_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
/* transfers weight from active to selected */
@@ -628,11 +625,9 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob_act = ED_object_active_context(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
DataTransferModifierData *dtmd;
- CTX_data_eval_ctx(C, &eval_ctx);
-
dtmd = (DataTransferModifierData *)edit_modifier_property_get(op, ob_act, eModifierType_DataTransfer);
/* If we have a modifier, we transfer data layout from this modifier's source object to active one.
@@ -647,7 +642,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_object_data_transfer_layout(&eval_ctx, scene, ob_src, ob_dst, dtmd->data_types, use_delete,
+ BKE_object_data_transfer_layout(depsgraph, scene, ob_src, ob_dst, dtmd->data_types, use_delete,
dtmd->layers_select_src, dtmd->layers_select_dst);
DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
@@ -677,7 +672,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
for (ctx_ob_dst = ctx_objects.first; ctx_ob_dst; ctx_ob_dst = ctx_ob_dst->next) {
Object *ob_dst = ctx_ob_dst->ptr.data;
if (data_transfer_exec_is_object_valid(op, ob_src, ob_dst, false)) {
- BKE_object_data_transfer_layout(&eval_ctx, scene, ob_src, ob_dst, data_type, use_delete,
+ BKE_object_data_transfer_layout(depsgraph, scene, ob_src, ob_dst, data_type, use_delete,
layers_select_src, layers_select_dst);
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index b4fa27c3fd9..e58855c756e 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -51,7 +51,6 @@
#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
-#include "DNA_property_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force_types.h"
@@ -80,15 +79,13 @@
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_pointcache.h"
-#include "BKE_property.h"
-#include "BKE_sca.h"
#include "BKE_softbody.h"
#include "BKE_modifier.h"
#include "BKE_editlattice.h"
#include "BKE_editmesh.h"
#include "BKE_report.h"
-#include "BKE_object.h"
#include "BKE_workspace.h"
+#include "BKE_layer.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -282,9 +279,6 @@ bool ED_object_editmode_load(Object *obedit)
void ED_object_editmode_exit_ex(bContext *C, Scene *scene, Object *obedit, int flag)
{
BLI_assert(C || !(flag & EM_DO_UNDO));
- /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */
- /* Note! if 'EM_FREEDATA' isn't in the flag, use ED_object_editmode_load directly */
- ViewLayer *view_layer = CTX_data_view_layer(C);
const bool freedata = (flag & EM_FREEDATA) != 0;
if (flag & EM_WAITCURSOR) waitcursor(1);
@@ -292,8 +286,8 @@ void ED_object_editmode_exit_ex(bContext *C, Scene *scene, Object *obedit, int f
if (ED_object_editmode_load_ex(G.main, obedit, freedata) == false) {
/* in rare cases (background mode) its possible active object
* is flagged for editmode, without 'obedit' being set [#35489] */
- if (UNLIKELY(view_layer->basact && (view_layer->basact->object->mode & OB_MODE_EDIT))) {
- view_layer->basact->object->mode &= ~OB_MODE_EDIT;
+ if (UNLIKELY(obedit && obedit->mode & OB_MODE_EDIT)) {
+ obedit->mode &= ~OB_MODE_EDIT;
}
if (flag & EM_WAITCURSOR) waitcursor(0);
return;
@@ -320,15 +314,18 @@ void ED_object_editmode_exit_ex(bContext *C, Scene *scene, Object *obedit, int f
if (flag & EM_DO_UNDO)
ED_undo_push(C, "Editmode");
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
+ if (C != NULL) {
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
+ }
+ else {
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
+ }
+
obedit->mode &= ~OB_MODE_EDIT;
}
if (flag & EM_WAITCURSOR) waitcursor(0);
-
- /* This way we ensure scene's obedit is copied into all CoW scenes. */
- DEG_id_tag_update(&scene->id, 0);
}
void ED_object_editmode_exit(bContext *C, int flag)
@@ -338,25 +335,12 @@ void ED_object_editmode_exit(bContext *C, int flag)
ED_object_editmode_exit_ex(C, scene, obedit, flag);
}
-void ED_object_editmode_enter(bContext *C, int flag)
+void ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag)
{
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *ob;
bool ok = false;
- if (ID_IS_LINKED(scene)) return;
-
- if ((flag & EM_IGNORE_LAYER) == 0) {
- ob = CTX_data_active_object(C); /* active layer checked here for view3d */
-
- if (ob == NULL) return;
- }
- else {
- ob = view_layer->basact->object;
- }
-
if (ELEM(NULL, ob, ob->data)) return;
+ if (ID_IS_LINKED(ob)) return;
/* this checks actual object->data, for cases when other scenes have it in editmode context */
if (BKE_object_is_in_editmode(ob))
@@ -371,11 +355,6 @@ void ED_object_editmode_enter(bContext *C, int flag)
ob->restore_mode = ob->mode;
- /* note, when switching scenes the object can have editmode data but
- * not be scene->obedit: bug 22954, this avoids calling self eternally */
- if ((ob->restore_mode & OB_MODE_EDIT) == 0)
- ED_object_mode_toggle(C, ob->mode);
-
ob->mode = OB_MODE_EDIT;
if (ob->type == OB_MESH) {
@@ -392,7 +371,7 @@ void ED_object_editmode_enter(bContext *C, int flag)
BKE_editmesh_tessface_calc(em);
}
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MESH, scene);
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MESH, NULL);
}
else if (ob->type == OB_ARMATURE) {
bArmature *arm = ob->data;
@@ -414,51 +393,70 @@ void ED_object_editmode_enter(bContext *C, int flag)
/* to ensure all goes in restposition and without striding */
DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* XXX: should this be OB_RECALC_DATA? */
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene);
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene);
}
else if (ob->type == OB_FONT) {
ok = 1;
ED_curve_editfont_make(ob);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene);
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene);
}
else if (ob->type == OB_MBALL) {
ok = 1;
ED_mball_editmball_make(ob);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MBALL, scene);
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MBALL, scene);
}
else if (ob->type == OB_LATTICE) {
ok = 1;
BKE_editlattice_make(ob);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_LATTICE, scene);
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_LATTICE, scene);
}
else if (ob->type == OB_SURF || ob->type == OB_CURVE) {
ok = 1;
ED_curve_editnurb_make(ob);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene);
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene);
}
else if (ob->type == OB_GROOM) {
ok = 1;
ED_groom_editgroom_make(ob);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_GROOM, scene);
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_GROOM, scene);
}
if (ok) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- /* This way we ensure scene's obedit is copied into all CoW scenes. */
- DEG_id_tag_update(&scene->id, 0);
}
else {
- ob->mode &= ~OB_MODE_EDIT;
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
+ if ((flag & EM_NO_CONTEXT) == 0) {
+ ob->mode &= ~OB_MODE_EDIT;
+ }
+ WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
}
- if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode");
if (flag & EM_WAITCURSOR) waitcursor(0);
+ BLI_assert((flag & EM_DO_UNDO) == 0);
+}
+
+void ED_object_editmode_enter(bContext *C, int flag)
+{
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob;
+
+ if ((flag & EM_IGNORE_LAYER) == 0) {
+ ob = CTX_data_active_object(C); /* active layer checked here for view3d */
+ }
+ else {
+ ob = view_layer->basact->object;
+ }
+ if (ob == NULL) return;
+ if (ID_IS_LINKED(ob)) return;
+
+ ED_object_editmode_enter_ex(scene, ob, flag & ~EM_DO_UNDO);
+ if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode");
}
static int editmode_toggle_exec(bContext *C, wmOperator *op)
@@ -466,18 +464,39 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
const int mode_flag = OB_MODE_EDIT;
const bool is_mode_set = (CTX_data_edit_object(C) != NULL);
Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *obact = OBACT(view_layer);
if (!is_mode_set) {
- Object *ob = CTX_data_active_object(C);
- if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
+ if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
}
}
- if (!is_mode_set)
+ if (!is_mode_set) {
ED_object_editmode_enter(C, EM_WAITCURSOR);
- else
+ if (obact->mode & mode_flag) {
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ {
+ if ((ob != obact) && (ob->type == obact->type)) {
+ ED_object_editmode_enter_ex(scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT);
+ }
+ }
+ FOREACH_SELECTED_OBJECT_END;
+ }
+ }
+ else {
ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */
+ if ((obact->mode & mode_flag) == 0) {
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ {
+ if ((ob != obact) && (ob->type == obact->type)) {
+ ED_object_editmode_exit_ex(NULL, scene, ob, EM_FREEDATA | EM_WAITCURSOR);
+ }
+ }
+ FOREACH_SELECTED_OBJECT_END;
+ }
+ }
ED_space_image_uv_sculpt_update(CTX_wm_manager(C), scene);
@@ -521,27 +540,56 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot)
static int posemode_exec(bContext *C, wmOperator *op)
{
Base *base = CTX_data_active_base(C);
- Object *ob = base->object;
+ Object *obact = base->object;
const int mode_flag = OB_MODE_POSE;
- bool is_mode_set = (ob->mode & mode_flag) != 0;
+ bool is_mode_set = (obact->mode & mode_flag) != 0;
if (!is_mode_set) {
- if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
+ if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) {
return OPERATOR_CANCELLED;
}
}
- if (ob->type == OB_ARMATURE) {
- if (ob == CTX_data_edit_object(C)) {
+ if (obact->type == OB_ARMATURE) {
+ if (obact == CTX_data_edit_object(C)) {
ED_object_editmode_exit(C, EM_FREEDATA | EM_DO_UNDO);
is_mode_set = false;
}
if (is_mode_set) {
- ED_object_posemode_exit(C, ob);
+ bool ok = ED_object_posemode_exit(C, obact);
+ if (ok) {
+ struct Main *bmain = CTX_data_main(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ {
+ if ((ob != obact) &&
+ (ob->type == OB_ARMATURE) &&
+ (ob->mode & mode_flag))
+ {
+ ED_object_posemode_exit_ex(bmain, ob);
+ }
+ }
+ FOREACH_SELECTED_OBJECT_END;
+ }
}
else {
- ED_object_posemode_enter(C, ob);
+ bool ok = ED_object_posemode_enter(C, obact);
+ if (ok) {
+ struct Main *bmain = CTX_data_main(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ {
+ if ((ob != obact) &&
+ (ob->type == OB_ARMATURE) &&
+ (ob->mode == OB_MODE_OBJECT) &&
+ (!ID_IS_LINKED(ob)))
+ {
+ ED_object_posemode_enter_ex(bmain, ob);
+ }
+ }
+ FOREACH_SELECTED_OBJECT_END;
+ }
}
return OPERATOR_FINISHED;
}
@@ -564,102 +612,6 @@ void OBJECT_OT_posemode_toggle(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static void copymenu_properties(ViewLayer *view_layer, Object *ob)
-{
-//XXX no longer used - to be removed - replaced by game_properties_copy_exec
- bProperty *prop;
- Base *base;
- int nr, tot = 0;
- char *str;
-
- prop = ob->prop.first;
- while (prop) {
- tot++;
- prop = prop->next;
- }
-
- str = MEM_callocN(50 + 33 * tot, "copymenu prop");
-
- if (tot)
- strcpy(str, "Copy Property %t|Replace All|Merge All|%l");
- else
- strcpy(str, "Copy Property %t|Clear All (no properties on active)");
-
- tot = 0;
- prop = ob->prop.first;
- while (prop) {
- tot++;
- strcat(str, "|");
- strcat(str, prop->name);
- prop = prop->next;
- }
-
- nr = pupmenu(str);
-
- if (nr == 1 || nr == 2) {
- for (base = FIRSTBASE(view_layer); base; base = base->next) {
- if ((base != BASACT(view_layer)) && (TESTBASELIB(base))) {
- if (nr == 1) { /* replace */
- BKE_bproperty_copy_list(&base->object->prop, &ob->prop);
- }
- else {
- for (prop = ob->prop.first; prop; prop = prop->next) {
- BKE_bproperty_object_set(base->object, prop);
- }
- }
- }
- }
- }
- else if (nr > 0) {
- prop = BLI_findlink(&ob->prop, nr - 4); /* account for first 3 menu items & menu index starting at 1*/
-
- if (prop) {
- for (base = FIRSTBASE(view_layer); base; base = base->next) {
- if ((base != BASACT(view_layer)) && (TESTBASELIB(base))) {
- BKE_bproperty_object_set(base->object, prop);
- }
- }
- }
- }
- MEM_freeN(str);
-
-}
-
-static void copymenu_logicbricks(ViewLayer *view_layer, Object *ob)
-{
-//XXX no longer used - to be removed - replaced by logicbricks_copy_exec
- Base *base;
-
- for (base = FIRSTBASE(view_layer); base; base = base->next) {
- if (base->object != ob) {
- if (TESTBASELIB(base)) {
-
- /* first: free all logic */
- free_sensors(&base->object->sensors);
- unlink_controllers(&base->object->controllers);
- free_controllers(&base->object->controllers);
- unlink_actuators(&base->object->actuators);
- free_actuators(&base->object->actuators);
-
- /* now copy it, this also works without logicbricks! */
- clear_sca_new_poins_ob(ob);
- copy_sensors(&base->object->sensors, &ob->sensors, 0);
- copy_controllers(&base->object->controllers, &ob->controllers, 0);
- copy_actuators(&base->object->actuators, &ob->actuators, 0);
- set_sca_new_poins_ob(base->object);
-
- /* some menu settings */
- base->object->scavisflag = ob->scavisflag;
- base->object->scaflag = ob->scaflag;
-
- /* set the initial state */
- base->object->state = ob->state;
- base->object->init_state = ob->init_state;
- }
- }
- }
-}
-
/* both pointers should exist */
static void copy_texture_space(Object *to, Object *ob)
{
@@ -727,15 +679,8 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
/* obedit_copymenu(); */
return;
}
- if (event == 9) {
- copymenu_properties(view_layer, ob);
- return;
- }
- else if (event == 10) {
- copymenu_logicbricks(view_layer, ob);
- return;
- }
- else if (event == 24) {
+
+ if (event == 24) {
/* moved to BKE_object_link_modifiers */
/* copymenu_modifiers(bmain, scene, v3d, ob); */
return;
@@ -783,30 +728,6 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev
if (ob->dup_group)
id_us_plus(&ob->dup_group->id);
}
- else if (event == 7) { /* mass */
- base->object->mass = ob->mass;
- }
- else if (event == 8) { /* damping */
- base->object->damping = ob->damping;
- base->object->rdamping = ob->rdamping;
- }
- else if (event == 11) { /* all physical attributes */
- base->object->gameflag = ob->gameflag;
- base->object->inertia = ob->inertia;
- base->object->formfactor = ob->formfactor;
- base->object->damping = ob->damping;
- base->object->rdamping = ob->rdamping;
- base->object->min_vel = ob->min_vel;
- base->object->max_vel = ob->max_vel;
- base->object->min_angvel = ob->min_angvel;
- base->object->max_angvel = ob->max_angvel;
- if (ob->gameflag & OB_BOUNDS) {
- base->object->collision_boundtype = ob->collision_boundtype;
- }
- base->object->margin = ob->margin;
- base->object->bsoft = copy_bulletsoftbody(ob->bsoft, 0);
-
- }
else if (event == 17) { /* tex space */
copy_texture_space(base->object, ob);
}
@@ -1086,8 +1007,7 @@ void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
void ED_objects_recalculate_paths(bContext *C, Scene *scene)
{
struct Main *bmain = CTX_data_main(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ListBase targets = {NULL, NULL};
/* loop over objects in scene */
@@ -1100,7 +1020,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
CTX_DATA_END;
/* recalculate paths, then free */
- animviz_calc_motionpaths(&eval_ctx, bmain, scene, &targets);
+ animviz_calc_motionpaths(depsgraph, bmain, scene, &targets);
BLI_freelistN(&targets);
}
@@ -1386,68 +1306,6 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot)
/* ********************** */
-static void UNUSED_FUNCTION(image_aspect) (Scene *scene, ViewLayer *view_layer, Object *obedit)
-{
- /* all selected objects with an image map: scale in image aspect */
- Base *base;
- Object *ob;
- Material *ma;
- Tex *tex;
- float x, y, space;
- int a, b, done;
-
- if (obedit) return;
- if (ID_IS_LINKED(scene)) return;
-
- for (base = FIRSTBASE(view_layer); base; base = base->next) {
- if (TESTBASELIB(base)) {
- ob = base->object;
- done = false;
-
- for (a = 1; a <= ob->totcol; a++) {
- ma = give_current_material(ob, a);
- if (ma) {
- for (b = 0; b < MAX_MTEX; b++) {
- if (ma->mtex[b] && ma->mtex[b]->tex) {
- tex = ma->mtex[b]->tex;
- if (tex->type == TEX_IMAGE && tex->ima) {
- ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, NULL, NULL);
-
- /* texturespace */
- space = 1.0;
- if (ob->type == OB_MESH) {
- float size[3];
- BKE_mesh_texspace_get(ob->data, NULL, NULL, size);
- space = size[0] / size[1];
- }
- else if (ELEM(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
- float size[3];
- BKE_curve_texspace_get(ob->data, NULL, NULL, size);
- space = size[0] / size[1];
- }
-
- x = ibuf->x / space;
- y = ibuf->y;
-
- if (x > y) ob->size[0] = ob->size[1] * x / y;
- else ob->size[1] = ob->size[0] * y / x;
-
- done = true;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
-
- BKE_image_release_ibuf(tex->ima, ibuf, NULL);
- }
- }
- if (done) break;
- }
- }
- if (done) break;
- }
- }
- }
-
-}
-
static const EnumPropertyItem *object_mode_set_itemsf(
bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
{
@@ -1593,393 +1451,6 @@ void OBJECT_OT_mode_set(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
-/************************ Game Properties ***********************/
-
-static int game_property_new_exec(bContext *C, wmOperator *op)
-{
- Object *ob = CTX_data_active_object(C);
- bProperty *prop;
- char name[MAX_NAME];
- int type = RNA_enum_get(op->ptr, "type");
-
- prop = BKE_bproperty_new(type);
- BLI_addtail(&ob->prop, prop);
-
- RNA_string_get(op->ptr, "name", name);
- if (name[0] != '\0') {
- BLI_strncpy(prop->name, name, sizeof(prop->name));
- }
-
- BLI_uniquename(&ob->prop, prop, DATA_("Property"), '.', offsetof(bProperty, name), sizeof(prop->name));
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
- return OPERATOR_FINISHED;
-}
-
-
-void OBJECT_OT_game_property_new(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "New Game Property";
- ot->description = "Create a new property available to the game engine";
- ot->idname = "OBJECT_OT_game_property_new";
-
- /* api callbacks */
- ot->exec = game_property_new_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_enum(ot->srna, "type", rna_enum_gameproperty_type_items, GPROP_FLOAT, "Type", "Type of game property to add");
- RNA_def_string(ot->srna, "name", NULL, MAX_NAME, "Name", "Name of the game property to add");
-}
-
-static int game_property_remove_exec(bContext *C, wmOperator *op)
-{
- Object *ob = CTX_data_active_object(C);
- bProperty *prop;
- int index = RNA_int_get(op->ptr, "index");
-
- if (!ob)
- return OPERATOR_CANCELLED;
-
- prop = BLI_findlink(&ob->prop, index);
-
- if (prop) {
- BLI_remlink(&ob->prop, prop);
- BKE_bproperty_free(prop);
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-
-void OBJECT_OT_game_property_remove(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Remove Game Property";
- ot->description = "Remove game property";
- ot->idname = "OBJECT_OT_game_property_remove";
-
- /* api callbacks */
- ot->exec = game_property_remove_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Property index to remove ", 0, INT_MAX);
-}
-
-#define GAME_PROPERTY_MOVE_UP 1
-#define GAME_PROPERTY_MOVE_DOWN -1
-
-static int game_property_move(bContext *C, wmOperator *op)
-{
- Object *ob = CTX_data_active_object(C);
- bProperty *prop;
- bProperty *otherprop = NULL;
- const int index = RNA_int_get(op->ptr, "index");
- const int dir = RNA_enum_get(op->ptr, "direction");
-
- if (ob == NULL)
- return OPERATOR_CANCELLED;
-
- prop = BLI_findlink(&ob->prop, index);
- /* invalid index */
- if (prop == NULL)
- return OPERATOR_CANCELLED;
-
- if (dir == GAME_PROPERTY_MOVE_UP) {
- otherprop = prop->prev;
- }
- else if (dir == GAME_PROPERTY_MOVE_DOWN) {
- otherprop = prop->next;
- }
- else {
- BLI_assert(0);
- }
-
- if (prop && otherprop) {
- BLI_listbase_swaplinks(&ob->prop, prop, otherprop);
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-}
-
-void OBJECT_OT_game_property_move(wmOperatorType *ot)
-{
- static const EnumPropertyItem direction_property_move[] = {
- {GAME_PROPERTY_MOVE_UP, "UP", 0, "Up", ""},
- {GAME_PROPERTY_MOVE_DOWN, "DOWN", 0, "Down", ""},
- {0, NULL, 0, NULL, NULL}
- };
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Move Game Property";
- ot->description = "Move game property";
- ot->idname = "OBJECT_OT_game_property_move";
-
- /* api callbacks */
- ot->exec = game_property_move;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- prop = RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Property index to move", 0, INT_MAX);
- RNA_def_property_flag(prop, PROP_HIDDEN);
- RNA_def_enum(ot->srna, "direction", direction_property_move, 0, "Direction",
- "Direction for moving the property");
-}
-
-#undef GAME_PROPERTY_MOVE_UP
-#undef GAME_PROPERTY_MOVE_DOWN
-
-#define COPY_PROPERTIES_REPLACE 1
-#define COPY_PROPERTIES_MERGE 2
-#define COPY_PROPERTIES_COPY 3
-
-static const EnumPropertyItem game_properties_copy_operations[] = {
- {COPY_PROPERTIES_REPLACE, "REPLACE", 0, "Replace Properties", ""},
- {COPY_PROPERTIES_MERGE, "MERGE", 0, "Merge Properties", ""},
- {COPY_PROPERTIES_COPY, "COPY", 0, "Copy a Property", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-static const EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
- Object *ob = ED_object_active_context(C);
- EnumPropertyItem tmp = {0, "", 0, "", ""};
- EnumPropertyItem *item = NULL;
- bProperty *prop;
- int a, totitem = 0;
-
- if (!ob)
- return DummyRNA_NULL_items;
-
- for (a = 1, prop = ob->prop.first; prop; prop = prop->next, a++) {
- tmp.value = a;
- tmp.identifier = prop->name;
- tmp.name = prop->name;
- RNA_enum_item_add(&item, &totitem, &tmp);
- }
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
-static int game_property_copy_exec(bContext *C, wmOperator *op)
-{
- Object *ob = ED_object_active_context(C);
- bProperty *prop;
- int type = RNA_enum_get(op->ptr, "operation");
- int propid = RNA_enum_get(op->ptr, "property");
-
- if (propid > 0) { /* copy */
- prop = BLI_findlink(&ob->prop, propid - 1);
-
- if (prop) {
- CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
- {
- if (ob != ob_iter)
- BKE_bproperty_object_set(ob_iter, prop);
- } CTX_DATA_END;
- }
- }
-
- else {
- CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
- {
- if (ob != ob_iter) {
- if (type == COPY_PROPERTIES_REPLACE) {
- BKE_bproperty_copy_list(&ob_iter->prop, &ob->prop);
- }
- else {
- /* merge - the default when calling with no argument */
- for (prop = ob->prop.first; prop; prop = prop->next) {
- BKE_bproperty_object_set(ob_iter, prop);
- }
- }
- }
- }
- CTX_DATA_END;
- }
-
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_OT_game_property_copy(wmOperatorType *ot)
-{
- PropertyRNA *prop;
- /* identifiers */
- ot->name = "Copy Game Property";
- ot->idname = "OBJECT_OT_game_property_copy";
- ot->description = "Copy/merge/replace a game property from active object to all selected objects";
-
- /* api callbacks */
- ot->exec = game_property_copy_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", "");
- prop = RNA_def_enum(ot->srna, "property", DummyRNA_NULL_items, 0, "Property", "Properties to copy");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_ENUM_NO_TRANSLATE);
- RNA_def_enum_funcs(prop, gameprops_itemf);
- ot->prop = prop;
-}
-
-static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op))
-{
- CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
- {
- BKE_bproperty_free_list(&ob_iter->prop);
- }
- CTX_DATA_END;
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
- return OPERATOR_FINISHED;
-}
-void OBJECT_OT_game_property_clear(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Clear Game Properties";
- ot->idname = "OBJECT_OT_game_property_clear";
- ot->description = "Remove all game properties from all selected objects";
-
- /* api callbacks */
- ot->exec = game_property_clear_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-/************************ Copy Logic Bricks ***********************/
-
-static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = ED_object_active_context(C);
-
- CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
- {
- if (ob != ob_iter) {
- /* first: free all logic */
- free_sensors(&ob_iter->sensors);
- unlink_controllers(&ob_iter->controllers);
- free_controllers(&ob_iter->controllers);
- unlink_actuators(&ob_iter->actuators);
- free_actuators(&ob_iter->actuators);
-
- /* now copy it, this also works without logicbricks! */
- clear_sca_new_poins_ob(ob);
- copy_sensors(&ob_iter->sensors, &ob->sensors, 0);
- copy_controllers(&ob_iter->controllers, &ob->controllers, 0);
- copy_actuators(&ob_iter->actuators, &ob->actuators, 0);
- set_sca_new_poins_ob(ob_iter);
-
- /* some menu settings */
- ob_iter->scavisflag = ob->scavisflag;
- ob_iter->scaflag = ob->scaflag;
-
- /* set the initial state */
- ob_iter->state = ob->state;
- ob_iter->init_state = ob->init_state;
-
- if (ob_iter->totcol == ob->totcol) {
- ob_iter->actcol = ob->actcol;
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter);
- }
- }
- }
- CTX_DATA_END;
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_OT_logic_bricks_copy(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Copy Logic Bricks to Selected";
- ot->description = "Copy logic bricks to other selected objects";
- ot->idname = "OBJECT_OT_logic_bricks_copy";
-
- /* api callbacks */
- ot->exec = logicbricks_copy_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = ED_object_active_context(C);
-
- CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
- {
- if (ob != ob_iter) {
- ob_iter->gameflag = ob->gameflag;
- ob_iter->gameflag2 = ob->gameflag2;
- ob_iter->inertia = ob->inertia;
- ob_iter->formfactor = ob->formfactor;
- ob_iter->damping = ob->damping;
- ob_iter->rdamping = ob->rdamping;
- ob_iter->min_vel = ob->min_vel;
- ob_iter->max_vel = ob->max_vel;
- ob_iter->min_angvel = ob->min_angvel;
- ob_iter->max_angvel = ob->max_angvel;
- ob_iter->obstacleRad = ob->obstacleRad;
- ob_iter->mass = ob->mass;
- copy_v3_v3(ob_iter->anisotropicFriction, ob->anisotropicFriction);
- ob_iter->collision_boundtype = ob->collision_boundtype;
- ob_iter->margin = ob->margin;
- ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft, 0);
- if (ob->restrictflag & OB_RESTRICT_RENDER)
- ob_iter->restrictflag |= OB_RESTRICT_RENDER;
- else
- ob_iter->restrictflag &= ~OB_RESTRICT_RENDER;
-
- ob_iter->col_group = ob->col_group;
- ob_iter->col_mask = ob->col_mask;
- }
- }
- CTX_DATA_END;
-
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Copy Game Physics Properties to Selected";
- ot->description = "Copy game physics properties to other selected objects";
- ot->idname = "OBJECT_OT_game_physics_copy";
-
- /* api callbacks */
- ot->exec = game_physics_copy_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
bool ED_object_editmode_calc_active_center(Object *obedit, const bool select_only, float r_center[3])
{
switch (obedit->type) {
@@ -2173,16 +1644,16 @@ static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout
MoveToCollectionData *menu = menu_v;
uiItemIntO(layout,
- menu->collection->name,
- ICON_NONE,
- "OBJECT_OT_move_to_collection",
- "collection_index",
- menu->index);
+ menu->collection->name,
+ ICON_NONE,
+ "OBJECT_OT_move_to_collection",
+ "collection_index",
+ menu->index);
uiItemS(layout);
for (MoveToCollectionData *submenu = menu->submenus.first;
- submenu != NULL;
- submenu = submenu->next)
+ submenu != NULL;
+ submenu = submenu->next)
{
move_to_collection_menus_items(layout, submenu);
}
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 3ff794772fa..b5a71bb7a35 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -471,14 +471,11 @@ static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLay
{
ModifierData *md = NULL;
HookModifierData *hmd = NULL;
- EvaluationContext eval_ctx;
float cent[3];
float pose_mat[4][4];
int tot, ok, *indexar;
char name[MAX_NAME];
- CTX_data_eval_ctx(C, &eval_ctx);
-
ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent);
if (!ok) {
@@ -547,7 +544,7 @@ static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLay
/* matrix calculus */
/* vert x (obmat x hook->imat) x hook->obmat x ob->imat */
/* (parentinv ) */
- BKE_object_where_is_calc(&eval_ctx, scene, ob);
+ BKE_object_where_is_calc(CTX_data_depsgraph(C), scene, ob);
invert_m4_m4(ob->imat, ob->obmat);
/* apparently this call goes from right to left... */
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 944912ad6b6..524c23be767 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -87,14 +87,6 @@ void OBJECT_OT_paths_update(struct wmOperatorType *ot);
void OBJECT_OT_paths_clear(struct wmOperatorType *ot);
void OBJECT_OT_forcefield_toggle(struct wmOperatorType *ot);
-void OBJECT_OT_game_property_new(struct wmOperatorType *ot);
-void OBJECT_OT_game_property_remove(struct wmOperatorType *ot);
-void OBJECT_OT_game_property_copy(struct wmOperatorType *ot);
-void OBJECT_OT_game_property_clear(struct wmOperatorType *ot);
-void OBJECT_OT_game_property_move(struct wmOperatorType *ot);
-void OBJECT_OT_logic_bricks_copy(struct wmOperatorType *ot);
-void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot);
-
void OBJECT_OT_move_to_collection(struct wmOperatorType *ot);
/* object_select.c */
diff --git a/source/blender/editors/object/object_lod.c b/source/blender/editors/object/object_lod.c
deleted file mode 100644
index ced306178b8..00000000000
--- a/source/blender/editors/object/object_lod.c
+++ /dev/null
@@ -1,114 +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) Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/object/object_lod.c
- * \ingroup edobj
- */
-
-#include "DNA_object_types.h"
-
-#include "BKE_context.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "ED_screen.h"
-#include "ED_object.h"
-
-#ifdef WITH_GAMEENGINE
-# include "BKE_object.h"
-
-# include "RNA_enum_types.h"
-#endif
-
-#include "object_intern.h"
-
-static int object_lod_add_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = ED_object_context(C);
-
-#ifdef WITH_GAMEENGINE
- BKE_object_lod_add(ob);
-#else
- (void)ob;
-#endif
-
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_OT_lod_add(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Add Level of Detail";
- ot->description = "Add a level of detail to this object";
- ot->idname = "OBJECT_OT_lod_add";
-
- /* api callbacks */
- ot->exec = object_lod_add_exec;
- ot->poll = ED_operator_object_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int object_lod_remove_exec(bContext *C, wmOperator *op)
-{
- Object *ob = ED_object_context(C);
- int index = RNA_int_get(op->ptr, "index");
-
-#ifdef WITH_GAMEENGINE
- if (!BKE_object_lod_remove(ob, index))
- return OPERATOR_CANCELLED;
-#else
- (void)ob;
- (void)index;
-#endif
-
- WM_event_add_notifier(C, NC_OBJECT | ND_LOD, CTX_wm_view3d(C));
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_OT_lod_remove(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Remove Level of Detail";
- ot->description = "Remove a level of detail from this object";
- ot->idname = "OBJECT_OT_lod_remove";
-
- /* api callbacks */
- ot->exec = object_lod_remove_exec;
- ot->poll = ED_operator_object_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- ot->prop = RNA_def_int(ot->srna, "index", 1, 1, INT_MAX, "Index", "", 1, INT_MAX);
-}
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
index 9e6e6947320..7f293cd9e10 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -178,6 +178,9 @@ bool ED_object_mode_generic_enter(
struct bContext *C, eObjectMode object_mode)
{
Object *ob = CTX_data_active_object(C);
+ if (ob == NULL) {
+ return (object_mode == OB_MODE_OBJECT);
+ }
if (ob->mode == object_mode) {
return true;
}
@@ -195,7 +198,7 @@ bool ED_object_mode_generic_enter(
* Caller can check #OB_MODE_ALL_MODE_DATA to test if this needs to be run.
*/
static bool ed_object_mode_generic_exit_ex(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob,
bool only_test)
{
@@ -228,7 +231,7 @@ static bool ed_object_mode_generic_exit_ex(
if (only_test) {
return true;
}
- ED_object_sculptmode_exit_ex(eval_ctx, scene, ob);
+ ED_object_sculptmode_exit_ex(depsgraph, scene, ob);
}
}
else {
@@ -242,17 +245,17 @@ static bool ed_object_mode_generic_exit_ex(
}
void ED_object_mode_generic_exit(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob)
{
- ed_object_mode_generic_exit_ex(eval_ctx, scene, ob, false);
+ ed_object_mode_generic_exit_ex(depsgraph, scene, ob, false);
}
bool ED_object_mode_generic_has_data(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Object *ob)
{
- return ed_object_mode_generic_exit_ex(eval_ctx, NULL, ob, true);
+ return ed_object_mode_generic_exit_ex(depsgraph, NULL, ob, true);
}
/** \} */
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 5458e4c173f..30d211d2d54 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -78,6 +78,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -524,7 +525,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *
return 1;
}
-static int modifier_apply_shape(ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ModifierData *md)
+static int modifier_apply_shape(ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -557,7 +558,7 @@ static int modifier_apply_shape(ReportList *reports, const EvaluationContext *ev
return 0;
}
- dm = mesh_create_derived_for_modifier(eval_ctx, scene, ob, md, 0);
+ dm = mesh_create_derived_for_modifier(depsgraph, scene, ob, md, 0);
if (!dm) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
return 0;
@@ -584,7 +585,7 @@ static int modifier_apply_shape(ReportList *reports, const EvaluationContext *ev
return 1;
}
-static int modifier_apply_obdata(ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ModifierData *md)
+static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -610,13 +611,13 @@ static int modifier_apply_obdata(ReportList *reports, const EvaluationContext *e
multires_force_update(ob);
if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) {
- if (!multiresModifier_reshapeFromDeformMod(eval_ctx, scene, mmd, ob, md)) {
+ if (!multiresModifier_reshapeFromDeformMod(depsgraph, scene, mmd, ob, md)) {
BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply");
return 0;
}
}
else {
- dm = mesh_create_derived_for_modifier(eval_ctx, scene, ob, md, 1);
+ dm = mesh_create_derived_for_modifier(depsgraph, scene, ob, md, 1);
if (!dm) {
BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
return 0;
@@ -642,7 +643,7 @@ static int modifier_apply_obdata(ReportList *reports, const EvaluationContext *e
BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices");
vertexCos = BKE_curve_nurbs_vertexCos_get(&cu->nurb, &numVerts);
- mti->deformVerts(md, eval_ctx, ob, NULL, vertexCos, numVerts, 0);
+ mti->deformVerts(md, depsgraph, ob, NULL, vertexCos, numVerts, 0);
BK_curve_nurbs_vertexCos_apply(&cu->nurb, vertexCos);
MEM_freeN(vertexCos);
@@ -664,7 +665,7 @@ static int modifier_apply_obdata(ReportList *reports, const EvaluationContext *e
if (psys->part->type != PART_HAIR)
continue;
- psys_apply_hair_lattice(eval_ctx, scene, ob, psys);
+ psys_apply_hair_lattice(depsgraph, scene, ob, psys);
}
}
@@ -672,7 +673,7 @@ static int modifier_apply_obdata(ReportList *reports, const EvaluationContext *e
}
int ED_object_modifier_apply(
- ReportList *reports, const EvaluationContext *eval_ctx,
+ ReportList *reports, Depsgraph *depsgraph,
Scene *scene, Object *ob, ModifierData *md, int mode)
{
int prev_mode;
@@ -701,13 +702,13 @@ int ED_object_modifier_apply(
md->mode |= eModifierMode_Realtime;
if (mode == MODIFIER_APPLY_SHAPE) {
- if (!modifier_apply_shape(reports, eval_ctx, scene, ob, md)) {
+ if (!modifier_apply_shape(reports, depsgraph, scene, ob, md)) {
md->mode = prev_mode;
return 0;
}
}
else {
- if (!modifier_apply_obdata(reports, eval_ctx, scene, ob, md)) {
+ if (!modifier_apply_obdata(reports, depsgraph, scene, ob, md)) {
md->mode = prev_mode;
return 0;
}
@@ -1006,15 +1007,13 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
static int modifier_apply_exec(bContext *C, wmOperator *op)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int apply_as = RNA_enum_get(op->ptr, "apply_as");
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
- if (!md || !ED_object_modifier_apply(op->reports, &eval_ctx, scene, ob, md, apply_as)) {
+ if (!md || !ED_object_modifier_apply(op->reports, depsgraph, scene, ob, md, apply_as)) {
return OPERATOR_CANCELLED;
}
@@ -1239,6 +1238,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
static int multires_reshape_exec(bContext *C, wmOperator *op)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = ED_object_active_context(C), *secondob = NULL;
Scene *scene = CTX_data_scene(C);
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
@@ -1265,10 +1265,7 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
- if (!multiresModifier_reshape(&eval_ctx, scene, mmd, ob, secondob)) {
+ if (!multiresModifier_reshape(depsgraph, scene, mmd, ob, secondob)) {
BKE_report(op->reports, RPT_ERROR, "Objects do not have the same number of vertices");
return OPERATOR_CANCELLED;
}
@@ -1675,7 +1672,7 @@ static void skin_armature_bone_create(Object *skin_ob,
v = (e->v1 == parent_v ? e->v2 : e->v1);
- bone = ED_armature_edit_bone_add(arm, "Bone");
+ bone = ED_armature_ebone_add(arm, "Bone");
bone->parent = parent_bone;
bone->flag |= BONE_CONNECTED;
@@ -1701,7 +1698,7 @@ static void skin_armature_bone_create(Object *skin_ob,
}
}
-static Object *modifier_skin_armature_create(const EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *skin_ob)
+static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain, Scene *scene, Object *skin_ob)
{
BLI_bitmap *edges_visited;
DerivedMesh *deform_dm;
@@ -1714,7 +1711,7 @@ static Object *modifier_skin_armature_create(const EvaluationContext *eval_ctx,
int *emap_mem;
int v;
- deform_dm = mesh_get_derived_deform(eval_ctx, scene, skin_ob, CD_MASK_BAREMESH);
+ deform_dm = mesh_get_derived_deform(depsgraph, scene, skin_ob, CD_MASK_BAREMESH);
mvert = deform_dm->getVertArray(deform_dm);
/* add vertex weights to original mesh */
@@ -1724,7 +1721,8 @@ static Object *modifier_skin_armature_create(const EvaluationContext *eval_ctx,
NULL,
me->totvert);
- arm_ob = BKE_object_add(bmain, scene, eval_ctx->view_layer, OB_ARMATURE, NULL);
+ ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
+ arm_ob = BKE_object_add(bmain, scene, view_layer, OB_ARMATURE, NULL);
BKE_object_transform_copy(arm_ob, skin_ob);
arm = arm_ob->data;
arm->layer = 1;
@@ -1748,7 +1746,7 @@ static Object *modifier_skin_armature_create(const EvaluationContext *eval_ctx,
* a fake root bone (have it going off in the Y direction
* (arbitrary) */
if (emap[v].count > 1) {
- bone = ED_armature_edit_bone_add(arm, "Bone");
+ bone = ED_armature_ebone_add(arm, "Bone");
copy_v3_v3(bone->head, me->mvert[v].co);
copy_v3_v3(bone->tail, me->mvert[v].co);
@@ -1782,6 +1780,7 @@ static Object *modifier_skin_armature_create(const EvaluationContext *eval_ctx,
static int skin_armature_create_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C), *arm_ob;
Mesh *me = ob->data;
@@ -1793,11 +1792,8 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* create new armature */
- arm_ob = modifier_skin_armature_create(&eval_ctx, bmain, scene, ob);
+ arm_ob = modifier_skin_armature_create(depsgraph, bmain, scene, ob);
/* add a modifier to connect the new armature to the mesh */
arm_md = (ArmatureModifierData *)modifier_new(eModifierType_Armature);
@@ -1917,11 +1913,9 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform);
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (!mmd)
return OPERATOR_CANCELLED;
@@ -1955,21 +1949,21 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
int mode = mmd->modifier.mode;
/* force modifier to run, it will call binding routine */
- mmd->bindfunc = mesh_deform_bind;
+ mmd->bindfunc = ED_mesh_deform_bind_callback;
mmd->modifier.mode |= eModifierMode_Realtime;
if (ob->type == OB_MESH) {
- dm = mesh_create_derived_view(&eval_ctx, scene, ob, 0);
+ dm = mesh_create_derived_view(depsgraph, scene, ob, 0);
dm->release(dm);
}
else if (ob->type == OB_LATTICE) {
- BKE_lattice_modifiers_calc(&eval_ctx, scene, ob);
+ BKE_lattice_modifiers_calc(depsgraph, scene, ob);
}
else if (ob->type == OB_MBALL) {
- BKE_displist_make_mball(&eval_ctx, scene, ob);
+ BKE_displist_make_mball(depsgraph, scene, ob);
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
- BKE_displist_make_curveTypes(&eval_ctx, scene, ob, 0);
+ BKE_displist_make_curveTypes(depsgraph, scene, ob, 0);
}
mmd->bindfunc = NULL;
@@ -2439,11 +2433,10 @@ static int fur_generate_follicles_exec(bContext *C, wmOperator *op)
BLI_assert(fmd->hair_system != NULL);
struct Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
CustomDataMask datamask = CD_MASK_BAREMESH;
- DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, scene, ob, datamask);
+ DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, datamask);
BKE_hair_generate_follicles(
fmd->hair_system,
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index a35a54001e8..cb6bfe1d969 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -213,14 +213,6 @@ void ED_operatortypes_object(void)
WM_operatortype_append(TRANSFORM_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);
- WM_operatortype_append(OBJECT_OT_game_property_clear);
- WM_operatortype_append(OBJECT_OT_game_property_move);
- WM_operatortype_append(OBJECT_OT_logic_bricks_copy);
- WM_operatortype_append(OBJECT_OT_game_physics_copy);
-
WM_operatortype_append(OBJECT_OT_move_to_collection);
WM_operatortype_append(OBJECT_OT_shape_key_add);
@@ -250,9 +242,6 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_unlink_data);
WM_operatortype_append(OBJECT_OT_laplaciandeform_bind);
- WM_operatortype_append(OBJECT_OT_lod_add);
- WM_operatortype_append(OBJECT_OT_lod_remove);
-
WM_operatortype_append(TRANSFORM_OT_vertex_random);
WM_operatortype_append(OBJECT_OT_data_transfer);
@@ -329,9 +318,6 @@ void ED_keymap_object(wmKeyConfig *keyconf)
ED_keymap_proportional_cycle(keyconf, keymap);
ED_keymap_proportional_obmode(keyconf, keymap);
- /* game-engine only, leave free for users to define */
- WM_keymap_add_item(keymap, "VIEW3D_OT_game_start", PKEY, KM_PRESS, 0, 0);
-
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index fee39c8f0fb..453c86b5038 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -90,7 +90,6 @@
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_report.h"
-#include "BKE_sca.h"
#include "BKE_scene.h"
#include "BKE_speaker.h"
#include "BKE_texture.h"
@@ -130,9 +129,9 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *obedit = CTX_data_edit_object(C);
- EvaluationContext eval_ctx;
BMVert *eve;
BMIter iter;
Curve *cu;
@@ -142,8 +141,6 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
Object *par;
int a, v1 = 0, v2 = 0, v3 = 0, v4 = 0, nr = 1;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* we need 1 to 3 selected vertices */
if (obedit->type == OB_MESH) {
@@ -162,7 +159,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
/* derivedMesh might be needed for solving parenting,
* so re-create it here */
- makeDerivedMesh(&eval_ctx, scene, obedit, em, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX, false);
+ makeDerivedMesh(depsgraph, scene, obedit, em, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX, false);
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
@@ -258,7 +255,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
ob->par3 = v3 - 1;
/* inverse parent matrix */
- BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
+ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
else {
@@ -266,7 +263,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
ob->par1 = v1 - 1;
/* inverse parent matrix */
- BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
+ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
}
@@ -620,12 +617,10 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
int partype, const bool xmirror, const bool keep_transform, const int vert_par[3])
{
Main *bmain = CTX_data_main(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
bPoseChannel *pchan = NULL;
const bool pararm = ELEM(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO);
- CTX_data_eval_ctx(C, &eval_ctx);
-
DEG_id_tag_update(&par->id, OB_RECALC_OB);
/* preconditions */
@@ -637,7 +632,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
if ((cu->flag & CU_PATH) == 0) {
cu->flag |= CU_PATH | CU_FOLLOW;
- BKE_displist_make_curveTypes(&eval_ctx, scene, par, 0); /* force creation of path data */
+ BKE_displist_make_curveTypes(depsgraph, scene, par, 0); /* force creation of path data */
}
else {
cu->flag |= CU_FOLLOW;
@@ -779,32 +774,32 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
data = con->data;
data->tar = par;
- BKE_constraint_target_matrix_get(&eval_ctx, scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra);
+ BKE_constraint_target_matrix_get(depsgraph, scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra);
sub_v3_v3v3(vec, ob->obmat[3], cmat[3]);
copy_v3_v3(ob->loc, vec);
}
else if (pararm && (ob->type == OB_MESH) && (par->type == OB_ARMATURE)) {
if (partype == PAR_ARMATURE_NAME) {
- create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_NAME, false);
+ ED_object_vgroup_calc_from_armature(reports, depsgraph, scene, ob, par, ARM_GROUPS_NAME, false);
}
else if (partype == PAR_ARMATURE_ENVELOPE) {
- create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror);
+ ED_object_vgroup_calc_from_armature(reports, depsgraph, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror);
}
else if (partype == PAR_ARMATURE_AUTO) {
WM_cursor_wait(1);
- create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_AUTO, xmirror);
+ ED_object_vgroup_calc_from_armature(reports, depsgraph, scene, ob, par, ARM_GROUPS_AUTO, xmirror);
WM_cursor_wait(0);
}
/* get corrected inverse */
ob->partype = PAROBJECT;
- BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
+ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
else {
/* calculate inverse parent matrix */
- BKE_object_workob_calc_parent(&eval_ctx, scene, ob, &workob);
+ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
@@ -978,7 +973,7 @@ static void parent_set_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call. */
- uiDefAutoButsRNA(layout, &ptr, parent_set_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, parent_set_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
void OBJECT_OT_parent_set(wmOperatorType *ot)
@@ -1062,17 +1057,15 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot)
static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
if (ob->parent) {
if (ob->partype & PARSLOW) {
ob->partype -= PARSLOW;
- BKE_object_where_is_calc(&eval_ctx, scene, ob);
+ BKE_object_where_is_calc(depsgraph, scene, ob);
ob->partype |= PARSLOW;
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
}
@@ -1688,8 +1681,6 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
{
Group *group, *groupn;
- clear_sca_new_poins(); /* BGE logic */
-
/* duplicate all the objects of the scene */
SceneCollection *msc = BKE_collection_master(&scene->id);
single_object_users_scene_collection(bmain, scene, msc, flag, copy_groups);
@@ -1735,8 +1726,6 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
/* object and group pointers */
libblock_relink_scene_collection(msc);
-
- set_sca_new_poins();
}
/* not an especially efficient function, only added so the single user
@@ -1785,7 +1774,6 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer
Mesh *me;
Lattice *lat;
ID *id;
- int a;
FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, flag, ob)
{
@@ -1798,11 +1786,6 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer
switch (ob->type) {
case OB_LAMP:
ob->data = la = ID_NEW_SET(ob->data, BKE_lamp_copy(bmain, ob->data));
- for (a = 0; a < MAX_MTEX; a++) {
- if (la->mtex[a]) {
- ID_NEW_REMAP(la->mtex[a]->object);
- }
- }
break;
case OB_CAMERA:
ob->data = ID_NEW_SET(ob->data, BKE_camera_copy(bmain, ob->data));
@@ -1885,11 +1868,10 @@ static void single_object_action_users(Scene *scene, ViewLayer *view_layer, cons
FOREACH_OBJECT_FLAG_END;
}
-static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag, const bool do_textures)
+static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag)
{
Material *ma, *man;
- Tex *tex;
- int a, b;
+ int a;
FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, flag, ob)
{
@@ -1905,19 +1887,6 @@ static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, c
man->id.us = 0;
assign_material(ob, man, a, BKE_MAT_ASSIGN_USERPREF);
-
- if (do_textures) {
- for (b = 0; b < MAX_MTEX; b++) {
- if (ma->mtex[b] && (tex = ma->mtex[b]->tex)) {
- if (tex->id.us > 1) {
- id_us_min(&tex->id);
- tex = BKE_texture_copy(bmain, tex);
- BKE_animdata_copy_id_action(&tex->id, false);
- man->mtex[b]->tex = tex;
- }
- }
- }
- }
}
}
}
@@ -1926,66 +1895,6 @@ static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, c
FOREACH_OBJECT_FLAG_END;
}
-static void do_single_tex_user(Main *bmain, Tex **from)
-{
- Tex *tex, *texn;
-
- tex = *from;
- if (tex == NULL) return;
-
- if (tex->id.newid) {
- *from = (Tex *)tex->id.newid;
- id_us_plus(tex->id.newid);
- id_us_min(&tex->id);
- }
- else if (tex->id.us > 1) {
- texn = ID_NEW_SET(tex, BKE_texture_copy(bmain, tex));
- BKE_animdata_copy_id_action(&texn->id, false);
- tex->id.newid = (ID *)texn;
- id_us_min(&tex->id);
- *from = texn;
- }
-}
-
-static void single_tex_users_expand(Main *bmain)
-{
- /* only when 'parent' blocks are LIB_TAG_NEW */
- Material *ma;
- Lamp *la;
- World *wo;
- int b;
-
- for (ma = bmain->mat.first; ma; ma = ma->id.next) {
- if (ma->id.tag & LIB_TAG_NEW) {
- for (b = 0; b < MAX_MTEX; b++) {
- if (ma->mtex[b] && ma->mtex[b]->tex) {
- do_single_tex_user(bmain, &(ma->mtex[b]->tex));
- }
- }
- }
- }
-
- for (la = bmain->lamp.first; la; la = la->id.next) {
- if (la->id.tag & LIB_TAG_NEW) {
- for (b = 0; b < MAX_MTEX; b++) {
- if (la->mtex[b] && la->mtex[b]->tex) {
- do_single_tex_user(bmain, &(la->mtex[b]->tex));
- }
- }
- }
- }
-
- for (wo = bmain->world.first; wo; wo = wo->id.next) {
- if (wo->id.tag & LIB_TAG_NEW) {
- for (b = 0; b < MAX_MTEX; b++) {
- if (wo->mtex[b] && wo->mtex[b]->tex) {
- do_single_tex_user(bmain, &(wo->mtex[b]->tex));
- }
- }
- }
- }
-}
-
static void single_mat_users_expand(Main *bmain)
{
/* only when 'parent' blocks are LIB_TAG_NEW */
@@ -1993,8 +1902,6 @@ static void single_mat_users_expand(Main *bmain)
Mesh *me;
Curve *cu;
MetaBall *mb;
- Material *ma;
- int a;
for (ob = bmain->object.first; ob; ob = ob->id.next)
if (ob->id.tag & LIB_TAG_NEW)
@@ -2011,13 +1918,6 @@ static void single_mat_users_expand(Main *bmain)
for (mb = bmain->mball.first; mb; mb = mb->id.next)
if (mb->id.tag & LIB_TAG_NEW)
new_id_matar(bmain, mb->mat, mb->totcol);
-
- /* material imats */
- for (ma = bmain->mat.first; ma; ma = ma->id.next)
- if (ma->id.tag & LIB_TAG_NEW)
- for (a = 0; a < MAX_MTEX; a++)
- if (ma->mtex[a])
- ID_NEW_REMAP(ma->mtex[a]->object);
}
/* used for copying scenes */
@@ -2029,7 +1929,6 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo
single_obdata_users(bmain, scene, NULL, 0);
single_object_action_users(scene, NULL, 0);
single_mat_users_expand(bmain);
- single_tex_users_expand(bmain);
}
/* Relink nodetrees' pointers that have been duplicated. */
@@ -2216,12 +2115,6 @@ static void make_local_material_tag(Material *ma)
make_local_animdata_tag(BKE_animdata_from_id(&ma->id));
/* About nodetrees: root one is made local together with material, others we keep linked for now... */
-
- for (int a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a] && ma->mtex[a]->tex) {
- ma->mtex[a]->tex->id.tag &= ~LIB_TAG_PRE_EXISTING;
- }
- }
}
}
@@ -2231,7 +2124,6 @@ static int make_local_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
ParticleSystem *psys;
Material *ma, ***matarar;
- Lamp *la;
const int mode = RNA_enum_get(op->ptr, "type");
int a;
@@ -2282,16 +2174,6 @@ static int make_local_exec(bContext *C, wmOperator *op)
}
}
}
-
- if (ob->type == OB_LAMP) {
- BLI_assert(ob->data != NULL);
- la = ob->data;
- for (a = 0; a < MAX_MTEX; a++) {
- if (la->mtex[a] && la->mtex[a]->tex) {
- la->id.tag &= ~LIB_TAG_PRE_EXISTING;
- }
- }
- }
}
if (ELEM(mode, MAKE_LOCAL_SELECT_OBDATA, MAKE_LOCAL_SELECT_OBDATA_MATERIAL) && ob->data != NULL) {
@@ -2421,41 +2303,54 @@ static int make_override_static_exec(bContext *C, wmOperator *op)
Base *base = BLI_findlink(&obact->dup_group->view_layer->object_bases, RNA_enum_get(op->ptr, "object"));
Object *obgroup = obact;
obact = base->object;
+ Group *group = obgroup->dup_group;
/* First, we make a static override of the linked group itself. */
- obgroup->dup_group->id.tag |= LIB_TAG_DOIT;
-
- /* Then, we tag our 'main' object and its detected dependencies to be also overridden. */
- obact->id.tag |= LIB_TAG_DOIT;
+ group->id.tag |= LIB_TAG_DOIT;
- FOREACH_GROUP_OBJECT_BEGIN(obgroup->dup_group, ob)
+ /* Then, we make static override of the whole set of objects in the group. */
+ FOREACH_GROUP_OBJECT_BEGIN(group, ob)
{
- make_override_static_tag_object(obact, ob);
+ ob->id.tag |= LIB_TAG_DOIT;
}
FOREACH_GROUP_OBJECT_END;
success = BKE_override_static_create_from_tag(bmain);
- /* Intantiate our 'main' newly overridden object in scene, if not yet done. */
+ /* Intantiate our newly overridden objects in scene, if not yet done. */
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *new_obact = (Object *)obact->id.newid;
- if (new_obact != NULL && (base = BKE_view_layer_base_find(view_layer, new_obact)) == NULL) {
- BKE_collection_object_add_from(scene, obgroup, new_obact);
- base = BKE_view_layer_base_find(view_layer, new_obact);
- BKE_view_layer_base_select(view_layer, base);
+ Group *new_group = (Group *)group->id.newid;
+ FOREACH_GROUP_OBJECT_BEGIN(new_group, new_ob)
+ {
+ if (new_ob != NULL && (base = BKE_view_layer_base_find(view_layer, new_ob)) == NULL) {
+ BKE_collection_object_add_from(scene, obgroup, new_ob);
+ DEG_id_tag_update_ex(bmain, &new_ob->id, OB_RECALC_OB | DEG_TAG_BASE_FLAGS_UPDATE);
+ /* parent to 'group' empty */
+ if (new_ob->parent == NULL) {
+ new_ob->parent = obgroup;
+ }
+ if (new_ob == (Object *)obact->id.newid) {
+ base = BKE_view_layer_base_find(view_layer, new_ob);
+ BKE_view_layer_base_select(view_layer, base);
+ }
+ else {
+ /* Disable auto-override tags for non-active objects, will help with performaces... */
+ new_ob->id.flag &= ~LIB_OVERRIDE_STATIC_AUTO;
+ }
+ /* We still want to store all objects' current override status (i.e. change of parent). */
+ BKE_override_static_operations_create(&new_ob->id, true);
+ }
}
+ FOREACH_GROUP_OBJECT_END;
- /* Parent the group instantiating object to the new overridden one, or vice-versa, if possible. */
- if (obgroup->parent == NULL) {
- obgroup->parent = new_obact;
- }
- else if (new_obact->parent == NULL) {
- new_obact->parent = obgroup;
- }
+ /* obgroup is no more dupligroup-ing, it merely parents whole group of overriding instantiated objects. */
+ obgroup->dup_group = NULL;
/* Also, we'd likely want to lock by default things like transformations of implicitly overriden objects? */
+ DEG_id_tag_update(&scene->id, 0);
+
/* Cleanup. */
BKE_main_id_clear_newpoins(bmain);
BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, false);
@@ -2478,7 +2373,7 @@ static int make_override_static_exec(bContext *C, wmOperator *op)
BKE_main_id_clear_newpoins(bmain);
BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, false);
}
- /* TODO: probably more cases where we want ot do automated smart things in the future! */
+ /* TODO: probably more cases where we want to do automated smart things in the future! */
else {
success = (BKE_override_static_create_from_id(bmain, &obact->id) != NULL);
}
@@ -2555,13 +2450,9 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
}
if (RNA_boolean_get(op->ptr, "material")) {
- single_mat_users(bmain, scene, view_layer, flag, RNA_boolean_get(op->ptr, "texture"));
+ single_mat_users(bmain, scene, view_layer, flag);
}
-#if 0 /* can't do this separate from materials */
- if (RNA_boolean_get(op->ptr, "texture"))
- single_mat_users(scene, flag, true);
-#endif
if (RNA_boolean_get(op->ptr, "animation")) {
single_object_action_users(scene, view_layer, flag);
}
@@ -2603,8 +2494,6 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "object", 0, "Object", "Make single user objects");
RNA_def_boolean(ot->srna, "obdata", 0, "Object Data", "Make single user object data");
RNA_def_boolean(ot->srna, "material", 0, "Materials", "Make materials local to each data-block");
- RNA_def_boolean(ot->srna, "texture", 0, "Textures",
- "Make textures local to each material (needs 'Materials' to be set too)");
RNA_def_boolean(ot->srna, "animation", 0, "Object Animation", "Make animation data local to each object");
}
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index cd1300dd52e..d0d0418c861 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -37,7 +37,6 @@
#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
-#include "DNA_property_types.h"
#include "DNA_scene_types.h"
#include "DNA_armature_types.h"
#include "DNA_lamp_types.h"
@@ -59,7 +58,6 @@
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_paint.h"
-#include "BKE_property.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_workspace.h"
@@ -205,7 +203,6 @@ enum {
OBJECT_SELECT_LINKED_IPO = 1,
OBJECT_SELECT_LINKED_OBDATA,
OBJECT_SELECT_LINKED_MATERIAL,
- OBJECT_SELECT_LINKED_TEXTURE,
OBJECT_SELECT_LINKED_DUPGROUP,
OBJECT_SELECT_LINKED_PARTICLE,
OBJECT_SELECT_LINKED_LIBRARY,
@@ -216,7 +213,6 @@ static const EnumPropertyItem prop_select_linked_types[] = {
//{OBJECT_SELECT_LINKED_IPO, "IPO", 0, "Object IPO", ""}, // XXX deprecated animation system stuff...
{OBJECT_SELECT_LINKED_OBDATA, "OBDATA", 0, "Object Data", ""},
{OBJECT_SELECT_LINKED_MATERIAL, "MATERIAL", 0, "Material", ""},
- {OBJECT_SELECT_LINKED_TEXTURE, "TEXTURE", 0, "Texture", ""},
{OBJECT_SELECT_LINKED_DUPGROUP, "DUPGROUP", 0, "Dupligroup", ""},
{OBJECT_SELECT_LINKED_PARTICLE, "PARTICLE", 0, "Particle System", ""},
{OBJECT_SELECT_LINKED_LIBRARY, "LIBRARY", 0, "Library", ""},
@@ -242,7 +238,7 @@ static bool object_select_all_by_obdata(bContext *C, void *obdata)
return changed;
}
-static bool object_select_all_by_material_texture(bContext *C, int use_texture, Material *mat, Tex *tex)
+static bool object_select_all_by_material(bContext *C, Material *mat)
{
bool changed = false;
@@ -251,27 +247,14 @@ static bool object_select_all_by_material_texture(bContext *C, int use_texture,
if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) {
Object *ob = base->object;
Material *mat1;
- int a, b;
+ int a;
for (a = 1; a <= ob->totcol; a++) {
mat1 = give_current_material(ob, a);
- if (!use_texture) {
- if (mat1 == mat) {
- ED_object_base_select(base, BA_SELECT);
- changed = true;
- }
- }
- else if (mat1 && use_texture) {
- for (b = 0; b < MAX_MTEX; b++) {
- if (mat1->mtex[b]) {
- if (tex == mat1->mtex[b]->tex) {
- ED_object_base_select(base, BA_SELECT);
- changed = true;
- break;
- }
- }
- }
+ if (mat1 == mat) {
+ ED_object_base_select(base, BA_SELECT);
+ changed = true;
}
}
}
@@ -375,7 +358,7 @@ void ED_object_select_linked_by_id(bContext *C, ID *id)
changed = object_select_all_by_obdata(C, id);
}
else if (idtype == ID_MA) {
- changed = object_select_all_by_material_texture(C, false, (Material *)id, NULL);
+ changed = object_select_all_by_material(C, (Material *)id);
}
else if (idtype == ID_LI) {
changed = object_select_all_by_library(C, (Library *) id);
@@ -422,21 +405,13 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
changed = object_select_all_by_obdata(C, ob->data);
}
- else if (nr == OBJECT_SELECT_LINKED_MATERIAL || nr == OBJECT_SELECT_LINKED_TEXTURE) {
+ else if (nr == OBJECT_SELECT_LINKED_MATERIAL) {
Material *mat = NULL;
- Tex *tex = NULL;
- bool use_texture = false;
mat = give_current_material(ob, ob->actcol);
if (mat == NULL) return OPERATOR_CANCELLED;
- if (nr == OBJECT_SELECT_LINKED_TEXTURE) {
- use_texture = true;
- if (mat->mtex[(int)mat->texact]) tex = mat->mtex[(int)mat->texact]->tex;
- if (tex == NULL) return OPERATOR_CANCELLED;
- }
-
- changed = object_select_all_by_material_texture(C, use_texture, mat, tex);
+ changed = object_select_all_by_material(C, mat);
}
else if (nr == OBJECT_SELECT_LINKED_DUPGROUP) {
if (ob->dup_group == NULL)
@@ -504,9 +479,8 @@ enum {
OBJECT_GRPSEL_HOOK = 7,
OBJECT_GRPSEL_PASS = 8,
OBJECT_GRPSEL_COLOR = 9,
- OBJECT_GRPSEL_PROPERTIES = 10,
- OBJECT_GRPSEL_KEYINGSET = 11,
- OBJECT_GRPSEL_LAMP_TYPE = 12,
+ OBJECT_GRPSEL_KEYINGSET = 10,
+ OBJECT_GRPSEL_LAMP_TYPE = 11,
};
static const EnumPropertyItem prop_select_grouped_types[] = {
@@ -520,7 +494,6 @@ static const EnumPropertyItem prop_select_grouped_types[] = {
{OBJECT_GRPSEL_HOOK, "HOOK", 0, "Hook", ""},
{OBJECT_GRPSEL_PASS, "PASS", 0, "Pass", "Render pass Index"},
{OBJECT_GRPSEL_COLOR, "COLOR", 0, "Color", "Object Color"},
- {OBJECT_GRPSEL_PROPERTIES, "PROPERTIES", 0, "Properties", "Game Properties"},
{OBJECT_GRPSEL_KEYINGSET, "KEYINGSET", 0, "Keying Set", "Objects included in active Keying Set"},
{OBJECT_GRPSEL_LAMP_TYPE, "LAMP_TYPE", 0, "Lamp Type", "Matching lamp types"},
{0, NULL, 0, NULL, NULL}
@@ -773,33 +746,6 @@ static bool select_grouped_color(bContext *C, Object *ob)
return changed;
}
-static bool objects_share_gameprop(Object *a, Object *b)
-{
- bProperty *prop;
-
- for (prop = a->prop.first; prop; prop = prop->next) {
- if (BKE_bproperty_object_get(b, prop->name)) {
- return 1;
- }
- }
- return 0;
-}
-
-static bool select_grouped_gameprops(bContext *C, Object *ob)
-{
- bool changed = false;
-
- CTX_DATA_BEGIN (C, Base *, base, selectable_bases)
- {
- if (((base->flag & BASE_SELECTED) == 0) && (objects_share_gameprop(base->object, ob))) {
- ED_object_base_select(base, BA_SELECT);
- changed = true;
- }
- }
- CTX_DATA_END;
- return changed;
-}
-
static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList *reports)
{
KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C));
@@ -907,9 +853,6 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
case OBJECT_GRPSEL_COLOR:
changed |= select_grouped_color(C, ob);
break;
- case OBJECT_GRPSEL_PROPERTIES:
- changed |= select_grouped_gameprops(C, ob);
- break;
case OBJECT_GRPSEL_KEYINGSET:
changed |= select_grouped_keyingset(C, ob, op->reports);
break;
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index bb23f871a25..df8a1b8b87a 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -408,15 +408,13 @@ static void ignore_parent_tx(const bContext *C, Main *bmain, Scene *scene, Objec
{
Object workob;
Object *ob_child;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
/* a change was made, adjust the children to compensate */
for (ob_child = bmain->object.first; ob_child; ob_child = ob_child->id.next) {
if (ob_child->parent == ob) {
BKE_object_apply_mat4(ob_child, ob_child->obmat, true, false);
- BKE_object_workob_calc_parent(&eval_ctx, scene, ob_child, &workob);
+ BKE_object_workob_calc_parent(depsgraph, scene, ob_child, &workob);
invert_m4_m4(ob_child->parentinv, workob.obmat);
}
}
@@ -429,12 +427,10 @@ static int apply_objects_internal(
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale;
bool changed = true;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* first check if we can execute */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
@@ -536,7 +532,7 @@ static int apply_objects_internal(
Mesh *me = ob->data;
if (apply_scale)
- multiresModifier_scale_disp(&eval_ctx, scene, ob);
+ multiresModifier_scale_disp(depsgraph, scene, ob);
/* adjust data */
BKE_mesh_transform(me, mat, true);
@@ -545,7 +541,7 @@ static int apply_objects_internal(
BKE_mesh_calc_normals(me);
}
else if (ob->type == OB_ARMATURE) {
- ED_armature_apply_transform(ob, mat, do_props);
+ ED_armature_transform_apply(ob, mat, do_props);
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
@@ -626,9 +622,9 @@ static int apply_objects_internal(
unit_axis_angle(ob->rotAxis, &ob->rotAngle);
}
- BKE_object_where_is_calc(&eval_ctx, scene, ob);
+ BKE_object_where_is_calc(depsgraph, scene, ob);
if (ob->type == OB_ARMATURE) {
- BKE_pose_where_is(&eval_ctx, scene, ob); /* needed for bone parents */
+ BKE_pose_where_is(depsgraph, scene, ob); /* needed for bone parents */
}
ignore_parent_tx(C, bmain, scene, ob);
@@ -651,16 +647,14 @@ static int apply_objects_internal(
static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
bool changed = false;
-
- CTX_data_eval_ctx(C, &eval_ctx);
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
- BKE_object_where_is_calc(&eval_ctx, scene, ob);
+ BKE_object_where_is_calc(depsgraph, scene, ob);
BKE_object_apply_mat4(ob, ob->obmat, true, true);
- BKE_object_where_is_calc(&eval_ctx, scene, ob);
+ BKE_object_where_is_calc(depsgraph, scene, ob);
/* update for any children that may get moved */
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
@@ -744,7 +738,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
Object *obedit = CTX_data_edit_object(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *tob;
float cursor[3], cent[3], cent_neg[3], centn[3];
int centermode = RNA_enum_get(op->ptr, "type");
@@ -754,8 +748,6 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
CollectionPointerLink *ctx_ob;
CollectionPointerLink *ctx_ob_act = NULL;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* keep track of what is changed */
int tot_change = 0, tot_lib_error = 0, tot_multiuser_arm_error = 0;
@@ -871,7 +863,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
float min[3], max[3];
/* only bounds support */
INIT_MINMAX(min, max);
- BKE_object_minmax_dupli(scene, ob, min, max, true);
+ BKE_object_minmax_dupli(depsgraph, scene, ob, min, max, true);
mid_v3_v3v3(cent, min, max);
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_v3(ob->imat, cent);
@@ -988,8 +980,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
arm->id.tag |= LIB_TAG_DOIT;
/* do_inverse_offset = true; */ /* docenter_armature() handles this */
- BKE_object_where_is_calc(&eval_ctx, scene, ob);
- BKE_pose_where_is(&eval_ctx, scene, ob); /* needed for bone parents */
+ BKE_object_where_is_calc(depsgraph, scene, ob);
+ BKE_pose_where_is(depsgraph, scene, ob); /* needed for bone parents */
ignore_parent_tx(C, bmain, scene, ob);
@@ -1047,9 +1039,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
add_v3_v3(ob->loc, centn);
- BKE_object_where_is_calc(&eval_ctx, scene, ob);
+ BKE_object_where_is_calc(depsgraph, scene, ob);
if (ob->type == OB_ARMATURE) {
- BKE_pose_where_is(&eval_ctx, scene, ob); /* needed for bone parents */
+ BKE_pose_where_is(depsgraph, scene, ob); /* needed for bone parents */
}
ignore_parent_tx(C, bmain, scene, ob);
@@ -1076,9 +1068,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
mul_v3_mat3_m4v3(centn, ob_other->obmat, cent); /* omit translation part */
add_v3_v3(ob_other->loc, centn);
- BKE_object_where_is_calc(&eval_ctx, scene, ob_other);
+ BKE_object_where_is_calc(depsgraph, scene, ob_other);
if (ob_other->type == OB_ARMATURE) {
- BKE_pose_where_is(&eval_ctx, scene, ob_other); /* needed for bone parents */
+ BKE_pose_where_is(depsgraph, scene, ob_other); /* needed for bone parents */
}
ignore_parent_tx(C, bmain, scene, ob_other);
}
@@ -1292,11 +1284,7 @@ static int object_transform_axis_target_invoke(bContext *C, wmOperator *op, cons
return OPERATOR_PASS_THROUGH;
}
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
-
- ED_view3d_autodist_init(&eval_ctx, vc.depsgraph, vc.ar, vc.v3d, 0);
+ ED_view3d_autodist_init(vc.depsgraph, vc.ar, vc.v3d, 0);
if (vc.rv3d->depths != NULL) {
vc.rv3d->depths->damaged = true;
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 7026e8671ad..ff40aa07cd2 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -1273,9 +1273,9 @@ static void dm_deform_clear(DerivedMesh *dm, Object *ob)
}
/* recalculate the deformation */
-static DerivedMesh *dm_deform_recalc(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+static DerivedMesh *dm_deform_recalc(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
- return mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ return mesh_get_derived_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
}
/* by changing nonzero weights, try to move a vertex in me->mverts with index 'index' to
@@ -1288,7 +1288,7 @@ static DerivedMesh *dm_deform_recalc(EvaluationContext *eval_ctx, Scene *scene,
* coord is a point on the plane
*/
static void moveCloserToDistanceFromPlane(
- EvaluationContext *eval_ctx, Scene *scene, Object *ob, Mesh *me, int index, float norm[3],
+ Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *me, int index, float norm[3],
float coord[3], float d, float distToBe, float strength, float cp)
{
DerivedMesh *dm;
@@ -1315,7 +1315,7 @@ static void moveCloserToDistanceFromPlane(
float originalDistToBe = distToBe;
do {
wasChange = false;
- dm = dm_deform_recalc(eval_ctx, scene, ob);
+ dm = dm_deform_recalc(depsgraph, scene, ob);
dm->getVert(dm, index, &m);
copy_v3_v3(oldPos, m.co);
distToStart = dot_v3v3(norm, oldPos) + d;
@@ -1353,7 +1353,7 @@ static void moveCloserToDistanceFromPlane(
if (dw->weight > 1) {
dw->weight = 1;
}
- dm = dm_deform_recalc(eval_ctx, scene, ob);
+ dm = dm_deform_recalc(depsgraph, scene, ob);
dm->getVert(dm, index, &m);
getVerticalAndHorizontalChange(norm, d, coord, oldPos, distToStart, m.co, changes, dists, i);
dw->weight = oldw;
@@ -1465,11 +1465,9 @@ static void moveCloserToDistanceFromPlane(
* but it could be used to raise or lower an existing 'bump.' */
static void vgroup_fix(const bContext *C, Scene *scene, Object *ob, float distToBe, float strength, float cp)
{
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
int i;
- CTX_data_eval_ctx(C, &eval_ctx);
-
Mesh *me = ob->data;
MVert *mvert = me->mvert;
int *verts = NULL;
@@ -1483,7 +1481,7 @@ static void vgroup_fix(const bContext *C, Scene *scene, Object *ob, float distTo
MVert *p = MEM_callocN(sizeof(MVert) * (count), "deformedPoints");
int k;
- DerivedMesh *dm = mesh_get_derived_deform(&eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
k = count;
while (k--) {
dm->getVert(dm, verts[k], &m);
@@ -1501,7 +1499,7 @@ static void vgroup_fix(const bContext *C, Scene *scene, Object *ob, float distTo
if (mag) { /* zeros fix */
d = -dot_v3v3(norm, coord);
/* dist = (dot_v3v3(norm, m.co) + d); */ /* UNUSED */
- moveCloserToDistanceFromPlane(&eval_ctx, scene, ob, me, i, norm, coord, d, distToBe, strength, cp);
+ moveCloserToDistanceFromPlane(depsgraph, scene, ob, me, i, norm, coord, d, distToBe, strength, cp);
}
}
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 5d928d69da2..6dee6825b31 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -294,8 +294,6 @@ typedef struct DynamicPaintBakeJob {
DynamicPaintSurface *surface;
DynamicPaintCanvasSettings *canvas;
- EvaluationContext *eval_ctx;
-
int success;
double start;
} DynamicPaintBakeJob;
@@ -315,8 +313,6 @@ static void dpaint_bake_endjob(void *customdata)
dynamicPaint_freeSurfaceData(job->surface);
- MEM_freeN(job->eval_ctx);
-
G.is_rendering = false;
BKE_spacedata_draw_locks(false);
@@ -391,7 +387,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
/* calculate a frame */
scene->r.cfra = (int)frame;
ED_update_for_newframe(job->bmain, job->depsgraph);
- if (!dynamicPaint_calculateFrame(surface, job->eval_ctx, scene, cObject, frame)) {
+ if (!dynamicPaint_calculateFrame(surface, job->depsgraph, scene, cObject, frame)) {
job->success = 0;
return;
}
@@ -459,9 +455,6 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
DynamicPaintCanvasSettings *canvas;
Object *ob = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
- EvaluationContext *eval_ctx = MEM_mallocN(sizeof(*eval_ctx), "EvaluationContext");
-
- CTX_data_eval_ctx(C, eval_ctx);
DynamicPaintSurface *surface;
@@ -493,7 +486,6 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
job->ob = ob;
job->canvas = canvas;
job->surface = surface;
- job->eval_ctx = eval_ctx;
wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene,
"Dynamic Paint Bake", WM_JOB_PROGRESS,
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 51abb5b2eaa..a509a909111 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -194,7 +194,7 @@ static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *br
* note: this function runs on poll, therefor it can runs many times a second
* keep it fast! */
static PTCacheEdit *pe_get_current(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, int create)
+ Depsgraph *depsgraph, Scene *scene, Object *ob, int create)
{
ParticleEditSettings *pset= PE_settings(scene);
PTCacheEdit *edit = NULL;
@@ -233,18 +233,18 @@ static PTCacheEdit *pe_get_current(
if (psys->part && psys->part->type == PART_HAIR) {
if (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) {
if (create && !psys->pointcache->edit)
- PE_create_particle_edit(eval_ctx, scene, ob, pid->cache, NULL);
+ PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
edit = pid->cache->edit;
}
else {
if (create && !psys->edit && psys->flag & PSYS_HAIR_DONE)
- PE_create_particle_edit(eval_ctx, scene, ob, NULL, psys);
+ PE_create_particle_edit(depsgraph, scene, ob, NULL, psys);
edit = psys->edit;
}
}
else {
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
- PE_create_particle_edit(eval_ctx, scene, ob, pid->cache, psys);
+ PE_create_particle_edit(depsgraph, scene, ob, pid->cache, psys);
edit = pid->cache->edit;
}
@@ -255,7 +255,7 @@ static PTCacheEdit *pe_get_current(
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
pset->flag |= PE_FADE_TIME;
// NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB;
- PE_create_particle_edit(eval_ctx, scene, ob, pid->cache, NULL);
+ PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
}
edit = pid->cache->edit;
break;
@@ -264,7 +264,7 @@ static PTCacheEdit *pe_get_current(
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
pset->flag |= PE_FADE_TIME;
// NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB;
- PE_create_particle_edit(eval_ctx, scene, ob, pid->cache, NULL);
+ PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
}
edit = pid->cache->edit;
break;
@@ -284,15 +284,15 @@ PTCacheEdit *PE_get_current(Scene *scene, Object *ob)
return pe_get_current(NULL, scene, ob, 0);
}
-PTCacheEdit *PE_create_current(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+PTCacheEdit *PE_create_current(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
- return pe_get_current(eval_ctx, scene, ob, 1);
+ return pe_get_current(depsgraph, scene, ob, 1);
}
-void PE_current_changed(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+void PE_current_changed(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
if (ob->mode == OB_MODE_PARTICLE_EDIT) {
- PE_create_current(eval_ctx, scene, ob);
+ PE_create_current(depsgraph, scene, ob);
}
}
@@ -343,7 +343,7 @@ typedef struct PEData {
DerivedMesh *dm;
PTCacheEdit *edit;
BVHTreeFromMesh shape_bvh;
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph;
const int *mval;
rcti *rect;
@@ -376,7 +376,7 @@ static void PE_set_data(bContext *C, PEData *data)
data->scene = CTX_data_scene(C);
data->view_layer = CTX_data_view_layer(C);
data->ob = CTX_data_active_object(C);
- CTX_data_eval_ctx(C, &data->eval_ctx);
+ data->depsgraph = CTX_data_depsgraph(C);
data->edit = PE_get_current(data->scene, data->ob);
}
@@ -391,7 +391,7 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
/* needed or else the draw matrix can be incorrect */
view3d_operator_needs_opengl(C);
- ED_view3d_backbuf_validate(&data->eval_ctx, &data->vc);
+ ED_view3d_backbuf_validate(&data->vc);
/* we may need to force an update here by setting the rv3d as dirty
* for now it seems ok, but take care!:
* rv3d->depths->dirty = 1; */
@@ -1136,7 +1136,7 @@ void recalc_emitter_field(Object *ob, ParticleSystem *psys)
BLI_kdtree_balance(edit->emitter_field);
}
-static void PE_update_selection(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, int useflag)
+static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob, int useflag)
{
PTCacheEdit *edit = PE_get_current(scene, ob);
HairKey *hkey;
@@ -1157,7 +1157,7 @@ static void PE_update_selection(const EvaluationContext *eval_ctx, Scene *scene,
}
}
- psys_cache_edit_paths(eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
+ psys_cache_edit_paths(depsgraph, scene, ob, edit, CFRA, G.is_rendering);
/* disable update flag */
@@ -1243,7 +1243,7 @@ static void update_velocities(PTCacheEdit *edit)
}
}
-void PE_update_object(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, int useflag)
+void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int useflag)
{
/* use this to do partial particle updates, not usable when adding or
* removing, then a full redo is necessary and calling this may crash */
@@ -1273,7 +1273,7 @@ void PE_update_object(const EvaluationContext *eval_ctx, Scene *scene, Object *o
PE_hide_keys_time(scene, edit, CFRA);
/* regenerate path caches */
- psys_cache_edit_paths(eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
+ psys_cache_edit_paths(depsgraph, scene, ob, edit, CFRA, G.is_rendering);
/* disable update flag */
LOOP_POINTS {
@@ -1357,36 +1357,35 @@ static void toggle_key_select(PEData *data, int point_index, int key_index)
static void select_action_apply(PTCacheEditPoint *point, PTCacheEditKey *key, int action)
{
switch (action) {
- case SEL_SELECT:
- if ((key->flag & PEK_SELECT) == 0) {
- key->flag |= PEK_SELECT;
- point->flag |= PEP_EDIT_RECALC;
- }
- break;
- case SEL_DESELECT:
- if (key->flag & PEK_SELECT) {
- key->flag &= ~PEK_SELECT;
- point->flag |= PEP_EDIT_RECALC;
- }
- break;
- case SEL_INVERT:
- if ((key->flag & PEK_SELECT) == 0) {
- key->flag |= PEK_SELECT;
- point->flag |= PEP_EDIT_RECALC;
- }
- else {
- key->flag &= ~PEK_SELECT;
- point->flag |= PEP_EDIT_RECALC;
- }
- break;
+ case SEL_SELECT:
+ if ((key->flag & PEK_SELECT) == 0) {
+ key->flag |= PEK_SELECT;
+ point->flag |= PEP_EDIT_RECALC;
+ }
+ break;
+ case SEL_DESELECT:
+ if (key->flag & PEK_SELECT) {
+ key->flag &= ~PEK_SELECT;
+ point->flag |= PEP_EDIT_RECALC;
+ }
+ break;
+ case SEL_INVERT:
+ if ((key->flag & PEK_SELECT) == 0) {
+ key->flag |= PEK_SELECT;
+ point->flag |= PEP_EDIT_RECALC;
+ }
+ else {
+ key->flag &= ~PEK_SELECT;
+ point->flag |= PEP_EDIT_RECALC;
+ }
+ break;
}
}
static int pe_select_all_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob= CTX_data_active_object(C);
PTCacheEdit *edit= PE_get_current(scene, ob);
POINT_P; KEY_K;
@@ -1411,7 +1410,7 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(&eval_ctx, scene, ob, 1);
+ PE_update_selection(depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1468,7 +1467,7 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec
else
for_mouse_hit_keys(&data, toggle_key_select, 1);
- PE_update_selection(&data.eval_ctx, scene, ob, 1);
+ PE_update_selection(data.depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1509,7 +1508,7 @@ static int select_roots_exec(bContext *C, wmOperator *op)
data.select_action = action;
foreach_point(&data, select_root);
- PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1574,7 +1573,7 @@ static int select_tips_exec(bContext *C, wmOperator *op)
data.select_action = action;
foreach_point(&data, select_tip);
- PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1658,7 +1657,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
BLI_rng_free(rng);
- PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1702,7 +1701,7 @@ static int select_linked_exec(bContext *C, wmOperator *op)
data.select= !RNA_boolean_get(op->ptr, "deselect");
for_mouse_hit_keys(&data, select_keys, 1); /* nearest only */
- PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -1766,7 +1765,7 @@ int PE_border_select(bContext *C, rcti *rect, bool select, bool extend)
for_mouse_hit_keys(&data, select_key, 0);
- PE_update_selection(&data.eval_ctx, scene, ob, 1);
+ PE_update_selection(data.depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1791,7 +1790,7 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad)
for_mouse_hit_keys(&data, select_key, 0);
- PE_update_selection(&data.eval_ctx, scene, ob, 1);
+ PE_update_selection(data.depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1879,7 +1878,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool
}
}
- PE_update_selection(&data.eval_ctx, scene, ob, 1);
+ PE_update_selection(data.depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1891,8 +1890,7 @@ static int hide_exec(bContext *C, wmOperator *op)
{
Object *ob= CTX_data_active_object(C);
Scene *scene= CTX_data_scene(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
PTCacheEdit *edit= PE_get_current(scene, ob);
POINT_P; KEY_K;
@@ -1917,7 +1915,7 @@ static int hide_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(&eval_ctx, scene, ob, 1);
+ PE_update_selection(depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -1947,8 +1945,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
{
Object *ob= CTX_data_active_object(C);
Scene *scene= CTX_data_scene(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
PTCacheEdit *edit= PE_get_current(scene, ob);
const bool select = RNA_boolean_get(op->ptr, "select");
POINT_P; KEY_K;
@@ -1964,7 +1961,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
}
}
- PE_update_selection(&eval_ctx, scene, ob, 1);
+ PE_update_selection(depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, ob);
return OPERATOR_FINISHED;
@@ -2026,7 +2023,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
PE_set_data(C, &data);
foreach_point(&data, select_less_keys);
- PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -2088,7 +2085,7 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
PE_set_data(C, &data);
foreach_point(&data, select_more_keys);
- PE_update_selection(&data.eval_ctx, data.scene, data.ob, 1);
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob);
return OPERATOR_FINISHED;
@@ -2121,12 +2118,10 @@ static void rekey_particle(PEData *data, int pa_index)
ParticleKey state;
HairKey *key, *new_keys, *okey;
PTCacheEditKey *ekey;
- EvaluationContext eval_ctx;
float dval, sta, end;
int k;
- CTX_data_eval_ctx(data->context, &eval_ctx);
- sim.eval_ctx = &eval_ctx;
+ sim.depsgraph = data->depsgraph;
sim.scene = data->scene;
sim.ob = data->ob;
sim.psys = edit->psys;
@@ -2180,9 +2175,6 @@ static int rekey_exec(bContext *C, wmOperator *op)
{
PEData data;
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
PE_set_data(C, &data);
data.dval= 1.0f / (float)(data.totrekey-1);
@@ -2191,7 +2183,7 @@ static int rekey_exec(bContext *C, wmOperator *op)
foreach_selected_point(&data, rekey_particle);
recalc_lengths(data.edit);
- PE_update_object(&eval_ctx, data.scene, data.ob, 1);
+ PE_update_object(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
return OPERATOR_FINISHED;
@@ -2225,16 +2217,13 @@ static void rekey_particle_to_time(const bContext *C, Scene *scene, Object *ob,
ParticleKey state;
HairKey *new_keys, *key;
PTCacheEditKey *ekey;
- EvaluationContext eval_ctx;
int k;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (!edit || !edit->psys) return;
psys = edit->psys;
- sim.eval_ctx = &eval_ctx;
+ sim.depsgraph = CTX_data_depsgraph(C);
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -2447,14 +2436,12 @@ static void subdivide_particle(PEData *data, int pa_index)
ParticleKey state;
HairKey *key, *nkey, *new_keys;
PTCacheEditKey *ekey, *nekey, *new_ekeys;
- EvaluationContext eval_ctx;
int k;
short totnewkey=0;
float endtime;
- CTX_data_eval_ctx(data->context, &eval_ctx);
- sim.eval_ctx = &eval_ctx;
+ sim.depsgraph = data->depsgraph;
sim.scene = data->scene;
sim.ob = data->ob;
sim.psys = edit->psys;
@@ -2525,14 +2512,11 @@ static int subdivide_exec(bContext *C, wmOperator *UNUSED(op))
{
PEData data;
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
PE_set_data(C, &data);
foreach_point(&data, subdivide_particle);
recalc_lengths(data.edit);
- PE_update_object(&eval_ctx, data.scene, data.ob, 1);
+ PE_update_object(data.depsgraph, data.scene, data.ob, 1);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
return OPERATOR_FINISHED;
@@ -3356,21 +3340,19 @@ static int particle_intersect_dm(const bContext *C, Scene *scene, Object *ob, De
float *face_minmax, float *pa_minmax,
float radius, float *ipoint)
{
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
MFace *mface= NULL;
MVert *mvert= NULL;
int i, totface, intersect=0;
float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3], p_max[3];
float cur_ipoint[3];
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (dm == NULL) {
psys_disable_all(ob);
- dm = mesh_get_derived_final(&eval_ctx, scene, ob, 0);
+ dm = mesh_get_derived_final(depsgraph, scene, ob, 0);
if (dm == NULL)
- dm = mesh_get_derived_deform(&eval_ctx, scene, ob, 0);
+ dm = mesh_get_derived_deform(depsgraph, scene, ob, 0);
psys_enable_all(ob);
@@ -3485,8 +3467,7 @@ static int particle_intersect_dm(const bContext *C, Scene *scene, Object *ob, De
static int brush_add(const bContext *C, PEData *data, short number)
{
- EvaluationContext eval_ctx;
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene= data->scene;
Object *ob= data->ob;
DerivedMesh *dm;
@@ -3514,9 +3495,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
rng = BLI_rng_new_srandom(psys->seed+data->mval[0]+data->mval[1]);
- CTX_data_eval_ctx(C, &eval_ctx);
-
- sim.eval_ctx = &eval_ctx;
+ sim.depsgraph = depsgraph;
sim.scene= scene;
sim.ob= ob;
sim.psys= psys;
@@ -3608,7 +3587,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
tree=BLI_kdtree_new(psys->totpart);
for (i=0, pa=psys->particles; i<totpart; i++, pa++) {
- psys_particle_on_dm(psmd->dm_final, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, cur_co, 0, 0, 0, 0, 0);
+ psys_particle_on_dm(psmd->dm_final, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, cur_co, 0, 0, 0, 0);
BLI_kdtree_insert(tree, i, cur_co);
}
@@ -3652,7 +3631,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
int w, maxw;
float maxd, totw=0.0, weight[3];
- psys_particle_on_dm(psmd->dm_final, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co1, 0, 0, 0, 0, 0);
+ psys_particle_on_dm(psmd->dm_final, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co1, 0, 0, 0, 0);
maxw = BLI_kdtree_find_nearest_n(tree, co1, ptn, 3);
maxd= ptn[maxw-1].dist;
@@ -3805,8 +3784,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
if (!PE_start_edit(edit))
return;
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
RNA_float_get_array(itemptr, "mouse", mousef);
mouse[0] = mousef[0];
@@ -3991,7 +3969,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
else {
- PE_update_object(&eval_ctx, scene, ob, 1);
+ PE_update_object(depsgraph, scene, ob, 1);
}
}
@@ -4254,7 +4232,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
else {
- PE_update_object(&data.eval_ctx, scene, ob, 1);
+ PE_update_object(data.depsgraph, scene, ob, 1);
}
if (edit->psys) {
@@ -4331,7 +4309,7 @@ int PE_minmax(Scene *scene, ViewLayer *view_layer, float min[3], float max[3])
/* initialize needed data for bake edit */
void PE_create_particle_edit(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys)
+ Depsgraph *depsgraph, Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys)
{
PTCacheEdit *edit;
ParticleSystemModifierData *psmd = (psys) ? psys_get_modifier(ob, psys) : NULL;
@@ -4433,7 +4411,7 @@ void PE_create_particle_edit(
if (psys && !cache)
recalc_emitter_field(ob, psys);
- PE_update_object(eval_ctx, scene, ob, 1);
+ PE_update_object(depsgraph, scene, ob, 1);
}
}
@@ -4455,6 +4433,7 @@ static int particle_edit_toggle_poll(bContext *C)
static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_PARTICLE_EDIT;
@@ -4468,11 +4447,9 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
if (!is_mode_set) {
PTCacheEdit *edit;
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
ob->mode |= mode_flag;
- edit= PE_create_current(&eval_ctx, scene, ob);
+ edit= PE_create_current(depsgraph, scene, ob);
/* mesh may have changed since last entering editmode.
* note, this may have run before if the edit data was just created, so could avoid this and speed up a little */
@@ -4642,8 +4619,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
float average_length = calculate_average_length(edit);
@@ -4654,7 +4630,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op))
scale_points_to_length(edit, average_length);
- PE_update_object(&eval_ctx, scene, ob, 1);
+ PE_update_object(depsgraph, scene, ob, 1);
if (edit->psys) {
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
}
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 1fae5b70aff..23a6ba68fc9 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -546,7 +546,7 @@ void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot)
/************************ connect/disconnect hair operators *********************/
static void disconnect_hair(
- const EvaluationContext *eval_ctx, Scene *scene,
+ Depsgraph *depsgraph, Scene *scene,
Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
@@ -593,30 +593,28 @@ static void disconnect_hair(
if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_PUFF))
pset->brushtype = PE_BRUSH_NONE;
- PE_update_object(eval_ctx, scene, ob, 0);
+ PE_update_object(depsgraph, scene, ob, 0);
}
static int disconnect_hair_exec(bContext *C, wmOperator *op)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_context(C);
ParticleSystem *psys= NULL;
const bool all = RNA_boolean_get(op->ptr, "all");
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (!ob)
return OPERATOR_CANCELLED;
if (all) {
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
- disconnect_hair(&eval_ctx, scene, ob, psys);
+ disconnect_hair(depsgraph, scene, ob, psys);
}
}
else {
psys = psys_get_current(ob);
- disconnect_hair(&eval_ctx, scene, ob, psys);
+ disconnect_hair(depsgraph, scene, ob, psys);
}
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -643,7 +641,7 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
* from/to_mat : additional transform for from/to particles (e.g. for using object space copying)
*/
static bool remap_hair_emitter(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys,
Object *target_ob, ParticleSystem *target_psys, PTCacheEdit *target_edit,
float from_mat[4][4], float to_mat[4][4], bool from_global, bool to_global)
{
@@ -714,8 +712,8 @@ static bool remap_hair_emitter(
for (i = 0, tpa = target_psys->particles, pa = psys->particles;
i < target_psys->totpart;
- i++, tpa++, pa++) {
-
+ i++, tpa++, pa++)
+ {
float from_co[3];
BVHTreeNearest nearest;
@@ -829,13 +827,13 @@ static bool remap_hair_emitter(
psys_free_path_cache(target_psys, target_edit);
- PE_update_object(eval_ctx, scene, target_ob, 0);
+ PE_update_object(depsgraph, scene, target_ob, 0);
return true;
}
static bool connect_hair(
- const EvaluationContext *eval_ctx, Scene *scene,
+ Depsgraph *depsgraph, Scene *scene,
Object *ob, ParticleSystem *psys)
{
bool ok;
@@ -844,7 +842,7 @@ static bool connect_hair(
return false;
ok = remap_hair_emitter(
- eval_ctx, scene, ob, psys, ob, psys, psys->edit,
+ depsgraph, scene, ob, psys, ob, psys, psys->edit,
ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false);
psys->flag &= ~PSYS_GLOBAL_HAIR;
@@ -853,7 +851,7 @@ static bool connect_hair(
static int connect_hair_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_context(C);
ParticleSystem *psys= NULL;
@@ -863,16 +861,14 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
if (!ob)
return OPERATOR_CANCELLED;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (all) {
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
- any_connected |= connect_hair(&eval_ctx, scene, ob, psys);
+ any_connected |= connect_hair(depsgraph, scene, ob, psys);
}
}
else {
psys = psys_get_current(ob);
- any_connected |= connect_hair(&eval_ctx, scene, ob, psys);
+ any_connected |= connect_hair(depsgraph, scene, ob, psys);
}
if (!any_connected) {
@@ -909,7 +905,7 @@ typedef enum eCopyParticlesSpace {
} eCopyParticlesSpace;
static void copy_particle_edit(
- const EvaluationContext *eval_ctx, Scene *scene,
+ Depsgraph *depsgraph, Scene *scene,
Object *ob, ParticleSystem *psys, ParticleSystem *psys_from)
{
PTCacheEdit *edit_from = psys_from->edit, *edit;
@@ -957,7 +953,7 @@ static void copy_particle_edit(
recalc_lengths(edit);
recalc_emitter_field(ob, psys);
- PE_update_object(eval_ctx, scene, ob, true);
+ PE_update_object(depsgraph, scene, ob, true);
}
static void remove_particle_systems_from_object(Object *ob_to)
@@ -994,15 +990,13 @@ static bool copy_particle_systems_to_object(const bContext *C,
bool duplicate_settings)
{
Main *bmain = CTX_data_main(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ModifierData *md;
ParticleSystem *psys_start = NULL, *psys, *psys_from;
ParticleSystem **tmp_psys;
DerivedMesh *final_dm;
CustomDataMask cdmask;
int i, totpsys;
-
- CTX_data_eval_ctx(C, &eval_ctx);
if (ob_to->type != OB_MESH)
return false;
@@ -1026,8 +1020,8 @@ static bool copy_particle_systems_to_object(const bContext *C,
cdmask = 0;
for (psys_from = PSYS_FROM_FIRST, i = 0;
psys_from;
- psys_from = PSYS_FROM_NEXT(psys_from), ++i) {
-
+ psys_from = PSYS_FROM_NEXT(psys_from), ++i)
+ {
psys = BKE_object_copy_particlesystem(psys_from, 0);
tmp_psys[i] = psys;
@@ -1042,13 +1036,13 @@ static bool copy_particle_systems_to_object(const bContext *C,
psys_start = totpsys > 0 ? tmp_psys[0] : NULL;
/* get the DM (psys and their modifiers have not been appended yet) */
- final_dm = mesh_get_derived_final(&eval_ctx, scene, ob_to, cdmask);
+ final_dm = mesh_get_derived_final(depsgraph, scene, ob_to, cdmask);
/* now append psys to the object and make modifiers */
for (i = 0, psys_from = PSYS_FROM_FIRST;
i < totpsys;
- ++i, psys_from = PSYS_FROM_NEXT(psys_from)) {
-
+ ++i, psys_from = PSYS_FROM_NEXT(psys_from))
+ {
ParticleSystemModifierData *psmd;
psys = tmp_psys[i];
@@ -1071,7 +1065,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
DM_ensure_tessface(psmd->dm_final);
if (psys_from->edit) {
- copy_particle_edit(&eval_ctx, scene, ob_to, psys, psys_from);
+ copy_particle_edit(depsgraph, scene, ob_to, psys, psys_from);
}
if (duplicate_settings) {
@@ -1086,8 +1080,8 @@ static bool copy_particle_systems_to_object(const bContext *C,
*/
for (psys = psys_start, psys_from = PSYS_FROM_FIRST, i = 0;
psys;
- psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), ++i) {
-
+ psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), ++i)
+ {
float (*from_mat)[4], (*to_mat)[4];
switch (space) {
@@ -1107,7 +1101,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
}
if (ob_from != ob_to) {
remap_hair_emitter(
- &eval_ctx, scene, ob_from, psys_from, ob_to, psys, psys->edit,
+ depsgraph, scene, ob_from, psys_from, ob_to, psys, psys->edit,
from_mat, to_mat, psys_from->flag & PSYS_GLOBAL_HAIR, psys->flag & PSYS_GLOBAL_HAIR);
}
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index c0b2ae8ded4..541242fdc09 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -246,7 +246,7 @@ static void set_channel(float *channel, float time, float *value, int i, int siz
}
}
-static void set_vertex_channel(EvaluationContext *eval_ctx, float *channel, float time, struct Scene *scene, struct FluidObject *fobj, int i)
+static void set_vertex_channel(Depsgraph *depsgraph, float *channel, float time, struct Scene *scene, struct FluidObject *fobj, int i)
{
Object *ob = fobj->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
@@ -259,7 +259,7 @@ static void set_vertex_channel(EvaluationContext *eval_ctx, float *channel, floa
if (channel == NULL)
return;
- initElbeemMesh(eval_ctx, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
+ initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
/* don't allow mesh to change number of verts in anim sequence */
if (numVerts != fobj->numVerts) {
@@ -333,14 +333,11 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
- EvaluationContext eval_ctx;
Base *base;
int i;
int length = channels->length;
float eval_time;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* init time values (assuming that time moves at a constant speed; may be overridden later) */
init_time(domainSettings, channels);
@@ -380,7 +377,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
float *verts=NULL;
int *tris=NULL, modifierIndex = BLI_findindex(&ob->modifiers, (ModifierData *)fluidmd);
- initElbeemMesh(&eval_ctx, scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex);
+ initElbeemMesh(depsgraph, scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex);
fobj->VertexCache = MEM_callocN(length *((fobj->numVerts*CHANNEL_VEC)+1) * sizeof(float), "fluidobject VertexCache");
MEM_freeN(verts);
@@ -468,7 +465,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
}
if (fluid_is_animated_mesh(fluidmd->fss)) {
- set_vertex_channel(&eval_ctx, fobj->VertexCache, timeAtFrame, scene, fobj, i);
+ set_vertex_channel(depsgraph, fobj->VertexCache, timeAtFrame, scene, fobj, i);
}
}
}
@@ -476,10 +473,8 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *scene, int length)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
FluidObject *fobj;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
Object *ob = fobj->object;
@@ -501,7 +496,7 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
fsmesh.type = fluidmd->fss->type;
fsmesh.name = ob->id.name;
- initElbeemMesh(&eval_ctx, scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex);
+ initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex);
fsmesh.numVertices = numVerts;
fsmesh.numTriangles = numTris;
diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h
index 246bf79360f..72da417da63 100644
--- a/source/blender/editors/physics/physics_intern.h
+++ b/source/blender/editors/physics/physics_intern.h
@@ -33,7 +33,7 @@
#ifndef __PHYSICS_INTERN_H__
#define __PHYSICS_INTERN_H__
-struct EvaluationContext;
+struct Depsgraph;
struct Object;
struct PTCacheEdit;
struct ParticleSystem;
@@ -71,7 +71,7 @@ void PARTICLE_OT_edited_clear(struct wmOperatorType *ot);
void PARTICLE_OT_unify_length(struct wmOperatorType *ot);
void PE_create_particle_edit(
- const struct EvaluationContext *eval_ctx, struct Scene *scene,
+ struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, struct PointCache *cache, struct ParticleSystem *psys);
void recalc_lengths(struct PTCacheEdit *edit);
void recalc_emitter_field(struct Object *ob, struct ParticleSystem *psys);
diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h
index 2bc96a7f218..a1f646aefc1 100644
--- a/source/blender/editors/render/render_intern.h
+++ b/source/blender/editors/render/render_intern.h
@@ -83,15 +83,10 @@ void SCENE_OT_freestyle_stroke_material_create(struct wmOperatorType *ot);
void TEXTURE_OT_slot_copy(struct wmOperatorType *ot);
void TEXTURE_OT_slot_paste(struct wmOperatorType *ot);
void TEXTURE_OT_slot_move(struct wmOperatorType *ot);
-void TEXTURE_OT_envmap_save(struct wmOperatorType *ot);
-void TEXTURE_OT_envmap_clear(struct wmOperatorType *ot);
-void TEXTURE_OT_envmap_clear_all(struct wmOperatorType *ot);
/* render_internal.c */
void RENDER_OT_render(struct wmOperatorType *ot);
void RENDER_OT_shutter_curve_preset(struct wmOperatorType *ot);
-void render_view3d_update(struct RenderEngine *engine, const struct bContext *C);
-void render_view3d_draw(struct RenderEngine *engine, const struct bContext *C);
/* render_view.c */
struct ScrArea *render_view_open(struct bContext *C, int mx, int my, struct ReportList *reports);
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 51a75e36044..89dbd3da16d 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -298,7 +298,7 @@ static void screen_render_view_layer_set(wmOperator *op, Main *mainp, Scene **sc
static int screen_render_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- RenderEngineType *re_type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *re_type = RE_engines_find(scene->r.engine);
ViewLayer *view_layer = NULL;
Render *re;
Image *ima;
@@ -863,7 +863,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
Main *mainp;
ViewLayer *view_layer = NULL;
Scene *scene = CTX_data_scene(C);
- RenderEngineType *re_type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *re_type = RE_engines_find(scene->r.engine);
Render *re;
wmJob *wm_job;
RenderJob *rj;
@@ -1078,627 +1078,6 @@ void RENDER_OT_render(wmOperatorType *ot)
}
-/* ************** preview for 3d viewport ***************** */
-
-#define PR_UPDATE_VIEW 1
-#define PR_UPDATE_RENDERSIZE 2
-#define PR_UPDATE_MATERIAL 4
-#define PR_UPDATE_DATABASE 8
-
-typedef struct RenderPreview {
- /* from wmJob */
- void *owner;
- short *stop, *do_update;
- wmJob *job;
-
- Scene *scene;
- EvaluationContext *eval_ctx;
- Depsgraph *depsgraph;
- ScrArea *sa;
- ARegion *ar;
- View3D *v3d;
- RegionView3D *rv3d;
- Main *bmain;
- RenderEngine *engine;
-
- float viewmat[4][4];
-
- int start_resolution_divider;
- int resolution_divider;
- bool has_freestyle;
-} RenderPreview;
-
-static int render_view3d_disprect(Scene *scene, const Depsgraph *depsgraph,
- ARegion *ar, View3D *v3d, RegionView3D *rv3d, rcti *disprect)
-{
- /* copied code from view3d_draw.c */
- rctf viewborder;
- int draw_border;
-
- if (rv3d->persp == RV3D_CAMOB)
- draw_border = (scene->r.mode & R_BORDER) != 0;
- else
- draw_border = (v3d->flag2 & V3D_RENDER_BORDER) != 0;
-
- if (draw_border) {
- if (rv3d->persp == RV3D_CAMOB) {
- ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false);
-
- disprect->xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder);
- disprect->ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder);
- disprect->xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder);
- disprect->ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder);
- }
- else {
- disprect->xmin = v3d->render_border.xmin * ar->winx;
- disprect->xmax = v3d->render_border.xmax * ar->winx;
- disprect->ymin = v3d->render_border.ymin * ar->winy;
- disprect->ymax = v3d->render_border.ymax * ar->winy;
- }
-
- return 1;
- }
-
- BLI_rcti_init(disprect, 0, 0, 0, 0);
- return 0;
-}
-
-/* returns true if OK */
-static bool render_view3d_get_rects(
- const Depsgraph *depsgraph,
- ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewplane, RenderEngine *engine,
- float *r_clipsta, float *r_clipend, float *r_pixsize, bool *r_ortho)
-{
-
- if (ar->winx < 4 || ar->winy < 4) return false;
-
- *r_ortho = ED_view3d_viewplane_get(depsgraph, v3d, rv3d, ar->winx, ar->winy, viewplane, r_clipsta, r_clipend, r_pixsize);
-
- engine->resolution_x = ar->winx;
- engine->resolution_y = ar->winy;
-
- return true;
-}
-
-static bool render_view3d_is_valid(RenderPreview *rp)
-{
- return (rp->rv3d->render_engine != NULL);
-}
-
-/* called by renderer, checks job value */
-static int render_view3d_break(void *rpv)
-{
- RenderPreview *rp = rpv;
-
- if (G.is_break)
- return 1;
-
- /* during render, rv3d->engine can get freed */
- if (render_view3d_is_valid(rp) == false) {
- *rp->stop = 1;
- }
-
- return *(rp->stop);
-}
-
-static void render_view3d_display_update(void *rpv, RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect))
-{
- RenderPreview *rp = rpv;
-
- *(rp->do_update) = true;
-}
-
-static void render_view3d_renderinfo_cb(void *rjp, RenderStats *rs)
-{
- RenderPreview *rp = rjp;
-
- /* during render, rv3d->engine can get freed */
- if (rp->rv3d->render_engine == NULL) {
- *rp->stop = 1;
- }
- else {
- make_renderinfo_string(rs, rp->scene, false, NULL, rp->engine->text);
-
- /* make jobs timer to send notifier */
- *(rp->do_update) = true;
- }
-}
-
-BLI_INLINE void rcti_scale_coords(rcti *scaled_rect, const rcti *rect,
- const float scale)
-{
- scaled_rect->xmin = rect->xmin * scale;
- scaled_rect->ymin = rect->ymin * scale;
- scaled_rect->xmax = rect->xmax * scale;
- scaled_rect->ymax = rect->ymax * scale;
-}
-
-static void render_update_resolution(Render *re, const RenderPreview *rp,
- bool use_border, const rcti *clip_rect)
-{
- int winx = rp->ar->winx / rp->resolution_divider;
- int winy = rp->ar->winy / rp->resolution_divider;
- if (use_border) {
- rcti scaled_cliprct;
- rcti_scale_coords(&scaled_cliprct, clip_rect,
- 1.0f / rp->resolution_divider);
- RE_ChangeResolution(re, winx, winy, &scaled_cliprct);
- }
- else {
- RE_ChangeResolution(re, winx, winy, NULL);
- }
-
- if (rp->has_freestyle) {
- if (rp->resolution_divider == BKE_render_preview_pixel_size(&rp->scene->r)) {
- RE_ChangeModeFlag(re, R_EDGE_FRS, false);
- }
- else {
- RE_ChangeModeFlag(re, R_EDGE_FRS, true);
- }
- }
-}
-
-static void render_view3d_startjob(void *customdata, short *stop, short *do_update, float *UNUSED(progress))
-{
- RenderPreview *rp = customdata;
- Render *re;
- RenderStats *rstats;
- rctf viewplane;
- rcti cliprct;
- float clipsta, clipend, pixsize;
- bool orth, restore = 0;
- char name[32];
- int update_flag;
- bool use_border;
- int ob_inst_update_flag = 0;
-
- update_flag = rp->engine->job_update_flag;
- rp->engine->job_update_flag = 0;
-
- //printf("ma %d res %d view %d db %d\n", update_flag & PR_UPDATE_MATERIAL, update_flag & PR_UPDATE_RENDERSIZE, update_flag & PR_UPDATE_VIEW, update_flag & PR_UPDATE_DATABASE);
-
- G.is_break = false;
-
- if (false == render_view3d_get_rects(rp->depsgraph, rp->ar, rp->v3d, rp->rv3d, &viewplane, rp->engine, &clipsta, &clipend, &pixsize, &orth))
- return;
-
- rp->stop = stop;
- rp->do_update = do_update;
-
- // printf("Enter previewrender\n");
-
- /* ok, are we rendering all over? */
- sprintf(name, "View3dPreview %p", (void *)rp->ar);
- re = rp->engine->re = RE_GetRender(name);
-
- /* set this always, rp is different for each job */
- RE_test_break_cb(re, rp, render_view3d_break);
- RE_display_update_cb(re, rp, render_view3d_display_update);
- RE_stats_draw_cb(re, rp, render_view3d_renderinfo_cb);
-
- rstats = RE_GetStats(re);
-
- if (update_flag & PR_UPDATE_VIEW) {
- Object *object;
- rp->resolution_divider = rp->start_resolution_divider;
-
- /* Same as database_init_objects(), loop over all objects.
- * We might consider de-duplicating the code between this two cases.
- */
- for (object = rp->bmain->object.first; object; object = object->id.next) {
- float mat[4][4];
- mul_m4_m4m4(mat, rp->viewmat, object->obmat);
- invert_m4_m4(object->imat_ren, mat);
- }
- }
-
- use_border = render_view3d_disprect(rp->scene, rp->depsgraph,
- rp->ar, rp->v3d, rp->rv3d,
- &cliprct);
-
- if ((update_flag & (PR_UPDATE_RENDERSIZE | PR_UPDATE_DATABASE | PR_UPDATE_VIEW)) || rstats->convertdone == 0) {
- RenderData rdata;
-
- /* no osa, blur, seq, layers, savebuffer etc for preview render */
- rdata = rp->scene->r;
- rdata.mode &= ~(R_OSA | R_MBLUR | R_BORDER | R_PANORAMA);
- rdata.scemode &= ~(R_DOSEQ | R_DOCOMP | R_FREE_IMAGE | R_EXR_TILE_FILE | R_FULL_SAMPLE);
- rdata.scemode |= R_VIEWPORT_PREVIEW;
-
- /* we do use layers, but only active */
- rdata.scemode |= R_SINGLE_LAYER;
-
- /* initalize always */
- if (use_border) {
- rdata.mode |= R_BORDER;
- RE_InitState(re, NULL, &rdata, &rp->scene->view_layers, rp->scene->active_view_layer, &rp->scene->view_render, NULL, rp->ar->winx, rp->ar->winy, &cliprct);
- }
- else
- RE_InitState(re, NULL, &rdata, &rp->scene->view_layers, rp->scene->active_view_layer, &rp->scene->view_render, NULL, rp->ar->winx, rp->ar->winy, NULL);
- }
-
- if (orth)
- RE_SetOrtho(re, &viewplane, clipsta, clipend);
- else
- RE_SetWindow(re, &viewplane, clipsta, clipend);
-
- RE_SetPixelSize(re, pixsize);
-
- if ((update_flag & PR_UPDATE_DATABASE) || rstats->convertdone == 0) {
- unsigned int lay = rp->scene->lay;
-
- /* allow localview render for objects with lights in normal layers */
- if (rp->v3d->lay & 0xFF000000)
- lay |= rp->v3d->lay;
- else lay = rp->v3d->lay;
-
- RE_SetView(re, rp->viewmat);
-
- /* copying blender data while main thread is locked, to avoid crashes */
- WM_job_main_thread_lock_acquire(rp->job);
- RE_Database_Free(re);
- RE_Database_FromScene(re, rp->bmain, rp->scene, lay, 0); // 0= dont use camera view
- WM_job_main_thread_lock_release(rp->job);
-
- /* do preprocessing like building raytree, shadows, volumes, SSS */
- RE_Database_Preprocess(rp->eval_ctx, re);
-
- /* conversion not completed, need to do it again */
- if (!rstats->convertdone) {
- if (render_view3d_is_valid(rp)) {
- rp->engine->job_update_flag |= PR_UPDATE_DATABASE;
- }
- }
-
- // printf("dbase update\n");
- }
- else {
- // printf("dbase rotate\n");
- RE_DataBase_IncrementalView(re, rp->viewmat, 0);
- restore = 1;
- }
-
- RE_DataBase_ApplyWindow(re);
-
- /* OK, can we enter render code? */
- if (rstats->convertdone) {
- bool first_time = true;
-
- if (update_flag & PR_UPDATE_VIEW) {
- ob_inst_update_flag |= RE_OBJECT_INSTANCES_UPDATE_VIEW;
- }
-
- RE_updateRenderInstances(re, ob_inst_update_flag);
-
- for (;;) {
- int pixel_size = BKE_render_preview_pixel_size(&rp->scene->r);
- if (first_time == false) {
- if (restore)
- RE_DataBase_IncrementalView(re, rp->viewmat, 1);
-
- rp->resolution_divider = MAX2(rp->resolution_divider / 2, pixel_size);
- *do_update = 1;
-
- render_update_resolution(re, rp, use_border, &cliprct);
-
- RE_DataBase_IncrementalView(re, rp->viewmat, 0);
- RE_DataBase_ApplyWindow(re);
- restore = 1;
- }
- else {
- render_update_resolution(re, rp, use_border, &cliprct);
- }
-
- RE_TileProcessor(re);
-
- first_time = false;
-
- if (*stop || rp->resolution_divider == pixel_size) {
- break;
- }
- }
-
- /* always rotate back */
- if (restore)
- RE_DataBase_IncrementalView(re, rp->viewmat, 1);
- }
-}
-
-static void render_view3d_free(void *customdata)
-{
- RenderPreview *rp = customdata;
- DEG_evaluation_context_free(rp->eval_ctx);
-
- MEM_freeN(rp);
-}
-
-static bool render_view3d_flag_changed(RenderEngine *engine, const bContext *C)
-{
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
- View3D *v3d = CTX_wm_view3d(C);
- ARegion *ar = CTX_wm_region(C);
- Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- Render *re;
- rctf viewplane;
- rcti disprect;
- float clipsta, clipend;
- bool orth;
- int job_update_flag = 0;
- char name[32];
-
- /* ensure render engine exists */
- re = engine->re;
-
- if (!re) {
- sprintf(name, "View3dPreview %p", (void *)ar);
- re = engine->re = RE_GetRender(name);
- if (!re)
- re = engine->re = RE_NewRender(name);
-
- engine->update_flag |= RE_ENGINE_UPDATE_DATABASE;
- }
-
- /* check update_flag */
- if (engine->update_flag & RE_ENGINE_UPDATE_MA)
- job_update_flag |= PR_UPDATE_MATERIAL;
-
- if (engine->update_flag & RE_ENGINE_UPDATE_OTHER)
- job_update_flag |= PR_UPDATE_MATERIAL;
-
- if (engine->update_flag & RE_ENGINE_UPDATE_DATABASE) {
- job_update_flag |= PR_UPDATE_DATABASE;
-
- /* load editmesh */
- Object *obedit = CTX_data_edit_object(C);
- if (obedit) {
- ED_object_editmode_load(obedit);
- }
- }
-
- engine->update_flag = 0;
-
- /* check if viewport changed */
- if (engine->last_winx != ar->winx || engine->last_winy != ar->winy) {
- engine->last_winx = ar->winx;
- engine->last_winy = ar->winy;
- job_update_flag |= PR_UPDATE_RENDERSIZE;
- }
-
- if (compare_m4m4(engine->last_viewmat, rv3d->viewmat, 0.00001f) == 0) {
- copy_m4_m4(engine->last_viewmat, rv3d->viewmat);
- job_update_flag |= PR_UPDATE_VIEW;
- }
-
- render_view3d_get_rects(depsgraph, ar, v3d, rv3d, &viewplane, engine, &clipsta, &clipend, NULL, &orth);
-
- if (BLI_rctf_compare(&viewplane, &engine->last_viewplane, 0.00001f) == 0) {
- engine->last_viewplane = viewplane;
- job_update_flag |= PR_UPDATE_VIEW;
- }
-
- render_view3d_disprect(scene, depsgraph, ar, v3d, rv3d, &disprect);
- if (BLI_rcti_compare(&disprect, &engine->last_disprect) == 0) {
- engine->last_disprect = disprect;
- job_update_flag |= PR_UPDATE_RENDERSIZE;
- }
-
- /* any changes? go ahead and rerender */
- if (job_update_flag) {
- engine->job_update_flag |= job_update_flag;
- return true;
- }
-
- return false;
-}
-
-static void render_view3d_do(RenderEngine *engine, const bContext *C)
-{
- wmJob *wm_job;
- RenderPreview *rp;
- Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- ARegion *ar = CTX_wm_region(C);
- int width = ar->winx, height = ar->winy;
- int divider = BKE_render_preview_pixel_size(&scene->r);
- int resolution_threshold = scene->r.preview_start_resolution *
- scene->r.preview_start_resolution;
-
- if (CTX_wm_window(C) == NULL)
- return;
- if (!render_view3d_flag_changed(engine, C))
- return;
-
- wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), CTX_wm_region(C), "Render Preview",
- WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW);
- rp = MEM_callocN(sizeof(RenderPreview), "render preview");
- rp->job = wm_job;
-
- while (width * height > resolution_threshold) {
- width = max_ii(1, width / 2);
- height = max_ii(1, height / 2);
- divider *= 2;
- }
-
- /* customdata for preview thread */
- rp->scene = scene;
- rp->depsgraph = depsgraph;
- rp->eval_ctx = DEG_evaluation_context_new(DAG_EVAL_PREVIEW);
- CTX_data_eval_ctx(C, rp->eval_ctx);
- rp->engine = engine;
- rp->sa = CTX_wm_area(C);
- rp->ar = CTX_wm_region(C);
- rp->v3d = rp->sa->spacedata.first;
- rp->rv3d = CTX_wm_region_view3d(C);
- rp->bmain = CTX_data_main(C);
- rp->resolution_divider = divider;
- rp->start_resolution_divider = divider;
- rp->has_freestyle = (scene->r.mode & R_EDGE_FRS) != 0;
- copy_m4_m4(rp->viewmat, rp->rv3d->viewmat);
-
- /* clear info text */
- engine->text[0] = '\0';
-
- /* setup job */
- WM_jobs_customdata_set(wm_job, rp, render_view3d_free);
- WM_jobs_timer(wm_job, 0.1, NC_SPACE | ND_SPACE_VIEW3D, NC_SPACE | ND_SPACE_VIEW3D);
- WM_jobs_callbacks(wm_job, render_view3d_startjob, NULL, NULL, NULL);
-
- WM_jobs_start(CTX_wm_manager(C), wm_job);
-
- engine->flag &= ~RE_ENGINE_DO_UPDATE;
-}
-
-/* callback for render engine, on changes */
-void render_view3d_update(RenderEngine *engine, const bContext *C)
-{
- /* this shouldn't be needed and causes too many database rebuilds, but we
- * aren't actually tracking updates for all relevant datablocks so this is
- * a catch-all for updates */
- engine->update_flag |= RE_ENGINE_UPDATE_DATABASE;
-
- render_view3d_do(engine, C);
-}
-
-void render_view3d_draw(RenderEngine *engine, const bContext *C)
-{
- Render *re = engine->re;
- RenderResult rres;
- char name[32];
-
- render_view3d_do(engine, C);
-
- if (re == NULL) {
- sprintf(name, "View3dPreview %p", (void *)CTX_wm_region(C));
- re = RE_GetRender(name);
-
- if (re == NULL) return;
- }
-
- /* Viewport render preview doesn't support multiview, view hardcoded to 0 */
- RE_AcquireResultImage(re, &rres, 0);
-
- if (rres.rectf) {
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
- View3D *v3d = CTX_wm_view3d(C);
- Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- ARegion *ar = CTX_wm_region(C);
- bool force_fallback = false;
- bool need_fallback = true;
- float dither = scene->r.dither_intensity;
- float scale_x, scale_y;
- rcti clip_rect;
- int xof, yof;
-
- if (render_view3d_disprect(scene, depsgraph, ar, v3d, rv3d, &clip_rect)) {
- scale_x = (float) BLI_rcti_size_x(&clip_rect) / rres.rectx;
- scale_y = (float) BLI_rcti_size_y(&clip_rect) / rres.recty;
- xof = clip_rect.xmin;
- yof = clip_rect.ymin;
- }
- else {
- scale_x = (float) ar->winx / rres.rectx;
- scale_y = (float) ar->winy / rres.recty;
- xof = rres.xof;
- yof = rres.yof;
- }
-
- /* If user decided not to use GLSL, fallback to glaDrawPixelsAuto */
- force_fallback |= (U.image_draw_method != IMAGE_DRAW_METHOD_GLSL);
-
- /* Try using GLSL display transform. */
- if (force_fallback == false) {
- if (IMB_colormanagement_setup_glsl_draw(&scene->view_settings, &scene->display_settings, dither, true)) {
- glEnable(GL_BLEND);
- IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
- immDrawPixelsTex(&state, xof, yof, rres.rectx, rres.recty,
- GL_RGBA, GL_FLOAT, GL_NEAREST, rres.rectf,
- scale_x, scale_y, NULL);;
- glDisable(GL_BLEND);
-
- IMB_colormanagement_finish_glsl_draw();
- need_fallback = false;
- }
- }
-
- /* If GLSL failed, use old-school CPU-based transform. */
- if (need_fallback) {
- unsigned char *display_buffer = MEM_mallocN(4 * rres.rectx * rres.recty * sizeof(char),
- "render_view3d_draw");
-
- IMB_colormanagement_buffer_make_display_space(rres.rectf, display_buffer, rres.rectx, rres.recty,
- 4, dither, &scene->view_settings, &scene->display_settings);
-
- glEnable(GL_BLEND);
- IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
- immDrawPixelsTex(&state, xof, yof, rres.rectx, rres.recty,
- GL_RGBA, GL_UNSIGNED_BYTE,
- GL_NEAREST, display_buffer,
- scale_x, scale_y, NULL);
- glDisable(GL_BLEND);
-
- MEM_freeN(display_buffer);
- }
- }
-
- RE_ReleaseResultImage(re);
-}
-
-void ED_viewport_render_kill_jobs(wmWindowManager *wm,
- Main *bmain,
- bool free_database)
-{
- bScreen *sc;
- ScrArea *sa;
- ARegion *ar;
-
- if (!wm)
- return;
-
- /* kill all actively running jobs */
- WM_jobs_kill(wm, NULL, render_view3d_startjob);
-
- /* loop over 3D view render engines */
- for (sc = bmain->screen.first; sc; sc = sc->id.next) {
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- if (sa->spacetype != SPACE_VIEW3D)
- continue;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- RegionView3D *rv3d;
-
- if (ar->regiontype != RGN_TYPE_WINDOW)
- continue;
-
- rv3d = ar->regiondata;
-
- if (rv3d->render_engine) {
- /* free render database now before we change data, because
- * RE_Database_Free will also loop over blender data */
- if (free_database) {
- char name[32];
- Render *re;
-
- sprintf(name, "View3dPreview %p", (void *)ar);
- re = RE_GetRender(name);
-
- if (re)
- RE_Database_Free(re);
-
- /* tag render engine to update entire database */
- rv3d->render_engine->update_flag |= RE_ENGINE_UPDATE_DATABASE;
- }
- else {
- /* quick shader update */
- rv3d->render_engine->update_flag |= RE_ENGINE_UPDATE_MA;
- }
- }
- }
- }
- }
-}
-
Scene *ED_render_job_get_scene(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -1720,6 +1099,7 @@ Scene *ED_render_job_get_current_scene(const bContext *C)
return NULL;
}
+
/* Motion blur curve preset */
static int render_shutter_curve_preset_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index be2b184626d..1c6938cbdb3 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -268,8 +268,8 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = oglrender->scene;
- ViewLayer *view_layer = oglrender->view_layer;
ARegion *ar = oglrender->ar;
View3D *v3d = oglrender->v3d;
RegionView3D *rv3d = oglrender->rv3d;
@@ -277,14 +277,10 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
int sizex = oglrender->sizex;
int sizey = oglrender->sizey;
const short view_context = (v3d != NULL);
- bool draw_bgpic = true;
bool draw_sky = (scene->r.alphamode == R_ADDSKY);
float *rectf = NULL;
const char *viewname = RE_GetActiveRenderView(oglrender->re);
ImBuf *ibuf_result = NULL;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
if (oglrender->is_sequencer) {
SpaceSeq *sseq = oglrender->sseq;
@@ -353,16 +349,13 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
char err_out[256] = "unknown";
ImBuf *ibuf_view;
const int alpha_mode = (draw_sky) ? R_ADDSKY : R_ALPHAPREMUL;
- struct RenderEngineType *engine_type = CTX_data_engine_type(C);
unsigned int draw_flags = V3D_OFSDRAW_NONE;
draw_flags |= (oglrender->ofs_full_samples) ? V3D_OFSDRAW_USE_FULL_SAMPLE : 0;
if (view_context) {
- draw_flags |= (draw_bgpic) ? V3D_OFSDRAW_USE_BACKGROUND : 0;
-
ibuf_view = ED_view3d_draw_offscreen_imbuf(
- &eval_ctx, scene, view_layer, engine_type,
+ depsgraph, scene, v3d->drawtype,
v3d, ar, sizex, sizey,
IB_rectfloat, draw_flags, alpha_mode, oglrender->ofs_samples, viewname,
oglrender->ofs, err_out);
@@ -373,11 +366,11 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
}
}
else {
- draw_flags |= (V3D_OFSDRAW_USE_GPENCIL | V3D_OFSDRAW_USE_BACKGROUND);
+ draw_flags |= V3D_OFSDRAW_USE_GPENCIL;
ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(
- &eval_ctx, scene, view_layer, engine_type,
+ depsgraph, scene, OB_SOLID,
scene->camera, oglrender->sizex, oglrender->sizey,
- IB_rectfloat, draw_flags, OB_SOLID,
+ IB_rectfloat, draw_flags,
alpha_mode, oglrender->ofs_samples, viewname,
oglrender->ofs, err_out);
camera = scene->camera;
@@ -539,8 +532,8 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
int chanshown = sseq ? sseq->chanshown : 0;
BKE_sequencer_new_render_data(
- oglrender->bmain->eval_ctx, oglrender->bmain, scene,
- oglrender->sizex, oglrender->sizey, 100.0f,
+ oglrender->bmain, scene,
+ oglrender->sizex, oglrender->sizey, 100.0f, false,
&context);
for (view_id = 0; view_id < oglrender->views_len; view_id++) {
@@ -710,8 +703,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
/* create render */
oglrender->re = RE_NewSceneRender(scene);
- ViewRender *view_render = BKE_viewrender_get(scene, workspace);
- RE_SetEngineByID(oglrender->re, view_render->engine_id);
/* create image and image user */
oglrender->ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
@@ -722,7 +713,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
oglrender->iuser.ok = 1;
/* create render result */
- RE_InitState(oglrender->re, NULL, &scene->r, &scene->view_layers, scene->active_view_layer, view_render, NULL, sizex, sizey, NULL);
+ RE_InitState(oglrender->re, NULL, &scene->r, &scene->view_layers, scene->active_view_layer, NULL, sizex, sizey, NULL);
/* create render views */
screen_opengl_views_setup(oglrender);
diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c
index bd75c6879e1..13fe40e768a 100644
--- a/source/blender/editors/render/render_ops.c
+++ b/source/blender/editors/render/render_ops.c
@@ -85,9 +85,6 @@ void ED_operatortypes_render(void)
WM_operatortype_append(TEXTURE_OT_slot_copy);
WM_operatortype_append(TEXTURE_OT_slot_paste);
WM_operatortype_append(TEXTURE_OT_slot_move);
- WM_operatortype_append(TEXTURE_OT_envmap_save);
- WM_operatortype_append(TEXTURE_OT_envmap_clear);
- WM_operatortype_append(TEXTURE_OT_envmap_clear_all);
/* render_internal.c */
WM_operatortype_append(RENDER_OT_view_show);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 4297d4fa316..9a179ce3b47 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -173,7 +173,6 @@ typedef struct ShaderPreview {
Main *bmain;
Main *pr_main;
- ViewRender *view_render;
} ShaderPreview;
typedef struct IconPreviewSize {
@@ -188,7 +187,6 @@ typedef struct IconPreview {
void *owner;
ID *id;
ListBase sizes;
- ViewRender *view_render;
} IconPreview;
/* *************************** Preview for buttons *********************** */
@@ -231,7 +229,7 @@ void ED_preview_ensure_dbase(void)
static bool check_engine_supports_textures(Scene *scene)
{
- RenderEngineType *type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *type = RE_engines_find(scene->r.engine);
return type->flag & RE_USE_TEXTURE_PREVIEW;
}
@@ -244,32 +242,6 @@ void ED_preview_free_dbase(void)
BKE_main_free(G_pr_main_cycles);
}
-static int preview_mat_has_sss(Material *mat, bNodeTree *ntree)
-{
- if (mat) {
- if (mat->sss_flag & MA_DIFF_SSS)
- return 1;
- if (mat->nodetree)
- if (preview_mat_has_sss(NULL, mat->nodetree))
- return 1;
- }
- else if (ntree) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == NODE_GROUP && node->id) {
- if (preview_mat_has_sss(NULL, (bNodeTree *)node->id))
- return 1;
- }
- else if (node->id && ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) {
- mat = (Material *)node->id;
- if (mat->sss_flag & MA_DIFF_SSS)
- return 1;
- }
- }
- }
- return 0;
-}
-
static Scene *preview_get_scene(Main *pr_main)
{
if (pr_main == NULL) return NULL;
@@ -384,10 +356,10 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
* seems commonly used render engines does not support
* such kind of rendering.
*/
- BLI_strncpy(sce->view_render.engine_id, RE_engine_id_BLENDER_RENDER, sizeof(sce->view_render.engine_id));
+ BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(sce->r.engine));
}
else {
- BLI_strncpy(sce->view_render.engine_id, scene->view_render.engine_id, sizeof(sce->view_render.engine_id));
+ BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine));
}
if (id_type == ID_MA) {
@@ -399,83 +371,22 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
sp->matcopy = mat;
BLI_addtail(&pr_main->mat, mat);
- if (!BKE_scene_use_new_shading_nodes(scene)) {
- init_render_material(mat, 0, NULL); /* call that retrieves mode_l */
- end_render_material(mat);
-
- /* un-useful option */
- if (sp->pr_method == PR_ICON_RENDER)
- mat->shade_flag &= ~MA_OBCOLOR;
-
- /* turn on raytracing if needed */
- if (mat->mode_l & MA_RAYMIRROR)
- sce->r.mode |= R_RAYTRACE;
- if (mat->material_type == MA_TYPE_VOLUME)
- sce->r.mode |= R_RAYTRACE;
- if ((mat->mode_l & MA_RAYTRANSP) && (mat->mode_l & MA_TRANSP))
- sce->r.mode |= R_RAYTRACE;
- if (preview_mat_has_sss(mat, NULL))
- sce->r.mode |= R_SSS;
-
- /* turn off fake shadows if needed */
- /* this only works in a specific case where the preview.blend contains
- * an object starting with 'c' which has a material linked to it (not the obdata)
- * and that material has a fake shadow texture in the active texture slot */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- Object *ob = base->object;
- if (ob->id.name[2] == 'c') {
- Material *shadmat = give_current_material(ob, ob->actcol);
- if (shadmat) {
- if (mat->mode2 & MA_CASTSHADOW) {
- shadmat->septex = 0;
- }
- else {
- shadmat->septex |= 1;
- }
- }
- }
- }
-
- /* turn off bounce lights for volume,
- * doesn't make much visual difference and slows it down too */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- Object *ob = base->object;
- if (ob->type == OB_LAMP) {
- /* if doesn't match 'Lamp.002' --> main key light */
- if (!STREQ(ob->id.name + 2, "Lamp.002")) {
- if (mat->material_type == MA_TYPE_VOLUME) {
- base->flag &= ~BASE_VISIBLED;
- }
- else {
- base->flag |= BASE_VISIBLED;
- }
- }
- }
- }
+ /* use current scene world to light sphere */
+ if (mat->pr_type == MA_SPHERE_A && sp->pr_method == PR_BUTS_RENDER) {
+ /* Use current scene world to light sphere. */
+ sce->world = preview_get_localized_world(sp, scene->world);
}
- else {
- /* use current scene world to light sphere */
- if (mat->pr_type == MA_SPHERE_A && sp->pr_method == PR_BUTS_RENDER) {
- /* Use current scene world to light sphere. */
- sce->world = preview_get_localized_world(sp, scene->world);
- }
- else if (sce->world) {
- /* Use a default world color. Using the current
- * scene world can be slow if it has big textures. */
- sce->world->use_nodes = false;
- sce->world->horr = 0.5f;
- sce->world->horg = 0.5f;
- sce->world->horb = 0.5f;
- }
+ else if (sce->world) {
+ /* Use a default world color. Using the current
+ * scene world can be slow if it has big textures. */
+ sce->world->use_nodes = false;
+ sce->world->horr = 0.5f;
+ sce->world->horg = 0.5f;
+ sce->world->horb = 0.5f;
}
if (sp->pr_method == PR_ICON_RENDER) {
- if (mat->material_type == MA_TYPE_HALO) {
- set_preview_layer(view_layer, MA_FLAT);
- }
- else {
- set_preview_layer(view_layer, MA_SPHERE_A);
- }
+ set_preview_layer(view_layer, MA_SPHERE_A);
}
else {
set_preview_layer(view_layer, mat->pr_type);
@@ -488,7 +399,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
}
}
else {
- sce->r.mode &= ~(R_OSA | R_RAYTRACE | R_SSS);
+ sce->r.mode &= ~(R_OSA);
}
@@ -521,29 +432,6 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
}
set_preview_layer(view_layer, MA_TEXTURE);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- if (base->object->id.name[2] == 't') {
- Material *mat = give_current_material(base->object, base->object->actcol);
- if (mat && mat->mtex[0]) {
- mat->mtex[0]->tex = tex;
-
- if (tex && sp->slot)
- mat->mtex[0]->which_output = sp->slot->which_output;
-
- mat->mtex[0]->mapto &= ~MAP_ALPHA;
- mat->alpha = 1.0f;
-
- /* show alpha in this case */
- if (tex == NULL || (tex->flag & TEX_PRV_ALPHA)) {
- if (!(tex && tex->type == TEX_IMAGE && (tex->imaflag & (TEX_USEALPHA | TEX_CALCALPHA)) == 0)) {
- mat->mtex[0]->mapto |= MAP_ALPHA;
- mat->alpha = 0.0f;
- }
- }
- }
- }
- }
-
if (tex && tex->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
BKE_node_preview_init_tree(origtex->nodetree, sp->sizex, sp->sizey, true);
@@ -560,28 +448,14 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
BLI_addtail(&pr_main->lamp, la);
}
- if (!BKE_scene_use_new_shading_nodes(scene)) {
- if (la && la->type == LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) {
- set_preview_layer(view_layer, MA_ATMOS);
- sce->world = preview_get_localized_world(sp, scene->world);
- sce->camera = (Object *)BLI_findstring(&pr_main->object, "CameraAtmo", offsetof(ID, name) + 2);
- }
- else {
- sce->world = NULL;
- sce->camera = (Object *)BLI_findstring(&pr_main->object, "Camera", offsetof(ID, name) + 2);
- set_preview_layer(view_layer, MA_LAMP);
- }
- }
- else {
- set_preview_layer(view_layer, MA_LAMP);
+ set_preview_layer(view_layer, MA_LAMP);
- if (sce->world) {
- /* Only use lighting from the lamp. */
- sce->world->use_nodes = false;
- sce->world->horr = 0.0f;
- sce->world->horg = 0.0f;
- sce->world->horb = 0.0f;
- }
+ if (sce->world) {
+ /* Only use lighting from the lamp. */
+ sce->world->use_nodes = false;
+ sce->world->horr = 0.0f;
+ sce->world->horg = 0.0f;
+ sce->world->horb = 0.0f;
}
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
@@ -872,7 +746,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
((Camera *)sce->camera->data)->lens *= (float)sp->sizey / (float)sizex;
/* entire cycle for render engine */
- RE_PreviewRender(re, pr_main, sce, sp->view_render);
+ RE_PreviewRender(re, pr_main, sce);
((Camera *)sce->camera->data)->lens = oldlens;
@@ -1134,12 +1008,6 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
if (idtype == ID_WO) {
set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);
}
- else if (idtype == ID_MA) {
- Material *ma = (Material *)id;
-
- if (ma->material_type == MA_TYPE_HALO)
- set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);
- }
}
}
}
@@ -1184,7 +1052,6 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short
{
IconPreview *ip = (IconPreview *)customdata;
IconPreviewSize *cur_size;
- const bool use_new_shading = BKE_scene_use_new_shading_nodes(ip->scene);
for (cur_size = ip->sizes.first; cur_size; cur_size = cur_size->next) {
PreviewImage *prv = ip->owner;
@@ -1199,7 +1066,6 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short
/* construct shader preview from image size and previewcustomdata */
sp->scene = ip->scene;
- sp->view_render = ip->view_render;
sp->owner = ip->owner;
sp->sizex = cur_size->sizex;
sp->sizey = cur_size->sizey;
@@ -1210,19 +1076,14 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short
if (is_render) {
BLI_assert(ip->id);
- if (use_new_shading) {
- /* texture icon rendering is hardcoded to use BI,
- * so don't even think of using cycle's bmain for
- * texture icons
- */
- if (GS(ip->id->name) != ID_TE)
- sp->pr_main = G_pr_main_cycles;
- else
- sp->pr_main = G_pr_main;
- }
- else {
+ /* texture icon rendering is hardcoded to use the BI scene,
+ * so don't even think of using cycle's bmain for
+ * texture icons
+ */
+ if (GS(ip->id->name) != ID_TE)
+ sp->pr_main = G_pr_main_cycles;
+ else
sp->pr_main = G_pr_main;
- }
}
common_preview_startjob(sp, stop, do_update, progress);
@@ -1284,7 +1145,6 @@ void ED_preview_icon_render(Main *bmain, Scene *scene, ID *id, unsigned int *rec
ip.bmain = bmain;
ip.scene = scene;
- ip.view_render = &scene->view_render;
ip.owner = BKE_previewimg_id_ensure(id);
ip.id = id;
@@ -1318,7 +1178,6 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
/* customdata for preview thread */
ip->bmain = CTX_data_main(C);
ip->scene = CTX_data_scene(C);
- ip->view_render = &ip->scene->view_render;
ip->owner = owner;
ip->id = id;
@@ -1346,15 +1205,12 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
wmJob *wm_job;
ShaderPreview *sp;
Scene *scene = CTX_data_scene(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
short id_type = GS(id->name);
/* Use workspace render only for buttons Window, since the other previews are related to the datablock. */
- ViewRender *view_render = (method == PR_BUTS_RENDER) ? BKE_viewrender_get(scene, workspace) : &scene->view_render;
- bool use_new_shading = BKE_viewrender_use_new_shading_nodes(view_render);
/* Only texture node preview is supported with Cycles. */
- if (use_new_shading && method == PR_NODE_RENDER && id_type != ID_TE) {
+ if (method == PR_NODE_RENDER && id_type != ID_TE) {
return;
}
@@ -1374,11 +1230,10 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
sp->parent = parent;
sp->slot = slot;
sp->bmain = CTX_data_main(C);
- sp->view_render = view_render;
- /* hardcoded preview .blend for Eevee + cycles/internal, this should be solved
+ /* hardcoded preview .blend for Eevee + Cycles, this should be solved
* once with custom preview .blend path for external engines */
- if ((method != PR_NODE_RENDER) && id_type != ID_TE && use_new_shading) {
+ if ((method != PR_NODE_RENDER) && id_type != ID_TE) {
sp->pr_main = G_pr_main_cycles;
}
else {
@@ -1396,11 +1251,9 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
-void ED_preview_kill_jobs(wmWindowManager *wm, Main *bmain)
+void ED_preview_kill_jobs(wmWindowManager *wm, Main *UNUSED(bmain))
{
if (wm)
WM_jobs_kill(wm, NULL, common_preview_startjob);
-
- ED_viewport_render_kill_jobs(wm, bmain, false);
}
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 270ba2a7947..c5787a1d46c 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -460,7 +460,6 @@ void OBJECT_OT_material_slot_move(wmOperatorType *ot)
static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
Main *bmain = CTX_data_main(C);
PointerRNA ptr, idptr;
@@ -472,11 +471,8 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
}
else {
ma = BKE_material_add(bmain, DATA_("Material"));
-
- if (BKE_scene_use_new_shading_nodes(scene)) {
- ED_node_shader_default(C, &ma->id);
- ma->use_nodes = true;
- }
+ ED_node_shader_default(C, &ma->id);
+ ma->use_nodes = true;
}
/* hook into UI */
@@ -536,14 +532,6 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
* pointer use also increases user, so this compensates it */
id_us_min(&tex->id);
- if (ptr.id.data && GS(((ID *)ptr.id.data)->name) == ID_MA &&
- RNA_property_pointer_get(&ptr, prop).id.data == NULL)
- {
- /* In case we are assigning new texture to a material, and active slot was empty, reset 'use' flag. */
- Material *ma = (Material *)ptr.id.data;
- ma->septex &= ~(1 << ma->texact);
- }
-
RNA_id_pointer_create(&tex->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr);
RNA_property_update(C, &ptr, prop);
@@ -572,7 +560,6 @@ void TEXTURE_OT_new(wmOperatorType *ot)
static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
Main *bmain = CTX_data_main(C);
PointerRNA ptr, idptr;
@@ -584,11 +571,8 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
}
else {
wo = BKE_world_add(bmain, DATA_("World"));
-
- if (BKE_scene_use_new_shading_nodes(scene)) {
- ED_node_shader_default(C, &wo->id);
- wo->use_nodes = true;
- }
+ ED_node_shader_default(C, &wo->id);
+ wo->use_nodes = true;
}
/* hook into UI */
@@ -1457,15 +1441,6 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op)
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act - 1, -1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act - 1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
-
- if (GS(id->name) == ID_MA) {
- Material *ma = (Material *)id;
- int mtexuse = ma->septex & (1 << act);
- ma->septex &= ~(1 << act);
- ma->septex |= (ma->septex & (1 << (act - 1))) << 1;
- ma->septex &= ~(1 << (act - 1));
- ma->septex |= mtexuse >> 1;
- }
set_active_mtex(id, act - 1);
}
@@ -1479,15 +1454,6 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op)
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act + 1, -1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act + 1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
-
- if (GS(id->name) == ID_MA) {
- Material *ma = (Material *)id;
- int mtexuse = ma->septex & (1 << act);
- ma->septex &= ~(1 << act);
- ma->septex |= (ma->septex & (1 << (act + 1))) >> 1;
- ma->septex &= ~(1 << (act + 1));
- ma->septex |= mtexuse << 1;
- }
set_active_mtex(id, act + 1);
}
@@ -1524,180 +1490,6 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot)
-/********************** environment map operators *********************/
-
-static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, const char imtype)
-{
- PropertyRNA *prop;
- float layout[12];
-
- if ((prop = RNA_struct_find_property(op->ptr, "layout"))) {
- RNA_property_float_get_array(op->ptr, prop, layout);
- }
- else {
- memcpy(layout, default_envmap_layout, sizeof(layout));
- }
-
- if (RE_WriteEnvmapResult(op->reports, scene, env, path, imtype, layout)) {
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-
-}
-
-static int envmap_save_exec(bContext *C, wmOperator *op)
-{
- Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
- Scene *scene = CTX_data_scene(C);
- //int imtype = RNA_enum_get(op->ptr, "file_type");
- char imtype = scene->r.im_format.imtype;
- char path[FILE_MAX];
-
- RNA_string_get(op->ptr, "filepath", path);
-
- if (scene->r.scemode & R_EXTENSION) {
- BKE_image_path_ensure_ext_from_imformat(path, &scene->r.im_format);
- }
-
- WM_cursor_wait(1);
-
- save_envmap(op, scene, tex->env, path, imtype);
-
- WM_cursor_wait(0);
-
- WM_event_add_notifier(C, NC_TEXTURE, tex);
-
- return OPERATOR_FINISHED;
-}
-
-static int envmap_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- //Scene *scene= CTX_data_scene(C);
-
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
- return envmap_save_exec(C, op);
-
- //RNA_enum_set(op->ptr, "file_type", scene->r.im_format.imtype);
- RNA_string_set(op->ptr, "filepath", G.main->name);
- WM_event_add_fileselect(C, op);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-static int envmap_save_poll(bContext *C)
-{
- Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
-
- if (!tex)
- return 0;
- if (!tex->env || !tex->env->ok)
- return 0;
- if (tex->env->cube[1] == NULL)
- return 0;
-
- return 1;
-}
-
-void TEXTURE_OT_envmap_save(wmOperatorType *ot)
-{
- PropertyRNA *prop;
- /* identifiers */
- ot->name = "Save Environment Map";
- ot->idname = "TEXTURE_OT_envmap_save";
- ot->description = "Save the current generated Environment map to an image file";
-
- /* api callbacks */
- ot->exec = envmap_save_exec;
- ot->invoke = envmap_save_invoke;
- ot->poll = envmap_save_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL; /* no undo since this doesnt modify the env-map */
-
- /* properties */
- prop = RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f,
- "File layout",
- "Flat array describing the X,Y position of each cube face in the output image, "
- "where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] "
- "(use -1 to skip a face)", 0.0f, 0.0f);
- RNA_def_property_flag(prop, PROP_HIDDEN);
-
- WM_operator_properties_filesel(
- ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_SAVE,
- WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
-}
-
-static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
-
- BKE_texture_envmap_free_data(tex->env);
-
- WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
-
- return OPERATOR_FINISHED;
-}
-
-static int envmap_clear_poll(bContext *C)
-{
- Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
-
- if (!tex)
- return 0;
- if (!tex->env || !tex->env->ok)
- return 0;
- if (tex->env->cube[1] == NULL)
- return 0;
-
- return 1;
-}
-
-void TEXTURE_OT_envmap_clear(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Clear Environment Map";
- ot->idname = "TEXTURE_OT_envmap_clear";
- ot->description = "Discard the environment map and free it from memory";
-
- /* api callbacks */
- ot->exec = envmap_clear_exec;
- ot->poll = envmap_clear_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
-}
-
-static int envmap_clear_all_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Main *bmain = CTX_data_main(C);
- Tex *tex;
-
- for (tex = bmain->tex.first; tex; tex = tex->id.next)
- if (tex->env)
- BKE_texture_envmap_free_data(tex->env);
-
- WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
-
- return OPERATOR_FINISHED;
-}
-
-void TEXTURE_OT_envmap_clear_all(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Clear All Environment Maps";
- ot->idname = "TEXTURE_OT_envmap_clear_all";
- ot->description = "Discard all environment maps in the .blend file and free them from memory";
-
- /* api callbacks */
- ot->exec = envmap_clear_all_exec;
- ot->poll = envmap_clear_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
/********************** material operators *********************/
/* material copy/paste */
@@ -1769,17 +1561,6 @@ static void copy_mtex_copybuf(ID *id)
MTex **mtex = NULL;
switch (GS(id->name)) {
- case ID_MA:
- mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
- break;
- case ID_LA:
- mtex = &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
- // la->mtex[(int)la->texact] // TODO
- break;
- case ID_WO:
- mtex = &(((World *)id)->mtex[(int)((World *)id)->texact]);
- // mtex= wrld->mtex[(int)wrld->texact]; // TODO
- break;
case ID_PA:
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
break;
@@ -1807,17 +1588,6 @@ static void paste_mtex_copybuf(ID *id)
return;
switch (GS(id->name)) {
- case ID_MA:
- mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
- break;
- case ID_LA:
- mtex = &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
- // la->mtex[(int)la->texact] // TODO
- break;
- case ID_WO:
- mtex = &(((World *)id)->mtex[(int)((World *)id)->texact]);
- // mtex= wrld->mtex[(int)wrld->texact]; // TODO
- break;
case ID_PA:
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
break;
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index d29985041c6..1864cb0af6a 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -59,9 +59,7 @@
#include "BKE_scene.h"
#include "BKE_workspace.h"
-#include "GPU_lamp.h"
#include "GPU_material.h"
-#include "GPU_buffers.h"
#include "RE_engine.h"
#include "RE_pipeline.h"
@@ -120,8 +118,6 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
ARegion *ar;
CTX_wm_window_set(C, win);
- WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- ViewRender *view_render = BKE_viewrender_get(win->scene, workspace);
for (sa = sc->areabase.first; sa; sa = sa->next) {
if (sa->spacetype != SPACE_VIEW3D)
@@ -147,20 +143,18 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
}
else {
- RenderEngineType *engine_type = RE_engines_find(view_render->engine_id);
- if ((engine_type->flag & RE_USE_LEGACY_PIPELINE) == 0) {
- if (updated) {
- DRW_notify_view_update(
- (&(DRWUpdateContext){
- .bmain = bmain,
- .depsgraph = update_ctx->depsgraph,
- .scene = scene,
- .view_layer = view_layer,
- .ar = ar,
- .v3d = (View3D *)sa->spacedata.first,
- .engine_type = engine_type
- }));
- }
+ RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
+ if (updated) {
+ DRW_notify_view_update(
+ (&(DRWUpdateContext){
+ .bmain = bmain,
+ .depsgraph = update_ctx->depsgraph,
+ .scene = scene,
+ .view_layer = view_layer,
+ .ar = ar,
+ .v3d = (View3D *)sa->spacedata.first,
+ .engine_type = engine_type
+ }));
}
}
}
@@ -245,69 +239,8 @@ static void render_engine_flag_changed(Main *bmain, int update_flag)
}
}
-static int mtex_use_tex(MTex **mtex, int tot, Tex *tex)
+static void material_changed(Main *UNUSED(bmain), Material *ma)
{
- int a;
-
- if (!mtex)
- return 0;
-
- for (a = 0; a < tot; a++)
- if (mtex[a] && mtex[a]->tex == tex)
- return 1;
-
- return 0;
-}
-
-static int nodes_use_tex(bNodeTree *ntree, Tex *tex)
-{
- bNode *node;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->id) {
- if (node->id == (ID *)tex) {
- return 1;
- }
- else if (GS(node->id->name) == ID_MA) {
- if (mtex_use_tex(((Material *)node->id)->mtex, MAX_MTEX, tex))
- return 1;
- }
- else if (node->type == NODE_GROUP) {
- if (nodes_use_tex((bNodeTree *)node->id, tex))
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-static int nodes_use_material(bNodeTree *ntree, Material *ma)
-{
- bNode *node;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->id) {
- if (node->id == (ID *)ma) {
- return 1;
- }
- else if (node->type == NODE_GROUP) {
- if (nodes_use_material((bNodeTree *)node->id, ma))
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-static void material_changed(Main *bmain, Material *ma)
-{
- Material *parent;
- Object *ob;
- Scene *scene;
- int texture_draw = false;
-
/* icons */
BKE_icon_changed(BKE_icon_id_ensure(&ma->id));
@@ -317,86 +250,22 @@ static void material_changed(Main *bmain, Material *ma)
GPU_material_free(&ma->gpumaterial);
}
}
-
- /* find node materials using this */
- for (parent = bmain->mat.first; parent; parent = parent->id.next) {
- if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) {
- /* pass */
- }
- else {
- continue;
- }
-
- BKE_icon_changed(BKE_icon_id_ensure(&parent->id));
-
- if (parent->gpumaterial.first)
- GPU_material_free(&parent->gpumaterial);
- }
-
- /* find if we have a scene with textured display */
- for (scene = bmain->scene.first; scene; scene = scene->id.next) {
- if (scene->customdata_mask & CD_MASK_MTFACE) {
- texture_draw = true;
- break;
- }
- }
-
- /* find textured objects */
- if (texture_draw) {
- for (ob = bmain->object.first; ob; ob = ob->id.next) {
- DerivedMesh *dm = ob->derivedFinal;
- Material ***material = give_matarar(ob);
- short a, *totmaterial = give_totcolp(ob);
-
- if (dm && totmaterial && material) {
- for (a = 0; a < *totmaterial; a++) {
- if ((*material)[a] == ma) {
- GPU_drawobject_free(dm);
- break;
- }
- }
- }
- }
- }
-
}
-static void lamp_changed(Main *bmain, Lamp *la)
+static void lamp_changed(Main *UNUSED(bmain), Lamp *la)
{
- Object *ob;
-
/* icons */
BKE_icon_changed(BKE_icon_id_ensure(&la->id));
- /* glsl */
- for (ob = bmain->object.first; ob; ob = ob->id.next)
- if (ob->data == la && ob->gpulamp.first)
- GPU_lamp_free(ob);
-
if (defmaterial.gpumaterial.first)
GPU_material_free(&defmaterial.gpumaterial);
}
-static int material_uses_texture(Material *ma, Tex *tex)
-{
- if (mtex_use_tex(ma->mtex, MAX_MTEX, tex))
- return true;
- else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex))
- return true;
-
- return false;
-}
-
static void texture_changed(Main *bmain, Tex *tex)
{
- Material *ma;
- Lamp *la;
- World *wo;
Scene *scene;
ViewLayer *view_layer;
- Object *ob;
bNode *node;
- bool texture_draw = false;
/* icons */
BKE_icon_changed(BKE_icon_id_ensure(&tex->id));
@@ -408,48 +277,6 @@ static void texture_changed(Main *bmain, Tex *tex)
}
}
- /* find materials */
- for (ma = bmain->mat.first; ma; ma = ma->id.next) {
- if (!material_uses_texture(ma, tex))
- continue;
-
- BKE_icon_changed(BKE_icon_id_ensure(&ma->id));
-
- if (ma->gpumaterial.first)
- GPU_material_free(&ma->gpumaterial);
- }
-
- /* find lamps */
- for (la = bmain->lamp.first; la; la = la->id.next) {
- if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) {
- lamp_changed(bmain, la);
- }
- else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) {
- lamp_changed(bmain, la);
- }
- else {
- continue;
- }
- }
-
- /* find worlds */
- for (wo = bmain->world.first; wo; wo = wo->id.next) {
- if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)) {
- /* pass */
- }
- else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)) {
- /* pass */
- }
- else {
- continue;
- }
-
- BKE_icon_changed(BKE_icon_id_ensure(&wo->id));
-
- if (wo->gpumaterial.first)
- GPU_material_free(&wo->gpumaterial);
- }
-
/* find compositing nodes */
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->use_nodes && scene->nodetree) {
@@ -458,32 +285,6 @@ static void texture_changed(Main *bmain, Tex *tex)
ED_node_tag_update_id(&scene->id);
}
}
-
- if (scene->customdata_mask & CD_MASK_MTFACE)
- texture_draw = true;
- }
-
- /* find textured objects */
- if (texture_draw) {
- for (ob = bmain->object.first; ob; ob = ob->id.next) {
- DerivedMesh *dm = ob->derivedFinal;
- Material ***material = give_matarar(ob);
- short a, *totmaterial = give_totcolp(ob);
-
- if (dm && totmaterial && material) {
- for (a = 0; a < *totmaterial; a++) {
- if (ob->matbits && ob->matbits[a])
- ma = ob->mat[a];
- else
- ma = (*material)[a];
-
- if (ma && material_uses_texture(ma, tex)) {
- GPU_drawobject_free(dm);
- break;
- }
- }
- }
- }
}
}
@@ -528,7 +329,6 @@ static void scene_changed(Main *bmain, Scene *scene)
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
BKE_texpaint_slots_refresh_object(scene, ob);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
- GPU_drawobject_free(ob->derivedFinal);
}
}
}
@@ -570,12 +370,3 @@ void ED_render_id_flush_update(const DEGEditorUpdateContext *update_ctx, ID *id)
}
}
-
-void ED_render_internal_init(void)
-{
- RenderEngineType *ret = RE_engines_find(RE_engine_id_BLENDER_RENDER);
-
- ret->view_update = render_view3d_update;
- ret->render_to_view = render_view3d_draw;
-
-}
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index d16d60ba7b9..58a58ef8172 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -132,8 +132,6 @@ void ED_scene_change_update(
#if 0
/* mode syncing */
- EvaluationContext eval_ctx_old;
- CTX_data_eval_ctx(C, &eval_ctx_old);
eObjectMode object_mode_old = workspace->object_mode;
ViewLayer *layer_old = BKE_view_layer_from_workspace_get(scene_old, workspace);
Object *obact_old = OBACT(layer_old);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 105fff38f62..3eee303cf54 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -753,6 +753,10 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
return;
}
+ if (ED_area_is_global(sa)) {
+ return;
+ }
+
/* can't click on bottom corners on OS X, already used for resizing */
#ifdef __APPLE__
if (!(sa->totrct.xmin == 0 && sa->totrct.ymin == 0) || WM_window_is_fullscreen(win))
@@ -1168,7 +1172,7 @@ static bool region_is_overlap(wmWindow *win, ScrArea *sa, ARegion *ar)
return 0;
}
-static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad)
+static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad, bool add_azones)
{
rcti *remainder_prev = remainder;
int prefsizex, prefsizey;
@@ -1195,13 +1199,17 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
/* user errors */
if (ar->next == NULL && alignment != RGN_ALIGN_QSPLIT)
alignment = RGN_ALIGN_NONE;
-
+
/* prefsize, for header we stick to exception (prevent dpi rounding error) */
- prefsizex = UI_DPI_FAC * (ar->sizex > 1 ? ar->sizex + 0.5f : ar->type->prefsizex);
-
+ const float sizex_dpi_fac = (ar->flag & RGN_SIZEX_DPI_APPLIED) ? 1.0f : UI_DPI_FAC;
+ prefsizex = sizex_dpi_fac * ((ar->sizex > 1) ? ar->sizex + 0.5f : ar->type->prefsizex);
+
if (ar->regiontype == RGN_TYPE_HEADER) {
prefsizey = ED_area_headersize();
}
+ else if (ED_area_is_global(sa)) {
+ prefsizey = ED_region_global_size_y();
+ }
else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
}
@@ -1397,7 +1405,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
* but accounts for small common rounding problems when scaling the UI,
* must be minimum '4' */
}
- else {
+ else if (add_azones) {
const bScreen *screen = WM_window_get_active_screen(win);
if (ELEM(screen->state, SCREENNORMAL, SCREENMAXIMIZED)) {
@@ -1409,23 +1417,36 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
}
}
- region_rect_recursive(win, sa, ar->next, remainder, quad);
+ region_rect_recursive(win, sa, ar->next, remainder, quad, add_azones);
}
-static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
+static void area_calc_totrct(ScrArea *sa, int window_size_x, int window_size_y)
{
- short rt = (short) U.pixelsize;
+ short px = (short)U.pixelsize;
+
+ sa->totrct.xmin = sa->v1->vec.x;
+ sa->totrct.xmax = sa->v4->vec.x;
+ sa->totrct.ymin = sa->v1->vec.y;
+ sa->totrct.ymax = sa->v2->vec.y;
+
+ /* scale down totrct by 1 pixel on all sides not matching window borders */
+ if (sa->totrct.xmin > 0) {
+ sa->totrct.xmin += px;
+ }
+ if (sa->totrct.xmax < (window_size_x - 1)) {
+ sa->totrct.xmax -= px;
+ }
+ if (sa->totrct.ymin > 0) {
+ sa->totrct.ymin += px;
+ }
+ if (sa->totrct.ymax < (window_size_y - 1)) {
+ sa->totrct.ymax -= px;
+ }
+ BLI_assert(sa->totrct.xmin >= 0);
+ BLI_assert(sa->totrct.xmax >= 0);
+ BLI_assert(sa->totrct.ymin >= 0);
+ BLI_assert(sa->totrct.ymax >= 0);
- if (sa->v1->vec.x > 0) sa->totrct.xmin = sa->v1->vec.x + rt;
- else sa->totrct.xmin = sa->v1->vec.x;
- if (sa->v4->vec.x < sizex - 1) sa->totrct.xmax = sa->v4->vec.x - rt;
- else sa->totrct.xmax = sa->v4->vec.x;
-
- if (sa->v1->vec.y > 0) sa->totrct.ymin = sa->v1->vec.y + rt;
- else sa->totrct.ymin = sa->v1->vec.y;
- if (sa->v2->vec.y < sizey - 1) sa->totrct.ymax = sa->v2->vec.y - rt;
- else sa->totrct.ymax = sa->v2->vec.y;
-
/* for speedup */
sa->winx = BLI_rcti_size_x(&sa->totrct) + 1;
sa->winy = BLI_rcti_size_y(&sa->totrct) + 1;
@@ -1464,19 +1485,15 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
/* time-markers */
wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Markers", 0, 0);
- /* time space only has this keymap, the others get a boundbox restricted map */
- if (sa->spacetype != SPACE_TIME) {
- ARegion *ar;
- /* same local check for all areas */
- static rcti rect = {0, 10000, 0, -1};
- rect.ymax = UI_MARKER_MARGIN_Y;
- ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
- if (ar) {
- WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct);
- }
+ /* use a boundbox restricted map */
+ ARegion *ar;
+ /* same local check for all areas */
+ static rcti rect = {0, 10000, 0, -1};
+ rect.ymax = UI_MARKER_MARGIN_Y;
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if (ar) {
+ WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct);
}
- else
- WM_event_add_keymap_handler(handlers, keymap);
}
if (flag & ED_KEYMAP_ANIMATION) {
/* frame changing and timeline operators (for time spaces) */
@@ -1510,11 +1527,36 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
}
}
+void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area)
+{
+ const int size_x = WM_window_pixels_x(win);
+ const int size_y = WM_window_pixels_y(win);
+ rcti rect;
+
+ area_calc_totrct(area, size_x, size_y);
+
+ /* region rect sizes */
+ rect = area->totrct;
+ region_rect_recursive(win, area, area->regionbase.first, &rect, 0, false);
+
+ for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
+ region_subwindow(ar);
+
+ /* region size may have changed, init does necessary adjustments */
+ if (ar->type->init) {
+ ar->type->init(wm, ar);
+ }
+ }
+
+ area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
+}
/* called in screen_refresh, or screens_init, also area size changes */
void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
{
const bScreen *screen = WM_window_get_active_screen(win);
+ const int window_size_x = WM_window_pixels_x(win);
+ const int window_size_y = WM_window_pixels_y(win);
ARegion *ar;
rcti rect;
@@ -1528,16 +1570,17 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
for (ar = sa->regionbase.first; ar; ar = ar->next)
ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
-
+
/* area sizes */
- area_calc_totrct(sa, WM_window_pixels_x(win), WM_window_pixels_y(win));
-
+ area_calc_totrct(sa, window_size_x, window_size_y);
+
/* clear all azones, add the area triange widgets */
area_azone_initialize(win, screen, sa);
/* region rect sizes */
rect = sa->totrct;
- region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0);
+ region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0, true);
+ sa->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
/* default area handlers */
ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
@@ -1600,6 +1643,18 @@ void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *ar)
}
}
+/* for use after changing visiblity of regions */
+void ED_region_visibility_change_update(bContext *C, ARegion *ar)
+{
+ ScrArea *sa = CTX_wm_area(C);
+
+ if (ar->flag & RGN_FLAG_HIDDEN)
+ WM_event_remove_handlers(C, &ar->handlers);
+
+ ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
+ ED_area_tag_redraw(sa);
+}
+
/* for quick toggle, can skip fades */
void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade)
{
@@ -1612,11 +1667,7 @@ void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade)
region_blend_start(C, sa, ar);
}
else {
- if (ar->flag & RGN_FLAG_HIDDEN)
- WM_event_remove_handlers(C, &ar->handlers);
-
- ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
- ED_area_tag_redraw(sa);
+ ED_region_visibility_change_update(C, ar);
}
}
@@ -1832,6 +1883,25 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
/************************ standard UI regions ************************/
+static ThemeColorID region_background_color_id(const bContext *C, const ARegion *region)
+{
+ ScrArea *area = CTX_wm_area(C);
+
+ switch (region->regiontype) {
+ case RGN_TYPE_HEADER:
+ if (ED_screen_area_active(C) || ED_area_is_global(area)) {
+ return TH_HEADER;
+ }
+ else {
+ return TH_HEADERDESEL;
+ }
+ case RGN_TYPE_PREVIEW:
+ return TH_PREVIEW_BACK;
+ default:
+ return TH_BACK;
+ }
+}
+
void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int contextnr, const bool vertical)
{
const WorkSpace *workspace = CTX_wm_workspace(C);
@@ -2117,16 +2187,24 @@ void ED_region_header(const bContext *C, ARegion *ar)
Header header = {NULL};
int maxco, xco, yco;
int headery = ED_area_headersize();
+ const int start_ofs = 0.4f * UI_UNIT_X;
+ bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE;
/* clear */
- UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL);
+ UI_ThemeClearColor(region_background_color_id(C, ar));
glClear(GL_COLOR_BUFFER_BIT);
/* set view2d view matrix for scrolling (without scrollers) */
UI_view2d_view_ortho(&ar->v2d);
- xco = maxco = 0.4f * UI_UNIT_X;
- yco = headery - floor(0.2f * UI_UNIT_Y);
+ xco = maxco = start_ofs;
+ yco = headery + (ar->winy - headery)/2 - floor(0.2f * UI_UNIT_Y);
+
+ /* XXX workaround for 1 px alignment issue. Not sure what causes it... Would prefer a proper fix - Julian */
+ if (CTX_wm_area(C)->spacetype == SPACE_TOPBAR) {
+ xco += 1;
+ yco += 1;
+ }
/* draw all headers types */
for (ht = ar->type->headertypes.first; ht; ht = ht->next) {
@@ -2149,13 +2227,23 @@ void ED_region_header(const bContext *C, ARegion *ar)
/* for view2d */
if (xco > maxco)
maxco = xco;
-
+
+ if (region_layout_based && (ar->sizex != (maxco + start_ofs))) {
+ /* region size is layout based and needs to be updated */
+ ScrArea *sa = CTX_wm_area(C);
+
+ ar->sizex = maxco + start_ofs;
+ UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->sizex, ar->winy);
+
+ sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
+ ar->flag |= RGN_SIZEX_DPI_APPLIED;
+ }
UI_block_end(C, block);
UI_block_draw(C, block);
}
/* always as last */
- UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, headery);
+ UI_view2d_totRect_set(&ar->v2d, maxco + (region_layout_based ? 0 : UI_UNIT_X + 80), headery);
/* restore view matrix? */
UI_view2d_view_restore(C);
@@ -2172,6 +2260,31 @@ int ED_area_headersize(void)
return (int)(HEADERY * UI_DPI_FAC);
}
+/**
+ * \return the final height of a global \a area, accounting for DPI.
+ */
+int ED_area_global_size_y(const ScrArea *area)
+{
+ BLI_assert(ED_area_is_global(area));
+ return round_fl_to_int(area->global->cur_fixed_height * UI_DPI_FAC);
+}
+
+bool ED_area_is_global(const ScrArea *area)
+{
+ return area->global != NULL;
+}
+
+/**
+ * For now we just assume all global areas are made up out of horizontal bars
+ * with the same size. A fixed size could be stored in ARegion instead if needed.
+ *
+ * \return the DPI aware height of a single bar/region in global areas.
+ */
+int ED_region_global_size_y(void)
+{
+ return ED_area_headersize(); /* same size as header */
+}
+
void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float fill_color[4], const bool full_redraw)
{
const int header_height = UI_UNIT_Y;
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 98a6670d10f..85087d58276 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -30,6 +30,8 @@
#include <stdlib.h>
#include <string.h>
+#include "MEM_guardedalloc.h"
+
#include "DNA_object_types.h"
#include "DNA_armature_types.h"
#include "DNA_gpencil_types.h"
@@ -42,7 +44,6 @@
#include "BLI_utildefines.h"
-
#include "BKE_context.h"
#include "BKE_object.h"
#include "BKE_action.h"
@@ -209,38 +210,47 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
const bool editable_bones = CTX_data_equals(member, "editable_bones");
if (arm && arm->edbo) {
- /* Attention: X-Axis Mirroring is also handled here... */
- for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- /* first and foremost, bone must be visible and selected */
- if (EBONE_VISIBLE(arm, ebone)) {
- /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
- * so that most users of this data don't need to explicitly check for it themselves.
- *
- * We need to make sure that these mirrored copies are not selected, otherwise some
- * bones will be operated on twice.
- */
- if (arm->flag & ARM_MIRROR_EDIT)
- flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
-
- /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
- if (editable_bones) {
- /* only selected + editable */
- if (EBONE_EDITABLE(ebone)) {
+ uint objects_len;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint i = 0; i < objects_len; i++) {
+ Object *ob = objects[i];
+ arm = ob->data;
+
+ /* Attention: X-Axis Mirroring is also handled here... */
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ /* first and foremost, bone must be visible and selected */
+ if (EBONE_VISIBLE(arm, ebone)) {
+ /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
+ * so that most users of this data don't need to explicitly check for it themselves.
+ *
+ * We need to make sure that these mirrored copies are not selected, otherwise some
+ * bones will be operated on twice.
+ */
+ if (arm->flag & ARM_MIRROR_EDIT)
+ flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+
+ /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
+ if (editable_bones) {
+ /* only selected + editable */
+ if (EBONE_EDITABLE(ebone)) {
+ CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
+
+ if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+ CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
+ }
+ else {
+ /* only include bones if visible */
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
-
- if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+
+ if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0)
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
}
}
- else {
- /* only include bones if visible */
- CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
-
- if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0)
- CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
- }
}
}
+ MEM_freeN(objects);
+
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
return 1;
}
@@ -251,53 +261,65 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones");
if (arm && arm->edbo) {
- /* Attention: X-Axis Mirroring is also handled here... */
- for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- /* first and foremost, bone must be visible and selected */
- if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) {
- /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
- * so that most users of this data don't need to explicitly check for it themselves.
- *
- * We need to make sure that these mirrored copies are not selected, otherwise some
- * bones will be operated on twice.
- */
- if (arm->flag & ARM_MIRROR_EDIT)
- flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
-
- /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
- if (selected_editable_bones) {
- /* only selected + editable */
- if (EBONE_EDITABLE(ebone)) {
+ uint objects_len;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint i = 0; i < objects_len; i++) {
+ Object *ob = objects[i];
+ arm = ob->data;
+
+ /* Attention: X-Axis Mirroring is also handled here... */
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ /* first and foremost, bone must be visible and selected */
+ if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) {
+ /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
+ * so that most users of this data don't need to explicitly check for it themselves.
+ *
+ * We need to make sure that these mirrored copies are not selected, otherwise some
+ * bones will be operated on twice.
+ */
+ if (arm->flag & ARM_MIRROR_EDIT)
+ flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+
+ /* if we're filtering for editable too, use the check for that instead, as it has selection check too */
+ if (selected_editable_bones) {
+ /* only selected + editable */
+ if (EBONE_EDITABLE(ebone)) {
+ CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
+
+ if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+ CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
+ }
+ else {
+ /* only include bones if selected */
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
-
+
if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
}
}
- else {
- /* only include bones if selected */
- CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
-
- if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
- CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
- }
}
}
+ MEM_freeN(objects);
+
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
return 1;
}
}
else if (CTX_data_equals(member, "visible_pose_bones")) {
Object *obpose = BKE_object_pose_armature_get(obact);
- bArmature *arm = (obpose) ? obpose->data : NULL;
- bPoseChannel *pchan;
-
- if (obpose && obpose->pose && arm) {
- for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) {
- /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
- if (PBONE_VISIBLE(arm, pchan->bone)) {
+ if (obpose && obpose->pose && obpose->data) {
+ if (obpose != obact) {
+ FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (obpose, pchan) {
CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
- }
+ } FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
+ }
+ else if (obact->mode & OB_MODE_POSE) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) {
+ FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (ob_iter, pchan) {
+ CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan);
+ } FOREACH_PCHAN_VISIBLE_IN_OBJECT_END;
+ } FOREACH_OBJECT_IN_MODE_END;
}
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
return 1;
@@ -305,16 +327,18 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "selected_pose_bones")) {
Object *obpose = BKE_object_pose_armature_get(obact);
- bArmature *arm = (obpose) ? obpose->data : NULL;
- bPoseChannel *pchan;
-
- if (obpose && obpose->pose && arm) {
- for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) {
- /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
- if (PBONE_VISIBLE(arm, pchan->bone)) {
- if (pchan->bone->flag & BONE_SELECTED)
- CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
- }
+ if (obpose && obpose->pose && obpose->data) {
+ if (obpose != obact) {
+ FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (obpose, pchan) {
+ CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
+ } FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
+ }
+ else if (obact->mode & OB_MODE_POSE) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) {
+ FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) {
+ CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan);
+ } FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
+ } FOREACH_OBJECT_IN_MODE_END;
}
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
return 1;
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index e65fd2701b4..6f7d7632a3c 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -76,190 +76,34 @@
/* ******************* screen vert, edge, area managing *********************** */
-static ScrVert *screen_addvert(bScreen *sc, short x, short y)
+static ScrVert *screen_addvert_ex(ScrAreaMap *area_map, short x, short y)
{
ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert");
sv->vec.x = x;
sv->vec.y = y;
- BLI_addtail(&sc->vertbase, sv);
+ BLI_addtail(&area_map->vertbase, sv);
return sv;
}
-
-static void sortscrvert(ScrVert **v1, ScrVert **v2)
+static ScrVert *screen_addvert(bScreen *sc, short x, short y)
{
- ScrVert *tmp;
-
- if (*v1 > *v2) {
- tmp = *v1;
- *v1 = *v2;
- *v2 = tmp;
- }
+ return screen_addvert_ex(AREAMAP_FROM_SCREEN(sc), x, y);
}
-static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
+static ScrEdge *screen_addedge_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2)
{
ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge");
-
- sortscrvert(&v1, &v2);
+
+ BKE_screen_sort_scrvert(&v1, &v2);
se->v1 = v1;
se->v2 = v2;
-
- BLI_addtail(&sc->edgebase, se);
- return se;
-}
-
-
-ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
-{
- ScrEdge *se;
-
- sortscrvert(&v1, &v2);
- for (se = sc->edgebase.first; se; se = se->next)
- if (se->v1 == v1 && se->v2 == v2)
- return se;
-
- return NULL;
-}
-
-void removedouble_scrverts(bScreen *sc)
-{
- ScrVert *v1, *verg;
- ScrEdge *se;
- ScrArea *sa;
-
- verg = sc->vertbase.first;
- while (verg) {
- if (verg->newv == NULL) { /* !!! */
- v1 = verg->next;
- while (v1) {
- if (v1->newv == NULL) { /* !?! */
- if (v1->vec.x == verg->vec.x && v1->vec.y == verg->vec.y) {
- /* printf("doublevert\n"); */
- v1->newv = verg;
- }
- }
- v1 = v1->next;
- }
- }
- verg = verg->next;
- }
-
- /* replace pointers in edges and faces */
- se = sc->edgebase.first;
- while (se) {
- if (se->v1->newv) se->v1 = se->v1->newv;
- if (se->v2->newv) se->v2 = se->v2->newv;
- /* edges changed: so.... */
- sortscrvert(&(se->v1), &(se->v2));
- se = se->next;
- }
- sa = sc->areabase.first;
- while (sa) {
- if (sa->v1->newv) sa->v1 = sa->v1->newv;
- if (sa->v2->newv) sa->v2 = sa->v2->newv;
- if (sa->v3->newv) sa->v3 = sa->v3->newv;
- if (sa->v4->newv) sa->v4 = sa->v4->newv;
- sa = sa->next;
- }
-
- /* remove */
- verg = sc->vertbase.first;
- while (verg) {
- v1 = verg->next;
- if (verg->newv) {
- BLI_remlink(&sc->vertbase, verg);
- MEM_freeN(verg);
- }
- verg = v1;
- }
+ BLI_addtail(&area_map->edgebase, se);
+ return se;
}
-
-void removenotused_scrverts(bScreen *sc)
-{
- ScrVert *sv, *svn;
- ScrEdge *se;
-
- /* we assume edges are ok */
-
- se = sc->edgebase.first;
- while (se) {
- se->v1->flag = 1;
- se->v2->flag = 1;
- se = se->next;
- }
-
- sv = sc->vertbase.first;
- while (sv) {
- svn = sv->next;
- if (sv->flag == 0) {
- BLI_remlink(&sc->vertbase, sv);
- MEM_freeN(sv);
- }
- else {
- sv->flag = 0;
- }
- sv = svn;
- }
-}
-
-void removedouble_scredges(bScreen *sc)
-{
- ScrEdge *verg, *se, *sn;
-
- /* compare */
- verg = sc->edgebase.first;
- while (verg) {
- se = verg->next;
- while (se) {
- sn = se->next;
- if (verg->v1 == se->v1 && verg->v2 == se->v2) {
- BLI_remlink(&sc->edgebase, se);
- MEM_freeN(se);
- }
- se = sn;
- }
- verg = verg->next;
- }
-}
-
-void removenotused_scredges(bScreen *sc)
+static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
{
- ScrEdge *se, *sen;
- ScrArea *sa;
- int a = 0;
-
- /* sets flags when edge is used in area */
- sa = sc->areabase.first;
- while (sa) {
- se = screen_findedge(sc, sa->v1, sa->v2);
- if (se == NULL) printf("error: area %d edge 1 doesn't exist\n", a);
- else se->flag = 1;
- se = screen_findedge(sc, sa->v2, sa->v3);
- if (se == NULL) printf("error: area %d edge 2 doesn't exist\n", a);
- else se->flag = 1;
- se = screen_findedge(sc, sa->v3, sa->v4);
- if (se == NULL) printf("error: area %d edge 3 doesn't exist\n", a);
- else se->flag = 1;
- se = screen_findedge(sc, sa->v4, sa->v1);
- if (se == NULL) printf("error: area %d edge 4 doesn't exist\n", a);
- else se->flag = 1;
- sa = sa->next;
- a++;
- }
- se = sc->edgebase.first;
- while (se) {
- sen = se->next;
- if (se->flag == 0) {
- BLI_remlink(&sc->edgebase, se);
- MEM_freeN(se);
- }
- else {
- se->flag = 0;
- }
- se = sen;
- }
+ return screen_addedge_ex(AREAMAP_FROM_SCREEN(sc), v1, v2);
}
bool scredge_is_horizontal(ScrEdge *se)
@@ -268,16 +112,16 @@ bool scredge_is_horizontal(ScrEdge *se)
}
/* need win size to make sure not to include edges along screen edge */
-ScrEdge *screen_find_active_scredge(const bScreen *sc,
- const int winsize_x, const int winsize_y,
- const int mx, const int my)
+ScrEdge *screen_area_map_find_active_scredge(
+ const ScrAreaMap *area_map,
+ const int winsize_x, const int winsize_y,
+ const int mx, const int my)
{
- ScrEdge *se;
int safety = U.widget_unit / 10;
-
- if (safety < 2) safety = 2;
-
- for (se = sc->edgebase.first; se; se = se->next) {
+
+ CLAMP_MIN(safety, 2);
+
+ for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
if (scredge_is_horizontal(se)) {
if (se->v1->vec.y > 0 && se->v1->vec.y < winsize_y - 1) {
short min, max;
@@ -299,27 +143,56 @@ ScrEdge *screen_find_active_scredge(const bScreen *sc,
}
}
}
-
+
return NULL;
}
+/* need win size to make sure not to include edges along screen edge */
+ScrEdge *screen_find_active_scredge(
+ const wmWindow *win, const bScreen *screen,
+ const int mx, const int my)
+{
+ /* Use layout size (screen excluding global areas) for screen-layout area edges */
+ const int screen_x = WM_window_screen_pixels_x(win), screen_y = WM_window_screen_pixels_y(win);
+ ScrEdge *se = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), screen_x, screen_y, mx, my);
+
+ if (!se) {
+ /* Use entire window size (screen including global areas) for global area edges */
+ const int win_x = WM_window_pixels_x(win), win_y = WM_window_pixels_y(win);
+ se = screen_area_map_find_active_scredge(&win->global_areas, win_x, win_y, mx, my);
+ }
+ return se;
+}
+
/* adds no space data */
-static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype)
+static ScrArea *screen_addarea_ex(
+ ScrAreaMap *area_map,
+ ScrVert *bottom_left, ScrVert *top_left, ScrVert *top_right, ScrVert *bottom_right,
+ short headertype, short spacetype)
{
ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea");
- sa->v1 = v1;
- sa->v2 = v2;
- sa->v3 = v3;
- sa->v4 = v4;
+
+ sa->v1 = bottom_left;
+ sa->v2 = top_left;
+ sa->v3 = top_right;
+ sa->v4 = bottom_right;
sa->headertype = headertype;
sa->spacetype = sa->butspacetype = spacetype;
-
- BLI_addtail(&sc->areabase, sa);
-
+
+ BLI_addtail(&area_map->areabase, sa);
+
return sa;
}
+static ScrArea *screen_addarea(
+ bScreen *sc,
+ ScrVert *left_bottom, ScrVert *left_top, ScrVert *right_top, ScrVert *right_bottom,
+ short headertype, short spacetype)
+{
+ return screen_addarea_ex(AREAMAP_FROM_SCREEN(sc), left_bottom, left_top, right_top, right_bottom,
+ headertype, spacetype);
+}
static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
{
@@ -452,9 +325,9 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
/* remove double vertices en edges */
if (merge)
- removedouble_scrverts(sc);
- removedouble_scredges(sc);
- removenotused_scredges(sc);
+ BKE_screen_remove_double_scrverts(sc);
+ BKE_screen_remove_double_scredges(sc);
+ BKE_screen_remove_unused_scredges(sc);
return newa;
}
@@ -509,7 +382,7 @@ void screen_data_copy(bScreen *to, bScreen *from)
for (se = to->edgebase.first; se; se = se->next) {
se->v1 = se->v1->newv;
se->v2 = se->v2->newv;
- sortscrvert(&(se->v1), &(se->v2));
+ BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
}
saf = from->areabase.first;
@@ -618,18 +491,17 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
}
screen_delarea(C, scr, sa2);
- removedouble_scrverts(scr);
-
+ BKE_screen_remove_double_scrverts(scr);
/* Update preview thumbnail */
BKE_icon_changed(scr->id.icon_id);
return 1;
}
-void select_connected_scredge(bScreen *sc, ScrEdge *edge)
+void select_connected_scredge(const wmWindow *win, ScrEdge *edge)
{
+ bScreen *sc = WM_window_get_active_screen(win);
ScrEdge *se;
- ScrVert *sv;
int oneselected;
char dir;
@@ -639,12 +511,10 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v';
else dir = 'h';
- sv = sc->vertbase.first;
- while (sv) {
+ ED_screen_verts_iter(win, sc, sv) {
sv->flag = 0;
- sv = sv->next;
}
-
+
edge->v1->flag = 1;
edge->v2->flag = 1;
@@ -672,8 +542,13 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
}
}
-/* test if screen vertices should be scaled */
-static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
+/**
+ * Test if screen vertices should be scaled and do if needed.
+ */
+static void screen_vertices_scale(
+ const wmWindow *win, bScreen *sc,
+ int window_size_x, int window_size_y,
+ int screen_size_x, int screen_size_y)
{
/* clamp Y size of header sized areas when expanding windows
* avoids annoying empty space around file menu */
@@ -682,7 +557,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
const int headery_init = ED_area_headersize();
ScrVert *sv = NULL;
ScrArea *sa;
- int winsize_x_prev, winsize_y_prev;
+ int screen_size_x_prev, screen_size_y_prev;
float facx, facy, tempf, min[2], max[2];
/* calculate size */
@@ -700,8 +575,8 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
sv->vec.y -= min[1];
}
- winsize_x_prev = (max[0] - min[0]) + 1;
- winsize_y_prev = (max[1] - min[1]) + 1;
+ screen_size_x_prev = (max[0] - min[0]) + 1;
+ screen_size_y_prev = (max[1] - min[1]) + 1;
#ifdef USE_HEADER_SIZE_CLAMP
@@ -709,14 +584,14 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
#define TEMP_TOP 2
/* if the window's Y axis grows, clamp header sized areas */
- if (winsize_y_prev < winsize_y) { /* growing? */
+ if (screen_size_y_prev < screen_size_y) { /* growing? */
const int headery_margin_max = headery_init + 4;
for (sa = sc->areabase.first; sa; sa = sa->next) {
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
sa->temp = 0;
if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) {
- if (sa->v2->vec.y == winsize_y_prev - 1) {
+ if (sa->v2->vec.y == screen_size_y_prev) {
if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) {
sa->temp = TEMP_TOP;
}
@@ -732,9 +607,9 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
#endif
- if (winsize_x_prev != winsize_x || winsize_y_prev != winsize_y) {
- facx = ((float)winsize_x - 1) / ((float)winsize_x_prev - 1);
- facy = ((float)winsize_y - 1) / ((float)winsize_y_prev - 1);
+ if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) {
+ facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1);
+ facy = ((float)screen_size_y) / ((float)screen_size_y_prev);
/* make sure it fits! */
for (sv = sc->vertbase.first; sv; sv = sv->next) {
@@ -745,20 +620,20 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
//sv->vec.x += AREAGRID - 1;
//sv->vec.x -= (sv->vec.x % AREAGRID);
- CLAMP(sv->vec.x, 0, winsize_x - 1);
+ CLAMP(sv->vec.x, 0, screen_size_x - 1);
tempf = ((float)sv->vec.y) * facy;
sv->vec.y = (short)(tempf + 0.5f);
//sv->vec.y += AREAGRID - 1;
//sv->vec.y -= (sv->vec.y % AREAGRID);
- CLAMP(sv->vec.y, 0, winsize_y - 1);
+ CLAMP(sv->vec.y, 0, screen_size_y);
}
}
#ifdef USE_HEADER_SIZE_CLAMP
- if (winsize_y_prev < winsize_y) { /* growing? */
+ if (screen_size_y_prev < screen_size_y) { /* growing? */
for (sa = sc->areabase.first; sa; sa = sa->next) {
ScrEdge *se = NULL;
@@ -772,9 +647,9 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
if (sa->temp == TEMP_TOP) {
/* lower edge */
const int yval = sa->v2->vec.y - headery_init;
- se = screen_findedge(sc, sa->v4, sa->v1);
+ se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
if (se != NULL) {
- select_connected_scredge(sc, se);
+ select_connected_scredge(win, se);
}
for (sv = sc->vertbase.first; sv; sv = sv->next) {
if (sv != sa->v2 && sv != sa->v3) {
@@ -787,9 +662,9 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
else {
/* upper edge */
const int yval = sa->v1->vec.y + headery_init;
- se = screen_findedge(sc, sa->v2, sa->v3);
+ se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
if (se != NULL) {
- select_connected_scredge(sc, se);
+ select_connected_scredge(win, se);
}
for (sv = sc->vertbase.first; sv; sv = sv->next) {
if (sv != sa->v1 && sv != sa->v4) {
@@ -818,16 +693,16 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
/* adjust headery if verts are along the edge of window */
if (sa->v1->vec.y > 0)
headery += U.pixelsize;
- if (sa->v2->vec.y < winsize_y - 1)
+ if (sa->v2->vec.y < screen_size_y)
headery += U.pixelsize;
if (sa->v2->vec.y - sa->v1->vec.y + 1 < headery) {
/* lower edge */
- ScrEdge *se = screen_findedge(sc, sa->v4, sa->v1);
+ ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
if (se && sa->v1 != sa->v2) {
int yval;
- select_connected_scredge(sc, se);
+ select_connected_scredge(win, se);
/* all selected vertices get the right offset */
yval = sa->v2->vec.y - headery + 1;
@@ -842,7 +717,17 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
}
}
}
-
+
+ /* Global areas have a fixed size that only changes with the DPI. Here we ensure that exactly this size is set.
+ * TODO Assumes global area to be top-aligned. Should be made more generic */
+ for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ /* width */
+ area->v1->vec.x = area->v2->vec.x = 0;
+ area->v3->vec.x = area->v4->vec.x = window_size_x - 1;
+ /* height */
+ area->v2->vec.y = area->v3->vec.y = window_size_y - 1;
+ area->v1->vec.y = area->v4->vec.y = area->v2->vec.y - ED_area_global_size_y(area);
+ }
}
@@ -853,7 +738,7 @@ static void region_cursor_set(wmWindow *win, bool swin_changed)
{
bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar == screen->active_region) {
if (swin_changed || (ar->type && ar->type->event_cursor)) {
@@ -915,20 +800,21 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* exception for bg mode, we only need the screen context */
if (!G.background) {
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
- ScrArea *sa;
-
+ const int window_size_x = WM_window_pixels_x(win);
+ const int window_size_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
+
/* header size depends on DPI, let's verify */
WM_window_set_dpi(win);
screen_refresh_headersizes();
-
- screen_test_scale(screen, winsize_x, winsize_y);
-
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+
+ screen_vertices_scale(win, screen, window_size_x, window_size_y, screen_size_x, screen_size_y);
+
+ ED_screen_areas_iter(win, screen, area) {
/* set spacetype and region callbacks, calls init() */
/* sets subwindows for regions, adds handlers */
- ED_area_initialize(wm, win, sa);
+ ED_area_initialize(wm, win, area);
}
/* wake up animtimer */
@@ -946,6 +832,36 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
screen->context = ed_screen_context;
}
+static bool screen_regions_need_size_refresh(
+ const wmWindow *win, const bScreen *screen)
+{
+ ED_screen_areas_iter(win, screen, area) {
+ if (area->flag & AREA_FLAG_REGION_SIZE_UPDATE) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static void screen_refresh_region_sizes_only(
+ wmWindowManager *wm, wmWindow *win,
+ bScreen *screen)
+{
+ const int window_size_x = WM_window_pixels_x(win);
+ const int window_size_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
+
+ screen_vertices_scale(win, screen, window_size_x, window_size_y, screen_size_x, screen_size_y);
+
+ ED_screen_areas_iter(win, screen, area) {
+ screen_area_update_region_sizes(wm, win, area);
+ /* XXX hack to force drawing */
+ ED_area_tag_redraw(area);
+ }
+}
+
/* file read, set all screens, ... */
void ED_screens_initialize(wmWindowManager *wm)
{
@@ -956,8 +872,21 @@ void ED_screens_initialize(wmWindowManager *wm)
WM_window_set_active_workspace(win, G.main->workspaces.first);
}
+ if (BLI_listbase_is_empty(&win->global_areas.areabase)) {
+ ED_screen_global_areas_create(win);
+ }
+ ED_screen_refresh(wm, win);
+ }
+}
+
+void ED_screen_ensure_updated(wmWindowManager *wm, wmWindow *win, bScreen *screen)
+{
+ if (screen->do_refresh) {
ED_screen_refresh(wm, win);
}
+ else if (screen_regions_need_size_refresh(win, screen)) {
+ screen_refresh_region_sizes_only(wm, win, screen);
+ }
}
@@ -1030,11 +959,15 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
screen->active_region = NULL;
- for (ar = screen->regionbase.first; ar; ar = ar->next)
+ for (ar = screen->regionbase.first; ar; ar = ar->next) {
ED_region_exit(C, ar);
-
- for (sa = screen->areabase.first; sa; sa = sa->next)
+ }
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_area_exit(C, sa);
+ }
+ for (sa = window->global_areas.areabase.first; sa; sa = sa->next) {
ED_area_exit(C, sa);
+ }
/* mark it available for use for other windows */
screen->winid = 0;
@@ -1056,9 +989,6 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
static void screen_cursor_set(wmWindow *win, const wmEvent *event)
{
const bScreen *screen = WM_window_get_active_screen(win);
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
-
AZone *az = NULL;
ScrArea *sa;
@@ -1077,8 +1007,8 @@ static void screen_cursor_set(wmWindow *win, const wmEvent *event)
}
}
else {
- ScrEdge *actedge = screen_find_active_scredge(screen, winsize_x, winsize_y, event->x, event->y);
-
+ ScrEdge *actedge = screen_find_active_scredge(win, screen, event->x, event->y);
+
if (actedge) {
if (scredge_is_horizontal(actedge))
WM_cursor_set(win, CURSOR_Y_MOVE);
@@ -1099,15 +1029,19 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
bScreen *scr = WM_window_get_active_screen(win);
if (scr) {
- ScrArea *sa;
+ ScrArea *sa = NULL;
ARegion *ar;
ARegion *old_ar = scr->active_region;
- for (sa = scr->areabase.first; sa; sa = sa->next) {
- if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax)
- if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax)
- if (NULL == is_in_area_actionzone(sa, &event->x))
+ ED_screen_areas_iter(win, scr, area_iter) {
+ if (event->x > area_iter->totrct.xmin && event->x < area_iter->totrct.xmax) {
+ if (event->y > area_iter->totrct.ymin && event->y < area_iter->totrct.ymax) {
+ if (is_in_area_actionzone(area_iter, &event->x) == NULL) {
+ sa = area_iter;
break;
+ }
+ }
+ }
}
if (sa) {
/* make overlap active when mouse over */
@@ -1124,17 +1058,21 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
/* check for redraw headers */
if (old_ar != scr->active_region) {
- for (sa = scr->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, scr, area_iter) {
bool do_draw = false;
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar == old_ar || ar == scr->active_region)
+ for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
+ if (ar == old_ar || ar == scr->active_region) {
do_draw = true;
+ }
+ }
if (do_draw) {
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar->regiontype == RGN_TYPE_HEADER)
+ for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_HEADER) {
ED_region_tag_redraw(ar);
+ }
+ }
}
}
}
@@ -1179,6 +1117,47 @@ int ED_screen_area_active(const bContext *C)
return 0;
}
+void ED_screen_global_topbar_area_create(wmWindow *win, const bScreen *screen)
+{
+ if (screen->temp == 0) {
+ SpaceType *st = BKE_spacetype_from_id(SPACE_TOPBAR);
+ SpaceLink *sl = st->new(NULL);
+ ScrArea *sa;
+ const short size_y = 2.25 * HEADERY;
+ const int minx = 0, maxx = WM_window_pixels_x(win) - 1;
+ const int maxy = WM_window_pixels_y(win) - 1, miny = maxy - size_y;
+
+ ScrVert *bottom_left = screen_addvert_ex(&win->global_areas, minx, miny);
+ ScrVert *top_left = screen_addvert_ex(&win->global_areas, minx, maxy);
+ ScrVert *top_right = screen_addvert_ex(&win->global_areas, maxx, maxy);
+ ScrVert *bottom_right = screen_addvert_ex(&win->global_areas, maxx, miny);
+ screen_addedge_ex(&win->global_areas, bottom_left, top_left);
+ screen_addedge_ex(&win->global_areas, top_left, top_right);
+ screen_addedge_ex(&win->global_areas, top_right, bottom_right);
+ screen_addedge_ex(&win->global_areas, bottom_right, bottom_left);
+
+ sa = screen_addarea_ex(&win->global_areas, bottom_left, top_left, top_right, bottom_right,
+ HEADERTOP, SPACE_TOPBAR);
+ sa->regionbase = sl->regionbase;
+
+ /* Data specific to global areas. */
+ sa->global = MEM_callocN(sizeof(*sa->global), __func__);
+ sa->global->cur_fixed_height = size_y;
+ sa->global->size_max = size_y;
+ sa->global->size_min = HEADERY;
+
+ BLI_addhead(&sa->spacedata, sl);
+ BLI_listbase_clear(&sl->regionbase);
+ }
+ /* Do not create more area types here! Function is called on file load (wm_window_ghostwindows_ensure). TODO */
+}
+
+void ED_screen_global_areas_create(wmWindow *win)
+{
+ const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
+ ED_screen_global_topbar_area_create(win, screen);
+}
+
/* -------------------------------------------------------------------- */
/* Screen changing */
@@ -1331,7 +1310,6 @@ void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new
ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
{
wmWindow *win = CTX_wm_window(C);
- bScreen *screen = CTX_wm_screen(C);
ScrArea *newsa = NULL;
if (!sa || sa->full == NULL) {
@@ -1339,18 +1317,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
}
if (!newsa) {
- if (sa->full && (screen->state == SCREENMAXIMIZED)) {
- /* if this has been called from the temporary info header generated in
- * temp fullscreen layouts, find the correct fullscreen area to change
- * to create a new space inside */
- for (newsa = screen->areabase.first; newsa; newsa = newsa->next) {
- if (!(sa->flag & AREA_TEMP_INFO))
- break;
- }
- }
- else {
- newsa = sa;
- }
+ newsa = sa;
}
BLI_assert(newsa);
@@ -1471,10 +1438,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
/* clear full screen state */
old->full = NULL;
- old->flag &= ~AREA_TEMP_INFO;
}
- sa->flag &= ~AREA_TEMP_INFO;
sa->full = NULL;
if (fullsa == NULL) {
@@ -1512,6 +1477,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
ScrArea *newa;
char newname[MAX_ID_NAME - 2];
+ BLI_assert(ELEM(state, SCREENMAXIMIZED, SCREENFULL));
+
oldscreen = WM_window_get_active_screen(win);
oldscreen->state = state;
@@ -1530,50 +1497,30 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
/* use random area when we have no active one, e.g. when the
* mouse is outside of the window and we open a file browser */
- if (!sa)
+ if (!sa) {
sa = oldscreen->areabase.first;
-
- if (state == SCREENMAXIMIZED) {
- /* returns the top small area */
- newa = area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1);
- ED_area_newspace(C, newa, SPACE_INFO, false);
-
- /* copy area */
- newa = newa->prev;
- ED_area_data_swap(newa, sa);
- sa->flag |= AREA_TEMP_INFO;
-
- sa->full = oldscreen;
- newa->full = oldscreen;
- newa->next->full = oldscreen; // XXX
}
- else if (state == SCREENFULL) {
- newa = (ScrArea *)sc->areabase.first;
- /* copy area */
- ED_area_data_swap(newa, sa);
- newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */
+ newa = (ScrArea *)sc->areabase.first;
+
+ /* copy area */
+ ED_area_data_swap(newa, sa);
+ newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */
+ if (state == SCREENFULL) {
/* temporarily hide the side panels/header */
for (ar = newa->regionbase.first; ar; ar = ar->next) {
ar->flagfullscreen = ar->flag;
- if (ELEM(ar->regiontype,
- RGN_TYPE_UI,
- RGN_TYPE_HEADER,
- RGN_TYPE_TOOLS))
- {
+ if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_HEADER, RGN_TYPE_TOOLS)){
ar->flag |= RGN_FLAG_HIDDEN;
}
}
-
- sa->full = oldscreen;
- newa->full = oldscreen;
- }
- else {
- BLI_assert(false);
}
+ sa->full = oldscreen;
+ newa->full = oldscreen;
+
ED_screen_change(C, sc);
}
@@ -1661,7 +1608,7 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
if (sa)
spacetype = sa->spacetype;
- sad->from_anim_edit = (ELEM(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_TIME));
+ sad->from_anim_edit = (ELEM(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA));
screen->animtimer->customdata = sad;
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index 6d0a9f1e7d0..045e5ee6b48 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -44,6 +44,7 @@ struct Main;
/* area.c */
void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free);
void ED_area_data_swap(ScrArea *sa1, ScrArea *sa2);
+void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area);
void region_toggle_hidden(struct bContext *C, ARegion *ar, const bool do_fade);
/* screen_edit.c */
@@ -52,20 +53,19 @@ void screen_data_copy(bScreen *to, bScreen *from);
void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new);
void screen_change_update(struct bContext *C, wmWindow *win, bScreen *sc);
bScreen *screen_change_prepare(bScreen *screen_old, bScreen *screen_new, struct Main *bmain, struct bContext *C, wmWindow *win);
-ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2);
ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge);
int screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2);
int area_getorientation(ScrArea *sa, ScrArea *sb);
-void select_connected_scredge(bScreen *sc, ScrEdge *edge);
+void select_connected_scredge(const wmWindow *win, ScrEdge *edge);
-void removenotused_scrverts(bScreen *sc);
-void removedouble_scrverts(bScreen *sc);
-void removedouble_scredges(bScreen *sc);
-void removenotused_scredges(bScreen *sc);
bool scredge_is_horizontal(ScrEdge *se);
-ScrEdge *screen_find_active_scredge(const bScreen *sc,
- const int winsize_x, const int winsize_y,
- const int mx, const int my);
+ScrEdge *screen_area_map_find_active_scredge(
+ const struct ScrAreaMap *area_map,
+ const int winsize_x, const int winsize_y,
+ const int mx, const int my);
+ScrEdge *screen_find_active_scredge(
+ const wmWindow *win, const bScreen *screen,
+ const int mx, const int my);
struct AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 898010858b9..d7573c6ef81 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -198,7 +198,7 @@ int ED_operator_animview_active(bContext *C)
{
if (ED_operator_areaactive(C)) {
SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C);
- if (sl && (ELEM(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_IPO, SPACE_TIME)))
+ if (sl && (ELEM(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_IPO)))
return true;
}
@@ -206,11 +206,6 @@ int ED_operator_animview_active(bContext *C)
return 0;
}
-int ED_operator_timeline_active(bContext *C)
-{
- return ed_spacetype_test(C, SPACE_TIME);
-}
-
int ED_operator_outliner_active(bContext *C)
{
return ed_spacetype_test(C, SPACE_OUTLINER);
@@ -289,11 +284,6 @@ int ED_operator_nla_active(bContext *C)
return ed_spacetype_test(C, SPACE_NLA);
}
-int ED_operator_logic_active(bContext *C)
-{
- return ed_spacetype_test(C, SPACE_LOGIC);
-}
-
int ED_operator_info_active(bContext *C)
{
return ed_spacetype_test(C, SPACE_INFO);
@@ -805,8 +795,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
sActionzoneData *sad = op->customdata;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
switch (event->type) {
case MOUSEMOVE:
@@ -830,7 +820,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* once we drag outside the actionzone, register a gesture
* check we're not on an edge so join finds the other area */
is_gesture = ((is_in_area_actionzone(sad->sa1, &event->x) != sad->az) &&
- (screen_find_active_scredge(sc, winsize_x, winsize_y, event->x, event->y) == NULL));
+ (screen_area_map_find_active_scredge(
+ AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y) == NULL));
}
else {
const int delta_min = 1;
@@ -1063,6 +1054,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
layout_new = ED_workspace_layout_add(workspace, newwin, BKE_workspace_layout_name_get(layout_old));
newsc = BKE_workspace_layout_screen_get(layout_new);
WM_window_set_active_layout(newwin, workspace, layout_new);
+ ED_screen_global_areas_create(newwin);
/* copy area to new screen */
ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true);
@@ -1130,25 +1122,73 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot)
*/
typedef struct sAreaMoveData {
- int bigger, smaller, origval;
+ int bigger, smaller, origval, step;
char dir;
- bool do_snap;
+ enum AreaMoveSnapType {
+ /* Snapping disabled */
+ SNAP_NONE = 0,
+ /* Snap to mid-point and adjacent edges. */
+ SNAP_MIDPOINT_AND_ADJACENT,
+ /* Snap to either bigger or smaller, nothing in-between (used for
+ * global areas). This has priority over other snap types, if it is
+ * used, toggling SNAP_MIDPOINT_AND_ADJACENT doesn't work. */
+ SNAP_BIGGER_SMALLER_ONLY,
+ } snap_type;
} sAreaMoveData;
/* helper call to move area-edge, sets limits
* need window size in order to get correct limits */
-static void area_move_set_limits(bScreen *sc, int dir,
- const int winsize_x, const int winsize_y,
- int *bigger, int *smaller)
+static void area_move_set_limits(
+ wmWindow *win, bScreen *sc, int dir,
+ const int winsize_x, const int winsize_y,
+ int *bigger, int *smaller,
+ bool *use_bigger_smaller_snap)
{
- ScrArea *sa;
int areaminy = ED_area_headersize();
int areamin;
-
+
/* we check all areas and test for free space with MINSIZE */
*bigger = *smaller = 100000;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
+
+ if (use_bigger_smaller_snap != NULL) {
+ *use_bigger_smaller_snap = false;
+ for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ const int size_min = round_fl_to_int(area->global->size_min * UI_DPI_FAC);
+ const int size_max = round_fl_to_int(area->global->size_max * UI_DPI_FAC);
+
+ /* logic here is only tested for lower edge :) */
+ /* left edge */
+ if ((area->v1->editflag && area->v2->editflag)) {
+ *smaller = area->v4->vec.x - size_max;
+ *bigger = area->v4->vec.x - size_min;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ /* top edge */
+ else if ((area->v2->editflag && area->v3->editflag)) {
+ *smaller = area->v1->vec.y + size_min;
+ *bigger = area->v1->vec.y + size_max;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ /* right edge */
+ else if ((area->v3->editflag && area->v4->editflag)) {
+ *smaller = area->v1->vec.x + size_min;
+ *bigger = area->v1->vec.x + size_max;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ /* lower edge */
+ else if ((area->v4->editflag && area->v1->editflag)) {
+ *smaller = area->v2->vec.y - size_max;
+ *bigger = area->v2->vec.y - size_min;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ }
+ }
+
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
if (dir == 'h') {
int y1;
areamin = areaminy;
@@ -1194,9 +1234,8 @@ static int area_move_init(bContext *C, wmOperator *op)
wmWindow *win = CTX_wm_window(C);
ScrEdge *actedge;
sAreaMoveData *md;
- ScrVert *v1;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
int x, y;
/* required properties */
@@ -1204,7 +1243,7 @@ static int area_move_init(bContext *C, wmOperator *op)
y = RNA_int_get(op->ptr, "y");
/* setup */
- actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y);
+ actedge = screen_find_active_scredge(win, sc, x, y);
if (actedge == NULL) return 0;
md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
@@ -1214,23 +1253,33 @@ static int area_move_init(bContext *C, wmOperator *op)
if (md->dir == 'h') md->origval = actedge->v1->vec.y;
else md->origval = actedge->v1->vec.x;
- select_connected_scredge(sc, actedge);
- /* now all vertices with 'flag==1' are the ones that can be moved. Move this to editflag */
- for (v1 = sc->vertbase.first; v1; v1 = v1->next)
+ select_connected_scredge(win, actedge);
+ /* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */
+ ED_screen_verts_iter(win, sc, v1) {
v1->editflag = v1->flag;
-
- area_move_set_limits(sc, md->dir, winsize_x, winsize_y, &md->bigger, &md->smaller);
-
+ }
+
+ bool use_bigger_smaller_snap = false;
+ area_move_set_limits(win, sc, md->dir, screen_size_x, screen_size_y,
+ &md->bigger, &md->smaller,
+ &use_bigger_smaller_snap);
+
+ md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_NONE;
+
return 1;
}
static int area_snap_calc_location(
- const bScreen *sc, const int delta,
- const int origval, const int dir,
+ const bScreen *sc, const enum AreaMoveSnapType snap_type,
+ const int delta, const int origval, const int dir,
const int bigger, const int smaller)
{
- int final_loc = -1;
+ BLI_assert(snap_type != SNAP_NONE);
+ if (snap_type == SNAP_BIGGER_SMALLER_ONLY) {
+ return ((origval + delta) >= bigger) ? bigger : smaller;
+ }
+ int final_loc = -1;
const int m_loc = origval + delta;
const int axis = (dir == 'v') ? 0 : 1;
int snap_dist;
@@ -1274,29 +1323,29 @@ static void area_move_apply_do(
const bContext *C, int delta,
const int origval, const int dir,
const int bigger, const int smaller,
- const bool do_snap)
+ const enum AreaMoveSnapType snap_type)
{
+ wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
- ScrVert *v1;
bool doredraw = false;
CLAMP(delta, -smaller, bigger);
short final_loc = -1;
- if (do_snap) {
- final_loc = area_snap_calc_location(sc, delta, origval, dir, bigger, smaller);
- }
- else {
+ if (snap_type == SNAP_NONE) {
final_loc = origval + delta;
if (delta != bigger && delta != -smaller) {
final_loc -= (final_loc % AREAGRID);
}
}
+ else {
+ final_loc = area_snap_calc_location(sc, snap_type, delta, origval, dir, bigger, smaller);
+ }
BLI_assert(final_loc != -1);
short axis = (dir == 'v') ? 0 : 1;
- for (v1 = sc->vertbase.first; v1; v1 = v1->next) {
+ ED_screen_verts_iter(win, sc, v1) {
if (v1->editflag) {
short oldval = (&v1->vec.x)[axis];
(&v1->vec.x)[axis] = final_loc;
@@ -1311,11 +1360,23 @@ static void area_move_apply_do(
/* only redraw if we actually moved a screen vert, for AREAGRID */
if (doredraw) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ bool redraw_all = false;
+ ED_screen_areas_iter(win, sc, sa) {
if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag) {
+ if (ED_area_is_global(sa)) {
+ sa->global->cur_fixed_height = round_fl_to_int((sa->v2->vec.y - sa->v1->vec.y) / UI_DPI_FAC);
+ sc->do_refresh = true;
+ redraw_all = true;
+ }
+ ED_area_tag_redraw(sa);
+ }
+ }
+ if (redraw_all) {
+ ED_screen_areas_iter(win, sc, sa) {
ED_area_tag_redraw(sa);
}
}
+
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */
/* Update preview thumbnail */
BKE_icon_changed(sc->id.icon_id);
@@ -1327,7 +1388,7 @@ static void area_move_apply(bContext *C, wmOperator *op)
sAreaMoveData *md = op->customdata;
int delta = RNA_int_get(op->ptr, "delta");
- area_move_apply_do(C, delta, md->origval, md->dir, md->bigger, md->smaller, md->do_snap);
+ area_move_apply_do(C, delta, md->origval, md->dir, md->bigger, md->smaller, md->snap_type);
}
static void area_move_exit(bContext *C, wmOperator *op)
@@ -1337,8 +1398,8 @@ static void area_move_exit(bContext *C, wmOperator *op)
op->customdata = NULL;
/* this makes sure aligned edges will result in aligned grabbing */
- removedouble_scrverts(CTX_wm_screen(C));
- removedouble_scredges(CTX_wm_screen(C));
+ BKE_screen_remove_double_scrverts(CTX_wm_screen(C));
+ BKE_screen_remove_double_scredges(CTX_wm_screen(C));
}
static int area_move_exec(bContext *C, wmOperator *op)
@@ -1406,10 +1467,14 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
case KM_MODAL_SNAP_ON:
- md->do_snap = true;
+ if (md->snap_type == SNAP_NONE) {
+ md->snap_type = SNAP_MIDPOINT_AND_ADJACENT;
+ }
break;
case KM_MODAL_SNAP_OFF:
- md->do_snap = false;
+ if (md->snap_type == SNAP_MIDPOINT_AND_ADJACENT) {
+ md->snap_type = SNAP_NONE;
+ }
break;
}
break;
@@ -1566,16 +1631,16 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb)
ScrVert *sbv4 = sb->v4;
if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */
- return screen_findedge(screen, sav1, sav2);
+ return BKE_screen_find_edge(screen, sav1, sav2);
}
else if (sav2 == sbv1 && sav3 == sbv4) { /* sa to bottom of sb = N */
- return screen_findedge(screen, sav2, sav3);
+ return BKE_screen_find_edge(screen, sav2, sav3);
}
else if (sav3 == sbv2 && sav4 == sbv1) { /* sa to left of sb = E */
- return screen_findedge(screen, sav3, sav4);
+ return BKE_screen_find_edge(screen, sav3, sav4);
}
else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/
- return screen_findedge(screen, sav1, sav4);
+ return BKE_screen_find_edge(screen, sav1, sav4);
}
return NULL;
@@ -1641,8 +1706,8 @@ static void area_split_exit(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
/* this makes sure aligned edges will result in aligned grabbing */
- removedouble_scrverts(CTX_wm_screen(C));
- removedouble_scredges(CTX_wm_screen(C));
+ BKE_screen_remove_double_scrverts(CTX_wm_screen(C));
+ BKE_screen_remove_double_scredges(CTX_wm_screen(C));
}
static void area_split_preview_update_cursor(bContext *C, wmOperator *op)
@@ -1658,8 +1723,8 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
sAreaSplitData *sd;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
int dir;
/* no full window splitting allowed */
@@ -1712,7 +1777,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
else
y = event->x;
- actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y);
+ actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, x, y);
if (actedge == NULL)
return OPERATOR_CANCELLED;
@@ -1732,7 +1797,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* do the split */
if (area_split_apply(C, op)) {
- area_move_set_limits(sc, dir, winsize_x, winsize_y, &sd->bigger, &sd->smaller);
+ area_move_set_limits(win, sc, dir, screen_size_x, screen_size_y, &sd->bigger, &sd->smaller, NULL);
/* add temp handler for edge move or cancel */
WM_event_add_modal_handler(C, op);
@@ -1773,6 +1838,7 @@ static void area_split_cancel(bContext *C, wmOperator *op)
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
if (sd->previewmode) {
+ /* pass */
}
else {
if (screen_area_join(C, CTX_wm_screen(C), sd->sarea, sd->narea)) {
@@ -1849,10 +1915,11 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (sd->previewmode == 0) {
if (sd->do_snap) {
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->bigger, sd->smaller);
+ CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ sd->bigger, sd->smaller);
sd->delta = snap_loc - sd->origval;
}
- area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, false);
+ area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, SNAP_NONE);
}
else {
if (sd->sarea) {
@@ -1876,7 +1943,8 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1;
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->origmin + sd->origsize, -sd->origmin);
+ CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ sd->origmin + sd->origsize, -sd->origmin);
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0;
sd->delta = snap_loc - sd->origval;
@@ -2216,7 +2284,7 @@ static void areas_do_frame_follow(bContext *C, bool middle)
/* do follow here if editor type supports it */
if ((scr->redraws_flag & TIME_FOLLOW)) {
if ((ar->regiontype == RGN_TYPE_WINDOW &&
- ELEM(sa->spacetype, SPACE_SEQ, SPACE_TIME, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) ||
+ ELEM(sa->spacetype, SPACE_SEQ, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) ||
(sa->spacetype == SPACE_CLIP && ar->regiontype == RGN_TYPE_PREVIEW))
{
float w = BLI_rctf_size_x(&ar->v2d.cur);
@@ -2592,6 +2660,14 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int screen_maximize_area_poll(bContext *C)
+{
+ const bScreen *screen = CTX_wm_screen(C);
+ const ScrArea *area = CTX_wm_area(C);
+ return ED_operator_areaactive(C) &&
+ ((screen->state != SCREENNORMAL) || (area->spacetype != SPACE_TOPBAR));
+}
+
static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -2601,7 +2677,7 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
ot->idname = "SCREEN_OT_screen_full_area";
ot->exec = screen_maximize_area_exec;
- ot->poll = ED_operator_areaactive;
+ ot->poll = screen_maximize_area_poll;
ot->flag = 0;
prop = RNA_def_boolean(ot->srna, "use_hide_panels", false, "Hide Panels", "Hide all the panels");
@@ -2734,9 +2810,9 @@ static void area_join_exit(bContext *C, wmOperator *op)
}
/* this makes sure aligned edges will result in aligned grabbing */
- removedouble_scredges(CTX_wm_screen(C));
- removenotused_scredges(CTX_wm_screen(C));
- removenotused_scrverts(CTX_wm_screen(C));
+ BKE_screen_remove_double_scredges(CTX_wm_screen(C));
+ BKE_screen_remove_unused_scredges(CTX_wm_screen(C));
+ BKE_screen_remove_unused_scrverts(CTX_wm_screen(C));
}
static int area_join_exec(bContext *C, wmOperator *op)
@@ -2911,10 +2987,11 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
uiLayout *layout;
PointerRNA ptr;
ScrEdge *actedge;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
- actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, event->x, event->y);
+ actedge = screen_area_map_find_active_scredge(
+ AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y);
if (actedge == NULL) return OPERATOR_CANCELLED;
@@ -3318,6 +3395,18 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
+static int region_flip_poll(bContext *C)
+{
+ ScrArea *area = CTX_wm_area(C);
+
+ /* don't flip anything around in topbar */
+ if (area->spacetype == SPACE_TOPBAR) {
+ CTX_wm_operator_poll_msg_set(C, "Flipping regions in the Top-bar is not allowed");
+ return 0;
+ }
+
+ return ED_operator_areaactive(C);
+}
static void SCREEN_OT_region_flip(wmOperatorType *ot)
{
@@ -3328,7 +3417,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot)
/* api callbacks */
ot->exec = region_flip_exec;
- ot->poll = ED_operator_areaactive;
+ ot->poll = region_flip_poll;
ot->flag = 0;
}
@@ -3421,12 +3510,11 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
uiItemS(layout);
- /* file browser should be fullscreen all the time, but other regions can be maximized/restored... */
- if (sa->spacetype != SPACE_FILE) {
- if (sa->full)
- uiItemO(layout, IFACE_("Tile Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
- else
- uiItemO(layout, IFACE_("Maximize Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
+ /* file browser should be fullscreen all the time, topbar should
+ * never be. But other regions can be maximized/restored... */
+ if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
+ const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
+ uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area");
}
}
@@ -3486,13 +3574,14 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws,
return 1;
break;
case SPACE_IPO:
- case SPACE_ACTION:
case SPACE_NLA:
if ((redraws & TIME_ALL_ANIM_WIN) || from_anim_edit)
return 1;
break;
- case SPACE_TIME:
- /* if only 1 window or 3d windows, we do timeline too */
+ case SPACE_ACTION:
+ /* if only 1 window or 3d windows, we do timeline too
+ * NOTE: Now we do do action editor in all these cases, since timeline is here
+ */
if ((redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) || from_anim_edit)
return 1;
break;
@@ -3543,7 +3632,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws,
return 1;
}
else if (regiontype == RGN_TYPE_HEADER) {
- if (spacetype == SPACE_TIME)
+ if (spacetype == SPACE_ACTION)
return 1;
}
else if (regiontype == RGN_TYPE_PREVIEW) {
@@ -3705,7 +3794,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
/* do follow here if editor type supports it */
if ((sad->redraws & TIME_FOLLOW)) {
if ((ar->regiontype == RGN_TYPE_WINDOW &&
- ELEM(sa->spacetype, SPACE_SEQ, SPACE_TIME, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) ||
+ ELEM(sa->spacetype, SPACE_SEQ, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) ||
(sa->spacetype == SPACE_CLIP && ar->regiontype == RGN_TYPE_PREVIEW))
{
float w = BLI_rctf_size_x(&ar->v2d.cur);
@@ -3808,7 +3897,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
else {
- int refresh = SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */
+ int refresh = SPACE_ACTION; /* these settings are currently only available from a menu in the TimeLine */
if (mode == 1) /* XXX only play audio forwards!? */
BKE_sound_play_scene(scene);
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 69891a727d4..2c1cbc3d21d 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -275,7 +275,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
static int screenshot_poll(bContext *C)
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index ace3f17542e..c8aa4560dc4 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -76,12 +76,11 @@
WorkSpace *ED_workspace_add(
Main *bmain, const char *name, Scene *scene,
- ViewLayer *act_view_layer, ViewRender *view_render)
+ ViewLayer *act_view_layer)
{
WorkSpace *workspace = BKE_workspace_add(bmain, name);
BKE_workspace_view_layer_set(workspace, act_view_layer, scene);
- BKE_viewrender_copy(&workspace->view_render, view_render);
return workspace;
}
@@ -223,12 +222,7 @@ WorkSpace *ED_workspace_duplicate(
Scene *scene = WM_window_get_active_scene(win);
WorkSpace *workspace_new = ED_workspace_add(
bmain, workspace_old->id.name + 2, scene,
- BKE_workspace_view_layer_get(workspace_old, scene),
- &workspace_old->view_render);
- ListBase *transform_orientations_old = BKE_workspace_transform_orientations_get(workspace_old);
- ListBase *transform_orientations_new = BKE_workspace_transform_orientations_get(workspace_new);
-
- BLI_duplicatelist(transform_orientations_new, transform_orientations_old);
+ BKE_workspace_view_layer_get(workspace_old, scene));
workspace_new->tool = workspace_old->tool;
@@ -319,11 +313,9 @@ static void WORKSPACE_OT_workspace_duplicate(wmOperatorType *ot)
static int workspace_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain = CTX_data_main(C);
- wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
- ED_workspace_delete(WM_window_get_active_workspace(win), bmain, C, wm);
+ WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_DELETE, WM_window_get_active_workspace(win));
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c
index d84df160125..a6f991d4bbe 100644
--- a/source/blender/editors/screen/workspace_layout_edit.c
+++ b/source/blender/editors/screen/workspace_layout_edit.c
@@ -50,10 +50,10 @@ WorkSpaceLayout *ED_workspace_layout_add(
wmWindow *win,
const char *name)
{
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
- bScreen *screen = screen_add(name, winsize_x, winsize_y);
+ bScreen *screen = screen_add(name, screen_size_x, screen_size_y);
WorkSpaceLayout *layout = BKE_workspace_layout_add(workspace, screen, name);
return layout;
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 4d3c8fe4d5c..4dd770d79b9 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -362,7 +362,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
Object *ob = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Mesh *me = ob->data;
PartialVisAction action;
PartialVisArea area;
@@ -374,8 +374,6 @@ static int hide_show_exec(bContext *C, wmOperator *op)
rcti rect;
int totnode, i;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* read operator properties */
action = RNA_enum_get(op->ptr, "action");
area = RNA_enum_get(op->ptr, "area");
@@ -383,7 +381,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
clip_planes_from_rect(C, clip_planes, &rect);
- dm = mesh_get_derived_final(&eval_ctx, CTX_data_scene(C), ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(depsgraph, CTX_data_scene(C), ob, CD_MASK_BAREMESH);
pbvh = dm->getPBVH(ob, dm);
ob->sculpt->pbvh = pbvh;
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index ae26de8b269..dbb12282d0a 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -78,7 +78,6 @@
#include "RNA_define.h"
#include "GPU_draw.h"
-#include "GPU_buffers.h"
#include "GPU_immediate.h"
#include "BIF_gl.h"
@@ -1121,7 +1120,6 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
// ED_workspace_object_mode_sync_from_object(wm, workspace, ob);
- GPU_drawobject_free(ob->derivedFinal);
WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index c81a59b045f..cacb75b2668 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -227,7 +227,7 @@ typedef struct ProjPaintState {
View3D *v3d;
RegionView3D *rv3d;
ARegion *ar;
- const Depsgraph *depsgraph;
+ Depsgraph *depsgraph;
Scene *scene;
int source; /* PROJ_SRC_**** */
@@ -283,7 +283,6 @@ typedef struct ProjPaintState {
bool do_backfacecull; /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */
bool do_mask_normal; /* mask out pixels based on their normals */
bool do_mask_cavity; /* mask out pixels based on cavity */
- bool do_new_shading_nodes; /* cache BKE_scene_use_new_shading_nodes value */
float normal_angle; /* what angle to mask at */
float normal_angle__cos; /* cos(normal_angle), faster to compare */
float normal_angle_inner;
@@ -2492,8 +2491,7 @@ static bool IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot
static void project_paint_face_init(
const ProjPaintState *ps,
const int thread_index, const int bucket_index, const int tri_index, const int image_index,
- const rctf *clip_rect, const rctf *bucket_bounds, ImBuf *ibuf, ImBuf **tmpibuf,
- const bool clamp_u, const bool clamp_v)
+ const rctf *clip_rect, const rctf *bucket_bounds, ImBuf *ibuf, ImBuf **tmpibuf)
{
/* Projection vars, to get the 3D locations into screen space */
MemArena *arena = ps->arena_mt[thread_index];
@@ -2600,17 +2598,6 @@ static void project_paint_face_init(
#endif
if (pixel_bounds_array(uv_clip, &bounds_px, ibuf->x, ibuf->y, uv_clip_tot)) {
-
- if (clamp_u) {
- CLAMP(bounds_px.xmin, 0, ibuf->x);
- CLAMP(bounds_px.xmax, 0, ibuf->x);
- }
-
- if (clamp_v) {
- CLAMP(bounds_px.ymin, 0, ibuf->y);
- CLAMP(bounds_px.ymax, 0, ibuf->y);
- }
-
#if 0
project_paint_undo_tiles_init(&bounds_px, ps->projImages + image_index, tmpibuf,
tile_width, threaded, ps->do_masking);
@@ -2927,19 +2914,16 @@ static void project_bucket_init(
int tri_index, image_index = 0;
ImBuf *ibuf = NULL;
Image *tpage_last = NULL, *tpage;
- Image *ima = NULL;
ImBuf *tmpibuf = NULL;
if (ps->image_tot == 1) {
/* Simple loop, no context switching */
ibuf = ps->projImages[0].ibuf;
- ima = ps->projImages[0].ima;
for (node = ps->bucketFaces[bucket_index]; node; node = node->next) {
project_paint_face_init(
ps, thread_index, bucket_index, GET_INT_FROM_POINTER(node->link), 0,
- clip_rect, bucket_bounds, ibuf, &tmpibuf,
- (ima->tpageflag & IMA_CLAMP_U) != 0, (ima->tpageflag & IMA_CLAMP_V) != 0);
+ clip_rect, bucket_bounds, ibuf, &tmpibuf);
}
}
else {
@@ -2956,7 +2940,6 @@ static void project_bucket_init(
for (image_index = 0; image_index < ps->image_tot; image_index++) {
if (ps->projImages[image_index].ima == tpage_last) {
ibuf = ps->projImages[image_index].ibuf;
- ima = ps->projImages[image_index].ima;
break;
}
}
@@ -2965,8 +2948,7 @@ static void project_bucket_init(
project_paint_face_init(
ps, thread_index, bucket_index, tri_index, image_index,
- clip_rect, bucket_bounds, ibuf, &tmpibuf,
- (ima->tpageflag & IMA_CLAMP_U) != 0, (ima->tpageflag & IMA_CLAMP_V) != 0);
+ clip_rect, bucket_bounds, ibuf, &tmpibuf);
}
}
@@ -3426,13 +3408,12 @@ static void project_paint_bleed_add_face_user(
/* Return true if DM can be painted on, false otherwise */
static bool proj_paint_state_dm_init(const bContext *C, ProjPaintState *ps)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
/* Workaround for subsurf selection, try the display mesh first */
if (ps->source == PROJ_SRC_IMAGE_CAM) {
/* using render mesh, assume only camera was rendered from */
- ps->dm = mesh_create_derived_render(&eval_ctx, ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE);
+ ps->dm = mesh_create_derived_render(depsgraph, ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE);
ps->dm_release = true;
}
else if (ps->ob->derivedFinal &&
@@ -3444,7 +3425,7 @@ static bool proj_paint_state_dm_init(const bContext *C, ProjPaintState *ps)
}
else {
ps->dm = mesh_get_derived_final(
- &eval_ctx, ps->scene, ps->ob,
+ depsgraph, ps->scene, ps->ob,
ps->scene->customdata_mask | CD_MASK_MTFACE | (ps->do_face_sel ? CD_ORIGINDEX : 0));
ps->dm_release = true;
}
@@ -5030,7 +5011,6 @@ void paint_proj_stroke(
/* clone gets special treatment here to avoid going through image initialization */
if (ps_handle->is_clone_cursor_pick) {
- EvaluationContext eval_ctx;
Scene *scene = ps_handle->scene;
struct Depsgraph *graph = CTX_data_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -5040,9 +5020,7 @@ void paint_proj_stroke(
view3d_operator_needs_opengl(C);
- CTX_data_eval_ctx(C, &eval_ctx);
-
- if (!ED_view3d_autodist(&eval_ctx, graph, ar, v3d, mval_i, cursor, false, NULL)) {
+ if (!ED_view3d_autodist(graph, ar, v3d, mval_i, cursor, false, NULL)) {
return;
}
@@ -5123,7 +5101,6 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
else {
ps->do_backfacecull = ps->do_occlude = ps->do_mask_normal = 0;
}
- ps->do_new_shading_nodes = BKE_scene_use_new_shading_nodes(scene); /* only cache the value */
if (ps->tool == PAINT_TOOL_CLONE)
ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) ? 1 : 0;
@@ -5457,18 +5434,16 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
ImBuf *ibuf;
char filename[FILE_MAX];
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- struct RenderEngineType *engine_type = CTX_data_engine_type(C);
- EvaluationContext eval_ctx;
ToolSettings *settings = scene->toolsettings;
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
int w = settings->imapaint.screen_grab_size[0];
int h = settings->imapaint.screen_grab_size[1];
int maxsize;
char err_out[256] = "unknown";
- CTX_data_eval_ctx(C, &eval_ctx);
-
RNA_string_get(op->ptr, "filepath", filename);
maxsize = GPU_max_texture_size();
@@ -5477,8 +5452,8 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if (h > maxsize) h = maxsize;
ibuf = ED_view3d_draw_offscreen_imbuf(
- &eval_ctx, scene, view_layer, engine_type,
- CTX_wm_view3d(C), CTX_wm_region(C),
+ depsgraph, scene, v3d->drawtype,
+ v3d, CTX_wm_region(C),
w, h, IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL,
NULL, err_out);
if (!ibuf) {
@@ -5496,9 +5471,6 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if (image) {
/* now for the trickiness. store the view projection here!
* re-projection will reuse this */
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
-
IDPropertyTemplate val;
IDProperty *idgroup = IDP_GetProperties(&image->id, 1);
IDProperty *view_data;
@@ -5651,20 +5623,11 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m
/* Add layer operator */
static const EnumPropertyItem layer_type_items[] = {
- {MAP_COL, "DIFFUSE_COLOR", 0, "Diffuse Color", ""},
- {MAP_REF, "DIFFUSE_INTENSITY", 0, "Diffuse Intensity", ""},
- {MAP_ALPHA, "ALPHA", 0, "Alpha", ""},
- {MAP_TRANSLU, "TRANSLUCENCY", 0, "Translucency", ""},
- {MAP_COLSPEC, "SPECULAR_COLOR", 0, "Specular Color", ""},
- {MAP_SPEC, "SPECULAR_INTENSITY", 0, "Specular Intensity", ""},
- {MAP_HAR, "SPECULAR_HARDNESS", 0, "Specular Hardness", ""},
- {MAP_AMB, "AMBIENT", 0, "Ambient", ""},
- {MAP_EMIT, "EMIT", 0, "Emit", ""},
- {MAP_COLMIR, "MIRROR_COLOR", 0, "Mirror Color", ""},
- {MAP_RAYMIRR, "RAYMIRROR", 0, "Ray Mirror", ""},
- {MAP_NORM, "NORMAL", 0, "Normal", ""},
- {MAP_WARP, "WARP", 0, "Warp", ""},
- {MAP_DISPLACE, "DISPLACE", 0, "Displace", ""},
+ {0, "BASE_COLOR", 0, "Base Color", ""},
+ {1, "EMISSION", 0, "Emission", ""},
+ {2, "NORMAL", 0, "Normal", ""},
+ {3, "BUMP", 0, "Bump", ""},
+ {4, "DISPLACEMENT", 0, "Displacement", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -5699,7 +5662,6 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
Material *ma;
- bool is_bi = BKE_scene_uses_blender_internal(scene) || BKE_scene_uses_blender_game(scene);
Image *ima = NULL;
if (!ob)
@@ -5708,55 +5670,29 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op)
ma = give_current_material(ob, ob->actcol);
if (ma) {
+ /* TODO: use type to link to proper socket. */
Main *bmain = CTX_data_main(C);
- if (!is_bi && BKE_scene_use_new_shading_nodes(scene)) {
- bNode *imanode;
- bNodeTree *ntree = ma->nodetree;
+ bNode *imanode;
+ bNodeTree *ntree = ma->nodetree;
- if (!ntree) {
- ED_node_shader_default(C, &ma->id);
- ntree = ma->nodetree;
- }
-
- ma->use_nodes = true;
-
- /* try to add an image node */
- imanode = nodeAddStaticNode(C, ntree, SH_NODE_TEX_IMAGE);
-
- ima = proj_paint_image_create(op, bmain);
- imanode->id = &ima->id;
-
- nodeSetActive(ntree, imanode);
-
- ntreeUpdateTree(CTX_data_main(C), ntree);
- }
- else {
- MTex *mtex = BKE_texture_mtex_add_id(&ma->id, -1);
-
- /* successful creation of mtex layer, now create set */
- if (mtex) {
- int type = MAP_COL;
- char imagename_buff[MAX_ID_NAME - 2];
- const char *imagename = DATA_("Diffuse Color");
-
- if (op) {
- type = RNA_enum_get(op->ptr, "type");
- RNA_string_get(op->ptr, "name", imagename_buff);
- imagename = imagename_buff;
- }
-
- mtex->tex = BKE_texture_add(bmain, imagename);
- mtex->mapto = type;
-
- if (mtex->tex) {
- ima = mtex->tex->ima = proj_paint_image_create(op, bmain);
- }
-
- WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, mtex->tex);
- }
+ if (!ntree) {
+ ED_node_shader_default(C, &ma->id);
+ ntree = ma->nodetree;
}
+ ma->use_nodes = true;
+
+ /* try to add an image node */
+ imanode = nodeAddStaticNode(C, ntree, SH_NODE_TEX_IMAGE);
+
+ ima = proj_paint_image_create(op, bmain);
+ imanode->id = &ima->id;
+
+ nodeSetActive(ntree, imanode);
+
+ ntreeUpdateTree(CTX_data_main(C), ntree);
+
if (ima) {
BKE_texpaint_slot_refresh_cache(scene, ma);
BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE);
@@ -5847,59 +5783,6 @@ void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth");
}
-static int texture_paint_delete_texture_paint_slot_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = CTX_data_active_object(C);
- Scene *scene = CTX_data_scene(C);
- Material *ma;
- bool is_bi = BKE_scene_uses_blender_internal(scene) || BKE_scene_uses_blender_game(scene);
- TexPaintSlot *slot;
-
- /* not supported for node-based engines */
- if (!ob || !is_bi)
- return OPERATOR_CANCELLED;
-
- ma = give_current_material(ob, ob->actcol);
-
- if (!ma->texpaintslot || ma->use_nodes)
- return OPERATOR_CANCELLED;
-
- slot = ma->texpaintslot + ma->paint_active_slot;
-
- if (ma->mtex[slot->index]->tex) {
- id_us_min(&ma->mtex[slot->index]->tex->id);
-
- if (ma->mtex[slot->index]->tex->ima) {
- id_us_min(&ma->mtex[slot->index]->tex->ima->id);
- }
- }
- MEM_freeN(ma->mtex[slot->index]);
- ma->mtex[slot->index] = NULL;
-
- BKE_texpaint_slot_refresh_cache(scene, ma);
- DEG_id_tag_update(&ma->id, 0);
- WM_event_add_notifier(C, NC_MATERIAL, ma);
- /* we need a notifier for data change since we change the displayed modifier uvs */
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
- return OPERATOR_FINISHED;
-}
-
-
-void PAINT_OT_delete_texture_paint_slot(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Delete Texture Paint Slot";
- ot->description = "Delete selected texture paint slot";
- ot->idname = "PAINT_OT_delete_texture_paint_slot";
-
- /* api callbacks */
- ot->exec = texture_paint_delete_texture_paint_slot_exec;
- ot->poll = ED_operator_region_view3d_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op))
{
/* no checks here, poll function does them for us */
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index e22b996c6e5..ca82ca52463 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -157,10 +157,10 @@ void PAINT_OT_weight_sample_group(struct wmOperatorType *ot);
/* paint_vertex_proj.c */
struct VertProjHandle;
struct VertProjHandle *ED_vpaint_proj_handle_create(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
struct DMCoNo **r_vcosnos);
void ED_vpaint_proj_handle_update(
- const struct EvaluationContext *eval_ctx, struct VertProjHandle *vp_handle,
+ struct Depsgraph *depsgraph, struct VertProjHandle *vp_handle,
/* runtime vars */
struct ARegion *ar, const float mval_fl[2]);
void ED_vpaint_proj_handle_free(
@@ -216,7 +216,6 @@ void PAINT_OT_texture_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_project_image(struct wmOperatorType *ot);
void PAINT_OT_image_from_view(struct wmOperatorType *ot);
void PAINT_OT_add_texture_paint_slot(struct wmOperatorType *ot);
-void PAINT_OT_delete_texture_paint_slot(struct wmOperatorType *ot);
void PAINT_OT_image_paint(struct wmOperatorType *ot);
void PAINT_OT_add_simple_uvs(struct wmOperatorType *ot);
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 162c067166c..f22e6f514e6 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -134,7 +134,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
struct Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
PaintMaskFloodMode mode;
float value;
PBVH *pbvh;
@@ -143,12 +143,10 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
bool multires;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- CTX_data_eval_ctx(C, &eval_ctx);
-
mode = RNA_enum_get(op->ptr, "mode");
value = RNA_float_get(op->ptr, "value");
- BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, true);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true);
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
@@ -261,7 +259,7 @@ static void mask_box_select_task_cb(
int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select, bool UNUSED(extend))
{
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Sculpt *sd = vc->scene->toolsettings->sculpt;
BoundBox bb;
float clip_planes[4][4];
@@ -277,8 +275,6 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r
int totnode, symmpass;
int symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
- CTX_data_eval_ctx(C, &eval_ctx);
-
mode = PAINT_MASK_FLOOD_VALUE;
value = select ? 1.0 : 0.0;
@@ -286,7 +282,7 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r
ED_view3d_clipping_calc(&bb, clip_planes, vc->ar, vc->obact, rect);
negate_m4(clip_planes);
- BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, true);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true);
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
@@ -428,7 +424,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
if (mcords) {
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
float clip_planes[4][4], clip_planes_final[4][4];
BoundBox bb;
Object *ob;
@@ -444,8 +440,6 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
PaintMaskFloodMode mode = RNA_enum_get(op->ptr, "mode");
float value = RNA_float_get(op->ptr, "value");
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* 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 */
@@ -468,7 +462,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
ED_view3d_clipping_calc(&bb, clip_planes, vc.ar, vc.obact, &data.rect);
negate_m4(clip_planes);
- BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, true);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true);
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 004d2757a71..ad3047d6345 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -1035,7 +1035,6 @@ void ED_operatortypes_paint(void)
WM_operatortype_append(PAINT_OT_image_from_view);
WM_operatortype_append(PAINT_OT_brush_colors_flip);
WM_operatortype_append(PAINT_OT_add_texture_paint_slot);
- WM_operatortype_append(PAINT_OT_delete_texture_paint_slot);
WM_operatortype_append(PAINT_OT_add_simple_uvs);
/* weight */
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 0f22973c45d..f8888ad9809 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -274,9 +274,9 @@ static void imapaint_tri_weights(float matrix[4][4], GLint view[4],
}
/* compute uv coordinates of mouse in face */
-static void imapaint_pick_uv(EvaluationContext *eval_ctx, Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
+static void imapaint_pick_uv(Depsgraph *depsgraph, Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
{
- DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
const int tottri = dm->getNumLoopTri(dm);
int i, findex;
float p[2], w[3], absw, minabsw;
@@ -353,14 +353,14 @@ static void imapaint_pick_uv(EvaluationContext *eval_ctx, Scene *scene, Object *
/* returns 0 if not found, otherwise 1 */
static int imapaint_pick_face(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mval[2],
+ ViewContext *vc, const int mval[2],
unsigned int *r_index, unsigned int totpoly)
{
if (totpoly == 0)
return 0;
/* sample only on the exact position */
- *r_index = ED_view3d_backbuf_sample(eval_ctx, vc, mval[0], mval[1]);
+ *r_index = ED_view3d_backbuf_sample(vc, mval[0], mval[1]);
if ((*r_index) == 0 || (*r_index) > (unsigned int)totpoly) {
return 0;
@@ -426,7 +426,7 @@ void flip_qt_qt(float out[4], const float in[4], const char symm)
void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_proj, bool use_palette)
{
Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Paint *paint = BKE_paint_get_active_from_context(C);
Palette *palette = BKE_paint_palette(paint);
PaletteColor *color = NULL;
@@ -434,8 +434,6 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
unsigned int col;
const unsigned char *cp;
- CTX_data_eval_ctx(C, &eval_ctx);
-
CLAMP(x, 0, ar->winx);
CLAMP(y, 0, ar->winy);
@@ -460,7 +458,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
if (ob) {
Mesh *me = (Mesh *)ob->data;
- DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
ViewContext vc;
const int mval[2] = {x, y};
@@ -472,7 +470,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
view3d_operator_needs_opengl(C);
- if (imapaint_pick_face(&eval_ctx, &vc, mval, &faceindex, totpoly)) {
+ if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) {
Image *image;
if (use_material)
@@ -485,7 +483,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
if (ibuf && ibuf->rect) {
float uv[2];
float u, v;
- imapaint_pick_uv(&eval_ctx, scene, ob, faceindex, mval, uv);
+ imapaint_pick_uv(depsgraph, scene, ob, faceindex, mval, uv);
sample_success = true;
u = fmodf(uv[0], 1.0f);
@@ -499,10 +497,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
if (ibuf->rect_float) {
float rgba_f[4];
- if (U.gameflags & USER_DISABLE_MIPMAP)
- nearest_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
- else
- bilinear_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
+ bilinear_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
straight_to_premul_v4(rgba_f);
if (use_palette) {
linearrgb_to_srgb_v3_v3(color->rgb, rgba_f);
@@ -514,10 +509,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
}
else {
unsigned char rgba[4];
- if (U.gameflags & USER_DISABLE_MIPMAP)
- nearest_interpolation_color_wrap(ibuf, rgba, NULL, u, v);
- else
- bilinear_interpolation_color_wrap(ibuf, rgba, NULL, u, v);
+ bilinear_interpolation_color_wrap(ibuf, rgba, NULL, u, v);
if (use_palette) {
rgb_uchar_to_float(color->rgb, rgba);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 12fe55fb956..1775d4b9c8b 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -940,14 +940,14 @@ static void do_weight_paint_vertex(
/* Toggle operator for turning vertex paint mode on or off (copied from sculpt.c) */
-static void vertex_paint_init_session(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+static void vertex_paint_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
/* Create persistent sculpt mode data */
BKE_sculpt_toolsettings_data_ensure(scene);
if (ob->sculpt == NULL) {
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
- BKE_sculpt_update_mesh_elements(eval_ctx, scene, scene->toolsettings->sculpt, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, 0, false);
}
}
@@ -1034,7 +1034,7 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
* \{ */
static void ed_vwpaintmode_enter_generic(
- const EvaluationContext *eval_ctx, wmWindowManager *wm, Scene *scene,
+ Depsgraph *depsgraph, wmWindowManager *wm, Scene *scene,
Object *ob, const eObjectMode mode_flag)
{
ob->mode |= mode_flag;
@@ -1080,41 +1080,39 @@ static void ed_vwpaintmode_enter_generic(
BKE_sculptsession_free(ob);
}
- vertex_paint_init_session(eval_ctx, scene, ob);
+ vertex_paint_init_session(depsgraph, scene, ob);
}
void ED_object_vpaintmode_enter_ex(
- const EvaluationContext *eval_ctx, wmWindowManager *wm,
+ Depsgraph *depsgraph, wmWindowManager *wm,
Scene *scene, Object *ob)
{
ed_vwpaintmode_enter_generic(
- eval_ctx, wm, scene, ob, OB_MODE_VERTEX_PAINT);
+ depsgraph, wm, scene, ob, OB_MODE_VERTEX_PAINT);
}
void ED_object_vpaintmode_enter(struct bContext *C)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- ED_object_vpaintmode_enter_ex(&eval_ctx, wm, scene, ob);
+ ED_object_vpaintmode_enter_ex(depsgraph, wm, scene, ob);
}
void ED_object_wpaintmode_enter_ex(
- const EvaluationContext *eval_ctx, wmWindowManager *wm,
+ Depsgraph *depsgraph, wmWindowManager *wm,
Scene *scene, Object *ob)
{
ed_vwpaintmode_enter_generic(
- eval_ctx, wm, scene, ob, OB_MODE_WEIGHT_PAINT);
+ depsgraph, wm, scene, ob, OB_MODE_WEIGHT_PAINT);
}
void ED_object_wpaintmode_enter(struct bContext *C)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- ED_object_wpaintmode_enter_ex(&eval_ctx, wm, scene, ob);
+ ED_object_wpaintmode_enter_ex(depsgraph, wm, scene, ob);
}
/** \} */
@@ -1211,10 +1209,9 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
ED_object_wpaintmode_exit_ex(ob);
}
else {
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
wmWindowManager *wm = CTX_wm_manager(C);
- ED_object_wpaintmode_enter_ex(&eval_ctx, wm, scene, ob);
+ ED_object_wpaintmode_enter_ex(depsgraph, wm, scene, ob);
}
/* Weightpaint works by overriding colors in mesh,
@@ -1405,6 +1402,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
bool *defbase_sel;
SculptSession *ss = ob->sculpt;
VPaint *vp = CTX_data_tool_settings(C)->wpaint;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, &vgroup_index) == false) {
return false;
@@ -1507,11 +1505,8 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
wpd->precomputed_weight = MEM_mallocN(sizeof(float) * me->totvert, __func__);
}
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* If not previously created, create vertex/weight paint mode session data */
- vertex_paint_init_session(&eval_ctx, scene, ob);
+ vertex_paint_init_session(depsgraph, scene, ob);
vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
vertex_paint_init_session_data(ts, ob);
@@ -2347,10 +2342,9 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
ED_object_vpaintmode_exit_ex(ob);
}
else {
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
wmWindowManager *wm = CTX_wm_manager(C);
- ED_object_vpaintmode_enter_ex(&eval_ctx, wm, scene, ob);
+ ED_object_vpaintmode_enter_ex(depsgraph, wm, scene, ob);
}
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
@@ -2442,9 +2436,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
Object *ob = CTX_data_active_object(C);
Mesh *me;
SculptSession *ss = ob->sculpt;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
/* context checks could be a poll() */
me = BKE_mesh_from_object(ob);
@@ -2492,12 +2484,12 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
/* Create projection handle */
if (vpd->is_texbrush) {
ob->sculpt->building_vp_handle = true;
- vpd->vp_handle = ED_vpaint_proj_handle_create(&eval_ctx, scene, ob, &vpd->vertexcosnos);
+ vpd->vp_handle = ED_vpaint_proj_handle_create(depsgraph, scene, ob, &vpd->vertexcosnos);
ob->sculpt->building_vp_handle = false;
}
/* If not previously created, create vertex/weight paint mode session data */
- vertex_paint_init_session(&eval_ctx, scene, ob);
+ vertex_paint_init_session(depsgraph, scene, ob);
vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
vertex_paint_init_session_data(ts, ob);
@@ -3108,10 +3100,6 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
* avoid this if we can! */
DEG_id_tag_update(ob->data, 0);
}
- else {
- /* If using new VBO drawing, mark mcol as dirty to force colors gpu buffer refresh! */
- ob->derivedFinal->dirty |= DM_DIRTY_MCOL_UPDATE_DRAW;
- }
}
static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
index 336f851d4c1..c5c9aa48760 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
@@ -102,13 +102,13 @@ static void vpaint_proj_dm_map_cosnos_init__map_cb(
}
static void vpaint_proj_dm_map_cosnos_init(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob,
struct VertProjHandle *vp_handle)
{
Mesh *me = ob->data;
DerivedMesh *dm;
- dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
if (dm->foreachMappedVert) {
memset(vp_handle->vcosnos, 0, sizeof(DMCoNo) * me->totvert);
@@ -176,7 +176,7 @@ static void vpaint_proj_dm_map_cosnos_update__map_cb(
}
static void vpaint_proj_dm_map_cosnos_update(
- const struct EvaluationContext *eval_ctx, struct VertProjHandle *vp_handle,
+ struct Depsgraph *depsgraph, struct VertProjHandle *vp_handle,
ARegion *ar, const float mval_fl[2])
{
struct VertProjUpdate vp_update = {vp_handle, ar, mval_fl};
@@ -189,7 +189,7 @@ static void vpaint_proj_dm_map_cosnos_update(
/* quick sanity check - we shouldn't have to run this if there are no modifiers */
BLI_assert(BLI_listbase_is_empty(&ob->modifiers) == false);
- dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
/* highly unlikely this will become unavailable once painting starts (perhaps with animated modifiers) */
if (LIKELY(dm->foreachMappedVert)) {
@@ -206,7 +206,7 @@ static void vpaint_proj_dm_map_cosnos_update(
/* Public Functions */
struct VertProjHandle *ED_vpaint_proj_handle_create(
- const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob,
DMCoNo **r_vcosnos)
{
struct VertProjHandle *vp_handle = MEM_mallocN(sizeof(struct VertProjHandle), __func__);
@@ -217,7 +217,7 @@ struct VertProjHandle *ED_vpaint_proj_handle_create(
vp_handle->use_update = false;
/* sets 'use_update' if needed */
- vpaint_proj_dm_map_cosnos_init(eval_ctx, scene, ob, vp_handle);
+ vpaint_proj_dm_map_cosnos_init(depsgraph, scene, ob, vp_handle);
if (vp_handle->use_update) {
vp_handle->dists_sq = MEM_mallocN(sizeof(float) * me->totvert, __func__);
@@ -237,11 +237,11 @@ struct VertProjHandle *ED_vpaint_proj_handle_create(
}
void ED_vpaint_proj_handle_update(
- const struct EvaluationContext *eval_ctx, struct VertProjHandle *vp_handle,
+ struct Depsgraph *depsgraph, struct VertProjHandle *vp_handle,
ARegion *ar, const float mval_fl[2])
{
if (vp_handle->use_update) {
- vpaint_proj_dm_map_cosnos_update(eval_ctx, vp_handle, ar, mval_fl);
+ vpaint_proj_dm_map_cosnos_update(depsgraph, vp_handle, ar, mval_fl);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 3892b776440..3773806e192 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -125,17 +125,14 @@ static int weight_from_bones_poll(bContext *C)
static int weight_from_bones_exec(bContext *C, wmOperator *op)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
Object *armob = modifiers_isDeformedByArmature(ob);
Mesh *me = ob->data;
int type = RNA_enum_get(op->ptr, "type");
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
-
- create_vgroups_from_armature(op->reports, &eval_ctx, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
+ ED_object_vgroup_calc_from_armature(op->reports, depsgraph, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
DEG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
@@ -726,11 +723,9 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
float sco_end[2] = {x_end, y_end};
const bool is_interactive = (gesture != NULL);
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
- DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, scene, ob, scene->customdata_mask);
+ DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, scene->customdata_mask);
DMGradient_userData data = {NULL};
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 4a9d2597415..1d1c8460cfd 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -87,9 +87,6 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "GPU_buffers.h"
-#include "GPU_extensions.h"
-
#include "UI_interface.h"
#include "UI_resources.h"
@@ -4601,12 +4598,11 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const B
SculptSession *ss = ob->sculpt;
if (ss->kb || ss->modifiers_active) {
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Sculpt *sd = scene->toolsettings->sculpt;
bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0);
- BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, need_pmap, false);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, need_pmap, false);
}
}
@@ -4809,18 +4805,16 @@ static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession
static bool sculpt_brush_stroke_init(bContext *C, wmOperator *op)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- EvaluationContext eval_ctx;
SculptSession *ss = CTX_data_active_object(C)->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
int mode = RNA_enum_get(op->ptr, "mode");
bool is_smooth;
bool need_mask = false;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
need_mask = true;
}
@@ -4829,7 +4823,7 @@ static bool sculpt_brush_stroke_init(bContext *C, wmOperator *op)
sculpt_brush_init_tex(scene, sd, ss);
is_smooth = sculpt_any_smooth_mode(brush, NULL, mode);
- BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, is_smooth, need_mask);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, is_smooth, need_mask);
return 1;
}
@@ -4869,8 +4863,6 @@ static void sculpt_flush_update(bContext *C)
if (mmd)
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
- if (ob->derivedFinal) /* VBO no longer valid */
- GPU_drawobject_free(ob->derivedFinal);
if (ss->kb || ss->modifiers_active) {
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -5256,18 +5248,18 @@ void sculpt_dyntopo_node_layers_add(SculptSession *ss)
void sculpt_update_after_dynamic_topology_toggle(
- const EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Scene *scene, Object *ob)
{
Sculpt *sd = scene->toolsettings->sculpt;
/* Create the PBVH */
- BKE_sculpt_update_mesh_elements(eval_ctx, scene, sd, ob, false, false);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, false);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
void sculpt_dynamic_topology_enable_ex(
- const EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Scene *scene, Object *ob)
{
SculptSession *ss = ob->sculpt;
@@ -5305,7 +5297,7 @@ void sculpt_dynamic_topology_enable_ex(
ss->bm_log = BM_log_create(ss->bm);
/* Refresh */
- sculpt_update_after_dynamic_topology_toggle(eval_ctx, scene, ob);
+ sculpt_update_after_dynamic_topology_toggle(depsgraph, scene, ob);
}
/* Free the sculpt BMesh and BMLog
@@ -5313,7 +5305,7 @@ void sculpt_dynamic_topology_enable_ex(
* If 'unode' is given, the BMesh's data is copied out to the unode
* before the BMesh is deleted so that it can be restored from */
void sculpt_dynamic_topology_disable_ex(
- const EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Scene *scene, Object *ob, SculptUndoNode *unode)
{
SculptSession *ss = ob->sculpt;
@@ -5364,38 +5356,37 @@ void sculpt_dynamic_topology_disable_ex(
}
/* Refresh */
- sculpt_update_after_dynamic_topology_toggle(eval_ctx, scene, ob);
+ sculpt_update_after_dynamic_topology_toggle(depsgraph, scene, ob);
}
void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
- sculpt_dynamic_topology_disable_ex(&eval_ctx, scene, ob, unode);
+ sculpt_dynamic_topology_disable_ex(depsgraph, scene, ob, unode);
}
static void sculpt_dynamic_topology_disable_with_undo(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+ Depsgraph *depsgraph, Scene *scene, Object *ob)
{
SculptSession *ss = ob->sculpt;
if (ss->bm) {
sculpt_undo_push_begin("Dynamic topology disable");
sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END);
- sculpt_dynamic_topology_disable_ex(eval_ctx, scene, ob, NULL);
+ sculpt_dynamic_topology_disable_ex(depsgraph, scene, ob, NULL);
sculpt_undo_push_end();
}
}
static void sculpt_dynamic_topology_enable_with_undo(
- const EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Scene *scene, Object *ob)
{
SculptSession *ss = ob->sculpt;
if (ss->bm == NULL) {
sculpt_undo_push_begin("Dynamic topology enable");
- sculpt_dynamic_topology_enable_ex(eval_ctx, scene, ob);
+ sculpt_dynamic_topology_enable_ex(depsgraph, scene, ob);
sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
sculpt_undo_push_end();
}
@@ -5403,19 +5394,18 @@ static void sculpt_dynamic_topology_enable_with_undo(
static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
WM_cursor_wait(1);
if (ss->bm) {
- sculpt_dynamic_topology_disable_with_undo(&eval_ctx, scene, ob);
+ sculpt_dynamic_topology_disable_with_undo(depsgraph, scene, ob);
}
else {
- sculpt_dynamic_topology_enable_with_undo(&eval_ctx, scene, ob);
+ sculpt_dynamic_topology_enable_with_undo(depsgraph, scene, ob);
}
WM_cursor_wait(0);
@@ -5626,14 +5616,14 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot)
/**** Toggle operator for turning sculpt mode on or off ****/
-static void sculpt_init_session(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+static void sculpt_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
/* Create persistent sculpt mode data */
BKE_sculpt_toolsettings_data_ensure(scene);
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
ob->sculpt->mode_type = OB_MODE_SCULPT;
- BKE_sculpt_update_mesh_elements(eval_ctx, scene, scene->toolsettings->sculpt, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, 0, false);
}
static int ed_object_sculptmode_flush_recalc_flag(Scene *scene, Object *ob, MultiresModifierData *mmd)
@@ -5647,7 +5637,7 @@ static int ed_object_sculptmode_flush_recalc_flag(Scene *scene, Object *ob, Mult
}
void ED_object_sculptmode_enter_ex(
- const EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Scene *scene, Object *ob,
ReportList *reports)
{
@@ -5669,7 +5659,7 @@ void ED_object_sculptmode_enter_ex(
BKE_sculptsession_free(ob);
}
- sculpt_init_session(eval_ctx, scene, ob);
+ sculpt_init_session(depsgraph, scene, ob);
/* Mask layer is required */
if (mmd) {
@@ -5727,7 +5717,7 @@ void ED_object_sculptmode_enter_ex(
if (message_unsupported == NULL) {
/* undo push is needed to prevent memory leak */
sculpt_undo_push_begin("Dynamic topology enable");
- sculpt_dynamic_topology_enable_ex(eval_ctx, scene, ob);
+ sculpt_dynamic_topology_enable_ex(depsgraph, scene, ob);
sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
}
else {
@@ -5739,24 +5729,18 @@ void ED_object_sculptmode_enter_ex(
}
// ED_workspace_object_mode_sync_from_object(G.main->wm.first, workspace, ob);
-
- /* VBO no longer valid */
- if (ob->derivedFinal) {
- GPU_drawobject_free(ob->derivedFinal);
- }
}
void ED_object_sculptmode_enter(struct bContext *C, ReportList *reports)
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
- ED_object_sculptmode_enter_ex(&eval_ctx, scene, ob, reports);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ED_object_sculptmode_enter_ex(depsgraph, scene, ob, reports);
}
void ED_object_sculptmode_exit_ex(
- const EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Scene *scene, Object *ob)
{
const int mode_flag = OB_MODE_SCULPT;
@@ -5783,7 +5767,7 @@ void ED_object_sculptmode_exit_ex(
/* Dynamic topology must be disabled before exiting sculpt
* mode to ensure the undo stack stays in a consistent
* state */
- sculpt_dynamic_topology_disable_with_undo(eval_ctx, scene, ob);
+ sculpt_dynamic_topology_disable_with_undo(depsgraph, scene, ob);
/* store so we know to re-enable when entering sculpt mode */
me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
@@ -5797,24 +5781,19 @@ void ED_object_sculptmode_exit_ex(
BKE_sculptsession_free(ob);
paint_cursor_delete_textures();
-
- /* VBO no longer valid */
- if (ob->derivedFinal) {
- GPU_drawobject_free(ob->derivedFinal);
- }
}
void ED_object_sculptmode_exit(bContext *C)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
- ED_object_sculptmode_exit_ex(&eval_ctx, scene, ob);
+ ED_object_sculptmode_exit_ex(depsgraph, scene, ob);
}
static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_SCULPT;
@@ -5826,14 +5805,11 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
}
}
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (is_mode_set) {
- ED_object_sculptmode_exit_ex(&eval_ctx, scene, ob);
+ ED_object_sculptmode_exit_ex(depsgraph, scene, ob);
}
else {
- ED_object_sculptmode_enter_ex(&eval_ctx, scene, ob, op->reports);
+ ED_object_sculptmode_enter_ex(depsgraph, scene, ob, op->reports);
}
WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index ba39d51700d..bca33ad8014 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -61,15 +61,15 @@ bool sculpt_stroke_get_location(struct bContext *C, float out[3], const float mo
void sculpt_pbvh_clear(Object *ob);
void sculpt_dyntopo_node_layers_add(struct SculptSession *ss);
void sculpt_update_after_dynamic_topology_toggle(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob);
void sculpt_dynamic_topology_enable_ex(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob);
void sculpt_dynamic_topology_enable(bContext *C);
void sculpt_dynamic_topology_disable_ex(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct Scene *scene, struct Object *ob,
struct SculptUndoNode *unode);
void sculpt_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index e12ef2df4ab..b819fe8e97d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -66,8 +66,6 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "GPU_buffers.h"
-
#include "ED_paint.h"
#include "ED_object.h"
#include "ED_sculpt.h"
@@ -142,12 +140,10 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN
Scene *scene = CTX_data_scene(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
SculptSession *ss = ob->sculpt;
MVert *mvert;
int *index;
-
- CTX_data_eval_ctx(C, &eval_ctx);
if (unode->maxvert) {
/* regular mesh restore */
@@ -161,7 +157,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN
if (kb) {
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
- BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, 0, false);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, 0, false);
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
}
else {
@@ -477,7 +473,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
Scene *scene = CTX_data_scene(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
DerivedMesh *dm;
SculptSession *ss = ob->sculpt;
SculptUndoNode *unode;
@@ -485,8 +481,6 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
bool need_mask = false;
bool partial_update = true;
- CTX_data_eval_ctx(C, &eval_ctx);
-
for (unode = lb->first; unode; unode = unode->next) {
if (STREQ(unode->idname, ob->id.name)) {
if (unode->type == SCULPT_UNDO_MASK) {
@@ -498,10 +492,10 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
}
}
- BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, 0, need_mask);
+ BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, 0, need_mask);
/* call _after_ sculpt_update_mesh_elements() which may update 'ob->derivedFinal' */
- dm = mesh_get_derived_final(&eval_ctx, scene, ob, 0);
+ dm = mesh_get_derived_final(depsgraph, scene, ob, 0);
if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss))
return;
@@ -589,9 +583,6 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
else {
sculpt_update_object_bounding_box(ob);
}
-
- /* for non-PBVH drawing, need to recreate VBOs */
- GPU_drawobject_free(ob->derivedFinal);
}
}
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index a01b4aa1b18..eaf101b1083 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -635,7 +635,7 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* main draw call */
- uiDefAutoButsRNA(layout, &ptr, sound_mixdown_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, sound_mixdown_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
#endif // WITH_AUDASPACE
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 11ac1d60f39..3e9b742480a 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -43,16 +43,23 @@
/* Types --------------------------------------------------------------- */
#include "DNA_anim_types.h"
+#include "DNA_cachefile_types.h"
+#include "DNA_object_types.h"
#include "DNA_screen_types.h"
+#include "DNA_scene_types.h"
#include "BKE_action.h"
#include "BKE_context.h"
+#include "BKE_pointcache.h"
/* Everything from source (BIF, BDR, BSE) ------------------------------ */
#include "BIF_gl.h"
+#include "GPU_immediate.h"
+#include "GPU_matrix.h"
+
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -61,7 +68,6 @@
#include "ED_keyframes_draw.h"
#include "action_intern.h"
-#include "GPU_immediate.h"
/* ************************************************************************* */
/* Channel List */
@@ -381,3 +387,138 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* free temporary channels used for drawing */
ANIM_animdata_freelist(&anim_data);
}
+
+/* ************************************************************************* */
+/* Timeline - Caches */
+
+void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
+{
+ PTCacheID *pid;
+ ListBase pidlist;
+ const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
+ float yoffs = 0.f;
+
+ if (!(saction->cache_display & TIME_CACHE_DISPLAY) || (!ob))
+ return;
+
+ BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
+
+ unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ /* iterate over pointcaches on the active object, and draw each one's range */
+ for (pid = pidlist.first; pid; pid = pid->next) {
+ float col[4];
+
+ switch (pid->type) {
+ case PTCACHE_TYPE_SOFTBODY:
+ if (!(saction->cache_display & TIME_CACHE_SOFTBODY)) continue;
+ break;
+ case PTCACHE_TYPE_PARTICLES:
+ if (!(saction->cache_display & TIME_CACHE_PARTICLES)) continue;
+ break;
+ case PTCACHE_TYPE_CLOTH:
+ if (!(saction->cache_display & TIME_CACHE_CLOTH)) continue;
+ break;
+ case PTCACHE_TYPE_SMOKE_DOMAIN:
+ case PTCACHE_TYPE_SMOKE_HIGHRES:
+ if (!(saction->cache_display & TIME_CACHE_SMOKE)) continue;
+ break;
+ case PTCACHE_TYPE_DYNAMICPAINT:
+ if (!(saction->cache_display & TIME_CACHE_DYNAMICPAINT)) continue;
+ break;
+ case PTCACHE_TYPE_RIGIDBODY:
+ if (!(saction->cache_display & TIME_CACHE_RIGIDBODY)) continue;
+ break;
+ }
+
+ if (pid->cache->cached_frames == NULL)
+ continue;
+
+ gpuPushMatrix();
+ gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT + yoffs);
+ gpuScale2f(1.0, cache_draw_height);
+
+ switch (pid->type) {
+ case PTCACHE_TYPE_SOFTBODY:
+ col[0] = 1.0; col[1] = 0.4; col[2] = 0.02;
+ col[3] = 0.1;
+ break;
+ case PTCACHE_TYPE_PARTICLES:
+ col[0] = 1.0; col[1] = 0.1; col[2] = 0.02;
+ col[3] = 0.1;
+ break;
+ case PTCACHE_TYPE_CLOTH:
+ col[0] = 0.1; col[1] = 0.1; col[2] = 0.75;
+ col[3] = 0.1;
+ break;
+ case PTCACHE_TYPE_SMOKE_DOMAIN:
+ case PTCACHE_TYPE_SMOKE_HIGHRES:
+ col[0] = 0.2; col[1] = 0.2; col[2] = 0.2;
+ col[3] = 0.1;
+ break;
+ case PTCACHE_TYPE_DYNAMICPAINT:
+ col[0] = 1.0; col[1] = 0.1; col[2] = 0.75;
+ col[3] = 0.1;
+ break;
+ case PTCACHE_TYPE_RIGIDBODY:
+ col[0] = 1.0; col[1] = 0.6; col[2] = 0.0;
+ col[3] = 0.1;
+ break;
+ default:
+ col[0] = 1.0; col[1] = 0.0; col[2] = 1.0;
+ col[3] = 0.1;
+ BLI_assert(0);
+ break;
+ }
+
+ const int sta = pid->cache->startframe, end = pid->cache->endframe;
+ const int len = (end - sta + 1) * 6;
+
+ glEnable(GL_BLEND);
+
+ immUniformColor4fv(col);
+ immRectf(pos, (float)sta, 0.0, (float)end, 1.0);
+
+ col[3] = 0.4f;
+ if (pid->cache->flag & PTCACHE_BAKED) {
+ col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f;
+ }
+ else if (pid->cache->flag & PTCACHE_OUTDATED) {
+ col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f;
+ }
+
+ immUniformColor4fv(col);
+
+ if (len > 0) {
+ immBeginAtMost(GWN_PRIM_TRIS, len);
+
+ /* draw a quad for each cached frame */
+ for (int i = sta; i <= end; i++) {
+ if (pid->cache->cached_frames[i - sta]) {
+ immVertex2f(pos, (float)i - 0.5f, 0.0f);
+ immVertex2f(pos, (float)i - 0.5f, 1.0f);
+ immVertex2f(pos, (float)i + 0.5f, 1.0f);
+
+ immVertex2f(pos, (float)i - 0.5f, 0.0f);
+ immVertex2f(pos, (float)i + 0.5f, 1.0f);
+ immVertex2f(pos, (float)i + 0.5f, 0.0f);
+ }
+ }
+
+ immEnd();
+ }
+
+ glDisable(GL_BLEND);
+
+ gpuPopMatrix();
+
+ yoffs += cache_draw_height;
+ }
+
+ immUnbindProgram();
+
+ BLI_freelistN(&pidlist);
+}
+
+/* ************************************************************************* */
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index 408eb38d386..6ec6f0561c2 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -33,10 +33,13 @@
struct bContext;
struct bAnimContext;
+struct Scene;
+struct Object;
struct SpaceAction;
struct ScrArea;
struct ARegion;
struct ARegionType;
+struct View2D;
struct wmOperatorType;
/* internal exports only */
@@ -54,6 +57,8 @@ void ACTION_OT_properties(struct wmOperatorType *ot);
void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar);
void draw_channel_strips(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar);
+void timeline_draw_cache(struct SpaceAction *saction, struct Object *ob, struct Scene *scene);
+
/* ***************************************** */
/* action_select.c */
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 50882571dad..b68300e0d52 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -34,6 +34,7 @@
#include "DNA_action_types.h"
#include "DNA_group_types.h"
+#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
@@ -45,10 +46,13 @@
#include "BKE_context.h"
#include "BKE_screen.h"
-#include "BIF_gl.h"
+#include "RNA_access.h"
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_message.h"
+
+#include "BIF_gl.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -103,6 +107,12 @@ static SpaceLink *action_new(const bContext *C)
saction->ads.filterflag |= ADS_FILTER_SUMMARY;
+ /* enable all cache display */
+ saction->cache_display |= TIME_CACHE_DISPLAY;
+ saction->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES);
+ saction->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT);
+ saction->cache_display |= TIME_CACHE_RIGIDBODY;
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for action");
@@ -170,6 +180,7 @@ static void action_free(SpaceLink *UNUSED(sl))
static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
{
SpaceAction *saction = sa->spacedata.first;
+
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
}
@@ -202,6 +213,8 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceAction *saction = CTX_wm_space_action(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *obact = CTX_data_active_object(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
View2DGrid *grid;
@@ -221,7 +234,10 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_grid_free(grid);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+
+ /* start and end frame */
+ ANIM_draw_framerange(scene, v2d);
+
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
draw_channel_strips(&ac, saction, ar);
@@ -238,6 +254,11 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN;
ED_markers_draw(C, flag);
+ /* caches */
+ if (saction->mode == SACTCONT_TIMELINE) {
+ timeline_draw_cache(saction, obact, scene);
+ }
+
/* preview range */
UI_view2d_view_ortho(v2d);
ANIM_draw_previewrange(C, v2d, 0);
@@ -367,6 +388,7 @@ static void action_main_region_listener(
case ND_RENDER_OPTIONS:
case ND_OB_ACTIVE:
case ND_FRAME:
+ case ND_FRAME_RANGE:
case ND_MARKERS:
ED_region_tag_redraw(ar);
break;
@@ -407,6 +429,46 @@ static void action_main_region_listener(
}
}
+static void saction_main_region_message_subscribe(
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *UNUSED(workspace), struct Scene *scene,
+ struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ PointerRNA ptr;
+ RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, sa->spacedata.first, &ptr);
+
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ /* Timeline depends on scene properties. */
+ {
+ bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
+ extern PropertyRNA rna_Scene_frame_start;
+ extern PropertyRNA rna_Scene_frame_end;
+ extern PropertyRNA rna_Scene_frame_preview_start;
+ extern PropertyRNA rna_Scene_frame_preview_end;
+ extern PropertyRNA rna_Scene_use_preview_range;
+ extern PropertyRNA rna_Scene_frame_current;
+ const PropertyRNA *props[] = {
+ use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
+ use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
+ &rna_Scene_use_preview_range,
+ &rna_Scene_frame_current,
+ };
+
+ PointerRNA idptr;
+ RNA_id_pointer_create(&scene->id, &idptr);
+
+ for (int i = 0; i < ARRAY_SIZE(props); i++) {
+ WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
+ }
+ }
+}
+
/* editor level listener */
static void action_listener(
bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
@@ -450,16 +512,43 @@ static void action_listener(
}
break;
case NC_SCENE:
- switch (wmn->data) {
- case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
- case ND_OB_SELECT:
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
- ED_area_tag_refresh(sa);
- break;
-
- default: /* just redrawing the view will do */
- ED_area_tag_redraw(sa);
- break;
+ if (saction->mode == SACTCONT_TIMELINE) {
+ switch (wmn->data) {
+ case ND_RENDER_RESULT:
+ ED_area_tag_redraw(sa);
+ break;
+ case ND_OB_ACTIVE:
+ case ND_FRAME:
+ ED_area_tag_refresh(sa);
+ break;
+ case ND_FRAME_RANGE:
+ {
+ ARegion *ar;
+ Scene *scene = wmn->reference;
+
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ ar->v2d.tot.xmin = (float)(SFRA - 4);
+ ar->v2d.tot.xmax = (float)(EFRA + 4);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+ else {
+ switch (wmn->data) {
+ case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
+ case ND_OB_SELECT:
+ saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ ED_area_tag_refresh(sa);
+ break;
+
+ default: /* just redrawing the view will do */
+ ED_area_tag_redraw(sa);
+ break;
+ }
}
break;
case NC_OBJECT:
@@ -472,6 +561,15 @@ static void action_listener(
case ND_TRANSFORM:
/* moving object shouldn't need to redraw action */
break;
+ case ND_POINTCACHE:
+ case ND_MODIFIER:
+ case ND_PARTICLE:
+ /* only needed in timeline mode */
+ if (saction->mode == SACTCONT_TIMELINE) {
+ ED_area_tag_refresh(sa);
+ ED_area_tag_redraw(sa);
+ }
+ break;
default: /* just redrawing the view will do */
ED_area_tag_redraw(sa);
break;
@@ -502,6 +600,9 @@ static void action_listener(
case ND_SPACE_DOPESHEET:
ED_area_tag_redraw(sa);
break;
+ case ND_SPACE_TIME:
+ ED_area_tag_redraw(sa);
+ break;
case ND_SPACE_CHANGED:
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_area_tag_refresh(sa);
@@ -514,22 +615,49 @@ static void action_listener(
ED_area_tag_refresh(sa);
}
break;
+ case NC_WM:
+ switch (wmn->data) {
+ case ND_FILEREAD:
+ ED_area_tag_refresh(sa);
+ break;
+ }
+ break;
}
}
static void action_header_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
- // SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
+ SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
/* context changes */
switch (wmn->category) {
- case NC_SCENE:
- switch (wmn->data) {
- case ND_OB_ACTIVE:
+ case NC_SCREEN:
+ if (saction->mode == SACTCONT_TIMELINE) {
+ if (wmn->data == ND_ANIMPLAY)
ED_region_tag_redraw(ar);
- break;
+ }
+ break;
+ case NC_SCENE:
+ if (saction->mode == SACTCONT_TIMELINE) {
+ switch (wmn->data) {
+ case ND_RENDER_RESULT:
+ case ND_OB_SELECT:
+ case ND_FRAME:
+ case ND_FRAME_RANGE:
+ case ND_KEYINGSET:
+ case ND_RENDER_OPTIONS:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ }
+ else {
+ switch (wmn->data) {
+ case ND_OB_ACTIVE:
+ ED_region_tag_redraw(ar);
+ break;
+ }
}
break;
case NC_ID:
@@ -676,6 +804,7 @@ void ED_spacetype_action(void)
art->init = action_main_region_init;
art->draw = action_main_region_draw;
art->listener = action_main_region_listener;
+ art->message_subscribe = saction_main_region_message_subscribe;
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 2f85b915813..2e7304692fc 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -83,7 +83,6 @@ void ED_spacetypes_init(void)
/* create space types */
ED_spacetype_outliner();
- ED_spacetype_time();
ED_spacetype_view3d();
ED_spacetype_ipo();
ED_spacetype_image();
@@ -96,10 +95,10 @@ void ED_spacetypes_init(void)
ED_spacetype_script();
ED_spacetype_text();
ED_spacetype_sequencer();
- ED_spacetype_logic();
ED_spacetype_console();
ED_spacetype_userpref();
ED_spacetype_clip();
+ ED_spacetype_topbar();
// ...
/* register operator types for screen and all spaces */
@@ -122,7 +121,6 @@ void ED_spacetypes_init(void)
ED_operatortypes_metaball();
ED_operatortypes_sound();
ED_operatortypes_render();
- ED_operatortypes_logic();
ED_operatortypes_mask();
ED_operatortypes_io();
ED_operatortypes_groom();
@@ -151,9 +149,6 @@ void ED_spacetypes_init(void)
type->operatortypes();
}
}
-
- /* register internal render callbacks */
- ED_render_internal_init();
}
void ED_spacemacros_init(void)
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 4b5f01897c1..08b01dbccce 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -280,7 +280,7 @@ static int buttons_context_path_modifier(ButsContextPath *path)
return 0;
}
-static int buttons_context_path_material(ButsContextPath *path, bool for_texture, bool new_shading)
+static int buttons_context_path_material(ButsContextPath *path)
{
Object *ob;
PointerRNA *ptr = &path->ptr[path->len - 1];
@@ -298,18 +298,6 @@ static int buttons_context_path_material(ButsContextPath *path, bool for_texture
ma = give_current_material(ob, ob->actcol);
RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
path->len++;
-
- if (for_texture && give_current_material_texture_node(ma))
- return 1;
-
- if (!new_shading) {
- /* Only try to get mat from node in case of old shading system (see T40331). */
- ma = give_node_material(ma);
- if (ma) {
- RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
- path->len++;
- }
- }
return 1;
}
}
@@ -442,132 +430,38 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
static int buttons_context_path_texture(const bContext *C, ButsContextPath *path, ButsContextTexture *ct)
{
- if (ct) {
- /* new shading system */
- PointerRNA *ptr = &path->ptr[path->len - 1];
- ID *id;
-
- /* if we already have a (pinned) texture, we're done */
- if (RNA_struct_is_a(ptr->type, &RNA_Texture))
- return 1;
-
- if (!ct->user)
- return 0;
-
- id = ct->user->id;
-
- if (id) {
- if (GS(id->name) == ID_BR)
- buttons_context_path_brush(C, path);
- else if (GS(id->name) == ID_MA)
- buttons_context_path_material(path, false, true);
- else if (GS(id->name) == ID_WO)
- buttons_context_path_world(path);
- else if (GS(id->name) == ID_LA)
- buttons_context_path_data(path, OB_LAMP);
- else if (GS(id->name) == ID_PA)
- buttons_context_path_particle(path);
- else if (GS(id->name) == ID_OB)
- buttons_context_path_object(path);
- else if (GS(id->name) == ID_LS)
- buttons_context_path_linestyle(path);
- }
+ PointerRNA *ptr = &path->ptr[path->len - 1];
+ ID *id;
- if (ct->texture) {
- RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]);
- path->len++;
- }
+ if (!ct)
+ return 0;
+ /* if we already have a (pinned) texture, we're done */
+ if (RNA_struct_is_a(ptr->type, &RNA_Texture))
return 1;
- }
- else {
- /* old shading system */
- Material *ma;
- Lamp *la;
- World *wo;
- ParticleSystem *psys;
- FreestyleLineStyle *ls;
- Tex *tex;
- PointerRNA *ptr = &path->ptr[path->len - 1];
-
- /* if we already have a (pinned) texture, we're done */
- if (RNA_struct_is_a(ptr->type, &RNA_Texture)) {
- return 1;
- }
- /* try world */
- else if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) {
- wo = path->ptr[path->len - 1].data;
-
- if (wo && GS(wo->id.name) == ID_WO) {
- tex = give_current_world_texture(wo);
-
- RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
- /* try particles */
- else if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) {
- if (path->ptr[path->len - 1].type == &RNA_ParticleSettings) {
- ParticleSettings *part = path->ptr[path->len - 1].data;
-
- tex = give_current_particle_texture(part);
- RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
- path->len++;
- return 1;
- }
- else {
- psys = path->ptr[path->len - 1].data;
-
- if (psys && psys->part && GS(psys->part->id.name) == ID_PA) {
- tex = give_current_particle_texture(psys->part);
-
- RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
- }
- /* try material */
- else if ((path->tex_ctx == SB_TEXC_MATERIAL) && buttons_context_path_material(path, true, false)) {
- ma = path->ptr[path->len - 1].data;
-
- if (ma) {
- tex = give_current_material_texture(ma);
- RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
- /* try lamp */
- else if ((path->tex_ctx == SB_TEXC_LAMP) && buttons_context_path_data(path, OB_LAMP)) {
- la = path->ptr[path->len - 1].data;
-
- if (la) {
- tex = give_current_lamp_texture(la);
-
- RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
- /* try linestyle */
- else if ((path->tex_ctx == SB_TEXC_LINESTYLE) && buttons_context_path_linestyle(path)) {
- ls = path->ptr[path->len - 1].data;
+ if (!ct->user)
+ return 0;
+
+ id = ct->user->id;
- if (ls) {
- tex = give_current_linestyle_texture(ls);
+ if (id) {
+ if (GS(id->name) == ID_BR)
+ buttons_context_path_brush(C, path);
+ else if (GS(id->name) == ID_PA)
+ buttons_context_path_particle(path);
+ else if (GS(id->name) == ID_OB)
+ buttons_context_path_object(path);
+ else if (GS(id->name) == ID_LS)
+ buttons_context_path_linestyle(path);
+ }
- RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
+ if (ct->texture) {
+ RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]);
+ path->len++;
}
- /* no path to a texture possible */
- return 0;
+ return 1;
}
#ifdef WITH_FREESTYLE
@@ -607,7 +501,6 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
memset(path, 0, sizeof(*path));
path->flag = flag;
- path->tex_ctx = sbuts->texture_context;
const bool use_scene_settings = BKE_workspace_use_scene_settings_get(workspace);
@@ -680,7 +573,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
found = buttons_context_path_particle(path);
break;
case BCONTEXT_MATERIAL:
- found = buttons_context_path_material(path, false, (sbuts->texuser != NULL));
+ found = buttons_context_path_material(path);
break;
case BCONTEXT_TEXTURE:
found = buttons_context_path_texture(C, path, sbuts->texuser);
@@ -738,7 +631,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
path = sbuts->path;
- /* We need to set Scene path now! Else, buttons_texture_context_compute() might not get a valid scene. */
+ /* Set scene path. */
buttons_context_path(C, path, BCONTEXT_SCENE, pflag);
buttons_texture_context_compute(C, sbuts);
@@ -891,13 +784,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
ButsContextTexture *ct = sbuts->texuser;
if (ct) {
- /* new shading system */
CTX_data_pointer_set(result, &ct->texture->id, &RNA_Texture, ct->texture);
}
- else {
- /* old shading system */
- set_pointer_type(path, result, &RNA_Texture);
- }
return 1;
}
@@ -921,7 +809,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
ButsContextTexture *ct = sbuts->texuser;
if (!ct)
- return -1; /* old shading system (found but not available) */
+ return -1;
if (ct->user && ct->user->ptr.data) {
ButsTextureUser *user = ct->user;
@@ -934,7 +822,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
ButsContextTexture *ct = sbuts->texuser;
if (!ct)
- return -1; /* old shading system (found but not available) */
+ return -1;
if (ct->user && ct->user->ptr.data) {
ButsTextureUser *user = ct->user;
@@ -954,21 +842,6 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
return 1;
}
- else {
- /* old shading system */
- PointerRNA *ptr;
-
- if ((ptr = get_pointer_type(path, &RNA_Material))) {
- Material *ma = ptr->data;
-
- if (ma) {
- bNode *node = give_current_material_texture_node(ma);
- CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node);
- }
- }
-
- return 1;
- }
}
else if (CTX_data_equals(member, "texture_slot")) {
ButsContextTexture *ct = sbuts->texuser;
@@ -984,38 +857,6 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
else if (ct) {
return 0; /* new shading system */
}
- else if ((ptr = get_pointer_type(path, &RNA_Material))) {
- Material *ma = ptr->data;
-
- /* if we have a node material, get slot from material in material node */
- if (ma && ma->use_nodes && ma->nodetree) {
- /* if there's an active texture node in the node tree,
- * then that texture is in context directly, without a texture slot */
- if (give_current_material_texture_node(ma))
- return 0;
-
- ma = give_node_material(ma);
- if (ma)
- CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
- else
- return 0;
- }
- else if (ma) {
- CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
- }
- }
- else if ((ptr = get_pointer_type(path, &RNA_Lamp))) {
- Lamp *la = ptr->data;
-
- if (la)
- CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]);
- }
- else if ((ptr = get_pointer_type(path, &RNA_World))) {
- World *wo = ptr->data;
-
- if (wo)
- CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]);
- }
else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) {
FreestyleLineStyle *ls = ptr->data;
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index e6d19caad47..84c935dd737 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -64,7 +64,6 @@ typedef struct ButsContextPath {
PointerRNA ptr[8];
int len;
int flag;
- int tex_ctx;
int collection_ctx;
} ButsContextPath;
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 809480baece..df06eee3fd5 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -41,8 +41,6 @@
#include "DNA_brush_types.h"
#include "DNA_ID.h"
-#include "DNA_lamp_types.h"
-#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force_types.h"
@@ -50,13 +48,11 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
-#include "DNA_world_types.h"
#include "DNA_linestyle_types.h"
#include "BKE_context.h"
#include "BKE_layer.h"
#include "BKE_linestyle.h"
-#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_node.h"
#include "BKE_paint.h"
@@ -79,172 +75,6 @@
#include "buttons_intern.h" // own include
-/****************** "Old Shading" Texture Context ****************/
-
-bool ED_texture_context_check_world(const bContext *C)
-{
- Scene *scene = CTX_data_scene(C);
- return (scene && scene->world);
-}
-
-bool ED_texture_context_check_material(const bContext *C)
-{
- Object *ob = CTX_data_active_object(C);
- return (ob && (ob->totcol != 0));
-}
-
-bool ED_texture_context_check_lamp(const bContext *C)
-{
- Object *ob = CTX_data_active_object(C);
- return (ob && (ob->type == OB_LAMP));
-}
-
-bool ED_texture_context_check_particles(const bContext *C)
-{
- Object *ob = CTX_data_active_object(C);
- return (ob && ob->particlesystem.first);
-}
-
-bool ED_texture_context_check_linestyle(const bContext *C)
-{
-#ifdef WITH_FREESTYLE
- Scene *scene = CTX_data_scene(C);
- ViewLayer *active_view_layer;
- FreestyleConfig *config;
- FreestyleLineSet *lineset;
- FreestyleLineStyle *linestyle;
-
- if (scene && (scene->r.mode & R_EDGE_FRS)) {
- active_view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer);
- config = &active_view_layer->freestyle_config;
- if (config->mode == FREESTYLE_CONTROL_EDITOR_MODE) {
- lineset = BKE_freestyle_lineset_get_active(config);
- if (lineset) {
- linestyle = lineset->linestyle;
- return linestyle && (linestyle->flag & LS_TEXTURE);
- }
- }
- }
-#else
- (void)C;
-#endif
- return false;
-}
-
-static void texture_context_check_modifier_foreach(void *userData, Object *UNUSED(ob), ModifierData *UNUSED(md),
- const char *UNUSED(propname))
-{
- *((bool *)userData) = true;
-}
-
-bool ED_texture_context_check_others(const bContext *C)
-{
- /* We cannot rely on sbuts->texuser here, as it is NULL when in "old" tex handling, non-OTHERS tex context. */
- Object *ob = CTX_data_active_object(C);
-
- /* object */
- if (ob) {
- /* Tex force field. */
- if (ob->pd && ob->pd->forcefield == PFIELD_TEXTURE) {
- return true;
- }
-
- /* modifiers */
- {
- bool check = false;
- modifiers_foreachTexLink(ob, texture_context_check_modifier_foreach, &check);
- if (check) {
- return true;
- }
- }
- }
-
- /* brush */
- if (BKE_paint_brush(BKE_paint_get_active_from_context(C))) {
- return true;
- }
-
- return false;
-}
-
-static void set_texture_context(const bContext *C, SpaceButs *sbuts)
-{
- Scene *scene = CTX_data_scene(C);
-
- if (BKE_scene_use_new_shading_nodes(scene)) {
- return; /* No texture context in new shading mode */
- }
-
- {
- bool valid_world = ED_texture_context_check_world(C);
- bool valid_material = ED_texture_context_check_material(C);
- bool valid_lamp = ED_texture_context_check_lamp(C);
- bool valid_particles = ED_texture_context_check_particles(C);
- bool valid_linestyle = ED_texture_context_check_linestyle(C);
- bool valid_others = ED_texture_context_check_others(C);
-
- /* this is similar to direct user action, no need to keep "better" ctxt in _prev */
- if ((sbuts->mainb == BCONTEXT_WORLD) && valid_world) {
- sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_WORLD;
- }
- else if ((sbuts->mainb == BCONTEXT_MATERIAL) && valid_material) {
- sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_MATERIAL;
- }
- else if ((sbuts->mainb == BCONTEXT_DATA) && valid_lamp) {
- sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_LAMP;
- }
- else if ((sbuts->mainb == BCONTEXT_PARTICLE) && valid_particles) {
- sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_PARTICLES;
- }
- else if ((sbuts->mainb == BCONTEXT_VIEW_LAYER) && valid_linestyle) {
- sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_LINESTYLE;
- }
- else if ((ELEM(sbuts->mainb, BCONTEXT_MODIFIER, BCONTEXT_PHYSICS)) && valid_others) {
- sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_OTHER;
- }
- /* Else, try to revive a previous "better" ctxt... */
- else if ((sbuts->texture_context_prev != sbuts->texture_context) &&
- (((sbuts->texture_context_prev == SB_TEXC_WORLD) && valid_world) ||
- ((sbuts->texture_context_prev == SB_TEXC_MATERIAL) && valid_material) ||
- ((sbuts->texture_context_prev == SB_TEXC_LAMP) && valid_lamp) ||
- ((sbuts->texture_context_prev == SB_TEXC_PARTICLES) && valid_particles) ||
- ((sbuts->texture_context_prev == SB_TEXC_LINESTYLE) && valid_linestyle) ||
- ((sbuts->texture_context_prev == SB_TEXC_OTHER) && valid_others)))
- {
- sbuts->texture_context = sbuts->texture_context_prev;
- }
- /* Else, just be sure that current context is valid! */
- else if (((sbuts->texture_context == SB_TEXC_WORLD) && !valid_world) ||
- ((sbuts->texture_context == SB_TEXC_MATERIAL) && !valid_material) ||
- ((sbuts->texture_context == SB_TEXC_LAMP) && !valid_lamp) ||
- ((sbuts->texture_context == SB_TEXC_PARTICLES) && !valid_particles) ||
- ((sbuts->texture_context == SB_TEXC_LINESTYLE) && !valid_linestyle) ||
- ((sbuts->texture_context == SB_TEXC_OTHER) && !valid_others))
- {
- /* this is default fallback, do keep "better" ctxt in _prev */
- sbuts->texture_context_prev = sbuts->texture_context;
- if (valid_material) {
- sbuts->texture_context = SB_TEXC_MATERIAL;
- }
- else if (valid_lamp) {
- sbuts->texture_context = SB_TEXC_LAMP;
- }
- else if (valid_particles) {
- sbuts->texture_context = SB_TEXC_PARTICLES;
- }
- else if (valid_linestyle) {
- sbuts->texture_context = SB_TEXC_LINESTYLE;
- }
- else if (valid_world) {
- sbuts->texture_context = SB_TEXC_WORLD;
- }
- else if (valid_others) {
- sbuts->texture_context = SB_TEXC_OTHER;
- }
- }
- }
-}
-
/************************* Texture User **************************/
static void buttons_texture_user_property_add(ListBase *users, ID *id,
@@ -322,9 +152,6 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
{
Scene *scene = NULL;
Object *ob = NULL;
- Material *ma = NULL;
- Lamp *la = NULL;
- World *wrld = NULL;
WorkSpace *workspace = NULL;
FreestyleLineStyle *linestyle = NULL;
Brush *brush = NULL;
@@ -337,12 +164,6 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
scene = (Scene *)pinid;
else if (GS(pinid->name) == ID_OB)
ob = (Object *)pinid;
- else if (GS(pinid->name) == ID_LA)
- la = (Lamp *)pinid;
- else if (GS(pinid->name) == ID_WO)
- wrld = (World *)pinid;
- else if (GS(pinid->name) == ID_MA)
- ma = (Material *)pinid;
else if (GS(pinid->name) == ID_BR)
brush = (Brush *)pinid;
else if (GS(pinid->name) == ID_LS)
@@ -360,7 +181,6 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
if (workspace == NULL) {
- wrld = scene->world;
linestyle = BKE_linestyle_active_from_scene(scene);
workspace = CTX_wm_workspace(C);
}
@@ -369,20 +189,9 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
ob = OBACT(view_layer);
}
- if (ob && ob->type == OB_LAMP && !la)
- la = ob->data;
- if (ob && !ma)
- ma = give_current_material(ob, ob->actcol);
-
/* fill users */
BLI_listbase_clear(users);
- if (ma && !limited_mode)
- buttons_texture_users_find_nodetree(users, &ma->id, ma->nodetree, N_("Material"));
- if (la && !limited_mode)
- buttons_texture_users_find_nodetree(users, &la->id, la->nodetree, N_("Lamp"));
- if (wrld && !limited_mode)
- buttons_texture_users_find_nodetree(users, &wrld->id, wrld->nodetree, N_("World"));
if (linestyle && !limited_mode)
buttons_texture_users_find_nodetree(users, &linestyle->id, linestyle->nodetree, N_("Line Style"));
@@ -451,21 +260,8 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts)
/* gather available texture users in context. runs on every draw of
* properties editor, before the buttons are created. */
ButsContextTexture *ct = sbuts->texuser;
- Scene *scene = CTX_data_scene(C);
ID *pinid = sbuts->pinid;
- set_texture_context(C, sbuts);
-
- if (!((sbuts->texture_context == SB_TEXC_OTHER) || BKE_scene_use_new_shading_nodes(scene))) {
- if (ct) {
- BLI_freelistN(&ct->users);
- MEM_freeN(ct);
- sbuts->texuser = NULL;
- }
-
- return;
- }
-
if (!ct) {
ct = MEM_callocN(sizeof(ButsContextTexture), "ButsContextTexture");
sbuts->texuser = ct;
@@ -699,4 +495,3 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope
UI_but_func_set(but, template_texture_show, user->ptr.data, user->prop);
}
}
-
diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c
index d2a7244eded..3b1f423b5ef 100644
--- a/source/blender/editors/space_clip/clip_toolbar.c
+++ b/source/blender/editors/space_clip/clip_toolbar.c
@@ -32,6 +32,7 @@
#include <string.h>
#include "DNA_windowmanager_types.h"
+#include "DNA_workspace_types.h"
#include "MEM_guardedalloc.h"
@@ -118,19 +119,30 @@ void CLIP_OT_properties(wmOperatorType *ot)
static ARegion *clip_has_tools_region(ScrArea *sa)
{
- ARegion *ar, *artool = NULL, *arprops = NULL, *arhead;
+ ARegion *ar, *artool = NULL, *arhead;
+#ifndef WITH_REDO_REGION_REMOVAL
+ ARegion *arprops = NULL;
+#endif
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_TOOLS)
artool = ar;
+#ifndef WITH_REDO_REGION_REMOVAL
if (ar->regiontype == RGN_TYPE_TOOL_PROPS)
arprops = ar;
+#endif
}
/* tool region hide/unhide also hides props */
- if (arprops && artool)
+ if (artool
+#ifndef WITH_REDO_REGION_REMOVAL
+ && arprops
+#endif
+ )
+ {
return artool;
+ }
if (artool == NULL) {
/* add subdiv level; after header */
@@ -149,6 +161,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa)
artool->flag = RGN_FLAG_HIDDEN;
}
+#ifndef WITH_REDO_REGION_REMOVAL
if (arprops == NULL) {
/* add extra subdivided region for tool properties */
arprops = MEM_callocN(sizeof(ARegion), "tool props for clip");
@@ -157,6 +170,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa)
arprops->regiontype = RGN_TYPE_TOOL_PROPS;
arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
}
+#endif
return artool;
}
@@ -189,11 +203,13 @@ void CLIP_OT_tools(wmOperatorType *ot)
ot->poll = tools_poll;
}
+#ifndef WITH_REDO_REGION_REMOVAL
+
/************************** redo panel ******************************/
static void clip_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op)
{
- uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, 'V', 0);
+ uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0);
}
static void clip_panel_operator_redo_header(const bContext *C, Panel *pa)
@@ -263,3 +279,4 @@ void ED_clip_tool_props_register(ARegionType *art)
pt->draw = clip_panel_operator_redo;
BLI_addtail(&art->paneltypes, pt);
}
+#endif
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 478254fb165..ba9684411b3 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -256,12 +256,14 @@ static SpaceLink *clip_new(const bContext *C)
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
- /* tool properties */
+#ifndef WITH_REDO_REGION_REMOVAL
+ /* tools view */
ar = MEM_callocN(sizeof(ARegion), "tool properties for clip");
BLI_addtail(&sc->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOL_PROPS;
ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
+#endif
/* properties view */
ar = MEM_callocN(sizeof(ARegion), "properties for clip");
@@ -889,20 +891,25 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
ARegion *ar_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
- ARegion *ar_tool_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
ARegion *ar_preview = ED_clip_has_preview_region(C, sa);
ARegion *ar_properties = ED_clip_has_properties_region(sa);
ARegion *ar_channels = ED_clip_has_channels_region(sa);
bool main_visible = false, preview_visible = false, tools_visible = false;
- bool tool_props_visible = false, properties_visible = false, channels_visible = false;
+ bool properties_visible = false, channels_visible = false;
bool view_changed = false;
+#ifndef WITH_REDO_REGION_REMOVAL
+ ARegion *ar_tool_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
+ bool tool_props_visible = false;
+#endif
switch (sc->view) {
case SC_VIEW_CLIP:
main_visible = true;
preview_visible = false;
tools_visible = true;
+#ifndef WITH_REDO_REGION_REMOVAL
tool_props_visible = true;
+#endif
properties_visible = true;
channels_visible = false;
break;
@@ -910,7 +917,9 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
main_visible = false;
preview_visible = true;
tools_visible = false;
+#ifndef WITH_REDO_REGION_REMOVAL
tool_props_visible = false;
+#endif
properties_visible = false;
channels_visible = false;
@@ -920,7 +929,9 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
main_visible = false;
preview_visible = true;
tools_visible = false;
+#ifndef WITH_REDO_REGION_REMOVAL
tool_props_visible = false;
+#endif
properties_visible = false;
channels_visible = true;
@@ -1001,6 +1012,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
}
}
+#ifndef WITH_REDO_REGION_REMOVAL
if (tool_props_visible) {
if (ar_tool_props && (ar_tool_props->flag & RGN_FLAG_HIDDEN)) {
ar_tool_props->flag &= ~RGN_FLAG_HIDDEN;
@@ -1024,6 +1036,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
view_changed = true;
}
}
+#endif
if (preview_visible) {
if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
@@ -1607,6 +1620,7 @@ void ED_spacetype_clip(void)
BLI_addhead(&st->regiontypes, art);
+#ifndef WITH_REDO_REGION_REMOVAL
/* tool properties */
art = MEM_callocN(sizeof(ARegionType), "spacetype clip tool properties region");
art->regionid = RGN_TYPE_TOOL_PROPS;
@@ -1619,6 +1633,7 @@ void ED_spacetype_clip(void)
ED_clip_tool_props_register(art);
BLI_addhead(&st->regiontypes, art);
+#endif
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype clip region");
diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c
index 583beef5001..2c6ef20f1c4 100644
--- a/source/blender/editors/space_clip/tracking_ops_orient.c
+++ b/source/blender/editors/space_clip/tracking_ops_orient.c
@@ -405,7 +405,7 @@ static int set_plane_exec(bContext *C, wmOperator *op)
ListBase *tracksbase;
Object *object;
Object *camera = get_camera_with_movieclip(scene, clip);
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
int tot = 0;
float vec[3][3], mat[4][4], obmat[4][4], newmat[4][4], orig[3] = {0.0f, 0.0f, 0.0f};
int plane = RNA_enum_get(op->ptr, "plane");
@@ -430,8 +430,6 @@ static int set_plane_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- CTX_data_eval_ctx(C, &eval_ctx);
-
BKE_tracking_get_camera_object_matrix(scene, camera, mat);
/* Get 3 bundles to use as reference. */
@@ -494,7 +492,7 @@ static int set_plane_exec(bContext *C, wmOperator *op)
BKE_object_apply_mat4(object, mat, 0, 0);
}
- BKE_object_where_is_calc(&eval_ctx, scene, object);
+ BKE_object_where_is_calc(depsgraph, scene, object);
set_axis(scene, object, clip, tracking_object, axis_track, 'X');
DEG_id_tag_update(&clip->id, 0);
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 1839e861518..363e9666399 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -88,7 +88,8 @@ static void file_panel_operator(const bContext *C, Panel *pa)
UI_block_func_set(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL);
- uiTemplateOperatorPropertyButs(C, pa->layout, op, file_panel_check_prop, '\0', UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);
+ uiTemplateOperatorPropertyButs(C, pa->layout, op, file_panel_check_prop, UI_BUT_LABEL_ALIGN_NONE,
+ UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);
UI_block_func_set(uiLayoutGetBlock(pa->layout), NULL, NULL, NULL);
}
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 0fe51ea1c70..61ea4961f3e 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -646,7 +646,7 @@ static void file_tools_region_listener(
#if 0
/* context changes */
switch (wmn->category) {
-
+ /* pass */
}
#endif
}
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index a424084f6b1..b09de2470a2 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -57,6 +57,9 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_message.h"
+
+#include "RNA_access.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -226,6 +229,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceIpo *sipo = CTX_wm_space_graph(C);
+ Scene *scene = CTX_data_scene(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
View2DGrid *grid;
@@ -246,7 +250,12 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+
+ /* start and end frame (in F-Curve mode only) */
+ if (sipo->mode != SIPO_MODE_DRIVERS) {
+ ANIM_draw_framerange(scene, v2d);
+ }
+
/* draw data */
if (ANIM_animdata_get_context(C, &ac)) {
/* draw ghost curves */
@@ -427,6 +436,7 @@ static void graph_region_listener(
case ND_RENDER_OPTIONS:
case ND_OB_ACTIVE:
case ND_FRAME:
+ case ND_FRAME_RANGE:
case ND_MARKERS:
ED_region_tag_redraw(ar);
break;
@@ -474,6 +484,46 @@ static void graph_region_listener(
}
}
+static void graph_region_message_subscribe(
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *UNUSED(workspace), struct Scene *scene,
+ struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ PointerRNA ptr;
+ RNA_pointer_create(&screen->id, &RNA_SpaceGraphEditor, sa->spacedata.first, &ptr);
+
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ /* Timeline depends on scene properties. */
+ {
+ bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
+ extern PropertyRNA rna_Scene_frame_start;
+ extern PropertyRNA rna_Scene_frame_end;
+ extern PropertyRNA rna_Scene_frame_preview_start;
+ extern PropertyRNA rna_Scene_frame_preview_end;
+ extern PropertyRNA rna_Scene_use_preview_range;
+ extern PropertyRNA rna_Scene_frame_current;
+ const PropertyRNA *props[] = {
+ use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
+ use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
+ &rna_Scene_use_preview_range,
+ &rna_Scene_frame_current,
+ };
+
+ PointerRNA idptr;
+ RNA_id_pointer_create(&scene->id, &idptr);
+
+ for (int i = 0; i < ARRAY_SIZE(props); i++) {
+ WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
+ }
+ }
+}
+
/* editor level listener */
static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
WorkSpace *UNUSED(workspace))
@@ -735,6 +785,7 @@ void ED_spacetype_ipo(void)
art->init = graph_main_region_init;
art->draw = graph_main_region_draw;
art->listener = graph_region_listener;
+ art->message_subscribe = graph_region_message_subscribe;
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 43d5348da3e..e1ba83a0d78 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -548,118 +548,6 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
}
}
-static unsigned int *get_part_from_buffer(unsigned int *buffer, int width, short startx, short starty, short endx, short endy)
-{
- unsigned int *rt, *rp, *rectmain;
- short y, heigth, len;
-
- /* the right offset in rectot */
-
- rt = buffer + (starty * width + startx);
-
- len = (endx - startx);
- heigth = (endy - starty);
-
- rp = rectmain = MEM_mallocN(heigth * len * sizeof(int), "rect");
-
- for (y = 0; y < heigth; y++) {
- memcpy(rp, rt, len * 4);
- rt += width;
- rp += len;
- }
- return rectmain;
-}
-
-static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
-{
- unsigned char *display_buffer;
- unsigned int *rect;
- int dx, dy, sx, sy, x, y;
- void *cache_handle;
- float shuffle[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-
- /* verify valid values, just leave this a while */
- if (ima->xrep < 1) return;
- if (ima->yrep < 1) return;
-
- if (ima->flag & IMA_VIEW_AS_RENDER)
- display_buffer = IMB_display_buffer_acquire(ibuf, &scene->view_settings, &scene->display_settings, &cache_handle);
- else
- display_buffer = IMB_display_buffer_acquire(ibuf, NULL, &scene->display_settings, &cache_handle);
-
- if (!display_buffer)
- return;
-
- if (sima->curtile >= ima->xrep * ima->yrep)
- sima->curtile = ima->xrep * ima->yrep - 1;
-
- /* retrieve part of image buffer */
- dx = max_ii(ibuf->x / ima->xrep, 1);
- dy = max_ii(ibuf->y / ima->yrep, 1);
- sx = (sima->curtile % ima->xrep) * dx;
- sy = (sima->curtile / ima->xrep) * dy;
- rect = get_part_from_buffer((unsigned int *)display_buffer, ibuf->x, sx, sy, sx + dx, sy + dy);
-
- /* draw repeated */
- if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B | SI_SHOW_ALPHA)) != 0) {
- if (sima->flag & SI_SHOW_R)
- shuffle[0] = 1.0f;
- else if (sima->flag & SI_SHOW_G)
- shuffle[1] = 1.0f;
- else if (sima->flag & SI_SHOW_B)
- shuffle[2] = 1.0f;
- else if (sima->flag & SI_SHOW_ALPHA)
- shuffle[3] = 1.0f;
- }
-
- for (sy = 0; sy + dy <= ibuf->y; sy += dy) {
- for (sx = 0; sx + dx <= ibuf->x; sx += dx) {
- UI_view2d_view_to_region(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y);
-
- if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B | SI_SHOW_ALPHA)) == 0) {
- IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
- immDrawPixelsTex(&state, x, y, dx, dy, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, zoomx, zoomy, NULL);
- }
- else {
- IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
- GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle);
-
- immDrawPixelsTex(&state, x, y, dx, dy, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, zoomx, zoomy, NULL);
- }
- }
- }
-
- IMB_display_buffer_release(cache_handle);
-
- MEM_freeN(rect);
-}
-
-static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy)
-{
- const double time_current = PIL_check_seconds_timer();
-
- const int xmax = ceil(ar->v2d.cur.xmax);
- const int ymax = ceil(ar->v2d.cur.ymax);
- const int xmin = floor(ar->v2d.cur.xmin);
- const int ymin = floor(ar->v2d.cur.ymin);
-
- int x;
-
- for (x = xmin; x < xmax; x++) {
- int y;
- for (y = ymin; y < ymax; y++) {
- if (ima && (ima->tpageflag & IMA_TILES))
- draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
- else
- draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy);
-
- /* only draw until running out of time */
- if ((PIL_check_seconds_timer() - time_current) > 0.25)
- return;
- }
- }
-}
-
/* draw uv edit */
/* draw grease pencil */
@@ -810,14 +698,8 @@ void draw_image_main(const bContext *C, ARegion *ar)
ED_region_grid_draw(ar, zoomx, zoomy);
}
else {
+ draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
- if (sima->flag & SI_DRAW_TILE)
- draw_image_buffer_repeated(C, sima, ar, scene, ima, ibuf, zoomx, zoomy);
- else if (ima && (ima->tpageflag & IMA_TILES))
- draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy);
- else
- draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
-
if (sima->flag & SI_DRAW_METADATA) {
int x, y;
rctf frame;
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index c719af9e0e2..c598e486a7e 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -63,11 +63,8 @@ Image *ED_space_image(SpaceImage *sima)
}
/* called to assign images to UV faces */
-void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
+void ED_space_image_set(SpaceImage *sima, Scene *UNUSED(scene), Object *obedit, Image *ima)
{
- /* context may be NULL, so use global */
- ED_uvedit_assign_image(G.main, scene, obedit, ima, sima->image);
-
/* change the space ima after because uvedit_face_visible_test uses the space ima
* to check if the face is displayed in UV-localview */
sima->image = ima;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 9162b8b76a9..a2afb5cb5c5 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -73,7 +73,6 @@
#include "DEG_depsgraph.h"
#include "GPU_draw.h"
-#include "GPU_buffers.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
@@ -1432,7 +1431,7 @@ static void image_open_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
@@ -2148,7 +2147,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
/* multiview template */
if (is_multiview)
@@ -2445,7 +2444,6 @@ static int image_new_exec(bContext *C, wmOperator *op)
bScreen *sc;
Object *ob = CTX_data_active_object(C);
- GPU_drawobject_free(ob->derivedFinal);
if (scene->toolsettings->imapaint.canvas)
id_us_min(&scene->toolsettings->imapaint.canvas->id);
scene->toolsettings->imapaint.canvas = ima;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 54037059cc3..38a850568fd 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -410,7 +410,6 @@ static void image_refresh(const bContext *C, ScrArea *sa)
{
Scene *scene = CTX_data_scene(C);
SpaceImage *sima = sa->spacedata.first;
- Object *obedit = CTX_data_edit_object(C);
Image *ima;
ima = ED_space_image(sima);
@@ -426,32 +425,6 @@ static void image_refresh(const bContext *C, ScrArea *sa)
}
}
}
- else if (ima && (ima->source == IMA_SRC_VIEWER || sima->pin)) {
- /* pass */
- }
- else if (obedit && obedit->type == OB_MESH) {
- Mesh *me = (Mesh *)obedit->data;
- struct BMEditMesh *em = me->edit_btmesh;
- bool sloppy = true; /* partially selected face is ok */
- bool selected = !(scene->toolsettings->uv_flag & UV_SYNC_SELECTION); /* only selected active face? */
-
- if (BKE_scene_use_new_shading_nodes(scene)) {
- /* new shading system does not alter image */
- }
- else {
- /* old shading system, we set texface */
- if (em && EDBM_uv_check(em)) {
- BMFace *efa = BM_mesh_active_face_get(em->bm, sloppy, selected);
-
- if (efa) {
- /* don't need to check for pin here, see above */
- Image *image = BKE_object_material_edit_image_get(obedit, efa->mat_nr);
-
- sima->image = image;
- }
- }
- }
- }
}
static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *scene,
diff --git a/source/blender/editors/space_logic/CMakeLists.txt b/source/blender/editors/space_logic/CMakeLists.txt
deleted file mode 100644
index 349c003cf56..00000000000
--- a/source/blender/editors/space_logic/CMakeLists.txt
+++ /dev/null
@@ -1,58 +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.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- ../include
- ../interface
- ../../blenkernel
- ../../blenlib
- ../../blentranslation
- ../../gpu
- ../../makesdna
- ../../makesrna
- ../../windowmanager
- ../../../../intern/guardedalloc
- ../../../../intern/glew-mx
-)
-
-set(INC_SYS
- ${GLEW_INCLUDE_PATH}
-)
-
-set(SRC
- logic_buttons.c
- logic_ops.c
- logic_window.c
- space_logic.c
-
- logic_intern.h
-)
-
-if(WITH_GAMEENGINE)
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
-add_definitions(${GL_DEFINITIONS})
-
-if(WITH_INTERNATIONAL)
- add_definitions(-DWITH_INTERNATIONAL)
-endif()
-
-blender_add_lib(bf_editor_space_logic "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c
deleted file mode 100644
index 54e6e217b77..00000000000
--- a/source/blender/editors/space_logic/logic_buttons.c
+++ /dev/null
@@ -1,166 +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 by Blender Foundation
- * All rights reserved.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_logic/logic_buttons.c
- * \ingroup splogic
- */
-
-
-#include <string.h>
-#include <stdio.h>
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_context.h"
-
-#include "ED_screen.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "UI_interface.h"
-#include "UI_view2d.h"
-
-#include "interface_intern.h"
-#include "logic_intern.h"
-
-static int logic_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = logic_has_buttons_region(sa);
-
- if (ar)
- ED_region_toggle_hidden(C, ar);
-
- return OPERATOR_FINISHED;
-}
-
-void LOGIC_OT_properties(wmOperatorType *ot)
-{
- ot->name = "Properties";
- ot->description = "Toggle the properties region visibility";
- ot->idname = "LOGIC_OT_properties";
-
- ot->exec = logic_properties_toggle_exec;
- ot->poll = ED_operator_logic_active;
-
- /* flags */
- ot->flag = 0;
-}
-
-/* Remove Logic Bricks Connections */
-/* ********************** Cut Link operator ***************** */
-
-#define LINK_RESOL 12
-static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot)
-{
- float coord_array[LINK_RESOL+1][2];
- int i, b;
- rcti rectlink;
-
- rectlink.xmin = (int)BLI_rctf_cent_x(&line->from->rect);
- rectlink.ymin = (int)BLI_rctf_cent_y(&line->from->rect);
- rectlink.xmax = (int)BLI_rctf_cent_x(&line->to->rect);
- rectlink.ymax = (int)BLI_rctf_cent_y(&line->to->rect);
-
- if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) {
- for (i=0; i<tot-1; i++)
- for (b=0; b<LINK_RESOL-1; b++)
- if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0)
- return 1;
- }
- return 0;
-}
-
-static int cut_links_exec(bContext *C, wmOperator *op)
-{
- ARegion *ar = CTX_wm_region(C);
- float mcoords[256][2];
- int i = 0;
-
- RNA_BEGIN (op->ptr, itemptr, "path")
- {
- float loc[2];
-
- RNA_float_get_array(&itemptr, "loc", loc);
- UI_view2d_region_to_view(&ar->v2d,
- (int)loc[0], (int)loc[1],
- &mcoords[i][0], &mcoords[i][1]);
- i++;
- if (i >= 256) break;
- }
- RNA_END;
-
- if (i>1) {
- uiBlock *block;
- uiLinkLine *line, *nline;
- uiBut *but;
- for (block = ar->uiblocks.first; block; block = block->next) {
- but = block->buttons.first;
- while (but) {
- if (but->type==UI_BTYPE_LINK && but->link) {
- for (line = but->link->lines.first; line; line = nline) {
- nline = line->next;
-
- if (cut_links_intersect(line, mcoords, i)) {
- ui_linkline_remove(line, but);
- }
- }
- }
- but = but->next;
- }
- }
- return OPERATOR_FINISHED;
- }
- return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH;
-}
-
-void LOGIC_OT_links_cut(wmOperatorType *ot)
-{
- ot->name = "Cut Links";
- ot->idname = "LOGIC_OT_links_cut";
- ot->description = "Remove logic brick connections";
-
- ot->invoke = WM_gesture_lines_invoke;
- ot->modal = WM_gesture_lines_modal;
- ot->exec = cut_links_exec;
- ot->cancel = WM_gesture_lines_cancel;
-
- ot->poll = ED_operator_logic_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-
- /* properties */
- PropertyRNA *prop;
- prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
- /* internal */
- RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
-}
-
diff --git a/source/blender/editors/space_logic/logic_intern.h b/source/blender/editors/space_logic/logic_intern.h
deleted file mode 100644
index 13146621d1b..00000000000
--- a/source/blender/editors/space_logic/logic_intern.h
+++ /dev/null
@@ -1,55 +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): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_logic/logic_intern.h
- * \ingroup splogic
- */
-
-
-#ifndef __LOGIC_INTERN_H__
-#define __LOGIC_INTERN_H__
-
-/* internal exports only */
-struct bContext;
-struct ARegion;
-struct ScrArea;
-struct wmOperatorType;
-
-/* space_logic.c */
-struct ARegion *logic_has_buttons_region(struct ScrArea *sa);
-
-/* logic_ops.c */
-
-/* logic_buttons.c */
-void LOGIC_OT_properties(struct wmOperatorType *ot);
-void LOGIC_OT_links_cut(struct wmOperatorType *ot);
-
-/* logic_window.c */
-void logic_buttons(struct bContext *C, struct ARegion *ar);
-void make_unique_prop_names(struct bContext *C, char *str);
-
-#endif /* __LOGIC_INTERN_H__ */
-
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c
deleted file mode 100644
index 7b9a8634490..00000000000
--- a/source/blender/editors/space_logic/logic_ops.c
+++ /dev/null
@@ -1,753 +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): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_logic/logic_ops.c
- * \ingroup splogic
- */
-
-#include <stddef.h>
-
-#include "DNA_object_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_scene_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_string_utils.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "BKE_context.h"
-#include "BKE_main.h"
-#include "BKE_sca.h"
-
-#include "ED_logic.h"
-#include "ED_object.h"
-#include "ED_screen.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-#include "RNA_enum_types.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "UI_view2d.h"
-
-#include "logic_intern.h"
-
-/* ************* Generic Operator Helpers ************* */
-static int edit_sensor_poll(bContext *C)
-{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "sensor", &RNA_Sensor);
-
- if (ptr.data && ID_IS_LINKED(ptr.id.data)) return 0;
- return 1;
-}
-
-static int edit_controller_poll(bContext *C)
-{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "controller", &RNA_Controller);
-
- if (ptr.data && ID_IS_LINKED(ptr.id.data)) return 0;
- return 1;
-}
-
-static int edit_actuator_poll(bContext *C)
-{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "actuator", &RNA_Actuator);
-
- if (ptr.data && ID_IS_LINKED(ptr.id.data)) return 0;
- return 1;
-}
-
-static void edit_sensor_properties(wmOperatorType *ot)
-{
- RNA_def_string(ot->srna, "sensor", NULL, MAX_NAME, "Sensor", "Name of the sensor to edit");
- RNA_def_string(ot->srna, "object", NULL, MAX_NAME, "Object", "Name of the object the sensor belongs to");
-}
-
-static int edit_sensor_invoke_properties(bContext *C, wmOperator *op)
-{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "sensor", &RNA_Sensor);
-
- if (RNA_struct_property_is_set(op->ptr, "sensor") && RNA_struct_property_is_set(op->ptr, "object") )
- return 1;
-
- if (ptr.data) {
- bSensor *sens = ptr.data;
- Object *ob = ptr.id.data;
-
- RNA_string_set(op->ptr, "sensor", sens->name);
- RNA_string_set(op->ptr, "object", ob->id.name + 2);
- return 1;
- }
-
- return 0;
-}
-
-static Object *edit_object_property_get(bContext *C, wmOperator *op)
-{
- char ob_name[MAX_NAME];
- Object *ob;
-
- RNA_string_get(op->ptr, "object", ob_name);
-
- /* if ob_name is valid try to find the object with this name
- * otherwise gets the active object */
- if (*ob_name)
- ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2);
- else
- ob = ED_object_active_context(C);
-
- return ob;
-}
-
-static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **ob)
-{
- char sensor_name[MAX_NAME];
- bSensor *sens;
-
- RNA_string_get(op->ptr, "sensor", sensor_name);
-
- *ob = edit_object_property_get(C, op);
- if (!*ob) return NULL;
-
- sens = BLI_findstring(&((*ob)->sensors), sensor_name, offsetof(bSensor, name));
- return sens;
-}
-
-static void edit_controller_properties(wmOperatorType *ot)
-{
- RNA_def_string(ot->srna, "controller", NULL, MAX_NAME, "Controller", "Name of the controller to edit");
- RNA_def_string(ot->srna, "object", NULL, MAX_NAME, "Object", "Name of the object the controller belongs to");
-}
-
-static int edit_controller_invoke_properties(bContext *C, wmOperator *op)
-{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "controller", &RNA_Controller);
-
- if (RNA_struct_property_is_set(op->ptr, "controller") && RNA_struct_property_is_set(op->ptr, "object") )
- return 1;
-
- if (ptr.data) {
- bController *cont = ptr.data;
- Object *ob = ptr.id.data;
-
- RNA_string_set(op->ptr, "controller", cont->name);
- RNA_string_set(op->ptr, "object", ob->id.name + 2);
- return 1;
- }
-
- return 0;
-}
-
-static bController *edit_controller_property_get(bContext *C, wmOperator *op, Object **ob)
-{
- char controller_name[MAX_NAME];
- bController *cont;
-
- RNA_string_get(op->ptr, "controller", controller_name);
-
- *ob = edit_object_property_get(C, op);
- if (!*ob) return NULL;
-
- cont = BLI_findstring(&((*ob)->controllers), controller_name, offsetof(bController, name));
- return cont;
-}
-
-static void edit_actuator_properties(wmOperatorType *ot)
-{
- RNA_def_string(ot->srna, "actuator", NULL, MAX_NAME, "Actuator", "Name of the actuator to edit");
- RNA_def_string(ot->srna, "object", NULL, MAX_NAME, "Object", "Name of the object the actuator belongs to");
-}
-
-static int edit_actuator_invoke_properties(bContext *C, wmOperator *op)
-{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "actuator", &RNA_Actuator);
-
- if (RNA_struct_property_is_set(op->ptr, "actuator") && RNA_struct_property_is_set(op->ptr, "object") )
- return 1;
-
- if (ptr.data) {
- bActuator *act = ptr.data;
- Object *ob = ptr.id.data;
-
- RNA_string_set(op->ptr, "actuator", act->name);
- RNA_string_set(op->ptr, "object", ob->id.name + 2);
- return 1;
- }
-
- return 0;
-}
-
-static bActuator *edit_actuator_property_get(bContext *C, wmOperator *op, Object **ob)
-{
- char actuator_name[MAX_NAME];
- bActuator *act;
-
- RNA_string_get(op->ptr, "actuator", actuator_name);
-
- *ob = edit_object_property_get(C, op);
- if (!*ob) return NULL;
-
- act = BLI_findstring(&((*ob)->actuators), actuator_name, offsetof(bActuator, name));
- return act;
-}
-
-static int logicbricks_move_property_get(wmOperator *op)
-{
- int type = RNA_enum_get(op->ptr, "direction");
-
- if (type == 1)
- return true;
- else
- return false;
-}
-
-/* ************* Add/Remove Sensor Operator ************* */
-
-static int sensor_remove_exec(bContext *C, wmOperator *op)
-{
- Object *ob = NULL;
- bSensor *sens = edit_sensor_property_get(C, op, &ob);
-
- if (!sens)
- return OPERATOR_CANCELLED;
-
- BLI_remlink(&(ob->sensors), sens);
- free_sensor(sens);
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static int sensor_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- if (edit_sensor_invoke_properties(C, op))
- return sensor_remove_exec(C, op);
- else
- return OPERATOR_CANCELLED;
-}
-
-static void LOGIC_OT_sensor_remove(wmOperatorType *ot)
-{
- ot->name = "Remove Sensor";
- ot->description = "Remove a sensor from the active object";
- ot->idname = "LOGIC_OT_sensor_remove";
-
- ot->invoke = sensor_remove_invoke;
- ot->exec = sensor_remove_exec;
- ot->poll = edit_sensor_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
- edit_sensor_properties(ot);
-}
-
-static int sensor_add_exec(bContext *C, wmOperator *op)
-{
- Object *ob;
- bSensor *sens;
- PointerRNA sens_ptr;
- PropertyRNA *prop;
- const char *sens_name;
- char name[MAX_NAME];
- int type = RNA_enum_get(op->ptr, "type");
-
- ob = edit_object_property_get(C, op);
- if (!ob)
- return OPERATOR_CANCELLED;
-
- sens = new_sensor(type);
- BLI_addtail(&(ob->sensors), sens);
-
- /* set the sensor name based on rna type enum */
- RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &sens_ptr);
- prop = RNA_struct_find_property(&sens_ptr, "type");
-
- RNA_string_get(op->ptr, "name", name);
- if (*name) {
- BLI_strncpy(sens->name, name, sizeof(sens->name));
- }
- else {
- RNA_property_enum_name(C, &sens_ptr, prop, RNA_property_enum_get(&sens_ptr, prop), &sens_name);
- BLI_strncpy(sens->name, sens_name, sizeof(sens->name));
- }
-
- BLI_uniquename(&ob->sensors, sens, DATA_("Sensor"), '.', offsetof(bSensor, name), sizeof(sens->name));
- ob->scaflag |= OB_SHOWSENS;
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static void LOGIC_OT_sensor_add(wmOperatorType *ot)
-{
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Add Sensor";
- ot->description = "Add a sensor to the active object";
- ot->idname = "LOGIC_OT_sensor_add";
-
- /* api callbacks */
- ot->invoke = WM_menu_invoke;
- ot->exec = sensor_add_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
-
- /* properties */
- ot->prop = prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, SENS_ALWAYS, "Type", "Type of sensor to add");
- RNA_def_enum_funcs(prop, rna_Sensor_type_itemf);
- prop = RNA_def_string(ot->srna, "name", NULL, MAX_NAME, "Name", "Name of the Sensor to add");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_string(ot->srna, "object", NULL, MAX_NAME, "Object", "Name of the Object to add the Sensor to");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-}
-
-/* ************* Add/Remove Controller Operator ************* */
-
-static int controller_remove_exec(bContext *C, wmOperator *op)
-{
- Object *ob = NULL;
- bController *cont = edit_controller_property_get(C, op, &ob);
-
- if (!cont)
- return OPERATOR_CANCELLED;
-
- BLI_remlink(&(ob->controllers), cont);
- unlink_controller(cont);
- free_controller(cont);
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static int controller_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- if (edit_controller_invoke_properties(C, op))
- return controller_remove_exec(C, op);
- else
- return OPERATOR_CANCELLED;
-}
-
-static void LOGIC_OT_controller_remove(wmOperatorType *ot)
-{
- ot->name = "Remove Controller";
- ot->description = "Remove a controller from the active object";
- ot->idname = "LOGIC_OT_controller_remove";
-
- ot->invoke = controller_remove_invoke;
- ot->exec = controller_remove_exec;
- ot->poll = edit_controller_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
- edit_controller_properties(ot);
-}
-
-static int controller_add_exec(bContext *C, wmOperator *op)
-{
- Object *ob;
- bController *cont;
- PointerRNA cont_ptr;
- PropertyRNA *prop;
- const char *cont_name;
- int bit;
- char name[MAX_NAME];
- int type = RNA_enum_get(op->ptr, "type");
-
- ob = edit_object_property_get(C, op);
- if (!ob)
- return OPERATOR_CANCELLED;
-
- cont = new_controller(type);
- BLI_addtail(&(ob->controllers), cont);
-
- /* set the controller name based on rna type enum */
- RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &cont_ptr);
- prop = RNA_struct_find_property(&cont_ptr, "type");
-
- RNA_string_get(op->ptr, "name", name);
- if (*name) {
- BLI_strncpy(cont->name, name, sizeof(cont->name));
- }
- else {
- RNA_property_enum_name(C, &cont_ptr, prop, RNA_property_enum_get(&cont_ptr, prop), &cont_name);
- BLI_strncpy(cont->name, cont_name, sizeof(cont->name));
- }
-
- BLI_uniquename(&ob->controllers, cont, DATA_("Controller"), '.', offsetof(bController, name), sizeof(cont->name));
-
- /* set the controller state mask from the current object state.
- * A controller is always in a single state, so select the lowest bit set
- * from the object state */
- for (bit = 0; bit < OB_MAX_STATES; bit++) {
- if (ob->state & (1 << bit))
- break;
- }
- cont->state_mask = (1 << bit);
- if (cont->state_mask == 0) {
- /* shouldn't happen, object state is never 0 */
- cont->state_mask = 1;
- }
-
- ob->scaflag |= OB_SHOWCONT;
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static void LOGIC_OT_controller_add(wmOperatorType *ot)
-{
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Add Controller";
- ot->description = "Add a controller to the active object";
- ot->idname = "LOGIC_OT_controller_add";
-
- /* api callbacks */
- ot->invoke = WM_menu_invoke;
- ot->exec = controller_add_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
-
- /* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_controller_type_items, CONT_LOGIC_AND, "Type", "Type of controller to add");
- prop = RNA_def_string(ot->srna, "name", NULL, MAX_NAME, "Name", "Name of the Controller to add");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_string(ot->srna, "object", NULL, MAX_NAME, "Object", "Name of the Object to add the Controller to");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-}
-
-/* ************* Add/Remove Actuator Operator ************* */
-
-static int actuator_remove_exec(bContext *C, wmOperator *op)
-{
- Object *ob = NULL;
- bActuator *act = edit_actuator_property_get(C, op, &ob);
-
- if (!act)
- return OPERATOR_CANCELLED;
-
- BLI_remlink(&(ob->actuators), act);
- unlink_actuator(act);
- free_actuator(act);
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static int actuator_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- if (edit_actuator_invoke_properties(C, op))
- return actuator_remove_exec(C, op);
- else
- return OPERATOR_CANCELLED;
-}
-
-static void LOGIC_OT_actuator_remove(wmOperatorType *ot)
-{
- ot->name = "Remove Actuator";
- ot->description = "Remove an actuator from the active object";
- ot->idname = "LOGIC_OT_actuator_remove";
-
- ot->invoke = actuator_remove_invoke;
- ot->exec = actuator_remove_exec;
- ot->poll = edit_actuator_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
- edit_actuator_properties(ot);
-}
-
-static int actuator_add_exec(bContext *C, wmOperator *op)
-{
- Object *ob;
- bActuator *act;
- PointerRNA act_ptr;
- PropertyRNA *prop;
- const char *act_name;
- char name[MAX_NAME];
- int type = RNA_enum_get(op->ptr, "type");
-
- ob = edit_object_property_get(C, op);
- if (!ob)
- return OPERATOR_CANCELLED;
-
- act = new_actuator(type);
- BLI_addtail(&(ob->actuators), act);
-
- /* set the actuator name based on rna type enum */
- RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &act_ptr);
- prop = RNA_struct_find_property(&act_ptr, "type");
-
- RNA_string_get(op->ptr, "name", name);
- if (*name) {
- BLI_strncpy(act->name, name, sizeof(act->name));
- }
- else {
- RNA_property_enum_name(C, &act_ptr, prop, RNA_property_enum_get(&act_ptr, prop), &act_name);
- BLI_strncpy(act->name, act_name, sizeof(act->name));
- }
-
- BLI_uniquename(&ob->actuators, act, DATA_("Actuator"), '.', offsetof(bActuator, name), sizeof(act->name));
- ob->scaflag |= OB_SHOWACT;
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static void LOGIC_OT_actuator_add(wmOperatorType *ot)
-{
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Add Actuator";
- ot->description = "Add an actuator to the active object";
- ot->idname = "LOGIC_OT_actuator_add";
-
- /* api callbacks */
- ot->invoke = WM_menu_invoke;
- ot->exec = actuator_add_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
-
- /* properties */
- ot->prop = prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, CONT_LOGIC_AND, "Type", "Type of actuator to add");
- RNA_def_enum_funcs(prop, rna_Actuator_type_itemf);
- prop = RNA_def_string(ot->srna, "name", NULL, MAX_NAME, "Name", "Name of the Actuator to add");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_string(ot->srna, "object", NULL, MAX_NAME, "Object", "Name of the Object to add the Actuator to");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-}
-
-/* ************* Move Logic Bricks Operator ************* */
-static const EnumPropertyItem logicbricks_move_direction[] = {
- {1, "UP", 0, "Move Up", ""},
- {2, "DOWN", 0, "Move Down", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-
-static int sensor_move_exec(bContext *C, wmOperator *op)
-{
- Object *ob = NULL;
- bSensor *sens = edit_sensor_property_get(C, op, &ob);
- int move_up = logicbricks_move_property_get(op);
-
- if (!sens)
- return OPERATOR_CANCELLED;
-
- sca_move_sensor(sens, ob, move_up);
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static int sensor_move_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- if (edit_sensor_invoke_properties(C, op)) {
- return sensor_move_exec(C, op);
- }
- else
- return OPERATOR_CANCELLED;
-}
-
-static void LOGIC_OT_sensor_move(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Move Sensor";
- ot->description = "Move Sensor";
- ot->idname = "LOGIC_OT_sensor_move";
-
- /* api callbacks */
- ot->invoke = sensor_move_invoke;
- ot->exec = sensor_move_exec;
- ot->poll = edit_sensor_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
-
- /* properties */
- edit_sensor_properties(ot);
- RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down");
-}
-
-static int controller_move_exec(bContext *C, wmOperator *op)
-{
- Object *ob = NULL;
- bController *cont = edit_controller_property_get(C, op, &ob);
- int move_up = logicbricks_move_property_get(op);
-
- if (!cont)
- return OPERATOR_CANCELLED;
-
- sca_move_controller(cont, ob, move_up);
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static int controller_move_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- if (edit_controller_invoke_properties(C, op)) {
- return controller_move_exec(C, op);
- }
- else
- return OPERATOR_CANCELLED;
-}
-
-static void LOGIC_OT_controller_move(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Move Controller";
- ot->description = "Move Controller";
- ot->idname = "LOGIC_OT_controller_move";
-
- /* api callbacks */
- ot->invoke = controller_move_invoke;
- ot->exec = controller_move_exec;
- ot->poll = edit_controller_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
-
- /* properties */
- edit_controller_properties(ot);
- RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down");
-}
-
-static int actuator_move_exec(bContext *C, wmOperator *op)
-{
- Object *ob = NULL;
- bActuator *act = edit_actuator_property_get(C, op, &ob);
- int move_up = logicbricks_move_property_get(op);
-
- if (!act)
- return OPERATOR_CANCELLED;
-
- sca_move_actuator(act, ob, move_up);
-
- WM_event_add_notifier(C, NC_LOGIC, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static int actuator_move_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- if (edit_actuator_invoke_properties(C, op)) {
- return actuator_move_exec(C, op);
- }
- else
- return OPERATOR_CANCELLED;
-}
-
-static void LOGIC_OT_actuator_move(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Move Actuator";
- ot->description = "Move Actuator";
- ot->idname = "LOGIC_OT_actuator_move";
-
- /* api callbacks */
- ot->invoke = actuator_move_invoke;
- ot->exec = actuator_move_exec;
- ot->poll = edit_actuator_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
-
- /* properties */
- edit_actuator_properties(ot);
- RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down");
-}
-
-/* ************************ view ********************* */
-
-static int logic_view_all_exec(bContext *C, wmOperator *op)
-{
- ARegion *ar = CTX_wm_region(C);
- rctf cur_new = ar->v2d.tot;
- float aspect = BLI_rctf_size_y(&ar->v2d.cur) / BLI_rctf_size_x(&ar->v2d.cur);
- const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
-
- /* force the view2d code to zoom to width, not height */
- cur_new.ymin = cur_new.ymax - BLI_rctf_size_x(&cur_new) * aspect;
-
- UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
-
- return OPERATOR_FINISHED;
-}
-
-static void LOGIC_OT_view_all(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "View All";
- ot->idname = "LOGIC_OT_view_all";
- ot->description = "Resize view so you can see all logic bricks";
-
- /* api callbacks */
- ot->exec = logic_view_all_exec;
- ot->poll = ED_operator_logic_active;
-
- /* flags */
- ot->flag = 0;
-}
-
-/* ************************* */
-
-void ED_operatortypes_logic(void)
-{
- WM_operatortype_append(LOGIC_OT_sensor_remove);
- WM_operatortype_append(LOGIC_OT_sensor_add);
- WM_operatortype_append(LOGIC_OT_sensor_move);
- WM_operatortype_append(LOGIC_OT_controller_remove);
- WM_operatortype_append(LOGIC_OT_controller_add);
- WM_operatortype_append(LOGIC_OT_controller_move);
- WM_operatortype_append(LOGIC_OT_actuator_remove);
- WM_operatortype_append(LOGIC_OT_actuator_add);
- WM_operatortype_append(LOGIC_OT_actuator_move);
- WM_operatortype_append(LOGIC_OT_view_all);
-}
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
deleted file mode 100644
index 9bdc92f98ab..00000000000
--- a/source/blender/editors/space_logic/logic_window.c
+++ /dev/null
@@ -1,2594 +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): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_logic/logic_window.c
- * \ingroup splogic
- */
-
-
-#include <string.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <float.h>
-
-#include "DNA_actuator_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_property_types.h"
-#include "DNA_space_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_object_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_string_utils.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_action.h"
-#include "BKE_context.h"
-#include "BKE_library.h"
-#include "BKE_main.h"
-#include "BKE_sca.h"
-
-#include "ED_undo.h"
-
-#include "BLT_translation.h"
-
-#include "UI_interface.h"
-#include "UI_view2d.h"
-
-#include "RNA_access.h"
-
-/* XXX BAD BAD */
-#include "../interface/interface_intern.h"
-
-#include "logic_intern.h"
-
-#define B_REDR 1
-
-#define B_ADD_SENS 2703
-#define B_CHANGE_SENS 2704
-#define B_DEL_SENS 2705
-
-#define B_ADD_CONT 2706
-#define B_CHANGE_CONT 2707
-#define B_DEL_CONT 2708
-
-#define B_ADD_ACT 2709
-#define B_CHANGE_ACT 2710
-#define B_DEL_ACT 2711
-
-#define B_SOUNDACT_BROWSE 2712
-
-#define B_SETPROP 2714
-#define B_SETACTOR 2715
-#define B_SETMAINACTOR 2716
-#define B_SETDYNA 2717
-#define B_SET_STATE_BIT 2718
-#define B_INIT_STATE_BIT 2719
-
-/* proto */
-static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisflag);
-
-static void do_logic_buts(bContext *C, void *UNUSED(arg), int event)
-{
- Main *bmain= CTX_data_main(C);
- bSensor *sens;
- bController *cont;
- bActuator *act;
- Object *ob;
- int didit, bit;
-
- ob= CTX_data_active_object(C);
- if (ob==NULL) return;
-
- switch (event) {
-
- case B_SETPROP:
- /* check for inconsistent types */
- ob->gameflag &= ~(OB_SECTOR|OB_MAINACTOR|OB_DYNAMIC|OB_ACTOR);
- break;
-
- case B_SETACTOR:
- case B_SETDYNA:
- case B_SETMAINACTOR:
- ob->gameflag &= ~(OB_SECTOR|OB_PROP);
- break;
-
- case B_ADD_SENS:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- if (ob->scaflag & OB_ADDSENS) {
- ob->scaflag &= ~OB_ADDSENS;
- sens= new_sensor(SENS_ALWAYS);
- BLI_addtail(&(ob->sensors), sens);
- BLI_uniquename(&ob->sensors, sens, DATA_("Sensor"), '.', offsetof(bSensor, name), sizeof(sens->name));
- ob->scaflag |= OB_SHOWSENS;
- }
- }
-
- ED_undo_push(C, "Add sensor");
- break;
-
- case B_CHANGE_SENS:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- sens= ob->sensors.first;
- while (sens) {
- if (sens->type != sens->otype) {
- init_sensor(sens);
- sens->otype= sens->type;
- break;
- }
- sens= sens->next;
- }
- }
- break;
-
- case B_DEL_SENS:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- sens= ob->sensors.first;
- while (sens) {
- if (sens->flag & SENS_DEL) {
- BLI_remlink(&(ob->sensors), sens);
- free_sensor(sens);
- break;
- }
- sens= sens->next;
- }
- }
- ED_undo_push(C, "Delete sensor");
- break;
-
- case B_ADD_CONT:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- if (ob->scaflag & OB_ADDCONT) {
- ob->scaflag &= ~OB_ADDCONT;
- cont= new_controller(CONT_LOGIC_AND);
- BLI_uniquename(&ob->controllers, cont, DATA_("Controller"), '.', offsetof(bController, name), sizeof(cont->name));
- ob->scaflag |= OB_SHOWCONT;
- BLI_addtail(&(ob->controllers), cont);
- /* set the controller state mask from the current object state.
- * A controller is always in a single state, so select the lowest bit set
- * from the object state */
- for (bit=0; bit<32; bit++) {
- if (ob->state & (1<<bit))
- break;
- }
- cont->state_mask = (1<<bit);
- if (cont->state_mask == 0) {
- /* shouldn't happen, object state is never 0 */
- cont->state_mask = 1;
- }
- }
- }
- ED_undo_push(C, "Add controller");
- break;
-
- case B_SET_STATE_BIT:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- if (ob->scaflag & OB_ALLSTATE) {
- ob->scaflag &= ~OB_ALLSTATE;
- ob->state = 0x3FFFFFFF;
- }
- }
- break;
-
- case B_INIT_STATE_BIT:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- if (ob->scaflag & OB_INITSTBIT) {
- ob->scaflag &= ~OB_INITSTBIT;
- ob->state = ob->init_state;
- if (!ob->state)
- ob->state = 1;
- }
- }
- break;
-
- case B_CHANGE_CONT:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- cont= ob->controllers.first;
- while (cont) {
- if (cont->type != cont->otype) {
- init_controller(cont);
- cont->otype= cont->type;
- break;
- }
- cont= cont->next;
- }
- }
- break;
-
-
- case B_DEL_CONT:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- cont= ob->controllers.first;
- while (cont) {
- if (cont->flag & CONT_DEL) {
- BLI_remlink(&(ob->controllers), cont);
- unlink_controller(cont);
- free_controller(cont);
- break;
- }
- cont= cont->next;
- }
- }
- ED_undo_push(C, "Delete controller");
- break;
-
- case B_ADD_ACT:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- if (ob->scaflag & OB_ADDACT) {
- ob->scaflag &= ~OB_ADDACT;
- act= new_actuator(ACT_OBJECT);
- BLI_uniquename(&ob->actuators, act, DATA_("Actuator"), '.', offsetof(bActuator, name), sizeof(act->name));
- BLI_addtail(&(ob->actuators), act);
- ob->scaflag |= OB_SHOWACT;
- }
- }
- ED_undo_push(C, "Add actuator");
- break;
-
- case B_CHANGE_ACT:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- act= ob->actuators.first;
- while (act) {
- if (act->type != act->otype) {
- init_actuator(act);
- act->otype= act->type;
- break;
- }
- act= act->next;
- }
- }
- break;
-
- case B_DEL_ACT:
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- act= ob->actuators.first;
- while (act) {
- if (act->flag & ACT_DEL) {
- BLI_remlink(&(ob->actuators), act);
- unlink_actuator(act);
- free_actuator(act);
- break;
- }
- act= act->next;
- }
- }
- ED_undo_push(C, "Delete actuator");
- break;
-
- case B_SOUNDACT_BROWSE:
- /* since we don't know which... */
- didit= 0;
- for (ob=bmain->object.first; ob; ob=ob->id.next) {
- act= ob->actuators.first;
- while (act) {
- if (act->type==ACT_SOUND) {
- bSoundActuator *sa= act->data;
- if (sa->sndnr) {
- ID *sound= bmain->sound.first;
- int nr= 1;
-
- if (sa->sndnr == -2) {
-// XXX activate_databrowse((ID *)bmain->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE,
-// &sa->sndnr, do_logic_buts);
- break;
- }
-
- while (sound) {
- if (nr==sa->sndnr)
- break;
- nr++;
- sound= sound->next;
- }
-
- if (sa->sound)
- id_us_min(((ID *)sa->sound));
-
- sa->sound= (struct bSound *)sound;
-
- if (sound) {
- id_us_plus(sound);
- }
-
- sa->sndnr= 0;
- didit= 1;
- }
- }
- act= act->next;
- }
- if (didit)
- break;
- }
-
- break;
- }
-}
-
-
-static const char *sensor_name(int type)
-{
- switch (type) {
- case SENS_ALWAYS:
- return N_("Always");
- case SENS_NEAR:
- return N_("Near");
- case SENS_KEYBOARD:
- return N_("Keyboard");
- case SENS_PROPERTY:
- return N_("Property");
- case SENS_ARMATURE:
- return N_("Armature");
- case SENS_ACTUATOR:
- return N_("Actuator");
- case SENS_DELAY:
- return N_("Delay");
- case SENS_MOUSE:
- return N_("Mouse");
- case SENS_COLLISION:
- return N_("Collision");
- case SENS_RADAR:
- return N_("Radar");
- case SENS_RANDOM:
- return N_("Random");
- case SENS_RAY:
- return N_("Ray");
- case SENS_MESSAGE:
- return N_("Message");
- case SENS_JOYSTICK:
- return N_("Joystick");
- }
- return N_("Unknown");
-}
-
-static const char *controller_name(int type)
-{
- switch (type) {
- case CONT_LOGIC_AND:
- return N_("And");
- case CONT_LOGIC_OR:
- return N_("Or");
- case CONT_LOGIC_NAND:
- return N_("Nand");
- case CONT_LOGIC_NOR:
- return N_("Nor");
- case CONT_LOGIC_XOR:
- return N_("Xor");
- case CONT_LOGIC_XNOR:
- return N_("Xnor");
- case CONT_EXPRESSION:
- return N_("Expression");
- case CONT_PYTHON:
- return N_("Python");
- }
- return N_("Unknown");
-}
-
-static const char *actuator_name(int type)
-{
- switch (type) {
- case ACT_SHAPEACTION:
- return N_("Shape Action");
- case ACT_ACTION:
- return N_("Action");
- case ACT_OBJECT:
- return N_("Motion");
- case ACT_LAMP:
- return N_("Lamp");
- case ACT_CAMERA:
- return N_("Camera");
- case ACT_MATERIAL:
- return N_("Material");
- case ACT_SOUND:
- return N_("Sound");
- case ACT_PROPERTY:
- return N_("Property");
- case ACT_EDIT_OBJECT:
- return N_("Edit Object");
- case ACT_CONSTRAINT:
- return N_("Constraint");
- case ACT_SCENE:
- return N_("Scene");
- case ACT_GROUP:
- return N_("Group");
- case ACT_RANDOM:
- return N_("Random");
- case ACT_MESSAGE:
- return N_("Message");
- case ACT_GAME:
- return N_("Game");
- case ACT_VISIBILITY:
- return N_("Visibility");
- case ACT_2DFILTER:
- return N_("Filter 2D");
- case ACT_PARENT:
- return N_("Parent");
- case ACT_STATE:
- return N_("State");
- case ACT_ARMATURE:
- return N_("Armature");
- case ACT_STEERING:
- return N_("Steering");
- case ACT_MOUSE:
- return N_("Mouse");
- }
- return N_("Unknown");
-}
-
-static void set_sca_ob(Object *ob)
-{
- bController *cont;
- bActuator *act;
-
- cont= ob->controllers.first;
- while (cont) {
- cont->mynew= (bController *)ob;
- cont= cont->next;
- }
- act= ob->actuators.first;
- while (act) {
- act->mynew= (bActuator *)ob;
- act= act->next;
- }
-}
-
-static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisflag)
-{
- Base *base;
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *ob, *obt, *obact = CTX_data_active_object(C);
- ID **idar;
- bSensor *sens;
- bController *cont;
- int a, nr, do_it;
-
- /* we need a sorted object list */
- /* set scavisflags flags in Objects to indicate these should be evaluated */
- /* also hide ob pointers in ->new entries of controllerss/actuators */
-
- *count= 0;
-
- if (scene==NULL) return NULL;
-
- ob= bmain->object.first;
- while (ob) {
- ob->scavisflag= 0;
- set_sca_ob(ob);
- ob= ob->id.next;
- }
-
- for (base = FIRSTBASE(view_layer); base; base = base->next) {
- if ((base->flag & BASE_VISIBLED) && (base->flag & SELECT)) {
- if (scavisflag & BUTS_SENS_SEL) base->object->scavisflag |= OB_VIS_SENS;
- if (scavisflag & BUTS_CONT_SEL) base->object->scavisflag |= OB_VIS_CONT;
- if (scavisflag & BUTS_ACT_SEL) base->object->scavisflag |= OB_VIS_ACT;
- }
- }
-
- if (obact) {
- if (scavisflag & BUTS_SENS_ACT) obact->scavisflag |= OB_VIS_SENS;
- if (scavisflag & BUTS_CONT_ACT) obact->scavisflag |= OB_VIS_CONT;
- if (scavisflag & BUTS_ACT_ACT) obact->scavisflag |= OB_VIS_ACT;
- }
-
- /* BUTS_XXX_STATE are similar to BUTS_XXX_LINK for selecting the object */
- if (scavisflag & (BUTS_SENS_LINK|BUTS_CONT_LINK|BUTS_ACT_LINK|BUTS_SENS_STATE|BUTS_ACT_STATE)) {
- do_it = true;
- while (do_it) {
- do_it = false;
-
- ob= bmain->object.first;
- while (ob) {
-
- /* 1st case: select sensor when controller selected */
- if ((scavisflag & (BUTS_SENS_LINK|BUTS_SENS_STATE)) && (ob->scavisflag & OB_VIS_SENS)==0) {
- sens= ob->sensors.first;
- while (sens) {
- for (a=0; a<sens->totlinks; a++) {
- if (sens->links[a]) {
- obt= (Object *)sens->links[a]->mynew;
- if (obt && (obt->scavisflag & OB_VIS_CONT)) {
- do_it = true;
- ob->scavisflag |= OB_VIS_SENS;
- break;
- }
- }
- }
- if (do_it) break;
- sens= sens->next;
- }
- }
-
- /* 2nd case: select cont when act selected */
- if ((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_CONT)==0) {
- cont= ob->controllers.first;
- while (cont) {
- for (a=0; a<cont->totlinks; a++) {
- if (cont->links[a]) {
- obt= (Object *)cont->links[a]->mynew;
- if (obt && (obt->scavisflag & OB_VIS_ACT)) {
- do_it = true;
- ob->scavisflag |= OB_VIS_CONT;
- break;
- }
- }
- }
- if (do_it) break;
- cont= cont->next;
- }
- }
-
- /* 3rd case: select controller when sensor selected */
- if ((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_SENS)) {
- sens= ob->sensors.first;
- while (sens) {
- for (a=0; a<sens->totlinks; a++) {
- if (sens->links[a]) {
- obt= (Object *)sens->links[a]->mynew;
- if (obt && (obt->scavisflag & OB_VIS_CONT)==0) {
- do_it = true;
- obt->scavisflag |= OB_VIS_CONT;
- }
- }
- }
- sens= sens->next;
- }
- }
-
- /* 4th case: select actuator when controller selected */
- if ((scavisflag & (BUTS_ACT_LINK|BUTS_ACT_STATE)) && (ob->scavisflag & OB_VIS_CONT)) {
- cont= ob->controllers.first;
- while (cont) {
- for (a=0; a<cont->totlinks; a++) {
- if (cont->links[a]) {
- obt= (Object *)cont->links[a]->mynew;
- if (obt && (obt->scavisflag & OB_VIS_ACT)==0) {
- do_it = true;
- obt->scavisflag |= OB_VIS_ACT;
- }
- }
- }
- cont= cont->next;
- }
-
- }
- ob= ob->id.next;
- }
- }
- }
-
- /* now we count */
- ob= bmain->object.first;
- while (ob) {
- if ( ob->scavisflag ) (*count)++;
- ob= ob->id.next;
- }
-
- if (*count == 0) return NULL;
- if (*count > 24) *count = 24; /* temporal */
-
- idar= MEM_callocN((*count)*sizeof(void *), "idar");
-
- ob= bmain->object.first;
- nr= 0;
-
- /* make the active object always the first one of the list */
- if (obact) {
- idar[0] = (ID *)obact;
- nr++;
- }
-
- while (ob) {
- if ((ob->scavisflag) && (ob != obact)) {
- idar[nr] = (ID *)ob;
- nr++;
- }
- if (nr >= 24) break;
- ob= ob->id.next;
- }
-
- /* just to be sure... these were set in set_sca_done_ob() */
- clear_sca_new_poins();
-
- return idar;
-}
-
-static void get_armature_bone_constraint(Object *ob, const char *posechannel, const char *constraint_name, bConstraint **constraint)
-{
- /* check that bone exist in the active object */
- if (ob->type == OB_ARMATURE && ob->pose) {
- bPoseChannel *pchan= BKE_pose_channel_find_name(ob->pose, posechannel);
- if (pchan) {
- bConstraint *con= BLI_findstring(&pchan->constraints, constraint_name, offsetof(bConstraint, name));
- if (con) {
- *constraint= con;
- }
- }
- }
- /* didn't find any */
-}
-
-static void do_sensor_menu(bContext *C, void *UNUSED(arg), int event)
-{
- SpaceLogic *slogic= CTX_wm_space_logic(C);
- ID **idar;
- Object *ob;
- bSensor *sens;
- short count, a;
-
- idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
-
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
- if (event==0 || event==2) ob->scaflag |= OB_SHOWSENS;
- else if (event==1) ob->scaflag &= ~OB_SHOWSENS;
- }
-
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
- sens= ob->sensors.first;
- while (sens) {
- if (event==2) sens->flag |= SENS_SHOW;
- else if (event==3) sens->flag &= ~SENS_SHOW;
- sens= sens->next;
- }
- }
-
- if (idar) MEM_freeN(idar);
-}
-
-static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg))
-{
- uiBlock *block;
- int yco=0;
-
- block= UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN);
- UI_block_func_butmenu_set(block, do_sensor_menu, NULL);
-
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
- uiDefBut(block, UI_BTYPE_SEPR_LINE, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, "");
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, "");
-
- UI_block_direction_set(block, UI_DIR_UP);
- UI_block_end(C, block);
-
- return block;
-}
-
-static void do_controller_menu(bContext *C, void *UNUSED(arg), int event)
-{
- SpaceLogic *slogic= CTX_wm_space_logic(C);
- ID **idar;
- Object *ob;
- bController *cont;
- short count, a;
-
- idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
-
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
- if (event==0 || event==2) ob->scaflag |= OB_SHOWCONT;
- else if (event==1) ob->scaflag &= ~OB_SHOWCONT;
- }
-
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
- cont= ob->controllers.first;
- while (cont) {
- if (event==2) cont->flag |= CONT_SHOW;
- else if (event==3) cont->flag &= ~CONT_SHOW;
- cont= cont->next;
- }
- }
-
- if (idar) MEM_freeN(idar);
-}
-
-static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg))
-{
- uiBlock *block;
- int yco=0;
-
- block= UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN);
- UI_block_func_butmenu_set(block, do_controller_menu, NULL);
-
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
- uiDefBut(block, UI_BTYPE_SEPR_LINE, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, "");
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, "");
-
- UI_block_direction_set(block, UI_DIR_UP);
- UI_block_end(C, block);
-
- return block;
-}
-
-static void do_actuator_menu(bContext *C, void *UNUSED(arg), int event)
-{
- SpaceLogic *slogic= CTX_wm_space_logic(C);
- ID **idar;
- Object *ob;
- bActuator *act;
- short count, a;
-
- idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
-
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
- if (event==0 || event==2) ob->scaflag |= OB_SHOWACT;
- else if (event==1) ob->scaflag &= ~OB_SHOWACT;
- }
-
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
- act= ob->actuators.first;
- while (act) {
- if (event==2) act->flag |= ACT_SHOW;
- else if (event==3) act->flag &= ~ACT_SHOW;
- act= act->next;
- }
- }
-
- if (idar) MEM_freeN(idar);
-}
-
-static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg))
-{
- uiBlock *block;
- int xco=0;
-
- block= UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN);
- UI_block_func_butmenu_set(block, do_actuator_menu, NULL);
-
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
- uiDefBut(block, UI_BTYPE_SEPR_LINE, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, "");
- uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, "");
-
- UI_block_direction_set(block, UI_DIR_UP);
- UI_block_end(C, block);
-
- return block;
-}
-
-static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, void *arg2_mask)
-{
- unsigned int *cont_mask = arg2_mask;
- uiBut *but = arg1_but;
-
- /* a controller is always in a single state */
- *cont_mask = (1<<but->retval);
- but->retval = B_REDR;
-}
-
-static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_cont)
-{
- uiBlock *block;
- uiBut *but;
- bController *cont = arg_cont;
-
- short yco = 12, xco = 0, stbit, offset;
-
- block= UI_block_begin(C, ar, __func__, UI_EMBOSS);
-
- /* use this for a fake extra empy space around the buttons */
- uiDefBut(block, UI_BTYPE_LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, "");
-
- for (offset=0; offset<15; offset += 5) {
- UI_block_align_begin(block);
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, UI_BTYPE_TOGGLE, (1<<(stbit+offset)), (stbit+offset), "", (short)(xco+12*stbit+13*offset), yco, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, "");
- UI_but_func_set(but, check_controller_state_mask, but, &(cont->state_mask));
- }
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, UI_BTYPE_TOGGLE, (1<<(stbit+offset+15)), (stbit+offset+15), "", (short)(xco+12*stbit+13*offset), yco-12, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, "");
- UI_but_func_set(but, check_controller_state_mask, but, &(cont->state_mask));
- }
- }
- UI_block_align_end(block);
-
- UI_block_direction_set(block, UI_DIR_UP);
- UI_block_end(C, block);
-
- return block;
-}
-
-static bool is_sensor_linked(uiBlock *block, bSensor *sens)
-{
- bController *cont;
- int i;
-
- for (i=0; i<sens->totlinks; i++) {
- cont = sens->links[i];
- if (UI_block_links_find_inlink(block, cont) != NULL)
- return 1;
- }
- return 0;
-}
-
-/* Sensors code */
-
-static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr)
-{
- uiLayout *box, *row, *sub;
- bSensor *sens= (bSensor *)ptr->data;
-
- box = uiLayoutBox(layout);
- row = uiLayoutRow(box, false);
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
- if (RNA_boolean_get(ptr, "show_expanded")) {
- uiItemR(sub, ptr, "type", 0, "", ICON_NONE);
- uiItemR(sub, ptr, "name", 0, "", ICON_NONE);
- }
- else {
- uiItemL(sub, IFACE_(sensor_name(sens->type)), ICON_NONE);
- uiItemL(sub, sens->name, ICON_NONE);
- }
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, (((RNA_boolean_get(logic_ptr, "show_sensors_active_states") &&
- RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")) &&
- RNA_boolean_get(ptr, "active")));
- uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE);
-
- if (RNA_boolean_get(ptr, "show_expanded")==0) {
- sub = uiLayoutRow(row, true);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_UP, "direction", 1); // up
- uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_DOWN, "direction", 2); // down
- }
-
- sub = uiLayoutRow(row, false);
- uiItemR(sub, ptr, "active", 0, "", ICON_NONE);
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemO(sub, "", ICON_X, "LOGIC_OT_sensor_remove");
-}
-
-static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *box, *split, *sub, *row;
-
- box = uiLayoutBox(layout);
- uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
- split = uiLayoutSplit(box, 0.45f, false);
-
- row = uiLayoutRow(split, true);
- uiItemR(row, ptr, "use_pulse_true_level", 0, "", ICON_DOTSUP);
- uiItemR(row, ptr, "use_pulse_false_level", 0, "", ICON_DOTSDOWN);
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, (RNA_boolean_get(ptr, "use_pulse_true_level") ||
- RNA_boolean_get(ptr, "use_pulse_false_level")));
- uiItemR(sub, ptr, "tick_skip", 0, IFACE_("Skip"), ICON_NONE);
-
- row = uiLayoutRow(split, true);
- uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- uiItemR(split, ptr, "invert", UI_ITEM_R_TOGGLE, IFACE_("Invert"), ICON_NONE);
-}
-/* sensors in alphabetical order */
-
-static void draw_sensor_actuator(uiLayout *layout, PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- PointerRNA settings_ptr;
-
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
- uiItemPointerR(layout, ptr, "actuator", &settings_ptr, "actuators", NULL, ICON_LOGIC);
-}
-
-static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr)
-{
- bSensor *sens = (bSensor *)ptr->data;
- bArmatureSensor *as = (bArmatureSensor *) sens->data;
- Object *ob = (Object *)ptr->id.data;
- uiLayout *row;
-
- if (ob->type != OB_ARMATURE) {
- uiItemL(layout, IFACE_("Sensor only available for armatures"), ICON_NONE);
- return;
- }
-
- if (ob->pose) {
- PointerRNA pose_ptr, pchan_ptr;
- PropertyRNA *bones_prop;
-
- RNA_pointer_create((ID *)ob, &RNA_Pose, ob->pose, &pose_ptr);
- bones_prop = RNA_struct_find_property(&pose_ptr, "bones");
-
- uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA);
-
- if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, as->posechannel, &pchan_ptr))
- uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
- }
- row = uiLayoutRow(layout, true);
- uiItemR(row, ptr, "test_type", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "test_type") != SENS_ARM_STATE_CHANGED)
- uiItemR(row, ptr, "value", 0, NULL, ICON_NONE);
-}
-
-static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr, bContext *C)
-{
- uiLayout *row, *split;
- PointerRNA main_ptr;
-
- RNA_main_pointer_create(CTX_data_main(C), &main_ptr);
-
- split = uiLayoutSplit(layout, 0.3f, false);
- row = uiLayoutRow(split, true);
- uiItemR(row, ptr, "use_pulse", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- uiItemR(row, ptr, "use_material", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- switch (RNA_boolean_get(ptr, "use_material")) {
- case SENS_COLLISION_PROPERTY:
- uiItemR(split, ptr, "property", 0, NULL, ICON_NONE);
- break;
- case SENS_COLLISION_MATERIAL:
- uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA);
- break;
- }
-}
-
-static void draw_sensor_delay(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *row;
-
- row = uiLayoutRow(layout, false);
-
- uiItemR(row, ptr, "delay", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "duration", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "use_repeat", 0, NULL, ICON_NONE);
-}
-
-static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *col, *row;
-
- uiItemR(layout, ptr, "joystick_index", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "event_type", 0, NULL, ICON_NONE);
-
- switch (RNA_enum_get(ptr, "event_type")) {
- case SENS_JOY_BUTTON:
- uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE);
-
- col = uiLayoutColumn(layout, false);
- uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == false);
- uiItemR(col, ptr, "button_number", 0, NULL, ICON_NONE);
- break;
- case SENS_JOY_AXIS:
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "axis_number", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE);
-
- uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE);
- col = uiLayoutColumn(layout, false);
- uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == false);
- uiItemR(col, ptr, "axis_direction", 0, NULL, ICON_NONE);
- break;
- case SENS_JOY_HAT:
- uiItemR(layout, ptr, "hat_number", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE);
-
- col = uiLayoutColumn(layout, false);
- uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == false);
- uiItemR(col, ptr, "hat_direction", 0, NULL, ICON_NONE);
- break;
- case SENS_JOY_AXIS_SINGLE:
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "single_axis_number", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE);
- break;
- }
-}
-
-static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- PointerRNA settings_ptr;
- uiLayout *row, *col;
-
- row = uiLayoutRow(layout, false);
- uiItemL(row, CTX_IFACE_(BLT_I18NCONTEXT_ID_WINDOWMANAGER, "Key:"), ICON_NONE);
- col = uiLayoutColumn(row, false);
- uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == false);
- uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", ICON_NONE);
- col = uiLayoutColumn(row, false);
- uiItemR(col, ptr, "use_all_keys", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- col = uiLayoutColumn(layout, false);
- uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == false);
- row = uiLayoutRow(col, false);
- uiItemL(row, IFACE_("First Modifier:"), ICON_NONE);
- uiItemR(row, ptr, "modifier_key_1", UI_ITEM_R_EVENT, "", ICON_NONE);
-
- row = uiLayoutRow(col, false);
- uiItemL(row, IFACE_("Second Modifier:"), ICON_NONE);
- uiItemR(row, ptr, "modifier_key_2", UI_ITEM_R_EVENT, "", ICON_NONE);
-
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
- uiItemPointerR(layout, ptr, "log", &settings_ptr, "properties", NULL, ICON_NONE);
- uiItemPointerR(layout, ptr, "target", &settings_ptr, "properties", NULL, ICON_NONE);
-}
-
-static void draw_sensor_message(uiLayout *layout, PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "subject", 0, NULL, ICON_NONE);
-}
-
-static void draw_sensor_mouse(uiLayout *layout, PointerRNA *ptr, bContext *C)
-{
- uiLayout *split, *split2;
- PointerRNA main_ptr;
-
- split = uiLayoutSplit(layout, 0.8f, false);
- uiItemR(split, ptr, "mouse_event", 0, NULL, ICON_NONE);
-
- if (RNA_enum_get(ptr, "mouse_event") == BL_SENS_MOUSE_MOUSEOVER_ANY) {
- uiItemR(split, ptr, "use_pulse", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.3f, false);
- uiItemR(split, ptr, "use_material", 0, "", ICON_NONE);
-
- split2 = uiLayoutSplit(split, 0.7f, false);
- if (RNA_enum_get(ptr, "use_material") == SENS_RAY_PROPERTY) {
- uiItemR(split2, ptr, "property", 0, "", ICON_NONE);
- }
- else {
- RNA_main_pointer_create(CTX_data_main(C), &main_ptr);
- uiItemPointerR(split2, ptr, "material", &main_ptr, "materials", "", ICON_MATERIAL_DATA);
- }
- uiItemR(split2, ptr, "use_x_ray", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- }
-}
-
-static void draw_sensor_near(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *row;
-
- uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, true);
- uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "reset_distance", 0, NULL, ICON_NONE);
-}
-
-static void draw_sensor_property(uiLayout *layout, PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- PointerRNA settings_ptr;
-
- uiLayout *row;
- uiItemR(layout, ptr, "evaluation_type", 0, NULL, ICON_NONE);
-
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
- uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE);
-
- switch (RNA_enum_get(ptr, "evaluation_type")) {
- case SENS_PROP_INTERVAL:
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "value_min", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "value_max", 0, NULL, ICON_NONE);
- break;
- case SENS_PROP_EQUAL:
- case SENS_PROP_NEQUAL:
- case SENS_PROP_LESSTHAN:
- case SENS_PROP_GREATERTHAN:
- uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE);
- break;
- case SENS_PROP_CHANGED:
- break;
- }
-}
-
-static void draw_sensor_radar(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *row;
-
- uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "axis", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "angle", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE);
-}
-
-static void draw_sensor_random(uiLayout *layout, PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "seed", 0, NULL, ICON_NONE);
-}
-
-static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr, bContext *C)
-{
- uiLayout *split, *row;
- PointerRNA main_ptr;
-
- RNA_main_pointer_create(CTX_data_main(C), &main_ptr);
- split = uiLayoutSplit(layout, 0.3f, false);
- uiItemR(split, ptr, "ray_type", 0, "", ICON_NONE);
- switch (RNA_enum_get(ptr, "ray_type")) {
- case SENS_RAY_PROPERTY:
- uiItemR(split, ptr, "property", 0, "", ICON_NONE);
- break;
- case SENS_RAY_MATERIAL:
- uiItemPointerR(split, ptr, "material", &main_ptr, "materials", "", ICON_MATERIAL_DATA);
- break;
- }
-
- split = uiLayoutSplit(layout, 0.3, false);
- uiItemR(split, ptr, "axis", 0, "", ICON_NONE);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "range", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "use_x_ray", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-}
-
-static void draw_brick_sensor(uiLayout *layout, PointerRNA *ptr, bContext *C)
-{
- uiLayout *box;
-
- if (!RNA_boolean_get(ptr, "show_expanded"))
- return;
-
- draw_sensor_internal_header(layout, ptr);
-
- box = uiLayoutBox(layout);
- uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
-
- switch (RNA_enum_get(ptr, "type")) {
-
- case SENS_ACTUATOR:
- draw_sensor_actuator(box, ptr);
- break;
- case SENS_ALWAYS:
- break;
- case SENS_ARMATURE:
- draw_sensor_armature(box, ptr);
- break;
- case SENS_COLLISION:
- draw_sensor_collision(box, ptr, C);
- break;
- case SENS_DELAY:
- draw_sensor_delay(box, ptr);
- break;
- case SENS_JOYSTICK:
- draw_sensor_joystick(box, ptr);
- break;
- case SENS_KEYBOARD:
- draw_sensor_keyboard(box, ptr);
- break;
- case SENS_MESSAGE:
- draw_sensor_message(box, ptr);
- break;
- case SENS_MOUSE:
- draw_sensor_mouse(box, ptr, C);
- break;
- case SENS_NEAR:
- draw_sensor_near(box, ptr);
- break;
- case SENS_PROPERTY:
- draw_sensor_property(box, ptr);
- break;
- case SENS_RADAR:
- draw_sensor_radar(box, ptr);
- break;
- case SENS_RANDOM:
- draw_sensor_random(box, ptr);
- break;
- case SENS_RAY:
- draw_sensor_ray(box, ptr, C);
- break;
- }
-}
-
-/* Controller code */
-static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, int width, int yco)
-{
- uiLayout *box, *row, *sub;
- bController *cont= (bController *)ptr->data;
-
- char state[3];
- BLI_snprintf(state, sizeof(state), "%d", RNA_int_get(ptr, "states"));
-
- box = uiLayoutBox(layout);
- row = uiLayoutRow(box, false);
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
- if (RNA_boolean_get(ptr, "show_expanded")) {
- uiItemR(sub, ptr, "type", 0, "", ICON_NONE);
- uiItemR(sub, ptr, "name", 0, "", ICON_NONE);
- /* XXX provisory for Blender 2.50Beta */
- uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, IFACE_("Set controller state index (from 1 to 30)"));
- }
- else {
- uiItemL(sub, IFACE_(controller_name(cont->type)), ICON_NONE);
- uiItemL(sub, cont->name, ICON_NONE);
- uiItemL(sub, state, ICON_NONE);
- }
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemR(sub, ptr, "use_priority", 0, "", ICON_NONE);
-
- if (RNA_boolean_get(ptr, "show_expanded")==0) {
- sub = uiLayoutRow(row, true);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_UP, "direction", 1); // up
- uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_DOWN, "direction", 2); // down
- }
-
- sub = uiLayoutRow(row, false);
- uiItemR(sub, ptr, "active", 0, "", ICON_NONE);
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemO(sub, "", ICON_X, "LOGIC_OT_controller_remove");
-}
-
-static void draw_controller_expression(uiLayout *layout, PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "expression", 0, "", ICON_NONE);
-}
-
-static void draw_controller_python(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *split, *sub;
-
- split = uiLayoutSplit(layout, 0.3, true);
- uiItemR(split, ptr, "mode", 0, "", ICON_NONE);
- if (RNA_enum_get(ptr, "mode") == CONT_PY_SCRIPT) {
- uiItemR(split, ptr, "text", 0, "", ICON_NONE);
- }
- else {
- sub = uiLayoutSplit(split, 0.8f, false);
- uiItemR(sub, ptr, "module", 0, "", ICON_NONE);
- uiItemR(sub, ptr, "use_debug", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- }
-}
-
-static void draw_controller_state(uiLayout *UNUSED(layout), PointerRNA *UNUSED(ptr))
-{
-
-}
-
-static void draw_brick_controller(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *box;
-
- if (!RNA_boolean_get(ptr, "show_expanded"))
- return;
-
- box = uiLayoutBox(layout);
- uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
-
- draw_controller_state(box, ptr);
-
- switch (RNA_enum_get(ptr, "type")) {
- case CONT_LOGIC_AND:
- break;
- case CONT_LOGIC_OR:
- break;
- case CONT_EXPRESSION:
- draw_controller_expression(box, ptr);
- break;
- case CONT_PYTHON:
- draw_controller_python(box, ptr);
- break;
- case CONT_LOGIC_NAND:
- break;
- case CONT_LOGIC_NOR:
- break;
- case CONT_LOGIC_XOR:
- break;
- case CONT_LOGIC_XNOR:
- break;
- }
-}
-
-/* Actuator code */
-static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr)
-{
- uiLayout *box, *row, *sub;
- bActuator *act= (bActuator *)ptr->data;
-
- box = uiLayoutBox(layout);
- row = uiLayoutRow(box, false);
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
- if (RNA_boolean_get(ptr, "show_expanded")) {
- uiItemR(sub, ptr, "type", 0, "", ICON_NONE);
- uiItemR(sub, ptr, "name", 0, "", ICON_NONE);
- }
- else {
- uiItemL(sub, IFACE_(actuator_name(act->type)), ICON_NONE);
- uiItemL(sub, act->name, ICON_NONE);
- }
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, (((RNA_boolean_get(logic_ptr, "show_actuators_active_states") &&
- RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")) &&
- RNA_boolean_get(ptr, "active")));
- uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE);
-
- if (RNA_boolean_get(ptr, "show_expanded")==0) {
- sub = uiLayoutRow(row, true);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_UP, "direction", 1); // up
- uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_DOWN, "direction", 2); // down
- }
-
- sub = uiLayoutRow(row, false);
- uiItemR(sub, ptr, "active", 0, "", ICON_NONE);
-
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active"));
- uiItemO(sub, "", ICON_X, "LOGIC_OT_actuator_remove");
-}
-
-static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- PointerRNA settings_ptr;
- uiLayout *row, *sub;
-
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "play_mode", 0, "", ICON_NONE);
-
- sub = uiLayoutRow(row, true);
- uiItemR(sub, ptr, "use_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- uiItemR(sub, ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- row = uiLayoutColumn(sub, false);
- uiLayoutSetActive(row, (RNA_boolean_get(ptr, "use_additive") || RNA_boolean_get(ptr, "use_force")));
- uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "action", 0, "", ICON_NONE);
- uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- if ((RNA_enum_get(ptr, "play_mode") == ACT_ACTION_FROM_PROP))
- uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE);
-
- else {
- uiItemR(row, ptr, "frame_start", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "frame_end", 0, NULL, ICON_NONE);
- }
-
- uiItemR(row, ptr, "apply_to_children", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "layer_weight", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "blend_mode", 0, "", ICON_NONE);
-
- uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE);
-
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- uiItemR(layout, "stride_length", 0, NULL, ICON_NONE);
-#endif
-}
-
-static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr)
-{
- bActuator *act = (bActuator *)ptr->data;
- bArmatureActuator *aa = (bArmatureActuator *) act->data;
- Object *ob = (Object *)ptr->id.data;
- bConstraint *constraint = NULL;
- PointerRNA pose_ptr, pchan_ptr;
- PropertyRNA *bones_prop = NULL;
-
- if (ob->type != OB_ARMATURE) {
- uiItemL(layout, IFACE_("Actuator only available for armatures"), ICON_NONE);
- return;
- }
-
- if (ob->pose) {
- RNA_pointer_create((ID *)ob, &RNA_Pose, ob->pose, &pose_ptr);
- bones_prop = RNA_struct_find_property(&pose_ptr, "bones");
- }
-
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
-
- switch (RNA_enum_get(ptr, "mode")) {
- case ACT_ARM_RUN:
- break;
- case ACT_ARM_ENABLE:
- case ACT_ARM_DISABLE:
- if (ob->pose) {
- uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA);
-
- if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, aa->posechannel, &pchan_ptr))
- uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
- }
- break;
- case ACT_ARM_SETTARGET:
- if (ob->pose) {
- uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA);
-
- if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, aa->posechannel, &pchan_ptr))
- uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
- }
-
- uiItemR(layout, ptr, "target", 0, NULL, ICON_NONE);
-
- /* show second target only if the constraint supports it */
- get_armature_bone_constraint(ob, aa->posechannel, aa->constraint, &constraint);
- if (constraint && constraint->type == CONSTRAINT_TYPE_KINEMATIC) {
- uiItemR(layout, ptr, "secondary_target", 0, NULL, ICON_NONE);
- }
- break;
- case ACT_ARM_SETWEIGHT:
- if (ob->pose) {
- uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA);
-
- if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, aa->posechannel, &pchan_ptr))
- uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
- }
-
- uiItemR(layout, ptr, "weight", 0, NULL, ICON_NONE);
- break;
- case ACT_ARM_SETINFLUENCE:
- if (ob->pose) {
- uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA);
-
- if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, aa->posechannel, &pchan_ptr))
- uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
- }
-
- uiItemR(layout, ptr, "influence", 0, NULL, ICON_NONE);
- break;
- }
-}
-
-static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *row;
- uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "height", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "axis", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, true);
- uiItemR(row, ptr, "min", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "max", 0, NULL, ICON_NONE);
-
- uiItemR(layout, ptr, "damping", 0, NULL, ICON_NONE);
-}
-
-static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext *C)
-{
- uiLayout *row, *col, *sub, *split;
- PointerRNA main_ptr;
-
- RNA_main_pointer_create(CTX_data_main(C), &main_ptr);
-
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
- switch (RNA_enum_get(ptr, "mode")) {
- case ACT_CONST_TYPE_LOC:
- uiItemR(layout, ptr, "limit", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, true);
- uiItemR(row, ptr, "limit_min", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "limit_max", 0, NULL, ICON_NONE);
-
- uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- break;
-
- case ACT_CONST_TYPE_DIST:
- split = uiLayoutSplit(layout, 0.8, false);
- uiItemR(split, ptr, "direction", 0, NULL, ICON_NONE);
- row = uiLayoutRow(split, true);
- uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- uiItemR(row, ptr, "use_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- col = uiLayoutColumn(row, true);
- uiItemL(col, IFACE_("Range:"), ICON_NONE);
- uiItemR(col, ptr, "range", 0, "", ICON_NONE);
-
- col = uiLayoutColumn(row, true);
- uiItemR(col, ptr, "use_force_distance", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- sub = uiLayoutColumn(col, false);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_force_distance") == true);
- uiItemR(sub, ptr, "distance", 0, "", ICON_NONE);
-
- uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.15f, false);
- uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- if (RNA_boolean_get(ptr, "use_material_detect"))
- uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA);
- else
- uiItemR(split, ptr, "property", 0, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.15, false);
- uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- row = uiLayoutRow(split, true);
- uiItemR(row, ptr, "time", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- break;
-
- case ACT_CONST_TYPE_ORI:
- uiItemR(layout, ptr, "direction_axis_pos", 0, NULL, ICON_NONE);
-
- row=uiLayoutRow(layout, true);
- uiItemR(row, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- uiItemR(row, ptr, "time", 0, NULL, ICON_NONE);
-
- row=uiLayoutRow(layout, false);
- uiItemR(row, ptr, "rotation_max", 0, NULL, ICON_NONE);
-
- row=uiLayoutRow(layout, true);
- uiItemR(row, ptr, "angle_min", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "angle_max", 0, NULL, ICON_NONE);
- break;
-
- case ACT_CONST_TYPE_FH:
- split = uiLayoutSplit(layout, 0.75, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "fh_damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
-
- uiItemR(row, ptr, "fh_height", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_fh_paralel_axis", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "direction_axis", 0, NULL, ICON_NONE);
- split = uiLayoutSplit(row, 0.9f, false);
- uiItemR(split, ptr, "fh_force", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_fh_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.15, false);
- uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- if (RNA_boolean_get(ptr, "use_material_detect"))
- uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA);
- else
- uiItemR(split, ptr, "property", 0, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.15, false);
- uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "time", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- break;
- }
-}
-
-static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- uiLayout *row, *split, *sub;
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
-
- switch (RNA_enum_get(ptr, "mode")) {
- case ACT_EDOB_ADD_OBJECT:
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "object", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "time", 0, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "angular_velocity", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- break;
- case ACT_EDOB_END_OBJECT:
- break;
- case ACT_EDOB_REPLACE_MESH:
- if (ob->type != OB_MESH) {
- uiItemL(layout, IFACE_("Mode only available for mesh objects"), ICON_NONE);
- break;
- }
- split = uiLayoutSplit(layout, 0.6, false);
- uiItemR(split, ptr, "mesh", 0, NULL, ICON_NONE);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "use_replace_display_mesh", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- uiItemR(row, ptr, "use_replace_physics_mesh", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- break;
- case ACT_EDOB_TRACK_TO:
- split = uiLayoutSplit(layout, 0.5, false);
- uiItemR(split, ptr, "track_object", 0, NULL, ICON_NONE);
- sub = uiLayoutSplit(split, 0.7f, false);
- uiItemR(sub, ptr, "time", 0, NULL, ICON_NONE);
- uiItemR(sub, ptr, "use_3d_tracking", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "up_axis", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "track_axis", 0, NULL, ICON_NONE);
- break;
- case ACT_EDOB_DYNAMICS:
- if (ob->type != OB_MESH) {
- uiItemL(layout, IFACE_("Mode only available for mesh objects"), ICON_NONE);
- break;
- }
- uiItemR(layout, ptr, "dynamic_operation", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "dynamic_operation") == ACT_EDOB_SET_MASS)
- uiItemR(layout, ptr, "mass", 0, NULL, ICON_NONE);
- break;
- }
-}
-
-static void draw_actuator_filter_2d(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *row, *split;
-
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
- switch (RNA_enum_get(ptr, "mode")) {
- case ACT_2DFILTER_CUSTOMFILTER:
- uiItemR(layout, ptr, "filter_pass", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "glsl_shader", 0, NULL, ICON_NONE);
- break;
- case ACT_2DFILTER_MOTIONBLUR:
- split=uiLayoutSplit(layout, 0.75f, true);
- row = uiLayoutRow(split, false);
- uiLayoutSetActive(row, RNA_boolean_get(ptr, "use_motion_blur") == true);
- uiItemR(row, ptr, "motion_blur_factor", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_motion_blur", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- break;
- default: // all other 2D Filters
- uiItemR(layout, ptr, "filter_pass", 0, NULL, ICON_NONE);
- break;
- }
-}
-
-static void draw_actuator_game(uiLayout *layout, PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
- if (ELEM(RNA_enum_get(ptr, "mode"), ACT_GAME_LOAD, ACT_GAME_SCREENSHOT))
- uiItemR(layout, ptr, "filename", 0, NULL, ICON_NONE);
-}
-
-static void draw_actuator_message(uiLayout *layout, PointerRNA *ptr, bContext *C)
-{
- Object *ob;
- PointerRNA main_ptr, settings_ptr;
- uiLayout *row;
-
- RNA_main_pointer_create(CTX_data_main(C), &main_ptr);
-
- ob = (Object *)ptr->id.data;
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-
- uiItemPointerR(layout, ptr, "to_property", &main_ptr, "objects", NULL, ICON_OBJECT_DATA);
- uiItemR(layout, ptr, "subject", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, true);
- uiItemR(row, ptr, "body_type", 0, NULL, ICON_NONE);
-
- if (RNA_enum_get(ptr, "body_type") == ACT_MESG_MESG)
- uiItemR(row, ptr, "body_message", 0, "", ICON_NONE);
- else // mode == ACT_MESG_PROP
- uiItemPointerR(row, ptr, "body_property", &settings_ptr, "properties", "", ICON_NONE);
-}
-
-static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr)
-{
- Object *ob;
- PointerRNA settings_ptr;
- uiLayout *split, *row, *col, *sub;
- int physics_type;
-
- ob = (Object *)ptr->id.data;
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
- physics_type = RNA_enum_get(&settings_ptr, "physics_type");
-
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
-
- switch (RNA_enum_get(ptr, "mode")) {
- case ACT_OBJECT_NORMAL:
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "offset_location", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_local_location", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "offset_rotation", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_local_rotation", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- if (ELEM(physics_type, OB_BODY_TYPE_DYNAMIC, OB_BODY_TYPE_RIGID, OB_BODY_TYPE_SOFT)) {
- uiItemL(layout, IFACE_("Dynamic Object Settings:"), ICON_NONE);
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "force", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_local_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "torque", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_local_torque", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE);
- row = uiLayoutRow(split, true);
- uiItemR(row, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- uiItemR(row, ptr, "use_add_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "angular_velocity", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- uiItemR(layout, ptr, "damping", 0, NULL, ICON_NONE);
- }
- break;
- case ACT_OBJECT_SERVO:
- uiItemR(layout, ptr, "reference_object", 0, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- col = uiLayoutColumn(row, false);
- uiItemR(col, ptr, "use_servo_limit_x", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- sub = uiLayoutColumn(col, true);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_x") == true);
- uiItemR(sub, ptr, "force_max_x", 0, NULL, ICON_NONE);
- uiItemR(sub, ptr, "force_min_x", 0, NULL, ICON_NONE);
-
- col = uiLayoutColumn(row, false);
- uiItemR(col, ptr, "use_servo_limit_y", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- sub = uiLayoutColumn(col, true);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_y") == true);
- uiItemR(sub, ptr, "force_max_y", 0, NULL, ICON_NONE);
- uiItemR(sub, ptr, "force_min_y", 0, NULL, ICON_NONE);
-
- col = uiLayoutColumn(row, false);
- uiItemR(col, ptr, "use_servo_limit_z", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- sub = uiLayoutColumn(col, true);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_z") == true);
- uiItemR(sub, ptr, "force_max_z", 0, NULL, ICON_NONE);
- uiItemR(sub, ptr, "force_min_z", 0, NULL, ICON_NONE);
-
- //XXXACTUATOR missing labels from original 2.49 ui (e.g. Servo, Min, Max, Fast)
- //Layout designers willing to help on that, please compare with 2.49 ui
- // (since the old code is going to be deleted ... soon)
-
- col = uiLayoutColumn(layout, true);
- uiItemR(col, ptr, "proportional_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- uiItemR(col, ptr, "integral_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- uiItemR(col, ptr, "derivate_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- break;
- case ACT_OBJECT_CHARACTER:
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "offset_location", 0, NULL, ICON_NONE);
- row = uiLayoutRow(split, true);
- uiItemR(row, ptr, "use_local_location", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- uiItemR(row, ptr, "use_add_character_location", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- uiItemR(row, ptr, "offset_rotation", 0, NULL, ICON_NONE);
- uiItemR(split, ptr, "use_local_rotation", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
-
- split = uiLayoutSplit(layout, 0.9, false);
- row = uiLayoutRow(split, false);
- split = uiLayoutSplit(row, 0.7, false);
- uiItemL(split, "", ICON_NONE); /*Just use this for some spacing */
- uiItemR(split, ptr, "use_character_jump", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- break;
- }
-}
-
-static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *row, *sub;
-
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
-
- if (RNA_enum_get(ptr, "mode") == ACT_PARENT_SET) {
- uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "use_compound", 0, NULL, ICON_NONE);
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_compound") == true);
- uiItemR(sub, ptr, "use_ghost", 0, NULL, ICON_NONE);
- }
-}
-
-static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- bActuator *act = (bActuator *)ptr->data;
- bPropertyActuator *pa = (bPropertyActuator *) act->data;
- Object *ob_from= pa->ob;
- PointerRNA settings_ptr, obj_settings_ptr;
-
- uiLayout *row, *sub;
-
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
- uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE);
-
- switch (RNA_enum_get(ptr, "mode")) {
- case ACT_PROP_TOGGLE:
- case ACT_PROP_LEVEL:
- break;
- case ACT_PROP_ADD:
- uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE);
- break;
- case ACT_PROP_ASSIGN:
- uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE);
- break;
- case ACT_PROP_COPY:
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "object", 0, NULL, ICON_NONE);
- if (ob_from) {
- RNA_pointer_create((ID *)ob_from, &RNA_GameObjectSettings, ob_from, &obj_settings_ptr);
- uiItemPointerR(row, ptr, "object_property", &obj_settings_ptr, "properties", NULL, ICON_NONE);
- }
- else {
- sub = uiLayoutRow(row, false);
- uiLayoutSetActive(sub, false);
- uiItemR(sub, ptr, "object_property", 0, NULL, ICON_NONE);
- }
- break;
- }
-}
-
-static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr)
-{
- Object *ob;
- PointerRNA settings_ptr;
- uiLayout *row;
-
- ob = (Object *)ptr->id.data;
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-
- row = uiLayoutRow(layout, false);
-
- uiItemR(row, ptr, "seed", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "distribution", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
-
- switch (RNA_enum_get(ptr, "distribution")) {
- case ACT_RANDOM_BOOL_CONST:
- uiItemR(row, ptr, "use_always_true", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- break;
-
- case ACT_RANDOM_BOOL_UNIFORM:
- uiItemL(row, IFACE_("Choose between true and false, 50% chance each"), ICON_NONE);
- break;
-
- case ACT_RANDOM_BOOL_BERNOUILLI:
- uiItemR(row, ptr, "chance", 0, NULL, ICON_NONE);
- break;
-
- case ACT_RANDOM_INT_CONST:
- uiItemR(row, ptr, "int_value", 0, NULL, ICON_NONE);
- break;
-
- case ACT_RANDOM_INT_UNIFORM:
- uiItemR(row, ptr, "int_min", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "int_max", 0, NULL, ICON_NONE);
- break;
-
- case ACT_RANDOM_INT_POISSON:
- uiItemR(row, ptr, "int_mean", 0, NULL, ICON_NONE);
- break;
-
- case ACT_RANDOM_FLOAT_CONST:
- uiItemR(row, ptr, "float_value", 0, NULL, ICON_NONE);
- break;
-
- case ACT_RANDOM_FLOAT_UNIFORM:
- uiItemR(row, ptr, "float_min", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "float_max", 0, NULL, ICON_NONE);
- break;
-
- case ACT_RANDOM_FLOAT_NORMAL:
- uiItemR(row, ptr, "float_mean", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "standard_derivation", 0, NULL, ICON_NONE);
- break;
-
- case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL:
- uiItemR(row, ptr, "half_life_time", 0, NULL, ICON_NONE);
- break;
- }
-}
-
-static void draw_actuator_scene(uiLayout *layout, PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
-
- switch (RNA_enum_get(ptr, "mode")) {
- case ACT_SCENE_CAMERA:
- uiItemR(layout, ptr, "camera", 0, NULL, ICON_NONE);
- break;
- case ACT_SCENE_RESTART:
- break;
- default: // ACT_SCENE_SET|ACT_SCENE_ADD_FRONT|ACT_SCENE_ADD_BACK|ACT_SCENE_REMOVE|ACT_SCENE_SUSPEND|ACT_SCENE_RESUME
- uiItemR(layout, ptr, "scene", 0, NULL, ICON_NONE);
- break;
- }
-}
-
-static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- PointerRNA settings_ptr;
- uiLayout *row;
-
- if (ob->type != OB_MESH) {
- uiItemL(layout, IFACE_("Actuator only available for mesh objects"), ICON_NONE);
- return;
- }
-
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "mode", 0, "", ICON_NONE);
- uiItemR(row, ptr, "action", 0, "", ICON_NONE);
- uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- if ((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP))
- uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE);
-
- else {
- uiItemR(row, ptr, "frame_start", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "frame_end", 0, NULL, ICON_NONE);
- }
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemPointerR(row, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE);
-
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- uiItemR(row, "stride_length", 0, NULL, ICON_NONE);
-#endif
-}
-
-static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C)
-{
- uiLayout *row, *col;
-
- uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL);
- if (!RNA_pointer_get(ptr, "sound").data) {
- uiItemL(layout, IFACE_("Select a sound from the list or load a new one"), ICON_NONE);
- return;
- }
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "volume", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "pitch", 0, NULL, ICON_NONE);
-
- uiItemR(layout, ptr, "use_sound_3d", 0, NULL, ICON_NONE);
-
- col = uiLayoutColumn(layout, false);
- uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_sound_3d") == true);
-
- row = uiLayoutRow(col, false);
- uiItemR(row, ptr, "gain_3d_min", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "gain_3d_max", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(col, false);
- uiItemR(row, ptr, "distance_3d_reference", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "distance_3d_max", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(col, false);
- uiItemR(row, ptr, "rolloff_factor_3d", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "cone_outer_gain_3d", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(col, false);
- uiItemR(row, ptr, "cone_outer_angle_3d", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "cone_inner_angle_3d", 0, NULL, ICON_NONE);
-}
-
-static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *split;
- Object *ob = (Object *)ptr->id.data;
- PointerRNA settings_ptr;
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-
- split = uiLayoutSplit(layout, 0.35, false);
- uiItemR(split, ptr, "operation", 0, NULL, ICON_NONE);
-
- uiTemplateLayers(split, ptr, "states", &settings_ptr, "used_states", 0);
-}
-
-static void draw_actuator_visibility(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *row;
- row = uiLayoutRow(layout, false);
-
- uiItemR(row, ptr, "use_visible", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "use_occlusion", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "apply_to_children", 0, NULL, ICON_NONE);
-}
-
-static void draw_actuator_steering(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *row;
- uiLayout *col;
-
- uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "target", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "navmesh", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "velocity", 0, NULL, ICON_NONE);
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "acceleration", 0, NULL, ICON_NONE);
- uiItemR(row, ptr, "turn_speed", 0, NULL, ICON_NONE);
-
- row = uiLayoutRow(layout, false);
- col = uiLayoutColumn(row, false);
- uiItemR(col, ptr, "facing", 0, NULL, ICON_NONE);
- col = uiLayoutColumn(row, false);
- uiItemR(col, ptr, "facing_axis", 0, NULL, ICON_NONE);
- if (!RNA_boolean_get(ptr, "facing")) {
- uiLayoutSetActive(col, false);
- }
- col = uiLayoutColumn(row, false);
- uiItemR(col, ptr, "normal_up", 0, NULL, ICON_NONE);
- if (!RNA_pointer_get(ptr, "navmesh").data) {
- uiLayoutSetActive(col, false);
- }
-
- row = uiLayoutRow(layout, false);
- col = uiLayoutColumn(row, false);
- uiItemR(col, ptr, "self_terminated", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "mode")==ACT_STEERING_PATHFOLLOWING) {
- col = uiLayoutColumn(row, false);
- uiItemR(col, ptr, "update_period", 0, NULL, ICON_NONE);
- }
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "lock_z_velocity", 1, NULL, ICON_NONE);
- row = uiLayoutRow(layout, false);
- uiItemR(row, ptr, "show_visualization", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "mode") != ACT_STEERING_PATHFOLLOWING) {
- uiLayoutSetActive(row, false);
- }
-}
-
-static void draw_actuator_mouse(uiLayout *layout, PointerRNA *ptr)
-{
- uiLayout *row, *col, *subcol, *split, *subsplit;
-
- uiItemR(layout, ptr, "mode", 0, NULL, 0);
-
- switch (RNA_enum_get(ptr, "mode")) {
- case ACT_MOUSE_VISIBILITY:
- row = uiLayoutRow(layout, 0);
- uiItemR(row, ptr, "visible", UI_ITEM_R_TOGGLE, NULL, 0);
- break;
-
- case ACT_MOUSE_LOOK:
- /* X axis */
- row = uiLayoutRow(layout, 0);
- col = uiLayoutColumn(row, 1);
-
- uiItemR(col, ptr, "use_axis_x", UI_ITEM_R_TOGGLE, NULL, 0);
-
- subcol = uiLayoutColumn(col, 1);
- uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_axis_x")==1);
- uiItemR(subcol, ptr, "sensitivity_x", 0, NULL, 0);
- uiItemR(subcol, ptr, "threshold_x", 0, NULL, 0);
-
- uiItemR(subcol, ptr, "min_x", 0, NULL, 0);
- uiItemR(subcol, ptr, "max_x", 0, NULL, 0);
-
- uiItemR(subcol, ptr, "object_axis_x", 0, NULL, 0);
-
- /* Y Axis */
- col = uiLayoutColumn(row, 1);
-
- uiItemR(col, ptr, "use_axis_y", UI_ITEM_R_TOGGLE, NULL, 0);
-
- subcol = uiLayoutColumn(col, 1);
- uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_axis_y")==1);
- uiItemR(subcol, ptr, "sensitivity_y", 0, NULL, 0);
- uiItemR(subcol, ptr, "threshold_y", 0, NULL, 0);
-
- uiItemR(subcol, ptr, "min_y", 0, NULL, 0);
- uiItemR(subcol, ptr, "max_y", 0, NULL, 0);
-
- uiItemR(subcol, ptr, "object_axis_y", 0, NULL, 0);
-
- /* Lower options */
- row = uiLayoutRow(layout, 0);
- split = uiLayoutSplit(row, 0.5, 0);
-
- subsplit = uiLayoutSplit(split, 0.5, 1);
- uiLayoutSetActive(subsplit, RNA_boolean_get(ptr, "use_axis_x")==1);
- uiItemR(subsplit, ptr, "local_x", UI_ITEM_R_TOGGLE, NULL, 0);
- uiItemR(subsplit, ptr, "reset_x", UI_ITEM_R_TOGGLE, NULL, 0);
-
- subsplit = uiLayoutSplit(split, 0.5, 1);
- uiLayoutSetActive(subsplit, RNA_boolean_get(ptr, "use_axis_y")==1);
- uiItemR(subsplit, ptr, "local_y", UI_ITEM_R_TOGGLE, NULL, 0);
- uiItemR(subsplit, ptr, "reset_y", UI_ITEM_R_TOGGLE, NULL, 0);
-
- break;
- }
-}
-
-static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C)
-{
- uiLayout *box;
-
- if (!RNA_boolean_get(ptr, "show_expanded"))
- return;
-
- box = uiLayoutBox(layout);
- uiLayoutSetActive(box, RNA_boolean_get(ptr, "active"));
-
- switch (RNA_enum_get(ptr, "type")) {
- case ACT_ACTION:
- draw_actuator_action(box, ptr);
- break;
- case ACT_ARMATURE:
- draw_actuator_armature(box, ptr);
- break;
- case ACT_CAMERA:
- draw_actuator_camera(box, ptr);
- break;
- case ACT_CONSTRAINT:
- draw_actuator_constraint(box, ptr, C);
- break;
- case ACT_EDIT_OBJECT:
- draw_actuator_edit_object(box, ptr);
- break;
- case ACT_2DFILTER:
- draw_actuator_filter_2d(box, ptr);
- break;
- case ACT_GAME:
- draw_actuator_game(box, ptr);
- break;
- case ACT_MESSAGE:
- draw_actuator_message(box, ptr, C);
- break;
- case ACT_OBJECT:
- draw_actuator_motion(box, ptr);
- break;
- case ACT_PARENT:
- draw_actuator_parent(box, ptr);
- break;
- case ACT_PROPERTY:
- draw_actuator_property(box, ptr);
- break;
- case ACT_RANDOM:
- draw_actuator_random(box, ptr);
- break;
- case ACT_SCENE:
- draw_actuator_scene(box, ptr);
- break;
- case ACT_SHAPEACTION:
- draw_actuator_shape_action(box, ptr);
- break;
- case ACT_SOUND:
- draw_actuator_sound(box, ptr, C);
- break;
- case ACT_STATE:
- draw_actuator_state(box, ptr);
- break;
- case ACT_VISIBILITY:
- draw_actuator_visibility(box, ptr);
- break;
- case ACT_STEERING:
- draw_actuator_steering(box, ptr);
- break;
- case ACT_MOUSE:
- draw_actuator_mouse(box, ptr);
- break;
- }
-}
-
-void logic_buttons(bContext *C, ARegion *ar)
-{
- SpaceLogic *slogic= CTX_wm_space_logic(C);
- Object *ob= CTX_data_active_object(C);
- ID **idar;
- PointerRNA logic_ptr, settings_ptr, object_ptr;
- uiLayout *layout, *row, *box;
- uiBlock *block;
- uiBut *but;
- char uiblockstr[32];
- short a, count;
- int xco, yco, width, height;
-
- if (ob==NULL) return;
-
- RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
- idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
-
- BLI_snprintf(uiblockstr, sizeof(uiblockstr), "buttonswin %p", (void *)ar);
- block= UI_block_begin(C, ar, uiblockstr, UI_EMBOSS);
- UI_block_func_handle_set(block, do_logic_buts, NULL);
- UI_block_bounds_set_normal(block, U.widget_unit/2);
-
- /* loop over all objects and set visible/linked flags for the logic bricks */
- for (a=0; a<count; a++) {
- bActuator *act;
- bSensor *sens;
- bController *cont;
- int iact;
- short flag;
-
- ob= (Object *)idar[a];
-
- /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that we can determine which is actually linked/visible */
- act = ob->actuators.first;
- while (act) {
- act->flag &= ~(ACT_LINKED|ACT_VISIBLE);
- act = act->next;
- }
- /* same for sensors */
- sens= ob->sensors.first;
- while (sens) {
- sens->flag &= ~(SENS_VISIBLE);
- sens = sens->next;
- }
-
- /* mark the linked and visible actuators */
- cont= ob->controllers.first;
- while (cont) {
- flag = ACT_LINKED;
-
- /* this controller is visible, mark all its actuator */
- if ((ob->scaflag & OB_ALLSTATE) || (ob->state & cont->state_mask))
- flag |= ACT_VISIBLE;
-
- for (iact=0; iact<cont->totlinks; iact++) {
- act = cont->links[iact];
- if (act)
- act->flag |= flag;
- }
- cont = cont->next;
- }
- }
-
- /* ****************** Controllers ****************** */
-
- xco= 21 * U.widget_unit; yco= - U.widget_unit / 2; width= 15 * U.widget_unit;
- layout= UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_style_get());
- row = uiLayoutRow(layout, true);
-
- uiDefBlockBut(block, controller_menu, NULL, IFACE_("Controllers"), xco - U.widget_unit / 2, yco, width, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
-
- uiItemR(row, &logic_ptr, "show_controllers_selected_objects", 0, IFACE_("Sel"), ICON_NONE);
- uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, IFACE_("Act"), ICON_NONE);
- uiItemR(row, &logic_ptr, "show_controllers_linked_controller", 0, IFACE_("Link"), ICON_NONE);
-
- for (a=0; a<count; a++) {
- bController *cont;
- PointerRNA ptr;
- uiLayout *split, *subsplit, *col;
-
-
- ob= (Object *)idar[a];
-
- /* only draw the controller common header if "use_visible" */
- if ( (ob->scavisflag & OB_VIS_CONT) == 0) {
- continue;
- }
-
- /* Drawing the Controller Header common to all Selected Objects */
-
- RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-
- split = uiLayoutSplit(layout, 0.05f, false);
- uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT);
-
- row = uiLayoutRow(split, true);
- uiDefButBitS(block, UI_BTYPE_TOGGLE, OB_SHOWCONT, B_REDR, ob->id.name + 2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide controllers"));
-
- RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
- uiLayoutSetContextPointer(row, "object", &object_ptr);
- uiItemMenuEnumO(row, C, "LOGIC_OT_controller_add", "type", IFACE_("Add Controller"), ICON_NONE);
-
- if (RNA_boolean_get(&settings_ptr, "show_state_panel")) {
-
- box = uiLayoutBox(layout);
- split = uiLayoutSplit(box, 0.2f, false);
-
- col = uiLayoutColumn(split, false);
- uiItemL(col, IFACE_("Visible"), ICON_NONE);
- uiItemL(col, IFACE_("Initial"), ICON_NONE);
-
- subsplit = uiLayoutSplit(split, 0.85f, false);
- col = uiLayoutColumn(subsplit, false);
- row = uiLayoutRow(col, false);
- uiLayoutSetActive(row, RNA_boolean_get(&settings_ptr, "use_all_states") == false);
- uiTemplateGameStates(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0);
- row = uiLayoutRow(col, false);
- uiTemplateGameStates(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0);
-
- col = uiLayoutColumn(subsplit, false);
- uiItemR(col, &settings_ptr, "use_all_states", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
- uiItemR(col, &settings_ptr, "show_debug_state", 0, "", ICON_NONE);
- }
-
- /* End of Drawing the Controller Header common to all Selected Objects */
-
- if ((ob->scaflag & OB_SHOWCONT) == 0) continue;
-
-
- uiItemS(layout);
-
- for (cont= ob->controllers.first; cont; cont=cont->next) {
- RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &ptr);
-
- if (!(ob->scaflag & OB_ALLSTATE) && !(ob->state & cont->state_mask))
- continue;
-
- /* use two nested splits to align inlinks/links properly */
- split = uiLayoutSplit(layout, 0.05f, false);
-
- /* put inlink button to the left */
- col = uiLayoutColumn(split, false);
- uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
- uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT);
- but = uiDefIconBut(block, UI_BTYPE_INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, "");
- if (!RNA_boolean_get(&ptr, "active")) {
- UI_but_flag_enable(but, UI_BUT_SCA_LINK_GREY);
- }
-
- //col = uiLayoutColumn(split, true);
- /* nested split for middle and right columns */
- subsplit = uiLayoutSplit(split, 0.95f, false);
-
- col = uiLayoutColumn(subsplit, true);
- uiLayoutSetContextPointer(col, "controller", &ptr);
-
- /* should make UI template for controller header.. function will do for now */
-// draw_controller_header(col, &ptr);
- draw_controller_header(col, &ptr, xco, width, yco); //provisory for 2.50 beta
-
- /* draw the brick contents */
- draw_brick_controller(col, &ptr);
-
- /* put link button to the right */
- col = uiLayoutColumn(subsplit, false);
- uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
- uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT);
- but = uiDefIconBut(block, UI_BTYPE_LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- if (!RNA_boolean_get(&ptr, "active")) {
- UI_but_flag_enable(but, UI_BUT_SCA_LINK_GREY);
- }
-
- UI_but_link_set(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR);
-
- }
- }
- UI_block_layout_resolve(block, NULL, &yco); /* stores final height in yco */
- height = yco;
-
- /* ****************** Sensors ****************** */
-
- xco= U.widget_unit / 2; yco= -U.widget_unit / 2; width= 17 * U.widget_unit;
- layout= UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_style_get());
- row = uiLayoutRow(layout, true);
-
- uiDefBlockBut(block, sensor_menu, NULL, IFACE_("Sensors"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
-
- uiItemR(row, &logic_ptr, "show_sensors_selected_objects", 0, IFACE_("Sel"), ICON_NONE);
- uiItemR(row, &logic_ptr, "show_sensors_active_object", 0, IFACE_("Act"), ICON_NONE);
- uiItemR(row, &logic_ptr, "show_sensors_linked_controller", 0, IFACE_("Link"), ICON_NONE);
- uiItemR(row, &logic_ptr, "show_sensors_active_states", 0, IFACE_("State"), ICON_NONE);
-
- for (a=0; a<count; a++) {
- bSensor *sens;
- PointerRNA ptr;
-
- ob= (Object *)idar[a];
-
- /* only draw the sensor common header if "use_visible" */
- if ((ob->scavisflag & OB_VIS_SENS) == 0) continue;
-
- row = uiLayoutRow(layout, true);
- uiDefButBitS(block, UI_BTYPE_TOGGLE, OB_SHOWSENS, B_REDR, ob->id.name + 2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide sensors"));
-
- RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
- uiLayoutSetContextPointer(row, "object", &object_ptr);
- uiItemMenuEnumO(row, C, "LOGIC_OT_sensor_add", "type", IFACE_("Add Sensor"), ICON_NONE);
-
- if ((ob->scaflag & OB_SHOWSENS) == 0) continue;
-
- uiItemS(layout);
-
- for (sens= ob->sensors.first; sens; sens=sens->next) {
- RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &ptr);
-
- if ((ob->scaflag & OB_ALLSTATE) ||
- !(slogic->scaflag & BUTS_SENS_STATE) ||
- (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */
- (sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */
- (is_sensor_linked(block, sens))
- )
- { // gotta check if the current state is visible or not
- uiLayout *split, *col;
-
- /* make as visible, for move operator */
- sens->flag |= SENS_VISIBLE;
-
- split = uiLayoutSplit(layout, 0.95f, false);
- col = uiLayoutColumn(split, true);
- uiLayoutSetContextPointer(col, "sensor", &ptr);
-
- /* should make UI template for sensor header.. function will do for now */
- draw_sensor_header(col, &ptr, &logic_ptr);
-
- /* draw the brick contents */
- draw_brick_sensor(col, &ptr, C);
-
- /* put link button to the right */
- col = uiLayoutColumn(split, false);
- uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
- but = uiDefIconBut(block, UI_BTYPE_LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- if (!RNA_boolean_get(&ptr, "active")) {
- UI_but_flag_enable(but, UI_BUT_SCA_LINK_GREY);
- }
-
- /* use old-school uiButtons for links for now */
- UI_but_link_set(but, NULL, (void ***)&sens->links, &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
- }
- }
- }
- UI_block_layout_resolve(block, NULL, &yco); /* stores final height in yco */
- height = MIN2(height, yco);
-
- /* ****************** Actuators ****************** */
-
- xco= 40 * U.widget_unit; yco= -U.widget_unit / 2; width= 17 * U.widget_unit;
- layout= UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_style_get());
- row = uiLayoutRow(layout, true);
-
- uiDefBlockBut(block, actuator_menu, NULL, IFACE_("Actuators"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */
-
- uiItemR(row, &logic_ptr, "show_actuators_selected_objects", 0, IFACE_("Sel"), ICON_NONE);
- uiItemR(row, &logic_ptr, "show_actuators_active_object", 0, IFACE_("Act"), ICON_NONE);
- uiItemR(row, &logic_ptr, "show_actuators_linked_controller", 0, IFACE_("Link"), ICON_NONE);
- uiItemR(row, &logic_ptr, "show_actuators_active_states", 0, IFACE_("State"), ICON_NONE);
-
- for (a=0; a<count; a++) {
- bActuator *act;
- PointerRNA ptr;
-
- ob= (Object *)idar[a];
-
- /* only draw the actuator common header if "use_visible" */
- if ((ob->scavisflag & OB_VIS_ACT) == 0) {
- continue;
- }
-
- row = uiLayoutRow(layout, true);
- uiDefButBitS(block, UI_BTYPE_TOGGLE, OB_SHOWACT, B_REDR, ob->id.name + 2, (short)(xco - U.widget_unit / 2), yco, (short)(width - 1.5f * U.widget_unit), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide actuators"));
-
- RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
- uiLayoutSetContextPointer(row, "object", &object_ptr);
- uiItemMenuEnumO(row, C, "LOGIC_OT_actuator_add", "type", IFACE_("Add Actuator"), ICON_NONE);
-
- if ((ob->scaflag & OB_SHOWACT) == 0) continue;
-
- uiItemS(layout);
-
- for (act= ob->actuators.first; act; act=act->next) {
-
- RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &ptr);
-
- if ((ob->scaflag & OB_ALLSTATE) ||
- !(slogic->scaflag & BUTS_ACT_STATE) ||
- !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */
- (act->flag & ACT_VISIBLE) || /* this actuator has visible connection, display it */
- (act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE) /* states can hide some sensors, pinned sensors ignore the visible state */
- )
- { // gotta check if the current state is visible or not
- uiLayout *split, *col;
-
- /* make as visible, for move operator */
- act->flag |= ACT_VISIBLE;
-
- split = uiLayoutSplit(layout, 0.05f, false);
-
- /* put inlink button to the left */
- col = uiLayoutColumn(split, false);
- uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active"));
- but = uiDefIconBut(block, UI_BTYPE_INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, "");
- if (!RNA_boolean_get(&ptr, "active")) {
- UI_but_flag_enable(but, UI_BUT_SCA_LINK_GREY);
- }
-
- col = uiLayoutColumn(split, true);
- uiLayoutSetContextPointer(col, "actuator", &ptr);
-
- /* should make UI template for actuator header.. function will do for now */
- draw_actuator_header(col, &ptr, &logic_ptr);
-
- /* draw the brick contents */
- draw_brick_actuator(col, &ptr, C);
-
- }
- }
- }
- UI_block_layout_resolve(block, NULL, &yco); /* stores final height in yco */
- height = MIN2(height, yco);
-
- UI_view2d_totRect_set(&ar->v2d, 57.5f * U.widget_unit, height - U.widget_unit);
-
- /* set the view */
- UI_view2d_view_ortho(&ar->v2d);
-
- UI_block_links_compose(block);
-
- UI_block_end(C, block);
- UI_block_draw(C, block);
-
- /* restore view matrix */
- UI_view2d_view_restore(C);
-
- if (idar) MEM_freeN(idar);
-}
-
diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c
deleted file mode 100644
index af90ef487e0..00000000000
--- a/source/blender/editors/space_logic/space_logic.c
+++ /dev/null
@@ -1,377 +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): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_logic/space_logic.c
- * \ingroup splogic
- */
-
-
-#include <string.h>
-#include <stdio.h>
-
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-
-#include "DNA_gpencil_types.h"
-
-#include "BKE_context.h"
-#include "BKE_library.h"
-#include "BKE_screen.h"
-
-#include "ED_space_api.h"
-#include "ED_screen.h"
-
-#include "BIF_gl.h"
-
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "UI_resources.h"
-#include "UI_view2d.h"
-
-#include "logic_intern.h"
-
-/* ******************** manage regions ********************* */
-
-ARegion *logic_has_buttons_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) return ar;
-
- /* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
- /* is error! */
- if (ar == NULL) return NULL;
-
- arnew= MEM_callocN(sizeof(ARegion), "buttons for image");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
-/* ******************** default callbacks for image space ***************** */
-
-static SpaceLink *logic_new(const bContext *C)
-{
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar;
- SpaceLogic *slogic;
-
- slogic= MEM_callocN(sizeof(SpaceLogic), "initlogic");
- slogic->spacetype= SPACE_LOGIC;
-
- /* default options */
- slogic->scaflag = ((BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_SENS_LINK) |
- (BUTS_CONT_SEL|BUTS_CONT_ACT|BUTS_CONT_LINK) |
- (BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_ACT_LINK) |
- (BUTS_SENS_STATE|BUTS_ACT_STATE));
-
-
- /* header */
- ar= MEM_callocN(sizeof(ARegion), "header for logic");
-
- BLI_addtail(&slogic->regionbase, ar);
- ar->regiontype= RGN_TYPE_HEADER;
- ar->alignment= RGN_ALIGN_BOTTOM;
-
- /* buttons/list view */
- ar= MEM_callocN(sizeof(ARegion), "buttons for logic");
-
- BLI_addtail(&slogic->regionbase, ar);
- ar->regiontype= RGN_TYPE_UI;
- ar->alignment= RGN_ALIGN_RIGHT;
-
- /* main region */
- ar= MEM_callocN(sizeof(ARegion), "main region for logic");
-
- BLI_addtail(&slogic->regionbase, ar);
- ar->regiontype= RGN_TYPE_WINDOW;
-
- ar->v2d.tot.xmin = 0.0f;
- ar->v2d.tot.ymax = 0.0f;
- ar->v2d.tot.xmax = 1150.0f;
- ar->v2d.tot.ymin = ( 1150.0f/(float)sa->winx ) * (float)-sa->winy;
-
- ar->v2d.cur = ar->v2d.tot;
-
- ar->v2d.min[0] = 1.0f;
- ar->v2d.min[1] = 1.0f;
-
- ar->v2d.max[0] = 32000.0f;
- ar->v2d.max[1] = 32000.0f;
-
- ar->v2d.minzoom = 0.5f;
- ar->v2d.maxzoom = 1.5f;
-
- ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
- ar->v2d.keepzoom = V2D_KEEPZOOM | V2D_LIMITZOOM | V2D_KEEPASPECT;
- ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
- ar->v2d.align = V2D_ALIGN_NO_POS_Y | V2D_ALIGN_NO_NEG_X;
- ar->v2d.keepofs = V2D_KEEPOFS_Y;
-
- return (SpaceLink *)slogic;
-}
-
-/* not spacelink itself */
-static void logic_free(SpaceLink *UNUSED(sl))
-{
-// Spacelogic *slogic= (SpaceLogic *) sl;
-
-// if (slogic->gpd)
-// XXX BKE_gpencil_free(slogic->gpd);
-
-}
-
-
-/* spacetype; init callback */
-static void logic_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
-{
-
-}
-
-static SpaceLink *logic_duplicate(SpaceLink *sl)
-{
- SpaceLogic *slogicn= MEM_dupallocN(sl);
-
- return (SpaceLink *)slogicn;
-}
-
-static void logic_operatortypes(void)
-{
- WM_operatortype_append(LOGIC_OT_properties);
- WM_operatortype_append(LOGIC_OT_links_cut);
-}
-
-static void logic_keymap(struct wmKeyConfig *keyconf)
-{
- wmKeyMap *keymap = WM_keymap_find(keyconf, "Logic Editor", SPACE_LOGIC, 0);
-
- WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "LOGIC_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
- WM_keymap_add_item(keymap, "LOGIC_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
-#ifdef WITH_INPUT_NDOF
- WM_keymap_add_item(keymap, "LOGIC_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
-#endif
-}
-
-static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa))
-{
-// SpaceLogic *slogic= CTX_wm_space_logic(C);
-// Object *obedit= CTX_data_edit_object(C);
-
-}
-
-static void logic_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
- wmNotifier *wmn, const Scene *UNUSED(scene))
-{
- /* context changes */
- switch (wmn->category) {
- case NC_LOGIC:
- ED_region_tag_redraw(ar);
- break;
- case NC_SCENE:
- switch (wmn->data) {
- case ND_FRAME:
- ED_region_tag_redraw(ar);
- break;
-
- case ND_OB_ACTIVE:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_OBJECT:
- break;
- case NC_ID:
- if (wmn->action == NA_RENAME)
- ED_region_tag_redraw(ar);
- break;
- }
-}
-
-static int logic_context(const bContext *UNUSED(C), const char *UNUSED(member), bContextDataResult *UNUSED(result))
-{
-// SpaceLogic *slogic= CTX_wm_space_logic(C);
- return 0;
-}
-
-/************************** main region ***************************/
-
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void logic_main_region_init(wmWindowManager *wm, ARegion *ar)
-{
- wmKeyMap *keymap;
-
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-
- /* own keymaps */
- keymap = WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
- WM_event_add_keymap_handler(&ar->handlers, keymap);
-}
-
-static void logic_main_region_draw(const bContext *C, ARegion *ar)
-{
- /* draw entirely, view changes should be handled here */
-// SpaceLogic *slogic= CTX_wm_space_logic(C);
- View2D *v2d= &ar->v2d;
- View2DScrollers *scrollers;
-
- /* clear and setup matrix */
- UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
-
- UI_view2d_view_ortho(v2d);
-
- logic_buttons((bContext *)C, ar);
-
- /* reset view matrix */
- UI_view2d_view_restore(C);
-
- /* scrollers */
- scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
- UI_view2d_scrollers_free(scrollers);
-
-}
-
-
-/* *********************** buttons region ************************ */
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void logic_buttons_region_init(wmWindowManager *wm, ARegion *ar)
-{
- wmKeyMap *keymap;
-
- ED_region_panels_init(wm, ar);
-
- keymap = WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
- WM_event_add_keymap_handler(&ar->handlers, keymap);
-}
-
-static void logic_buttons_region_draw(const bContext *C, ARegion *ar)
-{
- ED_region_panels(C, ar, NULL, -1, true);
-}
-
-/************************* header region **************************/
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void logic_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
-{
- ED_region_header_init(ar);
-}
-
-static void logic_header_region_draw(const bContext *C, ARegion *ar)
-{
- ED_region_header(C, ar);
-}
-
-/**************************** spacetype *****************************/
-
-static void logic_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
-{
- SpaceLogic *slog = (SpaceLogic *)slink;
-
- if (!ELEM(GS(old_id->name), ID_GD)) {
- return;
- }
-
- if ((ID *)slog->gpd == old_id) {
- slog->gpd = (bGPdata *)new_id;
- id_us_min(old_id);
- id_us_plus(new_id);
- }
-}
-
-/* only called once, from space/spacetypes.c */
-void ED_spacetype_logic(void)
-{
- SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype logic");
- ARegionType *art;
-
- st->spaceid = SPACE_LOGIC;
- strncpy(st->name, "Logic", BKE_ST_MAXNAME);
-
- st->new = logic_new;
- st->free = logic_free;
- st->init = logic_init;
- st->duplicate = logic_duplicate;
- st->operatortypes = logic_operatortypes;
- st->keymap = logic_keymap;
- st->refresh = logic_refresh;
- st->context = logic_context;
- st->id_remap = logic_id_remap;
-
- /* regions: main window */
- art = MEM_callocN(sizeof(ARegionType), "spacetype logic region");
- art->regionid = RGN_TYPE_WINDOW;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES | ED_KEYMAP_VIEW2D;
- art->init = logic_main_region_init;
- art->draw = logic_main_region_draw;
- art->listener = logic_listener;
-
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: listview/buttons */
- art = MEM_callocN(sizeof(ARegionType), "spacetype logic region");
- art->regionid = RGN_TYPE_UI;
- art->prefsizex= 220; // XXX
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
- art->listener = logic_listener;
- art->init = logic_buttons_region_init;
- art->draw = logic_buttons_region_draw;
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: header */
- art= MEM_callocN(sizeof(ARegionType), "spacetype logic region");
- art->regionid = RGN_TYPE_HEADER;
- art->prefsizey = HEADERY;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
- art->init = logic_header_region_init;
- art->draw = logic_header_region_draw;
-
- BLI_addhead(&st->regiontypes, art);
-
- BKE_spacetype_register(st);
-}
-
-
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index 3080ac2de84..9551a1cf362 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -72,7 +72,7 @@ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int UNUSED(eve
//Scene *scene = CTX_data_scene(C);
#if 0
switch (event) {
-
+ /* pass */
}
#endif
/* default for now */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 08ac7c8973e..bf831f16108 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -55,6 +55,9 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_message.h"
+
+#include "RNA_access.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -268,6 +271,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceNla *snla = CTX_wm_space_nla(C);
+ Scene *scene = CTX_data_scene(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
View2DGrid *grid;
@@ -287,7 +291,10 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_grid_free(grid);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+
+ /* start and end frame */
+ ANIM_draw_framerange(scene, v2d);
+
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
/* strips and backdrops */
@@ -402,6 +409,7 @@ static void nla_main_region_listener(
case ND_RENDER_OPTIONS:
case ND_OB_ACTIVE:
case ND_FRAME:
+ case ND_FRAME_RANGE:
case ND_MARKERS:
ED_region_tag_redraw(ar);
break;
@@ -440,6 +448,46 @@ static void nla_main_region_listener(
}
}
+static void nla_main_region_message_subscribe(
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *UNUSED(workspace), struct Scene *scene,
+ struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ PointerRNA ptr;
+ RNA_pointer_create(&screen->id, &RNA_SpaceNLA, sa->spacedata.first, &ptr);
+
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ /* Timeline depends on scene properties. */
+ {
+ bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
+ extern PropertyRNA rna_Scene_frame_start;
+ extern PropertyRNA rna_Scene_frame_end;
+ extern PropertyRNA rna_Scene_frame_preview_start;
+ extern PropertyRNA rna_Scene_frame_preview_end;
+ extern PropertyRNA rna_Scene_use_preview_range;
+ extern PropertyRNA rna_Scene_frame_current;
+ const PropertyRNA *props[] = {
+ use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
+ use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
+ &rna_Scene_use_preview_range,
+ &rna_Scene_frame_current,
+ };
+
+ PointerRNA idptr;
+ RNA_id_pointer_create(&scene->id, &idptr);
+
+ for (int i = 0; i < ARRAY_SIZE(props); i++) {
+ WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
+ }
+ }
+}
+
static void nla_channel_region_listener(
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
@@ -552,6 +600,7 @@ void ED_spacetype_nla(void)
art->init = nla_main_region_init;
art->draw = nla_main_region_draw;
art->listener = nla_main_region_listener;
+ art->message_subscribe = nla_main_region_message_subscribe;
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 1cb9c57404a..ca6ae5955a9 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -679,21 +679,6 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
}
}
-static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
-{
- bNode *node = ptr->data;
- uiLayout *col;
-
- uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL);
-
- if (!node->id) return;
-
- col = uiLayoutColumn(layout, false);
- uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "invert_normal", 0, NULL, ICON_NONE);
-}
-
static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *row, *col, *sub;
@@ -741,30 +726,6 @@ static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C
uiItemR(layout, ptr, "convert_to", 0, "", ICON_NONE);
}
-static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
-{
- PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
- uiLayout *col;
-
- col = uiLayoutColumn(layout, false);
-
- if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
- PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
-
- uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_layers", "", ICON_NONE);
- uiItemPointerR(col, ptr, "color_layer", &dataptr, "vertex_colors", "", ICON_NONE);
- }
- else {
- uiItemR(col, ptr, "uv_layer", 0, IFACE_("UV"), ICON_NONE);
- uiItemR(col, ptr, "color_layer", 0, IFACE_("VCol"), ICON_NONE);
- }
-}
-
-static void node_shader_buts_lamp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
- uiItemR(layout, ptr, "lamp_object", 0, IFACE_("Lamp Object"), ICON_NONE);
-}
-
static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "attribute_name", 0, IFACE_("Name"), ICON_NONE);
@@ -1108,13 +1069,6 @@ static void node_shader_buts_bevel(uiLayout *layout, bContext *UNUSED(C), Pointe
static void node_shader_set_butfunc(bNodeType *ntype)
{
switch (ntype->type) {
- case SH_NODE_MATERIAL:
- case SH_NODE_MATERIAL_EXT:
- ntype->draw_buttons = node_shader_buts_material;
- break;
- case SH_NODE_TEXTURE:
- ntype->draw_buttons = node_buts_texture;
- break;
case SH_NODE_NORMAL:
ntype->draw_buttons = node_buts_normal;
break;
@@ -1148,12 +1102,6 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_VECT_TRANSFORM:
ntype->draw_buttons = node_shader_buts_vect_transform;
break;
- case SH_NODE_GEOMETRY:
- ntype->draw_buttons = node_shader_buts_geometry;
- break;
- case SH_NODE_LAMP:
- ntype->draw_buttons = node_shader_buts_lamp;
- break;
case SH_NODE_ATTRIBUTE:
ntype->draw_buttons = node_shader_buts_attribute;
break;
@@ -3441,7 +3389,7 @@ static void nodelink_batch_init(void)
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC);
int vcount = LINK_RESOL * 2; /* curve */
vcount += 2; /* restart strip */
- vcount += 3*2; /* arrow */
+ vcount += 3 * 2; /* arrow */
vcount *= 2; /* shadow */
vcount += 2; /* restart strip */
GWN_vertbuf_data_alloc(vbo, vcount);
@@ -3458,7 +3406,7 @@ static void nodelink_batch_init(void)
/* curve strip */
for (int i = 0; i < LINK_RESOL; ++i) {
- uv[0] = 255 * (i / (float)(LINK_RESOL-1));
+ uv[0] = 255 * (i / (float)(LINK_RESOL - 1));
uv[1] = 0;
set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
uv[1] = 255;
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index ec35727d176..c200c5a7612 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -316,10 +316,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
switch (snode->nodetree->type) {
case NTREE_SHADER:
- if (BKE_scene_use_new_shading_nodes(CTX_data_scene(C)))
- type = SH_NODE_TEX_IMAGE;
- else
- type = SH_NODE_TEXTURE;
+ type = SH_NODE_TEX_IMAGE;
break;
case NTREE_TEXTURE:
type = TEX_NODE_IMAGE;
@@ -340,14 +337,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (type == SH_NODE_TEXTURE) {
- Tex *tex = BKE_texture_add(CTX_data_main(C), DATA_(ima->id.name));
- tex->ima = ima;
- node->id = (ID *)tex;
- WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, node->id);
- }
- else
- node->id = (ID *)ima;
+ node->id = (ID *)ima;
/* When adding new image file via drag-drop we need to load imbuf in order
* to get proper image source.
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index c82c56ea648..ae810b0fde0 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -879,10 +879,6 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
char showname[128]; /* 128 used below */
View2D *v2d = &ar->v2d;
- /* XXX hack: copy values from linked ID data where displayed as sockets */
- if (node->block)
- nodeSynchronizeID(node, false);
-
/* skip if out of view */
if (BLI_rctf_isect(&node->totr, &v2d->cur, NULL) == false) {
UI_block_end(C, node->block);
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 94c31a7ddb7..340184845b8 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -383,7 +383,6 @@ bool ED_node_is_texture(struct SpaceNode *snode)
/* called from shading buttons or header */
void ED_node_shader_default(const bContext *C, ID *id)
{
- ViewRender *view_render = CTX_data_view_render(C);
bNode *in, *out;
bNodeSocket *fromsock, *tosock, *sock;
bNodeTree *ntree;
@@ -398,18 +397,8 @@ void ED_node_shader_default(const bContext *C, ID *id)
Material *ma = (Material *)id;
ma->nodetree = ntree;
- if (BKE_viewrender_uses_blender_eevee(view_render)) {
- output_type = SH_NODE_OUTPUT_MATERIAL;
- shader_type = SH_NODE_BSDF_PRINCIPLED;
- }
- else if (BKE_viewrender_use_new_shading_nodes(view_render)) {
- output_type = SH_NODE_OUTPUT_MATERIAL;
- shader_type = SH_NODE_BSDF_DIFFUSE;
- }
- else {
- output_type = SH_NODE_OUTPUT;
- shader_type = SH_NODE_MATERIAL;
- }
+ output_type = SH_NODE_OUTPUT_MATERIAL;
+ shader_type = SH_NODE_BSDF_PRINCIPLED;
copy_v3_v3(color, &ma->r);
strength = 0.0f;
@@ -460,18 +449,16 @@ void ED_node_shader_default(const bContext *C, ID *id)
nodeAddLink(ntree, in, fromsock, out, tosock);
/* default values */
- if (BKE_viewrender_use_new_shading_nodes(view_render)) {
- PointerRNA sockptr;
- sock = in->inputs.first;
- RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
-
- RNA_float_set_array(&sockptr, "default_value", color);
+ PointerRNA sockptr;
+ sock = in->inputs.first;
+ RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
+
+ RNA_float_set_array(&sockptr, "default_value", color);
- if (strength != 0.0f) {
- sock = in->inputs.last;
- RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
- RNA_float_set(&sockptr, "default_value", strength);
- }
+ if (strength != 0.0f) {
+ sock = in->inputs.last;
+ RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
+ RNA_float_set(&sockptr, "default_value", strength);
}
ntreeUpdateTree(CTX_data_main(C), ntree);
@@ -550,12 +537,6 @@ void snode_set_context(const bContext *C)
bNodeTree *ntree = snode->nodetree;
ID *id = snode->id, *from = snode->from;
- /* we use this to signal warnings, when node shaders are drawn in wrong render engine */
- if (BKE_scene_use_new_shading_nodes(CTX_data_scene(C)))
- snode->flag |= SNODE_NEW_SHADERS;
- else
- snode->flag &= ~SNODE_NEW_SHADERS;
-
/* check the tree type */
if (!treetype ||
(treetype->poll && !treetype->poll(C, treetype)))
@@ -643,7 +624,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO))
nodeClearActiveID(ntree, ID_TE);
- if (ELEM(node->type, SH_NODE_OUTPUT, SH_NODE_OUTPUT_MATERIAL,
+ if (ELEM(node->type, SH_NODE_OUTPUT_MATERIAL,
SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LAMP, SH_NODE_OUTPUT_LINESTYLE))
{
bNode *tnode;
@@ -1321,40 +1302,6 @@ void NODE_OT_read_viewlayers(wmOperatorType *ot)
ot->flag = 0;
}
-static int node_read_fullsamplelayers_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Main *bmain = CTX_data_main(C);
- SpaceNode *snode = CTX_wm_space_node(C);
- Scene *curscene = CTX_data_scene(C);
- Render *re = RE_NewSceneRender(curscene);
-
- WM_cursor_wait(1);
- RE_MergeFullSample(re, bmain, curscene, snode->nodetree);
- WM_cursor_wait(0);
-
- /* note we are careful to send the right notifier, as otherwise the
- * compositor would reexecute and overwrite the full sample result */
- WM_event_add_notifier(C, NC_SCENE | ND_COMPO_RESULT, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-
-void NODE_OT_read_fullsamplelayers(wmOperatorType *ot)
-{
-
- ot->name = "Read Full Sample Layers";
- ot->idname = "NODE_OT_read_fullsamplelayers";
- ot->description = "Read all render layers of current scene, in full sample";
-
- ot->exec = node_read_fullsamplelayers_exec;
-
- ot->poll = composite_node_active;
-
- /* flags */
- ot->flag = 0;
-}
-
int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *sce = CTX_data_scene(C);
@@ -2353,7 +2300,7 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot)
static int node_shader_script_update_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- RenderEngineType *type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *type = RE_engines_find(scene->r.engine);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node;
Text *text;
@@ -2423,7 +2370,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
bool found = false;
/* setup render engine */
- type = RE_engines_find(scene->view_render.engine_id);
+ type = RE_engines_find(scene->r.engine);
engine = RE_engine_create(type);
engine->reports = op->reports;
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index 1859785173c..c9c29212f02 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -95,7 +95,6 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_insert_offset);
WM_operatortype_append(NODE_OT_read_viewlayers);
- WM_operatortype_append(NODE_OT_read_fullsamplelayers);
WM_operatortype_append(NODE_OT_render_changed);
WM_operatortype_append(NODE_OT_backimage_move);
@@ -336,7 +335,6 @@ void node_keymap(struct wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "exit", true);
WM_keymap_add_item(keymap, "NODE_OT_read_viewlayers", RKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "NODE_OT_read_fullsamplelayers", RKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "NODE_OT_render_changed", ZKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_clipboard_copy", CKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 241ab60fe43..ed64cb6a6e1 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -455,10 +455,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
int compatibility = 0;
if (ntree->type == NTREE_SHADER) {
- if (BKE_scene_use_new_shading_nodes(arg->scene))
- compatibility = NODE_NEW_SHADING;
- else
- compatibility = NODE_OLD_SHADING;
+ compatibility = NODE_NEW_SHADING;
}
/* generate array of node types sorted by UI name */
@@ -559,7 +556,6 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- ViewRender *view_render = CTX_data_view_render(C);
uiBlock *block = uiLayoutGetBlock(layout);
uiBut *but = (uiBut *)but_p;
uiLayout *split, *column;
@@ -576,7 +572,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
arg->layout = split;
if (ntreetype && ntreetype->foreach_nodeclass)
- ntreetype->foreach_nodeclass(view_render, arg, node_menu_column_foreach_cb);
+ ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb);
column = uiLayoutColumn(split, false);
UI_block_layout_set_current(block, column);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index e1765e39f7a..a6a178b570d 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -382,14 +382,13 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
}
-static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *scene,
- WorkSpace *workspace)
+static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
+ WorkSpace *UNUSED(workspace))
{
/* note, ED_area_tag_refresh will re-execute compositor */
SpaceNode *snode = sa->spacedata.first;
- ViewRender *view_render = BKE_viewrender_get(scene, workspace);
/* shaderfrom is only used for new shading nodes, otherwise all shaders are from objects */
- short shader_type = BKE_viewrender_use_new_shading_nodes(view_render) ? snode->shaderfrom : SNODE_SHADER_OBJECT;
+ short shader_type = snode->shaderfrom;
/* preview renders */
switch (wmn->category) {
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 0f9723dea4b..25112fd13d1 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1428,7 +1428,7 @@ static void outliner_draw_tree_element(
/* Master collection can't expand/collapse. */
}
else if (te->subtree.first || (tselem->type == 0 && te->idcode == ID_SCE) || (te->flag & TE_LAZY_CLOSED)) {
- /* open/close icon, only when sublevels, except for scene */
+ /* open/close icon, only when sublevels, except for scene */
int icon_x = startx;
// icons a bit higher
@@ -1905,8 +1905,6 @@ static void outliner_draw_restrictcols(ARegion *ar)
void draw_outliner(const bContext *C)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
Main *mainvar = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 13567c2a5a2..672b2c1d318 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -51,7 +51,6 @@ struct bPoseChannel;
struct EditBone;
struct wmEvent;
struct wmKeyConfig;
-struct EvaluationContext;
typedef enum TreeElementInsertType {
TE_INSERT_BEFORE,
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index ba501ac7db5..543a0b0f8d7 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -288,7 +288,8 @@ static int outliner_item_drag_drop_modal(bContext *C, wmOperator *op, const wmEv
* It will fail when there is no next/prev TreeElement, or when the
* element is an Override or something else in the future.
*/
-static bool tree_element_is_collection_get(const TreeElement *te) {
+static bool tree_element_is_collection_get(const TreeElement *te)
+{
if (te == NULL) {
return false;
}
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 2f44420f3b7..73f450e9392 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -253,93 +253,6 @@ static eOLDrawState tree_element_active_material(
return OL_DRAWSEL_NONE;
}
-static eOLDrawState tree_element_active_texture(
- bContext *C, Scene *scene, ViewLayer *view_layer, SpaceOops *UNUSED(soops),
- TreeElement *te, const eOLSetState set)
-{
- TreeElement *tep;
- TreeStoreElem /* *tselem,*/ *tselemp;
- Object *ob = OBACT(view_layer);
- SpaceButs *sbuts = NULL;
-
- if (ob == NULL) {
- /* no active object */
- return OL_DRAWSEL_NONE;
- }
-
- /*tselem = TREESTORE(te);*/ /*UNUSED*/
-
- /* find buttons region (note, this is undefined really still, needs recode in blender) */
- /* XXX removed finding sbuts */
-
- /* where is texture linked to? */
- tep = te->parent;
- tselemp = TREESTORE(tep);
-
- if (tep->idcode == ID_WO) {
- World *wrld = (World *)tselemp->id;
-
- if (set != OL_SETSEL_NONE) {
- if (sbuts) {
- // XXX sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c
- // XXX sbuts->texfrom = 1;
- }
-// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture
- wrld->texact = te->index;
- }
- else if (tselemp->id == (ID *)(scene->world)) {
- if (wrld->texact == te->index) {
- return OL_DRAWSEL_NORMAL;
- }
- }
- }
- else if (tep->idcode == ID_LA) {
- Lamp *la = (Lamp *)tselemp->id;
- if (set != OL_SETSEL_NONE) {
- if (sbuts) {
- // XXX sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c
- // XXX sbuts->texfrom = 2;
- }
-// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture
- la->texact = te->index;
- }
- else {
- if (tselemp->id == ob->data) {
- if (la->texact == te->index) {
- return OL_DRAWSEL_NORMAL;
- }
- }
- }
- }
- else if (tep->idcode == ID_MA) {
- Material *ma = (Material *)tselemp->id;
- if (set != OL_SETSEL_NONE) {
- if (sbuts) {
- //sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c
- // XXX sbuts->texfrom = 0;
- }
-// XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture
- ma->texact = (char)te->index;
-
- /* also set active material */
- ob->actcol = tep->index + 1;
- }
- else if (tep->flag & TE_ACTIVE) { // this is active material
- if (ma->texact == te->index) {
- return OL_DRAWSEL_NORMAL;
- }
- }
- }
-
- if (set != OL_SETSEL_NONE) {
- WM_event_add_notifier(C, NC_TEXTURE, NULL);
- }
-
- /* no active object */
- return OL_DRAWSEL_NONE;
-}
-
-
static eOLDrawState tree_element_active_lamp(
bContext *UNUSED(C), Scene *UNUSED(scene), ViewLayer *view_layer, SpaceOops *soops,
TreeElement *te, const eOLSetState set)
@@ -575,7 +488,7 @@ static eOLDrawState tree_element_active_ebone(
if (set != OL_SETSEL_NONE) {
if (set == OL_SETSEL_NORMAL) {
if (!(ebone->flag & BONE_HIDDEN_A)) {
- ED_armature_deselect_all(obedit);
+ ED_armature_edit_deselect_all(obedit);
tree_element_active_ebone__sel(C, obedit, arm, ebone, true);
status = OL_DRAWSEL_NORMAL;
}
@@ -827,8 +740,6 @@ eOLDrawState tree_element_active(bContext *C, Scene *scene, ViewLayer *view_laye
return tree_element_active_world(C, scene, view_layer, soops, te, set);
case ID_LA:
return tree_element_active_lamp(C, scene, view_layer, soops, te, set);
- case ID_TE:
- return tree_element_active_texture(C, scene, view_layer, soops, te, set);
case ID_TXT:
return tree_element_active_text(C, scene, view_layer, soops, te, set);
case ID_CA:
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 735e2b5a37a..89c0712c217 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -196,19 +196,7 @@ static void unlink_texture_cb(
MTex **mtex = NULL;
int a;
- if (GS(tsep->id->name) == ID_MA) {
- Material *ma = (Material *)tsep->id;
- mtex = ma->mtex;
- }
- else if (GS(tsep->id->name) == ID_LA) {
- Lamp *la = (Lamp *)tsep->id;
- mtex = la->mtex;
- }
- else if (GS(tsep->id->name) == ID_WO) {
- World *wrld = (World *)tsep->id;
- mtex = wrld->mtex;
- }
- else if (GS(tsep->id->name) == ID_LS) {
+ if (GS(tsep->id->name) == ID_LS) {
FreestyleLineStyle *ls = (FreestyleLineStyle *)tsep->id;
mtex = ls->mtex;
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 9f44b5bfc02..2fbb7964661 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -409,11 +409,6 @@ 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->gpd, te, 0, 0);
-
-#ifdef WITH_FREESTYLE
- if (STREQ(sce->view_render->engine_id, RE_engine_id_BLENDER_RENDER) && (sce->r.mode & R_EDGE_FRS))
- outliner_add_line_styles(soops, lb, sce, te);
-#endif
}
TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *customdata)
@@ -759,14 +754,9 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_MA:
{
Material *ma = (Material *)id;
- int a;
if (outliner_animdata_test(ma->adt))
outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0);
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a);
- }
break;
}
case ID_TE:
@@ -800,14 +790,9 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_LA:
{
Lamp *la = (Lamp *)id;
- int a;
if (outliner_animdata_test(la->adt))
outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0);
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a);
- }
break;
}
case ID_SPK:
@@ -829,14 +814,9 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
case ID_WO:
{
World *wrld = (World *)id;
- int a;
if (outliner_animdata_test(wrld->adt))
outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0);
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a);
- }
break;
}
case ID_KE:
@@ -2075,7 +2055,7 @@ static bool outliner_element_visible_get(ViewLayer *view_layer, TreeElement *te,
}
}
else if (te->parent != NULL &&
- TREESTORE(te->parent)->type == 0 && te->parent->idcode == ID_OB)
+ TREESTORE(te->parent)->type == 0 && te->parent->idcode == ID_OB)
{
if (exclude_filter & SO_FILTER_NO_OB_CONTENT) {
return false;
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 0b6bacfbe68..caa3ba593fb 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -690,7 +690,7 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, sequencer_add_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, sequencer_add_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 8e5863fd514..6f88a3481b5 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -919,8 +919,8 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int
recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f;
BKE_sequencer_new_render_data(
- bmain->eval_ctx, bmain, scene,
- rectx, recty, proxy_size,
+ bmain, scene,
+ rectx, recty, proxy_size, false,
&context);
context.view_id = BKE_scene_multiview_view_id_get(&scene->r, viewname);
@@ -1454,7 +1454,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
/* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not,
* for now just disable drawing since the strip frame will likely be offset */
- //if (sc->mode == SC_MODE_MASKEDIT) {
+ // if (sc->mode == SC_MODE_MASKEDIT)
if (0 && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
Mask *mask = BKE_sequencer_mask_get(scene);
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 9a0578fe220..e200dffa308 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -71,7 +71,6 @@
#include "UI_view2d.h"
#include "UI_interface.h"
-
/* own include */
#include "sequencer_intern.h"
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 7ce2f73cbef..de7c46cc02c 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -36,6 +36,7 @@
/* internal exports only */
+struct Depsgraph;
struct Sequence;
struct bContext;
struct rctf;
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index da16ac5acaa..a8344a1fbd0 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -53,6 +53,9 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_message.h"
+
+#include "RNA_access.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -533,6 +536,46 @@ static void sequencer_main_region_listener(
}
}
+static void sequencer_main_region_message_subscribe(
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *UNUSED(workspace), struct Scene *scene,
+ struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ PointerRNA ptr;
+ RNA_pointer_create(&screen->id, &RNA_SpaceSequenceEditor, sa->spacedata.first, &ptr);
+
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ /* Timeline depends on scene properties. */
+ {
+ bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
+ extern PropertyRNA rna_Scene_frame_start;
+ extern PropertyRNA rna_Scene_frame_end;
+ extern PropertyRNA rna_Scene_frame_preview_start;
+ extern PropertyRNA rna_Scene_frame_preview_end;
+ extern PropertyRNA rna_Scene_use_preview_range;
+ extern PropertyRNA rna_Scene_frame_current;
+ const PropertyRNA *props[] = {
+ use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
+ use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
+ &rna_Scene_use_preview_range,
+ &rna_Scene_frame_current,
+ };
+
+ PointerRNA idptr;
+ RNA_id_pointer_create(&scene->id, &idptr);
+
+ for (int i = 0; i < ARRAY_SIZE(props); i++) {
+ WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
+ }
+ }
+}
+
/* *********************** header region ************************ */
/* add handlers, stuff you only do once or on area/region changes */
static void sequencer_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
@@ -743,6 +786,7 @@ void ED_spacetype_sequencer(void)
art->init = sequencer_main_region_init;
art->draw = sequencer_main_region_draw;
art->listener = sequencer_main_region_listener;
+ art->message_subscribe = sequencer_main_region_message_subscribe;
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_FRAMES | ED_KEYMAP_ANIMATION;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 4f332c09ce2..2ce699aa6e2 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -2063,6 +2063,9 @@ void TEXT_OT_delete(wmOperatorType *ot)
ot->exec = text_delete_exec;
ot->poll = text_edit_poll;
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+
/* properties */
RNA_def_enum(ot->srna, "type", delete_type_items, DEL_NEXT_CHAR, "Type", "Which part of the text to delete");
}
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
deleted file mode 100644
index 42027f10fe6..00000000000
--- a/source/blender/editors/space_time/space_time.c
+++ /dev/null
@@ -1,861 +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) 2008 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_time/space_time.c
- * \ingroup sptime
- */
-
-
-#include <string.h>
-#include <stdio.h>
-
-#include "DNA_cachefile_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_gpencil_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_dlrbTree.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_constraint.h"
-#include "BKE_context.h"
-#include "BKE_main.h"
-#include "BKE_modifier.h"
-#include "BKE_screen.h"
-#include "BKE_pointcache.h"
-
-#include "ED_anim_api.h"
-#include "ED_keyframes_draw.h"
-#include "ED_screen.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-#include "WM_message.h"
-
-#include "RNA_access.h"
-
-#include "BIF_gl.h"
-
-#include "UI_resources.h"
-#include "UI_view2d.h"
-#include "UI_interface.h"
-
-#include "ED_space_api.h"
-#include "ED_markers.h"
-
-#include "GPU_immediate.h"
-#include "GPU_matrix.h"
-
-#include "time_intern.h"
-
-/* ************************ main time area region *********************** */
-
-static void time_draw_sfra_efra(Scene *scene, View2D *v2d)
-{
- /* draw darkened area outside of active timeline
- * frame range used is preview range or scene range
- */
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
-
- if (PSFRA < PEFRA) {
- immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
- immRectf(pos, (float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
- }
- else {
- immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
- }
-
- glDisable(GL_BLEND);
-
- /* thin lines where the actual frames are */
- immUniformThemeColorShade(TH_BACK, -60);
-
- immBegin(GWN_PRIM_LINES, 4);
-
- immVertex2f(pos, (float)PSFRA, v2d->cur.ymin);
- immVertex2f(pos, (float)PSFRA, v2d->cur.ymax);
-
- immVertex2f(pos, (float)PEFRA, v2d->cur.ymin);
- immVertex2f(pos, (float)PEFRA, v2d->cur.ymax);
-
- immEnd();
- immUnbindProgram();
-}
-
-static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
-{
- PTCacheID *pid;
- ListBase pidlist;
- const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
- float yoffs = 0.f;
-
- if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob))
- return;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- /* iterate over pointcaches on the active object,
- * add spacetimecache and vertex array for each */
- for (pid = pidlist.first; pid; pid = pid->next) {
- float col[4];
-
- switch (pid->type) {
- case PTCACHE_TYPE_SOFTBODY:
- if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue;
- break;
- case PTCACHE_TYPE_PARTICLES:
- if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue;
- break;
- case PTCACHE_TYPE_CLOTH:
- if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue;
- break;
- case PTCACHE_TYPE_SMOKE_DOMAIN:
- case PTCACHE_TYPE_SMOKE_HIGHRES:
- if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue;
- break;
- case PTCACHE_TYPE_DYNAMICPAINT:
- if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue;
- break;
- case PTCACHE_TYPE_RIGIDBODY:
- if (!(stime->cache_display & TIME_CACHE_RIGIDBODY)) continue;
- break;
- }
-
- if (pid->cache->cached_frames == NULL)
- continue;
-
- gpuPushMatrix();
- gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT + yoffs);
- gpuScale2f(1.0, cache_draw_height);
-
- switch (pid->type) {
- case PTCACHE_TYPE_SOFTBODY:
- col[0] = 1.0; col[1] = 0.4; col[2] = 0.02;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_PARTICLES:
- col[0] = 1.0; col[1] = 0.1; col[2] = 0.02;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_CLOTH:
- col[0] = 0.1; col[1] = 0.1; col[2] = 0.75;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_SMOKE_DOMAIN:
- case PTCACHE_TYPE_SMOKE_HIGHRES:
- col[0] = 0.2; col[1] = 0.2; col[2] = 0.2;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_DYNAMICPAINT:
- col[0] = 1.0; col[1] = 0.1; col[2] = 0.75;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_RIGIDBODY:
- col[0] = 1.0; col[1] = 0.6; col[2] = 0.0;
- col[3] = 0.1;
- break;
- default:
- col[0] = 1.0; col[1] = 0.0; col[2] = 1.0;
- col[3] = 0.1;
- BLI_assert(0);
- break;
- }
-
- const int sta = pid->cache->startframe, end = pid->cache->endframe;
- const int len = (end - sta + 1) * 6;
-
- glEnable(GL_BLEND);
-
- immUniformColor4fv(col);
- immRectf(pos, (float)sta, 0.0, (float)end, 1.0);
-
- col[3] = 0.4f;
- if (pid->cache->flag & PTCACHE_BAKED) {
- col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f;
- }
- else if (pid->cache->flag & PTCACHE_OUTDATED) {
- col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f;
- }
-
- immUniformColor4fv(col);
-
- if (len > 0) {
- immBeginAtMost(GWN_PRIM_TRIS, len);
-
- /* draw a quad for each cached frame */
- for (int i = sta; i <= end; i++) {
- if (pid->cache->cached_frames[i - sta]) {
- immVertex2f(pos, (float)i - 0.5f, 0.0f);
- immVertex2f(pos, (float)i - 0.5f, 1.0f);
- immVertex2f(pos, (float)i + 0.5f, 1.0f);
-
- immVertex2f(pos, (float)i - 0.5f, 0.0f);
- immVertex2f(pos, (float)i + 0.5f, 1.0f);
- immVertex2f(pos, (float)i + 0.5f, 0.0f);
- }
- }
-
- immEnd();
- }
-
- glDisable(GL_BLEND);
-
- gpuPopMatrix();
-
- yoffs += cache_draw_height;
- }
-
- immUnbindProgram();
-
- BLI_freelistN(&pidlist);
-}
-
-/* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */
-static ActKeyColumn *time_cfra_find_ak(ActKeyColumn *ak, float cframe)
-{
- ActKeyColumn *akn = NULL;
-
- /* sanity checks */
- if (ak == NULL)
- return NULL;
-
- /* check if this is a match, or whether it is in some subtree */
- if (cframe < ak->cfra)
- akn = time_cfra_find_ak(ak->left, cframe);
- else if (cframe > ak->cfra)
- akn = time_cfra_find_ak(ak->right, cframe);
-
- /* if no match found (or found match), just use the current one */
- if (akn == NULL)
- return ak;
- else
- return akn;
-}
-
-/* helper for time_draw_keyframes() */
-static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel, const unsigned char color[3])
-{
- bDopeSheet ads = {NULL};
- DLRBT_Tree keys;
- ActKeyColumn *ak;
-
- float fac1 = (GS(id->name) == ID_GD) ? 0.8f : 0.6f; /* draw GPencil keys taller, to help distinguish them */
- float fac2 = 1.0f - fac1;
-
- float ymin = v2d->tot.ymin;
- float ymax = v2d->tot.ymax * fac1 + ymin * fac2;
-
- /* init binarytree-list for getting keyframes */
- BLI_dlrbTree_init(&keys);
-
- /* init dopesheet settings */
- if (onlysel)
- ads.filterflag |= ADS_FILTER_ONLYSEL;
-
- /* populate tree with keyframe nodes */
- switch (GS(id->name)) {
- case ID_SCE:
- scene_to_keylist(&ads, (Scene *)id, &keys, NULL);
- break;
- case ID_OB:
- ob_to_keylist(&ads, (Object *)id, &keys, NULL);
- break;
- case ID_GD:
- gpencil_to_keylist(&ads, (bGPdata *)id, &keys);
- break;
- case ID_CF:
- cachefile_to_keylist(&ads, (CacheFile *)id, &keys, NULL);
- break;
- default:
- break;
- }
-
- /* build linked-list for searching */
- BLI_dlrbTree_linkedlist_sync(&keys);
-
- /* start drawing keyframes
- * - we use the binary-search capabilities of the tree to only start from
- * the first visible keyframe (last one can then be easily checked)
- * - draw within a single GL block to be faster
- */
-
- ActKeyColumn *link;
- int max_len = 0;
-
- ak = time_cfra_find_ak(keys.root, v2d->cur.xmin);
-
- for (link = ak; link; link = link->next) {
- max_len++;
- }
-
- if (max_len > 0) {
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformColor3ubv(color);
-
- immBeginAtMost(GWN_PRIM_LINES, max_len * 2);
-
- for (; (ak) && (ak->cfra <= v2d->cur.xmax); ak = ak->next) {
- immVertex2f(pos, ak->cfra, ymin);
- immVertex2f(pos, ak->cfra, ymax);
- }
-
- immEnd();
- immUnbindProgram();
- }
-
- /* free temp stuff */
- BLI_dlrbTree_free(&keys);
-}
-
-static void time_draw_caches_keyframes(Main *bmain, ViewLayer *view_layer, View2D *v2d, bool onlysel, const unsigned char color[3])
-{
- CacheFile *cache_file;
-
- for (cache_file = bmain->cachefiles.first;
- cache_file;
- cache_file = cache_file->id.next)
- {
- cache_file->draw_flag &= ~CACHEFILE_KEYFRAME_DRAWN;
- }
-
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- Object *ob = base->object;
-
- ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache);
-
- if (md) {
- MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
-
- cache_file = mcmd->cache_file;
-
- if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) {
- continue;
- }
-
- cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN;
-
- time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel, color);
- }
-
- for (bConstraint *con = ob->constraints.first; con; con = con->next) {
- if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) {
- continue;
- }
-
- bTransformCacheConstraint *data = con->data;
-
- cache_file = data->cache_file;
-
- if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) {
- continue;
- }
-
- cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN;
-
- time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel, color);
- }
- }
-}
-
-/* draw keyframe lines for timeline */
-static void time_draw_keyframes(const bContext *C, ARegion *ar)
-{
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *ob = CTX_data_active_object(C);
- View2D *v2d = &ar->v2d;
- bool onlysel = ((scene->flag & SCE_KEYS_NO_SELONLY) == 0);
- unsigned char color[3];
-
- /* set this for all keyframe lines once and for all */
- glLineWidth(1.0);
-
- /* draw cache files keyframes (if available) */
- UI_GetThemeColor3ubv(TH_TIME_KEYFRAME, color);
- time_draw_caches_keyframes(CTX_data_main(C), view_layer, v2d, onlysel, color);
-
- /* draw grease pencil keyframes (if available) */
- UI_GetThemeColor3ubv(TH_TIME_GP_KEYFRAME, color);
-
- if (scene->gpd) {
- time_draw_idblock_keyframes(v2d, (ID *)scene->gpd, onlysel, color);
- }
- if (ob && ob->gpd) {
- time_draw_idblock_keyframes(v2d, (ID *)ob->gpd, onlysel, color);
- }
-
- /* draw scene keyframes first
- * - don't try to do this when only drawing active/selected data keyframes,
- * since this can become quite slow
- */
- if (onlysel == 0) {
- /* set draw color */
- UI_GetThemeColorShade3ubv(TH_TIME_KEYFRAME, -50, color);
- time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel, color);
- }
-
- /* draw keyframes from selected objects
- * - only do the active object if in posemode (i.e. showing only keyframes for the bones)
- * OR the onlysel flag was set, which means that only active object's keyframes should
- * be considered
- */
- UI_GetThemeColor3ubv(TH_TIME_KEYFRAME, color);
-
- if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
- /* draw keyframes for active object only */
- time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel, color);
- }
- else {
- bool active_done = false;
-
- /* draw keyframes from all selected objects */
- CTX_DATA_BEGIN (C, Object *, obsel, selected_objects)
- {
- /* last arg is 0, since onlysel doesn't apply here... */
- time_draw_idblock_keyframes(v2d, (ID *)obsel, 0, color);
-
- /* if this object is the active one, set flag so that we don't draw again */
- if (obsel == ob)
- active_done = true;
- }
- CTX_DATA_END;
-
- /* if active object hasn't been done yet, draw it... */
- if (ob && (active_done == 0))
- time_draw_idblock_keyframes(v2d, (ID *)ob, 0, color);
- }
-}
-
-/* ---------------- */
-
-/* editor level listener */
-static void time_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
- WorkSpace *UNUSED(workspace))
-{
-
- /* mainly for updating cache display */
- switch (wmn->category) {
- case NC_OBJECT:
- {
- switch (wmn->data) {
- case ND_BONE_SELECT:
- case ND_BONE_ACTIVE:
- case ND_POINTCACHE:
- case ND_MODIFIER:
- case ND_PARTICLE:
- case ND_KEYS:
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
- break;
- }
- break;
- }
- case NC_SCENE:
- {
- switch (wmn->data) {
- case ND_RENDER_RESULT:
- ED_area_tag_redraw(sa);
- break;
- case ND_OB_ACTIVE:
- case ND_FRAME:
- ED_area_tag_refresh(sa);
- break;
- case ND_FRAME_RANGE:
- {
- ARegion *ar;
- Scene *scene = wmn->reference;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- ar->v2d.tot.xmin = (float)(SFRA - 4);
- ar->v2d.tot.xmax = (float)(EFRA + 4);
- break;
- }
- }
- break;
- }
- }
- break;
- }
- case NC_SPACE:
- {
- switch (wmn->data) {
- case ND_SPACE_CHANGED:
- ED_area_tag_refresh(sa);
- break;
- }
- break;
- }
- case NC_WM:
- {
- switch (wmn->data) {
- case ND_FILEREAD:
- ED_area_tag_refresh(sa);
- break;
- }
- break;
- }
- }
-}
-
-/* ---------------- */
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void time_main_region_init(wmWindowManager *wm, ARegion *ar)
-{
- wmKeyMap *keymap;
-
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-
- /* own keymap */
- keymap = WM_keymap_find(wm->defaultconf, "Timeline", SPACE_TIME, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-}
-
-static void time_main_region_draw(const bContext *C, ARegion *ar)
-{
- /* draw entirely, view changes should be handled here */
- Scene *scene = CTX_data_scene(C);
- SpaceTime *stime = CTX_wm_space_time(C);
- Object *obact = CTX_data_active_object(C);
- View2D *v2d = &ar->v2d;
- View2DGrid *grid;
- View2DScrollers *scrollers;
- int unit, flag = 0;
-
- /* clear and setup matrix */
- UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
-
- UI_view2d_view_ortho(v2d);
-
- /* grid */
- unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS;
- grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
- UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS));
- UI_view2d_grid_free(grid);
-
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
- /* start and end frame */
- time_draw_sfra_efra(scene, v2d);
-
- /* current frame */
- flag = DRAWCFRA_WIDE; /* this is only really needed on frames where there's a keyframe, but this will do... */
- if ((stime->flag & TIME_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS;
- if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX;
- ANIM_draw_cfra(C, v2d, flag);
-
- UI_view2d_view_ortho(v2d);
-
- /* keyframes */
- time_draw_keyframes(C, ar);
-
- /* markers */
- UI_view2d_view_orthoSpecial(ar, v2d, 1);
- ED_markers_draw(C, 0);
-
- /* caches */
- time_draw_cache(stime, obact, scene);
-
- /* callback */
- UI_view2d_view_ortho(v2d);
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
-
- /* reset view matrix */
- UI_view2d_view_restore(C);
-
- /* scrollers */
- scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
- UI_view2d_scrollers_free(scrollers);
-}
-
-static void time_main_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
- wmNotifier *wmn, const Scene *UNUSED(scene))
-{
- /* context changes */
- switch (wmn->category) {
- case NC_SPACE:
- if (wmn->data == ND_SPACE_TIME)
- ED_region_tag_redraw(ar);
- break;
-
- case NC_ANIMATION:
- ED_region_tag_redraw(ar);
- break;
-
- case NC_SCENE:
- switch (wmn->data) {
- case ND_OB_SELECT:
- case ND_OB_ACTIVE:
- case ND_FRAME:
- case ND_FRAME_RANGE:
- case ND_KEYINGSET:
- case ND_RENDER_OPTIONS:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_GPENCIL:
- if (wmn->data == ND_DATA)
- ED_region_tag_redraw(ar);
- break;
- case NC_SCREEN:
- if (ELEM(wmn->data, ND_LAYER)) {
- ED_region_tag_redraw(ar);
- }
- break;
- }
-}
-
-static void time_main_region_message_subscribe(
- const struct bContext *UNUSED(C),
- struct WorkSpace *UNUSED(workspace), struct Scene *scene,
- struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
- struct wmMsgBus *mbus)
-{
- PointerRNA ptr;
- RNA_pointer_create(&screen->id, &RNA_SpaceTimeline, sa->spacedata.first, &ptr);
-
- wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
- .owner = ar,
- .user_data = ar,
- .notify = ED_region_do_msg_notify_tag_redraw,
- };
-
- /* Timeline depends on scene properties. */
- {
- bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
- extern PropertyRNA rna_Scene_frame_start;
- extern PropertyRNA rna_Scene_frame_end;
- extern PropertyRNA rna_Scene_frame_preview_start;
- extern PropertyRNA rna_Scene_frame_preview_end;
- extern PropertyRNA rna_Scene_use_preview_range;
- extern PropertyRNA rna_Scene_frame_current;
- const PropertyRNA *props[] = {
- use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
- use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
- &rna_Scene_use_preview_range,
- &rna_Scene_frame_current,
- };
-
- PointerRNA idptr;
- RNA_id_pointer_create(&scene->id, &idptr);
-
- for (int i = 0; i < ARRAY_SIZE(props); i++) {
- WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
- }
- }
-}
-
-
-/* ************************ header time area region *********************** */
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void time_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
-{
- ED_region_header_init(ar);
-}
-
-static void time_header_region_draw(const bContext *C, ARegion *ar)
-{
- ED_region_header(C, ar);
-}
-
-static void time_header_region_listener(
- bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
- wmNotifier *wmn, const Scene *UNUSED(scene))
-{
- /* context changes */
- switch (wmn->category) {
- case NC_SCREEN:
- {
- if (wmn->data == ND_ANIMPLAY)
- ED_region_tag_redraw(ar);
- break;
- }
- case NC_SCENE:
- {
- switch (wmn->data) {
- case ND_RENDER_RESULT:
- case ND_OB_SELECT:
- case ND_FRAME:
- case ND_FRAME_RANGE:
- case ND_KEYINGSET:
- case ND_RENDER_OPTIONS:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- }
- case NC_SPACE:
- {
- if (wmn->data == ND_SPACE_TIME)
- ED_region_tag_redraw(ar);
- break;
- }
- }
-}
-
-/* ******************** default callbacks for time space ***************** */
-
-static SpaceLink *time_new(const bContext *C)
-{
- Scene *scene = CTX_data_scene(C);
- ARegion *ar;
- SpaceTime *stime;
-
- stime = MEM_callocN(sizeof(SpaceTime), "inittime");
-
- stime->spacetype = SPACE_TIME;
- stime->flag |= TIME_DRAWFRAMES;
-
- /* header */
- ar = MEM_callocN(sizeof(ARegion), "header for time");
-
- BLI_addtail(&stime->regionbase, ar);
- ar->regiontype = RGN_TYPE_HEADER;
- ar->alignment = RGN_ALIGN_BOTTOM;
-
- /* main region */
- ar = MEM_callocN(sizeof(ARegion), "main region for time");
-
- BLI_addtail(&stime->regionbase, ar);
- ar->regiontype = RGN_TYPE_WINDOW;
-
- ar->v2d.tot.xmin = (float)(SFRA - 4);
- ar->v2d.tot.ymin = 0.0f;
- ar->v2d.tot.xmax = (float)(EFRA + 4);
- ar->v2d.tot.ymax = 50.0f;
-
- ar->v2d.cur = ar->v2d.tot;
-
- ar->v2d.min[0] = 1.0f;
- ar->v2d.min[1] = 50.0f;
-
- ar->v2d.max[0] = MAXFRAMEF;
- ar->v2d.max[1] = 50.0;
-
- ar->v2d.minzoom = 0.1f;
- ar->v2d.maxzoom = 10.0;
-
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
- ar->v2d.keepofs |= V2D_LOCKOFS_Y;
- ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
-
-
- return (SpaceLink *)stime;
-}
-
-/* spacetype; init callback in ED_area_initialize() */
-/* init is called to (re)initialize an existing editor (file read, screen changes) */
-/* validate spacedata, add own area level handlers */
-static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
-{
- SpaceTime *stime = (SpaceTime *)sa->spacedata.first;
-
- /* enable all cache display */
- stime->cache_display |= TIME_CACHE_DISPLAY;
- stime->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES);
- stime->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT);
- stime->cache_display |= TIME_CACHE_RIGIDBODY;
-}
-
-static SpaceLink *time_duplicate(SpaceLink *sl)
-{
- SpaceTime *stime = (SpaceTime *)sl;
- SpaceTime *stimen = MEM_dupallocN(stime);
-
- BLI_listbase_clear(&stimen->caches);
-
- return (SpaceLink *)stimen;
-}
-
-/* only called once, from space_api/spacetypes.c */
-/* it defines all callbacks to maintain spaces */
-void ED_spacetype_time(void)
-{
- SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time");
- ARegionType *art;
-
- st->spaceid = SPACE_TIME;
- strncpy(st->name, "Timeline", BKE_ST_MAXNAME);
-
- st->new = time_new;
- st->init = time_init;
- st->duplicate = time_duplicate;
- st->operatortypes = time_operatortypes;
- st->keymap = NULL;
- st->listener = time_listener;
-
- /* regions: main window */
- art = MEM_callocN(sizeof(ARegionType), "spacetype time region");
- art->regionid = RGN_TYPE_WINDOW;
- art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
-
- art->init = time_main_region_init;
- art->draw = time_main_region_draw;
- art->listener = time_main_region_listener;
- art->message_subscribe = time_main_region_message_subscribe;
- art->keymap = time_keymap;
- art->lock = 1; /* Due to pointcache, see T4960. */
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: header */
- art = MEM_callocN(sizeof(ARegionType), "spacetype time region");
- art->regionid = RGN_TYPE_HEADER;
- art->prefsizey = HEADERY;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
-
- art->init = time_header_region_init;
- art->draw = time_header_region_draw;
- art->listener = time_header_region_listener;
- BLI_addhead(&st->regiontypes, art);
-
- BKE_spacetype_register(st);
-}
diff --git a/source/blender/editors/space_time/time_intern.h b/source/blender/editors/space_time/time_intern.h
deleted file mode 100644
index ced36b2ac2d..00000000000
--- a/source/blender/editors/space_time/time_intern.h
+++ /dev/null
@@ -1,43 +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) 2008 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_time/time_intern.h
- * \ingroup sptime
- */
-
-
-#ifndef __TIME_INTERN_H__
-#define __TIME_INTERN_H__
-
-/* internal exports only */
-
-
-/* time_ops.c */
-void time_operatortypes(void);
-void time_keymap(struct wmKeyConfig *keyconf);
-
-#endif /* __TIME_INTERN_H__ */
-
diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c
deleted file mode 100644
index 872793128f0..00000000000
--- a/source/blender/editors/space_time/time_ops.c
+++ /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) 2008 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_time/time_ops.c
- * \ingroup sptime
- */
-
-
-#include <stdlib.h>
-#include <math.h>
-
-#include "DNA_scene_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_context.h"
-
-#include "ED_anim_api.h"
-#include "ED_screen.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "time_intern.h"
-
-/* ****************** Start/End Frame Operators *******************************/
-static int time_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene = CTX_data_scene(C);
- int frame;
-
- if (scene == NULL)
- return OPERATOR_CANCELLED;
-
- frame = CFRA;
-
- /* if Preview Range is defined, set the 'start' frame for that */
- if (PRVRANGEON)
- scene->r.psfra = frame;
- else
- scene->r.sfra = frame;
-
- if (PEFRA < frame) {
- if (PRVRANGEON)
- scene->r.pefra = frame;
- else
- scene->r.efra = frame;
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
- return OPERATOR_FINISHED;
-}
-
-static void TIME_OT_start_frame_set(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Set Start Frame";
- ot->idname = "TIME_OT_start_frame_set";
- ot->description = "Set the start frame";
-
- /* api callbacks */
- ot->exec = time_set_sfra_exec;
- ot->poll = ED_operator_timeline_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-
-static int time_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene = CTX_data_scene(C);
- int frame;
-
- if (scene == NULL)
- return OPERATOR_CANCELLED;
-
- frame = CFRA;
-
- /* if Preview Range is defined, set the 'end' frame for that */
- if (PRVRANGEON)
- scene->r.pefra = frame;
- else
- scene->r.efra = frame;
-
- if (PSFRA > frame) {
- if (PRVRANGEON)
- scene->r.psfra = frame;
- else
- scene->r.sfra = frame;
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
- return OPERATOR_FINISHED;
-}
-
-static void TIME_OT_end_frame_set(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Set End Frame";
- ot->idname = "TIME_OT_end_frame_set";
- ot->description = "Set the end frame";
-
- /* api callbacks */
- ot->exec = time_set_efra_exec;
- ot->poll = ED_operator_timeline_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-/* ************************ View All Operator *******************************/
-
-static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene = CTX_data_scene(C);
- ARegion *ar = CTX_wm_region(C);
-
- if (ELEM(NULL, scene, ar))
- return OPERATOR_CANCELLED;
-
- View2D *v2d = &ar->v2d;
-
- /* set extents of view to start/end frames (Preview Range too) */
- v2d->cur.xmin = (float)PSFRA;
- v2d->cur.xmax = (float)PEFRA;
-
- /* we need an extra "buffer" factor on either side so that the endpoints are visible */
- const float extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
- v2d->cur.xmin -= extra;
- v2d->cur.xmax += extra;
-
- /* this only affects this TimeLine instance, so just force redraw of this region */
- ED_region_tag_redraw(ar);
-
- return OPERATOR_FINISHED;
-}
-
-static void TIME_OT_view_all(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "View All";
- ot->idname = "TIME_OT_view_all";
- ot->description = "Show the entire playable frame range";
-
- /* api callbacks */
- ot->exec = time_view_all_exec;
- ot->poll = ED_operator_timeline_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-/* ************************ View Frame Operator *******************************/
-
-static int time_view_frame_exec(bContext *C, wmOperator *op)
-{
- const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
- ANIM_center_frame(C, smooth_viewtx);
-
- return OPERATOR_FINISHED;
-}
-
-static void TIME_OT_view_frame(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "View Frame";
- ot->idname = "TIME_OT_view_frame";
- ot->description = "Reset viewable area to show range around current frame";
-
- /* api callbacks */
- ot->exec = time_view_frame_exec;
- ot->poll = ED_operator_timeline_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-/* ************************** registration **********************************/
-
-void time_operatortypes(void)
-{
- WM_operatortype_append(TIME_OT_start_frame_set);
- WM_operatortype_append(TIME_OT_end_frame_set);
- WM_operatortype_append(TIME_OT_view_all);
- WM_operatortype_append(TIME_OT_view_frame);
-}
-
-void time_keymap(wmKeyConfig *keyconf)
-{
- wmKeyMap *keymap = WM_keymap_find(keyconf, "Timeline", SPACE_TIME, 0);
-
- WM_keymap_add_item(keymap, "TIME_OT_start_frame_set", SKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "TIME_OT_end_frame_set", EKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "TIME_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
-#ifdef WITH_INPUT_NDOF
- WM_keymap_add_item(keymap, "TIME_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
-#endif
- WM_keymap_add_item(keymap, "TIME_OT_view_frame", PAD0, KM_PRESS, 0, 0);
-}
-
diff --git a/source/blender/editors/space_time/CMakeLists.txt b/source/blender/editors/space_topbar/CMakeLists.txt
index 90af405eaa8..9559c28de0a 100644
--- a/source/blender/editors/space_time/CMakeLists.txt
+++ b/source/blender/editors/space_topbar/CMakeLists.txt
@@ -22,6 +22,8 @@ set(INC
../include
../../blenkernel
../../blenlib
+ ../../blenloader
+ ../../blentranslation
../../gpu
../../makesdna
../../makesrna
@@ -35,12 +37,9 @@ set(INC_SYS
)
set(SRC
- space_time.c
- time_ops.c
-
- time_intern.h
+ space_topbar.c
)
add_definitions(${GL_DEFINITIONS})
-blender_add_lib(bf_editor_space_time "${SRC}" "${INC}" "${INC_SYS}")
+blender_add_lib(bf_editor_space_topbar "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
new file mode 100644
index 00000000000..35858a927fe
--- /dev/null
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -0,0 +1,265 @@
+/*
+ * ***** 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) 2017 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_topbar/space_topbar.c
+ * \ingroup sptopbar
+ */
+
+
+#include <string.h>
+#include <stdio.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+
+#include "BLO_readfile.h"
+#include "BLT_translation.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_screen.h"
+
+#include "ED_screen.h"
+#include "ED_space_api.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+#include "UI_view2d.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+
+/* ******************** default callbacks for topbar space ***************** */
+
+static SpaceLink *topbar_new(const bContext *UNUSED(C))
+{
+ ARegion *ar;
+ SpaceTopBar *stopbar;
+
+ stopbar = MEM_callocN(sizeof(*stopbar), "init topbar");
+ stopbar->spacetype = SPACE_TOPBAR;
+
+ /* header */
+ ar = MEM_callocN(sizeof(ARegion), "left aligned header for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_TOP;
+ ar = MEM_callocN(sizeof(ARegion), "right aligned header for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_RIGHT | RGN_SPLIT_PREV;
+
+ /* main regions */
+ ar = MEM_callocN(sizeof(ARegion), "left aligned main region for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_WINDOW;
+ ar->alignment = RGN_ALIGN_LEFT;
+ ar = MEM_callocN(sizeof(ARegion), "right aligned main region for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_WINDOW;
+ ar->alignment = RGN_ALIGN_RIGHT;
+ ar = MEM_callocN(sizeof(ARegion), "center main region for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_WINDOW;
+
+ return (SpaceLink *)stopbar;
+}
+
+/* not spacelink itself */
+static void topbar_free(SpaceLink *UNUSED(sl))
+{
+
+}
+
+
+/* spacetype; init callback */
+static void topbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+{
+
+}
+
+static SpaceLink *topbar_duplicate(SpaceLink *sl)
+{
+ SpaceTopBar *stopbarn = MEM_dupallocN(sl);
+
+ /* clear or remove stuff from old */
+
+ return (SpaceLink *)stopbarn;
+}
+
+
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void topbar_main_region_init(wmWindowManager *wm, ARegion *region)
+{
+ wmKeyMap *keymap;
+
+ /* force delayed UI_view2d_region_reinit call */
+ if (ELEM(region->alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
+ region->flag |= RGN_FLAG_DYNAMIC_SIZE;
+ }
+ UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_HEADER, region->winx, region->winy);
+
+ keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0);
+ WM_event_add_keymap_handler(&region->handlers, keymap);
+}
+
+static void topbar_main_region_draw(const bContext *C, ARegion *region)
+{
+ ED_region_header(C, region);
+}
+
+static void topbar_operatortypes(void)
+{
+
+}
+
+static void topbar_keymap(struct wmKeyConfig *UNUSED(keyconf))
+{
+
+}
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void topbar_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
+{
+ if ((ar->alignment & ~RGN_SPLIT_PREV) == RGN_ALIGN_RIGHT) {
+ ar->flag |= RGN_FLAG_DYNAMIC_SIZE;
+ }
+ ED_region_header_init(ar);
+}
+
+static void topbar_header_region_draw(const bContext *C, ARegion *ar)
+{
+ ED_region_header(C, ar);
+}
+
+static void topbar_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmNotifier *wmn, const Scene *UNUSED(scene))
+{
+ /* context changes */
+ switch (wmn->category) {
+ case NC_WM:
+ if (wmn->data == ND_HISTORY)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_SCENE:
+ if (wmn->data == ND_MODE)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_VIEW3D)
+ ED_region_tag_redraw(ar);
+ break;
+ }
+}
+
+static void topbar_header_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
+{
+ /* context changes */
+#if 0
+ switch (wmn->category) {
+ default:
+ break;
+ }
+#endif
+}
+
+static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
+{
+ struct RecentFile *recent;
+ uiLayout *layout = menu->layout;
+ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
+ if (!BLI_listbase_is_empty(&G.recent_files)) {
+ for (recent = G.recent_files.first; (recent); recent = recent->next) {
+ const char *file = BLI_path_basename(recent->filepath);
+ const int icon = BLO_has_bfile_extension(file) ? ICON_FILE_BLEND : ICON_FILE_BACKUP;
+ uiItemStringO(layout, file, icon, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ }
+ }
+ else {
+ uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE);
+ }
+}
+
+static void recent_files_menu_register(void)
+{
+ MenuType *mt;
+
+ mt = MEM_callocN(sizeof(MenuType), "spacetype info menu recent files");
+ strcpy(mt->idname, "TOPBAR_MT_file_open_recent");
+ strcpy(mt->label, N_("Open Recent..."));
+ strcpy(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ mt->draw = recent_files_menu_draw;
+ WM_menutype_add(mt);
+}
+
+
+/* only called once, from space/spacetypes.c */
+void ED_spacetype_topbar(void)
+{
+ SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype topbar");
+ ARegionType *art;
+
+ st->spaceid = SPACE_TOPBAR;
+ strncpy(st->name, "Top Bar", BKE_ST_MAXNAME);
+
+ st->new = topbar_new;
+ st->free = topbar_free;
+ st->init = topbar_init;
+ st->duplicate = topbar_duplicate;
+ st->operatortypes = topbar_operatortypes;
+ st->keymap = topbar_keymap;
+
+ /* regions: main window */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype topbar main region");
+ art->regionid = RGN_TYPE_WINDOW;
+ art->init = topbar_main_region_init;
+ art->draw = topbar_main_region_draw;
+ art->listener = topbar_main_region_listener;
+ art->prefsizex = UI_UNIT_X * 5; /* Mainly to avoid glitches */
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
+
+ BLI_addhead(&st->regiontypes, art);
+
+ /* regions: header */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype topbar header region");
+ art->regionid = RGN_TYPE_HEADER;
+ art->prefsizey = HEADERY;
+ art->prefsizex = UI_UNIT_X * 5; /* Mainly to avoid glitches */
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
+ art->listener = topbar_header_listener;
+ art->init = topbar_header_region_init;
+ art->draw = topbar_header_region_draw;
+
+ BLI_addhead(&st->regiontypes, art);
+
+ recent_files_menu_register();
+
+ BKE_spacetype_register(st);
+}
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index d148ef3c6fe..f8e38587117 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -43,11 +43,7 @@ set(INC_SYS
)
set(SRC
- drawanimviz.c
- drawarmature.c
- drawmesh.c
drawobject.c
- drawsimdebug.c
drawvolume.c
space_view3d.c
view3d_buttons.c
@@ -84,13 +80,6 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
-if(WITH_GAMEENGINE)
- list(APPEND INC
- ../../../gameengine/BlenderRoutines
- )
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
add_definitions(${GL_DEFINITIONS})
if(WITH_INTERNATIONAL)
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c
deleted file mode 100644
index 9fa85b55362..00000000000
--- a/source/blender/editors/space_view3d/drawanimviz.c
+++ /dev/null
@@ -1,438 +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 by the Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Joshua Leung
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_view3d/drawanimviz.c
- * \ingroup spview3d
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "BLI_sys_types.h"
-
-#include "DNA_anim_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_object_types.h"
-
-#include "BLI_math.h"
-#include "BLI_dlrbTree.h"
-
-#include "BKE_animsys.h"
-#include "BKE_action.h"
-
-#include "GPU_immediate.h"
-#include "GPU_matrix.h"
-
-#include "ED_keyframes_draw.h"
-
-
-#include "UI_resources.h"
-
-#include "view3d_intern.h"
-
-/* ************************************ Motion Paths ************************************* */
-
-/* TODO:
- * - options to draw paths with lines
- * - include support for editing the path verts */
-
-/* Set up drawing environment for drawing motion paths */
-void draw_motion_paths_init(View3D *v3d, ARegion *ar)
-{
- RegionView3D *rv3d = ar->regiondata;
-
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- gpuPushMatrix();
- gpuLoadMatrix(rv3d->viewmat);
-}
-
-/* set color
- * - more intense for active/selected bones, less intense for unselected bones
- * - black for before current frame, green for current frame, blue for after current frame
- * - intensity decreases as distance from current frame increases
- *
- * If the user select custom color, the color is replaced for the color selected in UI panel
- * - 75% Darker color is used for previous frames
- * - 50% Darker color for current frame
- * - User selected color for next frames
- */
-static void set_motion_path_color(Scene *scene, bMotionPath *mpath, int i, short sel, int sfra, int efra,
- float prev_color[3], float frame_color[3], float next_color[3], unsigned color)
-{
- int frame = sfra + i;
- int blend_base = (abs(frame - CFRA) == 1) ? TH_CFRAME : TH_BACK; /* "bleed" cframe color to ease color blending */
- unsigned char ubcolor[3];
-
-#define SET_INTENSITY(A, B, C, min, max) (((1.0f - ((C - B) / (C - A))) * (max - min)) + min)
- float intensity; /* how faint */
-
- if (frame < CFRA) {
- if (mpath->flag & MOTIONPATH_FLAG_CUSTOM) {
- /* Custom color: previous frames color is darker than current frame */
- rgb_float_to_uchar(ubcolor, prev_color);
- }
- else {
- /* black - before cfra */
- if (sel) {
- /* intensity = 0.5f; */
- intensity = SET_INTENSITY(sfra, i, CFRA, 0.25f, 0.75f);
- }
- else {
- /* intensity = 0.8f; */
- intensity = SET_INTENSITY(sfra, i, CFRA, 0.68f, 0.92f);
- }
-
- UI_GetThemeColorBlend3ubv(TH_WIRE, blend_base, intensity, ubcolor);
- }
- }
- else if (frame > CFRA) {
- if (mpath->flag & MOTIONPATH_FLAG_CUSTOM) {
- /* Custom color: next frames color is equal to user selected color */
- rgb_float_to_uchar(ubcolor, next_color);
- }
- else {
- /* blue - after cfra */
- if (sel) {
- /* intensity = 0.5f; */
- intensity = SET_INTENSITY(CFRA, i, efra, 0.25f, 0.75f);
- }
- else {
- /* intensity = 0.8f; */
- intensity = SET_INTENSITY(CFRA, i, efra, 0.68f, 0.92f);
- }
-
- UI_GetThemeColorBlend3ubv(TH_BONE_POSE, blend_base, intensity, ubcolor);
- }
- }
- else {
- if (mpath->flag & MOTIONPATH_FLAG_CUSTOM) {
- /* Custom color: current frame color is slightly darker than user selected color */
- rgb_float_to_uchar(ubcolor, frame_color);
- }
- else {
- /* green - on cfra */
- if (sel) {
- intensity = 0.5f;
- }
- else {
- intensity = 0.99f;
- }
- UI_GetThemeColorBlendShade3ubv(TH_CFRAME, TH_BACK, intensity, 10, ubcolor);
- }
- }
-
- immAttrib3ubv(color, ubcolor);
-
-#undef SET_INTENSITY
-}
-
-/* Draw the given motion path for an Object or a Bone
- * - assumes that the viewport has already been initialized properly
- * i.e. draw_motion_paths_init() has been called
- */
-void draw_motion_path_instance(Scene *scene,
- Object *ob, bPoseChannel *pchan, bAnimVizSettings *avs, bMotionPath *mpath)
-{
- //RegionView3D *rv3d = ar->regiondata;
- bMotionPathVert *mpv, *mpv_start;
- int i, stepsize = avs->path_step;
- int sfra, efra, sind, len;
- float prev_color[3];
- float frame_color[3];
- float next_color[3];
-
- /* Custom color - Previous frames: color is darker than current frame */
- prev_color[0] = mpath->color[0] * 0.25f;
- prev_color[1] = mpath->color[1] * 0.25f;
- prev_color[2] = mpath->color[2] * 0.25f;
-
- /* Custom color - Current frame: color is slightly darker than user selected color */
- frame_color[0] = mpath->color[0] * 0.50f;
- frame_color[1] = mpath->color[1] * 0.50f;
- frame_color[2] = mpath->color[2] * 0.50f;
-
- /* Custom color - Next frames: color is equal to user selection */
- next_color[0] = mpath->color[0];
- next_color[1] = mpath->color[1];
- next_color[2] = mpath->color[2];
-
- /* Save old line width */
- GLfloat old_width;
- glGetFloatv(GL_LINE_WIDTH, &old_width);
-
- /* get frame ranges */
- if (avs->path_type == MOTIONPATH_TYPE_ACFRA) {
- /* With "Around Current", we only choose frames from around
- * the current frame to draw.
- */
- sfra = CFRA - avs->path_bc;
- efra = CFRA + avs->path_ac;
- }
- else {
- /* Use the current display range */
- sfra = avs->path_sf;
- efra = avs->path_ef;
- }
-
- /* no matter what, we can only show what is in the cache and no more
- * - abort if whole range is past ends of path
- * - otherwise clamp endpoints to extents of path
- */
- if (sfra < mpath->start_frame) {
- /* start clamp */
- sfra = mpath->start_frame;
- }
- if (efra > mpath->end_frame) {
- /* end clamp */
- efra = mpath->end_frame;
- }
-
- if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) {
- /* whole path is out of bounds */
- return;
- }
-
- len = efra - sfra;
-
- if ((len <= 0) || (mpath->points == NULL)) {
- return;
- }
-
- /* get pointers to parts of path */
- sind = sfra - mpath->start_frame;
- mpv_start = (mpath->points + sind);
-
- /* draw curve-line of path */
- /* Draw lines only if line drawing option is enabled */
- if (mpath->flag & MOTIONPATH_FLAG_LINES) {
- /* set line thickness */
- glLineWidth(mpath->line_thickness);
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR);
-
- immBegin(GWN_PRIM_LINE_STRIP, len);
-
- for (i = 0, mpv = mpv_start; i < len; i++, mpv++) {
- short sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT);
-
- /* Set color */
- set_motion_path_color(scene, mpath, i, sel, sfra, efra, prev_color, frame_color, next_color, color);
-
- /* draw a vertex with this color */
- immVertex3fv(pos, mpv->co);
- }
-
- immEnd();
-
- immUnbindProgram();
-
- /* back to old line thickness */
- glLineWidth(old_width);
- }
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- /* Point must be bigger than line thickness */
- glPointSize(mpath->line_thickness + 1.0);
-
- /* draw little black point at each frame */
- immUniformColor3ub(0, 0, 0);
-
- immBegin(GWN_PRIM_POINTS, len);
-
- for (i = 0, mpv = mpv_start; i < len; i++, mpv++) {
- immVertex3fv(pos, mpv->co);
- }
-
- immEnd();
-
- /* Draw little white dots at each framestep value or replace with custom color */
- if (mpath->flag & MOTIONPATH_FLAG_CUSTOM) {
- immUniformColor3fv(mpath->color);
- }
- else {
- immUniformThemeColor(TH_TEXT_HI);
- }
-
- immBegin(GWN_PRIM_POINTS, (len + stepsize - 1) / stepsize);
-
- for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize) {
- immVertex3fv(pos, mpv->co);
- }
-
- immEnd();
-
- /* Draw big green dot where the current frame is
- * NOTE: this is only done when keyframes are shown, since this adds similar types of clutter
- */
- if ((avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) &&
- (sfra < CFRA) && (CFRA <= efra))
- {
- glPointSize(mpath->line_thickness + 5.0);
- immUniformThemeColor(TH_CFRAME);
-
- immBegin(GWN_PRIM_POINTS, 1);
-
- mpv = mpv_start + (CFRA - sfra);
- immVertex3fv(pos, mpv->co);
-
- immEnd();
- }
-
- immUnbindProgram();
-
- /* XXX, this isn't up to date but probably should be kept so. */
- invert_m4_m4(ob->imat, ob->obmat);
-
- /* Draw frame numbers at each framestep value */
- if (avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) {
- unsigned char col[4];
- UI_GetThemeColor3ubv(TH_TEXT_HI, col);
- col[3] = 255;
-
- for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize) {
- int frame = sfra + i;
- char numstr[32];
- size_t numstr_len;
- float co[3];
-
- /* only draw framenum if several consecutive highlighted points don't occur on same point */
- if (i == 0) {
- numstr_len = sprintf(numstr, " %d", frame);
- mul_v3_m4v3(co, ob->imat, mpv->co);
- view3d_cached_text_draw_add(co, numstr, numstr_len,
- 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
- }
- else if ((i >= stepsize) && (i < len - stepsize)) {
- bMotionPathVert *mpvP = (mpv - stepsize);
- bMotionPathVert *mpvN = (mpv + stepsize);
-
- if ((equals_v3v3(mpv->co, mpvP->co) == 0) || (equals_v3v3(mpv->co, mpvN->co) == 0)) {
- numstr_len = sprintf(numstr, " %d", frame);
- mul_v3_m4v3(co, ob->imat, mpv->co);
- view3d_cached_text_draw_add(co, numstr, numstr_len,
- 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
- }
- }
- }
- }
-
- /* Keyframes - dots and numbers */
- if (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) {
- unsigned char col[4];
-
- AnimData *adt = BKE_animdata_from_id(&ob->id);
- DLRBT_Tree keys;
-
- /* build list of all keyframes in active action for object or pchan */
- BLI_dlrbTree_init(&keys);
-
- if (adt) {
- /* it is assumed that keyframes for bones are all grouped in a single group
- * unless an option is set to always use the whole action
- */
- if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT) == 0) {
- bActionGroup *agrp = BKE_action_group_find_name(adt->action, pchan->name);
-
- if (agrp) {
- agroup_to_keylist(adt, agrp, &keys, NULL);
- BLI_dlrbTree_linkedlist_sync(&keys);
- }
- }
- else {
- action_to_keylist(adt, adt->action, &keys, NULL);
- BLI_dlrbTree_linkedlist_sync(&keys);
- }
- }
-
- /* Draw slightly-larger yellow dots at each keyframe */
- UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col);
- col[3] = 255;
-
- /* point must be bigger than line */
- glPointSize(mpath->line_thickness + 3.0);
-
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor3ubv(col);
-
- immBeginAtMost(GWN_PRIM_POINTS, len);
-
- for (i = 0, mpv = mpv_start; i < len; i++, mpv++) {
- int frame = sfra + i;
- float mframe = (float)(frame);
-
- if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) {
- immVertex3fv(pos, mpv->co);
- }
- }
-
- immEnd();
-
- immUnbindProgram();
-
- /* Draw frame numbers of keyframes */
- if (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) {
- float co[3];
- for (i = 0, mpv = mpv_start; i < len; i++, mpv++) {
- float mframe = (float)(sfra + i);
-
- if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) {
- char numstr[32];
- size_t numstr_len;
-
- numstr_len = sprintf(numstr, " %d", (sfra + i));
- mul_v3_m4v3(co, ob->imat, mpv->co);
- view3d_cached_text_draw_add(co, numstr, numstr_len,
- 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
- }
- }
- }
-
- BLI_dlrbTree_free(&keys);
- }
-}
-
-/* Clean up drawing environment after drawing motion paths */
-void draw_motion_paths_cleanup(View3D *v3d)
-{
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- gpuPopMatrix();
-}
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
deleted file mode 100644
index 77cd64be7c1..00000000000
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ /dev/null
@@ -1,3010 +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) 2005 by the Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_view3d/drawarmature.c
- * \ingroup spview3d
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "DNA_anim_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_object_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_dlrbTree.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_animsys.h"
-#include "BKE_action.h"
-#include "BKE_armature.h"
-#include "BKE_global.h"
-#include "BKE_modifier.h"
-#include "BKE_nla.h"
-#include "BKE_curve.h"
-#include "BKE_context.h"
-
-#include "DEG_depsgraph.h"
-
-#include "BIF_glutil.h"
-
-#include "ED_armature.h"
-#include "ED_keyframes_draw.h"
-
-#include "GPU_basic_shader.h"
-#include "GPU_batch.h"
-#include "GPU_immediate.h"
-#include "GPU_immediate_util.h"
-#include "GPU_matrix.h"
-
-#include "UI_resources.h"
-
-#include "view3d_intern.h"
-
-#include "GPU_select.h"
-
-/* *************** Armature Drawing - Coloring API ***************************** */
-
-/* global here is reset before drawing each bone */
-static ThemeWireColor *bcolor = NULL;
-static float fcolor[4] = {0.0f};
-static bool flat_color;
-
-/* values of colCode for set_pchan_color */
-enum {
- PCHAN_COLOR_NORMAL = 0, /* normal drawing */
- PCHAN_COLOR_SOLID, /* specific case where "solid" color is needed */
- PCHAN_COLOR_CONSTS, /* "constraint" colors (which may/may-not be suppressed) */
-
- PCHAN_COLOR_SPHEREBONE_BASE, /* for the 'stick' of sphere (envelope) bones */
- PCHAN_COLOR_SPHEREBONE_END, /* for the ends of sphere (envelope) bones */
- PCHAN_COLOR_LINEBONE /* for the middle of line-bones */
-};
-
-/* This function sets the color-set for coloring a certain bone */
-static void set_pchan_colorset(Object *ob, bPoseChannel *pchan)
-{
- bPose *pose = (ob) ? ob->pose : NULL;
- bArmature *arm = (ob) ? ob->data : NULL;
- bActionGroup *grp = NULL;
- short color_index = 0;
-
- /* sanity check */
- if (ELEM(NULL, ob, arm, pose, pchan)) {
- bcolor = NULL;
- return;
- }
-
- /* only try to set custom color if enabled for armature */
- if (arm->flag & ARM_COL_CUSTOM) {
- /* currently, a bone can only use a custom color set if it's group (if it has one),
- * has been set to use one
- */
- if (pchan->agrp_index) {
- grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1));
- if (grp)
- color_index = grp->customCol;
- }
- }
-
- /* bcolor is a pointer to the color set to use. If NULL, then the default
- * color set (based on the theme colors for 3d-view) is used.
- */
- if (color_index > 0) {
- bTheme *btheme = UI_GetTheme();
- bcolor = &btheme->tarm[(color_index - 1)];
- }
- else if (color_index == -1) {
- /* use the group's own custom color set (grp is always != NULL here) */
- bcolor = &grp->cs;
- }
- else {
- bcolor = NULL;
- }
-}
-
-/* This function is for brightening/darkening a given color (like UI_GetThemeColorShade3ubv()) */
-static void cp_shade_color3ub(unsigned char cp[3], const int offset)
-{
- int r, g, b;
-
- r = offset + (int) cp[0];
- CLAMP(r, 0, 255);
- g = offset + (int) cp[1];
- CLAMP(g, 0, 255);
- b = offset + (int) cp[2];
- CLAMP(b, 0, 255);
-
- cp[0] = r;
- cp[1] = g;
- cp[2] = b;
-}
-
-/* This function sets the gl-color for coloring a certain bone (based on bcolor) */
-static bool set_pchan_color(short colCode, int boneflag, short constflag)
-{
- switch (colCode) {
- case PCHAN_COLOR_NORMAL:
- {
- if (bcolor) {
- unsigned char cp[4] = {255};
-
- if (boneflag & BONE_DRAW_ACTIVE) {
- copy_v3_v3_char((char *)cp, bcolor->active);
- if (!(boneflag & BONE_SELECTED)) {
- cp_shade_color3ub(cp, -80);
- }
- }
- else if (boneflag & BONE_SELECTED) {
- copy_v3_v3_char((char *)cp, bcolor->select);
- }
- else {
- /* a bit darker than solid */
- copy_v3_v3_char((char *)cp, bcolor->solid);
- cp_shade_color3ub(cp, -50);
- }
-
- rgb_uchar_to_float(fcolor, cp);
- }
- else {
- if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) {
- UI_GetThemeColor4fv(TH_BONE_POSE_ACTIVE, fcolor);
- }
- else if (boneflag & BONE_DRAW_ACTIVE) {
- UI_GetThemeColorBlendShade4fv(TH_WIRE, TH_BONE_POSE, 0.15f, 0, fcolor);
- }
- else if (boneflag & BONE_SELECTED) {
- UI_GetThemeColor4fv(TH_BONE_POSE, fcolor);
- }
- else {
- UI_GetThemeColor4fv(TH_WIRE, fcolor);
- }
- }
-
- return true;
- }
- case PCHAN_COLOR_SOLID:
- {
- if (bcolor) {
- rgb_uchar_to_float(fcolor, (unsigned char *)bcolor->solid);
- }
- else {
- UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
- }
-
- return true;
- }
- case PCHAN_COLOR_CONSTS:
- {
- if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) {
- unsigned char cp[4];
- if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 80);
- else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 80);
- else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 80);
- else if (constflag & PCHAN_HAS_CONST) rgba_char_args_set((char *)cp, 0, 255, 120, 80);
-
- rgba_uchar_to_float(fcolor, cp);
-
- return true;
- }
- return false;
- }
- case PCHAN_COLOR_SPHEREBONE_BASE:
- {
- if (bcolor) {
- unsigned char cp[4] = {255};
-
- if (boneflag & BONE_DRAW_ACTIVE) {
- copy_v3_v3_char((char *)cp, bcolor->active);
- }
- else if (boneflag & BONE_SELECTED) {
- copy_v3_v3_char((char *)cp, bcolor->select);
- }
- else {
- copy_v3_v3_char((char *)cp, bcolor->solid);
- }
-
- rgb_uchar_to_float(fcolor, cp);
- }
- else {
- if (boneflag & BONE_DRAW_ACTIVE) {
- UI_GetThemeColorShade4fv(TH_BONE_POSE, 40, fcolor);
- }
- else if (boneflag & BONE_SELECTED) {
- UI_GetThemeColor4fv(TH_BONE_POSE, fcolor);
- }
- else {
- UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
- }
- }
-
- return true;
- }
- case PCHAN_COLOR_SPHEREBONE_END:
- {
- if (bcolor) {
- unsigned char cp[4] = {255};
-
- if (boneflag & BONE_DRAW_ACTIVE) {
- copy_v3_v3_char((char *)cp, bcolor->active);
- cp_shade_color3ub(cp, 10);
- }
- else if (boneflag & BONE_SELECTED) {
- copy_v3_v3_char((char *)cp, bcolor->select);
- cp_shade_color3ub(cp, -30);
- }
- else {
- copy_v3_v3_char((char *)cp, bcolor->solid);
- cp_shade_color3ub(cp, -30);
- }
-
- rgb_uchar_to_float(fcolor, cp);
- }
- else {
- if (boneflag & BONE_DRAW_ACTIVE) {
- UI_GetThemeColorShade4fv(TH_BONE_POSE, 10, fcolor);
- }
- else if (boneflag & BONE_SELECTED) {
- UI_GetThemeColorShade4fv(TH_BONE_POSE, -30, fcolor);
- }
- else {
- UI_GetThemeColorShade4fv(TH_BONE_SOLID, -30, fcolor);
- }
- }
- break;
- }
- case PCHAN_COLOR_LINEBONE:
- {
- /* inner part in background color or constraint */
- if ((constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS))) {
- unsigned char cp[4];
- if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 255);
- else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 255);
- else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 255);
- else if (constflag & PCHAN_HAS_CONST) rgba_char_args_set((char *)cp, 0, 255, 120, 255);
- else if (constflag) UI_GetThemeColor4ubv(TH_BONE_POSE, cp); /* PCHAN_HAS_ACTION */
-
- rgb_uchar_to_float(fcolor, cp);
- }
- else {
- if (bcolor) {
- const char *cp = bcolor->solid;
- rgb_uchar_to_float(fcolor, (unsigned char *)cp);
- fcolor[3] = 204.f / 255.f;
- }
- else {
- UI_GetThemeColorShade4fv(TH_BACK, -30, fcolor);
- }
- }
-
- return true;
- }
- }
-
- return false;
-}
-
-static void set_ebone_color(const unsigned int boneflag)
-{
- if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) {
- UI_GetThemeColor4fv(TH_EDGE_SELECT, fcolor);
- }
- else if (boneflag & BONE_DRAW_ACTIVE) {
- UI_GetThemeColorBlendShade4fv(TH_WIRE_EDIT, TH_EDGE_SELECT, 0.15f, 0, fcolor);
- }
- else if (boneflag & BONE_SELECTED) {
- UI_GetThemeColorShade4fv(TH_EDGE_SELECT, -20, fcolor);
- }
- else {
- UI_GetThemeColor4fv(TH_WIRE_EDIT, fcolor);
- }
-}
-
-/* *************** Armature drawing, helper calls for parts ******************* */
-
-static void add_solid_flat_triangle(Gwn_VertBuf *vbo, unsigned int *vertex, unsigned int pos, unsigned int nor,
- const float p1[3], const float p2[3], const float p3[3], const float n[3])
-{
- GWN_vertbuf_attr_set(vbo, nor, *vertex, n);
- GWN_vertbuf_attr_set(vbo, pos, (*vertex)++, p1);
- GWN_vertbuf_attr_set(vbo, nor, *vertex, n);
- GWN_vertbuf_attr_set(vbo, pos, (*vertex)++, p2);
- GWN_vertbuf_attr_set(vbo, nor, *vertex, n);
- GWN_vertbuf_attr_set(vbo, pos, (*vertex)++, p3);
-}
-
-/* half the cube, in Y */
-static const float cube_vert[8][3] = {
- {-1.0, 0.0, -1.0},
- {-1.0, 0.0, 1.0},
- {-1.0, 1.0, 1.0},
- {-1.0, 1.0, -1.0},
- { 1.0, 0.0, -1.0},
- { 1.0, 0.0, 1.0},
- { 1.0, 1.0, 1.0},
- { 1.0, 1.0, -1.0},
-};
-
-static const float cube_wire[24] = {
- 0, 1, 1, 2, 2, 3, 3, 0,
- 4, 5, 5, 6, 6, 7, 7, 4,
- 0, 4, 1, 5, 2, 6, 3, 7,
-};
-
-static void drawsolidcube_size(float xsize, float ysize, float zsize)
-{
- static Gwn_VertFormat format = {0};
- static Gwn_VertBuf vbo = {{0}};
- static Gwn_Batch batch = {{0}};
- const float light_vec[3] = {0.0f, 0.0f, 1.0f};
-
- if (format.attrib_ct == 0) {
- unsigned int i = 0;
- float n[3] = {0.0f};
- /* Vertex format */
- unsigned int pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- /* Vertices */
- GWN_vertbuf_init_with_format(&vbo, &format);
- GWN_vertbuf_data_alloc(&vbo, 36);
-
- n[0] = -1.0;
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[0], cube_vert[1], cube_vert[2], n);
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[2], cube_vert[3], cube_vert[0], n);
- n[0] = 0;
- n[1] = -1.0;
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[0], cube_vert[4], cube_vert[5], n);
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[5], cube_vert[1], cube_vert[0], n);
- n[1] = 0;
- n[0] = 1.0;
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[4], cube_vert[7], cube_vert[6], n);
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[6], cube_vert[5], cube_vert[4], n);
- n[0] = 0;
- n[1] = 1.0;
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[7], cube_vert[3], cube_vert[2], n);
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[2], cube_vert[6], cube_vert[7], n);
- n[1] = 0;
- n[2] = 1.0;
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[1], cube_vert[5], cube_vert[6], n);
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[6], cube_vert[2], cube_vert[1], n);
- n[2] = -1.0;
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[7], cube_vert[4], cube_vert[0], n);
- add_solid_flat_triangle(&vbo, &i, pos, nor, cube_vert[0], cube_vert[3], cube_vert[7], n);
-
- GWN_batch_init(&batch, GWN_PRIM_TRIS, &vbo, NULL);
- }
-
- gpuPushMatrix();
- gpuScale3f(xsize, ysize, zsize);
-
- if (flat_color) {
- GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
- }
- else {
- /* TODO replace with good default lighting shader ? */
- GWN_batch_program_set_builtin(&batch, GPU_SHADER_SIMPLE_LIGHTING);
- GWN_batch_uniform_3fv(&batch, "light", light_vec);
- }
- GWN_batch_uniform_4fv(&batch, "color", fcolor);
- GWN_batch_draw(&batch);
-
- gpuPopMatrix();
-}
-
-static void drawcube_size(float xsize, float ysize, float zsize)
-{
- static Gwn_VertFormat format = {0};
- static Gwn_VertBuf vbo = {{0}};
- static Gwn_IndexBufBuilder elb = {0};
- static Gwn_IndexBuf el = {0};
- static Gwn_Batch batch = {{0}};
-
- if (format.attrib_ct == 0) {
- /* Vertex format */
- unsigned int pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- /* Elements */
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES, 12, 8);
- for (int i = 0; i < 12; ++i) {
- GWN_indexbuf_add_line_verts(&elb, cube_wire[i * 2], cube_wire[i * 2 + 1]);
- }
- GWN_indexbuf_build_in_place(&elb, &el);
-
- /* Vertices */
- GWN_vertbuf_init_with_format(&vbo, &format);
- GWN_vertbuf_data_alloc(&vbo, 8);
- for (int i = 0; i < 8; ++i) {
- GWN_vertbuf_attr_set(&vbo, pos, i, cube_vert[i]);
- }
-
- GWN_batch_init(&batch, GWN_PRIM_LINES, &vbo, &el);
- GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
- }
-
- gpuPushMatrix();
- gpuScale3f(xsize, ysize, zsize);
-
- GWN_batch_program_use_begin(&batch);
- GWN_batch_uniform_4fv(&batch, "color", fcolor);
- GWN_batch_draw(&batch);
-
- gpuPopMatrix();
-}
-
-
-static void draw_bonevert(void)
-{
- static Gwn_VertFormat format = {0};
- static Gwn_VertBuf vbo = {{0}};
- static Gwn_Batch batch = {{0}};
-
- if (format.attrib_ct == 0) {
- /* Vertex format */
- unsigned int pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- /* Vertices */
- GWN_vertbuf_init_with_format(&vbo, &format);
- GWN_vertbuf_data_alloc(&vbo, 96);
- for (int i = 0; i < 16; ++i) {
- float vert[3] = {0.f, 0.f, 0.f};
- const float r = 0.05f;
-
- vert[0] = r * cosf(2 * M_PI * i / 16.f);
- vert[1] = r * sinf(2 * M_PI * i / 16.f);
- GWN_vertbuf_attr_set(&vbo, pos, i * 6 + 0, vert);
- vert[0] = r * cosf(2 * M_PI * (i + 1) / 16.f);
- vert[1] = r * sinf(2 * M_PI * (i + 1) / 16.f);
- GWN_vertbuf_attr_set(&vbo, pos, i * 6 + 1, vert);
-
- vert[0] = 0.f;
- vert[1] = r * cosf(2 * M_PI * i / 16.f);
- vert[2] = r * sinf(2 * M_PI * i / 16.f);
- GWN_vertbuf_attr_set(&vbo, pos, i * 6 + 2, vert);
- vert[1] = r * cosf(2 * M_PI * (i + 1) / 16.f);
- vert[2] = r * sinf(2 * M_PI * (i + 1) / 16.f);
- GWN_vertbuf_attr_set(&vbo, pos, i * 6 + 3, vert);
-
- vert[1] = 0.f;
- vert[0] = r * cosf(2 * M_PI * i / 16.f);
- vert[2] = r * sinf(2 * M_PI * i / 16.f);
- GWN_vertbuf_attr_set(&vbo, pos, i * 6 + 4, vert);
- vert[0] = r * cosf(2 * M_PI * (i + 1) / 16.f);
- vert[2] = r * sinf(2 * M_PI * (i + 1) / 16.f);
- GWN_vertbuf_attr_set(&vbo, pos, i * 6 + 5, vert);
- }
-
- GWN_batch_init(&batch, GWN_PRIM_LINES, &vbo, NULL);
- GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
- }
-
- GWN_batch_program_use_begin(&batch);
- GWN_batch_uniform_4fv(&batch, "color", fcolor);
- GWN_batch_draw(&batch);
-}
-
-static void draw_bonevert_solid(void)
-{
- Gwn_Batch *batch = GPU_batch_preset_sphere(0);
- const float light_vec[3] = {0.0f, 0.0f, 1.0f};
-
- gpuPushMatrix();
- gpuScaleUniform(0.05);
-
- if (flat_color) {
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
- }
- else {
- /* TODO replace with good default lighting shader ? */
- GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING);
- GWN_batch_uniform_3fv(batch, "light", light_vec);
- }
- GWN_batch_uniform_4fv(batch, "color", fcolor);
- GWN_batch_draw(batch);
-
- gpuPopMatrix();
-}
-
-static const float bone_octahedral_verts[6][3] = {
- { 0.0f, 0.0f, 0.0f},
- { 0.1f, 0.1f, 0.1f},
- { 0.1f, 0.1f, -0.1f},
- {-0.1f, 0.1f, -0.1f},
- {-0.1f, 0.1f, 0.1f},
- { 0.0f, 1.0f, 0.0f}
-};
-
-static const unsigned int bone_octahedral_wire[24] = {
- 0, 1, 1, 5, 5, 3, 3, 0,
- 0, 4, 4, 5, 5, 2, 2, 0,
- 1, 2, 2, 3, 3, 4, 4, 1,
-};
-
-static const unsigned int bone_octahedral_solid_tris[8][3] = {
- {2, 1, 0}, /* bottom */
- {3, 2, 0},
- {4, 3, 0},
- {1, 4, 0},
-
- {5, 1, 2}, /* top */
- {5, 2, 3},
- {5, 3, 4},
- {5, 4, 1}
-};
-
-/* aligned with bone_octahedral_solid_tris */
-static const float bone_octahedral_solid_normals[8][3] = {
- { M_SQRT1_2, -M_SQRT1_2, 0.00000000f},
- {-0.00000000f, -M_SQRT1_2, -M_SQRT1_2},
- {-M_SQRT1_2, -M_SQRT1_2, 0.00000000f},
- { 0.00000000f, -M_SQRT1_2, M_SQRT1_2},
- { 0.99388373f, 0.11043154f, -0.00000000f},
- { 0.00000000f, 0.11043154f, -0.99388373f},
- {-0.99388373f, 0.11043154f, 0.00000000f},
- { 0.00000000f, 0.11043154f, 0.99388373f}
-};
-
-static void draw_bone_octahedral(void)
-{
- static Gwn_VertFormat format = {0};
- static Gwn_VertBuf vbo = {{0}};
- static Gwn_IndexBufBuilder elb = {0};
- static Gwn_IndexBuf el = {0};
- static Gwn_Batch batch = {{0}};
-
- if (format.attrib_ct == 0) {
- /* Vertex format */
- unsigned int pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- /* Elements */
- GWN_indexbuf_init(&elb, GWN_PRIM_LINES, 12, 6);
- for (int i = 0; i < 12; ++i) {
- GWN_indexbuf_add_line_verts(&elb, bone_octahedral_wire[i * 2], bone_octahedral_wire[i * 2 + 1]);
- }
- GWN_indexbuf_build_in_place(&elb, &el);
-
- /* Vertices */
- GWN_vertbuf_init_with_format(&vbo, &format);
- GWN_vertbuf_data_alloc(&vbo, 6);
- for (int i = 0; i < 6; ++i) {
- GWN_vertbuf_attr_set(&vbo, pos, i, bone_octahedral_verts[i]);
- }
-
- GWN_batch_init(&batch, GWN_PRIM_LINES, &vbo, &el);
- GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
- }
-
- GWN_batch_program_use_begin(&batch);
- GWN_batch_uniform_4fv(&batch, "color", fcolor);
- GWN_batch_draw(&batch);
-}
-
-static void draw_bone_solid_octahedral(void)
-{
- static Gwn_VertFormat format = {0};
- static Gwn_VertBuf vbo = {{0}};
- static Gwn_Batch batch = {{0}};
- const float light_vec[3] = {0.0f, 0.0f, 1.0f};
-
- if (format.attrib_ct == 0) {
- unsigned int v_idx = 0;
- /* Vertex format */
- unsigned int pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- /* Vertices */
- GWN_vertbuf_init_with_format(&vbo, &format);
- GWN_vertbuf_data_alloc(&vbo, 24);
-
- for (int i = 0; i < 8; i++) {
- add_solid_flat_triangle(&vbo, &v_idx, pos, nor,
- bone_octahedral_verts[bone_octahedral_solid_tris[i][0]],
- bone_octahedral_verts[bone_octahedral_solid_tris[i][1]],
- bone_octahedral_verts[bone_octahedral_solid_tris[i][2]],
- bone_octahedral_solid_normals[i]);
- }
-
- GWN_batch_init(&batch, GWN_PRIM_TRIS, &vbo, NULL);
- }
-
- if (flat_color) {
- GWN_batch_program_set_builtin(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
- }
- else {
- /* TODO replace with good default lighting shader ? */
- GWN_batch_program_set_builtin(&batch, GPU_SHADER_SIMPLE_LIGHTING);
- GWN_batch_uniform_3fv(&batch, "light", light_vec);
- }
- GWN_batch_uniform_4fv(&batch, "color", fcolor);
- GWN_batch_draw(&batch);
-}
-
-/* *************** Armature drawing, bones ******************* */
-
-
-static void draw_bone_points(const short dt, int armflag, unsigned int boneflag, int id)
-{
- /* Draw root point if we are not connected */
- if ((boneflag & BONE_CONNECTED) == 0) {
- if (id != -1)
- GPU_select_load_id(id | BONESEL_ROOT);
-
- if (dt <= OB_WIRE) {
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_ROOTSEL) {
- UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
- }
- else {
- UI_GetThemeColor4fv(TH_VERTEX, fcolor);
- }
- }
- }
- else {
- if (armflag & ARM_POSEMODE)
- set_pchan_color(PCHAN_COLOR_SOLID, boneflag, 0);
- else {
- UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
- }
- }
-
- if (dt > OB_WIRE)
- draw_bonevert_solid();
- else
- draw_bonevert();
- }
-
- /* Draw tip point */
- if (id != -1)
- GPU_select_load_id(id | BONESEL_TIP);
-
- if (dt <= OB_WIRE) {
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_TIPSEL) {
- UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
- }
- else {
- UI_GetThemeColor4fv(TH_VERTEX, fcolor);
- }
- }
- }
- else {
- if (armflag & ARM_POSEMODE)
- set_pchan_color(PCHAN_COLOR_SOLID, boneflag, 0);
- else {
- UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
- }
- }
-
- gpuPushMatrix();
- gpuTranslate2f(0.0f, 1.0f);
- if (dt > OB_WIRE)
- draw_bonevert_solid();
- else
- draw_bonevert();
- gpuPopMatrix();
-}
-
-/* 16 values of sin function (still same result!) */
-static const float si[16] = {
- 0.00000000f,
- 0.20129852f, 0.39435585f,
- 0.57126821f, 0.72479278f,
- 0.84864425f, 0.93775213f,
- 0.98846832f, 0.99871650f,
- 0.96807711f, 0.89780453f,
- 0.79077573f, 0.65137248f,
- 0.48530196f, 0.29936312f,
- 0.10116832f
-};
-/* 16 values of cos function (still same result!) */
-static const float co[16] = {
- 1.00000000f,
- 0.97952994f, 0.91895781f,
- 0.82076344f, 0.68896691f,
- 0.52896401f, 0.34730525f,
- 0.15142777f, -0.05064916f,
- -0.25065253f, -0.44039415f,
- -0.61210598f, -0.75875812f,
- -0.87434661f, -0.95413925f,
- -0.99486932f
-};
-
-
-
-/* smat, imat = mat & imat to draw screenaligned */
-static void draw_sphere_bone_dist(float smat[4][4], float imat[4][4], bPoseChannel *pchan, EditBone *ebone)
-{
- float head, tail, dist /*, length*/;
- float *headvec, *tailvec, dirvec[3];
-
- /* figure out the sizes of spheres */
- if (ebone) {
- /* this routine doesn't call get_matrix_editbone() that calculates it */
- ebone->length = len_v3v3(ebone->head, ebone->tail);
-
- /*length = ebone->length;*/ /*UNUSED*/
- tail = ebone->rad_tail;
- dist = ebone->dist;
- if (ebone->parent && (ebone->flag & BONE_CONNECTED))
- head = ebone->parent->rad_tail;
- else
- head = ebone->rad_head;
- headvec = ebone->head;
- tailvec = ebone->tail;
- }
- else {
- /*length = pchan->bone->length;*/ /*UNUSED*/
- tail = pchan->bone->rad_tail;
- dist = pchan->bone->dist;
- if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED))
- head = pchan->parent->bone->rad_tail;
- else
- head = pchan->bone->rad_head;
- headvec = pchan->pose_head;
- tailvec = pchan->pose_tail;
- }
-
- /* ***** draw it ***** */
-
- /* move vector to viewspace */
- sub_v3_v3v3(dirvec, tailvec, headvec);
- mul_mat3_m4_v3(smat, dirvec);
- /* clear zcomp */
- dirvec[2] = 0.0f;
-
- if (head != tail) {
- /* correction when viewing along the bones axis
- * it pops in and out but better then artifacts, [#23841] */
- float view_dist = len_v2(dirvec);
-
- if (head - view_dist > tail) {
- tailvec = headvec;
- tail = head;
- zero_v3(dirvec);
- dirvec[0] = 0.00001; /* XXX. weak but ok */
- }
- else if (tail - view_dist > head) {
- headvec = tailvec;
- head = tail;
- zero_v3(dirvec);
- dirvec[0] = 0.00001; /* XXX. weak but ok */
- }
- }
-
- /* move vector back */
- mul_mat3_m4_v3(imat, dirvec);
-
- if (0.0f != normalize_v3(dirvec)) {
- float norvec[3], vec1[3], vec2[3], vec[3];
- int a;
-
- //mul_v3_fl(dirvec, head);
- cross_v3_v3v3(norvec, dirvec, imat[2]);
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immBegin(GWN_PRIM_TRI_STRIP, 66);
- immUniformColor4ub(255, 255, 255, 50);
-
- for (a = 0; a < 16; a++) {
- vec[0] = -si[a] * dirvec[0] + co[a] * norvec[0];
- vec[1] = -si[a] * dirvec[1] + co[a] * norvec[1];
- vec[2] = -si[a] * dirvec[2] + co[a] * norvec[2];
-
- madd_v3_v3v3fl(vec1, headvec, vec, head);
- madd_v3_v3v3fl(vec2, headvec, vec, head + dist);
-
- immVertex3fv(pos, vec1);
- immVertex3fv(pos, vec2);
- }
-
- for (a = 15; a >= 0; a--) {
- vec[0] = si[a] * dirvec[0] + co[a] * norvec[0];
- vec[1] = si[a] * dirvec[1] + co[a] * norvec[1];
- vec[2] = si[a] * dirvec[2] + co[a] * norvec[2];
-
- madd_v3_v3v3fl(vec1, tailvec, vec, tail);
- madd_v3_v3v3fl(vec2, tailvec, vec, tail + dist);
-
- immVertex3fv(pos, vec1);
- immVertex3fv(pos, vec2);
- }
- /* make it cyclic... */
-
- vec[0] = -si[0] * dirvec[0] + co[0] * norvec[0];
- vec[1] = -si[0] * dirvec[1] + co[0] * norvec[1];
- vec[2] = -si[0] * dirvec[2] + co[0] * norvec[2];
-
- madd_v3_v3v3fl(vec1, headvec, vec, head);
- madd_v3_v3v3fl(vec2, headvec, vec, head + dist);
-
- immVertex3fv(pos, vec1);
- immVertex3fv(pos, vec2);
-
- immEnd();
- immUnbindProgram();
- }
-}
-
-
-/* smat, imat = mat & imat to draw screenaligned */
-static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4],
- int armflag, int boneflag, short constflag, unsigned int id,
- bPoseChannel *pchan, EditBone *ebone)
-{
- float head, tail /*, length*/;
- float *headvec, *tailvec, dirvec[3];
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- /* figure out the sizes of spheres */
- if (ebone) {
- /* this routine doesn't call get_matrix_editbone() that calculates it */
- ebone->length = len_v3v3(ebone->head, ebone->tail);
-
- /*length = ebone->length;*/ /*UNUSED*/
- tail = ebone->rad_tail;
- if (ebone->parent && (boneflag & BONE_CONNECTED))
- head = ebone->parent->rad_tail;
- else
- head = ebone->rad_head;
- headvec = ebone->head;
- tailvec = ebone->tail;
- }
- else {
- /*length = pchan->bone->length;*/ /*UNUSED*/
- tail = pchan->bone->rad_tail;
- if ((pchan->parent) && (boneflag & BONE_CONNECTED))
- head = pchan->parent->bone->rad_tail;
- else
- head = pchan->bone->rad_head;
- headvec = pchan->pose_head;
- tailvec = pchan->pose_tail;
- }
-
- /* sphere root color */
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_ROOTSEL) {
- UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
- }
- else {
- UI_GetThemeColor4fv(TH_VERTEX, fcolor);
- }
- }
- else if (armflag & ARM_POSEMODE)
- set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, constflag);
-
- immUniformColor4fv(fcolor);
-
- /* Draw root point if we are not connected */
- if ((boneflag & BONE_CONNECTED) == 0) {
- if (id != -1)
- GPU_select_load_id(id | BONESEL_ROOT);
-
- imm_drawcircball(headvec, head, imat, pos);
- }
-
- /* Draw tip point */
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_TIPSEL) {
- UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
- }
- else {
- UI_GetThemeColor4fv(TH_VERTEX, fcolor);
- }
- }
-
- if (id != -1)
- GPU_select_load_id(id | BONESEL_TIP);
-
- imm_drawcircball(tailvec, tail, imat, pos);
-
- /* base */
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_SELECTED) {
- UI_GetThemeColor4fv(TH_SELECT, fcolor);
- }
- else {
- UI_GetThemeColor4fv(TH_WIRE_EDIT, fcolor);
- }
- }
-
- sub_v3_v3v3(dirvec, tailvec, headvec);
-
- /* move vector to viewspace */
- mul_mat3_m4_v3(smat, dirvec);
- /* clear zcomp */
- dirvec[2] = 0.0f;
- /* move vector back */
- mul_mat3_m4_v3(imat, dirvec);
-
- if (0.0f != normalize_v3(dirvec)) {
- float norvech[3], norvect[3], vec[3];
-
- copy_v3_v3(vec, dirvec);
-
- mul_v3_fl(dirvec, head);
- cross_v3_v3v3(norvech, dirvec, imat[2]);
-
- mul_v3_fl(vec, tail);
- cross_v3_v3v3(norvect, vec, imat[2]);
-
- if (id != -1)
- GPU_select_load_id(id | BONESEL_BONE);
-
- immBegin(GWN_PRIM_LINES, 4);
-
- add_v3_v3v3(vec, headvec, norvech);
- immVertex3fv(pos, vec);
-
- add_v3_v3v3(vec, tailvec, norvect);
- immVertex3fv(pos, vec);
-
- sub_v3_v3v3(vec, headvec, norvech);
- immVertex3fv(pos, vec);
-
- sub_v3_v3v3(vec, tailvec, norvect);
- immVertex3fv(pos, vec);
-
- immEnd();
- }
-
- immUnbindProgram();
-}
-
-/* does wire only for outline selecting */
-static void draw_sphere_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id,
- bPoseChannel *pchan, EditBone *ebone)
-{
- Gwn_Batch *sphere = GPU_batch_preset_sphere(1);
- float head, tail, length;
- float fac1, fac2, size1, size2;
- const float light_vec[3] = {0.0f, 0.0f, 1.0f};
-
- /* dt is always OB_SOlID */
- GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING);
- GWN_batch_uniform_3fv(sphere, "light", light_vec);
-
- gpuPushMatrix();
-
- /* figure out the sizes of spheres */
- if (ebone) {
- length = ebone->length;
- tail = ebone->rad_tail;
- if (ebone->parent && (boneflag & BONE_CONNECTED))
- head = ebone->parent->rad_tail;
- else
- head = ebone->rad_head;
- }
- else {
- length = pchan->bone->length;
- tail = pchan->bone->rad_tail;
- if (pchan->parent && (boneflag & BONE_CONNECTED))
- head = pchan->parent->bone->rad_tail;
- else
- head = pchan->bone->rad_head;
- }
-
- /* move to z-axis space */
- gpuRotateAxis(-90.0f, 'X');
-
- /* sphere root color */
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_ROOTSEL)
- UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
- else
- UI_GetThemeColorShade4fv(TH_BONE_SOLID, -30, fcolor);
- }
- else if (armflag & ARM_POSEMODE)
- set_pchan_color(PCHAN_COLOR_SPHEREBONE_END, boneflag, constflag);
- else if (dt == OB_SOLID)
- UI_GetThemeColorShade4fv(TH_BONE_SOLID, -30, fcolor);
-
- /* Draw root point if we are not connected */
- if ((boneflag & BONE_CONNECTED) == 0) {
- if (id != -1)
- GPU_select_load_id(id | BONESEL_ROOT);
- gpuPushMatrix();
- gpuScaleUniform(head);
- GWN_batch_uniform_4fv(sphere, "color", fcolor);
- GWN_batch_draw(sphere);
- gpuPopMatrix();
- }
-
- /* Draw tip point */
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_TIPSEL) UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
- else UI_GetThemeColorShade4fv(TH_BONE_SOLID, -30, fcolor);
- }
-
- if (id != -1)
- GPU_select_load_id(id | BONESEL_TIP);
-
- gpuTranslate3f(0.0f, 0.0f, length);
-
- gpuPushMatrix();
- gpuScaleUniform(tail);
- GWN_batch_program_use_begin(sphere); /* hack to make the following uniforms stick */
- GWN_batch_uniform_4fv(sphere, "color", fcolor);
- GWN_batch_draw(sphere);
- gpuPopMatrix();
-
- gpuTranslate3f(0.0f, 0.0f, -length);
-
- /* base */
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_SELECTED) UI_GetThemeColor4fv(TH_SELECT, fcolor);
- else UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
- }
- else if (armflag & ARM_POSEMODE)
- set_pchan_color(PCHAN_COLOR_SPHEREBONE_BASE, boneflag, constflag);
- else if (dt == OB_SOLID)
- UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
-
- GWN_batch_program_use_begin(sphere); /* hack to make the following uniforms stick */
- GWN_batch_uniform_4fv(sphere, "color", fcolor);
-
- fac1 = (length - head) / length;
- fac2 = (length - tail) / length;
-
- if (length > (head + tail)) {
- size1 = fac2 * tail + (1.0f - fac2) * head;
- size2 = fac1 * head + (1.0f - fac1) * tail;
-
- if (id != -1)
- GPU_select_load_id(id | BONESEL_BONE);
-
- /* draw sphere on extrema */
- gpuPushMatrix();
- gpuTranslate3f(0.0f, 0.0f, length - tail);
- gpuScaleUniform(size1);
-
- GWN_batch_draw(sphere);
- gpuPopMatrix();
-
- gpuPushMatrix();
- gpuTranslate3f(0.0f, 0.0f, head);
- gpuScaleUniform(size2);
-
- GWN_batch_draw(sphere);
- gpuPopMatrix();
-
- /* draw cynlinder between spheres */
- glEnable(GL_POLYGON_OFFSET_FILL);
- glPolygonOffset(-1.0f, -1.0f);
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int nor = GWN_vertformat_attr_add(format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_SIMPLE_LIGHTING);
- immUniformColor4fv(fcolor);
- immUniform3fv("light", light_vec);
-
- gpuTranslate3f(0.0f, 0.0f, head);
- imm_draw_cylinder_fill_normal_3d(pos, nor, size2, size1, length - head - tail, 16, 1);
-
- immUnbindProgram();
-
- glDisable(GL_POLYGON_OFFSET_FILL);
- }
- else {
- size1 = fac1 * head + (1.0f - fac1) * tail;
-
- /* 1 sphere in center */
- gpuTranslate3f(0.0f, 0.0f, (head + length - tail) / 2.0f);
-
- gpuScaleUniform(size1);
- GWN_batch_draw(sphere);
- }
-
- gpuPopMatrix();
-}
-
-static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned int id,
- bPoseChannel *pchan, EditBone *ebone)
-{
- float length;
-
- if (pchan)
- length = pchan->bone->length;
- else
- length = ebone->length;
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- gpuPushMatrix();
- gpuScaleUniform(length);
-
- /* this chunk not in object mode */
- if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) {
- glLineWidth(4.0f);
- glPointSize(8.0f);
-
- if (armflag & ARM_POSEMODE)
- set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, constflag);
- else if (armflag & ARM_EDITMODE) {
- UI_GetThemeColor4fv(TH_WIRE_EDIT, fcolor);
- }
-
- /* line */
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4fv(fcolor);
-
- if (id != -1)
- GPU_select_load_id(id | BONESEL_BONE);
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3f(pos, 0.0f, 1.0f, 0.0f);
- immVertex3f(pos, 0.0f, 0.0f, 0.0f);
- immEnd();
-
- immUnbindProgram();
-
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR);
- immUniformColor4fv(fcolor);
-
- /* Draw root point if we are not connected */
- if ((boneflag & BONE_CONNECTED) == 0) {
- if (G.f & G_PICKSEL)
- GPU_select_load_id(id | BONESEL_ROOT);
-
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3f(pos, 0.0f, 0.0f, 0.0f);
- immEnd();
- }
-
- /* tip */
- if (G.f & G_PICKSEL)
- GPU_select_load_id(id | BONESEL_TIP);
-
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3f(pos, 0.0f, 1.0f, 0.0f);
- immEnd();
-
- immUnbindProgram();
-
-
- /* further we send no names */
- if (id != -1)
- GPU_select_load_id(id & 0xFFFF); /* object tag, for bordersel optim */
-
- if (armflag & ARM_POSEMODE)
- set_pchan_color(PCHAN_COLOR_LINEBONE, boneflag, constflag);
- }
-
- /* Now draw the inner color */
- glLineWidth(2.0f);
- glPointSize(5.0f);
-
- /* line */
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_SELECTED) UI_GetThemeColor4fv(TH_EDGE_SELECT, fcolor);
- else UI_GetThemeColorShade4fv(TH_BACK, -30, fcolor);
- }
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4fv(fcolor);
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3f(pos, 0.0f, 1.0f, 0.0f);
- immVertex3f(pos, 0.0f, 0.0f, 0.0f);
- immEnd();
-
- immUnbindProgram();
-
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR);
-
- /*Draw root point if we are not connected */
- if ((boneflag & BONE_CONNECTED) == 0) {
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_ROOTSEL) UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
- else UI_GetThemeColor4fv(TH_VERTEX, fcolor);
- }
- immUniformColor4fv(fcolor);
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3f(pos, 0.0f, 0.0f, 0.0f);
- immEnd();
- }
-
- /* tip */
- if ((G.f & G_PICKSEL) == 0) {
- /* no bitmap in selection mode, crashes 3d cards... */
- if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_TIPSEL) UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
- else UI_GetThemeColor4fv(TH_VERTEX, fcolor);
- }
- immUniformColor4fv(fcolor);
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3f(pos, 0.0f, 1.0f, 0.0f);
- immEnd();
- }
-
- immUnbindProgram();
-
- gpuPopMatrix();
-}
-
-/* A partial copy of b_bone_spline_setup(), with just the parts for previewing editmode curve settings
- *
- * This assumes that prev/next bones don't have any impact (since they should all still be in the "straight"
- * position here anyway), and that we can simply apply the bbone settings to get the desired effect...
- */
-static void ebone_spline_preview(EditBone *ebone, Mat4 result_array[MAX_BBONE_SUBDIV])
-{
- float h1[3], h2[3], length, hlength1, hlength2, roll1 = 0.0f, roll2 = 0.0f;
- float mat3[3][3];
- float data[MAX_BBONE_SUBDIV + 1][4], *fp;
- int a;
-
- length = ebone->length;
-
- hlength1 = ebone->ease1 * length * 0.390464f; /* 0.5f * sqrt(2) * kappa, the handle length for near-perfect circles */
- hlength2 = ebone->ease2 * length * 0.390464f;
-
- /* find the handle points, since this is inside bone space, the
- * first point = (0, 0, 0)
- * last point = (0, length, 0)
- *
- * we also just apply all the "extra effects", since they're the whole reason we're doing this...
- */
- h1[0] = ebone->curveInX;
- h1[1] = hlength1;
- h1[2] = ebone->curveInY;
- roll1 = ebone->roll1;
-
- h2[0] = ebone->curveOutX;
- h2[1] = -hlength2;
- h2[2] = ebone->curveOutY;
- roll2 = ebone->roll2;
-
- /* make curve */
- if (ebone->segments > MAX_BBONE_SUBDIV)
- ebone->segments = MAX_BBONE_SUBDIV;
-
- BKE_curve_forward_diff_bezier(0.0f, h1[0], h2[0], 0.0f, data[0], MAX_BBONE_SUBDIV, 4 * sizeof(float));
- BKE_curve_forward_diff_bezier(0.0f, h1[1], length + h2[1], length, data[0] + 1, MAX_BBONE_SUBDIV, 4 * sizeof(float));
- BKE_curve_forward_diff_bezier(0.0f, h1[2], h2[2], 0.0f, data[0] + 2, MAX_BBONE_SUBDIV, 4 * sizeof(float));
- BKE_curve_forward_diff_bezier(roll1, roll1 + 0.390464f * (roll2 - roll1), roll2 - 0.390464f * (roll2 - roll1), roll2, data[0] + 3, MAX_BBONE_SUBDIV, 4 * sizeof(float));
-
- equalize_bbone_bezier(data[0], ebone->segments); /* note: does stride 4! */
-
- /* make transformation matrices for the segments for drawing */
- for (a = 0, fp = data[0]; a < ebone->segments; a++, fp += 4) {
- sub_v3_v3v3(h1, fp + 4, fp);
- vec_roll_to_mat3(h1, fp[3], mat3); /* fp[3] is roll */
-
- copy_m4_m3(result_array[a].mat, mat3);
- copy_v3_v3(result_array[a].mat[3], fp);
-
- /* "extra" scale facs... */
- {
- const int num_segments = ebone->segments;
-
- const float scaleFactorIn = 1.0f + (ebone->scaleIn - 1.0f) * ((float)(num_segments - a) / (float)num_segments);
- const float scaleFactorOut = 1.0f + (ebone->scaleOut - 1.0f) * ((float)(a + 1) / (float)num_segments);
-
- const float scalefac = scaleFactorIn * scaleFactorOut;
- float bscalemat[4][4], bscale[3];
-
- bscale[0] = scalefac;
- bscale[1] = 1.0f;
- bscale[2] = scalefac;
-
- size_to_mat4(bscalemat, bscale);
-
- /* Note: don't multiply by inverse scale mat here, as it causes problems with scaling shearing and breaking segment chains */
- mul_m4_series(result_array[a].mat, result_array[a].mat, bscalemat);
- }
- }
-}
-
-static void draw_b_bone_boxes(const short dt, bPoseChannel *pchan, EditBone *ebone, float xwidth, float length, float zwidth)
-{
- int segments = 0;
-
- if (pchan)
- segments = pchan->bone->segments;
- else if (ebone)
- segments = ebone->segments;
-
- if (segments > 1) {
- float dlen = length / (float)segments;
- Mat4 bbone[MAX_BBONE_SUBDIV];
- int a;
-
- if (pchan) {
- b_bone_spline_setup(pchan, 0, bbone);
- }
- else if (ebone) {
- ebone_spline_preview(ebone, bbone);
- }
-
- for (a = 0; a < segments; a++) {
- gpuPushMatrix();
- gpuMultMatrix(bbone[a].mat);
- if (dt == OB_SOLID) drawsolidcube_size(xwidth, dlen, zwidth);
- else drawcube_size(xwidth, dlen, zwidth);
- gpuPopMatrix();
- }
- }
- else {
- if (dt == OB_SOLID) drawsolidcube_size(xwidth, length, zwidth);
- else drawcube_size(xwidth, length, zwidth);
- }
-}
-
-static void draw_b_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id,
- bPoseChannel *pchan, EditBone *ebone)
-{
- float xwidth, length, zwidth;
-
- if (pchan) {
- xwidth = pchan->bone->xwidth;
- length = pchan->bone->length;
- zwidth = pchan->bone->zwidth;
- }
- else {
- xwidth = ebone->xwidth;
- length = ebone->length;
- zwidth = ebone->zwidth;
- }
-
- /* draw points only if... */
- if (armflag & ARM_EDITMODE) {
- /* move to unitspace */
- gpuPushMatrix();
- gpuScaleUniform(length);
- draw_bone_points(dt, armflag, boneflag, id);
- gpuPopMatrix();
- length *= 0.95f; /* make vertices visible */
- }
-
- /* colors for modes */
- if (armflag & ARM_POSEMODE) {
- if (dt <= OB_WIRE)
- set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, constflag);
- else
- set_pchan_color(PCHAN_COLOR_SOLID, boneflag, constflag);
- }
- else if (armflag & ARM_EDITMODE) {
- if (dt == OB_WIRE) {
- set_ebone_color(boneflag);
- }
- else {
- UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
- }
- }
-
- if (id != -1) {
- GPU_select_load_id((GLuint) id | BONESEL_BONE);
- }
-
- /* set up solid drawing */
- if (dt > OB_WIRE) {
- if (armflag & ARM_POSEMODE)
- set_pchan_color(PCHAN_COLOR_SOLID, boneflag, constflag);
- else {
- UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
- }
-
- flat_color = false;
- draw_b_bone_boxes(OB_SOLID, pchan, ebone, xwidth, length, zwidth);
- }
- else {
- /* wire */
- if (armflag & ARM_POSEMODE) {
- if (constflag && ((G.f & G_PICKSEL) == 0)) {
- /* set constraint colors */
- if (set_pchan_color(PCHAN_COLOR_CONSTS, boneflag, constflag)) {
- glEnable(GL_BLEND);
-
- flat_color = true;
- draw_b_bone_boxes(OB_SOLID, pchan, ebone, xwidth, length, zwidth);
-
- glDisable(GL_BLEND);
- }
-
- /* restore colors */
- set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, constflag);
- }
- }
-
- draw_b_bone_boxes(OB_WIRE, pchan, ebone, xwidth, length, zwidth);
- }
-}
-
-static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float length, int segments)
-{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4fv(fcolor);
-
- if ((segments > 1) && (pchan)) {
- float dlen = length / (float)segments;
- Mat4 *bbone = bbones;
- int a;
-
- for (a = 0; a < segments; a++, bbone++) {
- gpuPushMatrix();
- gpuMultMatrix(bbone->mat);
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3f(pos, 0.0f, 0.0f, 0.0f);
- immVertex3f(pos, 0.0f, dlen, 0.0f);
- immEnd();
-
- gpuPopMatrix();
- }
- }
- else {
- gpuPushMatrix();
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3f(pos, 0.0f, 0.0f, 0.0f);
- immVertex3f(pos, 0.0f, length, 0.0f);
- immEnd();
-
- gpuPopMatrix();
- }
-
- immUnbindProgram();
-}
-
-static void draw_wire_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id,
- bPoseChannel *pchan, EditBone *ebone)
-{
- Mat4 bbones_array[MAX_BBONE_SUBDIV];
- Mat4 *bbones = NULL;
- int segments = 0;
- float length;
-
- if (pchan) {
- segments = pchan->bone->segments;
- length = pchan->bone->length;
-
- if (segments > 1) {
- b_bone_spline_setup(pchan, 0, bbones_array);
- bbones = bbones_array;
- }
- }
- else
- length = ebone->length;
-
- /* draw points only if... */
- if (armflag & ARM_EDITMODE) {
- /* move to unitspace */
- gpuPushMatrix();
- gpuScaleUniform(length);
- flat_color = true;
- draw_bone_points(dt, armflag, boneflag, id);
- gpuPopMatrix();
- length *= 0.95f; /* make vertices visible */
- }
-
- /* this chunk not in object mode */
- if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) {
- if (id != -1)
- GPU_select_load_id((GLuint) id | BONESEL_BONE);
-
- draw_wire_bone_segments(pchan, bbones, length, segments);
-
- /* further we send no names */
- if (id != -1)
- GPU_select_load_id(id & 0xFFFF); /* object tag, for bordersel optim */
- }
-
- /* colors for modes */
- if (armflag & ARM_POSEMODE) {
- set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, constflag);
- }
- else if (armflag & ARM_EDITMODE) {
- set_ebone_color(boneflag);
- }
-
- /* draw normal */
- draw_wire_bone_segments(pchan, bbones, length, segments);
-}
-
-static void draw_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id, float length)
-{
-
- /* Draw a 3d octahedral bone, we use normalized space based on length */
- gpuScaleUniform(length);
-
- /* set up solid drawing */
- if (dt > OB_WIRE) {
- UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
- flat_color = false;
- }
- else
- flat_color = true;
-
- /* colors for posemode */
- if (armflag & ARM_POSEMODE) {
- if (dt <= OB_WIRE)
- set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, constflag);
- else
- set_pchan_color(PCHAN_COLOR_SOLID, boneflag, constflag);
- }
-
-
- draw_bone_points(dt, armflag, boneflag, id);
-
- /* now draw the bone itself */
- if (id != -1) {
- GPU_select_load_id((GLuint) id | BONESEL_BONE);
- }
-
- /* wire? */
- if (dt <= OB_WIRE) {
- /* colors */
- if (armflag & ARM_EDITMODE) {
- set_ebone_color(boneflag);
- }
- else if (armflag & ARM_POSEMODE) {
- if (constflag && ((G.f & G_PICKSEL) == 0)) {
- /* draw constraint colors */
- if (set_pchan_color(PCHAN_COLOR_CONSTS, boneflag, constflag)) {
- glEnable(GL_BLEND);
-
- draw_bone_solid_octahedral();
-
- glDisable(GL_BLEND);
- }
-
- /* restore colors */
- set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, constflag);
- }
- }
- draw_bone_octahedral();
- }
- else {
- /* solid */
- if (armflag & ARM_POSEMODE)
- set_pchan_color(PCHAN_COLOR_SOLID, boneflag, constflag);
- else
- UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
-
- draw_bone_solid_octahedral();
- }
-}
-
-static void draw_custom_bone(
- const struct EvaluationContext *eval_ctx,
- Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Object *ob,
- const short dt, int armflag, int boneflag, unsigned int id, float length)
-{
- if (ob == NULL) return;
-
- gpuScaleUniform(length);
-
- /* colors for posemode */
- if (armflag & ARM_POSEMODE) {
- set_pchan_color(PCHAN_COLOR_NORMAL, boneflag, 0);
- }
-
- if (id != -1) {
- GPU_select_load_id((GLuint) id | BONESEL_BONE);
- }
-
- draw_object_instance(eval_ctx, scene, view_layer, v3d, rv3d, ob, dt, armflag & ARM_POSEMODE, fcolor);
-}
-
-
-static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
-{
- bConstraint *con;
- bPoseChannel *parchan;
-
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
-
- float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
- immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
-
- immUniform1i("num_colors", 0); /* "simple" mode */
- immUniformColor4fv(fcolor);
- immUniform1f("dash_width", 6.0f);
- immUniform1f("dash_factor", 0.5f);
-
- for (con = pchan->constraints.first; con; con = con->next) {
- if (con->enforce == 0.0f)
- continue;
-
- switch (con->type) {
- case CONSTRAINT_TYPE_KINEMATIC:
- {
- bKinematicConstraint *data = (bKinematicConstraint *)con->data;
- int segcount = 0;
- float ik_tip[3];
-
- /* if only_temp, only draw if it is a temporary ik-chain */
- if ((only_temp) && !(data->flag & CONSTRAINT_IK_TEMP))
- continue;
-
- /* exclude tip from chain? */
- if ((data->flag & CONSTRAINT_IK_TIP) == 0)
- parchan = pchan->parent;
- else
- parchan = pchan;
-
- copy_v3_v3(ik_tip, parchan->pose_tail);
-
- /* Find the chain's root */
- while (parchan->parent) {
- segcount++;
- /* FIXME: revise the breaking conditions */
- if (segcount == data->rootbone || segcount > 255) break; /* 255 is weak */
- parchan = parchan->parent;
- }
-
- if (parchan) {
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(shdr_pos, ik_tip);
- immVertex3fv(shdr_pos, parchan->pose_head);
- immEnd();
- }
-
- break;
- }
- case CONSTRAINT_TYPE_SPLINEIK:
- {
- bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
- int segcount = 0;
- float ik_tip[3];
-
- parchan = pchan;
- copy_v3_v3(ik_tip, parchan->pose_tail);
-
- /* Find the chain's root */
- while (parchan->parent) {
- segcount++;
- /* FIXME: revise the breaking conditions */
- if (segcount == data->chainlen || segcount > 255) break; /* 255 is weak */
- parchan = parchan->parent;
- }
- /* Only draw line in case our chain is more than one bone long! */
- if (parchan != pchan) { /* XXX revise the breaking conditions to only stop at the tail? */
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(shdr_pos, ik_tip);
- immVertex3fv(shdr_pos, parchan->pose_head);
- immEnd();
- }
- break;
- }
- }
- }
-
- immUnbindProgram();
-}
-
-static void imm_sphere_project(unsigned int pos, float ax, float az)
-{
- float dir[3], sine, q3;
-
- sine = 1.0f - ax * ax - az * az;
- q3 = (sine < 0.0f) ? 0.0f : (2.0f * sqrtf(sine));
-
- dir[0] = -az * q3;
- dir[1] = 1.0f - 2.0f * sine;
- dir[2] = ax * q3;
-
- immVertex3fv(pos, dir);
-}
-
-static void draw_dof_ellipse(unsigned int pos, float ax, float az)
-{
- const int n = 16;
- const int tri = n * n - 2 * n + 1; /* Yay fancy math ! */
- const float staticSine[16] = {
- 0.0f, 0.104528463268f, 0.207911690818f, 0.309016994375f,
- 0.406736643076f, 0.5f, 0.587785252292f, 0.669130606359f,
- 0.743144825477f, 0.809016994375f, 0.866025403784f,
- 0.913545457643f, 0.951056516295f, 0.978147600734f,
- 0.994521895368f, 1.0f
- };
-
- int i, j;
- float x, z, px, pz;
-
- glEnable(GL_BLEND);
- glDepthMask(0);
-
- immUniformColor4ub(70, 70, 70, 50);
-
- immBegin(GWN_PRIM_TRIS, tri * 3);
- pz = 0.0f;
- for (i = 1; i < n; i++) {
- z = staticSine[i];
-
- px = 0.0f;
- for (j = 1; j <= (n - i); j++) {
- x = staticSine[j];
-
- if (j == n - i) {
- imm_sphere_project(pos, ax * px, az * z);
- imm_sphere_project(pos, ax * px, az * pz);
- imm_sphere_project(pos, ax * x, az * pz);
- }
- else {
- imm_sphere_project(pos, ax * x, az * z);
- imm_sphere_project(pos, ax * x, az * pz);
- imm_sphere_project(pos, ax * px, az * pz);
-
- imm_sphere_project(pos, ax * px, az * pz);
- imm_sphere_project(pos, ax * px, az * z);
- imm_sphere_project(pos, ax * x, az * z);
- }
-
- px = x;
- }
- pz = z;
- }
- immEnd();
-
- glDisable(GL_BLEND);
- glDepthMask(1);
-
- immUniformColor3ub(0, 0, 0);
-
- immBegin(GWN_PRIM_LINE_STRIP, n);
- for (i = 0; i < n; i++)
- imm_sphere_project(pos, staticSine[n - i - 1] * ax, staticSine[i] * az);
- immEnd();
-}
-
-static void draw_pose_dofs(Object *ob)
-{
- bArmature *arm = ob->data;
- bPoseChannel *pchan;
- Bone *bone;
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- bone = pchan->bone;
-
- if ((bone != NULL) && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) {
- if (bone->flag & BONE_SELECTED) {
- if (bone->layer & arm->layer) {
- if (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ZLIMIT)) {
- if (BKE_pose_channel_in_IK_chain(ob, pchan)) {
- float corner[4][3], posetrans[3], mat[4][4];
- float phi = 0.0f, theta = 0.0f, scale;
- int a, i;
-
- /* in parent-bone pose, but own restspace */
- gpuPushMatrix();
-
- copy_v3_v3(posetrans, pchan->pose_mat[3]);
- gpuTranslate3fv(posetrans);
-
- if (pchan->parent) {
- copy_m4_m4(mat, pchan->parent->pose_mat);
- mat[3][0] = mat[3][1] = mat[3][2] = 0.0f;
- gpuMultMatrix(mat);
- }
-
- copy_m4_m3(mat, pchan->bone->bone_mat);
- gpuMultMatrix(mat);
-
- scale = bone->length * pchan->size[1];
- gpuScaleUniform(scale);
-
- if (((pchan->ikflag & BONE_IK_XLIMIT) != 0) &&
- ((pchan->ikflag & BONE_IK_ZLIMIT) != 0))
- {
- float amin[3], amax[3];
-
- for (i = 0; i < 3; i++) {
- /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
- amin[i] = sinf(pchan->limitmin[i] * 0.5f);
- amax[i] = sinf(pchan->limitmax[i] * 0.5f);
- }
-
- gpuScale3f(1.0f, -1.0f, 1.0f);
- if ((amin[0] != 0.0f) && (amin[2] != 0.0f))
- draw_dof_ellipse(pos, amin[0], amin[2]);
- if ((amin[0] != 0.0f) && (amax[2] != 0.0f))
- draw_dof_ellipse(pos, amin[0], amax[2]);
- if ((amax[0] != 0.0f) && (amin[2] != 0.0f))
- draw_dof_ellipse(pos, amax[0], amin[2]);
- if ((amax[0] != 0.0f) && (amax[2] != 0.0f))
- draw_dof_ellipse(pos, amax[0], amax[2]);
- gpuScale3f(1.0f, -1.0f, 1.0f); /* XXX same as above, is this intentional? */
- }
-
- /* arcs */
- if (pchan->ikflag & BONE_IK_ZLIMIT) {
- /* OpenGL requires rotations in degrees; so we're taking the average angle here */
- theta = RAD2DEGF(0.5f * (pchan->limitmin[2] + pchan->limitmax[2]));
- gpuPushMatrix();
- gpuRotateAxis(theta, 'Z');
-
- immUniformColor3ub(50, 50, 255); /* blue, Z axis limit */
- immBegin(GWN_PRIM_LINE_STRIP, 33);
- for (a = -16; a <= 16; a++) {
- /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
- float fac = ((float)a) / 16.0f * 0.5f;
-
- phi = fac * (pchan->limitmax[2] - pchan->limitmin[2]);
-
- i = (a == -16) ? 0 : 1;
- corner[i][0] = sinf(phi);
- corner[i][1] = cosf(phi);
- corner[i][2] = 0.0f;
- immVertex3fv(pos, corner[i]);
- }
- immEnd();
-
- gpuPopMatrix();
- }
-
- if (pchan->ikflag & BONE_IK_XLIMIT) {
- /* OpenGL requires rotations in degrees; so we're taking the average angle here */
- theta = RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0]));
- gpuPushMatrix();
- gpuRotateAxis(theta, 'X');
-
- immUniformColor3ub(255, 50, 50); /* Red, X axis limit */
- immBegin(GWN_PRIM_LINE_STRIP, 33);
- for (a = -16; a <= 16; a++) {
- /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
- float fac = ((float)a) / 16.0f * 0.5f;
- phi = (float)M_PI_2 + fac * (pchan->limitmax[0] - pchan->limitmin[0]);
-
- i = (a == -16) ? 2 : 3;
- corner[i][0] = 0.0f;
- corner[i][1] = sinf(phi);
- corner[i][2] = cosf(phi);
- immVertex3fv(pos, corner[i]);
- }
- immEnd();
-
- gpuPopMatrix();
- }
-
- /* out of cone, out of bone */
- gpuPopMatrix();
- }
- }
- }
- }
- }
- }
-
- immUnbindProgram();
-}
-
-static void bone_matrix_translate_y(float mat[4][4], float y)
-{
- float trans[3];
-
- copy_v3_v3(trans, mat[1]);
- mul_v3_fl(trans, y);
- add_v3_v3(mat[3], trans);
-}
-
-/* assumes object is Armature with pose */
-static void draw_pose_bones(
- const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, ARegion *ar, Base *base,
- const short dt, const unsigned char ob_wire_col[4],
- const bool do_const_color, const bool is_outline)
-{
- RegionView3D *rv3d = ar->regiondata;
- Object *ob = base->object;
- bArmature *arm = ob->data;
- bPoseChannel *pchan;
- Bone *bone;
- float smat[4][4], imat[4][4], bmat[4][4];
- int index = -1;
- const enum {
- DASH_RELATIONSHIP_LINES = 1,
- DASH_HELP_LINES = 2,
- } do_dashed = (
- (is_outline ? 0 : DASH_RELATIONSHIP_LINES) |
- ((v3d->flag & V3D_HIDE_HELPLINES) ? 0 : DASH_HELP_LINES));
- bool draw_wire = false;
- int flag;
- bool is_cull_enabled;
-
- /* being set below */
- arm->layer_used = 0;
-
- rgba_uchar_to_float(fcolor, ob_wire_col);
-
- /* precalc inverse matrix for drawing screen aligned */
- if (arm->drawtype == ARM_ENVELOPE) {
- /* precalc inverse matrix for drawing screen aligned */
- copy_m4_m4(smat, rv3d->viewmatob);
- mul_mat3_m4_fl(smat, 1.0f / len_v3(ob->obmat[0]));
- invert_m4_m4(imat, smat);
-
- /* and draw blended distances */
- if (arm->flag & ARM_POSEMODE) {
- glEnable(GL_BLEND);
-
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- bone = pchan->bone;
- if (bone) {
- /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194]
- * NOTE: this is the only case with (NO_DEFORM == 0) flag, as this is for envelope influence drawing
- */
- if (((bone->flag & (BONE_HIDDEN_P | BONE_NO_DEFORM | BONE_HIDDEN_PG)) == 0) &&
- ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0))
- {
- if (bone->flag & (BONE_SELECTED)) {
- if (bone->layer & arm->layer)
- draw_sphere_bone_dist(smat, imat, pchan, NULL);
- }
- }
- }
- }
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- }
- }
-
- /* little speedup, also make sure transparent only draws once */
- glCullFace(GL_BACK);
- if (v3d->flag2 & V3D_BACKFACE_CULLING) {
- glEnable(GL_CULL_FACE);
- is_cull_enabled = true;
- }
- else {
- is_cull_enabled = false;
- }
-
- /* if solid we draw that first, with selection codes, but without names, axes etc */
- if (dt > OB_WIRE) {
- if (arm->flag & ARM_POSEMODE)
- index = base->object->select_color;
-
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- bone = pchan->bone;
- arm->layer_used |= bone->layer;
-
- /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */
- if (((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) &&
- ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0))
- {
- if (bone->layer & arm->layer) {
- const bool use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM);
- gpuPushMatrix();
-
- if (use_custom && pchan->custom_tx) {
- gpuMultMatrix(pchan->custom_tx->pose_mat);
- }
- else {
- gpuMultMatrix(pchan->pose_mat);
- }
-
- /* catch exception for bone with hidden parent */
- flag = bone->flag;
- if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) {
- flag &= ~BONE_CONNECTED;
- }
-
- /* set temporary flag for drawing bone as active, but only if selected */
- if (bone == arm->act_bone)
- flag |= BONE_DRAW_ACTIVE;
-
- if (do_const_color) {
- /* keep color */
- }
- else {
- /* set color-set to use */
- set_pchan_colorset(ob, pchan);
- }
-
- /* may be 2x width from custom bone's outline option */
- glLineWidth(1.0f);
-
- if (use_custom) {
- /* if drawwire, don't try to draw in solid */
- if (pchan->bone->flag & BONE_DRAWWIRE) {
- draw_wire = true;
- }
- else {
- if (is_cull_enabled && (v3d->flag2 & V3D_BACKFACE_CULLING) == 0) {
- is_cull_enabled = false;
- glDisable(GL_CULL_FACE);
- }
-
- draw_custom_bone(eval_ctx, scene, view_layer, v3d, rv3d, pchan->custom,
- OB_SOLID, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan));
- }
- }
- else {
- if (is_cull_enabled == false) {
- is_cull_enabled = true;
- glEnable(GL_CULL_FACE);
- }
-
- if (arm->drawtype == ARM_LINE) {
- /* nothing in solid */
- }
- else if (arm->drawtype == ARM_WIRE) {
- /* nothing in solid */
- }
- else if (arm->drawtype == ARM_ENVELOPE) {
- draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, pchan, NULL);
- }
- else if (arm->drawtype == ARM_B_BONE) {
- draw_b_bone(OB_SOLID, arm->flag, flag, 0, index, pchan, NULL);
- }
- else {
- draw_bone(OB_SOLID, arm->flag, flag, 0, index, bone->length);
- }
- }
-
- gpuPopMatrix();
- }
- }
-
- if (index != -1)
- index += 0x10000; /* pose bones count in higher 2 bytes only */
- }
-
- /* very very confusing... but in object mode, solid draw, we cannot do GPU_select_load_id yet,
- * stick bones and/or wire custom-shapes are drawn in next loop
- */
- if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && (draw_wire == false) && index != -1) {
- /* object tag, for bordersel optim */
- GPU_select_load_id(index & 0xFFFF);
- index = -1;
- }
- }
-
- /* custom bone may draw outline double-width */
- if (arm->flag & ARM_POSEMODE) {
- glLineWidth(1.0f);
- }
-
- /* draw custom bone shapes as wireframes */
- if (!(arm->flag & ARM_NO_CUSTOM) &&
- (draw_wire || (dt <= OB_WIRE)) )
- {
- if (arm->flag & ARM_POSEMODE)
- index = base->object->select_color;
-
- /* only draw custom bone shapes that need to be drawn as wires */
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- bone = pchan->bone;
-
- /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */
- if (((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) &&
- ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0) )
- {
- if (bone->layer & arm->layer) {
- if (pchan->custom) {
- if ((dt < OB_SOLID) || (bone->flag & BONE_DRAWWIRE)) {
- gpuPushMatrix();
-
- if (pchan->custom_tx) {
- gpuMultMatrix(pchan->custom_tx->pose_mat);
- }
- else {
- gpuMultMatrix(pchan->pose_mat);
- }
-
- /* prepare colors */
- if (do_const_color) {
- /* 13 October 2009, Disabled this to make ghosting show the right colors (Aligorith) */
- }
- else if (arm->flag & ARM_POSEMODE)
- set_pchan_colorset(ob, pchan);
- else {
- rgba_uchar_to_float(fcolor, ob_wire_col);
- }
-
- /* catch exception for bone with hidden parent */
- flag = bone->flag;
- if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)))
- flag &= ~BONE_CONNECTED;
-
- /* set temporary flag for drawing bone as active, but only if selected */
- if (bone == arm->act_bone)
- flag |= BONE_DRAW_ACTIVE;
-
- draw_custom_bone(eval_ctx, scene, view_layer, v3d, rv3d, pchan->custom,
- OB_WIRE, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan));
-
- gpuPopMatrix();
- }
- }
- }
- }
-
- if (index != -1)
- index += 0x10000; /* pose bones count in higher 2 bytes only */
- }
- /* stick or wire bones have not been drawn yet so don't clear object selection in this case */
- if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && draw_wire && index != -1) {
- /* object tag, for bordersel optim */
- GPU_select_load_id(index & 0xFFFF);
- index = -1;
- }
- }
-
- /* wire draw over solid only in posemode */
- if ((dt <= OB_WIRE) || (arm->flag & ARM_POSEMODE) || ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
- /* draw line check first. we do selection indices */
- if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
- if (arm->flag & ARM_POSEMODE)
- index = base->object->select_color;
- }
- /* if solid && posemode, we draw again with polygonoffset */
- else if ((dt > OB_WIRE) && (arm->flag & ARM_POSEMODE)) {
- ED_view3d_polygon_offset(rv3d, 1.0);
- }
- else {
- /* and we use selection indices if not done yet */
- if (arm->flag & ARM_POSEMODE)
- index = base->object->select_color;
- }
-
- if (is_cull_enabled == false) {
- is_cull_enabled = true;
- glEnable(GL_CULL_FACE);
- }
-
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- bone = pchan->bone;
- arm->layer_used |= bone->layer;
-
- /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */
- if (((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) &&
- ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0))
- {
- if (bone->layer & arm->layer) {
- const short constflag = pchan->constflag;
- if ((do_dashed & DASH_RELATIONSHIP_LINES) && (pchan->parent)) {
- /* Draw a line from our root to the parent's tip
- * - only if V3D_HIDE_HELPLINES is enabled...
- */
- if ((do_dashed & DASH_HELP_LINES) && ((bone->flag & BONE_CONNECTED) == 0)) {
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
-
- float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
- immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
-
- immUniform1i("num_colors", 0); /* "simple" mode */
- immUniformColor4fv(fcolor);
- immUniform1f("dash_width", 6.0f);
- immUniform1f("dash_factor", 0.5f);
-
- if (arm->flag & ARM_POSEMODE) {
- GPU_select_load_id(index & 0xFFFF); /* object tag, for bordersel optim */
- immUniformThemeColor(TH_WIRE);
- }
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(shdr_pos, pchan->parent->pose_tail);
- immVertex3fv(shdr_pos, pchan->pose_head);
- immEnd();
-
- immUnbindProgram();
- }
-
- /* Draw a line to IK root bone
- * - only if temporary chain (i.e. "autoik")
- */
- if (arm->flag & ARM_POSEMODE) {
- if (constflag & PCHAN_HAS_IK) {
- if (bone->flag & BONE_SELECTED) {
- if (constflag & PCHAN_HAS_TARGET) {
- rgba_float_args_set(fcolor, 200.f / 255.f, 120.f / 255.f, 0.f / 255.f, 1.0f);
- }
- /* add theme! */
- else rgba_float_args_set(fcolor, 200.f / 255.f, 200.f / 255.f, 50.f / 255.f, 1.0f);
-
- GPU_select_load_id(index & 0xFFFF);
- pchan_draw_IK_root_lines(pchan, !(do_dashed & DASH_HELP_LINES));
- }
- }
- else if (constflag & PCHAN_HAS_SPLINEIK) {
- if (bone->flag & BONE_SELECTED) {
- /* add theme! */
- rgba_float_args_set(fcolor, 150.f / 255.f, 200.f / 255.f, 50.f / 255.f, 1.0f);
-
- GPU_select_load_id(index & 0xFFFF);
- pchan_draw_IK_root_lines(pchan, !(do_dashed & DASH_HELP_LINES));
- }
- }
- }
- }
-
- gpuPushMatrix();
- if (arm->drawtype != ARM_ENVELOPE)
- gpuMultMatrix(pchan->pose_mat);
-
- /* catch exception for bone with hidden parent */
- flag = bone->flag;
- if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)))
- flag &= ~BONE_CONNECTED;
-
- /* set temporary flag for drawing bone as active, but only if selected */
- if (bone == arm->act_bone)
- flag |= BONE_DRAW_ACTIVE;
-
- /* extra draw service for pose mode */
-
- /* set color-set to use */
- if (do_const_color) {
- /* keep color */
- }
- else {
- set_pchan_colorset(ob, pchan);
- }
-
- if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) {
- /* custom bone shapes should not be drawn here! */
- }
- else if (arm->drawtype == ARM_ENVELOPE) {
- if (dt < OB_SOLID)
- draw_sphere_bone_wire(smat, imat, arm->flag, flag, constflag, index, pchan, NULL);
- }
- else if (arm->drawtype == ARM_LINE)
- draw_line_bone(arm->flag, flag, constflag, index, pchan, NULL);
- else if (arm->drawtype == ARM_WIRE)
- draw_wire_bone(dt, arm->flag, flag, constflag, index, pchan, NULL);
- else if (arm->drawtype == ARM_B_BONE)
- draw_b_bone(OB_WIRE, arm->flag, flag, constflag, index, pchan, NULL);
- else
- draw_bone(OB_WIRE, arm->flag, flag, constflag, index, bone->length);
-
- gpuPopMatrix();
- }
- }
-
- /* pose bones count in higher 2 bytes only */
- if (index != -1)
- index += 0x10000;
- }
- /* restore things */
- if (!ELEM(arm->drawtype, ARM_WIRE, ARM_LINE) && (dt > OB_WIRE) && (arm->flag & ARM_POSEMODE))
- ED_view3d_polygon_offset(rv3d, 0.0);
- }
-
- /* restore */
- if (is_cull_enabled) {
- glDisable(GL_CULL_FACE);
- }
-
- /* draw DoFs */
- if (arm->flag & ARM_POSEMODE) {
- if (((base->flag_legacy & OB_FROMDUPLI) == 0) && ((v3d->flag & V3D_HIDE_HELPLINES) == 0)) {
- draw_pose_dofs(ob);
- }
- }
-
- /* finally names and axes */
- if ((arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) &&
- (is_outline == 0) &&
- ((base->flag_legacy & OB_FROMDUPLI) == 0))
- {
- /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */
- if ((G.f & G_PICKSEL) == 0) {
- float vec[3];
-
- unsigned char col[4];
- col[0] = ob_wire_col[0];
- col[1] = ob_wire_col[1];
- col[2] = ob_wire_col[2];
- col[3] = 255;
-
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if ((pchan->bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) {
- if (pchan->bone->layer & arm->layer) {
- if (arm->flag & (ARM_EDITMODE | ARM_POSEMODE)) {
- bone = pchan->bone;
- UI_GetThemeColor3ubv((bone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, col);
- }
- else if (dt > OB_WIRE) {
- UI_GetThemeColor3ubv(TH_TEXT, col);
- }
-
- /* Draw names of bone */
- if (arm->flag & ARM_DRAWNAMES) {
- mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail);
- view3d_cached_text_draw_add(vec, pchan->name, strlen(pchan->name), 10, 0, col);
- }
-
- /* Draw additional axes on the bone tail */
- if ((arm->flag & ARM_DRAWAXES) && (arm->flag & ARM_POSEMODE)) {
- gpuPushMatrix();
- copy_m4_m4(bmat, pchan->pose_mat);
- bone_matrix_translate_y(bmat, pchan->bone->length);
- gpuMultMatrix(bmat);
-
- float viewmat_pchan[4][4];
- mul_m4_m4m4(viewmat_pchan, rv3d->viewmatob, bmat);
- drawaxes(viewmat_pchan, pchan->bone->length * 0.25f, OB_ARROWS, col);
-
- gpuPopMatrix();
- }
- }
- }
- }
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- }
- }
-
- if (index != -1) {
- GPU_select_load_id(-1);
- }
-}
-
-/* in editmode, we don't store the bone matrix... */
-static void get_matrix_editbone(EditBone *ebone, float bmat[4][4])
-{
- ebone->length = len_v3v3(ebone->tail, ebone->head);
- ED_armature_ebone_to_mat4(ebone, bmat);
-}
-
-static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
-{
- RegionView3D *rv3d = ar->regiondata;
- EditBone *eBone;
- bArmature *arm = ob->data;
- float smat[4][4], imat[4][4], bmat[4][4];
- unsigned int index;
- int flag;
-
- /* being set in code below */
- arm->layer_used = 0;
-
- ED_view3d_check_mats_rv3d(rv3d);
-
- /* envelope (deform distance) */
- if (arm->drawtype == ARM_ENVELOPE) {
- /* precalc inverse matrix for drawing screen aligned */
- copy_m4_m4(smat, rv3d->viewmatob);
- mul_mat3_m4_fl(smat, 1.0f / len_v3(ob->obmat[0]));
- invert_m4_m4(imat, smat);
-
- /* and draw blended distances */
- glEnable(GL_BLEND);
-
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
- if (eBone->layer & arm->layer) {
- if ((eBone->flag & (BONE_HIDDEN_A | BONE_NO_DEFORM)) == 0) {
- if (eBone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL))
- draw_sphere_bone_dist(smat, imat, NULL, eBone);
- }
- }
- }
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- }
-
- /* if solid we draw it first */
- if ((dt > OB_WIRE) && (arm->drawtype != ARM_LINE)) {
- for (eBone = arm->edbo->first, index = 0; eBone; eBone = eBone->next, index++) {
- if (eBone->layer & arm->layer) {
- if ((eBone->flag & BONE_HIDDEN_A) == 0) {
- gpuPushMatrix();
- get_matrix_editbone(eBone, bmat);
- gpuMultMatrix(bmat);
-
- /* catch exception for bone with hidden parent */
- flag = eBone->flag;
- if ((eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent)) {
- flag &= ~BONE_CONNECTED;
- }
-
- /* set temporary flag for drawing bone as active, but only if selected */
- if (eBone == arm->act_edbone)
- flag |= BONE_DRAW_ACTIVE;
-
- if (arm->drawtype == ARM_ENVELOPE)
- draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone);
- else if (arm->drawtype == ARM_B_BONE)
- draw_b_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone);
- else if (arm->drawtype == ARM_WIRE)
- draw_wire_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone);
- else {
- draw_bone(OB_SOLID, arm->flag, flag, 0, index, eBone->length);
- }
-
- gpuPopMatrix();
- }
- }
- }
- }
-
- /* if wire over solid, set offset */
- index = -1;
- GPU_select_load_id(-1);
- if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
- if (G.f & G_PICKSEL)
- index = 0;
- }
- else if (dt > OB_WIRE)
- ED_view3d_polygon_offset(rv3d, 1.0);
- else if (arm->flag & ARM_EDITMODE)
- index = 0; /* do selection codes */
-
- for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
- arm->layer_used |= eBone->layer;
- if (eBone->layer & arm->layer) {
- if ((eBone->flag & BONE_HIDDEN_A) == 0) {
-
- /* catch exception for bone with hidden parent */
- flag = eBone->flag;
- if ((eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent)) {
- flag &= ~BONE_CONNECTED;
- }
-
- /* set temporary flag for drawing bone as active, but only if selected */
- if (eBone == arm->act_edbone)
- flag |= BONE_DRAW_ACTIVE;
-
- if (arm->drawtype == ARM_ENVELOPE) {
- if (dt < OB_SOLID)
- draw_sphere_bone_wire(smat, imat, arm->flag, flag, 0, index, NULL, eBone);
- }
- else {
- gpuPushMatrix();
- get_matrix_editbone(eBone, bmat);
- gpuMultMatrix(bmat);
-
- if (arm->drawtype == ARM_LINE)
- draw_line_bone(arm->flag, flag, 0, index, NULL, eBone);
- else if (arm->drawtype == ARM_WIRE)
- draw_wire_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone);
- else if (arm->drawtype == ARM_B_BONE)
- draw_b_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone);
- else
- draw_bone(OB_WIRE, arm->flag, flag, 0, index, eBone->length);
-
- gpuPopMatrix();
- }
-
- /* offset to parent */
- if (eBone->parent) {
- const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- GPU_select_load_id(-1); /* -1 here is OK! */
-
- immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
-
- float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
- immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
-
- immUniform1i("num_colors", 0); /* "simple" mode */
- immUniformThemeColor(TH_WIRE_EDIT);
- immUniform1f("dash_width", 6.0f);
- immUniform1f("dash_factor", 0.5f);
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(shdr_pos, eBone->parent->tail);
- immVertex3fv(shdr_pos, eBone->head);
- immEnd();
-
- immUnbindProgram();
- }
- }
- }
- if (index != -1) index++;
- }
-
- /* restore */
- if (index != -1) {
- GPU_select_load_id(-1);
- }
-
- if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
- /* pass */
- }
- else if (dt > OB_WIRE) {
- ED_view3d_polygon_offset(rv3d, 0.0);
- }
-
- /* finally names and axes */
- if (arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) {
- /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */
- if ((G.f & G_PICKSEL) == 0) {
- float vec[3];
- unsigned char col[4];
- col[3] = 255;
-
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
- if (eBone->layer & arm->layer) {
- if ((eBone->flag & BONE_HIDDEN_A) == 0) {
-
- UI_GetThemeColor3ubv((eBone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, col);
-
- /* Draw name */
- if (arm->flag & ARM_DRAWNAMES) {
- mid_v3_v3v3(vec, eBone->head, eBone->tail);
- view3d_cached_text_draw_add(vec, eBone->name, strlen(eBone->name), 10, 0, col);
- }
- /* Draw additional axes */
- if (arm->flag & ARM_DRAWAXES) {
- gpuPushMatrix();
- get_matrix_editbone(eBone, bmat);
- bone_matrix_translate_y(bmat, eBone->length);
- gpuMultMatrix(bmat);
-
- float viewmat_ebone[4][4];
- mul_m4_m4m4(viewmat_ebone, rv3d->viewmatob, bmat);
- drawaxes(viewmat_ebone, eBone->length * 0.25f, OB_ARROWS, col);
-
- gpuPopMatrix();
- }
-
- }
- }
- }
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- }
- }
-}
-
-/* ****************************** Armature Visualization ******************************** */
-
-/* ---------- Paths --------- */
-
-/* draw bone paths
- * - in view space
- */
-static void draw_pose_paths(Scene *scene, View3D *v3d, ARegion *ar, Object *ob)
-{
- bAnimVizSettings *avs = &ob->pose->avs;
- bArmature *arm = ob->data;
- bPoseChannel *pchan;
-
- /* setup drawing environment for paths */
- draw_motion_paths_init(v3d, ar);
-
- /* draw paths where they exist and they releated bone is visible */
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if ((pchan->bone->layer & arm->layer) && (pchan->mpath))
- draw_motion_path_instance(scene, ob, pchan, avs, pchan->mpath);
- }
-
- /* cleanup after drawing */
- draw_motion_paths_cleanup(v3d);
-}
-
-
-/* ---------- Ghosts --------- */
-
-/* helper function for ghost drawing - sets/removes flags for temporarily
- * hiding unselected bones while drawing ghosts
- */
-static void ghost_poses_tag_unselected(Object *ob, short unset)
-{
- bArmature *arm = ob->data;
- bPose *pose = ob->pose;
- bPoseChannel *pchan;
-
- /* don't do anything if no hiding any bones */
- if ((arm->flag & ARM_GHOST_ONLYSEL) == 0)
- return;
-
- /* loop over all pchans, adding/removing tags as appropriate */
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- if ((pchan->bone) && (arm->layer & pchan->bone->layer)) {
- if (unset) {
- /* remove tags from all pchans if cleaning up */
- pchan->bone->flag &= ~BONE_HIDDEN_PG;
- }
- else {
- /* set tags on unselected pchans only */
- if ((pchan->bone->flag & BONE_SELECTED) == 0)
- pchan->bone->flag |= BONE_HIDDEN_PG;
- }
- }
- }
-}
-
-/* draw ghosts that occur within a frame range
- * note: object should be in posemode
- */
-static void draw_ghost_poses_range(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, ARegion *ar, Base *base)
-{
- Object *ob = base->object;
- AnimData *adt = BKE_animdata_from_id(&ob->id);
- bArmature *arm = ob->data;
- bPose *posen, *poseo;
- float start, end, stepsize, range, colfac;
- int cfrao, flago;
- unsigned char col[4];
-
- start = (float)arm->ghostsf;
- end = (float)arm->ghostef;
- if (end <= start)
- return;
-
- /* prevent infinite loops if this is set to 0 - T49527 */
- if (arm->ghostsize < 1)
- arm->ghostsize = 1;
-
- stepsize = (float)(arm->ghostsize);
- range = (float)(end - start);
-
- /* store values */
- ob->mode &= ~OB_MODE_POSE;
- cfrao = CFRA;
- flago = arm->flag;
- arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES);
-
- /* copy the pose */
- poseo = ob->pose;
- BKE_pose_copy_data(&posen, ob->pose, 1);
- ob->pose = posen;
- BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */
- ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */
-
- glEnable(GL_BLEND);
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- /* draw from first frame of range to last */
- for (CFRA = (int)start; CFRA <= end; CFRA += (int)stepsize) {
- colfac = (end - (float)CFRA) / range;
- UI_GetThemeColorShadeAlpha4ubv(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac)), col);
-
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(eval_ctx, scene, ob);
- draw_pose_bones(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
- }
- glDisable(GL_BLEND);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-
- /* before disposing of temp pose, use it to restore object to a sane state */
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)cfrao, ADT_RECALC_ALL);
-
- /* clean up temporary pose */
- ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */
- BKE_pose_free(posen);
-
- /* restore */
- CFRA = cfrao;
- ob->pose = poseo;
- arm->flag = flago;
- ob->mode |= OB_MODE_POSE;
-}
-
-/* draw ghosts on keyframes in action within range
- * - object should be in posemode
- */
-static void draw_ghost_poses_keys(
- const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
- View3D *v3d, ARegion *ar, Base *base)
-{
- Object *ob = base->object;
- AnimData *adt = BKE_animdata_from_id(&ob->id);
- bAction *act = (adt) ? adt->action : NULL;
- bArmature *arm = ob->data;
- bPose *posen, *poseo;
- DLRBT_Tree keys;
- ActKeyColumn *ak, *akn;
- float start, end, range, colfac, i;
- int cfrao, flago;
- unsigned char col[4];
-
- start = (float)arm->ghostsf;
- end = (float)arm->ghostef;
- if (end <= start)
- return;
-
- /* get keyframes - then clip to only within range */
- BLI_dlrbTree_init(&keys);
- action_to_keylist(adt, act, &keys, NULL);
- BLI_dlrbTree_linkedlist_sync(&keys);
-
- range = 0;
- for (ak = keys.first; ak; ak = akn) {
- akn = ak->next;
-
- if ((ak->cfra < start) || (ak->cfra > end))
- BLI_freelinkN((ListBase *)&keys, ak);
- else
- range++;
- }
- if (range == 0) return;
-
- /* store values */
- ob->mode &= ~OB_MODE_POSE;
- cfrao = CFRA;
- flago = arm->flag;
- arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES);
-
- /* copy the pose */
- poseo = ob->pose;
- BKE_pose_copy_data(&posen, ob->pose, 1);
- ob->pose = posen;
- BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */
- ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */
-
- glEnable(GL_BLEND);
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- /* draw from first frame of range to last */
- for (ak = keys.first, i = 0; ak; ak = ak->next, i++) {
- colfac = i / range;
- UI_GetThemeColorShadeAlpha4ubv(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac)), col);
-
- CFRA = (int)ak->cfra;
-
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(eval_ctx, scene, ob);
- draw_pose_bones(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
- }
- glDisable(GL_BLEND);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-
- /* before disposing of temp pose, use it to restore object to a sane state */
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)cfrao, ADT_RECALC_ALL);
-
- /* clean up temporary pose */
- ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */
- BLI_dlrbTree_free(&keys);
- BKE_pose_free(posen);
-
- /* restore */
- CFRA = cfrao;
- ob->pose = poseo;
- arm->flag = flago;
- ob->mode |= OB_MODE_POSE;
-}
-
-/* draw ghosts around current frame
- * - object is supposed to be armature in posemode
- */
-static void draw_ghost_poses(
- const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
- View3D *v3d, ARegion *ar, Base *base)
-{
- Object *ob = base->object;
- AnimData *adt = BKE_animdata_from_id(&ob->id);
- bArmature *arm = ob->data;
- bPose *posen, *poseo;
- float cur, start, end, stepsize, range, colfac, actframe, ctime;
- int cfrao, flago;
- unsigned char col[4];
-
- /* pre conditions, get an action with sufficient frames */
- if (ELEM(NULL, adt, adt->action))
- return;
-
- calc_action_range(adt->action, &start, &end, 0);
- if (start == end)
- return;
-
- /* prevent infinite loops if this is set to 0 - T49527 */
- if (arm->ghostsize < 1)
- arm->ghostsize = 1;
-
- stepsize = (float)(arm->ghostsize);
- range = (float)(arm->ghostep) * stepsize + 0.5f; /* plus half to make the for loop end correct */
-
- /* store values */
- ob->mode &= ~OB_MODE_POSE;
- cfrao = CFRA;
- actframe = BKE_nla_tweakedit_remap(adt, (float)CFRA, 0);
- flago = arm->flag;
- arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES);
-
- /* copy the pose */
- poseo = ob->pose;
- BKE_pose_copy_data(&posen, ob->pose, 1);
- ob->pose = posen;
- BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */
- ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */
-
- glEnable(GL_BLEND);
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- /* draw from darkest blend to lowest */
- for (cur = stepsize; cur < range; cur += stepsize) {
- ctime = cur - (float)fmod(cfrao, stepsize); /* ensures consistent stepping */
- colfac = ctime / range;
- UI_GetThemeColorShadeAlpha4ubv(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac)), col);
-
- /* only within action range */
- if (actframe + ctime >= start && actframe + ctime <= end) {
- CFRA = (int)BKE_nla_tweakedit_remap(adt, actframe + ctime, NLATIME_CONVERT_MAP);
-
- if (CFRA != cfrao) {
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(eval_ctx, scene, ob);
- draw_pose_bones(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
- }
- }
-
- ctime = cur + (float)fmod((float)cfrao, stepsize) - stepsize + 1.0f; /* ensures consistent stepping */
- colfac = ctime / range;
- UI_GetThemeColorShadeAlpha4ubv(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac)), col);
-
- /* only within action range */
- if ((actframe - ctime >= start) && (actframe - ctime <= end)) {
- CFRA = (int)BKE_nla_tweakedit_remap(adt, actframe - ctime, NLATIME_CONVERT_MAP);
-
- if (CFRA != cfrao) {
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
- BKE_pose_where_is(eval_ctx, scene, ob);
- draw_pose_bones(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, col, true, false);
- }
- }
- }
- glDisable(GL_BLEND);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-
- /* before disposing of temp pose, use it to restore object to a sane state */
- BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)cfrao, ADT_RECALC_ALL);
-
- /* clean up temporary pose */
- ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */
- BKE_pose_free(posen);
-
- /* restore */
- CFRA = cfrao;
- ob->pose = poseo;
- arm->flag = flago;
- ob->mode |= OB_MODE_POSE;
-}
-
-/* ********************************** Armature Drawing - Main ************************* */
-
-/* called from drawobject.c, return true if nothing was drawn
- * (ob_wire_col == NULL) when drawing ghost */
-bool draw_armature(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, ARegion *ar, Base *base,
- const short dt, const short dflag, const unsigned char ob_wire_col[4],
- const bool is_outline)
-{
- Object *ob = base->object;
- bArmature *arm = ob->data;
- bool retval = false;
-
- if (v3d->flag2 & V3D_RENDER_OVERRIDE)
- return true;
-
-#if 0 /* Not used until lighting is properly reimplemented */
- if (dt > OB_WIRE) {
- /* we use color for solid lighting */
- if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
- const float diffuse[3] = {0.64f, 0.64f, 0.64f};
- const float specular[3] = {0.5f, 0.5f, 0.5f};
- GPU_basic_shader_colors(diffuse, specular, 35, 1.0f);
- }
- else {
- const float diffuse[3] = {1.0f, 1.0f, 1.0f};
- const float specular[3] = {1.0f, 1.0f, 1.0f};
- GPU_basic_shader_colors(diffuse, specular, 35, 1.0f);
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); /* only for lighting... */
- }
- }
-#endif
-
- /* arm->flag is being used to detect mode... */
- /* editmode? */
- if (arm->edbo) {
- arm->flag |= ARM_EDITMODE;
- draw_ebones(v3d, ar, ob, dt);
- arm->flag &= ~ARM_EDITMODE;
- }
- else {
- /* Draw Pose */
- if (ob->pose && ob->pose->chanbase.first) {
- /* We can't safely draw non-updated pose, might contain NULL bone pointers... */
- if (ob->pose->flag & POSE_RECALC) {
- BKE_pose_rebuild(ob, arm);
- }
-
- /* drawing posemode selection indices or colors only in these cases */
- if (!(base->flag_legacy & OB_FROMDUPLI)) {
- if (G.f & G_PICKSEL) {
-#if 0
- /* nifty but actually confusing to allow bone selection out of posemode */
- if (OBACT && (OBACT->mode & OB_MODE_WEIGHT_PAINT)) {
- if (ob == modifiers_isDeformedByArmature(OBACT))
- arm->flag |= ARM_POSEMODE;
- }
- else
-#endif
- if (ob->mode & OB_MODE_POSE) {
- arm->flag |= ARM_POSEMODE;
- }
- }
- else if (ob->mode & OB_MODE_POSE) {
- if (arm->ghosttype == ARM_GHOST_RANGE) {
- draw_ghost_poses_range(eval_ctx, scene, view_layer, v3d, ar, base);
- }
- else if (arm->ghosttype == ARM_GHOST_KEYS) {
- draw_ghost_poses_keys(eval_ctx, scene, view_layer, v3d, ar, base);
- }
- else if (arm->ghosttype == ARM_GHOST_CUR) {
- if (arm->ghostep)
- draw_ghost_poses(eval_ctx, scene, view_layer, v3d, ar, base);
- }
- if ((dflag & DRAW_SCENESET) == 0) {
- if (ob == OBACT(view_layer))
- arm->flag |= ARM_POSEMODE;
- else if (OBACT(view_layer) && (OBACT(view_layer)->mode & OB_MODE_WEIGHT_PAINT)) {
- if (ob == modifiers_isDeformedByArmature(OBACT(view_layer)))
- arm->flag |= ARM_POSEMODE;
- }
- draw_pose_paths(scene, v3d, ar, ob);
- }
- }
- }
- draw_pose_bones(eval_ctx, scene, view_layer, v3d, ar, base, dt, ob_wire_col, (dflag & DRAW_CONSTCOLOR), is_outline);
- arm->flag &= ~ARM_POSEMODE;
- }
- else {
- retval = true;
- }
- }
- /* restore */
- glFrontFace(GL_CCW);
-
- return retval;
-}
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
deleted file mode 100644
index 0d4ec4d42d1..00000000000
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ /dev/null
@@ -1,366 +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.
- *
- * Contributor(s): Blender Foundation, full update, glsl support
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_view3d/drawmesh.c
- * \ingroup spview3d
- */
-
-#include <string.h>
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_bitmap.h"
-#include "BLI_math.h"
-
-#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_node_types.h"
-#include "DNA_object_types.h"
-#include "DNA_property_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_view3d_types.h"
-
-#include "BKE_DerivedMesh.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_material.h"
-#include "BKE_paint.h"
-#include "BKE_property.h"
-#include "BKE_editmesh.h"
-#include "BKE_scene.h"
-
-#include "BIF_glutil.h"
-
-#include "UI_resources.h"
-
-#include "GPU_draw.h"
-#include "GPU_material.h"
-#include "GPU_basic_shader.h"
-#include "GPU_shader.h"
-#include "GPU_matrix.h"
-
-#include "RE_engine.h"
-
-#include "ED_uvedit.h"
-
-#include "view3d_intern.h" /* own include */
-
-/* user data structures for derived mesh callbacks */
-typedef struct drawMeshFaceSelect_userData {
- Mesh *me;
- BLI_bitmap *edge_flags; /* pairs of edge options (visible, select) */
-} drawMeshFaceSelect_userData;
-
-/**************************** Face Select Mode *******************************/
-
-/* mainly to be less confusing */
-BLI_INLINE int edge_vis_index(const int index) { return index * 2; }
-BLI_INLINE int edge_sel_index(const int index) { return index * 2 + 1; }
-
-static BLI_bitmap *get_tface_mesh_marked_edge_info(Mesh *me, bool draw_select_edges)
-{
- BLI_bitmap *bitmap_edge_flags = BLI_BITMAP_NEW(me->totedge * 2, __func__);
- MPoly *mp;
- MLoop *ml;
- int i, j;
- bool select_set;
-
- for (i = 0; i < me->totpoly; i++) {
- mp = &me->mpoly[i];
-
- if (!(mp->flag & ME_HIDE)) {
- select_set = (mp->flag & ME_FACE_SEL) != 0;
-
- ml = me->mloop + mp->loopstart;
- for (j = 0; j < mp->totloop; j++, ml++) {
- if ((draw_select_edges == false) &&
- (select_set && BLI_BITMAP_TEST(bitmap_edge_flags, edge_sel_index(ml->e))))
- {
- BLI_BITMAP_DISABLE(bitmap_edge_flags, edge_vis_index(ml->e));
- }
- else {
- BLI_BITMAP_ENABLE(bitmap_edge_flags, edge_vis_index(ml->e));
- if (select_set) {
- BLI_BITMAP_ENABLE(bitmap_edge_flags, edge_sel_index(ml->e));
- }
- }
- }
- }
- }
-
- return bitmap_edge_flags;
-}
-
-
-static DMDrawOption draw_mesh_face_select__setHiddenOpts(void *userData, int index)
-{
- drawMeshFaceSelect_userData *data = userData;
- Mesh *me = data->me;
-
- if (me->drawflag & ME_DRAWEDGES) {
- if ((BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index))))
- return DM_DRAW_OPTION_NORMAL;
- else
- return DM_DRAW_OPTION_SKIP;
- }
- else if (BLI_BITMAP_TEST(data->edge_flags, edge_sel_index(index)) &&
- BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index)))
- {
- return DM_DRAW_OPTION_NORMAL;
- }
- else {
- return DM_DRAW_OPTION_SKIP;
- }
-}
-
-static DMDrawOption draw_mesh_face_select__setSelectOpts(void *userData, int index)
-{
- drawMeshFaceSelect_userData *data = userData;
- return (BLI_BITMAP_TEST(data->edge_flags, edge_sel_index(index)) &&
- BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index))) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
-}
-
-/* draws unselected */
-static DMDrawOption draw_mesh_face_select__drawFaceOptsInv(void *userData, int index)
-{
- Mesh *me = (Mesh *)userData;
-
- MPoly *mpoly = &me->mpoly[index];
- if (!(mpoly->flag & ME_HIDE) && !(mpoly->flag & ME_FACE_SEL))
- return DM_DRAW_OPTION_NORMAL;
- else
- return DM_DRAW_OPTION_SKIP;
-}
-
-void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm, bool draw_select_edges)
-{
- drawMeshFaceSelect_userData data;
-
- data.me = me;
- data.edge_flags = get_tface_mesh_marked_edge_info(me, draw_select_edges);
-
- glEnable(GL_DEPTH_TEST);
- ED_view3d_polygon_offset(rv3d, 1.0);
-
- /* Draw (Hidden) Edges */
- setlinestyle(1);
- UI_ThemeColor(TH_EDGE_FACESEL);
- dm->drawMappedEdges(dm, draw_mesh_face_select__setHiddenOpts, &data);
- setlinestyle(0);
-
- /* Draw Selected Faces */
- if (me->drawflag & ME_DRAWFACES) {
- glEnable(GL_BLEND);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- /* dull unselected faces so as not to get in the way of seeing color */
- glColor4ub(96, 96, 96, 64);
- dm->drawMappedFaces(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, NULL, (void *)me, DM_DRAW_SKIP_HIDDEN);
- glDisable(GL_BLEND);
- }
-
- ED_view3d_polygon_offset(rv3d, 1.0);
-
- /* Draw Stippled Outline for selected faces */
- glColor3ub(255, 255, 255);
- setlinestyle(1);
- dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data);
- setlinestyle(0);
-
- ED_view3d_polygon_offset(rv3d, 0.0); /* resets correctly now, even after calling accumulated offsets */
-
- MEM_freeN(data.edge_flags);
-}
-
-/***************************** Texture Drawing ******************************/
-
-/* when face select is on, use face hidden flag */
-static DMDrawOption wpaint__setSolidDrawOptions_facemask(void *userData, int index)
-{
- Mesh *me = (Mesh *)userData;
- MPoly *mp = &me->mpoly[index];
- if (mp->flag & ME_HIDE)
- return DM_DRAW_OPTION_SKIP;
- return DM_DRAW_OPTION_NORMAL;
-}
-
-/************************** NEW SHADING NODES ********************************/
-
-typedef struct TexMatCallback {
- Scene *scene;
- Object *ob;
- Mesh *me;
- DerivedMesh *dm;
- bool shadeless;
- bool two_sided_lighting;
-} TexMatCallback;
-
-void draw_mesh_textured(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d,
- Object *ob, DerivedMesh *dm, const int draw_flags)
-{
- UNUSED_VARS(scene, view_layer, v3d, rv3d, ob, dm, draw_flags);
- return;
-}
-
-/* Vertex Paint and Weight Paint */
-static void draw_mesh_paint_light_begin(void)
-{
- /* get material diffuse color from vertex colors but set default spec */
- const float specular[3] = {0.47f, 0.47f, 0.47f};
- GPU_basic_shader_colors(NULL, specular, 35, 1.0f);
- GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
-}
-
-static void draw_mesh_paint_light_end(void)
-{
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
-}
-
-void draw_mesh_paint_weight_faces(DerivedMesh *dm, const bool use_light,
- void *facemask_cb, void *user_data)
-{
- DMSetMaterial setMaterial = GPU_object_materials_check() ? GPU_object_material_bind : NULL;
- int flags = DM_DRAW_USE_COLORS;
-
- if (use_light) {
- draw_mesh_paint_light_begin();
- flags |= DM_DRAW_NEED_NORMALS;
- }
-
- dm->drawMappedFaces(dm, (DMSetDrawOptions)facemask_cb, setMaterial, NULL, user_data, flags);
-
- if (use_light) {
- draw_mesh_paint_light_end();
- }
-}
-
-void draw_mesh_paint_vcolor_faces(DerivedMesh *dm, const bool use_light,
- void *facemask_cb, void *user_data,
- const Mesh *me)
-{
- DMSetMaterial setMaterial = GPU_object_materials_check() ? GPU_object_material_bind : NULL;
- int flags = 0;
-
- if (use_light) {
- draw_mesh_paint_light_begin();
- flags |= DM_DRAW_NEED_NORMALS;
- }
-
- if (me->mloopcol) {
- dm->drawMappedFaces(dm, facemask_cb, setMaterial, NULL, user_data,
- DM_DRAW_USE_COLORS | flags);
- }
- else {
- glColor3f(1.0f, 1.0f, 1.0f);
- dm->drawMappedFaces(dm, facemask_cb, setMaterial, NULL, user_data, flags);
- }
-
- if (use_light) {
- draw_mesh_paint_light_end();
- }
-}
-
-void draw_mesh_paint_weight_edges(RegionView3D *rv3d, DerivedMesh *dm,
- const bool use_depth, const bool use_alpha,
- void *edgemask_cb, void *user_data)
-{
- /* weight paint in solid mode, special case. focus on making the weights clear
- * rather than the shading, this is also forced in wire view */
-
- if (use_depth) {
- ED_view3d_polygon_offset(rv3d, 1.0);
- glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
- }
- else {
- glDisable(GL_DEPTH_TEST);
- }
-
- if (use_alpha) {
- glEnable(GL_BLEND);
- }
-
- glColor4ub(255, 255, 255, 96);
- GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
- GPU_basic_shader_line_stipple(1, 0xAAAA);
-
- dm->drawMappedEdges(dm, (DMSetDrawOptions)edgemask_cb, user_data);
-
- if (use_depth) {
- ED_view3d_polygon_offset(rv3d, 0.0);
- glDepthMask(1);
- }
- else {
- glEnable(GL_DEPTH_TEST);
- }
-
- GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
-
- if (use_alpha) {
- glDisable(GL_BLEND);
- }
-}
-
-void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
- Object *ob, DerivedMesh *dm, const int draw_flags)
-{
- DMSetDrawOptions facemask = NULL;
- Mesh *me = ob->data;
- const bool use_light = (v3d->drawtype >= OB_SOLID);
-
- /* hide faces in face select mode */
- if (me->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL))
- facemask = wpaint__setSolidDrawOptions_facemask;
-
- if (ob->mode & OB_MODE_WEIGHT_PAINT) {
- draw_mesh_paint_weight_faces(dm, use_light, facemask, me);
- }
- else if (ob->mode & OB_MODE_VERTEX_PAINT) {
- draw_mesh_paint_vcolor_faces(dm, use_light, facemask, me, me);
- }
-
- /* draw face selection on top */
- if (draw_flags & DRAW_FACE_SELECT) {
- bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0;
- draw_mesh_face_select(rv3d, me, dm, draw_select_edges);
- }
- else if ((use_light == false) || (ob->dtx & OB_DRAWWIRE)) {
- const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT);
- const bool use_alpha = (ob->mode & OB_MODE_VERTEX_PAINT) == 0;
-
- if (use_alpha == false) {
- set_inverted_drawing(1);
- }
-
- draw_mesh_paint_weight_edges(rv3d, dm, use_depth, use_alpha, NULL, NULL);
-
- if (use_alpha == false) {
- set_inverted_drawing(0);
- }
- }
-}
-
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 93bcbc3ea0c..8e04a2e17b8 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -83,6 +83,7 @@
#include "BKE_editmesh.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -115,136 +116,6 @@
#include "../../draw/intern/draw_cache_impl.h" /* bad level include (temporary) */
-/* prototypes */
-static void imm_draw_box(const float vec[8][3], bool solid, unsigned pos);
-
-// #define USE_MESH_DM_SELECT
-
-/* Workaround for sequencer scene render mode.
- *
- * Strips doesn't use DAG to update objects or so, which
- * might lead to situations when object is drawing without
- * curve cache ready.
- *
- * Ideally we don't want to evaluate objects from drawing,
- * but it'll require some major sequencer re-design. So
- * for now just fallback to legacy behavior with calling
- * display ist creating from draw().
- */
-#define SEQUENCER_DAG_WORKAROUND
-
-typedef enum eWireDrawMode {
- OBDRAW_WIRE_OFF = 0,
- OBDRAW_WIRE_ON = 1,
- OBDRAW_WIRE_ON_DEPTH = 2
-} eWireDrawMode;
-
-typedef struct drawDMVerts_userData {
- BMesh *bm;
-
- BMVert *eve_act;
- char sel;
- unsigned int pos, color;
-
- /* cached theme values */
- unsigned char th_editmesh_active[4];
- unsigned char th_vertex_select[4];
- unsigned char th_vertex[4];
- unsigned char th_skin_root[4];
-
- /* for skin node drawing */
- int cd_vskin_offset;
- float imat[4][4];
-} drawDMVerts_userData;
-
-typedef struct drawDMEdgesSel_userData {
- BMesh *bm;
-
- unsigned char *baseCol, *selCol, *actCol;
- BMEdge *eed_act;
-} drawDMEdgesSel_userData;
-
-typedef struct drawDMEdgesSelInterp_userData {
- BMesh *bm;
-
- unsigned char *baseCol, *selCol;
- unsigned char *lastCol;
-} drawDMEdgesSelInterp_userData;
-
-typedef struct drawDMEdgesWeightInterp_userData {
- BMesh *bm;
-
- int cd_dvert_offset;
- int defgroup_tot;
- int vgroup_index;
- char weight_user;
- float alert_color[3];
-
-} drawDMEdgesWeightInterp_userData;
-
-typedef struct drawDMFacesSel_userData {
-#ifdef WITH_FREESTYLE
- unsigned char *cols[4];
-#else
- unsigned char *cols[3];
-#endif
-
- DerivedMesh *dm;
- BMesh *bm;
-
- BMFace *efa_act;
- const int *orig_index_mp_to_orig;
-} drawDMFacesSel_userData;
-
-typedef struct drawDMNormal_userData {
- unsigned int pos;
- BMesh *bm;
- int uniform_scale;
- float normalsize;
- float tmat[3][3];
- float imat[3][3];
-} drawDMNormal_userData;
-
-typedef struct drawMVertOffset_userData {
- unsigned int pos, col;
- MVert *mvert;
- int offset;
-} drawMVertOffset_userData;
-
-typedef struct drawDMLayer_userData {
- BMesh *bm;
- int cd_layer_offset;
- unsigned int pos, col;
-} drawDMLayer_userData;
-
-typedef struct drawBMOffset_userData {
- unsigned int pos, col;
- BMesh *bm;
- int offset;
-} drawBMOffset_userData;
-
-typedef struct drawBMSelect_userData {
- BMesh *bm;
- bool select;
- unsigned int pos;
-} drawBMSelect_userData;
-
-
-static void drawcube_size(float size, unsigned pos);
-static void drawcircle_size(float size, unsigned pos);
-static void draw_empty_sphere(float size, unsigned pos);
-static void draw_empty_cone(float size, unsigned pos);
-
-static void ob_wire_color_blend_theme_id(const unsigned char ob_wire_col[4], const int theme_id, float fac, float r_col[3])
-{
- float col_wire[3], col_bg[3];
-
- rgb_uchar_to_float(col_wire, ob_wire_col);
-
- UI_GetThemeColor3fv(theme_id, col_bg);
- interp_v3_v3v3(r_col, col_bg, col_wire, fac);
-}
-
int view3d_effective_drawtype(const struct View3D *v3d)
{
if (v3d->drawtype == OB_RENDER) {
@@ -253,42 +124,6 @@ int view3d_effective_drawtype(const struct View3D *v3d)
return v3d->drawtype;
}
-/* this condition has been made more complex since editmode can draw textures */
-bool check_object_draw_texture(Scene *scene, View3D *v3d, const char drawtype)
-{
- const int v3d_drawtype = view3d_effective_drawtype(v3d);
- /* texture and material draw modes */
- if (ELEM(v3d_drawtype, OB_TEXTURE, OB_MATERIAL) && drawtype > OB_SOLID) {
- return true;
- }
-
- /* textured solid */
- if ((v3d_drawtype == OB_SOLID) &&
- (v3d->flag2 & V3D_SOLID_TEX) &&
- (BKE_scene_use_new_shading_nodes(scene) == false))
- {
- return true;
- }
-
- if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) {
- return true;
- }
-
- return false;
-}
-
-static bool check_object_draw_editweight(Mesh *me, DerivedMesh *finalDM)
-{
- if (me->drawflag & ME_DRAWEIGHT) {
- /* editmesh handles its own weight drawing */
- if (finalDM->type != DM_TYPE_EDITBMESH) {
- return true;
- }
- }
-
- return false;
-}
-
static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
{
if ((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0)
@@ -310,49 +145,6 @@ static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
return true;
}
-/* ************************ */
-
-/* check for glsl drawing */
-
-bool draw_glsl_material(Scene *scene, ViewLayer *view_layer, Object *ob, View3D *v3d, const char dt)
-{
- if (G.f & G_PICKSEL)
- return false;
- if (!check_object_draw_texture(scene, v3d, dt))
- return false;
- if (ob == OBACT(view_layer) && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
- return false;
-
- if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP)
- return true;
-
- if (v3d->drawtype == OB_TEXTURE)
- return (scene->gm.matmode == GAME_MAT_GLSL && !BKE_scene_use_new_shading_nodes(scene));
- else if (v3d->drawtype == OB_MATERIAL && dt > OB_SOLID)
- return true;
- else
- return false;
-}
-
-static bool check_alpha_pass(Base *base)
-{
- if (base->flag_legacy & OB_FROMDUPLI)
- return false;
-
- if (G.f & G_PICKSEL)
- return false;
-
- if (base->object->mode & OB_MODE_ALL_PAINT)
- return false;
-
- return (base->object->dtx & OB_DRAWTRANSP);
-}
-
-/***/
-static const unsigned int colortab[] = {
- 0x0, 0x403000, 0xFFFF88
-};
-
/* ----------------- OpenGL Circle Drawing - Tables for Optimized Drawing Speed ------------------ */
/* 32 values of sin function (still same result!) */
#define CIRCLE_RESOL 32
@@ -428,365 +220,6 @@ static const float cosval[CIRCLE_RESOL] = {
1.00000000
};
-/**
- * \param viewmat_local_unit is typically the 'rv3d->viewmatob'
- * copied into a 3x3 matrix and normalized.
- */
-static void draw_xyz_wire(const float viewmat_local_unit[3][3], const float c[3], float size, int axis, unsigned pos)
-{
- Gwn_PrimType line_type = GWN_PRIM_LINES;
- float buffer[4][3];
- int n = 0;
-
- float v1[3] = {0.0f, 0.0f, 0.0f}, v2[3] = {0.0f, 0.0f, 0.0f};
- float dim = size * 0.1f;
- float dx[3], dy[3];
-
- dx[0] = dim; dx[1] = 0.0f; dx[2] = 0.0f;
- dy[0] = 0.0f; dy[1] = dim; dy[2] = 0.0f;
-
- switch (axis) {
- case 0: /* x axis */
- /* bottom left to top right */
- negate_v3_v3(v1, dx);
- sub_v3_v3(v1, dy);
- copy_v3_v3(v2, dx);
- add_v3_v3(v2, dy);
-
- copy_v3_v3(buffer[n++], v1);
- copy_v3_v3(buffer[n++], v2);
-
- /* top left to bottom right */
- mul_v3_fl(dy, 2.0f);
- add_v3_v3(v1, dy);
- sub_v3_v3(v2, dy);
-
- copy_v3_v3(buffer[n++], v1);
- copy_v3_v3(buffer[n++], v2);
-
- break;
- case 1: /* y axis */
- /* bottom left to top right */
- mul_v3_fl(dx, 0.75f);
- negate_v3_v3(v1, dx);
- sub_v3_v3(v1, dy);
- copy_v3_v3(v2, dx);
- add_v3_v3(v2, dy);
-
- copy_v3_v3(buffer[n++], v1);
- copy_v3_v3(buffer[n++], v2);
-
- /* top left to center */
- mul_v3_fl(dy, 2.0f);
- add_v3_v3(v1, dy);
- zero_v3(v2);
-
- copy_v3_v3(buffer[n++], v1);
- copy_v3_v3(buffer[n++], v2);
-
- break;
- case 2: /* z axis */
- line_type = GWN_PRIM_LINE_STRIP;
-
- /* start at top left */
- negate_v3_v3(v1, dx);
- add_v3_v3(v1, dy);
-
- copy_v3_v3(buffer[n++], v1);
-
- mul_v3_fl(dx, 2.0f);
- add_v3_v3(v1, dx);
-
- copy_v3_v3(buffer[n++], v1);
-
- mul_v3_fl(dy, 2.0f);
- sub_v3_v3(v1, dx);
- sub_v3_v3(v1, dy);
-
- copy_v3_v3(buffer[n++], v1);
-
- add_v3_v3(v1, dx);
-
- copy_v3_v3(buffer[n++], v1);
-
- break;
- default:
- BLI_assert(0);
- return;
- }
-
- immBegin(line_type, n);
- for (int i = 0; i < n; i++) {
- mul_transposed_m3_v3((float (*)[3])viewmat_local_unit, buffer[i]);
- add_v3_v3(buffer[i], c);
- immVertex3fv(pos, buffer[i]);
- }
- immEnd();
-
- /* TODO: recode this function for clarity once we're not in a hurry to modernize GL usage */
-}
-
-void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const unsigned char color[4])
-{
- int axis;
- float v1[3] = {0.0, 0.0, 0.0};
- float v2[3] = {0.0, 0.0, 0.0};
- float v3[3] = {0.0, 0.0, 0.0};
-
- glLineWidth(1.0f);
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- if (color) {
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4ubv(color);
- }
- else {
- immBindBuiltinProgram(GPU_SHADER_3D_DEPTH_ONLY);
- }
-
- switch (drawtype) {
- case OB_PLAINAXES:
- immBegin(GWN_PRIM_LINES, 6);
- for (axis = 0; axis < 3; axis++) {
- v1[axis] = size;
- v2[axis] = -size;
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
-
- /* reset v1 & v2 to zero */
- v1[axis] = v2[axis] = 0.0f;
- }
- immEnd();
- break;
-
- case OB_SINGLE_ARROW:
- immBegin(GWN_PRIM_LINES, 2);
- /* in positive z direction only */
- v1[2] = size;
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
- immEnd();
-
- /* square pyramid */
- immBegin(GWN_PRIM_TRIS, 12);
-
- v2[0] = size * 0.035f; v2[1] = size * 0.035f;
- v3[0] = size * -0.035f; v3[1] = size * 0.035f;
- v2[2] = v3[2] = size * 0.75f;
-
- for (axis = 0; axis < 4; axis++) {
- if (axis % 2 == 1) {
- v2[0] = -v2[0];
- v3[1] = -v3[1];
- }
- else {
- v2[1] = -v2[1];
- v3[0] = -v3[0];
- }
-
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
- immVertex3fv(pos, v3);
- }
- immEnd();
- break;
-
- case OB_CUBE:
- drawcube_size(size, pos);
- break;
-
- case OB_CIRCLE:
- drawcircle_size(size, pos);
- break;
-
- case OB_EMPTY_SPHERE:
- draw_empty_sphere(size, pos);
- break;
-
- case OB_EMPTY_CONE:
- draw_empty_cone(size, pos);
- break;
-
- case OB_ARROWS:
- default:
- {
- float viewmat_local_unit[3][3];
-
- copy_m3_m4(viewmat_local_unit, (float (*)[4])viewmat_local);
- normalize_m3(viewmat_local_unit);
-
- for (axis = 0; axis < 3; axis++) {
- const int arrow_axis = (axis == 0) ? 1 : 0;
-
- immBegin(GWN_PRIM_LINES, 6);
-
- v2[axis] = size;
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
-
- v1[axis] = size * 0.85f;
- v1[arrow_axis] = -size * 0.08f;
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
-
- v1[arrow_axis] = size * 0.08f;
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
-
- immEnd();
-
- v2[axis] += size * 0.125f;
-
- draw_xyz_wire(viewmat_local_unit, v2, size, axis, pos);
-
- /* reset v1 & v2 to zero */
- v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f;
- }
- }
- }
-
- immUnbindProgram();
-}
-
-
-/* Function to draw an Image on an empty Object */
-static void draw_empty_image(Object *ob, const short dflag, const unsigned char ob_wire_col[4], eStereoViews sview)
-{
- Image *ima = ob->data;
-
- const float ob_alpha = ob->col[3];
- float ima_x, ima_y;
-
- int bindcode = 0;
-
- if (ima) {
- ImageUser iuser = *ob->iuser;
-
- /* Support multi-view */
- if (ima && (sview == STEREO_RIGHT_ID)) {
- iuser.multiview_eye = sview;
- iuser.flag |= IMA_SHOW_STEREO;
- BKE_image_multiview_index(ima, &iuser);
- }
-
- if (ob_alpha > 0.0f) {
- bindcode = GPU_verify_image(ima, &iuser, GL_TEXTURE_2D, 0, false, false, false);
- /* don't bother drawing the image if alpha = 0 */
- }
-
- int w, h;
- BKE_image_get_size(ima, &iuser, &w, &h);
- ima_x = w;
- ima_y = h;
- }
- else {
- /* if no image, make it a 1x1 empty square, honor scale & offset */
- ima_x = ima_y = 1.0f;
- }
-
- /* Get the image aspect even if the buffer is invalid */
- float sca_x = 1.0f, sca_y = 1.0f;
- if (ima) {
- if (ima->aspx > ima->aspy) {
- sca_y = ima->aspy / ima->aspx;
- }
- else if (ima->aspx < ima->aspy) {
- sca_x = ima->aspx / ima->aspy;
- }
- }
-
- float scale_x;
- float scale_y;
- {
- const float scale_x_inv = ima_x * sca_x;
- const float scale_y_inv = ima_y * sca_y;
- if (scale_x_inv > scale_y_inv) {
- scale_x = ob->empty_drawsize;
- scale_y = ob->empty_drawsize * (scale_y_inv / scale_x_inv);
- }
- else {
- scale_x = ob->empty_drawsize * (scale_x_inv / scale_y_inv);
- scale_y = ob->empty_drawsize;
- }
- }
-
- const float ofs_x = ob->ima_ofs[0] * scale_x;
- const float ofs_y = ob->ima_ofs[1] * scale_y;
-
- const rctf rect = {
- .xmin = ofs_x,
- .xmax = ofs_x + scale_x,
- .ymin = ofs_y,
- .ymax = ofs_y + scale_y,
- };
-
- bool use_blend = false;
-
- if (bindcode) {
- use_blend = ob_alpha < 1.0f || BKE_image_has_alpha(ima);
-
- if (use_blend) {
- glEnable(GL_BLEND);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- }
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_IMAGE_MODULATE_ALPHA);
- immUniform1f("alpha", ob_alpha);
- immUniform1i("image", 0); /* default GL_TEXTURE0 unit */
-
- immBegin(GWN_PRIM_TRI_FAN, 4);
- immAttrib2f(texCoord, 0.0f, 0.0f);
- immVertex2f(pos, rect.xmin, rect.ymin);
-
- immAttrib2f(texCoord, 1.0f, 0.0f);
- immVertex2f(pos, rect.xmax, rect.ymin);
-
- immAttrib2f(texCoord, 1.0f, 1.0f);
- immVertex2f(pos, rect.xmax, rect.ymax);
-
- immAttrib2f(texCoord, 0.0f, 1.0f);
- immVertex2f(pos, rect.xmin, rect.ymax);
- immEnd();
-
- immUnbindProgram();
- }
-
- /* Draw the image outline */
- glLineWidth(1.5f);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-
- const bool picking = dflag & DRAW_CONSTCOLOR;
- if (picking) {
- /* TODO: deal with picking separately, use this function just to draw */
- immBindBuiltinProgram(GPU_SHADER_3D_DEPTH_ONLY);
- if (use_blend) {
- glDisable(GL_BLEND);
- }
-
- imm_draw_box_wire_2d(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
- }
- else {
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor3ubv(ob_wire_col);
- glEnable(GL_LINE_SMOOTH);
-
- if (!use_blend) {
- glEnable(GL_BLEND);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- }
-
- imm_draw_box_wire_2d(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
-
- glDisable(GL_LINE_SMOOTH);
- glDisable(GL_BLEND);
- }
-
- immUnbindProgram();
-}
-
static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, const float tmat[4][4])
{
float vx[3], vy[3];
@@ -815,8567 +248,11 @@ void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], un
immEnd();
}
-/* circle for object centers, special_color is for library or ob users */
-static void drawcentercircle(View3D *v3d, RegionView3D *UNUSED(rv3d), const float co[3], int selstate, bool special_color)
-{
- const float outlineWidth = 1.0f * U.pixelsize;
- const float size = U.obcenter_dia * U.pixelsize + outlineWidth;
-
- if (v3d->zbuf) {
- glDisable(GL_DEPTH_TEST);
- /* TODO(merwin): fit things like this into plates/buffers design */
- }
-
- glEnable(GL_BLEND);
- GPU_enable_program_point_size();
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA);
- immUniform1f("size", size);
-
- if (special_color) {
- if (selstate == ACTIVE || selstate == SELECT) immUniformColor4ub(0x88, 0xFF, 0xFF, 155);
- else immUniformColor4ub(0x55, 0xCC, 0xCC, 155);
- }
- else {
- if (selstate == ACTIVE) immUniformThemeColorShadeAlpha(TH_ACTIVE, 0, -80);
- else if (selstate == SELECT) immUniformThemeColorShadeAlpha(TH_SELECT, 0, -80);
- else if (selstate == DESELECT) immUniformThemeColorShadeAlpha(TH_TRANSFORM, 0, -80);
- }
-
- /* set up outline */
- float outlineColor[4];
- UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, outlineColor);
- immUniform4fv("outlineColor", outlineColor);
- immUniform1f("outlineWidth", outlineWidth);
-
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3fv(pos, co);
- immEnd();
-
- immUnbindProgram();
-
- GPU_disable_program_point_size();
- glDisable(GL_BLEND);
-
- if (v3d->zbuf) {
- glEnable(GL_DEPTH_TEST);
- }
-}
-
-/* *********** text drawing for object/particles/armature ************* */
-
-typedef struct ViewCachedString {
- struct ViewCachedString *next;
- float vec[3];
- union {
- unsigned char ub[4];
- int pack;
- } col;
- short sco[2];
- short xoffs;
- short flag;
- int str_len;
-
- /* str is allocated past the end */
- char str[0];
-} ViewCachedString;
-
-/* one arena for all 3 string lists */
-static MemArena *g_v3d_strings_arena = NULL;
-static ViewCachedString *g_v3d_strings[3] = {NULL, NULL, NULL};
-static int g_v3d_string_level = -1;
-
-void view3d_cached_text_draw_begin(void)
-{
- g_v3d_string_level++;
-
- BLI_assert(g_v3d_string_level >= 0);
-
- if (g_v3d_string_level == 0) {
- BLI_assert(g_v3d_strings_arena == NULL);
- }
-}
-
-void view3d_cached_text_draw_add(const float co[3],
- const char *str, const size_t str_len,
- short xoffs, short flag,
- const unsigned char col[4])
-{
- int alloc_len = str_len + 1;
- ViewCachedString *vos;
-
- BLI_assert(str_len == strlen(str));
-
- if (g_v3d_strings_arena == NULL) {
- g_v3d_strings_arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 14), __func__);
- }
-
- vos = BLI_memarena_alloc(g_v3d_strings_arena, sizeof(ViewCachedString) + alloc_len);
-
- BLI_LINKS_PREPEND(g_v3d_strings[g_v3d_string_level], vos);
-
- copy_v3_v3(vos->vec, co);
- copy_v4_v4_uchar(vos->col.ub, col);
- vos->xoffs = xoffs;
- vos->flag = flag;
- vos->str_len = str_len;
-
- /* allocate past the end */
- memcpy(vos->str, str, alloc_len);
-}
-
-void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write)
-{
- RegionView3D *rv3d = ar->regiondata;
- ViewCachedString *vos;
- int tot = 0;
-
- BLI_assert(g_v3d_string_level >= 0 && g_v3d_string_level <= 2);
-
- /* project first and test */
- for (vos = g_v3d_strings[g_v3d_string_level]; vos; vos = vos->next) {
- if (ED_view3d_project_short_ex(ar,
- (vos->flag & V3D_CACHE_TEXT_GLOBALSPACE) ? rv3d->persmat : rv3d->persmatob,
- (vos->flag & V3D_CACHE_TEXT_LOCALCLIP) != 0,
- vos->vec, vos->sco,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
- {
- tot++;
- }
- else {
- vos->sco[0] = IS_CLIPPED;
- }
- }
-
- if (tot) {
- int col_pack_prev = 0;
-
- if (rv3d->rflag & RV3D_CLIPPING) {
- ED_view3d_clipping_disable();
- }
-
- float original_proj[4][4];
- gpuGetProjectionMatrix(original_proj);
- wmOrtho2_region_pixelspace(ar);
-
- gpuPushMatrix();
- gpuLoadIdentity();
-
- if (depth_write) {
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
- }
- else {
- glDepthMask(GL_FALSE);
- }
-
- const int font_id = BLF_default();
-
- for (vos = g_v3d_strings[g_v3d_string_level]; vos; vos = vos->next) {
- if (vos->sco[0] != IS_CLIPPED) {
- if (col_pack_prev != vos->col.pack) {
- BLF_color3ubv(font_id, vos->col.ub);
- col_pack_prev = vos->col.pack;
- }
-
- ((vos->flag & V3D_CACHE_TEXT_ASCII) ? BLF_draw_default_ascii : BLF_draw_default)(
- (float)(vos->sco[0] + vos->xoffs),
- (float)(vos->sco[1]),
- (depth_write) ? 0.0f : 2.0f,
- vos->str,
- vos->str_len);
- }
- }
-
- if (depth_write) {
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- }
- else {
- glDepthMask(GL_TRUE);
- }
-
- gpuPopMatrix();
- gpuLoadProjectionMatrix(original_proj);
-
- if (rv3d->rflag & RV3D_CLIPPING) {
- ED_view3d_clipping_enable();
- }
- }
-
- g_v3d_strings[g_v3d_string_level] = NULL;
-
- if (g_v3d_string_level == 0) {
- if (g_v3d_strings_arena) {
- BLI_memarena_free(g_v3d_strings_arena);
- g_v3d_strings_arena = NULL;
- }
- }
-
- g_v3d_string_level--;
-}
-
-/* ******************** primitive drawing ******************* */
-
-/* draws a cube given the scaling of the cube, assuming that
- * all required matrices have been set (used for drawing empties)
- */
-static void drawcube_size(float size, unsigned pos)
-{
- const float verts[8][3] = {
- {-size, -size, -size},
- {-size, -size, size},
- {-size, size, -size},
- {-size, size, size},
- { size, -size, -size},
- { size, -size, size},
- { size, size, -size},
- { size, size, size}
- };
-
- const GLubyte indices[24] = {0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 4, 5, 5, 7, 7, 6, 6, 4, 1, 5, 3, 7, 2, 6};
-
-#if 0
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, verts);
- glDrawRangeElements(GL_LINES, 0, 7, 24, GL_UNSIGNED_BYTE, indices);
- glDisableClientState(GL_VERTEX_ARRAY);
-#else
- immBegin(GWN_PRIM_LINES, 24);
- for (int i = 0; i < 24; ++i) {
- immVertex3fv(pos, verts[indices[i]]);
- }
- immEnd();
-#endif
-}
-
-static void drawshadbuflimits(const Lamp *la, const float mat[4][4], unsigned pos)
-{
- float sta[3], end[3], lavec[3];
-
- negate_v3_v3(lavec, mat[2]);
- normalize_v3(lavec);
-
- madd_v3_v3v3fl(sta, mat[3], lavec, la->clipsta);
- madd_v3_v3v3fl(end, mat[3], lavec, la->clipend);
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(pos, sta);
- immVertex3fv(pos, end);
- immEnd();
-
- glPointSize(3.0f);
- immBegin(GWN_PRIM_POINTS, 2);
- immVertex3fv(pos, sta);
- immVertex3fv(pos, end);
- immEnd();
-}
-
-static void spotvolume(float lvec[3], float vvec[3], const float inp)
-{
- /* camera is at 0,0,0 */
- float temp[3], plane[3], mat1[3][3], mat2[3][3], mat3[3][3], mat4[3][3], q[4], co, si, angle;
-
- normalize_v3(lvec);
- normalize_v3(vvec); /* is this the correct vector ? */
-
- cross_v3_v3v3(temp, vvec, lvec); /* equation for a plane through vvec and lvec */
- cross_v3_v3v3(plane, lvec, temp); /* a plane perpendicular to this, parallel with lvec */
-
- /* vectors are exactly aligned, use the X axis, this is arbitrary */
- if (normalize_v3(plane) == 0.0f)
- plane[1] = 1.0f;
-
- /* now we've got two equations: one of a cone and one of a plane, but we have
- * three unknowns. We remove one unknown by rotating the plane to z=0 (the plane normal) */
-
- /* rotate around cross product vector of (0,0,1) and plane normal, dot product degrees */
- /* according definition, we derive cross product is (plane[1],-plane[0],0), en cos = plane[2]);*/
-
- /* translating this comment to english didnt really help me understanding the math! :-) (ton) */
-
- q[1] = plane[1];
- q[2] = -plane[0];
- q[3] = 0;
- normalize_v3(&q[1]);
-
- angle = saacos(plane[2]) / 2.0f;
- co = cosf(angle);
- si = sqrtf(1 - co * co);
-
- q[0] = co;
- q[1] *= si;
- q[2] *= si;
- q[3] = 0;
-
- quat_to_mat3(mat1, q);
-
- /* rotate lamp vector now over acos(inp) degrees */
- copy_v3_v3(vvec, lvec);
-
- unit_m3(mat2);
- co = inp;
- si = sqrtf(1.0f - inp * inp);
-
- mat2[0][0] = co;
- mat2[1][0] = -si;
- mat2[0][1] = si;
- mat2[1][1] = co;
- mul_m3_m3m3(mat3, mat2, mat1);
-
- mat2[1][0] = si;
- mat2[0][1] = -si;
- mul_m3_m3m3(mat4, mat2, mat1);
- transpose_m3(mat1);
-
- mul_m3_m3m3(mat2, mat1, mat3);
- mul_m3_v3(mat2, lvec);
- mul_m3_m3m3(mat2, mat1, mat4);
- mul_m3_v3(mat2, vvec);
-}
-
-static void draw_spot_cone(Lamp *la, float x, float z, unsigned pos)
-{
- z = fabsf(z);
-
- const bool square = (la->mode & LA_SQUARE);
-
- immBegin(GWN_PRIM_TRI_FAN, square ? 6 : 34);
- immVertex3f(pos, 0.0f, 0.0f, -x);
-
- if (square) {
- immVertex3f(pos, z, z, 0);
- immVertex3f(pos, -z, z, 0);
- immVertex3f(pos, -z, -z, 0);
- immVertex3f(pos, z, -z, 0);
- immVertex3f(pos, z, z, 0);
- }
- else {
- for (int a = 0; a < 33; a++) {
- float angle = a * M_PI * 2 / (33 - 1);
- immVertex3f(pos, z * cosf(angle), z * sinf(angle), 0.0f);
- }
- }
-
- immEnd();
-}
-
-static void draw_transp_spot_volume(Lamp *la, float x, float z, unsigned pos)
-{
- glEnable(GL_CULL_FACE);
- glEnable(GL_BLEND);
- glDepthMask(GL_FALSE);
-
- /* draw backside darkening */
- glCullFace(GL_FRONT);
-
- glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
- immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
-
- draw_spot_cone(la, x, z, pos);
-
- /* draw front side lighting */
- glCullFace(GL_BACK);
-
- glBlendFunc(GL_ONE, GL_ONE);
- immUniformColor3f(0.2f, 0.2f, 0.2f);
-
- draw_spot_cone(la, x, z, pos);
-
- /* restore state */
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE);
- glDisable(GL_CULL_FACE);
-}
-
-#ifdef WITH_GAMEENGINE
-static void draw_transp_sun_volume(Lamp *la, unsigned pos)
-{
- float box[8][3];
-
- /* construct box */
- box[0][0] = box[1][0] = box[2][0] = box[3][0] = -la->shadow_frustum_size;
- box[4][0] = box[5][0] = box[6][0] = box[7][0] = +la->shadow_frustum_size;
- box[0][1] = box[1][1] = box[4][1] = box[5][1] = -la->shadow_frustum_size;
- box[2][1] = box[3][1] = box[6][1] = box[7][1] = +la->shadow_frustum_size;
- box[0][2] = box[3][2] = box[4][2] = box[7][2] = -la->clipend;
- box[1][2] = box[2][2] = box[5][2] = box[6][2] = -la->clipsta;
-
- /* draw edges */
- imm_draw_box(box, false, pos);
-
- /* draw faces */
- glEnable(GL_CULL_FACE);
- glEnable(GL_BLEND);
- glDepthMask(GL_FALSE);
-
- /* draw backside darkening */
- glCullFace(GL_FRONT);
-
- glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
- immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
-
- imm_draw_box(box, true, pos);
-
- /* draw front side lighting */
- glCullFace(GL_BACK);
-
- glBlendFunc(GL_ONE, GL_ONE);
- immUniformColor3f(0.2f, 0.2f, 0.2f);
-
- imm_draw_box(box, true, pos);
-
- /* restore state */
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE);
- glDisable(GL_CULL_FACE);
-}
-#endif
-
-void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4], const bool is_obact)
-{
- Object *ob = base->object;
- const float pixsize = ED_view3d_pixel_size(rv3d, ob->obmat[3]);
- Lamp *la = ob->data;
- float vec[3], lvec[3], vvec[3], circrad;
- float imat[4][4];
-
- /* cone can't be drawn for duplicated lamps, because duplilist would be freed */
- /* the moment of view3d_draw_transp() call */
- const bool is_view = (rv3d->persp == RV3D_CAMOB && v3d->camera == base->object);
- const bool drawcone = ((dt > OB_WIRE) &&
- !(G.f & G_PICKSEL) &&
- (la->type == LA_SPOT) &&
- (la->mode & LA_SHOW_CONE) &&
- !(base->flag_legacy & OB_FROMDUPLI) &&
- !is_view);
-
-#ifdef WITH_GAMEENGINE
- const bool drawshadowbox = (
- (rv3d->rflag & RV3D_IS_GAME_ENGINE) &&
- (dt > OB_WIRE) &&
- !(G.f & G_PICKSEL) &&
- (la->type == LA_SUN) &&
- ((la->mode & LA_SHAD_BUF) ||
- (la->mode & LA_SHAD_RAY)) &&
- (la->mode & LA_SHOW_SHADOW_BOX) &&
- !(base->flag_legacy & OB_FROMDUPLI) &&
- !is_view);
-#else
- const bool drawshadowbox = false;
-#endif
-
- if ((drawcone || drawshadowbox) && !v3d->transp) {
- /* in this case we need to draw delayed */
- ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
- return;
- }
-
- /* we first draw only the screen aligned & fixed scale stuff */
- gpuPushMatrix();
- gpuLoadMatrix(rv3d->viewmat);
-
- /* lets calculate the scale: */
- const float lampsize_px = U.obcenter_dia;
- const float lampsize = pixsize * lampsize_px * 0.5f;
-
- /* and view aligned matrix: */
- copy_m4_m4(imat, rv3d->viewinv);
- normalize_v3(imat[0]);
- normalize_v3(imat[1]);
-
- const unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- /* lamp center */
- copy_v3_v3(vec, ob->obmat[3]);
-
- float curcol[4];
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- /* for AA effects */
- rgb_uchar_to_float(curcol, ob_wire_col);
- curcol[3] = 0.6f;
- /* TODO: pay attention to GL_BLEND */
- }
-
- glLineWidth(1.0f);
- setlinestyle(3);
-
- if (lampsize > 0.0f) {
- const float outlineWidth = 1.5f * U.pixelsize;
- const float lampdot_size = lampsize_px * U.pixelsize + outlineWidth;
-
- /* Inner Circle */
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- const float *color = curcol;
- if (ob->id.us > 1) {
- if (is_obact || ((base->flag & BASE_SELECTED) != 0)) {
- static const float active_color[4] = {0.533f, 1.0f, 1.0f, 1.0f};
- color = active_color;
- }
- else {
- static const float inactive_color[4] = {0.467f, 0.8f, 0.8f, 1.0f};
- color = inactive_color;
- }
- }
-
- GPU_enable_program_point_size();
- glEnable(GL_BLEND);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA);
- immUniform1f("size", lampdot_size);
- immUniform1f("outlineWidth", outlineWidth);
- immUniformColor3fvAlpha(color, 0.3f);
- immUniform4fv("outlineColor", color);
-
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3fv(pos, vec);
- immEnd();
-
- immUnbindProgram();
-
- glDisable(GL_BLEND);
- GPU_disable_program_point_size();
- }
- else {
- /* CONSTCOLOR in effect */
- /* TODO: separate picking from drawing */
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR);
- /* color doesn't matter, so don't set */
- glPointSize(lampdot_size);
-
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3fv(pos, vec);
- immEnd();
-
- immUnbindProgram();
- }
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- /* TODO(merwin): short term, use DEPTH_ONLY for picking
- * long term, separate picking from drawing
- */
-
- /* restore */
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- immUniformColor4fv(curcol);
- }
-
- /* Outer circle */
- circrad = 3.0f * lampsize;
-
- imm_drawcircball(vec, circrad, imat, pos);
-
- /* draw dashed outer circle if shadow is on. remember some lamps can't have certain shadows! */
- if (la->type != LA_HEMI) {
- if ((la->mode & LA_SHAD_RAY) || ((la->mode & LA_SHAD_BUF) && (la->type == LA_SPOT))) {
- imm_drawcircball(vec, circrad + 3.0f * pixsize, imat, pos);
- }
- }
- }
- else {
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- immUniformColor4fv(curcol);
- }
- circrad = 0.0f;
- }
-
- /* draw the pretty sun rays */
- if (la->type == LA_SUN) {
- float v1[3], v2[3], mat[3][3];
- short axis;
-
- /* setup a 45 degree rotation matrix */
- axis_angle_normalized_to_mat3_ex(mat, imat[2], M_SQRT1_2, M_SQRT1_2);
-
- /* vectors */
- mul_v3_v3fl(v1, imat[0], circrad * 1.2f);
- mul_v3_v3fl(v2, imat[0], circrad * 2.5f);
-
- /* center */
- gpuPushMatrix();
- gpuTranslate3fv(vec);
-
- setlinestyle(3);
-
- immBegin(GWN_PRIM_LINES, 16);
- for (axis = 0; axis < 8; axis++) {
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
- mul_m3_v3(mat, v1);
- mul_m3_v3(mat, v2);
- }
- immEnd();
-
- gpuPopMatrix();
- }
-
- if (la->type == LA_LOCAL) {
- if (la->mode & LA_SPHERE) {
- imm_drawcircball(vec, la->dist, imat, pos);
- }
- }
-
- gpuPopMatrix(); /* back in object space */
- zero_v3(vec);
-
- if (is_view) {
- /* skip drawing extra info */
- }
- else if (la->type == LA_SPOT) {
- float x, y, z, z_abs;
- copy_v3_fl3(lvec, 0.0f, 0.0f, 1.0f);
- copy_v3_fl3(vvec, rv3d->persmat[0][2], rv3d->persmat[1][2], rv3d->persmat[2][2]);
- mul_transposed_mat3_m4_v3(ob->obmat, vvec);
-
- x = -la->dist;
- y = cosf(la->spotsize * 0.5f);
- z = x * sqrtf(1.0f - y * y);
-
- spotvolume(lvec, vvec, y);
- mul_v3_fl(lvec, x);
- mul_v3_fl(vvec, x);
-
- x *= y;
-
- z_abs = fabsf(z);
-
- if (la->mode & LA_SQUARE) {
- /* draw pyramid */
- const float vertices[5][3] = {
- /* 5 of vertex coords of pyramid */
- {0.0f, 0.0f, 0.0f},
- {z_abs, z_abs, x},
- {-z_abs, -z_abs, x},
- {z_abs, -z_abs, x},
- {-z_abs, z_abs, x},
- };
-
- immBegin(GWN_PRIM_LINES, 16);
- for (int i = 1; i <= 4; ++i) {
- immVertex3fv(pos, vertices[0]); /* apex to corner */
- immVertex3fv(pos, vertices[i]);
- int next_i = (i == 4) ? 1 : (i + 1);
- immVertex3fv(pos, vertices[i]); /* corner to next corner */
- immVertex3fv(pos, vertices[next_i]);
- }
- immEnd();
-
- gpuTranslate3f(0.0f, 0.0f, x);
-
- /* draw the square representing spotbl */
- if (la->type == LA_SPOT) {
- float blend = z_abs * (1.0f - pow2f(la->spotblend));
-
- /* hide line if it is zero size or overlaps with outer border,
- * previously it adjusted to always to show it but that seems
- * confusing because it doesn't show the actual blend size */
- if (blend != 0.0f && blend != z_abs) {
- imm_draw_box_wire_3d(pos, blend, -blend, -blend, blend);
- }
- }
- }
- else {
- /* draw the angled sides of the cone */
- immBegin(GWN_PRIM_LINE_STRIP, 3);
- immVertex3fv(pos, vvec);
- immVertex3fv(pos, vec);
- immVertex3fv(pos, lvec);
- immEnd();
-
- /* draw the circle at the end of the cone */
- gpuTranslate3f(0.0f, 0.0f, x);
- imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, z_abs, 32);
-
- /* draw the circle representing spotbl */
- if (la->type == LA_SPOT) {
- float blend = z_abs * (1.0f - pow2f(la->spotblend));
-
- /* hide line if it is zero size or overlaps with outer border,
- * previously it adjusted to always to show it but that seems
- * confusing because it doesn't show the actual blend size */
- if (blend != 0.0f && blend != z_abs) {
- imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, blend, 32);
- }
- }
- }
-
- if (drawcone)
- draw_transp_spot_volume(la, x, z, pos);
-
- /* draw clip start, useful for wide cones where its not obvious where the start is */
- gpuTranslate3f(0.0f, 0.0f, -x); /* reverse translation above */
- immBegin(GWN_PRIM_LINES, 2);
- if (la->type == LA_SPOT && (la->mode & LA_SHAD_BUF)) {
- float lvec_clip[3];
- float vvec_clip[3];
- float clipsta_fac = la->clipsta / -x;
-
- interp_v3_v3v3(lvec_clip, vec, lvec, clipsta_fac);
- interp_v3_v3v3(vvec_clip, vec, vvec, clipsta_fac);
-
- immVertex3fv(pos, lvec_clip);
- immVertex3fv(pos, vvec_clip);
- }
- /* Else, draw spot direction (using distance as end limit, same as for Area lamp). */
- else {
- immVertex3f(pos, 0.0f, 0.0f, -circrad);
- immVertex3f(pos, 0.0f, 0.0f, -la->dist);
- }
- immEnd();
- }
- else if (ELEM(la->type, LA_HEMI, LA_SUN)) {
- /* draw the line from the circle along the dist */
- immBegin(GWN_PRIM_LINES, 2);
- vec[2] = -circrad;
- immVertex3fv(pos, vec);
- vec[2] = -la->dist;
- immVertex3fv(pos, vec);
- immEnd();
-
- if (la->type == LA_HEMI) {
- /* draw the hemisphere curves */
- short axis, steps, dir;
- float outdist, zdist, mul;
- zero_v3(vec);
- outdist = 0.14f; mul = 1.4f; dir = 1;
-
- setlinestyle(4);
- /* loop over the 4 compass points, and draw each arc as a LINE_STRIP */
- for (axis = 0; axis < 4; axis++) {
- float v[3] = {0.0f, 0.0f, 0.0f};
- zdist = 0.02f;
-
- immBegin(GWN_PRIM_LINE_STRIP, 6);
-
- for (steps = 0; steps < 6; steps++) {
- if (axis == 0 || axis == 1) { /* x axis up, x axis down */
- /* make the arcs start at the edge of the energy circle */
- if (steps == 0) v[0] = dir * circrad;
- else v[0] = v[0] + dir * (steps * outdist);
- }
- else if (axis == 2 || axis == 3) { /* y axis up, y axis down */
- /* make the arcs start at the edge of the energy circle */
- v[1] = (steps == 0) ? (dir * circrad) : (v[1] + dir * (steps * outdist));
- }
-
- v[2] = v[2] - steps * zdist;
-
- immVertex3fv(pos, v);
-
- zdist = zdist * mul;
- }
-
- immEnd();
- /* flip the direction */
- dir = -dir;
- }
- }
-
-#ifdef WITH_GAMEENGINE
- if (drawshadowbox) {
- draw_transp_sun_volume(la, pos);
- }
-#endif
- }
- else if (la->type == LA_AREA) {
- setlinestyle(3);
- if (la->area_shape == LA_AREA_SQUARE)
- imm_draw_box_wire_3d(pos, -la->area_size * 0.5f, -la->area_size * 0.5f, la->area_size * 0.5f, la->area_size * 0.5f);
- else if (la->area_shape == LA_AREA_RECT)
- imm_draw_box_wire_3d(pos, -la->area_size * 0.5f, -la->area_sizey * 0.5f, la->area_size * 0.5f, la->area_sizey * 0.5f);
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3f(pos, 0.0f, 0.0f, -circrad);
- immVertex3f(pos, 0.0f, 0.0f, -la->dist);
- immEnd();
- }
-
- /* and back to viewspace */
- gpuPushMatrix();
- gpuLoadMatrix(rv3d->viewmat);
- copy_v3_v3(vec, ob->obmat[3]);
-
- setlinestyle(0);
-
- if ((la->type == LA_SPOT) && (la->mode & LA_SHAD_BUF) && (is_view == false)) {
- drawshadbuflimits(la, ob->obmat, pos);
- }
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- immUniformThemeColor(TH_LAMP);
- }
-
- glEnable(GL_BLEND);
-
- if (vec[2] > 0) vec[2] -= circrad;
- else vec[2] += circrad;
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(pos, vec);
- vec[2] = 0;
- immVertex3fv(pos, vec);
- immEnd();
-
- glPointSize(2.0f);
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3fv(pos, vec);
- immEnd();
-
- glDisable(GL_BLEND);
-
- immUnbindProgram();
- gpuPopMatrix();
-}
-
-static void draw_limit_line(float sta, float end, const short dflag, const unsigned char col[3], unsigned pos)
-{
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3f(pos, 0.0f, 0.0f, -sta);
- immVertex3f(pos, 0.0f, 0.0f, -end);
- immEnd();
-
- if (!(dflag & DRAW_PICKING)) {
- glPointSize(3.0f);
- /* would like smooth round points here, but that means binding another shader...
- * if it's really desired, pull these points into their own function to be called after */
- immBegin(GWN_PRIM_POINTS, 2);
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- immUniformColor3ubv(col);
- }
- immVertex3f(pos, 0.0f, 0.0f, -sta);
- immVertex3f(pos, 0.0f, 0.0f, -end);
- immEnd();
- }
-}
-
-
-/* yafray: draw camera focus point (cross, similar to aqsis code in tuhopuu) */
-/* qdn: now also enabled for Blender to set focus point for defocus composite node */
-static void draw_focus_cross(float dist, float size, unsigned pos)
-{
- immBegin(GWN_PRIM_LINES, 4);
- immVertex3f(pos, -size, 0.0f, -dist);
- immVertex3f(pos, size, 0.0f, -dist);
- immVertex3f(pos, 0.0f, -size, -dist);
- immVertex3f(pos, 0.0f, size, -dist);
- immEnd();
-}
-
#ifdef VIEW3D_CAMERA_BORDER_HACK
unsigned char view3d_camera_border_hack_col[3];
bool view3d_camera_border_hack_test = false;
#endif
-/* ****************** draw clip data *************** */
-
-static void draw_viewport_object_reconstruction(
- Scene *scene, Base *base, const View3D *v3d, const RegionView3D *rv3d,
- MovieClip *clip, MovieTrackingObject *tracking_object,
- const short dflag, const unsigned char ob_wire_col[4],
- int *global_track_index, bool draw_selected)
-{
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingTrack *track;
- float mat[4][4], imat[4][4];
- unsigned char col_unsel[4], col_sel[4];
- int tracknr = *global_track_index;
- ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
- float camera_size[3];
-
- UI_GetThemeColor4ubv(TH_TEXT, col_unsel);
- UI_GetThemeColor4ubv(TH_SELECT, col_sel);
-
- BKE_tracking_get_camera_object_matrix(scene, base->object, mat);
-
- /* we're compensating camera size for bundles size,
- * to make it so bundles are always displayed with the same size */
- copy_v3_v3(camera_size, base->object->size);
- if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0)
- mul_v3_fl(camera_size, tracking_object->scale);
-
- gpuPushMatrix();
-
- if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
- /* current ogl matrix is translated in camera space, bundles should
- * be rendered in world space, so camera matrix should be "removed"
- * from current ogl matrix */
- invert_m4_m4(imat, base->object->obmat);
-
- gpuMultMatrix(imat);
- gpuMultMatrix(mat);
- }
- else {
- float obmat[4][4];
- int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra);
-
- BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, obmat);
-
- invert_m4_m4(imat, obmat);
- gpuMultMatrix(imat);
- }
-
- for (track = tracksbase->first; track; track = track->next) {
- bool selected = TRACK_SELECTED(track);
-
- if (draw_selected && !selected)
- continue;
-
- if ((track->flag & TRACK_HAS_BUNDLE) == 0)
- continue;
-
- if (dflag & DRAW_PICKING)
- GPU_select_load_id(base->object->select_color + (tracknr << 16));
-
- gpuPushMatrix();
- gpuTranslate3fv(track->bundle_pos);
- gpuScale3f(v3d->bundle_size / 0.05f / camera_size[0],
- v3d->bundle_size / 0.05f / camera_size[1],
- v3d->bundle_size / 0.05f / camera_size[2]);
-
- const int v3d_drawtype = view3d_effective_drawtype(v3d);
- if (v3d_drawtype == OB_WIRE) {
- unsigned char color[4];
- const unsigned char *color_ptr = NULL;
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if (selected && (track->flag & TRACK_CUSTOMCOLOR) == 0) {
- color_ptr = ob_wire_col;
- }
- else {
- rgba_float_to_uchar(color, track->color);
- color_ptr = color;
- }
- }
-
- drawaxes(rv3d->viewmatob, 0.05f, v3d->bundle_drawtype, color_ptr);
- }
- else if (v3d_drawtype > OB_WIRE) {
- if (v3d->bundle_drawtype == OB_EMPTY_SPHERE) {
- Gwn_Batch *batch;
-
- gpuScaleUniform(0.05f);
-
- /* selection outline */
- if (selected) {
- batch = GPU_batch_preset_sphere_wire(1);
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
- GWN_batch_uniform_4f(batch, "color",
- ob_wire_col[0] / 255.f,
- ob_wire_col[1] / 255.f,
- ob_wire_col[2] / 255.f, 1.0f);
- }
- else {
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_DEPTH_ONLY);
- }
- glLineWidth(2.0f);
-
- GWN_batch_draw(batch);
- }
-
- batch = GPU_batch_preset_sphere(0);
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- const float light[3] = {0.0f, 0.0f, 1.0f};
- float col[3];
- GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING);
- GWN_batch_uniform_3fv(batch, "light", light);
-
- if (track->flag & TRACK_CUSTOMCOLOR) copy_v3_v3(col, track->color);
- else UI_GetThemeColor3fv(TH_BUNDLE_SOLID, col);
- GWN_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f);
- }
- else {
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_DEPTH_ONLY);
- }
-
- GWN_batch_draw(batch);
- }
- else {
- unsigned char color[4];
- const unsigned char *color_ptr = NULL;
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if (selected) {
- color_ptr = ob_wire_col;
- }
- else {
- if (track->flag & TRACK_CUSTOMCOLOR) rgba_float_to_uchar(color, track->color);
- else UI_GetThemeColor4ubv(TH_WIRE, color);
-
- color_ptr = color;
- }
- }
-
- drawaxes(rv3d->viewmatob, 0.05f, v3d->bundle_drawtype, color_ptr);
- }
- }
-
- gpuPopMatrix();
-
- if ((dflag & DRAW_PICKING) == 0 && (v3d->flag2 & V3D_SHOW_BUNDLENAME)) {
- float pos[3];
-
- mul_v3_m4v3(pos, mat, track->bundle_pos);
- view3d_cached_text_draw_add(pos,
- track->name, strlen(track->name),
- 10, V3D_CACHE_TEXT_GLOBALSPACE,
- selected ? col_sel : col_unsel);
- }
-
- tracknr++;
- }
-
- if ((dflag & DRAW_PICKING) == 0) {
- if ((v3d->flag2 & V3D_SHOW_CAMERAPATH) && (tracking_object->flag & TRACKING_OBJECT_CAMERA)) {
- MovieTrackingReconstruction *reconstruction;
- reconstruction = BKE_tracking_object_get_reconstruction(tracking, tracking_object);
-
- if (reconstruction->camnr >= 2) {
- MovieReconstructedCamera *camera = reconstruction->cameras;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformThemeColor(TH_CAMERA_PATH);
-
- glLineWidth(2.0f);
-
- immBegin(GWN_PRIM_LINE_STRIP, reconstruction->camnr);
- for (int a = 0; a < reconstruction->camnr; a++, camera++) {
- immVertex3fv(pos, camera->mat[3]);
- }
- immEnd();
-
- immUnbindProgram();
- }
- }
- }
-
- gpuPopMatrix();
-
- *global_track_index = tracknr;
-}
-
-static void draw_viewport_reconstruction(
- Scene *scene, Base *base, const View3D *v3d, const RegionView3D *rv3d, MovieClip *clip,
- const short dflag, const unsigned char ob_wire_col[4],
- const bool draw_selected)
-{
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object;
- int global_track_index = 1;
-
- if ((v3d->flag2 & V3D_SHOW_RECONSTRUCTION) == 0)
- return;
-
- if (v3d->flag2 & V3D_RENDER_OVERRIDE)
- return;
-
- GPU_basic_shader_colors(NULL, NULL, 0, 1.0f);
- GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
-
- tracking_object = tracking->objects.first;
- while (tracking_object) {
- draw_viewport_object_reconstruction(
- scene, base, v3d, rv3d, clip, tracking_object,
- dflag, ob_wire_col, &global_track_index, draw_selected);
-
- tracking_object = tracking_object->next;
- }
-
- /* restore */
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
-
- if (dflag & DRAW_PICKING)
- GPU_select_load_id(base->object->select_color);
-}
-
-/* camera frame */
-static void drawcamera_frame(float vec[4][3], bool filled, unsigned pos)
-{
- immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4);
- immVertex3fv(pos, vec[0]);
- immVertex3fv(pos, vec[1]);
- immVertex3fv(pos, vec[2]);
- immVertex3fv(pos, vec[3]);
- immEnd();
-}
-
-/* center point to camera frame */
-static void drawcamera_framelines(float vec[4][3], float origin[3], unsigned pos)
-{
- immBegin(GWN_PRIM_LINES, 8);
- immVertex3fv(pos, origin);
- immVertex3fv(pos, vec[0]);
- immVertex3fv(pos, origin);
- immVertex3fv(pos, vec[1]);
- immVertex3fv(pos, origin);
- immVertex3fv(pos, vec[2]);
- immVertex3fv(pos, origin);
- immVertex3fv(pos, vec[3]);
- immEnd();
-}
-
-static void drawcamera_volume(float near_plane[4][3], float far_plane[4][3], bool filled, unsigned pos)
-{
- drawcamera_frame(near_plane, filled, pos);
- drawcamera_frame(far_plane, filled, pos);
-
- if (filled) {
- immBegin(GWN_PRIM_TRI_STRIP, 10);
-
- immVertex3fv(pos, near_plane[0]);
- immVertex3fv(pos, far_plane[0]);
- immVertex3fv(pos, near_plane[1]);
- immVertex3fv(pos, far_plane[1]);
- immVertex3fv(pos, near_plane[2]);
- immVertex3fv(pos, far_plane[2]);
- immVertex3fv(pos, near_plane[3]);
- immVertex3fv(pos, far_plane[3]);
- immVertex3fv(pos, near_plane[0]);
- immVertex3fv(pos, far_plane[0]);
-
- immEnd();
- }
- else {
- immBegin(GWN_PRIM_LINES, 8);
- for (int i = 0; i < 4; ++i) {
- immVertex3fv(pos, near_plane[i]);
- immVertex3fv(pos, far_plane[i]);
- }
- immEnd();
- }
-}
-
-static bool drawcamera_is_stereo3d(Scene *scene, View3D *v3d, Object *ob)
-{
- return (ob == v3d->camera) &&
- (scene->r.scemode & R_MULTIVIEW) != 0 &&
- (v3d->stereo3d_flag);
-}
-
-static void drawcamera_stereo3d(
- Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, const Camera *cam,
- float vec[4][3], float drawsize, const float scale[3], unsigned pos)
-{
- float obmat[4][4];
- float vec_lr[2][4][3];
- const float fac = (cam->stereo.pivot == CAM_S3D_PIVOT_CENTER) ? 2.0f : 1.0f;
- float origin[2][3] = {{0}};
- float tvec[3];
- const Camera *cam_lr[2];
- const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
-
- const bool is_stereo3d_cameras = (v3d->stereo3d_flag & V3D_S3D_DISPCAMERAS) && (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D);
- const bool is_stereo3d_plane = (v3d->stereo3d_flag & V3D_S3D_DISPPLANE) && (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D);
- const bool is_stereo3d_volume = (v3d->stereo3d_flag & V3D_S3D_DISPVOLUME);
-
- zero_v3(tvec);
-
- /* caller bound GPU_SHADER_3D_UNIFORM_COLOR, passed in pos attribute ID */
-
- for (int i = 0; i < 2; i++) {
- ob = BKE_camera_multiview_render(scene, ob, names[i]);
- cam_lr[i] = ob->data;
-
- gpuLoadMatrix(rv3d->viewmat);
- BKE_camera_multiview_model_matrix(&scene->r, ob, names[i], obmat);
- gpuMultMatrix(obmat);
-
- copy_m3_m3(vec_lr[i], vec);
- copy_v3_v3(vec_lr[i][3], vec[3]);
-
- if (cam->stereo.convergence_mode == CAM_S3D_OFFAXIS) {
- const float shift_x =
- ((BKE_camera_multiview_shift_x(&scene->r, ob, names[i]) - cam->shiftx) *
- (drawsize * scale[0] * fac));
-
- for (int j = 0; j < 4; j++) {
- vec_lr[i][j][0] += shift_x;
- }
- }
-
- if (is_stereo3d_cameras) {
- /* camera frame */
- drawcamera_frame(vec_lr[i], false, pos);
-
- /* center point to camera frame */
- drawcamera_framelines(vec_lr[i], tvec, pos);
- }
-
- /* connecting line */
- mul_m4_v3(obmat, origin[i]);
-
- /* convergence plane */
- if (is_stereo3d_plane || is_stereo3d_volume) {
- for (int j = 0; j < 4; j++) {
- mul_m4_v3(obmat, vec_lr[i][j]);
- }
- }
- }
-
- /* the remaining drawing takes place in the view space */
- gpuLoadMatrix(rv3d->viewmat);
-
- if (is_stereo3d_cameras) {
- /* draw connecting lines */
- glLineStipple(2, 0xAAAA);
- glEnable(GL_LINE_STIPPLE);
-
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(pos, origin[0]);
- immVertex3fv(pos, origin[1]);
- immEnd();
-
- glDisable(GL_LINE_STIPPLE);
- }
-
- /* draw convergence plane */
- if (is_stereo3d_plane) {
- float axis_center[3], screen_center[3];
- float world_plane[4][3];
- float local_plane[4][3];
- float offset;
-
- mid_v3_v3v3(axis_center, origin[0], origin[1]);
-
- for (int i = 0; i < 4; i++) {
- mid_v3_v3v3(world_plane[i], vec_lr[0][i], vec_lr[1][i]);
- sub_v3_v3v3(local_plane[i], world_plane[i], axis_center);
- }
-
- mid_v3_v3v3(screen_center, world_plane[0], world_plane[2]);
- offset = cam->stereo.convergence_distance / len_v3v3(screen_center, axis_center);
-
- for (int i = 0; i < 4; i++) {
- mul_v3_fl(local_plane[i], offset);
- add_v3_v3(local_plane[i], axis_center);
- }
-
- immUniformColor3f(0.0f, 0.0f, 0.0f);
-
- /* camera frame */
- drawcamera_frame(local_plane, false, pos);
-
- if (v3d->stereo3d_convergence_alpha > 0.0f) {
- glEnable(GL_BLEND);
- glDepthMask(GL_FALSE); /* disable write in zbuffer, needed for nice transp */
-
- immUniformColor4f(0.0f, 0.0f, 0.0f, v3d->stereo3d_convergence_alpha);
-
- drawcamera_frame(local_plane, true, pos);
-
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE); /* restore write in zbuffer */
- }
- }
-
- /* draw convergence plane */
- if (is_stereo3d_volume) {
- float screen_center[3];
- float near_plane[4][3], far_plane[4][3];
-
- for (int i = 0; i < 2; i++) {
- mid_v3_v3v3(screen_center, vec_lr[i][0], vec_lr[i][2]);
-
- float offset = len_v3v3(screen_center, origin[i]);
-
- for (int j = 0; j < 4; j++) {
- sub_v3_v3v3(near_plane[j], vec_lr[i][j], origin[i]);
- mul_v3_fl(near_plane[j], cam_lr[i]->clipsta / offset);
- add_v3_v3(near_plane[j], origin[i]);
-
- sub_v3_v3v3(far_plane[j], vec_lr[i][j], origin[i]);
- mul_v3_fl(far_plane[j], cam_lr[i]->clipend / offset);
- add_v3_v3(far_plane[j], origin[i]);
- }
-
- /* camera frame */
- immUniformColor3f(0.0f, 0.0f, 0.0f);
-
- drawcamera_volume(near_plane, far_plane, false, pos);
-
- if (v3d->stereo3d_volume_alpha > 0.0f) {
- glEnable(GL_BLEND);
- glDepthMask(GL_FALSE); /* disable write in zbuffer, needed for nice transp */
-
- if (i == 0)
- immUniformColor4f(0.0f, 1.0f, 1.0f, v3d->stereo3d_volume_alpha);
- else
- immUniformColor4f(1.0f, 0.0f, 0.0f, v3d->stereo3d_volume_alpha);
-
- drawcamera_volume(near_plane, far_plane, true, pos);
-
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE); /* restore write in zbuffer */
- }
- }
- }
-}
-
-/* flag similar to draw_object() */
-void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
- const short dflag, const unsigned char ob_wire_col[4])
-{
- /* a standing up pyramid with (0,0,0) as top */
- Camera *cam;
- Object *ob = base->object;
- float tvec[3];
- float vec[4][3], asp[2], shift[2], scale[3];
- MovieClip *clip = BKE_object_movieclip_get(scene, base->object, false);
-
- const bool is_active = (ob == v3d->camera);
- const bool is_view = (rv3d->persp == RV3D_CAMOB && is_active);
- const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
- const bool is_stereo3d = drawcamera_is_stereo3d(scene, v3d, ob);
- const bool is_stereo3d_view = (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D);
- const bool is_stereo3d_cameras = (ob == scene->camera) &&
- is_multiview &&
- is_stereo3d_view &&
- (v3d->stereo3d_flag & V3D_S3D_DISPCAMERAS);
- const bool is_selection_camera_stereo = (G.f & G_PICKSEL) &&
- is_view && is_multiview &&
- is_stereo3d_view;
-
- /* draw data for movie clip set as active for scene */
- if (clip) {
- draw_viewport_reconstruction(scene, base, v3d, rv3d, clip, dflag, ob_wire_col, false);
- draw_viewport_reconstruction(scene, base, v3d, rv3d, clip, dflag, ob_wire_col, true);
- }
-
-#ifdef VIEW3D_CAMERA_BORDER_HACK
- if (is_view && !(G.f & G_PICKSEL)) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- view3d_camera_border_hack_col[0] = ob_wire_col[0];
- view3d_camera_border_hack_col[1] = ob_wire_col[1];
- view3d_camera_border_hack_col[2] = ob_wire_col[2];
- }
- else {
- float col[4];
- glGetFloatv(GL_CURRENT_COLOR, col);
- rgb_float_to_uchar(view3d_camera_border_hack_col, col);
- }
- view3d_camera_border_hack_test = true;
- return;
- }
-#endif
-
- cam = ob->data;
-
- /* BKE_camera_multiview_model_matrix already accounts for scale, don't do it here */
- if (is_selection_camera_stereo) {
- scale[0] = 1.0f;
- scale[1] = 1.0f;
- scale[2] = 1.0f;
- }
- else {
- scale[0] = 1.0f / len_v3(ob->obmat[0]);
- scale[1] = 1.0f / len_v3(ob->obmat[1]);
- scale[2] = 1.0f / len_v3(ob->obmat[2]);
- }
-
- float drawsize;
- BKE_camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale,
- asp, shift, &drawsize, vec);
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- if (ob_wire_col) {
- immUniformColor3ubv(ob_wire_col);
- }
- glLineWidth(1.0f);
-
- /* camera frame */
- if (!is_stereo3d_cameras) {
- /* make sure selection uses the same matrix for camera as the one used while viewing */
- if (is_selection_camera_stereo) {
- float obmat[4][4];
- bool is_left = v3d->multiview_eye == STEREO_LEFT_ID;
-
- gpuPushMatrix();
- gpuLoadMatrix(rv3d->viewmat);
- BKE_camera_multiview_model_matrix(&scene->r, ob, is_left ? STEREO_LEFT_NAME : STEREO_RIGHT_NAME, obmat);
- gpuMultMatrix(obmat);
-
- drawcamera_frame(vec, false, pos);
- gpuPopMatrix();
- }
- else {
- drawcamera_frame(vec, false, pos);
- }
- }
-
- if (is_view) {
- immUnbindProgram();
- return;
- }
-
- zero_v3(tvec);
-
- /* center point to camera frame */
- if (!is_stereo3d_cameras)
- drawcamera_framelines(vec, tvec, pos);
-
- /* arrow on top */
- tvec[2] = vec[1][2]; /* copy the depth */
-
- /* draw an outline arrow for inactive cameras and filled
- * for active cameras. We actually draw both outline+filled
- * for active cameras so the wire can be seen side-on */
- for (int i = 0; i < 2; i++) {
- if (i == 0) immBegin(GWN_PRIM_LINE_LOOP, 3);
- else if (i == 1 && is_active) {
- glDisable(GL_CULL_FACE); /* TODO: declarative state tracking */
- immBegin(GWN_PRIM_TRIS, 3);
- }
- else break;
-
- tvec[0] = shift[0] + ((-0.7f * drawsize) * scale[0]);
- tvec[1] = shift[1] + ((drawsize * (asp[1] + 0.1f)) * scale[1]);
- immVertex3fv(pos, tvec); /* left */
-
- tvec[0] = shift[0] + ((0.7f * drawsize) * scale[0]);
- immVertex3fv(pos, tvec); /* right */
-
- tvec[0] = shift[0];
- tvec[1] = shift[1] + ((1.1f * drawsize * (asp[1] + 0.7f)) * scale[1]);
- immVertex3fv(pos, tvec); /* top */
-
- immEnd();
- }
-
- if ((dflag & DRAW_SCENESET) == 0) {
- if (cam->flag & (CAM_SHOWLIMITS | CAM_SHOWMIST)) {
- float nobmat[4][4];
-
- /* draw in normalized object matrix space */
- copy_m4_m4(nobmat, ob->obmat);
- normalize_m4(nobmat);
-
- gpuLoadMatrix(rv3d->viewmat);
- gpuMultMatrix(nobmat);
-
- if (cam->flag & CAM_SHOWLIMITS) {
- const unsigned char col[3] = {128, 128, 60}, col_hi[3] = {255, 255, 120};
-
- draw_limit_line(cam->clipsta, cam->clipend, dflag, (is_active ? col_hi : col), pos);
- /* qdn: was yafray only, now also enabled for Blender to be used with defocus composite node */
- draw_focus_cross(BKE_camera_object_dof_distance(ob), cam->drawsize, pos);
- }
-
- if (cam->flag & CAM_SHOWMIST) {
- World *world = scene->world;
- const unsigned char col[3] = {128, 128, 128}, col_hi[3] = {255, 255, 255};
-
- if (world) {
- draw_limit_line(world->miststa, world->miststa + world->mistdist,
- dflag, (is_active ? col_hi : col), pos);
- }
- }
- }
- }
-
- /* stereo cameras drawing */
- if (is_stereo3d) {
- drawcamera_stereo3d(scene, v3d, rv3d, ob, cam, vec, drawsize, scale, pos);
- }
-
- immUnbindProgram();
-}
-
-/* flag similar to draw_object() */
-void drawspeaker(const unsigned char ob_wire_col[3])
-{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- if (ob_wire_col) {
- immUniformColor3ubv(ob_wire_col);
- }
-
- glLineWidth(1.0f);
-
- const int segments = 16;
-
- for (int j = 0; j < 3; j++) {
- float z = 0.25f * j - 0.125f;
-
- immBegin(GWN_PRIM_LINE_LOOP, segments);
- for (int i = 0; i < segments; i++) {
- float x = cosf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
- float y = sinf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
- immVertex3f(pos, x, y, z);
- }
- immEnd();
- }
-
- for (int j = 0; j < 4; j++) {
- float x = (((j + 1) % 2) * (j - 1)) * 0.5f;
- float y = ((j % 2) * (j - 2)) * 0.5f;
- immBegin(GWN_PRIM_LINE_STRIP, 3);
- for (int i = 0; i < 3; i++) {
- if (i == 1) {
- x *= 0.5f;
- y *= 0.5f;
- }
-
- float z = 0.25f * i - 0.125f;
- immVertex3f(pos, x, y, z);
- }
- immEnd();
- }
-
- immUnbindProgram();
-}
-
-static void lattice_draw_verts(Lattice *lt, DispList *dl, BPoint *actbp, short sel,
- unsigned int pos, unsigned int color)
-{
- BPoint *bp = lt->def;
- const float *co = dl ? dl->verts : NULL;
- float active_color[4], draw_color[4];
-
- UI_GetThemeColor4fv(sel ? TH_VERTEX_SELECT : TH_VERTEX, draw_color);
- UI_GetThemeColor4fv(TH_ACTIVE_VERT, active_color);
-
- glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
- immBeginAtMost(GWN_PRIM_POINTS, lt->pntsw * lt->pntsv * lt->pntsu);
-
- for (int w = 0; w < lt->pntsw; w++) {
- int wxt = (w == 0 || w == lt->pntsw - 1);
- for (int v = 0; v < lt->pntsv; v++) {
- int vxt = (v == 0 || v == lt->pntsv - 1);
- for (int u = 0; u < lt->pntsu; u++, bp++, co += 3) {
- int uxt = (u == 0 || u == lt->pntsu - 1);
- if (!(lt->flag & LT_OUTSIDE) || uxt || vxt || wxt) {
- if (bp->hide == 0) {
- /* check for active BPoint and ensure selected */
- if ((bp == actbp) && (bp->f1 & SELECT)) {
- immAttrib4fv(color, active_color);
- immVertex3fv(pos, dl ? co : bp->vec);
- }
- else if ((bp->f1 & SELECT) == sel) {
- immAttrib4fv(color, draw_color);
- immVertex3fv(pos, dl ? co : bp->vec);
- }
- }
- }
- }
- }
- }
-
- immEnd();
-}
-
-static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, int actdef_wcol,
- unsigned int pos, unsigned int color)
-{
- int index = ((w * lt->pntsv + v) * lt->pntsu) + u;
-
- if (actdef_wcol) {
- float col[3];
- MDeformWeight *mdw = defvert_find_index(lt->dvert + index, actdef_wcol - 1);
- weight_to_rgb(col, mdw ? mdw->weight : 0.0f);
- immAttrib3fv(color, col);
- }
-
- if (dl) {
- immVertex3fv(pos, &dl->verts[index * 3]);
- }
- else {
- immVertex3fv(pos, lt->def[index].vec);
- }
-}
-
-#ifdef SEQUENCER_DAG_WORKAROUND
-static void ensure_curve_cache(
- const EvaluationContext *eval_ctx, Scene *scene, Object *object)
-{
- bool need_recalc = object->curve_cache == NULL;
- /* Render thread might have freed the curve cache if the
- * object is not visible. If the object is also used for
- * particles duplication, then render thread might have
- * also created curve_cache with only bevel and path
- * filled in.
- *
- * So check for curve_cache != NULL is not fully correct
- * here, we also need to check whether display list is
- * empty or not.
- *
- * The trick below tries to optimize calls to displist
- * creation for cases curve is empty. Meaning, if the curve
- * is empty (without splines) bevel list would also be empty.
- * And the thing is, render thread always leaves bevel list
- * in a proper state. So if bevel list is here and display
- * list is not we need to make display list.
- */
- if (need_recalc == false) {
- need_recalc = object->curve_cache->disp.first == NULL &&
- object->curve_cache->bev.first != NULL;
- }
- if (need_recalc) {
- switch (object->type) {
- case OB_CURVE:
- case OB_SURF:
- case OB_FONT:
- BKE_displist_make_curveTypes(eval_ctx, scene, object, false);
- break;
- case OB_MBALL:
- BKE_displist_make_mball(eval_ctx, scene, object);
- break;
- case OB_LATTICE:
- BKE_lattice_modifiers_calc(eval_ctx, scene, object);
- break;
- }
- }
-}
-#endif
-
-/* lattice color is hardcoded, now also shows weightgroup values in edit mode */
-static void drawlattice(View3D *v3d, Object *ob, const short dflag, const unsigned char ob_wire_col[4])
-{
- Lattice *lt = ob->data;
- DispList *dl;
- int u, v, w;
- int actdef_wcol = 0;
- const bool is_edit = (lt->editlatt != NULL);
-
- dl = BKE_displist_find(&ob->curve_cache->disp, DL_VERTS);
-
- if (is_edit) {
- lt = lt->editlatt->latt;
-
- if (ob->defbase.first && lt->dvert) {
- actdef_wcol = ob->actdef;
- }
- }
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int color, pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- if (actdef_wcol) {
- color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR);
- }
- else {
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- if (is_edit) {
- immUniformThemeColor(TH_WIRE_EDIT);
- }
- else {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- immUniformColor3ubv(ob_wire_col);
- }
- else {
- immUniformColor3f(0.0f, 0.0f, 0.0f);
- }
- }
- }
-
- glLineWidth(1.0f);
- immBeginAtMost(GWN_PRIM_LINES, lt->pntsw * lt->pntsv * lt->pntsu * 6);
-
- for (w = 0; w < lt->pntsw; w++) {
- int wxt = (w == 0 || w == lt->pntsw - 1);
- for (v = 0; v < lt->pntsv; v++) {
- int vxt = (v == 0 || v == lt->pntsv - 1);
- for (u = 0; u < lt->pntsu; u++) {
- int uxt = (u == 0 || u == lt->pntsu - 1);
-
- if (w && ((uxt || vxt) || !(lt->flag & LT_OUTSIDE))) {
- drawlattice__point(lt, dl, u, v, w - 1, actdef_wcol, pos, color);
- drawlattice__point(lt, dl, u, v, w, actdef_wcol, pos, color);
- }
- if (v && ((uxt || wxt) || !(lt->flag & LT_OUTSIDE))) {
- drawlattice__point(lt, dl, u, v - 1, w, actdef_wcol, pos, color);
- drawlattice__point(lt, dl, u, v, w, actdef_wcol, pos, color);
- }
- if (u && ((vxt || wxt) || !(lt->flag & LT_OUTSIDE))) {
- drawlattice__point(lt, dl, u - 1, v, w, actdef_wcol, pos, color);
- drawlattice__point(lt, dl, u, v, w, actdef_wcol, pos, color);
- }
- }
- }
- }
-
- immEnd();
- immUnbindProgram();
-
- if (is_edit) {
- BPoint *actbp = BKE_lattice_active_point_get(lt);
-
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- Gwn_VertFormat *v_format = immVertexFormat();
- unsigned int v_pos = GWN_vertformat_attr_add(v_format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int v_color = GWN_vertformat_attr_add(v_format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
-
- lattice_draw_verts(lt, dl, actbp, 0, v_pos, v_color);
- lattice_draw_verts(lt, dl, actbp, 1, v_pos, v_color);
-
- immUnbindProgram();
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- }
-}
-
-/* ***************** ******************** */
-
-/* draw callback */
-
-typedef struct drawDMVertSel_userData {
- MVert *mvert;
- int active;
- unsigned char *col[3]; /* (base, sel, act) */
- char sel_prev;
- unsigned int pos, color;
-} drawDMVertSel_userData;
-
-static void drawSelectedVertices__mapFunc(void *userData, int index, const float co[3],
- const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
-{
- drawDMVertSel_userData *data = userData;
- MVert *mv = &data->mvert[index];
-
- if (!(mv->flag & ME_HIDE)) {
- const char sel = (index == data->active) ? 2 : (mv->flag & SELECT);
- if (sel != data->sel_prev) {
- immAttrib3ubv(data->color, data->col[sel]);
- data->sel_prev = sel;
- }
-
- immVertex3fv(data->pos, co);
- }
-}
-
-static void drawSelectedVertices(DerivedMesh *dm, Mesh *me)
-{
- drawDMVertSel_userData data;
- Gwn_VertFormat *format = immVertexFormat();
-
- /* TODO define selected color */
- unsigned char base_col[3] = {0x0, 0x0, 0x0};
- unsigned char sel_col[3] = {0xd8, 0xb8, 0x0};
- unsigned char act_col[3] = {0xff, 0xff, 0xff};
-
- data.mvert = me->mvert;
- data.active = BKE_mesh_mselect_active_get(me, ME_VSEL);
- data.sel_prev = 0xff;
-
- data.col[0] = base_col;
- data.col[1] = sel_col;
- data.col[2] = act_col;
-
- data.color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- if (dm->getNumVerts(dm) == 0) return;
-
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- immBeginAtMost(GWN_PRIM_POINTS, dm->getNumVerts(dm));
- dm->foreachMappedVert(dm, drawSelectedVertices__mapFunc, &data, DM_FOREACH_NOP);
- immEnd();
-
- immUnbindProgram();
-}
-
-/* ************** DRAW MESH ****************** */
-
-/* First section is all the "simple" draw routines,
- * ones that just pass some sort of primitive to GL,
- * with perhaps various options to control lighting,
- * color, etc.
- *
- * These routines should not have user interface related
- * logic!!!
- */
-
-static void calcDrawDMNormalScale(Object *ob, drawDMNormal_userData *data)
-{
- float obmat[3][3];
-
- copy_m3_m4(obmat, ob->obmat);
-
- data->uniform_scale = is_uniform_scaled_m3(obmat);
-
- if (!data->uniform_scale) {
- /* inverted matrix */
- invert_m3_m3(data->imat, obmat);
-
- /* transposed inverted matrix */
- transpose_m3_m3(data->tmat, data->imat);
- }
-}
-
-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 = BM_face_at_index(data->bm, index);
- float n[3];
-
- if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
- if (!data->uniform_scale) {
- mul_v3_m3v3(n, data->tmat, no);
- normalize_v3(n);
- mul_m3_v3(data->imat, n);
- }
- else {
- copy_v3_v3(n, no);
- }
-
- immVertex3fv(data->pos, cent);
- immVertex3f(data->pos, cent[0] + n[0] * data->normalsize,
- cent[1] + n[1] * data->normalsize,
- cent[2] + n[2] * data->normalsize);
- }
-}
-
-static void draw_dm_face_normals(BMEditMesh *em, Scene *scene, Object *ob, DerivedMesh *dm, int theme_id)
-{
- Gwn_VertFormat *format = immVertexFormat();
- drawDMNormal_userData data;
-
- data.bm = em->bm;
- data.normalsize = scene->toolsettings->normalsize;
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- calcDrawDMNormalScale(ob, &data);
-
- if (dm->getNumPolys(dm) == 0) return;
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformThemeColor(theme_id);
-
- immBeginAtMost(GWN_PRIM_LINES, dm->getNumPolys(dm) * 2);
- dm->foreachMappedFaceCenter(dm, draw_dm_face_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL);
- immEnd();
-
- immUnbindProgram();
-}
-
-static void draw_dm_face_centers__mapFunc(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
-{
- drawBMSelect_userData *data = userData;
- BMFace *efa = BM_face_at_index(data->bm, index);
-
- if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) &&
- (BM_elem_flag_test(efa, BM_ELEM_SELECT) == data->select))
- {
- immVertex3fv(data->pos, cent);
- }
-}
-static void draw_dm_face_centers(BMEditMesh *em, DerivedMesh *dm, bool select, const unsigned char fcol[3])
-{
- Gwn_VertFormat *format = immVertexFormat();
-
- drawBMSelect_userData data;
- data.bm = em->bm;
- data.select = select;
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- if (dm->getNumPolys(dm) == 0) return;
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor3ubv(fcol);
-
- immBeginAtMost(GWN_PRIM_POINTS, dm->getNumPolys(dm));
- dm->foreachMappedFaceCenter(dm, draw_dm_face_centers__mapFunc, &data, DM_FOREACH_NOP);
- immEnd();
-
- immUnbindProgram();
-}
-
-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 = BM_vert_at_index(data->bm, index);
-
- if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- float no[3], n[3];
-
- if (no_f) {
- copy_v3_v3(no, no_f);
- }
- else {
- normal_short_to_float_v3(no, no_s);
- }
-
- if (!data->uniform_scale) {
- mul_v3_m3v3(n, data->tmat, no);
- normalize_v3(n);
- mul_m3_v3(data->imat, n);
- }
- else {
- copy_v3_v3(n, no);
- }
-
- immVertex3fv(data->pos, co);
- immVertex3f(data->pos, co[0] + n[0] * data->normalsize,
- co[1] + n[1] * data->normalsize,
- co[2] + n[2] * data->normalsize);
- }
-}
-
-static void draw_dm_vert_normals(BMEditMesh *em, Scene *scene, Object *ob, DerivedMesh *dm, int theme_id)
-{
- drawDMNormal_userData data;
- Gwn_VertFormat *format = immVertexFormat();
-
- data.bm = em->bm;
- data.normalsize = scene->toolsettings->normalsize;
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- calcDrawDMNormalScale(ob, &data);
-
- if (dm->getNumVerts(dm) == 0) return;
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformThemeColor(theme_id);
-
- immBeginAtMost(GWN_PRIM_LINES, dm->getNumVerts(dm) * 2);
- dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL);
- immEnd();
-
- immUnbindProgram();
-}
-
-static void draw_dm_verts_skin_root__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 = 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 node(s) */
- const MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, data->cd_vskin_offset);
- if (vs->flag & MVERT_SKIN_ROOT) {
- float radius = (vs->radius[0] + vs->radius[1]) * 0.5f;
- imm_drawcircball(co, radius, data->imat, data->pos);
- }
- }
-}
-
-/* Draw verts with color set based on selection */
-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 = 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) {
- /* draw active in a different color - no need to stop/start point drawing for this :D */
- if (eve == data->eve_act) {
- immAttrib4ubv(data->color, data->th_editmesh_active);
- immVertex3fv(data->pos, co);
- }
- else {
- immAttrib4ubv(data->color, data->sel ? data->th_vertex_select : data->th_vertex);
- immVertex3fv(data->pos, co);
- }
- }
-}
-
-static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, const char sel, BMVert *eve_act,
- RegionView3D *rv3d, const unsigned char col[4])
-{
- Gwn_VertFormat *format = immVertexFormat();
-
- drawDMVerts_userData data;
- data.sel = sel;
- data.eve_act = eve_act;
- data.bm = em->bm;
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- data.color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
-
- /* Cache theme values */
- UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, data.th_editmesh_active);
- UI_GetThemeColor4ubv(TH_VERTEX_SELECT, data.th_vertex_select);
- UI_GetThemeColor4ubv(TH_VERTEX, data.th_vertex);
- UI_GetThemeColor4ubv(TH_SKIN_ROOT, data.th_skin_root);
-
- /* Set correct alpha */
- data.th_editmesh_active[3] = data.th_vertex_select[3] = data.th_vertex[3] = data.th_skin_root[3] = col[3];
-
- /* view-aligned matrix */
- mul_m4_m4m4(data.imat, rv3d->viewmat, em->ob->obmat);
- invert_m4(data.imat);
-
- if (dm->getNumVerts(dm) == 0) return;
-
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
-
- immBeginAtMost(GWN_PRIM_POINTS, dm->getNumVerts(dm));
- dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &data, DM_FOREACH_NOP);
- immEnd();
-
- immUnbindProgram();
-
- /* For skin root drawing */
- data.cd_vskin_offset = CustomData_get_offset(&em->bm->vdata, CD_MVERT_SKIN);
-
- if (data.cd_vskin_offset != -1) {
- data.pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor4ubv(data.th_skin_root);
-
- dm->foreachMappedVert(dm, draw_dm_verts_skin_root__mapFunc, &data, DM_FOREACH_NOP);
-
- immUnbindProgram();
- }
-}
-
-/* Draw edges with color set based on selection */
-static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index)
-{
- BMEdge *eed;
- drawDMEdgesSel_userData *data = userData;
- unsigned char *col;
-
- eed = BM_edge_at_index(data->bm, index);
-
- if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- if (eed == data->eed_act) {
- glColor4ubv(data->actCol);
- }
- else {
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- col = data->selCol;
- }
- else {
- col = data->baseCol;
- }
- /* no alpha, this is used so a transparent color can disable drawing unselected edges in editmode */
- if (col[3] == 0)
- return DM_DRAW_OPTION_SKIP;
-
- glColor4ubv(col);
- }
- return DM_DRAW_OPTION_NORMAL;
- }
- else {
- return DM_DRAW_OPTION_SKIP;
- }
-}
-
-static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
- unsigned char *selCol, unsigned char *actCol, BMEdge *eed_act)
-{
- drawDMEdgesSel_userData data;
-
- data.baseCol = baseCol;
- data.selCol = selCol;
- data.actCol = actCol;
- data.bm = em->bm;
- data.eed_act = eed_act;
- dm->drawMappedEdges(dm, draw_dm_edges_sel__setDrawOptions, &data);
-}
-
-/* Draw edges */
-static DMDrawOption draw_dm_edges__setDrawOptions(void *userData, int index)
-{
- 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;
-}
-
-static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm)
-{
- 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)
-{
- drawDMEdgesSelInterp_userData *data = userData;
- if (BM_elem_flag_test(BM_edge_at_index(data->bm, 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)
-{
- drawDMEdgesSelInterp_userData *data = userData;
- BMEdge *eed = BM_edge_at_index(data->bm, index);
- unsigned char **cols = userData;
- unsigned int col0_id = (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT)) ? 2 : 1;
- unsigned int col1_id = (BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1;
- unsigned char *col0 = cols[col0_id];
- unsigned char *col1 = cols[col1_id];
- unsigned char *col_pt;
-
- if (col0_id == col1_id) {
- col_pt = col0;
- }
- else if (t == 0.0f) {
- col_pt = col0;
- }
- else if (t == 1.0f) {
- col_pt = col1;
- }
- else {
- unsigned char col_blend[4];
- interp_v4_v4v4_uchar(col_blend, col0, col1, t);
- glColor4ubv(col_blend);
- data->lastCol = NULL;
- return;
- }
-
- if (data->lastCol != col_pt) {
- data->lastCol = col_pt;
- glColor4ubv(col_pt);
- }
-}
-
-static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
-{
- drawDMEdgesSelInterp_userData data;
- data.bm = em->bm;
- data.baseCol = baseCol;
- data.selCol = selCol;
- data.lastCol = NULL;
-
- dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, &data);
-}
-
-static void bm_color_from_weight(float col[3], BMVert *vert, drawDMEdgesWeightInterp_userData *data)
-{
- MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(vert, data->cd_dvert_offset);
- float weight = defvert_find_weight(dvert, data->vgroup_index);
-
- if ((weight == 0.0f) &&
- ((data->weight_user == OB_DRAW_GROUPUSER_ACTIVE) ||
- ((data->weight_user == OB_DRAW_GROUPUSER_ALL) && defvert_is_weight_zero(dvert, data->defgroup_tot))))
- {
- copy_v3_v3(col, data->alert_color);
- }
- else {
- weight_to_rgb(col, weight);
- }
-}
-
-static void draw_dm_edges_nop_interp__setDrawInterpOptions(void *UNUSED(userData), int UNUSED(index), float UNUSED(t))
-{
- /* pass */
-}
-
-static void draw_dm_edges_weight_interp__setDrawInterpOptions(void *userData, int index, float t)
-{
- drawDMEdgesWeightInterp_userData *data = userData;
- BMEdge *eed = BM_edge_at_index(data->bm, index);
- float col[3];
-
- if (t == 0.0f) {
- bm_color_from_weight(col, eed->v1, data);
- }
- else if (t == 1.0f) {
- bm_color_from_weight(col, eed->v2, data);
- }
- else {
- float col_v1[3];
- float col_v2[3];
-
- bm_color_from_weight(col_v1, eed->v1, data);
- bm_color_from_weight(col_v2, eed->v2, data);
- interp_v3_v3v3(col, col_v1, col_v2, t);
- }
-
- glColor3fv(col);
-}
-
-static void draw_dm_edges_weight_interp(BMEditMesh *em, DerivedMesh *dm, const char weight_user)
-{
- drawDMEdgesWeightInterp_userData data;
- Object *ob = em->ob;
-
- data.bm = em->bm;
- data.cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
- data.defgroup_tot = BLI_listbase_count(&ob->defbase);
- data.vgroup_index = ob->actdef - 1;
- data.weight_user = weight_user;
- UI_GetThemeColor3fv(TH_VERTEX_UNREFERENCED, data.alert_color);
-
- if ((data.vgroup_index != -1) && (data.cd_dvert_offset != -1)) {
- glEnable(GL_BLEND);
- dm->drawMappedEdgesInterp(
- dm,
- draw_dm_edges_sel_interp__setDrawOptions,
- draw_dm_edges_weight_interp__setDrawInterpOptions,
- &data);
- glDisable(GL_BLEND);
- }
- else {
- float col[3];
-
- if (data.weight_user == OB_DRAW_GROUPUSER_NONE) {
- weight_to_rgb(col, 0.0f);
- }
- else {
- copy_v3_v3(col, data.alert_color);
- }
- glColor3fv(col);
-
- dm->drawMappedEdgesInterp(
- dm,
- draw_dm_edges_sel_interp__setDrawOptions,
- draw_dm_edges_nop_interp__setDrawInterpOptions,
- &data);
- }
-
-}
-
-static bool draw_dm_edges_weight_check(Mesh *me, View3D *v3d)
-{
- if (me->drawflag & ME_DRAWEIGHT) {
- if ((v3d->drawtype == OB_WIRE) ||
- (v3d->flag2 & V3D_SOLID_MATCAP) ||
- ((v3d->flag2 & V3D_OCCLUDE_WIRE) && (v3d->drawtype > OB_WIRE)))
- {
- return true;
- }
- }
-
- return false;
-}
-
-/* Draw only seam edges */
-static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int 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;
- else
- return DM_DRAW_OPTION_SKIP;
-}
-
-static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm)
-{
- 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 = 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;
- else
- return DM_DRAW_OPTION_SKIP;
-}
-
-static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm)
-{
- dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em->bm);
-}
-
-#ifdef WITH_FREESTYLE
-
-static bool draw_dm_test_freestyle_edge_mark(BMesh *bm, BMEdge *eed)
-{
- FreestyleEdge *fed = CustomData_bmesh_get(&bm->edata, eed->head.data, CD_FREESTYLE_EDGE);
- if (!fed)
- return false;
- return (fed->flag & FREESTYLE_EDGE_MARK) != 0;
-}
-
-/* Draw only Freestyle feature edges */
-static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int 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;
- else
- return DM_DRAW_OPTION_SKIP;
-}
-
-static void draw_dm_edges_freestyle(BMEditMesh *em, DerivedMesh *dm)
-{
- dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em->bm);
-}
-
-static bool draw_dm_test_freestyle_face_mark(BMesh *bm, BMFace *efa)
-{
- FreestyleFace *ffa = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_FREESTYLE_FACE);
- if (!ffa)
- return false;
- return (ffa->flag & FREESTYLE_FACE_MARK) != 0;
-}
-
-#endif
-
-/* Draw loop normals. */
-static void draw_dm_loop_normals__mapFunc(void *userData, int vertex_index, int face_index,
- const float co[3], const float no[3])
-{
- if (no) {
- const drawDMNormal_userData *data = userData;
- const BMVert *eve = BM_vert_at_index(data->bm, vertex_index);
- const BMFace *efa = BM_face_at_index(data->bm, face_index);
- float vec[3];
-
- if (!(BM_elem_flag_test(eve, BM_ELEM_HIDDEN) || BM_elem_flag_test(efa, BM_ELEM_HIDDEN))) {
- if (!data->uniform_scale) {
- mul_v3_m3v3(vec, (float(*)[3])data->tmat, no);
- normalize_v3(vec);
- mul_m3_v3((float(*)[3])data->imat, vec);
- }
- else {
- copy_v3_v3(vec, no);
- }
- mul_v3_fl(vec, data->normalsize);
- add_v3_v3(vec, co);
- immVertex3fv(data->pos, co);
- immVertex3fv(data->pos, vec);
- }
- }
-}
-
-static void draw_dm_loop_normals(BMEditMesh *em, Scene *scene, Object *ob, DerivedMesh *dm, int theme_id)
-{
- drawDMNormal_userData data;
-
- data.bm = em->bm;
- data.normalsize = scene->toolsettings->normalsize;
- data.pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- if (dm->getNumLoops(dm) == 0) return;
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformThemeColor(theme_id);
-
- calcDrawDMNormalScale(ob, &data);
-
- immBeginAtMost(GWN_PRIM_LINES, dm->getNumLoops(dm) * 2);
- dm->foreachMappedLoop(dm, draw_dm_loop_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL);
- immEnd();
-
- immUnbindProgram();
-}
-
-/* Draw faces with color set based on selection
- * return 2 for the active face so it renders with stipple enabled */
-static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index)
-{
- drawDMFacesSel_userData *data = userData;
- BMFace *efa = BM_face_at_index(data->bm, index);
- unsigned char *col;
-
- if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
- if (efa == data->efa_act) {
- glColor4ubv(data->cols[2]);
- return DM_DRAW_OPTION_STIPPLE;
- }
- else {
-#ifdef WITH_FREESTYLE
- 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
- if (col[3] == 0)
- return DM_DRAW_OPTION_SKIP;
- glColor4ubv(col);
- return DM_DRAW_OPTION_NORMAL;
- }
- }
- return DM_DRAW_OPTION_SKIP;
-}
-
-static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index)
-{
-
- drawDMFacesSel_userData *data = userData;
- int i;
- BMFace *efa;
- BMFace *next_efa;
-
- unsigned char *col, *next_col;
-
- i = data->orig_index_mp_to_orig ? data->orig_index_mp_to_orig[index] : index;
- efa = (i != ORIGINDEX_NONE) ? BM_face_at_index(data->bm, i) : NULL;
- i = data->orig_index_mp_to_orig ? data->orig_index_mp_to_orig[next_index] : next_index;
- next_efa = (i != ORIGINDEX_NONE) ? BM_face_at_index(data->bm, i) : NULL;
-
- if (ELEM(NULL, efa, next_efa))
- return 0;
-
- if (efa == next_efa)
- return 1;
-
- if (efa == data->efa_act || next_efa == data->efa_act)
- return 0;
-
-#ifdef WITH_FREESTYLE
- 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];
-#endif
-
- if (col[3] == 0 || next_col[3] == 0)
- return 0;
-
- return col == next_col;
-}
-
-/* also draws the active face */
-#ifdef WITH_FREESTYLE
-static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
- unsigned char *selCol, unsigned char *actCol, unsigned char *markCol, BMFace *efa_act)
-#else
-static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
- unsigned char *selCol, unsigned char *actCol, BMFace *efa_act)
-#endif
-{
- drawDMFacesSel_userData data;
- data.dm = dm;
- data.cols[0] = baseCol;
- data.bm = em->bm;
- data.cols[1] = selCol;
- data.cols[2] = actCol;
-#ifdef WITH_FREESTYLE
- data.cols[3] = markCol;
-#endif
- data.efa_act = efa_act;
- /* double lookup */
- data.orig_index_mp_to_orig = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
-
- dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, NULL, draw_dm_faces_sel__compareDrawOptions, &data, DM_DRAW_SKIP_HIDDEN);
-}
-
-static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index)
-{
- drawDMLayer_userData *data = userData;
- 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);
- if (crease != 0.0f) {
- UI_ThemeColorBlend(TH_WIRE_EDIT, TH_EDGE_CREASE, crease);
- return DM_DRAW_OPTION_NORMAL;
- }
- }
- return DM_DRAW_OPTION_SKIP;
-}
-static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm)
-{
- drawDMLayer_userData data;
-
- data.bm = em->bm;
- data.cd_layer_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE);
-
- if (data.cd_layer_offset != -1) {
- glLineWidth(3.0f);
- dm->drawMappedEdges(dm, draw_dm_creases__setDrawOptions, &data);
- }
-}
-
-static DMDrawOption draw_dm_bweights__setDrawOptions(void *userData, int index)
-{
- drawDMLayer_userData *data = userData;
- 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);
- if (bweight != 0.0f) {
- UI_ThemeColorBlend(TH_WIRE_EDIT, TH_EDGE_BEVEL, bweight);
- return DM_DRAW_OPTION_NORMAL;
- }
- }
- return DM_DRAW_OPTION_SKIP;
-}
-static void draw_dm_bweights__mapFunc(void *userData, int index, const float co[3],
- const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
-{
- drawDMLayer_userData *data = userData;
- 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);
- if (bweight != 0.0f) {
- unsigned char col[3];
- UI_GetThemeColorBlend3ubv(TH_VERTEX, TH_VERTEX_BEVEL, bweight, col);
- immAttrib3ubv(data->col, col);
- immVertex3fv(data->pos, co);
- }
- }
-}
-static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm)
-{
- ToolSettings *ts = scene->toolsettings;
-
- if (ts->selectmode & SCE_SELECT_VERTEX) {
- drawDMLayer_userData data;
-
- data.bm = em->bm;
- data.cd_layer_offset = CustomData_get_offset(&em->bm->vdata, CD_BWEIGHT);
-
- /* is that ever true? */
- if (data.cd_layer_offset != -1) {
- Gwn_VertFormat *format = immVertexFormat();
- data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) + 2.0f);
-
- immBeginAtMost(GWN_PRIM_POINTS, dm->getNumVerts(dm));
- dm->foreachMappedVert(dm, draw_dm_bweights__mapFunc, &data, DM_FOREACH_NOP);
- immEnd();
-
- immUnbindProgram();
- }
- }
- else {
- drawDMLayer_userData data;
-
- data.bm = em->bm;
- data.cd_layer_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT);
-
- if (data.cd_layer_offset != -1) {
- glLineWidth(3.0f);
- dm->drawMappedEdges(dm, draw_dm_bweights__setDrawOptions, &data);
- }
- }
-}
-
-/* Second section of routines: Combine first sets to form fancy
- * drawing routines (for example rendering twice to get overlays).
- *
- * Also includes routines that are basic drawing but are too
- * specialized to be split out (like drawing creases or measurements).
- */
-
-/* EditMesh drawing routines */
-
-static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit,
- BMEditMesh *em, DerivedMesh *cageDM, BMVert *eve_act,
- RegionView3D *rv3d)
-{
- ToolSettings *ts = scene->toolsettings;
-
- if (v3d->zbuf) glDepthMask(GL_FALSE); /* disable write in zbuffer, zbuf select */
-
- for (int sel = 0; sel < 2; sel++) {
- unsigned char col[4], fcol[4];
-
- UI_GetThemeColor3ubv(sel ? TH_VERTEX_SELECT : TH_VERTEX, col);
- UI_GetThemeColor3ubv(sel ? TH_FACE_DOT : TH_WIRE_EDIT, fcol);
-
- for (int pass = 0; pass < 2; pass++) {
- float size = UI_GetThemeValuef(TH_VERTEX_SIZE);
- float fsize = UI_GetThemeValuef(TH_FACEDOT_SIZE);
-
- if (pass == 0) {
- if (v3d->zbuf && !(v3d->flag & V3D_ZBUF_SELECT)) {
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_BLEND);
- }
- else {
- continue;
- }
-
- size = (size > 2.1f ? size / 2.0f : size);
- fsize = (fsize > 2.1f ? fsize / 2.0f : fsize);
- col[3] = fcol[3] = 100;
- }
- else {
- col[3] = fcol[3] = 255;
- }
-
- if (ts->selectmode & SCE_SELECT_VERTEX) {
- draw_dm_verts(em, cageDM, sel, eve_act, rv3d, col);
- }
-
- if (check_ob_drawface_dot(scene, v3d, obedit->dt)) {
- glPointSize(fsize);
- draw_dm_face_centers(em, cageDM, sel, fcol);
- }
-
- if (pass == 0) {
- glDisable(GL_BLEND);
- glEnable(GL_DEPTH_TEST);
- }
- }
- }
-
- if (v3d->zbuf) glDepthMask(GL_TRUE);
-}
-
-static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d,
- Mesh *me, DerivedMesh *cageDM, short sel_only,
- BMEdge *eed_act)
-{
- ToolSettings *ts = scene->toolsettings;
- unsigned char wireCol[4], selCol[4], actCol[4];
-
- /* since this function does transparent... */
- UI_GetThemeColor4ubv(TH_EDGE_SELECT, selCol);
- UI_GetThemeColor4ubv(TH_WIRE_EDIT, wireCol);
- UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, actCol);
-
- /* when sel only is used, don't render wire, only selected, this is used for
- * textured draw mode when the 'edges' option is disabled */
- if (sel_only)
- wireCol[3] = 0;
-
- for (int pass = 0; pass < 2; pass++) {
- /* show wires in transparent when no zbuf clipping for select */
- if (pass == 0) {
- if (v3d->zbuf && (v3d->flag & V3D_ZBUF_SELECT) == 0) {
- glEnable(GL_BLEND);
- glDisable(GL_DEPTH_TEST);
- selCol[3] = 85;
- if (!sel_only) wireCol[3] = 85;
- }
- else {
- continue;
- }
- }
- else {
- selCol[3] = 255;
- if (!sel_only) wireCol[3] = 255;
- }
-
- if ((me->drawflag & ME_DRAWEDGES) || (ts->selectmode & SCE_SELECT_EDGE)) {
- if (cageDM->drawMappedEdgesInterp &&
- ((ts->selectmode & SCE_SELECT_VERTEX) || (me->drawflag & ME_DRAWEIGHT)))
- {
- if (draw_dm_edges_weight_check(me, v3d)) {
- // Interpolate vertex weights
- draw_dm_edges_weight_interp(em, cageDM, ts->weightuser);
- }
- else if (ts->selectmode == SCE_SELECT_FACE) {
- draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act);
- }
- else {
- // Interpolate vertex selection
- draw_dm_edges_sel_interp(em, cageDM, wireCol, selCol);
- }
- }
- else {
- draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act);
- }
- }
- else {
- if (!sel_only) {
- glColor4ubv(wireCol);
- draw_dm_edges(em, cageDM);
- }
- }
-
- if (pass == 0) {
- glDisable(GL_BLEND);
- glEnable(GL_DEPTH_TEST);
- }
- }
-}
-
-static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMesh *em, UnitSettings *unit)
-{
- /* 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 */
- size_t numstr_len;
- const char *conv_float; /* Use a float conversion matching the grid size */
- unsigned char col[4] = {0, 0, 0, 255}; /* color of the text to draw */
- float area; /* area of the face */
- float grid = unit->system ? unit->scale_length : v3d->grid;
- const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0;
- const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0;
- const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 0;
- /* when 2 edge-info options are enabled, space apart */
- const bool do_edge_textpair = (me->drawflag & ME_DRAWEXTRA_EDGELEN) && (me->drawflag & ME_DRAWEXTRA_EDGEANG);
- const float edge_texpair_sep = 0.4f;
- float clip_planes[4][4];
- /* allow for displaying shape keys and deform mods */
- DerivedMesh *dm = EDBM_mesh_deform_dm_get(em);
- BMIter iter;
-
- /* make the precision of the display value proportionate to the gridsize */
-
- if (grid <= 0.01f) conv_float = "%.6g";
- else if (grid <= 0.1f) conv_float = "%.5g";
- else if (grid <= 1.0f) conv_float = "%.4g";
- else if (grid <= 10.0f) conv_float = "%.3g";
- else conv_float = "%.2g";
-
- if (me->drawflag & (ME_DRAWEXTRA_EDGELEN | ME_DRAWEXTRA_EDGEANG)) {
- BoundBox bb;
- const rcti rect = {0, ar->winx, 0, ar->winy};
-
- ED_view3d_clipping_calc(&bb, clip_planes, ar, em->ob, &rect);
- }
-
- if (me->drawflag & ME_DRAWEXTRA_EDGELEN) {
- BMEdge *eed;
-
- UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
-
- if (dm) {
- BM_mesh_elem_index_ensure(em->bm, BM_VERT);
- }
-
- BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- /* draw selected edges, or edges next to selected verts while dragging */
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT) ||
- (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
- BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))))
- {
- float v1_clip[3], v2_clip[3];
-
- if (dm) {
- dm->getVertCo(dm, BM_elem_index_get(eed->v1), v1);
- dm->getVertCo(dm, BM_elem_index_get(eed->v2), v2);
- }
- else {
- copy_v3_v3(v1, eed->v1->co);
- copy_v3_v3(v2, eed->v2->co);
- }
-
- if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) {
-
- if (do_edge_textpair) {
- interp_v3_v3v3(vmid, v1, v2, edge_texpair_sep);
- }
- else {
- mid_v3_v3v3(vmid, v1_clip, v2_clip);
- }
-
- if (do_global) {
- mul_mat3_m4_v3(ob->obmat, v1);
- mul_mat3_m4_v3(ob->obmat, v2);
- }
-
- if (unit->system) {
- numstr_len = bUnit_AsString(numstr, sizeof(numstr), len_v3v3(v1, v2) * unit->scale_length, 3,
- unit->system, B_UNIT_LENGTH, do_split, false);
- }
- else {
- numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2));
- }
-
- view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col);
- }
- }
- }
- }
-
- if (me->drawflag & ME_DRAWEXTRA_EDGEANG) {
- const bool is_rad = (unit->system_rotation == USER_UNIT_ROT_RADIANS);
- BMEdge *eed;
-
- UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGEANG, col);
-
- if (dm) {
- BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
- }
-
- BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- BMLoop *l_a, *l_b;
- if (BM_edge_loop_pair(eed, &l_a, &l_b)) {
- /* draw selected edges, or edges next to selected verts while dragging */
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT) ||
- (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
- BM_elem_flag_test(eed->v2, BM_ELEM_SELECT) ||
- /* special case, this is useful to show when verts connected to
- * this edge via a face are being transformed */
- BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) ||
- BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) ||
- BM_elem_flag_test(l_b->next->next->v, BM_ELEM_SELECT) ||
- BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT)
- )))
- {
- float v1_clip[3], v2_clip[3];
-
- if (dm) {
- dm->getVertCo(dm, BM_elem_index_get(eed->v1), v1);
- dm->getVertCo(dm, BM_elem_index_get(eed->v2), v2);
- }
- else {
- copy_v3_v3(v1, eed->v1->co);
- copy_v3_v3(v2, eed->v2->co);
- }
-
- if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) {
- float no_a[3], no_b[3];
- float angle;
-
- if (do_edge_textpair) {
- interp_v3_v3v3(vmid, v2_clip, v1_clip, edge_texpair_sep);
- }
- else {
- mid_v3_v3v3(vmid, v1_clip, v2_clip);
- }
-
- if (dm) {
- dm->getPolyNo(dm, BM_elem_index_get(l_a->f), no_a);
- dm->getPolyNo(dm, BM_elem_index_get(l_b->f), no_b);
- }
- else {
- copy_v3_v3(no_a, l_a->f->no);
- copy_v3_v3(no_b, l_b->f->no);
- }
-
- if (do_global) {
- mul_mat3_m4_v3(ob->imat, no_a);
- mul_mat3_m4_v3(ob->imat, no_b);
- normalize_v3(no_a);
- normalize_v3(no_b);
- }
-
- angle = angle_normalized_v3v3(no_a, no_b);
-
- numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
-
- view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col);
- }
- }
- }
- }
- }
-
- if (me->drawflag & ME_DRAWEXTRA_FACEAREA) {
- /* would be nice to use BM_face_calc_area, but that is for 2d faces
- * so instead add up tessellation triangle areas */
- BMFace *f = NULL;
-
-#define DRAW_EM_MEASURE_STATS_FACEAREA() \
- if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { \
- mul_v3_fl(vmid, 1.0f / (float)n); \
- if (unit->system) { \
- numstr_len = bUnit_AsString( \
- numstr, sizeof(numstr), \
- (double)(area * unit->scale_length * unit->scale_length), \
- 3, unit->system, B_UNIT_AREA, do_split, false); \
- } \
- else { \
- numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, area); \
- } \
- view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col); \
- } (void)0
-
- UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
-
- if (dm) {
- BM_mesh_elem_index_ensure(em->bm, BM_VERT);
- }
-
- area = 0.0;
- zero_v3(vmid);
- int n = 0;
- for (int i = 0; i < em->tottri; i++) {
- BMLoop **l = em->looptris[i];
- if (f && l[0]->f != f) {
- DRAW_EM_MEASURE_STATS_FACEAREA();
- zero_v3(vmid);
- area = 0.0;
- n = 0;
- }
-
- f = l[0]->f;
-
- if (dm) {
- dm->getVertCo(dm, BM_elem_index_get(l[0]->v), v1);
- dm->getVertCo(dm, BM_elem_index_get(l[1]->v), v2);
- dm->getVertCo(dm, BM_elem_index_get(l[2]->v), v3);
- }
- else {
- copy_v3_v3(v1, l[0]->v->co);
- copy_v3_v3(v2, l[1]->v->co);
- copy_v3_v3(v3, l[2]->v->co);
- }
-
- add_v3_v3(vmid, v1);
- add_v3_v3(vmid, v2);
- add_v3_v3(vmid, v3);
- n += 3;
- if (do_global) {
- mul_mat3_m4_v3(ob->obmat, v1);
- mul_mat3_m4_v3(ob->obmat, v2);
- mul_mat3_m4_v3(ob->obmat, v3);
- }
- area += area_tri_v3(v1, v2, v3);
- }
-
- if (f) {
- DRAW_EM_MEASURE_STATS_FACEAREA();
- }
-#undef DRAW_EM_MEASURE_STATS_FACEAREA
- }
-
- if (me->drawflag & ME_DRAWEXTRA_FACEANG) {
- BMFace *efa;
- const bool is_rad = (unit->system_rotation == USER_UNIT_ROT_RADIANS);
-
- UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
-
- if (dm) {
- BM_mesh_elem_index_ensure(em->bm, BM_VERT);
- }
-
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- const bool is_face_sel = BM_elem_flag_test_bool(efa, BM_ELEM_SELECT);
-
- if (is_face_sel || do_moving) {
- BMIter liter;
- BMLoop *loop;
- bool is_first = true;
-
- BM_ITER_ELEM (loop, &liter, efa, BM_LOOPS_OF_FACE) {
- if (is_face_sel ||
- (do_moving &&
- (BM_elem_flag_test(loop->v, BM_ELEM_SELECT) ||
- BM_elem_flag_test(loop->prev->v, BM_ELEM_SELECT) ||
- BM_elem_flag_test(loop->next->v, BM_ELEM_SELECT))))
- {
- float v2_local[3];
-
- /* lazy init center calc */
- if (is_first) {
- if (dm) {
- BMLoop *l_iter, *l_first;
- float tvec[3];
- zero_v3(vmid);
- l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
- do {
- dm->getVertCo(dm, BM_elem_index_get(l_iter->v), tvec);
- add_v3_v3(vmid, tvec);
- } while ((l_iter = l_iter->next) != l_first);
- mul_v3_fl(vmid, 1.0f / (float)efa->len);
- }
- else {
- BM_face_calc_center_bounds(efa, vmid);
- }
- is_first = false;
- }
-
- if (dm) {
- dm->getVertCo(dm, BM_elem_index_get(loop->prev->v), v1);
- dm->getVertCo(dm, BM_elem_index_get(loop->v), v2);
- dm->getVertCo(dm, BM_elem_index_get(loop->next->v), v3);
- }
- else {
- copy_v3_v3(v1, loop->prev->v->co);
- copy_v3_v3(v2, loop->v->co);
- copy_v3_v3(v3, loop->next->v->co);
- }
-
- copy_v3_v3(v2_local, v2);
-
- if (do_global) {
- mul_mat3_m4_v3(ob->obmat, v1);
- mul_mat3_m4_v3(ob->obmat, v2);
- mul_mat3_m4_v3(ob->obmat, v3);
- }
-
- float angle = angle_v3v3v3(v1, v2, v3);
-
- numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
- interp_v3_v3v3(fvec, vmid, v2_local, 0.8f);
- view3d_cached_text_draw_add(fvec, numstr, numstr_len, 0, txt_flag, col);
- }
- }
- }
- }
- }
-}
-
-static void draw_em_indices(BMEditMesh *em)
-{
- const short txt_flag = V3D_CACHE_TEXT_ASCII | V3D_CACHE_TEXT_LOCALCLIP;
- BMEdge *e;
- BMFace *f;
- BMVert *v;
- char numstr[32];
- size_t numstr_len;
- float pos[3];
- unsigned char col[4];
-
- BMIter iter;
- BMesh *bm = em->bm;
-
- /* For now, reuse appropriate theme colors from stats text colors */
- int i = 0;
- if (em->selectmode & SCE_SELECT_VERTEX) {
- UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
- numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
- view3d_cached_text_draw_add(v->co, numstr, numstr_len, 0, txt_flag, col);
- }
- i++;
- }
- }
-
- if (em->selectmode & SCE_SELECT_EDGE) {
- i = 0;
- UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
- numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
- mid_v3_v3v3(pos, e->v1->co, e->v2->co);
- view3d_cached_text_draw_add(pos, numstr, numstr_len, 0, txt_flag, col);
- }
- i++;
- }
- }
-
- if (em->selectmode & SCE_SELECT_FACE) {
- i = 0;
- UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
- BM_face_calc_center_mean(f, pos);
- numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
- view3d_cached_text_draw_add(pos, numstr, numstr_len, 0, txt_flag, col);
- }
- i++;
- }
- }
-}
-
-static DMDrawOption draw_em_fancy__setFaceOpts(void *userData, int index)
-{
- BMEditMesh *em = userData;
-
- if (UNLIKELY(index >= em->bm->totface))
- return DM_DRAW_OPTION_NORMAL;
-
- BMFace *efa = BM_face_at_index(em->bm, index);
- if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
- return DM_DRAW_OPTION_NORMAL;
- }
- else {
- return DM_DRAW_OPTION_SKIP;
- }
-}
-
-static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index)
-{
- BMEditMesh *em = userData;
-
- if (UNLIKELY(index >= em->bm->totface))
- return DM_DRAW_OPTION_NORMAL;
-
- BMFace *efa = BM_face_at_index(em->bm, index);
-
- if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
- return DM_DRAW_OPTION_NORMAL;
- }
- else {
- return DM_DRAW_OPTION_SKIP;
- }
-}
-
-static void draw_em_fancy(Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d,
- Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt)
-
-{
- RegionView3D *rv3d = ar->regiondata;
- Mesh *me = ob->data;
- const bool use_occlude_wire = (dt > OB_WIRE) && (v3d->flag2 & V3D_OCCLUDE_WIRE);
- bool use_depth_offset = false;
-
- glLineWidth(1.0f);
-
- BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
-
- if (check_object_draw_editweight(me, finalDM)) {
- if (dt > OB_WIRE) {
- draw_mesh_paint_weight_faces(finalDM, true, draw_em_fancy__setFaceOpts, me->edit_btmesh);
-
- ED_view3d_polygon_offset(rv3d, 1.0);
- glDepthMask(GL_FALSE);
- use_depth_offset = true;
- }
- 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, true, draw_dm_edges__setDrawOptions, me->edit_btmesh->bm);
- glDisable(GL_DEPTH_TEST);
- }
- }
- else if (dt > OB_WIRE) {
- if (use_occlude_wire) {
- /* use the cageDM since it always overlaps the editmesh faces */
- glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
- cageDM->drawMappedFaces(cageDM, draw_em_fancy__setFaceOpts,
- GPU_object_material_bind, NULL, me->edit_btmesh, DM_DRAW_SKIP_HIDDEN | DM_DRAW_NEED_NORMALS);
- GPU_object_material_unbind();
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- }
- else if (check_object_draw_texture(scene, v3d, dt)) {
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
-
- finalDM->drawMappedFacesGLSL(finalDM, GPU_object_material_bind,
- draw_em_fancy__setGLSLFaceOpts, em);
- GPU_object_material_unbind();
-
- glFrontFace(GL_CCW);
- }
- else {
- draw_mesh_textured(scene, view_layer, v3d, rv3d, ob, finalDM, 0);
- }
- }
- else {
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, GPU_object_material_bind, NULL, me->edit_btmesh, DM_DRAW_SKIP_HIDDEN | DM_DRAW_NEED_NORMALS);
-
- glFrontFace(GL_CCW);
-
- GPU_object_material_unbind();
- }
-
- /* Setup for drawing wire over, disable zbuffer
- * write to show selected edge wires better */
- UI_ThemeColor(TH_WIRE_EDIT);
-
- ED_view3d_polygon_offset(rv3d, 1.0);
- glDepthMask(GL_FALSE);
- use_depth_offset = true;
- }
- else {
- if (cageDM != finalDM) {
- UI_ThemeColorBlend(TH_WIRE_EDIT, TH_BACK, 0.7);
- finalDM->drawEdges(finalDM, 1, 0);
- }
- }
-
- if ((dt > OB_WIRE) && (v3d->flag2 & V3D_RENDER_SHADOW)) {
- /* pass */
- }
- else {
- /* annoying but active faces is stored differently */
- BMFace *efa_act = BM_mesh_active_face_get(em->bm, false, true);
- BMEdge *eed_act = NULL;
- BMVert *eve_act = NULL;
-
- if (em->bm->selected.last) {
- BMEditSelection *ese = em->bm->selected.last;
- /* face is handled above */
-#if 0
- if (ese->type == BM_FACE) {
- efa_act = (BMFace *)ese->data;
- }
- else
-#endif
- if (ese->htype == BM_EDGE) {
- eed_act = (BMEdge *)ese->ele;
- }
- else if (ese->htype == BM_VERT) {
- eve_act = (BMVert *)ese->ele;
- }
- }
-
- if ((me->drawflag & ME_DRAWFACES) && (use_occlude_wire == false)) { /* transp faces */
- unsigned char col1[4], col2[4], col3[4];
-#ifdef WITH_FREESTYLE
- unsigned char col4[4];
-#endif
-
- UI_GetThemeColor4ubv(TH_FACE, col1);
- UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
- UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
-#ifdef WITH_FREESTYLE
- UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col4);
-#endif
-
- glEnable(GL_BLEND);
- glDepthMask(GL_FALSE); /* disable write in zbuffer, needed for nice transp */
-
- /* don't draw unselected faces, only selected, this is MUCH nicer when texturing */
- if (check_object_draw_texture(scene, v3d, dt))
- col1[3] = 0;
-
-#ifdef WITH_FREESTYLE
- if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE) || !CustomData_has_layer(&em->bm->pdata, CD_FREESTYLE_FACE))
- col4[3] = 0;
-
- draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
-#else
- draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
-#endif
-
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE); /* restore write in zbuffer */
- }
- else if (efa_act) {
- /* even if draw faces is off it would be nice to draw the stipple face
- * Make all other faces zero alpha except for the active */
- unsigned char col1[4], col2[4], col3[4];
-#ifdef WITH_FREESTYLE
- unsigned char col4[4];
- col4[3] = 0; /* don't draw */
-#endif
- col1[3] = col2[3] = 0; /* don't draw */
-
- UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
-
- glEnable(GL_BLEND);
- glDepthMask(GL_FALSE); /* disable write in zbuffer, needed for nice transp */
-
-#ifdef WITH_FREESTYLE
- draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
-#else
- draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
-#endif
-
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE); /* restore write in zbuffer */
- }
-
- /* here starts all fancy draw-extra over */
- if ((me->drawflag & ME_DRAWEDGES) == 0 && check_object_draw_texture(scene, v3d, dt)) {
- /* we are drawing textures and 'ME_DRAWEDGES' is disabled, don't draw any edges */
-
- /* only draw selected edges otherwise there is no way of telling if a face is selected */
- draw_em_fancy_edges(em, scene, v3d, me, cageDM, 1, eed_act);
-
- }
- else {
- if (me->drawflag & ME_DRAWSEAMS) {
- UI_ThemeColor(TH_EDGE_SEAM);
- glLineWidth(2.0f);
-
- draw_dm_edges_seams(em, cageDM);
-
- glColor3ub(0, 0, 0);
- }
-
- if (me->drawflag & ME_DRAWSHARP) {
- UI_ThemeColor(TH_EDGE_SHARP);
- glLineWidth(2.0f);
-
- draw_dm_edges_sharp(em, cageDM);
-
- glColor3ub(0, 0, 0);
- }
-
-#ifdef WITH_FREESTYLE
- if (me->drawflag & ME_DRAW_FREESTYLE_EDGE && CustomData_has_layer(&em->bm->edata, CD_FREESTYLE_EDGE)) {
- UI_ThemeColor(TH_FREESTYLE_EDGE_MARK);
- glLineWidth(2.0f);
-
- draw_dm_edges_freestyle(em, cageDM);
-
- glColor3ub(0, 0, 0);
- }
-#endif
-
- if (me->drawflag & ME_DRAWCREASES) {
- draw_dm_creases(em, cageDM);
- }
- if (me->drawflag & ME_DRAWBWEIGHTS) {
- draw_dm_bweights(em, scene, cageDM);
- }
-
- glLineWidth(1.0f);
- draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act);
- }
-
- {
- draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d);
-
- if (me->drawflag & ME_DRAWNORMALS) {
- draw_dm_face_normals(em, scene, ob, cageDM, TH_NORMAL);
- }
- if (me->drawflag & ME_DRAW_VNORMALS) {
- draw_dm_vert_normals(em, scene, ob, cageDM, TH_VNORMAL);
- }
- if (me->drawflag & ME_DRAW_LNORMALS) {
- draw_dm_loop_normals(em, scene, ob, cageDM, TH_LNORMAL);
- }
-
- if ((me->drawflag & (ME_DRAWEXTRA_EDGELEN |
- ME_DRAWEXTRA_FACEAREA |
- ME_DRAWEXTRA_FACEANG |
- ME_DRAWEXTRA_EDGEANG)) &&
- !(v3d->flag2 & V3D_RENDER_OVERRIDE))
- {
- draw_em_measure_stats(ar, v3d, ob, em, &scene->unit);
- }
-
- if ((G.debug & G_DEBUG) && (me->drawflag & ME_DRAWEXTRA_INDICES) &&
- !(v3d->flag2 & V3D_RENDER_OVERRIDE))
- {
- draw_em_indices(em);
- }
- }
- }
-
- if (use_depth_offset) {
- glDepthMask(GL_TRUE);
- ED_view3d_polygon_offset(rv3d, 0.0);
- GPU_object_material_unbind();
- }
-#if 0 /* currently not needed */
- else if (use_occlude_wire) {
- ED_view3d_polygon_offset(rv3d, 0.0);
- }
-#endif
-}
-
-static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D *UNUSED(v3d),
- Object *UNUSED(ob), Mesh *me, BMEditMesh *UNUSED(em), DerivedMesh *UNUSED(cageDM), DerivedMesh *UNUSED(finalDM), const char UNUSED(dt))
-{
- /* for now... something simple! */
- Gwn_Batch *surface = DRW_mesh_batch_cache_get_all_triangles(me);
-
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
-
- glEnable(GL_BLEND);
-
- /* disable depth writes for transparent surface, so it doesn't interfere with itself */
- glDepthMask(GL_FALSE);
-
- GWN_batch_program_set_builtin(surface, GPU_SHADER_3D_UNIFORM_COLOR);
- GWN_batch_uniform_4f(surface, "color", 1.0f, 0.5f, 0.0f, 0.5f);
- GWN_batch_draw(surface);
-
-#if 0 /* until I understand finalDM better */
- if (finalDM != cageDM) {
- puts("finalDM != cageDM");
- Gwn_Batch *finalSurface = MBC_get_all_triangles(finalDM);
- GWN_batch_program_set_builtin(finalSurface, GPU_SHADER_3D_UNIFORM_COLOR);
- GWN_batch_uniform_4f(finalSurface, "color", 0.0f, 0.0f, 0.0f, 0.05f);
- GWN_batch_draw(finalSurface);
- }
-#endif
-
- glDepthMask(GL_TRUE);
-
- /* now write surface depth so other objects won't poke through
- * NOTE: does not help as much as desired
- * TODO: draw edit object last to avoid this mess
- */
- GWN_batch_program_set_builtin(surface, GPU_SHADER_3D_DEPTH_ONLY);
- GWN_batch_draw(surface);
-
- if (GLEW_VERSION_3_2) {
-#if 0
- Gwn_Batch *overlay = DRW_mesh_batch_cache_get_overlay_edges(me);
- GWN_batch_program_set_builtin(overlay, GPU_SHADER_EDGES_OVERLAY);
- GWN_batch_uniform_2f(overlay, "viewportSize", ar->winx, ar->winy);
- GWN_batch_draw(overlay);
-#endif
-
-#if 0 /* TODO: use this SIMPLE variant for pure triangle meshes */
- GWN_batch_program_set_builtin(surface, GPU_SHADER_EDGES_OVERLAY_SIMPLE);
- /* use these defaults:
- * const float edgeColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
- * GWN_batch_uniform_4f(surface, "fillColor", edgeColor[0], edgeColor[1], edgeColor[2], 0.0f);
- * GWN_batch_uniform_4fv(surface, "outlineColor", edgeColor);
- * GWN_batch_uniform_1f(surface, "outlineWidth", 1.0f);
- */
- GWN_batch_uniform_2f(surface, "viewportSize", ar->winx, ar->winy);
- GWN_batch_draw(surface);
-#endif
- }
- else {
- Gwn_Batch *edges = DRW_mesh_batch_cache_get_all_edges(me);
- GWN_batch_program_set_builtin(edges, GPU_SHADER_3D_UNIFORM_COLOR);
- GWN_batch_uniform_4f(edges, "color", 0.0f, 0.0f, 0.0f, 1.0f);
- glEnable(GL_LINE_SMOOTH);
- glLineWidth(1.5f);
- GWN_batch_draw(edges);
- glDisable(GL_LINE_SMOOTH);
- }
-
-#if 0 /* looks good even without points */
- Gwn_Batch *verts = MBC_get_all_verts(me);
- glEnable(GL_BLEND);
-
- GWN_batch_program_set_builtin(verts, GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
- GWN_batch_uniform_4f(verts, "color", 0.0f, 0.0f, 0.0f, 1.0f);
- GWN_batch_uniform_1f(verts, "size", UI_GetThemeValuef(TH_VERTEX_SIZE) * 1.5f);
- GWN_batch_draw(verts);
-
- glDisable(GL_BLEND);
-#endif
-}
-
-/* Mesh drawing routines */
-
-void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */
-{
- if ((v3d->transp == false) && /* not when we draw the transparent pass */
- (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
- {
- glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
- glDepthMask(GL_FALSE);
-
- if (ob_wire_col) glColor4ubv(ob_wire_col);
-
- /* if transparent, we cannot draw the edges for solid select... edges
- * have no material info. GPU_object_material_visible will skip the
- * transparent faces */
- if (ob->dtx & OB_DRAWTRANSP) {
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_visible);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- }
- else {
- dm->drawEdges(dm, 0, 1);
- }
-
- glDepthMask(GL_TRUE);
- }
-}
-
-static void draw_mesh_object_outline_new(View3D *v3d, RegionView3D *rv3d, Object *ob, Mesh *me, const bool is_active)
-{
- if ((v3d->transp == false) && /* not when we draw the transparent pass */
- (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
- {
- glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
- glDepthMask(GL_FALSE);
-
- float outline_color[4];
- UI_GetThemeColor4fv((is_active ? TH_ACTIVE : TH_SELECT), outline_color);
-
-#if 1 /* new version that draws only silhouette edges */
- Gwn_Batch *fancy_edges = DRW_mesh_batch_cache_get_fancy_edges(me);
-
- if (rv3d->persp == RV3D_ORTHO) {
- GWN_batch_program_set_builtin(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_ORTHO);
- /* set eye vector, transformed to object coords */
- float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */
- mul_m3_v3(gpuGetNormalMatrixInverse(NULL), eye);
- GWN_batch_uniform_3fv(fancy_edges, "eye", eye);
- }
- else {
- GWN_batch_program_set_builtin(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_PERSP);
- }
-
- GWN_batch_uniform_1b(fancy_edges, "drawFront", false);
- GWN_batch_uniform_1b(fancy_edges, "drawBack", false);
- GWN_batch_uniform_1b(fancy_edges, "drawSilhouette", true);
- GWN_batch_uniform_4fv(fancy_edges, "silhouetteColor", outline_color);
-
- GWN_batch_draw(fancy_edges);
-#else /* alternate version that matches look of old viewport (but more efficient) */
- Gwn_Batch *batch = MBC_get_all_edges(dm);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
- GWN_batch_uniform_4fv(batch, "color", outline_color);
- GWN_batch_draw(batch);
-#endif
-
- glDepthMask(GL_TRUE);
- }
-}
-
-static bool object_is_halo(Scene *scene, Object *ob)
-{
- const Material *ma = give_current_material(ob, 1);
- return (ma && (ma->material_type == MA_TYPE_HALO) && !BKE_scene_use_new_shading_nodes(scene));
-}
-
-static void draw_mesh_fancy(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const unsigned char ob_wire_col[4], const short dflag)
-{
-#ifdef WITH_GAMEENGINE
- Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object;
-#else
- Object *ob = base->object;
-#endif
- Mesh *me = ob->data;
- eWireDrawMode draw_wire = OBDRAW_WIRE_OFF;
- bool /* no_verts,*/ no_edges, no_faces;
- DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
- const bool is_obact = (ob == OBACT(view_layer));
- int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
-
- if (!dm)
- return;
-
- DM_update_materials(dm, ob);
-
- /* Check to draw dynamic paint colors (or weights from WeightVG modifiers).
- * Note: Last "preview-active" modifier in stack will win! */
- if (DM_get_loop_data_layer(dm, CD_PREVIEW_MLOOPCOL) && modifiers_isPreview(ob))
- draw_flags |= DRAW_MODIFIERS_PREVIEW;
-
- /* Unwanted combination */
- if (draw_flags & DRAW_FACE_SELECT) {
- draw_wire = OBDRAW_WIRE_OFF;
- }
- else if (ob->dtx & OB_DRAWWIRE) {
- draw_wire = OBDRAW_WIRE_ON_DEPTH; /* draw wire after solid using zoffset and depth buffer adjusment */
- }
-
- /* check polys instead of tessfaces because of dyntopo where tessfaces don't exist */
- if (dm->type == DM_TYPE_CCGDM) {
- no_edges = !subsurf_has_edges(dm);
- no_faces = !subsurf_has_faces(dm);
- }
- else {
- no_edges = (dm->getNumEdges(dm) == 0);
- no_faces = (dm->getNumPolys(dm) == 0);
- }
-
- /* vertexpaint, faceselect wants this, but it doesnt work for shaded? */
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
-
- if (dt == OB_BOUNDBOX) {
- if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE) == 0)
- draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
- }
- else if ((no_faces && no_edges) ||
- ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
- {
- glPointSize(1.5f);
- dm->drawVerts(dm);
- }
- else if ((dt == OB_WIRE) || no_faces) {
- draw_wire = OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff */
- }
- else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
- check_object_draw_texture(scene, v3d, dt))
- {
- bool draw_loose = true;
-
- if ((v3d->flag & V3D_SELECT_OUTLINE) &&
- ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
- (base->flag & BASE_SELECTED) &&
- !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
- (draw_wire == OBDRAW_WIRE_OFF))
- {
- draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
- }
-
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
- Paint *p;
-
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
-
- if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
- GPUVertexAttribs gattribs;
- float planes[4][4];
- float (*fpl)[4] = NULL;
- const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
-
- if (ob->sculpt->partial_redraw) {
- if (ar->do_draw & RGN_DRAW_PARTIAL) {
- ED_sculpt_redraw_planes_get(planes, ar, ob);
- fpl = planes;
- ob->sculpt->partial_redraw = 0;
- }
- }
-
- GPU_object_material_bind(1, &gattribs);
- dm->drawFacesSolid(dm, fpl, fast, NULL);
- draw_loose = false;
- }
- else
- dm->drawFacesGLSL(dm, GPU_object_material_bind);
-
-#if 0 /* XXX */
- if (BKE_bproperty_object_get(ob, "Text"))
- draw_mesh_text(ob, 1);
-#endif
- GPU_object_material_unbind();
-
- glFrontFace(GL_CCW);
-
- if (draw_flags & DRAW_FACE_SELECT)
- draw_mesh_face_select(rv3d, me, dm, false);
- }
- else {
- draw_mesh_textured(scene, view_layer, v3d, rv3d, ob, dm, draw_flags);
- }
-
- if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) {
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
- }
- glLineWidth(1.0f);
- dm->drawLooseEdges(dm);
- }
- }
- }
- else if (dt == OB_SOLID) {
- if (draw_flags & DRAW_MODIFIERS_PREVIEW) {
- /* for object selection draws no shade */
- if (dflag & (DRAW_PICKING | DRAW_CONSTCOLOR)) {
- dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
- GPU_object_material_unbind();
- }
- else {
- const float specular[3] = {0.47f, 0.47f, 0.47f};
-
- /* draw outline */
- if ((v3d->flag & V3D_SELECT_OUTLINE) &&
- ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
- (base->flag & BASE_SELECTED) &&
- (draw_wire == OBDRAW_WIRE_OFF) &&
- (ob->sculpt == NULL))
- {
- draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
- }
-
- /* materials arent compatible with vertex colors */
- GPU_end_object_materials();
-
- /* set default specular */
- GPU_basic_shader_colors(NULL, specular, 35, 1.0f);
- GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
-
- dm->drawMappedFaces(dm, NULL, NULL, NULL, NULL, DM_DRAW_USE_COLORS | DM_DRAW_NEED_NORMALS);
-
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- }
- }
- else {
- Paint *p;
-
- if ((v3d->flag & V3D_SELECT_OUTLINE) &&
- ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
- (base->flag & BASE_SELECTED) &&
- (draw_wire == OBDRAW_WIRE_OFF) &&
- (ob->sculpt == NULL))
- {
- draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
- }
-
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
-
- if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
- float planes[4][4];
- float (*fpl)[4] = NULL;
- const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
-
- if (ob->sculpt->partial_redraw) {
- if (ar->do_draw & RGN_DRAW_PARTIAL) {
- ED_sculpt_redraw_planes_get(planes, ar, ob);
- fpl = planes;
- ob->sculpt->partial_redraw = 0;
- }
- }
-
- dm->drawFacesSolid(dm, fpl, fast, GPU_object_material_bind);
- }
- else
- dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
-
- glFrontFace(GL_CCW);
-
- GPU_object_material_unbind();
-
- if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
- }
- glLineWidth(1.0f);
- dm->drawLooseEdges(dm);
- }
- }
- }
- else if (dt == OB_PAINT) {
- draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags);
-
- /* since we already draw wire as wp guide, don't draw over the top */
- draw_wire = OBDRAW_WIRE_OFF;
- }
-
- if ((draw_wire != OBDRAW_WIRE_OFF) && /* draw extra wire */
- /* when overriding with render only, don't bother */
- (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0))
- {
- /* When using wireframe object draw in particle edit mode
- * the mesh gets in the way of seeing the particles, fade the wire color
- * with the background. */
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
- float color[3];
- ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f, color);
- glColor3fv(color);
- }
- else {
- glColor3ubv(ob_wire_col);
- }
- }
-
- /* If drawing wire and drawtype is not OB_WIRE then we are
- * overlaying the wires.
- *
- * UPDATE bug #10290 - With this wire-only objects can draw
- * behind other objects depending on their order in the scene. 2x if 0's below. undo'ing zr's commit: r4059
- *
- * if draw wire is 1 then just drawing wire, no need for depth buffer stuff,
- * otherwise this wire is to overlay solid mode faces so do some depth buffer tricks.
- */
- if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) {
- ED_view3d_polygon_offset(rv3d, 1.0);
- glDepthMask(GL_FALSE); /* disable write in zbuffer, selected edge wires show better */
- }
-
- glLineWidth(1.0f);
- dm->drawEdges(dm, ((dt == OB_WIRE) || no_faces), (ob->dtx & OB_DRAW_ALL_EDGES) != 0);
-
- if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) {
- glDepthMask(GL_TRUE);
- ED_view3d_polygon_offset(rv3d, 0.0);
- }
- }
-
- if (is_obact && BKE_paint_select_vert_test(ob)) {
- const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0;
- glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
-
- if (!use_depth) glDisable(GL_DEPTH_TEST);
- else ED_view3d_polygon_offset(rv3d, 1.0);
- drawSelectedVertices(dm, ob->data);
- if (!use_depth) glEnable(GL_DEPTH_TEST);
- else ED_view3d_polygon_offset(rv3d, 0.0);
- }
- dm->release(dm);
-}
-
-/* returns true if nothing was drawn, for detecting to draw an object center */
-static bool draw_mesh_object(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const unsigned char ob_wire_col[4], const short dflag)
-{
- Object *ob = base->object;
- Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
- Mesh *me = ob->data;
- BMEditMesh *em = me->edit_btmesh;
- bool do_alpha_after = false, drawlinked = false, retval = false;
-
- /* If we are drawing shadows and any of the materials don't cast a shadow,
- * then don't draw the object */
- if (v3d->flag2 & V3D_RENDER_SHADOW) {
- for (int i = 0; i < ob->totcol; ++i) {
- Material *ma = give_current_material(ob, i);
- if (ma && !(ma->mode2 & MA_CASTSHADOW)) {
- return true;
- }
- }
- }
-
- if (obedit && ob != obedit && ob->data == obedit->data) {
- if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {}
- else if (ob->modifiers.first || obedit->modifiers.first) {}
- else drawlinked = true;
- }
-
- /* backface culling */
- if (v3d->flag2 & V3D_BACKFACE_CULLING) {
- glEnable(GL_CULL_FACE);
- glCullFace(GL_BACK);
- }
-
- if (ob == obedit || drawlinked) {
- DerivedMesh *finalDM, *cageDM;
-
- if (obedit != ob) {
- finalDM = cageDM = editbmesh_get_derived_base(
- ob, em, scene->customdata_mask);
- }
- else {
- cageDM = editbmesh_get_derived_cage_and_final(
- eval_ctx, scene, ob, em, scene->customdata_mask,
- &finalDM);
- }
-
- const bool use_material = ((me->drawflag & ME_DRAWEIGHT) == 0);
-
- DM_update_materials(finalDM, ob);
- if (cageDM != finalDM) {
- DM_update_materials(cageDM, ob);
- }
-
- if (use_material) {
- if (dt > OB_WIRE) {
- const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
-
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
- }
- }
-
- draw_em_fancy(scene, view_layer, ar, v3d, ob, em, cageDM, finalDM, dt);
-
- if (use_material) {
- GPU_end_object_materials();
- }
-
- if (obedit != ob)
- finalDM->release(finalDM);
- }
- else {
- /* ob->bb was set by derived mesh system, do NULL check just to be sure */
- if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) {
- if (dt > OB_WIRE) {
- const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
-
- if (dt == OB_SOLID || glsl) {
- const bool check_alpha = check_alpha_pass(base);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl,
- (check_alpha) ? &do_alpha_after : NULL);
- }
- }
-
- draw_mesh_fancy(eval_ctx, scene, view_layer, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
-
- GPU_end_object_materials();
-
- if (me->totvert == 0) retval = true;
- }
- }
-
- if ((dflag & DRAW_PICKING) == 0 && (base->flag_legacy & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
- /* GPU_begin_object_materials checked if this is needed */
- if (do_alpha_after) {
- if (ob->dtx & OB_DRAWXRAY) {
- ED_view3d_after_add(&v3d->afterdraw_xraytransp, base, dflag);
- }
- else {
- ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
- }
- }
- else if (ob->dtx & OB_DRAWXRAY && ob->dtx & OB_DRAWTRANSP) {
- /* special case xray+transp when alpha is 1.0, without this the object vanishes */
- if (v3d->xray == 0 && v3d->transp == 0) {
- ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
- }
- }
- }
-
- if (v3d->flag2 & V3D_BACKFACE_CULLING)
- glDisable(GL_CULL_FACE);
-
- return retval;
-}
-
-static void make_color_variations(const unsigned char base_ubyte[4], float low[4], float med[4], float high[4], const bool other_obedit)
-{
- /* original idea: nice variations (lighter & darker shades) of base color
- * current implementation uses input color as high; med & low get closer to background color
- */
-
- float bg[3];
- UI_GetThemeColor3fv(TH_BACK, bg);
-
- float base[4];
- rgba_uchar_to_float(base, base_ubyte);
-
- if (other_obedit) {
- /* this object should fade away so user can focus on the object being edited */
- interp_v3_v3v3(low, bg, base, 0.1f);
- interp_v3_v3v3(med, bg, base, 0.2f);
- interp_v3_v3v3(high, bg, base, 0.25f);
- }
- else {
- interp_v3_v3v3(low, bg, base, 0.333f);
- interp_v3_v3v3(med, bg, base, 0.667f);
- copy_v3_v3(high, base);
- }
-
- /* use original alpha */
- low[3] = base[3];
- med[3] = base[3];
- high[3] = base[3];
-}
-
-static void draw_mesh_fancy_new(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
- ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const unsigned char ob_wire_col[4], const short dflag, const bool other_obedit)
-{
- if (dflag & (DRAW_PICKING | DRAW_CONSTCOLOR)) {
- /* too complicated! use existing methods */
- /* TODO: move this into a separate depth pre-pass */
- draw_mesh_fancy(eval_ctx, scene, view_layer, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
- return;
- }
-
-#ifdef WITH_GAMEENGINE
- Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object;
-#else
- Object *ob = base->object;
-#endif
- Mesh *me = ob->data;
- eWireDrawMode draw_wire = OBDRAW_WIRE_OFF; /* could be bool draw_wire_overlay */
- bool no_edges, no_faces;
- DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
- const bool is_obact = (ob == OBACT(view_layer));
- int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
-
- if (!dm)
- return;
-
- const bool solid = dt >= OB_SOLID;
- if (solid) {
- DM_update_materials(dm, ob);
- }
-
- /* Check to draw dynamic paint colors (or weights from WeightVG modifiers).
- * Note: Last "preview-active" modifier in stack will win! */
- if (DM_get_loop_data_layer(dm, CD_PREVIEW_MLOOPCOL) && modifiers_isPreview(ob))
- draw_flags |= DRAW_MODIFIERS_PREVIEW;
-
- /* Unwanted combination */
- if (draw_flags & DRAW_FACE_SELECT) {
- draw_wire = OBDRAW_WIRE_OFF;
- }
- else if (ob->dtx & OB_DRAWWIRE) {
- draw_wire = OBDRAW_WIRE_ON;
- }
-
- /* check polys instead of tessfaces because of dyntopo where tessfaces don't exist */
- if (dm->type == DM_TYPE_CCGDM) {
- no_edges = !subsurf_has_edges(dm);
- no_faces = !subsurf_has_faces(dm);
- }
- else {
- no_edges = (dm->getNumEdges(dm) == 0);
- no_faces = (dm->getNumPolys(dm) == 0);
- }
-
- if (solid) {
- /* vertexpaint, faceselect wants this, but it doesnt work for shaded? */
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- }
-
- if (dt == OB_BOUNDBOX) {
- if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE) == 0)
- draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
- }
- else if ((no_faces && no_edges) ||
- ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
- {
- glPointSize(1.5f);
- // dm->drawVerts(dm);
- // TODO: draw smooth round points as a batch
- }
- else if ((dt == OB_WIRE) || no_faces) {
- draw_wire = OBDRAW_WIRE_ON;
-
- /* enable depth for wireframes */
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
-
- glLineWidth(1.0f);
-
-#if 1 /* fancy wireframes */
-
- Gwn_Batch *fancy_edges = DRW_mesh_batch_cache_get_fancy_edges(me);
-
- if (rv3d->persp == RV3D_ORTHO) {
- GWN_batch_program_set_builtin(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_ORTHO);
- /* set eye vector, transformed to object coords */
- float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */
- mul_m3_v3(gpuGetNormalMatrixInverse(NULL), eye);
- GWN_batch_uniform_3fv(fancy_edges, "eye", eye);
- }
- else {
- GWN_batch_program_set_builtin(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_PERSP);
- }
-
- float frontColor[4];
- float backColor[4];
- float outlineColor[4];
- make_color_variations(ob_wire_col, backColor, frontColor, outlineColor, other_obedit);
-
- GWN_batch_uniform_4fv(fancy_edges, "frontColor", frontColor);
- GWN_batch_uniform_4fv(fancy_edges, "backColor", backColor);
- GWN_batch_uniform_1b(fancy_edges, "drawFront", true);
- GWN_batch_uniform_1b(fancy_edges, "drawBack", true); /* false here = backface cull */
- GWN_batch_uniform_1b(fancy_edges, "drawSilhouette", false);
-
- GWN_batch_draw(fancy_edges);
-
- /* extra oomph for the silhouette contours */
- glLineWidth(2.0f);
- GWN_batch_program_use_begin(fancy_edges); /* hack to make the following uniforms stick */
- GWN_batch_uniform_1b(fancy_edges, "drawFront", false);
- GWN_batch_uniform_1b(fancy_edges, "drawBack", false);
- GWN_batch_uniform_1b(fancy_edges, "drawSilhouette", true);
- GWN_batch_uniform_4fv(fancy_edges, "silhouetteColor", outlineColor);
-
- GWN_batch_draw(fancy_edges);
-
-#else /* simple wireframes */
-
- Gwn_Batch *batch = MBC_get_all_edges(dm);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
-
- float color[4];
- rgba_uchar_to_float(color, ob_wire_col);
-
- GWN_batch_uniform_4fv(batch, "color", color);
-
- GWN_batch_draw(batch);
-#endif
- }
- else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
- check_object_draw_texture(scene, v3d, dt))
- {
- bool draw_loose = true;
-
- if ((v3d->flag & V3D_SELECT_OUTLINE) &&
- ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
- (base->flag & BASE_SELECTED) &&
- !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
- (draw_wire == OBDRAW_WIRE_OFF))
- {
- draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer)));
- }
-
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
- Paint *p;
-
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
-
- if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
- GPUVertexAttribs gattribs;
- float planes[4][4];
- float (*fpl)[4] = NULL;
- const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
-
- if (ob->sculpt->partial_redraw) {
- if (ar->do_draw & RGN_DRAW_PARTIAL) {
- ED_sculpt_redraw_planes_get(planes, ar, ob);
- fpl = planes;
- ob->sculpt->partial_redraw = 0;
- }
- }
-
- GPU_object_material_bind(1, &gattribs);
- dm->drawFacesSolid(dm, fpl, fast, NULL);
- draw_loose = false;
- }
- else
- dm->drawFacesGLSL(dm, GPU_object_material_bind);
-
- GPU_object_material_unbind();
-
- glFrontFace(GL_CCW);
-
- if (draw_flags & DRAW_FACE_SELECT)
- draw_mesh_face_select(rv3d, me, dm, false);
- }
- else {
- draw_mesh_textured(scene, view_layer, v3d, rv3d, ob, dm, draw_flags);
- }
-
- if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) {
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
- }
- glLineWidth(1.0f);
- dm->drawLooseEdges(dm);
- }
- }
- }
- else if (dt == OB_SOLID) {
- if (draw_flags & DRAW_MODIFIERS_PREVIEW) {
- /* for object selection draws no shade */
- if (dflag & (DRAW_PICKING | DRAW_CONSTCOLOR)) {
- /* TODO: draw basic faces with GPU_SHADER_3D_DEPTH_ONLY */
- }
- else {
- const float specular[3] = {0.47f, 0.47f, 0.47f};
-
- /* draw outline */
- /* TODO: move this into a separate pass */
- if ((v3d->flag & V3D_SELECT_OUTLINE) &&
- ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
- (base->flag & BASE_SELECTED) &&
- (draw_wire == OBDRAW_WIRE_OFF) &&
- (ob->sculpt == NULL))
- {
- draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer)));
- }
-
- /* materials arent compatible with vertex colors */
- GPU_end_object_materials();
-
- /* set default specular */
- GPU_basic_shader_colors(NULL, specular, 35, 1.0f);
- GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
-
- dm->drawMappedFaces(dm, NULL, NULL, NULL, NULL, DM_DRAW_USE_COLORS | DM_DRAW_NEED_NORMALS);
-
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- }
- }
- else {
- Paint *p;
-
- if ((v3d->flag & V3D_SELECT_OUTLINE) &&
- ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
- (base->flag & BASE_SELECTED) &&
- (draw_wire == OBDRAW_WIRE_OFF) &&
- (ob->sculpt == NULL))
- {
- /* TODO: move this into a separate pass */
- draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer)));
- }
-
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
-
- if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) {
- float planes[4][4];
- float (*fpl)[4] = NULL;
- const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
-
- if (ob->sculpt->partial_redraw) {
- if (ar->do_draw & RGN_DRAW_PARTIAL) {
- ED_sculpt_redraw_planes_get(planes, ar, ob);
- fpl = planes;
- ob->sculpt->partial_redraw = 0;
- }
- }
-
- dm->drawFacesSolid(dm, fpl, fast, GPU_object_material_bind);
- }
- else
- dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
-
- glFrontFace(GL_CCW);
-
- GPU_object_material_unbind();
-
- if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
- }
- glLineWidth(1.0f);
- dm->drawLooseEdges(dm);
- }
- }
- }
- else if (dt == OB_PAINT) {
- draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags);
-
- /* since we already draw wire as wp guide, don't draw over the top */
- draw_wire = OBDRAW_WIRE_OFF;
- }
-
- if ((draw_wire != OBDRAW_WIRE_OFF) && /* draw extra wire */
- /* when overriding with render only, don't bother */
- (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0)) // <-- is this "== 0" in the right spot???
- {
- /* When using wireframe object draw in particle edit mode
- * the mesh gets in the way of seeing the particles, fade the wire color
- * with the background. */
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- /* TODO:
- * Batch_UniformColor4ubv(ob_wire_col);
- */
- }
-
- /* If drawing wire and drawtype is not OB_WIRE then we are
- * overlaying the wires.
- *
- * No need for polygon offset because new technique is AWESOME.
- */
-#if 0
- glLineWidth(1.0f);
- dm->drawEdges(dm, ((dt == OB_WIRE) || no_faces), (ob->dtx & OB_DRAW_ALL_EDGES) != 0);
-#else
- /* something */
-#endif
- }
-
-#if 0 // (merwin) what is this for?
- if (is_obact && BKE_paint_select_vert_test(ob)) {
- const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0;
- glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
-
- if (!use_depth) glDisable(GL_DEPTH_TEST);
- else ED_view3d_polygon_offset(rv3d, 1.0);
- drawSelectedVertices(dm, ob->data);
- if (!use_depth) glEnable(GL_DEPTH_TEST);
- else ED_view3d_polygon_offset(rv3d, 0.0);
- }
-#endif
-
- dm->release(dm);
-}
-
-static bool UNUSED_FUNCTION(draw_mesh_object_new)(
- const EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const unsigned char ob_wire_col[4], const short dflag)
-{
- Object *ob = base->object;
- Mesh *me = ob->data;
- BMEditMesh *em = me->edit_btmesh;
- bool do_alpha_after = false, drawlinked = false, retval = false;
-
- if (v3d->flag2 & V3D_RENDER_SHADOW) {
- /* TODO: handle shadow pass separately */
- return true;
- }
- Object *obedit = OBEDIT_FROM_VIEW_LAYER(eval_ctx->view_layer);
-
- if (obedit && ob != obedit && ob->data == obedit->data) {
- if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {}
- else if (ob->modifiers.first || obedit->modifiers.first) {}
- else drawlinked = true;
- }
-
- /* backface culling */
- const bool solid = dt > OB_WIRE;
- const bool cullBackface = solid && (v3d->flag2 & V3D_BACKFACE_CULLING);
- if (cullBackface) {
- glEnable(GL_CULL_FACE);
- glCullFace(GL_BACK);
- }
-
- if (ob == obedit || drawlinked) {
- DerivedMesh *finalDM, *cageDM;
-
- if (obedit != ob) {
- /* linked to the edit object */
- finalDM = cageDM = editbmesh_get_derived_base(
- ob, em, scene->customdata_mask);
- }
- else {
- cageDM = editbmesh_get_derived_cage_and_final(
- eval_ctx, scene, ob, em, scene->customdata_mask,
- &finalDM);
- }
-
- const bool use_material = solid && ((me->drawflag & ME_DRAWEIGHT) == 0);
-
-#if 0 // why update if not being used?
- DM_update_materials(finalDM, ob);
- if (cageDM != finalDM) {
- DM_update_materials(cageDM, ob);
- }
-#endif // moved to below
-
- if (use_material) {
- DM_update_materials(finalDM, ob);
- if (cageDM != finalDM) {
- DM_update_materials(cageDM, ob);
- }
-
- const bool glsl = draw_glsl_material(scene, eval_ctx->view_layer, ob, v3d, dt);
-
- GPU_begin_object_materials(v3d, rv3d, scene, eval_ctx->view_layer, ob, glsl, NULL);
- }
-
- draw_em_fancy_new(scene, ar, v3d, ob, me, em, cageDM, finalDM, dt);
-
- if (use_material) {
- GPU_end_object_materials();
- }
-
- if (obedit != ob)
- finalDM->release(finalDM);
- }
- else {
- /* ob->bb was set by derived mesh system, do NULL check just to be sure */
- if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) {
- if (solid) {
- const bool glsl = draw_glsl_material(scene, eval_ctx->view_layer, ob, v3d, dt);
-
- if (dt == OB_SOLID || glsl) {
- const bool check_alpha = check_alpha_pass(base);
- GPU_begin_object_materials(v3d, rv3d, scene, eval_ctx->view_layer, ob, glsl,
- (check_alpha) ? &do_alpha_after : NULL);
- }
- }
-
- const bool other_obedit = obedit && (obedit != ob);
-
- draw_mesh_fancy_new(eval_ctx, scene, eval_ctx->view_layer, ar, v3d, rv3d, base, dt, ob_wire_col, dflag, other_obedit);
-
- GPU_end_object_materials();
-
- if (me->totvert == 0) retval = true;
- }
- }
-
- if (cullBackface)
- glDisable(GL_CULL_FACE);
-
- return retval;
-}
-
-/* ************** DRAW DISPLIST ****************** */
-
-static void drawDispListVerts(Gwn_PrimType prim_type, const void *data, unsigned int vert_ct, const unsigned char wire_col[3])
-{
- Gwn_VertFormat format = {0};
- unsigned int pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vert_ct);
-
- GWN_vertbuf_attr_fill(vbo, pos_id, data);
-
- Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
- if (wire_col) {
- GWN_batch_uniform_4f(batch, "color", wire_col[0] / 255.0f, wire_col[1] / 255.0f, wire_col[2] / 255.0f, 1.0f);
- }
- GWN_batch_draw(batch);
- GWN_batch_discard(batch);
-}
-
-/* convert dispList with elem indices to batch, only support triangles and quads
- * XXX : This is a huge perf issue. We should cache the resulting batches inside the object instead.
- * But new viewport will do it anyway
- * TODO implement flat drawing */
-static void drawDispListElem(
- bool quads, bool UNUSED(smooth), bool ndata_is_single,
- const float *data, const float *ndata, unsigned int data_len,
- const int *elem, unsigned int elem_len, const unsigned char wire_col[3])
-{
- Gwn_VertFormat format = {0};
- int i;
- const int *idx = elem;
- unsigned int pos_id, nor_id;
-
- pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- if (ndata) {
- if (ndata_is_single) {
- /* pass */
- }
- else {
- nor_id = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- }
- }
-
- Gwn_IndexBufBuilder elb;
- GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, (quads) ? elem_len * 2 : elem_len, 0xffffffff);
-
- if (quads) {
- for (i = elem_len; i; --i, idx += 4) {
- GWN_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
- GWN_indexbuf_add_tri_verts(&elb, idx[0], idx[2], idx[3]);
- }
- }
- else {
- for (i = elem_len; i; --i, idx += 3) {
- GWN_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
- }
- }
-
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, data_len);
-
- GWN_vertbuf_attr_fill(vbo, pos_id, data);
-
- if (ndata) {
- if (ndata_is_single) {
- /* TODO: something like glNormal for a single value */
- }
- else {
- GWN_vertbuf_attr_fill(vbo, nor_id, ndata);
- }
- }
-
- Gwn_Batch *batch = GWN_batch_create_ex(
- GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb), GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING);
- if (wire_col) {
- GWN_batch_uniform_4f(batch, "color", wire_col[0] / 255.0f, wire_col[1] / 255.0f, wire_col[2] / 255.0f, 1.0f);
- }
- GWN_batch_uniform_4f(batch, "color", 0.8f, 0.8f, 0.8f, 1.0f);
- GWN_batch_uniform_3f(batch, "light", 0.0f, 0.0f, 1.0f);
- GWN_batch_draw(batch);
- GWN_batch_discard(batch);
-}
-
-/**
- * \param dl_type_mask Only draw types matching this mask.
- * \return true when nothing was drawn
- */
-static bool drawDispListwire_ex(ListBase *dlbase, unsigned int dl_type_mask, const unsigned char wire_col[3])
-{
- if (dlbase == NULL) return true;
-
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-
- for (DispList *dl = dlbase->first; dl; dl = dl->next) {
- if (dl->parts == 0 || dl->nr == 0) {
- continue;
- }
-
- if ((dl_type_mask & (1 << dl->type)) == 0) {
- continue;
- }
-
- const float *data = dl->verts;
- int parts;
-
- switch (dl->type) {
- case DL_SEGM:
- for (parts = 0; parts < dl->parts; parts++)
- drawDispListVerts(GWN_PRIM_LINE_STRIP, data + (parts * dl->nr * 3), dl->nr, wire_col);
- break;
-
- case DL_POLY:
- for (parts = 0; parts < dl->parts; parts++)
- drawDispListVerts(GWN_PRIM_LINE_LOOP, data + (parts * dl->nr * 3), dl->nr, wire_col);
- break;
-
- case DL_SURF:
- for (parts = 0; parts < dl->parts; parts++) {
- if (dl->flag & DL_CYCL_U)
- drawDispListVerts(GWN_PRIM_LINE_LOOP, data + (parts * dl->nr * 3), dl->nr, wire_col);
- else
- drawDispListVerts(GWN_PRIM_LINE_STRIP, data + (parts * dl->nr * 3), dl->nr, wire_col);
- }
-
- float *data_aligned = MEM_mallocN(sizeof(float) * 3 * dl->parts, "aligned data");
- for (int nr = 0; nr < dl->nr; nr++) {
- int ofs = 3 * dl->nr;
- int idx = 0;
-
- data = (dl->verts) + 3 * nr;
- parts = dl->parts;
-
- while (parts--) {
- copy_v3_v3(data_aligned + idx, data);
- data += ofs;
- idx += 3;
- }
-
- if (dl->flag & DL_CYCL_V)
- drawDispListVerts(GWN_PRIM_LINE_LOOP, data_aligned, dl->parts, wire_col);
- else
- drawDispListVerts(GWN_PRIM_LINE_STRIP, data_aligned, dl->parts, wire_col);
- }
-
- if (data_aligned)
- MEM_freeN(data_aligned);
-
- break;
-
- case DL_INDEX3:
- drawDispListElem(
- false, true, false,
- dl->verts, NULL, dl->nr,
- dl->index, dl->parts, wire_col);
- break;
-
- case DL_INDEX4:
- drawDispListElem(
- true, true, false,
- dl->verts, NULL, dl->nr,
- dl->index, dl->parts, wire_col);
- break;
- }
- }
-
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-
- return false;
-}
-
-static bool drawDispListwire(ListBase *dlbase, const short ob_type, const unsigned char wire_col[3])
-{
- unsigned int dl_mask = 0xffffffff;
-
- /* skip fill-faces for curves & fonts */
- if (ELEM(ob_type, OB_FONT, OB_CURVE)) {
- dl_mask &= ~((1 << DL_INDEX3) | (1 << DL_INDEX4));
- }
-
- return drawDispListwire_ex(dlbase, dl_mask, wire_col);
-}
-
-static bool index3_nors_incr = true;
-
-static void drawDispListsolid(ListBase *lb, Object *ob, const short UNUSED(dflag),
- const unsigned char ob_wire_col[4], const bool use_glsl)
-{
- GPUVertexAttribs gattribs;
-
- if (lb == NULL) return;
-
- /* track current material, -1 for none (needed for lines) */
- short col = -1;
-
- DispList *dl = lb->first;
- while (dl) {
- const float *data = dl->verts;
- //const float *ndata = dl->nors;
-
- switch (dl->type) {
- case DL_SEGM:
- if (ob->type == OB_SURF) {
- if (col != -1) {
- GPU_object_material_unbind();
- col = -1;
- }
-
- drawDispListVerts(GWN_PRIM_LINE_STRIP, data, dl->nr, ob_wire_col);
- }
- break;
- case DL_POLY:
- if (ob->type == OB_SURF) {
- if (col != -1) {
- GPU_object_material_unbind();
- col = -1;
- }
-
- drawDispListVerts(GWN_PRIM_LINE_LOOP, data, dl->nr, ob_wire_col);
- }
- break;
- case DL_SURF:
-
- if (dl->index) {
- if (col != dl->col) {
- GPU_object_material_bind(dl->col + 1, use_glsl ? &gattribs : NULL);
- col = dl->col;
- }
- const unsigned int verts_len = dl->nr * dl->parts;
-
- drawDispListElem(
- true, (dl->rt & CU_SMOOTH) != 0, false,
- dl->verts, dl->nors, verts_len,
- dl->index, dl->totindex, ob_wire_col);
- }
- break;
-
- case DL_INDEX3:
- if (col != dl->col) {
- GPU_object_material_bind(dl->col + 1, use_glsl ? &gattribs : NULL);
- col = dl->col;
- }
-
-#if 0
- /* for polys only one normal needed */
- if (index3_nors_incr) {
- glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(GL_FLOAT, 0, dl->nors);
- }
- else
- glNormal3fv(ndata);
-#endif
- /* special case, 'nors' is a single value */
- drawDispListElem(
- false, (dl->rt & CU_SMOOTH) != 0, true,
- dl->verts, dl->nors, dl->nr,
- dl->index, dl->parts, ob_wire_col);
-
-#if 0
- if (index3_nors_incr)
- glDisableClientState(GL_NORMAL_ARRAY);
-#endif
-
- break;
-
- case DL_INDEX4:
- if (col != dl->col) {
- GPU_object_material_bind(dl->col + 1, use_glsl ? &gattribs : NULL);
- col = dl->col;
- }
-
- drawDispListElem(
- true, true, false,
- dl->verts, dl->nors, dl->nr,
- dl->index, dl->parts, ob_wire_col);
-
- break;
- }
- dl = dl->next;
- }
-
- glFrontFace(GL_CCW);
-
- if (col != -1) {
- GPU_object_material_unbind();
- }
-}
-
-static void drawCurveDMWired(Object *ob)
-{
- DerivedMesh *dm = ob->derivedFinal;
- dm->drawEdges(dm, 1, 0);
-}
-
-/* return true when nothing was drawn */
-static bool drawCurveDerivedMesh(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt)
-{
- Object *ob = base->object;
- DerivedMesh *dm = ob->derivedFinal;
-
- if (!dm) {
- return true;
- }
-
- DM_update_materials(dm, ob);
-
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
-
- if (dt > OB_WIRE && dm->getNumPolys(dm)) {
- bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
-
- if (!glsl)
- dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
- else
- dm->drawFacesGLSL(dm, GPU_object_material_bind);
-
- GPU_end_object_materials();
- }
- else {
- if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0)
- drawCurveDMWired(ob);
- }
-
- return false;
-}
-
-/**
- * Only called by #drawDispList
- * \return true when nothing was drawn
- */
-static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4])
-{
- Object *ob = base->object;
- ListBase *lb = NULL;
- DispList *dl;
- Curve *cu;
- const bool render_only = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
- const bool solid = (dt > OB_WIRE);
-
- switch (ob->type) {
- case OB_FONT:
- case OB_CURVE:
- cu = ob->data;
-
- lb = &ob->curve_cache->disp;
-
- if (solid) {
- const bool has_faces = BKE_displist_has_faces(lb);
- dl = lb->first;
- if (dl == NULL) {
- return true;
- }
-
- if (dl->nors == NULL) BKE_displist_normals_add(lb);
- index3_nors_incr = false;
-
- if (!render_only) {
- /* when we have faces, only draw loose-wire */
- if (has_faces) {
- drawDispListwire_ex(lb, (1 << DL_SEGM), ob_wire_col);
- }
- else {
- drawDispListwire(lb, ob->type, ob_wire_col);
- }
- }
-
- if (has_faces == false) {
- /* pass */
- }
- else {
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL);
- drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
- GPU_end_object_materials();
- }
- else {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL);
- drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
- GPU_end_object_materials();
- }
- if (cu->editnurb && cu->bevobj == NULL && cu->taperobj == NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) {
- unsigned char col[4] = {0, 0, 0, 0};
- drawDispListwire(lb, ob->type, col);
- }
- }
- index3_nors_incr = true;
- }
- else {
- if (!render_only || BKE_displist_has_faces(lb)) {
- return drawDispListwire(lb, ob->type, ob_wire_col);
- }
- }
- break;
- case OB_SURF:
-
- lb = &ob->curve_cache->disp;
-
- if (solid) {
- dl = lb->first;
- if (dl == NULL) {
- return true;
- }
-
- if (dl->nors == NULL) BKE_displist_normals_add(lb);
-
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL);
- drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
- GPU_end_object_materials();
- }
- else {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL);
- drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
- GPU_end_object_materials();
- }
- }
- else {
- return drawDispListwire(lb, ob->type, ob_wire_col);
- }
- break;
- case OB_MBALL:
-
- if (BKE_mball_is_basis(ob)) {
- lb = &ob->curve_cache->disp;
- if (BLI_listbase_is_empty(lb)) {
- return true;
- }
-
- if (solid) {
-
- if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL);
- drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
- GPU_end_object_materials();
- }
- else {
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL);
- drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
- GPU_end_object_materials();
- }
- }
- else {
- return drawDispListwire(lb, ob->type, ob_wire_col);
- }
- }
- break;
- }
-
- return false;
-}
-static bool drawDispList(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4])
-{
- bool retval;
-
- /* backface culling */
- if (v3d->flag2 & V3D_BACKFACE_CULLING) {
- /* not all displists use same in/out normal direction convention */
- glEnable(GL_CULL_FACE);
- glCullFace(GL_BACK);
- }
-
-#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(eval_ctx, scene, base->object);
-#endif
-
- if (drawCurveDerivedMesh(scene, view_layer, v3d, rv3d, base, dt) == false) {
- retval = false;
- }
- else {
- Object *ob = base->object;
- GLenum mode;
-
- if (ob->type == OB_MBALL) {
- mode = (ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW;
- }
- else {
- mode = (ob->transflag & OB_NEG_SCALE) ? GL_CCW : GL_CW;
- }
-
- glFrontFace(mode);
-
- retval = drawDispList_nobackface(scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
-
- if (mode != GL_CCW) {
- glFrontFace(GL_CCW);
- }
- }
-
- if (v3d->flag2 & V3D_BACKFACE_CULLING) {
- glDisable(GL_CULL_FACE);
- }
-
- return retval;
-}
-
-/* *********** drawing for particles ************* */
-/* stride : offset size in bytes
- * col[4] : the color to use when *color is NULL, can be also NULL */
-static void draw_vertex_array(Gwn_PrimType prim_type, const float *vert, const float *nor, const float *color, int stride, int vert_ct, float col[4])
-{
- Gwn_VertFormat format = {0};
- unsigned int pos_id, nor_id, col_id;
- pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- if (nor) nor_id = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- if (color) col_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, vert_ct);
-
- if (stride == 0) {
- GWN_vertbuf_attr_fill(vbo, pos_id, vert);
- if (nor) GWN_vertbuf_attr_fill(vbo, nor_id, nor);
- if (color) GWN_vertbuf_attr_fill(vbo, col_id, color);
- }
- else {
- GWN_vertbuf_attr_fill_stride(vbo, pos_id, stride, vert);
- if (nor) GWN_vertbuf_attr_fill_stride(vbo, nor_id, stride, nor);
- if (color) GWN_vertbuf_attr_fill_stride(vbo, col_id, stride, color);
- }
-
- Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO);
- if (nor && color) {
- GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR);
- GWN_batch_uniform_3f(batch, "light", 0.0f, 0.0f, 1.0f);
- }
- else if (nor) {
- GWN_batch_program_set_builtin(batch, GPU_SHADER_SIMPLE_LIGHTING);
- GWN_batch_uniform_3f(batch, "light", 0.0f, 0.0f, 1.0f);
- if (col) GWN_batch_uniform_4fv(batch, "color", col);
- }
- else if (color) {
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR);
- }
- else {
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
- if (col) GWN_batch_uniform_4fv(batch, "color", col);
- }
- GWN_batch_draw(batch);
- GWN_batch_discard(batch);
-}
-
-static void draw_particle_arrays_new(int draw_as, int ob_dt, int select,
- const float *vert, const float *nor, const float *color,
- int totpoint, float col[4])
-{
- /* draw created data arrays */
- switch (draw_as) {
- case PART_DRAW_AXIS:
- case PART_DRAW_CROSS:
- draw_vertex_array(GWN_PRIM_LINES, vert, nor, color, 0, 6 * totpoint, col);
- break;
- case PART_DRAW_LINE:
- draw_vertex_array(GWN_PRIM_LINES, vert, nor, color, 0, 2 * totpoint, col);
- break;
- case PART_DRAW_BB:
- if (ob_dt <= OB_WIRE || select)
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- else
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-
- draw_vertex_array(GWN_PRIM_TRIS, vert, nor, color, 0, 6 * totpoint, col);
- break;
- default:
- draw_vertex_array(GWN_PRIM_POINTS, vert, nor, color, 0, totpoint, col);
- break;
- }
-}
-static void draw_particle(ParticleKey *state, int draw_as, short draw, float pixsize,
- float imat[4][4], const float draw_line[2], ParticleBillboardData *bb, ParticleDrawData *pdd,
- unsigned int pos)
-{
- float vec[3], vec2[3];
- float *vd = NULL;
- float *cd = NULL;
- float ma_col[3] = {0.0f, 0.0f, 0.0f};
-
- /* null only for PART_DRAW_CIRC */
- if (pdd) {
- vd = pdd->vd;
- cd = pdd->cd;
-
- if (pdd->ma_col) {
- copy_v3_v3(ma_col, pdd->ma_col);
- }
- }
-
- switch (draw_as) {
- case PART_DRAW_DOT:
- {
- if (vd) {
- copy_v3_v3(vd, state->co); pdd->vd += 3;
- }
- if (cd) {
- copy_v3_v3(cd, pdd->ma_col);
- pdd->cd += 3;
- }
- break;
- }
- case PART_DRAW_CROSS:
- case PART_DRAW_AXIS:
- {
- vec[0] = 2.0f * pixsize;
- vec[1] = vec[2] = 0.0;
- mul_qt_v3(state->rot, vec);
- if (draw_as == PART_DRAW_AXIS) {
- if (cd) {
- cd[1] = cd[2] = cd[4] = cd[5] = 0.0;
- cd[0] = cd[3] = 1.0;
- cd[6] = cd[8] = cd[9] = cd[11] = 0.0;
- cd[7] = cd[10] = 1.0;
- cd[13] = cd[12] = cd[15] = cd[16] = 0.0;
- cd[14] = cd[17] = 1.0;
- pdd->cd += 18;
- }
-
- copy_v3_v3(vec2, state->co);
- }
- else {
- if (cd) {
- cd[0] = cd[3] = cd[6] = cd[9] = cd[12] = cd[15] = ma_col[0];
- cd[1] = cd[4] = cd[7] = cd[10] = cd[13] = cd[16] = ma_col[1];
- cd[2] = cd[5] = cd[8] = cd[11] = cd[14] = cd[17] = ma_col[2];
- pdd->cd += 18;
- }
- sub_v3_v3v3(vec2, state->co, vec);
- }
-
- add_v3_v3(vec, state->co);
- copy_v3_v3(pdd->vd, vec); pdd->vd += 3;
- copy_v3_v3(pdd->vd, vec2); pdd->vd += 3;
-
- vec[1] = 2.0f * pixsize;
- vec[0] = vec[2] = 0.0;
- mul_qt_v3(state->rot, vec);
- if (draw_as == PART_DRAW_AXIS) {
- copy_v3_v3(vec2, state->co);
- }
- else {
- sub_v3_v3v3(vec2, state->co, vec);
- }
-
- add_v3_v3(vec, state->co);
- copy_v3_v3(pdd->vd, vec); pdd->vd += 3;
- copy_v3_v3(pdd->vd, vec2); pdd->vd += 3;
-
- vec[2] = 2.0f * pixsize;
- vec[0] = vec[1] = 0.0f;
- mul_qt_v3(state->rot, vec);
- if (draw_as == PART_DRAW_AXIS) {
- copy_v3_v3(vec2, state->co);
- }
- else {
- sub_v3_v3v3(vec2, state->co, vec);
- }
-
- add_v3_v3(vec, state->co);
-
- copy_v3_v3(pdd->vd, vec); pdd->vd += 3;
- copy_v3_v3(pdd->vd, vec2); pdd->vd += 3;
- break;
- }
- case PART_DRAW_LINE:
- {
- copy_v3_v3(vec, state->vel);
- normalize_v3(vec);
- if (draw & PART_DRAW_VEL_LENGTH)
- mul_v3_fl(vec, len_v3(state->vel));
- madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd += 3;
- madd_v3_v3v3fl(pdd->vd, state->co, vec, draw_line[1]); pdd->vd += 3;
- if (cd) {
- cd[0] = cd[3] = ma_col[0];
- cd[1] = cd[4] = ma_col[1];
- cd[2] = cd[5] = ma_col[2];
- pdd->cd += 6;
- }
- break;
- }
- case PART_DRAW_CIRC:
- {
- imm_drawcircball(state->co, pixsize, imat, pos);
- break;
- }
- case PART_DRAW_BB:
- {
- float xvec[3], yvec[3], zvec[3], bb_center[3];
-
- copy_v3_v3(bb->vec, state->co);
- copy_v3_v3(bb->vel, state->vel);
-
- psys_make_billboard(bb, xvec, yvec, zvec, bb_center);
-
- /* First tri */
- add_v3_v3v3(pdd->vd, bb_center, xvec);
- add_v3_v3(pdd->vd, yvec); pdd->vd += 3;
-
- sub_v3_v3v3(pdd->vd, bb_center, xvec);
- add_v3_v3(pdd->vd, yvec); pdd->vd += 3;
-
- sub_v3_v3v3(pdd->vd, bb_center, xvec);
- sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd += 3;
-
- /* Second tri */
- add_v3_v3v3(pdd->vd, bb_center, xvec);
- add_v3_v3(pdd->vd, yvec); pdd->vd += 3;
-
- sub_v3_v3v3(pdd->vd, bb_center, xvec);
- sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd += 3;
-
- add_v3_v3v3(pdd->vd, bb_center, xvec);
- sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd += 3;
-
- if (cd) {
- for (int i = 0; i < 6; i++, cd += 3, pdd->cd += 3) {
- copy_v3_v3(cd, ma_col);
- }
- }
- for (int i = 0; i < 6; i++, pdd->nd += 3) {
- copy_v3_v3(pdd->nd, zvec);
- }
- break;
- }
- }
-}
-static void draw_particle_data(ParticleSystem *psys, RegionView3D *rv3d,
- ParticleKey *state, int draw_as,
- float imat[4][4], ParticleBillboardData *bb, ParticleDrawData *pdd,
- const float ct, const float pa_size, const float r_tilt, const float pixsize_scale,
- unsigned int pos)
-{
- ParticleSettings *part = psys->part;
- float pixsize;
-
- if (psys->parent)
- mul_m4_v3(psys->parent->obmat, state->co);
-
- /* create actual particle data */
- if (draw_as == PART_DRAW_BB) {
- bb->offset[0] = part->bb_offset[0];
- bb->offset[1] = part->bb_offset[1];
- bb->size[0] = part->bb_size[0] * pa_size;
- if (part->bb_align == PART_BB_VEL) {
- float pa_vel = len_v3(state->vel);
- float head = part->bb_vel_head * pa_vel;
- float tail = part->bb_vel_tail * pa_vel;
- bb->size[1] = part->bb_size[1] * pa_size + head + tail;
- /* use offset to adjust the particle center. this is relative to size, so need to divide! */
- if (bb->size[1] > 0.0f)
- bb->offset[1] += (head - tail) / bb->size[1];
- }
- else {
- bb->size[1] = part->bb_size[1] * pa_size;
- }
- bb->tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
- bb->time = ct;
- }
-
- pixsize = ED_view3d_pixel_size(rv3d, state->co) * pixsize_scale;
-
- draw_particle(state, draw_as, part->draw, pixsize, imat, part->draw_line, bb, pdd, pos);
-}
-/* unified drawing of all new particle systems draw types except dupli ob & group
- * mostly tries to use vertex arrays for speed
- *
- * 1. check that everything is ok & updated
- * 2. start initializing things
- * 3. initialize according to draw type
- * 4. allocate drawing data arrays
- * 5. start filling the arrays
- * 6. draw the arrays
- * 7. clean up
- */
-static void draw_new_particle_system(
- const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d,
- Base *base, ParticleSystem *psys,
- const char ob_dt, const short dflag)
-{
- Object *ob = base->object;
- ParticleEditSettings *pset = PE_settings(scene);
- ParticleSettings *part = psys->part;
- ParticleData *pars = psys->particles;
- ParticleData *pa;
- ParticleKey state, *states = NULL;
- ParticleBillboardData bb;
- ParticleSimulationData sim = {NULL};
- ParticleDrawData *pdd = psys->pdd;
- Material *ma;
- float vel[3], imat[4][4];
- float timestep, pixsize_scale = 1.0f, pa_size, r_tilt, r_length;
- float pa_time, pa_birthtime, pa_dietime, pa_health, intensity;
- float cfra;
- float ma_col[3] = {0.0f, 0.0f, 0.0f};
- int a, totpart, totpoint = 0, totve = 0, drawn, draw_as, totchild = 0;
- bool select = (base->flag & BASE_SELECTED) != 0, create_cdata = false, need_v = false;
- GLint polygonmode[2];
- char numstr[32];
- unsigned char tcol[4] = {0, 0, 0, 255};
- unsigned int pos;
-
-/* 1. */
- if (part == NULL || !psys_check_enabled(ob, psys, G.is_rendering))
- return;
-
- if (pars == NULL) return;
-
- /* don't draw normal paths in edit mode */
- if (psys_in_edit_mode(eval_ctx->depsgraph, psys) && (pset->flag & PE_DRAW_PART) == 0)
- return;
-
- if (part->draw_as == PART_DRAW_REND)
- draw_as = part->ren_as;
- else
- draw_as = part->draw_as;
-
- if (draw_as == PART_DRAW_NOT)
- return;
-
- /* prepare curvemapping tables */
- if ((psys->part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && psys->part->clumpcurve)
- curvemapping_changed_all(psys->part->clumpcurve);
- if ((psys->part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && psys->part->roughcurve)
- curvemapping_changed_all(psys->part->roughcurve);
- if ((psys->part->child_flag & PART_CHILD_USE_TWIST_CURVE) && psys->part->twistcurve)
- curvemapping_changed_all(psys->part->twistcurve);
-
-/* 2. */
- sim.eval_ctx = eval_ctx;
- sim.scene = scene;
- sim.ob = ob;
- sim.psys = psys;
- sim.psmd = psys_get_modifier(ob, psys);
-
- if (part->phystype == PART_PHYS_KEYED) {
- if (psys->flag & PSYS_KEYED) {
- psys_count_keyed_targets(&sim);
- if (psys->totkeyed == 0)
- return;
- }
- }
-
- if (select) {
- select = false;
- if (psys_get_current(ob) == psys)
- select = true;
- }
-
- psys->flag |= PSYS_DRAWING;
-
- if (part->type == PART_HAIR && !psys->childcache)
- totchild = 0;
- else
- totchild = psys->totchild * part->disp / 100;
-
- ma = give_current_material(ob, part->omat);
-
- if (v3d->zbuf) glDepthMask(1);
-
- if ((ma) && (part->draw_col == PART_DRAW_COL_MAT)) {
- rgb_float_to_uchar(tcol, &(ma->r));
- copy_v3_v3(ma_col, &ma->r);
- }
-
- timestep = psys_get_timestep(&sim);
-
- if ((ob->flag & OB_FROMGROUP) != 0) {
- float mat[4][4];
- mul_m4_m4m4(mat, ob->obmat, psys->imat);
- gpuMultMatrix(mat);
- }
-
- /* needed for text display */
- invert_m4_m4(ob->imat, ob->obmat);
-
- totpart = psys->totpart;
-
- cfra = BKE_scene_frame_get(scene);
-
- if (draw_as == PART_DRAW_PATH && psys->pathcache == NULL && psys->childcache == NULL)
- draw_as = PART_DRAW_DOT;
-
-/* 3. */
- glLineWidth(1.0f);
-
- switch (draw_as) {
- case PART_DRAW_DOT:
- if (part->draw_size)
- glPointSize(part->draw_size);
- else
- glPointSize(2.0); /* default dot size */
- break;
- case PART_DRAW_CIRC:
- /* calculate view aligned matrix: */
- copy_m4_m4(imat, rv3d->viewinv);
- normalize_v3(imat[0]);
- normalize_v3(imat[1]);
- ATTR_FALLTHROUGH;
- case PART_DRAW_CROSS:
- case PART_DRAW_AXIS:
- /* lets calculate the scale: */
-
- if (part->draw_size == 0.0)
- pixsize_scale = 2.0f;
- else
- pixsize_scale = part->draw_size;
-
- if (draw_as == PART_DRAW_AXIS)
- create_cdata = 1;
- break;
- case PART_DRAW_OB:
- if (part->dup_ob == NULL)
- draw_as = PART_DRAW_DOT;
- else
- draw_as = 0;
- break;
- case PART_DRAW_GR:
- if (part->dup_group == NULL)
- draw_as = PART_DRAW_DOT;
- else
- draw_as = 0;
- break;
- case PART_DRAW_BB:
- if (v3d->camera == NULL && part->bb_ob == NULL) {
- printf("Billboards need an active camera or a target object!\n");
-
- draw_as = part->draw_as = PART_DRAW_DOT;
-
- if (part->draw_size)
- glPointSize(part->draw_size);
- else
- glPointSize(2.0); /* default dot size */
- }
- else if (part->bb_ob)
- bb.ob = part->bb_ob;
- else
- bb.ob = v3d->camera;
-
- bb.align = part->bb_align;
- bb.anim = part->bb_anim;
- bb.lock = part->draw & PART_DRAW_BB_LOCK;
- break;
- case PART_DRAW_PATH:
- break;
- case PART_DRAW_LINE:
- need_v = 1;
- break;
- }
- if (part->draw & PART_DRAW_SIZE && part->draw_as != PART_DRAW_CIRC) {
- copy_m4_m4(imat, rv3d->viewinv);
- normalize_v3(imat[0]);
- normalize_v3(imat[1]);
- }
-
- if (ELEM(draw_as, PART_DRAW_DOT, PART_DRAW_CROSS, PART_DRAW_LINE) &&
- (part->draw_col > PART_DRAW_COL_MAT))
- {
- create_cdata = 1;
- }
-
- if (!create_cdata && pdd && pdd->cdata) {
- MEM_freeN(pdd->cdata);
- pdd->cdata = pdd->cd = NULL;
- }
-
-/* 4. */
- if (draw_as && ELEM(draw_as, PART_DRAW_PATH, PART_DRAW_CIRC) == 0) {
- int partsize = 3 * sizeof(float);
- int create_ndata = 0;
-
- if (!pdd)
- pdd = psys->pdd = MEM_callocN(sizeof(ParticleDrawData), "ParticleDrawData");
-
- if (part->draw_as == PART_DRAW_REND && part->trail_count > 1) {
- partsize *= part->trail_count;
- psys_make_temp_pointcache(ob, psys);
- }
-
- switch (draw_as) {
- case PART_DRAW_AXIS:
- case PART_DRAW_CROSS:
- partsize *= 6;
- if (draw_as != PART_DRAW_CROSS)
- create_cdata = 1;
- break;
- case PART_DRAW_LINE:
- partsize *= 2;
- break;
- case PART_DRAW_BB:
- partsize *= 6; /* New OGL only understands tris, no choice here. */
- create_ndata = 1;
- break;
- }
-
- if (pdd->totpart != totpart + totchild || pdd->partsize != partsize)
- psys_free_pdd(psys);
-
- if (!pdd->vdata)
- pdd->vdata = MEM_calloc_arrayN(totpart + totchild, partsize, "particle_vdata");
- if (create_cdata && !pdd->cdata)
- pdd->cdata = MEM_calloc_arrayN(totpart + totchild, partsize, "particle_cdata");
- if (create_ndata && !pdd->ndata)
- pdd->ndata = MEM_calloc_arrayN(totpart + totchild, partsize, "particle_ndata");
-
- if (part->draw & PART_DRAW_VEL && draw_as != PART_DRAW_LINE) {
- if (!pdd->vedata)
- pdd->vedata = MEM_calloc_arrayN(totpart + totchild, 2 * 3 * sizeof(float), "particle_vedata");
-
- need_v = 1;
- }
- else if (pdd->vedata) {
- /* velocity data not needed, so free it */
- MEM_freeN(pdd->vedata);
- pdd->vedata = NULL;
- }
-
- pdd->vd = pdd->vdata;
- pdd->ved = pdd->vedata;
- pdd->cd = pdd->cdata;
- pdd->nd = pdd->ndata;
- pdd->totpart = totpart + totchild;
- pdd->partsize = partsize;
- }
- else if (psys->pdd) {
- psys_free_pdd(psys);
- MEM_freeN(psys->pdd);
- pdd = psys->pdd = NULL;
- }
-
- if (pdd) {
- pdd->ma_col = ma_col;
- }
-
- psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
-
- /* circles don't use drawdata, so have to add a special case here */
- if ((pdd || draw_as == PART_DRAW_CIRC) && draw_as != PART_DRAW_PATH) {
- /* 5. */
- if (pdd && (pdd->flag & PARTICLE_DRAW_DATA_UPDATED) &&
- (pdd->vedata || part->draw & (PART_DRAW_SIZE | PART_DRAW_NUM | PART_DRAW_HEALTH)) == 0)
- {
- totpoint = pdd->totpoint; /* draw data is up to date */
- }
- else {
- if ((draw_as == PART_DRAW_CIRC) || (part->draw & PART_DRAW_SIZE)) {
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- imm_cpack(0xFFFFFF);
- }
- for (a = 0, pa = pars; a < totpart + totchild; a++, pa++) {
- /* setup per particle individual stuff */
- if (a < totpart) {
- if (totchild && (part->draw & PART_DRAW_PARENT) == 0) continue;
- if (pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST) continue;
-
- pa_time = (cfra - pa->time) / pa->lifetime;
- pa_birthtime = pa->time;
- pa_dietime = pa->dietime;
- pa_size = pa->size;
- if (part->phystype == PART_PHYS_BOIDS)
- pa_health = pa->boid->data.health;
- else
- pa_health = -1.0;
-
- r_tilt = 2.0f * (psys_frand(psys, a + 21) - 0.5f);
- r_length = psys_frand(psys, a + 22);
-
- if (part->draw_col > PART_DRAW_COL_MAT) {
- switch (part->draw_col) {
- case PART_DRAW_COL_VEL:
- intensity = len_v3(pa->state.vel) / part->color_vec_max;
- break;
- case PART_DRAW_COL_ACC:
- intensity = len_v3v3(pa->state.vel, pa->prev_state.vel) / ((pa->state.time - pa->prev_state.time) * part->color_vec_max);
- break;
- default:
- intensity = 1.0f; /* should never happen */
- BLI_assert(0);
- break;
- }
- CLAMP(intensity, 0.0f, 1.0f);
- weight_to_rgb(ma_col, intensity);
- }
- }
- else {
- ChildParticle *cpa = &psys->child[a - totpart];
-
- pa_time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime);
- pa_size = psys_get_child_size(psys, cpa, cfra, NULL);
-
- pa_health = -1.0;
-
- r_tilt = 2.0f * (psys_frand(psys, a + 21) - 0.5f);
- r_length = psys_frand(psys, a + 22);
- }
-
- drawn = 0;
- if (part->draw_as == PART_DRAW_REND && part->trail_count > 1) {
- float length = part->path_end * (1.0f - part->randlength * r_length);
- int trail_count = part->trail_count * (1.0f - part->randlength * r_length);
- float ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length;
- float dt = length / (trail_count ? (float)trail_count : 1.0f);
- int i = 0;
-
- ct += dt;
- for (i = 0; i < trail_count; i++, ct += dt) {
-
- if (part->draw & PART_ABS_PATH_TIME) {
- if (ct < pa_birthtime || ct > pa_dietime)
- continue;
- }
- else if (ct < 0.0f || ct > 1.0f)
- continue;
-
- state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : -(pa_birthtime + ct * (pa_dietime - pa_birthtime));
- psys_get_particle_on_path(&sim, a, &state, need_v);
-
- draw_particle_data(psys, rv3d,
- &state, draw_as, imat, &bb, psys->pdd,
- ct, pa_size, r_tilt, pixsize_scale, pos);
-
- totpoint++;
- drawn = 1;
- }
- }
- else {
- state.time = cfra;
- if (psys_get_particle_state(&sim, a, &state, 0)) {
-
- draw_particle_data(psys, rv3d,
- &state, draw_as, imat, &bb, psys->pdd,
- pa_time, pa_size, r_tilt, pixsize_scale, pos);
-
- totpoint++;
- drawn = 1;
- }
- }
-
- if (drawn) {
- /* additional things to draw for each particle
- * (velocity, size and number) */
- if ((part->draw & PART_DRAW_VEL) && pdd && pdd->vedata) {
- copy_v3_v3(pdd->ved, state.co);
- pdd->ved += 3;
- mul_v3_v3fl(vel, state.vel, timestep);
- add_v3_v3v3(pdd->ved, state.co, vel);
- pdd->ved += 3;
-
- totve++;
- }
-
- if (part->draw & PART_DRAW_SIZE) {
- setlinestyle(3);
- imm_drawcircball(state.co, pa_size, imat, pos);
- setlinestyle(0);
- }
-
-
- if ((part->draw & PART_DRAW_NUM || part->draw & PART_DRAW_HEALTH) &&
- (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)
- {
- size_t numstr_len;
- float vec_txt[3];
- char *val_pos = numstr;
- numstr[0] = '\0';
-
- if (part->draw & PART_DRAW_NUM) {
- if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
- numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%d:%.2f", a, pa_health);
- }
- else {
- numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%d", a);
- }
- }
- else {
- if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
- numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%.2f", pa_health);
- }
- }
-
- if (numstr[0]) {
- /* in path drawing state.co is the end point
- * use worldspace because object matrix is already applied */
- mul_v3_m4v3(vec_txt, ob->imat, state.co);
- view3d_cached_text_draw_add(vec_txt, numstr, numstr_len,
- 10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
- }
- }
- }
- }
- if ((draw_as == PART_DRAW_CIRC) || (part->draw & PART_DRAW_SIZE)) {
- immUnbindProgram();
- }
- }
- }
-/* 6. */
-
- glGetIntegerv(GL_POLYGON_MODE, polygonmode);
-
- if (draw_as == PART_DRAW_PATH) {
- ParticleCacheKey **cache, *path;
- float *cdata2 = NULL;
-
- if (totchild && (part->draw & PART_DRAW_PARENT) == 0)
- totpart = 0;
- else if (psys->pathcache == NULL)
- totpart = 0;
-
- /* draw actual/parent particles */
- cache = psys->pathcache;
- for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
- path = cache[a];
- if (path->segments > 0) {
- if (((dflag & DRAW_CONSTCOLOR) == 0) && (part->draw_col == PART_DRAW_COL_MAT)) {
- draw_vertex_array(GWN_PRIM_LINE_STRIP, path->co, path->vel, path->col, sizeof(ParticleCacheKey), path->segments + 1, NULL);
- }
- else {
- float color[4];
- rgba_uchar_to_float(color, tcol);
- draw_vertex_array(GWN_PRIM_LINE_STRIP, path->co, path->vel, NULL, sizeof(ParticleCacheKey), path->segments + 1, color);
- }
- }
- }
-
- if (part->type == PART_HAIR) {
- if (part->draw & PART_DRAW_GUIDE_HAIRS) {
- DerivedMesh *hair_dm = psys->hair_out_dm;
-
- for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
- if (pa->totkey > 1) {
- HairKey *hkey = pa->hair;
-
- /* XXX use proper theme color here */
- float color[4] = {0.58f, 0.67f, 1.0f, 1.0f};
- draw_vertex_array(GWN_PRIM_LINE_STRIP, hkey->world_co, NULL, NULL, sizeof(HairKey), pa->totkey, color);
- }
- }
-
- if (hair_dm) {
- MVert *mvert = hair_dm->getVertArray(hair_dm);
- int i;
-
- unsigned int pos_id = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor3f(0.9f, 0.4f, 0.4f);
-
- unsigned int count = 0;
- for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
- count += MAX2(pa->totkey - 1, 0);
- }
-
- if (count > 0) {
- immBegin(GWN_PRIM_LINES, count * 2);
- for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
- for (i = 1; i < pa->totkey; ++i) {
- float v1[3], v2[3];
-
- copy_v3_v3(v1, mvert[pa->hair_index + i - 1].co);
- copy_v3_v3(v2, mvert[pa->hair_index + i].co);
-
- mul_m4_v3(ob->obmat, v1);
- mul_m4_v3(ob->obmat, v2);
-
- immVertex3fv(pos_id, v1);
- immVertex3fv(pos_id, v2);
- }
- }
- immEnd();
- }
-
- immUnbindProgram();
- }
- }
-
- if (part->draw & PART_DRAW_HAIR_GRID) {
- ClothModifierData *clmd = psys->clmd;
- if (clmd) {
- float *gmin = clmd->hair_grid_min;
- float *gmax = clmd->hair_grid_max;
- int *res = clmd->hair_grid_res;
- int i;
-
- unsigned int pos_id = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- if (select)
- immUniformThemeColor(TH_ACTIVE);
- else
- immUniformThemeColor(TH_WIRE);
-
- immBegin(GWN_PRIM_LINES, 24);
- immVertex3f(pos_id, gmin[0], gmin[1], gmin[2]); immVertex3f(pos_id, gmax[0], gmin[1], gmin[2]);
- immVertex3f(pos_id, gmax[0], gmin[1], gmin[2]); immVertex3f(pos_id, gmax[0], gmax[1], gmin[2]);
- immVertex3f(pos_id, gmax[0], gmax[1], gmin[2]); immVertex3f(pos_id, gmin[0], gmax[1], gmin[2]);
- immVertex3f(pos_id, gmin[0], gmax[1], gmin[2]); immVertex3f(pos_id, gmin[0], gmin[1], gmin[2]);
-
- immVertex3f(pos_id, gmin[0], gmin[1], gmax[2]); immVertex3f(pos_id, gmax[0], gmin[1], gmax[2]);
- immVertex3f(pos_id, gmax[0], gmin[1], gmax[2]); immVertex3f(pos_id, gmax[0], gmax[1], gmax[2]);
- immVertex3f(pos_id, gmax[0], gmax[1], gmax[2]); immVertex3f(pos_id, gmin[0], gmax[1], gmax[2]);
- immVertex3f(pos_id, gmin[0], gmax[1], gmax[2]); immVertex3f(pos_id, gmin[0], gmin[1], gmax[2]);
-
- immVertex3f(pos_id, gmin[0], gmin[1], gmin[2]); immVertex3f(pos_id, gmin[0], gmin[1], gmax[2]);
- immVertex3f(pos_id, gmax[0], gmin[1], gmin[2]); immVertex3f(pos_id, gmax[0], gmin[1], gmax[2]);
- immVertex3f(pos_id, gmin[0], gmax[1], gmin[2]); immVertex3f(pos_id, gmin[0], gmax[1], gmax[2]);
- immVertex3f(pos_id, gmax[0], gmax[1], gmin[2]); immVertex3f(pos_id, gmax[0], gmax[1], gmax[2]);
- immEnd();
-
- if (select)
- immUniformThemeColorShadeAlpha(TH_ACTIVE, 0, -100);
- else
- immUniformThemeColorShadeAlpha(TH_WIRE, 0, -100);
-
- int count = 0;
- count += MAX2(0, res[0] - 2) * 8;
- count += MAX2(0, res[1] - 2) * 8;
- count += MAX2(0, res[2] - 2) * 8;
-
- if (count >= 2) {
- glEnable(GL_BLEND);
- immBegin(GWN_PRIM_LINES, count);
- for (i = 1; i < res[0] - 1; ++i) {
- float f = interpf(gmax[0], gmin[0], (float)i / (float)(res[0] - 1));
- immVertex3f(pos_id, f, gmin[1], gmin[2]); immVertex3f(pos_id, f, gmax[1], gmin[2]);
- immVertex3f(pos_id, f, gmax[1], gmin[2]); immVertex3f(pos_id, f, gmax[1], gmax[2]);
- immVertex3f(pos_id, f, gmax[1], gmax[2]); immVertex3f(pos_id, f, gmin[1], gmax[2]);
- immVertex3f(pos_id, f, gmin[1], gmax[2]); immVertex3f(pos_id, f, gmin[1], gmin[2]);
- }
- for (i = 1; i < res[1] - 1; ++i) {
- float f = interpf(gmax[1], gmin[1], (float)i / (float)(res[1] - 1));
- immVertex3f(pos_id, gmin[0], f, gmin[2]); immVertex3f(pos_id, gmax[0], f, gmin[2]);
- immVertex3f(pos_id, gmax[0], f, gmin[2]); immVertex3f(pos_id, gmax[0], f, gmax[2]);
- immVertex3f(pos_id, gmax[0], f, gmax[2]); immVertex3f(pos_id, gmin[0], f, gmax[2]);
- immVertex3f(pos_id, gmin[0], f, gmax[2]); immVertex3f(pos_id, gmin[0], f, gmin[2]);
- }
- for (i = 1; i < res[2] - 1; ++i) {
- float f = interpf(gmax[2], gmin[2], (float)i / (float)(res[2] - 1));
- immVertex3f(pos_id, gmin[0], gmin[1], f); immVertex3f(pos_id, gmax[0], gmin[1], f);
- immVertex3f(pos_id, gmax[0], gmin[1], f); immVertex3f(pos_id, gmax[0], gmax[1], f);
- immVertex3f(pos_id, gmax[0], gmax[1], f); immVertex3f(pos_id, gmin[0], gmax[1], f);
- immVertex3f(pos_id, gmin[0], gmax[1], f); immVertex3f(pos_id, gmin[0], gmin[1], f);
- }
- immEnd();
- glDisable(GL_BLEND);
- }
-
- immUnbindProgram();
- }
- }
- }
-
- /* draw child particles */
- cache = psys->childcache;
- for (a = 0; a < totchild; a++) {
- path = cache[a];
-
- if (((dflag & DRAW_CONSTCOLOR) == 0) && (part->draw_col == PART_DRAW_COL_MAT)) {
- draw_vertex_array(GWN_PRIM_LINE_STRIP, path->co, path->vel, path->col, sizeof(ParticleCacheKey), path->segments + 1, NULL);
- }
- else {
- float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
- draw_vertex_array(GWN_PRIM_LINE_STRIP, path->co, path->vel, NULL, sizeof(ParticleCacheKey), path->segments + 1, color);
- }
- }
-
- /* restore & clean up */
- if (cdata2) {
- MEM_freeN(cdata2);
- cdata2 = NULL;
- }
-
- if ((part->draw & PART_DRAW_NUM) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- cache = psys->pathcache;
-
- for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
- float vec_txt[3];
- size_t numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%i", a);
- /* use worldspace because object matrix is already applied */
- mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co);
- view3d_cached_text_draw_add(vec_txt, numstr, numstr_len,
- 10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
- }
- }
- }
- else if (pdd && ELEM(draw_as, 0, PART_DRAW_CIRC) == 0) {
-
- if (pdd->vdata) {
- if (select) {
- float color[4];
- UI_GetThemeColor4fv(TH_ACTIVE, color);
-
- if (part->draw_size)
- glPointSize(part->draw_size + 2);
- else
- glPointSize(4.0);
-
- glLineWidth(3.0);
-
- draw_particle_arrays_new(draw_as, ob_dt, 1, pdd->vdata, NULL, NULL, totpoint, color);
- }
-
- glPointSize(part->draw_size ? part->draw_size : 2.0);
- glLineWidth(1.0);
-
-
-#if 0
- /* enable other data arrays */
- /* billboards are drawn this way */
- if (pdd->ndata && ob_dt > OB_WIRE) {
- GPU_basic_shader_colors(NULL, NULL, 0.0f, 1.0f);
- GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
- }
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if (pdd->cdata) {
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer(3, GL_FLOAT, 0, pdd->cdata);
- }
- }
-#endif
-
- draw_particle_arrays_new(draw_as, ob_dt, 0, pdd->vdata, pdd->ndata, pdd->cdata, totpoint, NULL);
- }
-
-
- pdd->flag |= PARTICLE_DRAW_DATA_UPDATED;
- pdd->totpoint = totpoint;
- }
-
- if (pdd && pdd->vedata) {
- float color[4] = {0.75f, 0.75f, 0.75f, 1.0f};
- draw_vertex_array(GWN_PRIM_LINES, pdd->vedata, NULL, NULL, 0, 2 * totve, color);
- }
-
- glPolygonMode(GL_FRONT, polygonmode[0]);
- glPolygonMode(GL_BACK, polygonmode[1]);
-
-/* 7. */
-
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
-
- if (states)
- MEM_freeN(states);
-
- psys->flag &= ~PSYS_DRAWING;
-
- /* draw data can't be saved for billboards as they must update to target changes */
- if (draw_as == PART_DRAW_BB) {
- psys_free_pdd(psys);
- pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED;
- }
-
- if (psys->lattice_deform_data) {
- end_latt_deform(psys->lattice_deform_data);
- psys->lattice_deform_data = NULL;
- }
-
- if (pdd) {
- /* drop references to stack memory */
- pdd->ma_col = NULL;
- }
-
- if ((ob->flag & OB_FROMGROUP) != 0) {
- gpuLoadMatrix(rv3d->viewmat);
- }
-}
-
-static void draw_update_ptcache_edit(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, PTCacheEdit *edit)
-{
- if (edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED)
- PE_update_object(eval_ctx, scene, ob, 0);
-
- /* create path and child path cache if it doesn't exist already */
- if (edit->pathcache == NULL) {
- psys_cache_edit_paths(eval_ctx, scene, ob, edit, CFRA, G.is_rendering);
- }
-}
-
-static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
-{
- ParticleEditSettings *pset = PE_settings(scene);
- const int totpoint = edit->totpoint;
- const bool timed = (pset->flag & PE_FADE_TIME) ? pset->fade_frames : false;
-
- if (edit->pathcache == NULL)
- return;
-
- PE_hide_keys_time(scene, edit, CFRA);
-
- /* opengl setup */
- if ((v3d->flag & V3D_ZBUF_SELECT) == 0)
- glDisable(GL_DEPTH_TEST);
-
- /* get selection theme colors */
- float sel_col[3], nosel_col[3];
- UI_GetThemeColor3fv(TH_VERTEX_SELECT, sel_col);
- UI_GetThemeColor3fv(TH_VERTEX, nosel_col);
-
- /* draw paths */
- const int totkeys = (*edit->pathcache)->segments + 1;
-
- glEnable(GL_BLEND);
- float *pathcol = MEM_calloc_arrayN(totkeys, 4 * sizeof(float), "particle path color data");
-
- if (pset->brushtype == PE_BRUSH_WEIGHT)
- glLineWidth(2.0f);
-
- ParticleCacheKey **cache = edit->pathcache;
- PTCacheEditPoint *point;
- int i;
-
- for (i = 0, point = edit->points; i < totpoint; i++, point++) {
- ParticleCacheKey *path = cache[i];
-
- Gwn_VertFormat format = {0};
- unsigned int pos_id, col_id, col_comp;
-
- col_comp = ((point->flag & PEP_HIDE) || timed) ? 4 : 3;
-
- pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- col_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, col_comp, GWN_FETCH_FLOAT);
-
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, path->segments + 1);
-
- GWN_vertbuf_attr_fill_stride(vbo, pos_id, sizeof(ParticleCacheKey), path->co);
-
- float *pcol = pathcol;
-
- if (point->flag & PEP_HIDE) {
- for (int k = 0; k < totkeys; k++, pcol += 4) {
- copy_v3_v3(pcol, path->col);
- pcol[3] = 0.25f;
- }
-
- GWN_vertbuf_attr_fill(vbo, col_id, pathcol);
- }
- else if (timed) {
- ParticleCacheKey *pkey = path;
- for (int k = 0; k < totkeys; k++, pkey++, pcol += 4) {
- copy_v3_v3(pcol, pkey->col);
- pcol[3] = 1.0f - fabsf((float)(CFRA) -pkey->time) / (float)pset->fade_frames;
- }
-
- GWN_vertbuf_attr_fill(vbo, col_id, pathcol);
- }
- else {
- /* FIXME: shader wants 4 color components but the cache only contains ParticleCacheKey
- * So alpha is random */
- GWN_vertbuf_attr_fill_stride(vbo, col_id, sizeof(ParticleCacheKey), path->col);
- }
-
- Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR);
- GWN_batch_draw(batch);
- GWN_batch_discard(batch);
- }
-
- if (pathcol) { MEM_freeN(pathcol); pathcol = NULL; }
-
- /* draw edit vertices */
- if (pset->selectmode != SCE_SELECT_PATH) {
- glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
-
- if (pset->selectmode == SCE_SELECT_POINT) {
- float *pd = NULL, *pdata = NULL;
- float *cd = NULL, *cdata = NULL;
- int totkeys_visible = 0;
-
- Gwn_VertFormat format = {0};
- unsigned int pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int col_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, (timed ? 4 : 3), GWN_FETCH_FLOAT);
-
- for (i = 0, point = edit->points; i < totpoint; i++, point++)
- if (!(point->flag & PEP_HIDE))
- totkeys_visible += point->totkey;
-
- if (totkeys_visible) {
- if (edit->points && !(edit->points->keys->flag & PEK_USE_WCO))
- pd = pdata = MEM_calloc_arrayN(totkeys_visible, 3 * sizeof(float), "particle edit point data");
- cd = cdata = MEM_calloc_arrayN(totkeys_visible, (timed ? 4 : 3) * sizeof(float), "particle edit color data");
- }
-
- for (i = 0, point = edit->points; i < totpoint; i++, point++) {
- if (point->flag & PEP_HIDE)
- continue;
-
- PTCacheEditKey *key = point->keys;
- for (int k = 0; k < point->totkey; k++, key++) {
- if (pd) {
- copy_v3_v3(pd, key->co);
- pd += 3;
- }
-
- if (key->flag & PEK_SELECT) {
- copy_v3_v3(cd, sel_col);
- }
- else {
- copy_v3_v3(cd, nosel_col);
- }
-
- if (timed)
- *(cd + 3) = 1.0f - fabsf((float)CFRA - *key->time) / (float)pset->fade_frames;
-
- cd += (timed ? 4 : 3);
- }
- }
- cd = cdata;
- pd = pdata;
- for (i = 0, point = edit->points; i < totpoint; i++, point++) {
- if (point->flag & PEP_HIDE || point->totkey == 0)
- continue;
-
- Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo, point->totkey);
-
- if (point->keys->flag & PEK_USE_WCO)
- GWN_vertbuf_attr_fill_stride(vbo, pos_id, sizeof(PTCacheEditKey), point->keys->world_co);
- else
- GWN_vertbuf_attr_fill(vbo, pos_id, pd);
-
- GWN_vertbuf_attr_fill(vbo, col_id, cd);
-
- Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO);
- GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR);
- GWN_batch_draw(batch);
- GWN_batch_discard(batch);
-
- pd += pd ? 3 * point->totkey : 0;
- cd += (timed ? 4 : 3) * point->totkey;
- }
- if (pdata) { MEM_freeN(pdata); pd = pdata = NULL; }
- if (cdata) { MEM_freeN(cdata); cd = cdata = NULL; }
- }
- else if (pset->selectmode == SCE_SELECT_END) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int col_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
- immBeginAtMost(GWN_PRIM_POINTS, totpoint);
- for (i = 0, point = edit->points; i < totpoint; i++, point++) {
- if ((point->flag & PEP_HIDE) == 0 && point->totkey) {
- PTCacheEditKey *key = point->keys + point->totkey - 1;
- if ((key->flag & PEK_SELECT) != 0) {
- immAttrib3fv(col_id, sel_col);
- }
- else {
- immAttrib3fv(col_id, nosel_col);
- }
- /* has to be like this.. otherwise selection won't work, have try glArrayElement later..*/
- immVertex3fv(pos_id, (key->flag & PEK_USE_WCO) ? key->world_co : key->co);
- }
- }
- immEnd();
- immUnbindProgram();
- }
- }
-
- glDisable(GL_BLEND);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-}
-
-static void ob_draw_RE_motion(float com[3], float rotscale[3][3], float itw, float ith, float drw_size)
-{
- float tr[3][3];
- float root[3], tip[3];
- /* take a copy for not spoiling original */
- copy_m3_m3(tr, rotscale);
- float tw = itw * drw_size;
- float th = ith * drw_size;
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- immBegin(GWN_PRIM_LINES, 30);
-
- immAttrib4ub(col, 0x7F, 0x00, 0x00, 155);
- root[1] = root[2] = 0.0f;
- root[0] = -drw_size;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- tip[1] = tip[2] = 0.0f;
- tip[0] = drw_size;
- mul_m3_v3(tr, tip);
- add_v3_v3(tip, com);
- immVertex3fv(pos, tip);
-
- root[1] = 0.0f; root[2] = tw;
- root[0] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- root[1] = 0.0f; root[2] = -tw;
- root[0] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- root[1] = tw; root[2] = 0.0f;
- root[0] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- root[1] = -tw; root[2] = 0.0f;
- root[0] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- immAttrib4ub(col, 0x00, 0x7F, 0x00, 155);
-
- root[0] = root[2] = 0.0f;
- root[1] = -drw_size;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- tip[0] = tip[2] = 0.0f;
- tip[1] = drw_size;
- mul_m3_v3(tr, tip);
- add_v3_v3(tip, com);
- immVertex3fv(pos, tip);
-
- root[0] = 0.0f; root[2] = tw;
- root[1] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- root[0] = 0.0f; root[2] = -tw;
- root[1] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- root[0] = tw; root[2] = 0.0f;
- root[1] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- root[0] = -tw; root[2] = 0.0f;
- root[1] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- immAttrib4ub(col, 0x00, 0x00, 0x7F, 155);
- root[0] = root[1] = 0.0f;
- root[2] = -drw_size;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- tip[0] = tip[1] = 0.0f;
- tip[2] = drw_size;
- mul_m3_v3(tr, tip);
- add_v3_v3(tip, com);
- immVertex3fv(pos, tip);
-
- root[0] = 0.0f; root[1] = tw;
- root[2] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- root[0] = 0.0f; root[1] = -tw;
- root[2] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- root[0] = tw; root[1] = 0.0f;
- root[2] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- root[0] = -tw; root[1] = 0.0f;
- root[2] = th;
- mul_m3_v3(tr, root);
- add_v3_v3(root, com);
- immVertex3fv(pos, root);
- immVertex3fv(pos, tip);
-
- immEnd();
-
- immUnbindProgram();
-}
-
-/* place to add drawers */
-
-static void drawhandlesN(Nurb *nu, const char sel, const bool hide_handles)
-{
- if (nu->hide || hide_handles) return;
-
- if (nu->type == CU_BEZIER && nu->pntsu > 0) {
-
- const float *fp;
-
-#define TH_HANDLE_COL_TOT ((TH_HANDLE_SEL_FREE - TH_HANDLE_FREE) + 1)
- /* use MIN2 when indexing to ensure newer files don't read outside the array */
- unsigned char handle_cols[TH_HANDLE_COL_TOT][3];
- const int basecol = sel ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
-
- for (int a = 0; a < TH_HANDLE_COL_TOT; a++) {
- UI_GetThemeColor3ubv(basecol + a, handle_cols[a]);
- }
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- glLineWidth(1.0f);
-
- immBeginAtMost(GWN_PRIM_LINES, nu->pntsu * 4);
-
- BezTriple *bezt = nu->bezt;
- int a = nu->pntsu;
- while (a--) {
- if (bezt->hide == 0) {
- if ((bezt->f2 & SELECT) == sel) {
- fp = bezt->vec[0];
-
- immAttrib3ubv(col, handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]);
- immVertex3fv(pos, fp);
- immVertex3fv(pos, fp + 3);
-
- immAttrib3ubv(col, handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]);
- immVertex3fv(pos, fp + 3);
- immVertex3fv(pos, fp + 6);
- }
- else if ((bezt->f1 & SELECT) == sel) {
- fp = bezt->vec[0];
-
- immAttrib3ubv(col, handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]);
- immVertex3fv(pos, fp);
- immVertex3fv(pos, fp + 3);
- }
- else if ((bezt->f3 & SELECT) == sel) {
- fp = bezt->vec[1];
-
- immAttrib3ubv(col, handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]);
- immVertex3fv(pos, fp);
- immVertex3fv(pos, fp + 3);
- }
- }
- bezt++;
- }
-
- immEnd();
-
- immUnbindProgram();
-
-#undef TH_HANDLE_COL_TOT
-
- }
-}
-
-static void drawhandlesN_active(Nurb *nu)
-{
- if (nu->hide) return;
-
- if (nu->type == CU_BEZIER && nu->pntsu > 0) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformThemeColor(TH_ACTIVE_SPLINE);
- glLineWidth(2.0f);
-
- immBeginAtMost(GWN_PRIM_LINES, nu->pntsu * 4);
- BezTriple *bezt = nu->bezt;
- int a = nu->pntsu;
- while (a--) {
- if (bezt->hide == 0) {
- const float *fp = bezt->vec[0];
-
- immVertex3fv(pos, fp);
- immVertex3fv(pos, fp + 3);
-
- immVertex3fv(pos, fp + 3);
- immVertex3fv(pos, fp + 6);
- }
- bezt++;
- }
- immEnd();
- immUnbindProgram();
- }
-}
-
-static void drawvertsN(const Nurb *nurb, const bool hide_handles, const void *vert)
-{
- const Nurb *nu;
-
- // just quick guesstimate of how many verts to draw
- int count = 0;
- for (nu = nurb; nu; nu = nu->next) {
- if (!nu->hide) {
- if (nu->type == CU_BEZIER) {
- count += nu->pntsu * 3;
- }
- else {
- count += nu->pntsu * nu->pntsv;
- }
- }
- }
- if (count == 0) return;
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- unsigned char vert_color[3];
- unsigned char vert_color_select[3];
- unsigned char vert_color_active[3];
- UI_GetThemeColor3ubv(TH_VERTEX, vert_color);
- UI_GetThemeColor3ubv(TH_VERTEX_SELECT, vert_color_select);
- UI_GetThemeColor3ubv(TH_ACTIVE_VERT, vert_color_active);
-
- glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
-
- immBeginAtMost(GWN_PRIM_POINTS, count);
-
- for (nu = nurb; nu; nu = nu->next) {
-
- if (nu->hide) continue;
-
- if (nu->type == CU_BEZIER) {
-
- const BezTriple *bezt = nu->bezt;
- int a = nu->pntsu;
- while (a--) {
- if (bezt->hide == 0) {
- if (bezt == vert) {
- immAttrib3ubv(color, bezt->f2 & SELECT ? vert_color_active : vert_color);
- immVertex3fv(pos, bezt->vec[1]);
- if (!hide_handles) {
- immAttrib3ubv(color, bezt->f1 & SELECT ? vert_color_active : vert_color);
- immVertex3fv(pos, bezt->vec[0]);
- immAttrib3ubv(color, bezt->f3 & SELECT ? vert_color_active : vert_color);
- immVertex3fv(pos, bezt->vec[2]);
- }
- }
- else {
- immAttrib3ubv(color, bezt->f2 & SELECT ? vert_color_select : vert_color);
- immVertex3fv(pos, bezt->vec[1]);
- if (!hide_handles) {
- immAttrib3ubv(color, bezt->f1 & SELECT ? vert_color_select : vert_color);
- immVertex3fv(pos, bezt->vec[0]);
- immAttrib3ubv(color, bezt->f3 & SELECT ? vert_color_select : vert_color);
- immVertex3fv(pos, bezt->vec[2]);
- }
- }
- }
- bezt++;
- }
- }
- else {
- const BPoint *bp = nu->bp;
- int a = nu->pntsu * nu->pntsv;
- while (a--) {
- if (bp->hide == 0) {
- if (bp == vert) {
- immAttrib3ubv(color, vert_color_active);
- }
- else {
- immAttrib3ubv(color, bp->f1 & SELECT ? vert_color_select : vert_color);
- }
- immVertex3fv(pos, bp->vec);
- }
- bp++;
- }
- }
- }
-
- immEnd();
- immUnbindProgram();
-}
-
-static void editnurb_draw_active_poly(Nurb *nu)
-{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformThemeColor(TH_ACTIVE_SPLINE);
-
- glLineWidth(2.0f);
-
- BPoint *bp = nu->bp;
- for (int b = 0; b < nu->pntsv; b++) {
- if (nu->pntsu >= 2) {
- if (nu->flagu & 1) immBegin(GWN_PRIM_LINE_LOOP, nu->pntsu);
- else immBegin(GWN_PRIM_LINE_STRIP, nu->pntsu);
-
- for (int a = 0; a < nu->pntsu; a++, bp++) {
- immVertex3fv(pos, bp->vec);
- }
-
- immEnd();
- }
- }
-
- immUnbindProgram();
-}
-
-static void editnurb_draw_active_nurbs(Nurb *nu)
-{
- if (nu->pntsv > 0) {
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformThemeColor(TH_ACTIVE_SPLINE);
-
- glLineWidth(2.0f);
- // just quick guesstimate of how many verts to draw
- int count = (nu->pntsu - 1) * nu->pntsv * 2;
- if (nu->pntsv > 1) count += (nu->pntsv - 1) * nu->pntsu * 2;
- if (count < 2) return;
-
- immBeginAtMost(GWN_PRIM_LINES, count);
- BPoint *bp = nu->bp;
- for (int b = 0; b < nu->pntsv; b++) {
- BPoint *bp1 = bp;
- bp++;
-
- for (int a = nu->pntsu - 1; a > 0; a--, bp++) {
- if (bp->hide == 0 && bp1->hide == 0) {
- immVertex3fv(pos, bp->vec);
- immVertex3fv(pos, bp1->vec);
- }
- bp1 = bp;
- }
- }
-
- if (nu->pntsv > 1) { /* surface */
- int ofs = nu->pntsu;
- for (int b = 0; b < nu->pntsu; b++) {
- BPoint *bp1 = nu->bp + b;
- bp = bp1 + ofs;
- for (int a = nu->pntsv - 1; a > 0; a--, bp += ofs) {
- if (bp->hide == 0 && bp1->hide == 0) {
- immVertex3fv(pos, bp->vec);
- immVertex3fv(pos, bp1->vec);
- }
- bp1 = bp;
- }
- }
- }
-
- immEnd();
-
- immUnbindProgram();
- }
-}
-
-static void draw_editnurb_splines(Object *ob, Nurb *nurb, const bool sel)
-{
- BPoint *bp, *bp1;
- int a, b;
- Curve *cu = ob->data;
- Gwn_VertFormat *format;
- unsigned int pos, col;
- unsigned char color[3];
-
- int index = 0;
- Nurb *nu = nurb;
- while (nu) {
- if (nu->hide == 0) {
- switch (nu->type) {
- case CU_POLY:
- {
- if (!sel && index == cu->actnu) {
- /* we should draw active spline highlight below everything */
- editnurb_draw_active_poly(nu);
- }
-
- format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- glLineWidth(1.0f);
-
- immUniformThemeColor(TH_NURB_ULINE);
- bp = nu->bp;
- for (b = 0; b < nu->pntsv; b++) {
- if (nu->pntsu >= 2) {
- if (nu->flagu & 1) immBegin(GWN_PRIM_LINE_LOOP, nu->pntsu);
- else immBegin(GWN_PRIM_LINE_STRIP, nu->pntsu);
-
- for (a = 0; a < nu->pntsu; a++, bp++) {
- immVertex3fv(pos, bp->vec);
- }
-
- immEnd();
- }
- }
- immUnbindProgram();
- break;
- }
- case CU_NURBS:
- {
- if (!sel && index == cu->actnu) {
- /* we should draw active spline highlight below everything */
- editnurb_draw_active_nurbs(nu);
- }
-
- format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- // just quick guesstimate of how many verts to draw
- int count = (nu->pntsu - 1) * nu->pntsv * 2;
- if (nu->pntsv > 1) count += (nu->pntsv - 1) * nu->pntsu * 2;
- if (count < 2) return;
-
- glLineWidth(1.0f);
-
- immBeginAtMost(GWN_PRIM_LINES, count);
-
- bp = nu->bp;
- for (b = 0; b < nu->pntsv; b++) {
- bp1 = bp;
- bp++;
- for (a = nu->pntsu - 1; a > 0; a--, bp++) {
- if (bp->hide == 0 && bp1->hide == 0) {
- if (sel) {
- if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
- UI_GetThemeColor3ubv(TH_NURB_SEL_ULINE, color);
- immAttrib3ubv(col, color);
- immVertex3fv(pos, bp->vec);
- immVertex3fv(pos, bp1->vec);
- }
- }
- else {
- if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
- /* pass */
- }
- else {
- UI_GetThemeColor3ubv(TH_NURB_ULINE, color);
- immAttrib3ubv(col, color);
- immVertex3fv(pos, bp->vec);
- immVertex3fv(pos, bp1->vec);
- }
- }
- }
- bp1 = bp;
- }
- }
-
- if (nu->pntsv > 1) { /* surface */
- int ofs = nu->pntsu;
- for (b = 0; b < nu->pntsu; b++) {
- bp1 = nu->bp + b;
- bp = bp1 + ofs;
- for (a = nu->pntsv - 1; a > 0; a--, bp += ofs) {
- if (bp->hide == 0 && bp1->hide == 0) {
- if (sel) {
- if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
- UI_GetThemeColor3ubv(TH_NURB_SEL_VLINE, color);
- immAttrib3ubv(col, color);
- immVertex3fv(pos, bp->vec);
- immVertex3fv(pos, bp1->vec);
- }
- }
- else {
- if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
- /* pass */
- }
- else {
- UI_GetThemeColor3ubv(TH_NURB_VLINE, color);
- immAttrib3ubv(col, color);
- immVertex3fv(pos, bp->vec);
- immVertex3fv(pos, bp1->vec);
- }
- }
- }
- bp1 = bp;
- }
- }
- }
- immEnd();
- immUnbindProgram();
- break;
- }
- }
- }
-
- index++;
- nu = nu->next;
- }
-}
-
-static void draw_editnurb(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
- View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb,
- const char dt, const short dflag, const unsigned char UNUSED(ob_wire_col[4]))
-{
- ToolSettings *ts = scene->toolsettings;
- Object *ob = base->object;
- Curve *cu = ob->data;
- Nurb *nu;
- const void *vert = BKE_curve_vert_active_get(cu);
- const bool hide_handles = (cu->drawflag & CU_HIDE_HANDLES) != 0;
- unsigned char wire_col[3];
-
- /* DispList */
- UI_GetThemeColor3ubv(TH_WIRE_EDIT, wire_col);
-
- drawDispList(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, wire_col);
-
- /* for shadows only show solid faces */
- if (v3d->flag2 & V3D_RENDER_SHADOW)
- return;
-
- if (v3d->zbuf) glDepthFunc(GL_ALWAYS);
-
- /* first non-selected and active handles */
- int index = 0;
- for (nu = nurb; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER) {
- if (index == cu->actnu && !hide_handles)
- drawhandlesN_active(nu);
- drawhandlesN(nu, 0, hide_handles);
- }
- index++;
- }
- draw_editnurb_splines(ob, nurb, false);
- draw_editnurb_splines(ob, nurb, true);
- /* selected handles */
- for (nu = nurb; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER && (cu->drawflag & CU_HIDE_HANDLES) == 0)
- drawhandlesN(nu, 1, hide_handles);
- }
-
- if (v3d->zbuf) glDepthFunc(GL_LEQUAL);
-
- /* direction vectors for 3d curve paths
- * when at its lowest, don't render normals */
- if ((cu->flag & CU_3D) && (ts->normalsize > 0.0015f) && (cu->drawflag & CU_HIDE_NORMALS) == 0) {
- BevList *bl;
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformThemeColor(TH_WIRE_EDIT);
-
- glLineWidth(1.0f);
-
- int count = 0;
- int count_used = 0;
- for (bl = ob->curve_cache->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
- int nr = bl->nr;
- int skip = nu->resolu / 16;
-
-#if 0
- while (nr-- > 0) { /* accounts for empty bevel lists */
- count += 4;
- nr -= skip;
- }
-#else
- /* Same as loop above */
- count += 4 * ((nr / (skip + 1)) + ((nr % (skip + 1)) != 0));
-#endif
- }
-
- if (count > 2) {
- immBegin(GWN_PRIM_LINES, count);
- for (bl = ob->curve_cache->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
- BevPoint *bevp = bl->bevpoints;
- int nr = bl->nr;
- int skip = nu->resolu / 16;
-
- while (nr-- > 0) { /* accounts for empty bevel lists */
- const float fac = bevp->radius * ts->normalsize;
- float vec_a[3]; /* Offset perpendicular to the curve */
- float vec_b[3]; /* Delta along the curve */
-
- vec_a[0] = fac;
- vec_a[1] = 0.0f;
- vec_a[2] = 0.0f;
-
- mul_qt_v3(bevp->quat, vec_a);
- madd_v3_v3fl(vec_a, bevp->dir, -fac);
-
- reflect_v3_v3v3(vec_b, vec_a, bevp->dir);
- negate_v3(vec_b);
-
- add_v3_v3(vec_a, bevp->vec);
- add_v3_v3(vec_b, bevp->vec);
-
- immVertex3fv(pos, vec_a);
- immVertex3fv(pos, bevp->vec);
- immVertex3fv(pos, bevp->vec);
- immVertex3fv(pos, vec_b);
-
- bevp += skip + 1;
- nr -= skip;
- count_used += 4;
- }
- }
- BLI_assert(count == count_used);
- UNUSED_VARS_NDEBUG(count_used);
-
- immEnd();
- }
- immUnbindProgram();
- }
-
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
- drawvertsN(nurb, hide_handles, vert);
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
-}
-
-static void draw_editfont_textcurs(RegionView3D *rv3d, float textcurs[4][2])
-{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- ED_view3d_polygon_offset(rv3d, -1.0);
- set_inverted_drawing(1);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- imm_cpack(0);
- immBegin(GWN_PRIM_TRI_FAN, 4);
- immVertex2fv(pos, textcurs[0]);
- immVertex2fv(pos, textcurs[1]);
- immVertex2fv(pos, textcurs[2]);
- immVertex2fv(pos, textcurs[3]);
- immEnd();
- set_inverted_drawing(0);
- ED_view3d_polygon_offset(rv3d, 0.0);
- immUnbindProgram();
-}
-
-static void draw_editfont(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4])
-{
- Object *ob = base->object;
- Curve *cu = ob->data;
- EditFont *ef = cu->editfont;
- float vec1[3], vec2[3];
-
- draw_editfont_textcurs(rv3d, ef->textcurs);
-
- if (cu->flag & CU_FAST) {
- imm_cpack(0xFFFFFF);
- set_inverted_drawing(1);
- drawDispList(eval_ctx, scene, view_layer, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
- set_inverted_drawing(0);
- }
- else {
- drawDispList(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
- }
-
- if (cu->linewidth != 0.0f) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformThemeColor(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);
- immBegin(GWN_PRIM_LINES, 2);
- immVertex2fv(pos, vec1);
- immVertex2fv(pos, vec2);
- immEnd();
- setlinestyle(0);
- immUnbindProgram();
- }
-
- setlinestyle(3);
- for (int i = 0; i < cu->totbox; i++) {
- if (cu->tb[i].w != 0.0f) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE);
- vec1[0] = cu->xof + cu->tb[i].x;
- vec1[1] = cu->yof + cu->tb[i].y + cu->fsize;
- vec1[2] = 0.001;
- immBegin(GWN_PRIM_LINE_STRIP, 5);
- immVertex3fv(pos, vec1);
- vec1[0] += cu->tb[i].w;
- immVertex3fv(pos, vec1);
- vec1[1] -= cu->tb[i].h;
- immVertex3fv(pos, vec1);
- vec1[0] -= cu->tb[i].w;
- immVertex3fv(pos, vec1);
- vec1[1] += cu->tb[i].h;
- immVertex3fv(pos, vec1);
- immEnd();
- immUnbindProgram();
- }
- }
- setlinestyle(0);
-
-
- if (ef->selboxes && ef->selboxes_len) {
- float selboxw;
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- imm_cpack(0xffffff);
- set_inverted_drawing(1);
- for (int i = 0; i < ef->selboxes_len; i++) {
- EditFontSelBox *sb = &ef->selboxes[i];
- float tvec[3];
-
- if (i + 1 != ef->selboxes_len) {
- if (ef->selboxes[i + 1].y == sb->y)
- selboxw = ef->selboxes[i + 1].x - sb->x;
- else
- selboxw = sb->w;
- }
- else {
- selboxw = sb->w;
- }
-
- /* fill in xy below */
- tvec[2] = 0.001;
-
- immBegin(GWN_PRIM_TRI_FAN, 4);
-
- if (sb->rot == 0.0f) {
- copy_v2_fl2(tvec, sb->x, sb->y);
- immVertex3fv(pos, tvec);
-
- copy_v2_fl2(tvec, sb->x + selboxw, sb->y);
- immVertex3fv(pos, tvec);
-
- copy_v2_fl2(tvec, sb->x + selboxw, sb->y + sb->h);
- immVertex3fv(pos, tvec);
-
- copy_v2_fl2(tvec, sb->x, sb->y + sb->h);
- immVertex3fv(pos, tvec);
- }
- else {
- float mat[2][2];
-
- angle_to_mat2(mat, sb->rot);
-
- copy_v2_fl2(tvec, sb->x, sb->y);
- immVertex3fv(pos, tvec);
-
- copy_v2_fl2(tvec, selboxw, 0.0f);
- mul_m2v2(mat, tvec);
- add_v2_v2(tvec, &sb->x);
- immVertex3fv(pos, tvec);
-
- copy_v2_fl2(tvec, selboxw, sb->h);
- mul_m2v2(mat, tvec);
- add_v2_v2(tvec, &sb->x);
- immVertex3fv(pos, tvec);
-
- copy_v2_fl2(tvec, 0.0f, sb->h);
- mul_m2v2(mat, tvec);
- add_v2_v2(tvec, &sb->x);
- immVertex3fv(pos, tvec);
- }
-
- immEnd();
- }
- set_inverted_drawing(0);
- immUnbindProgram();
- }
-}
-
-/* draw a sphere for use as an empty drawtype */
-static void draw_empty_sphere(float size, unsigned pos)
-{
-#define NSEGMENTS 16
- /* a single ring of vertices */
- float p[NSEGMENTS][2];
- for (int i = 0; i < NSEGMENTS; ++i) {
- float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
- p[i][0] = size * cosf(angle);
- p[i][1] = size * sinf(angle);
- }
-
- immBegin(GWN_PRIM_LINE_LOOP, NSEGMENTS);
- for (int i = 0; i < NSEGMENTS; ++i)
- immVertex3f(pos, p[i][0], p[i][1], 0.0f);
- immEnd();
- immBegin(GWN_PRIM_LINE_LOOP, NSEGMENTS);
- for (int i = 0; i < NSEGMENTS; ++i)
- immVertex3f(pos, p[i][0], 0.0f, p[i][1]);
- immEnd();
- immBegin(GWN_PRIM_LINE_LOOP, NSEGMENTS);
- for (int i = 0; i < NSEGMENTS; ++i)
- immVertex3f(pos, 0.0f, p[i][0], p[i][1]);
- immEnd();
-#undef NSEGMENTS
-}
-
-/* draw a cone for use as an empty drawtype */
-static void draw_empty_cone(float size, unsigned pos)
-{
-#define NSEGMENTS 8
- /* a single ring of vertices */
- float p[NSEGMENTS][2];
- for (int i = 0; i < NSEGMENTS; ++i) {
- float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
- p[i][0] = size * cosf(angle);
- p[i][1] = size * sinf(angle);
- }
-
- /* cone sides */
- immBegin(GWN_PRIM_LINES, NSEGMENTS * 2);
- for (int i = 0; i < NSEGMENTS; ++i) {
- immVertex3f(pos, 0.0f, 2.0f * size, 0.0f);
- immVertex3f(pos, p[i][0], 0.0f, p[i][1]);
- }
- immEnd();
-
- /* end ring */
- immBegin(GWN_PRIM_LINE_LOOP, NSEGMENTS);
- for (int i = 0; i < NSEGMENTS; ++i)
- immVertex3f(pos, p[i][0], 0.0f, p[i][1]);
- immEnd();
-#undef NSEGMENTS
-}
-
-static void drawspiral(unsigned int pos, const float cent[3], float rad, float tmat[4][4], int start)
-{
- float vec[3], vx[3], vy[3];
- const float tot_inv = 1.0f / (float)CIRCLE_RESOL;
- int a;
- bool inverse = false;
- float x, y, fac;
-
- if (start < 0) {
- inverse = true;
- start = -start;
- }
-
- mul_v3_v3fl(vx, tmat[0], rad);
- mul_v3_v3fl(vy, tmat[1], rad);
-
- immBegin(GWN_PRIM_LINE_STRIP, CIRCLE_RESOL + 1);
-
- if (inverse == 0) {
- copy_v3_v3(vec, cent);
- immVertex3fv(pos, vec);
-
- for (a = 0; a < CIRCLE_RESOL; a++) {
- if (a + start >= CIRCLE_RESOL)
- start = -a + 1;
-
- fac = (float)a * tot_inv;
- x = sinval[a + start] * fac;
- y = cosval[a + start] * fac;
-
- vec[0] = cent[0] + (x * vx[0] + y * vy[0]);
- vec[1] = cent[1] + (x * vx[1] + y * vy[1]);
- vec[2] = cent[2] + (x * vx[2] + y * vy[2]);
-
- immVertex3fv(pos, vec);
- }
- }
- else {
- fac = (float)(CIRCLE_RESOL - 1) * tot_inv;
- x = sinval[start] * fac;
- y = cosval[start] * fac;
-
- vec[0] = cent[0] + (x * vx[0] + y * vy[0]);
- vec[1] = cent[1] + (x * vx[1] + y * vy[1]);
- vec[2] = cent[2] + (x * vx[2] + y * vy[2]);
-
- immVertex3fv(pos, vec);
-
- for (a = 0; a < CIRCLE_RESOL; a++) {
- if (a + start >= CIRCLE_RESOL)
- start = -a + 1;
-
- fac = (float)(-a + (CIRCLE_RESOL - 1)) * tot_inv;
- x = sinval[a + start] * fac;
- y = cosval[a + start] * fac;
-
- vec[0] = cent[0] + (x * vx[0] + y * vy[0]);
- vec[1] = cent[1] + (x * vx[1] + y * vy[1]);
- vec[2] = cent[2] + (x * vx[2] + y * vy[2]);
- immVertex3fv(pos, vec);
- }
- }
-
- immEnd();
-}
-
-/* draws a circle on x-z plane given the scaling of the circle, assuming that
- * all required matrices have been set (used for drawing empties) */
-static void drawcircle_size(float size, unsigned pos)
-{
- immBegin(GWN_PRIM_LINE_LOOP, CIRCLE_RESOL);
-
- /* coordinates are: cos(degrees * 11.25) = x, sin(degrees * 11.25) = y, 0.0f = z */
- for (short degrees = 0; degrees < CIRCLE_RESOL; degrees++) {
- float x = cosval[degrees];
- float y = sinval[degrees];
-
- immVertex3f(pos, x * size, 0.0f, y * size);
- }
-
- immEnd();
-}
-
-/* needs fixing if non-identity matrix used */
-static void imm_drawtube(const float vec[3], float radius, float height, float tmat[4][4], unsigned pos)
-{
- float cur[3];
- imm_drawcircball(vec, radius, tmat, pos);
-
- copy_v3_v3(cur, vec);
- cur[2] += height;
-
- imm_drawcircball(cur, radius, tmat, pos);
-
- immBegin(GWN_PRIM_LINES, 8);
- immVertex3f(pos, vec[0] + radius, vec[1], vec[2]);
- immVertex3f(pos, cur[0] + radius, cur[1], cur[2]);
- immVertex3f(pos, vec[0] - radius, vec[1], vec[2]);
- immVertex3f(pos, cur[0] - radius, cur[1], cur[2]);
- immVertex3f(pos, vec[0], vec[1] + radius, vec[2]);
- immVertex3f(pos, cur[0], cur[1] + radius, cur[2]);
- immVertex3f(pos, vec[0], vec[1] - radius, vec[2]);
- immVertex3f(pos, cur[0], cur[1] - radius, cur[2]);
- immEnd();
-}
-
-/* needs fixing if non-identity matrix used */
-static void imm_drawcone(const float vec[3], float radius, float height, float tmat[4][4], unsigned pos)
-{
- float cur[3];
-
- copy_v3_v3(cur, vec);
- cur[2] += height;
-
- imm_drawcircball(cur, radius, tmat, pos);
-
- immBegin(GWN_PRIM_LINES, 8);
- immVertex3f(pos, vec[0], vec[1], vec[2]);
- immVertex3f(pos, cur[0] + radius, cur[1], cur[2]);
- immVertex3f(pos, vec[0], vec[1], vec[2]);
- immVertex3f(pos, cur[0] - radius, cur[1], cur[2]);
- immVertex3f(pos, vec[0], vec[1], vec[2]);
- immVertex3f(pos, cur[0], cur[1] + radius, cur[2]);
- immVertex3f(pos, vec[0], vec[1], vec[2]);
- immVertex3f(pos, cur[0], cur[1] - radius, cur[2]);
- immEnd();
-}
-
-/* return true if nothing was drawn */
-static bool drawmball(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4])
-{
- Object *ob = base->object;
- MetaElem *ml;
- float imat[4][4];
- int code = 1;
-
- MetaBall *mb = ob->data;
-
- if (mb->editelems) {
- if ((G.f & G_PICKSEL) == 0) {
- unsigned char wire_col[4];
- UI_GetThemeColor4ubv(TH_WIRE_EDIT, wire_col);
- drawDispList(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, wire_col);
- }
- ml = mb->editelems->first;
- }
- else {
- if ((base->flag_legacy & OB_FROMDUPLI) == 0) {
- drawDispList(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
- }
- ml = mb->elems.first;
- }
-
- if (ml == NULL) {
- return true;
- }
-
- if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
- return false;
- }
-
- invert_m4_m4(imat, rv3d->viewmatob);
- normalize_v3(imat[0]);
- normalize_v3(imat[1]);
-
-#if 0 /* no purpose? */
- if (mb->editelems == NULL) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
- }
- }
-#endif
-
- glLineWidth(1.0f);
-
- const unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- while (ml) {
- /* draw radius */
- if (mb->editelems) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) imm_cpack(0xA0A0F0);
- else imm_cpack(0x3030A0);
- }
-
- if (G.f & G_PICKSEL) {
- ml->selcol1 = code;
- GPU_select_load_id(code++);
- }
- }
- imm_drawcircball(&(ml->x), ml->rad, imat, pos);
-
- /* draw stiffness */
- if (mb->editelems) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) imm_cpack(0xA0F0A0);
- else imm_cpack(0x30A030);
- }
-
- if (G.f & G_PICKSEL) {
- ml->selcol2 = code;
- GPU_select_load_id(code++);
- }
- imm_drawcircball(&(ml->x), ml->rad * atanf(ml->s) / (float)M_PI_2, imat, pos);
- }
-
- ml = ml->next;
- }
-
- immUnbindProgram();
- return false;
-}
-
-static void draw_forcefield(Object *ob, RegionView3D *rv3d,
- const short dflag, const unsigned char ob_wire_col[4])
-{
- PartDeflect *pd = ob->pd;
- float imat[4][4], tmat[4][4];
- float vec[3] = {0.0, 0.0, 0.0};
- float draw_color[3] = {0.0f, 0.0f, 0.0f};
- /* scale size of circle etc with the empty drawsize */
- const float size = (ob->type == OB_EMPTY) ? ob->empty_drawsize : 1.0f;
-
- /* calculus here, is reused in PFIELD_FORCE */
- invert_m4_m4(imat, rv3d->viewmatob);
-#if 0
- normalize_v3(imat[0]); /* we don't do this because field doesnt scale either... apart from wind! */
- normalize_v3(imat[1]);
-#endif
-
- const unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor3fv(draw_color);
-
- if (pd->forcefield == PFIELD_WIND) {
- float force_val = pd->f_strength;
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f, draw_color);
- immUniformColor3fv(draw_color);
- }
-
- unit_m4(tmat);
- force_val *= 0.1f;
- imm_drawcircball(vec, size, tmat, pos);
- vec[2] = 0.5f * force_val;
- imm_drawcircball(vec, size, tmat, pos);
- vec[2] = 1.0f * force_val;
- imm_drawcircball(vec, size, tmat, pos);
- vec[2] = 1.5f * force_val;
- imm_drawcircball(vec, size, tmat, pos);
- vec[2] = 0.0f; /* reset vec for max dist circle */
- }
- else if (pd->forcefield == PFIELD_FORCE) {
- float ffall_val = pd->f_power;
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f, draw_color);
- immUniformColor3fv(draw_color);
- }
-
- imm_drawcircball(vec, size, imat, pos);
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val), draw_color);
- immUniformColor3fv(draw_color);
- }
-
- imm_drawcircball(vec, size * 1.5f, imat, pos);
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val), draw_color);
- immUniformColor3fv(draw_color);
- }
-
- imm_drawcircball(vec, size * 2.0f, imat, pos);
- }
- else if (pd->forcefield == PFIELD_VORTEX) {
- float force_val = pd->f_strength;
-
- unit_m4(tmat);
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.7f, draw_color);
- immUniformColor3fv(draw_color);
- }
-
- if (force_val < 0) {
- drawspiral(pos, vec, size, tmat, 1);
- drawspiral(pos, vec, size, tmat, 16);
- }
- else {
- drawspiral(pos, vec, size, tmat, -1);
- drawspiral(pos, vec, size, tmat, -16);
- }
- }
- else if (pd->forcefield == PFIELD_GUIDE && ob->type == OB_CURVE) {
- Curve *cu = ob->data;
- if ((cu->flag & CU_PATH) && ob->curve_cache->path && ob->curve_cache->path->data) {
- float guidevec1[4], guidevec2[3];
- float mindist = pd->f_strength;
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f, draw_color);
- immUniformColor3fv(draw_color);
- }
-
- /* path end */
- setlinestyle(3);
- where_on_path(ob, 1.0f, guidevec1, guidevec2, NULL, NULL, NULL);
- imm_drawcircball(guidevec1, mindist, imat, pos);
-
- /* path beginning */
- setlinestyle(0);
- where_on_path(ob, 0.0f, guidevec1, guidevec2, NULL, NULL, NULL);
- imm_drawcircball(guidevec1, mindist, imat, pos);
-
- copy_v3_v3(vec, guidevec1); /* max center */
- }
- }
-
- setlinestyle(3);
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f, draw_color);
- immUniformColor3fv(draw_color);
- }
-
- if (pd->falloff == PFIELD_FALL_SPHERE) {
- /* as last, guide curve alters it */
- if ((pd->flag & PFIELD_USEMAX) != 0) {
- imm_drawcircball(vec, pd->maxdist, imat, pos);
- }
-
- if ((pd->flag & PFIELD_USEMIN) != 0) {
- imm_drawcircball(vec, pd->mindist, imat, pos);
- }
- }
- else if (pd->falloff == PFIELD_FALL_TUBE) {
- float radius, distance;
-
- unit_m4(tmat);
-
- vec[0] = vec[1] = 0.0f;
- radius = (pd->flag & PFIELD_USEMAXR) ? pd->maxrad : 1.0f;
- distance = (pd->flag & PFIELD_USEMAX) ? pd->maxdist : 0.0f;
- vec[2] = distance;
- distance = (pd->flag & PFIELD_POSZ) ? -distance : -2.0f * distance;
-
- if (pd->flag & (PFIELD_USEMAX | PFIELD_USEMAXR)) {
- imm_drawtube(vec, radius, distance, tmat, pos);
- }
-
- radius = (pd->flag & PFIELD_USEMINR) ? pd->minrad : 1.0f;
- distance = (pd->flag & PFIELD_USEMIN) ? pd->mindist : 0.0f;
- vec[2] = distance;
- distance = (pd->flag & PFIELD_POSZ) ? -distance : -2.0f * distance;
-
- if (pd->flag & (PFIELD_USEMIN | PFIELD_USEMINR)) {
- imm_drawtube(vec, radius, distance, tmat, pos);
- }
- }
- else if (pd->falloff == PFIELD_FALL_CONE) {
- float radius, distance;
-
- unit_m4(tmat);
-
- radius = DEG2RADF((pd->flag & PFIELD_USEMAXR) ? pd->maxrad : 1.0f);
- distance = (pd->flag & PFIELD_USEMAX) ? pd->maxdist : 0.0f;
-
- if (pd->flag & (PFIELD_USEMAX | PFIELD_USEMAXR)) {
- imm_drawcone(vec, distance * sinf(radius), distance * cosf(radius), tmat, pos);
- if ((pd->flag & PFIELD_POSZ) == 0)
- imm_drawcone(vec, distance * sinf(radius), -distance * cosf(radius), tmat, pos);
- }
-
- radius = DEG2RADF((pd->flag & PFIELD_USEMINR) ? pd->minrad : 1.0f);
- distance = (pd->flag & PFIELD_USEMIN) ? pd->mindist : 0.0f;
-
- if (pd->flag & (PFIELD_USEMIN | PFIELD_USEMINR)) {
- imm_drawcone(vec, distance * sinf(radius), distance * cosf(radius), tmat, pos);
- if ((pd->flag & PFIELD_POSZ) == 0)
- imm_drawcone(vec, distance * sinf(radius), -distance * cosf(radius), tmat, pos);
- }
- }
- setlinestyle(0);
-
- immUnbindProgram();
-}
-
-static void imm_draw_box(const float vec[8][3], bool solid, unsigned pos)
-{
- if (solid) {
- /* Adpated from "Optimizing Triangle Strips for Fast Rendering" by F. Evans, S. Skiena and A. Varshney
- * (http://www.cs.umd.edu/gvil/papers/av_ts.pdf). */
- static const GLubyte tris_strip_indices[14] = {0, 1, 3, 2, 6, 1, 5, 0, 4, 3, 7, 6, 4, 5};
- immBegin(GWN_PRIM_TRI_STRIP, 14);
- for (int i = 0; i < 14; ++i) {
- immVertex3fv(pos, vec[tris_strip_indices[i]]);
- }
- immEnd();
- }
- else {
- static const GLubyte line_indices[24] =
- {0, 1, 1, 2, 2, 3, 3, 0, 0, 4, 4, 5, 5, 6, 6, 7, 7, 4, 1, 5, 2, 6, 3, 7};
- immBegin(GWN_PRIM_LINES, 24);
- for (int i = 0; i < 24; ++i) {
- immVertex3fv(pos, vec[line_indices[i]]);
- }
- immEnd();
- }
-
-}
-
-static void imm_draw_bb(BoundBox *bb, char type, bool around_origin, const unsigned char ob_wire_col[4])
-{
- float size[3], cent[3];
- Gwn_Batch *sphere = GPU_batch_preset_sphere_wire(0);
- GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
- if (ob_wire_col) GWN_batch_uniform_4f(sphere, "color", ob_wire_col[0] / 255.0f, ob_wire_col[1] / 255.0f, ob_wire_col[2] / 255.0f, 1.0f);
-
- BKE_boundbox_calc_size_aabb(bb, size);
-
- if (around_origin) {
- zero_v3(cent);
- }
- else {
- BKE_boundbox_calc_center_aabb(bb, cent);
- }
-
- gpuPushMatrix();
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- if (ob_wire_col) immUniformColor3ubv(ob_wire_col);
-
- if (type == OB_BOUND_SPHERE) {
- float scale = MAX3(size[0], size[1], size[2]);
- gpuTranslate3fv(cent);
- gpuRotateAxis(90, 'X');
- gpuScaleUniform(scale);
- GWN_batch_draw(sphere);
- }
- else if (type == OB_BOUND_CYLINDER) {
- float radius = size[0] > size[1] ? size[0] : size[1];
- gpuTranslate3f(cent[0], cent[1], cent[2] - size[2]);
- gpuScale3f(radius, radius, 2.0f * size[2]);
- imm_draw_cylinder_wire_3d(pos, 1.0f, 1.0f, 1.0f, 8, 1);
- }
- else if (type == OB_BOUND_CONE) {
- float radius = size[0] > size[1] ? size[0] : size[1];
- gpuTranslate3f(cent[0], cent[1], cent[2] - size[2]);
- gpuScale3f(radius, radius, 2.0f * size[2]);
- imm_draw_cylinder_wire_3d(pos, 1.0f, 0.0f, 1.0f, 8, 1);
-
- }
- else if (type == OB_BOUND_CAPSULE) {
- float radius = size[0] > size[1] ? size[0] : size[1];
- float length = size[2] > radius ? 2.0f * (size[2] - radius) : 0.0f;
- gpuTranslate3f(cent[0], cent[1], cent[2] - length * 0.5f);
- imm_draw_cylinder_wire_3d(pos, radius, radius, length, 8, 1);
-
- gpuRotateAxis(90, 'X');
- gpuScaleUniform(radius);
- GWN_batch_draw(sphere);
-
- gpuTranslate3f(0.0f, length / radius, 0.0f);
- GWN_batch_draw(sphere);
- }
-
- gpuPopMatrix();
- immUnbindProgram();
-}
-
-void draw_bounding_volume(Object *ob, char type, const unsigned char ob_wire_col[4])
-{
- BoundBox bb_local;
- BoundBox *bb = NULL;
-
- if (ob->type == OB_MESH) {
- bb = BKE_mesh_boundbox_get(ob);
- }
- else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
- bb = BKE_curve_boundbox_get(ob);
- }
- else if (ob->type == OB_MBALL) {
- if (BKE_mball_is_basis(ob)) {
- bb = ob->bb;
- }
- }
- else if (ob->type == OB_ARMATURE) {
- bb = BKE_armature_boundbox_get(ob);
- }
- else if (ob->type == OB_LATTICE) {
- bb = BKE_lattice_boundbox_get(ob);
- }
- else {
- const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f};
- bb = &bb_local;
- BKE_boundbox_init_from_minmax(bb, min, max);
- }
-
- if (bb == NULL)
- return;
-
- if (ob->gameflag & OB_BOUNDS) { /* bounds need to be drawn around origin for game engine */
-
- if (type == OB_BOUND_BOX) {
- float vec[8][3], size[3];
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- if (ob_wire_col) immUniformColor3ubv(ob_wire_col);
-
- BKE_boundbox_calc_size_aabb(bb, size);
-
- vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = -size[0];
- vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = +size[0];
- vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = -size[1];
- vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = +size[1];
- vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = -size[2];
- vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = +size[2];
-
- imm_draw_box(vec, false, pos);
-
- immUnbindProgram();
- }
- else {
- imm_draw_bb(bb, type, true, ob_wire_col);
- }
- }
- else {
- if (type == OB_BOUND_BOX) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- if (ob_wire_col) immUniformColor3ubv(ob_wire_col);
-
- imm_draw_box(bb->vec, false, pos);
-
- immUnbindProgram();
- }
- else
- imm_draw_bb(bb, type, false, ob_wire_col);
- }
-
-}
-
-static void drawtexspace(Object *ob, const unsigned char ob_wire_col[3])
-{
- float vec[8][3], loc[3], size[3];
-
- if (ob->type == OB_MESH) {
- BKE_mesh_texspace_get(ob->data, loc, NULL, size);
- }
- else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
- BKE_curve_texspace_get(ob->data, loc, NULL, size);
- }
- else if (ob->type == OB_MBALL) {
- MetaBall *mb = ob->data;
- copy_v3_v3(size, mb->size);
- copy_v3_v3(loc, mb->loc);
- }
- else {
- return;
- }
-
- vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = loc[0] - size[0];
- vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = loc[0] + size[0];
-
- vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = loc[1] - size[1];
- vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = loc[1] + size[1];
-
- vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = loc[2] - size[2];
- vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = loc[2] + size[2];
-
- setlinestyle(2);
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- if (ob_wire_col) {
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor3ubv(ob_wire_col);
- }
- else {
- immBindBuiltinProgram(GPU_SHADER_3D_DEPTH_ONLY);
- }
-
- imm_draw_box(vec, false, pos);
-
- immUnbindProgram();
-
- setlinestyle(0);
-}
-
-/* draws wire outline */
-static void draw_object_selected_outline(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, ARegion *ar, Base *base,
- const unsigned char ob_wire_col[4])
-{
- RegionView3D *rv3d = ar->regiondata;
- Object *ob = base->object;
-
- glDepthMask(GL_FALSE);
-
- if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
- bool has_faces = false;
-
-#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(eval_ctx, scene, ob);
-#endif
-
- DerivedMesh *dm = ob->derivedFinal;
- if (dm) {
- DM_update_materials(dm, ob);
- }
-
- if (dm) {
- has_faces = (dm->getNumPolys(dm) != 0);
- }
- else {
- has_faces = BKE_displist_has_faces(&ob->curve_cache->disp);
- }
-
- if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->bb)) {
- glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
- if (dm) {
- draw_mesh_object_outline(v3d, ob, dm, ob_wire_col);
- }
- else {
- /* only draw 'solid' parts of the display list as wire. */
- drawDispListwire_ex(&ob->curve_cache->disp, (DL_INDEX3 | DL_INDEX4 | DL_SURF), ob_wire_col);
- }
- }
- }
- else if (ob->type == OB_MBALL) {
- if (BKE_mball_is_basis(ob)) {
- if ((base->flag_legacy & OB_FROMDUPLI) == 0) {
- glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
- drawDispListwire(&ob->curve_cache->disp, ob->type, ob_wire_col);
- }
- }
- }
- else if (ob->type == OB_ARMATURE) {
- if (!(ob->mode & OB_MODE_POSE && base == view_layer->basact)) {
- glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
- draw_armature(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, 0, ob_wire_col, true);
- }
- }
-
- glDepthMask(GL_TRUE);
-}
-
-static void draw_wire_extra(
- RegionView3D *rv3d, Object *ob, const bool is_obedit, const unsigned char ob_wire_col[4])
-{
- if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)) {
- unsigned char wire_edit_col[4];
- UI_GetThemeColor4ubv(TH_WIRE_EDIT, wire_edit_col);
-
- ED_view3d_polygon_offset(rv3d, 1.0);
- glDepthMask(GL_FALSE); /* disable write in zbuffer, selected edge wires show better */
- glLineWidth(1.0f);
-
- if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
- if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
-
- if (ob->derivedFinal) {
- drawCurveDMWired(ob);
- }
- else {
- drawDispListwire(&ob->curve_cache->disp, ob->type, is_obedit ? wire_edit_col : ob_wire_col);
- }
- }
- }
- else if (ob->type == OB_MBALL) {
- if (BKE_mball_is_basis(ob)) {
- drawDispListwire(&ob->curve_cache->disp, ob->type, is_obedit ? wire_edit_col : ob_wire_col);
- }
- }
-
- glDepthMask(GL_TRUE);
- ED_view3d_polygon_offset(rv3d, 0.0);
- }
-}
-
-/* should be called in view space */
-static void draw_hooks(Object *ob, unsigned int pos)
-{
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Hook) {
- HookModifierData *hmd = (HookModifierData *) md;
- float vec[3];
-
- mul_v3_m4v3(vec, ob->obmat, hmd->cent);
-
- if (hmd->object) {
- setlinestyle(3);
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(pos, hmd->object->obmat[3]);
- immVertex3fv(pos, vec);
- immEnd();
- setlinestyle(0);
- }
-
- glPointSize(3.0f);
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3fv(pos, vec);
- immEnd();
- }
- }
-}
-
-static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data,
- const short dflag, const unsigned char ob_wire_col[4])
-{
- const char *axis_str[3] = {"px", "py", "pz"};
- float mat[4][4];
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- if (ob_wire_col) immUniformColor3ubv(ob_wire_col);
-
- eul_to_mat4(mat, &data->axX);
- glLineWidth(4.0f);
- setlinestyle(2);
-
- immBegin(GWN_PRIM_LINES, 6);
- for (int axis = 0; axis < 3; axis++) {
- float dir[3] = {0, 0, 0};
- float v[3];
-
- copy_v3_v3(v, &data->pivX);
-
- dir[axis] = 1.0f;
- mul_m4_v3(mat, dir);
- add_v3_v3(v, dir);
- immVertex3fv(pos, &data->pivX);
- immVertex3fv(pos, v);
-
- /* when const color is set wirecolor is NULL - we could get the current color but
- * with selection and group instancing its not needed to draw the text */
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- view3d_cached_text_draw_add(v, axis_str[axis], 2, 0, V3D_CACHE_TEXT_ASCII, ob_wire_col);
- }
- }
- immEnd();
-
- setlinestyle(0);
- glLineWidth(1.0f);
-
- immUnbindProgram();
-}
-
-void draw_object_wire_color(ViewLayer *view_layer, Base *base, unsigned char r_ob_wire_col[4])
-{
- Object *ob = base->object;
- int colindex = 0;
- const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
- /* confusing logic here, there are 2 methods of setting the color
- * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
- *
- * note: no theme yet for 'colindex' */
- int theme_id = is_edit ? TH_WIRE_EDIT : TH_WIRE;
- int theme_shade = 0;
-
- if (((ob->mode & OB_MODE_EDIT) == 0) &&
- (G.moving & G_TRANSFORM_OBJ) &&
- ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)))
- {
- theme_id = TH_TRANSFORM;
- }
- else {
- /* Sets the 'colindex' */
- if (ID_IS_LINKED(ob)) {
- colindex = ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)) ? 2 : 1;
- }
- /* Sets the 'theme_id' or fallback to wire */
- else {
- if ((ob->flag & OB_FROMGROUP) != 0) {
- if ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)) {
- /* uses darker active color for non-active + selected */
- theme_id = TH_GROUP_ACTIVE;
-
- if (view_layer->basact != base) {
- theme_shade = -32;
- }
- }
- else {
- theme_id = TH_GROUP;
- }
- }
- else {
- if ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)) {
- theme_id = view_layer->basact == base ? TH_ACTIVE : TH_SELECT;
- }
- else {
- if (ob->type == OB_LAMP) theme_id = TH_LAMP;
- else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER;
- else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA;
- else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY;
- /* fallback to TH_WIRE */
- }
- }
- }
- }
-
- /* finally set the color */
- if (colindex == 0) {
- if (theme_shade == 0) UI_GetThemeColor3ubv(theme_id, r_ob_wire_col);
- else UI_GetThemeColorShade3ubv(theme_id, theme_shade, r_ob_wire_col);
- }
- else {
- cpack_cpy_3ub(r_ob_wire_col, colortab[colindex]);
- }
-
- /* no reason to use this but some functions take col[4] */
- r_ob_wire_col[3] = 255;
-}
-
-static void draw_object_matcap_check(View3D *v3d, Object *ob)
-{
- /* fixed rule, active object draws as matcap */
- BLI_assert((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0);
- (void)ob;
-
- if (v3d->defmaterial == NULL) {
- extern Material defmaterial;
-
- v3d->defmaterial = MEM_mallocN(sizeof(Material), "matcap material");
- *(v3d->defmaterial) = defmaterial;
- BLI_listbase_clear(&v3d->defmaterial->gpumaterial);
- v3d->defmaterial->preview = NULL;
- }
- /* first time users */
- if (v3d->matcap_icon < ICON_MATCAP_01 ||
- v3d->matcap_icon > ICON_MATCAP_24)
- {
- v3d->matcap_icon = ICON_MATCAP_01;
- }
-
- if (v3d->defmaterial->preview == NULL)
- v3d->defmaterial->preview = UI_icon_to_preview(v3d->matcap_icon);
-
- /* signal to all material checks, gets cleared below */
- v3d->flag2 |= V3D_SHOW_SOLID_MATCAP;
-}
-
-void draw_rigidbody_shape(Object *ob, const unsigned char ob_wire_col[4])
-{
- BoundBox *bb = NULL;
- float size[3], vec[8][3];
- unsigned int pos;
-
- if (ob->type == OB_MESH) {
- bb = BKE_mesh_boundbox_get(ob);
- }
-
- if (bb == NULL)
- return;
-
- switch (ob->rigidbody_object->shape) {
- case RB_SHAPE_BOX:
- BKE_boundbox_calc_size_aabb(bb, size);
-
- pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- if (ob_wire_col) immUniformColor3ubv(ob_wire_col);
-
- vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = -size[0];
- vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = +size[0];
- vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = -size[1];
- vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = +size[1];
- vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = -size[2];
- vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = +size[2];
-
- imm_draw_box(vec, false, pos);
- immUnbindProgram();
- break;
- case RB_SHAPE_SPHERE:
- imm_draw_bb(bb, OB_BOUND_SPHERE, true, ob_wire_col);
- break;
- case RB_SHAPE_CONE:
- imm_draw_bb(bb, OB_BOUND_CONE, true, ob_wire_col);
- break;
- case RB_SHAPE_CYLINDER:
- imm_draw_bb(bb, OB_BOUND_CYLINDER, true, ob_wire_col);
- break;
- case RB_SHAPE_CAPSULE:
- imm_draw_bb(bb, OB_BOUND_CAPSULE, true, ob_wire_col);
- break;
- }
-}
-
-/**
- * main object drawing function, draws in selection
- * \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET
- */
-void draw_object(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d,
- Base *base, const short dflag)
-{
- ModifierData *md = NULL;
- Object *ob = base->object;
- Curve *cu;
- RegionView3D *rv3d = ar->regiondata;
- unsigned char _ob_wire_col[4]; /* dont initialize this */
- const unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */
- bool zbufoff = false, is_paint = false, empty_object = false;
- Object *ob_active = OBACT(view_layer);
- const bool is_obact = (ob == ob_active);
- /* this could be moved to a 'dflag'. */
- const bool is_obedit = (is_obact && (ob == OBEDIT_FROM_OBACT(ob_active)));
- const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
- const bool is_picking = (G.f & G_PICKSEL) != 0;
- const bool has_particles = (ob->particlesystem.first != NULL);
- bool skip_object = false; /* Draw particles but not their emitter object. */
- SmokeModifierData *smd = NULL;
-
- if (is_obedit == false) {
- if (ob->restrictflag & OB_RESTRICT_VIEW)
- return;
-
- if (render_override) {
- if (ob->restrictflag & OB_RESTRICT_RENDER)
- return;
-
- if (!has_particles && (ob->transflag & (OB_DUPLI & ~OB_DUPLIFRAMES)))
- return;
- }
- }
-
- if (has_particles) {
- /* XXX particles are not safe for simultaneous threaded render */
- if (G.is_rendering) {
- return;
- }
-
- if (ob->mode == OB_MODE_OBJECT) {
- ParticleSystem *psys;
-
- 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) {
- skip_object = false;
- break;
- }
- }
- }
- }
-
- if (((base->flag_legacy & OB_FROMDUPLI) == 0) &&
- (md = modifiers_findByType(ob, eModifierType_Smoke)) &&
- (modifier_isEnabled(scene, md, eModifierMode_Realtime)))
- {
- smd = (SmokeModifierData *)md;
-
- if (smd->domain) {
- if (!v3d->transp && (dflag & DRAW_PICKING) == 0) {
- if (!v3d->xray && !(ob->dtx & OB_DRAWXRAY)) {
- /* object has already been drawn so skip drawing it */
- ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
- return;
- }
- else if (v3d->xray) {
- /* object has already been drawn so skip drawing it */
- ED_view3d_after_add(&v3d->afterdraw_xraytransp, base, dflag);
- return;
- }
- }
- }
- }
-
-
- /* xray delay? */
- if ((dflag & DRAW_PICKING) == 0 && (base->flag_legacy & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
- /* don't do xray in particle mode, need the z-buffer */
- if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
- /* xray and transp are set when it is drawing the 2nd/3rd pass */
- if (!v3d->xray && !v3d->transp && (ob->dtx & OB_DRAWXRAY) && !(ob->dtx & OB_DRAWTRANSP)) {
- ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
- return;
- }
-
- /* allow transp option for empty images */
- if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
- if (!v3d->xray && !v3d->transp && !(ob->dtx & OB_DRAWXRAY) && (ob->dtx & OB_DRAWTRANSP)) {
- ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
- return;
- }
- }
- }
- }
-
-
- /* -------------------------------------------------------------------- */
- /* no return after this point, otherwise leaks */
-
- /* only once set now, will be removed too, should become a global standard */
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- /* reset here to avoid having to call all over */
- glLineWidth(1.0f);
-
- view3d_cached_text_draw_begin();
-
- /* draw motion paths (in view space) */
- if (ob->mpath && !render_override) {
- bAnimVizSettings *avs = &ob->avs;
-
- /* setup drawing environment for paths */
- draw_motion_paths_init(v3d, ar);
-
- /* draw motion path for object */
- draw_motion_path_instance(scene, ob, NULL, avs, ob->mpath);
-
- /* cleanup after drawing */
- draw_motion_paths_cleanup(v3d);
- }
-
- /* multiply view with object matrix.
- * local viewmat and persmat, to calculate projections */
- ED_view3d_init_mats_rv3d_gl(ob, rv3d);
-
- /* which wire color */
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
-
- ED_view3d_project_base(ar, base);
-
- draw_object_wire_color(view_layer, base, _ob_wire_col);
- ob_wire_col = _ob_wire_col;
-
- //glColor3ubv(ob_wire_col);
- }
-
- /* maximum drawtype */
- char dt = v3d->drawtype;
- if (dt == OB_RENDER) dt = v3d->prev_drawtype;
- dt = MIN2(dt, ob->dt);
- if (v3d->zbuf == 0 && dt > OB_WIRE) dt = OB_WIRE;
- short dtx = 0;
-
-
- /* faceselect exception: also draw solid when (dt == wire), except in editmode */
- if (is_obact) {
- if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
- if (ob->type == OB_MESH) {
- if (dt < OB_SOLID) {
- zbufoff = true;
- dt = OB_SOLID;
- }
-
- if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
- dt = OB_PAINT;
- }
-
- is_paint = true;
- glEnable(GL_DEPTH_TEST);
- }
- }
- }
-
- /* matcap check - only when not painting color */
- if ((v3d->flag2 & V3D_SOLID_MATCAP) &&
- (dt == OB_SOLID) &&
- (is_paint == false && is_picking == false) &&
- ((v3d->flag2 & V3D_RENDER_SHADOW) == 0))
- {
- draw_object_matcap_check(v3d, ob);
- }
-
- /* draw-extra supported for boundbox drawmode too */
- if (dt >= OB_BOUNDBOX) {
- dtx = ob->dtx;
- if (ob->mode & OB_MODE_EDIT) {
- /* the only 2 extra drawtypes alowed in editmode */
- dtx = dtx & (OB_DRAWWIRE | OB_TEXSPACE);
- }
- }
-
- if (!skip_object) {
- /* 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) && (base->flag & BASE_SELECTED) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
- draw_object_selected_outline(eval_ctx, scene, view_layer, v3d, ar, base, ob_wire_col);
- }
- }
- }
-
- /* TODO Viewport: draw only for selection */
- if ((dflag & DRAW_PICKING) == 0) {
- if ((dt == OB_BOUNDBOX) || ELEM(ob->type, OB_EMPTY, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
- goto afterdraw;
- }
- }
-
- switch (ob->type) {
- case OB_MESH:
- empty_object = draw_mesh_object(eval_ctx, scene, view_layer, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- /* mesh draws wire itself */
- dtx &= ~OB_DRAWWIRE;
- }
-
- break;
- case OB_FONT:
- cu = ob->data;
- if (cu->editfont) {
- draw_editfont(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
- }
- else if (dt == OB_BOUNDBOX) {
- if ((render_override && v3d->drawtype >= OB_WIRE) == 0) {
-#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(eval_ctx, scene, base->object);
-#endif
- draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
- }
- }
- else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
- empty_object = drawDispList(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
- }
-
- break;
- case OB_CURVE:
- case OB_SURF:
- cu = ob->data;
-
- if (cu->editnurb) {
- ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- draw_editnurb(eval_ctx, scene, view_layer, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
- }
- else if (dt == OB_BOUNDBOX) {
- if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
-#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(eval_ctx, scene, base->object);
-#endif
- draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
- }
- }
- else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
- empty_object = drawDispList(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
- }
- break;
- case OB_MBALL:
- {
- MetaBall *mb = ob->data;
-
- if (mb->editelems)
- drawmball(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
- else if (dt == OB_BOUNDBOX) {
- if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
-#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(eval_ctx, scene, base->object);
-#endif
- draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
- }
- }
- else
- empty_object = drawmball(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col);
- break;
- }
- case OB_EMPTY:
- if (!render_override) {
- if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
- draw_empty_image(ob, dflag, ob_wire_col, v3d->multiview_eye);
- }
- else {
- drawaxes(rv3d->viewmatob, ob->empty_drawsize, ob->empty_drawtype, ob_wire_col);
- }
- }
- break;
- case OB_LAMP:
- if (!render_override) {
- drawlamp(v3d, rv3d, base, dt, dflag, ob_wire_col, is_obact);
- }
- 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);
- }
- break;
- case OB_SPEAKER:
- if (!render_override)
- drawspeaker(ob_wire_col);
- 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(ob, ob->boundtype, ob_wire_col);
- }
- else {
-#ifdef SEQUENCER_DAG_WORKAROUND
- ensure_curve_cache(eval_ctx, scene, ob);
-#endif
- drawlattice(v3d, ob, dflag, ob_wire_col);
- }
- }
- 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(ob, ob->boundtype, ob_wire_col);
- }
- else {
- unsigned char arm_col[4];
- glLineWidth(1.0f);
-
- if (ob_wire_col == NULL) {
- float fcol[4] = {0.0f, 0.0f, 0.0f, 1.0f};
- rgba_float_to_uchar(arm_col, fcol);
- }
- else
- copy_v4_v4_uchar(arm_col, ob_wire_col);
-
- empty_object = draw_armature(eval_ctx, scene, view_layer, v3d, ar, base, dt, dflag, arm_col, false);
- }
- }
- break;
- default:
- if (!render_override) {
- drawaxes(rv3d->viewmatob, 1.0, OB_ARROWS, ob_wire_col);
- }
- break;
- }
-
- /* TODO Viewport: some elements are being drawn for object selection only */
-afterdraw:
-
- 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) {
-
- gpuLoadMatrix(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);
- gpuMultMatrix(ob->obmat);
- }
- }
- }
-
- if (ob->pd && ob->pd->forcefield) {
- draw_forcefield(ob, rv3d, dflag, ob_wire_col);
- }
- }
- }
-
- /* code for new particle system */
- if ((ob->particlesystem.first) &&
- (is_obedit == false))
- {
- ParticleSystem *psys;
-
- //glDepthMask(GL_FALSE);
-
- gpuLoadMatrix(rv3d->viewmat);
-
- view3d_cached_text_draw_begin();
-
- for (psys = ob->particlesystem.first; psys; psys = psys->next) {
- /* run this so that possible child particles get cached */
- if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
- PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob);
- if (edit && edit->psys == psys)
- draw_update_ptcache_edit(eval_ctx, scene, ob, edit);
- }
-
- draw_new_particle_system(eval_ctx, scene, v3d, rv3d, base, psys, dt, dflag);
- }
- invert_m4_m4(ob->imat, ob->obmat);
- view3d_cached_text_draw_end(v3d, ar, 0);
-
- gpuMultMatrix(ob->obmat);
-
- //glDepthMask(GL_TRUE);
- }
-
- /* draw edit particles last so that they can draw over child particles */
- if ((dflag & DRAW_PICKING) == 0 &&
- (is_obedit == false))
- {
-
- if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
- PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob);
- if (edit) {
- gpuLoadMatrix(rv3d->viewmat);
- draw_update_ptcache_edit(eval_ctx, scene, ob, edit);
- draw_ptcache_edit(scene, v3d, edit);
- gpuMultMatrix(ob->obmat);
- }
- }
- }
-
- /* draw code for smoke, only draw domains */
- if (smd && smd->domain) {
- SmokeDomainSettings *sds = smd->domain;
- const bool show_smoke = (CFRA >= sds->point_cache[0]->startframe);
- float viewnormal[3];
-
- gpuLoadMatrix(rv3d->viewmat);
- gpuMultMatrix(ob->obmat);
-
- if (!render_override) {
- BoundBox bb;
- float p0[3], p1[3];
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- if (ob_wire_col) immUniformColor3ubv(ob_wire_col);
-
- /* draw max domain bounds */
- if ((sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN)) {
- VECSUBFAC(p0, sds->p0, sds->cell_size, sds->adapt_res);
- VECADDFAC(p1, sds->p1, sds->cell_size, sds->adapt_res);
- BKE_boundbox_init_from_minmax(&bb, p0, p1);
- imm_draw_box(bb.vec, false, pos);
- }
-
- /* draw a single voxel to hint the user about the resolution of the fluid */
- copy_v3_v3(p0, sds->p0);
-
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- madd_v3_v3v3fl(p1, p0, sds->cell_size, 1.0f / (sds->amplify + 1));
- }
- else {
- add_v3_v3v3(p1, p0, sds->cell_size);
- }
-
- BKE_boundbox_init_from_minmax(&bb, p0, p1);
- imm_draw_box(bb.vec, false, pos);
-
- immUnbindProgram();
- }
-
- /* don't show smoke before simulation starts, this could be made an option in the future */
- if (sds->fluid && show_smoke) {
- float p0[3], p1[3];
-
- /* get view vector */
- invert_m4_m4(ob->imat, ob->obmat);
- mul_v3_mat3_m4v3(viewnormal, ob->imat, rv3d->viewinv[2]);
- normalize_v3(viewnormal);
-
- /* set dynamic boundaries to draw the volume
- * also scale cube to global space to equalize volume slicing on all axes
- * (it's scaled back before drawing) */
- p0[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_min[0] + sds->obj_shift_f[0]) * fabsf(ob->size[0]);
- p0[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_min[1] + sds->obj_shift_f[1]) * fabsf(ob->size[1]);
- p0[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_min[2] + sds->obj_shift_f[2]) * fabsf(ob->size[2]);
- p1[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_max[0] + sds->obj_shift_f[0]) * fabsf(ob->size[0]);
- p1[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_max[1] + sds->obj_shift_f[1]) * fabsf(ob->size[1]);
- p1[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_max[2] + sds->obj_shift_f[2]) * fabsf(ob->size[2]);
-
- if (!sds->wt || !(sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
- sds->tex = NULL;
- GPU_create_smoke(smd, 0);
- draw_smoke_volume(sds, ob, p0, p1, viewnormal);
- GPU_free_smoke(smd);
- }
- else if (sds->wt && (sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
- sds->tex = NULL;
- GPU_create_smoke(smd, 1);
- draw_smoke_volume(sds, ob, p0, p1, viewnormal);
- GPU_free_smoke(smd);
- }
-
- /* smoke debug render */
- if (!render_override && sds->draw_velocity) {
- draw_smoke_velocity(sds, viewnormal);
- }
- }
- }
-
- if (!render_override) {
- bConstraint *con;
-
- for (con = ob->constraints.first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) {
- bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)con->data;
- if (data->flag & CONSTRAINT_DRAW_PIVOT)
- draw_rigid_body_pivot(data, dflag, ob_wire_col);
- }
- }
-
- if ((ob->gameflag & OB_BOUNDS) && (ob->mode == OB_MODE_OBJECT)) {
- if (ob->boundtype != ob->collision_boundtype || (dtx & OB_DRAWBOUNDOX) == 0) {
- setlinestyle(2);
- draw_bounding_volume(ob, ob->collision_boundtype, ob_wire_col);
- setlinestyle(0);
- }
- }
- if (ob->rigidbody_object) {
- draw_rigidbody_shape(ob, ob_wire_col);
- }
-
- /* draw extra: after normal draw because of makeDispList */
- if (dtx && (G.f & G_RENDER_OGL) == 0) {
-
- if (dtx & OB_AXIS) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- /* prevent random colors being used */
- drawaxes(rv3d->viewmatob, 1.0f, OB_ARROWS, ob_wire_col);
- }
- else {
- drawaxes(rv3d->viewmatob, 1.0f, OB_ARROWS, NULL);
- }
- }
- if (dtx & OB_DRAWBOUNDOX) {
- draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
- }
- if (dtx & OB_TEXSPACE) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- /* prevent random colors being used */
- drawtexspace(ob, ob_wire_col);
- }
- else {
- drawtexspace(ob, NULL);
- }
- }
- if (dtx & OB_DRAWNAME) {
- /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */
- /* but, we also don't draw names for sets or duplicators */
- if (dflag == 0) {
- const float zero[3] = {0, 0, 0};
- view3d_cached_text_draw_add(zero, ob->id.name + 2, strlen(ob->id.name + 2), 10, 0, ob_wire_col);
- }
- }
- if ((dtx & OB_DRAWWIRE) && dt >= OB_SOLID) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- draw_wire_extra(rv3d, ob, is_obedit, ob_wire_col);
- }
- }
- }
- }
-
- if ((dt <= OB_SOLID) && !render_override) {
- if (((ob->gameflag & OB_DYNAMIC) &&
- ((ob->gameflag & OB_BOUNDS) == 0)) ||
-
- ((ob->gameflag & OB_BOUNDS) &&
- (ob->collision_boundtype == OB_BOUND_SPHERE)))
- {
- float imat[4][4], vec[3] = {0.0f, 0.0f, 0.0f};
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- invert_m4_m4(imat, rv3d->viewmatob);
-
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- /* prevent random colors being used */
- immUniformColor3ubv(ob_wire_col);
- }
-
- setlinestyle(2);
- imm_drawcircball(vec, ob->inertia, imat, pos);
- setlinestyle(0);
-
- immUnbindProgram();
- }
- }
-
- /* return warning, this is cached text draw */
- invert_m4_m4(ob->imat, ob->obmat);
- view3d_cached_text_draw_end(v3d, ar, 1);
- /* return warning, clear temp flag */
- v3d->flag2 &= ~V3D_SHOW_SOLID_MATCAP;
-
- gpuLoadMatrix(rv3d->viewmat);
-
- if (zbufoff) {
- glDisable(GL_DEPTH_TEST);
- }
-
- if ((base->flag_legacy & OB_FROMDUPLI) || render_override) {
- ED_view3d_clear_mats_rv3d(rv3d);
- return;
- }
-
- /* object centers, need to be drawn in viewmat space for speed, but OK for picking select */
- if (!is_obact || !(ob->mode & OB_MODE_ALL_PAINT)) {
- int do_draw_center = -1; /* defines below are zero or positive... */
-
- if (render_override) {
- /* don't draw */
- }
- else if (is_obact)
- do_draw_center = ACTIVE;
- else if (base->flag & BASE_SELECTED)
- do_draw_center = SELECT;
- else if (empty_object || (v3d->flag & V3D_DRAW_CENTERS))
- do_draw_center = DESELECT;
-
- if (do_draw_center != -1) {
- if (dflag & DRAW_PICKING) {
- /* draw a single point for opengl selection */
- if ((base->sx != IS_CLIPPED) &&
- (U.obcenter_dia != 0.0))
- {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR);
- /* TODO: short term, use DEPTH_ONLY shader or set appropriate color */
- /* TODO: long term, solve picking & selection problem better */
- glPointSize(U.obcenter_dia);
- immBegin(GWN_PRIM_POINTS, 1);
- immVertex3fv(pos, ob->obmat[3]);
- immEnd();
- immUnbindProgram();
- }
- }
- else if ((dflag & DRAW_CONSTCOLOR) == 0) {
- /* we don't draw centers for duplicators and sets */
- if ((base->sx != IS_CLIPPED) &&
- (U.obcenter_dia != 0.0) &&
- !(G.f & G_RENDER_OGL))
- {
- /* check > 0 otherwise grease pencil can draw into the circle select which is annoying. */
- drawcentercircle(v3d, rv3d, ob->obmat[3], do_draw_center, ID_IS_LINKED(ob) || ob->id.us > 1);
- }
- }
- }
- }
-
- /* not for sets, duplicators or picking */
- if (dflag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && !render_override) {
- ListBase *list;
- RigidBodyCon *rbc = ob->rigidbody_constraint;
-
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor3ubv(ob_wire_col);
-
- /* draw hook center and offset line */
- if (is_obedit == false)
- draw_hooks(ob, pos);
-
- /* help lines and so */
- if ((is_obedit == false) && ob->parent) {
- const eObjectVisibilityCheck mode = eval_ctx->mode != DAG_EVAL_VIEWPORT ?
- OB_VISIBILITY_CHECK_FOR_RENDER :
- OB_VISIBILITY_CHECK_FOR_VIEWPORT;
- if (BKE_object_is_visible(ob->parent, mode)) {
- setlinestyle(3);
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(pos, ob->obmat[3]);
- immVertex3fv(pos, ob->orig);
- immEnd();
- setlinestyle(0);
- }
- }
-
- /* Drawing the constraint lines */
- if (ob->constraints.first) {
- bConstraint *curcon;
- bConstraintOb *cob;
- unsigned char col1[4], col2[4];
-
- list = &ob->constraints;
-
- UI_GetThemeColor3ubv(TH_GRID, col1);
- UI_make_axis_color(col1, col2, 'Z');
- immUniformColor3ubv(col2);
-
- cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
-
- for (curcon = list->first; curcon; curcon = curcon->next) {
- if (ELEM(curcon->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_OBJECTSOLVER)) {
- /* special case for object solver and follow track constraints because they don't fill
- * constraint targets properly (design limitation -- scene is needed for their target
- * but it can't be accessed from get_targets callback) */
-
- Object *camob = NULL;
-
- if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
- bFollowTrackConstraint *data = (bFollowTrackConstraint *)curcon->data;
-
- camob = data->camera ? data->camera : scene->camera;
- }
- else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
- bObjectSolverConstraint *data = (bObjectSolverConstraint *)curcon->data;
-
- camob = data->camera ? data->camera : scene->camera;
- }
-
- if (camob) {
- setlinestyle(3);
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(pos, camob->obmat[3]);
- immVertex3fv(pos, ob->obmat[3]);
- immEnd();
- setlinestyle(0);
- }
- }
- else {
- const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
-
- if ((cti && cti->get_constraint_targets) && (curcon->flag & CONSTRAINT_EXPAND)) {
- ListBase targets = {NULL, NULL};
- bConstraintTarget *ct;
-
- cti->get_constraint_targets(curcon, &targets);
-
- for (ct = targets.first; ct; ct = ct->next) {
- /* calculate target's matrix */
- if (cti->get_target_matrix)
- cti->get_target_matrix(eval_ctx, curcon, cob, ct, BKE_scene_frame_get(scene));
- else
- unit_m4(ct->matrix);
-
- setlinestyle(3);
- immBegin(GWN_PRIM_LINES, 2);
- immVertex3fv(pos, ct->matrix[3]);
- immVertex3fv(pos, ob->obmat[3]);
- immEnd();
- setlinestyle(0);
- }
-
- if (cti->flush_constraint_targets)
- cti->flush_constraint_targets(curcon, &targets, 1);
- }
- }
- }
-
- BKE_constraints_clear_evalob(cob);
- }
- /* draw rigid body constraint lines */
- if (rbc && (rbc->ob1 || rbc->ob2)) {
- immUniformThemeColor(TH_WIRE);
-
- setlinestyle(3);
- immBegin(GWN_PRIM_LINES, ((int)((bool)rbc->ob1) + (int)((bool)rbc->ob2)) * 2);
- if (rbc->ob1) {
- immVertex3fv(pos, ob->obmat[3]);
- immVertex3fv(pos, rbc->ob1->obmat[3]);
- }
- if (rbc->ob2) {
- immVertex3fv(pos, ob->obmat[3]);
- immVertex3fv(pos, rbc->ob2->obmat[3]);
- }
- immEnd();
- setlinestyle(0);
- }
-
- immUnbindProgram();
- }
-
- ED_view3d_clear_mats_rv3d(rv3d);
-}
-
-
-/**
- * Drawing for selection picking,
- * caller must have called 'GPU_select_load_id(base->selcode)' first.
- */
-void draw_object_select(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d,
- Base *base, const short dflag)
-{
- BLI_assert(dflag & DRAW_PICKING && dflag & DRAW_CONSTCOLOR);
- draw_object(eval_ctx, scene, view_layer, ar, v3d, base, dflag);
-
- /* we draw duplicators for selection too */
- if ((base->object->transflag & OB_DUPLI)) {
- ListBase *lb;
- DupliObject *dob;
- Base tbase;
-
- tbase.flag_legacy = OB_FROMDUPLI;
- lb = object_duplilist(eval_ctx, scene, base->object);
-
- for (dob = lb->first; dob; dob = dob->next) {
- float omat[4][4];
-
- tbase.object = dob->ob;
- copy_m4_m4(omat, dob->ob->obmat);
- copy_m4_m4(dob->ob->obmat, dob->mat);
-
- /* extra service: draw the duplicator in drawtype of parent */
- /* MIN2 for the drawtype to allow bounding box objects in groups for lods */
- char dt = tbase.object->dt; tbase.object->dt = MIN2(tbase.object->dt, base->object->dt);
- short dtx = tbase.object->dtx; tbase.object->dtx = base->object->dtx;
-
- draw_object(eval_ctx, scene, view_layer, ar, v3d, &tbase, dflag);
-
- tbase.object->dt = dt;
- tbase.object->dtx = dtx;
-
- copy_m4_m4(dob->ob->obmat, omat);
- }
- free_object_duplilist(lb);
- }
-}
-
/* ***************** BACKBUF SEL (BBS) ********* */
#ifdef USE_MESH_DM_SELECT
@@ -9659,24 +536,6 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
}
}
-static DMDrawOption bbs_mesh_solid__setDrawOpts(void *UNUSED(userData), int index)
-{
- GPU_select_index_set(index + 1);
- return DM_DRAW_OPTION_NORMAL;
-}
-
-static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index)
-{
- Mesh *me = userData;
-
- if (!(me->mpoly[index].flag & ME_HIDE)) {
- return DM_DRAW_OPTION_NORMAL;
- }
- else {
- return DM_DRAW_OPTION_SKIP;
- }
-}
-
#ifdef USE_MESH_DM_SELECT
/* must have called GPU_framebuffer_index_set beforehand */
static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index)
@@ -9691,10 +550,10 @@ static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index)
}
}
-static void bbs_mesh_solid_verts(const EvaluationContext *eval_ctx, Scene *scene, Object *ob)
+static void bbs_mesh_solid_verts(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
Mesh *me = ob->data;
- DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask);
+ DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, scene->customdata_mask);
DM_update_materials(dm, ob);
@@ -9711,7 +570,7 @@ static void bbs_mesh_solid_verts(const EvaluationContext *eval_ctx, Scene *scene
dm->release(dm);
}
#else
-static void bbs_mesh_solid_verts(const EvaluationContext *UNUSED(eval_ctx), Scene *UNUSED(scene), Object *ob)
+static void bbs_mesh_solid_verts(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(scene), Object *ob)
{
Mesh *me = ob->data;
@@ -9736,10 +595,9 @@ static void bbs_mesh_solid_verts(const EvaluationContext *UNUSED(eval_ctx), Scen
}
#endif
-static void bbs_mesh_solid_faces(Scene *scene, Object *ob)
+static void bbs_mesh_solid_faces(Scene *UNUSED(scene), Object *ob)
{
Mesh *me = ob->data;
- UNUSED_VARS(scene, bbs_mesh_solid_hide__setDrawOpts, bbs_mesh_solid__setDrawOpts);
Gwn_Batch *batch;
if ((me->editflag & ME_EDIT_PAINT_FACE_SEL)) {
batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1);
@@ -9752,7 +610,7 @@ static void bbs_mesh_solid_faces(Scene *scene, Object *ob)
}
void draw_object_backbufsel(
- const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
+ Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
{
ToolSettings *ts = scene->toolsettings;
@@ -9767,7 +625,7 @@ void draw_object_backbufsel(
Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
- DerivedMesh *dm = editbmesh_get_derived_cage(eval_ctx, scene, ob, em, CD_MASK_BAREMESH);
+ DerivedMesh *dm = editbmesh_get_derived_cage(depsgraph, scene, ob, em, CD_MASK_BAREMESH);
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
@@ -9811,7 +669,7 @@ void draw_object_backbufsel(
/* currently vertex select supports weight paint and vertex paint*/
((ob->mode & OB_MODE_WEIGHT_PAINT) || (ob->mode & OB_MODE_VERTEX_PAINT)))
{
- bbs_mesh_solid_verts(eval_ctx, scene, ob);
+ bbs_mesh_solid_verts(depsgraph, scene, ob);
}
else {
bbs_mesh_solid_faces(scene, ob);
@@ -9827,83 +685,8 @@ void draw_object_backbufsel(
}
-/* ************* draw object instances for bones, for example ****************** */
-/* assumes all matrices/etc set OK */
-
-/* helper function for drawing object instances - meshes */
-static void draw_object_mesh_instance(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d,
- Object *ob, const short dt, int outline, const unsigned char ob_wire_col[4])
-{
- Mesh *me = ob->data;
- DerivedMesh *dm = NULL, *edm = NULL;
-
- if (ob->mode & OB_MODE_EDIT) {
- edm = editbmesh_get_derived_base(ob, me->edit_btmesh, CD_MASK_BAREMESH);
- DM_update_materials(edm, ob);
- }
- else {
- dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
- DM_update_materials(dm, ob);
- }
-
- if (dt <= OB_WIRE) {
- glColor4ubv(ob_wire_col);
- if (dm)
- dm->drawEdges(dm, 1, 0);
- else if (edm)
- edm->drawEdges(edm, 1, 0);
- }
- else {
- if (outline)
- draw_mesh_object_outline(v3d, ob, dm ? dm : edm, ob_wire_col);
-
- if (dm) {
- bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt);
- GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL);
- }
-
- glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
-
- if (dm) {
- dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
- GPU_end_object_materials();
- }
- else if (edm)
- edm->drawMappedFaces(edm, NULL, GPU_object_material_bind, NULL, NULL, DM_DRAW_NEED_NORMALS);
-
- GPU_object_material_unbind();
- }
-
- if (edm) edm->release(edm);
- if (dm) dm->release(dm);
-}
-
-void draw_object_instance(const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Object *ob, const char dt, int outline, const float wire_col[4])
-{
- if (ob == NULL)
- return;
-
- unsigned char bcol[4];
- rgba_float_to_uchar(bcol, wire_col);
-
- switch (ob->type) {
- case OB_MESH:
- draw_object_mesh_instance(eval_ctx, scene, view_layer, v3d, rv3d, ob, dt, outline, bcol);
- break;
- case OB_EMPTY:
- if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
- draw_empty_image(ob, 0, bcol, v3d->multiview_eye);
- }
- else {
- drawaxes(rv3d->viewmatob, ob->empty_drawsize, ob->empty_drawtype, bcol);
- }
- break;
- }
-}
-
void ED_draw_object_facemap(
- const EvaluationContext *eval_ctx, Scene *scene, Object *ob, const float col[4], const int facemap)
+ Depsgraph *depsgraph, Scene *scene, Object *ob, const float col[4], const int facemap)
{
DerivedMesh *dm = NULL;
@@ -9916,7 +699,7 @@ void ED_draw_object_facemap(
return;
}
- dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
if (!dm || !CustomData_has_layer(&dm->polyData, CD_FACEMAP))
return;
diff --git a/source/blender/editors/space_view3d/drawsimdebug.c b/source/blender/editors/space_view3d/drawsimdebug.c
deleted file mode 100644
index 14708ca67bc..00000000000
--- a/source/blender/editors/space_view3d/drawsimdebug.c
+++ /dev/null
@@ -1,209 +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) 2014 by the Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Lukas Toenne
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_view3d/drawsimdebug.c
- * \ingroup spview3d
- */
-
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_object_types.h"
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-
-#include "BKE_effect.h"
-
-#include "GPU_immediate.h"
-#include "GPU_matrix.h"
-
-#include "view3d_intern.h"
-
-
-static void draw_sim_debug_elements(SimDebugData *debug_data, float imat[4][4])
-{
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- /* count element types */
- GHashIterator iter;
- int num_dots = 0;
- int num_circles = 0;
- int num_lines = 0;
- int num_vectors = 0;
- for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) {
- SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
- switch (elem->type) {
- case SIM_DEBUG_ELEM_DOT: ++num_dots; break;
- case SIM_DEBUG_ELEM_CIRCLE: ++num_circles; break;
- case SIM_DEBUG_ELEM_LINE: ++num_lines; break;
- case SIM_DEBUG_ELEM_VECTOR: ++num_vectors; break;
- }
- }
-
- /**** dots ****/
-
- glPointSize(3.0f);
- immBegin(GWN_PRIM_POINTS, num_dots);
- for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) {
- SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
- if (elem->type != SIM_DEBUG_ELEM_DOT)
- continue;
-
- immAttrib3fv(color, elem->color);
- immVertex3fv(pos, elem->v1);
- }
- immEnd();
-
- /**** circles ****/
-
- {
-#define CIRCLERES 16
- float circle[CIRCLERES][2] = {
- {0.000000, 1.000000}, {0.382683, 0.923880}, {0.707107, 0.707107}, {0.923880, 0.382683},
- {1.000000, -0.000000}, {0.923880, -0.382683}, {0.707107, -0.707107}, {0.382683, -0.923880},
- {-0.000000, -1.000000}, {-0.382683, -0.923880}, {-0.707107, -0.707107}, {-0.923879, -0.382684},
- {-1.000000, 0.000000}, {-0.923879, 0.382684}, {-0.707107, 0.707107}, {-0.382683, 0.923880} };
-
- immBegin(GWN_PRIM_LINES, num_circles * CIRCLERES * 2);
-
- for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) {
- SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
- float radius = elem->v2[0];
- float co[3], nco[3];
- int i;
-
- if (elem->type != SIM_DEBUG_ELEM_CIRCLE)
- continue;
-
- immAttrib3fv(color, elem->color);
- zero_v3(co);
- for (i = 0; i <= CIRCLERES; ++i) {
- int ni = i % CIRCLERES;
- nco[0] = radius * circle[ni][0];
- nco[1] = radius * circle[ni][1];
- nco[2] = 0.0f;
- mul_mat3_m4_v3(imat, nco);
- add_v3_v3(nco, elem->v1);
-
- if (i > 0) {
- immVertex3fv(pos, co);
- immVertex3fv(pos, nco);
- }
-
- copy_v3_v3(co, nco);
- }
- }
-
- immEnd();
-#undef CIRCLERES
- }
-
- /**** lines ****/
-
- immBegin(GWN_PRIM_LINES, num_lines * 2);
- for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) {
- SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
- if (elem->type != SIM_DEBUG_ELEM_LINE)
- continue;
-
- immAttrib3fv(color, elem->color);
- immVertex3fv(pos, elem->v1);
- immVertex3fv(pos, elem->v2);
- }
- immEnd();
-
- /**** vectors ****/
-
- glPointSize(2.0f);
- immBegin(GWN_PRIM_POINTS, num_vectors);
- for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) {
- SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
- if (elem->type != SIM_DEBUG_ELEM_VECTOR)
- continue;
-
- immAttrib3fv(color, elem->color);
- immVertex3fv(pos, elem->v1);
- }
- immEnd();
-
- immBegin(GWN_PRIM_LINES, num_vectors * 2);
- for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) {
- SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
- float t[3];
- if (elem->type != SIM_DEBUG_ELEM_VECTOR)
- continue;
-
- immAttrib3fv(color, elem->color);
- immVertex3fv(pos, elem->v1);
- add_v3_v3v3(t, elem->v1, elem->v2);
- immVertex3fv(pos, t);
- }
- immEnd();
-
- immUnbindProgram();
-
- /**** strings ****/
-
- for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) {
- SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
- if (elem->type != SIM_DEBUG_ELEM_STRING)
- continue;
-
- unsigned char col[4];
- rgb_float_to_uchar(col, elem->color);
- col[3] = 255;
- view3d_cached_text_draw_add(elem->v1, elem->str, strlen(elem->str),
- 0, V3D_CACHE_TEXT_GLOBALSPACE, col);
- }
-}
-
-void draw_sim_debug_data(Scene *UNUSED(scene), View3D *v3d, ARegion *ar)
-{
- RegionView3D *rv3d = ar->regiondata;
- /*Object *ob = base->object;*/
- float imat[4][4];
-
- if (!_sim_debug_data)
- return;
-
- invert_m4_m4(imat, rv3d->viewmatob);
-
- gpuPushMatrix();
- gpuLoadMatrix(rv3d->viewmat);
-
- view3d_cached_text_draw_begin();
- draw_sim_debug_elements(_sim_debug_data, imat);
- view3d_cached_text_draw_end(v3d, ar, false);
-
- gpuPopMatrix();
-}
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 74087e6f27b..0894e015cc5 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -113,18 +113,30 @@ ARegion *view3d_has_buttons_region(ScrArea *sa)
ARegion *view3d_has_tools_region(ScrArea *sa)
{
- ARegion *ar, *artool = NULL, *arprops = NULL, *arhead;
-
+ ARegion *ar, *artool = NULL, *arhead;
+#ifndef WITH_REDO_REGION_REMOVAL
+ ARegion *arprops = NULL;
+#endif
+
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_TOOLS)
artool = ar;
+#ifndef WITH_REDO_REGION_REMOVAL
if (ar->regiontype == RGN_TYPE_TOOL_PROPS)
arprops = ar;
+#endif
}
-
+
/* tool region hide/unhide also hides props */
- if (arprops && artool) return artool;
-
+ if (artool
+#ifndef WITH_REDO_REGION_REMOVAL
+ && arprops
+#endif
+ )
+ {
+ return artool;
+ }
+
if (artool == NULL) {
/* add subdiv level; after header */
for (arhead = sa->regionbase.first; arhead; arhead = arhead->next)
@@ -142,15 +154,17 @@ ARegion *view3d_has_tools_region(ScrArea *sa)
artool->flag = RGN_FLAG_HIDDEN;
}
+#ifndef WITH_REDO_REGION_REMOVAL
if (arprops == NULL) {
/* add extra subdivided region for tool properties */
arprops = MEM_callocN(sizeof(ARegion), "tool props for view3d");
-
+
BLI_insertlinkafter(&sa->regionbase, artool, arprops);
arprops->regiontype = RGN_TYPE_TOOL_PROPS;
arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
}
-
+#endif
+
return artool;
}
@@ -290,8 +304,6 @@ void ED_view3d_stop_render_preview(wmWindowManager *wm, ARegion *ar)
BPy_END_ALLOW_THREADS;
#endif
- if (rv3d->render_engine->re)
- RE_Database_Free(rv3d->render_engine->re);
RE_engine_free(rv3d->render_engine);
rv3d->render_engine = NULL;
}
@@ -333,6 +345,7 @@ static SpaceLink *view3d_new(const bContext *C)
v3d->gridlines = 16;
v3d->gridsubdiv = 10;
v3d->drawtype = OB_SOLID;
+ v3d->drawtype_lighting = V3D_LIGHTING_STUDIO;
v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;
@@ -344,9 +357,8 @@ static SpaceLink *view3d_new(const bContext *C)
v3d->far = 1000.0f;
v3d->twflag |= U.manipulator_flag & V3D_MANIPULATOR_DRAW;
- v3d->twtype = V3D_MANIP_TRANSLATE;
v3d->around = V3D_AROUND_CENTER_MEAN;
- v3d->custom_orientation_index = -1;
+ scene->orientation_index_custom = -1;
v3d->bundle_size = 0.2f;
v3d->bundle_drawtype = OB_PLAINAXES;
@@ -371,15 +383,17 @@ static SpaceLink *view3d_new(const bContext *C)
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
ar->flag = RGN_FLAG_HIDDEN;
-
+
+#ifndef WITH_REDO_REGION_REMOVAL
/* tool properties */
ar = MEM_callocN(sizeof(ARegion), "tool properties for view3d");
-
+
BLI_addtail(&v3d->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOL_PROPS;
ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
ar->flag = RGN_FLAG_HIDDEN;
-
+#endif
+
/* buttons/list view */
ar = MEM_callocN(sizeof(ARegion), "buttons for view3d");
@@ -711,7 +725,6 @@ static void view3d_widgets(void)
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(
&(const struct wmManipulatorMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW});
- WM_manipulatorgrouptype_append_and_link(mmap_type, TRANSFORM_WGT_manipulator);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_spot);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_area);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_target);
@@ -721,6 +734,7 @@ static void view3d_widgets(void)
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_empty_image);
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_armature_spline);
+ WM_manipulatorgrouptype_append(TRANSFORM_WGT_manipulator);
WM_manipulatorgrouptype_append(VIEW3D_WGT_xform_cage);
WM_manipulatorgrouptype_append(VIEW3D_WGT_ruler);
@@ -921,6 +935,7 @@ static void view3d_main_region_listener(
ob_data = OBEDIT_FROM_VIEW_LAYER(view_layer)->data;
}
if (ob_data) {
+ BLI_assert(OB_DATA_SUPPORT_ID(GS(ob_data->name)));
/* TODO(sergey): Notifiers shouldn't really be doing DEG tags. */
DEG_id_tag_update(ob_data, DEG_TAG_SELECT_UPDATE);
}
@@ -1062,7 +1077,7 @@ static void view3d_main_region_listener(
static void view3d_main_region_message_subscribe(
const struct bContext *UNUSED(C),
- struct WorkSpace *workspace, struct Scene *scene,
+ struct WorkSpace *UNUSED(workspace), struct Scene *scene,
struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar,
struct wmMsgBus *mbus)
{
@@ -1071,7 +1086,6 @@ static void view3d_main_region_message_subscribe(
* accepting some redundant redraws.
*
* For other space types we might try avoid this, keep the 3D view as an exceptional case! */
- ViewRender *view_render = BKE_viewrender_get(scene, workspace);
wmMsgParams_RNA msg_key_params = {{{0}}};
/* Only subscribe to types. */
@@ -1089,7 +1103,6 @@ static void view3d_main_region_message_subscribe(
&RNA_Object,
&RNA_UnitSettings, /* grid-floor */
- &RNA_ViewRenderSettings,
&RNA_World,
};
@@ -1111,6 +1124,7 @@ static void view3d_main_region_message_subscribe(
/* Subscribe to a handful of other properties. */
RegionView3D *rv3d = ar->regiondata;
+ WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, engine, &msg_sub_value_region_tag_redraw);
WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_x, &msg_sub_value_region_tag_redraw);
WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, resolution_y, &msg_sub_value_region_tag_redraw);
WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, pixel_aspect_x, &msg_sub_value_region_tag_redraw);
@@ -1121,12 +1135,12 @@ static void view3d_main_region_message_subscribe(
/* Each engine could be responsible for its own engine data types.
* For now this is simplest. */
- if (STREQ(view_render->engine_id, RE_engine_id_BLENDER_EEVEE)) {
+ if (STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE)) {
extern StructRNA RNA_ViewLayerEngineSettingsEevee;
WM_msg_subscribe_rna_anon_type(mbus, ViewLayerEngineSettingsEevee, &msg_sub_value_region_tag_redraw);
}
#ifdef WITH_CLAY_ENGINE
- else if (STREQ(view_render->engine_id, RE_engine_id_BLENDER_CLAY)) {
+ else if (STREQ(scene->r.engine, RE_engine_id_BLENDER_CLAY)) {
extern StructRNA RNA_ViewLayerEngineSettingsClay;
WM_msg_subscribe_rna_anon_type(mbus, ViewLayerEngineSettingsClay, &msg_sub_value_region_tag_redraw);
}
@@ -1317,6 +1331,7 @@ static void view3d_tools_region_draw(const bContext *C, ARegion *ar)
ED_region_panels(C, ar, CTX_data_mode_string(C), -1, true);
}
+#ifndef WITH_REDO_REGION_REMOVAL
static void view3d_props_region_listener(
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
@@ -1337,6 +1352,7 @@ static void view3d_props_region_listener(
break;
}
}
+#endif
/* area (not region) level listener */
static void space_view3d_listener(
@@ -1528,6 +1544,7 @@ void ED_spacetype_view3d(void)
view3d_toolshelf_register(art);
#endif
+#ifndef WITH_REDO_REGION_REMOVAL
/* regions: tool properties */
art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tool properties region");
art->regionid = RGN_TYPE_TOOL_PROPS;
@@ -1538,10 +1555,10 @@ void ED_spacetype_view3d(void)
art->init = view3d_tools_region_init;
art->draw = view3d_tools_region_draw;
BLI_addhead(&st->regiontypes, art);
-
+
view3d_tool_props_register(art);
-
-
+#endif
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype view3d header region");
art->regionid = RGN_TYPE_HEADER;
diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c
index 5962f1ed2ff..d0475684262 100644
--- a/source/blender/editors/space_view3d/view3d_camera_control.c
+++ b/source/blender/editors/space_view3d/view3d_camera_control.c
@@ -138,7 +138,7 @@ Object *ED_view3d_cameracontrol_object_get(View3DCameraControl *vctrl)
* the view for first-person style navigation.
*/
struct View3DCameraControl *ED_view3d_cameracontrol_acquire(
- const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d,
+ Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d,
const bool use_parent_root)
{
View3DCameraControl *vctrl;
@@ -178,7 +178,7 @@ struct View3DCameraControl *ED_view3d_cameracontrol_acquire(
/* store the original camera loc and rot */
vctrl->obtfm = BKE_object_tfm_backup(ob_back);
- BKE_object_where_is_calc(eval_ctx, scene, v3d->camera);
+ BKE_object_where_is_calc(depsgraph, scene, v3d->camera);
negate_v3_v3(rv3d->ofs, v3d->camera->obmat[3]);
rv3d->dist = 0.0;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 4a0ee31a2b7..166684e7230 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -98,31 +98,13 @@
/* ******************** general functions ***************** */
-static bool use_depth_doit(View3D *v3d, Object *obedit)
-{
- if (v3d->drawtype > OB_WIRE)
- return true;
-
- /* special case (depth for wire color) */
- if (v3d->drawtype <= OB_WIRE) {
- if (obedit && obedit->type == OB_MESH) {
- Mesh *me = obedit->data;
- if (me->drawflag & ME_DRAWEIGHT) {
- return true;
- }
- }
- }
- return false;
-}
-
/**
* \note keep this synced with #ED_view3d_mats_rv3d_backup/#ED_view3d_mats_rv3d_restore
*/
void ED_view3d_update_viewmat(
- const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar,
+ Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *ar,
float viewmat[4][4], float winmat[4][4], const rcti *rect)
{
- const Depsgraph *depsgraph = eval_ctx->depsgraph;
RegionView3D *rv3d = ar->regiondata;
/* setup window matrices */
@@ -142,7 +124,7 @@ void ED_view3d_update_viewmat(
rect_scale[1] = (float)BLI_rcti_size_y(rect) / (float)ar->winy;
}
/* note: calls BKE_object_where_is_calc for camera... */
- view3d_viewmatrix_set(eval_ctx, scene, v3d, rv3d, rect ? rect_scale : NULL);
+ view3d_viewmatrix_set(depsgraph, scene, v3d, rv3d, rect ? rect_scale : NULL);
}
/* update utility matrices */
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
@@ -154,7 +136,7 @@ void ED_view3d_update_viewmat(
/* store window coordinates scaling/offset */
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
rctf cameraborder;
- ED_view3d_calc_camera_border(scene, eval_ctx->depsgraph, ar, v3d, rv3d, &cameraborder, false);
+ ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &cameraborder, false);
rv3d->viewcamtexcofac[0] = (float)ar->winx / BLI_rctf_size_x(&cameraborder);
rv3d->viewcamtexcofac[1] = (float)ar->winy / BLI_rctf_size_y(&cameraborder);
@@ -189,12 +171,12 @@ void ED_view3d_update_viewmat(
}
static void view3d_main_region_setup_view(
- const EvaluationContext *eval_ctx, Scene *scene,
+ Depsgraph *depsgraph, Scene *scene,
View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4], const rcti *rect)
{
RegionView3D *rv3d = ar->regiondata;
- ED_view3d_update_viewmat(eval_ctx, scene, v3d, ar, viewmat, winmat, rect);
+ ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, viewmat, winmat, rect);
/* set for opengl */
gpuLoadProjectionMatrix(rv3d->winmat);
@@ -245,7 +227,7 @@ static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, Reg
* view3d)main_region_setup_view() code to account for that.
*/
static void view3d_stereo3d_setup(
- const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar, const rcti *rect)
+ Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *ar, const rcti *rect)
{
bool is_left;
const char *names[2] = { STEREO_LEFT_NAME, STEREO_RIGHT_NAME };
@@ -271,7 +253,7 @@ static void view3d_stereo3d_setup(
data->shiftx = BKE_camera_multiview_shift_x(&scene->r, v3d->camera, viewname);
BKE_camera_multiview_view_matrix(&scene->r, v3d->camera, is_left, viewmat);
- view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, NULL, rect);
+ view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, NULL, rect);
data->shiftx = shiftx;
BLI_thread_unlock(LOCK_VIEW3D);
@@ -285,7 +267,7 @@ static void view3d_stereo3d_setup(
v3d->camera = camera;
BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat);
- view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, NULL, rect);
+ view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, NULL, rect);
v3d->camera = view_ob;
BLI_thread_unlock(LOCK_VIEW3D);
@@ -296,24 +278,24 @@ static void view3d_stereo3d_setup(
* Set the correct matrices
*/
void ED_view3d_draw_setup_view(
- wmWindow *win, const EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d,
+ wmWindow *win, Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d,
float viewmat[4][4], float winmat[4][4], const rcti *rect)
{
RegionView3D *rv3d = ar->regiondata;
/* Setup the view matrix. */
if (view3d_stereo3d_active(win, scene, v3d, rv3d)) {
- view3d_stereo3d_setup(eval_ctx, scene, v3d, ar, rect);
+ view3d_stereo3d_setup(depsgraph, scene, v3d, ar, rect);
}
else {
- view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, rect);
+ view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, rect);
}
}
/* ******************** view border ***************** */
static void view3d_camera_border(
- const Scene *scene, const struct Depsgraph *depsgraph,
+ const Scene *scene, struct Depsgraph *depsgraph,
const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d,
rctf *r_viewborder, const bool no_shift, const bool no_zoom)
{
@@ -349,7 +331,7 @@ static void view3d_camera_border(
}
void ED_view3d_calc_camera_border_size(
- const Scene *scene, const Depsgraph *depsgraph,
+ const Scene *scene, Depsgraph *depsgraph,
const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d,
float r_size[2])
{
@@ -361,7 +343,7 @@ void ED_view3d_calc_camera_border_size(
}
void ED_view3d_calc_camera_border(
- const Scene *scene, const Depsgraph *depsgraph,
+ const Scene *scene, Depsgraph *depsgraph,
const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d,
rctf *r_viewborder, const bool no_shift)
{
@@ -444,7 +426,7 @@ static void drawviewborder_triangle(
immEnd();
}
-static void drawviewborder(Scene *scene, const Depsgraph *depsgraph, ARegion *ar, View3D *v3d)
+static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View3D *v3d)
{
float x1, x2, y1, y2;
float x1i, x2i, y1i, y2i;
@@ -709,11 +691,11 @@ static void drawrenderborder(ARegion *ar, View3D *v3d)
}
void ED_view3d_draw_depth(
- const EvaluationContext *eval_ctx, struct Depsgraph *graph,
+ Depsgraph *depsgraph,
ARegion *ar, View3D *v3d, bool alphaoverride)
{
struct bThemeState theme_state;
- Scene *scene = DEG_get_evaluated_scene(graph);
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
RegionView3D *rv3d = ar->regiondata;
short zbuf = v3d->zbuf;
@@ -730,7 +712,7 @@ void ED_view3d_draw_depth(
UI_Theme_Store(&theme_state);
UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
- ED_view3d_draw_setup_view(NULL, eval_ctx, scene, ar, v3d, NULL, NULL, NULL);
+ ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL);
glClear(GL_DEPTH_BUFFER_BIT);
@@ -743,16 +725,7 @@ void ED_view3d_draw_depth(
v3d->zbuf = true;
glEnable(GL_DEPTH_TEST);
-#ifdef WITH_OPENGL_LEGACY
- if (IS_VIEWPORT_LEGACY(vc->v3d)) {
- /* temp, calls into view3d_draw_legacy.c */
- ED_view3d_draw_depth_loop(scene, ar, v3d);
- }
- else
-#endif /* WITH_OPENGL_LEGACY */
- {
- DRW_draw_depth_loop(graph, ar, v3d);
- }
+ DRW_draw_depth_loop(depsgraph, ar, v3d);
if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_disable();
@@ -769,536 +742,8 @@ void ED_view3d_draw_depth(
UI_Theme_Restore(&theme_state);
}
-/* ******************** background plates ***************** */
-
-static void view3d_draw_background_gradient(void)
-{
- /* TODO: finish 2D API & draw background with that */
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
- unsigned char col_hi[3], col_lo[3];
-
- immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
-
- UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo);
- UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi);
-
- immBegin(GWN_PRIM_TRI_FAN, 4);
- immAttrib3ubv(color, col_lo);
- immVertex2f(pos, -1.0f, -1.0f);
- immVertex2f(pos, 1.0f, -1.0f);
-
- immAttrib3ubv(color, col_hi);
- immVertex2f(pos, 1.0f, 1.0f);
- immVertex2f(pos, -1.0f, 1.0f);
- immEnd();
-
- immUnbindProgram();
-}
-
-static void view3d_draw_background_none(void)
-{
- UI_ThemeClearColorAlpha(TH_HIGH_GRAD, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
-}
-
-static void view3d_draw_background_world(Scene *scene, RegionView3D *rv3d)
-{
- if (scene->world) {
- GPUMaterial *gpumat = GPU_material_world(scene, scene->world);
-
- /* calculate full shader for background */
- GPU_material_bind(gpumat, 1, 1, 1.0f, false, rv3d->viewmat, rv3d->viewinv, rv3d->viewcamtexcofac);
-
- if (GPU_material_bound(gpumat)) {
- /* TODO viewport (dfelinto): GPU_material_bind relies on immediate mode,
- * we can't get rid of the following code without a bigger refactor
- * or we dropping this functionality. */
-
- glBegin(GL_TRIANGLE_STRIP);
- glVertex2f(-1.0f, -1.0f);
- glVertex2f(1.0f, -1.0f);
- glVertex2f(-1.0f, 1.0f);
- glVertex2f(1.0f, 1.0f);
- glEnd();
-
- GPU_material_unbind(gpumat);
- return;
- }
- }
-
- /* if any of the above fails */
- view3d_draw_background_none();
-}
-
/* ******************** other elements ***************** */
-
-#define DEBUG_GRID 0
-
-static void gridline_range(double x0, double dx, double max, int *r_first, int *r_count)
-{
- /* determine range of gridlines that appear in this Area -- similar calc but separate ranges for x & y
- * x0 is gridline 0, the axis in screen space
- * Area covers [0 .. max) pixels */
-
- int first = (int)ceil(-x0 / dx);
- int last = (int)floor((max - x0) / dx);
-
- if (first <= last) {
- *r_first = first;
- *r_count = last - first + 1;
- }
- else {
- *r_first = 0;
- *r_count = 0;
- }
-
-#if DEBUG_GRID
- printf(" first %d * dx = %f\n", first, x0 + first * dx);
- printf(" last %d * dx = %f\n", last, x0 + last * dx);
- printf(" count = %d\n", *count_out);
-#endif
-}
-
-static int gridline_count(ARegion *ar, double x0, double y0, double dx)
-{
- /* x0 & y0 establish the "phase" of the grid within this 2D region
- * dx is the frequency, shared by x & y directions
- * pass in dx of smallest (highest precision) grid we want to draw */
-
-#if DEBUG_GRID
- printf(" %s(%f, %f, dx:%f)\n", __FUNCTION__, x0, y0, dx);
-#endif
-
- int first, x_ct, y_ct;
-
- gridline_range(x0, dx, ar->winx, &first, &x_ct);
- gridline_range(y0, dx, ar->winy, &first, &y_ct);
-
- int total_ct = x_ct + y_ct;
-
-#if DEBUG_GRID
- printf(" %d + %d = %d gridlines\n", x_ct, y_ct, total_ct);
-#endif
-
- return total_ct;
-}
-
-static bool drawgrid_draw(ARegion *ar, double x0, double y0, double dx, int skip_mod, unsigned pos, unsigned col, GLubyte col_value[3])
-{
- /* skip every skip_mod lines relative to each axis; they will be overlaid by another drawgrid_draw
- * always skip exact x0 & y0 axes; they will be drawn later in color
- *
- * set grid color once, just before the first line is drawn
- * it's harmless to set same color for every line, or every vertex
- * but if no lines are drawn, color must not be set! */
-
-#if DEBUG_GRID
- printf(" %s(%f, %f, dx:%f, skip_mod:%d)\n", __FUNCTION__, x0, y0, dx, skip_mod);
-#endif
-
- const float x_max = (float)ar->winx;
- const float y_max = (float)ar->winy;
-
- int first, ct;
- int x_ct = 0, y_ct = 0; /* count of lines actually drawn */
- int lines_skipped_for_next_unit = 0;
-
- /* draw vertical lines */
- gridline_range(x0, dx, x_max, &first, &ct);
-
- for (int i = first; i < first + ct; ++i) {
- if (i == 0)
- continue;
- else if (skip_mod && (i % skip_mod) == 0) {
- ++lines_skipped_for_next_unit;
- continue;
- }
-
- if (x_ct == 0)
- immAttrib3ub(col, col_value[0], col_value[1], col_value[2]);
-
- float x = (float)(x0 + i * dx);
- immVertex2f(pos, x, 0.0f);
- immVertex2f(pos, x, y_max);
- ++x_ct;
- }
-
- /* draw horizontal lines */
- gridline_range(y0, dx, y_max, &first, &ct);
-
- for (int i = first; i < first + ct; ++i) {
- if (i == 0)
- continue;
- else if (skip_mod && (i % skip_mod) == 0) {
- ++lines_skipped_for_next_unit;
- continue;
- }
-
- if (x_ct + y_ct == 0)
- immAttrib3ub(col, col_value[0], col_value[1], col_value[2]);
-
- float y = (float)(y0 + i * dx);
- immVertex2f(pos, 0.0f, y);
- immVertex2f(pos, x_max, y);
- ++y_ct;
- }
-
-#if DEBUG_GRID
- int total_ct = x_ct + y_ct;
- printf(" %d + %d = %d gridlines drawn, %d skipped for next unit\n", x_ct, y_ct, total_ct, lines_skipped_for_next_unit);
-#endif
-
- return lines_skipped_for_next_unit > 0;
-}
-
-#define GRID_MIN_PX_D 6.0
-#define GRID_MIN_PX_F 6.0f
-
-static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit)
-{
- RegionView3D *rv3d = ar->regiondata;
-
-#if DEBUG_GRID
- printf("%s width %d, height %d\n", __FUNCTION__, ar->winx, ar->winy);
-#endif
-
- double fx = rv3d->persmat[3][0];
- double fy = rv3d->persmat[3][1];
- double fw = rv3d->persmat[3][3];
-
- const double wx = 0.5 * ar->winx; /* use double precision to avoid rounding errors */
- const double wy = 0.5 * ar->winy;
-
- double x = wx * fx / fw;
- double y = wy * fy / fw;
-
- double vec4[4] = { v3d->grid, v3d->grid, 0.0, 1.0 };
- mul_m4_v4d(rv3d->persmat, vec4);
- fx = vec4[0];
- fy = vec4[1];
- fw = vec4[3];
-
- double dx = fabs(x - wx * fx / fw);
- if (dx == 0) dx = fabs(y - wy * fy / fw);
-
- x += wx;
- y += wy;
-
- /* now x, y, and dx have their final values
- * (x,y) is the world origin (0,0,0) mapped to Area-relative screen space
- * dx is the distance in pixels between grid lines -- same for horiz or vert grid lines */
-
- glLineWidth(1.0f);
-
-#if 0 /* TODO: write to UI/widget depth buffer, not scene depth */
- glDepthMask(GL_FALSE); /* disable write in zbuffer */
-#endif
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
-
- unsigned char col[3], col2[3];
- UI_GetThemeColor3ubv(TH_GRID, col);
-
- if (unit->system) {
- const void *usys;
- int len;
-
- bUnit_GetSystem(unit->system, B_UNIT_LENGTH, &usys, &len);
-
- bool first = true;
-
- if (usys) {
- int i = len;
- while (i--) {
- double scalar = bUnit_GetScaler(usys, i);
-
- double dx_scalar = dx * scalar / (double)unit->scale_length;
- if (dx_scalar < (GRID_MIN_PX_D * 2.0)) {
- /* very very small grid items are less useful when dealing with units */
- continue;
- }
-
- if (first) {
- first = false;
-
- /* Store the smallest drawn grid size units name so users know how big each grid cell is */
- *grid_unit = bUnit_GetNameDisplay(usys, i);
- rv3d->gridview = (float)((scalar * (double)v3d->grid) / (double)unit->scale_length);
-
- int gridline_ct = gridline_count(ar, x, y, dx_scalar);
- if (gridline_ct == 0)
- goto drawgrid_cleanup; /* nothing to draw */
-
- immBegin(GWN_PRIM_LINES, gridline_ct * 2);
- }
-
- float blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar);
- /* tweak to have the fade a bit nicer */
- blend_fac = (blend_fac * blend_fac) * 2.0f;
- CLAMP(blend_fac, 0.3f, 1.0f);
-
- UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, blend_fac, col2);
-
- const int skip_mod = (i == 0) ? 0 : (int)round(bUnit_GetScaler(usys, i - 1) / scalar);
-#if DEBUG_GRID
- printf("%s %f, ", bUnit_GetNameDisplay(usys, i), scalar);
- if (i > 0)
- printf("next unit is %d times larger\n", skip_mod);
- else
- printf("largest unit\n");
-#endif
- if (!drawgrid_draw(ar, x, y, dx_scalar, skip_mod, pos, color, col2))
- break;
- }
- }
- }
- else {
- const double sublines = v3d->gridsubdiv;
- const float sublines_fl = v3d->gridsubdiv;
-
- int grids_to_draw = 2; /* first the faint fine grid, then the bold coarse grid */
-
- if (dx < GRID_MIN_PX_D) {
- rv3d->gridview *= sublines_fl;
- dx *= sublines;
- if (dx < GRID_MIN_PX_D) {
- rv3d->gridview *= sublines_fl;
- dx *= sublines;
- if (dx < GRID_MIN_PX_D) {
- rv3d->gridview *= sublines_fl;
- dx *= sublines;
- grids_to_draw = (dx < GRID_MIN_PX_D) ? 0 : 1;
- }
- }
- }
- else {
- if (dx > (GRID_MIN_PX_D * 10.0)) { /* start blending in */
- rv3d->gridview /= sublines_fl;
- dx /= sublines;
- if (dx > (GRID_MIN_PX_D * 10.0)) { /* start blending in */
- rv3d->gridview /= sublines_fl;
- dx /= sublines;
- if (dx > (GRID_MIN_PX_D * 10.0)) {
- grids_to_draw = 1;
- }
- }
- }
- }
-
- int gridline_ct = gridline_count(ar, x, y, dx);
- if (gridline_ct == 0)
- goto drawgrid_cleanup; /* nothing to draw */
-
- immBegin(GWN_PRIM_LINES, gridline_ct * 2);
-
- if (grids_to_draw == 2) {
- UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2);
- if (drawgrid_draw(ar, x, y, dx, v3d->gridsubdiv, pos, color, col2))
- drawgrid_draw(ar, x, y, dx * sublines, 0, pos, color, col);
- }
- else if (grids_to_draw == 1) {
- drawgrid_draw(ar, x, y, dx, 0, pos, color, col);
- }
- }
-
- /* draw visible axes */
- /* horizontal line */
- if (0 <= y && y < ar->winy) {
- UI_make_axis_color(col, col2, ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT) ? 'Y' : 'X');
- immAttrib3ub(color, col2[0], col2[1], col2[2]);
- immVertex2f(pos, 0.0f, y);
- immVertex2f(pos, (float)ar->winx, y);
- }
-
- /* vertical line */
- if (0 <= x && x < ar->winx) {
- UI_make_axis_color(col, col2, ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM) ? 'Y' : 'Z');
- immAttrib3ub(color, col2[0], col2[1], col2[2]);
- immVertex2f(pos, x, 0.0f);
- immVertex2f(pos, x, (float)ar->winy);
- }
-
- immEnd();
-
-drawgrid_cleanup:
- immUnbindProgram();
-
-#if 0 /* depth write is left enabled above */
- glDepthMask(GL_TRUE); /* enable write in zbuffer */
-#endif
-}
-
-#undef DEBUG_GRID
-#undef GRID_MIN_PX_D
-#undef GRID_MIN_PX_F
-
-static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool write_depth)
-{
- /* draw only if there is something to draw */
- if (v3d->gridflag & (V3D_SHOW_FLOOR | V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) {
- /* draw how many lines?
- * trunc(v3d->gridlines / 2) * 4
- * + 2 for xy axes (possibly with special colors)
- * + 1 for z axis (the only line not in xy plane)
- * even v3d->gridlines are honored, odd rounded down */
- const int gridlines = v3d->gridlines / 2;
- const float grid_scale = ED_view3d_grid_scale(scene, v3d, grid_unit);
- const float grid = gridlines * grid_scale;
-
- const bool show_floor = (v3d->gridflag & V3D_SHOW_FLOOR) && gridlines >= 1;
-
- bool show_axis_x = v3d->gridflag & V3D_SHOW_X;
- bool show_axis_y = v3d->gridflag & V3D_SHOW_Y;
- bool show_axis_z = v3d->gridflag & V3D_SHOW_Z;
-
- unsigned char col_grid[3], col_axis[3];
-
- glLineWidth(1.0f);
-
- UI_GetThemeColor3ubv(TH_GRID, col_grid);
-
- if (!write_depth)
- glDepthMask(GL_FALSE);
-
- if (show_floor) {
- const unsigned vertex_ct = 2 * (gridlines * 4 + 2);
- const int sublines = v3d->gridsubdiv;
-
- unsigned char col_bg[3], col_grid_emphasise[3], col_grid_light[3];
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
-
- immBegin(GWN_PRIM_LINES, vertex_ct);
-
- /* draw normal grid lines */
- UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10);
-
- for (int a = 1; a <= gridlines; a++) {
- /* skip emphasised divider lines */
- if (a % sublines != 0) {
- const float line = a * grid_scale;
-
- immAttrib3ubv(color, col_grid_light);
-
- immVertex2f(pos, -grid, -line);
- immVertex2f(pos, +grid, -line);
- immVertex2f(pos, -grid, +line);
- immVertex2f(pos, +grid, +line);
-
- immVertex2f(pos, -line, -grid);
- immVertex2f(pos, -line, +grid);
- immVertex2f(pos, +line, -grid);
- immVertex2f(pos, +line, +grid);
- }
- }
-
- /* draw emphasised grid lines */
- UI_GetThemeColor3ubv(TH_BACK, col_bg);
- /* emphasise division lines lighter instead of darker, if background is darker than grid */
- UI_GetColorPtrShade3ubv(col_grid, col_grid_emphasise,
- (col_grid[0] + col_grid[1] + col_grid[2] + 30 >
- col_bg[0] + col_bg[1] + col_bg[2]) ? 20 : -10);
-
- if (sublines <= gridlines) {
- immAttrib3ubv(color, col_grid_emphasise);
-
- for (int a = sublines; a <= gridlines; a += sublines) {
- const float line = a * grid_scale;
-
- immVertex2f(pos, -grid, -line);
- immVertex2f(pos, +grid, -line);
- immVertex2f(pos, -grid, +line);
- immVertex2f(pos, +grid, +line);
-
- immVertex2f(pos, -line, -grid);
- immVertex2f(pos, -line, +grid);
- immVertex2f(pos, +line, -grid);
- immVertex2f(pos, +line, +grid);
- }
- }
-
- /* draw X axis */
- if (show_axis_x) {
- show_axis_x = false; /* drawing now, won't need to draw later */
- UI_make_axis_color(col_grid, col_axis, 'X');
- immAttrib3ubv(color, col_axis);
- }
- else
- immAttrib3ubv(color, col_grid_emphasise);
-
- immVertex2f(pos, -grid, 0.0f);
- immVertex2f(pos, +grid, 0.0f);
-
- /* draw Y axis */
- if (show_axis_y) {
- show_axis_y = false; /* drawing now, won't need to draw later */
- UI_make_axis_color(col_grid, col_axis, 'Y');
- immAttrib3ubv(color, col_axis);
- }
- else
- immAttrib3ubv(color, col_grid_emphasise);
-
- immVertex2f(pos, 0.0f, -grid);
- immVertex2f(pos, 0.0f, +grid);
-
- immEnd();
- immUnbindProgram();
-
- /* done with XY plane */
- }
-
- if (show_axis_x || show_axis_y || show_axis_z) {
- /* draw axis lines -- sometimes grid floor is off, other times we still need to draw the Z axis */
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2);
-
- if (show_axis_x) {
- UI_make_axis_color(col_grid, col_axis, 'X');
- immAttrib3ubv(color, col_axis);
- immVertex3f(pos, -grid, 0.0f, 0.0f);
- immVertex3f(pos, +grid, 0.0f, 0.0f);
- }
-
- if (show_axis_y) {
- UI_make_axis_color(col_grid, col_axis, 'Y');
- immAttrib3ubv(color, col_axis);
- immVertex3f(pos, 0.0f, -grid, 0.0f);
- immVertex3f(pos, 0.0f, +grid, 0.0f);
- }
-
- if (show_axis_z) {
- UI_make_axis_color(col_grid, col_axis, 'Z');
- immAttrib3ubv(color, col_axis);
- immVertex3f(pos, 0.0f, 0.0f, -grid);
- immVertex3f(pos, 0.0f, 0.0f, +grid);
- }
-
- immEnd();
- immUnbindProgram();
- }
-
- if (!write_depth)
- glDepthMask(GL_TRUE);
- }
-}
-
/** could move this elsewhere, but tied into #ED_view3d_grid_scale */
float ED_scene_grid_scale(Scene *scene, const char **grid_unit)
{
@@ -1325,102 +770,6 @@ float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit)
return v3d->grid * ED_scene_grid_scale(scene, grid_unit);
}
-static bool is_cursor_visible(Scene *scene, ViewLayer *view_layer)
-{
- if (U.app_flag & USER_APP_VIEW3D_HIDE_CURSOR) {
- return false;
- }
-
- Object *ob = OBACT(view_layer);
-
- /* don't draw cursor in paint modes, but with a few exceptions */
- if (ob && ob->mode & OB_MODE_ALL_PAINT) {
- /* exception: object is in weight paint and has deforming armature in pose mode */
- if (ob->mode & OB_MODE_WEIGHT_PAINT) {
- if (BKE_object_pose_armature_get(ob) != NULL) {
- return true;
- }
- }
- /* exception: object in texture paint mode, clone brush, use_clone_layer disabled */
- else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
- const Paint *p = BKE_paint_get_active(scene, view_layer);
-
- if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
- if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) {
- return true;
- }
- }
- }
-
- /* no exception met? then don't draw cursor! */
- return false;
- }
-
- return true;
-}
-
-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, 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;
-
- glLineWidth(1.0f);
-
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
-
- const int segments = 16;
-
- immBegin(GWN_PRIM_LINE_LOOP, segments);
-
- for (int i = 0; i < segments; ++i) {
- float angle = 2 * M_PI * ((float)i / (float)segments);
- float x = co[0] + f10 * cosf(angle);
- float y = co[1] + f10 * sinf(angle);
-
- if (i % 2 == 0)
- immAttrib3ub(color, 255, 0, 0);
- else
- immAttrib3ub(color, 255, 255, 255);
-
- immVertex2f(pos, x, y);
- }
- immEnd();
-
- immUnbindProgram();
-
- GWN_vertformat_clear(format);
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- unsigned char crosshair_color[3];
- UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color);
- immUniformColor3ubv(crosshair_color);
-
- immBegin(GWN_PRIM_LINES, 8);
- immVertex2f(pos, co[0] - f20, co[1]);
- immVertex2f(pos, co[0] - f5, co[1]);
- immVertex2f(pos, co[0] + f5, co[1]);
- immVertex2f(pos, co[0] + f20, co[1]);
- immVertex2f(pos, co[0], co[1] - f20);
- immVertex2f(pos, co[0], co[1] - f5);
- immVertex2f(pos, co[0], co[1] + f5);
- immVertex2f(pos, co[0], co[1] + f20);
- immEnd();
-
- immUnbindProgram();
- }
-}
-
static void draw_view_axis(RegionView3D *rv3d, const rcti *rect)
{
const float k = U.rvisize * U.pixelsize; /* axis size */
@@ -1888,29 +1237,29 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset)
static void view3d_draw_view(const bContext *C, ARegion *ar)
{
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
- ED_view3d_draw_setup_view(CTX_wm_window(C), &eval_ctx, CTX_data_scene(C), ar, CTX_wm_view3d(C), NULL, NULL, NULL);
+ ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, CTX_wm_view3d(C), NULL, NULL, NULL);
/* Only 100% compliant on new spec goes bellow */
DRW_draw_view(C);
}
+RenderEngineType *ED_view3d_engine_type(Scene *scene, int drawtype)
+{
+ /*
+ * Tempory viewport draw modes until we have a proper system.
+ * all modes are done in the draw manager, except
+ * cycles material as it is an external render engine.
+ */
+ if (strcmp(scene->r.engine, RE_engine_id_CYCLES) == 0 && drawtype == OB_MATERIAL) {
+ return RE_engines_find(RE_engine_id_BLENDER_EEVEE);
+ }
+ return RE_engines_find(scene->r.engine);
+}
+
void view3d_main_region_draw(const bContext *C, ARegion *ar)
{
- Scene *scene = CTX_data_scene(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ar->regiondata;
- ViewRender *view_render = BKE_viewrender_get(scene, workspace);
- RenderEngineType *type = RE_engines_find(view_render->engine_id);
-
- /* Provisory Blender Internal drawing */
- if (type->flag & RE_USE_LEGACY_PIPELINE) {
- view3d_main_region_draw_legacy(C, ar);
- return;
- }
if (!rv3d->viewport) {
rv3d->viewport = GPU_viewport_create();
@@ -1937,7 +1286,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar)
* \{ */
static void view3d_stereo3d_setup_offscreen(
- const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar,
+ Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *ar,
float winmat[4][4], const char *viewname)
{
/* update the viewport matrices with the new camera */
@@ -1946,59 +1295,28 @@ static void view3d_stereo3d_setup_offscreen(
const bool is_left = STREQ(viewname, STEREO_LEFT_NAME);
BKE_camera_multiview_view_matrix(&scene->r, v3d->camera, is_left, viewmat);
- view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
+ view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, NULL);
}
else { /* SCE_VIEWS_FORMAT_MULTIVIEW */
float viewmat[4][4];
Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat);
- view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
+ view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, NULL);
}
}
-void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx,
- Scene *scene,
- ViewLayer *view_layer,
- RenderEngineType *engine_type,
- View3D *v3d)
-{
- if (engine_type->flag & RE_USE_LEGACY_PIPELINE) {
- /* shadow buffers, before we setup matrices */
- if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype)) {
- VP_deprecated_gpu_update_lamps_shadows_world(eval_ctx, scene, v3d);
- }
- }
-}
-
-/*
- * Function to clear the view
- */
-static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar)
-{
- glClear(GL_DEPTH_BUFFER_BIT);
-
- if (scene->world && (v3d->flag3 & V3D_SHOW_WORLD)) {
- VP_view3d_draw_background_world(scene, ar->regiondata);
- }
- else {
- VP_view3d_draw_background_none();
- }
-}
-
-/* ED_view3d_draw_offscreen_init should be called before this to initialize
- * stuff like shadow buffers
- */
void ED_view3d_draw_offscreen(
- const EvaluationContext *eval_ctx, Scene *scene,
- ViewLayer *view_layer, RenderEngineType *engine_type,
+ Depsgraph *depsgraph, Scene *scene,
+ int drawtype,
View3D *v3d, ARegion *ar, int winx, int winy,
float viewmat[4][4], float winmat[4][4],
- bool do_bgpic, bool do_sky, bool UNUSED(is_persp), const char *viewname,
+ bool do_sky, bool UNUSED(is_persp), const char *viewname,
GPUFXSettings *UNUSED(fx_settings),
GPUOffScreen *ofs, GPUViewport *viewport)
{
RegionView3D *rv3d = ar->regiondata;
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, drawtype);
/* set temporary new size */
int bwinx = ar->winx;
@@ -2031,34 +1349,14 @@ void ED_view3d_draw_offscreen(
gpuLoadIdentity();
if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera)
- view3d_stereo3d_setup_offscreen(eval_ctx, scene, v3d, ar, winmat, viewname);
+ view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, ar, winmat, viewname);
else
- view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
-
- Depsgraph *depsgraph = eval_ctx->depsgraph;
+ view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, NULL);
/* main drawing call */
- if (engine_type->flag & RE_USE_LEGACY_PIPELINE) {
- VP_deprecated_view3d_draw_objects(NULL, eval_ctx, scene, v3d, ar, NULL, do_bgpic, true);
-
- if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
- /* draw grease-pencil stuff */
- ED_region_pixelspace(ar);
-
- if (v3d->flag2 & V3D_SHOW_GPENCIL) {
- /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
- ED_gpencil_draw_view3d(NULL, scene, view_layer, depsgraph, v3d, ar, false);
- }
-
- /* freeing the images again here could be done after the operator runs, leaving for now */
- GPU_free_images_anim();
- }
- }
- else {
- DRW_draw_render_loop_offscreen(
- depsgraph, engine_type, ar, v3d,
- do_sky, ofs, viewport);
- }
+ DRW_draw_render_loop_offscreen(
+ depsgraph, engine_type, ar, v3d,
+ do_sky, ofs, viewport);
/* restore size */
ar->winx = bwinx;
@@ -2080,18 +1378,16 @@ void ED_view3d_draw_offscreen(
* (avoids re-creating when doing multiple GL renders).
*/
ImBuf *ED_view3d_draw_offscreen_imbuf(
- const EvaluationContext *eval_ctx, Scene *scene,
- ViewLayer *view_layer, RenderEngineType *engine_type,
+ Depsgraph *depsgraph, Scene *scene,
+ int drawtype,
View3D *v3d, ARegion *ar, int sizex, int sizey,
unsigned int flag, unsigned int draw_flags,
int alpha_mode, int samples, const char *viewname,
/* output vars */
GPUOffScreen *ofs, char err_out[256])
{
- const Depsgraph *depsgraph = eval_ctx->depsgraph;
RegionView3D *rv3d = ar->regiondata;
const bool draw_sky = (alpha_mode == R_ADDSKY);
- const bool draw_background = (draw_flags & V3D_OFSDRAW_USE_BACKGROUND);
const bool use_full_sample = (draw_flags & V3D_OFSDRAW_USE_FULL_SAMPLE);
/* view state */
@@ -2116,8 +1412,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
}
}
- ED_view3d_draw_offscreen_init(eval_ctx, scene, view_layer, engine_type, v3d);
-
GPU_offscreen_bind(ofs, true);
/* read in pixels & stamp */
@@ -2158,9 +1452,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
if ((samples && use_full_sample) == 0) {
/* Single-pass render, common case */
ED_view3d_draw_offscreen(
- eval_ctx, scene, view_layer, engine_type,
+ depsgraph, scene, drawtype,
v3d, ar, sizex, sizey, NULL, winmat,
- draw_background, draw_sky, !is_ortho, viewname,
+ draw_sky, !is_ortho, viewname,
&fx_settings, ofs, NULL);
if (ibuf->rect_float) {
@@ -2183,9 +1477,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
/* first sample buffer, also initializes 'rv3d->persmat' */
ED_view3d_draw_offscreen(
- eval_ctx, scene, view_layer, engine_type,
+ depsgraph, scene, drawtype,
v3d, ar, sizex, sizey, NULL, winmat,
- draw_background, draw_sky, !is_ortho, viewname,
+ draw_sky, !is_ortho, viewname,
&fx_settings, ofs, viewport);
GPU_offscreen_read_pixels(ofs, GL_FLOAT, accum_buffer);
@@ -2198,9 +1492,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
(jit_ofs[j][1] * 2.0f) / sizey);
ED_view3d_draw_offscreen(
- eval_ctx, scene, view_layer, engine_type,
+ depsgraph, scene, drawtype,
v3d, ar, sizex, sizey, NULL, winmat_jitter,
- draw_background, draw_sky, !is_ortho, viewname,
+ draw_sky, !is_ortho, viewname,
&fx_settings, ofs, viewport);
GPU_offscreen_read_pixels(ofs, GL_FLOAT, rect_temp);
@@ -2262,10 +1556,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
* \note used by the sequencer
*/
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
- const EvaluationContext *eval_ctx, Scene *scene,
- ViewLayer *view_layer, RenderEngineType *engine_type,
+ Depsgraph *depsgraph, Scene *scene,
+ int drawtype,
Object *camera, int width, int height,
- unsigned int flag, unsigned int draw_flags, int drawtype,
+ unsigned int flag, unsigned int draw_flags,
int alpha_mode, int samples, const char *viewname,
GPUOffScreen *ofs, char err_out[256])
{
@@ -2289,9 +1583,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
if (draw_flags & V3D_OFSDRAW_USE_SOLID_TEX) {
v3d.flag2 |= V3D_SOLID_TEX;
}
- if (draw_flags & V3D_OFSDRAW_USE_BACKGROUND) {
- v3d.flag3 |= V3D_SHOW_WORLD;
- }
+
+ v3d.flag3 |= V3D_SHOW_WORLD;
+
if (draw_flags & V3D_OFSDRAW_USE_CAMERA_DOF) {
if (camera->type == OB_CAMERA) {
v3d.fx_settings.dof = &((Camera *)camera->data)->gpu_dof;
@@ -2325,105 +1619,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
return ED_view3d_draw_offscreen_imbuf(
- eval_ctx, scene, view_layer, engine_type,
+ depsgraph, scene, drawtype,
&v3d, &ar, width, height, flag,
draw_flags, alpha_mode, samples, viewname, ofs, err_out);
}
/** \} */
-
-
-/* -------------------------------------------------------------------- */
-
-/** \name Legacy Interface
- *
- * This will be removed once the viewport gets replaced
- * meanwhile it should keep the old viewport working.
- *
- * \{ */
-
-void VP_legacy_drawcursor(Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d)
-{
- if (is_cursor_visible(scene, view_layer)) {
- drawcursor(scene, ar, v3d);
- }
-}
-
-void VP_legacy_draw_view_axis(RegionView3D *rv3d, const rcti *rect)
-{
- draw_view_axis(rv3d, rect);
-}
-
-void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect)
-{
- draw_viewport_name(ar, v3d, rect);
-}
-
-void VP_legacy_draw_selected_name(Scene *scene, Object *ob, rcti *rect)
-{
- draw_selected_name(scene, ob, rect);
-}
-
-void VP_legacy_drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit)
-{
- drawgrid(unit, ar, v3d, grid_unit);
-}
-
-void VP_legacy_drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool write_depth)
-{
- drawfloor(scene, v3d, grid_unit, write_depth);
-}
-
-void VP_legacy_view3d_main_region_setup_view(
- const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d,
- ARegion *ar, float viewmat[4][4], float winmat[4][4])
-{
- view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
-}
-
-bool VP_legacy_view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d)
-{
- return view3d_stereo3d_active(win, scene, v3d, rv3d);
-}
-
-void VP_legacy_view3d_stereo3d_setup(const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar)
-{
- view3d_stereo3d_setup(eval_ctx, scene, v3d, ar, NULL);
-}
-
-bool VP_legacy_use_depth(View3D *v3d, Object *obedit)
-{
- return use_depth_doit(v3d, obedit);
-}
-
-void VP_drawviewborder(Scene *scene, const struct Depsgraph *depsgraph, ARegion *ar, View3D *v3d)
-{
- drawviewborder(scene, depsgraph, ar, v3d);
-}
-
-void VP_drawrenderborder(ARegion *ar, View3D *v3d)
-{
- drawrenderborder(ar, v3d);
-}
-
-void VP_view3d_draw_background_none(void)
-{
- if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
- view3d_draw_background_gradient();
- }
- else {
- view3d_draw_background_none();
- }
-}
-
-void VP_view3d_draw_background_world(Scene *scene, RegionView3D *rv3d)
-{
- view3d_draw_background_world(scene, rv3d);
-}
-
-void VP_view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar)
-{
- view3d_main_region_clear(scene, v3d, ar);
-}
-
-/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 7272fc6b408..1ba46453915 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -71,6 +71,7 @@
#include "BKE_movieclip.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -98,7 +99,6 @@
#include "GPU_draw.h"
#include "GPU_framebuffer.h"
-#include "GPU_lamp.h"
#include "GPU_material.h"
#include "GPU_extensions.h"
#include "GPU_immediate.h"
@@ -114,34 +114,6 @@
/* ********* custom clipping *********** */
-static void view3d_draw_clipping(RegionView3D *rv3d)
-{
- BoundBox *bb = rv3d->clipbb;
-
- if (bb) {
- const unsigned int clipping_index[6][4] = {
- {0, 1, 2, 3},
- {0, 4, 5, 1},
- {4, 7, 6, 5},
- {7, 3, 2, 6},
- {1, 5, 6, 2},
- {7, 4, 0, 3}
- };
-
- /* fill in zero alpha for rendering & re-projection [#31530] */
- unsigned char col[4];
- UI_GetThemeColor4ubv(TH_V3D_CLIPPING_BORDER, col);
- glColor4ubv(col);
-
- glEnable(GL_BLEND);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, bb->vec);
- glDrawElements(GL_QUADS, sizeof(clipping_index) / sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisable(GL_BLEND);
- }
-}
-
void ED_view3d_clipping_set(RegionView3D *rv3d)
{
double plane[4];
@@ -186,32 +158,10 @@ bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], const
return view3d_clipping_test(co, is_local ? rv3d->clip_local : rv3d->clip);
}
-/* ********* end custom clipping *********** */
-
-static void draw_view_icon(RegionView3D *rv3d, rcti *rect)
-{
- BIFIconID icon;
-
- if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
- icon = ICON_AXIS_TOP;
- else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK))
- icon = ICON_AXIS_FRONT;
- else if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
- icon = ICON_AXIS_SIDE;
- else return;
-
- glEnable(GL_BLEND);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- UI_icon_draw(5.0 + rect->xmin, 5.0 + rect->ymin, icon);
-
- glDisable(GL_BLEND);
-}
-
/* *********************** backdraw for selection *************** */
static void backdrawview3d(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
ARegion *ar, View3D *v3d,
Object *obact, Object *obedit)
{
@@ -311,7 +261,7 @@ static void backdrawview3d(
G.f |= G_BACKBUFSEL;
if (obact && ((obact->base_flag & BASE_VISIBLED) != 0)) {
- draw_object_backbufsel(eval_ctx, scene, v3d, rv3d, obact);
+ draw_object_backbufsel(depsgraph, scene, v3d, rv3d, obact);
}
if (rv3d->gpuoffscreen)
@@ -351,10 +301,10 @@ static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h,
glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data);
}
-void ED_view3d_backbuf_validate(const struct EvaluationContext *eval_ctx, ViewContext *vc)
+void ED_view3d_backbuf_validate(ViewContext *vc)
{
if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
- backdrawview3d(eval_ctx, vc->scene, vc->ar, vc->v3d, vc->obact, vc->obedit);
+ backdrawview3d(vc->depsgraph, vc->scene, vc->ar, vc->v3d, vc->obact, vc->obedit);
}
}
@@ -369,13 +319,13 @@ int ED_view3d_backbuf_sample_size_clamp(ARegion *ar, const float dist)
/* samples a single pixel (copied from vpaint) */
unsigned int ED_view3d_backbuf_sample(
- const EvaluationContext *eval_ctx, ViewContext *vc, int x, int y)
+ ViewContext *vc, int x, int y)
{
if (x >= vc->ar->winx || y >= vc->ar->winy) {
return 0;
}
- ED_view3d_backbuf_validate(eval_ctx, vc);
+ ED_view3d_backbuf_validate(vc);
unsigned int col;
view3d_opengl_read_pixels(vc->ar, x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
@@ -390,7 +340,7 @@ unsigned int ED_view3d_backbuf_sample(
/* reads full rect, converts indices */
ImBuf *ED_view3d_backbuf_read(
- const EvaluationContext *eval_ctx, ViewContext *vc, int xmin, int ymin, int xmax, int ymax)
+ ViewContext *vc, int xmin, int ymin, int xmax, int ymax)
{
/* clip */
const rcti clip = {
@@ -408,7 +358,7 @@ ImBuf *ED_view3d_backbuf_read(
ImBuf *ibuf_clip = IMB_allocImBuf(size_clip[0], size_clip[1], 32, IB_rect);
- ED_view3d_backbuf_validate(eval_ctx, vc);
+ ED_view3d_backbuf_validate(vc);
view3d_opengl_read_pixels(vc->ar, clip.xmin, clip.ymin, size_clip[0], size_clip[1], GL_RGBA, GL_UNSIGNED_BYTE, ibuf_clip->rect);
@@ -447,7 +397,7 @@ ImBuf *ED_view3d_backbuf_read(
/* smart function to sample a rect spiralling outside, nice for backbuf selection */
unsigned int ED_view3d_backbuf_sample_rect(
- const EvaluationContext *eval_ctx, ViewContext *vc, const int mval[2], int size,
+ ViewContext *vc, const int mval[2], int size,
unsigned int min, unsigned int max, float *r_dist)
{
int dirvec[4][2];
@@ -456,7 +406,7 @@ unsigned int ED_view3d_backbuf_sample_rect(
const int minx = mval[0] - (amount + 1);
const int miny = mval[1] - (amount + 1);
- ImBuf *buf = ED_view3d_backbuf_read(eval_ctx, vc, minx, miny, minx + size - 1, miny + size - 1);
+ ImBuf *buf = ED_view3d_backbuf_read(vc, minx, miny, minx + size - 1, miny + size - 1);
if (!buf) return 0;
unsigned index = 0;
@@ -528,7 +478,7 @@ static void view3d_stereo_bgpic_setup(Scene *scene, View3D *v3d, Image *ima, Ima
}
}
-static void view3d_draw_bgpic(Scene *scene, const Depsgraph *depsgraph,
+static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
ARegion *ar, View3D *v3d,
const bool do_foreground, const bool do_camera_frame)
{
@@ -773,7 +723,7 @@ static void view3d_draw_bgpic(Scene *scene, const Depsgraph *depsgraph,
}
void ED_view3d_draw_bgpic_test(
- Scene *scene, const Depsgraph *depsgraph,
+ Scene *scene, Depsgraph *depsgraph,
ARegion *ar, View3D *v3d,
const bool do_foreground, const bool do_camera_frame)
{
@@ -806,259 +756,8 @@ void ED_view3d_draw_bgpic_test(
}
}
-/* ****************** View3d afterdraw *************** */
-
-typedef struct View3DAfter {
- struct View3DAfter *next, *prev;
- struct Base *base;
- short dflag;
-} View3DAfter;
-
-/* temp storage of Objects that need to be drawn as last */
-void ED_view3d_after_add(ListBase *lb, Base *base, const short dflag)
-{
- View3DAfter *v3da = MEM_callocN(sizeof(View3DAfter), "View 3d after");
- BLI_assert((base->flag_legacy & OB_FROMDUPLI) == 0);
- BLI_addtail(lb, v3da);
- v3da->base = base;
- v3da->dflag = dflag;
-}
-
-/* disables write in zbuffer and draws it over */
-static void view3d_draw_transp(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d)
-{
- View3DAfter *v3da;
-
- glDepthMask(GL_FALSE);
- v3d->transp = true;
-
- while ((v3da = BLI_pophead(&v3d->afterdraw_transp))) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, v3da->base, v3da->dflag);
- MEM_freeN(v3da);
- }
- v3d->transp = false;
-
- glDepthMask(GL_TRUE);
-
-}
-
-/* clears zbuffer and draws it over */
-static void view3d_draw_xray(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, bool *clear)
-{
- if (*clear && v3d->zbuf) {
- glClear(GL_DEPTH_BUFFER_BIT);
- *clear = false;
- }
-
- v3d->xray = true;
- View3DAfter *v3da;
- while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, v3da->base, v3da->dflag);
- MEM_freeN(v3da);
- }
- v3d->xray = false;
-}
-
-
-/* clears zbuffer and draws it over */
-static void view3d_draw_xraytransp(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, const bool clear)
-{
- if (clear && v3d->zbuf)
- glClear(GL_DEPTH_BUFFER_BIT);
-
- v3d->xray = true;
- v3d->transp = true;
-
- glDepthMask(GL_FALSE);
-
- View3DAfter *v3da;
- while ((v3da = BLI_pophead(&v3d->afterdraw_xraytransp))) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, v3da->base, v3da->dflag);
- MEM_freeN(v3da);
- }
-
- v3d->transp = false;
- v3d->xray = false;
-
- glDepthMask(GL_TRUE);
-}
-
-/* clears zbuffer and draws it over,
- * note that in the select version we don't care about transparent flag as with regular drawing */
-static void view3d_draw_xray_select(
- const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, bool *clear)
-{
- /* Not ideal, but we need to read from the previous depths before clearing
- * otherwise we could have a function to load the depths after drawing.
- *
- * Clearing the depth buffer isn't all that common between drawing objects so accept this for now.
- */
- if (U.gpu_select_pick_deph) {
- GPU_select_load_id(-1);
- }
-
- View3DAfter *v3da;
- if (*clear && v3d->zbuf) {
- glClear(GL_DEPTH_BUFFER_BIT);
- *clear = false;
- }
-
- v3d->xray = true;
- while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
- if (GPU_select_load_id(v3da->base->object->select_color)) {
- draw_object_select(eval_ctx, scene, view_layer, ar, v3d, v3da->base, v3da->dflag);
- }
- MEM_freeN(v3da);
- }
- v3d->xray = false;
-}
-
/* *********************** */
-/*
- * In most cases call draw_dupli_objects,
- * draw_dupli_objects_color was added because when drawing set dupli's
- * we need to force the color
- */
-
-#if 0
-int dupli_ob_sort(void *arg1, void *arg2)
-{
- void *p1 = ((DupliObject *)arg1)->ob;
- void *p2 = ((DupliObject *)arg2)->ob;
- int val = 0;
- if (p1 < p2) val = -1;
- else if (p1 > p2) val = 1;
- return val;
-}
-#endif
-
-
-static DupliObject *dupli_step(DupliObject *dob)
-{
- while (dob && dob->no_draw)
- dob = dob->next;
- return dob;
-}
-
-static void draw_dupli_objects_color(
- const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, Base *base,
- const short dflag, const int color)
-{
- RegionView3D *rv3d = ar->regiondata;
- ListBase *lb;
- LodLevel *savedlod;
- Base tbase = {NULL};
- BoundBox bb, *bb_tmp; /* use a copy because draw_object, calls clear_mesh_caches */
- unsigned char color_rgb[3];
- const short dflag_dupli = dflag | DRAW_CONSTCOLOR;
- short transflag;
- char dt;
- short dtx;
- DupliApplyData *apply_data;
-
- if ((base->flag & BASE_VISIBLED) == 0) return;
- if ((base->object->restrictflag & OB_RESTRICT_RENDER) && (v3d->flag2 & V3D_RENDER_OVERRIDE)) return;
-
- if (dflag & DRAW_CONSTCOLOR) {
- BLI_assert(color == TH_UNDEFINED);
- }
- else {
- UI_GetThemeColorBlend3ubv(color, TH_BACK, 0.5f, color_rgb);
- }
-
- tbase.flag_legacy = OB_FROMDUPLI | base->flag_legacy;
- tbase.flag = base->flag;
- lb = object_duplilist(eval_ctx, scene, base->object);
- // BLI_listbase_sort(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */
-
- apply_data = duplilist_apply(eval_ctx, base->object, scene, lb);
-
- DupliObject *dob_next = NULL;
- DupliObject *dob = dupli_step(lb->first);
- if (dob) dob_next = dupli_step(dob->next);
-
- for (; dob; dob = dob_next, dob_next = dob_next ? dupli_step(dob_next->next) : NULL) {
- bool testbb = false;
-
- tbase.object = dob->ob;
-
- /* Make sure lod is updated from dupli's position */
- savedlod = dob->ob->currentlod;
-
-#ifdef WITH_GAMEENGINE
- if (rv3d->rflag & RV3D_IS_GAME_ENGINE) {
- BKE_object_lod_update(dob->ob, rv3d->viewinv[3]);
- }
-#endif
-
- /* extra service: draw the duplicator in drawtype of parent, minimum taken
- * to allow e.g. boundbox box objects in groups for LOD */
- dt = tbase.object->dt;
- tbase.object->dt = MIN2(tbase.object->dt, base->object->dt);
-
- /* inherit draw extra, but not if a boundbox under the assumption that this
- * is intended to speed up drawing, and drawing extra (especially wire) can
- * slow it down too much */
- dtx = tbase.object->dtx;
- if (tbase.object->dt != OB_BOUNDBOX)
- tbase.object->dtx = base->object->dtx;
-
- /* negative scale flag has to propagate */
- transflag = tbase.object->transflag;
-
- if (is_negative_m4(dob->mat))
- tbase.object->transflag |= OB_NEG_SCALE;
- else
- tbase.object->transflag &= ~OB_NEG_SCALE;
-
- /* should move outside the loop but possible color is set in draw_object still */
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(color_rgb);
- }
-
- if ((bb_tmp = BKE_object_boundbox_get(dob->ob))) {
- bb = *bb_tmp; /* must make a copy */
- testbb = true;
- }
-
- if (!testbb || ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) {
- copy_m4_m4(dob->ob->obmat, dob->mat);
- GPU_begin_dupli_object(dob);
- draw_object(eval_ctx, scene, view_layer, ar, v3d, &tbase, dflag_dupli);
- GPU_end_dupli_object();
- }
-
- tbase.object->dt = dt;
- tbase.object->dtx = dtx;
- tbase.object->transflag = transflag;
- tbase.object->currentlod = savedlod;
- }
-
- if (apply_data) {
- duplilist_restore(lb, apply_data);
- duplilist_free_apply_data(apply_data);
- }
-
- free_object_duplilist(lb);
-}
-
-void draw_dupli_objects(const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, Base *base)
-{
- /* define the color here so draw_dupli_objects_color can be called
- * from the set loop */
-
- int color = (base->flag & BASE_SELECTED) ? TH_SELECT : TH_WIRE;
- /* debug */
- if (base->object->dup_group && base->object->dup_group->id.us < 1)
- color = TH_REDALERT;
-
- draw_dupli_objects_color(eval_ctx, scene, view_layer, ar, v3d, base, 0, color);
-}
-
/* XXX warning, not using gpu offscreen here */
void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
{
@@ -1170,12 +869,13 @@ float view3d_depth_near(ViewDepths *d)
}
void ED_view3d_draw_depth_gpencil(
- const EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d)
+ Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d)
{
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
bool zbuf = v3d->zbuf;
/* Setup view matrix. */
- ED_view3d_draw_setup_view(NULL, eval_ctx, scene, ar, v3d, NULL, NULL, NULL);
+ ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL);
glClear(GL_DEPTH_BUFFER_BIT);
@@ -1183,273 +883,16 @@ void ED_view3d_draw_depth_gpencil(
glEnable(GL_DEPTH_TEST);
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
- ED_gpencil_draw_view3d(NULL, scene, eval_ctx->view_layer, eval_ctx->depsgraph, v3d, ar, true);
+ ED_gpencil_draw_view3d(NULL, scene, view_layer, depsgraph, v3d, ar, true);
}
v3d->zbuf = zbuf;
if (!zbuf) glDisable(GL_DEPTH_TEST);
}
-void ED_view3d_draw_depth_loop(const EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d)
-{
- Base *base;
- ViewLayer *view_layer = eval_ctx->view_layer;
- /* no need for color when drawing depth buffer */
- const short dflag_depth = DRAW_CONSTCOLOR;
-
- /* draw set first */
- if (scene->set) {
- Scene *sce_iter;
- for (SETLOOPER(scene->set, sce_iter, base)) {
- if ((base->flag & BASE_VISIBLED) != 0) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0);
- if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects_color(eval_ctx, scene, view_layer, ar, v3d, base, dflag_depth, TH_UNDEFINED);
- }
- }
- }
- }
-
- for (base = view_layer->object_bases.first; base; base = base->next) {
- if ((base->flag & BASE_VISIBLED) != 0) {
- /* dupli drawing */
- if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects_color(eval_ctx, scene, view_layer, ar, v3d, base, dflag_depth, TH_UNDEFINED);
- }
- draw_object(eval_ctx, scene, view_layer, ar, v3d, base, dflag_depth);
- }
- }
-
- /* this isn't that nice, draw xray objects as if they are normal */
- if (v3d->afterdraw_transp.first ||
- v3d->afterdraw_xray.first ||
- v3d->afterdraw_xraytransp.first)
- {
- View3DAfter *v3da;
- int mask_orig;
-
- v3d->xray = true;
-
- /* transp materials can change the depth mask, see #21388 */
- glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
-
-
- if (v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) {
- glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */
- for (v3da = v3d->afterdraw_xray.first; v3da; v3da = v3da->next) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, v3da->base, dflag_depth);
- }
- glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */
- }
-
- /* draw 3 passes, transp/xray/xraytransp */
- v3d->xray = false;
- v3d->transp = true;
- while ((v3da = BLI_pophead(&v3d->afterdraw_transp))) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, v3da->base, dflag_depth);
- MEM_freeN(v3da);
- }
-
- v3d->xray = true;
- v3d->transp = false;
- while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, v3da->base, dflag_depth);
- MEM_freeN(v3da);
- }
-
- v3d->xray = true;
- v3d->transp = true;
- while ((v3da = BLI_pophead(&v3d->afterdraw_xraytransp))) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, v3da->base, dflag_depth);
- MEM_freeN(v3da);
- }
-
-
- v3d->xray = false;
- v3d->transp = false;
-
- glDepthMask(mask_orig);
- }
-}
-
-void ED_view3d_draw_select_loop(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, Scene *scene, ViewLayer *view_layer,
- View3D *v3d, ARegion *ar, bool use_obedit_skip, bool use_nearest)
-{
- struct bThemeState theme_state;
-
- short code = 1;
- const short dflag = DRAW_PICKING | DRAW_CONSTCOLOR;
-
- /* Tools may request depth outside of regular drawing code. */
- UI_Theme_Store(&theme_state);
- UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
-
- if (vc->obedit && vc->obedit->type == OB_MBALL) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, BASACT(view_layer), dflag);
- }
- else if ((vc->obedit && vc->obedit->type == OB_ARMATURE)) {
- /* if not drawing sketch, draw bones */
- if (!BDR_drawSketchNames(vc)) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, BASACT(view_layer), dflag);
- }
- }
- else {
- Base *base;
-
- for (base = view_layer->object_bases.first; base; base = base->next) {
- if ((base->flag & BASE_VISIBLED) != 0) {
- if (((base->flag & BASE_SELECTABLED) == 0) ||
- (use_obedit_skip && (vc->obedit->data == base->object->data)))
- {
- base->object->select_color = 0;
- }
- else {
- base->object->select_color = code;
-
- if (use_nearest && (base->object->dtx & OB_DRAWXRAY)) {
- ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
- }
- else {
- if (GPU_select_load_id(code)) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, base, dflag);
- }
- }
- code++;
- }
- }
- }
-
- if (use_nearest) {
- bool xrayclear = true;
- if (v3d->afterdraw_xray.first) {
- view3d_draw_xray_select(eval_ctx, scene, view_layer, ar, v3d, &xrayclear);
- }
- }
- }
-
- UI_Theme_Restore(&theme_state);
-}
-
-typedef struct View3DShadow {
- struct View3DShadow *next, *prev;
- GPULamp *lamp;
-} View3DShadow;
-
-static void gpu_render_lamp_update(Scene *scene, View3D *v3d,
- Object *ob, Object *par,
- float obmat[4][4], unsigned int lay,
- ListBase *shadows)
-{
- GPULamp *lamp = GPU_lamp_from_blender(scene, ob, par);
-
- if (lamp) {
- Lamp *la = (Lamp *)ob->data;
-
- GPU_lamp_update(lamp, lay, (ob->restrictflag & OB_RESTRICT_RENDER), obmat);
- GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy);
-
- unsigned int layers = lay & v3d->lay;
-
- if (layers &&
- GPU_lamp_has_shadow_buffer(lamp) &&
- /* keep last, may do string lookup */
- GPU_lamp_visible(lamp, NULL))
- {
- View3DShadow *shadow = MEM_callocN(sizeof(View3DShadow), "View3DShadow");
- shadow->lamp = lamp;
- BLI_addtail(shadows, shadow);
- }
- }
-}
-
-static void gpu_update_lamps_shadows_world(const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d)
-{
- ListBase shadows;
- Scene *sce_iter;
- Base *base;
- World *world = scene->world;
-
- BLI_listbase_clear(&shadows);
-
- /* update lamp transform and gather shadow lamps */
- for (SETLOOPER(scene, sce_iter, base)) {
- Object *ob = base->object;
-
- if (ob->type == OB_LAMP)
- gpu_render_lamp_update(scene, v3d, ob, NULL, ob->obmat, ob->lay, &shadows);
-
- if (ob->transflag & OB_DUPLI) {
- DupliObject *dob;
- ListBase *lb = object_duplilist(G.main->eval_ctx, scene, ob);
-
- for (dob = lb->first; dob; dob = dob->next)
- if (dob->ob->type == OB_LAMP)
- gpu_render_lamp_update(scene, v3d, dob->ob, ob, dob->mat, ob->lay, &shadows);
-
- free_object_duplilist(lb);
- }
- }
-
- /* render shadows after updating all lamps, nested object_duplilist
- * don't work correct since it's replacing object matrices */
- for (View3DShadow *shadow = shadows.first; shadow; shadow = shadow->next) {
- /* this needs to be done better .. */
- float viewmat[4][4], winmat[4][4];
- ARegion ar = {NULL};
- RegionView3D rv3d = {{{0}}};
-
- int drawtype = v3d->drawtype;
- int lay = v3d->lay;
- int flag2 = v3d->flag2;
-
- v3d->drawtype = OB_SOLID;
- v3d->lay &= GPU_lamp_shadow_layer(shadow->lamp);
- v3d->flag2 &= ~(V3D_SOLID_TEX | V3D_SHOW_SOLID_MATCAP);
- v3d->flag2 |= V3D_RENDER_OVERRIDE | V3D_RENDER_SHADOW;
-
- int winsize;
- GPU_lamp_shadow_buffer_bind(shadow->lamp, viewmat, &winsize, winmat);
-
- ar.regiondata = &rv3d;
- ar.regiontype = RGN_TYPE_WINDOW;
- rv3d.persp = RV3D_CAMOB;
- copy_m4_m4(rv3d.winmat, winmat);
- copy_m4_m4(rv3d.viewmat, viewmat);
- invert_m4_m4(rv3d.viewinv, rv3d.viewmat);
- mul_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
- invert_m4_m4(rv3d.persinv, rv3d.viewinv);
-
- RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
-
- /* no need to call ED_view3d_draw_offscreen_init since shadow buffers were already updated */
- ED_view3d_draw_offscreen(
- eval_ctx, scene, eval_ctx->view_layer, engine_type,
- v3d, &ar, winsize, winsize, viewmat, winmat,
- false, false, true,
- NULL, NULL, NULL, NULL);
- GPU_lamp_shadow_buffer_unbind(shadow->lamp);
-
- v3d->drawtype = drawtype;
- v3d->lay = lay;
- v3d->flag2 = flag2;
- }
-
- BLI_freelistN(&shadows);
-
- /* update world values */
- if (world) {
- GPU_mist_update_enable(world->mode & WO_MIST);
- GPU_mist_update_values(world->mistype, world->miststa, world->mistdist, world->misi, &world->horr);
- GPU_horizon_update_color(&world->horr);
- GPU_ambient_update_color(&world->ambr);
- GPU_zenith_update_color(&world->zenr);
- }
-}
-
/* *********************** customdata **************** */
-CustomDataMask ED_view3d_datamask(const Scene *scene, const View3D *v3d)
+CustomDataMask ED_view3d_datamask(const Scene *UNUSED(scene), const View3D *v3d)
{
CustomDataMask mask = 0;
const int drawtype = view3d_effective_drawtype(v3d);
@@ -1459,17 +902,8 @@ CustomDataMask ED_view3d_datamask(const Scene *scene, const View3D *v3d)
{
mask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL;
- if (BKE_scene_use_new_shading_nodes(scene)) {
- if (drawtype == OB_MATERIAL)
- mask |= CD_MASK_ORCO;
- }
- else {
- if ((scene->gm.matmode == GAME_MAT_GLSL && drawtype == OB_TEXTURE) ||
- (drawtype == OB_MATERIAL))
- {
- mask |= CD_MASK_ORCO;
- }
- }
+ if (drawtype == OB_MATERIAL)
+ mask |= CD_MASK_ORCO;
}
return mask;
@@ -1491,179 +925,6 @@ CustomDataMask ED_view3d_screen_datamask(const Scene *scene, const bScreen *scre
}
/**
- * Shared by #ED_view3d_draw_offscreen and #view3d_main_region_draw_objects
- *
- * \note \a C and \a grid_unit will be NULL when \a draw_offscreen is set.
- * \note Drawing lamps and opengl render uses this, so dont do grease pencil or view widgets here.
- */
-static void view3d_draw_objects(
- const bContext *C,
- const EvaluationContext *eval_ctx,
- Scene *scene, View3D *v3d, ARegion *ar,
- const char **grid_unit,
- const bool do_bgpic, const bool draw_offscreen)
-{
- ViewLayer *view_layer = C ? CTX_data_view_layer(C) : BKE_view_layer_from_scene_get(scene);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- RegionView3D *rv3d = ar->regiondata;
- Base *base;
- Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
- const bool do_camera_frame = !draw_offscreen;
- const bool draw_grids = !draw_offscreen && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0;
- const bool draw_floor = (rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO);
- /* only draw grids after in solid modes, else it hovers over mesh wires */
- const bool draw_grids_after = draw_grids && draw_floor && (v3d->drawtype > OB_WIRE);
- bool xrayclear = true;
-
- if (!draw_offscreen) {
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
- }
-
- if (rv3d->rflag & RV3D_CLIPPING)
- view3d_draw_clipping(rv3d);
-
- /* set zbuffer after we draw clipping region */
- v3d->zbuf = VP_legacy_use_depth(v3d, obedit);
-
- if (v3d->zbuf) {
- glEnable(GL_DEPTH_TEST);
- }
-
- /* ortho grid goes first, does not write to depth buffer and doesn't need depth test so it will override
- * objects if done last */
- if (draw_grids) {
- /* needs to be done always, gridview is adjusted in drawgrid() now, but only for ortho views. */
- rv3d->gridview = ED_view3d_grid_scale(scene, v3d, grid_unit);
-
- if (!draw_floor) {
- ED_region_pixelspace(ar);
- *grid_unit = NULL; /* drawgrid need this to detect/affect smallest valid unit... */
- VP_legacy_drawgrid(&scene->unit, ar, v3d, grid_unit);
- gpuLoadProjectionMatrix(rv3d->winmat);
- gpuLoadMatrix(rv3d->viewmat);
- }
- else if (!draw_grids_after) {
- VP_legacy_drawfloor(scene, v3d, grid_unit, true);
- }
- }
-
- /* important to do before clipping */
- if (do_bgpic) {
- ED_view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, false, do_camera_frame);
- }
-
- if (rv3d->rflag & RV3D_CLIPPING) {
- ED_view3d_clipping_set(rv3d);
- }
-
- /* draw set first */
- if (scene->set) {
- const short dflag = DRAW_CONSTCOLOR | DRAW_SCENESET;
- Scene *sce_iter;
- for (SETLOOPER(scene->set, sce_iter, base)) {
- if ((base->flag & BASE_VISIBLED) != 0) {
- UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
- draw_object(eval_ctx, scene, view_layer, ar, v3d, base, dflag);
-
- if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects_color(eval_ctx, scene, view_layer, ar, v3d, base, dflag, TH_UNDEFINED);
- }
- }
- }
-
- /* Transp and X-ray afterdraw stuff for sets is done later */
- }
-
- if (draw_offscreen) {
- for (base = view_layer->object_bases.first; base; base = base->next) {
- if ((base->flag & BASE_VISIBLED) != 0) {
- /* dupli drawing */
- if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects(eval_ctx, scene, view_layer, ar, v3d, base);
- }
-
- draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0);
- }
- }
- }
- else {
- unsigned int lay_used = 0;
-
- /* then draw not selected and the duplis, but skip editmode object */
- for (base = view_layer->object_bases.first; base; base = base->next) {
- lay_used |= base->lay;
-
- if ((base->flag & BASE_VISIBLED) != 0) {
-
- /* dupli drawing */
- if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects(eval_ctx, scene, view_layer, ar, v3d, base);
- }
- if ((base->flag & BASE_SELECTED) == 0) {
- if (base->object != obedit)
- draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0);
- }
- }
- }
-
- /* mask out localview */
- v3d->lay_used = lay_used & ((1 << 20) - 1);
-
- /* draw selected and editmode */
- for (base = view_layer->object_bases.first; base; base = base->next) {
- if ((base->flag & BASE_VISIBLED) != 0) {
- if (base->object == obedit || (base->flag & BASE_SELECTED)) {
- draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0);
- }
- }
- }
- }
-
- /* perspective floor goes last to use scene depth and avoid writing to depth buffer */
- if (draw_grids_after) {
- VP_legacy_drawfloor(scene, v3d, grid_unit, false);
- }
-
- /* must be before xray draw which clears the depth buffer */
- if (v3d->flag2 & V3D_SHOW_GPENCIL) {
- wmWindowManager *wm = (C != NULL) ? CTX_wm_manager(C) : NULL;
-
- /* must be before xray draw which clears the depth buffer */
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
- ED_gpencil_draw_view3d(wm, scene, view_layer, depsgraph, v3d, ar, true);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- }
-
- /* transp and X-ray afterdraw stuff */
- if (v3d->afterdraw_transp.first) view3d_draw_transp(eval_ctx, scene, view_layer, ar, v3d);
-
- if (v3d->afterdraw_xray.first) view3d_draw_xray(eval_ctx, scene, view_layer, ar, v3d, &xrayclear);
- if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(eval_ctx, scene, view_layer, ar, v3d, xrayclear);
-
- if (!draw_offscreen) {
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
- }
-
- if (rv3d->rflag & RV3D_CLIPPING)
- ED_view3d_clipping_disable();
-
- /* important to do after clipping */
- if (do_bgpic) {
- ED_view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, true, do_camera_frame);
- }
-
- /* cleanup */
- if (v3d->zbuf) {
- v3d->zbuf = false;
- glDisable(GL_DEPTH_TEST);
- }
-
- if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
- GPU_free_images_old();
- }
-}
-
-/**
* Store values from #RegionView3D, set when drawing.
* This is needed when we draw with to a viewport using a different matrix (offscreen drawing for example).
*
@@ -1764,11 +1025,11 @@ void ED_scene_draw_fps(Scene *scene, const rcti *rect)
static bool view3d_main_region_do_render_draw(const Scene *scene)
{
- RenderEngineType *type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *type = RE_engines_find(scene->r.engine);
return (type && type->view_update && type->render_to_view);
}
-bool ED_view3d_calc_render_border(const Scene *scene, const Depsgraph *depsgraph, View3D *v3d, ARegion *ar, rcti *rect)
+bool ED_view3d_calc_render_border(const Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *ar, rcti *rect)
{
RegionView3D *rv3d = ar->regiondata;
bool use_border;
@@ -1808,339 +1069,3 @@ bool ED_view3d_calc_render_border(const Scene *scene, const Depsgraph *depsgraph
return true;
}
-
-/**
- * IMPORTANT: this is deprecated, any changes made in this function should
- * be mirrored in view3d_draw_render_draw() in view3d_draw.c
- */
-static bool view3d_main_region_draw_engine(
- const bContext *C, const EvaluationContext *eval_ctx, Scene *scene,
- ARegion *ar, View3D *v3d,
- bool clip_border, const rcti *border_rect)
-{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
- RegionView3D *rv3d = ar->regiondata;
- RenderEngineType *type;
- GLint scissor[4];
-
- /* create render engine */
- if (!rv3d->render_engine) {
- RenderEngine *engine;
- type = RE_engines_find(scene->view_render.engine_id);
-
- if (!(type->view_update && type->render_to_view))
- return false;
-
- engine = RE_engine_create_ex(type, true);
-
- engine->tile_x = scene->r.tilex;
- engine->tile_y = scene->r.tiley;
-
- type->view_update(engine, C);
-
- rv3d->render_engine = engine;
- }
-
- /* setup view matrices */
- VP_legacy_view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, NULL, NULL);
-
- /* background draw */
- ED_region_pixelspace(ar);
-
- if (clip_border) {
- /* for border draw, we only need to clear a subset of the 3d view */
- if (border_rect->xmax > border_rect->xmin && border_rect->ymax > border_rect->ymin) {
- glGetIntegerv(GL_SCISSOR_BOX, scissor);
- glScissor(border_rect->xmin, border_rect->ymin,
- BLI_rcti_size_x(border_rect), BLI_rcti_size_y(border_rect));
- }
- else {
- return false;
- }
- }
-
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- bool show_image = false;
- {
- Camera *cam = ED_view3d_camera_data_get(v3d, rv3d);
- if (cam->flag & CAM_SHOW_BG_IMAGE) {
- show_image = true;
- ED_view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, false, true);
- }
- else {
- imm_draw_box_checker_2d(0, 0, ar->winx, ar->winy);
- }
- }
-
- if (show_image) {
- ED_view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, false, true);
- }
- else {
- imm_draw_box_checker_2d(0, 0, ar->winx, ar->winy);
- }
-
- /* render result draw */
- type = rv3d->render_engine->type;
- type->render_to_view(rv3d->render_engine, C);
-
- if (show_image) {
- ED_view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, true, true);
- }
-
- if (clip_border) {
- /* restore scissor as it was before */
- glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
- }
-
- return true;
-}
-
-static void view3d_main_region_draw_engine_info(View3D *v3d, RegionView3D *rv3d, ARegion *ar, bool render_border)
-{
- float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.25f};
-
- if (!rv3d->render_engine || !rv3d->render_engine->text[0])
- return;
-
- if (render_border) {
- /* draw darkened background color. no alpha because border render does
- * partial redraw and will not redraw the region behind this info bar */
- float alpha = 1.0f - fill_color[3];
- Camera *camera = ED_view3d_camera_data_get(v3d, rv3d);
-
- if (camera) {
- if (camera->flag & CAM_SHOWPASSEPARTOUT) {
- alpha *= (1.0f - camera->passepartalpha);
- }
- }
-
- UI_GetThemeColor3fv(TH_HIGH_GRAD, fill_color);
- mul_v3_fl(fill_color, alpha);
- fill_color[3] = 1.0f;
- }
-
- ED_region_info_draw(ar, rv3d->render_engine->text, fill_color, true);
-}
-
-#ifdef WITH_GAMEENGINE
-static void update_lods(Scene *scene, float camera_pos[3])
-{
- Scene *sce_iter;
- Base *base;
-
- for (SETLOOPER(scene, sce_iter, base)) {
- Object *ob = base->object;
- BKE_object_lod_update(ob, camera_pos);
- }
-}
-#endif
-
-static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, ViewLayer *view_layer, View3D *v3d,
- ARegion *ar, const char **grid_unit)
-{
- wmWindow *win = CTX_wm_window(C);
- EvaluationContext eval_ctx;
- RegionView3D *rv3d = ar->regiondata;
- unsigned int lay_used = v3d->lay_used;
-
- CTX_data_eval_ctx(C, &eval_ctx);
-
- /* shadow buffers, before we setup matrices */
- if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype))
- gpu_update_lamps_shadows_world(&eval_ctx, scene, v3d);
-
- /* reset default OpenGL lights if needed (i.e. after preferences have been altered) */
- if (rv3d->rflag & RV3D_GPULIGHT_UPDATE) {
- rv3d->rflag &= ~RV3D_GPULIGHT_UPDATE;
- GPU_default_lights();
- }
-
- /* setup the view matrix */
- if (VP_legacy_view3d_stereo3d_active(win, scene, v3d, rv3d)) {
- VP_legacy_view3d_stereo3d_setup(&eval_ctx, scene, v3d, ar);
- }
- else {
- VP_legacy_view3d_main_region_setup_view(&eval_ctx, scene, v3d, ar, NULL, NULL);
- }
-
- rv3d->rflag &= ~RV3D_IS_GAME_ENGINE;
-#ifdef WITH_GAMEENGINE
- if (STREQ(scene->view_render.engine_id, RE_engine_id_BLENDER_GAME)) {
- rv3d->rflag |= RV3D_IS_GAME_ENGINE;
-
- /* Make sure LoDs are up to date */
- update_lods(scene, rv3d->viewinv[3]);
- }
-#endif
-
- /* main drawing call */
- view3d_draw_objects(C, &eval_ctx, scene, v3d, ar, grid_unit, true, false);
-
- if (v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */
- /* find header and force tag redraw */
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
- ED_region_tag_redraw(ar_header); /* can be NULL */
- }
-
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- BDR_drawSketch(C);
- }
-}
-
-static void view3d_main_region_draw_info(const bContext *C, Scene *scene,
- ARegion *ar, View3D *v3d,
- const char *grid_unit, bool render_border)
-{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- wmWindowManager *wm = CTX_wm_manager(C);
- RegionView3D *rv3d = ar->regiondata;
- rcti rect;
-
- /* local coordinate visible rect inside region, to accomodate overlapping ui */
- ED_region_visible_rect(ar, &rect);
-
- if (rv3d->persp == RV3D_CAMOB) {
- VP_drawviewborder(scene, CTX_data_depsgraph(C), ar, v3d);
- }
- else if (v3d->flag2 & V3D_RENDER_BORDER) {
- VP_drawrenderborder(ar, v3d);
- }
-
- if (v3d->flag2 & V3D_SHOW_GPENCIL) {
- /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
- ED_gpencil_draw_view3d(wm, scene, view_layer, depsgraph, v3d, ar, false);
- }
-
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- VP_legacy_drawcursor(scene, view_layer, ar, v3d); /* 3D cursor */
-
- if (U.uiflag & USER_SHOW_ROTVIEWICON)
- VP_legacy_draw_view_axis(rv3d, &rect);
- else
- draw_view_icon(rv3d, &rect);
-
- if (U.uiflag & USER_DRAWVIEWINFO) {
- Object *ob = OBACT(view_layer);
- VP_legacy_draw_selected_name(scene, ob, &rect);
- }
- }
-
- if (rv3d->render_engine) {
- view3d_main_region_draw_engine_info(v3d, rv3d, ar, render_border);
- return;
- }
-
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) {
- ED_scene_draw_fps(scene, &rect);
- }
- else if (U.uiflag & USER_SHOW_VIEWPORTNAME) {
- VP_legacy_draw_viewport_name(ar, v3d, &rect);
- }
-
- if (grid_unit) { /* draw below the viewport name */
- char numstr[32] = "";
-
- UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
- if (v3d->grid != 1.0f) {
- BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
- }
-
- BLF_draw_default_ascii(rect.xmin + U.widget_unit,
- rect.ymax - (USER_SHOW_VIEWPORTNAME ? 2 * U.widget_unit : U.widget_unit), 0.0f,
- numstr[0] ? numstr : grid_unit, sizeof(numstr));
- }
- }
-}
-
-void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar)
-{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
- EvaluationContext eval_ctx;
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- View3D *v3d = CTX_wm_view3d(C);
- const char *grid_unit = NULL;
- rcti border_rect;
-
- /* if we only redraw render border area, skip opengl draw and also
- * don't do scissor because it's already set */
- bool render_border = ED_view3d_calc_render_border(scene, depsgraph, v3d, ar, &border_rect);
- bool clip_border = (render_border && !BLI_rcti_compare(&ar->drawrct, &border_rect));
-
- gpuPushProjectionMatrix();
- gpuLoadIdentityProjectionMatrix();
- gpuPushMatrix();
- gpuLoadIdentity();
-
- CTX_data_eval_ctx(C, &eval_ctx);
-
- /* draw viewport using opengl */
- if (v3d->drawtype != OB_RENDER || !view3d_main_region_do_render_draw(scene) || clip_border) {
- VP_view3d_main_region_clear(scene, v3d, ar); /* background */
- view3d_main_region_draw_objects(C, scene, view_layer, v3d, ar, &grid_unit);
-
- if (G.debug & G_DEBUG_SIMDATA)
- draw_sim_debug_data(scene, v3d, ar);
-
- glDisable(GL_DEPTH_TEST);
- ED_region_pixelspace(ar);
- }
-
- /* draw viewport using external renderer */
- if (v3d->drawtype == OB_RENDER) {
- view3d_main_region_draw_engine(C, &eval_ctx, scene, ar, v3d, clip_border, &border_rect);
- }
-
- VP_legacy_view3d_main_region_setup_view(&eval_ctx, scene, v3d, ar, NULL, NULL);
- glClear(GL_DEPTH_BUFFER_BIT);
-
- WM_manipulatormap_draw(ar->manipulator_map, C, WM_MANIPULATORMAP_DRAWSTEP_3D);
-
- ED_region_pixelspace(ar);
-
- view3d_main_region_draw_info(C, scene, ar, v3d, grid_unit, render_border);
-
- WM_manipulatormap_draw(ar->manipulator_map, C, WM_MANIPULATORMAP_DRAWSTEP_2D);
-
- gpuPopProjectionMatrix();
- gpuPopMatrix();
-
- v3d->flag |= V3D_INVALID_BACKBUF;
-
- BLI_assert(BLI_listbase_is_empty(&v3d->afterdraw_transp));
- BLI_assert(BLI_listbase_is_empty(&v3d->afterdraw_xray));
- BLI_assert(BLI_listbase_is_empty(&v3d->afterdraw_xraytransp));
-}
-
-
-/* -------------------------------------------------------------------- */
-
-/** \name Deprecated Interface
- *
- * New viewport sometimes has a check for new/old viewport code.
- * Use these functions so new viewport can *optionally* call.
- *
- * \{ */
-
-
-void VP_deprecated_view3d_draw_objects(
- const bContext *C,
- const EvaluationContext *eval_ctx,
- Scene *scene, View3D *v3d, ARegion *ar,
- const char **grid_unit,
- const bool do_bgpic, const bool draw_offscreen)
-{
- view3d_draw_objects(C, eval_ctx, scene, v3d, ar, grid_unit, do_bgpic, draw_offscreen);
-}
-
-void VP_deprecated_gpu_update_lamps_shadows_world(const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d)
-{
- gpu_update_lamps_shadows_world(eval_ctx, scene, v3d);
-}
-
-/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 0ae69debf18..f80d4a3b4b4 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -377,18 +377,15 @@ static void viewops_data_create(
/* we need the depth info before changing any viewport options */
if (viewops_flag & VIEWOPS_FLAG_DEPTH_NAVIGATE) {
- EvaluationContext eval_ctx;
struct Depsgraph *graph = CTX_data_depsgraph(C);
float fallback_depth_pt[3];
- CTX_data_eval_ctx(C, &eval_ctx);
-
view3d_operator_needs_opengl(C); /* needed for zbuf drawing */
negate_v3_v3(fallback_depth_pt, rv3d->ofs);
vod->use_dyn_ofs = ED_view3d_autodist(
- &eval_ctx, graph, vod->ar, vod->v3d,
+ graph, vod->ar, vod->v3d,
event->mval, vod->dyn_ofs, true, fallback_depth_pt);
}
else {
@@ -1800,7 +1797,7 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf)
* \param zoom_xy: Optionally zoom to window location (coords compatible w/ #wmEvent.x, y). Use when not NULL.
*/
static void view_zoom_to_window_xy_camera(
- Scene *scene, const Depsgraph *depsgraph, View3D *v3d,
+ Scene *scene, Depsgraph *depsgraph, View3D *v3d,
ARegion *ar, float dfac, const int zoom_xy[2])
{
RegionView3D *rv3d = ar->regiondata;
@@ -2117,7 +2114,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int viewzoom_exec(bContext *C, wmOperator *op)
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d;
RegionView3D *rv3d;
@@ -2795,6 +2792,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
@@ -2826,6 +2824,8 @@ static int viewselected_exec(bContext *C, wmOperator *op)
break;
}
}
+ if (base)
+ ob = base->object;
}
if (is_gp_edit) {
@@ -2844,10 +2844,17 @@ static int viewselected_exec(bContext *C, wmOperator *op)
ok = WM_manipulatormap_minmax(ar->manipulator_map, true, true, min, max);
}
else if (obedit) {
- ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */
+ /* only selected */
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, obedit->mode, ob_iter) {
+ ok |= ED_view3d_minmax_verts(ob_iter, min, max);
+ }
+ FOREACH_OBJECT_IN_MODE_END;
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
- ok = BKE_pose_minmax(ob, min, max, true, true);
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, ob->mode, ob_iter) {
+ ok |= BKE_pose_minmax(ob_iter, min, max, true, true);
+ }
+ FOREACH_OBJECT_IN_MODE_END;
}
else if (BKE_paint_select_face_test(ob)) {
ok = paintface_minmax(ob, min, max);
@@ -2873,7 +2880,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
}
/* account for duplis */
- if (BKE_object_minmax_dupli(scene, base->object, min, max, false) == 0)
+ if (BKE_object_minmax_dupli(depsgraph, scene, base->object, min, max, false) == 0)
BKE_object_minmax(base->object, min, max, false); /* use if duplis not found */
ok = 1;
@@ -3066,18 +3073,15 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
ARegion *ar = CTX_wm_region(C);
if (rv3d) {
- EvaluationContext eval_ctx;
struct Depsgraph *graph = CTX_data_depsgraph(C);
float new_ofs[3];
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
- CTX_data_eval_ctx(C, &eval_ctx);
-
ED_view3d_smooth_view_force_finish(C, v3d, ar);
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(&eval_ctx, graph, ar, v3d, event->mval, new_ofs, false, NULL)) {
+ if (ED_view3d_autodist(graph, ar, v3d, event->mval, new_ofs, false, NULL)) {
/* pass */
}
else {
@@ -3117,7 +3121,7 @@ void VIEW3D_OT_view_center_pick(wmOperatorType *ot)
static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was view3d_home() in 2.4x */
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
float xfac, yfac;
float size[2];
@@ -3201,7 +3205,7 @@ void VIEW3D_OT_view_center_lock(wmOperatorType *ot)
static int render_border_exec(bContext *C, wmOperator *op)
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
@@ -3356,7 +3360,6 @@ void VIEW3D_OT_clear_render_border(wmOperatorType *ot)
static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -3378,8 +3381,6 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
/* note; otherwise opengl won't work */
view3d_operator_needs_opengl(C);
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* get border select values using rna */
WM_operator_properties_border_to_rcti(op, &rect);
@@ -3389,7 +3390,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
ED_view3d_dist_range_get(v3d, dist_range);
/* Get Z Depths, needed for perspective, nice for ortho */
- ED_view3d_draw_depth(&eval_ctx, CTX_data_depsgraph(C), ar, v3d, true);
+ ED_view3d_draw_depth(CTX_data_depsgraph(C), ar, v3d, true);
{
/* avoid allocating the whole depth buffer */
@@ -3529,7 +3530,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot)
* Sets the view to 1:1 camera/render-pixel.
* \{ */
-static void view3d_set_1_to_1_viewborder(Scene *scene, const Depsgraph *depsgraph, ARegion *ar, View3D *v3d)
+static void view3d_set_1_to_1_viewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View3D *v3d)
{
RegionView3D *rv3d = ar->regiondata;
float size[2];
@@ -3543,7 +3544,7 @@ static void view3d_set_1_to_1_viewborder(Scene *scene, const Depsgraph *depsgrap
static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op))
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d;
@@ -4548,13 +4549,10 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
}
if (U.uiflag & USER_DEPTH_CURSOR) { /* maybe this should be accessed some other way */
- EvaluationContext eval_ctx;
struct Depsgraph *graph = CTX_data_depsgraph(C);
- CTX_data_eval_ctx(C, &eval_ctx);
-
view3d_operator_needs_opengl(C);
- if (ED_view3d_autodist(&eval_ctx, graph, ar, v3d, mval, fp, true, NULL)) {
+ if (ED_view3d_autodist(graph, ar, v3d, mval, fp, true, NULL)) {
depth_used = true;
}
}
@@ -4604,6 +4602,8 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
else
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
+
+ DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
}
static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
@@ -4633,52 +4633,6 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Enable Transform Manipulator Operator
- * \{ */
-
-static int enable_manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- View3D *v3d = CTX_wm_view3d(C);
-
- v3d->twtype = 0;
-
- if (RNA_boolean_get(op->ptr, "translate"))
- v3d->twtype |= V3D_MANIP_TRANSLATE;
- if (RNA_boolean_get(op->ptr, "rotate"))
- v3d->twtype |= V3D_MANIP_ROTATE;
- if (RNA_boolean_get(op->ptr, "scale"))
- v3d->twtype |= V3D_MANIP_SCALE;
-
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
-
- return OPERATOR_FINISHED;
-}
-
-void VIEW3D_OT_enable_manipulator(wmOperatorType *ot)
-{
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Enable 3D Manipulator";
- ot->description = "Enable the transform manipulator for use";
- ot->idname = "VIEW3D_OT_enable_manipulator";
-
- /* api callbacks */
- ot->invoke = enable_manipulator_invoke;
- ot->poll = ED_operator_view3d_active;
-
- /* properties */
- prop = RNA_def_boolean(ot->srna, "translate", 0, "Translate", "Enable the translate manipulator");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_boolean(ot->srna, "rotate", 0, "Rotate", "Enable the rotate manipulator");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_boolean(ot->srna, "scale", 0, "Scale", "Enable the scale manipulator");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Toggle Render Shading Operator
* \{ */
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index d2aa19509d7..3715f4672d7 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -195,7 +195,7 @@ typedef struct FlyInfo {
RegionView3D *rv3d;
View3D *v3d;
ARegion *ar;
- const struct Depsgraph *depsgraph;
+ struct Depsgraph *depsgraph;
Scene *scene;
wmTimer *timer; /* needed for redraws */
@@ -346,9 +346,6 @@ enum {
static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
rctf viewborder;
@@ -425,7 +422,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
}
fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(
- &eval_ctx, fly->scene, fly->v3d, fly->rv3d,
+ CTX_data_depsgraph(C), fly->scene, fly->v3d, fly->rv3d,
(U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
/* calculate center */
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 3ed6c87b750..6038a53f8a2 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -303,6 +303,12 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
/* other buttons: */
UI_block_emboss_set(block, UI_EMBOSS);
+ /* Draw type */
+ uiItemR(layout, &v3dptr, "viewport_shade", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
+ if (v3d->drawtype == OB_SOLID) {
+ uiItemR(layout, &v3dptr, "viewport_lighting", 0, "", ICON_NONE);
+ }
+
row = uiLayoutRow(layout, true);
uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
if (!ob || ELEM(ob->mode, OB_MODE_OBJECT, OB_MODE_POSE, OB_MODE_WEIGHT_PAINT)) {
@@ -330,10 +336,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
/* Transform widget / manipulators */
row = uiLayoutRow(layout, true);
uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
- if (v3d->twflag & V3D_MANIPULATOR_DRAW) {
- uiItemR(row, &v3dptr, "transform_manipulators", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
- }
- uiItemR(row, &v3dptr, "transform_orientation", 0, "", ICON_NONE);
+ uiItemR(row, &sceneptr, "transform_orientation", 0, "", ICON_NONE);
}
if (obedit == NULL && v3d->localvd == NULL) {
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 0f56f1265bc..7e0dc20203d 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -40,6 +40,7 @@ struct ARegionType;
struct Base;
struct BoundBox;
struct Gwn_Batch;
+struct Depsgraph;
struct DerivedMesh;
struct Object;
struct SmokeDomainSettings;
@@ -62,12 +63,6 @@ enum {
DRAW_SCENESET = (1 << 2)
};
-/* draw_mesh_fancy/draw_mesh_textured draw_flags */
-enum {
- DRAW_MODIFIERS_PREVIEW = (1 << 0),
- DRAW_FACE_SELECT = (1 << 1)
-};
-
/* view3d_header.c */
void VIEW3D_OT_layers(struct wmOperatorType *ot);
@@ -104,7 +99,6 @@ void VIEW3D_OT_view_orbit(struct wmOperatorType *ot);
void VIEW3D_OT_view_roll(struct wmOperatorType *ot);
void VIEW3D_OT_clip_border(struct wmOperatorType *ot);
void VIEW3D_OT_cursor3d(struct wmOperatorType *ot);
-void VIEW3D_OT_enable_manipulator(struct wmOperatorType *ot);
void VIEW3D_OT_render_border(struct wmOperatorType *ot);
void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot);
void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
@@ -137,102 +131,28 @@ void VIEW3D_OT_walk(struct wmOperatorType *ot);
/* view3d_ruler.c */
void VIEW3D_OT_ruler(struct wmOperatorType *ot);
-/* drawanim.c */
-void draw_motion_paths_init(View3D *v3d, struct ARegion *ar);
-void draw_motion_path_instance(Scene *scene,
- struct Object *ob, struct bPoseChannel *pchan,
- struct bAnimVizSettings *avs, struct bMotionPath *mpath);
-void draw_motion_paths_cleanup(View3D *v3d);
-
-
-
/* drawobject.c */
-void draw_object(
- const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, struct ARegion *ar, View3D *v3d,
- struct Base *base, const short dflag);
-void draw_object_select(
- const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, struct ARegion *ar, View3D *v3d,
- Base *base, const short dflag);
-
-void draw_mesh_object_outline(View3D *v3d, struct Object *ob, struct DerivedMesh *dm, const unsigned char ob_wire_col[4]);
-
-bool draw_glsl_material(Scene *scene, struct ViewLayer *view_layer, struct Object *ob, View3D *v3d, const char dt);
-void draw_object_instance(const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const char dt, int outline, const float wire_col[4]);
-void draw_object_backbufsel(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob);
-
-void draw_object_wire_color(struct ViewLayer *, Base *base, unsigned char r_ob_wire_col[4]);
-void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const unsigned char color[4]);
-void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
- const char dt, const short dflag, const unsigned char ob_wire_col[4],
- const bool is_obact);
-void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
- const short dflag, const unsigned char ob_wire_col[4]);
-void drawspeaker(const unsigned char ob_wire_col[3]);
-void draw_bounding_volume(struct Object *ob, char type, const unsigned char ob_wire_col[4]);
-void draw_rigidbody_shape(struct Object *ob, const unsigned char ob_wire_col[4]);
-
-void view3d_cached_text_draw_begin(void);
-void view3d_cached_text_draw_add(const float co[3],
- const char *str, const size_t str_len,
- short xoffs, short flag, const unsigned char col[4]);
-void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write);
-
-bool check_object_draw_texture(struct Scene *scene, struct View3D *v3d, const char drawtype);
-
-enum {
- V3D_CACHE_TEXT_ZBUF = (1 << 0),
- V3D_CACHE_TEXT_WORLDSPACE = (1 << 1),
- V3D_CACHE_TEXT_ASCII = (1 << 2),
- V3D_CACHE_TEXT_GLOBALSPACE = (1 << 3),
- V3D_CACHE_TEXT_LOCALCLIP = (1 << 4)
-};
+void draw_object_backbufsel(struct Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob);
int view3d_effective_drawtype(const struct View3D *v3d);
-/* drawarmature.c */
-bool draw_armature(
- const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, View3D *v3d, ARegion *ar, Base *base,
- const short dt, const short dflag, const unsigned char ob_wire_col[4],
- const bool is_outline);
-
-/* drawmesh.c */
-void draw_mesh_textured(Scene *scene, struct ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d,
- struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
-void draw_mesh_face_select(
- struct RegionView3D *rv3d, struct Mesh *me, struct DerivedMesh *dm,
- bool draw_select_edges);
-void draw_mesh_paint_weight_faces(struct DerivedMesh *dm, const bool do_light,
- void *facemask_cb, void *user_data);
-void draw_mesh_paint_vcolor_faces(struct DerivedMesh *dm, const bool use_light,
- void *facemask_cb, void *user_data,
- const struct Mesh *me);
-void draw_mesh_paint_weight_edges(RegionView3D *rv3d, struct DerivedMesh *dm,
- const bool use_depth, const bool use_alpha,
- void *edgemask_cb, void *user_data);
-void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
- struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
-
-/* drawsimdebug.c */
-void draw_sim_debug_data(Scene *scene, View3D *v3d, ARegion *ar);
-
/* view3d_draw.c */
void view3d_main_region_draw(const struct bContext *C, struct ARegion *ar);
void view3d_draw_region_info(const struct bContext *C, struct ARegion *ar, const int offset);
void ED_view3d_draw_depth(
- const struct EvaluationContext *eval_ctx, struct Depsgraph *graph,
+ struct Depsgraph *depsgraph,
struct ARegion *ar, View3D *v3d, bool alphaoverride);
/* view3d_draw_legacy.c */
-void view3d_main_region_draw_legacy(const struct bContext *C, struct ARegion *ar);
-void ED_view3d_draw_depth_gpencil(const struct EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d);
+void ED_view3d_draw_depth_gpencil(struct Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d);
void ED_view3d_draw_select_loop(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, Scene *scene, struct ViewLayer *view_layer, View3D *v3d, ARegion *ar,
+ struct Depsgraph *depsgraph, ViewContext *vc, Scene *scene, struct ViewLayer *view_layer, View3D *v3d, ARegion *ar,
bool use_obedit_skip, bool use_nearest);
void ED_view3d_draw_depth_loop(
- const struct EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d);
+ struct Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d);
void ED_view3d_after_add(ListBase *lb, Base *base, const short dflag);
@@ -250,8 +170,6 @@ void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
void VIEW3D_OT_camera_to_view(struct wmOperatorType *ot);
void VIEW3D_OT_camera_to_view_selected(struct wmOperatorType *ot);
void VIEW3D_OT_object_as_camera(struct wmOperatorType *ot);
-void VIEW3D_OT_game_start(struct wmOperatorType *ot);
-
bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const struct BoundBox *bb, float obmat[4][4]);
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb);
@@ -278,10 +196,10 @@ void ED_view3d_smooth_view_force_finish(
struct View3D *v3d, struct ARegion *ar);
void view3d_winmatrix_set(
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
ARegion *ar, const View3D *v3d, const rcti *rect);
void view3d_viewmatrix_set(
- const struct EvaluationContext *eval_ctx, Scene *scene,
+ struct Depsgraph *depsgraph, Scene *scene,
const View3D *v3d, RegionView3D *rv3d, const float rect_scale[2]);
void fly_modal_keymap(struct wmKeyConfig *keyconf);
@@ -297,7 +215,7 @@ void view3d_buttons_register(struct ARegionType *art);
/* view3d_camera_control.c */
struct View3DCameraControl *ED_view3d_cameracontrol_acquire(
- const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d,
+ struct Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d,
const bool use_parent_root);
void ED_view3d_cameracontrol_update(
struct View3DCameraControl *vctrl,
@@ -366,31 +284,4 @@ extern unsigned char view3d_camera_border_hack_col[3];
extern bool view3d_camera_border_hack_test;
#endif
-/* temporary for legacy viewport to work */
-void VP_legacy_drawcursor(Scene *scene, struct ViewLayer *view_layer, ARegion *ar, View3D *v3d);
-void VP_legacy_draw_view_axis(RegionView3D *rv3d, const rcti *rect);
-void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect);
-void VP_legacy_draw_selected_name(Scene *scene, struct Object *ob, rcti *rect);
-void VP_legacy_drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit);
-void VP_legacy_drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool write_depth);
-void VP_legacy_view3d_main_region_setup_view(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4]);
-bool VP_legacy_view3d_stereo3d_active(struct wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d);
-void VP_legacy_view3d_stereo3d_setup(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar);
-void draw_dupli_objects(const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, Base *base);
-bool VP_legacy_use_depth(View3D *v3d, struct Object *obedit);
-void VP_drawviewborder(Scene *scene, const struct Depsgraph *depsgraph, ARegion *ar, View3D *v3d);
-void VP_drawrenderborder(ARegion *ar, View3D *v3d);
-void VP_view3d_draw_background_none(void);
-void VP_view3d_draw_background_world(Scene *scene, RegionView3D *rv3d);
-void VP_view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar);
-
-/* temporary legacy calls, only when there is a switch between new/old draw calls */
-void VP_deprecated_gpu_update_lamps_shadows_world(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d);
-void VP_deprecated_view3d_draw_objects(
- const struct bContext *C,
- const struct EvaluationContext *eval_ctx,
- Scene *scene, View3D *v3d, ARegion *ar,
- const char **grid_unit,
- const bool do_bgpic, const bool draw_offscreen);
-
#endif /* __VIEW3D_INTERN_H__ */
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index d3bee637fd7..99c67172dc5 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -110,14 +110,14 @@ static void meshobject_foreachScreenVert__mapFunc(void *userData, int index, con
}
void meshobject_foreachScreenVert(
- const EvaluationContext *eval_ctx, ViewContext *vc,
+ ViewContext *vc,
void (*func)(void *userData, MVert *eve, const float screen_co[2], int index),
void *userData, eV3DProjTest clip_flag)
{
foreachScreenObjectVert_userData data;
DerivedMesh *dm;
- dm = mesh_get_derived_deform(eval_ctx, vc->scene, vc->obact, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_deform(vc->depsgraph, vc->scene, vc->obact, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -153,14 +153,14 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const flo
}
void mesh_foreachScreenVert(
- const EvaluationContext *eval_ctx, ViewContext *vc,
+ ViewContext *vc,
void (*func)(void *userData, BMVert *eve, const float screen_co[2], int index),
void *userData, eV3DProjTest clip_flag)
{
foreachScreenVert_userData data;
DerivedMesh *dm;
- dm = editbmesh_get_derived_cage(eval_ctx, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ dm = editbmesh_get_derived_cage(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -209,14 +209,14 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const flo
}
void mesh_foreachScreenEdge(
- const EvaluationContext *eval_ctx, ViewContext *vc,
+ ViewContext *vc,
void (*func)(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index),
void *userData, eV3DProjTest clip_flag)
{
foreachScreenEdge_userData data;
DerivedMesh *dm;
- dm = editbmesh_get_derived_cage(eval_ctx, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ dm = editbmesh_get_derived_cage(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -257,14 +257,14 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const flo
}
void mesh_foreachScreenFace(
- const EvaluationContext *eval_ctx, ViewContext *vc,
+ ViewContext *vc,
void (*func)(void *userData, BMFace *efa, const float screen_co_b[2], int index),
void *userData, const eV3DProjTest clip_flag)
{
foreachScreenFace_userData data;
DerivedMesh *dm;
- dm = editbmesh_get_derived_cage(eval_ctx, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ dm = editbmesh_get_derived_cage(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
index c3f8d92ed7f..06ac2f83ea7 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
@@ -143,9 +143,10 @@ static void axis_geom_draw(
madd_v3_v3fl(
center,
(float [3]){
- mpr->matrix_offset[0][2],
- mpr->matrix_offset[1][2],
- mpr->matrix_offset[2][2]},
+ mpr->matrix_offset[0][2],
+ mpr->matrix_offset[1][2],
+ mpr->matrix_offset[2][2],
+ },
0.08f);
imm_draw_cube_wire_3d(pos_id, center, size);
glDisable(GL_BLEND);
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
index f9955f29774..eedc346db1d 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
@@ -277,7 +277,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
}
else if (state == RULER_STATE_DRAG) {
ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), CTX_data_scene(C), CTX_data_view_layer(C), 0,
+ CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ruler_info->ar, CTX_wm_view3d(C));
}
else {
@@ -924,8 +924,8 @@ static void manipulator_ruler_exit(bContext *C, wmManipulator *mpr, const bool c
ruler_item->flag &= ~RULERITEM_USE_ANGLE;
}
else {
- /* Not ideal, since the ruler isn't a mode and we don't want to override delete key
- * use dragging out of the view for removal. */
+ /* Not ideal, since the ruler isn't a mode and we don't want to override delete key
+ * use dragging out of the view for removal. */
ruler_item_remove(C, mgroup, ruler_item);
ruler_item = NULL;
mpr = NULL;
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 8e6f5228b09..2e0ca07f601 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -196,14 +196,12 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_render_border);
WM_operatortype_append(VIEW3D_OT_clear_render_border);
WM_operatortype_append(VIEW3D_OT_zoom_border);
- WM_operatortype_append(VIEW3D_OT_enable_manipulator);
WM_operatortype_append(VIEW3D_OT_cursor3d);
WM_operatortype_append(VIEW3D_OT_select_lasso);
WM_operatortype_append(VIEW3D_OT_select_menu);
WM_operatortype_append(VIEW3D_OT_camera_to_view);
WM_operatortype_append(VIEW3D_OT_camera_to_view_selected);
WM_operatortype_append(VIEW3D_OT_object_as_camera);
- WM_operatortype_append(VIEW3D_OT_game_start);
WM_operatortype_append(VIEW3D_OT_fly);
WM_operatortype_append(VIEW3D_OT_walk);
WM_operatortype_append(VIEW3D_OT_navigate);
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index ba3e78b25b9..eb86800f4a9 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -309,7 +309,7 @@ float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3], bool *r_f
}
static void view3d_win_to_ray_segment(
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
const ARegion *ar, const View3D *v3d, const float mval[2],
float r_ray_co[3], float r_ray_dir[3], float r_ray_start[3], float r_ray_end[3])
{
@@ -366,7 +366,7 @@ bool ED_view3d_clip_segment(const RegionView3D *rv3d, float ray_start[3], float
* \return success, false if the ray is totally clipped.
*/
bool ED_view3d_win_to_ray_ex(
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
const ARegion *ar, const View3D *v3d, const float mval[2],
float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip)
{
@@ -396,11 +396,11 @@ bool ED_view3d_win_to_ray_ex(
* \return success, false if the ray is totally clipped.
*/
bool ED_view3d_win_to_ray(
- const struct Depsgraph *depsgraph,
+ struct Depsgraph *depsgraph,
const ARegion *ar, const View3D *v3d, const float mval[2],
float r_ray_start[3], float r_ray_normal[3], const bool do_clip)
{
- return ED_view3d_win_to_ray_ex(depsgraph,ar, v3d, mval, NULL, r_ray_normal, r_ray_start, do_clip);
+ return ED_view3d_win_to_ray_ex(depsgraph, ar, v3d, mval, NULL, r_ray_normal, r_ray_start, do_clip);
}
/**
@@ -630,7 +630,7 @@ void ED_view3d_win_to_vector(const ARegion *ar, const float mval[2], float out[3
* \param do_clip Optionally clip the ray by the view clipping planes.
* \return success, false if the segment is totally clipped.
*/
-bool ED_view3d_win_to_segment(const struct Depsgraph *depsgraph,
+bool ED_view3d_win_to_segment(struct Depsgraph *depsgraph,
const ARegion *ar, View3D *v3d, const float mval[2],
float r_ray_start[3], float r_ray_end[3], const bool do_clip)
{
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index f61aad2806e..6706a98ba55 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -282,7 +282,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
}
else if (state == RULER_STATE_DRAG) {
ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), CTX_data_scene(C), CTX_data_view_layer(C), 0,
+ CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ruler_info->ar, CTX_wm_view3d(C));
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 21219bced3c..04cdf9778ba 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -48,6 +48,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_array.h"
#include "BLI_math.h"
#include "BLI_lasso_2d.h"
#include "BLI_rect.h"
@@ -56,6 +57,10 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
+#ifdef __BIG_ENDIAN__
+# include "BLI_endian_switch.h"
+#endif
+
/* vertex box select */
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -117,7 +122,6 @@ void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc)
vc->depsgraph = CTX_data_depsgraph(C);
vc->scene = CTX_data_scene(C);
vc->view_layer = CTX_data_view_layer(C);
- vc->engine_type = CTX_data_engine_type(C);
vc->v3d = CTX_wm_view3d(C);
vc->win = CTX_wm_window(C);
vc->rv3d = CTX_wm_region_view3d(C);
@@ -125,6 +129,21 @@ void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc)
vc->obedit = CTX_data_edit_object(C);
}
+void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact)
+{
+ vc->obact = obact;
+ if (vc->obedit) {
+ BLI_assert(BKE_object_is_in_editmode(obact));
+ vc->obedit = obact;
+ /* previous selections are now invalid. */
+ vc->v3d->flag |= V3D_INVALID_BACKBUF;
+
+ if (vc->em) {
+ vc->em = BKE_editmesh_from_object(vc->obedit);
+ }
+ }
+}
+
/* ********************** view3d_select: selection manipulations ********************* */
/* local prototypes */
@@ -397,6 +416,7 @@ static void do_lasso_select_objects(
ViewContext *vc, const int mcords[][2], const short moves,
const bool extend, const bool select)
{
+ bool is_pose_mode = vc->obact ? (vc->obact->mode & OB_MODE_POSE) : false;
Base *base;
if (extend == false && select)
@@ -410,7 +430,10 @@ static void do_lasso_select_objects(
ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
}
}
- if (vc->obact == base->object && (base->object->mode & OB_MODE_POSE)) {
+ if (is_pose_mode &&
+ ((vc->obact == base->object) || (base->flag & BASE_SELECTED)) &&
+ (base->object->mode & OB_MODE_POSE))
+ {
do_lasso_select_pose(vc, base->object, mcords, moves, select);
}
}
@@ -466,7 +489,7 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, cons
}
static void do_lasso_select_mesh(
- const struct EvaluationContext *eval_ctx, ViewContext *vc,
+ ViewContext *vc,
const int mcords[][2], short moves, bool extend, bool select)
{
LassoSelectUserData data;
@@ -488,24 +511,24 @@ static void do_lasso_select_mesh(
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
gpuLoadMatrix(vc->rv3d->viewmat);
- bbsel = EDBM_backbuf_border_mask_init(eval_ctx, vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
edbm_backbuf_check_and_select_verts(vc->em, select);
}
else {
- mesh_foreachScreenVert(eval_ctx, vc, do_lasso_select_mesh__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenVert(vc, do_lasso_select_mesh__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both bbsel and non-bbsel versions (need screen cos for both) */
data.pass = 0;
- mesh_foreachScreenEdge(eval_ctx, vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
if (data.is_done == false) {
data.pass = 1;
- mesh_foreachScreenEdge(eval_ctx, vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
}
}
@@ -514,7 +537,7 @@ static void do_lasso_select_mesh(
edbm_backbuf_check_and_select_faces(vc->em, select);
}
else {
- mesh_foreachScreenFace(eval_ctx, vc, do_lasso_select_mesh__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -703,14 +726,14 @@ static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], sho
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
if (extend == false && select)
- ED_armature_deselect_all_visible(vc->obedit);
+ ED_armature_edit_deselect_all_visible(vc->obedit);
armature_foreachScreenBone(vc, do_lasso_select_armature__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
if (data.is_changed) {
bArmature *arm = vc->obedit->data;
- ED_armature_sync_selection(arm->edbo);
- ED_armature_validate_active(arm);
+ ED_armature_edit_sync_selection(arm->edbo);
+ ED_armature_edit_validate_active(arm);
WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit);
}
}
@@ -756,7 +779,7 @@ static void do_lasso_select_meshobject__doSelectVert(void *userData, MVert *mv,
SET_FLAG_FROM_TEST(mv->flag, data->select, SELECT);
}
}
-static void do_lasso_select_paintvert(const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
+static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
{
const bool use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT) != 0;
Object *ob = vc->obact;
@@ -774,7 +797,7 @@ static void do_lasso_select_paintvert(const struct EvaluationContext *eval_ctx,
if (use_zbuf) {
bm_vertoffs = me->totvert + 1; /* max index array */
- EDBM_backbuf_border_mask_init(eval_ctx, vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
edbm_backbuf_check_and_select_verts_obmode(me, select);
@@ -787,7 +810,7 @@ static void do_lasso_select_paintvert(const struct EvaluationContext *eval_ctx,
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d);
- meshobject_foreachScreenVert(eval_ctx, vc, do_lasso_select_meshobject__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ meshobject_foreachScreenVert(vc, do_lasso_select_meshobject__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
@@ -796,7 +819,7 @@ static void do_lasso_select_paintvert(const struct EvaluationContext *eval_ctx,
}
paintvert_flush_flags(ob);
}
-static void do_lasso_select_paintface(const struct EvaluationContext *eval_ctx, ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
+static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select)
{
Object *ob = vc->obact;
Mesh *me = ob->data;
@@ -811,7 +834,7 @@ static void do_lasso_select_paintface(const struct EvaluationContext *eval_ctx,
bm_vertoffs = me->totpoly + 1; /* max index array */
BLI_lasso_boundbox(&rect, mcords, moves);
- EDBM_backbuf_border_mask_init(eval_ctx, vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
edbm_backbuf_check_and_select_tfaces(me, select);
@@ -858,15 +881,12 @@ static void view3d_lasso_select(
{
Object *ob = CTX_data_active_object(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (vc->obedit == NULL) { /* Object Mode */
if (BKE_paint_select_face_test(ob)) {
- do_lasso_select_paintface(&eval_ctx, vc, mcords, moves, extend, select);
+ do_lasso_select_paintface(vc, mcords, moves, extend, select);
}
else if (BKE_paint_select_vert_test(ob)) {
- do_lasso_select_paintvert(&eval_ctx, vc, mcords, moves, extend, select);
+ do_lasso_select_paintvert(vc, mcords, moves, extend, select);
}
else if (ob && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
/* pass */
@@ -880,32 +900,38 @@ static void view3d_lasso_select(
}
}
else { /* Edit Mode */
- switch (vc->obedit->type) {
- case OB_MESH:
- do_lasso_select_mesh(&eval_ctx, vc, mcords, moves, extend, select);
- break;
- case OB_CURVE:
- case OB_SURF:
- do_lasso_select_curve(vc, mcords, moves, extend, select);
- break;
- case OB_LATTICE:
- do_lasso_select_lattice(vc, mcords, moves, extend, select);
- break;
- case OB_ARMATURE:
- do_lasso_select_armature(vc, mcords, moves, extend, select);
- break;
- case OB_MBALL:
- do_lasso_select_meta(vc, mcords, moves, extend, select);
- break;
+
+ FOREACH_OBJECT_IN_MODE_BEGIN (vc->view_layer, ob->mode, ob_iter) {
+ ED_view3d_viewcontext_init_object(vc, ob_iter);
+
+ switch (vc->obedit->type) {
+ case OB_MESH:
+ do_lasso_select_mesh(vc, mcords, moves, extend, select);
+ break;
+ case OB_CURVE:
+ case OB_SURF:
+ do_lasso_select_curve(vc, mcords, moves, extend, select);
+ break;
+ case OB_LATTICE:
+ do_lasso_select_lattice(vc, mcords, moves, extend, select);
+ break;
+ case OB_ARMATURE:
+ do_lasso_select_armature(vc, mcords, moves, extend, select);
+ break;
+ case OB_MBALL:
+ do_lasso_select_meta(vc, mcords, moves, extend, select);
+ break;
case OB_GROOM:
do_lasso_select_groom(vc, mcords, moves, extend, select);
break;
- default:
- assert(!"lasso select on incorrect object type");
- break;
- }
+ default:
+ assert(!"lasso select on incorrect object type");
+ break;
+ }
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc->obedit->data);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc->obedit->data);
+ }
+ FOREACH_OBJECT_IN_MODE_END;
}
}
@@ -1187,7 +1213,7 @@ static int selectbuffer_ret_hits_5(unsigned int *buffer, const int hits15, const
/* we want a select buffer with bones, if there are... */
/* so check three selection levels and compare */
static int mixed_bones_object_selectbuffer(
- const EvaluationContext *eval_ctx, ViewContext *vc, unsigned int *buffer, const int mval[2],
+ ViewContext *vc, unsigned int *buffer, const int mval[2],
bool use_cycle, bool enumerate,
bool *r_do_nearest)
{
@@ -1227,7 +1253,7 @@ static int mixed_bones_object_selectbuffer(
view3d_opengl_select_cache_begin();
BLI_rcti_init_pt_radius(&rect, mval, 14);
- hits15 = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, &rect, select_mode);
+ hits15 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode);
if (hits15 == 1) {
hits = selectbuffer_ret_hits_15(buffer, hits15);
goto finally;
@@ -1238,7 +1264,7 @@ static int mixed_bones_object_selectbuffer(
offs = 4 * hits15;
BLI_rcti_init_pt_radius(&rect, mval, 9);
- hits9 = view3d_opengl_select(eval_ctx, vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
+ hits9 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
if (hits9 == 1) {
hits = selectbuffer_ret_hits_9(buffer, hits15, hits9);
goto finally;
@@ -1248,7 +1274,7 @@ static int mixed_bones_object_selectbuffer(
offs += 4 * hits9;
BLI_rcti_init_pt_radius(&rect, mval, 5);
- hits5 = view3d_opengl_select(eval_ctx, vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
+ hits5 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode);
if (hits5 == 1) {
hits = selectbuffer_ret_hits_5(buffer, hits15, hits9, hits5);
goto finally;
@@ -1361,7 +1387,6 @@ static Base *mouse_select_eval_buffer(
/* mval comes from event->mval, only use within region handlers */
Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2])
{
- EvaluationContext eval_ctx;
ViewContext vc;
Base *basact = NULL;
unsigned int buffer[MAXPICKBUF];
@@ -1371,10 +1396,9 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2])
/* setup view context for argument to callbacks */
view3d_operator_needs_opengl(C);
- CTX_data_eval_ctx(C, &eval_ctx);
ED_view3d_viewcontext_init(C, &vc);
- hits = mixed_bones_object_selectbuffer(&eval_ctx, &vc, buffer, mval, false, false, &do_nearest);
+ hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, false, false, &do_nearest);
if (hits > 0) {
const bool has_bones = selectbuffer_has_bones(buffer, hits);
@@ -1408,7 +1432,6 @@ static bool ed_object_select_pick(
bContext *C, const int mval[2],
bool extend, bool deselect, bool toggle, bool obcenter, bool enumerate, bool object)
{
- EvaluationContext eval_ctx;
ViewContext vc;
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
@@ -1422,7 +1445,6 @@ static bool ed_object_select_pick(
/* setup view context for argument to callbacks */
- CTX_data_eval_ctx(C, &eval_ctx);
ED_view3d_viewcontext_init(C, &vc);
is_obedit = (vc.obedit != NULL);
@@ -1430,7 +1452,10 @@ static bool ed_object_select_pick(
/* signal for view3d_opengl_select to skip editmode objects */
vc.obedit = NULL;
}
-
+
+ /* In pose mode we don't want to mess with object selection. */
+ const bool is_pose_mode = (vc.obact && vc.obact->mode & OB_MODE_POSE);
+
/* always start list from basact in wire mode */
startbase = FIRSTBASE(view_layer);
if (BASACT(view_layer) && BASACT(view_layer)->next) startbase = BASACT(view_layer)->next;
@@ -1474,7 +1499,7 @@ static bool ed_object_select_pick(
// TIMEIT_START(select_time);
/* if objects have posemode set, the bones are in the same selection buffer */
- hits = mixed_bones_object_selectbuffer(&eval_ctx, &vc, buffer, mval, true, enumerate, &do_nearest);
+ hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, true, enumerate, &do_nearest);
// TIMEIT_END(select_time);
@@ -1549,7 +1574,9 @@ static bool ed_object_select_pick(
}
}
}
- else if (ED_do_pose_selectbuffer(view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest)) {
+ else if (ED_armature_pose_select_pick_with_buffer(
+ view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest))
+ {
/* then bone is found */
/* we make the armature selected:
@@ -1606,8 +1633,11 @@ static bool ed_object_select_pick(
}
}
else {
- deselectall_except(view_layer, basact);
- ED_object_base_select(basact, BA_SELECT);
+ /* When enabled, this puts other objects out of multi pose-mode. */
+ if (is_pose_mode == false) {
+ deselectall_except(view_layer, basact);
+ ED_object_base_select(basact, BA_SELECT);
+ }
}
if ((oldbasact != basact) && (is_obedit == false)) {
@@ -1669,7 +1699,7 @@ static void do_paintvert_box_select__doSelectVert(void *userData, MVert *mv, con
}
}
static int do_paintvert_box_select(
- const EvaluationContext *eval_ctx, ViewContext *vc, rcti *rect, bool select, bool extend)
+ ViewContext *vc, rcti *rect, bool select, bool extend)
{
const bool use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT) != 0;
Mesh *me;
@@ -1693,7 +1723,7 @@ static int do_paintvert_box_select(
if (use_zbuf) {
selar = MEM_callocN(me->totvert + 1, "selar");
- ED_view3d_backbuf_validate(eval_ctx, vc);
+ ED_view3d_backbuf_validate(vc);
ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect);
rt = ibuf->rect;
@@ -1741,7 +1771,7 @@ static int do_paintvert_box_select(
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d);
- meshobject_foreachScreenVert(eval_ctx, vc, do_paintvert_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ meshobject_foreachScreenVert(vc, do_paintvert_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
if (select == false) {
@@ -1900,7 +1930,7 @@ static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, const
}
}
static int do_mesh_box_select(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, rcti *rect, bool select, bool extend)
+ ViewContext *vc, rcti *rect, bool select, bool extend)
{
BoxSelectUserData data;
ToolSettings *ts = vc->scene->toolsettings;
@@ -1915,25 +1945,25 @@ static int do_mesh_box_select(
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
gpuLoadMatrix(vc->rv3d->viewmat);
- bbsel = EDBM_backbuf_border_init(eval_ctx, vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ bbsel = EDBM_backbuf_border_init(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
edbm_backbuf_check_and_select_verts(vc->em, select);
}
else {
- mesh_foreachScreenVert(eval_ctx, vc, do_mesh_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenVert(vc, do_mesh_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both bbsel and non-bbsel versions (need screen cos for both) */
data.pass = 0;
- mesh_foreachScreenEdge(eval_ctx, vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
if (data.is_done == 0) {
data.pass = 1;
- mesh_foreachScreenEdge(eval_ctx, vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
}
}
@@ -1942,7 +1972,7 @@ static int do_mesh_box_select(
edbm_backbuf_check_and_select_faces(vc->em, select);
}
else {
- mesh_foreachScreenFace(eval_ctx, vc, do_mesh_box_select__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -1954,7 +1984,7 @@ static int do_mesh_box_select(
}
static int do_meta_box_select(
- const struct EvaluationContext *eval_ctx, ViewContext *vc,
+ ViewContext *vc,
const rcti *rect, bool select, bool extend)
{
MetaBall *mb = (MetaBall *)vc->obedit->data;
@@ -1964,7 +1994,7 @@ static int do_meta_box_select(
unsigned int buffer[MAXPICKBUF];
int hits;
- hits = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL);
+ hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL);
if (extend == false && select)
BKE_mball_deselect_all(mb);
@@ -1990,40 +2020,49 @@ static int do_meta_box_select(
}
static int do_armature_box_select(
- const struct EvaluationContext *eval_ctx, ViewContext *vc,
+ ViewContext *vc,
const rcti *rect, bool select, bool extend)
{
- bArmature *arm = vc->obedit->data;
- EditBone *ebone;
int a;
unsigned int buffer[MAXPICKBUF];
int hits;
- hits = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL);
-
+ hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL);
+
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc->view_layer, &objects_len);
+
/* clear flag we use to detect point was affected */
- for (ebone = arm->edbo->first; ebone; ebone = ebone->next)
- ebone->flag &= ~BONE_DONE;
-
- if (extend == false && select)
- ED_armature_deselect_all_visible(vc->obedit);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ bArmature *arm = obedit->data;
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ ebone->flag &= ~BONE_DONE;
+ }
+ }
+
+ if (extend == false && select) {
+ ED_armature_edit_deselect_all_visible_multi(objects, objects_len);
+ }
/* first we only check points inside the border */
for (a = 0; a < hits; a++) {
int index = buffer[(4 * a) + 3];
if (index != -1) {
- ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
if ((index & 0xFFFF0000) == 0) {
continue;
}
+
+ EditBone *ebone;
+ ED_armature_object_and_ebone_from_select_buffer(objects, objects_len, index, &ebone);
if ((select == false) || ((ebone->flag & BONE_UNSELECTABLE) == 0)) {
if (index & BONESEL_TIP) {
ebone->flag |= BONE_DONE;
if (select) ebone->flag |= BONE_TIPSEL;
else ebone->flag &= ~BONE_TIPSEL;
}
-
+
if (index & BONESEL_ROOT) {
ebone->flag |= BONE_DONE;
if (select) ebone->flag |= BONE_ROOTSEL;
@@ -2032,35 +2071,49 @@ static int do_armature_box_select(
}
}
}
-
+
/* now we have to flush tag from parents... */
- for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
- if (ebone->parent->flag & BONE_DONE)
- ebone->flag |= BONE_DONE;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ bArmature *arm = obedit->data;
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
+ if (ebone->parent->flag & BONE_DONE) {
+ ebone->flag |= BONE_DONE;
+ }
+ }
}
}
-
+
/* only select/deselect entire bones when no points where in the rect */
for (a = 0; a < hits; a++) {
int index = buffer[(4 * a) + 3];
if (index != -1) {
- ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
if (index & BONESEL_BONE) {
+ EditBone *ebone;
+ ED_armature_object_and_ebone_from_select_buffer(objects, objects_len, index, &ebone);
if ((select == false) || ((ebone->flag & BONE_UNSELECTABLE) == 0)) {
if (!(ebone->flag & BONE_DONE)) {
- if (select)
+ if (select) {
ebone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED);
- else
+ }
+ else {
ebone->flag &= ~(BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED);
+ }
}
}
}
}
}
-
- ED_armature_sync_selection(arm->edbo);
-
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ bArmature *arm = obedit->data;
+ ED_armature_edit_sync_selection(arm->edbo);
+ }
+
+ MEM_freeN(objects);
+
return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -2068,11 +2121,16 @@ static int do_armature_box_select(
* Compare result of 'GPU_select': 'uint[4]',
* needed for when we need to align with object draw-order.
*/
-static int opengl_select_buffer_cmp(const void *sel_a_p, const void *sel_b_p)
+static int opengl_bone_select_buffer_cmp(const void *sel_a_p, const void *sel_b_p)
{
/* 4th element is select id */
- const uint sel_a = ((uint *)sel_a_p)[3];
- const uint sel_b = ((uint *)sel_b_p)[3];
+ uint sel_a = ((uint *)sel_a_p)[3];
+ uint sel_b = ((uint *)sel_b_p)[3];
+
+#ifdef __BIG_ENDIAN__
+ BLI_endian_switch_uint32(&sel_a);
+ BLI_endian_switch_uint32(&sel_b);
+#endif
if (sel_a < sel_b) {
return -1;
@@ -2087,32 +2145,29 @@ static int opengl_select_buffer_cmp(const void *sel_a_p, const void *sel_b_p)
static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, bool select, bool extend)
{
- EvaluationContext eval_ctx;
- Bone *bone;
- Object *ob = vc->obact;
unsigned int *vbuffer = NULL; /* selection buffer */
- unsigned int *col; /* color in buffer */
int bone_only;
- int bone_selected = 0;
int totobj = MAXPICKBUF; /* XXX solve later */
int hits;
- CTX_data_eval_ctx(C, &eval_ctx);
-
- if ((ob) && (ob->mode & OB_MODE_POSE))
+ if (vc->obact && (vc->obact->mode & OB_MODE_POSE))
bone_only = 1;
else
bone_only = 0;
if (extend == false && select) {
if (bone_only) {
- CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
- {
- if ((select == false) || ((pchan->bone->flag & BONE_UNSELECTABLE) == 0)) {
- pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ FOREACH_OBJECT_IN_MODE_BEGIN (vc->view_layer, OB_MODE_POSE, ob_iter) {
+ bArmature *arm = ob_iter->data;
+ for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (PBONE_VISIBLE(arm, pchan->bone)) {
+ if ((select == false) || ((pchan->bone->flag & BONE_UNSELECTABLE) == 0)) {
+ pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
+ }
}
}
- CTX_DATA_END;
+ FOREACH_OBJECT_IN_MODE_END;
}
else {
object_deselect_all_visible(vc->view_layer);
@@ -2121,7 +2176,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
/* selection buffer now has bones potentially too, so we add MAXPICKBUF */
vbuffer = MEM_mallocN(4 * (totobj + MAXPICKELEMS) * sizeof(unsigned int), "selection buffer");
- hits = view3d_opengl_select(&eval_ctx, vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL);
+ hits = view3d_opengl_select(vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL);
/*
* LOGIC NOTES (theeth):
* The buffer and ListBase have the same relative order, which makes the selection
@@ -2132,60 +2187,83 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
*/
if (hits > 0) { /* no need to loop if there's no hit */
- Base *base;
- col = vbuffer + 3;
/* The draw order doesn't always match the order we populate the engine, see: T51695. */
- qsort(vbuffer, hits, sizeof(uint[4]), opengl_select_buffer_cmp);
+ qsort(vbuffer, hits, sizeof(uint[4]), opengl_bone_select_buffer_cmp);
- /*
- * Even though 'DRW_draw_select_loop' uses 'DEG_OBJECT_ITER_BEGIN',
- * we can be sure the order remains the same between both.
- */
- for (base = vc->view_layer->object_bases.first; base && hits; base = base->next) {
+ Base **bases = NULL;
+ BLI_array_declare(bases);
+
+ for (Base *base = vc->view_layer->object_bases.first; base && hits; base = base->next) {
if (BASE_SELECTABLE(base)) {
- while (base->object->select_color == (*col & 0xFFFF)) { /* we got an object */
- if (*col & 0xFFFF0000) { /* we got a bone */
- bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY));
- if (bone) {
- if (select) {
- if ((bone->flag & BONE_UNSELECTABLE) == 0) {
- bone->flag |= BONE_SELECTED;
- bone_selected = 1;
- }
- }
- else {
- bArmature *arm = base->object->data;
- bone->flag &= ~BONE_SELECTED;
- if (arm->act_bone == bone)
- arm->act_bone = NULL;
- }
+ if ((base->object->select_color & 0x0000FFFF) != 0) {
+ BLI_array_append(bases, base);
+ }
+ }
+ }
+
+ for (const uint *col = vbuffer + 3, *col_end = col + (hits * 4); col < col_end; col += 4) {
+ Bone *bone;
+ Base *base = ED_armature_base_and_bone_from_select_buffer(bases, BLI_array_len(bases), *col, &bone);
+
+ if (base == NULL) {
+ continue;
+ }
+ /* Loop over contiguous bone hits for 'base'. */
+ bool bone_selected = false;
+ for (; col != col_end; col += 4) {
+ /* should never fail */
+ if (bone != NULL) {
+ if (select) {
+ if ((bone->flag & BONE_UNSELECTABLE) == 0) {
+ bone->flag |= BONE_SELECTED;
+ bone_selected = true;
}
}
- else if (!bone_only) {
- ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
+ else {
+ bArmature *arm = base->object->data;
+ bone->flag &= ~BONE_SELECTED;
+ if (arm->act_bone == bone)
+ arm->act_bone = NULL;
+ }
+ }
+ else if (!bone_only) {
+ ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
+ }
+
+ /* Select the next bone if we're not switching bases. */
+ if (col + 4 != col_end) {
+ if ((base->object->select_color & 0x0000FFFF) != (col[4] & 0x0000FFFF)) {
+ break;
+ }
+
+ if ((base->object->pose != NULL) && bone_only) {
+ const uint hit_bone = (col[4] & ~BONESEL_ANY) >> 16;
+ bPoseChannel *pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone);;
+ bone = pchan ? pchan->bone : NULL;
+ }
+ else {
+ bone = NULL;
}
-
- col += 4; /* next color */
- hits--;
- if (hits == 0) break;
}
}
-
+
if (bone_selected) {
if (base->object && (base->object->type == OB_ARMATURE)) {
bArmature *arm = base->object->data;
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object);
-
- if (arm && (arm->flag & ARM_HAS_VIZ_DEPS)) {
+
+ if (vc->obact && arm && (arm->flag & ARM_HAS_VIZ_DEPS)) {
/* mask modifier ('armature' mode), etc. */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&vc->obact->id, OB_RECALC_DATA);
}
}
}
}
-
+
+ MEM_freeN(bases);
+
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene);
}
MEM_freeN(vbuffer);
@@ -2195,7 +2273,6 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
static int view3d_borderselect_exec(bContext *C, wmOperator *op)
{
- EvaluationContext eval_ctx;
ViewContext vc;
rcti rect;
bool extend;
@@ -2206,7 +2283,6 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
view3d_operator_needs_opengl(C);
/* setup view context for argument to callbacks */
- CTX_data_eval_ctx(C, &eval_ctx);
ED_view3d_viewcontext_init(C, &vc);
select = !RNA_boolean_get(op->ptr, "deselect");
@@ -2214,69 +2290,81 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rcti(op, &rect);
if (vc.obedit) {
- switch (vc.obedit->type) {
- case OB_MESH:
- vc.em = BKE_editmesh_from_object(vc.obedit);
- ret = do_mesh_box_select(&eval_ctx, &vc, &rect, select, extend);
-// if (EM_texFaceCheck())
- if (ret & OPERATOR_FINISHED) {
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
- }
- break;
- case OB_CURVE:
- case OB_SURF:
- ret = do_nurbs_box_select(&vc, &rect, select, extend);
- if (ret & OPERATOR_FINISHED) {
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
- }
- break;
- case OB_MBALL:
- ret = do_meta_box_select(&eval_ctx, &vc, &rect, select, extend);
- if (ret & OPERATOR_FINISHED) {
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
- }
- break;
- case OB_ARMATURE:
- ret = do_armature_box_select(&eval_ctx, &vc, &rect, select, extend);
- if (ret & OPERATOR_FINISHED) {
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit);
- }
- break;
- case OB_LATTICE:
- ret = do_lattice_box_select(&vc, &rect, select, extend);
- if (ret & OPERATOR_FINISHED) {
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
- }
- break;
+
+ FOREACH_OBJECT_IN_MODE_BEGIN (vc.view_layer, vc.obedit->mode, ob_iter) {
+ ED_view3d_viewcontext_init_object(&vc, ob_iter);
+
+ switch (vc.obedit->type) {
+ case OB_MESH:
+ vc.em = BKE_editmesh_from_object(vc.obedit);
+ ret |= do_mesh_box_select(&vc, &rect, select, extend);
+ if (ret & OPERATOR_FINISHED) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
+ }
+ break;
+ case OB_CURVE:
+ case OB_SURF:
+ ret |= do_nurbs_box_select(&vc, &rect, select, extend);
+ if (ret & OPERATOR_FINISHED) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
+ }
+ break;
+ case OB_MBALL:
+ ret |= do_meta_box_select(&vc, &rect, select, extend);
+ if (ret & OPERATOR_FINISHED) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
+ }
+ break;
+ case OB_ARMATURE:
+ ret |= do_armature_box_select(&vc, &rect, select, extend);
+ if (ret & OPERATOR_FINISHED) {
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit);
+ }
+ break;
+ case OB_LATTICE:
+ ret |= do_lattice_box_select(&vc, &rect, select, extend);
+ if (ret & OPERATOR_FINISHED) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
+ }
+ break;
case OB_GROOM:
ret = do_groom_box_select(&vc, &rect, select, extend);
if (ret & OPERATOR_FINISHED) {
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
break;
- default:
- assert(!"border select on incorrect object type");
- break;
+ default:
+ assert(!"border select on incorrect object type");
+ break;
+ }
}
+ FOREACH_OBJECT_IN_MODE_END;
}
else { /* no editmode, unified for bones and objects */
if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
- ret = ED_sculpt_mask_box_select(C, &vc, &rect, select, extend);
+ ret |= ED_sculpt_mask_box_select(C, &vc, &rect, select, extend);
}
else if (vc.obact && BKE_paint_select_face_test(vc.obact)) {
- ret = do_paintface_box_select(&eval_ctx, &vc, &rect, select, extend);
+ ret |= do_paintface_box_select(&vc, &rect, select, extend);
}
else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) {
- ret = do_paintvert_box_select(&eval_ctx, &vc, &rect, select, extend);
+ ret |= do_paintvert_box_select(&vc, &rect, select, extend);
}
else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
- ret = PE_border_select(C, &rect, select, extend);
+ ret |= PE_border_select(C, &rect, select, extend);
}
else { /* object mode with none active */
- ret = do_object_pose_box_select(C, &vc, &rect, select, extend);
+ ret |= do_object_pose_box_select(C, &vc, &rect, select, extend);
}
}
+ if (ret & OPERATOR_FINISHED) {
+ ret = OPERATOR_FINISHED;
+ }
+ else {
+ ret = OPERATOR_CANCELLED;
+ }
+
return ret;
}
@@ -2391,7 +2479,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
if (obedit->type == OB_MESH)
retval = EDBM_select_pick(C, location, extend, deselect, toggle);
else if (obedit->type == OB_ARMATURE)
- retval = ED_armature_select_pick(C, location, extend, deselect, toggle);
+ retval = ED_armature_edit_select_pick(C, location, extend, deselect, toggle);
else if (obedit->type == OB_LATTICE)
retval = ED_lattice_select_pick(C, location, extend, deselect, toggle);
else if (ELEM(obedit->type, OB_CURVE, OB_SURF))
@@ -2515,13 +2603,13 @@ static void mesh_circle_doSelectFace(void *userData, BMFace *efa, const float sc
}
}
-static void mesh_circle_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
+static void mesh_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad)
{
ToolSettings *ts = vc->scene->toolsettings;
int bbsel;
CircleSelectUserData data;
- bbsel = EDBM_backbuf_circle_init(eval_ctx, vc, mval[0], mval[1], (short)(rad + 1.0f));
+ bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
vc->em = BKE_editmesh_from_object(vc->obedit);
@@ -2533,7 +2621,7 @@ static void mesh_circle_select(const struct EvaluationContext *eval_ctx, ViewCon
edbm_backbuf_check_and_select_verts(vc->em, select);
}
else {
- mesh_foreachScreenVert(eval_ctx, vc, mesh_circle_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -2542,7 +2630,7 @@ static void mesh_circle_select(const struct EvaluationContext *eval_ctx, ViewCon
edbm_backbuf_check_and_select_edges(vc->em, select);
}
else {
- mesh_foreachScreenEdge(eval_ctx, vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
+ mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR);
}
}
@@ -2551,7 +2639,7 @@ static void mesh_circle_select(const struct EvaluationContext *eval_ctx, ViewCon
edbm_backbuf_check_and_select_faces(vc->em, select);
}
else {
- mesh_foreachScreenFace(eval_ctx, vc, mesh_circle_doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
}
@@ -2559,7 +2647,7 @@ static void mesh_circle_select(const struct EvaluationContext *eval_ctx, ViewCon
EDBM_selectmode_flush(vc->em);
}
-static void paint_facesel_circle_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
+static void paint_facesel_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad)
{
Object *ob = vc->obact;
Mesh *me = ob->data;
@@ -2567,7 +2655,7 @@ static void paint_facesel_circle_select(const struct EvaluationContext *eval_ctx
bm_vertoffs = me->totpoly + 1; /* max index array */
- bbsel = EDBM_backbuf_circle_init(eval_ctx, vc, mval[0], mval[1], (short)(rad + 1.0f));
+ bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
if (bbsel) {
edbm_backbuf_check_and_select_tfaces(me, select);
EDBM_backbuf_free();
@@ -2583,7 +2671,7 @@ static void paint_vertsel_circle_select_doSelectVert(void *userData, MVert *mv,
SET_FLAG_FROM_TEST(mv->flag, data->select, SELECT);
}
}
-static void paint_vertsel_circle_select(const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
+static void paint_vertsel_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad)
{
const bool use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT) != 0;
Object *ob = vc->obact;
@@ -2594,7 +2682,7 @@ static void paint_vertsel_circle_select(const struct EvaluationContext *eval_ctx
if (use_zbuf) {
bm_vertoffs = me->totvert + 1; /* max index array */
- bbsel = EDBM_backbuf_circle_init(eval_ctx, vc, mval[0], mval[1], (short)(rad + 1.0f));
+ bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f));
if (bbsel) {
edbm_backbuf_check_and_select_verts_obmode(me, select);
EDBM_backbuf_free();
@@ -2606,7 +2694,7 @@ static void paint_vertsel_circle_select(const struct EvaluationContext *eval_ctx
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
- meshobject_foreachScreenVert(eval_ctx, vc, paint_vertsel_circle_select_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ meshobject_foreachScreenVert(vc, paint_vertsel_circle_select_doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
if (select != LEFTMOUSE) {
@@ -2871,8 +2959,8 @@ static void armature_circle_select(ViewContext *vc, const bool select, const int
armature_foreachScreenBone(vc, do_circle_select_armature__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
if (data.is_changed) {
- ED_armature_sync_selection(arm->edbo);
- ED_armature_validate_active(arm);
+ ED_armature_edit_sync_selection(arm->edbo);
+ ED_armature_edit_validate_active(arm);
WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit);
}
}
@@ -2901,11 +2989,11 @@ static void mball_circle_select(ViewContext *vc, const bool select, const int mv
/** Callbacks for circle selection in Editmode */
static void obedit_circle_select(
- const struct EvaluationContext *eval_ctx, ViewContext *vc, const bool select, const int mval[2], float rad)
+ ViewContext *vc, const bool select, const int mval[2], float rad)
{
switch (vc->obedit->type) {
case OB_MESH:
- mesh_circle_select(eval_ctx, vc, select, mval, rad);
+ mesh_circle_select(vc, select, mval, rad);
break;
case OB_CURVE:
case OB_SURF:
@@ -2959,50 +3047,56 @@ static bool object_circle_select(ViewContext *vc, const bool select, const int m
/* not a real operator, only for circle test */
static int view3d_circle_select_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Object *obact = CTX_data_active_object(C);
+ ViewContext vc;
const int radius = RNA_int_get(op->ptr, "radius");
const bool select = !RNA_boolean_get(op->ptr, "deselect");
const int mval[2] = {RNA_int_get(op->ptr, "x"),
RNA_int_get(op->ptr, "y")};
- if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(obact) ||
+
+ ED_view3d_viewcontext_init(C, &vc);
+
+ Object *obact = vc.obact;
+ Object *obedit = vc.obedit;
+
+ if (obedit || BKE_paint_select_elem_test(obact) ||
(obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) )
{
- EvaluationContext eval_ctx;
- ViewContext vc;
-
view3d_operator_needs_opengl(C);
-
- CTX_data_eval_ctx(C, &eval_ctx);
- ED_view3d_viewcontext_init(C, &vc);
- if (CTX_data_edit_object(C)) {
- obedit_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
- }
- else if (BKE_paint_select_face_test(obact)) {
- paint_facesel_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
- }
- else if (BKE_paint_select_vert_test(obact)) {
- paint_vertsel_circle_select(&eval_ctx, &vc, select, mval, (float)radius);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
+ FOREACH_OBJECT_IN_MODE_BEGIN (vc.view_layer, obact->mode, ob_iter) {
+ ED_view3d_viewcontext_init_object(&vc, ob_iter);
+
+ obact = vc.obact;
+ obedit = vc.obedit;
+
+ if (CTX_data_edit_object(C)) {
+ obedit_circle_select(&vc, select, mval, (float)radius);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
+ }
+ else if (BKE_paint_select_face_test(obact)) {
+ paint_facesel_circle_select(&vc, select, mval, (float)radius);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
+ }
+ else if (BKE_paint_select_vert_test(obact)) {
+ paint_vertsel_circle_select(&vc, select, mval, (float)radius);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
+ }
+ else if (obact->mode & OB_MODE_POSE) {
+ pose_circle_select(&vc, select, mval, (float)radius);
+ }
+ else {
+ return PE_circle_select(C, select, mval, (float)radius);
+ }
}
- else if (obact->mode & OB_MODE_POSE)
- pose_circle_select(&vc, select, mval, (float)radius);
- else
- return PE_circle_select(C, select, mval, (float)radius);
+ FOREACH_OBJECT_IN_MODE_END;
}
else if (obact && obact->mode & OB_MODE_SCULPT) {
return OPERATOR_CANCELLED;
}
else {
- ViewContext vc;
- ED_view3d_viewcontext_init(C, &vc);
-
if (object_circle_select(&vc, select, mval, (float)radius)) {
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc.scene);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 1df29201bf6..970fb5f5b9d 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -69,17 +69,15 @@ static bool snap_calc_active_center(bContext *C, const bool select_only, float r
static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
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;
- EvaluationContext eval_ctx;
float gridf, imat[3][3], bmat[3][3], vec[3];
int a;
- CTX_data_eval_ctx(C, &eval_ctx);
-
gridf = rv3d->gridview;
if (obedit) {
@@ -166,7 +164,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
if (ob->parent) {
float originmat[3][3];
- BKE_object_where_is_calc_ex(&eval_ctx, scene, NULL, ob, originmat);
+ BKE_object_where_is_calc_ex(depsgraph, scene, NULL, ob, originmat);
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, vec);
@@ -211,20 +209,18 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
static int snap_selected_to_location(bContext *C, const float snap_target_global[3], const bool use_offset)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
View3D *v3d = CTX_wm_view3d(C);
TransVertStore tvs = {NULL};
TransVert *tv;
- EvaluationContext eval_ctx;
float imat[3][3], bmat[3][3];
float center_global[3];
float offset_global[3];
int a;
- CTX_data_eval_ctx(C, &eval_ctx);
-
if (use_offset) {
if ((v3d && v3d->around == V3D_AROUND_ACTIVE) &&
snap_calc_active_center(C, true, center_global))
@@ -377,7 +373,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
if (ob->parent) {
float originmat[3][3];
- BKE_object_where_is_calc_ex(&eval_ctx, scene, NULL, ob, originmat);
+ BKE_object_where_is_calc_ex(depsgraph, scene, NULL, ob, originmat);
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, cursor_parent);
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index dfa64bd2015..8c77cf36c91 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -63,11 +63,12 @@
#include "view3d_intern.h" /* own include */
+#ifndef WITH_REDO_REGION_REMOVAL
/* ******************* view3d space & buttons ************** */
static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op)
{
- uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, 'V', 0);
+ uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0);
}
static void view3d_panel_operator_redo_header(const bContext *C, Panel *pa)
@@ -126,6 +127,8 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
CTX_wm_region_set((bContext *)C, ar);
}
+#endif
+
/* ******************* */
typedef struct CustomTool {
@@ -239,10 +242,11 @@ void view3d_toolshelf_register(ARegionType *art)
BLI_addtail(&art->paneltypes, pt);
}
+#ifndef WITH_REDO_REGION_REMOVAL
void view3d_tool_props_register(ARegionType *art)
{
PanelType *pt;
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator");
strcpy(pt->idname, "VIEW3D_PT_last_operator");
strcpy(pt->label, N_("Operator"));
@@ -251,6 +255,7 @@ void view3d_tool_props_register(ARegionType *art)
pt->draw = view3d_panel_operator_redo;
BLI_addtail(&art->paneltypes, pt);
}
+#endif
/* ********** operator to open/close toolshelf region */
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 92b3ec19acb..09a3202c85e 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -100,7 +100,7 @@ void ED_view3d_dist_range_get(
* \note copies logic of #ED_view3d_viewplane_get(), keep in sync.
*/
bool ED_view3d_clip_range_get(
- const Depsgraph *depsgraph,
+ Depsgraph *depsgraph,
const View3D *v3d, const RegionView3D *rv3d,
float *r_clipsta, float *r_clipend,
const bool use_ortho_factor)
@@ -123,7 +123,7 @@ bool ED_view3d_clip_range_get(
}
bool ED_view3d_viewplane_get(
- const Depsgraph *depsgraph,
+ Depsgraph *depsgraph,
const View3D *v3d, const RegionView3D *rv3d, int winx, int winy,
rctf *r_viewplane, float *r_clipsta, float *r_clipend, float *r_pixsize)
{
@@ -878,7 +878,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
* \param fallback_depth_pt: Use this points depth when no depth can be found.
*/
bool ED_view3d_autodist(
- const EvaluationContext *eval_ctx, struct Depsgraph *graph, ARegion *ar, View3D *v3d,
+ struct Depsgraph *graph, ARegion *ar, View3D *v3d,
const int mval[2], float mouse_worldloc[3],
const bool alphaoverride, const float fallback_depth_pt[3])
{
@@ -888,7 +888,7 @@ bool ED_view3d_autodist(
bool depth_ok = false;
/* Get Z Depths, needed for perspective, nice for ortho */
- ED_view3d_draw_depth(eval_ctx, graph, ar, v3d, alphaoverride);
+ ED_view3d_draw_depth(graph, ar, v3d, alphaoverride);
/* Attempt with low margin's first */
i = 0;
@@ -916,18 +916,18 @@ bool ED_view3d_autodist(
}
void ED_view3d_autodist_init(
- const EvaluationContext *eval_ctx, struct Depsgraph *graph,
+ struct Depsgraph *graph,
ARegion *ar, View3D *v3d, int mode)
{
/* Get Z Depths, needed for perspective, nice for ortho */
switch (mode) {
case 0:
- ED_view3d_draw_depth(eval_ctx, graph, ar, v3d, true);
+ ED_view3d_draw_depth(graph, ar, v3d, true);
break;
case 1:
{
Scene *scene = DEG_get_evaluated_scene(graph);
- ED_view3d_draw_depth_gpencil(eval_ctx, scene, ar, v3d);
+ ED_view3d_draw_depth_gpencil(graph, scene, ar, v3d);
break;
}
}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 1a547d07b80..b6ea68c8fe4 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -64,15 +64,6 @@
#include "DEG_depsgraph_query.h"
-#ifdef WITH_GAMEENGINE
-# include "BLI_listbase.h"
-# include "BLI_callbacks.h"
-
-# include "GPU_draw.h"
-
-# include "BL_System.h"
-#endif
-
#include "view3d_intern.h" /* own include */
/* -------------------------------------------------------------------- */
@@ -403,9 +394,6 @@ void ED_view3d_smooth_view_force_finish(
View3D *v3d, ARegion *ar)
{
RegionView3D *rv3d = ar->regiondata;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
if (rv3d && rv3d->sms) {
rv3d->sms->time_allowed = 0.0; /* force finishing */
@@ -413,8 +401,9 @@ void ED_view3d_smooth_view_force_finish(
/* force update of view matrix so tools that run immediately after
* can use them without redrawing first */
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
- ED_view3d_update_viewmat(&eval_ctx, scene, v3d, ar, NULL, NULL, NULL);
+ ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL);
}
}
@@ -512,6 +501,7 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot)
* meant to take into account vertex/bone selection for eg. */
static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
@@ -526,7 +516,7 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
}
/* this function does all the important stuff */
- if (BKE_camera_view_frame_fit_to_scene(scene, view_layer, camera_ob, r_co, &r_scale)) {
+ if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob, r_co, &r_scale)) {
ObjectTfmProtectedChannels obtfm;
float obmat_new[4][4];
@@ -698,7 +688,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
/**
* \param rect optional for picking (can be NULL).
*/
-void view3d_winmatrix_set(const Depsgraph *depsgraph, ARegion *ar, const View3D *v3d, const rcti *rect)
+void view3d_winmatrix_set(Depsgraph *depsgraph, ARegion *ar, const View3D *v3d, const rcti *rect)
{
RegionView3D *rv3d = ar->regiondata;
rctf viewplane;
@@ -750,7 +740,7 @@ static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
/**
* Sets #RegionView3D.viewmat
*
- * \param eval_ctx: Context.
+ * \param depsgraph: Depsgraph.
* \param scene: Scene for camera and cursor location.
* \param v3d: View 3D space data.
* \param rv3d: 3D region which stores the final matrices.
@@ -760,14 +750,13 @@ static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
* \note don't set windows active in here, is used by renderwin too.
*/
void view3d_viewmatrix_set(
- const EvaluationContext *eval_ctx, Scene *scene,
+ Depsgraph *depsgraph, Scene *scene,
const View3D *v3d, RegionView3D *rv3d, const float rect_scale[2])
{
if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */
if (v3d->camera) {
- const Depsgraph *depsgraph = eval_ctx->depsgraph;
Object *camera_object = DEG_get_evaluated_object(depsgraph, v3d->camera);
- BKE_object_where_is_calc(eval_ctx, scene, camera_object);
+ BKE_object_where_is_calc(depsgraph, scene, camera_object);
obmat_to_viewmat(rv3d, camera_object);
}
else {
@@ -908,7 +897,7 @@ static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data)
* \note (vc->obedit == NULL) can be set to explicitly skip edit-object selection.
*/
int view3d_opengl_select(
- const EvaluationContext *eval_ctx, ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const rcti *input,
+ ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const rcti *input,
eV3DSelectMode select_mode)
{
struct bThemeState theme_state;
@@ -979,7 +968,7 @@ int view3d_opengl_select(
/* Important we use the 'viewmat' and don't re-calculate since
* the object & bone view locking takes 'rect' into account, see: T51629. */
- ED_view3d_draw_setup_view(vc->win, eval_ctx, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect);
+ ED_view3d_draw_setup_view(vc->win, graph, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect);
if (v3d->drawtype > OB_WIRE) {
v3d->zbuf = true;
@@ -1024,7 +1013,7 @@ int view3d_opengl_select(
#endif /* WITH_OPENGL_LEGACY */
G.f &= ~G_PICKSEL;
- ED_view3d_draw_setup_view(vc->win, eval_ctx, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL);
+ ED_view3d_draw_setup_view(vc->win, graph, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL);
if (v3d->drawtype > OB_WIRE) {
v3d->zbuf = 0;
@@ -1092,213 +1081,3 @@ int ED_view3d_view_layer_set(int lay, const int *values, int *active)
}
/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Game Engine Operator
- *
- * Start the game engine (handles context switching).
- * \{ */
-
-#ifdef WITH_GAMEENGINE
-
-static ListBase queue_back;
-static void game_engine_save_state(bContext *C, wmWindow *win)
-{
- Object *obact = CTX_data_active_object(C);
-
- glPushAttrib(GL_ALL_ATTRIB_BITS);
-
- if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
- GPU_paint_set_mipmap(1);
- }
-
- queue_back = win->queue;
-
- BLI_listbase_clear(&win->queue);
-}
-
-static void game_engine_restore_state(bContext *C, wmWindow *win)
-{
- Object *obact = CTX_data_active_object(C);
-
- if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
- GPU_paint_set_mipmap(0);
- }
- /* check because closing win can set to NULL */
- if (win) {
- win->queue = queue_back;
- }
-
- GPU_state_init();
-
- glPopAttrib();
-}
-
-/* was space_set_commmandline_options in 2.4x */
-static void game_set_commmandline_options(GameData *gm)
-{
- SYS_SystemHandle syshandle;
- int test;
-
- if ((syshandle = SYS_GetSystem())) {
- /* User defined settings */
- test = (U.gameflags & USER_DISABLE_MIPMAP);
- GPU_set_mipmap(!test);
- SYS_WriteCommandLineInt(syshandle, "nomipmap", test);
-
- /* File specific settings: */
- /* Only test the first one. These two are switched
- * simultaneously. */
- test = (gm->flag & GAME_SHOW_FRAMERATE);
- SYS_WriteCommandLineInt(syshandle, "show_framerate", test);
- SYS_WriteCommandLineInt(syshandle, "show_profile", test);
-
- test = (gm->flag & GAME_SHOW_DEBUG_PROPS);
- SYS_WriteCommandLineInt(syshandle, "show_properties", test);
-
- test = (gm->flag & GAME_SHOW_PHYSICS);
- SYS_WriteCommandLineInt(syshandle, "show_physics", test);
-
- test = (gm->flag & GAME_ENABLE_ALL_FRAMES);
- SYS_WriteCommandLineInt(syshandle, "fixedtime", test);
-
- test = (gm->flag & GAME_ENABLE_ANIMATION_RECORD);
- SYS_WriteCommandLineInt(syshandle, "animation_record", test);
-
- test = (gm->flag & GAME_IGNORE_DEPRECATION_WARNINGS);
- SYS_WriteCommandLineInt(syshandle, "ignore_deprecation_warnings", test);
-
- test = (gm->matmode == GAME_MAT_MULTITEX);
- SYS_WriteCommandLineInt(syshandle, "blender_material", test);
- test = (gm->matmode == GAME_MAT_GLSL);
- SYS_WriteCommandLineInt(syshandle, "blender_glsl_material", test);
- }
-}
-
-#endif /* WITH_GAMEENGINE */
-
-static int game_engine_poll(bContext *C)
-{
- const wmWindow *win = CTX_wm_window(C);
- const Scene *scene = WM_window_get_active_scene(win);
-
- /* we need a context and area to launch BGE
- * it's a temporary solution to avoid crash at load time
- * if we try to auto run the BGE. Ideally we want the
- * context to be set as soon as we load the file. */
-
- if (win == NULL) return 0;
- if (CTX_wm_screen(C) == NULL) return 0;
-
- if (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)
- return 0;
-
- if (!BKE_scene_uses_blender_game(scene))
- return 0;
-
- return 1;
-}
-
-static int game_engine_exec(bContext *C, wmOperator *op)
-{
-#ifdef WITH_GAMEENGINE
- Scene *startscene = CTX_data_scene(C);
- Main *bmain = CTX_data_main(C);
- ScrArea /* *sa, */ /* UNUSED */ *prevsa = CTX_wm_area(C);
- ARegion *ar, *prevar = CTX_wm_region(C);
- wmWindow *prevwin = CTX_wm_window(C);
- RegionView3D *rv3d;
- rcti cam_frame;
-
- UNUSED_VARS(op);
-
- /* bad context switch .. */
- if (!ED_view3d_context_activate(C))
- return OPERATOR_CANCELLED;
-
- /* redraw to hide any menus/popups, we don't go back to
- * the window manager until after this operator exits */
- WM_redraw_windows(C);
-
- BLI_callback_exec(bmain, &startscene->id, BLI_CB_EVT_GAME_PRE);
-
- rv3d = CTX_wm_region_view3d(C);
- /* sa = CTX_wm_area(C); */ /* UNUSED */
- ar = CTX_wm_region(C);
-
- view3d_operator_needs_opengl(C);
-
- game_set_commmandline_options(&startscene->gm);
-
- if ((rv3d->persp == RV3D_CAMOB) &&
- (startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) &&
- (startscene->gm.stereoflag != STEREO_DOME))
- {
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
- /* Letterbox */
- rctf cam_framef;
- ED_view3d_calc_camera_border(startscene, depsgraph, ar, CTX_wm_view3d(C), rv3d, &cam_framef, false);
- cam_frame.xmin = cam_framef.xmin + ar->winrct.xmin;
- cam_frame.xmax = cam_framef.xmax + ar->winrct.xmin;
- cam_frame.ymin = cam_framef.ymin + ar->winrct.ymin;
- cam_frame.ymax = cam_framef.ymax + ar->winrct.ymin;
- BLI_rcti_isect(&ar->winrct, &cam_frame, &cam_frame);
- }
- else {
- cam_frame.xmin = ar->winrct.xmin;
- cam_frame.xmax = ar->winrct.xmax;
- cam_frame.ymin = ar->winrct.ymin;
- cam_frame.ymax = ar->winrct.ymax;
- }
-
-
- game_engine_save_state(C, prevwin);
-
- StartKetsjiShell(C, ar, &cam_frame, 1);
-
- /* window wasnt closed while the BGE was running */
- if (BLI_findindex(&CTX_wm_manager(C)->windows, prevwin) == -1) {
- prevwin = NULL;
- CTX_wm_window_set(C, NULL);
- }
-
- ED_area_tag_redraw(CTX_wm_area(C));
-
- if (prevwin) {
- /* restore context, in case it changed in the meantime, for
- * example by working in another window or closing it */
- CTX_wm_region_set(C, prevar);
- CTX_wm_window_set(C, prevwin);
- CTX_wm_area_set(C, prevsa);
- }
-
- game_engine_restore_state(C, prevwin);
-
- //XXX restore_all_scene_cfra(scene_cfra_store);
- BKE_scene_set_background(CTX_data_main(C), startscene);
- //XXX BKE_scene_graph_update_for_newframe(bmain->eval_ctx, bmain, scene, depsgraph);
-
- BLI_callback_exec(bmain, &startscene->id, BLI_CB_EVT_GAME_POST);
-
- return OPERATOR_FINISHED;
-#else
- UNUSED_VARS(C);
- BKE_report(op->reports, RPT_ERROR, "Game engine is disabled in this build");
- return OPERATOR_CANCELLED;
-#endif
-}
-
-void VIEW3D_OT_game_start(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Start Game Engine";
- ot->description = "Start game engine";
- ot->idname = "VIEW3D_OT_game_start";
-
- /* api callbacks */
- ot->exec = game_engine_exec;
-
- ot->poll = game_engine_poll;
-}
-
-/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 3bf0e579bb3..6bbc0b7d985 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -249,9 +249,8 @@ typedef struct WalkInfo {
RegionView3D *rv3d;
View3D *v3d;
ARegion *ar;
- const struct Depsgraph *depsgraph;
+ struct Depsgraph *depsgraph;
Scene *scene;
- ViewLayer *view_layer;
wmTimer *timer; /* needed for redraws */
@@ -509,16 +508,12 @@ static float userdef_speed = -1.f;
static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
{
wmWindow *win = CTX_wm_window(C);
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
walk->rv3d = CTX_wm_region_view3d(C);
walk->v3d = CTX_wm_view3d(C);
walk->ar = CTX_wm_region(C);
walk->depsgraph = CTX_data_depsgraph(C);
walk->scene = CTX_data_scene(C);
- walk->view_layer = CTX_data_view_layer(C);
#ifdef NDOF_WALK_DEBUG
puts("\n-- walk begin --");
@@ -607,11 +602,11 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->rv3d->rflag |= RV3D_NAVIGATING;
walk->snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), walk->scene, walk->view_layer, 0,
+ CTX_data_main(C), walk->scene, CTX_data_depsgraph(C), 0,
walk->ar, walk->v3d);
walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(
- &eval_ctx, walk->scene, walk->v3d, walk->rv3d,
+ walk->depsgraph, walk->scene, walk->v3d, walk->rv3d,
(U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
/* center the mouse */
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 3aeb38970d2..b6d794a7812 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -62,6 +62,7 @@
#include "BKE_constraint.h"
#include "BKE_particle.h"
#include "BKE_unit.h"
+#include "BKE_scene.h"
#include "BKE_mask.h"
#include "BKE_report.h"
#include "BKE_workspace.h"
@@ -110,7 +111,7 @@ static void drawEdgeSlide(TransInfo *t);
static void drawVertSlide(TransInfo *t);
static void postInputRotation(TransInfo *t, float values[3]);
-static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], const short around);
+static void ElementRotation(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3], const short around);
static void initSnapSpatial(TransInfo *t, float r_snap[3]);
@@ -211,7 +212,8 @@ static bool transdata_check_local_center(TransInfo *t, short around)
{
return ((around == V3D_AROUND_LOCAL_ORIGINS) && (
(t->flag & (T_OBJECT | T_POSE)) ||
- (t->obedit && ELEM(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)) ||
+ /* implicit: (t->flag & T_EDIT) */
+ (ELEM(t->obedit_type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)) ||
(t->spacetype == SPACE_IPO) ||
(t->options & (CTX_MOVIECLIP | CTX_MASK | CTX_PAINT_CURVE)))
);
@@ -220,7 +222,7 @@ static bool transdata_check_local_center(TransInfo *t, short around)
bool transdata_check_local_islands(TransInfo *t, short around)
{
return ((around == V3D_AROUND_LOCAL_ORIGINS) && (
- (t->obedit && ELEM(t->obedit->type, OB_MESH))));
+ (ELEM(t->obedit_type, OB_MESH))));
}
/* ************************** SPACE DEPENDANT CODE **************************** */
@@ -245,6 +247,7 @@ void setTransformViewMatrices(TransInfo *t)
}
calculateCenter2D(t);
+ calculateCenterLocal(t, t->center_global);
}
void setTransformViewAspect(TransInfo *t, float r_aspect[3])
@@ -619,8 +622,12 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
else {
// XXX how to deal with lock?
SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
- if (sima->lock) WM_event_add_notifier(C, NC_GEOM | ND_DATA, t->obedit->data);
- else ED_area_tag_redraw(t->sa);
+ if (sima->lock) {
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, OBEDIT_FROM_VIEW_LAYER(t->view_layer)->data);
+ }
+ else {
+ ED_area_tag_redraw(t->sa);
+ }
}
}
else if (t->spacetype == SPACE_CLIP) {
@@ -1024,7 +1031,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
else {
- if (t->obedit && t->obedit->type == OB_MESH) {
+ if (t->obedit_type == OB_MESH) {
if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) {
restoreTransObjects(t);
resetTransModal(t);
@@ -1570,7 +1577,7 @@ bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], floa
t->around = centerMode; // override userdefined mode
- if (t->total == 0) {
+ if (t->data_len_all == 0) {
success = false;
}
else {
@@ -1971,7 +1978,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
ts->proportional_fcurve = proportional;
else if (t->spacetype == SPACE_ACTION)
ts->proportional_action = proportional;
- else if (t->obedit)
+ else if (t->obedit_type != -1)
ts->proportional = proportional;
else if (t->options & CTX_MASK)
ts->proportional_mask = (proportional != PROP_EDIT_OFF);
@@ -2003,13 +2010,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
!RNA_property_is_set(op->ptr, prop))
{
- View3D *v3d = t->view;
-
- v3d->twmode = t->current_orientation;
-
- BLI_assert(((v3d->custom_orientation_index == -1) && (t->custom_orientation == NULL)) ||
- (BKE_workspace_transform_orientation_get_index(
- CTX_wm_workspace(C), t->custom_orientation) == v3d->custom_orientation_index));
+ t->scene->orientation_type = t->current_orientation;
+ BLI_assert(((t->scene->orientation_index_custom == -1) && (t->custom_orientation == NULL)) ||
+ (BKE_scene_transform_orientation_get_index(
+ t->scene, t->custom_orientation) == t->scene->orientation_index_custom));
}
}
}
@@ -2034,12 +2038,11 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->current_orientation;
if (orientation == V3D_MANIP_CUSTOM) {
- WorkSpace *workspace = CTX_wm_workspace(C);
- const int custom_orientation_index = BKE_workspace_transform_orientation_get_index(
- workspace, t->custom_orientation);
+ const int orientation_index_custom = BKE_scene_transform_orientation_get_index(
+ t->scene, t->custom_orientation);
/* Maybe we need a t->con.custom_orientation? Seems like it would always match t->custom_orientation. */
- orientation = V3D_MANIP_CUSTOM + custom_orientation_index;
+ orientation = V3D_MANIP_CUSTOM + orientation_index_custom;
BLI_assert(orientation >= V3D_MANIP_CUSTOM);
}
RNA_enum_set(op->ptr, "constraint_orientation", orientation);
@@ -2161,7 +2164,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
createTransData(C, t); // make TransData structs from selection
- if (t->total == 0) {
+ if (t->data_len_all == 0) {
postTrans(C, t);
return 0;
}
@@ -2265,7 +2268,9 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
break;
case TFM_BONESIZE:
{ /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
- bArmature *arm = t->poseobj->data;
+ /* Note: we have to pick one, use the active object. */
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t);
+ bArmature *arm = tc->poseobj->data;
if (arm->drawtype == ARM_ENVELOPE) {
initBoneEnvelope(t);
t->mode = TFM_BONE_ENVELOPE_DIST;
@@ -2663,7 +2668,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
}
/* get constraint targets if needed */
- BKE_constraint_targets_for_solving_get(&t->eval_ctx, con, &cob, &targets, ctime);
+ BKE_constraint_targets_for_solving_get(t->depsgraph, con, &cob, &targets, ctime);
/* do constraint */
cti->evaluate_constraint(con, &cob, &targets);
@@ -2870,6 +2875,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
* \{ */
struct BendCustomData {
+ /* All values are in global space. */
float warp_sta[3];
float warp_end[3];
@@ -2910,9 +2916,9 @@ static void initBend(TransInfo *t)
//copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
if ((t->flag & T_OVERRIDE_CENTER) == 0) {
- calculateCenterCursor(t, t->center);
+ calculateCenterCursor(t, t->center_global);
}
- calculateCenterGlobal(t, t->center, t->center_global);
+ calculateCenterLocal(t, t->center_global);
t->val = 0.0f;
@@ -2923,10 +2929,6 @@ static void initBend(TransInfo *t)
ED_view3d_win_to_3d(t->sa->spacedata.first, t->ar, curs, mval_fl, data->warp_end);
copy_v3_v3(data->warp_nor, t->viewinv[2]);
- if (t->flag & T_EDIT) {
- sub_v3_v3(data->warp_sta, t->obedit->obmat[3]);
- sub_v3_v3(data->warp_end, t->obedit->obmat[3]);
- }
normalize_v3(data->warp_nor);
/* tangent */
@@ -2953,10 +2955,9 @@ static eRedrawFlag handleEventBend(TransInfo *UNUSED(t), const wmEvent *event)
static void Bend(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
float vec[3];
- float pivot[3];
- float warp_end_radius[3];
+ float pivot_global[3];
+ float warp_end_radius_global[3];
int i;
char str[UI_MAX_DRAW_STR];
const struct BendCustomData *data = t->custom.mode.data;
@@ -3011,66 +3012,89 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
values.scale *= data->warp_init_dist;
/* calc 'data->warp_end' from 'data->warp_end_init' */
- copy_v3_v3(warp_end_radius, data->warp_end);
- dist_ensure_v3_v3fl(warp_end_radius, data->warp_sta, values.scale);
+ copy_v3_v3(warp_end_radius_global, data->warp_end);
+ dist_ensure_v3_v3fl(warp_end_radius_global, data->warp_sta, values.scale);
/* done */
/* calculate pivot */
- copy_v3_v3(pivot, data->warp_sta);
+ copy_v3_v3(pivot_global, data->warp_sta);
if (values.angle > 0.0f) {
- madd_v3_v3fl(pivot, data->warp_tan, -values.scale * shell_angle_to_dist((float)M_PI_2 - values.angle));
+ madd_v3_v3fl(pivot_global, data->warp_tan, -values.scale * shell_angle_to_dist((float)M_PI_2 - values.angle));
}
else {
- madd_v3_v3fl(pivot, data->warp_tan, +values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle));
+ madd_v3_v3fl(pivot_global, data->warp_tan, +values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle));
}
- for (i = 0; i < t->total; i++, td++) {
- float mat[3][3];
- float delta[3];
- float fac, fac_scaled;
+ /* TODO(campbell): xform, compensate object center. */
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
+ float warp_sta_local[3];
+ float warp_end_local[3];
+ float warp_end_radius_local[3];
+ float pivot_local[3];
- if (UNLIKELY(values.angle == 0.0f)) {
- copy_v3_v3(td->loc, td->iloc);
- continue;
+ if (t->flag & T_EDIT) {
+ sub_v3_v3v3(warp_sta_local, data->warp_sta, tc->obedit->obmat[3]);
+ sub_v3_v3v3(warp_end_local, data->warp_end, tc->obedit->obmat[3]);
+ sub_v3_v3v3(warp_end_radius_local, warp_end_radius_global, tc->obedit->obmat[3]);
+ sub_v3_v3v3(pivot_local, pivot_global, tc->obedit->obmat[3]);
+ }
+ else {
+ copy_v3_v3(warp_sta_local, data->warp_sta);
+ copy_v3_v3(warp_end_local, data->warp_end);
+ copy_v3_v3(warp_end_radius_local, warp_end_radius_global);
+ copy_v3_v3(pivot_local, pivot_global);
}
- copy_v3_v3(vec, td->iloc);
- mul_m3_v3(td->mtx, vec);
+ for (i = 0; i < tc->data_len; i++, td++) {
+ float mat[3][3];
+ float delta[3];
+ float fac, fac_scaled;
- fac = line_point_factor_v3(vec, data->warp_sta, warp_end_radius);
- if (is_clamp) {
- CLAMP(fac, 0.0f, 1.0f);
- }
+ if (td->flag & TD_NOACTION)
+ break;
- fac_scaled = fac * td->factor;
- axis_angle_normalized_to_mat3(mat, data->warp_nor, values.angle * fac_scaled);
- interp_v3_v3v3(delta, data->warp_sta, warp_end_radius, fac_scaled);
- sub_v3_v3(delta, data->warp_sta);
+ if (td->flag & TD_SKIP)
+ continue;
- /* delta is subtracted, rotation adds back this offset */
- sub_v3_v3(vec, delta);
+ if (UNLIKELY(values.angle == 0.0f)) {
+ copy_v3_v3(td->loc, td->iloc);
+ continue;
+ }
- sub_v3_v3(vec, pivot);
- mul_m3_v3(mat, vec);
- add_v3_v3(vec, pivot);
+ copy_v3_v3(vec, td->iloc);
+ mul_m3_v3(td->mtx, vec);
- mul_m3_v3(td->smtx, vec);
+ fac = line_point_factor_v3(vec, warp_sta_local, warp_end_radius_local);
+ if (is_clamp) {
+ CLAMP(fac, 0.0f, 1.0f);
+ }
- /* rotation */
- if ((t->flag & T_POINTS) == 0) {
- ElementRotation(t, td, mat, V3D_AROUND_LOCAL_ORIGINS);
- }
+ fac_scaled = fac * td->factor;
+ axis_angle_normalized_to_mat3(mat, data->warp_nor, values.angle * fac_scaled);
+ interp_v3_v3v3(delta, warp_sta_local, warp_end_radius_local, fac_scaled);
+ sub_v3_v3(delta, warp_sta_local);
+
+ /* delta is subtracted, rotation adds back this offset */
+ sub_v3_v3(vec, delta);
+
+ sub_v3_v3(vec, pivot_local);
+ mul_m3_v3(mat, vec);
+ add_v3_v3(vec, pivot_local);
+
+ mul_m3_v3(td->smtx, vec);
- /* location */
- copy_v3_v3(td->loc, vec);
+ /* rotation */
+ if ((t->flag & T_POINTS) == 0) {
+ ElementRotation(t, tc, td, mat, V3D_AROUND_LOCAL_ORIGINS);
+ }
+
+ /* location */
+ copy_v3_v3(td->loc, vec);
+ }
}
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -3141,7 +3165,6 @@ static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event)
static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
float vec[3];
float smat[3][3], tmat[3][3], totmat[3][3], persmat[3][3], persinv[3][3];
float value;
@@ -3184,45 +3207,48 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
mul_m3_m3m3(tmat, smat, persmat);
mul_m3_m3m3(totmat, persinv, tmat);
- for (i = 0; i < t->total; i++, td++) {
- const float *center, *co;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ const float *center, *co;
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
-
- if (t->obedit) {
- float mat3[3][3];
- mul_m3_m3m3(mat3, totmat, td->mtx);
- mul_m3_m3m3(tmat, td->smtx, mat3);
- }
- else {
- copy_m3_m3(tmat, totmat);
- }
+ if (td->flag & TD_NOACTION)
+ break;
- if (is_local_center) {
- center = td->center;
- co = td->loc;
- }
- else {
- center = t->center;
- co = td->center;
- }
+ if (td->flag & TD_SKIP)
+ continue;
- sub_v3_v3v3(vec, co, center);
-
- mul_m3_v3(tmat, vec);
-
- add_v3_v3(vec, center);
- sub_v3_v3(vec, co);
-
- mul_v3_fl(vec, td->factor);
-
- add_v3_v3v3(td->loc, td->iloc, vec);
+ if (t->flag & T_EDIT) {
+ float mat3[3][3];
+ mul_m3_m3m3(mat3, totmat, td->mtx);
+ mul_m3_m3m3(tmat, td->smtx, mat3);
+ }
+ else {
+ copy_m3_m3(tmat, totmat);
+ }
+
+ if (is_local_center) {
+ center = td->center;
+ co = td->loc;
+ }
+ else {
+ center = tc->center_local;
+ co = td->center;
+ }
+
+ sub_v3_v3v3(vec, co, center);
+
+ mul_m3_v3(tmat, vec);
+
+ add_v3_v3(vec, center);
+ sub_v3_v3(vec, co);
+
+ mul_v3_fl(vec, td->factor);
+
+ add_v3_v3v3(td->loc, td->iloc, vec);
+ }
}
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -3248,7 +3274,7 @@ static void initResize(TransInfo *t)
t->num.val_flag[1] |= NUM_NULL_ONE;
t->num.val_flag[2] |= NUM_NULL_ONE;
t->num.flag |= NUM_AFFECT_ALL;
- if (!t->obedit) {
+ if ((t->flag & T_EDIT) == 0) {
t->flag |= T_NO_ZERO;
#ifdef USE_NUM_NO_ZERO
t->num.val_flag[0] |= NUM_NO_ZERO;
@@ -3332,7 +3358,7 @@ static void TransMat3ToSize(float mat[3][3], float smat[3][3], float size[3])
if (dot_v3v3(rmat[2], smat[2]) < 0.0f) size[2] = -size[2];
}
-static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
+static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3])
{
float tmat[3][3], smat[3][3], center[3];
float vec[3];
@@ -3346,7 +3372,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
}
if (t->con.applySize) {
- t->con.applySize(t, td, tmat);
+ t->con.applySize(t, tc, td, tmat);
}
/* local constraint shouldn't alter center */
@@ -3358,11 +3384,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
copy_v3_v3(center, td->center);
}
else {
- copy_v3_v3(center, t->center);
+ copy_v3_v3(center, tc->center_local);
}
}
else {
- copy_v3_v3(center, t->center);
+ copy_v3_v3(center, tc->center_local);
}
if (td->ext) {
@@ -3435,7 +3461,6 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td;
float mat[3][3];
int i;
char str[UI_MAX_DRAW_STR];
@@ -3460,39 +3485,46 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
size_to_mat3(mat, t->values);
if (t->con.applySize) {
- t->con.applySize(t, NULL, mat);
+ t->con.applySize(t, NULL, NULL, mat);
}
copy_m3_m3(t->mat, mat); // used in manipulator
headerResize(t, t->values, str);
-
- for (i = 0, td = t->data; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
-
- ElementResize(t, td, mat);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ ElementResize(t, tc, td, mat);
+ }
}
-
+
/* evil hack - redo resize if cliping needed */
if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 1)) {
size_to_mat3(mat, t->values);
-
+
if (t->con.applySize)
- t->con.applySize(t, NULL, mat);
-
- for (i = 0, td = t->data; i < t->total; i++, td++)
- ElementResize(t, td, mat);
+ t->con.applySize(t, NULL, NULL, mat);
- /* In proportional edit it can happen that */
- /* vertices in the radius of the brush end */
- /* outside the clipping area */
- /* XXX HACK - dg */
- if (t->flag & T_PROP_EDIT_ALL) {
- clipUVData(t);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++)
+ ElementResize(t, tc, td, mat);
+
+ /* In proportional edit it can happen that */
+ /* vertices in the radius of the brush end */
+ /* outside the clipping area */
+ /* XXX HACK - dg */
+ if (t->flag & T_PROP_EDIT_ALL) {
+ clipUVData(t);
+ }
}
}
@@ -3521,7 +3553,7 @@ static void initSkinResize(TransInfo *t)
t->num.val_flag[1] |= NUM_NULL_ONE;
t->num.val_flag[2] |= NUM_NULL_ONE;
t->num.flag |= NUM_AFFECT_ALL;
- if (!t->obedit) {
+ if ((t->flag & T_EDIT) == 0) {
t->flag |= T_NO_ZERO;
#ifdef USE_NUM_NO_ZERO
t->num.val_flag[0] |= NUM_NO_ZERO;
@@ -3545,7 +3577,6 @@ static void initSkinResize(TransInfo *t)
static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td;
float size[3], mat[3][3];
int i;
char str[UI_MAX_DRAW_STR];
@@ -3569,34 +3600,37 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
size_to_mat3(mat, size);
headerResize(t, size, str);
-
- for (i = 0, td = t->data; i < t->total; i++, td++) {
- float tmat[3][3], smat[3][3];
- float fsize[3];
-
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
- if (t->flag & T_EDIT) {
- mul_m3_m3m3(smat, mat, td->mtx);
- mul_m3_m3m3(tmat, td->smtx, smat);
- }
- else {
- copy_m3_m3(tmat, mat);
- }
-
- if (t->con.applySize) {
- t->con.applySize(t, NULL, tmat);
- }
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ float tmat[3][3], smat[3][3];
+ float fsize[3];
+
+ if (td->flag & TD_NOACTION)
+ break;
- mat3_to_size(fsize, tmat);
- td->val[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor);
- td->val[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor);
+ if (td->flag & TD_SKIP)
+ continue;
+
+ if (t->flag & T_EDIT) {
+ mul_m3_m3m3(smat, mat, td->mtx);
+ mul_m3_m3m3(tmat, td->smtx, smat);
+ }
+ else {
+ copy_m3_m3(tmat, mat);
+ }
+
+ if (t->con.applySize) {
+ t->con.applySize(t, NULL, NULL, tmat);
+ }
+
+ mat3_to_size(fsize, tmat);
+ td->val[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor);
+ td->val[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor);
+ }
}
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -3612,7 +3646,6 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
static void initToSphere(TransInfo *t)
{
- TransData *td = t->data;
int i;
t->mode = TFM_TOSPHERE;
@@ -3632,13 +3665,16 @@ static void initToSphere(TransInfo *t)
t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
t->flag |= T_NO_CONSTRAINT;
-
+
// Calculate average radius
- for (i = 0; i < t->total; i++, td++) {
- t->val += len_v3v3(t->center, td->iloc);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ t->val += len_v3v3(tc->center_local, td->iloc);
+ }
}
-
- t->val /= (float)t->total;
+
+ t->val /= (float)t->data_len_all;
}
static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
@@ -3647,8 +3683,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
float ratio, radius;
int i;
char str[UI_MAX_DRAW_STR];
- TransData *td = t->data;
-
+
ratio = t->values[0];
snapGridIncrement(t, &ratio);
@@ -3671,28 +3706,29 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
/* default header print */
BLI_snprintf(str, sizeof(str), IFACE_("To Sphere: %.4f %s"), ratio, t->proptext);
}
-
-
- for (i = 0; i < t->total; i++, td++) {
- float tratio;
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
-
- sub_v3_v3v3(vec, td->iloc, t->center);
-
- radius = normalize_v3(vec);
-
- tratio = ratio * td->factor;
-
- mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio);
-
- add_v3_v3v3(td->loc, t->center, vec);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ float tratio;
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ sub_v3_v3v3(vec, td->iloc, tc->center_local);
+
+ radius = normalize_v3(vec);
+
+ tratio = ratio * td->factor;
+
+ mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio);
+
+ add_v3_v3v3(td->loc, tc->center_local, vec);
+ }
}
-
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -3709,7 +3745,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
static void postInputRotation(TransInfo *t, float values[3])
{
if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
- t->con.applyRot(t, NULL, t->axis, values);
+ t->con.applyRot(t, NULL, NULL, t->axis, values);
}
}
@@ -3754,7 +3790,7 @@ static void initRotation(TransInfo *t)
*
* Protected axis and other transform settings are taken into account.
*/
-static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], const float *center)
+static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3], const float *center)
{
float vec[3], totmat[3][3], smat[3][3];
float eul[3], fmat[3][3], quat[4];
@@ -3801,7 +3837,7 @@ static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], con
float pmtx[3][3], imtx[3][3];
// Extract and invert armature object matrix
- copy_m3_m4(pmtx, t->poseobj->obmat);
+ copy_m3_m4(pmtx, tc->poseobj->obmat);
invert_m3_m3(imtx, pmtx);
if ((td->flag & TD_NO_LOC) == 0) {
@@ -3967,7 +4003,7 @@ static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], con
}
}
-static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], const short around)
+static void ElementRotation(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3], const short around)
{
const float *center;
@@ -3976,37 +4012,39 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], const
center = td->center;
}
else {
- center = t->center;
+ center = tc->center_local;
}
- ElementRotation_ex(t, td, mat, center);
+ ElementRotation_ex(t, tc, td, mat, center);
}
static void applyRotationValue(TransInfo *t, float angle, float axis[3])
{
- TransData *td = t->data;
float mat[3][3];
int i;
axis_angle_normalized_to_mat3(mat, axis, angle);
-
- for (i = 0; i < t->total; i++, td++) {
-
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
-
- if (t->con.applyRot) {
- t->con.applyRot(t, td, axis, NULL);
- axis_angle_normalized_to_mat3(mat, axis, angle * td->factor);
- }
- else if (t->flag & T_PROP_EDIT) {
- axis_angle_normalized_to_mat3(mat, axis, angle * td->factor);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ if (t->con.applyRot) {
+ t->con.applyRot(t, tc, td, axis, NULL);
+ axis_angle_normalized_to_mat3(mat, axis, angle * td->factor);
+ }
+ else if (t->flag & T_PROP_EDIT) {
+ axis_angle_normalized_to_mat3(mat, axis, angle * td->factor);
+ }
+
+ ElementRotation(t, tc, td, mat, t->around);
}
-
- ElementRotation(t, td, mat, t->around);
}
}
@@ -4022,7 +4060,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
snapGridIncrement(t, &final);
if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
- t->con.applyRot(t, NULL, t->axis, NULL);
+ t->con.applyRot(t, NULL, NULL, t->axis, NULL);
}
else {
/* reset axis if constraint is not set */
@@ -4091,7 +4129,6 @@ static void initTrackball(TransInfo *t)
static void applyTrackballValue(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2])
{
- TransData *td = t->data;
float mat[3][3];
float axis[3];
float angle;
@@ -4102,18 +4139,21 @@ static void applyTrackballValue(TransInfo *t, const float axis1[3], const float
angle = normalize_v3(axis);
axis_angle_normalized_to_mat3(mat, axis, angle);
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- if (t->flag & T_PROP_EDIT) {
- axis_angle_normalized_to_mat3(mat, axis, td->factor * angle);
- }
+ if (t->flag & T_PROP_EDIT) {
+ axis_angle_normalized_to_mat3(mat, axis, td->factor * angle);
+ }
- ElementRotation(t, td, mat, t->around);
+ ElementRotation(t, tc, td, mat, t->around);
+ }
}
}
@@ -4368,81 +4408,84 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
static void applyTranslationValue(TransInfo *t, const float vec[3])
{
- TransData *td = t->data;
+ const bool apply_snap_align_rotation = usingSnappingNormal(t);// && (t->tsnap.status & POINT_INIT);
float tvec[3];
/* The ideal would be "apply_snap_align_rotation" only when a snap point is found
* so, maybe inside this function is not the best place to apply this rotation.
* but you need "handle snapping rotation before doing the translation" (really?) */
- const bool apply_snap_align_rotation = usingSnappingNormal(t);// && (t->tsnap.status & POINT_INIT);
- float pivot[3];
- if (apply_snap_align_rotation) {
- copy_v3_v3(pivot, t->tsnap.snapTarget);
- /* The pivot has to be in local-space (see T49494) */
- if (t->flag & (T_EDIT | T_POSE)) {
- Object *ob = t->obedit ? t->obedit : t->poseobj;
- mul_m4_v3(ob->imat, pivot);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+
+ float pivot[3];
+ if (apply_snap_align_rotation) {
+ copy_v3_v3(pivot, t->tsnap.snapTarget);
+ /* The pivot has to be in local-space (see T49494) */
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = tc->obedit ? tc->obedit : tc->poseobj;
+ mul_m4_v3(ob->imat, pivot);
+ }
}
- }
- for (int i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
+ TransData *td = tc->data;
+ for (int i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- float rotate_offset[3] = {0};
- bool use_rotate_offset = false;
+ if (td->flag & TD_SKIP)
+ continue;
- /* handle snapping rotation before doing the translation */
- if (apply_snap_align_rotation) {
- float mat[3][3];
+ float rotate_offset[3] = {0};
+ bool use_rotate_offset = false;
- if (validSnappingNormal(t)) {
- const float *original_normal;
+ /* handle snapping rotation before doing the translation */
+ if (apply_snap_align_rotation) {
+ float mat[3][3];
- /* In pose mode, we want to align normals with Y axis of bones... */
- if (t->flag & T_POSE)
- original_normal = td->axismtx[1];
- else
- original_normal = td->axismtx[2];
+ if (validSnappingNormal(t)) {
+ const float *original_normal;
+
+ /* In pose mode, we want to align normals with Y axis of bones... */
+ if (t->flag & T_POSE)
+ original_normal = td->axismtx[1];
+ else
+ original_normal = td->axismtx[2];
- rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal);
+ rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal);
+ }
+ else {
+ unit_m3(mat);
+ }
+
+ ElementRotation_ex(t, tc, td, mat, pivot);
+
+ if (td->loc) {
+ use_rotate_offset = true;
+ sub_v3_v3v3(rotate_offset, td->loc, td->iloc);
+ }
+ }
+
+ if (t->con.applyVec) {
+ float pvec[3];
+ t->con.applyVec(t, tc, td, vec, tvec, pvec);
}
else {
- unit_m3(mat);
+ copy_v3_v3(tvec, vec);
}
- ElementRotation_ex(t, td, mat, pivot);
-
- if (td->loc) {
- use_rotate_offset = true;
- sub_v3_v3v3(rotate_offset, td->loc, td->iloc);
+ if (use_rotate_offset) {
+ add_v3_v3(tvec, rotate_offset);
}
- }
- if (t->con.applyVec) {
- float pvec[3];
- t->con.applyVec(t, td, vec, tvec, pvec);
- }
- else {
- copy_v3_v3(tvec, vec);
- }
+ mul_m3_v3(td->smtx, tvec);
+ mul_v3_fl(tvec, td->factor);
- if (use_rotate_offset) {
- add_v3_v3(tvec, rotate_offset);
- }
-
- mul_m3_v3(td->smtx, tvec);
- mul_v3_fl(tvec, td->factor);
-
- protectedTransBits(td->protectflag, tvec);
-
- if (td->loc)
- add_v3_v3v3(td->loc, td->iloc, tvec);
+ protectedTransBits(td->protectflag, tvec);
- constraintTransLim(t, td);
+ if (td->loc)
+ add_v3_v3v3(td->loc, td->iloc, tvec);
+
+ constraintTransLim(t, td);
+ }
}
}
@@ -4468,7 +4511,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
if (t->con.mode & CON_APPLY) {
float pvec[3] = {0.0f, 0.0f, 0.0f};
- t->con.applyVec(t, NULL, t->values, value_final, pvec);
+ t->con.applyVec(t, NULL, NULL, t->values, value_final, pvec);
headerTranslation(t, pvec, str);
/* only so we have re-usable value with redo, see T46741. */
@@ -4512,7 +4555,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
static void initShrinkFatten(TransInfo *t)
{
// If not in mesh edit mode, fallback to Resize
- if (t->obedit == NULL || t->obedit->type != OB_MESH) {
+ if ((t->flag & T_EDIT) == 0 || (t->obedit_type != OB_MESH)) {
initResize(t);
}
else {
@@ -4542,7 +4585,6 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
int i;
char str[UI_MAX_DRAW_STR];
size_t ofs = 0;
- TransData *td = t->data;
distance = -t->values[0];
@@ -4579,21 +4621,24 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0));
/* done with header string */
- for (i = 0; i < t->total; i++, td++) {
- float tdistance; /* temp dist */
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ float tdistance; /* temp dist */
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- /* get the final offset */
- tdistance = distance * td->factor;
- if (td->ext && (t->flag & T_ALT_TRANSFORM)) {
- tdistance *= td->ext->isize[0]; /* shell factor */
- }
+ /* get the final offset */
+ tdistance = distance * td->factor;
+ if (td->ext && (t->flag & T_ALT_TRANSFORM)) {
+ tdistance *= td->ext->isize[0]; /* shell factor */
+ }
- madd_v3_v3v3fl(td->loc, td->iloc, td->axismtx[2], tdistance);
+ madd_v3_v3v3fl(td->loc, td->iloc, td->axismtx[2], tdistance);
+ }
}
recalcData(t);
@@ -4633,7 +4678,6 @@ static void initTilt(TransInfo *t)
static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
int i;
char str[UI_MAX_DRAW_STR];
@@ -4661,15 +4705,18 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Tilt: %.2f° %s"), RAD2DEGF(final), t->proptext);
}
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- if (td->val) {
- *td->val = td->ival + final * td->factor;
+ if (td->val) {
+ *td->val = td->ival + final * td->factor;
+ }
}
}
@@ -4713,7 +4760,6 @@ static void initCurveShrinkFatten(TransInfo *t)
static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
float ratio;
int i;
char str[UI_MAX_DRAW_STR];
@@ -4737,18 +4783,21 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %3f"), ratio);
}
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- if (td->val) {
- *td->val = td->ival * ratio;
- /* apply PET */
- *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
- if (*td->val <= 0.0f) *td->val = 0.001f;
+ if (td->val) {
+ *td->val = td->ival * ratio;
+ /* apply PET */
+ *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
+ if (*td->val <= 0.0f) *td->val = 0.001f;
+ }
}
}
@@ -4792,7 +4841,6 @@ static void initMaskShrinkFatten(TransInfo *t)
static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td;
float ratio;
int i;
bool initial_feather = false;
@@ -4821,35 +4869,41 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
if (ratio > 1.0f) {
initial_feather = true;
- for (td = t->data, i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- if (td->ival >= 0.001f)
- initial_feather = false;
+ if (td->ival >= 0.001f)
+ initial_feather = false;
+ }
}
}
/* apply shrink/fatten */
- for (td = t->data, i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (td = tc->data, i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- if (td->val) {
- if (initial_feather)
- *td->val = td->ival + (ratio - 1.0f) * 0.01f;
- else
- *td->val = td->ival * ratio;
+ if (td->val) {
+ if (initial_feather)
+ *td->val = td->ival + (ratio - 1.0f) * 0.01f;
+ else
+ *td->val = td->ival * ratio;
- /* apply PET */
- *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
- if (*td->val <= 0.0f) *td->val = 0.001f;
+ /* apply PET */
+ *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
+ if (*td->val <= 0.0f) *td->val = 0.001f;
+ }
}
}
@@ -4893,7 +4947,6 @@ static void initGPShrinkFatten(TransInfo *t)
static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
float ratio;
int i;
char str[UI_MAX_DRAW_STR];
@@ -4917,18 +4970,21 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %3f"), ratio);
}
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- if (td->val) {
- *td->val = td->ival * ratio;
- /* apply PET */
- *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
- if (*td->val <= 0.0f) *td->val = 0.001f;
+ if (td->val) {
+ *td->val = td->ival * ratio;
+ /* apply PET */
+ *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
+ if (*td->val <= 0.0f) *td->val = 0.001f;
+ }
}
}
@@ -4970,7 +5026,6 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
float distance;
int i;
char str[UI_MAX_DRAW_STR];
- TransData *td = t->data;
distance = t->values[0];
@@ -4994,35 +5049,38 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
}
if (t->con.applyRot && t->con.mode & CON_APPLY) {
- t->con.applyRot(t, NULL, axis_global, NULL);
+ t->con.applyRot(t, NULL, NULL, axis_global, NULL);
}
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- sub_v3_v3v3(vec, t->center, td->center);
- if (t->con.applyRot && t->con.mode & CON_APPLY) {
- float axis[3];
- copy_v3_v3(axis, axis_global);
- t->con.applyRot(t, td, axis, NULL);
+ if (td->flag & TD_SKIP)
+ continue;
- mul_m3_v3(td->smtx, axis);
- if (isLockConstraint(t)) {
- float dvec[3];
- project_v3_v3v3(dvec, vec, axis);
- sub_v3_v3(vec, dvec);
- }
- else {
- project_v3_v3v3(vec, vec, axis);
+ sub_v3_v3v3(vec, tc->center_local, td->center);
+ if (t->con.applyRot && t->con.mode & CON_APPLY) {
+ float axis[3];
+ copy_v3_v3(axis, axis_global);
+ t->con.applyRot(t, tc, td, axis, NULL);
+
+ mul_m3_v3(td->smtx, axis);
+ if (isLockConstraint(t)) {
+ float dvec[3];
+ project_v3_v3v3(dvec, vec, axis);
+ sub_v3_v3(vec, dvec);
+ }
+ else {
+ project_v3_v3v3(vec, vec, axis);
+ }
}
- }
- normalize_v3_length(vec, distance * td->factor);
+ normalize_v3_length(vec, distance * td->factor);
- add_v3_v3v3(td->loc, td->iloc, vec);
+ add_v3_v3v3(td->loc, td->iloc, vec);
+ }
}
recalcData(t);
@@ -5060,7 +5118,6 @@ static void initBevelWeight(TransInfo *t)
static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
float weight;
int i;
char str[UI_MAX_DRAW_STR];
@@ -5094,14 +5151,17 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: %.3f %s"), weight, t->proptext);
}
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->val) {
- *td->val = td->ival + weight * td->factor;
- if (*td->val < 0.0f) *td->val = 0.0f;
- if (*td->val > 1.0f) *td->val = 1.0f;
+ if (td->val) {
+ *td->val = td->ival + weight * td->factor;
+ if (*td->val < 0.0f) *td->val = 0.0f;
+ if (*td->val > 1.0f) *td->val = 1.0f;
+ }
}
}
@@ -5140,7 +5200,6 @@ static void initCrease(TransInfo *t)
static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
float crease;
int i;
char str[UI_MAX_DRAW_STR];
@@ -5174,17 +5233,20 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Crease: %.3f %s"), crease, t->proptext);
}
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- if (td->val) {
- *td->val = td->ival + crease * td->factor;
- if (*td->val < 0.0f) *td->val = 0.0f;
- if (*td->val > 1.0f) *td->val = 1.0f;
+ if (td->val) {
+ *td->val = td->ival + crease * td->factor;
+ if (*td->val < 0.0f) *td->val = 0.0f;
+ if (*td->val > 1.0f) *td->val = 1.0f;
+ }
}
}
@@ -5251,7 +5313,7 @@ static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRA
}
}
-static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
+static void ElementBoneSize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3])
{
float tmat[3][3], smat[3][3], oldy;
float sizemat[3][3];
@@ -5260,7 +5322,7 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
mul_m3_m3m3(tmat, td->smtx, smat);
if (t->con.applySize) {
- t->con.applySize(t, td, tmat);
+ t->con.applySize(t, tc, td, tmat);
}
/* we've tucked the scale in loc */
@@ -5273,7 +5335,6 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
float size[3], mat[3][3];
float ratio = t->values[0];
int i;
@@ -5292,23 +5353,26 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
size_to_mat3(mat, size);
if (t->con.applySize) {
- t->con.applySize(t, NULL, mat);
+ t->con.applySize(t, NULL, NULL, mat);
}
copy_m3_m3(t->mat, mat); // used in manipulator
headerBoneSize(t, size, str);
-
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
-
- ElementBoneSize(t, td, mat);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ ElementBoneSize(t, tc, td, mat);
+ }
}
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -5344,7 +5408,6 @@ static void initBoneEnvelope(TransInfo *t)
static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
float ratio;
int i;
char str[UI_MAX_DRAW_STR];
@@ -5367,23 +5430,26 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
else {
BLI_snprintf(str, sizeof(str), IFACE_("Envelope: %3f"), ratio);
}
-
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
-
- if (td->val) {
- /* if the old/original value was 0.0f, then just use ratio */
- if (td->ival)
- *td->val = td->ival * ratio;
- else
- *td->val = ratio;
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ if (td->val) {
+ /* if the old/original value was 0.0f, then just use ratio */
+ if (td->ival)
+ *td->val = td->ival * ratio;
+ else
+ *td->val = ratio;
+ }
}
}
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -5397,9 +5463,9 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
* \{ */
static void slide_origdata_init_flag(
- TransInfo *t, SlideOrigData *sod)
+ TransInfo *t, TransDataContainer *tc, SlideOrigData *sod)
{
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
const bool has_layer_math = CustomData_has_math(&bm->ldata);
const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
@@ -5420,10 +5486,10 @@ static void slide_origdata_init_flag(
}
static void slide_origdata_init_data(
- TransInfo *t, SlideOrigData *sod)
+ TransDataContainer *tc, SlideOrigData *sod)
{
if (sod->use_origfaces) {
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
sod->origfaces = BLI_ghash_ptr_new(__func__);
@@ -5484,11 +5550,11 @@ static void slide_origdata_create_data_vert(
}
static void slide_origdata_create_data(
- TransInfo *t, SlideOrigData *sod,
+ TransInfo *t, TransDataContainer *tc, SlideOrigData *sod,
TransDataGenericSlideVert *sv_array, unsigned int v_stride, unsigned int v_num)
{
if (sod->use_origfaces) {
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
unsigned int i;
TransDataGenericSlideVert *sv;
@@ -5520,15 +5586,15 @@ static void slide_origdata_create_data(
}
if (t->flag & T_MIRROR) {
- TransData *td = t->data;
+ TransData *td = tc->data;
TransDataGenericSlideVert *sv_mirror;
- sod->sv_mirror = MEM_callocN(sizeof(*sv_mirror) * t->total, __func__);
- sod->totsv_mirror = t->total;
+ sod->sv_mirror = MEM_callocN(sizeof(*sv_mirror) * tc->data_len, __func__);
+ sod->totsv_mirror = tc->data_len;
sv_mirror = sod->sv_mirror;
- for (i = 0; i < t->total; i++, td++) {
+ for (i = 0; i < tc->data_len; i++, td++) {
BMVert *eve = td->extra;
if (eve) {
sv_mirror->v = eve;
@@ -5577,7 +5643,7 @@ static void slide_origdata_interp_data_vert(
project_plane_normalized_v3_v3v3(v_proj[1], sv->co_orig_3d, v_proj_axis);
}
- // BM_ITER_ELEM (l, &liter, sv->v, BM_LOOPS_OF_VERT) {
+ // BM_ITER_ELEM (l, &liter, sv->v, BM_LOOPS_OF_VERT)
BM_iter_init(&liter, bm, BM_LOOPS_OF_VERT, sv->v);
l_num = liter.count;
loop_weights = do_loop_weight ? BLI_array_alloca(loop_weights, l_num) : NULL;
@@ -5682,12 +5748,12 @@ static void slide_origdata_interp_data_vert(
}
static void slide_origdata_interp_data(
- TransInfo *t, SlideOrigData *sod,
+ Object *obedit, SlideOrigData *sod,
TransDataGenericSlideVert *sv, unsigned int v_stride, unsigned int v_num,
bool is_final)
{
if (sod->use_origfaces) {
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMesh *bm = em->bm;
unsigned int i;
const bool has_mdisps = (sod->cd_loop_mdisp_offset != -1);
@@ -5750,7 +5816,7 @@ static void slide_origdata_free_date(
static void calcEdgeSlideCustomPoints(struct TransInfo *t)
{
- EdgeSlideData *sld = t->custom.mode.data;
+ EdgeSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
setCustomPoints(t, &t->mouse, sld->mval_end, sld->mval_start);
@@ -5947,11 +6013,11 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
* Calculate screenspace `mval_start` / `mval_end`, optionally slide direction.
*/
static void calcEdgeSlide_mval_range(
- TransInfo *t, EdgeSlideData *sld, const int *sv_table, const int loop_nr,
+ TransInfo *t, TransDataContainer *tc, EdgeSlideData *sld, const int *sv_table, const int loop_nr,
const float mval[2], const bool use_occlude_geometry, const bool use_calc_direction)
{
TransDataEdgeSlideVert *sv_array = sld->sv;
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
ARegion *ar = t->ar;
View3D *v3d = NULL;
@@ -5978,7 +6044,7 @@ static void calcEdgeSlide_mval_range(
unit_m4(projectMat);
}
else {
- ED_view3d_ob_project_mat_get(rv3d, t->obedit, projectMat);
+ ED_view3d_ob_project_mat_get(rv3d, tc->obedit, projectMat);
}
if (use_occlude_geometry) {
@@ -6021,7 +6087,7 @@ static void calcEdgeSlide_mval_range(
/* This test is only relevant if object is not wire-drawn! See [#32068]. */
if (use_occlude_geometry &&
- !BMBVH_EdgeVisible(bmbvh, e_other, t->depsgraph, ar, v3d, t->obedit))
+ !BMBVH_EdgeVisible(bmbvh, e_other, t->depsgraph, ar, v3d, tc->obedit))
{
continue;
}
@@ -6109,7 +6175,7 @@ static void calcEdgeSlide_mval_range(
}
static void calcEdgeSlide_even(
- TransInfo *t, EdgeSlideData *sld, const float mval[2])
+ TransInfo *t, TransDataContainer *tc, EdgeSlideData *sld, const float mval[2])
{
TransDataEdgeSlideVert *sv = sld->sv;
@@ -6134,7 +6200,7 @@ static void calcEdgeSlide_even(
unit_m4(projectMat);
}
else {
- ED_view3d_ob_project_mat_get(rv3d, t->obedit, projectMat);
+ ED_view3d_ob_project_mat_get(rv3d, tc->obedit, projectMat);
}
for (i = 0; i < sld->totsv; i++, sv++) {
@@ -6154,9 +6220,9 @@ static void calcEdgeSlide_even(
}
}
-static bool createEdgeSlideVerts_double_side(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
+static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *tc)
{
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
BMIter iter;
BMEdge *e;
@@ -6171,13 +6237,9 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, bool use_even, bool f
View3D *v3d = NULL;
RegionView3D *rv3d = NULL;
- slide_origdata_init_flag(t, &sld->orig_data);
+ slide_origdata_init_flag(t, tc, &sld->orig_data);
- sld->use_even = use_even;
sld->curr_sv_index = 0;
- sld->flipped = flipped;
- if (!use_clamp)
- t->flag |= T_ALT_TRANSFORM;
/*ensure valid selection*/
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
@@ -6493,26 +6555,24 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, bool use_even, bool f
if (t->spacetype == SPACE_VIEW3D) {
v3d = t->sa ? t->sa->spacedata.first : NULL;
rv3d = t->ar ? t->ar->regiondata : NULL;
- use_occlude_geometry = (v3d && t->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE);
+ use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE);
}
- calcEdgeSlide_mval_range(t, sld, sv_table, loop_nr, mval, use_occlude_geometry, true);
+ calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, true);
/* create copies of faces for customdata projection */
bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
- slide_origdata_init_data(t, &sld->orig_data);
- slide_origdata_create_data(t, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv);
+ slide_origdata_init_data(tc, &sld->orig_data);
+ slide_origdata_create_data(t, tc, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv);
if (rv3d) {
- calcEdgeSlide_even(t, sld, mval);
+ calcEdgeSlide_even(t, tc, sld, mval);
}
sld->em = em;
-
- sld->perc = 0.0f;
-
- t->custom.mode.data = sld;
-
+
+ tc->custom.mode.data = sld;
+
MEM_freeN(sv_table);
return true;
@@ -6522,9 +6582,9 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, bool use_even, bool f
* A simple version of #createEdgeSlideVerts_double_side
* Which assumes the longest unselected.
*/
-static bool createEdgeSlideVerts_single_side(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
+static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *tc)
{
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
BMIter iter;
BMEdge *e;
@@ -6544,15 +6604,9 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, bool use_even, bool f
rv3d = t->ar ? t->ar->regiondata : NULL;
}
- slide_origdata_init_flag(t, &sld->orig_data);
+ slide_origdata_init_flag(t, tc, &sld->orig_data);
- sld->use_even = use_even;
sld->curr_sv_index = 0;
- /* happens to be best for single-sided */
- sld->flipped = !flipped;
- if (!use_clamp)
- t->flag |= T_ALT_TRANSFORM;
-
/* ensure valid selection */
{
int i = 0, j = 0;
@@ -6696,25 +6750,23 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, bool use_even, bool f
if (t->spacetype == SPACE_VIEW3D) {
v3d = t->sa ? t->sa->spacedata.first : NULL;
rv3d = t->ar ? t->ar->regiondata : NULL;
- use_occlude_geometry = (v3d && t->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE);
+ use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE);
}
- calcEdgeSlide_mval_range(t, sld, sv_table, loop_nr, mval, use_occlude_geometry, false);
+ calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, false);
/* create copies of faces for customdata projection */
bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
- slide_origdata_init_data(t, &sld->orig_data);
- slide_origdata_create_data(t, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv);
+ slide_origdata_init_data(tc, &sld->orig_data);
+ slide_origdata_create_data(t, tc, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv);
if (rv3d) {
- calcEdgeSlide_even(t, sld, mval);
+ calcEdgeSlide_even(t, tc, sld, mval);
}
sld->em = em;
- sld->perc = 0.0f;
-
- t->custom.mode.data = sld;
+ tc->custom.mode.data = sld;
MEM_freeN(sv_table);
@@ -6723,14 +6775,16 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, bool use_even, bool f
void projectEdgeSlideData(TransInfo *t, bool is_final)
{
- EdgeSlideData *sld = t->custom.mode.data;
- SlideOrigData *sod = &sld->orig_data;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ EdgeSlideData *sld = tc->custom.mode.data;
+ SlideOrigData *sod = &sld->orig_data;
- if (sod->use_origfaces == false) {
- return;
- }
+ if (sod->use_origfaces == false) {
+ return;
+ }
- slide_origdata_interp_data(t, sod, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv, is_final);
+ slide_origdata_interp_data(tc->obedit, sod, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv, is_final);
+ }
}
void freeEdgeSlideTempFaces(EdgeSlideData *sld)
@@ -6738,7 +6792,7 @@ void freeEdgeSlideTempFaces(EdgeSlideData *sld)
slide_origdata_free_date(&sld->orig_data);
}
-void freeEdgeSlideVerts(TransInfo *UNUSED(t), TransCustomData *custom_data)
+void freeEdgeSlideVerts(TransInfo *UNUSED(t), TransDataContainer *UNUSED(tc), TransCustomData *custom_data)
{
EdgeSlideData *sld = custom_data->data;
@@ -6758,30 +6812,53 @@ void freeEdgeSlideVerts(TransInfo *UNUSED(t), TransCustomData *custom_data)
static void initEdgeSlide_ex(TransInfo *t, bool use_double_side, bool use_even, bool flipped, bool use_clamp)
{
EdgeSlideData *sld;
- bool ok;
+ bool ok = false;
t->mode = TFM_EDGE_SLIDE;
t->transform = applyEdgeSlide;
t->handleEvent = handleEventEdgeSlide;
+ {
+ EdgeSlideParams *slp = MEM_callocN(sizeof(*slp), __func__);
+ slp->use_even = use_even;
+ slp->flipped = flipped;
+ /* happens to be best for single-sided */
+ if (use_double_side == false) {
+ slp->flipped = !flipped;
+ }
+ slp->perc = 0.0f;
+
+ if (!use_clamp) {
+ t->flag |= T_ALT_TRANSFORM;
+ }
+
+ t->custom.mode.data = slp;
+ t->custom.mode.use_free = true;
+ }
+
if (use_double_side) {
- ok = createEdgeSlideVerts_double_side(t, use_even, flipped, use_clamp);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ ok |= createEdgeSlideVerts_double_side(t, tc);
+ }
}
else {
- ok = createEdgeSlideVerts_single_side(t, use_even, flipped, use_clamp);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ ok |= createEdgeSlideVerts_single_side(t, tc);
+ }
}
if (!ok) {
t->state = TRANS_CANCEL;
return;
}
-
- sld = t->custom.mode.data;
-
- if (!sld)
- return;
- t->custom.mode.free_cb = freeEdgeSlideVerts;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ sld = tc->custom.mode.data;
+ if (!sld) {
+ continue;
+ }
+ tc->custom.mode.free_cb = freeEdgeSlideVerts;
+ }
/* set custom point first if you want value to be initialized by init */
calcEdgeSlideCustomPoints(t);
@@ -6808,20 +6885,20 @@ static void initEdgeSlide(TransInfo *t)
static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
{
if (t->mode == TFM_EDGE_SLIDE) {
- EdgeSlideData *sld = t->custom.mode.data;
+ EdgeSlideParams *slp = t->custom.mode.data;
- if (sld) {
+ if (slp) {
switch (event->type) {
case EKEY:
if (event->val == KM_PRESS) {
- sld->use_even = !sld->use_even;
+ slp->use_even = !slp->use_even;
calcEdgeSlideCustomPoints(t);
return TREDRAW_HARD;
}
break;
case FKEY:
if (event->val == KM_PRESS) {
- sld->flipped = !sld->flipped;
+ slp->flipped = !slp->flipped;
calcEdgeSlideCustomPoints(t);
return TREDRAW_HARD;
}
@@ -6835,6 +6912,7 @@ static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEven
}
break;
case EVT_MODAL_MAP:
+#if 0
switch (event->val) {
case TFM_MODAL_EDGESLIDE_DOWN:
sld->curr_sv_index = ((sld->curr_sv_index - 1) + sld->totsv) % sld->totsv;
@@ -6843,6 +6921,7 @@ static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEven
sld->curr_sv_index = (sld->curr_sv_index + 1) % sld->totsv;
return TREDRAW_HARD;
}
+#endif
break;
case MOUSEMOVE:
calcEdgeSlideCustomPoints(t);
@@ -6857,12 +6936,13 @@ static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEven
static void drawEdgeSlide(TransInfo *t)
{
- if ((t->mode == TFM_EDGE_SLIDE) && t->custom.mode.data) {
- EdgeSlideData *sld = t->custom.mode.data;
+ if ((t->mode == TFM_EDGE_SLIDE) && TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data) {
+ EdgeSlideParams *slp = t->custom.mode.data;
+ EdgeSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
/* Even mode */
- if ((sld->use_even == true) || (is_clamp == false)) {
+ if ((slp->use_even == true) || (is_clamp == false)) {
View3D *v3d = t->view;
const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
@@ -6873,16 +6953,16 @@ static void drawEdgeSlide(TransInfo *t)
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
gpuPushMatrix();
- gpuMultMatrix(t->obedit->obmat);
+ gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- if (sld->use_even == true) {
+ if (slp->use_even == true) {
float co_a[3], co_b[3], co_mark[3];
TransDataEdgeSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
- const float fac = (sld->perc + 1.0f) / 2.0f;
+ const float fac = (slp->perc + 1.0f) / 2.0f;
const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
const float guide_size = ctrl_size - 0.5f;
const int alpha_shade = -30;
@@ -6906,7 +6986,7 @@ static void drawEdgeSlide(TransInfo *t)
immUniformThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade);
glPointSize(ctrl_size);
immBegin(GWN_PRIM_POINTS, 1);
- if (sld->flipped) {
+ if (slp->flipped) {
if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co);
}
else {
@@ -6932,6 +7012,7 @@ static void drawEdgeSlide(TransInfo *t)
immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
immBegin(GWN_PRIM_LINES, sld->totsv * 2);
+ /* TODO(campbell): Loop over all verts */
sv = sld->sv;
for (i = 0; i < sld->totsv; i++, sv++) {
float a[3], b[3];
@@ -6972,38 +7053,43 @@ static void drawEdgeSlide(TransInfo *t)
static void doEdgeSlide(TransInfo *t, float perc)
{
- EdgeSlideData *sld = t->custom.mode.data;
- TransDataEdgeSlideVert *svlist = sld->sv, *sv;
- int i;
+ EdgeSlideParams *slp = t->custom.mode.data;
+ EdgeSlideData *sld_active = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
- sld->perc = perc;
- sv = svlist;
+ slp->perc = perc;
- if (sld->use_even == false) {
+ if (slp->use_even == false) {
const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
if (is_clamp) {
const int side_index = (perc < 0.0f);
const float perc_final = fabsf(perc);
- for (i = 0; i < sld->totsv; i++, sv++) {
- madd_v3_v3v3fl(sv->v->co, sv->v_co_orig, sv->dir_side[side_index], perc_final);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ EdgeSlideData *sld = tc->custom.mode.data;
+ TransDataEdgeSlideVert *sv = sld->sv;
+ for (int i = 0; i < sld->totsv; i++, sv++) {
+ madd_v3_v3v3fl(sv->v->co, sv->v_co_orig, sv->dir_side[side_index], perc_final);
+ }
+ sld->curr_side_unclamp = side_index;
}
-
- sld->curr_side_unclamp = side_index;
}
else {
- const int side_index = sld->curr_side_unclamp;
- const float perc_init = fabsf(perc) * ((sld->curr_side_unclamp == (perc < 0.0f)) ? 1 : -1);
- for (i = 0; i < sld->totsv; i++, sv++) {
- float dir_flip[3];
- float perc_final = perc_init;
- if (!is_zero_v3(sv->dir_side[side_index])) {
- copy_v3_v3(dir_flip, sv->dir_side[side_index]);
- }
- else {
- copy_v3_v3(dir_flip, sv->dir_side[!side_index]);
- perc_final *= -1;
+ const float perc_init = fabsf(perc) * ((sld_active->curr_side_unclamp == (perc < 0.0f)) ? 1 : -1);
+ const int side_index = sld_active->curr_side_unclamp;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ EdgeSlideData *sld = tc->custom.mode.data;
+ TransDataEdgeSlideVert *sv = sld->sv;
+ for (int i = 0; i < sld->totsv; i++, sv++) {
+ float dir_flip[3];
+ float perc_final = perc_init;
+ if (!is_zero_v3(sv->dir_side[side_index])) {
+ copy_v3_v3(dir_flip, sv->dir_side[side_index]);
+ }
+ else {
+ copy_v3_v3(dir_flip, sv->dir_side[!side_index]);
+ perc_final *= -1;
+ }
+ madd_v3_v3v3fl(sv->v->co, sv->v_co_orig, dir_flip, perc_final);
}
- madd_v3_v3v3fl(sv->v->co, sv->v_co_orig, dir_flip, perc_final);
}
}
}
@@ -7016,24 +7102,28 @@ static void doEdgeSlide(TransInfo *t, float perc)
* \note len_v3v3(curr_sv->dir_side[0], curr_sv->dir_side[1])
* is the same as the distance between the original vert locations, same goes for the lines below.
*/
- TransDataEdgeSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
- const float curr_length_perc = curr_sv->edge_len * (((sld->flipped ? perc : -perc) + 1.0f) / 2.0f);
+ TransDataEdgeSlideVert *curr_sv = &sld_active->sv[sld_active->curr_sv_index];
+ const float curr_length_perc = curr_sv->edge_len * (((slp->flipped ? perc : -perc) + 1.0f) / 2.0f);
float co_a[3];
float co_b[3];
- for (i = 0; i < sld->totsv; i++, sv++) {
- if (sv->edge_len > FLT_EPSILON) {
- const float fac = min_ff(sv->edge_len, curr_length_perc) / sv->edge_len;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ EdgeSlideData *sld = tc->custom.mode.data;
+ TransDataEdgeSlideVert *sv = sld->sv;
+ for (int i = 0; i < sld->totsv; i++, sv++) {
+ if (sv->edge_len > FLT_EPSILON) {
+ const float fac = min_ff(sv->edge_len, curr_length_perc) / sv->edge_len;
- add_v3_v3v3(co_a, sv->v_co_orig, sv->dir_side[0]);
- add_v3_v3v3(co_b, sv->v_co_orig, sv->dir_side[1]);
+ add_v3_v3v3(co_a, sv->v_co_orig, sv->dir_side[0]);
+ add_v3_v3v3(co_b, sv->v_co_orig, sv->dir_side[1]);
- if (sld->flipped) {
- interp_line_v3_v3v3v3(sv->v->co, co_b, sv->v_co_orig, co_a, fac);
- }
- else {
- interp_line_v3_v3v3v3(sv->v->co, co_a, sv->v_co_orig, co_b, fac);
+ if (slp->flipped) {
+ interp_line_v3_v3v3v3(sv->v->co, co_b, sv->v_co_orig, co_a, fac);
+ }
+ else {
+ interp_line_v3_v3v3v3(sv->v->co, co_a, sv->v_co_orig, co_b, fac);
+ }
}
}
}
@@ -7045,9 +7135,9 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
char str[UI_MAX_DRAW_STR];
size_t ofs = 0;
float final;
- EdgeSlideData *sld = t->custom.mode.data;
- bool flipped = sld->flipped;
- bool use_even = sld->use_even;
+ EdgeSlideParams *slp = t->custom.mode.data;
+ bool flipped = slp->flipped;
+ bool use_even = slp->use_even;
const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num));
@@ -7099,7 +7189,7 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
static void calcVertSlideCustomPoints(struct TransInfo *t)
{
- VertSlideData *sld = t->custom.mode.data;
+ VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
const float *co_orig_3d = sv->co_orig_3d;
@@ -7134,7 +7224,8 @@ static void calcVertSlideCustomPoints(struct TransInfo *t)
*/
static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2])
{
- VertSlideData *sld = t->custom.mode.data;
+ /* Active object may have no selected vertices. */
+ VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
float mval_fl[2] = {UNPACK2(mval)};
TransDataVertSlideVert *sv;
@@ -7161,7 +7252,7 @@ static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2])
*/
static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2])
{
- VertSlideData *sld = t->custom.mode.data;
+ VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
float imval_fl[2] = {UNPACK2(t->mouse.imval)};
float mval_fl[2] = {UNPACK2(mval)};
@@ -7189,7 +7280,7 @@ static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2]
float dir_dot;
sub_v3_v3v3(tdir, sv->co_orig_3d, sv->co_link_orig_3d[j]);
- mul_mat3_m4_v3(t->obedit->obmat, tdir);
+ mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat, tdir);
project_plane_v3_v3v3(tdir, tdir, t->viewinv[2]);
normalize_v3(tdir);
@@ -7207,9 +7298,9 @@ static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2]
}
}
-static bool createVertSlideVerts(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
+static bool createVertSlideVerts(TransInfo *t, TransDataContainer *tc)
{
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
BMIter iter;
BMIter eiter;
@@ -7219,13 +7310,9 @@ static bool createVertSlideVerts(TransInfo *t, bool use_even, bool flipped, bool
VertSlideData *sld = MEM_callocN(sizeof(*sld), "sld");
int j;
- slide_origdata_init_flag(t, &sld->orig_data);
+ slide_origdata_init_flag(t, tc, &sld->orig_data);
- sld->use_even = use_even;
sld->curr_sv_index = 0;
- sld->flipped = flipped;
- if (!use_clamp)
- t->flag |= T_ALT_TRANSFORM;
j = 0;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
@@ -7288,14 +7375,12 @@ static bool createVertSlideVerts(TransInfo *t, bool use_even, bool flipped, bool
sld->totsv = j;
bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
- slide_origdata_init_data(t, &sld->orig_data);
- slide_origdata_create_data(t, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv);
+ slide_origdata_init_data(tc, &sld->orig_data);
+ slide_origdata_create_data(t, tc, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv);
sld->em = em;
- sld->perc = 0.0f;
-
- t->custom.mode.data = sld;
+ tc->custom.mode.data = sld;
/* most likely will be set below */
unit_m4(sld->proj_mat);
@@ -7307,9 +7392,12 @@ static bool createVertSlideVerts(TransInfo *t, bool use_even, bool flipped, bool
rv3d = ar ? ar->regiondata : NULL;
if (rv3d) {
- ED_view3d_ob_project_mat_get(rv3d, t->obedit, sld->proj_mat);
+ ED_view3d_ob_project_mat_get(rv3d, tc->obedit, sld->proj_mat);
}
+ }
+ /* XXX, calc vert slide across all objects */
+ if (tc == t->data_container) {
calcVertSlideMouseActiveVert(t, t->mval);
calcVertSlideMouseActiveEdges(t, t->mval);
}
@@ -7319,14 +7407,13 @@ static bool createVertSlideVerts(TransInfo *t, bool use_even, bool flipped, bool
void projectVertSlideData(TransInfo *t, bool is_final)
{
- VertSlideData *sld = t->custom.mode.data;
- SlideOrigData *sod = &sld->orig_data;
-
- if (sod->use_origfaces == false) {
- return;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ VertSlideData *sld = tc->custom.mode.data;
+ SlideOrigData *sod = &sld->orig_data;
+ if (sod->use_origfaces == true) {
+ slide_origdata_interp_data(tc->obedit, sod, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv, is_final);
+ }
}
-
- slide_origdata_interp_data(t, sod, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv, is_final);
}
void freeVertSlideTempFaces(VertSlideData *sld)
@@ -7334,7 +7421,7 @@ void freeVertSlideTempFaces(VertSlideData *sld)
slide_origdata_free_date(&sld->orig_data);
}
-void freeVertSlideVerts(TransInfo *UNUSED(t), TransCustomData *custom_data)
+void freeVertSlideVerts(TransInfo *UNUSED(t), TransDataContainer *UNUSED(tc), TransCustomData *custom_data)
{
VertSlideData *sld = custom_data->data;
@@ -7361,23 +7448,38 @@ void freeVertSlideVerts(TransInfo *UNUSED(t), TransCustomData *custom_data)
static void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
{
- VertSlideData *sld;
t->mode = TFM_VERT_SLIDE;
t->transform = applyVertSlide;
t->handleEvent = handleEventVertSlide;
- if (!createVertSlideVerts(t, use_even, flipped, use_clamp)) {
- t->state = TRANS_CANCEL;
- return;
+ {
+ VertSlideParams *slp = MEM_callocN(sizeof(*slp), __func__);
+ slp->use_even = use_even;
+ slp->flipped = flipped;
+ slp->perc = 0.0f;
+
+ if (!use_clamp) {
+ t->flag |= T_ALT_TRANSFORM;
+ }
+
+ t->custom.mode.data = slp;
+ t->custom.mode.use_free = true;
}
- sld = t->custom.mode.data;
+ bool ok = false;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ ok |= createVertSlideVerts(t, tc);
+ VertSlideData *sld = tc->custom.mode.data;
+ if (sld) {
+ tc->custom.mode.free_cb = freeVertSlideVerts;
+ }
+ }
- if (!sld)
+ if (ok == false) {
+ t->state = TRANS_CANCEL;
return;
-
- t->custom.mode.free_cb = freeVertSlideVerts;
+ }
/* set custom point first if you want value to be initialized by init */
calcVertSlideCustomPoints(t);
@@ -7404,14 +7506,14 @@ static void initVertSlide(TransInfo *t)
static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
{
if (t->mode == TFM_VERT_SLIDE) {
- VertSlideData *sld = t->custom.mode.data;
+ VertSlideParams *slp = t->custom.mode.data;
- if (sld) {
+ if (slp) {
switch (event->type) {
case EKEY:
if (event->val == KM_PRESS) {
- sld->use_even = !sld->use_even;
- if (sld->flipped) {
+ slp->use_even = !slp->use_even;
+ if (slp->flipped) {
calcVertSlideCustomPoints(t);
}
return TREDRAW_HARD;
@@ -7419,7 +7521,7 @@ static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEven
break;
case FKEY:
if (event->val == KM_PRESS) {
- sld->flipped = !sld->flipped;
+ slp->flipped = !slp->flipped;
calcVertSlideCustomPoints(t);
return TREDRAW_HARD;
}
@@ -7464,8 +7566,8 @@ static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEven
static void drawVertSlide(TransInfo *t)
{
- if ((t->mode == TFM_VERT_SLIDE) && t->custom.mode.data) {
- VertSlideData *sld = t->custom.mode.data;
+ if ((t->mode == TFM_VERT_SLIDE) && TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data) {
+ VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
/* Non-Prop mode */
@@ -7485,12 +7587,12 @@ static void drawVertSlide(TransInfo *t)
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
gpuPushMatrix();
- gpuMultMatrix(t->obedit->obmat);
+ gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
glLineWidth(line_size);
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
-
+
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
@@ -7540,13 +7642,13 @@ static void drawVertSlide(TransInfo *t)
mval_ofs[0] = t->mval[0] - t->mouse.imval[0];
mval_ofs[1] = t->mval[1] - t->mouse.imval[1];
- mul_v3_m4v3(co_orig_3d, t->obedit->obmat, curr_sv->co_orig_3d);
+ mul_v3_m4v3(co_orig_3d, TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat, curr_sv->co_orig_3d);
zfac = ED_view3d_calc_zfac(t->ar->regiondata, co_orig_3d, NULL);
ED_view3d_win_to_delta(t->ar, mval_ofs, co_dest_3d, zfac);
- invert_m4_m4(t->obedit->imat, t->obedit->obmat);
- mul_mat3_m4_v3(t->obedit->imat, co_dest_3d);
+ invert_m4_m4(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->imat, TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
+ mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->imat, co_dest_3d);
add_v3_v3(co_dest_3d, curr_sv->co_orig_3d);
@@ -7581,41 +7683,43 @@ static void drawVertSlide(TransInfo *t)
static void doVertSlide(TransInfo *t, float perc)
{
- VertSlideData *sld = t->custom.mode.data;
- TransDataVertSlideVert *svlist = sld->sv, *sv;
- int i;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ VertSlideData *sld = tc->custom.mode.data;
+ TransDataVertSlideVert *svlist = sld->sv, *sv;
+ int i;
- sld->perc = perc;
- sv = svlist;
+ sld->perc = perc;
+ sv = svlist;
- if (sld->use_even == false) {
- for (i = 0; i < sld->totsv; i++, sv++) {
- interp_v3_v3v3(sv->v->co, sv->co_orig_3d, sv->co_link_orig_3d[sv->co_link_curr], perc);
+ if (sld->use_even == false) {
+ for (i = 0; i < sld->totsv; i++, sv++) {
+ interp_v3_v3v3(sv->v->co, sv->co_orig_3d, sv->co_link_orig_3d[sv->co_link_curr], perc);
+ }
}
- }
- else {
- TransDataVertSlideVert *sv_curr = &sld->sv[sld->curr_sv_index];
- const float edge_len_curr = len_v3v3(sv_curr->co_orig_3d, sv_curr->co_link_orig_3d[sv_curr->co_link_curr]);
- const float tperc = perc * edge_len_curr;
+ else {
+ TransDataVertSlideVert *sv_curr = &sld->sv[sld->curr_sv_index];
+ const float edge_len_curr = len_v3v3(sv_curr->co_orig_3d, sv_curr->co_link_orig_3d[sv_curr->co_link_curr]);
+ const float tperc = perc * edge_len_curr;
- for (i = 0; i < sld->totsv; i++, sv++) {
- float edge_len;
- float dir[3];
+ for (i = 0; i < sld->totsv; i++, sv++) {
+ float edge_len;
+ float dir[3];
- sub_v3_v3v3(dir, sv->co_link_orig_3d[sv->co_link_curr], sv->co_orig_3d);
- edge_len = normalize_v3(dir);
+ sub_v3_v3v3(dir, sv->co_link_orig_3d[sv->co_link_curr], sv->co_orig_3d);
+ edge_len = normalize_v3(dir);
- if (edge_len > FLT_EPSILON) {
- if (sld->flipped) {
- madd_v3_v3v3fl(sv->v->co, sv->co_link_orig_3d[sv->co_link_curr], dir, -tperc);
+ if (edge_len > FLT_EPSILON) {
+ if (sld->flipped) {
+ madd_v3_v3v3fl(sv->v->co, sv->co_link_orig_3d[sv->co_link_curr], dir, -tperc);
+ }
+ else {
+ madd_v3_v3v3fl(sv->v->co, sv->co_orig_3d, dir, tperc);
+ }
}
else {
- madd_v3_v3v3fl(sv->v->co, sv->co_orig_3d, dir, tperc);
+ copy_v3_v3(sv->v->co, sv->co_orig_3d);
}
}
- else {
- copy_v3_v3(sv->v->co, sv->co_orig_3d);
- }
}
}
}
@@ -7625,9 +7729,9 @@ static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
char str[UI_MAX_DRAW_STR];
size_t ofs = 0;
float final;
- VertSlideData *sld = t->custom.mode.data;
- const bool flipped = sld->flipped;
- const bool use_even = sld->use_even;
+ VertSlideData *slp = t->custom.mode.data;
+ const bool flipped = slp->flipped;
+ const bool use_even = slp->use_even;
const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num));
@@ -7700,7 +7804,6 @@ static void initBoneRoll(TransInfo *t)
static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
int i;
char str[UI_MAX_DRAW_STR];
@@ -7726,14 +7829,17 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
}
/* set roll values */
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- *(td->val) = td->ival - final;
+ *(td->val) = td->ival - final;
+ }
}
recalcData(t);
@@ -7767,7 +7873,6 @@ static void initBakeTime(TransInfo *t)
static void applyBakeTime(TransInfo *t, const int mval[2])
{
- TransData *td = t->data;
float time;
int i;
char str[UI_MAX_DRAW_STR];
@@ -7811,17 +7916,20 @@ static void applyBakeTime(TransInfo *t, const int mval[2])
BLI_snprintf(str, sizeof(str), IFACE_("Time: %.3f %s"), time, t->proptext);
}
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- if (td->val) {
- *td->val = td->ival + time * td->factor;
- if (td->ext->size && *td->val < *td->ext->size) *td->val = *td->ext->size;
- if (td->ext->quat && *td->val > *td->ext->quat) *td->val = *td->ext->quat;
+ if (td->val) {
+ *td->val = td->ival + time * td->factor;
+ if (td->ext->size && *td->val < *td->ext->size) *td->val = *td->ext->size;
+ if (td->ext->quat && *td->val > *td->ext->quat) *td->val = *td->ext->quat;
+ }
}
}
@@ -7844,14 +7952,13 @@ static void initMirror(TransInfo *t)
initMouseInputMode(t, &t->mouse, INPUT_NONE);
t->flag |= T_NULL_ONE;
- if (!t->obedit) {
+ if ((t->flag & T_EDIT) == 0) {
t->flag |= T_NO_ZERO;
}
}
static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td;
float size[3], mat[3][3];
int i;
char str[UI_MAX_DRAW_STR];
@@ -7869,19 +7976,22 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
size_to_mat3(mat, size);
if (t->con.applySize) {
- t->con.applySize(t, NULL, mat);
+ t->con.applySize(t, NULL, NULL, mat);
}
BLI_snprintf(str, sizeof(str), IFACE_("Mirror%s"), t->con.text);
- for (i = 0, td = t->data; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- ElementResize(t, td, mat);
+ ElementResize(t, tc, td, mat);
+ }
}
recalcData(t);
@@ -7893,14 +8003,17 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
size_to_mat3(mat, size);
- for (i = 0, td = t->data; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- ElementResize(t, td, mat);
+ ElementResize(t, tc, td, mat);
+ }
}
recalcData(t);
@@ -7931,42 +8044,43 @@ static void initAlign(TransInfo *t)
static void applyAlign(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
float center[3];
int i;
- /* saving original center */
- copy_v3_v3(center, t->center);
- for (i = 0; i < t->total; i++, td++) {
- float mat[3][3], invmat[3][3];
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ /* saving original center */
+ copy_v3_v3(center, tc->center_local);
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ float mat[3][3], invmat[3][3];
- if (td->flag & TD_NOACTION)
- break;
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- /* around local centers */
- if (t->flag & (T_OBJECT | T_POSE)) {
- copy_v3_v3(t->center, td->center);
- }
- else {
- if (t->settings->selectmode & SCE_SELECT_FACE) {
- copy_v3_v3(t->center, td->center);
+ /* around local centers */
+ if (t->flag & (T_OBJECT | T_POSE)) {
+ copy_v3_v3(tc->center_local, td->center);
+ }
+ else {
+ if (t->settings->selectmode & SCE_SELECT_FACE) {
+ copy_v3_v3(tc->center_local, td->center);
+ }
}
- }
- invert_m3_m3(invmat, td->axismtx);
+ invert_m3_m3(invmat, td->axismtx);
- mul_m3_m3m3(mat, t->spacemtx, invmat);
+ mul_m3_m3m3(mat, t->spacemtx, invmat);
- ElementRotation(t, td, mat, t->around);
+ ElementRotation(t, tc, td, mat, t->around);
+ }
+ /* restoring original center */
+ copy_v3_v3(tc->center_local, center);
}
- /* restoring original center */
- copy_v3_v3(t->center, center);
-
recalcData(t);
ED_area_headerprint(t->sa, IFACE_("Align"));
@@ -8027,17 +8141,19 @@ static void headerSeqSlide(TransInfo *t, const float val[2], char str[UI_MAX_DRA
static void applySeqSlideValue(TransInfo *t, const float val[2])
{
- TransData *td = t->data;
int i;
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if (td->flag & TD_SKIP)
- continue;
+ if (td->flag & TD_SKIP)
+ continue;
- madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor);
+ madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor);
+ }
}
}
@@ -8050,7 +8166,7 @@ static void applySeqSlide(TransInfo *t, const int mval[2])
if (t->con.mode & CON_APPLY) {
float pvec[3] = {0.0f, 0.0f, 0.0f};
float tvec[3];
- t->con.applyVec(t, NULL, t->values, tvec, pvec);
+ t->con.applyVec(t, NULL, NULL, t->values, tvec, pvec);
copy_v3_v3(t->values, tvec);
}
else {
@@ -8270,56 +8386,58 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR])
static void applyTimeTranslateValue(TransInfo *t)
{
- TransData *td = t->data;
- TransData2D *td2d = t->data2d;
Scene *scene = t->scene;
int i;
-
+
const short autosnap = getAnimEdit_SnapMode(t);
const double secf = FPS;
float deltax, val /* , valprev */;
- /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
- for (i = 0; i < t->total; i++, td++, td2d++) {
- /* it is assumed that td->extra is a pointer to the AnimData,
- * whose active action is where this keyframe comes from
- * (this is only valid when not in NLA)
- */
- AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ TransData2D *td2d = tc->data_2d;
+ /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
+ for (i = 0; i < tc->data_len; i++, td++, td2d++) {
+ /* it is assumed that td->extra is a pointer to the AnimData,
+ * whose active action is where this keyframe comes from
+ * (this is only valid when not in NLA)
+ */
+ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
- /* valprev = *td->val; */ /* UNUSED */
+ /* valprev = *td->val; */ /* UNUSED */
- /* check if any need to apply nla-mapping */
- if (adt && (t->spacetype != SPACE_SEQ)) {
- deltax = t->values[0];
+ /* check if any need to apply nla-mapping */
+ if (adt && (t->spacetype != SPACE_SEQ)) {
+ deltax = t->values[0];
- if (autosnap == SACTSNAP_TSTEP) {
- deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf);
- }
- else if (autosnap == SACTSNAP_STEP) {
- deltax = floorf(deltax + 0.5f);
+ if (autosnap == SACTSNAP_TSTEP) {
+ deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf);
+ }
+ else if (autosnap == SACTSNAP_STEP) {
+ deltax = floorf(deltax + 0.5f);
+ }
+
+ val = BKE_nla_tweakedit_remap(adt, td->ival, NLATIME_CONVERT_MAP);
+ val += deltax * td->factor;
+ *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
}
+ else {
+ deltax = val = t->values[0];
- val = BKE_nla_tweakedit_remap(adt, td->ival, NLATIME_CONVERT_MAP);
- val += deltax * td->factor;
- *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
- }
- else {
- deltax = val = t->values[0];
+ if (autosnap == SACTSNAP_TSTEP) {
+ val = (float)(floor(((double)deltax / secf) + 0.5) * secf);
+ }
+ else if (autosnap == SACTSNAP_STEP) {
+ val = floorf(val + 0.5f);
+ }
- if (autosnap == SACTSNAP_TSTEP) {
- val = (float)(floor(((double)deltax / secf) + 0.5) * secf);
- }
- else if (autosnap == SACTSNAP_STEP) {
- val = floorf(val + 0.5f);
+ *(td->val) = td->ival + val;
}
- *(td->val) = td->ival + val;
+ /* apply nearest snapping */
+ doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap);
}
-
- /* apply nearest snapping */
- doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap);
}
}
@@ -8386,18 +8504,19 @@ static void initTimeSlide(TransInfo *t)
float min = 999999999.0f, max = -999999999.0f;
int i;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+ float val = *(td->val);
- TransData *td = t->data;
- for (i = 0; i < t->total; i++, td++) {
- AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
- float val = *(td->val);
-
- /* strip/action time to global (mapped) time */
- if (adt)
- val = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_MAP);
-
- if (min > val) min = val;
- if (max < val) max = val;
+ /* strip/action time to global (mapped) time */
+ if (adt)
+ val = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_MAP);
+
+ if (min > val) min = val;
+ if (max < val) max = val;
+ }
}
if (min == max) {
@@ -8450,7 +8569,6 @@ static void headerTimeSlide(TransInfo *t, const float sval, char str[UI_MAX_DRAW
static void applyTimeSlideValue(TransInfo *t, float sval)
{
- TransData *td = t->data;
int i;
const float *range = t->custom.mode.data;
float minx = range[0];
@@ -8465,44 +8583,47 @@ static void applyTimeSlideValue(TransInfo *t, float sval)
}
/* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
- for (i = 0; i < t->total; i++, td++) {
- /* it is assumed that td->extra is a pointer to the AnimData,
- * whose active action is where this keyframe comes from
- * (this is only valid when not in NLA)
- */
- AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
- float cval = t->values[0];
-
- /* only apply to data if in range */
- if ((sval > minx) && (sval < maxx)) {
- float cvalc = CLAMPIS(cval, minx, maxx);
- float ival = td->ival;
- float timefac;
-
- /* NLA mapping magic here works as follows:
- * - "ival" goes from strip time to global time
- * - calculation is performed into td->val in global time
- * (since sval and min/max are all in global time)
- * - "td->val" then gets put back into strip time
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ /* it is assumed that td->extra is a pointer to the AnimData,
+ * whose active action is where this keyframe comes from
+ * (this is only valid when not in NLA)
*/
- if (adt) {
- /* strip to global */
- ival = BKE_nla_tweakedit_remap(adt, ival, NLATIME_CONVERT_MAP);
- }
-
- /* left half? */
- if (ival < sval) {
- timefac = (sval - ival) / (sval - minx);
- *(td->val) = cvalc - timefac * (cvalc - minx);
- }
- else {
- timefac = (ival - sval) / (maxx - sval);
- *(td->val) = cvalc + timefac * (maxx - cvalc);
- }
-
- if (adt) {
- /* global to strip */
- *(td->val) = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_UNMAP);
+ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+ float cval = t->values[0];
+
+ /* only apply to data if in range */
+ if ((sval > minx) && (sval < maxx)) {
+ float cvalc = CLAMPIS(cval, minx, maxx);
+ float ival = td->ival;
+ float timefac;
+
+ /* NLA mapping magic here works as follows:
+ * - "ival" goes from strip time to global time
+ * - calculation is performed into td->val in global time
+ * (since sval and min/max are all in global time)
+ * - "td->val" then gets put back into strip time
+ */
+ if (adt) {
+ /* strip to global */
+ ival = BKE_nla_tweakedit_remap(adt, ival, NLATIME_CONVERT_MAP);
+ }
+
+ /* left half? */
+ if (ival < sval) {
+ timefac = (sval - ival) / (sval - minx);
+ *(td->val) = cvalc - timefac * (cvalc - minx);
+ }
+ else {
+ timefac = (ival - sval) / (maxx - sval);
+ *(td->val) = cvalc + timefac * (maxx - cvalc);
+ }
+
+ if (adt) {
+ /* global to strip */
+ *(td->val) = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_UNMAP);
+ }
}
}
}
@@ -8563,8 +8684,8 @@ static void initTimeScale(TransInfo *t)
/* recalculate center2d to use CFRA and mouse Y, since that's
* what is used in time scale */
if ((t->flag & T_OVERRIDE_CENTER) == 0) {
- t->center[0] = t->scene->r.cfra;
- projectFloatView(t, t->center, center);
+ t->center_global[0] = t->scene->r.cfra;
+ projectFloatView(t, t->center_global, center);
center[1] = t->mouse.imval[1];
}
@@ -8605,39 +8726,40 @@ static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR])
static void applyTimeScaleValue(TransInfo *t)
{
Scene *scene = t->scene;
- TransData *td = t->data;
- TransData2D *td2d = t->data2d;
int i;
const short autosnap = getAnimEdit_SnapMode(t);
const double secf = FPS;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ TransData2D *td2d = tc->data_2d;
+ for (i = 0; i < tc->data_len; i++, td++, td2d++) {
+ /* it is assumed that td->extra is a pointer to the AnimData,
+ * whose active action is where this keyframe comes from
+ * (this is only valid when not in NLA)
+ */
+ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+ float startx = CFRA;
+ float fac = t->values[0];
- for (i = 0; i < t->total; i++, td++, td2d++) {
- /* it is assumed that td->extra is a pointer to the AnimData,
- * whose active action is where this keyframe comes from
- * (this is only valid when not in NLA)
- */
- AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
- float startx = CFRA;
- float fac = t->values[0];
-
- if (autosnap == SACTSNAP_TSTEP) {
- fac = (float)(floor((double)fac / secf + 0.5) * secf);
- }
- else if (autosnap == SACTSNAP_STEP) {
- fac = floorf(fac + 0.5f);
- }
+ if (autosnap == SACTSNAP_TSTEP) {
+ fac = (float)(floor((double)fac / secf + 0.5) * secf);
+ }
+ else if (autosnap == SACTSNAP_STEP) {
+ fac = floorf(fac + 0.5f);
+ }
- /* check if any need to apply nla-mapping */
- if (adt)
- startx = BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
+ /* check if any need to apply nla-mapping */
+ if (adt)
+ startx = BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
- /* now, calculate the new value */
- *(td->val) = ((td->ival - startx) * fac) + startx;
+ /* now, calculate the new value */
+ *(td->val) = ((td->ival - startx) * fac) + startx;
- /* apply nearest snapping */
- doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap);
+ /* apply nearest snapping */
+ doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap);
+ }
}
}
@@ -8666,7 +8788,7 @@ bool checkUseAxisMatrix(TransInfo *t)
/* currently only checks for editmode */
if (t->flag & T_EDIT) {
if ((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
- (ELEM(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)))
+ (ELEM(t->obedit_type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)))
{
/* not all editmode supports axis-matrix */
return true;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 40f6b64b055..ba8f094b653 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -47,6 +47,7 @@
struct Depsgraph;
struct TransInfo;
+struct TransDataContainer;
struct TransData;
struct TransformOrientation;
struct TransSnap;
@@ -109,7 +110,7 @@ typedef struct TransSnap {
* \note Return value can be anything,
* where the smallest absolute value defines whats closest.
*/
- float (*distance)(struct TransInfo *, const float p1[3], const float p2[3]);
+ float (*distance)(struct TransInfo *t, const float p1[3], const float p2[3]);
/**
* Re-usable snap context data.
@@ -127,14 +128,16 @@ typedef struct TransCon {
/* the one in TransInfo is not garanty to stay the same (Rotates change it) */
int mode; /* Mode flags of the Constraint */
void (*drawExtra)(struct TransInfo *t);
+
+ /* Note: if 'tc' is NULL, 'td' must also be NULL. */
/* For constraints that needs to draw differently from the other
* uses this instead of the generic draw function */
- void (*applyVec)(struct TransInfo *t, struct TransData *td, const float in[3], float out[3], float pvec[3]);
+ void (*applyVec)(struct TransInfo *t, struct TransDataContainer *tc, struct TransData *td, const float in[3], float out[3], float pvec[3]);
/* Apply function pointer for linear vectorial transformation */
/* The last three parameters are pointers to the in/out/printable vectors */
- void (*applySize)(struct TransInfo *t, struct TransData *td, float smat[3][3]);
+ void (*applySize)(struct TransInfo *t, struct TransDataContainer *tc, struct TransData *td, float smat[3][3]);
/* Apply function pointer for size transformation */
- void (*applyRot)(struct TransInfo *t, struct TransData *td, float vec[3], float *angle);
+ void (*applyRot)(struct TransInfo *t, struct TransDataContainer *tc, struct TransData *td, float vec[3], float *angle);
/* Apply function pointer for rotation transformation */
} TransCon;
@@ -270,10 +273,6 @@ typedef struct EdgeSlideData {
SlideOrigData orig_data;
- float perc;
-
- bool use_even;
- bool flipped;
int curr_sv_index;
@@ -281,6 +280,12 @@ typedef struct EdgeSlideData {
int curr_side_unclamp;
} EdgeSlideData;
+typedef struct EdgeSlideParams {
+ float perc;
+
+ bool use_even;
+ bool flipped;
+} EdgeSlideParams;
typedef struct TransDataVertSlideVert {
/* TransDataGenericSlideVert */
@@ -313,6 +318,13 @@ typedef struct VertSlideData {
float proj_mat[4][4];
} VertSlideData;
+typedef struct VertSlideParams {
+ float perc;
+
+ bool use_even;
+ bool flipped;
+} VertSlideParams;
+
typedef struct BoneInitData {
struct EditBone *bone;
float tail[3];
@@ -373,16 +385,68 @@ typedef struct MouseInput {
typedef struct TransCustomData {
void *data;
- void (*free_cb)(struct TransInfo *, struct TransCustomData *);
+ void (*free_cb)(struct TransInfo *, struct TransDataContainer *tc, struct TransCustomData *custom_data);
unsigned int use_free : 1;
} TransCustomData;
typedef struct TransCenterData {
- float local[3], global[3];
+ float global[3];
unsigned int is_set : 1;
} TransCenterData;
+/**
+ * Rule of thumb for choosing between mode/type:
+ * - If transform mode uses the data, assign to `mode`
+ * (typically in transform.c).
+ * - If conversion uses the data as an extension to the #TransData, assign to `type`
+ * (typically in transform_conversion.c).
+ */
+typedef struct TransCustomDataContainer {
+ /** Owned by the mode (grab, scale, bend... ).*/
+ union {
+ TransCustomData mode, first_elem;
+ };
+ TransCustomData type;
+} TransCustomDataContainer;
+#define TRANS_CUSTOM_DATA_ELEM_MAX (sizeof(TransCustomDataContainer) / sizeof(TransCustomData))
+
+typedef struct TransDataContainer {
+ /**
+ * Use for cases we care about the active, eg: active vert of active mesh.
+ * if set this will _always_ be the first item in the array.
+ */
+ bool is_active;
+
+ /** Transformed data (array). */
+ TransData *data;
+ /** Total number of transformed data. */
+ int data_len;
+
+ /** Transformed data extension (array). */
+ TransDataExtension *data_ext;
+ /** Transformed data for 2d (array). */
+ TransData2D *data_2d;
+
+ struct Object *obedit;
+ /** Normalized editmode matrix ('T_EDIT' only). */
+ float obedit_mat[3][3];
+
+ /** if 't->flag & T_POSE', this denotes pose object */
+ struct Object *poseobj;
+
+ /** Center of transformation (in local-space), Calculated from #TransInfo.center_global. */
+ float center_local[3];
+
+ TransCustomDataContainer custom;
+} TransDataContainer;
+
typedef struct TransInfo {
+ TransDataContainer *data_container;
+ int data_container_len;
+ /** Combine length of all #TransDataContainer.data_len
+ * Use to check if nothing is selected or if we have a single selection. */
+ int data_len_all;
+
int mode; /* current mode */
int flag; /* generic flags for special behaviors */
int modifiers; /* special modifiers, by function, not key */
@@ -393,10 +457,6 @@ typedef struct TransInfo {
/* transform function pointer */
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) */
- TransDataExtension *ext; /* transformed data extension (array) */
- TransData2D *data2d; /* transformed data for 2d (array) */
TransCon con; /* transformed constraint */
TransSnap tsnap;
NumInput num; /* numerical input */
@@ -406,7 +466,6 @@ typedef struct TransInfo {
char proptext[20]; /* proportional falloff text */
float aspect[3]; /* spaces using non 1:1 aspect, (uv's, f-curve, movie-clip... etc)
* use for conversion and snapping. */
- float center[3]; /* center of transformation (in local-space) */
float center_global[3]; /* center of transformation (in global-space) */
float center2d[2]; /* center in screen coordinates */
/* Lazy initialize center data for when we need other center values.
@@ -425,6 +484,7 @@ typedef struct TransInfo {
short around;
char spacetype; /* spacetype where transforming is */
char helpline; /* helpline modes (not to be confused with hotline) */
+ short obedit_type; /* Avoid looking inside TransDataContainer obedit. */
float vec[3]; /* translation, to show for widget */
float mat[3][3]; /* rot/rescale, to show for widget */
@@ -432,31 +492,12 @@ typedef struct TransInfo {
float spacemtx[3][3]; /* orientation matrix of the current space */
char spacename[64]; /* name of the current space, MAX_NAME */
- struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */
-
- /**
- * Rule of thumb for choosing between mode/type:
- * - If transform mode uses the data, assign to `mode`
- * (typically in transform.c).
- * - If conversion uses the data as an extension to the #TransData, assign to `type`
- * (typically in transform_conversion.c).
- */
- struct {
- /* owned by the mode (grab, scale, bend... )*/
- union {
- TransCustomData mode, first_elem;
- };
- /* owned by the type (mesh, armature, nla...) */
- TransCustomData type;
- } custom;
-#define TRANS_CUSTOM_DATA_ELEM_MAX (sizeof(((TransInfo *)NULL)->custom) / sizeof(TransCustomData))
-
/*************** NEW STUFF *********************/
short launch_event; /* event type used to launch transform */
short current_orientation;
TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */
- short twtype; /* backup from view3d, to restore on end */
+ short twflag; /* backup from view3d, to restore on end */
short prop_mode;
@@ -469,7 +510,6 @@ typedef struct TransInfo {
bool remove_on_cancel; /* remove elements if operator is canceled */
- EvaluationContext eval_ctx;
void *view;
struct bContext *context; /* Only valid (non null) during an operator called function. */
struct ScrArea *sa;
@@ -477,19 +517,19 @@ typedef struct TransInfo {
struct Depsgraph *depsgraph;
struct Scene *scene;
struct ViewLayer *view_layer;
- struct RenderEngineType *engine_type;
struct ToolSettings *settings;
struct wmTimer *animtimer;
struct wmKeyMap *keymap; /* so we can do lookups for header text */
struct ReportList *reports; /* assign from the operator, or can be NULL */
int mval[2]; /* current mouse position */
float zfac; /* use for 3d view */
- struct Object *obedit;
- float obedit_mat[3][3]; /* normalized editmode matrix (T_EDIT only) */
void *draw_handle_apply;
void *draw_handle_view;
void *draw_handle_pixel;
void *draw_handle_cursor;
+
+ /** Typically for mode settings. */
+ TransCustomDataContainer custom;
} TransInfo;
@@ -649,7 +689,7 @@ void flushTransTracking(TransInfo *t);
void flushTransMasking(TransInfo *t);
void flushTransPaintCurve(TransInfo *t);
void flushTransGroom(TransInfo *t);
-void restoreBones(TransInfo *t);
+void restoreBones(TransDataContainer *tc);
/*********************** transform_manipulator.c ********** */
@@ -759,6 +799,7 @@ void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *t, float val
/*********************** Generics ********************************/
+void initTransDataContainers_FromObjectData(TransInfo *t);
void initTransInfo(struct bContext *C, TransInfo *t, struct wmOperator *op, const struct wmEvent *event);
void postTrans(struct bContext *C, TransInfo *t);
void resetTransModal(TransInfo *t);
@@ -774,9 +815,7 @@ void restoreTransObjects(TransInfo *t);
void recalcData(TransInfo *t);
void calculateCenter2D(TransInfo *t);
-void calculateCenterGlobal(
- TransInfo *t, const float center_local[3],
- float r_center_global[3]);
+void calculateCenterLocal(TransInfo *t, const float center_global[3]);
const TransCenterData *transformCenter_from_type(TransInfo *t, int around);
void calculateCenter(TransInfo *t);
@@ -817,11 +856,11 @@ int getTransformOrientation_ex(const struct bContext *C, float normal[3], float
int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3]);
void freeEdgeSlideTempFaces(EdgeSlideData *sld);
-void freeEdgeSlideVerts(TransInfo *t, TransCustomData *custom_data);
+void freeEdgeSlideVerts(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data);
void projectEdgeSlideData(TransInfo *t, bool is_final);
void freeVertSlideTempFaces(VertSlideData *sld);
-void freeVertSlideVerts(TransInfo *t, TransCustomData *custom_data);
+void freeVertSlideVerts(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data);
void projectVertSlideData(TransInfo *t, bool is_final);
@@ -832,4 +871,22 @@ bool checkUseAxisMatrix(TransInfo *t);
#define TRANSFORM_SNAP_MAX_PX 100.0f
#define TRANSFORM_DIST_INVALID -FLT_MAX
+/* Temp macros. */
+
+/* This is to be replaced, just to get things compiling early on. */
+#define TRANS_DATA_CONTAINER_FIRST_EVIL(t) (&(t)->data_container[0])
+#define TRANS_DATA_CONTAINER_FIRST_OK(t) (&(t)->data_container[0])
+/* For cases we _know_ there is only one handle. */
+#define TRANS_DATA_CONTAINER_FIRST_SINGLE(t) (BLI_assert((t)->data_container_len == 1), (&(t)->data_container[0]))
+
+#define FOREACH_TRANS_DATA_CONTAINER(t, th) \
+ for (TransDataContainer *tc = t->data_container, *tc_end = t->data_container + t->data_container_len; \
+ th != tc_end; \
+ th++)
+
+#define FOREACH_TRANS_DATA_CONTAINER_INDEX(t, th, i) \
+ for (TransDataContainer *tc = ((i = 0), t->data_container), *tc_end = t->data_container + t->data_container_len; \
+ th != tc_end; \
+ th++, i++)
+
#endif
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index f612dc0e474..bc9d0f19389 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -333,7 +333,8 @@ static void planeProjection(TransInfo *t, const float in[3], float out[3])
*
*/
-static void applyAxisConstraintVec(TransInfo *t, TransData *td, const float in[3], float out[3], float pvec[3])
+static void applyAxisConstraintVec(
+ TransInfo *t, TransDataContainer *UNUSED(tc), TransData *td, const float in[3], float out[3], float pvec[3])
{
copy_v3_v3(out, in);
if (!td && t->con.mode & CON_APPLY) {
@@ -380,7 +381,8 @@ static void applyAxisConstraintVec(TransInfo *t, TransData *td, const float in[3
* Further down, that vector is mapped to each data's space.
*/
-static void applyObjectConstraintVec(TransInfo *t, TransData *td, const float in[3], float out[3], float pvec[3])
+static void applyObjectConstraintVec(
+ TransInfo *t, TransDataContainer *tc, TransData *td, const float in[3], float out[3], float pvec[3])
{
copy_v3_v3(out, in);
if (t->con.mode & CON_APPLY) {
@@ -428,7 +430,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, const float in
mul_m3_v3(td->axismtx, out);
if (t->flag & T_EDIT) {
- mul_m3_v3(t->obedit_mat, out);
+ mul_m3_v3(tc->obedit_mat, out);
}
}
}
@@ -438,7 +440,8 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, const float in
* Generic callback for constant spatial constraints applied to resize motion
*/
-static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3])
+static void applyAxisConstraintSize(
+ TransInfo *t, TransDataContainer *UNUSED(tc), TransData *td, float smat[3][3])
{
if (!td && t->con.mode & CON_APPLY) {
float tmat[3][3];
@@ -462,7 +465,8 @@ static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3
* Callback for object based spatial constraints applied to resize motion
*/
-static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3][3])
+static void applyObjectConstraintSize(
+ TransInfo *t, TransDataContainer *tc, TransData *td, float smat[3][3])
{
if (td && t->con.mode & CON_APPLY) {
float tmat[3][3];
@@ -482,7 +486,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3]
mul_m3_m3m3(tmat, smat, imat);
if (t->flag & T_EDIT) {
- mul_m3_m3m3(smat, t->obedit_mat, smat);
+ mul_m3_m3m3(smat, tc->obedit_mat, smat);
}
mul_m3_m3m3(smat, td->axismtx, tmat);
}
@@ -502,7 +506,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3]
* (ie: not doing counterclockwise rotations when the mouse moves clockwise).
*/
-static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle)
+static void applyAxisConstraintRot(TransInfo *t, TransDataContainer *UNUSED(tc), TransData *td, float vec[3], float *angle)
{
if (!td && t->con.mode & CON_APPLY) {
int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
@@ -544,7 +548,8 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl
* (ie: not doing counterclockwise rotations when the mouse moves clockwise).
*/
-static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle)
+static void applyObjectConstraintRot(
+ TransInfo *t, TransDataContainer *tc, TransData *td, float vec[3], float *angle)
{
if (t->con.mode & CON_APPLY) {
int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
@@ -553,11 +558,11 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3],
/* on setup call, use first object */
if (td == NULL) {
- td = t->data;
+ td = tc->data;
}
if (t->flag & T_EDIT) {
- mul_m3_m3m3(tmp_axismtx, t->obedit_mat, td->axismtx);
+ mul_m3_m3m3(tmp_axismtx, tc->obedit_mat, td->axismtx);
axismtx = tmp_axismtx;
}
else {
@@ -607,20 +612,21 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
/* applies individual td->axismtx constraints */
void setAxisMatrixConstraint(TransInfo *t, int mode, const char text[])
{
- if (t->total == 1) {
+ TransDataContainer *tc = t->data_container;
+ if (t->data_len_all == 1) {
float axismtx[3][3];
if (t->flag & T_EDIT) {
- mul_m3_m3m3(axismtx, t->obedit_mat, t->data->axismtx);
+ mul_m3_m3m3(axismtx, tc->obedit_mat, tc->data->axismtx);
}
else {
- copy_m3_m3(axismtx, t->data->axismtx);
+ copy_m3_m3(axismtx, tc->data->axismtx);
}
setConstraint(t, axismtx, mode, text);
}
else {
BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1);
- copy_m3_m3(t->con.mtx, t->data->axismtx);
+ copy_m3_m3(t->con.mtx, tc->data->axismtx);
t->con.mode = mode;
getConstraintMatrix(t);
@@ -638,7 +644,9 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[])
{
/* edit-mode now allows local transforms too */
if (t->flag & T_EDIT) {
- setConstraint(t, t->obedit_mat, mode, text);
+ /* Use the active (first) edit object. */
+ TransDataContainer *tc = t->data_container;
+ setConstraint(t, tc->obedit_mat, mode, text);
}
else {
setAxisMatrixConstraint(t, mode, text);
@@ -836,57 +844,59 @@ static void drawObjectConstraint(TransInfo *t)
* Without drawing the first light, users have little clue what they are doing.
*/
short options = DRAWLIGHT;
- TransData *td = t->data;
int i;
float tmp_axismtx[3][3];
- for (i = 0; i < t->total; i++, td++) {
- float co[3];
- float (*axismtx)[3];
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ 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_PROP_EDIT) {
+ /* we're sorted, so skip the rest */
+ if (td->factor == 0.0f) {
+ break;
+ }
}
- }
- if (t->options & CTX_GPENCIL_STROKES) {
- /* only draw a constraint line for one point, otherwise we can't see anything */
- if ((options & DRAWLIGHT) == 0) {
- break;
+ if (t->options & CTX_GPENCIL_STROKES) {
+ /* only draw a constraint line for one point, otherwise we can't see anything */
+ if ((options & DRAWLIGHT) == 0) {
+ break;
+ }
}
- }
- if (t->flag & T_OBJECT) {
- copy_v3_v3(co, td->ob->obmat[3]);
- axismtx = td->axismtx;
- }
- else if (t->flag & T_EDIT) {
- mul_v3_m4v3(co, t->obedit->obmat, td->center);
+ if (t->flag & T_OBJECT) {
+ copy_v3_v3(co, td->ob->obmat[3]);
+ axismtx = td->axismtx;
+ }
+ else if (t->flag & T_EDIT) {
+ mul_v3_m4v3(co, tc->obedit->obmat, td->center);
- mul_m3_m3m3(tmp_axismtx, t->obedit_mat, td->axismtx);
- axismtx = tmp_axismtx;
- }
- else if (t->flag & T_POSE) {
- mul_v3_m4v3(co, t->poseobj->obmat, td->center);
- axismtx = td->axismtx;
- }
- else {
- copy_v3_v3(co, td->center);
- axismtx = td->axismtx;
- }
+ mul_m3_m3m3(tmp_axismtx, tc->obedit_mat, td->axismtx);
+ axismtx = tmp_axismtx;
+ }
+ else if (t->flag & T_POSE) {
+ mul_v3_m4v3(co, tc->poseobj->obmat, td->center);
+ axismtx = td->axismtx;
+ }
+ else {
+ copy_v3_v3(co, td->center);
+ axismtx = td->axismtx;
+ }
- if (t->con.mode & CON_AXIS0) {
- drawLine(t, co, axismtx[0], 'X', options);
- }
- if (t->con.mode & CON_AXIS1) {
- drawLine(t, co, axismtx[1], 'Y', options);
- }
- if (t->con.mode & CON_AXIS2) {
- drawLine(t, co, axismtx[2], 'Z', options);
+ if (t->con.mode & CON_AXIS0) {
+ drawLine(t, co, axismtx[0], 'X', options);
+ }
+ if (t->con.mode & CON_AXIS1) {
+ drawLine(t, co, axismtx[1], 'Y', options);
+ }
+ if (t->con.mode & CON_AXIS2) {
+ drawLine(t, co, axismtx[2], 'Z', options);
+ }
+ options &= ~DRAWLIGHT;
}
- options &= ~DRAWLIGHT;
}
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 3a1c60e4a65..7ca42e0da8d 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -132,7 +132,7 @@
*/
static void transform_around_single_fallback(TransInfo *t)
{
- if ((t->total == 1) &&
+ if ((t->data_len_all == 1) &&
(ELEM(t->around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEAN, V3D_AROUND_ACTIVE)) &&
(ELEM(t->mode, TFM_RESIZE, TFM_ROTATION, TFM_TRACKBALL)))
{
@@ -173,45 +173,50 @@ static int trans_data_compare_rdist(const void *a, const void *b)
void sort_trans_data_dist(TransInfo *t)
{
- TransData *start = t->data;
- int i;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *start = tc->data;
+ int i;
- for (i = 0; i < t->total && start->flag & TD_SELECTED; i++)
- start++;
-
- if (i < t->total) {
- if (t->flag & T_PROP_CONNECTED)
- qsort(start, t->total - i, sizeof(TransData), trans_data_compare_dist);
- else
- qsort(start, t->total - i, sizeof(TransData), trans_data_compare_rdist);
+ for (i = 0; i < tc->data_len && start->flag & TD_SELECTED; i++) {
+ start++;
+ }
+
+ if (i < tc->data_len) {
+ if (t->flag & T_PROP_CONNECTED)
+ qsort(start, tc->data_len - i, sizeof(TransData), trans_data_compare_dist);
+ else
+ qsort(start, tc->data_len - i, sizeof(TransData), trans_data_compare_rdist);
+ }
}
}
static void sort_trans_data(TransInfo *t)
{
- TransData *sel, *unsel;
- TransData temp;
- unsel = t->data;
- sel = t->data;
- sel += t->total - 1;
- while (sel > unsel) {
- while (unsel->flag & TD_SELECTED) {
- unsel++;
- if (unsel == sel) {
- return;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *sel, *unsel;
+ TransData temp;
+ unsel = tc->data;
+ sel = tc->data;
+ sel += tc->data_len - 1;
+ while (sel > unsel) {
+ while (unsel->flag & TD_SELECTED) {
+ unsel++;
+ if (unsel == sel) {
+ return;
+ }
}
- }
- while (!(sel->flag & TD_SELECTED)) {
- sel--;
- if (unsel == sel) {
- return;
+ while (!(sel->flag & TD_SELECTED)) {
+ sel--;
+ if (unsel == sel) {
+ return;
+ }
}
+ temp = *unsel;
+ *unsel = *sel;
+ *sel = temp;
+ sel--;
+ unsel++;
}
- temp = *unsel;
- *unsel = *sel;
- *sel = temp;
- sel--;
- unsel++;
}
}
@@ -219,7 +224,6 @@ static void sort_trans_data(TransInfo *t)
* warning; this is loops inside loop, has minor N^2 issues, but by sorting list it is OK */
static void set_prop_dist(TransInfo *t, const bool with_dist)
{
- TransData *tob;
int a;
float _proj_vec[3];
@@ -236,49 +240,52 @@ static void set_prop_dist(TransInfo *t, const bool with_dist)
}
}
- for (a = 0, tob = t->data; a < t->total; a++, tob++) {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *tob = tc->data;
+ for (a = 0; a < tc->data_len; a++, tob++) {
- tob->rdist = 0.0f; // init, it was mallocced
+ tob->rdist = 0.0f; // init, it was mallocced
- if ((tob->flag & TD_SELECTED) == 0) {
- TransData *td;
- int i;
- float dist_sq, vec[3];
+ if ((tob->flag & TD_SELECTED) == 0) {
+ TransData *td;
+ int i;
+ float dist_sq, vec[3];
- tob->rdist = -1.0f; // signal for next loop
+ tob->rdist = -1.0f; // signal for next loop
- for (i = 0, td = t->data; i < t->total; i++, td++) {
- if (td->flag & TD_SELECTED) {
- if (use_island) {
- sub_v3_v3v3(vec, tob->iloc, td->iloc);
- }
- else {
- sub_v3_v3v3(vec, tob->center, td->center);
- }
- mul_m3_v3(tob->mtx, vec);
+ for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SELECTED) {
+ if (use_island) {
+ sub_v3_v3v3(vec, tob->iloc, td->iloc);
+ }
+ else {
+ sub_v3_v3v3(vec, tob->center, td->center);
+ }
+ mul_m3_v3(tob->mtx, vec);
- if (proj_vec) {
- float vec_p[3];
- project_v3_v3v3(vec_p, vec, proj_vec);
- sub_v3_v3(vec, vec_p);
- }
+ if (proj_vec) {
+ float vec_p[3];
+ project_v3_v3v3(vec_p, vec, proj_vec);
+ sub_v3_v3(vec, vec_p);
+ }
- dist_sq = len_squared_v3(vec);
- if ((tob->rdist == -1.0f) || (dist_sq < SQUARE(tob->rdist))) {
- tob->rdist = sqrtf(dist_sq);
- if (use_island) {
- copy_v3_v3(tob->center, td->center);
- copy_m3_m3(tob->axismtx, td->axismtx);
+ dist_sq = len_squared_v3(vec);
+ if ((tob->rdist == -1.0f) || (dist_sq < SQUARE(tob->rdist))) {
+ tob->rdist = sqrtf(dist_sq);
+ if (use_island) {
+ copy_v3_v3(tob->center, td->center);
+ copy_m3_m3(tob->axismtx, td->axismtx);
+ }
}
}
+ else {
+ break; /* by definition transdata has selected items in beginning */
+ }
}
- else {
- break; /* by definition transdata has selected items in beginning */
+ if (with_dist) {
+ tob->dist = tob->rdist;
}
}
- if (with_dist) {
- tob->dist = tob->rdist;
- }
}
}
}
@@ -298,26 +305,32 @@ static void createTransTexspace(TransInfo *t)
ob = OBACT(view_layer);
if (ob == NULL) { // Shouldn't logically happen, but still...
- t->total = 0;
+ t->data_len_all = 0;
return;
}
id = ob->data;
if (id == NULL || !ELEM(GS(id->name), ID_ME, ID_CU, ID_MB)) {
BKE_report(t->reports, RPT_ERROR, "Unsupported object type for text-space transform");
- t->total = 0;
+ t->data_len_all = 0;
return;
}
if (BKE_object_obdata_is_libdata(ob)) {
BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
- t->total = 0;
+ t->data_len_all = 0;
return;
}
- t->total = 1;
- td = t->data = MEM_callocN(sizeof(TransData), "TransTexspace");
- td->ext = t->ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
+
+ {
+ TransDataContainer *tc = t->data_container = MEM_callocN(sizeof(*t->data_container), __func__);
+ tc->data_len = 1;
+ td = tc->data = MEM_callocN(sizeof(TransData), "TransTexspace");
+ td->ext = tc->data_ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
+ }
+
+ t->data_len_all = 1;
td->flag = TD_SELECTED;
copy_v3_v3(td->center, ob->obmat[3]);
@@ -342,72 +355,77 @@ static void createTransTexspace(TransInfo *t)
static void createTransEdge(TransInfo *t)
{
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
- TransData *td = NULL;
- BMEdge *eed;
- BMIter iter;
- float mtx[3][3], smtx[3][3];
- int count = 0, countsel = 0;
- const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
- int cd_edge_float_offset;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) countsel++;
- if (is_prop_edit) count++;
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
+ TransData *td = NULL;
+ BMEdge *eed;
+ BMIter iter;
+ float mtx[3][3], smtx[3][3];
+ int count = 0, countsel = 0;
+ const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+ int cd_edge_float_offset;
+
+ BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) countsel++;
+ if (is_prop_edit) count++;
+ }
}
- }
- if (countsel == 0)
- return;
+ if (countsel == 0) {
+ tc->data_len = 0;
+ continue;
+ }
- if (is_prop_edit) {
- t->total = count;
- }
- else {
- t->total = countsel;
- }
+ if (is_prop_edit) {
+ tc->data_len = count;
+ }
+ else {
+ tc->data_len = countsel;
+ }
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransCrease");
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransCrease");
- copy_m3_m4(mtx, t->obedit->obmat);
- pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
+ copy_m3_m4(mtx, tc->obedit->obmat);
+ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
- /* create data we need */
- if (t->mode == TFM_BWEIGHT) {
- BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(t->obedit), ME_CDFLAG_EDGE_BWEIGHT);
- cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT);
- }
- else { //if (t->mode == TFM_CREASE) {
- BLI_assert(t->mode == TFM_CREASE);
- BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(t->obedit), ME_CDFLAG_EDGE_CREASE);
- cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE);
- }
+ /* create data we need */
+ if (t->mode == TFM_BWEIGHT) {
+ BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_BWEIGHT);
+ cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT);
+ }
+ else { //if (t->mode == TFM_CREASE) {
+ BLI_assert(t->mode == TFM_CREASE);
+ BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_CREASE);
+ cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE);
+ }
- BLI_assert(cd_edge_float_offset != -1);
+ BLI_assert(cd_edge_float_offset != -1);
- BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed, BM_ELEM_SELECT) || is_prop_edit)) {
- float *fl_ptr;
- /* need to set center for center calculations */
- mid_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
+ BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed, BM_ELEM_SELECT) || is_prop_edit)) {
+ float *fl_ptr;
+ /* need to set center for center calculations */
+ mid_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
- td->loc = NULL;
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
- td->flag = TD_SELECTED;
- else
- td->flag = 0;
+ td->loc = NULL;
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
+ td->flag = TD_SELECTED;
+ else
+ td->flag = 0;
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
- td->ext = NULL;
+ td->ext = NULL;
- fl_ptr = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_float_offset);
- td->val = fl_ptr;
- td->ival = *fl_ptr;
+ fl_ptr = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_float_offset);
+ td->val = fl_ptr;
+ td->ival = *fl_ptr;
- td++;
+ td++;
+ }
}
}
}
@@ -525,7 +543,7 @@ static short apply_targetless_ik(Object *ob)
return apply;
}
-static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, TransData *td)
+static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, TransDataContainer *tc, TransData *td)
{
Bone *bone = pchan->bone;
float pmat[3][3], omat[3][3];
@@ -636,7 +654,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
normalize_m3(td->axismtx);
if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
- bArmature *arm = t->poseobj->data;
+ bArmature *arm = tc->poseobj->data;
if ((t->mode == TFM_BONE_ENVELOPE_DIST) || (arm->drawtype == ARM_ENVELOPE)) {
td->loc = NULL;
@@ -830,14 +848,19 @@ void transform_autoik_update(TransInfo *t, short mode)
}
}
- /* sanity checks (don't assume t->poseobj is set, or that it is an armature) */
- if (ELEM(NULL, t->poseobj, t->poseobj->pose))
- return;
-
/* apply to all pose-channels */
bool changed = false;
- for (pchan = t->poseobj->pose->chanbase.first; pchan; pchan = pchan->next) {
- changed |= pchan_autoik_adjust(pchan, *chainlen);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+
+ /* sanity checks (don't assume t->poseobj is set, or that it is an armature) */
+ if (ELEM(NULL, tc->poseobj, tc->poseobj->pose)) {
+ continue;
+ }
+
+ for (pchan = tc->poseobj->pose->chanbase.first; pchan; pchan = pchan->next) {
+ changed |= pchan_autoik_adjust(pchan, *chainlen);
+ }
}
if (changed) {
@@ -1047,75 +1070,101 @@ static short pose_grab_with_ik(Object *ob)
}
-/* only called with pose mode active object now */
-static void createTransPose(TransInfo *t, Object *ob)
+/**
+ * When objects array is NULL, use 't->data_container' as is.
+ */
+static void createTransPose(TransInfo *t, Object **objects, uint objects_len)
{
- bArmature *arm;
- bPoseChannel *pchan;
- TransData *td;
- TransDataExtension *tdx;
- short ik_on = 0;
- int i;
+ if (objects != NULL) {
+ if (t->data_container) {
+ MEM_freeN(t->data_container);
+ }
+ t->data_container = MEM_callocN(sizeof(*t->data_container) * objects_len, __func__);
+ t->data_container_len = objects_len;
+ int th_index;
+ FOREACH_TRANS_DATA_CONTAINER_INDEX (t, tc, th_index) {
+ tc->poseobj = objects[th_index];
+ }
+ }
- t->total = 0;
+ t->data_len_all = 0;
- /* check validity of state */
- arm = BKE_armature_from_object(ob);
- if ((arm == NULL) || (ob->pose == NULL)) return;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Object *ob = tc->poseobj;
- if (arm->flag & ARM_RESTPOS) {
- if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE) == 0) {
- BKE_report(t->reports, RPT_ERROR, "Cannot change Pose when 'Rest Position' is enabled");
- return;
+ bArmature *arm;
+ bPoseChannel *pchan;
+ TransData *td;
+ TransDataExtension *tdx;
+ short ik_on = 0;
+ int i;
+
+
+ /* check validity of state */
+ arm = BKE_armature_from_object(tc->poseobj);
+ if ((arm == NULL) || (ob->pose == NULL)) {
+ continue;
}
- }
- /* do we need to add temporal IK chains? */
- if ((arm->flag & ARM_AUTO_IK) && t->mode == TFM_TRANSLATION) {
- ik_on = pose_grab_with_ik(ob);
- if (ik_on) t->flag |= T_AUTOIK;
- }
+ if (arm->flag & ARM_RESTPOS) {
+ if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE) == 0) {
+ BKE_report(t->reports, RPT_ERROR, "Cannot change Pose when 'Rest Position' is enabled");
+ return;
+ }
+ }
- /* set flags and count total (warning, can change transform to rotate) */
- t->total = count_set_pose_transflags(&t->mode, t->around, ob);
+ /* do we need to add temporal IK chains? */
+ if ((arm->flag & ARM_AUTO_IK) && t->mode == TFM_TRANSLATION) {
+ ik_on = pose_grab_with_ik(ob);
+ if (ik_on) t->flag |= T_AUTOIK;
+ }
- if (t->total == 0) return;
+ /* set flags and count total (warning, can change transform to rotate) */
+ tc->data_len = count_set_pose_transflags(&t->mode, t->around, ob);
- t->flag |= T_POSE;
- t->poseobj = ob; /* we also allow non-active objects to be transformed, in weightpaint */
+ if (tc->data_len == 0) {
+ continue;
+ }
- /* disable PET, its not usable in pose mode yet [#32444] */
- t->flag &= ~T_PROP_EDIT_ALL;
+ tc->poseobj = ob; /* we also allow non-active objects to be transformed, in weightpaint */
- /* init trans data */
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransPoseBone");
- tdx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "TransPoseBoneExt");
- for (i = 0; i < t->total; i++, td++, tdx++) {
- td->ext = tdx;
- td->val = NULL;
- }
+ /* init trans data */
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransPoseBone");
+ tdx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension), "TransPoseBoneExt");
+ for (i = 0; i < tc->data_len; i++, td++, tdx++) {
+ td->ext = tdx;
+ td->val = NULL;
+ }
- /* use pose channels to fill trans data */
- td = t->data;
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->bone->flag & BONE_TRANSFORM) {
- add_pose_transdata(t, pchan, ob, td);
- td++;
+ /* use pose channels to fill trans data */
+ td = tc->data;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (pchan->bone->flag & BONE_TRANSFORM) {
+ add_pose_transdata(t, pchan, ob, tc, td);
+ td++;
+ }
+ }
+
+ if (td != (tc->data + tc->data_len)) {
+ BKE_report(t->reports, RPT_DEBUG, "Bone selection count error");
}
- }
- if (td != (t->data + t->total)) {
- BKE_report(t->reports, RPT_DEBUG, "Bone selection count error");
+ /* initialize initial auto=ik chainlen's? */
+ if (ik_on) {
+ transform_autoik_update(t, 0);
+ }
}
- /* initialize initial auto=ik chainlen's? */
- if (ik_on) transform_autoik_update(t, 0);
+ t->flag |= T_POSE;
+ /* disable PET, its not usable in pose mode yet [#32444] */
+ t->flag &= ~T_PROP_EDIT_ALL;
+
}
-void restoreBones(TransInfo *t)
+void restoreBones(TransDataContainer *tc)
{
- bArmature *arm = t->obedit->data;
- BoneInitData *bid = t->custom.type.data;
+ bArmature *arm = tc->obedit->data;
+ BoneInitData *bid = tc->custom.type.data;
EditBone *ebo;
while (bid->bone) {
@@ -1156,226 +1205,230 @@ void restoreBones(TransInfo *t)
/* ********************* armature ************** */
static void createTransArmatureVerts(TransInfo *t)
{
- EditBone *ebo, *eboflip;
- bArmature *arm = t->obedit->data;
- ListBase *edbo = arm->edbo;
- TransData *td, *td_old;
- float mtx[3][3], smtx[3][3], bonemat[3][3];
- bool mirror = ((arm->flag & ARM_MIRROR_EDIT) != 0);
- int total_mirrored = 0, i;
- int oldtot;
- BoneInitData *bid;
-
- t->total = 0;
- for (ebo = edbo->first; ebo; ebo = ebo->next) {
- oldtot = t->total;
-
- if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
- if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
- if (ebo->flag & BONE_SELECTED)
- t->total++;
- }
- else if (t->mode == TFM_BONE_ROLL) {
- if (ebo->flag & BONE_SELECTED)
- t->total++;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ EditBone *ebo, *eboflip;
+ bArmature *arm = tc->obedit->data;
+ ListBase *edbo = arm->edbo;
+ TransData *td, *td_old;
+ float mtx[3][3], smtx[3][3], bonemat[3][3];
+ bool mirror = ((arm->flag & ARM_MIRROR_EDIT) != 0);
+ int total_mirrored = 0, i;
+ int oldtot;
+ BoneInitData *bid;
+
+ tc->data_len = 0;
+ for (ebo = edbo->first; ebo; ebo = ebo->next) {
+ oldtot = tc->data_len;
+
+ if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
+ if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
+ if (ebo->flag & BONE_SELECTED)
+ tc->data_len++;
+ }
+ else if (t->mode == TFM_BONE_ROLL) {
+ if (ebo->flag & BONE_SELECTED)
+ tc->data_len++;
+ }
+ else {
+ if (ebo->flag & BONE_TIPSEL)
+ tc->data_len++;
+ if (ebo->flag & BONE_ROOTSEL)
+ tc->data_len++;
+ }
}
- else {
- if (ebo->flag & BONE_TIPSEL)
- t->total++;
- if (ebo->flag & BONE_ROOTSEL)
- t->total++;
+
+ if (mirror && (oldtot < tc->data_len)) {
+ eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo);
+ if (eboflip)
+ total_mirrored++;
}
}
- if (mirror && (oldtot < t->total)) {
- eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo);
- if (eboflip)
- total_mirrored++;
+ if (!tc->data_len) {
+ continue;
}
- }
- if (!t->total) return;
+ transform_around_single_fallback(t);
- transform_around_single_fallback(t);
+ copy_m3_m4(mtx, tc->obedit->obmat);
+ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
- copy_m3_m4(mtx, t->obedit->obmat);
- pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransEditBone");
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransEditBone");
+ if (mirror) {
+ tc->custom.type.data = bid = MEM_mallocN((total_mirrored + 1) * sizeof(BoneInitData), "BoneInitData");
+ tc->custom.type.use_free = true;
+ }
- if (mirror) {
- t->custom.type.data = bid = MEM_mallocN((total_mirrored + 1) * sizeof(BoneInitData), "BoneInitData");
- t->custom.type.use_free = true;
- }
+ i = 0;
- i = 0;
+ for (ebo = edbo->first; ebo; ebo = ebo->next) {
+ td_old = td;
+ ebo->oldlength = ebo->length; // length==0.0 on extrude, used for scaling radius of bone points
- for (ebo = edbo->first; ebo; ebo = ebo->next) {
- td_old = td;
- ebo->oldlength = ebo->length; // length==0.0 on extrude, used for scaling radius of bone points
+ if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
+ if (t->mode == TFM_BONE_ENVELOPE) {
+ if (ebo->flag & BONE_ROOTSEL) {
+ td->val = &ebo->rad_head;
+ td->ival = *td->val;
- if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
- if (t->mode == TFM_BONE_ENVELOPE) {
- if (ebo->flag & BONE_ROOTSEL) {
- td->val = &ebo->rad_head;
- td->ival = *td->val;
+ copy_v3_v3(td->center, ebo->head);
+ td->flag = TD_SELECTED;
- copy_v3_v3(td->center, ebo->head);
- td->flag = TD_SELECTED;
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
+ td->loc = NULL;
+ td->ext = NULL;
+ td->ob = tc->obedit;
- td->loc = NULL;
- td->ext = NULL;
- td->ob = t->obedit;
+ td++;
+ }
+ if (ebo->flag & BONE_TIPSEL) {
+ td->val = &ebo->rad_tail;
+ td->ival = *td->val;
+ copy_v3_v3(td->center, ebo->tail);
+ td->flag = TD_SELECTED;
- td++;
- }
- if (ebo->flag & BONE_TIPSEL) {
- td->val = &ebo->rad_tail;
- td->ival = *td->val;
- copy_v3_v3(td->center, ebo->tail);
- td->flag = TD_SELECTED;
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
+ td->loc = NULL;
+ td->ext = NULL;
+ td->ob = tc->obedit;
- td->loc = NULL;
- td->ext = NULL;
- td->ob = t->obedit;
+ td++;
+ }
- td++;
}
+ else if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
+ if (ebo->flag & BONE_SELECTED) {
+ if ((t->mode == TFM_BONE_ENVELOPE_DIST) || (arm->drawtype == ARM_ENVELOPE)) {
+ td->loc = NULL;
+ td->val = &ebo->dist;
+ td->ival = ebo->dist;
+ }
+ else {
+ // abusive storage of scale in the loc pointer :)
+ td->loc = &ebo->xwidth;
+ copy_v3_v3(td->iloc, td->loc);
+ td->val = NULL;
+ }
+ copy_v3_v3(td->center, ebo->head);
+ td->flag = TD_SELECTED;
- }
- else if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
- if (ebo->flag & BONE_SELECTED) {
- if ((t->mode == TFM_BONE_ENVELOPE_DIST) || (arm->drawtype == ARM_ENVELOPE)) {
- td->loc = NULL;
- td->val = &ebo->dist;
- td->ival = ebo->dist;
- }
- else {
- // abusive storage of scale in the loc pointer :)
- td->loc = &ebo->xwidth;
- copy_v3_v3(td->iloc, td->loc);
- td->val = NULL;
- }
- copy_v3_v3(td->center, ebo->head);
- td->flag = TD_SELECTED;
-
- /* use local bone matrix */
- ED_armature_ebone_to_mat3(ebo, bonemat);
- mul_m3_m3m3(td->mtx, mtx, bonemat);
- invert_m3_m3(td->smtx, td->mtx);
+ /* use local bone matrix */
+ ED_armature_ebone_to_mat3(ebo, bonemat);
+ mul_m3_m3m3(td->mtx, mtx, bonemat);
+ invert_m3_m3(td->smtx, td->mtx);
- copy_m3_m3(td->axismtx, td->mtx);
- normalize_m3(td->axismtx);
+ copy_m3_m3(td->axismtx, td->mtx);
+ normalize_m3(td->axismtx);
- td->ext = NULL;
- td->ob = t->obedit;
+ td->ext = NULL;
+ td->ob = tc->obedit;
- td++;
+ td++;
+ }
}
- }
- else if (t->mode == TFM_BONE_ROLL) {
- if (ebo->flag & BONE_SELECTED) {
- td->loc = NULL;
- td->val = &(ebo->roll);
- td->ival = ebo->roll;
+ else if (t->mode == TFM_BONE_ROLL) {
+ if (ebo->flag & BONE_SELECTED) {
+ td->loc = NULL;
+ td->val = &(ebo->roll);
+ td->ival = ebo->roll;
- copy_v3_v3(td->center, ebo->head);
- td->flag = TD_SELECTED;
+ copy_v3_v3(td->center, ebo->head);
+ td->flag = TD_SELECTED;
- td->ext = NULL;
- td->ob = t->obedit;
+ td->ext = NULL;
+ td->ob = tc->obedit;
- td++;
- }
- }
- else {
- if (ebo->flag & BONE_TIPSEL) {
- copy_v3_v3(td->iloc, ebo->tail);
-
- /* Don't allow single selected tips to have a modified center,
- * causes problem with snapping (see T45974).
- * However, in rotation mode, we want to keep that 'rotate bone around root with
- * only its tip selected' behavior (see T46325). */
- if ((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
- ((t->mode == TFM_ROTATION) || (ebo->flag & BONE_ROOTSEL)))
- {
- copy_v3_v3(td->center, ebo->head);
- }
- else {
- copy_v3_v3(td->center, td->iloc);
+ td++;
}
+ }
+ else {
+ if (ebo->flag & BONE_TIPSEL) {
+ copy_v3_v3(td->iloc, ebo->tail);
+
+ /* Don't allow single selected tips to have a modified center,
+ * causes problem with snapping (see T45974).
+ * However, in rotation mode, we want to keep that 'rotate bone around root with
+ * only its tip selected' behavior (see T46325). */
+ if ((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
+ ((t->mode == TFM_ROTATION) || (ebo->flag & BONE_ROOTSEL)))
+ {
+ copy_v3_v3(td->center, ebo->head);
+ }
+ else {
+ copy_v3_v3(td->center, td->iloc);
+ }
- td->loc = ebo->tail;
- td->flag = TD_SELECTED;
- if (ebo->flag & BONE_EDITMODE_LOCKED)
- td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
+ td->loc = ebo->tail;
+ td->flag = TD_SELECTED;
+ if (ebo->flag & BONE_EDITMODE_LOCKED)
+ td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
- ED_armature_ebone_to_mat3(ebo, td->axismtx);
+ ED_armature_ebone_to_mat3(ebo, td->axismtx);
- if ((ebo->flag & BONE_ROOTSEL) == 0) {
- td->extra = ebo;
- td->ival = ebo->roll;
- }
+ if ((ebo->flag & BONE_ROOTSEL) == 0) {
+ td->extra = ebo;
+ td->ival = ebo->roll;
+ }
- td->ext = NULL;
- td->val = NULL;
- td->ob = t->obedit;
+ td->ext = NULL;
+ td->val = NULL;
+ td->ob = tc->obedit;
- td++;
- }
- if (ebo->flag & BONE_ROOTSEL) {
- copy_v3_v3(td->iloc, ebo->head);
- copy_v3_v3(td->center, td->iloc);
- td->loc = ebo->head;
- td->flag = TD_SELECTED;
- if (ebo->flag & BONE_EDITMODE_LOCKED)
- td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
+ td++;
+ }
+ if (ebo->flag & BONE_ROOTSEL) {
+ copy_v3_v3(td->iloc, ebo->head);
+ copy_v3_v3(td->center, td->iloc);
+ td->loc = ebo->head;
+ td->flag = TD_SELECTED;
+ if (ebo->flag & BONE_EDITMODE_LOCKED)
+ td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
- ED_armature_ebone_to_mat3(ebo, td->axismtx);
+ ED_armature_ebone_to_mat3(ebo, td->axismtx);
- td->extra = ebo; /* to fix roll */
- td->ival = ebo->roll;
+ td->extra = ebo; /* to fix roll */
+ td->ival = ebo->roll;
- td->ext = NULL;
- td->val = NULL;
- td->ob = t->obedit;
+ td->ext = NULL;
+ td->val = NULL;
+ td->ob = tc->obedit;
- td++;
+ td++;
+ }
}
}
- }
- if (mirror && (td_old != td)) {
- eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo);
- if (eboflip) {
- bid[i].bone = eboflip;
- bid[i].dist = eboflip->dist;
- bid[i].rad_tail = eboflip->rad_tail;
- bid[i].roll = eboflip->roll;
- bid[i].xwidth = eboflip->xwidth;
- bid[i].zwidth = eboflip->zwidth;
- copy_v3_v3(bid[i].head, eboflip->head);
- copy_v3_v3(bid[i].tail, eboflip->tail);
- i++;
+ if (mirror && (td_old != td)) {
+ eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo);
+ if (eboflip) {
+ bid[i].bone = eboflip;
+ bid[i].dist = eboflip->dist;
+ bid[i].rad_tail = eboflip->rad_tail;
+ bid[i].roll = eboflip->roll;
+ bid[i].xwidth = eboflip->xwidth;
+ bid[i].zwidth = eboflip->zwidth;
+ copy_v3_v3(bid[i].head, eboflip->head);
+ copy_v3_v3(bid[i].tail, eboflip->tail);
+ i++;
+ }
}
}
- }
- if (mirror) {
- /* trick to terminate iteration */
- bid[total_mirrored].bone = NULL;
+ if (mirror) {
+ /* trick to terminate iteration */
+ bid[total_mirrored].bone = NULL;
+ }
}
}
@@ -1383,72 +1436,76 @@ static void createTransArmatureVerts(TransInfo *t)
static void createTransMBallVerts(TransInfo *t)
{
- MetaBall *mb = (MetaBall *)t->obedit->data;
- MetaElem *ml;
- TransData *td;
- TransDataExtension *tx;
- float mtx[3][3], smtx[3][3];
- int count = 0, countsel = 0;
- const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
-
- /* count totals */
- for (ml = mb->editelems->first; ml; ml = ml->next) {
- if (ml->flag & SELECT) countsel++;
- if (is_prop_edit) count++;
- }
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ MetaBall *mb = (MetaBall *)tc->obedit->data;
+ MetaElem *ml;
+ TransData *td;
+ TransDataExtension *tx;
+ float mtx[3][3], smtx[3][3];
+ int count = 0, countsel = 0;
+ const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+
+ /* count totals */
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
+ if (ml->flag & SELECT) countsel++;
+ if (is_prop_edit) count++;
+ }
- /* note: in prop mode we need at least 1 selected */
- if (countsel == 0) return;
+ /* note: in prop mode we need at least 1 selected */
+ if (countsel == 0) {
+ continue;
+ }
- if (is_prop_edit) t->total = count;
- else t->total = countsel;
+ if (is_prop_edit) tc->data_len = count;
+ else tc->data_len = countsel;
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(MBall EditMode)");
- tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "MetaElement_TransExtension");
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(MBall EditMode)");
+ tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension), "MetaElement_TransExtension");
- copy_m3_m4(mtx, t->obedit->obmat);
- pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
+ copy_m3_m4(mtx, tc->obedit->obmat);
+ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
- for (ml = mb->editelems->first; ml; ml = ml->next) {
- if (is_prop_edit || (ml->flag & SELECT)) {
- td->loc = &ml->x;
- copy_v3_v3(td->iloc, td->loc);
- copy_v3_v3(td->center, td->loc);
+ for (ml = mb->editelems->first; ml; ml = ml->next) {
+ if (is_prop_edit || (ml->flag & SELECT)) {
+ td->loc = &ml->x;
+ copy_v3_v3(td->iloc, td->loc);
+ copy_v3_v3(td->center, td->loc);
- quat_to_mat3(td->axismtx, ml->quat);
+ quat_to_mat3(td->axismtx, ml->quat);
- if (ml->flag & SELECT) td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
- else td->flag = TD_USEQUAT;
+ if (ml->flag & SELECT) td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
+ else td->flag = TD_USEQUAT;
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
- td->ext = tx;
+ td->ext = tx;
- /* Radius of MetaElem (mass of MetaElem influence) */
- if (ml->flag & MB_SCALE_RAD) {
- td->val = &ml->rad;
- td->ival = ml->rad;
- }
- else {
- td->val = &ml->s;
- td->ival = ml->s;
- }
+ /* Radius of MetaElem (mass of MetaElem influence) */
+ if (ml->flag & MB_SCALE_RAD) {
+ td->val = &ml->rad;
+ td->ival = ml->rad;
+ }
+ else {
+ td->val = &ml->s;
+ td->ival = ml->s;
+ }
- /* expx/expy/expz determine "shape" of some MetaElem types */
- tx->size = &ml->expx;
- tx->isize[0] = ml->expx;
- tx->isize[1] = ml->expy;
- tx->isize[2] = ml->expz;
+ /* expx/expy/expz determine "shape" of some MetaElem types */
+ tx->size = &ml->expx;
+ tx->isize[0] = ml->expx;
+ tx->isize[1] = ml->expy;
+ tx->isize[2] = ml->expz;
- /* quat is used for rotation of MetaElem */
- tx->quat = ml->quat;
- copy_qt_qt(tx->iquat, ml->quat);
+ /* quat is used for rotation of MetaElem */
+ tx->quat = ml->quat;
+ copy_qt_qt(tx->iquat, ml->quat);
- tx->rot = NULL;
+ tx->rot = NULL;
- td++;
- tx++;
+ td++;
+ tx++;
+ }
}
}
}
@@ -1557,271 +1614,277 @@ static int bezt_select_to_transform_triple_flag(
static void createTransCurveVerts(TransInfo *t)
{
- Curve *cu = t->obedit->data;
- TransData *td = NULL;
- Nurb *nu;
- BezTriple *bezt;
- BPoint *bp;
- float mtx[3][3], smtx[3][3];
- int a;
- int count = 0, countsel = 0;
- const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
- short hide_handles = (cu->drawflag & CU_HIDE_HANDLES);
- ListBase *nurbs;
-
- /* to be sure */
- if (cu->editnurb == NULL) return;
#define SEL_F1 (1 << 0)
#define SEL_F2 (1 << 1)
#define SEL_F3 (1 << 2)
- /* count total of vertices, check identical as in 2nd loop for making transdata! */
- nurbs = BKE_curve_editNurbs_get(cu);
- for (nu = nurbs->first; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER) {
- for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
- if (bezt->hide == 0) {
- const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, hide_handles);
- if (bezt_tx & SEL_F1) { countsel++; }
- if (bezt_tx & SEL_F2) { countsel++; }
- if (bezt_tx & SEL_F3) { countsel++; }
- if (is_prop_edit) count += 3;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Curve *cu = tc->obedit->data;
+ TransData *td = NULL;
+ Nurb *nu;
+ BezTriple *bezt;
+ BPoint *bp;
+ float mtx[3][3], smtx[3][3];
+ int a;
+ int count = 0, countsel = 0;
+ const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+ short hide_handles = (cu->drawflag & CU_HIDE_HANDLES);
+ ListBase *nurbs;
+
+ /* to be sure */
+ if (cu->editnurb == NULL) return;
+
+ /* count total of vertices, check identical as in 2nd loop for making transdata! */
+ nurbs = BKE_curve_editNurbs_get(cu);
+ for (nu = nurbs->first; nu; nu = nu->next) {
+ if (nu->type == CU_BEZIER) {
+ for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
+ if (bezt->hide == 0) {
+ const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, hide_handles);
+ if (bezt_tx & SEL_F1) { countsel++; }
+ if (bezt_tx & SEL_F2) { countsel++; }
+ if (bezt_tx & SEL_F3) { countsel++; }
+ if (is_prop_edit) count += 3;
+
+ }
}
}
- }
- else {
- for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
- if (bp->hide == 0) {
- if (is_prop_edit) count++;
- if (bp->f1 & SELECT) countsel++;
+ else {
+ for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
+ if (bp->hide == 0) {
+ if (is_prop_edit) count++;
+ if (bp->f1 & SELECT) countsel++;
+ }
}
}
}
- }
- /* note: in prop mode we need at least 1 selected */
- if (countsel == 0) return;
+ /* note: in prop mode we need at least 1 selected */
+ if (countsel == 0) {
+ tc->data_len = 0;
+ continue;
+ }
- if (is_prop_edit) t->total = count;
- else t->total = countsel;
- t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Curve EditMode)");
+ if (is_prop_edit) tc->data_len = count;
+ else tc->data_len = countsel;
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Curve EditMode)");
- transform_around_single_fallback(t);
+ transform_around_single_fallback(t);
- copy_m3_m4(mtx, t->obedit->obmat);
- pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
+ copy_m3_m4(mtx, tc->obedit->obmat);
+ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
- td = t->data;
- for (nu = nurbs->first; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER) {
- TransData *head, *tail;
- head = tail = td;
- for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
- if (bezt->hide == 0) {
- TransDataCurveHandleFlags *hdata = NULL;
- float axismtx[3][3];
+ td = tc->data;
+ for (nu = nurbs->first; nu; nu = nu->next) {
+ if (nu->type == CU_BEZIER) {
+ TransData *head, *tail;
+ head = tail = td;
+ for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
+ if (bezt->hide == 0) {
+ TransDataCurveHandleFlags *hdata = NULL;
+ float axismtx[3][3];
- if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
- float normal[3], plane[3];
+ if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
+ float normal[3], plane[3];
- BKE_nurb_bezt_calc_normal(nu, bezt, normal);
- BKE_nurb_bezt_calc_plane(nu, bezt, plane);
+ BKE_nurb_bezt_calc_normal(nu, bezt, normal);
+ BKE_nurb_bezt_calc_plane(nu, bezt, plane);
- if (createSpaceNormalTangent(axismtx, normal, plane)) {
- /* pass */
- }
- else {
- normalize_v3(normal);
- axis_dominant_v3_to_m3(axismtx, normal);
- invert_m3(axismtx);
+ if (createSpaceNormalTangent(axismtx, normal, plane)) {
+ /* pass */
+ }
+ else {
+ normalize_v3(normal);
+ axis_dominant_v3_to_m3(axismtx, normal);
+ invert_m3(axismtx);
+ }
}
- }
- /* Elements that will be transform (not always a match to selection). */
- const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, hide_handles);
+ /* Elements that will be transform (not always a match to selection). */
+ const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, hide_handles);
+
+ if (is_prop_edit || bezt_tx & SEL_F1) {
+ copy_v3_v3(td->iloc, bezt->vec[0]);
+ td->loc = bezt->vec[0];
+ copy_v3_v3(td->center, bezt->vec[(hide_handles ||
+ (t->around == V3D_AROUND_LOCAL_ORIGINS) ||
+ (bezt->f2 & SELECT)) ? 1 : 0]);
+ if (hide_handles) {
+ if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
+ }
+ else {
+ if (bezt->f1 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
+ }
+ td->ext = NULL;
+ td->val = NULL;
- if (is_prop_edit || bezt_tx & SEL_F1) {
- copy_v3_v3(td->iloc, bezt->vec[0]);
- td->loc = bezt->vec[0];
- copy_v3_v3(td->center, bezt->vec[(hide_handles ||
- (t->around == V3D_AROUND_LOCAL_ORIGINS) ||
- (bezt->f2 & SELECT)) ? 1 : 0]);
- if (hide_handles) {
- if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
- else td->flag = 0;
- }
- else {
- if (bezt->f1 & SELECT) td->flag = TD_SELECTED;
- else td->flag = 0;
- }
- td->ext = NULL;
- td->val = NULL;
+ hdata = initTransDataCurveHandles(td, bezt);
- hdata = initTransDataCurveHandles(td, bezt);
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
+ if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
+ copy_m3_m3(td->axismtx, axismtx);
+ }
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
- if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
- copy_m3_m3(td->axismtx, axismtx);
+ td++;
+ count++;
+ tail++;
}
- td++;
- count++;
- tail++;
- }
+ /* This is the Curve Point, the other two are handles */
+ if (is_prop_edit || bezt_tx & SEL_F2) {
+ copy_v3_v3(td->iloc, bezt->vec[1]);
+ td->loc = bezt->vec[1];
+ copy_v3_v3(td->center, td->loc);
+ if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
+ td->ext = NULL;
- /* This is the Curve Point, the other two are handles */
- if (is_prop_edit || bezt_tx & SEL_F2) {
- copy_v3_v3(td->iloc, bezt->vec[1]);
- td->loc = bezt->vec[1];
- copy_v3_v3(td->center, td->loc);
- if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
- else td->flag = 0;
- td->ext = NULL;
+ if (t->mode == TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */
+ td->val = &(bezt->radius);
+ td->ival = bezt->radius;
+ }
+ else if (t->mode == TFM_TILT) {
+ td->val = &(bezt->alfa);
+ td->ival = bezt->alfa;
+ }
+ else {
+ td->val = NULL;
+ }
- if (t->mode == TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */
- td->val = &(bezt->radius);
- td->ival = bezt->radius;
- }
- else if (t->mode == TFM_TILT) {
- td->val = &(bezt->alfa);
- td->ival = bezt->alfa;
- }
- else {
- td->val = NULL;
- }
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
+ if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
+ copy_m3_m3(td->axismtx, axismtx);
+ }
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
- if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
- copy_m3_m3(td->axismtx, axismtx);
+ if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0)
+ /* If the middle is selected but the sides arnt, this is needed */
+ if (hdata == NULL) { /* if the handle was not saved by the previous handle */
+ hdata = initTransDataCurveHandles(td, bezt);
+ }
+
+ td++;
+ count++;
+ tail++;
}
+ if (is_prop_edit || bezt_tx & SEL_F3) {
+ copy_v3_v3(td->iloc, bezt->vec[2]);
+ td->loc = bezt->vec[2];
+ copy_v3_v3(td->center, bezt->vec[(hide_handles ||
+ (t->around == V3D_AROUND_LOCAL_ORIGINS) ||
+ (bezt->f2 & SELECT)) ? 1 : 2]);
+ if (hide_handles) {
+ if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
+ }
+ else {
+ if (bezt->f3 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
+ }
+ td->ext = NULL;
+ td->val = NULL;
- if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0)
- /* If the middle is selected but the sides arnt, this is needed */
if (hdata == NULL) { /* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandles(td, bezt);
}
- td++;
- count++;
- tail++;
- }
- if (is_prop_edit || bezt_tx & SEL_F3) {
- copy_v3_v3(td->iloc, bezt->vec[2]);
- td->loc = bezt->vec[2];
- copy_v3_v3(td->center, bezt->vec[(hide_handles ||
- (t->around == V3D_AROUND_LOCAL_ORIGINS) ||
- (bezt->f2 & SELECT)) ? 1 : 2]);
- if (hide_handles) {
- if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
- else td->flag = 0;
- }
- else {
- if (bezt->f3 & SELECT) td->flag = TD_SELECTED;
- else td->flag = 0;
- }
- td->ext = NULL;
- td->val = NULL;
-
- if (hdata == NULL) { /* if the handle was not saved by the previous handle */
- hdata = initTransDataCurveHandles(td, bezt);
- }
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
+ if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
+ copy_m3_m3(td->axismtx, axismtx);
+ }
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
- if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
- copy_m3_m3(td->axismtx, axismtx);
+ td++;
+ count++;
+ tail++;
}
- td++;
- count++;
- tail++;
+ (void)hdata; /* quiet warning */
+ }
+ else if (is_prop_edit && head != tail) {
+ calc_distanceCurveVerts(head, tail - 1);
+ head = tail;
}
-
- (void)hdata; /* quiet warning */
}
- else if (is_prop_edit && head != tail) {
+ if (is_prop_edit && head != tail)
calc_distanceCurveVerts(head, tail - 1);
- head = tail;
- }
- }
- if (is_prop_edit && head != tail)
- calc_distanceCurveVerts(head, tail - 1);
- /* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles
- * but for now just don't change handle types */
- if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT, TFM_DUMMY) == 0) {
- /* sets the handles based on their selection, do this after the data is copied to the TransData */
- BKE_nurb_handles_test(nu, !hide_handles);
+ /* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles
+ * but for now just don't change handle types */
+ if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT, TFM_DUMMY) == 0) {
+ /* sets the handles based on their selection, do this after the data is copied to the TransData */
+ BKE_nurb_handles_test(nu, !hide_handles);
+ }
}
- }
- else {
- TransData *head, *tail;
- head = tail = td;
- for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
- if (bp->hide == 0) {
- if (is_prop_edit || (bp->f1 & SELECT)) {
- float axismtx[3][3];
-
- if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
- if (nu->pntsv == 1) {
- float normal[3], plane[3];
-
- BKE_nurb_bpoint_calc_normal(nu, bp, normal);
- BKE_nurb_bpoint_calc_plane(nu, bp, plane);
-
- if (createSpaceNormalTangent(axismtx, normal, plane)) {
- /* pass */
- }
- else {
- normalize_v3(normal);
- axis_dominant_v3_to_m3(axismtx, normal);
- invert_m3(axismtx);
+ else {
+ TransData *head, *tail;
+ head = tail = td;
+ for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
+ if (bp->hide == 0) {
+ if (is_prop_edit || (bp->f1 & SELECT)) {
+ float axismtx[3][3];
+
+ if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
+ if (nu->pntsv == 1) {
+ float normal[3], plane[3];
+
+ BKE_nurb_bpoint_calc_normal(nu, bp, normal);
+ BKE_nurb_bpoint_calc_plane(nu, bp, plane);
+
+ if (createSpaceNormalTangent(axismtx, normal, plane)) {
+ /* pass */
+ }
+ else {
+ normalize_v3(normal);
+ axis_dominant_v3_to_m3(axismtx, normal);
+ invert_m3(axismtx);
+ }
}
}
- }
- copy_v3_v3(td->iloc, bp->vec);
- td->loc = bp->vec;
- copy_v3_v3(td->center, td->loc);
- if (bp->f1 & SELECT) td->flag = TD_SELECTED;
- else td->flag = 0;
- td->ext = NULL;
+ copy_v3_v3(td->iloc, bp->vec);
+ td->loc = bp->vec;
+ copy_v3_v3(td->center, td->loc);
+ if (bp->f1 & SELECT) td->flag = TD_SELECTED;
+ else td->flag = 0;
+ td->ext = NULL;
- if (t->mode == TFM_CURVE_SHRINKFATTEN || t->mode == TFM_RESIZE) {
- td->val = &(bp->radius);
- td->ival = bp->radius;
- }
- else {
- td->val = &(bp->alfa);
- td->ival = bp->alfa;
- }
+ if (t->mode == TFM_CURVE_SHRINKFATTEN || t->mode == TFM_RESIZE) {
+ td->val = &(bp->radius);
+ td->ival = bp->radius;
+ }
+ else {
+ td->val = &(bp->alfa);
+ td->ival = bp->alfa;
+ }
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
- if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
- if (nu->pntsv == 1) {
- copy_m3_m3(td->axismtx, axismtx);
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
+ if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
+ if (nu->pntsv == 1) {
+ copy_m3_m3(td->axismtx, axismtx);
+ }
}
- }
- td++;
- count++;
- tail++;
+ td++;
+ count++;
+ tail++;
+ }
+ }
+ else if (is_prop_edit && head != tail) {
+ calc_distanceCurveVerts(head, tail - 1);
+ head = tail;
}
}
- else if (is_prop_edit && head != tail) {
+ if (is_prop_edit && head != tail)
calc_distanceCurveVerts(head, tail - 1);
- head = tail;
- }
}
- if (is_prop_edit && head != tail)
- calc_distanceCurveVerts(head, tail - 1);
}
}
-
#undef SEL_F1
#undef SEL_F2
#undef SEL_F3
@@ -1831,60 +1894,63 @@ static void createTransCurveVerts(TransInfo *t)
static void createTransLatticeVerts(TransInfo *t)
{
- Lattice *latt = ((Lattice *)t->obedit->data)->editlatt->latt;
- TransData *td = NULL;
- BPoint *bp;
- float mtx[3][3], smtx[3][3];
- int a;
- int count = 0, countsel = 0;
- const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- bp = latt->def;
- a = latt->pntsu * latt->pntsv * latt->pntsw;
- while (a--) {
- if (bp->hide == 0) {
- if (bp->f1 & SELECT) countsel++;
- if (is_prop_edit) count++;
+ Lattice *latt = ((Lattice *)tc->obedit->data)->editlatt->latt;
+ TransData *td = NULL;
+ BPoint *bp;
+ float mtx[3][3], smtx[3][3];
+ int a;
+ int count = 0, countsel = 0;
+ const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+
+ bp = latt->def;
+ a = latt->pntsu * latt->pntsv * latt->pntsw;
+ while (a--) {
+ if (bp->hide == 0) {
+ if (bp->f1 & SELECT) countsel++;
+ if (is_prop_edit) count++;
+ }
+ bp++;
}
- bp++;
- }
- /* note: in prop mode we need at least 1 selected */
- if (countsel == 0) return;
+ /* note: in prop mode we need at least 1 selected */
+ if (countsel == 0) return;
- if (is_prop_edit) t->total = count;
- else t->total = countsel;
- t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Lattice EditMode)");
+ if (is_prop_edit) tc->data_len = count;
+ else tc->data_len = countsel;
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Lattice EditMode)");
- copy_m3_m4(mtx, t->obedit->obmat);
- pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
+ copy_m3_m4(mtx, tc->obedit->obmat);
+ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
- td = t->data;
- bp = latt->def;
- a = latt->pntsu * latt->pntsv * latt->pntsw;
- while (a--) {
- if (is_prop_edit || (bp->f1 & SELECT)) {
- if (bp->hide == 0) {
- copy_v3_v3(td->iloc, bp->vec);
- td->loc = bp->vec;
- copy_v3_v3(td->center, td->loc);
- if (bp->f1 & SELECT) {
- td->flag = TD_SELECTED;
- }
- else {
- td->flag = 0;
- }
- copy_m3_m3(td->smtx, smtx);
- copy_m3_m3(td->mtx, mtx);
+ td = tc->data;
+ bp = latt->def;
+ a = latt->pntsu * latt->pntsv * latt->pntsw;
+ while (a--) {
+ if (is_prop_edit || (bp->f1 & SELECT)) {
+ if (bp->hide == 0) {
+ copy_v3_v3(td->iloc, bp->vec);
+ td->loc = bp->vec;
+ copy_v3_v3(td->center, td->loc);
+ if (bp->f1 & SELECT) {
+ td->flag = TD_SELECTED;
+ }
+ else {
+ td->flag = 0;
+ }
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
- td->ext = NULL;
- td->val = NULL;
+ td->ext = NULL;
+ td->val = NULL;
- td++;
- count++;
+ td++;
+ count++;
+ }
}
+ bp++;
}
- bp++;
}
}
@@ -2061,58 +2127,64 @@ static void groom_transdata_init_verts(
static void createTransGroomVerts(TransInfo *t)
{
- const ToolSettings *tsettings = t->scene->toolsettings;
- const bool is_prop_edit = t->flag & T_PROP_EDIT;
- EditGroom *edit = ((Groom *)t->obedit->data)->editgroom;
-
- switch (tsettings->groom_edit_settings.mode)
+ FOREACH_TRANS_DATA_CONTAINER(t, tc)
{
- case GM_EDIT_MODE_REGIONS:
- t->total = groom_trans_count_regions(edit, is_prop_edit);
- if (t->total > 0)
- {
- // TODO
- groom_transdata_init_regions(edit, is_prop_edit, t->obedit->obmat, t->data);
- }
- break;
- case GM_EDIT_MODE_CURVES:
- t->total = groom_trans_count_curves(edit, is_prop_edit);
- if (t->total > 0)
- {
- t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(Groom EditMode)");
-
- groom_transdata_init_curves(edit, is_prop_edit, t->obedit->obmat, t->data);
- }
- break;
- case GM_EDIT_MODE_SECTIONS:
- t->total = groom_trans_count_verts(edit, is_prop_edit);
- if (t->total > 0)
- {
- t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(Groom EditMode)");
- t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransData2D(Groom EditMode)");
-
- groom_transdata_init_verts(edit, is_prop_edit, t->obedit->obmat, t->data, t->data2d);
- }
- break;
+ const ToolSettings *tsettings = t->scene->toolsettings;
+ const bool is_prop_edit = t->flag & T_PROP_EDIT;
+ EditGroom *edit = ((Groom *)tc->obedit->data)->editgroom;
+
+ switch (tsettings->groom_edit_settings.mode)
+ {
+ case GM_EDIT_MODE_REGIONS:
+ tc->data_len = groom_trans_count_regions(edit, is_prop_edit);
+ if (tc->data_len > 0)
+ {
+ // TODO
+ groom_transdata_init_regions(edit, is_prop_edit, tc->obedit->obmat, tc->data);
+ }
+ break;
+ case GM_EDIT_MODE_CURVES:
+ tc->data_len = groom_trans_count_curves(edit, is_prop_edit);
+ if (tc->data_len > 0)
+ {
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(Groom EditMode)");
+
+ groom_transdata_init_curves(edit, is_prop_edit, tc->obedit->obmat, tc->data);
+ }
+ break;
+ case GM_EDIT_MODE_SECTIONS:
+ tc->data_len = groom_trans_count_verts(edit, is_prop_edit);
+ if (tc->data_len > 0)
+ {
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(Groom EditMode)");
+ tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransData2D(Groom EditMode)");
+
+ groom_transdata_init_verts(edit, is_prop_edit, tc->obedit->obmat, tc->data, tc->data_2d);
+ }
+ break;
+ }
}
}
void flushTransGroom(TransInfo *t)
{
- switch (t->scene->toolsettings->groom_edit_settings.mode)
+ FOREACH_TRANS_DATA_CONTAINER(t, tc)
{
- case GM_EDIT_MODE_REGIONS:
- break;
- case GM_EDIT_MODE_CURVES:
- break;
- case GM_EDIT_MODE_SECTIONS:
+ switch (t->scene->toolsettings->groom_edit_settings.mode)
{
- TransData2D *td2d = t->data2d;
- for (int i = 0; i < t->total; ++i, ++td2d)
+ case GM_EDIT_MODE_REGIONS:
+ break;
+ case GM_EDIT_MODE_CURVES:
+ break;
+ case GM_EDIT_MODE_SECTIONS:
{
- copy_v2_v2(td2d->loc2d, td2d->loc);
+ TransData2D *td2d = tc->data_2d;
+ for (int i = 0; i < tc->data_len; ++i, ++td2d)
+ {
+ copy_v2_v2(td2d->loc2d, td2d->loc);
+ }
+ break;
}
- break;
}
}
}
@@ -2120,167 +2192,173 @@ void flushTransGroom(TransInfo *t)
/* ******************* particle edit **************** */
static void createTransParticleVerts(bContext *C, TransInfo *t)
{
- TransData *td = NULL;
- TransDataExtension *tx;
- Object *ob = CTX_data_active_object(C);
- ParticleEditSettings *pset = PE_settings(t->scene);
- PTCacheEdit *edit = PE_get_current(t->scene, ob);
- ParticleSystem *psys = NULL;
- ParticleSystemModifierData *psmd = NULL;
- PTCacheEditPoint *point;
- PTCacheEditKey *key;
- float mat[4][4];
- int i, k, transformparticle;
- int count = 0, hasselected = 0;
- const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
-
- if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) return;
-
- psys = edit->psys;
-
- if (psys)
- psmd = psys_get_modifier(ob, psys);
-
- for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
- point->flag &= ~PEP_TRANSFORM;
- transformparticle = 0;
-
- if ((point->flag & PEP_HIDE) == 0) {
- for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
- if ((key->flag & PEK_HIDE) == 0) {
- if (key->flag & PEK_SELECT) {
- hasselected = 1;
- transformparticle = 1;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+
+ TransData *td = NULL;
+ TransDataExtension *tx;
+ Object *ob = CTX_data_active_object(C);
+ ParticleEditSettings *pset = PE_settings(t->scene);
+ PTCacheEdit *edit = PE_get_current(t->scene, ob);
+ ParticleSystem *psys = NULL;
+ ParticleSystemModifierData *psmd = NULL;
+ PTCacheEditPoint *point;
+ PTCacheEditKey *key;
+ float mat[4][4];
+ int i, k, transformparticle;
+ int count = 0, hasselected = 0;
+ const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+
+ if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) return;
+
+ psys = edit->psys;
+
+ if (psys)
+ psmd = psys_get_modifier(ob, psys);
+
+ for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
+ point->flag &= ~PEP_TRANSFORM;
+ transformparticle = 0;
+
+ if ((point->flag & PEP_HIDE) == 0) {
+ for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
+ if ((key->flag & PEK_HIDE) == 0) {
+ if (key->flag & PEK_SELECT) {
+ hasselected = 1;
+ transformparticle = 1;
+ }
+ else if (is_prop_edit)
+ transformparticle = 1;
}
- else if (is_prop_edit)
- transformparticle = 1;
}
}
- }
- if (transformparticle) {
- count += point->totkey;
- point->flag |= PEP_TRANSFORM;
+ if (transformparticle) {
+ count += point->totkey;
+ point->flag |= PEP_TRANSFORM;
+ }
}
- }
- /* note: in prop mode we need at least 1 selected */
- if (hasselected == 0) return;
+ /* note: in prop mode we need at least 1 selected */
+ if (hasselected == 0) return;
- t->total = count;
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Particle Mode)");
+ tc->data_len = count;
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Particle Mode)");
- if (t->mode == TFM_BAKE_TIME)
- tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "Particle_TransExtension");
- else
- tx = t->ext = NULL;
+ if (t->mode == TFM_BAKE_TIME)
+ tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension), "Particle_TransExtension");
+ else
+ tx = tc->data_ext = NULL;
- unit_m4(mat);
+ unit_m4(mat);
- invert_m4_m4(ob->imat, ob->obmat);
+ invert_m4_m4(ob->imat, ob->obmat);
- for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
- TransData *head, *tail;
- head = tail = td;
+ for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
+ TransData *head, *tail;
+ head = tail = td;
- if (!(point->flag & PEP_TRANSFORM)) continue;
+ if (!(point->flag & PEP_TRANSFORM)) continue;
- if (psys && !(psys->flag & PSYS_GLOBAL_HAIR))
- psys_mat_hair_to_global(ob, psmd->dm_final, psys->part->from, psys->particles + i, mat);
+ if (psys && !(psys->flag & PSYS_GLOBAL_HAIR))
+ psys_mat_hair_to_global(ob, psmd->dm_final, psys->part->from, psys->particles + i, mat);
- for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
- if (key->flag & PEK_USE_WCO) {
- copy_v3_v3(key->world_co, key->co);
- mul_m4_v3(mat, key->world_co);
- td->loc = key->world_co;
- }
- else
- td->loc = key->co;
+ for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
+ if (key->flag & PEK_USE_WCO) {
+ copy_v3_v3(key->world_co, key->co);
+ mul_m4_v3(mat, key->world_co);
+ td->loc = key->world_co;
+ }
+ else
+ td->loc = key->co;
- copy_v3_v3(td->iloc, td->loc);
- copy_v3_v3(td->center, td->loc);
+ copy_v3_v3(td->iloc, td->loc);
+ copy_v3_v3(td->center, td->loc);
- if (key->flag & PEK_SELECT)
- td->flag |= TD_SELECTED;
- else if (!is_prop_edit)
- td->flag |= TD_SKIP;
+ if (key->flag & PEK_SELECT)
+ td->flag |= TD_SELECTED;
+ else if (!is_prop_edit)
+ td->flag |= TD_SKIP;
- unit_m3(td->mtx);
- unit_m3(td->smtx);
+ unit_m3(td->mtx);
+ unit_m3(td->smtx);
- /* don't allow moving roots */
- if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR)))
- td->protectflag |= OB_LOCK_LOC;
+ /* don't allow moving roots */
+ if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR)))
+ td->protectflag |= OB_LOCK_LOC;
- td->ob = ob;
- td->ext = tx;
- if (t->mode == TFM_BAKE_TIME) {
- td->val = key->time;
- td->ival = *(key->time);
- /* abuse size and quat for min/max values */
- td->flag |= TD_NO_EXT;
- if (k == 0) tx->size = NULL;
- else tx->size = (key - 1)->time;
+ td->ob = ob;
+ td->ext = tx;
+ if (t->mode == TFM_BAKE_TIME) {
+ td->val = key->time;
+ td->ival = *(key->time);
+ /* abuse size and quat for min/max values */
+ td->flag |= TD_NO_EXT;
+ if (k == 0) tx->size = NULL;
+ else tx->size = (key - 1)->time;
- if (k == point->totkey - 1) tx->quat = NULL;
- else tx->quat = (key + 1)->time;
- }
+ if (k == point->totkey - 1) tx->quat = NULL;
+ else tx->quat = (key + 1)->time;
+ }
- td++;
- if (tx)
- tx++;
- tail++;
+ td++;
+ if (tx)
+ tx++;
+ tail++;
+ }
+ if (is_prop_edit && head != tail)
+ calc_distanceCurveVerts(head, tail - 1);
}
- if (is_prop_edit && head != tail)
- calc_distanceCurveVerts(head, tail - 1);
}
}
void flushTransParticles(TransInfo *t)
{
- Scene *scene = t->scene;
- ViewLayer *view_layer = t->view_layer;
- Object *ob = OBACT(view_layer);
- PTCacheEdit *edit = PE_get_current(scene, ob);
- ParticleSystem *psys = edit->psys;
- ParticleSystemModifierData *psmd = NULL;
- PTCacheEditPoint *point;
- PTCacheEditKey *key;
- TransData *td;
- float mat[4][4], imat[4][4], co[3];
- int i, k;
- const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
-
- if (psys)
- psmd = psys_get_modifier(ob, psys);
-
- /* we do transform in world space, so flush world space position
- * back to particle local space (only for hair particles) */
- td = t->data;
- for (i = 0, point = edit->points; i < edit->totpoint; i++, point++, td++) {
- if (!(point->flag & PEP_TRANSFORM)) continue;
-
- if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
- psys_mat_hair_to_global(ob, psmd->dm_final, psys->part->from, psys->particles + i, mat);
- invert_m4_m4(imat, mat);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
- copy_v3_v3(co, key->world_co);
- mul_m4_v3(imat, co);
-
-
- /* optimization for proportional edit */
- if (!is_prop_edit || !compare_v3v3(key->co, co, 0.0001f)) {
- copy_v3_v3(key->co, co);
- point->flag |= PEP_EDIT_RECALC;
+ Scene *scene = t->scene;
+ ViewLayer *view_layer = t->view_layer;
+ Object *ob = OBACT(view_layer);
+ PTCacheEdit *edit = PE_get_current(scene, ob);
+ ParticleSystem *psys = edit->psys;
+ ParticleSystemModifierData *psmd = NULL;
+ PTCacheEditPoint *point;
+ PTCacheEditKey *key;
+ TransData *td;
+ float mat[4][4], imat[4][4], co[3];
+ int i, k;
+ const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+
+ if (psys)
+ psmd = psys_get_modifier(ob, psys);
+
+ /* we do transform in world space, so flush world space position
+ * back to particle local space (only for hair particles) */
+ td = tc->data;
+ for (i = 0, point = edit->points; i < edit->totpoint; i++, point++, td++) {
+ if (!(point->flag & PEP_TRANSFORM)) continue;
+
+ if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
+ psys_mat_hair_to_global(ob, psmd->dm_final, psys->part->from, psys->particles + i, mat);
+ invert_m4_m4(imat, mat);
+
+ for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
+ copy_v3_v3(co, key->world_co);
+ mul_m4_v3(imat, co);
+
+
+ /* optimization for proportional edit */
+ if (!is_prop_edit || !compare_v3v3(key->co, co, 0.0001f)) {
+ copy_v3_v3(key->co, co);
+ point->flag |= PEP_EDIT_RECALC;
+ }
}
}
+ else
+ point->flag |= PEP_EDIT_RECALC;
}
- else
- point->flag |= PEP_EDIT_RECALC;
- }
- PE_update_object(&t->eval_ctx, scene, OBACT(view_layer), 1);
+ PE_update_object(t->depsgraph, scene, OBACT(view_layer), 1);
+ }
}
/* ********************* mesh ****************** */
@@ -2690,243 +2768,248 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx
static void createTransEditVerts(TransInfo *t)
{
- TransData *tob = NULL;
- TransDataExtension *tx = NULL;
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
- Mesh *me = t->obedit->data;
- BMesh *bm = em->bm;
- BMVert *eve;
- BMIter iter;
- float (*mappedcos)[3] = NULL, (*quats)[4] = NULL;
- float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
- float *dists = NULL;
- int a;
- const int prop_mode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0;
- int mirror = 0;
- int cd_vert_bweight_offset = -1;
- bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- struct TransIslandData *island_info = NULL;
- int island_info_tot;
- int *island_vert_map = NULL;
+ TransData *tob = NULL;
+ TransDataExtension *tx = NULL;
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
+ Mesh *me = tc->obedit->data;
+ BMesh *bm = em->bm;
+ BMVert *eve;
+ BMIter iter;
+ float (*mappedcos)[3] = NULL, (*quats)[4] = NULL;
+ float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
+ float *dists = NULL;
+ int a;
+ const int prop_mode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0;
+ int mirror = 0;
+ int cd_vert_bweight_offset = -1;
+ bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
- /* Even for translation this is needed because of island-orientation, see: T51651. */
- const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
- /* Original index of our connected vertex when connected distances are calculated.
- * Optional, allocate if needed. */
- int *dists_index = NULL;
+ struct TransIslandData *island_info = NULL;
+ int island_info_tot;
+ int *island_vert_map = NULL;
- if (t->flag & T_MIRROR) {
- EDBM_verts_mirror_cache_begin(em, 0, false, (t->flag & T_PROP_EDIT) == 0, use_topology);
- mirror = 1;
- }
+ /* Even for translation this is needed because of island-orientation, see: T51651. */
+ const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
+ /* Original index of our connected vertex when connected distances are calculated.
+ * Optional, allocate if needed. */
+ int *dists_index = NULL;
- /**
- * Quick check if we can transform.
- *
- * \note ignore modes here, even in edge/face modes, transform data is created by selected vertices.
- * \note in prop mode we need at least 1 selected.
- */
- if (bm->totvertsel == 0) {
- goto cleanup;
- }
+ if (t->flag & T_MIRROR) {
+ /* TODO(campbell): xform: We need support for many mirror objects at once! */
+ if (tc->is_active) {
+ EDBM_verts_mirror_cache_begin(em, 0, false, (t->flag & T_PROP_EDIT) == 0, use_topology);
+ mirror = 1;
+ }
+ }
- if (t->mode == TFM_BWEIGHT) {
- BM_mesh_cd_flag_ensure(bm, BKE_mesh_from_object(t->obedit), ME_CDFLAG_VERT_BWEIGHT);
- cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
- }
+ /**
+ * Quick check if we can transform.
+ *
+ * \note ignore modes here, even in edge/face modes, transform data is created by selected vertices.
+ * \note in prop mode we need at least 1 selected.
+ */
+ if (bm->totvertsel == 0) {
+ goto cleanup;
+ }
- if (prop_mode) {
- unsigned int count = 0;
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- count++;
- }
+ if (t->mode == TFM_BWEIGHT) {
+ BM_mesh_cd_flag_ensure(bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_VERT_BWEIGHT);
+ cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
}
- t->total = count;
+ if (prop_mode) {
+ unsigned int count = 0;
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ count++;
+ }
+ }
- /* allocating scratch arrays */
- if (prop_mode & T_PROP_CONNECTED) {
- dists = MEM_mallocN(em->bm->totvert * sizeof(float), __func__);
- if (is_island_center) {
- dists_index = MEM_mallocN(em->bm->totvert * sizeof(int), __func__);
+ tc->data_len = count;
+
+ /* allocating scratch arrays */
+ if (prop_mode & T_PROP_CONNECTED) {
+ dists = MEM_mallocN(em->bm->totvert * sizeof(float), __func__);
+ if (is_island_center) {
+ dists_index = MEM_mallocN(em->bm->totvert * sizeof(int), __func__);
+ }
}
}
- }
- else {
- t->total = bm->totvertsel;
- }
-
- tob = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mesh EditMode)");
- if (ELEM(t->mode, TFM_SKIN_RESIZE, TFM_SHRINKFATTEN)) {
- /* warning, this is overkill, we only need 2 extra floats,
- * but this stores loads of extra stuff, for TFM_SHRINKFATTEN its even more overkill
- * since we may not use the 'alt' transform mode to maintain shell thickness,
- * but with generic transform code its hard to lazy init vars */
- tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension),
- "TransObData ext");
- }
+ else {
+ tc->data_len = bm->totvertsel;
+ }
- copy_m3_m4(mtx, t->obedit->obmat);
- /* we use a pseudoinverse so that when one of the axes is scaled to 0,
- * matrix inversion still works and we can still moving along the other */
- pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
+ tob = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Mesh EditMode)");
+ if (ELEM(t->mode, TFM_SKIN_RESIZE, TFM_SHRINKFATTEN)) {
+ /* warning, this is overkill, we only need 2 extra floats,
+ * but this stores loads of extra stuff, for TFM_SHRINKFATTEN its even more overkill
+ * since we may not use the 'alt' transform mode to maintain shell thickness,
+ * but with generic transform code its hard to lazy init vars */
+ tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension), "TransObData ext");
+ }
- if (prop_mode & T_PROP_CONNECTED) {
- editmesh_set_connectivity_distance(em->bm, mtx, dists, dists_index);
- }
+ copy_m3_m4(mtx, tc->obedit->obmat);
+ /* we use a pseudoinverse so that when one of the axes is scaled to 0,
+ * matrix inversion still works and we can still moving along the other */
+ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
- if (is_island_center) {
- /* In this specific case, near-by vertices will need to know the island of the nearest connected vertex. */
- const bool calc_single_islands = (
- (prop_mode & T_PROP_CONNECTED) &&
- (t->around == V3D_AROUND_LOCAL_ORIGINS) &&
- (em->selectmode & SCE_SELECT_VERTEX));
+ if (prop_mode & T_PROP_CONNECTED) {
+ editmesh_set_connectivity_distance(em->bm, mtx, dists, dists_index);
+ }
- island_info = editmesh_islands_info_calc(em, &island_info_tot, &island_vert_map, calc_single_islands);
- }
+ if (is_island_center) {
+ /* In this specific case, near-by vertices will need to know the island of the nearest connected vertex. */
+ const bool calc_single_islands = (
+ (prop_mode & T_PROP_CONNECTED) &&
+ (t->around == V3D_AROUND_LOCAL_ORIGINS) &&
+ (em->selectmode & SCE_SELECT_VERTEX));
- /* detect CrazySpace [tm] */
- if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1) != -1) {
- int totleft = -1;
- if (modifiers_isCorrectableDeformed(t->scene, t->obedit)) {
- /* check if we can use deform matrices for modifier from the
- * start up to stack, they are more accurate than quats */
- totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(&t->eval_ctx, t->scene, t->obedit, em, &defmats, &defcos);
+ island_info = editmesh_islands_info_calc(em, &island_info_tot, &island_vert_map, calc_single_islands);
}
- /* if we still have more modifiers, also do crazyspace
- * correction with quats, relative to the coordinates after
- * the modifiers that support deform matrices (defcos) */
+ /* detect CrazySpace [tm] */
+ if (modifiers_getCageIndex(t->scene, tc->obedit, NULL, 1) != -1) {
+ int totleft = -1;
+ if (modifiers_isCorrectableDeformed(t->scene, tc->obedit)) {
+ /* check if we can use deform matrices for modifier from the
+ * start up to stack, they are more accurate than quats */
+ totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(t->depsgraph, t->scene, tc->obedit, em, &defmats, &defcos);
+ }
+
+ /* if we still have more modifiers, also do crazyspace
+ * correction with quats, relative to the coordinates after
+ * the modifiers that support deform matrices (defcos) */
#if 0 /* TODO, fix crazyspace+extrude so it can be enabled for general use - campbell */
- if ((totleft > 0) || (totleft == -1))
+ if ((totleft > 0) || (totleft == -1))
#else
- if (totleft > 0)
+ if (totleft > 0)
#endif
- {
- mappedcos = BKE_crazyspace_get_mapped_editverts(&t->eval_ctx, t->scene, t->obedit);
- quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats");
- BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !prop_mode);
- if (mappedcos)
- MEM_freeN(mappedcos);
- }
+ {
+ mappedcos = BKE_crazyspace_get_mapped_editverts(t->depsgraph, t->scene, tc->obedit);
+ quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats");
+ BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !prop_mode);
+ if (mappedcos)
+ MEM_freeN(mappedcos);
+ }
- if (defcos) {
- MEM_freeN(defcos);
+ if (defcos) {
+ MEM_freeN(defcos);
+ }
}
- }
- /* find out which half we do */
- if (mirror) {
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && eve->co[0] != 0.0f) {
- if (eve->co[0] < 0.0f) {
- t->mirror = -1;
- mirror = -1;
+ /* find out which half we do */
+ if (mirror) {
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && eve->co[0] != 0.0f) {
+ if (eve->co[0] < 0.0f) {
+ t->mirror = -1;
+ mirror = -1;
+ }
+ break;
}
- break;
}
}
- }
-
- BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
- if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- struct TransIslandData *v_island = NULL;
- float *bweight = (cd_vert_bweight_offset != -1) ? BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) : NULL;
- if (island_info) {
- const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a;
- v_island = (island_vert_map[connected_index] != -1) ?
- &island_info[island_vert_map[connected_index]] : NULL;
- }
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
+ if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ struct TransIslandData *v_island = NULL;
+ float *bweight = (cd_vert_bweight_offset != -1) ? BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) : NULL;
+
+ if (island_info) {
+ const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a;
+ v_island = (island_vert_map[connected_index] != -1) ?
+ &island_info[island_vert_map[connected_index]] : NULL;
+ }
- VertsToTransData(t, tob, tx, em, eve, bweight, v_island);
- if (tx)
- tx++;
+ VertsToTransData(t, tob, tx, em, eve, bweight, v_island);
+ if (tx)
+ tx++;
- /* selected */
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT))
- tob->flag |= TD_SELECTED;
+ /* selected */
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT))
+ tob->flag |= TD_SELECTED;
- if (prop_mode) {
- if (prop_mode & T_PROP_CONNECTED) {
- tob->dist = dists[a];
- }
- else {
- tob->flag |= TD_NOTCONNECTED;
- tob->dist = FLT_MAX;
+ if (prop_mode) {
+ if (prop_mode & T_PROP_CONNECTED) {
+ tob->dist = dists[a];
+ }
+ else {
+ tob->flag |= TD_NOTCONNECTED;
+ tob->dist = FLT_MAX;
+ }
}
- }
- /* CrazySpace */
- if (defmats || (quats && BM_elem_flag_test(eve, BM_ELEM_TAG))) {
- float mat[3][3], qmat[3][3], imat[3][3];
+ /* CrazySpace */
+ if (defmats || (quats && BM_elem_flag_test(eve, BM_ELEM_TAG))) {
+ float mat[3][3], qmat[3][3], imat[3][3];
- /* use both or either quat and defmat correction */
- if (quats && BM_elem_flag_test(eve, BM_ELEM_TAG)) {
- quat_to_mat3(qmat, quats[BM_elem_index_get(eve)]);
+ /* use both or either quat and defmat correction */
+ if (quats && BM_elem_flag_test(eve, BM_ELEM_TAG)) {
+ quat_to_mat3(qmat, quats[BM_elem_index_get(eve)]);
- if (defmats)
- mul_m3_series(mat, defmats[a], qmat, mtx);
+ if (defmats)
+ mul_m3_series(mat, defmats[a], qmat, mtx);
+ else
+ mul_m3_m3m3(mat, mtx, qmat);
+ }
else
- mul_m3_m3m3(mat, mtx, qmat);
- }
- else
- mul_m3_m3m3(mat, mtx, defmats[a]);
+ mul_m3_m3m3(mat, mtx, defmats[a]);
- invert_m3_m3(imat, mat);
+ invert_m3_m3(imat, mat);
- copy_m3_m3(tob->smtx, imat);
- copy_m3_m3(tob->mtx, mat);
- }
- else {
- copy_m3_m3(tob->smtx, smtx);
- copy_m3_m3(tob->mtx, mtx);
- }
+ copy_m3_m3(tob->smtx, imat);
+ copy_m3_m3(tob->mtx, mat);
+ }
+ else {
+ copy_m3_m3(tob->smtx, smtx);
+ copy_m3_m3(tob->mtx, mtx);
+ }
- /* Mirror? */
- if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) {
- BMVert *vmir = EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a);
- if (vmir && vmir != eve) {
- tob->extra = vmir;
+ /* Mirror? */
+ if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) {
+ BMVert *vmir = EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a);
+ if (vmir && vmir != eve) {
+ tob->extra = vmir;
+ }
}
+ tob++;
}
- tob++;
}
}
- }
-
- if (island_info) {
- MEM_freeN(island_info);
- MEM_freeN(island_vert_map);
- }
- if (mirror != 0) {
- tob = t->data;
- for (a = 0; a < t->total; a++, tob++) {
- if (ABS(tob->loc[0]) <= 0.00001f) {
- tob->flag |= TD_MIRROR_EDGE;
+ if (island_info) {
+ MEM_freeN(island_info);
+ MEM_freeN(island_vert_map);
+ }
+
+ if (mirror != 0) {
+ tob = tc->data;
+ for (a = 0; a < tc->data_len; a++, tob++) {
+ if (ABS(tob->loc[0]) <= 0.00001f) {
+ tob->flag |= TD_MIRROR_EDGE;
+ }
}
}
- }
cleanup:
- /* crazy space free */
- if (quats)
- MEM_freeN(quats);
- if (defmats)
- MEM_freeN(defmats);
- if (dists)
- MEM_freeN(dists);
- if (dists_index)
- MEM_freeN(dists_index);
+ /* crazy space free */
+ if (quats)
+ MEM_freeN(quats);
+ if (defmats)
+ MEM_freeN(defmats);
+ if (dists)
+ MEM_freeN(dists);
+ if (dists_index)
+ MEM_freeN(dists_index);
- if (t->flag & T_MIRROR) {
- EDBM_verts_mirror_cache_end(em);
+ if (t->flag & T_MIRROR) {
+ EDBM_verts_mirror_cache_end(em);
+ }
}
}
@@ -2934,40 +3017,43 @@ cleanup:
void flushTransNodes(TransInfo *t)
{
const float dpi_fac = UI_DPI_FAC;
- 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 locx, locy;
- /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ int a;
+ TransData *td;
+ TransData2D *td2d;
+
+ applyGridAbsolute(t);
+
+ /* flush to 2d vector from internally used 3d vector */
+ for (a = 0, td = tc->data, td2d = tc->data_2d; a < tc->data_len; a++, td++, td2d++) {
+ bNode *node = td->extra;
+ float locx, locy;
+
+ /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */
#ifdef USE_NODE_CENTER
- locx = (td2d->loc[0] - (BLI_rctf_size_x(&node->totr)) * +0.5f) / dpi_fac;
- locy = (td2d->loc[1] - (BLI_rctf_size_y(&node->totr)) * -0.5f) / dpi_fac;
+ locx = (td2d->loc[0] - (BLI_rctf_size_x(&node->totr)) * +0.5f) / dpi_fac;
+ locy = (td2d->loc[1] - (BLI_rctf_size_y(&node->totr)) * -0.5f) / dpi_fac;
#else
- locx = td2d->loc[0] / dpi_fac;
- locy = td2d->loc[1] / dpi_fac;
+ locx = td2d->loc[0] / dpi_fac;
+ locy = td2d->loc[1] / dpi_fac;
#endif
-
- /* account for parents (nested nodes) */
- if (node->parent) {
- nodeFromView(node->parent, locx, locy, &node->locx, &node->locy);
+
+ /* account for parents (nested nodes) */
+ if (node->parent) {
+ nodeFromView(node->parent, locx, locy, &node->locx, &node->locy);
+ }
+ else {
+ node->locx = locx;
+ node->locy = locy;
+ }
}
- else {
- node->locx = locx;
- node->locy = locy;
+
+ /* handle intersection with noodles */
+ if (tc->data_len == 1) {
+ ED_node_link_intersect_test(t->sa, 1);
}
}
-
- /* handle intersection with noodles */
- if (t->total == 1) {
- ED_node_link_intersect_test(t->sa, 1);
- }
}
/* *** SEQUENCE EDITOR *** */
@@ -2996,13 +3082,14 @@ BLI_INLINE void trans_update_seq(Scene *sce, Sequence *seq, int old_start, int s
void flushTransSeq(TransInfo *t)
{
ListBase *seqbasep = BKE_sequencer_editing_get(t->scene, false)->seqbasep; /* Editing null check already done */
+
int a, new_frame;
TransData *td = NULL;
TransData2D *td2d = NULL;
TransDataSeq *tdsq = NULL;
Sequence *seq;
-
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
/* prevent updating the same seq twice
* if the transdata order is changed this will mess up
@@ -3011,7 +3098,7 @@ void flushTransSeq(TransInfo *t)
int old_start_prev = 0, sel_flag_prev = 0;
/* flush to 2d vector from internally used 3d vector */
- for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
+ for (a = 0, td = tc->data, td2d = tc->data_2d; a < tc->data_len; a++, td++, td2d++) {
int old_start;
tdsq = (TransDataSeq *)td->extra;
seq = tdsq->seq;
@@ -3084,8 +3171,8 @@ void flushTransSeq(TransInfo *t)
}
/* update effects inside meta's */
- for (a = 0, seq_prev = NULL, td = t->data, td2d = t->data2d;
- a < t->total;
+ for (a = 0, seq_prev = NULL, td = tc->data, td2d = tc->data_2d;
+ a < tc->data_len;
a++, td++, td2d++, seq_prev = seq)
{
tdsq = (TransDataSeq *)td->extra;
@@ -3101,7 +3188,7 @@ void flushTransSeq(TransInfo *t)
/* need to do the overlap check in a new loop otherwise adjacent strips
* will not be updated and we'll get false positives */
seq_prev = NULL;
- for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
+ for (a = 0, td = tc->data, td2d = tc->data_2d; a < tc->data_len; a++, td++, td2d++) {
tdsq = (TransDataSeq *)td->extra;
seq = tdsq->seq;
@@ -3162,157 +3249,167 @@ static void createTransUVs(bContext *C, TransInfo *t)
Image *ima = CTX_data_edit_image(C);
Scene *scene = t->scene;
ToolSettings *ts = CTX_data_tool_settings(C);
- TransData *td = NULL;
- TransData2D *td2d = NULL;
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
- BMFace *efa;
- BMIter iter, liter;
- UvElementMap *elementmap = NULL;
- BLI_bitmap *island_enabled = NULL;
- struct { float co[2]; int co_num; } *island_center = NULL;
- int count = 0, countsel = 0, count_rejected = 0;
+
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0;
const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- if (!ED_space_image_show_uvedit(sima, t->obedit))
- return;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- /* count */
- if (is_prop_connected || is_island_center) {
- /* create element map with island information */
- const bool use_facesel = (ts->uv_flag & UV_SYNC_SELECTION) == 0;
- elementmap = BM_uv_element_map_create(em->bm, use_facesel, false, true);
- if (elementmap == NULL) {
- return;
- }
+ TransData *td = NULL;
+ TransData2D *td2d = NULL;
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
+ BMFace *efa;
+ BMIter iter, liter;
+ UvElementMap *elementmap = NULL;
+ BLI_bitmap *island_enabled = NULL;
+ struct { float co[2]; int co_num; } *island_center = NULL;
+ int count = 0, countsel = 0, count_rejected = 0;
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- if (is_prop_connected) {
- island_enabled = BLI_BITMAP_NEW(elementmap->totalIslands, "TransIslandData(UV Editing)");
+ if (!ED_space_image_show_uvedit(sima, tc->obedit)) {
+ continue;
}
- if (is_island_center) {
- island_center = MEM_callocN(sizeof(*island_center) * elementmap->totalIslands, __func__);
- }
- }
+ /* count */
+ if (is_prop_connected || is_island_center) {
+ /* create element map with island information */
+ const bool use_facesel = (ts->uv_flag & UV_SYNC_SELECTION) == 0;
+ elementmap = BM_uv_element_map_create(em->bm, use_facesel, false, true);
+ if (elementmap == NULL) {
+ return;
+ }
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- BMLoop *l;
+ if (is_prop_connected) {
+ island_enabled = BLI_BITMAP_NEW(elementmap->totalIslands, "TransIslandData(UV Editing)");
+ }
- if (!uvedit_face_visible_test(scene, t->obedit, ima, efa)) {
- BM_elem_flag_disable(efa, BM_ELEM_TAG);
- continue;
+ if (is_island_center) {
+ island_center = MEM_callocN(sizeof(*island_center) * elementmap->totalIslands, __func__);
+ }
}
- BM_elem_flag_enable(efa, BM_ELEM_TAG);
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
- countsel++;
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ BMLoop *l;
- if (is_prop_connected || island_center) {
- UvElement *element = BM_uv_element_get(elementmap, efa, l);
+ if (!uvedit_face_visible_test(scene, tc->obedit, ima, efa)) {
+ BM_elem_flag_disable(efa, BM_ELEM_TAG);
+ continue;
+ }
- if (is_prop_connected) {
- BLI_BITMAP_ENABLE(island_enabled, element->island);
- }
+ BM_elem_flag_enable(efa, BM_ELEM_TAG);
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+ countsel++;
- if (is_island_center) {
- if (element->flag == false) {
- MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- add_v2_v2(island_center[element->island].co, luv->uv);
- island_center[element->island].co_num++;
- element->flag = true;
+ if (is_prop_connected || island_center) {
+ UvElement *element = BM_uv_element_get(elementmap, efa, l);
+
+ if (is_prop_connected) {
+ BLI_BITMAP_ENABLE(island_enabled, element->island);
+ }
+
+ if (is_island_center) {
+ if (element->flag == false) {
+ MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ add_v2_v2(island_center[element->island].co, luv->uv);
+ island_center[element->island].co_num++;
+ element->flag = true;
+ }
}
}
}
- }
- if (is_prop_edit) {
- count++;
+ if (is_prop_edit) {
+ count++;
+ }
}
}
- }
- /* note: in prop mode we need at least 1 selected */
- if (countsel == 0) {
- goto finally;
- }
+ /* note: in prop mode we need at least 1 selected */
+ if (countsel == 0) {
+ goto finally;
+ }
- if (is_island_center) {
- int i;
+ if (is_island_center) {
+ int i;
- for (i = 0; i < elementmap->totalIslands; i++) {
- mul_v2_fl(island_center[i].co, 1.0f / island_center[i].co_num);
- mul_v2_v2(island_center[i].co, t->aspect);
+ for (i = 0; i < elementmap->totalIslands; i++) {
+ mul_v2_fl(island_center[i].co, 1.0f / island_center[i].co_num);
+ mul_v2_v2(island_center[i].co, t->aspect);
+ }
}
- }
- t->total = (is_prop_edit) ? count : countsel;
- t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(UV Editing)");
- /* for each 2d uv coord a 3d vector is allocated, so that they can be
- * treated just as if they were 3d verts */
- t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransObData2D(UV Editing)");
+ tc->data_len = (is_prop_edit) ? count : countsel;
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(UV Editing)");
+ /* for each 2d uv coord a 3d vector is allocated, so that they can be
+ * treated just as if they were 3d verts */
+ tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransObData2D(UV Editing)");
- if (sima->flag & SI_CLIP_UV)
- t->flag |= T_CLIP_UV;
+ if (sima->flag & SI_CLIP_UV)
+ t->flag |= T_CLIP_UV;
- td = t->data;
- td2d = t->data2d;
+ td = tc->data;
+ td2d = tc->data_2d;
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- BMLoop *l;
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ BMLoop *l;
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
- continue;
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ continue;
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- const bool selected = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
- MLoopUV *luv;
- const float *center = NULL;
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ const bool selected = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
+ MLoopUV *luv;
+ const float *center = NULL;
- if (!is_prop_edit && !selected)
- continue;
+ if (!is_prop_edit && !selected)
+ continue;
- if (is_prop_connected || is_island_center) {
- UvElement *element = BM_uv_element_get(elementmap, efa, l);
+ if (is_prop_connected || is_island_center) {
+ UvElement *element = BM_uv_element_get(elementmap, efa, l);
- if (is_prop_connected) {
- if (!BLI_BITMAP_TEST(island_enabled, element->island)) {
- count_rejected++;
- continue;
+ if (is_prop_connected) {
+ if (!BLI_BITMAP_TEST(island_enabled, element->island)) {
+ count_rejected++;
+ continue;
+ }
}
- }
- if (is_island_center) {
- center = island_center[element->island].co;
+ if (is_island_center) {
+ center = island_center[element->island].co;
+ }
}
+
+ BM_elem_flag_enable(l, BM_ELEM_TAG);
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ UVsToTransData(t->aspect, td++, td2d++, luv->uv, center, selected);
}
-
- BM_elem_flag_enable(l, BM_ELEM_TAG);
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- UVsToTransData(t->aspect, td++, td2d++, luv->uv, center, selected);
}
- }
-
- if (is_prop_connected) {
- t->total -= count_rejected;
- }
- if (sima->flag & SI_LIVE_UNWRAP)
- ED_uvedit_live_unwrap_begin(t->scene, t->obedit);
+ if (is_prop_connected) {
+ tc->data_len -= count_rejected;
+ }
+ if (sima->flag & SI_LIVE_UNWRAP) {
+ /* TODO(campbell): xform: Only active object currently!
+ * it uses a static variable. */
+ if (tc->is_active) {
+ ED_uvedit_live_unwrap_begin(t->scene, tc->obedit);
+ }
+ }
finally:
- if (is_prop_connected || is_island_center) {
- BM_uv_element_map_free(elementmap);
+ if (is_prop_connected || is_island_center) {
+ BM_uv_element_map_free(elementmap);
- if (is_prop_connected) {
- MEM_freeN(island_enabled);
- }
+ if (is_prop_connected) {
+ MEM_freeN(island_enabled);
+ }
- if (island_center) {
- MEM_freeN(island_center);
+ if (island_center) {
+ MEM_freeN(island_center);
+ }
}
}
}
@@ -3320,37 +3417,38 @@ finally:
void flushTransUVs(TransInfo *t)
{
SpaceImage *sima = t->sa->spacedata.first;
- TransData2D *td;
- int a;
- float aspect_inv[2], size[2];
const bool use_pixel_snap = ((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL));
- aspect_inv[0] = 1.0f / t->aspect[0];
- aspect_inv[1] = 1.0f / t->aspect[1];
-
- if (use_pixel_snap) {
- int size_i[2];
- ED_space_image_get_size(sima, &size_i[0], &size_i[1]);
- size[0] = size_i[0];
- size[1] = size_i[1];
- }
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData2D *td;
+ int a;
+ float aspect_inv[2], size[2];
- /* flush to 2d vector from internally used 3d vector */
- for (a = 0, td = t->data2d; a < t->total; a++, td++) {
- td->loc2d[0] = td->loc[0] * aspect_inv[0];
- td->loc2d[1] = td->loc[1] * aspect_inv[1];
+ aspect_inv[0] = 1.0f / t->aspect[0];
+ aspect_inv[1] = 1.0f / t->aspect[1];
if (use_pixel_snap) {
- td->loc2d[0] = roundf(td->loc2d[0] * size[0]) / size[0];
- td->loc2d[1] = roundf(td->loc2d[1] * size[1]) / size[1];
+ int size_i[2];
+ ED_space_image_get_size(sima, &size_i[0], &size_i[1]);
+ size[0] = size_i[0];
+ size[1] = size_i[1];
+ }
+
+ /* flush to 2d vector from internally used 3d vector */
+ for (a = 0, td = tc->data_2d; a < tc->data_len; a++, td++) {
+ td->loc2d[0] = td->loc[0] * aspect_inv[0];
+ td->loc2d[1] = td->loc[1] * aspect_inv[1];
+
+ if (use_pixel_snap) {
+ td->loc2d[0] = roundf(td->loc2d[0] * size[0]) / size[0];
+ td->loc2d[1] = roundf(td->loc2d[1] * size[1]) / size[1];
+ }
}
}
}
bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
{
- TransData *td;
- int a;
bool clipx = true, clipy = true;
float min[2], max[2];
@@ -3358,39 +3456,45 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
max[0] = t->aspect[0];
max[1] = t->aspect[1];
- for (a = 0, td = t->data; a < t->total; a++, td++) {
- minmax_v2v2_v2(min, max, td->loc);
- }
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- if (resize) {
- if (min[0] < 0.0f && t->center[0] > 0.0f && t->center[0] < t->aspect[0] * 0.5f)
- vec[0] *= t->center[0] / (t->center[0] - min[0]);
- else if (max[0] > t->aspect[0] && t->center[0] < t->aspect[0])
- vec[0] *= (t->center[0] - t->aspect[0]) / (t->center[0] - max[0]);
- else
- clipx = 0;
+ TransData *td;
+ int a;
- if (min[1] < 0.0f && t->center[1] > 0.0f && t->center[1] < t->aspect[1] * 0.5f)
- vec[1] *= t->center[1] / (t->center[1] - min[1]);
- else if (max[1] > t->aspect[1] && t->center[1] < t->aspect[1])
- vec[1] *= (t->center[1] - t->aspect[1]) / (t->center[1] - max[1]);
- else
- clipy = 0;
- }
- else {
- if (min[0] < 0.0f)
- vec[0] -= min[0];
- else if (max[0] > t->aspect[0])
- vec[0] -= max[0] - t->aspect[0];
- else
- clipx = 0;
+ for (a = 0, td = tc->data; a < tc->data_len; a++, td++) {
+ minmax_v2v2_v2(min, max, td->loc);
+ }
- if (min[1] < 0.0f)
- vec[1] -= min[1];
- else if (max[1] > t->aspect[1])
- vec[1] -= max[1] - t->aspect[1];
- else
- clipy = 0;
+ if (resize) {
+ if (min[0] < 0.0f && t->center_global[0] > 0.0f && t->center_global[0] < t->aspect[0] * 0.5f)
+ vec[0] *= t->center_global[0] / (t->center_global[0] - min[0]);
+ else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0])
+ vec[0] *= (t->center_global[0] - t->aspect[0]) / (t->center_global[0] - max[0]);
+ else
+ clipx = 0;
+
+ if (min[1] < 0.0f && t->center_global[1] > 0.0f && t->center_global[1] < t->aspect[1] * 0.5f)
+ vec[1] *= t->center_global[1] / (t->center_global[1] - min[1]);
+ else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1])
+ vec[1] *= (t->center_global[1] - t->aspect[1]) / (t->center_global[1] - max[1]);
+ else
+ clipy = 0;
+ }
+ else {
+ if (min[0] < 0.0f)
+ vec[0] -= min[0];
+ else if (max[0] > t->aspect[0])
+ vec[0] -= max[0] - t->aspect[0];
+ else
+ clipx = 0;
+
+ if (min[1] < 0.0f)
+ vec[1] -= min[1];
+ else if (max[1] > t->aspect[1])
+ vec[1] -= max[1] - t->aspect[1];
+ else
+ clipy = 0;
+ }
}
return (clipx || clipy);
@@ -3398,18 +3502,18 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
void clipUVData(TransInfo *t)
{
- TransData *td = NULL;
- int a;
-
- for (a = 0, td = t->data; a < t->total; a++, td++) {
- if (td->flag & TD_NOACTION)
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (int a = 0; a < tc->data_len; a++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
- if ((td->flag & TD_SKIP) || (!td->loc))
- continue;
+ if ((td->flag & TD_SKIP) || (!td->loc))
+ continue;
- td->loc[0] = min_ff(max_ff(0.0f, td->loc[0]), t->aspect[0]);
- td->loc[1] = min_ff(max_ff(0.0f, td->loc[1]), t->aspect[1]);
+ td->loc[0] = min_ff(max_ff(0.0f, td->loc[0]), t->aspect[0]);
+ td->loc[1] = min_ff(max_ff(0.0f, td->loc[1]), t->aspect[1]);
+ }
}
}
@@ -3443,7 +3547,9 @@ static void createTransNlaData(bContext *C, TransInfo *t)
int filter;
int count = 0;
-
+
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
@@ -3503,12 +3609,12 @@ static void createTransNlaData(bContext *C, TransInfo *t)
}
/* allocate memory for data */
- t->total = count;
+ tc->data_len = count;
- t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(NLA Editor)");
- td = t->data;
- t->custom.type.data = tdn = MEM_callocN(t->total * sizeof(TransDataNla), "TransDataNla (NLA Editor)");
- t->custom.type.use_free = true;
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(NLA Editor)");
+ td = tc->data;
+ tc->custom.type.data = tdn = MEM_callocN(tc->data_len * sizeof(TransDataNla), "TransDataNla (NLA Editor)");
+ tc->custom.type.use_free = true;
/* loop 2: build transdata array */
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -4038,11 +4144,11 @@ typedef struct tGPFtransdata {
/* This function helps flush transdata written to tempdata into the gp-frames */
void flushTransIntFrameActionData(TransInfo *t)
{
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
tGPFtransdata *tfd = t->custom.type.data;
- int i;
/* flush data! */
- for (i = 0; i < t->total; i++, tfd++) {
+ for (int i = 0; i < tc->data_len; i++, tfd++) {
*(tfd->sdata) = round_fl_to_int(tfd->val);
}
}
@@ -4198,18 +4304,20 @@ static void createTransActionData(bContext *C, TransInfo *t)
ANIM_animdata_freelist(&anim_data);
return;
}
-
+
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* allocate memory for data */
- t->total = count;
+ tc->data_len = count;
- t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(Action Editor)");
- t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "transdata2d");
- td = t->data;
- td2d = t->data2d;
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(Action Editor)");
+ tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "transdata2d");
+ td = tc->data;
+ td2d = tc->data_2d;
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
- t->custom.type.data = tfd = MEM_callocN(sizeof(tGPFtransdata) * count, "tGPFtransdata");
- t->custom.type.use_free = true;
+ tc->custom.type.data = tfd = MEM_callocN(sizeof(tGPFtransdata) * count, "tGPFtransdata");
+ tc->custom.type.use_free = true;
}
/* loop 2: build transdata array */
@@ -4254,7 +4362,7 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* calculate distances for proportional editing */
if (is_prop_edit) {
- td = t->data;
+ td = tc->data;
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt;
@@ -4596,19 +4704,21 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
ANIM_animdata_freelist(&anim_data);
return;
}
-
+
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* allocate memory for data */
- t->total = count;
+ tc->data_len = count;
- t->data = MEM_callocN(t->total * sizeof(TransData), "TransData (Graph Editor)");
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData (Graph Editor)");
/* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */
- t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransData2D (Graph Editor)");
- t->custom.type.data = MEM_callocN(t->total * sizeof(TransDataGraph), "TransDataGraph");
- t->custom.type.use_free = true;
+ tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransData2D (Graph Editor)");
+ tc->custom.type.data = MEM_callocN(tc->data_len * sizeof(TransDataGraph), "TransDataGraph");
+ tc->custom.type.use_free = true;
- td = t->data;
- td2d = t->data2d;
- tdg = t->custom.type.data;
+ td = tc->data;
+ td2d = tc->data_2d;
+ tdg = tc->custom.type.data;
/* precompute space-conversion matrices for dealing with non-uniform scaling of Graph Editor */
unit_m3(mtx);
@@ -4735,7 +4845,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (is_prop_edit) {
/* loop 2: build transdata arrays */
- td = t->data;
+ td = tc->data;
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
@@ -4891,12 +5001,14 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve
TransData *td;
int i, j;
char *adjusted;
-
+
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* dynamically allocate an array of chars to mark whether an TransData's
* pointers have been fixed already, so that we don't override ones that are
* already done
*/
- adjusted = MEM_callocN(t->total, "beztmap_adjusted_map");
+ adjusted = MEM_callocN(tc->data_len, "beztmap_adjusted_map");
/* for each beztmap item, find if it is used anywhere */
bezm = bezms;
@@ -4904,9 +5016,9 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve
/* loop through transdata, testing if we have a hit
* for the handles (vec[0]/vec[2]), we must also check if they need to be swapped...
*/
- td2d = t->data2d;
- td = t->data;
- for (j = 0; j < t->total; j++, td2d++, td++) {
+ td2d = tc->data_2d;
+ td = tc->data;
+ for (j = 0; j < tc->data_len; j++, td2d++, td++) {
/* skip item if already marked */
if (adjusted[j] != 0) continue;
@@ -5009,9 +5121,11 @@ void flushTransGraphData(TransInfo *t)
double secf = FPS;
int a;
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* flush to 2d vector from internally used 3d vector */
- for (a = 0, td = t->data, td2d = t->data2d, tdg = t->custom.type.data;
- a < t->total;
+ for (a = 0, td = tc->data, td2d = tc->data_2d, tdg = tc->custom.type.data;
+ a < tc->data_len;
a++, td++, td2d++, tdg++)
{
AnimData *adt = (AnimData *)td->extra; /* pointers to relevant AnimData blocks are stored in the td->extra pointers */
@@ -5373,13 +5487,15 @@ static void SeqTransDataBounds(TransInfo *t, ListBase *seqbase, TransSeq *ts)
}
-static void freeSeqData(TransInfo *t, TransCustomData *custom_data)
+static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data)
{
Editing *ed = BKE_sequencer_editing_get(t->scene, false);
if (ed != NULL) {
+
+
ListBase *seqbasep = ed->seqbasep;
- TransData *td = t->data;
+ TransData *td = tc->data;
int a;
/* prevent updating the same seq twice
@@ -5407,7 +5523,7 @@ static void freeSeqData(TransInfo *t, TransCustomData *custom_data)
{
int overlap = 0;
- for (a = 0, seq_prev = NULL; a < t->total; a++, td++, seq_prev = seq) {
+ for (a = 0, seq_prev = NULL; a < tc->data_len; a++, td++, seq_prev = seq) {
seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev) && (seq->depth == 0) && (seq->flag & SEQ_OVERLAP)) {
overlap = 1;
@@ -5420,8 +5536,8 @@ static void freeSeqData(TransInfo *t, TransCustomData *custom_data)
for (seq = seqbasep->first; seq; seq = seq->next)
seq->tmp = NULL;
- td = t->data;
- for (a = 0, seq_prev = NULL; a < t->total; a++, td++, seq_prev = seq) {
+ td = tc->data;
+ for (a = 0, seq_prev = NULL; a < tc->data_len; a++, td++, seq_prev = seq) {
seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev)) {
/* check effects strips, we cant change their time */
@@ -5444,8 +5560,8 @@ static void freeSeqData(TransInfo *t, TransCustomData *custom_data)
if (t->flag & T_ALT_TRANSFORM) {
int minframe = MAXFRAME;
- td = t->data;
- for (a = 0, seq_prev = NULL; a < t->total; a++, td++, seq_prev = seq) {
+ td = tc->data;
+ for (a = 0, seq_prev = NULL; a < tc->data_len; a++, td++, seq_prev = seq) {
seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev) && (seq->depth == 0)) {
minframe = min_ii(minframe, seq->startdisp);
@@ -5481,8 +5597,8 @@ static void freeSeqData(TransInfo *t, TransCustomData *custom_data)
if (has_effect_any) {
/* update effects strips based on strips just moved in time */
- td = t->data;
- for (a = 0, seq_prev = NULL; a < t->total; a++, td++, seq_prev = seq) {
+ td = tc->data;
+ for (a = 0, seq_prev = NULL; a < tc->data_len; a++, td++, seq_prev = seq) {
seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev)) {
if ((seq->type & SEQ_TYPE_EFFECT) && seq->seq1) {
@@ -5494,8 +5610,8 @@ static void freeSeqData(TransInfo *t, TransCustomData *custom_data)
if (has_effect_root) {
/* now if any effects _still_ overlap, we need to move them up */
- td = t->data;
- for (a = 0, seq_prev = NULL; a < t->total; a++, td++, seq_prev = seq) {
+ td = tc->data;
+ for (a = 0, seq_prev = NULL; a < tc->data_len; a++, td++, seq_prev = seq) {
seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev) && (seq->depth == 0)) {
if ((seq->type & SEQ_TYPE_EFFECT) && seq->seq1) {
@@ -5524,7 +5640,7 @@ static void freeSeqData(TransInfo *t, TransCustomData *custom_data)
}
else {
/* Canceled, need to update the strips display */
- for (a = 0; a < t->total; a++, td++) {
+ for (a = 0; a < tc->data_len; a++, td++) {
seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev) && (seq->depth == 0)) {
if (seq->flag & SEQ_OVERLAP)
@@ -5543,9 +5659,9 @@ static void freeSeqData(TransInfo *t, TransCustomData *custom_data)
MEM_freeN(custom_data->data);
custom_data->data = NULL;
}
- if (t->data) {
- MEM_freeN(t->data); // XXX postTrans usually does this
- t->data = NULL;
+ if (tc->data) {
+ MEM_freeN(tc->data); // XXX postTrans usually does this
+ tc->data = NULL;
}
}
@@ -5564,12 +5680,14 @@ static void createTransSeqData(bContext *C, TransInfo *t)
int count = 0;
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
if (ed == NULL) {
- t->total = 0;
+ tc->data_len = 0;
return;
}
- t->custom.type.free_cb = freeSeqData;
+ tc->custom.type.free_cb = freeSeqData;
xmouse = (int)UI_view2d_region_to_view_x(v2d, t->mouse.imval[0]);
@@ -5608,18 +5726,18 @@ static void createTransSeqData(bContext *C, TransInfo *t)
count = SeqTransCount(t, NULL, ed->seqbasep, 0);
/* allocate memory for data */
- t->total = count;
+ tc->data_len = count;
/* stop if trying to build list if nothing selected */
if (count == 0) {
return;
}
- t->custom.type.data = ts = MEM_callocN(sizeof(TransSeq), "transseq");
- t->custom.type.use_free = true;
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransSeq TransData");
- td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransSeq TransData2D");
- ts->tdseq = tdsq = MEM_callocN(t->total * sizeof(TransDataSeq), "TransSeq TransDataSeq");
+ tc->custom.type.data = ts = MEM_callocN(sizeof(TransSeq), "transseq");
+ tc->custom.type.use_free = true;
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransSeq TransData");
+ td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransSeq TransData2D");
+ ts->tdseq = tdsq = MEM_callocN(tc->data_len * sizeof(TransDataSeq), "TransSeq TransDataSeq");
/* loop 2: build transdata array */
SeqToTransData_Recursive(t, ed->seqbasep, td, td2d, tdsq);
@@ -5748,11 +5866,11 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
if (skip_invert == false && constinv == false) {
ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */
- BKE_object_where_is_calc(&t->eval_ctx, t->scene, ob);
+ BKE_object_where_is_calc(t->depsgraph, t->scene, ob);
ob->transflag &= ~OB_NO_CONSTRAINTS;
}
else
- BKE_object_where_is_calc(&t->eval_ctx, t->scene, ob);
+ BKE_object_where_is_calc(t->depsgraph, t->scene, ob);
td->ob = ob;
@@ -6349,39 +6467,42 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
{
/* so automerge supports mirror */
if ((t->scene->toolsettings->automerge) &&
- (t->obedit && t->obedit->type == OB_MESH))
+ ((t->flag & T_EDIT) && t->obedit_type == OB_MESH))
{
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
- BMesh *bm = em->bm;
- char hflag;
- bool has_face_sel = (bm->totfacesel != 0);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- if (t->flag & T_MIRROR) {
- TransData *td;
- int i;
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
+ BMesh *bm = em->bm;
+ char hflag;
+ bool has_face_sel = (bm->totfacesel != 0);
+
+ if (t->flag & T_MIRROR) {
+ TransData *td;
+ int i;
- /* rather then adjusting the selection (which the user would notice)
- * tag all mirrored verts, then automerge those */
- BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
+ /* rather then adjusting the selection (which the user would notice)
+ * tag all mirrored verts, then automerge those */
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
- for (i = 0, td = t->data; i < t->total; i++, td++) {
- if (td->extra) {
- BM_elem_flag_enable((BMVert *)td->extra, BM_ELEM_TAG);
+ for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
+ if (td->extra) {
+ BM_elem_flag_enable((BMVert *)td->extra, BM_ELEM_TAG);
+ }
}
- }
- hflag = BM_ELEM_SELECT | BM_ELEM_TAG;
- }
- else {
- hflag = BM_ELEM_SELECT;
- }
+ hflag = BM_ELEM_SELECT | BM_ELEM_TAG;
+ }
+ else {
+ hflag = BM_ELEM_SELECT;
+ }
- EDBM_automerge(t->scene, t->obedit, true, hflag);
+ EDBM_automerge(t->scene, tc->obedit, true, hflag);
- /* Special case, this is needed or faces won't re-select.
- * Flush selected edges to faces. */
- if (has_face_sel && (em->selectmode == SCE_SELECT_FACE)) {
- EDBM_selectmode_flush_ex(em, SCE_SELECT_EDGE);
+ /* Special case, this is needed or faces won't re-select.
+ * Flush selected edges to faces. */
+ if (has_face_sel && (em->selectmode == SCE_SELECT_FACE)) {
+ EDBM_selectmode_flush_ex(em, SCE_SELECT_EDGE);
+ }
}
}
}
@@ -6399,50 +6520,53 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
const bool duplicate = (t->mode == TFM_TIME_DUPLICATE);
/* early out when nothing happened */
- if (t->total == 0 || t->mode == TFM_DUMMY)
+ if (t->data_len_all == 0 || t->mode == TFM_DUMMY) {
return;
-
+ }
+
if (t->spacetype == SPACE_VIEW3D) {
- if (t->obedit) {
+ if (t->flag & T_EDIT) {
/* Special Exception:
* We don't normally access 't->custom.mode' here, but its needed in this case. */
if (canceled == 0) {
/* we need to delete the temporary faces before automerging */
if (t->mode == TFM_EDGE_SLIDE) {
- EdgeSlideData *sld = t->custom.mode.data;
-
/* handle multires re-projection, done
* on transform completion since it's
* really slow -joeedh */
projectEdgeSlideData(t, true);
- /* free temporary faces to avoid automerging and deleting
- * during cleanup - psy-fi */
- freeEdgeSlideTempFaces(sld);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ EdgeSlideData *sld = tc->custom.mode.data;
+
+ /* free temporary faces to avoid automerging and deleting
+ * during cleanup - psy-fi */
+ freeEdgeSlideTempFaces(sld);
+ }
}
else if (t->mode == TFM_VERT_SLIDE) {
/* as above */
- VertSlideData *sld = t->custom.mode.data;
projectVertSlideData(t, true);
- freeVertSlideTempFaces(sld);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ VertSlideData *sld = tc->custom.mode.data;
+ freeVertSlideTempFaces(sld);
+ }
}
- if (t->obedit->type == OB_MESH) {
+ if (t->obedit_type == OB_MESH) {
special_aftertrans_update__mesh(C, t);
}
}
else {
if (t->mode == TFM_EDGE_SLIDE) {
- EdgeSlideData *sld = t->custom.mode.data;
-
- sld->perc = 0.0;
+ EdgeSlideParams *slp = t->custom.mode.data;
+ slp->perc = 0.0;
projectEdgeSlideData(t, false);
}
else if (t->mode == TFM_VERT_SLIDE) {
- VertSlideData *sld = t->custom.mode.data;
-
- sld->perc = 0.0;
+ EdgeSlideParams *slp = t->custom.mode.data;
+ slp->perc = 0.0;
projectVertSlideData(t, false);
}
}
@@ -6716,64 +6840,71 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
ED_nla_postop_refresh(&ac);
}
}
- else if (t->obedit) {
- if (t->obedit->type == OB_MESH) {
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
- /* table needs to be created for each edit command, since vertices can move etc */
- ED_mesh_mirror_spatial_table(t->obedit, em, NULL, NULL, 'e');
+ else if (t->flag & T_EDIT) {
+ if (t->obedit_type == OB_MESH) {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
+ /* table needs to be created for each edit command, since vertices can move etc */
+ ED_mesh_mirror_spatial_table(tc->obedit, em, NULL, NULL, 'e');
+ /* TODO(campbell): xform: We need support for many mirror objects at once! */
+ break;
+ }
}
}
- else if ((t->flag & T_POSE) && (t->poseobj)) {
- bArmature *arm;
- bPoseChannel *pchan;
- short targetless_ik = 0;
+ else if (t->flag & T_POSE) {
- ob = t->poseobj;
- arm = ob->data;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- if ((t->flag & T_AUTOIK) && (t->options & CTX_AUTOCONFIRM)) {
- /* when running transform non-interactively (operator exec),
- * we need to update the pose otherwise no updates get called during
- * transform and the auto-ik is not applied. see [#26164] */
- struct Object *pose_ob = t->poseobj;
- BKE_pose_where_is(&t->eval_ctx, t->scene, pose_ob);
- }
+ bArmature *arm;
+ bPoseChannel *pchan;
+ short targetless_ik = 0;
- /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */
- if (!canceled && (t->mode != TFM_DUMMY))
- count_set_pose_transflags(&t->mode, t->around, ob);
+ ob = tc->poseobj;
+ arm = ob->data;
- /* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
- if (!canceled && t->mode == TFM_TRANSLATION)
- targetless_ik = apply_targetless_ik(ob);
- else {
- /* not forget to clear the auto flag */
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- bKinematicConstraint *data = has_targetless_ik(pchan);
- if (data) data->flag &= ~CONSTRAINT_IK_AUTO;
+ if ((t->flag & T_AUTOIK) && (t->options & CTX_AUTOCONFIRM)) {
+ /* when running transform non-interactively (operator exec),
+ * we need to update the pose otherwise no updates get called during
+ * transform and the auto-ik is not applied. see [#26164] */
+ struct Object *pose_ob = tc->poseobj;
+ BKE_pose_where_is(t->depsgraph, t->scene, pose_ob);
}
- }
- if (t->mode == TFM_TRANSLATION)
- pose_grab_with_ik_clear(ob);
-
- /* automatic inserting of keys and unkeyed tagging - only if transform wasn't canceled (or TFM_DUMMY) */
- if (!canceled && (t->mode != TFM_DUMMY)) {
- autokeyframe_pose_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- }
- else if (arm->flag & ARM_DELAYDEFORM) {
- /* TODO(sergey): Armature is already updated by recalcData(), so we
- * might save some time by skipping re-evaluating it. But this isn't
- * possible yet within new dependency graph, and also other contexts
- * might need to update their CoW copies.
- */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- }
- else {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- }
+ /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */
+ if (!canceled && (t->mode != TFM_DUMMY))
+ count_set_pose_transflags(&t->mode, t->around, ob);
+
+ /* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
+ if (!canceled && t->mode == TFM_TRANSLATION)
+ targetless_ik = apply_targetless_ik(ob);
+ else {
+ /* not forget to clear the auto flag */
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ bKinematicConstraint *data = has_targetless_ik(pchan);
+ if (data) data->flag &= ~CONSTRAINT_IK_AUTO;
+ }
+ }
+
+ if (t->mode == TFM_TRANSLATION)
+ pose_grab_with_ik_clear(ob);
+ /* automatic inserting of keys and unkeyed tagging - only if transform wasn't canceled (or TFM_DUMMY) */
+ if (!canceled && (t->mode != TFM_DUMMY)) {
+ autokeyframe_pose_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
+ else if (arm->flag & ARM_DELAYDEFORM) {
+ /* TODO(sergey): Armature is already updated by recalcData(), so we
+ * might save some time by skipping re-evaluating it. But this isn't
+ * possible yet within new dependency graph, and also other contexts
+ * might need to update their CoW copies.
+ */
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
+ else {
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
+ }
}
else if (t->options & CTX_PAINT_CURVE) {
/* pass */
@@ -6790,8 +6921,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
BLI_assert(t->flag & (T_OBJECT | T_TEXTURE));
- for (i = 0; i < t->total; i++) {
- TransData *td = t->data + i;
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
+ for (i = 0; i < tc->data_len; i++) {
+ TransData *td = tc->data + i;
ListBase pidlist;
PTCacheID *pid;
ob = td->ob;
@@ -6845,7 +6978,7 @@ int special_transform_moving(TransInfo *t)
else if (t->spacetype == SPACE_IPO) {
return G_TRANSFORM_FCURVES;
}
- else if (t->obedit || ((t->flag & T_POSE) && (t->poseobj))) {
+ else if ((t->flag & T_EDIT) || (t->flag & T_POSE)) {
return G_TRANSFORM_EDIT;
}
else if (t->flag & (T_OBJECT | T_TEXTURE)) {
@@ -6863,21 +6996,23 @@ static void createTransObject(bContext *C, TransInfo *t)
set_trans_object_base_flags(t);
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* count */
- t->total = CTX_DATA_COUNT(C, selected_objects);
+ tc->data_len = CTX_DATA_COUNT(C, selected_objects);
- if (!t->total) {
+ if (!tc->data_len) {
/* clear here, main transform function escapes too */
clear_trans_object_base_flags(t);
return;
}
if (is_prop_edit) {
- t->total += count_proportional_objects(t);
+ tc->data_len += count_proportional_objects(t);
}
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransOb");
- tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "TransObExtension");
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransOb");
+ tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension), "TransObExtension");
CTX_DATA_BEGIN(C, Base *, base, selected_bases)
{
@@ -6997,7 +7132,9 @@ static void createTransNodeData(bContext *UNUSED(C), TransInfo *t)
SpaceNode *snode = t->sa->spacedata.first;
bNode *node;
- t->total = 0;
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
+ tc->data_len = 0;
if (!snode->edittree) {
return;
@@ -7010,15 +7147,15 @@ static void createTransNodeData(bContext *UNUSED(C), TransInfo *t)
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_SELECT && is_node_parent_select(node) == false) {
node->flag |= NODE_TRANSFORM;
- t->total++;
+ tc->data_len++;
}
else {
node->flag &= ~NODE_TRANSFORM;
}
}
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransNode TransData");
- td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransNode TransData2D");
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransNode TransData");
+ td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransNode TransData2D");
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TRANSFORM) {
@@ -7203,7 +7340,7 @@ static void planeTrackToTransData(const int framenr, TransData *td, TransData2D
}
}
-static void transDataTrackingFree(TransInfo *UNUSED(t), TransCustomData *custom_data)
+static void transDataTrackingFree(TransInfo *UNUSED(t), TransDataContainer *UNUSED(tc), TransCustomData *custom_data)
{
if (custom_data->data) {
TransDataTracking *tdt = custom_data->data;
@@ -7228,22 +7365,24 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
TransDataTracking *tdt;
int framenr = ED_space_clip_get_clip_frame_number(sc);
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* count */
- t->total = 0;
+ tc->data_len = 0;
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- t->total++; /* offset */
+ tc->data_len++; /* offset */
if (track->flag & SELECT)
- t->total++;
+ tc->data_len++;
if (track->pat_flag & SELECT)
- t->total += 4;
+ tc->data_len += 4;
if (track->search_flag & SELECT)
- t->total += 2;
+ tc->data_len += 2;
}
track = track->next;
@@ -7254,18 +7393,18 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
plane_track = plane_track->next)
{
if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
- t->total += 4;
+ tc->data_len += 4;
}
}
- if (t->total == 0)
+ if (tc->data_len == 0)
return;
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransTracking TransData");
- td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransTracking TransData2D");
- tdt = t->custom.type.data = MEM_callocN(t->total * sizeof(TransDataTracking), "TransTracking TransDataTracking");
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransTracking TransData");
+ td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransTracking TransData2D");
+ tdt = tc->custom.type.data = MEM_callocN(tc->data_len * sizeof(TransDataTracking), "TransTracking TransDataTracking");
- t->custom.type.free_cb = transDataTrackingFree;
+ tc->custom.type.free_cb = transDataTrackingFree;
/* create actual data */
track = tracksbase->first;
@@ -7367,8 +7506,10 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* count */
- t->total = 0;
+ tc->data_len = 0;
if ((sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) == 0) {
return;
@@ -7385,23 +7526,23 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
continue;
if (marker->flag & MARKER_GRAPH_SEL_X)
- t->total += 1;
+ tc->data_len += 1;
if (marker->flag & MARKER_GRAPH_SEL_Y)
- t->total += 1;
+ tc->data_len += 1;
}
}
track = track->next;
}
- if (t->total == 0)
+ if (tc->data_len == 0)
return;
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransTracking TransData");
- td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransTracking TransData2D");
- t->custom.type.data = tdt = MEM_callocN(t->total * sizeof(TransDataTracking), "TransTracking TransDataTracking");
- t->custom.type.free_cb = transDataTrackingFree;
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransTracking TransData");
+ td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransTracking TransData2D");
+ tc->custom.type.data = tdt = MEM_callocN(tc->data_len * sizeof(TransDataTracking), "TransTracking TransDataTracking");
+ tc->custom.type.free_cb = transDataTrackingFree;
/* create actual data */
track = tracksbase->first;
@@ -7442,7 +7583,9 @@ static void createTransTrackingData(bContext *C, TransInfo *t)
MovieClip *clip = ED_space_clip_get_clip(sc);
int width, height;
- t->total = 0;
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
+ tc->data_len = 0;
if (!clip)
return;
@@ -7463,12 +7606,14 @@ static void createTransTrackingData(bContext *C, TransInfo *t)
static void cancelTransTracking(TransInfo *t)
{
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
SpaceClip *sc = t->sa->spacedata.first;
int i, framenr = ED_space_clip_get_clip_frame_number(sc);
- TransDataTracking *tdt_array = t->custom.type.data;
+ TransDataTracking *tdt_array = tc->custom.type.data;
+
i = 0;
- while (i < t->total) {
+ while (i < tc->data_len) {
TransDataTracking *tdt = &tdt_array[i];
if (tdt->mode == transDataTracking_ModeTracks) {
@@ -7525,8 +7670,10 @@ void flushTransTracking(TransInfo *t)
if (t->state == TRANS_CANCEL)
cancelTransTracking(t);
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* flush to 2d vector from internally used 3d vector */
- for (a = 0, td = t->data, td2d = t->data2d, tdt = t->custom.type.data; a < t->total; a++, td2d++, td++, tdt++) {
+ for (a = 0, td = tc->data, td2d = tc->data_2d, tdt = tc->custom.type.data; a < tc->data_len; a++, td2d++, td++, tdt++) {
if (tdt->mode == transDataTracking_ModeTracks) {
float loc2d[2];
@@ -7792,7 +7939,9 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
const bool is_prop_edit = (t->flag & T_PROP_EDIT);
float asp[2];
- t->total = 0;
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
+ tc->data_len = 0;
if (!mask)
return;
@@ -7852,13 +8001,13 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
ED_mask_get_aspect(t->sa, t->ar, &asp[0], &asp[1]);
- t->total = (is_prop_edit) ? count : countsel;
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mask Editing)");
+ tc->data_len = (is_prop_edit) ? count : countsel;
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Mask Editing)");
/* for each 2d uv coord a 3d vector is allocated, so that they can be
* treated just as if they were 3d verts */
- td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransObData2D(Mask Editing)");
- t->custom.type.data = tdm = MEM_callocN(t->total * sizeof(TransDataMasking), "TransDataMasking(Mask Editing)");
- t->custom.type.use_free = true;
+ td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransObData2D(Mask Editing)");
+ tc->custom.type.data = tdm = MEM_callocN(tc->data_len * sizeof(TransDataMasking), "TransDataMasking(Mask Editing)");
+ tc->custom.type.use_free = true;
/* create data */
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
@@ -7915,12 +8064,14 @@ void flushTransMasking(TransInfo *t)
int a;
float asp[2], inv[2];
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
ED_mask_get_aspect(t->sa, t->ar, &asp[0], &asp[1]);
inv[0] = 1.0f / asp[0];
inv[1] = 1.0f / asp[1];
/* flush to 2d vector from internally used 3d vector */
- for (a = 0, td = t->data2d, tdm = t->custom.type.data; a < t->total; a++, td++, tdm++) {
+ for (a = 0, td = tc->data_2d, tdm = tc->custom.type.data; a < tc->data_len; a++, td++, tdm++) {
td->loc2d[0] = td->loc[0] * inv[0];
td->loc2d[1] = td->loc[1] * inv[1];
mul_m3_v2(tdm->parent_inverse_matrix, td->loc2d);
@@ -8039,7 +8190,9 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t)
int i;
int total = 0;
- t->total = 0;
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
+ tc->data_len = 0;
if (!paint || !paint->brush || !paint->brush->paint_curve)
return;
@@ -8065,11 +8218,11 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t)
if (!total)
return;
- t->total = total;
- td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransData2D");
- td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransData");
- t->custom.type.data = tdpc = MEM_callocN(t->total * sizeof(TransDataPaintCurve), "TransDataPaintCurve");
- t->custom.type.use_free = true;
+ tc->data_len = total;
+ td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransData2D");
+ td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData");
+ tc->custom.type.data = tdpc = MEM_callocN(tc->data_len * sizeof(TransDataPaintCurve), "TransDataPaintCurve");
+ tc->custom.type.use_free = true;
for (pcp = pc->points, i = 0; i < pc->tot_points; i++, pcp++) {
if (PC_IS_ANY_SEL(pcp)) {
@@ -8100,10 +8253,13 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t)
void flushTransPaintCurve(TransInfo *t)
{
int i;
- TransData2D *td2d = t->data2d;
- TransDataPaintCurve *tdpc = t->custom.type.data;
- for (i = 0; i < t->total; i++, tdpc++, td2d++) {
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
+ TransData2D *td2d = tc->data_2d;
+ TransDataPaintCurve *tdpc = tc->custom.type.data;
+
+ for (i = 0; i < tc->data_len; i++, tdpc++, td2d++) {
PaintCurvePoint *pcp = tdpc->pcp;
copy_v2_v2(pcp->bez.vec[tdpc->id], td2d->loc);
}
@@ -8122,15 +8278,16 @@ static void createTransGPencil(bContext *C, TransInfo *t)
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
const bool is_prop_edit_connected = (t->flag & T_PROP_CONNECTED) != 0;
-
-
+
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* == Grease Pencil Strokes to Transform Data ==
* Grease Pencil stroke points can be a mixture of 2D (screen-space),
* or 3D coordinates. However, they're always saved as 3D points.
* For now, we just do these without creating TransData2D for the 2D
* strokes. This may cause issues in future though.
*/
- t->total = 0;
+ tc->data_len = 0;
if (gpd == NULL)
return;
@@ -8159,11 +8316,11 @@ static void createTransGPencil(bContext *C, TransInfo *t)
if (is_prop_edit_connected) {
/* connected only - so only if selected */
if (gps->flag & GP_STROKE_SELECT)
- t->total += gps->totpoints;
+ tc->data_len += gps->totpoints;
}
else {
/* everything goes - connection status doesn't matter */
- t->total += gps->totpoints;
+ tc->data_len += gps->totpoints;
}
}
else {
@@ -8175,7 +8332,7 @@ static void createTransGPencil(bContext *C, TransInfo *t)
// TODO: 2D vs 3D?
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & GP_SPOINT_SELECT)
- t->total++;
+ tc->data_len++;
}
}
}
@@ -8184,13 +8341,13 @@ static void createTransGPencil(bContext *C, TransInfo *t)
}
/* Stop trying if nothing selected */
- if (t->total == 0) {
+ if (tc->data_len == 0) {
return;
}
/* Allocate memory for data */
- t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(GPencil)");
- td = t->data;
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(GPencil)");
+ td = tc->data;
unit_m3(smtx);
unit_m3(mtx);
@@ -8358,6 +8515,29 @@ static void createTransGPencil(bContext *C, TransInfo *t)
}
}
+static int countAndCleanTransDataContainer(TransInfo *t)
+{
+ BLI_assert(ELEM(t->data_len_all, 0, -1));
+ t->data_len_all = 0;
+ uint data_container_len_orig = t->data_container_len;
+ for (TransDataContainer *th_end = t->data_container - 1, *tc = t->data_container + (t->data_container_len - 1); tc != th_end; tc--) {
+ if (tc->data_len == 0) {
+ uint index = tc - t->data_container;
+ if (index + 1 != t->data_container_len) {
+ SWAP(TransDataContainer, t->data_container[index], t->data_container[t->data_container_len - 1]);
+ }
+ t->data_container_len -= 1;
+ }
+ else {
+ t->data_len_all += tc->data_len;
+ }
+ }
+ if (data_container_len_orig != t->data_container_len) {
+ t->data_container = MEM_reallocN(t->data_container, sizeof(*t->data_container) * t->data_container_len);
+ }
+ return t->data_len_all;
+}
+
void createTransData(bContext *C, TransInfo *t)
{
@@ -8365,16 +8545,27 @@ void createTransData(bContext *C, TransInfo *t)
ViewLayer *view_layer = t->view_layer;
Object *ob = OBACT(view_layer);
+ t->data_len_all = -1;
+
/* if tests must match recalcData for correct updates */
if (t->options & CTX_TEXTURE) {
t->flag |= T_TEXTURE;
+
createTransTexspace(t);
+ countAndCleanTransDataContainer(t);
}
else if (t->options & CTX_EDGE) {
- t->ext = NULL;
+ /* Multi object editing. */
+ initTransDataContainers_FromObjectData(t);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ tc->data_ext = NULL;
+ }
t->flag |= T_EDIT;
+
createTransEdge(t);
- if (t->data && t->flag & T_PROP_EDIT) {
+ countAndCleanTransDataContainer(t);
+
+ if (t->data_len_all && t->flag & T_PROP_EDIT) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
@@ -8383,9 +8574,11 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->options & CTX_GPENCIL_STROKES) {
t->options |= CTX_GPENCIL_STROKES;
t->flag |= T_POINTS;
+
createTransGPencil(C, t);
+ countAndCleanTransDataContainer(t);
- if (t->data && (t->flag & T_PROP_EDIT)) {
+ if (t->data_len_all && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
@@ -8394,22 +8587,32 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->spacetype == SPACE_IMAGE) {
t->flag |= T_POINTS | T_2D_EDIT;
if (t->options & CTX_MASK) {
+
/* copied from below */
createTransMaskingData(C, t);
+ countAndCleanTransDataContainer(t);
- if (t->data && (t->flag & T_PROP_EDIT)) {
+ if (t->data_len_all && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, true);
sort_trans_data_dist(t);
}
}
else if (t->options & CTX_PAINT_CURVE) {
- if (!ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN))
+ if (!ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN)) {
createTransPaintCurveVerts(C, t);
+ countAndCleanTransDataContainer(t);
+ }
}
- else if (t->obedit) {
+ else if (t->obedit_type == OB_MESH) {
+
+ initTransDataContainers_FromObjectData(t);
createTransUVs(C, t);
- if (t->data && (t->flag & T_PROP_EDIT)) {
+ countAndCleanTransDataContainer(t);
+
+ t->flag |= T_EDIT;
+
+ if (t->data_len_all && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
@@ -8418,9 +8621,11 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_ACTION) {
t->flag |= T_POINTS | T_2D_EDIT;
+
createTransActionData(C, t);
+ countAndCleanTransDataContainer(t);
- if (t->data && (t->flag & T_PROP_EDIT)) {
+ if (t->data_len_all && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
//set_prop_dist(t, false); /* don't do that, distance has been set in createTransActionData already */
sort_trans_data_dist(t);
@@ -8429,17 +8634,20 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->spacetype == SPACE_NLA) {
t->flag |= T_POINTS | T_2D_EDIT;
createTransNlaData(C, t);
+ countAndCleanTransDataContainer(t);
}
else if (t->spacetype == SPACE_SEQ) {
t->flag |= T_POINTS | T_2D_EDIT;
t->num.flag |= NUM_NO_FRACTION; /* sequencer has no use for floating point transformations */
createTransSeqData(C, t);
+ countAndCleanTransDataContainer(t);
}
else if (t->spacetype == SPACE_IPO) {
t->flag |= T_POINTS | T_2D_EDIT;
createTransGraphEditData(C, t);
+ countAndCleanTransDataContainer(t);
- if (t->data && (t->flag & T_PROP_EDIT)) {
+ if (t->data_len_all && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, false); /* don't do that, distance has been set in createTransGraphEditData already */
sort_trans_data_dist(t);
@@ -8447,8 +8655,11 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_NODE) {
t->flag |= T_POINTS | T_2D_EDIT;
+
createTransNodeData(C, t);
- if (t->data && (t->flag & T_PROP_EDIT)) {
+ countAndCleanTransDataContainer(t);
+
+ if (t->data_len_all && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
@@ -8456,37 +8667,45 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_CLIP) {
t->flag |= T_POINTS | T_2D_EDIT;
- if (t->options & CTX_MOVIECLIP)
+ if (t->options & CTX_MOVIECLIP) {
createTransTrackingData(C, t);
+ countAndCleanTransDataContainer(t);
+ }
else if (t->options & CTX_MASK) {
/* copied from above */
createTransMaskingData(C, t);
+ countAndCleanTransDataContainer(t);
- if (t->data && (t->flag & T_PROP_EDIT)) {
+ if (t->data_len_all && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, true);
sort_trans_data_dist(t);
}
}
}
- else if (t->obedit) {
- t->ext = NULL;
- if (t->obedit->type == OB_MESH) {
+ else if (t->obedit_type != -1) {
+ /* Multi object editing. */
+ initTransDataContainers_FromObjectData(t);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ tc->data_ext = NULL;
+ }
+ if (t->obedit_type == OB_MESH) {
createTransEditVerts(t);
}
- else if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) {
+ else if (ELEM(t->obedit_type, OB_CURVE, OB_SURF)) {
createTransCurveVerts(t);
}
- else if (t->obedit->type == OB_LATTICE) {
+ else if (t->obedit_type == OB_LATTICE) {
createTransLatticeVerts(t);
}
- else if (t->obedit->type == OB_MBALL) {
+ else if (t->obedit_type == OB_MBALL) {
createTransMBallVerts(t);
}
- else if (t->obedit->type == OB_GROOM) {
+ else if (t->obedit_type == OB_GROOM) {
createTransGroomVerts(t);
}
- else if (t->obedit->type == OB_ARMATURE) {
+ else if (t->obedit_type == OB_ARMATURE) {
t->flag &= ~T_PROP_EDIT;
createTransArmatureVerts(t);
}
@@ -8494,12 +8713,14 @@ void createTransData(bContext *C, TransInfo *t)
printf("edit type not implemented!\n");
}
+ countAndCleanTransDataContainer(t);
+
t->flag |= T_EDIT | T_POINTS;
- if (t->data && t->flag & T_PROP_EDIT) {
- if (ELEM(t->obedit->type, OB_CURVE, OB_MESH)) {
+ if (t->data_len_all && t->flag & T_PROP_EDIT) {
+ if (ELEM(t->obedit_type, OB_CURVE, OB_MESH)) {
sort_trans_data(t); // makes selected become first in array
- if ((t->obedit->type == OB_MESH) && (t->flag & T_PROP_CONNECTED)) {
+ if ((t->obedit_type == OB_MESH) && (t->flag & T_PROP_CONNECTED)) {
/* already calculated by editmesh_set_connectivity_distance */
}
else {
@@ -8518,13 +8739,21 @@ void createTransData(bContext *C, TransInfo *t)
if (t->mode == TFM_BONESIZE) {
t->flag &= ~(T_EDIT | T_POINTS);
t->flag |= T_POSE;
- t->poseobj = ob; /* <- tsk tsk, this is going to give issues one day */
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ tc->poseobj = tc->obedit;
+ tc->obedit = NULL;
+ }
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
// XXX this is currently limited to active armature only...
// XXX active-layer checking isn't done as that should probably be checked through context instead
- createTransPose(t, ob);
+
+ /* Multi object editing. */
+ initTransDataContainers_FromObjectData(t);
+ createTransPose(t, NULL, 0);
+ countAndCleanTransDataContainer(t);
}
else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) {
/* important that ob_armature can be set even when its not selected [#23412]
@@ -8534,7 +8763,11 @@ void createTransData(bContext *C, TransInfo *t)
Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
if (base_arm) {
if (BASE_VISIBLE(base_arm)) {
- createTransPose(t, ob_armature);
+ Object *objects[1];
+ objects[0] = ob_armature;
+ uint objects_len = 1;
+ createTransPose(t, objects, objects_len);
+ countAndCleanTransDataContainer(t);
}
}
@@ -8542,9 +8775,10 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, ob))) {
createTransParticleVerts(C, t);
+ countAndCleanTransDataContainer(t);
t->flag |= T_POINTS;
- if (t->data && t->flag & T_PROP_EDIT) {
+ if (t->data_len_all && t->flag & T_PROP_EDIT) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
@@ -8554,13 +8788,15 @@ void createTransData(bContext *C, TransInfo *t)
if ((t->options & CTX_PAINT_CURVE) && !ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN)) {
t->flag |= T_POINTS | T_2D_EDIT;
createTransPaintCurveVerts(C, t);
+ countAndCleanTransDataContainer(t);
}
}
else {
createTransObject(C, t);
+ countAndCleanTransDataContainer(t);
t->flag |= T_OBJECT;
- if (t->data && t->flag & T_PROP_EDIT) {
+ if (t->data_len_all && t->flag & T_PROP_EDIT) {
// selected objects are already first, no need to presort
set_prop_dist(t, 1);
sort_trans_data_dist(t);
@@ -8578,4 +8814,7 @@ void createTransData(bContext *C, TransInfo *t)
}
}
}
+
+ /* Check that 'countAndCleanTransDataContainer' ran. */
+ BLI_assert(t->data_len_all != -1);
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 32cd02c59e6..1b3feedd78d 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -82,6 +82,8 @@
#include "BKE_tracking.h"
#include "BKE_mask.h"
#include "BKE_workspace.h"
+#include "BKE_layer.h"
+#include "BKE_scene.h"
#include "DEG_depsgraph.h"
@@ -127,98 +129,101 @@ void getViewVector(TransInfo *t, float coord[3], float vec[3])
/* ************************** GENERICS **************************** */
-static void clipMirrorModifier(TransInfo *t, Object *ob)
+static void clipMirrorModifier(TransInfo *t)
{
- ModifierData *md = ob->modifiers.first;
- float tolerance[3] = {0.0f, 0.0f, 0.0f};
- int axis = 0;
-
- for (; md; md = md->next) {
- if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) {
- MirrorModifierData *mmd = (MirrorModifierData *) md;
-
- if (mmd->flag & MOD_MIR_CLIPPING) {
- axis = 0;
- if (mmd->flag & MOD_MIR_AXIS_X) {
- axis |= 1;
- tolerance[0] = mmd->tolerance;
- }
- if (mmd->flag & MOD_MIR_AXIS_Y) {
- axis |= 2;
- tolerance[1] = mmd->tolerance;
- }
- if (mmd->flag & MOD_MIR_AXIS_Z) {
- axis |= 4;
- tolerance[2] = mmd->tolerance;
- }
- if (axis) {
- float mtx[4][4], imtx[4][4];
- int i;
- TransData *td = t->data;
-
- if (mmd->mirror_ob) {
- float obinv[4][4];
-
- invert_m4_m4(obinv, mmd->mirror_ob->obmat);
- mul_m4_m4m4(mtx, obinv, ob->obmat);
- invert_m4_m4(imtx, mtx);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Object *ob = tc->obedit;
+ ModifierData *md = ob->modifiers.first;
+ float tolerance[3] = {0.0f, 0.0f, 0.0f};
+ int axis = 0;
+
+ for (; md; md = md->next) {
+ if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) {
+ MirrorModifierData *mmd = (MirrorModifierData *) md;
+
+ if (mmd->flag & MOD_MIR_CLIPPING) {
+ axis = 0;
+ if (mmd->flag & MOD_MIR_AXIS_X) {
+ axis |= 1;
+ tolerance[0] = mmd->tolerance;
}
-
- for (i = 0; i < t->total; i++, td++) {
- int clip;
- float loc[3], iloc[3];
-
- if (td->flag & TD_NOACTION)
- break;
- if (td->loc == NULL)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
-
- copy_v3_v3(loc, td->loc);
- copy_v3_v3(iloc, td->iloc);
-
+ if (mmd->flag & MOD_MIR_AXIS_Y) {
+ axis |= 2;
+ tolerance[1] = mmd->tolerance;
+ }
+ if (mmd->flag & MOD_MIR_AXIS_Z) {
+ axis |= 4;
+ tolerance[2] = mmd->tolerance;
+ }
+ if (axis) {
+ float mtx[4][4], imtx[4][4];
+ int i;
+
if (mmd->mirror_ob) {
- mul_m4_v3(mtx, loc);
- mul_m4_v3(mtx, iloc);
+ float obinv[4][4];
+
+ invert_m4_m4(obinv, mmd->mirror_ob->obmat);
+ mul_m4_m4m4(mtx, obinv, ob->obmat);
+ invert_m4_m4(imtx, mtx);
}
-
- clip = 0;
- if (axis & 1) {
- if (fabsf(iloc[0]) <= tolerance[0] ||
- loc[0] * iloc[0] < 0.0f)
- {
- loc[0] = 0.0f;
- clip = 1;
+
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ int clip;
+ float loc[3], iloc[3];
+
+ if (td->flag & TD_NOACTION)
+ break;
+ if (td->loc == NULL)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ copy_v3_v3(loc, td->loc);
+ copy_v3_v3(iloc, td->iloc);
+
+ if (mmd->mirror_ob) {
+ mul_m4_v3(mtx, loc);
+ mul_m4_v3(mtx, iloc);
}
- }
-
- if (axis & 2) {
- if (fabsf(iloc[1]) <= tolerance[1] ||
- loc[1] * iloc[1] < 0.0f)
- {
- loc[1] = 0.0f;
- clip = 1;
+
+ clip = 0;
+ if (axis & 1) {
+ if (fabsf(iloc[0]) <= tolerance[0] ||
+ loc[0] * iloc[0] < 0.0f)
+ {
+ loc[0] = 0.0f;
+ clip = 1;
+ }
}
- }
- if (axis & 4) {
- if (fabsf(iloc[2]) <= tolerance[2] ||
- loc[2] * iloc[2] < 0.0f)
- {
- loc[2] = 0.0f;
- clip = 1;
+
+ if (axis & 2) {
+ if (fabsf(iloc[1]) <= tolerance[1] ||
+ loc[1] * iloc[1] < 0.0f)
+ {
+ loc[1] = 0.0f;
+ clip = 1;
+ }
}
- }
- if (clip) {
- if (mmd->mirror_ob) {
- mul_m4_v3(imtx, loc);
+ if (axis & 4) {
+ if (fabsf(iloc[2]) <= tolerance[2] ||
+ loc[2] * iloc[2] < 0.0f)
+ {
+ loc[2] = 0.0f;
+ clip = 1;
+ }
+ }
+ if (clip) {
+ if (mmd->mirror_ob) {
+ mul_m4_v3(imtx, loc);
+ }
+ copy_v3_v3(td->loc, loc);
}
- copy_v3_v3(td->loc, loc);
}
}
+
}
-
}
}
}
@@ -227,27 +232,29 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
/* assumes obedit set to mesh object */
static void editbmesh_apply_to_mirror(TransInfo *t)
{
- TransData *td = t->data;
- BMVert *eve;
- int i;
-
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_NOACTION)
- break;
- if (td->loc == NULL)
- break;
- if (td->flag & TD_SKIP)
- continue;
-
- eve = td->extra;
- if (eve) {
- eve->co[0] = -td->loc[0];
- eve->co[1] = td->loc[1];
- eve->co[2] = td->loc[2];
- }
-
- if (td->flag & TD_MIRROR_EDGE) {
- td->loc[0] = 0;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ BMVert *eve;
+ int i;
+
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
+ if (td->loc == NULL)
+ break;
+ if (td->flag & TD_SKIP)
+ continue;
+
+ eve = td->extra;
+ if (eve) {
+ eve->co[0] = -td->loc[0];
+ eve->co[1] = td->loc[1];
+ eve->co[2] = td->loc[2];
+ }
+
+ if (td->flag & TD_MIRROR_EDGE) {
+ td->loc[0] = 0;
+ }
}
}
}
@@ -432,12 +439,14 @@ static void recalcData_nla(TransInfo *t)
Scene *scene = t->scene;
double secf = FPS;
int i;
-
+
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
/* for each strip we've got, perform some additional validation of the values that got set before
* using RNA to set the value (which does some special operations when setting these values to make
* sure that everything works ok)
*/
- for (i = 0; i < t->total; i++, tdn++) {
+ for (i = 0; i < tc->data_len; i++, tdn++) {
NlaStrip *strip = tdn->strip;
PointerRNA strip_ptr;
short pExceeded, nExceeded, iter;
@@ -654,14 +663,18 @@ static void recalcData_image(TransInfo *t)
else if (t->options & CTX_PAINT_CURVE) {
flushTransPaintCurve(t);
}
- else if (t->obedit && t->obedit->type == OB_MESH) {
+ else if ((t->flag & T_EDIT) && t->obedit_type == OB_MESH) {
SpaceImage *sima = t->sa->spacedata.first;
flushTransUVs(t);
if (sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_re_solve();
-
- DEG_id_tag_update(t->obedit->data, 0);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ if (tc->data_len) {
+ DEG_id_tag_update(tc->obedit->data, 0);
+ }
+ }
}
}
@@ -716,57 +729,64 @@ static void recalcData_objects(TransInfo *t)
{
Base *base = t->view_layer->basact;
- if (t->obedit) {
- if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) {
- Curve *cu = t->obedit->data;
- ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- Nurb *nu = nurbs->first;
-
+ if (t->obedit_type != -1) {
+ if (ELEM(t->obedit_type, OB_CURVE, OB_SURF)) {
+
if (t->state != TRANS_CANCEL) {
- clipMirrorModifier(t, t->obedit);
+ clipMirrorModifier(t);
applyProject(t);
}
-
- DEG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */
-
- if (t->state == TRANS_CANCEL) {
- while (nu) {
- BKE_nurb_handles_calc(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
- nu = nu->next;
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Curve *cu = tc->obedit->data;
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
+ Nurb *nu = nurbs->first;
+
+ DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */
+
+ if (t->state == TRANS_CANCEL) {
+ while (nu) {
+ BKE_nurb_handles_calc(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
+ nu = nu->next;
+ }
}
- }
- else {
- /* Normal updating */
- while (nu) {
- BKE_nurb_test2D(nu);
- BKE_nurb_handles_calc(nu);
- nu = nu->next;
+ else {
+ /* Normal updating */
+ while (nu) {
+ BKE_nurb_test2D(nu);
+ BKE_nurb_handles_calc(nu);
+ nu = nu->next;
+ }
}
}
}
- else if (t->obedit->type == OB_LATTICE) {
- Lattice *la = t->obedit->data;
-
+ else if (t->obedit_type == OB_LATTICE) {
+
if (t->state != TRANS_CANCEL) {
applyProject(t);
}
-
- DEG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */
-
- if (la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Lattice *la = tc->obedit->data;
+ DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */
+ if (la->editlatt->latt->flag & LT_OUTSIDE) {
+ outside_lattice(la->editlatt->latt);
+ }
+ }
}
- else if (t->obedit->type == OB_GROOM) {
+ else if (t->obedit_type == OB_GROOM) {
flushTransGroom(t);
-
- DEG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */
+ }
}
- else if (t->obedit->type == OB_MESH) {
- BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
+ else if (t->obedit_type == OB_MESH) {
/* mirror modifier clipping? */
if (t->state != TRANS_CANCEL) {
/* apply clipping after so we never project past the clip plane [#25423] */
applyProject(t);
- clipMirrorModifier(t, t->obedit);
+ clipMirrorModifier(t);
}
if ((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR))
editbmesh_apply_to_mirror(t);
@@ -778,133 +798,148 @@ static void recalcData_objects(TransInfo *t)
projectVertSlideData(t, false);
}
- DEG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */
-
- EDBM_mesh_normals_update(em);
- BKE_editmesh_tessface_calc(em);
- }
- else if (t->obedit->type == OB_ARMATURE) { /* no recalc flag, does pose */
- bArmature *arm = t->obedit->data;
- ListBase *edbo = arm->edbo;
- EditBone *ebo, *ebo_parent;
- TransData *td = t->data;
- int i;
-
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */
+ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
+ EDBM_mesh_normals_update(em);
+ BKE_editmesh_tessface_calc(em);
+ }
+ }
+ else if (t->obedit_type == OB_ARMATURE) { /* no recalc flag, does pose */
+
if (t->state != TRANS_CANCEL) {
applyProject(t);
}
-
- /* Ensure all bones are correctly adjusted */
- for (ebo = edbo->first; ebo; ebo = ebo->next) {
- ebo_parent = (ebo->flag & BONE_CONNECTED) ? ebo->parent : NULL;
-
- if (ebo_parent) {
- /* If this bone has a parent tip that has been moved */
- if (ebo_parent->flag & BONE_TIPSEL) {
- copy_v3_v3(ebo->head, ebo_parent->tail);
- if (t->mode == TFM_BONE_ENVELOPE) ebo->rad_head = ebo_parent->rad_tail;
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ bArmature *arm = tc->obedit->data;
+ ListBase *edbo = arm->edbo;
+ EditBone *ebo, *ebo_parent;
+ TransData *td = tc->data;
+ int i;
+
+ /* Ensure all bones are correctly adjusted */
+ for (ebo = edbo->first; ebo; ebo = ebo->next) {
+ ebo_parent = (ebo->flag & BONE_CONNECTED) ? ebo->parent : NULL;
+
+ if (ebo_parent) {
+ /* If this bone has a parent tip that has been moved */
+ if (ebo_parent->flag & BONE_TIPSEL) {
+ copy_v3_v3(ebo->head, ebo_parent->tail);
+ if (t->mode == TFM_BONE_ENVELOPE) ebo->rad_head = ebo_parent->rad_tail;
+ }
+ /* If this bone has a parent tip that has NOT been moved */
+ else {
+ copy_v3_v3(ebo_parent->tail, ebo->head);
+ if (t->mode == TFM_BONE_ENVELOPE) ebo_parent->rad_tail = ebo->rad_head;
+ }
}
- /* If this bone has a parent tip that has NOT been moved */
- else {
- copy_v3_v3(ebo_parent->tail, ebo->head);
- if (t->mode == TFM_BONE_ENVELOPE) ebo_parent->rad_tail = ebo->rad_head;
+
+ /* on extrude bones, oldlength==0.0f, so we scale radius of points */
+ ebo->length = len_v3v3(ebo->head, ebo->tail);
+ if (ebo->oldlength == 0.0f) {
+ ebo->rad_head = 0.25f * ebo->length;
+ ebo->rad_tail = 0.10f * ebo->length;
+ ebo->dist = 0.25f * ebo->length;
+ if (ebo->parent) {
+ if (ebo->rad_head > ebo->parent->rad_tail)
+ ebo->rad_head = ebo->parent->rad_tail;
+ }
}
- }
-
- /* on extrude bones, oldlength==0.0f, so we scale radius of points */
- ebo->length = len_v3v3(ebo->head, ebo->tail);
- if (ebo->oldlength == 0.0f) {
- ebo->rad_head = 0.25f * ebo->length;
- ebo->rad_tail = 0.10f * ebo->length;
- ebo->dist = 0.25f * ebo->length;
- if (ebo->parent) {
- if (ebo->rad_head > ebo->parent->rad_tail)
- ebo->rad_head = ebo->parent->rad_tail;
+ else if (t->mode != TFM_BONE_ENVELOPE) {
+ /* if bones change length, lets do that for the deform distance as well */
+ ebo->dist *= ebo->length / ebo->oldlength;
+ ebo->rad_head *= ebo->length / ebo->oldlength;
+ ebo->rad_tail *= ebo->length / ebo->oldlength;
+ ebo->oldlength = ebo->length;
+
+ if (ebo_parent) {
+ ebo_parent->rad_tail = ebo->rad_head;
+ }
}
}
- else if (t->mode != TFM_BONE_ENVELOPE) {
- /* if bones change length, lets do that for the deform distance as well */
- ebo->dist *= ebo->length / ebo->oldlength;
- ebo->rad_head *= ebo->length / ebo->oldlength;
- ebo->rad_tail *= ebo->length / ebo->oldlength;
- ebo->oldlength = ebo->length;
- if (ebo_parent) {
- ebo_parent->rad_tail = ebo->rad_head;
- }
- }
- }
-
- if (!ELEM(t->mode, TFM_BONE_ROLL, TFM_BONE_ENVELOPE, TFM_BONE_ENVELOPE_DIST, TFM_BONESIZE)) {
- /* fix roll */
- for (i = 0; i < t->total; i++, td++) {
- if (td->extra) {
- float vec[3], up_axis[3];
- float qrot[4];
- float roll;
-
- ebo = td->extra;
+ if (!ELEM(t->mode, TFM_BONE_ROLL, TFM_BONE_ENVELOPE, TFM_BONE_ENVELOPE_DIST, TFM_BONESIZE)) {
+ /* fix roll */
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->extra) {
+ float vec[3], up_axis[3];
+ float qrot[4];
+ float roll;
- if (t->state == TRANS_CANCEL) {
- /* restore roll */
- ebo->roll = td->ival;
- }
- else {
- copy_v3_v3(up_axis, td->axismtx[2]);
+ ebo = td->extra;
+
+ if (t->state == TRANS_CANCEL) {
+ /* restore roll */
+ ebo->roll = td->ival;
+ }
+ else {
+ copy_v3_v3(up_axis, td->axismtx[2]);
- sub_v3_v3v3(vec, ebo->tail, ebo->head);
- normalize_v3(vec);
- rotation_between_vecs_to_quat(qrot, td->axismtx[1], vec);
- mul_qt_v3(qrot, up_axis);
+ sub_v3_v3v3(vec, ebo->tail, ebo->head);
+ normalize_v3(vec);
+ rotation_between_vecs_to_quat(qrot, td->axismtx[1], vec);
+ mul_qt_v3(qrot, up_axis);
- /* roll has a tendency to flip in certain orientations - [#34283], [#33974] */
- roll = ED_rollBoneToVector(ebo, up_axis, false);
- ebo->roll = angle_compat_rad(roll, td->ival);
+ /* roll has a tendency to flip in certain orientations - [#34283], [#33974] */
+ roll = ED_armature_ebone_roll_to_vector(ebo, up_axis, false);
+ ebo->roll = angle_compat_rad(roll, td->ival);
+ }
}
}
}
- }
-
- if (arm->flag & ARM_MIRROR_EDIT) {
- if (t->state != TRANS_CANCEL)
- transform_armature_mirror_update(t->obedit);
- else
- restoreBones(t);
+
+ if (arm->flag & ARM_MIRROR_EDIT) {
+ if (t->state != TRANS_CANCEL) {
+ ED_armature_edit_transform_mirror_update(tc->obedit);
+ }
+ else {
+ restoreBones(tc);
+ }
+ }
}
}
else {
if (t->state != TRANS_CANCEL) {
applyProject(t);
}
- DEG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ if (tc->data_len) {
+ DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */
+ }
+ }
}
+
}
- else if ((t->flag & T_POSE) && t->poseobj) {
- Object *ob = t->poseobj;
- bArmature *arm = ob->data;
-
- /* if animtimer is running, and the object already has animation data,
- * check if the auto-record feature means that we should record 'samples'
- * (i.e. uneditable animation values)
- *
- * context is needed for keying set poll() functions.
- */
- // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
- if ((t->animtimer) && (t->context) && IS_AUTOKEY_ON(t->scene)) {
- int targetless_ik = (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
-
- animrecord_check_state(t->scene, &ob->id, t->animtimer);
- autokeyframe_pose_cb_func(t->context, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
- }
-
- /* old optimize trick... this enforces to bypass the depgraph */
- if (!(arm->flag & ARM_DELAYDEFORM)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
- /* transformation of pose may affect IK tree, make sure it is rebuilt */
- BIK_clear_data(ob->pose);
+ else if (t->flag & T_POSE) {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Object *ob = tc->poseobj;
+ bArmature *arm = ob->data;
+
+ /* if animtimer is running, and the object already has animation data,
+ * check if the auto-record feature means that we should record 'samples'
+ * (i.e. uneditable animation values)
+ *
+ * context is needed for keying set poll() functions.
+ */
+ // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
+ if ((t->animtimer) && (t->context) && IS_AUTOKEY_ON(t->scene)) {
+ int targetless_ik = (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
+
+ animrecord_check_state(t->scene, &ob->id, t->animtimer);
+ autokeyframe_pose_cb_func(t->context, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
+ }
+
+ /* old optimize trick... this enforces to bypass the depgraph */
+ if (!(arm->flag & ARM_DELAYDEFORM)) {
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
+ /* transformation of pose may affect IK tree, make sure it is rebuilt */
+ BIK_clear_data(ob->pose);
+ }
+ else {
+ BKE_pose_where_is(t->depsgraph, t->scene, ob);
+ }
}
- else
- BKE_pose_where_is(&t->eval_ctx, t->scene, ob);
}
else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) &&
PE_get_current(t->scene, base->object))
@@ -920,34 +955,37 @@ static void recalcData_objects(TransInfo *t)
if (t->state != TRANS_CANCEL) {
applyProject(t);
}
-
- for (i = 0; i < t->total; i++) {
- TransData *td = t->data + i;
- Object *ob = td->ob;
-
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
-
- /* if animtimer is running, and the object already has animation data,
- * check if the auto-record feature means that we should record 'samples'
- * (i.e. uneditable animation values)
- */
- // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
- if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
- animrecord_check_state(t->scene, &ob->id, t->animtimer);
- autokeyframe_ob_cb_func(t->context, t->scene, t->view_layer, (View3D *)t->view, ob, t->mode);
- }
-
- /* sets recalc flags fully, instead of flushing existing ones
- * otherwise proxies don't function correctly
- */
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
- if (t->flag & T_TEXTURE)
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+
+ for (i = 0; i < tc->data_len; i++, td++) {
+ Object *ob = td->ob;
+
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ /* if animtimer is running, and the object already has animation data,
+ * check if the auto-record feature means that we should record 'samples'
+ * (i.e. uneditable animation values)
+ */
+ // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
+ if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
+ animrecord_check_state(t->scene, &ob->id, t->animtimer);
+ autokeyframe_ob_cb_func(t->context, t->scene, t->view_layer, (View3D *)t->view, ob, t->mode);
+ }
+
+ /* sets recalc flags fully, instead of flushing existing ones
+ * otherwise proxies don't function correctly
+ */
+ DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+
+ if (t->flag & T_TEXTURE)
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
}
}
}
@@ -959,7 +997,9 @@ static void recalcData_sequencer(TransInfo *t)
int a;
Sequence *seq_prev = NULL;
- for (a = 0, td = t->data; a < t->total; a++, td++) {
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
+ for (a = 0, td = tc->data; a < tc->data_len; a++, td++) {
TransDataSeq *tdsq = (TransDataSeq *) td->extra;
Sequence *seq = tdsq->seq;
@@ -984,8 +1024,10 @@ static void recalcData_sequencer(TransInfo *t)
/* force recalculation of triangles during transformation */
static void recalcData_gpencil_strokes(TransInfo *t)
{
- TransData *td = t->data;
- for (int i = 0; i < t->total; i++, td++) {
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
+ TransData *td = tc->data;
+ for (int i = 0; i < tc->data_len; i++, td++) {
bGPDstroke *gps = td->extra;
if (gps != NULL) {
gps->flag |= GP_STROKE_RECALC_CACHES;
@@ -1083,11 +1125,17 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis
*/
void resetTransModal(TransInfo *t)
{
- if (t->mode == TFM_EDGE_SLIDE) {
- freeEdgeSlideVerts(t, &t->custom.mode);
- }
- else if (t->mode == TFM_VERT_SLIDE) {
- freeVertSlideVerts(t, &t->custom.mode);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ if (t->mode == TFM_EDGE_SLIDE) {
+ freeEdgeSlideVerts(t, tc, &tc->custom.mode);
+ }
+ else if (t->mode == TFM_VERT_SLIDE) {
+ freeVertSlideVerts(t, tc, &tc->custom.mode);
+ }
+ else {
+ /* no need to keep looping... */
+ break;
+ }
}
}
@@ -1110,6 +1158,40 @@ static int initTransInfo_edit_pet_to_flag(const int proportional)
}
}
+void initTransDataContainers_FromObjectData(TransInfo *t)
+{
+ const eObjectMode object_mode = OBACT(t->view_layer) ? OBACT(t->view_layer)->mode : OB_MODE_OBJECT;
+ const short object_type = OBACT(t->view_layer) ? OBACT(t->view_layer)->type : -1;
+
+ if ((object_mode & OB_MODE_EDIT) ||
+ ((object_mode & OB_MODE_POSE) && (object_type == OB_ARMATURE)))
+ {
+ if (t->data_container) {
+ MEM_freeN(t->data_container);
+ }
+ uint objects_len;
+ Object **objects = BKE_view_layer_array_from_objects_in_mode(
+ t->view_layer, &objects_len, {
+ .object_mode = object_mode,
+ .no_dup_data = true});
+ t->data_container = MEM_callocN(sizeof(*t->data_container) * objects_len, __func__);
+ t->data_container_len = objects_len;
+
+ for (int i = 0; i < objects_len; i++) {
+ TransDataContainer *tc = &t->data_container[i];
+ if (object_mode & OB_MODE_EDIT) {
+ tc->obedit = objects[i];
+ copy_m3_m4(tc->obedit_mat, tc->obedit->obmat);
+ normalize_m3(tc->obedit_mat);
+ }
+ else if (object_mode & OB_MODE_POSE) {
+ tc->poseobj = objects[i];
+ }
+ }
+ MEM_freeN(objects);
+ }
+}
+
/**
* Setup internal data, mouse, vectors
*
@@ -1119,41 +1201,38 @@ static int initTransInfo_edit_pet_to_flag(const int proportional)
*/
void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
{
- CTX_data_eval_ctx(C, &t->eval_ctx);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *sce = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ const eObjectMode object_mode = OBACT(view_layer) ? OBACT(view_layer)->mode : OB_MODE_OBJECT;
+ const short object_type = OBACT(view_layer) ? OBACT(view_layer)->type : -1;
ToolSettings *ts = CTX_data_tool_settings(C);
ARegion *ar = CTX_wm_region(C);
ScrArea *sa = CTX_wm_area(C);
- Object *obedit = CTX_data_edit_object(C);
- Object *ob = CTX_data_active_object(C);
+
bGPdata *gpd = CTX_data_gpencil_data(C);
- RenderEngineType *engine_type = CTX_data_engine_type(C);
PropertyRNA *prop;
t->depsgraph = depsgraph;
t->scene = sce;
t->view_layer = view_layer;
- t->engine_type = engine_type;
t->sa = sa;
t->ar = ar;
- t->obedit = obedit;
t->settings = ts;
t->reports = op ? op->reports : NULL;
- if (obedit) {
- copy_m3_m4(t->obedit_mat, obedit->obmat);
- normalize_m3(t->obedit_mat);
- }
-
- t->data = NULL;
- t->ext = NULL;
-
t->helpline = HLP_NONE;
t->flag = 0;
-
+
+ t->obedit_type = (object_mode == OB_MODE_EDIT) ? object_type : -1;
+
+ /* Many kinds of transform only use a single handle. */
+ if (t->data_container == NULL) {
+ t->data_container = MEM_callocN(sizeof(*t->data_container), __func__);
+ t->data_container_len = 1;
+ }
+
t->redraw = TREDRAW_HARD; /* redraw first time */
if (event) {
@@ -1174,12 +1253,11 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->transform = NULL;
t->handleEvent = NULL;
- t->total = 0;
+ t->data_len_all = 0;
t->val = 0.0f;
zero_v3(t->vec);
- zero_v3(t->center);
zero_v3(t->center_global);
unit_m3(t->mat);
@@ -1244,8 +1322,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* turn manipulator off during transform */
if (t->flag & T_MODAL) {
- t->twtype = v3d->twtype;
- v3d->twtype = 0;
+ t->twflag = v3d->twflag;
+ v3d->twflag = 0;
}
if (v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;
@@ -1256,22 +1334,22 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->around = V3D_AROUND_CURSOR;
}
- t->current_orientation = v3d->twmode;
- t->custom_orientation = BKE_workspace_transform_orientation_find(
- CTX_wm_workspace(C), v3d->custom_orientation_index);
+ t->current_orientation = t->scene->orientation_type;
+ t->custom_orientation = BKE_scene_transform_orientation_find(
+ t->scene, t->scene->orientation_index_custom);
/* exceptional case */
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) {
const bool use_island = transdata_check_local_islands(t, t->around);
- if (obedit && !use_island) {
+ if ((t->obedit_type != -1) && !use_island) {
t->options |= CTX_NO_PET;
}
}
}
- if (ob && ob->mode & OB_MODE_ALL_PAINT) {
+ if (object_mode & OB_MODE_ALL_PAINT) {
Paint *p = BKE_paint_get_active_from_context(C);
if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) {
t->options |= CTX_PAINT_CURVE;
@@ -1300,7 +1378,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->view = &ar->v2d;
t->around = sima->around;
- if (ED_space_image_show_uvedit(sima, t->obedit)) {
+ if (ED_space_image_show_uvedit(sima, OBACT(t->view_layer))) {
/* UV transform */
}
else if (sima->mode == SI_MODE_MASK) {
@@ -1357,8 +1435,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
orientation = V3D_MANIP_GLOBAL;
}
else {
- custom_orientation = BKE_workspace_transform_orientation_find(
- CTX_wm_workspace(C), orientation - V3D_MANIP_CUSTOM);
+ custom_orientation = BKE_scene_transform_orientation_find(
+ t->scene, orientation - V3D_MANIP_CUSTOM);
orientation = V3D_MANIP_CUSTOM;
}
}
@@ -1390,7 +1468,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
// Need stuff to take it from edit mesh or whatnot here
else if (t->spacetype == SPACE_VIEW3D) {
- if (t->obedit && t->obedit->type == OB_MESH && (((Mesh *)t->obedit->data)->editflag & ME_EDIT_MIRROR_X)) {
+ /* TODO(campbell): xform, get mirror from each object. */
+ if (t->obedit_type == OB_MESH && (((Mesh *)OBACT(t->view_layer)->data)->editflag & ME_EDIT_MIRROR_X)) {
t->flag |= T_MIRROR;
t->mirror = 1;
}
@@ -1411,7 +1490,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
else if (t->spacetype == SPACE_ACTION) {
t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_action);
}
- else if (t->obedit) {
+ else if (t->obedit_type != -1) {
t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional);
}
else if (t->options & CTX_GPENCIL_STROKES) {
@@ -1426,7 +1505,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
}
- else if (t->obedit == NULL && ts->proportional_objects) {
+ else if ((t->obedit_type == -1) && ts->proportional_objects) {
t->flag |= T_PROP_EDIT;
}
}
@@ -1472,8 +1551,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
setTransformViewAspect(t, t->aspect);
if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && RNA_property_is_set(op->ptr, prop)) {
- RNA_property_float_get_array(op->ptr, prop, t->center);
- mul_v3_v3(t->center, t->aspect);
+ RNA_property_float_get_array(op->ptr, prop, t->center_global);
+ mul_v3_v3(t->center_global, t->aspect);
t->flag |= T_OVERRIDE_CENTER;
}
@@ -1481,11 +1560,25 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
initNumInput(&t->num);
}
+static void freeTransCustomDataContainer(TransInfo *t, TransDataContainer *tc, TransCustomDataContainer *tcdc)
+{
+ TransCustomData *custom_data = &tcdc->first_elem;
+ for (int i = 0; i < TRANS_CUSTOM_DATA_ELEM_MAX; i++, custom_data++) {
+ if (custom_data->free_cb) {
+ /* Can take over freeing t->data and data_2d etc... */
+ custom_data->free_cb(t, tc, custom_data);
+ BLI_assert(custom_data->data == NULL);
+ }
+ else if ((custom_data->data != NULL) && custom_data->use_free) {
+ MEM_freeN(custom_data->data);
+ custom_data->data = NULL;
+ }
+ }
+}
+
/* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */
void postTrans(bContext *C, TransInfo *t)
{
- TransData *td;
-
if (t->draw_handle_view)
ED_region_draw_cb_exit(t->ar->type, t->draw_handle_view);
if (t->draw_handle_apply)
@@ -1496,46 +1589,37 @@ void postTrans(bContext *C, TransInfo *t)
WM_paint_cursor_end(CTX_wm_manager(C), t->draw_handle_cursor);
/* Free all custom-data */
- {
- TransCustomData *custom_data = &t->custom.first_elem;
- for (int i = 0; i < TRANS_CUSTOM_DATA_ELEM_MAX; i++, custom_data++) {
- if (custom_data->free_cb) {
- /* Can take over freeing t->data and data2d etc... */
- custom_data->free_cb(t, custom_data);
- BLI_assert(custom_data->data == NULL);
- }
- else if ((custom_data->data != NULL) && custom_data->use_free) {
- MEM_freeN(custom_data->data);
- custom_data->data = NULL;
- }
- }
+ freeTransCustomDataContainer(t, NULL, &t->custom);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ freeTransCustomDataContainer(t, tc, &tc->custom);
}
/* postTrans can be called when nothing is selected, so data is NULL already */
- if (t->data) {
-
- /* free data malloced per trans-data */
- if ((t->obedit && ELEM(t->obedit->type, OB_CURVE, OB_SURF)) ||
- (t->spacetype == SPACE_IPO))
- {
- int a;
- for (a = 0, td = t->data; a < t->total; a++, td++) {
- if (td->flag & TD_BEZTRIPLE) {
- MEM_freeN(td->hdata);
+ if (t->data_len_all != 0) {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ /* free data malloced per trans-data */
+ if (ELEM(t->obedit_type, OB_CURVE, OB_SURF) ||
+ (t->spacetype == SPACE_IPO))
+ {
+ TransData *td = tc->data;
+ for (int a = 0; a < tc->data_len; a++, td++) {
+ if (td->flag & TD_BEZTRIPLE) {
+ MEM_freeN(td->hdata);
+ }
}
}
+ MEM_freeN(tc->data);
+
+ MEM_SAFE_FREE(tc->data_ext);
+ MEM_SAFE_FREE(tc->data_2d);
}
- MEM_freeN(t->data);
}
+ MEM_SAFE_FREE(t->data_container);
+ t->data_container = NULL;
+
BLI_freelistN(&t->tsnap.points);
- if (t->ext) MEM_freeN(t->ext);
- if (t->data2d) {
- MEM_freeN(t->data2d);
- t->data2d = NULL;
- }
-
if (t->spacetype == SPACE_IMAGE) {
if (t->options & (CTX_MASK | CTX_PAINT_CURVE)) {
/* pass */
@@ -1550,7 +1634,7 @@ void postTrans(bContext *C, TransInfo *t)
View3D *v3d = t->sa->spacedata.first;
/* restore manipulator */
if (t->flag & T_MODAL) {
- v3d->twtype = t->twtype;
+ v3d->twflag = t->twflag;
}
}
@@ -1563,9 +1647,11 @@ void postTrans(bContext *C, TransInfo *t)
void applyTransObjects(TransInfo *t)
{
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+
TransData *td;
-
- for (td = t->data; td < t->data + t->total; td++) {
+
+ for (td = tc->data; td < tc->data + tc->data_len; td++) {
copy_v3_v3(td->iloc, td->loc);
if (td->ext->rot) {
copy_v3_v3(td->ext->irot, td->ext->rot);
@@ -1614,25 +1700,29 @@ static void restoreElement(TransData *td)
void restoreTransObjects(TransInfo *t)
{
- TransData *td;
- TransData2D *td2d;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- for (td = t->data; td < t->data + t->total; td++) {
- restoreElement(td);
- }
-
- for (td2d = t->data2d; t->data2d && td2d < t->data2d + t->total; td2d++) {
- if (td2d->h1) {
- td2d->h1[0] = td2d->ih1[0];
- td2d->h1[1] = td2d->ih1[1];
+ TransData *td;
+ TransData2D *td2d;
+
+ for (td = tc->data; td < tc->data + tc->data_len; td++) {
+ restoreElement(td);
}
- if (td2d->h2) {
- td2d->h2[0] = td2d->ih2[0];
- td2d->h2[1] = td2d->ih2[1];
+
+ for (td2d = tc->data_2d; tc->data_2d && td2d < tc->data_2d + tc->data_len; td2d++) {
+ if (td2d->h1) {
+ td2d->h1[0] = td2d->ih1[0];
+ td2d->h1[1] = td2d->ih1[1];
+ }
+ if (td2d->h2) {
+ td2d->h2[0] = td2d->ih2[0];
+ td2d->h2[1] = td2d->ih2[1];
+ }
}
- }
- unit_m3(t->mat);
+ unit_m3(t->mat);
+
+ }
recalcData(t);
}
@@ -1640,32 +1730,26 @@ void restoreTransObjects(TransInfo *t)
void calculateCenter2D(TransInfo *t)
{
BLI_assert(!is_zero_v3(t->aspect));
-
- if (t->flag & (T_EDIT | T_POSE)) {
- Object *ob = t->obedit ? t->obedit : t->poseobj;
- float vec[3];
-
- copy_v3_v3(vec, t->center);
- mul_m4_v3(ob->obmat, vec);
- projectFloatView(t, vec, t->center2d);
- }
- else {
- projectFloatView(t, t->center, t->center2d);
- }
+ projectFloatView(t, t->center_global, t->center2d);
}
-void calculateCenterGlobal(
- TransInfo *t, const float center_local[3],
- float r_center_global[3])
+void calculateCenterLocal(
+ TransInfo *t, const float center_global[3])
{
/* setting constraint center */
/* note, init functions may over-ride t->center */
if (t->flag & (T_EDIT | T_POSE)) {
- Object *ob = t->obedit ? t->obedit : t->poseobj;
- mul_v3_m4v3(r_center_global, ob->obmat, center_local);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ float obinv[4][4];
+ Object *ob = tc->obedit ? tc->obedit : tc->poseobj;
+ invert_m4_m4(obinv, ob->obmat);
+ mul_v3_m4v3(tc->center_local, obinv, center_global);
+ }
}
else {
- copy_v3_v3(r_center_global, center_local);
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ copy_v3_v3(tc->center_local, center_global);
+ }
}
}
@@ -1677,16 +1761,7 @@ void calculateCenterCursor(TransInfo *t, float r_center[3])
copy_v3_v3(r_center, cursor);
/* If edit or pose mode, move cursor in local space */
- if (t->flag & (T_EDIT | T_POSE)) {
- Object *ob = t->obedit ? t->obedit : t->poseobj;
- float mat[3][3], imat[3][3];
-
- sub_v3_v3v3(r_center, r_center, ob->obmat[3]);
- copy_m3_m4(mat, ob->obmat);
- invert_m3_m3(imat, mat);
- mul_m3_v3(imat, r_center);
- }
- else if (t->options & CTX_PAINT_CURVE) {
+ if (t->options & CTX_PAINT_CURVE) {
if (ED_view3d_project_float_global(t->ar, cursor, r_center, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
r_center[0] = t->ar->winx / 2.0f;
r_center[1] = t->ar->winy / 2.0f;
@@ -1760,13 +1835,23 @@ void calculateCenterMedian(TransInfo *t, float r_center[3])
{
float partial[3] = {0.0f, 0.0f, 0.0f};
int total = 0;
- int i;
-
- for (i = 0; i < t->total; i++) {
- if (t->data[i].flag & TD_SELECTED) {
- if (!(t->data[i].flag & TD_NOCENTER)) {
- add_v3_v3(partial, t->data[i].center);
- total++;
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Object *ob_xform = tc->obedit ? tc->obedit : tc->poseobj;
+ int i;
+ for (i = 0; i < tc->data_len; i++) {
+ if (tc->data[i].flag & TD_SELECTED) {
+ if (!(tc->data[i].flag & TD_NOCENTER)) {
+ if (ob_xform) {
+ float v[3];
+ mul_v3_m4v3(v, ob_xform->obmat, tc->data[i].center);
+ add_v3_v3(partial, v);
+ }
+ else {
+ add_v3_v3(partial, tc->data[i].center);
+ }
+ total++;
+ }
}
}
}
@@ -1781,16 +1866,29 @@ void calculateCenterBound(TransInfo *t, float r_center[3])
float max[3];
float min[3];
int i;
- for (i = 0; i < t->total; i++) {
- if (i) {
- if (t->data[i].flag & TD_SELECTED) {
- if (!(t->data[i].flag & TD_NOCENTER))
- minmax_v3v3_v3(min, max, t->data[i].center);
+ bool is_first = true;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Object *ob_xform = tc->obedit ? tc->obedit : tc->poseobj;
+ for (i = 0; i < tc->data_len; i++) {
+ if (is_first == false) {
+ if (tc->data[i].flag & TD_SELECTED) {
+ if (!(tc->data[i].flag & TD_NOCENTER)) {
+ if (ob_xform) {
+ float v[3];
+ mul_v3_m4v3(v, ob_xform->obmat, tc->data[i].center);
+ minmax_v3v3_v3(min, max, v);
+ }
+ else {
+ minmax_v3v3_v3(min, max, tc->data[i].center);
+ }
+ }
+ }
+ is_first = false;
+ }
+ else {
+ copy_v3_v3(max, tc->data[i].center);
+ copy_v3_v3(min, tc->data[i].center);
}
- }
- else {
- copy_v3_v3(max, t->data[i].center);
- copy_v3_v3(min, t->data[i].center);
}
}
mid_v3_v3v3(r_center, min, max);
@@ -1801,10 +1899,13 @@ void calculateCenterBound(TransInfo *t, float r_center[3])
*/
bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
{
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t);
+
bool ok = false;
- if (t->obedit) {
- if (ED_object_editmode_calc_active_center(t->obedit, select_only, r_center)) {
+ if (tc->obedit) {
+ if (ED_object_editmode_calc_active_center(tc->obedit, select_only, r_center)) {
+ mul_m4_v3(tc->obedit->obmat, r_center);
ok = true;
}
}
@@ -1815,6 +1916,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
bPoseChannel *pchan = BKE_pose_channel_active(ob);
if (pchan && (!select_only || (pchan->bone->flag & BONE_SELECTED))) {
copy_v3_v3(r_center, pchan->pose_head);
+ mul_m4_v3(tc->obedit->obmat, r_center);
ok = true;
}
}
@@ -1879,14 +1981,13 @@ static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[
void calculateCenter(TransInfo *t)
{
if ((t->flag & T_OVERRIDE_CENTER) == 0) {
- calculateCenter_FromAround(t, t->around, t->center);
+ calculateCenter_FromAround(t, t->around, t->center_global);
}
- calculateCenterGlobal(t, t->center, t->center_global);
+ calculateCenterLocal(t, t->center_global);
/* avoid calculating again */
{
TransCenterData *cd = &t->center_cache[t->around];
- copy_v3_v3(cd->local, t->center);
copy_v3_v3(cd->global, t->center_global);
cd->is_set = true;
}
@@ -1904,16 +2005,15 @@ void calculateCenter(TransInfo *t)
normalize_v3(axis);
/* 6.0 = 6 grid units */
- axis[0] = t->center[0] - 6.0f * axis[0];
- axis[1] = t->center[1] - 6.0f * axis[1];
- axis[2] = t->center[2] - 6.0f * axis[2];
+ axis[0] = t->center_global[0] - 6.0f * axis[0];
+ axis[1] = t->center_global[1] - 6.0f * axis[1];
+ axis[2] = t->center_global[2] - 6.0f * axis[2];
projectFloatView(t, axis, t->center2d);
/* rotate only needs correct 2d center, grab needs ED_view3d_calc_zfac() value */
if (t->mode == TFM_TRANSLATION) {
- copy_v3_v3(t->center, axis);
- copy_v3_v3(t->center_global, t->center);
+ copy_v3_v3(t->center_global, axis);
}
}
}
@@ -1947,8 +2047,7 @@ const TransCenterData *transformCenter_from_type(TransInfo *t, int around)
BLI_assert(around <= V3D_AROUND_ACTIVE);
TransCenterData *cd = &t->center_cache[around];
if (cd->is_set == false) {
- calculateCenter_FromAround(t, around, cd->local);
- calculateCenterGlobal(t, cd->local, cd->global);
+ calculateCenter_FromAround(t, around, cd->global);
cd->is_set = true;
}
return cd;
@@ -1956,7 +2055,6 @@ const TransCenterData *transformCenter_from_type(TransInfo *t, int around)
void calculatePropRatio(TransInfo *t)
{
- TransData *td = t->data;
int i;
float dist;
const bool connected = (t->flag & T_PROP_CONNECTED) != 0;
@@ -1965,75 +2063,79 @@ void calculatePropRatio(TransInfo *t)
if (t->flag & T_PROP_EDIT) {
const char *pet_id = NULL;
- for (i = 0; i < t->total; i++, td++) {
- if (td->flag & TD_SELECTED) {
- td->factor = 1.0f;
- }
- else if (t->flag & T_MIRROR && td->loc[0] * t->mirror < -0.00001f) {
- td->flag |= TD_SKIP;
- td->factor = 0.0f;
- restoreElement(td);
- }
- else if ((connected && (td->flag & TD_NOTCONNECTED || td->dist > t->prop_size)) ||
- (connected == 0 && td->rdist > t->prop_size))
- {
- /*
- * The elements are sorted according to their dist member in the array,
- * that means we can stop when it finds one element outside of the propsize.
- * do not set 'td->flag |= TD_NOACTION', the prop circle is being changed.
- */
-
- td->factor = 0.0f;
- restoreElement(td);
- }
- else {
- /* Use rdist for falloff calculations, it is the real distance */
- td->flag &= ~TD_NOACTION;
-
- if (connected)
- dist = (t->prop_size - td->dist) / t->prop_size;
- else
- dist = (t->prop_size - td->rdist) / t->prop_size;
-
- /*
- * Clamp to positive numbers.
- * Certain corner cases with connectivity and individual centers
- * can give values of rdist larger than propsize.
- */
- if (dist < 0.0f)
- dist = 0.0f;
-
- switch (t->prop_mode) {
- case PROP_SHARP:
- td->factor = dist * dist;
- break;
- case PROP_SMOOTH:
- td->factor = 3.0f * dist * dist - 2.0f * dist * dist * dist;
- break;
- case PROP_ROOT:
- td->factor = sqrtf(dist);
- break;
- case PROP_LIN:
- td->factor = dist;
- break;
- case PROP_CONST:
- td->factor = 1.0f;
- break;
- case PROP_SPHERE:
- td->factor = sqrtf(2 * dist - dist * dist);
- break;
- case PROP_RANDOM:
- td->factor = BLI_frand() * dist;
- break;
- case PROP_INVSQUARE:
- td->factor = dist * (2.0f - dist);
- break;
- default:
- td->factor = 1;
- break;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ if (td->flag & TD_SELECTED) {
+ td->factor = 1.0f;
+ }
+ else if (t->flag & T_MIRROR && td->loc[0] * t->mirror < -0.00001f) {
+ td->flag |= TD_SKIP;
+ td->factor = 0.0f;
+ restoreElement(td);
+ }
+ else if ((connected && (td->flag & TD_NOTCONNECTED || td->dist > t->prop_size)) ||
+ (connected == 0 && td->rdist > t->prop_size))
+ {
+ /*
+ * The elements are sorted according to their dist member in the array,
+ * that means we can stop when it finds one element outside of the propsize.
+ * do not set 'td->flag |= TD_NOACTION', the prop circle is being changed.
+ */
+
+ td->factor = 0.0f;
+ restoreElement(td);
+ }
+ else {
+ /* Use rdist for falloff calculations, it is the real distance */
+ td->flag &= ~TD_NOACTION;
+
+ if (connected)
+ dist = (t->prop_size - td->dist) / t->prop_size;
+ else
+ dist = (t->prop_size - td->rdist) / t->prop_size;
+
+ /*
+ * Clamp to positive numbers.
+ * Certain corner cases with connectivity and individual centers
+ * can give values of rdist larger than propsize.
+ */
+ if (dist < 0.0f)
+ dist = 0.0f;
+
+ switch (t->prop_mode) {
+ case PROP_SHARP:
+ td->factor = dist * dist;
+ break;
+ case PROP_SMOOTH:
+ td->factor = 3.0f * dist * dist - 2.0f * dist * dist * dist;
+ break;
+ case PROP_ROOT:
+ td->factor = sqrtf(dist);
+ break;
+ case PROP_LIN:
+ td->factor = dist;
+ break;
+ case PROP_CONST:
+ td->factor = 1.0f;
+ break;
+ case PROP_SPHERE:
+ td->factor = sqrtf(2 * dist - dist * dist);
+ break;
+ case PROP_RANDOM:
+ td->factor = BLI_frand() * dist;
+ break;
+ case PROP_INVSQUARE:
+ td->factor = dist * (2.0f - dist);
+ break;
+ default:
+ td->factor = 1;
+ break;
+ }
}
}
}
+
switch (t->prop_mode) {
case PROP_SHARP:
pet_id = N_("(Sharp)");
@@ -2068,8 +2170,11 @@ void calculatePropRatio(TransInfo *t)
}
}
else {
- for (i = 0; i < t->total; i++, td++) {
- td->factor = 1.0;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (i = 0; i < tc->data_len; i++, td++) {
+ td->factor = 1.0;
+ }
}
}
}
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 8944817baca..8221412b32a 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -59,6 +59,7 @@
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
#include "BKE_gpencil.h"
+#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "BIF_gl.h"
@@ -154,8 +155,17 @@ enum {
MAN_AXES_SCALE,
};
+/* naming from old blender we may combine. */
+enum {
+ V3D_MANIP_TRANSLATE = 1,
+ V3D_MANIP_ROTATE = 2,
+ V3D_MANIP_SCALE = 4,
+};
+
+
typedef struct ManipulatorGroup {
bool all_hidden;
+ int twtype;
struct wmManipulator *manipulators[MAN_AXIS_LAST];
} ManipulatorGroup;
@@ -248,7 +258,7 @@ static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane)
}
static bool manipulator_is_axis_visible(
- const View3D *v3d, const RegionView3D *rv3d,
+ const RegionView3D *rv3d, const int twtype,
const float idot[3], const int axis_type, const int axis_idx)
{
bool is_plane = false;
@@ -264,9 +274,9 @@ static bool manipulator_is_axis_visible(
}
}
- if ((axis_type == MAN_AXES_TRANSLATE && !(v3d->twtype & V3D_MANIP_TRANSLATE)) ||
- (axis_type == MAN_AXES_ROTATE && !(v3d->twtype & V3D_MANIP_ROTATE)) ||
- (axis_type == MAN_AXES_SCALE && !(v3d->twtype & V3D_MANIP_SCALE)))
+ if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & V3D_MANIP_TRANSLATE)) ||
+ (axis_type == MAN_AXES_ROTATE && !(twtype & V3D_MANIP_ROTATE)) ||
+ (axis_type == MAN_AXES_SCALE && !(twtype & V3D_MANIP_SCALE)))
{
return false;
}
@@ -296,34 +306,34 @@ static bool manipulator_is_axis_visible(
case MAN_AXIS_SCALE_Z:
return (rv3d->twdrawflag & MAN_SCALE_Z);
case MAN_AXIS_SCALE_C:
- return (rv3d->twdrawflag & MAN_SCALE_C && (v3d->twtype & V3D_MANIP_TRANSLATE) == 0);
+ return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & V3D_MANIP_TRANSLATE) == 0);
case MAN_AXIS_TRANS_XY:
return (rv3d->twdrawflag & MAN_TRANS_X &&
rv3d->twdrawflag & MAN_TRANS_Y &&
- (v3d->twtype & V3D_MANIP_ROTATE) == 0);
+ (twtype & V3D_MANIP_ROTATE) == 0);
case MAN_AXIS_TRANS_YZ:
return (rv3d->twdrawflag & MAN_TRANS_Y &&
rv3d->twdrawflag & MAN_TRANS_Z &&
- (v3d->twtype & V3D_MANIP_ROTATE) == 0);
+ (twtype & V3D_MANIP_ROTATE) == 0);
case MAN_AXIS_TRANS_ZX:
return (rv3d->twdrawflag & MAN_TRANS_Z &&
rv3d->twdrawflag & MAN_TRANS_X &&
- (v3d->twtype & V3D_MANIP_ROTATE) == 0);
+ (twtype & V3D_MANIP_ROTATE) == 0);
case MAN_AXIS_SCALE_XY:
return (rv3d->twdrawflag & MAN_SCALE_X &&
rv3d->twdrawflag & MAN_SCALE_Y &&
- (v3d->twtype & V3D_MANIP_TRANSLATE) == 0 &&
- (v3d->twtype & V3D_MANIP_ROTATE) == 0);
+ (twtype & V3D_MANIP_TRANSLATE) == 0 &&
+ (twtype & V3D_MANIP_ROTATE) == 0);
case MAN_AXIS_SCALE_YZ:
return (rv3d->twdrawflag & MAN_SCALE_Y &&
rv3d->twdrawflag & MAN_SCALE_Z &&
- (v3d->twtype & V3D_MANIP_TRANSLATE) == 0 &&
- (v3d->twtype & V3D_MANIP_ROTATE) == 0);
+ (twtype & V3D_MANIP_TRANSLATE) == 0 &&
+ (twtype & V3D_MANIP_ROTATE) == 0);
case MAN_AXIS_SCALE_ZX:
return (rv3d->twdrawflag & MAN_SCALE_Z &&
rv3d->twdrawflag & MAN_SCALE_X &&
- (v3d->twtype & V3D_MANIP_TRANSLATE) == 0 &&
- (v3d->twtype & V3D_MANIP_ROTATE) == 0);
+ (twtype & V3D_MANIP_TRANSLATE) == 0 &&
+ (twtype & V3D_MANIP_ROTATE) == 0);
}
return false;
}
@@ -619,7 +629,7 @@ static int calc_manipulator_stats(
* if we could check 'totsel' now, this should be skipped with no selection. */
if (ob && !is_gp_edit) {
- switch (v3d->twmode) {
+ switch (scene->orientation_type) {
case V3D_MANIP_GLOBAL:
{
@@ -672,8 +682,8 @@ static int calc_manipulator_stats(
}
case V3D_MANIP_CUSTOM:
{
- TransformOrientation *custom_orientation = BKE_workspace_transform_orientation_find(
- CTX_wm_workspace(C), v3d->custom_orientation_index);
+ TransformOrientation *custom_orientation = BKE_scene_transform_orientation_find(
+ scene, scene->orientation_index_custom);
float mat[3][3];
if (applyTransformOrientation(custom_orientation, mat, NULL)) {
@@ -1092,7 +1102,7 @@ static void manipulator_prepare_mat(
* Sets up \a r_start and \a r_len to define arrow line range.
* Needed to adjust line drawing for combined manipulator axis types.
*/
-static void manipulator_line_range(const View3D *v3d, const short axis_type, float *r_start, float *r_len)
+static void manipulator_line_range(const int twtype, const short axis_type, float *r_start, float *r_len)
{
const float ofs = 0.2f;
@@ -1101,15 +1111,15 @@ static void manipulator_line_range(const View3D *v3d, const short axis_type, flo
switch (axis_type) {
case MAN_AXES_TRANSLATE:
- if (v3d->twtype & V3D_MANIP_SCALE) {
+ if (twtype & V3D_MANIP_SCALE) {
*r_start = *r_len - ofs + 0.075f;
}
- if (v3d->twtype & V3D_MANIP_ROTATE) {
+ if (twtype & V3D_MANIP_ROTATE) {
*r_len += ofs;
}
break;
case MAN_AXES_SCALE:
- if (v3d->twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) {
+ if (twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) {
*r_len -= ofs + 0.025f;
}
break;
@@ -1133,9 +1143,9 @@ static void manipulator_xform_message_subscribe(
RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &space_ptr);
{
- extern PropertyRNA rna_SpaceView3D_transform_orientation;
+ extern PropertyRNA rna_Scene_transform_orientation;
const PropertyRNA *props[] = {
- &rna_SpaceView3D_transform_orientation,
+ &rna_Scene_transform_orientation,
};
for (int i = 0; i < ARRAY_SIZE(props); i++) {
WM_msg_subscribe_rna(mbus, &space_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__);
@@ -1251,7 +1261,7 @@ static int manipulator_modal(
return OPERATOR_RUNNING_MODAL;
}
-static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
+static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup)
{
ManipulatorGroup *man = manipulatorgroup_init(mgroup);
struct {
@@ -1260,6 +1270,27 @@ static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulat
mgroup->customdata = man;
+ {
+ /* TODO: support mixing modes again? - it's supported but tool system makes it unobvious. */
+ man->twtype = 0;
+ WorkSpace *workspace = CTX_wm_workspace(C);
+ ScrArea *sa = CTX_wm_area(C);
+ wmKeyMap *km = WM_keymap_find_all(C, workspace->tool.keymap, sa->spacetype, RGN_TYPE_WINDOW);
+ /* Weak, check first event */
+ wmKeyMapItem *kmi = km->items.first;
+
+ if (STREQ(kmi->idname, "TRANSFORM_OT_translate")) {
+ man->twtype |= V3D_MANIP_TRANSLATE;
+ }
+ else if (STREQ(kmi->idname, "TRANSFORM_OT_rotate")) {
+ man->twtype |= V3D_MANIP_ROTATE;
+ }
+ else if (STREQ(kmi->idname, "TRANSFORM_OT_resize")) {
+ man->twtype |= V3D_MANIP_SCALE;
+ }
+ BLI_assert(man->twtype != 0);
+ }
+
/* *** set properties for axes *** */
MAN_ITER_AXES_BEGIN(axis, axis_idx)
@@ -1402,7 +1433,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
float start_co[3] = {0.0f, 0.0f, 0.0f};
float len;
- manipulator_line_range(v3d, axis_type, &start_co[2], &len);
+ manipulator_line_range(man->twtype, axis_type, &start_co[2], &len);
WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]);
RNA_float_set(axis->ptr, "length", len);
@@ -1444,9 +1475,9 @@ static void WIDGETGROUP_manipulator_message_subscribe(
static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
{
ManipulatorGroup *man = mgroup->customdata;
- ScrArea *sa = CTX_wm_area(C);
+ // ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- View3D *v3d = sa->spacedata.first;
+ // View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
float idot[3];
@@ -1468,7 +1499,7 @@ static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulato
{
const short axis_type = manipulator_get_axis_type(axis_idx);
/* XXX maybe unset _HIDDEN flag on redraw? */
- if (manipulator_is_axis_visible(v3d, rv3d, idot, axis_type, axis_idx)) {
+ if (manipulator_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) {
WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, false);
}
else {
@@ -1493,22 +1524,21 @@ static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulato
MAN_ITER_AXES_END;
}
-static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *UNUSED(wgt))
+static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt)
{
/* it's a given we only use this in 3D view */
- const ScrArea *sa = CTX_wm_area(C);
- const View3D *v3d = sa->spacedata.first;
+ ScrArea *sa = CTX_wm_area(C);
+ View3D *v3d = sa->spacedata.first;
+ if (v3d && ((v3d->twflag & V3D_MANIPULATOR_DRAW)) == 0) {
+ return false;
+ }
- if (((v3d->twflag & V3D_MANIPULATOR_DRAW) != 0) &&
- ((v3d->twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE | V3D_MANIP_SCALE)) != 0))
- {
- /* Don't show when tools have a manipulator. */
- WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->tool.manipulator_group[0] == '\0') {
- return true;
- }
+ WorkSpace *workspace = CTX_wm_workspace(C);
+ if (!STREQ(workspace->tool.manipulator_group, "TRANSFORM_WGT_manipulator")) {
+ WM_manipulator_group_type_unlink_delayed_ptr(wgt);
+ return false;
}
- return false;
+ return true;
}
void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt)
@@ -1516,8 +1546,10 @@ void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt)
wgt->name = "Transform Manipulator";
wgt->idname = "TRANSFORM_WGT_manipulator";
- wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
- WM_MANIPULATORGROUPTYPE_3D);
+ wgt->flag |= WM_MANIPULATORGROUPTYPE_3D;
+
+ wgt->mmap_params.spaceid = SPACE_VIEW3D;
+ wgt->mmap_params.regionid = RGN_TYPE_WINDOW;
wgt->poll = WIDGETGROUP_manipulator_poll;
wgt->setup = WIDGETGROUP_manipulator_setup;
@@ -1539,6 +1571,12 @@ struct XFormCageWidgetGroup {
static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmManipulatorGroupType *wgt)
{
+ ScrArea *sa = CTX_wm_area(C);
+ View3D *v3d = sa->spacedata.first;
+ if (v3d && ((v3d->twflag & V3D_MANIPULATOR_DRAW)) == 0) {
+ return false;
+ }
+
WorkSpace *workspace = CTX_wm_workspace(C);
if (!STREQ(wgt->idname, workspace->tool.manipulator_group)) {
WM_manipulator_group_type_unlink_delayed_ptr(wgt);
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index d5d25888ec8..6f31f5311bc 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -160,12 +160,12 @@ const EnumPropertyItem rna_enum_transform_mode_types[] =
static int select_orientation_exec(bContext *C, wmOperator *op)
{
- View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
int orientation = RNA_enum_get(op->ptr, "orientation");
- BIF_selectTransformOrientationValue(v3d, orientation);
-
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ BIF_selectTransformOrientationValue(scene, orientation);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
return OPERATOR_FINISHED;
}
@@ -206,12 +206,10 @@ static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot)
static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op))
{
- View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
+ BIF_removeTransformOrientationIndex(C, scene->orientation_index_custom);
- BIF_removeTransformOrientationIndex(C, v3d->custom_orientation_index);
-
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
- WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
return OPERATOR_FINISHED;
}
@@ -223,12 +221,12 @@ static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent
static int delete_orientation_poll(bContext *C)
{
- View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
if (ED_operator_areaactive(C) == 0)
return 0;
- return (v3d->twmode >= V3D_MANIP_CUSTOM) && (v3d->custom_orientation_index != -1);
+ return (scene->orientation_type >= V3D_MANIP_CUSTOM) && (scene->orientation_index_custom != -1);
}
static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot)
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 7b3f91b81da..9e6f4847b5b 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -53,6 +53,7 @@
#include "BKE_report.h"
#include "BKE_main.h"
#include "BKE_screen.h"
+#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "BLT_translation.h"
@@ -65,16 +66,15 @@
void BIF_clearTransformOrientation(bContext *C)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
- ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace);
+ Scene *scene = CTX_data_scene(C);
+ ListBase *transform_orientations = &scene->transform_spaces;
View3D *v3d = CTX_wm_view3d(C);
BLI_freelistN(transform_orientations);
-
- // Need to loop over all view3d
- if (v3d && v3d->twmode == V3D_MANIP_CUSTOM) {
- v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
- v3d->custom_orientation_index = -1;
+
+ if (v3d && scene->orientation_type == V3D_MANIP_CUSTOM) {
+ scene->orientation_type = V3D_MANIP_GLOBAL; /* fallback to global */
+ scene->orientation_index_custom = -1;
}
}
@@ -323,8 +323,8 @@ TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3],
const char *name, const bool overwrite)
{
TransformOrientation *ts = NULL;
- WorkSpace *workspace = CTX_wm_workspace(C);
- ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace);
+ Scene *scene = CTX_data_scene(C);
+ ListBase *transform_orientations = &scene->transform_spaces;
char name_unique[sizeof(ts->name)];
if (overwrite) {
@@ -351,24 +351,24 @@ TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3],
void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target)
{
- BKE_workspace_transform_orientation_remove(CTX_wm_workspace(C), target);
+ BKE_scene_transform_orientation_remove(CTX_data_scene(C), target);
}
void BIF_removeTransformOrientationIndex(bContext *C, int index)
{
- TransformOrientation *target = BKE_workspace_transform_orientation_find(CTX_wm_workspace(C), index);
+ TransformOrientation *target = BKE_scene_transform_orientation_find(CTX_data_scene(C), index);
BIF_removeTransformOrientation(C, target);
}
void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target)
{
- int index = BKE_workspace_transform_orientation_get_index(CTX_wm_workspace(C), target);
- View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
+ int index = BKE_scene_transform_orientation_get_index(scene, target);
BLI_assert(index != -1);
- v3d->twmode = V3D_MANIP_CUSTOM;
- v3d->custom_orientation_index = index;
+ scene->orientation_type = V3D_MANIP_CUSTOM;
+ scene->orientation_index_custom = index;
}
/**
@@ -377,18 +377,17 @@ void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target)
* \param orientation: If this is #V3D_MANIP_CUSTOM or greater, the custom transform orientation
* with index \a orientation - #V3D_MANIP_CUSTOM gets activated.
*/
-void BIF_selectTransformOrientationValue(View3D *v3d, int orientation)
+void BIF_selectTransformOrientationValue(Scene *scene, int orientation)
{
const bool is_custom = orientation >= V3D_MANIP_CUSTOM;
-
- v3d->twmode = is_custom ? V3D_MANIP_CUSTOM : orientation;
- v3d->custom_orientation_index = is_custom ? (orientation - V3D_MANIP_CUSTOM) : -1;
+ scene->orientation_type = is_custom ? V3D_MANIP_CUSTOM : orientation;
+ scene->orientation_index_custom = is_custom ? (orientation - V3D_MANIP_CUSTOM) : -1;
}
int BIF_countTransformOrientation(const bContext *C)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
- ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace);
+ Scene *scene = CTX_data_scene(C);
+ ListBase *transform_orientations = &scene->transform_spaces;
return BLI_listbase_count(transform_orientations);
}
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 5cb3f262ced..7e996fd4086 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -272,73 +272,78 @@ void applyProject(TransInfo *t)
{
/* XXX FLICKER IN OBJECT MODE */
if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0) {
- TransData *td = t->data;
float tvec[3];
- float imat[4][4];
int i;
-
- if (t->flag & (T_EDIT | T_POSE)) {
- Object *ob = t->obedit ? t->obedit : t->poseobj;
- invert_m4_m4(imat, ob->obmat);
- }
- for (i = 0; i < t->total; i++, td++) {
- float iloc[3], loc[3], no[3];
- float mval_fl[2];
- float dist_px = TRANSFORM_DIST_MAX_PX;
-
- if (td->flag & TD_NOACTION)
- break;
-
- if (td->flag & TD_SKIP)
- continue;
+ FOREACH_TRANS_DATA_CONTAINER(t, tc) {
+ TransData *td = tc->data;
- if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f))
- continue;
-
- copy_v3_v3(iloc, td->loc);
+ float imat[4][4];
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) {
- BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob);
- copy_v3_v3(iloc, td->ob->obmat[3]);
+ Object *ob = tc->obedit ? tc->obedit : tc->poseobj;
+ invert_m4_m4(imat, ob->obmat);
}
-
- if (ED_view3d_project_float_global(t->ar, iloc, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- if (snapObjectsTransform(
- t, mval_fl, &dist_px,
- loc, no))
- {
-// if (t->flag & (T_EDIT|T_POSE)) {
-// mul_m4_v3(imat, loc);
-// }
- sub_v3_v3v3(tvec, loc, iloc);
+ for (i = 0; i < tc->data_len; i++, td++) {
+ float iloc[3], loc[3], no[3];
+ float mval_fl[2];
+ float dist_px = TRANSFORM_DIST_MAX_PX;
+
+ 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 = tc->obedit ? tc->obedit : tc->poseobj;
+ mul_m4_v3(ob->obmat, iloc);
+ }
+ else if (t->flag & T_OBJECT) {
+ BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob);
+ copy_v3_v3(iloc, td->ob->obmat[3]);
+ }
+
+ if (ED_view3d_project_float_global(t->ar, iloc, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
+ if (snapObjectsTransform(
+ t, mval_fl, &dist_px,
+ loc, no))
+ {
+#if 0
+ if (t->flag & (T_EDIT | T_POSE)) {
+ mul_m4_v3(imat, loc);
+ }
+#endif
- mul_m3_v3(td->smtx, tvec);
+ sub_v3_v3v3(tvec, loc, iloc);
- add_v3_v3(td->loc, tvec);
+ mul_m3_v3(td->smtx, tvec);
- if (t->tsnap.align && (t->flag & T_OBJECT)) {
- /* handle alignment as well */
- const float *original_normal;
- float mat[3][3];
+ add_v3_v3(td->loc, tvec);
- /* In pose mode, we want to align normals with Y axis of bones... */
- original_normal = td->axismtx[2];
+ if (t->tsnap.align && (t->flag & T_OBJECT)) {
+ /* handle alignment as well */
+ const float *original_normal;
+ float mat[3][3];
- rotation_between_vecs_to_mat3(mat, original_normal, no);
+ /* In pose mode, we want to align normals with Y axis of bones... */
+ original_normal = td->axismtx[2];
- transform_data_ext_rotate(td, mat, true);
+ rotation_between_vecs_to_mat3(mat, original_normal, no);
- /* TODO support constraints for rotation too? see ElementRotation */
+ transform_data_ext_rotate(td, mat, true);
+
+ /* TODO support constraints for rotation too? see ElementRotation */
+ }
}
}
+
+ //XXX constraintTransLim(t, td);
}
-
- //XXX constraintTransLim(t, td);
}
}
}
@@ -347,7 +352,6 @@ void applyGridAbsolute(TransInfo *t)
{
float grid_size = 0.0f;
GearsType grid_action;
- TransData *td;
float (*obmat)[4] = NULL;
bool use_obmat = false;
int i;
@@ -368,42 +372,46 @@ void applyGridAbsolute(TransInfo *t)
if (grid_size == 0.0f)
return;
- if (t->flag & (T_EDIT | T_POSE)) {
- Object *ob = t->obedit ? t->obedit : t->poseobj;
- obmat = ob->obmat;
- use_obmat = true;
- }
-
- 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 (use_obmat) {
- mul_m4_v3(obmat, iloc);
+ FOREACH_TRANS_DATA_CONTAINER(t, tc) {
+ TransData *td;
+
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = tc->obedit ? tc->obedit : tc->poseobj;
+ obmat = ob->obmat;
+ use_obmat = true;
}
- else if (t->flag & T_OBJECT) {
- BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob);
- copy_v3_v3(iloc, td->ob->obmat[3]);
+
+ for (i = 0, td = tc->data; i < tc->data_len; 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 (use_obmat) {
+ mul_m4_v3(obmat, iloc);
+ }
+ else if (t->flag & T_OBJECT) {
+ BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob);
+ copy_v3_v3(iloc, td->ob->obmat[3]);
+ }
+
+ mul_v3_v3fl(loc, iloc, 1.0f / grid_size);
+ loc[0] = roundf(loc[0]);
+ loc[1] = roundf(loc[1]);
+ loc[2] = roundf(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);
}
-
- mul_v3_v3fl(loc, iloc, 1.0f / grid_size);
- loc[0] = roundf(loc[0]);
- loc[1] = roundf(loc[1]);
- loc[2] = roundf(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);
}
}
@@ -501,7 +509,8 @@ static bool bm_face_is_snap_target(BMFace *f, void *UNUSED(user_data))
static void initSnappingMode(TransInfo *t)
{
ToolSettings *ts = t->settings;
- Object *obedit = t->obedit;
+ /* All obedit types will match. */
+ const int obedit_type = t->data_container->obedit ? t->data_container->obedit->type : -1;
ViewLayer *view_layer = t->view_layer;
Base *base_act = view_layer->basact;
@@ -532,10 +541,10 @@ static void initSnappingMode(TransInfo *t)
/* Edit mode */
if (t->tsnap.applySnap != NULL && // A snapping function actually exist
- (obedit != NULL && ELEM(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) ) // Temporary limited to edit mode meshes, armature, curves, mballs
+ ((obedit_type != -1) && ELEM(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)) {
+ if ((obedit_type == OB_MESH) && (t->flag & T_PROP_EDIT)) {
t->tsnap.modeSelect = SNAP_NOT_ACTIVE;
}
else {
@@ -544,13 +553,13 @@ static void initSnappingMode(TransInfo *t)
}
/* Particles edit mode*/
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
- (obedit == NULL && base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT))
+ ((obedit_type == -1) && base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT))
{
t->tsnap.modeSelect = SNAP_ALL;
}
/* Object mode */
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
- (obedit == NULL) ) // Object Mode
+ (obedit_type == -1) ) // Object Mode
{
/* In "Edit Strokes" mode, Snap tool can perform snap to selected or active objects (see T49632)
* TODO: perform self snap in gpencil_strokes */
@@ -584,7 +593,7 @@ static void initSnappingMode(TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
if (t->tsnap.object_context == NULL) {
t->tsnap.object_context = ED_transform_snap_object_context_create_view3d(
- G.main, t->scene, t->view_layer, 0, t->ar, t->view);
+ G.main, t->scene, t->depsgraph, 0, t->ar, t->view);
ED_transform_snap_object_context_set_editmesh_callbacks(
t->tsnap.object_context,
@@ -863,7 +872,8 @@ static float TranslationBetween(TransInfo *UNUSED(t), const float p1[3], const f
return len_squared_v3v3(p1, p2);
}
-static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3])
+static float RotationBetween(
+ TransInfo *t, const float p1[3], const float p2[3])
{
float angle, start[3], end[3];
@@ -874,7 +884,7 @@ static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3])
if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) {
float axis[3], tmp[3];
- t->con.applyRot(t, NULL, axis, NULL);
+ t->con.applyRot(t, NULL, NULL, axis, NULL);
project_v3_v3v3(tmp, end, axis);
sub_v3_v3v3(end, end, tmp);
@@ -977,14 +987,14 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
t->tsnap.status &= ~POINT_INIT;
}
}
- else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type == OB_MESH) {
+ else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) {
/* same as above but for UV's */
Image *ima = ED_space_image(t->sa->spacedata.first);
float co[2];
UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
- if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) {
+ if (ED_uvedit_nearest_uv(t->scene, TRANS_DATA_CONTAINER_FIRST_EVIL(t)->obedit, ima, co, t->tsnap.snapPoint)) {
t->tsnap.snapPoint[0] *= t->aspect[0];
t->tsnap.snapPoint[1] *= t->aspect[1];
@@ -1059,11 +1069,6 @@ static void TargetSnapActive(TransInfo *t)
/* Only need to calculate once */
if ((t->tsnap.status & TARGET_INIT) == 0) {
if (calculateCenterActive(t, true, t->tsnap.snapTarget)) {
- if (t->flag & (T_EDIT | T_POSE)) {
- Object *ob = t->obedit ? t->obedit : t->poseobj;
- mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
- }
-
TargetSnapOffset(t, NULL);
t->tsnap.status |= TARGET_INIT;
@@ -1081,23 +1086,34 @@ static void TargetSnapMedian(TransInfo *t)
{
// Only need to calculate once
if ((t->tsnap.status & TARGET_INIT) == 0) {
- TransData *td = NULL;
- int i;
+ int i_accum = 0;
t->tsnap.snapTarget[0] = 0;
t->tsnap.snapTarget[1] = 0;
t->tsnap.snapTarget[2] = 0;
-
- for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
- add_v3_v3(t->tsnap.snapTarget, td->center);
- }
-
- mul_v3_fl(t->tsnap.snapTarget, 1.0 / i);
-
- if (t->flag & (T_EDIT | T_POSE)) {
- Object *ob = t->obedit ? t->obedit : t->poseobj;
- mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Object *ob_xform = NULL;
+ if (t->flag & (T_EDIT | T_POSE)) {
+ ob_xform = tc->obedit ? tc->obedit : tc->poseobj;
+ }
+ TransData *td = tc->data;
+ int i;
+ for (i = 0; i < tc->data_len && td->flag & TD_SELECTED; i++, td++) {
+ /* TODO(campbell): perform the global transformation once per TransDataContainer */
+ if (ob_xform) {
+ float v[3];
+ mul_v3_m4v3(v, ob_xform->obmat, td->center);
+ add_v3_v3(t->tsnap.snapTarget, v);
+ }
+ else {
+ add_v3_v3(t->tsnap.snapTarget, td->center);
+ }
+ }
+ i_accum += i;
}
+
+ mul_v3_fl(t->tsnap.snapTarget, 1.0 / i_accum);
TargetSnapOffset(t, NULL);
@@ -1110,25 +1126,45 @@ static void TargetSnapClosest(TransInfo *t)
// Only valid if a snap point has been selected
if (t->tsnap.status & POINT_INIT) {
float dist_closest = 0.0f;
- TransData *closest = NULL, *td = NULL;
+ TransData *closest = NULL;
/* Object mode */
if (t->flag & T_OBJECT) {
int i;
- for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
- struct BoundBox *bb = BKE_object_boundbox_get(td->ob);
-
- /* use boundbox if possible */
- if (bb) {
- int j;
-
- for (j = 0; j < 8; j++) {
+ FOREACH_TRANS_DATA_CONTAINER(t, tc) {
+ TransData *td = tc->data;
+ for (td = tc->data, i = 0; i < tc->data_len && td->flag & TD_SELECTED; i++, td++) {
+ struct BoundBox *bb = BKE_object_boundbox_get(td->ob);
+
+ /* use boundbox if possible */
+ if (bb) {
+ int j;
+
+ for (j = 0; j < 8; j++) {
+ float loc[3];
+ float dist;
+
+ copy_v3_v3(loc, bb->vec[j]);
+ mul_m4_v3(td->ext->obmat, loc);
+
+ dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
+
+ if ((dist != TRANSFORM_DIST_INVALID) &&
+ (closest == NULL || fabsf(dist) < fabsf(dist_closest)))
+ {
+ copy_v3_v3(t->tsnap.snapTarget, loc);
+ closest = td;
+ dist_closest = dist;
+ }
+ }
+ }
+ /* use element center otherwise */
+ else {
float loc[3];
float dist;
-
- copy_v3_v3(loc, bb->vec[j]);
- mul_m4_v3(td->ext->obmat, loc);
-
+
+ copy_v3_v3(loc, td->center);
+
dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
if ((dist != TRANSFORM_DIST_INVALID) &&
@@ -1136,17 +1172,26 @@ static void TargetSnapClosest(TransInfo *t)
{
copy_v3_v3(t->tsnap.snapTarget, loc);
closest = td;
- dist_closest = dist;
}
}
}
- /* use element center otherwise */
- else {
+ }
+ }
+ else {
+ FOREACH_TRANS_DATA_CONTAINER(t, tc) {
+ TransData *td = tc->data;
+ int i;
+ for (i = 0; i < tc->data_len && td->flag & TD_SELECTED; i++, td++) {
float loc[3];
float dist;
-
+
copy_v3_v3(loc, td->center);
-
+
+ if (t->flag & (T_EDIT | T_POSE)) {
+ Object *ob = tc->obedit ? tc->obedit : tc->poseobj;
+ mul_m4_v3(ob->obmat, loc);
+ }
+
dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
if ((dist != TRANSFORM_DIST_INVALID) &&
@@ -1154,34 +1199,11 @@ static void TargetSnapClosest(TransInfo *t)
{
copy_v3_v3(t->tsnap.snapTarget, loc);
closest = td;
+ dist_closest = dist;
}
}
}
}
- else {
- int i;
- for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
- float loc[3];
- float dist;
-
- copy_v3_v3(loc, td->center);
-
- if (t->flag & (T_EDIT | T_POSE)) {
- Object *ob = t->obedit ? t->obedit : t->poseobj;
- mul_m4_v3(ob->obmat, loc);
- }
-
- dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
-
- if ((dist != TRANSFORM_DIST_INVALID) &&
- (closest == NULL || fabsf(dist) < fabsf(dist_closest)))
- {
- copy_v3_v3(t->tsnap.snapTarget, loc);
- closest = td;
- dist_closest = dist;
- }
- }
- }
TargetSnapOffset(t, closest);
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 2a9b4790eaf..b6b7e157591 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -54,6 +54,7 @@
#include "BKE_context.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "ED_transform.h"
#include "ED_transform_snap_object_context.h"
@@ -108,7 +109,7 @@ typedef struct SnapObjectData_EditMesh {
struct SnapObjectContext {
Main *bmain;
Scene *scene;
- EvaluationContext eval_ctx;
+ Depsgraph *depsgraph;
int flag;
@@ -162,8 +163,9 @@ static void iter_snap_objects(
IterSnapObjsCallback sob_callback,
void *data)
{
- Base *base_act = sctx->eval_ctx.view_layer->basact;
- for (Base *base = sctx->eval_ctx.view_layer->object_bases.first; base != NULL; base = base->next) {
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(sctx->depsgraph);
+ Base *base_act = view_layer->basact;
+ for (Base *base = view_layer->object_bases.first; base != NULL; base = base->next) {
if ((BASE_VISIBLE(base)) && (base->flag_legacy & BA_SNAP_FIX_DEPS_FIASCO) == 0 &&
!((snap_select == SNAP_NOT_SELECTED && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) ||
(snap_select == SNAP_NOT_ACTIVE && base == base_act)))
@@ -172,7 +174,7 @@ static void iter_snap_objects(
Object *obj = base->object;
if (obj->transflag & OB_DUPLI) {
DupliObject *dupli_ob;
- ListBase *lb = object_duplilist(&sctx->eval_ctx, sctx->scene, obj);
+ ListBase *lb = object_duplilist(sctx->depsgraph, sctx->scene, obj);
for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
use_obedit = obedit && dupli_ob->ob->data == obedit->data;
sob_callback(sctx, use_obedit, use_obedit ? obedit : dupli_ob->ob, dupli_ob->mat, data);
@@ -729,10 +731,10 @@ static bool raycastObj(
DerivedMesh *dm;
em = BKE_editmesh_from_object(ob);
if (em) {
- editbmesh_get_derived_cage_and_final(&sctx->eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
+ editbmesh_get_derived_cage_and_final(sctx->depsgraph, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
}
else {
- dm = mesh_get_derived_final(&sctx->eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(sctx->depsgraph, sctx->scene, ob, CD_MASK_BAREMESH);
}
retval = raycastDerivedMesh(
sctx,
@@ -821,7 +823,8 @@ static bool raycastObjects(
Object **r_ob, float r_obmat[4][4],
ListBase *r_hit_list)
{
- Object *obedit = use_object_edit_cage ? OBEDIT_FROM_VIEW_LAYER(sctx->eval_ctx.view_layer) : NULL;
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(sctx->depsgraph);
+ Object *obedit = use_object_edit_cage ? OBEDIT_FROM_VIEW_LAYER(view_layer) : NULL;
struct RaycastObjUserData data = {
.ray_start = ray_start,
@@ -1936,10 +1939,10 @@ static bool snapObject(
DerivedMesh *dm;
em = BKE_editmesh_from_object(ob);
if (em) {
- editbmesh_get_derived_cage_and_final(&sctx->eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
+ editbmesh_get_derived_cage_and_final(sctx->depsgraph, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
}
else {
- dm = mesh_get_derived_final(&sctx->eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(sctx->depsgraph, sctx->scene, ob, CD_MASK_BAREMESH);
}
retval = snapDerivedMesh(
sctx, snapdata, ob, dm, obmat,
@@ -2054,7 +2057,8 @@ static bool snapObjectsRay(
float r_loc[3], float r_no[3],
Object **r_ob, float r_obmat[4][4])
{
- Object *obedit = use_object_edit_cage ? OBEDIT_FROM_VIEW_LAYER(sctx->eval_ctx.view_layer) : NULL;
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(sctx->depsgraph);
+ Object *obedit = use_object_edit_cage ? OBEDIT_FROM_VIEW_LAYER(view_layer) : NULL;
struct SnapObjUserData data = {
.snapdata = snapdata,
@@ -2079,7 +2083,7 @@ static bool snapObjectsRay(
* \{ */
SnapObjectContext *ED_transform_snap_object_context_create(
- Main *bmain, Scene *scene, ViewLayer *view_layer, int flag)
+ Main *bmain, Scene *scene, Depsgraph *depsgraph, int flag)
{
SnapObjectContext *sctx = MEM_callocN(sizeof(*sctx), __func__);
@@ -2087,9 +2091,7 @@ SnapObjectContext *ED_transform_snap_object_context_create(
sctx->bmain = bmain;
sctx->scene = scene;
-
- DEG_evaluation_context_init_from_scene(
- &sctx->eval_ctx, scene, view_layer, DAG_EVAL_VIEWPORT);
+ sctx->depsgraph = depsgraph;
sctx->cache.object_map = BLI_ghash_ptr_new(__func__);
sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
@@ -2098,11 +2100,11 @@ SnapObjectContext *ED_transform_snap_object_context_create(
}
SnapObjectContext *ED_transform_snap_object_context_create_view3d(
- Main *bmain, Scene *scene, ViewLayer *view_layer, int flag,
+ Main *bmain, Scene *scene, Depsgraph *depsgraph, int flag,
/* extra args for view3d */
const ARegion *ar, const View3D *v3d)
{
- SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, view_layer, flag);
+ SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, depsgraph, flag);
sctx->use_v3d = true;
sctx->v3d_data.ar = ar;
@@ -2365,7 +2367,7 @@ bool ED_transform_snap_object_project_view3d_ex(
ED_view3d_win_to_vector(ar, mval, ray_normal);
ED_view3d_clip_range_get(
- sctx->eval_ctx.depsgraph,
+ sctx->depsgraph,
sctx->v3d_data.v3d, sctx->v3d_data.ar->regiondata,
&depth_range[0], &depth_range[1], false);
@@ -2432,7 +2434,7 @@ bool ED_transform_snap_object_project_all_view3d_ex(
float ray_start[3], ray_normal[3];
if (!ED_view3d_win_to_ray_ex(
- sctx->eval_ctx.depsgraph,
+ sctx->depsgraph,
sctx->v3d_data.ar, sctx->v3d_data.v3d,
mval, NULL, ray_normal, ray_start, true))
{
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index d8b194e3336..03dd1ad26e7 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -36,6 +36,7 @@
#include "CLG_log.h"
#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
#include "BLI_utildefines.h"
@@ -46,6 +47,7 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_screen.h"
+#include "BKE_layer.h"
#include "BKE_undo_system.h"
#include "ED_gpencil.h"
@@ -302,12 +304,44 @@ void ED_OT_undo_redo(wmOperatorType *ot)
/** \} */
+#ifdef WITH_REDO_REGION_REMOVAL
+struct OperatorRepeatContextHandle {
+ ScrArea *restore_area;
+ ARegion *restore_region;
+};
+
+/**
+ * Resets the context to the state \a op was executed in (or at least, was in when registering).
+ * #ED_operator_repeat_reset_context should be called when done repeating!
+ */
+const OperatorRepeatContextHandle *ED_operator_repeat_prepare_context(bContext *C, wmOperator *op)
+{
+ static OperatorRepeatContextHandle context_info;
+
+ context_info.restore_area = CTX_wm_area(C);
+ context_info.restore_region = CTX_wm_region(C);
+
+ CTX_wm_area_set(C, op->execution_area);
+ CTX_wm_region_set(C, op->execution_region);
+
+ return &context_info;
+}
+/**
+ * Resets context to the old state from before #ED_operator_repeat_prepare_context was called.
+ */
+void ED_operator_repeat_reset_context(bContext *C, const OperatorRepeatContextHandle *context_info)
+{
+ CTX_wm_area_set(C, context_info->restore_area);
+ CTX_wm_region_set(C, context_info->restore_region);
+}
+#endif
+
/* -------------------------------------------------------------------- */
/** \name Operator Repeat
* \{ */
/* ui callbacks should call this rather than calling WM_operator_repeat() themselves */
-int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
+int ED_undo_operator_repeat(bContext *C, wmOperator *op)
{
int ret = 0;
@@ -316,12 +350,17 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
wmWindowManager *wm = CTX_wm_manager(C);
struct Scene *scene = CTX_data_scene(C);
+#ifdef WITH_REDO_REGION_REMOVAL
+ const OperatorRepeatContextHandle *context_info;
+ context_info = ED_operator_repeat_prepare_context(C, op);
+#else
/* keep in sync with logic in view3d_panel_operator_redo() */
ARegion *ar = CTX_wm_region(C);
ARegion *ar1 = BKE_area_find_region_active_win(CTX_wm_area(C));
if (ar1)
CTX_wm_region_set(C, ar1);
+#endif
if ((WM_operator_repeat_check(C, op)) &&
(WM_operator_poll(C, op->type)) &&
@@ -334,8 +373,6 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
{
int retval;
- ED_viewport_render_kill_jobs(wm, CTX_data_main(C), true);
-
if (G.debug & G_DEBUG)
printf("redo_cb: operator redo %s\n", op->type->name);
@@ -369,8 +406,12 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
}
}
+#ifdef WITH_REDO_REGION_REMOVAL
+ ED_operator_repeat_reset_context(C, context_info);
+#else
/* set region back */
CTX_wm_region_set(C, ar);
+#endif
}
else {
CLOG_WARN(&LOG, "called with NULL 'op'");
@@ -495,3 +536,24 @@ void ED_OT_undo_history(wmOperatorType *ot)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Undo Helper Functions
+ * \{ */
+
+void ED_undo_object_set_active_or_warn(ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log)
+{
+ Object *ob_prev = OBACT(view_layer);
+ if (ob_prev != ob) {
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+ if (base != NULL) {
+ view_layer->basact = base;
+ }
+ else {
+ /* Should never fail, may not crash but can give odd behavior. */
+ CLOG_WARN(log, "'%s' failed to restore active object: '%s'", info, ob->id.name + 2);
+ }
+ }
+}
+
+/** \} */
diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c
index 511f4bc72f1..d45470ab0a1 100644
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@ -85,8 +85,6 @@ static void memfile_undosys_step_decode(struct bContext *C, UndoStep *us_p, int
/* Loading the content will correctly switch into compatible non-object modes. */
ED_object_mode_set(C, OB_MODE_OBJECT);
- /* This is needed so undoing/redoing doesn't crash with threaded previews going */
- ED_viewport_render_kill_jobs(CTX_wm_manager(C), CTX_data_main(C), true);
MemFileUndoStep *us = (MemFileUndoStep *)us_p;
BKE_memfile_undo_decode(us->data, C);
diff --git a/source/blender/editors/util/ed_transverts.c b/source/blender/editors/util/ed_transverts.c
index 872810c5cf2..494ae769cf3 100644
--- a/source/blender/editors/util/ed_transverts.c
+++ b/source/blender/editors/util/ed_transverts.c
@@ -154,7 +154,7 @@ void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
}
}
if (arm->flag & ARM_MIRROR_EDIT)
- transform_armature_mirror_update(obedit);
+ ED_armature_edit_transform_mirror_update(obedit);
}
else if (obedit->type == OB_LATTICE) {
Lattice *lt = obedit->data;
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 3fcc89d0973..945d30eabb5 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -51,6 +51,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_editmesh.h"
#include "BKE_material.h"
+#include "BKE_layer.h"
#include "BKE_scene.h"
@@ -389,7 +390,7 @@ static void draw_uvs_lineloop_bmfaces(BMesh *bm, const int cd_loop_uv_offset, co
MLoopUV *luv;
/* For more efficiency first transfer the entire buffer to vram. */
- Gwn_Batch *uv_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop);
+ Gwn_Batch *loop_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop);
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
@@ -403,19 +404,17 @@ static void draw_uvs_lineloop_bmfaces(BMesh *bm, const int cd_loop_uv_offset, co
immEnd();
/* Then draw each face contour separately. */
- GWN_batch_program_use_begin(uv_batch);
+ GWN_batch_program_use_begin(loop_batch);
unsigned int index = 0;
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- GWN_batch_draw_range_ex(uv_batch, index, efa->len, false);
+ GWN_batch_draw_range_ex(loop_batch, index, efa->len, false);
index += efa->len;
}
- GWN_batch_program_use_end(uv_batch);
-
- GWN_vertbuf_discard(uv_batch->verts[0]);
- GWN_batch_discard(uv_batch);
+ GWN_batch_program_use_end(loop_batch);
+ GWN_batch_discard(loop_batch);
immUnbindProgram();
@@ -437,43 +436,8 @@ static void draw_uvs_lineloop_mpoly(Mesh *me, MPoly *mpoly, unsigned int pos)
immEnd();
}
-static void draw_uvs_other_mesh_texface(Object *ob, const Image *curimage, const int other_uv_filter, unsigned int pos)
-{
- Mesh *me = ob->data;
- MPoly *mpoly = me->mpoly;
- int a;
-
- if (me->mloopuv == NULL) {
- return;
- }
-
- Image **image_array = NULL;
-
- if (other_uv_filter == SI_FILTER_SAME_IMAGE) {
- image_array = BKE_object_material_edit_image_get_array(ob);
- }
-
- for (a = me->totpoly; a != 0; a--, mpoly++) {
- if (other_uv_filter == SI_FILTER_ALL) {
- /* Nothing to compare, all UV faces are visible. */
- }
- else if (other_uv_filter == SI_FILTER_SAME_IMAGE) {
- if (mpoly[a].mat_nr >= ob->totcol) {
- continue;
- }
- if (image_array[mpoly[a].mat_nr] != curimage) {
- continue;
- }
- }
-
- draw_uvs_lineloop_mpoly(me, mpoly, pos);
- }
-
- if (image_array) {
- MEM_freeN(image_array);
- }
-}
-static void draw_uvs_other_mesh_new_shading(Object *ob, const Image *curimage, const int other_uv_filter, unsigned int pos)
+static void draw_uvs_other_mesh(Object *ob, const Image *curimage,
+ const int other_uv_filter, unsigned int pos)
{
Mesh *me = ob->data;
MPoly *mpoly = me->mpoly;
@@ -528,18 +492,8 @@ static void draw_uvs_other_mesh_new_shading(Object *ob, const Image *curimage, c
draw_uvs_lineloop_mpoly(me, mpoly, pos);
}
}
-static void draw_uvs_other_mesh(Object *ob, const Image *curimage, const bool new_shading_nodes,
- const int other_uv_filter, unsigned int pos)
-{
- if (new_shading_nodes) {
- draw_uvs_other_mesh_new_shading(ob, curimage, other_uv_filter, pos);
- }
- else {
- draw_uvs_other_mesh_texface(ob, curimage, other_uv_filter, pos);
- }
-}
-static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *curimage, const bool new_shading_nodes,
+static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *curimage,
const int other_uv_filter)
{
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -554,7 +508,7 @@ static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *c
{
Object *ob = base->object;
if ((ob->type == OB_MESH) && (ob != obedit) && ((Mesh *)ob->data)->mloopuv) {
- draw_uvs_other_mesh(ob, curimage, new_shading_nodes, other_uv_filter, pos);
+ draw_uvs_other_mesh(ob, curimage, other_uv_filter, pos);
}
}
}
@@ -563,13 +517,12 @@ static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *c
static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Object *ob)
{
- const bool new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
Image *curimage = ED_space_image(sima);
Mesh *me = ob->data;
Material *ma;
if (sima->flag & SI_DRAW_OTHER) {
- draw_uvs_other(view_layer, ob, curimage, new_shading_nodes, sima->other_uv_filter);
+ draw_uvs_other(view_layer, ob, curimage, sima->other_uv_filter);
}
ma = give_current_material(ob, ob->actcol);
@@ -628,7 +581,6 @@ static void draw_uvs_looptri(BMEditMesh *em, unsigned int *r_loop_index, const i
/* draws uv's in the image space */
static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Object *obedit, Depsgraph *depsgraph)
{
- const bool new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
ToolSettings *ts;
Mesh *me = obedit->data;
BMEditMesh *em = me->edit_btmesh;
@@ -659,19 +611,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
if (sima->flag & SI_DRAW_OTHER) {
Image *curimage;
- if (new_shading_nodes) {
- if (efa_act) {
- ED_object_get_active_image(obedit, efa_act->mat_nr + 1, &curimage, NULL, NULL, NULL);
- }
- else {
- curimage = ima;
- }
+ if (efa_act) {
+ ED_object_get_active_image(obedit, efa_act->mat_nr + 1, &curimage, NULL, NULL, NULL);
}
else {
- curimage = (efa_act) ? BKE_object_material_edit_image_get(obedit, efa_act->mat_nr) : ima;
+ curimage = ima;
}
- draw_uvs_other(view_layer, obedit, curimage, new_shading_nodes, sima->other_uv_filter);
+ draw_uvs_other(view_layer, obedit, curimage, sima->other_uv_filter);
}
/* 1. draw shadow mesh */
@@ -718,7 +665,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_TRIS, tri_count * 3);
+ Gwn_Batch *face_batch = immBeginBatch(GWN_PRIM_TRIS, tri_count * 3);
for (unsigned int i = 0; i < em->tottri; i++) {
efa = em->looptris[i][0]->f;
if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
@@ -739,6 +686,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
}
immEnd();
+ /* XXX performance: we should not create and throw away result. */
+ GWN_batch_draw(face_batch);
+ GWN_batch_program_use_end(face_batch);
+ GWN_batch_discard(face_batch);
+
immUnbindProgram();
glDisable(GL_BLEND);
@@ -800,8 +752,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
}
/* For more efficiency first transfer the entire buffer to vram. */
- Gwn_Batch *uv_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop);
- Gwn_VertBuf* uv_vbo = uv_batch->verts[0];
+ Gwn_Batch *loop_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop);
+ Gwn_VertBuf* loop_vbo = loop_batch->verts[0];
BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
@@ -814,120 +766,123 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
immEnd();
/* Then draw each face contour separately. */
- GWN_batch_program_use_begin(uv_batch);
- unsigned int index = 0, vbo_len_used;
- BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
- continue;
+ if (loop_vbo->vertex_ct != 0) {
+ GWN_batch_program_use_begin(loop_batch);
+ unsigned int index = 0, loop_vbo_count;
+ BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ continue;
- GWN_batch_draw_range_ex(uv_batch, index, efa->len, false);
- index += efa->len;
- }
- vbo_len_used = index;
- GWN_batch_program_use_end(uv_batch);
- immUnbindProgram();
+ GWN_batch_draw_range_ex(loop_batch, index, efa->len, false);
+ index += efa->len;
+ }
+ loop_vbo_count = index;
+ GWN_batch_program_use_end(loop_batch);
+ immUnbindProgram();
- if (sima->dt_uv == SI_UVDT_OUTLINE) {
- glLineWidth(1.0f);
- UI_GetThemeColor4fv(TH_WIRE_EDIT, col2);
+ if (sima->dt_uv == SI_UVDT_OUTLINE) {
+ glLineWidth(1.0f);
+ UI_GetThemeColor4fv(TH_WIRE_EDIT, col2);
+
+ if (me->drawflag & ME_DRAWEDGES) {
+ int sel;
+ UI_GetThemeColor4fv(TH_EDGE_SELECT, col1);
+
+ if (interpedges) {
+ /* Create a color buffer. */
+ static Gwn_VertFormat format = { 0 };
+ static uint shdr_col;
+ if (format.attrib_ct == 0) {
+ shdr_col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ }
- if (me->drawflag & ME_DRAWEDGES) {
- int sel;
- UI_GetThemeColor4fv(TH_EDGE_SELECT, col1);
+ Gwn_VertBuf *vbo_col = GWN_vertbuf_create_with_format(&format);
+ GWN_vertbuf_data_alloc(vbo_col, loop_vbo_count);
- if (interpedges) {
- /* Create a color buffer. */
- static Gwn_VertFormat format = {0};
- static uint shdr_col;
- if (format.attrib_ct == 0) {
- shdr_col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
- }
+ index = 0;
+ BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ continue;
- Gwn_VertBuf *vbo_col = GWN_vertbuf_create_with_format(&format);
- GWN_vertbuf_data_alloc(vbo_col, vbo_len_used);
+ BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
+ sel = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
+ GWN_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2);
+ }
+ }
+ /* Reuse the UV buffer and add the color buffer. */
+ GWN_batch_vertbuf_add_ex(loop_batch, vbo_col, true);
- index = 0;
- BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
- continue;
+ /* Now draw each face contour separately with another builtin program. */
+ GWN_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR);
+ gpuBindMatrices(loop_batch->interface);
- BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
- sel = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
- GWN_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2);
+ GWN_batch_program_use_begin(loop_batch);
+ index = 0;
+ BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ continue;
+
+ GWN_batch_draw_range_ex(loop_batch, index, efa->len, false);
+ index += efa->len;
}
+ GWN_batch_program_use_end(loop_batch);
}
- /* Reuse the UV buffer and add the color buffer. */
- GWN_batch_vertbuf_add_ex(uv_batch, vbo_col, true);
+ else {
+ Gwn_VertFormat *format = immVertexFormat();
+ pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
- /* Now draw each face contour separately with another builtin program. */
- GWN_batch_program_set_builtin(uv_batch, GPU_SHADER_2D_SMOOTH_COLOR);
- gpuBindMatrices(uv_batch->interface);
+ immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- GWN_batch_program_use_begin(uv_batch);
- index = 0;
- BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
- continue;
+ /* Use batch here to avoid problems with `IMM_BUFFER_SIZE`. */
+ Gwn_Batch *flat_edges_batch = immBeginBatchAtMost(GWN_PRIM_LINES, loop_vbo_count * 2);
+ BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ continue;
- GWN_batch_draw_range_ex(uv_batch, index, efa->len, false);
- index += efa->len;
+ BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
+ sel = uvedit_edge_select_test(scene, l, cd_loop_uv_offset);
+ immAttrib4fv(color, sel ? col1 : col2);
+
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ immVertex2fv(pos, luv->uv);
+ luv = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
+ immVertex2fv(pos, luv->uv);
+ }
+ }
+ immEnd();
+
+ GWN_batch_draw(flat_edges_batch);
+ GWN_batch_discard(flat_edges_batch);
+
+ immUnbindProgram();
}
- GWN_batch_program_use_end(uv_batch);
}
else {
- Gwn_VertFormat *format = immVertexFormat();
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ GWN_batch_uniform_4fv(loop_batch, "color", col2);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
-
- /* Use batch here to avoid problems with `IMM_BUFFER_SIZE`. */
- Gwn_Batch *flat_edges_batch = immBeginBatchAtMost(GWN_PRIM_LINES, vbo_len_used * 2);
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ /* no nice edges */
+ GWN_batch_program_use_begin(loop_batch);
+ index = 0;
+ BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- sel = uvedit_edge_select_test(scene, l, cd_loop_uv_offset);
- immAttrib4fv(color, sel ? col1 : col2);
-
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- immVertex2fv(pos, luv->uv);
- luv = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
- immVertex2fv(pos, luv->uv);
- }
+ GWN_batch_draw_range_ex(loop_batch, index, efa->len, false);
+ index += efa->len;
}
- immEnd();
-
- GWN_batch_draw(flat_edges_batch);
- GWN_vertbuf_discard(flat_edges_batch->verts[0]);
- GWN_batch_discard(flat_edges_batch);
-
+ GWN_batch_program_use_end(loop_batch);
immUnbindProgram();
}
}
- else {
- GWN_batch_uniform_4fv(uv_batch, "color", col2);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- /* no nice edges */
- GWN_batch_program_use_begin(uv_batch);
- index = 0;
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
- continue;
-
- GWN_batch_draw_range_ex(uv_batch, index, efa->len, false);
- index += efa->len;
- }
- GWN_batch_program_use_end(uv_batch);
- immUnbindProgram();
- }
+ }
+ else {
+ immUnbindProgram();
}
- GWN_vertbuf_discard(uv_vbo);
- GWN_batch_discard(uv_batch);
+ GWN_batch_discard(loop_batch);
if (sima->flag & SI_SMOOTH_UV) {
glDisable(GL_LINE_SMOOTH);
@@ -1100,12 +1055,21 @@ void ED_uvedit_draw_main(
draw_uv_shadows_get(sima, obact, obedit, &show_uvshadow, &show_texpaint_uvshadow);
if (show_uvedit || show_uvshadow || show_texpaint_uvshadow) {
- if (show_uvshadow)
+ if (show_uvshadow) {
draw_uvs_shadow(obedit);
- else if (show_uvedit)
- draw_uvs(sima, scene, view_layer, obedit, depsgraph);
- else
+ }
+ else if (show_uvedit) {
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ draw_uvs(sima, scene, view_layer, ob_iter, depsgraph);
+ }
+ MEM_SAFE_FREE(objects);
+ }
+ else {
draw_uvs_texpaint(sima, scene, view_layer, obact);
+ }
if (show_uvedit && !(toolsettings->use_uv_sculpt))
ED_image_draw_cursor(ar, sima->cursor);
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index c5f16d6fb14..e3db0162f10 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -51,6 +51,8 @@ void uv_poly_center(struct BMFace *f, float r_cent[2], const int cd_loop_uv_off
/* find nearest */
typedef struct UvNearestHit {
+ /** Only for `*_multi(..)` versions of functions. */
+ struct Object *ob;
/** Always set if we have a hit. */
struct BMFace *efa;
struct BMLoop *l;
@@ -66,14 +68,23 @@ typedef struct UvNearestHit {
bool uv_find_nearest_vert(
struct Scene *scene, struct Image *ima, struct Object *obedit,
const float co[2], const float penalty_dist, struct UvNearestHit *hit_final);
+bool uv_find_nearest_vert_multi(
+ struct Scene *scene, struct Image *ima, struct Object **objects, const uint objects_len,
+ const float co[2], const float penalty_dist, struct UvNearestHit *hit_final);
bool uv_find_nearest_edge(
struct Scene *scene, struct Image *ima, struct Object *obedit,
const float co[2], struct UvNearestHit *hit_final);
+bool uv_find_nearest_edge_multi(
+ struct Scene *scene, struct Image *ima, struct Object **objects, const uint objects_len,
+ const float co[2], struct UvNearestHit *hit_final);
bool uv_find_nearest_face(
struct Scene *scene, struct Image *ima, struct Object *obedit,
const float co[2], struct UvNearestHit *hit_final);
+bool uv_find_nearest_face_multi(
+ struct Scene *scene, struct Image *ima, struct Object **objects, const uint objects_len,
+ const float co[2], struct UvNearestHit *hit_final);
/* utility tool functions */
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 9df0c7c89ed..6fa75b0a2b3 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -66,6 +66,7 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_editmesh.h"
+#include "BKE_layer.h"
#include "DEG_depsgraph.h"
@@ -89,7 +90,10 @@
#include "uvedit_intern.h"
-static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, BMEditMesh *em, int action);
+static bool uv_select_is_any_selected(Scene *scene, Image *ima, Object *obedit);
+static bool uv_select_is_any_selected_multi(Scene *scene, Image *ima, Object **objects, const uint objects_len);
+static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, int action);
+static void uv_select_all_perform_multi(Scene *scene, Image *ima, Object **objects, const uint objects_len, int action);
static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object *obedit, const bool select);
static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object *obedit, const bool select);
@@ -191,93 +195,6 @@ void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *i
//#define USE_SWITCH_ASPECT
-void ED_uvedit_assign_image(Main *UNUSED(bmain), Scene *scene, Object *obedit, Image *ima, Image *previma)
-{
- BMEditMesh *em;
- BMIter iter;
- bool update = false;
- const bool selected = !(scene->toolsettings->uv_flag & UV_SYNC_SELECTION);
-
- /* skip assigning these procedural images... */
- if (ima && (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE))
- return;
-
- /* verify we have a mesh we can work with */
- if (!obedit || (obedit->type != OB_MESH))
- return;
-
- em = BKE_editmesh_from_object(obedit);
- if (!em || !em->bm->totface) {
- return;
- }
-
- if (BKE_scene_use_new_shading_nodes(scene)) {
- /* new shading system, do not assign anything */
- }
- else {
- BMFace *efa;
-
- int cd_loop_uv_offset;
- /* old shading system, assign image to selected faces */
-#ifdef USE_SWITCH_ASPECT
- float prev_aspect[2], fprev_aspect;
- float aspect[2], faspect;
-
- ED_image_get_uv_aspect(previma, prev_aspect, prev_aspect + 1);
- ED_image_get_uv_aspect(ima, aspect, aspect + 1);
-
- fprev_aspect = prev_aspect[0] / prev_aspect[1];
- faspect = aspect[0] / aspect[1];
-#endif
-
- /* ensure we have a uv map */
- if (!CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV)) {
- BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPUV);
- /* make UVs all nice 0-1 */
- ED_mesh_uv_loop_reset_ex(obedit->data, CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPUV));
- update = true;
- }
-
- cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-
- /* now assign to all visible faces */
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (uvedit_face_visible_test(scene, obedit, previma, efa) &&
- (selected == true || uvedit_face_select_test(scene, efa, cd_loop_uv_offset)))
- {
-#ifdef USE_SWITCH_ASPECT
- if (ima) {
- /* we also need to correct the aspect of uvs */
- if (scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT) {
- /* do nothing */
- }
- else {
- BMIter liter;
- BMLoop *l;
-
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-
- luv->uv[0] *= fprev_aspect;
- luv->uv[0] /= faspect;
- }
- }
- }
-#endif
- BKE_object_material_edit_image_set(obedit, efa->mat_nr, ima);
-
- update = true;
- }
- }
-
- /* and update depdency graph */
- if (update) {
- DEG_id_tag_update(obedit->data, 0);
- }
- }
-
-}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -336,7 +253,8 @@ bool uvedit_face_visible_test(Scene *scene, Object *obedit, Image *ima, BMFace *
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SHOW_SAME_IMAGE) {
- const Image *face_image = BKE_object_material_edit_image_get(obedit, efa->mat_nr);
+ Image *face_image;
+ ED_object_get_active_image(obedit, efa->mat_nr + 1, &face_image, NULL, NULL, NULL);
return (face_image == ima) ? uvedit_face_visible_nolocal(scene, efa) : false;
}
else {
@@ -794,6 +712,21 @@ bool uv_find_nearest_edge(
return found;
}
+bool uv_find_nearest_edge_multi(
+ Scene *scene, Image *ima, Object **objects, const uint objects_len,
+ const float co[2], UvNearestHit *hit_final)
+{
+ bool found = false;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ if (uv_find_nearest_edge(scene, ima, obedit, co, hit_final)) {
+ hit_final->ob = obedit;
+ found = true;
+ }
+ }
+ return found;
+}
+
bool uv_find_nearest_face(
Scene *scene, Image *ima, Object *obedit, const float co[2],
UvNearestHit *hit_final)
@@ -837,6 +770,21 @@ bool uv_find_nearest_face(
return found;
}
+bool uv_find_nearest_face_multi(
+ Scene *scene, Image *ima, Object **objects, const uint objects_len,
+ const float co[2], UvNearestHit *hit_final)
+{
+ bool found = false;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ if (uv_find_nearest_face(scene, ima, obedit, co, hit_final)) {
+ hit_final->ob = obedit;
+ found = true;
+ }
+ }
+ return found;
+}
+
static bool uv_nearest_between(
const BMLoop *l, const float co[2],
const int cd_loop_uv_offset)
@@ -918,6 +866,21 @@ bool uv_find_nearest_vert(
return found;
}
+bool uv_find_nearest_vert_multi(
+ Scene *scene, Image *ima, Object **objects, const uint objects_len,
+ float const co[2], const float penalty_dist, UvNearestHit *hit_final)
+{
+ bool found = false;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ if (uv_find_nearest_vert(scene, ima, obedit, co, penalty_dist, hit_final)) {
+ hit_final->ob = obedit;
+ found = true;
+ }
+ }
+ return found;
+}
+
bool ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float co[2], float r_uv[2])
{
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -1043,9 +1006,10 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1,
}
static int uv_select_edgeloop(
- Scene *scene, Image *ima, Object *obedit, BMEditMesh *em, UvNearestHit *hit,
+ Scene *scene, Image *ima, Object *obedit, UvNearestHit *hit,
const float limit[2], const bool extend)
{
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMFace *efa;
BMIter iter, liter;
BMLoop *l;
@@ -1064,7 +1028,7 @@ static int uv_select_edgeloop(
BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
if (!extend) {
- uv_select_all_perform(scene, ima, obedit, em, SEL_DESELECT);
+ uv_select_all_perform(scene, ima, obedit, SEL_DESELECT);
}
BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false);
@@ -1147,168 +1111,133 @@ static int uv_select_edgeloop(
/** \name Select Linked
* \{ */
-static void uv_select_linked(
- Scene *scene, Image *ima, Object *obedit, BMEditMesh *em, const float limit[2],
+static void uv_select_linked_multi(
+ Scene *scene, Image *ima, Object **objects, const uint objects_len, const float limit[2],
UvNearestHit *hit_final, bool extend, bool select_faces)
{
- BMFace *efa;
- BMLoop *l;
- BMIter iter, liter;
- MLoopUV *luv;
- UvVertMap *vmap;
- UvMapVert *vlist, *iterv, *startv;
- int i, stacksize = 0, *stack;
- unsigned int a;
- char *flag;
+ /* loop over objects, or just use hit_final->ob */
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ if (hit_final && ob_index != 0) {
+ break;
+ }
+ Object *obedit = hit_final ? hit_final->ob : objects[ob_index];
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ BMFace *efa;
+ BMLoop *l;
+ BMIter iter, liter;
+ MLoopUV *luv;
+ UvVertMap *vmap;
+ UvMapVert *vlist, *iterv, *startv;
+ int i, stacksize = 0, *stack;
+ unsigned int a;
+ char *flag;
- BM_mesh_elem_table_ensure(em->bm, BM_FACE); /* we can use this too */
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- /* Note, we had 'use winding' so we don't consider overlapping islands as connected, see T44320
- * this made *every* projection split the island into front/back islands.
- * Keep 'use_winding' to false, see: T50970.
- *
- * Better solve this by having a delimit option for select-linked operator,
- * keeping island-select working as is. */
- vmap = BM_uv_vert_map_create(em->bm, limit, !select_faces, false);
+ BM_mesh_elem_table_ensure(em->bm, BM_FACE); /* we can use this too */
- if (vmap == NULL)
- return;
+ /* Note, we had 'use winding' so we don't consider overlapping islands as connected, see T44320
+ * this made *every* projection split the island into front/back islands.
+ * Keep 'use_winding' to false, see: T50970.
+ *
+ * Better solve this by having a delimit option for select-linked operator,
+ * keeping island-select working as is. */
+ vmap = BM_uv_vert_map_create(em->bm, limit, !select_faces, false);
- stack = MEM_mallocN(sizeof(*stack) * (em->bm->totface + 1), "UvLinkStack");
- flag = MEM_callocN(sizeof(*flag) * em->bm->totface, "UvLinkFlag");
+ if (vmap == NULL)
+ return;
- if (hit_final == NULL) {
- /* Use existing selection */
- BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, a) {
- if (uvedit_face_visible_test(scene, obedit, ima, efa)) {
- if (select_faces) {
- if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
- stack[stacksize] = a;
- stacksize++;
- flag[a] = 1;
- }
- }
- else {
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ stack = MEM_mallocN(sizeof(*stack) * (em->bm->totface + 1), "UvLinkStack");
+ flag = MEM_callocN(sizeof(*flag) * em->bm->totface, "UvLinkFlag");
- if (luv->flag & MLOOPUV_VERTSEL) {
+ if (hit_final == NULL) {
+ /* Use existing selection */
+ BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, a) {
+ if (uvedit_face_visible_test(scene, obedit, ima, efa)) {
+ if (select_faces) {
+ if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
stack[stacksize] = a;
stacksize++;
flag[a] = 1;
+ }
+ }
+ else {
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- break;
+ if (luv->flag & MLOOPUV_VERTSEL) {
+ stack[stacksize] = a;
+ stacksize++;
+ flag[a] = 1;
+
+ break;
+ }
}
}
}
}
}
- }
- else {
- BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, a) {
- if (efa == hit_final->efa) {
- stack[stacksize] = a;
- stacksize++;
- flag[a] = 1;
- break;
+ else {
+ BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, a) {
+ if (efa == hit_final->efa) {
+ stack[stacksize] = a;
+ stacksize++;
+ flag[a] = 1;
+ break;
+ }
}
}
- }
-
- while (stacksize > 0) {
- stacksize--;
- a = stack[stacksize];
+ while (stacksize > 0) {
- efa = BM_face_at_index(em->bm, a);
+ stacksize--;
+ a = stack[stacksize];
- 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 = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
-
- startv = vlist;
+ efa = BM_face_at_index(em->bm, a);
- for (iterv = vlist; iterv; iterv = iterv->next) {
- if (iterv->separate)
- startv = iterv;
- if (iterv->f == a)
- break;
- }
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
- for (iterv = startv; iterv; iterv = iterv->next) {
- if ((startv != iterv) && (iterv->separate))
- break;
- else if (!flag[iterv->f]) {
- flag[iterv->f] = 1;
- stack[stacksize] = iterv->f;
- stacksize++;
- }
- }
- }
- }
+ /* make_uv_vert_map_EM sets verts tmp.l to the indices */
+ vlist = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
- if (!extend) {
- BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, a) {
- if (select_faces) {
- if (flag[a])
- BM_face_select_set(em->bm, efa, true);
- else
- BM_face_select_set(em->bm, efa, false);
- }
- else {
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ startv = vlist;
- if (flag[a])
- luv->flag |= MLOOPUV_VERTSEL;
- else
- luv->flag &= ~MLOOPUV_VERTSEL;
+ for (iterv = vlist; iterv; iterv = iterv->next) {
+ if (iterv->separate)
+ startv = iterv;
+ if (iterv->f == a)
+ break;
}
- }
- }
- }
- else {
- BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, a) {
- if (!flag[a]) {
- continue;
- }
-
- if (select_faces) {
- if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
- break;
- }
- else {
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- if (luv->flag & MLOOPUV_VERTSEL) {
+ for (iterv = startv; iterv; iterv = iterv->next) {
+ if ((startv != iterv) && (iterv->separate))
break;
+ else if (!flag[iterv->f]) {
+ flag[iterv->f] = 1;
+ stack[stacksize] = iterv->f;
+ stacksize++;
}
}
-
- if (l) {
- break;
- }
}
}
- if (efa) {
+ if (!extend) {
BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, a) {
- if (!flag[a]) {
- continue;
- }
-
if (select_faces) {
- BM_face_select_set(em->bm, efa, false);
+ if (flag[a])
+ BM_face_select_set(em->bm, efa, true);
+ else
+ BM_face_select_set(em->bm, efa, false);
}
else {
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- luv->flag &= ~MLOOPUV_VERTSEL;
+ if (flag[a])
+ luv->flag |= MLOOPUV_VERTSEL;
+ else
+ luv->flag &= ~MLOOPUV_VERTSEL;
}
}
}
@@ -1320,22 +1249,66 @@ static void uv_select_linked(
}
if (select_faces) {
- BM_face_select_set(em->bm, efa, true);
+ if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ break;
}
else {
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- luv->flag |= MLOOPUV_VERTSEL;
+ if (luv->flag & MLOOPUV_VERTSEL) {
+ break;
+ }
+ }
+
+ if (l) {
+ break;
+ }
+ }
+ }
+
+ if (efa) {
+ BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, a) {
+ if (!flag[a]) {
+ continue;
+ }
+
+ if (select_faces) {
+ BM_face_select_set(em->bm, efa, false);
+ }
+ else {
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+
+ luv->flag &= ~MLOOPUV_VERTSEL;
+ }
+ }
+ }
+ }
+ else {
+ BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, a) {
+ if (!flag[a]) {
+ continue;
+ }
+
+ if (select_faces) {
+ BM_face_select_set(em->bm, efa, true);
+ }
+ else {
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+
+ luv->flag |= MLOOPUV_VERTSEL;
+ }
}
}
}
}
+
+ MEM_freeN(stack);
+ MEM_freeN(flag);
+ BM_uv_vert_map_free(vmap);
}
-
- MEM_freeN(stack);
- MEM_freeN(flag);
- BM_uv_vert_map_free(vmap);
}
/* WATCH IT: this returns first selected UV,
@@ -1957,9 +1930,53 @@ static void UV_OT_weld(wmOperatorType *ot)
/** \name (De)Select All Operator
* \{ */
-static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, BMEditMesh *em, int action)
+
+static bool uv_select_is_any_selected(Scene *scene, Image *ima, Object *obedit)
+{
+ ToolSettings *ts = scene->toolsettings;
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMFace *efa;
+ BMLoop *l;
+ BMIter iter, liter;
+ MLoopUV *luv;
+
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ return (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel);
+ }
+ else {
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
+ continue;
+ }
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ if (luv->flag & MLOOPUV_VERTSEL) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+static bool uv_select_is_any_selected_multi(Scene *scene, Image *ima, Object **objects, const uint objects_len)
+{
+ bool found = false;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ if (uv_select_is_any_selected(scene, ima, obedit)) {
+ found = true;
+ break;
+ }
+ }
+ return found;
+}
+
+static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, int action)
{
ToolSettings *ts = scene->toolsettings;
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMFace *efa;
BMLoop *l;
BMIter iter, liter;
@@ -1967,8 +1984,11 @@ static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, BMEd
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (action == SEL_TOGGLE) {
+ action = uv_select_is_any_selected(scene, ima, obedit) ? SEL_DESELECT : SEL_SELECT;
+ }
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
switch (action) {
case SEL_TOGGLE:
EDBM_select_toggle_all(em);
@@ -1986,24 +2006,6 @@ static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, BMEd
}
}
else {
- if (action == SEL_TOGGLE) {
- action = SEL_SELECT;
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
- continue;
-
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-
- if (luv->flag & MLOOPUV_VERTSEL) {
- action = SEL_DESELECT;
- break;
- }
- }
- }
- }
-
-
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (!uvedit_face_visible_test(scene, obedit, ima, efa))
continue;
@@ -2027,18 +2029,38 @@ static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, BMEd
}
}
+static void uv_select_all_perform_multi(
+ Scene *scene, Image *ima, Object **objects, const uint objects_len, int action)
+{
+ if (action == SEL_TOGGLE) {
+ action = uv_select_is_any_selected_multi(scene, ima, objects, objects_len) ? SEL_DESELECT : SEL_SELECT;
+ }
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ uv_select_all_perform(scene, ima, obedit, action);
+ }
+}
+
static int uv_select_all_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
Image *ima = CTX_data_edit_image(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
int action = RNA_enum_get(op->ptr, "action");
- uv_select_all_perform(scene, ima, obedit, em, action);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, action);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
+
+ MEM_SAFE_FREE(objects);
return OPERATOR_FINISHED;
}
@@ -2087,14 +2109,14 @@ static bool uv_sticky_select(float *limit, int hitv[], int v, float *hituv[], fl
return false;
}
-static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loop)
+static int uv_mouse_select_multi(
+ bContext *C, Object **objects, uint objects_len,
+ const float co[2], bool extend, bool loop)
{
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
- Object *obedit = CTX_data_edit_object(C);
Image *ima = CTX_data_edit_image(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMFace *efa;
BMLoop *l;
BMIter iter, liter;
@@ -2105,8 +2127,6 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
int flush = 0, hitlen = 0; /* 0 == don't flush, 1 == sel, -1 == desel; only use when selection sync is enabled */
float limit[2], **hituv = NULL;
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-
/* notice 'limit' is the same no matter the zoom level, since this is like
* remove doubles and could annoying if it joined points when zoomed out.
* 'penalty' is in screen pixel space otherwise zooming in on a uv-vert and
@@ -2143,7 +2163,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
/* find nearest element */
if (loop) {
/* find edge */
- if (!uv_find_nearest_edge(scene, ima, obedit, co, &hit)) {
+ if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
return OPERATOR_CANCELLED;
}
@@ -2151,7 +2171,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
}
else if (selectmode == UV_SELECT_VERTEX) {
/* find vertex */
- if (!uv_find_nearest_vert(scene, ima, obedit, co, penalty_dist, &hit)) {
+ if (!uv_find_nearest_vert_multi(scene, ima, objects, objects_len, co, penalty_dist, &hit)) {
return OPERATOR_CANCELLED;
}
@@ -2167,7 +2187,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
}
else if (selectmode == UV_SELECT_EDGE) {
/* find edge */
- if (!uv_find_nearest_edge(scene, ima, obedit, co, &hit)) {
+ if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
return OPERATOR_CANCELLED;
}
@@ -2185,10 +2205,13 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
}
else if (selectmode == UV_SELECT_FACE) {
/* find face */
- if (!uv_find_nearest_face(scene, ima, obedit, co, &hit)) {
+ if (!uv_find_nearest_face_multi(scene, ima, objects, objects_len, co, &hit)) {
return OPERATOR_CANCELLED;
}
+ BMEditMesh *em = BKE_editmesh_from_object(hit.ob);
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+
/* make active */
BM_mesh_active_face_set(em->bm, hit.efa);
@@ -2205,7 +2228,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
hitlen = hit.efa->len;
}
else if (selectmode == UV_SELECT_ISLAND) {
- if (!uv_find_nearest_edge(scene, ima, obedit, co, &hit)) {
+ if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
return OPERATOR_CANCELLED;
}
@@ -2216,12 +2239,24 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
return OPERATOR_CANCELLED;
}
+ Object *obedit = hit.ob;
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+
/* do selection */
if (loop) {
- flush = uv_select_edgeloop(scene, ima, obedit, em, &hit, limit, extend);
+ if (!extend) {
+ /* TODO(MULTI_EDIT): We only need to de-select non-active */
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
+ }
+ flush = uv_select_edgeloop(scene, ima, obedit, &hit, limit, extend);
}
else if (selectmode == UV_SELECT_ISLAND) {
- uv_select_linked(scene, ima, obedit, em, limit, &hit, extend, false);
+ if (!extend) {
+ /* TODO(MULTI_EDIT): We only need to de-select non-active */
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
+ }
+ uv_select_linked_multi(scene, ima, objects, objects_len, limit, &hit, extend, false);
}
else if (extend) {
if (selectmode == UV_SELECT_VERTEX) {
@@ -2271,7 +2306,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
}
else {
/* deselect all */
- uv_select_all_perform(scene, ima, obedit, em, SEL_DESELECT);
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
if (selectmode == UV_SELECT_VERTEX) {
/* select vertex */
@@ -2339,6 +2374,15 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED;
}
+static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loop)
+{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ int ret = uv_mouse_select_multi(C, objects, objects_len, co, extend, loop);
+ MEM_freeN(objects);
+ return ret;
+}
static int uv_select_exec(bContext *C, wmOperator *op)
{
@@ -2443,9 +2487,8 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
- Object *obedit = CTX_data_edit_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
Image *ima = CTX_data_edit_image(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
float limit[2];
int extend;
bool select_faces = (ts->uv_flag & UV_SYNC_SELECTION) && (ts->selectmode & SCE_SELECT_FACE);
@@ -2460,6 +2503,9 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
extend = RNA_boolean_get(op->ptr, "extend");
uvedit_pixel_to_float(sima, limit, 0.05f);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+
if (pick) {
float co[2];
@@ -2475,15 +2521,32 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
RNA_float_get_array(op->ptr, "location", co);
}
- if (!uv_find_nearest_edge(scene, ima, obedit, co, &hit)) {
+ if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
+ MEM_SAFE_FREE(objects);
return OPERATOR_CANCELLED;
}
}
- uv_select_linked(scene, ima, obedit, em, limit, pick ? &hit : NULL, extend, select_faces);
+ if (!extend) {
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
+ }
- DEG_id_tag_update(obedit->data, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ uv_select_linked_multi(scene, ima, objects, objects_len, limit, pick ? &hit : NULL, extend, select_faces);
+
+ /* weak!, but works */
+ Object **objects_free = objects;
+ if (pick) {
+ objects = &hit.ob;
+ objects_len = 1;
+ }
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ DEG_id_tag_update(obedit->data, 0);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
+
+ MEM_SAFE_FREE(objects_free);
return OPERATOR_FINISHED;
}
@@ -2879,23 +2942,20 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
- Object *obedit = CTX_data_edit_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
Image *ima = CTX_data_edit_image(C);
ARegion *ar = CTX_wm_region(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMFace *efa;
BMLoop *l;
BMIter iter, liter;
MLoopUV *luv;
rctf rectf;
- bool changed, pinned, select, extend;
+ bool pinned, select, extend;
const bool use_face_center = (
(ts->uv_flag & UV_SYNC_SELECTION) ?
(ts->selectmode == SCE_SELECT_FACE) :
(ts->uv_selectmode == UV_SELECT_FACE));
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-
/* get rectangle from operator */
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf);
@@ -2905,79 +2965,96 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
extend = RNA_boolean_get(op->ptr, "extend");
pinned = RNA_boolean_get(op->ptr, "pinned");
- if (!extend)
- uv_select_all_perform(scene, ima, obedit, em, SEL_DESELECT);
+ bool changed_multi = false;
- /* do actual selection */
- if (use_face_center && !pinned) {
- /* handle face selection mode */
- float cent[2];
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
- changed = false;
+ /* don't indent to avoid diff noise! */
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- /* assume not touched */
- BM_elem_flag_disable(efa, BM_ELEM_TAG);
+ bool changed = false;
- if (uvedit_face_visible_test(scene, obedit, ima, efa)) {
- uv_poly_center(efa, cent, cd_loop_uv_offset);
- if (BLI_rctf_isect_pt_v(&rectf, cent)) {
- BM_elem_flag_enable(efa, BM_ELEM_TAG);
- changed = true;
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+
+ if (!extend)
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
+
+ /* do actual selection */
+ if (use_face_center && !pinned) {
+ /* handle face selection mode */
+ float cent[2];
+
+ changed = false;
+
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ /* assume not touched */
+ BM_elem_flag_disable(efa, BM_ELEM_TAG);
+
+ if (uvedit_face_visible_test(scene, obedit, ima, efa)) {
+ uv_poly_center(efa, cent, cd_loop_uv_offset);
+ if (BLI_rctf_isect_pt_v(&rectf, cent)) {
+ BM_elem_flag_enable(efa, BM_ELEM_TAG);
+ changed = true;
+ }
}
}
- }
- /* (de)selects all tagged faces and deals with sticky modes */
- if (changed) {
- uv_select_flush_from_tag_face(sima, scene, obedit, select);
+ /* (de)selects all tagged faces and deals with sticky modes */
+ if (changed) {
+ uv_select_flush_from_tag_face(sima, scene, obedit, select);
+ }
}
- }
- else {
- /* other selection modes */
- changed = true;
- BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
+ else {
+ /* other selection modes */
+ changed = true;
+ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
- continue;
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ continue;
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION)) {
+ if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION)) {
- /* UV_SYNC_SELECTION - can't do pinned selection */
- if (BLI_rctf_isect_pt_v(&rectf, luv->uv)) {
- uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
- BM_elem_flag_enable(l->v, BM_ELEM_TAG);
+ /* UV_SYNC_SELECTION - can't do pinned selection */
+ if (BLI_rctf_isect_pt_v(&rectf, luv->uv)) {
+ uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+ BM_elem_flag_enable(l->v, BM_ELEM_TAG);
+ }
}
- }
- else if (pinned) {
- if ((luv->flag & MLOOPUV_PINNED) && BLI_rctf_isect_pt_v(&rectf, luv->uv)) {
- uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
- BM_elem_flag_enable(l->v, BM_ELEM_TAG);
+ else if (pinned) {
+ if ((luv->flag & MLOOPUV_PINNED) && BLI_rctf_isect_pt_v(&rectf, luv->uv)) {
+ uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+ BM_elem_flag_enable(l->v, BM_ELEM_TAG);
+ }
}
}
}
- }
- if (sima->sticky == SI_STICKY_VERTEX) {
- uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset);
+ if (sima->sticky == SI_STICKY_VERTEX) {
+ uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset);
+ }
}
- }
- if (changed) {
- uv_select_sync_flush(ts, em, select);
+ if (changed) {
+ changed_multi = true;
+
+ uv_select_sync_flush(ts, em, select);
- if (ts->uv_flag & UV_SYNC_SELECTION) {
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
}
-
- return OPERATOR_FINISHED;
}
- return OPERATOR_CANCELLED;
-}
+ MEM_SAFE_FREE(objects);
+
+ return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+}
static void UV_OT_select_border(wmOperatorType *ot)
{
@@ -3131,99 +3208,112 @@ static void UV_OT_circle_select(wmOperatorType *ot)
/** \name Lasso Select Operator
* \{ */
-static bool do_lasso_select_mesh_uv(
- bContext *C, const int mcords[][2], short moves,
- const bool select, const bool extend)
+static bool do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short moves,
+ const bool select, const bool extend)
{
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = CTX_data_edit_image(C);
ARegion *ar = CTX_wm_region(C);
- Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
const bool use_face_center = (
(ts->uv_flag & UV_SYNC_SELECTION) ?
(ts->selectmode == SCE_SELECT_FACE) :
(ts->uv_selectmode == UV_SELECT_FACE));
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BMIter iter, liter;
BMFace *efa;
BMLoop *l;
int screen_uv[2];
- bool changed = false;
+ bool changed_multi = false;
rcti rect;
BLI_lasso_boundbox(&rect, mcords, moves);
- if (!extend && select) {
- uv_select_all_perform(scene, ima, obedit, em, SEL_DESELECT);
- }
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
- if (use_face_center) { /* Face Center Sel */
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- BM_elem_flag_disable(efa, BM_ELEM_TAG);
- /* assume not touched */
- if (select != uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) {
- float cent[2];
- uv_poly_center(efa, cent, cd_loop_uv_offset);
+ /* don't indent to avoid diff noise! */
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
- if (UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]) &&
- BLI_rcti_isect_pt_v(&rect, screen_uv) &&
- BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED))
- {
- BM_elem_flag_enable(efa, BM_ELEM_TAG);
- changed = true;
+ bool changed = false;
+
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+
+ if (!extend && select) {
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
+ }
+
+ if (use_face_center) { /* Face Center Sel */
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ BM_elem_flag_disable(efa, BM_ELEM_TAG);
+ /* assume not touched */
+ if (select != uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) {
+ float cent[2];
+ uv_poly_center(efa, cent, cd_loop_uv_offset);
+
+ if (UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]) &&
+ BLI_rcti_isect_pt_v(&rect, screen_uv) &&
+ BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED))
+ {
+ BM_elem_flag_enable(efa, BM_ELEM_TAG);
+ changed = true;
+ }
}
}
- }
- /* (de)selects all tagged faces and deals with sticky modes */
- if (changed) {
- uv_select_flush_from_tag_face(sima, scene, obedit, select);
+ /* (de)selects all tagged faces and deals with sticky modes */
+ if (changed) {
+ uv_select_flush_from_tag_face(sima, scene, obedit, select);
+ }
}
- }
- else { /* Vert Sel */
- BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
+ else { /* Vert Sel */
+ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (uvedit_face_visible_test(scene, obedit, ima, efa)) {
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if ((select) != (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))) {
- MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- if (UI_view2d_view_to_region_clip(
- &ar->v2d,
- luv->uv[0], luv->uv[1],
- &screen_uv[0], &screen_uv[1]) &&
- BLI_rcti_isect_pt_v(&rect, screen_uv) &&
- BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED))
- {
- uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
- changed = true;
- BM_elem_flag_enable(l->v, BM_ELEM_TAG);
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (uvedit_face_visible_test(scene, obedit, ima, efa)) {
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ if ((select) != (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))) {
+ MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ if (UI_view2d_view_to_region_clip(
+ &ar->v2d,
+ luv->uv[0], luv->uv[1],
+ &screen_uv[0], &screen_uv[1]) &&
+ BLI_rcti_isect_pt_v(&rect, screen_uv) &&
+ BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED))
+ {
+ uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+ changed = true;
+ BM_elem_flag_enable(l->v, BM_ELEM_TAG);
+ }
}
}
}
}
- }
- if (sima->sticky == SI_STICKY_VERTEX) {
- uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset);
+ if (sima->sticky == SI_STICKY_VERTEX) {
+ uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset);
+ }
}
- }
- if (changed) {
- uv_select_sync_flush(scene->toolsettings, em, select);
+ if (changed) {
+ changed_multi = true;
- if (ts->uv_flag & UV_SYNC_SELECTION) {
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ uv_select_sync_flush(scene->toolsettings, em, select);
+
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
}
}
- return changed;
+ return changed_multi;
}
static int uv_lasso_select_exec(bContext *C, wmOperator *op)
@@ -4175,7 +4265,7 @@ static int uv_mark_seam_exec(bContext *C, wmOperator *op)
me->drawflag |= ME_DRAWSEAMS;
if (scene->toolsettings->edge_mode_live_unwrap)
- ED_unwrap_lscm(scene, ob, false);
+ ED_unwrap_lscm(scene, ob, false, false);
DEG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 4f28d1f9eea..1442266a3aa 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -61,6 +61,7 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_editmesh.h"
+#include "BKE_layer.h"
#include "DEG_depsgraph.h"
@@ -102,9 +103,8 @@ static void modifier_unwrap_state(Object *obedit, Scene *scene, bool *r_use_subs
*r_use_subsurf = subsurf;
}
-static bool ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
+static bool ED_uvedit_ensure_uvs(bContext *C, Scene *UNUSED(scene), Object *obedit)
{
- Main *bmain = CTX_data_main(C);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMFace *efa;
BMIter iter;
@@ -148,9 +148,6 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
}
}
- if (ima)
- ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL);
-
/* select new UV's (ignore UV_SYNC_SELECTION in this case) */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
BMIter liter;
@@ -202,7 +199,22 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, bool implicit)
return false;
}
-void ED_uvedit_get_aspect(Scene *scene, Object *ob, BMesh *bm, float *aspx, float *aspy)
+static bool uvedit_have_selection_multi(
+ Scene *scene, Object **objects, const uint objects_len, bool implicit)
+{
+ bool have_select = false;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ if (uvedit_have_selection(scene, em, implicit)) {
+ have_select = true;
+ break;
+ }
+ }
+ return have_select;
+}
+
+void ED_uvedit_get_aspect(Scene *UNUSED(scene), Object *ob, BMesh *bm, float *aspx, float *aspy)
{
bool sloppy = true;
bool selected = false;
@@ -212,12 +224,7 @@ void ED_uvedit_get_aspect(Scene *scene, Object *ob, BMesh *bm, float *aspx, floa
efa = BM_mesh_active_face_get(bm, sloppy, selected);
if (efa) {
- if (BKE_scene_use_new_shading_nodes(scene)) {
- ED_object_get_active_image(ob, efa->mat_nr + 1, &ima, NULL, NULL, NULL);
- }
- else {
- ima = BKE_object_material_edit_image_get(ob, efa->mat_nr);
- }
+ ED_object_get_active_image(ob, efa->mat_nr + 1, &ima, NULL, NULL, NULL);
ED_image_get_uv_aspect(ima, NULL, aspx, aspy);
}
@@ -258,9 +265,11 @@ static void construct_param_handle_face_add(ParamHandle *handle, Scene *scene,
param_face_add(handle, key, i, vkeys, co, uv, pin, select, efa->no);
}
-static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm,
- const bool implicit, const bool fill, const bool sel,
- const bool correct_aspect)
+/* See: construct_param_handle_multi to handle multiple objects at once. */
+static ParamHandle *construct_param_handle(
+ Scene *scene, Object *ob, BMesh *bm,
+ const bool implicit, const bool fill, const bool sel,
+ const bool correct_aspect)
{
ParamHandle *handle;
BMFace *efa;
@@ -324,6 +333,89 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm,
return handle;
}
+/**
+ * Version of #construct_param_handle_single that handles multiple objects.
+ */
+static ParamHandle *construct_param_handle_multi(
+ Scene *scene, Object **objects, const uint objects_len,
+ const bool implicit, const bool fill, const bool sel,
+ const bool correct_aspect)
+{
+ ParamHandle *handle;
+ BMFace *efa;
+ BMLoop *l;
+ BMEdge *eed;
+ BMIter iter, liter;
+ int i;
+
+
+ handle = param_construct_begin();
+
+ if (correct_aspect) {
+ Object *ob = objects[0];
+ BMEditMesh *em = BKE_editmesh_from_object(ob);
+ BMesh *bm = em->bm;
+ float aspx, aspy;
+
+ ED_uvedit_get_aspect(scene, ob, bm, &aspx, &aspy);
+ if (aspx != aspy) {
+ param_aspect_ratio(handle, aspx, aspy);
+ }
+ }
+
+ /* we need the vert indices */
+ EDBM_mesh_elem_index_ensure_multi(objects, objects_len, BM_VERT);
+
+ int offset = 0;
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+
+ const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
+
+ BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
+
+ if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) {
+ continue;
+ }
+
+ if (implicit) {
+ bool is_loopsel = false;
+
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+ is_loopsel = true;
+ break;
+ }
+ }
+ if (is_loopsel == false) {
+ continue;
+ }
+ }
+
+ construct_param_handle_face_add(handle, scene, efa, i + offset, cd_loop_uv_offset);
+ }
+
+ if (!implicit) {
+ BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
+ ParamKey vkeys[2];
+ vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
+ vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
+ param_edge_set_seam(handle, vkeys);
+ }
+ }
+ }
+ offset += bm->totface;
+ }
+
+ param_construct_end(handle, fill, implicit);
+
+ return handle;
+}
+
static void texface_from_original_index(BMFace *efa, int index, float **uv, ParamBool *pin, ParamBool *select,
Scene *scene, const int cd_loop_uv_offset)
@@ -715,6 +807,7 @@ void UV_OT_minimize_stretch(wmOperatorType *ot)
/* ******************** Pack Islands operator **************** */
+
void ED_uvedit_pack_islands(Scene *scene, Object *ob, BMesh *bm, bool selected, bool correct_aspect, bool do_rotate)
{
ParamHandle *handle;
@@ -724,14 +817,29 @@ void ED_uvedit_pack_islands(Scene *scene, Object *ob, BMesh *bm, bool selected,
param_delete(handle);
}
+void ED_uvedit_pack_islands_multi(
+ Scene *scene, Object **objects, const uint objects_len,
+ bool selected, bool correct_aspect, bool do_rotate)
+{
+ ParamHandle *handle;
+ handle = construct_param_handle_multi(
+ scene, objects, objects_len, true, false, selected, correct_aspect);
+ param_pack(handle, scene->toolsettings->uvcalc_margin, do_rotate);
+ param_flush(handle);
+ param_delete(handle);
+}
+
static int pack_islands_exec(bContext *C, wmOperator *op)
{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
bool do_rotate = RNA_boolean_get(op->ptr, "rotate");
- if (!uvedit_have_selection(scene, em, true)) {
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+
+ if (!uvedit_have_selection_multi(scene, objects, objects_len, true)) {
+ MEM_SAFE_FREE(objects);
return OPERATOR_CANCELLED;
}
@@ -740,10 +848,15 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
else
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
- ED_uvedit_pack_islands(scene, obedit, em->bm, true, true, do_rotate);
-
- DEG_id_tag_update(obedit->data, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+ ED_uvedit_pack_islands_multi(scene, objects, objects_len, true, true, do_rotate);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ DEG_id_tag_update(obedit->data, 0);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+ }
+
+ MEM_SAFE_FREE(objects);
return OPERATOR_FINISHED;
}
@@ -856,7 +969,7 @@ void ED_uvedit_live_unwrap(Scene *scene, Object *obedit)
if (scene->toolsettings->edge_mode_live_unwrap &&
CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV))
{
- ED_unwrap_lscm(scene, obedit, false); /* unwrap all not just sel */
+ ED_unwrap_lscm(scene, obedit, false, false); /* unwrap all not just sel */
}
}
@@ -1178,7 +1291,7 @@ static void uv_map_clip_correct(Scene *scene, Object *ob, BMEditMesh *em, wmOper
/* ******************** Unwrap operator **************** */
/* assumes UV Map is checked, doesn't run update funcs */
-void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel)
+void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel, const bool pack)
{
BMEditMesh *em = BKE_editmesh_from_object(obedit);
ParamHandle *handle;
@@ -1199,7 +1312,10 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel)
param_lscm_end(handle);
param_average(handle);
- param_pack(handle, scene->toolsettings->uvcalc_margin, false);
+
+ if (pack) {
+ param_pack(handle, scene->toolsettings->uvcalc_margin, false);
+ }
param_flush(handle);
@@ -1208,33 +1324,48 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel)
static int unwrap_exec(bContext *C, wmOperator *op)
{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
int method = RNA_enum_get(op->ptr, "method");
const bool fill_holes = RNA_boolean_get(op->ptr, "fill_holes");
const bool correct_aspect = RNA_boolean_get(op->ptr, "correct_aspect");
const bool use_subsurf = RNA_boolean_get(op->ptr, "use_subsurf_data");
- bool use_subsurf_final;
float obsize[3];
bool implicit = false;
- if (!uvedit_have_selection(scene, em, implicit)) {
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ if (!uvedit_have_selection_multi(scene, objects, objects_len, implicit)) {
+ MEM_SAFE_FREE(objects);
return OPERATOR_CANCELLED;
}
-
+
/* add uvs if they don't exist yet */
- if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
- return OPERATOR_CANCELLED;
- }
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ bool use_subsurf_final;
+
+ if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+ continue;
+ }
- mat4_to_size(obsize, obedit->obmat);
- if (!(fabsf(obsize[0] - obsize[1]) < 1e-4f && fabsf(obsize[1] - obsize[2]) < 1e-4f))
- BKE_report(op->reports, RPT_INFO,
- "Object has non-uniform scale, unwrap will operate on a non-scaled version of the mesh");
- else if (is_negative_m4(obedit->obmat))
- BKE_report(op->reports, RPT_INFO,
- "Object has negative scale, unwrap will operate on a non-flipped version of the mesh");
+ mat4_to_size(obsize, obedit->obmat);
+ if (!(fabsf(obsize[0] - obsize[1]) < 1e-4f && fabsf(obsize[1] - obsize[2]) < 1e-4f))
+ BKE_report(op->reports, RPT_INFO,
+ "Object has non-uniform scale, unwrap will operate on a non-scaled version of the mesh");
+ else if (is_negative_m4(obedit->obmat))
+ BKE_report(op->reports, RPT_INFO,
+ "Object has negative scale, unwrap will operate on a non-flipped version of the mesh");
+
+
+ /* double up the check here but better keep ED_unwrap_lscm interface simple and not
+ * pass operator for warning append */
+ modifier_unwrap_state(obedit, scene, &use_subsurf_final);
+ if (use_subsurf != use_subsurf_final) {
+ BKE_report(op->reports, RPT_INFO, "Subdivision Surface modifier needs to be first to work with unwrap");
+ }
+ }
/* remember last method for live unwrap */
if (RNA_struct_property_is_set(op->ptr, "method"))
@@ -1257,17 +1388,17 @@ static int unwrap_exec(bContext *C, wmOperator *op)
if (use_subsurf) scene->toolsettings->uvcalc_flag |= UVCALC_USESUBSURF;
else scene->toolsettings->uvcalc_flag &= ~UVCALC_USESUBSURF;
- /* double up the check here but better keep ED_unwrap_lscm interface simple and not
- * pass operator for warning append */
- modifier_unwrap_state(obedit, scene, &use_subsurf_final);
- if (use_subsurf != use_subsurf_final)
- BKE_report(op->reports, RPT_INFO, "Subdivision Surface modifier needs to be first to work with unwrap");
-
/* execute unwrap */
- ED_unwrap_lscm(scene, obedit, true);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ ED_unwrap_lscm(scene, obedit, true, false);
+ DEG_id_tag_update(obedit->data, 0);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+ }
- DEG_id_tag_update(obedit->data, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+ ED_uvedit_pack_islands_multi(scene, objects, objects_len, true, true, true);
+
+ MEM_SAFE_FREE(objects);
return OPERATOR_FINISHED;
}
@@ -1322,9 +1453,8 @@ static int uv_from_view_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
static int uv_from_view_exec(bContext *C, wmOperator *op)
{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -1334,69 +1464,90 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
BMIter iter, liter;
MLoopUV *luv;
float rotmat[4][4];
+ bool changed_multi = false;
- int cd_loop_uv_offset;
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- /* add uvs if they don't exist yet */
- if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
- return OPERATOR_CANCELLED;
- }
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ bool changed = false;
- cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ /* add uvs if they don't exist yet */
+ if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+ continue;
+ }
- if (RNA_boolean_get(op->ptr, "orthographic")) {
- uv_map_rotation_matrix(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f);
-
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
- continue;
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- BLI_uvproject_from_view_ortho(luv->uv, l->v->co, rotmat);
- }
- }
- }
- else if (camera) {
- const bool camera_bounds = RNA_boolean_get(op->ptr, "camera_bounds");
- struct ProjCameraInfo *uci = BLI_uvproject_camera_info(v3d->camera, obedit->obmat,
- camera_bounds ? (scene->r.xsch * scene->r.xasp) : 1.0f,
- camera_bounds ? (scene->r.ysch * scene->r.yasp) : 1.0f);
+ if (RNA_boolean_get(op->ptr, "orthographic")) {
+ uv_map_rotation_matrix(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f);
- if (uci) {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
continue;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- BLI_uvproject_from_camera(luv->uv, l->v->co, uci);
+ BLI_uvproject_from_view_ortho(luv->uv, l->v->co, rotmat);
}
+ changed = true;
}
-
- MEM_freeN(uci);
}
- }
- else {
- copy_m4_m4(rotmat, obedit->obmat);
+ else if (camera) {
+ const bool camera_bounds = RNA_boolean_get(op->ptr, "camera_bounds");
+ struct ProjCameraInfo *uci = BLI_uvproject_camera_info(
+ v3d->camera, obedit->obmat,
+ camera_bounds ? (scene->r.xsch * scene->r.xasp) : 1.0f,
+ camera_bounds ? (scene->r.ysch * scene->r.yasp) : 1.0f);
+
+ if (uci) {
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ continue;
+
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ BLI_uvproject_from_camera(luv->uv, l->v->co, uci);
+ }
+ changed = true;
+ }
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
- continue;
+ MEM_freeN(uci);
+ }
+ }
+ else {
+ copy_m4_m4(rotmat, obedit->obmat);
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- BLI_uvproject_from_view(luv->uv, l->v->co, rv3d->persmat, rotmat, ar->winx, ar->winy);
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ continue;
+
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ BLI_uvproject_from_view(luv->uv, l->v->co, rv3d->persmat, rotmat, ar->winx, ar->winy);
+ }
+ changed = true;
}
}
- }
- uv_map_clip_correct(scene, obedit, em, op);
+ if (changed) {
+ changed_multi = true;
+ uv_map_clip_correct(scene, obedit, em, op);
- DEG_id_tag_update(obedit->data, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+ DEG_id_tag_update(obedit->data, 0);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+ }
+ }
+ MEM_SAFE_FREE(objects);
- return OPERATOR_FINISHED;
+ if (changed_multi) {
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
}
static int uv_from_view_poll(bContext *C)
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index c1fa86d4653..d571ca135a1 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -80,16 +80,8 @@ NodeGroup *BlenderFileLoader::Load()
}
ViewLayer *view_layer = (ViewLayer*)BLI_findstring(&_re->scene->view_layers, _view_layer->name, offsetof(ViewLayer, name));
-
- EvaluationContext *eval_ctx = DEG_evaluation_context_new(DAG_EVAL_RENDER);
Depsgraph *depsgraph = DEG_graph_new(_re->scene, view_layer, DAG_EVAL_RENDER);
- DEG_evaluation_context_init_from_view_layer_for_render(
- eval_ctx,
- depsgraph,
- _re->scene,
- view_layer);
-
BKE_scene_graph_update_tagged(depsgraph, _re->main);
#if 0
@@ -116,7 +108,7 @@ NodeGroup *BlenderFileLoader::Load()
bool apply_modifiers = true;
bool calc_undeformed = false;
bool calc_tessface = false;
- Mesh *mesh = BKE_mesh_new_from_object(eval_ctx,
+ Mesh *mesh = BKE_mesh_new_from_object(depsgraph,
_re->main,
_re->scene,
ob,
@@ -132,7 +124,6 @@ NodeGroup *BlenderFileLoader::Load()
DEG_OBJECT_ITER_END;
DEG_graph_free(depsgraph);
- DEG_evaluation_context_free(eval_ctx);
// Return the built scene.
return _Scene;
@@ -434,19 +425,8 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
float v1[3], v2[3], v3[3];
float n1[3], n2[3], n3[3], facenormal[3];
int clip[3];
- int wire_material = 0;
for (int a = 0; a < tottri; a++) {
const MLoopTri *lt = &mlooptri[a];
- const MPoly *mp = &mpoly[lt->poly];
- Material *mat = give_current_material(ob, mp->mat_nr + 1);
-
- if (mat && mat->mode & MA_ONLYCAST) {
- continue;
- }
- if (mat && mat->material_type == MA_TYPE_WIRE) {
- wire_material = 1;
- continue;
- }
copy_v3_v3(v1, mvert[mloop[lt->tri[0]].v].co);
copy_v3_v3(v2, mvert[mloop[lt->tri[1]].v].co);
@@ -462,11 +442,6 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
numFaces += countClippedFaces(v1, v2, v3, clip);
}
- if (wire_material) {
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "Warning: Object " << name << " has wire materials (ignored)" << endl;
- }
- }
#if 0
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "numFaces " << numFaces << endl;
@@ -523,9 +498,6 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
const MPoly *mp = &mpoly[lt->poly];
Material *mat = give_current_material(ob, mp->mat_nr + 1);
- if (mat && ((mat->mode & MA_ONLYCAST) || mat->material_type == MA_TYPE_WIRE))
- continue;
-
copy_v3_v3(v1, mvert[mloop[lt->tri[0]].v].co);
copy_v3_v3(v2, mvert[mloop[lt->tri[1]].v].co);
copy_v3_v3(v3, mvert[mloop[lt->tri[2]].v].co);
@@ -575,11 +547,8 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
if (mat) {
tmpMat.setLine(mat->line_col[0], mat->line_col[1], mat->line_col[2], mat->line_col[3]);
tmpMat.setDiffuse(mat->r, mat->g, mat->b, mat->alpha);
- tmpMat.setSpecular(mat->specr, mat->specg, mat->specb, mat->spectra);
- float s = 1.0 * (mat->har + 1) / 4 ; // in Blender: [1;511] => in OpenGL: [0;128]
- if (s > 128.f)
- s = 128.f;
- tmpMat.setShininess(s);
+ tmpMat.setSpecular(mat->specr, mat->specg, mat->specb, 1.0f);
+ tmpMat.setShininess(128.f);
tmpMat.setPriority(mat->line_priority);
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
index f9a8c787c08..0542b7f45fd 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
@@ -49,7 +49,6 @@ extern "C" {
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "renderdatabase.h"
#include "render_types.h"
#include "BKE_customdata.h"
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 8aac83a6179..06f62f5a5dc 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -89,7 +89,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
freestyle_scene = BKE_scene_add(freestyle_bmain, name);
freestyle_scene->r.cfra = old_scene->r.cfra;
freestyle_scene->r.mode = old_scene->r.mode &
- ~(R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR | R_BORDER);
+ ~(R_EDGE_FRS | R_PANORAMA | R_MBLUR | R_BORDER);
freestyle_scene->r.xsch = re->rectx; // old_scene->r.xsch
freestyle_scene->r.ysch = re->recty; // old_scene->r.ysch
freestyle_scene->r.xasp = 1.0f; // old_scene->r.xasp;
@@ -97,8 +97,6 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
freestyle_scene->r.tilex = old_scene->r.tilex;
freestyle_scene->r.tiley = old_scene->r.tiley;
freestyle_scene->r.size = 100; // old_scene->r.size
- //freestyle_scene->r.maximsize = old_scene->r.maximsize; /* DEPRECATED */
- freestyle_scene->r.ocres = old_scene->r.ocres;
freestyle_scene->r.color_mgt_flag = 0; // old_scene->r.color_mgt_flag;
freestyle_scene->r.scemode = old_scene->r.scemode & ~(R_SINGLE_LAYER | R_NO_FRAME_UPDATE | R_MULTIVIEW);
freestyle_scene->r.flag = old_scene->r.flag;
@@ -112,13 +110,10 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
freestyle_scene->r.safety.ymin = old_scene->r.safety.ymin;
freestyle_scene->r.safety.xmax = old_scene->r.safety.xmax;
freestyle_scene->r.safety.ymax = old_scene->r.safety.ymax;
- freestyle_scene->r.osa = old_scene->r.osa;
- freestyle_scene->r.filtertype = old_scene->r.filtertype;
- freestyle_scene->r.gauss = old_scene->r.gauss;
freestyle_scene->r.dither_intensity = old_scene->r.dither_intensity;
- BKE_viewrender_copy(&freestyle_scene->view_render, &old_scene->view_render);
+ STRNCPY(freestyle_scene->r.engine, old_scene->r.engine);
if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "Stroke rendering engine : " << freestyle_scene->view_render.engine_id << endl;
+ cout << "Stroke rendering engine : " << freestyle_scene->r.engine << endl;
}
freestyle_scene->r.im_format.planes = R_IMF_PLANES_RGBA;
freestyle_scene->r.im_format.imtype = R_IMF_IMTYPE_PNG;
@@ -128,7 +123,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
freestyle_scene->id.properties = IDP_CopyProperty_ex(old_scene->id.properties, 0);
}
- if (STREQ(freestyle_scene->view_render.engine_id, RE_engine_id_CYCLES)) {
+ if (STREQ(freestyle_scene->r.engine, RE_engine_id_CYCLES)) {
/* Render with transparent background. */
PointerRNA freestyle_scene_ptr;
RNA_id_pointer_create(&freestyle_scene->id, &freestyle_scene_ptr);
@@ -167,17 +162,11 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
// Reset serial mesh ID (used for BlenderStrokeRenderer::NewMesh())
_mesh_id = 0xffffffff;
- // Check if the rendering engine uses new shading nodes
- _use_shading_nodes = BKE_scene_use_new_shading_nodes(freestyle_scene);
-
// Create a bNodeTree-to-Material hash table
- if (_use_shading_nodes)
- _nodetree_hash = BLI_ghash_ptr_new("BlenderStrokeRenderer::_nodetree_hash");
- else
- _nodetree_hash = NULL;
+ _nodetree_hash = BLI_ghash_ptr_new("BlenderStrokeRenderer::_nodetree_hash");
// Depsgraph
- freestyle_depsgraph = DEG_graph_new(re->scene, view_layer, DAG_EVAL_RENDER);
+ freestyle_depsgraph = DEG_graph_new(freestyle_scene, view_layer, DAG_EVAL_RENDER);
DEG_graph_id_tag_update(freestyle_bmain, freestyle_depsgraph, &freestyle_scene->id, 0);
DEG_graph_id_tag_update(freestyle_bmain, freestyle_depsgraph, &object_camera->id, 0);
DEG_graph_tag_relations_update(freestyle_depsgraph);
@@ -230,21 +219,11 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer()
while (lnk)
{
Material *ma = (Material*)lnk;
- // We want to retain the linestyle mtexs, so let's detach them first
- for (int a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a]) {
- ma->mtex[a] = NULL;
- }
- else {
- break; // Textures are ordered, no empty slots between two textures
- }
- }
lnk = lnk->next;
BKE_libblock_free(freestyle_bmain, ma);
}
- if (_use_shading_nodes)
- BLI_ghash_free(_nodetree_hash, NULL, NULL);
+ BLI_ghash_free(_nodetree_hash, NULL, NULL);
DEG_graph_free(freestyle_depsgraph);
@@ -488,67 +467,13 @@ void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
{
- if (_use_shading_nodes) {
- bNodeTree *nt = iStrokeRep->getNodeTree();
- Material *ma = (Material *)BLI_ghash_lookup(_nodetree_hash, nt);
- if (!ma) {
- ma = BlenderStrokeRenderer::GetStrokeShader(freestyle_bmain, nt, false);
- BLI_ghash_insert(_nodetree_hash, nt, ma);
- }
- iStrokeRep->setMaterial(ma);
- }
- else {
- bool has_mat = false;
- int a = 0;
-
- // Look for a good existing material
- for (Link *lnk = (Link *)freestyle_bmain->mat.first; lnk; lnk = lnk->next) {
- Material *ma = (Material*)lnk;
- bool texs_are_good = true;
- // as soon as textures differ it's not the right one
- for (int a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a] != iStrokeRep->getMTex(a)) {
- texs_are_good = false;
- break;
- }
- }
-
- if (texs_are_good) {
- iStrokeRep->setMaterial(ma);
- has_mat = true;
- break; // if textures are good, no need to search anymore
- }
- }
-
- // If still no material, create one
- if (!has_mat) {
- Material *ma = BKE_material_add(freestyle_bmain, "stroke_material");
- DEG_relations_tag_update(freestyle_bmain);
- ma->mode |= MA_VERTEXCOLP;
- ma->mode |= MA_TRANSP;
- ma->mode |= MA_SHLESS;
- ma->vcol_alpha = 1;
-
- id_us_min(&ma->id);
-
- // Textures
- while (iStrokeRep->getMTex(a)) {
- ma->mtex[a] = (MTex *)iStrokeRep->getMTex(a);
-
- // We'll generate both with tips and without tips
- // coordinates, on two different UV layers.
- if (ma->mtex[a]->texflag & MTEX_TIPS) {
- BLI_strncpy(ma->mtex[a]->uvname, uvNames[1], sizeof(ma->mtex[a]->uvname));
- }
- else {
- BLI_strncpy(ma->mtex[a]->uvname, uvNames[0], sizeof(ma->mtex[a]->uvname));
- }
- a++;
- }
-
- iStrokeRep->setMaterial(ma);
- }
+ bNodeTree *nt = iStrokeRep->getNodeTree();
+ Material *ma = (Material *)BLI_ghash_lookup(_nodetree_hash, nt);
+ if (!ma) {
+ ma = BlenderStrokeRenderer::GetStrokeShader(freestyle_bmain, nt, false);
+ BLI_ghash_insert(_nodetree_hash, nt, ma);
}
+ iStrokeRep->setMaterial(ma);
const vector<Strip*>& strips = iStrokeRep->getStrips();
const bool hasTex = iStrokeRep->hasTex();
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index e2560a33443..75687edd9f6 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -58,12 +58,12 @@ extern "C" {
#include "BLI_blenlib.h"
#include "BLI_math.h"
+#include "BLI_math_color_blend.h"
#include "BLI_callbacks.h"
#include "BPY_extern.h"
#include "renderpipeline.h"
-#include "pixelblending.h"
#include "FRS_freestyle.h"
@@ -530,7 +530,7 @@ void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_r
pixSrc = src + 4 * (rectx * y + x);
if (pixSrc[3] > 0.0) {
pixDest = dest + 4 * (rectx * y + x);
- addAlphaOverFloat(pixDest, pixSrc);
+ blend_color_mix_float(pixDest, pixDest, pixSrc);
}
}
}
diff --git a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
index 956842580c5..4142117c361 100644
--- a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
@@ -275,7 +275,7 @@ protected:
{
if (_Point != 0) {
delete _Point;
- _Point = 0;
+ _Point = 0;
}
if ((_currentn == _n - 1) && (_t == 1.0f)) {
// we're setting the iterator to end
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index db96a27e073..c004d73e6fe 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -44,8 +44,7 @@
#endif
extern "C" {
-#include "DNA_material_types.h"
-
+struct MTex;
struct bNodeTree;
}
diff --git a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
index 8e98cabd75b..a3a0b5cbaeb 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
@@ -555,9 +555,9 @@ public:
// operators
// operator corresponding to ++i.
inline Self& operator++()
- {
- increment();
- return *this;
+ {
+ increment();
+ return *this;
}
// operator corresponding to i++, i.e. which returns the value *and then* increments it.
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
index 5683b39fd28..601c208b137 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
@@ -113,7 +113,7 @@ public:
#endif
inline void setRenderMonitor(RenderMonitor *iRenderMonitor) {
- _pRenderMonitor = iRenderMonitor;
+ _pRenderMonitor = iRenderMonitor;
}
protected:
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index bf0e6ea3368..f915191fc28 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -62,7 +62,6 @@ set(SRC
intern/gpu_immediate.c
intern/gpu_immediate_util.c
intern/gpu_init_exit.c
- intern/gpu_lamp.c
intern/gpu_material.c
intern/gpu_matrix.c
intern/gpu_select.c
@@ -105,7 +104,6 @@ set(SRC
GPU_immediate.h
GPU_immediate_util.h
GPU_init_exit.h
- GPU_lamp.h
GPU_legacy_stubs.h
GPU_material.h
GPU_matrix.h
@@ -117,7 +115,6 @@ set(SRC
intern/gpu_codegen.h
intern/gpu_private.h
- intern/gpu_lamp_private.h
intern/gpu_select_private.h
intern/gpu_shader_private.h
)
@@ -131,6 +128,7 @@ data_to_c_simple(shaders/gpu_shader_simple_lighting_smooth_color_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_simple_lighting_smooth_color_alpha_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_flat_color_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_flat_color_alpha_test_0_frag.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_flat_id_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_widget_base_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_widget_base_frag.glsl SRC)
@@ -144,6 +142,7 @@ data_to_c_simple(shaders/gpu_shader_2D_line_dashed_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_geom.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_smooth_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_smooth_color_frag.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_2D_smooth_color_uniform_alpha_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_image_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_image_rect_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_image_multi_rect_vert.glsl SRC)
@@ -172,6 +171,7 @@ data_to_c_simple(shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_screen_aligned_vert.glsl SRC)
@@ -232,10 +232,6 @@ data_to_c_simple(shaders/gpu_shader_vertex_world.glsl SRC)
data_to_c_simple(shaders/gpu_shader_vsm_store_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_vsm_store_vert.glsl SRC)
-if(WITH_GAMEENGINE)
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
if(WITH_MOD_SMOKE)
add_definitions(-DWITH_SMOKE)
endif()
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 0d8a7a45ee9..f496c92f283 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -32,192 +32,19 @@
#ifndef __GPU_BUFFERS_H__
#define __GPU_BUFFERS_H__
-#ifdef DEBUG
-/* #define DEBUG_VBO(X) printf(X)*/
-# define DEBUG_VBO(X)
-#else
-# define DEBUG_VBO(X)
-#endif
-
#include <stddef.h>
struct BMesh;
struct CCGElem;
struct CCGKey;
struct DMFlagMat;
-struct DerivedMesh;
-struct GSet;
-struct GPUVertPointLink;
-struct GPUDrawObject;
struct GridCommonGPUBuffer;
-struct PBVH;
-struct Gwn_Batch;
+struct GSet;
+struct MLoop;
+struct MLoopTri;
+struct MPoly;
struct MVert;
-
-typedef struct GPUBuffer {
- size_t size; /* in bytes */
- unsigned int id; /* used with vertex buffer objects */
-} GPUBuffer;
-
-typedef struct GPUBufferMaterial {
- /* range of points used for this material */
- unsigned int start;
- unsigned int totelements;
- unsigned int totloops;
- unsigned int *polys; /* array of polygons for this material */
- unsigned int totpolys; /* total polygons in polys */
- unsigned int totvisiblepolys; /* total visible polygons */
-
- /* original material index */
- short mat_nr;
-} GPUBufferMaterial;
-
-void GPU_buffer_material_finalize(struct GPUDrawObject *gdo, GPUBufferMaterial *matinfo, int totmat);
-
-/* meshes are split up by material since changing materials requires
- * GL state changes that can't occur in the middle of drawing an
- * array.
- *
- * some simplifying assumptions are made:
- * - all quads are treated as two triangles.
- * - no vertex sharing is used; each triangle gets its own copy of the
- * vertices it uses (this makes it easy to deal with a vertex used
- * by faces with different properties, such as smooth/solid shading,
- * different MCols, etc.)
- *
- * to avoid confusion between the original MVert vertices and the
- * arrays of OpenGL vertices, the latter are referred to here and in
- * the source as `points'. similarly, the OpenGL triangles generated
- * for MFaces are referred to as triangles rather than faces.
- */
-typedef struct GPUDrawObject {
- GPUBuffer *points;
- GPUBuffer *normals;
- GPUBuffer *uv;
- GPUBuffer *uv_tex;
- GPUBuffer *colors;
- GPUBuffer *edges;
- GPUBuffer *uvedges;
- GPUBuffer *triangles; /* triangle index buffer */
-
- /* for each original vertex, the list of related points */
- struct GPUVertPointLink *vert_points;
-
- /* see: USE_GPU_POINT_LINK define */
-#if 0
- /* storage for the vert_points lists */
- struct GPUVertPointLink *vert_points_mem;
- int vert_points_usage;
-#endif
-
- int colType;
-
- GPUBufferMaterial *materials;
- int totmaterial;
-
- unsigned int tot_triangle_point;
- unsigned int tot_loose_point;
- /* different than total loops since ngons get tesselated still */
- unsigned int tot_loop_verts;
-
- /* caches of the original DerivedMesh values */
- unsigned int totvert;
- unsigned int totedge;
-
- unsigned int loose_edge_offset;
- unsigned int tot_loose_edge_drawn;
- unsigned int tot_edge_drawn;
-
- /* for subsurf, offset where drawing of interior edges starts */
- unsigned int interior_offset;
- unsigned int totinterior;
-} GPUDrawObject;
-
-/* currently unused */
-// #define USE_GPU_POINT_LINK
-
-typedef struct GPUVertPointLink {
-#ifdef USE_GPU_POINT_LINK
- struct GPUVertPointLink *next;
-#endif
- /* -1 means uninitialized */
- int point_index;
-} GPUVertPointLink;
-
-
-
-/* used for GLSL materials */
-typedef struct GPUAttrib {
- int index;
- int info_index;
- int size;
- int type;
-} GPUAttrib;
-
-void GPU_global_buffer_pool_free(void);
-void GPU_global_buffer_pool_free_unused(void);
-
-GPUBuffer *GPU_buffer_alloc(size_t size);
-void GPU_buffer_free(GPUBuffer *buffer);
-
-void GPU_drawobject_free(struct DerivedMesh *dm);
-
-/* flag that controls data type to fill buffer with, a modifier will prepare. */
-typedef enum {
- GPU_BUFFER_VERTEX = 0,
- GPU_BUFFER_NORMAL,
- GPU_BUFFER_COLOR,
- GPU_BUFFER_UV,
- GPU_BUFFER_UV_TEXPAINT,
- GPU_BUFFER_EDGE,
- GPU_BUFFER_UVEDGE,
- GPU_BUFFER_TRIANGLES
-} GPUBufferType;
-
-typedef enum {
- GPU_BINDING_ARRAY = 0,
- GPU_BINDING_INDEX = 1,
-} GPUBindingType;
-
-typedef enum {
- GPU_ATTR_INFO_SRGB = (1 << 0),
-} GPUAttrInfo;
-
-/* called before drawing */
-void GPU_vertex_setup(struct DerivedMesh *dm);
-void GPU_normal_setup(struct DerivedMesh *dm);
-void GPU_uv_setup(struct DerivedMesh *dm);
-void GPU_texpaint_uv_setup(struct DerivedMesh *dm);
-/* colType is the cddata MCol type to use! */
-void GPU_color_setup(struct DerivedMesh *dm, int colType);
-void GPU_buffer_bind_as_color(GPUBuffer *buffer);
-void GPU_edge_setup(struct DerivedMesh *dm); /* does not mix with other data */
-void GPU_uvedge_setup(struct DerivedMesh *dm);
-
-void GPU_triangle_setup(struct DerivedMesh *dm);
-
-int GPU_attrib_element_size(GPUAttrib data[], int numdata);
-void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata, int element_size);
-
-void GPU_buffer_bind(GPUBuffer *buffer, GPUBindingType binding);
-void GPU_buffer_unbind(GPUBuffer *buffer, GPUBindingType binding);
-
-/* can't lock more than one buffer at once */
-void *GPU_buffer_lock(GPUBuffer *buffer, GPUBindingType binding);
-void *GPU_buffer_lock_stream(GPUBuffer *buffer, GPUBindingType binding);
-void GPU_buffer_unlock(GPUBuffer *buffer, GPUBindingType binding);
-
-/* switch color rendering on=1/off=0 */
-void GPU_color_switch(int mode);
-
-/* used for drawing edges */
-void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, int count);
-
-/* called after drawing */
-void GPU_buffers_unbind(void);
-
-/* only unbind interleaved data */
-void GPU_interleaved_attrib_unbind(void);
+struct PBVH;
/* Buffers for non-DerivedMesh drawing */
typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers;
@@ -264,9 +91,6 @@ void GPU_pbvh_grid_buffers_update(
const int update_flags);
/* draw */
-void GPU_pbvh_buffers_draw(
- GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
- bool wireframe, bool fast);
struct Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast);
/* debug PBVH draw */
@@ -278,4 +102,6 @@ bool GPU_pbvh_buffers_mask_changed(GPU_PBVH_Buffers *buffers, bool show_mask);
void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers);
void GPU_pbvh_multires_buffers_free(struct GridCommonGPUBuffer **grid_common_gpu_buffer);
+void GPU_pbvh_fix_linking(void);
+
#endif
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 9bbf46b2a1f..e26d973142b 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -49,15 +49,12 @@ struct DupliObject;
#include "DNA_object_enums.h"
-/* OpenGL drawing functions related to shading. These are also
- * shared with the game engine, where there were previously
- * duplicates of some of these functions. */
+/* OpenGL drawing functions related to shading. */
/* Initialize
* - sets the default Blender opengl state, if in doubt, check
* the contents of this function
- * - this is called when starting Blender, for opengl rendering,
- * and for switching back from the game engine for example. */
+ * - this is called when starting Blender, for opengl rendering. */
void GPU_state_init(void);
@@ -68,49 +65,6 @@ void GPU_state_init(void);
void GPU_enable_program_point_size(void);
void GPU_disable_program_point_size(void);
-/* Material drawing
- * - first the state is initialized by a particular object and
- * it's materials
- * - after this, materials can be quickly enabled by their number,
- * GPU_object_material_bind returns 0 if drawing should be skipped
- * - after drawing, the material must be disabled again */
-
-void GPU_begin_object_materials(
- struct View3D *v3d, struct RegionView3D *rv3d,
- struct Scene *scene, struct ViewLayer *view_layer,
- struct Object *ob, bool glsl, bool *do_alpha_after);
-void GPU_end_object_materials(void);
-bool GPU_object_materials_check(void);
-
-int GPU_object_material_bind(int nr, void *attribs);
-void GPU_object_material_unbind(void);
-int GPU_object_material_visible(int nr, void *attribs);
-
-void GPU_begin_dupli_object(struct DupliObject *dob);
-void GPU_end_dupli_object(void);
-
-void GPU_material_diffuse_get(int nr, float diff[4]);
-bool GPU_material_use_matcaps_get(void);
-
-void GPU_set_material_alpha_blend(int alphablend);
-int GPU_get_material_alpha_blend(void);
-
-/* Lights
- * - returns how many lights were enabled
- * - this affects fixed functions materials and texface, not glsl */
-
-int GPU_default_lights(void);
-int GPU_scene_object_lights(
- struct ViewLayer *view_layer, float viewmat[4][4], int ortho);
-
-/* Text render
- * - based on moving uv coordinates */
-
-void GPU_render_text(
- int mode, const char *textstr, int textlen, unsigned int *col,
- const float *v_quad[4], const float *uv_quad[4],
- int glattrib);
-
/* Mipmap settings
* - these will free textures on changes */
@@ -132,11 +86,9 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap);
* - these deal with images bound as opengl textures */
void GPU_paint_update_image(struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h);
-void GPU_update_images_framechange(void);
-int GPU_update_image_time(struct Image *ima, double time);
int GPU_verify_image(
struct Image *ima, struct ImageUser *iuser,
- int textarget, int tftile, bool compare, bool mipmap, bool is_data);
+ int textarget, bool compare, bool mipmap, bool is_data);
void GPU_create_gl_tex(
unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth,
int textarget, bool mipmap, bool use_hight_bit_depth, struct Image *ima);
@@ -156,11 +108,6 @@ void GPU_create_smoke(struct SmokeModifierData *smd, int highres);
/* Delayed free of OpenGL buffers by main thread */
void GPU_free_unused_buffers(void);
-#ifdef WITH_OPENSUBDIV
-struct DerivedMesh;
-void GPU_draw_update_fvar_offset(struct DerivedMesh *dm);
-#endif
-
/* utilities */
void GPU_select_index_set(int index);
void GPU_select_index_get(int index, int *r_col);
diff --git a/source/blender/gpu/GPU_lamp.h b/source/blender/gpu/GPU_lamp.h
deleted file mode 100644
index 87350f1ceb4..00000000000
--- a/source/blender/gpu/GPU_lamp.h
+++ /dev/null
@@ -1,77 +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) 2005 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Brecht Van Lommel, Clément Foucault.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file GPU_lamp.h
- * \ingroup gpu
- */
-
-#ifndef __GPU_LAMP_H__
-#define __GPU_LAMP_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct Scene;
-struct Object;
-struct RenderEngineType;
-
-typedef struct GPULamp GPULamp;
-
-#define MAX_LAMP_DATA 2
-
-typedef struct LampEngineData {
- void *storage[MAX_LAMP_DATA];
-} LampEngineData;
-
-LampEngineData *GPU_lamp_engine_data_get(struct Scene *scene, struct Object *ob, struct Object *par, struct RenderEngineType *re);
-
-GPULamp *GPU_lamp_from_blender(struct Scene *scene, struct Object *ob, struct Object *par);
-void GPU_lamp_free(struct Object *ob);
-void GPU_lamp_engine_data_free(LampEngineData *led);
-
-bool GPU_lamp_visible(GPULamp *lamp, struct Material *ma);
-bool GPU_lamp_has_shadow_buffer(GPULamp *lamp);
-void GPU_lamp_update_buffer_mats(GPULamp *lamp);
-void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[4][4], int *winsize, float winmat[4][4]);
-void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp);
-int GPU_lamp_shadow_buffer_type(GPULamp *lamp);
-int GPU_lamp_shadow_bind_code(GPULamp *lamp);
-float *GPU_lamp_dynpersmat(GPULamp *lamp);
-
-void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[4][4]);
-void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy);
-void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float att2,
- float coeff_const, float coeff_lin, float coeff_quad);
-void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend);
-int GPU_lamp_shadow_layer(GPULamp *lamp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __GPU_LAMP_H__ */
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 1d2b234e7f3..c9ef5ca3ae6 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -236,37 +236,23 @@ GPUNodeLink *GPU_uniformbuffer_link_out(
struct GPUNodeStack *stack, const int index);
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link);
-void GPU_material_enable_alpha(GPUMaterial *material);
GPUBuiltin GPU_get_material_builtins(GPUMaterial *material);
-GPUBlendMode GPU_material_alpha_blend(GPUMaterial *material, float obcol[4]);
void GPU_material_sss_profile_create(GPUMaterial *material, float *radii, short *falloff_type, float *sharpness);
struct GPUUniformBuffer *GPU_material_sss_profile_get(
GPUMaterial *material, int sample_ct, struct GPUTexture **tex_profile);
/* High level functions to create and use GPU materials */
-GPUMaterial *GPU_material_world(struct Scene *scene, struct World *wo);
GPUMaterial *GPU_material_from_nodetree_find(
struct ListBase *gpumaterials, const void *engine_type, int options);
GPUMaterial *GPU_material_from_nodetree(
- struct Scene *scene, struct bNodeTree *ntree, struct ListBase *gpumaterials, const void *engine_type, int options,
- const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines, bool deferred);
-GPUMaterial *GPU_material_from_blender(struct Scene *scene, struct Material *ma, bool use_opensubdiv);
-GPUMaterial *GPU_material_matcap(struct Scene *scene, struct Material *ma, bool use_opensubdiv);
+ struct Scene *scene, struct bNodeTree *ntree, struct ListBase *gpumaterials, const void *engine_type, int options);
void GPU_material_generate_pass(
GPUMaterial *mat, const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines);
void GPU_material_free(struct ListBase *gpumaterial);
void GPU_materials_free(void);
-void GPU_material_bind(
- GPUMaterial *material, int oblay, int viewlay, double time, int mipmap,
- float viewmat[4][4], float viewinv[4][4], float cameraborder[4]);
-void GPU_material_bind_uniforms(
- GPUMaterial *material, float obmat[4][4], float viewmat[4][4], float obcol[4],
- float autobumpscale, GPUParticleInfo *pi, float object_info[3]);
-void GPU_material_unbind(GPUMaterial *material);
-bool GPU_material_bound(GPUMaterial *material);
struct Scene *GPU_material_scene(GPUMaterial *material);
GPUMatType GPU_Material_get_type(GPUMaterial *material);
struct GPUPass *GPU_material_get_pass(GPUMaterial *material);
@@ -281,103 +267,9 @@ void GPU_material_vertex_attributes(GPUMaterial *material,
struct GPUVertexAttribs *attrib);
bool GPU_material_do_color_management(GPUMaterial *mat);
-bool GPU_material_use_new_shading_nodes(GPUMaterial *mat);
-bool GPU_material_use_world_space_shading(GPUMaterial *mat);
bool GPU_material_use_domain_surface(GPUMaterial *mat);
bool GPU_material_use_domain_volume(GPUMaterial *mat);
-/* Exported shading */
-
-typedef struct GPUShadeInput {
- GPUMaterial *gpumat;
- struct Material *mat;
-
- GPUNodeLink *rgb, *specrgb, *vn, *view, *vcol, *ref;
- GPUNodeLink *alpha, *refl, *spec, *emit, *har, *amb;
- GPUNodeLink *spectra, *mir, *refcol;
-} GPUShadeInput;
-
-typedef struct GPUShadeResult {
- GPUNodeLink *diff, *spec, *combined, *alpha;
-} GPUShadeResult;
-
-void GPU_shadeinput_set(GPUMaterial *mat, struct Material *ma, GPUShadeInput *shi);
-void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr);
-
-/* Export GLSL shader */
-
-typedef enum GPUDataType {
- GPU_DATA_NONE = 0,
- GPU_DATA_1I = 1, /* 1 integer */
- GPU_DATA_1F = 2,
- GPU_DATA_2F = 3,
- GPU_DATA_3F = 4,
- GPU_DATA_4F = 5,
- GPU_DATA_9F = 6,
- GPU_DATA_16F = 7,
- GPU_DATA_4UB = 8,
-} GPUDataType;
-
-/* this structure gives information of each uniform found in the shader */
-typedef struct GPUInputUniform {
- struct GPUInputUniform *next, *prev;
- char varname[32]; /* name of uniform in shader */
- GPUDynamicType type; /* type of uniform, data format and calculation derive from it */
- GPUDataType datatype; /* type of uniform data */
- struct Object *lamp; /* when type=GPU_DYNAMIC_LAMP_... or GPU_DYNAMIC_SAMPLER_2DSHADOW */
- struct Image *image; /* when type=GPU_DYNAMIC_SAMPLER_2DIMAGE */
- struct Material *material;/* when type=GPU_DYNAMIC_MAT_... */
- int texnumber; /* when type=GPU_DYNAMIC_SAMPLER, texture number: 0.. */
- unsigned char *texpixels; /* for internally generated texture, pixel data in RGBA format */
- int texsize; /* size in pixel of the texture in texpixels buffer:
- * for 2D textures, this is S and T size (square texture) */
-} GPUInputUniform;
-
-typedef struct GPUInputAttribute {
- struct GPUInputAttribute *next, *prev;
- char varname[32]; /* name of attribute in shader */
- int type; /* from CustomData.type, data type derives from it */
- GPUDataType datatype; /* type of attribute data */
- const char *name; /* layer name */
- int number; /* generic attribute number */
-} GPUInputAttribute;
-
-typedef struct GPUShaderExport {
- ListBase uniforms;
- ListBase attributes;
- char *vertex;
- char *fragment;
-} GPUShaderExport;
-
-GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma);
-void GPU_free_shader_export(GPUShaderExport *shader);
-
-/* Lamps */
-GPUNodeLink *GPU_lamp_get_data(
- GPUMaterial *mat, struct GPULamp *lamp,
- GPUNodeLink **r_col, GPUNodeLink **r_lv, GPUNodeLink **r_dist, GPUNodeLink **r_shadow, GPUNodeLink **r_energy);
-
-/* World */
-void GPU_mist_update_enable(short enable);
-void GPU_mist_update_values(int type, float start, float dist, float inten, float color[3]);
-void GPU_horizon_update_color(float color[3]);
-void GPU_ambient_update_color(float color[3]);
-void GPU_zenith_update_color(float color[3]);
-
-struct GPUParticleInfo
-{
- float scalprops[4];
- float location[4];
- float velocity[3];
- float angular_velocity[3];
-};
-
-#ifdef WITH_OPENSUBDIV
-struct DerivedMesh;
-void GPU_material_update_fvar_offset(GPUMaterial *gpu_material,
- struct DerivedMesh *dm);
-#endif
-
void GPU_pass_cache_garbage_collect(void);
void GPU_pass_cache_free(void);
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index b33df9fdb20..9131f56a07e 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -111,6 +111,7 @@ typedef enum GPUBuiltinShader {
GPU_SHADER_2D_UNIFORM_COLOR,
GPU_SHADER_2D_FLAT_COLOR,
GPU_SHADER_2D_SMOOTH_COLOR,
+ GPU_SHADER_2D_SMOOTH_COLOR_UNIFORM_ALPHA,
GPU_SHADER_2D_IMAGE,
GPU_SHADER_2D_IMAGE_COLOR,
GPU_SHADER_2D_IMAGE_ALPHA_COLOR,
@@ -168,6 +169,7 @@ typedef enum GPUBuiltinShader {
GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED,
/* instance */
GPU_SHADER_INSTANCE_UNIFORM_COLOR,
+ GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE, /* Uniformly scaled */
GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, /* Uniformly scaled */
GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE,
GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR,
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 7c33153ee01..180ecb51173 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -71,6 +71,7 @@ typedef enum GPUTextureFormat {
GPU_R32F,
GPU_R16F,
GPU_R16I,
+ GPU_R16UI,
GPU_RG8,
GPU_R8,
#if 0
@@ -89,7 +90,6 @@ typedef enum GPUTextureFormat {
GPU_RG8UI,
GPU_R32I,
GPU_R32UI,
- GPU_R16UI,
GPU_R16,
GPU_R8I,
GPU_R8UI,
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 332102aca46..59d88e81822 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -25,7 +25,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/gpu/intern/gpu_basic_shader.c
+/** \file blender/gpu/intern/gpu_batch.c
* \ingroup gpu
*/
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 3367a568bc5..bbee252cd20 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -58,52 +58,6 @@
#include "bmesh.h"
-/* TODO: gawain support for baseelemarray */
-// #define USE_BASE_ELEM
-
-typedef enum {
- GPU_BUFFER_VERTEX_STATE = (1 << 0),
- GPU_BUFFER_NORMAL_STATE = (1 << 1),
- GPU_BUFFER_TEXCOORD_UNIT_0_STATE = (1 << 2),
- GPU_BUFFER_TEXCOORD_UNIT_2_STATE = (1 << 3),
- GPU_BUFFER_COLOR_STATE = (1 << 4),
- GPU_BUFFER_ELEMENT_STATE = (1 << 5),
-} GPUBufferState;
-
-typedef struct {
- GLenum gl_buffer_type;
- int num_components; /* number of data components for one vertex */
-} GPUBufferTypeSettings;
-
-
-static size_t gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type);
-
-static const GPUBufferTypeSettings gpu_buffer_type_settings[] = {
- /* vertex */
- {GL_ARRAY_BUFFER, 3},
- /* normal */
- {GL_ARRAY_BUFFER, 4}, /* we copy 3 shorts per normal but we add a fourth for alignment */
- /* mcol */
- {GL_ARRAY_BUFFER, 4},
- /* uv */
- {GL_ARRAY_BUFFER, 2},
- /* uv for texpaint */
- {GL_ARRAY_BUFFER, 4},
- /* edge */
- {GL_ELEMENT_ARRAY_BUFFER, 2},
- /* uv edge */
- {GL_ELEMENT_ARRAY_BUFFER, 4},
- /* triangles, 1 point since we are allocating from tottriangle points, which account for all points */
- {GL_ELEMENT_ARRAY_BUFFER, 1},
-};
-
-#define MAX_GPU_ATTRIB_DATA 32
-
-#define BUFFER_OFFSET(n) ((GLubyte *)NULL + (n))
-
-static GPUBufferState GLStates = 0;
-static GPUAttrib attribData[MAX_GPU_ATTRIB_DATA] = { { -1, 0, 0 } };
-
static ThreadMutex buffer_mutex = BLI_MUTEX_INITIALIZER;
/* multires global buffer, can be used for many grids having the same grid size */
@@ -113,834 +67,6 @@ typedef struct GridCommonGPUBuffer {
unsigned mres_prev_totquad;
} GridCommonGPUBuffer;
-void GPU_buffer_material_finalize(GPUDrawObject *gdo, GPUBufferMaterial *matinfo, int totmat)
-{
- int i, curmat, curelement;
-
- /* count the number of materials used by this DerivedMesh */
- for (i = 0; i < totmat; i++) {
- if (matinfo[i].totelements > 0)
- gdo->totmaterial++;
- }
-
- /* allocate an array of materials used by this DerivedMesh */
- gdo->materials = MEM_mallocN(sizeof(GPUBufferMaterial) * gdo->totmaterial,
- "GPUDrawObject.materials");
-
- /* initialize the materials array */
- for (i = 0, curmat = 0, curelement = 0; i < totmat; i++) {
- if (matinfo[i].totelements > 0) {
- gdo->materials[curmat] = matinfo[i];
- gdo->materials[curmat].start = curelement;
- gdo->materials[curmat].mat_nr = i;
- gdo->materials[curmat].polys = MEM_mallocN(sizeof(int) * matinfo[i].totpolys, "GPUBufferMaterial.polys");
-
- curelement += matinfo[i].totelements;
- curmat++;
- }
- }
-
- MEM_freeN(matinfo);
-}
-
-
-/* stores recently-deleted buffers so that new buffers won't have to
- * be recreated as often
- *
- * only one instance of this pool is created, stored in
- * gpu_buffer_pool
- *
- * note that the number of buffers in the pool is usually limited to
- * MAX_FREE_GPU_BUFFERS, but this limit may be exceeded temporarily
- * when a GPUBuffer is released outside the main thread; due to OpenGL
- * restrictions it cannot be immediately released
- */
-typedef struct GPUBufferPool {
- /* number of allocated buffers stored */
- int totbuf;
- /* actual allocated length of the arrays */
- int maxsize;
- GPUBuffer **buffers;
-} GPUBufferPool;
-#define MAX_FREE_GPU_BUFFERS 8
-
-/* create a new GPUBufferPool */
-static GPUBufferPool *gpu_buffer_pool_new(void)
-{
- GPUBufferPool *pool;
-
- pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer_Pool");
-
- pool->maxsize = MAX_FREE_GPU_BUFFERS;
- pool->buffers = MEM_mallocN(sizeof(*pool->buffers) * pool->maxsize,
- "GPUBufferPool.buffers");
- return pool;
-}
-
-/* remove a GPUBuffer from the pool (does not free the GPUBuffer) */
-static void gpu_buffer_pool_remove_index(GPUBufferPool *pool, int index)
-{
- int i;
-
- if (!pool || index < 0 || index >= pool->totbuf)
- return;
-
- /* shift entries down, overwriting the buffer at `index' */
- for (i = index; i < pool->totbuf - 1; i++)
- pool->buffers[i] = pool->buffers[i + 1];
-
- /* clear the last entry */
- if (pool->totbuf > 0)
- pool->buffers[pool->totbuf - 1] = NULL;
-
- pool->totbuf--;
-}
-
-/* delete the last entry in the pool */
-static void gpu_buffer_pool_delete_last(GPUBufferPool *pool)
-{
- GPUBuffer *last;
-
- if (pool->totbuf <= 0)
- return;
-
- /* get the last entry */
- if (!(last = pool->buffers[pool->totbuf - 1]))
- return;
-
- /* delete the buffer's data */
- glDeleteBuffers(1, &last->id);
-
- /* delete the buffer and remove from pool */
- MEM_freeN(last);
- pool->totbuf--;
- pool->buffers[pool->totbuf] = NULL;
-}
-
-/* free a GPUBufferPool; also frees the data in the pool's
- * GPUBuffers */
-static void gpu_buffer_pool_free(GPUBufferPool *pool)
-{
- if (!pool)
- return;
-
- while (pool->totbuf)
- gpu_buffer_pool_delete_last(pool);
-
- MEM_freeN(pool->buffers);
- MEM_freeN(pool);
-}
-
-static void gpu_buffer_pool_free_unused(GPUBufferPool *pool)
-{
- if (!pool)
- return;
-
- BLI_mutex_lock(&buffer_mutex);
-
- while (pool->totbuf)
- gpu_buffer_pool_delete_last(pool);
-
- BLI_mutex_unlock(&buffer_mutex);
-}
-
-static GPUBufferPool *gpu_buffer_pool = NULL;
-static GPUBufferPool *gpu_get_global_buffer_pool(void)
-{
- /* initialize the pool */
- if (!gpu_buffer_pool)
- gpu_buffer_pool = gpu_buffer_pool_new();
-
- return gpu_buffer_pool;
-}
-
-void GPU_global_buffer_pool_free(void)
-{
- gpu_buffer_pool_free(gpu_buffer_pool);
- gpu_buffer_pool = NULL;
-}
-
-void GPU_global_buffer_pool_free_unused(void)
-{
- gpu_buffer_pool_free_unused(gpu_buffer_pool);
-}
-
-/* get a GPUBuffer of at least `size' bytes; uses one from the buffer
- * pool if possible, otherwise creates a new one
- *
- * Thread-unsafe version for internal usage only.
- */
-static GPUBuffer *gpu_buffer_alloc_intern(size_t size)
-{
- GPUBufferPool *pool;
- GPUBuffer *buf;
- int i, bestfit = -1;
- size_t bufsize;
-
- /* bad case, leads to leak of buf since buf->pointer will allocate
- * NULL, leading to return without cleanup. In any case better detect early
- * psy-fi */
- if (size == 0)
- return NULL;
-
- pool = gpu_get_global_buffer_pool();
-
- /* not sure if this buffer pool code has been profiled much,
- * seems to me that the graphics driver and system memory
- * management might do this stuff anyway. --nicholas
- */
-
- /* check the global buffer pool for a recently-deleted buffer
- * that is at least as big as the request, but not more than
- * twice as big */
- for (i = 0; i < pool->totbuf; i++) {
- bufsize = pool->buffers[i]->size;
-
- /* check for an exact size match */
- if (bufsize == size) {
- bestfit = i;
- break;
- }
- /* smaller buffers won't fit data and buffers at least
- * twice as big are a waste of memory */
- else if (bufsize > size && size > (bufsize / 2)) {
- /* is it closer to the required size than the
- * last appropriate buffer found. try to save
- * memory */
- if (bestfit == -1 || pool->buffers[bestfit]->size > bufsize) {
- bestfit = i;
- }
- }
- }
-
- /* if an acceptable buffer was found in the pool, remove it
- * from the pool and return it */
- if (bestfit != -1) {
- buf = pool->buffers[bestfit];
- gpu_buffer_pool_remove_index(pool, bestfit);
- return buf;
- }
-
- /* no acceptable buffer found in the pool, create a new one */
- buf = MEM_callocN(sizeof(GPUBuffer), "GPUBuffer");
- buf->size = size;
-
- glGenBuffers(1, &buf->id);
- glBindBuffer(GL_ARRAY_BUFFER, buf->id);
- glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- return buf;
-}
-
-/* Same as above, but safe for threading. */
-GPUBuffer *GPU_buffer_alloc(size_t size)
-{
- GPUBuffer *buffer;
-
- if (size == 0) {
- /* Early out, no lock needed in this case. */
- return NULL;
- }
-
- BLI_mutex_lock(&buffer_mutex);
- buffer = gpu_buffer_alloc_intern(size);
- BLI_mutex_unlock(&buffer_mutex);
-
- return buffer;
-}
-
-/* release a GPUBuffer; does not free the actual buffer or its data,
- * but rather moves it to the pool of recently-freed buffers for
- * possible re-use
- *
- * Thread-unsafe version for internal usage only.
- */
-static void gpu_buffer_free_intern(GPUBuffer *buffer)
-{
- GPUBufferPool *pool;
- int i;
-
- if (!buffer)
- return;
-
- pool = gpu_get_global_buffer_pool();
-
- /* free the last used buffer in the queue if no more space, but only
- * if we are in the main thread. for e.g. rendering or baking it can
- * happen that we are in other thread and can't call OpenGL, in that
- * case cleanup will be done GPU_buffer_pool_free_unused */
- if (BLI_thread_is_main()) {
- /* in main thread, safe to decrease size of pool back
- * down to MAX_FREE_GPU_BUFFERS */
- while (pool->totbuf >= MAX_FREE_GPU_BUFFERS)
- gpu_buffer_pool_delete_last(pool);
- }
- else {
- /* outside of main thread, can't safely delete the
- * buffer, so increase pool size */
- if (pool->maxsize == pool->totbuf) {
- pool->maxsize += MAX_FREE_GPU_BUFFERS;
- pool->buffers = MEM_reallocN(pool->buffers,
- sizeof(GPUBuffer *) * pool->maxsize);
- }
- }
-
- /* shift pool entries up by one */
- for (i = pool->totbuf; i > 0; i--)
- pool->buffers[i] = pool->buffers[i - 1];
-
- /* insert the buffer into the beginning of the pool */
- pool->buffers[0] = buffer;
- pool->totbuf++;
-}
-
-/* Same as above, but safe for threading. */
-void GPU_buffer_free(GPUBuffer *buffer)
-{
- if (!buffer) {
- /* Early output, no need to lock in this case, */
- return;
- }
-
- BLI_mutex_lock(&buffer_mutex);
- gpu_buffer_free_intern(buffer);
- BLI_mutex_unlock(&buffer_mutex);
-}
-
-void GPU_drawobject_free(DerivedMesh *dm)
-{
- GPUDrawObject *gdo;
- int i;
-
- if (!dm || !(gdo = dm->drawObject))
- return;
-
- for (i = 0; i < gdo->totmaterial; i++) {
- if (gdo->materials[i].polys)
- MEM_freeN(gdo->materials[i].polys);
- }
-
- MEM_freeN(gdo->materials);
- if (gdo->vert_points)
- MEM_freeN(gdo->vert_points);
-#ifdef USE_GPU_POINT_LINK
- MEM_freeN(gdo->vert_points_mem);
-#endif
- GPU_buffer_free(gdo->points);
- GPU_buffer_free(gdo->normals);
- GPU_buffer_free(gdo->uv);
- GPU_buffer_free(gdo->uv_tex);
- GPU_buffer_free(gdo->colors);
- GPU_buffer_free(gdo->edges);
- GPU_buffer_free(gdo->uvedges);
- GPU_buffer_free(gdo->triangles);
-
- MEM_freeN(gdo);
- dm->drawObject = NULL;
-}
-
-static GPUBuffer *gpu_try_realloc(GPUBufferPool *pool, GPUBuffer *buffer, size_t size)
-{
- /* try freeing an entry from the pool
- * and reallocating the buffer */
- gpu_buffer_free_intern(buffer);
-
- buffer = NULL;
-
- while (pool->totbuf && !buffer) {
- gpu_buffer_pool_delete_last(pool);
- buffer = gpu_buffer_alloc_intern(size);
- }
-
- return buffer;
-}
-
-static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
- int type, void *user, GPUBuffer *buffer)
-{
- GPUBufferPool *pool;
- float *varray;
- int *mat_orig_to_new;
- int i;
- const GPUBufferTypeSettings *ts = &gpu_buffer_type_settings[type];
- GLenum target = ts->gl_buffer_type;
- size_t size = gpu_buffer_size_from_type(dm, type);
- GLboolean uploaded;
-
- pool = gpu_get_global_buffer_pool();
-
- BLI_mutex_lock(&buffer_mutex);
-
- /* alloc a GPUBuffer; fall back to legacy mode on failure */
- if (!buffer) {
- if (!(buffer = gpu_buffer_alloc_intern(size))) {
- BLI_mutex_unlock(&buffer_mutex);
- return NULL;
- }
- }
-
- mat_orig_to_new = MEM_mallocN(sizeof(*mat_orig_to_new) * dm->totmat,
- "GPU_buffer_setup.mat_orig_to_new");
- for (i = 0; i < object->totmaterial; i++) {
- /* map from original material index to new
- * GPUBufferMaterial index */
- mat_orig_to_new[object->materials[i].mat_nr] = i;
- }
-
- /* bind the buffer and discard previous data,
- * avoids stalling gpu */
- glBindBuffer(target, buffer->id);
- glBufferData(target, buffer->size, NULL, GL_STATIC_DRAW);
-
- /* attempt to map the buffer */
- if (!(varray = glMapBuffer(target, GL_WRITE_ONLY))) {
- buffer = gpu_try_realloc(pool, buffer, size);
-
- /* allocation still failed; unfortunately we need to exit */
- if (!(buffer && (varray = glMapBuffer(target, GL_WRITE_ONLY)))) {
- if (buffer)
- gpu_buffer_free_intern(buffer);
- BLI_mutex_unlock(&buffer_mutex);
- return NULL;
- }
- }
-
- uploaded = GL_FALSE;
-
- /* attempt to upload the data to the VBO */
- while (uploaded == GL_FALSE) {
- dm->copy_gpu_data(dm, type, varray, mat_orig_to_new, user);
- /* glUnmapBuffer returns GL_FALSE if
- * the data store is corrupted; retry
- * in that case */
- uploaded = glUnmapBuffer(target);
- }
- glBindBuffer(target, 0);
-
- MEM_freeN(mat_orig_to_new);
-
- BLI_mutex_unlock(&buffer_mutex);
-
- return buffer;
-}
-
-/* get the GPUDrawObject buffer associated with a type */
-static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBufferType type)
-{
- switch (type) {
- case GPU_BUFFER_VERTEX:
- return &gdo->points;
- case GPU_BUFFER_NORMAL:
- return &gdo->normals;
- case GPU_BUFFER_COLOR:
- return &gdo->colors;
- case GPU_BUFFER_UV:
- return &gdo->uv;
- case GPU_BUFFER_UV_TEXPAINT:
- return &gdo->uv_tex;
- case GPU_BUFFER_EDGE:
- return &gdo->edges;
- case GPU_BUFFER_UVEDGE:
- return &gdo->uvedges;
- case GPU_BUFFER_TRIANGLES:
- return &gdo->triangles;
- default:
- return NULL;
- }
-}
-
-/* get the amount of space to allocate for a buffer of a particular type */
-static size_t gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type)
-{
- const int components = gpu_buffer_type_settings[type].num_components;
- switch (type) {
- case GPU_BUFFER_VERTEX:
- return sizeof(float) * components * (dm->drawObject->tot_loop_verts + dm->drawObject->tot_loose_point);
- case GPU_BUFFER_NORMAL:
- return sizeof(short) * components * dm->drawObject->tot_loop_verts;
- case GPU_BUFFER_COLOR:
- return sizeof(char) * components * dm->drawObject->tot_loop_verts;
- case GPU_BUFFER_UV:
- return sizeof(float) * components * dm->drawObject->tot_loop_verts;
- case GPU_BUFFER_UV_TEXPAINT:
- return sizeof(float) * components * dm->drawObject->tot_loop_verts;
- case GPU_BUFFER_EDGE:
- return sizeof(int) * components * dm->drawObject->totedge;
- case GPU_BUFFER_UVEDGE:
- return sizeof(int) * components * dm->drawObject->tot_loop_verts;
- case GPU_BUFFER_TRIANGLES:
- return sizeof(int) * components * dm->drawObject->tot_triangle_point;
- default:
- return -1;
- }
-}
-
-/* call gpu_buffer_setup with settings for a particular type of buffer */
-static GPUBuffer *gpu_buffer_setup_type(DerivedMesh *dm, GPUBufferType type, GPUBuffer *buf)
-{
- void *user_data = NULL;
-
- /* special handling for MCol and UV buffers */
- if (type == GPU_BUFFER_COLOR) {
- if (!(user_data = DM_get_loop_data_layer(dm, dm->drawObject->colType)))
- return NULL;
- }
- else if (ELEM(type, GPU_BUFFER_UV, GPU_BUFFER_UV_TEXPAINT)) {
- if (!DM_get_loop_data_layer(dm, CD_MLOOPUV))
- return NULL;
- }
-
- buf = gpu_buffer_setup(dm, dm->drawObject, type, user_data, buf);
-
- return buf;
-}
-
-/* get the buffer of `type', initializing the GPUDrawObject and
- * buffer if needed */
-static GPUBuffer *gpu_buffer_setup_common(DerivedMesh *dm, GPUBufferType type, bool update)
-{
- GPUBuffer **buf;
-
- if (!dm->drawObject)
- dm->drawObject = dm->gpuObjectNew(dm);
-
- buf = gpu_drawobject_buffer_from_type(dm->drawObject, type);
- if (!(*buf))
- *buf = gpu_buffer_setup_type(dm, type, NULL);
- else if (update)
- *buf = gpu_buffer_setup_type(dm, type, *buf);
-
- return *buf;
-}
-
-void GPU_vertex_setup(DerivedMesh *dm)
-{
- if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX, false))
- return;
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->points->id);
- glVertexPointer(3, GL_FLOAT, 0, 0);
-
- GLStates |= GPU_BUFFER_VERTEX_STATE;
-}
-
-void GPU_normal_setup(DerivedMesh *dm)
-{
- if (!gpu_buffer_setup_common(dm, GPU_BUFFER_NORMAL, false))
- return;
-
- glEnableClientState(GL_NORMAL_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->normals->id);
- glNormalPointer(GL_SHORT, 4 * sizeof(short), 0);
-
- GLStates |= GPU_BUFFER_NORMAL_STATE;
-}
-
-void GPU_uv_setup(DerivedMesh *dm)
-{
- if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV, false))
- return;
-
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uv->id);
- glTexCoordPointer(2, GL_FLOAT, 0, 0);
-
- GLStates |= GPU_BUFFER_TEXCOORD_UNIT_0_STATE;
-}
-
-void GPU_texpaint_uv_setup(DerivedMesh *dm)
-{
- if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV_TEXPAINT, false))
- return;
-
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uv_tex->id);
- glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), 0);
- glClientActiveTexture(GL_TEXTURE2);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), BUFFER_OFFSET(2 * sizeof(float)));
- glClientActiveTexture(GL_TEXTURE0);
-
- GLStates |= GPU_BUFFER_TEXCOORD_UNIT_0_STATE | GPU_BUFFER_TEXCOORD_UNIT_2_STATE;
-}
-
-
-void GPU_color_setup(DerivedMesh *dm, int colType)
-{
- bool update = false;
-
- if (!dm->drawObject) {
- /* XXX Not really nice, but we need a valid gpu draw object to set the colType...
- * Else we would have to add a new param to gpu_buffer_setup_common. */
- dm->drawObject = dm->gpuObjectNew(dm);
- dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW;
- dm->drawObject->colType = colType;
- }
- /* In paint mode, dm may stay the same during stroke, however we still want to update colors!
- * Also check in case we changed color type (i.e. which MCol cdlayer we use). */
- else if ((dm->dirty & DM_DIRTY_MCOL_UPDATE_DRAW) || (colType != dm->drawObject->colType)) {
- update = true;
- dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW;
- dm->drawObject->colType = colType;
- }
-
- if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR, update))
- return;
-
- glEnableClientState(GL_COLOR_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->colors->id);
- glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
-
- GLStates |= GPU_BUFFER_COLOR_STATE;
-}
-
-void GPU_buffer_bind_as_color(GPUBuffer *buffer)
-{
- glEnableClientState(GL_COLOR_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, buffer->id);
- glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
-
- GLStates |= GPU_BUFFER_COLOR_STATE;
-}
-
-
-void GPU_edge_setup(DerivedMesh *dm)
-{
- if (!gpu_buffer_setup_common(dm, GPU_BUFFER_EDGE, false))
- return;
-
- if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX, false))
- return;
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->points->id);
- glVertexPointer(3, GL_FLOAT, 0, 0);
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dm->drawObject->edges->id);
-
- GLStates |= (GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_ELEMENT_STATE);
-}
-
-void GPU_uvedge_setup(DerivedMesh *dm)
-{
- if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UVEDGE, false))
- return;
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uvedges->id);
- glVertexPointer(2, GL_FLOAT, 0, 0);
-
- GLStates |= GPU_BUFFER_VERTEX_STATE;
-}
-
-void GPU_triangle_setup(struct DerivedMesh *dm)
-{
- if (!gpu_buffer_setup_common(dm, GPU_BUFFER_TRIANGLES, false))
- return;
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dm->drawObject->triangles->id);
- GLStates |= GPU_BUFFER_ELEMENT_STATE;
-}
-
-static int gpu_typesize(int type)
-{
- switch (type) {
- case GL_FLOAT:
- return sizeof(float);
- case GL_INT:
- return sizeof(int);
- case GL_UNSIGNED_INT:
- return sizeof(unsigned int);
- case GL_BYTE:
- return sizeof(char);
- case GL_UNSIGNED_BYTE:
- return sizeof(unsigned char);
- default:
- return 0;
- }
-}
-
-int GPU_attrib_element_size(GPUAttrib data[], int numdata)
-{
- int i, elementsize = 0;
-
- for (i = 0; i < numdata; i++) {
- int typesize = gpu_typesize(data[i].type);
- if (typesize != 0)
- elementsize += typesize * data[i].size;
- }
- return elementsize;
-}
-
-void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata, int element_size)
-{
- int i;
- int elementsize;
- size_t offset = 0;
-
- for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) {
- if (attribData[i].index != -1) {
- glDisableVertexAttribArray(attribData[i].index);
- }
- else
- break;
- }
- if (element_size == 0)
- elementsize = GPU_attrib_element_size(data, numdata);
- else
- elementsize = element_size;
-
- glBindBuffer(GL_ARRAY_BUFFER, buffer->id);
-
- for (i = 0; i < numdata; i++) {
- glEnableVertexAttribArray(data[i].index);
- int info = 0;
- if (data[i].type == GL_UNSIGNED_BYTE) {
- info |= GPU_ATTR_INFO_SRGB;
- }
- glUniform1i(data[i].info_index, info);
-
- glVertexAttribPointer(data[i].index, data[i].size, data[i].type,
- GL_TRUE, elementsize, BUFFER_OFFSET(offset));
- offset += data[i].size * gpu_typesize(data[i].type);
-
- attribData[i].index = data[i].index;
- attribData[i].size = data[i].size;
- attribData[i].type = data[i].type;
- }
-
- attribData[numdata].index = -1;
-}
-
-void GPU_interleaved_attrib_unbind(void)
-{
- int i;
- for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) {
- if (attribData[i].index != -1) {
- glDisableVertexAttribArray(attribData[i].index);
- }
- else
- break;
- }
- attribData[0].index = -1;
-}
-
-void GPU_buffers_unbind(void)
-{
- int i;
-
- if (GLStates & GPU_BUFFER_VERTEX_STATE)
- glDisableClientState(GL_VERTEX_ARRAY);
- if (GLStates & GPU_BUFFER_NORMAL_STATE)
- glDisableClientState(GL_NORMAL_ARRAY);
- if (GLStates & GPU_BUFFER_TEXCOORD_UNIT_0_STATE)
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- if (GLStates & GPU_BUFFER_TEXCOORD_UNIT_2_STATE) {
- glClientActiveTexture(GL_TEXTURE2);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glClientActiveTexture(GL_TEXTURE0);
- }
- if (GLStates & GPU_BUFFER_COLOR_STATE)
- glDisableClientState(GL_COLOR_ARRAY);
- if (GLStates & GPU_BUFFER_ELEMENT_STATE)
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-
- GLStates &= ~(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE |
- GPU_BUFFER_TEXCOORD_UNIT_0_STATE | GPU_BUFFER_TEXCOORD_UNIT_2_STATE |
- GPU_BUFFER_COLOR_STATE | GPU_BUFFER_ELEMENT_STATE);
-
- for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) {
- if (attribData[i].index != -1) {
- glDisableVertexAttribArray(attribData[i].index);
- }
- else
- break;
- }
- attribData[0].index = -1;
-
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-}
-
-void GPU_color_switch(int mode)
-{
- if (mode) {
- if (!(GLStates & GPU_BUFFER_COLOR_STATE))
- glEnableClientState(GL_COLOR_ARRAY);
- GLStates |= GPU_BUFFER_COLOR_STATE;
- }
- else {
- if (GLStates & GPU_BUFFER_COLOR_STATE)
- glDisableClientState(GL_COLOR_ARRAY);
- GLStates &= ~GPU_BUFFER_COLOR_STATE;
- }
-}
-
-static int gpu_binding_type_gl[] =
-{
- GL_ARRAY_BUFFER,
- GL_ELEMENT_ARRAY_BUFFER
-};
-
-void *GPU_buffer_lock(GPUBuffer *buffer, GPUBindingType binding)
-{
- float *varray;
- int bindtypegl;
-
- if (!buffer)
- return 0;
-
- bindtypegl = gpu_binding_type_gl[binding];
- glBindBuffer(bindtypegl, buffer->id);
- varray = glMapBuffer(bindtypegl, GL_WRITE_ONLY);
- return varray;
-}
-
-void *GPU_buffer_lock_stream(GPUBuffer *buffer, GPUBindingType binding)
-{
- float *varray;
- int bindtypegl;
-
- if (!buffer)
- return 0;
-
- bindtypegl = gpu_binding_type_gl[binding];
- glBindBuffer(bindtypegl, buffer->id);
- /* discard previous data, avoid stalling gpu */
- glBufferData(bindtypegl, buffer->size, 0, GL_STREAM_DRAW);
- varray = glMapBuffer(bindtypegl, GL_WRITE_ONLY);
- return varray;
-}
-
-void GPU_buffer_unlock(GPUBuffer *UNUSED(buffer), GPUBindingType binding)
-{
- int bindtypegl = gpu_binding_type_gl[binding];
- /* note: this operation can fail, could return
- * an error code from this function? */
- glUnmapBuffer(bindtypegl);
- glBindBuffer(bindtypegl, 0);
-}
-
-void GPU_buffer_bind(GPUBuffer *buffer, GPUBindingType binding)
-{
- int bindtypegl = gpu_binding_type_gl[binding];
- glBindBuffer(bindtypegl, buffer->id);
-}
-
-void GPU_buffer_unbind(GPUBuffer *UNUSED(buffer), GPUBindingType binding)
-{
- int bindtypegl = gpu_binding_type_gl[binding];
- glBindBuffer(bindtypegl, 0);
-}
-
-/* used for drawing edges */
-void GPU_buffer_draw_elements(GPUBuffer *UNUSED(elements), unsigned int mode, int start, int count)
-{
- glDrawElements(mode, count, GL_UNSIGNED_INT, BUFFER_OFFSET(start * sizeof(unsigned int)));
-}
-
-
/* XXX: the rest of the code in this file is used for optimized PBVH
* drawing and doesn't interact at all with the buffer code above */
@@ -982,7 +108,6 @@ struct GPU_PBVH_Buffers {
bool show_diffuse_color;
bool show_mask;
- bool use_matcaps;
float diffuse_color[4];
};
@@ -990,6 +115,15 @@ static struct {
uint pos, nor, col;
} g_vbo_id = {0};
+static void gpu_material_diffuse_get(int UNUSED(nr), float diff[4])
+{
+ /* TODO: sculpt diffuse color option not supported in 2.8 yet. */
+ diff[0] = 0.8f;
+ diff[1] = 0.8f;
+ diff[2] = 0.8f;
+ diff[3] = 1.0f;
+}
+
/* Allocates a non-initialized buffer to be sent to GPU.
* Return is false it indicates that the memory map failed. */
static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int vert_ct)
@@ -1086,19 +220,16 @@ void GPU_pbvh_mesh_buffers_update(
buffers->vmask = vmask;
buffers->show_diffuse_color = show_diffuse_color;
buffers->show_mask = show_mask;
- buffers->use_matcaps = GPU_material_use_matcaps_get();
{
int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3));
float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 0.8f};
- if (buffers->use_matcaps)
- diffuse_color[0] = diffuse_color[1] = diffuse_color[2] = 1.0;
- else if (show_diffuse_color) {
+ if (show_diffuse_color) {
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]];
const MPoly *mp = &buffers->mpoly[lt->poly];
- GPU_material_diffuse_get(mp->mat_nr + 1, diffuse_color);
+ gpu_material_diffuse_get(mp->mat_nr + 1, diffuse_color);
}
copy_v4_v4(buffers->diffuse_color, diffuse_color);
@@ -1210,7 +341,6 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(
buffers->show_diffuse_color = false;
buffers->show_mask = true;
- buffers->use_matcaps = false;
/* Count the number of visible triangles */
for (i = 0, tottri = 0; i < face_indices_len; ++i) {
@@ -1283,7 +413,6 @@ void GPU_pbvh_grid_buffers_update(
buffers->show_diffuse_color = show_diffuse_color;
buffers->show_mask = show_mask;
- buffers->use_matcaps = GPU_material_use_matcaps_get();
buffers->smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH;
/* Build VBO */
@@ -1291,13 +420,10 @@ void GPU_pbvh_grid_buffers_update(
const int has_mask = key->has_mask;
float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f};
- if (buffers->use_matcaps) {
- diffuse_color[0] = diffuse_color[1] = diffuse_color[2] = 1.0;
- }
- else if (show_diffuse_color) {
+ if (show_diffuse_color) {
const DMFlagMat *flags = &grid_flag_mats[grid_indices[0]];
- GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color);
+ gpu_material_diffuse_get(flags->mat_nr + 1, diffuse_color);
}
copy_v4_v4(buffers->diffuse_color, diffuse_color);
@@ -1504,7 +630,6 @@ GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(
buffers->show_diffuse_color = false;
buffers->show_mask = true;
- buffers->use_matcaps = false;
/* Count the number of quads */
totquad = BKE_pbvh_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize);
@@ -1661,7 +786,6 @@ void GPU_pbvh_bmesh_buffers_update(
buffers->show_diffuse_color = show_diffuse_color;
buffers->show_mask = show_mask;
- buffers->use_matcaps = GPU_material_use_matcaps_get();
/* Count visible triangles */
tottri = gpu_bmesh_face_visible_count(bm_faces);
@@ -1678,15 +802,13 @@ void GPU_pbvh_bmesh_buffers_update(
return;
}
- if (buffers->use_matcaps)
- diffuse_color[0] = diffuse_color[1] = diffuse_color[2] = 1.0;
- else if (show_diffuse_color) {
+ if (show_diffuse_color) {
/* due to dynamic nature of dyntopo, only get first material */
GSetIterator gs_iter;
BMFace *f;
BLI_gsetIterator_init(&gs_iter, bm_faces);
f = BLI_gsetIterator_getKey(&gs_iter);
- GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
+ gpu_material_diffuse_get(f->mat_nr + 1, diffuse_color);
}
copy_v4_v4(buffers->diffuse_color, diffuse_color);
@@ -1734,7 +856,7 @@ void GPU_pbvh_bmesh_buffers_update(
int i;
#if 0
- BM_iter_as_array(bm, BM_VERTS_OF_FACE, f, (void**)v, 3);
+ BM_iter_as_array(bm, BM_VERTS_OF_FACE, f, (void **)v, 3);
#endif
BM_face_as_array_vert_tri(f, v);
@@ -1823,44 +945,10 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading)
buffers->smooth = smooth_shading;
buffers->show_diffuse_color = false;
buffers->show_mask = true;
- buffers->use_matcaps = false;
return buffers;
}
-void GPU_pbvh_buffers_draw(
- GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
- bool wireframe, bool fast)
-{
- UNUSED_VARS(wireframe, fast, setMaterial);
- bool do_fast = fast && buffers->triangles_fast;
- Gwn_Batch *triangles = do_fast ? buffers->triangles_fast : buffers->triangles;
-
- if (triangles) {
-
- /* Simple Shader: use when drawing without the draw-manager (old 2.7x viewport) */
- if (triangles->interface == NULL) {
- GPUBuiltinShader shader_id =
- buffers->smooth ? GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR : GPU_SHADER_SIMPLE_LIGHTING_FLAT_COLOR;
- GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
-
- GWN_batch_program_set(
- triangles,
- GPU_shader_get_program(shader), GPU_shader_get_interface(shader));
-
- static float light[3] = {-0.3f, 0.5f, 1.0f};
- static float alpha = 1.0f;
- static float world_light = 1.0f;
-
- GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "light"), 3, 1, light);
- GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "alpha"), 1, 1, &alpha);
- GPU_shader_uniform_vector(shader, GPU_shader_get_uniform(shader, "global"), 1, 1, &world_light);
-
- }
- GWN_batch_draw(triangles);
- }
-}
-
Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast)
{
return (fast && buffers->triangles_fast) ?
@@ -1870,22 +958,18 @@ Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast)
bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GSet *bm_faces, bool show_diffuse_color)
{
float diffuse_color[4];
- bool use_matcaps = GPU_material_use_matcaps_get();
if (buffers->show_diffuse_color != show_diffuse_color)
return true;
- if (buffers->use_matcaps != use_matcaps)
- return true;
-
- if ((buffers->show_diffuse_color == false) || use_matcaps)
+ if (buffers->show_diffuse_color == false)
return false;
if (buffers->looptri) {
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]];
const MPoly *mp = &buffers->mpoly[lt->poly];
- GPU_material_diffuse_get(mp->mat_nr + 1, diffuse_color);
+ gpu_material_diffuse_get(mp->mat_nr + 1, diffuse_color);
}
else if (buffers->use_bmesh) {
/* due to dynamic nature of dyntopo, only get first material */
@@ -1895,7 +979,7 @@ bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GSet *bm_faces,
BLI_gsetIterator_init(&gs_iter, bm_faces);
f = BLI_gsetIterator_getKey(&gs_iter);
- GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color);
+ gpu_material_diffuse_get(f->mat_nr + 1, diffuse_color);
}
else {
return false;
@@ -1904,7 +988,7 @@ bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GSet *bm_faces,
else {
const DMFlagMat *flags = &buffers->grid_flag_mats[buffers->grid_indices[0]];
- GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color);
+ gpu_material_diffuse_get(flags->mat_nr + 1, diffuse_color);
}
return !equals_v3v3(diffuse_color, buffers->diffuse_color);
@@ -2007,3 +1091,7 @@ void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos)
immEnd();
}
+
+void GPU_pbvh_fix_linking()
+{
+}
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index b245c9a161f..da69d9cdb16 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -780,7 +780,7 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
BLI_dynstr_append(ds, ";\n");
}
-static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUOutput *output, bool use_new_shading)
+static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUOutput *output)
{
DynStr *ds = BLI_dynstr_new();
char *code;
@@ -806,38 +806,20 @@ static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUO
BLI_dynstr_append(ds, "Closure nodetree_exec(void)\n{\n");
- if (use_new_shading) {
- if (builtins & GPU_VIEW_MATRIX)
- BLI_dynstr_append(ds, "\tmat4 viewmat = ViewMatrix;\n");
- if (builtins & GPU_CAMERA_TEXCO_FACTORS)
- BLI_dynstr_append(ds, "\tvec4 camtexfac = CameraTexCoFactors;\n");
- if (builtins & GPU_OBJECT_MATRIX)
- BLI_dynstr_append(ds, "\tmat4 objmat = ModelMatrix;\n");
- if (builtins & GPU_INVERSE_OBJECT_MATRIX)
- BLI_dynstr_append(ds, "\tmat4 objinv = ModelMatrixInverse;\n");
- if (builtins & GPU_INVERSE_VIEW_MATRIX)
- BLI_dynstr_append(ds, "\tmat4 viewinv = ViewMatrixInverse;\n");
- if (builtins & GPU_VIEW_NORMAL)
- BLI_dynstr_append(ds, "\tvec3 facingnormal = gl_FrontFacing? viewNormal: -viewNormal;\n");
- if (builtins & GPU_VIEW_POSITION)
- BLI_dynstr_append(ds, "\tvec3 viewposition = viewPosition;\n");
- }
- else {
- if (builtins & GPU_VIEW_MATRIX)
- BLI_dynstr_append(ds, "\tmat4 viewmat = unfviewmat;\n");
- if (builtins & GPU_CAMERA_TEXCO_FACTORS)
- BLI_dynstr_append(ds, "\tvec4 camtexfac = unfcameratexfactors;\n");
- if (builtins & GPU_OBJECT_MATRIX)
- BLI_dynstr_append(ds, "\tmat4 objmat = unfobmat;\n");
- if (builtins & GPU_INVERSE_OBJECT_MATRIX)
- BLI_dynstr_append(ds, "\tmat4 objinv = unfinvobmat;\n");
- if (builtins & GPU_INVERSE_VIEW_MATRIX)
- BLI_dynstr_append(ds, "\tmat4 viewinv = unfinvviewmat;\n");
- if (builtins & GPU_VIEW_NORMAL)
- BLI_dynstr_append(ds, "\tvec3 facingnormal = gl_FrontFacing? varnormal: -varnormal;\n");
- if (builtins & GPU_VIEW_POSITION)
- BLI_dynstr_append(ds, "\tvec3 viewposition = varposition;\n");
- }
+ if (builtins & GPU_VIEW_MATRIX)
+ BLI_dynstr_append(ds, "\tmat4 viewmat = ViewMatrix;\n");
+ if (builtins & GPU_CAMERA_TEXCO_FACTORS)
+ BLI_dynstr_append(ds, "\tvec4 camtexfac = CameraTexCoFactors;\n");
+ if (builtins & GPU_OBJECT_MATRIX)
+ BLI_dynstr_append(ds, "\tmat4 objmat = ModelMatrix;\n");
+ if (builtins & GPU_INVERSE_OBJECT_MATRIX)
+ BLI_dynstr_append(ds, "\tmat4 objinv = ModelMatrixInverse;\n");
+ if (builtins & GPU_INVERSE_VIEW_MATRIX)
+ BLI_dynstr_append(ds, "\tmat4 viewinv = ViewMatrixInverse;\n");
+ if (builtins & GPU_VIEW_NORMAL)
+ BLI_dynstr_append(ds, "\tvec3 facingnormal = gl_FrontFacing? viewNormal: -viewNormal;\n");
+ if (builtins & GPU_VIEW_POSITION)
+ BLI_dynstr_append(ds, "\tvec3 viewposition = viewPosition;\n");
/* Calculate tangent space. */
#ifdef WITH_OPENSUBDIV
@@ -906,7 +888,7 @@ static const char *attrib_prefix_get(CustomDataType type)
}
}
-static char *code_generate_vertex_new(ListBase *nodes, const char *vert_code, bool use_geom)
+static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool use_geom)
{
DynStr *ds = BLI_dynstr_new();
GPUNode *node;
@@ -983,115 +965,7 @@ static char *code_generate_vertex_new(ListBase *nodes, const char *vert_code, bo
return code;
}
-static char *code_generate_vertex(ListBase *nodes, const GPUMatType type)
-{
- DynStr *ds = BLI_dynstr_new();
- GPUNode *node;
- GPUInput *input;
- char *code;
- char *vertcode = NULL;
-
- for (node = nodes->first; node; node = node->next) {
- for (input = node->inputs.first; input; input = input->next) {
- if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
-#ifdef WITH_OPENSUBDIV
- bool skip_opensubdiv = ELEM(input->attribtype, CD_MTFACE, CD_TANGENT);
- if (skip_opensubdiv) {
- BLI_dynstr_appendf(ds, "#ifndef USE_OPENSUBDIV\n");
- }
-#endif
- BLI_dynstr_appendf(ds, "%s %s att%d;\n",
- GLEW_VERSION_3_0 ? "in" : "attribute",
- GPU_DATATYPE_STR[input->type], input->attribid);
- BLI_dynstr_appendf(ds, "uniform int att%d_info;\n", input->attribid);
- BLI_dynstr_appendf(ds, "%s %s var%d;\n",
- GLEW_VERSION_3_0 ? "out" : "varying",
- GPU_DATATYPE_STR[input->type], input->attribid);
-#ifdef WITH_OPENSUBDIV
- if (skip_opensubdiv) {
- BLI_dynstr_appendf(ds, "#endif\n");
- }
-#endif
- }
- }
- }
-
- BLI_dynstr_append(ds, "\n");
-
- switch (type) {
- case GPU_MATERIAL_TYPE_MESH:
- vertcode = datatoc_gpu_shader_vertex_glsl;
- break;
- case GPU_MATERIAL_TYPE_WORLD:
- vertcode = datatoc_gpu_shader_vertex_world_glsl;
- break;
- default:
- fprintf(stderr, "invalid material type, set one after GPU_material_construct_begin\n");
- break;
- }
-
- BLI_dynstr_append(ds, vertcode);
-
- for (node = nodes->first; node; node = node->next)
- for (input = node->inputs.first; input; input = input->next)
- if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
- if (input->attribtype == CD_TANGENT) { /* silly exception */
-#ifdef WITH_OPENSUBDIV
- BLI_dynstr_appendf(ds, "#ifndef USE_OPENSUBDIV\n");
-#endif
- BLI_dynstr_appendf(
- ds, "\tvar%d.xyz = normalize(NormalMatrix * att%d.xyz);\n",
- input->attribid, input->attribid);
- BLI_dynstr_appendf(
- ds, "\tvar%d.w = att%d.w;\n",
- input->attribid, input->attribid);
-#ifdef WITH_OPENSUBDIV
- BLI_dynstr_appendf(ds, "#endif\n");
-#endif
- }
- else {
-#ifdef WITH_OPENSUBDIV
- bool is_mtface = input->attribtype == CD_MTFACE;
- if (is_mtface) {
- BLI_dynstr_appendf(ds, "#ifndef USE_OPENSUBDIV\n");
- }
-#endif
- BLI_dynstr_appendf(ds, "\tset_var_from_attr(att%d, att%d_info, var%d);\n",
- input->attribid, input->attribid, input->attribid);
-#ifdef WITH_OPENSUBDIV
- if (is_mtface) {
- BLI_dynstr_appendf(ds, "#endif\n");
- }
-#endif
- }
- }
- /* unfortunately special handling is needed here because we abuse gl_Color/gl_SecondaryColor flat shading */
- else if (input->source == GPU_SOURCE_OPENGL_BUILTIN) {
- if (input->oglbuiltin == GPU_MATCAP_NORMAL) {
- /* remap to 0.0 - 1.0 range. This is done because OpenGL 2.0 clamps colors
- * between shader stages and we want the full range of the normal */
- BLI_dynstr_appendf(ds, "\tvec3 matcapcol = vec3(0.5) * varnormal + vec3(0.5);\n");
- BLI_dynstr_appendf(ds, "\tgl_FrontSecondaryColor = vec4(matcapcol, 1.0);\n");
- }
- else if (input->oglbuiltin == GPU_COLOR) {
- BLI_dynstr_appendf(ds, "\tgl_FrontColor = gl_Color;\n");
- }
- }
-
- BLI_dynstr_append(ds, "}\n");
-
- code = BLI_dynstr_get_cstring(ds);
-
- BLI_dynstr_free(ds);
-
-#if 0
- if (G.debug & G_DEBUG) printf("%s\n", code);
-#endif
-
- return code;
-}
-
-static char *code_generate_geometry_new(ListBase *nodes, const char *geom_code)
+static char *code_generate_geometry(ListBase *nodes, const char *geom_code)
{
DynStr *ds = BLI_dynstr_new();
GPUNode *node;
@@ -1136,67 +1010,6 @@ static char *code_generate_geometry_new(ListBase *nodes, const char *geom_code)
return code;
}
-static char *code_generate_geometry(ListBase *nodes, bool use_opensubdiv)
-{
-#ifdef WITH_OPENSUBDIV
- if (use_opensubdiv) {
- DynStr *ds = BLI_dynstr_new();
- GPUNode *node;
- GPUInput *input;
- char *code;
-
- /* Generate varying declarations. */
- for (node = nodes->first; node; node = node->next) {
- for (input = node->inputs.first; input; input = input->next) {
- if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
- if (input->attribtype == CD_MTFACE) {
- /* NOTE: For now we are using varying on purpose,
- * otherwise we are not able to write to the varying.
- */
- BLI_dynstr_appendf(ds, "%s %s var%d%s;\n",
- "varying",
- GPU_DATATYPE_STR[input->type],
- input->attribid,
- "");
- BLI_dynstr_appendf(ds, "uniform int fvar%d_offset;\n",
- input->attribid);
- }
- }
- }
- }
-
- BLI_dynstr_append(ds, datatoc_gpu_shader_geometry_glsl);
-
- /* Generate varying assignments. */
- for (node = nodes->first; node; node = node->next) {
- for (input = node->inputs.first; input; input = input->next) {
- if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) {
- if (input->attribtype == CD_MTFACE) {
- BLI_dynstr_appendf(
- ds,
- "\tINTERP_FACE_VARYING_ATT_2(var%d, "
- "int(texelFetch(FVarDataOffsetBuffer, fvar%d_offset).r), st);\n",
- input->attribid,
- input->attribid);
- }
- }
- }
- }
-
- BLI_dynstr_append(ds, "}\n");
- code = BLI_dynstr_get_cstring(ds);
- BLI_dynstr_free(ds);
-
- //if (G.debug & G_DEBUG) printf("%s\n", code);
-
- return code;
- }
-#else
- UNUSED_VARS(nodes, use_opensubdiv);
-#endif
- return NULL;
-}
-
void GPU_code_generate_glsl_lib(void)
{
DynStr *ds;
@@ -1223,65 +1036,6 @@ GPUShader *GPU_pass_shader(GPUPass *pass)
return pass->shader;
}
-static void gpu_nodes_extract_dynamic_inputs_new(GPUShader *shader, ListBase *inputs, ListBase *nodes)
-{
- GPUNode *node;
- GPUInput *next, *input;
- int extract, z;
-
- BLI_listbase_clear(inputs);
-
- if (!shader)
- return;
-
- GPU_shader_bind(shader);
-
- for (node = nodes->first; node; node = node->next) {
- z = 0;
- for (input = node->inputs.first; input; input = next, z++) {
- next = input->next;
-
- /* attributes don't need to be bound, they already have
- * an id that the drawing functions will use */
- if (input->source == GPU_SOURCE_ATTRIB) {
- continue;
- }
-
- if (input->source == GPU_SOURCE_BUILTIN ||
- input->source == GPU_SOURCE_OPENGL_BUILTIN)
- {
- continue;
- }
-
- if (input->ima || input->tex || input->prv)
- BLI_snprintf(input->shadername, sizeof(input->shadername), "samp%d", input->texid);
- else
- BLI_snprintf(input->shadername, sizeof(input->shadername), "unf%d", input->id);
-
- /* pass non-dynamic uniforms to opengl */
- extract = 0;
-
- if (input->ima || input->tex || input->prv) {
- if (input->bindtex)
- extract = 1;
- }
- else if (input->dynamicvec)
- extract = 1;
-
- if (extract)
- input->shaderloc = GPU_shader_get_uniform(shader, input->shadername);
-
- /* extract nodes */
- if (extract) {
- BLI_remlink(&node->inputs, input);
- BLI_addtail(inputs, input);
- }
- }
- }
-
- GPU_shader_unbind();
-}
-
static void gpu_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListBase *nodes)
{
GPUNode *node;
@@ -1303,26 +1057,9 @@ static void gpu_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs
/* attributes don't need to be bound, they already have
* an id that the drawing functions will use */
if (input->source == GPU_SOURCE_ATTRIB) {
-#ifdef WITH_OPENSUBDIV
- /* We do need mtface attributes for later, so we can
- * update face-varuing variables offset in the texture
- * buffer for proper sampling from the shader.
- *
- * We don't do anything about attribute itself, we
- * only use it to learn which uniform name is to be
- * updated.
- *
- * TODO(sergey): We can add ad extra uniform input
- * for the offset, which will be purely internal and
- * which would avoid having such an exceptions.
- */
- if (input->attribtype != CD_MTFACE) {
- continue;
- }
-#else
continue;
-#endif
}
+
if (input->source == GPU_SOURCE_BUILTIN ||
input->source == GPU_SOURCE_OPENGL_BUILTIN)
{
@@ -1347,14 +1084,6 @@ static void gpu_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs
if (extract)
input->shaderloc = GPU_shader_get_uniform(shader, input->shadername);
-#ifdef WITH_OPENSUBDIV
- if (input->source == GPU_SOURCE_ATTRIB &&
- input->attribtype == CD_MTFACE)
- {
- extract = 1;
- }
-#endif
-
/* extract nodes */
if (extract) {
BLI_remlink(&node->inputs, input);
@@ -1802,19 +1531,6 @@ void GPU_nodes_get_vertex_attributes(ListBase *nodes, GPUVertexAttribs *attribs)
}
}
-static void gpu_nodes_get_builtin_flag(ListBase *nodes, int *builtin)
-{
- GPUNode *node;
- GPUInput *input;
-
- *builtin = 0;
-
- for (node = nodes->first; node; node = node->next)
- for (input = node->inputs.first; input; input = input->next)
- if (input->source == GPU_SOURCE_BUILTIN)
- *builtin |= input->builtin;
-}
-
/* varargs linking */
GPUNodeLink *GPU_attribute(const CustomDataType type, const char *name)
@@ -2129,11 +1845,11 @@ GPUPass *GPU_generate_pass_new(
GPU_nodes_get_vertex_attributes(nodes, attribs);
/* generate code */
- char *fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output, true);
+ char *fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output);
char *tmp = BLI_strdupcat(frag_lib, glsl_material_library);
- vertexcode = code_generate_vertex_new(nodes, vert_code, (geom_code != NULL));
- geometrycode = (geom_code) ? code_generate_geometry_new(nodes, geom_code) : NULL;
+ vertexcode = code_generate_vertex(nodes, vert_code, (geom_code != NULL));
+ geometrycode = (geom_code) ? code_generate_geometry(nodes, geom_code) : NULL;
fragmentcode = BLI_strdupcat(tmp, fragmentgen);
MEM_freeN(fragmentgen);
@@ -2182,85 +1898,11 @@ GPUPass *GPU_generate_pass_new(
return NULL;
}
else {
- gpu_nodes_extract_dynamic_inputs_new(shader, inputs, nodes);
+ gpu_nodes_extract_dynamic_inputs(shader, inputs, nodes);
return pass;
}
}
-/* TODO(fclem) Remove for 2.8 */
-GPUPass *GPU_generate_pass(
- ListBase *nodes, ListBase *inputs, GPUNodeLink *outlink,
- GPUVertexAttribs *attribs, int *builtins,
- const GPUMatType type, const char *UNUSED(name),
- const bool use_opensubdiv,
- const bool use_new_shading)
-{
- GPUShader *shader;
- GPUPass *pass;
- char *vertexcode, *geometrycode, *fragmentcode;
-
-#if 0
- if (!FUNCTION_LIB) {
- GPU_nodes_free(nodes);
- return NULL;
- }
-#endif
-
- /* prune unused nodes */
- GPU_nodes_prune(nodes, outlink);
-
- GPU_nodes_get_vertex_attributes(nodes, attribs);
- gpu_nodes_get_builtin_flag(nodes, builtins);
-
- /* generate code and compile with opengl */
- fragmentcode = code_generate_fragment(NULL, nodes, outlink->output, false);
- vertexcode = code_generate_vertex(nodes, type);
- geometrycode = code_generate_geometry(nodes, use_opensubdiv);
-
- int flags = GPU_SHADER_FLAGS_NONE;
- if (use_opensubdiv) {
- flags |= GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV;
- }
- if (use_new_shading) {
- flags |= GPU_SHADER_FLAGS_NEW_SHADING;
- }
- shader = GPU_shader_create_ex(vertexcode,
- fragmentcode,
- geometrycode,
- glsl_material_library,
- NULL,
- flags);
-
- /* failed? */
- if (!shader) {
- if (fragmentcode)
- MEM_freeN(fragmentcode);
- if (vertexcode)
- MEM_freeN(vertexcode);
- memset(attribs, 0, sizeof(*attribs));
- memset(builtins, 0, sizeof(*builtins));
- gpu_nodes_free(nodes);
- return NULL;
- }
-
- /* create pass */
- pass = MEM_callocN(sizeof(GPUPass), "GPUPass");
- pass->refcount = 1;
- pass->shader = shader;
- pass->fragmentcode = fragmentcode;
- pass->geometrycode = geometrycode;
- pass->vertexcode = vertexcode;
- pass->libcode = glsl_material_library;
-
- BLI_linklist_prepend(&pass_cache, pass);
-
- /* extract dynamic inputs and throw away nodes */
- gpu_nodes_extract_dynamic_inputs(shader, inputs, nodes);
- gpu_nodes_free(nodes);
-
- return pass;
-}
-
void GPU_pass_release(GPUPass *pass)
{
BLI_assert(pass->refcount > 0);
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index dab0bc3f8b1..328da36c3de 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -180,8 +180,7 @@ GPUPass *GPU_generate_pass(
ListBase *nodes, ListBase *inputs, struct GPUNodeLink *outlink,
struct GPUVertexAttribs *attribs, int *builtin,
const GPUMatType type, const char *name,
- const bool use_opensubdiv,
- const bool use_new_shading);
+ const bool use_opensubdiv);
struct GPUShader *GPU_pass_shader(GPUPass *pass);
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 8b344716a9c..6b768d4bdd6 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -31,8 +31,8 @@
* Utility functions for dealing with OpenGL texture & material context,
* mipmap generation and light objects.
*
- * These are some obscure rendering functions shared between the
- * game engine and the blender, in this module to avoid duplication
+ * These are some obscure rendering functions shared between the game engine (not anymore)
+ * and the blender, in this module to avoid duplication
* and abstract them away from the rest a bit.
*/
@@ -70,12 +70,8 @@
#include "BKE_node.h"
#include "BKE_scene.h"
#include "BKE_DerivedMesh.h"
-#ifdef WITH_GAMEENGINE
-# include "BKE_object.h"
-#endif
#include "GPU_basic_shader.h"
-#include "GPU_buffers.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_material.h"
@@ -98,131 +94,7 @@
extern Material defmaterial; /* from material.c */
-/* Text Rendering */
-
-static void gpu_mcol(unsigned int ucol)
-{
- /* mcol order is swapped */
- const char *cp = (char *)&ucol;
- glColor3ub(cp[3], cp[2], cp[1]);
-}
-
-void GPU_render_text(
- int mode, const char *textstr, int textlen, unsigned int *col,
- const float *v_quad[4], const float *uv_quad[4],
- int glattrib)
-{
- /* XXX, 2.8 removes texface */
-#if 0
- Image *ima = mtexpoly->tpage;
-#else
- Image *ima = NULL;
-#endif
- if ((mode & GEMAT_TEXT) && (textlen > 0) && ima) {
- const float *v1 = v_quad[0];
- const float *v2 = v_quad[1];
- const float *v3 = v_quad[2];
- const float *v4 = v_quad[3];
- const size_t textlen_st = textlen;
- float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
-
- /* multiline */
- float line_start = 0.0f, line_height;
-
- if (v4)
- line_height = max_ffff(v1[1], v2[1], v3[1], v4[2]) - min_ffff(v1[1], v2[1], v3[1], v4[2]);
- else
- line_height = max_fff(v1[1], v2[1], v3[1]) - min_fff(v1[1], v2[1], v3[1]);
- line_height *= 1.2f; /* could be an option? */
- /* end multiline */
-
-
- /* color has been set */
- if (!col)
- glColor3f(1.0f, 1.0f, 1.0f);
-
- gpuPushMatrix();
-
- /* get the tab width */
- ImBuf *first_ibuf = BKE_image_get_first_ibuf(ima);
- matrixGlyph(first_ibuf, ' ', &centerx, &centery,
- &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
-
- float advance_tab = advance * 4; /* tab width could also be an option */
-
-
- for (size_t index = 0; index < textlen_st; ) {
- unsigned int character;
- float uv[4][2];
-
- /* lets calculate offset stuff */
- character = BLI_str_utf8_as_unicode_and_size_safe(textstr + index, &index);
-
- if (character == '\n') {
- gpuTranslate2f(line_start, -line_height);
- line_start = 0.0f;
- continue;
- }
- else if (character == '\t') {
- gpuTranslate2f(advance_tab, 0.0f);
- line_start -= advance_tab; /* so we can go back to the start of the line */
- continue;
-
- }
- else if (character > USHRT_MAX) {
- /* not much we can do here bmfonts take ushort */
- character = '?';
- }
-
- /* space starts at offset 1 */
- /* character = character - ' ' + 1; */
- matrixGlyph(first_ibuf, character, & centerx, &centery,
- &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
-
- uv[0][0] = (uv_quad[0][0] - centerx) * sizex + transx;
- uv[0][1] = (uv_quad[0][1] - centery) * sizey + transy;
- uv[1][0] = (uv_quad[1][0] - centerx) * sizex + transx;
- uv[1][1] = (uv_quad[1][1] - centery) * sizey + transy;
- uv[2][0] = (uv_quad[2][0] - centerx) * sizex + transx;
- uv[2][1] = (uv_quad[2][1] - centery) * sizey + transy;
-
- glBegin(GL_POLYGON);
- if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[0]);
- else glTexCoord2fv(uv[0]);
- if (col) gpu_mcol(col[0]);
- glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
-
- if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[1]);
- else glTexCoord2fv(uv[1]);
- if (col) gpu_mcol(col[1]);
- glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
-
- if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[2]);
- else glTexCoord2fv(uv[2]);
- if (col) gpu_mcol(col[2]);
- glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
-
- if (v4) {
- uv[3][0] = (uv_quad[3][0] - centerx) * sizex + transx;
- uv[3][1] = (uv_quad[3][1] - centery) * sizey + transy;
-
- if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[3]);
- else glTexCoord2fv(uv[3]);
- if (col) gpu_mcol(col[3]);
- glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
- }
- glEnd();
-
- gpuTranslate2f(advance, 0.0f);
- line_start -= advance; /* so we can go back to the start of the line */
- }
- gpuPopMatrix();
-
- BKE_image_release_ibuf(ima, first_ibuf, NULL);
- }
-}
-
-/* Checking powers of two for images since OpenGL ES requires it */
+//* Checking powers of two for images since OpenGL ES requires it */
#ifdef WITH_DDS
static bool is_power_of_2_resolution(int w, int h)
{
@@ -255,10 +127,6 @@ static int smaller_power_of_2_limit(int num)
/* Current OpenGL state caching for GPU_set_tpage */
static struct GPUTextureState {
- int curtile, tile;
- int curtilemode, tilemode;
- int curtileXRep, tileXRep;
- int curtileYRep, tileYRep;
Image *ima, *curima;
/* also controls min/mag filtering */
@@ -271,7 +139,7 @@ static struct GPUTextureState {
int alphablend;
float anisotropic;
int gpu_mipmap;
-} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.0f, 0};
+} GTS = {NULL, NULL, 1, 0, 0, -1, 1.0f, 0};
/* Mipmap settings */
@@ -359,28 +227,6 @@ float GPU_get_anisotropic(void)
/* Set OpenGL state for an MTFace */
-static void gpu_make_repbind(Image *ima)
-{
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
- if (ibuf == NULL)
- return;
-
- if (ima->repbind) {
- glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
- MEM_freeN(ima->repbind);
- ima->repbind = NULL;
- ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
- }
-
- ima->totbind = ima->xrep * ima->yrep;
-
- if (ima->totbind > 1) {
- ima->repbind = MEM_callocN(sizeof(int) * ima->totbind, "repbind");
- }
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
-}
-
static unsigned int *gpu_get_image_bindcode(Image *ima, GLenum textarget)
{
unsigned int *bind = 0;
@@ -393,38 +239,6 @@ static unsigned int *gpu_get_image_bindcode(Image *ima, GLenum textarget)
return bind;
}
-static void gpu_set_alpha_blend(GPUBlendMode alphablend)
-{
- if (alphablend == GPU_BLEND_SOLID) {
- glDisable(GL_BLEND);
- glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- }
- else if (alphablend == GPU_BLEND_ADD) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE);
- glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
- }
- else if (ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) {
- glEnable(GL_BLEND);
- glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-
- /* for OpenGL render we use the alpha channel, this makes alpha blend correct */
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- /* if U.glalphaclip == 1.0, some cards go bonkers...
- * turn off alpha test in this case */
-
- }
- else if (alphablend == GPU_BLEND_CLIP) {
- glDisable(GL_BLEND);
- glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
- }
- else if (alphablend == GPU_BLEND_ALPHA_TO_COVERAGE) {
- glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
- }
-}
-
typedef struct VerifyThreadData {
ImBuf *ibuf;
float *srgb_frect;
@@ -477,7 +291,7 @@ static void gpu_verify_high_bit_srgb_buffer(float *srgb_frect,
int GPU_verify_image(
Image *ima, ImageUser *iuser,
- int textarget, int tftile, bool compare, bool mipmap, bool is_data)
+ int textarget, bool compare, bool mipmap, bool is_data)
{
unsigned int *bind = NULL;
int tpx = 0, tpy = 0;
@@ -487,30 +301,9 @@ int GPU_verify_image(
/* flag to determine whether deep format is used */
bool use_high_bit_depth = false, do_color_management = false;
- /* initialize tile mode and number of repeats */
GTS.ima = ima;
- GTS.tilemode = (ima && (ima->tpageflag & (IMA_TILES | IMA_TWINANIM)));
- GTS.tileXRep = 0;
- GTS.tileYRep = 0;
-
- /* setting current tile according to frame */
- if (ima && (ima->tpageflag & IMA_TWINANIM))
- GTS.tile = ima->lastframe;
- else
- GTS.tile = tftile;
-
- GTS.tile = MAX2(0, GTS.tile);
-
- if (ima) {
- GTS.tileXRep = ima->xrep;
- GTS.tileYRep = ima->yrep;
- }
- /* if same image & tile, we're done */
- if (compare && ima == GTS.curima && GTS.curtile == GTS.tile &&
- GTS.tilemode == GTS.curtilemode && GTS.curtileXRep == GTS.tileXRep &&
- GTS.curtileYRep == GTS.tileYRep)
- {
+ if (compare && ima == GTS.curima) {
return (ima != NULL);
}
@@ -550,47 +343,7 @@ int GPU_verify_image(
ima->tpageflag &= ~IMA_TPAGE_REFRESH;
}
- if (GTS.tilemode) {
- /* tiled mode */
- if (ima->repbind == NULL) gpu_make_repbind(ima);
- if (GTS.tile >= ima->totbind) GTS.tile = 0;
-
- /* this happens when you change repeat buttons */
- if (ima->repbind && textarget == GL_TEXTURE_2D) bind = &ima->repbind[GTS.tile];
- else bind = gpu_get_image_bindcode(ima, textarget);
-
- if (*bind == 0) {
- short texwindx = ibuf->x / ima->xrep;
- short texwindy = ibuf->y / ima->yrep;
-
- if (GTS.tile >= ima->xrep * ima->yrep)
- GTS.tile = ima->xrep * ima->yrep - 1;
-
- short texwinsy = GTS.tile / ima->xrep;
- short texwinsx = GTS.tile - texwinsy * ima->xrep;
-
- texwinsx *= texwindx;
- texwinsy *= texwindy;
-
- tpx = texwindx;
- tpy = texwindy;
-
- if (use_high_bit_depth) {
- if (do_color_management) {
- srgb_frect = MEM_mallocN(ibuf->x * ibuf->y * sizeof(float) * 4, "floar_buf_col_cor");
- gpu_verify_high_bit_srgb_buffer(srgb_frect, ibuf);
- frect = srgb_frect + (4 * (texwinsy * ibuf->x + texwinsx));
- }
- else {
- frect = ibuf->rect_float + (ibuf->channels * (texwinsy * ibuf->x + texwinsx));
- }
- }
- else {
- rect = ibuf->rect + texwinsy * ibuf->x + texwinsx;
- }
- }
- }
- else {
+ {
/* regular image mode */
bind = gpu_get_image_bindcode(ima, textarget);
@@ -619,37 +372,6 @@ int GPU_verify_image(
const int rectw = tpx;
const int recth = tpy;
- unsigned *tilerect = NULL;
- float *ftilerect = NULL;
-
- /* for tiles, copy only part of image into buffer */
- if (GTS.tilemode) {
- if (use_high_bit_depth) {
- ftilerect = MEM_mallocN(rectw * recth * sizeof(*ftilerect), "tilerect");
-
- for (int y = 0; y < recth; y++) {
- const float *frectrow = &frect[y * ibuf->x];
- float *ftilerectrow = &ftilerect[y * rectw];
-
- memcpy(ftilerectrow, frectrow, tpx * sizeof(*frectrow));
- }
-
- frect = ftilerect;
- }
- else {
- tilerect = MEM_mallocN(rectw * recth * sizeof(*tilerect), "tilerect");
-
- for (int y = 0; y < recth; y++) {
- const unsigned *rectrow = &rect[y * ibuf->x];
- unsigned *tilerectrow = &tilerect[y * rectw];
-
- memcpy(tilerectrow, rectrow, tpx * sizeof(*rectrow));
- }
-
- rect = tilerect;
- }
- }
-
#ifdef WITH_DDS
if (ibuf->ftype == IMB_FTYPE_DDS)
GPU_create_gl_tex_compressed(bind, rect, rectw, recth, textarget, mipmap, ima, ibuf);
@@ -666,10 +388,6 @@ int GPU_verify_image(
}
/* clean up */
- if (tilerect)
- MEM_freeN(tilerect);
- if (ftilerect)
- MEM_freeN(ftilerect);
if (srgb_frect)
MEM_freeN(srgb_frect);
@@ -1092,8 +810,7 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
{
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
- if (ima->repbind ||
- (!GTS.gpu_mipmap && GPU_get_mipmap()) ||
+ if ((!GTS.gpu_mipmap && GPU_get_mipmap()) ||
(ima->bindcode[TEXTARGET_TEXTURE_2D] == 0) ||
(ibuf == NULL) ||
(w == 0) || (h == 0))
@@ -1170,61 +887,6 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
BKE_image_release_ibuf(ima, ibuf, NULL);
}
-void GPU_update_images_framechange(void)
-{
- for (Image *ima = G.main->image.first; ima; ima = ima->id.next) {
- if (ima->tpageflag & IMA_TWINANIM) {
- if (ima->twend >= ima->xrep * ima->yrep)
- ima->twend = ima->xrep * ima->yrep - 1;
-
- /* check: is bindcode not in the array? free. (to do) */
-
- ima->lastframe++;
- if (ima->lastframe > ima->twend)
- ima->lastframe = ima->twsta;
- }
- }
-}
-
-int GPU_update_image_time(Image *ima, double time)
-{
- if (!ima)
- return 0;
-
- if (ima->lastupdate < 0)
- ima->lastupdate = 0;
-
- if (ima->lastupdate > (float)time)
- ima->lastupdate = (float)time;
-
- int inc = 0;
-
- if (ima->tpageflag & IMA_TWINANIM) {
- if (ima->twend >= ima->xrep * ima->yrep) ima->twend = ima->xrep * ima->yrep - 1;
-
- /* check: is the bindcode not in the array? Then free. (still to do) */
-
- float diff = (float)((float)time - ima->lastupdate);
- inc = (int)(diff * (float)ima->animspeed);
-
- ima->lastupdate += ((float)inc / (float)ima->animspeed);
-
- int newframe = ima->lastframe + inc;
-
- if (newframe > (int)ima->twend) {
- if (ima->twend - ima->twsta != 0)
- newframe = (int)ima->twsta - 1 + (newframe - ima->twend) % (ima->twend - ima->twsta);
- else
- newframe = ima->twsta;
- }
-
- ima->lastframe = newframe;
- }
-
- return inc;
-}
-
-
void GPU_free_smoke(SmokeModifierData *smd)
{
if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
@@ -1343,9 +1005,6 @@ void GPU_free_unused_buffers(void)
BLI_linklist_free(image_free_queue, NULL);
image_free_queue = NULL;
- /* vbo buffers */
- GPU_global_buffer_pool_free_unused();
-
BLI_thread_unlock(LOCK_OPENGL);
}
@@ -1369,14 +1028,6 @@ void GPU_free_image(Image *ima)
}
}
- /* free repeated image binding */
- if (ima->repbind) {
- glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
-
- MEM_freeN(ima->repbind);
- ima->repbind = NULL;
- }
-
ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE | IMA_GLBIND_IS_DATA);
}
@@ -1420,7 +1071,7 @@ void GPU_free_images_old(void)
if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) {
/* If it's in GL memory, deallocate and set time tag to current time
* This gives textures a "second chance" to be used before dying. */
- if (BKE_image_has_bindcode(ima) || ima->repbind) {
+ if (BKE_image_has_bindcode(ima)) {
GPU_free_image(ima);
ima->lastused = ctime;
}
@@ -1433,668 +1084,6 @@ void GPU_free_images_old(void)
}
}
-
-/* OpenGL Materials */
-
-#define FIXEDMAT 8
-
-/* OpenGL state caching for materials */
-
-typedef struct GPUMaterialFixed {
- float diff[3];
- float spec[3];
- int hard;
- float alpha;
-} GPUMaterialFixed;
-
-static struct GPUMaterialState {
- GPUMaterialFixed (*matbuf);
- GPUMaterialFixed matbuf_fixed[FIXEDMAT];
- int totmat;
-
- /* set when called inside GPU_begin_object_materials / GPU_end_object_materials
- * otherwise calling GPU_object_material_bind returns zero */
- bool is_enabled;
-
- Material **gmatbuf;
- Material *gmatbuf_fixed[FIXEDMAT];
- Material *gboundmat;
- Object *gob;
- DupliObject *dob;
- Scene *gscene;
- int glay;
- float (*gviewmat)[4];
- float (*gviewinv)[4];
- float (*gviewcamtexcofac);
-
- bool backface_culling;
- bool two_sided_lighting;
-
- GPUBlendMode *alphablend;
- GPUBlendMode alphablend_fixed[FIXEDMAT];
- bool use_alpha_pass, is_alpha_pass;
- bool use_matcaps;
-
- int lastmatnr, lastretval;
- GPUBlendMode lastalphablend;
- bool is_opensubdiv;
-} GMS = {NULL};
-
-/* fixed function material, alpha handed by caller */
-static void gpu_material_to_fixed(
- GPUMaterialFixed *smat, const Material *bmat, const int gamma, const Object *ob,
- const int new_shading_nodes, const bool dimdown)
-{
- if (bmat->mode & MA_SHLESS) {
- copy_v3_v3(smat->diff, &bmat->r);
-
- if (gamma)
- linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
-
- zero_v3(smat->spec);
- smat->alpha = 1.0f;
- smat->hard = 0;
- }
- else if (new_shading_nodes) {
- copy_v3_v3(smat->diff, &bmat->r);
- copy_v3_v3(smat->spec, &bmat->specr);
- smat->alpha = 1.0f;
- smat->hard = CLAMPIS(bmat->har, 0, 128);
-
- if (dimdown) {
- mul_v3_fl(smat->diff, 0.8f);
- mul_v3_fl(smat->spec, 0.5f);
- }
-
- if (gamma) {
- linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
- linearrgb_to_srgb_v3_v3(smat->spec, smat->spec);
- }
- }
- else {
- mul_v3_v3fl(smat->diff, &bmat->r, bmat->ref + bmat->emit);
-
- if (bmat->shade_flag & MA_OBCOLOR)
- mul_v3_v3(smat->diff, ob->col);
-
- mul_v3_v3fl(smat->spec, &bmat->specr, bmat->spec);
- smat->hard = CLAMPIS(bmat->har, 1, 128);
- smat->alpha = 1.0f;
-
- if (gamma) {
- linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
- linearrgb_to_srgb_v3_v3(smat->spec, smat->spec);
- }
- }
-}
-
-static Material *gpu_active_node_material(Material *ma)
-{
- if (ma && ma->use_nodes && ma->nodetree) {
- bNode *node = nodeGetActiveID(ma->nodetree, ID_MA);
-
- if (node)
- return (Material *)node->id;
- else
- return NULL;
- }
-
- return ma;
-}
-
-void GPU_begin_dupli_object(DupliObject *dob)
-{
- GMS.dob = dob;
-}
-
-void GPU_end_dupli_object(void)
-{
- GMS.dob = NULL;
-}
-
-void GPU_begin_object_materials(
- View3D *v3d, RegionView3D *rv3d, Scene *scene, ViewLayer *view_layer, Object *ob,
- bool glsl, bool *do_alpha_after)
-{
- Material *ma;
- GPUMaterial *gpumat;
- GPUBlendMode alphablend;
- DupliObject *dob;
- int a;
- const bool gamma = BKE_scene_check_color_management_enabled(scene);
- const bool new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
- const bool use_matcap = (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) != 0; /* assumes v3d->defmaterial->preview is set */
- bool use_opensubdiv = false;
-
-#ifdef WITH_OPENSUBDIV
- {
- DerivedMesh *derivedFinal = NULL;
- if (ob->type == OB_MESH) {
- Mesh *me = ob->data;
- BMEditMesh *em = me->edit_btmesh;
- if (em != NULL) {
- derivedFinal = em->derivedFinal;
- }
- else {
- derivedFinal = ob->derivedFinal;
- }
- }
- else {
- derivedFinal = ob->derivedFinal;
- }
-
- if (derivedFinal != NULL && derivedFinal->type == DM_TYPE_CCGDM) {
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) derivedFinal;
- use_opensubdiv = ccgdm->useGpuBackend;
- }
- }
-#endif
-
-#ifdef WITH_GAMEENGINE
- if (rv3d->rflag & RV3D_IS_GAME_ENGINE) {
- ob = BKE_object_lod_matob_get(ob, view_layer);
- }
-#else
- UNUSED_VARS(view_layer);
-#endif
-
- /* initialize state */
- /* DupliObject must be restored */
- dob = GMS.dob;
- memset(&GMS, 0, sizeof(GMS));
- GMS.is_enabled = true;
- GMS.dob = dob;
- GMS.lastmatnr = -1;
- GMS.lastretval = -1;
- GMS.lastalphablend = GPU_BLEND_SOLID;
- GMS.use_matcaps = use_matcap;
-
- GMS.backface_culling = (v3d->flag2 & V3D_BACKFACE_CULLING) != 0;
-
- GMS.two_sided_lighting = false;
- if (ob && ob->type == OB_MESH)
- GMS.two_sided_lighting = (((Mesh *)ob->data)->flag & ME_TWOSIDED) != 0;
-
- GMS.gob = ob;
- GMS.gscene = scene;
- GMS.is_opensubdiv = use_opensubdiv;
- GMS.totmat = use_matcap ? 1 : ob->totcol + 1; /* materials start from 1, default material is 0 */
- GMS.glay = (v3d->localvd) ? v3d->localvd->lay : v3d->lay; /* keep lamps visible in local view */
- GMS.gviewmat = rv3d->viewmat;
- GMS.gviewinv = rv3d->viewinv;
- GMS.gviewcamtexcofac = rv3d->viewcamtexcofac;
-
- /* alpha pass setup. there's various cases to handle here:
- * - object transparency on: only solid materials draw in the first pass,
- * and only transparent in the second 'alpha' pass.
- * - object transparency off: for glsl we draw both in a single pass, and
- * for solid we don't use transparency at all. */
- GMS.use_alpha_pass = (do_alpha_after != NULL);
- GMS.is_alpha_pass = (v3d->transp != false);
- if (GMS.use_alpha_pass)
- *do_alpha_after = false;
-
- if (GMS.totmat > FIXEDMAT) {
- GMS.matbuf = MEM_callocN(sizeof(GPUMaterialFixed) * GMS.totmat, "GMS.matbuf");
- GMS.gmatbuf = MEM_callocN(sizeof(*GMS.gmatbuf) * GMS.totmat, "GMS.matbuf");
- GMS.alphablend = MEM_callocN(sizeof(*GMS.alphablend) * GMS.totmat, "GMS.matbuf");
- }
- else {
- GMS.matbuf = GMS.matbuf_fixed;
- GMS.gmatbuf = GMS.gmatbuf_fixed;
- GMS.alphablend = GMS.alphablend_fixed;
- }
-
- /* viewport material, setup in space_view3d, defaults to matcap using ma->preview now */
- if (use_matcap) {
- GMS.gmatbuf[0] = v3d->defmaterial;
- GPU_material_matcap(scene, v3d->defmaterial, use_opensubdiv);
-
- /* do material 1 too, for displists! */
- memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed));
-
- GMS.alphablend[0] = GPU_BLEND_SOLID;
- }
- else {
-
- /* no materials assigned? */
- if (ob->totcol == 0) {
- gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob, new_shading_nodes, true);
-
- /* do material 1 too, for displists! */
- memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed));
-
- if (glsl) {
- GMS.gmatbuf[0] = &defmaterial;
- GPU_material_from_blender(GMS.gscene, &defmaterial, GMS.is_opensubdiv);
- }
-
- GMS.alphablend[0] = GPU_BLEND_SOLID;
- }
-
- /* setup materials */
- for (a = 1; a <= ob->totcol; a++) {
- /* find a suitable material */
- ma = give_current_material(ob, a);
- if (!glsl && !new_shading_nodes) ma = gpu_active_node_material(ma);
- if (ma == NULL) ma = &defmaterial;
-
- /* create glsl material if requested */
- gpumat = glsl ? GPU_material_from_blender(GMS.gscene, ma, GMS.is_opensubdiv) : NULL;
-
- if (gpumat) {
- /* do glsl only if creating it succeed, else fallback */
- GMS.gmatbuf[a] = ma;
- alphablend = GPU_material_alpha_blend(gpumat, ob->col);
- }
- else {
- /* fixed function opengl materials */
- gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob, new_shading_nodes, false);
-
- if (GMS.use_alpha_pass && ((ma->mode & MA_TRANSP) || (new_shading_nodes && ma->alpha != 1.0f))) {
- GMS.matbuf[a].alpha = ma->alpha;
- alphablend = (ma->alpha == 1.0f) ? GPU_BLEND_SOLID: GPU_BLEND_ALPHA;
- }
- else {
- GMS.matbuf[a].alpha = 1.0f;
- alphablend = GPU_BLEND_SOLID;
- }
- }
-
- /* setting 'do_alpha_after = true' indicates this object needs to be
- * drawn in a second alpha pass for improved blending */
- if (do_alpha_after && !GMS.is_alpha_pass)
- if (ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ADD, GPU_BLEND_ALPHA_SORT))
- *do_alpha_after = true;
-
- GMS.alphablend[a] = alphablend;
- }
- }
-
- /* let's start with a clean state */
- GPU_object_material_unbind();
-}
-
-static int gpu_get_particle_info(GPUParticleInfo *pi)
-{
- DupliObject *dob = GMS.dob;
- if (dob->particle_system) {
- int ind;
- if (dob->persistent_id[0] < dob->particle_system->totpart)
- ind = dob->persistent_id[0];
- else {
- ind = dob->particle_system->child[dob->persistent_id[0] - dob->particle_system->totpart].parent;
- }
- if (ind >= 0) {
- ParticleData *p = &dob->particle_system->particles[ind];
-
- pi->scalprops[0] = ind;
- pi->scalprops[1] = GMS.gscene->r.cfra - p->time;
- pi->scalprops[2] = p->lifetime;
- pi->scalprops[3] = p->size;
-
- copy_v3_v3(pi->location, p->state.co);
- pi->location[3] = BLI_hash_int_01(ind);
-
- copy_v3_v3(pi->velocity, p->state.vel);
- copy_v3_v3(pi->angular_velocity, p->state.ave);
- return 1;
- }
- else return 0;
- }
- else
- return 0;
-}
-
-static void GPU_get_object_info(float oi[3], Material *mat)
-{
- Object *ob = GMS.gob;
- oi[0] = ob->index;
- oi[1] = mat->index;
- unsigned int random;
- if (GMS.dob) {
- random = GMS.dob->random_id;
- }
- else {
- random = BLI_hash_int_2d(BLI_hash_string(GMS.gob->id.name + 2), 0);
- }
- oi[2] = random * (1.0f / (float)0xFFFFFFFF);
-}
-
-int GPU_object_material_bind(int nr, void *attribs)
-{
- GPUVertexAttribs *gattribs = attribs;
-
- /* no GPU_begin_object_materials, use default material */
- if (!GMS.matbuf) {
- memset(&GMS, 0, sizeof(GMS));
-
- float diffuse[3], specular[3];
- mul_v3_v3fl(diffuse, &defmaterial.r, defmaterial.ref + defmaterial.emit);
- mul_v3_v3fl(specular, &defmaterial.specr, defmaterial.spec);
- GPU_basic_shader_colors(diffuse, specular, 35, 1.0f);
-
- if (GMS.two_sided_lighting)
- GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_TWO_SIDED);
- else
- GPU_basic_shader_bind(GPU_SHADER_LIGHTING);
-
- return 0;
- }
-
- /* prevent index to use un-initialized array items */
- if (nr >= GMS.totmat)
- nr = 0;
-
- if (gattribs)
- memset(gattribs, 0, sizeof(*gattribs));
-
- /* keep current material */
- if (nr == GMS.lastmatnr)
- return GMS.lastretval;
-
- /* unbind glsl material */
- if (GMS.gboundmat) {
- if (GMS.is_alpha_pass) glDepthMask(0);
- GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat, GMS.is_opensubdiv));
- GMS.gboundmat = NULL;
- }
-
- /* draw materials with alpha in alpha pass */
- GMS.lastmatnr = nr;
- GMS.lastretval = 1;
-
- if (GMS.use_alpha_pass) {
- GMS.lastretval = ELEM(GMS.alphablend[nr], GPU_BLEND_SOLID, GPU_BLEND_CLIP);
- if (GMS.is_alpha_pass)
- GMS.lastretval = !GMS.lastretval;
- }
- else
- GMS.lastretval = !GMS.is_alpha_pass;
-
- if (GMS.lastretval) {
- /* for alpha pass, use alpha blend */
- GPUBlendMode alphablend = GMS.alphablend[nr];
-
- if (gattribs && GMS.gmatbuf[nr]) {
- /* bind glsl material and get attributes */
- Material *mat = GMS.gmatbuf[nr];
- GPUParticleInfo partile_info;
- float object_info[3] = {0};
-
- float auto_bump_scale;
-
- GPUMaterial *gpumat = GPU_material_from_blender(GMS.gscene, mat, GMS.is_opensubdiv);
- GPU_material_vertex_attributes(gpumat, gattribs);
-
- if (GMS.dob) {
- gpu_get_particle_info(&partile_info);
- }
-
- if ((GPU_get_material_builtins(gpumat) & GPU_OBJECT_INFO) != 0) {
- GPU_get_object_info(object_info, mat);
- }
-
- GPU_material_bind(
- gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT),
- GMS.gviewmat, GMS.gviewinv, GMS.gviewcamtexcofac);
-
- auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f;
- GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gob->col, auto_bump_scale, &partile_info, object_info);
- GMS.gboundmat = mat;
-
- /* for glsl use alpha blend mode, unless it's set to solid and
- * we are already drawing in an alpha pass */
- if (mat->game.alpha_blend != GPU_BLEND_SOLID)
- alphablend = mat->game.alpha_blend;
-
- if (GMS.is_alpha_pass) glDepthMask(1);
-
- if (GMS.backface_culling) {
- if (mat->game.flag)
- glEnable(GL_CULL_FACE);
- else
- glDisable(GL_CULL_FACE);
- }
-
- if (GMS.use_matcaps)
- glColor3f(1.0f, 1.0f, 1.0f);
- }
- else {
- /* or do fixed function opengl material */
- GPU_basic_shader_colors(
- GMS.matbuf[nr].diff,
- GMS.matbuf[nr].spec, GMS.matbuf[nr].hard, GMS.matbuf[nr].alpha);
-
- if (GMS.two_sided_lighting)
- GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_TWO_SIDED);
- else
- GPU_basic_shader_bind(GPU_SHADER_LIGHTING);
- }
-
- /* set (alpha) blending mode */
- GPU_set_material_alpha_blend(alphablend);
- }
-
- return GMS.lastretval;
-}
-
-int GPU_object_material_visible(int nr, void *attribs)
-{
- GPUVertexAttribs *gattribs = attribs;
- int visible;
-
- if (!GMS.matbuf)
- return 0;
-
- if (gattribs)
- memset(gattribs, 0, sizeof(*gattribs));
-
- if (nr >= GMS.totmat)
- nr = 0;
-
- if (GMS.use_alpha_pass) {
- visible = ELEM(GMS.alphablend[nr], GPU_BLEND_SOLID, GPU_BLEND_CLIP);
- if (GMS.is_alpha_pass)
- visible = !visible;
- }
- else
- visible = !GMS.is_alpha_pass;
-
- return visible;
-}
-
-void GPU_set_material_alpha_blend(int alphablend)
-{
- if (GMS.lastalphablend == alphablend)
- return;
-
- gpu_set_alpha_blend(alphablend);
- GMS.lastalphablend = alphablend;
-}
-
-int GPU_get_material_alpha_blend(void)
-{
- return GMS.lastalphablend;
-}
-
-void GPU_object_material_unbind(void)
-{
- GMS.lastmatnr = -1;
- GMS.lastretval = 1;
-
- if (GMS.gboundmat) {
- if (GMS.backface_culling)
- glDisable(GL_CULL_FACE);
-
- if (GMS.is_alpha_pass) glDepthMask(0);
- GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat, GMS.is_opensubdiv));
- GMS.gboundmat = NULL;
- }
- else
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
-
- GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
-}
-
-void GPU_material_diffuse_get(int nr, float diff[4])
-{
- /* prevent index to use un-initialized array items */
- if (nr >= GMS.totmat)
- nr = 0;
-
- /* no GPU_begin_object_materials, use default material */
- if (!GMS.matbuf) {
- mul_v3_v3fl(diff, &defmaterial.r, defmaterial.ref + defmaterial.emit);
- }
- else {
- copy_v3_v3(diff, GMS.matbuf[nr].diff);
- diff[3] = GMS.matbuf[nr].alpha;
- }
-}
-
-bool GPU_material_use_matcaps_get(void)
-{
- return GMS.use_matcaps;
-}
-
-bool GPU_object_materials_check(void)
-{
- return GMS.is_enabled;
-}
-
-void GPU_end_object_materials(void)
-{
- GPU_object_material_unbind();
-
- GMS.is_enabled = false;
-
- if (GMS.matbuf && GMS.matbuf != GMS.matbuf_fixed) {
- MEM_freeN(GMS.matbuf);
- MEM_freeN(GMS.gmatbuf);
- MEM_freeN(GMS.alphablend);
- }
-
- GMS.matbuf = NULL;
- GMS.gmatbuf = NULL;
- GMS.alphablend = NULL;
- GMS.two_sided_lighting = false;
-}
-
-/* Lights */
-
-int GPU_default_lights(void)
-{
- /* initialize */
- if (U.light[0].flag == 0 && U.light[1].flag == 0 && U.light[2].flag == 0) {
- U.light[0].flag = 1;
- U.light[0].vec[0] = -0.3; U.light[0].vec[1] = 0.3; U.light[0].vec[2] = 0.9;
- U.light[0].col[0] = 0.8; U.light[0].col[1] = 0.8; U.light[0].col[2] = 0.8;
- U.light[0].spec[0] = 0.5; U.light[0].spec[1] = 0.5; U.light[0].spec[2] = 0.5;
- U.light[0].spec[3] = 1.0;
-
- U.light[1].flag = 0;
- U.light[1].vec[0] = 0.5; U.light[1].vec[1] = 0.5; U.light[1].vec[2] = 0.1;
- U.light[1].col[0] = 0.4; U.light[1].col[1] = 0.4; U.light[1].col[2] = 0.8;
- U.light[1].spec[0] = 0.3; U.light[1].spec[1] = 0.3; U.light[1].spec[2] = 0.5;
- U.light[1].spec[3] = 1.0;
-
- U.light[2].flag = 0;
- U.light[2].vec[0] = 0.3; U.light[2].vec[1] = -0.3; U.light[2].vec[2] = -0.2;
- U.light[2].col[0] = 0.8; U.light[2].col[1] = 0.5; U.light[2].col[2] = 0.4;
- U.light[2].spec[0] = 0.5; U.light[2].spec[1] = 0.4; U.light[2].spec[2] = 0.3;
- U.light[2].spec[3] = 1.0;
- }
-
- GPU_basic_shader_light_set_viewer(false);
-
- int count = 0;
-
- for (int a = 0; a < 8; a++) {
- if (a < 3 && U.light[a].flag) {
- GPULightData light = {0};
-
- light.type = GPU_LIGHT_SUN;
-
- normalize_v3_v3(light.direction, U.light[a].vec);
- copy_v3_v3(light.diffuse, U.light[a].col);
- copy_v3_v3(light.specular, U.light[a].spec);
-
- GPU_basic_shader_light_set(a, &light);
-
- count++;
- }
- else
- GPU_basic_shader_light_set(a, NULL);
- }
-
- return count;
-}
-
-int GPU_scene_object_lights(ViewLayer *view_layer, float viewmat[4][4], int ortho)
-{
- /* disable all lights */
- for (int count = 0; count < 8; count++)
- GPU_basic_shader_light_set(count, NULL);
-
- /* view direction for specular is not computed correct by default in
- * opengl, so we set the settings ourselves */
- GPU_basic_shader_light_set_viewer(!ortho);
-
- int count = 0;
-
- for (Base *base = FIRSTBASE(view_layer); base; base = base->next) {
- if (base->object->type != OB_LAMP)
- continue;
-
- Lamp *la = base->object->data;
-
- /* setup lamp transform */
- gpuPushMatrix();
- gpuLoadMatrix(viewmat);
-
- /* setup light */
- GPULightData light = {0};
-
- mul_v3_v3fl(light.diffuse, &la->r, la->energy);
- mul_v3_v3fl(light.specular, &la->r, la->energy);
-
- if (la->type == LA_SUN) {
- /* directional sun light */
- light.type = GPU_LIGHT_SUN;
- normalize_v3_v3(light.direction, base->object->obmat[2]);
- }
- else {
- /* other lamps with position attenuation */
- copy_v3_v3(light.position, base->object->obmat[3]);
-
- light.constant_attenuation = 1.0f;
- light.linear_attenuation = la->att1 / la->dist;
- light.quadratic_attenuation = la->att2 / (la->dist * la->dist);
-
- if (la->type == LA_SPOT) {
- light.type = GPU_LIGHT_SPOT;
- negate_v3_v3(light.direction, base->object->obmat[2]);
- normalize_v3(light.direction);
- light.spot_cutoff = RAD2DEGF(la->spotsize * 0.5f);
- light.spot_exponent = 128.0f * la->spotblend;
- }
- else
- light.type = GPU_LIGHT_POINT;
- }
-
- GPU_basic_shader_light_set(count, &light);
-
- gpuPopMatrix();
-
- count++;
- if (count == 8)
- break;
- }
-
- return count;
-}
-
static void gpu_disable_multisample(void)
{
#ifdef __linux__
@@ -2120,15 +1109,13 @@ static void gpu_disable_multisample(void)
/* Default OpenGL State
*
- * This is called on startup, for opengl offscreen render and to restore state
- * for the game engine. Generally we should always return to this state when
+ * This is called on startup, for opengl offscreen render.
+ * Generally we should always return to this state when
* temporarily modifying the state for drawing, though that are (undocumented)
* exceptions that we should try to get rid of. */
void GPU_state_init(void)
{
- GPU_default_lights();
-
GPU_disable_program_point_size();
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
@@ -2159,34 +1146,6 @@ void GPU_disable_program_point_size(void)
glDisable(GL_PROGRAM_POINT_SIZE);
}
-#ifdef WITH_OPENSUBDIV
-/* Update face-varying variables offset which might be
- * different from mesh to mesh sharing the same material.
- */
-void GPU_draw_update_fvar_offset(DerivedMesh *dm)
-{
- /* Sanity check to be sure we only do this for OpenSubdiv draw. */
- BLI_assert(dm->type == DM_TYPE_CCGDM);
- BLI_assert(GMS.is_opensubdiv);
-
- for (int i = 0; i < GMS.totmat; ++i) {
- Material *material = GMS.gmatbuf[i];
- GPUMaterial *gpu_material;
-
- if (material == NULL) {
- continue;
- }
-
- gpu_material = GPU_material_from_blender(GMS.gscene,
- material,
- GMS.is_opensubdiv);
-
- GPU_material_update_fvar_offset(gpu_material, dm);
- }
-}
-#endif
-
-
/** \name Framebuffer color depth, for selection codes
* \{ */
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index 8d8fb50d9b9..73a1f14b9f6 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -87,7 +87,7 @@ static GLenum convert_attachment_type_to_gl(GPUAttachmentType type)
[GPU_FB_COLOR_ATTACHMENT2] = GL_COLOR_ATTACHMENT2,
[GPU_FB_COLOR_ATTACHMENT3] = GL_COLOR_ATTACHMENT3,
[GPU_FB_COLOR_ATTACHMENT4] = GL_COLOR_ATTACHMENT4
- };
+ };
return table[type];
}
@@ -210,8 +210,8 @@ static void gpu_framebuffer_texture_attach_ex(GPUFrameBuffer *fb, GPUTexture *te
GPUAttachment *attachment = &fb->attachments[type];
if ((attachment->tex == tex) &&
- (attachment->mip == mip) &&
- (attachment->layer == layer))
+ (attachment->mip == mip) &&
+ (attachment->layer == layer))
{
return; /* Exact same texture already bound here. */
}
@@ -543,7 +543,7 @@ void GPU_framebuffer_blit(
BLI_assert(GPU_texture_format(read_tex) == GPU_texture_format(write_tex));
}
if (GPU_texture_samples(write_tex) != 0 ||
- GPU_texture_samples(read_tex) != 0)
+ GPU_texture_samples(read_tex) != 0)
{
/* Can only blit multisample textures to another texture of the same size. */
BLI_assert((fb_read->width == fb_write->width) &&
@@ -664,11 +664,13 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
ofs->depth = GPU_texture_create_depth_with_stencil_multisample(width, height, samples, err_out);
}
- if (!ofs->depth || !ofs->color) {
+ if ((depth && !ofs->depth) || !ofs->color) {
GPU_offscreen_free(ofs);
return NULL;
}
-
+
+ gpuPushAttrib(GPU_VIEWPORT_BIT);
+
GPU_framebuffer_ensure_config(&ofs->fb, {
GPU_ATTACHMENT_TEXTURE(ofs->depth),
GPU_ATTACHMENT_TEXTURE(ofs->color)
@@ -677,11 +679,14 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
/* check validity at the very end! */
if (!GPU_framebuffer_check_valid(ofs->fb, err_out)) {
GPU_offscreen_free(ofs);
+ gpuPopAttrib();
return NULL;
}
GPU_framebuffer_restore();
+ gpuPopAttrib();
+
return ofs;
}
diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c
index 7a6b1ff6c70..5015d7c2372 100644
--- a/source/blender/gpu/intern/gpu_init_exit.c
+++ b/source/blender/gpu/intern/gpu_init_exit.c
@@ -30,6 +30,7 @@
*/
#include "BLI_sys_types.h"
+#include "GPU_buffers.h"
#include "GPU_init_exit.h" /* interface */
#include "GPU_immediate.h"
#include "GPU_batch.h"
@@ -63,6 +64,8 @@ void GPU_init(void)
gpu_batch_init();
immInit();
+
+ GPU_pbvh_fix_linking();
}
diff --git a/source/blender/gpu/intern/gpu_lamp.c b/source/blender/gpu/intern/gpu_lamp.c
deleted file mode 100644
index 8968521060d..00000000000
--- a/source/blender/gpu/intern/gpu_lamp.c
+++ /dev/null
@@ -1,460 +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) 2006 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Brecht Van Lommel, Clément Foucault.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/gpu/intern/gpu_lamp.c
- * \ingroup gpu
- *
- * Manages Opengl lights.
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_lamp_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-
-#include "BLI_listbase.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_group.h"
-
-#include "GPU_framebuffer.h"
-#include "GPU_glew.h"
-#include "GPU_lamp.h"
-#include "GPU_material.h"
-#include "GPU_shader.h"
-#include "GPU_texture.h"
-#include "GPU_batch.h"
-
-#include "gpu_lamp_private.h"
-
-bool GPU_lamp_visible(GPULamp *lamp, Material *ma)
-{
- if (lamp->hide)
- return false;
- else if (ma && ma->group)
- return BKE_group_object_exists(ma->group, lamp->ob);
- else
- return true;
-}
-
-static void gpu_lamp_calc_winmat(GPULamp *lamp)
-{
- float temp, angle, pixsize, wsize;
-
- if (lamp->type == LA_SUN) {
- wsize = lamp->la->shadow_frustum_size;
- orthographic_m4(lamp->winmat, -wsize, wsize, -wsize, wsize, lamp->d, lamp->clipend);
- }
- else if (lamp->type == LA_SPOT) {
- angle = saacos(lamp->spotsi);
- temp = 0.5f * lamp->size * cosf(angle) / sinf(angle);
- pixsize = lamp->d / temp;
- wsize = pixsize * 0.5f * lamp->size;
- /* compute shadows according to X and Y scaling factors */
- perspective_m4(
- lamp->winmat,
- -wsize * lamp->spotvec[0], wsize * lamp->spotvec[0],
- -wsize * lamp->spotvec[1], wsize * lamp->spotvec[1],
- lamp->d, lamp->clipend);
- }
-}
-
-void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[4][4])
-{
- float mat[4][4];
- float obmat_scale[3];
-
- lamp->lay = lay;
- lamp->hide = hide;
-
- normalize_m4_m4_ex(mat, obmat, obmat_scale);
-
- copy_v3_v3(lamp->vec, mat[2]);
- copy_v3_v3(lamp->co, mat[3]);
- copy_m4_m4(lamp->obmat, mat);
- invert_m4_m4(lamp->imat, mat);
-
- if (lamp->type == LA_SPOT) {
- /* update spotlamp scale on X and Y axis */
- lamp->spotvec[0] = obmat_scale[0] / obmat_scale[2];
- lamp->spotvec[1] = obmat_scale[1] / obmat_scale[2];
- }
-
- if (GPU_lamp_has_shadow_buffer(lamp)) {
- /* makeshadowbuf */
- gpu_lamp_calc_winmat(lamp);
- }
-}
-
-void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy)
-{
- lamp->energy = energy;
- if (lamp->mode & LA_NEG) lamp->energy = -lamp->energy;
-
- lamp->col[0] = r;
- lamp->col[1] = g;
- lamp->col[2] = b;
-}
-
-void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float att2,
- float coeff_const, float coeff_lin, float coeff_quad)
-{
- lamp->dist = distance;
- lamp->att1 = att1;
- lamp->att2 = att2;
- lamp->coeff_const = coeff_const;
- lamp->coeff_lin = coeff_lin;
- lamp->coeff_quad = coeff_quad;
-}
-
-void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend)
-{
- lamp->spotsi = cosf(spotsize * 0.5f);
- lamp->spotbl = (1.0f - lamp->spotsi) * spotblend;
-}
-
-static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *la, GPULamp *lamp)
-{
- lamp->scene = scene;
- lamp->ob = ob;
- lamp->par = par;
- lamp->la = la;
-
- /* add_render_lamp */
- lamp->mode = la->mode;
- lamp->type = la->type;
-
- lamp->energy = la->energy;
- if (lamp->mode & LA_NEG) lamp->energy = -lamp->energy;
-
- lamp->col[0] = la->r;
- lamp->col[1] = la->g;
- lamp->col[2] = la->b;
-
- GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), ob->obmat);
-
- lamp->spotsi = la->spotsize;
- if (lamp->mode & LA_HALO)
- if (lamp->spotsi > DEG2RADF(170.0f))
- lamp->spotsi = DEG2RADF(170.0f);
- lamp->spotsi = cosf(lamp->spotsi * 0.5f);
- lamp->spotbl = (1.0f - lamp->spotsi) * la->spotblend;
- lamp->k = la->k;
-
- lamp->dist = la->dist;
- lamp->falloff_type = la->falloff_type;
- lamp->att1 = la->att1;
- lamp->att2 = la->att2;
- lamp->coeff_const = la->coeff_const;
- lamp->coeff_lin = la->coeff_lin;
- lamp->coeff_quad = la->coeff_quad;
- lamp->curfalloff = la->curfalloff;
-
- /* initshadowbuf */
- lamp->bias = 0.02f * la->bias;
- lamp->size = la->bufsize;
- lamp->d = la->clipsta;
- lamp->clipend = la->clipend;
-
- /* arbitrary correction for the fact we do no soft transition */
- lamp->bias *= 0.25f;
-}
-
-static void gpu_lamp_shadow_free(GPULamp *lamp)
-{
- if (lamp->tex) {
- GPU_texture_free(lamp->tex);
- lamp->tex = NULL;
- }
- if (lamp->depthtex) {
- GPU_texture_free(lamp->depthtex);
- lamp->depthtex = NULL;
- }
- if (lamp->fb) {
- GPU_framebuffer_free(lamp->fb);
- lamp->fb = NULL;
- }
- if (lamp->blurtex) {
- GPU_texture_free(lamp->blurtex);
- lamp->blurtex = NULL;
- }
- if (lamp->blurfb) {
- GPU_framebuffer_free(lamp->blurfb);
- lamp->blurfb = NULL;
- }
-}
-
-static GPUTexture *gpu_lamp_create_vsm_shadow_map(int size)
-{
- return GPU_texture_create_2D_custom(size, size, 2, GPU_RG32F, NULL, NULL);
-}
-
-LampEngineData *GPU_lamp_engine_data_get(Scene *scene, Object *ob, Object *par, struct RenderEngineType *re)
-{
- GPULamp *lamp;
- LinkData *link;
-
- for (link = ob->gpulamp.first; link; link = link->next) {
- lamp = (GPULamp *)link->data;
-
- if ((lamp->par == par) && (lamp->scene == scene) && (lamp->re == re))
- return &lamp->data;
- }
-
- lamp = MEM_callocN(sizeof(GPULamp), "GPULamp");
-
- link = MEM_callocN(sizeof(LinkData), "GPULampLink");
- link->data = lamp;
- BLI_addtail(&ob->gpulamp, link);
-
- lamp->scene = scene;
- lamp->ob = ob;
- lamp->par = par;
- lamp->la = ob->data;
- lamp->re = re;
-
- return &lamp->data;
-}
-
-GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par)
-{
- Lamp *la;
- GPULamp *lamp;
- LinkData *link;
-
- for (link = ob->gpulamp.first; link; link = link->next) {
- lamp = (GPULamp *)link->data;
-
- if (lamp->par == par && lamp->scene == scene)
- return link->data;
- }
-
- lamp = MEM_callocN(sizeof(GPULamp), "GPULamp");
-
- link = MEM_callocN(sizeof(LinkData), "GPULampLink");
- link->data = lamp;
- BLI_addtail(&ob->gpulamp, link);
-
- la = ob->data;
- gpu_lamp_from_blender(scene, ob, par, la, lamp);
-
- if ((la->type == LA_SPOT && (la->mode & (LA_SHAD_BUF | LA_SHAD_RAY))) ||
- (la->type == LA_SUN && (la->mode & LA_SHAD_RAY)))
- {
- if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
- lamp->depthtex = GPU_texture_create_depth(lamp->size, lamp->size, NULL);
- lamp->tex = gpu_lamp_create_vsm_shadow_map(lamp->size);
- lamp->blurtex = gpu_lamp_create_vsm_shadow_map(lamp->size * 0.5);
-
- lamp->fb = GPU_framebuffer_create();
- GPU_framebuffer_texture_attach(lamp->fb, lamp->depthtex, 0, 0);
- GPU_framebuffer_texture_attach(lamp->fb, lamp->tex, 0, 0);
-
- lamp->blurfb = GPU_framebuffer_create();
- GPU_framebuffer_texture_attach(lamp->blurfb, lamp->blurtex, 0, 0);
-
- if (!GPU_framebuffer_check_valid(lamp->fb, NULL) ||
- !GPU_framebuffer_check_valid(lamp->blurfb, NULL))
- {
- gpu_lamp_shadow_free(lamp);
- return lamp;
- }
- }
- else {
- lamp->tex = GPU_texture_create_depth(lamp->size, lamp->size, NULL);
-
- GPU_texture_bind(lamp->tex, 0);
- GPU_texture_compare_mode(lamp->tex, true);
- GPU_texture_filter_mode(lamp->tex, true);
- GPU_texture_unbind(lamp->tex);
-
- lamp->fb = GPU_framebuffer_create();
- GPU_framebuffer_texture_attach(lamp->fb, lamp->tex, 0, 0);
-
- if (!GPU_framebuffer_check_valid(lamp->fb, NULL)) {
- gpu_lamp_shadow_free(lamp);
- return lamp;
- }
- }
-
- GPU_framebuffer_restore();
-
- lamp->shadow_color[0] = la->shdwr;
- lamp->shadow_color[1] = la->shdwg;
- lamp->shadow_color[2] = la->shdwb;
- }
- else {
- lamp->shadow_color[0] = 1.0;
- lamp->shadow_color[1] = 1.0;
- lamp->shadow_color[2] = 1.0;
- }
-
- return lamp;
-}
-
-void GPU_lamp_engine_data_free(LampEngineData *led)
-{
- for (int i = 0; i < MAX_LAMP_DATA; ++i) {
- if (led->storage[i]) {
- MEM_freeN(led->storage[i]);
- led->storage[i] = NULL;
- }
- }
-}
-
-void GPU_lamp_free(Object *ob)
-{
- GPULamp *lamp;
- LinkData *link;
-
- for (link = ob->gpulamp.first; link; link = link->next) {
- lamp = link->data;
-
- gpu_lamp_shadow_free(lamp);
- GPU_lamp_engine_data_free(&lamp->data);
-
- MEM_freeN(lamp);
- }
-
- BLI_freelistN(&ob->gpulamp);
-}
-
-bool GPU_lamp_has_shadow_buffer(GPULamp *lamp)
-{
- return (!(lamp->scene->gm.flag & GAME_GLSL_NO_SHADOWS) &&
- !(lamp->scene->gm.flag & GAME_GLSL_NO_LIGHTS) &&
- lamp->tex && lamp->fb);
-}
-
-void GPU_lamp_update_buffer_mats(GPULamp *lamp)
-{
- float rangemat[4][4], persmat[4][4];
-
- /* initshadowbuf */
- invert_m4_m4(lamp->viewmat, lamp->obmat);
- normalize_v3(lamp->viewmat[0]);
- normalize_v3(lamp->viewmat[1]);
- normalize_v3(lamp->viewmat[2]);
-
- /* makeshadowbuf */
- mul_m4_m4m4(persmat, lamp->winmat, lamp->viewmat);
-
- /* opengl depth buffer is range 0.0..1.0 instead of -1.0..1.0 in blender */
- unit_m4(rangemat);
- rangemat[0][0] = 0.5f;
- rangemat[1][1] = 0.5f;
- rangemat[2][2] = 0.5f;
- rangemat[3][0] = 0.5f;
- rangemat[3][1] = 0.5f;
- rangemat[3][2] = 0.5f;
-
- mul_m4_m4m4(lamp->persmat, rangemat, persmat);
-}
-
-void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[4][4], int *winsize, float winmat[4][4])
-{
- GPU_lamp_update_buffer_mats(lamp);
-
- /* opengl */
- glDisable(GL_SCISSOR_TEST);
- GPU_framebuffer_bind(lamp->fb);
- if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE)
- GPU_shader_bind(GPU_shader_get_builtin_shader(GPU_SHADER_VSM_STORE));
-
- /* set matrices */
- copy_m4_m4(viewmat, lamp->viewmat);
- copy_m4_m4(winmat, lamp->winmat);
- *winsize = lamp->size;
-}
-
-static void gpu_lamp_shadow_blur(GPULamp *lamp)
-{
- const float scaleh[2] = {1.0f / GPU_texture_width(lamp->blurtex), 0.0f};
- const float scalev[2] = {0.0f, 1.0f / GPU_texture_height(lamp->tex)};
-
- GPUShader *blur_shader = GPU_shader_get_builtin_shader(GPU_SHADER_SEP_GAUSSIAN_BLUR);
-
- if (!blur_shader)
- return;
-
- int tex_loc = GPU_shader_get_uniform(blur_shader, "textureSource");
- int scale_loc = GPU_shader_get_uniform(blur_shader, "ScaleU");
-
- glDisable(GL_DEPTH_TEST);
-
- GPU_shader_bind(blur_shader);
-
- /* Blurring horizontally */
- GPU_framebuffer_bind(lamp->blurfb);
- GPU_texture_bind(lamp->tex, 0);
- GPU_shader_uniform_vector(blur_shader, scale_loc, 2, 1, scaleh);
- GPU_shader_uniform_texture(blur_shader, tex_loc, lamp->tex);
- GWN_draw_primitive(GL_TRIANGLES, 3);
-
- /* Blurring vertically */
- GPU_framebuffer_bind(lamp->fb);
- GPU_texture_bind(lamp->blurtex, 0);
- GPU_shader_uniform_vector(blur_shader, scale_loc, 2, 1, scalev);
- GPU_shader_uniform_texture(blur_shader, tex_loc, lamp->blurtex);
- GWN_draw_primitive(GL_TRIANGLES, 3);
-}
-
-void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp)
-{
- if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
- GPU_shader_unbind();
- gpu_lamp_shadow_blur(lamp);
- }
-
- GPU_framebuffer_restore();
- glEnable(GL_SCISSOR_TEST);
-}
-
-int GPU_lamp_shadow_buffer_type(GPULamp *lamp)
-{
- return lamp->la->shadowmap_type;
-}
-
-int GPU_lamp_shadow_bind_code(GPULamp *lamp)
-{
- return lamp->tex ? GPU_texture_opengl_bindcode(lamp->tex) : -1;
-}
-
-float *GPU_lamp_dynpersmat(GPULamp *lamp)
-{
- return &lamp->dynpersmat[0][0];
-}
-
-int GPU_lamp_shadow_layer(GPULamp *lamp)
-{
- if (lamp->fb && lamp->tex && (lamp->mode & (LA_LAYER | LA_LAYER_SHADOW)))
- return lamp->lay;
- else
- return -1;
-}
diff --git a/source/blender/gpu/intern/gpu_lamp_private.h b/source/blender/gpu/intern/gpu_lamp_private.h
deleted file mode 100644
index f227ce74e7e..00000000000
--- a/source/blender/gpu/intern/gpu_lamp_private.h
+++ /dev/null
@@ -1,84 +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) 2005 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Brecht Van Lommel, Clément Foucault.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gpu_lamp_private.h
- * \ingroup gpu
- */
-
-#ifndef __GPU_LAMP_PRIVATE_H__
-#define __GPU_LAMP_PRIVATE_H__
-
-#include "BLI_sys_types.h" /* for bool */
-
-struct GPULamp {
- Scene *scene;
- Object *ob;
- Object *par;
- Lamp *la;
- struct RenderEngineType *re;
-
- /* Old Viewport (pre-2.8) */
- int type, mode, lay, hide;
-
- float dynenergy, dyncol[3];
- float energy, col[3];
-
- float co[3], vec[3];
- float dynco[3], dynvec[3];
- float obmat[4][4];
- float imat[4][4];
- float dynimat[4][4];
-
- float spotsi, spotbl, k;
- float spotvec[2];
- float dyndist, dynatt1, dynatt2;
- float dist, att1, att2;
- float coeff_const, coeff_lin, coeff_quad;
- float shadow_color[3];
-
- float bias, d, clipend;
- int size;
-
- int falloff_type;
- struct CurveMapping *curfalloff;
-
- float winmat[4][4];
- float viewmat[4][4];
- float persmat[4][4];
- float dynpersmat[4][4];
-
- GPUFrameBuffer *fb;
- GPUFrameBuffer *blurfb;
- GPUTexture *tex;
- GPUTexture *depthtex;
- GPUTexture *blurtex;
-
- /* New viewport */
- struct LampEngineData data;
-};
-
-#endif /* __GPU_LAMP_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index a408a41513a..d5f4f3269ed 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -62,7 +62,6 @@
#include "GPU_extensions.h"
#include "GPU_framebuffer.h"
-#include "GPU_lamp.h"
#include "GPU_material.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
@@ -71,7 +70,6 @@
#include "DRW_engine.h"
#include "gpu_codegen.h"
-#include "gpu_lamp_private.h"
#ifdef WITH_OPENSUBDIV
# include "BKE_DerivedMesh.h"
@@ -79,25 +77,6 @@
/* Structs */
-typedef enum DynMatProperty {
- DYN_LAMP_CO = 1,
- DYN_LAMP_VEC = 2,
- DYN_LAMP_IMAT = 4,
- DYN_LAMP_PERSMAT = 8,
-} DynMatProperty;
-
-static struct GPUWorld {
- float mistenabled;
- float mistype;
- float miststart;
- float mistdistance;
- float mistintensity;
- float mistcol[4];
- float horicol[3];
- float ambcol[4];
- float zencol[3];
-} GPUWorld;
-
struct GPUMaterial {
Scene *scene; /* DEPRECATED was only usefull for lamps */
Material *ma;
@@ -136,9 +115,6 @@ struct GPUMaterial {
int objectinfoloc;
- ListBase lamps;
- bool bound;
-
bool is_opensubdiv;
/* XXX: Should be in Material. But it depends on the output node
@@ -165,115 +141,8 @@ enum {
GPU_DOMAIN_SSS = (1 << 2)
};
-/* Forward declaration so shade_light_textures() can use this, while still keeping the code somewhat organized */
-static void texture_rgb_blend(
- GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg,
- int blendtype, GPUNodeLink **in);
-
/* Functions */
-static GPUMaterial *GPU_material_construct_begin(Material *ma)
-{
- GPUMaterial *material = MEM_callocN(sizeof(GPUMaterial), "GPUMaterial");
-
- material->ma = ma;
-
- return material;
-}
-
-static void gpu_material_set_attrib_id(GPUMaterial *material)
-{
- GPUVertexAttribs *attribs = &material->attribs;
- GPUPass *pass = material->pass;
- if (!pass) {
- attribs->totlayer = 0;
- return;
- }
-
- GPUShader *shader = GPU_pass_shader(pass);
- if (!shader) {
- attribs->totlayer = 0;
- return;
- }
-
- /* convert from attribute number to the actual id assigned by opengl,
- * in case the attrib does not get a valid index back, it was probably
- * removed by the glsl compiler by dead code elimination */
-
- int b = 0;
- for (int a = 0; a < attribs->totlayer; a++) {
- char name[32];
- BLI_snprintf(name, sizeof(name), "att%d", attribs->layer[a].attribid);
- attribs->layer[a].glindex = GPU_shader_get_attribute(shader, name);
-
- BLI_snprintf(name, sizeof(name), "att%d_info", attribs->layer[a].attribid);
- attribs->layer[a].glinfoindoex = GPU_shader_get_uniform(shader, name);
-
- if (attribs->layer[a].glindex >= 0) {
- attribs->layer[b] = attribs->layer[a];
- b++;
- }
- }
-
- attribs->totlayer = b;
-}
-
-static int gpu_material_construct_end(GPUMaterial *material, const char *passname)
-{
- if (material->outlink) {
- GPUNodeLink *outlink = material->outlink;
- material->pass = GPU_generate_pass(&material->nodes, &material->inputs, outlink,
- &material->attribs, &material->builtins, material->type,
- passname,
- material->is_opensubdiv,
- GPU_material_use_new_shading_nodes(material));
-
- material->status = (material->pass) ? GPU_MAT_SUCCESS : GPU_MAT_FAILED;
-
- if (!material->pass)
- return 0;
-
- gpu_material_set_attrib_id(material);
-
- GPUShader *shader = GPU_pass_shader(material->pass);
-
- if (material->builtins & GPU_VIEW_MATRIX)
- material->viewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_VIEW_MATRIX));
- if (material->builtins & GPU_INVERSE_VIEW_MATRIX)
- material->invviewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_VIEW_MATRIX));
- if (material->builtins & GPU_OBJECT_MATRIX)
- material->obmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBJECT_MATRIX));
- if (material->builtins & GPU_INVERSE_OBJECT_MATRIX)
- material->invobmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_OBJECT_MATRIX));
- if (material->builtins & GPU_LOC_TO_VIEW_MATRIX)
- material->localtoviewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_LOC_TO_VIEW_MATRIX));
- if (material->builtins & GPU_INVERSE_LOC_TO_VIEW_MATRIX)
- material->invlocaltoviewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_LOC_TO_VIEW_MATRIX));
- if (material->builtins & GPU_OBCOLOR)
- material->obcolloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBCOLOR));
- if (material->builtins & GPU_AUTO_BUMPSCALE)
- material->obautobumpscaleloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_AUTO_BUMPSCALE));
- if (material->builtins & GPU_CAMERA_TEXCO_FACTORS)
- material->cameratexcofacloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_CAMERA_TEXCO_FACTORS));
- if (material->builtins & GPU_PARTICLE_SCALAR_PROPS)
- material->partscalarpropsloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_PARTICLE_SCALAR_PROPS));
- if (material->builtins & GPU_PARTICLE_LOCATION)
- material->partcoloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_PARTICLE_LOCATION));
- if (material->builtins & GPU_PARTICLE_VELOCITY)
- material->partvel = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_PARTICLE_VELOCITY));
- if (material->builtins & GPU_PARTICLE_ANG_VELOCITY)
- material->partangvel = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_PARTICLE_ANG_VELOCITY));
- if (material->builtins & GPU_OBJECT_INFO)
- material->objectinfoloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBJECT_INFO));
- return 1;
- }
- else {
- GPU_pass_free_nodes(&material->nodes);
- }
-
- return 0;
-}
-
void GPU_material_free(ListBase *gpumaterial)
{
for (LinkData *link = gpumaterial->first; link; link = link->next) {
@@ -300,166 +169,17 @@ void GPU_material_free(ListBase *gpumaterial)
GPU_uniformbuffer_free(material->sss_profile);
}
- BLI_freelistN(&material->lamps);
-
MEM_freeN(material);
}
BLI_freelistN(gpumaterial);
}
-void GPU_material_bind(
- GPUMaterial *material, int oblay, int viewlay, double time, int mipmap,
- float viewmat[4][4], float viewinv[4][4], float camerafactors[4])
-{
- if (material->pass) {
- GPUShader *shader = GPU_pass_shader(material->pass);
-
- /* handle layer lamps */
- if (material->type == GPU_MATERIAL_TYPE_MESH) {
- for (LinkData *nlink = material->lamps.first; nlink; nlink = nlink->next) {
- GPULamp *lamp = nlink->data;
-
- if ((lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay)) &&
- GPU_lamp_visible(lamp, material->ma))
- {
- lamp->dynenergy = lamp->energy;
- copy_v3_v3(lamp->dyncol, lamp->col);
- }
- else {
- lamp->dynenergy = 0.0f;
- lamp->dyncol[0] = lamp->dyncol[1] = lamp->dyncol[2] = 0.0f;
- }
-
- if (material->dynproperty & DYN_LAMP_VEC) {
- copy_v3_v3(lamp->dynvec, lamp->vec);
- normalize_v3(lamp->dynvec);
- negate_v3(lamp->dynvec);
- mul_mat3_m4_v3(viewmat, lamp->dynvec);
- }
-
- if (material->dynproperty & DYN_LAMP_CO) {
- copy_v3_v3(lamp->dynco, lamp->co);
- mul_m4_v3(viewmat, lamp->dynco);
- }
-
- if (material->dynproperty & DYN_LAMP_IMAT) {
- mul_m4_m4m4(lamp->dynimat, lamp->imat, viewinv);
- }
-
- if (material->dynproperty & DYN_LAMP_PERSMAT) {
- /* The lamp matrices are already updated if we're using shadow buffers */
- if (!GPU_lamp_has_shadow_buffer(lamp)) {
- GPU_lamp_update_buffer_mats(lamp);
- }
- mul_m4_m4m4(lamp->dynpersmat, lamp->persmat, viewinv);
- }
- }
- }
-
- /* note material must be bound before setting uniforms */
- GPU_pass_bind(material->pass, &material->inputs, time, mipmap);
-
- /* handle per material built-ins */
- if (material->builtins & GPU_VIEW_MATRIX) {
- GPU_shader_uniform_vector(shader, material->viewmatloc, 16, 1, (float *)viewmat);
- }
- if (material->builtins & GPU_INVERSE_VIEW_MATRIX) {
- GPU_shader_uniform_vector(shader, material->invviewmatloc, 16, 1, (float *)viewinv);
- }
- if (material->builtins & GPU_CAMERA_TEXCO_FACTORS) {
- if (camerafactors) {
- GPU_shader_uniform_vector(shader, material->cameratexcofacloc, 4, 1, (float *)camerafactors);
- }
- else {
- /* use default, no scaling no offset */
- float borders[4] = {1.0f, 1.0f, 0.0f, 0.0f};
- GPU_shader_uniform_vector(shader, material->cameratexcofacloc, 4, 1, (float *)borders);
- }
- }
-
- GPU_pass_update_uniforms(material->pass, &material->inputs);
-
- material->bound = 1;
- }
-}
-
GPUBuiltin GPU_get_material_builtins(GPUMaterial *material)
{
return material->builtins;
}
-void GPU_material_bind_uniforms(
- GPUMaterial *material, float obmat[4][4], float viewmat[4][4], float obcol[4],
- float autobumpscale, GPUParticleInfo *pi, float object_info[3])
-{
- if (material->pass) {
- GPUShader *shader = GPU_pass_shader(material->pass);
- float invmat[4][4], col[4];
- float localtoviewmat[4][4];
- float invlocaltoviewmat[4][4];
-
- /* handle per object builtins */
- if (material->builtins & GPU_OBJECT_MATRIX) {
- GPU_shader_uniform_vector(shader, material->obmatloc, 16, 1, (float *)obmat);
- }
- if (material->builtins & GPU_INVERSE_OBJECT_MATRIX) {
- invert_m4_m4(invmat, obmat);
- GPU_shader_uniform_vector(shader, material->invobmatloc, 16, 1, (float *)invmat);
- }
- if (material->builtins & GPU_LOC_TO_VIEW_MATRIX) {
- if (viewmat) {
- mul_m4_m4m4(localtoviewmat, viewmat, obmat);
- GPU_shader_uniform_vector(shader, material->localtoviewmatloc, 16, 1, (float *)localtoviewmat);
- }
- }
- if (material->builtins & GPU_INVERSE_LOC_TO_VIEW_MATRIX) {
- if (viewmat) {
- mul_m4_m4m4(localtoviewmat, viewmat, obmat);
- invert_m4_m4(invlocaltoviewmat, localtoviewmat);
- GPU_shader_uniform_vector(shader, material->invlocaltoviewmatloc, 16, 1, (float *)invlocaltoviewmat);
- }
- }
- if (material->builtins & GPU_OBCOLOR) {
- copy_v4_v4(col, obcol);
- CLAMP(col[3], 0.0f, 1.0f);
- GPU_shader_uniform_vector(shader, material->obcolloc, 4, 1, col);
- }
- if (material->builtins & GPU_AUTO_BUMPSCALE) {
- GPU_shader_uniform_vector(shader, material->obautobumpscaleloc, 1, 1, &autobumpscale);
- }
- if (material->builtins & GPU_PARTICLE_SCALAR_PROPS) {
- GPU_shader_uniform_vector(shader, material->partscalarpropsloc, 4, 1, pi->scalprops);
- }
- if (material->builtins & GPU_PARTICLE_LOCATION) {
- GPU_shader_uniform_vector(shader, material->partcoloc, 4, 1, pi->location);
- }
- if (material->builtins & GPU_PARTICLE_VELOCITY) {
- GPU_shader_uniform_vector(shader, material->partvel, 3, 1, pi->velocity);
- }
- if (material->builtins & GPU_PARTICLE_ANG_VELOCITY) {
- GPU_shader_uniform_vector(shader, material->partangvel, 3, 1, pi->angular_velocity);
- }
- if (material->builtins & GPU_OBJECT_INFO) {
- GPU_shader_uniform_vector(shader, material->objectinfoloc, 3, 1, object_info);
- }
-
- }
-}
-
-void GPU_material_unbind(GPUMaterial *material)
-{
- if (material->pass) {
- material->bound = 0;
- GPU_pass_unbind(material->pass, &material->inputs);
- }
-}
-
-bool GPU_material_bound(GPUMaterial *material)
-{
- return material->bound;
-}
-
Scene *GPU_material_scene(GPUMaterial *material)
{
return material->scene;
@@ -831,19 +551,6 @@ void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link)
material->outlink = link;
}
-void GPU_material_enable_alpha(GPUMaterial *material)
-{
- material->alpha = 1;
-}
-
-GPUBlendMode GPU_material_alpha_blend(GPUMaterial *material, float obcol[4])
-{
- if (material->alpha || (material->obcolalpha && obcol[3] < 1.0f))
- return GPU_BLEND_ALPHA;
- else
- return GPU_BLEND_SOLID;
-}
-
void gpu_material_add_node(GPUMaterial *material, GPUNode *node)
{
BLI_addtail(&material->nodes, node);
@@ -865,16 +572,6 @@ bool GPU_material_do_color_management(GPUMaterial *mat)
return true;
}
-bool GPU_material_use_new_shading_nodes(GPUMaterial *mat)
-{
- return BKE_scene_use_new_shading_nodes(mat->scene);
-}
-
-bool GPU_material_use_world_space_shading(GPUMaterial *mat)
-{
- return BKE_scene_use_world_space_shading(mat->scene);
-}
-
bool GPU_material_use_domain_surface(GPUMaterial *mat)
{
return (mat->domain & GPU_DOMAIN_SURFACE);
@@ -885,1613 +582,6 @@ bool GPU_material_use_domain_volume(GPUMaterial *mat)
return (mat->domain & GPU_DOMAIN_VOLUME);
}
-static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **lv, GPUNodeLink **dist)
-{
- GPUNodeLink *visifac;
-
- /* from get_lamp_visibility */
- if (lamp->type == LA_SUN || lamp->type == LA_HEMI) {
- mat->dynproperty |= DYN_LAMP_VEC;
- GPU_link(mat, "lamp_visibility_sun_hemi",
- GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), lv, dist, &visifac);
- return visifac;
- }
- else {
- mat->dynproperty |= DYN_LAMP_CO;
- GPU_link(mat, "lamp_visibility_other",
- GPU_builtin(GPU_VIEW_POSITION),
- GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob), lv, dist, &visifac);
-
- if (lamp->type == LA_AREA)
- return visifac;
-
- switch (lamp->falloff_type) {
- case LA_FALLOFF_CONSTANT:
- break;
- case LA_FALLOFF_INVLINEAR:
- GPU_link(mat, "lamp_falloff_invlinear",
- GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac);
- break;
- case LA_FALLOFF_INVSQUARE:
- GPU_link(mat, "lamp_falloff_invsquare",
- GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac);
- break;
- case LA_FALLOFF_SLIDERS:
- GPU_link(mat, "lamp_falloff_sliders",
- GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob),
- GPU_dynamic_uniform(&lamp->att1, GPU_DYNAMIC_LAMP_ATT1, lamp->ob),
- GPU_dynamic_uniform(&lamp->att2, GPU_DYNAMIC_LAMP_ATT2, lamp->ob), *dist, &visifac);
- break;
- case LA_FALLOFF_INVCOEFFICIENTS:
- GPU_link(mat, "lamp_falloff_invcoefficients",
- GPU_dynamic_uniform(&lamp->coeff_const, GPU_DYNAMIC_LAMP_COEFFCONST, lamp->ob),
- GPU_dynamic_uniform(&lamp->coeff_lin, GPU_DYNAMIC_LAMP_COEFFLIN, lamp->ob),
- GPU_dynamic_uniform(&lamp->coeff_quad, GPU_DYNAMIC_LAMP_COEFFQUAD, lamp->ob), *dist, &visifac);
- break;
- case LA_FALLOFF_CURVE:
- {
- float *array;
- int size;
-
- curvemapping_initialize(lamp->curfalloff);
- curvemapping_table_RGBA(lamp->curfalloff, &array, &size);
- GPU_link(mat, "lamp_falloff_curve",
- GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob),
- GPU_texture(size, array), *dist, &visifac);
-
- break;
- }
- }
-
- if (lamp->mode & LA_SPHERE)
- GPU_link(mat, "lamp_visibility_sphere",
- GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob),
- *dist, visifac, &visifac);
-
- if (lamp->type == LA_SPOT) {
- GPUNodeLink *inpr;
-
- if (lamp->mode & LA_SQUARE) {
- mat->dynproperty |= DYN_LAMP_VEC | DYN_LAMP_IMAT;
- GPU_link(mat, "lamp_visibility_spot_square",
- GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob),
- GPU_dynamic_uniform((float *)lamp->dynimat, GPU_DYNAMIC_LAMP_DYNIMAT, lamp->ob),
- GPU_dynamic_uniform((float *)lamp->spotvec, GPU_DYNAMIC_LAMP_SPOTSCALE, lamp->ob), *lv, &inpr);
- }
- else {
- mat->dynproperty |= DYN_LAMP_VEC | DYN_LAMP_IMAT;
- GPU_link(mat, "lamp_visibility_spot_circle",
- GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob),
- GPU_dynamic_uniform((float *)lamp->dynimat, GPU_DYNAMIC_LAMP_DYNIMAT, lamp->ob),
- GPU_dynamic_uniform((float *)lamp->spotvec, GPU_DYNAMIC_LAMP_SPOTSCALE, lamp->ob), *lv, &inpr);
- }
-
- GPU_link(mat, "lamp_visibility_spot",
- GPU_dynamic_uniform(&lamp->spotsi, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob),
- GPU_dynamic_uniform(&lamp->spotbl, GPU_DYNAMIC_LAMP_SPOTBLEND, lamp->ob),
- inpr, visifac, &visifac);
- }
-
- GPU_link(mat, "lamp_visibility_clamp", visifac, &visifac);
-
- return visifac;
- }
-}
-
-#if 0
-static void area_lamp_vectors(LampRen *lar)
-{
- float xsize = 0.5f * lar->area_size, ysize = 0.5f * lar->area_sizey;
-
- /* make it smaller, so area light can be multisampled */
- float multifac = 1.0f / sqrtf((float)lar->ray_totsamp);
- xsize *= multifac;
- ysize *= multifac;
-
- /* corner vectors */
- lar->area[0][0] = lar->co[0] - xsize * lar->mat[0][0] - ysize * lar->mat[1][0];
- lar->area[0][1] = lar->co[1] - xsize * lar->mat[0][1] - ysize * lar->mat[1][1];
- lar->area[0][2] = lar->co[2] - xsize * lar->mat[0][2] - ysize * lar->mat[1][2];
-
- /* corner vectors */
- lar->area[1][0] = lar->co[0] - xsize * lar->mat[0][0] + ysize * lar->mat[1][0];
- lar->area[1][1] = lar->co[1] - xsize * lar->mat[0][1] + ysize * lar->mat[1][1];
- lar->area[1][2] = lar->co[2] - xsize * lar->mat[0][2] + ysize * lar->mat[1][2];
-
- /* corner vectors */
- lar->area[2][0] = lar->co[0] + xsize * lar->mat[0][0] + ysize * lar->mat[1][0];
- lar->area[2][1] = lar->co[1] + xsize * lar->mat[0][1] + ysize * lar->mat[1][1];
- lar->area[2][2] = lar->co[2] + xsize * lar->mat[0][2] + ysize * lar->mat[1][2];
-
- /* corner vectors */
- lar->area[3][0] = lar->co[0] + xsize * lar->mat[0][0] - ysize * lar->mat[1][0];
- lar->area[3][1] = lar->co[1] + xsize * lar->mat[0][1] - ysize * lar->mat[1][1];
- lar->area[3][2] = lar->co[2] + xsize * lar->mat[0][2] - ysize * lar->mat[1][2];
- /* only for correction button size, matrix size works on energy */
- lar->areasize = lar->dist * lar->dist / (4.0f * xsize * ysize);
-}
-#endif
-
-static void ramp_blend(
- GPUMaterial *mat, GPUNodeLink *fac, GPUNodeLink *col1, GPUNodeLink *col2, int type,
- GPUNodeLink **r_col)
-{
- static const char *names[] = {"mix_blend", "mix_add", "mix_mult", "mix_sub",
- "mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light",
- "mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat",
- "mix_val", "mix_color", "mix_soft", "mix_linear"};
-
- GPU_link(mat, names[type], fac, col1, col2, r_col);
-}
-
-static void BKE_colorband_eval_blend(
- GPUMaterial *mat, ColorBand *coba, GPUNodeLink *fac, float rampfac, int type,
- GPUNodeLink *incol, GPUNodeLink **r_col)
-{
- GPUNodeLink *tmp, *alpha, *col;
- float *array;
- int size;
-
- /* do colorband */
- BKE_colorband_evaluate_table_rgba(coba, &array, &size);
- GPU_link(mat, "valtorgb", fac, GPU_texture(size, array), &col, &tmp);
-
- /* use alpha in fac */
- GPU_link(mat, "mtex_alpha_from_col", col, &alpha);
- GPU_link(mat, "math_multiply", alpha, GPU_uniform(&rampfac), &fac);
-
- /* blending method */
- ramp_blend(mat, fac, incol, col, type, r_col);
-}
-
-static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff)
-{
- Material *ma = shi->mat;
- GPUMaterial *mat = shi->gpumat;
-
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS)) {
- if (ma->ramp_col) {
- if (ma->rampin_col == MA_RAMP_IN_RESULT) {
- GPUNodeLink *fac;
- GPU_link(mat, "ramp_rgbtobw", *diff, &fac);
-
- /* colorband + blend */
- BKE_colorband_eval_blend(mat, ma->ramp_col, fac, ma->rampfac_col, ma->rampblend_col, *diff, diff);
- }
- }
- }
-}
-
-static void add_to_diffuse(
- GPUMaterial *mat, Material *ma, GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *rgb,
- GPUNodeLink **r_diff)
-{
- GPUNodeLink *fac, *tmp, *addcol;
-
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) &&
- ma->ramp_col && (ma->mode & MA_RAMP_COL))
- {
- /* MA_RAMP_IN_RESULT is exceptional */
- if (ma->rampin_col == MA_RAMP_IN_RESULT) {
- addcol = shi->rgb;
- }
- else {
- /* input */
- switch (ma->rampin_col) {
- case MA_RAMP_IN_ENERGY:
- GPU_link(mat, "ramp_rgbtobw", rgb, &fac);
- break;
- case MA_RAMP_IN_SHADER:
- fac = is;
- break;
- case MA_RAMP_IN_NOR:
- GPU_link(mat, "vec_math_dot", shi->view, shi->vn, &tmp, &fac);
- break;
- default:
- GPU_link(mat, "set_value_zero", &fac);
- break;
- }
-
- /* colorband + blend */
- BKE_colorband_eval_blend(mat, ma->ramp_col, fac, ma->rampfac_col, ma->rampblend_col, shi->rgb, &addcol);
- }
- }
- else
- addcol = shi->rgb;
-
- /* output to */
- GPU_link(mat, "shade_madd", *r_diff, rgb, addcol, r_diff);
-}
-
-static void ramp_spec_result(GPUShadeInput *shi, GPUNodeLink **spec)
-{
- Material *ma = shi->mat;
- GPUMaterial *mat = shi->gpumat;
-
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) &&
- ma->ramp_spec && ma->rampin_spec == MA_RAMP_IN_RESULT)
- {
- GPUNodeLink *fac;
- GPU_link(mat, "ramp_rgbtobw", *spec, &fac);
-
- /* colorband + blend */
- BKE_colorband_eval_blend(mat, ma->ramp_spec, fac, ma->rampfac_spec, ma->rampblend_spec, *spec, spec);
- }
-}
-
-static void do_specular_ramp(GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *t, GPUNodeLink **spec)
-{
- Material *ma = shi->mat;
- GPUMaterial *mat = shi->gpumat;
- GPUNodeLink *fac, *tmp;
-
- *spec = shi->specrgb;
-
- /* MA_RAMP_IN_RESULT is exception */
- if (ma->ramp_spec && (ma->rampin_spec != MA_RAMP_IN_RESULT)) {
-
- /* input */
- switch (ma->rampin_spec) {
- case MA_RAMP_IN_ENERGY:
- fac = t;
- break;
- case MA_RAMP_IN_SHADER:
- fac = is;
- break;
- case MA_RAMP_IN_NOR:
- GPU_link(mat, "vec_math_dot", shi->view, shi->vn, &tmp, &fac);
- break;
- default:
- GPU_link(mat, "set_value_zero", &fac);
- break;
- }
-
- /* colorband + blend */
- BKE_colorband_eval_blend(mat, ma->ramp_spec, fac, ma->rampfac_spec, ma->rampblend_spec, *spec, spec);
- }
-}
-
-static void add_user_list(ListBase *list, void *data)
-{
- LinkData *link = MEM_callocN(sizeof(LinkData), "GPULinkData");
- link->data = data;
- BLI_addtail(list, link);
-}
-
-static void shade_light_textures(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **rgb)
-{
- for (int i = 0; i < MAX_MTEX; ++i) {
- MTex *mtex = lamp->la->mtex[i];
-
- if (mtex && mtex->tex && (mtex->tex->type & TEX_IMAGE) && mtex->tex->ima) {
- mat->dynproperty |= DYN_LAMP_PERSMAT;
-
- float one = 1.0f;
- GPUNodeLink *tex_rgb;
-
- GPU_link(mat, "shade_light_texture",
- GPU_builtin(GPU_VIEW_POSITION),
- GPU_image(mtex->tex->ima, &mtex->tex->iuser, false),
- GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
- &tex_rgb);
- texture_rgb_blend(mat, tex_rgb, *rgb, GPU_uniform(&one), GPU_uniform(&mtex->colfac), mtex->blendtype, rgb);
- }
- }
-}
-
-static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *lamp)
-{
- Material *ma = shi->mat;
- GPUMaterial *mat = shi->gpumat;
- GPUNodeLink *lv, *dist, *is, *inp, *i;
- GPUNodeLink *outcol, *specfac, *t, *shadfac = NULL, *lcol;
- float one = 1.0f;
-
- if ((lamp->mode & LA_ONLYSHADOW) && !(ma->mode & MA_SHADOW))
- return;
-
- GPUNodeLink *vn = shi->vn;
- GPUNodeLink *view = shi->view;
-
- GPUNodeLink *visifac = lamp_get_visibility(mat, lamp, &lv, &dist);
-
-#if 0
- if (ma->mode & MA_TANGENT_V)
- GPU_link(mat, "shade_tangent_v", lv, GPU_attribute(CD_TANGENT, ""), &vn);
-#endif
-
- GPU_link(mat, "shade_inp", vn, lv, &inp);
-
- if (lamp->mode & LA_NO_DIFF) {
- GPU_link(mat, "shade_is_no_diffuse", &is);
- }
- else if (lamp->type == LA_HEMI) {
- GPU_link(mat, "shade_is_hemi", inp, &is);
- }
- else {
- if (lamp->type == LA_AREA) {
- float area[4][4] = {{0.0f}}, areasize = 0.0f;
-
- mat->dynproperty |= DYN_LAMP_VEC | DYN_LAMP_CO;
- GPU_link(mat, "shade_inp_area",
- GPU_builtin(GPU_VIEW_POSITION),
- GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob),
- GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), vn,
- GPU_uniform((float *)area),
- GPU_uniform(&areasize),
- GPU_uniform(&lamp->k), &inp);
- }
-
- is = inp; /* Lambert */
-
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) {
- if (ma->diff_shader == MA_DIFF_ORENNAYAR)
- GPU_link(mat, "shade_diffuse_oren_nayer", inp, vn, lv, view,
- GPU_uniform(&ma->roughness), &is);
- else if (ma->diff_shader == MA_DIFF_TOON)
- GPU_link(mat, "shade_diffuse_toon", vn, lv, view,
- GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
- else if (ma->diff_shader == MA_DIFF_MINNAERT)
- GPU_link(mat, "shade_diffuse_minnaert", inp, vn, view,
- GPU_uniform(&ma->darkness), &is);
- else if (ma->diff_shader == MA_DIFF_FRESNEL)
- GPU_link(mat, "shade_diffuse_fresnel", vn, lv, view,
- GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
- }
- }
-
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS))
- if (ma->shade_flag & MA_CUBIC)
- GPU_link(mat, "shade_cubic", is, &is);
-
- i = is;
- GPU_link(mat, "shade_visifac", i, visifac, shi->refl, &i);
-
- GPU_link(mat, "set_rgb", GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob), &lcol);
- shade_light_textures(mat, lamp, &lcol);
- GPU_link(mat, "shade_mul_value_v3",
- GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob), lcol, &lcol);
-
-#if 0
- if (ma->mode & MA_TANGENT_VN)
- GPU_link(mat, "shade_tangent_v_spec", GPU_attribute(CD_TANGENT, ""), &vn);
-#endif
-
- /* this replaces if (i > 0.0) conditional until that is supported */
- /* done in shade_visifac now, GPU_link(mat, "mtex_value_clamp_positive", i, &i); */
-
- if ((ma->mode & MA_SHADOW) && GPU_lamp_has_shadow_buffer(lamp)) {
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS)) {
- mat->dynproperty |= DYN_LAMP_PERSMAT;
-
- if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
- GPU_link(mat, "test_shadowbuf_vsm",
- GPU_builtin(GPU_VIEW_POSITION),
- GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
- GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
- GPU_uniform(&lamp->bias), GPU_uniform(&lamp->la->bleedbias), inp, &shadfac);
- }
- else {
- GPU_link(mat, "test_shadowbuf",
- GPU_builtin(GPU_VIEW_POSITION),
- GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
- GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
- GPU_uniform(&lamp->bias), inp, &shadfac);
- }
-
- if (lamp->mode & LA_ONLYSHADOW) {
- GPUNodeLink *shadrgb;
- GPU_link(mat, "shade_only_shadow", i, shadfac,
- GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob),
- GPU_uniform(lamp->shadow_color), &shadrgb);
-
- if (!(lamp->mode & LA_NO_DIFF)) {
- GPU_link(mat, "shade_only_shadow_diffuse", shadrgb, shi->rgb,
- shr->diff, &shr->diff);
- }
-
- if (!(lamp->mode & LA_NO_SPEC)) {
- GPU_link(mat, "shade_only_shadow_specular", shadrgb, shi->specrgb,
- shr->spec, &shr->spec);
- }
-
- add_user_list(&mat->lamps, lamp);
- return;
- }
- }
- }
- else if ((mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) {
- add_user_list(&mat->lamps, lamp);
- return;
- }
- else
- GPU_link(mat, "set_value", GPU_uniform(&one), &shadfac);
-
- if (GPU_link_changed(shi->refl) || ma->ref != 0.0f) {
- if (!(lamp->mode & LA_NO_DIFF)) {
- GPUNodeLink *rgb;
- GPU_link(mat, "shade_mul_value", i, lcol, &rgb);
- GPU_link(mat, "mtex_value_invert", shadfac, &shadfac);
- GPU_link(mat, "mix_mult", shadfac, rgb, GPU_uniform(lamp->shadow_color), &rgb);
- GPU_link(mat, "mtex_value_invert", shadfac, &shadfac);
- add_to_diffuse(mat, ma, shi, is, rgb, &shr->diff);
- }
- }
-
- if (mat->scene->gm.flag & GAME_GLSL_NO_SHADERS) {
- /* pass */
- }
- else if (!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) &&
- (GPU_link_changed(shi->spec) || ma->spec != 0.0f))
- {
- if (lamp->type == LA_HEMI) {
- GPU_link(mat, "shade_hemi_spec", vn, lv, view, GPU_uniform(&ma->spec), shi->har, visifac, &t);
- GPU_link(mat, "shade_add_spec", t, lcol, shi->specrgb, &outcol);
- GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec);
- }
- else {
- if (ma->spec_shader == MA_SPEC_PHONG) {
- GPU_link(mat, "shade_phong_spec", vn, lv, view, shi->har, &specfac);
- }
- else if (ma->spec_shader == MA_SPEC_COOKTORR) {
- GPU_link(mat, "shade_cooktorr_spec", vn, lv, view, shi->har, &specfac);
- }
- else if (ma->spec_shader == MA_SPEC_BLINN) {
- GPU_link(mat, "shade_blinn_spec", vn, lv, view,
- GPU_uniform(&ma->refrac), shi->har, &specfac);
- }
- else if (ma->spec_shader == MA_SPEC_WARDISO) {
- GPU_link(mat, "shade_wardiso_spec", vn, lv, view,
- GPU_uniform(&ma->rms), &specfac);
- }
- else {
- GPU_link(mat, "shade_toon_spec", vn, lv, view,
- GPU_uniform(&ma->param[2]), GPU_uniform(&ma->param[3]), &specfac);
- }
-
- if (lamp->type == LA_AREA)
- GPU_link(mat, "shade_spec_area_inp", specfac, inp, &specfac);
-
- GPU_link(mat, "shade_spec_t", shadfac, shi->spec, visifac, specfac, &t);
-
- if (ma->mode & MA_RAMP_SPEC) {
- GPUNodeLink *spec;
- do_specular_ramp(shi, specfac, t, &spec);
- GPU_link(mat, "shade_add_spec", t, lcol, spec, &outcol);
- GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec);
- }
- else {
- GPU_link(mat, "shade_add_spec", t, lcol, shi->specrgb, &outcol);
- GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec);
- }
- }
- }
-
- add_user_list(&mat->lamps, lamp);
-}
-
-static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr)
-{
- Base *base;
- Scene *sce_iter;
-
- for (SETLOOPER(shi->gpumat->scene, sce_iter, base)) {
- Object *ob = base->object;
-
- if (ob->type == OB_LAMP) {
- GPULamp *lamp = GPU_lamp_from_blender(shi->gpumat->scene, ob, NULL);
- if (lamp)
- shade_one_light(shi, shr, lamp);
- }
-
- if (ob->transflag & OB_DUPLI) {
- ListBase *lb = object_duplilist(G.main->eval_ctx, shi->gpumat->scene, ob);
-
- for (DupliObject *dob = lb->first; dob; dob = dob->next) {
- Object *ob_iter = dob->ob;
-
- if (ob_iter->type == OB_LAMP) {
- float omat[4][4];
- copy_m4_m4(omat, ob_iter->obmat);
- copy_m4_m4(ob_iter->obmat, dob->mat);
-
- GPULamp *lamp = GPU_lamp_from_blender(shi->gpumat->scene, ob_iter, ob);
- if (lamp)
- shade_one_light(shi, shr, lamp);
-
- copy_m4_m4(ob_iter->obmat, omat);
- }
- }
-
- free_object_duplilist(lb);
- }
- }
-
- /* prevent only shadow lamps from producing negative colors.*/
- GPU_link(shi->gpumat, "shade_clamp_positive", shr->spec, &shr->spec);
- GPU_link(shi->gpumat, "shade_clamp_positive", shr->diff, &shr->diff);
-}
-
-static void texture_rgb_blend(
- GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg,
- int blendtype, GPUNodeLink **in)
-{
- switch (blendtype) {
- case MTEX_BLEND:
- GPU_link(mat, "mtex_rgb_blend", out, tex, fact, facg, in);
- break;
- case MTEX_MUL:
- GPU_link(mat, "mtex_rgb_mul", out, tex, fact, facg, in);
- break;
- case MTEX_SCREEN:
- GPU_link(mat, "mtex_rgb_screen", out, tex, fact, facg, in);
- break;
- case MTEX_OVERLAY:
- GPU_link(mat, "mtex_rgb_overlay", out, tex, fact, facg, in);
- break;
- case MTEX_SUB:
- GPU_link(mat, "mtex_rgb_sub", out, tex, fact, facg, in);
- break;
- case MTEX_ADD:
- GPU_link(mat, "mtex_rgb_add", out, tex, fact, facg, in);
- break;
- case MTEX_DIV:
- GPU_link(mat, "mtex_rgb_div", out, tex, fact, facg, in);
- break;
- case MTEX_DIFF:
- GPU_link(mat, "mtex_rgb_diff", out, tex, fact, facg, in);
- break;
- case MTEX_DARK:
- GPU_link(mat, "mtex_rgb_dark", out, tex, fact, facg, in);
- break;
- case MTEX_LIGHT:
- GPU_link(mat, "mtex_rgb_light", out, tex, fact, facg, in);
- break;
- case MTEX_BLEND_HUE:
- GPU_link(mat, "mtex_rgb_hue", out, tex, fact, facg, in);
- break;
- case MTEX_BLEND_SAT:
- GPU_link(mat, "mtex_rgb_sat", out, tex, fact, facg, in);
- break;
- case MTEX_BLEND_VAL:
- GPU_link(mat, "mtex_rgb_val", out, tex, fact, facg, in);
- break;
- case MTEX_BLEND_COLOR:
- GPU_link(mat, "mtex_rgb_color", out, tex, fact, facg, in);
- break;
- case MTEX_SOFT_LIGHT:
- GPU_link(mat, "mtex_rgb_soft", out, tex, fact, facg, in);
- break;
- case MTEX_LIN_LIGHT:
- GPU_link(mat, "mtex_rgb_linear", out, tex, fact, facg, in);
- break;
- default:
- GPU_link(mat, "set_rgb_zero", &in);
- break;
- }
-}
-
-static void texture_value_blend(
- GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg,
- int blendtype, GPUNodeLink **in)
-{
- switch (blendtype) {
- case MTEX_BLEND:
- GPU_link(mat, "mtex_value_blend", out, tex, fact, facg, in);
- break;
- case MTEX_MUL:
- GPU_link(mat, "mtex_value_mul", out, tex, fact, facg, in);
- break;
- case MTEX_SCREEN:
- GPU_link(mat, "mtex_value_screen", out, tex, fact, facg, in);
- break;
- case MTEX_SUB:
- GPU_link(mat, "mtex_value_sub", out, tex, fact, facg, in);
- break;
- case MTEX_ADD:
- GPU_link(mat, "mtex_value_add", out, tex, fact, facg, in);
- break;
- case MTEX_DIV:
- GPU_link(mat, "mtex_value_div", out, tex, fact, facg, in);
- break;
- case MTEX_DIFF:
- GPU_link(mat, "mtex_value_diff", out, tex, fact, facg, in);
- break;
- case MTEX_DARK:
- GPU_link(mat, "mtex_value_dark", out, tex, fact, facg, in);
- break;
- case MTEX_LIGHT:
- GPU_link(mat, "mtex_value_light", out, tex, fact, facg, in);
- break;
- default:
- GPU_link(mat, "set_value_zero", &in);
- break;
- }
-}
-
-static void do_material_tex(GPUShadeInput *shi)
-{
- Material *ma = shi->mat;
- GPUMaterial *mat = shi->gpumat;
- MTex *mtex;
- Tex *tex;
- GPUNodeLink *texco, *tin, *trgb, *tnor, *tcol, *stencil, *tnorfac;
- GPUNodeLink *texco_norm, *texco_orco, *texco_object;
- GPUNodeLink *texco_global, *texco_uv = NULL;
- GPUNodeLink *newnor, *orn;
- float one = 1.0f;
- int rgbnor, talpha;
- bool init_done = false;
- int iBumpSpacePrev = 0; /* Not necessary, quieting gcc warning. */
- GPUNodeLink *vNorg, *vNacc, *fPrevMagnitude;
- int iFirstTimeNMap = 1;
- bool found_deriv_map = false;
-
- GPU_link(mat, "set_value", GPU_uniform(&one), &stencil);
-
- GPU_link(mat, "texco_norm", GPU_builtin(GPU_VIEW_NORMAL), &texco_norm);
- GPU_link(mat, "texco_orco", GPU_attribute(CD_ORCO, ""), &texco_orco);
- GPU_link(mat, "texco_object", GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
- GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
- GPU_builtin(GPU_VIEW_POSITION), &texco_object);
-#if 0
- GPU_link(mat, "texco_tangent", GPU_attribute(CD_TANGENT, ""), &texco_tangent);
-#endif
- GPU_link(mat, "texco_global", GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
- GPU_builtin(GPU_VIEW_POSITION), &texco_global);
-
- orn = texco_norm;
-
- /* go over texture slots */
- for (int tex_nr = 0; tex_nr < MAX_MTEX; tex_nr++) {
- /* separate tex switching */
- if (ma->septex & (1 << tex_nr)) continue;
-
- if (ma->mtex[tex_nr]) {
- mtex = ma->mtex[tex_nr];
-
- tex = mtex->tex;
- if (tex == NULL) continue;
-
- /* which coords */
- if (mtex->texco == TEXCO_ORCO)
- texco = texco_orco;
- else if (mtex->texco == TEXCO_OBJECT)
- texco = texco_object;
- else if (mtex->texco == TEXCO_NORM)
- texco = orn;
- else if (mtex->texco == TEXCO_TANGENT)
- texco = texco_object;
- else if (mtex->texco == TEXCO_GLOB)
- texco = texco_global;
- else if (mtex->texco == TEXCO_REFL) {
- GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref);
- texco = shi->ref;
- }
- else if (mtex->texco == TEXCO_UV) {
- if (1) { //!(texco_uv && strcmp(mtex->uvname, lastuvname) == 0)) {
- GPU_link(mat, "texco_uv", GPU_attribute(CD_MTFACE, mtex->uvname), &texco_uv);
- /*lastuvname = mtex->uvname;*/ /*UNUSED*/
- }
- texco = texco_uv;
- }
- else
- continue;
-
- /* in case of uv, this would just undo a multiplication in texco_uv */
- if (mtex->texco != TEXCO_UV)
- GPU_link(mat, "mtex_2d_mapping", texco, &texco);
-
- if (mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.0f)
- GPU_link(mat, "mtex_mapping_size", texco, GPU_uniform(mtex->size), &texco);
-
- float ofs[3] = {
- mtex->ofs[0] + 0.5f - 0.5f * mtex->size[0],
- mtex->ofs[1] + 0.5f - 0.5f * mtex->size[1],
- 0.0f
- };
-
- if (ofs[0] != 0.0f || ofs[1] != 0.0f || ofs[2] != 0.0f)
- GPU_link(mat, "mtex_mapping_ofs", texco, GPU_uniform(ofs), &texco);
-
- talpha = 0;
-
- if (tex && tex->ima &&
- ((tex->type == TEX_IMAGE) ||
- ((tex->type == TEX_ENVMAP) && (mtex->texco == TEXCO_REFL))))
- {
- if (tex->type == TEX_IMAGE) {
- GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, false), &tin, &trgb);
- }
- else {
- GPU_link(mat, "mtex_cube_map_refl",
- GPU_cube_map(tex->ima, &tex->iuser, false), shi->view, shi->vn,
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
- GPU_builtin(GPU_VIEW_MATRIX), &tin, &trgb);
- }
- rgbnor = TEX_RGB;
-
- talpha = ((tex->imaflag & TEX_USEALPHA) && tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0);
- }
- else {
- continue;
- }
-
- /* texture output */
- if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
- GPU_link(mat, "mtex_rgbtoint", trgb, &tin);
- rgbnor -= TEX_RGB;
- }
-
- if (mtex->texflag & MTEX_NEGATIVE) {
- if (rgbnor & TEX_RGB)
- GPU_link(mat, "mtex_rgb_invert", trgb, &trgb);
- else
- GPU_link(mat, "mtex_value_invert", tin, &tin);
- }
-
- if (mtex->texflag & MTEX_STENCIL) {
- if (rgbnor & TEX_RGB)
- GPU_link(mat, "mtex_rgb_stencil", stencil, trgb, &stencil, &trgb);
- else
- GPU_link(mat, "mtex_value_stencil", stencil, tin, &stencil, &tin);
- }
-
- /* mapping */
- if (mtex->mapto & (MAP_COL | MAP_COLSPEC | MAP_COLMIR)) {
- /* stencil maps on the texture control slider, not texture intensity value */
- if ((rgbnor & TEX_RGB) == 0) {
- GPU_link(mat, "set_rgb", GPU_uniform(&mtex->r), &tcol);
- }
- else {
- GPU_link(mat, "set_rgba", trgb, &tcol);
-
- if (mtex->mapto & MAP_ALPHA)
- GPU_link(mat, "set_value", stencil, &tin);
- else if (talpha)
- GPU_link(mat, "mtex_alpha_from_col", trgb, &tin);
- else
- GPU_link(mat, "set_value_one", &tin);
- }
-
- if ((tex->type == TEX_IMAGE) ||
- ((tex->type == TEX_ENVMAP) && (mtex->texco == TEXCO_REFL)))
- {
- if (GPU_material_do_color_management(mat)) {
- GPU_link(mat, "srgb_to_linearrgb", tcol, &tcol);
- }
- }
-
- if (mtex->mapto & MAP_COL) {
- GPUNodeLink *colfac;
-
- if (mtex->colfac == 1.0f) colfac = stencil;
- else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->colfac), stencil, &colfac);
-
- texture_rgb_blend(mat, tcol, shi->rgb, tin, colfac, mtex->blendtype, &shi->rgb);
- }
-
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) {
- GPUNodeLink *colspecfac;
-
- if (mtex->colspecfac == 1.0f) colspecfac = stencil;
- else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->colspecfac), stencil, &colspecfac);
-
- texture_rgb_blend(mat, tcol, shi->specrgb, tin, colspecfac, mtex->blendtype, &shi->specrgb);
- }
-
- if (mtex->mapto & MAP_COLMIR) {
- GPUNodeLink *colmirfac;
-
- if (mtex->mirrfac == 1.0f) colmirfac = stencil;
- else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->mirrfac), stencil, &colmirfac);
-
- /* exception for envmap only */
- if (tex->type == TEX_ENVMAP && mtex->blendtype == MTEX_BLEND) {
- GPU_link(mat, "mtex_mirror", tcol, shi->refcol, tin, colmirfac, &shi->refcol);
- }
- else
- texture_rgb_blend(mat, tcol, shi->mir, tin, colmirfac, mtex->blendtype, &shi->mir);
- }
- }
-
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) {
- if (tex->type == TEX_IMAGE) {
- found_deriv_map = tex->imaflag & TEX_DERIVATIVEMAP;
-
- if (tex->imaflag & TEX_NORMALMAP) {
- /* normalmap image */
- GPU_link(mat, "mtex_normal", texco, GPU_image(tex->ima, &tex->iuser, true), &tnor);
-
- if (mtex->norfac < 0.0f)
- GPU_link(mat, "mtex_negate_texnormal", tnor, &tnor);
-
- if (mtex->normapspace == MTEX_NSPACE_TANGENT) {
- if (iFirstTimeNMap != 0) {
- // use unnormalized normal (this is how we bake it - closer to gamedev)
- GPUNodeLink *vNegNorm;
- GPU_link(mat, "vec_math_negate",
- GPU_builtin(GPU_VIEW_NORMAL), &vNegNorm);
- GPU_link(mat, "mtex_nspace_tangent",
- GPU_attribute(CD_TANGENT, ""), vNegNorm, tnor, &newnor);
- iFirstTimeNMap = 0;
- }
- else { /* otherwise use accumulated perturbations */
- GPU_link(mat, "mtex_nspace_tangent",
- GPU_attribute(CD_TANGENT, ""), shi->vn, tnor, &newnor);
- }
- }
- else if (mtex->normapspace == MTEX_NSPACE_OBJECT) {
- /* transform normal by object then view matrix */
- GPU_link(mat, "mtex_nspace_object", tnor, &newnor);
- }
- else if (mtex->normapspace == MTEX_NSPACE_WORLD) {
- /* transform normal by view matrix */
- GPU_link(mat, "mtex_nspace_world", GPU_builtin(GPU_VIEW_MATRIX), tnor, &newnor);
- }
- else {
- /* no transform, normal in camera space */
- newnor = tnor;
- }
-
- float norfac = min_ff(fabsf(mtex->norfac), 1.0f);
-
- if (norfac == 1.0f && !GPU_link_changed(stencil)) {
- shi->vn = newnor;
- }
- else {
- tnorfac = GPU_uniform(&norfac);
-
- if (GPU_link_changed(stencil))
- GPU_link(mat, "math_multiply", tnorfac, stencil, &tnorfac);
-
- GPU_link(mat, "mtex_blend_normal", tnorfac, shi->vn, newnor, &shi->vn);
- }
-
- }
- else if (found_deriv_map ||
- (mtex->texflag & (MTEX_3TAP_BUMP | MTEX_5TAP_BUMP | MTEX_BICUBIC_BUMP)))
- {
- /* ntap bumpmap image */
- int iBumpSpace;
- float ima_x, ima_y;
-
- float imag_tspace_dimension_x = 1024.0f; /* only used for texture space variant */
- float aspect = 1.0f;
-
- GPUNodeLink *vR1, *vR2;
- GPUNodeLink *dBs, *dBt, *fDet;
-
- float hScale = 0.1f; /* compatibility adjustment factor for all bumpspace types */
- if (mtex->texflag & MTEX_BUMP_TEXTURESPACE)
- hScale = 13.0f; /* factor for scaling texspace bumps */
- else if (found_deriv_map)
- hScale = 1.0f;
-
- /* resolve texture resolution */
- if ((mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map) {
- ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL);
- ima_x = 512.0f; ima_y = 512.0f; /* prevent calling textureSize, glsl 1.3 only */
- if (ibuf) {
- ima_x = ibuf->x;
- ima_y = ibuf->y;
- aspect = (float)ima_y / ima_x;
- }
- BKE_image_release_ibuf(tex->ima, ibuf, NULL);
- }
-
- /* The negate on norfac is done because the
- * normal in the renderer points inward which corresponds
- * to inverting the bump map. Should this ever change
- * this negate must be removed. */
- float norfac = -hScale * mtex->norfac;
- if (found_deriv_map) {
- float fVirtDim = sqrtf(fabsf(ima_x * mtex->size[0] * ima_y * mtex->size[1]));
- norfac /= MAX2(fVirtDim, FLT_EPSILON);
- }
-
- tnorfac = GPU_uniform(&norfac);
-
- if (found_deriv_map)
- GPU_link(mat, "math_multiply", tnorfac, GPU_builtin(GPU_AUTO_BUMPSCALE), &tnorfac);
-
- if (GPU_link_changed(stencil))
- GPU_link(mat, "math_multiply", tnorfac, stencil, &tnorfac);
-
- if (!init_done) {
- /* copy shi->vn to vNorg and vNacc, set magnitude to 1 */
- GPU_link(mat, "mtex_bump_normals_init", shi->vn, &vNorg, &vNacc, &fPrevMagnitude);
- iBumpSpacePrev = 0;
- init_done = true;
- }
-
- // find current bump space
- if (mtex->texflag & MTEX_BUMP_OBJECTSPACE)
- iBumpSpace = 1;
- else if (mtex->texflag & MTEX_BUMP_TEXTURESPACE)
- iBumpSpace = 2;
- else
- iBumpSpace = 4; /* ViewSpace */
-
- /* re-initialize if bump space changed */
- if (iBumpSpacePrev != iBumpSpace) {
- GPUNodeLink *surf_pos = GPU_builtin(GPU_VIEW_POSITION);
-
- if (mtex->texflag & MTEX_BUMP_OBJECTSPACE)
- GPU_link(mat, "mtex_bump_init_objspace",
- surf_pos, vNorg,
- GPU_builtin(GPU_VIEW_MATRIX),
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
- GPU_builtin(GPU_OBJECT_MATRIX),
- GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
- fPrevMagnitude, vNacc,
- &fPrevMagnitude, &vNacc,
- &vR1, &vR2, &fDet);
-
- else if (mtex->texflag & MTEX_BUMP_TEXTURESPACE)
- GPU_link(mat, "mtex_bump_init_texturespace",
- surf_pos, vNorg,
- fPrevMagnitude, vNacc,
- &fPrevMagnitude, &vNacc,
- &vR1, &vR2, &fDet);
-
- else
- GPU_link(mat, "mtex_bump_init_viewspace",
- surf_pos, vNorg,
- fPrevMagnitude, vNacc,
- &fPrevMagnitude, &vNacc,
- &vR1, &vR2, &fDet);
-
- iBumpSpacePrev = iBumpSpace;
- }
-
-
- if (found_deriv_map) {
- GPU_link(mat, "mtex_bump_deriv",
- texco, GPU_image(tex->ima, &tex->iuser, true),
- GPU_uniform(&ima_x), GPU_uniform(&ima_y), tnorfac,
- &dBs, &dBt);
- }
- else if (mtex->texflag & MTEX_3TAP_BUMP)
- GPU_link(mat, "mtex_bump_tap3",
- texco, GPU_image(tex->ima, &tex->iuser, true), tnorfac,
- &dBs, &dBt);
- else if (mtex->texflag & MTEX_5TAP_BUMP)
- GPU_link(mat, "mtex_bump_tap5",
- texco, GPU_image(tex->ima, &tex->iuser, true), tnorfac,
- &dBs, &dBt);
- else if (mtex->texflag & MTEX_BICUBIC_BUMP) {
- if (GPU_bicubic_bump_support()) {
- GPU_link(mat, "mtex_bump_bicubic",
- texco, GPU_image(tex->ima, &tex->iuser, true), tnorfac,
- &dBs, &dBt);
- }
- else {
- GPU_link(mat, "mtex_bump_tap5",
- texco, GPU_image(tex->ima, &tex->iuser, true), tnorfac,
- &dBs, &dBt);
- }
- }
-
-
- if (mtex->texflag & MTEX_BUMP_TEXTURESPACE) {
- float imag_tspace_dimension_y = aspect * imag_tspace_dimension_x;
- GPU_link(mat, "mtex_bump_apply_texspace",
- fDet, dBs, dBt, vR1, vR2,
- GPU_image(tex->ima, &tex->iuser, true), texco,
- GPU_uniform(&imag_tspace_dimension_x),
- GPU_uniform(&imag_tspace_dimension_y), vNacc,
- &vNacc, &shi->vn);
- }
- else
- GPU_link(mat, "mtex_bump_apply",
- fDet, dBs, dBt, vR1, vR2, vNacc,
- &vNacc, &shi->vn);
-
- }
- }
-
- GPU_link(mat, "vec_math_negate", shi->vn, &orn);
- }
-
- if ((mtex->mapto & MAP_VARS)) {
- if (rgbnor & TEX_RGB) {
- if (talpha)
- GPU_link(mat, "mtex_alpha_from_col", trgb, &tin);
- else
- GPU_link(mat, "mtex_rgbtoint", trgb, &tin);
- }
-
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) {
- GPUNodeLink *difffac;
-
- if (mtex->difffac == 1.0f) difffac = stencil;
- else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->difffac), stencil, &difffac);
-
- texture_value_blend(
- mat, GPU_uniform(&mtex->def_var), shi->refl, tin, difffac,
- mtex->blendtype, &shi->refl);
- GPU_link(mat, "mtex_value_clamp_positive", shi->refl, &shi->refl);
- }
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) {
- GPUNodeLink *specfac;
-
- if (mtex->specfac == 1.0f) specfac = stencil;
- else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->specfac), stencil, &specfac);
-
- texture_value_blend(
- mat, GPU_uniform(&mtex->def_var), shi->spec, tin, specfac,
- mtex->blendtype, &shi->spec);
- GPU_link(mat, "mtex_value_clamp_positive", shi->spec, &shi->spec);
- }
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) {
- GPUNodeLink *emitfac;
-
- if (mtex->emitfac == 1.0f) emitfac = stencil;
- else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->emitfac), stencil, &emitfac);
-
- texture_value_blend(
- mat, GPU_uniform(&mtex->def_var), shi->emit, tin, emitfac,
- mtex->blendtype, &shi->emit);
- GPU_link(mat, "mtex_value_clamp_positive", shi->emit, &shi->emit);
- }
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) {
- GPUNodeLink *hardfac;
-
- if (mtex->hardfac == 1.0f) hardfac = stencil;
- else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->hardfac), stencil, &hardfac);
-
- GPU_link(mat, "mtex_har_divide", shi->har, &shi->har);
- texture_value_blend(
- mat, GPU_uniform(&mtex->def_var), shi->har, tin, hardfac,
- mtex->blendtype, &shi->har);
- GPU_link(mat, "mtex_har_multiply_clamp", shi->har, &shi->har);
- }
- if (mtex->mapto & MAP_ALPHA) {
- GPUNodeLink *alphafac;
-
- if (mtex->alphafac == 1.0f) alphafac = stencil;
- else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->alphafac), stencil, &alphafac);
-
- texture_value_blend(
- mat, GPU_uniform(&mtex->def_var), shi->alpha, tin, alphafac,
- mtex->blendtype, &shi->alpha);
- GPU_link(mat, "mtex_value_clamp", shi->alpha, &shi->alpha);
- }
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) {
- GPUNodeLink *ambfac;
-
- if (mtex->ambfac == 1.0f) ambfac = stencil;
- else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->ambfac), stencil, &ambfac);
-
- texture_value_blend(
- mat, GPU_uniform(&mtex->def_var), shi->amb, tin, ambfac,
- mtex->blendtype, &shi->amb);
- GPU_link(mat, "mtex_value_clamp", shi->amb, &shi->amb);
- }
- }
- }
- }
-}
-
-void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi)
-{
- float one = 1.0f;
-
- memset(shi, 0, sizeof(*shi));
-
- shi->gpumat = mat;
- shi->mat = ma;
-
- GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&ma->r, GPU_DYNAMIC_MAT_DIFFRGB, ma), &shi->rgb);
- GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&ma->specr, GPU_DYNAMIC_MAT_SPECRGB, ma), &shi->specrgb);
- GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&ma->mirr, GPU_DYNAMIC_MAT_MIR, ma), &shi->mir);
- GPU_link(mat, "set_rgba_zero", &shi->refcol);
- GPU_link(mat, "shade_norm", GPU_builtin(GPU_VIEW_NORMAL), &shi->vn);
-
- if (mat->alpha)
- GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->alpha, GPU_DYNAMIC_MAT_ALPHA, ma), &shi->alpha);
- else
- GPU_link(mat, "set_value", GPU_uniform(&one), &shi->alpha);
-
- GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->ref, GPU_DYNAMIC_MAT_REF, ma), &shi->refl);
- GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->spec, GPU_DYNAMIC_MAT_SPEC, ma), &shi->spec);
- GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->emit, GPU_DYNAMIC_MAT_EMIT, ma), &shi->emit);
- GPU_link(mat, "set_value", GPU_dynamic_uniform((float *)&ma->har, GPU_DYNAMIC_MAT_HARD, ma), &shi->har);
- GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->amb, GPU_DYNAMIC_MAT_AMB, ma), &shi->amb);
- GPU_link(mat, "set_value", GPU_uniform(&ma->spectra), &shi->spectra);
- GPU_link(mat, "shade_view", GPU_builtin(GPU_VIEW_POSITION), &shi->view);
- GPU_link(mat, "vcol_attribute", GPU_attribute(CD_MCOL, ""), &shi->vcol);
- if (GPU_material_do_color_management(mat))
- GPU_link(mat, "srgb_to_linearrgb", shi->vcol, &shi->vcol);
- GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref);
-}
-
-void GPU_mist_update_enable(short enable)
-{
- GPUWorld.mistenabled = (float)enable;
-}
-
-void GPU_mist_update_values(int type, float start, float dist, float inten, float color[3])
-{
- GPUWorld.mistype = (float)type;
- GPUWorld.miststart = start;
- GPUWorld.mistdistance = dist;
- GPUWorld.mistintensity = inten;
- copy_v3_v3(GPUWorld.mistcol, color);
- GPUWorld.mistcol[3] = 1.0f;
-}
-
-void GPU_horizon_update_color(float color[3])
-{
- copy_v3_v3(GPUWorld.horicol, color);
-}
-
-void GPU_ambient_update_color(float color[3])
-{
- copy_v3_v3(GPUWorld.ambcol, color);
- GPUWorld.ambcol[3] = 1.0f;
-}
-
-void GPU_zenith_update_color(float color[3])
-{
- copy_v3_v3(GPUWorld.zencol, color);
-}
-
-void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
-{
- GPUMaterial *mat = shi->gpumat;
- GPUNodeLink *emit, *ulinfac, *ulogfac, *mistfac;
- Material *ma = shi->mat;
- World *world = mat->scene->world;
- float linfac, logfac;
-
- memset(shr, 0, sizeof(*shr));
-
- if (ma->mode & MA_VERTEXCOLP)
- shi->rgb = shi->vcol;
-
- do_material_tex(shi);
-
- if ((mat->scene->gm.flag & GAME_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) {
- GPU_link(mat, "set_rgb", shi->rgb, &shr->diff);
- GPU_link(mat, "set_rgb_zero", &shr->spec);
- GPU_link(mat, "set_value", shi->alpha, &shr->alpha);
- shr->combined = shr->diff;
- }
- else {
- if (GPU_link_changed(shi->emit) || ma->emit != 0.0f) {
- if ((ma->mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == MA_VERTEXCOL) {
- GPU_link(mat, "shade_add", shi->emit, shi->vcol, &emit);
- GPU_link(mat, "shade_mul", emit, shi->rgb, &shr->diff);
- }
- else
- GPU_link(mat, "shade_mul_value", shi->emit, shi->rgb, &shr->diff);
- }
- else
- GPU_link(mat, "set_rgb_zero", &shr->diff);
-
- GPU_link(mat, "set_rgb_zero", &shr->spec);
-
- material_lights(shi, shr);
-
- shr->combined = shr->diff;
-
- GPU_link(mat, "set_value", shi->alpha, &shr->alpha);
-
- if (world) {
- /* exposure correction */
- if (world->exp != 0.0f || world->range != 1.0f) {
- linfac = 1.0f + powf((2.0f * world->exp + 0.5f), -10);
- logfac = logf((linfac - 1.0f) / linfac) / world->range;
-
- GPU_link(mat, "set_value", GPU_uniform(&linfac), &ulinfac);
- GPU_link(mat, "set_value", GPU_uniform(&logfac), &ulogfac);
-
- GPU_link(mat, "shade_exposure_correct", shr->combined,
- ulinfac, ulogfac, &shr->combined);
- GPU_link(mat, "shade_exposure_correct", shr->spec,
- ulinfac, ulogfac, &shr->spec);
- }
-
- /* environment lighting */
- if (!(mat->scene->gm.flag & GAME_GLSL_NO_ENV_LIGHTING) &&
- (world->mode & WO_ENV_LIGHT) &&
- (mat->scene->r.mode & R_SHADOW) &&
- !BKE_scene_use_new_shading_nodes(mat->scene))
- {
- if ((world->ao_env_energy != 0.0f) && (GPU_link_changed(shi->amb) || ma->amb != 0.0f) &&
- (GPU_link_changed(shi->refl) || ma->ref != 0.0f))
- {
- if (world->aocolor != WO_AOPLAIN) {
- if (!(is_zero_v3(&world->horr) & is_zero_v3(&world->zenr))) {
- GPUNodeLink *fcol, *f;
- GPU_link(mat, "math_multiply", shi->amb, shi->refl, &f);
- GPU_link(mat, "math_multiply", f, GPU_uniform(&world->ao_env_energy), &f);
- GPU_link(mat, "shade_mul_value", f, shi->rgb, &fcol);
- GPU_link(mat, "env_apply", shr->combined,
- GPU_dynamic_uniform(GPUWorld.horicol, GPU_DYNAMIC_HORIZON_COLOR, NULL),
- GPU_dynamic_uniform(GPUWorld.zencol, GPU_DYNAMIC_ZENITH_COLOR, NULL), fcol,
- GPU_builtin(GPU_VIEW_MATRIX), shi->vn, &shr->combined);
- }
- }
- else {
- GPUNodeLink *f;
- GPU_link(mat, "math_multiply", shi->amb, shi->refl, &f);
- GPU_link(mat, "math_multiply", f, GPU_uniform(&world->ao_env_energy), &f);
- GPU_link(mat, "shade_maddf", shr->combined, f, shi->rgb, &shr->combined);
- }
- }
- }
-
- /* ambient color */
- if (GPU_link_changed(shi->amb) || ma->amb != 0.0f) {
- GPU_link(mat, "shade_maddf", shr->combined, GPU_uniform(&ma->amb),
- GPU_dynamic_uniform(GPUWorld.ambcol, GPU_DYNAMIC_AMBIENT_COLOR, NULL),
- &shr->combined);
- }
- }
-
- if (ma->mode & MA_TRANSP && (ma->mode & (MA_ZTRANSP | MA_RAYTRANSP))) {
- if (GPU_link_changed(shi->spectra) || ma->spectra != 0.0f) {
- GPU_link(mat, "alpha_spec_correction", shr->spec, shi->spectra,
- shi->alpha, &shr->alpha);
- }
- }
-
- if (ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined);
- if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec);
-
- if (GPU_link_changed(shi->refcol))
- GPU_link(mat, "shade_add_mirror", shi->mir, shi->refcol, shr->combined, &shr->combined);
-
- if (GPU_link_changed(shi->spec) || ma->spec != 0.0f)
- GPU_link(mat, "shade_add", shr->combined, shr->spec, &shr->combined);
- }
-
- GPU_link(mat, "mtex_alpha_to_col", shr->combined, shr->alpha, &shr->combined);
-
- if (ma->shade_flag & MA_OBCOLOR)
- GPU_link(mat, "shade_obcolor", shr->combined, GPU_builtin(GPU_OBCOLOR), &shr->combined);
-
- if (!(ma->mode & MA_NOMIST)) {
- GPU_link(mat, "shade_mist_factor", GPU_builtin(GPU_VIEW_POSITION),
- GPU_dynamic_uniform(&GPUWorld.mistenabled, GPU_DYNAMIC_MIST_ENABLE, NULL),
- GPU_dynamic_uniform(&GPUWorld.miststart, GPU_DYNAMIC_MIST_START, NULL),
- GPU_dynamic_uniform(&GPUWorld.mistdistance, GPU_DYNAMIC_MIST_DISTANCE, NULL),
- GPU_dynamic_uniform(&GPUWorld.mistype, GPU_DYNAMIC_MIST_TYPE, NULL),
- GPU_dynamic_uniform(&GPUWorld.mistintensity, GPU_DYNAMIC_MIST_INTENSITY, NULL), &mistfac);
-
- GPU_link(mat, "mix_blend", mistfac, shr->combined,
- GPU_dynamic_uniform(GPUWorld.mistcol, GPU_DYNAMIC_MIST_COLOR, NULL), &shr->combined);
- }
-
- if (!mat->alpha) {
- if (world && (GPU_link_changed(shr->alpha) || ma->alpha != 1.0f))
- GPU_link(mat, "shade_world_mix", GPU_dynamic_uniform(GPUWorld.horicol, GPU_DYNAMIC_HORIZON_COLOR, NULL),
- shr->combined, &shr->combined);
-
- GPU_link(mat, "shade_alpha_opaque", shr->combined, &shr->combined);
- }
-
- if (ma->shade_flag & MA_OBCOLOR) {
- mat->obcolalpha = 1;
- GPU_link(mat, "shade_alpha_obcolor", shr->combined, GPU_builtin(GPU_OBCOLOR), &shr->combined);
- }
-}
-
-static GPUNodeLink *GPU_blender_material(GPUMaterial *mat, Material *ma)
-{
- GPUShadeInput shi;
- GPUShadeResult shr;
-
- GPU_shadeinput_set(mat, ma, &shi);
- GPU_shaderesult_set(&shi, &shr);
-
- return shr.combined;
-}
-
-static GPUNodeLink *gpu_material_diffuse_bsdf(GPUMaterial *mat, Material *ma)
-{
- static float roughness = 0.0f;
- GPUNodeLink *outlink;
-
- GPU_link(mat, "node_bsdf_diffuse",
- GPU_uniform(&ma->r), GPU_uniform(&roughness), GPU_builtin(GPU_VIEW_NORMAL), &outlink);
-
- return outlink;
-}
-
-static GPUNodeLink *gpu_material_preview_matcap(GPUMaterial *mat, Material *ma)
-{
- GPUNodeLink *outlink;
-
- /* some explanations here:
- * matcap normal holds the normal remapped to the 0.0 - 1.0 range. To take advantage of flat shading, we abuse
- * the built in secondary color of opengl. Color is just the regular color, which should include mask value too.
- * This also needs flat shading so we use the primary opengl color built-in */
- GPU_link(mat, "material_preview_matcap", GPU_uniform(&ma->r), GPU_image_preview(ma->preview),
- GPU_opengl_builtin(GPU_MATCAP_NORMAL), GPU_opengl_builtin(GPU_COLOR), &outlink);
-
- return outlink;
-}
-
-/* new solid draw mode with glsl matcaps */
-GPUMaterial *GPU_material_matcap(Scene *scene, Material *ma, bool use_opensubdiv)
-{
- GPUMaterial *mat;
- GPUNodeLink *outlink;
- LinkData *link;
-
- for (link = ma->gpumaterial.first; link; link = link->next) {
- GPUMaterial *current_material = (GPUMaterial *)link->data;
- if (current_material->scene == scene &&
- current_material->is_opensubdiv == use_opensubdiv)
- {
- return current_material;
- }
- }
-
- /* allocate material */
- mat = GPU_material_construct_begin(ma);
- mat->scene = scene;
- mat->type = GPU_MATERIAL_TYPE_MESH;
- mat->is_opensubdiv = use_opensubdiv;
-
- if (ma->preview && ma->preview->rect[0]) {
- outlink = gpu_material_preview_matcap(mat, ma);
- }
- else {
- outlink = gpu_material_diffuse_bsdf(mat, ma);
- }
-
- GPU_material_output_link(mat, outlink);
-
- gpu_material_construct_end(mat, "matcap_pass");
-
- /* note that even if building the shader fails in some way, we still keep
- * it to avoid trying to compile again and again, and simple do not use
- * the actual shader on drawing */
-
- link = MEM_callocN(sizeof(LinkData), "GPUMaterialLink");
- link->data = mat;
- BLI_addtail(&ma->gpumaterial, link);
-
- return mat;
-}
-
-static void do_world_tex(GPUShadeInput *shi, struct World *wo, GPUNodeLink **hor, GPUNodeLink **zen, GPUNodeLink **blend)
-{
- GPUMaterial *mat = shi->gpumat;
- GPUNodeLink *texco, *tin, *trgb, *stencil, *tcol, *zenfac;
- MTex *mtex;
- Tex *tex;
- float ofs[3], zero = 0.0f;
- int tex_nr, rgbnor;
-
- GPU_link(mat, "set_value_one", &stencil);
- /* go over texture slots */
- for (tex_nr = 0; tex_nr < MAX_MTEX; tex_nr++) {
- if (wo->mtex[tex_nr]) {
- mtex = wo->mtex[tex_nr];
- tex = mtex->tex;
- if (tex == NULL || !tex->ima || (tex->type != TEX_IMAGE && tex->type != TEX_ENVMAP))
- continue;
- /* which coords */
- if (mtex->texco == TEXCO_VIEW || mtex->texco == TEXCO_GLOB) {
- if (tex->type == TEX_IMAGE)
- texco = GPU_builtin(GPU_VIEW_POSITION);
- else if (tex->type == TEX_ENVMAP)
- GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &texco);
- }
- else if (mtex->texco == TEXCO_EQUIRECTMAP || mtex->texco == TEXCO_ANGMAP) {
- if ((tex->type == TEX_IMAGE && wo->skytype & WO_SKYREAL) || tex->type == TEX_ENVMAP)
- GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &texco);
- else
- texco = GPU_builtin(GPU_VIEW_POSITION);
- }
- else
- continue;
- GPU_link(mat, "texco_norm", texco, &texco);
- if (tex->type == TEX_IMAGE && !(wo->skytype & WO_SKYREAL)) {
- GPU_link(mat, "mtex_2d_mapping", texco, &texco);
- }
- if (mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.0f) {
- float size[3] = { mtex->size[0], mtex->size[1], mtex->size[2] };
- if (tex->type == TEX_ENVMAP) {
- size[1] = mtex->size[2];
- size[2] = mtex->size[1];
- }
- GPU_link(mat, "mtex_mapping_size", texco, GPU_uniform(size), &texco);
- }
- ofs[0] = mtex->ofs[0] + 0.5f - 0.5f * mtex->size[0];
- if (tex->type == TEX_ENVMAP) {
- ofs[1] = -mtex->ofs[2] + 0.5f - 0.5f * mtex->size[2];
- ofs[2] = mtex->ofs[1] + 0.5f - 0.5f * mtex->size[1];
- }
- else {
- ofs[1] = mtex->ofs[1] + 0.5f - 0.5f * mtex->size[1];
- ofs[2] = 0.0;
- }
- if (ofs[0] != 0.0f || ofs[1] != 0.0f || ofs[2] != 0.0f)
- GPU_link(mat, "mtex_mapping_ofs", texco, GPU_uniform(ofs), &texco);
- if (mtex->texco == TEXCO_EQUIRECTMAP) {
- GPU_link(mat, "node_tex_environment_equirectangular", texco, GPU_image(tex->ima, &tex->iuser, false), &trgb);
- }
- else if (mtex->texco == TEXCO_ANGMAP) {
- GPU_link(mat, "node_tex_environment_mirror_ball", texco, GPU_image(tex->ima, &tex->iuser, false), &trgb);
- }
- else {
- if (tex->type == TEX_ENVMAP)
- GPU_link(mat, "mtex_cube_map", texco, GPU_cube_map(tex->ima, &tex->iuser, false), &tin, &trgb);
- else if (tex->type == TEX_IMAGE)
- GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, false), &tin, &trgb);
- }
- rgbnor = TEX_RGB;
- if (tex->type == TEX_IMAGE || tex->type == TEX_ENVMAP)
- if (GPU_material_do_color_management(mat))
- GPU_link(mat, "srgb_to_linearrgb", trgb, &trgb);
- /* texture output */
- if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
- GPU_link(mat, "mtex_rgbtoint", trgb, &tin);
- rgbnor -= TEX_RGB;
- }
- if (mtex->texflag & MTEX_NEGATIVE) {
- if (rgbnor & TEX_RGB)
- GPU_link(mat, "mtex_rgb_invert", trgb, &trgb);
- else
- GPU_link(mat, "mtex_value_invert", tin, &tin);
- }
- if (mtex->texflag & MTEX_STENCIL) {
- if (rgbnor & TEX_RGB)
- GPU_link(mat, "mtex_rgb_stencil", stencil, trgb, &stencil, &trgb);
- else
- GPU_link(mat, "mtex_value_stencil", stencil, tin, &stencil, &tin);
- }
- else {
- if (rgbnor & TEX_RGB)
- GPU_link(mat, "mtex_alpha_multiply_value", trgb, stencil, &trgb);
- else
- GPU_link(mat, "math_multiply", stencil, tin, &tin);
- }
- /* color mapping */
- if (mtex->mapto & (WOMAP_HORIZ + WOMAP_ZENUP + WOMAP_ZENDOWN)) {
- if ((rgbnor & TEX_RGB) == 0)
- GPU_link(mat, "set_rgb", GPU_uniform(&mtex->r), &trgb);
- else
- GPU_link(mat, "mtex_alpha_from_col", trgb, &tin);
- GPU_link(mat, "set_rgb", trgb, &tcol);
- if (mtex->mapto & WOMAP_HORIZ) {
- texture_rgb_blend(mat, tcol, *hor, tin, GPU_uniform(&mtex->colfac), mtex->blendtype, hor);
- }
- if (mtex->mapto & (WOMAP_ZENUP + WOMAP_ZENDOWN)) {
- GPU_link(mat, "set_value_zero", &zenfac);
- if (wo->skytype & WO_SKYREAL) {
- if (mtex->mapto & WOMAP_ZENUP) {
- if (mtex->mapto & WOMAP_ZENDOWN) {
- GPU_link(mat, "world_zen_mapping", shi->view, GPU_uniform(&mtex->zenupfac),
- GPU_uniform(&mtex->zendownfac), &zenfac);
- }
- else {
- GPU_link(mat, "world_zen_mapping", shi->view, GPU_uniform(&mtex->zenupfac),
- GPU_uniform(&zero), &zenfac);
- }
- }
- else if (mtex->mapto & WOMAP_ZENDOWN) {
- GPU_link(mat, "world_zen_mapping", shi->view, GPU_uniform(&zero),
- GPU_uniform(&mtex->zendownfac), &zenfac);
- }
- }
- else {
- if (mtex->mapto & WOMAP_ZENUP)
- GPU_link(mat, "set_value", GPU_uniform(&mtex->zenupfac), &zenfac);
- else if (mtex->mapto & WOMAP_ZENDOWN)
- GPU_link(mat, "set_value", GPU_uniform(&mtex->zendownfac), &zenfac);
- }
- texture_rgb_blend(mat, tcol, *zen, tin, zenfac, mtex->blendtype, zen);
- }
- }
- if (mtex->mapto & WOMAP_BLEND && wo->skytype & WO_SKYBLEND) {
- if (rgbnor & TEX_RGB)
- GPU_link(mat, "mtex_rgbtoint", trgb, &tin);
- texture_value_blend(mat, GPU_uniform(&mtex->def_var), *blend, tin, GPU_uniform(&mtex->blendfac), mtex->blendtype, blend);
- }
- }
- }
-}
-
-static void gpu_material_old_world(struct GPUMaterial *mat, struct World *wo)
-{
- GPUShadeInput shi;
- GPUShadeResult shr;
- GPUNodeLink *hor, *zen, *ray, *blend;
-
- shi.gpumat = mat;
-
- for (int i = 0; i < MAX_MTEX; i++) {
- if (wo->mtex[i] && wo->mtex[i]->tex) {
- wo->skytype |= WO_SKYTEX;
- break;
- }
- }
- if ((wo->skytype & (WO_SKYBLEND + WO_SKYTEX)) == 0) {
- GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&wo->horr, GPU_DYNAMIC_HORIZON_COLOR, NULL), &shr.combined);
- }
- else {
- GPU_link(mat, "set_rgb_zero", &shi.rgb);
- GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &ray);
- if (wo->skytype & WO_SKYPAPER)
- GPU_link(mat, "world_paper_view", GPU_builtin(GPU_VIEW_POSITION), &shi.view);
- else
- GPU_link(mat, "shade_view", ray, &shi.view);
- if (wo->skytype & WO_SKYBLEND) {
- if (wo->skytype & WO_SKYPAPER) {
- if (wo->skytype & WO_SKYREAL)
- GPU_link(mat, "world_blend_paper_real", GPU_builtin(GPU_VIEW_POSITION), &blend);
- else
- GPU_link(mat, "world_blend_paper", GPU_builtin(GPU_VIEW_POSITION), &blend);
- }
- else {
- if (wo->skytype & WO_SKYREAL)
- GPU_link(mat, "world_blend_real", ray, &blend);
- else
- GPU_link(mat, "world_blend", ray, &blend);
- }
- }
- else {
- GPU_link(mat, "set_value_zero", &blend);
- }
- GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&wo->horr, GPU_DYNAMIC_HORIZON_COLOR, NULL), &hor);
- GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&wo->zenr, GPU_DYNAMIC_ZENITH_COLOR, NULL), &zen);
- do_world_tex(&shi, wo, &hor, &zen, &blend);
- if (wo->skytype & WO_SKYBLEND)
- GPU_link(mat, "node_mix_shader", blend, hor, zen, &shi.rgb);
- else
- GPU_link(mat, "set_rgb", hor, &shi.rgb);
- GPU_link(mat, "set_rgb", shi.rgb, &shr.combined);
- }
- GPU_material_output_link(mat, shr.combined);
-}
-
-GPUMaterial *GPU_material_world(struct Scene *scene, struct World *wo)
-{
- LinkData *link;
- GPUMaterial *mat;
-
- for (link = wo->gpumaterial.first; link; link = link->next)
- if (((GPUMaterial *)link->data)->scene == scene)
- return link->data;
-
- /* allocate material */
- mat = GPU_material_construct_begin(NULL);
- mat->scene = scene;
- mat->type = GPU_MATERIAL_TYPE_WORLD;
-
- /* create nodes */
- if (BKE_scene_use_new_shading_nodes(scene) && wo->nodetree && wo->use_nodes) {
- ntreeGPUMaterialNodes(wo->nodetree, mat, NODE_NEW_SHADING);
- }
- else {
- gpu_material_old_world(mat, wo);
- }
-
- if (GPU_material_do_color_management(mat))
- if (mat->outlink)
- GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &mat->outlink);
-
- gpu_material_construct_end(mat, wo->id.name);
-
- /* note that even if building the shader fails in some way, we still keep
- * it to avoid trying to compile again and again, and simple do not use
- * the actual shader on drawing */
-
- link = MEM_callocN(sizeof(LinkData), "GPUMaterialLink");
- link->data = mat;
- BLI_addtail(&wo->gpumaterial, link);
-
- return mat;
-}
-
GPUMaterial *GPU_material_from_nodetree_find(
ListBase *gpumaterials, const void *engine_type, int options)
{
@@ -2508,15 +598,12 @@ GPUMaterial *GPU_material_from_nodetree_find(
}
/**
- * TODO: This is supposed to replace GPU_material_from_blender/_world in the future
- *
* \note Caller must use #GPU_material_from_nodetree_find to re-use existing materials,
* This is enforced since constructing other arguments to this function may be expensive
* so only do this when they are needed.
*/
GPUMaterial *GPU_material_from_nodetree(
- Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options,
- const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines, bool deferred)
+ Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options)
{
LinkData *link;
bool has_volume_output, has_surface_output;
@@ -2540,10 +627,7 @@ GPUMaterial *GPU_material_from_nodetree(
mat->domain |= GPU_DOMAIN_VOLUME;
}
- if (!deferred) {
- GPU_material_generate_pass(mat, vert_code, geom_code, frag_lib, defines);
- }
- else if (mat->outlink) {
+ if (mat->outlink) {
/* Prune the unused nodes and extract attribs before compiling so the
* generated VBOs are ready to accept the future shader. */
GPU_nodes_prune(&mat->nodes, mat->outlink);
@@ -2562,9 +646,8 @@ GPUMaterial *GPU_material_from_nodetree(
return mat;
}
-/* Calls this function if /a mat was created with deferred compilation. */
void GPU_material_generate_pass(
- GPUMaterial *mat, const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines)
+ GPUMaterial *mat, const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines)
{
BLI_assert(mat->pass == NULL); /* Only run once! */
if (mat->outlink) {
@@ -2577,74 +660,8 @@ void GPU_material_generate_pass(
}
}
-GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma, bool use_opensubdiv)
-{
- GPUMaterial *mat;
- GPUNodeLink *outlink;
- LinkData *link;
-
- for (link = ma->gpumaterial.first; link; link = link->next) {
- GPUMaterial *current_material = (GPUMaterial *)link->data;
- if (current_material->scene == scene &&
- current_material->is_opensubdiv == use_opensubdiv)
- {
- return current_material;
- }
- }
-
- /* allocate material */
- mat = GPU_material_construct_begin(ma);
- mat->scene = scene;
- mat->type = GPU_MATERIAL_TYPE_MESH;
- mat->is_opensubdiv = use_opensubdiv;
-
- /* render pipeline option */
- bool new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
- if (!new_shading_nodes && (ma->mode & MA_TRANSP))
- GPU_material_enable_alpha(mat);
- else if (new_shading_nodes && ma->alpha < 1.0f)
- GPU_material_enable_alpha(mat);
-
- if (!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) {
- /* create nodes */
- if (new_shading_nodes)
- ntreeGPUMaterialNodes(ma->nodetree, mat, NODE_NEW_SHADING);
- else
- ntreeGPUMaterialNodes(ma->nodetree, mat, NODE_OLD_SHADING);
- }
- else {
- if (new_shading_nodes) {
- /* create simple diffuse material instead of nodes */
- outlink = gpu_material_diffuse_bsdf(mat, ma);
- }
- else {
- /* create blender material */
- outlink = GPU_blender_material(mat, ma);
- }
-
- GPU_material_output_link(mat, outlink);
- }
-
- if (GPU_material_do_color_management(mat))
- if (mat->outlink)
- GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &mat->outlink);
-
- gpu_material_construct_end(mat, ma->id.name);
-
- /* note that even if building the shader fails in some way, we still keep
- * it to avoid trying to compile again and again, and simple do not use
- * the actual shader on drawing */
-
- link = MEM_callocN(sizeof(LinkData), "GPUMaterialLink");
- link->data = mat;
- BLI_addtail(&ma->gpumaterial, link);
-
- return mat;
-}
-
void GPU_materials_free(void)
{
- Object *ob;
Material *ma;
World *wo;
extern Material defmaterial;
@@ -2656,307 +673,4 @@ void GPU_materials_free(void)
GPU_material_free(&wo->gpumaterial);
GPU_material_free(&defmaterial.gpumaterial);
-
- for (ob = G.main->object.first; ob; ob = ob->id.next)
- GPU_lamp_free(ob);
-}
-
-/* Lamps and shadow buffers */
-
-GPUNodeLink *GPU_lamp_get_data(
- GPUMaterial *mat, GPULamp *lamp,
- GPUNodeLink **r_col, GPUNodeLink **r_lv, GPUNodeLink **r_dist, GPUNodeLink **r_shadow, GPUNodeLink **r_energy)
-{
- GPUNodeLink *visifac;
-
- *r_col = GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob);
- *r_energy = GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob);
- visifac = lamp_get_visibility(mat, lamp, r_lv, r_dist);
-
- shade_light_textures(mat, lamp, r_col);
-
- if (GPU_lamp_has_shadow_buffer(lamp)) {
- GPUNodeLink *vn, *inp;
-
- GPU_link(mat, "shade_norm", GPU_builtin(GPU_VIEW_NORMAL), &vn);
- GPU_link(mat, "shade_inp", vn, *r_lv, &inp);
- mat->dynproperty |= DYN_LAMP_PERSMAT;
-
- if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
- GPU_link(mat, "shadows_only_vsm",
- GPU_builtin(GPU_VIEW_POSITION),
- GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
- GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
- GPU_uniform(&lamp->bias), GPU_uniform(&lamp->la->bleedbias),
- GPU_uniform(lamp->shadow_color), inp, r_shadow);
- }
- else {
- GPU_link(mat, "shadows_only",
- GPU_builtin(GPU_VIEW_POSITION),
- GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
- GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
- GPU_uniform(&lamp->bias), GPU_uniform(lamp->shadow_color), inp, r_shadow);
- }
- }
- else {
- GPU_link(mat, "set_rgb_one", r_shadow);
- }
-
- /* ensure shadow buffer and lamp textures will be updated */
- add_user_list(&mat->lamps, lamp);
-
- return visifac;
-}
-
-/* export the GLSL shader */
-
-GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
-{
- static struct {
- GPUBuiltin gputype;
- GPUDynamicType dynamictype;
- GPUDataType datatype;
- } builtins[] = {
- { GPU_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_VIEWMAT, GPU_DATA_16F },
- { GPU_INVERSE_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_VIEWIMAT, GPU_DATA_16F },
- { GPU_OBJECT_MATRIX, GPU_DYNAMIC_OBJECT_MAT, GPU_DATA_16F },
- { GPU_INVERSE_OBJECT_MATRIX, GPU_DYNAMIC_OBJECT_IMAT, GPU_DATA_16F },
- { GPU_LOC_TO_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_LOCTOVIEWMAT, GPU_DATA_16F },
- { GPU_INVERSE_LOC_TO_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_LOCTOVIEWIMAT, GPU_DATA_16F },
- { GPU_OBCOLOR, GPU_DYNAMIC_OBJECT_COLOR, GPU_DATA_4F },
- { GPU_AUTO_BUMPSCALE, GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE, GPU_DATA_1F },
- { 0 }
- };
-
- GPUShaderExport *shader = NULL;
- GPUInput *input;
- int liblen, fraglen;
-
- /* TODO(sergey): How to determine whether we need OSD or not here? */
- GPUMaterial *mat = GPU_material_from_blender(scene, ma, false);
- GPUPass *pass = (mat) ? mat->pass : NULL;
-
- if (pass && pass->fragmentcode && pass->vertexcode) {
- shader = MEM_callocN(sizeof(GPUShaderExport), "GPUShaderExport");
-
- for (input = mat->inputs.first; input; input = input->next) {
- GPUInputUniform *uniform = MEM_callocN(sizeof(GPUInputUniform), "GPUInputUniform");
-
- if (input->ima) {
- /* image sampler uniform */
- uniform->type = GPU_DYNAMIC_SAMPLER_2DIMAGE;
- uniform->datatype = GPU_DATA_1I;
- uniform->image = input->ima;
- uniform->texnumber = input->texid;
- BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname));
- }
- else if (input->tex) {
- /* generated buffer */
- uniform->texnumber = input->texid;
- uniform->datatype = GPU_DATA_1I;
- BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname));
-
- switch (input->textype) {
- case GPU_SHADOW2D:
- uniform->type = GPU_DYNAMIC_SAMPLER_2DSHADOW;
- uniform->lamp = input->dynamicdata;
- break;
- case GPU_TEX2D:
- if (GPU_texture_opengl_bindcode(input->tex)) {
- uniform->type = GPU_DYNAMIC_SAMPLER_2DBUFFER;
- glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(input->tex));
- uniform->texsize = GPU_texture_width(input->tex) * GPU_texture_height(input->tex);
- uniform->texpixels = MEM_mallocN(uniform->texsize * 4, "RGBApixels");
- glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, uniform->texpixels);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
- break;
-
- case GPU_NONE:
- case GPU_TEX3D:
- case GPU_TEXCUBE:
- case GPU_FLOAT:
- case GPU_VEC2:
- case GPU_VEC3:
- case GPU_VEC4:
- case GPU_MAT3:
- case GPU_MAT4:
- case GPU_CLOSURE:
- case GPU_ATTRIB:
- break;
- }
- }
- else {
- uniform->type = input->dynamictype;
- BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname));
- switch (input->type) {
- case GPU_FLOAT:
- uniform->datatype = GPU_DATA_1F;
- break;
- case GPU_VEC2:
- uniform->datatype = GPU_DATA_2F;
- break;
- case GPU_VEC3:
- uniform->datatype = GPU_DATA_3F;
- break;
- case GPU_VEC4:
- uniform->datatype = GPU_DATA_4F;
- break;
- case GPU_MAT3:
- uniform->datatype = GPU_DATA_9F;
- break;
- case GPU_MAT4:
- uniform->datatype = GPU_DATA_16F;
- break;
-
- case GPU_NONE:
- case GPU_CLOSURE:
- case GPU_TEX2D:
- case GPU_TEX3D:
- case GPU_TEXCUBE:
- case GPU_SHADOW2D:
- case GPU_ATTRIB:
- break;
- }
-
- if (GPU_DYNAMIC_GROUP_FROM_TYPE(uniform->type) == GPU_DYNAMIC_GROUP_LAMP)
- uniform->lamp = input->dynamicdata;
-
- if (GPU_DYNAMIC_GROUP_FROM_TYPE(uniform->type) == GPU_DYNAMIC_GROUP_MAT)
- uniform->material = input->dynamicdata;
- }
-
- if (uniform->type != GPU_DYNAMIC_NONE)
- BLI_addtail(&shader->uniforms, uniform);
- else
- MEM_freeN(uniform);
- }
-
- /* process builtin uniform */
- for (int i = 0; builtins[i].gputype; i++) {
- if (mat->builtins & builtins[i].gputype) {
- GPUInputUniform *uniform = MEM_callocN(sizeof(GPUInputUniform), "GPUInputUniform");
- uniform->type = builtins[i].dynamictype;
- uniform->datatype = builtins[i].datatype;
- BLI_strncpy(uniform->varname, GPU_builtin_name(builtins[i].gputype), sizeof(uniform->varname));
- BLI_addtail(&shader->uniforms, uniform);
- }
- }
-
- /* now link fragment shader with library shader */
- /* TBD: remove the function that are not used in the main function */
- liblen = (pass->libcode) ? strlen(pass->libcode) : 0;
- fraglen = strlen(pass->fragmentcode);
- shader->fragment = (char *)MEM_mallocN(liblen + fraglen + 1, "GPUFragShader");
- if (pass->libcode)
- memcpy(shader->fragment, pass->libcode, liblen);
- memcpy(&shader->fragment[liblen], pass->fragmentcode, fraglen);
- shader->fragment[liblen + fraglen] = 0;
-
- // export the attribute
- for (int i = 0; i < mat->attribs.totlayer; i++) {
- GPUInputAttribute *attribute = MEM_callocN(sizeof(GPUInputAttribute), "GPUInputAttribute");
- attribute->type = mat->attribs.layer[i].type;
- attribute->number = mat->attribs.layer[i].glindex;
- BLI_snprintf(attribute->varname, sizeof(attribute->varname), "att%d", mat->attribs.layer[i].attribid);
-
- switch (attribute->type) {
- case CD_TANGENT:
- attribute->datatype = GPU_DATA_4F;
- break;
- case CD_MTFACE:
- attribute->datatype = GPU_DATA_2F;
- attribute->name = mat->attribs.layer[i].name;
- break;
- case CD_MCOL:
- attribute->datatype = GPU_DATA_4UB;
- attribute->name = mat->attribs.layer[i].name;
- break;
- case CD_ORCO:
- attribute->datatype = GPU_DATA_3F;
- break;
- }
-
- if (attribute->datatype != GPU_DATA_NONE)
- BLI_addtail(&shader->attributes, attribute);
- else
- MEM_freeN(attribute);
- }
-
- /* export the vertex shader */
- shader->vertex = BLI_strdup(pass->vertexcode);
- }
-
- return shader;
-}
-
-void GPU_free_shader_export(GPUShaderExport *shader)
-{
- if (shader == NULL)
- return;
-
- for (GPUInputUniform *uniform = shader->uniforms.first; uniform; uniform = uniform->next)
- if (uniform->texpixels)
- MEM_freeN(uniform->texpixels);
-
- BLI_freelistN(&shader->uniforms);
- BLI_freelistN(&shader->attributes);
-
- if (shader->vertex)
- MEM_freeN(shader->vertex);
- if (shader->fragment)
- MEM_freeN(shader->fragment);
-
- MEM_freeN(shader);
}
-
-#ifdef WITH_OPENSUBDIV
-void GPU_material_update_fvar_offset(GPUMaterial *gpu_material,
- DerivedMesh *dm)
-{
- GPUPass *pass = gpu_material->pass;
- GPUShader *shader = (pass != NULL ? pass->shader : NULL);
- ListBase *inputs = (pass != NULL ? &gpu_material->inputs : NULL);
- GPUInput *input;
-
- if (shader == NULL) {
- return;
- }
-
- GPU_shader_bind(shader);
-
- for (input = inputs->first;
- input != NULL;
- input = input->next)
- {
- if (input->source == GPU_SOURCE_ATTRIB &&
- input->attribtype == CD_MTFACE)
- {
- char name[64];
- /* TODO(sergey): This will work for until names are
- * consistent, we'll need to solve this somehow in the future.
- */
- int layer_index;
- int location;
-
- if (input->attribname[0] != '\0') {
- layer_index = CustomData_get_named_layer(&dm->loopData,
- CD_MLOOPUV,
- input->attribname);
- }
- else {
- layer_index = CustomData_get_active_layer(&dm->loopData,
- CD_MLOOPUV);
- }
-
- BLI_snprintf(name, sizeof(name),
- "fvar%d_offset",
- input->attribid);
- location = GPU_shader_get_uniform(shader, name);
- GPU_shader_uniform_int(shader, location, layer_index);
- }
- }
-
- GPU_shader_unbind();
-}
-#endif
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index e0b11edb197..db464498a27 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -60,8 +60,10 @@ extern char datatoc_gpu_shader_simple_lighting_smooth_color_frag_glsl[];
extern char datatoc_gpu_shader_simple_lighting_smooth_color_alpha_frag_glsl[];
extern char datatoc_gpu_shader_flat_color_frag_glsl[];
extern char datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl[];
+extern char datatoc_gpu_shader_flat_id_frag_glsl[];
extern char datatoc_gpu_shader_2D_vert_glsl[];
extern char datatoc_gpu_shader_2D_flat_color_vert_glsl[];
+extern char datatoc_gpu_shader_2D_smooth_color_uniform_alpha_vert_glsl[];
extern char datatoc_gpu_shader_2D_smooth_color_vert_glsl[];
extern char datatoc_gpu_shader_2D_smooth_color_frag_glsl[];
extern char datatoc_gpu_shader_2D_image_vert_glsl[];
@@ -98,6 +100,7 @@ extern char datatoc_gpu_shader_3D_clipped_uniform_color_vert_glsl[];
extern char datatoc_gpu_shader_instance_vert_glsl[];
extern char datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl[];
+extern char datatoc_gpu_shader_instance_variying_size_variying_id_vert_glsl[];
extern char datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl[];
extern char datatoc_gpu_shader_instance_screenspace_variying_color_vert_glsl[];
extern char datatoc_gpu_shader_instance_screen_aligned_vert_glsl[];
@@ -211,8 +214,7 @@ static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH])
}
static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH],
- bool use_opensubdiv,
- bool use_new_shading)
+ bool use_opensubdiv)
{
/* some useful defines to detect GPU type */
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
@@ -251,10 +253,6 @@ static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH],
UNUSED_VARS(use_opensubdiv);
#endif
- if (use_new_shading) {
- strcat(defines, "#define USE_NEW_SHADING\n");
- }
-
return;
}
@@ -362,8 +360,7 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
}
gpu_shader_standard_defines(standard_defines,
- use_opensubdiv,
- (flags & GPU_SHADER_FLAGS_NEW_SHADING) != 0);
+ use_opensubdiv);
gpu_shader_standard_extensions(standard_extensions);
if (vertexcode) {
@@ -703,6 +700,8 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
datatoc_gpu_shader_flat_color_frag_glsl },
[GPU_SHADER_2D_SMOOTH_COLOR] = { datatoc_gpu_shader_2D_smooth_color_vert_glsl,
datatoc_gpu_shader_2D_smooth_color_frag_glsl },
+ [GPU_SHADER_2D_SMOOTH_COLOR_UNIFORM_ALPHA] = { datatoc_gpu_shader_2D_smooth_color_uniform_alpha_vert_glsl,
+ datatoc_gpu_shader_2D_smooth_color_frag_glsl },
[GPU_SHADER_2D_IMAGE_LINEAR_TO_SRGB] = { datatoc_gpu_shader_2D_image_vert_glsl,
datatoc_gpu_shader_image_linear_frag_glsl },
[GPU_SHADER_2D_IMAGE] = { datatoc_gpu_shader_2D_image_vert_glsl,
@@ -792,6 +791,9 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
datatoc_gpu_shader_point_uniform_color_outline_aa_frag_glsl },
[GPU_SHADER_INSTANCE_UNIFORM_COLOR] = { datatoc_gpu_shader_instance_vert_glsl, datatoc_gpu_shader_uniform_color_frag_glsl },
+ [GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE] =
+ { datatoc_gpu_shader_instance_variying_size_variying_id_vert_glsl,
+ datatoc_gpu_shader_flat_id_frag_glsl },
[GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE] =
{ datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl,
datatoc_gpu_shader_flat_color_frag_glsl },
@@ -833,6 +835,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
case GPU_SHADER_SMOKE_COBA:
defines = "#define USE_COBA\n";
break;
+ case GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE:
case GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE:
defines = "#define UNIFORM_SCALE\n";
break;
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 75830f60f03..bccc818aa34 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -147,8 +147,14 @@ static GLenum gpu_texture_get_format(
}
else {
/* Integer formats */
- if (ELEM(data_type, GPU_RG16I, GPU_R16I)) {
- *data_format = GL_INT;
+ if (ELEM(data_type, GPU_RG16I, GPU_R16I, GPU_R16UI)) {
+ if (ELEM(data_type, GPU_R16UI)) {
+ *data_format = GL_UNSIGNED_INT;
+ }
+ else {
+ *data_format = GL_INT;
+ }
+
*format_flag |= GPU_FORMAT_INTEGER;
switch (components) {
@@ -224,6 +230,7 @@ static GLenum gpu_texture_get_format(
case GPU_R32F: return GL_R32F;
case GPU_R16F: return GL_R16F;
case GPU_R16I: return GL_R16I;
+ case GPU_R16UI: return GL_R16UI;
case GPU_RG8: return GL_RG8;
case GPU_R8: return GL_R8;
/* Special formats texture & renderbuffer */
@@ -464,8 +471,8 @@ static GPUTexture *GPU_texture_create_nD(
/* Texture Parameters */
if (GPU_texture_stencil(tex) || /* Does not support filtering */
- GPU_texture_integer(tex) || /* Does not support filtering */
- GPU_texture_depth(tex))
+ GPU_texture_integer(tex) || /* Does not support filtering */
+ GPU_texture_depth(tex))
{
glTexParameteri(tex->target_base, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(tex->target_base, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -575,12 +582,11 @@ static GPUTexture *GPU_texture_cube_create(
return tex;
}
-GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget, bool is_data, double time, int mipmap)
+GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget, bool is_data, double UNUSED(time), int mipmap)
{
int gputt;
/* this binds a texture, so that's why to restore it to 0 */
- GLint bindcode = GPU_verify_image(ima, iuser, textarget, 0, 0, mipmap, is_data);
- GPU_update_image_time(ima, time);
+ GLint bindcode = GPU_verify_image(ima, iuser, textarget, 0, mipmap, is_data);
/* see GPUInput::textarget: it can take two values - GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP
* these values are correct for glDisable, so textarget can be safely used in
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_smooth_color_uniform_alpha_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_smooth_color_uniform_alpha_vert.glsl
new file mode 100644
index 00000000000..a8ad5575235
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_2D_smooth_color_uniform_alpha_vert.glsl
@@ -0,0 +1,14 @@
+
+uniform mat4 ModelViewProjectionMatrix;
+uniform float alpha;
+
+in vec2 pos;
+in vec4 color;
+
+noperspective out vec4 finalColor;
+
+void main()
+{
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
+ finalColor = vec4(color[0], color[1], color[2], color[3] * alpha);
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
index 0c351a3bce4..107480580f9 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
@@ -47,11 +47,11 @@ const vec2 jit[9] = vec2[9](
/* We can reuse the CORNER_* bits for tria */
#define TRIA_VEC_RANGE BIT_RANGE(6)
-const vec2 triavec[34] = vec2[34](
- /* horizontal tria */
+const vec2 triavec[37] = vec2[37](
+ /* ROUNDBOX_TRIA_ARROWS */
vec2(-0.352077, 0.532607), vec2(-0.352077, -0.549313), vec2( 0.330000, -0.008353),
vec2( 0.352077, 0.532607), vec2( 0.352077, -0.549313), vec2(-0.330000, -0.008353),
- /* circle tria (triangle strip) */
+ /* ROUNDBOX_TRIA_SCROLL - circle tria (triangle strip) */
vec2(0.000000, 1.000000),
vec2(0.382684, 0.923879), vec2(-0.382683, 0.923880),
vec2(0.707107, 0.707107), vec2(-0.707107, 0.707107),
@@ -61,12 +61,19 @@ const vec2 triavec[34] = vec2[34](
vec2(0.707107, -0.707107), vec2(-0.707107, -0.707107),
vec2(0.382684, -0.923879), vec2(-0.382683, -0.923880),
vec2(0.000000, -1.000000),
- /* menu arrow */
+ /* ROUNDBOX_TRIA_MENU - menu arrows */
vec2(-0.33, 0.16), vec2(0.33, 0.16), vec2(0.0, 0.82),
vec2(0.0, -0.82), vec2(-0.33, -0.16), vec2(0.33, -0.16),
- /* check mark */
+ /* ROUNDBOX_TRIA_CHECK - check mark */
vec2(-0.578579, 0.253369), vec2(-0.392773, 0.412794), vec2(-0.004241, -0.328551),
- vec2(-0.003001, 0.034320), vec2(1.055313, 0.864744), vec2(0.866408, 1.026895)
+ vec2(-0.003001, 0.034320), vec2(1.055313, 0.864744), vec2(0.866408, 1.026895),
+ /* ROUNDBOX_TRIA_HOLD_ACTION_ARROW - hold action arrows */
+#define OY -0.2
+#define SC 0.35
+// vec2(-0.5 + SC, 1.0 + OY), vec2( 0.5, 1.0 + OY), vec2( 0.5, 0.0 + OY + SC),
+ vec2( 0.5 - SC, 1.0 + OY), vec2(-0.5, 1.0 + OY), vec2(-0.5, 0.0 + OY + SC)
+#undef OY
+#undef SC
);
uniform mat4 ModelViewProjectionMatrix;
@@ -183,4 +190,4 @@ void main()
v += jit[(vflag >> JIT_OFS) & JIT_RANGE];
gl_Position = ModelViewProjectionMatrix * vec4(v, 0.0, 1.0);
-} \ No newline at end of file
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_flat_id_frag.glsl b/source/blender/gpu/shaders/gpu_shader_flat_id_frag.glsl
new file mode 100644
index 00000000000..aa6f30531ae
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_flat_id_frag.glsl
@@ -0,0 +1,8 @@
+
+flat in uint finalId;
+out uint fragId;
+
+void main()
+{
+ fragId = finalId;
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_geometry.glsl b/source/blender/gpu/shaders/gpu_shader_geometry.glsl
index 7586050b258..705b79cbf56 100644
--- a/source/blender/gpu/shaders/gpu_shader_geometry.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_geometry.glsl
@@ -32,17 +32,12 @@ uniform int osd_fvar_count;
tessCoord.t); \
}
-#ifdef USE_NEW_SHADING
# define INTERP_FACE_VARYING_ATT_2(result, fvarOffset, tessCoord) \
{ \
vec2 tmp; \
INTERP_FACE_VARYING_2(tmp, fvarOffset, tessCoord); \
result = vec3(tmp, 0); \
}
-#else
-# define INTERP_FACE_VARYING_ATT_2(result, fvarOffset, tessCoord) \
- INTERP_FACE_VARYING_2(result, fvarOffset, tessCoord)
-#endif
uniform samplerBuffer FVarDataBuffer;
uniform isamplerBuffer FVarDataOffsetBuffer;
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl
new file mode 100644
index 00000000000..49750dddb3c
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl
@@ -0,0 +1,23 @@
+
+uniform mat4 ViewProjectionMatrix;
+uniform int baseId;
+
+/* ---- Instanciated Attribs ---- */
+in vec3 pos;
+
+/* ---- Per instance Attribs ---- */
+in mat4 InstanceModelMatrix;
+#ifdef UNIFORM_SCALE
+in float size;
+#else
+in vec3 size;
+#endif
+in int callId;
+
+flat out uint finalId;
+
+void main()
+{
+ gl_Position = ViewProjectionMatrix * InstanceModelMatrix * vec4(pos * size, 1.0);
+ finalId = uint(baseId + callId);
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index d3bc1f0ef8e..45701f090fa 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -41,11 +41,7 @@ Closure nodetree_exec(void); /* Prototype */
float convert_rgba_to_float(vec4 color)
{
-#ifdef USE_NEW_SHADING
return dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));
-#else
- return (color.r + color.g + color.b) * 0.333333;
-#endif
}
float exp_blender(float f)
@@ -203,50 +199,6 @@ void color_to_blender_normal_new_shading(vec3 color, out vec3 normal)
/*********** SHADER NODES ***************/
-void vcol_attribute(vec4 attvcol, out vec4 vcol)
-{
- vcol = vec4(attvcol.xyz, 1.0);
-}
-
-void uv_attribute(vec2 attuv, out vec3 uv)
-{
- uv = vec3(attuv * 2.0 - vec2(1.0, 1.0), 0.0);
-}
-
-void geom(
- vec3 co, vec3 nor, mat4 viewinvmat, vec3 attorco, vec2 attuv, vec4 attvcol,
- out vec3 global, out vec3 local, out vec3 view, out vec3 orco, out vec3 uv,
- out vec3 normal, out vec4 vcol, out float vcol_alpha, out float frontback)
-{
- local = co;
- view = (ProjectionMatrix[3][3] == 0.0) ? normalize(local) : vec3(0.0, 0.0, -1.0);
- global = (viewinvmat * vec4(local, 1.0)).xyz;
- orco = attorco;
- uv_attribute(attuv, uv);
- normal = -normalize(nor); /* blender render normal is negated */
- vcol_attribute(attvcol, vcol);
- srgb_to_linearrgb(vcol, vcol);
- vcol_alpha = attvcol.a;
- frontback = (gl_FrontFacing) ? 1.0 : 0.0;
-}
-
-void particle_info(
- vec4 sprops, vec4 loc, vec3 vel, vec3 avel,
- out float index, out float random, out float age,
- out float life_time, out vec3 location,
- out float size, out vec3 velocity, out vec3 angular_velocity)
-{
- index = sprops.x;
- random = loc.w;
- age = sprops.y;
- life_time = sprops.z;
- size = sprops.w;
-
- location = loc.xyz;
- velocity = vel;
- angular_velocity = avel;
-}
-
void vect_normalize(vec3 vin, out vec3 vout)
{
vout = normalize(vin);
@@ -314,17 +266,6 @@ void camera(vec3 co, out vec3 outview, out float outdepth, out float outdist)
outview = normalize(co);
}
-void lamp(
- vec4 col, float energy, vec3 lv, float dist, vec3 shadow, float visifac,
- out vec4 outcol, out vec3 outlv, out float outdist, out vec4 outshadow, out float outvisifac)
-{
- outcol = col * energy;
- outlv = lv;
- outdist = dist;
- outshadow = vec4(shadow, 1.0);
- outvisifac = visifac;
-}
-
void math_add(float val1, float val2, out float outval)
{
outval = val1 + val2;
@@ -866,11 +807,7 @@ void valtorgb(float fac, sampler2D colormap, out vec4 outcol, out float outalpha
void rgbtobw(vec4 color, out float outval)
{
-#ifdef USE_NEW_SHADING
vec3 factors = vec3(0.2126, 0.7152, 0.0722);
-#else
- vec3 factors = vec3(0.35, 0.45, 0.2); /* keep these factors in sync with texture.h:RGBTOBW */
-#endif
outval = dot(color.rgb, factors);
}
@@ -954,56 +891,6 @@ void output_node(vec4 rgb, float alpha, out vec4 outrgb)
/*********** TEXTURES ***************/
-void texture_flip_blend(vec3 vec, out vec3 outvec)
-{
- outvec = vec.yxz;
-}
-
-void texture_blend_lin(vec3 vec, out float outval)
-{
- outval = (1.0 + vec.x) * 0.5;
-}
-
-void texture_blend_quad(vec3 vec, out float outval)
-{
- outval = max((1.0 + vec.x) * 0.5, 0.0);
- outval *= outval;
-}
-
-void texture_wood_sin(vec3 vec, out float value, out vec4 color, out vec3 normal)
-{
- float a = sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z) * 20.0;
- float wi = 0.5 + 0.5 * sin(a);
-
- value = wi;
- color = vec4(wi, wi, wi, 1.0);
- normal = vec3(0.0);
-}
-
-void texture_image(vec3 vec, sampler2D ima, out float value, out vec4 color, out vec3 normal)
-{
- color = texture(ima, (vec.xy + vec2(1.0)) * 0.5);
- value = color.a;
-
- normal.x = 2.0 * (color.r - 0.5);
- normal.y = 2.0 * (0.5 - color.g);
- normal.z = 2.0 * (color.b - 0.5);
-}
-
-/************* MTEX *****************/
-
-void texco_orco(vec3 attorco, out vec3 orco)
-{
- orco = attorco;
-}
-
-void texco_uv(vec2 attuv, out vec3 uv)
-{
- /* disabled for now, works together with leaving out mtex_2d_mapping */
- // uv = vec3(attuv*2.0 - vec2(1.0, 1.0), 0.0); */
- uv = vec3(attuv, 0.0);
-}
-
void texco_norm(vec3 normal, out vec3 outnormal)
{
/* corresponds to shi->orn, which is negated so cancels
@@ -1011,432 +898,11 @@ void texco_norm(vec3 normal, out vec3 outnormal)
outnormal = normalize(normal);
}
-void texco_tangent(vec4 tangent, out vec3 outtangent)
-{
- outtangent = normalize(tangent.xyz);
-}
-
-void texco_global(mat4 viewinvmat, vec3 co, out vec3 global)
-{
- global = (viewinvmat * vec4(co, 1.0)).xyz;
-}
-
-void texco_object(mat4 viewinvmat, mat4 obinvmat, vec3 co, out vec3 object)
-{
- object = (obinvmat * (viewinvmat * vec4(co, 1.0))).xyz;
-}
-
-void texco_refl(vec3 vn, vec3 view, out vec3 ref)
-{
- ref = view - 2.0 * dot(vn, view) * vn;
-}
-
-void shade_norm(vec3 normal, out vec3 outnormal)
-{
- /* blender render normal is negated */
- outnormal = -normalize(normal);
-}
-
-void mtex_mirror(vec3 tcol, vec4 refcol, float tin, float colmirfac, out vec4 outrefcol)
-{
- outrefcol = mix(refcol, vec4(1.0, tcol), tin * colmirfac);
-}
-
-void mtex_rgb_blend(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- float facm;
-
- fact *= facg;
- facm = 1.0 - fact;
-
- incol = fact * texcol + facm * outcol;
-}
-
-void mtex_rgb_mul(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- float facm;
-
- fact *= facg;
- facm = 1.0 - fact;
-
- incol = (facm + fact * texcol) * outcol;
-}
-
-void mtex_rgb_screen(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- float facm;
-
- fact *= facg;
- facm = 1.0 - fact;
-
- incol = vec3(1.0) - (vec3(facm) + fact * (vec3(1.0) - texcol)) * (vec3(1.0) - outcol);
-}
-
-void mtex_rgb_overlay(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- float facm;
-
- fact *= facg;
- facm = 1.0 - fact;
-
- if (outcol.r < 0.5)
- incol.r = outcol.r * (facm + 2.0 * fact * texcol.r);
- else
- incol.r = 1.0 - (facm + 2.0 * fact * (1.0 - texcol.r)) * (1.0 - outcol.r);
-
- if (outcol.g < 0.5)
- incol.g = outcol.g * (facm + 2.0 * fact * texcol.g);
- else
- incol.g = 1.0 - (facm + 2.0 * fact * (1.0 - texcol.g)) * (1.0 - outcol.g);
-
- if (outcol.b < 0.5)
- incol.b = outcol.b * (facm + 2.0 * fact * texcol.b);
- else
- incol.b = 1.0 - (facm + 2.0 * fact * (1.0 - texcol.b)) * (1.0 - outcol.b);
-}
-
-void mtex_rgb_sub(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- incol = -fact * facg * texcol + outcol;
-}
-
-void mtex_rgb_add(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- incol = fact * facg * texcol + outcol;
-}
-
-void mtex_rgb_div(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- float facm;
-
- fact *= facg;
- facm = 1.0 - fact;
-
- if (texcol.r != 0.0) incol.r = facm * outcol.r + fact * outcol.r / texcol.r;
- if (texcol.g != 0.0) incol.g = facm * outcol.g + fact * outcol.g / texcol.g;
- if (texcol.b != 0.0) incol.b = facm * outcol.b + fact * outcol.b / texcol.b;
-}
-
-void mtex_rgb_diff(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- float facm;
-
- fact *= facg;
- facm = 1.0 - fact;
-
- incol = facm * outcol + fact * abs(texcol - outcol);
-}
-
-void mtex_rgb_dark(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- float facm, col;
-
- fact *= facg;
- facm = 1.0 - fact;
-
- incol.r = min(outcol.r, texcol.r) * fact + outcol.r * facm;
- incol.g = min(outcol.g, texcol.g) * fact + outcol.g * facm;
- incol.b = min(outcol.b, texcol.b) * fact + outcol.b * facm;
-}
-
-void mtex_rgb_light(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- float facm, col;
-
- fact *= facg;
-
- col = fact * texcol.r;
- if (col > outcol.r) incol.r = col; else incol.r = outcol.r;
- col = fact * texcol.g;
- if (col > outcol.g) incol.g = col; else incol.g = outcol.g;
- col = fact * texcol.b;
- if (col > outcol.b) incol.b = col; else incol.b = outcol.b;
-}
-
-void mtex_rgb_hue(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- vec4 col;
-
- mix_hue(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
- incol.rgb = col.rgb;
-}
-
-void mtex_rgb_sat(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- vec4 col;
-
- mix_sat(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
- incol.rgb = col.rgb;
-}
-
-void mtex_rgb_val(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- vec4 col;
-
- mix_val(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
- incol.rgb = col.rgb;
-}
-
-void mtex_rgb_color(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- vec4 col;
-
- mix_color(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
- incol.rgb = col.rgb;
-}
-
-void mtex_rgb_soft(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- vec4 col;
-
- mix_soft(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
- incol.rgb = col.rgb;
-}
-
-void mtex_rgb_linear(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
-{
- fact *= facg;
-
- if (texcol.r > 0.5)
- incol.r = outcol.r + fact * (2.0 * (texcol.r - 0.5));
- else
- incol.r = outcol.r + fact * (2.0 * (texcol.r) - 1.0);
-
- if (texcol.g > 0.5)
- incol.g = outcol.g + fact * (2.0 * (texcol.g - 0.5));
- else
- incol.g = outcol.g + fact * (2.0 * (texcol.g) - 1.0);
-
- if (texcol.b > 0.5)
- incol.b = outcol.b + fact * (2.0 * (texcol.b - 0.5));
- else
- incol.b = outcol.b + fact * (2.0 * (texcol.b) - 1.0);
-}
-
-void mtex_value_vars(inout float fact, float facg, out float facm)
-{
- fact *= abs(facg);
- facm = 1.0 - fact;
-
- if (facg < 0.0) {
- float tmp = fact;
- fact = facm;
- facm = tmp;
- }
-}
-
-void mtex_value_blend(float outcol, float texcol, float fact, float facg, out float incol)
-{
- float facm;
- mtex_value_vars(fact, facg, facm);
-
- incol = fact * texcol + facm * outcol;
-}
-
-void mtex_value_mul(float outcol, float texcol, float fact, float facg, out float incol)
-{
- float facm;
- mtex_value_vars(fact, facg, facm);
-
- facm = 1.0 - facg;
- incol = (facm + fact * texcol) * outcol;
-}
-
-void mtex_value_screen(float outcol, float texcol, float fact, float facg, out float incol)
-{
- float facm;
- mtex_value_vars(fact, facg, facm);
-
- facm = 1.0 - facg;
- incol = 1.0 - (facm + fact * (1.0 - texcol)) * (1.0 - outcol);
-}
-
-void mtex_value_sub(float outcol, float texcol, float fact, float facg, out float incol)
-{
- float facm;
- mtex_value_vars(fact, facg, facm);
-
- fact = -fact;
- incol = fact * texcol + outcol;
-}
-
-void mtex_value_add(float outcol, float texcol, float fact, float facg, out float incol)
-{
- float facm;
- mtex_value_vars(fact, facg, facm);
-
- fact = fact;
- incol = fact * texcol + outcol;
-}
-
-void mtex_value_div(float outcol, float texcol, float fact, float facg, out float incol)
-{
- float facm;
- mtex_value_vars(fact, facg, facm);
-
- if (texcol != 0.0)
- incol = facm * outcol + fact * outcol / texcol;
- else
- incol = 0.0;
-}
-
-void mtex_value_diff(float outcol, float texcol, float fact, float facg, out float incol)
-{
- float facm;
- mtex_value_vars(fact, facg, facm);
-
- incol = facm * outcol + fact * abs(texcol - outcol);
-}
-
-void mtex_value_dark(float outcol, float texcol, float fact, float facg, out float incol)
-{
- float facm;
- mtex_value_vars(fact, facg, facm);
-
- incol = facm * outcol + fact * min(outcol, texcol);
-}
-
-void mtex_value_light(float outcol, float texcol, float fact, float facg, out float incol)
-{
- float facm;
- mtex_value_vars(fact, facg, facm);
-
- float col = fact * texcol;
- if (col > outcol) incol = col; else incol = outcol;
-}
-
-void mtex_value_clamp_positive(float fac, out float outfac)
-{
- outfac = max(fac, 0.0);
-}
-
-void mtex_value_clamp(float fac, out float outfac)
-{
- outfac = clamp(fac, 0.0, 1.0);
-}
-
-void mtex_har_divide(float har, out float outhar)
-{
- outhar = har / 128.0;
-}
-
-void mtex_har_multiply_clamp(float har, out float outhar)
-{
- outhar = clamp(har * 128.0, 1.0, 511.0);
-}
-
-void mtex_alpha_from_col(vec4 col, out float alpha)
-{
- alpha = col.a;
-}
-
-void mtex_alpha_to_col(vec4 col, float alpha, out vec4 outcol)
-{
- outcol = vec4(col.rgb, alpha);
-}
-
-void mtex_alpha_multiply_value(vec4 col, float value, out vec4 outcol)
-{
- outcol = vec4(col.rgb, col.a * value);
-}
-
-void mtex_rgbtoint(vec4 rgb, out float intensity)
-{
- intensity = dot(vec3(0.35, 0.45, 0.2), rgb.rgb);
-}
-
-void mtex_value_invert(float invalue, out float outvalue)
-{
- outvalue = 1.0 - invalue;
-}
-
-void mtex_rgb_invert(vec4 inrgb, out vec4 outrgb)
-{
- outrgb = vec4(vec3(1.0) - inrgb.rgb, inrgb.a);
-}
-
-void mtex_value_stencil(float stencil, float intensity, out float outstencil, out float outintensity)
-{
- float fact = intensity;
- outintensity = intensity * stencil;
- outstencil = stencil * fact;
-}
-
-void mtex_rgb_stencil(float stencil, vec4 rgb, out float outstencil, out vec4 outrgb)
-{
- float fact = rgb.a;
- outrgb = vec4(rgb.rgb, rgb.a * stencil);
- outstencil = stencil * fact;
-}
-
-void mtex_mapping_ofs(vec3 texco, vec3 ofs, out vec3 outtexco)
-{
- outtexco = texco + ofs;
-}
-
-void mtex_mapping_size(vec3 texco, vec3 size, out vec3 outtexco)
-{
- outtexco = size * texco;
-}
-
-void mtex_2d_mapping(vec3 vec, out vec3 outvec)
-{
- outvec = vec3(vec.xy * 0.5 + vec2(0.5), vec.z);
-}
-
vec3 mtex_2d_mapping(vec3 vec)
{
return vec3(vec.xy * 0.5 + vec2(0.5), vec.z);
}
-void mtex_cube_map(vec3 co, samplerCube ima, out float value, out vec4 color)
-{
- color = texture(ima, co);
- value = 1.0;
-}
-
-void mtex_cube_map_refl_from_refldir(
- samplerCube ima, vec3 reflecteddirection, out float value, out vec4 color)
-{
- color = texture(ima, reflecteddirection);
- value = color.a;
-}
-
-void mtex_cube_map_refl(
- samplerCube ima, vec3 vp, vec3 vn, mat4 viewmatrixinverse, mat4 viewmatrix,
- out float value, out vec4 color)
-{
- vec3 viewdirection = vec3(viewmatrixinverse * vec4(vp, 0.0));
- vec3 normaldirection = normalize(vec3(vec4(vn, 0.0) * viewmatrix));
- vec3 reflecteddirection = reflect(viewdirection, normaldirection);
- color = texture(ima, reflecteddirection);
- value = 1.0;
-}
-
-void mtex_image(vec3 texco, sampler2D ima, out float value, out vec4 color)
-{
- color = texture(ima, texco.xy);
- value = 1.0;
-}
-
-void mtex_normal(vec3 texco, sampler2D ima, out vec3 normal)
-{
- // The invert of the red channel is to make
- // the normal map compliant with the outside world.
- // It needs to be done because in Blender
- // the normal used points inward.
- // Should this ever change this negate must be removed.
- vec4 color = texture(ima, texco.xy);
- normal = 2.0 * (vec3(-color.r, color.g, color.b) - vec3(-0.5, 0.5, 0.5));
-}
-
-void mtex_bump_normals_init(vec3 vN, out vec3 vNorg, out vec3 vNacc, out float fPrevMagnitude)
-{
- vNorg = vN;
- vNacc = vN;
- fPrevMagnitude = 1.0;
-}
-
/** helper method to extract the upper left 3x3 matrix from a 4x4 matrix */
mat3 to_mat3(mat4 m4)
{
@@ -1447,978 +913,6 @@ mat3 to_mat3(mat4 m4)
return m3;
}
-void mtex_bump_init_objspace(
- vec3 surf_pos, vec3 surf_norm,
- mat4 mView, mat4 mViewInv, mat4 mObj, mat4 mObjInv,
- float fPrevMagnitude_in, vec3 vNacc_in,
- out float fPrevMagnitude_out, out vec3 vNacc_out,
- out vec3 vR1, out vec3 vR2, out float fDet)
-{
- mat3 obj2view = to_mat3(ModelViewMatrix);
- mat3 view2obj = to_mat3(ModelViewMatrixInverse);
-
- vec3 vSigmaS = view2obj * dFdx(surf_pos);
- vec3 vSigmaT = view2obj * dFdy(surf_pos);
- vec3 vN = normalize(surf_norm * obj2view);
-
- vR1 = cross(vSigmaT, vN);
- vR2 = cross(vN, vSigmaS);
- fDet = dot(vSigmaS, vR1);
-
- /* pretransform vNacc (in mtex_bump_apply) using the inverse transposed */
- vR1 = vR1 * view2obj;
- vR2 = vR2 * view2obj;
- vN = vN * view2obj;
-
- float fMagnitude = abs(fDet) * length(vN);
- vNacc_out = vNacc_in * (fMagnitude / fPrevMagnitude_in);
- fPrevMagnitude_out = fMagnitude;
-}
-
-void mtex_bump_init_texturespace(
- vec3 surf_pos, vec3 surf_norm,
- float fPrevMagnitude_in, vec3 vNacc_in,
- out float fPrevMagnitude_out, out vec3 vNacc_out,
- out vec3 vR1, out vec3 vR2, out float fDet)
-{
- vec3 vSigmaS = dFdx(surf_pos);
- vec3 vSigmaT = dFdy(surf_pos);
- vec3 vN = surf_norm; /* normalized interpolated vertex normal */
-
- vR1 = normalize(cross(vSigmaT, vN));
- vR2 = normalize(cross(vN, vSigmaS));
- fDet = sign(dot(vSigmaS, vR1));
-
- float fMagnitude = abs(fDet);
- vNacc_out = vNacc_in * (fMagnitude / fPrevMagnitude_in);
- fPrevMagnitude_out = fMagnitude;
-}
-
-void mtex_bump_init_viewspace(
- vec3 surf_pos, vec3 surf_norm,
- float fPrevMagnitude_in, vec3 vNacc_in,
- out float fPrevMagnitude_out, out vec3 vNacc_out,
- out vec3 vR1, out vec3 vR2, out float fDet)
-{
- vec3 vSigmaS = dFdx(surf_pos);
- vec3 vSigmaT = dFdy(surf_pos);
- vec3 vN = surf_norm; /* normalized interpolated vertex normal */
-
- vR1 = cross(vSigmaT, vN);
- vR2 = cross(vN, vSigmaS);
- fDet = dot(vSigmaS, vR1);
-
- float fMagnitude = abs(fDet);
- vNacc_out = vNacc_in * (fMagnitude / fPrevMagnitude_in);
- fPrevMagnitude_out = fMagnitude;
-}
-
-void mtex_bump_tap3(
- vec3 texco, sampler2D ima, float hScale,
- out float dBs, out float dBt)
-{
- vec2 STll = texco.xy;
- vec2 STlr = texco.xy + dFdx(texco.xy);
- vec2 STul = texco.xy + dFdy(texco.xy);
-
- float Hll, Hlr, Hul;
- rgbtobw(texture(ima, STll), Hll);
- rgbtobw(texture(ima, STlr), Hlr);
- rgbtobw(texture(ima, STul), Hul);
-
- dBs = hScale * (Hlr - Hll);
- dBt = hScale * (Hul - Hll);
-}
-
-#ifdef BUMP_BICUBIC
-
-void mtex_bump_bicubic(
- vec3 texco, sampler2D ima, float hScale,
- out float dBs, out float dBt )
-{
- float Hl;
- float Hr;
- float Hd;
- float Hu;
-
- vec2 TexDx = dFdx(texco.xy);
- vec2 TexDy = dFdy(texco.xy);
-
- vec2 STl = texco.xy - 0.5 * TexDx;
- vec2 STr = texco.xy + 0.5 * TexDx;
- vec2 STd = texco.xy - 0.5 * TexDy;
- vec2 STu = texco.xy + 0.5 * TexDy;
-
- rgbtobw(texture(ima, STl), Hl);
- rgbtobw(texture(ima, STr), Hr);
- rgbtobw(texture(ima, STd), Hd);
- rgbtobw(texture(ima, STu), Hu);
-
- vec2 dHdxy = vec2(Hr - Hl, Hu - Hd);
- float fBlend = clamp(1.0 - textureQueryLOD(ima, texco.xy).x, 0.0, 1.0);
- if (fBlend != 0.0) {
- // the derivative of the bicubic sampling of level 0
- ivec2 vDim;
- vDim = textureSize(ima, 0);
-
- // taking the fract part of the texture coordinate is a hardcoded wrap mode.
- // this is acceptable as textures use wrap mode exclusively in 3D view elsewhere in blender.
- // this is done so that we can still get a valid texel with uvs outside the 0,1 range
- // by texelFetch below, as coordinates are clamped when using this function.
- vec2 fTexLoc = vDim * fract(texco.xy) - vec2(0.5, 0.5);
- ivec2 iTexLoc = ivec2(floor(fTexLoc));
- vec2 t = clamp(fTexLoc - iTexLoc, 0.0, 1.0); // sat just to be pedantic
-
-/*******************************************************************************************
- * This block will replace the one below when one channel textures are properly supported. *
- *******************************************************************************************
- vec4 vSamplesUL = textureGather(ima, (iTexLoc+ivec2(-1,-1) + vec2(0.5,0.5))/vDim);
- vec4 vSamplesUR = textureGather(ima, (iTexLoc+ivec2(1,-1) + vec2(0.5,0.5))/vDim);
- vec4 vSamplesLL = textureGather(ima, (iTexLoc+ivec2(-1,1) + vec2(0.5,0.5))/vDim);
- vec4 vSamplesLR = textureGather(ima, (iTexLoc+ivec2(1,1) + vec2(0.5,0.5))/vDim);
-
- mat4 H = mat4(vSamplesUL.w, vSamplesUL.x, vSamplesLL.w, vSamplesLL.x,
- vSamplesUL.z, vSamplesUL.y, vSamplesLL.z, vSamplesLL.y,
- vSamplesUR.w, vSamplesUR.x, vSamplesLR.w, vSamplesLR.x,
- vSamplesUR.z, vSamplesUR.y, vSamplesLR.z, vSamplesLR.y);
- */
- ivec2 iTexLocMod = iTexLoc + ivec2(-1, -1);
-
- mat4 H;
-
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 4; j++) {
- ivec2 iTexTmp = iTexLocMod + ivec2(i, j);
-
- // wrap texture coordinates manually for texelFetch to work on uvs oitside the 0,1 range.
- // this is guaranteed to work since we take the fractional part of the uv above.
- iTexTmp.x = (iTexTmp.x < 0) ? iTexTmp.x + vDim.x : ((iTexTmp.x >= vDim.x) ? iTexTmp.x - vDim.x : iTexTmp.x);
- iTexTmp.y = (iTexTmp.y < 0) ? iTexTmp.y + vDim.y : ((iTexTmp.y >= vDim.y) ? iTexTmp.y - vDim.y : iTexTmp.y);
-
- rgbtobw(texelFetch(ima, iTexTmp, 0), H[i][j]);
- }
- }
-
- float x = t.x, y = t.y;
- float x2 = x * x, x3 = x2 * x, y2 = y * y, y3 = y2 * y;
-
- vec4 X = vec4(-0.5 * (x3 + x) + x2, 1.5 * x3 - 2.5 * x2 + 1, -1.5 * x3 + 2 * x2 + 0.5 * x, 0.5 * (x3 - x2));
- vec4 Y = vec4(-0.5 * (y3 + y) + y2, 1.5 * y3 - 2.5 * y2 + 1, -1.5 * y3 + 2 * y2 + 0.5 * y, 0.5 * (y3 - y2));
- vec4 dX = vec4(-1.5 * x2 + 2 * x - 0.5, 4.5 * x2 - 5 * x, -4.5 * x2 + 4 * x + 0.5, 1.5 * x2 - x);
- vec4 dY = vec4(-1.5 * y2 + 2 * y - 0.5, 4.5 * y2 - 5 * y, -4.5 * y2 + 4 * y + 0.5, 1.5 * y2 - y);
-
- // complete derivative in normalized coordinates (mul by vDim)
- vec2 dHdST = vDim * vec2(dot(Y, H * dX), dot(dY, H * X));
-
- // transform derivative to screen-space
- vec2 dHdxy_bicubic = vec2(dHdST.x * TexDx.x + dHdST.y * TexDx.y,
- dHdST.x * TexDy.x + dHdST.y * TexDy.y);
-
- // blend between the two
- dHdxy = dHdxy * (1 - fBlend) + dHdxy_bicubic * fBlend;
- }
-
- dBs = hScale * dHdxy.x;
- dBt = hScale * dHdxy.y;
-}
-
-#endif
-
-void mtex_bump_tap5(
- vec3 texco, sampler2D ima, float hScale,
- out float dBs, out float dBt)
-{
- vec2 TexDx = dFdx(texco.xy);
- vec2 TexDy = dFdy(texco.xy);
-
- vec2 STc = texco.xy;
- vec2 STl = texco.xy - 0.5 * TexDx;
- vec2 STr = texco.xy + 0.5 * TexDx;
- vec2 STd = texco.xy - 0.5 * TexDy;
- vec2 STu = texco.xy + 0.5 * TexDy;
-
- float Hc, Hl, Hr, Hd, Hu;
- rgbtobw(texture(ima, STc), Hc);
- rgbtobw(texture(ima, STl), Hl);
- rgbtobw(texture(ima, STr), Hr);
- rgbtobw(texture(ima, STd), Hd);
- rgbtobw(texture(ima, STu), Hu);
-
- dBs = hScale * (Hr - Hl);
- dBt = hScale * (Hu - Hd);
-}
-
-void mtex_bump_deriv(
- vec3 texco, sampler2D ima, float ima_x, float ima_y, float hScale,
- out float dBs, out float dBt)
-{
- float s = 1.0; // negate this if flipped texture coordinate
- vec2 TexDx = dFdx(texco.xy);
- vec2 TexDy = dFdy(texco.xy);
-
- // this variant using a derivative map is described here
- // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html
- vec2 dim = vec2(ima_x, ima_y);
- vec2 dBduv = hScale * dim * (2.0 * texture(ima, texco.xy).xy - 1.0);
-
- dBs = dBduv.x * TexDx.x + s * dBduv.y * TexDx.y;
- dBt = dBduv.x * TexDy.x + s * dBduv.y * TexDy.y;
-}
-
-void mtex_bump_apply(
- float fDet, float dBs, float dBt, vec3 vR1, vec3 vR2, vec3 vNacc_in,
- out vec3 vNacc_out, out vec3 perturbed_norm)
-{
- vec3 vSurfGrad = sign(fDet) * (dBs * vR1 + dBt * vR2);
-
- vNacc_out = vNacc_in - vSurfGrad;
- perturbed_norm = normalize(vNacc_out);
-}
-
-void mtex_bump_apply_texspace(
- float fDet, float dBs, float dBt, vec3 vR1, vec3 vR2,
- sampler2D ima, vec3 texco, float ima_x, float ima_y, vec3 vNacc_in,
- out vec3 vNacc_out, out vec3 perturbed_norm)
-{
- vec2 TexDx = dFdx(texco.xy);
- vec2 TexDy = dFdy(texco.xy);
-
- vec3 vSurfGrad = sign(fDet) * (
- dBs / length(vec2(ima_x * TexDx.x, ima_y * TexDx.y)) * vR1 +
- dBt / length(vec2(ima_x * TexDy.x, ima_y * TexDy.y)) * vR2);
-
- vNacc_out = vNacc_in - vSurfGrad;
- perturbed_norm = normalize(vNacc_out);
-}
-
-void mtex_negate_texnormal(vec3 normal, out vec3 outnormal)
-{
- outnormal = vec3(-normal.x, -normal.y, normal.z);
-}
-
-void mtex_nspace_tangent(vec4 tangent, vec3 normal, vec3 texnormal, out vec3 outnormal)
-{
- vec3 B = tangent.w * cross(normal, tangent.xyz);
-
- outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * normal;
- outnormal = normalize(outnormal);
-}
-
-void mtex_nspace_world(mat4 viewmat, vec3 texnormal, out vec3 outnormal)
-{
- outnormal = normalize((viewmat * vec4(texnormal, 0.0)).xyz);
-}
-
-void mtex_nspace_object(vec3 texnormal, out vec3 outnormal)
-{
- outnormal = normalize(NormalMatrix * texnormal);
-}
-
-void mtex_blend_normal(float norfac, vec3 normal, vec3 newnormal, out vec3 outnormal)
-{
- outnormal = (1.0 - norfac) * normal + norfac * newnormal;
- outnormal = normalize(outnormal);
-}
-
-/******* MATERIAL *********/
-
-void lamp_visibility_sun_hemi(vec3 lampvec, out vec3 lv, out float dist, out float visifac)
-{
- lv = lampvec;
- dist = 1.0;
- visifac = 1.0;
-}
-
-void lamp_visibility_other(vec3 co, vec3 lampco, out vec3 lv, out float dist, out float visifac)
-{
- lv = co - lampco;
- dist = length(lv);
- lv = normalize(lv);
- visifac = 1.0;
-}
-
-void lamp_falloff_invlinear(float lampdist, float dist, out float visifac)
-{
- visifac = lampdist / (lampdist + dist);
-}
-
-void lamp_falloff_invsquare(float lampdist, float dist, out float visifac)
-{
- visifac = lampdist / (lampdist + dist * dist);
-}
-
-void lamp_falloff_sliders(float lampdist, float ld1, float ld2, float dist, out float visifac)
-{
- float lampdistkw = lampdist * lampdist;
-
- visifac = lampdist / (lampdist + ld1 * dist);
- visifac *= lampdistkw / (lampdistkw + ld2 * dist * dist);
-}
-
-void lamp_falloff_invcoefficients(float coeff_const, float coeff_lin, float coeff_quad, float dist, out float visifac)
-{
- vec3 coeff = vec3(coeff_const, coeff_lin, coeff_quad);
- vec3 d_coeff = vec3(1.0, dist, dist * dist);
- float visifac_r = dot(coeff, d_coeff);
- if (visifac_r > 0.0)
- visifac = 1.0 / visifac_r;
- else
- visifac = 0.0;
-}
-
-void lamp_falloff_curve(float lampdist, sampler2D curvemap, float dist, out float visifac)
-{
- visifac = texture(curvemap, vec2(dist / lampdist, 0.0)).x;
-}
-
-void lamp_visibility_sphere(float lampdist, float dist, float visifac, out float outvisifac)
-{
- float t = lampdist - dist;
-
- outvisifac = visifac * max(t, 0.0) / lampdist;
-}
-
-void lamp_visibility_spot_square(vec3 lampvec, mat4 lampimat, vec2 scale, vec3 lv, out float inpr)
-{
- if (dot(lv, lampvec) > 0.0) {
- vec3 lvrot = (lampimat * vec4(lv, 0.0)).xyz;
- /* without clever non-uniform scale, we could do: */
- // float x = max(abs(lvrot.x / lvrot.z), abs(lvrot.y / lvrot.z));
- float x = max(abs((lvrot.x / scale.x) / lvrot.z), abs((lvrot.y / scale.y) / lvrot.z));
-
- inpr = 1.0 / sqrt(1.0 + x * x);
- }
- else
- inpr = 0.0;
-}
-
-void lamp_visibility_spot_circle(vec3 lampvec, mat4 lampimat, vec2 scale, vec3 lv, out float inpr)
-{
- /* without clever non-uniform scale, we could do: */
- // inpr = dot(lv, lampvec);
- if (dot(lv, lampvec) > 0.0) {
- vec3 lvrot = (lampimat * vec4(lv, 0.0)).xyz;
- float x = abs(lvrot.x / lvrot.z);
- float y = abs(lvrot.y / lvrot.z);
-
- float ellipse = abs((x * x) / (scale.x * scale.x) + (y * y) / (scale.y * scale.y));
-
- inpr = 1.0 / sqrt(1.0 + ellipse);
- }
- else
- inpr = 0.0;
-}
-
-void lamp_visibility_spot(float spotsi, float spotbl, float inpr, float visifac, out float outvisifac)
-{
- float t = spotsi;
-
- if (inpr <= t) {
- outvisifac = 0.0;
- }
- else {
- t = inpr - t;
-
- /* soft area */
- if (spotbl != 0.0)
- inpr *= smoothstep(0.0, 1.0, t / spotbl);
-
- outvisifac = visifac * inpr;
- }
-}
-
-void lamp_visibility_clamp(float visifac, out float outvisifac)
-{
- outvisifac = (visifac < 0.001) ? 0.0 : visifac;
-}
-
-void world_paper_view(vec3 vec, out vec3 outvec)
-{
- vec3 nvec = normalize(vec);
- outvec = (ProjectionMatrix[3][3] == 0.0) ? vec3(nvec.x, 0.0, nvec.y) : vec3(0.0, 0.0, -1.0);
-}
-
-void world_zen_mapping(vec3 view, float zenup, float zendown, out float zenfac)
-{
- if (view.z >= 0.0)
- zenfac = zenup;
- else
- zenfac = zendown;
-}
-
-void world_blend_paper_real(vec3 vec, out float blend)
-{
- blend = abs(vec.y);
-}
-
-void world_blend_paper(vec3 vec, out float blend)
-{
- blend = (vec.y + 1.0) * 0.5;
-}
-
-void world_blend_real(vec3 vec, out float blend)
-{
- blend = abs(normalize(vec).z);
-}
-
-void world_blend(vec3 vec, out float blend)
-{
- blend = (normalize(vec).z + 1) * 0.5;
-}
-
-void shade_view(vec3 co, out vec3 view)
-{
- /* handle perspective/orthographic */
- view = (ProjectionMatrix[3][3] == 0.0) ? normalize(co) : vec3(0.0, 0.0, -1.0);
-}
-
-void shade_tangent_v(vec3 lv, vec3 tang, out vec3 vn)
-{
- vec3 c = cross(lv, tang);
- vec3 vnor = cross(c, tang);
-
- vn = -normalize(vnor);
-}
-
-void shade_inp(vec3 vn, vec3 lv, out float inp)
-{
- inp = dot(vn, lv);
-}
-
-void shade_is_no_diffuse(out float is)
-{
- is = 0.0;
-}
-
-void shade_is_hemi(float inp, out float is)
-{
- is = 0.5 * inp + 0.5;
-}
-
-float area_lamp_energy(mat4 area, vec3 co, vec3 vn)
-{
- vec3 vec[4], c[4];
- float rad[4], fac;
-
- vec[0] = normalize(co - area[0].xyz);
- vec[1] = normalize(co - area[1].xyz);
- vec[2] = normalize(co - area[2].xyz);
- vec[3] = normalize(co - area[3].xyz);
-
- c[0] = normalize(cross(vec[0], vec[1]));
- c[1] = normalize(cross(vec[1], vec[2]));
- c[2] = normalize(cross(vec[2], vec[3]));
- c[3] = normalize(cross(vec[3], vec[0]));
-
- rad[0] = acos(dot(vec[0], vec[1]));
- rad[1] = acos(dot(vec[1], vec[2]));
- rad[2] = acos(dot(vec[2], vec[3]));
- rad[3] = acos(dot(vec[3], vec[0]));
-
- fac = rad[0] * dot(vn, c[0]);
- fac += rad[1] * dot(vn, c[1]);
- fac += rad[2] * dot(vn, c[2]);
- fac += rad[3] * dot(vn, c[3]);
-
- return max(fac, 0.0);
-}
-
-void shade_inp_area(
- vec3 position, vec3 lampco, vec3 lampvec, vec3 vn, mat4 area, float areasize, float k,
- out float inp)
-{
- vec3 co = position;
- vec3 vec = co - lampco;
-
- if (dot(vec, lampvec) < 0.0) {
- inp = 0.0;
- }
- else {
- float intens = area_lamp_energy(area, co, vn);
-
- inp = pow(intens * areasize, k);
- }
-}
-
-void shade_diffuse_oren_nayer(float nl, vec3 n, vec3 l, vec3 v, float rough, out float is)
-{
- vec3 h = normalize(v + l);
- float nh = max(dot(n, h), 0.0);
- float nv = max(dot(n, v), 0.0);
- float realnl = dot(n, l);
-
- if (realnl < 0.0) {
- is = 0.0;
- }
- else if (nl < 0.0) {
- is = 0.0;
- }
- else {
- float vh = max(dot(v, h), 0.0);
- float Lit_A = acos(realnl);
- float View_A = acos(nv);
-
- vec3 Lit_B = normalize(l - realnl * n);
- vec3 View_B = normalize(v - nv * n);
-
- float t = max(dot(Lit_B, View_B), 0.0);
-
- float a, b;
-
- if (Lit_A > View_A) {
- a = Lit_A;
- b = View_A;
- }
- else {
- a = View_A;
- b = Lit_A;
- }
-
- float A = 1.0 - (0.5 * ((rough * rough) / ((rough * rough) + 0.33)));
- float B = 0.45 * ((rough * rough) / ((rough * rough) + 0.09));
-
- b *= 0.95;
- is = nl * (A + (B * t * sin(a) * tan(b)));
- }
-}
-
-void shade_diffuse_toon(vec3 n, vec3 l, vec3 v, float size, float tsmooth, out float is)
-{
- float rslt = dot(n, l);
- float ang = acos(rslt);
-
- if (ang < size) is = 1.0;
- else if (ang > (size + tsmooth) || tsmooth == 0.0) is = 0.0;
- else is = 1.0 - ((ang - size) / tsmooth);
-}
-
-void shade_diffuse_minnaert(float nl, vec3 n, vec3 v, float darkness, out float is)
-{
- if (nl <= 0.0) {
- is = 0.0;
- }
- else {
- float nv = max(dot(n, v), 0.0);
-
- if (darkness <= 1.0)
- is = nl * pow(max(nv * nl, 0.1), darkness - 1.0);
- else
- is = nl * pow(1.0001 - nv, darkness - 1.0);
- }
-}
-
-float fresnel_fac(vec3 view, vec3 vn, float grad, float fac)
-{
- float t1, t2;
- float ffac;
-
- if (fac == 0.0) {
- ffac = 1.0;
- }
- else {
- t1 = dot(view, vn);
- if (t1 > 0.0) t2 = 1.0 + t1;
- else t2 = 1.0 - t1;
-
- t2 = grad + (1.0 - grad) * pow(t2, fac);
-
- if (t2 < 0.0) ffac = 0.0;
- else if (t2 > 1.0) ffac = 1.0;
- else ffac = t2;
- }
-
- return ffac;
-}
-
-void shade_diffuse_fresnel(vec3 vn, vec3 lv, vec3 view, float fac_i, float fac, out float is)
-{
- is = fresnel_fac(lv, vn, fac_i, fac);
-}
-
-void shade_cubic(float is, out float outis)
-{
- if (is > 0.0 && is < 1.0)
- outis = smoothstep(0.0, 1.0, is);
- else
- outis = is;
-}
-
-void shade_visifac(float i, float visifac, float refl, out float outi)
-{
- /*if (i > 0.0)*/
- outi = max(i * visifac * refl, 0.0);
- /*else
- outi = i;*/
-}
-
-void shade_tangent_v_spec(vec3 tang, out vec3 vn)
-{
- vn = tang;
-}
-
-void shade_add_to_diffuse(float i, vec3 lampcol, vec3 col, out vec3 outcol)
-{
- if (i > 0.0)
- outcol = i * lampcol * col;
- else
- outcol = vec3(0.0);
-}
-
-void shade_hemi_spec(vec3 vn, vec3 lv, vec3 view, float spec, float hard, float visifac, out float t)
-{
- lv += view;
- lv = normalize(lv);
-
- t = dot(vn, lv);
- t = 0.5 * t + 0.5;
-
- t = visifac * spec * pow(t, hard);
-}
-
-void shade_phong_spec(vec3 n, vec3 l, vec3 v, float hard, out float specfac)
-{
- vec3 h = normalize(l + v);
- float rslt = max(dot(h, n), 0.0);
-
- specfac = pow(rslt, hard);
-}
-
-void shade_cooktorr_spec(vec3 n, vec3 l, vec3 v, float hard, out float specfac)
-{
- vec3 h = normalize(v + l);
- float nh = dot(n, h);
-
- if (nh < 0.0) {
- specfac = 0.0;
- }
- else {
- float nv = max(dot(n, v), 0.0);
- float i = pow(nh, hard);
-
- i = i / (0.1 + nv);
- specfac = i;
- }
-}
-
-void shade_blinn_spec(vec3 n, vec3 l, vec3 v, float refrac, float spec_power, out float specfac)
-{
- if (refrac < 1.0) {
- specfac = 0.0;
- }
- else if (spec_power == 0.0) {
- specfac = 0.0;
- }
- else {
- if (spec_power < 100.0)
- spec_power = sqrt(1.0 / spec_power);
- else
- spec_power = 10.0 / spec_power;
-
- vec3 h = normalize(v + l);
- float nh = dot(n, h);
- if (nh < 0.0) {
- specfac = 0.0;
- }
- else {
- float nv = max(dot(n, v), 0.01);
- float nl = dot(n, l);
- if (nl <= 0.01) {
- specfac = 0.0;
- }
- else {
- float vh = max(dot(v, h), 0.01);
-
- float a = 1.0;
- float b = (2.0 * nh * nv) / vh;
- float c = (2.0 * nh * nl) / vh;
-
- float g = 0.0;
-
- if (a < b && a < c) g = a;
- else if (b < a && b < c) g = b;
- else if (c < a && c < b) g = c;
-
- float p = sqrt(((refrac * refrac) + (vh * vh) - 1.0));
- float f = ((((p - vh) * (p - vh)) / ((p + vh) * (p + vh))) *
- (1.0 + ((((vh * (p + vh)) - 1.0) * ((vh * (p + vh)) - 1.0)) /
- (((vh * (p - vh)) + 1.0) * ((vh * (p - vh)) + 1.0)))));
- float ang = acos(nh);
-
- specfac = max(f * g * exp_blender((-(ang * ang) / (2.0 * spec_power * spec_power))), 0.0);
- }
- }
- }
-}
-
-void shade_wardiso_spec(vec3 n, vec3 l, vec3 v, float rms, out float specfac)
-{
- vec3 h = normalize(l + v);
- float nh = max(dot(n, h), 0.001);
- float nv = max(dot(n, v), 0.001);
- float nl = max(dot(n, l), 0.001);
- float angle = tan(acos(nh));
- float alpha = max(rms, 0.001);
-
- specfac = nl * (1.0 / (4.0 * M_PI * alpha * alpha)) * (exp_blender(-(angle * angle) / (alpha * alpha)) / (sqrt(nv * nl)));
-}
-
-void shade_toon_spec(vec3 n, vec3 l, vec3 v, float size, float tsmooth, out float specfac)
-{
- vec3 h = normalize(l + v);
- float rslt = dot(h, n);
- float ang = acos(rslt);
-
- if (ang < size) rslt = 1.0;
- else if (ang >= (size + tsmooth) || tsmooth == 0.0) rslt = 0.0;
- else rslt = 1.0 - ((ang - size) / tsmooth);
-
- specfac = rslt;
-}
-
-void shade_spec_area_inp(float specfac, float inp, out float outspecfac)
-{
- outspecfac = specfac * inp;
-}
-
-void shade_spec_t(float shadfac, float spec, float visifac, float specfac, out float t)
-{
- t = shadfac * spec * visifac * specfac;
-}
-
-void shade_add_spec(float t, vec3 lampcol, vec3 speccol, out vec3 outcol)
-{
- outcol = t * lampcol * speccol;
-}
-
-void shade_add_mirror(vec3 mir, vec4 refcol, vec3 combined, out vec3 result)
-{
- result = mir * refcol.gba + (vec3(1.0) - mir * refcol.rrr) * combined;
-}
-
-void alpha_spec_correction(vec3 spec, float spectra, float alpha, out float outalpha)
-{
- if (spectra > 0.0) {
- float t = clamp(max(max(spec.r, spec.g), spec.b) * spectra, 0.0, 1.0);
- outalpha = (1.0 - t) * alpha + t;
- }
- else {
- outalpha = alpha;
- }
-}
-
-void shade_add(vec4 col1, vec4 col2, out vec4 outcol)
-{
- outcol = col1 + col2;
-}
-
-void shade_madd(vec4 col, vec4 col1, vec4 col2, out vec4 outcol)
-{
- outcol = col + col1 * col2;
-}
-
-void shade_add_clamped(vec4 col1, vec4 col2, out vec4 outcol)
-{
- outcol = col1 + max(col2, vec4(0.0));
-}
-
-void shade_madd_clamped(vec4 col, vec4 col1, vec4 col2, out vec4 outcol)
-{
- outcol = col + max(col1 * col2, vec4(0.0));
-}
-
-void env_apply(vec4 col, vec3 hor, vec3 zen, vec4 f, mat4 vm, vec3 vn, out vec4 outcol)
-{
- vec3 vv = normalize(vm[2].xyz);
- float skyfac = 0.5 * (1.0 + dot(vn, -vv));
- outcol = col + f * vec4(mix(hor, zen, skyfac), 0);
-}
-
-void shade_maddf(vec4 col, float f, vec4 col1, out vec4 outcol)
-{
- outcol = col + f * col1;
-}
-
-void shade_mul(vec4 col1, vec4 col2, out vec4 outcol)
-{
- outcol = col1 * col2;
-}
-
-void shade_mul_value(float fac, vec4 col, out vec4 outcol)
-{
- outcol = col * fac;
-}
-
-void shade_mul_value_v3(float fac, vec3 col, out vec3 outcol)
-{
- outcol = col * fac;
-}
-
-void shade_obcolor(vec4 col, vec4 obcol, out vec4 outcol)
-{
- outcol = vec4(col.rgb * obcol.rgb, col.a);
-}
-
-void ramp_rgbtobw(vec3 color, out float outval)
-{
- outval = dot(color, vec3(0.3, 0.58, 0.12));
-}
-
-void shade_only_shadow(float i, float shadfac, float energy, vec3 shadcol, out vec3 outshadrgb)
-{
- outshadrgb = i * energy * (1.0 - shadfac) * (vec3(1.0) - shadcol);
-}
-
-void shade_only_shadow_diffuse(vec3 shadrgb, vec3 rgb, vec4 diff, out vec4 outdiff)
-{
- outdiff = diff - vec4(rgb * shadrgb, 0.0);
-}
-
-void shade_only_shadow_specular(vec3 shadrgb, vec3 specrgb, vec4 spec, out vec4 outspec)
-{
- outspec = spec - vec4(specrgb * shadrgb, 0.0);
-}
-
-void shade_clamp_positive(vec4 col, out vec4 outcol)
-{
- outcol = max(col, vec4(0.0));
-}
-
-void test_shadowbuf(
- vec3 rco, sampler2DShadow shadowmap, mat4 shadowpersmat, float shadowbias, float inp,
- out float result)
-{
- if (inp <= 0.0) {
- result = 0.0;
- }
- else {
- vec4 co = shadowpersmat * vec4(rco, 1.0);
-
- //float bias = (1.5 - inp*inp)*shadowbias;
- co.z -= shadowbias * co.w;
-
- if (co.w > 0.0 && co.x > 0.0 && co.x / co.w < 1.0 && co.y > 0.0 && co.y / co.w < 1.0) {
- result = textureProj(shadowmap, co);
- }
- else {
- result = 1.0;
- }
- }
-}
-
-void test_shadowbuf_vsm(
- vec3 rco, sampler2D shadowmap, mat4 shadowpersmat, float shadowbias, float bleedbias, float inp,
- out float result)
-{
- if (inp <= 0.0) {
- result = 0.0;
- }
- else {
- vec4 co = shadowpersmat * vec4(rco, 1.0);
- if (co.w > 0.0 && co.x > 0.0 && co.x / co.w < 1.0 && co.y > 0.0 && co.y / co.w < 1.0) {
- vec2 moments = textureProj(shadowmap, co).rg;
- float dist = co.z / co.w;
- float p = 0.0;
-
- if (dist <= moments.x)
- p = 1.0;
-
- float variance = moments.y - (moments.x * moments.x);
- variance = max(variance, shadowbias / 10.0);
-
- float d = moments.x - dist;
- float p_max = variance / (variance + d * d);
-
- // Now reduce light-bleeding by removing the [0, x] tail and linearly rescaling (x, 1]
- p_max = clamp((p_max - bleedbias) / (1.0 - bleedbias), 0.0, 1.0);
-
- result = max(p, p_max);
- }
- else {
- result = 1.0;
- }
- }
-}
-
-void shadows_only(
- vec3 rco, sampler2DShadow shadowmap, mat4 shadowpersmat,
- float shadowbias, vec3 shadowcolor, float inp,
- out vec3 result)
-{
- result = vec3(1.0);
-
- if (inp > 0.0) {
- float shadfac;
-
- test_shadowbuf(rco, shadowmap, shadowpersmat, shadowbias, inp, shadfac);
- result -= (1.0 - shadfac) * (vec3(1.0) - shadowcolor);
- }
-}
-
-void shadows_only_vsm(
- vec3 rco, sampler2D shadowmap, mat4 shadowpersmat,
- float shadowbias, float bleedbias, vec3 shadowcolor, float inp,
- out vec3 result)
-{
- result = vec3(1.0);
-
- if (inp > 0.0) {
- float shadfac;
-
- test_shadowbuf_vsm(rco, shadowmap, shadowpersmat, shadowbias, bleedbias, inp, shadfac);
- result -= (1.0 - shadfac) * (vec3(1.0) - shadowcolor);
- }
-}
-
-void shade_light_texture(vec3 rco, sampler2D cookie, mat4 shadowpersmat, out vec4 result)
-{
-
- vec4 co = shadowpersmat * vec4(rco, 1.0);
-
- result = textureProj(cookie, co);
-}
-
-void shade_exposure_correct(vec3 col, float linfac, float logfac, out vec3 outcol)
-{
- outcol = linfac * (1.0 - exp(col * logfac));
-}
-
-void shade_mist_factor(
- vec3 co, float enable, float miststa, float mistdist, float misttype, float misi,
- out float outfac)
-{
- if (enable == 1.0) {
- float fac, zcor;
-
- zcor = (ProjectionMatrix[3][3] == 0.0) ? length(co) : -co[2];
-
- fac = clamp((zcor - miststa) / mistdist, 0.0, 1.0);
- if (misttype == 0.0) fac *= fac;
- else if (misttype == 1.0) ;
- else fac = sqrt(fac);
-
- outfac = 1.0 - (1.0 - fac) * (1.0 - misi);
- }
- else {
- outfac = 0.0;
- }
-}
-
-void shade_world_mix(vec3 hor, vec4 col, out vec4 outcol)
-{
- float fac = clamp(col.a, 0.0, 1.0);
- outcol = vec4(mix(hor, col.rgb, fac), col.a);
-}
-
-void shade_alpha_opaque(vec4 col, out vec4 outcol)
-{
- outcol = vec4(col.rgb, 1.0);
-}
-
-void shade_alpha_obcolor(vec4 col, vec4 obcol, out vec4 outcol)
-{
- outcol = vec4(col.rgb, col.a * obcol.a);
-}
-
/*********** NEW SHADER UTILITIES **************/
float fresnel_dielectric_0(float eta)
@@ -2555,83 +1049,7 @@ float floorfrac(float x, out int i)
return x - i;
}
-
-/* Principled BSDF operations */
-
-float sqr(float a)
-{
- return a*a;
-}
-
-float schlick_fresnel(float u)
-{
- float m = clamp(1.0 - u, 0.0, 1.0);
- float m2 = m * m;
- return m2 * m2 * m; // pow(m,5)
-}
-
-float GTR1(float NdotH, float a)
-{
- if (a >= 1.0) {
- return M_1_PI;
- }
-
- a = max(a, 0.001);
- float a2 = a*a;
- float t = 1.0 + (a2 - 1.0) * NdotH*NdotH;
- return (a2 - 1.0) / (M_PI * log(a2) * t);
-}
-
-float GTR2(float NdotH, float a)
-{
- float a2 = a*a;
- float t = 1.0 + (a2 - 1.0) * NdotH*NdotH;
- return a2 / (M_PI * t*t);
-}
-
-float GTR2_aniso(float NdotH, float HdotX, float HdotY, float ax, float ay)
-{
- return 1.0 / (M_PI * ax*ay * sqr(sqr(HdotX / ax) + sqr(HdotY / ay) + NdotH*NdotH));
-}
-
-float smithG_GGX(float NdotV, float alphaG)
-{
- float a = alphaG*alphaG;
- float b = NdotV*NdotV;
- return 1.0 / (NdotV + sqrt(a + b - a * b));
-}
-
-vec3 rotate_vector(vec3 p, vec3 n, float theta) {
- return (
- p * cos(theta) + cross(n, p) *
- sin(theta) + n * dot(p, n) *
- (1.0 - cos(theta))
- );
-}
-
-void prepare_tangent(
- float anisotropic, float anisotropic_rotation, float roughness, vec3 N, vec3 T,
- out vec3 X, out vec3 Y, out float ax, out float ay)
-{
- /* rotate tangent */
- if (anisotropic_rotation != 0.0) {
- T = rotate_vector(T, N, anisotropic_rotation * 2.0 * M_PI);
- }
-
- Y = normalize(cross(T, N));
-
- float aspect = sqrt(1.0 - anisotropic * 0.9);
- float a = sqr(roughness);
- ax = max(0.001, a / aspect);
- ay = max(0.001, a * aspect);
-}
-
-void convert_metallic_to_specular(vec3 basecol, float metallic, float specular_fac, out vec3 diffuse, out vec3 f0)
-{
- vec3 dielectric = vec3(0.034) * specular_fac * 2.0;
- diffuse = mix(basecol, vec3(0.0), metallic);
- f0 = mix(dielectric, basecol, metallic);
-}
+/* bsdfs */
void convert_metallic_to_specular_tinted(
vec3 basecol, float metallic, float specular_fac, float specular_tint,
@@ -2644,51 +1062,18 @@ void convert_metallic_to_specular_tinted(
diffuse = mix(basecol, vec3(0.0), metallic);
}
-/*********** NEW SHADER NODES ***************/
-
-#define NUM_LIGHTS 3
-
-struct glLight {
- vec4 position;
- vec4 diffuse;
- vec4 specular;
- vec4 halfVector;
-};
-
-layout(std140) uniform lightSource {
- glLight glLightSource[NUM_LIGHTS];
-};
-
#ifndef VOLUMETRICS
-/* bsdfs */
void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out Closure result)
{
-#ifdef EEVEE_ENGINE
vec3 vN = normalize(mat3(ViewMatrix) * N);
result = CLOSURE_DEFAULT;
result.ssr_normal = normal_encode(vN, viewCameraVec);
eevee_closure_diffuse(N, color.rgb, 1.0, result.radiance);
result.radiance *= color.rgb;
-#else
- /* ambient light */
- vec3 L = vec3(0.2);
-
- /* directional lights */
- for (int i = 0; i < NUM_LIGHTS; i++) {
- vec3 light_position = glLightSource[i].position.xyz;
- vec3 light_diffuse = glLightSource[i].diffuse.rgb;
-
- float bsdf = max(dot(N, light_position), 0.0);
- L += light_diffuse * bsdf;
- }
-
- result = Closure(L * color.rgb, 1.0);
-#endif
}
void node_bsdf_glossy(vec4 color, float roughness, vec3 N, float ssr_id, out Closure result)
{
-#ifdef EEVEE_ENGINE
vec3 out_spec, ssr_spec;
eevee_closure_glossy(N, vec3(1.0), int(ssr_id), roughness, 1.0, out_spec, ssr_spec);
vec3 vN = normalize(mat3(ViewMatrix) * N);
@@ -2697,28 +1082,6 @@ void node_bsdf_glossy(vec4 color, float roughness, vec3 N, float ssr_id, out Clo
result.ssr_data = vec4(ssr_spec * color.rgb, roughness);
result.ssr_normal = normal_encode(vN, viewCameraVec);
result.ssr_id = int(ssr_id);
-#else
- /* ambient light */
- vec3 L = vec3(0.2);
-
- direction_transform_m4v3(N, ViewMatrix, N);
-
- /* directional lights */
- for (int i = 0; i < NUM_LIGHTS; i++) {
- vec3 light_position = glLightSource[i].position.xyz;
- vec3 H = glLightSource[i].halfVector.xyz;
- vec3 light_diffuse = glLightSource[i].diffuse.rgb;
- vec3 light_specular = glLightSource[i].specular.rgb;
-
- /* we mix in some diffuse so low roughness still shows up */
- float r2 = roughness * roughness;
- float bsdf = 0.5 * pow(max(dot(N, H), 0.0), 1.0 / r2);
- bsdf += 0.5 * max(dot(N, light_position), 0.0);
- L += light_specular * bsdf;
- }
-
- result = Closure(L * color.rgb, 1.0);
-#endif
}
void node_bsdf_anisotropic(
@@ -2730,7 +1093,6 @@ void node_bsdf_anisotropic(
void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, float ssr_id, out Closure result)
{
-#ifdef EEVEE_ENGINE
vec3 out_spec, out_refr, ssr_spec;
vec3 refr_color = (refractionDepth > 0.0) ? color.rgb * color.rgb : color.rgb; /* Simulate 2 transmission event */
eevee_closure_glass(N, vec3(1.0), int(ssr_id), roughness, 1.0, ior, out_spec, out_refr, ssr_spec);
@@ -2743,9 +1105,6 @@ void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, float ssr_i
result.ssr_data = vec4(ssr_spec * color.rgb * fresnel, roughness);
result.ssr_normal = normal_encode(vN, viewCameraVec);
result.ssr_id = int(ssr_id);
-#else
- node_bsdf_diffuse(color, 0.0, N, result);
-#endif
}
void node_bsdf_toon(vec4 color, float size, float tsmooth, vec3 N, out Closure result)
@@ -2753,112 +1112,11 @@ void node_bsdf_toon(vec4 color, float size, float tsmooth, vec3 N, out Closure r
node_bsdf_diffuse(color, 0.0, N, result);
}
-#ifndef EEVEE_ENGINE
-void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_radius, vec4 subsurface_color, float metallic, float specular,
- float specular_tint, float roughness, float anisotropic, float anisotropic_rotation, float sheen, float sheen_tint, float clearcoat,
- float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, out Closure result)
-{
- vec3 X, Y;
- float ax, ay;
- prepare_tangent(anisotropic, anisotropic_rotation, roughness, N, T, X, Y, ax, ay);
-
- /* ambient light */
- // TODO: set ambient light to an appropriate value
- vec3 L = mix(0.1, 0.03, metallic) * mix(base_color.rgb, subsurface_color.rgb, subsurface * (1.0 - metallic));
-
- float eta = (2.0 / (1.0 - sqrt(0.08 * specular))) - 1.0;
-
- /* set the viewing vector */
- vec3 V = (ProjectionMatrix[3][3] == 0.0) ? -normalize(I) : vec3(0.0, 0.0, 1.0);
-
- /* fresnel normalization parameters */
- float F0 = fresnel_dielectric_0(eta);
- float F0_norm = 1.0 / (1.0 - F0);
-
- /* directional lights */
- for (int i = 0; i < NUM_LIGHTS; i++) {
- vec3 light_position_world = glLightSource[i].position.xyz;
- vec3 light_position = normalize(light_position_world);
-
- vec3 H = normalize(light_position + V);
-
- vec3 light_diffuse = glLightSource[i].diffuse.rgb;
- vec3 light_specular = glLightSource[i].specular.rgb;
-
- float NdotL = dot(N, light_position);
- float NdotV = dot(N, V);
- float LdotH = dot(light_position, H);
-
- vec3 diffuse_and_specular_bsdf = vec3(0.0);
- if (NdotL >= 0.0 && NdotV >= 0.0) {
- float NdotH = dot(N, H);
-
- float Cdlum = dot(base_color.rgb, vec3(0.3, 0.6, 0.1)); // luminance approx.
-
- vec3 Ctint = Cdlum > 0 ? base_color.rgb / Cdlum : vec3(1.0); // normalize lum. to isolate hue+sat
- vec3 Cspec0 = mix(specular * 0.08 * mix(vec3(1.0), Ctint, specular_tint), base_color.rgb, metallic);
- vec3 Csheen = mix(vec3(1.0), Ctint, sheen_tint);
-
- // Diffuse fresnel - go from 1 at normal incidence to .5 at grazing
- // and mix in diffuse retro-reflection based on roughness
-
- float FL = schlick_fresnel(NdotL), FV = schlick_fresnel(NdotV);
- float Fd90 = 0.5 + 2.0 * LdotH*LdotH * roughness;
- float Fd = mix(1.0, Fd90, FL) * mix(1.0, Fd90, FV);
-
- // Based on Hanrahan-Krueger brdf approximation of isotropic bssrdf
- // 1.25 scale is used to (roughly) preserve albedo
- // Fss90 used to "flatten" retroreflection based on roughness
- float Fss90 = LdotH*LdotH * roughness;
- float Fss = mix(1.0, Fss90, FL) * mix(1.0, Fss90, FV);
- float ss = 1.25 * (Fss * (1.0 / (NdotL + NdotV) - 0.5) + 0.5);
-
- // specular
- float Ds = GTR2_aniso(NdotH, dot(H, X), dot(H, Y), ax, ay); //GTR2(NdotH, a);
- float FH = (fresnel_dielectric_cos(LdotH, eta) - F0) * F0_norm;
- vec3 Fs = mix(Cspec0, vec3(1.0), FH);
- float roughg = sqr(roughness * 0.5 + 0.5);
- float Gs = smithG_GGX(NdotL, roughg) * smithG_GGX(NdotV, roughg);
-
- // sheen
- vec3 Fsheen = schlick_fresnel(LdotH) * sheen * Csheen;
-
- vec3 diffuse_bsdf = (mix(Fd * base_color.rgb, ss * subsurface_color.rgb, subsurface) + Fsheen) * light_diffuse;
- vec3 specular_bsdf = Gs * Fs * Ds * light_specular;
- diffuse_and_specular_bsdf = diffuse_bsdf * (1.0 - metallic) + specular_bsdf;
- }
- diffuse_and_specular_bsdf *= max(NdotL, 0.0);
-
- float CNdotL = dot(CN, light_position);
- float CNdotV = dot(CN, V);
-
- vec3 clearcoat_bsdf = vec3(0.0);
- if (CNdotL >= 0.0 && CNdotV >= 0.0 && clearcoat > 0.0) {
- float CNdotH = dot(CN, H);
- //float FH = schlick_fresnel(LdotH);
-
- // clearcoat (ior = 1.5 -> F0 = 0.04)
- float Dr = GTR1(CNdotH, sqr(clearcoat_roughness));
- float Fr = fresnel_dielectric_cos(LdotH, 1.5); //mix(0.04, 1.0, FH);
- float Gr = smithG_GGX(CNdotL, 0.25) * smithG_GGX(CNdotV, 0.25);
-
- clearcoat_bsdf = clearcoat * Gr * Fr * Dr * vec3(0.25) * light_specular;
- }
- clearcoat_bsdf *= max(CNdotL, 0.0);
-
- L += diffuse_and_specular_bsdf + clearcoat_bsdf;
- }
-
- result = Closure(L, 1.0);
-}
-#endif
-
void node_bsdf_principled_clearcoat(vec4 base_color, float subsurface, vec3 subsurface_radius, vec4 subsurface_color, float metallic, float specular,
float specular_tint, float roughness, float anisotropic, float anisotropic_rotation, float sheen, float sheen_tint, float clearcoat,
float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, float ssr_id,
float sss_id, vec3 sss_scale, out Closure result)
{
-#ifdef EEVEE_ENGINE
metallic = saturate(metallic);
transmission = saturate(transmission);
@@ -2910,12 +1168,6 @@ void node_bsdf_principled_clearcoat(vec4 base_color, float subsurface, vec3 subs
#endif
result.sss_data.rgb *= (1.0 - transmission);
#endif
-
-#else
- node_bsdf_principled(base_color, subsurface, subsurface_radius, subsurface_color, metallic, specular,
- specular_tint, roughness, anisotropic, anisotropic_rotation, sheen, sheen_tint, clearcoat,
- clearcoat_roughness, ior, transmission, transmission_roughness, N, CN, T, I, result);
-#endif
}
void node_bsdf_translucent(vec4 color, vec3 N, out Closure result)
@@ -2929,9 +1181,7 @@ void node_bsdf_transparent(vec4 color, out Closure result)
result = CLOSURE_DEFAULT;
result.radiance = vec3(0.0);
result.opacity = 0.0;
-#ifdef EEVEE_ENGINE
result.ssr_id = TRANSPARENT_CLOSURE_FLAG;
-#endif
}
void node_bsdf_velvet(vec4 color, float sigma, vec3 N, out Closure result)
@@ -2943,7 +1193,7 @@ void node_subsurface_scattering(
vec4 color, float scale, vec3 radius, float sharpen, float texture_blur, vec3 N, float sss_id,
out Closure result)
{
-#if defined(EEVEE_ENGINE) && defined(USE_SSS)
+#if defined(USE_SSS)
vec3 out_diff, out_trans;
vec3 vN = normalize(mat3(ViewMatrix) * N);
result = CLOSURE_DEFAULT;
@@ -2967,7 +1217,6 @@ void node_subsurface_scattering(
void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Closure result)
{
-#ifdef EEVEE_ENGINE
vec3 out_refr;
color.rgb *= (refractionDepth > 0.0) ? color.rgb : vec3(1.0); /* Simulate 2 absorption event. */
eevee_closure_refraction(N, roughness, ior, out_refr);
@@ -2976,23 +1225,7 @@ void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Cl
result.ssr_normal = normal_encode(vN, viewCameraVec);
result.radiance = out_refr * color.rgb;
result.ssr_id = REFRACT_CLOSURE_FLAG;
-#else
- node_bsdf_diffuse(color, 0.0, N, result);
-#endif /* EEVEE_ENGINE */
-}
-
-/* Unsupported for now */
-#ifndef EEVEE_ENGINE
-void node_bsdf_hair(vec4 color, float offset, float roughnessu, float roughnessv, vec3 tangent, out Closure result)
-{
- result = Closure(color.rgb, color.a);
-}
-
-void node_ambient_occlusion(vec4 color, out Closure result)
-{
- result = Closure(color.rgb, color.a);
}
-#endif /* EEVEE_ENGINE */
#endif /* VOLUMETRICS */
@@ -3002,15 +1235,11 @@ void node_emission(vec4 color, float strength, vec3 vN, out Closure result)
{
#ifndef VOLUMETRICS
color *= strength;
-#ifdef EEVEE_ENGINE
result = CLOSURE_DEFAULT;
result.radiance = color.rgb;
result.opacity = color.a;
result.ssr_normal = normal_encode(vN, viewCameraVec);
#else
- result = Closure(color.rgb, color.a);
-#endif
-#else
result = Closure(vec3(0.0), vec3(0.0), color.rgb * strength, 0.0);
#endif
}
@@ -3034,14 +1263,10 @@ void node_background(vec4 color, float strength, out Closure result)
{
#ifndef VOLUMETRICS
color *= strength;
-#ifdef EEVEE_ENGINE
result = CLOSURE_DEFAULT;
result.radiance = color.rgb;
result.opacity = color.a;
#else
- result = Closure(color.rgb, color.a);
-#endif
-#else
result = CLOSURE_DEFAULT;
#endif
}
@@ -3207,7 +1432,7 @@ void node_gamma(vec4 col, float gamma, out vec4 outcol)
void node_attribute_volume_density(sampler3D tex, out vec4 outcol, out vec3 outvec, out float outf)
{
-#if defined(EEVEE_ENGINE) && defined(MESH_SHADER) && defined(VOLUMETRICS)
+#if defined(MESH_SHADER) && defined(VOLUMETRICS)
vec3 cos = volumeObjectLocalCoord;
#else
vec3 cos = vec3(0.0);
@@ -3219,7 +1444,7 @@ void node_attribute_volume_density(sampler3D tex, out vec4 outcol, out vec3 outv
void node_attribute_volume_color(sampler3D tex, out vec4 outcol, out vec3 outvec, out float outf)
{
-#if defined(EEVEE_ENGINE) && defined(MESH_SHADER) && defined(VOLUMETRICS)
+#if defined(MESH_SHADER) && defined(VOLUMETRICS)
vec3 cos = volumeObjectLocalCoord;
#else
vec3 cos = vec3(0.0);
@@ -3237,7 +1462,7 @@ void node_attribute_volume_color(sampler3D tex, out vec4 outcol, out vec3 outvec
void node_attribute_volume_flame(sampler3D tex, out vec4 outcol, out vec3 outvec, out float outf)
{
-#if defined(EEVEE_ENGINE) && defined(MESH_SHADER) && defined(VOLUMETRICS)
+#if defined(MESH_SHADER) && defined(VOLUMETRICS)
vec3 cos = volumeObjectLocalCoord;
#else
vec3 cos = vec3(0.0);
@@ -3249,7 +1474,7 @@ void node_attribute_volume_flame(sampler3D tex, out vec4 outcol, out vec3 outvec
void node_attribute_volume_temperature(sampler3D tex, vec2 temperature, out vec4 outcol, out vec3 outvec, out float outf)
{
-#if defined(EEVEE_ENGINE) && defined(MESH_SHADER) && defined(VOLUMETRICS)
+#if defined(MESH_SHADER) && defined(VOLUMETRICS)
vec3 cos = volumeObjectLocalCoord;
#else
vec3 cos = vec3(0.0);
@@ -3306,11 +1531,7 @@ void node_geometry(
out vec3 true_normal, out vec3 incoming, out vec3 parametric,
out float backfacing, out float pointiness)
{
-#ifdef EEVEE_ENGINE
position = worldPosition;
-#else
- position = (toworld * vec4(I, 1.0)).xyz;
-#endif
normal = (toworld * vec4(N, 0.0)).xyz;
tangent_orco_z(orco, orco);
node_tangent(N, orco, objmat, toworld, tangent);
@@ -3339,8 +1560,7 @@ void node_tex_coord(
vec4 projvec = ProjectionMatrix * vec4(I, 1.0);
window = vec3(mtex_2d_mapping(projvec.xyz / projvec.w).xy * camerafac.xy + camerafac.zw, 0.0);
- vec3 shade_I;
- shade_view(I, shade_I);
+ vec3 shade_I = (ProjectionMatrix[3][3] == 0.0) ? normalize(I) : vec3(0.0, 0.0, -1.0);
vec3 view_reflection = reflect(shade_I, normalize(N));
reflection = (viewinvmat * vec4(view_reflection, 0.0)).xyz;
}
@@ -4291,13 +2511,9 @@ uniform float backgroundAlpha;
void node_output_world(Closure surface, Closure volume, out Closure result)
{
#ifndef VOLUMETRICS
-#ifdef EEVEE_ENGINE
result.radiance = surface.radiance;
result.opacity = backgroundAlpha;
#else
- result = Closure(surface.radiance, backgroundAlpha);
-#endif
-#else
result = volume;
#endif /* VOLUMETRICS */
}
@@ -4305,7 +2521,6 @@ void node_output_world(Closure surface, Closure volume, out Closure result)
#ifndef VOLUMETRICS
/* TODO : clean this ifdef mess */
/* EEVEE output */
-#ifdef EEVEE_ENGINE
void world_normals_get(out vec3 N)
{
N = gl_FrontFacing ? worldNormal : -worldNormal;
@@ -4329,27 +2544,4 @@ void node_eevee_specular(
result.ssr_id = int(ssr_id);
}
-#endif /* EEVEE_ENGINE */
#endif /* VOLUMETRICS */
-
-/* ********************** matcap style render ******************** */
-
-void material_preview_matcap(vec4 color, sampler2D ima, vec4 N, vec4 mask, out vec4 result)
-{
- vec3 normal;
-
-#ifndef USE_OPENSUBDIV
- /* remap to 0.0 - 1.0 range. This is done because OpenGL 2.0 clamps colors
- * between shader stages and we want the full range of the normal */
- normal = 2.0 * N.xyz - vec3(1.0);
- normal.z = max(normal.z, 0.0);
- normal = normalize(normal);
-#else
- normal = inpt.v.normal;
- mask = vec4(1.0);
-#endif
-
- vec2 tex = 0.49 * normal.xy + vec2(0.5);
-
- result = texture(ima, tex) * mask;
-}
diff --git a/source/blender/gpu/shaders/gpu_shader_vertex.glsl b/source/blender/gpu/shaders/gpu_shader_vertex.glsl
index 4ebd10d514f..2a6c137e195 100644
--- a/source/blender/gpu/shaders/gpu_shader_vertex.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_vertex.glsl
@@ -47,11 +47,7 @@ void srgb_to_linearrgb(vec4 col_from, out vec4 col_to)
bool is_srgb(int info)
{
-#ifdef USE_NEW_SHADING
return (info == 1)? true: false;
-#else
- return false;
-#endif
}
void set_var_from_attr(float attr, int info, out float var)
diff --git a/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl b/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl
index 89a2f391a12..af2e4ba19a2 100644
--- a/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl
@@ -29,11 +29,7 @@ void srgb_to_linearrgb(vec4 col_from, out vec4 col_to)
bool is_srgb(int info)
{
-#ifdef USE_NEW_SHADING
return (info == 1)? true: false;
-#else
- return false;
-#endif
}
void set_var_from_attr(float attr, int info, out float var)
diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h
index ad842029941..2a7a473db51 100644
--- a/source/blender/ikplugin/BIK_api.h
+++ b/source/blender/ikplugin/BIK_api.h
@@ -43,7 +43,7 @@ struct bPoseChannel;
struct bPose;
struct Scene;
struct bConstraint;
-struct EvaluationContext;
+struct Depsgraph;
enum BIK_ParamType {
BIK_PARAM_TYPE_FLOAT = 0,
@@ -62,8 +62,8 @@ struct BIK_ParamValue {
};
typedef struct BIK_ParamValue BIK_ParamValue;
-void BIK_initialize_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
-void BIK_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime);
+void BIK_initialize_tree(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime);
+void BIK_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime);
void BIK_release_tree(struct Scene *scene, struct Object *ob, float ctime);
void BIK_clear_data(struct bPose *pose);
void BIK_clear_cache(struct bPose *pose);
diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c
index 0ee26ff45f1..9330f969ae7 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.c
+++ b/source/blender/ikplugin/intern/ikplugin_api.c
@@ -89,20 +89,20 @@ static IKPlugin *get_plugin(bPose *pose)
/*----------------------------------------*/
/* Plugin API */
-void BIK_initialize_tree(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime)
+void BIK_initialize_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
{
IKPlugin *plugin = get_plugin(ob->pose);
if (plugin && plugin->initialize_tree_func)
- plugin->initialize_tree_func(eval_ctx, scene, ob, ctime);
+ plugin->initialize_tree_func(depsgraph, scene, ob, ctime);
}
-void BIK_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
+void BIK_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
{
IKPlugin *plugin = get_plugin(ob->pose);
if (plugin && plugin->execute_tree_func)
- plugin->execute_tree_func(eval_ctx, scene, ob, pchan, ctime);
+ plugin->execute_tree_func(depsgraph, scene, ob, pchan, ctime);
}
void BIK_release_tree(struct Scene *scene, Object *ob, float ctime)
diff --git a/source/blender/ikplugin/intern/ikplugin_api.h b/source/blender/ikplugin/intern/ikplugin_api.h
index 9a71463ede4..1c55639c33b 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.h
+++ b/source/blender/ikplugin/intern/ikplugin_api.h
@@ -38,15 +38,15 @@
extern "C" {
#endif
+struct Depsgraph;
struct Object;
-struct bPoseChannel;
struct Scene;
-struct EvaluationContext;
+struct bPoseChannel;
struct IKPlugin {
- void (*initialize_tree_func)(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
- void (*execute_tree_func)(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime);
+ void (*initialize_tree_func)(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime);
+ void (*execute_tree_func)(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime);
void (*release_tree_func)(struct Scene *scene, struct Object *ob, float ctime);
void (*remove_armature_func)(struct bPose *pose);
void (*clear_cache)(struct bPose *pose);
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index 5169b72590c..8ad07d85639 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -252,7 +252,7 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[3][3]) // nr =
/* called from within the core BKE_pose_where_is loop, all animsystems and constraints
* were executed & assigned. Now as last we do an IK pass */
-static void execute_posetree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, PoseTree *tree)
+static void execute_posetree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, PoseTree *tree)
{
float R_parmat[3][3], identity[3][3];
float iR_parmat[3][3];
@@ -394,7 +394,7 @@ static void execute_posetree(const struct EvaluationContext *eval_ctx, struct Sc
/* 1.0=ctime, we pass on object for auto-ik (owner-type here is object, even though
* strictly speaking, it is a posechannel)
*/
- BKE_constraint_target_matrix_get(eval_ctx, scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+ BKE_constraint_target_matrix_get(depsgraph, scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
/* and set and transform goal */
mul_m4_m4m4(goal, goalinv, rootmat);
@@ -405,7 +405,7 @@ static void execute_posetree(const struct EvaluationContext *eval_ctx, struct Sc
/* same for pole vector target */
if (data->poletar) {
- BKE_constraint_target_matrix_get(eval_ctx, scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+ BKE_constraint_target_matrix_get(depsgraph, scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
if (data->flag & CONSTRAINT_IK_SETANGLE) {
/* don't solve IK when we are setting the pole angle */
@@ -534,7 +534,7 @@ static void free_posetree(PoseTree *tree)
///----------------------------------------
/// Plugin API for legacy iksolver
-void iksolver_initialize_tree(const struct EvaluationContext *UNUSED(eval_ctx), struct Scene *UNUSED(scene), struct Object *ob, float UNUSED(ctime))
+void iksolver_initialize_tree(struct Depsgraph *UNUSED(depsgraph), struct Scene *UNUSED(scene), struct Object *ob, float UNUSED(ctime))
{
bPoseChannel *pchan;
@@ -545,7 +545,7 @@ void iksolver_initialize_tree(const struct EvaluationContext *UNUSED(eval_ctx),
ob->pose->flag &= ~POSE_WAS_REBUILT;
}
-void iksolver_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
+void iksolver_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
{
while (pchan_root->iktree.first) {
PoseTree *tree = pchan_root->iktree.first;
@@ -558,13 +558,13 @@ void iksolver_execute_tree(const struct EvaluationContext *eval_ctx, struct Scen
/* 4. walk over the tree for regular solving */
for (a = 0; a < tree->totchannel; a++) {
if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag
- BKE_pose_where_is_bone(eval_ctx, scene, ob, tree->pchan[a], ctime, 1);
+ BKE_pose_where_is_bone(depsgraph, scene, ob, tree->pchan[a], ctime, 1);
/* tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() */
tree->pchan[a]->flag |= POSE_CHAIN;
}
/* 5. execute the IK solver */
- execute_posetree(eval_ctx, scene, ob, tree);
+ execute_posetree(depsgraph, scene, ob, tree);
/* 6. apply the differences to the channels,
* we need to calculate the original differences first */
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.h b/source/blender/ikplugin/intern/iksolver_plugin.h
index f1ca91ebb49..9925d3c45d4 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.h
+++ b/source/blender/ikplugin/intern/iksolver_plugin.h
@@ -41,9 +41,9 @@ extern "C" {
#endif
void iksolver_initialize_tree(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime);
void iksolver_execute_tree(
- const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
struct bPoseChannel *pchan_root, float ctime);
#ifdef __cplusplus
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index c74cbb252ff..af303556090 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -90,7 +90,7 @@ typedef void (*ErrorCallback)(const iTaSC::ConstraintValues *values, unsigned in
// one structure for each target in the scene
struct IK_Target {
- const struct EvaluationContext *eval_ctx;
+ struct Depsgraph *bldepsgraph;
struct Scene *blscene;
iTaSC::MovingFrame* target;
iTaSC::ConstraintSet* constraint;
@@ -108,7 +108,7 @@ struct IK_Target {
float eeRest[4][4]; //end effector initial pose relative to armature
IK_Target() {
- eval_ctx = NULL;
+ bldepsgraph = NULL;
blscene = NULL;
target = NULL;
constraint = NULL;
@@ -159,7 +159,7 @@ struct IK_Channel {
};
struct IK_Scene {
- const struct EvaluationContext *eval_ctx;
+ struct Depsgraph *bldepsgraph;
struct Scene *blscene;
IK_Scene* next;
int numchan; // number of channel in pchan
@@ -180,7 +180,7 @@ struct IK_Scene {
std::vector<IK_Target*> targets;
IK_Scene() {
- eval_ctx = NULL;
+ bldepsgraph = NULL;
blscene = NULL;
next = NULL;
channels = NULL;
@@ -554,7 +554,7 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram
bConstraint *constraint = (bConstraint *)target->blenderConstraint;
float tarmat[4][4];
- BKE_constraint_target_matrix_get(target->eval_ctx, target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
+ BKE_constraint_target_matrix_get(target->bldepsgraph, target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
// rootmat contains the target pose in world coordinate
// if enforce is != 1.0, blend the target position with the end effector position
@@ -623,7 +623,7 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame&
IK_Channel &rootchan = ikscene->channels[0];
// get polar target matrix in world space
- BKE_constraint_target_matrix_get(ikscene->eval_ctx, ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
+ BKE_constraint_target_matrix_get(ikscene->bldepsgraph, ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
// convert to armature space
mul_m4_m4m4(polemat, imat, mat);
// get the target in world space (was computed before as target object are defined before base object)
@@ -867,7 +867,7 @@ static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintV
}
// build array of joint corresponding to IK chain
-static int convert_channels(const struct EvaluationContext *eval_ctx, IK_Scene *ikscene, PoseTree *tree, float ctime)
+static int convert_channels(struct Depsgraph *depsgraph, IK_Scene *ikscene, PoseTree *tree, float ctime)
{
IK_Channel *ikchan;
bPoseChannel *pchan;
@@ -884,7 +884,7 @@ static int convert_channels(const struct EvaluationContext *eval_ctx, IK_Scene *
// this is because some of the pose data (e.g. pose head) don't have corresponding
// joint angles and can't be applied to the iTaSC armature dynamically
if (!(pchan->flag & POSE_DONE))
- BKE_pose_where_is_bone(eval_ctx, ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
+ BKE_pose_where_is_bone(depsgraph, ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
// tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is()
pchan->flag |= (POSE_DONE | POSE_CHAIN);
@@ -1060,7 +1060,7 @@ static void BKE_pose_rest(IK_Scene *ikscene)
}
}
-static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *blscene, Object *ob, bPoseChannel *pchan, float ctime)
+static IK_Scene *convert_tree(struct Depsgraph *depsgraph, Scene *blscene, Object *ob, bPoseChannel *pchan, float ctime)
{
PoseTree *tree = (PoseTree *)pchan->iktree.first;
PoseTarget *target;
@@ -1072,12 +1072,11 @@ static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *b
IK_Scene *ikscene;
IK_Channel *ikchan;
KDL::Frame initPose;
- KDL::Rotation boneRot;
Bone *bone;
int a, numtarget;
unsigned int t;
float length;
- bool ret = true, ingame;
+ bool ret = true;
double *rot;
float start[3];
@@ -1086,7 +1085,7 @@ static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *b
ikscene = new IK_Scene;
ikscene->blscene = blscene;
- ikscene->eval_ctx = eval_ctx;
+ ikscene->bldepsgraph = depsgraph;
arm = new iTaSC::Armature();
scene = new iTaSC::Scene();
ikscene->channels = new IK_Channel[tree->totchannel];
@@ -1094,26 +1093,13 @@ static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *b
ikscene->armature = arm;
ikscene->scene = scene;
ikparam = (bItasc *)ob->pose->ikparam;
- ingame = (ob->pose->flag & POSE_GAME_ENGINE);
+
if (!ikparam) {
// you must have our own copy
ikparam = &DefIKParam;
}
- else if (ingame) {
- // tweak the param when in game to have efficient stepping
- // using fixed substep is not effecient since frames in the GE are often
- // shorter than in animation => move to auto step automatically and set
- // the target substep duration via min/max
- if (!(ikparam->flag & ITASC_AUTO_STEP)) {
- float timestep = blscene->r.frs_sec_base / blscene->r.frs_sec;
- if (ikparam->numstep > 0)
- timestep /= ikparam->numstep;
- // with equal min and max, the algorythm will take this step and the indicative substep most of the time
- ikparam->minstep = ikparam->maxstep = timestep;
- ikparam->flag |= ITASC_AUTO_STEP;
- }
- }
- if ((ikparam->flag & ITASC_SIMULATION) && !ingame)
+
+ if (ikparam->flag & ITASC_SIMULATION)
// no cache in animation mode
ikscene->cache = new iTaSC::Cache();
@@ -1139,16 +1125,9 @@ static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *b
std::vector<double> weights;
double weight[3];
// build the array of joints corresponding to the IK chain
- convert_channels(eval_ctx, ikscene, tree, ctime);
- if (ingame) {
- // in the GE, set the initial joint angle to match the current pose
- // this will update the jointArray in ikscene
- convert_pose(ikscene);
- }
- else {
- // in Blender, the rest pose is always 0 for joints
- BKE_pose_rest(ikscene);
- }
+ convert_channels(depsgraph, ikscene, tree, ctime);
+ // in Blender, the rest pose is always 0 for joints
+ BKE_pose_rest(ikscene);
rot = ikscene->jointArray(0);
for (a = 0, ikchan = ikscene->channels; a < tree->totchannel; ++a, ++ikchan) {
@@ -1444,7 +1423,7 @@ static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *b
for (t = 0; t < ikscene->targets.size(); t++) {
IK_Target *iktarget = ikscene->targets[t];
iktarget->blscene = blscene;
- iktarget->eval_ctx = eval_ctx;
+ iktarget->bldepsgraph = depsgraph;
condata = (bKinematicConstraint *)iktarget->blenderConstraint->data;
pchan = tree->pchan[iktarget->channel];
unsigned int controltype, bonecnt;
@@ -1532,7 +1511,7 @@ static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *b
return ikscene;
}
-static void create_scene(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime)
+static void create_scene(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
{
bPoseChannel *pchan;
@@ -1543,7 +1522,7 @@ static void create_scene(const struct EvaluationContext *eval_ctx, Scene *scene,
if (tree) {
IK_Data *ikdata = get_ikdata(ob->pose);
// convert tree in iTaSC::Scene
- IK_Scene *ikscene = convert_tree(eval_ctx, scene, ob, pchan, ctime);
+ IK_Scene *ikscene = convert_tree(depsgraph, scene, ob, pchan, ctime);
if (ikscene) {
ikscene->next = ikdata->first;
ikdata->first = ikscene;
@@ -1582,7 +1561,7 @@ static int init_scene(Object *ob)
return 0;
}
-static void execute_scene(const struct EvaluationContext *eval_ctx, Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, float ctime, float frtime)
+static void execute_scene(struct Depsgraph *depsgraph, Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, float ctime, float frtime)
{
int i;
IK_Channel *ikchan;
@@ -1598,7 +1577,7 @@ static void execute_scene(const struct EvaluationContext *eval_ctx, Scene *blsce
// in animation mode, we must get the bone position from action and constraints
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) {
if (!(ikchan->pchan->flag & POSE_DONE))
- BKE_pose_where_is_bone(eval_ctx, blscene, ikscene->blArmature, ikchan->pchan, ctime, 1);
+ BKE_pose_where_is_bone(depsgraph, blscene, ikscene->blArmature, ikchan->pchan, ctime, 1);
// tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is()
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
@@ -1750,7 +1729,7 @@ static void execute_scene(const struct EvaluationContext *eval_ctx, Scene *blsce
//---------------------------------------------------
// plugin interface
//
-void itasc_initialize_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, float ctime)
+void itasc_initialize_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, float ctime)
{
bPoseChannel *pchan;
int count = 0;
@@ -1770,13 +1749,13 @@ void itasc_initialize_tree(const struct EvaluationContext *eval_ctx, struct Scen
// if at least one tree, create the scenes from the PoseTree stored in the channels
// postpone until execute_tree: this way the pose constraint are included
if (count)
- create_scene(eval_ctx, scene, ob, ctime);
+ create_scene(depsgraph, scene, ob, ctime);
itasc_update_param(ob->pose);
// make sure we don't rebuilt until the user changes something important
ob->pose->flag &= ~POSE_WAS_REBUILT;
}
-void itasc_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
+void itasc_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
{
if (ob->pose->ikdata) {
IK_Data *ikdata = (IK_Data *)ob->pose->ikdata;
@@ -1787,13 +1766,7 @@ void itasc_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *
for (IK_Scene *ikscene = ikdata->first; ikscene; ikscene = ikscene->next) {
if (ikscene->channels[0].pchan == pchan_root) {
float timestep = scene->r.frs_sec_base / scene->r.frs_sec;
- if (ob->pose->flag & POSE_GAME_ENGINE) {
- timestep = ob->pose->ctime;
- // limit the timestep to avoid excessive number of iteration
- if (timestep > 0.2f)
- timestep = 0.2f;
- }
- execute_scene(eval_ctx, scene, ikscene, ikparam, ctime, timestep);
+ execute_scene(depsgraph, scene, ikscene, ikparam, ctime, timestep);
break;
}
}
diff --git a/source/blender/ikplugin/intern/itasc_plugin.h b/source/blender/ikplugin/intern/itasc_plugin.h
index 2f4e4036d76..0ab9a67dce4 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.h
+++ b/source/blender/ikplugin/intern/itasc_plugin.h
@@ -40,8 +40,8 @@
extern "C" {
#endif
-void itasc_initialize_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
-void itasc_execute_tree(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
+void itasc_initialize_tree(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime);
+void itasc_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
void itasc_release_tree(struct Scene *scene, struct Object *ob, float ctime);
void itasc_clear_data(struct bPose *pose);
void itasc_clear_cache(struct bPose *pose);
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index a4281514e39..7c11fca3c34 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -704,11 +704,12 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
{
// Make sure the masks are correct.
if ((rmask & gmask) ||
- (rmask & bmask) ||
- (rmask & amask) ||
- (gmask & bmask) ||
- (gmask & amask) ||
- (bmask & amask)) {
+ (rmask & bmask) ||
+ (rmask & amask) ||
+ (gmask & bmask) ||
+ (gmask & amask) ||
+ (bmask & amask))
+ {
printf("DDS: bad RGBA masks, pixel format not set\n");
return;
}
@@ -1068,7 +1069,7 @@ bool DirectDrawSurface::isTexture3D() const
}
else
{
- return (header.caps.caps2 & DDSCAPS2_VOLUME) != 0;
+ return (header.caps.caps2 & DDSCAPS2_VOLUME) != 0;
}
}
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index eaf4dfd84b4..2bda07bdbbe 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -1041,7 +1041,7 @@ static IndexBuildContext *index_fallback_create_context(struct anim *anim, IMB_T
/* since timecode indices only work with ffmpeg right now,
* don't know a sensible fallback here...
*
- * so no proxies, no game to play...
+ * so no proxies...
*/
if (proxy_sizes_in_use == IMB_PROXY_NONE) {
return NULL;
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 388c2734fe9..30a0fdf4e55 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -119,7 +119,7 @@ static void info_callback(const char *msg, void *client_data)
# define PIXEL_LOOPER_END \
} \
- } (void)0 \
+} (void)0 \
struct ImBuf *imb_jp2_decode(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 72e4597a06e..82f944dc020 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -109,6 +109,9 @@ enum {
/*->flag*/
enum {
+ /* This IDProp may be statically overridden. Should only be used/be relevant for custom properties. */
+ IDP_FLAG_OVERRIDABLE_STATIC = 1 << 0,
+
IDP_FLAG_GHOST = 1 << 7, /* this means the property is set but RNA will return false when checking
* 'RNA_property_is_set', currently this is a runtime flag */
};
@@ -385,6 +388,10 @@ typedef enum ID_Type {
#define ID_IS_STATIC_OVERRIDE_TEMPLATE(_id) (((ID *)(_id))->override_static != NULL && \
((ID *)(_id))->override_static->reference == NULL)
+#define ID_IS_STATIC_OVERRIDE_AUTO(_id) (!ID_IS_LINKED((_id)) && \
+ ID_IS_STATIC_OVERRIDE((_id)) && \
+ (((ID *)(_id))->flag & LIB_OVERRIDE_STATIC_AUTO))
+
#ifdef GS
# undef GS
#endif
@@ -433,7 +440,9 @@ enum {
LIB_TAG_MISSING = 1 << 6,
/* RESET_NEVER tag datablock as being up-to-date regarding its reference. */
- LIB_TAG_OVERRIDESTATIC_OK = 1 << 9,
+ LIB_TAG_OVERRIDESTATIC_REFOK = 1 << 9,
+ /* RESET_NEVER tag datablock as needing an auto-override execution, if enabled. */
+ LIB_TAG_OVERRIDESTATIC_AUTOREFRESH = 1 << 17,
/* tag datablock has having an extra user. */
LIB_TAG_EXTRAUSER = 1 << 2,
@@ -461,6 +470,7 @@ enum {
LIB_TAG_NOT_ALLOCATED = 1 << 16,
};
+/* WARNING - when adding flags check on PSYS_RECALC */
enum {
/* RESET_AFTER_USE, used by update code (depsgraph). */
ID_RECALC_NONE = 0,
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 95cbdeadf87..3c035ae0bc8 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -434,8 +434,7 @@ typedef enum ePose_Flags {
POSE_RECALCPATHS = (1 << 4),
/* set by BKE_pose_rebuild to give a chance to the IK solver to rebuild IK tree */
POSE_WAS_REBUILT = (1 << 5),
- /* set by game_copy_pose to indicate that this pose is used in the game engine */
- POSE_GAME_ENGINE = (1 << 6),
+ POSE_FLAG_DEPRECATED = (1 << 6), /* deprecated. */
/* pose constraint flags needs to be updated */
POSE_CONSTRAINTS_NEED_UPDATE_FLAGS = (1 << 7),
} ePose_Flags;
@@ -681,6 +680,9 @@ typedef struct SpaceAction {
char mode, autosnap; /* mode: editing context; autosnap: automatic keyframe snapping mode */
short flag; /* flag: bitmapped settings; */
float timeslide; /* for Time-Slide transform mode drawing - current frame? */
+
+ int cache_display; /* (eTimeline_Cache_Flag) */
+ int pad;
} SpaceAction;
/* SpaceAction flag */
@@ -725,6 +727,8 @@ typedef enum eAnimEdit_Context {
SACTCONT_MASK = 4,
/* cache file */
SACTCONT_CACHEFILE = 5,
+ /* timeline - replacement for the standalone "timeline editor" */
+ SACTCONT_TIMELINE = 6,
} eAnimEdit_Context;
/* SpaceAction AutoSnap Settings (also used by other Animation Editors) */
@@ -743,6 +747,17 @@ typedef enum eAnimEdit_AutoSnap {
SACTSNAP_TSTEP = 5
} eAnimEdit_AutoSnap;
+/* SAction->cache_display */
+typedef enum eTimeline_Cache_Flag {
+ TIME_CACHE_DISPLAY = (1 << 0),
+ TIME_CACHE_SOFTBODY = (1 << 1),
+ TIME_CACHE_PARTICLES = (1 << 2),
+ TIME_CACHE_CLOTH = (1 << 3),
+ TIME_CACHE_SMOKE = (1 << 4),
+ TIME_CACHE_DYNAMICPAINT = (1 << 5),
+ TIME_CACHE_RIGIDBODY = (1 << 6),
+} eTimeline_Cache_Flag;
+
/* ************************************************ */
/* Legacy Data */
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
deleted file mode 100644
index 6bdea21da1e..00000000000
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ /dev/null
@@ -1,583 +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 DNA_actuator_types.h
- * \ingroup DNA
- *
- * #bActuator type is specifically for use by Object logic-bricks in the game-engine.
- */
-
-#ifndef __DNA_ACTUATOR_TYPES_H__
-#define __DNA_ACTUATOR_TYPES_H__
-
-struct Object;
-struct Mesh;
-struct Scene;
-struct Group;
-struct Text;
-
-/* ****************** ACTUATORS ********************* */
-
-/* unused now, moved to editobjectactuator in 2.02. Still needed for dna */
-typedef struct bAddObjectActuator {
- int time, pad;
- struct Object *ob;
-} bAddObjectActuator;
-
-typedef struct bActionActuator {
- struct bAction *act; /* Pointer to action */
- short type, flag; /* Playback type */ // not in use
- float sta, end; /* Start & End frames */
- char name[64]; /* For property-driven playback, MAX_NAME */
- char frameProp[64]; /* Set this property to the actions current frame, MAX_NAME */
- short blendin; /* Number of frames of blending */
- short priority; /* Execution priority */
- short layer; /* Animation layer */
- short end_reset; /* Ending the actuator (negative pulse) wont reset the action to its starting frame */
- short strideaxis; /* Displacement axis */
- short blend_mode; /* Layer blending mode */
- float stridelength; /* Displacement incurred by cycle */ // not in use
- float layer_weight; /* How much of the previous layer to use for blending. (<0 = disable, 0 = add mode) */
-} bActionActuator;
-
-typedef struct Sound3D {
- float min_gain;
- float max_gain;
- float reference_distance;
- float max_distance;
- float rolloff_factor;
- float cone_inner_angle;
- float cone_outer_angle;
- float cone_outer_gain;
-} Sound3D;
-
-typedef struct bSoundActuator {
- short flag, sndnr;
- int pad1, pad2;
- short pad3[2];
- float volume, pitch;
- struct bSound *sound;
- struct Sound3D sound3D;
- short type, pad4;
- short pad5, pad6[1];
-} bSoundActuator;
-
-typedef struct bEditObjectActuator {
- int time;
- short type, flag;
- struct Object *ob;
- struct Mesh *me;
- char name[64]; /* MAX_NAME */
- float linVelocity[3]; /* initial lin. velocity on creation */
- float angVelocity[3]; /* initial ang. velocity on creation */
- float mass;
- short localflag; /* flag for the lin & ang. vel: apply locally */
- short dyn_operation;
- short upflag, trackflag; /* flag for up axis and track axis */
- int pad;
-} bEditObjectActuator;
-
-typedef struct bSceneActuator {
- short type, pad1;
- int pad;
- struct Scene *scene;
- struct Object *camera;
-} bSceneActuator;
-
-typedef struct bPropertyActuator {
- int pad, type;
- char name[64], value[64]; /* MAX_NAME */
- struct Object *ob;
-} bPropertyActuator;
-
-typedef struct bObjectActuator {
- short flag, type, otype;
- short damping;
- float forceloc[3], forcerot[3];
- float pad[3], pad1[3];
- float dloc[3], drot[3]; /* angle in radians */
- float linearvelocity[3], angularvelocity[3];
- struct Object *reference;
-} bObjectActuator;
-
-/* deprecated, handled by bActionActuator now */
-typedef struct bIpoActuator {
- short flag, type;
- float sta, end;
- char name[64]; /* MAX_NAME */
- char frameProp[64]; /* Set this property to the actions current frame, MAX_NAME */
-
- short pad1, pad2, pad3, pad4;
-
-} bIpoActuator;
-
-typedef struct bCameraActuator {
- struct Object *ob;
- float height, min, max;
- float damping;
- short pad1, axis;
- float pad2;
-} bCameraActuator;
-
-typedef struct bConstraintActuator {
- short type, mode;
- short flag, damp;
- short time, rotdamp;
- int pad;
- float minloc[3], maxloc[3];
- float minrot[3], maxrot[3];
- char matprop[64]; /* MAX_NAME */
-} bConstraintActuator;
-
-typedef struct bGroupActuator {
- short flag, type;
- int sta, end;
- char name[64]; /* property or groupkey, MAX_NAME */
-
- short pad[3], cur, butsta, butend;/* not referenced, can remove? */
- /* struct Group *group; not used, remove */
-
-} bGroupActuator;
-
-/* I added a few extra fields here, to facilitate conversions */
-typedef struct bRandomActuator {
- int seed;
- int distribution;
- int int_arg_1;
- int int_arg_2;
- float float_arg_1;
- float float_arg_2;
- char propname[64]; /* MAX_NAME */
-} bRandomActuator;
-
-typedef struct bMessageActuator {
- char toPropName[64]; /* Send to all objects with this propertyname. Empty to broadcast. MAX_NAME. */
- struct Object *toObject;/* (Possible future use) pointer to a single destination object. */
- char subject[64]; /* Message Subject to send. MAX_NAME. */
- short bodyType, pad1; /* bodyType is either 'User defined text' or PropName */
- int pad2;
- char body[64]; /* Either User Defined Text or our PropName to send value of, MAX_NAME */
-} bMessageActuator;
-
-typedef struct bGameActuator {
- short flag, type;
- int sta, end;
- char filename[64];
- char loadaniname[64];
-} bGameActuator;
-
-typedef struct bVisibilityActuator {
- /** bit 0: Is this object visible?
- ** bit 1: Apply recursively
- ** bit 2: Is this object an occluder? */
- int flag;
-} bVisibilityActuator;
-
-typedef struct bTwoDFilterActuator {
- char pad[4];
- /* Tells what type of 2D Filter */
- short type;
- /* (flag == 0) means 2D filter is activate and
- * (flag != 0) means 2D filter is inactive */
- short flag;
- int int_arg;
- /* a float argument */
- float float_arg;
- struct Text *text;
-} bTwoDFilterActuator;
-
-typedef struct bParentActuator {
- char pad[2];
- short flag;
- int type;
- struct Object *ob;
-} bParentActuator;
-
-typedef struct bStateActuator {
- int type; /* 0=Set, 1=Add, 2=Rem, 3=Chg */
- unsigned int mask; /* the bits to change */
-} bStateActuator;
-
-typedef struct bArmatureActuator {
- char posechannel[64]; /* MAX_NAME */
- char constraint[64]; /* MAX_NAME */
- int type; /* 0=run, 1=enable, 2=disable, 3=set target, 4=set weight */
- float weight;
- float influence;
- float pad;
- struct Object *target;
- struct Object *subtarget;
-} bArmatureActuator;
-
-typedef struct bSteeringActuator {
- char pad[5];
- char flag;
- short facingaxis;
- int type; /* 0=seek, 1=flee, 2=path following */
- float dist;
- float velocity;
- float acceleration;
- float turnspeed;
- int updateTime;
- struct Object *target;
- struct Object *navmesh;
-} bSteeringActuator;
-
-typedef struct bMouseActuator {
- short type; /* 0=Visibility, 1=Look */
- short flag;
-
- int object_axis[2];
- float threshold[2];
- float sensitivity[2];
- float limit_x[2];
- float limit_y[2];
-} bMouseActuator;
-
-
-typedef struct bActuator {
- struct bActuator *next, *prev, *mynew;
- short type;
- /**
- * Tells what type of actuator data \ref data holds.
- */
- short flag;
- short otype, go;
- char name[64]; /* MAX_NAME */
-
- /**
- * data must point to an object actuator type struct.
- */
- void *data;
-
- /**
- * For ipo's and props: to find out which object the actuator
- * belongs to */
- struct Object *ob;
-
-} bActuator;
-
-/* objectactuator->flag */
-#define ACT_FORCE_LOCAL 1
-#define ACT_TORQUE_LOCAL 2
-#define ACT_SERVO_LIMIT_X 2
-#define ACT_DLOC_LOCAL 4
-#define ACT_SERVO_LIMIT_Y 4
-#define ACT_DROT_LOCAL 8
-#define ACT_SERVO_LIMIT_Z 8
-#define ACT_LIN_VEL_LOCAL 16
-#define ACT_ANG_VEL_LOCAL 32
-//#define ACT_ADD_LIN_VEL_LOCAL 64
-#define ACT_ADD_LIN_VEL 64
-#define ACT_ADD_CHAR_LOC 128
-#define ACT_CHAR_JUMP 256
-
-/* objectactuator->type */
-#define ACT_OBJECT_NORMAL 0
-#define ACT_OBJECT_SERVO 1
-#define ACT_OBJECT_CHARACTER 2
-
-/* actuator->type */
-#define ACT_OBJECT 0
-#define ACT_IPO 1
-#define ACT_LAMP 2
-#define ACT_CAMERA 3
-#define ACT_MATERIAL 4
-#define ACT_SOUND 5
-#define ACT_PROPERTY 6
- /* these two obsolete since 2.02 */
-#define ACT_ADD_OBJECT 7
-#define ACT_END_OBJECT 8
-
-#define ACT_CONSTRAINT 9
-#define ACT_EDIT_OBJECT 10
-#define ACT_SCENE 11
-#define ACT_GROUP 12
-#define ACT_RANDOM 13
-#define ACT_MESSAGE 14
-#define ACT_ACTION 15 /* __ NLA */
-#define ACT_GAME 17
-#define ACT_VISIBILITY 18
-#define ACT_2DFILTER 19
-#define ACT_PARENT 20
-#define ACT_SHAPEACTION 21
-#define ACT_STATE 22
-#define ACT_ARMATURE 23
-#define ACT_STEERING 24
-#define ACT_MOUSE 25
-
-/* actuator flag */
-#define ACT_SHOW 1
-#define ACT_DEL 2
-#define ACT_NEW 4
-#define ACT_LINKED 8
-#define ACT_VISIBLE 16
-#define ACT_PIN 32
-#define ACT_DEACTIVATE 64
-
-/* link codes */
-#define LINK_SENSOR 0
-#define LINK_CONTROLLER 1
-#define LINK_ACTUATOR 2
-
-/* keyboardsensor->type */
-#define SENS_ALL_KEYS 1
-
-/* actionactuator->type */
-#define ACT_ACTION_PLAY 0
-#define ACT_ACTION_PINGPONG 1
-#define ACT_ACTION_FLIPPER 2
-#define ACT_ACTION_LOOP_STOP 3
-#define ACT_ACTION_LOOP_END 4
-#define ACT_ACTION_KEY2KEY 5
-#define ACT_ACTION_FROM_PROP 6
-#define ACT_ACTION_MOTION 7
-
-/* actionactuator->blend_mode */
-#define ACT_ACTION_BLEND 0
-#define ACT_ACTION_ADD 1
-
-/* ipoactuator->type */
-/* used for conversion from 2.01 */
-#define ACT_IPO_FROM_PROP 6
-
-/* groupactuator->type */
-#define ACT_GROUP_PLAY 0
-#define ACT_GROUP_PINGPONG 1
-#define ACT_GROUP_FLIPPER 2
-#define ACT_GROUP_LOOP_STOP 3
-#define ACT_GROUP_LOOP_END 4
-#define ACT_GROUP_FROM_PROP 5
-#define ACT_GROUP_SET 6
-
-/* ipoactuator->flag */
-#define ACT_IPOFORCE (1 << 0)
-#define ACT_IPOEND (1 << 1)
-#define ACT_IPOLOCAL (1 << 2)
-#define ACT_IPOCHILD (1 << 4)
-#define ACT_IPOADD (1 << 5)
-
-/* property actuator->type */
-#define ACT_PROP_ASSIGN 0
-#define ACT_PROP_ADD 1
-#define ACT_PROP_COPY 2
-#define ACT_PROP_TOGGLE 3
-#define ACT_PROP_LEVEL 4
-
-/* constraint flag */
-#define ACT_CONST_NONE 0
-#define ACT_CONST_LOCX 1
-#define ACT_CONST_LOCY 2
-#define ACT_CONST_LOCZ 4
-#define ACT_CONST_ROTX 8
-#define ACT_CONST_ROTY 16
-#define ACT_CONST_ROTZ 32
-#define ACT_CONST_NORMAL 64
-#define ACT_CONST_MATERIAL 128
-#define ACT_CONST_PERMANENT 256
-#define ACT_CONST_DISTANCE 512
-#define ACT_CONST_LOCAL 1024
-#define ACT_CONST_DOROTFH 2048
-
-/* constraint mode */
-#define ACT_CONST_DIRPX 1
-#define ACT_CONST_DIRPY 2
-#define ACT_CONST_DIRPZ 4
-#define ACT_CONST_DIRNX 8
-#define ACT_CONST_DIRNY 16
-#define ACT_CONST_DIRNZ 32
-
-/* constraint type */
-#define ACT_CONST_TYPE_LOC 0
-#define ACT_CONST_TYPE_DIST 1
-#define ACT_CONST_TYPE_ORI 2
-#define ACT_CONST_TYPE_FH 3
-
-/* editObjectActuator->type */
-#define ACT_EDOB_ADD_OBJECT 0
-#define ACT_EDOB_END_OBJECT 1
-#define ACT_EDOB_REPLACE_MESH 2
-#define ACT_EDOB_TRACK_TO 3
-#define ACT_EDOB_DYNAMICS 4
-
-/* editObjectActuator->localflag */
-#define ACT_EDOB_LOCAL_LINV 2
-#define ACT_EDOB_LOCAL_ANGV 4
-
-/* editObjectActuator->flag */
-#define ACT_TRACK_3D 1
-
-/* editObjectActuator->upflag */
-#define ACT_TRACK_UP_X 0
-#define ACT_TRACK_UP_Y 1
-#define ACT_TRACK_UP_Z 2
-
-/* editObjectActuator->trackflag */
-#define ACT_TRACK_TRAXIS_X 0
-#define ACT_TRACK_TRAXIS_Y 1
-#define ACT_TRACK_TRAXIS_Z 2
-#define ACT_TRACK_TRAXIS_NEGX 3
-#define ACT_TRACK_TRAXIS_NEGY 4
-#define ACT_TRACK_TRAXIS_NEGZ 5
-
-/* editObjectActuator->flag for replace mesh actuator */
-#define ACT_EDOB_REPLACE_MESH_NOGFX 2 /* use for replace mesh actuator */
-#define ACT_EDOB_REPLACE_MESH_PHYS 4
-
-/* editObjectActuator->dyn_operation */
-#define ACT_EDOB_RESTORE_DYN 0
-#define ACT_EDOB_SUSPEND_DYN 1
-#define ACT_EDOB_ENABLE_RB 2
-#define ACT_EDOB_DISABLE_RB 3
-#define ACT_EDOB_SET_MASS 4
-
-
-/* SceneActuator->type */
-#define ACT_SCENE_RESTART 0
-#define ACT_SCENE_SET 1
-#define ACT_SCENE_CAMERA 2
-#define ACT_SCENE_ADD_FRONT 3
-#define ACT_SCENE_ADD_BACK 4
-#define ACT_SCENE_REMOVE 5
-#define ACT_SCENE_SUSPEND 6
-#define ACT_SCENE_RESUME 7
-
-
-/* randomAct->distribution */
-#define ACT_RANDOM_BOOL_CONST 0
-#define ACT_RANDOM_BOOL_UNIFORM 1
-#define ACT_RANDOM_BOOL_BERNOUILLI 2
-#define ACT_RANDOM_INT_CONST 3
-#define ACT_RANDOM_INT_UNIFORM 4
-#define ACT_RANDOM_INT_POISSON 5
-#define ACT_RANDOM_FLOAT_CONST 6
-#define ACT_RANDOM_FLOAT_UNIFORM 7
-#define ACT_RANDOM_FLOAT_NORMAL 8
-#define ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL 9
-
-/* SoundActuator->flag */
-#define ACT_SND_3D_SOUND 1
-
-/* SoundActuator->type */
-#define ACT_SND_PLAY_STOP_SOUND 0
-#define ACT_SND_PLAY_END_SOUND 1
-#define ACT_SND_LOOP_STOP_SOUND 2
-#define ACT_SND_LOOP_END_SOUND 3
-#define ACT_SND_LOOP_BIDIRECTIONAL_SOUND 4
-#define ACT_SND_LOOP_BIDIRECTIONAL_STOP_SOUND 5
-
-/* messageactuator->type */
-#define ACT_MESG_MESG 0
-#define ACT_MESG_PROP 1
-
-/* gameactuator->type */
-#define ACT_GAME_LOAD 0
-#define ACT_GAME_START 1
-#define ACT_GAME_RESTART 2
-#define ACT_GAME_QUIT 3
-#define ACT_GAME_SAVECFG 4
-#define ACT_GAME_LOADCFG 5
-#define ACT_GAME_SCREENSHOT 6
-
-/* visibilityact->flag */
-/* Set means the object will become invisible */
-#define ACT_VISIBILITY_INVISIBLE (1 << 0)
-#define ACT_VISIBILITY_RECURSIVE (1 << 1)
-#define ACT_VISIBILITY_OCCLUSION (1 << 2)
-
-/* twodfilter->type */
-#define ACT_2DFILTER_ENABLED -2
-#define ACT_2DFILTER_DISABLED -1
-#define ACT_2DFILTER_NOFILTER 0
-#define ACT_2DFILTER_MOTIONBLUR 1
-#define ACT_2DFILTER_BLUR 2
-#define ACT_2DFILTER_SHARPEN 3
-#define ACT_2DFILTER_DILATION 4
-#define ACT_2DFILTER_EROSION 5
-#define ACT_2DFILTER_LAPLACIAN 6
-#define ACT_2DFILTER_SOBEL 7
-#define ACT_2DFILTER_PREWITT 8
-#define ACT_2DFILTER_GRAYSCALE 9
-#define ACT_2DFILTER_SEPIA 10
-#define ACT_2DFILTER_INVERT 11
-#define ACT_2DFILTER_CUSTOMFILTER 12
-#define ACT_2DFILTER_NUMBER_OF_FILTERS 13
-
-/* parentactuator->type */
-#define ACT_PARENT_SET 0
-#define ACT_PARENT_REMOVE 1
-
-/* parentactuator->flag */
-#define ACT_PARENT_COMPOUND 1
-#define ACT_PARENT_GHOST 2
-
-/* armatureactuator->type */
-#define ACT_ARM_RUN 0
-#define ACT_ARM_ENABLE 1
-#define ACT_ARM_DISABLE 2
-#define ACT_ARM_SETTARGET 3
-#define ACT_ARM_SETWEIGHT 4
-#define ACT_ARM_SETINFLUENCE 5
-/* update this define if more types are added */
-#define ACT_ARM_MAXTYPE 5
-
-/* stateactuator->type */
-#define ACT_STATE_SET 0
-#define ACT_STATE_ADD 1
-#define ACT_STATE_REMOVE 2
-#define ACT_STATE_CHANGE 3
-
-/* steeringactuator->type */
-#define ACT_STEERING_SEEK 0
-#define ACT_STEERING_FLEE 1
-#define ACT_STEERING_PATHFOLLOWING 2
-/* steeringactuator->flag */
-#define ACT_STEERING_SELFTERMINATED 1
-#define ACT_STEERING_ENABLEVISUALIZATION 2
-#define ACT_STEERING_AUTOMATICFACING 4
-#define ACT_STEERING_NORMALUP 8
-#define ACT_STEERING_LOCKZVEL 16
-
-/* mouseactuator->type */
-#define ACT_MOUSE_VISIBILITY 0
-#define ACT_MOUSE_LOOK 1
-
-/* mouseactuator->flag */
-#define ACT_MOUSE_VISIBLE (1 << 0)
-#define ACT_MOUSE_USE_AXIS_X (1 << 1)
-#define ACT_MOUSE_USE_AXIS_Y (1 << 2)
-#define ACT_MOUSE_RESET_X (1 << 3)
-#define ACT_MOUSE_RESET_Y (1 << 4)
-#define ACT_MOUSE_LOCAL_X (1 << 5)
-#define ACT_MOUSE_LOCAL_Y (1 << 6)
-
-/* mouseactuator->object_axis */
-#define ACT_MOUSE_OBJECT_AXIS_X 0
-#define ACT_MOUSE_OBJECT_AXIS_Y 1
-#define ACT_MOUSE_OBJECT_AXIS_Z 2
-
-#endif /* __DNA_ACTUATOR_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 099d5da7c49..cea1a1cf40f 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -840,17 +840,18 @@ typedef enum eKS_Settings {
/* Flags for use by keyframe creation/deletion calls */
typedef enum eInsertKeyFlags {
+ INSERTKEY_NOFLAGS = 0,
INSERTKEY_NEEDED = (1<<0), /* only insert keyframes where they're needed */
INSERTKEY_MATRIX = (1<<1), /* insert 'visual' keyframes where possible/needed */
INSERTKEY_FAST = (1<<2), /* don't recalculate handles,etc. after adding key */
INSERTKEY_FASTR = (1<<3), /* don't realloc mem (or increase count, as array has already been set out) */
INSERTKEY_REPLACE = (1<<4), /* only replace an existing keyframe (this overrides INSERTKEY_NEEDED) */
INSERTKEY_XYZ2RGB = (1<<5), /* transform F-Curves should have XYZ->RGB color mode */
- INSERTKEY_NO_USERPREF = (1 << 6), /* ignore user-prefs (needed for predictable API use) */
+ INSERTKEY_NO_USERPREF = (1<<6), /* ignore user-prefs (needed for predictable API use) */
/* Allow to make a full copy of new key into existing one, if any, instead of 'reusing' existing handles.
* Used by copy/paste code. */
INSERTKEY_OVERWRITE_FULL = (1<<7),
- INSERTKEY_DRIVER = (1<<8), /* for driver FCurves, use driver's "input" value - for easier corrective driver setup */
+ INSERTKEY_DRIVER = (1<<8), /* for driver FCurves, use driver's "input" value - for easier corrective driver setup */
} eInsertKeyFlags;
/* ************************************************ */
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 757c0eb8394..9e278c63904 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -99,8 +99,6 @@ typedef struct bArmature {
Bone *act_bone; /* active bone */
struct EditBone *act_edbone; /* active editbone (in editmode) */
- void *sketch; /* sketch struct for etch-a-ton */
-
int flag;
int drawtype;
int gevertdeformer; /* how vertex deformation is handled in the ge */
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index 4c4440ad573..9a87b64ac08 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -488,7 +488,7 @@ typedef enum eBConstraint_Types {
CONSTRAINT_TYPE_DISTLIMIT = 14, /* limit distance */
CONSTRAINT_TYPE_STRETCHTO = 15, /* claiming this to be mine :) is in tuhopuu bjornmose */
CONSTRAINT_TYPE_MINMAX = 16, /* floor constraint */
- CONSTRAINT_TYPE_RIGIDBODYJOINT = 17, /* rigidbody constraint */
+ /* CONSTRAINT_TYPE_DEPRECATED = 17 */
CONSTRAINT_TYPE_CLAMPTO = 18, /* clampto constraint */
CONSTRAINT_TYPE_TRANSFORM = 19, /* transformation (loc/rot/size -> loc/rot/size) constraint */
CONSTRAINT_TYPE_SHRINKWRAP = 20, /* shrinkwrap (loc/rot) constraint */
@@ -841,10 +841,6 @@ typedef enum eObjectSolver_Flags {
OBJECTSOLVER_ACTIVECLIP = (1<<0)
} eObjectSolver_Flags;
-/* Rigid-Body Constraint */
-#define CONSTRAINT_DRAW_PIVOT 0x40
-#define CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
-
/* ObjectSolver Constraint -> flag */
typedef enum eStretchTo_Flags {
STRETCHTOCON_USE_BULGE_MIN = (1 << 0),
diff --git a/source/blender/makesdna/DNA_controller_types.h b/source/blender/makesdna/DNA_controller_types.h
deleted file mode 100644
index 154542d60c5..00000000000
--- a/source/blender/makesdna/DNA_controller_types.h
+++ /dev/null
@@ -1,95 +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 DNA_controller_types.h
- * \ingroup DNA
- *
- * #bController type is specifically for use by Object logic-bricks in the game-engine.
- */
-
-#ifndef __DNA_CONTROLLER_TYPES_H__
-#define __DNA_CONTROLLER_TYPES_H__
-
-struct bActuator;
-struct Text;
-struct bSensor;
-
-/* ****************** CONTROLLERS ********************* */
-
-typedef struct bExpressionCont {
- char str[128];
-} bExpressionCont;
-
-typedef struct bPythonCont {
- struct Text *text;
- char module[64];
- int mode;
- int flag; /* only used for debug now */
-} bPythonCont;
-
-typedef struct bController {
- struct bController *next, *prev, *mynew;
- short type, flag, inputs, totlinks;
- short otype, totslinks, pad2, pad3;
-
- char name[64];
- void *data;
-
- struct bActuator **links;
-
- struct bSensor **slinks;
- short val, valo;
- unsigned int state_mask;
-
-} bController;
-
-/* controller->type */
-#define CONT_LOGIC_AND 0
-#define CONT_LOGIC_OR 1
-#define CONT_EXPRESSION 2
-#define CONT_PYTHON 3
-#define CONT_LOGIC_NAND 4
-#define CONT_LOGIC_NOR 5
-#define CONT_LOGIC_XOR 6
-#define CONT_LOGIC_XNOR 7
-
-/* controller->flag */
-#define CONT_SHOW 1
-#define CONT_DEL 2
-#define CONT_NEW 4
-#define CONT_MASK 8
-#define CONT_PRIO 16
-#define CONT_DEACTIVATE 32
-
-/* pyctrl->flag */
-#define CONT_PY_DEBUG 1
-
-/* pyctrl->mode */
-#define CONT_PY_SCRIPT 0
-#define CONT_PY_MODULE 1
-
-#endif /* __DNA_CONTROLLER_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 48fe82b3e1a..fd0170b9766 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -116,7 +116,7 @@ typedef struct BezTriple {
char h1, h2; /* h1, h2: the handle type of the two handles */
char f1, f2, f3; /* f1, f2, f3: used for selection status */
- char hide; /* hide: used to indicate whether BezTriple is hidden (3D), type of keyframe (eBezTriple_KeyframeTypes) */
+ char hide; /* hide: used to indicate whether BezTriple is hidden (3D), type of keyframe (eBezTriple_KeyframeType) */
char easing; /* easing: easing type for interpolation mode (eBezTriple_Easing) */
float back; /* BEZT_IPO_BACK */
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index 17553e98817..ecdcb2398ac 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -177,7 +177,7 @@ typedef struct DynamicPaintCanvasSettings {
/* flags */
enum {
MOD_DPAINT_PART_RAD = 1 << 0, /* use particle radius */
- MOD_DPAINT_USE_MATERIAL = 1 << 1, /* use object material */
+ //MOD_DPAINT_USE_MATERIAL = 1 << 1, /* DNA_DEPRECATED */
MOD_DPAINT_ABS_ALPHA = 1 << 2, /* don't increase alpha unless paint alpha is higher than existing */
MOD_DPAINT_ERASE = 1 << 3, /* removes paint */
@@ -231,7 +231,6 @@ typedef struct DynamicPaintBrushSettings {
struct DynamicPaintModifierData *pmd; /* for fast RNA access */
struct DerivedMesh *dm;
struct ParticleSystem *psys;
- struct Material *mat;
int flags;
int collision;
diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h
index b4bc26f45cd..3d29c5b3833 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -116,23 +116,18 @@ typedef struct Image {
int lastframe;
/* texture page */
- short tpageflag, totbind;
- short xrep, yrep;
- short twsta, twend;
+ short tpageflag;
+ short pad2;
unsigned int bindcode[2]; /* only for current image... 2 = TEXTARGET_COUNT */
- char pad1[4];
- unsigned int *repbind; /* for repeat of parts of images */
-
+ unsigned int pad3;
+
struct PackedFile *packedfile DNA_DEPRECATED; /* deprecated */
struct ListBase packedfiles;
struct PreviewImage *preview;
- /* game engine tile animation */
- float lastupdate;
int lastused;
- short animspeed;
-
short ok;
+ short pad4[3];
/* for generated images */
int gen_x, gen_y;
@@ -168,7 +163,7 @@ enum {
#ifdef DNA_DEPRECATED
IMA_DO_PREMUL = (1 << 2), /* deprecated, should not be used */
#endif
- IMA_REFLECT = (1 << 4),
+ //IMA_REFLECT = (1 << 4), /* deprecated */
IMA_NOCOLLECT = (1 << 5),
//IMA_DONE_TAG = (1 << 6), // UNUSED
IMA_OLD_PREMUL = (1 << 7),
@@ -184,12 +179,12 @@ enum {
};
/* Image.tpageflag */
-#define IMA_TILES 1
-#define IMA_TWINANIM 2
-#define IMA_COLCYCLE 4 /* Depreciated */
+//#define IMA_TILES 1 /* Deprecated */
+//#define IMA_TWINANIM 2 /* Deprecated */
+#define IMA_COLCYCLE 4 /* Deprecated */
#define IMA_MIPMAP_COMPLETE 8 /* all mipmap levels in OpenGL texture set? */
-#define IMA_CLAMP_U 16
-#define IMA_CLAMP_V 32
+//#define IMA_CLAMP_U 16 /* Deprecated */
+//#define IMA_CLAMP_V 32 /* Deprecated */
#define IMA_TPAGE_REFRESH 64
#define IMA_GLBIND_IS_DATA 128 /* opengl image texture bound as non-color data */
diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h
index 92703fa2d3b..68453e5f189 100644
--- a/source/blender/makesdna/DNA_lamp_types.h
+++ b/source/blender/makesdna/DNA_lamp_types.h
@@ -67,42 +67,17 @@ typedef struct Lamp {
short pad2;
float clipsta, clipend;
- float bias, soft, compressthresh, bleedbias, bleedexp;
+ float bias, soft, bleedbias, bleedexp;
short bufsize, samp, buffers, filtertype;
char bufflag, buftype;
- short ray_samp, ray_sampy, ray_sampz;
- short ray_samp_type;
short area_shape;
float area_size, area_sizey, area_sizez;
- float adapt_thresh;
- short ray_samp_method;
- short shadowmap_type;
/* texact is for buttons */
short texact, shadhalostep;
- /* sun/sky */
- short sun_effect_type;
- short skyblendtype;
- float horizon_brightness;
- float spread;
- float sun_brightness;
- float sun_size;
- float backscattered_light;
- float sun_intensity;
- float atm_turbidity;
- float atm_inscattering_factor;
- float atm_extinction_factor;
- float atm_distance_factor;
- float skyblendfac;
- float sky_exposure;
- float shadow_frustum_size; /* BGE Only */
- short sky_colorspace;
- char pad4[2];
-
struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */
- struct MTex *mtex[18]; /* MAX_MTEX */
short pr_texture, use_nodes;
char pad6[4];
@@ -139,37 +114,28 @@ typedef struct Lamp {
/* mode */
#define LA_SHAD_BUF (1 << 0)
-#define LA_HALO (1 << 1)
-#define LA_LAYER (1 << 2)
-#define LA_QUAD (1 << 3) /* no longer used */
-#define LA_NEG (1 << 4)
-#define LA_ONLYSHADOW (1 << 5)
-#define LA_SPHERE (1 << 6)
+/* #define LA_HALO (1 << 1) */ /* not used anymore */
+/* #define LA_LAYER (1 << 2) */ /* not used anymore */
+/* #define LA_QUAD (1 << 3) */ /* not used anymore */
+/* #define LA_NEG (1 << 4) */ /* not used anymore */
+/* #define LA_ONLYSHADOW(1 << 5) */ /* not used anymore */
+/* #define LA_SPHERE (1 << 6) */ /* not used anymore */
#define LA_SQUARE (1 << 7)
-#define LA_TEXTURE (1 << 8)
-#define LA_OSATEX (1 << 9)
+/* #define LA_TEXTURE (1 << 8) */ /* not used anymore */
+/* #define LA_OSATEX (1 << 9) */ /* not used anymore */
/* #define LA_DEEP_SHADOW (1 << 10) */ /* not used anywhere */
-#define LA_NO_DIFF (1 << 11)
-#define LA_NO_SPEC (1 << 12)
+/* #define LA_NO_DIFF (1 << 11) */ /* not used anywhere */
+/* #define LA_NO_SPEC (1 << 12) */ /* not used anywhere */
#define LA_SHAD_RAY (1 << 13)
/* yafray: lamp shadowbuffer flag, softlight */
/* Since it is used with LOCAL lamp, can't use LA_SHAD */
-/* #define LA_YF_SOFT (1 << 14) */ /* no longer used */
-#define LA_LAYER_SHADOW (1 << 15)
-#define LA_SHAD_TEX (1 << 16)
+/* #define LA_YF_SOFT (1 << 14) */ /* not used anymore */
+/* #define LA_LAYER_SHADOW (1 << 15) */ /* not used anymore */
+/* #define LA_SHAD_TEX (1 << 16) */ /* not used anymore */
#define LA_SHOW_CONE (1 << 17)
-#define LA_SHOW_SHADOW_BOX (1 << 18)
+/* #define LA_SHOW_SHADOW_BOX (1 << 18) */
#define LA_SHAD_CONTACT (1 << 19)
-/* layer_shadow */
-#define LA_LAYER_SHADOW_BOTH 0
-#define LA_LAYER_SHADOW_CAST 1
-#define LA_LAYER_SHADOW_RECEIVE 2
-
-/* sun effect type*/
-#define LA_SUN_EFFECT_SKY 1
-#define LA_SUN_EFFECT_AP 2
-
/* falloff_type */
#define LA_FALLOFF_CONSTANT 0
#define LA_FALLOFF_INVLINEAR 1
@@ -178,47 +144,11 @@ typedef struct Lamp {
#define LA_FALLOFF_SLIDERS 4
#define LA_FALLOFF_INVCOEFFICIENTS 5
-
-/* buftype, no flag */
-#define LA_SHADBUF_REGULAR 0
-#define LA_SHADBUF_IRREGULAR 1
-#define LA_SHADBUF_HALFWAY 2
-#define LA_SHADBUF_DEEP 3
-
-/* bufflag, auto clipping */
-#define LA_SHADBUF_AUTO_START 1
-#define LA_SHADBUF_AUTO_END 2
-
-/* filtertype */
-#define LA_SHADBUF_BOX 0
-#define LA_SHADBUF_TENT 1
-#define LA_SHADBUF_GAUSS 2
-
/* area shape */
#define LA_AREA_SQUARE 0
#define LA_AREA_RECT 1
#define LA_AREA_CUBE 2
#define LA_AREA_BOX 3
-/* ray_samp_method */
-#define LA_SAMP_CONSTANT 0
-#define LA_SAMP_HALTON 1
-#define LA_SAMP_HAMMERSLEY 2
-
-
-/* ray_samp_type */
-// #define LA_SAMP_ROUND 1 // UNUSED
-#define LA_SAMP_UMBRA 2
-#define LA_SAMP_DITHER 4
-#define LA_SAMP_JITTER 8
-
-/* mapto */
-#define LAMAP_COL 1
-#define LAMAP_SHAD 2
-
-/* shadowmap_type */
-#define LA_SHADMAP_SIMPLE 0
-#define LA_SHADMAP_VARIANCE 1
-
#endif /* __DNA_LAMP_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index bc33b7ba6e2..564e6aee3fc 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -40,53 +40,17 @@
#define MAX_MTEX 18
#endif
-struct MTex;
struct Image;
-struct ColorBand;
-struct Group;
struct bNodeTree;
struct AnimData;
struct Ipo;
/* WATCH IT: change type? also make changes in ipo.h */
-typedef struct VolumeSettings {
- float density;
- float emission;
- float scattering;
- float reflection;
-
- float emission_col[3];
- float transmission_col[3];
- float reflection_col[3];
-
- float density_scale;
- float depth_cutoff;
- float asymmetry;
-
- short stepsize_type;
- short shadeflag;
- short shade_type;
- short precache_resolution;
-
- float stepsize;
- float ms_diff;
- float ms_intensity;
- float ms_spread;
-} VolumeSettings;
-
-/* Game Engine Options (old Texface mode, transp and flag) */
-typedef struct GameSettings {
- int flag;
- int alpha_blend;
- int face_orientation;
- int pad1;
-} GameSettings;
-
typedef struct TexPaintSlot {
struct Image *ima; /* image to be painted on */
char *uvname; /* customdata index for uv layer, MAX_NAME*/
- int index; /* index for mtex slot in material for blender internal */
+ int valid; /* do we have a valid image and UV map */
int pad;
} TexPaintSlot;
@@ -104,157 +68,51 @@ typedef struct Material {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
- short material_type, flag;
- /* note, keep this below synced with render_types.h */
+ short flag, pad1[7];
+
+ /* Colors from Blender Internal that we are still using. */
float r, g, b;
float specr, specg, specb;
- float mirr, mirg, mirb;
- float ambr, ambb, ambg;
- float amb, emit, ang, spectra, ray_mirror;
- float alpha, ref, spec, zoffs, add;
- float translucency;
- /* end synced with render_types.h */
-
- struct VolumeSettings vol;
- struct GameSettings game;
-
- float fresnel_mir, fresnel_mir_i;
- float fresnel_tra, fresnel_tra_i;
- float filter; /* filter added, for raytrace transparency and transmissivity */
- float tx_limit, tx_falloff;
- short ray_depth, ray_depth_tra;
- short har;
- char seed1, seed2;
-
- float gloss_mir, gloss_tra;
- short samp_gloss_mir, samp_gloss_tra;
- float adapt_thresh_mir, adapt_thresh_tra;
- float aniso_gloss_mir;
- float dist_mir;
- short fadeto_mir;
- short shade_flag; /* like Cubic interpolation */
-
- int mode, mode_l; /* mode_l is the or-ed result of all layer modes */
- int mode2, mode2_l; /* additional mode flags */
- short flarec, starc, linec, ringc;
- float hasize, flaresize, subsize, flareboost;
- float strand_sta, strand_end, strand_ease, strand_surfnor;
- float strand_min, strand_widthfade;
- char strand_uvname[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
-
- float sbias; /* shadow bias to prevent terminator prob */
- float lbias; /* factor to multiply lampbias with (0.0 = no mult) */
- float shad_alpha; /* in use for irregular shadowbuffer */
- int septex;
-
- /* for buttons and render*/
- char rgbsel, texact, pr_type, use_nodes;
- short pr_lamp, pr_texture, ml_flag; /* ml_flag is for disable base material */
-
- /* mapping */
- char mapflag, pad;
-
- /* shaders */
- short diff_shader, spec_shader;
- float roughness, refrac;
- /* XXX param[4] needs review and improvement (shader system as whole anyway)
- * This is nasty reused variable for different goals and not easy to RNAify nicely. -jesterKing */
- float param[4]; /* size, smooth, size, smooth, for toonshader, 0 (fac) and 1 (fresnel) also for fresnel shader */
- float rms;
- float darkness;
-
- /* runtime - OR'd from 'mtex' */
- short texco, mapto;
-
- /* ramp colors */
- struct ColorBand *ramp_col;
- struct ColorBand *ramp_spec;
- char rampin_col, rampin_spec;
- char rampblend_col, rampblend_spec;
- short ramp_show, pad3;
- float rampfac_col, rampfac_spec;
-
- struct MTex *mtex[18]; /* MAX_MTEX */
- struct bNodeTree *nodetree;
- struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */
- struct Group *group; /* light group */
- struct PreviewImage *preview;
+ float alpha, ray_mirror, spec, gloss_mir;
- /* dynamic properties */
- float friction, fh, reflect;
- float fhdist, xyfrict;
- short dynamode, pad2;
+ /* Ror buttons and render. */
+ char pr_type, use_nodes;
+ short pr_lamp, pr_texture;
- /* subsurface scattering */
- float sss_radius[3], sss_col[3];
- float sss_error, sss_scale, sss_ior;
- float sss_colfac, sss_texfac;
- float sss_front, sss_back;
- short sss_flag, sss_preset;
+ /* Index for render passes. */
+ short index;
- int mapto_textured; /* render-time cache to optimize texture lookups */
- short shadowonly_flag; /* "shadowsonly" type */
- short index; /* custom index for render passes */
+ struct bNodeTree *nodetree;
+ struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */
+ struct PreviewImage *preview;
- /* Freestyle line settings */
+ /* Freestyle line settings. */
float line_col[4];
short line_priority;
short vcol_alpha;
- /* texture painting */
+ /* Texture painting slots. */
short paint_active_slot;
short paint_clone_slot;
short tot_slots;
- short pad4[3];
-
- /* multiple tangent (Normal Map node) */
- char nmap_tangent_names[9][64]; /* [MAX_MTFACE+1][MAX_NAME]; +1 for empty name */
- int nmap_tangent_names_count, pad5;
+ short pad2[3];
- /* Transparency */
+ /* Transparency. */
float alpha_threshold;
float refract_depth;
char blend_method;
char blend_shadow;
char blend_flag;
- char pad6[5];
+ char pad3[5];
- /* image to use for image/uv space, also bake target
- * (not to be used shading/rendering pipeline, this is editor featyure only!). */
- struct Image *edit_image;
+ /* Cached slots for texture painting, must be refreshed in
+ * refresh_texpaint_image_cache before using. */
+ struct TexPaintSlot *texpaintslot;
- struct TexPaintSlot *texpaintslot; /* cached slot for painting. Make sure to recalculate before use
- * with refresh_texpaint_image_cache */
- ListBase gpumaterial; /* runtime */
+ /* Runtime cache for GLSL materials. */
+ ListBase gpumaterial;
} Material;
-
-/* **************** GAME PROPERTIES ********************* */
-// Blend Transparency Options - alpha_blend /* match GPU_material::GPUBlendMode */
-#define GEMAT_SOLID 0 /* GPU_BLEND_SOLID */
-#define GEMAT_ADD 1 /* GPU_BLEND_ADD */
-#define GEMAT_ALPHA 2 /* GPU_BLEND_ALPHA */
-#define GEMAT_CLIP 4 /* GPU_BLEND_CLIP */
-#define GEMAT_ALPHA_SORT 8 /* GPU_BLEND_ALPHA_SORT */
-#define GEMAT_ALPHA_TO_COVERAGE 16 /* GPU_BLEND_ALPHA_TO_COVERAGE */
-
-// Game Options - flag
-#define GEMAT_BACKCULL 16 /* KX_BACKCULL */
-#define GEMAT_SHADED 32 /* KX_LIGHT */
-#define GEMAT_TEXT 64 /* RAS_RENDER_3DPOLYGON_TEXT */
-#define GEMAT_NOPHYSICS 128
-#define GEMAT_INVISIBLE 256
-
-// Face Orientation Options - face_orientation
-#define GEMAT_NORMAL 0
-#define GEMAT_HALO 512 /* BILLBOARD_SCREENALIGNED */
-#define GEMAT_BILLBOARD 1024 /* BILLBOARD_AXISALIGNED */
-#define GEMAT_SHADOW 2048 /* SHADOW */
-
-// Use Textures - not defined directly in the UI
-#define GEMAT_TEX 4096 /* KX_TEX */
-
-
/* **************** MATERIAL ********************* */
/* maximum number of materials per material array.
@@ -263,12 +121,6 @@ typedef struct Material {
* -1 because for active material we store the index + 1 */
#define MAXMAT (32767-1)
-/* material_type */
-#define MA_TYPE_SURFACE 0
-#define MA_TYPE_HALO 1
-#define MA_TYPE_VOLUME 2
-#define MA_TYPE_WIRE 3
-
/* flag */
/* for render */
#define MA_IS_USED 1
@@ -280,101 +132,7 @@ typedef struct Material {
*/
#define MA_DS_SHOW_TEXS 4
-/* mode (is int) */
-#define MA_TRACEBLE 1
-#define MA_SHADOW 2
-#define MA_SHLESS 4
-#define MA_WIRE 8 /* deprecated */
-#define MA_VERTEXCOL 16
-#define MA_HALO_SOFT 16
-#define MA_HALO 32 /* deprecated */
-#define MA_ZTRANSP 64
-#define MA_VERTEXCOLP 128
-#define MA_ZINV 256
-#define MA_HALO_RINGS 256
-#define MA_ENV 512
-#define MA_HALO_LINES 512
-#define MA_ONLYSHADOW 1024
-#define MA_HALO_XALPHA 1024
-#define MA_STAR 0x800
-// #define MA_FACETEXTURE 0x800 /* deprecated */
-#define MA_HALOTEX 0x1000
-#define MA_HALOPUNO 0x2000
-#define MA_ONLYCAST 0x2000
-#define MA_NOMIST 0x4000
-#define MA_HALO_SHADE 0x4000
-#define MA_HALO_FLARE 0x8000
-#define MA_TRANSP 0x10000
-#define MA_RAYTRANSP 0x20000
-#define MA_RAYMIRROR 0x40000
-#define MA_SHADOW_TRA 0x80000
-#define MA_RAMP_COL 0x100000
-#define MA_RAMP_SPEC 0x200000
-#define MA_RAYBIAS 0x400000
-#define MA_FULL_OSA 0x800000
-#define MA_TANGENT_STR 0x1000000
-#define MA_SHADBUF 0x2000000
- /* note; we drop MA_TANGENT_STR later to become tangent_u */
-#define MA_TANGENT_V 0x4000000
-/* qdn: a bit clumsy this, tangents needed for normal maps separated from shading */
-#define MA_NORMAP_TANG 0x8000000
-#define MA_GROUP_NOLAY 0x10000000
-// #define MA_FACETEXTURE_ALPHA 0x20000000 /* deprecated */
-#define MA_STR_B_UNITS 0x40000000
-#define MA_STR_SURFDIFF 0x80000000
-
-#define MA_MODE_MASK 0x6fffffff /* all valid mode bits */
-#define MA_MODE_PIPELINE (MA_TRANSP | MA_ZTRANSP | MA_RAYTRANSP \
- | MA_TRACEBLE | MA_FULL_OSA | MA_ENV | MA_ZINV \
- | MA_ONLYCAST | MA_SHADBUF)
-
-/* mode2 (is int) */
-#define MA_CASTSHADOW (1 << 0)
-#define MA_MODE2_PIPELINE (MA_CASTSHADOW)
-#define MA_TANGENT_CONCRETE (1 << 1)
-
-/* mapflag */
-#define MA_MAPFLAG_UVPROJECT (1 << 0)
-
-/* ray mirror fadeout */
-#define MA_RAYMIR_FADETOSKY 0
-#define MA_RAYMIR_FADETOMAT 1
-
-/* shadowonly_flag */
-#define MA_SO_OLD 0
-#define MA_SO_SHADOW 1
-#define MA_SO_SHADED 2
-
-/* shade_flag */
-#define MA_CUBIC 1
-#define MA_OBCOLOR 2
-#define MA_APPROX_OCCLUSION 4
-#define MA_GROUP_LOCAL 8
-
-/* diff_shader */
-#define MA_DIFF_LAMBERT 0
-#define MA_DIFF_ORENNAYAR 1
-#define MA_DIFF_TOON 2
-#define MA_DIFF_MINNAERT 3
-#define MA_DIFF_FRESNEL 4
-
-/* spec_shader */
-#define MA_SPEC_COOKTORR 0
-#define MA_SPEC_PHONG 1
-#define MA_SPEC_BLINN 2
-#define MA_SPEC_TOON 3
-#define MA_SPEC_WARDISO 4
-
-/* dynamode */
-// #define MA_DRAW_DYNABUTS 1 /* deprecated */
-#define MA_FH_NOR 2
-
/* ramps */
-#define MA_RAMP_IN_SHADER 0
-#define MA_RAMP_IN_ENERGY 1
-#define MA_RAMP_IN_NOR 2
-#define MA_RAMP_IN_RESULT 3
-
#define MA_RAMP_BLEND 0
#define MA_RAMP_ADD 1
#define MA_RAMP_MULT 2
@@ -416,38 +174,7 @@ typedef struct Material {
/* mapto */
#define MAP_COL 1
-#define MAP_NORM 2
-#define MAP_COLSPEC 4
-#define MAP_COLMIR 8
-#define MAP_VARS (0xFFF0)
-#define MAP_REF 16
-#define MAP_SPEC 32
-#define MAP_EMIT 64
#define MAP_ALPHA 128
-#define MAP_HAR 256
-#define MAP_RAYMIRR 512
-#define MAP_TRANSLU 1024
-#define MAP_AMB 2048
-#define MAP_DISPLACE 4096
-#define MAP_WARP 8192
-// #define MAP_LAYER 16384 /* unused */
-
-/* volume mapto - reuse definitions for now - a bit naughty! */
-#define MAP_DENSITY 128
-#define MAP_EMISSION 64
-#define MAP_EMISSION_COL 1
-#define MAP_SCATTERING 16
-#define MAP_TRANSMISSION_COL 8
-#define MAP_REFLECTION_COL 4
-#define MAP_REFLECTION 32
-
-
-/* mapto for halo */
-//#define MAP_HA_COL 1
-//#define MAP_HA_ALPHA 128
-//#define MAP_HA_HAR 256
-//#define MAP_HA_SIZE 2
-//#define MAP_HA_ADD 64
/* pmapto */
/* init */
@@ -480,25 +207,6 @@ typedef struct Material {
#define MA_HAIR 10
#define MA_ATMOS 11
-/* sss_flag */
-#define MA_DIFF_SSS 1
-
-/* vol_stepsize_type */
-#define MA_VOL_STEP_RANDOMIZED 0
-#define MA_VOL_STEP_CONSTANT 1
-#define MA_VOL_STEP_ADAPTIVE 2
-
-/* vol_shadeflag */
-#define MA_VOL_RECV_EXT_SHADOW 1
-#define MA_VOL_PRECACHESHADING 8
-
-/* vol_shading_type */
-#define MA_VOL_SHADE_SHADELESS 0
-#define MA_VOL_SHADE_SHADOWED 2
-#define MA_VOL_SHADE_SHADED 1
-#define MA_VOL_SHADE_MULTIPLE 3
-#define MA_VOL_SHADE_SHADEDPLUSMULTIPLE 4
-
/* blend_method */
enum {
MA_BM_SOLID,
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index f3f507bf95a..d0753ce0e1e 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -420,7 +420,6 @@ typedef struct UVProjectModifierData {
/* the objects which do the projecting */
struct Object *projectors[10]; /* MOD_UVPROJECT_MAXPROJECTORS */
- struct Image *image; /* the image to project */
int pad2;
int num_projectors;
float aspectx, aspecty;
@@ -754,12 +753,21 @@ typedef enum {
eParticleInstanceFlag_UseSize = (1 << 7),
} ParticleInstanceModifierFlag;
+typedef enum {
+ eParticleInstanceSpace_World = 0,
+ eParticleInstanceSpace_Local = 1,
+} ParticleInstanceModifierSpace;
+
typedef struct ParticleInstanceModifierData {
ModifierData modifier;
struct Object *ob;
- short psys, flag, axis, pad;
+ short psys, flag, axis, space;
float position, random_position;
+ float rotation, random_rotation;
+ float particle_amount, particle_offset;
+ char index_layer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
+ char value_layer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
} ParticleInstanceModifierData;
typedef enum {
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 63eecebf44a..b5a3752072b 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -653,11 +653,6 @@ typedef struct NodeTwoFloats {
float x, y;
} NodeTwoFloats;
-typedef struct NodeGeometry {
- char uvname[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
- char colname[64];
-} NodeGeometry;
-
typedef struct NodeVertexCol {
char name[64];
} NodeVertexCol;
diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h
index e7ebd3b72d7..16c96073469 100644
--- a/source/blender/makesdna/DNA_object_force_types.h
+++ b/source/blender/makesdna/DNA_object_force_types.h
@@ -218,59 +218,6 @@ typedef struct SBVertex {
float vec[4];
} SBVertex;
-typedef struct BulletSoftBody {
- int flag; /* various boolean options */
- float linStiff; /* linear stiffness 0..1 */
- float angStiff; /* angular stiffness 0..1 */
- float volume; /* volume preservation 0..1 */
-
- int viterations; /* Velocities solver iterations */
- int piterations; /* Positions solver iterations */
- int diterations; /* Drift solver iterations */
- int citerations; /* Cluster solver iterations */
-
- float kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
- float kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
- float kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
- float kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
-
- float kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- float kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- float kVCF; /* Velocities correction factor (Baumgarte) */
- float kDP; /* Damping coefficient [0,1] */
-
- float kDG; /* Drag coefficient [0,+inf] */
- float kLF; /* Lift coefficient [0,+inf] */
- float kPR; /* Pressure coefficient [-inf,+inf] */
- float kVC; /* Volume conversation coefficient [0,+inf] */
-
- float kDF; /* Dynamic friction coefficient [0,1] */
- float kMT; /* Pose matching coefficient [0,1] */
- float kCHR; /* Rigid contacts hardness [0,1] */
- float kKHR; /* Kinetic contacts hardness [0,1] */
-
- float kSHR; /* Soft contacts hardness [0,1] */
- float kAHR; /* Anchors hardness [0,1] */
- int collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
- int numclusteriterations; /* number of iterations to refine collision clusters*/
- float welding; /* welding limit to remove duplicate/nearby vertices, 0.0..0.01 */
- float margin; /* margin specific to softbody */
-} BulletSoftBody;
-
-/* BulletSoftBody.flag */
-#define OB_BSB_SHAPE_MATCHING 2
-// #define OB_BSB_UNUSED 4
-#define OB_BSB_BENDING_CONSTRAINTS 8
-#define OB_BSB_AERO_VPOINT 16 /* aero model, Vertex normals are oriented toward velocity*/
-// #define OB_BSB_AERO_VTWOSIDE 32 /* aero model, Vertex normals are flipped to match velocity */
-
-/* BulletSoftBody.collisionflags */
-#define OB_BSB_COL_SDF_RS 2 /* SDF based rigid vs soft */
-#define OB_BSB_COL_CL_RS 4 /* Cluster based rigid vs soft */
-#define OB_BSB_COL_CL_SS 8 /* Cluster based soft vs soft */
-#define OB_BSB_COL_VF_SS 16 /* Vertex/Face based soft vs soft */
-
-
typedef struct SoftBody {
/* dynamic data */
int totpoint, totspring;
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 17dc7ebd2ad..25fec7aa726 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -212,9 +212,7 @@ typedef struct Object {
short transflag, protectflag; /* transformation settings and transform locks */
short trackflag, upflag;
short nlaflag; /* used for DopeSheet filtering settings (expanded/collapsed) */
- short scaflag; /* ui state for game logic */
- char scavisflag; /* more display settings for game logic */
- char pad;
+ short pad[2];
/* did last modifier stack generation need mapping support? */
char lastNeedMapping; /* bool */
@@ -223,39 +221,9 @@ typedef struct Object {
/* dupli-frame settings */
int dupon, dupoff, dupsta, dupend;
- /* during realtime */
-
- /* note that inertia is only called inertia for historical reasons
- * and is not changed to avoid DNA surgery. It actually reflects the
- * Size value in the GameButtons (= radius) */
-
- float mass, damping, inertia;
- /* The form factor k is introduced to give the user more control
- * and to fix incompatibility problems.
- * For rotational symmetric objects, the inertia value can be
- * expressed as: Theta = k * m * r^2
- * where m = Mass, r = Radius
- * For a Sphere, the form factor is by default = 0.4
- */
-
- float formfactor;
- float rdamping;
- float margin;
- float max_vel; /* clamp the maximum velocity 0.0 is disabled */
- float min_vel; /* clamp the minimum velocity 0.0 is disabled */
- float max_angvel; /* clamp the maximum angular velocity, 0.0 is disabled */
- float min_angvel; /* clamp the minimum angular velocity, 0.0 is disabled */
- float obstacleRad;
-
- /* "Character" physics properties */
- float step_height;
- float jump_speed;
- float fall_speed;
- unsigned char max_jumps;
- char pad2;
-
/* Depsgraph */
short base_flag; /* used by depsgraph, flushed from base */
+ short pad8;
/** Collision mask settings */
unsigned short col_group, col_mask;
@@ -270,11 +238,6 @@ typedef struct Object {
char empty_drawtype;
float empty_drawsize;
float dupfacesca; /* dupliface scale */
-
- ListBase prop; /* game logic property list (not to be confused with IDProperties) */
- ListBase sensors; /* game logic sensors */
- ListBase controllers; /* game logic controllers */
- ListBase actuators; /* game logic actuators */
float sf; /* sf is time-offset */
@@ -284,25 +247,22 @@ typedef struct Object {
unsigned char pad5[6];
float col[4]; /* object color */
- int gameflag;
- int gameflag2;
-
char restrictflag; /* for restricting view, select, render etc. accessible in outliner */
char pad3;
short softflag; /* softbody settings */
- float anisotropicFriction[3];
+ float pad9[3];
ListBase constraints; /* object constraints */
ListBase nlastrips DNA_DEPRECATED; // XXX deprecated... old animation system
ListBase hooks DNA_DEPRECATED; // XXX deprecated... old animation system
ListBase particlesystem; /* particle systems */
- struct BulletSoftBody *bsoft; /* settings for game engine bullet soft body */
struct PartDeflect *pd; /* particle deflector/attractor/collision data */
struct SoftBody *soft; /* if exists, saved in file */
struct Group *dup_group; /* object duplicator for group */
+ void *pad10;
- char body_type; /* for now used to temporarily holds the type of collision object */
+ char pad4;
char shapeflag; /* flag for pinning */
short shapenr; /* current shape key for menu or pinned */
float smoothresh; /* smoothresh is phong interpolation ray_shadow correction in render */
@@ -313,8 +273,6 @@ typedef struct Object {
void *pad7;
uint64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */
uint64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */
- unsigned int state; /* bit masks of game controllers that are active */
- unsigned int init_state; /* bit masks of initial state as recorded by the users */
/* Runtime valuated curve-specific data, not stored in the file */
struct CurveCache *curve_cache;
@@ -477,8 +435,6 @@ enum {
OB_NEGZ = 5,
};
-/* gameflag in game.h */
-
/* dt: no flags */
enum {
OB_BOUNDBOX = 1,
@@ -487,8 +443,6 @@ enum {
OB_MATERIAL = 4,
OB_TEXTURE = 5,
OB_RENDER = 6,
-
- OB_PAINT = 100, /* temporary used in draw code */
};
/* dtx: flags (short) */
@@ -581,84 +535,6 @@ enum {
/* collision masks */
#define OB_MAX_COL_MASKS 16
-/* ob->gameflag */
-enum {
- OB_DYNAMIC = 1 << 0,
- OB_CHILD = 1 << 1,
- OB_ACTOR = 1 << 2,
- OB_INERTIA_LOCK_X = 1 << 3,
- OB_INERTIA_LOCK_Y = 1 << 4,
- OB_INERTIA_LOCK_Z = 1 << 5,
- OB_DO_FH = 1 << 6,
- OB_ROT_FH = 1 << 7,
- OB_ANISOTROPIC_FRICTION = 1 << 8,
- OB_GHOST = 1 << 9,
- OB_RIGID_BODY = 1 << 10,
- OB_BOUNDS = 1 << 11,
-
- OB_COLLISION_RESPONSE = 1 << 12,
- OB_SECTOR = 1 << 13,
- OB_PROP = 1 << 14,
- OB_MAINACTOR = 1 << 15,
-
- OB_COLLISION = 1 << 16,
- OB_SOFT_BODY = 1 << 17,
- OB_OCCLUDER = 1 << 18,
- OB_SENSOR = 1 << 19,
- OB_NAVMESH = 1 << 20,
- OB_HASOBSTACLE = 1 << 21,
- OB_CHARACTER = 1 << 22,
-
- OB_RECORD_ANIMATION = 1 << 23,
-};
-
-/* ob->gameflag2 */
-enum {
- OB_NEVER_DO_ACTIVITY_CULLING = 1 << 0,
- OB_LOCK_RIGID_BODY_X_AXIS = 1 << 2,
- OB_LOCK_RIGID_BODY_Y_AXIS = 1 << 3,
- OB_LOCK_RIGID_BODY_Z_AXIS = 1 << 4,
- OB_LOCK_RIGID_BODY_X_ROT_AXIS = 1 << 5,
- OB_LOCK_RIGID_BODY_Y_ROT_AXIS = 1 << 6,
- OB_LOCK_RIGID_BODY_Z_ROT_AXIS = 1 << 7,
-
-/* OB_LIFE = OB_PROP | OB_DYNAMIC | OB_ACTOR | OB_MAINACTOR | OB_CHILD, */
-};
-
-/* ob->body_type */
-enum {
- OB_BODY_TYPE_NO_COLLISION = 0,
- OB_BODY_TYPE_STATIC = 1,
- OB_BODY_TYPE_DYNAMIC = 2,
- OB_BODY_TYPE_RIGID = 3,
- OB_BODY_TYPE_SOFT = 4,
- OB_BODY_TYPE_OCCLUDER = 5,
- OB_BODY_TYPE_SENSOR = 6,
- OB_BODY_TYPE_NAVMESH = 7,
- OB_BODY_TYPE_CHARACTER = 8,
-};
-
-/* ob->scavisflag */
-enum {
- OB_VIS_SENS = 1 << 0,
- OB_VIS_CONT = 1 << 1,
- OB_VIS_ACT = 1 << 2,
-};
-
-/* ob->scaflag */
-enum {
- OB_SHOWSENS = 1 << 6,
- OB_SHOWACT = 1 << 7,
- OB_ADDSENS = 1 << 8,
- OB_ADDCONT = 1 << 9,
- OB_ADDACT = 1 << 10,
- OB_SHOWCONT = 1 << 11,
- OB_ALLSTATE = 1 << 12,
- OB_INITSTBIT = 1 << 13,
- OB_DEBUGSTATE = 1 << 14,
- OB_SHOWSTATE = 1 << 15,
-};
-
/* ob->restrictflag */
enum {
OB_RESTRICT_VIEW = 1 << 0,
diff --git a/source/blender/makesdna/DNA_property_types.h b/source/blender/makesdna/DNA_property_types.h
deleted file mode 100644
index 77cd7c3e102..00000000000
--- a/source/blender/makesdna/DNA_property_types.h
+++ /dev/null
@@ -1,65 +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 DNA_property_types.h
- * \ingroup DNA
- * \since mar-2001
- * \author nzc
- * \attention Renderrecipe and scene decription. The fact that there is a
- * hierarchy here is a bit strange, and not desirable.
- *
- * #bProperty type is specifically for use by Objects game-logic.
- */
-
-#ifndef __DNA_PROPERTY_TYPES_H__
-#define __DNA_PROPERTY_TYPES_H__
-
-/* ********************* PROPERTY ************************ */
-
-typedef struct bProperty {
- struct bProperty *next, *prev;
- char name[64]; /* MAX_NAME */
- short type, flag;
- int data; /* data should be 4 bytes to store int,float stuff */
- void *poin; /* references data unless its a string which is malloc'd */
-
-} bProperty;
-
-/* property->type XXX Game Property, not RNA */
-#define GPROP_BOOL 0
-#define GPROP_INT 1
-#define GPROP_FLOAT 2
-#define GPROP_STRING 3
-// #define GPROP_VECTOR 4 // UNUSED
-#define GPROP_TIME 5
-
-/* property->flag */
-#define PROP_DEBUG 1
-
-#define MAX_PROPSTRING 128
-
-#endif /* __DNA_PROPERTY_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 4b27190d79f..e0f3ea32024 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -571,29 +571,14 @@ typedef struct RenderData {
float framelen, blurfac;
- /** For UR edge rendering: give the edges this color */
- float edgeR, edgeG, edgeB;
-
-
- /* standalone player */ // XXX deprecated since 2.5
- short fullscreen DNA_DEPRECATED, xplay DNA_DEPRECATED, yplay DNA_DEPRECATED;
- short freqplay DNA_DEPRECATED;
- /* standalone player */ // XXX deprecated since 2.5
- short depth DNA_DEPRECATED, attrib DNA_DEPRECATED;
-
-
int frame_step; /* frames to jump during render/playback */
short stereomode DNA_DEPRECATED; /* standalone player stereo settings */ // XXX deprecated since 2.5
short dimensionspreset; /* for the dimensions presets menu */
- short filtertype; /* filter is box, tent, gauss, mitch, etc */
-
short size; /* size in % */
- short maximsize DNA_DEPRECATED; /* max in Kb */
-
short pad6;
/* from buttons: */
@@ -607,15 +592,6 @@ typedef struct RenderData {
int ysch;
/**
- * The number of part to use in the x direction
- */
- short xparts DNA_DEPRECATED;
- /**
- * The number of part to use in the y direction
- */
- short yparts DNA_DEPRECATED;
-
- /**
* render tile dimensions
*/
int tilex, tiley;
@@ -640,22 +616,6 @@ typedef struct RenderData {
int mode;
/**
- * Flags for raytrace settings. Use bit-masking to access the settings.
- */
- int raytrace_options;
-
- /**
- * Raytrace acceleration structure
- */
- short raytrace_structure;
-
- short pad1;
-
- /* octree resolution */
- short ocres;
- short pad4;
-
- /**
* What to do with the sky/background. Picks sky/premul/key
* blending for the background
*/
@@ -666,7 +626,7 @@ typedef struct RenderData {
*/
short osa;
- short frs_sec, edgeint;
+ short frs_sec, pad[7];
/* safety, border and display rect */
@@ -676,9 +636,7 @@ typedef struct RenderData {
/* information on different layers to be rendered */
ListBase layers DNA_DEPRECATED; /* Converted to Scene->view_layers. */
short actlay DNA_DEPRECATED; /* Converted to Scene->active_layer. */
-
- /* number of mblur samples */
- short mblur_samples;
+ short pad1;
/**
* Adjustment factors for the aspect ratio in the x direction, was a short in 2.45
@@ -695,18 +653,13 @@ typedef struct RenderData {
/* color management settings - color profiles, gamma correction, etc */
int color_mgt_flag;
- /** post-production settings. deprecated, but here for upwards compat (initialized to 1) */
- float postgamma, posthue, postsat;
-
/* Dither noise intensity */
float dither_intensity;
/* Bake Render options */
- short bake_osa, bake_filter, bake_mode, bake_flag;
- short bake_normal_space, bake_quad_split;
- float bake_maxdist, bake_biasdist;
- short bake_samples, bake_pad;
- float bake_user_scale, bake_pad1;
+ short bake_mode, bake_flag;
+ short bake_filter, bake_samples;
+ float bake_biasdist, bake_user_scale;
/* path to render output */
char pic[1024]; /* 1024 = FILE_MAX */
@@ -729,35 +682,19 @@ typedef struct RenderData {
char pad5[5];
/* render simplify */
- int simplify_flag;
short simplify_subsurf;
short simplify_subsurf_render;
- short simplify_shadowsamples, pad9;
+ short pad9, pad10;
float simplify_particles;
float simplify_particles_render;
- float simplify_aosss;
-
- /* cineon */
- short cineonwhite DNA_DEPRECATED, cineonblack DNA_DEPRECATED; /*deprecated*/
- float cineongamma DNA_DEPRECATED; /*deprecated*/
-
- /* jpeg2000 */
- short jp2_preset DNA_DEPRECATED, jp2_depth DNA_DEPRECATED; /*deprecated*/
- int rpad3;
-
- /* Dome variables */ // XXX deprecated since 2.5
- short domeres DNA_DEPRECATED, domemode DNA_DEPRECATED; // XXX deprecated since 2.5
- short domeangle DNA_DEPRECATED, dometilt DNA_DEPRECATED; // XXX deprecated since 2.5
- float domeresbuf DNA_DEPRECATED; // XXX deprecated since 2.5
- float pad2;
- struct Text *dometext DNA_DEPRECATED; // XXX deprecated since 2.5
/* Freestyle line thickness options */
int line_thickness_mode;
float unit_line_thickness; /* in pixels */
/* render engine */
- char engine[32] DNA_DEPRECATED; // XXX deprecated since 2.8
+ char engine[32];
+ int pad2;
/* Cycles baking */
struct BakeData bake;
@@ -781,12 +718,6 @@ typedef struct RenderData {
} RenderData;
/* *************************************************************** */
-/* Settings related to viewport drawing/render, only settings used by WorkSpace and Scene. */
-typedef struct ViewRender {
- char engine_id[32];
-} ViewRender;
-
-/* *************************************************************** */
/* Render Conversion/Simplfication Settings */
/* control render convert and shading engine */
@@ -803,180 +734,6 @@ typedef struct RenderProfile {
} RenderProfile;
-/* *************************************************************** */
-/* Game Engine - Dome */
-
-typedef struct GameDome {
- short res, mode;
- short angle, tilt;
- float resbuf, pad2;
- struct Text *warptext;
-} GameDome;
-
-/* GameDome.mode */
-#define DOME_FISHEYE 1
-#define DOME_TRUNCATED_FRONT 2
-#define DOME_TRUNCATED_REAR 3
-#define DOME_ENVMAP 4
-#define DOME_PANORAM_SPH 5
-#define DOME_NUM_MODES 6
-
-/* *************************************************************** */
-/* Game Engine */
-
-typedef struct GameFraming {
- float col[3];
- char type, pad1, pad2, pad3;
-} GameFraming;
-
-/* GameFraming.type */
-#define SCE_GAMEFRAMING_BARS 0
-#define SCE_GAMEFRAMING_EXTEND 1
-#define SCE_GAMEFRAMING_SCALE 2
-
-typedef struct RecastData {
- float cellsize;
- float cellheight;
- float agentmaxslope;
- float agentmaxclimb;
- float agentheight;
- float agentradius;
- float edgemaxlen;
- float edgemaxerror;
- float regionminsize;
- float regionmergesize;
- int vertsperpoly;
- float detailsampledist;
- float detailsamplemaxerror;
- char partitioning;
- char pad1;
- short pad2;
-} RecastData;
-
-/* RecastData.partitioning */
-#define RC_PARTITION_WATERSHED 0
-#define RC_PARTITION_MONOTONE 1
-#define RC_PARTITION_LAYERS 2
-
-typedef struct GameData {
-
- /* standalone player */
- struct GameFraming framing;
- short playerflag, xplay, yplay, freqplay;
- short depth, attrib, rt1, rt2;
- short aasamples, pad4[3];
-
- /* stereo/dome mode */
- struct GameDome dome;
- short stereoflag, stereomode;
- float eyeseparation;
- RecastData recastData;
-
-
- /* physics (it was in world)*/
- float gravity; /*Gravitation constant for the game world*/
-
- /*
- * Radius of the activity bubble, in Manhattan length. Objects
- * outside the box are activity-culled. */
- float activityBoxRadius;
-
- /*
- * bit 3: (gameengine): Activity culling is enabled.
- * bit 5: (gameengine) : enable Bullet DBVT tree for view frustum culling
- */
- int flag;
- short mode, matmode;
- short occlusionRes; /* resolution of occlusion Z buffer in pixel */
- short physicsEngine;
- short exitkey;
- short vsync; /* Controls vsync: off, on, or adaptive (if supported) */
- short ticrate, maxlogicstep, physubstep, maxphystep;
- short obstacleSimulation;
- short raster_storage;
- float levelHeight;
- float deactivationtime, lineardeactthreshold, angulardeactthreshold;
-
- /* Scene LoD */
- short lodflag, pad2;
- int scehysteresis, pad5;
-
-} GameData;
-
-/* GameData.stereoflag */
-#define STEREO_NOSTEREO 1
-#define STEREO_ENABLED 2
-#define STEREO_DOME 3
-
-/* GameData.stereomode */
-//#define STEREO_NOSTEREO 1
-#define STEREO_QUADBUFFERED 2
-#define STEREO_ABOVEBELOW 3
-#define STEREO_INTERLACED 4
-#define STEREO_ANAGLYPH 5
-#define STEREO_SIDEBYSIDE 6
-#define STEREO_VINTERLACE 7
-//#define STEREO_DOME 8
-#define STEREO_3DTVTOPBOTTOM 9
-
-/* GameData.physicsEngine */
-#define WOPHY_NONE 0
-#define WOPHY_BULLET 5
-
-/* obstacleSimulation */
-#define OBSTSIMULATION_NONE 0
-#define OBSTSIMULATION_TOI_rays 1
-#define OBSTSIMULATION_TOI_cells 2
-
-/* GameData.raster_storage */
-#define RAS_STORE_AUTO 0
-/* #define RAS_STORE_IMMEDIATE 1 */ /* DEPRECATED */
-#define RAS_STORE_VA 2
-#define RAS_STORE_VBO 3
-
-/* GameData.vsync */
-#define VSYNC_ON 0
-#define VSYNC_OFF 1
-#define VSYNC_ADAPTIVE 2
-
-/* GameData.flag */
-#define GAME_RESTRICT_ANIM_UPDATES (1 << 0)
-#define GAME_ENABLE_ALL_FRAMES (1 << 1)
-#define GAME_SHOW_DEBUG_PROPS (1 << 2)
-#define GAME_SHOW_FRAMERATE (1 << 3)
-#define GAME_SHOW_PHYSICS (1 << 4)
-// #define GAME_DISPLAY_LISTS (1 << 5) /* deprecated */
-#define GAME_GLSL_NO_LIGHTS (1 << 6)
-#define GAME_GLSL_NO_SHADERS (1 << 7)
-#define GAME_GLSL_NO_SHADOWS (1 << 8)
-#define GAME_GLSL_NO_RAMPS (1 << 9)
-#define GAME_GLSL_NO_NODES (1 << 10)
-#define GAME_GLSL_NO_EXTRA_TEX (1 << 11)
-#define GAME_IGNORE_DEPRECATION_WARNINGS (1 << 12)
-#define GAME_ENABLE_ANIMATION_RECORD (1 << 13)
-#define GAME_SHOW_MOUSE (1 << 14)
-#define GAME_GLSL_NO_COLOR_MANAGEMENT (1 << 15)
-#define GAME_SHOW_OBSTACLE_SIMULATION (1 << 16)
-#define GAME_NO_MATERIAL_CACHING (1 << 17)
-#define GAME_GLSL_NO_ENV_LIGHTING (1 << 18)
-/* Note: GameData.flag is now an int (max 32 flags). A short could only take 16 flags */
-
-/* GameData.playerflag */
-#define GAME_PLAYER_FULLSCREEN (1 << 0)
-#define GAME_PLAYER_DESKTOP_RESOLUTION (1 << 1)
-
-/* GameData.matmode */
-enum {
-#ifdef DNA_DEPRECATED
- GAME_MAT_TEXFACE = 0, /* deprecated */
-#endif
- GAME_MAT_MULTITEX = 1,
- GAME_MAT_GLSL = 2,
-};
-
-/* GameData.lodflag */
-#define SCE_LOD_USE_HYST (1 << 0)
-
/* UV Paint */
/* ToolSettings.uv_sculpt_settings */
#define UV_SCULPT_LOCK_BORDERS 1
@@ -1524,37 +1281,10 @@ typedef struct ToolSettings {
/* Multires */
char multires_subdiv_type;
- /* Skeleton generation */
- short skgen_resolution;
- float skgen_threshold_internal;
- float skgen_threshold_external;
- float skgen_length_ratio;
- float skgen_length_limit;
- float skgen_angle_limit;
- float skgen_correlation_limit;
- float skgen_symmetry_limit;
- float skgen_retarget_angle_weight;
- float skgen_retarget_length_weight;
- float skgen_retarget_distance_weight;
- short skgen_options;
- char skgen_postpro;
- char skgen_postpro_passes;
- char skgen_subdivisions[3];
- char skgen_multi_level;
-
- /* Skeleton Sketching */
- struct Object *skgen_template;
- char bone_sketching;
- char bone_sketching_convert;
- char skgen_subdivision_number;
- char skgen_retarget_options;
- char skgen_retarget_roll;
- char skgen_side_string[8];
- char skgen_num_string[8];
-
/* Alt+RMB option */
char edge_mode;
char edge_mode_live_unwrap;
+ char _pad1;
/* Transform */
char snap_mode, snap_node_mode;
@@ -1574,10 +1304,11 @@ typedef struct ToolSettings {
char vgroupsubset; /* subset selection filter in wpaint */
/* UV painting */
- int use_uv_sculpt;
- int uv_sculpt_settings;
- int uv_sculpt_tool;
- int uv_relax_method;
+ char _pad2[2];
+ char use_uv_sculpt;
+ char uv_sculpt_settings;
+ char uv_sculpt_tool;
+ char uv_relax_method;
/* XXX: these sculpt_paint_* fields are deprecated, use the
* unified_paint_settings field instead! */
short sculpt_paint_settings DNA_DEPRECATED; short pad5;
@@ -1681,7 +1412,10 @@ typedef struct Scene {
struct AudioData audio;
ListBase markers;
- ListBase transform_spaces DNA_DEPRECATED;
+ ListBase transform_spaces;
+
+ int orientation_index_custom;
+ int orientation_type;
void *sound_scene;
void *playback_handle;
@@ -1697,10 +1431,6 @@ typedef struct Scene {
/* User-Defined KeyingSets */
int active_keyingset; /* index of the active KeyingSet. first KeyingSet has index 1, 'none' active is 0, 'add new' is -1 */
ListBase keyingsets; /* KeyingSets for this scene */
-
- /* Game Settings */
- struct GameFraming framing DNA_DEPRECATED; // XXX deprecated since 2.5
- struct GameData gm;
/* Units */
struct UnitSettings unit;
@@ -1734,10 +1464,6 @@ typedef struct Scene {
IDProperty *collection_properties; /* settings to be overriden by layer collections */
IDProperty *layer_properties; /* settings to be override by workspaces */
-
- int pad5[2];
-
- ViewRender view_render;
} Scene;
/* **************** RENDERDATA ********************* */
@@ -1751,25 +1477,25 @@ typedef struct Scene {
/* RenderData.mode */
#define R_OSA 0x0001
-#define R_SHADOW 0x0002
-#define R_GAMMA 0x0004
-#define R_ORTHO 0x0008
-#define R_ENVMAP 0x0010
-#define R_EDGE 0x0020
-#define R_FIELDS 0x0040
-#define R_FIELDSTILL 0x0080
+/* #define R_SHADOW 0x0002 */
+/* #define R_GAMMA 0x0004 */
+#define R_ORTHO 0x0008
+/* #define R_ENVMAP 0x0010 */
+/* #define R_EDGE 0x0020 */
+/* #define R_FIELDS 0x0040 */
+/*#define R_FIELDSTILL 0x0080 */
/*#define R_RADIO 0x0100 */ /* deprecated */
#define R_BORDER 0x0200
-#define R_PANORAMA 0x0400 /* deprecated as scene option, still used in renderer */
+#define R_PANORAMA 0x0400
#define R_CROP 0x0800
/* Disable camera switching: runtime (DURIAN_CAMERA_SWITCH) */
#define R_NO_CAMERA_SWITCH 0x1000
-#define R_ODDFIELD 0x2000
+/* #define R_ODDFIELD 0x2000 */
#define R_MBLUR 0x4000
/* unified was here */
-#define R_RAYTRACE 0x10000
+/* #define R_RAYTRACE 0x10000 */
/* R_GAUSS is obsolete, but used to retrieve setting from old files */
-#define R_GAUSS 0x20000
+/* #define R_GAUSS 0x20000 */
/* fbuf obsolete... */
/*#define R_FBUF 0x40000*/
/* threads obsolete... is there for old files, now use for autodetect threads */
@@ -1777,14 +1503,14 @@ typedef struct Scene {
/* Use the same flag for autothreads */
#define R_FIXED_THREADS 0x80000
-#define R_SPEED 0x100000
-#define R_SSS 0x200000
+/* #define R_SPEED 0x100000 */
+/* #define R_SSS 0x200000 */
#define R_NO_OVERWRITE 0x400000 /* skip existing files */
#define R_TOUCH 0x800000 /* touch files before rendering */
#define R_SIMPLIFY 0x1000000
#define R_EDGE_FRS 0x2000000 /* R_EDGE reserved for Freestyle */
#define R_PERSISTENT_DATA 0x4000000 /* keep data around for re-render */
-#define R_USE_WS_SHADING 0x8000000 /* use world space interpretation of lighting data */
+/* #define R_USE_WS_SHADING 0x8000000 */ /* use world space interpretation of lighting data */
/* RenderData.seq_flag */
enum {
@@ -1801,7 +1527,7 @@ enum {
#define R_OUTPUT_NONE 3
/*#define R_OUTPUT_FORKED 4*/
-/* RenderData.filtertype */
+/* RenderData.filtertype (used for nodes) */
#define R_FILTER_BOX 0
#define R_FILTER_TENT 1
#define R_FILTER_QUAD 2
@@ -1809,19 +1535,7 @@ enum {
#define R_FILTER_CATROM 4
#define R_FILTER_GAUSS 5
#define R_FILTER_MITCH 6
-#define R_FILTER_FAST_GAUSS 7 /* note, this is only used for nodes at the moment */
-
-/* RenderData.raytrace_structure */
-#define R_RAYSTRUCTURE_AUTO 0
-#define R_RAYSTRUCTURE_OCTREE 1
-#define R_RAYSTRUCTURE_BLIBVH 2 /* removed */
-#define R_RAYSTRUCTURE_VBVH 3
-#define R_RAYSTRUCTURE_SIMD_SVBVH 4 /* needs SIMD */
-#define R_RAYSTRUCTURE_SIMD_QBVH 5 /* needs SIMD */
-
-/* RenderData.raytrace_options */
-#define R_RAYTRACE_USE_LOCAL_COORDS 0x0001
-#define R_RAYTRACE_USE_INSTANCES 0x0002
+#define R_FILTER_FAST_GAUSS 7
/* RenderData.scemode (int now) */
#define R_DOSEQ 0x0001
@@ -1833,12 +1547,12 @@ enum {
#define R_MATNODE_PREVIEW 0x0020
#define R_DOCOMP 0x0040
#define R_COMP_CROP 0x0080
-#define R_FREE_IMAGE 0x0100
+/* #define R_FREE_IMAGE 0x0100 */
#define R_SINGLE_LAYER 0x0200
#define R_EXR_TILE_FILE 0x0400
/* #define R_COMP_FREE 0x0800 */
#define R_NO_IMAGE_LOAD 0x1000
-#define R_NO_TEX 0x2000
+/* #define R_NO_TEX 0x2000 */
#define R_NO_FRAME_UPDATE 0x4000
#define R_FULL_SAMPLE 0x8000
/* #define R_DEPRECATED 0x10000 */
@@ -1901,12 +1615,12 @@ enum {
/* bake_mode: same as RE_BAKE_xxx defines */
/* RenderData.bake_flag */
#define R_BAKE_CLEAR 1
-#define R_BAKE_OSA 2
+/* #define R_BAKE_OSA 2 */ /* deprecated */
#define R_BAKE_TO_ACTIVE 4
-#define R_BAKE_NORMALIZE 8
+/* #define R_BAKE_NORMALIZE 8 */ /* deprecated */
#define R_BAKE_MULTIRES 16
#define R_BAKE_LORES_MESH 32
-#define R_BAKE_VCOL 64
+/* #define R_BAKE_VCOL 64 */ /* deprecated */
#define R_BAKE_USERSCALE 128
#define R_BAKE_CAGE 256
#define R_BAKE_SPLIT_MAT 512
@@ -1918,9 +1632,6 @@ enum {
#define R_BAKE_SPACE_OBJECT 2
#define R_BAKE_SPACE_TANGENT 3
-/* RenderData.simplify_flag */
-#define R_SIMPLE_NO_TRIANGULATE 1
-
/* RenderData.line_thickness_mode */
#define R_LINE_THICKNESS_ABSOLUTE 1
#define R_LINE_THICKNESS_RELATIVE 2
@@ -1928,10 +1639,9 @@ enum {
/* sequencer seq_prev_type seq_rend_type */
/* RenderData.engine (scene.c) */
-extern const char *RE_engine_id_BLENDER_RENDER;
-extern const char *RE_engine_id_BLENDER_GAME;
extern const char *RE_engine_id_BLENDER_CLAY;
extern const char *RE_engine_id_BLENDER_EEVEE;
+extern const char *RE_engine_id_BLENDER_WORKBENCH;
extern const char *RE_engine_id_CYCLES;
/* **************** SCENE ********************* */
@@ -2311,15 +2021,6 @@ typedef enum eGPencil_Placement_Flags {
#define BONE_SKETCHING_QUICK 2
#define BONE_SKETCHING_ADJUST 4
-/* ToolSettings.bone_sketching_convert */
-#define SK_CONVERT_CUT_FIXED 0
-#define SK_CONVERT_CUT_LENGTH 1
-#define SK_CONVERT_CUT_ADAPTATIVE 2
-#define SK_CONVERT_RETARGET 3
-
-/* ToolSettings.skgen_retarget_options */
-#define SK_RETARGET_AUTONAME 1
-
/* ToolSettings.skgen_retarget_roll */
#define SK_RETARGET_ROLL_NONE 0
#define SK_RETARGET_ROLL_VIEW 1
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 46eb0cbade3..6d4494ca2d2 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -48,12 +48,19 @@ struct wmTimer;
struct wmTooltipState;
+/* TODO Doing this is quite ugly :)
+ * Once the top-bar is merged bScreen should be refactored to use ScrAreaMap. */
+#define AREAMAP_FROM_SCREEN(screen) ((ScrAreaMap *)&(screen)->vertbase)
+
typedef struct bScreen {
ID id;
-
+
+ /* TODO Should become ScrAreaMap now.
+ * ** NOTE: KEEP ORDER IN SYNC WITH ScrAreaMap! (see AREAMAP_FROM_SCREEN macro above) ** */
ListBase vertbase; /* screens have vertices/edges to define areas */
ListBase edgebase;
ListBase areabase;
+
ListBase regionbase; /* screen level regions (menus), runtime only */
struct Scene *scene DNA_DEPRECATED;
@@ -98,6 +105,14 @@ typedef struct ScrEdge {
int pad;
} ScrEdge;
+typedef struct ScrAreaMap {
+ /* ** NOTE: KEEP ORDER IN SYNC WITH LISTBASES IN bScreen! ** */
+
+ ListBase vertbase; /* ScrVert - screens have vertices/edges to define areas */
+ ListBase edgebase; /* ScrEdge */
+ ListBase areabase; /* ScrArea */
+} ScrAreaMap;
+
typedef struct Panel { /* the part from uiBlock that needs saved in file */
struct Panel *next, *prev;
@@ -211,6 +226,23 @@ typedef struct uiPreview { /* some preview UI data need to be saved in
short pad1[3];
} uiPreview;
+/* These two lines with # tell makesdna this struct can be excluded.
+ * Should be: #ifndef WITH_TOPBAR_WRITING */
+#
+#
+typedef struct ScrGlobalAreaData {
+ /* Global areas have a non-dynamic size. That means, changing the window
+ * size doesn't affect their size at all. However, they can still be
+ * 'collapsed', by changing this value. Ignores DPI (ED_area_global_size_y
+ * and winx/winy don't) */
+ short cur_fixed_height;
+ /* For global areas, this is the min and max size they can use depending on
+ * if they are 'collapsed' or not. Value is set on area creation and not
+ * touched afterwards. */
+ short size_min, size_max;
+ short pad;
+} ScrGlobalAreaData;
+
typedef struct ScrArea {
struct ScrArea *next, *prev;
@@ -221,7 +253,7 @@ typedef struct ScrArea {
char spacetype, butspacetype; /* SPACE_..., butspacetype is button arg */
short winx, winy; /* size */
-
+
short headertype; /* OLD! 0=no header, 1= down, 2= up */
short do_refresh; /* private, for spacetype refresh callback */
short flag;
@@ -231,6 +263,9 @@ typedef struct ScrArea {
struct SpaceType *type; /* callbacks for this space type */
+ /* Non-NULL if this area is global. */
+ ScrGlobalAreaData *global;
+
/* A list of space links (editors) that were open in this area before. When
* changing the editor type, we try to reuse old editor data from this list.
* The first item is the active/visible one.
@@ -295,7 +330,11 @@ enum {
HEADER_NO_PULLDOWN = (1 << 0),
// AREA_FLAG_DEPRECATED_1 = (1 << 1),
// AREA_FLAG_DEPRECATED_2 = (1 << 2),
- AREA_TEMP_INFO = (1 << 3),
+#ifdef DNA_DEPRECATED_ALLOW
+ AREA_TEMP_INFO = (1 << 3), /* versioned to make slot reusable */
+#endif
+ /* update size of regions within the area */
+ AREA_FLAG_REGION_SIZE_UPDATE = (1 << 3),
// AREA_FLAG_DEPRECATED_4 = (1 << 4),
// AREA_FLAG_DEPRECATED_5 = (1 << 5),
/* used to check if we should switch back to prevspace (of a different type) */
@@ -413,8 +452,19 @@ enum {
#define RGN_SPLIT_PREV 32
/* region flag */
-#define RGN_FLAG_HIDDEN 1
-#define RGN_FLAG_TOO_SMALL 2
+enum {
+ RGN_FLAG_HIDDEN = (1 << 0),
+ RGN_FLAG_TOO_SMALL = (1 << 1),
+ /* Force delayed reinit of region size data, so that region size is calculated
+ * just big enough to show all its content (if enough space is available).
+ * Note that only ED_region_header supports this right now. */
+ RGN_FLAG_DYNAMIC_SIZE = (1 << 2),
+ /* The region width stored in ARegion.sizex already has the DPI
+ * factor applied, skip applying it again (in region_rect_recursive).
+ * XXX Not nice at all. Leaving for now as temporary solution, but
+ * it might cause issues if we change how ARegion.sizex is used... */
+ RGN_SIZEX_DPI_APPLIED = (1 << 3),
+};
/* region do_draw */
#define RGN_DRAW 1
diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h
deleted file mode 100644
index 37064854920..00000000000
--- a/source/blender/makesdna/DNA_sensor_types.h
+++ /dev/null
@@ -1,334 +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 DNA_sensor_types.h
- * \ingroup DNA
- * \since mar-2001
- * \author nzc
- *
- * #bSensor type is specifically for use by Object logic-bricks in the game-engine.
- */
-
-#ifndef __DNA_SENSOR_TYPES_H__
-#define __DNA_SENSOR_TYPES_H__
-
-struct Object;
-struct Material;
-
-/* ****************** SENSORS ********************* */
-
-typedef struct bNearSensor {
- char name[64]; /* MAX_NAME */
- float dist, resetdist;
- int lastval, pad;
-} bNearSensor;
-
-/**
- * Defines the settings of a mouse sensor.
- */
-typedef struct bMouseSensor {
- /**
- * The type of key this sensor listens to.
- */
- short type;
- short flag;
- short pad1;
- short mode; /* flag to choose material or property */
- char propname[64];
- char matname[64];
-} bMouseSensor;
-
-/* DEPRECATED */
-typedef struct bTouchSensor {
- char name[64]; /* MAX_NAME */
- struct Material *ma;
- float dist, pad;
-} bTouchSensor;
-
-typedef struct bKeyboardSensor {
- short key, qual;
- short type, qual2;
- /**
- * Name of the target property
- */
- char targetName[64]; /* MAX_NAME */
- /**
- * Name of the toggle property
- */
- char toggleName[64]; /* MAX_NAME */
-} bKeyboardSensor;
-
-typedef struct bPropertySensor {
- int type;
- int pad;
- char name[64]; /* MAX_NAME */
- char value[64];
- char maxvalue[64];
-} bPropertySensor;
-
-typedef struct bActuatorSensor {
- int type;
- int pad;
- char name[64]; /* MAX_NAME */
-} bActuatorSensor;
-
-typedef struct bDelaySensor {
- short delay;
- short duration;
- short flag;
- short pad;
-} bDelaySensor;
-
-typedef struct bCollisionSensor {
- char name[64]; /* property name. MAX_NAME */
- char materialName[64]; /* material */
- // struct Material *ma; // XXX remove materialName
- short damptimer, damp;
- short mode; /* flag to choose material or property */
- short pad2;
-} bCollisionSensor;
-
-typedef struct bRadarSensor {
- char name[64]; /* MAX_NAME */
- float angle;
- float range;
- short flag, axis;
-} bRadarSensor;
-
-typedef struct bRandomSensor {
- char name[64]; /* MAX_NAME */
- int seed;
- int delay;
-} bRandomSensor;
-
-typedef struct bRaySensor {
- char name[64]; /* MAX_NAME */
- float range;
- char propname[64];
- char matname[64];
- //struct Material *ma; // XXX remove materialName
- short mode;
- short pad1;
- int axisflag;
-} bRaySensor;
-
-typedef struct bArmatureSensor {
- char posechannel[64]; /* MAX_NAME */
- char constraint[64]; /* MAX_NAME */
- int type;
- float value;
-} bArmatureSensor;
-
-typedef struct bMessageSensor {
- /**
- * (Possible future use) pointer to a single sender object
- */
- struct Object *fromObject;
-
- /**
- * Can be used to filter on subjects like this
- */
- char subject[64];
-
- /**
- * (Possible future use) body to filter on
- */
- char body[64];
-} bMessageSensor;
-
-typedef struct bSensor {
- struct bSensor *next, *prev;
- /* pulse and freq are the bool toggle and frame count for pulse mode */
- short type, otype, flag, pulse;
- short freq, totlinks, pad1, pad2; /* freq makes reference to skipped ticks between 2 active pulses */
- char name[64]; /* MAX_NAME */
- void *data;
-
- struct bController **links;
-
- struct Object *ob;
-
- /* just add here, to avoid align errors... */
- short invert; /* Whether or not to invert the output. */
- short level; /* Whether the sensor is level base (edge by default) */
- short tap;
- short pad;
-} bSensor;
-
-typedef struct bJoystickSensor {
- char name[64]; /* MAX_NAME */
- char type;
- char joyindex;
- short flag;
- short axis;
- short axis_single;
- int axisf;
- int button;
- int hat;
- int hatf;
- int precision;
-} bJoystickSensor;
-
-/* bMouseSensor->type: uses blender event defines */
-
-/* bMouseSensor->flag: only pulse for now */
-#define SENS_MOUSE_FOCUS_PULSE 1
-
-/* propertysensor->type */
-#define SENS_PROP_EQUAL 0
-#define SENS_PROP_NEQUAL 1
-#define SENS_PROP_INTERVAL 2
-#define SENS_PROP_CHANGED 3
-#define SENS_PROP_EXPRESSION 4
-#define SENS_PROP_LESSTHAN 5
-#define SENS_PROP_GREATERTHAN 6
-
-/* raysensor->axisflag */
-/* flip x and y to make y default!!! */
-#define SENS_RAY_X_AXIS 1
-#define SENS_RAY_Y_AXIS 0
-#define SENS_RAY_Z_AXIS 2
-#define SENS_RAY_NEG_X_AXIS 3
-#define SENS_RAY_NEG_Y_AXIS 4
-#define SENS_RAY_NEG_Z_AXIS 5
-//#define SENS_RAY_NEGATIVE_AXIS 1
-
-/* bRadarSensor->axis */
-#define SENS_RADAR_X_AXIS 0
-#define SENS_RADAR_Y_AXIS 1
-#define SENS_RADAR_Z_AXIS 2
-#define SENS_RADAR_NEG_X_AXIS 3
-#define SENS_RADAR_NEG_Y_AXIS 4
-#define SENS_RADAR_NEG_Z_AXIS 5
-
-/* bMessageSensor->type */
-#define SENS_MESG_MESG 0
-#define SENS_MESG_PROP 1
-
-/* bArmatureSensor->type */
-#define SENS_ARM_STATE_CHANGED 0
-#define SENS_ARM_LIN_ERROR_BELOW 1
-#define SENS_ARM_LIN_ERROR_ABOVE 2
-#define SENS_ARM_ROT_ERROR_BELOW 3
-#define SENS_ARM_ROT_ERROR_ABOVE 4
-/* update this when adding new type */
-#define SENS_ARM_MAXTYPE 4
-
-/* sensor->type */
-#define SENS_ALWAYS 0
-#define SENS_TOUCH 1 /* DEPRECATED */
-#define SENS_NEAR 2
-#define SENS_KEYBOARD 3
-#define SENS_PROPERTY 4
-#define SENS_MOUSE 5
-#define SENS_COLLISION 6
-#define SENS_RADAR 7
-#define SENS_RANDOM 8
-#define SENS_RAY 9
-#define SENS_MESSAGE 10
-#define SENS_JOYSTICK 11
-#define SENS_ACTUATOR 12
-#define SENS_DELAY 13
-#define SENS_ARMATURE 14
-/* sensor->flag */
-#define SENS_SHOW 1
-#define SENS_DEL 2
-#define SENS_NEW 4
-#define SENS_NOT 8
-#define SENS_VISIBLE 16
-#define SENS_PIN 32
-#define SENS_DEACTIVATE 64
-
-/* sensor->pulse */
-#define SENS_PULSE_CONT 0
-#define SENS_PULSE_REPEAT 1
-//#define SENS_PULSE_ONCE 2
-#define SENS_NEG_PULSE_MODE 4
-
-/* sensor->suppress */
-#define SENS_SUPPRESS_POSITIVE (1 << 0)
-#define SENS_SUPPRESS_NEGATIVE (1 << 1)
-
-/* collision, ray sensor modes: */
-/* A little bit fake: when property is active, the first bit is
- * reset. Bite me :) So we don't actually use it, so we comment it out
- * ... The reason for this is that we need to be backward compatible,
- * and have a proper default value for this thing.
- * */
-#define SENS_COLLISION_PROPERTY 0
-#define SENS_COLLISION_MATERIAL 1
-#define SENS_COLLISION_PULSE 2
-
-/* ray specific mode */
-/* X-Ray means that the ray will traverse objects that don't have the property/material */
-#define SENS_RAY_PROPERTY 0
-#define SENS_RAY_MATERIAL 1
-#define SENS_RAY_XRAY 2
-
-/* Some stuff for the mouse sensor Type: */
-#define BL_SENS_MOUSE_LEFT_BUTTON 1
-#define BL_SENS_MOUSE_MIDDLE_BUTTON 2
-#define BL_SENS_MOUSE_RIGHT_BUTTON 4
-#define BL_SENS_MOUSE_WHEEL_UP 5
-#define BL_SENS_MOUSE_WHEEL_DOWN 6
-#define BL_SENS_MOUSE_MOVEMENT 8
-#define BL_SENS_MOUSE_MOUSEOVER 16
-#define BL_SENS_MOUSE_MOUSEOVER_ANY 32
-
-/* Joystick sensor - sorted by axis types */
-#define SENS_JOY_ANY_EVENT 1
-
-#define SENS_JOY_BUTTON 0 /* axis type */
-
-#define SENS_JOY_AXIS 1 /* axis type */
-#define SENS_JOY_X_AXIS 0
-#define SENS_JOY_Y_AXIS 1
-#define SENS_JOY_NEG_X_AXIS 2
-#define SENS_JOY_NEG_Y_AXIS 3
-#define SENS_JOY_PRECISION 4
-
-#define SENS_JOY_HAT 2 /* axis type */
-#define SENS_JOY_HAT_DIR 0
-#define SENS_JOY_HAT_UP 1
-#define SENS_JOY_HAT_RIGHT 2
-#define SENS_JOY_HAT_DOWN 4
-#define SENS_JOY_HAT_LEFT 8
-
-#define SENS_JOY_HAT_UP_RIGHT SENS_JOY_HAT_UP | SENS_JOY_HAT_RIGHT
-#define SENS_JOY_HAT_DOWN_RIGHT SENS_JOY_HAT_DOWN | SENS_JOY_HAT_RIGHT
-#define SENS_JOY_HAT_UP_LEFT SENS_JOY_HAT_UP | SENS_JOY_HAT_LEFT
-#define SENS_JOY_HAT_DOWN_LEFT SENS_JOY_HAT_DOWN | SENS_JOY_HAT_LEFT
-
-
-#define SENS_JOY_AXIS_SINGLE 3 /* axis type */
-
-
-#define SENS_DELAY_REPEAT 1
-// should match JOYINDEX_MAX in SCA_JoystickDefines.h */
-#define SENS_JOY_MAXINDEX 8
-
-#endif /* __DNA_SENSOR_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 077ac4f7aa3..403e22dac73 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -67,6 +67,14 @@ struct MovieClipScopes;
struct Mask;
struct BLI_mempool;
+/* TODO 2.8: Remove the operator redo panel/region from the 3D View and Clip
+ * Editor toolshelf. Leaving this ifdef'ed out for until new tool system and
+ * topbar design is more clear. */
+//#define WITH_REDO_REGION_REMOVAL
+/* TODO 2.8: We don't write the topbar to files currently. Uncomment this
+ * define to enable writing (should become the default in a bit). */
+//#define WITH_TOPBAR_WRITING
+
/* SpaceLink (Base) ==================================== */
@@ -124,11 +132,9 @@ typedef struct SpaceButs {
short mainb, mainbo, mainbuser; /* context tabs */
short re_align, align; /* align for panels */
short preview; /* preview is signal to refresh */
- /* texture context selector (material, lamp, particles, world, other) */
- short texture_context, texture_context_prev;
char flag;
char collection_context;
- char pad[6];
+ char pad[2];
void *path; /* runtime */
int pathflag, dataicon; /* runtime */
@@ -146,7 +152,7 @@ typedef struct SpaceButs {
#define CONTEXT_SHADING 3
#define CONTEXT_EDITING 4
#define CONTEXT_SCRIPT 5
-#define CONTEXT_LOGIC 6
+//#define CONTEXT_LOGIC 6
/* sbuts->mainb old (deprecated) */
#ifdef DNA_DEPRECATED_ALLOW
@@ -158,7 +164,7 @@ typedef struct SpaceButs {
#define BUTS_WORLD 5
#define BUTS_RENDER 6
#define BUTS_EDIT 7
-#define BUTS_GAME 8
+// #define BUTS_GAME 8
#define BUTS_FPAINT 9
#define BUTS_RADIO 10
#define BUTS_SCRIPT 11
@@ -200,16 +206,6 @@ typedef enum eSpaceButtons_Flag {
SB_SHADING_CONTEXT = (1 << 4),
} eSpaceButtons_Flag;
-/* sbuts->texture_context */
-typedef enum eSpaceButtons_Texture_Context {
- SB_TEXC_MATERIAL = 0,
- SB_TEXC_WORLD = 1,
- SB_TEXC_LAMP = 2,
- SB_TEXC_PARTICLES = 3,
- SB_TEXC_OTHER = 4,
- SB_TEXC_LINESTYLE = 5,
-} eSpaceButtons_Texture_Context;
-
/* sbuts->collection_context */
typedef enum eSpaceButtons_Collection_Context {
SB_COLLECTION_CTX_VIEW_LAYER = 0,
@@ -478,40 +474,6 @@ typedef enum eSpaceNla_Flag {
/* Timeline =============================================== */
-/* Pointcache drawing data */
-# /* Only store the data array in the cache to avoid constant reallocation. */
-# /* No need to store when saved. */
-typedef struct SpaceTimeCache {
- struct SpaceTimeCache *next, *prev;
- float *array;
-} SpaceTimeCache;
-
-/* Timeline View */
-typedef struct SpaceTime {
- SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
-
- View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
-
- ListBase caches;
-
- int cache_display;
- int flag;
-} SpaceTime;
-
-
-/* time->flag */
-typedef enum eTimeline_Flag {
- /* show timing in frames instead of in seconds */
- TIME_DRAWFRAMES = (1 << 0),
- /* show time indicator box beside the frame number */
- TIME_CFRA_NUM = (1 << 1),
- /* only keyframes from active/selected channels get shown */
- TIME_ONLYACTSEL = (1 << 2),
-} eTimeline_Flag;
-
/* time->redraws (now screen->redraws_flag) */
typedef enum eScreen_Redraws_Flag {
TIME_REGION = (1 << 0),
@@ -528,18 +490,6 @@ typedef enum eScreen_Redraws_Flag {
TIME_FOLLOW = (1 << 15),
} eScreen_Redraws_Flag;
-/* time->cache */
-typedef enum eTimeline_Cache_Flag {
- TIME_CACHE_DISPLAY = (1 << 0),
- TIME_CACHE_SOFTBODY = (1 << 1),
- TIME_CACHE_PARTICLES = (1 << 2),
- TIME_CACHE_CLOTH = (1 << 3),
- TIME_CACHE_SMOKE = (1 << 4),
- TIME_CACHE_DYNAMICPAINT = (1 << 5),
- TIME_CACHE_RIGIDBODY = (1 << 6),
-} eTimeline_Cache_Flag;
-
-
/* Sequence Editor ======================================= */
/* Sequencer */
@@ -1217,14 +1167,14 @@ typedef enum eSpaceNode_Flag {
SNODE_AUTO_RENDER = (1 << 5),
// SNODE_SHOW_HIGHLIGHT = (1 << 6), DNA_DEPRECATED
// SNODE_USE_HIDDEN_PREVIEW = (1 << 10), DNA_DEPRECATED December2013
- SNODE_NEW_SHADERS = (1 << 11),
+// SNODE_NEW_SHADERS = (1 << 11), DNA_DEPRECATED
SNODE_PIN = (1 << 12),
SNODE_SKIP_INSOFFSET = (1 << 13), /* automatically offset following nodes in a chain on insertion */
} eSpaceNode_Flag;
/* snode->texfrom */
typedef enum eSpaceNode_TexFrom {
- SNODE_TEX_OBJECT = 0,
+ /* SNODE_TEX_OBJECT = 0, */
SNODE_TEX_WORLD = 1,
SNODE_TEX_BRUSH = 2,
SNODE_TEX_LINESTYLE = 3,
@@ -1243,23 +1193,6 @@ enum {
SNODE_INSERTOFS_DIR_LEFT = 1,
};
-/* Game Logic Editor ===================================== */
-
-/* Logic Editor */
-typedef struct SpaceLogic {
- SpaceLink *next, *prev;
- ListBase regionbase; /* storage of regions for inactive spaces */
- int spacetype;
- float blockscale DNA_DEPRECATED;
-
- short blockhandler[8] DNA_DEPRECATED;
-
- short flag, scaflag;
- int pad;
-
- struct bGPdata *gpd; /* grease-pencil data */
-} SpaceLogic;
-
/* Console ================================================ */
/* Console content */
@@ -1359,6 +1292,7 @@ typedef struct SpaceClip {
MaskSpaceInfo mask_info;
} SpaceClip;
+
/* SpaceClip->flag */
typedef enum eSpaceClip_Flag {
SC_SHOW_MARKER_PATTERN = (1 << 0),
@@ -1407,6 +1341,22 @@ typedef enum eSpaceClip_GPencil_Source {
SC_GPENCIL_SRC_TRACK = 1,
} eSpaceClip_GPencil_Source;
+
+/* Top Bar ======================================= */
+
+/* These two lines with # tell makesdna this struct can be excluded.
+ * Should be: #ifndef WITH_TOPBAR_WRITING */
+#
+#
+typedef struct SpaceTopBar {
+ SpaceLink *next, *prev;
+ ListBase regionbase; /* storage of regions for inactive spaces */
+ int spacetype;
+
+ int pad;
+} SpaceTopBar;
+
+
/* **************** SPACE DEFINES ********************* */
/* space types, moved from DNA_screen_types.h */
@@ -1430,14 +1380,15 @@ typedef enum eSpace_Type {
SPACE_NLA = 13,
/* TODO: fully deprecate */
SPACE_SCRIPT = 14, /* Deprecated */
- SPACE_TIME = 15,
+ SPACE_TIME = 15, /* Deprecated */
SPACE_NODE = 16,
- SPACE_LOGIC = 17,
+ SPACE_LOGIC = 17, /* deprecated */
SPACE_CONSOLE = 18,
SPACE_USERPREF = 19,
SPACE_CLIP = 20,
-
- SPACEICONMAX = SPACE_CLIP
+ SPACE_TOPBAR = 21,
+
+ SPACEICONMAX = SPACE_TOPBAR
} eSpace_Type;
/* use for function args */
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 0eb54a9b5b3..f5267f20d2c 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -45,13 +45,11 @@ extern "C" {
struct AnimData;
struct Ipo;
struct ColorBand;
-struct EnvMap;
struct Object;
struct Tex;
struct Image;
struct PreviewImage;
struct ImBuf;
-struct Ocean;
struct CurveMapping;
typedef struct MTex {
@@ -121,21 +119,6 @@ typedef struct ColorBand {
CBData data[32];
} ColorBand;
-typedef struct EnvMap {
- struct Object *object;
- struct Image *ima; /* type ENV_LOAD */
- struct ImBuf *cube[6]; /* these images are dynamic, not part of the main struct */
- float imat[4][4];
- float obimat[3][3];
- short type, stype;
- float clipsta, clipend;
- float viewscale; /* viewscale is for planar envmaps to zoom in or out */
- unsigned int notlay;
- short cuberes, depth;
- int ok, lastframe;
- short recalc, lastsize;
-} EnvMap;
-
typedef struct PointDensity {
short flag;
@@ -172,38 +155,6 @@ typedef struct PointDensity {
struct CurveMapping *falloff_curve; /* falloff density curve */
} PointDensity;
-typedef struct VoxelData {
- int resol[3];
- int interp_type;
- short file_format;
- short flag;
- short extend;
- short smoked_type;
- short hair_type;
- short data_type;
- int _pad;
-
- struct Object *object; /* for rendering smoke sims */
- float int_multiplier;
- int still_frame;
- char source_path[1024]; /* 1024 = FILE_MAX */
-
- /* temporary data */
- float *dataset;
- int cachedframe;
- int ok;
-
-} VoxelData;
-
-typedef struct OceanTex {
- struct Object *object;
- char oceanmod[64];
-
- int output;
- int pad;
-
-} OceanTex;
-
typedef struct Tex {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
@@ -254,11 +205,7 @@ typedef struct Tex {
struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */
struct Image *ima;
struct ColorBand *coba;
- struct EnvMap *env;
struct PreviewImage *preview;
- struct PointDensity *pd;
- struct VoxelData *vd;
- struct OceanTex *ot;
char use_nodes;
char pad[7];
@@ -316,13 +263,13 @@ typedef struct ColorMapping {
#define TEX_NOISE 7
#define TEX_IMAGE 8
//#define TEX_PLUGIN 9 /* Deprecated */
-#define TEX_ENVMAP 10
+//#define TEX_ENVMAP 10 /* Deprecated */
#define TEX_MUSGRAVE 11
#define TEX_VORONOI 12
#define TEX_DISTNOISE 13
-#define TEX_POINTDENSITY 14
-#define TEX_VOXELDATA 15
-#define TEX_OCEAN 16
+//#define TEX_POINTDENSITY 14 /* Deprecated */
+//#define TEX_VOXELDATA 15 /* Deprecated */
+//#define TEX_OCEAN 16 /* Deprecated */
/* musgrave stype */
#define TEX_MFRACTAL 0
@@ -549,22 +496,6 @@ enum {
COLBAND_HUE_CCW = 3,
};
-/* **************** EnvMap ********************* */
-
-/* type */
-#define ENV_CUBE 0
-#define ENV_PLANE 1
-#define ENV_SPHERE 2
-
-/* stype */
-#define ENV_STATIC 0
-#define ENV_ANIM 1
-#define ENV_LOAD 2
-
-/* ok */
-#define ENV_NORMAL 1
-#define ENV_OSA 2
-
/* **************** PointDensity ********************* */
/* source */
@@ -592,9 +523,9 @@ enum {
/* noise_influence */
#define TEX_PD_NOISE_STATIC 0
-#define TEX_PD_NOISE_VEL 1
-#define TEX_PD_NOISE_AGE 2
-#define TEX_PD_NOISE_TIME 3
+/* #define TEX_PD_NOISE_VEL 1 */ /* Deprecated */
+/* #define TEX_PD_NOISE_AGE 2 */ /* Deprecated */
+/* #define TEX_PD_NOISE_TIME 3 */ /* Deprecated */
/* color_source */
enum {
@@ -613,55 +544,6 @@ enum {
#define POINT_DATA_LIFE 2
#define POINT_DATA_COLOR 4
-/******************** Voxel Data *****************************/
-/* flag */
-#define TEX_VD_STILL 1
-
-/* interpolation */
-#define TEX_VD_NEARESTNEIGHBOR 0
-#define TEX_VD_LINEAR 1
-#define TEX_VD_QUADRATIC 2
-#define TEX_VD_TRICUBIC_CATROM 3
-#define TEX_VD_TRICUBIC_BSPLINE 4
-#define TEX_VD_TRICUBIC_SLOW 5
-
-/* file format */
-#define TEX_VD_BLENDERVOXEL 0
-#define TEX_VD_RAW_8BIT 1
-#define TEX_VD_RAW_16BIT 2
-#define TEX_VD_IMAGE_SEQUENCE 3
-#define TEX_VD_SMOKE 4
-#define TEX_VD_HAIR 5
-/* for voxels which use VoxelData->source_path */
-#define TEX_VD_IS_SOURCE_PATH(_format) (ELEM(_format, TEX_VD_BLENDERVOXEL, TEX_VD_RAW_8BIT, TEX_VD_RAW_16BIT))
-
-/* smoke data types */
-#define TEX_VD_SMOKEDENSITY 0
-#define TEX_VD_SMOKEHEAT 1
-#define TEX_VD_SMOKEVEL 2
-#define TEX_VD_SMOKEFLAME 3
-
-#define TEX_VD_HAIRDENSITY 0
-#define TEX_VD_HAIRVELOCITY 1
-#define TEX_VD_HAIRENERGY 2
-#define TEX_VD_HAIRRESTDENSITY 3
-
-/* data_type */
-#define TEX_VD_INTENSITY 0
-#define TEX_VD_RGBA_PREMUL 1
-
-/******************** Ocean *****************************/
-/* output */
-#define TEX_OCN_DISPLACEMENT 1
-#define TEX_OCN_FOAM 2
-#define TEX_OCN_JPLUS 3
-#define TEX_OCN_EMINUS 4
-#define TEX_OCN_EPLUS 5
-
-/* flag */
-#define TEX_OCN_GENERATE_NORMALS 1
-#define TEX_OCN_XZ 2
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 3da0bdb6ca2..fc10de67d48 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -397,11 +397,11 @@ typedef struct bTheme {
ThemeSpace toops;
ThemeSpace ttime;
ThemeSpace tnode;
- ThemeSpace tlogic;
ThemeSpace tuserpref;
ThemeSpace tconsole;
ThemeSpace tclip;
-
+ ThemeSpace ttopbar;
+
/* 20 sets of bone colors for this theme */
ThemeWireColor tarm[20];
/*ThemeWireColor tobj[20];*/
@@ -466,7 +466,7 @@ typedef struct UserDef {
short versions;
short dbl_click_time;
- short gameflags;
+ short pad;
short wheellinescroll;
int uiflag; /* eUserpref_UI_Flag */
int uiflag2; /* eUserpref_UI_Flag2 */
@@ -568,7 +568,7 @@ typedef struct UserDef {
float gpencil_new_layer_col[4]; /* default color for newly created Grease Pencil layers */
short tweak_threshold;
- char navigation_mode, pad;
+ char navigation_mode, pad10;
char author[80]; /* author name for file formats supporting it */
@@ -787,15 +787,6 @@ typedef enum eDupli_ID_Flags {
USER_DUP_PSYS = (1 << 11)
} eDupli_ID_Flags;
-/* UserDef.gameflags */
-typedef enum eOpenGL_RenderingOptions {
- USER_GL_RENDER_DEPRECATED_0 = (1 << 0),
- USER_GL_RENDER_DEPRECATED_1 = (1 << 1),
- USER_DISABLE_MIPMAP = (1 << 2),
- USER_GL_RENDER_DEPRECATED_3 = (1 << 3),
- USER_GL_RENDER_DEPRECATED_4 = (1 << 4),
-} eOpenGL_RenderingOptions;
-
/* selection method for opengl gpu_select_method */
typedef enum eOpenGL_SelectOptions {
USER_SELECT_AUTO = 0,
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 619f9fd4f6e..d7f9e33d6be 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -74,6 +74,19 @@ typedef struct View3DDebug {
} View3DDebug;
/* ********************************* */
+enum {
+ V3D_LIGHTING_FLAT = 0,
+ V3D_LIGHTING_STUDIO = 1,
+ V3D_LIGHTING_SCENE = 2
+};
+
+enum {
+ V3D_DRAWOPTION_RANDOMIZE = (1<<0),
+};
+
+enum {
+ V3D_OVERLAY_FACE_ORIENTATION = (1 << 0),
+};
typedef struct RegionView3D {
@@ -197,10 +210,10 @@ typedef struct View3D {
char gridflag;
/* transform manipulator info */
- char twtype, twmode, twflag;
+ char twtype, _pad5, twflag;
short flag3;
-
+
/* afterdraw, for xray & transparent */
struct ListBase afterdraw_transp;
struct ListBase afterdraw_xray;
@@ -211,9 +224,7 @@ typedef struct View3D {
char multiview_eye; /* multiview current eye - for internal use */
- /* The active custom transform orientation of this 3D view. */
- short custom_orientation_index;
- char pad3[2];
+ char pad3[4];
/* note, 'fx_settings.dof' is currently _not_ allocated,
* instead set (temporarily) from camera */
@@ -238,8 +249,14 @@ typedef struct View3D {
* Runtime-only, set in the rendered viewport toggle operator.
*/
short prev_drawtype;
- short pad1;
- float pad2;
+ /* drawtype options (lighting, random) used for drawtype == OB_SOLID */
+ short drawtype_lighting;
+ short drawtype_options;
+ short pad5;
+
+ int overlays;
+ int pad6;
+
View3DDebug debug;
} View3D;
@@ -270,7 +287,7 @@ typedef struct View3D {
#define RV3D_CLIPPING 4
#define RV3D_NAVIGATING 8
#define RV3D_GPULIGHT_UPDATE 16
-#define RV3D_IS_GAME_ENGINE 32 /* runtime flag, used to check if LoD's should be used */
+/*#define RV3D_IS_GAME_ENGINE 32 *//* UNUSED */
/**
* Disable zbuffer offset, skip calls to #ED_view3d_polygon_offset.
* Use when precise surface depth is needed and picking bias isn't, see T45434).
@@ -354,12 +371,7 @@ enum {
#define V3D_SHOW_Y 4
#define V3D_SHOW_Z 8
-/* View3d->twtype (bits, we can combine them) */
-#define V3D_MANIP_TRANSLATE 1
-#define V3D_MANIP_ROTATE 2
-#define V3D_MANIP_SCALE 4
-
-/* View3d->twmode */
+/* Scene.orientation_type */
#define V3D_MANIP_GLOBAL 0
#define V3D_MANIP_LOCAL 1
#define V3D_MANIP_NORMAL 2
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index f03ff4ba8b7..8797f4b1fd6 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -32,6 +32,7 @@
#define __DNA_WINDOWMANAGER_TYPES_H__
#include "DNA_listBase.h"
+#include "DNA_screen_types.h"
#include "DNA_vec_types.h"
#include "DNA_userdef_types.h"
@@ -190,6 +191,10 @@ typedef struct wmWindow {
struct WorkSpaceInstanceHook *workspace_hook;
+ /** Global areas aren't part of the screen, but part of the window directly.
+ * \note Code assumes global areas with fixed height, fixed width not supported yet */
+ ScrAreaMap global_areas;
+
struct bScreen *screen DNA_DEPRECATED;
short posx, posy, sizex, sizey; /* window coords */
@@ -376,6 +381,10 @@ typedef struct wmOperator {
struct uiLayout *layout; /* runtime for drawing */
short flag, pad[3];
+ /* Screen context the operator was finished in. It gets temporarily
+ * restored during operator repeat. Only set for registered operators. */
+ struct ScrArea *execution_area;
+ struct ARegion *execution_region;
} wmOperator;
/* operator type return flags: exec(), invoke() modal(), return values */
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 82aa7b8b81c..baa6d0f94db 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -95,9 +95,6 @@ typedef struct WorkSpace {
/* Feature tagging (use for addons) */
ListBase owner_ids DNA_PRIVATE_WORKSPACE_READ_WRITE; /* wmOwnerID */
- /* Custom transform orientations */
- ListBase transform_orientations DNA_PRIVATE_WORKSPACE;
-
int pad;
int flags DNA_PRIVATE_WORKSPACE; /* enum eWorkSpaceFlags */
@@ -105,7 +102,6 @@ typedef struct WorkSpace {
bToolDef tool;
struct ViewLayer *view_layer DNA_DEPRECATED;
- struct ViewRender view_render;
} WorkSpace;
/* internal struct, but exported for read/write */
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index 3361e50e257..ac93033609d 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -47,8 +47,7 @@ struct MTex;
/**
* World defines general modeling data such as a background fill,
- * gravity, color model etc. It mixes game-data, rendering
- * data and modeling data. */
+ * gravity, color model etc. It mixes rendering data and modeling data. */
typedef struct World {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
@@ -57,8 +56,6 @@ typedef struct World {
short texact, mistype;
float horr, horg, horb;
- float zenr, zeng, zenb;
- float ambr, ambg, ambb;
/**
* Exposure= mult factor. unused now, but maybe back later. Kept in to be upward compat.
@@ -67,59 +64,23 @@ typedef struct World {
*/
float exposure, exp, range;
float linfac, logfac;
-
- /**
- * Gravitation constant for the game world
- */
- float gravity; // XXX moved to scene->gamedata in 2.5
-
- /**
- * Radius of the activity bubble, in Manhattan length. Objects
- * outside the box are activity-culled. */
- float activityBoxRadius; // XXX moved to scene->gamedata in 2.5
- short skytype;
/**
* Some world modes
* bit 0: Do mist
- * bit 1: Do stars
- * bit 2: (reserved) depth of field
- * bit 3: (gameengine): Activity culling is enabled.
- * bit 4: ambient occlusion
- * bit 5: (gameengine) : enable Bullet DBVT tree for view frustum culling
*/
short mode; // partially moved to scene->gamedata in 2.5
- short occlusionRes; /* resolution of occlusion Z buffer in pixel */ // XXX moved to scene->gamedata in 2.5
- short physicsEngine; /* here it's aligned */ // XXX moved to scene->gamedata in 2.5
- short ticrate, maxlogicstep, physubstep, maxphystep; // XXX moved to scene->gamedata in 2.5
-
+ short pad2[3];
+
float misi, miststa, mistdist, misthi;
-
- float starr DNA_DEPRECATED, starg DNA_DEPRECATED, starb DNA_DEPRECATED, stark DNA_DEPRECATED; /* Deprecated */
- float starsize DNA_DEPRECATED, starmindist DNA_DEPRECATED;
- float stardist DNA_DEPRECATED, starcolnoise DNA_DEPRECATED;
-
- /* unused now: DOF */
- short dofsta, dofend, dofmin, dofmax;
-
+
/* ambient occlusion */
- float aodist, aodistfac, aoenergy, aobias;
- short aomode, aosamp, aomix, aocolor;
- float ao_adapt_thresh, ao_adapt_speed_fac;
- float ao_approx_error, ao_approx_correction;
- float ao_indirect_energy, ao_env_energy, ao_pad2;
- short ao_indirect_bounces, ao_pad;
- short ao_samp_method, ao_gather_method, ao_approx_passes;
-
- /* assorted settings (in the middle of ambient occlusion settings for padding reasons) */
- short flag;
-
- /* ambient occlusion (contd...) */
- float *aosphere, *aotables;
+ float aodist, aoenergy;
+ /* assorted settings */
+ short flag, pad3[3];
struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */
- struct MTex *mtex[18]; /* MAX_MTEX */
short pr_texture, use_nodes, pad;
short update_flag; /* XXX temporary flag waiting for depsgraph proper tagging */
@@ -135,33 +96,15 @@ typedef struct World {
/* **************** WORLD ********************* */
-/* skytype */
-#define WO_SKYBLEND 1
-#define WO_SKYREAL 2
-#define WO_SKYPAPER 4
-/* while render: */
-#define WO_SKYTEX 8
-#define WO_ZENUP 16
-
/* mode */
#define WO_MIST 1
//#define WO_STARS 2 /* deprecated */
/*#define WO_DOF 4*/
-#define WO_ACTIVITY_CULLING 8
-#define WO_ENV_LIGHT 16
-#define WO_DBVT_CULLING 32
+//#define WO_ACTIVITY_CULLING 8 /* deprecated */
+//#define WO_ENV_LIGHT 16
+//#define WO_DBVT_CULLING 32 /* deprecated */
#define WO_AMB_OCC 64
-#define WO_INDIRECT_LIGHT 128
-
-/* aomix */
-enum {
- WO_AOADD = 0,
-#ifdef DNA_DEPRECATED
- WO_AOSUB = 1, /* deprecated */
- WO_AOADDSUB = 2, /* deprecated */
-#endif
- WO_AOMUL = 3,
-};
+//#define WO_INDIRECT_LIGHT 128
enum {
WO_MIST_QUADRATIC = 0,
@@ -169,38 +112,6 @@ enum {
WO_MIST_INVERSE_QUADRATIC = 2,
};
-/* ao_samp_method - methods for sampling the AO hemi */
-#define WO_AOSAMP_CONSTANT 0
-#define WO_AOSAMP_HALTON 1
-#define WO_AOSAMP_HAMMERSLEY 2
-
-/* aomode (use distances & random sampling modes) */
-#define WO_AODIST 1
-#define WO_AORNDSMP 2
-#define WO_AOCACHE 4
-
-/* aocolor */
-#define WO_AOPLAIN 0
-#define WO_AOSKYCOL 1
-#define WO_AOSKYTEX 2
-
-/* ao_gather_method */
-#define WO_AOGATHER_RAYTRACE 0
-#define WO_AOGATHER_APPROX 1
-
-/* texco (also in DNA_material_types.h) */
-#define TEXCO_ANGMAP 64
-#define TEXCO_H_SPHEREMAP 256
-#define TEXCO_H_TUBEMAP 1024
-#define TEXCO_EQUIRECTMAP 2048
-
-/* mapto */
-#define WOMAP_BLEND 1
-#define WOMAP_HORIZ 2
-#define WOMAP_ZENUP 4
-#define WOMAP_ZENDOWN 8
-// #define WOMAP_MIST 16 /* Deprecated */
-
/* flag */
#define WO_DS_EXPAND (1<<0)
/* NOTE: this must have the same value as MA_DS_SHOW_TEXS,
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index e66ea248e7c..f14f895203b 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -100,10 +100,6 @@ static const char *includefiles[] = {
"DNA_sequence_types.h",
"DNA_effect_types.h",
"DNA_outliner_types.h",
- "DNA_property_types.h",
- "DNA_sensor_types.h",
- "DNA_controller_types.h",
- "DNA_actuator_types.h",
"DNA_sound_types.h",
"DNA_group_types.h",
"DNA_armature_types.h",
@@ -470,7 +466,7 @@ static int preprocess_include(char *maindata, int len)
if (cp[0] == '/' && cp[1] == '/') {
comment = 1;
}
- else if (*cp < 32) {
+ else if (*cp == '\n') {
comment = 0;
}
if (comment || *cp < 32 || *cp > 128) *cp = 32;
@@ -579,9 +575,10 @@ static int convert_include(const char *filename)
/* read include file, skip structs with a '#' before it.
* store all data in temporal arrays.
*/
- int filelen, count, overslaan, slen, type, name, strct;
+ int filelen, count, slen, type, name, strct;
short *structpoin, *sp;
char *maindata, *mainend, *md, *md1;
+ bool skip_struct;
md = maindata = read_file_data(filename, &filelen);
if (filelen == -1) {
@@ -594,18 +591,18 @@ static int convert_include(const char *filename)
/* we look for '{' and then back to 'struct' */
count = 0;
- overslaan = 0;
+ skip_struct = false;
while (count < filelen) {
/* code for skipping a struct: two hashes on 2 lines. (preprocess added a space) */
if (md[0] == '#' && md[1] == ' ' && md[2] == '#') {
- overslaan = 1;
+ skip_struct = true;
}
if (md[0] == '{') {
md[0] = 0;
- if (overslaan) {
- overslaan = 0;
+ if (skip_struct) {
+ skip_struct = false;
}
else {
if (md[-1] == ' ') md[-1] = 0;
@@ -1329,10 +1326,6 @@ int main(int argc, char **argv)
#include "DNA_sequence_types.h"
#include "DNA_effect_types.h"
#include "DNA_outliner_types.h"
-#include "DNA_property_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
#include "DNA_sound_types.h"
#include "DNA_group_types.h"
#include "DNA_armature_types.h"
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index d5752ff3e5e..0f7fe1e9ca4 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -234,8 +234,6 @@ extern StructRNA RNA_EffectSequence;
extern StructRNA RNA_EffectorWeights;
extern StructRNA RNA_EnumProperty;
extern StructRNA RNA_EnumPropertyItem;
-extern StructRNA RNA_EnvironmentMap;
-extern StructRNA RNA_EnvironmentMapTexture;
extern StructRNA RNA_Event;
extern StructRNA RNA_ExplodeModifier;
extern StructRNA RNA_ExpressionController;
@@ -278,14 +276,6 @@ extern StructRNA RNA_GPencilStroke;
extern StructRNA RNA_GPencilStrokePoint;
extern StructRNA RNA_GPencilSculptSettings;
extern StructRNA RNA_GPencilSculptBrush;
-extern StructRNA RNA_GameBooleanProperty;
-extern StructRNA RNA_GameFloatProperty;
-extern StructRNA RNA_GameIntProperty;
-extern StructRNA RNA_GameObjectSettings;
-extern StructRNA RNA_GameProperty;
-extern StructRNA RNA_GameSoftBodySettings;
-extern StructRNA RNA_GameStringProperty;
-extern StructRNA RNA_GameTimerProperty;
extern StructRNA RNA_GaussianBlurSequence;
extern StructRNA RNA_GlowSequence;
extern StructRNA RNA_GreasePencil;
@@ -395,15 +385,8 @@ extern StructRNA RNA_MarbleTexture;
extern StructRNA RNA_MaskModifier;
extern StructRNA RNA_MaskSequence;
extern StructRNA RNA_Material;
-extern StructRNA RNA_MaterialHalo;
-extern StructRNA RNA_MaterialPhysics;
extern StructRNA RNA_MaterialRaytraceMirror;
-extern StructRNA RNA_MaterialRaytraceTransparency;
extern StructRNA RNA_MaterialSlot;
-extern StructRNA RNA_MaterialStrand;
-extern StructRNA RNA_MaterialSubsurfaceScattering;
-extern StructRNA RNA_MaterialTextureSlot;
-extern StructRNA RNA_MaterialVolume;
extern StructRNA RNA_Mask;
extern StructRNA RNA_MaskLayer;
extern StructRNA RNA_Menu;
@@ -497,8 +480,6 @@ extern StructRNA RNA_ParticleSystemModifier;
extern StructRNA RNA_ParticleTarget;
extern StructRNA RNA_PivotConstraint;
extern StructRNA RNA_PointCache;
-extern StructRNA RNA_PointDensity;
-extern StructRNA RNA_PointDensityTexture;
extern StructRNA RNA_PointLamp;
extern StructRNA RNA_PointerProperty;
extern StructRNA RNA_Pose;
@@ -526,7 +507,6 @@ extern StructRNA RNA_RigidBodyObject;
extern StructRNA RNA_RigidBodyJointConstraint;
extern StructRNA RNA_SPHFluidSettings;
extern StructRNA RNA_Scene;
-extern StructRNA RNA_SceneGameData;
extern StructRNA RNA_SceneRenderLayer;
extern StructRNA RNA_SceneSequence;
extern StructRNA RNA_SceneObjects;
@@ -596,14 +576,12 @@ extern StructRNA RNA_SpaceFileBrowser;
extern StructRNA RNA_SpaceGraphEditor;
extern StructRNA RNA_SpaceImageEditor;
extern StructRNA RNA_SpaceInfo;
-extern StructRNA RNA_SpaceLogicEditor;
extern StructRNA RNA_SpaceNLA;
extern StructRNA RNA_SpaceNodeEditor;
extern StructRNA RNA_SpaceOutliner;
extern StructRNA RNA_SpaceProperties;
extern StructRNA RNA_SpaceSequenceEditor;
extern StructRNA RNA_SpaceTextEditor;
-extern StructRNA RNA_SpaceTimeline;
extern StructRNA RNA_SpaceUVEditor;
extern StructRNA RNA_SpaceUserPreferences;
extern StructRNA RNA_SpaceView3D;
@@ -677,7 +655,6 @@ extern StructRNA RNA_ThemeSpaceGradient;
extern StructRNA RNA_ThemeSpaceListGeneric;
extern StructRNA RNA_ThemeStyle;
extern StructRNA RNA_ThemeTextEditor;
-extern StructRNA RNA_ThemeTimeline;
extern StructRNA RNA_ThemeUserInterface;
extern StructRNA RNA_ThemeUserPreferences;
extern StructRNA RNA_ThemeView3D;
@@ -711,15 +688,12 @@ extern StructRNA RNA_VertexGroup;
extern StructRNA RNA_VertexGroupElement;
extern StructRNA RNA_VertexPaint;
extern StructRNA RNA_VoronoiTexture;
-extern StructRNA RNA_VoxelData;
-extern StructRNA RNA_VoxelDataTexture;
extern StructRNA RNA_WarpModifier;
extern StructRNA RNA_WaveModifier;
extern StructRNA RNA_VertexWeightEditModifier;
extern StructRNA RNA_VertexWeightMixModifier;
extern StructRNA RNA_VertexWeightProximityModifier;
extern StructRNA RNA_ViewLayer;
-extern StructRNA RNA_ViewRenderSettings;
extern StructRNA RNA_Window;
extern StructRNA RNA_WindowManager;
extern StructRNA RNA_WipeSequence;
@@ -905,7 +879,8 @@ bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index);
bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop); /* without lib check, only checks the flag */
bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop);
bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop);
-bool RNA_property_overridable(PointerRNA *ptr, PropertyRNA *prop);
+bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop);
+bool RNA_property_overridable_static_set(PointerRNA *ptr, PropertyRNA *prop, const bool is_overridable);
bool RNA_property_overridden(PointerRNA *ptr, PropertyRNA *prop);
bool RNA_property_comparable(PointerRNA *ptr, PropertyRNA *prop);
bool RNA_property_path_from_ID_check(PointerRNA *ptr, PropertyRNA *prop); /* slow, use with care */
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 345c47ae1bf..0c0a22cc467 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -165,8 +165,6 @@ extern const EnumPropertyItem rna_enum_property_type_items[];
extern const EnumPropertyItem rna_enum_property_subtype_items[];
extern const EnumPropertyItem rna_enum_property_unit_items[];
-extern const EnumPropertyItem rna_enum_gameproperty_type_items[];
-
extern const EnumPropertyItem rna_enum_viewport_shade_items[];
extern const EnumPropertyItem rna_enum_navigation_mode_items[];
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index bac0ecd1e4d..465a7200c1b 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -32,7 +32,6 @@ endif()
set(DEFSRC
rna_ID.c
rna_action.c
- rna_actuator.c
rna_animation.c
rna_animviz.c
rna_armature.c
@@ -44,7 +43,6 @@ set(DEFSRC
rna_color.c
rna_constraint.c
rna_context.c
- rna_controller.c
rna_curve.c
rna_depsgraph.c
rna_dynamicpaint.c
@@ -77,14 +75,12 @@ set(DEFSRC
rna_particle.c
rna_pose.c
rna_lightprobe.c
- rna_property.c
rna_render.c
rna_rigidbody.c
rna_rna.c
rna_scene.c
rna_screen.c
rna_sculpt_paint.c
- rna_sensor.c
rna_sequencer.c
rna_smoke.c
rna_sound.c
@@ -106,11 +102,9 @@ set(DEFSRC
set(APISRC
rna_action_api.c
- rna_actuator_api.c
rna_animation_api.c
rna_armature_api.c
rna_camera_api.c
- rna_controller_api.c
rna_curve_api.c
rna_fcurve_api.c
rna_image_api.c
@@ -123,7 +117,6 @@ set(APISRC
rna_object_api.c
rna_pose_api.c
rna_scene_api.c
- rna_sensor_api.c
rna_sequencer_api.c
rna_sound_api.c
rna_space_api.c
@@ -196,10 +189,6 @@ if(WITH_PYTHON)
)
endif()
-if(WITH_GAMEENGINE)
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
if(WITH_CLAY_ENGINE)
add_definitions(-DWITH_CLAY_ENGINE)
endif()
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index ab1eaca52e4..95a1586efa5 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3350,7 +3350,6 @@ static RNAProcessItem PROCESS_ITEMS[] = {
{"rna_action.c", "rna_action_api.c", RNA_def_action},
{"rna_animation.c", "rna_animation_api.c", RNA_def_animation},
{"rna_animviz.c", NULL, RNA_def_animviz},
- {"rna_actuator.c", "rna_actuator_api.c", RNA_def_actuator},
{"rna_armature.c", "rna_armature_api.c", RNA_def_armature},
{"rna_boid.c", NULL, RNA_def_boid},
{"rna_brush.c", NULL, RNA_def_brush},
@@ -3360,7 +3359,6 @@ static RNAProcessItem PROCESS_ITEMS[] = {
{"rna_color.c", NULL, RNA_def_color},
{"rna_constraint.c", NULL, RNA_def_constraint},
{"rna_context.c", NULL, RNA_def_context},
- {"rna_controller.c", "rna_controller_api.c", RNA_def_controller},
{"rna_curve.c", "rna_curve_api.c", RNA_def_curve},
{"rna_dynamicpaint.c", NULL, RNA_def_dynamic_paint},
{"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve},
@@ -3391,13 +3389,11 @@ static RNAProcessItem PROCESS_ITEMS[] = {
{"rna_particle.c", NULL, RNA_def_particle},
{"rna_pose.c", "rna_pose_api.c", RNA_def_pose},
{"rna_lightprobe.c", NULL, RNA_def_lightprobe},
- {"rna_property.c", NULL, RNA_def_gameproperty},
{"rna_render.c", NULL, RNA_def_render},
{"rna_rigidbody.c", NULL, RNA_def_rigidbody},
{"rna_scene.c", "rna_scene_api.c", RNA_def_scene},
{"rna_screen.c", NULL, RNA_def_screen},
{"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint},
- {"rna_sensor.c", "rna_sensor_api.c", RNA_def_sensor},
{"rna_sequencer.c", "rna_sequencer_api.c", RNA_def_sequencer},
{"rna_smoke.c", NULL, RNA_def_smoke},
{"rna_space.c", "rna_space_api.c", RNA_def_space},
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 4a267313ac9..59d0095e3fb 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -284,8 +284,9 @@ IDProperty *RNA_struct_idprops(PointerRNA *ptr, bool create)
{
StructRNA *type = ptr->type;
- if (type && type->idproperties)
+ if (type && type->idproperties) {
return type->idproperties(ptr, create);
+ }
return NULL;
}
@@ -299,8 +300,16 @@ static IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name)
{
IDProperty *group = RNA_struct_idprops(ptr, 0);
- if (group)
- return IDP_GetPropertyFromGroup(group, name);
+ if (group) {
+ if (group->type == IDP_GROUP) {
+ return IDP_GetPropertyFromGroup(group, name);
+ }
+ else {
+ /* Not sure why that happens sometimes, with nested properties... */
+ /* Seems to be actually array prop, name is usually "0"... To be sorted out later. */
+// printf("Got unexpected IDProp container when trying to retrieve %s: %d\n", name, group->type);
+ }
+ }
return NULL;
}
@@ -1843,7 +1852,7 @@ bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop)
return ((flag & PROP_EDITABLE) &&
(flag & PROP_REGISTER) == 0 &&
(!id || ((!ID_IS_LINKED(id) || (prop->flag & PROP_LIB_EXCEPTION)) &&
- (!id->override_static || RNA_property_overridable(ptr, prop)))));
+ (!id->override_static || RNA_property_overridable_get(ptr, prop)))));
}
/**
@@ -1876,7 +1885,7 @@ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char *
}
return false;
}
- if (id->override_static != NULL && !RNA_property_overridable(ptr, prop)) {
+ if (id->override_static != NULL && !RNA_property_overridable_get(ptr, prop)) {
if (!(*r_info)[0]) {
*r_info = N_("Can't edit this property from an override data-block.");
}
@@ -1957,13 +1966,34 @@ bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop)
/** \note Does not take into account editable status, this has to be checked separately
* (using RNA_property_edtiable_flag() usually). */
-bool RNA_property_overridable(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
+bool RNA_property_overridable_get(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
{
- prop = rna_ensure_property(prop);
+ if (prop->magic == RNA_MAGIC) {
+ /* If this is a RNA-defined property (real or 'virtual' IDProp), we want to use RNA prop flag. */
+ return !(prop->flag & PROP_NO_COMPARISON) && (prop->flag & PROP_OVERRIDABLE_STATIC);
+ }
+ else {
+ /* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */
+ return !(prop->flag & PROP_NO_COMPARISON) && (((IDProperty *)prop)->flag & IDP_FLAG_OVERRIDABLE_STATIC);
+ }
+}
+
+/* Should only be used for custom properties */
+bool RNA_property_overridable_static_set(PointerRNA *UNUSED(ptr), PropertyRNA *prop, const bool is_overridable)
+{
+ /* Only works for pure custom properties IDProps. */
+ if (prop->magic != RNA_MAGIC) {
+ IDProperty *idprop = (IDProperty *)prop;
+
+ idprop->flag = is_overridable ? (idprop->flag | IDP_FLAG_OVERRIDABLE_STATIC) :
+ (idprop->flag & ~IDP_FLAG_OVERRIDABLE_STATIC);
+ return true;
+ }
- return !(prop->flag & PROP_NO_COMPARISON) && (prop->flag & PROP_OVERRIDABLE_STATIC);
+ return false;
}
+
bool RNA_property_overridden(PointerRNA *ptr, PropertyRNA *prop)
{
char *rna_path = RNA_path_from_ID_to_property(ptr, prop);
@@ -7277,7 +7307,7 @@ static int rna_property_override_diff(
bool override_changed = false;
int diff_flags = flags;
- if (!RNA_property_overridable(ptr_a, prop_a)) {
+ if (!RNA_property_overridable_get(ptr_a, prop_a)) {
diff_flags &= ~RNA_OVERRIDE_COMPARE_CREATE;
}
const int diff = override_diff(
@@ -7440,12 +7470,21 @@ bool RNA_struct_override_matches(
const bool do_create = (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0;
const bool do_restore = (flags & RNA_OVERRIDE_COMPARE_RESTORE) != 0;
+//#define DEBUG_OVERRIDE_TIMEIT
#ifdef DEBUG_OVERRIDE_TIMEIT
- static float _sum_time = 0.0f;
- static float _num_time = 0.0f;
- double _timeit_time;
+ static float _sum_time_global = 0.0f;
+ static float _num_time_global = 0.0f;
+ double _timeit_time_global;
+ static float _sum_time_diffing = 0.0f;
+ static float _delta_time_diffing = 0.0f;
+ static int _num_delta_time_diffing = 0.0f;
+ static float _num_time_diffing = 0.0f;
+ double _timeit_time_diffing;
+
if (!root_path) {
- _timeit_time = PIL_check_seconds_timer();
+ _delta_time_diffing = 0.0f;
+ _num_delta_time_diffing = 0;
+ _timeit_time_global = PIL_check_seconds_timer();
}
#endif
@@ -7463,7 +7502,7 @@ bool RNA_struct_override_matches(
continue;
}
- if (ignore_non_overridable && !RNA_property_overridable(ptr_local, prop_local)) {
+ if (ignore_non_overridable && !RNA_property_overridable_get(ptr_local, prop_local)) {
continue;
}
@@ -7473,34 +7512,61 @@ bool RNA_struct_override_matches(
continue;
}
+#define RNA_PATH_BUFFSIZE 8192
+#define RNA_PATH_PRINTF(_str, ...) \
+ if (BLI_snprintf(rna_path, RNA_PATH_BUFFSIZE, \
+ (_str), __VA_ARGS__) >= RNA_PATH_BUFFSIZE) \
+ { rna_path = BLI_sprintfN((_str), __VA_ARGS__); }(void)0
+#define RNA_PATH_FREE \
+ if (rna_path != rna_path_buffer) MEM_freeN(rna_path)
+
+ char rna_path_buffer[RNA_PATH_BUFFSIZE];
+ char *rna_path = rna_path_buffer;
+
/* XXX TODO this will have to be refined to handle collections insertions, and array items */
- char *rna_path;
if (root_path) {
/* Inlined building, much much more efficient. */
if (prop_local->magic == RNA_MAGIC) {
- rna_path = BLI_sprintfN("%s.%s", root_path, RNA_property_identifier(prop_local));
+ RNA_PATH_PRINTF("%s.%s", root_path, RNA_property_identifier(prop_local));
}
else {
- rna_path = BLI_sprintfN("%s[\"%s\"]", root_path, RNA_property_identifier(prop_local));
+ RNA_PATH_PRINTF("%s[\"%s\"]", root_path, RNA_property_identifier(prop_local));
}
}
else {
+ /* This is rather slow, but is not much called, so not really worth optimizing. */
rna_path = RNA_path_from_ID_to_property(ptr_local, prop_local);
}
if (rna_path == NULL) {
continue;
}
+// printf("Override Checking %s\n", rna_path);
+
if (ignore_overridden && BKE_override_static_property_find(override, rna_path) != NULL) {
- MEM_SAFE_FREE(rna_path);
+ RNA_PATH_FREE;
continue;
}
+#ifdef DEBUG_OVERRIDE_TIMEIT
+ if (!root_path) {
+ _timeit_time_diffing = PIL_check_seconds_timer();
+ }
+#endif
+
eRNAOverrideMatchResult report_flags = 0;
const int diff = rna_property_override_diff(
ptr_local, ptr_reference, NULL, prop_local, prop_reference, rna_path,
RNA_EQ_STRICT, override, flags, &report_flags);
+#ifdef DEBUG_OVERRIDE_TIMEIT
+ if (!root_path) {
+ const float _delta_time = (float)(PIL_check_seconds_timer() - _timeit_time_diffing);
+ _delta_time_diffing += _delta_time;
+ _num_delta_time_diffing++;
+ }
+#endif
+
matching = matching && diff == 0;
if (r_report_flags) {
*r_report_flags |= report_flags;
@@ -7545,18 +7611,28 @@ bool RNA_struct_override_matches(
}
}
- MEM_SAFE_FREE(rna_path);
+ RNA_PATH_FREE;
+
+#undef RNA_PATH_BUFFSIZE
+#undef RNA_PATH_PRINTF
+#undef RNA_PATH_FREE
}
RNA_property_collection_end(&iter);
#ifdef DEBUG_OVERRIDE_TIMEIT
if (!root_path) {
- const float _delta_time = (float)(PIL_check_seconds_timer() - _timeit_time);
- _sum_time += _delta_time;
- _num_time++;
+ const float _delta_time = (float)(PIL_check_seconds_timer() - _timeit_time_global);
+ _sum_time_global += _delta_time;
+ _num_time_global++;
+ _sum_time_diffing += _delta_time_diffing;
+ _num_time_diffing++;
printf("ID: %s\n", ((ID *)ptr_local->id.data)->name);
printf("time end (%s): %.6f\n", __func__, _delta_time);
- printf("time averaged (%s): %.6f (total: %.6f, in %d runs)\n", __func__, (_sum_time / _num_time), _sum_time, (int)_num_time);
+ printf("time averaged (%s): %.6f (total: %.6f, in %d runs)\n", __func__,
+ (_sum_time_global / _num_time_global), _sum_time_global, (int)_num_time_global);
+ printf("diffing time end (%s): %.6f (in %d runs)\n", __func__, _delta_time_diffing, _num_delta_time_diffing);
+ printf("diffing time averaged (%s): %.6f (total: %.6f, in %d runs)\n", __func__,
+ (_sum_time_diffing / _num_time_diffing), _sum_time_diffing, (int)_num_time_diffing);
}
#endif
@@ -7722,7 +7798,7 @@ eRNAOverrideStatus RNA_property_override_status(PointerRNA *ptr, PropertyRNA *pr
return override_status;
}
- if (RNA_property_overridable(ptr, prop) && RNA_property_editable_flag(ptr, prop)) {
+ if (RNA_property_overridable_get(ptr, prop) && RNA_property_editable_flag(ptr, prop)) {
override_status |= RNA_OVERRIDE_STATUS_OVERRIDABLE;
}
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c
deleted file mode 100644
index 26ec813a14f..00000000000
--- a/source/blender/makesrna/intern/rna_actuator.c
+++ /dev/null
@@ -1,2220 +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.
- *
- * Contributor(s): Blender Foundation (2008).
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/makesrna/intern/rna_actuator.c
- * \ingroup RNA
- */
-
-
-#include <stdlib.h>
-
-#include "DNA_constraint_types.h"
-#include "DNA_object_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_scene_types.h" /* for MAXFRAME */
-
-#include "BLI_math.h"
-#include "BLI_string_utils.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "RNA_define.h"
-#include "RNA_access.h"
-#include "RNA_enum_types.h"
-
-#include "rna_internal.h"
-
-#include "WM_types.h"
-
-/* Always keep in alphabetical order */
-static const EnumPropertyItem actuator_type_items[] = {
- {ACT_ACTION, "ACTION", 0, "Action", ""},
- {ACT_ARMATURE, "ARMATURE", 0, "Armature", ""},
- {ACT_CAMERA, "CAMERA", 0, "Camera", ""},
- {ACT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""},
- {ACT_EDIT_OBJECT, "EDIT_OBJECT", 0, "Edit Object", ""},
- {ACT_2DFILTER, "FILTER_2D", 0, "Filter 2D", ""},
- {ACT_GAME, "GAME", 0, "Game", ""},
- {ACT_MESSAGE, "MESSAGE", 0, "Message", ""},
- {ACT_OBJECT, "MOTION", 0, "Motion", ""},
- {ACT_MOUSE, "MOUSE", 0, "Mouse", ""},
- {ACT_PARENT, "PARENT", 0, "Parent", ""},
- {ACT_PROPERTY, "PROPERTY", 0, "Property", ""},
- {ACT_RANDOM, "RANDOM", 0, "Random", ""},
- {ACT_SCENE, "SCENE", 0, "Scene", ""},
- {ACT_SOUND, "SOUND", 0, "Sound", ""},
- {ACT_STATE, "STATE", 0, "State", ""},
- {ACT_STEERING, "STEERING", 0, "Steering", ""},
- {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-#ifdef RNA_RUNTIME
-
-#include "BKE_sca.h"
-
-static StructRNA *rna_Actuator_refine(struct PointerRNA *ptr)
-{
- bActuator *actuator = (bActuator *)ptr->data;
-
- switch (actuator->type) {
- case ACT_ACTION:
- return &RNA_ActionActuator;
- case ACT_OBJECT:
- return &RNA_ObjectActuator;
- case ACT_CAMERA:
- return &RNA_CameraActuator;
- case ACT_SOUND:
- return &RNA_SoundActuator;
- case ACT_PROPERTY:
- return &RNA_PropertyActuator;
- case ACT_CONSTRAINT:
- return &RNA_ConstraintActuator;
- case ACT_EDIT_OBJECT:
- return &RNA_EditObjectActuator;
- case ACT_SCENE:
- return &RNA_SceneActuator;
- case ACT_RANDOM:
- return &RNA_RandomActuator;
- case ACT_MESSAGE:
- return &RNA_MessageActuator;
- case ACT_GAME:
- return &RNA_GameActuator;
- case ACT_VISIBILITY:
- return &RNA_VisibilityActuator;
- case ACT_2DFILTER:
- return &RNA_Filter2DActuator;
- case ACT_PARENT:
- return &RNA_ParentActuator;
- case ACT_STATE:
- return &RNA_StateActuator;
- case ACT_ARMATURE:
- return &RNA_ArmatureActuator;
- case ACT_STEERING:
- return &RNA_SteeringActuator;
- case ACT_MOUSE:
- return &RNA_MouseActuator;
- default:
- return &RNA_Actuator;
- }
-}
-
-static void rna_Actuator_name_set(PointerRNA *ptr, const char *value)
-{
- Object *ob = ptr->id.data;
- bActuator *act = ptr->data;
- BLI_strncpy_utf8(act->name, value, sizeof(act->name));
- BLI_uniquename(&ob->actuators, act, DATA_("Actuator"), '.', offsetof(bActuator, name), sizeof(act->name));
-}
-
-static void rna_Actuator_type_set(struct PointerRNA *ptr, int value)
-{
- bActuator *act = (bActuator *)ptr->data;
-
- if (value != act->type) {
- act->type = value;
- init_actuator(act);
- }
-}
-
-static void rna_ConstraintActuator_type_set(struct PointerRNA *ptr, int value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
-
- if (value != ca->type) {
- ca->type = value;
- switch (ca->type) {
- case ACT_CONST_TYPE_ORI:
- /* negative axis not supported in the orientation mode */
- if (ELEM(ca->mode, ACT_CONST_DIRNX, ACT_CONST_DIRNY, ACT_CONST_DIRNZ))
- ca->mode = ACT_CONST_NONE;
- break;
-
- case ACT_CONST_TYPE_LOC:
- case ACT_CONST_TYPE_DIST:
- case ACT_CONST_TYPE_FH:
- default:
- break;
- }
- }
-}
-
-static float rna_ConstraintActuator_limitmin_get(struct PointerRNA *ptr)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->flag & ACT_CONST_LOCX) fp = ca->minloc;
- else if (ca->flag & ACT_CONST_LOCY) fp = ca->minloc + 1;
- else if (ca->flag & ACT_CONST_LOCZ) fp = ca->minloc + 2;
- else if (ca->flag & ACT_CONST_ROTX) fp = ca->minrot;
- else if (ca->flag & ACT_CONST_ROTY) fp = ca->minrot + 1;
- else fp = ca->minrot + 2;
-
- return *fp;
-}
-
-static void rna_ConstraintActuator_limitmin_set(struct PointerRNA *ptr, float value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->flag & ACT_CONST_LOCX) fp = ca->minloc;
- else if (ca->flag & ACT_CONST_LOCY) fp = ca->minloc + 1;
- else if (ca->flag & ACT_CONST_LOCZ) fp = ca->minloc + 2;
- else if (ca->flag & ACT_CONST_ROTX) fp = ca->minrot;
- else if (ca->flag & ACT_CONST_ROTY) fp = ca->minrot + 1;
- else fp = ca->minrot + 2;
-
- *fp = value;
-}
-
-static float rna_ConstraintActuator_limitmax_get(struct PointerRNA *ptr)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->flag & ACT_CONST_LOCX) fp = ca->maxloc;
- else if (ca->flag & ACT_CONST_LOCY) fp = ca->maxloc + 1;
- else if (ca->flag & ACT_CONST_LOCZ) fp = ca->maxloc + 2;
- else if (ca->flag & ACT_CONST_ROTX) fp = ca->maxrot;
- else if (ca->flag & ACT_CONST_ROTY) fp = ca->maxrot + 1;
- else fp = ca->maxrot + 2;
-
- return *fp;
-}
-
-static void rna_ConstraintActuator_limitmax_set(struct PointerRNA *ptr, float value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->flag & ACT_CONST_LOCX) fp = ca->maxloc;
- else if (ca->flag & ACT_CONST_LOCY) fp = ca->maxloc + 1;
- else if (ca->flag & ACT_CONST_LOCZ) fp = ca->maxloc + 2;
- else if (ca->flag & ACT_CONST_ROTX) fp = ca->maxrot;
- else if (ca->flag & ACT_CONST_ROTY) fp = ca->maxrot + 1;
- else fp = ca->maxrot + 2;
-
- *fp = value;
-}
-
-static float rna_ConstraintActuator_distance_get(struct PointerRNA *ptr)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->minloc;
- else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->minloc + 1;
- else fp = ca->minloc + 2;
-
- return *fp;
-}
-
-static void rna_ConstraintActuator_distance_set(struct PointerRNA *ptr, float value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->minloc;
- else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->minloc + 1;
- else fp = ca->minloc + 2;
-
- *fp = value;
-}
-
-static float rna_ConstraintActuator_range_get(struct PointerRNA *ptr)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->maxloc;
- else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->maxloc + 1;
- else fp = ca->maxloc + 2;
-
- return *fp;
-}
-
-static void rna_ConstraintActuator_range_set(struct PointerRNA *ptr, float value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->maxloc;
- else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->maxloc + 1;
- else fp = ca->maxloc + 2;
-
- *fp = value;
-}
-
-static float rna_ConstraintActuator_fhheight_get(struct PointerRNA *ptr)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->minloc;
- else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->minloc + 1;
- else fp = ca->minloc + 2;
-
- return *fp;
-}
-
-static void rna_ConstraintActuator_fhheight_set(struct PointerRNA *ptr, float value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->minloc;
- else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->minloc + 1;
- else fp = ca->minloc + 2;
-
- *fp = value;
-}
-
-static float rna_ConstraintActuator_spring_get(struct PointerRNA *ptr)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->maxloc;
- else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->maxloc + 1;
- else fp = ca->maxloc + 2;
-
- return *fp;
-}
-
-static void rna_ConstraintActuator_spring_set(struct PointerRNA *ptr, float value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
- float *fp;
-
- if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->maxloc;
- else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->maxloc + 1;
- else fp = ca->maxloc + 2;
-
- *fp = value;
-}
-/* ConstraintActuator uses the same property for Material and Property.
- * Therefore we need to clear the property when "use_material_detect" mode changes */
-static void rna_Actuator_constraint_detect_material_set(struct PointerRNA *ptr, int value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bConstraintActuator *ca = act->data;
-
- short old_value = (ca->flag & ACT_CONST_MATERIAL) ? 1 : 0;
-
- if (old_value != value) {
- ca->flag ^= ACT_CONST_MATERIAL;
- ca->matprop[0] = '\0';
- }
-}
-
-static void rna_ActionActuator_add_set(struct PointerRNA *ptr, int value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bActionActuator *aa = act->data;
-
- if (value == 1) {
- aa->flag &= ~ACT_IPOFORCE;
- aa->flag |= ACT_IPOADD;
- }
- else {
- aa->flag &= ~ACT_IPOADD;
- }
-}
-
-static void rna_ActionActuator_force_set(struct PointerRNA *ptr, int value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bActionActuator *aa = act->data;
-
- if (value == 1) {
- aa->flag &= ~ACT_IPOADD;
- aa->flag |= ACT_IPOFORCE;
- }
- else {
- aa->flag &= ~ACT_IPOFORCE;
- }
-}
-
-static void rna_ObjectActuator_type_set(struct PointerRNA *ptr, int value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bObjectActuator *oa = act->data;
- if (value != oa->type) {
- oa->type = value;
- switch (oa->type) {
- case ACT_OBJECT_NORMAL:
- memset(oa, 0, sizeof(bObjectActuator));
- oa->flag = ACT_FORCE_LOCAL | ACT_TORQUE_LOCAL | ACT_DLOC_LOCAL | ACT_DROT_LOCAL;
- oa->type = ACT_OBJECT_NORMAL;
- break;
-
- case ACT_OBJECT_SERVO:
- memset(oa, 0, sizeof(bObjectActuator));
- oa->flag = ACT_LIN_VEL_LOCAL;
- oa->type = ACT_OBJECT_SERVO;
- oa->forcerot[0] = 30.0f;
- oa->forcerot[1] = 0.5f;
- oa->forcerot[2] = 0.0f;
- break;
-
- case ACT_OBJECT_CHARACTER:
- memset(oa, 0, sizeof(bObjectActuator));
- oa->flag = ACT_DLOC_LOCAL | ACT_DROT_LOCAL;
- oa->type = ACT_OBJECT_CHARACTER;
- break;
- }
- }
-}
-
-static void rna_ObjectActuator_integralcoefficient_set(struct PointerRNA *ptr, float value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bObjectActuator *oa = act->data;
-
- oa->forcerot[1] = value;
- oa->forcerot[0] = 60.0f * oa->forcerot[1];
-}
-
-static void rna_StateActuator_state_set(PointerRNA *ptr, const int *values)
-{
- bActuator *act = (bActuator *)ptr->data;
- bStateActuator *sa = act->data;
-
- int i, tot = 0;
-
- /* ensure we always have some state selected */
- for (i = 0; i < OB_MAX_STATES; i++)
- if (values[i])
- tot++;
-
- if (tot == 0)
- return;
-
- for (i = 0; i < OB_MAX_STATES; i++) {
- if (values[i]) sa->mask |= (1 << i);
- else sa->mask &= ~(1 << i);
- }
-}
-
-/* Always keep in alphabetical order */
-const EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
-{
- EnumPropertyItem *item = NULL;
- Object *ob = NULL;
- int totitem = 0;
-
- if (ptr->type == &RNA_Actuator || RNA_struct_is_a(ptr->type, &RNA_Actuator)) {
- ob = (Object *)ptr->id.data;
- }
- else {
- /* can't use ob from ptr->id.data because that enum is also used by operators */
- ob = CTX_data_active_object(C);
- }
-
- if (ob != NULL) {
- if (ob->type == OB_ARMATURE) {
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ARMATURE);
- }
- }
-
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ACTION);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CAMERA);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CONSTRAINT);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_EDIT_OBJECT);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_2DFILTER);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_GAME);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_MESSAGE);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_MOUSE);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_OBJECT);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PARENT);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PROPERTY);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_RANDOM);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SCENE);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_STEERING);
-
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SOUND);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_STATE);
- RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_VISIBILITY);
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
-static void rna_Actuator_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- bActuator *act = (bActuator *)ptr->data;
- bArmatureActuator *aa = act->data;
- Object *ob = (Object *)ptr->id.data;
-
- char *posechannel = aa->posechannel;
- char *constraint = aa->constraint;
-
- /* check that bone exist in the active object */
- if (ob->type == OB_ARMATURE && ob->pose) {
- bPoseChannel *pchan;
- bPose *pose = ob->pose;
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- if (STREQ(pchan->name, posechannel)) {
- /* found it, now look for constraint channel */
- bConstraint *con;
- for (con = pchan->constraints.first; con; con = con->next) {
- if (STREQ(con->name, constraint)) {
- /* found it, all ok */
- return;
- }
- }
- /* didn't find constraint, make empty */
- constraint[0] = 0;
- return;
- }
- }
- }
- /* didn't find any */
- posechannel[0] = 0;
- constraint[0] = 0;
-}
-
-static void rna_SteeringActuator_navmesh_set(PointerRNA *ptr, PointerRNA value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bSteeringActuator *sa = (bSteeringActuator *) act->data;
-
- Object *obj = value.data;
- if (obj && obj->body_type == OB_BODY_TYPE_NAVMESH)
- sa->navmesh = obj;
- else
- sa->navmesh = NULL;
-}
-
-/* note: the following set functions exists only to avoid id refcounting */
-static void rna_Actuator_editobject_mesh_set(PointerRNA *ptr, PointerRNA value)
-{
- bActuator *act = (bActuator *)ptr->data;
- bEditObjectActuator *eoa = (bEditObjectActuator *) act->data;
-
- eoa->me = value.data;
-}
-
-#else
-
-static void rna_def_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "Actuator", NULL);
- RNA_def_struct_ui_text(srna, "Actuator", "Actuator to apply actions in the game engine");
- RNA_def_struct_sdna(srna, "bActuator");
- RNA_def_struct_refine_func(srna, "rna_Actuator_refine");
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Name", "");
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Actuator_name_set");
- RNA_def_struct_name_property(srna, prop);
-
- prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_enum_items(prop, actuator_type_items);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Actuator_type_set", "rna_Actuator_type_itemf");
- RNA_def_property_ui_text(prop, "Type", "");
-
- prop = RNA_def_property(srna, "pin", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_PIN);
- RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller");
- RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SHOW);
- RNA_def_property_ui_text(prop, "Expanded", "Set actuator expanded in the user interface");
- RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
-
- prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_DEACTIVATE);
- RNA_def_property_ui_text(prop, "Active", "Set the active state of the actuator");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- RNA_api_actuator(srna);
-}
-
-static void rna_def_action_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_ACTION_PLAY, "PLAY", 0, "Play", ""},
- {ACT_ACTION_PINGPONG, "PINGPONG", 0, "Ping Pong", ""},
- {ACT_ACTION_FLIPPER, "FLIPPER", 0, "Flipper", ""},
- {ACT_ACTION_LOOP_STOP, "LOOPSTOP", 0, "Loop Stop", ""},
- {ACT_ACTION_LOOP_END, "LOOPEND", 0, "Loop End", ""},
- {ACT_ACTION_FROM_PROP, "PROPERTY", 0, "Property", ""},
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- {ACT_ACTION_MOTION, "MOTION", 0, "Displacement", ""},
-#endif
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_blend_items[] = {
- {ACT_ACTION_BLEND, "BLEND", 0, "Blend", ""},
- {ACT_ACTION_ADD, "ADD", 0, "Add", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "ActionActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Action Actuator", "Actuator to control the object movement");
- RNA_def_struct_sdna_from(srna, "bActionActuator", "data");
-
- prop = RNA_def_property(srna, "play_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Action Type", "Action playback type");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "act");
- RNA_def_property_struct_type(prop, "Action");
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
- RNA_def_property_ui_text(prop, "Action", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_continue_last_frame", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "end_reset", 1);
- RNA_def_property_ui_text(prop, "Continue",
- "Restore last frame when switching on/off, otherwise play from the start each time");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "Use this property to define the Action position");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sta");
- RNA_def_property_ui_range(prop, 0.0, MAXFRAME, 100, 2);
- RNA_def_property_ui_text(prop, "Start Frame", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "end");
- RNA_def_property_ui_range(prop, 0.0, MAXFRAME, 100, 2);
- RNA_def_property_ui_text(prop, "End Frame", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "frame_blend_in", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "blendin");
- RNA_def_property_range(prop, 0, 32767);
- RNA_def_property_ui_text(prop, "Blendin", "Number of frames of motion blending");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "priority", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, 100);
- RNA_def_property_ui_text(prop, "Priority",
- "Execution priority - lower numbers will override actions with higher numbers "
- "(with 2 or more actions at once, the overriding channels must be lower in the stack)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "layer", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, 32766); /* This should match BL_ActionManager::MAX_ACTION_LAYERS - 1 */
- RNA_def_property_ui_text(prop, "Layer", "The animation layer to play the action on");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "layer_weight", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_ui_text(prop, "Layer Weight",
- "How much of the previous layer to blend into this one");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "frameProp");
- RNA_def_property_ui_text(prop, "Frame Property", "Assign the action's current frame number to this property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* booleans */
- prop = RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOADD);
- RNA_def_property_boolean_funcs(prop, NULL, "rna_ActionActuator_add_set");
- RNA_def_property_ui_text(prop, "Add",
- "Action is added to the current loc/rot/scale in global or local coordinate according to "
- "Local flag");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_force", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOFORCE);
- RNA_def_property_boolean_funcs(prop, NULL, "rna_ActionActuator_force_set");
- RNA_def_property_ui_text(prop, "Force",
- "Apply Action as a global or local force depending on the local option "
- "(dynamic objects only)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_local", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOLOCAL);
- RNA_def_property_ui_text(prop, "L", "Let the Action act in local coordinates, used in Force and Add mode");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "apply_to_children", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOCHILD);
- RNA_def_property_ui_text(prop, "Child", "Update Action on all children Objects as well");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "blend_mode");
- RNA_def_property_enum_items(prop, prop_blend_items);
- RNA_def_property_ui_text(prop, "Blend Mode", "How this layer is blended with previous layers");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- prop = RNA_def_property(srna, "stride_length", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "stridelength");
- RNA_def_property_range(prop, 0.0, 2500.0);
- RNA_def_property_ui_text(prop, "Cycle", "Distance covered by a single cycle of the action");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-#endif
-}
-
-static void rna_def_object_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_OBJECT_NORMAL, "OBJECT_NORMAL", 0, "Simple Motion", ""},
- {ACT_OBJECT_SERVO, "OBJECT_SERVO", 0, "Servo Control", ""},
- {ACT_OBJECT_CHARACTER, "OBJECT_CHARACTER", 0, "Character Motion", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "ObjectActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Motion Actuator", "Actuator to control the object movement");
- RNA_def_struct_sdna_from(srna, "bObjectActuator", "data");
-
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_enum_funcs(prop, NULL, "rna_ObjectActuator_type_set", NULL);
- RNA_def_property_ui_text(prop, "Motion Type", "Specify the motion system");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "reference_object", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_sdna(prop, NULL, "reference");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Reference Object",
- "Reference object for velocity calculation, leave empty for world reference");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "damping", PROP_INT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0, 1000, 1, 1);
- RNA_def_property_ui_text(prop, "Damping Frames", "Number of frames to reach the target velocity");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "proportional_coefficient", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "forcerot[0]");
- RNA_def_property_ui_range(prop, 0.0, 200.0, 10, 2);
- RNA_def_property_ui_text(prop, "Proportional Coefficient", "Typical value is 60x integral coefficient");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "integral_coefficient", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "forcerot[1]");
- RNA_def_property_ui_range(prop, 0.0, 3.0, 10, 2);
- RNA_def_property_float_funcs(prop, NULL, "rna_ObjectActuator_integralcoefficient_set", NULL);
- RNA_def_property_ui_text(prop, "Integral Coefficient",
- "Low value (0.01) for slow response, high value (0.5) for fast response");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "derivate_coefficient", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "forcerot[2]");
- RNA_def_property_ui_range(prop, -100.0, 100.0, 10, 2);
- RNA_def_property_ui_text(prop, "Derivate Coefficient", "Not required, high values can cause instability");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Servo Limit */
- prop = RNA_def_property(srna, "force_max_x", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "dloc[0]");
- RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2);
- RNA_def_property_ui_text(prop, "Max", "Upper limit for X force");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "force_min_x", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "drot[0]");
- RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2);
- RNA_def_property_ui_text(prop, "Min", "Lower limit for X force");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "force_max_y", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "dloc[1]");
- RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2);
- RNA_def_property_ui_text(prop, "Max", "Upper limit for Y force");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "force_min_y", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "drot[1]");
- RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2);
- RNA_def_property_ui_text(prop, "Min", "Lower limit for Y force");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "force_max_z", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "dloc[2]");
- RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2);
- RNA_def_property_ui_text(prop, "Max", "Upper limit for Z force");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "force_min_z", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "drot[2]");
- RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2);
- RNA_def_property_ui_text(prop, "Min", "Lower limit for Z force");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* floats 3 Arrays*/
- prop = RNA_def_property(srna, "offset_location", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "dloc");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2);
- RNA_def_property_ui_text(prop, "Loc", "Location");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "offset_rotation", PROP_FLOAT, PROP_EULER);
- RNA_def_property_float_sdna(prop, NULL, "drot");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2);
- RNA_def_property_ui_text(prop, "Rot", "Rotation");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "force", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "forceloc");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2);
- RNA_def_property_ui_text(prop, "Force", "Force");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "torque", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "forcerot");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2);
- RNA_def_property_ui_text(prop, "Torque", "Torque");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "linear_velocity", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "linearvelocity");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2);
- RNA_def_property_ui_text(prop, "Linear Velocity",
- "Linear velocity (in Servo mode it sets the target relative linear velocity, it will be "
- "achieved by automatic application of force - Null velocity is a valid target)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "angularvelocity");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2);
- RNA_def_property_ui_text(prop, "Angular Velocity", "Angular velocity");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* booleans */
- prop = RNA_def_property(srna, "use_local_location", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_DLOC_LOCAL);
- RNA_def_property_ui_text(prop, "L", "Location is defined in local coordinates");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_local_rotation", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_DROT_LOCAL);
- RNA_def_property_ui_text(prop, "L", "Rotation is defined in local coordinates");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_local_force", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_FORCE_LOCAL);
- RNA_def_property_ui_text(prop, "L", "Force is defined in local coordinates");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_local_torque", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_TORQUE_LOCAL);
- RNA_def_property_ui_text(prop, "L", "Torque is defined in local coordinates");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_local_linear_velocity", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_LIN_VEL_LOCAL);
- RNA_def_property_ui_text(prop, "L", "Velocity is defined in local coordinates");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_local_angular_velocity", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_ANG_VEL_LOCAL);
- RNA_def_property_ui_text(prop, "L", "Angular velocity is defined in local coordinates");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_add_linear_velocity", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_ADD_LIN_VEL);
- RNA_def_property_ui_text(prop, "Add", "Toggles between ADD and SET linV");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_add_character_location", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_ADD_CHAR_LOC);
- RNA_def_property_ui_text(prop, "Add", "Toggle between ADD and SET character location");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_servo_limit_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SERVO_LIMIT_X);
- RNA_def_property_ui_text(prop, "X", "Set limit to force along the X axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_servo_limit_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SERVO_LIMIT_Y);
- RNA_def_property_ui_text(prop, "Y", "Set limit to force along the Y axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_servo_limit_z", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SERVO_LIMIT_Z);
- RNA_def_property_ui_text(prop, "Z", "Set limit to force along the Z axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_character_jump", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CHAR_JUMP);
- RNA_def_property_ui_text(prop, "Jump", "Make the character jump using the settings in the physics properties");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_camera_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_axis_items[] = {
- {OB_POSX, "POS_X", 0, "+X", "Camera tries to get behind the X axis"},
- {OB_POSY, "POS_Y", 0, "+Y", "Camera tries to get behind the Y axis"},
- {OB_NEGX, "NEG_X", 0, "-X", "Camera tries to get behind the -X axis"},
- {OB_NEGY, "NEG_Y", 0, "-Y", "Camera tries to get behind the -Y axis"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "CameraActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Camera Actuator", "");
- RNA_def_struct_sdna_from(srna, "bCameraActuator", "data");
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_sdna(prop, NULL, "ob");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Camera Object", "Look at this Object");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* floats */
- prop = RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.0, 20.0, 1, 2);
- RNA_def_property_ui_text(prop, "Height", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.0, 20.0, 1, 2);
- RNA_def_property_ui_text(prop, "Min", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.0, 20.0, 1, 2);
- RNA_def_property_ui_text(prop, "Max", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "damping");
- RNA_def_property_range(prop, 0, 10.0);
- RNA_def_property_ui_range(prop, 0, 5.0, 1, 2);
- RNA_def_property_ui_text(prop, "Damping", "Strength of the constraint that drives the camera behind the target");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* +x/+y/-x/-y */
- prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "axis");
- RNA_def_property_enum_items(prop, prop_axis_items);
- RNA_def_property_ui_text(prop, "Axis", "Axis the Camera will try to get behind");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_sound_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_SND_PLAY_STOP_SOUND, "PLAYSTOP", 0, "Play Stop", ""},
- {ACT_SND_PLAY_END_SOUND, "PLAYEND", 0, "Play End", ""},
- {ACT_SND_LOOP_STOP_SOUND, "LOOPSTOP", 0, "Loop Stop", ""},
- {ACT_SND_LOOP_END_SOUND, "LOOPEND", 0, "Loop End", ""},
- {ACT_SND_LOOP_BIDIRECTIONAL_SOUND, "LOOPBIDIRECTIONAL", 0, "Loop Bidirectional", ""},
- {ACT_SND_LOOP_BIDIRECTIONAL_STOP_SOUND, "LOOPBIDIRECTIONALSTOP", 0, "Loop Bidirectional Stop", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "SoundActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Sound Actuator", "Actuator to handle sound");
- RNA_def_struct_sdna_from(srna, "bSoundActuator", "data");
-
- prop = RNA_def_property(srna, "sound", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Sound");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_struct_ui_text(srna, "Sound", "Sound file");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Play Mode", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "volume", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2);
- RNA_def_property_range(prop, 0.0, 2.0);
- RNA_def_property_ui_text(prop, "Volume", "Initial volume of the sound");
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SOUND);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, -12.0, 12.0, 1, 2);
- RNA_def_property_ui_text(prop, "Pitch", "Pitch of the sound");
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SOUND);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* floats - 3D Parameters */
- prop = RNA_def_property(srna, "gain_3d_min", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sound3D.min_gain");
- RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2);
- RNA_def_property_ui_text(prop, "Minimum Gain", "The minimum gain of the sound, no matter how far it is away");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "gain_3d_max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sound3D.max_gain");
- RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2);
- RNA_def_property_ui_text(prop, "Maximum Gain", "The maximum gain of the sound, no matter how near it is");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "distance_3d_reference", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sound3D.reference_distance");
- RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 1, 2);
- RNA_def_property_ui_text(prop, "Reference Distance", "The distance where the sound has a gain of 1.0");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "distance_3d_max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sound3D.max_distance");
- RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 1, 2);
- RNA_def_property_ui_text(prop, "Maximum Distance", "The maximum distance at which you can hear the sound");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "rolloff_factor_3d", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sound3D.rolloff_factor");
- RNA_def_property_ui_range(prop, 0.0, 5.0, 1, 2);
- RNA_def_property_ui_text(prop, "Rolloff", "The influence factor on volume depending on distance");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "cone_outer_gain_3d", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sound3D.cone_outer_gain");
- RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2);
- RNA_def_property_ui_text(prop, "Cone Outer Gain",
- "The gain outside the outer cone (the gain in the outer cone will be interpolated "
- "between this value and the normal gain in the inner cone)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "cone_outer_angle_3d", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "sound3D.cone_outer_angle");
- RNA_def_property_ui_range(prop, 0.0, DEG2RADF(360.0f), 1, 2);
- RNA_def_property_ui_text(prop, "Cone Outer Angle", "The angle of the outer cone");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "cone_inner_angle_3d", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "sound3D.cone_inner_angle");
- RNA_def_property_ui_range(prop, 0.0, DEG2RADF(360.0f), 1, 2);
- RNA_def_property_ui_text(prop, "Cone Inner Angle", "The angle of the inner cone");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* booleans */
- prop = RNA_def_property(srna, "use_sound_3d", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SND_3D_SOUND);
- RNA_def_property_ui_text(prop, "3D Sound", "Enable/Disable 3D Sound");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_property_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_PROP_ASSIGN, "ASSIGN", 0, "Assign", ""},
- {ACT_PROP_ADD, "ADD", 0, "Add", ""},
- {ACT_PROP_COPY, "COPY", 0, "Copy", ""},
- {ACT_PROP_TOGGLE, "TOGGLE", 0, "Toggle", "For bool/int/float/timer properties only"},
- {ACT_PROP_LEVEL, "LEVEL", 0, "Level", "For bool/int/float/timer properties only"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "PropertyActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Property Actuator", "Actuator to handle properties");
- RNA_def_struct_sdna_from(srna, "bPropertyActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Mode", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "The name of the property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Value", "The name of the property or the value to use (use \"\" around strings)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Copy Mode */
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_sdna(prop, NULL, "ob");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Object", "Copy from this Object");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /*XXX add even magic'er property lookup (need to look for the property list of the target object) */
- prop = RNA_def_property(srna, "object_property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "value");
- RNA_def_property_ui_text(prop, "Property Name", "Copy this property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_constraint_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_CONST_TYPE_LOC, "LOC", 0, "Location Constraint", ""},
- {ACT_CONST_TYPE_DIST, "DIST", 0, "Distance Constraint", ""},
- {ACT_CONST_TYPE_ORI, "ORI", 0, "Orientation Constraint", ""},
- {ACT_CONST_TYPE_FH, "FH", 0, "Force Field Constraint", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_limit_items[] = {
- {ACT_CONST_NONE, "NONE", 0, "None", ""},
- {ACT_CONST_LOCX, "LOCX", 0, "Loc X", ""},
- {ACT_CONST_LOCY, "LOCY", 0, "Loc Y", ""},
- {ACT_CONST_LOCZ, "LOCZ", 0, "Loc Z", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_direction_items[] = {
- {ACT_CONST_NONE, "NONE", 0, "None", ""},
- {ACT_CONST_DIRPX, "DIRPX", 0, "X axis", ""},
- {ACT_CONST_DIRPY, "DIRPY", 0, "Y axis", ""},
- {ACT_CONST_DIRPZ, "DIRPZ", 0, "Z axis", ""},
- {ACT_CONST_DIRNX, "DIRNX", 0, "-X axis", ""},
- {ACT_CONST_DIRNY, "DIRNY", 0, "-Y axis", ""},
- {ACT_CONST_DIRNZ, "DIRNZ", 0, "-Z axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_direction_pos_items[] = {
- {ACT_CONST_NONE, "NONE", 0, "None", ""},
- {ACT_CONST_DIRPX, "DIRPX", 0, "X axis", ""},
- {ACT_CONST_DIRPY, "DIRPY", 0, "Y axis", ""},
- {ACT_CONST_DIRPZ, "DIRPZ", 0, "Z axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "ConstraintActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Constraint Actuator", "Actuator to handle Constraints");
- RNA_def_struct_sdna_from(srna, "bConstraintActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_enum_funcs(prop, NULL, "rna_ConstraintActuator_type_set", NULL);
- RNA_def_property_ui_text(prop, "Constraints Mode", "The type of the constraint");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "limit", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "flag");
- RNA_def_property_enum_items(prop, prop_limit_items);
- RNA_def_property_ui_text(prop, "Limit", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, prop_direction_items);
- RNA_def_property_ui_text(prop, "Direction", "Direction of the ray");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "direction_axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, prop_direction_items);
- RNA_def_property_ui_text(prop, "Direction", "Select the axis to be aligned along the reference direction");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_CONST_TYPE_LOC */
- prop = RNA_def_property(srna, "limit_min", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_limitmin_get",
- "rna_ConstraintActuator_limitmin_set", NULL);
- RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2);
- RNA_def_property_ui_text(prop, "Min", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "limit_max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_limitmax_get",
- "rna_ConstraintActuator_limitmax_set", NULL);
- RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2);
- RNA_def_property_ui_text(prop, "Max", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "damping", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "damp");
- RNA_def_property_ui_range(prop, 0, 100, 1, 1);
- RNA_def_property_ui_text(prop, "Damping", "Damping factor: time constant (in frame) of low pass filter");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_CONST_TYPE_DIST */
- prop = RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_range_get", "rna_ConstraintActuator_range_set", NULL);
- RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2);
- RNA_def_property_ui_text(prop, "Range", "Maximum length of ray");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_distance_get",
- "rna_ConstraintActuator_distance_set", NULL);
- RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2);
- RNA_def_property_ui_text(prop, "Distance", "Keep this distance to target");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /*XXX to use a pointer or add a material lookup */
- prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "matprop");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Material", "Ray detects only Objects with this material");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /*XXX add magic property lookup */
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "matprop");
- RNA_def_property_ui_text(prop, "Property", "Ray detects only Objects with this property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "time", PROP_INT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0, 1000, 1, 2);
- RNA_def_property_ui_text(prop, "Time", "Maximum activation time in frame, 0 for unlimited");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "damping_rotation", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "rotdamp");
- RNA_def_property_ui_range(prop, 0, 100, 1, 1);
- RNA_def_property_ui_text(prop, "RotDamp", "Use a different damping for orientation");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_CONST_TYPE_ORI */
- prop = RNA_def_property(srna, "direction_axis_pos", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, prop_direction_pos_items);
- RNA_def_property_ui_text(prop, "Direction", "Select the axis to be aligned along the reference direction");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "rotation_max", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "maxrot");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_range(prop, -2000.0, 2000.0, 10, 2);
- RNA_def_property_ui_text(prop, "Reference Direction", "Reference Direction");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "minloc[0]");
- RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
- RNA_def_property_ui_text(prop, "Min Angle",
- "Minimum angle to maintain with target direction "
- "(no correction is done if angle with target direction is between min and max)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "maxloc[0]");
- RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
- RNA_def_property_ui_text(prop, "Max Angle",
- "Maximum angle allowed with target direction "
- "(no correction is done if angle with target direction is between min and max)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_CONST_TYPE_FH */
- prop = RNA_def_property(srna, "fh_height", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_fhheight_get",
- "rna_ConstraintActuator_fhheight_set", NULL);
- RNA_def_property_ui_range(prop, 0.01, 2000.0, 10, 2);
- RNA_def_property_ui_text(prop, "Distance", "Height of the force field area");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "fh_force", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_spring_get", "rna_ConstraintActuator_spring_set", NULL);
- RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2);
- RNA_def_property_ui_text(prop, "Force", "Spring force within the force field area");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "fh_damping", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "maxrot[0]");
- RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2);
- RNA_def_property_ui_text(prop, "Damping", "Damping factor of the force field spring");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* booleans */
- prop = RNA_def_property(srna, "use_force_distance", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_DISTANCE);
- RNA_def_property_ui_text(prop, "Force Distance", "Force distance of object to point of impact of ray");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_local", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_LOCAL);
- RNA_def_property_ui_text(prop, "L", "Set ray along object's axis or global axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_NORMAL);
- RNA_def_property_ui_text(prop, "N",
- "Set object axis along (local axis) or parallel (global axis) to the normal at "
- "hit position");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_persistent", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_PERMANENT);
- RNA_def_property_ui_text(prop, "PER", "Persistent actuator: stays active even if ray does not reach target");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /*XXX to use an enum instead of a flag if possible */
- prop = RNA_def_property(srna, "use_material_detect", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_MATERIAL);
- RNA_def_property_ui_text(prop, "M/P", "Detect material instead of property");
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Actuator_constraint_detect_material_set");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_fh_paralel_axis", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_DOROTFH);
- RNA_def_property_ui_text(prop, "Rot Fh", "Keep object axis parallel to normal");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_fh_normal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_NORMAL);
- RNA_def_property_ui_text(prop, "N", "Add a horizontal spring force on slopes");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_edit_object_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_dyn_items[] = {
- {ACT_EDOB_RESTORE_DYN, "RESTOREDYN", 0, "Restore Dynamics", ""},
- {ACT_EDOB_SUSPEND_DYN, "SUSPENDDYN", 0, "Suspend Dynamics", ""},
- {ACT_EDOB_ENABLE_RB, "ENABLERIGIDBODY", 0, "Enable Rigid Body", ""},
- {ACT_EDOB_DISABLE_RB, "DISABLERIGIDBODY", 0, "Disable Rigid Body", ""},
- {ACT_EDOB_SET_MASS, "SETMASS", 0, "Set Mass", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_EDOB_ADD_OBJECT, "ADDOBJECT", 0, "Add Object", ""},
- {ACT_EDOB_END_OBJECT, "ENDOBJECT", 0, "End Object", ""},
- {ACT_EDOB_REPLACE_MESH, "REPLACEMESH", 0, "Replace Mesh", ""},
- {ACT_EDOB_TRACK_TO, "TRACKTO", 0, "Track to", ""},
- {ACT_EDOB_DYNAMICS, "DYNAMICS", 0, "Dynamics", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_track_axis_items[] = {
- {ACT_TRACK_TRAXIS_X, "TRACKAXISX", 0, "X axis", ""},
- {ACT_TRACK_TRAXIS_Y, "TRACKAXISY", 0, "Y axis", ""},
- {ACT_TRACK_TRAXIS_Z, "TRACKAXISZ", 0, "Z axis", ""},
- {ACT_TRACK_TRAXIS_NEGX, "TRACKAXISNEGX", 0, "-X axis", ""},
- {ACT_TRACK_TRAXIS_NEGY, "TRACKAXISNEGY", 0, "-Y axis", ""},
- {ACT_TRACK_TRAXIS_NEGZ, "TRACKAXISNEGZ", 0, "-Z axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_up_axis_items[] = {
- {ACT_TRACK_UP_X, "UPAXISX", 0, "X axis", ""},
- {ACT_TRACK_UP_Y, "UPAXISY", 0, "Y axis", ""},
- {ACT_TRACK_UP_Z, "UPAXISZ", 0, "Z axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "EditObjectActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Edit Object Actuator", "Actuator used to edit objects");
- RNA_def_struct_sdna_from(srna, "bEditObjectActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Edit Object", "The mode of the actuator");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "dynamic_operation", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "dyn_operation");
- RNA_def_property_enum_items(prop, prop_dyn_items);
- RNA_def_property_ui_text(prop, "Dynamic Operation", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "upflag");
- RNA_def_property_enum_items(prop, prop_up_axis_items);
- RNA_def_property_ui_text(prop, "Up Axis", "The axis that points upward");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "trackflag");
- RNA_def_property_enum_items(prop, prop_track_axis_items);
- RNA_def_property_ui_text(prop, "Track Axis", "The axis that points to the target object");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_sdna(prop, NULL, "ob");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Object", "Add this Object and all its children (can't be on a visible layer)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "track_object", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_sdna(prop, NULL, "ob");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Object", "Track to this Object");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "mesh", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Mesh");
- RNA_def_property_pointer_sdna(prop, NULL, "me");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Mesh",
- "Replace the existing, when left blank 'Phys' will remake the existing physics mesh");
- /* note: custom set function is ONLY to avoid rna setting a user for this. */
- RNA_def_property_pointer_funcs(prop, NULL, "rna_Actuator_editobject_mesh_set", NULL, NULL);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "time", PROP_INT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0, 2000, 1, 1);
- RNA_def_property_ui_text(prop, "Time", "Duration the new Object lives or the track takes");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0, 10000, 1, 2);
- RNA_def_property_ui_text(prop, "Mass", "The mass of the object");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* floats 3 Arrays*/
- prop = RNA_def_property(srna, "linear_velocity", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "linVelocity");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_range(prop, -100.0, 100.0, 10, 2);
- RNA_def_property_ui_text(prop, "Linear Velocity", "Velocity upon creation");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "angVelocity");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2);
- RNA_def_property_ui_text(prop, "Angular Velocity", "Angular velocity upon creation");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* booleans */
- prop = RNA_def_property(srna, "use_local_linear_velocity", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "localflag", ACT_EDOB_LOCAL_LINV);
- RNA_def_property_ui_text(prop, "L", "Apply the transformation locally");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_local_angular_velocity", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "localflag", ACT_EDOB_LOCAL_ANGV);
- RNA_def_property_ui_text(prop, "L", "Apply the rotation locally");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_replace_display_mesh", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_EDOB_REPLACE_MESH_NOGFX);
- RNA_def_property_ui_text(prop, "Gfx", "Replace the display mesh");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_replace_physics_mesh", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_EDOB_REPLACE_MESH_PHYS);
- RNA_def_property_ui_text(prop, "Phys",
- "Replace the physics mesh (triangle bounds only - compound shapes not supported)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_3d_tracking", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_TRACK_3D);
- RNA_def_property_ui_text(prop, "3D", "Enable 3D tracking");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_scene_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_SCENE_RESTART, "RESTART", 0, "Restart", ""},
- {ACT_SCENE_SET, "SET", 0, "Set Scene", ""},
- {ACT_SCENE_CAMERA, "CAMERA", 0, "Set Camera", ""},
- {ACT_SCENE_ADD_FRONT, "ADDFRONT", 0, "Add Overlay Scene", ""},
- {ACT_SCENE_ADD_BACK, "ADDBACK", 0, "Add Background Scene", ""},
- {ACT_SCENE_REMOVE, "REMOVE", 0, "Remove Scene", ""},
- {ACT_SCENE_SUSPEND, "SUSPEND", 0, "Suspend Scene", ""},
- {ACT_SCENE_RESUME, "RESUME", 0, "Resume Scene", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "SceneActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Scene Actuator", "");
- RNA_def_struct_sdna_from(srna, "bSceneActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Mode", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Camera Object", "Set this Camera (leave empty to refer to self object)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Scene");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Scene", "Scene to be added/removed/paused/resumed");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_random_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_distribution_items[] = {
- {ACT_RANDOM_BOOL_CONST, "BOOL_CONSTANT", 0, "Bool Constant", ""},
- {ACT_RANDOM_BOOL_UNIFORM, "BOOL_UNIFORM", 0, "Bool Uniform", ""},
- {ACT_RANDOM_BOOL_BERNOUILLI, "BOOL_BERNOUILLI", 0, "Bool Bernoulli", ""},
- {ACT_RANDOM_INT_CONST, "INT_CONSTANT", 0, "Int Constant", ""},
- {ACT_RANDOM_INT_UNIFORM, "INT_UNIFORM", 0, "Int Uniform", ""},
- {ACT_RANDOM_INT_POISSON, "INT_POISSON", 0, "Int Poisson", ""},
- {ACT_RANDOM_FLOAT_CONST, "FLOAT_CONSTANT", 0, "Float Constant", ""},
- {ACT_RANDOM_FLOAT_UNIFORM, "FLOAT_UNIFORM", 0, "Float Uniform", ""},
- {ACT_RANDOM_FLOAT_NORMAL, "FLOAT_NORMAL", 0, "Float Normal", ""},
- {ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL, "FLOAT_NEGATIVE_EXPONENTIAL", 0, "Float Neg. Exp.", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "RandomActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Random Actuator", "");
- RNA_def_struct_sdna_from(srna, "bRandomActuator", "data");
-
- prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0, 1000, 1, 1);
- RNA_def_property_range(prop, 0, MAXFRAME);
- RNA_def_property_ui_text(prop, "Seed",
- "Initial seed of the random generator, use Python for more freedom "
- "(choose 0 for not random)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "propname");
- RNA_def_property_ui_text(prop, "Property", "Assign the random value to this property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, prop_distribution_items);
- RNA_def_property_ui_text(prop, "Distribution", "Choose the type of distribution");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* arguments for the distribution */
- /* int_arg_1, int_arg_2, float_arg_1, float_arg_2 */
-
- /* ACT_RANDOM_BOOL_CONST */
- prop = RNA_def_property(srna, "use_always_true", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "int_arg_1", 1);
- RNA_def_property_ui_text(prop, "Always True", "Always false or always true");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_RANDOM_BOOL_UNIFORM */
- /* label => "Choose between true and false, 50% chance each" */
-
- /* ACT_RANDOM_BOOL_BERNOUILLI */
- prop = RNA_def_property(srna, "chance", PROP_FLOAT, PROP_PERCENTAGE);
- RNA_def_property_float_sdna(prop, NULL, "float_arg_1");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_ui_text(prop, "Chance", "Pick a number between 0 and 1, success if it's below this value");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_RANDOM_INT_CONST */
- prop = RNA_def_property(srna, "int_value", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "int_arg_1");
- RNA_def_property_ui_range(prop, -1000, 1000, 1, 1);
- RNA_def_property_ui_text(prop, "Value", "Always return this number");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_RANDOM_INT_UNIFORM */
- prop = RNA_def_property(srna, "int_min", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "int_arg_1");
- RNA_def_property_range(prop, -1000, 1000);
- RNA_def_property_ui_text(prop, "Min", "Choose a number from a range: lower boundary of the range");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "int_max", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "int_arg_2");
- RNA_def_property_range(prop, -1000, 1000);
- RNA_def_property_ui_text(prop, "Max", "Choose a number from a range: upper boundary of the range");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_RANDOM_INT_POISSON */
- prop = RNA_def_property(srna, "int_mean", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "float_arg_1");
- RNA_def_property_range(prop, 0.01, 100.0);
- RNA_def_property_ui_text(prop, "Mean", "Expected mean value of the distribution");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_RANDOM_FLOAT_CONST */
- prop = RNA_def_property(srna, "float_value", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "float_arg_1");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_ui_text(prop, "Value", "Always return this number");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_RANDOM_FLOAT_UNIFORM */
- prop = RNA_def_property(srna, "float_min", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "float_arg_1");
- RNA_def_property_range(prop, -1000.0, 1000.0);
- RNA_def_property_ui_text(prop, "Min", "Choose a number from a range: lower boundary of the range");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "float_max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "float_arg_2");
- RNA_def_property_range(prop, -1000.0, 1000.0);
- RNA_def_property_ui_text(prop, "Max", "Choose a number from a range: upper boundary of the range");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_RANDOM_FLOAT_NORMAL */
- prop = RNA_def_property(srna, "float_mean", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "float_arg_1");
- RNA_def_property_range(prop, -1000.0, 1000.0);
- RNA_def_property_ui_text(prop, "Mean", "A normal distribution: mean of the distribution");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "standard_derivation", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "float_arg_2");
- RNA_def_property_range(prop, -1000.0, 1000.0);
- RNA_def_property_ui_text(prop, "SD", "A normal distribution: standard deviation of the distribution");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL */
- prop = RNA_def_property(srna, "half_life_time", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "float_arg_1");
- RNA_def_property_range(prop, -1000.0, 1000.0);
- RNA_def_property_ui_text(prop, "Half-Life Time", "Negative exponential dropoff");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_message_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_body_type_items[] = {
- {ACT_MESG_MESG, "TEXT", 0, "Text", ""},
- {ACT_MESG_PROP, "PROPERTY", 0, "Property", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "MessageActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Message Actuator", "");
- RNA_def_struct_sdna_from(srna, "bMessageActuator", "data");
-
- prop = RNA_def_property(srna, "to_property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "toPropName");
- RNA_def_property_ui_text(prop, "To",
- "Optional, send message to objects with this name only, or empty to broadcast");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "subject", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Subject", "Optional, message subject (this is what can be filtered on)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "body_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "bodyType");
- RNA_def_property_enum_items(prop, prop_body_type_items);
- RNA_def_property_ui_text(prop, "Body", "Toggle message type: either Text or a PropertyName");
-
- /* ACT_MESG_MESG */
- prop = RNA_def_property(srna, "body_message", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "body");
- RNA_def_property_ui_text(prop, "Body", "Optional, message body Text");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_MESG_PROP */
- prop = RNA_def_property(srna, "body_property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "body");
- RNA_def_property_ui_text(prop, "Prop Name", "The message body will be set by the Property Value");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_game_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
-/* {ACT_GAME_LOAD, "LOAD", 0, "Load Game", ""}, */
-/* {ACT_GAME_START, "START", 0, "Start Loaded Game", ""}, */
-/* keeping the load/start hacky for compatibility with 2.49 */
-/* ideally we could use ACT_GAME_START again and do a do_version() */
-
- {ACT_GAME_LOAD, "START", 0, "Start Game From File", ""},
- {ACT_GAME_RESTART, "RESTART", 0, "Restart Game", ""},
- {ACT_GAME_QUIT, "QUIT", 0, "Quit Game", ""},
- {ACT_GAME_SAVECFG, "SAVECFG", 0, "Save bge.logic.globalDict", ""},
- {ACT_GAME_LOADCFG, "LOADCFG", 0, "Load bge.logic.globalDict", ""},
- {ACT_GAME_SCREENSHOT, "SCREENSHOT", 0, "Screenshot", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "GameActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Game Actuator", "");
- RNA_def_struct_sdna_from(srna, "bGameActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Game", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* ACT_GAME_LOAD */
- prop = RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH);
- RNA_def_property_ui_text(prop, "File",
- "The file to use, depending on the mode (e.g. the blend file to load or a destination "
- "for saving a screenshot) - use the \"//\" prefix for a relative path");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
- /*XXX to do: an operator that calls file_browse with relative_path on and blender filtering active */
-}
-
-static void rna_def_visibility_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "VisibilityActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Visibility Actuator", "Actuator to set visibility and occlusion of the object");
- RNA_def_struct_sdna_from(srna, "bVisibilityActuator", "data");
-
- prop = RNA_def_property(srna, "use_visible", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_VISIBILITY_INVISIBLE);
- RNA_def_property_ui_text(prop, "Visible",
- "Set the objects visible (initialized from the object render restriction toggle in "
- "physics button)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_occlusion", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_VISIBILITY_OCCLUSION);
- RNA_def_property_ui_text(prop, "Occlusion",
- "Set the object to occlude objects behind it (initialized from the object type in "
- "physics button)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "apply_to_children", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_VISIBILITY_RECURSIVE);
- RNA_def_property_ui_text(prop, "Children",
- "Set all the children of this object to the same visibility/occlusion recursively");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_twodfilter_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_2DFILTER_ENABLED, "ENABLE", 0, "Enable Filter", ""},
- {ACT_2DFILTER_DISABLED, "DISABLE", 0, "Disable Filter", ""},
- {ACT_2DFILTER_NOFILTER, "REMOVE", 0, "Remove Filter", ""},
- {ACT_2DFILTER_MOTIONBLUR, "MOTIONBLUR", 0, "Motion Blur", ""},
- {ACT_2DFILTER_BLUR, "BLUR", 0, "Blur", ""},
- {ACT_2DFILTER_SHARPEN, "SHARPEN", 0, "Sharpen", ""},
- {ACT_2DFILTER_DILATION, "DILATION", 0, "Dilation", ""},
- {ACT_2DFILTER_EROSION, "EROSION", 0, "Erosion", ""},
- {ACT_2DFILTER_LAPLACIAN, "LAPLACIAN", 0, "Laplacian", ""},
- {ACT_2DFILTER_SOBEL, "SOBEL", 0, "Sobel", ""},
- {ACT_2DFILTER_PREWITT, "PREWITT", 0, "Prewitt", ""},
- {ACT_2DFILTER_GRAYSCALE, "GRAYSCALE", 0, "Gray Scale", ""},
- {ACT_2DFILTER_SEPIA, "SEPIA", 0, "Sepia", ""},
- {ACT_2DFILTER_INVERT, "INVERT", 0, "Invert", ""},
- {ACT_2DFILTER_CUSTOMFILTER, "CUSTOMFILTER", 0, "Custom Filter", ""},
-/* {ACT_2DFILTER_NUMBER_OF_FILTERS, "", 0, "Do not use it. Sentinel", ""}, */
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "Filter2DActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Filter 2D Actuator", "Actuator to apply screen graphic effects");
- RNA_def_struct_sdna_from(srna, "bTwoDFilterActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Filter 2D Type", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "glsl_shader", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "text");
- RNA_def_property_struct_type(prop, "Text");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Script", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "filter_pass", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "int_arg");
- RNA_def_property_ui_text(prop, "Pass Number", "Set filter order");
- RNA_def_property_range(prop, 0, 99); /*MAX_RENDER_PASS-1 */
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "motion_blur_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "float_arg");
- RNA_def_property_ui_text(prop, "Value", "Motion blur factor");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* booleans */
- prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", 1);
- RNA_def_property_ui_text(prop, "Enable", "Enable/Disable Motion Blur");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_parent_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_PARENT_SET, "SETPARENT", 0, "Set Parent", ""},
- {ACT_PARENT_REMOVE, "REMOVEPARENT", 0, "Remove Parent", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "ParentActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Parent Actuator", "");
- RNA_def_struct_sdna_from(srna, "bParentActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Scene", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_sdna(prop, NULL, "ob");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Parent Object", "Set this object as parent");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* booleans */
- prop = RNA_def_property(srna, "use_compound", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_PARENT_COMPOUND);
- RNA_def_property_ui_text(prop, "Compound",
- "Add this object shape to the parent shape "
- "(only if the parent shape is already compound)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_PARENT_GHOST);
- RNA_def_property_ui_text(prop, "Ghost", "Make this object ghost while parented");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_state_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_STATE_SET, "SET", 0, "Set State", ""},
- {ACT_STATE_ADD, "ADD", 0, "Add State", ""},
- {ACT_STATE_REMOVE, "REMOVE", 0, "Remove State", ""},
- {ACT_STATE_CHANGE, "CHANGE", 0, "Change State", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "StateActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "State Actuator", "Actuator to handle states");
- RNA_def_struct_sdna_from(srna, "bStateActuator", "data");
-
- prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Operation", "Select the bit operation on object state mask");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER);
- RNA_def_property_boolean_sdna(prop, NULL, "mask", 1);
- RNA_def_property_array(prop, OB_MAX_STATES);
- RNA_def_property_ui_text(prop, "State", "");
- RNA_def_property_boolean_funcs(prop, NULL, "rna_StateActuator_state_set");
-}
-
-static void rna_def_armature_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_ARM_RUN, "RUN", 0, "Run Armature", ""},
- {ACT_ARM_ENABLE, "ENABLE", 0, "Enable", ""},
- {ACT_ARM_DISABLE, "DISABLE", 0, "Disable", ""},
- {ACT_ARM_SETTARGET, "SETTARGET", 0, "Set Target", ""},
- {ACT_ARM_SETWEIGHT, "SETWEIGHT", 0, "Set Weight", ""},
- {ACT_ARM_SETINFLUENCE, "SETINFLUENCE", 0, "Set Influence", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "ArmatureActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Armature Actuator", "");
- RNA_def_struct_sdna_from(srna, "bArmatureActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Constraint Type", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "bone", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "posechannel");
- RNA_def_property_ui_text(prop, "Bone", "Bone on which the constraint is defined");
- RNA_def_property_update(prop, NC_LOGIC, "rna_Actuator_Armature_update");
-
- prop = RNA_def_property(srna, "constraint", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "constraint");
- RNA_def_property_ui_text(prop, "Constraint", "Name of the constraint to control");
- RNA_def_property_update(prop, NC_LOGIC, "rna_Actuator_Armature_update");
-
- prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Target", "Set this object as the target of the constraint");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "secondary_target", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "subtarget");
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Secondary Target",
- "Set this object as the secondary target of the constraint "
- "(only IK polar target at the moment)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "weight");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_ui_text(prop, "Weight", "Weight of this constraint");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "influence");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_ui_text(prop, "Influence", "Influence of this constraint");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_steering_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_STEERING_SEEK, "SEEK", 0, "Seek", ""},
- {ACT_STEERING_FLEE, "FLEE", 0, "Flee", ""},
- {ACT_STEERING_PATHFOLLOWING, "PATHFOLLOWING", 0, "Path following", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem facingaxis_items[] = {
- {1, "X", 0, "X", ""},
- {2, "Y", 0, "Y", ""},
- {3, "Z", 0, "Z", ""},
- {4, "NEG_X", 0, "-X", ""},
- {5, "NEG_Y", 0, "-Y", ""},
- {6, "NEG_Z", 0, "-Z", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "SteeringActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Steering Actuator", "");
- RNA_def_struct_sdna_from(srna, "bSteeringActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Behavior", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "velocity");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_ui_text(prop, "Velocity", "Velocity magnitude");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "acceleration", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "acceleration");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_ui_text(prop, "Acceleration", "Max acceleration");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "turn_speed", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "turnspeed");
- RNA_def_property_range(prop, 0.0, 720.0);
- RNA_def_property_ui_text(prop, "Turn Speed", "Max turn speed");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "dist");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_ui_text(prop, "Dist", "Relax distance");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_sdna(prop, NULL, "target");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Target Object", "Target object");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "self_terminated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_SELFTERMINATED);
- RNA_def_property_ui_text(prop, "Self Terminated", "Terminate when target is reached");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_visualization", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_ENABLEVISUALIZATION);
- RNA_def_property_ui_text(prop, "Visualize", "Enable debug visualization for 'Path following'");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "update_period", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "updateTime");
- RNA_def_property_ui_range(prop, -1, 100000, 1, 1);
- RNA_def_property_ui_text(prop, "Update period", "Path update period");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "navmesh", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_sdna(prop, NULL, "navmesh");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Navigation Mesh Object", "Navigation mesh");
- RNA_def_property_pointer_funcs(prop, NULL, "rna_SteeringActuator_navmesh_set", NULL, NULL);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "facing", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_AUTOMATICFACING);
- RNA_def_property_ui_text(prop, "Facing", "Enable automatic facing");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "facing_axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "facingaxis");
- RNA_def_property_enum_items(prop, facingaxis_items);
- RNA_def_property_ui_text(prop, "Axis", "Axis for automatic facing");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "normal_up", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_NORMALUP);
- RNA_def_property_ui_text(prop, "N", "Use normal of the navmesh to set \"UP\" vector");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "lock_z_velocity", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_LOCKZVEL);
- RNA_def_property_ui_text(prop, "Lock Z velocity", "Disable simulation of linear motion along Z axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_mouse_actuator(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_type_items[] = {
- {ACT_MOUSE_VISIBILITY, "VISIBILITY", 0, "Visibility", ""},
- {ACT_MOUSE_LOOK, "LOOK", 0, "Look", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_object_axis_items[] = {
- {ACT_MOUSE_OBJECT_AXIS_X, "OBJECT_AXIS_X", 0, "X Axis", ""},
- {ACT_MOUSE_OBJECT_AXIS_Y, "OBJECT_AXIS_Y", 0, "Y Axis", ""},
- {ACT_MOUSE_OBJECT_AXIS_Z, "OBJECT_AXIS_Z", 0, "Z Axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "MouseActuator", "Actuator");
- RNA_def_struct_ui_text(srna, "Mouse Actuator", "");
- RNA_def_struct_sdna_from(srna, "bMouseActuator", "data");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Mode", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Visibility */
- prop = RNA_def_property(srna, "visible", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_VISIBLE);
- RNA_def_property_ui_text(prop, "Visible", "Make mouse cursor visible");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Mouse Look */
- prop = RNA_def_property(srna, "use_axis_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_USE_AXIS_X);
- RNA_def_property_ui_text(prop, "Use X Axis", "Calculate mouse movement on the X axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_axis_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_USE_AXIS_Y);
- RNA_def_property_ui_text(prop, "Use Y Axis", "Calculate mouse movement on the Y axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "reset_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_RESET_X);
- RNA_def_property_ui_text(prop, "Reset",
- "Reset the cursor's X position to the center of the screen space after calculating");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "reset_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_RESET_Y);
- RNA_def_property_ui_text(prop, "Reset",
- "Reset the cursor's Y position to the center of the screen space after calculating");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "local_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_LOCAL_X);
- RNA_def_property_ui_text(prop, "Local", "Apply rotation locally");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "local_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_LOCAL_Y);
- RNA_def_property_ui_text(prop, "Local", "Apply rotation locally");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "threshold_x", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "threshold[0]");
- RNA_def_property_ui_range(prop, 0, 0.5, 1, 3);
- RNA_def_property_ui_text(prop, "Threshold", "Amount of X motion before mouse movement will register");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "threshold_y", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "threshold[1]");
- RNA_def_property_ui_range(prop, 0, 0.5, 1, 3);
- RNA_def_property_ui_text(prop, "Threshold", "Amount of Y motion before mouse movement will register");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "object_axis_x", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "object_axis[0]");
- RNA_def_property_enum_items(prop, prop_object_axis_items);
- RNA_def_property_ui_text(prop, "Object Axis", "Local object axis mouse movement in the X direction will apply to");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "object_axis_y", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "object_axis[1]");
- RNA_def_property_enum_items(prop, prop_object_axis_items);
- RNA_def_property_ui_text(prop, "Object Axis", "Local object axis mouse movement in the Y direction will apply to");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "sensitivity_x", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sensitivity[0]");
- RNA_def_property_ui_range(prop, -100.0, 100.0, 0.2, 3);
- RNA_def_property_ui_text(prop, "Sensitivity", "Sensitivity of the X axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "sensitivity_y", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sensitivity[1]");
- RNA_def_property_ui_range(prop, -100.0, 100.0, 0.2, 3);
- RNA_def_property_ui_text(prop, "Sensitivity", "Sensitivity of the Y axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "limit_x[0]");
- RNA_def_property_ui_range(prop, DEG2RADF(-3600.0f), 0.0, 9, 3);
- RNA_def_property_ui_text(prop, "Min", "Maximum negative rotation allowed by X mouse movement (0 for infinite)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "limit_x[1]");
- RNA_def_property_ui_range(prop, 0.0, DEG2RADF(3600.0f), 9, 3);
- RNA_def_property_ui_text(prop, "Max", "Maximum positive rotation allowed by X mouse movement (0 for infinite)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "limit_y[0]");
- RNA_def_property_ui_range(prop, DEG2RADF(-3600.0f), 0.0, 9, 3);
- RNA_def_property_ui_text(prop, "Min", "Maximum negative rotation allowed by Y mouse movement (0 for infinite)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "limit_y[1]");
- RNA_def_property_ui_range(prop, 0.0, DEG2RADF(3600.0f), 9, 3);
- RNA_def_property_ui_text(prop, "Max", "Maximum positive rotation allowed by Y mouse movement (0 for infinite)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-void RNA_def_actuator(BlenderRNA *brna)
-{
- rna_def_actuator(brna);
-
- rna_def_action_actuator(brna);
- rna_def_object_actuator(brna);
- rna_def_camera_actuator(brna);
- rna_def_sound_actuator(brna);
- rna_def_property_actuator(brna);
- rna_def_constraint_actuator(brna);
- rna_def_edit_object_actuator(brna);
- rna_def_scene_actuator(brna);
- rna_def_random_actuator(brna);
- rna_def_message_actuator(brna);
- rna_def_game_actuator(brna);
- rna_def_visibility_actuator(brna);
- rna_def_twodfilter_actuator(brna);
- rna_def_parent_actuator(brna);
- rna_def_state_actuator(brna);
- rna_def_armature_actuator(brna);
- rna_def_steering_actuator(brna);
- rna_def_mouse_actuator(brna);
-}
-
-#endif
diff --git a/source/blender/makesrna/intern/rna_actuator_api.c b/source/blender/makesrna/intern/rna_actuator_api.c
deleted file mode 100644
index 23fdd8a1d5b..00000000000
--- a/source/blender/makesrna/intern/rna_actuator_api.c
+++ /dev/null
@@ -1,77 +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):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/makesrna/intern/rna_actuator_api.c
- * \ingroup RNA
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "WM_types.h"
-#include "RNA_define.h"
-
-#include "rna_internal.h" /* own include */
-
-#ifdef RNA_RUNTIME
-
-#include "BKE_sca.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
-
-static void rna_Actuator_link(bActuator *act, bController *cont)
-{
- link_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks, sizeof(bActuator *));
-}
-
-static void rna_Actuator_unlink(bActuator *act, bController *cont)
-{
- unlink_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks);
-}
-
-#else
-
-void RNA_api_actuator(StructRNA *srna)
-{
- FunctionRNA *func;
- PropertyRNA *parm;
-
- func = RNA_def_function(srna, "link", "rna_Actuator_link");
- RNA_def_function_ui_description(func, "Link the actuator to a controller");
- parm = RNA_def_pointer(func, "controller", "Controller", "", "Controller to link to");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_property_update(parm, NC_LOGIC, NULL);
-
- func = RNA_def_function(srna, "unlink", "rna_Actuator_unlink");
- RNA_def_function_ui_description(func, "Unlink the actuator from a controller");
- parm = RNA_def_pointer(func, "controller", "Controller", "", "Controller to unlink from");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_property_update(parm, NC_LOGIC, NULL);
-}
-
-#endif
-
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index bbcb583ab39..1747d2fbc23 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -108,7 +108,7 @@ static EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports,
BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in edit mode, cannot add an editbone", arm->id.name + 2);
return NULL;
}
- return ED_armature_edit_bone_add(arm, name);
+ return ED_armature_ebone_add(arm, name);
}
static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, PointerRNA *ebone_ptr)
@@ -124,7 +124,7 @@ static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, P
return;
}
- ED_armature_edit_bone_remove(arm, ebone);
+ ED_armature_ebone_remove(arm, ebone);
RNA_POINTER_INVALIDATE(ebone_ptr);
}
@@ -147,6 +147,7 @@ static void rna_Armature_redraw_data(Main *UNUSED(bmain), Scene *UNUSED(scene),
{
ID *id = ptr->id.data;
+ DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE);
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
}
@@ -427,7 +428,7 @@ static void rna_Armature_editbone_transform_update(Main *bmain, Scene *scene, Po
copy_v3_v3(child->head, ebone->tail);
if (arm->flag & ARM_MIRROR_EDIT) {
- eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebone);
+ eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (eboflip) {
eboflip->roll = -ebone->roll;
@@ -989,11 +990,6 @@ static void rna_def_armature(BlenderRNA *brna)
{ARM_WIRE, "WIRE", 0, "Wire", "Display bones as thin wires, showing subdivision and B-Splines"},
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem prop_vdeformer[] = {
- {ARM_VDEF_BLENDER, "BLENDER", 0, "Blender", "Use Blender's armature vertex deformation"},
- {ARM_VDEF_BGE_CPU, "BGE_CPU", 0, "BGE", "Use vertex deformation code optimized for the BGE"},
- {0, NULL, 0, NULL, NULL}
- };
static const EnumPropertyItem prop_ghost_type_items[] = {
{ARM_GHOST_CUR, "CURRENT_FRAME", 0, "Around Frame",
"Display Ghosts of poses within a fixed number of frames around the current frame"},
@@ -1050,13 +1046,6 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
- prop = RNA_def_property(srna, "deform_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "gevertdeformer");
- RNA_def_property_enum_items(prop, prop_vdeformer);
- RNA_def_property_ui_text(prop, "Vertex Deformer", "Vertex Deformer Method (Game Engine only)");
- RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
- RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
-
/* XXX deprecated ....... old animviz for armatures only */
prop = RNA_def_property(srna, "ghost_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "ghosttype");
diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c
index 0616331bc05..222baf99afd 100644
--- a/source/blender/makesrna/intern/rna_armature_api.c
+++ b/source/blender/makesrna/intern/rna_armature_api.c
@@ -46,7 +46,7 @@
static void rna_EditBone_align_roll(EditBone *ebo, float no[3])
{
- ebo->roll = ED_rollBoneToVector(ebo, no, false);
+ ebo->roll = ED_armature_ebone_roll_to_vector(ebo, no, false);
}
static float rna_Bone_do_envelope(Bone *bone, float *vec)
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index d9b7a58de04..f895cfbbf0c 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -160,17 +160,6 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
ID *id = ptr->id.data;
switch (GS(id->name)) {
- case ID_MA: /* material has 2 cases - diffuse and specular */
- {
- Material *ma = (Material *)id;
-
- if (ptr->data == ma->ramp_col)
- path = BLI_strdup("diffuse_ramp");
- else if (ptr->data == ma->ramp_spec)
- path = BLI_strdup("specular_ramp");
- break;
- }
-
case ID_NT:
{
bNodeTree *ntree = (bNodeTree *)id;
@@ -245,22 +234,6 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
ID *id = ptr->id.data;
switch (GS(id->name)) {
- case ID_MA: /* 2 cases for material - diffuse and spec */
- {
- Material *ma = (Material *)id;
-
- /* try diffuse first */
- if (ma->ramp_col) {
- RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_col, &ramp_ptr);
- COLRAMP_GETPATH;
- }
- /* try specular if not diffuse */
- if (!path && ma->ramp_spec) {
- RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_spec, &ramp_ptr);
- COLRAMP_GETPATH;
- }
- break;
- }
case ID_NT:
{
bNodeTree *ntree = (bNodeTree *)id;
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 8eb6bc1261e..97114e02e48 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -100,8 +100,8 @@ const EnumPropertyItem rna_enum_constraint_type_items[] = {
"Use to animate an object/bone following a path"},
{CONSTRAINT_TYPE_PIVOT, "PIVOT", ICON_CONSTRAINT_DATA, "Pivot",
"Change pivot point for transforms (buggy)"},
- {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", ICON_CONSTRAINT_DATA, "Rigid Body Joint",
- "Use to define a Rigid Body Constraint (for Game Engine use only)"},
+ /* {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", ICON_CONSTRAINT_DATA, "Rigid Body Joint",
+ "Use to define a Rigid Body Constraint (for Game Engine use only)"}, */
/* {CONSTRAINT_TYPE_PYTHON, "SCRIPT", ICON_CONSTRAINT_DATA, "Script",
"Custom constraint(s) written in Python (Not yet implemented)"}, */
{CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT_DATA, "Shrinkwrap",
@@ -190,8 +190,6 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr)
return &RNA_StretchToConstraint;
case CONSTRAINT_TYPE_MINMAX:
return &RNA_FloorConstraint;
- case CONSTRAINT_TYPE_RIGIDBODYJOINT:
- return &RNA_RigidBodyJointConstraint;
case CONSTRAINT_TYPE_CLAMPTO:
return &RNA_ClampToConstraint;
case CONSTRAINT_TYPE_TRANSFORM:
@@ -1419,178 +1417,6 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
}
-static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem pivot_items[] = {
- {CONSTRAINT_RB_BALL, "BALL", 0, "Ball", "Allow rotations around all axes"},
- {CONSTRAINT_RB_HINGE, "HINGE", 0, "Hinge", "Work in one plane, allow rotations around one axis only"},
- {CONSTRAINT_RB_CONETWIST, "CONE_TWIST", 0, "Cone Twist",
- "Allow rotations around all axes with limits for the cone and twist axes"},
- {CONSTRAINT_RB_GENERIC6DOF, "GENERIC_6_DOF", 0, "Generic 6 DoF",
- "No constraints by default, limits can be set individually"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "RigidBodyJointConstraint", "Constraint");
- RNA_def_struct_ui_text(srna, "Rigid Body Joint Constraint", "For use with the Game Engine");
- RNA_def_struct_sdna_from(srna, "bRigidBodyJointConstraint", "data");
-
- prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "tar");
- RNA_def_property_ui_text(prop, "Target", "Target Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
- prop = RNA_def_property(srna, "child", PROP_POINTER, PROP_NONE);
- RNA_def_property_ui_text(prop, "Child Object", "Child object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
- prop = RNA_def_property(srna, "pivot_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, pivot_items);
- RNA_def_property_ui_text(prop, "Pivot Type", "");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "pivX");
- RNA_def_property_range(prop, -1000.0, 1000.f);
- RNA_def_property_ui_text(prop, "Pivot X", "Offset pivot on X");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "pivY");
- RNA_def_property_range(prop, -1000.0, 1000.f);
- RNA_def_property_ui_text(prop, "Pivot Y", "Offset pivot on Y");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "pivZ");
- RNA_def_property_range(prop, -1000.0, 1000.f);
- RNA_def_property_ui_text(prop, "Pivot Z", "Offset pivot on Z");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "axX");
- RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
- RNA_def_property_ui_text(prop, "Axis X", "Rotate pivot on X axis");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "axY");
- RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
- RNA_def_property_ui_text(prop, "Axis Y", "Rotate pivot on Y axis");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "axZ");
- RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
- RNA_def_property_ui_text(prop, "Axis Z", "Rotate pivot on Z axis");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "use_linked_collision", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE_LINKED_COLLISION);
- RNA_def_property_ui_text(prop, "Disable Linked Collision", "Disable collision between linked bodies");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "show_pivot", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DRAW_PIVOT);
- RNA_def_property_ui_text(prop, "Draw Pivot", "Display the pivot point and rotation in 3D view");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
-
- /* Limits */
- /* Limit Min/Max */
- prop = RNA_def_property(srna, "limit_min_x", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "minLimit[0]");
- RNA_def_property_ui_text(prop, "Minimum Limit X", "");
-
- prop = RNA_def_property(srna, "limit_min_y", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "minLimit[1]");
- RNA_def_property_ui_text(prop, "Minimum Limit Y", "");
-
- prop = RNA_def_property(srna, "limit_min_z", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "minLimit[2]");
- RNA_def_property_ui_text(prop, "Minimum Limit Z", "");
-
- prop = RNA_def_property(srna, "limit_max_x", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "maxLimit[0]");
- RNA_def_property_ui_text(prop, "Maximum Limit X", "");
-
- prop = RNA_def_property(srna, "limit_max_y", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "maxLimit[1]");
- RNA_def_property_ui_text(prop, "Maximum Limit Y", "");
-
- prop = RNA_def_property(srna, "limit_max_z", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "maxLimit[2]");
- RNA_def_property_ui_text(prop, "Maximum Limit Z", "");
-
- /* Limit Min/Max for angle */
- prop = RNA_def_property(srna, "limit_angle_min_x", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "minLimit[3]");
- RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
- RNA_def_property_ui_text(prop, "Minimum Angular Limit X", "");
-
- prop = RNA_def_property(srna, "limit_angle_min_y", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "minLimit[4]");
- RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
- RNA_def_property_ui_text(prop, "Minimum Angular Limit Y", "");
-
- prop = RNA_def_property(srna, "limit_angle_min_z", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "minLimit[5]");
- RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
- RNA_def_property_ui_text(prop, "Minimum Angular Limit Z", "");
-
- prop = RNA_def_property(srna, "limit_angle_max_x", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "maxLimit[3]");
- RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
- RNA_def_property_ui_text(prop, "Maximum Angular Limit X", "");
-
- prop = RNA_def_property(srna, "limit_angle_max_y", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "maxLimit[4]");
- RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
- RNA_def_property_ui_text(prop, "Maximum Angular Limit Y", "");
-
- prop = RNA_def_property(srna, "limit_angle_max_z", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "maxLimit[5]");
- RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
- RNA_def_property_ui_text(prop, "Maximum Angular Limit Z", "");
-
- /* Limit Booleans */
- prop = RNA_def_property(srna, "use_limit_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", 1);
- RNA_def_property_ui_text(prop, "Limit X", "Use minimum/maximum X limit");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "use_limit_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", 2);
- RNA_def_property_ui_text(prop, "Limit Y", "Use minimum/maximum y limit");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "use_limit_z", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", 4);
- RNA_def_property_ui_text(prop, "Limit Z", "Use minimum/maximum z limit");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "use_angular_limit_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", 8);
- RNA_def_property_ui_text(prop, "Angular X Limit", "Use minimum/maximum X angular limit");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "use_angular_limit_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", 16);
- RNA_def_property_ui_text(prop, "Angular Y Limit", "Use minimum/maximum Y angular limit");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-
- prop = RNA_def_property(srna, "use_angular_limit_z", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", 32);
- RNA_def_property_ui_text(prop, "Angular Z Limit", "Use minimum/maximum Z angular limit");
- RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
-}
-
static void rna_def_constraint_clamp_to(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2718,7 +2544,6 @@ void RNA_def_constraint(BlenderRNA *brna)
rna_def_constraint_minmax(brna);
rna_def_constraint_track_to(brna);
rna_def_constraint_kinematic(brna);
- rna_def_constraint_rigid_body_joint(brna);
rna_def_constraint_clamp_to(brna);
rna_def_constraint_distance_limit(brna);
rna_def_constraint_size_limit(brna);
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index bcd805b0f3a..fd128548ed1 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -139,12 +139,6 @@ static PointerRNA rna_Context_view_layer_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(&scene_ptr, &RNA_ViewLayer, CTX_data_view_layer(C));
}
-static PointerRNA rna_Context_view_render_get(PointerRNA *ptr)
-{
- bContext *C = (bContext *)ptr->data;
- return rna_pointer_inherit_refine(ptr, &RNA_ViewRenderSettings, CTX_data_view_render(C));
-}
-
static void rna_Context_engine_get(PointerRNA *ptr, char *value)
{
bContext *C = (bContext *)ptr->data;
@@ -289,11 +283,6 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ViewLayer");
RNA_def_property_pointer_funcs(prop, "rna_Context_view_layer_get", NULL, NULL, NULL);
- prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_struct_type(prop, "ViewRenderSettings");
- RNA_def_property_pointer_funcs(prop, "rna_Context_view_render_get", NULL, NULL, NULL);
-
prop = RNA_def_property(srna, "engine", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Context_engine_get", "rna_Context_engine_length", NULL);
diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c
deleted file mode 100644
index bdb3daedebb..00000000000
--- a/source/blender/makesrna/intern/rna_controller.c
+++ /dev/null
@@ -1,327 +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.
- *
- * Contributor(s): Blender Foundation (2008).
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/makesrna/intern/rna_controller.c
- * \ingroup RNA
- */
-
-#include <stdlib.h>
-
-#include "DNA_object_types.h"
-#include "DNA_controller_types.h"
-
-#include "BLI_string_utils.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "RNA_define.h"
-#include "RNA_enum_types.h"
-
-#include "rna_internal.h"
-
-#include "WM_types.h"
-
-const EnumPropertyItem rna_enum_controller_type_items[] = {
- {CONT_LOGIC_AND, "LOGIC_AND", 0, "And", "Logic And"},
- {CONT_LOGIC_OR, "LOGIC_OR", 0, "Or", "Logic Or"},
- {CONT_LOGIC_NAND, "LOGIC_NAND", 0, "Nand", "Logic Nand"},
- {CONT_LOGIC_NOR, "LOGIC_NOR", 0, "Nor", "Logic Nor"},
- {CONT_LOGIC_XOR, "LOGIC_XOR", 0, "Xor", "Logic Xor"},
- {CONT_LOGIC_XNOR, "LOGIC_XNOR", 0, "Xnor", "Logic Xnor"},
- {CONT_EXPRESSION, "EXPRESSION", 0, "Expression", ""},
- {CONT_PYTHON, "PYTHON", 0, "Python", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-#ifdef RNA_RUNTIME
-
-#include "BKE_sca.h"
-#include "DNA_actuator_types.h"
-
-static StructRNA *rna_Controller_refine(struct PointerRNA *ptr)
-{
- bController *controller = (bController *)ptr->data;
-
- switch (controller->type) {
- case CONT_LOGIC_AND:
- return &RNA_AndController;
- case CONT_LOGIC_OR:
- return &RNA_OrController;
- case CONT_LOGIC_NAND:
- return &RNA_NandController;
- case CONT_LOGIC_NOR:
- return &RNA_NorController;
- case CONT_LOGIC_XOR:
- return &RNA_XorController;
- case CONT_LOGIC_XNOR:
- return &RNA_XnorController;
- case CONT_EXPRESSION:
- return &RNA_ExpressionController;
- case CONT_PYTHON:
- return &RNA_PythonController;
- default:
- return &RNA_Controller;
- }
-}
-
-static void rna_Constroller_name_set(PointerRNA *ptr, const char *value)
-{
- Object *ob = ptr->id.data;
- bController *cont = ptr->data;
- BLI_strncpy_utf8(cont->name, value, sizeof(cont->name));
- BLI_uniquename(&ob->controllers, cont, DATA_("Controller"), '.', offsetof(bController, name), sizeof(cont->name));
-}
-
-static void rna_Controller_type_set(struct PointerRNA *ptr, int value)
-{
- bController *cont = (bController *)ptr->data;
-
- if (value != cont->type) {
- cont->type = value;
- init_controller(cont);
- }
-}
-
-static void rna_Controller_mode_set(struct PointerRNA *ptr, int value)
-{
- bController *cont = (bController *)ptr->data;
- bPythonCont *pycon = (bPythonCont *)cont->data;
-
- /* if mode changed and previous mode were Script */
- if (value != pycon->mode && pycon->mode == CONT_PY_SCRIPT) {
- /* clear script to avoid it to get linked with the controller */
- pycon->text = NULL;
- }
- pycon->mode = value;
-}
-
-static int rna_Controller_state_number_get(struct PointerRNA *ptr)
-{
- bController *cont = (bController *)ptr->data;
- int bit;
-
- for (bit = 0; bit < 32; bit++) {
- if (cont->state_mask & (1u << bit))
- return bit + 1;
- }
- return 0;
-}
-
-static void rna_Controller_state_number_set(struct PointerRNA *ptr, const int value)
-{
- bController *cont = (bController *)ptr->data;
- if (value < 1 || value > OB_MAX_STATES)
- return;
-
- cont->state_mask = (1 << (value - 1));
-}
-
-static void rna_Controller_actuators_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- bController *cont = (bController *)ptr->data;
- rna_iterator_array_begin(iter, cont->links, sizeof(bActuator *), (int)cont->totlinks, 0, NULL);
-}
-
-static int rna_Controller_actuators_length(PointerRNA *ptr)
-{
- bController *cont = (bController *)ptr->data;
- return (int) cont->totlinks;
-}
-
-#if 0 /* editable is set to false, comment for now. */
-static void rna_Controller_state_get(PointerRNA *ptr, int *values)
-{
- bController *cont = (bController *)ptr->data;
- int i;
-
- memset(values, 0, sizeof(int) * OB_MAX_STATES);
- for (i = 0; i < OB_MAX_STATES; i++)
- values[i] = (cont->state_mask & (1 << i));
-}
-
-static void rna_Controller_state_set(PointerRNA *ptr, const int *values)
-{
- bController *cont = (bController *)ptr->data;
- int i, tot = 0;
-
- /* ensure we always have some state selected */
- for (i = 0; i < OB_MAX_STATES; i++)
- if (values[i])
- tot++;
-
- if (tot == 0)
- return;
-
- /* only works for one state at once */
- if (tot > 1)
- return;
-
- for (i = 0; i < OB_MAX_STATES; i++) {
- if (values[i]) cont->state_mask |= (1 << i);
- else cont->state_mask &= ~(1 << i);
- }
-}
-#endif
-
-#else
-
-void RNA_def_controller(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem python_controller_modes[] = {
- {CONT_PY_SCRIPT, "SCRIPT", 0, "Script", ""},
- {CONT_PY_MODULE, "MODULE", 0, "Module", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- /* Controller */
- srna = RNA_def_struct(brna, "Controller", NULL);
- RNA_def_struct_sdna(srna, "bController");
- RNA_def_struct_refine_func(srna, "rna_Controller_refine");
- RNA_def_struct_ui_text(srna, "Controller",
- "Game engine logic brick to process events, connecting sensors to actuators");
-
- RNA_api_controller(srna);
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Name", "");
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Constroller_name_set");
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Controller_type_set", NULL);
- RNA_def_property_enum_items(prop, rna_enum_controller_type_items);
- RNA_def_property_ui_text(prop, "Type", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_SHOW);
- RNA_def_property_ui_text(prop, "Expanded", "Set controller expanded in the user interface");
- RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONT_DEACTIVATE);
- RNA_def_property_ui_text(prop, "Active", "Set the active state of the controller");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_priority", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_PRIO);
- RNA_def_property_ui_text(prop, "Priority",
- "Mark controller for execution before all non-marked controllers "
- "(good for startup scripts)");
- RNA_def_property_ui_icon(prop, ICON_BOOKMARKS, 1);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "links", NULL);
- RNA_def_property_struct_type(prop, "Actuator");
- RNA_def_property_ui_text(prop, "Actuators", "The list containing the actuators connected to the controller");
- RNA_def_property_collection_funcs(prop, "rna_Controller_actuators_begin", "rna_iterator_array_next",
- "rna_iterator_array_end", "rna_iterator_array_dereference_get",
- "rna_Controller_actuators_length", NULL, NULL, NULL);
-
- /* State */
-
- /* array of OB_MAX_STATES */
- /*prop = RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER); */
- /*RNA_def_property_array(prop, OB_MAX_STATES); */
- /*RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
- /*RNA_def_property_ui_text(prop, "", "Set Controller state index (1 to 30)"); */
- /*RNA_def_property_boolean_funcs(prop, "rna_Controller_state_get", "rna_Controller_state_set"); */
- /*RNA_def_property_update(prop, NC_LOGIC, NULL); */
-
- /* number of the state */
- prop = RNA_def_property(srna, "states", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "state_mask");
- RNA_def_property_range(prop, 1, OB_MAX_STATES);
- RNA_def_property_ui_text(prop, "", "Set Controller state index (1 to 30)");
- RNA_def_property_int_funcs(prop, "rna_Controller_state_number_get", "rna_Controller_state_number_set", NULL);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Expression Controller */
- srna = RNA_def_struct(brna, "ExpressionController", "Controller");
- RNA_def_struct_sdna_from(srna, "bExpressionCont", "data");
- RNA_def_struct_ui_text(srna, "Expression Controller",
- "Controller passing on events based on the evaluation of an expression");
-
- prop = RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "str");
- RNA_def_property_ui_text(prop, "Expression", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Python Controller */
- srna = RNA_def_struct(brna, "PythonController", "Controller");
- RNA_def_struct_sdna_from(srna, "bPythonCont", "data");
- RNA_def_struct_ui_text(srna, "Python Controller", "Controller executing a python script");
-
- prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, python_controller_modes);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Controller_mode_set", NULL);
- RNA_def_property_ui_text(prop, "Execution Method", "Python script type (textblock or module - faster)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Text");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Text", "Text data-block with the python script");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "module", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Module",
- "Module name and function to run, e.g. \"someModule.main\" "
- "(internal texts and external python files can be used)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_debug", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_PY_DEBUG);
- RNA_def_property_ui_text(prop, "D",
- "Continuously reload the module from disk for editing external modules "
- "without restarting");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Other Controllers */
- srna = RNA_def_struct(brna, "AndController", "Controller");
- RNA_def_struct_ui_text(srna, "And Controller", "Controller passing on events based on a logical AND operation");
-
- srna = RNA_def_struct(brna, "OrController", "Controller");
- RNA_def_struct_ui_text(srna, "Or Controller", "Controller passing on events based on a logical OR operation");
-
- srna = RNA_def_struct(brna, "NorController", "Controller");
- RNA_def_struct_ui_text(srna, "Nor Controller", "Controller passing on events based on a logical NOR operation");
-
- srna = RNA_def_struct(brna, "NandController", "Controller");
- RNA_def_struct_ui_text(srna, "Nand Controller", "Controller passing on events based on a logical NAND operation");
-
- srna = RNA_def_struct(brna, "XorController", "Controller");
- RNA_def_struct_ui_text(srna, "Xor Controller", "Controller passing on events based on a logical XOR operation");
-
- srna = RNA_def_struct(brna, "XnorController", "Controller");
- RNA_def_struct_ui_text(srna, "Xnor Controller", "Controller passing on events based on a logical XNOR operation");
-}
-
-#endif
diff --git a/source/blender/makesrna/intern/rna_controller_api.c b/source/blender/makesrna/intern/rna_controller_api.c
deleted file mode 100644
index 639d6a330a5..00000000000
--- a/source/blender/makesrna/intern/rna_controller_api.c
+++ /dev/null
@@ -1,86 +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):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/makesrna/intern/rna_controller_api.c
- * \ingroup RNA
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "WM_types.h"
-#include "RNA_define.h"
-
-#include "rna_internal.h" /* own include */
-
-#ifdef RNA_RUNTIME
-
-#include "BKE_sca.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
-
-static void rna_Controller_link(bController *cont, bSensor *sens, bActuator *act)
-{
- if (sens)
- link_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks, sizeof(bController *));
- if (act)
- link_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks, sizeof(bActuator *));
-}
-
-static void rna_Controller_unlink(bController *cont, bSensor *sens, bActuator *act)
-{
- if (sens)
- unlink_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks);
- if (act)
- unlink_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks);
-}
-
-#else
-
-void RNA_api_controller(StructRNA *srna)
-{
- FunctionRNA *func;
- PropertyRNA *parm;
-
- func = RNA_def_function(srna, "link", "rna_Controller_link");
- RNA_def_function_ui_description(func, "Link the controller with a sensor/actuator");
- parm = RNA_def_pointer(func, "sensor", "Sensor", "", "Sensor to link the controller to");
- RNA_def_property_update(parm, NC_LOGIC, NULL);
- parm = RNA_def_pointer(func, "actuator", "Actuator", "", "Actuator to link the controller to");
- RNA_def_property_update(parm, NC_LOGIC, NULL);
-
- func = RNA_def_function(srna, "unlink", "rna_Controller_unlink");
- RNA_def_function_ui_description(func, "Unlink the controller from a sensor/actuator");
- parm = RNA_def_pointer(func, "sensor", "Sensor", "", "Sensor to unlink the controller from");
- RNA_def_property_update(parm, NC_LOGIC, NULL);
- parm = RNA_def_pointer(func, "actuator", "Actuator", "", "Actuator to unlink the controller from");
- RNA_def_property_update(parm, NC_LOGIC, NULL);
-}
-
-#endif
-
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index 466a01a7271..aeb845ddcf7 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -825,18 +825,6 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Paint Alpha", "Paint alpha");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
- prop = RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_USE_MATERIAL);
- RNA_def_property_ui_text(prop, "Use object material", "Use object material to define color and influence");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
- prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "mat");
- RNA_def_property_ui_text(prop, "Material",
- "Material to use (if not defined, material linked to the mesh is used)");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
prop = RNA_def_property(srna, "use_absolute_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ABS_ALPHA);
RNA_def_property_ui_text(prop, "Absolute Alpha",
diff --git a/source/blender/makesrna/intern/rna_hair.c b/source/blender/makesrna/intern/rna_hair.c
index db641c35dce..126b1f3145b 100644
--- a/source/blender/makesrna/intern/rna_hair.c
+++ b/source/blender/makesrna/intern/rna_hair.c
@@ -74,11 +74,10 @@ static void rna_HairSystem_generate_follicles(
}
struct Scene *scene = CTX_data_scene(C);
- EvaluationContext eval_ctx;
- CTX_data_eval_ctx(C, &eval_ctx);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
CustomDataMask datamask = CD_MASK_BAREMESH;
- DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, scene, scalp, datamask);
+ DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, scalp, datamask);
BKE_hair_generate_follicles(hsys, dm, (unsigned int)seed, count);
}
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 212a8bb8e20..6db8ee8bde1 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -70,19 +70,6 @@ static const EnumPropertyItem image_source_items[] = {
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-static void rna_Image_animated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- Image *ima = (Image *)ptr->data;
- int nr;
-
- if (ima->flag & IMA_TWINANIM) {
- nr = ima->xrep * ima->yrep;
- if (ima->twsta >= nr) ima->twsta = 1;
- if (ima->twend >= nr) ima->twend = nr - 1;
- if (ima->twsta > ima->twend) ima->twsta = 1;
- }
-}
-
static int rna_Image_is_stereo_3d_get(PointerRNA *ptr)
{
return BKE_image_is_stereo((Image *)ptr->data);
@@ -648,11 +635,6 @@ static void rna_def_image(BlenderRNA *brna)
{IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem prop_mapping_items[] = {
- {0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"},
- {IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"},
- {0, NULL, 0, NULL, NULL}
- };
static const EnumPropertyItem prop_field_order_items[] = {
{0, "EVEN", 0, "Upper First", "Upper field first"},
{IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"},
@@ -803,14 +785,6 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- /* realtime properties */
- prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
- RNA_def_property_enum_items(prop, prop_mapping_items);
- RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
-
prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
RNA_def_property_float_sdna(prop, NULL, "aspx");
@@ -820,66 +794,6 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
- prop = RNA_def_property(srna, "use_animation", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TWINANIM);
- RNA_def_property_ui_text(prop, "Animated", "Use as animated texture in the game engine");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update");
-
- prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_int_sdna(prop, NULL, "twsta");
- RNA_def_property_range(prop, 0, 255);
- RNA_def_property_ui_text(prop, "Animation Start", "Start frame of an animated texture");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update");
-
- prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_int_sdna(prop, NULL, "twend");
- RNA_def_property_range(prop, 0, 255);
- RNA_def_property_ui_text(prop, "Animation End", "End frame of an animated texture");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update");
-
- prop = RNA_def_property(srna, "fps", PROP_INT, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_int_sdna(prop, NULL, "animspeed");
- RNA_def_property_range(prop, 1, 100);
- RNA_def_property_ui_text(prop, "Animation Speed", "Speed of the animation in frames per second");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
-
- prop = RNA_def_property(srna, "use_tiles", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES);
- RNA_def_property_ui_text(prop, "Tiles",
- "Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
-
- prop = RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_int_sdna(prop, NULL, "xrep");
- RNA_def_property_range(prop, 1, 16);
- RNA_def_property_ui_text(prop, "Tiles X", "Degree of repetition in the X direction");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
-
- prop = RNA_def_property(srna, "tiles_y", PROP_INT, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_int_sdna(prop, NULL, "yrep");
- RNA_def_property_range(prop, 1, 16);
- RNA_def_property_ui_text(prop, "Tiles Y", "Degree of repetition in the Y direction");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
-
- prop = RNA_def_property(srna, "use_clamp_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_U);
- RNA_def_property_ui_text(prop, "Clamp X", "Disable texture repeating horizontally");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
-
- prop = RNA_def_property(srna, "use_clamp_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
- RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V);
- RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
-
prop = RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "bindcode");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 8bc82e90999..9897ce42804 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -151,7 +151,6 @@ void RNA_def_depsgraph(struct BlenderRNA *brna);
void RNA_def_dynamic_paint(struct BlenderRNA *brna);
void RNA_def_fluidsim(struct BlenderRNA *brna);
void RNA_def_fcurve(struct BlenderRNA *brna);
-void RNA_def_gameproperty(struct BlenderRNA *brna);
void RNA_def_gpencil(struct BlenderRNA *brna);
void RNA_def_groom(struct BlenderRNA *brna);
void RNA_def_group(struct BlenderRNA *brna);
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index a47a5c604b4..472298a3053 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -713,7 +713,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
prop = RNA_def_property(srna, "relative_key", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ShapeKey");
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL | PROP_PTR_NO_OWNERSHIP);
RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get",
"rna_ShapeKey_relative_key_set", NULL, NULL);
RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key");
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index 9e28e31057d..7e437a8a51f 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -63,33 +63,6 @@ static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value)
la->bufsize &= (~15); /* round to multiple of 16 */
}
-static PointerRNA rna_Lamp_sky_settings_get(PointerRNA *ptr)
-{
- return rna_pointer_inherit_refine(ptr, &RNA_LampSkySettings, ptr->id.data);
-}
-
-static void rna_Lamp_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- Lamp *la = (Lamp *)ptr->data;
- rna_iterator_array_begin(iter, (void *)la->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL);
-}
-
-static PointerRNA rna_Lamp_active_texture_get(PointerRNA *ptr)
-{
- Lamp *la = (Lamp *)ptr->data;
- Tex *tex;
-
- tex = give_current_lamp_texture(la);
- return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
-}
-
-static void rna_Lamp_active_texture_set(PointerRNA *ptr, PointerRNA value)
-{
- Lamp *la = (Lamp *)ptr->data;
-
- set_current_lamp_texture(la, value.data);
-}
-
static int rna_use_shadow_get(PointerRNA *ptr)
{
Lamp *la = (Lamp *)ptr->data;
@@ -147,14 +120,6 @@ static void rna_Lamp_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin
WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, la);
}
-static void rna_Lamp_sky_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- Lamp *la = ptr->id.data;
-
- DEG_id_tag_update(&la->id, 0);
- WM_main_add_notifier(NC_LAMP | ND_SKY, la);
-}
-
static void rna_Lamp_use_nodes_update(bContext *C, PointerRNA *ptr)
{
Lamp *la = (Lamp *)ptr->data;
@@ -176,167 +141,6 @@ const EnumPropertyItem rna_enum_lamp_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static void rna_def_lamp_mtex(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_texture_coordinates_items[] = {
- {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"},
- {TEXCO_VIEW, "VIEW", 0, "View", "Use view coordinates for the texture coordinates"},
- {TEXCO_OBJECT, "OBJECT", 0, "Object", "Use linked object's coordinates for texture coordinates"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "LampTextureSlot", "TextureSlot");
- RNA_def_struct_sdna(srna, "MTex");
- RNA_def_struct_ui_text(srna, "Lamp Texture Slot", "Texture slot for textures in a Lamp data-block");
-
- prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "texco");
- RNA_def_property_enum_items(prop, prop_texture_coordinates_items);
- RNA_def_property_ui_text(prop, "Texture Coordinates", "");
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "object");
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates");
-
- prop = RNA_def_property(srna, "use_map_color", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_COL);
- RNA_def_property_ui_text(prop, "Color", "Let the texture affect the basic color of the lamp");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "use_map_shadow", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_SHAD);
- RNA_def_property_ui_text(prop, "Shadow", "Let the texture affect the shadow color of the lamp");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "colfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Color Factor", "Amount texture affects color values");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "shadow_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "shadowfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Shadow Factor", "Amount texture affects shadow");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-}
-
-static void rna_def_lamp_sky_settings(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_skycolorspace_items[] = {
- {0, "SMPTE", 0, "SMPTE", ""},
- {1, "REC709", 0, "REC709", ""},
- {2, "CIE", 0, "CIE", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "LampSkySettings", NULL);
- RNA_def_struct_sdna(srna, "Lamp");
- RNA_def_struct_nested(brna, srna, "SunLamp");
- RNA_def_struct_ui_text(srna, "Lamp Sky Settings", "Sky related settings for a sun lamp");
-
- prop = RNA_def_property(srna, "sky_color_space", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "sky_colorspace");
- RNA_def_property_enum_items(prop, prop_skycolorspace_items);
- RNA_def_property_ui_text(prop, "Sky Color Space", "Color space to use for internal XYZ->RGB color conversion");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "sky_blend_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "skyblendtype");
- RNA_def_property_enum_items(prop, rna_enum_ramp_blend_items);
- RNA_def_property_ui_text(prop, "Sky Blend Mode", "Blend mode for combining sun sky with world sky");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- /* Number values */
-
- prop = RNA_def_property(srna, "horizon_brightness", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0f, 20.0f);
- RNA_def_property_ui_text(prop, "Horizon Brightness", "Horizon brightness");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "spread", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0f, 10.0f);
- RNA_def_property_ui_text(prop, "Horizon Spread", "Horizon Spread");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "sun_brightness", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0f, 10.0f);
- RNA_def_property_ui_text(prop, "Sun Brightness", "Sun brightness");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "sun_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0f, 10.0f);
- RNA_def_property_ui_text(prop, "Sun Size", "Sun size");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "backscattered_light", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, -1.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Backscattered Light", "Backscattered light");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "sun_intensity", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0f, 10.0f);
- RNA_def_property_ui_text(prop, "Sun Intensity", "Sun intensity");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "atmosphere_turbidity", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "atm_turbidity");
- RNA_def_property_range(prop, 1.0f, 30.0f);
- RNA_def_property_ui_range(prop, 2.0f, 10.0f, 1, 2);
- RNA_def_property_ui_text(prop, "Atmosphere Turbidity", "Sky turbidity");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "atmosphere_inscattering", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "atm_inscattering_factor");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Atmosphere Inscatter", "Scatter contribution factor");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "atmosphere_extinction", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "atm_extinction_factor");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Atmosphere Extinction", "Extinction scattering contribution factor");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "atmosphere_distance_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "atm_distance_factor");
- RNA_def_property_range(prop, 0.0f, 500.0f);
- RNA_def_property_ui_text(prop, "Atmosphere Distance Factor",
- "Multiplier to convert blender units to physical distance");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "sky_blend", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "skyblendfac");
- RNA_def_property_range(prop, 0.0f, 2.0f);
- RNA_def_property_ui_text(prop, "Sky Blend", "Blend factor with sky");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "sky_exposure", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0f, 20.0f);
- RNA_def_property_ui_text(prop, "Sky Exposure", "Strength of sky shading exponential exposure correction");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- /* boolean */
-
- prop = RNA_def_property(srna, "use_sky", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_SKY);
- RNA_def_property_ui_text(prop, "Sky", "Apply sun effect on sky");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-
- prop = RNA_def_property(srna, "use_atmosphere", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_AP);
- RNA_def_property_ui_text(prop, "Atmosphere", "Apply sun effect on atmosphere");
- RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
-}
-
static void rna_def_lamp(BlenderRNA *brna)
{
StructRNA *srna;
@@ -372,26 +176,6 @@ static void rna_def_lamp(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Color", "Light color");
RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
- prop = RNA_def_property(srna, "use_own_layer", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER);
- RNA_def_property_ui_text(prop, "Layer", "Illuminate objects only on the same layers the lamp is on");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "use_negative", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_NEG);
- RNA_def_property_ui_text(prop, "Negative", "Cast negative light");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "use_specular", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_SPEC);
- RNA_def_property_ui_text(prop, "Specular", "Create specular highlights");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "use_diffuse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_DIFF);
- RNA_def_property_ui_text(prop, "Diffuse", "Do diffuse shading");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
/* nodes */
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
@@ -406,11 +190,6 @@ static void rna_def_lamp(BlenderRNA *brna)
/* common */
rna_def_animdata_common(srna);
-
- /* textures */
- rna_def_mtex_common(brna, srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get",
- "rna_Lamp_active_texture_set", NULL, "LampTextureSlot", "LampTextureSlots",
- "rna_Lamp_draw_update", "rna_Lamp_draw_update");
}
static void rna_def_lamp_falloff(StructRNA *srna)
@@ -437,11 +216,6 @@ static void rna_def_lamp_falloff(StructRNA *srna)
RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
- prop = RNA_def_property(srna, "use_sphere", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SPHERE);
- RNA_def_property_ui_text(prop, "Sphere", "Set light intensity to zero beyond lamp distance");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
-
prop = RNA_def_property(srna, "linear_attenuation", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "att1");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -476,79 +250,14 @@ static void rna_def_lamp_falloff(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
}
-static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area, int sun)
+static void rna_def_lamp_shadow(StructRNA *srna, int sun)
{
PropertyRNA *prop;
- static const EnumPropertyItem prop_shadow_items[] = {
- {0, "NOSHADOW", 0, "No Shadow", ""},
- {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_spot_shadow_items[] = {
- {0, "NOSHADOW", 0, "No Shadow", ""},
- {LA_SHAD_BUF, "BUFFER_SHADOW", 0, "Buffer Shadow", "Let spotlight produce shadows using shadow buffer"},
- {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_ray_sampling_method_items[] = {
- {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""},
- {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_spot_ray_sampling_method_items[] = {
- {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""},
- {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""},
- {LA_SAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_shadbuftype_items[] = {
- {LA_SHADBUF_REGULAR, "REGULAR", 0, "Classical", "Classic shadow buffer"},
- {LA_SHADBUF_HALFWAY, "HALFWAY", 0, "Classic-Halfway",
- "Regular buffer, averaging the closest and 2nd closest Z value to reducing "
- "bias artifacts"},
- {LA_SHADBUF_IRREGULAR, "IRREGULAR", 0, "Irregular",
- "Irregular buffer produces sharp shadow always, but it doesn't show up for raytracing"},
- {LA_SHADBUF_DEEP, "DEEP", 0, "Deep",
- "Deep shadow buffer supports transparency and better filtering, at the cost of "
- "more memory usage and processing time"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_shadbuffiltertype_items[] = {
- {LA_SHADBUF_BOX, "BOX", 0, "Box", "Apply the Box filter to shadow buffer samples"},
- {LA_SHADBUF_TENT, "TENT", 0, "Tent", "Apply the Tent Filter to shadow buffer samples"},
- {LA_SHADBUF_GAUSS, "GAUSS", 0, "Gauss", "Apply the Gauss filter to shadow buffer samples"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_numbuffer_items[] = {
- {1, "BUFFERS_1", 0, "1", "Only one buffer rendered"},
- {4, "BUFFERS_4", 0, "4", "Render 4 buffers for better AA, this quadruples memory usage"},
- {9, "BUFFERS_9", 0, "9", "Render 9 buffers for better AA, this uses nine times more memory"},
- {0, NULL, 0, NULL, NULL}
- };
-
- /* GE only */
- static const EnumPropertyItem prop_ge_shadowbuffer_type_items[] = {
- {LA_SHADMAP_SIMPLE, "SIMPLE", 0, "Simple", "Simple shadow maps"},
- {LA_SHADMAP_VARIANCE, "VARIANCE", 0, "Variance", "Variance shadow maps"},
- {0, NULL, 0, NULL, NULL}
- };
-
prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_use_shadow_get", "rna_use_shadow_set");
RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
- prop = RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, (spot) ? prop_spot_shadow_items : prop_shadow_items);
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
-
prop = RNA_def_property(srna, "shadow_buffer_size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "bufsize");
RNA_def_property_range(prop, 128, 10240);
@@ -558,19 +267,6 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area, int sun)
RNA_def_property_int_funcs(prop, NULL, "rna_Lamp_buffer_size_set", NULL);
RNA_def_property_update(prop, 0, "rna_Lamp_update");
- prop = RNA_def_property(srna, "shadow_filter_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "filtertype");
- RNA_def_property_enum_items(prop, prop_shadbuffiltertype_items);
- RNA_def_property_ui_text(prop, "Shadow Filter Type", "Type of shadow filter (Buffer Shadows)");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "shadow_sample_buffers", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "buffers");
- RNA_def_property_enum_items(prop, prop_numbuffer_items);
- RNA_def_property_ui_text(prop, "Shadow Sample Buffers",
- "Number of shadow buffers to render for better AA, this increases memory usage");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
prop = RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "clipsta");
RNA_def_property_range(prop, 0.0f, 9999.0f);
@@ -616,77 +312,12 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area, int sun)
RNA_def_property_ui_text(prop, "Samples", "Number of shadow buffer samples");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
- prop = RNA_def_property(srna, "shadow_buffer_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "buftype");
- RNA_def_property_enum_items(prop, prop_shadbuftype_items);
- RNA_def_property_ui_text(prop, "Shadow Buffer Type", "Type of shadow buffer");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "ge_shadow_buffer_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "shadowmap_type");
- RNA_def_property_enum_items(prop, prop_ge_shadowbuffer_type_items);
- RNA_def_property_ui_text(prop, "Shadow Map Type", "The shadow mapping algorithm used");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
-
- prop = RNA_def_property(srna, "use_auto_clip_start", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_START);
- RNA_def_property_ui_text(prop, "Autoclip Start",
- "Automatic calculation of clipping-start, based on visible vertices");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
-
- prop = RNA_def_property(srna, "use_auto_clip_end", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_END);
- RNA_def_property_ui_text(prop, "Autoclip End", "Automatic calculation of clipping-end, based on visible vertices");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
-
- prop = RNA_def_property(srna, "compression_threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "compressthresh");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Compress", "Deep shadow map compression threshold");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
prop = RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "shdwr");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the lamp");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
- prop = RNA_def_property(srna, "use_only_shadow", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_ONLYSHADOW);
- RNA_def_property_ui_text(prop, "Only Shadow", "Cast shadows only, without illuminating objects");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "shadow_ray_sample_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "ray_samp_method");
- RNA_def_property_enum_items(prop, (area) ? prop_spot_ray_sampling_method_items : prop_ray_sampling_method_items);
- RNA_def_property_ui_text(prop, "Shadow Ray Sampling Method",
- "Method for generating shadow samples: Adaptive QMC is fastest, "
- "Constant QMC is less noisy but slower");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, (area) ? "shadow_ray_samples_x" : "shadow_ray_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "ray_samp");
- RNA_def_property_range(prop, 1, 64);
- RNA_def_property_ui_text(prop, (area) ? "Shadow Ray Samples" : "Shadow Ray Samples X",
- "Number of samples taken extra (samples x samples)");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- if (area) {
- prop = RNA_def_property(srna, "shadow_ray_samples_y", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "ray_sampy");
- RNA_def_property_range(prop, 1, 64);
- RNA_def_property_ui_text(prop, "Shadow Ray Samples Y",
- "Number of samples taken extra (samples x samples)");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
- }
-
- prop = RNA_def_property(srna, "shadow_adaptive_threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "adapt_thresh");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Shadow Adaptive Threshold", "Threshold for Adaptive Sampling (Raytraced shadows)");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
prop = RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "area_size");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
@@ -694,11 +325,6 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area, int sun)
RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
- prop = RNA_def_property(srna, "use_shadow_layer", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER_SHADOW);
- RNA_def_property_ui_text(prop, "Shadow Layer", "Objects on the same layers only cast shadows");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
/* Eevee */
prop = RNA_def_property(srna, "use_contact_shadow", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHAD_CONTACT);
@@ -771,7 +397,7 @@ static void rna_def_point_lamp(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_LAMP_POINT);
rna_def_lamp_falloff(srna);
- rna_def_lamp_shadow(srna, 0, 0, 0);
+ rna_def_lamp_shadow(srna, 0);
}
static void rna_def_area_lamp(BlenderRNA *brna)
@@ -790,24 +416,9 @@ static void rna_def_area_lamp(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Area Lamp", "Directional area lamp");
RNA_def_struct_ui_icon(srna, ICON_LAMP_AREA);
- rna_def_lamp_shadow(srna, 0, 1, 0);
+ rna_def_lamp_shadow(srna, 0);
rna_def_lamp_falloff(srna);
- prop = RNA_def_property(srna, "use_umbra", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_UMBRA);
- RNA_def_property_ui_text(prop, "Umbra", "Emphasize parts that are fully shadowed (Constant Jittered sampling)");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "use_dither", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_DITHER);
- RNA_def_property_ui_text(prop, "Dither", "Use 2x2 dithering for sampling (Constant Jittered sampling)");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "use_jitter", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_JITTER);
- RNA_def_property_ui_text(prop, "Jitter", "Use noise for sampling (Constant Jittered sampling)");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "area_shape");
RNA_def_property_enum_items(prop, prop_areashape_items);
@@ -828,12 +439,6 @@ static void rna_def_area_lamp(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Size Y",
"Size of the area of the area Lamp in the Y direction for Rectangle shapes");
RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
-
- prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "k");
- RNA_def_property_ui_range(prop, 0.001, 2.0, 0.1, 3);
- RNA_def_property_ui_text(prop, "Gamma", "Light gamma correction value");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
}
static void rna_def_spot_lamp(BlenderRNA *brna)
@@ -847,30 +452,13 @@ static void rna_def_spot_lamp(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_LAMP_SPOT);
rna_def_lamp_falloff(srna);
- rna_def_lamp_shadow(srna, 1, 0, 0);
+ rna_def_lamp_shadow(srna, 0);
prop = RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SQUARE);
RNA_def_property_ui_text(prop, "Square", "Cast a square spot light shape");
RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
- prop = RNA_def_property(srna, "use_halo", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_HALO);
- RNA_def_property_ui_text(prop, "Halo", "Render spotlight with a volumetric halo");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "halo_intensity", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "haint");
- RNA_def_property_ui_range(prop, 0, 5.0, 0.1, 3);
- RNA_def_property_ui_text(prop, "Halo Intensity", "Brightness of the spotlight's halo cone");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
- prop = RNA_def_property(srna, "halo_step", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "shadhalostep");
- RNA_def_property_range(prop, 0, 12);
- RNA_def_property_ui_text(prop, "Halo Step", "Volumetric halo sampling frequency");
- RNA_def_property_update(prop, 0, "rna_Lamp_update");
-
prop = RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "spotblend");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -893,36 +481,13 @@ static void rna_def_spot_lamp(BlenderRNA *brna)
static void rna_def_sun_lamp(BlenderRNA *brna)
{
StructRNA *srna;
- PropertyRNA *prop;
srna = RNA_def_struct(brna, "SunLamp", "Lamp");
RNA_def_struct_sdna(srna, "Lamp");
RNA_def_struct_ui_text(srna, "Sun Lamp", "Constant direction parallel ray lamp");
RNA_def_struct_ui_icon(srna, ICON_LAMP_SUN);
- rna_def_lamp_shadow(srna, 0, 0, 1);
-
- /* sky */
- prop = RNA_def_property(srna, "sky", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "LampSkySettings");
- RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Sky Settings", "Sky related settings for sun lamps");
-
- rna_def_lamp_sky_settings(brna);
-
- /* BGE Only */
- prop = RNA_def_property(srna, "shadow_frustum_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "shadow_frustum_size");
- RNA_def_property_ui_range(prop, 0.001, 100.0, 2, 1);
- RNA_def_property_ui_text(prop, "Frustum Size", "Size of the frustum used for creating the shadow map");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
-
- prop = RNA_def_property(srna, "show_shadow_box", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHOW_SHADOW_BOX);
- RNA_def_property_ui_text(prop, "Show Shadow Box",
- "Draw a box in 3D view to visualize which objects are contained in it");
- RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
+ rna_def_lamp_shadow(srna, 1);
}
static void rna_def_hemi_lamp(BlenderRNA *brna)
@@ -943,7 +508,6 @@ void RNA_def_lamp(BlenderRNA *brna)
rna_def_spot_lamp(brna);
rna_def_sun_lamp(brna);
rna_def_hemi_lamp(brna);
- rna_def_lamp_mtex(brna);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 7d09f30ed6a..6082f6ddf2e 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -26,6 +26,7 @@
#include "DNA_scene_types.h"
#include "DNA_layer_types.h"
+#include "DNA_view3d_types.h"
#include "BLI_math.h"
#include "BLI_string_utils.h"
@@ -309,6 +310,12 @@ static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr,
#define RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(bool, Eevee, COLLECTION_MODE_NONE, _NAME_)
+#define RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(_NAME_, _LEN_) \
+ RNA_LAYER_ENGINE_GET_SET_ARRAY(float, Workbench, COLLECTION_MODE_NONE, _NAME_, _LEN_)
+
+#define RNA_LAYER_ENGINE_WORKBENCH_GET_SET_INT(_NAME_) \
+ RNA_LAYER_ENGINE_GET_SET(int, Workbench, COLLECTION_MODE_NONE, _NAME_)
+
/* mode engines */
#define RNA_LAYER_MODE_OBJECT_GET_SET_FLOAT(_NAME_) \
@@ -402,6 +409,7 @@ RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_size)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(shadow_high_bitdepth)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(taa_samples)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(taa_render_samples)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(taa_reprojection)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gi_diffuse_bounces)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gi_cubemap_resolution)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gi_visibility_resolution)
@@ -578,6 +586,9 @@ static StructRNA *rna_LayerCollectionSettings_refine(PointerRNA *ptr)
return &RNA_LayerCollectionEngineSettingsClay;
}
#endif
+ if (STREQ(props->name, RE_engine_id_BLENDER_WORKBENCH)) {
+ return &RNA_LayerCollectionEngineSettingsWorkbench;
+ }
if (STREQ(props->name, RE_engine_id_BLENDER_EEVEE)) {
/* printf("Mode not fully implemented\n"); */
return &RNA_LayerCollectionSettings;
@@ -918,90 +929,6 @@ static void rna_ObjectBase_select_update(Main *UNUSED(bmain), Scene *UNUSED(scen
ED_object_base_select(base, mode);
}
-static char *rna_ViewRenderSettings_path(PointerRNA *UNUSED(ptr))
-{
- return BLI_sprintfN("view_render");
-}
-
-static void rna_ViewRenderSettings_engine_set(PointerRNA *ptr, int value)
-{
- ViewRender *view_render = (ViewRender *)ptr->data;
- RenderEngineType *type = BLI_findlink(&R_engines, value);
-
- if (type) {
- BLI_strncpy_utf8(view_render->engine_id, type->idname, sizeof(view_render->engine_id));
- DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE);
- }
-}
-
-static const EnumPropertyItem *rna_ViewRenderSettings_engine_itemf(
- bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
-{
- RenderEngineType *type;
- EnumPropertyItem *item = NULL;
- EnumPropertyItem tmp = {0, "", 0, "", ""};
- int a = 0, totitem = 0;
-
- for (type = R_engines.first; type; type = type->next, a++) {
- tmp.value = a;
- tmp.identifier = type->idname;
- tmp.name = type->name;
- RNA_enum_item_add(&item, &totitem, &tmp);
- }
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
-static int rna_ViewRenderSettings_engine_get(PointerRNA *ptr)
-{
- ViewRender *view_render = (ViewRender *)ptr->data;
- RenderEngineType *type;
- int a = 0;
-
- for (type = R_engines.first; type; type = type->next, a++)
- if (STREQ(type->idname, view_render->engine_id))
- return a;
-
- return 0;
-}
-
-static void rna_ViewRenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr))
-{
- ED_render_engine_changed(bmain);
-}
-
-static int rna_ViewRenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr))
-{
- return (BLI_listbase_count(&R_engines) > 1);
-}
-
-static int rna_ViewRenderSettings_use_shading_nodes_get(PointerRNA *ptr)
-{
- ViewRender *view_render = (ViewRender *)ptr->data;
- return BKE_viewrender_use_new_shading_nodes(view_render);
-}
-
-static int rna_ViewRenderSettings_use_spherical_stereo_get(PointerRNA *ptr)
-{
- ViewRender *view_render = (ViewRender *)ptr->data;
- return BKE_viewrender_use_spherical_stereo(view_render);
-}
-
-static int rna_ViewRenderSettings_use_game_engine_get(PointerRNA *ptr)
-{
- ViewRender *view_render = (ViewRender *)ptr->data;
- RenderEngineType *type;
-
- for (type = R_engines.first; type; type = type->next)
- if (STREQ(type->idname, view_render->engine_id))
- return (type->flag & RE_GAME) != 0;
-
- return 0;
-}
-
#else
static void rna_def_scene_collections(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1258,6 +1185,14 @@ static void rna_def_view_layer_engine_settings_eevee(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
+ prop = RNA_def_property(srna, "taa_reprojection", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_taa_reprojection_get",
+ "rna_LayerEngineSettings_Eevee_taa_reprojection_set");
+ RNA_def_property_ui_text(prop, "Viewport Denoising", "Denoise image using temporal reprojection "
+ "(can leave some ghosting)");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
+
/* Screen Space Subsurface Scattering */
prop = RNA_def_property(srna, "sss_enable", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_sss_enable_get",
@@ -1736,6 +1671,17 @@ static void rna_def_layer_collection_engine_settings_clay(BlenderRNA *brna)
}
#endif /* WITH_CLAY_ENGINE */
+/* Workbench engine */
+static void rna_def_layer_collection_engine_settings_workbench(BlenderRNA *brna)
+{
+ StructRNA *srna;
+
+ srna = RNA_def_struct(brna, "LayerCollectionEngineSettingsWorkbench", "LayerCollectionSettings");
+ RNA_def_struct_ui_text(srna, "Collections Workbench Engine Settings", "Workbench specific settings for this collection");
+
+ RNA_define_verify_sdna(0); /* not in sdna */
+}
+
static void rna_def_layer_collection_mode_settings_object(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1958,6 +1904,7 @@ static void rna_def_layer_collection_settings(BlenderRNA *brna)
rna_def_layer_collection_engine_settings_clay(brna);
#endif
+ rna_def_layer_collection_engine_settings_workbench(brna);
rna_def_layer_collection_mode_settings_object(brna);
rna_def_layer_collection_mode_settings_edit(brna);
rna_def_layer_collection_mode_settings_paint_weight(brna);
@@ -2165,51 +2112,6 @@ static void rna_def_object_base(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ObjectBase_select_update");
}
-static void rna_def_scene_view_render(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem engine_items[] = {
- {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "ViewRenderSettings", NULL);
- RNA_def_struct_sdna(srna, "ViewRender");
- RNA_def_struct_path_func(srna, "rna_ViewRenderSettings_path");
- RNA_def_struct_ui_text(srna, "View Render", "Rendering settings related to viewport drawing/rendering");
-
- /* engine */
- prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, engine_items);
- RNA_def_property_enum_funcs(prop, "rna_ViewRenderSettings_engine_get", "rna_ViewRenderSettings_engine_set",
- "rna_ViewRenderSettings_engine_itemf");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering");
- RNA_def_property_update(prop, NC_WINDOW, "rna_ViewRenderSettings_engine_update");
-
- prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_multiple_engines_get", NULL);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available");
-
- prop = RNA_def_property(srna, "use_shading_nodes", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_shading_nodes_get", NULL);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Use Shading Nodes", "Active render engine uses new shading nodes system");
-
- prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_spherical_stereo_get", NULL);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Active render engine supports spherical stereo rendering");
-
- prop = RNA_def_property(srna, "use_game_engine", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_ViewRenderSettings_use_game_engine_get", NULL);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine");
-}
-
void RNA_def_view_layer(BlenderRNA *brna)
{
FunctionRNA *func;
@@ -2289,7 +2191,6 @@ void RNA_def_view_layer(BlenderRNA *brna)
/* *** Animated *** */
rna_def_view_layer_settings(brna);
rna_def_layer_collection_settings(brna);
- rna_def_scene_view_render(brna);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 42c8eceeb16..3ba2aee5f70 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -305,14 +305,8 @@ Mesh *rna_Main_meshes_new_from_object(
Main *bmain, ReportList *reports, Depsgraph *depsgraph,
Object *ob, int apply_modifiers, int calc_tessface, int calc_undeformed)
{
- EvaluationContext eval_ctx;
Scene *sce = DEG_get_evaluated_scene(depsgraph);
- DEG_evaluation_context_init(&eval_ctx, DEG_get_mode(depsgraph));
- eval_ctx.ctime = DEG_get_ctime(depsgraph);
- eval_ctx.view_layer = DEG_get_evaluated_view_layer(depsgraph);
- eval_ctx.depsgraph = depsgraph;
-
switch (ob->type) {
case OB_FONT:
case OB_CURVE:
@@ -325,7 +319,7 @@ Mesh *rna_Main_meshes_new_from_object(
return NULL;
}
- return BKE_mesh_new_from_object(&eval_ctx, bmain, sce, ob, apply_modifiers, calc_tessface, calc_undeformed);
+ return BKE_mesh_new_from_object(depsgraph, bmain, sce, ob, apply_modifiers, calc_tessface, calc_undeformed);
}
static Lamp *rna_Main_lamps_new(Main *bmain, const char *name, int type)
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index bf6e13e587c..0621c1e1ad6 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -38,22 +38,6 @@
#include "WM_api.h"
#include "WM_types.h"
-static const EnumPropertyItem prop_texture_coordinates_items[] = {
- {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"},
- {TEXCO_OBJECT, "OBJECT", 0, "Object", "Use linked object's coordinates for texture coordinates"},
- {TEXCO_UV, "UV", 0, "UV", "Use UV coordinates for texture coordinates"},
- {TEXCO_ORCO, "ORCO", 0, "Generated", "Use the original undeformed coordinates of the object"},
- {TEXCO_STRAND, "STRAND", 0, "Strand / Particle",
- "Use normalized strand texture coordinate (1D) or particle age (X) and trail position (Y)"},
- {TEXCO_WINDOW, "WINDOW", 0, "Window", "Use screen coordinates as texture coordinates"},
- {TEXCO_NORM, "NORMAL", 0, "Normal", "Use normal vector as texture coordinates"},
- {TEXCO_REFL, "REFLECTION", 0, "Reflection", "Use reflection vector as texture coordinates"},
- {TEXCO_STRESS, "STRESS", 0, "Stress",
- "Use the difference of edge lengths compared to original coordinates of the mesh"},
- {TEXCO_TANGENT, "TANGENT", 0, "Tangent", "Use the optional tangent vector as texture coordinates"},
- {0, NULL, 0, NULL, NULL}
-};
-
const EnumPropertyItem rna_enum_ramp_blend_items[] = {
{MA_RAMP_BLEND, "MIX", 0, "Mix", ""},
{MA_RAMP_ADD, "ADD", 0, "Add", ""},
@@ -133,47 +117,6 @@ static PointerRNA rna_Material_mirror_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data);
}
-static PointerRNA rna_Material_transp_get(PointerRNA *ptr)
-{
- return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceTransparency, ptr->id.data);
-}
-
-static PointerRNA rna_Material_halo_get(PointerRNA *ptr)
-{
- return rna_pointer_inherit_refine(ptr, &RNA_MaterialHalo, ptr->id.data);
-}
-
-static PointerRNA rna_Material_sss_get(PointerRNA *ptr)
-{
- return rna_pointer_inherit_refine(ptr, &RNA_MaterialSubsurfaceScattering, ptr->id.data);
-}
-
-static PointerRNA rna_Material_strand_get(PointerRNA *ptr)
-{
- return rna_pointer_inherit_refine(ptr, &RNA_MaterialStrand, ptr->id.data);
-}
-
-static PointerRNA rna_Material_physics_get(PointerRNA *ptr)
-{
- return rna_pointer_inherit_refine(ptr, &RNA_MaterialPhysics, ptr->id.data);
-}
-
-static void rna_Material_type_set(PointerRNA *ptr, int value)
-{
- Material *ma = (Material *)ptr->data;
-
- if (ma->material_type == MA_TYPE_HALO && value != MA_TYPE_HALO)
- ma->mode &= ~(MA_STAR | MA_HALO_XALPHA | MA_ZINV | MA_ENV);
-
- ma->material_type = value;
-}
-
-static void rna_Material_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- Material *ma = (Material *)ptr->data;
- rna_iterator_array_begin(iter, (void *)ma->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL);
-}
-
static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Material *ma = (Material *)ptr->data;
@@ -234,124 +177,6 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s
WM_main_add_notifier(NC_MATERIAL | ND_SHADING, ma);
}
-static PointerRNA rna_Material_active_texture_get(PointerRNA *ptr)
-{
- Material *ma = (Material *)ptr->data;
- Tex *tex;
-
- tex = give_current_material_texture(ma);
- return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
-}
-
-static void rna_Material_active_texture_set(PointerRNA *ptr, PointerRNA value)
-{
- Material *ma = (Material *)ptr->data;
-
- set_current_material_texture(ma, value.data);
-}
-
-static int rna_Material_active_texture_editable(PointerRNA *ptr, const char **UNUSED(r_info))
-{
- Material *ma = (Material *)ptr->id.data;
-
- return has_current_material_texture(ma) ? PROP_EDITABLE : 0;
-}
-
-static PointerRNA rna_Material_active_node_material_get(PointerRNA *ptr)
-{
- Material *ma = give_node_material((Material *)ptr->data);
- return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
-}
-
-static void rna_Material_active_node_material_set(PointerRNA *ptr, PointerRNA value)
-{
- Material *ma = (Material *)ptr->data;
- Material *ma_act = value.data;
-
- nodeSetActiveID(ma->nodetree, ID_MA, &ma_act->id);
-}
-
-static void rna_MaterialStrand_start_size_range(PointerRNA *ptr, float *min, float *max,
- float *UNUSED(softmin), float *UNUSED(softmax))
-{
- Material *ma = (Material *)ptr->id.data;
-
- if (ma->mode & MA_STR_B_UNITS) {
- *min = 0.0001f;
- *max = 2.0f;
- }
- else {
- *min = 0.25f;
- *max = 20.0f;
- }
-}
-
-static void rna_MaterialStrand_end_size_range(PointerRNA *ptr, float *min, float *max,
- float *UNUSED(softmin), float *UNUSED(softmax))
-{
- Material *ma = (Material *)ptr->id.data;
-
- if (ma->mode & MA_STR_B_UNITS) {
- *min = 0.0001f;
- *max = 1.0f;
- }
- else {
- *min = 0.25f;
- *max = 10.0f;
- }
-}
-
-static int rna_MaterialTextureSlot_use_get(PointerRNA *ptr)
-{
- Material *ma = (Material *)ptr->id.data;
- MTex *mtex = (MTex *)ptr->data;
- int a;
-
- for (a = 0; a < MAX_MTEX; a++)
- if (ma->mtex[a] == mtex)
- return (ma->septex & (1 << a)) == 0;
-
- return 0;
-}
-
-static void rna_MaterialTextureSlot_use_set(PointerRNA *ptr, int value)
-{
- Material *ma = (Material *)ptr->id.data;
- MTex *mtex = (MTex *)ptr->data;
- int a;
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (ma->mtex[a] == mtex) {
- if (value)
- ma->septex &= ~(1 << a);
- else
- ma->septex |= (1 << a);
- }
- }
-}
-
-static void rna_Material_use_diffuse_ramp_set(PointerRNA *ptr, int value)
-{
- Material *ma = (Material *)ptr->data;
-
- if (value) ma->mode |= MA_RAMP_COL;
- else ma->mode &= ~MA_RAMP_COL;
-
- if ((ma->mode & MA_RAMP_COL) && ma->ramp_col == NULL)
- ma->ramp_col = BKE_colorband_add(false);
-}
-
-static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value)
-{
- Material *ma = (Material *)ptr->data;
-
- if (value) ma->mode |= MA_RAMP_SPEC;
- else ma->mode &= ~MA_RAMP_SPEC;
-
- if ((ma->mode & MA_RAMP_SPEC) && ma->ramp_spec == NULL)
- ma->ramp_spec = BKE_colorband_add(false);
-}
-
static void rna_Material_use_nodes_update(bContext *C, PointerRNA *ptr)
{
Material *ma = (Material *)ptr->data;
@@ -364,36 +189,6 @@ static void rna_Material_use_nodes_update(bContext *C, PointerRNA *ptr)
rna_Material_draw_update(bmain, CTX_data_scene(C), ptr);
}
-static const EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *UNUSED(C), PointerRNA *ptr,
- PropertyRNA *UNUSED(prop), bool *r_free)
-{
- Material *ma = (Material *)ptr->id.data;
- EnumPropertyItem *item = NULL;
- int totitem = 0;
-
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_GLOB);
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_OBJECT);
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_ORCO);
-
- if (ma->material_type == MA_TYPE_VOLUME) {
-
- }
- else if (ELEM(ma->material_type, MA_TYPE_SURFACE, MA_TYPE_HALO, MA_TYPE_WIRE)) {
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_UV);
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRAND);
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_WINDOW);
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_NORM);
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_REFL);
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRESS);
- RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_TANGENT);
- }
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
MTex *rna_mtex_texture_slots_add(ID *self_id, struct bContext *C, ReportList *reports)
{
MTex *mtex = BKE_texture_mtex_add_id(self_id, -1);
@@ -455,467 +250,10 @@ void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *r
#else
-static void rna_def_material_mtex(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_mapping_items[] = {
- {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"},
- {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"},
- {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"},
- {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_x_mapping_items[] = {
- {0, "NONE", 0, "None", ""},
- {1, "X", 0, "X", ""},
- {2, "Y", 0, "Y", ""},
- {3, "Z", 0, "Z", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_y_mapping_items[] = {
- {0, "NONE", 0, "None", ""},
- {1, "X", 0, "X", ""},
- {2, "Y", 0, "Y", ""},
- {3, "Z", 0, "Z", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_z_mapping_items[] = {
- {0, "NONE", 0, "None", ""},
- {1, "X", 0, "X", ""},
- {2, "Y", 0, "Y", ""},
- {3, "Z", 0, "Z", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_normal_map_space_items[] = {
- {MTEX_NSPACE_CAMERA, "CAMERA", 0, "Camera", ""},
- {MTEX_NSPACE_WORLD, "WORLD", 0, "World", ""},
- {MTEX_NSPACE_OBJECT, "OBJECT", 0, "Object", ""},
- {MTEX_NSPACE_TANGENT, "TANGENT", 0, "Tangent", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_bump_method_items[] = {
- {0, "BUMP_ORIGINAL", 0, "Original", ""},
- {MTEX_COMPAT_BUMP, "BUMP_COMPATIBLE", 0, "Compatible", ""},
- {MTEX_3TAP_BUMP, "BUMP_LOW_QUALITY", 0, "Low Quality", "Use 3 tap filtering"},
- {MTEX_5TAP_BUMP, "BUMP_MEDIUM_QUALITY", 0, "Medium Quality", "Use 5 tap filtering"},
- {MTEX_BICUBIC_BUMP, "BUMP_BEST_QUALITY", 0,
- "Best Quality", "Use bicubic filtering (requires OpenGL 3.0+, it will fall back on "
- "medium setting for other systems)"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_bump_space_items[] = {
- {0, "BUMP_VIEWSPACE", 0, "ViewSpace", ""},
- {MTEX_BUMP_OBJECTSPACE, "BUMP_OBJECTSPACE", 0, "ObjectSpace", ""},
- {MTEX_BUMP_TEXTURESPACE, "BUMP_TEXTURESPACE", 0, "TextureSpace", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "MaterialTextureSlot", "TextureSlot");
- RNA_def_struct_sdna(srna, "MTex");
- RNA_def_struct_ui_text(srna, "Material Texture Slot", "Texture slot for textures in a Material data-block");
-
- prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "texco");
- RNA_def_property_enum_items(prop, prop_texture_coordinates_items);
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Material_texture_coordinates_itemf");
- RNA_def_property_ui_text(prop, "Texture Coordinates", "");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "object");
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "uvname");
- RNA_def_property_ui_text(prop, "UV Map", "UV map to use for mapping with UV texture coordinates");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_from_dupli", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_DUPLI_MAPTO);
- RNA_def_property_ui_text(prop, "From Dupli",
- "Dupli's instanced from verts, faces or particles, inherit texture coordinate "
- "from their parent");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_to_bounds", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_MAPTO_BOUNDS);
- RNA_def_property_ui_text(prop, "Map to Bounds",
- "Map coordinates in object bounds");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_from_original", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_OB_DUPLI_ORIG);
- RNA_def_property_ui_text(prop, "From Original",
- "Dupli's derive their object coordinates from the original object's transformation");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_color_diffuse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COL);
- RNA_def_property_ui_text(prop, "Diffuse Color", "The texture affects basic color of the material");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_normal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_NORM);
- RNA_def_property_ui_text(prop, "Normal", "The texture affects the rendered normal");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_color_spec", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COLSPEC);
- RNA_def_property_ui_text(prop, "Specular Color", "The texture affects the specularity color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_mirror", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COLMIR);
- RNA_def_property_ui_text(prop, "Mirror", "The texture affects the mirror color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_diffuse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REF);
- RNA_def_property_ui_text(prop, "Diffuse", "The texture affects the value of diffuse reflectivity");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_specular", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_SPEC);
- RNA_def_property_ui_text(prop, "Specular", "The texture affects the value of specular reflectivity");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_ambient", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_AMB);
- RNA_def_property_ui_text(prop, "Ambient", "The texture affects the value of ambient");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_hardness", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_HAR);
- RNA_def_property_ui_text(prop, "Hardness", "The texture affects the hardness value");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_raymir", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_RAYMIRR);
- RNA_def_property_ui_text(prop, "Ray-Mirror", "The texture affects the ray-mirror value");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_alpha", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_ALPHA);
- RNA_def_property_ui_text(prop, "Alpha", "The texture affects the alpha value");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_emit", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMIT);
- RNA_def_property_ui_text(prop, "Emit", "The texture affects the emit value");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_translucency", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_TRANSLU);
- RNA_def_property_ui_text(prop, "Translucency", "The texture affects the translucency value");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_displacement", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_DISPLACE);
- RNA_def_property_ui_text(prop, "Displacement", "Let the texture displace the surface");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_warp", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_WARP);
- RNA_def_property_ui_text(prop, "Warp", "Let the texture warp texture coordinates of next channels");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "projx");
- RNA_def_property_enum_items(prop, prop_x_mapping_items);
- RNA_def_property_ui_text(prop, "X Mapping", "");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "projy");
- RNA_def_property_enum_items(prop, prop_y_mapping_items);
- RNA_def_property_ui_text(prop, "Y Mapping", "");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "projz");
- RNA_def_property_enum_items(prop, prop_z_mapping_items);
- RNA_def_property_ui_text(prop, "Z Mapping", "");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, prop_mapping_items);
- RNA_def_property_ui_text(prop, "Mapping", "");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "normal_map_space", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "normapspace");
- RNA_def_property_enum_items(prop, prop_normal_map_space_items);
- RNA_def_property_ui_text(prop, "Normal Map Space", "Set space of normal map image");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "norfac");
- RNA_def_property_ui_range(prop, -5, 5, 10, 3);
- RNA_def_property_ui_text(prop, "Normal Factor", "Amount texture affects normal values");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "displacement_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "dispfac");
- RNA_def_property_ui_range(prop, -1, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Displacement Factor", "Amount texture displaces the surface");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "warp_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "warpfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Warp Factor", "Amount texture affects texture coordinates of next channels");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_color_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "colspecfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Specular Color Factor", "Amount texture affects specular color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_color_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "colfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Diffuse Color Factor", "Amount texture affects diffuse color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "mirror_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "mirrfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Mirror Factor", "Amount texture affects mirror color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "alpha_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "alphafac");
- RNA_def_property_ui_range(prop, -1, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Alpha Factor", "Amount texture affects alpha");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "difffac");
- RNA_def_property_ui_range(prop, -1, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Diffuse Factor", "Amount texture affects diffuse reflectivity");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "specfac");
- RNA_def_property_ui_range(prop, -1, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Specular Factor", "Amount texture affects specular reflectivity");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "emit_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "emitfac");
- RNA_def_property_ui_range(prop, -1, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Emit Factor", "Amount texture affects emission");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "hardness_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "hardfac");
- RNA_def_property_ui_range(prop, -1, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Hardness Factor", "Amount texture affects hardness");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "raymir_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "raymirrfac");
- RNA_def_property_ui_range(prop, -1, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Ray Mirror Factor", "Amount texture affects ray mirror");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "translucency_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "translfac");
- RNA_def_property_ui_range(prop, -1, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Translucency Factor", "Amount texture affects translucency");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "ambient_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ambfac");
- RNA_def_property_ui_range(prop, -1, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Ambient Factor", "Amount texture affects ambient");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- /* volume material */
- prop = RNA_def_property(srna, "use_map_color_emission", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION_COL);
- RNA_def_property_ui_text(prop, "Emission Color", "The texture affects the color of emission");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_color_reflection", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REFLECTION_COL);
- RNA_def_property_ui_text(prop, "Reflection Color", "The texture affects the color of scattered light");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_color_transmission", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_TRANSMISSION_COL);
- RNA_def_property_ui_text(prop, "Transmission Color",
- "The texture affects the result color after other light has been scattered/absorbed");
- RNA_def_property_update(prop, NC_TEXTURE, NULL);
-
- prop = RNA_def_property(srna, "use_map_density", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_DENSITY);
- RNA_def_property_ui_text(prop, "Density", "The texture affects the volume's density");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_emission", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION);
- RNA_def_property_ui_text(prop, "Emission", "The texture affects the volume's emission");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_scatter", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_SCATTERING);
- RNA_def_property_ui_text(prop, "Scattering", "The texture affects the volume's scattering");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_map_reflect", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REFLECTION);
- RNA_def_property_ui_text(prop, "Reflection", "The texture affects the reflected light's brightness");
- RNA_def_property_update(prop, NC_TEXTURE, NULL);
-
- prop = RNA_def_property(srna, "emission_color_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "colemitfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Emission Color Factor", "Amount texture affects emission color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "reflection_color_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "colreflfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Reflection Color Factor", "Amount texture affects color of out-scattered light");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "transmission_color_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "coltransfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Transmission Color Factor",
- "Amount texture affects result color after light has been scattered/absorbed");
- RNA_def_property_update(prop, NC_TEXTURE, NULL);
-
- prop = RNA_def_property(srna, "density_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "densfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Density Factor", "Amount texture affects density");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "emission_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "emitfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Emission Factor", "Amount texture affects emission");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "scattering_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "scatterfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Scattering Factor", "Amount texture affects scattering");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "reflection_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "reflfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Reflection Factor", "Amount texture affects brightness of out-scattered light");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- /* end volume material */
-
- prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_MaterialTextureSlot_use_get", "rna_MaterialTextureSlot_use_set");
- RNA_def_property_ui_text(prop, "Enabled", "Enable this material texture slot");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "bump_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "texflag");
- RNA_def_property_enum_items(prop, prop_bump_method_items);
- RNA_def_property_ui_text(prop, "Bump Method", "Method to use for bump mapping");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "bump_objectspace", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "texflag");
- RNA_def_property_enum_items(prop, prop_bump_space_items);
- RNA_def_property_ui_text(prop, "Bump Space", "Space to apply bump mapping in");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
-static void rna_def_material_gamesettings(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_alpha_blend_items[] = {
- {GEMAT_SOLID, "OPAQUE", 0, "Opaque", "Render color of textured face as color"},
- {GEMAT_ADD, "ADD", 0, "Add", "Render face transparent and add color of face"},
- {GEMAT_CLIP, "CLIP", 0, "Alpha Clip", "Use the image alpha values clipped with no blending (binary alpha)"},
- {GEMAT_ALPHA, "ALPHA", 0, "Alpha Blend",
- "Render polygon transparent, depending on alpha channel of the texture"},
- {GEMAT_ALPHA_SORT, "ALPHA_SORT", 0, "Alpha Sort",
- "Sort faces for correct alpha drawing (slow, use Alpha Clip instead when possible)"},
- {GEMAT_ALPHA_TO_COVERAGE, "ALPHA_ANTIALIASING", 0, "Alpha Anti-Aliasing",
- "Use textures alpha as anti-aliasing mask, requires multi-sample OpenGL display"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_face_orientation_items[] = {
- {GEMAT_NORMAL, "NORMAL", 0, "Normal", "No transformation"},
- {GEMAT_HALO, "HALO", 0, "Halo", "Screen aligned billboard"},
- {GEMAT_BILLBOARD, "BILLBOARD", 0, "Billboard", "Billboard with Z-axis constraint"},
- {GEMAT_SHADOW, "SHADOW", 0, "Shadow", "Faces are used for shadow"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "MaterialGameSettings", NULL);
- RNA_def_struct_sdna(srna, "GameSettings");
- RNA_def_struct_nested(brna, srna, "Material");
- RNA_def_struct_ui_text(srna, "Material Game Settings", "Game Engine settings for a Material data-block");
-
- prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_BACKCULL); /* use bitflags */
- RNA_def_property_ui_text(prop, "Backface Culling", "Hide Back of the face in Game Engine ");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "text", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_TEXT); /* use bitflags */
- RNA_def_property_ui_text(prop, "Text", "Use material as text in Game Engine ");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "invisible", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_INVISIBLE); /* use bitflags */
- RNA_def_property_ui_text(prop, "Invisible", "Make face invisible");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "alpha_blend", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "alpha_blend");
- RNA_def_property_enum_items(prop, prop_alpha_blend_items);
- RNA_def_property_ui_text(prop, "Blend Mode", "Blend Mode for Transparent Faces");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "face_orientation", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, prop_face_orientation_items);
- RNA_def_property_ui_text(prop, "Face Orientations", "Especial face orientation options");
-
- prop = RNA_def_property(srna, "physics", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GEMAT_NOPHYSICS); /* use bitflags */
- RNA_def_property_ui_text(prop, "Physics", "Use physics properties of materials ");
-}
-
static void rna_def_material_colors(StructRNA *srna)
{
PropertyRNA *prop;
- static const EnumPropertyItem prop_ramp_input_items[] = {
- {MA_RAMP_IN_SHADER, "SHADER", 0, "Shader", ""},
- {MA_RAMP_IN_ENERGY, "ENERGY", 0, "Energy", ""},
- {MA_RAMP_IN_NOR, "NORMAL", 0, "Normal", ""},
- {MA_RAMP_IN_RESULT, "RESULT", 0, "Result", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "r");
RNA_def_property_array(prop, 3);
@@ -928,84 +266,17 @@ static void rna_def_material_colors(StructRNA *srna)
RNA_def_property_ui_text(prop, "Specular Color", "Specular color of the material");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
- prop = RNA_def_property(srna, "mirror_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "mirr");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Mirror Color", "Mirror color of the material");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
+ prop = RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "spec");
+ RNA_def_property_range(prop, 0, 1);
+ RNA_def_property_ui_text(prop, "Specular Intensity", "How intense (bright) the specular reflection is");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Alpha", "Alpha transparency of the material");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
- prop = RNA_def_property(srna, "specular_alpha", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "spectra");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Specular Alpha", "Alpha transparency for specular areas");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- /* Color bands */
- prop = RNA_def_property(srna, "use_diffuse_ramp", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAMP_COL);
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_diffuse_ramp_set");
- RNA_def_property_ui_text(prop, "Use Diffuse Ramp", "Toggle diffuse ramp operations");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_ramp", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "ramp_col");
- RNA_def_property_struct_type(prop, "ColorRamp");
- RNA_def_property_ui_text(prop, "Diffuse Ramp", "Color ramp used to affect diffuse shading");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_specular_ramp", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAMP_SPEC);
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_specular_ramp_set");
- RNA_def_property_ui_text(prop, "Use Specular Ramp", "Toggle specular ramp operations");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_ramp", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "ramp_spec");
- RNA_def_property_struct_type(prop, "ColorRamp");
- RNA_def_property_ui_text(prop, "Specular Ramp", "Color ramp used to affect specular shading");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_ramp_blend", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "rampblend_col");
- RNA_def_property_enum_items(prop, rna_enum_ramp_blend_items);
- RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", "Blending method of the ramp and the diffuse color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_ramp_blend", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "rampblend_spec");
- RNA_def_property_enum_items(prop, rna_enum_ramp_blend_items);
- RNA_def_property_ui_text(prop, "Specular Ramp Blend", "Blending method of the ramp and the specular color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_ramp_input", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "rampin_col");
- RNA_def_property_enum_items(prop, prop_ramp_input_items);
- RNA_def_property_ui_text(prop, "Diffuse Ramp Input", "How the ramp maps on the surface");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_ramp_input", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "rampin_spec");
- RNA_def_property_enum_items(prop, prop_ramp_input_items);
- RNA_def_property_ui_text(prop, "Specular Ramp Input", "How the ramp maps on the surface");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_ramp_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "rampfac_col");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Diffuse Ramp Factor", "Blending factor (also uses alpha in Colorband)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_ramp_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "rampfac_spec");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Specular Ramp Factor", "Blending factor (also uses alpha in Colorband)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
/* Freestyle line color */
prop = RNA_def_property(srna, "line_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "line_col");
@@ -1021,768 +292,28 @@ static void rna_def_material_colors(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Material_update");
}
-static void rna_def_material_diffuse(StructRNA *srna)
-{
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_diff_shader_items[] = {
- {MA_DIFF_LAMBERT, "LAMBERT", 0, "Lambert", "Use a Lambertian shader"},
- {MA_DIFF_ORENNAYAR, "OREN_NAYAR", 0, "Oren-Nayar", "Use an Oren-Nayar shader"},
- {MA_DIFF_TOON, "TOON", 0, "Toon", "Use a toon shader"},
- {MA_DIFF_MINNAERT, "MINNAERT", 0, "Minnaert", "Use a Minnaert shader"},
- {MA_DIFF_FRESNEL, "FRESNEL", 0, "Fresnel", "Use a Fresnel shader"},
- {0, NULL, 0, NULL, NULL}
- };
-
- prop = RNA_def_property(srna, "diffuse_shader", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "diff_shader");
- RNA_def_property_enum_items(prop, prop_diff_shader_items);
- RNA_def_property_ui_text(prop, "Diffuse Shader Model", "");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_intensity", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "ref");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Diffuse Intensity", "Amount of diffuse reflection");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0f, 3.14f);
- RNA_def_property_ui_text(prop, "Roughness", "Oren-Nayar Roughness");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_toon_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "param[0]");
- RNA_def_property_range(prop, 0.0f, 3.14f);
- RNA_def_property_ui_text(prop, "Diffuse Toon Size", "Size of diffuse toon area");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_toon_smooth", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "param[1]");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Diffuse Toon Smooth", "Smoothness of diffuse toon area");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_fresnel", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "param[1]");
- RNA_def_property_range(prop, 0.0f, 5.0f);
- RNA_def_property_ui_text(prop, "Diffuse Fresnel", "Power of Fresnel");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "diffuse_fresnel_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "param[0]");
- RNA_def_property_range(prop, 0.0f, 5.0f);
- RNA_def_property_ui_text(prop, "Diffuse Fresnel Factor", "Blending factor of Fresnel");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "darkness", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0f, 2.0f);
- RNA_def_property_ui_text(prop, "Darkness", "Minnaert darkness");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
static void rna_def_material_raymirror(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
- static const EnumPropertyItem prop_fadeto_mir_items[] = {
- {MA_RAYMIR_FADETOSKY, "FADE_TO_SKY", 0, "Sky", ""},
- {MA_RAYMIR_FADETOMAT, "FADE_TO_MATERIAL", 0, "Material", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
srna = RNA_def_struct(brna, "MaterialRaytraceMirror", NULL);
RNA_def_struct_sdna(srna, "Material");
RNA_def_struct_nested(brna, srna, "Material");
RNA_def_struct_ui_text(srna, "Material Raytrace Mirror", "Raytraced reflection settings for a Material data-block");
- prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYMIRROR); /* use bitflags */
- RNA_def_property_ui_text(prop, "Enabled", "Enable raytraced reflections");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
prop = RNA_def_property(srna, "reflect_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "ray_mirror");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Reflectivity", "Amount of mirror reflection for raytrace");
RNA_def_property_update(prop, 0, "rna_Material_update");
- prop = RNA_def_property(srna, "fresnel", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fresnel_mir");
- RNA_def_property_range(prop, 0.0f, 5.0f);
- RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for mirror reflection");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "fresnel_mir_i");
- RNA_def_property_range(prop, 0.0f, 5.0f);
- RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
prop = RNA_def_property(srna, "gloss_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "gloss_mir");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Gloss Amount",
"The shininess of the reflection (values < 1.0 give diffuse, blurry reflections)");
RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "gloss_anisotropic", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "aniso_gloss_mir");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Gloss Anisotropy",
- "The shape of the reflection, from 0.0 (circular) to 1.0 "
- "(fully stretched along the tangent");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "gloss_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "samp_gloss_mir");
- RNA_def_property_range(prop, 0, 1024);
- RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry reflections");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_mir");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Gloss Threshold",
- "Threshold for adaptive sampling (if a sample contributes less than "
- "this amount [as a percentage], sampling is stopped)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "ray_depth");
- RNA_def_property_ui_range(prop, 0, 100, 1, 3);
- RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-reflections");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "dist_mir");
- RNA_def_property_range(prop, 0.0f, 10000.0f);
- RNA_def_property_ui_text(prop, "Maximum Distance",
- "Maximum distance of reflected rays (reflections further than this "
- "range fade to sky color or material color)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "fade_to", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "fadeto_mir");
- RNA_def_property_enum_items(prop, prop_fadeto_mir_items);
- RNA_def_property_ui_text(prop, "Fade-out Color",
- "The color that rays with no intersection within the Max Distance take "
- "(material color can be best for indoor scenes, sky color for outdoor)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
-static void rna_def_material_raytra(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MaterialRaytraceTransparency", NULL);
- RNA_def_struct_sdna(srna, "Material");
- RNA_def_struct_nested(brna, srna, "Material");
- RNA_def_struct_ui_text(srna, "Material Raytrace Transparency",
- "Raytraced refraction settings for a Material data-block");
-
- prop = RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ang");
- RNA_def_property_range(prop, 0.25f, 4.0f);
- RNA_def_property_ui_text(prop, "IOR", "Angular index of refraction for raytraced refraction");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "fresnel", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fresnel_tra");
- RNA_def_property_range(prop, 0.0f, 5.0f);
- RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for transparency (Ray or ZTransp)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "fresnel_tra_i");
- RNA_def_property_range(prop, 1.0f, 5.0f);
- RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "gloss_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "gloss_tra");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Gloss Amount",
- "The clarity of the refraction. Values < 1.0 give diffuse, blurry refractions");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "gloss_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "samp_gloss_tra");
- RNA_def_property_range(prop, 0, 1024);
- RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry refractions");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_tra");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Gloss Threshold",
- "Threshold for adaptive sampling. If a sample contributes less than "
- "this amount (as a percentage), sampling is stopped");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "ray_depth_tra");
- RNA_def_property_ui_range(prop, 0, 100, 1, 3);
- RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-refractions");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "filter", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "filter");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Filter",
- "Amount to blend in the material's diffuse color in raytraced "
- "transparency (simulating absorption)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "depth_max", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "tx_limit");
- RNA_def_property_range(prop, 0.0f, 100.0f);
- RNA_def_property_ui_text(prop, "Limit",
- "Maximum depth for light to travel through the transparent material "
- "before becoming fully filtered (0.0 is disabled)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "tx_falloff");
- RNA_def_property_range(prop, 0.1f, 10.0f);
- RNA_def_property_ui_text(prop, "Falloff", "Falloff power for transmissivity filter effect (1.0 is linear)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
-static void rna_def_material_volume(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_lighting_items[] = {
- {MA_VOL_SHADE_SHADELESS, "SHADELESS", 0, "Shadeless", "Do not calculate lighting and shadows"},
- {MA_VOL_SHADE_SHADOWED, "SHADOWED", 0, "Shadowed", ""},
- {MA_VOL_SHADE_SHADED, "SHADED", 0, "Shaded", ""},
- {MA_VOL_SHADE_MULTIPLE, "MULTIPLE_SCATTERING", 0, "Multiple Scattering", ""},
- {MA_VOL_SHADE_SHADEDPLUSMULTIPLE, "SHADED_PLUS_MULTIPLE_SCATTERING", 0, "Shaded + Multiple Scattering", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_stepsize_items[] = {
- {MA_VOL_STEP_RANDOMIZED, "RANDOMIZED", 0, "Randomized", ""},
- {MA_VOL_STEP_CONSTANT, "CONSTANT", 0, "Constant", ""},
- /*{MA_VOL_STEP_ADAPTIVE, "ADAPTIVE", 0, "Adaptive", ""}, */
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "MaterialVolume", NULL);
- RNA_def_struct_sdna(srna, "VolumeSettings");
- RNA_def_struct_nested(brna, srna, "Material");
- RNA_def_struct_ui_text(srna, "Material Volume", "Volume rendering settings for a Material data-block");
-
- prop = RNA_def_property(srna, "step_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "stepsize_type");
- RNA_def_property_enum_items(prop, prop_stepsize_items);
- RNA_def_property_ui_text(prop, "Step Calculation", "Method of calculating the steps through the volume");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "stepsize");
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.001f, 1.0f, 1, 3);
- RNA_def_property_ui_text(prop, "Step Size", "Distance between subsequent volume depth samples");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "light_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "shade_type");
- RNA_def_property_enum_items(prop, prop_lighting_items);
- RNA_def_property_ui_text(prop, "Lighting Mode",
- "Method of shading, attenuating, and scattering light through the volume");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_external_shadows", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shadeflag", MA_VOL_RECV_EXT_SHADOW); /* use bitflags */
- RNA_def_property_ui_text(prop, "External Shadows", "Receive shadows from sources outside the volume (temporary)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_light_cache", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shadeflag", MA_VOL_PRECACHESHADING); /* use bitflags */
- RNA_def_property_ui_text(prop, "Light Cache",
- "Pre-calculate the shading information into a voxel grid, "
- "speeds up shading at slightly less accuracy");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "cache_resolution", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "precache_resolution");
- RNA_def_property_range(prop, 1, 1024);
- RNA_def_property_ui_text(prop, "Resolution",
- "Resolution of the voxel grid, low resolutions are faster, "
- "high resolutions use more memory");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "ms_diffusion", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ms_diff");
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_ui_text(prop, "Diffusion", "Diffusion factor, the strength of the blurring effect");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "ms_spread", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ms_spread");
- RNA_def_property_range(prop, 0, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
- RNA_def_property_ui_text(prop, "Spread", "Proportional distance over which the light is diffused");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "ms_intensity", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ms_intensity");
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_ui_text(prop, "Intensity", "Multiplier for multiple scattered light energy");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "depth_threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "depth_cutoff");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Depth Cutoff",
- "Stop ray marching early if transmission drops below this luminance - "
- "higher values give speedups in dense volumes at the expense of accuracy");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "density");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Density", "The base density of the volume");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "density_scale", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "density_scale");
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
- RNA_def_property_ui_text(prop, "Density Scale", "Multiplier for the material's density");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "scattering", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "scattering");
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
- RNA_def_property_ui_text(prop, "Scattering",
- "Amount of light that gets scattered out by the volume - "
- "the more out-scattering, the shallower the light will penetrate");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "transmission_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "transmission_col");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Transmission Color",
- "Result color of the volume, after other light has been scattered/absorbed");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "reflection_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "reflection_col");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Reflection Color",
- "Color of light scattered out of the volume (does not affect transmission)");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "reflection", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "reflection");
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
- RNA_def_property_ui_text(prop, "Reflection",
- "Multiplier to make out-scattered light brighter or darker (non-physically correct)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "emission_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "emission_col");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Emission Color", "Color of emitted light");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "emission", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "emission");
- RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
- RNA_def_property_ui_text(prop, "Emission", "Amount of light that gets emitted by the volume");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "asymmetry", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "asymmetry");
- RNA_def_property_range(prop, -1.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Asymmetry",
- "Back scattering (-1.0) to Forward scattering (1.0) and the range in between");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
-
-static void rna_def_material_halo(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MaterialHalo", NULL);
- RNA_def_struct_sdna(srna, "Material");
- RNA_def_struct_nested(brna, srna, "Material");
- RNA_def_struct_ui_text(srna, "Material Halo", "Halo particle effect settings for a Material data-block");
-
- prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "hasize");
- RNA_def_property_range(prop, 0.0f, 100.0f);
- RNA_def_property_ui_text(prop, "Size", "Dimension of the halo");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "hardness", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "har");
- RNA_def_property_range(prop, 0, 127);
- RNA_def_property_ui_text(prop, "Hardness", "Hardness of the halo");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "add", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "add");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Add", "Strength of the add effect");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "ring_count", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "ringc");
- RNA_def_property_range(prop, 0, 24);
- RNA_def_property_ui_text(prop, "Rings", "Number of rings rendered over the halo");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "line_count", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "linec");
- RNA_def_property_range(prop, 0, 250);
- RNA_def_property_ui_text(prop, "Line Number", "Number of star shaped lines rendered over the halo");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "star_tip_count", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "starc");
- RNA_def_property_range(prop, 3, 50);
- RNA_def_property_ui_text(prop, "Star Tips", "Number of points on the star shaped halo");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "seed1");
- RNA_def_property_range(prop, 0, 255);
- RNA_def_property_ui_text(prop, "Seed", "Randomize ring dimension and line location");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_flare_mode", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_FLARE); /* use bitflags */
- RNA_def_property_ui_text(prop, "Flare", "Render halo as a lens flare");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "flare_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "flaresize");
- RNA_def_property_range(prop, 0.1f, 25.0f);
- RNA_def_property_ui_text(prop, "Flare Size", "Factor by which the flare is larger than the halo");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "flare_subflare_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "subsize");
- RNA_def_property_range(prop, 0.1f, 25.0f);
- RNA_def_property_ui_text(prop, "Flare Subsize", "Dimension of the sub-flares, dots and circles");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "flare_boost", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "flareboost");
- RNA_def_property_range(prop, 0.1f, 10.0f);
- RNA_def_property_ui_text(prop, "Flare Boost", "Give the flare extra strength");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "flare_seed", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "seed2");
- RNA_def_property_range(prop, 0, 255);
- RNA_def_property_ui_text(prop, "Flare Seed", "Offset in the flare seed table");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "flare_subflare_count", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "flarec");
- RNA_def_property_range(prop, 1, 32);
- RNA_def_property_ui_text(prop, "Flares Sub", "Number of sub-flares");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_ring", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_RINGS);
- RNA_def_property_ui_text(prop, "Rings", "Render rings over halo");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_lines", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_LINES);
- RNA_def_property_ui_text(prop, "Lines", "Render star shaped lines over halo");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_star", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STAR);
- RNA_def_property_ui_text(prop, "Star", "Render halo as a star");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALOTEX);
- RNA_def_property_ui_text(prop, "Texture", "Give halo a texture");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_vertex_normal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALOPUNO);
- RNA_def_property_ui_text(prop, "Vertex Normal", "Use the vertex normal to specify the dimension of the halo");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_extreme_alpha", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_XALPHA);
- RNA_def_property_ui_text(prop, "Extreme Alpha", "Use extreme alpha");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_shaded", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_SHADE);
- RNA_def_property_ui_text(prop, "Shaded", "Let halo receive light and shadows from external objects");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_soft", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_SOFT);
- RNA_def_property_ui_text(prop, "Soft", "Soften the edges of halos at intersections with other geometry");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
-static void rna_def_material_sss(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MaterialSubsurfaceScattering", NULL);
- RNA_def_struct_sdna(srna, "Material");
- RNA_def_struct_nested(brna, srna, "Material");
- RNA_def_struct_ui_text(srna, "Material Subsurface Scattering",
- "Diffuse subsurface scattering settings for a Material data-block");
-
- prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_COLOR | PROP_UNIT_LENGTH);
- RNA_def_property_float_sdna(prop, NULL, "sss_radius");
- RNA_def_property_range(prop, 0.001, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.001, 10000, 1, 3);
- RNA_def_property_ui_text(prop, "Radius", "Mean red/green/blue scattering path length");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "sss_col");
- RNA_def_property_ui_text(prop, "Color", "Scattering color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sss_error");
- RNA_def_property_ui_range(prop, 0.0001, 10, 1, 3);
- RNA_def_property_ui_text(prop, "Error Tolerance", "Error tolerance (low values are slower and higher quality)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sss_scale");
- RNA_def_property_ui_range(prop, 0.001, 1000, 1, 3);
- RNA_def_property_ui_text(prop, "Scale", "Object scale factor");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sss_ior");
- RNA_def_property_ui_range(prop, 0.1, 2, 1, 3);
- RNA_def_property_ui_text(prop, "IOR", "Index of refraction (higher values are denser)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "sss_colfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Color Factor", "Blend factor for SSS colors");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "texture_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "sss_texfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Texture Factor", "Texture scattering blend factor");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "front", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sss_front");
- RNA_def_property_range(prop, 0, 2);
- RNA_def_property_ui_text(prop, "Front", "Front scattering weight");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sss_back");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "Back", "Back scattering weight");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "sss_flag", MA_DIFF_SSS);
- RNA_def_property_ui_text(prop, "Enabled", "Enable diffuse subsurface scattering effects in a material");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
-static void rna_def_material_specularity(StructRNA *srna)
-{
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_specular_shader_items[] = {
- {MA_SPEC_COOKTORR, "COOKTORR", 0, "CookTorr", "Use a Cook-Torrance shader"},
- {MA_SPEC_PHONG, "PHONG", 0, "Phong", "Use a Phong shader"},
- {MA_SPEC_BLINN, "BLINN", 0, "Blinn", "Use a Blinn shader"},
- {MA_SPEC_TOON, "TOON", 0, "Toon", "Use a toon shader"},
- {MA_SPEC_WARDISO, "WARDISO", 0, "WardIso", "Use a Ward anisotropic shader"},
- {0, NULL, 0, NULL, NULL}
- };
-
- prop = RNA_def_property(srna, "specular_shader", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "spec_shader");
- RNA_def_property_enum_items(prop, prop_specular_shader_items);
- RNA_def_property_ui_text(prop, "Specular Shader Model", "");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "spec");
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_text(prop, "Specular Intensity", "How intense (bright) the specular reflection is");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- /* NOTE: "har", "param", etc are used for multiple purposes depending on
- * settings. This should be fixed in DNA once, for RNA we just expose them
- * multiple times, which may give somewhat strange changes in the outliner,
- * but in the UI they are never visible at the same time. */
-
- prop = RNA_def_property(srna, "specular_hardness", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "har");
- RNA_def_property_range(prop, 1, 511);
- RNA_def_property_ui_text(prop, "Specular Hardness", "How hard (sharp) the specular reflection is");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "specular_ior", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "refrac");
- RNA_def_property_range(prop, 1, 10);
- RNA_def_property_ui_text(prop, "Specular IOR", "Specular index of refraction");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_toon_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "param[2]");
- RNA_def_property_range(prop, 0.0f, 1.53f);
- RNA_def_property_ui_text(prop, "Specular Toon Size", "Size of specular toon area");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_toon_smooth", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "param[3]");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Specular Toon Smooth", "Smoothness of specular toon area");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "specular_slope", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "rms");
- RNA_def_property_range(prop, 0, 0.4);
- RNA_def_property_ui_text(prop, "Specular Slope", "The standard deviation of surface slope");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
-static void rna_def_material_strand(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MaterialStrand", NULL);
- RNA_def_struct_sdna(srna, "Material");
- RNA_def_struct_nested(brna, srna, "Material");
- RNA_def_struct_ui_text(srna, "Material Strand", "Strand settings for a Material data-block");
-
- prop = RNA_def_property(srna, "use_tangent_shading", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_STR);
- RNA_def_property_ui_text(prop, "Tangent Shading", "Use direction of strands as normal for tangent-shading");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- /* this flag is only set when rendering, not to be edited manually */
- prop = RNA_def_property(srna, "use_surface_diffuse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_SURFDIFF);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Surface Diffuse", "Make diffuse shading more similar to shading the surface");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "strand_surfnor");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "Blend Distance", "Worldspace distance over which to blend in the surface normal");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_blender_units", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_B_UNITS);
- RNA_def_property_ui_text(prop, "Blender Units", "Use Blender units for widths instead of pixels");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "root_size", PROP_FLOAT, PROP_UNSIGNED);
- RNA_def_property_float_sdna(prop, NULL, "strand_sta");
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_start_size_range");
- RNA_def_property_ui_range(prop, 0, 10.0f, 10, 5);
- RNA_def_property_ui_text(prop, "Root Size", "Start size of strands in pixels or Blender units");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "tip_size", PROP_FLOAT, PROP_UNSIGNED);
- RNA_def_property_float_sdna(prop, NULL, "strand_end");
- RNA_def_property_ui_range(prop, 0, 10.0f, 10, 5);
- RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_end_size_range");
- RNA_def_property_ui_text(prop, "Tip Size", "End size of strands in pixels or Blender units");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "size_min", PROP_FLOAT, PROP_UNSIGNED);
- RNA_def_property_float_sdna(prop, NULL, "strand_min");
- RNA_def_property_range(prop, 0.001, 10);
- RNA_def_property_ui_text(prop, "Minimum Size", "Minimum size of strands in pixels");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "shape", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "strand_ease");
- RNA_def_property_range(prop, -0.9, 0.9);
- RNA_def_property_ui_text(prop, "Shape", "Positive values make strands rounder, negative ones make strands spiky");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "width_fade", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "strand_widthfade");
- RNA_def_property_range(prop, 0, 2);
- RNA_def_property_ui_text(prop, "Width Fade", "Transparency along the width of the strand");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "strand_uvname");
- RNA_def_property_ui_text(prop, "UV Map", "Name of UV map to override");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-}
-
-static void rna_def_material_physics(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MaterialPhysics", NULL);
- RNA_def_struct_sdna(srna, "Material");
- RNA_def_struct_nested(brna, srna, "Material");
- RNA_def_struct_ui_text(srna, "Material Physics", "Physics settings for a Material data-block");
-
- prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "friction");
- RNA_def_property_range(prop, 0, 100);
- RNA_def_property_ui_text(prop, "Friction", "Coulomb friction coefficient, when inside the physics distance area");
-
- prop = RNA_def_property(srna, "elasticity", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "reflect");
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_text(prop, "Elasticity", "Elasticity of collisions");
-
- /* FH/Force Field Settings */
- prop = RNA_def_property(srna, "use_fh_normal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "dynamode", MA_FH_NOR);
- RNA_def_property_ui_text(prop, "Align to Normal",
- "Align dynamic game objects along the surface normal, "
- "when inside the physics distance area");
-
- prop = RNA_def_property(srna, "fh_force", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fh");
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2);
- RNA_def_property_ui_text(prop, "Force", "Upward spring force, when inside the physics distance area");
-
- prop = RNA_def_property(srna, "fh_distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fhdist");
- RNA_def_property_range(prop, 0, 20);
- RNA_def_property_ui_text(prop, "Distance", "Distance of the physics area");
-
- prop = RNA_def_property(srna, "fh_damping", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "xyfrict");
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_text(prop, "Damping", "Damping of the spring force, when inside the physics distance area");
}
void RNA_def_material(BlenderRNA *brna)
@@ -1790,20 +321,6 @@ void RNA_def_material(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static const EnumPropertyItem prop_type_items[] = {
- {MA_TYPE_SURFACE, "SURFACE", 0, "Surface", "Render object as a surface"},
- {MA_TYPE_WIRE, "WIRE", 0, "Wire", "Render the edges of faces as wires (not supported in raytracing)"},
- {MA_TYPE_VOLUME, "VOLUME", 0, "Volume", "Render object as a volume"},
- {MA_TYPE_HALO, "HALO", 0, "Halo", "Render object as halo particles"},
- {0, NULL, 0, NULL, NULL}
- };
- static const EnumPropertyItem transparency_items[] = {
- {0, "MASK", 0, "Mask", "Mask the background"},
- {MA_ZTRANSP, "Z_TRANSPARENCY", 0, "Z Transparency", "Use alpha buffer for transparent faces"},
- {MA_RAYTRANSP, "RAYTRACE", 0, "Raytrace", "Use raytracing for transparent refraction rendering"},
- {0, NULL, 0, NULL, NULL}
- };
-
/* Render Preview Types */
static const EnumPropertyItem preview_type_items[] = {
{MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Flat XY plane"},
@@ -1815,14 +332,6 @@ void RNA_def_material(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem prop_shadows_only_items[] = {
- {MA_SO_OLD, "SHADOW_ONLY_OLD", 0, "Shadow and Distance", "Old shadow only method"},
- {MA_SO_SHADOW, "SHADOW_ONLY", 0, "Shadow Only", "Improved shadow only method"},
- {MA_SO_SHADED, "SHADOW_ONLY_SHADED", 0, "Shadow and Shading",
- "Improved shadow only method which also renders lightless areas as shadows"},
- {0, NULL, 0, NULL, NULL}
- };
-
static EnumPropertyItem prop_eevee_blend_items[] = {
{MA_BM_SOLID, "OPAQUE", 0, "Opaque", "Render surface without transparency"},
{MA_BM_ADD, "ADD", 0, "Additive", "Render surface and blend the result with additive blending"},
@@ -1846,24 +355,6 @@ void RNA_def_material(BlenderRNA *brna)
"Material data-block to define the appearance of geometric objects for rendering");
RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
- prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "material_type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Type", "Material type defining how the object is rendered");
- RNA_def_property_enum_funcs(prop, NULL, "rna_Material_type_set", NULL);
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "use_transparency", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRANSP);
- RNA_def_property_ui_text(prop, "Transparency", "Render material as transparent");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "transparency_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, transparency_items);
- RNA_def_property_ui_text(prop, "Transparency Method", "Method to use for rendering transparency");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
/* Blending (only Eevee for now) */
prop = RNA_def_property(srna, "blend_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_eevee_blend_items);
@@ -1916,203 +407,11 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render");
RNA_def_property_update(prop, 0, "rna_Material_update_previews");
- prop = RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "amb");
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_text(prop, "Ambient", "Amount of global ambient color the material receives");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "emit", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0, FLT_MAX);
- RNA_def_property_ui_range(prop, 0, 2.0f, 1, 2);
- RNA_def_property_ui_text(prop, "Emit", "Amount of light to emit");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "translucency", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_text(prop, "Translucency", "Amount of diffuse shading on the back side");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_cubic", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_CUBIC);
- RNA_def_property_ui_text(prop, "Cubic Interpolation",
- "Use cubic interpolation for diffuse values, for smoother transitions");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_object_color", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_OBCOLOR);
- RNA_def_property_ui_text(prop, "Object Color", "Modulate the result with a per-object color");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "shadow_ray_bias", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "sbias");
- RNA_def_property_range(prop, 0, 0.25);
- RNA_def_property_ui_text(prop, "Shadow Ray Bias",
- "Shadow raytracing bias to prevent terminator problems on shadow boundary");
-
- prop = RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "lbias");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Factor to multiply shadow buffer bias with (0 is ignore)");
-
- prop = RNA_def_property(srna, "shadow_cast_alpha", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "shad_alpha");
- RNA_def_property_range(prop, 0.001, 1);
- RNA_def_property_ui_text(prop, "Shadow Casting Alpha",
- "Shadow casting alpha, in use for Irregular and Deep shadow buffer");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "light_group", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "group");
- RNA_def_property_struct_type(prop, "Group");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Light Group", "Limit lighting to lamps in this Group");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "edit_image", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "edit_image");
- RNA_def_property_struct_type(prop, "Image");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Edit Image", "Image to use for UV-mapping");
-
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "index");
RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Material Index\" render pass");
RNA_def_property_update(prop, NC_OBJECT, "rna_Material_update");
- /* flags */
-
- prop = RNA_def_property(srna, "use_light_group_exclusive", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_GROUP_NOLAY);
- RNA_def_property_ui_text(prop, "Light Group Exclusive",
- "Material uses the light group exclusively - these lamps are excluded "
- "from other scene lighting");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_light_group_local", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_GROUP_LOCAL);
- RNA_def_property_ui_text(prop, "Light Group Local", "When linked in, material uses local light group with the same name");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRACEBLE);
- RNA_def_property_ui_text(prop, "Traceable",
- "Include this material and geometry that uses it in raytracing calculations");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_shadows", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW);
- RNA_def_property_ui_text(prop, "Shadows", "Allow this material to receive shadows");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_shadeless", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHLESS);
- RNA_def_property_ui_text(prop, "Shadeless", "Make this material insensitive to light or shadow");
- RNA_def_property_update(prop, 0, "rna_Material_draw_update");
-
- prop = RNA_def_property(srna, "use_vertex_color_light", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOL);
- RNA_def_property_ui_text(prop, "Vertex Color Light", "Add vertex colors as additional lighting");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_vertex_color_paint", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOLP);
- RNA_def_property_ui_text(prop, "Vertex Color Paint",
- "Replace object base color with vertex colors (multiply with "
- "'texture face' face assigned textures)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ZINV);
- RNA_def_property_ui_text(prop, "Invert Z Depth",
- "Render material's faces with an inverted Z buffer (scanline only)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "offset_z", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "zoffs");
- RNA_def_property_ui_text(prop, "Z Offset", "Give faces an artificial offset in the Z buffer for Z transparency");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_sky", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ENV);
- RNA_def_property_ui_text(prop, "Sky",
- "Render this material with zero alpha, with sky background in place (scanline only)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_only_shadow", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ONLYSHADOW);
- RNA_def_property_ui_text(prop, "Only Shadow",
- "Render shadows as the material's alpha value, making the material "
- "transparent except for shadowed areas");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "shadow_only_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "shadowonly_flag");
- RNA_def_property_enum_items(prop, prop_shadows_only_items);
- RNA_def_property_ui_text(prop, "Shadow Type", "How to draw shadows");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_cast_shadows", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode2", MA_CASTSHADOW);
- RNA_def_property_ui_text(prop, "Cast Shadows",
- "Allow this material to cast shadows");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_cast_shadows_only", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ONLYCAST);
- RNA_def_property_ui_text(prop, "Cast Shadows Only",
- "Make objects with this material appear invisible (not rendered), only casting shadows");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_mist", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", MA_NOMIST);
- RNA_def_property_ui_text(prop, "Use Mist", "Use mist with this material (in world settings)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_transparent_shadows", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW_TRA);
- RNA_def_property_ui_text(prop, "Receive Transparent Shadows",
- "Allow this object to receive transparent shadows cast through other objects");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_ray_shadow_bias", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYBIAS);
- RNA_def_property_ui_text(prop, "Ray Shadow Bias",
- "Prevent raytraced shadow errors on surfaces with smooth shaded normals "
- "(terminator problem)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_full_oversampling", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FULL_OSA);
- RNA_def_property_ui_text(prop, "Full Oversampling",
- "Force this material to render full shading/textures for all anti-aliasing samples");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_cast_buffer_shadows", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADBUF);
- RNA_def_property_ui_text(prop, "Cast Buffer Shadows",
- "Allow this material to cast shadows from shadow buffer lamps");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_cast_approximate", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_APPROX_OCCLUSION);
- RNA_def_property_ui_text(prop, "Cast Approximate",
- "Allow this material to cast shadows when using approximate ambient occlusion");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_tangent_shading", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_V);
- RNA_def_property_ui_text(prop, "Tangent Shading",
- "Use the material's tangent vector instead of the normal for shading "
- "- for anisotropic shading effects");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
- prop = RNA_def_property(srna, "use_uv_project", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapflag", MA_MAPFLAG_UVPROJECT);
- RNA_def_property_ui_text(prop, "UV Project",
- "Use to ensure UV interpolation is correct for camera projections (use with UV project modifier)");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
/* nested structs */
prop = RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -2120,49 +419,6 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, "rna_Material_mirror_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Raytrace Mirror", "Raytraced reflection settings for the material");
- prop = RNA_def_property(srna, "raytrace_transparency", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "MaterialRaytraceTransparency");
- RNA_def_property_pointer_funcs(prop, "rna_Material_transp_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Raytrace Transparency", "Raytraced transparency settings for the material");
-
- prop = RNA_def_property(srna, "volume", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "vol");
- RNA_def_property_struct_type(prop, "MaterialVolume");
- RNA_def_property_ui_text(prop, "Volume", "Volume settings for the material");
-
- prop = RNA_def_property(srna, "halo", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "MaterialHalo");
- RNA_def_property_pointer_funcs(prop, "rna_Material_halo_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Halo", "Halo settings for the material");
-
- prop = RNA_def_property(srna, "subsurface_scattering", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "MaterialSubsurfaceScattering");
- RNA_def_property_pointer_funcs(prop, "rna_Material_sss_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Subsurface Scattering", "Subsurface scattering settings for the material");
-
- prop = RNA_def_property(srna, "strand", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "MaterialStrand");
- RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Strand", "Strand settings for the material");
-
- prop = RNA_def_property(srna, "physics", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "MaterialPhysics");
- RNA_def_property_pointer_funcs(prop, "rna_Material_physics_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Physics", "Game physics settings");
-
- /* game settings */
- prop = RNA_def_property(srna, "game_settings", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "game");
- RNA_def_property_struct_type(prop, "MaterialGameSettings");
- RNA_def_property_ui_text(prop, "Game Settings", "Game material settings");
-
/* nodetree */
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
@@ -2175,43 +431,12 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material");
RNA_def_property_update(prop, 0, "rna_Material_use_nodes_update");
- prop = RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Material");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_pointer_funcs(prop, "rna_Material_active_node_material_get",
- "rna_Material_active_node_material_set", NULL, NULL);
- RNA_def_property_ui_text(prop, "Material", "Active node material");
- RNA_def_property_update(prop, NC_MATERIAL, NULL);
-
/* common */
rna_def_animdata_common(srna);
- rna_def_mtex_common(brna, srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get",
- "rna_Material_active_texture_set", "rna_Material_active_texture_editable",
- "MaterialTextureSlot", "MaterialTextureSlots", "rna_Material_update", "rna_Material_update");
-
rna_def_texpaint_slots(brna, srna);
- /* only material has this one */
- prop = RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "septex", 1);
- RNA_def_property_array(prop, 18);
- RNA_def_property_ui_text(prop, "Use Textures", "Enable/Disable each texture");
- RNA_def_property_update(prop, 0, "rna_Material_update");
-
rna_def_material_colors(srna);
- rna_def_material_diffuse(srna);
- rna_def_material_specularity(srna);
-
- /* nested structs */
rna_def_material_raymirror(brna);
- rna_def_material_raytra(brna);
- rna_def_material_volume(brna);
- rna_def_material_halo(brna);
- rna_def_material_sss(brna);
- rna_def_material_mtex(brna);
- rna_def_material_strand(brna);
- rna_def_material_physics(brna);
- rna_def_material_gamesettings(brna);
RNA_api_material(srna);
}
@@ -2294,9 +519,9 @@ static void rna_def_tex_slot(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "UV Map", "Name of UV map");
RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Material_update");
- prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "valid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Index", "Index of MTex slot in the material");
+ RNA_def_property_ui_text(prop, "Valid", "Slot has a valid image and UV map");
}
diff --git a/source/blender/makesrna/intern/rna_mesh_utils.h b/source/blender/makesrna/intern/rna_mesh_utils.h
index 05274e13e1e..a85e2095121 100644
--- a/source/blender/makesrna/intern/rna_mesh_utils.h
+++ b/source/blender/makesrna/intern/rna_mesh_utils.h
@@ -85,7 +85,7 @@
} \
else { \
layer = NULL; \
- } \
+ } \
return rna_pointer_inherit_refine(ptr, &RNA_##layer_rna_type, layer); \
} \
\
diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c
index 8589d819360..124f3a2fbe2 100644
--- a/source/blender/makesrna/intern/rna_meta.c
+++ b/source/blender/makesrna/intern/rna_meta.c
@@ -48,6 +48,7 @@
#include "BKE_mball.h"
#include "BKE_main.h"
+#include "BKE_scene.h"
#include "DEG_depsgraph.h"
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 8dd3caa60ef..afb16930c68 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1165,6 +1165,43 @@ static void rna_MeshSequenceCache_object_path_update(Main *bmain, Scene *scene,
rna_Modifier_update(bmain, scene, ptr);
}
+static int rna_ParticleInstanceModifier_particle_system_poll(PointerRNA *ptr, const PointerRNA value)
+{
+ ParticleInstanceModifierData *psmd = ptr->data;
+ ParticleSystem *psys = value.data;
+
+ if (!psmd->ob)
+ return false;
+
+ /* make sure psys is in the object */
+ return BLI_findindex(&psmd->ob->particlesystem, psys) >= 0;
+}
+
+static PointerRNA rna_ParticleInstanceModifier_particle_system_get(PointerRNA *ptr)
+{
+ ParticleInstanceModifierData *psmd = ptr->data;
+ ParticleSystem *psys;
+ PointerRNA rptr;
+
+ if (!psmd->ob)
+ return PointerRNA_NULL;
+
+ psys = BLI_findlink(&psmd->ob->particlesystem, psmd->psys - 1);
+ RNA_pointer_create((ID *)psmd->ob, &RNA_ParticleSystem, psys, &rptr);
+ return rptr;
+}
+
+static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr, const PointerRNA value)
+{
+ ParticleInstanceModifierData *psmd = ptr->data;
+
+ if (!psmd->ob)
+ return;
+
+ psmd->psys = BLI_findindex(&psmd->ob->particlesystem, value.data) + 1;
+ CLAMP_MIN(psmd->psys, 1);
+}
+
static void rna_Fur_guide_curves_clear(FurModifierData *fmd)
{
for (FurModifierGuideCurve* curve = fmd->guide_curves.first; curve; curve = curve->next)
@@ -2302,11 +2339,6 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna)
"rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Projectors", "");
- prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
- RNA_def_property_ui_text(prop, "Image", "");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
prop = RNA_def_property(srna, "aspect_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "aspectx");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
@@ -2707,6 +2739,12 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static EnumPropertyItem particleinstance_space[] = {
+ {eParticleInstanceSpace_Local, "LOCAL", 0, "Local", "Use offset from the particle object in the instance object"},
+ {eParticleInstanceSpace_World, "WORLD", 0, "World", "Use world space offset in the instance object"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "ParticleInstanceModifier", "Modifier");
RNA_def_struct_ui_text(srna, "ParticleInstance Modifier", "Particle system instancing modifier");
RNA_def_struct_sdna(srna, "ParticleInstanceModifierData");
@@ -2721,16 +2759,30 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna)
prop = RNA_def_property(srna, "particle_system_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "psys");
- RNA_def_property_range(prop, 1, 10);
+ RNA_def_property_range(prop, 1, SHRT_MAX);
RNA_def_property_ui_text(prop, "Particle System Number", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ParticleSystem");
+ RNA_def_property_pointer_funcs(prop, "rna_ParticleInstanceModifier_particle_system_get", "rna_ParticleInstanceModifier_particle_system_set",
+ NULL, "rna_ParticleInstanceModifier_particle_system_poll");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Particle System", "");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "axis");
RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
RNA_def_property_ui_text(prop, "Axis", "Pole axis for rotation");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
+
+ prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "space");
+ RNA_def_property_enum_items(prop, particleinstance_space);
+ RNA_def_property_ui_text(prop, "Space", "Space to use for copying mesh data");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Parents);
RNA_def_property_ui_text(prop, "Normal", "Create instances from normal particles");
@@ -2782,6 +2834,40 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "Random Position", "Randomize position along path");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "rotation");
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_ui_text(prop, "Rotation", "Rotation around path");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "random_rotation", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "random_rotation");
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_ui_text(prop, "Random Rotation", "Randomize rotation around path");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "particle_amount", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_ui_text(prop, "Particle Amount", "Amount of particles to use for instancing");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "particle_offset", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_ui_text(prop, "Particle Offset", "Relative offset of particles to use for instancing, to avoid overlap of multiple instances");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "index_layer_name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "index_layer_name");
+ RNA_def_property_ui_text(prop, "Index Layer Name", "Custom data layer name for the index");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "value_layer_name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "value_layer_name");
+ RNA_def_property_ui_text(prop, "Value Layer Name", "Custom data layer name for the randomized value");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
static void rna_def_modifier_explode(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 012545cb5d2..79a1ce73071 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -2339,14 +2339,6 @@ static void rna_NodeSocketStandard_value_update(struct bContext *C, PointerRNA *
/* fall back to searching node in the tree */
nodeFindNode(ntree, sock, &node, NULL);
}
-
- if (node) {
- nodeSynchronizeID(node, true);
-
- /* extra update for sockets that get synced to material */
- if (node->id && ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT))
- WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, node->id);
- }
}
@@ -2502,17 +2494,6 @@ static void rna_Node_tex_image_update(Main *bmain, Scene *UNUSED(scene), Pointer
WM_main_add_notifier(NC_IMAGE, NULL);
}
-static void rna_Node_material_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
-{
- bNodeTree *ntree = (bNodeTree *)ptr->id.data;
- bNode *node = (bNode *)ptr->data;
-
- if (node->id)
- nodeSetActive(ntree, node);
-
- ED_node_tag_update_nodetree(bmain, ntree, node);
-}
-
static void rna_NodeGroup_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
bNodeTree *ntree = (bNodeTree *)ptr->id.data;
@@ -3035,7 +3016,7 @@ static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *p
{
bNodeTree *ntree = (bNodeTree *)ptr->id.data;
bNode *node = (bNode *)ptr->data;
- RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
if (engine_type && engine_type->update_script_node) {
/* auto update node */
@@ -3144,11 +3125,6 @@ void rna_ShaderNodePointDensity_density_cache(bNode *self,
return;
}
- EvaluationContext eval_ctx;
- DEG_evaluation_context_init_from_depsgraph(&eval_ctx,
- depsgraph,
- DEG_get_mode(depsgraph));
-
/* Make sure there's no cached data. */
BKE_texture_pointdensity_free_data(pd);
RE_point_density_free(pd);
@@ -3177,8 +3153,7 @@ void rna_ShaderNodePointDensity_density_cache(bNode *self,
shader_point_density->cached_resolution = shader_point_density->resolution;
/* Single-threaded sampling of the voxel domain. */
- RE_point_density_cache(&eval_ctx,
- pd);
+ RE_point_density_cache(depsgraph, pd);
}
void rna_ShaderNodePointDensity_density_calc(bNode *self,
@@ -3195,11 +3170,6 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self,
return;
}
- EvaluationContext eval_ctx;
- DEG_evaluation_context_init_from_depsgraph(&eval_ctx,
- depsgraph,
- DEG_get_mode(depsgraph));
-
/* TODO(sergey): Will likely overflow, but how to pass size_t via RNA? */
*length = 4 * resolution * resolution * resolution;
@@ -3208,10 +3178,7 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self,
}
/* Single-threaded sampling of the voxel domain. */
- RE_point_density_sample(&eval_ctx,
- pd,
- resolution,
- *values);
+ RE_point_density_sample(depsgraph, pd, resolution, *values);
/* We're done, time to clean up. */
BKE_texture_pointdensity_free_data(pd);
@@ -3233,12 +3200,7 @@ void rna_ShaderNodePointDensity_density_minmax(bNode *self,
return;
}
- EvaluationContext eval_ctx;
- DEG_evaluation_context_init_from_depsgraph(&eval_ctx,
- depsgraph,
- DEG_get_mode(depsgraph));
-
- RE_point_density_minmax(&eval_ctx, pd, r_min, r_max);
+ RE_point_density_minmax(depsgraph, pd, r_min, r_max);
}
#else
@@ -3567,33 +3529,6 @@ static void def_sh_output_linestyle(StructRNA *srna)
def_mix_rgb(srna);
}
-static void def_sh_material(StructRNA *srna)
-{
- PropertyRNA *prop;
-
- prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "id");
- RNA_def_property_struct_type(prop, "Material");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Material", "");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_material_update");
-
- prop = RNA_def_property(srna, "use_diffuse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_DIFF);
- RNA_def_property_ui_text(prop, "Diffuse", "Material Node outputs Diffuse");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
- prop = RNA_def_property(srna, "use_specular", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_SPEC);
- RNA_def_property_ui_text(prop, "Specular", "Material Node outputs Specular");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
- prop = RNA_def_property(srna, "invert_normal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_NEG);
- RNA_def_property_ui_text(prop, "Invert Normal", "Material Node uses inverted normal");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-}
-
static void def_sh_mapping(StructRNA *srna)
{
static const EnumPropertyItem prop_vect_type_items[] = {
@@ -3656,36 +3591,6 @@ static void def_sh_mapping(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
}
-static void def_sh_geometry(StructRNA *srna)
-{
- PropertyRNA *prop;
-
- RNA_def_struct_sdna_from(srna, "NodeGeometry", "storage");
-
- prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "uvname");
- RNA_def_property_ui_text(prop, "UV Map", "");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
- prop = RNA_def_property(srna, "color_layer", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "colname");
- RNA_def_property_ui_text(prop, "Vertex Color Layer", "");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-}
-
-static void def_sh_lamp(StructRNA *srna)
-{
- PropertyRNA *prop;
-
- prop = RNA_def_property(srna, "lamp_object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "id");
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
- RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Lamp_object_poll");
- RNA_def_property_ui_text(prop, "Lamp Object", "");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-}
-
static void def_sh_attribute(StructRNA *srna)
{
PropertyRNA *prop;
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 43001d6bd66..79c23e2a9c4 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -29,13 +29,11 @@
#include "DNA_action_types.h"
#include "DNA_customdata_types.h"
-#include "DNA_controller_types.h"
#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
-#include "DNA_property_types.h"
#include "DNA_scene_types.h"
#include "DNA_meta_types.h"
#include "DNA_workspace_types.h"
@@ -121,18 +119,6 @@ static EnumPropertyItem dupli_items_nogroup[] = {
#undef DUPLI_ITEMS_SHARED
#undef DUPLI_ITEM_GROUP
-static const EnumPropertyItem collision_bounds_items[] = {
- {OB_BOUND_BOX, "BOX", ICON_MESH_CUBE, "Box", ""},
- {OB_BOUND_SPHERE, "SPHERE", ICON_MESH_UVSPHERE, "Sphere", ""},
- {OB_BOUND_CYLINDER, "CYLINDER", ICON_MESH_CYLINDER, "Cylinder", ""},
- {OB_BOUND_CONE, "CONE", ICON_MESH_CONE, "Cone", ""},
- {OB_BOUND_CONVEX_HULL, "CONVEX_HULL", ICON_MESH_ICOSPHERE, "Convex Hull", ""},
- {OB_BOUND_TRIANGLE_MESH, "TRIANGLE_MESH", ICON_MESH_MONKEY, "Triangle Mesh", ""},
- {OB_BOUND_CAPSULE, "CAPSULE", ICON_MESH_CAPSULE, "Capsule", ""},
- /*{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, */
- {0, NULL, 0, NULL, NULL}
-};
-
const EnumPropertyItem rna_enum_metaelem_type_items[] = {
{MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
{MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
@@ -193,7 +179,6 @@ const EnumPropertyItem rna_enum_object_axis_items[] = {
#include "DNA_node_types.h"
#include "BKE_armature.h"
-#include "BKE_bullet.h"
#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_curve.h"
@@ -471,32 +456,6 @@ static void rna_Object_empty_draw_type_set(PointerRNA *ptr, int value)
BKE_object_empty_draw_type_set(ob, value);
}
-static const EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *UNUSED(C), PointerRNA *ptr,
- PropertyRNA *UNUSED(prop), bool *r_free)
-{
- Object *ob = (Object *)ptr->data;
- EnumPropertyItem *item = NULL;
- int totitem = 0;
-
- if (ob->body_type != OB_BODY_TYPE_CHARACTER) {
- RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_TRIANGLE_MESH);
- }
- RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONVEX_HULL);
-
- if (ob->body_type != OB_BODY_TYPE_SOFT) {
- RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONE);
- RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CYLINDER);
- RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_SPHERE);
- RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_BOX);
- RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CAPSULE);
- }
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
{
Object *ob = (Object *)ptr->data;
@@ -1049,122 +1008,6 @@ static char *rna_MaterialSlot_path(PointerRNA *ptr)
*
* logic from check_body_type()
* */
-static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
-
- /* determine the body_type setting based on flags */
- if (!(ob->gameflag & OB_COLLISION)) {
- if (ob->gameflag & OB_OCCLUDER) {
- ob->body_type = OB_BODY_TYPE_OCCLUDER;
- }
- else if (ob->gameflag & OB_NAVMESH) {
- ob->body_type = OB_BODY_TYPE_NAVMESH;
- }
- else {
- ob->body_type = OB_BODY_TYPE_NO_COLLISION;
- }
- }
- else if (ob->gameflag & OB_CHARACTER) {
- ob->body_type = OB_BODY_TYPE_CHARACTER;
- }
- else if (ob->gameflag & OB_SENSOR) {
- ob->body_type = OB_BODY_TYPE_SENSOR;
- }
- else if (!(ob->gameflag & OB_DYNAMIC)) {
- ob->body_type = OB_BODY_TYPE_STATIC;
- }
- else if (!(ob->gameflag & (OB_RIGID_BODY | OB_SOFT_BODY))) {
- ob->body_type = OB_BODY_TYPE_DYNAMIC;
- }
- else if (ob->gameflag & OB_RIGID_BODY) {
- ob->body_type = OB_BODY_TYPE_RIGID;
- }
- else {
- ob->body_type = OB_BODY_TYPE_SOFT;
- /* create the structure here because we display soft body buttons in the main panel */
- if (!ob->bsoft)
- ob->bsoft = bsbNew();
- }
-
- return ob->body_type;
-}
-
-static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
-{
- Object *ob = (Object *)ptr->id.data;
- const int gameflag_prev = ob->gameflag;
- ob->body_type = value;
-
- switch (ob->body_type) {
- case OB_BODY_TYPE_SENSOR:
- ob->gameflag |= OB_SENSOR | OB_COLLISION;
- ob->gameflag &= ~(OB_OCCLUDER | OB_CHARACTER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
- OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
- break;
- case OB_BODY_TYPE_OCCLUDER:
- ob->gameflag |= OB_OCCLUDER;
- ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_NAVMESH);
- break;
- case OB_BODY_TYPE_NAVMESH:
- ob->gameflag |= OB_NAVMESH;
- ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_OCCLUDER);
-
- if (ob->type == OB_MESH) {
- /* could be moved into mesh UI but for now ensure mesh data layer */
- BKE_mesh_ensure_navmesh(ob->data);
- }
-
- break;
- case OB_BODY_TYPE_NO_COLLISION:
- ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH);
- break;
- case OB_BODY_TYPE_CHARACTER:
- ob->gameflag |= OB_COLLISION | OB_CHARACTER;
- ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
- OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
- /* When we switch to character physics and the collision bounds is set to triangle mesh
- * we have to change collision bounds because triangle mesh is not supported by Characters */
- if ((ob->gameflag & OB_BOUNDS) && ob->collision_boundtype == OB_BOUND_TRIANGLE_MESH) {
- ob->boundtype = ob->collision_boundtype = OB_BOUND_BOX;
- }
- break;
- case OB_BODY_TYPE_STATIC:
- ob->gameflag |= OB_COLLISION;
- ob->gameflag &= ~(OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
- break;
- case OB_BODY_TYPE_DYNAMIC:
- ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_ACTOR;
- ob->gameflag &= ~(OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
- break;
- case OB_BODY_TYPE_RIGID:
- ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_RIGID_BODY | OB_ACTOR;
- ob->gameflag &= ~(OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
- break;
- default:
- case OB_BODY_TYPE_SOFT:
- ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_SOFT_BODY | OB_ACTOR;
- ob->gameflag &= ~(OB_RIGID_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
-
- /* assume triangle mesh, if no bounds chosen for soft body */
- if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype < OB_BOUND_TRIANGLE_MESH)) {
- ob->boundtype = OB_BOUND_TRIANGLE_MESH;
- }
- /* create a BulletSoftBody structure if not already existing */
- if (!ob->bsoft)
- ob->bsoft = bsbNew();
- break;
- }
-
- if ((gameflag_prev & OB_NAVMESH) != (ob->gameflag & OB_NAVMESH)) {
- if (ob->type == OB_MESH) {
- /* this is needed to refresh the derived meshes draw func */
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
- }
- }
-
- WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
-}
static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
{
@@ -1173,117 +1016,6 @@ static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys);
}
-static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr)
-{
- return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data);
-}
-
-static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values)
-{
- Object *ob = (Object *)ptr->data;
- int i;
- int all_states = (ob->scaflag & OB_ALLSTATE) ? 1 : 0;
-
- memset(values, 0, sizeof(int) * OB_MAX_STATES);
- for (i = 0; i < OB_MAX_STATES; i++) {
- values[i] = (ob->state & (1 << i)) ? 1 : 0 | all_states;
- }
-}
-
-static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
-{
- Object *ob = (Object *)ptr->data;
- int i, tot = 0;
-
- /* ensure we always have some state selected */
- for (i = 0; i < OB_MAX_STATES; i++)
- if (values[i])
- tot++;
-
- if (tot == 0)
- return;
-
- for (i = 0; i < OB_MAX_STATES; i++) {
- if (values[i]) ob->state |= (1 << i);
- else ob->state &= ~(1 << i);
- }
-}
-
-static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values)
-{
- Object *ob = (Object *)ptr->data;
- bController *cont;
-
- memset(values, 0, sizeof(int) * OB_MAX_STATES);
- for (cont = ob->controllers.first; cont; cont = cont->next) {
- int i;
-
- for (i = 0; i < OB_MAX_STATES; i++) {
- if (cont->state_mask & (1 << i))
- values[i] = 1;
- }
- }
-}
-
-static void rna_GameObjectSettings_col_group_get(PointerRNA *ptr, int *values)
-{
- Object *ob = (Object *)ptr->data;
- int i;
-
- for (i = 0; i < OB_MAX_COL_MASKS; i++) {
- values[i] = (ob->col_group & (1 << i)) != 0;
- }
-}
-
-static void rna_GameObjectSettings_col_group_set(PointerRNA *ptr, const int *values)
-{
- Object *ob = (Object *)ptr->data;
- int i, tot = 0;
-
- /* ensure we always have some group selected */
- for (i = 0; i < OB_MAX_COL_MASKS; i++)
- if (values[i])
- tot++;
-
- if (tot == 0)
- return;
-
- for (i = 0; i < OB_MAX_COL_MASKS; i++) {
- if (values[i]) ob->col_group |= (1 << i);
- else ob->col_group &= ~(1 << i);
- }
-}
-
-static void rna_GameObjectSettings_col_mask_get(PointerRNA *ptr, int *values)
-{
- Object *ob = (Object *)ptr->data;
- int i;
-
- for (i = 0; i < OB_MAX_COL_MASKS; i++) {
- values[i] = (ob->col_mask & (1 << i)) != 0;
- }
-}
-
-static void rna_GameObjectSettings_col_mask_set(PointerRNA *ptr, const int *values)
-{
- Object *ob = (Object *)ptr->data;
- int i, tot = 0;
-
- /* ensure we always have some mask selected */
- for (i = 0; i < OB_MAX_COL_MASKS; i++)
- if (values[i])
- tot++;
-
- if (tot == 0)
- return;
-
- for (i = 0; i < OB_MAX_COL_MASKS; i++) {
- if (values[i]) ob->col_mask |= (1 << i);
- else ob->col_mask &= ~(1 << i);
- }
-}
-
-
static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max,
int *UNUSED(softmin), int *UNUSED(softmax))
{
@@ -1619,16 +1351,6 @@ int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
return (ss && ss->bm);
}
-static void rna_Object_lod_distance_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
-
-#ifdef WITH_GAMEENGINE
- BKE_object_lod_sort(ob);
-#else
- (void)ob;
-#endif
-}
#else
static void rna_def_vertex_group(BlenderRNA *brna)
@@ -1779,313 +1501,6 @@ static void rna_def_material_slot(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_MaterialSlot_path");
}
-static void rna_def_object_game_settings(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem body_type_items[] = {
- {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", "Disable collision for this object"},
- {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", "Stationary object"},
- {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", "Linear physics"},
- {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", "Linear and angular physics"},
- {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", "Soft body"},
- {OB_BODY_TYPE_OCCLUDER, "OCCLUDER", 0, "Occluder", "Occluder for optimizing scene rendering"},
- {OB_BODY_TYPE_SENSOR, "SENSOR", 0, "Sensor",
- "Collision Sensor, detects static and dynamic objects but not the other "
- "collision sensor objects"},
- {OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "Navigation Mesh", "Navigation mesh"},
- {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character",
- "Simple kinematic physics appropriate for game characters"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "GameObjectSettings", NULL);
- RNA_def_struct_sdna(srna, "Object");
- RNA_def_struct_nested(brna, srna, "Object");
- RNA_def_struct_ui_text(srna, "Game Object Settings", "Game engine related settings for the object");
- RNA_def_struct_ui_icon(srna, ICON_GAME);
-
- /* logic */
-
- prop = RNA_def_property(srna, "sensors", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_type(prop, "Sensor");
- RNA_def_property_ui_text(prop, "Sensors", "Game engine sensor to detect events");
-
- prop = RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_type(prop, "Controller");
- RNA_def_property_ui_text(prop, "Controllers",
- "Game engine controllers to process events, connecting sensors to actuators");
-
- prop = RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_type(prop, "Actuator");
- RNA_def_property_ui_text(prop, "Actuators", "Game engine actuators to act on events");
-
- prop = RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "prop", NULL);
- RNA_def_property_struct_type(prop, "GameProperty"); /* rna_property.c */
- RNA_def_property_ui_text(prop, "Properties", "Game engine properties");
-
- prop = RNA_def_property(srna, "show_sensors", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSENS);
- RNA_def_property_ui_text(prop, "Show Sensors", "Shows sensors for this object in the user interface");
-
- prop = RNA_def_property(srna, "show_controllers", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWCONT);
- RNA_def_property_ui_text(prop, "Show Controllers", "Shows controllers for this object in the user interface");
-
- prop = RNA_def_property(srna, "show_actuators", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWACT);
- RNA_def_property_ui_text(prop, "Show Actuators", "Shows actuators for this object in the user interface");
-
- /* physics */
-
- prop = RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "body_type");
- RNA_def_property_enum_items(prop, body_type_items);
- RNA_def_property_enum_default(prop, OB_BODY_TYPE_STATIC);
- RNA_def_property_enum_funcs(prop, "rna_GameObjectSettings_physics_type_get",
- "rna_GameObjectSettings_physics_type_set", NULL);
- RNA_def_property_ui_text(prop, "Physics Type", "Select the type of physical representation");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_record_animation", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_RECORD_ANIMATION);
- RNA_def_property_ui_text(prop, "Record Animation", "Record animation objects without physics");
-
- prop = RNA_def_property(srna, "use_actor", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ACTOR);
- RNA_def_property_ui_text(prop, "Actor", "Object is detected by the Near and Radar sensor");
-
- prop = RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST);
- RNA_def_property_ui_text(prop, "Ghost", "Object does not react to collisions, like a ghost");
-
- prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.01, 10000.0);
- RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(prop, "Mass", "Mass of the object");
-
- prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
- RNA_def_property_float_sdna(prop, NULL, "inertia");
- RNA_def_property_range(prop, 0.01f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.01f, 10.0f, 1, 3);
- RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics");
- RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
- prop = RNA_def_property(srna, "use_sleep", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_COLLISION_RESPONSE);
- RNA_def_property_ui_text(prop, "No Sleeping", "Disable auto (de)activation in physics simulation");
-
- prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "damping");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_float_default(prop, 0.04f);
- RNA_def_property_ui_text(prop, "Damping", "General movement damping");
-
- prop = RNA_def_property(srna, "rotation_damping", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "rdamping");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_float_default(prop, 0.1f);
- RNA_def_property_ui_text(prop, "Rotation Damping", "General rotation damping");
-
- prop = RNA_def_property(srna, "velocity_min", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "min_vel");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_ui_text(prop, "Velocity Min", "Clamp velocity to this minimum speed (except when totally still), "
- "in distance per second");
-
- prop = RNA_def_property(srna, "velocity_max", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "max_vel");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed, "
- "in distance per second");
-
- prop = RNA_def_property(srna, "angular_velocity_min", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "min_angvel");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_ui_text(prop, "Angular Velocity Min",
- "Clamp angular velocity to this minimum speed (except when totally still), "
- "in angle per second");
-
- prop = RNA_def_property(srna, "angular_velocity_max", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "max_angvel");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_ui_text(prop, "Angular Velocity Max", "Clamp angular velocity to this maximum speed, "
- "in angle per second");
-
- /* Character physics */
- prop = RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "step_height");
- RNA_def_property_range(prop, 0.01, 1.0);
- RNA_def_property_float_default(prop, 0.15f);
- RNA_def_property_ui_text(prop, "Step Height", "Maximum height of steps the character can run over");
-
- prop = RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "jump_speed");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_float_default(prop, 10.0f);
- RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping");
-
- prop = RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fall_speed");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_float_default(prop, 55.0f);
- RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall");
-
- prop = RNA_def_property(srna, "jump_max", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "max_jumps");
- RNA_def_property_range(prop, 1, CHAR_MAX);
- RNA_def_property_ui_range(prop, 1, 10, 1, 1);
- RNA_def_property_int_default(prop, 1);
- RNA_def_property_ui_text(prop, "Max Jumps",
- "The maximum number of jumps the character can make before it hits the ground");
-
- /* Collision Masks */
- prop = RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER);
- RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1);
- RNA_def_property_array(prop, OB_MAX_COL_MASKS);
- RNA_def_property_ui_text(prop, "Collision Group", "The collision group of the object");
- RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_group_get", "rna_GameObjectSettings_col_group_set");
-
- prop = RNA_def_property(srna, "collision_mask", PROP_BOOLEAN, PROP_LAYER_MEMBER);
- RNA_def_property_boolean_sdna(prop, NULL, "col_mask", 1);
- RNA_def_property_array(prop, OB_MAX_COL_MASKS);
- RNA_def_property_ui_text(prop, "Collision Mask", "The groups this object can collide with");
- RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_mask_get", "rna_GameObjectSettings_col_mask_set");
-
- /* lock position */
- prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_AXIS);
- RNA_def_property_ui_text(prop, "Lock X Axis", "Disable simulation of linear motion along the X axis");
-
- prop = RNA_def_property(srna, "lock_location_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_AXIS);
- RNA_def_property_ui_text(prop, "Lock Y Axis", "Disable simulation of linear motion along the Y axis");
-
- prop = RNA_def_property(srna, "lock_location_z", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_AXIS);
- RNA_def_property_ui_text(prop, "Lock Z Axis", "Disable simulation of linear motion along the Z axis");
-
-
- /* lock rotation */
- prop = RNA_def_property(srna, "lock_rotation_x", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_ROT_AXIS);
- RNA_def_property_ui_text(prop, "Lock X Rotation Axis", "Disable simulation of angular motion along the X axis");
-
- prop = RNA_def_property(srna, "lock_rotation_y", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_ROT_AXIS);
- RNA_def_property_ui_text(prop, "Lock Y Rotation Axis", "Disable simulation of angular motion along the Y axis");
-
- prop = RNA_def_property(srna, "lock_rotation_z", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_ROT_AXIS);
- RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
-
- /* is this used anywhere ? */
- prop = RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflag2", OB_NEVER_DO_ACTIVITY_CULLING);
- RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
-
-
- prop = RNA_def_property(srna, "use_material_physics_fh", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH);
- RNA_def_property_ui_text(prop, "Use Material Force Field", "React to force field physics settings in materials");
-
- prop = RNA_def_property(srna, "use_rotate_from_normal", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ROT_FH);
- RNA_def_property_ui_text(prop, "Rotate From Normal",
- "Use face normal to rotate object, so that it points away from the surface");
-
- prop = RNA_def_property(srna, "form_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "formfactor");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_float_default(prop, 0.4f);
- RNA_def_property_ui_text(prop, "Form Factor", "Form factor scales the inertia tensor");
-
- prop = RNA_def_property(srna, "use_anisotropic_friction", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ANISOTROPIC_FRICTION);
- RNA_def_property_ui_text(prop, "Anisotropic Friction", "Enable anisotropic friction");
-
- prop = RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "anisotropicFriction");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_ui_text(prop, "Friction Coefficients",
- "Relative friction coefficients in the in the X, Y and Z directions, "
- "when anisotropic friction is enabled");
-
- prop = RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS);
- RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default");
- RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
- prop = RNA_def_property(srna, "collision_bounds_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "collision_boundtype");
- RNA_def_property_enum_items(prop, collision_bounds_items);
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf");
- RNA_def_property_ui_text(prop, "Collision Shape", "Select the collision shape that better fits the object");
- RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
-
- prop = RNA_def_property(srna, "use_collision_compound", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD);
- RNA_def_property_ui_text(prop, "Collision Compound", "Add children to form a compound collision object");
-
- prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
- RNA_def_property_float_sdna(prop, NULL, "margin");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_float_default(prop, 0.04f);
- RNA_def_property_ui_text(prop, "Collision Margin",
- "Extra margin around object for collision detection, small amount required "
- "for stability");
-
- prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "bsoft");
- RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for Bullet soft body simulation");
-
- prop = RNA_def_property(srna, "use_obstacle_create", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_HASOBSTACLE);
- RNA_def_property_ui_text(prop, "Create obstacle", "Create representation for obstacle simulation");
-
- prop = RNA_def_property(srna, "obstacle_radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
- RNA_def_property_float_sdna(prop, NULL, "obstacleRad");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(prop, "Obstacle Radius", "Radius of object representation in obstacle simulation");
-
- /* state */
-
- prop = RNA_def_property(srna, "states_visible", PROP_BOOLEAN, PROP_LAYER_MEMBER);
- RNA_def_property_boolean_sdna(prop, NULL, "state", 1);
- RNA_def_property_array(prop, OB_MAX_STATES);
- RNA_def_property_ui_text(prop, "State", "State determining which controllers are displayed");
- RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_state_get", "rna_GameObjectSettings_state_set");
-
- prop = RNA_def_property(srna, "used_states", PROP_BOOLEAN, PROP_LAYER_MEMBER);
- RNA_def_property_array(prop, OB_MAX_STATES);
- RNA_def_property_ui_text(prop, "Used State", "States which are being used by controllers");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_used_state_get", NULL);
-
- prop = RNA_def_property(srna, "states_initial", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "init_state", 1);
- RNA_def_property_array(prop, OB_MAX_STATES);
- RNA_def_property_ui_text(prop, "Initial State", "Initial state when the game starts");
-
- prop = RNA_def_property(srna, "show_debug_state", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_DEBUGSTATE);
- RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine");
- RNA_def_property_ui_icon(prop, ICON_INFO, 0);
-
- prop = RNA_def_property(srna, "use_all_states", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_ALLSTATE);
- RNA_def_property_ui_text(prop, "All", "Set all state bits");
-
- prop = RNA_def_property(srna, "show_state_panel", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSTATE);
- RNA_def_property_ui_text(prop, "States", "Show state panel");
- RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
-}
-
static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
@@ -2314,54 +1729,6 @@ static void rna_def_object_face_maps(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Delete all vertex groups from object");
}
-static void rna_def_object_lodlevel(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "LodLevel", NULL);
- RNA_def_struct_sdna(srna, "LodLevel");
-
- prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "distance");
- RNA_def_property_range(prop, 0.0, FLT_MAX);
- RNA_def_property_ui_text(prop, "Distance", "Distance to begin using this level of detail");
- RNA_def_property_update(prop, NC_OBJECT | ND_LOD, "rna_Object_lod_distance_update");
-
- prop = RNA_def_property(srna, "object_hysteresis_percentage", PROP_INT, PROP_PERCENTAGE);
- RNA_def_property_int_sdna(prop, NULL, "obhysteresis");
- RNA_def_property_range(prop, 0, 100);
- RNA_def_property_ui_range(prop, 0, 100, 10, 1);
- RNA_def_property_ui_text(prop, "Hysteresis %",
- "Minimum distance change required to transition to the previous level of detail");
- RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL);
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "source");
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Object", "Object to use for this level of detail");
- RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL);
-
- prop = RNA_def_property(srna, "use_mesh", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", OB_LOD_USE_MESH);
- RNA_def_property_ui_text(prop, "Use Mesh", "Use the mesh from this object at this level of detail");
- RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0);
- RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL);
-
- prop = RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", OB_LOD_USE_MAT);
- RNA_def_property_ui_text(prop, "Use Material", "Use the material from this object at this level of detail");
- RNA_def_property_ui_icon(prop, ICON_MATERIAL, 0);
- RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL);
-
- prop = RNA_def_property(srna, "use_object_hysteresis", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", OB_LOD_USE_HYST);
- RNA_def_property_ui_text(prop, "Hysteresis Override", "Override LoD Hysteresis scene setting for this LoD level");
- RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL);
-}
-
-
static void rna_def_object(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2712,13 +2079,6 @@ static void rna_def_object(BlenderRNA *brna)
/* RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove"); */
rna_def_object_constraints(brna, prop);
- /* game engine */
- prop = RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "GameObjectSettings");
- RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Game Settings", "Game engine related settings for the object");
-
/* vertex groups */
prop = RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "defbase", NULL);
@@ -3042,13 +2402,6 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", NULL);
- /* Levels of Detail */
- prop = RNA_def_property(srna, "lod_levels", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "lodlevels", NULL);
- RNA_def_property_struct_type(prop, "LodLevel");
- RNA_def_property_ui_text(prop, "Level of Detail Levels", "A collection of detail levels to automatically switch between");
- RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL);
-
/* Base Settings */
prop = RNA_def_property(srna, "is_from_duplicator", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_FROMDUPLI);
@@ -3126,13 +2479,11 @@ void RNA_def_object(BlenderRNA *brna)
rna_def_object(brna);
RNA_define_animate_sdna(false);
- rna_def_object_game_settings(brna);
rna_def_vertex_group(brna);
rna_def_face_map(brna);
rna_def_material_slot(brna);
rna_def_dupli_object(brna);
RNA_define_animate_sdna(true);
- rna_def_object_lodlevel(brna);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 7d062d41e4f..3a61accfad3 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -1459,78 +1459,6 @@ static void rna_def_field(BlenderRNA *brna)
/* falloff_power, use_max_distance, maximum_distance */
}
-static void rna_def_game_softbody(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "GameSoftBodySettings", NULL);
- RNA_def_struct_sdna(srna, "BulletSoftBody");
- RNA_def_struct_ui_text(srna, "Game Soft Body Settings",
- "Soft body simulation settings for an object in the game engine");
-
- /* Floats */
-
- prop = RNA_def_property(srna, "linear_stiffness", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "linStiff");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Linear Stiffness", "Linear stiffness of the soft body links");
-
- prop = RNA_def_property(srna, "dynamic_friction", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "kDF");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Friction", "Dynamic Friction");
-
- prop = RNA_def_property(srna, "shape_threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "kMT");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Threshold", "Shape matching threshold");
-
- prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "margin");
- RNA_def_property_range(prop, 0.01f, 1.0f);
- RNA_def_property_ui_text(prop, "Margin",
- "Collision margin for soft body. Small value makes the algorithm unstable");
-
- prop = RNA_def_property(srna, "weld_threshold", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "welding");
- RNA_def_property_range(prop, 0.0f, 0.01f);
- RNA_def_property_ui_text(prop, "Welding",
- "Welding threshold: distance between nearby vertices to be considered equal "
- "=> set to 0.0 to disable welding test and speed up scene loading "
- "(ok if the mesh has no duplicates)");
-
- /* Integers */
-
- prop = RNA_def_property(srna, "location_iterations", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "piterations");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "Position Iterations", "Position solver iterations");
-
- prop = RNA_def_property(srna, "cluster_iterations", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "numclusteriterations");
- RNA_def_property_range(prop, 1, 128);
- RNA_def_property_ui_text(prop, "Cluster Iterations", "Number of cluster iterations");
-
- /* Booleans */
-
- prop = RNA_def_property(srna, "use_shape_match", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_BSB_SHAPE_MATCHING);
- RNA_def_property_ui_text(prop, "Shape Match", "Enable soft body shape matching goal");
-
- prop = RNA_def_property(srna, "use_bending_constraints", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_BSB_BENDING_CONSTRAINTS);
- RNA_def_property_ui_text(prop, "Bending Const", "Enable bending constraints");
-
- prop = RNA_def_property(srna, "use_cluster_rigid_to_softbody", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "collisionflags", OB_BSB_COL_CL_RS);
- RNA_def_property_ui_text(prop, "Rigid to Soft Body", "Enable cluster collision between soft and rigid body");
-
- prop = RNA_def_property(srna, "use_cluster_soft_to_softbody", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "collisionflags", OB_BSB_COL_CL_SS);
- RNA_def_property_ui_text(prop, "Soft to Soft Body", "Enable cluster collision between soft and soft body");
-}
-
static void rna_def_softbody(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1851,7 +1779,6 @@ void RNA_def_object_force(BlenderRNA *brna)
rna_def_collision(brna);
rna_def_effector_weight(brna);
rna_def_field(brna);
- rna_def_game_softbody(brna);
rna_def_softbody(brna);
}
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index f50be85c446..84f3738d15d 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -908,7 +908,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
prop = RNA_def_property(srna, "bbone_custom_handle_start", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "bbone_prev");
RNA_def_property_struct_type(prop, "PoseBone");
- RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_PTR_NO_OWNERSHIP);
RNA_def_property_ui_text(prop, "B-Bone Start Handle",
"Bone that serves as the start handle for the B-Bone curve");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
@@ -924,7 +924,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
prop = RNA_def_property(srna, "bbone_custom_handle_end", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "bbone_next");
RNA_def_property_struct_type(prop, "PoseBone");
- RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_PTR_NO_OWNERSHIP);
RNA_def_property_ui_text(prop, "B-Bone End Handle",
"Bone that serves as the end handle for the B-Bone curve");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c
deleted file mode 100644
index 7ee792b5d1f..00000000000
--- a/source/blender/makesrna/intern/rna_property.c
+++ /dev/null
@@ -1,203 +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.
- *
- * Contributor(s): Blender Foundation (2008).
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/makesrna/intern/rna_property.c
- * \ingroup RNA
- */
-
-
-#include <stdlib.h>
-
-#include "DNA_property_types.h"
-#include "DNA_object_types.h"
-
-#include "BLI_path_util.h"
-#include "BLI_string_utils.h"
-
-#include "BLT_translation.h"
-
-#include "RNA_define.h"
-#include "RNA_enum_types.h"
-
-#include "rna_internal.h"
-
-
-#include "WM_types.h"
-
-const EnumPropertyItem rna_enum_gameproperty_type_items[] = {
- {GPROP_BOOL, "BOOL", 0, "Boolean", "Boolean Property"},
- {GPROP_INT, "INT", 0, "Integer", "Integer Property"},
- {GPROP_FLOAT, "FLOAT", 0, "Float", "Floating-Point Property"},
- {GPROP_STRING, "STRING", 0, "String", "String Property"},
- {GPROP_TIME, "TIMER", 0, "Timer", "Timer Property"},
- {0, NULL, 0, NULL, NULL}
-};
-
-
-#ifdef RNA_RUNTIME
-
-#include "BKE_property.h"
-
-static StructRNA *rna_GameProperty_refine(struct PointerRNA *ptr)
-{
- bProperty *property = (bProperty *)ptr->data;
-
- switch (property->type) {
- case GPROP_BOOL:
- return &RNA_GameBooleanProperty;
- case GPROP_INT:
- return &RNA_GameIntProperty;
- case GPROP_FLOAT:
- return &RNA_GameFloatProperty;
- case GPROP_STRING:
- return &RNA_GameStringProperty;
- case GPROP_TIME:
- return &RNA_GameTimerProperty;
- default:
- return &RNA_GameProperty;
- }
-}
-
-/* for both float and timer */
-static float rna_GameFloatProperty_value_get(PointerRNA *ptr)
-{
- bProperty *prop = (bProperty *)(ptr->data);
- return *(float *)(&prop->data);
-}
-
-static void rna_GameFloatProperty_value_set(PointerRNA *ptr, float value)
-{
- bProperty *prop = (bProperty *)(ptr->data);
- CLAMP(value, -10000.0f, 10000.0f);
- *(float *)(&prop->data) = value;
-}
-
-static void rna_GameProperty_type_set(PointerRNA *ptr, int value)
-{
- bProperty *prop = (bProperty *)(ptr->data);
-
- if (prop->type != value) {
- prop->type = value;
- BKE_bproperty_init(prop);
- }
-}
-
-static void rna_GameProperty_name_set(PointerRNA *ptr, const char *value)
-{
- Object *ob = ptr->id.data;
- bProperty *prop = ptr->data;
- BLI_strncpy_utf8(prop->name, value, sizeof(prop->name));
-
- BLI_uniquename(&ob->prop, prop, DATA_("Property"), '.', offsetof(bProperty, name), sizeof(prop->name));
-}
-
-
-#else
-
-void RNA_def_gameproperty(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- /* Base Struct for GameProperty */
- srna = RNA_def_struct(brna, "GameProperty", NULL);
- RNA_def_struct_ui_text(srna, "Game Property", "Game engine user defined object property");
- RNA_def_struct_sdna(srna, "bProperty");
- RNA_def_struct_refine_func(srna, "rna_GameProperty_refine");
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Name", "Available as GameObject attributes in the game engine's python API");
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GameProperty_name_set");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, rna_enum_gameproperty_type_items);
- RNA_def_property_ui_text(prop, "Type", "");
- RNA_def_property_enum_funcs(prop, NULL, "rna_GameProperty_type_set", NULL);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_debug", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PROP_DEBUG);
- RNA_def_property_ui_text(prop, "Debug", "Print debug information for this property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* GameBooleanProperty */
- srna = RNA_def_struct(brna, "GameBooleanProperty", "GameProperty");
- RNA_def_struct_ui_text(srna, "Game Boolean Property", "Game engine user defined Boolean property");
- RNA_def_struct_sdna(srna, "bProperty");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "data", 1);
- RNA_def_property_ui_text(prop, "Value", "Property value");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* GameIntProperty */
- srna = RNA_def_struct(brna, "GameIntProperty", "GameProperty");
- RNA_def_struct_ui_text(srna, "Game Integer Property", "Game engine user defined integer number property");
- RNA_def_struct_sdna(srna, "bProperty");
-
- prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "data");
- RNA_def_property_ui_text(prop, "Value", "Property value");
- RNA_def_property_range(prop, -10000, 10000);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* GameFloatProperty */
- srna = RNA_def_struct(brna, "GameFloatProperty", "GameProperty");
- RNA_def_struct_ui_text(srna, "Game Float Property", "Game engine user defined floating point number property");
- RNA_def_struct_sdna(srna, "bProperty");
-
- prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
- /* RNA_def_property_float_sdna(prop, NULL, "data"); */
- RNA_def_property_ui_text(prop, "Value", "Property value");
- RNA_def_property_range(prop, -10000, 10000);
- RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* GameTimerProperty */
- srna = RNA_def_struct(brna, "GameTimerProperty", "GameProperty");
- RNA_def_struct_ui_text(srna, "Game Timer Property", "Game engine user defined timer property");
- RNA_def_struct_sdna(srna, "bProperty");
-
- prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
- /* RNA_def_property_float_sdna(prop, NULL, "data"); */
- RNA_def_property_ui_text(prop, "Value", "Property value");
- RNA_def_property_range(prop, -10000, 10000);
- RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* GameStringProperty */
- srna = RNA_def_struct(brna, "GameStringProperty", "GameProperty");
- RNA_def_struct_ui_text(srna, "Game String Property", "Game engine user defined text string property");
- RNA_def_struct_sdna(srna, "bProperty");
-
- prop = RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "poin");
- RNA_def_property_string_maxlength(prop, MAX_PROPSTRING);
- RNA_def_property_ui_text(prop, "Value", "Property value");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-#endif
-
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 3782e694d73..14323858c12 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -37,6 +37,8 @@
#include "DNA_userdef_types.h"
#include "DNA_world_types.h"
#include "DNA_gpencil_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_screen_types.h" /* TransformOrientation */
#include "IMB_imbuf_types.h"
@@ -71,6 +73,7 @@
#endif
#include "ED_render.h"
+#include "ED_transform.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -112,7 +115,7 @@ const EnumPropertyItem rna_enum_uv_sculpt_tool_items[] = {
const EnumPropertyItem rna_enum_snap_target_items[] = {
{SCE_SNAP_TARGET_CLOSEST, "CLOSEST", 0, "Closest", "Snap closest point onto target"},
- {SCE_SNAP_TARGET_CENTER, "CENTER", 0, "Center", "Snap center onto target"},
+ {SCE_SNAP_TARGET_CENTER, "CENTER", 0, "Center", "Snap transormation center onto target"},
{SCE_SNAP_TARGET_MEDIAN, "MEDIAN", 0, "Median", "Snap median onto target"},
{SCE_SNAP_TARGET_ACTIVE, "ACTIVE", 0, "Active", "Snap active onto target"},
{0, NULL, 0, NULL, NULL}
@@ -438,6 +441,18 @@ static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = {
#endif
+static const EnumPropertyItem transform_orientation_items[] = {
+ {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", "Align the transformation axes to world space"},
+ {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", "Align the transformation axes to the selected objects' local space"},
+ {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal",
+ "Align the transformation axes to average normal of selected elements "
+ "(bone Y axis for pose mode)"},
+ {V3D_MANIP_GIMBAL, "GIMBAL", 0, "Gimbal", "Align each axis to the Euler rotation axis as used for input"},
+ {V3D_MANIP_VIEW, "VIEW", 0, "View", "Align the transformation axes to the window"},
+ // {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"},
+ {0, NULL, 0, NULL, NULL}
+};
+
#ifdef RNA_RUNTIME
#include "DNA_anim_types.h"
@@ -651,15 +666,6 @@ static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter)
/* End of read-only Iterator of all the scene objects. */
-static void rna_Scene_skgen_etch_template_set(PointerRNA *ptr, PointerRNA value)
-{
- ToolSettings *ts = (ToolSettings *)ptr->data;
- if (value.data && ((Object *)value.data)->type == OB_ARMATURE)
- ts->skgen_template = value.data;
- else
- ts->skgen_template = NULL;
-}
-
static void rna_Scene_set_set(PointerRNA *ptr, PointerRNA value)
{
Scene *scene = (Scene *)ptr->data;
@@ -1031,17 +1037,6 @@ static int rna_RenderSettings_is_movie_format_get(PointerRNA *ptr)
return BKE_imtype_is_movie(rd->im_format.imtype);
}
-static int rna_RenderSettings_save_buffers_get(PointerRNA *ptr)
-{
- RenderData *rd = (RenderData *)ptr->data;
- Scene *scene = (Scene *)ptr->id.data;
-
- if (!BKE_scene_use_new_shading_nodes(scene))
- return (rd->scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE)) != 0;
- else
- return (rd->scemode & R_EXR_TILE_FILE) != 0;
-}
-
static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value)
{
ImageFormatData *imf = (ImageFormatData *)ptr->data;
@@ -1378,6 +1373,67 @@ static void rna_RenderSettings_views_format_set(PointerRNA *ptr, int value)
rd->views_format = value;
}
+static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value)
+{
+ RenderData *rd = (RenderData *)ptr->data;
+ RenderEngineType *type = BLI_findlink(&R_engines, value);
+
+ if (type) {
+ BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine));
+ DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE);
+ }
+}
+
+static const EnumPropertyItem *rna_RenderSettings_engine_itemf(
+ bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ RenderEngineType *type;
+ EnumPropertyItem *item = NULL;
+ EnumPropertyItem tmp = {0, "", 0, "", ""};
+ int a = 0, totitem = 0;
+
+ for (type = R_engines.first; type; type = type->next, a++) {
+ tmp.value = a;
+ tmp.identifier = type->idname;
+ tmp.name = type->name;
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+
+ return item;
+}
+
+static int rna_RenderSettings_engine_get(PointerRNA *ptr)
+{
+ RenderData *rd = (RenderData *)ptr->data;
+ RenderEngineType *type;
+ int a = 0;
+
+ for (type = R_engines.first; type; type = type->next, a++)
+ if (STREQ(type->idname, rd->engine))
+ return a;
+
+ return 0;
+}
+
+static void rna_RenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr))
+{
+ ED_render_engine_changed(bmain);
+}
+
+static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr))
+{
+ return (BLI_listbase_count(&R_engines) > 1);
+}
+
+static int rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr)
+{
+ Scene *scene = (Scene *)ptr->id.data;
+ return BKE_scene_use_spherical_stereo(scene);
+}
+
void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->id.data;
@@ -1627,26 +1683,7 @@ static void rna_Scene_sync_mode_set(PointerRNA *ptr, int value)
}
}
-static int rna_GameSettings_auto_start_get(PointerRNA *UNUSED(ptr))
-{
- return (G.fileflags & G_FILE_AUTOPLAY) != 0;
-}
-static void rna_GameSettings_auto_start_set(PointerRNA *UNUSED(ptr), int value)
-{
- if (value)
- G.fileflags |= G_FILE_AUTOPLAY;
- else
- G.fileflags &= ~G_FILE_AUTOPLAY;
-}
-
-static void rna_GameSettings_exit_key_set(PointerRNA *ptr, int value)
-{
- GameData *gm = (GameData *)ptr->data;
-
- if (ISKEYBOARD(value))
- gm->exitkey = value;
-}
static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[], int frame)
{
@@ -2034,6 +2071,71 @@ static void rna_ViewLayer_remove(
}
}
+static int rna_Scene_transform_orientation_get(PointerRNA *ptr)
+{
+ Scene *scene = ptr->data;
+ /* convert to enum value */
+ return (scene->orientation_type == V3D_MANIP_CUSTOM) ?
+ (scene->orientation_type + scene->orientation_index_custom) : scene->orientation_type;
+}
+
+void rna_Scene_transform_orientation_set(PointerRNA *ptr, int value)
+{
+ Scene *scene = ptr->data;
+ BIF_selectTransformOrientationValue(scene, value);
+}
+
+static PointerRNA rna_Scene_current_orientation_get(PointerRNA *ptr)
+{
+ Scene *scene = ptr->data;
+ TransformOrientation *orientation;
+
+ if (scene->orientation_type < V3D_MANIP_CUSTOM) {
+ orientation = NULL;
+ }
+ else {
+ orientation = BKE_scene_transform_orientation_find(scene, scene->orientation_index_custom);
+ }
+
+ return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, orientation);
+}
+
+const EnumPropertyItem *rna_TransformOrientation_itemf(
+ bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem *item = NULL;
+ int i = V3D_MANIP_CUSTOM, totitem = 0;
+
+ RNA_enum_items_add(&item, &totitem, transform_orientation_items);
+
+ Scene *scene = CTX_data_scene(C);
+ if (ptr->type == &RNA_Scene) {
+ scene = ptr->data;
+ }
+ else {
+ scene = CTX_data_scene(C);
+ }
+ const ListBase *transform_orientations = &scene->transform_spaces;
+
+ if (transform_orientations && (BLI_listbase_is_empty(transform_orientations) == false)) {
+ RNA_enum_item_add_separator(&item, &totitem);
+
+ for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) {
+ tmp.identifier = ts->name;
+ tmp.name = ts->name;
+ tmp.value = i++;
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+
+ return item;
+}
+
+
#else
/* Grease Pencil Interpolation tool settings */
@@ -2302,6 +2404,24 @@ static void rna_def_gpencil_brushes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_ui_text(prop, "Active Brush Index", "Index of active brush");
}
+static void rna_def_transform_orientation(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "TransformOrientation", NULL);
+
+ prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_float_sdna(prop, NULL, "mat");
+ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+}
+
static void rna_def_tool_settings(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2325,22 +2445,6 @@ static void rna_def_tool_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem retarget_roll_items[] = {
- {SK_RETARGET_ROLL_NONE, "NONE", 0, "None", "Don't adjust roll"},
- {SK_RETARGET_ROLL_VIEW, "VIEW", 0, "View", "Roll bones to face the view"},
- {SK_RETARGET_ROLL_JOINT, "JOINT", 0, "Joint", "Roll bone to original joint plane offset"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem sketch_convert_items[] = {
- {SK_CONVERT_CUT_FIXED, "FIXED", 0, "Fixed", "Subdivide stroke in fixed number of bones"},
- {SK_CONVERT_CUT_LENGTH, "LENGTH", 0, "Length", "Subdivide stroke in bones of specific length"},
- {SK_CONVERT_CUT_ADAPTATIVE, "ADAPTIVE", 0, "Adaptive",
- "Subdivide stroke adaptively, with more subdivision in curvier parts"},
- {SK_CONVERT_RETARGET, "RETARGET", 0, "Retarget", "Retarget template bone chain to stroke"},
- {0, NULL, 0, NULL, NULL}
- };
-
static const EnumPropertyItem edge_tag_items[] = {
{EDGE_MODE_SELECT, "SELECT", 0, "Select", ""},
{EDGE_MODE_TAG_SEAM, "SEAM", 0, "Tag Seam", ""},
@@ -2748,72 +2852,6 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "edge_mode_live_unwrap", 1);
RNA_def_property_ui_text(prop, "Live Unwrap", "Changing edges seam re-calculates UV unwrap");
- /* etch-a-ton */
- prop = RNA_def_property(srna, "use_bone_sketching", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING);
- RNA_def_property_ui_text(prop, "Use Bone Sketching", "Use sketching to create and edit bones");
-/* RNA_def_property_ui_icon(prop, ICON_EDIT, 0); */
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "use_etch_quick", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING_QUICK);
- RNA_def_property_ui_text(prop, "Quick Sketching", "Automatically convert and delete on stroke end");
-
- prop = RNA_def_property(srna, "use_etch_overdraw", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING_ADJUST);
- RNA_def_property_ui_text(prop, "Overdraw Sketching", "Adjust strokes by drawing near them");
-
- prop = RNA_def_property(srna, "use_etch_autoname", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "skgen_retarget_options", SK_RETARGET_AUTONAME);
- RNA_def_property_ui_text(prop, "Autoname Bones",
- "Automatically generate values to replace &N and &S suffix placeholders in template names");
-
- prop = RNA_def_property(srna, "etch_number", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "skgen_num_string");
- RNA_def_property_ui_text(prop, "Number", "Text to replace &N with (e.g. 'Finger.&N' -> 'Finger.1' or 'Finger.One')");
-
- prop = RNA_def_property(srna, "etch_side", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "skgen_num_string");
- RNA_def_property_ui_text(prop, "Side", "Text to replace &S with (e.g. 'Arm.&S' -> 'Arm.R' or 'Arm.Right')");
-
- prop = RNA_def_property(srna, "etch_template", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "skgen_template");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_pointer_funcs(prop, NULL, "rna_Scene_skgen_etch_template_set", NULL, NULL);
- RNA_def_property_ui_text(prop, "Template", "Template armature that will be retargeted to the stroke");
-
- prop = RNA_def_property(srna, "etch_subdivision_number", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "skgen_subdivision_number");
- RNA_def_property_range(prop, 1, 255);
- RNA_def_property_ui_text(prop, "Subdivisions", "Number of bones in the subdivided stroke");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "etch_adaptive_limit", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "skgen_correlation_limit");
- RNA_def_property_range(prop, 0.00001, 1.0);
- RNA_def_property_ui_range(prop, 0.01, 1.0, 0.01, 2);
- RNA_def_property_ui_text(prop, "Limit", "Correlation threshold for number of bones in the subdivided stroke");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "etch_length_limit", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "skgen_length_limit");
- RNA_def_property_range(prop, 0.00001, 100000.0);
- RNA_def_property_ui_range(prop, 0.001, 100.0, 0.1, 3);
- RNA_def_property_ui_text(prop, "Length", "Maximum length of the subdivided bones");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "etch_roll_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "skgen_retarget_roll");
- RNA_def_property_enum_items(prop, retarget_roll_items);
- RNA_def_property_ui_text(prop, "Retarget roll mode", "Method used to adjust the roll of bones when retargeting");
-
- prop = RNA_def_property(srna, "etch_convert_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "bone_sketching_convert");
- RNA_def_property_enum_items(prop, sketch_convert_items);
- RNA_def_property_ui_text(prop, "Stroke conversion method", "Method used to convert stroke to bones");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
/* Unified Paint Settings */
prop = RNA_def_property(srna, "unified_paint_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -3320,18 +3358,6 @@ void rna_def_view_layer_common(StructRNA *srna, int scene)
if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop = RNA_def_property(srna, "use_pass_color", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_RGBA);
- RNA_def_property_ui_text(prop, "Color", "Deliver shade-less color pass");
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "use_pass_diffuse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE);
- RNA_def_property_ui_text(prop, "Diffuse", "Deliver diffuse pass");
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
prop = RNA_def_property(srna, "use_pass_specular", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SPEC);
RNA_def_property_ui_text(prop, "Specular", "Deliver specular pass");
@@ -3350,18 +3376,6 @@ void rna_def_view_layer_common(StructRNA *srna, int scene)
if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop = RNA_def_property(srna, "use_pass_reflection", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_REFLECT);
- RNA_def_property_ui_text(prop, "Reflection", "Deliver raytraced reflection pass");
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "use_pass_refraction", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_REFRACT);
- RNA_def_property_ui_text(prop, "Refraction", "Deliver raytraced refraction pass");
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
prop = RNA_def_property(srna, "use_pass_emit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_EMIT);
RNA_def_property_ui_text(prop, "Emit", "Deliver emission pass");
@@ -3380,62 +3394,6 @@ void rna_def_view_layer_common(StructRNA *srna, int scene)
if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop = RNA_def_property(srna, "exclude_specular", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_SPEC);
- RNA_def_property_ui_text(prop, "Specular Exclude", "Exclude specular pass from combined");
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "exclude_shadow", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_SHADOW);
- RNA_def_property_ui_text(prop, "Shadow Exclude", "Exclude shadow pass from combined");
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "exclude_ambient_occlusion", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_AO);
- RNA_def_property_ui_text(prop, "AO Exclude", "Exclude AO pass from combined");
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "exclude_reflection", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_REFLECT);
- RNA_def_property_ui_text(prop, "Reflection Exclude", "Exclude raytraced reflection pass from combined");
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "exclude_refraction", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_REFRACT);
- RNA_def_property_ui_text(prop, "Refraction Exclude", "Exclude raytraced refraction pass from combined");
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "exclude_emit", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_EMIT);
- RNA_def_property_ui_text(prop, "Emit Exclude", "Exclude emission pass from combined");
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "exclude_environment", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_ENVIRONMENT);
- RNA_def_property_ui_text(prop, "Environment Exclude", "Exclude environment pass from combined");
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "exclude_indirect", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_INDIRECT);
- RNA_def_property_ui_text(prop, "Indirect Exclude", "Exclude indirect pass from combined");
- RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
- if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
prop = RNA_def_property(srna, "use_pass_diffuse_direct", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_DIRECT);
RNA_def_property_ui_text(prop, "Diffuse Direct", "Deliver diffuse direct pass");
@@ -3945,124 +3903,6 @@ void rna_def_freestyle_settings(BlenderRNA *brna)
rna_def_freestyle_linesets(brna, prop);
}
-static void rna_def_scene_game_recast_data(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem rna_enum_partitioning_items[] = {
- {RC_PARTITION_WATERSHED, "WATERSHED", 0, "Watershed", "Classic Recast partitioning method generating the nicest tessellation"},
- {RC_PARTITION_MONOTONE, "MONOTONE", 0, "Monotone", "Fastest navmesh generation method, may create long thin polygons"},
- {RC_PARTITION_LAYERS, "LAYERS", 0, "Layers", "Reasonably fast method that produces better triangles than monotone partitioning"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "SceneGameRecastData", NULL);
- RNA_def_struct_sdna(srna, "RecastData");
- RNA_def_struct_nested(brna, srna, "Scene");
- RNA_def_struct_ui_text(srna, "Recast Data", "Recast data for a Game data-block");
-
- prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "cellsize");
- RNA_def_property_ui_range(prop, 0.1, 1, 1, 2);
- RNA_def_property_float_default(prop, 0.3f);
- RNA_def_property_ui_text(prop, "Cell Size", "Rasterized cell size");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "cell_height", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "cellheight");
- RNA_def_property_ui_range(prop, 0.1, 1, 1, 2);
- RNA_def_property_float_default(prop, 0.2f);
- RNA_def_property_ui_text(prop, "Cell Height", "Rasterized cell height");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "agent_height", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "agentheight");
- RNA_def_property_ui_range(prop, 0.1, 5, 1, 2);
- RNA_def_property_float_default(prop, 2.0f);
- RNA_def_property_ui_text(prop, "Agent Height", "Minimum height where the agent can still walk");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "agent_radius", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "agentradius");
- RNA_def_property_ui_range(prop, 0.1, 5, 1, 2);
- RNA_def_property_float_default(prop, 0.6f);
- RNA_def_property_ui_text(prop, "Agent Radius", "Radius of the agent");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "climb_max", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "agentmaxclimb");
- RNA_def_property_ui_range(prop, 0.1, 5, 1, 2);
- RNA_def_property_float_default(prop, 0.9f);
- RNA_def_property_ui_text(prop, "Max Climb", "Maximum height between grid cells the agent can climb");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "slope_max", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "agentmaxslope");
- RNA_def_property_range(prop, 0, M_PI_2);
- RNA_def_property_float_default(prop, M_PI_4);
- RNA_def_property_ui_text(prop, "Max Slope", "Maximum walkable slope angle");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
-
- prop = RNA_def_property(srna, "region_min_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "regionminsize");
- RNA_def_property_ui_range(prop, 0, 150, 1, 2);
- RNA_def_property_float_default(prop, 8.0f);
- RNA_def_property_ui_text(prop, "Min Region Size", "Minimum regions size (smaller regions will be deleted)");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "region_merge_size", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "regionmergesize");
- RNA_def_property_ui_range(prop, 0, 150, 1, 2);
- RNA_def_property_float_default(prop, 20.0f);
- RNA_def_property_ui_text(prop, "Merged Region Size", "Minimum regions size (smaller regions will be merged)");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "partitioning", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "partitioning");
- RNA_def_property_enum_items(prop, rna_enum_partitioning_items);
- RNA_def_property_enum_default(prop, RC_PARTITION_WATERSHED);
- RNA_def_property_ui_text(prop, "Partitioning", "Choose partitioning method");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "edge_max_len", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "edgemaxlen");
- RNA_def_property_ui_range(prop, 0, 50, 1, 2);
- RNA_def_property_float_default(prop, 12.0f);
- RNA_def_property_ui_text(prop, "Max Edge Length", "Maximum contour edge length");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "edge_max_error", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "edgemaxerror");
- RNA_def_property_ui_range(prop, 0.1, 3.0, 1, 2);
- RNA_def_property_float_default(prop, 1.3f);
- RNA_def_property_ui_text(prop, "Max Edge Error", "Maximum distance error from contour to cells");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "verts_per_poly", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "vertsperpoly");
- RNA_def_property_ui_range(prop, 3, 12, 1, -1);
- RNA_def_property_int_default(prop, 6);
- RNA_def_property_ui_text(prop, "Verts Per Poly", "Max number of vertices per polygon");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "sample_dist", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "detailsampledist");
- RNA_def_property_ui_range(prop, 0.0, 16.0, 1, 2);
- RNA_def_property_float_default(prop, 6.0f);
- RNA_def_property_ui_text(prop, "Sample Distance", "Detail mesh sample spacing");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "sample_max_error", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "detailsamplemaxerror");
- RNA_def_property_ui_range(prop, 0.0, 16.0, 1, 2);
- RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(prop, "Max Sample Error", "Detail mesh simplification max sample error");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-}
-
-
static void rna_def_bake_data(BlenderRNA *brna)
{
StructRNA *srna;
@@ -4226,493 +4066,6 @@ static void rna_def_bake_data(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}
-static void rna_def_scene_game_data(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem aasamples_items[] = {
- {0, "SAMPLES_0", 0, "Off", ""},
- {2, "SAMPLES_2", 0, "2x", ""},
- {4, "SAMPLES_4", 0, "4x", ""},
- {8, "SAMPLES_8", 0, "8x", ""},
- {16, "SAMPLES_16", 0, "16x", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem framing_types_items[] = {
- {SCE_GAMEFRAMING_BARS, "LETTERBOX", 0, "Letterbox",
- "Show the entire viewport in the display window, using bar horizontally or vertically"},
- {SCE_GAMEFRAMING_EXTEND, "EXTEND", 0, "Extend",
- "Show the entire viewport in the display window, viewing more horizontally "
- "or vertically"},
- {SCE_GAMEFRAMING_SCALE, "SCALE", 0, "Scale", "Stretch or squeeze the viewport to fill the display window"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem dome_modes_items[] = {
- {DOME_FISHEYE, "FISHEYE", 0, "Fisheye", ""},
- {DOME_TRUNCATED_FRONT, "TRUNCATED_FRONT", 0, "Front-Truncated", ""},
- {DOME_TRUNCATED_REAR, "TRUNCATED_REAR", 0, "Rear-Truncated", ""},
- {DOME_ENVMAP, "ENVMAP", 0, "Cube Map", ""},
- {DOME_PANORAM_SPH, "PANORAM_SPH", 0, "Spherical Panoramic", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem stereo_modes_items[] = {
- {STEREO_QUADBUFFERED, "QUADBUFFERED", 0, "Quad-Buffer", ""},
- {STEREO_ABOVEBELOW, "ABOVEBELOW", 0, "Above-Below", ""},
- {STEREO_INTERLACED, "INTERLACED", 0, "Interlaced", ""},
- {STEREO_ANAGLYPH, "ANAGLYPH", 0, "Anaglyph", ""},
- {STEREO_SIDEBYSIDE, "SIDEBYSIDE", 0, "Side-by-side", ""},
- {STEREO_VINTERLACE, "VINTERLACE", 0, "Vinterlace", ""},
- {STEREO_3DTVTOPBOTTOM, "3DTVTOPBOTTOM", 0, "3DTV Top-Bottom", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem stereo_items[] = {
- {STEREO_NOSTEREO, "NONE", 0, "None", "Disable Stereo and Dome environments"},
- {STEREO_ENABLED, "STEREO", 0, "Stereo", "Enable Stereo environment"},
- {STEREO_DOME, "DOME", 0, "Dome", "Enable Dome environment"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem physics_engine_items[] = {
- {WOPHY_NONE, "NONE", 0, "None", "Don't use a physics engine"},
- {WOPHY_BULLET, "BULLET", 0, "Bullet", "Use the Bullet physics engine"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem material_items[] = {
- {GAME_MAT_MULTITEX, "MULTITEXTURE", 0, "Multitexture", "Multitexture materials"},
- {GAME_MAT_GLSL, "GLSL", 0, "GLSL", "OpenGL shading language shaders"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem obstacle_simulation_items[] = {
- {OBSTSIMULATION_NONE, "NONE", 0, "None", ""},
- {OBSTSIMULATION_TOI_rays, "RVO_RAYS", 0, "RVO (rays)", ""},
- {OBSTSIMULATION_TOI_cells, "RVO_CELLS", 0, "RVO (cells)", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem vsync_items[] = {
- {VSYNC_OFF, "OFF", 0, "Off", "Disable vsync"},
- {VSYNC_ON, "ON", 0, "On", "Enable vsync"},
- {VSYNC_ADAPTIVE, "ADAPTIVE", 0, "Adaptive", "Enable adaptive vsync (if supported)"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem storage_items[] = {
- {RAS_STORE_AUTO, "AUTO", 0, "Auto Select", "Choose the best supported mode"},
- {RAS_STORE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Usually the best choice (good performance with display lists)"},
- {RAS_STORE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects",
- "Typically slower than vertex arrays with display lists, requires at least OpenGL 1.4"},
- {0, NULL, 0, NULL, NULL}};
-
- srna = RNA_def_struct(brna, "SceneGameData", NULL);
- RNA_def_struct_sdna(srna, "GameData");
- RNA_def_struct_nested(brna, srna, "Scene");
- RNA_def_struct_ui_text(srna, "Game Data", "Game data for a Scene data-block");
-
- prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_PIXEL);
- RNA_def_property_int_sdna(prop, NULL, "xplay");
- RNA_def_property_range(prop, 4, 10000);
- RNA_def_property_int_default(prop, 640);
- RNA_def_property_ui_text(prop, "Resolution X", "Number of horizontal pixels in the screen");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_PIXEL);
- RNA_def_property_int_sdna(prop, NULL, "yplay");
- RNA_def_property_range(prop, 4, 10000);
- RNA_def_property_int_default(prop, 480);
- RNA_def_property_ui_text(prop, "Resolution Y", "Number of vertical pixels in the screen");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "vsync", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "vsync");
- RNA_def_property_enum_items(prop, vsync_items);
- RNA_def_property_ui_text(prop, "Vsync", "Change vsync settings");
-
- prop = RNA_def_property(srna, "samples", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "aasamples");
- RNA_def_property_enum_items(prop, aasamples_items);
- RNA_def_property_ui_text(prop, "AA Samples", "The number of AA Samples to use for MSAA");
-
- prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "depth");
- RNA_def_property_range(prop, 8, 32);
- RNA_def_property_int_default(prop, 32);
- RNA_def_property_ui_text(prop, "Bits", "Display bit depth of full screen display");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "exit_key", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "exitkey");
- RNA_def_property_enum_items(prop, rna_enum_event_type_items);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
- RNA_def_property_enum_default(prop, ESCKEY);
- RNA_def_property_enum_funcs(prop, NULL, "rna_GameSettings_exit_key_set", NULL);
- RNA_def_property_ui_text(prop, "Exit Key", "The key that exits the Game Engine");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "raster_storage", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "raster_storage");
- RNA_def_property_enum_items(prop, storage_items);
- RNA_def_property_ui_text(prop, "Storage", "Set the storage mode used by the rasterizer");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- /* Do we need it here ? (since we already have it in World */
- prop = RNA_def_property(srna, "frequency", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "freqplay");
- RNA_def_property_range(prop, 4, 2000);
- RNA_def_property_int_default(prop, 60);
- RNA_def_property_ui_text(prop, "Freq", "Display clock frequency of fullscreen display");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "playerflag", GAME_PLAYER_FULLSCREEN);
- RNA_def_property_ui_text(prop, "Fullscreen", "Start player in a new fullscreen display");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "use_desktop", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "playerflag", GAME_PLAYER_DESKTOP_RESOLUTION);
- RNA_def_property_ui_text(prop, "Desktop", "Use the current desktop resolution in fullscreen mode");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- /* Framing */
- prop = RNA_def_property(srna, "frame_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "framing.type");
- RNA_def_property_enum_items(prop, framing_types_items);
- RNA_def_property_ui_text(prop, "Framing Types", "Select the type of Framing you want");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "frame_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "framing.col");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Framing Color", "Set color of the bars");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- /* Stereo */
- prop = RNA_def_property(srna, "stereo", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "stereoflag");
- RNA_def_property_enum_items(prop, stereo_items);
- RNA_def_property_ui_text(prop, "Stereo Options", "");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "stereo_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "stereomode");
- RNA_def_property_enum_items(prop, stereo_modes_items);
- RNA_def_property_enum_default(prop, STEREO_ANAGLYPH);
- RNA_def_property_ui_text(prop, "Stereo Mode", "Stereographic techniques");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "stereo_eye_separation", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "eyeseparation");
- RNA_def_property_range(prop, 0.01, 5.0);
- RNA_def_property_float_default(prop, 0.1f);
- RNA_def_property_ui_text(prop, "Eye Separation",
- "Set the distance between the eyes - the camera focal distance/30 should be fine");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- /* Dome */
- prop = RNA_def_property(srna, "dome_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "dome.mode");
- RNA_def_property_enum_items(prop, dome_modes_items);
- RNA_def_property_ui_text(prop, "Dome Mode", "Dome physical configurations");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "dome_tessellation", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "dome.res");
- RNA_def_property_ui_range(prop, 1, 8, 1, 1);
- RNA_def_property_int_default(prop, 4);
- RNA_def_property_ui_text(prop, "Tessellation", "Tessellation level - check the generated mesh in wireframe mode");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "dome_buffer_resolution", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "dome.resbuf");
- RNA_def_property_ui_range(prop, 0.1, 1.0, 0.1, 2);
- RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(prop, "Buffer Resolution", "Buffer Resolution - decrease it to increase speed");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "dome_angle", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "dome.angle");
- RNA_def_property_ui_range(prop, 90, 250, 1, 1);
- RNA_def_property_int_default(prop, 180);
- RNA_def_property_ui_text(prop, "Angle", "Field of View of the Dome - it only works in mode Fisheye and Truncated");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "dome_tilt", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "dome.tilt");
- RNA_def_property_ui_range(prop, -180, 180, 1, 1);
- RNA_def_property_ui_text(prop, "Tilt", "Camera rotation in horizontal axis");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "dome_text", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "dome.warptext");
- RNA_def_property_struct_type(prop, "Text");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Warp Data", "Custom Warp Mesh data file");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- /* physics */
- prop = RNA_def_property(srna, "physics_engine", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "physicsEngine");
- RNA_def_property_enum_items(prop, physics_engine_items);
- RNA_def_property_enum_default(prop, WOPHY_BULLET);
- RNA_def_property_ui_text(prop, "Physics Engine", "Physics engine used for physics simulation in the game engine");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "physics_gravity", PROP_FLOAT, PROP_ACCELERATION);
- RNA_def_property_float_sdna(prop, NULL, "gravity");
- RNA_def_property_ui_range(prop, 0.0, 25.0, 1, 2);
- RNA_def_property_range(prop, 0.0, 10000.0);
- RNA_def_property_float_default(prop, 9.8f);
- RNA_def_property_ui_text(prop, "Physics Gravity",
- "Gravitational constant used for physics simulation in the game engine");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "occlusion_culling_resolution", PROP_INT, PROP_PIXEL);
- RNA_def_property_int_sdna(prop, NULL, "occlusionRes");
- RNA_def_property_range(prop, 128.0, 1024.0);
- RNA_def_property_int_default(prop, 128);
- RNA_def_property_ui_text(prop, "Occlusion Resolution",
- "Size of the occlusion buffer, use higher value for better precision (slower)");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "fps", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "ticrate");
- RNA_def_property_ui_range(prop, 1, 60, 1, 1);
- RNA_def_property_range(prop, 1, 10000);
- RNA_def_property_int_default(prop, 60);
- RNA_def_property_ui_text(prop, "Frames Per Second",
- "Nominal number of game frames per second "
- "(physics fixed timestep = 1/fps, independently of actual frame rate)");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "logic_step_max", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "maxlogicstep");
- RNA_def_property_range(prop, 1, 10000);
- RNA_def_property_ui_range(prop, 1, 50, 1, 1);
- RNA_def_property_int_default(prop, 5);
- RNA_def_property_ui_text(prop, "Max Logic Steps",
- "Maximum number of logic frame per game frame if graphics slows down the game, "
- "higher value allows better synchronization with physics");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "physics_step_max", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "maxphystep");
- RNA_def_property_range(prop, 1, 10000);
- RNA_def_property_ui_range(prop, 1, 50, 1, 1);
- RNA_def_property_int_default(prop, 5);
- RNA_def_property_ui_text(prop, "Max Physics Steps",
- "Maximum number of physics step per game frame if graphics slows down the game, "
- "higher value allows physics to keep up with realtime");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "physics_step_sub", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "physubstep");
- RNA_def_property_range(prop, 1, 50);
- RNA_def_property_ui_range(prop, 1, 5, 1, 1);
- RNA_def_property_int_default(prop, 1);
- RNA_def_property_ui_text(prop, "Physics Sub Steps",
- "Number of simulation substep per physic timestep, "
- "higher value give better physics precision");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "deactivation_linear_threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "lineardeactthreshold");
- RNA_def_property_ui_range(prop, 0.001, 10000.0, 2, 3);
- RNA_def_property_range(prop, 0.001, 10000.0);
- RNA_def_property_float_default(prop, 0.8f);
- RNA_def_property_ui_text(prop, "Deactivation Linear Threshold",
- "Linear velocity that an object must be below before the deactivation timer can start");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "deactivation_angular_threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "angulardeactthreshold");
- RNA_def_property_ui_range(prop, 0.001, 10000.0, 2, 3);
- RNA_def_property_range(prop, 0.001, 10000.0);
- RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(prop, "Deactivation Angular Threshold",
- "Angular velocity that an object must be below before the deactivation timer can start");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "deactivation_time", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "deactivationtime");
- RNA_def_property_ui_range(prop, 0.0, 60.0, 1, 1);
- RNA_def_property_range(prop, 0.0, 60.0);
- RNA_def_property_ui_text(prop, "Deactivation Time",
- "Amount of time (in seconds) after which objects with a velocity less than the given "
- "threshold will deactivate (0.0 means no deactivation)");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- /* mode */
- /* not used *//* deprecated !!!!!!!!!!!!! */
- prop = RNA_def_property(srna, "use_occlusion_culling", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_DBVT_CULLING);
- RNA_def_property_ui_text(prop, "DBVT Culling",
- "Use optimized Bullet DBVT tree for view frustum and occlusion culling (more efficient, "
- "but it can waste unnecessary CPU if the scene doesn't have occluder objects)");
-
- /* not used *//* deprecated !!!!!!!!!!!!! */
- prop = RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_ACTIVITY_CULLING);
- RNA_def_property_ui_text(prop, "Activity Culling", "Activity culling is enabled");
-
- /* not used *//* deprecated !!!!!!!!!!!!! */
- prop = RNA_def_property(srna, "activity_culling_box_radius", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "activityBoxRadius");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_ui_text(prop, "Box Radius",
- "Radius of the activity bubble, in Manhattan length "
- "(objects outside the box are activity-culled)");
-
- /* booleans */
- prop = RNA_def_property(srna, "show_debug_properties", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_DEBUG_PROPS);
- RNA_def_property_ui_text(prop, "Show Debug Properties",
- "Show properties marked for debugging while the game runs");
-
- prop = RNA_def_property(srna, "show_framerate_profile", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_FRAMERATE);
- RNA_def_property_ui_text(prop, "Show Framerate and Profile",
- "Show framerate and profiling information while the game runs");
-
- prop = RNA_def_property(srna, "show_physics_visualization", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_PHYSICS);
- RNA_def_property_ui_text(prop, "Show Physics Visualization",
- "Show a visualization of physics bounds and interactions");
-
- prop = RNA_def_property(srna, "show_mouse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_MOUSE);
- RNA_def_property_ui_text(prop, "Show Mouse", "Start player with a visible mouse cursor");
-
- 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 from the Physics panel in the world properties "
- "rather than rendering as many frames as possible");
-
- prop = RNA_def_property(srna, "use_deprecation_warnings", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_IGNORE_DEPRECATION_WARNINGS);
- RNA_def_property_ui_text(prop, "Deprecation Warnings",
- "Print warnings when using deprecated features in the python API");
-
- prop = RNA_def_property(srna, "use_animation_record", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_ENABLE_ANIMATION_RECORD);
- RNA_def_property_ui_text(prop, "Record Animation", "Record animation to F-Curves");
-
- prop = RNA_def_property(srna, "use_auto_start", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_GameSettings_auto_start_get", "rna_GameSettings_auto_start_set");
- RNA_def_property_ui_text(prop, "Auto Start", "Automatically start game at load time");
-
- prop = RNA_def_property(srna, "use_restrict_animation_updates", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_RESTRICT_ANIM_UPDATES);
- RNA_def_property_ui_text(prop, "Restrict Animation Updates",
- "Restrict the number of animation updates to the animation FPS (this is "
- "better for performance, but can cause issues with smooth playback)");
-
- /* materials */
- prop = RNA_def_property(srna, "material_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "matmode");
- RNA_def_property_enum_items(prop, material_items);
- RNA_def_property_ui_text(prop, "Material Mode", "Material mode to use for rendering");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, NULL);
-
- prop = RNA_def_property(srna, "use_glsl_lights", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_LIGHTS);
- RNA_def_property_ui_text(prop, "GLSL Lights", "Use lights for GLSL rendering");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_glsl_shaders", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADERS);
- RNA_def_property_ui_text(prop, "GLSL Shaders", "Use shaders for GLSL rendering");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_glsl_shadows", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADOWS);
- RNA_def_property_ui_text(prop, "GLSL Shadows", "Use shadows for GLSL rendering");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_glsl_ramps", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_RAMPS);
- RNA_def_property_ui_text(prop, "GLSL Ramps", "Use ramps for GLSL rendering");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_glsl_nodes", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_NODES);
- RNA_def_property_ui_text(prop, "GLSL Nodes", "Use nodes for GLSL rendering");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_glsl_color_management", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_COLOR_MANAGEMENT);
- RNA_def_property_ui_text(prop, "GLSL Color Management", "Use color management for GLSL rendering");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_glsl_extra_textures", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_EXTRA_TEX);
- RNA_def_property_ui_text(prop, "GLSL Extra Textures",
- "Use extra textures like normal or specular maps for GLSL rendering");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_glsl_environment_lighting", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_ENV_LIGHTING);
- RNA_def_property_ui_text(prop, "GLSL Environment Lighting", "Use environment lighting for GLSL rendering");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_material_caching", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_NO_MATERIAL_CACHING);
- RNA_def_property_ui_text(prop, "Use Material Caching",
- "Cache materials in the converter (this is faster, but can cause problems with older "
- "Singletexture and Multitexture games)");
-
- /* obstacle simulation */
- prop = RNA_def_property(srna, "obstacle_simulation", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "obstacleSimulation");
- RNA_def_property_enum_items(prop, obstacle_simulation_items);
- RNA_def_property_ui_text(prop, "Obstacle simulation", "Simulation used for obstacle avoidance in the game engine");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "level_height", PROP_FLOAT, PROP_ACCELERATION);
- RNA_def_property_float_sdna(prop, NULL, "levelHeight");
- RNA_def_property_range(prop, 0.0f, 200.0f);
- RNA_def_property_float_default(prop, 2.0f);
- RNA_def_property_ui_text(prop, "Level height",
- "Max difference in heights of obstacles to enable their interaction");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "show_obstacle_simulation", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_OBSTACLE_SIMULATION);
- RNA_def_property_ui_text(prop, "Visualization", "Enable debug visualization for obstacle simulation");
-
- /* Recast Settings */
- prop = RNA_def_property(srna, "recast_data", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "recastData");
- RNA_def_property_struct_type(prop, "SceneGameRecastData");
- RNA_def_property_ui_text(prop, "Recast Data", "");
-
- /* Nestled Data */
- rna_def_scene_game_recast_data(brna);
-
- /* LoD */
- prop = RNA_def_property(srna, "use_scene_hysteresis", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "lodflag", SCE_LOD_USE_HYST);
- RNA_def_property_ui_text(prop, "Hysteresis", "Use LoD Hysteresis setting for the scene");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-
- prop = RNA_def_property(srna, "scene_hysteresis_percentage", PROP_INT, PROP_PERCENTAGE);
- RNA_def_property_int_sdna(prop, NULL, "scehysteresis");
- RNA_def_property_range(prop, 0, 100);
- RNA_def_property_ui_range(prop, 0, 100, 10, 1);
- RNA_def_property_int_default(prop, 10);
- RNA_def_property_ui_text(prop, "Hysteresis %",
- "Minimum distance change required to transition to the previous level of detail");
- RNA_def_property_update(prop, NC_SCENE, NULL);
-}
-
static void rna_def_gpu_dof_fx(BlenderRNA *brna)
{
StructRNA *srna;
@@ -5456,17 +4809,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static const EnumPropertyItem pixel_filter_items[] = {
- {R_FILTER_BOX, "BOX", 0, "Box", "Use a box filter for anti-aliasing"},
- {R_FILTER_TENT, "TENT", 0, "Tent", "Use a tent filter for anti-aliasing"},
- {R_FILTER_QUAD, "QUADRATIC", 0, "Quadratic", "Use a quadratic filter for anti-aliasing"},
- {R_FILTER_CUBIC, "CUBIC", 0, "Cubic", "Use a cubic filter for anti-aliasing"},
- {R_FILTER_CATROM, "CATMULLROM", 0, "Catmull-Rom", "Use a Catmull-Rom filter for anti-aliasing"},
- {R_FILTER_GAUSS, "GAUSSIAN", 0, "Gaussian", "Use a Gaussian filter for anti-aliasing"},
- {R_FILTER_MITCH, "MITCHELL", 0, "Mitchell-Netravali", "Use a Mitchell-Netravali filter for anti-aliasing"},
- {0, NULL, 0, NULL, NULL}
- };
-
static const EnumPropertyItem alpha_mode_items[] = {
{R_ADDSKY, "SKY", 0, "Sky", "Transparent pixels are filled with sky color"},
{R_ALPHAPREMUL, "TRANSPARENT", 0, "Transparent", "World background is transparent with premultiplied alpha"},
@@ -5480,41 +4822,15 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
{R_OUTPUT_NONE, "NONE", 0, "Keep UI", "Images are rendered without forcing UI changes"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* Bake */
static const EnumPropertyItem bake_mode_items[] = {
- {RE_BAKE_ALL, "FULL", 0, "Full Render", "Bake everything"},
- {RE_BAKE_AO, "AO", 0, "Ambient Occlusion", "Bake ambient occlusion"},
- {RE_BAKE_SHADOW, "SHADOW", 0, "Shadow", "Bake shadows"},
+ //{RE_BAKE_AO, "AO", 0, "Ambient Occlusion", "Bake ambient occlusion"},
{RE_BAKE_NORMALS, "NORMALS", 0, "Normals", "Bake normals"},
- {RE_BAKE_TEXTURE, "TEXTURE", 0, "Textures", "Bake textures"},
{RE_BAKE_DISPLACEMENT, "DISPLACEMENT", 0, "Displacement", "Bake displacement"},
- {RE_BAKE_DERIVATIVE, "DERIVATIVE", 0, "Derivative", "Bake derivative map"},
- {RE_BAKE_VERTEX_COLORS, "VERTEX_COLORS", 0, "Vertex Colors", "Bake vertex colors"},
- {RE_BAKE_EMIT, "EMIT", 0, "Emission", "Bake Emit values (glow)"},
- {RE_BAKE_ALPHA, "ALPHA", 0, "Alpha", "Bake Alpha values (transparency)"},
- {RE_BAKE_MIRROR_INTENSITY, "MIRROR_INTENSITY", 0, "Mirror Intensity", "Bake Mirror values"},
- {RE_BAKE_MIRROR_COLOR, "MIRROR_COLOR", 0, "Mirror Colors", "Bake Mirror colors"},
- {RE_BAKE_SPEC_INTENSITY, "SPEC_INTENSITY", 0, "Specular Intensity", "Bake Specular values"},
- {RE_BAKE_SPEC_COLOR, "SPEC_COLOR", 0, "Specular Colors", "Bake Specular colors"},
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem bake_normal_space_items[] = {
- {R_BAKE_SPACE_CAMERA, "CAMERA", 0, "Camera", "Bake the normals in camera space"},
- {R_BAKE_SPACE_WORLD, "WORLD", 0, "World", "Bake the normals in world space"},
- {R_BAKE_SPACE_OBJECT, "OBJECT", 0, "Object", "Bake the normals in object space"},
- {R_BAKE_SPACE_TANGENT, "TANGENT", 0, "Tangent", "Bake the normals in tangent space"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem bake_qyad_split_items[] = {
- {0, "AUTO", 0, "Automatic", "Split quads to give the least distortion while baking"},
- {1, "FIXED", 0, "Fixed", "Split quads predictably (0,1,2) (0,2,3)"},
- {2, "FIXED_ALT", 0, "Fixed Alternate", "Split quads predictably (1,2,3) (1,3,0)"},
- {0, NULL, 0, NULL, NULL}
- };
-
static const EnumPropertyItem pixel_size_items[] = {
{0, "AUTO", 0, "Automatic", "Automatic pixel size, depends on the UI scale"},
{1, "1", 0, "1x", "Render at full resolution"},
@@ -5524,23 +4840,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem octree_resolution_items[] = {
- {64, "64", 0, "64", ""},
- {128, "128", 0, "128", ""},
- {256, "256", 0, "256", ""},
- {512, "512", 0, "512", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem raytrace_structure_items[] = {
- {R_RAYSTRUCTURE_AUTO, "AUTO", 0, "Auto", "Automatically select acceleration structure"},
- {R_RAYSTRUCTURE_OCTREE, "OCTREE", 0, "Octree", "Use old Octree structure"},
- {R_RAYSTRUCTURE_VBVH, "VBVH", 0, "vBVH", "Use vBVH"},
- {R_RAYSTRUCTURE_SIMD_SVBVH, "SIMD_SVBVH", 0, "SIMD SVBVH", "Use SIMD SVBVH"},
- {R_RAYSTRUCTURE_SIMD_QBVH, "SIMD_QBVH", 0, "SIMD QBVH", "Use SIMD QBVH"},
- {0, NULL, 0, NULL, NULL}
- };
-
static const EnumPropertyItem fixed_oversample_items[] = {
{5, "5", 0, "5", ""},
{8, "8", 0, "8", ""},
@@ -5548,19 +4847,18 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
{16, "16", 0, "16", ""},
{0, NULL, 0, NULL, NULL}
};
-
- static const EnumPropertyItem field_order_items[] = {
- {0, "EVEN_FIRST", 0, "Upper First", "Upper field first"},
- {R_ODDFIELD, "ODD_FIRST", 0, "Lower First", "Lower field first"},
- {0, NULL, 0, NULL, NULL}
- };
-
+
static const EnumPropertyItem threads_mode_items[] = {
{0, "AUTO", 0, "Auto-detect", "Automatically determine the number of threads, based on CPUs"},
{R_FIXED_THREADS, "FIXED", 0, "Fixed", "Manually determine the number of threads"},
{0, NULL, 0, NULL, NULL}
};
+ static const EnumPropertyItem engine_items[] = {
+ {0, "BLENDER_EEVEE", 0, "Eevee", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
static const EnumPropertyItem freestyle_thickness_items[] = {
{R_LINE_THICKNESS_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Specify unit line thickness in pixels"},
{R_LINE_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative",
@@ -5708,50 +5006,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"Amount of dithering noise added to the rendered image to break up banding");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "pixel_filter_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "filtertype");
- RNA_def_property_enum_items(prop, pixel_filter_items);
- RNA_def_property_ui_text(prop, "Pixel Filter", "Reconstruction filter used for combining anti-aliasing samples");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "filter_size", PROP_FLOAT, PROP_PIXEL);
- RNA_def_property_float_sdna(prop, NULL, "gauss");
- RNA_def_property_range(prop, 0.0f, 500.0f);
- RNA_def_property_ui_range(prop, 0.01f, 10.0f, 1, 2);
- RNA_def_property_ui_text(prop, "Filter Size", "Width over which the reconstruction filter combines samples");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
prop = RNA_def_property(srna, "alpha_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "alphamode");
RNA_def_property_enum_items(prop, alpha_mode_items);
RNA_def_property_ui_text(prop, "Alpha Mode", "Representation of alpha information in the RGBA pixels");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "octree_resolution", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "ocres");
- RNA_def_property_enum_items(prop, octree_resolution_items);
- RNA_def_property_ui_text(prop, "Octree Resolution",
- "Resolution of raytrace accelerator, use higher resolutions for larger scenes");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "raytrace_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "raytrace_structure");
- RNA_def_property_enum_items(prop, raytrace_structure_items);
- RNA_def_property_ui_text(prop, "Raytrace Acceleration Structure", "Type of raytrace accelerator structure");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "use_instances", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "raytrace_options", R_RAYTRACE_USE_INSTANCES);
- RNA_def_property_ui_text(prop, "Use Instances",
- "Instance support leads to effective memory reduction when using duplicates");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "use_local_coords", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "raytrace_options", R_RAYTRACE_USE_LOCAL_COORDS);
- RNA_def_property_ui_text(prop, "Use Local Coords",
- "Vertex coordinates are stored locally on each primitive "
- "(increases memory usage, but may have impact on speed)");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_OSA);
@@ -5764,73 +5023,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_enum_items(prop, fixed_oversample_items);
RNA_def_property_ui_text(prop, "Anti-Aliasing Samples", "Amount of anti-aliasing samples per pixel");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", R_FIELDS);
- RNA_def_property_ui_text(prop, "Fields", "Render image to two fields per frame, for interlaced TV output");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, field_order_items);
- RNA_def_property_ui_text(prop, "Field Order",
- "Order of video fields (select which lines get rendered first, "
- "to create smooth motion for TV output)");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "use_fields_still", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", R_FIELDSTILL);
- RNA_def_property_ui_text(prop, "Fields Still", "Disable the time difference between fields");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- /* rendering features */
- prop = RNA_def_property(srna, "use_shadows", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SHADOW);
- RNA_def_property_ui_text(prop, "Shadows", "Calculate shadows while rendering");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_envmaps", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", R_ENVMAP);
- RNA_def_property_ui_text(prop, "Environment Maps", "Calculate environment maps while rendering");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_sss", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SSS);
- RNA_def_property_ui_text(prop, "Subsurface Scattering", "Calculate sub-surface scattering in materials rendering");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
- prop = RNA_def_property(srna, "use_world_space_shading", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", R_USE_WS_SHADING);
- RNA_def_property_ui_text(prop, "World Space Shading", "Use world space interpretation of lighting data for node materials");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", R_RAYTRACE);
- RNA_def_property_ui_text(prop, "Raytracing",
- "Pre-calculate the raytrace accelerator and render raytracing effects");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
-
- prop = RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "scemode", R_NO_TEX);
- RNA_def_property_ui_text(prop, "Textures", "Use textures to affect material properties");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
-
- 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, "rna_Scene_glsl_update");
-
- 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, "rna_Scene_glsl_update");
-
- 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, "rna_Scene_glsl_update");
prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -5862,13 +5055,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
- prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "mblur_samples");
- RNA_def_property_range(prop, 1, 32);
- RNA_def_property_ui_text(prop, "Motion Samples", "Number of scene samples to take with motion blur");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
-
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "blurfac");
RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 2);
@@ -5885,12 +5071,8 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_border", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_BORDER);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Border",
- "Render a user-defined border region, within the frame size "
- "(note that this disables save_buffers and full_sample)");
+ RNA_def_property_ui_text(prop, "Border", "Render a user-defined border region, within the frame size ");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
-
prop = RNA_def_property(srna, "border_min_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "border.xmin");
@@ -5978,15 +5160,8 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Movie Format", "When true the format is a movie");
- prop = RNA_def_property(srna, "use_free_image_textures", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE);
- RNA_def_property_ui_text(prop, "Free Image Textures",
- "Free all image textures from memory after render, to save memory before compositing");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
prop = RNA_def_property(srna, "use_save_buffers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXR_TILE_FILE);
- RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_save_buffers_get", NULL);
RNA_def_property_ui_text(prop, "Save Buffers",
"Save tiles for all RenderLayers and SceneNodes to files in the temp directory "
"(saves memory, required for Full Sample)");
@@ -6034,46 +5209,17 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bake Mode", "Choose shading information to bake into the image");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "bake_normal_space", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "bake_normal_space");
- RNA_def_property_enum_items(prop, bake_normal_space_items);
- RNA_def_property_ui_text(prop, "Normal Space", "Choose normal space for baking");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "bake_quad_split", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, bake_qyad_split_items);
- RNA_def_property_ui_text(prop, "Quad Split", "Choose the method used to split a quad into 2 triangles for baking");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
- prop = RNA_def_property(srna, "bake_aa_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "bake_osa");
- RNA_def_property_enum_items(prop, fixed_oversample_items);
- RNA_def_property_ui_text(prop, "Anti-Aliasing Level", "");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
prop = RNA_def_property(srna, "use_bake_selected_to_active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_TO_ACTIVE);
RNA_def_property_ui_text(prop, "Selected to Active",
"Bake shading on the surface of selected objects to the active object");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "use_bake_normalize", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_NORMALIZE);
- RNA_def_property_ui_text(prop, "Normalized",
- "With displacement normalize to the distance, with ambient occlusion "
- "normalize without using material settings");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
prop = RNA_def_property(srna, "use_bake_clear", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_CLEAR);
RNA_def_property_ui_text(prop, "Clear", "Clear Images before baking");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "use_bake_antialiasing", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_OSA);
- RNA_def_property_ui_text(prop, "Anti-Aliasing", "Enables Anti-aliasing");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
prop = RNA_def_property(srna, "bake_margin", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "bake_filter");
RNA_def_property_range(prop, 0, 64);
@@ -6081,13 +5227,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
"Extends the baked result as a post process filter");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "bake_distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "bake_maxdist");
- RNA_def_property_range(prop, 0.0, 1000.0);
- RNA_def_property_ui_text(prop, "Distance",
- "Maximum distance from active object to other object (in blender units)");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
prop = RNA_def_property(srna, "bake_bias", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "bake_biasdist");
RNA_def_property_range(prop, 0.0, 1000.0);
@@ -6112,12 +5251,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Samples", "Number of samples used for ambient occlusion baking from multires");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- prop = RNA_def_property(srna, "use_bake_to_vertex_color", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_VCOL);
- RNA_def_property_ui_text(prop, "Bake to Vertex Color",
- "Bake to vertex colors instead of to a UV-mapped image");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
prop = RNA_def_property(srna, "use_bake_user_scale", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_USERSCALE);
RNA_def_property_ui_text(prop, "User scale", "Use a user scale for the derivative map");
@@ -6302,6 +5435,25 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop, NULL, "rna_RenderSettings_views_format_set", NULL);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ /* engine */
+ prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, engine_items);
+ RNA_def_property_enum_funcs(prop, "rna_RenderSettings_engine_get", "rna_RenderSettings_engine_set",
+ "rna_RenderSettings_engine_itemf");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering");
+ RNA_def_property_update(prop, NC_WINDOW, "rna_RenderSettings_engine_update");
+
+ prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_multiple_engines_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available");
+
+ prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_spherical_stereo_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Active render engine supports spherical stereo rendering");
+
/* simplify */
prop = RNA_def_property(srna, "use_simplify", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SIMPLIFY);
@@ -6330,21 +5482,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Simplify Child Particles", "Global child particles percentage during rendering");
RNA_def_property_update(prop, 0, "rna_Scene_simplify_update");
- prop = RNA_def_property(srna, "simplify_shadow_samples", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "simplify_shadowsamples");
- RNA_def_property_ui_range(prop, 1, 16, 1, -1);
- RNA_def_property_ui_text(prop, "Simplify Shadow Samples", "Global maximum shadow samples");
- RNA_def_property_update(prop, 0, "rna_Scene_simplify_update");
-
- prop = RNA_def_property(srna, "simplify_ao_sss", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "simplify_aosss");
- RNA_def_property_ui_text(prop, "Simplify AO and SSS", "Global approximate AO and SSS quality factor");
- RNA_def_property_update(prop, 0, "rna_Scene_simplify_update");
-
- prop = RNA_def_property(srna, "use_simplify_triangulate", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE);
- RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated");
-
/* persistent data */
prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_PERSISTENT_DATA);
@@ -6875,12 +6012,6 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "RenderSettings");
RNA_def_property_ui_text(prop, "Render Data", "");
- /* View Render */
- prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "ViewRenderSettings");
- RNA_def_property_ui_text(prop, "View Render", "");
-
/* Render Engine Data */
prop = RNA_def_property(srna, "layer_properties", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "layer_properties->data.group", NULL);
@@ -6908,6 +6039,20 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Timeline Markers", "Markers used in all timelines for the current scene");
rna_def_timeline_markers(brna, prop);
+ /* Orientations */
+ prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "orientation_type");
+ RNA_def_property_enum_items(prop, transform_orientation_items);
+ RNA_def_property_enum_funcs(prop, "rna_Scene_transform_orientation_get", "rna_Scene_transform_orientation_set",
+ "rna_TransformOrientation_itemf");
+ RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "TransformOrientation");
+ RNA_def_property_pointer_funcs(prop, "rna_Scene_current_orientation_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation");
+
/* Audio Settings */
prop = RNA_def_property(srna, "use_audio", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Scene_use_audio_get", "rna_Scene_use_audio_set");
@@ -6954,13 +6099,6 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE, NULL);
RNA_def_property_float_funcs(prop, NULL, "rna_Scene_volume_set", NULL);
- /* Game Settings */
- prop = RNA_def_property(srna, "game_settings", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "gm");
- RNA_def_property_struct_type(prop, "SceneGameData");
- RNA_def_property_ui_text(prop, "Game Data", "");
-
/* Statistics */
func = RNA_def_function(srna, "statistics", "ED_info_stats_string");
parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Active layer");
@@ -7024,7 +6162,7 @@ void RNA_def_scene(BlenderRNA *brna)
rna_def_statvis(brna);
rna_def_unit_settings(brna);
rna_def_scene_image_format_data(brna);
- rna_def_scene_game_data(brna);
+ rna_def_transform_orientation(brna);
rna_def_selected_uv_element(brna);
rna_def_display_safe_areas(brna);
RNA_define_animate_sdna(true);
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index d2afb43d65e..ca7d153066f 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -170,8 +170,9 @@ static void rna_Scene_ray_cast(
{
normalize_v3(direction);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
SnapObjectContext *sctx = ED_transform_snap_object_context_create(
- G.main, scene, view_layer, 0);
+ G.main, scene, depsgraph, 0);
bool ret = ED_transform_snap_object_project_ray_ex(
sctx,
@@ -359,7 +360,7 @@ void RNA_api_scene(StructRNA *srna)
RNA_def_boolean(func, "export_hair", 1, "Export Hair", "Exports hair particle systems as animated curves");
RNA_def_boolean(func, "export_particles", 1, "Export Particles", "Exports non-hair particle systems");
RNA_def_enum(func, "compression_type", rna_enum_abc_compression_items, 0, "Compression", "");
- RNA_def_boolean(func, "packuv" , 0, "Export with packed UV islands", "Export with packed UV islands");
+ RNA_def_boolean(func, "packuv", 0, "Export with packed UV islands", "Export with packed UV islands");
RNA_def_float(func, "scale", 1.0f, 0.0001f, 1000.0f, "Scale", "Value by which to enlarge or shrink the objects with respect to the world's origin", 0.0001f, 1000.0f);
RNA_def_boolean(func, "triangulate", 0, "Triangulate", "Export Polygons (Quads & NGons) as Triangles");
RNA_def_enum(func, "quad_method", rna_enum_modifier_triangulate_quad_method_items, 0, "Quad Method", "Method for splitting the quads into triangles");
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 97b89937081..cc711673c85 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -72,8 +72,10 @@ static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
{
bScreen *screen = (bScreen *)ptr->data;
- /* the settings for this are currently only available from a menu in the TimeLine, hence refresh=SPACE_TIME */
- ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_TIME);
+ /* the settings for this are currently only available from a menu in the TimeLine,
+ * hence refresh=SPACE_ACTION, as timeline is now in there
+ */
+ ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_ACTION);
}
static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))
@@ -83,6 +85,12 @@ static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))
return wm ? (ED_screen_animation_playing(wm) != NULL) : 0;
}
+static int rna_region_alignment_get(PointerRNA *ptr)
+{
+ ARegion *region = ptr->data;
+ return (region->alignment & ~RGN_SPLIT_PREV);
+}
+
static void rna_Screen_layout_name_get(PointerRNA *ptr, char *value)
{
const bScreen *screen = ptr->data;
@@ -130,10 +138,22 @@ static int rna_Screen_fullscreen_get(PointerRNA *ptr)
/* UI compatible list: should not be needed, but for now we need to keep EMPTY
* at least in the static version of this enum for python scripts. */
static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr),
- PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
+ PropertyRNA *UNUSED(prop), bool *r_free)
{
+ EnumPropertyItem *item = NULL;
+ int totitem = 0;
+
/* +1 to skip SPACE_EMPTY */
- return rna_enum_space_type_items + 1;
+ for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) {
+ if (ELEM(item_from->value, SPACE_TOPBAR)) {
+ continue;
+ }
+ RNA_enum_item_add(&item, &totitem, item_from);
+ }
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+
+ return item;
}
static int rna_Area_type_get(PointerRNA *ptr)
@@ -145,6 +165,13 @@ static int rna_Area_type_get(PointerRNA *ptr)
static void rna_Area_type_set(PointerRNA *ptr, int value)
{
+ if (ELEM(value, SPACE_TOPBAR)) {
+ /* Special case: An area can not be set to show the top-bar editor (or
+ * other global areas). However it should still be possible to identify
+ * its type from Python. */
+ return;
+ }
+
ScrArea *sa = (ScrArea *)ptr->data;
sa->butspacetype = value;
}
@@ -329,6 +356,19 @@ static void rna_def_region(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static const EnumPropertyItem alignment_types[] = {
+ {RGN_ALIGN_NONE, "NONE", 0, "None", "Don't use any fixed alignment, fill available space"},
+ {RGN_ALIGN_TOP, "TOP", 0, "Top", ""},
+ {RGN_ALIGN_BOTTOM, "BOTTOM", 0, "Bottom", ""},
+ {RGN_ALIGN_LEFT, "LEFT", 0, "Left", ""},
+ {RGN_ALIGN_RIGHT, "RIGHT", 0, "Right", ""},
+ {RGN_ALIGN_HSPLIT, "HORIZONTAL_SPLIT", 0, "Horizontal Split", ""},
+ {RGN_ALIGN_VSPLIT, "VERTICAL_SPLIT", 0, "Vertical Split", ""},
+ {RGN_ALIGN_FLOAT, "FLOAT", 0, "Float", "Region floats on screen, doesn't use any fixed alignment"},
+ {RGN_ALIGN_QSPLIT, "QUAD_SPLIT", 0, "Quad Split", "Region is split horizontally and vertically"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "Region", NULL);
RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area");
RNA_def_struct_sdna(srna, "ARegion");
@@ -365,6 +405,12 @@ static void rna_def_region(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "View2D", "2D view of the region");
+ prop = RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_enum_items(prop, alignment_types);
+ RNA_def_property_enum_funcs(prop, "rna_region_alignment_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Alignment", "Alignment of the region within the area");
+
RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw");
}
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 13833c86d9a..f9c5f682621 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -111,8 +111,6 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
#include "DEG_depsgraph.h"
-#include "GPU_buffers.h"
-
#include "ED_particle.h"
static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
@@ -388,7 +386,6 @@ static void rna_ImaPaint_mode_update(bContext *C, PointerRNA *UNUSED(ptr))
BKE_texpaint_slots_refresh_object(scene, ob);
/* we assume that changing the current mode will invalidate the uv layers so we need to refresh display */
- GPU_drawobject_free(ob->derivedFinal);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
}
@@ -401,7 +398,6 @@ static void rna_ImaPaint_stencil_update(bContext *C, PointerRNA *UNUSED(ptr))
Object *ob = OBACT(view_layer);
if (ob && ob->type == OB_MESH) {
- GPU_drawobject_free(ob->derivedFinal);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
}
@@ -433,7 +429,6 @@ static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr))
}
if (ob && ob->type == OB_MESH) {
- GPU_drawobject_free(ob->derivedFinal);
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
}
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
deleted file mode 100644
index 735df471721..00000000000
--- a/source/blender/makesrna/intern/rna_sensor.c
+++ /dev/null
@@ -1,939 +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.
- *
- * Contributor(s): Blender Foundation (2008).
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/makesrna/intern/rna_sensor.c
- * \ingroup RNA
- */
-
-#include <stdlib.h>
-
-#include "DNA_constraint_types.h"
-#include "DNA_object_types.h"
-#include "DNA_sensor_types.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_math.h"
-#include "BLI_string_utils.h"
-
-#include "BLT_translation.h"
-
-#include "RNA_define.h"
-#include "RNA_enum_types.h"
-#include "RNA_access.h"
-
-#include "rna_internal.h"
-
-#include "WM_types.h"
-
-/* Always keep in alphabetical order */
-static const EnumPropertyItem sensor_type_items[] = {
- {SENS_ACTUATOR, "ACTUATOR", 0, "Actuator", ""},
- {SENS_ALWAYS, "ALWAYS", 0, "Always", ""},
- {SENS_ARMATURE, "ARMATURE", 0, "Armature", ""},
- {SENS_COLLISION, "COLLISION", 0, "Collision", ""},
- {SENS_DELAY, "DELAY", 0, "Delay", ""},
- {SENS_JOYSTICK, "JOYSTICK", 0, "Joystick", ""},
- {SENS_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
- {SENS_MESSAGE, "MESSAGE", 0, "Message", ""},
- {SENS_MOUSE, "MOUSE", 0, "Mouse", ""},
- {SENS_NEAR, "NEAR", 0, "Near", ""},
- {SENS_PROPERTY, "PROPERTY", 0, "Property", ""},
- {SENS_RADAR, "RADAR", 0, "Radar", ""},
- {SENS_RANDOM, "RANDOM", 0, "Random", ""},
- {SENS_RAY, "RAY", 0, "Ray", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-#ifdef RNA_RUNTIME
-
-#include "BKE_sca.h"
-#include "DNA_controller_types.h"
-
-static StructRNA *rna_Sensor_refine(struct PointerRNA *ptr)
-{
- bSensor *sensor = (bSensor *)ptr->data;
-
- switch (sensor->type) {
- case SENS_ALWAYS:
- return &RNA_AlwaysSensor;
- case SENS_NEAR:
- return &RNA_NearSensor;
- case SENS_KEYBOARD:
- return &RNA_KeyboardSensor;
- case SENS_PROPERTY:
- return &RNA_PropertySensor;
- case SENS_ARMATURE:
- return &RNA_ArmatureSensor;
- case SENS_MOUSE:
- return &RNA_MouseSensor;
- case SENS_COLLISION:
- return &RNA_CollisionSensor;
- case SENS_RADAR:
- return &RNA_RadarSensor;
- case SENS_RANDOM:
- return &RNA_RandomSensor;
- case SENS_RAY:
- return &RNA_RaySensor;
- case SENS_MESSAGE:
- return &RNA_MessageSensor;
- case SENS_JOYSTICK:
- return &RNA_JoystickSensor;
- case SENS_ACTUATOR:
- return &RNA_ActuatorSensor;
- case SENS_DELAY:
- return &RNA_DelaySensor;
- default:
- return &RNA_Sensor;
- }
-}
-
-static void rna_Sensor_name_set(PointerRNA *ptr, const char *value)
-{
- Object *ob = ptr->id.data;
- bSensor *sens = ptr->data;
- BLI_strncpy_utf8(sens->name, value, sizeof(sens->name));
- BLI_uniquename(&ob->sensors, sens, DATA_("Sensor"), '.', offsetof(bSensor, name), sizeof(sens->name));
-}
-
-static void rna_Sensor_type_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
- if (value != sens->type) {
- sens->type = value;
- init_sensor(sens);
- }
-}
-
-/* Always keep in alphabetical order */
-
-static void rna_Sensor_controllers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- bSensor *sens = (bSensor *)ptr->data;
- rna_iterator_array_begin(iter, sens->links, sizeof(bController *), (int)sens->totlinks, 0, NULL);
-}
-
-static int rna_Sensor_controllers_length(PointerRNA *ptr)
-{
- bSensor *sens = (bSensor *)ptr->data;
- return (int) sens->totlinks;
-}
-
-const EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
-{
- EnumPropertyItem *item = NULL;
- Object *ob = NULL;
- int totitem = 0;
-
- if (ptr->type == &RNA_Sensor || RNA_struct_is_a(ptr->type, &RNA_Sensor)) {
- ob = (Object *)ptr->id.data;
- }
- else {
- /* can't use ob from ptr->id.data because that enum is also used by operators */
- ob = CTX_data_active_object(C);
- }
-
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ACTUATOR);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ALWAYS);
-
- if (ob != NULL) {
- if (ob->type == OB_ARMATURE) {
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ARMATURE);
- }
- }
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_COLLISION);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_DELAY);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_JOYSTICK);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_KEYBOARD);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MESSAGE);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MOUSE);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_NEAR);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_PROPERTY);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RADAR);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RANDOM);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RAY);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH);
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
-static void rna_Sensor_keyboard_key_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
- bKeyboardSensor *ks = (bKeyboardSensor *)sens->data;
-
- if (ISKEYBOARD(value))
- ks->key = value;
- else
- ks->key = 0;
-}
-
-static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
- bKeyboardSensor *ks = (bKeyboardSensor *)sens->data;
-
- if (ISKEYBOARD(value))
- ks->qual = value;
- else
- ks->qual = 0;
-}
-
-static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
- bKeyboardSensor *ks = (bKeyboardSensor *)sens->data;
-
- if (ISKEYBOARD(value))
- ks->qual2 = value;
- else
- ks->qual2 = 0;
-}
-
-static void rna_Sensor_tap_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
-
- sens->tap = value;
- if (sens->tap == 1)
- sens->level = 0;
-}
-
-static void rna_Sensor_level_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
-
- sens->level = value;
- if (sens->level == 1)
- sens->tap = 0;
-}
-
-static void rna_Sensor_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- bSensor *sens = (bSensor *)ptr->data;
- bArmatureSensor *as = sens->data;
- Object *ob = (Object *)ptr->id.data;
-
- char *posechannel = as->posechannel;
- char *constraint = as->constraint;
-
- /* check that bone exist in the active object */
- if (ob->type == OB_ARMATURE && ob->pose) {
- bPoseChannel *pchan;
- bPose *pose = ob->pose;
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- if (STREQ(pchan->name, posechannel)) {
- /* found it, now look for constraint channel */
- bConstraint *con;
- for (con = pchan->constraints.first; con; con = con->next) {
- if (STREQ(con->name, constraint)) {
- /* found it, all ok */
- return;
- }
- }
- /* didn't find constraint, make empty */
- constraint[0] = 0;
- return;
- }
- }
- }
- /* didn't find any */
- posechannel[0] = 0;
- constraint[0] = 0;
-}
-#else
-
-static void rna_def_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "Sensor", NULL);
- RNA_def_struct_ui_text(srna, "Sensor", "Game engine logic brick to detect events");
- RNA_def_struct_sdna(srna, "bSensor");
- RNA_def_struct_refine_func(srna, "rna_Sensor_refine");
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Name", "Sensor name");
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Sensor_name_set");
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_enum_items(prop, sensor_type_items);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_type_set", "rna_Sensor_type_itemf");
- RNA_def_property_ui_text(prop, "Type", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "pin", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_PIN);
- RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller");
- RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SENS_DEACTIVATE);
- RNA_def_property_ui_text(prop, "Active", "Set active state of the sensor");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_SHOW);
- RNA_def_property_ui_text(prop, "Expanded", "Set sensor expanded in the user interface");
- RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_ui_text(prop, "Invert Output", "Invert the level(output) of this sensor");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_level", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "level", 1);
- RNA_def_property_ui_text(prop, "Level",
- "Level detector, trigger controllers of new states "
- "(only applicable upon logic state transition)");
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Sensor_level_set");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_pulse_true_level", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pulse", SENS_PULSE_REPEAT);
- RNA_def_property_ui_text(prop, "Pulse True Level", "Activate TRUE level triggering (pulse mode)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_pulse_false_level", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pulse", SENS_NEG_PULSE_MODE);
- RNA_def_property_ui_text(prop, "Pulse False Level", "Activate FALSE level triggering (pulse mode)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "tick_skip", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "freq");
- RNA_def_property_ui_text(prop, "Skip",
- "Number of logic ticks skipped between 2 active pulses "
- "(0 = pulse every logic tick, 1 = skip 1 logic tick between pulses, etc.)");
- RNA_def_property_range(prop, 0, 10000);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_tap", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "tap", 1);
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Sensor_tap_set");
- RNA_def_property_ui_text(prop, "Tap",
- "Trigger controllers only for an instant, even while the sensor remains true");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "links", NULL);
- RNA_def_property_struct_type(prop, "Controller");
- RNA_def_property_ui_text(prop, "Controllers", "The list containing the controllers connected to the sensor");
- RNA_def_property_collection_funcs(prop, "rna_Sensor_controllers_begin", "rna_iterator_array_next",
- "rna_iterator_array_end", "rna_iterator_array_dereference_get",
- "rna_Sensor_controllers_length", NULL, NULL, NULL);
-
-
- RNA_api_sensor(srna);
-}
-
-static void rna_def_always_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- srna = RNA_def_struct(brna, "AlwaysSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Always Sensor", "Sensor to generate continuous pulses");
-}
-
-static void rna_def_near_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "NearSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Near Sensor", "Sensor to detect nearby objects");
- RNA_def_struct_sdna_from(srna, "bNearSensor", "data");
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "dist");
- RNA_def_property_ui_text(prop, "Distance", "Trigger distance");
- RNA_def_property_range(prop, 0.0f, 10000.0f);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "reset_distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "resetdist");
- RNA_def_property_ui_text(prop, "Reset Distance", "The distance where the sensor forgets the actor");
- RNA_def_property_range(prop, 0.0f, 10000.0f);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_mouse_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem mouse_event_items[] = {
- {BL_SENS_MOUSE_LEFT_BUTTON, "LEFTCLICK", 0, "Left Button", ""},
- {BL_SENS_MOUSE_MIDDLE_BUTTON, "MIDDLECLICK", 0, "Middle Button", ""},
- {BL_SENS_MOUSE_RIGHT_BUTTON, "RIGHTCLICK", 0, "Right Button", ""},
- {BL_SENS_MOUSE_WHEEL_UP, "WHEELUP", 0, "Wheel Up", ""},
- {BL_SENS_MOUSE_WHEEL_DOWN, "WHEELDOWN", 0, "Wheel Down", ""},
- {BL_SENS_MOUSE_MOVEMENT, "MOVEMENT", 0, "Movement", ""},
- {BL_SENS_MOUSE_MOUSEOVER, "MOUSEOVER", 0, "Mouse Over", ""},
- {BL_SENS_MOUSE_MOUSEOVER_ANY, "MOUSEOVERANY", 0, "Mouse Over Any", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_mouse_type_items[] = {
- {SENS_COLLISION_PROPERTY, "PROPERTY", ICON_LOGIC, "Property", "Use a property for ray intersections"},
- {SENS_COLLISION_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Use a material for ray intersections"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "MouseSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Mouse Sensor", "Sensor to detect mouse events");
- RNA_def_struct_sdna_from(srna, "bMouseSensor", "data");
-
- prop = RNA_def_property(srna, "mouse_event", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, mouse_event_items);
- RNA_def_property_ui_text(prop, "Mouse Event", "Type of event this mouse sensor should trigger on");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_pulse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_MOUSE_FOCUS_PULSE);
- RNA_def_property_ui_text(prop, "Pulse", "Moving the mouse over a different object generates a pulse");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_material", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, prop_mouse_type_items);
- RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "propname");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "matname");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_x_ray", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_RAY_XRAY);
- RNA_def_property_ui_text(prop, "X-Ray", "Toggle X-Ray option (see through objects that don't have the property)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_keyboard_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "KeyboardSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Keyboard Sensor", "Sensor to detect keyboard events");
- RNA_def_struct_sdna_from(srna, "bKeyboardSensor", "data");
-
- prop = RNA_def_property(srna, "key", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "key");
- RNA_def_property_enum_items(prop, rna_enum_event_type_items);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_key_set", NULL);
- RNA_def_property_ui_text(prop, "Key", "");
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_WINDOWMANAGER);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "modifier_key_1", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "qual");
- RNA_def_property_enum_items(prop, rna_enum_event_type_items);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier_set", NULL);
- RNA_def_property_ui_text(prop, "Modifier Key", "Modifier key code");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "modifier_key_2", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "qual2");
- RNA_def_property_enum_items(prop, rna_enum_event_type_items);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier2_set", NULL);
- RNA_def_property_ui_text(prop, "Second Modifier Key", "Modifier key code");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "target", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "targetName");
- RNA_def_property_ui_text(prop, "Target", "Property that receives the keystrokes in case a string is logged");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "log", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "toggleName");
- RNA_def_property_ui_text(prop, "Log Toggle", "Property that indicates whether to log keystrokes as a string");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_all_keys", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "type", 1);
- RNA_def_property_ui_text(prop, "All Keys", "Trigger this sensor on any keystroke");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_property_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static const EnumPropertyItem prop_type_items[] = {
- {SENS_PROP_EQUAL, "PROPEQUAL", 0, "Equal", ""},
- {SENS_PROP_NEQUAL, "PROPNEQUAL", 0, "Not Equal", ""},
- {SENS_PROP_INTERVAL, "PROPINTERVAL", 0, "Interval", ""},
- {SENS_PROP_CHANGED, "PROPCHANGED", 0, "Changed", ""},
- /* {SENS_PROP_EXPRESSION, "PROPEXPRESSION", 0, "Expression", ""}, NOT_USED_IN_UI */
- {SENS_PROP_LESSTHAN, "PROPLESSTHAN", 0, "Less Than", ""},
- {SENS_PROP_GREATERTHAN, "PROPGREATERTHAN", 0, "Greater Than", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "PropertySensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Property Sensor", "Sensor to detect values and changes in values of properties");
- RNA_def_struct_sdna_from(srna, "bPropertySensor", "data");
-
- prop = RNA_def_property(srna, "evaluation_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Evaluation Type", "Type of property evaluation");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "value");
- RNA_def_property_ui_text(prop, "Value", "Check for this value in types in Equal, Not Equal, Less Than and Greater Than types");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "value_min", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "value");
- RNA_def_property_ui_text(prop, "Minimum Value", "Minimum value in Interval type");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "value_max", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "maxvalue");
- RNA_def_property_ui_text(prop, "Maximum Value", "Maximum value in Interval type");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_armature_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static const EnumPropertyItem prop_type_items[] = {
- {SENS_ARM_STATE_CHANGED, "STATECHG", 0, "State Changed", ""},
- {SENS_ARM_LIN_ERROR_BELOW, "LINERRORBELOW", 0, "Lin error below", ""},
- {SENS_ARM_LIN_ERROR_ABOVE, "LINERRORABOVE", 0, "Lin error above", ""},
- {SENS_ARM_ROT_ERROR_BELOW, "ROTERRORBELOW", 0, "Rot error below", ""},
- {SENS_ARM_ROT_ERROR_ABOVE, "ROTERRORABOVE", 0, "Rot error above", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "ArmatureSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Armature Sensor", "Sensor to detect values and changes in values of IK solver");
- RNA_def_struct_sdna_from(srna, "bArmatureSensor", "data");
-
- prop = RNA_def_property(srna, "test_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Test", "Type of value and test");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "bone", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "posechannel");
- RNA_def_property_ui_text(prop, "Bone Name", "Identify the bone to check value from");
- RNA_def_property_update(prop, NC_LOGIC, "rna_Sensor_Armature_update");
-
- prop = RNA_def_property(srna, "constraint", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "constraint");
- RNA_def_property_ui_text(prop, "Constraint Name", "Identify the bone constraint to check value from");
- RNA_def_property_update(prop, NC_LOGIC, "rna_Sensor_Armature_update");
-
- prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "value");
- RNA_def_property_ui_text(prop, "Compare Value", "Value to be used in comparison");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_actuator_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "ActuatorSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Actuator Sensor", "Sensor to detect state modifications of actuators");
- RNA_def_struct_sdna_from(srna, "bActuatorSensor", "data");
-
- /* XXX if eventually have Logics using RNA 100%, we could use the actuator data-block isntead of its name */
- prop = RNA_def_property(srna, "actuator", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Actuator", "Actuator name, actuator active state modifications will be detected");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_delay_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "DelaySensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Delay Sensor", "Sensor to send delayed events");
- RNA_def_struct_sdna_from(srna, "bDelaySensor", "data");
-
- prop = RNA_def_property(srna, "delay", PROP_INT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Delay",
- "Delay in number of logic tics before the positive trigger (default 60 per second)");
- RNA_def_property_range(prop, 0, 5000);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "duration", PROP_INT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Duration",
- "If >0, delay in number of logic tics before the negative trigger following "
- "the positive trigger");
- RNA_def_property_range(prop, 0, 5000);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_repeat", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_DELAY_REPEAT);
- RNA_def_property_ui_text(prop, "Repeat",
- "Toggle repeat option (if selected, the sensor restarts after Delay+Duration "
- "logic tics)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_collision_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "CollisionSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Collision Sensor",
- "Sensor to detect objects colliding with the current object, with more settings than "
- "the Touch sensor");
- RNA_def_struct_sdna_from(srna, "bCollisionSensor", "data");
-
- prop = RNA_def_property(srna, "use_pulse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_PULSE);
- RNA_def_property_ui_text(prop, "Pulse", "Change to the set of colliding objects generates pulse");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_MATERIAL);
- RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /*XXX to make a setFunction to create a lookup with all materials in Blend File (not only this object mat.) */
- prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "materialName");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
-#if 0
- /* XXX either use a data-block look up to store the string name (material)
- * or to do a doversion and use a material pointer. */
- prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Material");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_pointer_sdna(prop, NULL, "ma");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
-#endif
-}
-
-static void rna_def_radar_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static const EnumPropertyItem axis_items[] = {
- {SENS_RADAR_X_AXIS, "XAXIS", 0, "+X axis", ""},
- {SENS_RADAR_Y_AXIS, "YAXIS", 0, "+Y axis", ""},
- {SENS_RADAR_Z_AXIS, "ZAXIS", 0, "+Z axis", ""},
- {SENS_RADAR_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""},
- {SENS_RADAR_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""},
- {SENS_RADAR_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "RadarSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Radar Sensor",
- "Sensor to detect objects in a cone shaped radar emanating from the current object");
- RNA_def_struct_sdna_from(srna, "bRadarSensor", "data");
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, axis_items);
- RNA_def_property_ui_text(prop, "Axis", "Along which axis the radar cone is cast");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_range(prop, 0.0, DEG2RADF(179.9f));
- RNA_def_property_ui_text(prop, "Angle", "Opening angle of the radar cone");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "range");
- RNA_def_property_range(prop, 0.0, 10000.0);
- RNA_def_property_ui_text(prop, "Distance", "Depth of the radar cone");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_random_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "RandomSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Random Sensor", "Sensor to send random events");
- RNA_def_struct_sdna_from(srna, "bRandomSensor", "data");
-
- prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, 1000);
- RNA_def_property_ui_text(prop, "Seed", "Initial seed of the generator (choose 0 for not random)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_ray_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static const EnumPropertyItem axis_items[] = {
- {SENS_RAY_X_AXIS, "XAXIS", 0, "+X axis", ""},
- {SENS_RAY_Y_AXIS, "YAXIS", 0, "+Y axis", ""},
- {SENS_RAY_Z_AXIS, "ZAXIS", 0, "+Z axis", ""},
- {SENS_RAY_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""},
- {SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""},
- {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_ray_type_items[] = {
- {SENS_COLLISION_PROPERTY, "PROPERTY", ICON_LOGIC, "Property", "Use a property for ray intersections"},
- {SENS_COLLISION_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Use a material for ray intersections"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "RaySensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Ray Sensor",
- "Sensor to detect intersections with a ray emanating from the current object");
- RNA_def_struct_sdna_from(srna, "bRaySensor", "data");
-
- prop = RNA_def_property(srna, "ray_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, prop_ray_type_items);
- RNA_def_property_ui_text(prop, "Ray Type", "Toggle collision on material or property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "propname");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "matname");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
-#if 0
- /* XXX either use a data-block look up to store the string name (material)
- * or to do a doversion and use a material pointer. */
- prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Material");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_pointer_sdna(prop, NULL, "ma");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
-#endif
-
- prop = RNA_def_property(srna, "use_x_ray", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_RAY_XRAY);
- RNA_def_property_ui_text(prop, "X-Ray Mode",
- "Toggle X-Ray option (see through objects that don't have the property)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.01, 10000.0);
- RNA_def_property_ui_text(prop, "Range", "Sense objects no farther than this distance");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "axisflag");
- RNA_def_property_enum_items(prop, axis_items);
- RNA_def_property_ui_text(prop, "Axis", "Along which axis the ray is cast");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_message_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MessageSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Message Sensor", "Sensor to detect incoming messages");
- RNA_def_struct_sdna_from(srna, "bMessageSensor", "data");
-
- prop = RNA_def_property(srna, "subject", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Subject",
- "Optional subject filter: only accept messages with this subject, "
- "or empty to accept all");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_joystick_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem event_type_joystick_items[] = {
- {SENS_JOY_BUTTON, "BUTTON", 0, "Button", ""},
- {SENS_JOY_AXIS, "AXIS", 0, "Axis", ""},
- {SENS_JOY_HAT, "HAT", 0, "Hat", ""},
- {SENS_JOY_AXIS_SINGLE, "AXIS_SINGLE", 0, "Single Axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem axis_direction_items[] = {
- {SENS_JOY_X_AXIS, "RIGHTAXIS", 0, "Right Axis", ""},
- {SENS_JOY_Y_AXIS, "UPAXIS", 0, "Up Axis", ""},
- {SENS_JOY_NEG_X_AXIS, "LEFTAXIS", 0, "Left Axis", ""},
- {SENS_JOY_NEG_Y_AXIS, "DOWNAXIS", 0, "Down Axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem hat_direction_items[] = {
- {SENS_JOY_HAT_UP, "UP", 0, "Up", ""},
- {SENS_JOY_HAT_DOWN, "DOWN", 0, "Down", ""},
- {SENS_JOY_HAT_LEFT, "LEFT", 0, "Left", ""},
- {SENS_JOY_HAT_RIGHT, "RIGHT", 0, "Right", ""},
-
- {SENS_JOY_HAT_UP_RIGHT, "UPRIGHT", 0, "Up/Right", ""},
- {SENS_JOY_HAT_DOWN_LEFT, "DOWNLEFT", 0, "Down/Left", ""},
- {SENS_JOY_HAT_UP_LEFT, "UPLEFT", 0, "Up/Left", ""},
- {SENS_JOY_HAT_DOWN_RIGHT, "DOWNRIGHT", 0, "Down/Right", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "JoystickSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Joystick Sensor", "Sensor to detect joystick events");
- RNA_def_struct_sdna_from(srna, "bJoystickSensor", "data");
-
- prop = RNA_def_property(srna, "joystick_index", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "joyindex");
- RNA_def_property_ui_text(prop, "Index", "Which joystick to use");
- RNA_def_property_range(prop, 0, SENS_JOY_MAXINDEX - 1);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "event_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, event_type_joystick_items);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
- RNA_def_property_ui_text(prop, "Event Type", "The type of event this joystick sensor is triggered on");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_all_events", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_JOY_ANY_EVENT);
- RNA_def_property_ui_text(prop, "All Events",
- "Triggered by all events on this joystick's current type (axis/button/hat)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Button */
- prop = RNA_def_property(srna, "button_number", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "button");
- RNA_def_property_ui_text(prop, "Button Number", "Which button to use");
- RNA_def_property_range(prop, 0, 18);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Axis */
- prop = RNA_def_property(srna, "axis_number", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "axis");
- RNA_def_property_ui_text(prop, "Axis Number", "Which axis pair to use, 1 is usually the main direction input");
- RNA_def_property_range(prop, 1, 8);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "axis_threshold", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "precision");
- RNA_def_property_ui_text(prop, "Axis Threshold", "Precision of the axis");
- RNA_def_property_range(prop, 0, 32768);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "axis_direction", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "axisf");
- RNA_def_property_enum_items(prop, axis_direction_items);
- RNA_def_property_ui_text(prop, "Axis Direction", "The direction of the axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Single Axis */
- prop = RNA_def_property(srna, "single_axis_number", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "axis_single");
- RNA_def_property_ui_text(prop, "Axis Number", "Single axis (vertical/horizontal/other) to detect");
- RNA_def_property_range(prop, 1, 16);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Hat */
- prop = RNA_def_property(srna, "hat_number", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "hat");
- RNA_def_property_ui_text(prop, "Hat Number", "Which hat to use");
- RNA_def_property_range(prop, 1, 2);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "hat_direction", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "hatf");
- RNA_def_property_enum_items(prop, hat_direction_items);
- RNA_def_property_ui_text(prop, "Hat Direction", "Hat direction");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-void RNA_def_sensor(BlenderRNA *brna)
-{
- rna_def_sensor(brna);
-
- rna_def_always_sensor(brna);
- rna_def_near_sensor(brna);
- rna_def_mouse_sensor(brna);
- rna_def_keyboard_sensor(brna);
- rna_def_property_sensor(brna);
- rna_def_armature_sensor(brna);
- rna_def_actuator_sensor(brna);
- rna_def_delay_sensor(brna);
- rna_def_collision_sensor(brna);
- rna_def_radar_sensor(brna);
- rna_def_random_sensor(brna);
- rna_def_ray_sensor(brna);
- rna_def_message_sensor(brna);
- rna_def_joystick_sensor(brna);
-}
-
-#endif
diff --git a/source/blender/makesrna/intern/rna_sensor_api.c b/source/blender/makesrna/intern/rna_sensor_api.c
deleted file mode 100644
index b0c4109b1df..00000000000
--- a/source/blender/makesrna/intern/rna_sensor_api.c
+++ /dev/null
@@ -1,79 +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):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/makesrna/intern/rna_sensor_api.c
- * \ingroup RNA
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "BLI_utildefines.h"
-
-#include "RNA_define.h"
-
-#include "rna_internal.h" /* own include */
-
-#include "WM_types.h"
-
-#ifdef RNA_RUNTIME
-
-#include "BKE_sca.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-
-static void rna_Sensor_link(bSensor *sens, bController *cont)
-{
- link_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks, sizeof(bController *));
-}
-
-static void rna_Sensor_unlink(bSensor *sens, bController *cont)
-{
- unlink_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks);
-}
-
-#else
-
-void RNA_api_sensor(StructRNA *srna)
-{
- FunctionRNA *func;
- PropertyRNA *parm;
-
- func = RNA_def_function(srna, "link", "rna_Sensor_link");
- RNA_def_function_ui_description(func, "Link the sensor to a controller");
- parm = RNA_def_pointer(func, "controller", "Controller", "", "Controller to link to");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_property_update(parm, NC_LOGIC, NULL);
-
- func = RNA_def_function(srna, "unlink", "rna_Sensor_unlink");
- RNA_def_function_ui_description(func, "Unlink the sensor from a controller");
- parm = RNA_def_pointer(func, "controller", "Controller", "", "Controller to unlink from");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_property_update(parm, NC_LOGIC, NULL);
-}
-
-#endif
-
diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c
index 6aacede5816..0c1391fd2f7 100644
--- a/source/blender/makesrna/intern/rna_sound.c
+++ b/source/blender/makesrna/intern/rna_sound.c
@@ -32,7 +32,6 @@
#include "rna_internal.h"
#include "DNA_sound_types.h"
-#include "DNA_property_types.h"
#ifdef RNA_RUNTIME
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 2d8385a5f83..8f95daf9f69 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -75,7 +75,7 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
/* Animation */
{0, "", ICON_NONE, "Animation", ""},
- {SPACE_TIME, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls"},
+ //{SPACE_ACTION, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls (NOTE: Switch to 'Timeline' mode)"}, /* XXX */
{SPACE_IPO, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", "Edit drivers and keyframe interpolation"},
{SPACE_ACTION, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", "Adjust timing of keyframes"},
{SPACE_NLA, "NLA_EDITOR", ICON_NLA, "NLA Editor", "Combine and layer Actions"},
@@ -83,11 +83,12 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
/* Scripting */
{0, "", ICON_NONE, "Scripting", ""},
{SPACE_TEXT, "TEXT_EDITOR", ICON_TEXT, "Text Editor", "Edit scripts and in-file documentation"},
- {SPACE_LOGIC, "LOGIC_EDITOR", ICON_LOGIC, "Logic Editor", "Game logic editing"},
{SPACE_CONSOLE, "CONSOLE", ICON_CONSOLE, "Python Console", "Interactive programmatic console for "
"advanced editing and script development"},
{SPACE_INFO, "INFO", ICON_INFO, "Info", "Main menu bar and list of error messages "
"(drag down to expand and display)"},
+ /* Special case: Top-bar isn't supposed to be a regular editor for the user. */
+ {SPACE_TOPBAR, "TOPBAR", ICON_NONE, "Top Bar", "Global bar at the top of the screen for global per-window settings"},
/* Data */
{0, "", ICON_NONE, "Data", ""},
@@ -159,18 +160,6 @@ static const EnumPropertyItem draw_channels_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static const EnumPropertyItem transform_orientation_items[] = {
- {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", "Align the transformation axes to world space"},
- {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", "Align the transformation axes to the selected objects' local space"},
- {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal",
- "Align the transformation axes to average normal of selected elements "
- "(bone Y axis for pose mode)"},
- {V3D_MANIP_GIMBAL, "GIMBAL", 0, "Gimbal", "Align each axis to the Euler rotation axis as used for input"},
- {V3D_MANIP_VIEW, "VIEW", 0, "View", "Align the transformation axes to the window"},
- // {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"},
- {0, NULL, 0, NULL, NULL}
-};
-
#ifndef RNA_RUNTIME
static const EnumPropertyItem autosnap_items[] = {
{SACTSNAP_OFF, "NONE", 0, "No Auto-Snap", ""},
@@ -187,15 +176,20 @@ static const EnumPropertyItem autosnap_items[] = {
#endif
const EnumPropertyItem rna_enum_viewport_shade_items[] = {
- {OB_BOUNDBOX, "BOUNDBOX", ICON_BBOX, "Bounding Box", "Display the object's local bounding boxes only"},
{OB_WIRE, "WIREFRAME", ICON_WIRE, "Wireframe", "Display the object as wire edges"},
- {OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display the object solid, lit with default OpenGL lights"},
+ {OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display the object solid"},
{OB_TEXTURE, "TEXTURED", ICON_POTATO, "Texture", "Display the object solid, with a texture"},
{OB_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Display objects solid, with GLSL material"},
{OB_RENDER, "RENDERED", ICON_SMOOTH, "Rendered", "Display render preview"},
{0, NULL, 0, NULL, NULL}
};
+const EnumPropertyItem rna_enum_viewport_lighting_items[] = {
+ {V3D_LIGHTING_FLAT, "FLAT", 0, "Flat Lighting", "Display using flat lighting"},
+ {V3D_LIGHTING_STUDIO, "STUDIO", 0, "Studio Lighting", "Display using studio lighting"},
+ /* {V3D_LIGHTING_SCENE, "SCENE", 0, "Scene Lighting", "Display using scene lighting"}, */
+ {0, NULL, 0, NULL, NULL}
+};
const EnumPropertyItem rna_enum_clip_editor_mode_items[] = {
{SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"},
@@ -224,17 +218,6 @@ static const EnumPropertyItem buttons_context_items[] = {
{0, NULL, 0, NULL, NULL}
};
-/* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */
-static const EnumPropertyItem buttons_texture_context_items[] = {
- {SB_TEXC_MATERIAL, "MATERIAL", ICON_MATERIAL, "", "Show material textures"},
- {SB_TEXC_WORLD, "WORLD", ICON_WORLD, "", "Show world textures"},
- {SB_TEXC_LAMP, "LAMP", ICON_LAMP, "", "Show lamp textures"},
- {SB_TEXC_PARTICLES, "PARTICLES", ICON_PARTICLES, "", "Show particles textures"},
- {SB_TEXC_LINESTYLE, "LINESTYLE", ICON_LINE_DATA, "", "Show linestyle textures"},
- {SB_TEXC_OTHER, "OTHER", ICON_TEXTURE, "", "Show other data textures"},
- {0, NULL, 0, NULL, NULL}
-};
-
static const EnumPropertyItem buttons_collection_context_items[] = {
{SB_COLLECTION_CTX_VIEW_LAYER, "VIEW_LAYER", ICON_RENDERLAYERS, "", "Show material textures"},
{SB_COLLECTION_CTX_GROUP, "GROUP", ICON_GROUP, "", "Show world textures"},
@@ -327,12 +310,8 @@ static StructRNA *rna_Space_refine(struct PointerRNA *ptr)
return &RNA_SpaceDopeSheetEditor;
case SPACE_NLA:
return &RNA_SpaceNLA;
- case SPACE_TIME:
- return &RNA_SpaceTimeline;
case SPACE_NODE:
return &RNA_SpaceNodeEditor;
- case SPACE_LOGIC:
- return &RNA_SpaceLogicEditor;
case SPACE_CONSOLE:
return &RNA_SpaceConsole;
case SPACE_USERPREF:
@@ -427,77 +406,6 @@ static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), Scene *UNUSED(scen
}
}
-static int rna_View3D_transform_orientation_get(PointerRNA *ptr)
-{
- const View3D *v3d = (View3D *)ptr->data;
- /* convert to enum value */
- return (v3d->twmode == V3D_MANIP_CUSTOM) ? (v3d->twmode + v3d->custom_orientation_index) : v3d->twmode;
-}
-
-void rna_View3D_transform_orientation_set(PointerRNA *ptr, int value)
-{
- View3D *v3d = (View3D *)ptr->data;
- BIF_selectTransformOrientationValue(v3d, value);
-}
-
-static PointerRNA rna_View3D_current_orientation_get(PointerRNA *ptr)
-{
- View3D *v3d = (View3D *)ptr->data;
- TransformOrientation *orientation;
-
- if (v3d->twmode < V3D_MANIP_CUSTOM) {
- orientation = NULL;
- }
- else {
- WorkSpace *workspace;
- bScreen *screen = ptr->id.data;
-
- BKE_workspace_layout_find_global(G.main, screen, &workspace);
- orientation = BKE_workspace_transform_orientation_find(workspace, v3d->custom_orientation_index);
- }
-
- return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, orientation);
-}
-
-const EnumPropertyItem *rna_TransformOrientation_itemf(
- bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
-{
- WorkSpace *workspace;
- ListBase *transform_orientations;
- EnumPropertyItem tmp = {0, "", 0, "", ""};
- EnumPropertyItem *item = NULL;
- int i = V3D_MANIP_CUSTOM, totitem = 0;
-
- RNA_enum_items_add(&item, &totitem, transform_orientation_items);
-
- if (ptr->type == &RNA_SpaceView3D) {
- bScreen *screen = ptr->id.data;
- BKE_workspace_layout_find_global(G.main, screen, &workspace);
- }
- else {
- /* can't use scene from ptr->id.data because that enum is also used by operators */
- workspace = C ? CTX_wm_workspace(C) : NULL;
- }
-
- transform_orientations = workspace ? BKE_workspace_transform_orientations_get(workspace) : NULL;
-
- if (transform_orientations && (BLI_listbase_is_empty(transform_orientations) == false)) {
- RNA_enum_item_add_separator(&item, &totitem);
-
- for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) {
- tmp.identifier = ts->name;
- tmp.name = ts->name;
- tmp.value = i++;
- RNA_enum_item_add(&item, &totitem, &tmp);
- }
- }
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
/* Space 3D View */
static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
@@ -744,20 +652,22 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value
static int rna_SpaceView3D_viewport_shade_get(PointerRNA *ptr)
{
bScreen *screen = ptr->id.data;
-
Scene *scene = WM_windows_scene_get_from_screen(G.main->wm.first, screen);
- WorkSpace *workspace = WM_windows_workspace_get_from_screen(G.main->wm.first, screen);
-
- ViewRender *view_render = BKE_viewrender_get(scene, workspace);
- RenderEngineType *type = RE_engines_find(view_render->engine_id);
-
+ RenderEngineType *type = RE_engines_find(scene->r.engine);
View3D *v3d = (View3D *)ptr->data;
- int drawtype = v3d->drawtype;
- if (drawtype == OB_RENDER && !(type && type->render_to_view))
- return OB_SOLID;
+ if (BKE_scene_uses_blender_eevee(scene)) {
+ if (v3d->drawtype == OB_MATERIAL) {
+ return OB_RENDER;
+ }
+ }
+ else if (v3d->drawtype == OB_RENDER) {
+ if (!(type && type->render_to_view)) {
+ return OB_MATERIAL;
+ }
+ }
- return drawtype;
+ return v3d->drawtype;
}
static void rna_SpaceView3D_viewport_shade_set(PointerRNA *ptr, int value)
@@ -769,26 +679,28 @@ static void rna_SpaceView3D_viewport_shade_set(PointerRNA *ptr, int value)
v3d->drawtype = value;
}
-static const EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *C, PointerRNA *UNUSED(ptr),
- PropertyRNA *UNUSED(prop), bool *r_free)
+static const EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(
+ bContext *C, PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop), bool *r_free)
{
wmWindow *win = CTX_wm_window(C);
Scene *scene = WM_window_get_active_scene(win);
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- ViewRender *view_render = BKE_viewrender_get(scene, workspace);
- RenderEngineType *type = RE_engines_find(view_render->engine_id);
+ RenderEngineType *type = RE_engines_find(scene->r.engine);
EnumPropertyItem *item = NULL;
int totitem = 0;
- RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_BOUNDBOX);
- RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_WIRE);
RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_SOLID);
- RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_TEXTURE);
- RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_MATERIAL);
- if (type && type->render_to_view)
+ if (BKE_scene_uses_blender_eevee(scene)) {
RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_RENDER);
+ }
+ else {
+ RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_MATERIAL);
+ if (type && type->render_to_view) {
+ RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_RENDER);
+ }
+ }
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -796,8 +708,9 @@ static const EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *C,
return item;
}
-static const EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf(bContext *C, PointerRNA *UNUSED(ptr),
- PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
+static const EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf(
+ bContext *C, PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
{
Scene *scene = CTX_data_scene(C);
@@ -900,8 +813,9 @@ static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value)
ED_space_image_set_mask(NULL, sima, (Mask *)value.data);
}
-static const EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *UNUSED(C), PointerRNA *ptr,
- PropertyRNA *UNUSED(prop), bool *r_free)
+static const EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop), bool *r_free)
{
SpaceImage *sima = (SpaceImage *)ptr->data;
EnumPropertyItem *item = NULL;
@@ -1022,8 +936,9 @@ static void rna_SpaceImageEditor_scopes_update(struct bContext *C, struct Pointe
ED_space_image_release_buffer(sima, ibuf, lock);
}
-static const EnumPropertyItem *rna_SpaceImageEditor_pivot_itemf(bContext *UNUSED(C), PointerRNA *ptr,
- PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
+static const EnumPropertyItem *rna_SpaceImageEditor_pivot_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
{
static const EnumPropertyItem pivot_items[] = {
{V3D_AROUND_CENTER_BOUNDS, "CENTER", ICON_ROTATE, "Bounding Box Center", ""},
@@ -1125,8 +1040,9 @@ static void rna_SpaceProperties_context_set(PointerRNA *ptr, int value)
sbuts->mainbuser = value;
}
-static const EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSED(C), PointerRNA *ptr,
- PropertyRNA *UNUSED(prop), bool *r_free)
+static const EnumPropertyItem *rna_SpaceProperties_context_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop), bool *r_free)
{
SpaceButs *sbuts = (SpaceButs *)(ptr->data);
EnumPropertyItem *item = NULL;
@@ -1220,49 +1136,6 @@ static void rna_SpaceProperties_align_set(PointerRNA *ptr, int value)
sbuts->re_align = 1;
}
-static const EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C, PointerRNA *UNUSED(ptr),
- PropertyRNA *UNUSED(prop), bool *r_free)
-{
- EnumPropertyItem *item = NULL;
- int totitem = 0;
-
- if (ED_texture_context_check_world(C)) {
- RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_WORLD);
- }
-
- if (ED_texture_context_check_lamp(C)) {
- RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_LAMP);
- }
- else if (ED_texture_context_check_material(C)) {
- RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_MATERIAL);
- }
-
- if (ED_texture_context_check_particles(C)) {
- RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_PARTICLES);
- }
-
- if (ED_texture_context_check_linestyle(C)) {
- RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_LINESTYLE);
- }
-
- if (ED_texture_context_check_others(C)) {
- RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_OTHER);
- }
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
-static void rna_SpaceProperties_texture_context_set(PointerRNA *ptr, int value)
-{
- SpaceButs *sbuts = (SpaceButs *)(ptr->data);
-
- /* User action, no need to keep "better" value in prev here! */
- sbuts->texture_context = sbuts->texture_context_prev = value;
-}
-
/* Space Console */
static void rna_ConsoleLine_body_get(PointerRNA *ptr, char *value)
{
@@ -1417,6 +1290,7 @@ static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr)
static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr)
{
SpaceAction *saction = (SpaceAction *)(ptr->data);
+ ScrArea *sa = CTX_wm_area(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *obact = OBACT(view_layer);
@@ -1445,7 +1319,25 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr)
else
saction->action = NULL;
}
-
+
+ /* Collapse summary channel and hide channel list for timeline */
+ if (saction->mode == SACTCONT_TIMELINE) {
+ saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED;
+ }
+
+ if (sa && sa->spacedata.first == saction) {
+ ARegion *channels_region = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
+ if (channels_region) {
+ if (saction->mode == SACTCONT_TIMELINE) {
+ channels_region->flag |= RGN_FLAG_HIDDEN;
+ }
+ else {
+ channels_region->flag &= ~RGN_FLAG_HIDDEN;
+ }
+ ED_region_visibility_change_update(C, channels_region);
+ }
+ }
+
/* recalculate extents of channel list */
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
}
@@ -1520,8 +1412,9 @@ static int rna_SpaceNodeEditor_tree_type_poll(void *Cv, bNodeTreeType *type)
else
return true;
}
-static const EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf(bContext *C, PointerRNA *UNUSED(ptr),
- PropertyRNA *UNUSED(prop), bool *r_free)
+static const EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf(
+ bContext *C, PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_node_tree_type_itemf(C, rna_SpaceNodeEditor_tree_type_poll, r_free);
}
@@ -1932,6 +1825,7 @@ static void rna_def_space(BlenderRNA *brna)
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "spacetype");
RNA_def_property_enum_items(prop, rna_enum_space_type_items);
+ /* When making this editable, take care for the special case of global areas (see rna_Area_type_set). */
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Type", "Space data type");
@@ -2272,16 +2166,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static const EnumPropertyItem manipulators_items[] = {
- {V3D_MANIP_TRANSLATE, "TRANSLATE", ICON_MAN_TRANS, "Translate",
- "Use the manipulator for movement transformations"},
- {V3D_MANIP_ROTATE, "ROTATE", ICON_MAN_ROT, "Rotate",
- "Use the manipulator for rotation transformations"},
- {V3D_MANIP_SCALE, "SCALE", ICON_MAN_SCALE, "Scale",
- "Use the manipulator for scale transformations"},
- {0, NULL, 0, NULL, NULL}
- };
-
static const EnumPropertyItem rv3d_persp_items[] = {
{RV3D_PERSP, "PERSP", 0, "Perspective", ""},
{RV3D_ORTHO, "ORTHO", 0, "Orthographic", ""},
@@ -2395,6 +2279,24 @@ static void rna_def_space_view3d(BlenderRNA *brna)
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");
+ prop = RNA_def_property(srna, "viewport_lighting", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "drawtype_lighting");
+ RNA_def_property_enum_items(prop, rna_enum_viewport_lighting_items);
+ RNA_def_property_ui_text(prop, "Viewport Lighting", "Lighting Method for Solid/Texture Viewport Shading");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
+
+ prop = RNA_def_property(srna, "show_face_orientation_overlay", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "overlays", V3D_OVERLAY_FACE_ORIENTATION);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Face Orientation", "Show the Face Orientation Overlay");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
+
+ prop = RNA_def_property(srna, "show_random_object_colors", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "drawtype_options", V3D_DRAWOPTION_RANDOMIZE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Random Colors", "Show random object colors");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
+
prop = RNA_def_property(srna, "local_view", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "localvd");
RNA_def_property_ui_text(prop, "Local View",
@@ -2560,26 +2462,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "transform_manipulators", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "twtype");
- RNA_def_property_enum_items(prop, manipulators_items);
- RNA_def_property_flag(prop, PROP_ENUM_FLAG);
- RNA_def_property_ui_text(prop, "Transform Manipulators", "Transformation manipulators");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "twmode");
- RNA_def_property_enum_items(prop, transform_orientation_items);
- RNA_def_property_enum_funcs(prop, "rna_View3D_transform_orientation_get", "rna_View3D_transform_orientation_set",
- "rna_TransformOrientation_itemf");
- RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "TransformOrientation");
- RNA_def_property_pointer_funcs(prop, "rna_View3D_current_orientation_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation");
-
prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "scenelock", 1);
RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_lock_camera_and_layers_set");
@@ -2845,18 +2727,6 @@ static void rna_def_space_buttons(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Align", "Arrangement of the panels");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, NULL);
- prop = RNA_def_property(srna, "texture_context", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, buttons_texture_context_items);
- RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_texture_context_set",
- "rna_SpaceProperties_texture_context_itemf");
- RNA_def_property_ui_text(prop, "Texture Context", "Type of texture data to display and edit");
- RNA_def_property_update(prop, NC_TEXTURE, NULL);
-
- prop = RNA_def_property(srna, "use_limited_texture_context", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SB_TEX_USER_LIMITED);
- RNA_def_property_ui_text(prop, "Limited Texture Context",
- "Use the limited version of texture user (for 'old shading' mode)");
-
prop = RNA_def_property(srna, "collection_context", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, buttons_collection_context_items);
RNA_def_property_ui_text(prop, "Collection Context", "Which collection we want to show");
@@ -3327,6 +3197,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
/* XXX: action-editor is currently for object-level only actions, so show that using object-icon hint */
static EnumPropertyItem mode_items[] = {
+ {SACTCONT_TIMELINE, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls"},
{SACTCONT_DOPESHEET, "DOPESHEET", ICON_OOPS, "Dope Sheet", "Edit all keyframes in scene"},
{SACTCONT_ACTION, "ACTION", ICON_OBJECT_DATA, "Action Editor", "Edit keyframes in active object's Object-level action"},
{SACTCONT_SHAPEKEY, "SHAPEKEY", ICON_SHAPEKEY_DATA, "Shape Key Editor", "Edit keyframes in active object's Shape Keys action"},
@@ -3417,6 +3288,42 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
RNA_def_property_enum_items(prop, autosnap_items);
RNA_def_property_ui_text(prop, "Auto Snap", "Automatic time snapping settings for transformations");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
+
+ /* displaying cache status */
+ prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY);
+ RNA_def_property_ui_text(prop, "Show Cache", "Show the status of cached frames in the timeline");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
+
+ prop = RNA_def_property(srna, "cache_softbody", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SOFTBODY);
+ RNA_def_property_ui_text(prop, "Softbody", "Show the active object's softbody point cache");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
+
+ prop = RNA_def_property(srna, "cache_particles", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_PARTICLES);
+ RNA_def_property_ui_text(prop, "Particles", "Show the active object's particle point cache");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
+
+ prop = RNA_def_property(srna, "cache_cloth", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_CLOTH);
+ RNA_def_property_ui_text(prop, "Cloth", "Show the active object's cloth point cache");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
+
+ prop = RNA_def_property(srna, "cache_smoke", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SMOKE);
+ RNA_def_property_ui_text(prop, "Smoke", "Show the active object's smoke cache");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
+
+ prop = RNA_def_property(srna, "cache_dynamicpaint", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DYNAMICPAINT);
+ RNA_def_property_ui_text(prop, "Dynamic Paint", "Show the active object's Dynamic Paint cache");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
+
+ prop = RNA_def_property(srna, "cache_rigidbody", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_RIGIDBODY);
+ RNA_def_property_ui_text(prop, "Rigid Body", "Show the active object's Rigid Body cache");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
}
static void rna_def_space_graph(BlenderRNA *brna)
@@ -3620,63 +3527,6 @@ static void rna_def_space_nla(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NLA, NULL);
}
-static void rna_def_space_time(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "SpaceTimeline", "Space");
- RNA_def_struct_sdna(srna, "SpaceTime");
- RNA_def_struct_ui_text(srna, "Space Timeline Editor", "Timeline editor space data");
-
- /* view settings */
- prop = RNA_def_property(srna, "show_frame_indicator", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_CFRA_NUM);
- RNA_def_property_ui_text(prop, "Show Frame Number Indicator",
- "Show frame number beside the current frame indicator line");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-
- prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TIME_DRAWFRAMES);
- RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-
- /* displaying cache status */
- prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY);
- RNA_def_property_ui_text(prop, "Show Cache", "Show the status of cached frames in the timeline");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-
- prop = RNA_def_property(srna, "cache_softbody", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SOFTBODY);
- RNA_def_property_ui_text(prop, "Softbody", "Show the active object's softbody point cache");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-
- prop = RNA_def_property(srna, "cache_particles", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_PARTICLES);
- RNA_def_property_ui_text(prop, "Particles", "Show the active object's particle point cache");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-
- prop = RNA_def_property(srna, "cache_cloth", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_CLOTH);
- RNA_def_property_ui_text(prop, "Cloth", "Show the active object's cloth point cache");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-
- prop = RNA_def_property(srna, "cache_smoke", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SMOKE);
- RNA_def_property_ui_text(prop, "Smoke", "Show the active object's smoke cache");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-
- prop = RNA_def_property(srna, "cache_dynamicpaint", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DYNAMICPAINT);
- RNA_def_property_ui_text(prop, "Dynamic Paint", "Show the active object's Dynamic Paint cache");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-
- prop = RNA_def_property(srna, "cache_rigidbody", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_RIGIDBODY);
- RNA_def_property_ui_text(prop, "Rigid Body", "Show the active object's Rigid Body cache");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
-}
static void rna_def_console_line(BlenderRNA *brna)
{
@@ -4220,7 +4070,6 @@ static void rna_def_space_node(BlenderRNA *brna)
PropertyRNA *prop;
static const EnumPropertyItem texture_id_type_items[] = {
- {SNODE_TEX_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit texture nodes from Object"},
{SNODE_TEX_WORLD, "WORLD", ICON_WORLD_DATA, "World", "Edit texture nodes from World"},
{SNODE_TEX_BRUSH, "BRUSH", ICON_BRUSH_DATA, "Brush", "Edit texture nodes from Brush"},
#ifdef WITH_FREESTYLE
@@ -4376,75 +4225,6 @@ static void rna_def_space_node(BlenderRNA *brna)
RNA_api_space_node(srna);
}
-static void rna_def_space_logic(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "SpaceLogicEditor", "Space");
- RNA_def_struct_sdna(srna, "SpaceLogic");
- RNA_def_struct_ui_text(srna, "Space Logic Editor", "Logic editor space data");
-
- /* sensors */
- prop = RNA_def_property(srna, "show_sensors_selected_objects", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_SEL);
- RNA_def_property_ui_text(prop, "Show Selected Object", "Show sensors of all selected objects");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_sensors_active_object", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_ACT);
- RNA_def_property_ui_text(prop, "Show Active Object", "Show sensors of active object");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_sensors_linked_controller", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_LINK);
- RNA_def_property_ui_text(prop, "Show Linked to Controller", "Show linked objects to the controller");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_sensors_active_states", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_STATE);
- RNA_def_property_ui_text(prop, "Show Active States", "Show only sensors connected to active states");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* controllers */
- prop = RNA_def_property(srna, "show_controllers_selected_objects", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_CONT_SEL);
- RNA_def_property_ui_text(prop, "Show Selected Object", "Show controllers of all selected objects");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_controllers_active_object", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_CONT_ACT);
- RNA_def_property_ui_text(prop, "Show Active Object", "Show controllers of active object");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_controllers_linked_controller", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_CONT_LINK);
- RNA_def_property_ui_text(prop, "Show Linked to Controller", "Show linked objects to sensor/actuator");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* actuators */
- prop = RNA_def_property(srna, "show_actuators_selected_objects", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_SEL);
- RNA_def_property_ui_text(prop, "Show Selected Object", "Show actuators of all selected objects");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_actuators_active_object", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_ACT);
- RNA_def_property_ui_text(prop, "Show Active Object", "Show actuators of active object");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_actuators_linked_controller", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_LINK);
- RNA_def_property_ui_text(prop, "Show Linked to Actuator", "Show linked objects to the actuator");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_actuators_active_states", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_STATE);
- RNA_def_property_ui_text(prop, "Show Active States", "Show only actuators connected to active states");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
-}
-
static void rna_def_space_clip(BlenderRNA *brna)
{
StructRNA *srna;
@@ -4722,14 +4502,12 @@ void RNA_def_space(BlenderRNA *brna)
rna_def_space_dopesheet(brna);
rna_def_space_graph(brna);
rna_def_space_nla(brna);
- rna_def_space_time(brna);
rna_def_space_console(brna);
rna_def_console_line(brna);
rna_def_space_info(brna);
rna_def_space_userpref(brna);
rna_def_node_tree_path(brna);
rna_def_space_node(brna);
- rna_def_space_logic(brna);
rna_def_space_clip(brna);
}
diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c
index 822f5cbb4b6..f1206b7130f 100644
--- a/source/blender/makesrna/intern/rna_space_api.c
+++ b/source/blender/makesrna/intern/rna_space_api.c
@@ -39,20 +39,27 @@
static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C)
{
bScreen *sc = (bScreen *)id;
- EvaluationContext eval_ctx;
ScrArea *sa;
ARegion *ar;
- CTX_data_eval_ctx(C, &eval_ctx);
-
area_region_from_regiondata(sc, rv3d, &sa, &ar);
if (sa && ar && sa->spacetype == SPACE_VIEW3D) {
View3D *v3d = sa->spacedata.first;
- Scene *scene = ED_screen_scene_find(sc, G.main->wm.first);
-
- ED_view3d_update_viewmat(&eval_ctx, scene, v3d, ar, NULL, NULL, NULL);
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win;
+
+ for (win = wm->windows.first; win; win = win->next) {
+ if (WM_window_get_active_screen(win) == sc) {
+ Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+
+ ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL);
+ break;
+ }
+ }
}
}
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index 42e3e2c83fb..5449b67c040 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -67,19 +67,14 @@ const EnumPropertyItem rna_enum_texture_type_items[] = {
{TEX_CLOUDS, "CLOUDS", ICON_TEXTURE, "Clouds", "Procedural - create a cloud-like fractal noise texture"},
{TEX_DISTNOISE, "DISTORTED_NOISE", ICON_TEXTURE,
"Distorted Noise", "Procedural - noise texture distorted by two noise algorithms"},
- {TEX_ENVMAP, "ENVIRONMENT_MAP", ICON_IMAGE_DATA,
- "Environment Map", "Create a render of the environment mapped to a texture"},
{TEX_IMAGE, "IMAGE", ICON_IMAGE_DATA, "Image or Movie", "Allow for images or movies to be used as textures"},
{TEX_MAGIC, "MAGIC", ICON_TEXTURE, "Magic", "Procedural - color texture based on trigonometric functions"},
{TEX_MARBLE, "MARBLE", ICON_TEXTURE, "Marble", "Procedural - marble-like noise texture with wave generated bands"},
{TEX_MUSGRAVE, "MUSGRAVE", ICON_TEXTURE, "Musgrave", "Procedural - highly flexible fractal noise texture"},
{TEX_NOISE, "NOISE", ICON_TEXTURE, "Noise",
"Procedural - random noise, gives a different result every time, for every frame, for every pixel"},
- {TEX_OCEAN, "OCEAN", ICON_TEXTURE, "Ocean", "Use a texture generated by an Ocean modifier"},
- {TEX_POINTDENSITY, "POINT_DENSITY", ICON_TEXTURE, "Point Density", ""},
{TEX_STUCCI, "STUCCI", ICON_TEXTURE, "Stucci", "Procedural - create a fractal noise texture"},
{TEX_VORONOI, "VORONOI", ICON_TEXTURE, "Voronoi", "Procedural - create cell-like patterns based on Worley noise"},
- {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", "Create a 3D texture based on volumetric data"},
{TEX_WOOD, "WOOD", ICON_TEXTURE, "Wood", "Procedural - wave generated bands or rings, with optional noise"},
{0, NULL, 0, NULL, NULL}
};
@@ -134,8 +129,6 @@ static StructRNA *rna_Texture_refine(struct PointerRNA *ptr)
return &RNA_CloudsTexture;
case TEX_DISTNOISE:
return &RNA_DistortedNoiseTexture;
- case TEX_ENVMAP:
- return &RNA_EnvironmentMapTexture;
case TEX_IMAGE:
return &RNA_ImageTexture;
case TEX_MAGIC:
@@ -146,18 +139,12 @@ static StructRNA *rna_Texture_refine(struct PointerRNA *ptr)
return &RNA_MusgraveTexture;
case TEX_NOISE:
return &RNA_NoiseTexture;
- case TEX_POINTDENSITY:
- return &RNA_PointDensityTexture;
case TEX_STUCCI:
return &RNA_StucciTexture;
case TEX_VORONOI:
return &RNA_VoronoiTexture;
- case TEX_VOXELDATA:
- return &RNA_VoxelDataTexture;
case TEX_WOOD:
return &RNA_WoodTexture;
- case TEX_OCEAN:
- return &RNA_OceanTexture;
default:
return &RNA_Texture;
}
@@ -192,25 +179,6 @@ static void rna_Color_mapping_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
/* nothing to do */
}
-static void rna_Texture_voxeldata_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- Tex *tex = ptr->id.data;
-
- tex->vd->ok = 0;
- rna_Texture_update(bmain, scene, ptr);
-}
-
-static void rna_Texture_voxeldata_image_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- Tex *tex = ptr->id.data;
-
- if (tex->ima) { /* may be getting cleared too */
- tex->ima->source = IMA_SRC_SEQUENCE;
- }
- rna_Texture_voxeldata_update(bmain, scene, ptr);
-}
-
-
/* Used for Texture Properties, used (also) for/in Nodes */
static void rna_Texture_nodes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
@@ -433,54 +401,6 @@ static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, int value)
else tex->imaflag &= ~TEX_MIPMAP;
}
-static void rna_Envmap_update_generic(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- Tex *tex = ptr->id.data;
- if (tex->env) {
- ED_preview_kill_jobs(bmain->wm.first, bmain);
- BKE_texture_envmap_free_data(tex->env);
- }
- rna_Texture_update(bmain, scene, ptr);
-}
-
-static PointerRNA rna_PointDensity_psys_get(PointerRNA *ptr)
-{
- PointDensity *pd = ptr->data;
- Object *ob = pd->object;
- ParticleSystem *psys = NULL;
- PointerRNA value;
-
- if (ob && pd->psys)
- psys = BLI_findlink(&ob->particlesystem, pd->psys - 1);
-
- RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &value);
- return value;
-}
-
-static void rna_PointDensity_psys_set(PointerRNA *ptr, PointerRNA value)
-{
- PointDensity *pd = ptr->data;
- Object *ob = pd->object;
-
- if (ob && value.id.data == ob)
- pd->psys = BLI_findindex(&ob->particlesystem, value.data) + 1;
-}
-
-static char *rna_PointDensity_path(PointerRNA *UNUSED(ptr))
-{
- return BLI_sprintfN("point_density");
-}
-
-static char *rna_VoxelData_path(PointerRNA *UNUSED(ptr))
-{
- return BLI_sprintfN("voxel_data");
-}
-
-static char *rna_OceanTex_path(PointerRNA *UNUSED(ptr))
-{
- return BLI_sprintfN("ocean");
-}
-
#else
static void rna_def_texmapping(BlenderRNA *brna)
@@ -779,94 +699,6 @@ static void rna_def_filter_common(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Texture_update");
}
-static void rna_def_environment_map(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem prop_source_items[] = {
- {ENV_STATIC, "STATIC", 0, "Static", "Calculate environment map only once"},
- {ENV_ANIM, "ANIMATED", 0, "Animated", "Calculate environment map at each rendering"},
- {ENV_LOAD, "IMAGE_FILE", 0, "Image File", "Load a saved environment map image from disk"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_mapping_items[] = {
- {ENV_CUBE, "CUBE", 0, "Cube", "Use environment map with six cube sides"},
- {ENV_PLANE, "PLANE", 0, "Plane", "Only one side is rendered, with Z axis pointing in direction of image"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "EnvironmentMap", NULL);
- RNA_def_struct_sdna(srna, "EnvMap");
- RNA_def_struct_ui_text(srna, "EnvironmentMap",
- "Environment map created by the renderer and cached for subsequent renders");
-
- prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "stype");
- RNA_def_property_enum_items(prop, prop_source_items);
- RNA_def_property_ui_text(prop, "Source", "");
- RNA_def_property_update(prop, 0, "rna_Envmap_update_generic");
-
- prop = RNA_def_property(srna, "viewpoint_object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "object");
- RNA_def_property_ui_text(prop, "Viewpoint Object", "Object to use as the environment map's viewpoint location");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_mapping_items);
- RNA_def_property_ui_text(prop, "Mapping", "");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "clipsta");
- RNA_def_property_range(prop, 0.001, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.01, 50, 100, 2);
- RNA_def_property_ui_text(prop, "Clip Start", "Objects nearer than this are not visible to map");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "clipend");
- RNA_def_property_range(prop, 0.01, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.10, 20000, 100, 2);
- RNA_def_property_ui_text(prop, "Clip End", "Objects further than this are not visible to map");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "zoom", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "viewscale");
- RNA_def_property_range(prop, 0.1, 5.0);
- RNA_def_property_ui_range(prop, 0.5, 1.5, 1, 2);
- RNA_def_property_ui_text(prop, "Zoom", "");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "layers_ignore", PROP_BOOLEAN, PROP_LAYER_MEMBER);
- RNA_def_property_boolean_sdna(prop, NULL, "notlay", 1);
- RNA_def_property_array(prop, 20);
- RNA_def_property_ui_text(prop, "Ignore Layers",
- "Hide objects on these layers when generating the Environment Map");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "resolution", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "cuberes");
- RNA_def_property_range(prop, 50, 4096);
- RNA_def_property_ui_text(prop, "Resolution", "Pixel resolution of the rendered environment map");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_range(prop, 0, 5);
- RNA_def_property_ui_text(prop, "Depth", "Number of times a map will be rendered recursively (mirror effects)");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, 0);
- RNA_def_property_boolean_sdna(prop, NULL, "ok", 2);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Validity", "True if this map is ready for use, False if it needs rendering");
-
- RNA_api_environment_map(srna);
-}
-
static const EnumPropertyItem prop_noise_basis_items[] = {
{TEX_BLENDER, "BLENDER_ORIGINAL", 0, "Blender Original",
"Noise algorithm - Blender original: Smooth interpolated noise"},
@@ -1372,43 +1204,6 @@ static void rna_def_texture_image(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_NORMALMAP);
RNA_def_property_ui_text(prop, "Normal Map", "Use image RGB values for normal mapping");
RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- /* Derivative Map */
- prop = RNA_def_property(srna, "use_derivative_map", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_DERIVATIVEMAP);
- RNA_def_property_ui_text(prop, "Derivative Map", "Use red and green as derivative values");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-}
-
-static void rna_def_texture_environment_map(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "EnvironmentMapTexture", "Texture");
- RNA_def_struct_ui_text(srna, "Environment Map", "Environment map texture");
- RNA_def_struct_sdna(srna, "Tex");
-
- prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "ima");
- RNA_def_property_struct_type(prop, "Image");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Image", "Source image file to read the environment map from");
- RNA_def_property_update(prop, 0, "rna_Envmap_update_generic");
-
- prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "iuser");
- RNA_def_property_ui_text(prop, "Image User",
- "Parameters defining which layer, pass and frame of the image is displayed");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- rna_def_filter_common(srna);
-
- prop = RNA_def_property(srna, "environment_map", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "env");
- RNA_def_property_struct_type(prop, "EnvironmentMap");
- RNA_def_property_ui_text(prop, "Environment Map", "Get the environment map associated with this texture");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
}
static void rna_def_texture_musgrave(BlenderRNA *brna)
@@ -1633,407 +1428,6 @@ static void rna_def_texture_distorted_noise(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Texture_update");
}
-static void rna_def_texture_pointdensity(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem point_source_items[] = {
- {TEX_PD_PSYS, "PARTICLE_SYSTEM", 0, "Particle System", "Generate point density from a particle system"},
- {TEX_PD_OBJECT, "OBJECT", 0, "Object Vertices", "Generate point density from an object's vertices"},
- /*{TEX_PD_FILE, "FILE", 0, "File", ""}, */
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem particle_cache_items[] = {
- {TEX_PD_OBJECTLOC, "OBJECT_LOCATION", 0, "Emit Object Location", ""},
- {TEX_PD_OBJECTSPACE, "OBJECT_SPACE", 0, "Emit Object Space", ""},
- {TEX_PD_WORLDSPACE, "WORLD_SPACE", 0, "Global Space", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem vertex_cache_items[] = {
- {TEX_PD_OBJECTLOC, "OBJECT_LOCATION", 0, "Object Location", ""},
- {TEX_PD_OBJECTSPACE, "OBJECT_SPACE", 0, "Object Space", ""},
- {TEX_PD_WORLDSPACE, "WORLD_SPACE", 0, "Global Space", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem falloff_items[] = {
- {TEX_PD_FALLOFF_STD, "STANDARD", 0, "Standard", ""},
- {TEX_PD_FALLOFF_SMOOTH, "SMOOTH", 0, "Smooth", ""},
- {TEX_PD_FALLOFF_SOFT, "SOFT", 0, "Soft", ""},
- {TEX_PD_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", "Density is constant within lookup radius"},
- {TEX_PD_FALLOFF_ROOT, "ROOT", 0, "Root", ""},
- {TEX_PD_FALLOFF_PARTICLE_AGE, "PARTICLE_AGE", 0, "Particle Age", ""},
- {TEX_PD_FALLOFF_PARTICLE_VEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem particle_color_source_items[] = {
- {TEX_PD_COLOR_CONSTANT, "CONSTANT", 0, "Constant", ""},
- {TEX_PD_COLOR_PARTAGE, "PARTICLE_AGE", 0, "Particle Age", "Lifetime mapped as 0.0 - 1.0 intensity"},
- {TEX_PD_COLOR_PARTSPEED, "PARTICLE_SPEED", 0, "Particle Speed",
- "Particle speed (absolute magnitude of velocity) mapped as 0.0-1.0 intensity"},
- {TEX_PD_COLOR_PARTVEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", "XYZ velocity mapped to RGB colors"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem vertex_color_source_items[] = {
- {TEX_PD_COLOR_CONSTANT, "CONSTANT", 0, "Constant", ""},
- {TEX_PD_COLOR_VERTCOL, "VERTEX_COLOR", 0, "Vertex Color", "Vertex color layer"},
- {TEX_PD_COLOR_VERTWEIGHT, "VERTEX_WEIGHT", 0, "Vertex Weight", "Vertex group weight"},
- {TEX_PD_COLOR_VERTNOR, "VERTEX_NORMAL", 0, "Vertex Normal", "XYZ normal vector mapped to RGB colors"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem turbulence_influence_items[] = {
- {TEX_PD_NOISE_STATIC, "STATIC", 0, "Static",
- "Noise patterns will remain unchanged, faster and suitable for stills"},
- {TEX_PD_NOISE_VEL, "PARTICLE_VELOCITY", 0, "Particle Velocity",
- "Turbulent noise driven by particle velocity"},
- {TEX_PD_NOISE_AGE, "PARTICLE_AGE", 0, "Particle Age",
- "Turbulent noise driven by the particle's age between birth and death"},
- {TEX_PD_NOISE_TIME, "GLOBAL_TIME", 0, "Global Time", "Turbulent noise driven by the global current frame"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "PointDensity", NULL);
- RNA_def_struct_sdna(srna, "PointDensity");
- RNA_def_struct_ui_text(srna, "PointDensity", "Point density settings");
- RNA_def_struct_path_func(srna, "rna_PointDensity_path");
-
- prop = RNA_def_property(srna, "point_source", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "source");
- RNA_def_property_enum_items(prop, point_source_items);
- RNA_def_property_ui_text(prop, "Point Source", "Point data to use as renderable point density");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "object");
- RNA_def_property_ui_text(prop, "Object", "Object to take point data from");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
- RNA_def_property_ui_text(prop, "Particle System", "Particle System to render as points");
- RNA_def_property_struct_type(prop, "ParticleSystem");
- RNA_def_property_pointer_funcs(prop, "rna_PointDensity_psys_get", "rna_PointDensity_psys_set", NULL, NULL);
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "particle_cache_space", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "psys_cache_space");
- RNA_def_property_enum_items(prop, particle_cache_items);
- RNA_def_property_ui_text(prop, "Particle Cache", "Coordinate system to cache particles in");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "vertex_cache_space", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "ob_cache_space");
- RNA_def_property_enum_items(prop, vertex_cache_items);
- RNA_def_property_ui_text(prop, "Vertices Cache", "Coordinate system to cache vertices in");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "radius");
- RNA_def_property_range(prop, 0.001, FLT_MAX);
- RNA_def_property_ui_text(prop, "Radius", "Radius from the shaded sample to look for points within");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "falloff_type");
- RNA_def_property_enum_items(prop, falloff_items);
- RNA_def_property_ui_text(prop, "Falloff", "Method of attenuating density by distance from the point");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "falloff_soft", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "falloff_softness");
- RNA_def_property_range(prop, 0.01, FLT_MAX);
- RNA_def_property_ui_text(prop, "Softness", "Softness of the 'soft' falloff option");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "particle_color_source", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "color_source");
- RNA_def_property_enum_items(prop, particle_color_source_items);
- RNA_def_property_ui_text(prop, "Color Source", "Data to derive color results from");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "vertex_color_source", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "ob_color_source");
- RNA_def_property_enum_items(prop, vertex_color_source_items);
- RNA_def_property_ui_text(prop, "Color Source", "Data to derive color results from");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "vertex_attribute_name", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Vertex Attribute Name", "Vertex attribute to use for color");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "speed_scale", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "speed_scale");
- RNA_def_property_range(prop, 0.001, 100.0);
- RNA_def_property_ui_text(prop, "Scale", "Multiplier to bring particle speed within an acceptable range");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "falloff_speed_scale", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "falloff_speed_scale");
- RNA_def_property_range(prop, 0.001, 100.0);
- RNA_def_property_ui_text(prop, "Velocity Scale", "Multiplier to bring particle speed within an acceptable range");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
-
- prop = RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "coba");
- RNA_def_property_struct_type(prop, "ColorRamp");
- RNA_def_property_ui_text(prop, "Color Ramp", "");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "falloff_curve");
- RNA_def_property_struct_type(prop, "CurveMapping");
- RNA_def_property_ui_text(prop, "Falloff Curve", "");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "use_falloff_curve", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_FALLOFF_CURVE);
- RNA_def_property_ui_text(prop, "Falloff Curve", "Use a custom falloff curve");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- /* Turbulence */
- prop = RNA_def_property(srna, "use_turbulence", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_TURBULENCE);
- RNA_def_property_ui_text(prop, "Turbulence", "Add directed noise to the density at render-time");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "turbulence_scale", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "noise_size");
- RNA_def_property_range(prop, 0.01, FLT_MAX);
- RNA_def_property_ui_text(prop, "Size", "Scale of the added turbulent noise");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "turbulence_strength", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "noise_fac");
- RNA_def_property_range(prop, 0.01, FLT_MAX);
- RNA_def_property_ui_text(prop, "Turbulence Strength", "Strength of the added turbulent noise");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "noise_depth");
- RNA_def_property_range(prop, 0, 30);
- RNA_def_property_ui_text(prop, "Depth", "Level of detail in the added turbulent noise");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "turbulence_influence", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "noise_influence");
- RNA_def_property_enum_items(prop, turbulence_influence_items);
- RNA_def_property_ui_text(prop, "Turbulence Influence", "Method for driving added turbulent noise");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "noise_basis");
- RNA_def_property_enum_items(prop, prop_noise_basis_items);
- RNA_def_property_ui_text(prop, "Noise Basis", "Noise formula used for turbulence");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
-
- srna = RNA_def_struct(brna, "PointDensityTexture", "Texture");
- RNA_def_struct_sdna(srna, "Tex");
- RNA_def_struct_ui_text(srna, "Point Density", "Settings for the Point Density texture");
-
- prop = RNA_def_property(srna, "point_density", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "pd");
- RNA_def_property_struct_type(prop, "PointDensity");
- RNA_def_property_ui_text(prop, "Point Density", "The point density settings associated with this texture");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-}
-
-static void rna_def_texture_voxeldata(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem interpolation_type_items[] = {
- {TEX_VD_NEARESTNEIGHBOR, "NEREASTNEIGHBOR", 0, "Nearest Neighbor",
- "No interpolation, fast but blocky and low quality"},
- {TEX_VD_LINEAR, "TRILINEAR", 0, "Linear", "Good smoothness and speed"},
- {TEX_VD_QUADRATIC, "QUADRATIC", 0, "Quadratic", "Mid-range quality and speed"},
- {TEX_VD_TRICUBIC_CATROM, "TRICUBIC_CATROM", 0, "Cubic Catmull-Rom", "High quality interpolation, but slower"},
- {TEX_VD_TRICUBIC_BSPLINE, "TRICUBIC_BSPLINE", 0, "Cubic B-Spline",
- "Smoothed high quality interpolation, but slower"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem file_format_items[] = {
- {TEX_VD_BLENDERVOXEL, "BLENDER_VOXEL", 0, "Blender Voxel", "Default binary voxel file format"},
- {TEX_VD_RAW_8BIT, "RAW_8BIT", 0, "8 bit RAW", "8 bit grayscale binary data"},
- /*{TEX_VD_RAW_16BIT, "RAW_16BIT", 0, "16 bit RAW", ""}, */
- {TEX_VD_IMAGE_SEQUENCE, "IMAGE_SEQUENCE", 0, "Image Sequence",
- "Generate voxels from a sequence of image slices"},
- {TEX_VD_SMOKE, "SMOKE", 0, "Smoke", "Render voxels from a Blender smoke simulation"},
- {TEX_VD_HAIR, "HAIR", 0, "Hair", "Render voxels from a Blender hair simulation"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem voxeldata_extension[] = {
- {TEX_EXTEND, "EXTEND", 0, "Extend", "Extend by repeating edge pixels of the image"},
- {TEX_CLIP, "CLIP", 0, "Clip", "Clip to image size and set exterior pixels as transparent"},
- {TEX_REPEAT, "REPEAT", 0, "Repeat", "Cause the image to repeat horizontally and vertically"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem smoked_type_items[] = {
- {TEX_VD_SMOKEDENSITY, "SMOKEDENSITY", 0, "Smoke", "Use smoke density and color as texture data"},
- {TEX_VD_SMOKEFLAME, "SMOKEFLAME", 0, "Flame", "Use flame temperature as texture data"},
- {TEX_VD_SMOKEHEAT, "SMOKEHEAT", 0, "Heat", "Use smoke heat as texture data. Values from -2.0 to 2.0 are used"},
- {TEX_VD_SMOKEVEL, "SMOKEVEL", 0, "Velocity", "Use smoke velocity as texture data"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem hair_type_items[] = {
- {TEX_VD_HAIRDENSITY, "HAIRDENSITY", 0, "Density", "Use hair density as texture data"},
- {TEX_VD_HAIRRESTDENSITY, "HAIRRESTDENSITY", 0, "Rest Density", "Use hair rest density as texture data"},
- {TEX_VD_HAIRVELOCITY, "HAIRVELOCITY", 0, "Velocity", "Use hair velocity as texture data"},
- {TEX_VD_HAIRENERGY, "HAIRENERGY", 0, "Energy", "Use potential hair energy as texture data"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "VoxelData", NULL);
- RNA_def_struct_sdna(srna, "VoxelData");
- RNA_def_struct_ui_text(srna, "VoxelData", "Voxel data settings");
- RNA_def_struct_path_func(srna, "rna_VoxelData_path");
-
- prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "interp_type");
- RNA_def_property_enum_items(prop, interpolation_type_items);
- RNA_def_property_ui_text(prop, "Interpolation", "Method to interpolate/smooth values between voxel cells");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "smoke_data_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "smoked_type");
- RNA_def_property_enum_items(prop, smoked_type_items);
- RNA_def_property_ui_text(prop, "Source", "Simulation value to be used as a texture");
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update");
-
- prop = RNA_def_property(srna, "hair_data_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "hair_type");
- RNA_def_property_enum_items(prop, hair_type_items);
- RNA_def_property_ui_text(prop, "Source", "Simulation value to be used as a texture");
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update");
-
- prop = RNA_def_property(srna, "extension", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "extend");
- RNA_def_property_enum_items(prop, voxeldata_extension);
- RNA_def_property_ui_text(prop, "Extension", "How the texture is extrapolated past its original bounds");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "int_multiplier");
- RNA_def_property_range(prop, 0.01, FLT_MAX);
- RNA_def_property_ui_text(prop, "Intensity", "Multiplier for intensity values");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "file_format");
- RNA_def_property_enum_items(prop, file_format_items);
- RNA_def_property_ui_text(prop, "File Format", "Format of the source data set to render");
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update");
-
- prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
- RNA_def_property_string_sdna(prop, NULL, "source_path");
- RNA_def_property_ui_text(prop, "Source Path", "The external source data file to use");
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update");
-
- prop = RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "resol");
- RNA_def_property_range(prop, 1, 100000);
- RNA_def_property_ui_text(prop, "Resolution", "Resolution of the voxel grid");
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update");
-
- prop = RNA_def_property(srna, "use_still_frame", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_VD_STILL);
- RNA_def_property_ui_text(prop, "Still Frame Only", "Always render a still frame from the voxel data sequence");
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update");
-
- prop = RNA_def_property(srna, "still_frame", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "still_frame");
- RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
- RNA_def_property_ui_text(prop, "Still Frame Number", "The frame number to always use");
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update");
-
- prop = RNA_def_property(srna, "domain_object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "object");
- RNA_def_property_ui_text(prop, "Domain Object", "Object used as the smoke simulation domain");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update");
-
-
- srna = RNA_def_struct(brna, "VoxelDataTexture", "Texture");
- RNA_def_struct_sdna(srna, "Tex");
- RNA_def_struct_ui_text(srna, "Voxel Data", "Settings for the Voxel Data texture");
-
- prop = RNA_def_property(srna, "voxel_data", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "vd");
- RNA_def_property_struct_type(prop, "VoxelData");
- RNA_def_property_ui_text(prop, "Voxel Data", "The voxel data associated with this texture");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "ima");
- RNA_def_property_struct_type(prop, "Image");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Image", "");
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_image_update");
-
- prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "iuser");
- RNA_def_property_ui_text(prop, "Image User",
- "Parameters defining which layer, pass and frame of the image is displayed");
- RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update");
-}
-
-static void rna_def_texture_ocean(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem ocean_output_items[] = {
- {TEX_OCN_DISPLACEMENT, "DISPLACEMENT", 0, "Displacement", "Output XYZ displacement in RGB channels"},
- /*{TEX_OCN_NORMALS, "NORMALS", 0, "Normals", "Outputs wave normals"}, *//* these are in nor channel now */
- {TEX_OCN_FOAM, "FOAM", 0, "Foam", "Output Foam (wave overlap) amount in single channel"},
- {TEX_OCN_JPLUS, "JPLUS", 0, "Eigenvalues", "Positive Eigenvalues"},
- {TEX_OCN_EMINUS, "EMINUS", 0, "Eigenvectors (-)", "Negative Eigenvectors"},
- {TEX_OCN_EPLUS, "EPLUS", 0, "Eigenvectors (+)", "Positive Eigenvectors"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "OceanTexData", NULL);
- RNA_def_struct_sdna(srna, "OceanTex");
- RNA_def_struct_ui_text(srna, "Ocean", "Ocean Texture settings");
- RNA_def_struct_path_func(srna, "rna_OceanTex_path");
-
- prop = RNA_def_property(srna, "output", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "output");
- RNA_def_property_enum_items(prop, ocean_output_items);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Output", "The data that is output by the texture");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- prop = RNA_def_property(srna, "ocean_object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "object");
- RNA_def_property_ui_text(prop, "Modifier Object", "Object containing the ocean modifier");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-
- srna = RNA_def_struct(brna, "OceanTexture", "Texture");
- RNA_def_struct_sdna(srna, "Tex");
- RNA_def_struct_ui_text(srna, "Ocean", "Settings for the Ocean texture");
-
- prop = RNA_def_property(srna, "ocean", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "ot");
- RNA_def_property_struct_type(prop, "OceanTexData");
- RNA_def_property_ui_text(prop, "Ocean", "The ocean data associated with this texture");
- RNA_def_property_update(prop, 0, "rna_Texture_update");
-}
-
static void rna_def_texture(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2134,13 +1528,9 @@ static void rna_def_texture(BlenderRNA *brna)
rna_def_texture_stucci(brna);
rna_def_texture_noise(brna);
rna_def_texture_image(brna);
- rna_def_texture_environment_map(brna);
rna_def_texture_musgrave(brna);
rna_def_texture_voronoi(brna);
rna_def_texture_distorted_noise(brna);
- rna_def_texture_pointdensity(brna);
- rna_def_texture_voxeldata(brna);
- rna_def_texture_ocean(brna);
/* XXX add more types here .. */
RNA_api_texture(srna);
@@ -2150,7 +1540,6 @@ void RNA_def_texture(BlenderRNA *brna)
{
rna_def_texture(brna);
rna_def_mtex(brna);
- rna_def_environment_map(brna);
rna_def_texmapping(brna);
rna_def_colormapping(brna);
}
diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c
index a8fcf0ca3b6..1d513a494d7 100644
--- a/source/blender/makesrna/intern/rna_texture_api.c
+++ b/source/blender/makesrna/intern/rna_texture_api.c
@@ -45,30 +45,6 @@
#include "RE_pipeline.h"
#include "RE_shader_ext.h"
-static void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char *filepath,
- struct Scene *scene, float layout[12])
-{
- if (scene == NULL) {
- scene = CTX_data_scene(C);
- }
-
- RE_WriteEnvmapResult(reports, scene, env, filepath, scene->r.im_format.imtype, layout);
-}
-
-static void clear_envmap(struct EnvMap *env, bContext *C)
-{
- Main *bmain = CTX_data_main(C);
- Tex *tex;
-
- BKE_texture_envmap_free_data(env);
-
- for (tex = bmain->tex.first; tex; tex = tex->id.next)
- if (tex->env == env) {
- WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
- break;
- }
-}
-
static void texture_evaluate(struct Tex *tex, float value[3], float r_color[4])
{
TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
@@ -102,31 +78,4 @@ void RNA_api_texture(StructRNA *srna)
}
-void RNA_api_environment_map(StructRNA *srna)
-{
- FunctionRNA *func;
- PropertyRNA *parm;
-
- static const float default_layout[] = {0, 0, 1, 0, 2, 0, 0, 1, 1, 1, 2, 1};
-
- func = RNA_def_function(srna, "clear", "clear_envmap");
- RNA_def_function_ui_description(func, "Discard the environment map and free it from memory");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
-
-
- func = RNA_def_function(srna, "save", "save_envmap");
- RNA_def_function_ui_description(func, "Save the environment map to disc using the scene render settings");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
-
- parm = RNA_def_string_file_name(func, "filepath", NULL, FILE_MAX, "File path", "Location of the output file");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-
- RNA_def_pointer(func, "scene", "Scene", "", "Overrides the scene from which image parameters are taken");
-
- RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 1000.0f, "File layout",
- "Flat array describing the X,Y position of each cube face in the "
- "output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] "
- "(use -1 to skip a face)", 0.0f, 1000.0f);
-}
-
#endif
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 40657b3a225..bb4f6719fbc 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -568,7 +568,7 @@ static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
if (!ht)
return;
- if (!(art = region_type_find(NULL, ht->space_type, RGN_TYPE_HEADER)))
+ if (!(art = region_type_find(NULL, ht->space_type, ht->region_type)))
return;
RNA_struct_free_extension(type, &ht->ext);
@@ -592,6 +592,7 @@ static StructRNA *rna_Header_register(
/* setup dummy header & header type to store static properties in */
dummyheader.type = &dummyht;
+ dummyht.region_type = RGN_TYPE_HEADER; /* RGN_TYPE_HEADER by default, may be overridden */
RNA_pointer_create(NULL, &RNA_Header, &dummyheader, &dummyhtr);
/* validate the python class */
@@ -604,7 +605,7 @@ static StructRNA *rna_Header_register(
return NULL;
}
- if (!(art = region_type_find(reports, dummyht.space_type, RGN_TYPE_HEADER)))
+ if (!(art = region_type_find(reports, dummyht.space_type, dummyht.region_type)))
return NULL;
/* check if we have registered this header type before, and remove it */
@@ -1240,6 +1241,14 @@ static void rna_def_header(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_REGISTER);
RNA_def_property_ui_text(prop, "Space type", "The space where the header is going to be used in");
+ prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type->region_type");
+ RNA_def_property_enum_default(prop, RGN_TYPE_HEADER);
+ RNA_def_property_enum_items(prop, rna_enum_region_type_items);
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ RNA_def_property_ui_text(prop, "Region Type", "The region where the header is going to be used in "
+ "(defaults to header region)");
+
RNA_define_verify_sdna(1);
}
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 5fc263ae171..367efd71519 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -715,6 +715,15 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
api_ui_item_common_text(func);
+ func = RNA_def_function(srna, "template_ID_tabs", "uiTemplateIDTabs");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ api_ui_item_rna_common(func);
+ RNA_def_string(func, "new", NULL, 0, "", "Operator identifier to create a new ID block");
+ RNA_def_string(func, "open", NULL, 0, "", "Operator identifier to open a file for creating a new ID block");
+ RNA_def_string(func, "unlink", NULL, 0, "", "Operator identifier to unlink the ID block");
+ RNA_def_enum(func, "filter", id_template_filter_items, UI_TEMPLATE_ID_FILTER_ALL,
+ "", "Optionally limit the items which can be selected");
+
func = RNA_def_function(srna, "template_search", "uiTemplateSearch");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
api_ui_item_rna_common(func);
@@ -756,6 +765,12 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
RNA_def_function_return(func, parm);
+#ifdef WITH_REDO_REGION_REMOVAL
+ func = RNA_def_function(srna, "template_operator_redo_props", "uiTemplateOperatorRedoProperties");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Adds properties of the last executed operator using redo");
+#endif
+
func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
RNA_def_function_ui_description(func, "Generates the UI layout for constraints");
parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 88330ad2a8f..7fa43e0187b 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -52,7 +52,6 @@
#include "WM_types.h"
#include "BLT_lang.h"
-#include "GPU_buffers.h"
#ifdef WITH_OPENSUBDIV
static const EnumPropertyItem opensubdiv_compute_type_items[] = {
@@ -204,12 +203,6 @@ static void rna_userdef_load_ui_update(Main *UNUSED(bmain), Scene *UNUSED(scene)
else G.fileflags &= ~G_FILE_NO_UI;
}
-static void rna_userdef_mipmap_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
- rna_userdef_update(bmain, scene, ptr);
-}
-
static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
GPU_set_anisotropic(U.anisotropic_filter);
@@ -1037,6 +1030,11 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "State Colors", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
+ prop = RNA_def_property(srna, "wcol_tab", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_ui_text(prop, "Tab Colors", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
prop = RNA_def_property(srna, "menu_shadow_fac", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_ui_text(prop, "Menu Shadow Strength", "Blending factor for menu shadows");
RNA_def_property_range(prop, 0.01f, 1.0f);
@@ -2282,23 +2280,6 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_userdef_update");
}
-static void rna_def_userdef_theme_space_logic(BlenderRNA *brna)
-{
- StructRNA *srna;
-// PropertyRNA *prop;
-
- /* space_logic */
-
- srna = RNA_def_struct(brna, "ThemeLogicEditor", NULL);
- RNA_def_struct_sdna(srna, "ThemeSpace");
- RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
- RNA_def_struct_ui_text(srna, "Theme Logic Editor", "Theme settings for the Logic Editor");
-
- rna_def_userdef_theme_spaces_main(srna);
-
-}
-
-
static void rna_def_userdef_theme_space_buts(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2315,44 +2296,6 @@ static void rna_def_userdef_theme_space_buts(BlenderRNA *brna)
}
-static void rna_def_userdef_theme_space_time(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- /* space_time */
-
- srna = RNA_def_struct(brna, "ThemeTimeline", NULL);
- RNA_def_struct_sdna(srna, "ThemeSpace");
- RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
- RNA_def_struct_ui_text(srna, "Theme Timeline", "Theme settings for the Timeline");
-
- rna_def_userdef_theme_spaces_main(srna);
-
- prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Grid", "");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
-
- prop = RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "cframe");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Current Frame", "");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
-
- prop = RNA_def_property(srna, "time_keyframe", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "time_keyframe");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Keyframe", "Base color for keyframe indicator lines");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
-
- prop = RNA_def_property(srna, "time_grease_pencil", PROP_FLOAT, PROP_COLOR_GAMMA);
- RNA_def_property_float_sdna(prop, NULL, "time_gp_keyframe");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Grease Pencil", "Color of Grease Pencil keyframes");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
-}
-
static void rna_def_userdef_theme_space_image(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2984,6 +2927,20 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna)
rna_def_userdef_theme_spaces_curves(srna, false, false, false, true);
}
+static void rna_def_userdef_theme_space_topbar(BlenderRNA *brna)
+{
+ StructRNA *srna;
+
+ /* space_topbar */
+
+ srna = RNA_def_struct(brna, "ThemeTopBar", NULL);
+ RNA_def_struct_sdna(srna, "ThemeSpace");
+ RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
+ RNA_def_struct_ui_text(srna, "Theme Top Bar", "Theme settings for the Top Bar");
+
+ rna_def_userdef_theme_spaces_main(srna);
+}
+
static void rna_def_userdef_themes(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2994,7 +2951,6 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
{19, "STYLE", ICON_FONTPREVIEW, "Text Style", ""},
{18, "BONE_COLOR_SETS", ICON_COLOR, "Bone Color Sets", ""},
{1, "VIEW_3D", ICON_VIEW3D, "3D View", ""},
- {2, "TIMELINE", ICON_TIME, "Timeline", ""},
{3, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", ""},
{4, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", ""},
{5, "NLA_EDITOR", ICON_NLA, "NLA Editor", ""},
@@ -3002,7 +2958,6 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
{7, "SEQUENCE_EDITOR", ICON_SEQUENCE, "Video Sequence Editor", ""},
{8, "TEXT_EDITOR", ICON_TEXT, "Text Editor", ""},
{9, "NODE_EDITOR", ICON_NODETREE, "Node Editor", ""},
- {10, "LOGIC_EDITOR", ICON_LOGIC, "Logic Editor", ""},
{11, "PROPERTIES", ICON_BUTS, "Properties", ""},
{12, "OUTLINER", ICON_OOPS, "Outliner", ""},
{14, "USER_PREFERENCES", ICON_PREFERENCES, "User Preferences", ""},
@@ -3010,6 +2965,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
{16, "FILE_BROWSER", ICON_FILESEL, "File Browser", ""},
{17, "CONSOLE", ICON_CONSOLE, "Python Console", ""},
{20, "CLIP_EDITOR", ICON_CLIP, "Movie Clip Editor", ""},
+ {21, "TOPBAR", ICON_NONE, "Top Bar", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -3090,24 +3046,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ThemeTextEditor");
RNA_def_property_ui_text(prop, "Text Editor", "");
- prop = RNA_def_property(srna, "timeline", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "ttime");
- RNA_def_property_struct_type(prop, "ThemeTimeline");
- RNA_def_property_ui_text(prop, "Timeline", "");
-
prop = RNA_def_property(srna, "node_editor", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "tnode");
RNA_def_property_struct_type(prop, "ThemeNodeEditor");
RNA_def_property_ui_text(prop, "Node Editor", "");
- prop = RNA_def_property(srna, "logic_editor", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_pointer_sdna(prop, NULL, "tlogic");
- RNA_def_property_struct_type(prop, "ThemeLogicEditor");
- RNA_def_property_ui_text(prop, "Logic Editor", "");
-
prop = RNA_def_property(srna, "outliner", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "toops");
@@ -3143,6 +3087,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "tclip");
RNA_def_property_struct_type(prop, "ThemeClipEditor");
RNA_def_property_ui_text(prop, "Clip Editor", "");
+
+ prop = RNA_def_property(srna, "topbar", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_pointer_sdna(prop, NULL, "ttopbar");
+ RNA_def_property_struct_type(prop, "ThemeTopBar");
+ RNA_def_property_ui_text(prop, "Top Bar", "");
}
static void rna_def_userdef_addon(BlenderRNA *brna)
@@ -3226,14 +3176,13 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna)
rna_def_userdef_theme_space_seq(brna);
rna_def_userdef_theme_space_buts(brna);
rna_def_userdef_theme_space_text(brna);
- rna_def_userdef_theme_space_time(brna);
rna_def_userdef_theme_space_node(brna);
rna_def_userdef_theme_space_outliner(brna);
rna_def_userdef_theme_space_info(brna);
rna_def_userdef_theme_space_userpref(brna);
rna_def_userdef_theme_space_console(brna);
- rna_def_userdef_theme_space_logic(brna);
rna_def_userdef_theme_space_clip(brna);
+ rna_def_userdef_theme_space_topbar(brna);
rna_def_userdef_theme_colorset(brna);
rna_def_userdef_themes(brna);
}
@@ -4116,13 +4065,6 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Clip Alpha", "Clip alpha below this threshold in the 3D textured view");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
- prop = RNA_def_property(srna, "use_mipmaps", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_MIPMAP);
- RNA_def_property_ui_text(prop, "Mipmaps",
- "Scale textures for the 3D View (looks nicer but uses more memory and slows image "
- "reloading)");
- RNA_def_property_update(prop, 0, "rna_userdef_mipmap_update");
prop = RNA_def_property(srna, "use_16bit_textures", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_16bit_textures", 1);
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 609493c54b8..c48e80ad349 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -71,18 +71,6 @@ static PointerRNA rna_workspace_screens_item_get(CollectionPropertyIterator *ite
return rna_pointer_inherit_refine(&iter->parent, &RNA_Screen, screen);
}
-void rna_workspace_transform_orientations_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- WorkSpace *workspace = ptr->id.data;
- rna_iterator_listbase_begin(iter, BKE_workspace_transform_orientations_get(workspace), NULL);
-}
-
-static PointerRNA rna_workspace_transform_orientations_item_get(CollectionPropertyIterator *iter)
-{
- TransformOrientation *transform_orientation = rna_iterator_listbase_get(iter);
- return rna_pointer_inherit_refine(&iter->parent, &RNA_TransformOrientation, transform_orientation);
-}
-
/* workspace.owner_ids */
static wmOwnerID *rna_WorkSpace_owner_ids_new(
@@ -204,13 +192,6 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Active Tool Index", "Tool group index");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop = RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "transform_orientations", NULL);
- RNA_def_property_struct_type(prop, "TransformOrientation");
- RNA_def_property_collection_funcs(prop, "rna_workspace_transform_orientations_begin", NULL, NULL,
- "rna_workspace_transform_orientations_item_get", NULL, NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Transform Orientations", "");
-
prop = RNA_def_property(srna, "owner_ids", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "wmOwnerID");
RNA_def_property_ui_text(prop, "UI Tags", "");
@@ -222,12 +203,6 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Mode", "Object interaction mode used in this window");
#endif
- /* View Render */
- prop = RNA_def_property(srna, "view_render", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "ViewRenderSettings");
- RNA_def_property_ui_text(prop, "View Render", "");
-
/* Flags */
prop = RNA_def_property(srna, "use_scene_settings", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -244,29 +219,10 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_window_update_all");
}
-static void rna_def_transform_orientation(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "TransformOrientation", NULL);
-
- prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
- RNA_def_property_float_sdna(prop, NULL, "mat");
- RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-}
-
void RNA_def_workspace(BlenderRNA *brna)
{
rna_def_workspace_owner(brna);
rna_def_workspace(brna);
- rna_def_transform_orientation(brna);
}
#endif /* RNA_RUNTIME */
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index e78355ee426..92fbbd61898 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -64,28 +64,6 @@ static PointerRNA rna_World_mist_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_WorldMistSettings, ptr->id.data);
}
-static void rna_World_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- World *wo = (World *)ptr->data;
- rna_iterator_array_begin(iter, (void *)wo->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL);
-}
-
-static PointerRNA rna_World_active_texture_get(PointerRNA *ptr)
-{
- World *wo = (World *)ptr->data;
- Tex *tex;
-
- tex = give_current_world_texture(wo);
- return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
-}
-
-static void rna_World_active_texture_set(PointerRNA *ptr, PointerRNA value)
-{
- World *wo = (World *)ptr->data;
-
- set_current_world_texture(wo, value.data);
-}
-
static void rna_World_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
World *wo = ptr->id.data;
@@ -129,117 +107,11 @@ static void rna_World_use_nodes_update(bContext *C, PointerRNA *ptr)
#else
-static void rna_def_world_mtex(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem texco_items[] = {
- {TEXCO_VIEW, "VIEW", 0, "View", "Use view vector for the texture coordinates"},
- {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates (interior mist)"},
- {TEXCO_ANGMAP, "ANGMAP", 0, "AngMap", "Use 360 degree angular coordinates, e.g. for spherical light probes"},
- {TEXCO_H_SPHEREMAP, "SPHERE", 0, "Sphere", "For 360 degree panorama sky, spherical mapped, only top half"},
- {TEXCO_EQUIRECTMAP, "EQUIRECT", 0, "Equirectangular", "For 360 degree panorama sky, equirectangular mapping"},
- {TEXCO_H_TUBEMAP, "TUBE", 0, "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half"},
- {TEXCO_OBJECT, "OBJECT", 0, "Object", "Use linked object's coordinates for texture coordinates"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "WorldTextureSlot", "TextureSlot");
- RNA_def_struct_sdna(srna, "MTex");
- RNA_def_struct_ui_text(srna, "World Texture Slot", "Texture slot for textures in a World data-block");
-
- /* map to */
- prop = RNA_def_property(srna, "use_map_blend", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_BLEND);
- RNA_def_property_ui_text(prop, "Blend", "Affect the color progression of the background");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "use_map_horizon", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_HORIZ);
- RNA_def_property_ui_text(prop, "Horizon", "Affect the color of the horizon");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "use_map_zenith_up", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENUP);
- RNA_def_property_ui_text(prop, "Zenith Up", "Affect the color of the zenith above");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "use_map_zenith_down", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENDOWN);
- RNA_def_property_ui_text(prop, "Zenith Down", "Affect the color of the zenith below");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "texco");
- RNA_def_property_enum_items(prop, texco_items);
- RNA_def_property_ui_text(prop, "Texture Coordinates",
- "Texture coordinates used to map the texture onto the background");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "object");
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "blendfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Blend Factor", "Amount texture affects color progression of the background");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "horizon_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "colfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Horizon Factor", "Amount texture affects color of the horizon");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "zenith_up_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "zenupfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Zenith Up Factor", "Amount texture affects color of the zenith above");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "zenith_down_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "zendownfac");
- RNA_def_property_ui_range(prop, 0, 1, 10, 3);
- RNA_def_property_ui_text(prop, "Zenith Down Factor", "Amount texture affects color of the zenith below");
- RNA_def_property_update(prop, 0, "rna_World_update");
-}
-
static void rna_def_lighting(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
- static const EnumPropertyItem blend_mode_items[] = {
- {WO_AOMUL, "MULTIPLY", 0, "Multiply", "Multiply direct lighting with ambient occlusion, darkening the result"},
- {WO_AOADD, "ADD", 0, "Add", "Add light and shadow"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_color_items[] = {
- {WO_AOPLAIN, "PLAIN", 0, "White", "Plain diffuse energy (white.)"},
- {WO_AOSKYCOL, "SKY_COLOR", 0, "Sky Color", "Use horizon and zenith color for diffuse energy"},
- {WO_AOSKYTEX, "SKY_TEXTURE", 0, "Sky Texture", "Does full Sky texture render for diffuse energy"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_sample_method_items[] = {
- {WO_AOSAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", "Fastest and gives the most noise"},
- {WO_AOSAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", "Fast in high-contrast areas"},
- {WO_AOSAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", "Best quality"},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_gather_method_items[] = {
- {WO_AOGATHER_RAYTRACE, "RAYTRACE", 0, "Raytrace", "Accurate, but slow when noise-free results are required"},
- {WO_AOGATHER_APPROX, "APPROXIMATE", 0, "Approximate", "Inaccurate, but faster and without noise"},
- {0, NULL, 0, NULL, NULL}
- };
-
srna = RNA_def_struct(brna, "WorldLighting", NULL);
RNA_def_struct_sdna(srna, "World");
RNA_def_struct_nested(brna, srna, "World");
@@ -259,135 +131,12 @@ static void rna_def_lighting(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending");
RNA_def_property_update(prop, 0, "rna_World_update");
- prop = RNA_def_property(srna, "ao_blend_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "aomix");
- RNA_def_property_enum_items(prop, blend_mode_items);
- RNA_def_property_ui_text(prop, "Blend Mode", "Defines how AO mixes with material shading");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- /* environment lighting */
- prop = RNA_def_property(srna, "use_environment_light", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_ENV_LIGHT);
- RNA_def_property_ui_text(prop, "Use Environment Lighting", "Add light coming from the environment");
- RNA_def_property_update(prop, 0, "rna_World_draw_update");
-
- prop = RNA_def_property(srna, "environment_energy", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ao_env_energy");
- RNA_def_property_ui_range(prop, 0, FLT_MAX, 1, 3);
- RNA_def_property_ui_text(prop, "Environment Color", "Defines the strength of environment light");
- RNA_def_property_update(prop, 0, "rna_World_draw_update");
-
- prop = RNA_def_property(srna, "environment_color", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "aocolor");
- RNA_def_property_enum_items(prop, prop_color_items);
- RNA_def_property_ui_text(prop, "Environment Color", "Defines where the color of the environment light comes from");
- RNA_def_property_update(prop, 0, "rna_World_draw_update");
-
- /* indirect lighting */
- prop = RNA_def_property(srna, "use_indirect_light", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_INDIRECT_LIGHT);
- RNA_def_property_ui_text(prop, "Use Indirect Lighting", "Add indirect light bouncing of surrounding objects");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "indirect_factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "ao_indirect_energy");
- RNA_def_property_range(prop, 0, INT_MAX);
- RNA_def_property_ui_range(prop, 0, 1, 0.1, 2);
- RNA_def_property_ui_text(prop, "Indirect Factor", "Factor for how much surrounding objects contribute to light");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "indirect_bounces", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "ao_indirect_bounces");
- RNA_def_property_range(prop, 1, SHRT_MAX);
- RNA_def_property_ui_text(prop, "Bounces", "Number of indirect diffuse light bounces");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- /* gathering parameters */
- prop = RNA_def_property(srna, "gather_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "ao_gather_method");
- RNA_def_property_enum_items(prop, prop_gather_method_items);
- RNA_def_property_ui_text(prop, "Gather Method", "");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "passes", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "ao_approx_passes");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "Passes", "Number of preprocessing passes to reduce over-occlusion");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "aodist");
RNA_def_property_ui_text(prop, "Distance",
"Length of rays, defines how far away other faces give occlusion effect");
RNA_def_property_update(prop, 0, "rna_World_update");
- prop = RNA_def_property(srna, "falloff_strength", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "aodistfac");
- RNA_def_property_ui_text(prop, "Strength",
- "Attenuation falloff strength, the higher, the less influence distant objects have");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "bias", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "aobias");
- RNA_def_property_range(prop, 0, 0.5);
- RNA_def_property_ui_text(prop, "Bias",
- "Bias (in radians) to prevent smoothed faces from showing banding "
- "(for Raytrace Constant Jittered)");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ao_adapt_thresh");
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_text(prop, "Threshold",
- "Samples below this threshold will be considered fully shadowed/unshadowed and skipped "
- "(for Raytrace Adaptive QMC)");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "adapt_to_speed", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ao_adapt_speed_fac");
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_text(prop, "Adapt To Speed",
- "Use the speed vector pass to reduce AO samples in fast moving pixels - "
- "higher values result in more aggressive sample reduction "
- "(requires Vec pass enabled, for Raytrace Adaptive QMC)");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ao_approx_error");
- RNA_def_property_range(prop, 0.0001, 10);
- RNA_def_property_ui_text(prop, "Error Tolerance", "Low values are slower and higher quality");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "correction", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "ao_approx_correction");
- RNA_def_property_range(prop, 0, 1);
- RNA_def_property_ui_range(prop, 0, 1, 0.1, 2);
- RNA_def_property_ui_text(prop, "Correction", "Ad-hoc correction for over-occlusion due to the approximation");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AODIST);
- RNA_def_property_ui_text(prop, "Falloff", "Distance will be used to attenuate shadows");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "use_cache", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AOCACHE);
- RNA_def_property_ui_text(prop, "Pixel Cache",
- "Cache AO results in pixels and interpolate over neighboring pixels for speedup");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "aosamp");
- RNA_def_property_range(prop, 1, 128);
- RNA_def_property_ui_text(prop, "Samples",
- "Amount of ray samples. Higher values give smoother results and longer rendering times");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "sample_method", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "ao_samp_method");
- RNA_def_property_enum_items(prop, prop_sample_method_items);
- RNA_def_property_ui_text(prop, "Sample Method", "Method for generating shadow samples (for Raytrace)");
- RNA_def_property_update(prop, 0, "rna_World_update");
}
static void rna_def_world_mist(BlenderRNA *brna)
@@ -456,9 +205,6 @@ void RNA_def_world(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_WORLD_DATA);
rna_def_animdata_common(srna);
- rna_def_mtex_common(brna, srna, "rna_World_mtex_begin", "rna_World_active_texture_get",
- "rna_World_active_texture_set", NULL, "WorldTextureSlot", "WorldTextureSlots",
- "rna_World_update", "rna_World_update");
/* colors */
prop = RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR);
@@ -469,47 +215,6 @@ void RNA_def_world(BlenderRNA *brna)
/* render-only uses this */
RNA_def_property_update(prop, 0, "rna_World_draw_update");
- prop = RNA_def_property(srna, "zenith_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "zenr");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Zenith Color", "Color at the zenith");
- RNA_def_property_update(prop, 0, "rna_World_draw_update");
-
- prop = RNA_def_property(srna, "ambient_color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "ambr");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Ambient Color", "Ambient color of the world");
- RNA_def_property_update(prop, 0, "rna_World_draw_update");
-
- /* exp, range */
- prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "exp");
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_ui_text(prop, "Exposure", "Amount of exponential color correction for light");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- prop = RNA_def_property(srna, "color_range", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "range");
- RNA_def_property_range(prop, 0.2, 5.0);
- RNA_def_property_ui_text(prop, "Range", "The color range that will be mapped to 0-1");
- RNA_def_property_update(prop, 0, "rna_World_update");
-
- /* sky type */
- prop = RNA_def_property(srna, "use_sky_blend", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYBLEND);
- RNA_def_property_ui_text(prop, "Blend Sky", "Render background with natural progression from horizon to zenith");
- RNA_def_property_update(prop, NC_WORLD | ND_WORLD_DRAW, "rna_World_update");
-
- prop = RNA_def_property(srna, "use_sky_paper", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYPAPER);
- RNA_def_property_ui_text(prop, "Paper Sky", "Flatten blend or texture coordinates");
- RNA_def_property_update(prop, NC_WORLD | ND_WORLD_DRAW, "rna_World_update");
-
- prop = RNA_def_property(srna, "use_sky_real", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYREAL);
- RNA_def_property_ui_text(prop, "Real Sky", "Render background with a real horizon, relative to the camera angle");
- RNA_def_property_update(prop, NC_WORLD | ND_WORLD_DRAW, "rna_World_update");
-
/* nested structs */
prop = RNA_def_property(srna, "light_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
@@ -537,7 +242,6 @@ void RNA_def_world(BlenderRNA *brna)
rna_def_lighting(brna);
rna_def_world_mist(brna);
- rna_def_world_mtex(brna);
}
#endif
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index f6640704a83..37578664c4e 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -106,7 +106,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -127,7 +127,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *em,
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
@@ -150,7 +150,7 @@ static void deformVertsEM(
}
static void deformMatricesEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *em,
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3],
float (*defMats)[3][3], int numVerts)
{
@@ -165,7 +165,7 @@ static void deformMatricesEM(
if (!derivedData) dm->release(dm);
}
-static void deformMatrices(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
+static void deformMatrices(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index f598667f96d..42e3cf94d00 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -754,7 +754,7 @@ static DerivedMesh *arrayModifier_doArray(
}
-static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 35b8a3fd9cb..48de3507cfd 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -86,7 +86,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
/*
* This calls the new bevel code (added since 2.64)
*/
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
struct Object *ob, DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index c9d762a7fbe..16d456d1314 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -166,7 +166,7 @@ static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data))
}
static DerivedMesh *applyModifier(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
DerivedMesh *dm,
ModifierApplyFlag flag)
{
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index 2e0b13b0603..f99fef130f8 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -75,7 +75,7 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *UNUSED(ob), DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index bf86377960a..9037e5b6d54 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -429,7 +429,7 @@ static void cuboid_do(
}
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -452,7 +452,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 0c55d8f8beb..fd5bf1af312 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -69,7 +69,7 @@ static void initData(ModifierData *md)
cloth_init(clmd);
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
+static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm;
@@ -109,7 +109,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_c
CDDM_apply_vert_coords(dm, vertexCos);
- clothModifier_do(clmd, eval_ctx, md->scene, ob, dm, vertexCos);
+ clothModifier_do(clmd, depsgraph, md->scene, ob, dm, vertexCos);
dm->release(dm);
}
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index d2ecbaeaafe..cc14e6a0528 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -98,7 +98,7 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int UNUSED(numVerts),
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index d95f0ae9286..23a78312871 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -713,7 +713,7 @@ error:
static void deformVerts(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
@@ -727,7 +727,7 @@ static void deformVerts(
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index acb69de1e85..2152717319f 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -111,7 +111,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Curve Modifier");
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -126,14 +126,14 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, struct BMEditMesh *em,
+ ModifierData *md, struct Depsgraph *depsgraph, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
if (!derivedData) dm = CDDM_from_editbmesh(em, false, false);
- deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, 0);
+ deformVerts(md, depsgraph, ob, dm, vertexCos, numVerts, 0);
if (!derivedData) dm->release(dm);
}
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index a804a35954c..5b98c84422b 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -148,7 +148,7 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
DT_TYPE_SHARP_FACE \
)
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, DerivedMesh *derivedData,
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph, Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
@@ -180,7 +180,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
BKE_reports_init(&reports, RPT_STORE);
/* Note: no islands precision for now here. */
- BKE_object_data_transfer_dm(eval_ctx, md->scene, dtmd->ob_source, ob, dm, dtmd->data_types, false,
+ BKE_object_data_transfer_dm(depsgraph, md->scene, dtmd->ob_source, ob, dm, dtmd->data_types, false,
dtmd->vmap_mode, dtmd->emap_mode, dtmd->lmap_mode, dtmd->pmap_mode,
space_transform, false, max_dist, dtmd->map_ray_radius, 0.0f,
dtmd->layers_select_src, dtmd->layers_select_dst,
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index 83dcd7b9b89..ff124ef607d 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -86,7 +86,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 7ec89b23f25..a28c0fb8379 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -368,7 +368,7 @@ static void displaceModifier_do(
}
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -384,7 +384,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = get_cddm(ob, editData, derivedData, vertexCos, dependsOnNormals(md));
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index 914b4101760..97e2bf42d66 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -68,9 +68,6 @@ static void copyData(ModifierData *md, ModifierData *target)
id_us_plus((ID *)surface->init_texture);
}
}
- if (tpmd->brush) {
- id_us_plus((ID *)tpmd->brush->mat);
- }
}
static void freeData(ModifierData *md)
@@ -105,16 +102,10 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
}
}
-
- if (pmd->brush) {
- if (pmd->brush->flags & MOD_DPAINT_USE_MATERIAL) {
- dataMask |= CD_MASK_MLOOPUV;
- }
- }
return dataMask;
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *eval_ctx,
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
@@ -122,7 +113,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
/* dont apply dynamic paint on orco dm stack */
if (!(flag & MOD_APPLY_ORCO)) {
- return dynamicPaint_Modifier_do(pmd, eval_ctx, md->scene, ob, dm);
+ return dynamicPaint_Modifier_do(pmd, depsgraph, md->scene, ob, dm);
}
return dm;
}
@@ -169,9 +160,6 @@ static void foreachIDLink(ModifierData *md, Object *ob,
}
}
}
- if (pmd->brush) {
- walk(userData, ob, (ID **)&pmd->brush->mat, IDWALK_CB_USER);
- }
}
static void foreachTexLink(ModifierData *UNUSED(md), Object *UNUSED(ob),
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index 0e344a851f2..655284930b7 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -121,7 +121,7 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *UNUSED(ob), DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 8483da60576..4c04eadb265 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -147,7 +147,7 @@ static void createFacepa(ExplodeModifierData *emd,
/* make tree of emitter locations */
tree = BLI_kdtree_new(totpart);
for (p = 0, pa = psys->particles; p < totpart; p++, pa++) {
- psys_particle_on_emitter(psmd, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, NULL, NULL, NULL, NULL, NULL);
+ psys_particle_on_emitter(psmd, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, NULL, NULL, NULL, NULL);
BLI_kdtree_insert(tree, p, co);
}
BLI_kdtree_balance(tree);
@@ -787,7 +787,7 @@ static DerivedMesh *cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
}
static DerivedMesh *explodeMesh(
ExplodeModifierData *emd,
- ParticleSystemModifierData *psmd, const struct EvaluationContext *eval_ctx, Scene *scene,
+ ParticleSystemModifierData *psmd, struct Depsgraph *depsgraph, Scene *scene,
Object *ob, DerivedMesh *to_explode)
{
DerivedMesh *explode, *dm = to_explode;
@@ -813,7 +813,7 @@ static DerivedMesh *explodeMesh(
mface = dm->getTessFaceArray(dm);
totpart = psmd->psys->totpart;
- sim.eval_ctx = eval_ctx;
+ sim.depsgraph = depsgraph;
sim.scene = scene;
sim.ob = ob;
sim.psys = psmd->psys;
@@ -995,7 +995,7 @@ static ParticleSystemModifierData *findPrecedingParticlesystem(Object *ob, Modif
}
return psmd;
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *eval_ctx,
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
@@ -1030,7 +1030,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
if (emd->flag & eExplodeFlag_EdgeCut) {
int *facepa = emd->facepa;
DerivedMesh *splitdm = cutEdges(emd, dm);
- DerivedMesh *explode = explodeMesh(emd, psmd, eval_ctx, md->scene, ob, splitdm);
+ DerivedMesh *explode = explodeMesh(emd, psmd, depsgraph, md->scene, ob, splitdm);
MEM_freeN(emd->facepa);
emd->facepa = facepa;
@@ -1038,7 +1038,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
return explode;
}
else
- return explodeMesh(emd, psmd, eval_ctx, md->scene, ob, derivedData);
+ return explodeMesh(emd, psmd, depsgraph, md->scene, ob, derivedData);
}
return derivedData;
}
diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c
index 403a8706295..4b84fa00415 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim.c
@@ -82,7 +82,7 @@ static void copyData(ModifierData *md, ModifierData *target)
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 00abcc1c65c..c7c1f92edb1 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -352,7 +352,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm,
}
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag UNUSED(flag))
{
@@ -368,7 +368,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
+static void deformVertsEM(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
HookModifierData *hmd = (HookModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 72db3f1c132..c3a7e63173c 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -724,7 +724,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
@@ -736,7 +736,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 977b8b41cc3..5d3cfd830a0 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -506,7 +506,7 @@ static CustomDataMask required_data_mask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm;
@@ -524,7 +524,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm;
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 4bf52f552ce..cff07dd1584 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -99,7 +99,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Lattice Modifier");
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -115,14 +115,14 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, struct BMEditMesh *em,
+ ModifierData *md, struct Depsgraph *depsgraph, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
if (!derivedData) dm = CDDM_from_editbmesh(em, false, false);
- deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, 0);
+ deformVerts(md, depsgraph, ob, dm, vertexCos, numVerts, 0);
if (!derivedData) dm->release(dm);
}
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 080dc371508..eb9f1f39f56 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -90,7 +90,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index 5dfa1d874b2..43c7a044434 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -272,7 +272,7 @@ static void meshcache_do(
}
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -284,7 +284,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *UNUSED(editData),
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md;
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index d7f4af8df63..27a2f94255b 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -273,7 +273,7 @@ static void meshdeform_vert_task(
}
static void meshdeformModifier_do(
- ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, DerivedMesh *dm,
+ ModifierData *md, struct Depsgraph *depsgraph, Object *ob, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *) md;
@@ -300,7 +300,7 @@ static void meshdeformModifier_do(
*/
if (mmd->object->mode & OB_MODE_EDIT) {
BMEditMesh *em = BKE_editmesh_from_object(mmd->object);
- tmpdm = editbmesh_get_derived_cage_and_final(eval_ctx, md->scene, mmd->object, em, 0, &cagedm);
+ tmpdm = editbmesh_get_derived_cage_and_final(depsgraph, md->scene, mmd->object, em, 0, &cagedm);
if (tmpdm)
tmpdm->release(tmpdm);
}
@@ -409,7 +409,7 @@ static void meshdeformModifier_do(
cagedm->release(cagedm);
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
+static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph, Object *ob,
DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -419,13 +419,13 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_c
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
- meshdeformModifier_do(md, eval_ctx, ob, dm, vertexCos, numVerts);
+ meshdeformModifier_do(md, depsgraph, ob, dm, vertexCos, numVerts);
if (dm && dm != derivedData)
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
+static void deformVertsEM(ModifierData *md, struct Depsgraph *depsgraph, Object *ob,
struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData,
float (*vertexCos)[3],
@@ -433,7 +433,7 @@ static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval
{
DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
- meshdeformModifier_do(md, eval_ctx, ob, dm, vertexCos, numVerts);
+ meshdeformModifier_do(md, depsgraph, ob, dm, vertexCos, numVerts);
if (dm && dm != derivedData)
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 10e1cdea4ca..a1ab20a6612 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -90,7 +90,7 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (mcmd->cache_file == NULL) || (mcmd->object_path[0] == '\0');
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 62de2711b3d..1f51d5dba11 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -319,7 +319,7 @@ static DerivedMesh *mirrorModifier__doMirror(MirrorModifierData *mmd,
return result;
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index 2b675d36140..3145bef5ac0 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -67,7 +67,7 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
DerivedMesh *dm, ModifierApplyFlag flag)
{
MultiresModifierData *mmd = (MultiresModifierData *)md;
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 4fc49234468..9be23dbade6 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -517,7 +517,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
{
return normalEditModifier_do((NormalEditModifierData *)md, ob, dm);
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index b3a7ecaa138..f495e96f635 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -555,7 +555,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *UNUSED(ob),
}
#endif /* WITH_OCEANSIM */
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index 7979751395a..d7cb7fd8d94 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -40,10 +40,12 @@
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_rand.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_effect.h"
+#include "BKE_global.h"
#include "BKE_lattice.h"
#include "BKE_library_query.h"
#include "BKE_modifier.h"
@@ -52,8 +54,6 @@
#include "DEG_depsgraph_build.h"
-#include "MOD_modifiertypes.h"
-
static void initData(ModifierData *md)
{
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md;
@@ -63,7 +63,12 @@ static void initData(ModifierData *md)
pimd->psys = 1;
pimd->position = 1.0f;
pimd->axis = 2;
+ pimd->space = eParticleInstanceSpace_World;
+ pimd->particle_amount = 1.0f;
+ pimd->particle_offset = 0.0f;
+ STRNCPY(pimd->index_layer_name, "");
+ STRNCPY(pimd->value_layer_name, "");
}
static void copyData(ModifierData *md, ModifierData *target)
{
@@ -74,19 +79,34 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
+static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+{
+ ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
+ CustomDataMask dataMask = 0;
+
+ if (pimd->index_layer_name[0] != '\0' ||
+ pimd->value_layer_name[0] != '\0')
+ {
+ dataMask |= CD_MASK_MLOOPCOL;
+ }
+
+ return dataMask;
+
+}
+
static bool isDisabled(ModifierData *md, int useRenderParams)
{
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
ParticleSystem *psys;
ModifierData *ob_md;
-
+
if (!pimd->ob)
return true;
-
+
psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1);
if (psys == NULL)
return true;
-
+
/* If the psys modifier is disabled we cannot use its data.
* First look up the psys modifier from the object, then check if it is enabled.
*/
@@ -95,18 +115,18 @@ static bool isDisabled(ModifierData *md, int useRenderParams)
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)ob_md;
if (psmd->psys == psys) {
int required_mode;
-
+
if (useRenderParams) required_mode = eModifierMode_Render;
else required_mode = eModifierMode_Realtime;
-
+
if (!modifier_isEnabled(md->scene, ob_md, required_mode))
return true;
-
+
break;
}
}
}
-
+
return false;
}
@@ -115,6 +135,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md;
if (pimd->ob != NULL) {
DEG_add_object_relation(ctx->node, pimd->ob, DEG_OB_COMP_TRANSFORM, "Particle Instance Modifier");
+ DEG_add_object_relation(ctx->node, pimd->ob, DEG_OB_COMP_GEOMETRY, "Particle Instance Modifier");
}
}
@@ -126,42 +147,62 @@ static void foreachObjectLink(ModifierData *md, Object *ob,
walk(userData, ob, &pimd->ob, IDWALK_CB_NOP);
}
-static int particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *psys, int p)
+static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *psys, int p)
{
+ const bool between = (psys->part->childtype == PART_CHILD_FACES);
ParticleData *pa;
+ int totpart, randp, minp, maxp;
- if (pimd->flag & eParticleInstanceFlag_Parents) {
- if (p >= psys->totpart) {
- if (psys->part->childtype == PART_CHILD_PARTICLES) {
- pa = psys->particles + (psys->child + p - psys->totpart)->parent;
- }
- else {
- pa = NULL;
- }
- }
- else {
- pa = psys->particles + p;
- }
+ if (p >= psys->totpart) {
+ ChildParticle *cpa = psys->child + (p - psys->totpart);
+ pa = psys->particles + (between? cpa->pa[0]: cpa->parent);
}
else {
- if (psys->part->childtype == PART_CHILD_PARTICLES) {
- pa = psys->particles + (psys->child + p)->parent;
- }
- else {
- pa = NULL;
- }
+ pa = psys->particles + p;
}
if (pa) {
- if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) return 1;
- if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) return 1;
- if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) return 1;
+ if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) return true;
+ if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) return true;
+ if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) return true;
+ }
+
+ if (pimd->particle_amount == 1.0f) {
+ /* Early output, all particles are to be instanced. */
+ return false;
}
-
- return 0;
+
+ /* Randomly skip particles based on desired amount of visible particles. */
+
+ totpart = psys->totpart + psys->totchild;
+
+ /* TODO make randomization optional? */
+ randp = (int)(psys_frand(psys, 3578 + p) * totpart) % totpart;
+
+ minp = (int)(totpart * pimd->particle_offset) % (totpart+1);
+ maxp = (int)(totpart * (pimd->particle_offset + pimd->particle_amount)) % (totpart+1);
+
+ if (maxp > minp) {
+ return randp < minp || randp >= maxp;
+ }
+ else if (maxp < minp) {
+ return randp < minp && randp >= maxp;
+ }
+ else {
+ return true;
+ }
+
+ return false;
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *eval_ctx,
+static void store_float_in_vcol(MLoopCol *vcol, float float_value)
+{
+ const uchar value = FTOCHAR(float_value);
+ vcol->r = vcol->g = vcol->b = value;
+ vcol->a = 1.0f;
+}
+
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
@@ -174,11 +215,15 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
MLoop *mloop, *orig_mloop;
MVert *mvert, *orig_mvert;
int totvert, totpoly, totloop /* , totedge */;
- int maxvert, maxpoly, maxloop, totpart = 0, first_particle = 0;
+ int maxvert, maxpoly, maxloop, part_end = 0, part_start;
int k, p, p_skip;
short track = ob->trackflag % 3, trackneg, axis = pimd->axis;
float max_co = 0.0, min_co = 0.0, temp_co[3];
float *size = NULL;
+ float spacemat[4][4];
+ const bool use_parents = pimd->flag & eParticleInstanceFlag_Parents;
+ const bool use_children = pimd->flag & eParticleInstanceFlag_Children;
+ bool between;
trackneg = ((ob->trackflag > 2) ? 1 : 0);
@@ -196,26 +241,27 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
return derivedData;
}
- if (pimd->flag & eParticleInstanceFlag_Parents)
- totpart += psys->totpart;
- if (pimd->flag & eParticleInstanceFlag_Children) {
- if (totpart == 0)
- first_particle = psys->totpart;
- totpart += psys->totchild;
- }
+ part_start = use_parents ? 0 : psys->totpart;
- if (totpart == 0)
+ part_end = 0;
+ if (use_parents)
+ part_end += psys->totpart;
+ if (use_children)
+ part_end += psys->totchild;
+
+ if (part_end == 0)
return derivedData;
- sim.eval_ctx = eval_ctx;
+ sim.depsgraph = depsgraph;
sim.scene = md->scene;
sim.ob = pimd->ob;
sim.psys = psys;
sim.psmd = psys_get_modifier(pimd->ob, psys);
+ between = (psys->part->childtype == PART_CHILD_FACES);
if (pimd->flag & eParticleInstanceFlag_UseSize) {
float *si;
- si = size = MEM_calloc_arrayN(totpart, sizeof(float), "particle size array");
+ si = size = MEM_calloc_arrayN(part_end, sizeof(float), "particle size array");
if (pimd->flag & eParticleInstanceFlag_Parents) {
for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++, si++)
@@ -231,6 +277,21 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
}
}
+ switch (pimd->space) {
+ case eParticleInstanceSpace_World:
+ /* particle states are in world space already */
+ unit_m4(spacemat);
+ break;
+ case eParticleInstanceSpace_Local:
+ /* get particle states in the particle object's local space */
+ invert_m4_m4(spacemat, pimd->ob->obmat);
+ break;
+ default:
+ /* should not happen */
+ BLI_assert(false);
+ break;
+ }
+
totvert = dm->getNumVerts(dm);
totpoly = dm->getNumPolys(dm);
totloop = dm->getNumLoops(dm);
@@ -241,7 +302,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
maxpoly = 0;
maxloop = 0;
- for (p = 0; p < totpart; p++) {
+ for (p = part_start; p < part_end; p++) {
if (particle_skip(pimd, psys, p))
continue;
@@ -270,10 +331,22 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
mloop = result->getLoopArray(result);
orig_mloop = dm->getLoopArray(dm);
- for (p = 0, p_skip = 0; p < totpart; p++) {
+ MLoopCol *mloopcols_index = CustomData_get_layer_named(&result->loopData, CD_MLOOPCOL, pimd->index_layer_name);
+ MLoopCol *mloopcols_value = CustomData_get_layer_named(&result->loopData, CD_MLOOPCOL, pimd->value_layer_name);
+ int *vert_part_index = NULL;
+ float *vert_part_value = NULL;
+ if (mloopcols_index != NULL) {
+ vert_part_index = MEM_calloc_arrayN(maxvert, sizeof(int), "vertex part index array");
+ }
+ if (mloopcols_value) {
+ vert_part_value = MEM_calloc_arrayN(maxvert, sizeof(float), "vertex part value array");
+ }
+
+ for (p = part_start, p_skip = 0; p < part_end; p++) {
float prev_dir[3];
float frame[4]; /* frame orientation quaternion */
-
+ float p_random = psys_frand(psys, 77091 + 283*p);
+
/* skip particle? */
if (particle_skip(pimd, psys, p))
continue;
@@ -282,12 +355,20 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
for (k = 0; k < totvert; k++) {
ParticleKey state;
MVert *inMV;
- MVert *mv = mvert + p_skip * totvert + k;
+ int vindex = p_skip * totvert + k;
+ MVert *mv = mvert + vindex;
inMV = orig_mvert + k;
DM_copy_vert_data(dm, result, k, p_skip * totvert + k, 1);
*mv = *inMV;
+ if (vert_part_index != NULL) {
+ vert_part_index[vindex] = p;
+ }
+ if (vert_part_value != NULL) {
+ vert_part_value[vindex] = p_random;
+ }
+
/*change orientation based on object trackflag*/
copy_v3_v3(temp_co, mv->co);
mv->co[axis] = temp_co[track];
@@ -315,7 +396,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
mv->co[axis] = 0.0;
}
- psys_get_particle_on_path(&sim, first_particle + p, &state, 1);
+ psys_get_particle_on_path(&sim, p, &state, 1);
normalize_v3(state.vel);
@@ -323,18 +404,27 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
if (k == 0) {
float hairmat[4][4];
float mat[3][3];
-
- if (first_particle + p < psys->totpart)
- pa = psys->particles + first_particle + p;
+
+ if (p < psys->totpart)
+ pa = psys->particles + p;
else {
ChildParticle *cpa = psys->child + (p - psys->totpart);
- pa = psys->particles + cpa->parent;
+ pa = psys->particles + (between? cpa->pa[0]: cpa->parent);
}
psys_mat_hair_to_global(sim.ob, sim.psmd->dm_final, sim.psys->part->from, pa, hairmat);
copy_m3_m4(mat, hairmat);
/* to quaternion */
mat3_to_quat(frame, mat);
-
+
+ if (pimd->rotation > 0.0f || pimd->random_rotation > 0.0f) {
+ float angle = 2.0f*M_PI * (pimd->rotation + pimd->random_rotation * (psys_frand(psys, 19957323 + p) - 0.5f));
+ float eul[3] = { 0.0f, 0.0f, angle };
+ float rot[4];
+
+ eul_to_quat(rot, eul);
+ mul_qt_qtqt(frame, frame, rot);
+ }
+
/* note: direction is same as normal vector currently,
* but best to keep this separate so the frame can be
* rotated later if necessary
@@ -343,14 +433,14 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
}
else {
float rot[4];
-
+
/* incrementally rotate along bend direction */
rotation_between_vecs_to_quat(rot, prev_dir, state.vel);
mul_qt_qtqt(frame, rot, frame);
-
+
copy_v3_v3(prev_dir, state.vel);
}
-
+
copy_qt_qt(state.rot, frame);
#if 0
/* Absolute Frame (Frenet Frame) */
@@ -361,9 +451,9 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
float cross[3];
float temp[3] = {0.0f, 0.0f, 0.0f};
temp[axis] = 1.0f;
-
+
cross_v3_v3v3(cross, temp, state.vel);
-
+
/* state.vel[axis] is the only component surviving from a dot product with the axis */
axis_angle_to_quat(state.rot, cross, saacos(state.vel[axis]));
}
@@ -371,13 +461,15 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
}
else {
state.time = -1.0;
- psys_get_particle_state(&sim, first_particle + p, &state, 1);
+ psys_get_particle_state(&sim, p, &state, 1);
}
mul_qt_v3(state.rot, mv->co);
if (pimd->flag & eParticleInstanceFlag_UseSize)
mul_v3_fl(mv->co, size[p]);
add_v3_v3(mv->co, state.co);
+
+ mul_m4_v3(spacemat, mv->co);
}
/* create polys and loops */
@@ -397,6 +489,15 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
DM_copy_loop_data(dm, result, inMP->loopstart, mp->loopstart, j);
for (; j; j--, ml++, inML++) {
ml->v = inML->v + (p_skip * totvert);
+ const int ml_index = (ml - mloop);
+ if (mloopcols_index != NULL) {
+ const int part_index = vert_part_index[ml->v];
+ store_float_in_vcol(&mloopcols_index[ml_index], (float)part_index / psys->totpart);
+ }
+ if (mloopcols_value != NULL) {
+ const float part_value = vert_part_value[ml->v];
+ store_float_in_vcol(&mloopcols_value[ml_index], part_value);
+ }
}
}
}
@@ -414,6 +515,9 @@ static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationConte
if (size)
MEM_freeN(size);
+ MEM_SAFE_FREE(vert_part_index);
+ MEM_SAFE_FREE(vert_part_value);
+
result->dirty |= DM_DIRTY_NORMALS;
return result;
@@ -436,7 +540,7 @@ ModifierTypeInfo modifierType_ParticleInstance = {
/* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,
- /* requiredDataMask */ NULL,
+ /* requiredDataMask */ requiredDataMask,
/* freeData */ NULL,
/* isDisabled */ isDisabled,
/* updateDepsgraph */ updateDepsgraph,
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 9cc6e5f56b5..4dbd7ef7849 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -97,7 +97,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
/* saves the current emitter state for a particle system and calculates particles */
-static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx,
+static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph,
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int UNUSED(numVerts),
@@ -186,7 +186,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_c
if (!(ob->transflag & OB_NO_PSYS_UPDATE)) {
psmd->flag &= ~eParticleSystemFlag_psys_updated;
- particle_system_update(eval_ctx, md->scene, ob, psys, (flag & MOD_APPLY_RENDER) != 0);
+ particle_system_update(depsgraph, md->scene, ob, psys, (flag & MOD_APPLY_RENDER) != 0);
psmd->flag |= eParticleSystemFlag_psys_updated;
}
}
diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c
index c9070cced7e..67a4865f9db 100644
--- a/source/blender/modifiers/intern/MOD_remesh.c
+++ b/source/blender/modifiers/intern/MOD_remesh.c
@@ -143,7 +143,7 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4])
}
static DerivedMesh *applyModifier(ModifierData *md,
- const struct EvaluationContext *UNUSED(eval_ctx),
+ struct Depsgraph *UNUSED(depsgraph),
Object *UNUSED(ob),
DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
@@ -205,7 +205,7 @@ static DerivedMesh *applyModifier(ModifierData *md,
#else /* !WITH_MOD_REMESH */
static DerivedMesh *applyModifier(ModifierData *UNUSED(md),
- const struct EvaluationContext *UNUSED(eval_ctx),
+ struct Depsgraph *UNUSED(depsgraph),
Object *UNUSED(ob),
DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 5f30b762275..69ac3dbfefd 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -184,7 +184,7 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag flag)
{
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 822decea423..dc93474a420 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -44,7 +44,7 @@
#include "MOD_modifiertypes.h"
-static void deformVerts(ModifierData *UNUSED(md), const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *UNUSED(md), struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
int numVerts,
@@ -61,7 +61,7 @@ static void deformVerts(ModifierData *UNUSED(md), const struct EvaluationContext
}
}
-static void deformMatrices(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, DerivedMesh *derivedData,
+static void deformMatrices(ModifierData *md, struct Depsgraph *depsgraph, Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
Key *key = BKE_key_from_object(ob);
@@ -80,10 +80,10 @@ static void deformMatrices(ModifierData *md, const struct EvaluationContext *eva
copy_m3_m3(defMats[a], scale);
}
- deformVerts(md, eval_ctx, ob, derivedData, vertexCos, numVerts, 0);
+ deformVerts(md, depsgraph, ob, derivedData, vertexCos, numVerts, 0);
}
-static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob,
+static void deformVertsEM(ModifierData *md, struct Depsgraph *depsgraph, Object *ob,
struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData,
float (*vertexCos)[3],
@@ -92,10 +92,10 @@ static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval
Key *key = BKE_key_from_object(ob);
if (key && key->type == KEY_RELATIVE)
- deformVerts(md, eval_ctx, ob, derivedData, vertexCos, numVerts, 0);
+ deformVerts(md, depsgraph, ob, derivedData, vertexCos, numVerts, 0);
}
-static void deformMatricesEM(ModifierData *UNUSED(md), const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformMatricesEM(ModifierData *UNUSED(md), struct Depsgraph *UNUSED(depsgraph),
Object *ob, struct BMEditMesh *UNUSED(editData),
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index cbb96b31db1..877429c4a0b 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -103,7 +103,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk,
walk(userData, ob, &smd->auxTarget, IDWALK_CB_NOP);
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -124,7 +124,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+static void deformVertsEM(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
struct BMEditMesh *editData, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts)
{
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index 8590deb508a..5cbb602113a 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -383,7 +383,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -403,7 +403,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVertsEM(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData,
float (*vertexCos)[3],
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 4afe6ca33e2..ebf7fe9f640 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -1917,7 +1917,7 @@ static void copyData(ModifierData *md, ModifierData *target)
}
static DerivedMesh *applyModifier(ModifierData *md,
- const struct EvaluationContext *UNUSED(eval_ctx),
+ struct Depsgraph *UNUSED(depsgraph),
Object *UNUSED(ob),
DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index e610ef5f78d..330e0b05cdb 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -102,7 +102,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eval_ctx,
+static DerivedMesh *applyModifier(ModifierData *md, Depsgraph *depsgraph,
Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
@@ -111,7 +111,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eva
if (flag & MOD_APPLY_ORCO)
return dm;
- return smokeModifier_do(smd, eval_ctx, md->scene, ob, dm);
+ return smokeModifier_do(smd, depsgraph, md->scene, ob, dm);
}
static bool dependsOnTime(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 91c724cd1c9..346a973fa77 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -215,7 +215,7 @@ static void smoothModifier_do(
MEM_freeN(uctmp);
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
@@ -228,7 +228,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c
index 8d5217391af..876f56f4192 100644
--- a/source/blender/modifiers/intern/MOD_softbody.c
+++ b/source/blender/modifiers/intern/MOD_softbody.c
@@ -49,13 +49,13 @@
#include "MOD_modifiertypes.h"
-static void deformVerts(ModifierData *md, const EvaluationContext *eval_ctx, Object *ob,
+static void deformVerts(ModifierData *md, Depsgraph *depsgraph, Object *ob,
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
int numVerts,
ModifierApplyFlag UNUSED(flag))
{
- sbObjectStep(eval_ctx, md->scene, ob, (float)md->scene->r.cfra, vertexCos, numVerts);
+ sbObjectStep(depsgraph, md->scene, ob, (float)md->scene->r.cfra, vertexCos, numVerts);
}
static bool dependsOnTime(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 5635d37f100..68cd34b348c 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -205,7 +205,7 @@ BLI_INLINE void madd_v3v3short_fl(float r[3], const short a[3], const float f)
}
static DerivedMesh *applyModifier(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index a09923d6dfe..d620fec8ede 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -98,7 +98,7 @@ static bool isDisabled(ModifierData *md, int useRenderParams)
return get_render_subsurf_level(&md->scene->r, levels, useRenderParams != 0) == 0;
}
-static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eval_ctx,
+static DerivedMesh *applyModifier(ModifierData *md, Depsgraph *depsgraph,
Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag flag)
{
@@ -135,7 +135,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eva
else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
modifier_setError(md, "OpenSubdiv is not supported in paint modes");
}
- else if ((DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) == 0) {
+ else if ((DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) == 0) {
subsurf_flags |= SUBSURF_USE_GPU_BACKEND;
do_cddm_convert = false;
}
@@ -156,14 +156,14 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eva
#ifndef WITH_OPESUBDIV
(void) do_cddm_convert;
- UNUSED_VARS(eval_ctx);
+ UNUSED_VARS(depsgraph);
#endif
return result;
}
static DerivedMesh *applyModifierEM(
- ModifierData *md, const EvaluationContext *UNUSED(eval_ctx),
+ ModifierData *md, Depsgraph *UNUSED(depsgraph),
Object *UNUSED(ob), struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData,
ModifierApplyFlag flag)
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index bef35ccf1fe..5115572168b 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -85,7 +85,7 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int UNUSED(numVerts),
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 30b569207db..0d50cb40937 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1181,7 +1181,7 @@ static void surfacedeformModifier_do(
}
static void deformVerts(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3], int numVerts,
ModifierApplyFlag UNUSED(flag))
@@ -1190,7 +1190,7 @@ static void deformVerts(
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+ ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, struct BMEditMesh *UNUSED(editData),
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3], int numVerts)
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 5dd7e3dfda4..69e6578a280 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -85,7 +85,7 @@ static void copyData(ModifierData *md, ModifierData *target)
}
static DerivedMesh *applyModifier(ModifierData *md,
- const struct EvaluationContext *UNUSED(eval_ctx),
+ struct Depsgraph *UNUSED(depsgraph),
Object *UNUSED(ob),
DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 02f799fecb9..fba0663571e 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -71,12 +71,10 @@ static void copyData(ModifierData *md, ModifierData *target)
{
#if 0
UVProjectModifierData *umd = (UVProjectModifierData *) md;
-#endif
UVProjectModifierData *tumd = (UVProjectModifierData *) target;
+#endif
modifier_copyData_generic(md, target);
-
- id_us_plus((ID *)tumd->image);
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
@@ -102,9 +100,9 @@ static void foreachObjectLink(ModifierData *md, Object *ob,
static void foreachIDLink(ModifierData *md, Object *ob,
IDWalkFunc walk, void *userData)
{
+#if 0
UVProjectModifierData *umd = (UVProjectModifierData *) md;
-
- walk(userData, ob, (ID **)&umd->image, IDWALK_CB_USER);
+#endif
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
}
@@ -133,7 +131,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
float (*coords)[3], (*co)[3];
MLoopUV *mloop_uv;
int i, numVerts, numPolys, numLoops;
- Image *image = umd->image;
MPoly *mpoly, *mp;
MLoop *mloop;
Projector projectors[MOD_UVPROJECT_MAXPROJECTORS];
@@ -238,84 +235,73 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
mpoly = dm->getPolyArray(dm);
mloop = dm->getLoopArray(dm);
- Image **ob_image_array = NULL;
- if (image) {
- ob_image_array = BKE_object_material_edit_image_get_array(ob);
- }
-
- /* apply coords as UVs, and apply image if tfaces are new */
+ /* apply coords as UVs */
for (i = 0, mp = mpoly; i < numPolys; ++i, ++mp) {
- if (!image || (mp->mat_nr < ob->totcol ? ob_image_array[mp->mat_nr] : NULL) == image) {
- if (num_projectors == 1) {
- if (projectors[0].uci) {
- unsigned int fidx = mp->totloop - 1;
- do {
- unsigned int lidx = mp->loopstart + fidx;
- unsigned int vidx = mloop[lidx].v;
- BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], projectors[0].uci);
- } while (fidx--);
- }
- else {
- /* apply transformed coords as UVs */
- unsigned int fidx = mp->totloop - 1;
- do {
- unsigned int lidx = mp->loopstart + fidx;
- unsigned int vidx = mloop[lidx].v;
- copy_v2_v2(mloop_uv[lidx].uv, coords[vidx]);
- } while (fidx--);
- }
+ if (num_projectors == 1) {
+ if (projectors[0].uci) {
+ unsigned int fidx = mp->totloop - 1;
+ do {
+ unsigned int lidx = mp->loopstart + fidx;
+ unsigned int vidx = mloop[lidx].v;
+ BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], projectors[0].uci);
+ } while (fidx--);
}
else {
- /* multiple projectors, select the closest to face normal direction */
- float face_no[3];
- int j;
- Projector *best_projector;
- float best_dot;
-
- /* get the untransformed face normal */
- BKE_mesh_calc_poly_normal_coords(mp, mloop + mp->loopstart, (const float (*)[3])coords, face_no);
-
- /* find the projector which the face points at most directly
- * (projector normal with largest dot product is best)
- */
- best_dot = dot_v3v3(projectors[0].normal, face_no);
- best_projector = &projectors[0];
-
- for (j = 1; j < num_projectors; ++j) {
- float tmp_dot = dot_v3v3(projectors[j].normal,
- face_no);
- if (tmp_dot > best_dot) {
- best_dot = tmp_dot;
- best_projector = &projectors[j];
- }
+ /* apply transformed coords as UVs */
+ unsigned int fidx = mp->totloop - 1;
+ do {
+ unsigned int lidx = mp->loopstart + fidx;
+ unsigned int vidx = mloop[lidx].v;
+ copy_v2_v2(mloop_uv[lidx].uv, coords[vidx]);
+ } while (fidx--);
+ }
+ }
+ else {
+ /* multiple projectors, select the closest to face normal direction */
+ float face_no[3];
+ int j;
+ Projector *best_projector;
+ float best_dot;
+
+ /* get the untransformed face normal */
+ BKE_mesh_calc_poly_normal_coords(mp, mloop + mp->loopstart, (const float (*)[3])coords, face_no);
+
+ /* find the projector which the face points at most directly
+ * (projector normal with largest dot product is best)
+ */
+ best_dot = dot_v3v3(projectors[0].normal, face_no);
+ best_projector = &projectors[0];
+
+ for (j = 1; j < num_projectors; ++j) {
+ float tmp_dot = dot_v3v3(projectors[j].normal,
+ face_no);
+ if (tmp_dot > best_dot) {
+ best_dot = tmp_dot;
+ best_projector = &projectors[j];
}
+ }
- if (best_projector->uci) {
- unsigned int fidx = mp->totloop - 1;
- do {
- unsigned int lidx = mp->loopstart + fidx;
- unsigned int vidx = mloop[lidx].v;
- BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], best_projector->uci);
- } while (fidx--);
- }
- else {
- unsigned int fidx = mp->totloop - 1;
- do {
- unsigned int lidx = mp->loopstart + fidx;
- unsigned int vidx = mloop[lidx].v;
- mul_v2_project_m4_v3(mloop_uv[lidx].uv, best_projector->projmat, coords[vidx]);
- } while (fidx--);
- }
+ if (best_projector->uci) {
+ unsigned int fidx = mp->totloop - 1;
+ do {
+ unsigned int lidx = mp->loopstart + fidx;
+ unsigned int vidx = mloop[lidx].v;
+ BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], best_projector->uci);
+ } while (fidx--);
+ }
+ else {
+ unsigned int fidx = mp->totloop - 1;
+ do {
+ unsigned int lidx = mp->loopstart + fidx;
+ unsigned int vidx = mloop[lidx].v;
+ mul_v2_project_m4_v3(mloop_uv[lidx].uv, best_projector->projmat, coords[vidx]);
+ } while (fidx--);
}
}
}
MEM_freeN(coords);
- if (ob_image_array) {
- MEM_freeN(ob_image_array);
- }
-
if (free_uci) {
int j;
for (j = 0; j < num_projectors; ++j) {
@@ -331,7 +317,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
return dm;
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index 8af9fd6cde4..53e7d9f8e17 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -146,7 +146,7 @@ static void uv_warp_compute(
}
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
Object *ob, DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 204e344b8e1..06167bea3ab 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -309,7 +309,7 @@ static int warp_needs_dm(WarpModifierData *wmd)
return wmd->texture || wmd->defgrp_name[0];
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
{
DerivedMesh *dm = NULL;
@@ -326,7 +326,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED
}
}
-static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval_ctx, Object *ob, struct BMEditMesh *em,
+static void deformVertsEM(ModifierData *md, struct Depsgraph *depsgraph, Object *ob, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
@@ -337,7 +337,7 @@ static void deformVertsEM(ModifierData *md, const struct EvaluationContext *eval
dm = CDDM_from_editbmesh(em, false, false);
}
- deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, 0);
+ deformVerts(md, depsgraph, ob, dm, vertexCos, numVerts, 0);
if (use_dm) {
if (!derivedData) dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 7921ea662a7..3126ea0139e 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -56,6 +56,7 @@
#include "MOD_util.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
static void initData(ModifierData *md)
{
@@ -148,7 +149,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
static void waveModifier_do(WaveModifierData *md,
- const EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
Object *ob, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts)
{
@@ -156,7 +157,7 @@ static void waveModifier_do(WaveModifierData *md,
MVert *mvert = NULL;
MDeformVert *dvert;
int defgrp_index;
- float ctime = eval_ctx->ctime;
+ float ctime = DEG_get_ctime(depsgraph);
float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
float lifefac = wmd->height;
float (*tex_co)[3] = NULL;
@@ -301,7 +302,7 @@ static void waveModifier_do(WaveModifierData *md,
if (wmd->texture) MEM_freeN(tex_co);
}
-static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx,
+static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph,
Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts,
@@ -315,14 +316,14 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_c
else if (wmd->texture || wmd->defgrp_name[0])
dm = get_dm(ob, NULL, dm, NULL, false, false);
- waveModifier_do(wmd, eval_ctx, ob, dm, vertexCos, numVerts);
+ waveModifier_do(wmd, depsgraph, ob, dm, vertexCos, numVerts);
if (dm != derivedData)
dm->release(dm);
}
static void deformVertsEM(
- ModifierData *md, const struct EvaluationContext *eval_ctx,
+ ModifierData *md, struct Depsgraph *depsgraph,
Object *ob, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
@@ -334,7 +335,7 @@ static void deformVertsEM(
else if (wmd->texture || wmd->defgrp_name[0])
dm = get_dm(ob, editData, dm, NULL, false, false);
- waveModifier_do(wmd, eval_ctx, ob, dm, vertexCos, numVerts);
+ waveModifier_do(wmd, depsgraph, ob, dm, vertexCos, numVerts);
if (dm != derivedData)
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 6fdfe215c37..ba5422b929d 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -155,7 +155,7 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
}
static DerivedMesh *applyModifier(ModifierData *md,
- const struct EvaluationContext *UNUSED(eval_ctx),
+ struct Depsgraph *UNUSED(depsgraph),
Object *ob,
DerivedMesh *derivedData,
ModifierApplyFlag UNUSED(flag))
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 45c41498792..28f6be5d588 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -201,7 +201,7 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (wmd->defgrp_name_a[0] == '\0');
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
DerivedMesh *derivedData, ModifierApplyFlag UNUSED(flag))
{
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 84c5207830e..f0641365d3e 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -368,7 +368,7 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (wmd->proximity_ob_target == NULL);
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
DerivedMesh *derivedData, ModifierApplyFlag UNUSED(flag))
{
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
index 3cb35286114..e9b9a66cd73 100644
--- a/source/blender/modifiers/intern/MOD_wireframe.c
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -102,7 +102,7 @@ static DerivedMesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob,
}
-static DerivedMesh *applyModifier(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob,
+static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
{
return WireframeModifier_do((WireframeModifierData *)md, ob, dm);
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index ee70fcf510f..efe7db088f8 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -135,22 +135,17 @@ set(SRC
shader/nodes/node_shader_curves.c
shader/nodes/node_shader_gamma.c
shader/nodes/node_shader_brightness.c
- shader/nodes/node_shader_geom.c
shader/nodes/node_shader_hueSatVal.c
shader/nodes/node_shader_invert.c
- shader/nodes/node_shader_lamp.c
shader/nodes/node_shader_mapping.c
- shader/nodes/node_shader_material.c
shader/nodes/node_shader_math.c
shader/nodes/node_shader_mixRgb.c
shader/nodes/node_shader_normal.c
- shader/nodes/node_shader_output.c
shader/nodes/node_shader_rgb.c
shader/nodes/node_shader_sepcombRGB.c
shader/nodes/node_shader_sepcombHSV.c
shader/nodes/node_shader_sepcombXYZ.c
shader/nodes/node_shader_squeeze.c
- shader/nodes/node_shader_texture.c
shader/nodes/node_shader_valToRgb.c
shader/nodes/node_shader_value.c
shader/nodes/node_shader_wireframe.c
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index a507fdbd787..e411ceb6a23 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -44,20 +44,15 @@ void register_node_tree_type_sh(void);
void register_node_type_sh_group(void);
-void register_node_type_sh_output(void);
-void register_node_type_sh_material(void);
void register_node_type_sh_camera(void);
-void register_node_type_sh_lamp(void);
void register_node_type_sh_value(void);
void register_node_type_sh_rgb(void);
void register_node_type_sh_mix_rgb(void);
void register_node_type_sh_valtorgb(void);
void register_node_type_sh_rgbtobw(void);
-void register_node_type_sh_texture(void);
void register_node_type_sh_normal(void);
void register_node_type_sh_gamma(void);
void register_node_type_sh_brightcontrast(void);
-void register_node_type_sh_geom(void);
void register_node_type_sh_mapping(void);
void register_node_type_sh_curve_vec(void);
void register_node_type_sh_curve_rgb(void);
@@ -65,7 +60,6 @@ void register_node_type_sh_math(void);
void register_node_type_sh_vect_math(void);
void register_node_type_sh_squeeze(void);
void register_node_type_sh_dynamic(void);
-void register_node_type_sh_material_ext(void);
void register_node_type_sh_invert(void);
void register_node_type_sh_seprgb(void);
void register_node_type_sh_combrgb(void);
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 44713a7a000..299c3a627ee 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -40,27 +40,21 @@ DefNode( Node, NODE_GROUP_INPUT, def_group_input, "GROUP
DefNode( Node, NODE_GROUP_OUTPUT, def_group_output, "GROUP_OUTPUT", GroupOutput, "Group Output", "" )
DefNode( Node, NODE_REROUTE, 0, "REROUTE", Reroute, "Reroute", "" )
-DefNode( ShaderNode, SH_NODE_OUTPUT, def_sh_output, "OUTPUT", Output, "Output", "" )
-DefNode( ShaderNode, SH_NODE_MATERIAL, def_sh_material, "MATERIAL", Material, "Material", "" )
DefNode( ShaderNode, SH_NODE_RGB, 0, "RGB", RGB, "RGB", "" )
DefNode( ShaderNode, SH_NODE_VALUE, 0, "VALUE", Value, "Value", "" )
DefNode( ShaderNode, SH_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "MixRGB", "" )
DefNode( ShaderNode, SH_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" )
DefNode( ShaderNode, SH_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" )
-DefNode( ShaderNode, SH_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" )
DefNode( ShaderNode, SH_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" )
DefNode( ShaderNode, SH_NODE_GAMMA, 0, "GAMMA", Gamma, "Gamma", "" )
DefNode( ShaderNode, SH_NODE_BRIGHTCONTRAST, 0, "BRIGHTCONTRAST", BrightContrast, "Bright Contrast", "" )
-DefNode( ShaderNode, SH_NODE_GEOMETRY, def_sh_geometry, "GEOMETRY", Geometry, "Geometry", "" )
DefNode( ShaderNode, SH_NODE_MAPPING, def_sh_mapping, "MAPPING", Mapping, "Mapping", "" )
DefNode( ShaderNode, SH_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", VectorCurve, "Vector Curves", "" )
DefNode( ShaderNode, SH_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", RGBCurve, "RGB Curves", "" )
DefNode( ShaderNode, SH_NODE_CAMERA, 0, "CAMERA", CameraData, "Camera Data", "" )
-DefNode( ShaderNode, SH_NODE_LAMP, def_sh_lamp, "LAMP", LampData, "Lamp Data", "" )
DefNode( ShaderNode, SH_NODE_MATH, def_math, "MATH", Math, "Math", "" )
DefNode( ShaderNode, SH_NODE_VECT_MATH, def_vector_math, "VECT_MATH", VectorMath, "Vector Math", "" )
DefNode( ShaderNode, SH_NODE_SQUEEZE, 0, "SQUEEZE", Squeeze, "Squeeze Value", "" )
-DefNode( ShaderNode, SH_NODE_MATERIAL_EXT, def_sh_material, "MATERIAL_EXT", ExtendedMaterial, "Extended Material", "" )
DefNode( ShaderNode, SH_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" )
DefNode( ShaderNode, SH_NODE_SEPRGB, 0, "SEPRGB", SeparateRGB, "Separate RGB", "" )
DefNode( ShaderNode, SH_NODE_COMBRGB, 0, "COMBRGB", CombineRGB, "Combine RGB", "" )
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 8cb25d9167f..8994a2741f8 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -65,7 +65,7 @@ static void composite_get_from_context(const bContext *C, bNodeTreeType *UNUSED(
*r_ntree = scene->nodetree;
}
-static void foreach_nodeclass(ViewRender *UNUSED(view_render), void *calldata, bNodeClassCallback func)
+static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
{
func(calldata, NODE_CLASS_INPUT, N_("Input"));
func(calldata, NODE_CLASS_OUTPUT, N_("Output"));
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 7712d7d0e71..be23c535cba 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -219,7 +219,7 @@ static void cmp_node_rlayer_create_outputs(bNodeTree *ntree, bNode *node, LinkNo
Scene *scene = (Scene *)node->id;
if (scene) {
- RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
+ RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
if (engine_type && engine_type->update_render_passes) {
ViewLayer *view_layer = BLI_findlink(&scene->view_layers, node->custom1);
if (view_layer) {
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index 0cf131adbdc..ac4031f4932 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -304,8 +304,6 @@ bool ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call
* If the mute func is not set, assume the node should never be muted,
* and hence execute it!
*/
-// if (node->typeinfo->compatibility == NODE_NEW_SHADING)
-// return false;
if (node->typeinfo->execfunc && !(node->flag & NODE_MUTED))
node->typeinfo->execfunc(callerdata, thread, node, &nodeexec->data, nsin, nsout);
}
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index fd30df4293e..f4e084929cc 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -68,30 +68,22 @@
static int shader_tree_poll(const bContext *C, bNodeTreeType *UNUSED(treetype))
{
Scene *scene = CTX_data_scene(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
- ViewRender *view_render = BKE_viewrender_get(scene, workspace);
- const char *engine_id = view_render->engine_id;
+ const char *engine_id = scene->r.engine;
/* allow empty engine string too, this is from older versions that didn't have registerable engines yet */
return (engine_id[0] == '\0' ||
- STREQ(engine_id, RE_engine_id_BLENDER_RENDER) ||
- STREQ(engine_id, RE_engine_id_BLENDER_GAME) ||
STREQ(engine_id, RE_engine_id_CYCLES) ||
- !BKE_viewrender_use_shading_nodes_custom(view_render));
+ !BKE_scene_use_shading_nodes_custom(scene));
}
static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
{
SpaceNode *snode = CTX_wm_space_node(C);
Scene *scene = CTX_data_scene(C);
- WorkSpace *workspace = CTX_wm_workspace(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
- ViewRender *view_render = BKE_viewrender_get(scene, workspace);
- if ((snode->shaderfrom == SNODE_SHADER_OBJECT) ||
- (BKE_viewrender_use_new_shading_nodes(view_render) == false))
- {
+ if (snode->shaderfrom == SNODE_SHADER_OBJECT) {
if (ob) {
*r_from = &ob->id;
if (ob->type == OB_LAMP) {
@@ -126,16 +118,12 @@ static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tre
}
}
-static void foreach_nodeclass(ViewRender *view_render, void *calldata, bNodeClassCallback func)
+static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
{
func(calldata, NODE_CLASS_INPUT, N_("Input"));
func(calldata, NODE_CLASS_OUTPUT, N_("Output"));
-
- if (BKE_viewrender_use_new_shading_nodes(view_render)) {
- func(calldata, NODE_CLASS_SHADER, N_("Shader"));
- func(calldata, NODE_CLASS_TEXTURE, N_("Texture"));
- }
-
+ func(calldata, NODE_CLASS_SHADER, N_("Shader"));
+ func(calldata, NODE_CLASS_TEXTURE, N_("Texture"));
func(calldata, NODE_CLASS_OP_COLOR, N_("Color"));
func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector"));
func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor"));
@@ -630,16 +618,6 @@ void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat, short compatibili
MEM_freeN(localtree);
}
-/* **************** call to switch lamploop for material node ************ */
-
-void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *);
-
-void set_node_shader_lamp_loop(void (*lamp_loop_func)(ShadeInput *, ShadeResult *))
-{
- node_shader_lamp_loop = lamp_loop_func;
-}
-
-
bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key)
{
bNodeTreeExec *exec;
@@ -714,26 +692,14 @@ void ntreeShaderEndExecTree(bNodeTreeExec *exec)
}
}
-/* only for Blender internal */
-bool ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
+/* TODO: left over from Blender Internal, could reuse for new texture nodes. */
+bool ntreeShaderExecTree(bNodeTree *ntree, int thread)
{
ShaderCallData scd;
- /**
- * \note: preserve material from ShadeInput for material id, nodetree execs change it
- * fix for bug "[#28012] Mat ID messy with shader nodes"
- */
- Material *mat = shi->mat;
bNodeThreadStack *nts = NULL;
bNodeTreeExec *exec = ntree->execdata;
int compat;
- /* convert caller data to struct */
- scd.shi = shi;
- scd.shr = shr;
-
- /* each material node has own local shaderesult, with optional copying */
- memset(shr, 0, sizeof(ShadeResult));
-
/* ensure execdata is only initialized once */
if (!exec) {
BLI_thread_lock(LOCK_NODES);
@@ -744,18 +710,10 @@ bool ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
exec = ntree->execdata;
}
- nts = ntreeGetThreadStack(exec, shi->thread);
- compat = ntreeExecThreadNodes(exec, nts, &scd, shi->thread);
+ nts = ntreeGetThreadStack(exec, thread);
+ compat = ntreeExecThreadNodes(exec, nts, &scd, thread);
ntreeReleaseThreadStack(nts);
- // \note: set material back to preserved material
- shi->mat = mat;
-
- /* better not allow negative for now */
- if (shr->combined[0] < 0.0f) shr->combined[0] = 0.0f;
- if (shr->combined[1] < 0.0f) shr->combined[1] = 0.0f;
- if (shr->combined[2] < 0.0f) shr->combined[2] = 0.0f;
-
/* if compat is zero, it has been using non-compatible nodes */
return compat;
}
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index 22171f28790..69a69c156e3 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -91,53 +91,6 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
}
-/* go over all used Geometry and Texture nodes, and return a texco flag */
-/* no group inside needed, this function is called for groups too */
-void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mode)
-{
- bNode *node;
- bNodeSocket *sock;
- int a;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == SH_NODE_TEXTURE) {
- if ((r_mode & R_OSA) && node->id) {
- Tex *tex = (Tex *)node->id;
- if (ELEM(tex->type, TEX_IMAGE, TEX_ENVMAP)) {
- *texco |= TEXCO_OSA | NEED_UV;
- }
- }
- /* usability exception... without input we still give the node orcos */
- sock = node->inputs.first;
- if (sock == NULL || sock->link == NULL)
- *texco |= TEXCO_ORCO | NEED_UV;
- }
- else if (node->type == SH_NODE_GEOMETRY) {
- /* note; sockets always exist for the given type! */
- for (a = 0, sock = node->outputs.first; sock; sock = sock->next, a++) {
- if (sock->flag & SOCK_IN_USE) {
- switch (a) {
- case GEOM_OUT_GLOB:
- *texco |= TEXCO_GLOB | NEED_UV; break;
- case GEOM_OUT_VIEW:
- *texco |= TEXCO_VIEW | NEED_UV; break;
- case GEOM_OUT_ORCO:
- *texco |= TEXCO_ORCO | NEED_UV; break;
- case GEOM_OUT_UV:
- *texco |= TEXCO_UV | NEED_UV; break;
- case GEOM_OUT_NORMAL:
- *texco |= TEXCO_NORM | NEED_UV; break;
- case GEOM_OUT_VCOL:
- *texco |= NEED_UV; *mode |= MA_VERTEXCOL; break;
- case GEOM_OUT_VCOL_ALPHA:
- *texco |= NEED_UV; *mode |= MA_VERTEXCOL; break;
- }
- }
- }
- }
- }
-}
-
void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
{
memset(gs, 0, sizeof(*gs));
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index 2363addb56a..44c1ab7ca95 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -77,7 +77,6 @@
#include "RE_pipeline.h"
#include "RE_shader_ext.h"
-#include "GPU_lamp.h"
#include "GPU_material.h"
#include "GPU_uniformbuffer.h"
@@ -89,11 +88,10 @@ void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, shor
/* ********* exec data struct, remains internal *********** */
typedef struct ShaderCallData {
- ShadeInput *shi; /* from render pipe */
- ShadeResult *shr; /* from render pipe */
+ /* Empty for now, may be reused if we convert shader to texture nodes. */
+ int dummy;
} ShaderCallData;
-
void nodestack_get_vec(float *in, short type_in, bNodeStack *ns);
void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, struct bNodeStack *ns);
diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c
index ac0880d22ba..245360e789f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_camera.c
+++ b/source/blender/nodes/shader/nodes/node_shader_camera.c
@@ -40,28 +40,12 @@ static bNodeSocketTemplate sh_node_camera_out[] = {
{ -1, 0, "" }
};
-
-static void node_shader_exec_camera(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **out)
-{
- if (data) {
- ShadeInput *shi = ((ShaderCallData *)data)->shi; /* Data we need for shading. */
-
- copy_v3_v3(out[0]->vec, shi->co); /* get view vector */
- out[1]->vec[0] = fabsf(shi->co[2]); /* get view z-depth */
- out[2]->vec[0] = normalize_v3(out[0]->vec); /* get view distance */
- }
-}
-
static int gpu_shader_camera(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
GPUNodeLink *viewvec;
viewvec = GPU_builtin(GPU_VIEW_POSITION);
-
- /* Blender has negative Z, Cycles positive Z convention */
- if (GPU_material_use_new_shading_nodes(mat))
- GPU_link(mat, "invert_z", viewvec, &viewvec);
-
+ GPU_link(mat, "invert_z", viewvec, &viewvec);
return GPU_stack_link(mat, node, "camera", in, out, viewvec);
}
@@ -73,7 +57,6 @@ void register_node_type_sh_camera(void)
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
node_type_socket_templates(&ntype, NULL, sh_node_camera_out);
node_type_storage(&ntype, "", NULL, NULL);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_camera);
node_type_gpu(&ntype, gpu_shader_camera);
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
index b285f1a8a3e..30bdf0b0f42 100644
--- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c
+++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
@@ -44,40 +44,15 @@ static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *node, bNodeExecData
if (!in[1].link) {
in[1].link = GPU_builtin(GPU_VIEW_NORMAL);
}
- else if (GPU_material_use_world_space_shading(mat)) {
+ else {
GPU_link(mat, "direction_transform_m4v3", in[1].link, GPU_builtin(GPU_VIEW_MATRIX), &in[1].link);
}
return GPU_stack_link(mat, node, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_POSITION));
}
-static void node_shader_exec_fresnel(void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
+static void node_shader_exec_fresnel(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
{
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
-
- /* Compute IOR. */
- float eta;
- nodestack_get_vec(&eta, SOCK_FLOAT, in[0]);
- eta = max_ff(eta, 0.00001);
- eta = shi->flippednor ? 1 / eta : eta;
-
- /* Get normal from socket, but only if linked. */
- bNodeSocket *sock_normal = node->inputs.first;
- sock_normal = sock_normal->next;
-
- float n[3];
- if (sock_normal->link) {
- nodestack_get_vec(n, SOCK_VECTOR, in[1]);
- }
- else {
- copy_v3_v3(n, shi->vn);
- }
-
- if (shi->use_world_space_shading) {
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEW_MATRIX), n);
- }
-
- out[0]->vec[0] = RE_fresnel_dielectric(shi->view, n, eta);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c
deleted file mode 100644
index 57bef4a6784..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_geom.c
+++ /dev/null
@@ -1,163 +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) 2005 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/nodes/shader/nodes/node_shader_geom.c
- * \ingroup shdnodes
- */
-
-
-#include "node_shader_util.h"
-
-#include "DNA_customdata_types.h"
-
-/* **************** GEOMETRY ******************** */
-
-/* output socket type definition */
-static bNodeSocketTemplate sh_node_geom_out[] = {
- { SOCK_VECTOR, 0, N_("Global")},
- { SOCK_VECTOR, 0, N_("Local")},
- { SOCK_VECTOR, 0, N_("View")},
- { SOCK_VECTOR, 0, N_("Orco")},
- { SOCK_VECTOR, 0, N_("UV")},
- { SOCK_VECTOR, 0, N_("Normal")},
- { SOCK_RGBA, 0, N_("Vertex Color")},
- { SOCK_FLOAT, 0, N_("Vertex Alpha")},
- { SOCK_FLOAT, 0, N_("Front/Back")},
- { -1, 0, "" }
-};
-
-/* node execute callback */
-static void node_shader_exec_geom(void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **out)
-{
- if (data) {
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
- NodeGeometry *ngeo = (NodeGeometry *)node->storage;
- ShadeInputUV *suv = &shi->uv[shi->actuv];
- static float defaultvcol[4] = {1.0f, 1.0f, 1.0f, 1.0f};
- int i;
-
- if (ngeo->uvname[0]) {
- /* find uv map by name */
- for (i = 0; i < shi->totuv; i++) {
- if (STREQ(shi->uv[i].name, ngeo->uvname)) {
- suv = &shi->uv[i];
- break;
- }
- }
- }
-
- /* out: global, local, view, orco, uv, normal, vertex color */
- copy_v3_v3(out[GEOM_OUT_GLOB]->vec, shi->gl);
- copy_v3_v3(out[GEOM_OUT_LOCAL]->vec, shi->co);
- copy_v3_v3(out[GEOM_OUT_VIEW]->vec, shi->view);
- copy_v3_v3(out[GEOM_OUT_ORCO]->vec, shi->lo);
- copy_v3_v3(out[GEOM_OUT_UV]->vec, suv->uv);
- copy_v3_v3(out[GEOM_OUT_NORMAL]->vec, shi->vno);
-
- if (shi->use_world_space_shading) {
- negate_v3(out[GEOM_OUT_NORMAL]->vec);
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEWINV_MATRIX), out[GEOM_OUT_NORMAL]->vec);
- }
- if (shi->totcol) {
- /* find vertex color layer by name */
- ShadeInputCol *scol = &shi->col[0];
-
- if (ngeo->colname[0]) {
- for (i = 0; i < shi->totcol; i++) {
- if (STREQ(shi->col[i].name, ngeo->colname)) {
- scol = &shi->col[i];
- break;
- }
- }
- }
-
- srgb_to_linearrgb_v3_v3(out[GEOM_OUT_VCOL]->vec, scol->col);
- out[GEOM_OUT_VCOL]->vec[3] = scol->col[3];
- out[GEOM_OUT_VCOL_ALPHA]->vec[0] = scol->col[3];
- }
- else {
- memcpy(out[GEOM_OUT_VCOL]->vec, defaultvcol, sizeof(defaultvcol));
- out[GEOM_OUT_VCOL_ALPHA]->vec[0] = 1.0f;
- }
-
- if (shi->osatex) {
- out[GEOM_OUT_GLOB]->data = shi->dxgl;
- out[GEOM_OUT_GLOB]->datatype = NS_OSA_VECTORS;
- out[GEOM_OUT_LOCAL]->data = shi->dxco;
- out[GEOM_OUT_LOCAL]->datatype = NS_OSA_VECTORS;
- out[GEOM_OUT_VIEW]->data = &shi->dxview;
- out[GEOM_OUT_VIEW]->datatype = NS_OSA_VALUES;
- out[GEOM_OUT_ORCO]->data = shi->dxlo;
- out[GEOM_OUT_ORCO]->datatype = NS_OSA_VECTORS;
- out[GEOM_OUT_UV]->data = suv->dxuv;
- out[GEOM_OUT_UV]->datatype = NS_OSA_VECTORS;
- out[GEOM_OUT_NORMAL]->data = shi->dxno;
- out[GEOM_OUT_NORMAL]->datatype = NS_OSA_VECTORS;
- }
-
- /* front/back, normal flipping was stored */
- out[GEOM_OUT_FRONTBACK]->vec[0] = (shi->flippednor) ? 0.0f : 1.0f;
- }
-}
-
-static void node_shader_init_geometry(bNodeTree *UNUSED(ntree), bNode *node)
-{
- node->storage = MEM_callocN(sizeof(NodeGeometry), "NodeGeometry");
-}
-
-static int gpu_shader_geom(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- NodeGeometry *ngeo = (NodeGeometry *)node->storage;
- GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
- GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, ngeo->uvname);
- GPUNodeLink *mcol = GPU_attribute(CD_MCOL, ngeo->colname);
-
- bool ret = GPU_stack_link(mat, node, "geom", in, out,
- GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX), orco, mtface, mcol);
- if (GPU_material_use_world_space_shading(mat)) {
- GPU_link(mat, "vec_math_negate", out[5].link, &out[5].link);
- ret &= GPU_link(mat, "direction_transform_m4v3", out[5].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[5].link);
- }
- return ret;
-}
-
-/* node type definition */
-void register_node_type_sh_geom(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_GEOMETRY, "Geometry", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, NULL, sh_node_geom_out);
- node_type_init(&ntype, node_shader_init_geometry);
- node_type_storage(&ntype, "NodeGeometry", node_free_standard_storage, node_copy_standard_storage);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_geom);
- node_type_gpu(&ntype, gpu_shader_geom);
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_lamp.c b/source/blender/nodes/shader/nodes/node_shader_lamp.c
deleted file mode 100644
index 3c41227ab8b..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_lamp.c
+++ /dev/null
@@ -1,91 +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) 2013 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/nodes/shader/nodes/node_shader_lamp.c
- * \ingroup shdnodes
- */
-
-
-#include "node_shader_util.h"
-
-/* **************** LAMP INFO ******************** */
-static bNodeSocketTemplate sh_node_lamp_out[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { SOCK_VECTOR, 0, N_("Light Vector")},
- { SOCK_FLOAT, 0, N_("Distance")},
- { SOCK_RGBA, 0, N_("Shadow")},
- { SOCK_FLOAT, 0, N_("Visibility Factor")},
- { -1, 0, "" }
-};
-
-
-static void node_shader_exec_lamp(void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **out)
-{
- if (data) {
- Object *ob = (Object *)node->id;
-
- if (ob) {
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
-
- shi->nodes = 1; /* temp hack to prevent trashadow recursion */
- out[4]->vec[0] = RE_lamp_get_data(shi, ob, out[0]->vec, out[1]->vec, out[2]->vec, out[3]->vec);
- shi->nodes = 0;
- if (shi->use_world_space_shading)
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEWINV_MATRIX), out[1]->vec);
- }
- }
-}
-
-static int gpu_shader_lamp(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- if (node->id) {
- GPULamp *lamp = GPU_lamp_from_blender(GPU_material_scene(mat), (Object *)node->id, NULL);
- GPUNodeLink *col, *lv, *dist, *visifac, *shadow, *energy;
-
- visifac = GPU_lamp_get_data(mat, lamp, &col, &lv, &dist, &shadow, &energy);
-
- bool ret = GPU_stack_link(mat, node, "lamp", in, out, col, energy, lv, dist, shadow, visifac);
- if (GPU_material_use_world_space_shading(mat))
- ret &= GPU_link(mat, "direction_transform_m4v3", out[1].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[1].link);
- return ret;
- }
-
- return false;
-}
-
-void register_node_type_sh_lamp(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_LAMP, "Lamp Data", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, NULL, sh_node_lamp_out);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_lamp);
- node_type_gpu(&ntype, gpu_shader_lamp);
-
- nodeRegisterType(&ntype);
-}
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 3ab73fdde18..87ed85ffa99 100644
--- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
+++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c
@@ -43,50 +43,18 @@ static bNodeSocketTemplate sh_node_layer_weight_out[] = {
static int node_shader_gpu_layer_weight(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- if (!in[1].link)
+ if (!in[1].link) {
in[1].link = GPU_builtin(GPU_VIEW_NORMAL);
- else if (GPU_material_use_world_space_shading(mat)) {
+ }
+ else {
GPU_link(mat, "direction_transform_m4v3", in[1].link, GPU_builtin(GPU_VIEW_MATRIX), &in[1].link);
}
return GPU_stack_link(mat, node, "node_layer_weight", in, out, GPU_builtin(GPU_VIEW_POSITION));
}
-static void node_shader_exec_layer_weight(void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
+static void node_shader_exec_layer_weight(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
{
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
-
- /* Compute IOR. */
- float blend;
- nodestack_get_vec(&blend, SOCK_FLOAT, in[0]);
- float eta = max_ff(1 - blend, 0.00001);
- eta = shi->flippednor ? eta : 1 / eta;
-
- /* Get normal from socket, but only if linked. */
- bNodeSocket *sock_normal = node->inputs.first;
- sock_normal = sock_normal->next;
-
- float n[3];
- if (sock_normal->link) {
- nodestack_get_vec(n, SOCK_VECTOR, in[1]);
- }
- else {
- copy_v3_v3(n, shi->vn);
- }
-
-
- if (shi->use_world_space_shading)
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEW_MATRIX), n);
-
- out[0]->vec[0] = RE_fresnel_dielectric(shi->view, n, eta);
-
- float facing = fabs(dot_v3v3(shi->view, n));
- if (blend != 0.5) {
- CLAMP(blend, 0.0, 0.99999);
- blend = (blend < 0.5) ? 2.0 * blend : 0.5 / (1.0 - blend);
- facing = pow(facing, blend);
- }
- out[1]->vec[0] = 1.0 - facing;
}
/* 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
deleted file mode 100644
index 6850cdbf6ea..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_material.c
+++ /dev/null
@@ -1,374 +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) 2005 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/nodes/shader/nodes/node_shader_material.c
- * \ingroup shdnodes
- */
-
-#include "node_shader_util.h"
-
-/* **************** MATERIAL ******************** */
-
-static bNodeSocketTemplate sh_node_material_in[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 1, N_("Spec"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("DiffuseIntensity"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION},
- { -1, 0, "" }
-};
-
-static bNodeSocketTemplate sh_node_material_out[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { SOCK_FLOAT, 0, N_("Alpha")},
- { SOCK_VECTOR, 0, N_("Normal")},
- { -1, 0, "" }
-};
-
-/* **************** EXTENDED MATERIAL ******************** */
-
-static bNodeSocketTemplate sh_node_material_ext_in[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 1, N_("Spec"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("DiffuseIntensity"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION},
- { SOCK_RGBA, 1, N_("Mirror"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Ambient"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Emit"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
- { SOCK_FLOAT, 1, N_("SpecTra"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Reflectivity"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Alpha"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
- { SOCK_FLOAT, 1, N_("Translucency"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { -1, 0, "" }
-};
-
-static bNodeSocketTemplate sh_node_material_ext_out[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { SOCK_FLOAT, 0, N_("Alpha")},
- { SOCK_VECTOR, 0, N_("Normal")},
- { SOCK_RGBA, 0, N_("Diffuse")},
- { SOCK_RGBA, 0, N_("Spec")},
- { SOCK_RGBA, 0, N_("AO")},
- { -1, 0, "" }
-};
-
-static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
-{
- if (data && node->id) {
- ShadeResult shrnode;
- ShadeInput *shi;
- ShaderCallData *shcd = data;
- float col[4];
- bNodeSocket *sock;
- char hasinput[NUM_MAT_IN] = {'\0'};
- int i, mode;
-
- /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily
- * the constant input stack values (e.g. in case material node is inside a group).
- * we just want to know if a node input uses external data or the material setting.
- * this is an ugly hack, but so is this node as a whole.
- */
- for (sock = node->inputs.first, i = 0; sock; sock = sock->next, ++i)
- hasinput[i] = (sock->link != NULL);
-
- shi = shcd->shi;
- shi->mat = (Material *)node->id;
-
- /* copy all relevant material vars, note, keep this synced with render_types.h */
- memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float));
- shi->har = shi->mat->har;
-
- /* write values */
- if (hasinput[MAT_IN_COLOR])
- nodestack_get_vec(&shi->r, SOCK_VECTOR, in[MAT_IN_COLOR]);
-
- if (hasinput[MAT_IN_SPEC])
- nodestack_get_vec(&shi->specr, SOCK_VECTOR, in[MAT_IN_SPEC]);
-
- if (hasinput[MAT_IN_REFL])
- nodestack_get_vec(&shi->refl, SOCK_FLOAT, in[MAT_IN_REFL]);
-
- /* retrieve normal */
- if (hasinput[MAT_IN_NORMAL]) {
- nodestack_get_vec(shi->vn, SOCK_VECTOR, in[MAT_IN_NORMAL]);
- if (shi->use_world_space_shading) {
- negate_v3(shi->vn);
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEW_MATRIX), shi->vn);
- }
- normalize_v3(shi->vn);
- }
- else
- copy_v3_v3(shi->vn, shi->vno);
-
- /* custom option to flip normal */
- if (node->custom1 & SH_NODE_MAT_NEG) {
- negate_v3(shi->vn);
- }
-
- if (node->type == SH_NODE_MATERIAL_EXT) {
- if (hasinput[MAT_IN_MIR])
- nodestack_get_vec(&shi->mirr, SOCK_VECTOR, in[MAT_IN_MIR]);
- if (hasinput[MAT_IN_AMB])
- nodestack_get_vec(&shi->amb, SOCK_FLOAT, in[MAT_IN_AMB]);
- if (hasinput[MAT_IN_EMIT])
- nodestack_get_vec(&shi->emit, SOCK_FLOAT, in[MAT_IN_EMIT]);
- if (hasinput[MAT_IN_SPECTRA])
- nodestack_get_vec(&shi->spectra, SOCK_FLOAT, in[MAT_IN_SPECTRA]);
- if (hasinput[MAT_IN_RAY_MIRROR])
- nodestack_get_vec(&shi->ray_mirror, SOCK_FLOAT, in[MAT_IN_RAY_MIRROR]);
- if (hasinput[MAT_IN_ALPHA])
- nodestack_get_vec(&shi->alpha, SOCK_FLOAT, in[MAT_IN_ALPHA]);
- if (hasinput[MAT_IN_TRANSLUCENCY])
- nodestack_get_vec(&shi->translucency, SOCK_FLOAT, in[MAT_IN_TRANSLUCENCY]);
- }
-
- /* make alpha output give results even if transparency is only enabled on
- * the material linked in this not and not on the parent material */
- mode = shi->mode;
- if (shi->mat->mode & MA_TRANSP)
- shi->mode |= MA_TRANSP;
-
- shi->nodes = 1; /* temp hack to prevent trashadow recursion */
- node_shader_lamp_loop(shi, &shrnode); /* clears shrnode */
- shi->nodes = 0;
-
- shi->mode = mode;
-
- /* write to outputs */
- if (node->custom1 & SH_NODE_MAT_DIFF) {
- copy_v3_v3(col, shrnode.combined);
- if (!(node->custom1 & SH_NODE_MAT_SPEC)) {
- sub_v3_v3(col, shrnode.spec);
- }
- }
- else if (node->custom1 & SH_NODE_MAT_SPEC) {
- copy_v3_v3(col, shrnode.spec);
- }
- else
- col[0] = col[1] = col[2] = 0.0f;
-
- col[3] = shrnode.alpha;
-
- if (shi->do_preview)
- BKE_node_preview_set_pixel(execdata->preview, col, shi->xs, shi->ys, shi->do_manage);
-
- copy_v3_v3(out[MAT_OUT_COLOR]->vec, col);
- out[MAT_OUT_ALPHA]->vec[0] = shrnode.alpha;
-
- if (node->custom1 & SH_NODE_MAT_NEG) {
- shi->vn[0] = -shi->vn[0];
- shi->vn[1] = -shi->vn[1];
- shi->vn[2] = -shi->vn[2];
- }
-
- copy_v3_v3(out[MAT_OUT_NORMAL]->vec, shi->vn);
-
- if (shi->use_world_space_shading) {
- negate_v3(out[MAT_OUT_NORMAL]->vec);
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEWINV_MATRIX), out[MAT_OUT_NORMAL]->vec);
- }
- /* Extended material options */
- if (node->type == SH_NODE_MATERIAL_EXT) {
- /* Shadow, Reflect, Refract, Radiosity, Speed seem to cause problems inside
- * a node tree :( */
- copy_v3_v3(out[MAT_OUT_DIFFUSE]->vec, shrnode.diffshad);
- copy_v3_v3(out[MAT_OUT_SPEC]->vec, shrnode.spec);
- copy_v3_v3(out[MAT_OUT_AO]->vec, shrnode.ao);
- }
-
- /* copy passes, now just active node */
- if (node->flag & NODE_ACTIVE_ID) {
- float combined[4], alpha;
-
- copy_v4_v4(combined, shcd->shr->combined);
- alpha = shcd->shr->alpha;
-
- *(shcd->shr) = shrnode;
-
- copy_v4_v4(shcd->shr->combined, combined);
- shcd->shr->alpha = alpha;
- }
- }
-}
-
-
-static void node_shader_init_material(bNodeTree *UNUSED(ntree), bNode *node)
-{
- node->custom1 = SH_NODE_MAT_DIFF | SH_NODE_MAT_SPEC;
-}
-
-/* XXX this is also done as a local static function in gpu_codegen.c,
- * but we need this to hack around the crappy material node.
- */
-static GPUNodeLink *gpu_get_input_link(GPUMaterial *mat, GPUNodeStack *in)
-{
- if (in->link) {
- return in->link;
- }
- else {
- GPUNodeLink *result = NULL;
-
- /* note GPU_uniform() is only intended to be used as a parameter to
- * GPU_link(), returning it directly results in leaks or double frees */
- if (in->type == GPU_FLOAT)
- GPU_link(mat, "set_value", GPU_uniform(in->vec), &result);
- else if (in->type == GPU_VEC3)
- GPU_link(mat, "set_rgb", GPU_uniform(in->vec), &result);
- else if (in->type == GPU_VEC4)
- GPU_link(mat, "set_rgba", GPU_uniform(in->vec), &result);
- else
- BLI_assert(0);
-
- return result;
- }
-}
-
-static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- if (node->id) {
- GPUShadeInput shi;
- GPUShadeResult shr;
- bNodeSocket *sock;
- char hasinput[NUM_MAT_IN] = {'\0'};
- int i;
-
- /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily
- * the constant input stack values (e.g. in case material node is inside a group).
- * we just want to know if a node input uses external data or the material setting.
- */
- for (sock = node->inputs.first, i = 0; sock; sock = sock->next, ++i)
- hasinput[i] = (sock->link != NULL);
-
- GPU_shadeinput_set(mat, (Material *)node->id, &shi);
-
- /* write values */
- if (hasinput[MAT_IN_COLOR])
- shi.rgb = gpu_get_input_link(mat, &in[MAT_IN_COLOR]);
-
- if (hasinput[MAT_IN_SPEC])
- shi.specrgb = gpu_get_input_link(mat, &in[MAT_IN_SPEC]);
-
- if (hasinput[MAT_IN_REFL])
- shi.refl = gpu_get_input_link(mat, &in[MAT_IN_REFL]);
-
- /* retrieve normal */
- if (hasinput[MAT_IN_NORMAL]) {
- GPUNodeLink *tmp;
- shi.vn = gpu_get_input_link(mat, &in[MAT_IN_NORMAL]);
- if (GPU_material_use_world_space_shading(mat)) {
- GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
- GPU_link(mat, "direction_transform_m4v3", shi.vn, GPU_builtin(GPU_VIEW_MATRIX), &shi.vn);
- }
- GPU_link(mat, "vec_math_normalize", shi.vn, &shi.vn, &tmp);
- }
-
- /* custom option to flip normal */
- if (node->custom1 & SH_NODE_MAT_NEG)
- GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
-
- if (node->type == SH_NODE_MATERIAL_EXT) {
- if (hasinput[MAT_IN_MIR])
- shi.mir = gpu_get_input_link(mat, &in[MAT_IN_MIR]);
- if (hasinput[MAT_IN_AMB])
- shi.amb = gpu_get_input_link(mat, &in[MAT_IN_AMB]);
- if (hasinput[MAT_IN_EMIT])
- shi.emit = gpu_get_input_link(mat, &in[MAT_IN_EMIT]);
- if (hasinput[MAT_IN_SPECTRA])
- shi.spectra = gpu_get_input_link(mat, &in[MAT_IN_SPECTRA]);
- if (hasinput[MAT_IN_ALPHA])
- shi.alpha = gpu_get_input_link(mat, &in[MAT_IN_ALPHA]);
- }
-
- GPU_shaderesult_set(&shi, &shr); /* clears shr */
-
- /* write to outputs */
- if (node->custom1 & SH_NODE_MAT_DIFF) {
- out[MAT_OUT_COLOR].link = shr.combined;
-
- if (!(node->custom1 & SH_NODE_MAT_SPEC)) {
- GPUNodeLink *link;
- GPU_link(mat, "vec_math_sub", shr.combined, shr.spec, &out[MAT_OUT_COLOR].link, &link);
- }
- }
- else if (node->custom1 & SH_NODE_MAT_SPEC) {
- out[MAT_OUT_COLOR].link = shr.spec;
- }
- else
- GPU_link(mat, "set_rgb_zero", &out[MAT_OUT_COLOR].link);
-
- GPU_link(mat, "mtex_alpha_to_col", out[MAT_OUT_COLOR].link, shr.alpha, &out[MAT_OUT_COLOR].link);
-
- out[MAT_OUT_ALPHA].link = shr.alpha; //
-
- if (node->custom1 & SH_NODE_MAT_NEG)
- GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
- out[MAT_OUT_NORMAL].link = shi.vn;
- if (GPU_material_use_world_space_shading(mat)) {
- GPU_link(mat, "vec_math_negate", out[MAT_OUT_NORMAL].link, &out[MAT_OUT_NORMAL].link);
- GPU_link(mat, "direction_transform_m4v3", out[MAT_OUT_NORMAL].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[MAT_OUT_NORMAL].link);
- }
-
- 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;
- }
-
- return 0;
-}
-
-void register_node_type_sh_material(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_MATERIAL, "Material", NODE_CLASS_INPUT, NODE_PREVIEW);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, sh_node_material_in, sh_node_material_out);
- node_type_init(&ntype, node_shader_init_material);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_material);
- node_type_gpu(&ntype, gpu_shader_material);
-
- nodeRegisterType(&ntype);
-}
-
-
-void register_node_type_sh_material_ext(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_MATERIAL_EXT, "Extended Material", NODE_CLASS_INPUT, NODE_PREVIEW);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, sh_node_material_ext_in, sh_node_material_ext_out);
- node_type_init(&ntype, node_shader_init_material);
- node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_material);
- node_type_gpu(&ntype, gpu_shader_material);
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c
index 64f3ec94369..7033eeaead0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal.c
@@ -61,12 +61,7 @@ static void node_shader_exec_normal(void *UNUSED(data), int UNUSED(thread), bNod
static int gpu_shader_normal(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
GPUNodeLink *vec = GPU_uniform(out[0].vec);
- if (GPU_material_use_new_shading_nodes(mat)) {
- return GPU_stack_link(mat, node, "normal_new_shading", in, out, vec);
- }
- else {
- return GPU_stack_link(mat, node, "normal", in, out, vec);
- }
+ return GPU_stack_link(mat, node, "normal_new_shading", in, out, vec);
}
void register_node_type_sh_normal(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
index 7584b5eba4d..0d58be76030 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -47,80 +47,9 @@ static void node_shader_init_normal_map(bNodeTree *UNUSED(ntree), bNode *node)
}
static void node_shader_exec_normal_map(
- void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata),
- bNodeStack **in, bNodeStack **out)
+ void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata),
+ bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
{
- if (data) {
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
-
- NodeShaderNormalMap *nm = node->storage;
-
- float strength, vecIn[3];
- nodestack_get_vec(&strength, SOCK_FLOAT, in[0]);
- nodestack_get_vec(vecIn, SOCK_VECTOR, in[1]);
-
- vecIn[0] = -2 * (vecIn[0] - 0.5f);
- vecIn[1] = 2 * (vecIn[1] - 0.5f);
- vecIn[2] = 2 * (vecIn[2] - 0.5f);
-
- CLAMP_MIN(strength, 0.0f);
-
- float *N = shi->nmapnorm;
- int uv_index = 0;
- switch (nm->space) {
- case SHD_SPACE_TANGENT:
- if (nm->uv_map[0]) {
- /* find uv map by name */
- for (int i = 0; i < shi->totuv; i++) {
- if (STREQ(shi->uv[i].name, nm->uv_map)) {
- uv_index = i;
- break;
- }
- }
- }
- else {
- uv_index = shi->actuv;
- }
-
- float *T = shi->tangents[uv_index];
-
- float B[3];
- cross_v3_v3v3(B, N, T);
- mul_v3_fl(B, T[3]);
-
- for (int j = 0; j < 3; j++)
- out[0]->vec[j] = vecIn[0] * T[j] + vecIn[1] * B[j] + vecIn[2] * N[j];
- interp_v3_v3v3(out[0]->vec, N, out[0]->vec, strength);
- if (shi->use_world_space_shading) {
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEWINV_MATRIX), out[0]->vec);
- }
- break;
-
- case SHD_SPACE_OBJECT:
- case SHD_SPACE_BLENDER_OBJECT:
- if (shi->use_world_space_shading) {
- mul_mat3_m4_v3((float (*)[4])RE_object_instance_get_matrix(shi->obi, RE_OBJECT_INSTANCE_MATRIX_OB), vecIn);
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEWINV_MATRIX), N);
- }
- else
- mul_mat3_m4_v3((float (*)[4])RE_object_instance_get_matrix(shi->obi, RE_OBJECT_INSTANCE_MATRIX_LOCALTOVIEW), vecIn);
- interp_v3_v3v3(out[0]->vec, N, vecIn, strength);
- break;
-
- case SHD_SPACE_WORLD:
- case SHD_SPACE_BLENDER_WORLD:
- if (shi->use_world_space_shading)
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEWINV_MATRIX), N);
- else
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEW_MATRIX), vecIn);
- interp_v3_v3v3(out[0]->vec, N, vecIn, strength);
- break;
- }
- if (shi->use_world_space_shading) {
- negate_v3(out[0]->vec);
- }
- normalize_v3(out[0]->vec);
- }
}
static int gpu_shader_normal_map(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
@@ -145,57 +74,29 @@ static int gpu_shader_normal_map(GPUMaterial *mat, bNode *node, bNodeExecData *U
negnorm = GPU_builtin(GPU_VIEW_NORMAL);
GPU_link(mat, "math_max", strength, GPU_uniform(d), &strength);
- if (GPU_material_use_world_space_shading(mat)) {
-
- /* ******* CYCLES or BLENDER INTERNAL with world space shading flag ******* */
-
- const char *color_to_normal_fnc_name = "color_to_normal_new_shading";
- if (nm->space == SHD_SPACE_BLENDER_OBJECT || nm->space == SHD_SPACE_BLENDER_WORLD || !GPU_material_use_new_shading_nodes(mat))
- color_to_normal_fnc_name = "color_to_blender_normal_new_shading";
- switch (nm->space) {
- case SHD_SPACE_TANGENT:
- GPU_link(mat, "color_to_normal_new_shading", realnorm, &realnorm);
- GPU_link(mat, "node_normal_map", GPU_attribute(CD_TANGENT, nm->uv_map), negnorm, realnorm, &realnorm);
- GPU_link(mat, "vec_math_mix", strength, realnorm, GPU_builtin(GPU_VIEW_NORMAL), &out[0].link);
- /* for uniform scale this is sufficient to match Cycles */
- GPU_link(mat, "direction_transform_m4v3", out[0].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[0].link);
- GPU_link(mat, "vect_normalize", out[0].link, &out[0].link);
- return true;
- case SHD_SPACE_OBJECT:
- case SHD_SPACE_BLENDER_OBJECT:
- GPU_link(mat, "direction_transform_m4v3", negnorm, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &negnorm);
- GPU_link(mat, color_to_normal_fnc_name, realnorm, &realnorm);
- GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_OBJECT_MATRIX), &realnorm);
- break;
- case SHD_SPACE_WORLD:
- case SHD_SPACE_BLENDER_WORLD:
- GPU_link(mat, "direction_transform_m4v3", negnorm, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &negnorm);
- GPU_link(mat, color_to_normal_fnc_name, realnorm, &realnorm);
- break;
- }
-
- }
- else {
-
- /* ************** BLENDER INTERNAL without world space shading flag ******* */
-
- GPU_link(mat, "color_to_normal", realnorm, &realnorm);
- GPU_link(mat, "mtex_negate_texnormal", realnorm, &realnorm);
- GPU_link(mat, "vec_math_negate", negnorm, &negnorm);
-
- switch (nm->space) {
- case SHD_SPACE_TANGENT:
- GPU_link(mat, "node_normal_map", GPU_attribute(CD_TANGENT, nm->uv_map), negnorm, realnorm, &realnorm);
- break;
- case SHD_SPACE_OBJECT:
- case SHD_SPACE_BLENDER_OBJECT:
- GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_LOC_TO_VIEW_MATRIX), &realnorm);
- break;
- case SHD_SPACE_WORLD:
- case SHD_SPACE_BLENDER_WORLD:
- GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_VIEW_MATRIX), &realnorm);
- break;
- }
+ const char *color_to_normal_fnc_name = "color_to_normal_new_shading";
+ if (nm->space == SHD_SPACE_BLENDER_OBJECT || nm->space == SHD_SPACE_BLENDER_WORLD)
+ color_to_normal_fnc_name = "color_to_blender_normal_new_shading";
+ switch (nm->space) {
+ case SHD_SPACE_TANGENT:
+ GPU_link(mat, "color_to_normal_new_shading", realnorm, &realnorm);
+ GPU_link(mat, "node_normal_map", GPU_attribute(CD_TANGENT, nm->uv_map), negnorm, realnorm, &realnorm);
+ GPU_link(mat, "vec_math_mix", strength, realnorm, GPU_builtin(GPU_VIEW_NORMAL), &out[0].link);
+ /* for uniform scale this is sufficient to match Cycles */
+ GPU_link(mat, "direction_transform_m4v3", out[0].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[0].link);
+ GPU_link(mat, "vect_normalize", out[0].link, &out[0].link);
+ return true;
+ case SHD_SPACE_OBJECT:
+ case SHD_SPACE_BLENDER_OBJECT:
+ GPU_link(mat, "direction_transform_m4v3", negnorm, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &negnorm);
+ GPU_link(mat, color_to_normal_fnc_name, realnorm, &realnorm);
+ GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_OBJECT_MATRIX), &realnorm);
+ break;
+ case SHD_SPACE_WORLD:
+ case SHD_SPACE_BLENDER_WORLD:
+ GPU_link(mat, "direction_transform_m4v3", negnorm, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &negnorm);
+ GPU_link(mat, color_to_normal_fnc_name, realnorm, &realnorm);
+ break;
}
GPU_link(mat, "vec_math_mix", strength, realnorm, negnorm, &out[0].link);
diff --git a/source/blender/nodes/shader/nodes/node_shader_object_info.c b/source/blender/nodes/shader/nodes/node_shader_object_info.c
index 471331beae3..25c9bd77250 100644
--- a/source/blender/nodes/shader/nodes/node_shader_object_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_object_info.c
@@ -42,13 +42,8 @@ static int node_shader_gpu_object_info(GPUMaterial *mat, bNode *node, bNodeExecD
return GPU_stack_link(mat, node, "node_object_info", in, out, GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_OBJECT_INFO));
}
-static void node_shader_exec_object_info(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **out)
+static void node_shader_exec_object_info(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
{
- ShaderCallData *scd = (ShaderCallData *)data;
- copy_v4_v4(out[0]->vec, RE_object_instance_get_matrix(scd->shi->obi, RE_OBJECT_INSTANCE_MATRIX_OB)[3]);
- out[1]->vec[0] = RE_object_instance_get_object_pass_index(scd->shi->obi);
- out[2]->vec[0] = scd->shi->mat->index;
- out[3]->vec[0] = RE_object_instance_get_random_id(scd->shi->obi) * (1.0f / (float)0xFFFFFFFF);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c
deleted file mode 100644
index 52f659d8321..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_output.c
+++ /dev/null
@@ -1,99 +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) 2005 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/nodes/shader/nodes/node_shader_output.c
- * \ingroup shdnodes
- */
-
-
-#include "node_shader_util.h"
-
-#include "BKE_scene.h"
-
-/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_output_in[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
- { -1, 0, "" }
-};
-
-static void node_shader_exec_output(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **UNUSED(out))
-{
- if (data) {
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
- float col[4];
-
- /* stack order input sockets: col, alpha, normal */
- nodestack_get_vec(col, SOCK_VECTOR, in[0]);
- nodestack_get_vec(col + 3, SOCK_FLOAT, in[1]);
-
- if (shi->do_preview) {
- BKE_node_preview_set_pixel(execdata->preview, col, shi->xs, shi->ys, shi->do_manage);
- node->lasty = shi->ys;
- }
-
- if (node->flag & NODE_DO_OUTPUT) {
- ShadeResult *shr = ((ShaderCallData *)data)->shr;
-
- copy_v4_v4(shr->combined, col);
- shr->alpha = col[3];
-
- // copy_v3_v3(shr->nor, in[3]->vec);
- }
- }
-}
-
-static int gpu_shader_output(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- GPUNodeLink *outlink;
-
-#if 0
- if (in[1].hasinput)
- GPU_material_enable_alpha(mat);
-#endif
-
- GPU_stack_link(mat, node, "output_node", in, out, &outlink);
- GPU_material_output_link(mat, outlink);
-
- return 1;
-}
-
-void register_node_type_sh_output(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, sh_node_output_in, NULL);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_output);
- node_type_gpu(&ntype, gpu_shader_output);
-
- /* Do not allow muting output node. */
- node_type_internal_links(&ntype, NULL);
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
index 69fcbba8f88..46cb513a6d9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
@@ -42,11 +42,8 @@ static bNodeSocketTemplate outputs[] = {
{ SOCK_VECTOR, 0, "Angular Velocity" },
{ -1, 0, "" }
};
-static void node_shader_exec_particle_info(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **out)
+static void node_shader_exec_particle_info(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
{
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
-
- RE_instance_get_particle_info(shi->obi, out[0]->vec, out[1]->vec, out[2]->vec, out[3]->vec, out[4]->vec, out[5]->vec, out[6]->vec, out[7]->vec);
}
static int gpu_shader_particle_info(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c
deleted file mode 100644
index 755ef106ade..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_texture.c
+++ /dev/null
@@ -1,166 +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) 2005 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/nodes/shader/nodes/node_shader_texture.c
- * \ingroup shdnodes
- */
-
-#include "DNA_texture_types.h"
-
-#include "node_shader_util.h"
-
-#include "GPU_material.h"
-
-/* **************** TEXTURE ******************** */
-static bNodeSocketTemplate sh_node_texture_in[] = {
- { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, /* no limit */
- { -1, 0, "" }
-};
-static bNodeSocketTemplate sh_node_texture_out[] = {
- { SOCK_FLOAT, 0, N_("Value"), 0, 0, 0, 0, 0, 0, PROP_NONE, SOCK_NO_INTERNAL_LINK},
- { SOCK_RGBA, 0, N_("Color"), 0, 0, 0, 0, 0, 0, PROP_NONE, SOCK_NO_INTERNAL_LINK},
- { SOCK_VECTOR, 0, N_("Normal"), 0, 0, 0, 0, 0, 0, PROP_NONE, SOCK_NO_INTERNAL_LINK},
- { -1, 0, "" }
-};
-
-static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
-{
- if (data && node->id) {
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
- TexResult texres;
- bNodeSocket *sock_vector = node->inputs.first;
- float vec[3], nor[3] = {0.0f, 0.0f, 0.0f};
- int retval;
- short which_output = node->custom1;
-
- short thread = shi->thread;
-
- /* out: value, color, normal */
-
- /* we should find out if a normal as output is needed, for now we do all */
- texres.nor = nor;
- texres.tr = texres.tg = texres.tb = 0.0f;
-
- /* don't use in[0]->hasinput, see material node for explanation */
- if (sock_vector->link) {
- nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
-
- if (in[0]->datatype == NS_OSA_VECTORS) {
- float *fp = in[0]->data;
- retval = multitex_nodes((Tex *)node->id, vec, fp, fp + 3, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL);
- }
- else if (in[0]->datatype == NS_OSA_VALUES) {
- const float *fp = in[0]->data;
- float dxt[3], dyt[3];
-
- dxt[0] = fp[0]; dxt[1] = dxt[2] = 0.0f;
- dyt[0] = fp[1]; dyt[1] = dyt[2] = 0.0f;
- retval = multitex_nodes((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL);
- }
- else
- retval = multitex_nodes((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output, NULL, NULL, NULL);
- }
- else {
- copy_v3_v3(vec, shi->lo);
- retval = multitex_nodes((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output, NULL, NULL, NULL);
- }
-
- /* stupid exception */
- if ( ((Tex *)node->id)->type == TEX_STUCCI) {
- texres.tin = 0.5f + 0.7f * texres.nor[0];
- CLAMP(texres.tin, 0.0f, 1.0f);
- }
-
- /* intensity and color need some handling */
- if (texres.talpha)
- out[0]->vec[0] = texres.ta;
- else
- out[0]->vec[0] = texres.tin;
-
- if ((retval & TEX_RGB) == 0) {
- copy_v3_fl(out[1]->vec, out[0]->vec[0]);
- out[1]->vec[3] = 1.0f;
- }
- else {
- copy_v3_v3(out[1]->vec, &texres.tr);
- out[1]->vec[3] = 1.0f;
- }
-
- copy_v3_v3(out[2]->vec, nor);
-
- if (shi->do_preview) {
- BKE_node_preview_set_pixel(execdata->preview, out[1]->vec, shi->xs, shi->ys, shi->do_manage);
- }
-
- }
-}
-
-static int gpu_shader_texture(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- Tex *tex = (Tex *)node->id;
-
- if (tex && tex->ima && (tex->type == TEX_IMAGE || tex->type == TEX_ENVMAP)) {
- if (tex->type == TEX_IMAGE) {
- GPUNodeLink *texlink = GPU_image(tex->ima, &tex->iuser, false);
- GPU_stack_link(mat, node, "texture_image", in, out, texlink);
- }
- else { /* TEX_ENVMAP */
- if (!in[0].link)
- in[0].link = GPU_uniform(in[0].vec);
- if (!GPU_material_use_world_space_shading(mat))
- GPU_link(mat, "direction_transform_m4v3", in[0].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &in[0].link);
- GPU_link(mat, "mtex_cube_map_refl_from_refldir",
- GPU_cube_map(tex->ima, &tex->iuser, false), in[0].link, &out[0].link, &out[1].link);
- GPU_link(mat, "color_to_normal", out[1].link, &out[2].link);
- }
-
- ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL);
- if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
- GPU_material_do_color_management(mat))
- {
- GPU_link(mat, "srgb_to_linearrgb", out[1].link, &out[1].link);
- }
- BKE_image_release_ibuf(tex->ima, ibuf, NULL);
-
- return true;
- }
-
- return false;
-}
-
-void register_node_type_sh_texture(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_PREVIEW);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, sh_node_texture_in, sh_node_texture_out);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_texture);
- node_type_gpu(&ntype, gpu_shader_texture);
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
index 74e23aed7de..71bb88f892f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
@@ -52,68 +52,8 @@ static void node_shader_init_vect_transform(bNodeTree *UNUSED(ntree), bNode *nod
node->storage = vect;
}
-static const float (* get_matrix_from_to(ShaderCallData *scd, short from, short to))[4]
+static void node_shader_exec_vect_transform(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
{
- switch (from) {
- case SHD_VECT_TRANSFORM_SPACE_OBJECT:
- switch (to) {
- case SHD_VECT_TRANSFORM_SPACE_OBJECT:
- return NULL;
- case SHD_VECT_TRANSFORM_SPACE_WORLD:
- return RE_object_instance_get_matrix(scd->shi->obi, RE_OBJECT_INSTANCE_MATRIX_OB);
- case SHD_VECT_TRANSFORM_SPACE_CAMERA:
- return RE_object_instance_get_matrix(scd->shi->obi, RE_OBJECT_INSTANCE_MATRIX_LOCALTOVIEW);
- }
- break;
- case SHD_VECT_TRANSFORM_SPACE_WORLD:
- switch (to) {
- case SHD_VECT_TRANSFORM_SPACE_WORLD:
- return NULL;
- case SHD_VECT_TRANSFORM_SPACE_CAMERA:
- return RE_render_current_get_matrix(RE_VIEW_MATRIX);
- case SHD_VECT_TRANSFORM_SPACE_OBJECT:
- return RE_object_instance_get_matrix(scd->shi->obi, RE_OBJECT_INSTANCE_MATRIX_OBINV);
- }
- break;
- case SHD_VECT_TRANSFORM_SPACE_CAMERA:
- switch (to) {
- case SHD_VECT_TRANSFORM_SPACE_CAMERA:
- return NULL;
- case SHD_VECT_TRANSFORM_SPACE_WORLD:
- return RE_render_current_get_matrix(RE_VIEWINV_MATRIX);
- case SHD_VECT_TRANSFORM_SPACE_OBJECT:
- return RE_object_instance_get_matrix(scd->shi->obi, RE_OBJECT_INSTANCE_MATRIX_LOCALTOVIEWINV);
- }
- break;
- }
- return NULL;
-}
-
-static void node_shader_exec_vect_transform(void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
-{
- float vec[4];
- const float (*mat)[4];
-
- if (data) {
- NodeShaderVectTransform *nodeprop = (NodeShaderVectTransform *)node->storage;
-
- nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
-
- if (nodeprop->type == SHD_VECT_TRANSFORM_TYPE_POINT)
- vec[3] = 1.0f;
- else
- vec[3] = 0.0f;
-
- mat = get_matrix_from_to((ShaderCallData *)data, nodeprop->convert_from, nodeprop->convert_to);
- if (mat) {
- mul_m4_v4((float(*)[4])mat, vec);
- }
-
- if (nodeprop->type == SHD_VECT_TRANSFORM_TYPE_NORMAL)
- normalize_v3(vec);
-
- copy_v4_v4(out[0]->vec, vec);
- }
}
static GPUNodeLink *get_gpulink_matrix_from_to(short from, short to)
@@ -161,8 +101,6 @@ static int gpu_shader_vect_transform(GPUMaterial *mat, bNode *node, bNodeExecDat
const char *ptransform = "point_transform_m4v3";
const char *func_name = 0;
- bool new_shading = GPU_material_use_new_shading_nodes(mat);
-
NodeShaderVectTransform *nodeprop = (NodeShaderVectTransform *)node->storage;
if (in[0].hasinput)
@@ -174,19 +112,14 @@ static int gpu_shader_vect_transform(GPUMaterial *mat, bNode *node, bNodeExecDat
func_name = (nodeprop->type == SHD_VECT_TRANSFORM_TYPE_POINT) ? ptransform : vtransform;
if (fromto) {
- if (new_shading) {
- /* For cycles we have inverted Z */
- /* TODO: pass here the correct matrices */
- if (nodeprop->convert_from == SHD_VECT_TRANSFORM_SPACE_CAMERA && nodeprop->convert_to != SHD_VECT_TRANSFORM_SPACE_CAMERA) {
- GPU_link(mat, "invert_z", inputlink, &inputlink);
- }
- GPU_link(mat, func_name, inputlink, fromto, &out[0].link);
- if (nodeprop->convert_to == SHD_VECT_TRANSFORM_SPACE_CAMERA && nodeprop->convert_from != SHD_VECT_TRANSFORM_SPACE_CAMERA) {
- GPU_link(mat, "invert_z", out[0].link, &out[0].link);
- }
+ /* For cycles we have inverted Z */
+ /* TODO: pass here the correct matrices */
+ if (nodeprop->convert_from == SHD_VECT_TRANSFORM_SPACE_CAMERA && nodeprop->convert_to != SHD_VECT_TRANSFORM_SPACE_CAMERA) {
+ GPU_link(mat, "invert_z", inputlink, &inputlink);
}
- else {
- GPU_link(mat, func_name, inputlink, fromto, &out[0].link);
+ GPU_link(mat, func_name, inputlink, fromto, &out[0].link);
+ if (nodeprop->convert_to == SHD_VECT_TRANSFORM_SPACE_CAMERA && nodeprop->convert_from != SHD_VECT_TRANSFORM_SPACE_CAMERA) {
+ GPU_link(mat, "invert_z", out[0].link, &out[0].link);
}
}
else
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 932b60665c4..5e57338dc57 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -68,32 +68,7 @@ static void texture_get_from_context(
Object *ob = OBACT(view_layer);
Tex *tx = NULL;
- if (snode->texfrom == SNODE_TEX_OBJECT) {
- if (ob) {
- tx = give_current_object_texture(ob);
- if (tx) {
- if (ob->type == OB_LAMP)
- *r_from = (ID *)ob->data;
- else
- *r_from = (ID *)give_current_material(ob, ob->actcol);
-
- /* from is not set fully for material nodes, should be ID + Node then */
- *r_id = &tx->id;
- *r_ntree = tx->nodetree;
- }
- }
- }
- else if (snode->texfrom == SNODE_TEX_WORLD) {
- if (scene->world) {
- *r_from = (ID *)scene->world;
- tx = give_current_world_texture(scene->world);
- if (tx) {
- *r_id = &tx->id;
- *r_ntree = tx->nodetree;
- }
- }
- }
- else if (snode->texfrom == SNODE_TEX_BRUSH) {
+ if (snode->texfrom == SNODE_TEX_BRUSH) {
struct Brush *brush = NULL;
if (ob && (ob->mode & OB_MODE_SCULPT))
@@ -123,7 +98,7 @@ static void texture_get_from_context(
}
}
-static void foreach_nodeclass(ViewRender *UNUSED(view_render), void *calldata, bNodeClassCallback func)
+static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
{
func(calldata, NODE_CLASS_INPUT, N_("Input"));
func(calldata, NODE_CLASS_OUTPUT, N_("Output"));
@@ -324,7 +299,6 @@ int ntreeTexExecTree(
short which_output,
int cfra,
int preview,
- ShadeInput *shi,
MTex *mtex)
{
TexCallData data;
@@ -339,12 +313,11 @@ int ntreeTexExecTree(
data.osatex = osatex;
data.target = texres;
data.do_preview = preview;
- data.do_manage = (shi) ? shi->do_manage : true;
+ data.do_manage = true;
data.thread = thread;
data.which_output = which_output;
data.cfra = cfra;
data.mtex = mtex;
- data.shi = shi;
/* ensure execdata is only initialized once */
if (!exec) {
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index 32720364f73..8cb61478c41 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -124,7 +124,6 @@ void params_from_cdata(TexParams *out, TexCallData *in)
out->previewco = in->co;
out->osatex = in->osatex;
out->cfra = in->cfra;
- out->shi = in->shi;
out->mtex = in->mtex;
}
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index f6af5b1b6ca..82ba573425a 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -87,7 +87,6 @@ typedef struct TexCallData {
short which_output;
int cfra;
- ShadeInput *shi;
MTex *mtex;
} TexCallData;
@@ -100,7 +99,6 @@ typedef struct TexParams {
/* optional. we don't really want these here, but image
* textures need to do mapping & color correction */
- ShadeInput *shi;
MTex *mtex;
} TexParams;
diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c
index 0be5f875a23..c16d723e1e1 100644
--- a/source/blender/nodes/texture/nodes/node_texture_proc.c
+++ b/source/blender/nodes/texture/nodes/node_texture_proc.c
@@ -69,7 +69,7 @@ static void do_proc(float *result, TexParams *p, const float col1[4], const floa
texres.nor = NULL;
textype = multitex_nodes(tex, p->co, p->dxt, p->dyt, p->osatex,
- &texres, thread, 0, p->shi, p->mtex, NULL);
+ &texres, thread, 0, p->mtex, NULL);
if (is_normal)
return;
diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c
index 1fd0a55dc63..7e035d522f7 100644
--- a/source/blender/nodes/texture/nodes/node_texture_texture.c
+++ b/source/blender/nodes/texture/nodes/node_texture_texture.c
@@ -78,7 +78,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
texres.nor = nor;
textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex,
- &texres, thread, 0, p->shi, p->mtex, NULL);
+ &texres, thread, 0, p->mtex, NULL);
if (textype & TEX_RGB) {
copy_v4_v4(out, &texres.tr);
diff --git a/source/blender/physics/BPH_mass_spring.h b/source/blender/physics/BPH_mass_spring.h
index c650d83c927..e89aec1456e 100644
--- a/source/blender/physics/BPH_mass_spring.h
+++ b/source/blender/physics/BPH_mass_spring.h
@@ -58,8 +58,6 @@ void BPH_cloth_solver_free(struct ClothModifierData *clmd);
int BPH_cloth_solve(struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors);
void BKE_cloth_solver_set_positions(struct ClothModifierData *clmd);
-bool BPH_cloth_solver_get_texture_data(struct Object *ob, struct ClothModifierData *clmd, struct VoxelData *vd);
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 5b5639495da..e5724c97bbc 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -1091,24 +1091,3 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
return 1;
}
-
-bool BPH_cloth_solver_get_texture_data(Object *UNUSED(ob), ClothModifierData *clmd, VoxelData *vd)
-{
- Cloth *cloth = clmd->clothObject;
- HairGrid *grid;
- float gmin[3], gmax[3];
-
- if (!clmd->clothObject || !clmd->clothObject->implicit)
- return false;
-
- hair_get_boundbox(clmd, gmin, gmax);
-
- grid = BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_cell_size, gmin, gmax);
- cloth_continuum_fill_grid(grid, cloth);
-
- BPH_hair_volume_get_texture_data(grid, vd);
-
- BPH_hair_volume_free_vertex_grid(grid);
-
- return true;
-}
diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp
index 5cc1231e6cb..05d30657af8 100644
--- a/source/blender/physics/intern/hair_volume.cpp
+++ b/source/blender/physics/intern/hair_volume.cpp
@@ -1099,56 +1099,3 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
return collgrid;
}
#endif
-
-bool BPH_hair_volume_get_texture_data(HairGrid *grid, VoxelData *vd)
-{
- int totres, i;
- int depth;
-
- vd->resol[0] = grid->res[0];
- vd->resol[1] = grid->res[1];
- vd->resol[2] = grid->res[2];
-
- totres = hair_grid_size(grid->res);
-
- if (vd->hair_type == TEX_VD_HAIRVELOCITY) {
- depth = 4;
- vd->data_type = TEX_VD_RGBA_PREMUL;
- }
- else {
- depth = 1;
- vd->data_type = TEX_VD_INTENSITY;
- }
-
- if (totres > 0) {
- vd->dataset = (float *)MEM_mapallocN(sizeof(float) * depth * (totres), "hair volume texture data");
-
- for (i = 0; i < totres; ++i) {
- switch (vd->hair_type) {
- case TEX_VD_HAIRDENSITY:
- vd->dataset[i] = grid->verts[i].density;
- break;
-
- case TEX_VD_HAIRRESTDENSITY:
- vd->dataset[i] = 0.0f; // TODO
- break;
-
- case TEX_VD_HAIRVELOCITY: {
- vd->dataset[i + 0*totres] = grid->verts[i].velocity[0];
- vd->dataset[i + 1*totres] = grid->verts[i].velocity[1];
- vd->dataset[i + 2*totres] = grid->verts[i].velocity[2];
- vd->dataset[i + 3*totres] = len_v3(grid->verts[i].velocity);
- break;
- }
- case TEX_VD_HAIRENERGY:
- vd->dataset[i] = 0.0f; // TODO
- break;
- }
- }
- }
- else {
- vd->dataset = NULL;
- }
-
- return true;
-}
diff --git a/source/blender/physics/intern/implicit.h b/source/blender/physics/intern/implicit.h
index 2f62ab98e12..d6bf5c6b7bf 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -171,8 +171,6 @@ void BPH_hair_volume_vertex_grid_forces(struct HairGrid *grid, const float x[3],
float smoothfac, float pressurefac, float minpressure,
float f[3], float dfdx[3][3], float dfdv[3][3]);
-bool BPH_hair_volume_get_texture_data(struct HairGrid *grid, struct VoxelData *vd);
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index ec787768a57..a6ed92d139c 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -933,7 +933,7 @@ PyDoc_STRVAR(bpy_bmesh_from_object_doc,
);
static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject *kw)
{
- /* TODO: This doesn't work currently because of eval_ctx. */
+ /* TODO: This doesn't work currently because of missing depsgraph. */
#if 0
static const char *kwlist[] = {"object", "scene", "deform", "render", "cage", "face_normals", NULL};
PyObject *py_object;
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index ffac09efdde..750d0c20301 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -116,16 +116,6 @@ void bpy_import_main_set(struct Main *maggie)
bpy_import_main = maggie;
}
-void bpy_import_main_extra_add(struct Main *maggie)
-{
- BLI_addhead(&bpy_import_main_list, maggie);
-}
-
-void bpy_import_main_extra_remove(struct Main *maggie)
-{
- BLI_remlink_safe(&bpy_import_main_list, maggie);
-}
-
/* returns a dummy filename for a textblock so we can tell what file a text block comes from */
void bpy_text_filename_get(char *fn, size_t fn_len, Text *text)
{
diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h
index 905e045d657..f11571fb933 100644
--- a/source/blender/python/generic/bpy_internal_import.h
+++ b/source/blender/python/generic/bpy_internal_import.h
@@ -51,12 +51,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found);
void bpy_text_filename_get(char *fn, size_t fn_len, struct Text *text);
-/* The game engine has its own Main struct, if this is set search this rather than G.main */
struct Main *bpy_import_main_get(void);
void bpy_import_main_set(struct Main *maggie);
-/* This is used for importing text from dynamically loaded libraries in the game engine */
-void bpy_import_main_extra_add(struct Main *maggie);
-void bpy_import_main_extra_remove(struct Main *maggie);
-
#endif /* __BPY_INTERNAL_IMPORT_H__ */
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index fe7a046d99c..9f3c10bfd67 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -76,7 +76,7 @@ PyObject * PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size);
const char * PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */
const char * PyC_UnicodeAsByteAndSize(PyObject *py_str, Py_ssize_t *size, PyObject **coerce);
-/* name namespace function for bpy & bge */
+/* name namespace function for bpy */
PyObject * PyC_DefaultNameSpace(const char *filename);
void PyC_RunQuicky(const char *filepath, int n, ...);
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index f9098529772..c6cab3dda65 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -52,6 +52,7 @@ set(SRC
bpy_app_build_options.c
bpy_app_ffmpeg.c
bpy_app_handlers.c
+ bpy_app_icons.c
bpy_app_ocio.c
bpy_app_oiio.c
bpy_app_opensubdiv.c
@@ -93,6 +94,7 @@ set(SRC
bpy_app_build_options.h
bpy_app_ffmpeg.h
bpy_app_handlers.h
+ bpy_app_icons.h
bpy_app_ocio.h
bpy_app_oiio.h
bpy_app_opensubdiv.h
@@ -180,10 +182,6 @@ if(WITH_FREESTYLE)
add_definitions(-DWITH_FREESTYLE)
endif()
-if(WITH_GAMEENGINE)
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
if(WITH_IMAGE_CINEON)
add_definitions(-DWITH_CINEON)
endif()
@@ -306,10 +304,6 @@ if(WITH_OPENSUBDIV)
)
endif()
-if(WITH_PLAYER)
- add_definitions(-DWITH_PLAYER)
-endif()
-
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_python "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 1e2ce372727..f6e89ef38a5 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -47,6 +47,9 @@
#include "bpy_app_handlers.h"
#include "bpy_driver.h"
+/* modules */
+#include "bpy_app_icons.h"
+
#include "BLI_utildefines.h"
#include "BKE_appdir.h"
@@ -117,6 +120,9 @@ static PyStructSequence_Field app_info_fields[] = {
{(char *)"build_options", (char *)"A set containing most important enabled optional build features"},
{(char *)"handlers", (char *)"Application handler callbacks"},
{(char *)"translations", (char *)"Application and addons internationalization API"},
+
+ /* Modules (not struct sequence). */
+ {(char *)"icons", (char *)"Manage custom icons"},
{NULL},
};
@@ -129,6 +135,7 @@ PyDoc_STRVAR(bpy_app_doc,
" :maxdepth: 1\n"
"\n"
" bpy.app.handlers.rst\n"
+" bpy.app.icons.rst\n"
" bpy.app.translations.rst\n"
);
@@ -210,6 +217,9 @@ static PyObject *make_app_info(void)
SetObjItem(BPY_app_handlers_struct());
SetObjItem(BPY_app_translations_struct());
+ /* modules */
+ SetObjItem(BPY_app_icons_module());
+
#undef SetIntItem
#undef SetStrItem
#undef SetBytesItem
diff --git a/source/blender/python/intern/bpy_app_build_options.c b/source/blender/python/intern/bpy_app_build_options.c
index d5c325e4317..6e3f8da31f9 100644
--- a/source/blender/python/intern/bpy_app_build_options.c
+++ b/source/blender/python/intern/bpy_app_build_options.c
@@ -42,7 +42,6 @@ static PyStructSequence_Field app_builtopts_info_fields[] = {
{(char *)"cycles", NULL},
{(char *)"cycles_osl", NULL},
{(char *)"freestyle", NULL},
- {(char *)"gameengine", NULL},
{(char *)"image_cineon", NULL},
{(char *)"image_dds", NULL},
{(char *)"image_frameserver", NULL},
@@ -64,7 +63,6 @@ static PyStructSequence_Field app_builtopts_info_fields[] = {
{(char *)"mod_smoke", NULL},
{(char *)"collada", NULL},
{(char *)"opencolorio", NULL},
- {(char *)"player", NULL},
{(char *)"openmp", NULL},
{(char *)"openvdb", NULL},
{(char *)"alembic", NULL},
@@ -140,12 +138,6 @@ static PyObject *make_builtopts_info(void)
SetObjIncref(Py_False);
#endif
-#ifdef WITH_GAMEENGINE
- SetObjIncref(Py_True);
-#else
- SetObjIncref(Py_False);
-#endif
-
#ifdef WITH_CINEON
SetObjIncref(Py_True);
#else
@@ -272,12 +264,6 @@ static PyObject *make_builtopts_info(void)
SetObjIncref(Py_False);
#endif
-#ifdef WITH_PLAYER
- SetObjIncref(Py_True);
-#else
- SetObjIncref(Py_False);
-#endif
-
#ifdef _OPENMP
SetObjIncref(Py_True);
#else
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 5a309339e17..948a78d5794 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -59,8 +59,6 @@ static PyStructSequence_Field app_cb_info_fields[] = {
{(char *)"load_post", (char *)"on loading a new blend file (after)"},
{(char *)"save_pre", (char *)"on saving a blend file (before)"},
{(char *)"save_post", (char *)"on saving a blend file (after)"},
- {(char *)"game_pre", (char *)"on starting the game engine"},
- {(char *)"game_post", (char *)"on ending the game engine"},
{(char *)"version_update", (char *)"on ending the versioning code"},
/* sets the permanent tag */
diff --git a/source/blender/python/intern/bpy_app_icons.c b/source/blender/python/intern/bpy_app_icons.c
new file mode 100644
index 00000000000..8aeee1aff9c
--- /dev/null
+++ b/source/blender/python/intern/bpy_app_icons.c
@@ -0,0 +1,134 @@
+/*
+ * ***** 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 blender/python/intern/bpy_app_icons.c
+ * \ingroup pythonintern
+ *
+ * Runtime defined icons.
+ */
+
+#include <Python.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
+#include "BKE_icons.h"
+
+#include "../generic/py_capi_utils.h"
+
+#include "bpy_app_icons.h"
+
+/* We may want to load direct from file. */
+PyDoc_STRVAR(bpy_app_icons_new_triangles_doc,
+".. function:: new_triangles(coords, colors)"
+"\n"
+" Create a new icon from triangle geometry.\n"
+"\n"
+" :arg coords: Sequence of bytes (6 floats for one triangle) for (X, Y) coordinates.\n"
+" :type coords: byte sequence\n"
+" :arg colors: Sequence of ints (12 for one triangles) for RGBA.\n"
+" :type colors: byte sequence\n"
+" :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
+" :rtype: int\n"
+);
+static PyObject *bpy_app_icons_new_triangles(PyObject *UNUSED(self), PyObject *args)
+{
+ /* bytes */
+ PyObject *py_coords, *py_colors;
+ if (!PyArg_ParseTuple(args, "SS:new_triangles", &py_coords, &py_colors)) {
+ return NULL;
+ }
+
+ const int coords_len = PyBytes_GET_SIZE(py_coords);
+ const int tris_len = coords_len / 6;
+ if (tris_len * 6 != coords_len) {
+ PyErr_SetString(PyExc_ValueError, "coords must be multiple of 6");
+ return NULL;
+ }
+ if (PyBytes_GET_SIZE(py_colors) != 2 * coords_len) {
+ PyErr_SetString(PyExc_ValueError, "colors must be twice size of coords");
+ return NULL;
+ }
+
+ int coords_size = sizeof(uchar[2]) * tris_len * 3;
+ int colors_size = sizeof(uchar[4]) * tris_len * 3;
+ uchar (*coords)[2] = MEM_mallocN(coords_size, __func__);
+ uchar (*colors)[4] = MEM_mallocN(colors_size, __func__);
+
+ memcpy(coords, PyBytes_AS_STRING(py_coords), coords_size);
+ memcpy(colors, PyBytes_AS_STRING(py_colors), colors_size);
+
+ struct Icon_Geom *geom = MEM_mallocN(sizeof(*geom), __func__);
+ geom->coords_len = tris_len;
+ geom->coords = coords;
+ geom->colors = colors;
+ geom->icon_id = 0;
+ int icon_id = BKE_icon_geom_ensure(geom);
+ return PyLong_FromLong(icon_id);
+}
+
+PyDoc_STRVAR(bpy_app_icons_release_doc,
+".. function:: release(icon_id)"
+"\n"
+" Release the icon.\n"
+);
+static PyObject *bpy_app_icons_release(PyObject *UNUSED(self), PyObject *args)
+{
+ int icon_id;
+ static _PyArg_Parser _parser = {"i:release", NULL, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, NULL, &_parser,
+ &icon_id))
+ {
+ return NULL;
+ }
+
+ if (!BKE_icon_delete_unmanaged(icon_id)) {
+ PyErr_SetString(PyExc_ValueError, "invalid icon_id");
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
+static struct PyMethodDef M_AppIcons_methods[] = {
+ {"new_triangles", (PyCFunction)bpy_app_icons_new_triangles, METH_VARARGS, bpy_app_icons_new_triangles_doc},
+ {"release", (PyCFunction)bpy_app_icons_release, METH_VARARGS, bpy_app_icons_release_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+static struct PyModuleDef M_AppIcons_module_def = {
+ PyModuleDef_HEAD_INIT,
+ "bpy.app.icons", /* m_name */
+ NULL, /* m_doc */
+ 0, /* m_size */
+ M_AppIcons_methods, /* m_methods */
+ NULL, /* m_reload */
+ NULL, /* m_traverse */
+ NULL, /* m_clear */
+ NULL, /* m_free */
+};
+
+PyObject *BPY_app_icons_module(void)
+{
+ PyObject *mod = PyModule_Create(&M_AppIcons_module_def);
+
+ return mod;
+}
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h b/source/blender/python/intern/bpy_app_icons.h
index 00aa53feb27..309c7ed222f 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h
+++ b/source/blender/python/intern/bpy_app_icons.h
@@ -15,18 +15,16 @@
* 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/KXNetwork/KX_NetworkObjectSensor.h
- * \ingroup ketsjinet
+/** \file blender/python/intern/bpy_app_icons.h
+ * \ingroup pythonintern
*/
+#ifndef __BPY_APP_ICONS_H__
+#define __BPY_APP_ICONS_H__
+
+PyObject *BPY_app_icons_module(void);
+#endif /* __BPY_APP_ICONS_H__ */
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 12cce685533..f6feac1deeb 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -3509,6 +3509,68 @@ static PyObject *pyrna_struct_is_property_readonly(BPy_StructRNA *self, PyObject
return PyBool_FromLong(!RNA_property_editable(&self->ptr, prop));
}
+
+PyDoc_STRVAR(pyrna_struct_is_property_overridable_static_doc,
+".. method:: is_property_overridable_static(property)\n"
+"\n"
+" Check if a property is statically overridable.\n"
+"\n"
+" :return: True when the property is statically overridable.\n"
+" :rtype: boolean\n"
+);
+static PyObject *pyrna_struct_is_property_overridable_static(BPy_StructRNA *self, PyObject *args)
+{
+ PropertyRNA *prop;
+ const char *name;
+
+ PYRNA_STRUCT_CHECK_OBJ(self);
+
+ if (!PyArg_ParseTuple(args, "s:is_property_overridable_static", &name)) {
+ return NULL;
+ }
+
+ if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.is_property_overridable_static(\"%.200s\") not found",
+ RNA_struct_identifier(self->ptr.type), name);
+ return NULL;
+ }
+
+ return PyBool_FromLong((long)RNA_property_overridable_get(&self->ptr, prop));
+}
+
+PyDoc_STRVAR(pyrna_struct_property_overridable_static_set_doc,
+".. method:: property_overridable_static_set(property)\n"
+"\n"
+" Define a property as statically overridable or not (only for custom properties!).\n"
+"\n"
+" :return: True when the overridable status of the property was successfully set.\n"
+" :rtype: boolean\n"
+);
+static PyObject *pyrna_struct_property_overridable_static_set(BPy_StructRNA *self, PyObject *args)
+{
+ PropertyRNA *prop;
+ const char *name;
+ int is_overridable;
+
+ PYRNA_STRUCT_CHECK_OBJ(self);
+
+ if (!PyArg_ParseTuple(args, "sp:property_overridable_static_set", &name, &is_overridable)) {
+ return NULL;
+ }
+
+ if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.property_overridable_static_set(\"%.200s\") not found",
+ RNA_struct_identifier(self->ptr.type), name);
+ return NULL;
+ }
+
+ return PyBool_FromLong((long)RNA_property_overridable_static_set(&self->ptr, prop, (bool)is_overridable));
+}
+
+
+
PyDoc_STRVAR(pyrna_struct_path_resolve_doc,
".. method:: path_resolve(path, coerce=True)\n"
"\n"
@@ -5122,6 +5184,8 @@ static struct PyMethodDef pyrna_struct_methods[] = {
{"property_unset", (PyCFunction)pyrna_struct_property_unset, METH_VARARGS, pyrna_struct_property_unset_doc},
{"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, pyrna_struct_is_property_hidden_doc},
{"is_property_readonly", (PyCFunction)pyrna_struct_is_property_readonly, METH_VARARGS, pyrna_struct_is_property_readonly_doc},
+ {"is_property_overridable_static", (PyCFunction)pyrna_struct_is_property_overridable_static, METH_VARARGS, pyrna_struct_is_property_overridable_static_doc},
+ {"property_overridable_static_set", (PyCFunction)pyrna_struct_property_overridable_static_set, METH_VARARGS, pyrna_struct_property_overridable_static_set_doc},
{"path_resolve", (PyCFunction)pyrna_struct_path_resolve, METH_VARARGS, pyrna_struct_path_resolve_doc},
{"path_from_id", (PyCFunction)pyrna_struct_path_from_id, METH_VARARGS, pyrna_struct_path_from_id_doc},
{"type_recast", (PyCFunction)pyrna_struct_type_recast, METH_NOARGS, pyrna_struct_type_recast_doc},
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index 68783feacd9..6b8684c7acd 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -168,9 +168,7 @@ static eSpace_Type rna_Space_refine_reverse(StructRNA *srna)
if (srna == &RNA_SpaceTextEditor) return SPACE_TEXT;
if (srna == &RNA_SpaceDopeSheetEditor) return SPACE_ACTION;
if (srna == &RNA_SpaceNLA) return SPACE_NLA;
- if (srna == &RNA_SpaceTimeline) return SPACE_TIME;
if (srna == &RNA_SpaceNodeEditor) return SPACE_NODE;
- if (srna == &RNA_SpaceLogicEditor) return SPACE_LOGIC;
if (srna == &RNA_SpaceConsole) return SPACE_CONSOLE;
if (srna == &RNA_SpaceUserPreferences) return SPACE_USERPREF;
if (srna == &RNA_SpaceClipEditor) return SPACE_CLIP;
@@ -189,7 +187,7 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
StructRNA *srna;
if (PyTuple_GET_SIZE(args) < 2) {
- PyErr_SetString(PyExc_ValueError, "handler_add(handle): expected at least 2 args");
+ PyErr_SetString(PyExc_ValueError, "handler_add(handler): expected at least 2 args");
return NULL;
}
@@ -252,7 +250,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
int cb_regiontype;
if (PyTuple_GET_SIZE(args) < 2) {
- PyErr_SetString(PyExc_ValueError, "callback_remove(handle): expected at least 2 args");
+ PyErr_SetString(PyExc_ValueError, "callback_remove(handler): expected at least 2 args");
return NULL;
}
@@ -263,7 +261,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
py_handle = PyTuple_GET_ITEM(args, 1);
handle = PyCapsule_GetPointer(py_handle, RNA_CAPSULE_ID);
if (handle == NULL) {
- PyErr_SetString(PyExc_ValueError, "callback_remove(handle): NULL handle given, invalid or already removed");
+ PyErr_SetString(PyExc_ValueError, "callback_remove(handler): NULL handler given, invalid or already removed");
return NULL;
}
diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c
index a7a0ae78f26..06f3143ec46 100644
--- a/source/blender/python/intern/gpu.c
+++ b/source/blender/python/intern/gpu.c
@@ -55,7 +55,7 @@
#define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, # name, name)
PyDoc_STRVAR(M_gpu_doc,
-"This module provides access to the GLSL shader and Offscreen rendering functionalities."
+"This module provides access to GPU offscreen rendering, matrix stacks and selection."
);
static struct PyModuleDef gpumodule = {
PyModuleDef_HEAD_INIT,
@@ -74,251 +74,10 @@ static PyObject *PyInit_gpu(void)
if (m == NULL)
return NULL;
-
/* Take care to update docs when editing: 'doc/python_api/rst/gpu.rst' */
-
-
- /* -------------------------------------------------------------------- */
- /* GPUDynamicType */
-
- /* device constant groups */
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_MISC);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_LAMP);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_OBJECT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_SAMPLER);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_MIST);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_WORLD);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_GROUP_MAT);
-
- /* device constants */
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_NONE);
- /* GPU_DYNAMIC_GROUP_OBJECT */
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWMAT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_MAT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWIMAT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_IMAT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_LOCTOVIEWMAT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_LOCTOVIEWIMAT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_COLOR);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE);
- /* GPU_DYNAMIC_GROUP_LAMP */
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNVEC);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNCO);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNIMAT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNPERSMAT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNENERGY);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNCOL);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_ATT1);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_ATT2);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DISTANCE);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_SPOTSIZE);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_SPOTBLEND);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_SPOTSCALE);
- /* GPU_DYNAMIC_GROUP_SAMPLER */
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_SAMPLER_2DBUFFER);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_SAMPLER_2DIMAGE);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_SAMPLER_2DSHADOW);
- /* GPU_DYNAMIC_GROUP_MIST */
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_ENABLE);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_START);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_DISTANCE);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_INTENSITY);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_TYPE);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MIST_COLOR);
- /* GPU_DYNAMIC_GROUP_WORLD */
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_HORIZON_COLOR);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_AMBIENT_COLOR);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_ZENITH_COLOR);
- /* GPU_DYNAMIC_GROUP_MAT */
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_DIFFRGB);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_REF);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_SPECRGB);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_SPEC);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_HARD);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_EMIT);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_AMB);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_ALPHA);
- PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_MAT_MIR);
-
-
- /* -------------------------------------------------------------------- */
- /* GPUDataType */
-
- PY_MODULE_ADD_CONSTANT(m, GPU_DATA_1I);
- PY_MODULE_ADD_CONSTANT(m, GPU_DATA_1F);
- PY_MODULE_ADD_CONSTANT(m, GPU_DATA_2F);
- PY_MODULE_ADD_CONSTANT(m, GPU_DATA_3F);
- PY_MODULE_ADD_CONSTANT(m, GPU_DATA_4F);
- PY_MODULE_ADD_CONSTANT(m, GPU_DATA_9F);
- PY_MODULE_ADD_CONSTANT(m, GPU_DATA_16F);
- PY_MODULE_ADD_CONSTANT(m, GPU_DATA_4UB);
-
-
- /* -------------------------------------------------------------------- */
- /* CustomDataType
- *
- * Intentionally only include the subset used by the GPU API.
- */
- PY_MODULE_ADD_CONSTANT(m, CD_MTFACE);
- PY_MODULE_ADD_CONSTANT(m, CD_ORCO);
- PY_MODULE_ADD_CONSTANT(m, CD_TANGENT);
- PY_MODULE_ADD_CONSTANT(m, CD_MCOL);
return m;
}
-#define PY_DICT_ADD_STRING(d, s, f) \
- val = PyUnicode_FromString(s->f); \
- PyDict_SetItemString(d, # f, val); \
- Py_DECREF(val)
-
-#define PY_DICT_ADD_LONG(d, s, f) \
- val = PyLong_FromLong(s->f); \
- PyDict_SetItemString(d, # f, val); \
- Py_DECREF(val)
-
-#define PY_DICT_ADD_ID(d, s, f) \
- RNA_id_pointer_create((struct ID *)s->f, &tptr); \
- val = pyrna_struct_CreatePyObject(&tptr); \
- PyDict_SetItemString(d, # f, val); \
- Py_DECREF(val)
-
-#if 0 /* UNUSED */
-#define PY_OBJ_ADD_ID(d, s, f) \
- val = PyUnicode_FromString(&s->f->id.name[2]); \
- PyObject_SetAttrString(d, # f, val); \
- Py_DECREF(val)
-
-#define PY_OBJ_ADD_LONG(d, s, f) \
- val = PyLong_FromLong(s->f); \
- PyObject_SetAttrString(d, # f, val); \
- Py_DECREF(val)
-
-#define PY_OBJ_ADD_STRING(d, s, f) \
- val = PyUnicode_FromString(s->f); \
- PyObject_SetAttrString(d, # f, val); \
- Py_DECREF(val)
-#endif
-
-PyDoc_STRVAR(GPU_export_shader_doc,
-"export_shader(scene, material)\n"
-"\n"
-" Returns the GLSL shader that produces the visual effect of material in scene.\n"
-"\n"
-" :return: Dictionary defining the shader, uniforms and attributes.\n"
-" :rtype: Dict"
-);
-static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
-{
- PyObject *pyscene;
- PyObject *pymat;
- PyObject *result;
- PyObject *dict;
- PyObject *val;
- PyObject *seq;
-
- int i;
- Scene *scene;
- PointerRNA tptr;
- Material *material;
- GPUShaderExport *shader;
- GPUInputUniform *uniform;
- GPUInputAttribute *attribute;
-
- static const char *_keywords[] = {"scene", "material", NULL};
- static _PyArg_Parser _parser = {"OO:export_shader", _keywords, 0};
- if (!_PyArg_ParseTupleAndKeywordsFast(
- args, kw, &_parser,
- &pyscene, &pymat))
- {
- return NULL;
- }
- scene = (Scene *)PyC_RNA_AsPointer(pyscene, "Scene");
- if (scene == NULL) {
- return NULL;
- }
-
- material = (Material *)PyC_RNA_AsPointer(pymat, "Material");
- if (material == NULL) {
- return NULL;
- }
-
- /* we can call our internal function at last: */
- shader = GPU_shader_export(scene, material);
- if (!shader) {
- PyErr_SetString(PyExc_RuntimeError, "cannot export shader");
- return NULL;
- }
- /* build a dictionary */
- result = PyDict_New();
- if (shader->fragment) {
- PY_DICT_ADD_STRING(result, shader, fragment);
- }
- if (shader->vertex) {
- PY_DICT_ADD_STRING(result, shader, vertex);
- }
- seq = PyList_New(BLI_listbase_count(&shader->uniforms));
- for (i = 0, uniform = shader->uniforms.first; uniform; uniform = uniform->next, i++) {
- dict = PyDict_New();
- PY_DICT_ADD_STRING(dict, uniform, varname);
- PY_DICT_ADD_LONG(dict, uniform, datatype);
- PY_DICT_ADD_LONG(dict, uniform, type);
- if (uniform->lamp) {
- PY_DICT_ADD_ID(dict, uniform, lamp);
- }
- if (uniform->material) {
- PY_DICT_ADD_ID(dict, uniform, material);
- }
- if (uniform->image) {
- PY_DICT_ADD_ID(dict, uniform, image);
- }
- if (uniform->type == GPU_DYNAMIC_SAMPLER_2DBUFFER ||
- uniform->type == GPU_DYNAMIC_SAMPLER_2DIMAGE ||
- uniform->type == GPU_DYNAMIC_SAMPLER_2DSHADOW)
- {
- PY_DICT_ADD_LONG(dict, uniform, texnumber);
- }
- if (uniform->texpixels) {
- val = PyByteArray_FromStringAndSize((const char *)uniform->texpixels, uniform->texsize * 4);
- PyDict_SetItemString(dict, "texpixels", val);
- Py_DECREF(val);
- PY_DICT_ADD_LONG(dict, uniform, texsize);
- }
- PyList_SET_ITEM(seq, i, dict);
- }
- PyDict_SetItemString(result, "uniforms", seq);
- Py_DECREF(seq);
-
- seq = PyList_New(BLI_listbase_count(&shader->attributes));
- for (i = 0, attribute = shader->attributes.first; attribute; attribute = attribute->next, i++) {
- dict = PyDict_New();
- PY_DICT_ADD_STRING(dict, attribute, varname);
- PY_DICT_ADD_LONG(dict, attribute, datatype);
- PY_DICT_ADD_LONG(dict, attribute, type);
- PY_DICT_ADD_LONG(dict, attribute, number);
- if (attribute->name) {
- if (attribute->name[0] != 0) {
- PY_DICT_ADD_STRING(dict, attribute, name);
- }
- else {
- val = PyLong_FromLong(0);
- PyDict_SetItemString(dict, "name", val);
- Py_DECREF(val);
- }
- }
- PyList_SET_ITEM(seq, i, dict);
- }
- PyDict_SetItemString(result, "attributes", seq);
- Py_DECREF(seq);
-
- GPU_free_shader_export(shader);
-
- return result;
-}
-
-static PyMethodDef meth_export_shader[] = {
- {"export_shader", (PyCFunction)GPU_export_shader, METH_VARARGS | METH_KEYWORDS, GPU_export_shader_doc}
-};
-
/* -------------------------------------------------------------------- */
/* Initialize Module */
@@ -330,8 +89,6 @@ PyObject *GPU_initPython(void)
module = PyInit_gpu();
- PyModule_AddObject(module, "export_shader", (PyObject *)PyCFunction_New(meth_export_shader, NULL));
-
/* gpu.offscreen */
PyModule_AddObject(module, "offscreen", (submodule = BPyInit_gpu_offscreen()));
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
diff --git a/source/blender/python/intern/gpu_offscreen.c b/source/blender/python/intern/gpu_offscreen.c
index 72d338bd5db..a8ec828c13f 100644
--- a/source/blender/python/intern/gpu_offscreen.c
+++ b/source/blender/python/intern/gpu_offscreen.c
@@ -163,7 +163,7 @@ PyDoc_STRVAR(pygpu_offscreen_draw_view3d_doc,
);
static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *args, PyObject *kwds)
{
- /* TODO: This doesn't work currently because of eval_ctx. */
+ /* TODO: This doesn't work currently because of missing depsgraph. */
#if 0
static const char *kwlist[] = {"scene", "view_layer", "view3d", "region", "projection_matrix", "modelview_matrix", NULL};
@@ -197,8 +197,6 @@ static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *a
fx_settings = v3d->fx_settings; /* full copy */
- ED_view3d_draw_offscreen_init(scene, view_layer, v3d);
-
rv3d_mats = ED_view3d_mats_rv3d_backup(ar->regiondata);
GPU_offscreen_bind(self->ofs, true); /* bind */
diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h
index ec927a9e316..01d2350d7fd 100644
--- a/source/blender/python/mathutils/mathutils.h
+++ b/source/blender/python/mathutils/mathutils.h
@@ -62,7 +62,7 @@ enum {
float *_data; /* array of data (alias), wrapped status depends on wrapped status */ \
PyObject *cb_user; /* if this vector references another object, otherwise NULL, \
* *Note* this owns its reference */ \
- unsigned char cb_type; /* which user funcs do we adhere to, RNA, GameObject, etc */ \
+ unsigned char cb_type; /* which user funcs do we adhere to, RNA, etc */ \
unsigned char cb_subtype; /* subtype: location, rotation... \
* to avoid defining many new functions for every attribute of the same type */ \
unsigned char flag /* wrapped data type? */ \
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index 88195700a50..4119917a33f 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -1049,7 +1049,7 @@ static DerivedMesh *bvh_get_derived_mesh(
const char *funcname, struct Scene *scene, Object *ob,
bool use_deform, bool use_render, bool use_cage)
{
- /* TODO: This doesn't work currently because of eval_ctx. */
+ /* TODO: This doesn't work currently because of missing depsgraph. */
#if 0
/* we only need minimum mesh data for topology and vertex locations */
CustomDataMask mask = CD_MASK_BAREMESH;
diff --git a/source/blender/python/simple_enum_gen.py b/source/blender/python/simple_enum_gen.py
index 7e54f3dbb41..eef19b6c5f1 100644
--- a/source/blender/python/simple_enum_gen.py
+++ b/source/blender/python/simple_enum_gen.py
@@ -34,7 +34,7 @@ defs = """
SPACE_ACTION,
SPACE_NLA,
SPACE_SCRIPT, #Deprecated
- SPACE_TIME,
+ SPACE_TIME, #Deprecated
SPACE_NODE,
SPACEICONMAX
"""
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index 5cbc907d9c6..0f0060c7578 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -48,43 +48,15 @@ set(INC_SYS
)
set(SRC
- intern/raytrace/rayobject.cpp
- intern/raytrace/rayobject_empty.cpp
- intern/raytrace/rayobject_octree.cpp
- intern/raytrace/rayobject_raycounter.cpp
- intern/raytrace/rayobject_svbvh.cpp
- intern/raytrace/rayobject_instance.cpp
- intern/raytrace/rayobject_qbvh.cpp
- intern/raytrace/rayobject_rtbuild.cpp
- intern/raytrace/rayobject_vbvh.cpp
- intern/source/bake.c
intern/source/bake_api.c
- intern/source/convertblender.c
- intern/source/envmap.c
intern/source/external_engine.c
intern/source/imagetexture.c
intern/source/initrender.c
intern/source/multires_bake.c
- intern/source/occlusion.c
intern/source/pipeline.c
- intern/source/pixelblending.c
- intern/source/pixelshading.c
intern/source/pointdensity.c
- intern/source/rayshade.c
- intern/source/rendercore.c
intern/source/render_result.c
intern/source/render_texture.c
- intern/source/renderdatabase.c
- intern/source/shadbuf.c
- intern/source/shadeinput.c
- intern/source/shadeoutput.c
- intern/source/sss.c
- intern/source/strand.c
- intern/source/sunsky.c
- intern/source/texture_ocean.c
- intern/source/volume_precache.c
- intern/source/volumetric.c
- intern/source/voxeldata.c
intern/source/zbuf.c
extern/include/RE_engine.h
@@ -93,38 +65,12 @@ set(SRC
extern/include/RE_pipeline.h
extern/include/RE_render_ext.h
extern/include/RE_shader_ext.h
- intern/include/envmap.h
intern/include/initrender.h
- intern/include/occlusion.h
- intern/include/pixelblending.h
- intern/include/pixelshading.h
- intern/include/pointdensity.h
- intern/include/raycounter.h
- intern/include/rayobject.h
- intern/include/rayintersection.h
intern/include/render_types.h
intern/include/render_result.h
- intern/include/rendercore.h
- intern/include/renderdatabase.h
intern/include/renderpipeline.h
- intern/include/shadbuf.h
- intern/include/shading.h
- intern/include/sss.h
- intern/include/strand.h
- intern/include/sunsky.h
intern/include/texture.h
- intern/include/texture_ocean.h
- intern/include/volume_precache.h
- intern/include/volumetric.h
- intern/include/voxeldata.h
intern/include/zbuf.h
- intern/raytrace/bvh.h
- intern/raytrace/rayobject_hint.h
- intern/raytrace/rayobject_internal.h
- intern/raytrace/rayobject_rtbuild.h
- intern/raytrace/reorganize.h
- intern/raytrace/svbvh.h
- intern/raytrace/vbvh.h
)
if(WITH_PYTHON)
@@ -149,10 +95,6 @@ if(WITH_FREESTYLE)
add_definitions(-DWITH_FREESTYLE)
endif()
-if(WITH_GAMEENGINE)
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
diff --git a/source/blender/render/extern/include/RE_bake.h b/source/blender/render/extern/include/RE_bake.h
index 090e0e6c28d..d827a3507d9 100644
--- a/source/blender/render/extern/include/RE_bake.h
+++ b/source/blender/render/extern/include/RE_bake.h
@@ -76,9 +76,6 @@ bool RE_bake_engine(
/* bake.c */
int RE_pass_depth(const eScenePassType pass_type);
-bool RE_bake_internal(
- struct Render *re, struct Object *object, const BakePixel pixel_array[],
- const size_t num_pixels, const int depth, const eScenePassType pass_type, float result[]);
bool RE_bake_pixels_populate_from_objects(
struct Mesh *me_low, BakePixel pixel_array_from[], BakePixel pixel_array_to[],
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h
index d5230f74316..e857d508424 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/extern/include/RE_engine.h
@@ -42,7 +42,7 @@ struct bNodeTree;
struct BakePixel;
struct Depsgraph;
struct Depsgraph;
-struct EvaluationContext;
+struct Depsgraph;
struct IDProperty;
struct Main;
struct Object;
@@ -60,7 +60,7 @@ struct ViewLayer;
/* RenderEngineType.flag */
#define RE_INTERNAL 1
-#define RE_GAME 2
+/* #define RE_FLAG_DEPRECATED 2 */
#define RE_USE_PREVIEW 4
#define RE_USE_POSTPROCESS 8
#define RE_USE_SHADING_NODES 16
@@ -69,7 +69,6 @@ struct ViewLayer;
#define RE_USE_TEXTURE_PREVIEW 128
#define RE_USE_SHADING_NODES_CUSTOM 256
#define RE_USE_SPHERICAL_STEREO 512
-#define RE_USE_LEGACY_PIPELINE 1024 /* XXX Temporary flag, to be removed once draw manager is finished. */
/* RenderEngine.flag */
#define RE_ENGINE_ANIMATION 1
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index c5e8443374a..022f2a31826 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -39,7 +39,6 @@
struct bMovieHandle;
struct bNodeTree;
struct Depsgraph;
-struct EvaluationContext;
struct Image;
struct ImageFormatData;
struct Main;
@@ -50,9 +49,7 @@ struct RenderResult;
struct ReportList;
struct Scene;
struct ViewLayer;
-struct EnvMap;
struct StampData;
-struct ViewRender;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* this include is what is exposed of render to outside world */
@@ -123,8 +120,6 @@ typedef struct RenderLayer {
/* optional saved endresult on disk */
void *exrhandle;
- struct EvaluationContext eval_ctx;
-
ListBase passes;
} RenderLayer;
@@ -246,7 +241,7 @@ struct RenderPass *RE_create_gp_pass(struct RenderResult *rr, const char *layern
/* obligatory initialize call, disprect is optional */
void RE_InitState(struct Render *re, struct Render *source, struct RenderData *rd,
struct ListBase *render_layers, const int active_layer,
- struct ViewRender *view_render, struct ViewLayer *view_layer,
+ struct ViewLayer *view_layer,
int winx, int winy, rcti *disprect);
void RE_ChangeResolution(struct Render *re, int winx, int winy, rcti *disprect);
void RE_ChangeModeFlag(struct Render *re, int flag, bool clear);
@@ -255,10 +250,8 @@ void RE_ChangeModeFlag(struct Render *re, int flag, bool clear);
struct Object *RE_GetCamera(struct Render *re); /* return camera override if set */
void RE_SetOverrideCamera(struct Render *re, struct Object *camera);
void RE_SetCamera(struct Render *re, struct Object *camera);
-void RE_SetEnvmapCamera(struct Render *re, struct Object *cam_ob, float viewscale, float clipsta, float clipend);
void RE_SetWindow(struct Render *re, const rctf *viewplane, float clipsta, float clipend);
void RE_SetOrtho(struct Render *re, const rctf *viewplane, float clipsta, float clipend);
-void RE_SetPixelSize(struct Render *re, float pixsize);
/* option to set viewmatrix before making dbase */
void RE_SetView(struct Render *re, float mat[4][4]);
@@ -268,26 +261,13 @@ void RE_GetView(struct Render *re, float mat[4][4]);
void RE_GetViewPlane(struct Render *re, rctf *r_viewplane, rcti *r_disprect);
/* make or free the dbase */
-void RE_Database_FromScene(
- struct Render *re, struct Main *bmain, struct Scene *scene,
- unsigned int lay, int use_camera_view);
void RE_Database_CameraOnly(
struct Render *re, struct Main *bmain, struct Scene *scene,
unsigned int lay, int use_camera_view);
-void RE_Database_Preprocess(struct EvaluationContext *eavl_ctx, struct Render *re);
-void RE_Database_Free(struct Render *re);
-
-/* project dbase again, when viewplane/perspective changed */
-void RE_DataBase_ApplyWindow(struct Render *re);
-/* rotate scene again, for incremental render */
-void RE_DataBase_IncrementalView(struct Render *re, float viewmat[4][4], int restore);
/* set the render threads based on the commandline and autothreads setting */
void RE_init_threadcount(Render *re);
-/* the main processor, assumes all was set OK! */
-void RE_TileProcessor(struct Render *re);
-
bool RE_WriteRenderViewsImage(
struct ReportList *reports, struct RenderResult *rr, struct Scene *scene, const bool stamp, char *name);
bool RE_WriteRenderViewsMovie(
@@ -309,13 +289,11 @@ void RE_RenderFreestyleExternal(struct Render *re);
void RE_SetActiveRenderView(struct Render *re, const char *viewname);
const char *RE_GetActiveRenderView(struct Render *re);
-void RE_SetEngineByID(struct Render *re, const char *engine_id);
-
/* error reporting */
void RE_SetReports(struct Render *re, struct ReportList *reports);
/* main preview render call */
-void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene, struct ViewRender *render_view);
+void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene);
bool RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode);
bool RE_WriteRenderResult(
@@ -324,14 +302,6 @@ bool RE_WriteRenderResult(
struct RenderResult *RE_MultilayerConvert(
void *exrhandle, const char *colorspace, bool predivide, int rectx, int recty);
-extern const float default_envmap_layout[];
-bool RE_WriteEnvmapResult(
- struct ReportList *reports, struct Scene *scene, struct EnvMap *env,
- const char *relpath, const char imtype, float layout[12]);
-
-/* do a full sample buffer compo */
-void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce, struct bNodeTree *ntree);
-
/* 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));
@@ -354,27 +324,10 @@ struct RenderPass *RE_pass_find_by_name(volatile struct RenderLayer *rl, const c
struct RenderPass *RE_pass_find_by_type(volatile struct RenderLayer *rl, int passtype, const char *viewname);
/* shaded view or baking options */
-#define RE_BAKE_LIGHT 0 /* not listed in rna_scene.c -> can't be enabled! */
-#define RE_BAKE_ALL 1
+#define RE_BAKE_NORMALS 0
+#define RE_BAKE_DISPLACEMENT 1
#define RE_BAKE_AO 2
-#define RE_BAKE_NORMALS 3
-#define RE_BAKE_TEXTURE 4
-#define RE_BAKE_DISPLACEMENT 5
-#define RE_BAKE_SHADOW 6
-#define RE_BAKE_SPEC_COLOR 7
-#define RE_BAKE_SPEC_INTENSITY 8
-#define RE_BAKE_MIRROR_COLOR 9
-#define RE_BAKE_MIRROR_INTENSITY 10
-#define RE_BAKE_ALPHA 11
-#define RE_BAKE_EMIT 12
-#define RE_BAKE_DERIVATIVE 13
-#define RE_BAKE_VERTEX_COLORS 14
-
-void RE_Database_Baking(
- struct Render *re, struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer,
- unsigned int lay, const int type, struct Object *actob);
-
-void RE_DataBase_GetView(struct Render *re, float mat[4][4]);
+
void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[4][4]);
void RE_GetCameraModelMatrix(struct Render *re, struct Object *camera, float r_mat[4][4]);
struct Scene *RE_GetScene(struct Render *re);
@@ -384,13 +337,6 @@ bool RE_is_rendering_allowed(struct Scene *scene, struct Object *camera_override
bool RE_allow_render_generic_object(struct Object *ob);
-/* RE_updateRenderInstances flag */
-enum {
- RE_OBJECT_INSTANCES_UPDATE_VIEW = (1 << 0),
- RE_OBJECT_INSTANCES_UPDATE_OBMAT = (1 << 1)
-};
-void RE_updateRenderInstances(Render *re, int flag);
-
/******* defined in render_result.c *********/
bool RE_HasCombinedLayer(RenderResult *res);
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h
index 0021687efbd..3b4b9262465 100644
--- a/source/blender/render/extern/include/RE_render_ext.h
+++ b/source/blender/render/extern/include/RE_render_ext.h
@@ -38,7 +38,7 @@
/* called by meshtools */
struct DerivedMesh;
-struct EvaluationContext;
+struct Depsgraph;
struct ImagePool;
struct MTex;
struct Scene;
@@ -56,12 +56,6 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
void RE_texture_rng_init(void);
void RE_texture_rng_exit(void);
-struct Material *RE_sample_material_init(const struct EvaluationContext *eval_ctx, struct Material *orig_mat, struct Scene *scene);
-void RE_sample_material_free(struct Material *mat);
-void RE_sample_material_color(
- struct Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3],
- int tri_index, struct DerivedMesh *orcoDm, struct Object *ob);
-
/* imagetexture.c */
void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float result[4]);
@@ -69,20 +63,22 @@ void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, flo
struct PointDensity;
void RE_point_density_cache(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct PointDensity *pd);
void RE_point_density_minmax(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct PointDensity *pd,
float r_min[3], float r_max[3]);
void RE_point_density_sample(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct PointDensity *pd,
const int resolution,
float *values);
void RE_point_density_free(struct PointDensity *pd);
+void RE_point_density_fix_linking(void);
+
#endif /* __RE_RENDER_EXT_H__ */
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index 281f0082d7f..0d354c27e3a 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -33,7 +33,7 @@
#define __RE_SHADER_EXT_H__
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* this include is for shading and texture exports */
+/* this include is for texture exports */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* localized texture result data */
@@ -44,148 +44,6 @@ typedef struct TexResult {
float *nor;
} TexResult;
-/* localized shade result data */
-typedef struct ShadeResult {
- float combined[4];
- float col[4];
- float alpha, mist, z;
- float emit[3];
- float diff[3]; /* diffuse with no ramps, shadow, etc */
- float diffshad[3]; /* diffuse with shadow */
- float spec[3]; /* specular with shadow */
- float shad[4]; /* shad[3] is shadow intensity */
- float ao[3];
- float env[3];
- float indirect[3];
- float refl[3];
- float refr[3];
- float nor[3];
- float winspeed[4];
- float rayhits[4];
-} ShadeResult;
-
-/* only here for quick copy */
-struct ShadeInputCopy {
-
- struct Material *mat;
- struct VlakRen *vlr;
- struct StrandRen *strand;
- struct ObjectInstanceRen *obi;
- struct ObjectRen *obr;
- int facenr;
- float facenor[3]; /* copy from face */
- short flippednor; /* is facenor flipped? */
- struct VertRen *v1, *v2, *v3; /* vertices can be in any order for quads... */
- short i1, i2, i3; /* original vertex indices */
- short puno;
- short osatex;
- float vn[3], vno[3]; /* actual render normal, and a copy to restore it */
- float n1[3], n2[3], n3[3]; /* vertex normals, corrected */
- int mode, mode2; /* base material mode (OR-ed result of entire node tree) */
-};
-
-typedef struct ShadeInputUV {
- float dxuv[3], dyuv[3], uv[3];
- const char *name;
-} ShadeInputUV;
-
-typedef struct ShadeInputCol {
- float col[4];
- const char *name;
-} ShadeInputCol;
-
-/* localized renderloop data */
-typedef struct ShadeInput {
- /* copy from face, also to extract tria from quad */
- /* note it mirrors a struct above for quick copy */
-
- struct Material *mat;
- struct VlakRen *vlr;
- struct StrandRen *strand;
- struct ObjectInstanceRen *obi;
- struct ObjectRen *obr;
- int facenr;
- float facenor[3]; /* copy from face */
- short flippednor; /* is facenor flipped? */
- struct VertRen *v1, *v2, *v3; /* vertices can be in any order for quads... */
- short i1, i2, i3; /* original vertex indices */
- short puno;
- short osatex;
- float vn[3], vno[3]; /* actual render normal, and a copy to restore it */
- float n1[3], n2[3], n3[3]; /* vertex normals, corrected */
- int mode, mode2; /* base material mode (OR-ed result of entire node tree) */
-
- /* internal face coordinates */
- float u, v, dx_u, dx_v, dy_u, dy_v;
- float co[3], view[3], camera_co[3];
-
- /* copy from material, keep synced so we can do memcopy */
- /* current size: 23*4 */
- float r, g, b;
- float specr, specg, specb;
- float mirr, mirg, mirb;
- float ambr, ambb, ambg;
-
- float amb, emit, ang, spectra, ray_mirror;
- float alpha, refl, spec, zoffs, add;
- float translucency;
- /* end direct copy from material */
-
- /* individual copies: */
- int har; /* hardness */
-
- /* texture coordinates */
- float lo[3], gl[3], ref[3], orn[3], winco[3], vcol[4];
- float refcol[4], displace[3];
- float strandco, tang[3], nmapnorm[3], nmaptang[4], stress, winspeed[4];
- float duplilo[3], dupliuv[3];
- float tangents[8][4]; /* 8 = MAX_MTFACE */
-
- ShadeInputUV uv[8]; /* 8 = MAX_MTFACE */
- ShadeInputCol col[8]; /* 8 = MAX_MCOL */
- int totuv, totcol, actuv, actcol;
-
- /* dx/dy OSA coordinates */
- float dxco[3], dyco[3];
- float dxlo[3], dylo[3], dxgl[3], dygl[3];
- float dxref[3], dyref[3], dxorn[3], dyorn[3];
- float dxno[3], dyno[3], dxview, dyview;
- float dxlv[3], dylv[3];
- float dxwin[3], dywin[3];
- float dxrefract[3], dyrefract[3];
- float dxstrand, dystrand;
-
- /* AO is a pre-process now */
- float ao[3], indirect[3], env[3];
-
- int xs, ys; /* pixel to be rendered */
- int mask; /* subsample mask */
- float scanco[3]; /* original scanline coordinate without jitter */
-
- int samplenr; /* sample counter, to detect if we should do shadow again */
- int depth; /* 1 or larger on raytrace shading */
- int volume_depth; /* number of intersections through volumes */
-
- /* for strand shading, normal at the surface */
- float surfnor[3], surfdist;
-
- /* from initialize, part or renderlayer */
- bool do_preview; /* for nodes, in previewrender */
- bool do_manage; /* color management flag */
- bool use_world_space_shading;
- short thread, sample; /* sample: ShadeSample array index */
- short nodes; /* indicate node shading, temp hack to prevent recursion */
-
- unsigned int lay;
- int layflag, passflag, combinedflag;
- short object_pass_index;
-
-#ifdef RE_RAYCOUNTER
- RayCounter raycounter;
-#endif
-
-} ShadeInput;
-
typedef struct BakeImBufuserData {
float *displacement_buffer;
char *mask_buffer;
@@ -212,46 +70,6 @@ int multitex_ext(struct Tex *tex,
int multitex_ext_safe(struct Tex *tex, float texvec[3], struct TexResult *texres, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image);
/* only for internal node usage */
int multitex_nodes(struct Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres,
- const short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex,
- struct ImagePool *pool);
-float RE_lamp_get_data(struct ShadeInput *shi, struct Object *lamp_obj, float col[4], float lv[3], float *dist, float shadow[4]);
-void RE_instance_get_particle_info(struct ObjectInstanceRen *obi, float *index, float *random, float *age, float *lifetime, float co[3], float *size, float vel[3], float angvel[3]);
-
-float RE_fresnel_dielectric(float incoming[3], float normal[3], float eta);
-
-/* shaded view and bake */
-struct Render;
-struct Image;
-
-int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update, float *progress);
-struct Image *RE_bake_shade_get_image(void);
-void RE_bake_ibuf_filter(struct ImBuf *ibuf, char *mask, const int filter);
-void RE_bake_ibuf_normalize_displacement(struct ImBuf *ibuf, float *displacement, char *mask, float displacement_min, float displacement_max);
-float RE_bake_make_derivative(struct ImBuf *ibuf, float *heights_buffer, const char *mask,
- const float height_min, const float height_max,
- const float fmult);
-
-enum {
- RE_OBJECT_INSTANCE_MATRIX_OB,
- RE_OBJECT_INSTANCE_MATRIX_OBINV,
- RE_OBJECT_INSTANCE_MATRIX_LOCALTOVIEW,
- RE_OBJECT_INSTANCE_MATRIX_LOCALTOVIEWINV,
-};
-
-const float (*RE_object_instance_get_matrix(struct ObjectInstanceRen *obi, int matrix_id))[4];
-
-float RE_object_instance_get_object_pass_index(struct ObjectInstanceRen *obi);
-float RE_object_instance_get_random_id(struct ObjectInstanceRen *obi);
-
-enum {
- RE_VIEW_MATRIX,
- RE_VIEWINV_MATRIX,
-};
-
-const float (*RE_render_current_get_matrix(int matrix_id))[4];
-
-#define BAKE_RESULT_OK 0
-#define BAKE_RESULT_NO_OBJECTS 1
-#define BAKE_RESULT_FEEDBACK_LOOP 2
+ const short thread, short which_output, struct MTex *mtex, struct ImagePool *pool);
#endif /* __RE_SHADER_EXT_H__ */
diff --git a/source/blender/render/intern/include/envmap.h b/source/blender/render/intern/include/envmap.h
deleted file mode 100644
index 627e6c0e1e6..00000000000
--- a/source/blender/render/intern/include/envmap.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * envmap_ext.h
- *
- *
- * ***** 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 blender/render/intern/include/envmap.h
- * \ingroup render
- */
-
-
-#ifndef __ENVMAP_H__
-#define __ENVMAP_H__
-
-/**
- * Make environment maps for all objects in the scene that have an
- * environment map as texture.
- * (initrender.c)
- */
-
-struct Render;
-struct TexResult;
-struct ImagePool;
-
-void make_envmaps(struct Render *re);
-int envmaptex(struct Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres, struct ImagePool *pool, const bool skip_image_load);
-void env_rotate_scene(struct Render *re, float mat[4][4], int do_rotate);
-
-#endif /* __ENVMAP_H__ */
-
diff --git a/source/blender/render/intern/include/initrender.h b/source/blender/render/intern/include/initrender.h
index 87e2d2519d5..e7ff3c7097c 100644
--- a/source/blender/render/intern/include/initrender.h
+++ b/source/blender/render/intern/include/initrender.h
@@ -33,16 +33,11 @@
#ifndef __INITRENDER_H__
#define __INITRENDER_H__
-
/* Functions */
-void free_sample_tables(Render *re);
-void make_sample_tables(Render *re);
-
-void RE_parts_init(Render *re, bool do_crop);
+void RE_parts_init(Render *re);
void RE_parts_free(Render *re);
void RE_parts_clamp(Render *re);
-
#endif /* __INITRENDER_H__ */
diff --git a/source/blender/render/intern/include/occlusion.h b/source/blender/render/intern/include/occlusion.h
deleted file mode 100644
index 4a70d691436..00000000000
--- a/source/blender/render/intern/include/occlusion.h
+++ /dev/null
@@ -1,49 +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) 2008 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Brecht Van Lommel.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/occlusion.h
- * \ingroup render
- */
-
-
-#ifndef __OCCLUSION_H__
-#define __OCCLUSION_H__
-
-struct Render;
-struct ShadeInput;
-struct RenderPart;
-struct ShadeSample;
-
-void make_occ_tree(struct Render *re);
-void free_occ(struct Render *re);
-void sample_occ(struct Render *re, struct ShadeInput *shi);
-
-void cache_occ_samples(struct Render *re, struct RenderPart *pa, struct ShadeSample *ssamp);
-void free_occ_samples(struct Render *re, struct RenderPart *pa);
-
-#endif
-
diff --git a/source/blender/render/intern/include/pixelblending.h b/source/blender/render/intern/include/pixelblending.h
deleted file mode 100644
index 17a872a0676..00000000000
--- a/source/blender/render/intern/include/pixelblending.h
+++ /dev/null
@@ -1,65 +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.
- *
- * Contributor(s): 2004-2006 Blender Foundation, full recode
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/pixelblending.h
- * \ingroup render
- */
-
-
-#ifndef __PIXELBLENDING_H__
-#define __PIXELBLENDING_H__
-
-
-/**
- * add 1 pixel to into filtered three lines
- * (float vecs to float vec)
- */
-void add_filt_fmask(unsigned int mask, const float col[4], float *rowbuf, int row_w);
-void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row_w, int pixsize);
-void add_filt_fmask_coord(float filt[3][3], const float col[4], float *rowbuf, int row_stride, int x, int y, rcti *mask);
-void mask_array(unsigned int mask, float filt[3][3]);
-
-/**
- * Alpha-over blending for floats.
- */
-void addAlphaOverFloat(float dest[4], const float source[4]);
-
-/**
- * Alpha-under blending for floats.
- */
-void addAlphaUnderFloat(float dest[4], const float source[4]);
-
-
-/**
- * Same for floats
- */
-void addalphaAddfacFloat(float dest[4], const float source[4], char addfac);
-
-/**
- * dest = dest + source
- */
-void addalphaAddFloat(float dest[4], const float source[4]);
-
-#endif /* __PIXELBLENDING_H__ */
diff --git a/source/blender/render/intern/include/pixelshading.h b/source/blender/render/intern/include/pixelshading.h
deleted file mode 100644
index 8f23455564f..00000000000
--- a/source/blender/render/intern/include/pixelshading.h
+++ /dev/null
@@ -1,62 +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.
- *
- * Contributor(s): 2004-2006, Blender Foundation, full recode
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/pixelshading.h
- * \ingroup render
- *
- * These functions determine what actual color a pixel will have.
- */
-
-#ifndef __PIXELSHADING_H__
-#define __PIXELSHADING_H__
-
-
-/**
- * Render the pixel at (x,y) for object ap. Apply the jitter mask.
- * Output is given in float collector[4]. The type vector:
- * t[0] - min. distance
- * t[1] - face/halo index
- * t[2] - jitter mask
- * t[3] - type ZB_POLY or ZB_HALO
- * t[4] - max. distance
- * mask is pixel coverage in bits
- * \return pointer to the object
- */
-int shadeHaloFloat(HaloRen *har,
- float *col, int zz,
- float dist, float xn,
- float yn, short flarec);
-
-/**
- * Render the sky at pixel (x, y).
- */
-void shadeSkyPixel(float collector[4], float fx, float fy, short thread);
-void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const float dxyview[2], short thread);
-void shadeAtmPixel(struct SunSky *sunsky, float *collector, float fx, float fy, float distance);
-void shadeSunView(float col_r[3], const float view[3]);
-/* ------------------------------------------------------------------------- */
-
-#endif
-
diff --git a/source/blender/render/intern/include/pointdensity.h b/source/blender/render/intern/include/pointdensity.h
deleted file mode 100644
index f122b3dc4c1..00000000000
--- a/source/blender/render/intern/include/pointdensity.h
+++ /dev/null
@@ -1,52 +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): Matt Ebb
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/pointdensity.h
- * \ingroup render
- */
-
-
-#ifndef __POINTDENSITY_H__
-#define __POINTDENSITY_H__
-
-/**
- * Make point density kd-trees for all point density textures in the scene
- */
-
-struct EvaluationContext;
-struct PointDensity;
-struct Render;
-struct TexResult;
-
-void free_pointdensity(struct PointDensity *pd);
-void cache_pointdensity(const struct EvaluationContext *eval_ctx, struct Render *re, struct PointDensity *pd);
-void make_pointdensities(const struct EvaluationContext *eval_ctx, struct Render *re);
-void free_pointdensities(struct Render *re);
-int pointdensitytex(struct Tex *tex, const float texvec[3], struct TexResult *texres);
-
-#endif /* __POINTDENSITY_H__ */
-
diff --git a/source/blender/render/intern/include/raycounter.h b/source/blender/render/intern/include/raycounter.h
deleted file mode 100644
index 1694273df0e..00000000000
--- a/source/blender/render/intern/include/raycounter.h
+++ /dev/null
@@ -1,74 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/raycounter.h
- * \ingroup render
- */
-
-
-#ifndef __RAYCOUNTER_H__
-#define __RAYCOUNTER_H__
-
-//#define RE_RAYCOUNTER /* enable counters per ray, useful for measuring raytrace structures performance */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef RE_RAYCOUNTER
-
-/* ray counter functions */
-
-typedef struct RayCounter {
- struct {
- unsigned long long test, hit;
- } faces, bb, simd_bb, raycast, raytrace_hint, rayshadow_last_hit;
-} RayCounter;
-
-#define RE_RC_INIT(isec, shi) (isec).raycounter = &((shi).shading.raycounter)
-void RE_RC_INFO(RayCounter *rc);
-void RE_RC_MERGE(RayCounter *rc, RayCounter *tmp);
-#define RE_RC_COUNT(var) (var)++
-
-extern RayCounter re_rc_counter[];
-
-#else
-
-/* ray counter stubs */
-
-#define RE_RC_INIT(isec,shi)
-#define RE_RC_INFO(rc)
-#define RE_RC_MERGE(dest,src)
-#define RE_RC_COUNT(var)
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source/blender/render/intern/include/rayintersection.h b/source/blender/render/intern/include/rayintersection.h
deleted file mode 100644
index 1935e4ef59c..00000000000
--- a/source/blender/render/intern/include/rayintersection.h
+++ /dev/null
@@ -1,136 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- * RE_raytrace.h: ray tracing api, can be used independently from the renderer.
- */
-
-/** \file blender/render/intern/include/rayintersection.h
- * \ingroup render
- */
-
-
-#ifndef __RAYINTERSECTION_H__
-#define __RAYINTERSECTION_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "BLI_math_geom.h"
-
-struct RayObject;
-
-/* Ray Hints */
-
-#define RE_RAY_LCTS_MAX_SIZE 256
-#define RT_USE_LAST_HIT /* last shadow hit is reused before raycasting on whole tree */
-//#define RT_USE_HINT /* last hit object is reused before raycasting on whole tree */
-
-typedef struct LCTSHint {
- int size;
- struct RayObject *stack[RE_RAY_LCTS_MAX_SIZE];
-} LCTSHint;
-
-typedef struct RayHint {
- union { LCTSHint lcts; } data;
-} RayHint;
-
-/* Ray Intersection */
-
-typedef struct Isect {
- /* ray start, direction (normalized vector), and max distance. on hit,
- * the distance is modified to be the distance to the hit point. */
- float start[3];
- float dir[3];
- float dist;
-
- /* for envmap and incremental view update renders */
- float origstart[3];
- float origdir[3];
-
- /* precomputed values to accelerate bounding box intersection */
- int bv_index[6];
- float idot_axis[3];
-
- /* intersection options */
- int mode; /* RE_RAY_SHADOW, RE_RAY_MIRROR, RE_RAY_SHADOW_TRA */
- int lay; /* -1 default, set for layer lamps */
- int skip; /* skip flags */
- int check; /* check flags */
- void *userdata; /* used by bake check */
-
- /* hit information */
- float u, v;
- int isect; /* which half of quad */
-
- struct {
- void *ob;
- void *face;
- } hit, orig;
-
- /* last hit optimization */
- struct RayObject *last_hit;
-
- /* hints */
-#ifdef RT_USE_HINT
- RayTraceHint *hint, *hit_hint;
-#endif
- RayHint *hint;
-
- /* ray counter */
-#ifdef RE_RAYCOUNTER
- RayCounter *raycounter;
-#endif
-
- /* Precalculated coefficients for watertight intersection check. */
- struct IsectRayPrecalc isect_precalc;
-} Isect;
-
-/* ray types */
-#define RE_RAY_SHADOW 0
-#define RE_RAY_MIRROR 1
-#define RE_RAY_SHADOW_TRA 2
-
-/* skip options */
-#define RE_SKIP_CULLFACE (1 << 0)
-/* if using this flag then *face should be a pointer to a VlakRen */
-#define RE_SKIP_VLR_NEIGHBOUR (1 << 1)
-
-/* check options */
-#define RE_CHECK_VLR_NONE 0
-#define RE_CHECK_VLR_RENDER 1
-#define RE_CHECK_VLR_NON_SOLID_MATERIAL 2
-#define RE_CHECK_VLR_BAKE 3
-
-/* arbitrary, but can't use e.g. FLT_MAX because of precision issues */
-#define RE_RAYTRACE_MAXDIST 1e15f
-#define RE_RAYTRACE_EPSILON 0.0f
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __RAYINTERSECTION_H__ */
-
diff --git a/source/blender/render/intern/include/rayobject.h b/source/blender/render/intern/include/rayobject.h
deleted file mode 100644
index 63135d01c23..00000000000
--- a/source/blender/render/intern/include/rayobject.h
+++ /dev/null
@@ -1,121 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/rayobject.h
- * \ingroup render
- */
-
-
-#ifndef __RAYOBJECT_H__
-#define __RAYOBJECT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct Isect;
-struct ObjectInstanceRen;
-struct RayHint;
-struct VlakRen;
-
-/* RayObject
- * Can be a face/triangle, bvh tree, object instance, etc. This is the
- * public API used by the renderer, see rayobject_internal.h for the
- * internal implementation details.
- * */
-typedef struct RayObject RayObject;
-
-/* Intersection, see rayintersection.h */
-
-int RE_rayobject_raycast(RayObject *r, struct Isect *i);
-
-/* Acceleration Structures */
-
-RayObject *RE_rayobject_octree_create(int ocres, int size);
-RayObject *RE_rayobject_instance_create(RayObject *target, float transform[4][4], void *ob, void *target_ob);
-RayObject *RE_rayobject_empty_create(void);
-
-RayObject *RE_rayobject_vbvh_create(int size); /* raytrace/rayobject_vbvh.c */
-RayObject *RE_rayobject_svbvh_create(int size); /* raytrace/rayobject_svbvh.c */
-RayObject *RE_rayobject_qbvh_create(int size); /* raytrace/rayobject_qbvh.c */
-
-/* Building */
-
-void RE_rayobject_add(RayObject *r, RayObject *);
-void RE_rayobject_done(RayObject *r);
-void RE_rayobject_free(RayObject *r);
-
-void RE_rayobject_set_control(RayObject *r, void *data, int (*test_break)(void *data));
-
-/* RayObject representing faces, all data is locally available instead
- * of referring to some external data structure, for possibly faster
- * intersection tests. */
-
-typedef struct RayFace {
- float v1[4], v2[4], v3[4], v4[3];
- int quad;
- void *ob;
- void *face;
-} RayFace;
-
-#define RE_rayface_isQuad(a) ((a)->quad)
-
-RayObject *RE_rayface_from_vlak(RayFace *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr);
-
-RayObject *RE_rayface_from_coords(RayFace *rayface, void *ob, void *face, float *v1, float *v2, float *v3, float *v4);
-
-/* RayObject representing faces directly from a given VlakRen structure. Thus
- * allowing to save memory, but making code triangle intersection dependent on
- * render structures. */
-
-typedef struct VlakPrimitive {
- struct ObjectInstanceRen *ob;
- struct VlakRen *face;
-} VlakPrimitive;
-
-RayObject *RE_vlakprimitive_from_vlak(VlakPrimitive *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr);
-
-/* Bounding Box */
-
-/* extend min/max coords so that the rayobject is inside them */
-void RE_rayobject_merge_bb(RayObject *ob, float *min, float *max);
-
-/* initializes an hint for optimizing raycast where it is know that a ray will pass by the given BB often the origin point */
-void RE_rayobject_hint_bb(RayObject *r, struct RayHint *hint, float min[3], float max[3]);
-
-/* initializes an hint for optimizing raycast where it is know that a ray will be contained inside the given cone*/
-/* void RE_rayobject_hint_cone(RayObject *r, struct RayHint *hint, float *); */
-
-/* Internals */
-
-#include "../raytrace/rayobject_internal.h"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source/blender/render/intern/include/render_result.h b/source/blender/render/intern/include/render_result.h
index 03292579d90..9a1b1b5abe8 100644
--- a/source/blender/render/intern/include/render_result.h
+++ b/source/blender/render/intern/include/render_result.h
@@ -55,8 +55,6 @@ struct ColorManagedViewSettings;
struct RenderResult *render_result_new(struct Render *re,
struct rcti *partrct, int crop, int savebuffers, const char *layername, const char *viewname);
-struct RenderResult *render_result_new_full_sample(struct Render *re,
- struct ListBase *lb, struct rcti *partrct, int crop, int savebuffers, const char *viewname);
struct RenderResult *render_result_new_from_exr(void *exrhandle, const char *colorspace, bool predivide, int rectx, int recty);
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 2c46138c7ea..8308b5e76e4 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -35,58 +35,19 @@
/* exposed internal in render module only! */
/* ------------------------------------------------------------------------- */
-#include "DNA_color_types.h"
-#include "DNA_customdata_types.h"
#include "DNA_scene_types.h"
-#include "DNA_world_types.h"
#include "DNA_object_types.h"
-#include "DNA_vec_types.h"
#include "BLI_threads.h"
#include "BKE_main.h"
#include "RE_pipeline.h"
-#include "RE_shader_ext.h" /* TexResult, ShadeResult, ShadeInput */
-#include "sunsky.h"
-#include "BLI_sys_types.h" // for intptr_t support
-
-struct EvaluationContext;
struct Object;
-struct MemArena;
-struct VertTableNode;
-struct VlakTableNode;
-struct GHash;
-struct ObjectInstanceRen;
-struct RayObject;
-struct RayFace;
struct RenderEngine;
struct ReportList;
struct Main;
-struct ImagePool;
-
-#define TABLEINITSIZE 1024
-
-typedef struct SampleTables {
- float centLut[16];
- float *fmask1[9], *fmask2[9];
- char cmask[256], *centmask;
-
-} SampleTables;
-
-typedef struct QMCSampler {
- struct QMCSampler *next, *prev;
- int type;
- int tot;
- int used;
- double *samp2d;
- double offs[BLENDER_MAX_THREADS][2];
-} QMCSampler;
-
-// #define SAMP_TYPE_JITTERED 0 // UNUSED
-#define SAMP_TYPE_HALTON 1
-#define SAMP_TYPE_HAMMERSLEY 2
/* this is handed over to threaded hiding/passes/shading engine */
typedef struct RenderPart {
@@ -95,24 +56,10 @@ typedef struct RenderPart {
RenderResult *result; /* result of part rendering */
ListBase fullresult; /* optional full sample buffers */
- int *recto; /* object table for objects */
- int *rectp; /* polygon index table */
- int *rectz; /* zbuffer */
- int *rectmask; /* negative zmask */
- intptr_t *rectdaps; /* delta acum buffer for pixel structs */
- int *rectbacko; /* object table for backside sss */
- int *rectbackp; /* polygon index table for backside sss */
- int *rectbackz; /* zbuffer for backside sss */
- intptr_t *rectall; /* buffer for all faces for sss */
-
rcti disprect; /* part coordinates within total picture */
int rectx, recty; /* the size */
int nr; /* nr is partnr */
- short crop, status; /* crop is amount of pixels we crop, for filter */
- short sample; /* sample can be used by zbuffers */
- short thread; /* thread id */
-
- char *clipflag; /* clipflags for part zbuffering */
+ short status;
} RenderPart;
enum {
@@ -129,10 +76,7 @@ struct Render {
int slot;
/* state settings */
- short flag, osa, ok, result_ok;
-
- /* due to performance issues, getting initialized from color management settings once on Render initialization */
- bool scene_color_manage;
+ short flag, ok, result_ok;
/* result of rendering */
RenderResult *result;
@@ -150,8 +94,6 @@ struct Render {
* without border & crop. convert to long before multiplying together to avoid overflow. */
rcti disprect; /* part within winx winy */
rctf viewplane; /* mapped on winx winy */
- float viewdx, viewdy; /* size of 1 pixel */
- float clipcrop; /* 2 pixel boundary to prevent clip when filter used */
/* final picture width and height (within disprect) */
int rectx, recty;
@@ -160,14 +102,7 @@ struct Render {
* partx*xparts can be larger than rectx, in that case last part is smaller */
int partx, party;
- /* values for viewing */
- float ycor; /* (scene->xasp / scene->yasp), multiplied with 'winy' */
-
- float panophi, panosi, panoco, panodxp, panodxv;
-
- /* Matrices */
- float grvec[3]; /* for world */
- float imat[3][3]; /* copy of viewinv */
+ /* Camera transform, only used by Freestyle. */
float viewmat[4][4], viewinv[4][4];
float viewmat_orig[4][4]; /* for incremental render */
float winmat[4][4];
@@ -176,24 +111,12 @@ struct Render {
float clipsta;
float clipend;
- /* samples */
- SampleTables *samples;
- float jit[32][2];
- float mblur_jit[32][2];
- ListBase *qmcsamplers;
- int num_qmc_samplers;
-
- /* shadow counter, detect shadow-reuse for shaders */
- int shadowsamplenr[BLENDER_MAX_THREADS];
-
/* main, scene, and its full copy of renderdata and world */
struct Main *main;
Scene *scene;
RenderData r;
ListBase view_layers;
int active_view_layer;
- World wrld;
- ViewRender view_render;
struct Object *camera_override;
unsigned int lay, layer_override;
@@ -203,56 +126,11 @@ struct Render {
/* render engine */
struct RenderEngine *engine;
- /* octree tables and variables for raytrace */
- struct RayObject *raytree;
- struct RayFace *rayfaces;
- struct VlakPrimitive *rayprimitives;
- float maxdist; /* needed for keeping an incorrect behavior of SUN and HEMI lights (avoid breaking old scenes) */
-
- /* occlusion tree */
- void *occlusiontree;
- ListBase strandsurface;
-
- /* use this instead of R.r.cfra */
- float mblur_offs, field_offs;
-
- /* render database */
- int totvlak, totvert, tothalo, totstrand, totlamp;
- struct HaloRen **sortedhalos;
-
- ListBase lights; /* GroupObject pointers */
- ListBase lampren; /* storage, for free */
-
- ListBase objecttable;
-
- struct ObjectInstanceRen *objectinstance;
- ListBase instancetable;
- int totinstance;
-
- struct Image *bakebuf;
-
- struct GHash *orco_hash;
-
- struct GHash *sss_hash;
- ListBase *sss_points;
- struct Material *sss_mat;
-
- ListBase customdata_names;
-
- struct Object *excludeob;
- ListBase render_volumes_inside;
- ListBase volumes;
-
#ifdef WITH_FREESTYLE
struct Main *freestyle_bmain;
ListBase freestyle_renders;
#endif
- /* arena for allocating data for use during render, for
- * example dynamic TFaces to go in the VlakRen structure.
- */
- struct MemArena *memArena;
-
/* callbacks */
void (*display_init)(void *handle, RenderResult *rr);
void *dih;
@@ -277,414 +155,14 @@ struct Render {
struct ReportList *reports;
- struct ImagePool *pool;
-
void **movie_ctx_arr;
char viewname[MAX_NAME];
};
-/* ------------------------------------------------------------------------- */
-
-struct ISBData;
-
-typedef struct DeepSample {
- int z;
- float v;
-} DeepSample;
-
-typedef struct ShadSampleBuf {
- struct ShadSampleBuf *next, *prev;
- intptr_t *zbuf;
- char *cbuf;
- DeepSample **deepbuf;
- int *totbuf;
-} ShadSampleBuf;
-
-typedef struct ShadBuf {
- /* regular shadowbuffer */
- short samp, shadhalostep, totbuf;
- float persmat[4][4];
- float viewmat[4][4];
- float winmat[4][4];
- float *jit, *weight;
- float d, clipend, pixsize, soft, compressthresh;
- int co[3];
- int size, bias;
- ListBase buffers;
-
- /* irregular shadowbufer, result stored per thread */
- struct ISBData *isb_result[BLENDER_MAX_THREADS];
-} ShadBuf;
-
-/* ------------------------------------------------------------------------- */
-
-typedef struct ObjectRen {
- struct ObjectRen *next, *prev;
- struct Object *ob, *par;
- struct Scene *sce;
- int index, psysindex, flag, lay;
-
- float boundbox[2][3];
-
- int totvert, totvlak, totstrand, tothalo;
- int vertnodeslen, vlaknodeslen, strandnodeslen, blohalen;
- struct VertTableNode *vertnodes;
- struct VlakTableNode *vlaknodes;
- struct StrandTableNode *strandnodes;
- struct HaloRen **bloha;
- struct StrandBuffer *strandbuf;
-
- char (*mtface)[MAX_CUSTOMDATA_LAYER_NAME];
- char (*mcol)[MAX_CUSTOMDATA_LAYER_NAME];
- int actmtface, actmcol, bakemtface;
-
- short tangent_mask; /* which tangent layer should be calculated */
-
- float obmat[4][4]; /* only used in convertblender.c, for instancing */
-
- /* used on makeraytree */
- struct RayObject *raytree;
- struct RayFace *rayfaces;
- struct VlakPrimitive *rayprimitives;
- struct ObjectInstanceRen *rayobi;
-
-} ObjectRen;
-
-typedef struct ObjectInstanceRen {
- struct ObjectInstanceRen *next, *prev;
-
- ObjectRen *obr;
- Object *ob, *par;
- int index, psysindex, lay;
-
- float mat[4][4], imat[4][4];
- float nmat[3][3]; /* nmat is inverse mat tranposed */
-
- float obmat[4][4], obinvmat[4][4];
- float localtoviewmat[4][4], localtoviewinvmat[4][4];
-
- short flag;
-
- float dupliorco[3], dupliuv[2];
- float (*duplitexmat)[4];
-
- struct VolumePrecache *volume_precache;
-
- float *vectors; /* (RE_WINSPEED_ELEMS * VertRen.index) */
- int totvector;
-
- /* used on makeraytree */
- struct RayObject *raytree;
- int transform_primitives;
-
- /* Particle info */
- float part_index;
- float part_age;
- float part_lifetime;
- float part_size;
- float part_co[3];
- float part_vel[3];
- float part_avel[3];
-
- unsigned int random_id;
-} ObjectInstanceRen;
-
-/* ------------------------------------------------------------------------- */
-
-typedef struct VertRen {
- float co[3];
- float n[3];
- float *orco;
- unsigned int flag; /* in use for clipping zbuffer parts, temp setting stuff in convertblender.c
- * only an 'int' because of alignment, could be a char too */
- float accum; /* accum for radio weighting, and for strand texco static particles */
- int index; /* index allows extending vertren with any property */
-} VertRen;
-
-/* ------------------------------------------------------------------------- */
-
-struct halosort {
- struct HaloRen *har;
- int z;
-};
-
-/* ------------------------------------------------------------------------- */
-struct Material;
-struct ImagePool;
-
-typedef struct RadFace {
- float unshot[3], totrad[3];
- float norm[3], cent[3], area;
- int flag;
-} RadFace;
-
-typedef struct VlakRen {
- struct VertRen *v1, *v2, *v3, *v4; /* keep in order for ** addressing */
- float n[3];
- struct Material *mat;
- char puno;
- char flag, ec;
-#ifdef WITH_FREESTYLE
- char freestyle_edge_mark;
- char freestyle_face_mark;
-#endif
- int index;
-} VlakRen;
-
-typedef struct HaloRen {
- short miny, maxy;
- float alfa, xs, ys, rad, radsq, sin, cos, co[3], no[3];
- float hard, b, g, r;
- int zs, zd;
- int zBufDist; /* depth in the z-buffer coordinate system */
- char starpoints, type, add, tex;
- char linec, ringc, seed;
- short flarec; /* used to be a char. why ?*/
- float hasize;
- int pixels;
- unsigned int lay;
- struct Material *mat;
- struct ImagePool *pool;
- bool skip_load_image, texnode_preview;
-} HaloRen;
-
-/* ------------------------------------------------------------------------- */
-
-typedef struct StrandVert {
- float co[3];
- float strandco;
-} StrandVert;
-
-typedef struct StrandSurface {
- struct StrandSurface *next, *prev;
- ObjectRen obr;
- int (*face)[4];
- float (*co)[3];
- /* for occlusion caching */
- float (*ao)[3];
- float (*env)[3];
- float (*indirect)[3];
- /* for speedvectors */
- float (*prevco)[3], (*nextco)[3];
- int totvert, totface;
-} StrandSurface;
-
-typedef struct StrandBound {
- int start, end;
- float boundbox[2][3];
-} StrandBound;
-
-typedef struct StrandBuffer {
- struct StrandBuffer *next, *prev;
- struct StrandVert *vert;
- struct StrandBound *bound;
- int totvert, totbound;
-
- struct ObjectRen *obr;
- struct Material *ma;
- struct StrandSurface *surface;
- unsigned int lay;
- int overrideuv;
- int flag, maxdepth;
- float adaptcos, minwidth, widthfade;
-
- float maxwidth; /* for cliptest of strands in blender unit */
-
- float winmat[4][4];
- int winx, winy;
-} StrandBuffer;
-
-typedef struct StrandRen {
- StrandVert *vert;
- StrandBuffer *buffer;
- int totvert, flag;
- int clip, index;
- float orco[3];
-} StrandRen;
-
-/* ------------------------------------------------------------------------- */
-
-typedef struct VolumeOb {
- struct VolumeOb *next, *prev;
- struct Material *ma;
- struct ObjectRen *obr;
-} VolumeOb;
-
-typedef struct MatInside {
- struct MatInside *next, *prev;
- struct Material *ma;
- struct ObjectInstanceRen *obi;
-} MatInside;
-
-typedef struct VolPrecachePart {
- struct VolPrecachePart *next, *prev;
- struct RayObject *tree;
- struct ShadeInput *shi;
- struct ObjectInstanceRen *obi;
- float viewmat[4][4];
- int num;
- int minx, maxx;
- int miny, maxy;
- int minz, maxz;
- int res[3];
- float bbmin[3];
- float voxel[3];
- struct Render *re;
-} VolPrecachePart;
-
-typedef struct VolumePrecache {
- int res[3];
- float *bbmin, *bbmax;
- float *data_r;
- float *data_g;
- float *data_b;
-} VolumePrecache;
-
-/* ------------------------------------------------------------------------- */
-
-struct LampRen;
-struct MTex;
-
-/**
- * For each lamp in a scene, a LampRen is created. It determines the
- * properties of a lightsource.
- */
-
-typedef struct LampShadowSubSample {
- int samplenr;
- float shadfac[4]; /* rgba shadow */
-} LampShadowSubSample;
-
-typedef struct LampShadowSample {
- LampShadowSubSample s[16]; /* MAX OSA */
-} LampShadowSample;
-
-typedef struct LampRen {
- struct LampRen *next, *prev;
-
- float xs, ys, dist;
- float co[3];
- short type;
- int mode;
- float r, g, b, k;
- float shdwr, shdwg, shdwb;
- float energy, haint;
- int lay;
- float spotsi, spotbl;
- float vec[3];
- float xsp, ysp, distkw, inpr;
- float halokw, halo;
-
- short falloff_type;
- float ld1, ld2;
- float coeff_const, coeff_lin, coeff_quad;
- struct CurveMapping *curfalloff;
-
- /* copied from Lamp, to decouple more rendering stuff */
- /** Size of the shadowbuffer */
- short bufsize;
- /** Number of samples for the shadows */
- short samp;
- /** Softness factor for shadow */
- float soft;
- /** amount of subsample buffers and type of filter for sampling */
- short buffers, filtertype;
- /** shadow buffer type (regular, irregular) */
- short buftype;
- /** autoclip */
- short bufflag;
- /** shadow plus halo: detail level */
- short shadhalostep;
- /** Near clip of the lamp */
- float clipsta;
- /** Far clip of the lamp */
- float clipend;
- /** A small depth offset to prevent self-shadowing. */
- float bias;
- /* Compression threshold for deep shadow maps */
- float compressthresh;
-
- short ray_samp, ray_sampy, ray_sampz, ray_samp_method, ray_samp_type, area_shape, ray_totsamp;
- short xold[BLENDER_MAX_THREADS], yold[BLENDER_MAX_THREADS]; /* last jitter table for area lights */
- float area_size, area_sizey, area_sizez;
- float adapt_thresh;
-
- /* sun/sky */
- struct SunSky *sunsky;
-
- struct ShadBuf *shb;
- float *jitter;
-
- float imat[3][3];
- float spottexfac;
- float sh_invcampos[3], sh_zfac; /* sh_= spothalo */
-
- float lampmat[4][4]; /* worls space lamp matrix, used for scene rotation */
-
- float mat[3][3]; /* 3x3 part from lampmat x viewmat */
- float area[8][3], areasize;
-
- /* passes & node shader support: all shadow info for a pixel */
- LampShadowSample *shadsamp;
-
- /* ray optim */
- struct RayObject *last_hit[BLENDER_MAX_THREADS];
-
- struct MTex *mtex[MAX_MTEX];
-
- /* threading */
- int thread_assigned;
- int thread_ready;
-} LampRen;
-
/* **************** defines ********************* */
-/* R.r.mode flag is same as for renderdata */
-
/* R.flag */
-#define R_ZTRA 1
-#define R_HALO 2
-#define R_SEC_FIELD 4
-#define R_LAMPHALO 8
-#define R_NEED_TANGENT 16
-#define R_BAKE_TRACE 32
-#define R_BAKING 64
-#define R_ANIMATION 128
-#define R_NEED_VCOL 256
-
-/* vlakren->flag (vlak = face in dutch) char!!! */
-#define R_SMOOTH 1
-#define R_HIDDEN 2
-/* strand flag, means special handling */
-#define R_STRAND 4
-#define R_FULL_OSA 8
-#define R_FACE_SPLIT 16
-/* Tells render to divide face other way. */
-#define R_DIVIDE_24 32
-/* vertex normals are tangent or view-corrected vector, for hair strands */
-#define R_TANGENT 64
-#define R_TRACEBLE 128
-
-/* vlakren->freestyle_edge_mark */
-#ifdef WITH_FREESTYLE
-# define R_EDGE_V1V2 1
-# define R_EDGE_V2V3 2
-# define R_EDGE_V3V4 4
-# define R_EDGE_V3V1 4
-# define R_EDGE_V4V1 8
-#endif
-
-/* strandbuffer->flag */
-#define R_STRAND_BSPLINE 1
-#define R_STRAND_B_UNITS 2
-
-/* objectren->flag */
-#define R_INSTANCEABLE 1
-
-/* objectinstance->flag */
-#define R_DUPLI_TRANSFORMED 1
-#define R_ENV_TRANSFORMED 2
-#define R_TRANSFORMED (1|2)
+#define R_ANIMATION 1
#endif /* __RENDER_TYPES_H__ */
diff --git a/source/blender/render/intern/include/rendercore.h b/source/blender/render/intern/include/rendercore.h
deleted file mode 100644
index c01db7db53e..00000000000
--- a/source/blender/render/intern/include/rendercore.h
+++ /dev/null
@@ -1,105 +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 *****
- */
-
-#ifndef __RENDERCORE_H__
-#define __RENDERCORE_H__
-
-/** \file blender/render/intern/include/rendercore.h
- * \ingroup render
- */
-
-#include "render_types.h"
-
-#include "RE_engine.h"
-
-#include "DNA_node_types.h"
-
-#include "NOD_composite.h"
-
-struct ShadeInput;
-struct ShadeResult;
-struct World;
-struct RenderPart;
-struct RenderLayer;
-struct RayObject;
-
-/* ------------------------------------------------------------------------- */
-
-typedef struct PixStr {
- struct PixStr *next;
- int obi, facenr, z, maskz;
- unsigned short mask;
- short shadfac;
-} PixStr;
-
-typedef struct PixStrMain {
- struct PixStrMain *next, *prev;
- struct PixStr *ps;
- int counter;
-} PixStrMain;
-
-/* ------------------------------------------------------------------------- */
-
-
-void calc_view_vector(float view[3], float x, float y);
-float mistfactor(float zcor, const float co[3]); /* dist and height, return alpha */
-
-void renderspothalo(struct ShadeInput *shi, float col[4], float alpha);
-void add_halo_flare(Render *re);
-
-void calc_renderco_zbuf(float co[3], const float view[3], int z);
-void calc_renderco_ortho(float co[3], float x, float y, int z);
-
-int count_mask(unsigned short mask);
-
-void zbufshade_tile(struct RenderPart *pa);
-void zbufshadeDA_tile(struct RenderPart *pa);
-
-void zbufshade_sss_tile(struct RenderPart *pa);
-
-int get_sample_layers(struct RenderPart *pa, struct RenderLayer *rl, struct RenderLayer **rlpp);
-
-void render_internal_update_passes(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer);
-
-
-/* -------- ray.c ------- */
-
-struct RayObject *RE_rayobject_create(int type, int size, int octree_resolution);
-
-extern void freeraytree(Render *re);
-extern void makeraytree(Render *re);
-struct RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi);
-
-extern void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4]);
-extern void ray_trace(ShadeInput *shi, ShadeResult *);
-extern void ray_ao(ShadeInput *shi, float ao[3], float env[3]);
-extern void init_jitter_plane(LampRen *lar);
-extern void init_ao_sphere(Render *re, struct World *wrld);
-extern void init_render_qmcsampler(Render *re);
-extern void free_render_qmcsampler(Render *re);
-
-#endif /* __RENDERCORE_H__ */
diff --git a/source/blender/render/intern/include/renderdatabase.h b/source/blender/render/intern/include/renderdatabase.h
deleted file mode 100644
index 1d1af7092c8..00000000000
--- a/source/blender/render/intern/include/renderdatabase.h
+++ /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) 2006 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/renderdatabase.h
- * \ingroup render
- */
-
-
-#ifndef __RENDERDATABASE_H__
-#define __RENDERDATABASE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct Object;
-struct VlakRen;
-struct VertRen;
-struct EvaluationContext;
-struct HaloRen;
-struct Main;
-struct Material;
-struct Render;
-struct MCol;
-struct MTFace;
-struct CustomData;
-struct StrandBuffer;
-struct StrandRen;
-struct ObjectInstanceRen;
-struct RadFace;
-struct Isect;
-
-#define RE_QUAD_MASK 0x7FFFFFF
-#define RE_QUAD_OFFS 0x8000000
-
-/* render allocates totvert/256 of these nodes, for lookup and quick alloc */
-typedef struct VertTableNode {
- struct VertRen *vert;
- float *rad;
- float *strand;
- float *tangent;
- float *stress;
- float *winspeed;
- /* Index of vertex in source mesh (before modifiers). */
- int *origindex;
-} VertTableNode;
-
-typedef struct VlakTableNode {
- struct VlakRen *vlak;
- struct MTFace *mtface;
- struct MCol *mcol;
- /* Index of mpoly in source mesh (before tessellation). */
- int *origindex;
- int totmtface, totmcol;
- float *surfnor;
- float *tangent_arrays[MAX_MTFACE];
- struct RadFace **radface;
-} VlakTableNode;
-
-typedef struct StrandTableNode {
- struct StrandRen *strand;
- float *winspeed;
- float *surfnor;
- float *simplify;
- int *face;
- struct MCol *mcol;
- float *uv;
- int totuv, totmcol;
-} StrandTableNode;
-
-/* renderdatabase.c */
-void free_renderdata_tables(struct Render *re);
-void free_renderdata_vertnodes(struct VertTableNode *vertnodes);
-void free_renderdata_vlaknodes(struct VlakTableNode *vlaknodes);
-
-void project_renderdata(struct Render *re, void (*projectfunc)(const float *, float mat[4][4], float *), bool do_pano, float xoffs, bool do_buckets);
-int clip_render_object(float boundbox[2][3], float bounds[4], float mat[4][4]);
-
-/* functions are not exported... so wrong names */
-
-struct VlakRen *RE_findOrAddVlak(struct ObjectRen *obr, int nr);
-struct VertRen *RE_findOrAddVert(struct ObjectRen *obr, int nr);
-struct StrandRen *RE_findOrAddStrand(struct ObjectRen *obr, int nr);
-struct HaloRen *RE_findOrAddHalo(struct ObjectRen *obr, int nr);
-struct HaloRen *RE_inithalo(struct Render *re, struct ObjectRen *obr, struct Material *ma,
- const float vec[3], const float vec1[3],
- const float *orco, float hasize, float vectsize, int seed);
-struct HaloRen *RE_inithalo_particle(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, struct Material *ma,
- const float vec[3], const float vec1[3],
- const float *orco, const float *uvco, float hasize, float vectsize, int seed,
- const float pa_co[3]);
-struct StrandBuffer *RE_addStrandBuffer(struct ObjectRen *obr, int totvert);
-
-struct ObjectRen *RE_addRenderObject(struct Render *re, struct Object *ob, struct Object *par, int index, int psysindex, int lay);
-struct ObjectInstanceRen *RE_addRenderInstance(
- struct Render *re, struct ObjectRen *obr, struct Object *ob, struct Object *par,
- int index, int psysindex, float mat[4][4], int lay, const struct DupliObject *dob);
-void RE_makeRenderInstances(struct Render *re);
-void RE_updateRenderInstance(Render *re, ObjectInstanceRen *obi, int flag);
-
-void RE_instance_rotate_ray_start(struct ObjectInstanceRen *obi, struct Isect *is);
-void RE_instance_rotate_ray_dir(struct ObjectInstanceRen *obi, struct Isect *is);
-void RE_instance_rotate_ray(struct ObjectInstanceRen *obi, struct Isect *is);
-void RE_instance_rotate_ray_restore(struct ObjectInstanceRen *obi, struct Isect *is);
-
-float *RE_vertren_get_stress(struct ObjectRen *obr, struct VertRen *ver, int verify);
-float *RE_vertren_get_rad(struct ObjectRen *obr, struct VertRen *ver, int verify);
-float *RE_vertren_get_strand(struct ObjectRen *obr, struct VertRen *ver, int verify);
-float *RE_vertren_get_tangent(struct ObjectRen *obr, struct VertRen *ver, int verify);
-float *RE_vertren_get_winspeed(struct ObjectInstanceRen *obi, struct VertRen *ver, int verify);
-int *RE_vertren_get_origindex(struct ObjectRen *obr, VertRen *ver, int verify);
-
-struct MTFace *RE_vlakren_get_tface(struct ObjectRen *obr, VlakRen *ren, int n, char **name, int verify);
-struct MCol *RE_vlakren_get_mcol(struct ObjectRen *obr, VlakRen *ren, int n, char **name, int verify);
-int *RE_vlakren_get_origindex(struct ObjectRen *obr, VlakRen *vlak, int verify);
-float *RE_vlakren_get_surfnor(struct ObjectRen *obr, VlakRen *ren, int verify);
-float *RE_vlakren_get_nmap_tangent(ObjectRen *obr, VlakRen *vlak, int index, bool verify);
-RadFace **RE_vlakren_get_radface(struct ObjectRen *obr, VlakRen *ren, int verify);
-void RE_vlakren_get_normal(struct Render *re, struct ObjectInstanceRen *obi, struct VlakRen *vlr, float *nor);
-
-float *RE_strandren_get_surfnor(struct ObjectRen *obr, struct StrandRen *strand, int verify);
-float *RE_strandren_get_uv(struct ObjectRen *obr, struct StrandRen *strand, int n, char **name, int verify);
-struct MCol *RE_strandren_get_mcol(struct ObjectRen *obr, struct StrandRen *strand, int n, char **name, int verify);
-float *RE_strandren_get_simplify(struct ObjectRen *obr, struct StrandRen *strand, int verify);
-int *RE_strandren_get_face(struct ObjectRen *obr, struct StrandRen *strand, int verify);
-float *RE_strandren_get_winspeed(struct ObjectInstanceRen *obi, struct StrandRen *strand, int verify);
-
-struct VertRen *RE_vertren_copy(struct ObjectRen *obr, struct VertRen *ver);
-struct VlakRen *RE_vlakren_copy(struct ObjectRen *obr, struct VlakRen *vlr);
-
-void RE_set_customdata_names(struct ObjectRen *obr, struct CustomData *data);
-
-void area_lamp_vectors(struct LampRen *lar);
-
-
-/* haloren->type: flags */
-#define HA_ONLYSKY 1
-#define HA_VECT 2
-#define HA_XALPHA 4
-#define HA_FLARECIRC 8
-
-/* convertblender.c */
-void init_render_world(Render *re);
-void RE_Database_FromScene_Vectors(struct EvaluationContext *eval_ctx, Render *re, struct Main *bmain, struct Scene *sce, unsigned int lay);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __RENDERDATABASE_H__ */
-
diff --git a/source/blender/render/intern/include/renderpipeline.h b/source/blender/render/intern/include/renderpipeline.h
index 8c23eb0d4cb..68fbc01b914 100644
--- a/source/blender/render/intern/include/renderpipeline.h
+++ b/source/blender/render/intern/include/renderpipeline.h
@@ -38,13 +38,10 @@ struct Render;
struct RenderData;
struct RenderLayer;
struct RenderResult;
-struct ViewRender;
struct RenderLayer *render_get_active_layer(struct Render *re, struct RenderResult *rr);
-float panorama_pixel_rot(struct Render *re);
void render_update_anim_renderdata(struct Render *re, struct RenderData *rd, struct ListBase *render_layers);
void render_copy_renderdata(struct RenderData *to, struct RenderData *from);
-void render_copy_viewrender(struct ViewRender *to, struct ViewRender *from);
#endif /* __RENDERPIPELINE_H__ */
diff --git a/source/blender/render/intern/include/shadbuf.h b/source/blender/render/intern/include/shadbuf.h
deleted file mode 100644
index ddf5de8d974..00000000000
--- a/source/blender/render/intern/include/shadbuf.h
+++ /dev/null
@@ -1,112 +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 *****
- */
-
-#ifndef __SHADBUF_H__
-#define __SHADBUF_H__
-
-/** \file blender/render/intern/include/shadbuf.h
- * \ingroup render
- */
-
-#include "render_types.h"
-
-
-/**
- * Calculates shadowbuffers for a vector of shadow-giving lamps
- * \param lar The vector of lamps
- */
-void makeshadowbuf(struct Render *re, LampRen *lar);
-void freeshadowbuf(struct LampRen *lar);
-
-void threaded_makeshadowbufs(struct Render *re);
-
-/**
- * Determines the shadow factor for a face and lamp. There is some
- * communication with global variables here.
- * \return The shadow factors: 1.0 for no shadow, 0.0 for complete
- * shadow.
- * \param shb The shadowbuffer to find the shadow factor in.
- * \param inp The inproduct between viewvector and ?
- *
- */
-float testshadowbuf(struct Render *re, struct ShadBuf *shb, const float rco[3], const float dxco[3], const float dyco[3], float inp, float mat_bias);
-
-/**
- * Determines the shadow factor for lamp \a lar, between \a p1 and \a p2. (Which CS?)
- */
-float shadow_halo(LampRen *lar, const float p1[3], const float p2[3]);
-
-/**
- * Irregular shadowbuffer
- */
-
-struct MemArena;
-struct APixstr;
-
-void ISB_create(RenderPart *pa, struct APixstr *apixbuf);
-void ISB_free(RenderPart *pa);
-float ISB_getshadow(ShadeInput *shi, ShadBuf *shb);
-
-/* data structures have to be accessible both in camview(x, y) as in lampview(x, y) */
-/* since they're created per tile rendered, speed goes over memory requirements */
-
-
-/* buffer samples, allocated in camera buffer and pointed to in lampbuffer nodes */
-typedef struct ISBSample {
- float zco[3]; /* coordinate in lampview projection */
- short *shadfac; /* initialized zero = full lighted */
- int obi; /* object for face lookup */
- int facenr; /* index in faces list */
-} ISBSample;
-
-/* transparent version of buffer sample */
-typedef struct ISBSampleA {
- float zco[3]; /* coordinate in lampview projection */
- short *shadfac; /* NULL = full lighted */
- int obi; /* object for face lookup */
- int facenr; /* index in faces list */
- struct ISBSampleA *next; /* in end, we want the first items to align with ISBSample */
-} ISBSampleA;
-
-/* used for transparent storage only */
-typedef struct ISBShadfacA {
- struct ISBShadfacA *next;
- int obi;
- int facenr;
- float shadfac;
-} ISBShadfacA;
-
-/* What needs to be stored to evaluate shadow, for each thread in ShadBuf */
-typedef struct ISBData {
- short *shadfacs; /* simple storage for solid only */
- ISBShadfacA **shadfaca;
- struct MemArena *memarena;
- int minx, miny, rectx, recty; /* copy from part disprect */
-} ISBData;
-
-#endif /* __SHADBUF_H__ */
-
diff --git a/source/blender/render/intern/include/shading.h b/source/blender/render/intern/include/shading.h
deleted file mode 100644
index 3ef6e9d7476..00000000000
--- a/source/blender/render/intern/include/shading.h
+++ /dev/null
@@ -1,105 +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) 2006 Blender Foundation
- * All rights reserved.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/shading.h
- * \ingroup render
- */
-
-
-struct ShadeInput;
-struct ShadeResult;
-struct RenderPart;
-struct RenderLayer;
-struct PixStr;
-struct LampRen;
-struct VlakRen;
-struct StrandPoint;
-struct ObjectInstanceRen;
-struct Isect;
-
-/* shadeinput.c */
-
-#define RE_MAX_OSA 16
-
-/* needed to calculate shadow and AO for an entire pixel */
-typedef struct ShadeSample {
- int tot; /* amount of shi in use, can be 1 for not FULL_OSA */
-
- RenderLayer *rlpp[RE_MAX_OSA]; /* fast lookup from sample to renderlayer (fullsample buf) */
-
- /* could be malloced once */
- ShadeInput shi[RE_MAX_OSA];
- ShadeResult shr[RE_MAX_OSA];
-} ShadeSample;
-
-
- /* also the node shader callback */
-void shade_material_loop(struct ShadeInput *shi, struct ShadeResult *shr);
-
-void shade_input_set_triangle_i(struct ShadeInput *shi, struct ObjectInstanceRen *obi, struct VlakRen *vlr, short i1, short i2, short i3);
-void shade_input_set_triangle(struct ShadeInput *shi, int obi, int facenr, int normal_flip);
-void shade_input_copy_triangle(struct ShadeInput *shi, struct ShadeInput *from);
-void shade_input_calc_viewco(struct ShadeInput *shi, float x, float y, float z, float view[3], float dxyview[2], float co[3], float dxco[3], float dyco[3]);
-void shade_input_set_viewco(struct ShadeInput *shi, float x, float y, float sx, float sy, float z);
-void shade_input_set_uv(struct ShadeInput *shi);
-void shade_input_set_normals(struct ShadeInput *shi);
-void shade_input_set_vertex_normals(struct ShadeInput *shi);
-void shade_input_flip_normals(struct ShadeInput *shi);
-void shade_input_set_shade_texco(struct ShadeInput *shi);
-void shade_input_set_strand(struct ShadeInput *shi, struct StrandRen *strand, struct StrandPoint *spoint);
-void shade_input_set_strand_texco(struct ShadeInput *shi, struct StrandRen *strand, struct StrandVert *svert, struct StrandPoint *spoint);
-void shade_input_do_shade(struct ShadeInput *shi, struct ShadeResult *shr);
-
-void shade_input_init_material(struct ShadeInput *shi);
-void shade_input_initialize(struct ShadeInput *shi, struct RenderPart *pa, struct RenderLayer *rl, int sample);
-
-void shade_sample_initialize(struct ShadeSample *ssamp, struct RenderPart *pa, struct RenderLayer *rl);
-void shade_samples_do_AO(struct ShadeSample *ssamp);
-void shade_samples_fill_with_ps(struct ShadeSample *ssamp, struct PixStr *ps, int x, int y);
-int shade_samples(struct ShadeSample *ssamp, struct PixStr *ps, int x, int y);
-
-void vlr_set_uv_indices(struct VlakRen *vlr, int *i1, int *i2, int *i3);
-
-void calc_R_ref(struct ShadeInput *shi);
-
-void barycentric_differentials_from_position(
- const float co[3], const float v1[3], const float v2[3], const float v3[3],
- const float dxco[3], const float dyco[3], const float facenor[3], const bool differentials,
- float *u, float *v, float *dx_u, float *dx_v, float *dy_u, float *dy_v);
-
-/* shadeoutput. */
-void shade_lamp_loop(struct ShadeInput *shi, struct ShadeResult *shr);
-
-void shade_color(struct ShadeInput *shi, ShadeResult *shr);
-
-void ambient_occlusion(struct ShadeInput *shi);
-void environment_lighting_apply(struct ShadeInput *shi, struct ShadeResult *shr);
-
-ListBase *get_lights(struct ShadeInput *shi);
-float lamp_get_visibility(struct LampRen *lar, const float co[3], float lv[3], float *dist);
-void lamp_get_shadow(struct LampRen *lar, ShadeInput *shi, float inp, float shadfac[4], int do_real);
-
-float fresnel_fac(const float view[3], const float vn[3], float fresnel, float fac);
-
-/* rayshade.c */
-extern void shade_ray(struct Isect *is, struct ShadeInput *shi, struct ShadeResult *shr);
diff --git a/source/blender/render/intern/include/sss.h b/source/blender/render/intern/include/sss.h
deleted file mode 100644
index 0952c6bff65..00000000000
--- a/source/blender/render/intern/include/sss.h
+++ /dev/null
@@ -1,67 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/sss.h
- * \ingroup render
- */
-
-
-#ifndef __SSS_H__
-#define __SSS_H__
-
-/* Generic multiple scattering API */
-
-struct ScatterSettings;
-typedef struct ScatterSettings ScatterSettings;
-
-struct ScatterTree;
-typedef struct ScatterTree ScatterTree;
-
-ScatterSettings *scatter_settings_new(float refl, float radius, float ior,
- float reflfac, float frontweight, float backweight);
-void scatter_settings_free(ScatterSettings *ss);
-
-ScatterTree *scatter_tree_new(ScatterSettings *ss[3], float scale, float error,
- float (*co)[3], float (*color)[3], float *area, int totpoint);
-void scatter_tree_build(ScatterTree *tree);
-void scatter_tree_sample(ScatterTree *tree, const float co[3], float color[3]);
-void scatter_tree_free(ScatterTree *tree);
-
-/* Internal renderer API */
-
-struct Render;
-struct Material;
-
-void make_sss_tree(struct Render *re);
-void sss_add_points(Render *re, float (*co)[3], float (*color)[3], float *area, int totpoint);
-void free_sss(struct Render *re);
-
-int sample_sss(struct Render *re, struct Material *mat, const float co[3], float color[3]);
-int sss_pass_done(struct Render *re, struct Material *mat);
-
-#endif /*__SSS_H__*/
-
diff --git a/source/blender/render/intern/include/strand.h b/source/blender/render/intern/include/strand.h
deleted file mode 100644
index 5687ef3c837..00000000000
--- a/source/blender/render/intern/include/strand.h
+++ /dev/null
@@ -1,99 +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.
- *
- * Contributor(s): Brecht Van Lommel.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/strand.h
- * \ingroup render
- */
-
-
-#ifndef __STRAND_H__
-#define __STRAND_H__
-
-struct StrandVert;
-struct StrandRen;
-struct StrandBuffer;
-struct ShadeSample;
-struct StrandPart;
-struct Render;
-struct ZSpan;
-struct ObjectInstanceRen;
-struct StrandSurface;
-struct DerivedMesh;
-struct ObjectRen;
-
-typedef struct StrandPoint {
- /* position within segment */
- float t;
-
- /* camera space */
- float co[3];
- float nor[3];
- float tan[3];
- float strandco;
- float width;
-
- /* derivatives */
- float dtco[3], dsco[3];
- float dtstrandco;
-
- /* outer points */
- float co1[3], co2[3];
- float hoco1[4], hoco2[4];
- float zco1[3], zco2[3];
- int clip1, clip2;
-
- /* screen space */
- float hoco[4];
- float x, y;
-
- /* simplification */
- float alpha;
-} StrandPoint;
-
-typedef struct StrandSegment {
- struct StrandVert *v[4];
- struct StrandRen *strand;
- struct StrandBuffer *buffer;
- struct ObjectInstanceRen *obi;
- float sqadaptcos;
-
- StrandPoint point1, point2;
- int shaded;
-} StrandSegment;
-
-struct StrandShadeCache;
-typedef struct StrandShadeCache StrandShadeCache;
-
-void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint);
-void render_strand_segment(struct Render *re, float winmat[4][4], struct StrandPart *spart, struct ZSpan *zspan, int totzspan, StrandSegment *sseg);
-void strand_minmax(struct StrandRen *strand, float min[3], float max[3], const float width);
-
-struct StrandSurface *cache_strand_surface(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, float mat[4][4], int timeoffset);
-void free_strand_surface(struct Render *re);
-
-struct StrandShadeCache *strand_shade_cache_create(void);
-void strand_shade_cache_free(struct StrandShadeCache *cache);
-void strand_shade_segment(struct Render *re, struct StrandShadeCache *cache, struct StrandSegment *sseg, struct ShadeSample *ssamp, float t, float s, int addpassflag);
-void strand_shade_unref(struct StrandShadeCache *cache, struct ObjectInstanceRen *obi, struct StrandVert *svert);
-
-#endif
-
diff --git a/source/blender/render/intern/include/sunsky.h b/source/blender/render/intern/include/sunsky.h
deleted file mode 100644
index 60fa8aa51ba..00000000000
--- a/source/blender/render/intern/include/sunsky.h
+++ /dev/null
@@ -1,81 +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.
- *
- * Contributor(s): zaghaghi
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/sunsky.h
- * \ingroup render
- */
-
-#ifndef __SUNSKY_H__
-#define __SUNSKY_H__
-
-// #define SPECTRUM_MAX_COMPONENTS 100
-
-typedef struct SunSky {
- short effect_type, skyblendtype, sky_colorspace;
- float turbidity;
- float theta, phi;
-
- float toSun[3];
-
- /*float sunSpectralRaddata[SPECTRUM_MAX_COMPONENTS];*/
- float sunSolidAngle;
-
- float zenith_Y, zenith_x, zenith_y;
-
- float perez_Y[5], perez_x[5], perez_y[5];
-
- /* suggested by glome in patch [#8063] */
- float horizon_brightness;
- float spread;
- float sun_brightness;
- float sun_size;
- float backscattered_light;
- float skyblendfac;
- float sky_exposure;
-
- float atm_HGg;
-
- float atm_SunIntensity;
- float atm_InscatteringMultiplier;
- float atm_ExtinctionMultiplier;
- float atm_BetaRayMultiplier;
- float atm_BetaMieMultiplier;
- float atm_DistanceMultiplier;
-
- float atm_BetaRay[3];
- float atm_BetaDashRay[3];
- float atm_BetaMie[3];
- float atm_BetaDashMie[3];
- float atm_BetaRM[3];
-} SunSky;
-
-void InitSunSky(struct SunSky *sunsky, float turb, const float toSun[3], float horizon_brightness,
- float spread, float sun_brightness, float sun_size, float back_scatter,
- float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace);
-
-void GetSkyXYZRadiance(struct SunSky *sunsky, float theta, float phi, float color_out[3]);
-void GetSkyXYZRadiancef(struct SunSky *sunsky, const float varg[3], float color_out[3]);
-void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float rayf, float inscattf, float extincf, float disf);
-void AtmospherePixleShader(struct SunSky *sunSky, float view[3], float s, float rgb[3]);
-void ClipColor(float c[3]);
-
-#endif /*__SUNSKY_H__*/
diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h
index dfb491f46b0..71000e38960 100644
--- a/source/blender/render/intern/include/texture.h
+++ b/source/blender/render/intern/include/texture.h
@@ -63,29 +63,12 @@
} \
} \
-struct HaloRen;
-struct ShadeInput;
struct TexResult;
struct Tex;
struct Image;
struct ImBuf;
struct ImagePool;
-/* texture.h */
-
-void do_halo_tex(struct HaloRen *har, float xn, float yn, float col_r[4]);
-void do_sky_tex(
- const float rco[3], const float view[3], const float lo[3], const float dxyview[2],
- float hor[3], float zen[3], float *blend, int skyflag, short thread);
-void do_material_tex(struct ShadeInput *shi, struct Render *re);
-void do_lamp_tex(LampRen *la, const float lavec[3], struct ShadeInput *shi, float col_r[3], int effect);
-void do_volume_tex(struct ShadeInput *shi, const float xyz[3], int mapto_flag, float col_r[3], float *val, struct Render *re);
-
-void init_render_textures(Render *re);
-void end_render_textures(Render *re);
-
-void render_realtime_texture(struct ShadeInput *shi, struct Image *ima);
-
/* imagetexture.h */
int imagewraposa(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], const float dxt[2], const float dyt[2], struct TexResult *texres, struct ImagePool *pool, const bool skip_load_image);
diff --git a/source/blender/render/intern/include/texture_ocean.h b/source/blender/render/intern/include/texture_ocean.h
deleted file mode 100644
index 4a71aff930a..00000000000
--- a/source/blender/render/intern/include/texture_ocean.h
+++ /dev/null
@@ -1,35 +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.
- *
- * Contributors: Matt Ebb
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __TEXTURE_OCEAN_H__
-#define __TEXTURE_OCEAN_H__
-
-/** \file blender/render/intern/include/texture_ocean.h
- * \ingroup render
- */
-
-int ocean_texture(struct Tex *tex, const float texvec[2], struct TexResult *texres);
-
-#endif /* __TEXTURE_OCEAN_H__ */
diff --git a/source/blender/render/intern/include/volume_precache.h b/source/blender/render/intern/include/volume_precache.h
deleted file mode 100644
index 9aa280d8276..00000000000
--- a/source/blender/render/intern/include/volume_precache.h
+++ /dev/null
@@ -1,39 +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): Matt Ebb.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/volume_precache.h
- * \ingroup render
- */
-
-
-void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float bbmin[3], float bbmax[3]);
-int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, const float co[3]);
-
-void volume_precache(Render *re);
-void free_volume_precache(Render *re);
-
-#define VOL_MS_TIMESTEP 0.1f
diff --git a/source/blender/render/intern/include/volumetric.h b/source/blender/render/intern/include/volumetric.h
deleted file mode 100644
index 3805478fed0..00000000000
--- a/source/blender/render/intern/include/volumetric.h
+++ /dev/null
@@ -1,51 +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): Matt Ebb.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/volumetric.h
- * \ingroup render
- */
-
-
-struct Isect;
-struct ShadeInput;
-struct ShadeResult;
-
-float vol_get_density(struct ShadeInput *shi, const float co[3]);
-void vol_get_scattering(ShadeInput *shi, float scatter_col[3], const float co[3], const float view[3]);
-
-void shade_volume_outside(ShadeInput *shi, ShadeResult *shr);
-void shade_volume_inside(ShadeInput *shi, ShadeResult *shr);
-void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct Isect *last_is);
-
-#define VOL_IS_BACKFACE 1
-#define VOL_IS_SAMEMATERIAL 2
-
-#define VOL_BOUNDS_DEPTH 0
-#define VOL_BOUNDS_SS 1
-
-#define VOL_SHADE_OUTSIDE 0
-#define VOL_SHADE_INSIDE 1
diff --git a/source/blender/render/intern/include/voxeldata.h b/source/blender/render/intern/include/voxeldata.h
deleted file mode 100644
index dd2262e0357..00000000000
--- a/source/blender/render/intern/include/voxeldata.h
+++ /dev/null
@@ -1,47 +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): Raul Fernandez Hernandez (Farsthary), Matt Ebb.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/include/voxeldata.h
- * \ingroup render
- */
-
-#ifndef __VOXELDATA_H__
-#define __VOXELDATA_H__
-
-struct Render;
-struct TexResult;
-
-typedef struct VoxelDataHeader {
- int resolX, resolY, resolZ;
- int frames;
-} VoxelDataHeader;
-
-void cache_voxeldata(Tex *tex, int scene_frame);
-void make_voxeldata(struct Render *re);
-int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres);
-
-#endif /* __VOXELDATA_H__ */
diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/include/zbuf.h
index 6fc1a4c2656..1a93fc6c3b2 100644
--- a/source/blender/render/intern/include/zbuf.h
+++ b/source/blender/render/intern/include/zbuf.h
@@ -33,57 +33,6 @@
#ifndef __ZBUF_H__
#define __ZBUF_H__
-struct RenderPart;
-struct RenderLayer;
-struct LampRen;
-struct ListBase;
-struct ZSpan;
-struct APixstrand;
-struct APixstr;
-struct StrandShadeCache;
-
-void fillrect(int *rect, int x, int y, int val);
-
-/**
- * Converts a world coordinate into a homogeneous coordinate in view
- * coordinates.
- */
-void projectvert(const float v1[3], float winmat[4][4], float adr[4]);
-void projectverto(const float v1[3], float winmat[4][4], float adr[4]);
-int testclip(const float v[3]);
-
-void zbuffer_shadow(struct Render *re, float winmat[4][4], struct LampRen *lar, int *rectz, int size, float jitx, float jity);
-void zbuffer_abuf_shadow(struct Render *re, struct LampRen *lar, float winmat[4][4], struct APixstr *APixbuf, struct APixstrand *apixbuf, struct ListBase *apsmbase, int size, int samples, float (*jit)[2]);
-void zbuffer_solid(struct RenderPart *pa, struct RenderLayer *rl, void (*fillfunc)(struct RenderPart *, struct ZSpan *, int, void *), void *data);
-
-unsigned short *zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass, struct ListBase *psmlist);
-void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(void *, int, int, int, int, int));
-int zbuffer_strands_abuf(struct Render *re, struct RenderPart *pa, struct APixstrand *apixbuf, struct ListBase *apsmbase, unsigned int lay, int negzmask, float winmat[4][4], int winx, int winy, int sample, float (*jit)[2], float clipcrop, int shadow, struct StrandShadeCache *cache);
-
-typedef struct APixstr {
- unsigned short mask[4]; /* jitter mask */
- int z[4]; /* distance */
- int p[4]; /* index */
- int obi[4]; /* object instance */
- short shadfac[4]; /* optimize storage for irregular shadow */
- struct APixstr *next;
-} APixstr;
-
-typedef struct APixstrand {
- unsigned short mask[4]; /* jitter mask */
- int z[4]; /* distance */
- int p[4]; /* index */
- int obi[4]; /* object instance */
- int seg[4]; /* for strands, segment number */
- float u[4], v[4]; /* for strands, u,v coordinate in segment */
- struct APixstrand *next;
-} APixstrand;
-
-typedef struct APixstrMain {
- struct APixstrMain *next, *prev;
- void *ps;
-} APixstrMain;
-
/* span fill in method, is also used to localize data for zbuffering */
typedef struct ZSpan {
int rectx, recty; /* range for clipping */
@@ -91,61 +40,13 @@ typedef struct ZSpan {
int miny1, maxy1, miny2, maxy2; /* actual filled in range */
const float *minp1, *maxp1, *minp2, *maxp2; /* vertex pointers detect min/max range in */
float *span1, *span2;
-
- float zmulx, zmuly, zofsx, zofsy; /* transform from hoco to zbuf co */
-
- int *rectz, *arectz; /* zbuffers, arectz is for transparent */
- int *rectz1; /* secondary z buffer for shadowbuffer (2nd closest z) */
- int *rectp; /* polygon index buffer */
- int *recto; /* object buffer */
- int *rectmask; /* negative zmask buffer */
- APixstr *apixbuf, *curpstr; /* apixbuf for transparent */
- APixstrand *curpstrand; /* same for strands */
- struct ListBase *apsmbase;
-
- int polygon_offset; /* offset in Z */
- float shad_alpha; /* copy from material, used by irregular shadbuf */
- int mask, apsmcounter; /* in use by apixbuf */
- int apstrandmcounter;
-
- float clipcrop; /* for shadow, was in R global before */
-
- void *sss_handle; /* used by sss */
- void (*sss_func)(void *, int, int, int, int, int);
-
- void (*zbuffunc)(struct ZSpan *, int, int, const float *, const float *, const float *, const float *);
- void (*zbuflinefunc)(struct ZSpan *, int, int, const float *, const float *);
-
} ZSpan;
-/* exported to shadbuf.c */
-void zbufclip4(struct ZSpan *zspan, int obi, int zvlnr,
- const float f1[4], const float f2[4], const float f3[4], const float f4[4],
- const int c1, const int c2, const int c3, const int c4);
+void zbuf_alloc_span(struct ZSpan *zspan, int rectx, int recty);
void zbuf_free_span(struct ZSpan *zspan);
-void freepsA(struct ListBase *lb);
-/* to rendercore.c */
void zspan_scanconvert(struct ZSpan *zpan, void *handle, float *v1, float *v2, float *v3,
void (*func)(void *, int, int, float, float) );
-/* exported to edge render... */
-void zbufclip(struct ZSpan *zspan, int obi, int zvlnr,
- const float f1[4], const float f2[4], const float f3[4],
- const int c1, const int c2, const int c3);
-void zbuf_alloc_span(struct ZSpan *zspan, int rectx, int recty, float clipcrop);
-void zbufclipwire(struct ZSpan *zspan, int obi, int zvlnr, int ec,
- const float ho1[4], const float ho2[4], const float ho3[4], const float ho4[4],
- const int c1, const int c2, const int c3, const int c4);
-
-/* exported to shadeinput.c */
-void zbuf_make_winmat(Render *re, float winmat[4][4]);
-void zbuf_render_project(float winmat[4][4], const float co[3], float ho[4]);
-
-/* should not really be exposed, bad! */
-void hoco_to_zco(ZSpan *zspan, float zco[3], const float hoco[4]);
-void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, float *v3, void (*func)(void *, int, int, float, float, float) );
-void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, const float ho1[4], const float ho2[4]);
-
#endif
diff --git a/source/blender/render/intern/raytrace/bvh.h b/source/blender/render/intern/raytrace/bvh.h
deleted file mode 100644
index 25fdb41bb3a..00000000000
--- a/source/blender/render/intern/raytrace/bvh.h
+++ /dev/null
@@ -1,407 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/bvh.h
- * \ingroup render
- */
-
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-
-#include "raycounter.h"
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "rayobject_hint.h"
-#include "rayobject_rtbuild.h"
-
-#include <assert.h>
-
-#ifdef __SSE__
-#include <xmmintrin.h>
-#endif
-
-#ifndef __BVH_H__
-#define __BVH_H__
-
-#ifdef __SSE__
-inline int test_bb_group4(__m128 *bb_group, const Isect *isec)
-{
- const __m128 tmin0 = _mm_setzero_ps();
- const __m128 tmax0 = _mm_set_ps1(isec->dist);
-
- float start[3], idot_axis[3];
- copy_v3_v3(start, isec->start);
- copy_v3_v3(idot_axis, isec->idot_axis);
-
- const __m128 tmin1 = _mm_max_ps(tmin0, _mm_mul_ps(_mm_sub_ps(bb_group[isec->bv_index[0]], _mm_set_ps1(start[0]) ), _mm_set_ps1(idot_axis[0])) );
- const __m128 tmax1 = _mm_min_ps(tmax0, _mm_mul_ps(_mm_sub_ps(bb_group[isec->bv_index[1]], _mm_set_ps1(start[0]) ), _mm_set_ps1(idot_axis[0])) );
- const __m128 tmin2 = _mm_max_ps(tmin1, _mm_mul_ps(_mm_sub_ps(bb_group[isec->bv_index[2]], _mm_set_ps1(start[1]) ), _mm_set_ps1(idot_axis[1])) );
- const __m128 tmax2 = _mm_min_ps(tmax1, _mm_mul_ps(_mm_sub_ps(bb_group[isec->bv_index[3]], _mm_set_ps1(start[1]) ), _mm_set_ps1(idot_axis[1])) );
- const __m128 tmin3 = _mm_max_ps(tmin2, _mm_mul_ps(_mm_sub_ps(bb_group[isec->bv_index[4]], _mm_set_ps1(start[2]) ), _mm_set_ps1(idot_axis[2])) );
- const __m128 tmax3 = _mm_min_ps(tmax2, _mm_mul_ps(_mm_sub_ps(bb_group[isec->bv_index[5]], _mm_set_ps1(start[2]) ), _mm_set_ps1(idot_axis[2])) );
-
- return _mm_movemask_ps(_mm_cmpge_ps(tmax3, tmin3));
-}
-#endif
-
-/*
- * Determines the distance that the ray must travel to hit the bounding volume of the given node
- * Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe
- * [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9]
- */
-static inline int rayobject_bb_intersect_test(const Isect *isec, const float *_bb)
-{
- const float *bb = _bb;
-
- float t1x = (bb[isec->bv_index[0]] - isec->start[0]) * isec->idot_axis[0];
- float t2x = (bb[isec->bv_index[1]] - isec->start[0]) * isec->idot_axis[0];
- float t1y = (bb[isec->bv_index[2]] - isec->start[1]) * isec->idot_axis[1];
- float t2y = (bb[isec->bv_index[3]] - isec->start[1]) * isec->idot_axis[1];
- float t1z = (bb[isec->bv_index[4]] - isec->start[2]) * isec->idot_axis[2];
- float t2z = (bb[isec->bv_index[5]] - isec->start[2]) * isec->idot_axis[2];
-
- RE_RC_COUNT(isec->raycounter->bb.test);
-
- if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return 0;
- if (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return 0;
- if (t1x > isec->dist || t1y > isec->dist || t1z > isec->dist) return 0;
- RE_RC_COUNT(isec->raycounter->bb.hit);
-
- return 1;
-}
-
-/* bvh tree generics */
-template<class Tree> static void bvh_add(Tree *obj, RayObject *ob)
-{
- rtbuild_add(obj->builder, ob);
-}
-
-template<class Node>
-inline bool is_leaf(Node *node)
-{
- return !RE_rayobject_isAligned(node);
-}
-
-template<class Tree> static void bvh_done(Tree *obj);
-
-template<class Tree>
-static void bvh_free(Tree *obj)
-{
- if (obj->builder)
- rtbuild_free(obj->builder);
-
- if (obj->node_arena)
- BLI_memarena_free(obj->node_arena);
-
- MEM_freeN(obj);
-}
-
-template<class Tree>
-static void bvh_bb(Tree *obj, float *min, float *max)
-{
- if (obj->root)
- bvh_node_merge_bb(obj->root, min, max);
-}
-
-
-template<class Tree>
-static float bvh_cost(Tree *obj)
-{
- assert(obj->cost >= 0.0f);
- return obj->cost;
-}
-
-
-
-/* bvh tree nodes generics */
-template<class Node> static inline int bvh_node_hit_test(Node *node, Isect *isec)
-{
- return rayobject_bb_intersect_test(isec, (const float *)node->bb);
-}
-
-
-template<class Node>
-static inline void bvh_node_merge_bb(Node *node, float min[3], float max[3])
-{
- if (is_leaf(node)) {
- RE_rayobject_merge_bb((RayObject *)node, min, max);
- }
- else {
- DO_MIN(node->bb, min);
- DO_MAX(node->bb + 3, max);
- }
-}
-
-
-
-/*
- * recursively transverse a BVH looking for a rayhit using a local stack
- */
-template<class Node> static inline void bvh_node_push_childs(Node *node, Isect *isec, Node **stack, int &stack_pos);
-
-template<class Node, int MAX_STACK_SIZE, bool TEST_ROOT, bool SHADOW>
-static int bvh_node_stack_raycast(Node *root, Isect *isec)
-{
- Node *stack[MAX_STACK_SIZE];
- int hit = 0, stack_pos = 0;
-
- if (!TEST_ROOT && !is_leaf(root))
- bvh_node_push_childs(root, isec, stack, stack_pos);
- else
- stack[stack_pos++] = root;
-
- while (stack_pos) {
- Node *node = stack[--stack_pos];
- if (!is_leaf(node)) {
- if (bvh_node_hit_test(node, isec)) {
- bvh_node_push_childs(node, isec, stack, stack_pos);
- assert(stack_pos <= MAX_STACK_SIZE);
- }
- }
- else {
- hit |= RE_rayobject_intersect( (RayObject *)node, isec);
- if (SHADOW && hit) return hit;
- }
- }
- return hit;
-}
-
-
-#ifdef __SSE__
-/*
- * Generic SIMD bvh recursion
- * this was created to be able to use any simd (with the cost of some memmoves)
- * it can take advantage of any SIMD width and doens't needs any special tree care
- */
-template<class Node, int MAX_STACK_SIZE, bool TEST_ROOT>
-static int bvh_node_stack_raycast_simd(Node *root, Isect *isec)
-{
- Node *stack[MAX_STACK_SIZE];
-
- int hit = 0, stack_pos = 0;
-
- if (!TEST_ROOT) {
- if (!is_leaf(root)) {
- if (!is_leaf(root->child))
- bvh_node_push_childs(root, isec, stack, stack_pos);
- else
- return RE_rayobject_intersect( (RayObject *)root->child, isec);
- }
- else
- return RE_rayobject_intersect( (RayObject *)root, isec);
- }
- else {
- if (!is_leaf(root))
- stack[stack_pos++] = root;
- else
- return RE_rayobject_intersect( (RayObject *)root, isec);
- }
-
- while (true) {
- //Use SIMD 4
- if (stack_pos >= 4) {
- __m128 t_bb[6];
- Node *t_node[4];
-
- stack_pos -= 4;
-
- /* prepare the 4BB for SIMD */
- t_node[0] = stack[stack_pos + 0]->child;
- t_node[1] = stack[stack_pos + 1]->child;
- t_node[2] = stack[stack_pos + 2]->child;
- t_node[3] = stack[stack_pos + 3]->child;
-
- const float *bb0 = stack[stack_pos + 0]->bb;
- const float *bb1 = stack[stack_pos + 1]->bb;
- const float *bb2 = stack[stack_pos + 2]->bb;
- const float *bb3 = stack[stack_pos + 3]->bb;
-
- const __m128 x0y0x1y1 = _mm_shuffle_ps(_mm_load_ps(bb0), _mm_load_ps(bb1), _MM_SHUFFLE(1, 0, 1, 0) );
- const __m128 x2y2x3y3 = _mm_shuffle_ps(_mm_load_ps(bb2), _mm_load_ps(bb3), _MM_SHUFFLE(1, 0, 1, 0) );
- t_bb[0] = _mm_shuffle_ps(x0y0x1y1, x2y2x3y3, _MM_SHUFFLE(2, 0, 2, 0) );
- t_bb[1] = _mm_shuffle_ps(x0y0x1y1, x2y2x3y3, _MM_SHUFFLE(3, 1, 3, 1) );
-
- const __m128 z0X0z1X1 = _mm_shuffle_ps(_mm_load_ps(bb0), _mm_load_ps(bb1), _MM_SHUFFLE(3, 2, 3, 2) );
- const __m128 z2X2z3X3 = _mm_shuffle_ps(_mm_load_ps(bb2), _mm_load_ps(bb3), _MM_SHUFFLE(3, 2, 3, 2) );
- t_bb[2] = _mm_shuffle_ps(z0X0z1X1, z2X2z3X3, _MM_SHUFFLE(2, 0, 2, 0) );
- t_bb[3] = _mm_shuffle_ps(z0X0z1X1, z2X2z3X3, _MM_SHUFFLE(3, 1, 3, 1) );
-
- const __m128 Y0Z0Y1Z1 = _mm_shuffle_ps(_mm_load_ps(bb0 + 4), _mm_load_ps(bb1 + 4), _MM_SHUFFLE(1, 0, 1, 0) );
- const __m128 Y2Z2Y3Z3 = _mm_shuffle_ps(_mm_load_ps(bb2 + 4), _mm_load_ps(bb3 + 4), _MM_SHUFFLE(1, 0, 1, 0) );
- t_bb[4] = _mm_shuffle_ps(Y0Z0Y1Z1, Y2Z2Y3Z3, _MM_SHUFFLE(2, 0, 2, 0) );
- t_bb[5] = _mm_shuffle_ps(Y0Z0Y1Z1, Y2Z2Y3Z3, _MM_SHUFFLE(3, 1, 3, 1) );
-#if 0
- for (int i = 0; i < 4; i++)
- {
- Node *t = stack[stack_pos + i];
- assert(!is_leaf(t));
-
- float *bb = ((float *)t_bb) + i;
- bb[4 * 0] = t->bb[0];
- bb[4 * 1] = t->bb[1];
- bb[4 * 2] = t->bb[2];
- bb[4 * 3] = t->bb[3];
- bb[4 * 4] = t->bb[4];
- bb[4 * 5] = t->bb[5];
- t_node[i] = t->child;
- }
-#endif
- RE_RC_COUNT(isec->raycounter->simd_bb.test);
- int res = test_bb_group4(t_bb, isec);
-
- for (int i = 0; i < 4; i++)
- if (res & (1 << i)) {
- RE_RC_COUNT(isec->raycounter->simd_bb.hit);
- if (!is_leaf(t_node[i])) {
- for (Node *t = t_node[i]; t; t = t->sibling) {
- assert(stack_pos < MAX_STACK_SIZE);
- stack[stack_pos++] = t;
- }
- }
- else {
- hit |= RE_rayobject_intersect( (RayObject *)t_node[i], isec);
- if (hit && isec->mode == RE_RAY_SHADOW) return hit;
- }
- }
- }
- else if (stack_pos > 0) {
- Node *node = stack[--stack_pos];
- assert(!is_leaf(node));
-
- if (bvh_node_hit_test(node, isec)) {
- if (!is_leaf(node->child)) {
- bvh_node_push_childs(node, isec, stack, stack_pos);
- assert(stack_pos <= MAX_STACK_SIZE);
- }
- else {
- hit |= RE_rayobject_intersect( (RayObject *)node->child, isec);
- if (hit && isec->mode == RE_RAY_SHADOW) return hit;
- }
- }
- }
- else break;
- }
- return hit;
-}
-#endif
-
-/*
- * recursively transverse a BVH looking for a rayhit using system stack
- */
-#if 0
-template<class Node>
-static int bvh_node_raycast(Node *node, Isect *isec)
-{
- int hit = 0;
- if (bvh_test_node(node, isec))
- {
- if (isec->idot_axis[node->split_axis] > 0.0f)
- {
- int i;
- for (i = 0; i < BVH_NCHILDS; i++)
- if (!is_leaf(node->child[i]))
- {
- if (node->child[i] == 0) break;
-
- hit |= bvh_node_raycast(node->child[i], isec);
- if (hit && isec->mode == RE_RAY_SHADOW) return hit;
- }
- else {
- hit |= RE_rayobject_intersect( (RayObject *)node->child[i], isec);
- if (hit && isec->mode == RE_RAY_SHADOW) return hit;
- }
- }
- else {
- int i;
- for (i = BVH_NCHILDS - 1; i >= 0; i--)
- if (!is_leaf(node->child[i]))
- {
- if (node->child[i])
- {
- hit |= dfs_raycast(node->child[i], isec);
- if (hit && isec->mode == RE_RAY_SHADOW) return hit;
- }
- }
- else {
- hit |= RE_rayobject_intersect( (RayObject *)node->child[i], isec);
- if (hit && isec->mode == RE_RAY_SHADOW) return hit;
- }
- }
- }
- return hit;
-}
-#endif
-
-template<class Node, class HintObject>
-static void bvh_dfs_make_hint(Node *node, LCTSHint *hint, int reserve_space, HintObject *hintObject)
-{
- assert(hint->size + reserve_space + 1 <= RE_RAY_LCTS_MAX_SIZE);
-
- if (is_leaf(node)) {
- hint->stack[hint->size++] = (RayObject *)node;
- }
- else {
- int childs = count_childs(node);
- if (hint->size + reserve_space + childs <= RE_RAY_LCTS_MAX_SIZE) {
- int result = hint_test_bb(hintObject, node->bb, node->bb + 3);
- if (result == HINT_RECURSE) {
- /* We are 100% sure the ray will be pass inside this node */
- bvh_dfs_make_hint_push_siblings(node->child, hint, reserve_space, hintObject);
- }
- else if (result == HINT_ACCEPT) {
- hint->stack[hint->size++] = (RayObject *)node;
- }
- }
- else {
- hint->stack[hint->size++] = (RayObject *)node;
- }
- }
-}
-
-
-template<class Tree>
-static RayObjectAPI *bvh_get_api(int maxstacksize);
-
-
-template<class Tree, int DFS_STACK_SIZE>
-static inline RayObject *bvh_create_tree(int size)
-{
- Tree *obj = (Tree *)MEM_callocN(sizeof(Tree), "BVHTree");
- assert(RE_rayobject_isAligned(obj)); /* RayObject API assumes real data to be 4-byte aligned */
-
- obj->rayobj.api = bvh_get_api<Tree>(DFS_STACK_SIZE);
- obj->root = NULL;
-
- obj->node_arena = NULL;
- obj->builder = rtbuild_create(size);
-
- return RE_rayobject_unalignRayAPI((RayObject *) obj);
-}
-
-#endif
diff --git a/source/blender/render/intern/raytrace/rayobject.cpp b/source/blender/render/intern/raytrace/rayobject.cpp
deleted file mode 100644
index c16ef5500df..00000000000
--- a/source/blender/render/intern/raytrace/rayobject.cpp
+++ /dev/null
@@ -1,534 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject.cpp
- * \ingroup render
- */
-
-
-#include <assert.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "DNA_material_types.h"
-
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "raycounter.h"
-#include "render_types.h"
-#include "renderdatabase.h"
-
-/* RayFace
- *
- * note we force always inline here, because compiler refuses to otherwise
- * because function is too long. Since this is code that is called billions
- * of times we really do want to inline. */
-
-MALWAYS_INLINE RayObject *rayface_from_coords(RayFace *rayface, void *ob, void *face,
- float *v1, float *v2, float *v3, float *v4)
-{
- rayface->ob = ob;
- rayface->face = face;
-
- copy_v3_v3(rayface->v1, v1);
- copy_v3_v3(rayface->v2, v2);
- copy_v3_v3(rayface->v3, v3);
-
- if (v4) {
- copy_v3_v3(rayface->v4, v4);
- rayface->quad = 1;
- }
- else {
- rayface->quad = 0;
- }
-
- return RE_rayobject_unalignRayFace(rayface);
-}
-
-MALWAYS_INLINE void rayface_from_vlak(RayFace *rayface, ObjectInstanceRen *obi, VlakRen *vlr)
-{
- rayface_from_coords(rayface, obi, vlr, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4 ? vlr->v4->co : NULL);
-
- if (obi->transform_primitives) {
- mul_m4_v3(obi->mat, rayface->v1);
- mul_m4_v3(obi->mat, rayface->v2);
- mul_m4_v3(obi->mat, rayface->v3);
-
- if (RE_rayface_isQuad(rayface))
- mul_m4_v3(obi->mat, rayface->v4);
- }
-}
-
-RayObject *RE_rayface_from_vlak(RayFace *rayface, ObjectInstanceRen *obi, VlakRen *vlr)
-{
- return rayface_from_coords(rayface, obi, vlr, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4 ? vlr->v4->co : NULL);
-}
-
-RayObject *RE_rayface_from_coords(RayFace *rayface, void *ob, void *face, float *v1, float *v2, float *v3, float *v4)
-{
- return rayface_from_coords(rayface, ob, face, v1, v2, v3, v4);
-}
-
-/* VlakPrimitive */
-
-RayObject *RE_vlakprimitive_from_vlak(VlakPrimitive *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr)
-{
- face->ob = obi;
- face->face = vlr;
-
- return RE_rayobject_unalignVlakPrimitive(face);
-}
-
-/* Checks for ignoring faces or materials */
-
-MALWAYS_INLINE int vlr_check_intersect(Isect *is, ObjectInstanceRen *obi, VlakRen *vlr)
-{
- /* for baking selected to active non-traceable materials might still
- * be in the raytree */
- if (!(vlr->flag & R_TRACEBLE))
- return 0;
-
- /* I know... cpu cycle waste, might do smarter once */
- if (is->mode == RE_RAY_MIRROR)
- return !(vlr->mat->mode & MA_ONLYCAST);
- else
- return (vlr->mat->mode2 & MA_CASTSHADOW) && (is->lay & obi->lay);
-}
-
-MALWAYS_INLINE int vlr_check_intersect_solid(Isect *UNUSED(is), ObjectInstanceRen *UNUSED(obi), VlakRen *vlr)
-{
- /* solid material types only */
- if (vlr->mat->material_type == MA_TYPE_SURFACE)
- return 1;
- else
- return 0;
-}
-
-MALWAYS_INLINE int vlr_check_bake(Isect *is, ObjectInstanceRen *obi, VlakRen *UNUSED(vlr))
-{
- return (obi->obr->ob != is->userdata) && (obi->obr->ob->flag & SELECT);
-}
-
-/* Ray Triangle/Quad Intersection */
-
-static bool isect_ray_tri_watertight_no_sign_check_v3(
- const float ray_origin[3], const struct IsectRayPrecalc *isect_precalc,
- const float v0[3], const float v1[3], const float v2[3],
- float *r_lambda, float r_uv[2])
-{
- const int kx = isect_precalc->kx;
- const int ky = isect_precalc->ky;
- const int kz = isect_precalc->kz;
- const float sx = isect_precalc->sx;
- const float sy = isect_precalc->sy;
- const float sz = isect_precalc->sz;
-
- /* Calculate vertices relative to ray origin. */
- const float a[3] = {v0[0] - ray_origin[0], v0[1] - ray_origin[1], v0[2] - ray_origin[2]};
- const float b[3] = {v1[0] - ray_origin[0], v1[1] - ray_origin[1], v1[2] - ray_origin[2]};
- const float c[3] = {v2[0] - ray_origin[0], v2[1] - ray_origin[1], v2[2] - ray_origin[2]};
-
- const float a_kx = a[kx], a_ky = a[ky], a_kz = a[kz];
- const float b_kx = b[kx], b_ky = b[ky], b_kz = b[kz];
- const float c_kx = c[kx], c_ky = c[ky], c_kz = c[kz];
-
- /* Perform shear and scale of vertices. */
- const float ax = a_kx - sx * a_kz;
- const float ay = a_ky - sy * a_kz;
- const float bx = b_kx - sx * b_kz;
- const float by = b_ky - sy * b_kz;
- const float cx = c_kx - sx * c_kz;
- const float cy = c_ky - sy * c_kz;
-
- /* Calculate scaled barycentric coordinates. */
- const float u = cx * by - cy * bx;
- const float v = ax * cy - ay * cx;
- const float w = bx * ay - by * ax;
- float det;
-
- if ((u < 0.0f || v < 0.0f || w < 0.0f) &&
- (u > 0.0f || v > 0.0f || w > 0.0f))
- {
- return false;
- }
-
- /* Calculate determinant. */
- det = u + v + w;
- if (UNLIKELY(det == 0.0f)) {
- return false;
- }
- else {
- /* Calculate scaled z-coordinates of vertices and use them to calculate
- * the hit distance.
- */
- const float t = (u * a_kz + v * b_kz + w * c_kz) * sz;
- /* Normalize u, v and t. */
- const float inv_det = 1.0f / det;
- if (r_uv) {
- r_uv[0] = u * inv_det;
- r_uv[1] = v * inv_det;
- }
- *r_lambda = t * inv_det;
- return true;
- }
-}
-
-MALWAYS_INLINE int isec_tri_quad(const float start[3],
- const struct IsectRayPrecalc *isect_precalc,
- const RayFace *face,
- float r_uv[2], float *r_lambda)
-{
- float uv[2], l;
-
- if (isect_ray_tri_watertight_v3(start, isect_precalc, face->v1, face->v2, face->v3, &l, uv)) {
- /* check if intersection is within ray length */
- if (l > -RE_RAYTRACE_EPSILON && l < *r_lambda) {
- r_uv[0] = -uv[0];
- r_uv[1] = -uv[1];
- *r_lambda = l;
- return 1;
- }
- }
-
- /* intersect second triangle in quad */
- if (RE_rayface_isQuad(face)) {
- if (isect_ray_tri_watertight_v3(start, isect_precalc, face->v1, face->v3, face->v4, &l, uv)) {
- /* check if intersection is within ray length */
- if (l > -RE_RAYTRACE_EPSILON && l < *r_lambda) {
- r_uv[0] = -uv[0];
- r_uv[1] = -uv[1];
- *r_lambda = l;
- return 2;
- }
- }
- }
-
- return 0;
-}
-
-/* Simpler yes/no Ray Triangle/Quad Intersection */
-
-MALWAYS_INLINE int isec_tri_quad_neighbour(const float start[3],
- const float dir[3],
- const RayFace *face)
-{
- float r[3];
- struct IsectRayPrecalc isect_precalc;
- float uv[2], l;
-
- negate_v3_v3(r, dir); /* note, different than above function */
-
- isect_ray_tri_watertight_v3_precalc(&isect_precalc, r);
-
- if (isect_ray_tri_watertight_no_sign_check_v3(start, &isect_precalc, face->v1, face->v2, face->v3, &l, uv)) {
- return 1;
- }
-
- /* intersect second triangle in quad */
- if (RE_rayface_isQuad(face)) {
- if (isect_ray_tri_watertight_no_sign_check_v3(start, &isect_precalc, face->v1, face->v3, face->v4, &l, uv)) {
- return 2;
- }
- }
-
- return 0;
-}
-
-/* RayFace intersection with checks and neighbor verifaction included,
- * Isect is modified if the face is hit. */
-
-MALWAYS_INLINE int intersect_rayface(RayObject *hit_obj, RayFace *face, Isect *is)
-{
- float dist, uv[2];
- int ok = 0;
-
- /* avoid self-intersection */
- if (is->orig.ob == face->ob && is->orig.face == face->face)
- return 0;
-
- /* check if we should intersect this face */
- if (is->check == RE_CHECK_VLR_RENDER) {
- if (vlr_check_intersect(is, (ObjectInstanceRen *)face->ob, (VlakRen *)face->face) == 0)
- return 0;
- }
- else if (is->check == RE_CHECK_VLR_NON_SOLID_MATERIAL) {
- if (vlr_check_intersect(is, (ObjectInstanceRen *)face->ob, (VlakRen *)face->face) == 0)
- return 0;
- if (vlr_check_intersect_solid(is, (ObjectInstanceRen *)face->ob, (VlakRen *)face->face) == 0)
- return 0;
- }
- else if (is->check == RE_CHECK_VLR_BAKE) {
- if (vlr_check_bake(is, (ObjectInstanceRen *)face->ob, (VlakRen *)face->face) == 0)
- return 0;
- }
-
- /* ray counter */
- RE_RC_COUNT(is->raycounter->faces.test);
-
- dist = is->dist;
- ok = isec_tri_quad(is->start, &is->isect_precalc, face, uv, &dist);
-
- if (ok) {
-
- /* when a shadow ray leaves a face, it can be little outside the edges
- * of it, causing intersection to be detected in its neighbor face */
- if (is->skip & RE_SKIP_VLR_NEIGHBOUR) {
- if (dist < 0.1f && is->orig.ob == face->ob) {
- VlakRen *a = (VlakRen *)is->orig.face;
- VlakRen *b = (VlakRen *)face->face;
- ObjectRen *obr = ((ObjectInstanceRen *)face->ob)->obr;
-
- VertRen **va, **vb;
- int *org_idx_a, *org_idx_b;
- int i, j;
- bool is_neighbor = false;
-
- /* "same" vertex means either the actual same VertRen, or the same 'final org index', if available
- * (autosmooth only, currently). */
- for (i = 0, va = &a->v1; !is_neighbor && i < 4 && *va; ++i, ++va) {
- org_idx_a = RE_vertren_get_origindex(obr, *va, false);
- for (j = 0, vb = &b->v1; !is_neighbor && j < 4 && *vb; ++j, ++vb) {
- if (*va == *vb) {
- is_neighbor = true;
- }
- else if (org_idx_a) {
- org_idx_b = RE_vertren_get_origindex(obr, *vb, 0);
- if (org_idx_b && *org_idx_a == *org_idx_b) {
- is_neighbor = true;
- }
- }
- }
- }
-
- /* So there's a shared edge or vertex, let's intersect ray with self, if that's true
- * we can safely return 1, otherwise we assume the intersection is invalid, 0 */
- if (is_neighbor) {
- /* create RayFace from original face, transformed if necessary */
- RayFace origface;
- ObjectInstanceRen *ob = (ObjectInstanceRen *)is->orig.ob;
- rayface_from_vlak(&origface, ob, (VlakRen *)is->orig.face);
-
- if (!isec_tri_quad_neighbour(is->start, is->dir, &origface)) {
- return 0;
- }
- }
- }
- }
-
- RE_RC_COUNT(is->raycounter->faces.hit);
-
- is->isect = ok; // which half of the quad
- is->dist = dist;
- is->u = uv[0]; is->v = uv[1];
-
- is->hit.ob = face->ob;
- is->hit.face = face->face;
-#ifdef RT_USE_LAST_HIT
- is->last_hit = hit_obj;
-#endif
- return 1;
- }
-
- return 0;
-}
-
-/* Intersection */
-
-int RE_rayobject_raycast(RayObject *r, Isect *isec)
-{
- int i;
-
- /* Pre-calculate orientation for watertight intersection checks. */
- isect_ray_tri_watertight_v3_precalc(&isec->isect_precalc, isec->dir);
-
- RE_RC_COUNT(isec->raycounter->raycast.test);
-
- /* setup vars used on raycast */
- for (i = 0; i < 3; i++) {
- isec->idot_axis[i] = 1.0f / isec->dir[i];
-
- isec->bv_index[2 * i] = isec->idot_axis[i] < 0.0f ? 1 : 0;
- isec->bv_index[2 * i + 1] = 1 - isec->bv_index[2 * i];
-
- isec->bv_index[2 * i] = i + 3 * isec->bv_index[2 * i];
- isec->bv_index[2 * i + 1] = i + 3 * isec->bv_index[2 * i + 1];
- }
-
-#ifdef RT_USE_LAST_HIT
- /* last hit heuristic */
- if (isec->mode == RE_RAY_SHADOW && isec->last_hit) {
- RE_RC_COUNT(isec->raycounter->rayshadow_last_hit.test);
-
- if (RE_rayobject_intersect(isec->last_hit, isec)) {
- RE_RC_COUNT(isec->raycounter->raycast.hit);
- RE_RC_COUNT(isec->raycounter->rayshadow_last_hit.hit);
- return 1;
- }
- }
-#endif
-
-#ifdef RT_USE_HINT
- isec->hit_hint = 0;
-#endif
-
- if (RE_rayobject_intersect(r, isec)) {
- RE_RC_COUNT(isec->raycounter->raycast.hit);
-
-#ifdef RT_USE_HINT
- isec->hint = isec->hit_hint;
-#endif
- return 1;
- }
-
- return 0;
-}
-
-int RE_rayobject_intersect(RayObject *r, Isect *i)
-{
- if (RE_rayobject_isRayFace(r)) {
- return intersect_rayface(r, (RayFace *) RE_rayobject_align(r), i);
- }
- else if (RE_rayobject_isVlakPrimitive(r)) {
- //TODO optimize (useless copy to RayFace to avoid duplicate code)
- VlakPrimitive *face = (VlakPrimitive *) RE_rayobject_align(r);
- RayFace nface;
- rayface_from_vlak(&nface, face->ob, face->face);
-
- return intersect_rayface(r, &nface, i);
- }
- else if (RE_rayobject_isRayAPI(r)) {
- r = RE_rayobject_align(r);
- return r->api->raycast(r, i);
- }
- else {
- assert(0);
- return 0;
- }
-}
-
-/* Building */
-
-void RE_rayobject_add(RayObject *r, RayObject *o)
-{
- r = RE_rayobject_align(r);
- return r->api->add(r, o);
-}
-
-void RE_rayobject_done(RayObject *r)
-{
- r = RE_rayobject_align(r);
- r->api->done(r);
-}
-
-void RE_rayobject_free(RayObject *r)
-{
- r = RE_rayobject_align(r);
- r->api->free(r);
-}
-
-float RE_rayobject_cost(RayObject *r)
-{
- if (RE_rayobject_isRayFace(r) || RE_rayobject_isVlakPrimitive(r)) {
- return 1.0f;
- }
- else if (RE_rayobject_isRayAPI(r)) {
- r = RE_rayobject_align(r);
- return r->api->cost(r);
- }
- else {
- assert(0);
- return 1.0f;
- }
-}
-
-/* Bounding Boxes */
-
-void RE_rayobject_merge_bb(RayObject *r, float min[3], float max[3])
-{
- if (RE_rayobject_isRayFace(r)) {
- RayFace *face = (RayFace *) RE_rayobject_align(r);
-
- DO_MINMAX(face->v1, min, max);
- DO_MINMAX(face->v2, min, max);
- DO_MINMAX(face->v3, min, max);
- if (RE_rayface_isQuad(face)) DO_MINMAX(face->v4, min, max);
- }
- else if (RE_rayobject_isVlakPrimitive(r)) {
- VlakPrimitive *face = (VlakPrimitive *) RE_rayobject_align(r);
- RayFace nface;
- rayface_from_vlak(&nface, face->ob, face->face);
-
- DO_MINMAX(nface.v1, min, max);
- DO_MINMAX(nface.v2, min, max);
- DO_MINMAX(nface.v3, min, max);
- if (RE_rayface_isQuad(&nface)) DO_MINMAX(nface.v4, min, max);
- }
- else if (RE_rayobject_isRayAPI(r)) {
- r = RE_rayobject_align(r);
- r->api->bb(r, min, max);
- }
- else
- assert(0);
-}
-
-/* Hints */
-
-void RE_rayobject_hint_bb(RayObject *r, RayHint *hint, float *min, float *max)
-{
- if (RE_rayobject_isRayFace(r) || RE_rayobject_isVlakPrimitive(r)) {
- return;
- }
- else if (RE_rayobject_isRayAPI(r)) {
- r = RE_rayobject_align(r);
- return r->api->hint_bb(r, hint, min, max);
- }
- else
- assert(0);
-}
-
-/* RayObjectControl */
-
-int RE_rayobjectcontrol_test_break(RayObjectControl *control)
-{
- if (control->test_break)
- return control->test_break(control->data);
-
- return 0;
-}
-
-void RE_rayobject_set_control(RayObject *r, void *data, RE_rayobjectcontrol_test_break_callback test_break)
-{
- if (RE_rayobject_isRayAPI(r)) {
- r = RE_rayobject_align(r);
- r->control.data = data;
- r->control.test_break = test_break;
- }
-}
-
diff --git a/source/blender/render/intern/raytrace/rayobject_empty.cpp b/source/blender/render/intern/raytrace/rayobject_empty.cpp
deleted file mode 100644
index eacec0b7eb9..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_empty.cpp
+++ /dev/null
@@ -1,81 +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) 1990-1998 NeoGeo BV.
- * All rights reserved.
- *
- * Contributors: 2004/2005 Blender Foundation, full recode
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_empty.cpp
- * \ingroup render
- */
-
-
-#include "MEM_guardedalloc.h"
-
-#include "rayobject.h"
-
-#include "BLI_utildefines.h"
-
-/*
- * Empty raytree
- */
-
-static int RE_rayobject_empty_intersect(RayObject *UNUSED(o), Isect *UNUSED(is))
-{
- return 0;
-}
-
-static void RE_rayobject_empty_free(RayObject *UNUSED(o))
-{
-}
-
-static void RE_rayobject_empty_bb(RayObject *UNUSED(o), float *UNUSED(min), float *UNUSED(max))
-{
- return;
-}
-
-static float RE_rayobject_empty_cost(RayObject *UNUSED(o))
-{
- return 0.0;
-}
-
-static void RE_rayobject_empty_hint_bb(RayObject *UNUSED(o), RayHint *UNUSED(hint),
- float *UNUSED(min), float *UNUSED(max))
-{}
-
-static RayObjectAPI empty_api =
-{
- RE_rayobject_empty_intersect,
- NULL, //static void RE_rayobject_instance_add(RayObject *o, RayObject *ob);
- NULL, //static void RE_rayobject_instance_done(RayObject *o);
- RE_rayobject_empty_free,
- RE_rayobject_empty_bb,
- RE_rayobject_empty_cost,
- RE_rayobject_empty_hint_bb
-};
-
-static RayObject empty_raytree = { &empty_api, {NULL, NULL} };
-
-RayObject *RE_rayobject_empty_create()
-{
- return RE_rayobject_unalignRayAPI( &empty_raytree );
-}
-
diff --git a/source/blender/render/intern/raytrace/rayobject_hint.h b/source/blender/render/intern/raytrace/rayobject_hint.h
deleted file mode 100644
index 6eb3c035935..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_hint.h
+++ /dev/null
@@ -1,72 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_hint.h
- * \ingroup render
- */
-
-
-#ifndef __RAYOBJECT_HINT_H__
-#define __RAYOBJECT_HINT_H__
-
-#define HINT_RECURSE 1
-#define HINT_ACCEPT 0
-#define HINT_DISCARD -1
-
-struct HintBB {
- float bb[6];
-};
-
-inline int hint_test_bb(HintBB *obj, float *Nmin, float *Nmax)
-{
- if (bb_fits_inside(Nmin, Nmax, obj->bb, obj->bb + 3) )
- return HINT_RECURSE;
- else
- return HINT_ACCEPT;
-}
-#if 0
-struct HintFrustum {
- float co[3];
- float no[4][3];
-};
-
-inline int hint_test_bb(HintFrustum &obj, float *Nmin, float *Nmax)
-{
- //if frustum inside BB
- {
- return HINT_RECURSE;
- }
- //if BB outside frustum
- {
- return HINT_DISCARD;
- }
-
- return HINT_ACCEPT;
-}
-#endif
-
-#endif /* __RAYOBJECT_HINT_H__ */
diff --git a/source/blender/render/intern/raytrace/rayobject_instance.cpp b/source/blender/render/intern/raytrace/rayobject_instance.cpp
deleted file mode 100644
index 349f0fc6844..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_instance.cpp
+++ /dev/null
@@ -1,211 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_instance.cpp
- * \ingroup render
- */
-
-
-#include <assert.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "rayintersection.h"
-#include "rayobject.h"
-
-#define RE_COST_INSTANCE (1.0f)
-
-static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec);
-static void RE_rayobject_instance_free(RayObject *o);
-static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max);
-static float RE_rayobject_instance_cost(RayObject *o);
-
-static void RE_rayobject_instance_hint_bb(RayObject *UNUSED(o), RayHint *UNUSED(hint),
- float *UNUSED(min), float *UNUSED(max))
-{}
-
-static RayObjectAPI instance_api =
-{
- RE_rayobject_instance_intersect,
- NULL, //static void RE_rayobject_instance_add(RayObject *o, RayObject *ob);
- NULL, //static void RE_rayobject_instance_done(RayObject *o);
- RE_rayobject_instance_free,
- RE_rayobject_instance_bb,
- RE_rayobject_instance_cost,
- RE_rayobject_instance_hint_bb
-};
-
-typedef struct InstanceRayObject {
- RayObject rayobj;
- RayObject *target;
-
- void *ob; //Object represented by this instance
- void *target_ob; //Object represented by the inner RayObject, needed to handle self-intersection
-
- float global2target[4][4];
- float target2global[4][4];
-
-} InstanceRayObject;
-
-
-RayObject *RE_rayobject_instance_create(RayObject *target, float transform[4][4], void *ob, void *target_ob)
-{
- InstanceRayObject *obj = (InstanceRayObject *)MEM_callocN(sizeof(InstanceRayObject), "InstanceRayObject");
- assert(RE_rayobject_isAligned(obj) ); /* RayObject API assumes real data to be 4-byte aligned */
-
- obj->rayobj.api = &instance_api;
- obj->target = target;
- obj->ob = ob;
- obj->target_ob = target_ob;
-
- copy_m4_m4(obj->target2global, transform);
- invert_m4_m4(obj->global2target, obj->target2global);
-
- return RE_rayobject_unalignRayAPI((RayObject *) obj);
-}
-
-static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec)
-{
- InstanceRayObject *obj = (InstanceRayObject *)o;
- float start[3], dir[3], idot_axis[3], dist;
- int changed = 0, i, res;
-
- // TODO - this is disabling self intersection on instances
- if (isec->orig.ob == obj->ob && obj->ob) {
- changed = 1;
- isec->orig.ob = obj->target_ob;
- }
-
- // backup old values
- copy_v3_v3(start, isec->start);
- copy_v3_v3(dir, isec->dir);
- copy_v3_v3(idot_axis, isec->idot_axis);
- dist = isec->dist;
-
- // transform to target coordinates system
- mul_m4_v3(obj->global2target, isec->start);
- mul_mat3_m4_v3(obj->global2target, isec->dir);
- isec->dist *= normalize_v3(isec->dir);
-
- // update idot_axis and bv_index
- for (i = 0; i < 3; i++) {
- isec->idot_axis[i] = 1.0f / isec->dir[i];
-
- isec->bv_index[2 * i] = isec->idot_axis[i] < 0.0f ? 1 : 0;
- isec->bv_index[2 * i + 1] = 1 - isec->bv_index[2 * i];
-
- isec->bv_index[2 * i] = i + 3 * isec->bv_index[2 * i];
- isec->bv_index[2 * i + 1] = i + 3 * isec->bv_index[2 * i + 1];
- }
-
- // Pre-calculate orientation for watertight intersection checks.
- isect_ray_tri_watertight_v3_precalc(&isec->isect_precalc, isec->dir);
-
- // raycast
- res = RE_rayobject_intersect(obj->target, isec);
-
- // map dist into original coordinate space
- if (res == 0) {
- isec->dist = dist;
- }
- else {
- // note we don't just multiply dist, because of possible
- // non-uniform scaling in the transform matrix
- float vec[3];
-
- mul_v3_v3fl(vec, isec->dir, isec->dist);
- mul_mat3_m4_v3(obj->target2global, vec);
-
- isec->dist = len_v3(vec);
- isec->hit.ob = obj->ob;
-
-#ifdef RT_USE_LAST_HIT
- // TODO support for last hit optimization in instances that can jump
- // directly to the last hit face.
- // For now it jumps directly to the last-hit instance root node.
- isec->last_hit = RE_rayobject_unalignRayAPI((RayObject *) obj);
-#endif
- }
-
- // restore values
- copy_v3_v3(isec->start, start);
- copy_v3_v3(isec->dir, dir);
- copy_v3_v3(isec->idot_axis, idot_axis);
-
- if (changed)
- isec->orig.ob = obj->ob;
-
- // restore bv_index
- for (i = 0; i < 3; i++) {
- isec->bv_index[2 * i] = isec->idot_axis[i] < 0.0f ? 1 : 0;
- isec->bv_index[2 * i + 1] = 1 - isec->bv_index[2 * i];
-
- isec->bv_index[2 * i] = i + 3 * isec->bv_index[2 * i];
- isec->bv_index[2 * i + 1] = i + 3 * isec->bv_index[2 * i + 1];
- }
-
- // Pre-calculate orientation for watertight intersection checks.
- isect_ray_tri_watertight_v3_precalc(&isec->isect_precalc, isec->dir);
-
- return res;
-}
-
-static void RE_rayobject_instance_free(RayObject *o)
-{
- InstanceRayObject *obj = (InstanceRayObject *)o;
- MEM_freeN(obj);
-}
-
-static float RE_rayobject_instance_cost(RayObject *o)
-{
- InstanceRayObject *obj = (InstanceRayObject *)o;
- return RE_rayobject_cost(obj->target) + RE_COST_INSTANCE;
-}
-
-static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max)
-{
- //TODO:
- // *better bb.. calculated without rotations of bb
- // *maybe cache that better-fitted-BB at the InstanceRayObject
- InstanceRayObject *obj = (InstanceRayObject *)o;
-
- float m[3], M[3], t[3];
- int i, j;
- INIT_MINMAX(m, M);
- RE_rayobject_merge_bb(obj->target, m, M);
-
- //There must be a faster way than rotating all the 8 vertexs of the BB
- for (i = 0; i < 8; i++) {
- for (j = 0; j < 3; j++) t[j] = (i & (1 << j)) ? M[j] : m[j];
- mul_m4_v3(obj->target2global, t);
- DO_MINMAX(t, min, max);
- }
-}
-
diff --git a/source/blender/render/intern/raytrace/rayobject_internal.h b/source/blender/render/intern/raytrace/rayobject_internal.h
deleted file mode 100644
index 5b8a43eab03..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_internal.h
+++ /dev/null
@@ -1,157 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __RAYOBJECT_INTERNAL_H__
-#define __RAYOBJECT_INTERNAL_H__
-
-/** \file blender/render/intern/raytrace/rayobject_internal.h
- * \ingroup render
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* RayObjectControl
- *
- * This class is intended as a place holder for control, configuration of the
- * rayobject like:
- * - stop building (TODO maybe when porting build to threads this could be
- * implemented with some thread_cancel function)
- * - max number of threads and threads callback to use during build
- * ...
- */
-
-typedef int (*RE_rayobjectcontrol_test_break_callback)(void *data);
-
-typedef struct RayObjectControl {
- void *data;
- RE_rayobjectcontrol_test_break_callback test_break;
-} RayObjectControl;
-
-/* Returns true if for some reason a heavy processing function should stop
- * (eg.: user asked to stop during a tree a build)
- */
-
-int RE_rayobjectcontrol_test_break(RayObjectControl *c);
-
-/* RayObject
- *
- * A ray object is everything where we can cast rays like:
- * * a face/triangle
- * * an octree
- * * a bvh tree
- * * an octree of bvh's
- * * a bvh of bvh's
- *
- *
- * All types of RayObjects can be created by implementing the
- * callbacks of the RayObject.
- *
- * Due to high computing time evolved with casting on faces
- * there is a special type of RayObject (named RayFace)
- * which won't use callbacks like other generic nodes.
- *
- * In order to allow a mixture of RayFace+RayObjects,
- * all RayObjects must be 4byte aligned, allowing us to use the
- * 2 least significant bits (with the mask 0x03) to define the
- * type of RayObject.
- *
- * This leads to 4 possible types of RayObject:
- *
- * addr&3 - type of object
- * 0 Self (reserved for each structure)
- * 1 RayFace (tri/quad primitive)
- * 2 RayObject (generic with API callbacks)
- * 3 VlakPrimitive
- * (vlak primitive - to be used when we have a vlak describing the data
- * eg.: on render code)
- *
- * 0 means it's reserved and has it own meaning inside each ray acceleration structure
- * (this way each structure can use the align offset to determine if a node represents a
- * RayObject primitive, which can be used to save memory)
- */
-
-/* used to test the type of ray object */
-#define RE_rayobject_isAligned(o) ((((intptr_t)o)&3) == 0)
-#define RE_rayobject_isRayFace(o) ((((intptr_t)o)&3) == 1)
-#define RE_rayobject_isRayAPI(o) ((((intptr_t)o)&3) == 2)
-#define RE_rayobject_isVlakPrimitive(o) ((((intptr_t)o)&3) == 3)
-
-/* used to align a given ray object */
-#define RE_rayobject_align(o) ((RayObject *)(((intptr_t)o)&(~3)))
-
-/* used to unalign a given ray object */
-#define RE_rayobject_unalignRayFace(o) ((RayObject *)(((intptr_t)o)|1))
-#define RE_rayobject_unalignRayAPI(o) ((RayObject *)(((intptr_t)o)|2))
-#define RE_rayobject_unalignVlakPrimitive(o) ((RayObject *)(((intptr_t)o)|3))
-
-/*
- * This rayobject represents a generic object. With it's own callbacks for raytrace operations.
- * It's suitable to implement things like LOD.
- */
-
-struct RayObject {
- struct RayObjectAPI *api;
- struct RayObjectControl control;
-};
-
-typedef int (*RE_rayobject_raycast_callback)(RayObject *, struct Isect *);
-typedef void (*RE_rayobject_add_callback)(RayObject *raytree, RayObject *rayobject);
-typedef void (*RE_rayobject_done_callback)(RayObject *);
-typedef void (*RE_rayobject_free_callback)(RayObject *);
-typedef void (*RE_rayobject_merge_bb_callback)(RayObject *, float min[3], float max[3]);
-typedef float (*RE_rayobject_cost_callback)(RayObject *);
-typedef void (*RE_rayobject_hint_bb_callback)(RayObject *, struct RayHint *, float min[3], float max[3]);
-
-typedef struct RayObjectAPI {
- RE_rayobject_raycast_callback raycast;
- RE_rayobject_add_callback add;
- RE_rayobject_done_callback done;
- RE_rayobject_free_callback free;
- RE_rayobject_merge_bb_callback bb;
- RE_rayobject_cost_callback cost;
- RE_rayobject_hint_bb_callback hint_bb;
-} RayObjectAPI;
-
-/*
- * Returns the expected cost of raycast on this node, primitives have a cost of 1
- */
-float RE_rayobject_cost(RayObject *r);
-
-/*
- * This function differs from RE_rayobject_raycast
- * RE_rayobject_intersect does NOT perform last-hit optimization
- * So this is probably a function to call inside raytrace structures
- */
-int RE_rayobject_intersect(RayObject *r, struct Isect *i);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __RAYOBJECT_INTERNAL_H__ */
diff --git a/source/blender/render/intern/raytrace/rayobject_octree.cpp b/source/blender/render/intern/raytrace/rayobject_octree.cpp
deleted file mode 100644
index b21197e728d..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_octree.cpp
+++ /dev/null
@@ -1,1101 +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) 1990-1998 NeoGeo BV.
- * All rights reserved.
- *
- * Contributors: 2004/2005 Blender Foundation, full recode
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_octree.cpp
- * \ingroup render
- */
-
-
-/* IMPORTANT NOTE: this code must be independent of any other render code
- * to use it outside the renderer! */
-
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <float.h>
-#include <assert.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_material_types.h"
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "rayintersection.h"
-#include "rayobject.h"
-
-/* ********** structs *************** */
-#define BRANCH_ARRAY 1024
-#define NODE_ARRAY 4096
-
-typedef struct Branch {
- struct Branch *b[8];
-} Branch;
-
-typedef struct OcVal {
- short ocx, ocy, ocz;
-} OcVal;
-
-typedef struct Node {
- struct RayFace *v[8];
- struct OcVal ov[8];
- struct Node *next;
-} Node;
-
-typedef struct Octree {
- RayObject rayobj;
-
- struct Branch **adrbranch;
- struct Node **adrnode;
- float ocsize; /* ocsize: mult factor, max size octree */
- float ocfacx, ocfacy, ocfacz;
- float min[3], max[3];
- int ocres;
- int branchcount, nodecount;
-
- /* during building only */
- char *ocface;
-
- RayFace **ro_nodes;
- int ro_nodes_size, ro_nodes_used;
-
-} Octree;
-
-static int RE_rayobject_octree_intersect(RayObject *o, Isect *isec);
-static void RE_rayobject_octree_add(RayObject *o, RayObject *ob);
-static void RE_rayobject_octree_done(RayObject *o);
-static void RE_rayobject_octree_free(RayObject *o);
-static void RE_rayobject_octree_bb(RayObject *o, float *min, float *max);
-
-/*
- * This function is not expected to be called by current code state.
- */
-static float RE_rayobject_octree_cost(RayObject *UNUSED(o))
-{
- return 1.0;
-}
-
-static void RE_rayobject_octree_hint_bb(RayObject *UNUSED(o), RayHint *UNUSED(hint),
- float *UNUSED(min), float *UNUSED(max))
-{
- return;
-}
-
-static RayObjectAPI octree_api =
-{
- RE_rayobject_octree_intersect,
- RE_rayobject_octree_add,
- RE_rayobject_octree_done,
- RE_rayobject_octree_free,
- RE_rayobject_octree_bb,
- RE_rayobject_octree_cost,
- RE_rayobject_octree_hint_bb
-};
-
-/* **************** ocval method ******************* */
-/* within one octree node, a set of 3x15 bits defines a 'boundbox' to OR with */
-
-#define OCVALRES 15
-#define BROW16(min, max) \
- (((max) >= OCVALRES ? 0xFFFF : (1 << ((max) + 1)) - 1) - (((min) > 0) ? ((1 << (min)) - 1) : 0))
-
-static void calc_ocval_face(float *v1, float *v2, float *v3, float *v4, short x, short y, short z, OcVal *ov)
-{
- float min[3], max[3];
- int ocmin, ocmax;
-
- copy_v3_v3(min, v1);
- copy_v3_v3(max, v1);
- DO_MINMAX(v2, min, max);
- DO_MINMAX(v3, min, max);
- if (v4) {
- DO_MINMAX(v4, min, max);
- }
-
- ocmin = OCVALRES * (min[0] - x);
- ocmax = OCVALRES * (max[0] - x);
- ov->ocx = BROW16(ocmin, ocmax);
-
- ocmin = OCVALRES * (min[1] - y);
- ocmax = OCVALRES * (max[1] - y);
- ov->ocy = BROW16(ocmin, ocmax);
-
- ocmin = OCVALRES * (min[2] - z);
- ocmax = OCVALRES * (max[2] - z);
- ov->ocz = BROW16(ocmin, ocmax);
-
-}
-
-static void calc_ocval_ray(OcVal *ov, float xo, float yo, float zo, float *vec1, float *vec2)
-{
- int ocmin, ocmax;
-
- if (vec1[0] < vec2[0]) {
- ocmin = OCVALRES * (vec1[0] - xo);
- ocmax = OCVALRES * (vec2[0] - xo);
- }
- else {
- ocmin = OCVALRES * (vec2[0] - xo);
- ocmax = OCVALRES * (vec1[0] - xo);
- }
- ov->ocx = BROW16(ocmin, ocmax);
-
- if (vec1[1] < vec2[1]) {
- ocmin = OCVALRES * (vec1[1] - yo);
- ocmax = OCVALRES * (vec2[1] - yo);
- }
- else {
- ocmin = OCVALRES * (vec2[1] - yo);
- ocmax = OCVALRES * (vec1[1] - yo);
- }
- ov->ocy = BROW16(ocmin, ocmax);
-
- if (vec1[2] < vec2[2]) {
- ocmin = OCVALRES * (vec1[2] - zo);
- ocmax = OCVALRES * (vec2[2] - zo);
- }
- else {
- ocmin = OCVALRES * (vec2[2] - zo);
- ocmax = OCVALRES * (vec1[2] - zo);
- }
- ov->ocz = BROW16(ocmin, ocmax);
-}
-
-/* ************* octree ************** */
-
-static Branch *addbranch(Octree *oc, Branch *br, short ocb)
-{
- int index;
-
- if (br->b[ocb]) return br->b[ocb];
-
- oc->branchcount++;
- index = oc->branchcount >> 12;
-
- if (oc->adrbranch[index] == NULL)
- oc->adrbranch[index] = (Branch *)MEM_callocN(4096 * sizeof(Branch), "new oc branch");
-
- if (oc->branchcount >= BRANCH_ARRAY * 4096) {
- printf("error; octree branches full\n");
- oc->branchcount = 0;
- }
-
- return br->b[ocb] = oc->adrbranch[index] + (oc->branchcount & 4095);
-}
-
-static Node *addnode(Octree *oc)
-{
- int index;
-
- oc->nodecount++;
- index = oc->nodecount >> 12;
-
- if (oc->adrnode[index] == NULL)
- oc->adrnode[index] = (Node *)MEM_callocN(4096 * sizeof(Node), "addnode");
-
- if (oc->nodecount > NODE_ARRAY * NODE_ARRAY) {
- printf("error; octree nodes full\n");
- oc->nodecount = 0;
- }
-
- return oc->adrnode[index] + (oc->nodecount & 4095);
-}
-
-static bool face_in_node(RayFace *face, short x, short y, short z, float rtf[4][3])
-{
- static float nor[3], d;
- float fx, fy, fz;
-
- // init static vars
- if (face) {
- normal_tri_v3(nor, rtf[0], rtf[1], rtf[2]);
- d = -nor[0] * rtf[0][0] - nor[1] * rtf[0][1] - nor[2] * rtf[0][2];
- return 0;
- }
-
- fx = x;
- fy = y;
- fz = z;
-
- if ((fx) * nor[0] + (fy) * nor[1] + (fz) * nor[2] + d > 0.0f) {
- if ((fx + 1) * nor[0] + (fy ) * nor[1] + (fz ) * nor[2] + d < 0.0f) return 1;
- if ((fx ) * nor[0] + (fy + 1) * nor[1] + (fz ) * nor[2] + d < 0.0f) return 1;
- if ((fx + 1) * nor[0] + (fy + 1) * nor[1] + (fz ) * nor[2] + d < 0.0f) return 1;
-
- if ((fx ) * nor[0] + (fy ) * nor[1] + (fz + 1) * nor[2] + d < 0.0f) return 1;
- if ((fx + 1) * nor[0] + (fy ) * nor[1] + (fz + 1) * nor[2] + d < 0.0f) return 1;
- if ((fx ) * nor[0] + (fy + 1) * nor[1] + (fz + 1) * nor[2] + d < 0.0f) return 1;
- if ((fx + 1) * nor[0] + (fy + 1) * nor[1] + (fz + 1) * nor[2] + d < 0.0f) return 1;
- }
- else {
- if ((fx + 1) * nor[0] + (fy ) * nor[1] + (fz ) * nor[2] + d > 0.0f) return 1;
- if ((fx ) * nor[0] + (fy + 1) * nor[1] + (fz ) * nor[2] + d > 0.0f) return 1;
- if ((fx + 1) * nor[0] + (fy + 1) * nor[1] + (fz ) * nor[2] + d > 0.0f) return 1;
-
- if ((fx ) * nor[0] + (fy ) * nor[1] + (fz + 1) * nor[2] + d > 0.0f) return 1;
- if ((fx + 1) * nor[0] + (fy ) * nor[1] + (fz + 1) * nor[2] + d > 0.0f) return 1;
- if ((fx ) * nor[0] + (fy + 1) * nor[1] + (fz + 1) * nor[2] + d > 0.0f) return 1;
- if ((fx + 1) * nor[0] + (fy + 1) * nor[1] + (fz + 1) * nor[2] + d > 0.0f) return 1;
- }
-
- return 0;
-}
-
-static void ocwrite(Octree *oc, RayFace *face, int quad, short x, short y, short z, float rtf[4][3])
-{
- Branch *br;
- Node *no;
- short a, oc0, oc1, oc2, oc3, oc4, oc5;
-
- x <<= 2;
- y <<= 1;
-
- br = oc->adrbranch[0];
-
- if (oc->ocres == 512) {
- oc0 = ((x & 1024) + (y & 512) + (z & 256)) >> 8;
- br = addbranch(oc, br, oc0);
- }
- if (oc->ocres >= 256) {
- oc0 = ((x & 512) + (y & 256) + (z & 128)) >> 7;
- br = addbranch(oc, br, oc0);
- }
- if (oc->ocres >= 128) {
- oc0 = ((x & 256) + (y & 128) + (z & 64)) >> 6;
- br = addbranch(oc, br, oc0);
- }
-
- oc0 = ((x & 128) + (y & 64) + (z & 32)) >> 5;
- oc1 = ((x & 64) + (y & 32) + (z & 16)) >> 4;
- oc2 = ((x & 32) + (y & 16) + (z & 8)) >> 3;
- oc3 = ((x & 16) + (y & 8) + (z & 4)) >> 2;
- oc4 = ((x & 8) + (y & 4) + (z & 2)) >> 1;
- oc5 = ((x & 4) + (y & 2) + (z & 1));
-
- br = addbranch(oc, br, oc0);
- br = addbranch(oc, br, oc1);
- br = addbranch(oc, br, oc2);
- br = addbranch(oc, br, oc3);
- br = addbranch(oc, br, oc4);
- no = (Node *)br->b[oc5];
- if (no == NULL) br->b[oc5] = (Branch *)(no = addnode(oc));
-
- while (no->next) no = no->next;
-
- a = 0;
- if (no->v[7]) { /* node full */
- no->next = addnode(oc);
- no = no->next;
- }
- else {
- while (no->v[a] != NULL) a++;
- }
-
- no->v[a] = (RayFace *) RE_rayobject_align(face);
-
- if (quad)
- calc_ocval_face(rtf[0], rtf[1], rtf[2], rtf[3], x >> 2, y >> 1, z, &no->ov[a]);
- else
- calc_ocval_face(rtf[0], rtf[1], rtf[2], NULL, x >> 2, y >> 1, z, &no->ov[a]);
-}
-
-static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocface, short rts[4][3], float rtf[4][3])
-{
- int ocx1, ocx2, ocy1, ocy2;
- int x, y, dx = 0, dy = 0;
- float ox1, ox2, oy1, oy2;
- float lambda, lambda_o, lambda_x, lambda_y, ldx, ldy;
-
- ocx1 = rts[b1][c1];
- ocy1 = rts[b1][c2];
- ocx2 = rts[b2][c1];
- ocy2 = rts[b2][c2];
-
- if (ocx1 == ocx2 && ocy1 == ocy2) {
- ocface[oc->ocres * ocx1 + ocy1] = 1;
- return;
- }
-
- ox1 = rtf[b1][c1];
- oy1 = rtf[b1][c2];
- ox2 = rtf[b2][c1];
- oy2 = rtf[b2][c2];
-
- if (ox1 != ox2) {
- if (ox2 - ox1 > 0.0f) {
- lambda_x = (ox1 - ocx1 - 1.0f) / (ox1 - ox2);
- ldx = -1.0f / (ox1 - ox2);
- dx = 1;
- }
- else {
- lambda_x = (ox1 - ocx1) / (ox1 - ox2);
- ldx = 1.0f / (ox1 - ox2);
- dx = -1;
- }
- }
- else {
- lambda_x = 1.0f;
- ldx = 0;
- }
-
- if (oy1 != oy2) {
- if (oy2 - oy1 > 0.0f) {
- lambda_y = (oy1 - ocy1 - 1.0f) / (oy1 - oy2);
- ldy = -1.0f / (oy1 - oy2);
- dy = 1;
- }
- else {
- lambda_y = (oy1 - ocy1) / (oy1 - oy2);
- ldy = 1.0f / (oy1 - oy2);
- dy = -1;
- }
- }
- else {
- lambda_y = 1.0f;
- ldy = 0;
- }
-
- x = ocx1; y = ocy1;
- lambda = MIN2(lambda_x, lambda_y);
-
- while (true) {
-
- if (x < 0 || y < 0 || x >= oc->ocres || y >= oc->ocres) {
- /* pass*/
- }
- else {
- ocface[oc->ocres * x + y] = 1;
- }
-
- lambda_o = lambda;
- if (lambda_x == lambda_y) {
- lambda_x += ldx;
- x += dx;
- lambda_y += ldy;
- y += dy;
- }
- else {
- if (lambda_x < lambda_y) {
- lambda_x += ldx;
- x += dx;
- }
- else {
- lambda_y += ldy;
- y += dy;
- }
- }
- lambda = MIN2(lambda_x, lambda_y);
- if (lambda == lambda_o) break;
- if (lambda >= 1.0f) break;
- }
- ocface[oc->ocres * ocx2 + ocy2] = 1;
-}
-
-static void filltriangle(Octree *oc, short c1, short c2, char *ocface, short *ocmin, short *ocmax)
-{
- int a, x, y, y1, y2;
-
- for (x = ocmin[c1]; x <= ocmax[c1]; x++) {
- a = oc->ocres * x;
- for (y = ocmin[c2]; y <= ocmax[c2]; y++) {
- if (ocface[a + y]) {
- y++;
- while (ocface[a + y] && y != ocmax[c2]) y++;
- for (y1 = ocmax[c2]; y1 > y; y1--) {
- if (ocface[a + y1]) {
- for (y2 = y; y2 <= y1; y2++) ocface[a + y2] = 1;
- y1 = 0;
- }
- }
- y = ocmax[c2];
- }
- }
- }
-}
-
-static void RE_rayobject_octree_free(RayObject *tree)
-{
- Octree *oc = (Octree *)tree;
-
-#if 0
- printf("branches %d nodes %d\n", oc->branchcount, oc->nodecount);
- printf("raycount %d\n", raycount);
- printf("ray coherent %d\n", coherent_ray);
- printf("accepted %d rejected %d\n", accepted, rejected);
-#endif
- if (oc->ocface)
- MEM_freeN(oc->ocface);
-
- if (oc->adrbranch) {
- int a = 0;
- while (oc->adrbranch[a]) {
- MEM_freeN(oc->adrbranch[a]);
- oc->adrbranch[a] = NULL;
- a++;
- }
- MEM_freeN(oc->adrbranch);
- oc->adrbranch = NULL;
- }
- oc->branchcount = 0;
-
- if (oc->adrnode) {
- int a = 0;
- while (oc->adrnode[a]) {
- MEM_freeN(oc->adrnode[a]);
- oc->adrnode[a] = NULL;
- a++;
- }
- MEM_freeN(oc->adrnode);
- oc->adrnode = NULL;
- }
- oc->nodecount = 0;
-
- MEM_freeN(oc);
-}
-
-
-RayObject *RE_rayobject_octree_create(int ocres, int size)
-{
- Octree *oc = (Octree *)MEM_callocN(sizeof(Octree), "Octree");
- assert(RE_rayobject_isAligned(oc) ); /* RayObject API assumes real data to be 4-byte aligned */
-
- oc->rayobj.api = &octree_api;
-
- oc->ocres = ocres;
-
- oc->ro_nodes = (RayFace **)MEM_callocN(sizeof(RayFace *) * size, "octree rayobject nodes");
- oc->ro_nodes_size = size;
- oc->ro_nodes_used = 0;
-
-
- return RE_rayobject_unalignRayAPI((RayObject *) oc);
-}
-
-
-static void RE_rayobject_octree_add(RayObject *tree, RayObject *node)
-{
- Octree *oc = (Octree *)tree;
-
- assert(RE_rayobject_isRayFace(node) );
- assert(oc->ro_nodes_used < oc->ro_nodes_size);
- oc->ro_nodes[oc->ro_nodes_used++] = (RayFace *)RE_rayobject_align(node);
-}
-
-static void octree_fill_rayface(Octree *oc, RayFace *face)
-{
- float ocfac[3], rtf[4][3];
- float co1[3], co2[3], co3[3], co4[3];
- short rts[4][3];
- short ocmin[3], ocmax[3];
- char *ocface = oc->ocface; // front, top, size view of face, to fill in
- int a, b, c, oc1, oc2, oc3, oc4, x, y, z, ocres2;
-
- ocfac[0] = oc->ocfacx;
- ocfac[1] = oc->ocfacy;
- ocfac[2] = oc->ocfacz;
-
- ocres2 = oc->ocres * oc->ocres;
-
- copy_v3_v3(co1, face->v1);
- copy_v3_v3(co2, face->v2);
- copy_v3_v3(co3, face->v3);
- if (RE_rayface_isQuad(face))
- copy_v3_v3(co4, face->v4);
-
- for (c = 0; c < 3; c++) {
- rtf[0][c] = (co1[c] - oc->min[c]) * ocfac[c];
- rts[0][c] = (short)rtf[0][c];
- rtf[1][c] = (co2[c] - oc->min[c]) * ocfac[c];
- rts[1][c] = (short)rtf[1][c];
- rtf[2][c] = (co3[c] - oc->min[c]) * ocfac[c];
- rts[2][c] = (short)rtf[2][c];
- if (RE_rayface_isQuad(face)) {
- rtf[3][c] = (co4[c] - oc->min[c]) * ocfac[c];
- rts[3][c] = (short)rtf[3][c];
- }
- }
-
- for (c = 0; c < 3; c++) {
- oc1 = rts[0][c];
- oc2 = rts[1][c];
- oc3 = rts[2][c];
- if (!RE_rayface_isQuad(face)) {
- ocmin[c] = min_iii(oc1, oc2, oc3);
- ocmax[c] = max_iii(oc1, oc2, oc3);
- }
- else {
- oc4 = rts[3][c];
- ocmin[c] = min_iiii(oc1, oc2, oc3, oc4);
- ocmax[c] = max_iiii(oc1, oc2, oc3, oc4);
- }
- if (ocmax[c] > oc->ocres - 1) ocmax[c] = oc->ocres - 1;
- if (ocmin[c] < 0) ocmin[c] = 0;
- }
-
- if (ocmin[0] == ocmax[0] && ocmin[1] == ocmax[1] && ocmin[2] == ocmax[2]) {
- ocwrite(oc, face, RE_rayface_isQuad(face), ocmin[0], ocmin[1], ocmin[2], rtf);
- }
- else {
-
- d2dda(oc, 0, 1, 0, 1, ocface + ocres2, rts, rtf);
- d2dda(oc, 0, 1, 0, 2, ocface, rts, rtf);
- d2dda(oc, 0, 1, 1, 2, ocface + 2 * ocres2, rts, rtf);
- d2dda(oc, 1, 2, 0, 1, ocface + ocres2, rts, rtf);
- d2dda(oc, 1, 2, 0, 2, ocface, rts, rtf);
- d2dda(oc, 1, 2, 1, 2, ocface + 2 * ocres2, rts, rtf);
- if (!RE_rayface_isQuad(face)) {
- d2dda(oc, 2, 0, 0, 1, ocface + ocres2, rts, rtf);
- d2dda(oc, 2, 0, 0, 2, ocface, rts, rtf);
- d2dda(oc, 2, 0, 1, 2, ocface + 2 * ocres2, rts, rtf);
- }
- else {
- d2dda(oc, 2, 3, 0, 1, ocface + ocres2, rts, rtf);
- d2dda(oc, 2, 3, 0, 2, ocface, rts, rtf);
- d2dda(oc, 2, 3, 1, 2, ocface + 2 * ocres2, rts, rtf);
- d2dda(oc, 3, 0, 0, 1, ocface + ocres2, rts, rtf);
- d2dda(oc, 3, 0, 0, 2, ocface, rts, rtf);
- d2dda(oc, 3, 0, 1, 2, ocface + 2 * ocres2, rts, rtf);
- }
- /* nothing todo with triangle..., just fills :) */
- filltriangle(oc, 0, 1, ocface + ocres2, ocmin, ocmax);
- filltriangle(oc, 0, 2, ocface, ocmin, ocmax);
- filltriangle(oc, 1, 2, ocface + 2 * ocres2, ocmin, ocmax);
-
- /* init static vars here */
- face_in_node(face, 0, 0, 0, rtf);
-
- for (x = ocmin[0]; x <= ocmax[0]; x++) {
- a = oc->ocres * x;
- for (y = ocmin[1]; y <= ocmax[1]; y++) {
- if (ocface[a + y + ocres2]) {
- b = oc->ocres * y + 2 * ocres2;
- for (z = ocmin[2]; z <= ocmax[2]; z++) {
- if (ocface[b + z] && ocface[a + z]) {
- if (face_in_node(NULL, x, y, z, rtf))
- ocwrite(oc, face, RE_rayface_isQuad(face), x, y, z, rtf);
- }
- }
- }
- }
- }
-
- /* same loops to clear octree, doubt it can be done smarter */
- for (x = ocmin[0]; x <= ocmax[0]; x++) {
- a = oc->ocres * x;
- for (y = ocmin[1]; y <= ocmax[1]; y++) {
- /* x-y */
- ocface[a + y + ocres2] = 0;
-
- b = oc->ocres * y + 2 * ocres2;
- for (z = ocmin[2]; z <= ocmax[2]; z++) {
- /* y-z */
- ocface[b + z] = 0;
- /* x-z */
- ocface[a + z] = 0;
- }
- }
- }
- }
-}
-
-static void RE_rayobject_octree_done(RayObject *tree)
-{
- Octree *oc = (Octree *)tree;
- int c;
- float t00, t01, t02;
- int ocres2 = oc->ocres * oc->ocres;
-
- INIT_MINMAX(oc->min, oc->max);
-
- /* Calculate Bounding Box */
- for (c = 0; c < oc->ro_nodes_used; c++)
- RE_rayobject_merge_bb(RE_rayobject_unalignRayFace(oc->ro_nodes[c]), oc->min, oc->max);
-
- /* Alloc memory */
- oc->adrbranch = (Branch **)MEM_callocN(sizeof(void *) * BRANCH_ARRAY, "octree branches");
- oc->adrnode = (Node **)MEM_callocN(sizeof(void *) * NODE_ARRAY, "octree nodes");
-
- oc->adrbranch[0] = (Branch *)MEM_callocN(4096 * sizeof(Branch), "makeoctree");
-
- /* the lookup table, per face, for which nodes to fill in */
- oc->ocface = (char *)MEM_callocN(3 * ocres2 + 8, "ocface");
- memset(oc->ocface, 0, 3 * ocres2);
-
- for (c = 0; c < 3; c++) { /* octree enlarge, still needed? */
- oc->min[c] -= 0.01f;
- oc->max[c] += 0.01f;
- }
-
- t00 = oc->max[0] - oc->min[0];
- t01 = oc->max[1] - oc->min[1];
- t02 = oc->max[2] - oc->min[2];
-
- /* this minus 0.1 is old safety... seems to be needed? */
- oc->ocfacx = (oc->ocres - 0.1f) / t00;
- oc->ocfacy = (oc->ocres - 0.1f) / t01;
- oc->ocfacz = (oc->ocres - 0.1f) / t02;
-
- oc->ocsize = sqrtf(t00 * t00 + t01 * t01 + t02 * t02); /* global, max size octree */
-
- for (c = 0; c < oc->ro_nodes_used; c++) {
- octree_fill_rayface(oc, oc->ro_nodes[c]);
- }
-
- MEM_freeN(oc->ocface);
- oc->ocface = NULL;
- MEM_freeN(oc->ro_nodes);
- oc->ro_nodes = NULL;
-
-#if 0
- printf("%f %f - %f\n", oc->min[0], oc->max[0], oc->ocfacx);
- printf("%f %f - %f\n", oc->min[1], oc->max[1], oc->ocfacy);
- printf("%f %f - %f\n", oc->min[2], oc->max[2], oc->ocfacz);
-#endif
-}
-
-static void RE_rayobject_octree_bb(RayObject *tree, float *min, float *max)
-{
- Octree *oc = (Octree *)tree;
- DO_MINMAX(oc->min, min, max);
- DO_MINMAX(oc->max, min, max);
-}
-
-/* check all faces in this node */
-static int testnode(Octree *UNUSED(oc), Isect *is, Node *no, OcVal ocval)
-{
- short nr = 0;
-
- /* return on any first hit */
- if (is->mode == RE_RAY_SHADOW) {
-
- for (; no; no = no->next) {
- for (nr = 0; nr < 8; nr++) {
- RayFace *face = no->v[nr];
- OcVal *ov = no->ov + nr;
-
- if (!face) break;
-
- if ( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) ) {
- if (RE_rayobject_intersect(RE_rayobject_unalignRayFace(face), is) )
- return 1;
- }
- }
- }
- }
- else {
- /* else mirror or glass or shadowtra, return closest face */
- int found = 0;
-
- for (; no; no = no->next) {
- for (nr = 0; nr < 8; nr++) {
- RayFace *face = no->v[nr];
- OcVal *ov = no->ov + nr;
-
- if (!face) break;
-
- if ( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) ) {
- if (RE_rayobject_intersect(RE_rayobject_unalignRayFace(face), is) ) {
- found = 1;
- }
- }
- }
- }
-
- return found;
- }
-
- return 0;
-}
-
-/* find the Node for the octree coord x y z */
-static Node *ocread(Octree *oc, int x, int y, int z)
-{
- Branch *br;
- int oc1;
-
- x <<= 2;
- y <<= 1;
-
- br = oc->adrbranch[0];
-
- if (oc->ocres == 512) {
- oc1 = ((x & 1024) + (y & 512) + (z & 256)) >> 8;
- br = br->b[oc1];
- if (br == NULL) {
- return NULL;
- }
- }
- if (oc->ocres >= 256) {
- oc1 = ((x & 512) + (y & 256) + (z & 128)) >> 7;
- br = br->b[oc1];
- if (br == NULL) {
- return NULL;
- }
- }
- if (oc->ocres >= 128) {
- oc1 = ((x & 256) + (y & 128) + (z & 64)) >> 6;
- br = br->b[oc1];
- if (br == NULL) {
- return NULL;
- }
- }
-
- oc1 = ((x & 128) + (y & 64) + (z & 32)) >> 5;
- br = br->b[oc1];
- if (br) {
- oc1 = ((x & 64) + (y & 32) + (z & 16)) >> 4;
- br = br->b[oc1];
- if (br) {
- oc1 = ((x & 32) + (y & 16) + (z & 8)) >> 3;
- br = br->b[oc1];
- if (br) {
- oc1 = ((x & 16) + (y & 8) + (z & 4)) >> 2;
- br = br->b[oc1];
- if (br) {
- oc1 = ((x & 8) + (y & 4) + (z & 2)) >> 1;
- br = br->b[oc1];
- if (br) {
- oc1 = ((x & 4) + (y & 2) + (z & 1));
- return (Node *)br->b[oc1];
- }
- }
- }
- }
- }
-
- return NULL;
-}
-
-static int cliptest(float p, float q, float *u1, float *u2)
-{
- float r;
-
- if (p < 0.0f) {
- if (q < p) return 0;
- else if (q < 0.0f) {
- r = q / p;
- if (r > *u2) return 0;
- else if (r > *u1) *u1 = r;
- }
- }
- else {
- if (p > 0.0f) {
- if (q < 0.0f) return 0;
- else if (q < p) {
- r = q / p;
- if (r < *u1) return 0;
- else if (r < *u2) *u2 = r;
- }
- }
- else if (q < 0.0f) return 0;
- }
- return 1;
-}
-
-/* extensive coherence checks/storage cancels out the benefit of it, and gives errors... we
- * need better methods, sample code commented out below (ton) */
-
-#if 0
-
-in top : static int coh_nodes[16 * 16 * 16][6];
-in makeoctree : memset(coh_nodes, 0, sizeof(coh_nodes));
-
-static void add_coherence_test(int ocx1, int ocx2, int ocy1, int ocy2, int ocz1, int ocz2)
-{
- short *sp;
-
- sp = coh_nodes[(ocx2 & 15) + 16 * (ocy2 & 15) + 256 * (ocz2 & 15)];
- sp[0] = ocx1; sp[1] = ocy1; sp[2] = ocz1;
- sp[3] = ocx2; sp[4] = ocy2; sp[5] = ocz2;
-
-}
-
-static int do_coherence_test(int ocx1, int ocx2, int ocy1, int ocy2, int ocz1, int ocz2)
-{
- short *sp;
-
- sp = coh_nodes[(ocx2 & 15) + 16 * (ocy2 & 15) + 256 * (ocz2 & 15)];
- if (sp[0] == ocx1 && sp[1] == ocy1 && sp[2] == ocz1 &&
- sp[3] == ocx2 && sp[4] == ocy2 && sp[5] == ocz2) return 1;
- return 0;
-}
-
-#endif
-
-/* return 1: found valid intersection */
-/* starts with is->orig.face */
-static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
-{
- Octree *oc = (Octree *)tree;
- Node *no;
- OcVal ocval;
- float vec1[3], vec2[3], start[3], end[3];
- float u1, u2, ox1, ox2, oy1, oy2, oz1, oz2;
- float lambda_o, lambda_x, ldx, lambda_y, ldy, lambda_z, ldz, dda_lambda;
- float o_lambda = 0;
- int dx, dy, dz;
- int xo, yo, zo, c1 = 0;
- int ocx1, ocx2, ocy1, ocy2, ocz1, ocz2;
-
- /* clip with octree */
- if (oc->branchcount == 0) return 0;
-
- /* do this before intersect calls */
-#if 0
- is->facecontr = NULL; /* to check shared edge */
- is->obcontr = 0;
- is->faceisect = is->isect = 0; /* shared edge, quad half flag */
- is->userdata = oc->userdata;
-#endif
-
- copy_v3_v3(start, is->start);
- madd_v3_v3v3fl(end, is->start, is->dir, is->dist);
- ldx = is->dir[0] * is->dist;
- o_lambda = is->dist;
- u1 = 0.0f;
- u2 = 1.0f;
-
- /* clip with octree cube */
- if (cliptest(-ldx, start[0] - oc->min[0], &u1, &u2)) {
- if (cliptest(ldx, oc->max[0] - start[0], &u1, &u2)) {
- ldy = is->dir[1] * is->dist;
- if (cliptest(-ldy, start[1] - oc->min[1], &u1, &u2)) {
- if (cliptest(ldy, oc->max[1] - start[1], &u1, &u2)) {
- ldz = is->dir[2] * is->dist;
- if (cliptest(-ldz, start[2] - oc->min[2], &u1, &u2)) {
- if (cliptest(ldz, oc->max[2] - start[2], &u1, &u2)) {
- c1 = 1;
- if (u2 < 1.0f) {
- end[0] = start[0] + u2 * ldx;
- end[1] = start[1] + u2 * ldy;
- end[2] = start[2] + u2 * ldz;
- }
-
- if (u1 > 0.0f) {
- start[0] += u1 * ldx;
- start[1] += u1 * ldy;
- start[2] += u1 * ldz;
- }
- }
- }
- }
- }
- }
- }
-
- if (c1 == 0) return 0;
-
- /* reset static variables in ocread */
- //ocread(oc, oc->ocres, 0, 0);
-
- /* setup 3dda to traverse octree */
- ox1 = (start[0] - oc->min[0]) * oc->ocfacx;
- oy1 = (start[1] - oc->min[1]) * oc->ocfacy;
- oz1 = (start[2] - oc->min[2]) * oc->ocfacz;
- ox2 = (end[0] - oc->min[0]) * oc->ocfacx;
- oy2 = (end[1] - oc->min[1]) * oc->ocfacy;
- oz2 = (end[2] - oc->min[2]) * oc->ocfacz;
-
- ocx1 = (int)ox1;
- ocy1 = (int)oy1;
- ocz1 = (int)oz1;
- ocx2 = (int)ox2;
- ocy2 = (int)oy2;
- ocz2 = (int)oz2;
-
- if (ocx1 == ocx2 && ocy1 == ocy2 && ocz1 == ocz2) {
- no = ocread(oc, ocx1, ocy1, ocz1);
- if (no) {
- /* exact intersection with node */
- vec1[0] = ox1; vec1[1] = oy1; vec1[2] = oz1;
- vec2[0] = ox2; vec2[1] = oy2; vec2[2] = oz2;
- calc_ocval_ray(&ocval, (float)ocx1, (float)ocy1, (float)ocz1, vec1, vec2);
- if (testnode(oc, is, no, ocval) ) return 1;
- }
- }
- else {
- int found = 0;
- //static int coh_ocx1, coh_ocx2, coh_ocy1, coh_ocy2, coh_ocz1, coh_ocz2;
- float dox, doy, doz;
- int eqval;
-
- /* calc lambda en ld */
- dox = ox1 - ox2;
- doy = oy1 - oy2;
- doz = oz1 - oz2;
-
- if (dox < -FLT_EPSILON) {
- ldx = -1.0f / dox;
- lambda_x = (ocx1 - ox1 + 1.0f) * ldx;
- dx = 1;
- }
- else if (dox > FLT_EPSILON) {
- ldx = 1.0f / dox;
- lambda_x = (ox1 - ocx1) * ldx;
- dx = -1;
- }
- else {
- lambda_x = 1.0f;
- ldx = 0;
- dx = 0;
- }
-
- if (doy < -FLT_EPSILON) {
- ldy = -1.0f / doy;
- lambda_y = (ocy1 - oy1 + 1.0f) * ldy;
- dy = 1;
- }
- else if (doy > FLT_EPSILON) {
- ldy = 1.0f / doy;
- lambda_y = (oy1 - ocy1) * ldy;
- dy = -1;
- }
- else {
- lambda_y = 1.0f;
- ldy = 0;
- dy = 0;
- }
-
- if (doz < -FLT_EPSILON) {
- ldz = -1.0f / doz;
- lambda_z = (ocz1 - oz1 + 1.0f) * ldz;
- dz = 1;
- }
- else if (doz > FLT_EPSILON) {
- ldz = 1.0f / doz;
- lambda_z = (oz1 - ocz1) * ldz;
- dz = -1;
- }
- else {
- lambda_z = 1.0f;
- ldz = 0;
- dz = 0;
- }
-
- xo = ocx1; yo = ocy1; zo = ocz1;
- dda_lambda = min_fff(lambda_x, lambda_y, lambda_z);
-
- vec2[0] = ox1;
- vec2[1] = oy1;
- vec2[2] = oz1;
-
- /* this loop has been constructed to make sure the first and last node of ray
- * are always included, even when dda_lambda==1.0f or larger */
-
- while (true) {
-
- no = ocread(oc, xo, yo, zo);
- if (no) {
-
- /* calculate ray intersection with octree node */
- copy_v3_v3(vec1, vec2);
- // dox, y, z is negative
- vec2[0] = ox1 - dda_lambda * dox;
- vec2[1] = oy1 - dda_lambda * doy;
- vec2[2] = oz1 - dda_lambda * doz;
- calc_ocval_ray(&ocval, (float)xo, (float)yo, (float)zo, vec1, vec2);
-
- //is->dist = (u1 + dda_lambda * (u2 - u1)) * o_lambda;
- if (testnode(oc, is, no, ocval) )
- found = 1;
-
- if (is->dist < (u1 + dda_lambda * (u2 - u1)) * o_lambda)
- return found;
- }
-
-
- lambda_o = dda_lambda;
-
- /* traversing octree nodes need careful detection of smallest values, with proper
- * exceptions for equal lambdas */
- eqval = (lambda_x == lambda_y);
- if (lambda_y == lambda_z) eqval += 2;
- if (lambda_x == lambda_z) eqval += 4;
-
- if (eqval) { // only 4 cases exist!
- if (eqval == 7) { // x=y=z
- xo += dx; lambda_x += ldx;
- yo += dy; lambda_y += ldy;
- zo += dz; lambda_z += ldz;
- }
- else if (eqval == 1) { // x=y
- if (lambda_y < lambda_z) {
- xo += dx; lambda_x += ldx;
- yo += dy; lambda_y += ldy;
- }
- else {
- zo += dz; lambda_z += ldz;
- }
- }
- else if (eqval == 2) { // y=z
- if (lambda_x < lambda_y) {
- xo += dx; lambda_x += ldx;
- }
- else {
- yo += dy; lambda_y += ldy;
- zo += dz; lambda_z += ldz;
- }
- }
- else { // x=z
- if (lambda_y < lambda_x) {
- yo += dy; lambda_y += ldy;
- }
- else {
- xo += dx; lambda_x += ldx;
- zo += dz; lambda_z += ldz;
- }
- }
- }
- else { // all three different, just three cases exist
- eqval = (lambda_x < lambda_y);
- if (lambda_y < lambda_z) eqval += 2;
- if (lambda_x < lambda_z) eqval += 4;
-
- if (eqval == 7 || eqval == 5) { // x smallest
- xo += dx; lambda_x += ldx;
- }
- else if (eqval == 2 || eqval == 6) { // y smallest
- yo += dy; lambda_y += ldy;
- }
- else { // z smallest
- zo += dz; lambda_z += ldz;
- }
-
- }
-
- dda_lambda = min_fff(lambda_x, lambda_y, lambda_z);
- if (dda_lambda == lambda_o) break;
- /* to make sure the last node is always checked */
- if (lambda_o >= 1.0f) break;
- }
- }
-
- /* reached end, no intersections found */
- return 0;
-}
-
-
-
diff --git a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp
deleted file mode 100644
index 5b90ae77732..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp
+++ /dev/null
@@ -1,160 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_qbvh.cpp
- * \ingroup render
- */
-
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_utildefines.h"
-
-#include "vbvh.h"
-#include "svbvh.h"
-#include "reorganize.h"
-
-#ifdef __SSE__
-
-#define DFS_STACK_SIZE 256
-
-struct QBVHTree {
- RayObject rayobj;
-
- SVBVHNode *root;
- MemArena *node_arena;
-
- float cost;
- RTBuilder *builder;
-};
-
-
-template<>
-void bvh_done<QBVHTree>(QBVHTree *obj)
-{
- rtbuild_done(obj->builder, &obj->rayobj.control);
-
- //TODO find a away to exactly calculate the needed memory
- MemArena *arena1 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "qbvh arena");
- BLI_memarena_use_malloc(arena1);
-
- MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "qbvh arena 2");
- BLI_memarena_use_malloc(arena2);
- BLI_memarena_use_align(arena2, 16);
-
- //Build and optimize the tree
- //TODO do this in 1 pass (half memory usage during building)
- VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder);
-
- if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) {
- BLI_memarena_free(arena1);
- BLI_memarena_free(arena2);
- return;
- }
-
- if (root) {
- pushup_simd<VBVHNode, 4>(root);
- obj->root = Reorganize_SVBVH<VBVHNode>(arena2).transform(root);
- }
- else
- obj->root = NULL;
-
- //Free data
- BLI_memarena_free(arena1);
-
- obj->node_arena = arena2;
- obj->cost = 1.0;
-
- rtbuild_free(obj->builder);
- obj->builder = NULL;
-}
-
-template<int StackSize>
-static int intersect(QBVHTree *obj, Isect *isec)
-{
- //TODO renable hint support
- if (RE_rayobject_isAligned(obj->root)) {
- if (isec->mode == RE_RAY_SHADOW)
- return svbvh_node_stack_raycast<StackSize, true>(obj->root, isec);
- else
- return svbvh_node_stack_raycast<StackSize, false>(obj->root, isec);
- }
- else
- return RE_rayobject_intersect((RayObject *)obj->root, isec);
-}
-
-template<class Tree>
-static void bvh_hint_bb(Tree *tree, LCTSHint *hint, float *UNUSED(min), float *UNUSED(max))
-{
- //TODO renable hint support
- {
- hint->size = 0;
- hint->stack[hint->size++] = (RayObject *)tree->root;
- }
-}
-/* the cast to pointer function is needed to workarround gcc bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11407 */
-template<class Tree, int STACK_SIZE>
-static RayObjectAPI make_api()
-{
- static RayObjectAPI api =
- {
- (RE_rayobject_raycast_callback) ((int (*)(Tree *, Isect *)) & intersect<STACK_SIZE>),
- (RE_rayobject_add_callback) ((void (*)(Tree *, RayObject *)) & bvh_add<Tree>),
- (RE_rayobject_done_callback) ((void (*)(Tree *)) & bvh_done<Tree>),
- (RE_rayobject_free_callback) ((void (*)(Tree *)) & bvh_free<Tree>),
- (RE_rayobject_merge_bb_callback)((void (*)(Tree *, float *, float *)) & bvh_bb<Tree>),
- (RE_rayobject_cost_callback) ((float (*)(Tree *)) & bvh_cost<Tree>),
- (RE_rayobject_hint_bb_callback) ((void (*)(Tree *, LCTSHint *, float *, float *)) & bvh_hint_bb<Tree>)
- };
-
- return api;
-}
-
-template<class Tree>
-RayObjectAPI *bvh_get_api(int maxstacksize)
-{
- static RayObjectAPI bvh_api256 = make_api<Tree, 1024>();
-
- if (maxstacksize <= 1024) return &bvh_api256;
- assert(maxstacksize <= 256);
- return NULL;
-}
-
-RayObject *RE_rayobject_qbvh_create(int size)
-{
- return bvh_create_tree<QBVHTree, DFS_STACK_SIZE>(size);
-}
-
-#else
-
-RayObject *RE_rayobject_qbvh_create(int UNUSED(size))
-{
- puts("WARNING: SSE disabled at compile time\n");
- return NULL;
-}
-
-#endif
diff --git a/source/blender/render/intern/raytrace/rayobject_raycounter.cpp b/source/blender/render/intern/raytrace/rayobject_raycounter.cpp
deleted file mode 100644
index 5335bf50cbc..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_raycounter.cpp
+++ /dev/null
@@ -1,91 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_raycounter.cpp
- * \ingroup render
- */
-
-
-#include "rayobject.h"
-#include "raycounter.h"
-
-#ifdef RE_RAYCOUNTER
-
-void RE_RC_INFO(RayCounter *info)
-{
- printf("----------- Raycast counter --------\n");
- printf("Rays total: %llu\n", info->raycast.test );
- printf("Rays hit: %llu\n", info->raycast.hit );
- printf("\n");
- printf("BB tests: %llu\n", info->bb.test );
- printf("BB hits: %llu\n", info->bb.hit );
- printf("\n");
- printf("SIMD BB tests: %llu\n", info->simd_bb.test );
- printf("SIMD BB hits: %llu\n", info->simd_bb.hit );
- printf("\n");
- printf("Primitives tests: %llu\n", info->faces.test );
- printf("Primitives hits: %llu\n", info->faces.hit );
- printf("------------------------------------\n");
- printf("Shadow last-hit tests per ray: %f\n", info->rayshadow_last_hit.test / ((float)info->raycast.test) );
- printf("Shadow last-hit hits per ray: %f\n", info->rayshadow_last_hit.hit / ((float)info->raycast.test) );
- printf("\n");
- printf("Hint tests per ray: %f\n", info->raytrace_hint.test / ((float)info->raycast.test) );
- printf("Hint hits per ray: %f\n", info->raytrace_hint.hit / ((float)info->raycast.test) );
- printf("\n");
- printf("BB tests per ray: %f\n", info->bb.test / ((float)info->raycast.test) );
- printf("BB hits per ray: %f\n", info->bb.hit / ((float)info->raycast.test) );
- printf("\n");
- printf("SIMD tests per ray: %f\n", info->simd_bb.test / ((float)info->raycast.test) );
- printf("SIMD hits per ray: %f\n", info->simd_bb.hit / ((float)info->raycast.test) );
- printf("\n");
- printf("Primitives tests per ray: %f\n", info->faces.test / ((float)info->raycast.test) );
- printf("Primitives hits per ray: %f\n", info->faces.hit / ((float)info->raycast.test) );
- printf("------------------------------------\n");
-}
-
-void RE_RC_MERGE(RayCounter *dest, RayCounter *tmp)
-{
- dest->faces.test += tmp->faces.test;
- dest->faces.hit += tmp->faces.hit;
-
- dest->bb.test += tmp->bb.test;
- dest->bb.hit += tmp->bb.hit;
-
- dest->simd_bb.test += tmp->simd_bb.test;
- dest->simd_bb.hit += tmp->simd_bb.hit;
-
- dest->raycast.test += tmp->raycast.test;
- dest->raycast.hit += tmp->raycast.hit;
-
- dest->rayshadow_last_hit.test += tmp->rayshadow_last_hit.test;
- dest->rayshadow_last_hit.hit += tmp->rayshadow_last_hit.hit;
-
- dest->raytrace_hint.test += tmp->raytrace_hint.test;
- dest->raytrace_hint.hit += tmp->raytrace_hint.hit;
-}
-
-#endif
diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
deleted file mode 100644
index 103fa3e6034..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
+++ /dev/null
@@ -1,531 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_rtbuild.cpp
- * \ingroup render
- */
-
-
-#include <assert.h>
-#include <stdlib.h>
-#include <algorithm>
-
-#if __cplusplus >= 201103L
-#include <cmath>
-using std::isfinite;
-#else
-#include <math.h>
-#endif
-
-#include "rayobject_rtbuild.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-static bool selected_node(RTBuilder::Object *node)
-{
- return node->selected;
-}
-
-static void rtbuild_init(RTBuilder *b)
-{
- b->split_axis = -1;
- b->primitives.begin = NULL;
- b->primitives.end = NULL;
- b->primitives.maxsize = 0;
- b->depth = 0;
-
- for (int i = 0; i < RTBUILD_MAX_CHILDS; i++)
- b->child_offset[i] = 0;
-
- for (int i = 0; i < 3; i++)
- b->sorted_begin[i] = b->sorted_end[i] = NULL;
-
- INIT_MINMAX(b->bb, b->bb + 3);
-}
-
-RTBuilder *rtbuild_create(int size)
-{
- RTBuilder *builder = (RTBuilder *) MEM_mallocN(sizeof(RTBuilder), "RTBuilder");
- RTBuilder::Object *memblock = (RTBuilder::Object *)MEM_mallocN(sizeof(RTBuilder::Object) * size, "RTBuilder.objects");
-
-
- rtbuild_init(builder);
-
- builder->primitives.begin = builder->primitives.end = memblock;
- builder->primitives.maxsize = size;
-
- for (int i = 0; i < 3; i++) {
- builder->sorted_begin[i] = (RTBuilder::Object **)MEM_mallocN(sizeof(RTBuilder::Object *) * size, "RTBuilder.sorted_objects");
- builder->sorted_end[i] = builder->sorted_begin[i];
- }
-
-
- return builder;
-}
-
-void rtbuild_free(RTBuilder *b)
-{
- if (b->primitives.begin) MEM_freeN(b->primitives.begin);
-
- for (int i = 0; i < 3; i++)
- if (b->sorted_begin[i])
- MEM_freeN(b->sorted_begin[i]);
-
- MEM_freeN(b);
-}
-
-void rtbuild_add(RTBuilder *b, RayObject *o)
-{
- float bb[6];
-
- assert(b->primitives.begin + b->primitives.maxsize != b->primitives.end);
-
- INIT_MINMAX(bb, bb + 3);
- RE_rayobject_merge_bb(o, bb, bb + 3);
-
- /* skip objects with invalid bounding boxes, nan causes DO_MINMAX
- * to do nothing, so we get these invalid values. this shouldn't
- * happen usually, but bugs earlier in the pipeline can cause it. */
- if (bb[0] > bb[3] || bb[1] > bb[4] || bb[2] > bb[5])
- return;
- /* skip objects with inf bounding boxes */
- if (!isfinite(bb[0]) || !isfinite(bb[1]) || !isfinite(bb[2]))
- return;
- if (!isfinite(bb[3]) || !isfinite(bb[4]) || !isfinite(bb[5]))
- return;
- /* skip objects with zero bounding box, they are of no use, and
- * will give problems in rtbuild_heuristic_object_split later */
- if (bb[0] == bb[3] && bb[1] == bb[4] && bb[2] == bb[5])
- return;
-
- copy_v3_v3(b->primitives.end->bb, bb);
- copy_v3_v3(b->primitives.end->bb + 3, bb + 3);
- b->primitives.end->obj = o;
- b->primitives.end->cost = RE_rayobject_cost(o);
-
- for (int i = 0; i < 3; i++) {
- *(b->sorted_end[i]) = b->primitives.end;
- b->sorted_end[i]++;
- }
- b->primitives.end++;
-}
-
-int rtbuild_size(RTBuilder *b)
-{
- return b->sorted_end[0] - b->sorted_begin[0];
-}
-
-
-template<class Obj, int Axis>
-static bool obj_bb_compare(const Obj &a, const Obj &b)
-{
- if (a->bb[Axis] != b->bb[Axis])
- return a->bb[Axis] < b->bb[Axis];
- return a->obj < b->obj;
-}
-
-template<class Item>
-static void object_sort(Item *begin, Item *end, int axis)
-{
- if (axis == 0) return std::sort(begin, end, obj_bb_compare<Item, 0> );
- if (axis == 1) return std::sort(begin, end, obj_bb_compare<Item, 1> );
- if (axis == 2) return std::sort(begin, end, obj_bb_compare<Item, 2> );
- assert(false);
-}
-
-void rtbuild_done(RTBuilder *b, RayObjectControl *ctrl)
-{
- for (int i = 0; i < 3; i++) {
- if (b->sorted_begin[i]) {
- if (RE_rayobjectcontrol_test_break(ctrl)) break;
- object_sort(b->sorted_begin[i], b->sorted_end[i], i);
- }
- }
-}
-
-RayObject *rtbuild_get_primitive(RTBuilder *b, int index)
-{
- return b->sorted_begin[0][index]->obj;
-}
-
-RTBuilder *rtbuild_get_child(RTBuilder *b, int child, RTBuilder *tmp)
-{
- rtbuild_init(tmp);
-
- tmp->depth = b->depth + 1;
-
- for (int i = 0; i < 3; i++)
- if (b->sorted_begin[i]) {
- tmp->sorted_begin[i] = b->sorted_begin[i] + b->child_offset[child];
- tmp->sorted_end[i] = b->sorted_begin[i] + b->child_offset[child + 1];
- }
- else {
- tmp->sorted_begin[i] = NULL;
- tmp->sorted_end[i] = NULL;
- }
-
- return tmp;
-}
-
-static void rtbuild_calc_bb(RTBuilder *b)
-{
- if (b->bb[0] == 1.0e30f) {
- for (RTBuilder::Object **index = b->sorted_begin[0]; index != b->sorted_end[0]; index++)
- RE_rayobject_merge_bb( (*index)->obj, b->bb, b->bb + 3);
- }
-}
-
-void rtbuild_merge_bb(RTBuilder *b, float min[3], float max[3])
-{
- rtbuild_calc_bb(b);
- DO_MIN(b->bb, min);
- DO_MAX(b->bb + 3, max);
-}
-
-#if 0
-int rtbuild_get_largest_axis(RTBuilder *b)
-{
- rtbuild_calc_bb(b);
- return bb_largest_axis(b->bb, b->bb + 3);
-}
-
-//Left balanced tree
-int rtbuild_mean_split(RTBuilder *b, int nchilds, int axis)
-{
- int i;
- int mleafs_per_child, Mleafs_per_child;
- int tot_leafs = rtbuild_size(b);
- int missing_leafs;
-
- long long s;
-
- assert(nchilds <= RTBUILD_MAX_CHILDS);
-
- //TODO optimize calc of leafs_per_child
- for (s = nchilds; s < tot_leafs; s *= nchilds) ;
- Mleafs_per_child = s / nchilds;
- mleafs_per_child = Mleafs_per_child / nchilds;
-
- //split min leafs per child
- b->child_offset[0] = 0;
- for (i = 1; i <= nchilds; i++)
- b->child_offset[i] = mleafs_per_child;
-
- //split remaining leafs
- missing_leafs = tot_leafs - mleafs_per_child * nchilds;
- for (i = 1; i <= nchilds; i++)
- {
- if (missing_leafs > Mleafs_per_child - mleafs_per_child)
- {
- b->child_offset[i] += Mleafs_per_child - mleafs_per_child;
- missing_leafs -= Mleafs_per_child - mleafs_per_child;
- }
- else {
- b->child_offset[i] += missing_leafs;
- missing_leafs = 0;
- break;
- }
- }
-
- //adjust for accumulative offsets
- for (i = 1; i <= nchilds; i++)
- b->child_offset[i] += b->child_offset[i - 1];
-
- //Count created childs
- for (i = nchilds; b->child_offset[i] == b->child_offset[i - 1]; i--) ;
- split_leafs(b, b->child_offset, i, axis);
-
- assert(b->child_offset[0] == 0 && b->child_offset[i] == tot_leafs);
- return i;
-}
-
-
-int rtbuild_mean_split_largest_axis(RTBuilder *b, int nchilds)
-{
- int axis = rtbuild_get_largest_axis(b);
- return rtbuild_mean_split(b, nchilds, axis);
-}
-#endif
-
-/*
- * "separators" is an array of dim NCHILDS-1
- * and indicates where to cut the childs
- */
-#if 0
-int rtbuild_median_split(RTBuilder *b, float *separators, int nchilds, int axis)
-{
- int size = rtbuild_size(b);
-
- assert(nchilds <= RTBUILD_MAX_CHILDS);
- if (size <= nchilds)
- {
- return rtbuild_mean_split(b, nchilds, axis);
- }
- else {
- int i;
-
- b->split_axis = axis;
-
- //Calculate child offsets
- b->child_offset[0] = 0;
- for (i = 0; i < nchilds - 1; i++)
- b->child_offset[i + 1] = split_leafs_by_plane(b, b->child_offset[i], size, separators[i]);
- b->child_offset[nchilds] = size;
-
- for (i = 0; i < nchilds; i++)
- if (b->child_offset[i + 1] - b->child_offset[i] == size)
- return rtbuild_mean_split(b, nchilds, axis);
-
- return nchilds;
- }
-}
-
-int rtbuild_median_split_largest_axis(RTBuilder *b, int nchilds)
-{
- int la, i;
- float separators[RTBUILD_MAX_CHILDS];
-
- rtbuild_calc_bb(b);
-
- la = bb_largest_axis(b->bb, b->bb + 3);
- for (i = 1; i < nchilds; i++)
- separators[i - 1] = (b->bb[la + 3] - b->bb[la]) * i / nchilds;
-
- return rtbuild_median_split(b, separators, nchilds, la);
-}
-#endif
-
-//Heuristics Object Splitter
-
-
-struct SweepCost {
- float bb[6];
- float cost;
-};
-
-/* Object Surface Area Heuristic splitter */
-int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds)
-{
- int size = rtbuild_size(b);
- assert(nchilds == 2);
- assert(size > 1);
- int baxis = -1, boffset = 0;
-
- if (size > nchilds) {
- if (b->depth > RTBUILD_MAX_SAH_DEPTH) {
- // for degenerate cases we avoid running out of stack space
- // by simply splitting the children in the middle
- b->child_offset[0] = 0;
- b->child_offset[1] = (size+1)/2;
- b->child_offset[2] = size;
- return 2;
- }
-
- float bcost = FLT_MAX;
- baxis = -1;
- boffset = size / 2;
-
- SweepCost *sweep = (SweepCost *)MEM_mallocN(sizeof(SweepCost) * size, "RTBuilder.HeuristicSweep");
-
- for (int axis = 0; axis < 3; axis++) {
- SweepCost sweep_left;
-
- RTBuilder::Object **obj = b->sorted_begin[axis];
-
-// float right_cost = 0;
- for (int i = size - 1; i >= 0; i--) {
- if (i == size - 1) {
- copy_v3_v3(sweep[i].bb, obj[i]->bb);
- copy_v3_v3(sweep[i].bb + 3, obj[i]->bb + 3);
- sweep[i].cost = obj[i]->cost;
- }
- else {
- sweep[i].bb[0] = min_ff(obj[i]->bb[0], sweep[i + 1].bb[0]);
- sweep[i].bb[1] = min_ff(obj[i]->bb[1], sweep[i + 1].bb[1]);
- sweep[i].bb[2] = min_ff(obj[i]->bb[2], sweep[i + 1].bb[2]);
- sweep[i].bb[3] = max_ff(obj[i]->bb[3], sweep[i + 1].bb[3]);
- sweep[i].bb[4] = max_ff(obj[i]->bb[4], sweep[i + 1].bb[4]);
- sweep[i].bb[5] = max_ff(obj[i]->bb[5], sweep[i + 1].bb[5]);
- sweep[i].cost = obj[i]->cost + sweep[i + 1].cost;
- }
-// right_cost += obj[i]->cost;
- }
-
- sweep_left.bb[0] = obj[0]->bb[0];
- sweep_left.bb[1] = obj[0]->bb[1];
- sweep_left.bb[2] = obj[0]->bb[2];
- sweep_left.bb[3] = obj[0]->bb[3];
- sweep_left.bb[4] = obj[0]->bb[4];
- sweep_left.bb[5] = obj[0]->bb[5];
- sweep_left.cost = obj[0]->cost;
-
-// right_cost -= obj[0]->cost; if (right_cost < 0) right_cost = 0;
-
- for (int i = 1; i < size; i++) {
- //Worst case heuristic (cost of each child is linear)
- float hcost, left_side, right_side;
-
- // not using log seems to have no impact on raytracing perf, but
- // makes tree construction quicker, left out for now to test (brecht)
- // left_side = bb_area(sweep_left.bb, sweep_left.bb + 3) * (sweep_left.cost + logf((float)i));
- // right_side = bb_area(sweep[i].bb, sweep[i].bb + 3) * (sweep[i].cost + logf((float)size - i));
- left_side = bb_area(sweep_left.bb, sweep_left.bb + 3) * (sweep_left.cost);
- right_side = bb_area(sweep[i].bb, sweep[i].bb + 3) * (sweep[i].cost);
- hcost = left_side + right_side;
-
- assert(left_side >= 0);
- assert(right_side >= 0);
-
- if (left_side > bcost) break; //No way we can find a better heuristic in this axis
-
- assert(hcost >= 0);
- // this makes sure the tree built is the same whatever is the order of the sorting axis
- if (hcost < bcost || (hcost == bcost && axis < baxis)) {
- bcost = hcost;
- baxis = axis;
- boffset = i;
- }
- DO_MIN(obj[i]->bb, sweep_left.bb);
- DO_MAX(obj[i]->bb + 3, sweep_left.bb + 3);
-
- sweep_left.cost += obj[i]->cost;
-// right_cost -= obj[i]->cost; if (right_cost < 0) right_cost = 0;
- }
-
- //assert(baxis >= 0 && baxis < 3);
- if (!(baxis >= 0 && baxis < 3))
- baxis = 0;
- }
-
-
- MEM_freeN(sweep);
- }
- else if (size == 2) {
- baxis = 0;
- boffset = 1;
- }
- else if (size == 1) {
- b->child_offset[0] = 0;
- b->child_offset[1] = 1;
- return 1;
- }
-
- b->child_offset[0] = 0;
- b->child_offset[1] = boffset;
- b->child_offset[2] = size;
-
-
- /* Adjust sorted arrays for childs */
- for (int i = 0; i < boffset; i++) b->sorted_begin[baxis][i]->selected = true;
- for (int i = boffset; i < size; i++) b->sorted_begin[baxis][i]->selected = false;
- for (int i = 0; i < 3; i++)
- std::stable_partition(b->sorted_begin[i], b->sorted_end[i], selected_node);
-
- return nchilds;
-}
-
-/*
- * Helper code
- * PARTITION code / used on mean-split
- * basically this a std::nth_element (like on C++ STL algorithm)
- */
-#if 0
-static void split_leafs(RTBuilder *b, int *nth, int partitions, int split_axis)
-{
- int i;
- b->split_axis = split_axis;
-
- for (i = 0; i < partitions - 1; i++)
- {
- assert(nth[i] < nth[i + 1] && nth[i + 1] < nth[partitions]);
-
- if (split_axis == 0) std::nth_element(b, nth[i], nth[i + 1], nth[partitions], obj_bb_compare<RTBuilder::Object, 0>);
- if (split_axis == 1) std::nth_element(b, nth[i], nth[i + 1], nth[partitions], obj_bb_compare<RTBuilder::Object, 1>);
- if (split_axis == 2) std::nth_element(b, nth[i], nth[i + 1], nth[partitions], obj_bb_compare<RTBuilder::Object, 2>);
- }
-}
-#endif
-
-/*
- * Bounding Box utils
- */
-float bb_volume(const float min[3], const float max[3])
-{
- return (max[0] - min[0]) * (max[1] - min[1]) * (max[2] - min[2]);
-}
-
-float bb_area(const float min[3], const float max[3])
-{
- float sub[3], a;
- sub[0] = max[0] - min[0];
- sub[1] = max[1] - min[1];
- sub[2] = max[2] - min[2];
-
- a = (sub[0] * sub[1] + sub[0] * sub[2] + sub[1] * sub[2]) * 2.0f;
- /* used to have an assert() here on negative results
- * however, in this case its likely some overflow or ffast math error.
- * so just return 0.0f instead. */
- return a < 0.0f ? 0.0f : a;
-}
-
-int bb_largest_axis(const float min[3], const float max[3])
-{
- float sub[3];
-
- sub[0] = max[0] - min[0];
- sub[1] = max[1] - min[1];
- sub[2] = max[2] - min[2];
- if (sub[0] > sub[1]) {
- if (sub[0] > sub[2])
- return 0;
- else
- return 2;
- }
- else {
- if (sub[1] > sub[2])
- return 1;
- else
- return 2;
- }
-}
-
-/* only returns 0 if merging inner and outerbox would create a box larger than outer box */
-int bb_fits_inside(const float outer_min[3], const float outer_max[3],
- const float inner_min[3], const float inner_max[3])
-{
- int i;
- for (i = 0; i < 3; i++)
- if (outer_min[i] > inner_min[i]) return 0;
-
- for (i = 0; i < 3; i++)
- if (outer_max[i] < inner_max[i]) return 0;
-
- return 1;
-}
diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.h b/source/blender/render/intern/raytrace/rayobject_rtbuild.h
deleted file mode 100644
index 061d76e3a3e..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_rtbuild.h
+++ /dev/null
@@ -1,125 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_rtbuild.h
- * \ingroup render
- */
-
-#ifndef __RAYOBJECT_RTBUILD_H__
-#define __RAYOBJECT_RTBUILD_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "rayobject.h"
-
-
-/*
- * Ray Tree Builder
- * this structs helps building any type of tree
- * it contains several methods to organize/split nodes
- * allowing to create a given tree on the fly.
- *
- * Idea is that other trees BVH, BIH can use this code to
- * generate with simple calls, and then convert to the theirs
- * specific structure on the fly.
- */
-#define RTBUILD_MAX_CHILDS 32
-#define RTBUILD_MAX_SAH_DEPTH 256
-
-
-typedef struct RTBuilder {
- struct Object {
- RayObject *obj;
- float cost;
- float bb[6];
- int selected;
- };
-
- /* list to all primitives added in this tree */
- struct {
- Object *begin, *end;
- int maxsize;
- } primitives;
-
- /* sorted list of rayobjects */
- struct Object **sorted_begin[3], **sorted_end[3];
-
- /* axis used (if any) on the split method */
- int split_axis;
-
- /* child partitions calculated during splitting */
- int child_offset[RTBUILD_MAX_CHILDS + 1];
-
-// int child_sorted_axis; /* -1 if not sorted */
-
- float bb[6];
-
- /* current depth */
- int depth;
-} RTBuilder;
-
-/* used during creation */
-RTBuilder *rtbuild_create(int size);
-void rtbuild_free(RTBuilder *b);
-void rtbuild_add(RTBuilder *b, RayObject *o);
-void rtbuild_done(RTBuilder *b, RayObjectControl *c);
-void rtbuild_merge_bb(RTBuilder *b, float min[3], float max[3]);
-int rtbuild_size(RTBuilder *b);
-
-RayObject *rtbuild_get_primitive(RTBuilder *b, int offset);
-
-/* used during tree reorganization */
-RTBuilder *rtbuild_get_child(RTBuilder *b, int child, RTBuilder *tmp);
-
-/* Calculates child partitions and returns number of efectively needed partitions */
-int rtbuild_get_largest_axis(RTBuilder *b);
-
-//Object partition
-int rtbuild_mean_split(RTBuilder *b, int nchilds, int axis);
-int rtbuild_mean_split_largest_axis(RTBuilder *b, int nchilds);
-
-int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds);
-
-//Space partition
-int rtbuild_median_split(RTBuilder *b, float *separators, int nchilds, int axis);
-int rtbuild_median_split_largest_axis(RTBuilder *b, int nchilds);
-
-
-/* bb utils */
-float bb_area(const float min[3], const float max[3]);
-float bb_volume(const float min[3], const float max[3]);
-int bb_largest_axis(const float min[3], const float max[3]);
-int bb_fits_inside(const float outer_min[3], const float outer_max[3],
- const float inner_min[3], const float inner_max[3]);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __RAYOBJECT_RTBUILD_H__ */
diff --git a/source/blender/render/intern/raytrace/rayobject_svbvh.cpp b/source/blender/render/intern/raytrace/rayobject_svbvh.cpp
deleted file mode 100644
index eb7dddac06e..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_svbvh.cpp
+++ /dev/null
@@ -1,192 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_svbvh.cpp
- * \ingroup render
- */
-
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_utildefines.h"
-
-#include "vbvh.h"
-#include "svbvh.h"
-#include "reorganize.h"
-
-#ifdef __SSE__
-
-#define DFS_STACK_SIZE 256
-
-struct SVBVHTree {
- RayObject rayobj;
-
- SVBVHNode *root;
- MemArena *node_arena;
-
- float cost;
- RTBuilder *builder;
-};
-
-/*
- * Cost to test N childs
- */
-struct PackCost {
- float operator()(int n)
- {
- return (n / 4) + ((n % 4) > 2 ? 1 : n % 4);
- }
-};
-
-
-template<>
-void bvh_done<SVBVHTree>(SVBVHTree *obj)
-{
- rtbuild_done(obj->builder, &obj->rayobj.control);
-
- //TODO find a away to exactly calculate the needed memory
- MemArena *arena1 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "svbvh arena");
- BLI_memarena_use_malloc(arena1);
-
- MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "svbvh arena2");
- BLI_memarena_use_malloc(arena2);
- BLI_memarena_use_align(arena2, 16);
-
- //Build and optimize the tree
- if (0) {
- VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder);
-
- if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) {
- BLI_memarena_free(arena1);
- BLI_memarena_free(arena2);
- return;
- }
-
- reorganize(root);
- remove_useless(root, &root);
- bvh_refit(root);
-
- pushup(root);
- pushdown(root);
- pushup_simd<VBVHNode, 4>(root);
-
- obj->root = Reorganize_SVBVH<VBVHNode>(arena2).transform(root);
- }
- else {
- //Finds the optimal packing of this tree using a given cost model
- //TODO this uses quite a lot of memory, find ways to reduce memory usage during building
- OVBVHNode *root = BuildBinaryVBVH<OVBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder);
-
- if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) {
- BLI_memarena_free(arena1);
- BLI_memarena_free(arena2);
- return;
- }
-
- if (root) {
- VBVH_optimalPackSIMD<OVBVHNode, PackCost>(PackCost()).transform(root);
- obj->root = Reorganize_SVBVH<OVBVHNode>(arena2).transform(root);
- }
- else
- obj->root = NULL;
- }
-
- //Free data
- BLI_memarena_free(arena1);
-
- obj->node_arena = arena2;
- obj->cost = 1.0;
-
- rtbuild_free(obj->builder);
- obj->builder = NULL;
-}
-
-template<int StackSize>
-static int intersect(SVBVHTree *obj, Isect *isec)
-{
- //TODO renable hint support
- if (RE_rayobject_isAligned(obj->root)) {
- if (isec->mode == RE_RAY_SHADOW)
- return svbvh_node_stack_raycast<StackSize, true>(obj->root, isec);
- else
- return svbvh_node_stack_raycast<StackSize, false>(obj->root, isec);
- }
- else
- return RE_rayobject_intersect( (RayObject *) obj->root, isec);
-}
-
-template<class Tree>
-static void bvh_hint_bb(Tree *tree, LCTSHint *hint, float *UNUSED(min), float *UNUSED(max))
-{
- //TODO renable hint support
- {
- hint->size = 0;
- hint->stack[hint->size++] = (RayObject *)tree->root;
- }
-}
-/* the cast to pointer function is needed to workarround gcc bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11407 */
-template<class Tree, int STACK_SIZE>
-static RayObjectAPI make_api()
-{
- static RayObjectAPI api =
- {
- (RE_rayobject_raycast_callback) ((int (*)(Tree *, Isect *)) & intersect<STACK_SIZE>),
- (RE_rayobject_add_callback) ((void (*)(Tree *, RayObject *)) & bvh_add<Tree>),
- (RE_rayobject_done_callback) ((void (*)(Tree *)) & bvh_done<Tree>),
- (RE_rayobject_free_callback) ((void (*)(Tree *)) & bvh_free<Tree>),
- (RE_rayobject_merge_bb_callback)((void (*)(Tree *, float *, float *)) & bvh_bb<Tree>),
- (RE_rayobject_cost_callback) ((float (*)(Tree *)) & bvh_cost<Tree>),
- (RE_rayobject_hint_bb_callback) ((void (*)(Tree *, LCTSHint *, float *, float *)) & bvh_hint_bb<Tree>)
- };
-
- return api;
-}
-
-template<class Tree>
-static RayObjectAPI *bvh_get_api(int maxstacksize)
-{
- static RayObjectAPI bvh_api256 = make_api<Tree, 1024>();
-
- if (maxstacksize <= 1024) return &bvh_api256;
- assert(maxstacksize <= 256);
- return NULL;
-}
-
-RayObject *RE_rayobject_svbvh_create(int size)
-{
- return bvh_create_tree<SVBVHTree, DFS_STACK_SIZE>(size);
-}
-
-#else
-
-RayObject *RE_rayobject_svbvh_create(int UNUSED(size))
-{
- puts("WARNING: SSE disabled at compile time\n");
- return NULL;
-}
-
-#endif
diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp
deleted file mode 100644
index dfa5a69b335..00000000000
--- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp
+++ /dev/null
@@ -1,206 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/rayobject_vbvh.cpp
- * \ingroup render
- */
-
-
-int tot_pushup = 0;
-int tot_pushdown = 0;
-int tot_hints = 0;
-
-#include <assert.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_memarena.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_global.h"
-
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "rayobject_rtbuild.h"
-
-#include "reorganize.h"
-#include "bvh.h"
-#include "vbvh.h"
-
-#include <queue>
-#include <algorithm>
-
-#define DFS_STACK_SIZE 256
-
-struct VBVHTree {
- RayObject rayobj;
- VBVHNode *root;
- MemArena *node_arena;
- float cost;
- RTBuilder *builder;
-};
-
-/*
- * Cost to test N childs
- */
-struct PackCost {
- float operator()(int n)
- {
- return n;
- }
-};
-
-template<>
-void bvh_done<VBVHTree>(VBVHTree *obj)
-{
- rtbuild_done(obj->builder, &obj->rayobj.control);
-
- //TODO find a away to exactly calculate the needed memory
- MemArena *arena1 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "vbvh arena");
- BLI_memarena_use_malloc(arena1);
-
- //Build and optimize the tree
- if (1) {
- VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder);
- if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) {
- BLI_memarena_free(arena1);
- return;
- }
-
- if (root) {
- reorganize(root);
- remove_useless(root, &root);
- bvh_refit(root);
-
- pushup(root);
- pushdown(root);
- obj->root = root;
- }
- else
- obj->root = NULL;
- }
- else {
- /* TODO */
-#if 0
- MemArena *arena2 = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "vbvh arena2");
- BLI_memarena_use_malloc(arena2);
-
- //Finds the optimal packing of this tree using a given cost model
- //TODO this uses quite a lot of memory, find ways to reduce memory usage during building
- OVBVHNode *root = BuildBinaryVBVH<OVBVHNode>(arena2).transform(obj->builder);
- VBVH_optimalPackSIMD<OVBVHNode, PackCost>(PackCost()).transform(root);
- obj->root = Reorganize_VBVH<OVBVHNode>(arena1).transform(root);
-
- BLI_memarena_free(arena2);
-#endif
- }
-
- //Cleanup
- rtbuild_free(obj->builder);
- obj->builder = NULL;
-
- obj->node_arena = arena1;
- obj->cost = 1.0;
-}
-
-template<int StackSize>
-static int intersect(VBVHTree *obj, Isect *isec)
-{
- //TODO renable hint support
- if (RE_rayobject_isAligned(obj->root)) {
- if (isec->mode == RE_RAY_SHADOW)
- return bvh_node_stack_raycast<VBVHNode, StackSize, false, true>(obj->root, isec);
- else
- return bvh_node_stack_raycast<VBVHNode, StackSize, false, false>(obj->root, isec);
- }
- else
- return RE_rayobject_intersect( (RayObject *) obj->root, isec);
-}
-
-template<class Tree>
-static void bvh_hint_bb(Tree *tree, LCTSHint *hint, float *UNUSED(min), float *UNUSED(max))
-{
- //TODO renable hint support
- {
- hint->size = 0;
- hint->stack[hint->size++] = (RayObject *)tree->root;
- }
-}
-
-#if 0 /* UNUSED */
-static void bfree(VBVHTree *tree)
-{
- if (tot_pushup + tot_pushdown + tot_hints + tot_moves) {
- if (G.debug & G_DEBUG) {
- printf("tot pushups: %d\n", tot_pushup);
- printf("tot pushdowns: %d\n", tot_pushdown);
- printf("tot moves: %d\n", tot_moves);
- printf("tot hints created: %d\n", tot_hints);
- }
-
- tot_pushup = 0;
- tot_pushdown = 0;
- tot_hints = 0;
- tot_moves = 0;
- }
- bvh_free(tree);
-}
-#endif
-
-/* the cast to pointer function is needed to workarround gcc bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11407 */
-template<class Tree, int STACK_SIZE>
-static RayObjectAPI make_api()
-{
- static RayObjectAPI api =
- {
- (RE_rayobject_raycast_callback) ((int (*)(Tree *, Isect *)) & intersect<STACK_SIZE>),
- (RE_rayobject_add_callback) ((void (*)(Tree *, RayObject *)) & bvh_add<Tree>),
- (RE_rayobject_done_callback) ((void (*)(Tree *)) & bvh_done<Tree>),
- (RE_rayobject_free_callback) ((void (*)(Tree *)) & bvh_free<Tree>),
- (RE_rayobject_merge_bb_callback)((void (*)(Tree *, float *, float *)) & bvh_bb<Tree>),
- (RE_rayobject_cost_callback) ((float (*)(Tree *)) & bvh_cost<Tree>),
- (RE_rayobject_hint_bb_callback) ((void (*)(Tree *, LCTSHint *, float *, float *)) & bvh_hint_bb<Tree>)
- };
-
- return api;
-}
-
-template<class Tree>
-RayObjectAPI *bvh_get_api(int maxstacksize)
-{
- static RayObjectAPI bvh_api256 = make_api<Tree, 1024>();
-
- if (maxstacksize <= 1024) return &bvh_api256;
- assert(maxstacksize <= 256);
- return 0;
-}
-
-RayObject *RE_rayobject_vbvh_create(int size)
-{
- return bvh_create_tree<VBVHTree, DFS_STACK_SIZE>(size);
-}
diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h
deleted file mode 100644
index 84d04a8851f..00000000000
--- a/source/blender/render/intern/raytrace/reorganize.h
+++ /dev/null
@@ -1,513 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/reorganize.h
- * \ingroup render
- */
-
-
-#include <float.h>
-#include <math.h>
-#include <stdio.h>
-
-#include <algorithm>
-#include <queue>
-#include <vector>
-
-#include "BKE_global.h"
-
-#ifdef _WIN32
-# ifdef INFINITY
-# undef INFINITY
-# endif
-# define INFINITY FLT_MAX // in mingw math.h: (1.0F/0.0F). This generates compile error, though.
-#endif
-
-extern int tot_pushup;
-extern int tot_pushdown;
-
-#if !defined(INFINITY) && defined(HUGE_VAL)
-#define INFINITY HUGE_VAL
-#endif
-
-template<class Node>
-static bool node_fits_inside(Node *a, Node *b)
-{
- return bb_fits_inside(b->bb, b->bb + 3, a->bb, a->bb + 3);
-}
-
-template<class Node>
-static void reorganize_find_fittest_parent(Node *tree, Node *node, std::pair<float, Node *> &cost)
-{
- std::queue<Node *> q;
- q.push(tree);
-
- while (!q.empty()) {
- Node *parent = q.front();
- q.pop();
-
- if (parent == node) continue;
- if (node_fits_inside(node, parent) && RE_rayobject_isAligned(parent->child) ) {
- float pcost = bb_area(parent->bb, parent->bb + 3);
- cost = std::min(cost, std::make_pair(pcost, parent) );
- for (Node *child = parent->child; child; child = child->sibling)
- q.push(child);
- }
- }
-}
-
-template<class Node>
-static void reorganize(Node *root)
-{
- std::queue<Node *> q;
-
- q.push(root);
- while (!q.empty()) {
- Node *node = q.front();
- q.pop();
-
- if (RE_rayobject_isAligned(node->child)) {
- for (Node **prev = &node->child; *prev; ) {
- assert(RE_rayobject_isAligned(*prev));
- q.push(*prev);
-
- std::pair<float, Node *> best(FLT_MAX, root);
- reorganize_find_fittest_parent(root, *prev, best);
-
- if (best.second == node) {
- //Already inside the fitnest BB
- prev = &(*prev)->sibling;
- }
- else {
- Node *tmp = *prev;
- *prev = (*prev)->sibling;
-
- tmp->sibling = best.second->child;
- best.second->child = tmp;
- }
-
-
- }
- }
- if (node != root) {
- }
- }
-}
-
-/*
- * Prunes useless nodes from trees:
- * erases nodes with total amount of primitives = 0
- * prunes nodes with only one child (except if that child is a primitive)
- */
-template<class Node>
-static void remove_useless(Node *node, Node **new_node)
-{
- if (RE_rayobject_isAligned(node->child) ) {
-
- for (Node **prev = &node->child; *prev; ) {
- Node *next = (*prev)->sibling;
- remove_useless(*prev, prev);
- if (*prev == NULL)
- *prev = next;
- else {
- (*prev)->sibling = next;
- prev = &((*prev)->sibling);
- }
- }
- }
- if (node->child) {
- if (RE_rayobject_isAligned(node->child) && node->child->sibling == 0)
- *new_node = node->child;
- }
- else if (node->child == NULL) {
- *new_node = NULL;
- }
-}
-
-/*
- * Minimizes expected number of BBtest by colapsing nodes
- * it uses surface area heuristic for determining whether a node should be colapsed
- */
-template<class Node>
-static void pushup(Node *parent)
-{
- if (is_leaf(parent)) return;
-
- float p_area = bb_area(parent->bb, parent->bb + 3);
- Node **prev = &parent->child;
- for (Node *child = parent->child; RE_rayobject_isAligned(child) && child; ) {
- const float c_area = bb_area(child->bb, child->bb + 3);
- const int nchilds = count_childs(child);
- float original_cost = ((p_area != 0.0f) ? (c_area / p_area) * nchilds : 1.0f) + 1;
- float flatten_cost = nchilds;
- if (flatten_cost < original_cost && nchilds >= 2) {
- append_sibling(child, child->child);
- child = child->sibling;
- *prev = child;
-
-// *prev = child->child;
-// append_sibling( *prev, child->sibling );
-// child = *prev;
- tot_pushup++;
- }
- else {
- *prev = child;
- prev = &(*prev)->sibling;
- child = *prev;
- }
- }
-
- for (Node *child = parent->child; RE_rayobject_isAligned(child) && child; child = child->sibling)
- pushup(child);
-}
-
-/*
- * try to optimize number of childs to be a multiple of SSize
- */
-template<class Node, int SSize>
-static void pushup_simd(Node *parent)
-{
- if (is_leaf(parent)) return;
-
- int n = count_childs(parent);
-
- Node **prev = &parent->child;
- for (Node *child = parent->child; RE_rayobject_isAligned(child) && child; ) {
- int cn = count_childs(child);
- if (cn - 1 <= (SSize - (n % SSize) ) % SSize && RE_rayobject_isAligned(child->child) ) {
- n += (cn - 1);
- append_sibling(child, child->child);
- child = child->sibling;
- *prev = child;
- }
- else {
- *prev = child;
- prev = &(*prev)->sibling;
- child = *prev;
- }
- }
-
- for (Node *child = parent->child; RE_rayobject_isAligned(child) && child; child = child->sibling)
- pushup_simd<Node, SSize>(child);
-}
-
-
-/*
- * Pushdown
- * makes sure no child fits inside any of its sibling
- */
-template<class Node>
-static void pushdown(Node *parent)
-{
- Node **s_child = &parent->child;
- Node *child = parent->child;
-
- while (child && RE_rayobject_isAligned(child)) {
- Node *next = child->sibling;
- Node **next_s_child = &child->sibling;
-
- //assert(bb_fits_inside(parent->bb, parent->bb+3, child->bb, child->bb+3));
-
- for (Node *i = parent->child; RE_rayobject_isAligned(i) && i; i = i->sibling)
- if (child != i && bb_fits_inside(i->bb, i->bb + 3, child->bb, child->bb + 3) && RE_rayobject_isAligned(i->child)) {
-// todo optimize (should the one with the smallest area?)
-// float ia = bb_area(i->bb, i->bb+3)
-// if (child->i)
- *s_child = child->sibling;
- child->sibling = i->child;
- i->child = child;
- next_s_child = s_child;
-
- tot_pushdown++;
- break;
- }
- child = next;
- s_child = next_s_child;
- }
-
- for (Node *i = parent->child; RE_rayobject_isAligned(i) && i; i = i->sibling) {
- pushdown(i);
- }
-}
-
-
-/*
- * BVH refit
- * readjust nodes BB (useful if nodes childs where modified)
- */
-template<class Node>
-static float bvh_refit(Node *node)
-{
- if (is_leaf(node)) return 0;
- if (is_leaf(node->child)) return 0;
-
- float total = 0;
-
- for (Node *child = node->child; child; child = child->sibling)
- total += bvh_refit(child);
-
- float old_area = bb_area(node->bb, node->bb + 3);
- INIT_MINMAX(node->bb, node->bb + 3);
- for (Node *child = node->child; child; child = child->sibling) {
- DO_MIN(child->bb, node->bb);
- DO_MAX(child->bb + 3, node->bb + 3);
- }
- total += old_area - bb_area(node->bb, node->bb + 3);
- return total;
-}
-
-
-/*
- * this finds the best way to packing a tree according to a given test cost function
- * with the purpose to reduce the expected cost (eg.: number of BB tests).
- */
-#include <vector>
-#define MAX_CUT_SIZE 4 /* svbvh assumes max 4 children! */
-#define MAX_OPTIMIZE_CHILDS MAX_CUT_SIZE
-
-#define CUT_SIZE_IS_VALID(cut_size) ((cut_size) < MAX_CUT_SIZE && (cut_size) >= 0)
-#define CUT_SIZE_INVALID -1
-
-
-struct OVBVHNode {
- float bb[6];
-
- OVBVHNode *child;
- OVBVHNode *sibling;
-
- /*
- * Returns min cost to represent the subtree starting at the given node,
- * allowing it to have a given cutsize
- */
- float cut_cost[MAX_CUT_SIZE];
- float get_cost(int cutsize)
- {
- assert(CUT_SIZE_IS_VALID(cutsize - 1));
- return cut_cost[cutsize - 1];
- }
-
- /*
- * This saves the cut size of this child, when parent is reaching
- * its minimum cut with the given cut size
- */
- int cut_size[MAX_CUT_SIZE];
- int get_cut_size(int parent_cut_size)
- {
- assert(CUT_SIZE_IS_VALID(parent_cut_size - 1));
- return cut_size[parent_cut_size - 1];
- }
-
- /*
- * Reorganize the node based on calculated cut costs
- */
- int best_cutsize;
- void set_cut(int cutsize, OVBVHNode ***cut)
- {
- if (cutsize == 1) {
- **cut = this;
- *cut = &(**cut)->sibling;
- }
- else {
- if (cutsize > MAX_CUT_SIZE) {
- for (OVBVHNode *child = this->child; child && RE_rayobject_isAligned(child); child = child->sibling) {
- child->set_cut(1, cut);
- cutsize--;
- }
- assert(cutsize == 0);
- }
- else {
- for (OVBVHNode *child = this->child; child && RE_rayobject_isAligned(child); child = child->sibling) {
- child->set_cut(child->get_cut_size(cutsize), cut);
- }
- }
- }
- }
-
- void optimize()
- {
- if (RE_rayobject_isAligned(this->child)) {
- //Calc new childs
- if (this->best_cutsize != CUT_SIZE_INVALID) {
- OVBVHNode **cut = &(this->child);
- set_cut(this->best_cutsize, &cut);
- *cut = NULL;
- }
-
- //Optimize new childs
- for (OVBVHNode *child = this->child; child && RE_rayobject_isAligned(child); child = child->sibling)
- child->optimize();
- }
- }
-};
-
-/*
- * Calculates an optimal SIMD packing
- *
- */
-template<class Node, class TestCost>
-struct VBVH_optimalPackSIMD {
- TestCost testcost;
-
- VBVH_optimalPackSIMD(TestCost testcost)
- {
- this->testcost = testcost;
- }
-
- /*
- * calc best cut on a node
- */
- struct calc_best {
- Node *child[MAX_OPTIMIZE_CHILDS];
- float child_hit_prob[MAX_OPTIMIZE_CHILDS];
-
- calc_best(Node *node)
- {
- int nchilds = 0;
- //Fetch childs and needed data
- {
- float parent_area = bb_area(node->bb, node->bb + 3);
- for (Node *child = node->child; child && RE_rayobject_isAligned(child); child = child->sibling) {
- this->child[nchilds] = child;
- this->child_hit_prob[nchilds] = (parent_area != 0.0f) ? bb_area(child->bb, child->bb + 3) / parent_area : 1.0f;
- nchilds++;
- }
-
- assert(nchilds >= 2 && nchilds <= MAX_OPTIMIZE_CHILDS);
- }
-
-
- //Build DP table to find minimum cost to represent this node with a given cutsize
- int bt[MAX_OPTIMIZE_CHILDS + 1][MAX_CUT_SIZE + 1]; //backtrace table
- float cost[MAX_OPTIMIZE_CHILDS + 1][MAX_CUT_SIZE + 1]; //cost table (can be reduced to float[2][MAX_CUT_COST])
-
- for (int i = 0; i <= nchilds; i++) {
- for (int j = 0; j <= MAX_CUT_SIZE; j++) {
- cost[i][j] = INFINITY;
- }
- }
-
- cost[0][0] = 0;
-
- for (int i = 1; i <= nchilds; i++) {
- for (int size = i - 1; size /*+(nchilds-i)*/ <= MAX_CUT_SIZE; size++) {
- for (int cut = 1; cut + size /*+(nchilds-i)*/ <= MAX_CUT_SIZE; cut++) {
- float new_cost = cost[i - 1][size] + child_hit_prob[i - 1] * child[i - 1]->get_cost(cut);
- if (new_cost < cost[i][size + cut]) {
- cost[i][size + cut] = new_cost;
- bt[i][size + cut] = cut;
- }
- }
- }
- }
-
- /* Save the ways to archive the minimum cost with a given cutsize */
- for (int i = nchilds; i <= MAX_CUT_SIZE; i++) {
- node->cut_cost[i - 1] = cost[nchilds][i];
- if (cost[nchilds][i] < INFINITY) {
- int current_size = i;
- for (int j = nchilds; j > 0; j--) {
- child[j - 1]->cut_size[i - 1] = bt[j][current_size];
- current_size -= bt[j][current_size];
- }
- }
- }
- }
- };
-
- void calc_costs(Node *node)
- {
-
- if (RE_rayobject_isAligned(node->child) ) {
- int nchilds = 0;
- for (Node *child = node->child; child && RE_rayobject_isAligned(child); child = child->sibling) {
- calc_costs(child);
- nchilds++;
- }
-
- for (int i = 0; i < MAX_CUT_SIZE; i++)
- node->cut_cost[i] = INFINITY;
-
- //We are not allowed to look on nodes with with so many childs
- if (nchilds > MAX_CUT_SIZE) {
- float cost = 0;
-
- float parent_area = bb_area(node->bb, node->bb + 3);
- for (Node *child = node->child; child && RE_rayobject_isAligned(child); child = child->sibling) {
- cost += ((parent_area != 0.0f) ? (bb_area(child->bb, child->bb + 3) / parent_area) : 1.0f) * child->get_cost(1);
- }
-
- cost += testcost(nchilds);
- node->cut_cost[0] = cost;
- node->best_cutsize = nchilds;
- }
- else {
- calc_best calc(node);
-
- //calc expected cost if we optimaly pack this node
- for (int cutsize = nchilds; cutsize <= MAX_CUT_SIZE; cutsize++) {
- float m = node->get_cost(cutsize) + testcost(cutsize);
- if (m < node->cut_cost[0]) {
- node->cut_cost[0] = m;
- node->best_cutsize = cutsize;
- }
- }
- }
-
- if (node->cut_cost[0] == INFINITY) {
- node->best_cutsize = CUT_SIZE_INVALID;
- }
- }
- else {
- node->cut_cost[0] = 1.0f;
- for (int i = 1; i < MAX_CUT_SIZE; i++)
- node->cut_cost[i] = INFINITY;
-
- /* node->best_cutsize can remain unset here */
- }
- }
-
- Node *transform(Node *node)
- {
- if (RE_rayobject_isAligned(node->child)) {
-#ifdef DEBUG
- static int num = 0;
- bool first = false;
- if (num == 0) { num++; first = true; }
-#endif
-
- calc_costs(node);
-
-#ifdef DEBUG
- if (first && G.debug) {
- printf("expected cost = %f (%d)\n", node->cut_cost[0], node->best_cutsize);
- }
-#endif
- node->optimize();
- }
- return node;
- }
-};
diff --git a/source/blender/render/intern/raytrace/svbvh.h b/source/blender/render/intern/raytrace/svbvh.h
deleted file mode 100644
index 292b93c445f..00000000000
--- a/source/blender/render/intern/raytrace/svbvh.h
+++ /dev/null
@@ -1,317 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/svbvh.h
- * \ingroup render
- */
-
-#ifndef __SVBVH_H__
-#define __SVBVH_H__
-
-#ifdef __SSE__
-
-#include "bvh.h"
-#include "BLI_memarena.h"
-#include <algorithm>
-
-struct SVBVHNode {
- float child_bb[24];
- SVBVHNode *child[4];
- int nchilds;
-};
-
-static int svbvh_bb_intersect_test_simd4(const Isect *isec, const __m128 *bb_group)
-{
- const __m128 tmin0 = _mm_setzero_ps();
- const __m128 tmax0 = _mm_set_ps1(isec->dist);
-
- const __m128 start0 = _mm_set_ps1(isec->start[0]);
- const __m128 start1 = _mm_set_ps1(isec->start[1]);
- const __m128 start2 = _mm_set_ps1(isec->start[2]);
- const __m128 sub0 = _mm_sub_ps(bb_group[isec->bv_index[0]], start0);
- const __m128 sub1 = _mm_sub_ps(bb_group[isec->bv_index[1]], start0);
- const __m128 sub2 = _mm_sub_ps(bb_group[isec->bv_index[2]], start1);
- const __m128 sub3 = _mm_sub_ps(bb_group[isec->bv_index[3]], start1);
- const __m128 sub4 = _mm_sub_ps(bb_group[isec->bv_index[4]], start2);
- const __m128 sub5 = _mm_sub_ps(bb_group[isec->bv_index[5]], start2);
- const __m128 idot_axis0 = _mm_set_ps1(isec->idot_axis[0]);
- const __m128 idot_axis1 = _mm_set_ps1(isec->idot_axis[1]);
- const __m128 idot_axis2 = _mm_set_ps1(isec->idot_axis[2]);
- const __m128 mul0 = _mm_mul_ps(sub0, idot_axis0);
- const __m128 mul1 = _mm_mul_ps(sub1, idot_axis0);
- const __m128 mul2 = _mm_mul_ps(sub2, idot_axis1);
- const __m128 mul3 = _mm_mul_ps(sub3, idot_axis1);
- const __m128 mul4 = _mm_mul_ps(sub4, idot_axis2);
- const __m128 mul5 = _mm_mul_ps(sub5, idot_axis2);
- const __m128 tmin1 = _mm_max_ps(tmin0, mul0);
- const __m128 tmax1 = _mm_min_ps(tmax0, mul1);
- const __m128 tmin2 = _mm_max_ps(tmin1, mul2);
- const __m128 tmax2 = _mm_min_ps(tmax1, mul3);
- const __m128 tmin3 = _mm_max_ps(tmin2, mul4);
- const __m128 tmax3 = _mm_min_ps(tmax2, mul5);
-
- return _mm_movemask_ps(_mm_cmpge_ps(tmax3, tmin3));
-}
-
-static int svbvh_bb_intersect_test(const Isect *isec, const float *_bb)
-{
- const float *bb = _bb;
-
- float t1x = (bb[isec->bv_index[0]] - isec->start[0]) * isec->idot_axis[0];
- float t2x = (bb[isec->bv_index[1]] - isec->start[0]) * isec->idot_axis[0];
- float t1y = (bb[isec->bv_index[2]] - isec->start[1]) * isec->idot_axis[1];
- float t2y = (bb[isec->bv_index[3]] - isec->start[1]) * isec->idot_axis[1];
- float t1z = (bb[isec->bv_index[4]] - isec->start[2]) * isec->idot_axis[2];
- float t2z = (bb[isec->bv_index[5]] - isec->start[2]) * isec->idot_axis[2];
-
- RE_RC_COUNT(isec->raycounter->bb.test);
-
- if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return 0;
- if (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return 0;
- if (t1x > isec->dist || t1y > isec->dist || t1z > isec->dist) return 0;
-
- RE_RC_COUNT(isec->raycounter->bb.hit);
-
- return 1;
-}
-
-static bool svbvh_node_is_leaf(const SVBVHNode *node)
-{
- return !RE_rayobject_isAligned(node);
-}
-
-template<int MAX_STACK_SIZE, bool SHADOW>
-static int svbvh_node_stack_raycast(SVBVHNode *root, Isect *isec)
-{
- SVBVHNode *stack[MAX_STACK_SIZE], *node;
- int hit = 0, stack_pos = 0;
-
- stack[stack_pos++] = root;
-
- while (stack_pos) {
- node = stack[--stack_pos];
-
- if (!svbvh_node_is_leaf(node)) {
- int nchilds = node->nchilds;
-
- if (nchilds == 4) {
- float *child_bb = node->child_bb;
- int res = svbvh_bb_intersect_test_simd4(isec, ((__m128 *) (child_bb)));
- SVBVHNode **child = node->child;
-
- RE_RC_COUNT(isec->raycounter->simd_bb.test);
-
- if (res & 1) { stack[stack_pos++] = child[0]; RE_RC_COUNT(isec->raycounter->simd_bb.hit); }
- if (res & 2) { stack[stack_pos++] = child[1]; RE_RC_COUNT(isec->raycounter->simd_bb.hit); }
- if (res & 4) { stack[stack_pos++] = child[2]; RE_RC_COUNT(isec->raycounter->simd_bb.hit); }
- if (res & 8) { stack[stack_pos++] = child[3]; RE_RC_COUNT(isec->raycounter->simd_bb.hit); }
- }
- else {
- float *child_bb = node->child_bb;
- SVBVHNode **child = node->child;
- int i;
-
- for (i = 0; i < nchilds; i++) {
- if (svbvh_bb_intersect_test(isec, (float *)child_bb + 6 * i)) {
- stack[stack_pos++] = child[i];
- }
- }
- }
- }
- else {
- hit |= RE_rayobject_intersect((RayObject *)node, isec);
- if (SHADOW && hit) break;
- }
- }
-
- return hit;
-}
-
-
-template<>
-inline void bvh_node_merge_bb<SVBVHNode>(SVBVHNode *node, float min[3], float max[3])
-{
- if (is_leaf(node)) {
- RE_rayobject_merge_bb((RayObject *)node, min, max);
- }
- else {
- int i;
- for (i = 0; i + 4 <= node->nchilds; i += 4) {
- float *res = node->child_bb + 6 * i;
- for (int j = 0; j < 3; j++) {
- min[j] = min_ff(min[j],
- min_ffff(res[4 * j + 0],
- res[4 * j + 1],
- res[4 * j + 2],
- res[4 * j + 3]));
- }
- for (int j = 0; j < 3; j++) {
- max[j] = max_ff(max[j],
- max_ffff(res[4 * (j + 3) + 0],
- res[4 * (j + 3) + 1],
- res[4 * (j + 3) + 2],
- res[4 * (j + 3) + 3]));
- }
- }
-
- for (; i < node->nchilds; i++) {
- DO_MIN(node->child_bb + 6 * i, min);
- DO_MAX(node->child_bb + 3 + 6 * i, max);
- }
- }
-}
-
-
-
-/*
- * Builds a SVBVH tree form a VBVHTree
- */
-template<class OldNode>
-struct Reorganize_SVBVH {
- MemArena *arena;
-
- float childs_per_node;
- int nodes_with_childs[16];
- int useless_bb;
- int nodes;
-
- Reorganize_SVBVH(MemArena *a)
- {
- arena = a;
- nodes = 0;
- childs_per_node = 0;
- useless_bb = 0;
-
- for (int i = 0; i < 16; i++) {
- nodes_with_childs[i] = 0;
- }
- }
-
- ~Reorganize_SVBVH()
- {
-#if 0
- {
- printf("%f childs per node\n", childs_per_node / nodes);
- printf("%d childs BB are useless\n", useless_bb);
- for (int i = 0; i < 16; i++) {
- printf("%i childs per node: %d/%d = %f\n", i, nodes_with_childs[i], nodes, nodes_with_childs[i] / float(nodes));
- }
- }
-#endif
- }
-
- SVBVHNode *create_node(int nchilds)
- {
- SVBVHNode *node = (SVBVHNode *)BLI_memarena_alloc(arena, sizeof(SVBVHNode));
- node->nchilds = nchilds;
-
- return node;
- }
-
- void copy_bb(float bb[6], const float old_bb[6])
- {
- std::copy(old_bb, old_bb + 6, bb);
- }
-
- void prepare_for_simd(SVBVHNode *node)
- {
- int i = 0;
- while (i + 4 <= node->nchilds) {
- float vec_tmp[4 * 6];
- float *res = node->child_bb + 6 * i;
- std::copy(res, res + 6 * 4, vec_tmp);
-
- for (int j = 0; j < 6; j++) {
- res[4 * j + 0] = vec_tmp[6 * 0 + j];
- res[4 * j + 1] = vec_tmp[6 * 1 + j];
- res[4 * j + 2] = vec_tmp[6 * 2 + j];
- res[4 * j + 3] = vec_tmp[6 * 3 + j];
- }
-
- i += 4;
- }
- }
-
- /* amt must be power of two */
- inline int padup(int num, int amt)
- {
- return ((num + (amt - 1)) & ~(amt - 1));
- }
-
- SVBVHNode *transform(OldNode *old)
- {
- if (is_leaf(old))
- return (SVBVHNode *)old;
- if (is_leaf(old->child))
- return (SVBVHNode *)old->child;
-
- int nchilds = count_childs(old);
- int alloc_childs = nchilds;
- if (nchilds % 4 > 2)
- alloc_childs = padup(nchilds, 4);
-
- SVBVHNode *node = create_node(alloc_childs);
-
- childs_per_node += nchilds;
- nodes++;
- if (nchilds < 16)
- nodes_with_childs[nchilds]++;
-
- useless_bb += alloc_childs - nchilds;
- while (alloc_childs > nchilds) {
- const static float def_bb[6] = {FLT_MAX, FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX};
- alloc_childs--;
- node->child[alloc_childs] = NULL;
- copy_bb(node->child_bb + alloc_childs * 6, def_bb);
- }
-
- int i = nchilds;
- for (OldNode *o_child = old->child; o_child; o_child = o_child->sibling) {
- i--;
- node->child[i] = transform(o_child);
- if (is_leaf(o_child)) {
- float bb[6];
- INIT_MINMAX(bb, bb + 3);
- RE_rayobject_merge_bb((RayObject *)o_child, bb, bb + 3);
- copy_bb(node->child_bb + i * 6, bb);
- break;
- }
- else {
- copy_bb(node->child_bb + i * 6, o_child->bb);
- }
- }
- assert(i == 0);
-
- prepare_for_simd(node);
-
- return node;
- }
-};
-
-#endif /* __SSE__ */
-
-#endif /* __SVBVH_H__ */
diff --git a/source/blender/render/intern/raytrace/vbvh.h b/source/blender/render/intern/raytrace/vbvh.h
deleted file mode 100644
index abccab5fc13..00000000000
--- a/source/blender/render/intern/raytrace/vbvh.h
+++ /dev/null
@@ -1,238 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): André Pinto.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/raytrace/vbvh.h
- * \ingroup render
- */
-
-
-#include <assert.h>
-#include <algorithm>
-
-#include "BLI_memarena.h"
-
-#include "rayobject_rtbuild.h"
-
-/*
- * VBVHNode represents a BVHNode with support for a variable number of childrens
- */
-struct VBVHNode {
- float bb[6];
-
- VBVHNode *child;
- VBVHNode *sibling;
-};
-
-
-/*
- * Push nodes (used on dfs)
- */
-template<class Node>
-inline static void bvh_node_push_childs(Node *node, Isect *UNUSED(isec), Node **stack, int &stack_pos)
-{
- Node *child = node->child;
-
- if (is_leaf(child)) {
- stack[stack_pos++] = child;
- }
- else {
- while (child) {
- /* Skips BB tests on primitives */
-#if 0
- if (is_leaf(child->child)) {
- stack[stack_pos++] = child->child;
- }
- else
-#endif
- {
- stack[stack_pos++] = child;
- }
-
- child = child->sibling;
- }
- }
-}
-
-
-template<class Node>
-static int count_childs(Node *parent)
-{
- int n = 0;
- for (Node *i = parent->child; i; i = i->sibling) {
- n++;
- if (is_leaf(i))
- break;
- }
-
- return n;
-}
-
-
-template<class Node>
-static void append_sibling(Node *node, Node *sibling)
-{
- while (node->sibling)
- node = node->sibling;
-
- node->sibling = sibling;
-}
-
-
-/*
- * Builds a binary VBVH from a rtbuild
- */
-template<class Node>
-struct BuildBinaryVBVH {
- MemArena *arena;
- RayObjectControl *control;
-
- void test_break()
- {
- if (RE_rayobjectcontrol_test_break(control))
- throw "Stop";
- }
-
- BuildBinaryVBVH(MemArena *a, RayObjectControl *c)
- {
- arena = a;
- control = c;
- }
-
- Node *create_node()
- {
- Node *node = (Node *)BLI_memarena_alloc(arena, sizeof(Node) );
- assert(RE_rayobject_isAligned(node));
-
- node->sibling = NULL;
- node->child = NULL;
-
- return node;
- }
-
- int rtbuild_split(RTBuilder *builder)
- {
- return ::rtbuild_heuristic_object_split(builder, 2);
- }
-
- Node *transform(RTBuilder *builder)
- {
- try
- {
- return _transform(builder);
-
- } catch (...)
- {
- }
- return NULL;
- }
-
- Node *_transform(RTBuilder *builder)
- {
- int size = rtbuild_size(builder);
-
- if (size == 0) {
- return NULL;
- }
- else if (size == 1) {
- Node *node = create_node();
- INIT_MINMAX(node->bb, node->bb + 3);
- rtbuild_merge_bb(builder, node->bb, node->bb + 3);
- node->child = (Node *) rtbuild_get_primitive(builder, 0);
- return node;
- }
- else {
- test_break();
-
- Node *node = create_node();
-
- Node **child = &node->child;
-
- int nc = rtbuild_split(builder);
- INIT_MINMAX(node->bb, node->bb + 3);
-
- assert(nc == 2);
- for (int i = 0; i < nc; i++) {
- RTBuilder tmp;
- rtbuild_get_child(builder, i, &tmp);
-
- *child = _transform(&tmp);
- DO_MIN((*child)->bb, node->bb);
- DO_MAX((*child)->bb + 3, node->bb + 3);
- child = &((*child)->sibling);
- }
-
- *child = NULL;
- return node;
- }
- }
-};
-
-#if 0
-template<class Tree, class OldNode>
-struct Reorganize_VBVH {
- Tree *tree;
-
- Reorganize_VBVH(Tree *t)
- {
- tree = t;
- }
-
- VBVHNode *create_node()
- {
- VBVHNode *node = (VBVHNode *)BLI_memarena_alloc(tree->node_arena, sizeof(VBVHNode));
- return node;
- }
-
- void copy_bb(VBVHNode *node, OldNode *old)
- {
- std::copy(old->bb, old->bb + 6, node->bb);
- }
-
- VBVHNode *transform(OldNode *old)
- {
- if (is_leaf(old))
- return (VBVHNode *)old;
-
- VBVHNode *node = create_node();
- VBVHNode **child_ptr = &node->child;
- node->sibling = 0;
-
- copy_bb(node, old);
-
- for (OldNode *o_child = old->child; o_child; o_child = o_child->sibling)
- {
- VBVHNode *n_child = transform(o_child);
- *child_ptr = n_child;
- if (is_leaf(n_child)) return node;
- child_ptr = &n_child->sibling;
- }
- *child_ptr = 0;
-
- return node;
- }
-};
-#endif
diff --git a/source/blender/render/intern/source/bake.c b/source/blender/render/intern/source/bake.c
deleted file mode 100644
index 48f5f494e58..00000000000
--- a/source/blender/render/intern/source/bake.c
+++ /dev/null
@@ -1,1343 +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.
- *
- * Contributors: 2004/2005/2006 Blender Foundation, full recode
- * Contributors: Vertex color baking, Copyright 2011 AutoCRC
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/bake.c
- * \ingroup render
- */
-
-
-/* system includes */
-#include <stdio.h>
-#include <string.h>
-
-/* External modules: */
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_rand.h"
-#include "BLI_threads.h"
-#include "BLI_utildefines.h"
-
-#include "DNA_image_types.h"
-#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-
-#include "BKE_customdata.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_main.h"
-#include "BKE_node.h"
-#include "BKE_scene.h"
-#include "BKE_library.h"
-
-#include "IMB_imbuf_types.h"
-#include "IMB_imbuf.h"
-#include "IMB_colormanagement.h"
-
-/* local include */
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "render_types.h"
-#include "renderdatabase.h"
-#include "shading.h"
-#include "zbuf.h"
-
-#include "PIL_time.h"
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-
-/* ************************* bake ************************ */
-
-
-typedef struct BakeShade {
- int thread;
-
- ShadeSample ssamp;
- ObjectInstanceRen *obi;
- VlakRen *vlr;
-
- ZSpan *zspan;
- Image *ima;
- ImBuf *ibuf;
-
- int rectx, recty, quad, type, vdone;
- bool ready;
-
- float dir[3];
- Object *actob;
-
- /* Output: vertex color or image data. If vcol is not NULL, rect and
- * rect_float should be NULL. */
- MPoly *mpoly;
- MLoop *mloop;
- MLoopCol *vcol;
-
- unsigned int *rect;
- float *rect_float;
-
- /* displacement buffer used for normalization with unknown maximal distance */
- bool use_displacement_buffer;
- float *displacement_buffer;
- float displacement_min, displacement_max;
-
- bool use_mask;
- char *rect_mask; /* bake pixel mask */
-
- float dxco[3], dyco[3];
-
- short *do_update;
-
- struct ColorSpace *rect_colorspace;
-} BakeShade;
-
-static void bake_set_shade_input(ObjectInstanceRen *obi, VlakRen *vlr, ShadeInput *shi, int quad, int UNUSED(isect), int x, int y, float u, float v)
-{
- if (quad)
- shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3);
- else
- shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2);
-
- /* cache for shadow */
- shi->samplenr = R.shadowsamplenr[shi->thread]++;
-
- shi->mask = 0xFFFF; /* all samples */
-
- shi->u = -u;
- shi->v = -v;
- shi->xs = x;
- shi->ys = y;
-
- shade_input_set_uv(shi);
- shade_input_set_normals(shi);
-
- /* no normal flip */
- if (shi->flippednor)
- shade_input_flip_normals(shi);
-
- /* set up view vector to look right at the surface (note that the normal
- * is negated in the renderer so it does not need to be done here) */
- shi->view[0] = shi->vn[0];
- shi->view[1] = shi->vn[1];
- shi->view[2] = shi->vn[2];
-}
-
-static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(quad), int x, int y, float UNUSED(u), float UNUSED(v), float *tvn, float *ttang)
-{
- BakeShade *bs = handle;
- ShadeSample *ssamp = &bs->ssamp;
- ShadeResult shr;
- VlakRen *vlr = shi->vlr;
-
- shade_input_init_material(shi);
-
- if (bs->type == RE_BAKE_AO) {
- ambient_occlusion(shi);
-
- if (R.r.bake_flag & R_BAKE_NORMALIZE) {
- copy_v3_v3(shr.combined, shi->ao);
- }
- else {
- zero_v3(shr.combined);
- environment_lighting_apply(shi, &shr);
- }
- }
- else {
- if (bs->type == RE_BAKE_SHADOW) /* Why do shadows set the color anyhow?, ignore material color for baking */
- shi->r = shi->g = shi->b = 1.0f;
-
- shade_input_set_shade_texco(shi);
-
- /* only do AO for a full bake (and obviously AO bakes)
- * AO for light bakes is a leftover and might not be needed */
- if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_AO, RE_BAKE_LIGHT))
- shade_samples_do_AO(ssamp);
-
- if (shi->mat->nodetree && shi->mat->use_nodes) {
- ntreeShaderExecTree(shi->mat->nodetree, shi, &shr);
- shi->mat = vlr->mat; /* shi->mat is being set in nodetree */
- }
- else
- shade_material_loop(shi, &shr);
-
- if (bs->type == RE_BAKE_NORMALS) {
- float nor[3];
-
- copy_v3_v3(nor, shi->vn);
-
- if (R.r.bake_normal_space == R_BAKE_SPACE_CAMERA) {
- /* pass */
- }
- else if (R.r.bake_normal_space == R_BAKE_SPACE_TANGENT) {
- float mat[3][3], imat[3][3];
-
- /* bitangent */
- if (tvn && ttang) {
- copy_v3_v3(mat[0], ttang);
- cross_v3_v3v3(mat[1], tvn, ttang);
- mul_v3_fl(mat[1], ttang[3]);
- copy_v3_v3(mat[2], tvn);
- }
- else {
- copy_v3_v3(mat[0], shi->nmaptang);
- cross_v3_v3v3(mat[1], shi->nmapnorm, shi->nmaptang);
- mul_v3_fl(mat[1], shi->nmaptang[3]);
- copy_v3_v3(mat[2], shi->nmapnorm);
- }
-
- invert_m3_m3(imat, mat);
- mul_m3_v3(imat, nor);
- }
- else if (R.r.bake_normal_space == R_BAKE_SPACE_OBJECT)
- mul_mat3_m4_v3(ob->imat_ren, nor); /* ob->imat_ren includes viewinv! */
- else if (R.r.bake_normal_space == R_BAKE_SPACE_WORLD)
- mul_mat3_m4_v3(R.viewinv, nor);
-
- normalize_v3(nor); /* in case object has scaling */
-
- /* The invert of the red channel is to make
- * the normal map compliant with the outside world.
- * It needs to be done because in Blender
- * the normal used in the renderer points inward. It is generated
- * this way in calc_vertexnormals(). Should this ever change
- * this negate must be removed.
- *
- * there is also a small 1e-5f bias for precision issues. otherwise
- * we randomly get 127 or 128 for neutral colors. we choose 128
- * because it is the convention flat color. * */
- shr.combined[0] = (-nor[0]) / 2.0f + 0.5f + 1e-5f;
- shr.combined[1] = nor[1] / 2.0f + 0.5f + 1e-5f;
- shr.combined[2] = nor[2] / 2.0f + 0.5f + 1e-5f;
- }
- else if (bs->type == RE_BAKE_TEXTURE) {
- copy_v3_v3(shr.combined, &shi->r);
- shr.alpha = shi->alpha;
- }
- else if (bs->type == RE_BAKE_SHADOW) {
- copy_v3_v3(shr.combined, shr.shad);
- shr.alpha = shi->alpha;
- }
- else if (bs->type == RE_BAKE_SPEC_COLOR) {
- copy_v3_v3(shr.combined, &shi->specr);
- shr.alpha = 1.0f;
- }
- else if (bs->type == RE_BAKE_SPEC_INTENSITY) {
- copy_v3_fl(shr.combined, shi->spec);
- shr.alpha = 1.0f;
- }
- else if (bs->type == RE_BAKE_MIRROR_COLOR) {
- copy_v3_v3(shr.combined, &shi->mirr);
- shr.alpha = 1.0f;
- }
- else if (bs->type == RE_BAKE_MIRROR_INTENSITY) {
- copy_v3_fl(shr.combined, shi->ray_mirror);
- shr.alpha = 1.0f;
- }
- else if (bs->type == RE_BAKE_ALPHA) {
- copy_v3_fl(shr.combined, shi->alpha);
- shr.alpha = 1.0f;
- }
- else if (bs->type == RE_BAKE_EMIT) {
- copy_v3_fl(shr.combined, shi->emit);
- shr.alpha = 1.0f;
- }
- else if (bs->type == RE_BAKE_VERTEX_COLORS) {
- copy_v3_v3(shr.combined, shi->vcol);
- shr.alpha = shi->vcol[3];
- }
- }
-
- if (bs->rect_float && !bs->vcol) {
- float *col = bs->rect_float + 4 * (bs->rectx * y + x);
- copy_v3_v3(col, shr.combined);
- if (bs->type == RE_BAKE_ALL || bs->type == RE_BAKE_TEXTURE || bs->type == RE_BAKE_VERTEX_COLORS) {
- col[3] = shr.alpha;
- }
- else {
- col[3] = 1.0;
- }
- }
- else {
- /* Target is char (LDR). */
- unsigned char col[4];
-
- if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE)) {
- float rgb[3];
-
- copy_v3_v3(rgb, shr.combined);
- if (R.scene_color_manage) {
- /* Vertex colors have no way to specify color space, so they
- * default to sRGB. */
- if (!bs->vcol)
- IMB_colormanagement_scene_linear_to_colorspace_v3(rgb, bs->rect_colorspace);
- else
- linearrgb_to_srgb_v3_v3(rgb, rgb);
- }
- rgb_float_to_uchar(col, rgb);
- }
- else {
- rgb_float_to_uchar(col, shr.combined);
- }
-
- if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE, RE_BAKE_VERTEX_COLORS)) {
- col[3] = FTOCHAR(shr.alpha);
- }
- else {
- col[3] = 255;
- }
-
- if (bs->vcol) {
- /* Vertex color baking. Vcol has no useful alpha channel (it exists
- * but is used only for vertex painting). */
- bs->vcol->r = col[0];
- bs->vcol->g = col[1];
- bs->vcol->b = col[2];
- }
- else {
- unsigned char *imcol = (unsigned char *)(bs->rect + bs->rectx * y + x);
- copy_v4_v4_uchar(imcol, col);
- }
-
- }
-
- 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)
-{
- BakeShade *bs = handle;
- float disp;
-
- if (R.r.bake_flag & R_BAKE_NORMALIZE) {
- if (R.r.bake_maxdist)
- disp = (dist + R.r.bake_maxdist) / (R.r.bake_maxdist * 2); /* alter the range from [-bake_maxdist, bake_maxdist] to [0, 1]*/
- else
- disp = dist;
- }
- else {
- disp = 0.5f + dist; /* alter the range from [-0.5,0.5] to [0,1]*/
- }
-
- if (bs->displacement_buffer) {
- float *displacement = bs->displacement_buffer + (bs->rectx * y + x);
- *displacement = disp;
- bs->displacement_min = min_ff(bs->displacement_min, disp);
- bs->displacement_max = max_ff(bs->displacement_max, disp);
- }
-
- if (bs->rect_float && !bs->vcol) {
- float *col = bs->rect_float + 4 * (bs->rectx * y + x);
- col[0] = col[1] = col[2] = disp;
- col[3] = 1.0f;
- }
- else {
- /* Target is char (LDR). */
- unsigned char col[4];
- col[0] = col[1] = col[2] = FTOCHAR(disp);
- col[3] = 255;
-
- if (bs->vcol) {
- /* Vertex color baking. Vcol has no useful alpha channel (it exists
- * but is used only for vertex painting). */
- bs->vcol->r = col[0];
- bs->vcol->g = col[1];
- bs->vcol->b = col[2];
- }
- else {
- unsigned char *imcol = (unsigned char *)(bs->rect + bs->rectx * y + x);
- copy_v4_v4_uchar(imcol, col);
- }
- }
- if (bs->rect_mask) {
- bs->rect_mask[bs->rectx * y + x] = FILTER_MASK_USED;
- }
-}
-
-static int bake_intersect_tree(RayObject *raytree, Isect *isect, float *start, float *dir, float sign, float *hitco, float *dist)
-{
- float maxdist;
- int hit;
-
- /* might be useful to make a user setting for maxsize*/
- if (R.r.bake_maxdist > 0.0f)
- maxdist = R.r.bake_maxdist;
- else
- maxdist = RE_RAYTRACE_MAXDIST + R.r.bake_biasdist;
-
- /* 'dir' is always normalized */
- madd_v3_v3v3fl(isect->start, start, dir, -R.r.bake_biasdist);
-
- mul_v3_v3fl(isect->dir, dir, sign);
-
- isect->dist = maxdist;
-
- hit = RE_rayobject_raycast(raytree, isect);
- if (hit) {
- madd_v3_v3v3fl(hitco, isect->start, isect->dir, isect->dist);
-
- *dist = isect->dist;
- }
-
- return hit;
-}
-
-static void bake_set_vlr_dxyco(BakeShade *bs, float *uv1, float *uv2, float *uv3)
-{
- VlakRen *vlr = bs->vlr;
- float A, d1, d2, d3, *v1, *v2, *v3;
-
- if (bs->quad) {
- v1 = vlr->v1->co;
- v2 = vlr->v3->co;
- v3 = vlr->v4->co;
- }
- else {
- v1 = vlr->v1->co;
- v2 = vlr->v2->co;
- v3 = vlr->v3->co;
- }
-
- /* formula derived from barycentric coordinates:
- * (uvArea1*v1 + uvArea2*v2 + uvArea3*v3)/uvArea
- * then taking u and v partial derivatives to get dxco and dyco */
- A = (uv2[0] - uv1[0]) * (uv3[1] - uv1[1]) - (uv3[0] - uv1[0]) * (uv2[1] - uv1[1]);
-
- if (fabsf(A) > FLT_EPSILON) {
- A = 0.5f / A;
-
- d1 = uv2[1] - uv3[1];
- d2 = uv3[1] - uv1[1];
- d3 = uv1[1] - uv2[1];
- bs->dxco[0] = (v1[0] * d1 + v2[0] * d2 + v3[0] * d3) * A;
- bs->dxco[1] = (v1[1] * d1 + v2[1] * d2 + v3[1] * d3) * A;
- bs->dxco[2] = (v1[2] * d1 + v2[2] * d2 + v3[2] * d3) * A;
-
- d1 = uv3[0] - uv2[0];
- d2 = uv1[0] - uv3[0];
- d3 = uv2[0] - uv1[0];
- bs->dyco[0] = (v1[0] * d1 + v2[0] * d2 + v3[0] * d3) * A;
- bs->dyco[1] = (v1[1] * d1 + v2[1] * d2 + v3[1] * d3) * A;
- bs->dyco[2] = (v1[2] * d1 + v2[2] * d2 + v3[2] * d3) * A;
- }
- else {
- bs->dxco[0] = bs->dxco[1] = bs->dxco[2] = 0.0f;
- bs->dyco[0] = bs->dyco[1] = bs->dyco[2] = 0.0f;
- }
-
- if (bs->obi->flag & R_TRANSFORMED) {
- mul_m3_v3(bs->obi->nmat, bs->dxco);
- mul_m3_v3(bs->obi->nmat, bs->dyco);
- }
-}
-
-static void do_bake_shade(void *handle, int x, int y, float u, float v)
-{
- BakeShade *bs = handle;
- VlakRen *vlr = bs->vlr;
- ObjectInstanceRen *obi = bs->obi;
- Object *ob = obi->obr->ob;
- float l, *v1, *v2, *v3, tvn[3], ttang[4];
- int quad;
- ShadeSample *ssamp = &bs->ssamp;
- ShadeInput *shi = ssamp->shi;
-
- /* fast threadsafe break test */
- if (R.test_break(R.tbh))
- return;
-
- /* setup render coordinates */
- if (bs->quad) {
- v1 = vlr->v1->co;
- v2 = vlr->v3->co;
- v3 = vlr->v4->co;
- }
- else {
- v1 = vlr->v1->co;
- v2 = vlr->v2->co;
- v3 = vlr->v3->co;
- }
-
- l = 1.0f - u - v;
-
- /* shrink barycentric coordinates inwards slightly to avoid some issues
- * where baking selected to active might just miss the other face at the
- * near the edge of a face */
- if (bs->actob) {
- const float eps = 1.0f - 1e-4f;
- float invsum;
-
- u = (u - 0.5f) * eps + 0.5f;
- v = (v - 0.5f) * eps + 0.5f;
- l = (l - 0.5f) * eps + 0.5f;
-
- invsum = 1.0f / (u + v + l);
-
- u *= invsum;
- v *= invsum;
- l *= invsum;
- }
-
- /* renderco */
- shi->co[0] = l * v3[0] + u * v1[0] + v * v2[0];
- shi->co[1] = l * v3[1] + u * v1[1] + v * v2[1];
- shi->co[2] = l * v3[2] + u * v1[2] + v * v2[2];
-
- /* avoid self shadow with vertex bake from adjacent faces [#33729] */
- if ((bs->vcol != NULL) && (bs->actob == NULL)) {
- madd_v3_v3fl(shi->co, vlr->n, 0.0001f);
- }
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_v3(obi->mat, shi->co);
-
- copy_v3_v3(shi->dxco, bs->dxco);
- copy_v3_v3(shi->dyco, bs->dyco);
-
- quad = bs->quad;
- bake_set_shade_input(obi, vlr, shi, quad, 0, x, y, u, v);
-
- if (bs->type == RE_BAKE_NORMALS && R.r.bake_normal_space == R_BAKE_SPACE_TANGENT) {
- shade_input_set_shade_texco(shi);
- copy_v3_v3(tvn, shi->nmapnorm);
- copy_v4_v4(ttang, shi->nmaptang);
- }
-
- /* if we are doing selected to active baking, find point on other face */
- if (bs->actob) {
- Isect isec, minisec;
- float co[3], minco[3], dist, mindist = 0.0f;
- int hit, sign, dir = 1;
-
- /* intersect with ray going forward and backward*/
- hit = 0;
- memset(&minisec, 0, sizeof(minisec));
- minco[0] = minco[1] = minco[2] = 0.0f;
-
- copy_v3_v3(bs->dir, shi->vn);
-
- for (sign = -1; sign <= 1; sign += 2) {
- memset(&isec, 0, sizeof(isec));
- isec.mode = RE_RAY_MIRROR;
-
- isec.orig.ob = obi;
- isec.orig.face = vlr;
- isec.userdata = bs->actob;
- isec.check = RE_CHECK_VLR_BAKE;
- isec.skip = RE_SKIP_VLR_NEIGHBOUR;
-
- if (bake_intersect_tree(R.raytree, &isec, shi->co, shi->vn, sign, co, &dist)) {
- if (!hit || len_squared_v3v3(shi->co, co) < len_squared_v3v3(shi->co, minco)) {
- minisec = isec;
- mindist = dist;
- copy_v3_v3(minco, co);
- hit = 1;
- dir = sign;
- }
- }
- }
-
- if (ELEM(bs->type, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE)) {
- if (hit)
- bake_displacement(handle, shi, (dir == -1) ? mindist : -mindist, x, y);
- else
- bake_displacement(handle, shi, 0.0f, x, y);
- return;
- }
-
- /* if hit, we shade from the new point, otherwise from point one starting face */
- if (hit) {
- obi = (ObjectInstanceRen *)minisec.hit.ob;
- vlr = (VlakRen *)minisec.hit.face;
- quad = (minisec.isect == 2);
- copy_v3_v3(shi->co, minco);
-
- u = -minisec.u;
- v = -minisec.v;
- bake_set_shade_input(obi, vlr, shi, quad, 1, x, y, u, v);
- }
- }
-
- if (bs->type == RE_BAKE_NORMALS && R.r.bake_normal_space == R_BAKE_SPACE_TANGENT)
- bake_shade(handle, ob, shi, quad, x, y, u, v, tvn, ttang);
- else
- bake_shade(handle, ob, shi, quad, x, y, u, v, NULL, NULL);
-}
-
-static int get_next_bake_face(BakeShade *bs)
-{
- ObjectRen *obr;
- VlakRen *vlr;
- MTFace *tface;
- static int v = 0, vdone = false;
- static ObjectInstanceRen *obi = NULL;
-
- if (bs == NULL) {
- vlr = NULL;
- v = vdone = false;
- obi = R.instancetable.first;
- return 0;
- }
-
- BLI_thread_lock(LOCK_CUSTOM1);
-
- for (; obi; obi = obi->next, v = 0) {
- obr = obi->obr;
-
- /* only allow non instances here */
- if (obr->flag & R_INSTANCEABLE)
- continue;
-
- for (; v < obr->totvlak; v++) {
- vlr = RE_findOrAddVlak(obr, v);
-
- if ((bs->actob && bs->actob == obr->ob) || (!bs->actob && (obr->ob->flag & SELECT))) {
- if (R.r.bake_flag & R_BAKE_VCOL) {
- /* Gather face data for vertex color bake */
- Mesh *me;
- int *origindex, vcollayer;
- CustomDataLayer *cdl;
-
- if (obr->ob->type != OB_MESH)
- continue;
- me = obr->ob->data;
-
- origindex = RE_vlakren_get_origindex(obr, vlr, 0);
- if (origindex == NULL)
- continue;
- if (*origindex >= me->totpoly) {
- /* Small hack for Array modifier, which gives false
- * original indices - z0r */
- continue;
- }
-#if 0
- /* Only shade selected faces. */
- if ((me->mface[*origindex].flag & ME_FACE_SEL) == 0)
- continue;
-#endif
-
- vcollayer = CustomData_get_render_layer_index(&me->ldata, CD_MLOOPCOL);
- if (vcollayer == -1)
- continue;
-
- cdl = &me->ldata.layers[vcollayer];
- bs->mpoly = me->mpoly + *origindex;
- bs->vcol = ((MLoopCol *)cdl->data) + bs->mpoly->loopstart;
- bs->mloop = me->mloop + bs->mpoly->loopstart;
-
- /* Tag mesh for reevaluation. */
- me->id.tag |= LIB_TAG_DOIT;
- }
- else {
- Image *ima = NULL;
- ImBuf *ibuf = NULL;
- const float vec_alpha[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- const float vec_solid[4] = {0.0f, 0.0f, 0.0f, 1.0f};
- const float nor_alpha[4] = {0.5f, 0.5f, 1.0f, 0.0f};
- const float nor_solid[4] = {0.5f, 0.5f, 1.0f, 1.0f};
- const float disp_alpha[4] = {0.5f, 0.5f, 0.5f, 0.0f};
- const float disp_solid[4] = {0.5f, 0.5f, 0.5f, 1.0f};
-
- tface = RE_vlakren_get_tface(obr, vlr, obr->bakemtface, NULL, 0);
- /* should use 'BKE_object_material_edit_image_get' but in this case simpler not to */
- ima = vlr->mat ? vlr->mat->edit_image : NULL;
-
- if (!tface || !ima)
- continue;
-
- ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
-
- if (ibuf == NULL)
- continue;
-
- if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
- BKE_image_release_ibuf(ima, ibuf, NULL);
- continue;
- }
-
- if (ibuf->rect_float && !(ibuf->channels == 0 || ibuf->channels == 4)) {
- BKE_image_release_ibuf(ima, ibuf, NULL);
- continue;
- }
-
- if (ima->flag & IMA_USED_FOR_RENDER) {
- ima->id.tag &= ~LIB_TAG_DOIT;
- BKE_image_release_ibuf(ima, ibuf, NULL);
- continue;
- }
-
- /* find the image for the first time? */
- if (ima->id.tag & LIB_TAG_DOIT) {
- ima->id.tag &= ~LIB_TAG_DOIT;
-
- /* we either fill in float or char, this ensures things go fine */
- if (ibuf->rect_float)
- imb_freerectImBuf(ibuf);
- /* clear image */
- if (R.r.bake_flag & R_BAKE_CLEAR) {
- if (R.r.bake_mode == RE_BAKE_NORMALS && R.r.bake_normal_space == R_BAKE_SPACE_TANGENT)
- IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
- else if (ELEM(R.r.bake_mode, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE))
- IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? disp_alpha : disp_solid);
- else
- IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
- }
- /* might be read by UI to set active image for display */
- R.bakebuf = ima;
- }
-
- /* Tag image for redraw. */
- ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
- BKE_image_release_ibuf(ima, ibuf, NULL);
- }
-
- bs->obi = obi;
- bs->vlr = vlr;
- bs->vdone++; /* only for error message if nothing was rendered */
- v++;
- BLI_thread_unlock(LOCK_CUSTOM1);
- return 1;
- }
- }
- }
-
- BLI_thread_unlock(LOCK_CUSTOM1);
- return 0;
-}
-
-static void bake_single_vertex(BakeShade *bs, VertRen *vert, float u, float v)
-{
- int *origindex, i;
- MLoopCol *basevcol;
- MLoop *mloop;
-
- /* per vertex fixed seed */
- BLI_thread_srandom(bs->thread, vert->index);
-
- origindex = RE_vertren_get_origindex(bs->obi->obr, vert, 0);
- if (!origindex || *origindex == ORIGINDEX_NONE)
- return;
-
- /* Search for matching vertex index and apply shading. */
- for (i = 0; i < bs->mpoly->totloop; i++) {
- mloop = bs->mloop + i;
- if (mloop->v != *origindex)
- continue;
- basevcol = bs->vcol;
- bs->vcol = basevcol + i;
- do_bake_shade(bs, 0, 0, u, v);
- bs->vcol = basevcol;
- break;
- }
-}
-
-/* Bake all vertices of a face. Actually, this still works on a face-by-face
- * basis, and each vertex on each face is shaded. Vertex colors are a property
- * of loops, not vertices. */
-static void shade_verts(BakeShade *bs)
-{
- VlakRen *vlr = bs->vlr;
-
- /* Disable baking to image; write to vcol instead. vcol pointer is set in
- * bake_single_vertex. */
- bs->ima = NULL;
- bs->rect = NULL;
- bs->rect_float = NULL;
- bs->displacement_buffer = NULL;
- bs->displacement_min = FLT_MAX;
- bs->displacement_max = -FLT_MAX;
-
- bs->quad = 0;
-
- /* No anti-aliasing for vertices. */
- zero_v3(bs->dxco);
- zero_v3(bs->dyco);
-
- /* Shade each vertex of the face. u and v are barycentric coordinates; since
- * we're only interested in vertices, these will be 0 or 1. */
- if ((vlr->flag & R_FACE_SPLIT) == 0) {
- /* Processing triangle face, whole quad, or first half of split quad. */
-
- bake_single_vertex(bs, bs->vlr->v1, 1.0f, 0.0f);
- bake_single_vertex(bs, bs->vlr->v2, 0.0f, 1.0f);
- bake_single_vertex(bs, bs->vlr->v3, 0.0f, 0.0f);
-
- if (vlr->v4) {
- bs->quad = 1;
- bake_single_vertex(bs, bs->vlr->v4, 0.0f, 0.0f);
- }
- }
- else {
- /* Processing second half of split quad. Only one vertex to go. */
- if (vlr->flag & R_DIVIDE_24) {
- bake_single_vertex(bs, bs->vlr->v2, 0.0f, 1.0f);
- }
- else {
- bake_single_vertex(bs, bs->vlr->v3, 0.0f, 0.0f);
- }
- }
-}
-
-/* already have tested for tface and ima and zspan */
-static void shade_tface(BakeShade *bs)
-{
- VlakRen *vlr = bs->vlr;
- ObjectInstanceRen *obi = bs->obi;
- ObjectRen *obr = obi->obr;
- MTFace *tface = RE_vlakren_get_tface(obr, vlr, obr->bakemtface, NULL, 0);
- Image *ima = vlr->mat->edit_image;
- float vec[4][2];
- int a, i1, i2, i3;
-
- /* per face fixed seed */
- BLI_thread_srandom(bs->thread, vlr->index);
-
- /* check valid zspan */
- if (ima != bs->ima) {
- BKE_image_release_ibuf(bs->ima, bs->ibuf, NULL);
-
- bs->ima = ima;
- bs->ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
- /* note, these calls only free/fill contents of zspan struct, not zspan itself */
- zbuf_free_span(bs->zspan);
- zbuf_alloc_span(bs->zspan, bs->ibuf->x, bs->ibuf->y, R.clipcrop);
- }
-
- bs->rectx = bs->ibuf->x;
- bs->recty = bs->ibuf->y;
- bs->rect = bs->ibuf->rect;
- bs->rect_colorspace = bs->ibuf->rect_colorspace;
- bs->rect_float = bs->ibuf->rect_float;
- bs->vcol = NULL;
- bs->quad = 0;
- bs->rect_mask = NULL;
- bs->displacement_buffer = NULL;
-
- if (bs->use_mask || bs->use_displacement_buffer) {
- BakeImBufuserData *userdata = bs->ibuf->userdata;
- if (userdata == NULL) {
- BLI_thread_lock(LOCK_CUSTOM1);
- userdata = bs->ibuf->userdata;
- if (userdata == NULL) /* since the thread was locked, its possible another thread alloced the value */
- userdata = MEM_callocN(sizeof(BakeImBufuserData), "BakeImBufuserData");
-
- if (bs->use_mask) {
- if (userdata->mask_buffer == NULL) {
- userdata->mask_buffer = MEM_callocN(sizeof(char) * bs->rectx * bs->recty, "BakeMask");
- }
- }
-
- if (bs->use_displacement_buffer) {
- if (userdata->displacement_buffer == NULL) {
- userdata->displacement_buffer = MEM_callocN(sizeof(float) * bs->rectx * bs->recty, "BakeDisp");
- }
- }
-
- bs->ibuf->userdata = userdata;
-
- BLI_thread_unlock(LOCK_CUSTOM1);
- }
-
- bs->rect_mask = userdata->mask_buffer;
- bs->displacement_buffer = userdata->displacement_buffer;
- }
-
- /* get pixel level vertex coordinates */
- for (a = 0; a < 4; a++) {
- /* Note, workaround for pixel aligned UVs which are common and can screw up our intersection tests
- * where a pixel gets in between 2 faces or the middle of a quad,
- * camera aligned quads also have this problem but they are less common.
- * Add a small offset to the UVs, fixes bug #18685 - Campbell */
- vec[a][0] = tface->uv[a][0] * (float)bs->rectx - (0.5f + 0.001f);
- vec[a][1] = tface->uv[a][1] * (float)bs->recty - (0.5f + 0.002f);
- }
-
- /* UV indices have to be corrected for possible quad->tria splits */
- i1 = 0; i2 = 1; i3 = 2;
- vlr_set_uv_indices(vlr, &i1, &i2, &i3);
- bake_set_vlr_dxyco(bs, vec[i1], vec[i2], vec[i3]);
- zspan_scanconvert(bs->zspan, bs, vec[i1], vec[i2], vec[i3], do_bake_shade);
-
- if (vlr->v4) {
- bs->quad = 1;
- bake_set_vlr_dxyco(bs, vec[0], vec[2], vec[3]);
- zspan_scanconvert(bs->zspan, bs, vec[0], vec[2], vec[3], do_bake_shade);
- }
-}
-
-static void *do_bake_thread(void *bs_v)
-{
- BakeShade *bs = bs_v;
-
- while (get_next_bake_face(bs)) {
- if (R.r.bake_flag & R_BAKE_VCOL) {
- shade_verts(bs);
- }
- else {
- shade_tface(bs);
- }
-
- /* fast threadsafe break test */
- if (R.test_break(R.tbh))
- break;
-
- /* access is not threadsafe but since its just true/false probably ok
- * only used for interactive baking */
- if (bs->do_update) {
- *bs->do_update = true;
- }
- }
- bs->ready = true;
-
- BKE_image_release_ibuf(bs->ima, bs->ibuf, NULL);
-
- return NULL;
-}
-
-void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter)
-{
- /* must check before filtering */
- const bool is_new_alpha = (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_imbuf_alpha_test(ibuf);
-
- /* Margin */
- if (filter) {
- IMB_filter_extend(ibuf, mask, filter);
- }
-
- /* if the bake results in new alpha then change the image setting */
- if (is_new_alpha) {
- ibuf->planes = R_IMF_PLANES_RGBA;
- }
- else {
- if (filter && ibuf->planes != R_IMF_PLANES_RGBA) {
- /* clear alpha added by filtering */
- IMB_rectfill_alpha(ibuf, 1.0f);
- }
- }
-}
-
-void RE_bake_ibuf_normalize_displacement(ImBuf *ibuf, float *displacement, char *mask, float displacement_min, float displacement_max)
-{
- int i;
- const float *current_displacement = displacement;
- const char *current_mask = mask;
- float max_distance;
-
- max_distance = max_ff(fabsf(displacement_min), fabsf(displacement_max));
-
- for (i = 0; i < ibuf->x * ibuf->y; i++) {
- if (*current_mask == FILTER_MASK_USED) {
- float normalized_displacement;
-
- if (max_distance > 1e-5f)
- normalized_displacement = (*current_displacement + max_distance) / (max_distance * 2);
- else
- normalized_displacement = 0.5f;
-
- if (ibuf->rect_float) {
- /* currently baking happens to RGBA only */
- float *fp = ibuf->rect_float + i * 4;
- fp[0] = fp[1] = fp[2] = normalized_displacement;
- fp[3] = 1.0f;
- }
-
- if (ibuf->rect) {
- unsigned char *cp = (unsigned char *) (ibuf->rect + i);
- cp[0] = cp[1] = cp[2] = FTOCHAR(normalized_displacement);
- cp[3] = 255;
- }
- }
-
- current_displacement++;
- current_mask++;
- }
-}
-
-/* using object selection tags, the faces with UV maps get baked */
-/* render should have been setup */
-/* returns 0 if nothing was handled */
-int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_update, float *progress)
-{
- BakeShade *handles;
- ListBase threads;
- Image *ima;
- int a, vdone = false, result = BAKE_RESULT_OK;
- bool use_mask = false;
- bool use_displacement_buffer = false;
- bool do_manage = false;
-
- if (ELEM(type, RE_BAKE_ALL, RE_BAKE_TEXTURE)) {
- do_manage = BKE_scene_check_color_management_enabled(re->scene);
- }
-
- re->scene_color_manage = BKE_scene_check_color_management_enabled(re->scene);
-
- /* initialize render global */
- R = *re;
- R.bakebuf = NULL;
-
- /* initialize static vars */
- get_next_bake_face(NULL);
-
- /* do we need a mask? */
- if (re->r.bake_filter)
- use_mask = true;
-
- /* do we need buffer to store displacements */
- if (ELEM(type, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE)) {
- if (((R.r.bake_flag & R_BAKE_NORMALIZE) && R.r.bake_maxdist == 0.0f) ||
- (type == RE_BAKE_DERIVATIVE))
- {
- use_displacement_buffer = true;
- use_mask = true;
- }
- }
-
- /* baker uses this flag to detect if image was initialized */
- if ((R.r.bake_flag & R_BAKE_VCOL) == 0) {
- for (ima = G.main->image.first; ima; ima = ima->id.next) {
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
- ima->id.tag |= LIB_TAG_DOIT;
- ima->flag &= ~IMA_USED_FOR_RENDER;
- if (ibuf) {
- ibuf->userdata = NULL; /* use for masking if needed */
- }
- BKE_image_release_ibuf(ima, ibuf, NULL);
- }
- }
-
- if (R.r.bake_flag & R_BAKE_VCOL) {
- /* untag all meshes */
- BKE_main_id_tag_listbase(&G.main->mesh, LIB_TAG_DOIT, false);
- }
-
- BLI_threadpool_init(&threads, do_bake_thread, re->r.threads);
-
- handles = MEM_callocN(sizeof(BakeShade) * re->r.threads, "BakeShade");
-
- /* get the threads running */
- for (a = 0; a < re->r.threads; a++) {
- handles[a].thread = a;
-
- /* set defaults in handles */
- handles[a].ssamp.shi[0].lay = re->lay;
-
- if (type == RE_BAKE_SHADOW) {
- handles[a].ssamp.shi[0].passflag = SCE_PASS_SHADOW;
- }
- else {
- handles[a].ssamp.shi[0].passflag = SCE_PASS_COMBINED;
- }
- handles[a].ssamp.shi[0].combinedflag = ~(SCE_PASS_SPEC);
- handles[a].ssamp.shi[0].thread = a;
- handles[a].ssamp.shi[0].do_manage = do_manage;
- handles[a].ssamp.tot = 1;
-
- handles[a].type = type;
- handles[a].actob = actob;
- if (R.r.bake_flag & R_BAKE_VCOL)
- handles[a].zspan = NULL;
- else
- handles[a].zspan = MEM_callocN(sizeof(ZSpan), "zspan for bake");
-
- handles[a].use_mask = use_mask;
- handles[a].use_displacement_buffer = use_displacement_buffer;
-
- handles[a].do_update = do_update; /* use to tell the view to update */
-
- handles[a].displacement_min = FLT_MAX;
- handles[a].displacement_max = -FLT_MAX;
-
- BLI_threadpool_insert(&threads, &handles[a]);
- }
-
- /* wait for everything to be done */
- a = 0;
- while (a != re->r.threads) {
- PIL_sleep_ms(50);
-
- /* calculate progress */
- for (vdone = false, a = 0; a < re->r.threads; a++)
- vdone += handles[a].vdone;
- if (progress)
- *progress = (float)(vdone / (float)re->totvlak);
-
- for (a = 0; a < re->r.threads; a++) {
- if (handles[a].ready == false) {
- break;
- }
- }
- }
-
- /* filter and refresh images */
- if ((R.r.bake_flag & R_BAKE_VCOL) == 0) {
- float displacement_min = FLT_MAX, displacement_max = -FLT_MAX;
-
- if (use_displacement_buffer) {
- for (a = 0; a < re->r.threads; a++) {
- displacement_min = min_ff(displacement_min, handles[a].displacement_min);
- displacement_max = max_ff(displacement_max, handles[a].displacement_max);
- }
- }
-
- for (ima = G.main->image.first; ima; ima = ima->id.next) {
- if ((ima->id.tag & LIB_TAG_DOIT) == 0) {
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
- BakeImBufuserData *userdata;
-
- if (ima->flag & IMA_USED_FOR_RENDER)
- result = BAKE_RESULT_FEEDBACK_LOOP;
-
- if (!ibuf)
- continue;
-
- userdata = (BakeImBufuserData *)ibuf->userdata;
- if (userdata) {
- if (use_displacement_buffer) {
- if (type == RE_BAKE_DERIVATIVE) {
- float user_scale = (R.r.bake_flag & R_BAKE_USERSCALE) ? R.r.bake_user_scale : -1.0f;
- RE_bake_make_derivative(ibuf, userdata->displacement_buffer, userdata->mask_buffer,
- displacement_min, displacement_max, user_scale);
- }
- else {
- RE_bake_ibuf_normalize_displacement(ibuf, userdata->displacement_buffer, userdata->mask_buffer,
- displacement_min, displacement_max);
- }
- }
-
- RE_bake_ibuf_filter(ibuf, userdata->mask_buffer, re->r.bake_filter);
- }
-
- ibuf->userflags |= IB_BITMAPDIRTY;
- BKE_image_release_ibuf(ima, ibuf, NULL);
- }
- }
-
- /* calculate return value */
- for (a = 0; a < re->r.threads; a++) {
- zbuf_free_span(handles[a].zspan);
- MEM_freeN(handles[a].zspan);
- }
- }
-
- MEM_freeN(handles);
-
- BLI_threadpool_end(&threads);
-
- if (vdone == 0) {
- result = BAKE_RESULT_NO_OBJECTS;
- }
-
- return result;
-}
-
-struct Image *RE_bake_shade_get_image(void)
-{
- return R.bakebuf;
-}
-
-/* **************** Derivative Maps Baker **************** */
-
-static void add_single_heights_margin(const ImBuf *ibuf, const char *mask, float *heights_buffer)
-{
- int x, y;
-
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- int index = ibuf->x * y + x;
-
- /* If unassigned pixel, look for neighbors. */
- if (mask[index] != FILTER_MASK_USED) {
- float height_acc = 0;
- int denom = 0;
- int i, j;
-
- for (j = -1; j <= 1; j++)
- for (i = -1; i <= 1; i++) {
- int w = (i == 0 ? 1 : 0) + (j == 0 ? 1 : 0) + 1;
-
- if (i != 0 || j != 0) {
- int index2 = 0;
- int x0 = x + i;
- int y0 = y + j;
-
- CLAMP(x0, 0, ibuf->x - 1);
- CLAMP(y0, 0, ibuf->y - 1);
-
- index2 = ibuf->x * y0 + x0;
-
- if (mask[index2] == FILTER_MASK_USED) {
- height_acc += w * heights_buffer[index2];
- denom += w;
- }
- }
- }
-
- /* Insert final value. */
- if (denom > 0) {
- heights_buffer[index] = height_acc / denom;
- }
- }
- }
- }
-}
-
-/* returns user-scale */
-float RE_bake_make_derivative(ImBuf *ibuf, float *heights_buffer, const char *mask,
- const float height_min, const float height_max,
- const float fmult)
-{
- const float delta_height = height_max - height_min;
- const float denom = delta_height > 0.0f ? (8 * delta_height) : 1.0f;
- bool auto_range_fit = fmult <= 0.0f;
- float max_num_deriv = -1.0f;
- int x, y, index;
-
- /* Need a single margin to calculate good derivatives. */
- add_single_heights_margin(ibuf, mask, heights_buffer);
-
- 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 Yc = y;
- const int Yd = y == 0 ? 0 : (y - 1);
-
- 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);
-
- const float Hcy = heights_buffer[Yc * ibuf->x + Xr] - heights_buffer[Yc * ibuf->x + Xl];
- const float Hu = heights_buffer[Yu * ibuf->x + Xr] - heights_buffer[Yu * ibuf->x + Xl];
- const float Hd = heights_buffer[Yd * ibuf->x + Xr] - heights_buffer[Yd * ibuf->x + Xl];
-
- const float Hl = heights_buffer[Yu * ibuf->x + Xl] - heights_buffer[Yd * ibuf->x + Xl];
- const float Hcx = heights_buffer[Yu * ibuf->x + Xc] - heights_buffer[Yd * ibuf->x + Xc];
- const float Hr = heights_buffer[Yu * ibuf->x + Xr] - heights_buffer[Yd * ibuf->x + Xr];
-
- /* This corresponds to using the sobel kernel on the heights buffer
- * to obtain the derivative multiplied by 8.
- */
- const float deriv_x = Hu + 2 * Hcy + Hd;
- const float deriv_y = Hr + 2 * Hcx + Hl;
-
- /* early out */
- index = ibuf->x * y + x;
- if (mask[index] != FILTER_MASK_USED) {
- continue;
- }
-
- /* Widen bound. */
- if (fabsf(deriv_x) > max_num_deriv) {
- max_num_deriv = fabsf(deriv_x);
- }
-
- if (fabsf(deriv_y) > max_num_deriv) {
- max_num_deriv = fabsf(deriv_y);
- }
- }
- }
- }
-
- /* 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);
-
- 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);
-
- const float Hcy = heights_buffer[Yc * ibuf->x + Xr] - heights_buffer[Yc * ibuf->x + Xl];
- const float Hu = heights_buffer[Yu * ibuf->x + Xr] - heights_buffer[Yu * ibuf->x + Xl];
- const float Hd = heights_buffer[Yd * ibuf->x + Xr] - heights_buffer[Yd * ibuf->x + Xl];
-
- const float Hl = heights_buffer[Yu * ibuf->x + Xl] - heights_buffer[Yd * ibuf->x + Xl];
- const float Hcx = heights_buffer[Yu * ibuf->x + Xc] - heights_buffer[Yd * ibuf->x + Xc];
- const float Hr = heights_buffer[Yu * ibuf->x + Xr] - heights_buffer[Yd * ibuf->x + Xr];
-
- /* This corresponds to using the sobel kernel on the heights buffer
- * to obtain the derivative multiplied by 8.
- */
- float deriv_x = Hu + 2 * Hcy + Hd;
- float deriv_y = Hr + 2 * Hcx + Hl;
-
- /* Early out. */
- index = ibuf->x * y + x;
- if (mask[index] != FILTER_MASK_USED) {
- continue;
- }
-
- if (auto_range_fit) {
- deriv_x /= max_num_deriv;
- deriv_y /= max_num_deriv;
- }
- else {
- deriv_x *= (fmult / denom);
- deriv_y *= (fmult / denom);
- }
-
- deriv_x = deriv_x * 0.5f + 0.5f;
- deriv_y = deriv_y * 0.5f + 0.5f;
-
- /* Clamp. */
- CLAMP(deriv_x, 0.0f, 1.0f);
- CLAMP(deriv_y, 0.0f, 1.0f);
-
- /* Write out derivatives. */
- if (ibuf->rect_float) {
- float *rrgbf = ibuf->rect_float + index * 4;
-
- rrgbf[0] = deriv_x;
- rrgbf[1] = deriv_y;
- rrgbf[2] = 0.0f;
- rrgbf[3] = 1.0f;
- }
- else {
- char *rrgb = (char *)ibuf->rect + index * 4;
-
- rrgb[0] = FTOCHAR(deriv_x);
- rrgb[1] = FTOCHAR(deriv_y);
- rrgb[2] = 0;
- rrgb[3] = 255;
- }
- }
- }
-
- /* Eeturn user-scale (for rendering). */
- return auto_range_fit ? (max_num_deriv / denom) : (fmult > 0.0f ? (1.0f / fmult) : 0.0f);
-}
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c
index 505af3c2fa8..bd3e01c83a8 100644
--- a/source/blender/render/intern/source/bake_api.c
+++ b/source/blender/render/intern/source/bake_api.c
@@ -84,19 +84,11 @@
/* local include */
#include "render_types.h"
-#include "shading.h"
#include "zbuf.h"
/* Remove when Cycles moves from MFace to MLoopTri */
#define USE_MFACE_WORKAROUND
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-
typedef struct BakeDataZSpan {
BakePixel *pixel_array;
int primitive_id;
@@ -263,6 +255,36 @@ static void calc_point_from_barycentric_extrusion(
copy_v3_v3(r_dir, dir);
}
+static void barycentric_differentials_from_position(
+ const float co[3], const float v1[3], const float v2[3], const float v3[3],
+ const float dxco[3], const float dyco[3], const float facenor[3], const bool differentials,
+ float *u, float *v, float *dx_u, float *dx_v, float *dy_u, float *dy_v)
+{
+ /* find most stable axis to project */
+ int axis1, axis2;
+ axis_dominant_v3(&axis1, &axis2, facenor);
+
+ /* compute u,v and derivatives */
+ float t00 = v3[axis1] - v1[axis1];
+ float t01 = v3[axis2] - v1[axis2];
+ float t10 = v3[axis1] - v2[axis1];
+ float t11 = v3[axis2] - v2[axis2];
+
+ float detsh = (t00 * t11 - t10 * t01);
+ detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f;
+ t00 *= detsh; t01 *= detsh;
+ t10 *= detsh; t11 *= detsh;
+
+ *u = (v3[axis1] - co[axis1]) * t11 - (v3[axis2] - co[axis2]) * t10;
+ *v = (v3[axis2] - co[axis2]) * t00 - (v3[axis1] - co[axis1]) * t01;
+ if (differentials) {
+ *dx_u = dxco[axis1] * t11 - dxco[axis2] * t10;
+ *dx_v = dxco[axis2] * t00 - dxco[axis1] * t01;
+ *dy_u = dyco[axis1] * t11 - dyco[axis2] * t10;
+ *dy_v = dyco[axis2] * t00 - dyco[axis1] * t01;
+ }
+}
+
/**
* This function populates pixel_array and returns TRUE if things are correct
*/
@@ -665,7 +687,7 @@ void RE_bake_pixels_populate(
}
for (i = 0; i < bake_images->size; i++) {
- zbuf_alloc_span(&bd.zspan[i], bake_images->data[i].width, bake_images->data[i].height, R.clipcrop);
+ zbuf_alloc_span(&bd.zspan[i], bake_images->data[i].width, bake_images->data[i].height);
}
looptri = MEM_mallocN(sizeof(*looptri) * tottri, __func__);
@@ -958,36 +980,6 @@ void RE_bake_ibuf_clear(Image *image, const bool is_tangent)
/* ************************************************************* */
-/**
- * not the real UV, but the internal per-face UV instead
- * I'm using it to test if everything is correct */
-static bool bake_uv(const BakePixel pixel_array[], const size_t num_pixels, const int depth, float result[])
-{
- size_t i;
-
- for (i=0; i < num_pixels; i++) {
- size_t offset = i * depth;
- copy_v2_v2(&result[offset], pixel_array[i].uv);
- }
-
- return true;
-}
-
-bool RE_bake_internal(
- Render *UNUSED(re), Object *UNUSED(object), const BakePixel pixel_array[],
- const size_t num_pixels, const int depth, const eScenePassType pass_type, float result[])
-{
- switch (pass_type) {
- case SCE_PASS_UV:
- {
- return bake_uv(pixel_array, num_pixels, depth, result);
- }
- default:
- break;
- }
- return false;
-}
-
int RE_pass_depth(const eScenePassType pass_type)
{
/* IMB_buffer_byte_from_float assumes 4 channels
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
deleted file mode 100644
index c358f0388a4..00000000000
--- a/source/blender/render/intern/source/convertblender.c
+++ /dev/null
@@ -1,5980 +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.
- *
- * Contributors: 2004/2005/2006 Blender Foundation, full recode
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/convertblender.c
- * \ingroup render
- */
-
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-#include "BLI_rand.h"
-#include "BLI_memarena.h"
-#ifdef WITH_FREESTYLE
-# include "BLI_edgehash.h"
-#endif
-
-#include "BLT_translation.h"
-
-#include "DNA_material_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_group_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_image_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_node_types.h"
-#include "DNA_object_types.h"
-#include "DNA_object_fluidsim_types.h"
-#include "DNA_particle_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_texture_types.h"
-
-#include "BKE_anim.h"
-#include "BKE_curve.h"
-#include "BKE_customdata.h"
-#include "BKE_colortools.h"
-#include "BKE_displist.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_global.h"
-#include "BKE_group.h"
-#include "BKE_key.h"
-#include "BKE_image.h"
-#include "BKE_lattice.h"
-#include "BKE_layer.h"
-#include "BKE_material.h"
-#include "BKE_main.h"
-#include "BKE_mball.h"
-#include "BKE_mesh.h"
-#include "BKE_modifier.h"
-#include "BKE_node.h"
-#include "BKE_object.h"
-#include "BKE_particle.h"
-#include "BKE_scene.h"
-
-#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_build.h"
-
-#include "PIL_time.h"
-
-#include "envmap.h"
-#include "occlusion.h"
-#include "pointdensity.h"
-#include "voxeldata.h"
-#include "render_types.h"
-#include "rendercore.h"
-#include "renderdatabase.h"
-#include "renderpipeline.h"
-#include "shadbuf.h"
-#include "shading.h"
-#include "strand.h"
-#include "texture.h"
-#include "volume_precache.h"
-#include "sss.h"
-#include "zbuf.h"
-#include "sunsky.h"
-
-/* 10 times larger than normal epsilon, test it on default nurbs sphere with ray_transp (for quad detection) */
-/* or for checking vertex normal flips */
-#define FLT_EPSILON10 1.19209290e-06F
-
-/* could enable at some point but for now there are far too many conversions */
-#ifdef __GNUC__
-# pragma GCC diagnostic ignored "-Wdouble-promotion"
-#endif
-
-/* ------------------------------------------------------------------------- */
-/* tool functions/defines for ad hoc simplification and possible future
- * cleanup */
-/* ------------------------------------------------------------------------- */
-
-#define UVTOINDEX(u, v) (startvlak + (u) * sizev + (v))
-/*
- *
- * NOTE THAT U/V COORDINATES ARE SOMETIMES SWAPPED !!
- *
- * ^ ()----p4----p3----()
- * | | | | |
- * u | | F1 | F2 |
- * | | | |
- * ()----p1----p2----()
- * v ->
- */
-
-/* ------------------------------------------------------------------------- */
-
-#define CD_MASK_RENDER_INTERNAL \
- (CD_MASK_BAREMESH | CD_MASK_MFACE | CD_MASK_MTFACE | CD_MASK_MCOL)
-
-static void split_v_renderfaces(ObjectRen *obr, int startvlak, int UNUSED(startvert), int UNUSED(usize), int vsize, int uIndex, int UNUSED(cyclu), int cyclv)
-{
- int vLen = vsize-1+(!!cyclv);
- int v;
-
- for (v=0; v<vLen; v++) {
- VlakRen *vlr = RE_findOrAddVlak(obr, startvlak + vLen*uIndex + v);
- VlakRen *vlr_other;
- VertRen *vert = RE_vertren_copy(obr, vlr->v2);
-
- if (cyclv) {
- vlr->v2 = vert;
-
- if (v == vLen - 1) {
- vlr_other = RE_findOrAddVlak(obr, startvlak + vLen*uIndex + 0);
- vlr_other->v1 = vert;
- }
- else {
- vlr_other = RE_findOrAddVlak(obr, startvlak + vLen*uIndex + v+1);
- vlr_other->v1 = vert;
- }
- }
- else {
- vlr->v2 = vert;
-
- if (v < vLen - 1) {
- vlr_other = RE_findOrAddVlak(obr, startvlak + vLen*uIndex + v+1);
- vlr_other->v1 = vert;
- }
-
- if (v == 0) {
- vlr->v1 = RE_vertren_copy(obr, vlr->v1);
- }
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-/* Stress, tangents and normals */
-/* ------------------------------------------------------------------------- */
-
-static void calc_edge_stress_add(float *accum, VertRen *v1, VertRen *v2)
-{
- float len= len_v3v3(v1->co, v2->co)/len_v3v3(v1->orco, v2->orco);
- float *acc;
-
- acc= accum + 2*v1->index;
- acc[0]+= len;
- acc[1]+= 1.0f;
-
- acc= accum + 2*v2->index;
- acc[0]+= len;
- acc[1]+= 1.0f;
-}
-
-static void calc_edge_stress(Render *UNUSED(re), ObjectRen *obr, Mesh *me)
-{
- float loc[3], size[3], *accum, *acc, *accumoffs, *stress;
- int a;
-
- if (obr->totvert==0) return;
-
- BKE_mesh_texspace_get(me, loc, NULL, size);
-
- accum= MEM_callocN(2*sizeof(float)*obr->totvert, "temp accum for stress");
-
- /* de-normalize orco */
- for (a=0; a<obr->totvert; a++) {
- VertRen *ver= RE_findOrAddVert(obr, a);
- if (ver->orco) {
- ver->orco[0]= ver->orco[0]*size[0] +loc[0];
- ver->orco[1]= ver->orco[1]*size[1] +loc[1];
- ver->orco[2]= ver->orco[2]*size[2] +loc[2];
- }
- }
-
- /* add stress values */
- accumoffs= accum; /* so we can use vertex index */
- for (a=0; a<obr->totvlak; a++) {
- VlakRen *vlr= RE_findOrAddVlak(obr, a);
-
- if (vlr->v1->orco && vlr->v4) {
- calc_edge_stress_add(accumoffs, vlr->v1, vlr->v2);
- calc_edge_stress_add(accumoffs, vlr->v2, vlr->v3);
- calc_edge_stress_add(accumoffs, vlr->v3, vlr->v1);
- if (vlr->v4) {
- calc_edge_stress_add(accumoffs, vlr->v3, vlr->v4);
- calc_edge_stress_add(accumoffs, vlr->v4, vlr->v1);
- calc_edge_stress_add(accumoffs, vlr->v2, vlr->v4);
- }
- }
- }
-
- for (a=0; a<obr->totvert; a++) {
- VertRen *ver= RE_findOrAddVert(obr, a);
- if (ver->orco) {
- /* find stress value */
- acc= accumoffs + 2*ver->index;
- if (acc[1]!=0.0f)
- acc[0]/= acc[1];
- stress= RE_vertren_get_stress(obr, ver, 1);
- *stress= *acc;
-
- /* restore orcos */
- ver->orco[0] = (ver->orco[0]-loc[0])/size[0];
- ver->orco[1] = (ver->orco[1]-loc[1])/size[1];
- ver->orco[2] = (ver->orco[2]-loc[2])/size[2];
- }
- }
-
- MEM_freeN(accum);
-}
-
-/* gets tangent from tface or orco */
-static void calc_tangent_vector(ObjectRen *obr, VlakRen *vlr, int do_tangent)
-{
- MTFace *tface= RE_vlakren_get_tface(obr, vlr, obr->actmtface, NULL, 0);
- VertRen *v1=vlr->v1, *v2=vlr->v2, *v3=vlr->v3, *v4=vlr->v4;
- float tang[3], *tav;
- float *uv1, *uv2, *uv3, *uv4;
- float uv[4][2];
-
- if (tface) {
- uv1= tface->uv[0];
- uv2= tface->uv[1];
- uv3= tface->uv[2];
- uv4= tface->uv[3];
- }
- else if (v1->orco) {
- uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3];
- map_to_sphere(&uv[0][0], &uv[0][1], v1->orco[0], v1->orco[1], v1->orco[2]);
- map_to_sphere(&uv[1][0], &uv[1][1], v2->orco[0], v2->orco[1], v2->orco[2]);
- map_to_sphere(&uv[2][0], &uv[2][1], v3->orco[0], v3->orco[1], v3->orco[2]);
- if (v4)
- map_to_sphere(&uv[3][0], &uv[3][1], v4->orco[0], v4->orco[1], v4->orco[2]);
- }
- else return;
-
- tangent_from_uv_v3(uv1, uv2, uv3, v1->co, v2->co, v3->co, vlr->n, tang);
-
- if (do_tangent) {
- tav= RE_vertren_get_tangent(obr, v1, 1);
- add_v3_v3(tav, tang);
- tav= RE_vertren_get_tangent(obr, v2, 1);
- add_v3_v3(tav, tang);
- tav= RE_vertren_get_tangent(obr, v3, 1);
- add_v3_v3(tav, tang);
- }
-
- if (v4) {
- tangent_from_uv_v3(uv1, uv3, uv4, v1->co, v3->co, v4->co, vlr->n, tang);
-
- if (do_tangent) {
- tav= RE_vertren_get_tangent(obr, v1, 1);
- add_v3_v3(tav, tang);
- tav= RE_vertren_get_tangent(obr, v3, 1);
- add_v3_v3(tav, tang);
- tav= RE_vertren_get_tangent(obr, v4, 1);
- add_v3_v3(tav, tang);
- }
- }
-}
-
-
-
-/****************************************************************
- ************ tangent space generation interface ****************
- ****************************************************************/
-
-typedef struct {
- ObjectRen *obr;
- int mtface_index;
-} SRenderMeshToTangent;
-
-/* interface */
-#include "mikktspace.h"
-
-static int GetNumFaces(const SMikkTSpaceContext *pContext)
-{
- SRenderMeshToTangent *pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
- return pMesh->obr->totvlak;
-}
-
-static int GetNumVertsOfFace(const SMikkTSpaceContext *pContext, const int face_num)
-{
- SRenderMeshToTangent *pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
- VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
- return vlr->v4!=NULL ? 4 : 3;
-}
-
-static void GetPosition(const SMikkTSpaceContext *pContext, float r_co[3], const int face_num, const int vert_index)
-{
- //assert(vert_index>=0 && vert_index<4);
- SRenderMeshToTangent *pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
- VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
- const float *co = (&vlr->v1)[vert_index]->co;
- copy_v3_v3(r_co, co);
-}
-
-static void GetTextureCoordinate(const SMikkTSpaceContext *pContext, float r_uv[2], const int face_num, const int vert_index)
-{
- //assert(vert_index>=0 && vert_index<4);
- SRenderMeshToTangent *pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
- VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
- MTFace *tface= RE_vlakren_get_tface(pMesh->obr, vlr, pMesh->mtface_index, NULL, 0);
- const float *coord;
-
- if (tface != NULL) {
- coord= tface->uv[vert_index];
- copy_v2_v2(r_uv, coord);
- }
- else if ((coord = (&vlr->v1)[vert_index]->orco)) {
- map_to_sphere(&r_uv[0], &r_uv[1], coord[0], coord[1], coord[2]);
- }
- else { /* else we get un-initialized value, 0.0 ok default? */
- zero_v2(r_uv);
- }
-}
-
-static void GetNormal(const SMikkTSpaceContext *pContext, float r_no[3], const int face_num, const int vert_index)
-{
- //assert(vert_index>=0 && vert_index<4);
- SRenderMeshToTangent *pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
- VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
-
- if (vlr->flag & ME_SMOOTH) {
- const float *n = (&vlr->v1)[vert_index]->n;
- copy_v3_v3(r_no, n);
- }
- else {
- negate_v3_v3(r_no, vlr->n);
- }
-}
-static void SetTSpace(const SMikkTSpaceContext *pContext, const float fvTangent[3], const float fSign, const int face_num, const int iVert)
-{
- //assert(vert_index>=0 && vert_index<4);
- SRenderMeshToTangent *pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
- VlakRen *vlr = RE_findOrAddVlak(pMesh->obr, face_num);
- float *ftang = RE_vlakren_get_nmap_tangent(pMesh->obr, vlr, pMesh->mtface_index, true);
- if (ftang!=NULL) {
- copy_v3_v3(&ftang[iVert*4+0], fvTangent);
- ftang[iVert*4+3]=fSign;
- }
-}
-
-static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, bool do_vertex_normal, bool do_tangent, bool do_nmap_tangent)
-{
- int a;
-
- /* clear all vertex normals */
- if (do_vertex_normal) {
- for (a=0; a<obr->totvert; a++) {
- VertRen *ver= RE_findOrAddVert(obr, a);
- ver->n[0]=ver->n[1]=ver->n[2]= 0.0f;
- }
- }
-
- /* calculate cos of angles and point-masses, use as weight factor to
- * add face normal to vertex */
- for (a=0; a<obr->totvlak; a++) {
- VlakRen *vlr= RE_findOrAddVlak(obr, a);
- if (do_vertex_normal && vlr->flag & ME_SMOOTH) {
- float *n4= (vlr->v4)? vlr->v4->n: NULL;
- const float *c4= (vlr->v4)? vlr->v4->co: NULL;
-
- accumulate_vertex_normals_v3(vlr->v1->n, vlr->v2->n, vlr->v3->n, n4,
- vlr->n, vlr->v1->co, vlr->v2->co, vlr->v3->co, c4);
- }
- if (do_tangent) {
- /* tangents still need to be calculated for flat faces too */
- /* weighting removed, they are not vertexnormals */
- calc_tangent_vector(obr, vlr, do_tangent);
- }
- }
-
- /* do solid faces */
- for (a=0; a<obr->totvlak; a++) {
- VlakRen *vlr= RE_findOrAddVlak(obr, a);
-
- if (do_vertex_normal && (vlr->flag & ME_SMOOTH)==0) {
- if (is_zero_v3(vlr->v1->n)) copy_v3_v3(vlr->v1->n, vlr->n);
- if (is_zero_v3(vlr->v2->n)) copy_v3_v3(vlr->v2->n, vlr->n);
- if (is_zero_v3(vlr->v3->n)) copy_v3_v3(vlr->v3->n, vlr->n);
- if (vlr->v4 && is_zero_v3(vlr->v4->n)) copy_v3_v3(vlr->v4->n, vlr->n);
- }
- }
-
- /* normalize vertex normals */
- for (a=0; a<obr->totvert; a++) {
- VertRen *ver= RE_findOrAddVert(obr, a);
- normalize_v3(ver->n);
- if (do_tangent) {
- float *tav= RE_vertren_get_tangent(obr, ver, 0);
- if (tav) {
- /* orthonorm. */
- const float tdn = dot_v3v3(tav, ver->n);
- tav[0] -= ver->n[0]*tdn;
- tav[1] -= ver->n[1]*tdn;
- tav[2] -= ver->n[2]*tdn;
- normalize_v3(tav);
- }
- }
- }
-
- /* normal mapping tangent with mikktspace */
- if (do_nmap_tangent != false) {
- SRenderMeshToTangent mesh2tangent;
- SMikkTSpaceContext sContext;
- SMikkTSpaceInterface sInterface;
- memset(&mesh2tangent, 0, sizeof(SRenderMeshToTangent));
- memset(&sContext, 0, sizeof(SMikkTSpaceContext));
- memset(&sInterface, 0, sizeof(SMikkTSpaceInterface));
-
- mesh2tangent.obr = obr;
-
- sContext.m_pUserData = &mesh2tangent;
- sContext.m_pInterface = &sInterface;
- sInterface.m_getNumFaces = GetNumFaces;
- sInterface.m_getNumVerticesOfFace = GetNumVertsOfFace;
- sInterface.m_getPosition = GetPosition;
- sInterface.m_getTexCoord = GetTextureCoordinate;
- sInterface.m_getNormal = GetNormal;
- sInterface.m_setTSpaceBasic = SetTSpace;
-
- for (a = 0; a < MAX_MTFACE; a++) {
- if (obr->tangent_mask & 1 << a) {
- mesh2tangent.mtface_index = a;
- genTangSpaceDefault(&sContext);
- }
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-/* Autosmoothing: */
-/* ------------------------------------------------------------------------- */
-
-typedef struct ASvert {
- int totface;
- ListBase faces;
-} ASvert;
-
-typedef struct ASface {
- struct ASface *next, *prev;
- VlakRen *vlr[4];
- VertRen *nver[4];
-} ASface;
-
-static int as_addvert(ASvert *asv, VertRen *v1, VlakRen *vlr)
-{
- ASface *asf;
- int a = -1;
-
- if (v1 == NULL)
- return a;
-
- asf = asv->faces.last;
- if (asf) {
- for (a = 0; a < 4 && asf->vlr[a]; a++) {
- }
- }
- else {
- a = 4;
- }
-
- /* new face struct */
- if (a == 4) {
- a = 0;
- asf = MEM_callocN(sizeof(ASface), "asface");
- BLI_addtail(&asv->faces, asf);
- }
-
- asf->vlr[a] = vlr;
- asv->totface++;
-
- return a;
-}
-
-static VertRen *as_findvertex_lnor(VlakRen *vlr, VertRen *ver, ASvert *asv, const float lnor[3])
-{
- /* return when new vertex already was made, or existing one is OK */
- ASface *asf;
- int a;
-
- /* First face, we can use existing vert and assign it current lnor! */
- if (asv->totface == 1) {
- copy_v3_v3(ver->n, lnor);
- return ver;
- }
-
- /* In case existing ver has same normal as current lnor, we can simply use it! */
- if (equals_v3v3(lnor, ver->n)) {
- return ver;
- }
-
- asf = asv->faces.first;
- while (asf) {
- for (a = 0; a < 4; a++) {
- if (asf->vlr[a] && asf->vlr[a] != vlr) {
- /* this face already made a copy for this vertex! */
- if (asf->nver[a]) {
- if (equals_v3v3(lnor, asf->nver[a]->n)) {
- return asf->nver[a];
- }
- }
- }
- }
- asf = asf->next;
- }
-
- return NULL;
-}
-
-static void as_addvert_lnor(ObjectRen *obr, ASvert *asv, VertRen *ver, VlakRen *vlr, const short _lnor[3])
-{
- VertRen *v1;
- ASface *asf;
- int asf_idx;
- float lnor[3];
-
- normal_short_to_float_v3(lnor, _lnor);
-
- asf_idx = as_addvert(asv, ver, vlr);
- if (asf_idx < 0) {
- return;
- }
- asf = asv->faces.last;
-
- /* already made a new vertex within threshold? */
- v1 = as_findvertex_lnor(vlr, ver, asv, lnor);
- if (v1 == NULL) {
- /* make a new vertex */
- v1 = RE_vertren_copy(obr, ver);
- copy_v3_v3(v1->n, lnor);
- }
- if (v1 != ver) {
- asf->nver[asf_idx] = v1;
- if (vlr->v1 == ver) vlr->v1 = v1;
- if (vlr->v2 == ver) vlr->v2 = v1;
- if (vlr->v3 == ver) vlr->v3 = v1;
- if (vlr->v4 == ver) vlr->v4 = v1;
- }
-}
-
-/* note; autosmooth happens in object space still, after applying autosmooth we rotate */
-/* note2; actually, when original mesh and displist are equal sized, face normals are from original mesh */
-static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[4][4], short (*lnors)[4][3])
-{
- ASvert *asverts;
- VertRen *ver;
- VlakRen *vlr;
- int a, totvert;
-
- float rot[3][3];
-
- /* Note: For normals, we only want rotation, not scaling component.
- * Negative scales (aka mirroring) give wrong results, see T44102. */
- if (lnors) {
- float mat3[3][3], size[3];
-
- copy_m3_m4(mat3, mat);
- mat3_to_rot_size(rot, size, mat3);
- }
-
- if (obr->totvert == 0)
- return;
-
- totvert = obr->totvert;
- asverts = MEM_callocN(sizeof(ASvert) * totvert, "all smooth verts");
-
- if (lnors) {
- /* We construct listbase of all vertices and pointers to faces, and add new verts when needed
- * (i.e. when existing ones do not share the same (loop)normal).
- */
- for (a = 0; a < obr->totvlak; a++, lnors++) {
- vlr = RE_findOrAddVlak(obr, a);
- /* skip wire faces */
- if (vlr->v2 != vlr->v3) {
- as_addvert_lnor(obr, asverts+vlr->v1->index, vlr->v1, vlr, (const short*)lnors[0][0]);
- as_addvert_lnor(obr, asverts+vlr->v2->index, vlr->v2, vlr, (const short*)lnors[0][1]);
- as_addvert_lnor(obr, asverts+vlr->v3->index, vlr->v3, vlr, (const short*)lnors[0][2]);
- if (vlr->v4)
- as_addvert_lnor(obr, asverts+vlr->v4->index, vlr->v4, vlr, (const short*)lnors[0][3]);
- }
- }
- }
-
- /* free */
- for (a = 0; a < totvert; a++) {
- BLI_freelistN(&asverts[a].faces);
- }
- MEM_freeN(asverts);
-
- /* rotate vertices and calculate normal of faces */
- for (a = 0; a < obr->totvert; a++) {
- ver = RE_findOrAddVert(obr, a);
- mul_m4_v3(mat, ver->co);
- if (lnors) {
- mul_m3_v3(rot, ver->n);
- negate_v3(ver->n);
- }
- }
- for (a = 0; a < obr->totvlak; a++) {
- vlr = RE_findOrAddVlak(obr, a);
-
- /* skip wire faces */
- if (vlr->v2 != vlr->v3) {
- if (vlr->v4)
- normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- else
- normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-/* Orco hash and Materials */
-/* ------------------------------------------------------------------------- */
-
-static float *get_object_orco(Render *re, void *ob)
-{
- if (!re->orco_hash) {
- return NULL;
- }
-
- return BLI_ghash_lookup(re->orco_hash, ob);
-}
-
-static void set_object_orco(Render *re, void *ob, float *orco)
-{
- if (!re->orco_hash)
- re->orco_hash = BLI_ghash_ptr_new("set_object_orco gh");
-
- BLI_ghash_insert(re->orco_hash, ob, orco);
-}
-
-static void free_mesh_orco_hash(Render *re)
-{
- if (re->orco_hash) {
- BLI_ghash_free(re->orco_hash, NULL, MEM_freeN);
- re->orco_hash = NULL;
- }
-}
-
-static void check_material_mapto(Material *ma)
-{
- int a;
- ma->mapto_textured = 0;
-
- /* cache which inputs are actually textured.
- * this can avoid a bit of time spent iterating through all the texture slots, map inputs and map tos
- * every time a property which may or may not be textured is accessed */
-
- for (a=0; a<MAX_MTEX; a++) {
- if (ma->mtex[a] && ma->mtex[a]->tex) {
- /* currently used only in volume render, so we'll check for those flags */
- if (ma->mtex[a]->mapto & MAP_DENSITY) ma->mapto_textured |= MAP_DENSITY;
- if (ma->mtex[a]->mapto & MAP_EMISSION) ma->mapto_textured |= MAP_EMISSION;
- if (ma->mtex[a]->mapto & MAP_EMISSION_COL) ma->mapto_textured |= MAP_EMISSION_COL;
- if (ma->mtex[a]->mapto & MAP_SCATTERING) ma->mapto_textured |= MAP_SCATTERING;
- if (ma->mtex[a]->mapto & MAP_TRANSMISSION_COL) ma->mapto_textured |= MAP_TRANSMISSION_COL;
- if (ma->mtex[a]->mapto & MAP_REFLECTION) ma->mapto_textured |= MAP_REFLECTION;
- if (ma->mtex[a]->mapto & MAP_REFLECTION_COL) ma->mapto_textured |= MAP_REFLECTION_COL;
- }
- }
-}
-static void flag_render_node_material(Render *re, bNodeTree *ntree)
-{
- bNode *node;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->id) {
- if (GS(node->id->name)==ID_MA) {
- Material *ma= (Material *)node->id;
-
- if ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))
- re->flag |= R_ZTRA;
-
- ma->flag |= MA_IS_USED;
- }
- else if (node->type==NODE_GROUP)
- flag_render_node_material(re, (bNodeTree *)node->id);
- }
- }
-}
-
-static Material *give_render_material(Render *re, Object *ob, short nr)
-{
- extern Material defmaterial; /* material.c */
- Material *ma;
-
- ma= give_current_material(ob, nr);
- if (ma==NULL)
- ma= &defmaterial;
-
- if (re->r.mode & R_SPEED) ma->texco |= NEED_UV;
-
- if (ma->material_type == MA_TYPE_VOLUME) {
- ma->mode |= MA_TRANSP;
- ma->mode &= ~MA_SHADBUF;
- }
- if ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))
- re->flag |= R_ZTRA;
-
- /* for light groups and SSS */
- ma->flag |= MA_IS_USED;
-
- if (ma->nodetree && ma->use_nodes)
- flag_render_node_material(re, ma->nodetree);
-
- check_material_mapto(ma);
-
- return ma;
-}
-
-/* ------------------------------------------------------------------------- */
-/* Particles */
-/* ------------------------------------------------------------------------- */
-typedef struct ParticleStrandData {
- struct MCol *mcol;
- float *orco, *uvco, *surfnor;
- float time, adapt_angle, adapt_pix, size;
- int totuv, totcol;
- int first, line, adapt, override_uv;
-}
-ParticleStrandData;
-/* future thread problem... */
-static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, ParticleStrandData *sd, const float vec[3], const float vec1[3])
-{
- static VertRen *v1= NULL, *v2= NULL;
- VlakRen *vlr= NULL;
- float nor[3], cross[3], crosslen, w, dx, dy, width;
- static float anor[3], avec[3];
- int flag, i;
- static int second=0;
-
- sub_v3_v3v3(nor, vec, vec1);
- normalize_v3(nor); /* nor needed as tangent */
- cross_v3_v3v3(cross, vec, nor);
-
- /* turn cross in pixelsize */
- w= vec[2]*re->winmat[2][3] + re->winmat[3][3];
- dx= re->winx*cross[0]*re->winmat[0][0];
- dy= re->winy*cross[1]*re->winmat[1][1];
- w = sqrtf(dx * dx + dy * dy) / w;
-
- if (w!=0.0f) {
- float fac;
- if (ma->strand_ease!=0.0f) {
- if (ma->strand_ease<0.0f)
- fac= pow(sd->time, 1.0f+ma->strand_ease);
- else
- fac= pow(sd->time, 1.0f/(1.0f-ma->strand_ease));
- }
- else fac= sd->time;
-
- width= ((1.0f-fac)*ma->strand_sta + (fac)*ma->strand_end);
-
- /* use actual Blender units for strand width and fall back to minimum width */
- if (ma->mode & MA_STR_B_UNITS) {
- crosslen= len_v3(cross);
- w= 2.0f*crosslen*ma->strand_min/w;
-
- if (width < w)
- width= w;
-
- /*cross is the radius of the strand so we want it to be half of full width */
- mul_v3_fl(cross, 0.5f/crosslen);
- }
- else
- width/=w;
-
- mul_v3_fl(cross, width);
- }
-
- if (ma->mode & MA_TANGENT_STR)
- flag= R_SMOOTH|R_TANGENT;
- else
- flag= R_SMOOTH;
-
- /* only 1 pixel wide strands filled in as quads now, otherwise zbuf errors */
- if (ma->strand_sta==1.0f)
- flag |= R_STRAND;
-
- /* single face line */
- if (sd->line) {
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->flag= flag;
- vlr->v1= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v2= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v3= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v4= RE_findOrAddVert(obr, obr->totvert++);
-
- copy_v3_v3(vlr->v1->co, vec);
- add_v3_v3(vlr->v1->co, cross);
- copy_v3_v3(vlr->v1->n, nor);
- vlr->v1->orco= sd->orco;
- vlr->v1->accum = -1.0f; /* accum abuse for strand texco */
-
- copy_v3_v3(vlr->v2->co, vec);
- sub_v3_v3v3(vlr->v2->co, vlr->v2->co, cross);
- copy_v3_v3(vlr->v2->n, nor);
- vlr->v2->orco= sd->orco;
- vlr->v2->accum= vlr->v1->accum;
-
- copy_v3_v3(vlr->v4->co, vec1);
- add_v3_v3(vlr->v4->co, cross);
- copy_v3_v3(vlr->v4->n, nor);
- vlr->v4->orco= sd->orco;
- vlr->v4->accum = 1.0f; /* accum abuse for strand texco */
-
- copy_v3_v3(vlr->v3->co, vec1);
- sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross);
- copy_v3_v3(vlr->v3->n, nor);
- vlr->v3->orco= sd->orco;
- vlr->v3->accum= vlr->v4->accum;
-
- normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
-
- vlr->mat= ma;
- vlr->ec= ME_V2V3;
-
- if (sd->surfnor) {
- float *snor= RE_vlakren_get_surfnor(obr, vlr, 1);
- copy_v3_v3(snor, sd->surfnor);
- }
-
- if (sd->uvco) {
- for (i=0; i<sd->totuv; i++) {
- MTFace *mtf;
- mtf=RE_vlakren_get_tface(obr, vlr, i, NULL, 1);
- mtf->uv[0][0]=mtf->uv[1][0]=
- mtf->uv[2][0]=mtf->uv[3][0]=(sd->uvco+2*i)[0];
- mtf->uv[0][1]=mtf->uv[1][1]=
- mtf->uv[2][1]=mtf->uv[3][1]=(sd->uvco+2*i)[1];
- }
- if (sd->override_uv>=0) {
- MTFace *mtf;
- mtf=RE_vlakren_get_tface(obr, vlr, sd->override_uv, NULL, 0);
-
- mtf->uv[0][0]=mtf->uv[3][0]=0.0f;
- mtf->uv[1][0]=mtf->uv[2][0]=1.0f;
-
- mtf->uv[0][1]=mtf->uv[1][1]=0.0f;
- mtf->uv[2][1]=mtf->uv[3][1]=1.0f;
- }
- }
- if (sd->mcol) {
- for (i=0; i<sd->totcol; i++) {
- MCol *mc;
- mc=RE_vlakren_get_mcol(obr, vlr, i, NULL, 1);
- mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i];
- mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i];
- }
- }
- }
- /* first two vertices of a strand */
- else if (sd->first) {
- if (sd->adapt) {
- copy_v3_v3(anor, nor);
- copy_v3_v3(avec, vec);
- second=1;
- }
-
- v1= RE_findOrAddVert(obr, obr->totvert++);
- v2= RE_findOrAddVert(obr, obr->totvert++);
-
- copy_v3_v3(v1->co, vec);
- add_v3_v3(v1->co, cross);
- copy_v3_v3(v1->n, nor);
- v1->orco= sd->orco;
- v1->accum = -1.0f; /* accum abuse for strand texco */
-
- copy_v3_v3(v2->co, vec);
- sub_v3_v3v3(v2->co, v2->co, cross);
- copy_v3_v3(v2->n, nor);
- v2->orco= sd->orco;
- v2->accum= v1->accum;
- }
- /* more vertices & faces to strand */
- else {
- if (sd->adapt==0 || second) {
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->flag= flag;
- vlr->v1= v1;
- vlr->v2= v2;
- vlr->v3= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v4= RE_findOrAddVert(obr, obr->totvert++);
-
- v1= vlr->v4; /* cycle */
- v2= vlr->v3; /* cycle */
-
-
- if (sd->adapt) {
- second=0;
- copy_v3_v3(anor, nor);
- copy_v3_v3(avec, vec);
- }
-
- }
- else if (sd->adapt) {
- float dvec[3], pvec[3];
- sub_v3_v3v3(dvec, avec, vec);
- project_v3_v3v3(pvec, dvec, vec);
- sub_v3_v3v3(dvec, dvec, pvec);
-
- w= vec[2]*re->winmat[2][3] + re->winmat[3][3];
- dx= re->winx*dvec[0]*re->winmat[0][0]/w;
- dy= re->winy*dvec[1]*re->winmat[1][1]/w;
- w = sqrtf(dx * dx + dy * dy);
- if (dot_v3v3(anor, nor)<sd->adapt_angle && w>sd->adapt_pix) {
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->flag= flag;
- vlr->v1= v1;
- vlr->v2= v2;
- vlr->v3= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v4= RE_findOrAddVert(obr, obr->totvert++);
-
- v1= vlr->v4; /* cycle */
- v2= vlr->v3; /* cycle */
-
- copy_v3_v3(anor, nor);
- copy_v3_v3(avec, vec);
- }
- else {
- vlr= RE_findOrAddVlak(obr, obr->totvlak-1);
- }
- }
-
- copy_v3_v3(vlr->v4->co, vec);
- add_v3_v3(vlr->v4->co, cross);
- copy_v3_v3(vlr->v4->n, nor);
- vlr->v4->orco= sd->orco;
- vlr->v4->accum= -1.0f + 2.0f * sd->time; /* accum abuse for strand texco */
-
- copy_v3_v3(vlr->v3->co, vec);
- sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross);
- copy_v3_v3(vlr->v3->n, nor);
- vlr->v3->orco= sd->orco;
- vlr->v3->accum= vlr->v4->accum;
-
- normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
-
- vlr->mat= ma;
- vlr->ec= ME_V2V3;
-
- if (sd->surfnor) {
- float *snor= RE_vlakren_get_surfnor(obr, vlr, 1);
- copy_v3_v3(snor, sd->surfnor);
- }
-
- if (sd->uvco) {
- for (i=0; i<sd->totuv; i++) {
- MTFace *mtf;
- mtf=RE_vlakren_get_tface(obr, vlr, i, NULL, 1);
- mtf->uv[0][0]=mtf->uv[1][0]=
- mtf->uv[2][0]=mtf->uv[3][0]=(sd->uvco+2*i)[0];
- mtf->uv[0][1]=mtf->uv[1][1]=
- mtf->uv[2][1]=mtf->uv[3][1]=(sd->uvco+2*i)[1];
- }
- if (sd->override_uv>=0) {
- MTFace *mtf;
- mtf=RE_vlakren_get_tface(obr, vlr, sd->override_uv, NULL, 0);
-
- mtf->uv[0][0]=mtf->uv[3][0]=0.0f;
- mtf->uv[1][0]=mtf->uv[2][0]=1.0f;
-
- mtf->uv[0][1]=mtf->uv[1][1]=(vlr->v1->accum+1.0f)/2.0f;
- mtf->uv[2][1]=mtf->uv[3][1]=(vlr->v3->accum+1.0f)/2.0f;
- }
- }
- if (sd->mcol) {
- for (i=0; i<sd->totcol; i++) {
- MCol *mc;
- mc=RE_vlakren_get_mcol(obr, vlr, i, NULL, 1);
- mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i];
- mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i];
- }
- }
- }
-}
-
-static void static_particle_wire(ObjectRen *obr, Material *ma, const float vec[3], const float vec1[3], int first, int line)
-{
- VlakRen *vlr;
- static VertRen *v1;
-
- if (line) {
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->v1= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v2= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v3= vlr->v2;
- vlr->v4= NULL;
-
- copy_v3_v3(vlr->v1->co, vec);
- copy_v3_v3(vlr->v2->co, vec1);
-
- sub_v3_v3v3(vlr->n, vec, vec1);
- normalize_v3(vlr->n);
- copy_v3_v3(vlr->v1->n, vlr->n);
- copy_v3_v3(vlr->v2->n, vlr->n);
-
- vlr->mat= ma;
- vlr->ec= ME_V1V2;
-
- }
- else if (first) {
- v1= RE_findOrAddVert(obr, obr->totvert++);
- copy_v3_v3(v1->co, vec);
- }
- else {
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->v1= v1;
- vlr->v2= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v3= vlr->v2;
- vlr->v4= NULL;
-
- v1= vlr->v2; /* cycle */
- copy_v3_v3(v1->co, vec);
-
- sub_v3_v3v3(vlr->n, vec, vec1);
- normalize_v3(vlr->n);
- copy_v3_v3(v1->n, vlr->n);
-
- vlr->mat= ma;
- vlr->ec= ME_V1V2;
- }
-
-}
-
-static void particle_curve(Render *re, ObjectRen *obr, DerivedMesh *dm, Material *ma, ParticleStrandData *sd,
- const float loc[3], const float loc1[3], int seed, float *pa_co)
-{
- HaloRen *har = NULL;
-
- if (ma->material_type == MA_TYPE_WIRE)
- static_particle_wire(obr, ma, loc, loc1, sd->first, sd->line);
- else if (ma->material_type == MA_TYPE_HALO) {
- har= RE_inithalo_particle(re, obr, dm, ma, loc, loc1, sd->orco, sd->uvco, sd->size, 1.0, seed, pa_co);
- if (har) har->lay= obr->ob->lay;
- }
- else
- static_particle_strand(re, obr, ma, sd, loc, loc1);
-}
-static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, ParticleBillboardData *bb)
-{
- VlakRen *vlr;
- MTFace *mtf;
- float xvec[3], yvec[3], zvec[3], bb_center[3];
- /* Number of tiles */
- int totsplit = bb->uv_split * bb->uv_split;
- int tile, x, y;
- /* Tile offsets */
- float uvx = 0.0f, uvy = 0.0f, uvdx = 1.0f, uvdy = 1.0f, time = 0.0f;
-
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->v1= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v2= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v3= RE_findOrAddVert(obr, obr->totvert++);
- vlr->v4= RE_findOrAddVert(obr, obr->totvert++);
-
- psys_make_billboard(bb, xvec, yvec, zvec, bb_center);
-
- add_v3_v3v3(vlr->v1->co, bb_center, xvec);
- add_v3_v3(vlr->v1->co, yvec);
- mul_m4_v3(re->viewmat, vlr->v1->co);
-
- sub_v3_v3v3(vlr->v2->co, bb_center, xvec);
- add_v3_v3(vlr->v2->co, yvec);
- mul_m4_v3(re->viewmat, vlr->v2->co);
-
- sub_v3_v3v3(vlr->v3->co, bb_center, xvec);
- sub_v3_v3v3(vlr->v3->co, vlr->v3->co, yvec);
- mul_m4_v3(re->viewmat, vlr->v3->co);
-
- add_v3_v3v3(vlr->v4->co, bb_center, xvec);
- sub_v3_v3(vlr->v4->co, yvec);
- mul_m4_v3(re->viewmat, vlr->v4->co);
-
- normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- copy_v3_v3(vlr->v1->n, vlr->n);
- copy_v3_v3(vlr->v2->n, vlr->n);
- copy_v3_v3(vlr->v3->n, vlr->n);
- copy_v3_v3(vlr->v4->n, vlr->n);
-
- vlr->mat= ma;
- vlr->ec= ME_V2V3;
-
- if (bb->uv_split > 1) {
- uvdx = uvdy = 1.0f / (float)bb->uv_split;
-
- if (ELEM(bb->anim, PART_BB_ANIM_AGE, PART_BB_ANIM_FRAME)) {
- if (bb->anim == PART_BB_ANIM_FRAME)
- time = ((int)(bb->time * bb->lifetime) % totsplit)/(float)totsplit;
- else
- time = bb->time;
- }
- else if (bb->anim == PART_BB_ANIM_ANGLE) {
- if (bb->align == PART_BB_VIEW) {
- time = (float)fmod((bb->tilt + 1.0f) / 2.0f, 1.0);
- }
- else {
- float axis1[3] = {0.0f, 0.0f, 0.0f};
- float axis2[3] = {0.0f, 0.0f, 0.0f};
-
- axis1[(bb->align + 1) % 3] = 1.0f;
- axis2[(bb->align + 2) % 3] = 1.0f;
-
- if (bb->lock == 0) {
- zvec[bb->align] = 0.0f;
- normalize_v3(zvec);
- }
-
- time = saacos(dot_v3v3(zvec, axis1)) / (float)M_PI;
-
- if (dot_v3v3(zvec, axis2) < 0.0f)
- time = 1.0f - time / 2.0f;
- else
- time /= 2.0f;
- }
- }
-
- if (bb->split_offset == PART_BB_OFF_LINEAR)
- time = (float)fmod(time + (float)bb->num / (float)totsplit, 1.0f);
- else if (bb->split_offset==PART_BB_OFF_RANDOM)
- time = (float)fmod(time + bb->random, 1.0f);
-
- /* Find the coordinates in tile space (integer), then convert to UV
- * space (float). Note that Y is flipped. */
- tile = (int)((time + FLT_EPSILON10) * totsplit);
- x = tile % bb->uv_split;
- y = tile / bb->uv_split;
- y = (bb->uv_split - 1) - y;
- uvx = uvdx * x;
- uvy = uvdy * y;
- }
-
- /* normal UVs */
- if (bb->uv[0] >= 0) {
- mtf = RE_vlakren_get_tface(obr, vlr, bb->uv[0], NULL, 1);
- mtf->uv[0][0] = 1.0f;
- mtf->uv[0][1] = 1.0f;
- mtf->uv[1][0] = 0.0f;
- mtf->uv[1][1] = 1.0f;
- mtf->uv[2][0] = 0.0f;
- mtf->uv[2][1] = 0.0f;
- mtf->uv[3][0] = 1.0f;
- mtf->uv[3][1] = 0.0f;
- }
-
- /* time-index UVs */
- if (bb->uv[1] >= 0) {
- mtf = RE_vlakren_get_tface(obr, vlr, bb->uv[1], NULL, 1);
- mtf->uv[0][0] = mtf->uv[1][0] = mtf->uv[2][0] = mtf->uv[3][0] = bb->time;
- mtf->uv[0][1] = mtf->uv[1][1] = mtf->uv[2][1] = mtf->uv[3][1] = (float)bb->num/(float)bb->totnum;
- }
-
- /* split UVs */
- if (bb->uv_split > 1 && bb->uv[2] >= 0) {
- mtf = RE_vlakren_get_tface(obr, vlr, bb->uv[2], NULL, 1);
- mtf->uv[0][0] = uvx + uvdx;
- mtf->uv[0][1] = uvy + uvdy;
- mtf->uv[1][0] = uvx;
- mtf->uv[1][1] = uvy + uvdy;
- mtf->uv[2][0] = uvx;
- mtf->uv[2][1] = uvy;
- mtf->uv[3][0] = uvx + uvdx;
- mtf->uv[3][1] = uvy;
- }
-}
-static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re, ObjectRen *obr, DerivedMesh *dm, Material *ma, ParticleStrandData *sd, ParticleBillboardData *bb, ParticleKey *state, int seed, float hasize, float *pa_co)
-{
- float loc[3], loc0[3], loc1[3], vel[3];
-
- copy_v3_v3(loc, state->co);
-
- if (ren_as != PART_DRAW_BB)
- mul_m4_v3(re->viewmat, loc);
-
- switch (ren_as) {
- case PART_DRAW_LINE:
- sd->line = 1;
- sd->time = 0.0f;
- sd->size = hasize;
-
- mul_v3_mat3_m4v3(vel, re->viewmat, state->vel);
- normalize_v3(vel);
-
- if (part->draw & PART_DRAW_VEL_LENGTH)
- mul_v3_fl(vel, len_v3(state->vel));
-
- madd_v3_v3v3fl(loc0, loc, vel, -part->draw_line[0]);
- madd_v3_v3v3fl(loc1, loc, vel, part->draw_line[1]);
-
- particle_curve(re, obr, dm, ma, sd, loc0, loc1, seed, pa_co);
-
- break;
-
- case PART_DRAW_BB:
-
- copy_v3_v3(bb->vec, loc);
- copy_v3_v3(bb->vel, state->vel);
-
- particle_billboard(re, obr, ma, bb);
-
- break;
-
- default:
- {
- HaloRen *har = NULL;
-
- har = RE_inithalo_particle(re, obr, dm, ma, loc, NULL, sd->orco, sd->uvco, hasize, 0.0, seed, pa_co);
-
- if (har) har->lay= obr->ob->lay;
-
- break;
- }
- }
-}
-static void get_particle_uvco_mcol(short from, DerivedMesh *dm, float *fuv, int num, ParticleStrandData *sd)
-{
- int i;
-
- /* get uvco */
- if (sd->uvco && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) {
- for (i=0; i<sd->totuv; i++) {
- if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
- MFace *mface = dm->getTessFaceData(dm, num, CD_MFACE);
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&dm->faceData, CD_MTFACE, i);
- mtface += num;
-
- psys_interpolate_uvs(mtface, mface->v4, fuv, sd->uvco + 2 * i);
- }
- else {
- sd->uvco[2*i] = 0.0f;
- sd->uvco[2*i + 1] = 0.0f;
- }
- }
- }
-
- /* get mcol */
- if (sd->mcol && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) {
- for (i=0; i<sd->totcol; i++) {
- if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
- MFace *mface = dm->getTessFaceData(dm, num, CD_MFACE);
- MCol *mc = (MCol*)CustomData_get_layer_n(&dm->faceData, CD_MCOL, i);
- mc += num * 4;
-
- psys_interpolate_mcol(mc, mface->v4, fuv, sd->mcol + i);
- }
- else
- memset(&sd->mcol[i], 0, sizeof(MCol));
- }
- }
-}
-static int render_new_particle_system(const EvaluationContext *eval_ctx, Render *re,
- ObjectRen *obr, ParticleSystem *psys, int timeoffset)
-{
- Object *ob= obr->ob;
-// Object *tob=0;
- Material *ma = NULL;
- ParticleSystemModifierData *psmd;
- ParticleSystem *tpsys = NULL;
- ParticleSettings *part, *tpart = NULL;
- ParticleData *pars, *pa = NULL, *tpa = NULL;
- ParticleKey *states = NULL;
- ParticleKey state;
- ParticleCacheKey *cache = NULL;
- ParticleBillboardData bb;
- ParticleSimulationData sim = {NULL};
- ParticleStrandData sd;
- StrandBuffer *strandbuf = NULL;
- StrandVert *svert = NULL;
- StrandBound *sbound = NULL;
- StrandRen *strand = NULL;
- RNG *rng = NULL;
- float loc[3], loc1[3], loc0[3], mat[4][4], nmat[3][3], co[3], nor[3], duplimat[4][4];
- float strandlen=0.0f, curlen=0.0f;
- float hasize, pa_size, r_tilt, r_length;
- float pa_time, pa_birthtime, pa_dietime;
- float random, pa_co[3];
- const float cfra= BKE_scene_frame_get(re->scene);
- int i, a, k, max_k=0, totpart;
- bool do_surfacecache = false, use_duplimat = false;
- int totchild=0, step_nbr;
- int seed, path_nbr=0, orco1=0, num;
- int totface;
-
- const int *index_mf_to_mpoly = NULL;
- const int *index_mp_to_orig = NULL;
-
-/* 1. check that everything is ok & updated */
- if (psys==NULL)
- return 0;
-
- part=psys->part;
- pars=psys->particles;
-
- if (part==NULL || pars==NULL || !psys_check_enabled(ob, psys, G.is_rendering))
- return 0;
-
- if (part->ren_as==PART_DRAW_OB || part->ren_as==PART_DRAW_GR || part->ren_as==PART_DRAW_NOT)
- return 1;
-
- if ((re->r.scemode & R_VIEWPORT_PREVIEW) && (ob->mode & OB_MODE_PARTICLE_EDIT))
- return 0;
-
- if (part->ren_as == PART_DRAW_BB && part->bb_ob == NULL && RE_GetCamera(re) == NULL)
- return 0;
-
-/* 2. start initializing things */
-
- /* last possibility to bail out! */
- psmd = psys_get_modifier(ob, psys);
- if (!(psmd->modifier.mode & eModifierMode_Render))
- return 0;
-
- sim.eval_ctx = eval_ctx;
- sim.scene = re->scene;
- sim.ob = ob;
- sim.psys = psys;
- sim.psmd = psmd;
-
- if (part->phystype==PART_PHYS_KEYED)
- psys_count_keyed_targets(&sim);
-
- totchild=psys->totchild;
-
- /* can happen for disconnected/global hair */
- if (part->type==PART_HAIR && !psys->childcache)
- totchild= 0;
-
- if (re->r.scemode & R_VIEWPORT_PREVIEW) { /* preview render */
- totchild = (int)((float)totchild * (float)part->disp / 100.0f);
- step_nbr = 1 << part->draw_step;
- }
- else {
- step_nbr = 1 << part->ren_step;
- }
- if (ELEM(part->kink, PART_KINK_SPIRAL))
- step_nbr += part->kink_extra_steps;
-
- psys->flag |= PSYS_DRAWING;
-
- rng= BLI_rng_new(psys->seed);
-
- totpart=psys->totpart;
-
- memset(&sd, 0, sizeof(ParticleStrandData));
- sd.override_uv = -1;
-
-/* 2.1 setup material stff */
- ma= give_render_material(re, ob, part->omat);
-
-#if 0 /* XXX old animation system */
- if (ma->ipo) {
- calc_ipo(ma->ipo, cfra);
- execute_ipo((ID *)ma, ma->ipo);
- }
-#endif /* XXX old animation system */
-
- hasize = ma->hasize;
- seed = ma->seed1;
-
- re->flag |= R_HALO;
-
- RE_set_customdata_names(obr, &psmd->dm_final->faceData);
- sd.totuv = CustomData_number_of_layers(&psmd->dm_final->faceData, CD_MTFACE);
- sd.totcol = CustomData_number_of_layers(&psmd->dm_final->faceData, CD_MCOL);
-
- if (ma->texco & TEXCO_UV && sd.totuv) {
- sd.uvco = MEM_callocN(sd.totuv * 2 * sizeof(float), "particle_uvs");
-
- if (ma->strand_uvname[0]) {
- sd.override_uv = CustomData_get_named_layer_index(&psmd->dm_final->faceData, CD_MTFACE, ma->strand_uvname);
- sd.override_uv -= CustomData_get_layer_index(&psmd->dm_final->faceData, CD_MTFACE);
- }
- }
- else
- sd.uvco = NULL;
-
- if (sd.totcol)
- sd.mcol = MEM_callocN(sd.totcol * sizeof(MCol), "particle_mcols");
-
-/* 2.2 setup billboards */
- if (part->ren_as == PART_DRAW_BB) {
- int first_uv = CustomData_get_layer_index(&psmd->dm_final->faceData, CD_MTFACE);
-
- bb.uv[0] = CustomData_get_named_layer_index(&psmd->dm_final->faceData, CD_MTFACE, psys->bb_uvname[0]);
- if (bb.uv[0] < 0)
- bb.uv[0] = CustomData_get_active_layer_index(&psmd->dm_final->faceData, CD_MTFACE);
-
- bb.uv[1] = CustomData_get_named_layer_index(&psmd->dm_final->faceData, CD_MTFACE, psys->bb_uvname[1]);
-
- bb.uv[2] = CustomData_get_named_layer_index(&psmd->dm_final->faceData, CD_MTFACE, psys->bb_uvname[2]);
-
- if (first_uv >= 0) {
- bb.uv[0] -= first_uv;
- bb.uv[1] -= first_uv;
- bb.uv[2] -= first_uv;
- }
-
- bb.align = part->bb_align;
- bb.anim = part->bb_anim;
- bb.lock = part->draw & PART_DRAW_BB_LOCK;
- bb.ob = (part->bb_ob ? part->bb_ob : RE_GetCamera(re));
- bb.split_offset = part->bb_split_offset;
- bb.totnum = totpart+totchild;
- bb.uv_split = part->bb_uv_split;
- }
-
-/* 2.5 setup matrices */
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- invert_m4_m4(ob->imat, mat); /* need to be that way, for imat texture */
- transpose_m3_m4(nmat, ob->imat);
-
- if (psys->flag & PSYS_USE_IMAT) {
- /* psys->imat is the original emitter's inverse matrix, ob->obmat is the duplicated object's matrix */
- mul_m4_m4m4(duplimat, ob->obmat, psys->imat);
- use_duplimat = true;
- }
-
-/* 2.6 setup strand rendering */
- if (part->ren_as == PART_DRAW_PATH && psys->pathcache) {
- path_nbr = step_nbr;
-
- if (path_nbr) {
- if (!ELEM(ma->material_type, MA_TYPE_HALO, MA_TYPE_WIRE)) {
- 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);
- }
- }
- }
-
- if (part->draw & PART_DRAW_REN_ADAPT) {
- sd.adapt = 1;
- sd.adapt_pix = (float)part->adapt_pix;
- sd.adapt_angle = cosf(DEG2RADF((float)part->adapt_angle));
- }
-
- if (part->draw & PART_DRAW_REN_STRAND) {
- strandbuf= RE_addStrandBuffer(obr, (totpart+totchild)*(path_nbr+1));
- strandbuf->ma= ma;
- strandbuf->lay= ob->lay;
- copy_m4_m4(strandbuf->winmat, re->winmat);
- strandbuf->winx= re->winx;
- strandbuf->winy= re->winy;
- strandbuf->maxdepth= 2;
- strandbuf->adaptcos= cosf(DEG2RADF((float)part->adapt_angle));
- strandbuf->overrideuv= sd.override_uv;
- strandbuf->minwidth= ma->strand_min;
-
- if (ma->strand_widthfade == 0.0f)
- strandbuf->widthfade= -1.0f;
- else if (ma->strand_widthfade >= 1.0f)
- strandbuf->widthfade= 2.0f - ma->strand_widthfade;
- else
- strandbuf->widthfade= 1.0f/MAX2(ma->strand_widthfade, 1e-5f);
-
- if (part->flag & PART_HAIR_BSPLINE)
- strandbuf->flag |= R_STRAND_BSPLINE;
- if (ma->mode & MA_STR_B_UNITS)
- strandbuf->flag |= R_STRAND_B_UNITS;
-
- svert= strandbuf->vert;
-
- if (re->r.mode & R_SPEED)
- do_surfacecache = true;
- else if ((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && (re->wrld.ao_gather_method == WO_AOGATHER_APPROX))
- if (ma->amb != 0.0f)
- do_surfacecache = true;
-
- totface= psmd->dm_final->getNumTessFaces(psmd->dm_final);
- index_mf_to_mpoly = psmd->dm_final->getTessFaceDataArray(psmd->dm_final, CD_ORIGINDEX);
- index_mp_to_orig = psmd->dm_final->getPolyDataArray(psmd->dm_final, CD_ORIGINDEX);
- if (index_mf_to_mpoly == NULL) {
- index_mp_to_orig = NULL;
- }
- for (a=0; a<totface; a++)
- strandbuf->totbound = max_ii(strandbuf->totbound, (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a): a);
-
- strandbuf->totbound++;
- strandbuf->bound= MEM_callocN(sizeof(StrandBound)*strandbuf->totbound, "StrandBound");
- sbound= strandbuf->bound;
- sbound->start= sbound->end= 0;
- }
- }
-
- if (sd.orco == NULL) {
- sd.orco = MEM_mallocN(3 * sizeof(float), "particle orco");
- orco1 = 1;
- }
-
- if (path_nbr == 0)
- psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
-
-/* 3. start creating renderable things */
- for (a=0, pa=pars; a<totpart+totchild; a++, pa++, seed++) {
- random = BLI_rng_get_float(rng);
- /* setup per particle individual stuff */
- if (a<totpart) {
- if (pa->flag & PARS_UNEXIST) continue;
-
- pa_time=(cfra-pa->time)/pa->lifetime;
- pa_birthtime = pa->time;
- pa_dietime = pa->dietime;
-
- hasize = ma->hasize;
-
- /* XXX 'tpsys' is alwyas NULL, this code won't run! */
- /* get orco */
- if (tpsys && part->phystype == PART_PHYS_NO) {
- tpa = tpsys->particles + pa->num;
- psys_particle_on_emitter(
- psmd,
- tpart->from, tpa->num, pa->num_dmcache, tpa->fuv,
- tpa->foffset, co, nor, NULL, NULL, sd.orco, NULL);
- }
- else {
- psys_particle_on_emitter(
- psmd,
- part->from, pa->num, pa->num_dmcache,
- pa->fuv, pa->foffset, co, nor, NULL, NULL, sd.orco, NULL);
- }
-
- /* get uvco & mcol */
- num= pa->num_dmcache;
-
- if (num == DMCACHE_NOTFOUND)
- if (pa->num < psmd->dm_final->getNumTessFaces(psmd->dm_final))
- num= pa->num;
-
- get_particle_uvco_mcol(part->from, psmd->dm_final, pa->fuv, num, &sd);
-
- pa_size = pa->size;
-
- r_tilt = 2.0f*(psys_frand(psys, a) - 0.5f);
- r_length = psys_frand(psys, a+1);
-
- if (path_nbr) {
- cache = psys->pathcache[a];
- max_k = (int)cache->segments;
- }
-
- if (totchild && (part->draw&PART_DRAW_PARENT)==0) continue;
- }
- else {
- ChildParticle *cpa= psys->child+a-totpart;
-
- if (path_nbr) {
- cache = psys->childcache[a-totpart];
-
- if (cache->segments < 0)
- continue;
-
- max_k = (int)cache->segments;
- }
-
- pa_time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime);
- pa_size = psys_get_child_size(psys, cpa, cfra, &pa_time);
-
- r_tilt = 2.0f*(psys_frand(psys, a + 21) - 0.5f);
- r_length = psys_frand(psys, a + 22);
-
- num = cpa->num;
-
- /* get orco */
- if (part->childtype == PART_CHILD_FACES) {
- psys_particle_on_emitter(
- psmd,
- PART_FROM_FACE, cpa->num, DMCACHE_ISCHILD,
- cpa->fuv, cpa->foffset, co, nor, NULL, NULL, sd.orco, NULL);
- }
- else {
- ParticleData *par = psys->particles + cpa->parent;
- psys_particle_on_emitter(
- psmd,
- part->from, par->num, DMCACHE_ISCHILD, par->fuv,
- par->foffset, co, nor, NULL, NULL, sd.orco, NULL);
- }
-
- /* get uvco & mcol */
- if (part->childtype==PART_CHILD_FACES) {
- get_particle_uvco_mcol(PART_FROM_FACE, psmd->dm_final, cpa->fuv, cpa->num, &sd);
- }
- else {
- ParticleData *parent = psys->particles + cpa->parent;
- num = parent->num_dmcache;
-
- if (num == DMCACHE_NOTFOUND)
- if (parent->num < psmd->dm_final->getNumTessFaces(psmd->dm_final))
- num = parent->num;
-
- get_particle_uvco_mcol(part->from, psmd->dm_final, parent->fuv, num, &sd);
- }
-
- 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) &&
- (orignum < strandbuf->totbound))
- {
- sbound = &strandbuf->bound[orignum];
- sbound->start = sbound->end = obr->totstrand;
- }
- }
- }
-
- /* TEXCO_PARTICLE */
- pa_co[0] = pa_time;
- pa_co[1] = 0.f;
- pa_co[2] = 0.f;
-
- /* surface normal shading setup */
- if (ma->mode_l & MA_STR_SURFDIFF) {
- mul_m3_v3(nmat, nor);
- sd.surfnor= nor;
- }
- else
- sd.surfnor= NULL;
-
- /* strand render setup */
- if (strandbuf) {
- strand= RE_findOrAddStrand(obr, obr->totstrand++);
- strand->buffer= strandbuf;
- strand->vert= svert;
- copy_v3_v3(strand->orco, sd.orco);
-
- if (sd.surfnor) {
- float *snor= RE_strandren_get_surfnor(obr, strand, 1);
- copy_v3_v3(snor, sd.surfnor);
- }
-
- if (do_surfacecache && num >= 0) {
- int *facenum= RE_strandren_get_face(obr, strand, 1);
- *facenum= num;
- }
-
- if (sd.uvco) {
- for (i=0; i<sd.totuv; i++) {
- if (i != sd.override_uv) {
- float *uv= RE_strandren_get_uv(obr, strand, i, NULL, 1);
-
- uv[0]= sd.uvco[2*i];
- uv[1]= sd.uvco[2*i+1];
- }
- }
- }
- if (sd.mcol) {
- for (i=0; i<sd.totcol; i++) {
- MCol *mc= RE_strandren_get_mcol(obr, strand, i, NULL, 1);
- *mc = sd.mcol[i];
- }
- }
-
- sbound->end++;
- }
-
- /* strandco computation setup */
- if (path_nbr) {
- strandlen= 0.0f;
- curlen= 0.0f;
- for (k=1; k<=path_nbr; k++)
- if (k<=max_k)
- strandlen += len_v3v3((cache+k-1)->co, (cache+k)->co);
- }
-
- if (path_nbr) {
- /* render strands */
- for (k=0; k<=path_nbr; k++) {
- float time;
-
- if (k<=max_k) {
- copy_v3_v3(state.co, (cache+k)->co);
- copy_v3_v3(state.vel, (cache+k)->vel);
- }
- else
- continue;
-
- if (k > 0)
- curlen += len_v3v3((cache+k-1)->co, (cache+k)->co);
- time= curlen/strandlen;
-
- copy_v3_v3(loc, state.co);
- mul_m4_v3(re->viewmat, loc);
-
- if (strandbuf) {
- copy_v3_v3(svert->co, loc);
- svert->strandco= -1.0f + 2.0f*time;
- svert++;
- strand->totvert++;
- }
- else {
- sd.size = hasize;
-
- if (k==1) {
- sd.first = 1;
- sd.time = 0.0f;
- sub_v3_v3v3(loc0, loc1, loc);
- add_v3_v3v3(loc0, loc1, loc0);
-
- particle_curve(re, obr, psmd->dm_final, ma, &sd, loc1, loc0, seed, pa_co);
- }
-
- sd.first = 0;
- sd.time = time;
-
- if (k)
- particle_curve(re, obr, psmd->dm_final, ma, &sd, loc, loc1, seed, pa_co);
-
- copy_v3_v3(loc1, loc);
- }
- }
-
- }
- else {
- /* render normal particles */
- if (part->trail_count > 1) {
- float length = part->path_end * (1.0f - part->randlength * r_length);
- int trail_count = part->trail_count * (1.0f - part->randlength * r_length);
- float ct = (part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time;
- float dt = length / (trail_count ? (float)trail_count : 1.0f);
-
- /* make sure we have pointcache in memory before getting particle on path */
- psys_make_temp_pointcache(ob, psys);
-
- for (i=0; i < trail_count; i++, ct -= dt) {
- if (part->draw & PART_ABS_PATH_TIME) {
- if (ct < pa_birthtime || ct > pa_dietime)
- continue;
- }
- else if (ct < 0.0f || ct > 1.0f)
- continue;
-
- state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : ct;
- psys_get_particle_on_path(&sim, a, &state, 1);
-
- if (psys->parent)
- mul_m4_v3(psys->parent->obmat, state.co);
-
- if (use_duplimat)
- mul_m4_v4(duplimat, state.co);
-
- if (part->ren_as == PART_DRAW_BB) {
- bb.random = random;
- bb.offset[0] = part->bb_offset[0];
- bb.offset[1] = part->bb_offset[1];
- bb.size[0] = part->bb_size[0] * pa_size;
- if (part->bb_align==PART_BB_VEL) {
- float pa_vel = len_v3(state.vel);
- float head = part->bb_vel_head*pa_vel;
- float tail = part->bb_vel_tail*pa_vel;
- bb.size[1] = part->bb_size[1]*pa_size + head + tail;
- /* use offset to adjust the particle center. this is relative to size, so need to divide! */
- if (bb.size[1] > 0.0f)
- bb.offset[1] += (head-tail) / bb.size[1];
- }
- else
- bb.size[1] = part->bb_size[1] * pa_size;
- bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
- bb.time = ct;
- bb.num = a;
- }
-
- pa_co[0] = (part->draw & PART_ABS_PATH_TIME) ? (ct-pa_birthtime)/(pa_dietime-pa_birthtime) : ct;
- pa_co[1] = (float)i/(float)(trail_count-1);
-
- particle_normal_ren(part->ren_as, part, re, obr, psmd->dm_final, ma, &sd, &bb, &state, seed, hasize, pa_co);
- }
- }
- else {
- state.time=cfra;
- if (psys_get_particle_state(&sim, a, &state, 0)==0)
- continue;
-
- if (psys->parent)
- mul_m4_v3(psys->parent->obmat, state.co);
-
- if (use_duplimat)
- mul_m4_v3(duplimat, state.co);
-
- if (part->ren_as == PART_DRAW_BB) {
- bb.random = random;
- bb.offset[0] = part->bb_offset[0];
- bb.offset[1] = part->bb_offset[1];
- bb.size[0] = part->bb_size[0] * pa_size;
- if (part->bb_align==PART_BB_VEL) {
- float pa_vel = len_v3(state.vel);
- float head = part->bb_vel_head*pa_vel;
- float tail = part->bb_vel_tail*pa_vel;
- bb.size[1] = part->bb_size[1]*pa_size + head + tail;
- /* use offset to adjust the particle center. this is relative to size, so need to divide! */
- if (bb.size[1] > 0.0f)
- bb.offset[1] += (head-tail) / bb.size[1];
- }
- else
- bb.size[1] = part->bb_size[1] * pa_size;
- bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
- bb.time = pa_time;
- bb.num = a;
- bb.lifetime = pa_dietime-pa_birthtime;
- }
-
- particle_normal_ren(part->ren_as, part, re, obr, psmd->dm_final, ma, &sd, &bb, &state, seed, hasize, pa_co);
- }
- }
-
- if (orco1==0)
- sd.orco+=3;
-
- if (re->test_break(re->tbh))
- break;
- }
-
- if (do_surfacecache)
- strandbuf->surface= cache_strand_surface(re, obr, psmd->dm_final, mat, timeoffset);
-
-/* 4. clean up */
-#if 0 /* XXX old animation system */
- if (ma) do_mat_ipo(re->scene, ma);
-#endif /* XXX old animation system */
-
- if (orco1)
- MEM_freeN(sd.orco);
-
- if (sd.uvco)
- MEM_freeN(sd.uvco);
-
- if (sd.mcol)
- MEM_freeN(sd.mcol);
-
- if (states)
- MEM_freeN(states);
-
- BLI_rng_free(rng);
-
- psys->flag &= ~PSYS_DRAWING;
-
- if (psys->lattice_deform_data) {
- end_latt_deform(psys->lattice_deform_data);
- psys->lattice_deform_data = NULL;
- }
-
- if (path_nbr && (ma->mode_l & MA_TANGENT_STR)==0)
- calc_vertexnormals(re, obr, 1, 0, 0);
-
- return 1;
-}
-
-/* ------------------------------------------------------------------------- */
-/* Halo's */
-/* ------------------------------------------------------------------------- */
-
-static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int totvert, MVert *mvert, Material *ma, float *orco)
-{
- Object *ob= obr->ob;
- HaloRen *har;
- float xn, yn, zn, nor[3], view[3];
- float vec[3], hasize, mat[4][4], imat[3][3];
- int a, ok, seed= ma->seed1;
-
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- copy_m3_m4(imat, ob->imat);
-
- re->flag |= R_HALO;
-
- for (a=0; a<totvert; a++, mvert++) {
- ok= 1;
-
- if (ok) {
- hasize= ma->hasize;
-
- copy_v3_v3(vec, mvert->co);
- mul_m4_v3(mat, vec);
-
- if (ma->mode & MA_HALOPUNO) {
- xn= mvert->no[0];
- yn= mvert->no[1];
- zn= mvert->no[2];
-
- /* transpose ! */
- nor[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
- nor[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
- nor[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
- normalize_v3(nor);
-
- copy_v3_v3(view, vec);
- normalize_v3(view);
-
- zn = dot_v3v3(nor, view);
- if (zn>=0.0f) hasize= 0.0f;
- else hasize*= zn*zn*zn*zn;
- }
-
- if (orco) har= RE_inithalo(re, obr, ma, vec, NULL, orco, hasize, 0.0, seed);
- else har= RE_inithalo(re, obr, ma, vec, NULL, mvert->co, hasize, 0.0, seed);
- if (har) har->lay= ob->lay;
- }
- if (orco) orco+= 3;
- seed++;
- }
-}
-
-static int verghalo(const void *a1, const void *a2)
-{
- const HaloRen *har1= *(const HaloRen**)a1;
- const HaloRen *har2= *(const HaloRen**)a2;
-
- if (har1->zs < har2->zs) return 1;
- else if (har1->zs > har2->zs) return -1;
- return 0;
-}
-
-static void sort_halos(Render *re, int totsort)
-{
- ObjectRen *obr;
- HaloRen *har= NULL, **haso;
- int a;
-
- if (re->tothalo==0) return;
-
- re->sortedhalos= MEM_callocN(sizeof(HaloRen*)*re->tothalo, "sorthalos");
- haso= re->sortedhalos;
-
- for (obr=re->objecttable.first; obr; obr=obr->next) {
- for (a=0; a<obr->tothalo; a++) {
- if ((a & 255)==0) har= obr->bloha[a>>8];
- else har++;
-
- *(haso++)= har;
- }
- }
-
- qsort(re->sortedhalos, totsort, sizeof(HaloRen*), verghalo);
-}
-
-/* ------------------------------------------------------------------------- */
-/* Displacement Mapping */
-/* ------------------------------------------------------------------------- */
-
-static short test_for_displace(Render *re, Object *ob)
-{
- /* return 1 when this object uses displacement textures. */
- Material *ma;
- int i;
-
- for (i=1; i<=ob->totcol; i++) {
- ma=give_render_material(re, ob, i);
- /* ma->mapto is ORed total of all mapto channels */
- if (ma && (ma->mapto & MAP_DISPLACE)) return 1;
- }
- return 0;
-}
-
-static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, VertRen *vr, int vindex, float *scale)
-{
- MTFace *tface;
- short texco= shi->mat->texco;
- float sample=0, displace[3];
- char *name;
- int i;
-
- /* shi->co is current render coord, just make sure at least some vector is here */
- copy_v3_v3(shi->co, vr->co);
- /* vertex normal is used for textures type 'col' and 'var' */
- copy_v3_v3(shi->vn, vr->n);
-
- if (texco & TEXCO_UV) {
- shi->totuv= 0;
- shi->actuv= obr->actmtface;
-
- for (i=0; (tface=RE_vlakren_get_tface(obr, shi->vlr, i, &name, 0)); i++) {
- ShadeInputUV *suv= &shi->uv[i];
-
- /* shi.uv needs scale correction from tface uv */
- suv->uv[0]= 2*tface->uv[vindex][0]-1.0f;
- suv->uv[1]= 2*tface->uv[vindex][1]-1.0f;
- suv->uv[2]= 0.0f;
- suv->name= name;
- shi->totuv++;
- }
- }
-
- /* set all rendercoords, 'texco' is an ORed value for all textures needed */
- if ((texco & TEXCO_ORCO) && (vr->orco)) {
- copy_v3_v3(shi->lo, vr->orco);
- }
- if (texco & TEXCO_GLOB) {
- copy_v3_v3(shi->gl, shi->co);
- mul_m4_v3(re->viewinv, shi->gl);
- }
- if (texco & TEXCO_NORM) {
- copy_v3_v3(shi->orn, shi->vn);
- }
- if (texco & TEXCO_REFL) {
- /* not (yet?) */
- }
- if (texco & TEXCO_STRESS) {
- const float *s= RE_vertren_get_stress(obr, vr, 0);
-
- if (s) {
- shi->stress= *s;
- if (shi->stress<1.0f) shi->stress-= 1.0f;
- else shi->stress= (shi->stress-1.0f)/shi->stress;
- }
- else
- shi->stress= 0.0f;
- }
-
- shi->displace[0]= shi->displace[1]= shi->displace[2]= 0.0;
-
- do_material_tex(shi, re);
-
- //printf("no=%f, %f, %f\nbefore co=%f, %f, %f\n", vr->n[0], vr->n[1], vr->n[2],
- //vr->co[0], vr->co[1], vr->co[2]);
-
- displace[0]= shi->displace[0] * scale[0];
- displace[1]= shi->displace[1] * scale[1];
- displace[2]= shi->displace[2] * scale[2];
-
- /* 0.5 could become button once? */
- vr->co[0] += displace[0];
- vr->co[1] += displace[1];
- vr->co[2] += displace[2];
-
- //printf("after co=%f, %f, %f\n", vr->co[0], vr->co[1], vr->co[2]);
-
- /* we just don't do this vertex again, bad luck for other face using same vertex with
- * different material... */
- vr->flag |= 1;
-
- /* Pass sample back so displace_face can decide which way to split the quad */
- sample = shi->displace[0]*shi->displace[0];
- sample += shi->displace[1]*shi->displace[1];
- sample += shi->displace[2]*shi->displace[2];
-
- vr->accum=sample;
- /* Should be sqrt(sample), but I'm only looking for "bigger". Save the cycles. */
- return;
-}
-
-static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float *scale)
-{
- ShadeInput shi;
-
- /* Warning, This is not that nice, and possibly a bit slow,
- * however some variables were not initialized properly in, unless using shade_input_initialize(...), we need to do a memset */
- memset(&shi, 0, sizeof(ShadeInput));
- /* end warning! - Campbell */
-
- /* set up shadeinput struct for multitex() */
-
- /* memset above means we don't need this */
- /*shi.osatex= 0;*/ /* signal not to use dx[] and dy[] texture AA vectors */
-
- shi.obr= obr;
- shi.vlr= vlr; /* current render face */
- shi.mat= vlr->mat; /* current input material */
- shi.thread= 0;
-
- /* TODO, assign these, displacement with new bumpmap is skipped without - campbell */
-#if 0
- /* order is not known ? */
- shi.v1= vlr->v1;
- shi.v2= vlr->v2;
- shi.v3= vlr->v3;
-#endif
-
- /* Displace the verts, flag is set when done */
- if (!vlr->v1->flag)
- displace_render_vert(re, obr, &shi, vlr->v1, 0, scale);
-
- if (!vlr->v2->flag)
- displace_render_vert(re, obr, &shi, vlr->v2, 1, scale);
-
- if (!vlr->v3->flag)
- displace_render_vert(re, obr, &shi, vlr->v3, 2, scale);
-
- if (vlr->v4) {
- if (!vlr->v4->flag)
- displace_render_vert(re, obr, &shi, vlr->v4, 3, scale);
-
- /* closest in displace value. This will help smooth edges. */
- if (fabsf(vlr->v1->accum - vlr->v3->accum) > fabsf(vlr->v2->accum - vlr->v4->accum)) vlr->flag |= R_DIVIDE_24;
- else vlr->flag &= ~R_DIVIDE_24;
- }
-
- /* Recalculate the face normal - if flipped before, flip now */
- if (vlr->v4) {
- normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- }
- else {
- normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- }
-}
-
-static void displace(Render *re, ObjectRen *obr)
-{
- VertRen *vr;
- VlakRen *vlr;
-// float min[3]={1e30, 1e30, 1e30}, max[3]={-1e30, -1e30, -1e30};
- float scale[3]={1.0f, 1.0f, 1.0f}, temp[3];//, xn
- int i; //, texflag=0;
- Object *obt;
-
- /* Object Size with parenting */
- obt=obr->ob;
- while (obt) {
- mul_v3_v3v3(temp, obt->size, obt->dscale);
- scale[0]*=temp[0]; scale[1]*=temp[1]; scale[2]*=temp[2];
- obt=obt->parent;
- }
-
- /* Clear all flags */
- for (i=0; i<obr->totvert; i++) {
- vr= RE_findOrAddVert(obr, i);
- vr->flag= 0;
- }
-
- for (i=0; i<obr->totvlak; i++) {
- vlr=RE_findOrAddVlak(obr, i);
- displace_render_face(re, obr, vlr, scale);
- }
-
- /* Recalc vertex normals */
- calc_vertexnormals(re, obr, 1, 0, 0);
-}
-
-/* ------------------------------------------------------------------------- */
-/* Metaball */
-/* ------------------------------------------------------------------------- */
-
-static void init_render_mball(const EvaluationContext *eval_ctx, Render *re, ObjectRen *obr)
-{
- Object *ob= obr->ob;
- DispList *dl;
- VertRen *ver;
- VlakRen *vlr, *vlr1;
- Material *ma;
- float *data, *nors, *orco=NULL, mat[4][4], imat[3][3], xn, yn, zn;
- int a, need_orco, vlakindex, *index, negative_scale;
- ListBase dispbase= {NULL, NULL};
-
- if (ob!=BKE_mball_basis_find(re->scene, ob))
- return;
-
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- invert_m4_m4(ob->imat, mat);
- copy_m3_m4(imat, ob->imat);
- negative_scale = is_negative_m4(mat);
-
- ma= give_render_material(re, ob, 1);
-
- need_orco= 0;
- if (ma->texco & TEXCO_ORCO) {
- need_orco= 1;
- }
-
- BKE_displist_make_mball_forRender(eval_ctx, re->scene, ob, &dispbase);
- dl= dispbase.first;
- if (dl == NULL) return;
-
- data= dl->verts;
- nors= dl->nors;
- if (need_orco) {
- orco= get_object_orco(re, ob);
-
- if (!orco) {
- /* orco hasn't been found in cache - create new one and add to cache */
- orco= BKE_mball_make_orco(ob, &dispbase);
- set_object_orco(re, ob, orco);
- }
- }
-
- for (a=0; a<dl->nr; a++, data+=3, nors+=3) {
-
- ver= RE_findOrAddVert(obr, obr->totvert++);
- copy_v3_v3(ver->co, data);
- mul_m4_v3(mat, ver->co);
-
- /* render normals are inverted */
- xn= -nors[0];
- yn= -nors[1];
- zn= -nors[2];
-
- /* transpose ! */
- ver->n[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
- ver->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
- ver->n[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
- normalize_v3(ver->n);
- //if (ob->transflag & OB_NEG_SCALE) negate_v3(ver->n);
-
- if (need_orco) {
- ver->orco= orco;
- orco+=3;
- }
- }
-
- index= dl->index;
- for (a=0; a<dl->parts; a++, index+=4) {
-
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->v1= RE_findOrAddVert(obr, index[0]);
- vlr->v2= RE_findOrAddVert(obr, index[1]);
- vlr->v3= RE_findOrAddVert(obr, index[2]);
- vlr->v4 = NULL;
-
- if (negative_scale)
- normal_tri_v3(vlr->n, vlr->v1->co, vlr->v2->co, vlr->v3->co);
- else
- normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co);
-
- vlr->mat= ma;
- vlr->flag= ME_SMOOTH;
- vlr->ec= 0;
-
- /* mball -too bad- always has triangles, because quads can be non-planar */
- if (index[3] && index[3]!=index[2]) {
- vlr1= RE_findOrAddVlak(obr, obr->totvlak++);
- vlakindex= vlr1->index;
- *vlr1= *vlr;
- vlr1->index= vlakindex;
- vlr1->v2= vlr1->v3;
- vlr1->v3= RE_findOrAddVert(obr, index[3]);
- if (negative_scale)
- normal_tri_v3(vlr1->n, vlr1->v1->co, vlr1->v2->co, vlr1->v3->co);
- else
- normal_tri_v3(vlr1->n, vlr1->v3->co, vlr1->v2->co, vlr1->v1->co);
- }
- }
-
- /* enforce display lists remade */
- BKE_displist_free(&dispbase);
-}
-
-/* ------------------------------------------------------------------------- */
-/* Surfaces and Curves */
-/* ------------------------------------------------------------------------- */
-
-/* returns amount of vertices added for orco */
-static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, float *orco, float mat[4][4])
-{
- VertRen *v1, *v2, *v3, *v4, *ver;
- VlakRen *vlr, *vlr1, *vlr2, *vlr3;
- float *data, n1[3];
- int u, v, orcoret= 0;
- int p1, p2, p3, p4, a;
- int sizeu, nsizeu, sizev, nsizev;
- int startvert, startvlak;
-
- startvert= obr->totvert;
- nsizeu = sizeu = dl->parts; nsizev = sizev = dl->nr;
-
- data= dl->verts;
- for (u = 0; u < sizeu; u++) {
- v1 = RE_findOrAddVert(obr, obr->totvert++); /* save this for possible V wrapping */
- copy_v3_v3(v1->co, data); data += 3;
- if (orco) {
- v1->orco= orco; orco+= 3; orcoret++;
- }
- mul_m4_v3(mat, v1->co);
-
- for (v = 1; v < sizev; v++) {
- ver= RE_findOrAddVert(obr, obr->totvert++);
- copy_v3_v3(ver->co, data); data += 3;
- if (orco) {
- ver->orco= orco; orco+= 3; orcoret++;
- }
- mul_m4_v3(mat, ver->co);
- }
- /* if V-cyclic, add extra vertices at end of the row */
- if (dl->flag & DL_CYCL_U) {
- ver= RE_findOrAddVert(obr, obr->totvert++);
- copy_v3_v3(ver->co, v1->co);
- if (orco) {
- ver->orco= orco; orco+=3; orcoret++; //orcobase + 3*(u*sizev + 0);
- }
- }
- }
-
- /* Done before next loop to get corner vert */
- if (dl->flag & DL_CYCL_U) nsizev++;
- if (dl->flag & DL_CYCL_V) nsizeu++;
-
- /* if U cyclic, add extra row at end of column */
- if (dl->flag & DL_CYCL_V) {
- for (v = 0; v < nsizev; v++) {
- v1= RE_findOrAddVert(obr, startvert + v);
- ver= RE_findOrAddVert(obr, obr->totvert++);
- copy_v3_v3(ver->co, v1->co);
- if (orco) {
- ver->orco= orco; orco+=3; orcoret++; //ver->orco= orcobase + 3*(0*sizev + v);
- }
- }
- }
-
- sizeu = nsizeu;
- sizev = nsizev;
-
- startvlak= obr->totvlak;
-
- for (u = 0; u < sizeu - 1; u++) {
- p1 = startvert + u * sizev; /* walk through face list */
- p2 = p1 + 1;
- p3 = p2 + sizev;
- p4 = p3 - 1;
-
- for (v = 0; v < sizev - 1; v++) {
- v1= RE_findOrAddVert(obr, p1);
- v2= RE_findOrAddVert(obr, p2);
- v3= RE_findOrAddVert(obr, p3);
- v4= RE_findOrAddVert(obr, p4);
-
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->v1= v1; vlr->v2= v2; vlr->v3= v3; vlr->v4= v4;
-
- normal_quad_v3(n1, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
-
- copy_v3_v3(vlr->n, n1);
-
- vlr->mat= matar[ dl->col];
- vlr->ec= ME_V1V2+ME_V2V3;
- vlr->flag= dl->rt;
-
- add_v3_v3(v1->n, n1);
- add_v3_v3(v2->n, n1);
- add_v3_v3(v3->n, n1);
- add_v3_v3(v4->n, n1);
-
- p1++; p2++; p3++; p4++;
- }
- }
- /* fix normals for U resp. V cyclic faces */
- sizeu--; sizev--; /* dec size for face array */
- if (dl->flag & DL_CYCL_V) {
-
- for (v = 0; v < sizev; v++) {
- /* optimize! :*/
- vlr= RE_findOrAddVlak(obr, UVTOINDEX(sizeu - 1, v));
- vlr1= RE_findOrAddVlak(obr, UVTOINDEX(0, v));
- add_v3_v3(vlr1->v1->n, vlr->n);
- add_v3_v3(vlr1->v2->n, vlr->n);
- add_v3_v3(vlr->v3->n, vlr1->n);
- add_v3_v3(vlr->v4->n, vlr1->n);
- }
- }
- if (dl->flag & DL_CYCL_U) {
-
- for (u = 0; u < sizeu; u++) {
- /* optimize! :*/
- vlr= RE_findOrAddVlak(obr, UVTOINDEX(u, 0));
- vlr1= RE_findOrAddVlak(obr, UVTOINDEX(u, sizev-1));
- add_v3_v3(vlr1->v2->n, vlr->n);
- add_v3_v3(vlr1->v3->n, vlr->n);
- add_v3_v3(vlr->v1->n, vlr1->n);
- add_v3_v3(vlr->v4->n, vlr1->n);
- }
- }
-
- /* last vertex is an extra case:
- *
- * ^ ()----()----()----()
- * | | | || |
- * u | |(0,n)||(0,0)|
- * | | || |
- * ()====()====[]====()
- * | | || |
- * | |(m,n)||(m,0)|
- * | | || |
- * ()----()----()----()
- * v ->
- *
- * vertex [] is no longer shared, therefore distribute
- * normals of the surrounding faces to all of the duplicates of []
- */
-
- if ((dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U)) {
- vlr= RE_findOrAddVlak(obr, UVTOINDEX(sizeu - 1, sizev - 1)); /* (m, n) */
- vlr1= RE_findOrAddVlak(obr, UVTOINDEX(0, 0)); /* (0, 0) */
- add_v3_v3v3(n1, vlr->n, vlr1->n);
- vlr2= RE_findOrAddVlak(obr, UVTOINDEX(0, sizev-1)); /* (0, n) */
- add_v3_v3(n1, vlr2->n);
- vlr3= RE_findOrAddVlak(obr, UVTOINDEX(sizeu-1, 0)); /* (m, 0) */
- add_v3_v3(n1, vlr3->n);
- copy_v3_v3(vlr->v3->n, n1);
- copy_v3_v3(vlr1->v1->n, n1);
- copy_v3_v3(vlr2->v2->n, n1);
- copy_v3_v3(vlr3->v4->n, n1);
- }
- for (a = startvert; a < obr->totvert; a++) {
- ver= RE_findOrAddVert(obr, a);
- normalize_v3(ver->n);
- }
-
-
- return orcoret;
-}
-
-static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
- int timeoffset, float *orco, float mat[4][4])
-{
- Object *ob= obr->ob;
- int a, end, totvert, vertofs;
- short mat_iter;
- VertRen *ver;
- VlakRen *vlr;
- MVert *mvert = NULL;
- MFace *mface;
- Material *ma;
-#ifdef WITH_FREESTYLE
- const int *index_mf_to_mpoly = NULL;
- const int *index_mp_to_orig = NULL;
- FreestyleFace *ffa = NULL;
-#endif
- /* Curve *cu= ELEM(ob->type, OB_FONT, OB_CURVE) ? ob->data : NULL; */
-
- mvert= dm->getVertArray(dm);
- totvert= dm->getNumVerts(dm);
-
- for (a=0; a<totvert; a++, mvert++) {
- ver= RE_findOrAddVert(obr, obr->totvert++);
- copy_v3_v3(ver->co, mvert->co);
- mul_m4_v3(mat, ver->co);
-
- if (orco) {
- ver->orco= orco;
- orco+=3;
- }
- }
-
- if (!timeoffset) {
- /* store customdata names, because DerivedMesh is freed */
- RE_set_customdata_names(obr, &dm->faceData);
-
- /* still to do for keys: the correct local texture coordinate */
-
- /* faces in order of color blocks */
- vertofs= obr->totvert - totvert;
- for (mat_iter= 0; (mat_iter < ob->totcol || (mat_iter==0 && ob->totcol==0)); mat_iter++) {
-
- ma= give_render_material(re, ob, mat_iter+1);
- end= dm->getNumTessFaces(dm);
- mface= dm->getTessFaceArray(dm);
-
-#ifdef WITH_FREESTYLE
- if (ob->type == OB_MESH) {
- Mesh *me= ob->data;
- index_mf_to_mpoly= dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
- index_mp_to_orig= dm->getPolyDataArray(dm, CD_ORIGINDEX);
- ffa= CustomData_get_layer(&me->pdata, CD_FREESTYLE_FACE);
- }
-#endif
-
- for (a=0; a<end; a++, mface++) {
- int v1, v2, v3, v4, flag;
-
- if (mface->mat_nr == mat_iter) {
- float len;
-
- v1= mface->v1;
- v2= mface->v2;
- v3= mface->v3;
- v4= mface->v4;
- flag= mface->flag & ME_SMOOTH;
-
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->v1= RE_findOrAddVert(obr, vertofs+v1);
- vlr->v2= RE_findOrAddVert(obr, vertofs+v2);
- vlr->v3= RE_findOrAddVert(obr, vertofs+v3);
- if (v4) vlr->v4= RE_findOrAddVert(obr, vertofs+v4);
- else vlr->v4 = NULL;
-
- /* render normals are inverted in render */
- if (vlr->v4)
- len= normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- else
- len= normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co);
-
- vlr->mat= ma;
- vlr->flag= flag;
- vlr->ec= 0; /* mesh edges rendered separately */
-#ifdef WITH_FREESTYLE
- if (ffa) {
- int index = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a) : a;
- vlr->freestyle_face_mark= (ffa[index].flag & FREESTYLE_FACE_MARK) ? 1 : 0;
- }
- else {
- vlr->freestyle_face_mark= 0;
- }
-#endif
-
- if (len==0) obr->totvlak--;
- else {
- CustomDataLayer *layer;
- MTFace *mtface, *mtf;
- MCol *mcol, *mc;
- int index, mtfn= 0, mcn= 0;
- char *name;
-
- for (index=0; index<dm->faceData.totlayer; index++) {
- layer= &dm->faceData.layers[index];
- name= layer->name;
-
- if (layer->type == CD_MTFACE && mtfn < MAX_MTFACE) {
- mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1);
- mtface= (MTFace*)layer->data;
- *mtf= mtface[a];
- }
- else if (layer->type == CD_MCOL && mcn < MAX_MCOL) {
- mc= RE_vlakren_get_mcol(obr, vlr, mcn++, &name, 1);
- mcol= (MCol*)layer->data;
- memcpy(mc, &mcol[a*4], sizeof(MCol)*4);
- }
- }
- }
- }
- }
- }
-
- /* Normals */
- calc_vertexnormals(re, obr, 1, 0, 0);
- }
-
-}
-
-static void init_render_surf(const EvaluationContext *eval_ctx, Render *re, ObjectRen *obr, int timeoffset)
-{
- Object *ob= obr->ob;
- Nurb *nu = NULL;
- Curve *cu;
- ListBase displist= {NULL, NULL};
- DispList *dl;
- Material **matar;
- float *orco=NULL, mat[4][4];
- int a, totmat;
- bool need_orco = false;
- DerivedMesh *dm= NULL;
-
- cu= ob->data;
- nu= cu->nurb.first;
- if (nu == NULL) return;
-
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- invert_m4_m4(ob->imat, mat);
-
- /* material array */
- totmat= ob->totcol+1;
- matar= MEM_callocN(sizeof(Material*)*totmat, "init_render_surf matar");
-
- for (a=0; a<totmat; a++) {
- matar[a]= give_render_material(re, ob, a+1);
-
- if (matar[a] && matar[a]->texco & TEXCO_ORCO)
- need_orco= 1;
- }
-
- if (ob->parent && (ob->parent->type==OB_LATTICE)) need_orco= 1;
-
- BKE_displist_make_surf(eval_ctx, re->scene, ob, &displist, &dm, 1, 0, 1);
-
- if (dm) {
- if (need_orco) {
- orco = get_object_orco(re, ob);
- if (!orco) {
- orco= BKE_displist_make_orco(eval_ctx, re->scene, ob, dm, true, true);
- if (orco) {
- set_object_orco(re, ob, orco);
- }
- }
- }
-
- init_render_dm(dm, re, obr, timeoffset, orco, mat);
- dm->release(dm);
- }
- else {
- if (need_orco) {
- 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 */
- for (dl=displist.first; dl; dl=dl->next) {
- /* watch out: u ^= y, v ^= x !! */
- if (dl->type==DL_SURF)
- orco+= 3*dl_surf_to_renderdata(obr, dl, matar, orco, mat);
- }
- }
-
- BKE_displist_free(&displist);
-
- MEM_freeN(matar);
-}
-
-static void init_render_curve(const EvaluationContext *eval_ctx, Render *re, ObjectRen *obr, int timeoffset)
-{
- Object *ob= obr->ob;
- Curve *cu;
- VertRen *ver;
- VlakRen *vlr;
- DispList *dl;
- DerivedMesh *dm = NULL;
- ListBase disp={NULL, NULL};
- Material **matar;
- float *data, *fp, *orco=NULL;
- float n[3], mat[4][4], nmat[4][4];
- int nr, startvert, a, b, negative_scale;
- bool need_orco = false;
- int totmat;
-
- cu= ob->data;
- if (ob->type==OB_FONT && cu->str==NULL) return;
- else if (ob->type==OB_CURVE && cu->nurb.first==NULL) return;
-
- BKE_displist_make_curveTypes_forRender(eval_ctx, re->scene, ob, &disp, &dm, false, true);
- dl= disp.first;
- if (dl==NULL) return;
-
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- invert_m4_m4(ob->imat, mat);
- negative_scale = is_negative_m4(mat);
-
- /* local object -> world space transform for normals */
- transpose_m4_m4(nmat, mat);
- invert_m4(nmat);
-
- /* material array */
- totmat= ob->totcol+1;
- matar= MEM_callocN(sizeof(Material*)*totmat, "init_render_surf matar");
-
- for (a=0; a<totmat; a++) {
- matar[a]= give_render_material(re, ob, a+1);
-
- if (matar[a] && matar[a]->texco & TEXCO_ORCO)
- need_orco= 1;
- }
-
- if (dm) {
- if (need_orco) {
- orco = get_object_orco(re, ob);
- if (!orco) {
- orco = BKE_displist_make_orco(eval_ctx, re->scene, ob, dm, true, true);
- if (orco) {
- set_object_orco(re, ob, orco);
- }
- }
- }
-
- init_render_dm(dm, re, obr, timeoffset, orco, mat);
- dm->release(dm);
- }
- else {
- if (need_orco) {
- orco = get_object_orco(re, ob);
- if (!orco) {
- orco = BKE_curve_make_orco(eval_ctx, re->scene, ob, NULL);
- set_object_orco(re, ob, orco);
- }
- }
-
- while (dl) {
- if (dl->col > ob->totcol) {
- /* pass */
- }
- else if (dl->type==DL_INDEX3) {
- const int *index;
-
- startvert= obr->totvert;
- data= dl->verts;
-
- for (a=0; a<dl->nr; a++, data+=3) {
- ver= RE_findOrAddVert(obr, obr->totvert++);
- copy_v3_v3(ver->co, data);
-
- mul_m4_v3(mat, ver->co);
-
- if (orco) {
- ver->orco = orco;
- orco += 3;
- }
- }
-
- if (timeoffset==0) {
- float tmp[3];
- const int startvlak= obr->totvlak;
-
- zero_v3(n);
- index= dl->index;
- for (a=0; a<dl->parts; a++, index+=3) {
- int v1 = index[0], v2 = index[2], v3 = index[1];
- float *co1 = &dl->verts[v1 * 3],
- *co2 = &dl->verts[v2 * 3],
- *co3 = &dl->verts[v3 * 3];
-
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->v1= RE_findOrAddVert(obr, startvert + v1);
- vlr->v2= RE_findOrAddVert(obr, startvert + v2);
- vlr->v3= RE_findOrAddVert(obr, startvert + v3);
- vlr->v4= NULL;
-
- /* to prevent float accuracy issues, we calculate normal in local object space (not world) */
- if (normal_tri_v3(tmp, co1, co2, co3) > FLT_EPSILON) {
- if (negative_scale == false) {
- add_v3_v3(n, tmp);
- }
- else {
- sub_v3_v3(n, tmp);
- }
- }
-
- vlr->mat= matar[ dl->col ];
- vlr->flag= 0;
- vlr->ec= 0;
- }
-
- /* transform normal to world space */
- mul_m4_v3(nmat, n);
- normalize_v3(n);
-
- /* vertex normals */
- for (a= startvlak; a<obr->totvlak; a++) {
- vlr= RE_findOrAddVlak(obr, a);
-
- copy_v3_v3(vlr->n, n);
- add_v3_v3(vlr->v1->n, vlr->n);
- add_v3_v3(vlr->v3->n, vlr->n);
- add_v3_v3(vlr->v2->n, vlr->n);
- }
- for (a=startvert; a<obr->totvert; a++) {
- ver= RE_findOrAddVert(obr, a);
- normalize_v3(ver->n);
- }
- }
- }
- else if (dl->type==DL_SURF) {
-
- /* cyclic U means an extruded full circular curve, we skip bevel splitting then */
- if (dl->flag & DL_CYCL_U) {
- orco+= 3*dl_surf_to_renderdata(obr, dl, matar, orco, mat);
- }
- else {
- int p1, p2, p3, p4;
-
- fp= dl->verts;
- startvert= obr->totvert;
- nr= dl->nr*dl->parts;
-
- while (nr--) {
- ver= RE_findOrAddVert(obr, obr->totvert++);
-
- copy_v3_v3(ver->co, fp);
- mul_m4_v3(mat, ver->co);
- fp+= 3;
-
- if (orco) {
- ver->orco = orco;
- orco += 3;
- }
- }
-
- if (dl->flag & DL_CYCL_V && orco) {
- fp = dl->verts;
- nr = dl->nr;
- while (nr--) {
- ver = RE_findOrAddVert(obr, obr->totvert++);
- copy_v3_v3(ver->co, fp);
- mul_m4_v3(mat, ver->co);
- ver->orco = orco;
- fp += 3;
- orco += 3;
- }
- }
-
- if (dl->bevel_split || timeoffset == 0) {
- const int startvlak= obr->totvlak;
-
- for (a=0; a<dl->parts; a++) {
-
- if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4)==0)
- break;
-
- p1+= startvert;
- p2+= startvert;
- p3+= startvert;
- p4+= startvert;
-
- if (dl->flag & DL_CYCL_V && orco && a == dl->parts - 1) {
- p3 = p1 + dl->nr;
- p4 = p2 + dl->nr;
- }
-
- for (; b<dl->nr; b++) {
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- /* important 1 offset in order is kept [#24913] */
- vlr->v1= RE_findOrAddVert(obr, p2);
- vlr->v2= RE_findOrAddVert(obr, p1);
- vlr->v3= RE_findOrAddVert(obr, p3);
- vlr->v4= RE_findOrAddVert(obr, p4);
- vlr->ec= ME_V2V3+ME_V3V4;
- if (a==0) vlr->ec+= ME_V1V2;
-
- vlr->flag= dl->rt;
-
- normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- vlr->mat= matar[ dl->col ];
-
- p4= p3;
- p3++;
- p2= p1;
- p1++;
- }
- }
-
- if (dl->bevel_split) {
- for (a = 0; a < dl->parts - 1 + !!(dl->flag & DL_CYCL_V); a++) {
- if (BLI_BITMAP_TEST(dl->bevel_split, a)) {
- split_v_renderfaces(
- obr, startvlak, startvert, dl->parts, dl->nr, a,
- /* intentionally swap (v, u) --> (u, v) */
- dl->flag & DL_CYCL_V, dl->flag & DL_CYCL_U);
- }
- }
- }
-
- /* vertex normals */
- for (a= startvlak; a<obr->totvlak; a++) {
- vlr= RE_findOrAddVlak(obr, a);
-
- add_v3_v3(vlr->v1->n, vlr->n);
- add_v3_v3(vlr->v3->n, vlr->n);
- add_v3_v3(vlr->v2->n, vlr->n);
- add_v3_v3(vlr->v4->n, vlr->n);
- }
- for (a=startvert; a<obr->totvert; a++) {
- ver= RE_findOrAddVert(obr, a);
- normalize_v3(ver->n);
- }
- }
- }
- }
-
- dl= dl->next;
- }
- }
-
- BKE_displist_free(&disp);
-
- MEM_freeN(matar);
-}
-
-/* ------------------------------------------------------------------------- */
-/* Mesh */
-/* ------------------------------------------------------------------------- */
-
-struct edgesort {
- unsigned int v1, v2;
- int f;
- unsigned int i1, i2;
-};
-
-/* edges have to be added with lowest index first for sorting */
-static void to_edgesort(struct edgesort *ed,
- unsigned int i1, unsigned int i2,
- unsigned int v1, unsigned int v2, int f)
-{
- if (v1 > v2) {
- SWAP(unsigned int, v1, v2);
- SWAP(unsigned int, i1, i2);
- }
-
- ed->v1= v1;
- ed->v2= v2;
- ed->i1= i1;
- ed->i2= i2;
- ed->f = f;
-}
-
-static int vergedgesort(const void *v1, const void *v2)
-{
- const struct edgesort *x1=v1, *x2=v2;
-
- if ( x1->v1 > x2->v1) return 1;
- else if ( x1->v1 < x2->v1) return -1;
- else if ( x1->v2 > x2->v2) return 1;
- else if ( x1->v2 < x2->v2) return -1;
-
- return 0;
-}
-
-static struct edgesort *make_mesh_edge_lookup(DerivedMesh *dm, int *totedgesort)
-{
- MFace *mf, *mface;
- MTFace *tface=NULL;
- struct edgesort *edsort, *ed;
- unsigned int *mcol=NULL;
- int a, totedge=0, totface;
-
- mface= dm->getTessFaceArray(dm);
- totface= dm->getNumTessFaces(dm);
- tface= dm->getTessFaceDataArray(dm, CD_MTFACE);
- mcol= dm->getTessFaceDataArray(dm, CD_MCOL);
-
- if (mcol==NULL && tface==NULL) return NULL;
-
- /* make sorted table with edges and face indices in it */
- for (a= totface, mf= mface; a>0; a--, mf++) {
- totedge += mf->v4 ? 4 : 3;
- }
-
- if (totedge==0)
- return NULL;
-
- ed= edsort= MEM_callocN(totedge*sizeof(struct edgesort), "edgesort");
-
- for (a=0, mf=mface; a<totface; a++, mf++) {
- to_edgesort(ed++, 0, 1, mf->v1, mf->v2, a);
- to_edgesort(ed++, 1, 2, mf->v2, mf->v3, a);
- if (mf->v4) {
- to_edgesort(ed++, 2, 3, mf->v3, mf->v4, a);
- to_edgesort(ed++, 3, 0, mf->v4, mf->v1, a);
- }
- else {
- to_edgesort(ed++, 2, 3, mf->v3, mf->v1, a);
- }
- }
-
- qsort(edsort, totedge, sizeof(struct edgesort), vergedgesort);
-
- *totedgesort= totedge;
-
- return edsort;
-}
-
-static void use_mesh_edge_lookup(ObjectRen *obr, DerivedMesh *dm, MEdge *medge, VlakRen *vlr, struct edgesort *edgetable, int totedge)
-{
- struct edgesort ed, *edp;
- CustomDataLayer *layer;
- MTFace *mtface, *mtf;
- MCol *mcol, *mc;
- int index, mtfn, mcn;
- char *name;
-
- if (medge->v1 < medge->v2) {
- ed.v1= medge->v1;
- ed.v2= medge->v2;
- }
- else {
- ed.v1= medge->v2;
- ed.v2= medge->v1;
- }
-
- edp= bsearch(&ed, edgetable, totedge, sizeof(struct edgesort), vergedgesort);
-
- /* since edges have different index ordering, we have to duplicate mcol and tface */
- if (edp) {
- mtfn= mcn= 0;
-
- for (index=0; index<dm->faceData.totlayer; index++) {
- layer= &dm->faceData.layers[index];
- name= layer->name;
-
- if (layer->type == CD_MTFACE && mtfn < MAX_MTFACE) {
- mtface= &((MTFace*)layer->data)[edp->f];
- mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1);
-
- *mtf= *mtface;
-
- memcpy(mtf->uv[0], mtface->uv[edp->i1], sizeof(float)*2);
- memcpy(mtf->uv[1], mtface->uv[edp->i2], sizeof(float)*2);
- memcpy(mtf->uv[2], mtface->uv[1], sizeof(float)*2);
- memcpy(mtf->uv[3], mtface->uv[1], sizeof(float)*2);
- }
- else if (layer->type == CD_MCOL && mcn < MAX_MCOL) {
- mcol= &((MCol*)layer->data)[edp->f*4];
- mc= RE_vlakren_get_mcol(obr, vlr, mcn++, &name, 1);
-
- mc[0]= mcol[edp->i1];
- mc[1]= mc[2]= mc[3]= mcol[edp->i2];
- }
- }
- }
-}
-
-static void free_camera_inside_volumes(Render *re)
-{
- BLI_freelistN(&re->render_volumes_inside);
-}
-
-static void init_camera_inside_volumes(Render *re)
-{
- ObjectInstanceRen *obi;
- VolumeOb *vo;
- /* coordinates are all in camera space, so camera coordinate is zero. we also
- * add an offset for the clip start, however note that with clip start it's
- * actually impossible to do a single 'inside' test, since there will not be
- * a single point where all camera rays start from, though for small clip start
- * they will be close together. */
- float co[3] = {0.f, 0.f, -re->clipsta};
-
- for (vo= re->volumes.first; vo; vo= vo->next) {
- for (obi= re->instancetable.first; obi; obi= obi->next) {
- if (obi->obr == vo->obr) {
- if (point_inside_volume_objectinstance(re, obi, co)) {
- MatInside *mi;
-
- mi = MEM_mallocN(sizeof(MatInside), "camera inside material");
- mi->ma = vo->ma;
- mi->obi = obi;
-
- BLI_addtail(&(re->render_volumes_inside), mi);
- }
- }
- }
- }
-
-
-#if 0 /* debug */
- {
- MatInside *m;
- for (m = re->render_volumes_inside.first; m; m = m->next) {
- printf("matinside: ma: %s\n", m->ma->id.name + 2);
- }
- }
-#endif
-}
-
-static void add_volume(Render *re, ObjectRen *obr, Material *ma)
-{
- struct VolumeOb *vo;
-
- vo = MEM_mallocN(sizeof(VolumeOb), "volume object");
-
- vo->ma = ma;
- vo->obr = obr;
-
- BLI_addtail(&re->volumes, vo);
-}
-
-#ifdef WITH_FREESTYLE
-static EdgeHash *make_freestyle_edge_mark_hash(DerivedMesh *dm)
-{
- EdgeHash *edge_hash= NULL;
- FreestyleEdge *fed;
- MEdge *medge;
- int totedge, a;
-
- medge = dm->getEdgeArray(dm);
- totedge = dm->getNumEdges(dm);
- fed = dm->getEdgeDataArray(dm, CD_FREESTYLE_EDGE);
- if (fed) {
- edge_hash = BLI_edgehash_new(__func__);
- for (a = 0; a < totedge; a++) {
- if (fed[a].flag & FREESTYLE_EDGE_MARK)
- BLI_edgehash_insert(edge_hash, medge[a].v1, medge[a].v2, medge+a);
- }
- }
- return edge_hash;
-}
-
-static bool has_freestyle_edge_mark(EdgeHash *edge_hash, int v1, int v2)
-{
- MEdge *medge= BLI_edgehash_lookup(edge_hash, v1, v2);
- return (!medge) ? 0 : 1;
-}
-#endif
-
-static void init_render_mesh(const EvaluationContext *eval_ctx, Render *re, ObjectRen *obr, int timeoffset)
-{
- Object *ob= obr->ob;
- Mesh *me;
- MVert *mvert = NULL;
- MFace *mface;
- VlakRen *vlr; //, *vlr1;
- VertRen *ver;
- Material *ma;
- DerivedMesh *dm;
- CustomDataMask mask;
- float xn, yn, zn, imat[3][3], mat[4][4]; //nor[3],
- float *orco = NULL;
- short (*loop_nors)[4][3] = NULL;
- bool need_orco = false, need_stress = false, need_tangent = false, need_origindex = false;
- bool need_nmap_tangent_concrete = false;
- int a, a1, ok, vertofs;
- int end, totvert = 0;
- bool do_autosmooth = false, do_displace = false;
- bool use_original_normals = false;
- int recalc_normals = 0; /* false by default */
- int negative_scale;
-#ifdef WITH_FREESTYLE
- FreestyleFace *ffa;
-#endif
-
- me= ob->data;
-
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- invert_m4_m4(ob->imat, mat);
- copy_m3_m4(imat, ob->imat);
- negative_scale= is_negative_m4(mat);
-
- need_orco= 0;
- for (a=1; a<=ob->totcol; a++) {
- ma= give_render_material(re, ob, a);
- if (ma) {
- if (ma->texco & (TEXCO_ORCO|TEXCO_STRESS))
- need_orco= 1;
- if (ma->texco & TEXCO_STRESS)
- need_stress= 1;
- /* normalmaps, test if tangents needed, separated from shading */
- if (ma->mode_l & MA_TANGENT_V) {
- need_tangent= 1;
- if (me->mloopuv==NULL)
- need_orco= 1;
- }
- if (ma->mode_l & MA_NORMAP_TANG) {
- if (me->mloopuv==NULL) {
- need_orco= 1;
- }
- need_tangent= 1;
- }
- if (ma->mode2_l & MA_TANGENT_CONCRETE) {
- need_nmap_tangent_concrete = true;
- }
- }
- }
-
- if (re->flag & R_NEED_TANGENT) {
- /* exception for tangent space baking */
- if (me->mloopuv==NULL) {
- need_orco= 1;
- }
- need_tangent= 1;
- }
-
- /* check autosmooth and displacement, we then have to skip only-verts optimize
- * Note: not sure what we want to give higher priority, currently do_displace
- * takes precedence over do_autosmooth.
- */
- do_displace = test_for_displace(re, ob);
- do_autosmooth = ((me->flag & ME_AUTOSMOOTH) != 0) && !do_displace;
- if (do_autosmooth || do_displace)
- timeoffset = 0;
-
- /* origindex currently used when using autosmooth, or baking to vertex colors. */
- need_origindex = (do_autosmooth || ((re->flag & R_BAKING) && (re->r.bake_flag & R_BAKE_VCOL)));
-
- mask = CD_MASK_RENDER_INTERNAL;
- if (!timeoffset)
- if (need_orco)
- mask |= CD_MASK_ORCO;
-
-#ifdef WITH_FREESTYLE
- mask |= CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
-#endif
-
- if (re->r.scemode & R_VIEWPORT_PREVIEW)
- dm= mesh_create_derived_view(eval_ctx, re->scene, ob, mask);
- else
- dm= mesh_create_derived_render(eval_ctx, re->scene, ob, mask);
- if (dm==NULL) return; /* in case duplicated object fails? */
-
- mvert= dm->getVertArray(dm);
- totvert= dm->getNumVerts(dm);
-
- if (totvert == 0) {
- dm->release(dm);
- return;
- }
-
- if (mask & CD_MASK_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);
- }
- }
- }
-
- /* attempt to autsmooth on original mesh, only without subsurf */
- if (do_autosmooth && me->totvert==totvert && me->totface==dm->getNumTessFaces(dm))
- use_original_normals= true;
-
- ma= give_render_material(re, ob, 1);
-
-
- if (ma->material_type == MA_TYPE_HALO) {
- make_render_halos(re, obr, me, totvert, mvert, ma, orco);
- }
- else {
- const int *index_vert_orig = NULL;
- const int *index_mf_to_mpoly = NULL;
- const int *index_mp_to_orig = NULL;
- if (need_origindex) {
- index_vert_orig = dm->getVertDataArray(dm, CD_ORIGINDEX);
- /* double lookup for faces -> polys */
-#ifdef WITH_FREESTYLE
- index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
- index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
-#endif
- }
-
- for (a=0; a<totvert; a++, mvert++) {
- ver= RE_findOrAddVert(obr, obr->totvert++);
- copy_v3_v3(ver->co, mvert->co);
- if (do_autosmooth == false) { /* autosmooth on original unrotated data to prevent differences between frames */
- normal_short_to_float_v3(ver->n, mvert->no);
- mul_m4_v3(mat, ver->co);
- mul_transposed_m3_v3(imat, ver->n);
- normalize_v3(ver->n);
- negate_v3(ver->n);
- }
-
- if (orco) {
- ver->orco= orco;
- orco+=3;
- }
-
- if (need_origindex) {
- int *origindex;
- origindex = RE_vertren_get_origindex(obr, ver, 1);
-
- /* Use orig index array if it's available (e.g. in the presence
- * of modifiers). */
- if (index_vert_orig)
- *origindex = index_vert_orig[a];
- else
- *origindex = a;
- }
- }
-
- if (!timeoffset) {
- short (*lnp)[4][3] = NULL;
-#ifdef WITH_FREESTYLE
- EdgeHash *edge_hash;
-
- /* create a hash table of Freestyle edge marks */
- edge_hash = make_freestyle_edge_mark_hash(dm);
-#endif
-
- /* store customdata names, because DerivedMesh is freed */
- RE_set_customdata_names(obr, &dm->faceData);
-
- /* add tangent layers if we need */
- if ((ma->nmap_tangent_names_count && need_nmap_tangent_concrete) || need_tangent) {
- dm->calcLoopTangents(
- dm, need_tangent,
- (const char (*)[MAX_NAME])ma->nmap_tangent_names, ma->nmap_tangent_names_count);
- obr->tangent_mask = dm->tangent_mask;
- DM_generate_tangent_tessface_data(dm, need_nmap_tangent_concrete || need_tangent);
- }
-
- /* still to do for keys: the correct local texture coordinate */
-
- /* faces in order of color blocks */
- vertofs= obr->totvert - totvert;
- for (a1=0; (a1<ob->totcol || (a1==0 && ob->totcol==0)); a1++) {
-
- ma= give_render_material(re, ob, a1+1);
-
- /* test for 100% transparent */
- ok = 1;
- if ((ma->alpha == 0.0f) &&
- (ma->spectra == 0.0f) &&
- /* No need to test filter here, it's only active with MA_RAYTRANSP and we check against it below. */
- /* (ma->filter == 0.0f) && */
- (ma->mode & MA_TRANSP) &&
- (ma->mode & (MA_RAYTRANSP | MA_RAYMIRROR)) == 0)
- {
- ok = 0;
- /* texture on transparency? */
- for (a=0; a<MAX_MTEX; a++) {
- if (ma->mtex[a] && ma->mtex[a]->tex) {
- if (ma->mtex[a]->mapto & MAP_ALPHA) ok= 1;
- }
- }
- }
-
- /* if wire material, and we got edges, don't do the faces */
- if (ma->material_type == MA_TYPE_WIRE) {
- end= dm->getNumEdges(dm);
- if (end) ok= 0;
- }
-
- if (ok) {
- end= dm->getNumTessFaces(dm);
- mface= dm->getTessFaceArray(dm);
- if (!loop_nors && do_autosmooth &&
- (dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL) != NULL))
- {
- lnp = loop_nors = MEM_mallocN(sizeof(*loop_nors) * end, __func__);
- }
-#ifdef WITH_FREESTYLE
- index_mf_to_mpoly= dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
- index_mp_to_orig= dm->getPolyDataArray(dm, CD_ORIGINDEX);
- ffa= CustomData_get_layer(&me->pdata, CD_FREESTYLE_FACE);
-#endif
-
- for (a=0; a<end; a++, mface++) {
- int v1, v2, v3, v4, flag;
-
- if ( mface->mat_nr==a1 ) {
- float len;
- bool reverse_verts = (negative_scale != 0 && do_autosmooth == false);
- int rev_tab[] = {reverse_verts==0 ? 0 : 2, 1, reverse_verts==0 ? 2 : 0, 3};
- v1= reverse_verts==0 ? mface->v1 : mface->v3;
- v2= mface->v2;
- v3= reverse_verts==0 ? mface->v3 : mface->v1;
- v4= mface->v4;
- flag = do_autosmooth ? ME_SMOOTH : mface->flag & ME_SMOOTH;
-
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->v1= RE_findOrAddVert(obr, vertofs+v1);
- vlr->v2= RE_findOrAddVert(obr, vertofs+v2);
- vlr->v3= RE_findOrAddVert(obr, vertofs+v3);
- if (v4) vlr->v4 = RE_findOrAddVert(obr, vertofs+v4);
- else vlr->v4 = NULL;
-
-#ifdef WITH_FREESTYLE
- /* Freestyle edge/face marks */
- if (edge_hash) {
- int edge_mark = 0;
-
- if (has_freestyle_edge_mark(edge_hash, v1, v2)) edge_mark |= R_EDGE_V1V2;
- if (has_freestyle_edge_mark(edge_hash, v2, v3)) edge_mark |= R_EDGE_V2V3;
- if (!v4) {
- if (has_freestyle_edge_mark(edge_hash, v3, v1)) edge_mark |= R_EDGE_V3V1;
- }
- else {
- if (has_freestyle_edge_mark(edge_hash, v3, v4)) edge_mark |= R_EDGE_V3V4;
- if (has_freestyle_edge_mark(edge_hash, v4, v1)) edge_mark |= R_EDGE_V4V1;
- }
- vlr->freestyle_edge_mark= edge_mark;
- }
- if (ffa) {
- int index = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a) : a;
- vlr->freestyle_face_mark= (ffa[index].flag & FREESTYLE_FACE_MARK) ? 1 : 0;
- }
- else {
- vlr->freestyle_face_mark= 0;
- }
-#endif
-
- /* render normals are inverted in render */
- if (use_original_normals) {
- MFace *mf= me->mface+a;
- MVert *mv= me->mvert;
-
- if (vlr->v4)
- len= normal_quad_v3(vlr->n, mv[mf->v4].co, mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co);
- else
- len= normal_tri_v3(vlr->n, mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co);
- }
- else {
- if (vlr->v4)
- len= normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- else
- len= normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- }
-
- vlr->mat= ma;
- vlr->flag= flag;
- vlr->ec= 0; /* mesh edges rendered separately */
-
- if (len==0) obr->totvlak--;
- else {
- CustomDataLayer *layer;
- MTFace *mtface, *mtf;
- MCol *mcol, *mc;
- int index, mtfn= 0, mcn= 0, mln = 0, vindex;
- char *name;
- int nr_verts = v4!=0 ? 4 : 3;
-
- for (index=0; index<dm->faceData.totlayer; index++) {
- layer= &dm->faceData.layers[index];
- name= layer->name;
-
- if (layer->type == CD_MTFACE && mtfn < MAX_MTFACE) {
- int t;
- mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1);
- mtface= (MTFace*)layer->data;
- *mtf = mtface[a]; /* copy face info */
- for (vindex=0; vindex<nr_verts; vindex++)
- for (t=0; t<2; t++)
- mtf->uv[vindex][t]=mtface[a].uv[rev_tab[vindex]][t];
- }
- else if (layer->type == CD_MCOL && mcn < MAX_MCOL) {
- mc= RE_vlakren_get_mcol(obr, vlr, mcn++, &name, 1);
- mcol= (MCol*)layer->data;
- for (vindex=0; vindex<nr_verts; vindex++)
- mc[vindex]=mcol[a*4+rev_tab[vindex]];
- }
- else if (layer->type == CD_TANGENT) {
- if (need_nmap_tangent_concrete || need_tangent) {
- int uv_start = CustomData_get_layer_index(&dm->faceData, CD_MTFACE);
- int uv_index = CustomData_get_named_layer_index(&dm->faceData, CD_MTFACE, layer->name);
-
- /* if there are no UVs, orco tangents are in first slot */
- int n = (uv_start >= 0 && uv_index >= 0) ? uv_index - uv_start : 0;
-
- const float *tangent = (const float *) layer->data;
- float *ftang = RE_vlakren_get_nmap_tangent(obr, vlr, n, true);
-
- for (vindex=0; vindex<nr_verts; vindex++) {
- copy_v4_v4(ftang+vindex*4, tangent+a*16+rev_tab[vindex]*4);
- mul_mat3_m4_v3(mat, ftang+vindex*4);
- normalize_v3(ftang+vindex*4);
- }
- }
- }
- else if (layer->type == CD_TESSLOOPNORMAL && mln < 1) {
- if (loop_nors) {
- const short (*lnors)[4][3] = (const short (*)[4][3])layer->data;
- for (vindex = 0; vindex < 4; vindex++) {
- //print_v3("lnors[a][rev_tab[vindex]]", lnors[a][rev_tab[vindex]]);
- copy_v3_v3_short((short *)lnp[0][vindex], lnors[a][rev_tab[vindex]]);
- /* If we copy loop normals, we are doing autosmooth, so we are still
- * in object space, no need to multiply with mat!
- */
- }
- lnp++;
- }
- mln++;
- }
- }
-
- if (need_origindex) {
- /* Find original index of mpoly for this tessface. Options:
- * - Modified mesh; two-step look up from tessface -> modified mpoly -> original mpoly
- * - OR Tesselated mesh; look up from tessface -> mpoly
- * - OR Failsafe; tessface == mpoly. Could probably assert(false) in this case? */
- int *origindex;
- origindex = RE_vlakren_get_origindex(obr, vlr, 1);
- if (index_mf_to_mpoly && index_mp_to_orig)
- *origindex = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a);
- else if (index_mf_to_mpoly)
- *origindex = index_mf_to_mpoly[a];
- else
- *origindex = a;
- }
- }
- }
- }
- }
- }
-
-#ifdef WITH_FREESTYLE
- /* release the hash table of Freestyle edge marks */
- if (edge_hash)
- BLI_edgehash_free(edge_hash, NULL);
-#endif
-
- /* exception... we do edges for wire mode. potential conflict when faces exist... */
- end= dm->getNumEdges(dm);
- mvert= dm->getVertArray(dm);
- ma= give_render_material(re, ob, 1);
- if (end && (ma->material_type == MA_TYPE_WIRE)) {
- MEdge *medge;
- struct edgesort *edgetable;
- int totedge= 0;
- recalc_normals= 1;
-
- medge= dm->getEdgeArray(dm);
-
- /* we want edges to have UV and vcol too... */
- edgetable= make_mesh_edge_lookup(dm, &totedge);
-
- for (a1=0; a1<end; a1++, medge++) {
- if (medge->flag&ME_EDGERENDER) {
- MVert *v0 = &mvert[medge->v1];
- MVert *v1 = &mvert[medge->v2];
-
- vlr= RE_findOrAddVlak(obr, obr->totvlak++);
- vlr->v1= RE_findOrAddVert(obr, vertofs+medge->v1);
- vlr->v2= RE_findOrAddVert(obr, vertofs+medge->v2);
- vlr->v3= vlr->v2;
- vlr->v4= NULL;
-
- if (edgetable)
- use_mesh_edge_lookup(obr, dm, medge, vlr, edgetable, totedge);
-
- xn= -(v0->no[0]+v1->no[0]);
- yn= -(v0->no[1]+v1->no[1]);
- zn= -(v0->no[2]+v1->no[2]);
- /* transpose ! */
- vlr->n[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
- vlr->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
- vlr->n[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
- normalize_v3(vlr->n);
-
- vlr->mat= ma;
- vlr->flag= 0;
- vlr->ec= ME_V1V2;
- }
- }
- if (edgetable)
- MEM_freeN(edgetable);
- }
- }
- }
-
- if (!timeoffset) {
- if (need_stress)
- calc_edge_stress(re, obr, me);
-
- if (do_displace) {
- calc_vertexnormals(re, obr, 1, 0, 0);
- displace(re, obr);
- recalc_normals = 0; /* Already computed by displace! */
- }
- else if (do_autosmooth) {
- recalc_normals = (loop_nors == NULL); /* Should never happen, but better be safe than sorry. */
- autosmooth(re, obr, mat, loop_nors);
- }
-
- if (recalc_normals!=0 || need_tangent!=0)
- calc_vertexnormals(re, obr, recalc_normals, need_tangent, need_nmap_tangent_concrete);
- }
-
- MEM_SAFE_FREE(loop_nors);
-
- dm->release(dm);
-}
-
-/* ------------------------------------------------------------------------- */
-/* Lamps and Shadowbuffers */
-/* ------------------------------------------------------------------------- */
-
-static void initshadowbuf(Render *re, LampRen *lar, float mat[4][4])
-{
- struct ShadBuf *shb;
- float viewinv[4][4];
-
- /* if (la->spsi<16) return; */
-
- /* memory alloc */
- shb= (struct ShadBuf *)MEM_callocN(sizeof(struct ShadBuf), "initshadbuf");
- lar->shb= shb;
-
- if (shb==NULL) return;
-
- VECCOPY(shb->co, lar->co); /* int copy */
-
- /* percentage render: keep track of min and max */
- shb->size= (lar->bufsize*re->r.size)/100;
-
- if (shb->size<512) shb->size= 512;
- else if (shb->size > lar->bufsize) shb->size= lar->bufsize;
-
- shb->size &= ~15; /* make sure its multiples of 16 */
-
- shb->samp= lar->samp;
- shb->soft= lar->soft;
- shb->shadhalostep= lar->shadhalostep;
-
- normalize_m4(mat);
- invert_m4_m4(shb->winmat, mat); /* winmat is temp */
-
- /* matrix: combination of inverse view and lampmat */
- /* calculate again: the ortho-render has no correct viewinv */
- invert_m4_m4(viewinv, re->viewmat);
- mul_m4_m4m4(shb->viewmat, shb->winmat, viewinv);
-
- /* projection */
- shb->d= lar->clipsta;
- shb->clipend= lar->clipend;
-
- /* bias is percentage, made 2x larger because of correction for angle of incidence */
- /* when a ray is closer to parallel of a face, bias value is increased during render */
- shb->bias= (0.02f*lar->bias)*0x7FFFFFFF;
-
- /* halfway method (average of first and 2nd z) reduces bias issues */
- if (ELEM(lar->buftype, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP))
- shb->bias= 0.1f*shb->bias;
-
- shb->compressthresh= lar->compressthresh;
-}
-
-void area_lamp_vectors(LampRen *lar)
-{
- float xsize= 0.5f*lar->area_size, ysize= 0.5f*lar->area_sizey, multifac;
-
- /* make it smaller, so area light can be multisampled */
- multifac= 1.0f/sqrtf((float)lar->ray_totsamp);
- xsize *= multifac;
- ysize *= multifac;
-
- /* corner vectors */
- lar->area[0][0]= lar->co[0] - xsize*lar->mat[0][0] - ysize*lar->mat[1][0];
- lar->area[0][1]= lar->co[1] - xsize*lar->mat[0][1] - ysize*lar->mat[1][1];
- lar->area[0][2]= lar->co[2] - xsize*lar->mat[0][2] - ysize*lar->mat[1][2];
-
- /* corner vectors */
- lar->area[1][0]= lar->co[0] - xsize*lar->mat[0][0] + ysize*lar->mat[1][0];
- lar->area[1][1]= lar->co[1] - xsize*lar->mat[0][1] + ysize*lar->mat[1][1];
- lar->area[1][2]= lar->co[2] - xsize*lar->mat[0][2] + ysize*lar->mat[1][2];
-
- /* corner vectors */
- lar->area[2][0]= lar->co[0] + xsize*lar->mat[0][0] + ysize*lar->mat[1][0];
- lar->area[2][1]= lar->co[1] + xsize*lar->mat[0][1] + ysize*lar->mat[1][1];
- lar->area[2][2]= lar->co[2] + xsize*lar->mat[0][2] + ysize*lar->mat[1][2];
-
- /* corner vectors */
- lar->area[3][0]= lar->co[0] + xsize*lar->mat[0][0] - ysize*lar->mat[1][0];
- lar->area[3][1]= lar->co[1] + xsize*lar->mat[0][1] - ysize*lar->mat[1][1];
- lar->area[3][2]= lar->co[2] + xsize*lar->mat[0][2] - ysize*lar->mat[1][2];
- /* only for correction button size, matrix size works on energy */
- lar->areasize= lar->dist*lar->dist/(4.0f*xsize*ysize);
-}
-
-/* If lar takes more lamp data, the decoupling will be better. */
-static GroupObject *add_render_lamp(Render *re, Object *ob)
-{
- Lamp *la= ob->data;
- LampRen *lar;
- GroupObject *go;
- float mat[4][4], angle, xn, yn;
- float vec[3];
- int c;
-
- /* previewrender sets this to zero... prevent accidents */
- if (la==NULL) return NULL;
-
- /* prevent only shadow from rendering light */
- if (la->mode & LA_ONLYSHADOW)
- if ((re->r.mode & R_SHADOW)==0)
- return NULL;
-
- re->totlamp++;
-
- /* groups is used to unify support for lightgroups, this is the global lightgroup */
- go= MEM_callocN(sizeof(GroupObject), "groupobject");
- BLI_addtail(&re->lights, go);
- go->ob= ob;
- /* lamprens are in own list, for freeing */
- lar= (LampRen *)MEM_callocN(sizeof(LampRen), "lampren");
- BLI_addtail(&re->lampren, lar);
- go->lampren= lar;
-
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- invert_m4_m4(ob->imat, mat);
-
- copy_m4_m4(lar->lampmat, ob->obmat);
- copy_m3_m4(lar->mat, mat);
- copy_m3_m4(lar->imat, ob->imat);
-
- lar->bufsize = la->bufsize;
- lar->samp = la->samp;
- lar->buffers= la->buffers;
- if (lar->buffers==0) lar->buffers= 1;
- lar->buftype= la->buftype;
- lar->filtertype= la->filtertype;
- lar->soft = la->soft;
- lar->shadhalostep = la->shadhalostep;
- lar->clipsta = la->clipsta;
- lar->clipend = la->clipend;
-
- lar->bias = la->bias;
- lar->compressthresh = la->compressthresh;
-
- lar->type= la->type;
- lar->mode= la->mode;
-
- lar->energy= la->energy;
- if (la->mode & LA_NEG) lar->energy= -lar->energy;
-
- lar->vec[0]= -mat[2][0];
- lar->vec[1]= -mat[2][1];
- lar->vec[2]= -mat[2][2];
- normalize_v3(lar->vec);
- lar->co[0]= mat[3][0];
- lar->co[1]= mat[3][1];
- lar->co[2]= mat[3][2];
- lar->dist= la->dist;
- lar->haint= la->haint;
- lar->distkw= lar->dist*lar->dist;
- lar->r= lar->energy*la->r;
- lar->g= lar->energy*la->g;
- lar->b= lar->energy*la->b;
- lar->shdwr= la->shdwr;
- lar->shdwg= la->shdwg;
- lar->shdwb= la->shdwb;
- lar->k= la->k;
-
- /* area */
- lar->ray_samp= la->ray_samp;
- lar->ray_sampy= la->ray_sampy;
- lar->ray_sampz= la->ray_sampz;
-
- lar->area_size= la->area_size;
- lar->area_sizey= la->area_sizey;
- lar->area_sizez= la->area_sizez;
-
- lar->area_shape= la->area_shape;
-
- /* Annoying, lamp UI does this, but the UI might not have been used? - add here too.
- * make sure this matches buttons_shading.c's logic */
- if (ELEM(la->type, LA_AREA, LA_SPOT, LA_SUN, LA_LOCAL) && (la->mode & LA_SHAD_RAY))
- if (ELEM(la->type, LA_SPOT, LA_SUN, LA_LOCAL))
- if (la->ray_samp_method == LA_SAMP_CONSTANT) la->ray_samp_method = LA_SAMP_HALTON;
-
- lar->ray_samp_method= la->ray_samp_method;
- lar->ray_samp_type= la->ray_samp_type;
-
- lar->adapt_thresh= la->adapt_thresh;
- lar->sunsky = NULL;
-
- if ( ELEM(lar->type, LA_SPOT, LA_LOCAL)) {
- lar->ray_totsamp= lar->ray_samp*lar->ray_samp;
- lar->area_shape = LA_AREA_SQUARE;
- lar->area_sizey= lar->area_size;
- }
- else if (lar->type==LA_AREA) {
- switch (lar->area_shape) {
- case LA_AREA_SQUARE:
- lar->ray_totsamp= lar->ray_samp*lar->ray_samp;
- lar->ray_sampy= lar->ray_samp;
- lar->area_sizey= lar->area_size;
- break;
- case LA_AREA_RECT:
- lar->ray_totsamp= lar->ray_samp*lar->ray_sampy;
- break;
- case LA_AREA_CUBE:
- lar->ray_totsamp= lar->ray_samp*lar->ray_samp*lar->ray_samp;
- lar->ray_sampy= lar->ray_samp;
- lar->ray_sampz= lar->ray_samp;
- lar->area_sizey= lar->area_size;
- lar->area_sizez= lar->area_size;
- break;
- case LA_AREA_BOX:
- lar->ray_totsamp= lar->ray_samp*lar->ray_sampy*lar->ray_sampz;
- break;
- }
-
- area_lamp_vectors(lar);
- init_jitter_plane(lar); /* subsamples */
- }
- else if (lar->type==LA_SUN) {
- lar->ray_totsamp= lar->ray_samp*lar->ray_samp;
- lar->area_shape = LA_AREA_SQUARE;
- lar->area_sizey= lar->area_size;
-
- if ((la->sun_effect_type & LA_SUN_EFFECT_SKY) ||
- (la->sun_effect_type & LA_SUN_EFFECT_AP))
- {
- lar->sunsky = (struct SunSky*)MEM_callocN(sizeof(struct SunSky), "sunskyren");
- lar->sunsky->effect_type = la->sun_effect_type;
-
- copy_v3_v3(vec, ob->obmat[2]);
- normalize_v3(vec);
-
- InitSunSky(
- lar->sunsky, la->atm_turbidity, vec, la->horizon_brightness,
- la->spread, la->sun_brightness, la->sun_size, la->backscattered_light,
- la->skyblendfac, la->skyblendtype, la->sky_exposure, la->sky_colorspace);
- InitAtmosphere(
- lar->sunsky, la->sun_intensity, 1.0, 1.0, la->atm_inscattering_factor, la->atm_extinction_factor,
- la->atm_distance_factor);
- }
- }
- else lar->ray_totsamp= 0;
-
- lar->spotsi= la->spotsize;
- if (lar->mode & LA_HALO) {
- if (lar->spotsi > DEG2RADF(170.0f)) lar->spotsi = DEG2RADF(170.0f);
- }
- lar->spotsi= cosf(lar->spotsi * 0.5f);
- lar->spotbl= (1.0f-lar->spotsi)*la->spotblend;
-
- memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *));
-
- lar->lay = ob->lay & 0xFFFFFF; /* higher 8 bits are localview layers */
-
- lar->falloff_type = la->falloff_type;
- lar->ld1= la->att1;
- lar->ld2= la->att2;
- lar->coeff_const= la->coeff_const;
- lar->coeff_lin= la->coeff_lin;
- lar->coeff_quad= la->coeff_quad;
- lar->curfalloff = curvemapping_copy(la->curfalloff);
-
- if (lar->curfalloff) {
- /* so threads don't conflict on init */
- curvemapping_initialize(lar->curfalloff);
- }
-
- if (lar->type==LA_SPOT) {
-
- normalize_v3(lar->imat[0]);
- normalize_v3(lar->imat[1]);
- normalize_v3(lar->imat[2]);
-
- xn = saacos(lar->spotsi);
- xn = sinf(xn) / cosf(xn);
- lar->spottexfac= 1.0f/(xn);
-
- if (lar->mode & LA_ONLYSHADOW) {
- if ((lar->mode & (LA_SHAD_BUF|LA_SHAD_RAY))==0) lar->mode -= LA_ONLYSHADOW;
- }
-
- }
-
- /* set flag for spothalo en initvars */
- if ((la->type == LA_SPOT) && (la->mode & LA_HALO) &&
- (!(la->mode & LA_SHAD_BUF) || la->buftype != LA_SHADBUF_DEEP))
- {
- if (la->haint>0.0f) {
- re->flag |= R_LAMPHALO;
-
- /* camera position (0, 0, 0) rotate around lamp */
- lar->sh_invcampos[0]= -lar->co[0];
- lar->sh_invcampos[1]= -lar->co[1];
- lar->sh_invcampos[2]= -lar->co[2];
- mul_m3_v3(lar->imat, lar->sh_invcampos);
-
- /* z factor, for a normalized volume */
- angle= saacos(lar->spotsi);
- xn= lar->spotsi;
- yn = sinf(angle);
- lar->sh_zfac= yn/xn;
- /* pre-scale */
- lar->sh_invcampos[2]*= lar->sh_zfac;
-
- /* halfway shadow buffer doesn't work for volumetric effects */
- if (ELEM(lar->buftype, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP))
- lar->buftype = LA_SHADBUF_REGULAR;
-
- }
- }
- else if (la->type==LA_HEMI) {
- lar->mode &= ~(LA_SHAD_RAY|LA_SHAD_BUF);
- }
-
- for (c=0; c<MAX_MTEX; c++) {
- if (la->mtex[c] && la->mtex[c]->tex) {
- if (la->mtex[c]->mapto & LAMAP_COL)
- lar->mode |= LA_TEXTURE;
- if (la->mtex[c]->mapto & LAMAP_SHAD)
- lar->mode |= LA_SHAD_TEX;
-
- if (G.is_rendering) {
- if (re->osa) {
- if (la->mtex[c]->tex->type==TEX_IMAGE) lar->mode |= LA_OSATEX;
- }
- }
- }
- }
-
- /* old code checked for internal render (aka not yafray) */
- {
- /* to make sure we can check ray shadow easily in the render code */
- if (lar->mode & LA_SHAD_RAY) {
- if ( (re->r.mode & R_RAYTRACE)==0)
- lar->mode &= ~LA_SHAD_RAY;
- }
-
-
- if (re->r.mode & R_SHADOW) {
-
- if (la->type==LA_AREA && (lar->mode & LA_SHAD_RAY) && (lar->ray_samp_method == LA_SAMP_CONSTANT)) {
- init_jitter_plane(lar);
- }
- else if (la->type==LA_SPOT && (lar->mode & LA_SHAD_BUF) ) {
- /* Per lamp, one shadow buffer is made. */
- lar->bufflag= la->bufflag;
- copy_m4_m4(mat, ob->obmat);
- initshadowbuf(re, lar, mat); /* mat is altered */
- }
-
-
- /* this is the way used all over to check for shadow */
- if (lar->shb || (lar->mode & LA_SHAD_RAY)) {
- LampShadowSample *ls;
- LampShadowSubSample *lss;
- int a, b;
-
- memset(re->shadowsamplenr, 0, sizeof(re->shadowsamplenr));
-
- lar->shadsamp= MEM_mallocN(re->r.threads*sizeof(LampShadowSample), "lamp shadow sample");
- ls= lar->shadsamp;
-
- /* shadfacs actually mean light, let's put them to 1 to prevent unitialized accidents */
- for (a=0; a<re->r.threads; a++, ls++) {
- lss= ls->s;
- for (b=0; b<re->r.osa; b++, lss++) {
- lss->samplenr= -1; /* used to detect whether we store or read */
- lss->shadfac[0]= 1.0f;
- lss->shadfac[1]= 1.0f;
- lss->shadfac[2]= 1.0f;
- lss->shadfac[3]= 1.0f;
- }
- }
- }
- }
- }
-
- return go;
-}
-
-static bool is_object_restricted(Render *re, Object *ob)
-{
- if (re->r.scemode & R_VIEWPORT_PREVIEW)
- return (ob->restrictflag & OB_RESTRICT_VIEW) != 0;
- else
- return (ob->restrictflag & OB_RESTRICT_RENDER) != 0;
-}
-
-static bool is_object_hidden(Render *re, Object *ob)
-{
- if (is_object_restricted(re, ob))
- return true;
-
- if (re->r.scemode & R_VIEWPORT_PREVIEW) {
- /* Mesh deform cages and so on mess up the preview. To avoid the problem,
- * viewport doesn't show mesh object if its draw type is bounding box or wireframe.
- * Unless it's an active smoke domain!
- */
- ModifierData *md = NULL;
-
- if ((md = modifiers_findByType(ob, eModifierType_Smoke)) &&
- (modifier_isEnabled(re->scene, md, eModifierMode_Realtime)))
- {
- return false;
- }
- return ELEM(ob->dt, OB_BOUNDBOX, OB_WIRE);
- }
- else {
- return false;
- }
-}
-
-/* layflag: allows material group to ignore layerflag */
-static void add_lightgroup(Render *re, Group *group, int exclusive)
-{
- group->id.tag &= ~LIB_TAG_DOIT;
-
-#if 0
- /* it's a bit too many loops in loops... but will survive */
- /* note that 'exclusive' will remove it from the global list */
- FOREACH_GROUP_BASE_BEGIN(group, base)
- {
- Object *object = base->object;
-
- if (is_object_hidden(re, object)) {
- continue;
- }
-
- if (base->flag & BASE_VISIBLED) {
- if (object && object->type == OB_LAMP) {
- for (GroupObject *gol = re->lights.first; gol; gol = gol->next) {
- if (gol->ob == object) {
- go->lampren = gol->lampren;
- break;
- }
- }
-
- if (go->lampren == NULL) {
- gol= add_render_lamp(re, object);
- }
-
- if (gol && exclusive) {
- BLI_remlink(&re->lights, gol);
- MEM_freeN(gol);
- }
- }
- }
- }
- FOREACH_GROUP_BASE_END;
-#else
- UNUSED_VARS(re, exclusive);
-#endif
-}
-
-static void set_material_lightgroups(Render *re)
-{
- Group *group;
- Material *ma;
-
- /* not for preview render */
- if (re->scene->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))
- return;
-
- for (group= re->main->group.first; group; group=group->id.next)
- group->id.tag |= LIB_TAG_DOIT;
-
- /* it's a bit too many loops in loops... but will survive */
- /* hola! materials not in use...? */
- for (ma= re->main->mat.first; ma; ma=ma->id.next) {
- if (ma->group && (ma->group->id.tag & LIB_TAG_DOIT))
- add_lightgroup(re, ma->group, ma->mode & MA_GROUP_NOLAY);
- }
-}
-
-/* ------------------------------------------------------------------------- */
-/* World */
-/* ------------------------------------------------------------------------- */
-
-void init_render_world(Render *re)
-{
- void *wrld_prev[2] = {
- re->wrld.aotables,
- re->wrld.aosphere,
- };
-
- int a;
-
- if (re->scene && re->scene->world) {
- re->wrld = *(re->scene->world);
-
- copy_v3_v3(re->grvec, re->viewmat[2]);
- normalize_v3(re->grvec);
- copy_m3_m4(re->imat, re->viewinv);
-
- for (a=0; a<MAX_MTEX; a++)
- if (re->wrld.mtex[a] && re->wrld.mtex[a]->tex) re->wrld.skytype |= WO_SKYTEX;
-
- /* AO samples should be OSA minimum */
- if (re->osa)
- while (re->wrld.aosamp*re->wrld.aosamp < re->osa)
- re->wrld.aosamp++;
- if (!(re->r.mode & R_RAYTRACE) && (re->wrld.ao_gather_method == WO_AOGATHER_RAYTRACE))
- re->wrld.mode &= ~(WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT);
- }
- else {
- memset(&re->wrld, 0, sizeof(World));
- re->wrld.exp= 0.0f;
- re->wrld.range= 1.0f;
-
- /* for mist pass */
- re->wrld.miststa= re->clipsta;
- re->wrld.mistdist= re->clipend-re->clipsta;
- re->wrld.misi= 1.0f;
- }
-
- re->wrld.linfac= 1.0f + powf((2.0f*re->wrld.exp + 0.5f), -10);
- re->wrld.logfac= logf((re->wrld.linfac-1.0f)/re->wrld.linfac) / re->wrld.range;
-
- /* restore runtime vars, needed for viewport rendering [#36005] */
- re->wrld.aotables = wrld_prev[0];
- re->wrld.aosphere = wrld_prev[1];
-}
-
-
-
-/* ------------------------------------------------------------------------- */
-/* Object Finalization */
-/* ------------------------------------------------------------------------- */
-
-/* prevent phong interpolation for giving ray shadow errors (terminator problem) */
-static void set_phong_threshold(ObjectRen *obr)
-{
-// VertRen *ver;
- VlakRen *vlr;
- float thresh= 0.0, dot;
- int tot=0, i;
-
- /* Added check for 'pointy' situations, only dotproducts of 0.9 and larger
- * are taken into account. This threshold is meant to work on smooth geometry, not
- * for extreme cases (ton) */
-
- for (i=0; i<obr->totvlak; i++) {
- vlr= RE_findOrAddVlak(obr, i);
- if ((vlr->flag & R_SMOOTH) && (vlr->flag & R_STRAND)==0) {
- dot= dot_v3v3(vlr->n, vlr->v1->n);
- dot= ABS(dot);
- if (dot>0.9f) {
- thresh+= dot; tot++;
- }
- dot= dot_v3v3(vlr->n, vlr->v2->n);
- dot= ABS(dot);
- if (dot>0.9f) {
- thresh+= dot; tot++;
- }
-
- dot= dot_v3v3(vlr->n, vlr->v3->n);
- dot= ABS(dot);
- if (dot>0.9f) {
- thresh+= dot; tot++;
- }
-
- if (vlr->v4) {
- dot= dot_v3v3(vlr->n, vlr->v4->n);
- dot= ABS(dot);
- if (dot>0.9f) {
- thresh+= dot; tot++;
- }
- }
- }
- }
-
- if (tot) {
- thresh/= (float)tot;
- obr->ob->smoothresh= cosf(0.5f*(float)M_PI-saacos(thresh));
- }
-}
-
-/* per face check if all samples should be taken.
- * if raytrace or multisample, do always for raytraced material, or when material full_osa set */
-static void set_fullsample_trace_flag(Render *re, ObjectRen *obr)
-{
- VlakRen *vlr;
- int a, trace, mode, osa;
-
- osa= re->osa;
- trace= re->r.mode & R_RAYTRACE;
-
- for (a=obr->totvlak-1; a>=0; a--) {
- vlr= RE_findOrAddVlak(obr, a);
- mode= vlr->mat->mode;
-
- if (trace && (mode & MA_TRACEBLE))
- vlr->flag |= R_TRACEBLE;
-
- if (osa) {
- if (mode & MA_FULL_OSA) {
- vlr->flag |= R_FULL_OSA;
- }
- else if (trace) {
- if (mode & MA_SHLESS) {
- /* pass */
- }
- else if (vlr->mat->material_type == MA_TYPE_VOLUME) {
- /* pass */
- }
- else if ((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) {
- /* for blurry reflect/refract, better to take more samples
- * inside the raytrace than as OSA samples */
- if ((vlr->mat->gloss_mir == 1.0f) && (vlr->mat->gloss_tra == 1.0f))
- vlr->flag |= R_FULL_OSA;
- }
- }
- }
- }
-}
-
-/* split quads for predictable baking
- * dir 1 == (0, 1, 2) (0, 2, 3), 2 == (1, 3, 0) (1, 2, 3)
- */
-static void split_quads(ObjectRen *obr, int dir)
-{
- VlakRen *vlr, *vlr1;
- int a;
-
- for (a=obr->totvlak-1; a>=0; a--) {
- vlr= RE_findOrAddVlak(obr, a);
-
- /* test if rendering as a quad or triangle, skip wire */
- if ((vlr->flag & R_STRAND)==0 && (vlr->mat->material_type != MA_TYPE_WIRE)) {
-
- if (vlr->v4) {
-
- vlr1= RE_vlakren_copy(obr, vlr);
- vlr1->flag |= R_FACE_SPLIT;
-
- if ( dir==2 ) vlr->flag |= R_DIVIDE_24;
- else vlr->flag &= ~R_DIVIDE_24;
-
- /* new vertex pointers */
- if (vlr->flag & R_DIVIDE_24) {
- vlr1->v1= vlr->v2;
- vlr1->v2= vlr->v3;
- vlr1->v3= vlr->v4;
-
- vlr->v3 = vlr->v4;
-
- vlr1->flag |= R_DIVIDE_24;
- }
- else {
- vlr1->v1= vlr->v1;
- vlr1->v2= vlr->v3;
- vlr1->v3= vlr->v4;
-
- vlr1->flag &= ~R_DIVIDE_24;
- }
- vlr->v4 = vlr1->v4 = NULL;
-
-#ifdef WITH_FREESTYLE
- /* Freestyle edge marks */
- if (vlr->flag & R_DIVIDE_24) {
- vlr1->freestyle_edge_mark=
- ((vlr->freestyle_edge_mark & R_EDGE_V2V3) ? R_EDGE_V1V2 : 0) |
- ((vlr->freestyle_edge_mark & R_EDGE_V3V4) ? R_EDGE_V2V3 : 0);
- vlr->freestyle_edge_mark=
- ((vlr->freestyle_edge_mark & R_EDGE_V1V2) ? R_EDGE_V1V2 : 0) |
- ((vlr->freestyle_edge_mark & R_EDGE_V4V1) ? R_EDGE_V3V1 : 0);
- }
- else {
- vlr1->freestyle_edge_mark=
- ((vlr->freestyle_edge_mark & R_EDGE_V3V4) ? R_EDGE_V2V3 : 0) |
- ((vlr->freestyle_edge_mark & R_EDGE_V4V1) ? R_EDGE_V3V1 : 0);
- vlr->freestyle_edge_mark=
- ((vlr->freestyle_edge_mark & R_EDGE_V1V2) ? R_EDGE_V1V2 : 0) |
- ((vlr->freestyle_edge_mark & R_EDGE_V2V3) ? R_EDGE_V2V3 : 0);
- }
-#endif
-
- /* new normals */
- normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- normal_tri_v3(vlr1->n, vlr1->v3->co, vlr1->v2->co, vlr1->v1->co);
- }
- /* clear the flag when not divided */
- else vlr->flag &= ~R_DIVIDE_24;
- }
- }
-}
-
-static void check_non_flat_quads(ObjectRen *obr)
-{
- VlakRen *vlr, *vlr1;
- VertRen *v1, *v2, *v3, *v4;
- float nor[3], xn, flen;
- int a;
-
- for (a=obr->totvlak-1; a>=0; a--) {
- vlr= RE_findOrAddVlak(obr, a);
-
- /* test if rendering as a quad or triangle, skip wire */
- if (vlr->v4 && (vlr->flag & R_STRAND)==0 && (vlr->mat->material_type != MA_TYPE_WIRE)) {
-
- /* check if quad is actually triangle */
- v1= vlr->v1;
- v2= vlr->v2;
- v3= vlr->v3;
- v4= vlr->v4;
- sub_v3_v3v3(nor, v1->co, v2->co);
- if ( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) {
- vlr->v1= v2;
- vlr->v2= v3;
- vlr->v3= v4;
- vlr->v4= NULL;
- vlr->flag |= (R_DIVIDE_24 | R_FACE_SPLIT);
- }
- else {
- sub_v3_v3v3(nor, v2->co, v3->co);
- if ( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) {
- vlr->v2= v3;
- vlr->v3= v4;
- vlr->v4= NULL;
- vlr->flag |= R_FACE_SPLIT;
- }
- else {
- sub_v3_v3v3(nor, v3->co, v4->co);
- if ( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) {
- vlr->v4= NULL;
- }
- else {
- sub_v3_v3v3(nor, v4->co, v1->co);
- if ( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) {
- vlr->v4= NULL;
- }
- }
- }
- }
-
- if (vlr->v4) {
-
- /* Face is divided along edge with the least gradient */
- /* Flagged with R_DIVIDE_24 if divide is from vert 2 to 4 */
- /* 4---3 4---3 */
- /* |\ 1| or |1 /| */
- /* |0\ | |/ 0| */
- /* 1---2 1---2 0 = orig face, 1 = new face */
-
- /* render normals are inverted in render! we calculate normal of single tria here */
- flen= normal_tri_v3(nor, vlr->v4->co, vlr->v3->co, vlr->v1->co);
- if (flen==0.0f) normal_tri_v3(nor, vlr->v4->co, vlr->v2->co, vlr->v1->co);
-
- xn = dot_v3v3(nor, vlr->n);
-
- if (ABS(xn) < 0.999995f ) { /* checked on noisy fractal grid */
-
- float d1, d2;
-
- vlr1= RE_vlakren_copy(obr, vlr);
- vlr1->flag |= R_FACE_SPLIT;
-
- /* split direction based on vnorms */
- normal_tri_v3(nor, vlr->v1->co, vlr->v2->co, vlr->v3->co);
- d1 = dot_v3v3(nor, vlr->v1->n);
-
- normal_tri_v3(nor, vlr->v2->co, vlr->v3->co, vlr->v4->co);
- d2 = dot_v3v3(nor, vlr->v2->n);
-
- if (fabsf(d1) < fabsf(d2) ) vlr->flag |= R_DIVIDE_24;
- else vlr->flag &= ~R_DIVIDE_24;
-
- /* new vertex pointers */
- if (vlr->flag & R_DIVIDE_24) {
- vlr1->v1= vlr->v2;
- vlr1->v2= vlr->v3;
- vlr1->v3= vlr->v4;
-
- vlr->v3 = vlr->v4;
-
- vlr1->flag |= R_DIVIDE_24;
- }
- else {
- vlr1->v1= vlr->v1;
- vlr1->v2= vlr->v3;
- vlr1->v3= vlr->v4;
-
- vlr1->flag &= ~R_DIVIDE_24;
- }
- vlr->v4 = vlr1->v4 = NULL;
-
- /* new normals */
- normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co);
- normal_tri_v3(vlr1->n, vlr1->v3->co, vlr1->v2->co, vlr1->v1->co);
-
-#ifdef WITH_FREESTYLE
- /* Freestyle edge marks */
- if (vlr->flag & R_DIVIDE_24) {
- vlr1->freestyle_edge_mark=
- ((vlr->freestyle_edge_mark & R_EDGE_V2V3) ? R_EDGE_V1V2 : 0) |
- ((vlr->freestyle_edge_mark & R_EDGE_V3V4) ? R_EDGE_V2V3 : 0);
- vlr->freestyle_edge_mark=
- ((vlr->freestyle_edge_mark & R_EDGE_V1V2) ? R_EDGE_V1V2 : 0) |
- ((vlr->freestyle_edge_mark & R_EDGE_V4V1) ? R_EDGE_V3V1 : 0);
- }
- else {
- vlr1->freestyle_edge_mark=
- ((vlr->freestyle_edge_mark & R_EDGE_V3V4) ? R_EDGE_V2V3 : 0) |
- ((vlr->freestyle_edge_mark & R_EDGE_V4V1) ? R_EDGE_V3V1 : 0);
- vlr->freestyle_edge_mark=
- ((vlr->freestyle_edge_mark & R_EDGE_V1V2) ? R_EDGE_V1V2 : 0) |
- ((vlr->freestyle_edge_mark & R_EDGE_V2V3) ? R_EDGE_V2V3 : 0);
- }
-#endif
- }
- /* clear the flag when not divided */
- else vlr->flag &= ~R_DIVIDE_24;
- }
- }
- }
-}
-
-static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset)
-{
- Object *ob= obr->ob;
- VertRen *ver= NULL;
- StrandRen *strand= NULL;
- StrandBound *sbound= NULL;
- float min[3], max[3], smin[3], smax[3];
- int a, b;
-
- if (obr->totvert || obr->totvlak || obr->tothalo || obr->totstrand) {
- /* the exception below is because displace code now is in init_render_mesh call,
- * I will look at means to have autosmooth enabled for all object types
- * and have it as general postprocess, like displace */
- if (ob->type!=OB_MESH && test_for_displace(re, ob))
- displace(re, obr);
-
- if (!timeoffset) {
- /* phong normal interpolation can cause error in tracing
- * (terminator problem) */
- ob->smoothresh= 0.0;
- if ((re->r.mode & R_RAYTRACE) && (re->r.mode & R_SHADOW))
- set_phong_threshold(obr);
-
- if (re->flag & R_BAKING && re->r.bake_quad_split != 0) {
- /* Baking lets us define a quad split order */
- split_quads(obr, re->r.bake_quad_split);
- }
- else if (BKE_object_is_animated(re->scene, ob))
- split_quads(obr, 1);
- else {
- if ((re->r.mode & R_SIMPLIFY && re->r.simplify_flag & R_SIMPLE_NO_TRIANGULATE) == 0)
- check_non_flat_quads(obr);
- }
-
- set_fullsample_trace_flag(re, obr);
-
- /* compute bounding boxes for clipping */
- INIT_MINMAX(min, max);
- for (a=0; a<obr->totvert; a++) {
- if ((a & 255)==0) ver= obr->vertnodes[a>>8].vert;
- else ver++;
-
- minmax_v3v3_v3(min, max, ver->co);
- }
-
- if (obr->strandbuf) {
- float width;
-
- /* compute average bounding box of strandpoint itself (width) */
- if (obr->strandbuf->flag & R_STRAND_B_UNITS)
- obr->strandbuf->maxwidth = max_ff(obr->strandbuf->ma->strand_sta, obr->strandbuf->ma->strand_end);
- else
- obr->strandbuf->maxwidth= 0.0f;
-
- width= obr->strandbuf->maxwidth;
- sbound= obr->strandbuf->bound;
- for (b=0; b<obr->strandbuf->totbound; b++, sbound++) {
-
- INIT_MINMAX(smin, smax);
-
- for (a=sbound->start; a<sbound->end; a++) {
- strand= RE_findOrAddStrand(obr, a);
- strand_minmax(strand, smin, smax, width);
- }
-
- copy_v3_v3(sbound->boundbox[0], smin);
- copy_v3_v3(sbound->boundbox[1], smax);
-
- minmax_v3v3_v3(min, max, smin);
- minmax_v3v3_v3(min, max, smax);
- }
- }
-
- copy_v3_v3(obr->boundbox[0], min);
- copy_v3_v3(obr->boundbox[1], max);
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-/* Database */
-/* ------------------------------------------------------------------------- */
-
-static int render_object_type(short type)
-{
- return OB_TYPE_SUPPORT_MATERIAL(type);
-}
-
-static void find_dupli_instances(Render *re, ObjectRen *obr, DupliObject *dob)
-{
- ObjectInstanceRen *obi;
- float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3];
- int first = 1;
-
- mul_m4_m4m4(obmat, re->viewmat, obr->obmat);
- invert_m4_m4(imat, obmat);
-
- /* for objects instanced by dupliverts/faces/particles, we go over the
- * list of instances to find ones that instance obr, and setup their
- * matrices and obr pointer */
- for (obi=re->instancetable.last; obi; obi=obi->prev) {
- if (!obi->obr && obi->ob == obr->ob && obi->psysindex == obr->psysindex) {
- obi->obr= obr;
-
- /* compute difference between object matrix and
- * object matrix with dupli transform, in viewspace */
- copy_m4_m4(obimat, obi->mat);
- mul_m4_m4m4(obi->mat, obimat, imat);
-
- copy_m3_m4(nmat, obi->mat);
- invert_m3_m3(obi->nmat, nmat);
- transpose_m3(obi->nmat);
-
- if (dob) {
- copy_v3_v3(obi->dupliorco, dob->orco);
- obi->dupliuv[0]= dob->uv[0];
- obi->dupliuv[1]= dob->uv[1];
- }
-
- if (!first) {
- re->totvert += obr->totvert;
- re->totvlak += obr->totvlak;
- re->tothalo += obr->tothalo;
- re->totstrand += obr->totstrand;
- }
- else
- first= 0;
- }
- }
-}
-
-static void assign_dupligroup_dupli(Render *re, ObjectInstanceRen *obi, ObjectRen *obr, DupliObject *dob)
-{
- float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3];
-
- mul_m4_m4m4(obmat, re->viewmat, obr->obmat);
- invert_m4_m4(imat, obmat);
-
- obi->obr= obr;
-
- /* compute difference between object matrix and
- * object matrix with dupli transform, in viewspace */
- copy_m4_m4(obimat, obi->mat);
- mul_m4_m4m4(obi->mat, obimat, imat);
-
- copy_m3_m4(nmat, obi->mat);
- invert_m3_m3(obi->nmat, nmat);
- transpose_m3(obi->nmat);
-
- if (dob) {
- copy_v3_v3(obi->dupliorco, dob->orco);
- obi->dupliuv[0]= dob->uv[0];
- obi->dupliuv[1]= dob->uv[1];
- }
-
- re->totvert += obr->totvert;
- re->totvlak += obr->totvlak;
- re->tothalo += obr->tothalo;
- re->totstrand += obr->totstrand;
-}
-
-static ObjectRen *find_dupligroup_dupli(Render *re, Object *ob, int psysindex)
-{
- ObjectRen *obr;
-
- /* if the object is itself instanced, we don't want to create an instance
- * for it */
- if (ob->transflag & OB_RENDER_DUPLI)
- return NULL;
-
- /* try to find an object that was already created so we can reuse it
- * and save memory */
- for (obr=re->objecttable.first; obr; obr=obr->next)
- if (obr->ob == ob && obr->psysindex == psysindex && (obr->flag & R_INSTANCEABLE))
- return obr;
-
- return NULL;
-}
-
-static void set_dupli_tex_mat(Render *re, ObjectInstanceRen *obi, DupliObject *dob, float omat[4][4])
-{
- /* For duplis we need to have a matrix that transform the coordinate back
- * to it's original position, without the dupli transforms. We also check
- * the matrix is actually needed, to save memory on lots of dupliverts for
- * example */
- static Object *lastob= NULL;
- static int needtexmat= 0;
-
- /* init */
- if (!re) {
- lastob= NULL;
- needtexmat= 0;
- return;
- }
-
- /* check if we actually need it */
- if (lastob != dob->ob) {
- Material ***material;
- short a, *totmaterial;
-
- lastob= dob->ob;
- needtexmat= 0;
-
- totmaterial= give_totcolp(dob->ob);
- material= give_matarar(dob->ob);
-
- if (totmaterial && material)
- for (a= 0; a<*totmaterial; a++)
- if ((*material)[a] && (*material)[a]->texco & TEXCO_OBJECT)
- needtexmat= 1;
- }
-
- if (needtexmat) {
- float imat[4][4];
-
- obi->duplitexmat= BLI_memarena_alloc(re->memArena, sizeof(float)*4*4);
- invert_m4_m4(imat, dob->mat);
- mul_m4_series(obi->duplitexmat, re->viewmat, omat, imat, re->viewinv);
- }
-
- copy_v3_v3(obi->dupliorco, dob->orco);
- copy_v2_v2(obi->dupliuv, dob->uv);
-}
-
-static void init_render_object_data(const EvaluationContext *eval_ctx, Render *re, ObjectRen *obr, int timeoffset)
-{
- Object *ob= obr->ob;
- ParticleSystem *psys;
- int i;
-
- if (obr->psysindex) {
- if ((!obr->prev || obr->prev->ob != ob || (obr->prev->flag & R_INSTANCEABLE)==0) && ob->type==OB_MESH) {
- /* the emitter mesh wasn't rendered so the modifier stack wasn't
- * evaluated with render settings */
- DerivedMesh *dm;
- const CustomDataMask mask = CD_MASK_RENDER_INTERNAL;
-
- if (re->r.scemode & R_VIEWPORT_PREVIEW)
- dm = mesh_create_derived_view(eval_ctx, re->scene, ob, mask);
- else
- dm = mesh_create_derived_render(eval_ctx, re->scene, ob, mask);
- dm->release(dm);
- }
-
- for (psys=ob->particlesystem.first, i=0; i<obr->psysindex-1; i++)
- psys= psys->next;
-
- render_new_particle_system(eval_ctx, re, obr, psys, timeoffset);
- }
- else {
- if (ELEM(ob->type, OB_FONT, OB_CURVE))
- init_render_curve(eval_ctx, re, obr, timeoffset);
- else if (ob->type==OB_SURF)
- init_render_surf(eval_ctx, re, obr, timeoffset);
- else if (ob->type==OB_MESH)
- init_render_mesh(eval_ctx, re, obr, timeoffset);
- else if (ob->type==OB_MBALL)
- init_render_mball(eval_ctx, re, obr);
- }
-
- finalize_render_object(re, obr, timeoffset);
-
- re->totvert += obr->totvert;
- re->totvlak += obr->totvlak;
- re->tothalo += obr->tothalo;
- re->totstrand += obr->totstrand;
-}
-
-static void add_render_object(const EvaluationContext *eval_ctx, Render *re, Object *ob, Object *par, DupliObject *dob,
- float omat[4][4], int timeoffset)
-{
- ObjectRen *obr;
- ObjectInstanceRen *obi;
- ParticleSystem *psys;
- int show_emitter, allow_render= 1, index, psysindex, i;
-
- index= (dob)? dob->persistent_id[0]: 0;
-
- /* the emitter has to be processed first (render levels of modifiers) */
- /* so here we only check if the emitter should be rendered */
- if (ob->particlesystem.first) {
- show_emitter = (ob->duplicator_visibility_flag & OB_DUPLI_FLAG_RENDER) != 0;
-
- /* if no psys has "show emitter" selected don't render emitter */
- if (show_emitter == 0)
- allow_render= 0;
- }
-
- /* one render object for the data itself */
- if (allow_render) {
- obr= RE_addRenderObject(re, ob, par, index, 0, ob->lay);
- if ((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) {
- obr->flag |= R_INSTANCEABLE;
- copy_m4_m4(obr->obmat, ob->obmat);
- }
- init_render_object_data(eval_ctx, re, obr, timeoffset);
-
- /* only add instance for objects that have not been used for dupli */
- if (!(ob->transflag & OB_RENDER_DUPLI)) {
- obi = RE_addRenderInstance(re, obr, ob, par, index, 0, NULL, ob->lay, dob);
- if (dob) set_dupli_tex_mat(re, obi, dob, omat);
- }
- else
- find_dupli_instances(re, obr, dob);
-
- for (i=1; i<=ob->totcol; i++) {
- Material* ma = give_render_material(re, ob, i);
- if (ma && ma->material_type == MA_TYPE_VOLUME)
- add_volume(re, obr, ma);
- }
- }
-
- /* and one render object per particle system */
- if (ob->particlesystem.first) {
- psysindex= 1;
- for (psys=ob->particlesystem.first; psys; psys=psys->next, psysindex++) {
- if (!psys_check_enabled(ob, psys, G.is_rendering))
- continue;
-
- obr= RE_addRenderObject(re, ob, par, index, psysindex, ob->lay);
- if ((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) {
- obr->flag |= R_INSTANCEABLE;
- copy_m4_m4(obr->obmat, ob->obmat);
- }
- if (dob)
- psys->flag |= PSYS_USE_IMAT;
- init_render_object_data(eval_ctx, re, obr, timeoffset);
- psys->flag &= ~PSYS_USE_IMAT;
-
- /* only add instance for objects that have not been used for dupli */
- if (!(ob->transflag & OB_RENDER_DUPLI)) {
- obi = RE_addRenderInstance(re, obr, ob, par, index, psysindex, NULL, ob->lay, dob);
- if (dob) set_dupli_tex_mat(re, obi, dob, omat);
- }
- else
- find_dupli_instances(re, obr, dob);
- }
- }
-}
-
-/* par = pointer to duplicator parent, needed for object lookup table */
-/* index = when duplicater copies same object (particle), the counter */
-static void init_render_object(const EvaluationContext *eval_ctx, Render *re, Object *ob, Object *par, DupliObject *dob,
- float omat[4][4], int timeoffset)
-{
- static double lasttime= 0.0;
- double time;
- float mat[4][4];
-
- if (ob->type==OB_LAMP)
- add_render_lamp(re, ob);
- else if (render_object_type(ob->type))
- add_render_object(eval_ctx, re, ob, par, dob, omat, timeoffset);
- else {
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- invert_m4_m4(ob->imat, mat);
- }
-
- time= PIL_check_seconds_timer();
- if (time - lasttime > 1.0) {
- lasttime= time;
- /* clumsy copying still */
- re->i.totvert= re->totvert;
- re->i.totface= re->totvlak;
- re->i.totstrand= re->totstrand;
- re->i.tothalo= re->tothalo;
- re->i.totlamp= re->totlamp;
- re->stats_draw(re->sdh, &re->i);
- }
-
- ob->flag |= OB_DONE;
-}
-
-void RE_Database_Free(Render *re)
-{
- LampRen *lar;
-
- /* will crash if we try to free empty database */
- if (!re->i.convertdone)
- return;
-
- /* statistics for debugging render memory usage */
- if ((G.debug & G_DEBUG) && (G.is_rendering)) {
- if ((re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0) {
- BKE_image_print_memlist();
- MEM_printmemlist_stats();
- }
- }
-
- /* FREE */
-
- for (lar= re->lampren.first; lar; lar= lar->next) {
- freeshadowbuf(lar);
- if (lar->jitter) MEM_freeN(lar->jitter);
- if (lar->shadsamp) MEM_freeN(lar->shadsamp);
- if (lar->sunsky) MEM_freeN(lar->sunsky);
- curvemapping_free(lar->curfalloff);
- }
-
- free_volume_precache(re);
-
- BLI_freelistN(&re->lampren);
- BLI_freelistN(&re->lights);
-
- free_renderdata_tables(re);
-
- /* free orco */
- free_mesh_orco_hash(re);
-
- if (re->main) {
- end_render_materials(re->main);
- end_render_textures(re);
- free_pointdensities(re);
- }
-
- free_camera_inside_volumes(re);
-
- if (re->wrld.aosphere) {
- MEM_freeN(re->wrld.aosphere);
- re->wrld.aosphere= NULL;
- if (re->scene && re->scene->world)
- re->scene->world->aosphere= NULL;
- }
- if (re->wrld.aotables) {
- MEM_freeN(re->wrld.aotables);
- re->wrld.aotables= NULL;
- if (re->scene && re->scene->world)
- re->scene->world->aotables= NULL;
- }
- if (re->r.mode & R_RAYTRACE)
- free_render_qmcsampler(re);
-
- if (re->r.mode & R_RAYTRACE) freeraytree(re);
-
- free_sss(re);
- free_occ(re);
- free_strand_surface(re);
-
- re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
- re->i.convertdone = false;
-
- re->bakebuf= NULL;
-
- if (re->scene)
- if (re->scene->r.scemode & R_FREE_IMAGE)
- if ((re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0)
- BKE_image_free_all_textures();
-
- if (re->memArena) {
- BLI_memarena_free(re->memArena);
- re->memArena = NULL;
- }
-
- BKE_viewrender_free(&re->view_render);
-}
-
-static int allow_render_object(Render *re, Object *ob, int nolamps, int onlyselected, Object *actob)
-{
- if (is_object_hidden(re, ob))
- return 0;
-
- /* Only handle dupli-hiding here if there is no particle systems. Else, let those handle show/noshow. */
- if (!ob->particlesystem.first) {
- if ((ob->transflag & OB_DUPLI) && !(ob->transflag & OB_DUPLIFRAMES)) {
- return 0;
- }
- }
-
- /* don't add non-basic meta objects, ends up having renderobjects with no geometry */
- if (ob->type == OB_MBALL && ob!=BKE_mball_basis_find(re->scene, ob))
- return 0;
-
- if (nolamps && (ob->type==OB_LAMP))
- return 0;
-
- if (onlyselected && (ob!=actob && !(ob->flag & SELECT)))
- return 0;
-
- return 1;
-}
-
-static int allow_render_dupli_instance(Render *UNUSED(re), DupliObject *dob, Object *obd)
-{
- ParticleSystem *psys;
- Material *ma;
- short a, *totmaterial;
-
- /* don't allow objects with halos. we need to have
- * all halo's to sort them globally in advance */
- totmaterial= give_totcolp(obd);
-
- if (totmaterial) {
- for (a= 0; a<*totmaterial; a++) {
- ma= give_current_material(obd, a + 1);
- if (ma && (ma->material_type == MA_TYPE_HALO))
- return 0;
- }
- }
-
- for (psys=obd->particlesystem.first; psys; psys=psys->next)
- if (!ELEM(psys->part->ren_as, PART_DRAW_BB, PART_DRAW_LINE, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR))
- return 0;
-
- /* don't allow lamp, animated duplis, or radio render */
- return (render_object_type(obd->type) &&
- (!(dob->type == OB_DUPLIGROUP) || !dob->animated));
-}
-
-static int get_vector_viewlayers(Scene *UNUSED(sce))
-{
- return 0;
-}
-
-static void add_group_render_dupli_obs(const EvaluationContext *eval_ctx, Render *re, Group *group, int nolamps,
- int onlyselected, Object *actob, int timeoffset, int level)
-{
- /* Simple preventing of too deep nested groups. */
- if (level > MAX_DUPLI_RECUR) return;
-
- /* Recursively go into dupligroups to find objects with OB_RENDER_DUPLI
- * that were not created yet. */
- FOREACH_GROUP_OBJECT_BEGIN(group, ob)
- {
- if (ob->flag & OB_DONE) {
- if (ob->transflag & OB_RENDER_DUPLI) {
- if (allow_render_object(re, ob, nolamps, onlyselected, actob)) {
- init_render_object(eval_ctx, re, ob, NULL, NULL, NULL, timeoffset);
- ob->transflag &= ~OB_RENDER_DUPLI;
-
- if (ob->dup_group) {
- add_group_render_dupli_obs(eval_ctx, re, ob->dup_group, nolamps, onlyselected, actob, timeoffset, level+1);
- }
- }
- }
- }
- }
- FOREACH_GROUP_OBJECT_END;
-}
-
-static void database_init_objects(const EvaluationContext *eval_ctx, Render *re, unsigned int UNUSED(renderlay),
- int nolamps, int onlyselected, Object *actob, int timeoffset)
-{
- Base *base;
- Object *ob;
- Group *group;
- ObjectInstanceRen *obi;
- Scene *sce_iter;
-
- /* for duplis we need the Object texture mapping to work as if
- * untransformed, set_dupli_tex_mat sets the matrix to allow that
- * NULL is just for init */
- set_dupli_tex_mat(NULL, NULL, NULL, NULL);
-
- /* loop over all objects rather then using SETLOOPER because we may
- * reference an mtex-mapped object which isn't rendered or is an
- * empty in a dupli group. We could scan all render material/lamp/world
- * mtex's for mapto objects but its easier just to set the
- * 'imat' / 'imat_ren' on all and unlikely to be a performance hit
- * See bug: [#28744] - campbell */
- for (ob= re->main->object.first; ob; ob= ob->id.next) {
- float mat[4][4];
-
- /* imat objects has to be done here, since displace can have texture using Object map-input */
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- invert_m4_m4(ob->imat_ren, mat);
- copy_m4_m4(ob->imat, ob->imat_ren);
- /* each object should only be rendered once */
- ob->flag &= ~OB_DONE;
- ob->transflag &= ~OB_RENDER_DUPLI;
- }
-
- for (SETLOOPER(re->scene, sce_iter, base)) {
- ob= base->object;
-
-#if 0
- TODO_LAYER; /* investigate if this is an issue*/
- /* in the prev/next pass for making speed vectors, avoid creating
- * objects that are not on a renderlayer with a vector pass, can
- * save a lot of time in complex scenes */
- vectorlay= get_vector_viewlayers(re->scene);
-#endif
-
- /* if the object is not visible, ignore it */
- if ((base->flag & BASE_VISIBLED) == 0) {
- continue;
- }
-
- /* OB_DONE means the object itself got duplicated, so was already converted */
- if (ob->flag & OB_DONE) {
- /* OB_RENDER_DUPLI means instances for it were already created, now
- * it still needs to create the ObjectRen containing the data */
- if (ob->transflag & OB_RENDER_DUPLI) {
- if (allow_render_object(re, ob, nolamps, onlyselected, actob)) {
- init_render_object(eval_ctx, re, ob, NULL, NULL, NULL, timeoffset);
- ob->transflag &= ~OB_RENDER_DUPLI;
- }
- }
- }
- else if (((base->flag & BASE_VISIBLED) != 0) || (ob->type==OB_LAMP)) {
- if ((ob->transflag & OB_DUPLI) && (ob->type!=OB_MBALL)) {
- DupliObject *dob;
- ListBase *duplilist;
- DupliApplyData *duplilist_apply_data = NULL;
- int i;
-
- /* create list of duplis generated by this object, particle
- * system need to have render settings set for dupli particles */
- duplilist = object_duplilist(eval_ctx, re->scene, ob);
- duplilist_apply_data = duplilist_apply(eval_ctx, ob, NULL, duplilist);
-
- for (dob= duplilist->first, i = 0; dob; dob= dob->next, ++i) {
- DupliExtraData *dob_extra = &duplilist_apply_data->extra[i];
- Object *obd= dob->ob;
-
- copy_m4_m4(obd->obmat, dob->mat);
-
- /* group duplis need to set ob matrices correct, for deform. so no_draw is part handled */
- if (!(obd->transflag & OB_RENDER_DUPLI) && dob->no_draw)
- continue;
-
- if (is_object_hidden(re, obd))
- continue;
-
- if (obd->type==OB_MBALL)
- continue;
-
- if (!allow_render_object(re, obd, nolamps, onlyselected, actob))
- continue;
-
- if (allow_render_dupli_instance(re, dob, obd)) {
- ParticleSystem *psys;
- ObjectRen *obr = NULL;
- int psysindex;
- float mat[4][4];
-
- obi=NULL;
-
- /* instances instead of the actual object are added in two cases, either
- * this is a duplivert/face/particle, or it is a non-animated object in
- * a dupligroup that has already been created before */
- if (dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) {
- mul_m4_m4m4(mat, re->viewmat, dob->mat);
- /* ob = particle system, use that layer */
- obi = RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], 0, mat, ob->lay, dob);
-
- /* fill in instance variables for texturing */
- set_dupli_tex_mat(re, obi, dob, dob_extra->obmat);
- if (dob->type != OB_DUPLIGROUP) {
- copy_v3_v3(obi->dupliorco, dob->orco);
- obi->dupliuv[0]= dob->uv[0];
- obi->dupliuv[1]= dob->uv[1];
- }
- else {
- /* for the second case, setup instance to point to the already
- * created object, and possibly setup instances if this object
- * itself was duplicated. for the first case find_dupli_instances
- * will be called later. */
- assign_dupligroup_dupli(re, obi, obr, dob);
- if (obd->transflag & OB_RENDER_DUPLI)
- find_dupli_instances(re, obr, dob);
- }
- }
-
- /* same logic for particles, each particle system has it's own object, so
- * need to go over them separately */
- psysindex= 1;
- for (psys=obd->particlesystem.first; psys; psys=psys->next) {
- if (dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, psysindex))) {
- if (obi == NULL)
- mul_m4_m4m4(mat, re->viewmat, dob->mat);
- obi = RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], psysindex++, mat, obd->lay, dob);
-
- set_dupli_tex_mat(re, obi, dob, dob_extra->obmat);
- if (dob->type != OB_DUPLIGROUP) {
- copy_v3_v3(obi->dupliorco, dob->orco);
- obi->dupliuv[0]= dob->uv[0];
- obi->dupliuv[1]= dob->uv[1];
- }
- else {
- assign_dupligroup_dupli(re, obi, obr, dob);
- if (obd->transflag & OB_RENDER_DUPLI)
- find_dupli_instances(re, obr, dob);
- }
- }
- }
-
- if (obi==NULL)
- /* can't instance, just create the object */
- init_render_object(eval_ctx, re, obd, ob, dob, dob_extra->obmat, timeoffset);
-
- if (dob->type != OB_DUPLIGROUP) {
- obd->flag |= OB_DONE;
- obd->transflag |= OB_RENDER_DUPLI;
- }
- }
- else
- init_render_object(eval_ctx, re, obd, ob, dob, dob_extra->obmat, timeoffset);
-
- if (re->test_break(re->tbh)) break;
- }
-
- if (duplilist_apply_data) {
- duplilist_restore(duplilist, duplilist_apply_data);
- duplilist_free_apply_data(duplilist_apply_data);
- }
- free_object_duplilist(duplilist);
-
- if (allow_render_object(re, ob, nolamps, onlyselected, actob))
- init_render_object(eval_ctx, re, ob, NULL, NULL, NULL, timeoffset);
- }
- else if (allow_render_object(re, ob, nolamps, onlyselected, actob))
- init_render_object(eval_ctx, re, ob, NULL, NULL, NULL, timeoffset);
- }
-
- if (re->test_break(re->tbh)) break;
- }
-
- /* objects in groups with OB_RENDER_DUPLI set still need to be created,
- * since they may not be part of the scene */
- for (group= re->main->group.first; group; group=group->id.next)
- add_group_render_dupli_obs(eval_ctx, re, group, nolamps, onlyselected, actob, timeoffset, 0);
-
- if (!re->test_break(re->tbh))
- RE_makeRenderInstances(re);
-}
-
-void RE_Database_CameraOnly(Render *re, Main *bmain, Scene *scene, unsigned int lay, int use_camera_view)
-{
- Object *camera;
- float mat[4][4];
-
- re->main= bmain;
- re->scene= scene;
- re->lay= lay;
-
- /* scene needs to be set to get camera */
- camera= RE_GetCamera(re);
-
- /* if no camera, viewmat should have been set! */
- if (use_camera_view && camera) {
- /* called before but need to call again in case of lens animation from the
- * above call to BKE_scene_graph_update_for_newframe, fixes bug. [#22702].
- * following calls don't depend on 'RE_SetCamera' */
- RE_SetCamera(re, camera);
- RE_GetCameraModelMatrix(re, camera, mat);
- invert_m4(mat);
- RE_SetView(re, mat);
-
- /* force correct matrix for scaled cameras */
- DEG_id_tag_update_ex(re->main, &camera->id, OB_RECALC_OB);
- }
-}
-
-/* used to be 'rotate scene' */
-void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int lay, int use_camera_view)
-{
- Object *camera;
- float mat[4][4];
- float amb[3];
-
- re->main= bmain;
- re->scene= scene;
- re->lay= lay;
-
- if (re->r.scemode & R_VIEWPORT_PREVIEW)
- re->scene_color_manage = BKE_scene_check_color_management_enabled(scene);
-
- /* scene needs to be set to get camera */
- camera= RE_GetCamera(re);
-
- /* per second, per object, stats print this */
- re->i.infostr= "Preparing Scene data";
- re->i.cfra= scene->r.cfra;
- BLI_strncpy(re->i.scene_name, scene->id.name + 2, sizeof(re->i.scene_name));
- re->view_render = scene->view_render;
-
- /* XXX add test if dbase was filled already? */
-
- re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "render db arena");
- re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
- re->lights.first= re->lights.last= NULL;
- re->lampren.first= re->lampren.last= NULL;
-
- re->i.partsdone = false; /* signal now in use for previewrender */
-
- /* in localview, lamps are using normal layers, objects only local bits */
- if (re->lay & 0xFF000000)
- lay &= 0xFF000000;
-
- /* applies changes fully */
- if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0) {
- render_update_anim_renderdata(re, &re->scene->r, &re->scene->view_layers);
- }
-
- /* if no camera, viewmat should have been set! */
- if (use_camera_view && camera) {
- /* called before but need to call again in case of lens animation from the
- * above call to BKE_scene_graph_update_for_newframe, fixes bug. [#22702].
- * following calls don't depend on 'RE_SetCamera' */
- RE_SetCamera(re, camera);
- RE_GetCameraModelMatrix(re, camera, mat);
- invert_m4(mat);
- RE_SetView(re, mat);
-
- /* force correct matrix for scaled cameras */
- DEG_id_tag_update_ex(re->main, &camera->id, OB_RECALC_OB);
- }
-
- /* store for incremental render, viewmat rotates dbase */
- copy_m4_m4(re->viewmat_orig, re->viewmat);
-
- init_render_world(re); /* do first, because of ambient. also requires re->osa set correct */
- if (re->r.mode & R_RAYTRACE) {
- init_render_qmcsampler(re);
-
- if (re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT))
- if (re->wrld.ao_samp_method == WO_AOSAMP_CONSTANT)
- init_ao_sphere(re, &re->wrld);
- }
-
- /* still bad... doing all */
- init_render_textures(re);
- copy_v3_v3(amb, &re->wrld.ambr);
- init_render_materials(re->main, re->r.mode, amb, (re->r.scemode & R_BUTS_PREVIEW) == 0);
- set_node_shader_lamp_loop(shade_material_loop);
-
- /* MAKE RENDER DATA */
- EvaluationContext *eval_ctx = NULL;
- BLI_assert(eval_ctx);
- /* This will break things, and it should because honestly this function is deprecated and no one uses it.
- * maybe freestyle? But even so, this need to change. Even freestyle need to get data from depsgraph
- * so we can't create the database only once. */
- database_init_objects(eval_ctx, re, lay, 0, 0, NULL, 0);
-
- if (!re->test_break(re->tbh)) {
- set_material_lightgroups(re);
-
- /* for now some clumsy copying still */
- re->i.totvert= re->totvert;
- re->i.totface= re->totvlak;
- re->i.totstrand= re->totstrand;
- re->i.tothalo= re->tothalo;
- re->i.totlamp= re->totlamp;
- re->stats_draw(re->sdh, &re->i);
- }
-}
-
-void RE_Database_Preprocess(EvaluationContext *eval_ctx, Render *re)
-{
- if (!re->test_break(re->tbh)) {
- int tothalo;
-
- tothalo= re->tothalo;
- sort_halos(re, tothalo);
-
- init_camera_inside_volumes(re);
-
- re->i.infostr = IFACE_("Creating Shadowbuffers");
- re->stats_draw(re->sdh, &re->i);
-
- /* SHADOW BUFFER */
- threaded_makeshadowbufs(re);
-
- /* old code checked for internal render (aka not yafray) */
- {
- /* raytree */
- if (!re->test_break(re->tbh)) {
- if (re->r.mode & R_RAYTRACE) {
- makeraytree(re);
- }
- }
- /* ENVIRONMENT MAPS */
- if (!re->test_break(re->tbh))
- make_envmaps(re);
-
- /* point density texture */
- if (!re->test_break(re->tbh))
- make_pointdensities(eval_ctx, re);
- /* voxel data texture */
- if (!re->test_break(re->tbh))
- make_voxeldata(re);
- }
-
- if (!re->test_break(re->tbh))
- project_renderdata(re, projectverto, (re->r.mode & R_PANORAMA) != 0, 0, 1);
-
- /* Occlusion */
- if ((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && !re->test_break(re->tbh))
- if (re->wrld.ao_gather_method == WO_AOGATHER_APPROX)
- if (re->r.mode & R_SHADOW)
- make_occ_tree(re);
-
- /* SSS */
- if ((re->r.mode & R_SSS) && !re->test_break(re->tbh))
- make_sss_tree(re);
-
- if (!re->test_break(re->tbh))
- if (re->r.mode & R_RAYTRACE)
- volume_precache(re);
- }
-
- re->i.convertdone = true;
-
- if (re->test_break(re->tbh))
- RE_Database_Free(re);
-
- re->i.infostr = NULL;
- re->stats_draw(re->sdh, &re->i);
-}
-
-/* exported call to recalculate hoco for vertices, when winmat changed */
-void RE_DataBase_ApplyWindow(Render *re)
-{
- project_renderdata(re, projectverto, 0, 0, 0);
-}
-
-/* exported call to rotate render data again, when viewmat changed */
-void RE_DataBase_IncrementalView(Render *re, float viewmat[4][4], int restore)
-{
- float oldviewinv[4][4], tmat[4][4];
-
- invert_m4_m4(oldviewinv, re->viewmat_orig);
-
- /* we have to correct for the already rotated vertexcoords */
- mul_m4_m4m4(tmat, viewmat, oldviewinv);
-
- copy_m4_m4(re->viewmat, viewmat);
- invert_m4_m4(re->viewinv, re->viewmat);
-
- init_camera_inside_volumes(re);
-
- env_rotate_scene(re, tmat, !restore);
-
- /* SSS points distribution depends on view */
- if ((re->r.mode & R_SSS) && !re->test_break(re->tbh))
- make_sss_tree(re);
-}
-
-
-void RE_DataBase_GetView(Render *re, float mat[4][4])
-{
- copy_m4_m4(mat, re->viewmat);
-}
-
-/* ------------------------------------------------------------------------- */
-/* Speed Vectors */
-/* ------------------------------------------------------------------------- */
-
-static void database_fromscene_vectors(EvaluationContext *eval_ctx,
- Render *re,
- Scene *scene,
- unsigned int lay,
- int timeoffset)
-{
- Object *camera= RE_GetCamera(re);
- float mat[4][4];
-
- re->scene= scene;
- re->lay= lay;
-
- /* XXX add test if dbase was filled already? */
-
- re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "vector render db arena");
- re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
- re->i.totface=re->i.totvert=re->i.totstrand=re->i.totlamp=re->i.tothalo= 0;
- re->lights.first= re->lights.last= NULL;
-
- /* applies changes fully */
- scene->r.cfra += timeoffset;
- BKE_scene_graph_update_for_newframe(eval_ctx->depsgraph, re->main);
-
- /* if no camera, viewmat should have been set! */
- if (camera) {
- RE_GetCameraModelMatrix(re, camera, mat);
- normalize_m4(mat);
- invert_m4(mat);
- RE_SetView(re, mat);
- }
-
- /* MAKE RENDER DATA */
- database_init_objects(eval_ctx, re, lay, 0, 0, NULL, timeoffset);
-
- if (!re->test_break(re->tbh))
- project_renderdata(re, projectverto, (re->r.mode & R_PANORAMA) != 0, 0, 1);
-
- /* do this in end, particles for example need cfra */
- scene->r.cfra -= timeoffset;
-}
-
-/* choose to use static, to prevent giving too many args to this call */
-static void speedvector_project(Render *re, float zco[2], const float co[3], const float ho[4])
-{
- static float pixelphix=0.0f, pixelphiy=0.0f, zmulx=0.0f, zmuly=0.0f;
- static int pano= 0;
- float div;
-
- /* initialize */
- if (re) {
- pano= re->r.mode & R_PANORAMA;
-
- /* precalculate amount of radians 1 pixel rotates */
- if (pano) {
- /* size of 1 pixel mapped to viewplane coords */
- float psize;
-
- psize = BLI_rctf_size_x(&re->viewplane) / (float)re->winx;
- /* x angle of a pixel */
- pixelphix = atan(psize / re->clipsta);
-
- psize = BLI_rctf_size_y(&re->viewplane) / (float)re->winy;
- /* y angle of a pixel */
- pixelphiy = atan(psize / re->clipsta);
- }
- zmulx= re->winx/2;
- zmuly= re->winy/2;
-
- return;
- }
-
- /* now map hocos to screenspace, uses very primitive clip still */
- if (ho[3]<0.1f) div= 10.0f;
- else div= 1.0f/ho[3];
-
- /* use cylinder projection */
- if (pano) {
- float vec[3], ang;
- /* angle between (0, 0, -1) and (co) */
- copy_v3_v3(vec, co);
-
- ang= saacos(-vec[2]/sqrtf(vec[0]*vec[0] + vec[2]*vec[2]));
- if (vec[0]<0.0f) ang= -ang;
- zco[0]= ang/pixelphix + zmulx;
-
- ang= 0.5f*(float)M_PI - saacos(vec[1] / len_v3(vec));
- zco[1]= ang/pixelphiy + zmuly;
-
- }
- else {
- zco[0]= zmulx*(1.0f+ho[0]*div);
- zco[1]= zmuly*(1.0f+ho[1]*div);
- }
-}
-
-static void calculate_speedvector(const float vectors[2], int step, float winsq, float winroot, const float co[3], const float ho[4], float speed[4])
-{
- float zco[2], len;
-
- speedvector_project(NULL, zco, co, ho);
-
- zco[0]= vectors[0] - zco[0];
- zco[1]= vectors[1] - zco[1];
-
- /* enable nice masks for hardly moving stuff or float inaccuracy */
- if (zco[0]<0.1f && zco[0]>-0.1f && zco[1]<0.1f && zco[1]>-0.1f ) {
- zco[0]= 0.0f;
- zco[1]= 0.0f;
- }
-
- /* maximize speed for image width, otherwise it never looks good */
- len= zco[0]*zco[0] + zco[1]*zco[1];
- if (len > winsq) {
- len= winroot/sqrtf(len);
- zco[0]*= len;
- zco[1]*= len;
- }
-
- /* note; in main vecblur loop speedvec is negated again */
- if (step) {
- speed[2]= -zco[0];
- speed[3]= -zco[1];
- }
- else {
- speed[0]= zco[0];
- speed[1]= zco[1];
- }
-}
-
-static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen *obi, StrandSurface *mesh)
-{
- if (mesh->co && mesh->prevco && mesh->nextco) {
- float winsq= (float)re->winx*(float)re->winy; /* int's can wrap on large images */
- float winroot= sqrtf(winsq);
- float (*winspeed)[4];
- float ho[4], prevho[4], nextho[4], winmat[4][4], vec[2];
- int a;
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, re->winmat, obi->mat);
- else
- copy_m4_m4(winmat, re->winmat);
-
- winspeed= MEM_callocN(sizeof(float)*4*mesh->totvert, "StrandSurfWin");
-
- for (a=0; a<mesh->totvert; a++) {
- projectvert(mesh->co[a], winmat, ho);
-
- projectvert(mesh->prevco[a], winmat, prevho);
- speedvector_project(NULL, vec, mesh->prevco[a], prevho);
- calculate_speedvector(vec, 0, winsq, winroot, mesh->co[a], ho, winspeed[a]);
-
- projectvert(mesh->nextco[a], winmat, nextho);
- speedvector_project(NULL, vec, mesh->nextco[a], nextho);
- calculate_speedvector(vec, 1, winsq, winroot, mesh->co[a], ho, winspeed[a]);
- }
-
- return (float *)winspeed;
- }
-
- return NULL;
-}
-
-static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *vectors, int step)
-{
- ObjectRen *obr= obi->obr;
- VertRen *ver= NULL;
- StrandRen *strand= NULL;
- StrandBuffer *strandbuf;
- StrandSurface *mesh= NULL;
- float *speed, (*winspeed)[4]=NULL, ho[4], winmat[4][4];
- float *co1, *co2, *co3, *co4, w[4];
- float winsq = (float)re->winx * (float)re->winy, winroot = sqrtf(winsq); /* int's can wrap on large images */
- int a, *face, *index;
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, re->winmat, obi->mat);
- else
- copy_m4_m4(winmat, re->winmat);
-
- if (obr->vertnodes) {
- for (a=0; a<obr->totvert; a++, vectors+=2) {
- if ((a & 255)==0) ver= obr->vertnodes[a>>8].vert;
- else ver++;
-
- speed= RE_vertren_get_winspeed(obi, ver, 1);
- projectvert(ver->co, winmat, ho);
- calculate_speedvector(vectors, step, winsq, winroot, ver->co, ho, speed);
- }
- }
-
- if (obr->strandnodes) {
- strandbuf= obr->strandbuf;
- mesh= (strandbuf)? strandbuf->surface: NULL;
-
- /* compute speed vectors at surface vertices */
- if (mesh)
- winspeed= (float(*)[4])calculate_strandsurface_speedvectors(re, obi, mesh);
-
- if (winspeed) {
- for (a=0; a<obr->totstrand; a++, vectors+=2) {
- if ((a & 255)==0) strand= obr->strandnodes[a>>8].strand;
- else strand++;
-
- index= RE_strandren_get_face(obr, strand, 0);
- if (index && *index < mesh->totface) {
- speed= RE_strandren_get_winspeed(obi, strand, 1);
-
- /* interpolate speed vectors from strand surface */
- face= mesh->face[*index];
-
- co1 = mesh->co[face[0]];
- co2 = mesh->co[face[1]];
- co3 = mesh->co[face[2]];
-
- if (face[3]) {
- co4 = mesh->co[face[3]];
- interp_weights_quad_v3(w, co1, co2, co3, co4, strand->vert->co);
- }
- else {
- interp_weights_tri_v3(w, co1, co2, co3, strand->vert->co);
- }
-
- zero_v4(speed);
- madd_v4_v4fl(speed, winspeed[face[0]], w[0]);
- madd_v4_v4fl(speed, winspeed[face[1]], w[1]);
- madd_v4_v4fl(speed, winspeed[face[2]], w[2]);
- if (face[3])
- madd_v4_v4fl(speed, winspeed[face[3]], w[3]);
- }
- }
-
- MEM_freeN(winspeed);
- }
- }
-}
-
-static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float *vectors, int step)
-{
- ObjectRen *obr= obi->obr;
- Object *fsob= obr->ob;
- VertRen *ver= NULL;
- float *speed, div, zco[2], avgvel[4] = {0.0, 0.0, 0.0, 0.0};
- float zmulx= re->winx/2, zmuly= re->winy/2, len;
- float winsq = (float)re->winx * (float)re->winy, winroot= sqrtf(winsq); /* int's can wrap on large images */
- int a, j;
- float hoco[4], ho[4], fsvec[4], camco[4];
- float mat[4][4], winmat[4][4];
- float imat[4][4];
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(fsob, eModifierType_Fluidsim);
- FluidsimSettings *fss;
- FluidVertexVelocity *velarray = NULL;
-
- /* only one step needed */
- if (step) return 1;
-
- if (fluidmd)
- fss = fluidmd->fss;
- else
- return 0;
-
- copy_m4_m4(mat, re->viewmat);
- invert_m4_m4(imat, mat);
-
- /* set first vertex OK */
- if (!fss->meshVelocities) return 0;
-
- if ( obr->totvert != fss->totvert) {
- //fprintf(stderr, "load_fluidsimspeedvectors - modified fluidsim mesh, not using speed vectors (%d,%d)...\n", obr->totvert, fsob->fluidsimSettings->meshSurface->totvert); // DEBUG
- return 0;
- }
-
- velarray = fss->meshVelocities;
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, re->winmat, obi->mat);
- else
- copy_m4_m4(winmat, re->winmat);
-
- /* (bad) HACK calculate average velocity */
- /* better solution would be fixing getVelocityAt() in intern/elbeem/intern/solver_util.cpp
- * so that also small drops/little water volumes return a velocity != 0.
- * But I had no luck in fixing that function - DG */
- for (a=0; a<obr->totvert; a++) {
- for (j=0;j<3;j++) avgvel[j] += velarray[a].vel[j];
-
- }
- for (j=0;j<3;j++) avgvel[j] /= (float)(obr->totvert);
-
-
- for (a=0; a<obr->totvert; a++, vectors+=2) {
- if ((a & 255)==0)
- ver= obr->vertnodes[a>>8].vert;
- else
- ver++;
-
- /* get fluid velocity */
- fsvec[3] = 0.0f;
- //fsvec[0] = fsvec[1] = fsvec[2] = fsvec[3] = 0.0; fsvec[2] = 2.0f; // NT fixed test
- for (j=0;j<3;j++) fsvec[j] = velarray[a].vel[j];
-
- /* (bad) HACK insert average velocity if none is there (see previous comment) */
- if ((fsvec[0] == 0.0f) && (fsvec[1] == 0.0f) && (fsvec[2] == 0.0f)) {
- fsvec[0] = avgvel[0];
- fsvec[1] = avgvel[1];
- fsvec[2] = avgvel[2];
- }
-
- /* transform (=rotate) to cam space */
- camco[0] = dot_v3v3(imat[0], fsvec);
- camco[1] = dot_v3v3(imat[1], fsvec);
- camco[2] = dot_v3v3(imat[2], fsvec);
-
- /* get homogeneous coordinates */
- projectvert(camco, winmat, hoco);
- projectvert(ver->co, winmat, ho);
-
- /* now map hocos to screenspace, uses very primitive clip still */
- /* use ho[3] of original vertex, xy component of vel. direction */
- if (ho[3]<0.1f) div= 10.0f;
- else div= 1.0f/ho[3];
- zco[0]= zmulx*hoco[0]*div;
- zco[1]= zmuly*hoco[1]*div;
-
- /* maximize speed as usual */
- len= zco[0]*zco[0] + zco[1]*zco[1];
- if (len > winsq) {
- len= winroot/sqrtf(len);
- zco[0]*= len; zco[1]*= len;
- }
-
- speed= RE_vertren_get_winspeed(obi, ver, 1);
- /* set both to the same value */
- speed[0]= speed[2]= zco[0];
- speed[1]= speed[3]= zco[1];
- //if (a < 20) fprintf(stderr,"speed %d %f,%f | camco %f,%f,%f | hoco %f,%f,%f,%f\n", a, speed[0], speed[1], camco[0],camco[1], camco[2], hoco[0],hoco[1], hoco[2],hoco[3]); // NT DEBUG
- }
-
- return 1;
-}
-
-/* makes copy per object of all vectors */
-/* result should be that we can free entire database */
-static void copy_dbase_object_vectors(Render *re, ListBase *lb)
-{
- ObjectInstanceRen *obi, *obilb;
- ObjectRen *obr;
- VertRen *ver= NULL;
- float *vec, ho[4], winmat[4][4];
- int a, totvector;
-
- for (obi= re->instancetable.first; obi; obi= obi->next) {
- obr= obi->obr;
-
- obilb= MEM_mallocN(sizeof(ObjectInstanceRen), "ObInstanceVector");
- memcpy(obilb, obi, sizeof(ObjectInstanceRen));
- BLI_addtail(lb, obilb);
-
- obilb->totvector= totvector= obr->totvert;
-
- if (totvector > 0) {
- vec= obilb->vectors= MEM_mallocN(2*sizeof(float)*totvector, "vector array");
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, re->winmat, obi->mat);
- else
- copy_m4_m4(winmat, re->winmat);
-
- for (a=0; a<obr->totvert; a++, vec+=2) {
- if ((a & 255)==0) ver= obr->vertnodes[a>>8].vert;
- else ver++;
-
- projectvert(ver->co, winmat, ho);
- speedvector_project(NULL, vec, ver->co, ho);
- }
- }
- }
-}
-
-static void free_dbase_object_vectors(ListBase *lb)
-{
- ObjectInstanceRen *obi;
-
- for (obi= lb->first; obi; obi= obi->next)
- if (obi->vectors)
- MEM_freeN(obi->vectors);
- BLI_freelistN(lb);
-}
-
-void RE_Database_FromScene_Vectors(EvaluationContext *eval_ctx, Render *re, Main *bmain, Scene *sce, unsigned int lay)
-{
- ObjectInstanceRen *obi, *oldobi;
- StrandSurface *mesh;
- ListBase *table;
- ListBase oldtable= {NULL, NULL}, newtable= {NULL, NULL};
- ListBase strandsurface;
- int step;
-
- re->i.infostr = IFACE_("Calculating previous frame vectors");
- re->r.mode |= R_SPEED;
-
- speedvector_project(re, NULL, NULL, NULL); /* initializes projection code */
-
- /* creates entire dbase */
- database_fromscene_vectors(eval_ctx, re, sce, lay, -1);
-
- /* copy away vertex info */
- copy_dbase_object_vectors(re, &oldtable);
-
- /* free dbase and make the future one */
- strandsurface= re->strandsurface;
- memset(&re->strandsurface, 0, sizeof(ListBase));
- re->i.convertdone = true;
- RE_Database_Free(re);
- re->strandsurface= strandsurface;
-
- if (!re->test_break(re->tbh)) {
- /* creates entire dbase */
- re->i.infostr = IFACE_("Calculating next frame vectors");
-
- database_fromscene_vectors(eval_ctx, re, sce, lay, +1);
- }
- /* copy away vertex info */
- copy_dbase_object_vectors(re, &newtable);
-
- /* free dbase and make the real one */
- strandsurface= re->strandsurface;
- memset(&re->strandsurface, 0, sizeof(ListBase));
- re->i.convertdone = true;
- RE_Database_Free(re);
- re->strandsurface= strandsurface;
-
- if (!re->test_break(re->tbh)) {
- RE_Database_FromScene(re, bmain, sce, lay, 1);
- RE_Database_Preprocess(eval_ctx, re);
- }
-
- if (!re->test_break(re->tbh)) {
- int vectorlay= get_vector_viewlayers(re->scene);
-
- for (step= 0; step<2; step++) {
-
- if (step)
- table= &newtable;
- else
- table= &oldtable;
-
- oldobi= table->first;
- for (obi= re->instancetable.first; obi && oldobi; obi= obi->next) {
- int ok= 1;
- FluidsimModifierData *fluidmd;
-
- if (!(obi->lay & vectorlay))
- continue;
-
- obi->totvector= obi->obr->totvert;
-
- /* find matching object in old table */
- if (oldobi->ob!=obi->ob || oldobi->par!=obi->par || oldobi->index!=obi->index || oldobi->psysindex!=obi->psysindex) {
- ok= 0;
- for (oldobi= table->first; oldobi; oldobi= oldobi->next)
- if (oldobi->ob==obi->ob && oldobi->par==obi->par && oldobi->index==obi->index && oldobi->psysindex==obi->psysindex)
- break;
- if (oldobi==NULL)
- oldobi= table->first;
- else
- ok= 1;
- }
- if (ok==0) {
- printf("speed table: missing object %s\n", obi->ob->id.name + 2);
- continue;
- }
-
- /* NT check for fluidsim special treatment */
- fluidmd = (FluidsimModifierData *)modifiers_findByType(obi->ob, eModifierType_Fluidsim);
- if (fluidmd && fluidmd->fss && (fluidmd->fss->type & OB_FLUIDSIM_DOMAIN)) {
- /* use preloaded per vertex simulation data, only does calculation for step=1 */
- /* NOTE/FIXME - velocities and meshes loaded unnecessarily often during the database_fromscene_vectors calls... */
- load_fluidsimspeedvectors(re, obi, oldobi->vectors, step);
- }
- else {
- /* check if both have same amounts of vertices */
- if (obi->totvector==oldobi->totvector)
- calculate_speedvectors(re, obi, oldobi->vectors, step);
- else
- printf("Warning: object %s has different amount of vertices or strands on other frame\n", obi->ob->id.name + 2);
- } /* not fluidsim */
-
- oldobi= oldobi->next;
- }
- }
- }
-
- free_dbase_object_vectors(&oldtable);
- free_dbase_object_vectors(&newtable);
-
- for (mesh=re->strandsurface.first; mesh; mesh=mesh->next) {
- if (mesh->prevco) {
- MEM_freeN(mesh->prevco);
- mesh->prevco= NULL;
- }
- if (mesh->nextco) {
- MEM_freeN(mesh->nextco);
- mesh->nextco= NULL;
- }
- }
-
- re->i.infostr = NULL;
- re->stats_draw(re->sdh, &re->i);
-}
-
-
-/* ------------------------------------------------------------------------- */
-/* Baking */
-/* ------------------------------------------------------------------------- */
-
-/* setup for shaded view or bake, so only lamps and materials are initialized */
-/* type:
- * RE_BAKE_LIGHT: for shaded view, only add lamps
- * RE_BAKE_ALL: for baking, all lamps and objects
- * RE_BAKE_NORMALS:for baking, no lamps and only selected objects
- * RE_BAKE_AO: for baking, no lamps, but all objects
- * RE_BAKE_TEXTURE:for baking, no lamps, only selected objects
- * RE_BAKE_VERTEX_COLORS:for baking, no lamps, only selected objects
- * RE_BAKE_DISPLACEMENT:for baking, no lamps, only selected objects
- * RE_BAKE_DERIVATIVE:for baking, no lamps, only selected objects
- * RE_BAKE_SHADOW: for baking, only shadows, but all objects
- */
-void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, ViewLayer *view_layer,
- unsigned int lay, const int type, Object *actob)
-{
- Object *camera;
- float mat[4][4];
- float amb[3];
- const short onlyselected= !ELEM(type, RE_BAKE_LIGHT, RE_BAKE_ALL, RE_BAKE_SHADOW, RE_BAKE_AO, RE_BAKE_VERTEX_COLORS);
- const short nolamps= ELEM(type, RE_BAKE_NORMALS, RE_BAKE_TEXTURE, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE, RE_BAKE_VERTEX_COLORS);
-
- re->main= bmain;
- re->scene= scene;
- re->lay= lay;
-
- /* renderdata setup and exceptions */
- render_copy_renderdata(&re->r, &scene->r);
- render_copy_viewrender(&re->view_render, &scene->view_render);
-
- RE_init_threadcount(re);
-
- EvaluationContext *eval_ctx = DEG_evaluation_context_new(DAG_EVAL_RENDER);
- Depsgraph *depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
- DEG_evaluation_context_init_from_view_layer_for_render(eval_ctx, depsgraph, scene, view_layer);
- DEG_graph_build_from_view_layer(depsgraph, bmain, scene, view_layer);
- BKE_scene_graph_update_tagged(depsgraph, bmain);
-
- re->flag |= R_BAKING;
- re->excludeob= actob;
- if (actob)
- re->flag |= R_BAKE_TRACE;
-
- if (type==RE_BAKE_NORMALS && re->r.bake_normal_space==R_BAKE_SPACE_TANGENT)
- re->flag |= R_NEED_TANGENT;
-
- if (type==RE_BAKE_VERTEX_COLORS)
- re->flag |= R_NEED_VCOL;
-
- if (!actob && ELEM(type, RE_BAKE_LIGHT, RE_BAKE_NORMALS, RE_BAKE_TEXTURE, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE, RE_BAKE_VERTEX_COLORS)) {
- re->r.mode &= ~R_SHADOW;
- re->r.mode &= ~R_RAYTRACE;
- }
-
- if (!actob && (type==RE_BAKE_SHADOW)) {
- re->r.mode |= R_SHADOW;
- }
-
- /* setup render stuff */
- re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "bake db arena");
-
- re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
- re->lights.first= re->lights.last= NULL;
- re->lampren.first= re->lampren.last= NULL;
-
- /* in localview, lamps are using normal layers, objects only local bits */
- if (re->lay & 0xFF000000)
- lay &= 0xFF000000;
-
- camera= RE_GetCamera(re);
-
- /* if no camera, set unit */
- if (camera) {
- normalize_m4_m4(mat, camera->obmat);
- invert_m4(mat);
- RE_SetView(re, mat);
- }
- else {
- unit_m4(mat);
- RE_SetView(re, mat);
- }
- copy_m3_m4(re->imat, re->viewinv);
-
- /* TODO: deep shadow maps + baking + strands */
- /* strands use the window matrix and view size, there is to correct
- * window matrix but at least avoids malloc and crash loop [#27807] */
- unit_m4(re->winmat);
- re->winx= re->winy= 256;
- /* done setting dummy values */
-
- init_render_world(re); /* do first, because of ambient. also requires re->osa set correct */
- if (re->r.mode & R_RAYTRACE) {
- init_render_qmcsampler(re);
-
- if (re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT))
- if (re->wrld.ao_samp_method == WO_AOSAMP_CONSTANT)
- init_ao_sphere(re, &re->wrld);
- }
-
- /* still bad... doing all */
- init_render_textures(re);
-
- copy_v3_v3(amb, &re->wrld.ambr);
- init_render_materials(re->main, re->r.mode, amb, true);
-
- set_node_shader_lamp_loop(shade_material_loop);
-
- /* MAKE RENDER DATA */
- database_init_objects(eval_ctx, re, lay, nolamps, onlyselected, actob, 0);
-
- set_material_lightgroups(re);
-
- /* SHADOW BUFFER */
- if (type!=RE_BAKE_LIGHT)
- if (re->r.mode & R_SHADOW)
- threaded_makeshadowbufs(re);
-
- /* raytree */
- if (!re->test_break(re->tbh))
- if (re->r.mode & R_RAYTRACE)
- makeraytree(re);
-
- /* point density texture */
- if (!re->test_break(re->tbh))
- make_pointdensities(eval_ctx, re);
-
- /* voxel data texture */
- if (!re->test_break(re->tbh))
- make_voxeldata(re);
-
- /* occlusion */
- if ((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && !re->test_break(re->tbh))
- if (re->wrld.ao_gather_method == WO_AOGATHER_APPROX)
- if (re->r.mode & R_SHADOW)
- make_occ_tree(re);
-
- re->i.convertdone = true;
-}
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c
deleted file mode 100644
index 19635dd26f2..00000000000
--- a/source/blender/render/intern/source/envmap.c
+++ /dev/null
@@ -1,819 +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.
- *
- * Contributors: 2004/2005/2006 Blender Foundation, full recode
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/envmap.c
- * \ingroup render
- */
-
-#include <math.h>
-#include <string.h>
-
-/* external modules: */
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_threads.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "IMB_imbuf_types.h"
-#include "IMB_imbuf.h" /* for rectcpy */
-
-#include "DNA_group_types.h"
-#include "DNA_image_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_texture_types.h"
-
-#include "BKE_main.h"
-#include "BKE_image.h" /* BKE_imbuf_write */
-#include "BKE_layer.h"
-#include "BKE_texture.h"
-#include "BKE_scene.h"
-
-/* this module */
-#include "render_types.h"
-#include "envmap.h"
-#include "renderdatabase.h"
-#include "renderpipeline.h"
-#include "texture.h"
-#include "zbuf.h"
-#include "render_result.h"
-
-/* ------------------------------------------------------------------------- */
-
-static void envmap_split_ima(EnvMap *env, ImBuf *ibuf)
-{
- int dx, part;
-
- /* after lock we test cube[1], if set the other thread has done it fine */
- BLI_thread_lock(LOCK_IMAGE);
- if (env->cube[1] == NULL) {
-
- BKE_texture_envmap_free_data(env);
-
- dx = ibuf->y;
- dx /= 2;
- if (3 * dx == ibuf->x) {
- env->type = ENV_CUBE;
- env->ok = ENV_OSA;
- }
- else if (ibuf->x == ibuf->y) {
- env->type = ENV_PLANE;
- env->ok = ENV_OSA;
- }
- else {
- printf("Incorrect envmap size\n");
- env->ok = 0;
- env->ima->ok = 0;
- }
-
- if (env->ok) {
- if (env->type == ENV_CUBE) {
- for (part = 0; part < 6; part++) {
- env->cube[part] = IMB_allocImBuf(dx, dx, 24, IB_rect | IB_rectfloat);
- }
- IMB_float_from_rect(ibuf);
-
- IMB_rectcpy(env->cube[0], ibuf,
- 0, 0, 0, 0, dx, dx);
- IMB_rectcpy(env->cube[1], ibuf,
- 0, 0, dx, 0, dx, dx);
- IMB_rectcpy(env->cube[2], ibuf,
- 0, 0, 2 * dx, 0, dx, dx);
- IMB_rectcpy(env->cube[3], ibuf,
- 0, 0, 0, dx, dx, dx);
- IMB_rectcpy(env->cube[4], ibuf,
- 0, 0, dx, dx, dx, dx);
- IMB_rectcpy(env->cube[5], ibuf,
- 0, 0, 2 * dx, dx, dx, dx);
-
- }
- else { /* ENV_PLANE */
- env->cube[1] = IMB_dupImBuf(ibuf);
- IMB_float_from_rect(env->cube[1]);
- }
- }
- }
- BLI_thread_unlock(LOCK_IMAGE);
-}
-
-/* ------------------------------------------------------------------------- */
-/* ****************** RENDER ********************** */
-
-/* copy current render */
-static Render *envmap_render_copy(Render *re, EnvMap *env)
-{
- Render *envre;
- float viewscale;
- int cuberes;
-
- envre = RE_NewRender("Envmap");
-
- env->lastsize = re->r.size;
- cuberes = (env->cuberes * re->r.size) / 100;
- cuberes &= 0xFFFC;
-
- /* this flag has R_ZTRA in it for example */
- envre->flag = re->flag;
-
- /* set up renderdata */
- envre->r.mode &= ~(R_BORDER | R_PANORAMA | R_ORTHO | R_MBLUR);
- BLI_freelistN(&envre->view_layers);
- BLI_freelistN(&envre->r.views);
- envre->r.filtertype = 0;
- envre->r.tilex = envre->r.xsch / 2;
- envre->r.tiley = envre->r.ysch / 2;
- envre->r.size = 100;
- envre->r.yasp = envre->r.xasp = 1;
-
- RE_InitState(envre, NULL, &envre->r, &re->view_layers, re->active_view_layer, &envre->view_render, NULL, cuberes, cuberes, NULL);
- envre->main = re->main;
- envre->scene = re->scene; /* unsure about this... */
- envre->scene_color_manage = re->scene_color_manage;
- envre->lay = re->lay;
-
- /* view stuff in env render */
- viewscale = (env->type == ENV_PLANE) ? env->viewscale : 1.0f;
- RE_SetEnvmapCamera(envre, env->object, viewscale, env->clipsta, env->clipend);
- copy_m4_m4(envre->viewmat_orig, re->viewmat_orig);
-
- /* callbacks */
- envre->display_update = re->display_update;
- envre->duh = re->duh;
- envre->test_break = re->test_break;
- envre->tbh = re->tbh;
- envre->current_scene_update = re->current_scene_update;
- envre->suh = re->suh;
-
- /* and for the evil stuff; copy the database... */
- envre->totvlak = re->totvlak;
- envre->totvert = re->totvert;
- envre->tothalo = re->tothalo;
- envre->totstrand = re->totstrand;
- envre->totlamp = re->totlamp;
- envre->sortedhalos = re->sortedhalos;
- envre->lights = re->lights;
- envre->objecttable = re->objecttable;
- envre->customdata_names = re->customdata_names;
- envre->raytree = re->raytree;
- envre->totinstance = re->totinstance;
- envre->instancetable = re->instancetable;
- envre->objectinstance = re->objectinstance;
- envre->qmcsamplers = re->qmcsamplers;
-
- return envre;
-}
-
-static void envmap_free_render_copy(Render *envre)
-{
-
- envre->totvlak = 0;
- envre->totvert = 0;
- envre->tothalo = 0;
- envre->totstrand = 0;
- envre->totlamp = 0;
- envre->totinstance = 0;
- envre->sortedhalos = NULL;
- BLI_listbase_clear(&envre->lights);
- BLI_listbase_clear(&envre->objecttable);
- BLI_listbase_clear(&envre->customdata_names);
- envre->raytree = NULL;
- BLI_listbase_clear(&envre->instancetable);
- envre->objectinstance = NULL;
- envre->qmcsamplers = NULL;
-
- RE_FreeRender(envre);
-}
-
-/* ------------------------------------------------------------------------- */
-
-static void envmap_transmatrix(float mat[4][4], int part)
-{
- float tmat[4][4], eul[3], rotmat[4][4];
-
- eul[0] = eul[1] = eul[2] = 0.0;
-
- if (part == 0) { /* neg z */
- /* pass */
- }
- else if (part == 1) { /* pos z */
- eul[0] = M_PI;
- }
- else if (part == 2) { /* pos y */
- eul[0] = M_PI / 2.0;
- }
- else if (part == 3) { /* neg x */
- eul[0] = M_PI / 2.0;
- eul[2] = M_PI / 2.0;
- }
- else if (part == 4) { /* neg y */
- eul[0] = M_PI / 2.0;
- eul[2] = M_PI;
- }
- else { /* pos x */
- eul[0] = M_PI / 2.0;
- eul[2] = -M_PI / 2.0;
- }
-
- copy_m4_m4(tmat, mat);
- eul_to_mat4(rotmat, eul);
- mul_m4_m4m4(mat, tmat, rotmat);
-}
-/* ------------------------------------------------------------------------- */
-
-static void env_set_imats(Render *re)
-{
- float mat[4][4];
-
- FOREACH_SCENE_OBJECT_BEGIN(re->scene, ob)
- {
- mul_m4_m4m4(mat, re->viewmat, ob->obmat);
- invert_m4_m4(ob->imat, mat);
- }
- FOREACH_SCENE_OBJECT_END;
-}
-
-/* ------------------------------------------------------------------------- */
-
-void env_rotate_scene(Render *re, float mat[4][4], int do_rotate)
-{
- ObjectRen *obr;
- ObjectInstanceRen *obi;
- LampRen *lar = NULL;
- HaloRen *har = NULL;
- float imat[3][3], mat_inverse[4][4], smat[4][4], tmat[4][4], cmat[3][3], tmpmat[4][4];
- int a;
-
- if (do_rotate == 0) {
- invert_m4_m4(tmat, mat);
- copy_m3_m4(imat, tmat);
-
- copy_m4_m4(mat_inverse, mat);
- }
- else {
- copy_m4_m4(tmat, mat);
- copy_m3_m4(imat, mat);
-
- invert_m4_m4(mat_inverse, tmat);
- }
-
- for (obi = re->instancetable.first; obi; obi = obi->next) {
- /* append or set matrix depending on dupli */
- if (obi->flag & R_DUPLI_TRANSFORMED) {
- copy_m4_m4(tmpmat, obi->mat);
- mul_m4_m4m4(obi->mat, tmat, tmpmat);
- }
- else if (do_rotate == 1)
- copy_m4_m4(obi->mat, tmat);
- else
- unit_m4(obi->mat);
-
- copy_m3_m4(cmat, obi->mat);
- invert_m3_m3(obi->nmat, cmat);
- transpose_m3(obi->nmat);
-
- /* indicate the renderer has to use transform matrices */
- if (do_rotate == 0)
- obi->flag &= ~R_ENV_TRANSFORMED;
- else {
- obi->flag |= R_ENV_TRANSFORMED;
- copy_m4_m4(obi->imat, mat_inverse);
- }
- }
-
-
- for (obr = re->objecttable.first; obr; obr = obr->next) {
- for (a = 0; a < obr->tothalo; a++) {
- if ((a & 255) == 0) har = obr->bloha[a >> 8];
- else har++;
-
- mul_m4_v3(tmat, har->co);
- }
-
- /* imat_ren is needed for correct texture coordinates */
- mul_m4_m4m4(obr->ob->imat_ren, re->viewmat, obr->ob->obmat);
- invert_m4(obr->ob->imat_ren);
- }
-
- for (lar = re->lampren.first; lar; lar = lar->next) {
- float lamp_imat[4][4];
-
- /* copy from add_render_lamp */
- if (do_rotate == 1)
- mul_m4_m4m4(tmpmat, re->viewmat, lar->lampmat);
- else
- mul_m4_m4m4(tmpmat, re->viewmat_orig, lar->lampmat);
-
- invert_m4_m4(lamp_imat, tmpmat);
- copy_m3_m4(lar->mat, tmpmat);
- copy_m3_m4(lar->imat, lamp_imat);
-
- lar->vec[0]= -tmpmat[2][0];
- lar->vec[1]= -tmpmat[2][1];
- lar->vec[2]= -tmpmat[2][2];
- normalize_v3(lar->vec);
- lar->co[0]= tmpmat[3][0];
- lar->co[1]= tmpmat[3][1];
- lar->co[2]= tmpmat[3][2];
-
- if (lar->type == LA_AREA) {
- area_lamp_vectors(lar);
- }
- else if (lar->type == LA_SPOT) {
- normalize_v3(lar->imat[0]);
- normalize_v3(lar->imat[1]);
- normalize_v3(lar->imat[2]);
-
- lar->sh_invcampos[0] = -lar->co[0];
- lar->sh_invcampos[1] = -lar->co[1];
- lar->sh_invcampos[2] = -lar->co[2];
- mul_m3_v3(lar->imat, lar->sh_invcampos);
- lar->sh_invcampos[2] *= lar->sh_zfac;
-
- if (lar->shb) {
- if (do_rotate == 1) {
- mul_m4_m4m4(smat, lar->shb->viewmat, mat_inverse);
- mul_m4_m4m4(lar->shb->persmat, lar->shb->winmat, smat);
- }
- else mul_m4_m4m4(lar->shb->persmat, lar->shb->winmat, lar->shb->viewmat);
- }
- }
- }
-
- if (do_rotate) {
- init_render_world(re);
- env_set_imats(re);
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-static void env_layerflags(Render *re, unsigned int notlay)
-{
- ObjectRen *obr;
- VlakRen *vlr = NULL;
- int a;
-
- /* invert notlay, so if face is in multiple layers it will still be visible,
- * unless all 'notlay' bits match the face bits.
- * face: 0110
- * not: 0100
- * ~not: 1011
- * now (face & ~not) is true
- */
-
- notlay = ~notlay;
-
- for (obr = re->objecttable.first; obr; obr = obr->next) {
- if ((obr->lay & notlay) == 0) {
- for (a = 0; a < obr->totvlak; a++) {
- if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak;
- else vlr++;
-
- vlr->flag |= R_HIDDEN;
- }
- }
- }
-}
-
-static void env_hideobject(Render *re, Object *ob)
-{
- ObjectRen *obr;
- VlakRen *vlr = NULL;
- int a;
-
- for (obr = re->objecttable.first; obr; obr = obr->next) {
- for (a = 0; a < obr->totvlak; a++) {
- if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak;
- else vlr++;
-
- if (obr->ob == ob)
- vlr->flag |= R_HIDDEN;
- }
- }
-}
-
-static void env_showobjects(Render *re)
-{
- ObjectRen *obr;
- VlakRen *vlr = NULL;
- int a;
-
- for (obr = re->objecttable.first; obr; obr = obr->next) {
- for (a = 0; a < obr->totvlak; a++) {
- if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak;
- else vlr++;
-
- vlr->flag &= ~R_HIDDEN;
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-static void render_envmap(Render *re, EnvMap *env)
-{
- /* only the cubemap and planar map is implemented */
- Render *envre;
- ImBuf *ibuf;
- float orthmat[4][4];
- float oldviewinv[4][4], mat[4][4], tmat[4][4];
- short part;
-
- /* need a recalc: ortho-render has no correct viewinv */
- invert_m4_m4(oldviewinv, re->viewmat);
-
- envre = envmap_render_copy(re, env);
-
- /* precalc orthmat for object */
- copy_m4_m4(orthmat, env->object->obmat);
- normalize_m4(orthmat);
-
- /* need imat later for texture imat */
- mul_m4_m4m4(mat, re->viewmat, orthmat);
- invert_m4_m4(tmat, mat);
- copy_m3_m4(env->obimat, tmat);
-
- for (part = 0; part < 6; part++) {
- if (env->type == ENV_PLANE && part != 1)
- continue;
-
- re->display_clear(re->dch, envre->result);
-
- copy_m4_m4(tmat, orthmat);
- envmap_transmatrix(tmat, part);
- invert_m4_m4(mat, tmat);
- /* mat now is the camera 'viewmat' */
-
- copy_m4_m4(envre->viewmat, mat);
- copy_m4_m4(envre->viewinv, tmat);
-
- /* we have to correct for the already rotated vertexcoords */
- mul_m4_m4m4(tmat, envre->viewmat, oldviewinv);
- invert_m4_m4(env->imat, tmat);
-
- env_rotate_scene(envre, tmat, 1);
- project_renderdata(envre, projectverto, 0, 0, 1);
- env_layerflags(envre, env->notlay);
- env_hideobject(envre, env->object);
-
- if (re->test_break(re->tbh) == 0) {
- RE_TileProcessor(envre);
- }
-
- /* rotate back */
- env_showobjects(envre);
- env_rotate_scene(envre, tmat, 0);
-
- if (re->test_break(re->tbh) == 0) {
- int y;
- float *alpha;
- float *rect;
-
- if (envre->result->do_exr_tile) {
- BLI_rw_mutex_lock(&envre->resultmutex, THREAD_LOCK_WRITE);
- render_result_exr_file_end(envre);
- BLI_rw_mutex_unlock(&envre->resultmutex);
- }
-
- RenderLayer *rl = envre->result->layers.first;
-
- /* envmap is rendered independently of multiview */
- rect = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, "");
- ibuf = IMB_allocImBuf(envre->rectx, envre->recty, 24, IB_rect | IB_rectfloat);
- memcpy(ibuf->rect_float, rect, ibuf->channels * ibuf->x * ibuf->y * sizeof(float));
-
- /* envmap renders without alpha */
- alpha = ibuf->rect_float + 3;
- for (y = ibuf->x * ibuf->y - 1; y >= 0; y--, alpha += 4)
- *alpha = 1.0;
-
- env->cube[part] = ibuf;
- }
-
- if (re->test_break(re->tbh)) break;
-
- }
-
- if (re->test_break(re->tbh)) BKE_texture_envmap_free_data(env);
- else {
- if (envre->r.mode & R_OSA) env->ok = ENV_OSA;
- else env->ok = ENV_NORMAL;
- env->lastframe = re->scene->r.cfra;
- }
-
- /* restore */
- envmap_free_render_copy(envre);
- env_set_imats(re);
-
-}
-
-/* ------------------------------------------------------------------------- */
-
-void make_envmaps(Render *re)
-{
- Tex *tex;
- bool do_init = false;
- int depth = 0, trace;
-
- if (!(re->r.mode & R_ENVMAP)) return;
-
- /* we don't raytrace, disabling the flag will cause ray_transp render solid */
- trace = (re->r.mode & R_RAYTRACE);
- re->r.mode &= ~R_RAYTRACE;
-
- re->i.infostr = IFACE_("Creating Environment maps");
- re->stats_draw(re->sdh, &re->i);
-
- /* 5 = hardcoded max recursion level */
- while (depth < 5) {
- tex = re->main->tex.first;
- while (tex) {
- if (tex->id.us && tex->type == TEX_ENVMAP) {
- if (tex->env && tex->env->object) {
- EnvMap *env = tex->env;
-
- if (env->object->lay & re->lay) {
- if (env->stype == ENV_LOAD) {
- float orthmat[4][4], mat[4][4], tmat[4][4];
-
- /* precalc orthmat for object */
- copy_m4_m4(orthmat, env->object->obmat);
- normalize_m4(orthmat);
-
- /* need imat later for texture imat */
- mul_m4_m4m4(mat, re->viewmat, orthmat);
- invert_m4_m4(tmat, mat);
- copy_m3_m4(env->obimat, tmat);
- }
- else {
-
- /* decide if to render an envmap (again) */
- if (env->depth >= depth) {
-
- /* set 'recalc' to make sure it does an entire loop of recalcs */
-
- if (env->ok) {
- /* free when OSA, and old one isn't OSA */
- if ((re->r.mode & R_OSA) && env->ok == ENV_NORMAL)
- BKE_texture_envmap_free_data(env);
- /* free when size larger */
- else if (env->lastsize < re->r.size)
- BKE_texture_envmap_free_data(env);
- /* free when env is in recalcmode */
- else if (env->recalc)
- BKE_texture_envmap_free_data(env);
- }
-
- if (env->ok == 0 && depth == 0) env->recalc = 1;
-
- if (env->ok == 0) {
- do_init = true;
- render_envmap(re, env);
-
- if (depth == env->depth) env->recalc = 0;
- }
- }
- }
- }
- }
- }
- tex = tex->id.next;
- }
- depth++;
- }
-
- if (do_init) {
- re->display_init(re->dih, re->result);
- re->display_clear(re->dch, re->result);
- // re->flag |= R_REDRAW_PRV;
- }
- /* restore */
- re->r.mode |= trace;
-
-}
-
-/* ------------------------------------------------------------------------- */
-
-static int envcube_isect(EnvMap *env, const float vec[3], float answ[2])
-{
- float lambda;
- int face;
-
- if (env->type == ENV_PLANE) {
- face = 1;
-
- lambda = 1.0f / vec[2];
- answ[0] = env->viewscale * lambda * vec[0];
- answ[1] = -env->viewscale * lambda * vec[1];
- }
- else {
- /* which face */
- if (vec[2] <= -fabsf(vec[0]) && vec[2] <= -fabsf(vec[1]) ) {
- face = 0;
- lambda = -1.0f / vec[2];
- answ[0] = lambda * vec[0];
- answ[1] = lambda * vec[1];
- }
- else if (vec[2] >= fabsf(vec[0]) && vec[2] >= fabsf(vec[1])) {
- face = 1;
- lambda = 1.0f / vec[2];
- answ[0] = lambda * vec[0];
- answ[1] = -lambda * vec[1];
- }
- else if (vec[1] >= fabsf(vec[0])) {
- face = 2;
- lambda = 1.0f / vec[1];
- answ[0] = lambda * vec[0];
- answ[1] = lambda * vec[2];
- }
- else if (vec[0] <= -fabsf(vec[1])) {
- face = 3;
- lambda = -1.0f / vec[0];
- answ[0] = lambda * vec[1];
- answ[1] = lambda * vec[2];
- }
- else if (vec[1] <= -fabsf(vec[0])) {
- face = 4;
- lambda = -1.0f / vec[1];
- answ[0] = -lambda * vec[0];
- answ[1] = lambda * vec[2];
- }
- else {
- face = 5;
- lambda = 1.0f / vec[0];
- answ[0] = -lambda * vec[1];
- answ[1] = lambda * vec[2];
- }
- }
-
- answ[0] = 0.5f + 0.5f * answ[0];
- answ[1] = 0.5f + 0.5f * answ[1];
- return face;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static void set_dxtdyt(float r_dxt[3], float r_dyt[3], const float dxt[3], const float dyt[3], int face)
-{
- if (face == 2 || face == 4) {
- r_dxt[0] = dxt[0];
- r_dyt[0] = dyt[0];
- r_dxt[1] = dxt[2];
- r_dyt[1] = dyt[2];
- }
- else if (face == 3 || face == 5) {
- r_dxt[0] = dxt[1];
- r_dxt[1] = dxt[2];
- r_dyt[0] = dyt[1];
- r_dyt[1] = dyt[2];
- }
- else {
- r_dxt[0] = dxt[0];
- r_dyt[0] = dyt[0];
- r_dxt[1] = dxt[1];
- r_dyt[1] = dyt[1];
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-int envmaptex(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, struct ImagePool *pool, const bool skip_load_image)
-{
- extern Render R; /* only in this call */
- /* texvec should be the already reflected normal */
- EnvMap *env;
- ImBuf *ibuf;
- float fac, vec[3], sco[3], dxts[3], dyts[3];
- int face, face1;
-
- env = tex->env;
- if (env == NULL || (env->stype != ENV_LOAD && env->object == NULL)) {
- texres->tin = 0.0;
- return 0;
- }
-
- if (env->stype == ENV_LOAD) {
- env->ima = tex->ima;
- if (env->ima && env->ima->ok) {
- if (env->cube[1] == NULL) {
- ImBuf *ibuf_ima = BKE_image_pool_acquire_ibuf(env->ima, NULL, pool);
- if (ibuf_ima)
- envmap_split_ima(env, ibuf_ima);
- else
- env->ok = 0;
-
- if (env->type == ENV_PLANE)
- tex->extend = TEX_EXTEND;
-
- BKE_image_pool_release_ibuf(env->ima, ibuf_ima, pool);
- }
- }
- }
-
- if (env->ok == 0) {
- texres->tin = 0.0;
- return 0;
- }
-
- /* rotate to envmap space, if object is set */
- copy_v3_v3(vec, texvec);
- if (env->object) {
- mul_m3_v3(env->obimat, vec);
- if (osatex) {
- mul_m3_v3(env->obimat, dxt);
- mul_m3_v3(env->obimat, dyt);
- }
- }
- else {
- if (!BKE_scene_use_world_space_shading(R.scene)) {
- // texvec is in view space
- mul_mat3_m4_v3(R.viewinv, vec);
- if (osatex) {
- mul_mat3_m4_v3(R.viewinv, dxt);
- mul_mat3_m4_v3(R.viewinv, dyt);
- }
- }
- }
-
- face = envcube_isect(env, vec, sco);
- ibuf = env->cube[face];
-
- if (osatex) {
- set_dxtdyt(dxts, dyts, dxt, dyt, face);
- imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, texres, pool, skip_load_image);
-
- /* edges? */
-
- if (texres->ta < 1.0f) {
- TexResult texr1, texr2;
-
- texr1.nor = texr2.nor = NULL;
- texr1.talpha = texr2.talpha = texres->talpha; /* boxclip expects this initialized */
-
- add_v3_v3(vec, dxt);
- face1 = envcube_isect(env, vec, sco);
- sub_v3_v3(vec, dxt);
-
- if (face != face1) {
- ibuf = env->cube[face1];
- set_dxtdyt(dxts, dyts, dxt, dyt, face1);
- imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, &texr1, pool, skip_load_image);
- }
- else texr1.tr = texr1.tg = texr1.tb = texr1.ta = 0.0;
-
- /* here was the nasty bug! results were not zero-ed. FPE! */
-
- add_v3_v3(vec, dyt);
- face1 = envcube_isect(env, vec, sco);
- sub_v3_v3(vec, dyt);
-
- if (face != face1) {
- ibuf = env->cube[face1];
- set_dxtdyt(dxts, dyts, dxt, dyt, face1);
- imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, &texr2, pool, skip_load_image);
- }
- else texr2.tr = texr2.tg = texr2.tb = texr2.ta = 0.0;
-
- fac = (texres->ta + texr1.ta + texr2.ta);
- if (fac != 0.0f) {
- fac = 1.0f / fac;
-
- texres->tr = fac * (texres->ta * texres->tr + texr1.ta * texr1.tr + texr2.ta * texr2.tr);
- texres->tg = fac * (texres->ta * texres->tg + texr1.ta * texr1.tg + texr2.ta * texr2.tg);
- texres->tb = fac * (texres->ta * texres->tb + texr1.ta * texr1.tb + texr2.ta * texr2.tb);
- }
- texres->ta = 1.0;
- }
- }
- else {
- imagewrap(tex, NULL, ibuf, sco, texres, pool, skip_load_image);
- }
-
- return 1;
-}
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index 245a49ad5ae..03be96a20bc 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -47,6 +47,7 @@
#include "BKE_global.h"
#include "BKE_colortools.h"
#include "BKE_layer.h"
+#include "BKE_node.h"
#include "BKE_report.h"
#include "BKE_scene.h"
@@ -69,36 +70,13 @@
#include "renderpipeline.h"
#include "render_types.h"
#include "render_result.h"
-#include "rendercore.h"
/* Render Engine Types */
-static RenderEngineType internal_render_type = {
- NULL, NULL,
- "BLENDER_RENDER", N_("Blender Render"), RE_INTERNAL | RE_USE_LEGACY_PIPELINE,
- NULL, NULL, NULL, NULL, NULL, NULL, render_internal_update_passes, NULL, NULL, NULL,
- {NULL, NULL, NULL}
-};
-
-#ifdef WITH_GAMEENGINE
-
-static RenderEngineType internal_game_type = {
- NULL, NULL,
- "BLENDER_GAME", N_("Blender Game"), RE_INTERNAL | RE_GAME | RE_USE_LEGACY_PIPELINE,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- {NULL, NULL, NULL}
-};
-
-#endif
-
ListBase R_engines = {NULL, NULL};
void RE_engines_init(void)
{
- RE_engines_register(NULL, &internal_render_type);
-#ifdef WITH_GAMEENGINE
- RE_engines_register(NULL, &internal_game_type);
-#endif
DRW_engines_register();
}
@@ -147,7 +125,7 @@ RenderEngineType *RE_engines_find(const char *idname)
type = BLI_findstring(&R_engines, idname, offsetof(RenderEngineType, idname));
if (!type)
- type = &internal_render_type;
+ type = BLI_findstring(&R_engines, "BLENDER_EEVEE", offsetof(RenderEngineType, idname));
return type;
}
@@ -507,13 +485,6 @@ rcti* RE_engine_get_current_tiles(Render *re, int *r_total_tiles, bool *r_needs_
}
tiles[total_tiles] = pa->disprect;
- if (pa->crop) {
- tiles[total_tiles].xmin += pa->crop;
- tiles[total_tiles].ymin += pa->crop;
- tiles[total_tiles].xmax -= pa->crop;
- tiles[total_tiles].ymax -= pa->crop;
- }
-
total_tiles++;
}
}
@@ -575,12 +546,11 @@ void RE_bake_engine_set_engine_parameters(Render *re, Main *bmain, Scene *scene)
re->scene = scene;
re->main = bmain;
render_copy_renderdata(&re->r, &scene->r);
- render_copy_viewrender(&re->view_render, &scene->view_render);
}
bool RE_bake_has_engine(Render *re)
{
- RenderEngineType *type = RE_engines_find(re->view_render.engine_id);
+ RenderEngineType *type = RE_engines_find(re->r.engine);
return (type->bake != NULL);
}
@@ -591,7 +561,7 @@ bool RE_bake_engine(
const eScenePassType pass_type, const int pass_filter,
float result[])
{
- RenderEngineType *type = RE_engines_find(re->view_render.engine_id);
+ RenderEngineType *type = RE_engines_find(re->r.engine);
RenderEngine *engine;
bool persistent_data = (re->r.mode & R_PERSISTENT_DATA) != 0;
@@ -616,7 +586,7 @@ bool RE_bake_engine(
engine->resolution_x = re->winx;
engine->resolution_y = re->winy;
- RE_parts_init(re, false);
+ RE_parts_init(re);
engine->tile_x = re->r.tilex;
engine->tile_y = re->r.tiley;
@@ -668,7 +638,7 @@ bool RE_bake_engine(
int RE_engine_render(Render *re, int do_all)
{
- RenderEngineType *type = RE_engines_find(re->view_render.engine_id);
+ RenderEngineType *type = RE_engines_find(re->r.engine);
RenderEngine *engine;
bool persistent_data = (re->r.mode & R_PERSISTENT_DATA) != 0;
@@ -748,7 +718,7 @@ int RE_engine_render(Render *re, int do_all)
engine->resolution_x = re->winx;
engine->resolution_y = re->winy;
- RE_parts_init(re, false);
+ RE_parts_init(re);
engine->tile_x = re->partx;
engine->tile_y = re->party;
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 6e5d10fcc84..db28a5db531 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -53,16 +53,11 @@
#include "BKE_image.h"
#include "RE_render_ext.h"
+#include "RE_shader_ext.h"
#include "render_types.h"
#include "texture.h"
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float maxy, TexResult *texres, const short imaprepeat, const short imapextend);
/* *********** IMAGEWRAPPING ****************** */
@@ -211,11 +206,6 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
}
}
- /* warning, no return before setting back! */
- if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
- ibuf->rect+= (ibuf->x*ibuf->y);
- }
-
/* keep this before interpolation [#29761] */
if (ima) {
if ((tex->imaflag & TEX_USEALPHA) && (ima->flag & IMA_IGNORE_ALPHA) == 0) {
@@ -243,10 +233,6 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
ibuf_get_color(&texres->tr, ibuf, x, y);
}
- if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
- ibuf->rect-= (ibuf->x*ibuf->y);
- }
-
if (texres->nor) {
if (tex->imaflag & TEX_NORMALMAP) {
/* qdn: normal from color
@@ -979,17 +965,6 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
fy = texvec[1];
}
- if (ibuf->flags & IB_fields) {
- if (R.r.mode & R_FIELDS) { /* field render */
- if (R.flag & R_SEC_FIELD) { /* correction for 2nd field */
- /* fac1= 0.5/( (float)ibuf->y ); */
- /* fy-= fac1; */
- }
- else /* first field */
- fy += 0.5f/( (float)ibuf->y );
- }
- }
-
/* pixel coordinates */
minx = min_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
maxx = max_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
@@ -1129,10 +1104,6 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
intpol = tex->imaflag & TEX_INTERPOL;
- /* warning no return! */
- if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields))
- ibuf->rect += ibuf->x*ibuf->y;
-
/* struct common data */
copy_v2_v2(AFD.dxt, dxt);
copy_v2_v2(AFD.dyt, dyt);
@@ -1311,9 +1282,6 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
texres->tin = texres->ta;
if (tex->flag & TEX_NEGALPHA) texres->ta = 1.f - texres->ta;
- if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields))
- ibuf->rect -= ibuf->x*ibuf->y;
-
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */
/* The invert of the red channel is to make
* the normal map compliant with the outside world.
@@ -1411,18 +1379,6 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
fy= texvec[1];
}
- if (ibuf->flags & IB_fields) {
- if (R.r.mode & R_FIELDS) { /* field render */
- if (R.flag & R_SEC_FIELD) { /* correction for 2nd field */
- /* fac1= 0.5/( (float)ibuf->y ); */
- /* fy-= fac1; */
- }
- else { /* first field */
- fy+= 0.5f/( (float)ibuf->y );
- }
- }
- }
-
/* pixel coordinates */
minx = min_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
@@ -1580,11 +1536,6 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
}
}
- /* warning no return! */
- if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
- ibuf->rect+= (ibuf->x*ibuf->y);
- }
-
/* choice: */
if (tex->imaflag & TEX_MIPMAP) {
ImBuf *previbuf, *curibuf;
@@ -1731,10 +1682,6 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
if (tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta;
- if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
- ibuf->rect-= (ibuf->x*ibuf->y);
- }
-
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) {
/* qdn: normal from color
* The invert of the red channel is to make
@@ -1772,16 +1719,10 @@ void image_sample(Image *ima, float fx, float fy, float dx, float dy, float resu
return;
}
- if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) )
- ibuf->rect+= (ibuf->x*ibuf->y);
-
texres.talpha = true; /* boxsample expects to be initialized */
boxsample(ibuf, fx, fy, fx + dx, fy + dy, &texres, 0, 1);
copy_v4_v4(result, &texres.tr);
- if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) )
- ibuf->rect-= (ibuf->x*ibuf->y);
-
ima->flag|= IMA_USED_FOR_RENDER;
BKE_image_pool_release_ibuf(ima, ibuf, pool);
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 13c95dac05d..4274d641674 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -38,18 +38,12 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
-#include "BLI_jitter_2d.h"
#include "BLI_utildefines.h"
#include "DNA_camera_types.h"
-#include "DNA_image_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
#include "BKE_camera.h"
-#include "DEG_depsgraph.h"
-
/* this module */
#include "renderpipeline.h"
#include "render_types.h"
@@ -58,31 +52,6 @@
#include "initrender.h"
-/* ********************** */
-
-static void init_render_jit(Render *re)
-{
- static float jit[32][2]; /* simple caching */
- static float mblur_jit[32][2]; /* simple caching */
- static int lastjit = 0;
- static int last_mblur_jit = 0;
-
- if (lastjit != re->r.osa || last_mblur_jit != re->r.mblur_samples) {
- memset(jit, 0, sizeof(jit));
- BLI_jitter_init(jit, re->r.osa);
-
- memset(mblur_jit, 0, sizeof(mblur_jit));
- BLI_jitter_init(mblur_jit, re->r.mblur_samples);
- }
-
- lastjit = re->r.osa;
- memcpy(re->jit, jit, sizeof(jit));
-
- last_mblur_jit = re->r.mblur_samples;
- memcpy(re->mblur_jit, mblur_jit, sizeof(mblur_jit));
-}
-
-
/* ****************** MASKS and LUTS **************** */
static float filt_quadratic(float x)
@@ -173,256 +142,6 @@ float RE_filter_value(int type, float x)
return 0.0f;
}
-static float calc_weight(Render *re, float *weight, int i, int j)
-{
- float x, y, dist, totw = 0.0;
- int a;
-
- for (a = 0; a < re->osa; a++) {
- x = re->jit[a][0] + i;
- y = re->jit[a][1] + j;
- dist = sqrtf(x * x + y * y);
-
- weight[a] = 0.0;
-
- /* Weighting choices */
- switch (re->r.filtertype) {
- case R_FILTER_BOX:
- if (i == 0 && j == 0) weight[a] = 1.0;
- break;
-
- case R_FILTER_TENT:
- if (dist < re->r.gauss)
- weight[a] = re->r.gauss - dist;
- break;
-
- case R_FILTER_GAUSS:
- x = dist * re->r.gauss;
- weight[a] = (1.0f / expf(x * x) - 1.0f / expf(re->r.gauss * re->r.gauss * 2.25f));
- break;
-
- case R_FILTER_MITCH:
- weight[a] = filt_mitchell(dist * re->r.gauss);
- break;
-
- case R_FILTER_QUAD:
- weight[a] = filt_quadratic(dist * re->r.gauss);
- break;
-
- case R_FILTER_CUBIC:
- weight[a] = filt_cubic(dist * re->r.gauss);
- break;
-
- case R_FILTER_CATROM:
- weight[a] = filt_catrom(dist * re->r.gauss);
- break;
-
- }
-
- totw += weight[a];
-
- }
- return totw;
-}
-
-void free_sample_tables(Render *re)
-{
- int a;
-
- if (re->samples) {
- for (a = 0; a < 9; a++) {
- MEM_freeN(re->samples->fmask1[a]);
- MEM_freeN(re->samples->fmask2[a]);
- }
-
- MEM_freeN(re->samples->centmask);
- MEM_freeN(re->samples);
- re->samples = NULL;
- }
-}
-
-/* based on settings in render, it makes the lookup tables */
-void make_sample_tables(Render *re)
-{
- static int firsttime = 1;
- SampleTables *st;
- float flweight[32];
- float weight[32], totw, val, *fpx1, *fpx2, *fpy1, *fpy2, *m3, *m4;
- int i, j, a, centmasksize;
-
- /* optimization tables, only once */
- if (firsttime) {
- firsttime = 0;
- }
-
- free_sample_tables(re);
-
- init_render_jit(re); /* needed for mblur too */
-
- if (re->osa == 0) {
- /* just prevents cpu cycles for larger render and copying */
- re->r.filtertype = 0;
- return;
- }
-
- st = re->samples = MEM_callocN(sizeof(SampleTables), "sample tables");
-
- for (a = 0; a < 9; a++) {
- st->fmask1[a] = MEM_callocN(256 * sizeof(float), "initfilt");
- st->fmask2[a] = MEM_callocN(256 * sizeof(float), "initfilt");
- }
- for (a = 0; a < 256; a++) {
- st->cmask[a] = 0;
- if (a & 1) st->cmask[a]++;
- if (a & 2) st->cmask[a]++;
- if (a & 4) st->cmask[a]++;
- if (a & 8) st->cmask[a]++;
- if (a & 16) st->cmask[a]++;
- if (a & 32) st->cmask[a]++;
- if (a & 64) st->cmask[a]++;
- if (a & 128) st->cmask[a]++;
- }
-
- centmasksize = (1 << re->osa);
- st->centmask = MEM_mallocN(centmasksize, "Initfilt3");
-
- for (a = 0; a < 16; a++) {
- st->centLut[a] = -0.45f + ((float)a) / 16.0f;
- }
-
- /* calculate totw */
- totw = 0.0;
- for (j = -1; j < 2; j++) {
- for (i = -1; i < 2; i++) {
- totw += calc_weight(re, weight, i, j);
- }
- }
-
- for (j = -1; j < 2; j++) {
- for (i = -1; i < 2; i++) {
- /* calculate using jit, with offset the weights */
-
- memset(weight, 0, sizeof(weight));
- calc_weight(re, weight, i, j);
-
- for (a = 0; a < 16; a++) flweight[a] = weight[a] * (1.0f / totw);
-
- m3 = st->fmask1[3 * (j + 1) + i + 1];
- m4 = st->fmask2[3 * (j + 1) + i + 1];
-
- for (a = 0; a < 256; a++) {
- if (a & 1) {
- m3[a] += flweight[0];
- m4[a] += flweight[8];
- }
- if (a & 2) {
- m3[a] += flweight[1];
- m4[a] += flweight[9];
- }
- if (a & 4) {
- m3[a] += flweight[2];
- m4[a] += flweight[10];
- }
- if (a & 8) {
- m3[a] += flweight[3];
- m4[a] += flweight[11];
- }
- if (a & 16) {
- m3[a] += flweight[4];
- m4[a] += flweight[12];
- }
- if (a & 32) {
- m3[a] += flweight[5];
- m4[a] += flweight[13];
- }
- if (a & 64) {
- m3[a] += flweight[6];
- m4[a] += flweight[14];
- }
- if (a & 128) {
- m3[a] += flweight[7];
- m4[a] += flweight[15];
- }
- }
- }
- }
-
- /* centmask: the correct subpixel offset per mask */
-
- fpx1 = MEM_mallocN(256 * sizeof(float), "initgauss4");
- fpx2 = MEM_mallocN(256 * sizeof(float), "initgauss4");
- fpy1 = MEM_mallocN(256 * sizeof(float), "initgauss4");
- fpy2 = MEM_mallocN(256 * sizeof(float), "initgauss4");
- for (a = 0; a < 256; a++) {
- fpx1[a] = fpx2[a] = 0.0;
- fpy1[a] = fpy2[a] = 0.0;
- if (a & 1) {
- fpx1[a] += re->jit[0][0];
- fpy1[a] += re->jit[0][1];
- fpx2[a] += re->jit[8][0];
- fpy2[a] += re->jit[8][1];
- }
- if (a & 2) {
- fpx1[a] += re->jit[1][0];
- fpy1[a] += re->jit[1][1];
- fpx2[a] += re->jit[9][0];
- fpy2[a] += re->jit[9][1];
- }
- if (a & 4) {
- fpx1[a] += re->jit[2][0];
- fpy1[a] += re->jit[2][1];
- fpx2[a] += re->jit[10][0];
- fpy2[a] += re->jit[10][1];
- }
- if (a & 8) {
- fpx1[a] += re->jit[3][0];
- fpy1[a] += re->jit[3][1];
- fpx2[a] += re->jit[11][0];
- fpy2[a] += re->jit[11][1];
- }
- if (a & 16) {
- fpx1[a] += re->jit[4][0];
- fpy1[a] += re->jit[4][1];
- fpx2[a] += re->jit[12][0];
- fpy2[a] += re->jit[12][1];
- }
- if (a & 32) {
- fpx1[a] += re->jit[5][0];
- fpy1[a] += re->jit[5][1];
- fpx2[a] += re->jit[13][0];
- fpy2[a] += re->jit[13][1];
- }
- if (a & 64) {
- fpx1[a] += re->jit[6][0];
- fpy1[a] += re->jit[6][1];
- fpx2[a] += re->jit[14][0];
- fpy2[a] += re->jit[14][1];
- }
- if (a & 128) {
- fpx1[a] += re->jit[7][0];
- fpy1[a] += re->jit[7][1];
- fpx2[a] += re->jit[15][0];
- fpy2[a] += re->jit[15][1];
- }
- }
-
- for (a = centmasksize - 1; a > 0; a--) {
- val = st->cmask[a & 255] + st->cmask[a >> 8];
- i = 8 + (15.9f * (fpy1[a & 255] + fpy2[a >> 8]) / val);
- CLAMP(i, 0, 15);
- j = 8 + (15.9f * (fpx1[a & 255] + fpx2[a >> 8]) / val);
- CLAMP(j, 0, 15);
- i = j + (i << 4);
- st->centmask[a] = i;
- }
-
- MEM_freeN(fpx1);
- MEM_freeN(fpx2);
- MEM_freeN(fpy1);
- MEM_freeN(fpy2);
-}
-
-
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
struct Object *RE_GetCamera(Render *re)
{
@@ -437,37 +156,11 @@ static void re_camera_params_get(Render *re, CameraParams *params, Object *cam_o
re->clipsta = params->clipsta;
re->clipend = params->clipend;
- re->ycor = params->ycor;
- re->viewdx = params->viewdx;
- re->viewdy = params->viewdy;
re->viewplane = params->viewplane;
BKE_camera_object_mode(&re->r, cam_ob);
}
-void RE_SetEnvmapCamera(Render *re, Object *cam_ob, float viewscale, float clipsta, float clipend)
-{
- CameraParams params;
-
- /* setup parameters */
- BKE_camera_params_init(&params);
- BKE_camera_params_from_object(&params, cam_ob);
-
- params.lens = 16.0f * viewscale;
- params.sensor_x = 32.0f;
- params.sensor_y = 32.0f;
- params.sensor_fit = CAMERA_SENSOR_FIT_AUTO;
- params.clipsta = clipsta;
- params.clipend = clipend;
-
- /* compute matrix, viewplane, .. */
- BKE_camera_params_compute_viewplane(&params, re->winx, re->winy, 1.0f, 1.0f);
- BKE_camera_params_compute_matrix(&params);
-
- /* extract results */
- re_camera_params_get(re, &params, cam_ob);
-}
-
void RE_SetOverrideCamera(Render *re, Object *camera)
{
re->camera_override = camera;
@@ -489,10 +182,6 @@ void RE_SetCamera(Render *re, Object *cam_ob)
BKE_camera_params_from_object(&params, cam_ob);
re_camera_params_stereo3d(re, &params, cam_ob);
- params.use_fields = (re->r.mode & R_FIELDS);
- params.field_second = (re->flag & R_SEC_FIELD);
- params.field_odd = (re->r.mode & R_ODDFIELD);
-
/* compute matrix, viewplane, .. */
BKE_camera_params_compute_viewplane(&params, re->winx, re->winy, re->r.xasp, re->r.yasp);
BKE_camera_params_compute_matrix(&params);
@@ -501,12 +190,6 @@ void RE_SetCamera(Render *re, Object *cam_ob)
re_camera_params_get(re, &params, cam_ob);
}
-void RE_SetPixelSize(Render *re, float pixsize)
-{
- re->viewdx = pixsize;
- re->viewdy = re->ycor * pixsize;
-}
-
void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[4][4])
{
re->r.cfra = frame;
@@ -524,13 +207,6 @@ void RE_GetCameraModelMatrix(Render *re, struct Object *camera, float r_mat[4][4
void RE_parts_free(Render *re)
{
- RenderPart *part = re->parts.first;
-
- while (part) {
- if (part->rectp) MEM_freeN(part->rectp);
- if (part->rectz) MEM_freeN(part->rectz);
- part = part->next;
- }
BLI_freelistN(&re->parts);
}
@@ -541,7 +217,7 @@ void RE_parts_clamp(Render *re)
re->party = max_ii(1, min_ii(re->r.tiley, re->recty));
}
-void RE_parts_init(Render *re, bool do_crop)
+void RE_parts_init(Render *re)
{
int nr, xd, yd, partx, party, xparts, yparts;
int xminb, xmaxb, yminb, ymaxb;
@@ -567,10 +243,6 @@ void RE_parts_init(Render *re, bool do_crop)
xparts = (re->rectx + partx - 1) / partx;
yparts = (re->recty + party - 1) / party;
- /* calculate rotation factor of 1 pixel */
- if (re->r.mode & R_PANORAMA)
- re->panophi = panorama_pixel_rot(re);
-
for (nr = 0; nr < xparts * yparts; nr++) {
rcti disprect;
int rectx, recty;
@@ -603,16 +275,6 @@ void RE_parts_init(Render *re, bool do_crop)
if (rectx > 0 && recty > 0) {
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))) {
- pa->crop = 2;
- disprect.xmin -= pa->crop;
- disprect.ymin -= pa->crop;
- disprect.xmax += pa->crop;
- disprect.ymax += pa->crop;
- rectx += 2 * pa->crop;
- recty += 2 * pa->crop;
- }
pa->disprect = disprect;
pa->rectx = rectx;
pa->recty = recty;
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c
index ddab8b23b59..9fb7e718b18 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/source/multires_bake.c
@@ -36,6 +36,7 @@
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_scene_types.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
@@ -59,10 +60,6 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "rendercore.h"
-
typedef void (*MPassKnownData)(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void *thread_data,
void *bake_data, ImBuf *ibuf, const int face_index, const int lvl,
const float st[2], float tangmat[3][3], const int x, const int y);
@@ -115,19 +112,6 @@ typedef struct {
const int *orig_index_mp_to_orig;
} MNormalBakeData;
-typedef struct {
- int number_of_rays;
- float bias;
-
- unsigned short *permutation_table_1;
- unsigned short *permutation_table_2;
-
- RayObject *raytree;
- RayFace *rayfaces;
-
- const int *orig_index_mp_to_orig;
-} MAOBakeData;
-
static void multiresbake_get_normal(const MResolvePixelData *data, float norm[],const int tri_num, const int vert_index)
{
const int poly_index = data->mlooptri[tri_num].poly;
@@ -884,6 +868,8 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
}
}
+/* TODO: restore ambient occlusion baking support, using BLI BVH? */
+#if 0
/* **************** Ambient Occlusion Baker **************** */
// must be a power of two
@@ -1176,6 +1162,68 @@ static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void
rrgb[3] = 255;
}
}
+#endif
+
+/* ******$***************** Post processing ************************* */
+
+static void bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter)
+{
+ /* must check before filtering */
+ const bool is_new_alpha = (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_imbuf_alpha_test(ibuf);
+
+ /* Margin */
+ if (filter) {
+ IMB_filter_extend(ibuf, mask, filter);
+ }
+
+ /* if the bake results in new alpha then change the image setting */
+ if (is_new_alpha) {
+ ibuf->planes = R_IMF_PLANES_RGBA;
+ }
+ else {
+ if (filter && ibuf->planes != R_IMF_PLANES_RGBA) {
+ /* clear alpha added by filtering */
+ IMB_rectfill_alpha(ibuf, 1.0f);
+ }
+ }
+}
+
+static void bake_ibuf_normalize_displacement(ImBuf *ibuf, float *displacement, char *mask, float displacement_min, float displacement_max)
+{
+ int i;
+ const float *current_displacement = displacement;
+ const char *current_mask = mask;
+ float max_distance;
+
+ max_distance = max_ff(fabsf(displacement_min), fabsf(displacement_max));
+
+ for (i = 0; i < ibuf->x * ibuf->y; i++) {
+ if (*current_mask == FILTER_MASK_USED) {
+ float normalized_displacement;
+
+ if (max_distance > 1e-5f)
+ normalized_displacement = (*current_displacement + max_distance) / (max_distance * 2);
+ else
+ normalized_displacement = 0.5f;
+
+ if (ibuf->rect_float) {
+ /* currently baking happens to RGBA only */
+ float *fp = ibuf->rect_float + i * 4;
+ fp[0] = fp[1] = fp[2] = normalized_displacement;
+ fp[3] = 1.0f;
+ }
+
+ if (ibuf->rect) {
+ unsigned char *cp = (unsigned char *) (ibuf->rect + i);
+ cp[0] = cp[1] = cp[2] = FTOCHAR(normalized_displacement);
+ cp[3] = 255;
+ }
+ }
+
+ current_displacement++;
+ current_mask++;
+ }
+}
/* **************** Common functions public API relates on **************** */
@@ -1229,12 +1277,14 @@ static void bake_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
do_multires_bake(bkr, ima, true, apply_tangmat_callback, init_normal_data, free_normal_data, result);
break;
case RE_BAKE_DISPLACEMENT:
- case RE_BAKE_DERIVATIVE:
do_multires_bake(bkr, ima, false, apply_heights_callback, init_heights_data, free_heights_data, result);
break;
+/* TODO: restore ambient occlusion baking support. */
+#if 0
case RE_BAKE_AO:
do_multires_bake(bkr, ima, false, apply_ao_callback, init_ao_data, free_ao_data, result);
break;
+#endif
}
}
@@ -1247,7 +1297,7 @@ static void bake_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
{
LinkData *link;
- bool use_displacement_buffer = ELEM(bkr->mode, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE);
+ bool use_displacement_buffer = bkr->mode == RE_BAKE_DISPLACEMENT;
for (link = bkr->image.first; link; link = link->next) {
Image *ima = (Image *)link->data;
@@ -1258,17 +1308,11 @@ static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
continue;
if (use_displacement_buffer) {
- if (bkr->mode == RE_BAKE_DERIVATIVE) {
- RE_bake_make_derivative(ibuf, userdata->displacement_buffer, userdata->mask_buffer,
- result->height_min, result->height_max, bkr->user_scale);
- }
- else {
- RE_bake_ibuf_normalize_displacement(ibuf, userdata->displacement_buffer, userdata->mask_buffer,
- result->height_min, result->height_max);
- }
+ bake_ibuf_normalize_displacement(ibuf, userdata->displacement_buffer, userdata->mask_buffer,
+ result->height_min, result->height_max);
}
- RE_bake_ibuf_filter(ibuf, userdata->mask_buffer, bkr->bake_filter);
+ bake_ibuf_filter(ibuf, userdata->mask_buffer, bkr->bake_filter);
ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
deleted file mode 100644
index 42200a8278c..00000000000
--- a/source/blender/render/intern/source/occlusion.c
+++ /dev/null
@@ -1,1533 +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) 2008 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Brecht Van Lommel.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/occlusion.c
- * \ingroup render
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_material_types.h"
-
-#include "BLI_math.h"
-#include "BLI_memarena.h"
-#include "BLI_threads.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "BKE_node.h"
-#include "BKE_scene.h"
-
-
-#include "RE_shader_ext.h"
-
-/* local includes */
-#include "occlusion.h"
-#include "render_types.h"
-#include "rendercore.h"
-#include "renderdatabase.h"
-#include "shading.h"
-
-/* ------------------------- Declarations --------------------------- */
-
-#define INVPI ((float)M_1_PI)
-#define TOTCHILD 8
-#define CACHE_STEP 3
-
-typedef struct OcclusionCacheSample {
- float co[3], n[3], ao[3], env[3], indirect[3], intensity, dist2;
- int x, y, filled;
-} OcclusionCacheSample;
-
-typedef struct OcclusionCache {
- OcclusionCacheSample *sample;
- int x, y, w, h, step;
-} OcclusionCache;
-
-typedef struct OccFace {
- int obi;
- int facenr;
-} OccFace;
-
-typedef struct OccNode {
- float co[3], area;
- float sh[9], dco;
- float occlusion, rad[3];
- int childflag;
- union {
- //OccFace face;
- int face;
- struct OccNode *node;
- } child[TOTCHILD];
-} OccNode;
-
-typedef struct OcclusionTree {
- MemArena *arena;
-
- float (*co)[3]; /* temporary during build */
-
- OccFace *face; /* instance and face indices */
- float *occlusion; /* occlusion for faces */
- float (*rad)[3]; /* radiance for faces */
-
- OccNode *root;
-
- OccNode **stack[BLENDER_MAX_THREADS];
- int maxdepth;
-
- int totface;
-
- float error;
- float distfac;
-
- int dothreadedbuild;
- int totbuildthread;
- int doindirect;
-
- OcclusionCache *cache;
-
- int num_threads;
-} OcclusionTree;
-
-typedef struct OcclusionThread {
- Render *re;
- StrandSurface *mesh;
- float (*faceao)[3];
- float (*faceenv)[3];
- float (*faceindirect)[3];
- int begin, end;
- int thread;
-} OcclusionThread;
-
-typedef struct OcclusionBuildThread {
- OcclusionTree *tree;
- int begin, end, depth;
- OccNode *node;
-} OcclusionBuildThread;
-
-/* ------------------------- Shading --------------------------- */
-
-extern Render R; /* meh */
-
-static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, float *rad)
-{
- ShadeInput *shi = ssamp->shi;
- ShadeResult *shr = ssamp->shr;
- float l, u, v, *v1, *v2, *v3;
-
- /* init */
- if (vlr->v4) {
- shi->u = u = 0.5f;
- shi->v = v = 0.5f;
- }
- else {
- shi->u = u = 1.0f / 3.0f;
- shi->v = v = 1.0f / 3.0f;
- }
-
- /* setup render coordinates */
- v1 = vlr->v1->co;
- v2 = vlr->v2->co;
- v3 = vlr->v3->co;
-
- /* renderco */
- l = 1.0f - u - v;
-
- shi->co[0] = l * v3[0] + u * v1[0] + v * v2[0];
- shi->co[1] = l * v3[1] + u * v1[1] + v * v2[1];
- shi->co[2] = l * v3[2] + u * v1[2] + v * v2[2];
-
- shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2);
-
- /* set up view vector */
- copy_v3_v3(shi->view, shi->co);
- normalize_v3(shi->view);
-
- /* cache for shadow */
- shi->samplenr++;
-
- shi->xs = 0; /* TODO */
- shi->ys = 0;
-
- shade_input_set_normals(shi);
-
- /* no normal flip */
- if (shi->flippednor)
- shade_input_flip_normals(shi);
-
- madd_v3_v3fl(shi->co, shi->facenor, -0.0001f); /* ugly.. */
-
- /* not a pretty solution, but fixes common cases */
- if (shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) {
- negate_v3(shi->vn);
- negate_v3(shi->vno);
- negate_v3(shi->nmapnorm);
- }
-
- /* init material vars */
- shade_input_init_material(shi);
-
- /* render */
- shade_input_set_shade_texco(shi);
-
- if (shi->mat->nodetree && shi->mat->use_nodes) {
- ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
- shi->mat = vlr->mat; /* shi->mat is being set in nodetree */
- }
- else {
- shade_material_loop(shi, shr);
- }
-
- copy_v3_v3(rad, shr->combined);
-}
-
-static void occ_build_shade(Render *re, OcclusionTree *tree)
-{
- ShadeSample ssamp;
- ObjectInstanceRen *obi;
- VlakRen *vlr;
- int a;
-
- R = *re;
-
- /* setup shade sample with correct passes */
- memset(&ssamp, 0, sizeof(ShadeSample));
- ssamp.shi[0].lay = re->lay;
- ssamp.shi[0].passflag = SCE_PASS_DIFFUSE | SCE_PASS_RGBA;
- ssamp.shi[0].combinedflag = ~(SCE_PASS_SPEC);
- ssamp.tot = 1;
-
- for (a = 0; a < tree->totface; a++) {
- obi = &R.objectinstance[tree->face[a].obi];
- vlr = RE_findOrAddVlak(obi->obr, tree->face[a].facenr);
-
- occ_shade(&ssamp, obi, vlr, tree->rad[a]);
-
- if (re->test_break(re->tbh))
- break;
- }
-}
-
-/* ------------------------- Spherical Harmonics --------------------------- */
-
-/* Use 2nd order SH => 9 coefficients, stored in this order:
- * 0 = (0,0),
- * 1 = (1,-1), 2 = (1,0), 3 = (1,1),
- * 4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */
-
-static void sh_copy(float *shresult, float *sh)
-{
- memcpy(shresult, sh, sizeof(float) * 9);
-}
-
-static void sh_mul(float *sh, float f)
-{
- int i;
-
- for (i = 0; i < 9; i++)
- sh[i] *= f;
-}
-
-static void sh_add(float *shresult, float *sh1, float *sh2)
-{
- int i;
-
- for (i = 0; i < 9; i++)
- shresult[i] = sh1[i] + sh2[i];
-}
-
-static void sh_from_disc(float *n, float area, float *shresult)
-{
- /* See formula (3) in:
- * "An Efficient Representation for Irradiance Environment Maps" */
- float sh[9], x, y, z;
-
- x = n[0];
- y = n[1];
- z = n[2];
-
- sh[0] = 0.282095f;
-
- sh[1] = 0.488603f * y;
- sh[2] = 0.488603f * z;
- sh[3] = 0.488603f * x;
-
- sh[4] = 1.092548f * x * y;
- sh[5] = 1.092548f * y * z;
- sh[6] = 0.315392f * (3.0f * z * z - 1.0f);
- sh[7] = 1.092548f * x * z;
- sh[8] = 0.546274f * (x * x - y * y);
-
- sh_mul(sh, area);
- sh_copy(shresult, sh);
-}
-
-static float sh_eval(float *sh, float *v)
-{
- /* See formula (13) in:
- * "An Efficient Representation for Irradiance Environment Maps" */
- static const float c1 = 0.429043f, c2 = 0.511664f, c3 = 0.743125f;
- static const float c4 = 0.886227f, c5 = 0.247708f;
- float x, y, z, sum;
-
- x = v[0];
- y = v[1];
- z = v[2];
-
- sum = c1 * sh[8] * (x * x - y * y);
- sum += c3 * sh[6] * z * z;
- sum += c4 * sh[0];
- sum += -c5 * sh[6];
- sum += 2.0f * c1 * (sh[4] * x * y + sh[7] * x * z + sh[5] * y * z);
- sum += 2.0f * c2 * (sh[3] * x + sh[1] * y + sh[2] * z);
-
- return sum;
-}
-
-/* ------------------------------ Building --------------------------------- */
-
-static void occ_face(const OccFace *face, float co[3], float normal[3], float *area)
-{
- ObjectInstanceRen *obi;
- VlakRen *vlr;
- float v1[3], v2[3], v3[3], v4[3];
-
- obi = &R.objectinstance[face->obi];
- vlr = RE_findOrAddVlak(obi->obr, face->facenr);
-
- if (co) {
- if (vlr->v4)
- mid_v3_v3v3(co, vlr->v1->co, vlr->v3->co);
- else
- mid_v3_v3v3v3(co, vlr->v1->co, vlr->v2->co, vlr->v3->co);
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_v3(obi->mat, co);
- }
-
- if (normal) {
- normal[0] = -vlr->n[0];
- normal[1] = -vlr->n[1];
- normal[2] = -vlr->n[2];
-
- if (obi->flag & R_TRANSFORMED)
- mul_m3_v3(obi->nmat, normal);
- }
-
- if (area) {
- copy_v3_v3(v1, vlr->v1->co);
- copy_v3_v3(v2, vlr->v2->co);
- copy_v3_v3(v3, vlr->v3->co);
- if (vlr->v4) copy_v3_v3(v4, vlr->v4->co);
-
- if (obi->flag & R_TRANSFORMED) {
- mul_m4_v3(obi->mat, v1);
- mul_m4_v3(obi->mat, v2);
- mul_m4_v3(obi->mat, v3);
- if (vlr->v4) mul_m4_v3(obi->mat, v4);
- }
-
- /* todo: correct area for instances */
- if (vlr->v4)
- *area = area_quad_v3(v1, v2, v3, v4);
- else
- *area = area_tri_v3(v1, v2, v3);
- }
-}
-
-static void occ_sum_occlusion(OcclusionTree *tree, OccNode *node)
-{
- OccNode *child;
- float occ, area, totarea, rad[3];
- int a, b, indirect = tree->doindirect;
-
- occ = 0.0f;
- totarea = 0.0f;
- if (indirect) zero_v3(rad);
-
- for (b = 0; b < TOTCHILD; b++) {
- if (node->childflag & (1 << b)) {
- a = node->child[b].face;
- occ_face(&tree->face[a], NULL, NULL, &area);
- occ += area * tree->occlusion[a];
- if (indirect) madd_v3_v3fl(rad, tree->rad[a], area);
- totarea += area;
- }
- else if (node->child[b].node) {
- child = node->child[b].node;
- occ_sum_occlusion(tree, child);
-
- occ += child->area * child->occlusion;
- if (indirect) madd_v3_v3fl(rad, child->rad, child->area);
- totarea += child->area;
- }
- }
-
- if (totarea != 0.0f) {
- occ /= totarea;
- if (indirect) mul_v3_fl(rad, 1.0f / totarea);
- }
-
- node->occlusion = occ;
- if (indirect) copy_v3_v3(node->rad, rad);
-}
-
-static int occ_find_bbox_axis(OcclusionTree *tree, int begin, int end, float *min, float *max)
-{
- float len, maxlen = -1.0f;
- int a, axis = 0;
-
- INIT_MINMAX(min, max);
-
- for (a = begin; a < end; a++) {
- minmax_v3v3_v3(min, max, tree->co[a]);
- }
-
- for (a = 0; a < 3; a++) {
- len = max[a] - min[a];
-
- if (len > maxlen) {
- maxlen = len;
- axis = a;
- }
- }
-
- return axis;
-}
-
-static void occ_node_from_face(OccFace *face, OccNode *node)
-{
- float n[3];
-
- occ_face(face, node->co, n, &node->area);
- node->dco = 0.0f;
- sh_from_disc(n, node->area, node->sh);
-}
-
-static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], float *dco)
-{
- int b;
- for (b = 0; b < TOTCHILD; b++) {
- float dist, d[3], nco[3];
-
- if (node->childflag & (1 << b)) {
- occ_face(tree->face + node->child[b].face, nco, NULL, NULL);
- }
- else if (node->child[b].node) {
- OccNode *child = node->child[b].node;
- occ_build_dco(tree, child, co, dco);
- copy_v3_v3(nco, child->co);
- }
- else {
- continue;
- }
-
- sub_v3_v3v3(d, nco, co);
- dist = dot_v3v3(d, d);
- if (dist > *dco)
- *dco = dist;
- }
-}
-
-static void occ_build_split(OcclusionTree *tree, int begin, int end, int *split)
-{
- float min[3], max[3], mid;
- int axis, a, enda;
-
- /* split in middle of boundbox. this seems faster than median split
- * on complex scenes, possibly since it avoids two distant faces to
- * be in the same node better? */
- axis = occ_find_bbox_axis(tree, begin, end, min, max);
- mid = 0.5f * (min[axis] + max[axis]);
-
- a = begin;
- enda = end;
- while (a < enda) {
- if (tree->co[a][axis] > mid) {
- enda--;
- SWAP(OccFace, tree->face[a], tree->face[enda]);
- swap_v3_v3(tree->co[a], tree->co[enda]);
- }
- else
- a++;
- }
-
- *split = enda;
-}
-
-static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offset, int *count)
-{
- /* split faces into eight groups */
- int b, splitx, splity[2], splitz[4];
-
- occ_build_split(tree, begin, end, &splitx);
-
- /* force split if none found, to deal with degenerate geometry */
- if (splitx == begin || splitx == end)
- splitx = (begin + end) / 2;
-
- occ_build_split(tree, begin, splitx, &splity[0]);
- occ_build_split(tree, splitx, end, &splity[1]);
-
- occ_build_split(tree, begin, splity[0], &splitz[0]);
- occ_build_split(tree, splity[0], splitx, &splitz[1]);
- occ_build_split(tree, splitx, splity[1], &splitz[2]);
- occ_build_split(tree, splity[1], end, &splitz[3]);
-
- offset[0] = begin;
- offset[1] = splitz[0];
- offset[2] = splity[0];
- offset[3] = splitz[1];
- offset[4] = splitx;
- offset[5] = splitz[2];
- offset[6] = splity[1];
- offset[7] = splitz[3];
-
- for (b = 0; b < 7; b++)
- count[b] = offset[b + 1] - offset[b];
- count[7] = end - offset[7];
-}
-
-static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, int end, int depth);
-
-static void *exec_occ_build(void *data)
-{
- OcclusionBuildThread *othread = (OcclusionBuildThread *)data;
-
- occ_build_recursive(othread->tree, othread->node, othread->begin, othread->end, othread->depth);
-
- return NULL;
-}
-
-static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, int end, int depth)
-{
- ListBase threads;
- OcclusionBuildThread othreads[BLENDER_MAX_THREADS];
- OccNode *child, tmpnode;
- /* OccFace *face; */
- int a, b, totthread = 0, offset[TOTCHILD], count[TOTCHILD];
-
- /* add a new node */
- node->occlusion = 1.0f;
-
- /* leaf node with only children */
- if (end - begin <= TOTCHILD) {
- for (a = begin, b = 0; a < end; a++, b++) {
- /* face= &tree->face[a]; */
- node->child[b].face = a;
- node->childflag |= (1 << b);
- }
- }
- else {
- /* order faces */
- occ_build_8_split(tree, begin, end, offset, count);
-
- if (depth == 1 && tree->dothreadedbuild)
- BLI_threadpool_init(&threads, exec_occ_build, tree->totbuildthread);
-
- for (b = 0; b < TOTCHILD; b++) {
- if (count[b] == 0) {
- node->child[b].node = NULL;
- }
- else if (count[b] == 1) {
- /* face= &tree->face[offset[b]]; */
- node->child[b].face = offset[b];
- node->childflag |= (1 << b);
- }
- else {
- if (tree->dothreadedbuild)
- BLI_thread_lock(LOCK_CUSTOM1);
-
- child = BLI_memarena_alloc(tree->arena, sizeof(OccNode));
- node->child[b].node = child;
-
- /* keep track of maximum depth for stack */
- if (depth >= tree->maxdepth)
- tree->maxdepth = depth + 1;
-
- if (tree->dothreadedbuild)
- BLI_thread_unlock(LOCK_CUSTOM1);
-
- if (depth == 1 && tree->dothreadedbuild) {
- othreads[totthread].tree = tree;
- othreads[totthread].node = child;
- othreads[totthread].begin = offset[b];
- othreads[totthread].end = offset[b] + count[b];
- othreads[totthread].depth = depth + 1;
- BLI_threadpool_insert(&threads, &othreads[totthread]);
- totthread++;
- }
- else
- occ_build_recursive(tree, child, offset[b], offset[b] + count[b], depth + 1);
- }
- }
-
- if (depth == 1 && tree->dothreadedbuild)
- BLI_threadpool_end(&threads);
- }
-
- /* combine area, position and sh */
- for (b = 0; b < TOTCHILD; b++) {
- if (node->childflag & (1 << b)) {
- child = &tmpnode;
- occ_node_from_face(tree->face + node->child[b].face, &tmpnode);
- }
- else {
- child = node->child[b].node;
- }
-
- if (child) {
- node->area += child->area;
- sh_add(node->sh, node->sh, child->sh);
- madd_v3_v3fl(node->co, child->co, child->area);
- }
- }
-
- if (node->area != 0.0f)
- mul_v3_fl(node->co, 1.0f / node->area);
-
- /* compute maximum distance from center */
- node->dco = 0.0f;
- if (node->area > 0.0f)
- occ_build_dco(tree, node, node->co, &node->dco);
-}
-
-static void occ_build_sh_normalize(OccNode *node)
-{
- /* normalize spherical harmonics to not include area, so
- * we can clamp the dot product and then multiply by area */
- int b;
-
- if (node->area != 0.0f)
- sh_mul(node->sh, 1.0f / node->area);
-
- for (b = 0; b < TOTCHILD; b++) {
- if (node->childflag & (1 << b)) {
- /* pass */
- }
- else if (node->child[b].node) {
- occ_build_sh_normalize(node->child[b].node);
- }
- }
-}
-
-static OcclusionTree *occ_tree_build(Render *re)
-{
- const int num_threads = re->r.threads;
- OcclusionTree *tree;
- ObjectInstanceRen *obi;
- ObjectRen *obr;
- Material *ma;
- VlakRen *vlr = NULL;
- int a, b, c, totface;
-
- /* count */
- totface = 0;
- for (obi = re->instancetable.first; obi; obi = obi->next) {
- obr = obi->obr;
- for (a = 0; a < obr->totvlak; a++) {
- if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak;
- else vlr++;
-
- ma = vlr->mat;
-
- if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE))
- totface++;
- }
- }
-
- if (totface == 0)
- return NULL;
-
- tree = MEM_callocN(sizeof(OcclusionTree), "OcclusionTree");
- tree->totface = totface;
-
- /* parameters */
- tree->error = get_render_aosss_error(&re->r, re->wrld.ao_approx_error);
- tree->distfac = (re->wrld.aomode & WO_AODIST) ? re->wrld.aodistfac : 0.0f;
- tree->doindirect = (re->wrld.ao_indirect_energy > 0.0f && re->wrld.ao_indirect_bounces > 0);
-
- /* allocation */
- tree->arena = BLI_memarena_new(0x8000 * sizeof(OccNode), "occ tree arena");
- BLI_memarena_use_calloc(tree->arena);
-
- if (re->wrld.aomode & WO_AOCACHE)
- tree->cache = MEM_callocN(sizeof(OcclusionCache) * num_threads, "OcclusionCache");
-
- tree->face = MEM_callocN(sizeof(OccFace) * totface, "OcclusionFace");
- tree->co = MEM_callocN(sizeof(float) * 3 * totface, "OcclusionCo");
- tree->occlusion = MEM_callocN(sizeof(float) * totface, "OcclusionOcclusion");
-
- if (tree->doindirect)
- tree->rad = MEM_callocN(sizeof(float) * 3 * totface, "OcclusionRad");
-
- /* make array of face pointers */
- for (b = 0, c = 0, obi = re->instancetable.first; obi; obi = obi->next, c++) {
- obr = obi->obr;
- for (a = 0; a < obr->totvlak; a++) {
- if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak;
- else vlr++;
-
- ma = vlr->mat;
-
- if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) {
- tree->face[b].obi = c;
- tree->face[b].facenr = a;
- tree->occlusion[b] = 1.0f;
- occ_face(&tree->face[b], tree->co[b], NULL, NULL);
- b++;
- }
- }
- }
-
- /* threads */
- tree->totbuildthread = (re->r.threads > 1 && totface > 10000) ? 8 : 1;
- tree->dothreadedbuild = (tree->totbuildthread > 1);
-
- /* recurse */
- tree->root = BLI_memarena_alloc(tree->arena, sizeof(OccNode));
- tree->maxdepth = 1;
- occ_build_recursive(tree, tree->root, 0, totface, 1);
-
- if (tree->doindirect) {
- if (!(re->test_break(re->tbh)))
- occ_build_shade(re, tree);
-
- if (!(re->test_break(re->tbh)))
- occ_sum_occlusion(tree, tree->root);
- }
-
- MEM_freeN(tree->co);
- tree->co = NULL;
-
- if (!(re->test_break(re->tbh)))
- occ_build_sh_normalize(tree->root);
-
- for (a = 0; a < num_threads; a++)
- tree->stack[a] = MEM_callocN(sizeof(OccNode) * TOTCHILD * (tree->maxdepth + 1), "OccStack");
-
- tree->num_threads = num_threads;
-
- return tree;
-}
-
-static void occ_free_tree(OcclusionTree *tree)
-{
- int a;
-
- if (tree) {
- if (tree->arena) BLI_memarena_free(tree->arena);
- for (a = 0; a < tree->num_threads; a++)
- if (tree->stack[a])
- MEM_freeN(tree->stack[a]);
- if (tree->occlusion) MEM_freeN(tree->occlusion);
- if (tree->cache) MEM_freeN(tree->cache);
- if (tree->face) MEM_freeN(tree->face);
- if (tree->rad) MEM_freeN(tree->rad);
- MEM_freeN(tree);
- }
-}
-
-/* ------------------------- Traversal --------------------------- */
-
-static float occ_solid_angle(OccNode *node, const float v[3], float d2, float invd2, const float receivenormal[3])
-{
- float dotreceive, dotemit;
- float ev[3];
-
- ev[0] = -v[0] * invd2;
- ev[1] = -v[1] * invd2;
- ev[2] = -v[2] * invd2;
- dotemit = sh_eval(node->sh, ev);
- dotreceive = dot_v3v3(receivenormal, v) * invd2;
-
- CLAMP(dotemit, 0.0f, 1.0f);
- CLAMP(dotreceive, 0.0f, 1.0f);
-
- return ((node->area * dotemit * dotreceive) / (d2 + node->area * INVPI)) * INVPI;
-}
-
-static float occ_form_factor(OccFace *face, float *p, float *n)
-{
- ObjectInstanceRen *obi;
- VlakRen *vlr;
- float v1[3], v2[3], v3[3], v4[3], q0[3], q1[3], q2[3], q3[3], contrib = 0.0f;
-
- obi = &R.objectinstance[face->obi];
- vlr = RE_findOrAddVlak(obi->obr, face->facenr);
-
- copy_v3_v3(v1, vlr->v1->co);
- copy_v3_v3(v2, vlr->v2->co);
- copy_v3_v3(v3, vlr->v3->co);
-
- if (obi->flag & R_TRANSFORMED) {
- mul_m4_v3(obi->mat, v1);
- mul_m4_v3(obi->mat, v2);
- mul_m4_v3(obi->mat, v3);
- }
-
- if (form_factor_visible_quad(p, n, v1, v2, v3, q0, q1, q2, q3))
- contrib += form_factor_quad(p, n, q0, q1, q2, q3);
-
- if (vlr->v4) {
- copy_v3_v3(v4, vlr->v4->co);
- if (obi->flag & R_TRANSFORMED)
- mul_m4_v3(obi->mat, v4);
-
- if (form_factor_visible_quad(p, n, v1, v3, v4, q0, q1, q2, q3))
- contrib += form_factor_quad(p, n, q0, q1, q2, q3);
- }
-
- return contrib;
-}
-
-static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude,
- const float pp[3], const float pn[3], float *occ, float rad[3], float bentn[3])
-{
- OccNode *node, **stack;
- OccFace *face;
- float resultocc, resultrad[3], v[3], p[3], n[3], co[3], invd2;
- float distfac, fac, error, d2, weight, emitarea;
- int b, f, totstack;
-
- /* init variables */
- copy_v3_v3(p, pp);
- copy_v3_v3(n, pn);
- madd_v3_v3fl(p, n, 1e-4f);
-
- if (bentn)
- copy_v3_v3(bentn, n);
-
- error = tree->error;
- distfac = tree->distfac;
-
- resultocc = 0.0f;
- zero_v3(resultrad);
-
- /* init stack */
- stack = tree->stack[thread];
- stack[0] = tree->root;
- totstack = 1;
-
- while (totstack) {
- /* pop point off the stack */
- node = stack[--totstack];
-
- sub_v3_v3v3(v, node->co, p);
- d2 = dot_v3v3(v, v) + 1e-16f;
- emitarea = MAX2(node->area, node->dco);
-
- if (d2 * error > emitarea) {
- if (distfac != 0.0f) {
- fac = 1.0f / (1.0f + distfac * d2);
- if (fac < 0.01f)
- continue;
- }
- else
- fac = 1.0f;
-
- /* accumulate occlusion from spherical harmonics */
- invd2 = 1.0f / sqrtf(d2);
- weight = occ_solid_angle(node, v, d2, invd2, n);
-
- if (rad)
- madd_v3_v3fl(resultrad, node->rad, weight * fac);
-
- weight *= node->occlusion;
-
- if (bentn) {
- bentn[0] -= weight * invd2 * v[0];
- bentn[1] -= weight * invd2 * v[1];
- bentn[2] -= weight * invd2 * v[2];
- }
-
- resultocc += weight * fac;
- }
- else {
- /* traverse into children */
- for (b = 0; b < TOTCHILD; b++) {
- if (node->childflag & (1 << b)) {
- f = node->child[b].face;
- face = &tree->face[f];
-
- /* accumulate occlusion with face form factor */
- if (!exclude || !(face->obi == exclude->obi && face->facenr == exclude->facenr)) {
- if (bentn || distfac != 0.0f) {
- occ_face(face, co, NULL, NULL);
- sub_v3_v3v3(v, co, p);
- d2 = dot_v3v3(v, v) + 1e-16f;
-
- fac = (distfac == 0.0f) ? 1.0f : 1.0f / (1.0f + distfac * d2);
- if (fac < 0.01f)
- continue;
- }
- else
- fac = 1.0f;
-
- weight = occ_form_factor(face, p, n);
-
- if (rad)
- madd_v3_v3fl(resultrad, tree->rad[f], weight * fac);
-
- weight *= tree->occlusion[f];
-
- if (bentn) {
- invd2 = 1.0f / sqrtf(d2);
- bentn[0] -= weight * invd2 * v[0];
- bentn[1] -= weight * invd2 * v[1];
- bentn[2] -= weight * invd2 * v[2];
- }
-
- resultocc += weight * fac;
- }
- }
- else if (node->child[b].node) {
- /* push child on the stack */
- stack[totstack++] = node->child[b].node;
- }
- }
- }
- }
-
- if (occ) *occ = resultocc;
- if (rad) copy_v3_v3(rad, resultrad);
-#if 0
- if (rad && exclude) {
- int a;
- for (a = 0; a < tree->totface; a++)
- if ((tree->face[a].obi == exclude->obi && tree->face[a].facenr == exclude->facenr))
- copy_v3_v3(rad, tree->rad[a]);
- }
-#endif
- if (bentn) normalize_v3(bentn);
-}
-
-static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce)
-{
- float (*rad)[3], (*sum)[3], (*tmp)[3], co[3], n[3], occ;
- int bounce, i;
-
- rad = MEM_callocN(sizeof(float) * 3 * tree->totface, "OcclusionBounceRad");
- sum = MEM_dupallocN(tree->rad);
-
- for (bounce = 1; bounce < totbounce; bounce++) {
- for (i = 0; i < tree->totface; i++) {
- occ_face(&tree->face[i], co, n, NULL);
- madd_v3_v3fl(co, n, 1e-8f);
-
- occ_lookup(tree, 0, &tree->face[i], co, n, &occ, rad[i], NULL);
- rad[i][0] = MAX2(rad[i][0], 0.0f);
- rad[i][1] = MAX2(rad[i][1], 0.0f);
- rad[i][2] = MAX2(rad[i][2], 0.0f);
- add_v3_v3(sum[i], rad[i]);
-
- if (re->test_break(re->tbh))
- break;
- }
-
- if (re->test_break(re->tbh))
- break;
-
- tmp = tree->rad;
- tree->rad = rad;
- rad = tmp;
-
- occ_sum_occlusion(tree, tree->root);
- }
-
- MEM_freeN(rad);
- MEM_freeN(tree->rad);
- tree->rad = sum;
-
- if (!re->test_break(re->tbh))
- occ_sum_occlusion(tree, tree->root);
-}
-
-static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass)
-{
- float *occ, co[3], n[3];
- int pass, i;
-
- occ = MEM_callocN(sizeof(float) * tree->totface, "OcclusionPassOcc");
-
- for (pass = 0; pass < totpass; pass++) {
- for (i = 0; i < tree->totface; i++) {
- occ_face(&tree->face[i], co, n, NULL);
- negate_v3(n);
- madd_v3_v3fl(co, n, 1e-8f);
-
- occ_lookup(tree, 0, &tree->face[i], co, n, &occ[i], NULL, NULL);
- if (re->test_break(re->tbh))
- break;
- }
-
- if (re->test_break(re->tbh))
- break;
-
- for (i = 0; i < tree->totface; i++) {
- tree->occlusion[i] -= occ[i]; //MAX2(1.0f-occ[i], 0.0f);
- if (tree->occlusion[i] < 0.0f)
- tree->occlusion[i] = 0.0f;
- }
-
- occ_sum_occlusion(tree, tree->root);
- }
-
- MEM_freeN(occ);
-}
-
-static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude,
- const float co[3], const float n[3], int thread, int onlyshadow,
- float *ao, float *env, float *indirect)
-{
- float nn[3], bn[3], fac, occ, occlusion, correction, rad[3];
- int envcolor;
-
- envcolor = re->wrld.aocolor;
- if (onlyshadow)
- envcolor = WO_AOPLAIN;
-
- negate_v3_v3(nn, n);
-
- occ_lookup(tree, thread, exclude, co, nn, &occ, (tree->doindirect) ? rad : NULL, (env && envcolor) ? bn : NULL);
-
- correction = re->wrld.ao_approx_correction;
-
- occlusion = (1.0f - correction) * (1.0f - occ);
- CLAMP(occlusion, 0.0f, 1.0f);
- if (correction != 0.0f)
- occlusion += correction * expf(-occ);
-
- if (env) {
- /* sky shading using bent normal */
- if (ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) {
- fac = 0.5f * (1.0f + dot_v3v3(bn, re->grvec));
- env[0] = (1.0f - fac) * re->wrld.horr + fac * re->wrld.zenr;
- env[1] = (1.0f - fac) * re->wrld.horg + fac * re->wrld.zeng;
- env[2] = (1.0f - fac) * re->wrld.horb + fac * re->wrld.zenb;
-
- mul_v3_fl(env, occlusion);
- }
- else {
- env[0] = occlusion;
- env[1] = occlusion;
- env[2] = occlusion;
- }
-#if 0
- else { /* WO_AOSKYTEX */
- float dxyview[3];
- bn[0] = -bn[0];
- bn[1] = -bn[1];
- bn[2] = -bn[2];
- dxyview[0] = 1.0f;
- dxyview[1] = 1.0f;
- dxyview[2] = 0.0f;
- shadeSkyView(ao, co, bn, dxyview);
- }
-#endif
- }
-
- if (ao) {
- ao[0] = occlusion;
- ao[1] = occlusion;
- ao[2] = occlusion;
- }
-
- if (tree->doindirect) copy_v3_v3(indirect, rad);
- else zero_v3(indirect);
-}
-
-/* ---------------------------- Caching ------------------------------- */
-
-static OcclusionCacheSample *find_occ_sample(OcclusionCache *cache, int x, int y)
-{
- x -= cache->x;
- y -= cache->y;
-
- x /= cache->step;
- y /= cache->step;
- x *= cache->step;
- y *= cache->step;
-
- if (x < 0 || x >= cache->w || y < 0 || y >= cache->h)
- return NULL;
- else
- return &cache->sample[y * cache->w + x];
-}
-
-static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int y, int thread, float *ao, float *env, float *indirect)
-{
- OcclusionCache *cache;
- OcclusionCacheSample *samples[4], *sample;
- float wn[4], wz[4], wb[4], tx, ty, w, totw, mino, maxo;
- float d[3], dist2;
- int i, x1, y1, x2, y2;
-
- if (!tree->cache)
- return 0;
-
- /* first try to find a sample in the same pixel */
- cache = &tree->cache[thread];
-
- if (cache->sample && cache->step) {
- sample = &cache->sample[(y - cache->y) * cache->w + (x - cache->x)];
- if (sample->filled) {
- sub_v3_v3v3(d, sample->co, co);
- dist2 = dot_v3v3(d, d);
- if (dist2 < 0.5f * sample->dist2 && dot_v3v3(sample->n, n) > 0.98f) {
- copy_v3_v3(ao, sample->ao);
- copy_v3_v3(env, sample->env);
- copy_v3_v3(indirect, sample->indirect);
- return 1;
- }
- }
- }
- else
- return 0;
-
- /* try to interpolate between 4 neighboring pixels */
- samples[0] = find_occ_sample(cache, x, y);
- samples[1] = find_occ_sample(cache, x + cache->step, y);
- samples[2] = find_occ_sample(cache, x, y + cache->step);
- samples[3] = find_occ_sample(cache, x + cache->step, y + cache->step);
-
- for (i = 0; i < 4; i++)
- if (!samples[i] || !samples[i]->filled)
- return 0;
-
- /* require intensities not being too different */
- mino = min_ffff(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity);
- maxo = max_ffff(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity);
-
- if (maxo - mino > 0.05f)
- return 0;
-
- /* compute weighted interpolation between samples */
- zero_v3(ao);
- zero_v3(env);
- zero_v3(indirect);
- totw = 0.0f;
-
- x1 = samples[0]->x;
- y1 = samples[0]->y;
- x2 = samples[3]->x;
- y2 = samples[3]->y;
-
- tx = (float)(x2 - x) / (float)(x2 - x1);
- ty = (float)(y2 - y) / (float)(y2 - y1);
-
- wb[3] = (1.0f - tx) * (1.0f - ty);
- wb[2] = (tx) * (1.0f - ty);
- wb[1] = (1.0f - tx) * (ty);
- wb[0] = tx * ty;
-
- for (i = 0; i < 4; i++) {
- sub_v3_v3v3(d, samples[i]->co, co);
- //dist2 = dot_v3v3(d, d);
-
- wz[i] = 1.0f; //(samples[i]->dist2/(1e-4f + dist2));
- wn[i] = pow(dot_v3v3(samples[i]->n, n), 32.0f);
-
- w = wb[i] * wn[i] * wz[i];
-
- totw += w;
- madd_v3_v3fl(ao, samples[i]->ao, w);
- madd_v3_v3fl(env, samples[i]->env, w);
- madd_v3_v3fl(indirect, samples[i]->indirect, w);
- }
-
- if (totw >= 0.9f) {
- totw = 1.0f / totw;
- mul_v3_fl(ao, totw);
- mul_v3_fl(env, totw);
- mul_v3_fl(indirect, totw);
- return 1;
- }
-
- return 0;
-}
-
-static void sample_occ_surface(ShadeInput *shi)
-{
- StrandRen *strand = shi->strand;
- StrandSurface *mesh = strand->buffer->surface;
- const int *face, *index = RE_strandren_get_face(shi->obr, strand, 0);
- float w[4], *co1, *co2, *co3, *co4;
-
- if (mesh && mesh->face && mesh->co && mesh->ao && index) {
- face = mesh->face[*index];
-
- co1 = mesh->co[face[0]];
- co2 = mesh->co[face[1]];
- co3 = mesh->co[face[2]];
-
- if (face[3]) {
- co4 = mesh->co[face[3]];
- interp_weights_quad_v3(w, co1, co2, co3, co4, strand->vert->co);
- }
- else {
- interp_weights_tri_v3(w, co1, co2, co3, strand->vert->co);
- }
-
- zero_v3(shi->ao);
- zero_v3(shi->env);
- zero_v3(shi->indirect);
-
- madd_v3_v3fl(shi->ao, mesh->ao[face[0]], w[0]);
- madd_v3_v3fl(shi->env, mesh->env[face[0]], w[0]);
- madd_v3_v3fl(shi->indirect, mesh->indirect[face[0]], w[0]);
- madd_v3_v3fl(shi->ao, mesh->ao[face[1]], w[1]);
- madd_v3_v3fl(shi->env, mesh->env[face[1]], w[1]);
- madd_v3_v3fl(shi->indirect, mesh->indirect[face[1]], w[1]);
- madd_v3_v3fl(shi->ao, mesh->ao[face[2]], w[2]);
- madd_v3_v3fl(shi->env, mesh->env[face[2]], w[2]);
- madd_v3_v3fl(shi->indirect, mesh->indirect[face[2]], w[2]);
- if (face[3]) {
- madd_v3_v3fl(shi->ao, mesh->ao[face[3]], w[3]);
- madd_v3_v3fl(shi->env, mesh->env[face[3]], w[3]);
- madd_v3_v3fl(shi->indirect, mesh->indirect[face[3]], w[3]);
- }
- }
- else {
- shi->ao[0] = 1.0f;
- shi->ao[1] = 1.0f;
- shi->ao[2] = 1.0f;
- zero_v3(shi->env);
- zero_v3(shi->indirect);
- }
-}
-
-/* ------------------------- External Functions --------------------------- */
-
-static void *exec_strandsurface_sample(void *data)
-{
- OcclusionThread *othread = (OcclusionThread *)data;
- Render *re = othread->re;
- StrandSurface *mesh = othread->mesh;
- float ao[3], env[3], indirect[3], co[3], n[3], *co1, *co2, *co3, *co4;
- int a, *face;
-
- for (a = othread->begin; a < othread->end; a++) {
- face = mesh->face[a];
- co1 = mesh->co[face[0]];
- co2 = mesh->co[face[1]];
- co3 = mesh->co[face[2]];
-
- if (face[3]) {
- co4 = mesh->co[face[3]];
-
- mid_v3_v3v3(co, co1, co3);
- normal_quad_v3(n, co1, co2, co3, co4);
- }
- else {
- mid_v3_v3v3v3(co, co1, co2, co3);
- normal_tri_v3(n, co1, co2, co3);
- }
- negate_v3(n);
-
- sample_occ_tree(re, re->occlusiontree, NULL, co, n, othread->thread, 0, ao, env, indirect);
- copy_v3_v3(othread->faceao[a], ao);
- copy_v3_v3(othread->faceenv[a], env);
- copy_v3_v3(othread->faceindirect[a], indirect);
- }
-
- return NULL;
-}
-
-void make_occ_tree(Render *re)
-{
- OcclusionThread othreads[BLENDER_MAX_THREADS];
- OcclusionTree *tree;
- StrandSurface *mesh;
- ListBase threads;
- float ao[3], env[3], indirect[3], (*faceao)[3], (*faceenv)[3], (*faceindirect)[3];
- int a, totface, totthread, *face, *count;
-
- /* ugly, needed for occ_face */
- R = *re;
-
- re->i.infostr = IFACE_("Occlusion preprocessing");
- re->stats_draw(re->sdh, &re->i);
-
- re->occlusiontree = tree = occ_tree_build(re);
-
- if (tree && !re->test_break(re->tbh)) {
- if (re->wrld.ao_approx_passes > 0)
- occ_compute_passes(re, tree, re->wrld.ao_approx_passes);
- if (tree->doindirect && (re->wrld.mode & WO_INDIRECT_LIGHT))
- occ_compute_bounces(re, tree, re->wrld.ao_indirect_bounces);
-
- for (mesh = re->strandsurface.first; mesh; mesh = mesh->next) {
- if (!mesh->face || !mesh->co || !mesh->ao)
- continue;
-
- count = MEM_callocN(sizeof(int) * mesh->totvert, "OcclusionCount");
- faceao = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceAO");
- faceenv = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceEnv");
- faceindirect = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceIndirect");
-
- totthread = (mesh->totface > 10000) ? re->r.threads : 1;
- totface = mesh->totface / totthread;
- for (a = 0; a < totthread; a++) {
- othreads[a].re = re;
- othreads[a].faceao = faceao;
- othreads[a].faceenv = faceenv;
- othreads[a].faceindirect = faceindirect;
- othreads[a].thread = a;
- othreads[a].mesh = mesh;
- othreads[a].begin = a * totface;
- othreads[a].end = (a == totthread - 1) ? mesh->totface : (a + 1) * totface;
- }
-
- if (totthread == 1) {
- exec_strandsurface_sample(&othreads[0]);
- }
- else {
- BLI_threadpool_init(&threads, exec_strandsurface_sample, totthread);
-
- for (a = 0; a < totthread; a++)
- BLI_threadpool_insert(&threads, &othreads[a]);
-
- BLI_threadpool_end(&threads);
- }
-
- for (a = 0; a < mesh->totface; a++) {
- face = mesh->face[a];
-
- copy_v3_v3(ao, faceao[a]);
- copy_v3_v3(env, faceenv[a]);
- copy_v3_v3(indirect, faceindirect[a]);
-
- add_v3_v3(mesh->ao[face[0]], ao);
- add_v3_v3(mesh->env[face[0]], env);
- add_v3_v3(mesh->indirect[face[0]], indirect);
- count[face[0]]++;
- add_v3_v3(mesh->ao[face[1]], ao);
- add_v3_v3(mesh->env[face[1]], env);
- add_v3_v3(mesh->indirect[face[1]], indirect);
- count[face[1]]++;
- add_v3_v3(mesh->ao[face[2]], ao);
- add_v3_v3(mesh->env[face[2]], env);
- add_v3_v3(mesh->indirect[face[2]], indirect);
- count[face[2]]++;
-
- if (face[3]) {
- add_v3_v3(mesh->ao[face[3]], ao);
- add_v3_v3(mesh->env[face[3]], env);
- add_v3_v3(mesh->indirect[face[3]], indirect);
- count[face[3]]++;
- }
- }
-
- for (a = 0; a < mesh->totvert; a++) {
- if (count[a]) {
- mul_v3_fl(mesh->ao[a], 1.0f / count[a]);
- mul_v3_fl(mesh->env[a], 1.0f / count[a]);
- mul_v3_fl(mesh->indirect[a], 1.0f / count[a]);
- }
- }
-
- MEM_freeN(count);
- MEM_freeN(faceao);
- MEM_freeN(faceenv);
- MEM_freeN(faceindirect);
- }
- }
-}
-
-void free_occ(Render *re)
-{
- if (re->occlusiontree) {
- occ_free_tree(re->occlusiontree);
- re->occlusiontree = NULL;
- }
-}
-
-void sample_occ(Render *re, ShadeInput *shi)
-{
- OcclusionTree *tree = re->occlusiontree;
- OcclusionCache *cache;
- OcclusionCacheSample *sample;
- OccFace exclude;
- int onlyshadow;
-
- if (tree) {
- if (shi->strand) {
- sample_occ_surface(shi);
- }
- /* try to get result from the cache if possible */
- else if (shi->depth != 0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao, shi->env, shi->indirect)) {
- /* no luck, let's sample the occlusion */
- exclude.obi = shi->obi - re->objectinstance;
- exclude.facenr = shi->vlr->index;
- onlyshadow = (shi->mat->mode & MA_ONLYSHADOW);
- sample_occ_tree(re, tree, &exclude, shi->co, shi->vno, shi->thread, onlyshadow, shi->ao, shi->env, shi->indirect);
-
- /* fill result into sample, each time */
- if (tree->cache) {
- cache = &tree->cache[shi->thread];
-
- if (cache->sample && cache->step) {
- sample = &cache->sample[(shi->ys - cache->y) * cache->w + (shi->xs - cache->x)];
- copy_v3_v3(sample->co, shi->co);
- copy_v3_v3(sample->n, shi->vno);
- copy_v3_v3(sample->ao, shi->ao);
- copy_v3_v3(sample->env, shi->env);
- copy_v3_v3(sample->indirect, shi->indirect);
- sample->intensity = max_fff(sample->ao[0], sample->ao[1], sample->ao[2]);
- sample->intensity = max_ff(sample->intensity, max_fff(sample->env[0], sample->env[1], sample->env[2]));
- sample->intensity = max_ff(sample->intensity, max_fff(sample->indirect[0], sample->indirect[1], sample->indirect[2]));
- sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco);
- sample->filled = 1;
- }
- }
- }
- }
- else {
- shi->ao[0] = 1.0f;
- shi->ao[1] = 1.0f;
- shi->ao[2] = 1.0f;
-
- shi->env[0] = 0.0f;
- shi->env[1] = 0.0f;
- shi->env[2] = 0.0f;
-
- shi->indirect[0] = 0.0f;
- shi->indirect[1] = 0.0f;
- shi->indirect[2] = 0.0f;
- }
-}
-
-void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp)
-{
- OcclusionTree *tree = re->occlusiontree;
- PixStr ps;
- OcclusionCache *cache;
- OcclusionCacheSample *sample;
- OccFace exclude;
- ShadeInput *shi;
- intptr_t *rd = NULL;
- int *ro = NULL, *rp = NULL, *rz = NULL, onlyshadow;
- int x, y, step = CACHE_STEP;
-
- if (!tree->cache)
- return;
-
- cache = &tree->cache[pa->thread];
- cache->w = pa->rectx;
- cache->h = pa->recty;
- cache->x = pa->disprect.xmin;
- cache->y = pa->disprect.ymin;
- cache->step = step;
- cache->sample = MEM_callocN(sizeof(OcclusionCacheSample) * cache->w * cache->h, "OcclusionCacheSample");
- sample = cache->sample;
-
- if (re->osa) {
- rd = pa->rectdaps;
- }
- else {
- /* fake pixel struct for non-osa */
- ps.next = NULL;
- ps.mask = 0xFFFF;
-
- ro = pa->recto;
- rp = pa->rectp;
- rz = pa->rectz;
- }
-
- /* compute a sample at every step pixels */
- for (y = pa->disprect.ymin; y < pa->disprect.ymax; y++) {
- for (x = pa->disprect.xmin; x < pa->disprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) {
- if (!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax - 1))
- continue;
- if (!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax - 1))
- continue;
-
- if (re->osa) {
- if (!*rd) continue;
-
- shade_samples_fill_with_ps(ssamp, (PixStr *)(*rd), x, y);
- }
- else {
- if (!*rp) continue;
-
- ps.obi = *ro;
- ps.facenr = *rp;
- ps.z = *rz;
- shade_samples_fill_with_ps(ssamp, &ps, x, y);
- }
-
- shi = ssamp->shi;
- if (shi->vlr) {
- onlyshadow = (shi->mat->mode & MA_ONLYSHADOW);
- exclude.obi = shi->obi - re->objectinstance;
- exclude.facenr = shi->vlr->index;
- sample_occ_tree(re, tree, &exclude, shi->co, shi->vno, shi->thread, onlyshadow, shi->ao, shi->env, shi->indirect);
-
- copy_v3_v3(sample->co, shi->co);
- copy_v3_v3(sample->n, shi->vno);
- copy_v3_v3(sample->ao, shi->ao);
- copy_v3_v3(sample->env, shi->env);
- copy_v3_v3(sample->indirect, shi->indirect);
- sample->intensity = max_fff(sample->ao[0], sample->ao[1], sample->ao[2]);
- sample->intensity = max_ff(sample->intensity, max_fff(sample->env[0], sample->env[1], sample->env[2]));
- sample->intensity = max_ff(sample->intensity, max_fff(sample->indirect[0], sample->indirect[1], sample->indirect[2]));
- sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco);
- sample->x = shi->xs;
- sample->y = shi->ys;
- sample->filled = 1;
- }
-
- if (re->test_break(re->tbh))
- break;
- }
- }
-}
-
-void free_occ_samples(Render *re, RenderPart *pa)
-{
- OcclusionTree *tree = re->occlusiontree;
- OcclusionCache *cache;
-
- if (tree->cache) {
- cache = &tree->cache[pa->thread];
-
- if (cache->sample)
- MEM_freeN(cache->sample);
-
- cache->w = 0;
- cache->h = 0;
- cache->step = 0;
- }
-}
-
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 9ad9c653e54..dd2042d3220 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -92,6 +92,7 @@
#include "RE_engine.h"
#include "RE_pipeline.h"
+#include "RE_render_ext.h"
#ifdef WITH_FREESTYLE
# include "FRS_freestyle.h"
@@ -100,14 +101,10 @@
#include "DEG_depsgraph.h"
/* internal */
+#include "initrender.h"
+#include "renderpipeline.h"
#include "render_result.h"
#include "render_types.h"
-#include "renderpipeline.h"
-#include "renderdatabase.h"
-#include "rendercore.h"
-#include "initrender.h"
-#include "pixelblending.h"
-#include "zbuf.h"
/* render flow
*
@@ -142,19 +139,10 @@ static struct {
ListBase renderlist;
} RenderGlobal = {{NULL, NULL}};
-/* hardcopy of current render, used while rendering for speed */
-Render R;
-
/* ********* alloc and free ******** */
static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovieHandle *mh, const int totvideos, const char *name_override);
-static volatile int g_break = 0;
-static int thread_break(void *UNUSED(arg))
-{
- return g_break;
-}
-
/* default callbacks, set in each new render */
static void result_nothing(void *UNUSED(arg), RenderResult *UNUSED(rr)) {}
static void result_rcti_nothing(void *UNUSED(arg), RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect)) {}
@@ -289,18 +277,6 @@ RenderLayer *render_get_active_layer(Render *re, RenderResult *rr)
return rr->layers.first;
}
-static int UNUSED_FUNCTION(render_scene_needs_vector)(Render *re)
-{
- ViewLayer *view_layer;
- for (view_layer = re->view_layers.first; view_layer; view_layer = view_layer->next)
- if (view_layer->flag & VIEW_LAYER_RENDER) {
- if (view_layer->passflag & SCE_PASS_VECTOR) {
- return 1;
- }
- }
- return 0;
-}
-
static bool render_scene_has_layers_to_render(Scene *scene)
{
ViewLayer *view_layer;
@@ -525,9 +501,6 @@ Render *RE_NewRender(const char *name)
RE_InitRenderCB(re);
- /* init some variables */
- re->ycor = 1.0f;
-
return re;
}
@@ -598,9 +571,6 @@ void RE_FreeRender(Render *re)
re->main = NULL;
re->scene = NULL;
- RE_Database_Free(re); /* view render can still have full database */
- free_sample_tables(re);
-
render_result_free(re->result);
render_result_free(re->pushedresult);
@@ -665,19 +635,12 @@ void RE_FreePersistentData(void)
/* ********* initialize state ******** */
/* clear full sample and tile flags if needed */
-static int check_mode_full_sample(RenderData *rd, ViewRender *view_render)
+static int check_mode_full_sample(RenderData *rd)
{
- const char *engine_id = view_render->engine_id;
int scemode = rd->scemode;
- if (!STREQ(engine_id, RE_engine_id_BLENDER_RENDER) &&
- !STREQ(engine_id, RE_engine_id_BLENDER_GAME))
- {
- scemode &= ~R_FULL_SAMPLE;
- }
-
- if ((rd->mode & R_OSA) == 0)
- scemode &= ~R_FULL_SAMPLE;
+ /* not supported by any current renderer */
+ scemode &= ~R_FULL_SAMPLE;
#ifdef WITH_OPENEXR
if (scemode & R_FULL_SAMPLE)
@@ -697,7 +660,7 @@ static void re_init_resolution(Render *re, Render *source,
re->winy = winy;
if (source && (source->r.mode & R_BORDER)) {
/* eeh, doesn't seem original bordered disprect is storing anywhere
- * after insertion on black happening in do_render_fields_blur_3d(),
+ * after insertion on black happening in do_render(),
* so for now simply re-calculate disprect using border from source
* renderer (sergey)
*/
@@ -726,9 +689,6 @@ static void re_init_resolution(Render *re, Render *source,
re->rectx = winx;
re->recty = winy;
}
-
- /* we clip faces with a minimum of 2 pixel boundary outside of image border. see zbuf.c */
- re->clipcrop = 1.0f + 2.0f / (float)(re->winx > re->winy ? re->winy : re->winx);
}
void render_copy_renderdata(RenderData *to, RenderData *from)
@@ -742,16 +702,11 @@ void render_copy_renderdata(RenderData *to, RenderData *from)
curvemapping_copy_data(&to->mblur_shutter_curve, &from->mblur_shutter_curve);
}
-void render_copy_viewrender(ViewRender *to, ViewRender *from)
-{
- BKE_viewrender_copy(to, from);
-}
-
/* what doesn't change during entire render sequence */
/* disprect is optional, if NULL it assumes full window render */
void RE_InitState(Render *re, Render *source, RenderData *rd,
ListBase *render_layers, const int active_layer,
- ViewRender *view_render, ViewLayer *view_layer,
+ ViewLayer *view_layer,
int winx, int winy, rcti *disprect)
{
bool had_freestyle = (re->r.mode & R_EDGE_FRS) != 0;
@@ -762,7 +717,6 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
/* copy render data and render layers for thread safety */
render_copy_renderdata(&re->r, rd);
- render_copy_viewrender(&re->view_render, view_render);
BLI_freelistN(&re->view_layers);
BLI_duplicatelist(&re->view_layers, render_layers);
re->active_view_layer = active_layer;
@@ -795,24 +749,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
return;
}
- re->r.scemode = check_mode_full_sample(&re->r, &re->view_render);
-
- /* fullsample wants uniform osa levels */
- if (source && (re->r.scemode & R_FULL_SAMPLE)) {
- /* but, if source has no full sample we disable it */
- if ((source->r.scemode & R_FULL_SAMPLE) == 0)
- re->r.scemode &= ~R_FULL_SAMPLE;
- else
- re->r.osa = re->osa = source->osa;
- }
- else {
- /* check state variables, osa? */
- if (re->r.mode & (R_OSA)) {
- re->osa = re->r.osa;
- if (re->osa > 16) re->osa = 16;
- }
- else re->osa = 0;
- }
+ re->r.scemode = check_mode_full_sample(&re->r);
if (view_layer) {
int index = BLI_findindex(render_layers, view_layer);
@@ -822,9 +759,6 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
}
}
- /* always call, checks for gamma, gamma tables and jitter too */
- make_sample_tables(re);
-
/* if preview render, we try to keep old result */
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
@@ -867,7 +801,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
}
eEvaluationMode mode = (re->r.scemode & R_VIEWPORT_PREVIEW) ? DAG_EVAL_PREVIEW : DAG_EVAL_RENDER;
- /* If we had a consistent EvaluationContext now would be the time to update it. */
+ /* This mode should have been set in the Depsgraph immediately when it was created. */
(void)mode;
/* ensure renderdatabase can use part settings correct */
@@ -875,9 +809,9 @@ void RE_InitState(Render *re, Render *source, RenderData *rd,
BLI_rw_mutex_unlock(&re->resultmutex);
- re->mblur_offs = re->field_offs = 0.f;
-
RE_init_threadcount(re);
+
+ RE_point_density_fix_linking();
}
/* This function is only called by view3d rendering, which doesn't support
@@ -970,7 +904,6 @@ void render_update_anim_renderdata(Render *re, RenderData *rd, ListBase *render_
re->r.gauss = rd->gauss;
/* motion blur */
- re->r.mblur_samples = rd->mblur_samples;
re->r.blurfac = rd->blurfac;
/* freestyle */
@@ -1098,709 +1031,21 @@ void RE_AddObject(Render *UNUSED(re), Object *UNUSED(ob))
/* *************************************** */
-static int render_display_update_enabled(Render *re)
-{
- /* don't show preprocess for previewrender sss */
- if (re->sss_points)
- return !(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW));
- else
- return 1;
-}
-
-/* the main thread call, renders an entire part */
-static void *do_part_thread(void *pa_v)
-{
- RenderPart *pa = pa_v;
-
- pa->status = PART_STATUS_IN_PROGRESS;
-
- /* need to return nicely all parts on esc */
- if (R.test_break(R.tbh) == 0) {
-
- if (!R.sss_points && (R.r.scemode & R_FULL_SAMPLE))
- pa->result = render_result_new_full_sample(&R, &pa->fullresult, &pa->disprect, pa->crop, RR_USE_MEM, R.viewname);
- else
- pa->result = render_result_new(&R, &pa->disprect, pa->crop, RR_USE_MEM, RR_ALL_LAYERS, R.viewname);
-
- /* Copy EXR tile settings, so pipeline knows whether this is a result
- * for Save Buffers enabled rendering.
- *
- * TODO(sergey): This actually duplicates logic with external engine, so
- * worth looking into more generic solution.
- */
- pa->result->do_exr_tile = R.result->do_exr_tile;
-
- if (R.sss_points)
- zbufshade_sss_tile(pa);
- else if (R.osa)
- zbufshadeDA_tile(pa);
- else
- zbufshade_tile(pa);
-
- /* we do actually write pixels, but don't allocate/deallocate anything,
- * so it is safe with other threads reading at the same time */
- BLI_rw_mutex_lock(&R.resultmutex, THREAD_LOCK_READ);
-
- /* merge too on break! */
- if (R.result->do_exr_tile) {
- render_result_exr_file_merge(R.result, pa->result, R.viewname);
- }
- else if (render_display_update_enabled(&R)) {
- /* on break, don't merge in result for preview renders, looks nicer */
- if (R.test_break(R.tbh) && (R.r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))) {
- /* pass */
- }
- else {
- render_result_merge(R.result, pa->result);
- }
- }
-
- BLI_rw_mutex_unlock(&R.resultmutex);
- }
-
- pa->status = PART_STATUS_MERGED;
-
- return NULL;
-}
-
-/* calculus for how much 1 pixel rendered should rotate the 3d geometry */
-/* is not that simple, needs to be corrected for errors of larger viewplane sizes */
-/* called in initrender.c, RE_parts_init() and convertblender.c, for speedvectors */
-float panorama_pixel_rot(Render *re)
-{
- float psize, phi, xfac;
- float borderfac = (float)BLI_rcti_size_x(&re->disprect) / (float)re->winx;
- int xparts = (re->rectx + re->partx - 1) / re->partx;
-
- /* size of 1 pixel mapped to viewplane coords */
- psize = BLI_rctf_size_x(&re->viewplane) / (float)re->winx;
- /* angle of a pixel */
- phi = atan(psize / re->clipsta);
-
- /* correction factor for viewplane shifting, first calculate how much the viewplane angle is */
- xfac = borderfac * BLI_rctf_size_x(&re->viewplane) / (float)xparts;
- xfac = atan(0.5f * xfac / re->clipsta);
- /* and how much the same viewplane angle is wrapped */
- psize = 0.5f * phi * ((float)re->partx);
-
- /* the ratio applied to final per-pixel angle */
- phi *= xfac / psize;
-
- return phi;
-}
-
-/* for panorama, we render per Y slice, and update
- * camera parameters when we go the next slice */
-static bool find_next_pano_slice(Render *re, int *slice, int *minx, rctf *viewplane)
-{
- RenderPart *pa, *best = NULL;
- bool found = false;
-
- *minx = re->winx;
-
- if (!(re->r.mode & R_PANORAMA)) {
- /* for regular render, just one 'slice' */
- found = (*slice == 0);
- (*slice)++;
- return found;
- }
-
- /* most left part of the non-rendering parts */
- for (pa = re->parts.first; pa; pa = pa->next) {
- if (pa->status == PART_STATUS_NONE && pa->nr == 0) {
- if (pa->disprect.xmin < *minx) {
- found = true;
- best = pa;
- *minx = pa->disprect.xmin;
- }
- }
- }
-
- if (best) {
- float phi = panorama_pixel_rot(re);
-
- R.panodxp = (re->winx - (best->disprect.xmin + best->disprect.xmax) ) / 2;
- R.panodxv = (BLI_rctf_size_x(viewplane) * R.panodxp) / (float)(re->winx);
-
- /* shift viewplane */
- R.viewplane.xmin = viewplane->xmin + R.panodxv;
- R.viewplane.xmax = viewplane->xmax + R.panodxv;
- RE_SetWindow(re, &R.viewplane, R.clipsta, R.clipend);
- copy_m4_m4(R.winmat, re->winmat);
-
- /* rotate database according to part coordinates */
- project_renderdata(re, projectverto, 1, -R.panodxp * phi, 1);
- R.panosi = sinf(R.panodxp * phi);
- R.panoco = cosf(R.panodxp * phi);
- }
-
- (*slice)++;
-
- return found;
-}
-
-typedef struct SortRenderPart {
- RenderPart *pa;
- long long int dist;
-} SortRenderPart;
-
-static int sort_render_part(const void *pa1, const void *pa2) {
- const SortRenderPart *rpa1 = pa1;
- const SortRenderPart *rpa2 = pa2;
-
- if (rpa1->dist > rpa2->dist) return 1;
- else if (rpa1->dist < rpa2->dist) return -1;
-
- return 0;
-}
-
-static int sort_and_queue_parts(Render *re, int minx, ThreadQueue *workqueue)
-{
- RenderPart *pa;
-
- /* long long int's needed because of overflow [#24414] */
- long long int centx = re->winx / 2, centy = re->winy / 2, tot = 1;
- int totsort = 0;
-
- /* find center of rendered parts, image center counts for 1 too */
- for (pa = re->parts.first; pa; pa = pa->next) {
- if (pa->status >= PART_STATUS_RENDERED) {
- centx += BLI_rcti_cent_x(&pa->disprect);
- centy += BLI_rcti_cent_y(&pa->disprect);
- tot++;
- }
- else if (pa->status == PART_STATUS_NONE && pa->nr == 0) {
- if (!(re->r.mode & R_PANORAMA) || pa->disprect.xmin == minx) {
- totsort++;
- }
- }
- }
- centx /= tot;
- centy /= tot;
-
- if (totsort > 0) {
- SortRenderPart *sortlist = MEM_mallocN(sizeof(*sortlist) * totsort, "renderpartsort");
- long int i = 0;
-
- /* prepare the list */
- for (pa = re->parts.first; pa; pa = pa->next) {
- if (pa->status == PART_STATUS_NONE && pa->nr == 0) {
- if (!(re->r.mode & R_PANORAMA) || pa->disprect.xmin == minx) {
- long long int distx = centx - BLI_rcti_cent_x(&pa->disprect);
- long long int disty = centy - BLI_rcti_cent_y(&pa->disprect);
- sortlist[i].dist = (long long int)sqrt(distx * distx + disty * disty);
- sortlist[i].pa = pa;
- i++;
- }
- }
- }
-
- /* Now sort it */
- qsort(sortlist, totsort, sizeof(*sortlist), sort_render_part);
-
- /* Finally flush it to the workqueue */
- for (i = 0; i < totsort; i++) {
- pa = sortlist[i].pa;
- pa->nr = i + 1; /* for nicest part, and for stats */
- BLI_thread_queue_push(workqueue, pa);
- }
-
- MEM_freeN(sortlist);
-
- return totsort;
- }
-
- return 0;
-}
-
-static void print_part_stats(Render *re, RenderPart *pa)
-{
- char str[64];
-
- BLI_snprintf(str, sizeof(str), IFACE_("%s, Part %d-%d"), re->scene->id.name + 2, pa->nr, re->i.totpart);
- re->i.infostr = str;
- re->stats_draw(re->sdh, &re->i);
- re->i.infostr = NULL;
-}
-
-typedef struct RenderThread {
- ThreadQueue *workqueue;
- ThreadQueue *donequeue;
-
- int number;
-
- void (*display_update)(void *handle, RenderResult *rr, volatile rcti *rect);
- void *duh;
-} RenderThread;
-
-static void *do_render_thread(void *thread_v)
-{
- RenderThread *thread = thread_v;
- RenderPart *pa;
-
- while ((pa = BLI_thread_queue_pop(thread->workqueue))) {
- pa->thread = thread->number;
- do_part_thread(pa);
-
- if (thread->display_update) {
- thread->display_update(thread->duh, pa->result, NULL);
- }
-
- BLI_thread_queue_push(thread->donequeue, pa);
-
- if (R.test_break(R.tbh))
- break;
- }
-
- return NULL;
-}
-
-static void UNUSED_FUNCTION(main_render_result_end)(Render *re)
-{
- if (re->result->do_exr_tile) {
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- render_result_exr_file_end(re);
- BLI_rw_mutex_unlock(&re->resultmutex);
- }
-
- if (re->r.scemode & R_EXR_CACHE_FILE) {
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- render_result_exr_file_cache_write(re);
- BLI_rw_mutex_unlock(&re->resultmutex);
- }
-}
-
-static void main_render_result_new(Render *re)
-{
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
-
- /* first step; free the entire render result, make new, and/or prepare exr buffer saving */
- if (re->result == NULL || !(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))) {
- render_result_free(re->result);
-
- if (re->sss_points && render_display_update_enabled(re))
- re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS);
- else if (re->r.scemode & R_FULL_SAMPLE)
- re->result = render_result_new_full_sample(re, &re->fullresult, &re->disprect, 0, RR_USE_EXR, RR_ALL_VIEWS);
- else
- re->result = render_result_new(re, &re->disprect, 0,
- (re->r.scemode & R_EXR_TILE_FILE) ? RR_USE_EXR : RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS);
- }
-
- BLI_rw_mutex_unlock(&re->resultmutex);
-
- if (re->result) {
- if (re->result->do_exr_tile) {
- render_result_exr_file_begin(re);
- }
- }
-}
-
-static void threaded_tile_processor(Render *re)
-{
- RenderThread thread[BLENDER_MAX_THREADS];
- ThreadQueue *workqueue, *donequeue;
- ListBase threads;
- RenderPart *pa;
- rctf viewplane = re->viewplane;
- double lastdraw, elapsed, redrawtime = 1.0f;
- int totpart = 0, minx = 0, slice = 0, a, wait;
-
- if (re->result == NULL)
- return;
-
- /* warning; no return here without closing exr file */
- RE_parts_init(re, true);
-
- /* assuming no new data gets added to dbase... */
- R = *re;
-
- /* set threadsafe break */
- R.test_break = thread_break;
-
- /* create and fill work queue */
- workqueue = BLI_thread_queue_init();
- donequeue = BLI_thread_queue_init();
-
- /* for panorama we loop over slices */
- while (find_next_pano_slice(re, &slice, &minx, &viewplane)) {
- /* gather parts into queue */
- totpart = sort_and_queue_parts(re, minx, workqueue);
-
- BLI_thread_queue_nowait(workqueue);
-
- /* start all threads */
- BLI_threadpool_init(&threads, do_render_thread, re->r.threads);
-
- for (a = 0; a < re->r.threads; a++) {
- thread[a].workqueue = workqueue;
- thread[a].donequeue = donequeue;
- thread[a].number = a;
-
- if (render_display_update_enabled(re)) {
- thread[a].display_update = re->display_update;
- thread[a].duh = re->duh;
- }
- else {
- thread[a].display_update = NULL;
- thread[a].duh = NULL;
- }
-
- BLI_threadpool_insert(&threads, &thread[a]);
- }
-
- /* wait for results to come back */
- lastdraw = PIL_check_seconds_timer();
-
- while (1) {
- elapsed = PIL_check_seconds_timer() - lastdraw;
- wait = (redrawtime - elapsed)*1000;
-
- /* handle finished part */
- if ((pa=BLI_thread_queue_pop_timeout(donequeue, wait))) {
- if (pa->result) {
- print_part_stats(re, pa);
-
- render_result_free_list(&pa->fullresult, pa->result);
- pa->result = NULL;
- re->i.partsdone++;
- re->progress(re->prh, re->i.partsdone / (float)re->i.totpart);
- }
-
- totpart--;
- }
-
- /* check for render cancel */
- if ((g_break=re->test_break(re->tbh)))
- break;
-
- /* or done with parts */
- if (totpart == 0)
- break;
-
- /* redraw in progress parts */
- elapsed = PIL_check_seconds_timer() - lastdraw;
- if (elapsed > redrawtime) {
- if (render_display_update_enabled(re))
- for (pa = re->parts.first; pa; pa = pa->next)
- if ((pa->status == PART_STATUS_IN_PROGRESS) && pa->nr && pa->result)
- re->display_update(re->duh, pa->result, &pa->result->renrect);
-
- lastdraw = PIL_check_seconds_timer();
- }
- }
-
- BLI_threadpool_end(&threads);
-
- if ((g_break=re->test_break(re->tbh)))
- break;
- }
-
- if (g_break) {
- /* review the done queue and handle all the render parts,
- * so no unfreed render result are lurking around
- */
- BLI_thread_queue_nowait(donequeue);
- while ((pa = BLI_thread_queue_pop(donequeue))) {
- if (pa->result) {
- render_result_free_list(&pa->fullresult, pa->result);
- pa->result = NULL;
- }
- }
- }
-
- BLI_thread_queue_free(donequeue);
- BLI_thread_queue_free(workqueue);
-
- if (re->result->do_exr_tile) {
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- render_result_save_empty_result_tiles(re);
- BLI_rw_mutex_unlock(&re->resultmutex);
- }
-
- /* unset threadsafety */
- g_break = 0;
- BLI_rw_mutex_lock(&re->partsmutex, THREAD_LOCK_WRITE);
- RE_parts_free(re);
- BLI_rw_mutex_unlock(&re->partsmutex);
- re->viewplane = viewplane; /* restore viewplane, modified by pano render */
-}
-
#ifdef WITH_FREESTYLE
static void init_freestyle(Render *re);
static void add_freestyle(Render *re, int render);
static void free_all_freestyle_renders(void);
#endif
-/* currently only called by preview renders and envmap */
-void RE_TileProcessor(Render *re)
-{
- main_render_result_new(re);
- threaded_tile_processor(re);
-
- re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime;
- re->stats_draw(re->sdh, &re->i);
-
-#ifdef WITH_FREESTYLE
- /* Freestyle */
- if (re->r.mode & R_EDGE_FRS) {
- if (!re->test_break(re->tbh)) {
- init_freestyle(re);
- add_freestyle(re, 1);
- free_all_freestyle_renders();
-
- re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime;
- re->stats_draw(re->sdh, &re->i);
- }
- }
-#endif
-
-}
/* ************ This part uses API, for rendering Blender scenes ********** */
static void do_render_3d(Render *re)
{
re->current_scene_update(re->suh, re->scene);
-
- /* All the rendering pipeline goes through "external" render engines. */
RE_engine_render(re, 0);
}
-/* called by blur loop, accumulate RGBA key alpha */
-static void addblur_rect_key(RenderResult *rr, float *rectf, float *rectf1, float blurfac)
-{
- float mfac = 1.0f - blurfac;
- int a, b, stride = 4 * rr->rectx;
- int len = stride * sizeof(float);
-
- for (a = 0; a < rr->recty; a++) {
- if (blurfac == 1.0f) {
- memcpy(rectf, rectf1, len);
- }
- else {
- float *rf = rectf, *rf1 = rectf1;
-
- for (b = rr->rectx; b > 0; b--, rf += 4, rf1 += 4) {
- if (rf1[3] < 0.01f)
- rf[3] = mfac * rf[3];
- else if (rf[3] < 0.01f) {
- rf[0] = rf1[0];
- rf[1] = rf1[1];
- rf[2] = rf1[2];
- rf[3] = blurfac * rf1[3];
- }
- else {
- rf[0] = mfac * rf[0] + blurfac * rf1[0];
- rf[1] = mfac * rf[1] + blurfac * rf1[1];
- rf[2] = mfac * rf[2] + blurfac * rf1[2];
- rf[3] = mfac * rf[3] + blurfac * rf1[3];
- }
- }
- }
- rectf += stride;
- rectf1 += stride;
- }
-}
-
-/* called by blur loop, accumulate renderlayers */
-static void addblur_rect(RenderResult *rr, float *rectf, float *rectf1, float blurfac, int channels)
-{
- float mfac = 1.0f - blurfac;
- int a, b, stride = channels * rr->rectx;
- int len = stride * sizeof(float);
-
- for (a = 0; a < rr->recty; a++) {
- if (blurfac == 1.0f) {
- memcpy(rectf, rectf1, len);
- }
- else {
- float *rf = rectf, *rf1 = rectf1;
-
- for (b = rr->rectx * channels; b > 0; b--, rf++, rf1++) {
- rf[0] = mfac * rf[0] + blurfac * rf1[0];
- }
- }
- rectf += stride;
- rectf1 += stride;
- }
-}
-
-
-/* called by blur loop, accumulate renderlayers */
-static void merge_renderresult_blur(RenderResult *rr, RenderResult *brr, float blurfac, bool key_alpha)
-{
- RenderLayer *rl, *rl1;
- RenderPass *rpass, *rpass1;
-
- rl1 = brr->layers.first;
- for (rl = rr->layers.first; rl && rl1; rl = rl->next, rl1 = rl1->next) {
- /* passes are allocated in sync */
- rpass1 = rl1->passes.first;
- for (rpass = rl->passes.first; rpass && rpass1; rpass = rpass->next, rpass1 = rpass1->next) {
- if (STREQ(rpass->name, RE_PASSNAME_COMBINED) && key_alpha)
- addblur_rect_key(rr, rpass->rect, rpass1->rect, blurfac);
- else
- addblur_rect(rr, rpass->rect, rpass1->rect, blurfac, rpass->channels);
- }
- }
-}
-
-/* main blur loop, can be called by fields too */
-static void do_render_blur_3d(Render *re)
-{
- RenderResult *rres;
- float blurfac;
- int blur = re->r.mblur_samples;
-
- /* create accumulation render result */
- rres = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS);
-
- /* do the blur steps */
- while (blur--) {
- re->mblur_offs = re->r.blurfac * ((float)(re->r.mblur_samples - blur)) / (float)re->r.mblur_samples;
-
- re->i.curblur = re->r.mblur_samples - blur; /* stats */
-
- do_render_3d(re);
-
- blurfac = 1.0f / (float)(re->r.mblur_samples - blur);
-
- merge_renderresult_blur(rres, re->result, blurfac, false);
- if (re->test_break(re->tbh)) break;
- }
-
- /* swap results */
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- render_result_free(re->result);
- re->result = rres;
- BLI_rw_mutex_unlock(&re->resultmutex);
-
- re->mblur_offs = 0.0f;
- re->i.curblur = 0; /* stats */
-
- /* weak... the display callback wants an active renderlayer pointer... */
- re->result->renlay = render_get_active_layer(re, re->result);
- re->display_update(re->duh, re->result, NULL);
-}
-
-
-/* function assumes rectf1 and rectf2 to be half size of rectf */
-static void interleave_rect(RenderResult *rr, float *rectf, float *rectf1, float *rectf2, int channels)
-{
- int a, stride = channels * rr->rectx;
- int len = stride * sizeof(float);
-
- for (a = 0; a < rr->recty; a += 2) {
- memcpy(rectf, rectf1, len);
- rectf += stride;
- rectf1 += stride;
- memcpy(rectf, rectf2, len);
- rectf += stride;
- rectf2 += stride;
- }
-}
-
-/* merge render results of 2 fields */
-static void merge_renderresult_fields(RenderResult *rr, RenderResult *rr1, RenderResult *rr2)
-{
- RenderLayer *rl, *rl1, *rl2;
- RenderPass *rpass, *rpass1, *rpass2;
-
- rl1 = rr1->layers.first;
- rl2 = rr2->layers.first;
- for (rl = rr->layers.first; rl && rl1 && rl2; rl = rl->next, rl1 = rl1->next, rl2 = rl2->next) {
-
- /* passes are allocated in sync */
- rpass1 = rl1->passes.first;
- rpass2 = rl2->passes.first;
- for (rpass = rl->passes.first;
- rpass && rpass1 && rpass2;
- rpass = rpass->next, rpass1 = rpass1->next, rpass2 = rpass2->next)
- {
- interleave_rect(rr, rpass->rect, rpass1->rect, rpass2->rect, rpass->channels);
- }
- }
-}
-
-
-/* interleaves 2 frames */
-static void do_render_fields_3d(Render *re)
-{
- Object *camera = RE_GetCamera(re);
- RenderResult *rr1, *rr2 = NULL;
-
- /* no render result was created, we can safely halve render y */
- re->winy /= 2;
- re->recty /= 2;
- re->disprect.ymin /= 2;
- re->disprect.ymax /= 2;
-
- re->i.curfield = 1; /* stats */
-
- /* first field, we have to call camera routine for correct aspect and subpixel offset */
- RE_SetCamera(re, camera);
- if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE) == 0)
- do_render_blur_3d(re);
- else
- do_render_3d(re);
-
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- rr1 = re->result;
- re->result = NULL;
- BLI_rw_mutex_unlock(&re->resultmutex);
-
- /* second field */
- if (!re->test_break(re->tbh)) {
-
- re->i.curfield = 2; /* stats */
-
- re->flag |= R_SEC_FIELD;
- if ((re->r.mode & R_FIELDSTILL) == 0) {
- re->field_offs = 0.5f;
- }
- RE_SetCamera(re, camera);
- if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE) == 0)
- do_render_blur_3d(re);
- else
- do_render_3d(re);
- re->flag &= ~R_SEC_FIELD;
-
- re->field_offs = 0.0f;
-
- rr2 = re->result;
- }
-
- /* allocate original height new buffers */
- re->winy *= 2;
- re->recty *= 2;
- re->disprect.ymin *= 2;
- re->disprect.ymax *= 2;
-
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS);
-
- if (rr2) {
- if (re->r.mode & R_ODDFIELD)
- merge_renderresult_fields(re->result, rr2, rr1);
- else
- merge_renderresult_fields(re->result, rr1, rr2);
-
- render_result_free(rr2);
- }
-
- render_result_free(rr1);
-
- re->i.curfield = 0; /* stats */
-
- /* weak... the display callback wants an active renderlayer pointer... */
- re->result->renlay = render_get_active_layer(re, re->result);
-
- BLI_rw_mutex_unlock(&re->resultmutex);
-
- re->display_update(re->duh, re->result, NULL);
-}
-
/* make sure disprect is not affected by the render border */
static void render_result_disprect_to_full_resolution(Render *re)
{
@@ -1861,7 +1106,7 @@ static void render_result_uncrop(Render *re)
}
/* main render routine, no compositing */
-static void do_render_fields_blur_3d(Render *re)
+static void do_render(Render *re)
{
Object *camera = RE_GetCamera(re);
/* also check for camera here */
@@ -1874,12 +1119,7 @@ static void do_render_fields_blur_3d(Render *re)
/* now use renderdata and camera to set viewplane */
RE_SetCamera(re, camera);
- if (re->r.mode & R_FIELDS)
- do_render_fields_3d(re);
- else if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE) == 0)
- do_render_blur_3d(re);
- else
- do_render_3d(re);
+ do_render_3d(re);
/* when border render, check if we have to insert it in black */
render_result_uncrop(re);
@@ -1905,7 +1145,7 @@ static void render_scene(Render *re, Scene *sce, int cfra)
}
/* initial setup */
- RE_InitState(resc, re, &sce->r, &sce->view_layers, sce->active_view_layer, &sce->view_render, NULL, winx, winy, &re->disprect);
+ RE_InitState(resc, re, &sce->r, &sce->view_layers, sce->active_view_layer, NULL, winx, winy, &re->disprect);
/* We still want to use 'rendercache' setting from org (main) scene... */
resc->r.scemode = (resc->r.scemode & ~R_EXR_CACHE_FILE) | (re->r.scemode & R_EXR_CACHE_FILE);
@@ -1914,7 +1154,6 @@ static void render_scene(Render *re, Scene *sce, int cfra)
resc->main = re->main;
resc->scene = sce;
resc->lay = sce->lay;
- resc->scene_color_manage = BKE_scene_check_color_management_enabled(sce);
/* ensure scene has depsgraph, base flags etc OK */
BKE_scene_set_background(re->main, sce);
@@ -1929,7 +1168,7 @@ static void render_scene(Render *re, Scene *sce, int cfra)
resc->current_scene_update = re->current_scene_update;
resc->suh = re->suh;
- do_render_fields_blur_3d(resc);
+ do_render(resc);
}
/* helper call to detect if this scene needs a render, or if there's a any render layer to render */
@@ -2197,12 +1436,14 @@ static void ntree_render_scenes(Render *re)
}
/* bad call... need to think over proper method still */
-static void render_composit_stats(void *UNUSED(arg), const char *str)
+static void render_composit_stats(void *arg, const char *str)
{
+ Render *re = (Render*)arg;
+
RenderStats i;
- memcpy(&i, &R.i, sizeof(i));
+ memcpy(&i, &re->i, sizeof(i));
i.infostr = str;
- R.stats_draw(R.sdh, &i);
+ re->stats_draw(re->sdh, &i);
}
#ifdef WITH_FREESTYLE
@@ -2229,63 +1470,24 @@ static void add_freestyle(Render *re, int render)
ViewLayer *view_layer, *active_view_layer;
LinkData *link;
Render *r;
- const bool do_link = (re->r.mode & R_MBLUR) == 0 || re->i.curblur == re->r.mblur_samples;
active_view_layer = BLI_findlink(&re->view_layers, re->active_view_layer);
FRS_begin_stroke_rendering(re);
for (view_layer = (ViewLayer *)re->view_layers.first; view_layer; view_layer = view_layer->next) {
- if (do_link) {
- link = (LinkData *)MEM_callocN(sizeof(LinkData), "LinkData to Freestyle render");
- BLI_addtail(&re->freestyle_renders, link);
- }
+ link = (LinkData *)MEM_callocN(sizeof(LinkData), "LinkData to Freestyle render");
+ BLI_addtail(&re->freestyle_renders, link);
+
if ((re->r.scemode & R_SINGLE_LAYER) && view_layer != active_view_layer)
continue;
if (FRS_is_freestyle_enabled(view_layer)) {
r = FRS_do_stroke_rendering(re, view_layer, render);
- if (do_link)
- link->data = (void *)r;
+ link->data = (void *)r;
}
}
FRS_end_stroke_rendering(re);
-
- /* restore the global R value (invalidated by nested execution of the internal renderer) */
- R = *re;
-}
-
-/* merges the results of Freestyle stroke rendering into a given render result */
-static void composite_freestyle_renders(Render *re, int sample)
-{
- Render *freestyle_render;
- RenderView *rv;
- ViewLayer *view_layer, *active_view_layer;
- LinkData *link;
-
- active_view_layer = BLI_findlink(&re->view_layers, re->active_view_layer);
-
- link = (LinkData *)re->freestyle_renders.first;
-
- for (rv = re->result->views.first; rv; rv = rv->next) {
- for (view_layer = (ViewLayer *)re->view_layers.first; view_layer; view_layer = view_layer->next) {
- if ((re->r.scemode & R_SINGLE_LAYER) && view_layer != active_view_layer)
- continue;
-
- if (FRS_is_freestyle_enabled(view_layer)) {
- freestyle_render = (Render *)link->data;
-
- /* may be NULL in case of empty render layer */
- if (freestyle_render) {
- render_result_exr_file_read_sample(freestyle_render, sample);
- FRS_composite_result(re, view_layer, freestyle_render);
- RE_FreeRenderResult(freestyle_render->result);
- freestyle_render->result = NULL;
- }
- }
- link = link->next;
- }
- }
}
/* releases temporary scenes and renders for Freestyle stroke rendering */
@@ -2321,238 +1523,8 @@ static void free_all_freestyle_renders(void)
}
#endif
-/* reads all buffers, calls optional composite, merges in first result->views rectf */
-static void do_merge_fullsample(Render *re, bNodeTree *ntree)
-{
- ListBase *rectfs;
- RenderView *rv;
- rcti filter_mask = re->disprect;
- float *rectf, filt[3][3];
- int x, y, sample;
- int nr, numviews;
-
- /* interaction callbacks */
- if (ntree) {
- ntree->stats_draw = render_composit_stats;
- ntree->test_break = re->test_break;
- ntree->progress = re->progress;
- ntree->sdh = re->sdh;
- ntree->tbh = re->tbh;
- ntree->prh = re->prh;
- }
-
- /* filtmask needs it */
- R = *re;
-
- /* temporary storage of the acccumulation buffers */
- rectfs = MEM_callocN(sizeof(ListBase), "fullsample accumulation buffers");
-
- numviews = BLI_listbase_count(&re->result->views);
- for (nr = 0; nr < numviews; nr++) {
- rv = MEM_callocN(sizeof(RenderView), "fullsample renderview");
-
- /* we accumulate in here */
- rv->rectf = MEM_mapallocN(re->result->rectx * re->result->recty * sizeof(float) * 4, "fullsample rgba");
- BLI_addtail(rectfs, rv);
- }
-
- for (sample = 0; sample < re->r.osa; sample++) {
- Scene *sce;
- Render *re1;
- RenderResult rres;
- int mask;
-
- /* enable full sample print */
- R.i.curfsa = sample + 1;
-
- /* set all involved renders on the samplebuffers (first was done by render itself, but needs tagged) */
- /* also function below assumes this */
-
- tag_scenes_for_render(re);
- for (sce = re->main->scene.first; sce; sce = sce->id.next) {
- if (sce->id.tag & LIB_TAG_DOIT) {
- re1 = RE_GetSceneRender(sce);
-
- if (re1 && (re1->r.scemode & R_FULL_SAMPLE)) {
- if (sample) {
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- render_result_exr_file_read_sample(re1, sample);
-#ifdef WITH_FREESTYLE
- if (re1->r.mode & R_EDGE_FRS)
- composite_freestyle_renders(re1, sample);
-#endif
- BLI_rw_mutex_unlock(&re->resultmutex);
- render_result_uncrop(re1);
- }
- ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */
- }
- }
- }
-
-#ifdef DEPSGRAPH_WORKAROUND_GROUP_HACK
- tag_groups_for_render(re);
-#endif
-
- /* composite */
- if (ntree) {
- ntreeCompositTagRender(re->scene);
- ntreeCompositTagAnimated(ntree);
-
- for (rv = re->result->views.first; rv; rv = rv->next) {
- ntreeCompositExecTree(re->scene, ntree, &re->r, true, G.background == 0, &re->scene->view_settings, &re->scene->display_settings, rv->name);
- }
- }
-
- for (nr = 0, rv = rectfs->first; rv; rv = rv->next, nr++) {
- rectf = rv->rectf;
-
- /* ensure we get either composited result or the active layer */
- RE_AcquireResultImage(re, &rres, nr);
-
- /* accumulate with filter, and clip */
- mask = (1 << sample);
- mask_array(mask, filt);
-
- for (y = 0; y < re->result->recty; y++) {
- float *rf = rectf + 4 * y * re->result->rectx;
- float *col = rres.rectf + 4 * y * re->result->rectx;
-
- for (x = 0; x < re->result->rectx; x++, rf += 4, col += 4) {
- /* clamping to 1.0 is needed for correct AA */
- CLAMP(col[0], 0.0f, 1.0f);
- CLAMP(col[1], 0.0f, 1.0f);
- CLAMP(col[2], 0.0f, 1.0f);
-
- add_filt_fmask_coord(filt, col, rf, re->result->rectx, x, y, &filter_mask);
- }
- }
-
- RE_ReleaseResultImage(re);
-
- /* show stuff */
- if (sample != re->osa - 1) {
- /* weak... the display callback wants an active renderlayer pointer... */
- re->result->renlay = render_get_active_layer(re, re->result);
- RE_SetActiveRenderView(re, rv->name);
- re->display_update(re->duh, re->result, NULL);
- }
- }
- }
-
- for (nr = 0; nr < numviews; nr++) {
- rectf = ((RenderView *)BLI_findlink(rectfs, nr))->rectf;
-
- /* clamp alpha and RGB to 0..1 and 0..inf, can go outside due to filter */
- for (y = 0; y < re->result->recty; y++) {
- float *rf = rectf + 4 * y * re->result->rectx;
-
- for (x = 0; x < re->result->rectx; x++, rf += 4) {
- rf[0] = MAX2(rf[0], 0.0f);
- rf[1] = MAX2(rf[1], 0.0f);
- rf[2] = MAX2(rf[2], 0.0f);
- CLAMP(rf[3], 0.0f, 1.0f);
- }
- }
-
- /* store the final result */
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- rv = RE_RenderViewGetById(re->result, nr);
- if (rv->rectf)
- MEM_freeN(rv->rectf);
- rv->rectf = rectf;
- BLI_rw_mutex_unlock(&re->resultmutex);
- }
-
- /* clear interaction callbacks */
- if (ntree) {
- ntree->stats_draw = NULL;
- ntree->test_break = NULL;
- ntree->progress = NULL;
- ntree->tbh = ntree->sdh = ntree->prh = NULL;
- }
-
- /* disable full sample print */
- R.i.curfsa = 0;
-
- /* garbage collection */
- while (rectfs->first) {
- rv = rectfs->first;
- BLI_remlink(rectfs, rv);
- MEM_freeN(rv);
- }
- MEM_freeN(rectfs);
-}
-
-/* called externally, via compositor */
-void RE_MergeFullSample(Render *re, Main *bmain, Scene *sce, bNodeTree *ntree)
-{
- Scene *scene;
- bNode *node;
-
- /* default start situation */
- G.is_break = false;
-
- re->main = bmain;
- re->scene = sce;
- re->scene_color_manage = BKE_scene_check_color_management_enabled(sce);
-
- /* first call RE_ReadRenderResult on every renderlayer scene. this creates Render structs */
-
- /* tag scenes unread */
- for (scene = re->main->scene.first; scene; scene = scene->id.next)
- scene->id.tag |= LIB_TAG_DOIT;
-
-#ifdef WITH_FREESTYLE
- if (re->freestyle_bmain) {
- for (scene = re->freestyle_bmain->scene.first; scene; scene = scene->id.next)
- scene->id.tag &= ~LIB_TAG_DOIT;
- }
-#endif
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_R_LAYERS && (node->flag & NODE_MUTED) == 0) {
- Scene *nodescene = (Scene *)node->id;
-
- if (nodescene == NULL) nodescene = sce;
- if (nodescene->id.tag & LIB_TAG_DOIT) {
- nodescene->r.mode |= R_OSA; /* render struct needs tables */
- RE_ReadRenderResult(sce, nodescene);
- nodescene->id.tag &= ~LIB_TAG_DOIT;
- }
- }
- }
-
- /* own render result should be read/allocated */
- if (re->scene->id.tag & LIB_TAG_DOIT) {
- RE_ReadRenderResult(re->scene, re->scene);
- re->scene->id.tag &= ~LIB_TAG_DOIT;
- }
-
- /* and now we can draw (result is there) */
- re->display_init(re->dih, re->result);
- re->display_clear(re->dch, re->result);
-
-#ifdef WITH_FREESTYLE
- if (re->r.mode & R_EDGE_FRS) {
- init_freestyle(re);
- add_freestyle(re, 0);
- }
-#endif
-
- do_merge_fullsample(re, ntree);
-
-#ifdef WITH_FREESTYLE
- free_all_freestyle_renders();
-#endif
-
-#ifdef DEPSGRAPH_WORKAROUND_GROUP_HACK
- /* Restore their visibility based on the viewport visibility flags. */
- tag_groups_for_render(re);
-#endif
-}
-
/* returns fully composited render-result on given time step (in RenderData) */
-static void do_render_composite_fields_blur_3d(Render *re)
+static void do_render_composite(Render *re)
{
bNodeTree *ntree = re->scene->nodetree;
int update_newframe = 0;
@@ -2568,7 +1540,7 @@ static void do_render_composite_fields_blur_3d(Render *re)
* it could be optimized to render only the needed view
* but what if a scene has a different number of views
* than the main scene? */
- do_render_fields_blur_3d(re);
+ do_render(re);
}
else {
re->i.cfra = re->r.cfra;
@@ -2611,27 +1583,17 @@ static void do_render_composite_fields_blur_3d(Render *re)
ntree->stats_draw = render_composit_stats;
ntree->test_break = re->test_break;
ntree->progress = re->progress;
- ntree->sdh = re->sdh;
+ ntree->sdh = re;
ntree->tbh = re->tbh;
ntree->prh = re->prh;
- /* in case it was never initialized */
- R.sdh = re->sdh;
- R.stats_draw = re->stats_draw;
- R.i.starttime = re->i.starttime;
- R.i.cfra = re->i.cfra;
-
if (update_newframe) {
/* If we have consistent depsgraph now would be a time to update them. */
}
- if (re->r.scemode & R_FULL_SAMPLE)
- do_merge_fullsample(re, ntree);
- else {
- RenderView *rv;
- for (rv = re->result->views.first; rv; rv = rv->next) {
- ntreeCompositExecTree(re->scene, ntree, &re->r, true, G.background == 0, &re->scene->view_settings, &re->scene->display_settings, rv->name);
- }
+ RenderView *rv;
+ for (rv = re->result->views.first; rv; rv = rv->next) {
+ ntreeCompositExecTree(re->scene, ntree, &re->r, true, G.background == 0, &re->scene->view_settings, &re->scene->display_settings, rv->name);
}
ntree->stats_draw = NULL;
@@ -2640,8 +1602,6 @@ static void do_render_composite_fields_blur_3d(Render *re)
ntree->tbh = ntree->sdh = ntree->prh = NULL;
}
}
- else if (re->r.scemode & R_FULL_SAMPLE)
- do_merge_fullsample(re, NULL);
}
#ifdef WITH_FREESTYLE
@@ -2733,11 +1693,10 @@ static void do_render_seq(Render *re)
tot_views = BKE_scene_multiview_num_views_get(&re->r);
ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * tot_views, "Sequencer Views ImBufs");
- EvaluationContext *eval_ctx = DEG_evaluation_context_new(DAG_EVAL_RENDER);
BKE_sequencer_new_render_data(
- eval_ctx, re->main, re->scene,
- re_x, re_y, 100,
+ re->main, re->scene,
+ re_x, re_y, 100, true,
&context);
/* the renderresult gets destroyed during the rendering, so we first collect all ibufs
@@ -2758,8 +1717,6 @@ static void do_render_seq(Render *re)
}
}
- DEG_evaluation_context_free(eval_ctx);
-
rr = re->result;
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
@@ -2815,7 +1772,7 @@ static void do_render_seq(Render *re)
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* main loop: doing sequence + fields + blur + 3d render + compositing */
+/* main loop: doing sequence + 3d render + compositing */
static void do_render_all_options(Render *re)
{
Object *camera;
@@ -2845,12 +1802,7 @@ static void do_render_all_options(Render *re)
re->display_update(re->duh, re->result, NULL);
}
else {
- re->pool = BKE_image_pool_new();
-
- do_render_composite_fields_blur_3d(re);
-
- BKE_image_pool_free(re->pool);
- re->pool = NULL;
+ do_render_composite(re);
}
re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime;
@@ -2874,7 +1826,7 @@ static void do_render_all_options(Render *re)
bool RE_force_single_renderlayer(Scene *scene)
{
- int scemode = check_mode_full_sample(&scene->r, &scene->view_render);
+ int scemode = check_mode_full_sample(&scene->r);
if (scemode & R_SINGLE_LAYER) {
ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer);
/* force layer to be enabled */
@@ -3023,7 +1975,7 @@ static int check_composite_output(Scene *scene)
bool RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *reports)
{
- int scemode = check_mode_full_sample(&scene->r, &scene->view_render);
+ int scemode = check_mode_full_sample(&scene->r);
if (scene->r.mode & R_BORDER) {
if (scene->r.border.xmax <= scene->r.border.xmin ||
@@ -3043,13 +1995,6 @@ bool RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *
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) {
@@ -3096,15 +2041,6 @@ bool RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *
#endif
}
-#ifdef WITH_FREESTYLE
- if (scene->r.mode & R_EDGE_FRS) {
- if (scene->r.mode & R_FIELDS) {
- BKE_report(reports, RPT_ERROR, "Fields not supported in Freestyle");
- return false;
- }
- }
-#endif
-
if (RE_seq_render_active(scene, &scene->r)) {
if (scene->r.mode & R_BORDER) {
BKE_report(reports, RPT_ERROR, "Border rendering is not supported by sequencer");
@@ -3123,16 +2059,9 @@ bool RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *
static void validate_render_settings(Render *re)
{
- if (re->r.scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE)) {
- /* no osa + fullsample won't work... */
- if (re->r.osa == 0)
- re->r.scemode &= ~R_FULL_SAMPLE;
- }
-
if (RE_engine_is_external(re)) {
/* not supported yet */
re->r.scemode &= ~(R_FULL_SAMPLE);
- re->r.mode &= ~(R_FIELDS | R_MBLUR);
}
}
@@ -3163,13 +2092,8 @@ const char *RE_GetActiveRenderView(Render *re)
return re->viewname;
}
-void RE_SetEngineByID(Render *re, const char *engine_id)
-{
- BLI_strncpy(re->view_render.engine_id, engine_id, sizeof(re->view_render.engine_id));
-}
-
/* evaluating scene options for general Blender render */
-static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain, Scene *scene, ViewRender *view_render,
+static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain, Scene *scene,
ViewLayer *view_layer, Object *camera_override, unsigned int lay_override,
int anim, int anim_init)
{
@@ -3199,13 +2123,11 @@ static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain,
re->main = bmain;
re->scene = scene;
- re->scene_color_manage = BKE_scene_check_color_management_enabled(scene);
re->camera_override = camera_override;
re->lay = lay_override ? lay_override : scene->lay;
re->layer_override = lay_override;
re->i.localview = (re->lay & 0xFF000000) != 0;
re->viewname[0] = '\0';
- RE_SetEngineByID(re, view_render->engine_id);
/* not too nice, but it survives anim-border render */
if (anim) {
@@ -3239,7 +2161,7 @@ static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain,
BLI_rw_mutex_unlock(&re->resultmutex);
}
- RE_InitState(re, NULL, &scene->r, &scene->view_layers, scene->active_view_layer, &scene->view_render, view_layer, winx, winy, &disprect);
+ RE_InitState(re, NULL, &scene->r, &scene->view_layers, scene->active_view_layer, view_layer, winx, winy, &disprect);
if (!re->ok) /* if an error was printed, abort */
return 0;
@@ -3270,7 +2192,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, ViewLayer *view_laye
scene->r.cfra = frame;
- if (render_initialize_from_main(re, &scene->r, bmain, scene, &scene->view_render, view_layer,
+ if (render_initialize_from_main(re, &scene->r, bmain, scene, view_layer,
camera_override, lay_override, 0, 0))
{
MEM_reset_peak_memory();
@@ -3311,9 +2233,9 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, ViewLayer *view_laye
void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, int render)
{
re->result_ok= 0;
- if (render_initialize_from_main(re, &scene->r, bmain, scene, &scene->view_render, NULL, NULL, scene->lay, 0, 0)) {
+ if (render_initialize_from_main(re, &scene->r, bmain, scene, NULL, NULL, scene->lay, 0, 0)) {
if (render)
- do_render_fields_blur_3d(re);
+ do_render_3d(re);
}
re->result_ok = 1;
}
@@ -3327,7 +2249,28 @@ void RE_RenderFreestyleExternal(Render *re)
for (rv = re->result->views.first; rv; rv = rv->next) {
RE_SetActiveRenderView(re, rv->name);
- RE_Database_CameraOnly(re, re->main, re->scene, re->lay, 1);
+
+ /* scene needs to be set to get camera */
+ Object *camera = RE_GetCamera(re);
+
+ /* if no camera, viewmat should have been set! */
+ if (camera) {
+ /* called before but need to call again in case of lens animation from the
+ * above call to BKE_scene_graph_update_for_newframe, fixes bug. [#22702].
+ * following calls don't depend on 'RE_SetCamera' */
+ float mat[4][4];
+
+ RE_SetCamera(re, camera);
+ RE_GetCameraModelMatrix(re, camera, mat);
+ invert_m4(mat);
+ RE_SetView(re, mat);
+
+ /* force correct matrix for scaled cameras */
+ DEG_id_tag_update_ex(re->main, &camera->id, OB_RECALC_OB);
+ }
+
+ printf("add freestyle\n");
+
add_freestyle(re, 1);
}
}
@@ -3605,7 +2548,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_INIT);
/* do not fully call for each frame, it initializes & pops output window */
- if (!render_initialize_from_main(re, &rd, bmain, scene, &scene->view_render, NULL, camera_override, lay_override, 0, 1))
+ if (!render_initialize_from_main(re, &rd, bmain, scene, NULL, camera_override, lay_override, 0, 1))
return;
/* MULTIVIEW_TODO:
@@ -3695,7 +2638,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
}
/* only border now, todo: camera lens. (ton) */
- render_initialize_from_main(re, &rd, bmain, scene, &scene->view_render,
+ render_initialize_from_main(re, &rd, bmain, scene,
NULL, camera_override, lay_override, 1, 0);
if (nfra != scene->r.cfra) {
@@ -3845,7 +2788,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
G.is_rendering = false;
}
-void RE_PreviewRender(Render *re, Main *bmain, Scene *sce, ViewRender *view_render)
+void RE_PreviewRender(Render *re, Main *bmain, Scene *sce)
{
Object *camera;
int winx, winy;
@@ -3853,22 +2796,16 @@ void RE_PreviewRender(Render *re, Main *bmain, Scene *sce, ViewRender *view_rend
winx = (sce->r.size * sce->r.xsch) / 100;
winy = (sce->r.size * sce->r.ysch) / 100;
- RE_InitState(re, NULL, &sce->r, &sce->view_layers, sce->active_view_layer, view_render, NULL, winx, winy, NULL);
-
- re->pool = BKE_image_pool_new();
+ RE_InitState(re, NULL, &sce->r, &sce->view_layers, sce->active_view_layer, NULL, winx, winy, NULL);
re->main = bmain;
re->scene = sce;
- re->scene_color_manage = BKE_scene_check_color_management_enabled(sce);
re->lay = sce->lay;
camera = RE_GetCamera(re);
RE_SetCamera(re, camera);
do_render_3d(re);
-
- BKE_image_pool_free(re->pool);
- re->pool = NULL;
}
/* note; repeated win/disprect calc... solve that nicer, also in compo */
@@ -3906,9 +2843,8 @@ bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
re = RE_GetSceneRender(scene);
if (re == NULL)
re = RE_NewSceneRender(scene);
- RE_InitState(re, NULL, &scene->r, &scene->view_layers, scene->active_view_layer, &scene->view_render, NULL, winx, winy, &disprect);
+ RE_InitState(re, NULL, &scene->r, &scene->view_layers, scene->active_view_layer, NULL, winx, winy, &disprect);
re->scene = scene;
- re->scene_color_manage = BKE_scene_check_color_management_enabled(scene);
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
success = render_result_exr_file_cache_read(re);
@@ -3985,67 +2921,6 @@ void RE_result_load_from_file(RenderResult *result, ReportList *reports, const c
}
}
-const float default_envmap_layout[] = { 0, 0, 1, 0, 2, 0, 0, 1, 1, 1, 2, 1 };
-
-bool RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, const char *relpath, const char imtype, float layout[12])
-{
- ImageFormatData imf;
- ImBuf *ibuf = NULL;
- int ok;
- int dx;
- int maxX = 0, maxY = 0, i = 0;
- char filepath[FILE_MAX];
-
- if (env->cube[1] == NULL) {
- BKE_report(reports, RPT_ERROR, "There is no generated environment map available to save");
- return 0;
- }
-
- imf = scene->r.im_format;
- imf.imtype = imtype;
-
- dx = env->cube[1]->x;
-
- if (env->type == ENV_CUBE) {
- for (i = 0; i < 12; i += 2) {
- maxX = max_ii(maxX, (int)layout[i] + 1);
- maxY = max_ii(maxY, (int)layout[i + 1] + 1);
- }
-
- ibuf = IMB_allocImBuf(maxX * dx, maxY * dx, 24, IB_rectfloat);
-
- for (i = 0; i < 12; i += 2)
- if (layout[i] > -1 && layout[i + 1] > -1)
- IMB_rectcpy(ibuf, env->cube[i / 2], layout[i] * dx, layout[i + 1] * dx, 0, 0, dx, dx);
- }
- else if (env->type == ENV_PLANE) {
- ibuf = IMB_allocImBuf(dx, dx, 24, IB_rectfloat);
- IMB_rectcpy(ibuf, env->cube[1], 0, 0, 0, 0, dx, dx);
- }
- else {
- BKE_report(reports, RPT_ERROR, "Invalid environment map type");
- return 0;
- }
-
- IMB_colormanagement_imbuf_for_write(ibuf, true, false, &scene->view_settings, &scene->display_settings, &imf);
-
- /* to save, we first get absolute path */
- BLI_strncpy(filepath, relpath, sizeof(filepath));
- BLI_path_abs(filepath, G.main->name);
-
- ok = BKE_imbuf_write(ibuf, filepath, &imf);
-
- IMB_freeImBuf(ibuf);
-
- if (ok) {
- return true;
- }
- else {
- BKE_report(reports, RPT_ERROR, "Error writing environment map");
- return false;
- }
-}
-
/* Used in the interface to decide whether to show layers or passes. */
bool RE_layers_have_name(struct RenderResult *rr)
{
diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c
deleted file mode 100644
index fc79786e5c7..00000000000
--- a/source/blender/render/intern/source/pixelblending.c
+++ /dev/null
@@ -1,400 +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.
- *
- * Contributor(s): Full recode, 2004-2006 Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/pixelblending.c
- * \ingroup render
- *
- * Functions to blend pixels with or without alpha, in various formats
- * nzc - June 2000
- */
-
-
-#include <math.h>
-#include <string.h>
-
-/* global includes */
-
-/* own includes */
-#include "render_types.h"
-#include "pixelblending.h"
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-
-/* ------------------------------------------------------------------------- */
-/* Debug/behavior defines */
-/* if defined: alpha blending with floats clips color, as with shorts */
-/* #define RE_FLOAT_COLOR_CLIPPING */
-/* if defined: alpha values are clipped */
-/* For now, we just keep alpha clipping. We run into thresholding and */
-/* blending difficulties otherwise. Be careful here. */
-#define RE_ALPHA_CLIPPING
-
-
-
-/* Threshold for a 'full' pixel: pixels with alpha above this level are */
-/* considered opaque This is the decimal value for 0xFFF0 / 0xFFFF */
-#define RE_FULL_COLOR_FLOAT 0.9998f
-/* Threshold for an 'empty' pixel: pixels with alpha above this level are */
-/* considered completely transparent. This is the decimal value */
-/* for 0x000F / 0xFFFF */
-#define RE_EMPTY_COLOR_FLOAT 0.0002f
-
-
-/* ------------------------------------------------------------------------- */
-
-void addAlphaOverFloat(float dest[4], const float source[4])
-{
- /* d = s + (1-alpha_s)d*/
- float mul;
-
- mul = 1.0f - source[3];
-
- dest[0] = (mul * dest[0]) + source[0];
- dest[1] = (mul * dest[1]) + source[1];
- dest[2] = (mul * dest[2]) + source[2];
- dest[3] = (mul * dest[3]) + source[3];
-
-}
-
-
-/* ------------------------------------------------------------------------- */
-
-void addAlphaUnderFloat(float dest[4], const float source[4])
-{
- float mul;
-
- mul = 1.0f - dest[3];
-
- dest[0] += (mul * source[0]);
- dest[1] += (mul * source[1]);
- dest[2] += (mul * source[2]);
- dest[3] += (mul * source[3]);
-}
-
-
-/* ------------------------------------------------------------------------- */
-void addalphaAddfacFloat(float dest[4], const float source[4], char addfac)
-{
- float m; /* weiging factor of destination */
- float c; /* intermediate color */
-
- /* Addfac is a number between 0 and 1: rescale */
- /* final target is to diminish the influence of dest when addfac rises */
- m = 1.0f - (source[3] * ((255 - addfac) / 255.0f));
-
- /* blend colors*/
- c = (m * dest[0]) + source[0];
-#ifdef RE_FLOAT_COLOR_CLIPPING
- if (c >= RE_FULL_COLOR_FLOAT) dest[0] = RE_FULL_COLOR_FLOAT;
- else
-#endif
- dest[0] = c;
-
- c = (m * dest[1]) + source[1];
-#ifdef RE_FLOAT_COLOR_CLIPPING
- if (c >= RE_FULL_COLOR_FLOAT) dest[1] = RE_FULL_COLOR_FLOAT;
- else
-#endif
- dest[1] = c;
-
- c = (m * dest[2]) + source[2];
-#ifdef RE_FLOAT_COLOR_CLIPPING
- if (c >= RE_FULL_COLOR_FLOAT) dest[2] = RE_FULL_COLOR_FLOAT;
- else
-#endif
- dest[2] = c;
-
- c = (m * dest[3]) + source[3];
-#ifdef RE_ALPHA_CLIPPING
- if (c >= RE_FULL_COLOR_FLOAT) dest[3] = RE_FULL_COLOR_FLOAT;
- else
-#endif
- dest[3] = c;
-
-}
-
-
-/* ------------------------------------------------------------------------- */
-
-/* filtered adding to scanlines */
-void add_filt_fmask(unsigned int mask, const float col[4], float *rowbuf, int row_w)
-{
- /* calc the value of mask */
- float **fmask1 = R.samples->fmask1, **fmask2 = R.samples->fmask2;
- float *rb1, *rb2, *rb3;
- float val, r, g, b, al;
- unsigned int a, maskand, maskshift;
- int j;
-
- r = col[0];
- g = col[1];
- b = col[2];
- al = col[3];
-
- rb2 = rowbuf - 4;
- rb3 = rb2 - 4 * row_w;
- rb1 = rb2 + 4 * row_w;
-
- maskand = (mask & 255);
- maskshift = (mask >> 8);
-
- for (j = 2; j >= 0; j--) {
-
- a = j;
-
- val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
- if (val != 0.0f) {
- rb1[0] += val * r;
- rb1[1] += val * g;
- rb1[2] += val * b;
- rb1[3] += val * al;
- }
- a += 3;
-
- val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
- if (val != 0.0f) {
- rb2[0] += val * r;
- rb2[1] += val * g;
- rb2[2] += val * b;
- rb2[3] += val * al;
- }
- a += 3;
-
- val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
- if (val != 0.0f) {
- rb3[0] += val * r;
- rb3[1] += val * g;
- rb3[2] += val * b;
- rb3[3] += val * al;
- }
-
- rb1 += 4;
- rb2 += 4;
- rb3 += 4;
- }
-}
-
-
-void mask_array(unsigned int mask, float filt[3][3])
-{
- float **fmask1 = R.samples->fmask1, **fmask2 = R.samples->fmask2;
- unsigned int maskand = (mask & 255);
- unsigned int maskshift = (mask >> 8);
- int a, j;
-
- for (j = 2; j >= 0; j--) {
-
- a = j;
-
- filt[2][2 - j] = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
-
- a += 3;
-
- filt[1][2 - j] = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
-
- a += 3;
-
- filt[0][2 - j] = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
- }
-}
-
-
-/**
- * Index ordering, scanline based:
- *
- * <pre>
- * --- --- ---
- * | 2,0 | 2,1 | 2,2 |
- * --- --- ---
- * | 1,0 | 1,1 | 1,2 |
- * --- --- ---
- * | 0,0 | 0,1 | 0,2 |
- * --- --- ---
- * </pre>
- */
-
-void add_filt_fmask_coord(float filt[3][3], const float col[4], float *rowbuf, int row_stride, int x, int y, rcti *mask)
-{
- float *fpoin[3][3];
- float val, r, g, b, al, lfilt[3][3];
-
- r = col[0];
- g = col[1];
- b = col[2];
- al = col[3];
-
- memcpy(lfilt, filt, sizeof(lfilt));
-
- fpoin[0][1] = rowbuf - 4 * row_stride;
- fpoin[1][1] = rowbuf;
- fpoin[2][1] = rowbuf + 4 * row_stride;
-
- fpoin[0][0] = fpoin[0][1] - 4;
- fpoin[1][0] = fpoin[1][1] - 4;
- fpoin[2][0] = fpoin[2][1] - 4;
-
- fpoin[0][2] = fpoin[0][1] + 4;
- fpoin[1][2] = fpoin[1][1] + 4;
- fpoin[2][2] = fpoin[2][1] + 4;
-
- /* limit filtering to withing a mask for border rendering, so pixels don't
- * leak outside of the border */
- if (y <= mask->ymin) {
- fpoin[0][0] = fpoin[1][0];
- fpoin[0][1] = fpoin[1][1];
- fpoin[0][2] = fpoin[1][2];
- /* filter needs the opposite value yes! */
- lfilt[0][0] = filt[2][0];
- lfilt[0][1] = filt[2][1];
- lfilt[0][2] = filt[2][2];
- }
- else if (y >= mask->ymax - 1) {
- fpoin[2][0] = fpoin[1][0];
- fpoin[2][1] = fpoin[1][1];
- fpoin[2][2] = fpoin[1][2];
-
- lfilt[2][0] = filt[0][0];
- lfilt[2][1] = filt[0][1];
- lfilt[2][2] = filt[0][2];
- }
-
- if (x <= mask->xmin) {
- fpoin[2][0] = fpoin[2][1];
- fpoin[1][0] = fpoin[1][1];
- fpoin[0][0] = fpoin[0][1];
-
- lfilt[2][0] = filt[2][2];
- lfilt[1][0] = filt[1][2];
- lfilt[0][0] = filt[0][2];
- }
- else if (x >= mask->xmax - 1) {
- fpoin[2][2] = fpoin[2][1];
- fpoin[1][2] = fpoin[1][1];
- fpoin[0][2] = fpoin[0][1];
-
- lfilt[2][2] = filt[2][0];
- lfilt[1][2] = filt[1][0];
- lfilt[0][2] = filt[0][0];
- }
-
-
- /* loop unroll */
-#define MASKFILT(i, j) \
- val = lfilt[i][j]; \
- if (val != 0.0f) { \
- float *fp = fpoin[i][j]; \
- fp[0] += val * r; \
- fp[1] += val * g; \
- fp[2] += val * b; \
- fp[3] += val * al; \
- } (void)0
-
- MASKFILT(0, 0);
- MASKFILT(0, 1);
- MASKFILT(0, 2);
- MASKFILT(1, 0);
- MASKFILT(1, 1);
- MASKFILT(1, 2);
- MASKFILT(2, 0);
- MASKFILT(2, 1);
- MASKFILT(2, 2);
-
-#undef MASKFILT
-}
-
-void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row_w, int pixsize)
-{
- /* calc the value of mask */
- float **fmask1 = R.samples->fmask1, **fmask2 = R.samples->fmask2;
- float *rb1, *rb2, *rb3;
- float val;
- unsigned int a, maskand, maskshift;
- int i, j;
-
- rb2 = rowbuf - pixsize;
- rb3 = rb2 - pixsize * row_w;
- rb1 = rb2 + pixsize * row_w;
-
- maskand = (mask & 255);
- maskshift = (mask >> 8);
-
- for (j = 2; j >= 0; j--) {
-
- a = j;
-
- val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
- if (val != 0.0f) {
- for (i = 0; i < pixsize; i++)
- rb1[i] += val * in[i];
- }
- a += 3;
-
- val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
- if (val != 0.0f) {
- for (i = 0; i < pixsize; i++)
- rb2[i] += val * in[i];
- }
- a += 3;
-
- val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift);
- if (val != 0.0f) {
- for (i = 0; i < pixsize; i++)
- rb3[i] += val * in[i];
- }
-
- rb1 += pixsize;
- rb2 += pixsize;
- rb3 += pixsize;
- }
-}
-
-/* ------------------------------------------------------------------------- */
-void addalphaAddFloat(float dest[4], const float source[4])
-{
-
- /* Makes me wonder whether this is required... */
- if (dest[3] < RE_EMPTY_COLOR_FLOAT) {
- dest[0] = source[0];
- dest[1] = source[1];
- dest[2] = source[2];
- dest[3] = source[3];
- return;
- }
-
- /* no clipping! */
- dest[0] = dest[0] + source[0];
- dest[1] = dest[1] + source[1];
- dest[2] = dest[2] + source[2];
- dest[3] = dest[3] + source[3];
-
-}
-
-
-/* ---------------------------------------------------------------------------- */
diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c
deleted file mode 100644
index ddbdb35bf51..00000000000
--- a/source/blender/render/intern/source/pixelshading.c
+++ /dev/null
@@ -1,650 +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.
- *
- * Contributor(s): 2004-2006, Blender Foundation, full recode
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/pixelshading.c
- * \ingroup render
- */
-
-
-#include <float.h>
-#include <math.h>
-#include <string.h>
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-/* External modules: */
-
-#include "DNA_group_types.h"
-#include "DNA_material_types.h"
-#include "DNA_object_types.h"
-#include "DNA_image_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_lamp_types.h"
-
-#include "BKE_material.h"
-
-
-/* own module */
-#include "render_types.h"
-#include "renderdatabase.h"
-#include "texture.h"
-#include "rendercore.h"
-#include "shadbuf.h"
-#include "pixelshading.h"
-#include "sunsky.h"
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-
-extern const float hashvectf[];
-
-static void render_lighting_halo(HaloRen *har, float col_r[3])
-{
- GroupObject *go;
- LampRen *lar;
- float i, inp, inpr, rco[3], dco[3], lv[3], lampdist, ld, t, *vn;
- float ir, ig, ib, shadfac, soft, lacol[3];
-
- ir= ig= ib= 0.0;
-
- copy_v3_v3(rco, har->co);
- dco[0]=dco[1]=dco[2]= 1.0f/har->rad;
-
- vn= har->no;
-
- for (go=R.lights.first; go; go= go->next) {
- lar= go->lampren;
-
- /* test for lamplayer */
- if (lar->mode & LA_LAYER) if ((lar->lay & har->lay)==0) continue;
-
- /* lampdist cacluation */
- if (lar->type==LA_SUN || lar->type==LA_HEMI) {
- copy_v3_v3(lv, lar->vec);
- lampdist= 1.0;
- }
- else {
- lv[0]= rco[0]-lar->co[0];
- lv[1]= rco[1]-lar->co[1];
- lv[2]= rco[2]-lar->co[2];
- ld = len_v3(lv);
- lv[0]/= ld;
- lv[1]/= ld;
- lv[2]/= ld;
-
- /* ld is re-used further on (texco's) */
-
- if (lar->mode & LA_QUAD) {
- t= 1.0;
- if (lar->ld1>0.0f)
- t= lar->dist/(lar->dist+lar->ld1*ld);
- if (lar->ld2>0.0f)
- t*= lar->distkw/(lar->distkw+lar->ld2*ld*ld);
-
- lampdist= t;
- }
- else {
- lampdist= (lar->dist/(lar->dist+ld));
- }
-
- if (lar->mode & LA_SPHERE) {
- t= lar->dist - ld;
- if (t<0.0f) continue;
-
- t/= lar->dist;
- lampdist*= (t);
- }
-
- }
-
- lacol[0]= lar->r;
- lacol[1]= lar->g;
- lacol[2]= lar->b;
-
- if (lar->mode & LA_TEXTURE) {
- ShadeInput shi;
-
- /* Warning, This is not that nice, and possibly a bit slow,
- * however some variables were not initialized properly in, unless using shade_input_initialize(...),
- * we need to do a memset */
- memset(&shi, 0, sizeof(ShadeInput));
- /* end warning! - Campbell */
-
- copy_v3_v3(shi.co, rco);
- shi.osatex= 0;
- do_lamp_tex(lar, lv, &shi, lacol, LA_TEXTURE);
- }
-
- if (lar->type==LA_SPOT) {
-
- if (lar->mode & LA_SQUARE) {
- if (lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2]>0.0f) {
- float x, lvrot[3];
-
- /* rotate view to lampspace */
- copy_v3_v3(lvrot, lv);
- mul_m3_v3(lar->imat, lvrot);
-
- x = max_ff(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2]));
- /* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */
-
- inpr = 1.0f / (sqrtf(1.0f + x * x));
- }
- else inpr= 0.0;
- }
- else {
- inpr= lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2];
- }
-
- t= lar->spotsi;
- if (inpr<t) continue;
- else {
- t= inpr-t;
- soft= 1.0;
- if (t<lar->spotbl && lar->spotbl!=0.0f) {
- /* soft area */
- i= t/lar->spotbl;
- t= i*i;
- soft= (3.0f*t-2.0f*t*i);
- inpr*= soft;
- }
- if (lar->mode & LA_ONLYSHADOW) {
- /* if (ma->mode & MA_SHADOW) { */
- /* dot product positive: front side face! */
- inp= vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2];
- if (inp>0.0f) {
- /* testshadowbuf==0.0 : 100% shadow */
- shadfac = testshadowbuf(&R, lar->shb, rco, dco, dco, inp, 0.0f);
- if ( shadfac>0.0f ) {
- shadfac*= inp*soft*lar->energy;
- ir -= shadfac;
- ig -= shadfac;
- ib -= shadfac;
-
- continue;
- }
- }
- /* } */
- }
- lampdist*=inpr;
- }
- if (lar->mode & LA_ONLYSHADOW) continue;
-
- }
-
- /* dot product and reflectivity*/
-
- inp = 1.0f - fabsf(dot_v3v3(vn, lv));
-
- /* inp= cos(0.5*M_PI-acos(inp)); */
-
- i= inp;
-
- if (lar->type==LA_HEMI) {
- i= 0.5f*i+0.5f;
- }
- if (i>0.0f) {
- i*= lampdist;
- }
-
- /* shadow */
- if (i> -0.41f) { /* heuristic valua! */
- if (lar->shb) {
- shadfac = testshadowbuf(&R, lar->shb, rco, dco, dco, inp, 0.0f);
- if (shadfac==0.0f) continue;
- i*= shadfac;
- }
- }
-
- if (i>0.0f) {
- ir+= i*lacol[0];
- ig+= i*lacol[1];
- ib+= i*lacol[2];
- }
- }
-
- if (ir<0.0f) ir= 0.0f;
- if (ig<0.0f) ig= 0.0f;
- if (ib<0.0f) ib= 0.0f;
-
- col_r[0]*= ir;
- col_r[1]*= ig;
- col_r[2]*= ib;
-
-}
-
-
-/**
- * Converts a halo z-buffer value to distance from the camera's near plane
- * \param z The z-buffer value to convert
- * \return a distance from the camera's near plane in blender units
- */
-static float haloZtoDist(int z)
-{
- float zco = 0;
-
- if (z >= 0x7FFFFF)
- return 10e10;
- else {
- zco = (float)z/(float)0x7FFFFF;
- if (R.r.mode & R_ORTHO)
- return (R.winmat[3][2] - zco*R.winmat[3][3])/(R.winmat[2][2]);
- else
- return (R.winmat[3][2])/(R.winmat[2][2] - R.winmat[2][3]*zco);
- }
-}
-
-/**
- * \param col (float[4]) Store the rgb color here (with alpha)
- * The alpha is used to blend the color to the background
- * color_new = (1-alpha)*color_background + color
- * \param zz The current zbuffer value at the place of this pixel
- * \param dist Distance of the pixel from the center of the halo squared. Given in pixels
- * \param xn The x coordinate of the pixel relaticve to the center of the halo. given in pixels
- * \param yn The y coordinate of the pixel relaticve to the center of the halo. given in pixels
- */
-int shadeHaloFloat(HaloRen *har, float col[4], int zz,
- float dist, float xn, float yn, short flarec)
-{
- /* fill in col */
- float t, zn, radist, ringf=0.0f, linef=0.0f, alpha, si, co;
- int a;
-
- if (R.wrld.mode & WO_MIST) {
- if (har->type & HA_ONLYSKY) {
- alpha= har->alfa;
- }
- else {
- /* a bit patchy... */
- alpha= mistfactor(-har->co[2], har->co)*har->alfa;
- }
- }
- else alpha= har->alfa;
-
- if (alpha==0.0f)
- return 0;
-
- /* soften the halo if it intersects geometry */
- if (har->mat && har->mat->mode & MA_HALO_SOFT) {
- float segment_length, halo_depth, distance_from_z /* , visible_depth */ /* UNUSED */, soften;
-
- /* calculate halo depth */
- segment_length= har->hasize*sasqrt(1.0f - dist/(har->rad*har->rad));
- halo_depth= 2.0f*segment_length;
-
- if (halo_depth < FLT_EPSILON)
- return 0;
-
- /* calculate how much of this depth is visible */
- distance_from_z = haloZtoDist(zz) - haloZtoDist(har->zs);
- /* visible_depth = halo_depth; */ /* UNUSED */
- if (distance_from_z < segment_length) {
- soften= (segment_length + distance_from_z)/halo_depth;
-
- /* apply softening to alpha */
- if (soften < 1.0f)
- alpha *= soften;
- if (alpha <= 0.0f)
- return 0;
- }
- }
- else {
- /* not a soft halo. use the old softening code */
- /* halo being intersected? */
- if (har->zs> zz-har->zd) {
- t= ((float)(zz-har->zs))/(float)har->zd;
- alpha*= sqrtf(sqrtf(t));
- }
- }
-
- radist = sqrtf(dist);
-
- /* watch it: not used nicely: flarec is set at zero in pixstruct */
- if (flarec) har->pixels+= (int)(har->rad-radist);
-
- if (har->ringc) {
- const float *rc;
- float fac;
- int ofs;
-
- /* per ring an antialised circle */
- ofs= har->seed;
-
- for (a= har->ringc; a>0; a--, ofs+=2) {
-
- rc= hashvectf + (ofs % 768);
-
- fac = fabsf(rc[1] * (har->rad * fabsf(rc[0]) - radist));
-
- if (fac< 1.0f) {
- ringf+= (1.0f-fac);
- }
- }
- }
-
- if (har->type & HA_VECT) {
- dist= fabsf(har->cos * (yn) - har->sin * (xn)) / har->rad;
- if (dist>1.0f) dist= 1.0f;
- if (har->tex) {
- zn= har->sin*xn - har->cos*yn;
- yn= har->cos*xn + har->sin*yn;
- xn= zn;
- }
- }
- else dist= dist/har->radsq;
-
- if (har->type & HA_FLARECIRC) {
- dist = 0.5f + fabsf(dist - 0.5f);
- }
-
- if (har->hard>=30) {
- dist = sqrtf(dist);
- if (har->hard>=40) {
- dist = sinf(dist*(float)M_PI_2);
- if (har->hard>=50) {
- dist = sqrtf(dist);
- }
- }
- }
- else if (har->hard<20) dist*=dist;
-
- if (dist < 1.0f)
- dist= (1.0f-dist);
- else
- dist= 0.0f;
-
- if (har->linec) {
- const float *rc;
- float fac;
- int ofs;
-
- /* per starpoint an antialiased line */
- ofs= har->seed;
-
- for (a= har->linec; a>0; a--, ofs+=3) {
-
- rc= hashvectf + (ofs % 768);
-
- fac = fabsf((xn) * rc[0] + (yn) * rc[1]);
-
- if (fac< 1.0f )
- linef+= (1.0f-fac);
- }
-
- linef*= dist;
- }
-
- if (har->starpoints) {
- float ster, angle;
- /* rotation */
- angle = atan2f(yn, xn);
- angle *= (1.0f+0.25f*har->starpoints);
-
- co= cosf(angle);
- si= sinf(angle);
-
- angle= (co*xn+si*yn)*(co*yn-si*xn);
-
- ster = fabsf(angle);
- if (ster>1.0f) {
- ster= (har->rad)/(ster);
-
- if (ster<1.0f) dist*= sqrtf(ster);
- }
- }
-
- /* disputable optimize... (ton) */
- if (dist<=0.00001f)
- return 0;
-
- dist*= alpha;
- ringf*= dist;
- linef*= alpha;
-
- /* The color is either the rgb spec-ed by the user, or extracted from */
- /* the texture */
- if (har->tex) {
- col[0]= har->r;
- col[1]= har->g;
- col[2]= har->b;
- col[3]= dist;
-
- do_halo_tex(har, xn, yn, col);
-
- col[0]*= col[3];
- col[1]*= col[3];
- col[2]*= col[3];
-
- }
- else {
- col[0]= dist*har->r;
- col[1]= dist*har->g;
- col[2]= dist*har->b;
- if (har->type & HA_XALPHA) col[3]= dist*dist;
- else col[3]= dist;
- }
-
- if (har->mat) {
- if (har->mat->mode & MA_HALO_SHADE) {
- /* we test for lights because of preview... */
- if (R.lights.first) render_lighting_halo(har, col);
- }
-
- /* Next, we do the line and ring factor modifications. */
- if (linef!=0.0f) {
- Material *ma= har->mat;
-
- col[0]+= linef * ma->specr;
- col[1]+= linef * ma->specg;
- col[2]+= linef * ma->specb;
-
- if (har->type & HA_XALPHA) col[3]+= linef*linef;
- else col[3]+= linef;
- }
- if (ringf!=0.0f) {
- Material *ma= har->mat;
-
- col[0]+= ringf * ma->mirr;
- col[1]+= ringf * ma->mirg;
- col[2]+= ringf * ma->mirb;
-
- if (har->type & HA_XALPHA) col[3]+= ringf*ringf;
- else col[3]+= ringf;
- }
- }
-
- /* alpha requires clip, gives black dots */
- if (col[3] > 1.0f)
- col[3]= 1.0f;
-
- return 1;
-}
-
-/* ------------------------------------------------------------------------- */
-
-/* Only view vector is important here. Result goes to col_r[3] */
-void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const float dxyview[2], short thread)
-{
- float zen[3], hor[3], blend, blendm;
- int skyflag;
-
- /* flag indicating if we render the top hemisphere */
- skyflag = WO_ZENUP;
-
- /* Some view vector stuff. */
- if (R.wrld.skytype & WO_SKYREAL) {
-
- blend = dot_v3v3(view, R.grvec);
-
- if (blend<0.0f) skyflag= 0;
-
- blend = fabsf(blend);
- }
- else if (R.wrld.skytype & WO_SKYPAPER) {
- blend= 0.5f + 0.5f * view[1];
- }
- else {
- /* the fraction of how far we are above the bottom of the screen */
- blend = fabsf(0.5f + view[1]);
- }
-
- copy_v3_v3(hor, &R.wrld.horr);
- copy_v3_v3(zen, &R.wrld.zenr);
-
- /* Careful: SKYTEX and SKYBLEND are NOT mutually exclusive! If */
- /* SKYBLEND is active, the texture and color blend are added. */
- if (R.wrld.skytype & WO_SKYTEX) {
- float lo[3];
- copy_v3_v3(lo, view);
- if (R.wrld.skytype & WO_SKYREAL) {
-
- mul_m3_v3(R.imat, lo);
-
- SWAP(float, lo[1], lo[2]);
-
- }
- do_sky_tex(rco, view, lo, dxyview, hor, zen, &blend, skyflag, thread);
- }
-
- if (blend>1.0f) blend= 1.0f;
- blendm= 1.0f-blend;
-
- /* No clipping, no conversion! */
- if (R.wrld.skytype & WO_SKYBLEND) {
- col_r[0] = (blendm*hor[0] + blend*zen[0]);
- col_r[1] = (blendm*hor[1] + blend*zen[1]);
- col_r[2] = (blendm*hor[2] + blend*zen[2]);
- }
- else {
- /* Done when a texture was grabbed. */
- col_r[0]= hor[0];
- col_r[1]= hor[1];
- col_r[2]= hor[2];
- }
-}
-
-/* shade sky according to sun lamps, all parameters are like shadeSkyView except sunsky*/
-void shadeSunView(float col_r[3], const float view[3])
-{
- GroupObject *go;
- LampRen *lar;
- float sview[3];
- bool do_init = true;
-
- for (go=R.lights.first; go; go= go->next) {
- lar= go->lampren;
- if (lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_SKY)) {
- float sun_collector[3];
- float colorxyz[3];
-
- if (do_init) {
-
- normalize_v3_v3(sview, view);
- mul_m3_v3(R.imat, sview);
- if (sview[2] < 0.0f)
- sview[2] = 0.0f;
- normalize_v3(sview);
- do_init = false;
- }
-
- GetSkyXYZRadiancef(lar->sunsky, sview, colorxyz);
- xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &sun_collector[0], &sun_collector[1], &sun_collector[2],
- lar->sunsky->sky_colorspace);
-
- ramp_blend(lar->sunsky->skyblendtype, col_r, lar->sunsky->skyblendfac, sun_collector);
- }
- }
-}
-
-
-/*
- * Stuff the sky color into the collector.
- */
-void shadeSkyPixel(float collector[4], float fx, float fy, short thread)
-{
- float view[3], dxyview[2];
-
- /*
- * The rules for sky:
- * 1. Draw an image, if a background image was provided. Stop
- * 2. get texture and color blend, and combine these.
- */
-
- float fac;
-
- if ((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) {
- /* 1. solid color */
- copy_v3_v3(collector, &R.wrld.horr);
-
- collector[3] = 0.0f;
- }
- else {
- /* 2. */
-
- /* This one true because of the context of this routine */
- if (R.wrld.skytype & WO_SKYPAPER) {
- view[0]= -1.0f + 2.0f*(fx/(float)R.winx);
- view[1]= -1.0f + 2.0f*(fy/(float)R.winy);
- view[2]= 0.0;
-
- dxyview[0]= 1.0f/(float)R.winx;
- dxyview[1]= 1.0f/(float)R.winy;
- }
- else {
- calc_view_vector(view, fx, fy);
- fac= normalize_v3(view);
-
- if (R.wrld.skytype & WO_SKYTEX) {
- dxyview[0]= -R.viewdx/fac;
- dxyview[1]= -R.viewdy/fac;
- }
- }
-
- /* get sky color in the collector */
- shadeSkyView(collector, NULL, view, dxyview, thread);
- collector[3] = 0.0f;
- }
-
- calc_view_vector(view, fx, fy);
- shadeSunView(collector, view);
-}
-
-/* aerial perspective */
-void shadeAtmPixel(struct SunSky *sunsky, float collector[3], float fx, float fy, float distance)
-{
- float view[3];
-
- calc_view_vector(view, fx, fy);
- normalize_v3(view);
- /*mul_m3_v3(R.imat, view);*/
- AtmospherePixleShader(sunsky, view, distance, collector);
-}
-
-/* eof */
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index bba422345e0..86f31f79c49 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -63,15 +63,9 @@
#include "render_types.h"
#include "texture.h"
-#include "pointdensity.h"
#include "RE_render_ext.h"
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+#include "RE_shader_ext.h"
static ThreadMutex sample_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -80,15 +74,13 @@ static int point_data_used(PointDensity *pd)
int pd_bitflag = 0;
if (pd->source == TEX_PD_PSYS) {
- if ((pd->noise_influence == TEX_PD_NOISE_VEL) ||
- (pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL) ||
+ if ((pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL) ||
(pd->color_source == TEX_PD_COLOR_PARTVEL) ||
(pd->color_source == TEX_PD_COLOR_PARTSPEED))
{
pd_bitflag |= POINT_DATA_VEL;
}
- if ((pd->noise_influence == TEX_PD_NOISE_AGE) ||
- (pd->color_source == TEX_PD_COLOR_PARTAGE) ||
+ if ((pd->color_source == TEX_PD_COLOR_PARTAGE) ||
(pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE))
{
pd_bitflag |= POINT_DATA_LIFE;
@@ -170,7 +162,7 @@ static void alloc_point_data(PointDensity *pd)
}
}
-static void pointdensity_cache_psys(const EvaluationContext *eval_ctx, Scene *scene,
+static void pointdensity_cache_psys(Depsgraph *depsgraph, Scene *scene,
PointDensity *pd,
Object *ob,
ParticleSystem *psys,
@@ -196,12 +188,12 @@ static void pointdensity_cache_psys(const EvaluationContext *eval_ctx, Scene *sc
data_used = point_data_used(pd);
if (use_render_params) {
- dm = mesh_create_derived_render(eval_ctx, scene,
+ dm = mesh_create_derived_render(depsgraph, scene,
ob,
CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL);
}
else {
- dm = mesh_get_derived_final(eval_ctx, scene,
+ dm = mesh_get_derived_final(depsgraph, scene,
ob,
CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL);
}
@@ -210,7 +202,7 @@ static void pointdensity_cache_psys(const EvaluationContext *eval_ctx, Scene *sc
return;
}
- sim.eval_ctx = eval_ctx;
+ sim.depsgraph = depsgraph;
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -391,7 +383,7 @@ static void pointdensity_cache_vertex_normal(PointDensity *pd, Object *UNUSED(ob
}
}
-static void pointdensity_cache_object(const EvaluationContext *eval_ctx, Scene *scene,
+static void pointdensity_cache_object(Depsgraph *depsgraph, Scene *scene,
PointDensity *pd,
Object *ob,
const bool use_render_params)
@@ -412,10 +404,10 @@ static void pointdensity_cache_object(const EvaluationContext *eval_ctx, Scene *
}
if (use_render_params) {
- dm = mesh_create_derived_render(eval_ctx, scene, ob, mask);
+ dm = mesh_create_derived_render(depsgraph, scene, ob, mask);
}
else {
- dm = mesh_get_derived_final(eval_ctx, scene, ob, mask);
+ dm = mesh_get_derived_final(depsgraph, scene, ob, mask);
}
mvert = dm->getVertArray(dm); /* local object space */
@@ -466,10 +458,10 @@ static void pointdensity_cache_object(const EvaluationContext *eval_ctx, Scene *
}
-static void cache_pointdensity_ex(const EvaluationContext *eval_ctx,
- Scene *scene,
- PointDensity *pd,
- const bool use_render_params)
+static void cache_pointdensity(Depsgraph *depsgraph,
+ Scene *scene,
+ PointDensity *pd,
+ const bool use_render_params)
{
if (pd == NULL) {
return;
@@ -493,7 +485,7 @@ static void cache_pointdensity_ex(const EvaluationContext *eval_ctx,
return;
}
- pointdensity_cache_psys(eval_ctx,
+ pointdensity_cache_psys(depsgraph,
scene,
pd,
ob,
@@ -503,19 +495,11 @@ static void cache_pointdensity_ex(const EvaluationContext *eval_ctx,
else if (pd->source == TEX_PD_OBJECT) {
Object *ob = pd->object;
if (ob && ob->type == OB_MESH)
- pointdensity_cache_object(eval_ctx, scene, pd, ob, use_render_params);
+ pointdensity_cache_object(depsgraph, scene, pd, ob, use_render_params);
}
}
-void cache_pointdensity(const EvaluationContext *eval_ctx, Render *re, PointDensity *pd)
-{
- cache_pointdensity_ex(eval_ctx,
- re->scene,
- pd,
- true);
-}
-
-void free_pointdensity(PointDensity *pd)
+static void free_pointdensity(PointDensity *pd)
{
if (pd == NULL) {
return;
@@ -533,41 +517,6 @@ void free_pointdensity(PointDensity *pd)
pd->totpoints = 0;
}
-void make_pointdensities(const EvaluationContext *eval_ctx, Render *re)
-{
- Tex *tex;
-
- if (re->scene->r.scemode & R_BUTS_PREVIEW) {
- return;
- }
-
- re->i.infostr = IFACE_("Caching Point Densities");
- re->stats_draw(re->sdh, &re->i);
-
- for (tex = re->main->tex.first; tex != NULL; tex = tex->id.next) {
- if (tex->id.us && tex->type == TEX_POINTDENSITY) {
- cache_pointdensity(eval_ctx, re, tex->pd);
- }
- }
-
- re->i.infostr = NULL;
- re->stats_draw(re->sdh, &re->i);
-}
-
-void free_pointdensities(Render *re)
-{
- Tex *tex;
-
- if (re->scene->r.scemode & R_BUTS_PREVIEW)
- return;
-
- for (tex = re->main->tex.first; tex != NULL; tex = tex->id.next) {
- if (tex->id.us && tex->type == TEX_POINTDENSITY) {
- free_pointdensity(tex->pd);
- }
- }
-}
-
typedef struct PointDensityRangeData {
float *density;
float squared_radius;
@@ -678,7 +627,7 @@ static int pointdensity(PointDensity *pd,
{
int retval = TEX_INT;
PointDensityRangeData pdr;
- float density = 0.0f, age = 0.0f, time = 0.0f;
+ float density = 0.0f, age = 0.0f;
float vec[3] = {0.0f, 0.0f, 0.0f}, col[3] = {0.0f, 0.0f, 0.0f}, co[3];
float turb, noise_fac;
int num = 0;
@@ -712,21 +661,8 @@ static int pointdensity(PointDensity *pd,
}
if (pd->flag & TEX_PD_TURBULENCE) {
-
- if (pd->noise_influence == TEX_PD_NOISE_AGE) {
- turb = BLI_gTurbulence(pd->noise_size, texvec[0] + age, texvec[1] + age, texvec[2] + age,
- pd->noise_depth, 0, pd->noise_basis);
- }
- else if (pd->noise_influence == TEX_PD_NOISE_TIME) {
- time = R.r.cfra / (float)R.r.efra;
- turb = BLI_gTurbulence(pd->noise_size, texvec[0] + time, texvec[1] + time, texvec[2] + time,
- pd->noise_depth, 0, pd->noise_basis);
- //turb = BLI_turbulence(pd->noise_size, texvec[0]+time, texvec[1]+time, texvec[2]+time, pd->noise_depth);
- }
- else {
- turb = BLI_gTurbulence(pd->noise_size, texvec[0] + vec[0], texvec[1] + vec[1], texvec[2] + vec[2],
- pd->noise_depth, 0, pd->noise_basis);
- }
+ turb = BLI_gTurbulence(pd->noise_size, texvec[0] + vec[0], texvec[1] + vec[1], texvec[2] + vec[2],
+ pd->noise_depth, 0, pd->noise_basis);
turb -= 0.5f; /* re-center 0.0-1.0 range around 0 to prevent offsetting result */
@@ -838,32 +774,12 @@ static int pointdensity_color(PointDensity *pd, TexResult *texres, float age, co
return retval;
}
-int pointdensitytex(Tex *tex, const float texvec[3], TexResult *texres)
-{
- PointDensity *pd = tex->pd;
- float age = 0.0f;
- float vec[3] = {0.0f, 0.0f, 0.0f};
- float col[3] = {0.0f, 0.0f, 0.0f};
- int retval = pointdensity(pd, texvec, texres, vec, &age, col);
-
- retval |= pointdensity_color(pd, texres, age, vec, col);
- BRICONTRGB;
-
- return retval;
-
-#if 0
- if (texres->nor!=NULL) {
- texres->nor[0] = texres->nor[1] = texres->nor[2] = 0.0f;
- }
-#endif
-}
-
static void sample_dummy_point_density(int resolution, float *values)
{
memset(values, 0, sizeof(float) * 4 * resolution * resolution * resolution);
}
-static void particle_system_minmax(const EvaluationContext *eval_ctx,
+static void particle_system_minmax(Depsgraph *depsgraph,
Scene *scene,
Object *object,
ParticleSystem *psys,
@@ -887,7 +803,7 @@ static void particle_system_minmax(const EvaluationContext *eval_ctx,
unit_m4(mat);
- sim.eval_ctx = eval_ctx;
+ sim.depsgraph = depsgraph;
sim.scene = scene;
sim.ob = object;
sim.psys = psys;
@@ -918,26 +834,24 @@ static void particle_system_minmax(const EvaluationContext *eval_ctx,
}
void RE_point_density_cache(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
PointDensity *pd)
{
- const bool use_render_params = (eval_ctx->mode == DAG_EVAL_RENDER);
+ const bool use_render_params = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
- Depsgraph *depsgraph = eval_ctx->depsgraph;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
/* Same matricies/resolution as dupli_render_particle_set(). */
BLI_mutex_lock(&sample_mutex);
- cache_pointdensity_ex(eval_ctx, scene, pd, use_render_params);
+ cache_pointdensity(depsgraph, scene, pd, use_render_params);
BLI_mutex_unlock(&sample_mutex);
}
void RE_point_density_minmax(
- const struct EvaluationContext *eval_ctx,
+ struct Depsgraph *depsgraph,
struct PointDensity *pd,
float r_min[3], float r_max[3])
{
- Depsgraph *depsgraph = eval_ctx->depsgraph;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
Object *object = pd->object;
if (object == NULL) {
@@ -960,7 +874,7 @@ void RE_point_density_minmax(
return;
}
- particle_system_minmax(eval_ctx,
+ particle_system_minmax(depsgraph,
scene,
object,
psys,
@@ -1019,11 +933,15 @@ static void point_density_sample_func(
texvec[1] += dim[1] * (float)y / (float)resolution;
texvec[2] += dim[2] * (float)z / (float)resolution;
- pointdensity(pd, texvec, &texres, vec, &age, col);
- pointdensity_color(pd, &texres, age, vec, col);
+ if (pointdensity(pd, texvec, &texres, vec, &age, col)) {
+ pointdensity_color(pd, &texres, age, vec, col);
- copy_v3_v3(&values[index*4 + 0], &texres.tr);
- values[index*4 + 3] = texres.tin;
+ copy_v3_v3(&values[index*4 + 0], &texres.tr);
+ values[index*4 + 3] = texres.tin;
+ }
+ else {
+ zero_v4(&values[index*4]);
+ }
}
}
}
@@ -1032,7 +950,7 @@ static void point_density_sample_func(
* NOTE 2: Frees point density structure after sampling.
*/
void RE_point_density_sample(
- const EvaluationContext *eval_ctx,
+ Depsgraph *depsgraph,
PointDensity *pd,
const int resolution,
float *values)
@@ -1050,7 +968,7 @@ void RE_point_density_sample(
}
BLI_mutex_lock(&sample_mutex);
- RE_point_density_minmax(eval_ctx,
+ RE_point_density_minmax(depsgraph,
pd,
min,
max);
@@ -1083,3 +1001,8 @@ void RE_point_density_free(struct PointDensity *pd)
{
free_pointdensity(pd);
}
+
+void RE_point_density_fix_linking(void)
+{
+}
+
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
deleted file mode 100644
index 7bac7f29c5a..00000000000
--- a/source/blender/render/intern/source/rayshade.c
+++ /dev/null
@@ -1,2474 +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) 1990-1998 NeoGeo BV.
- * All rights reserved.
- *
- * Contributors: 2004/2005 Blender Foundation, full recode
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/rayshade.c
- * \ingroup render
- */
-
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <float.h>
-#include <assert.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_material_types.h"
-#include "DNA_lamp_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_system.h"
-#include "BLI_math.h"
-#include "BLI_rand.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "BKE_node.h"
-
-#include "render_result.h"
-#include "render_types.h"
-#include "rendercore.h"
-#include "renderdatabase.h"
-#include "pixelshading.h"
-#include "shading.h"
-#include "volumetric.h"
-
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "raycounter.h"
-
-#define RAY_TRA 1
-#define RAY_INSIDE 2
-
-#define DEPTH_SHADOW_TRA 10
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-static int test_break(void *data)
-{
- Render *re = (Render *)data;
- return re->test_break(re->tbh);
-}
-
-static void RE_rayobject_config_control(RayObject *r, Render *re)
-{
- if (RE_rayobject_isRayAPI(r)) {
- r = RE_rayobject_align(r);
- r->control.data = re;
- r->control.test_break = test_break;
- }
-}
-
-RayObject *RE_rayobject_create(int type, int size, int octree_resolution)
-{
- RayObject * res = NULL;
-
- if (type == R_RAYSTRUCTURE_AUTO) {
- /* TODO */
- //if (detect_simd())
-#ifdef __SSE__
- type = BLI_cpu_support_sse2()? R_RAYSTRUCTURE_SIMD_SVBVH: R_RAYSTRUCTURE_VBVH;
-#else
- type = R_RAYSTRUCTURE_VBVH;
-#endif
- }
-
-#ifndef __SSE__
- if (type == R_RAYSTRUCTURE_SIMD_SVBVH || type == R_RAYSTRUCTURE_SIMD_QBVH) {
- puts("Warning: Using VBVH (SSE was disabled at compile time)");
- type = R_RAYSTRUCTURE_VBVH;
- }
-#endif
-
-
- if (type == R_RAYSTRUCTURE_OCTREE) //TODO dynamic ocres
- res = RE_rayobject_octree_create(octree_resolution, size);
- else if (type == R_RAYSTRUCTURE_VBVH)
- res = RE_rayobject_vbvh_create(size);
- else if (type == R_RAYSTRUCTURE_SIMD_SVBVH)
- res = RE_rayobject_svbvh_create(size);
- else if (type == R_RAYSTRUCTURE_SIMD_QBVH)
- res = RE_rayobject_qbvh_create(size);
- else
- res = RE_rayobject_vbvh_create(size); //Fallback
-
- return res;
-}
-
-static RayObject* rayobject_create(Render *re, int type, int size)
-{
- RayObject * res = NULL;
-
- res = RE_rayobject_create(type, size, re->r.ocres);
-
- if (res)
- RE_rayobject_config_control(res, re);
-
- return res;
-}
-
-#ifdef RE_RAYCOUNTER
-RayCounter re_rc_counter[BLENDER_MAX_THREADS];
-#endif
-
-
-void freeraytree(Render *re)
-{
- ObjectInstanceRen *obi;
-
- if (re->raytree) {
- RE_rayobject_free(re->raytree);
- re->raytree = NULL;
- }
- if (re->rayfaces) {
- MEM_freeN(re->rayfaces);
- re->rayfaces = NULL;
- }
- if (re->rayprimitives) {
- MEM_freeN(re->rayprimitives);
- re->rayprimitives = NULL;
- }
-
- for (obi=re->instancetable.first; obi; obi=obi->next) {
- ObjectRen *obr = obi->obr;
- if (obr->raytree) {
- RE_rayobject_free(obr->raytree);
- obr->raytree = NULL;
- }
- if (obr->rayfaces) {
- MEM_freeN(obr->rayfaces);
- obr->rayfaces = NULL;
- }
- if (obi->raytree) {
- RE_rayobject_free(obi->raytree);
- obi->raytree = NULL;
- }
- }
-
-#ifdef RE_RAYCOUNTER
- {
- const int num_threads = re->r.threads;
- RayCounter sum;
- memset(&sum, 0, sizeof(sum));
- int i;
- for (i=0; i<num_threads; i++)
- RE_RC_MERGE(&sum, re_rc_counter+i);
- RE_RC_INFO(&sum);
- }
-#endif
-}
-
-static bool is_raytraceable_vlr(Render *re, VlakRen *vlr)
-{
- /* note: volumetric must be tracable, wire must not */
- if ((re->flag & R_BAKE_TRACE) || (vlr->flag & R_TRACEBLE) || (vlr->mat->material_type == MA_TYPE_VOLUME))
- if (vlr->mat->material_type != MA_TYPE_WIRE)
- return 1;
- return 0;
-}
-
-static bool is_raytraceable(Render *re, ObjectInstanceRen *obi)
-{
- int v;
- ObjectRen *obr = obi->obr;
-
- if (re->excludeob && obr->ob == re->excludeob)
- return 0;
-
- for (v=0;v<obr->totvlak;v++) {
- VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
-
- if (is_raytraceable_vlr(re, vlr))
- return 1;
- }
-
- return 0;
-}
-
-
-RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi)
-{
- /*TODO
- * out-of-memory safeproof
- * break render
- * update render stats */
- ObjectRen *obr = obi->obr;
-
- if (obr->raytree == NULL) {
- RayObject *raytree;
- RayFace *face = NULL;
- VlakPrimitive *vlakprimitive = NULL;
- int v;
-
- //Count faces
- int faces = 0;
- for (v=0;v<obr->totvlak;v++) {
- VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
- if (is_raytraceable_vlr(re, vlr))
- faces++;
- }
-
- if (faces == 0)
- return NULL;
-
- //Create Ray cast accelaration structure
- raytree = rayobject_create( re, re->r.raytrace_structure, faces );
- if ( (re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS) )
- vlakprimitive = obr->rayprimitives = (VlakPrimitive *)MEM_callocN(faces * sizeof(VlakPrimitive), "ObjectRen primitives");
- else
- face = obr->rayfaces = (RayFace *)MEM_callocN(faces * sizeof(RayFace), "ObjectRen faces");
-
- obr->rayobi = obi;
-
- for (v=0;v<obr->totvlak;v++) {
- VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
- if (is_raytraceable_vlr(re, vlr)) {
- if ((re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS)) {
- RE_rayobject_add(raytree, RE_vlakprimitive_from_vlak(vlakprimitive, obi, vlr));
- vlakprimitive++;
- }
- else {
- RE_rayface_from_vlak(face, obi, vlr);
- RE_rayobject_add(raytree, RE_rayobject_unalignRayFace(face));
- face++;
- }
- }
- }
- RE_rayobject_done(raytree);
-
- /* in case of cancel during build, raytree is not usable */
- if (test_break(re))
- RE_rayobject_free(raytree);
- else
- obr->raytree= raytree;
- }
-
- if (obr->raytree) {
- if ((obi->flag & R_TRANSFORMED) && obi->raytree == NULL) {
- obi->transform_primitives = 0;
- obi->raytree = RE_rayobject_instance_create( obr->raytree, obi->mat, obi, obi->obr->rayobi );
- }
- }
-
- if (obi->raytree) return obi->raytree;
- return obi->obr->raytree;
-}
-
-static bool has_special_rayobject(Render *re, ObjectInstanceRen *obi)
-{
- if ( (obi->flag & R_TRANSFORMED) && (re->r.raytrace_options & R_RAYTRACE_USE_INSTANCES) ) {
- ObjectRen *obr = obi->obr;
- int v, faces = 0;
-
- for (v=0;v<obr->totvlak;v++) {
- VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
- if (is_raytraceable_vlr(re, vlr)) {
- faces++;
- if (faces > 4)
- return 1;
- }
- }
- }
- return 0;
-}
-/*
- * create a single raytrace structure with all faces
- */
-static void makeraytree_single(Render *re)
-{
- ObjectInstanceRen *obi;
- RayObject *raytree;
- RayFace *face = NULL;
- VlakPrimitive *vlakprimitive = NULL;
- int faces = 0, special = 0;
-
- for (obi = re->instancetable.first; obi; obi = obi->next) {
- if (is_raytraceable(re, obi)) {
- ObjectRen *obr = obi->obr;
-
- if (has_special_rayobject(re, obi)) {
- special++;
- }
- else {
- int v;
- for (v = 0;v < obr->totvlak; v++) {
- VlakRen *vlr = obr->vlaknodes[v >> 8].vlak + (v&255);
- if (is_raytraceable_vlr(re, vlr)) {
- faces++;
- }
- }
- }
- }
- }
-
- if (faces + special == 0) {
- re->raytree = RE_rayobject_empty_create();
- return;
- }
-
- //Create raytree
- raytree = re->raytree = rayobject_create( re, re->r.raytrace_structure, faces+special );
-
- if ( (re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS) ) {
- vlakprimitive = re->rayprimitives = (VlakPrimitive *)MEM_callocN(faces * sizeof(VlakPrimitive), "Raytrace vlak-primitives");
- }
- else {
- face = re->rayfaces = (RayFace *)MEM_callocN(faces * sizeof(RayFace), "Render ray faces");
- }
-
- for (obi=re->instancetable.first; obi; obi=obi->next)
- if (is_raytraceable(re, obi)) {
- if (test_break(re))
- break;
-
- if (has_special_rayobject(re, obi)) {
- RayObject *obj = makeraytree_object(re, obi);
-
- if (test_break(re))
- break;
-
- if (obj)
- RE_rayobject_add(re->raytree, obj);
- }
- else {
- int v;
- ObjectRen *obr = obi->obr;
-
- if (obi->flag & R_TRANSFORMED) {
- obi->transform_primitives = 1;
- }
-
- for (v=0;v<obr->totvlak;v++) {
- VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
- if (is_raytraceable_vlr(re, vlr)) {
- if ((re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS)) {
- RayObject *obj = RE_vlakprimitive_from_vlak( vlakprimitive, obi, vlr );
- RE_rayobject_add(raytree, obj);
- vlakprimitive++;
- }
- else {
- RE_rayface_from_vlak(face, obi, vlr);
- if ((obi->flag & R_TRANSFORMED)) {
- mul_m4_v3(obi->mat, face->v1);
- mul_m4_v3(obi->mat, face->v2);
- mul_m4_v3(obi->mat, face->v3);
- if (RE_rayface_isQuad(face))
- mul_m4_v3(obi->mat, face->v4);
- }
-
- RE_rayobject_add(raytree, RE_rayobject_unalignRayFace(face));
- face++;
- }
- }
- }
- }
- }
-
- if (!test_break(re)) {
- re->i.infostr = IFACE_("Raytree.. building");
- re->stats_draw(re->sdh, &re->i);
-
- RE_rayobject_done(raytree);
- }
-}
-
-void makeraytree(Render *re)
-{
- float min[3], max[3], sub[3];
- int i;
-
- re->i.infostr = IFACE_("Raytree.. preparing");
- re->stats_draw(re->sdh, &re->i);
-
- /* disable options not yet supported by octree,
- * they might actually never be supported (unless people really need it) */
- if (re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE)
- re->r.raytrace_options &= ~( R_RAYTRACE_USE_INSTANCES | R_RAYTRACE_USE_LOCAL_COORDS);
-
- makeraytree_single(re);
-
- if (test_break(re)) {
- freeraytree(re);
-
- re->i.infostr = IFACE_("Raytree building canceled");
- re->stats_draw(re->sdh, &re->i);
- }
- else {
- /* Calculate raytree max_size
- * This is ONLY needed to kept a bogus behavior of SUN and HEMI lights */
- INIT_MINMAX(min, max);
- RE_rayobject_merge_bb(re->raytree, min, max);
- if (min[0] > max[0]) { /* empty raytree */
- zero_v3(min);
- zero_v3(max);
- }
- for (i=0; i<3; i++) {
- /* TODO: explain why add top both min and max??? */
- min[i] += 0.01f;
- max[i] += 0.01f;
- sub[i] = max[i]-min[i];
- }
-
- re->maxdist = len_v3(sub);
-
- re->i.infostr = IFACE_("Raytree finished");
- re->stats_draw(re->sdh, &re->i);
- }
-
-#ifdef RE_RAYCOUNTER
- memset(re_rc_counter, 0, sizeof(re_rc_counter));
-#endif
-}
-
-/* if (shi->osatex) */
-static void shade_ray_set_derivative(ShadeInput *shi)
-{
- float detsh, t00, t10, t01, t11;
- int axis1, axis2;
-
- /* find most stable axis to project */
- axis_dominant_v3(&axis1, &axis2, shi->facenor);
-
- /* compute u,v and derivatives */
- if (shi->obi->flag & R_TRANSFORMED) {
- float v1[3], v2[3], v3[3];
-
- mul_v3_m3v3(v1, shi->obi->nmat, shi->v1->co);
- mul_v3_m3v3(v2, shi->obi->nmat, shi->v2->co);
- mul_v3_m3v3(v3, shi->obi->nmat, shi->v3->co);
-
- /* same as below */
- t00= v3[axis1]-v1[axis1]; t01= v3[axis2]-v1[axis2];
- t10= v3[axis1]-v2[axis1]; t11= v3[axis2]-v2[axis2];
- }
- else {
- const float *v1= shi->v1->co;
- const float *v2= shi->v2->co;
- const float *v3= shi->v3->co;
-
- /* same as above */
- t00= v3[axis1]-v1[axis1]; t01= v3[axis2]-v1[axis2];
- t10= v3[axis1]-v2[axis1]; t11= v3[axis2]-v2[axis2];
- }
-
- detsh= 1.0f/(t00*t11-t10*t01);
- t00*= detsh; t01*=detsh;
- t10*=detsh; t11*=detsh;
-
- shi->dx_u= shi->dxco[axis1]*t11- shi->dxco[axis2]*t10;
- shi->dx_v= shi->dxco[axis2]*t00- shi->dxco[axis1]*t01;
- shi->dy_u= shi->dyco[axis1]*t11- shi->dyco[axis2]*t10;
- shi->dy_v= shi->dyco[axis2]*t00- shi->dyco[axis1]*t01;
-
-}
-
-/* main ray shader */
-void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
-{
- ObjectInstanceRen *obi = (ObjectInstanceRen *)is->hit.ob;
- VlakRen *vlr = (VlakRen *)is->hit.face;
-
- /* set up view vector */
- copy_v3_v3(shi->view, is->dir);
-
- /* render co */
- shi->co[0]= is->start[0]+is->dist*(shi->view[0]);
- shi->co[1]= is->start[1]+is->dist*(shi->view[1]);
- shi->co[2]= is->start[2]+is->dist*(shi->view[2]);
-
- normalize_v3(shi->view);
-
- shi->obi= obi;
- shi->obr= obi->obr;
- shi->vlr= vlr;
- shi->mat= vlr->mat;
- shade_input_init_material(shi);
-
- if (is->isect==2)
- shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3);
- else
- shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2);
-
- shi->u= is->u;
- shi->v= is->v;
- shi->dx_u= shi->dx_v= shi->dy_u= shi->dy_v= 0.0f;
-
- if (shi->osatex)
- shade_ray_set_derivative(shi);
- shade_input_set_normals(shi);
-
- shade_input_set_shade_texco(shi);
- if (shi->mat->material_type == MA_TYPE_VOLUME) {
- if (ELEM(is->mode, RE_RAY_SHADOW, RE_RAY_SHADOW_TRA)) {
- shade_volume_shadow(shi, shr, is);
- }
- else {
- shade_volume_outside(shi, shr);
- }
- }
- else if (is->mode==RE_RAY_SHADOW_TRA) {
- /* temp hack to prevent recursion */
- if (shi->nodes==0 && shi->mat->nodetree && shi->mat->use_nodes) {
- ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
- shi->mat= vlr->mat; /* shi->mat is being set in nodetree */
- }
- else
- shade_color(shi, shr);
- }
- else {
- if (shi->mat->nodetree && shi->mat->use_nodes) {
- ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
- shi->mat= vlr->mat; /* shi->mat is being set in nodetree */
- }
- else {
- shade_material_loop(shi, shr);
- }
-
- /* raytrace likes to separate the spec color */
- sub_v3_v3v3(shr->diff, shr->combined, shr->spec);
- copy_v3_v3(shr->diffshad, shr->diff);
- }
-
-}
-
-static int refraction(float refract[3], const float n[3], const float view[3], float index)
-{
- float dot, fac;
-
- copy_v3_v3(refract, view);
-
- dot = dot_v3v3(view, n);
-
- if (dot>0.0f) {
- index = 1.0f/index;
- fac= 1.0f - (1.0f - dot*dot)*index*index;
- if (fac <= 0.0f) return 0;
- fac= -dot*index + sqrtf(fac);
- }
- else {
- fac= 1.0f - (1.0f - dot*dot)*index*index;
- if (fac <= 0.0f) return 0;
- fac= -dot*index - sqrtf(fac);
- }
-
- refract[0]= index*view[0] + fac*n[0];
- refract[1]= index*view[1] + fac*n[1];
- refract[2]= index*view[2] + fac*n[2];
-
- return 1;
-}
-
-static void reflection_simple(float ref[3], float n[3], const float view[3])
-{
- const float f1= -2.0f * dot_v3v3(n, view);
- madd_v3_v3v3fl(ref, view, n, f1);
-}
-
-/* orn = original face normal */
-static void reflection(float ref[3], float n[3], const float view[3], const float orn[3])
-{
- float f1;
-
- reflection_simple(ref, n, view);
-
- /* test phong normals, then we should prevent vector going to the back */
- f1= dot_v3v3(ref, orn);
- if (f1>0.0f) {
- f1+= 0.01f;
- ref[0]-= f1*orn[0];
- ref[1]-= f1*orn[1];
- ref[2]-= f1*orn[2];
- }
-}
-
-#if 0
-static void color_combine(float *result, float fac1, float fac2, float col1[3], float col2[3])
-{
- float col1t[3], col2t[3];
-
- col1t[0]= sqrt(col1[0]);
- col1t[1]= sqrt(col1[1]);
- col1t[2]= sqrt(col1[2]);
- col2t[0]= sqrt(col2[0]);
- col2t[1]= sqrt(col2[1]);
- col2t[2]= sqrt(col2[2]);
-
- result[0]= (fac1*col1t[0] + fac2*col2t[0]);
- result[0]*= result[0];
- result[1]= (fac1*col1t[1] + fac2*col2t[1]);
- result[1]*= result[1];
- result[2]= (fac1*col1t[2] + fac2*col2t[2]);
- result[2]*= result[2];
-}
-#endif
-
-static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr)
-{
- float d;
- if (0 == (shi->mat->mode & MA_TRANSP))
- return -1;
-
- if (shi->mat->tx_limit <= 0.0f) {
- d= 1.0f;
- }
- else {
- float p;
-
- /* shi.co[] calculated by shade_ray() */
- const float dx= shi->co[0] - is->start[0];
- const float dy= shi->co[1] - is->start[1];
- const float dz= shi->co[2] - is->start[2];
- d = sqrtf(dx * dx + dy * dy + dz * dz);
- if (d > shi->mat->tx_limit)
- d= shi->mat->tx_limit;
-
- p = shi->mat->tx_falloff;
- if (p < 0.0f) p= 0.0f;
- else if (p > 10.0f) p= 10.0f;
-
- shr->alpha *= powf(d, p);
- if (shr->alpha > 1.0f)
- shr->alpha= 1.0f;
- }
-
- return d;
-}
-
-static void ray_fadeout_endcolor(float col[3], ShadeInput *origshi, ShadeInput *shi, ShadeResult *shr, Isect *isec, const float vec[3])
-{
- /* un-intersected rays get either rendered material color or sky color */
- if (origshi->mat->fadeto_mir == MA_RAYMIR_FADETOMAT) {
- copy_v3_v3(col, shr->combined);
- }
- else if (origshi->mat->fadeto_mir == MA_RAYMIR_FADETOSKY) {
- copy_v3_v3(shi->view, vec);
- normalize_v3(shi->view);
-
- shadeSkyView(col, isec->start, shi->view, NULL, shi->thread);
- shadeSunView(col, shi->view);
- }
-}
-
-static void ray_fadeout(Isect *is, ShadeInput *shi, float col[3], const float blendcol[3], float dist_mir)
-{
- /* if fading out, linear blend against fade color */
- float blendfac;
-
- blendfac = 1.0f - len_v3v3(shi->co, is->start)/dist_mir;
-
- col[0] = col[0]*blendfac + (1.0f - blendfac)*blendcol[0];
- col[1] = col[1]*blendfac + (1.0f - blendfac)*blendcol[1];
- col[2] = col[2]*blendfac + (1.0f - blendfac)*blendcol[2];
-}
-
-/* the main recursive tracer itself
- * note: 'col' must be initialized */
-static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, const float start[3], const float dir[3], float col[4], ObjectInstanceRen *obi, VlakRen *vlr, int traflag)
-{
- ShadeInput shi = {NULL};
- Isect isec;
- float dist_mir = origshi->mat->dist_mir;
-
- /* with high depth the number of rays can explode due to the path splitting
- * in two each time, giving 2^depth rays. we need to be able to cancel such
- * a render to avoid hanging, a better solution would be random picking
- * between directions and russian roulette termination */
- if (R.test_break(R.tbh)) {
- zero_v4(col);
- return;
- }
-
- copy_v3_v3(isec.start, start);
- copy_v3_v3(isec.dir, dir);
- isec.dist = dist_mir > 0 ? dist_mir : RE_RAYTRACE_MAXDIST;
- isec.mode= RE_RAY_MIRROR;
- isec.check = RE_CHECK_VLR_RENDER;
- isec.skip = RE_SKIP_VLR_NEIGHBOUR;
- isec.hint = NULL;
-
- isec.orig.ob = obi;
- isec.orig.face = vlr;
- RE_RC_INIT(isec, shi);
-
- /* database is in original view, obi->imat transforms current position back to original */
- RE_instance_rotate_ray(origshi->obi, &isec);
-
- if (RE_rayobject_raycast(R.raytree, &isec)) {
- ShadeResult shr= {{0}};
- float d= 1.0f;
-
- RE_instance_rotate_ray_restore(origshi->obi, &isec);
-
- /* for as long we don't have proper dx/dy transform for rays we copy over original */
- copy_v3_v3(shi.dxco, origshi->dxco);
- copy_v3_v3(shi.dyco, origshi->dyco);
-
- shi.mask= origshi->mask;
- shi.osatex= origshi->osatex;
- shi.depth= origshi->depth + 1; /* only used to indicate tracing */
- shi.thread= origshi->thread;
- //shi.sample= 0; // memset above, so don't need this
- shi.xs= origshi->xs;
- shi.ys= origshi->ys;
- shi.do_manage= origshi->do_manage;
- shi.lay= origshi->lay;
- shi.passflag= SCE_PASS_COMBINED; /* result of tracing needs no pass info */
- shi.combinedflag= 0xFFFFFF; /* ray trace does all options */
- //shi.do_preview = false; // memset above, so don't need this
-
- shade_ray(&isec, &shi, &shr);
- /* ray has traveled inside the material, so shade by transmission */
- if (traflag & RAY_INSIDE)
- d= shade_by_transmission(&isec, &shi, &shr);
-
- if (depth>0) {
- float fr, fg, fb, f1;
-
- if ((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f && (shi.mat->mode_l & (MA_ZTRANSP | MA_RAYTRANSP))) {
- float nf, f, refract[3], tracol[4];
-
- tracol[0]= shi.r;
- tracol[1]= shi.g;
- tracol[2]= shi.b;
- tracol[3]= col[3]; /* we pass on and accumulate alpha */
-
- if ((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) {
- /* don't overwrite traflag, it's value is used in mirror reflection */
- int new_traflag = traflag;
-
- if (new_traflag & RAY_INSIDE) {
- /* inside the material, so use inverse normal */
- float norm[3];
- norm[0]= - shi.vn[0];
- norm[1]= - shi.vn[1];
- norm[2]= - shi.vn[2];
-
- if (refraction(refract, norm, shi.view, shi.ang)) {
- /* ray comes out from the material into air */
- new_traflag &= ~RAY_INSIDE;
- }
- else {
- /* total internal reflection (ray stays inside the material) */
- reflection(refract, norm, shi.view, shi.vn);
- }
- }
- else {
- if (refraction(refract, shi.vn, shi.view, shi.ang)) {
- /* ray goes in to the material from air */
- new_traflag |= RAY_INSIDE;
- }
- else {
- /* total external reflection (ray doesn't enter the material) */
- reflection(refract, shi.vn, shi.view, shi.vn);
- }
- }
- traceray(origshi, origshr, depth-1, shi.co, refract, tracol, shi.obi, shi.vlr, new_traflag);
- }
- else
- traceray(origshi, origshr, depth-1, shi.co, shi.view, tracol, shi.obi, shi.vlr, 0);
-
- f= shr.alpha; f1= 1.0f-f;
- nf= (shi.mat->mode & MA_RAYTRANSP) ? d * shi.mat->filter : 0.0f;
- fr= 1.0f+ nf*(shi.r-1.0f);
- fg= 1.0f+ nf*(shi.g-1.0f);
- fb= 1.0f+ nf*(shi.b-1.0f);
- shr.diff[0]= f*shr.diff[0] + f1*fr*tracol[0];
- shr.diff[1]= f*shr.diff[1] + f1*fg*tracol[1];
- shr.diff[2]= f*shr.diff[2] + f1*fb*tracol[2];
-
- shr.spec[0] *=f;
- shr.spec[1] *=f;
- shr.spec[2] *=f;
-
- col[3]= f1*tracol[3] + f;
- }
- else {
- col[3]= 1.0f;
- }
-
- float f;
- if (shi.mat->mode_l & MA_RAYMIRROR) {
- f= shi.ray_mirror;
- if (f!=0.0f) f*= fresnel_fac(shi.view, shi.vn, shi.mat->fresnel_mir_i, shi.mat->fresnel_mir);
- }
- else f= 0.0f;
-
- if (f!=0.0f) {
- float mircol[4];
- float ref[3];
-
- reflection_simple(ref, shi.vn, shi.view);
- traceray(origshi, origshr, depth-1, shi.co, ref, mircol, shi.obi, shi.vlr, traflag);
-
- f1= 1.0f-f;
-
- /* combine */
- //color_combine(col, f*fr*(1.0f-shr.spec[0]), f1, col, shr.diff);
- //col[0]+= shr.spec[0];
- //col[1]+= shr.spec[1];
- //col[2]+= shr.spec[2];
-
- fr= shi.mirr;
- fg= shi.mirg;
- fb= shi.mirb;
-
- col[0]= f*fr*(1.0f-shr.spec[0])*mircol[0] + f1*shr.diff[0] + shr.spec[0];
- col[1]= f*fg*(1.0f-shr.spec[1])*mircol[1] + f1*shr.diff[1] + shr.spec[1];
- col[2]= f*fb*(1.0f-shr.spec[2])*mircol[2] + f1*shr.diff[2] + shr.spec[2];
- }
- else {
- col[0]= shr.diff[0] + shr.spec[0];
- col[1]= shr.diff[1] + shr.spec[1];
- col[2]= shr.diff[2] + shr.spec[2];
- }
-
- if (dist_mir > 0.0f) {
- float blendcol[3];
-
- /* max ray distance set, but found an intersection, so fade this color
- * out towards the sky/material color for a smooth transition */
- ray_fadeout_endcolor(blendcol, origshi, &shi, origshr, &isec, dir);
- ray_fadeout(&isec, &shi, col, blendcol, dist_mir);
- }
- }
- else {
- col[0]= shr.diff[0] + shr.spec[0];
- col[1]= shr.diff[1] + shr.spec[1];
- col[2]= shr.diff[2] + shr.spec[2];
- }
-
- }
- else {
- ray_fadeout_endcolor(col, origshi, &shi, origshr, &isec, dir);
- }
- RE_RC_MERGE(&origshi->raycounter, &shi.raycounter);
-}
-
-/* **************** jitter blocks ********** */
-
-/* calc distributed planar energy */
-
-static void DP_energy(float *table, float vec[2], int tot, float xsize, float ysize)
-{
- int x, y, a;
- float *fp, force[3], result[3];
- float dx, dy, dist, min;
-
- min= MIN2(xsize, ysize);
- min*= min;
- result[0]= result[1]= 0.0f;
-
- for (y= -1; y<2; y++) {
- dy= ysize*y;
- for (x= -1; x<2; x++) {
- dx= xsize*x;
- fp= table;
- for (a=0; a<tot; a++, fp+= 2) {
- force[0]= vec[0] - fp[0]-dx;
- force[1]= vec[1] - fp[1]-dy;
- dist= force[0]*force[0] + force[1]*force[1];
- if (dist < min && dist>0.0f) {
- result[0]+= force[0]/dist;
- result[1]+= force[1]/dist;
- }
- }
- }
- }
- vec[0] += 0.1f*min*result[0]/(float)tot;
- vec[1] += 0.1f*min*result[1]/(float)tot;
- /* cyclic clamping */
- vec[0]= vec[0] - xsize*floorf(vec[0]/xsize + 0.5f);
- vec[1]= vec[1] - ysize*floorf(vec[1]/ysize + 0.5f);
-}
-
-/* random offset of 1 in 2 */
-static void jitter_plane_offset(float *jitter1, float *jitter2, int tot, float sizex, float sizey, float ofsx, float ofsy)
-{
- float dsizex= sizex*ofsx;
- float dsizey= sizey*ofsy;
- float hsizex= 0.5f*sizex, hsizey= 0.5f*sizey;
- int x;
-
- for (x=tot; x>0; x--, jitter1+=2, jitter2+=2) {
- jitter2[0]= jitter1[0] + dsizex;
- jitter2[1]= jitter1[1] + dsizey;
- if (jitter2[0] > hsizex) jitter2[0]-= sizex;
- if (jitter2[1] > hsizey) jitter2[1]-= sizey;
- }
-}
-
-/* called from convertBlenderScene.c */
-/* we do this in advance to get consistent random, not alter the render seed, and be threadsafe */
-void init_jitter_plane(LampRen *lar)
-{
- float *fp;
- int x, tot= lar->ray_totsamp;
-
- /* test if already initialized */
- if (lar->jitter) return;
-
- /* at least 4, or max threads+1 tables */
- if (BLENDER_MAX_THREADS < 4) x= 4;
- else x= BLENDER_MAX_THREADS+1;
- fp= lar->jitter= MEM_callocN(x*tot*2*sizeof(float), "lamp jitter tab");
-
- /* if 1 sample, we leave table to be zero's */
- if (tot>1) {
- /* set per-lamp fixed seed */
- RNG *rng = BLI_rng_new_srandom(tot);
- int iter=12;
-
- /* fill table with random locations, area_size large */
- for (x=0; x<tot; x++, fp+=2) {
- fp[0]= (BLI_rng_get_float(rng)-0.5f)*lar->area_size;
- fp[1]= (BLI_rng_get_float(rng)-0.5f)*lar->area_sizey;
- }
-
- while (iter--) {
- fp= lar->jitter;
- for (x=tot; x>0; x--, fp+=2) {
- DP_energy(lar->jitter, fp, tot, lar->area_size, lar->area_sizey);
- }
- }
-
- BLI_rng_free(rng);
- }
- /* create the dithered tables (could just check lamp type!) */
- jitter_plane_offset(lar->jitter, lar->jitter+2*tot, tot, lar->area_size, lar->area_sizey, 0.5f, 0.0f);
- jitter_plane_offset(lar->jitter, lar->jitter+4*tot, tot, lar->area_size, lar->area_sizey, 0.5f, 0.5f);
- jitter_plane_offset(lar->jitter, lar->jitter+6*tot, tot, lar->area_size, lar->area_sizey, 0.0f, 0.5f);
-}
-
-/* table around origin, -0.5*size to 0.5*size */
-static float *give_jitter_plane(LampRen *lar, int thread, int xs, int ys)
-{
- int tot;
-
- tot= lar->ray_totsamp;
-
- if (lar->ray_samp_type & LA_SAMP_JITTER) {
- /* made it threadsafe */
-
- if (lar->xold[thread]!=xs || lar->yold[thread]!=ys) {
- jitter_plane_offset(lar->jitter, lar->jitter+2*(thread+1)*tot, tot, lar->area_size, lar->area_sizey, BLI_thread_frand(thread), BLI_thread_frand(thread));
- lar->xold[thread]= xs;
- lar->yold[thread]= ys;
- }
- return lar->jitter+2*(thread+1)*tot;
- }
- if (lar->ray_samp_type & LA_SAMP_DITHER) {
- return lar->jitter + 2*tot*((xs & 1)+2*(ys & 1));
- }
-
- return lar->jitter;
-}
-
-
-/* **************** QMC sampling *************** */
-
-static void UNUSED_FUNCTION(halton_sample)(double *ht_invprimes, double *ht_nums, double *v)
-{
- /* incremental halton sequence generator, from:
- * "Instant Radiosity", Keller A. */
- unsigned int i;
-
- for (i = 0; i < 2; i++) {
- double r = fabs((1.0 - ht_nums[i]) - 1e-10);
-
- if (ht_invprimes[i] >= r) {
- double lasth;
- double h = ht_invprimes[i];
-
- do {
- lasth = h;
- h *= ht_invprimes[i];
- } while (h >= r);
-
- ht_nums[i] += ((lasth + h) - 1.0);
- }
- else
- ht_nums[i] += ht_invprimes[i];
-
- v[i] = (float)ht_nums[i];
- }
-}
-
-static struct QMCSampler *QMC_initSampler(int type, int tot)
-{
- QMCSampler *qsa = MEM_callocN(sizeof(QMCSampler), "qmc sampler");
- qsa->samp2d = MEM_callocN(2*sizeof(double)*tot, "qmc sample table");
-
- qsa->tot = tot;
- qsa->type = type;
-
- if (qsa->type==SAMP_TYPE_HAMMERSLEY)
- BLI_hammersley_2D_sequence(qsa->tot, qsa->samp2d);
-
- return qsa;
-}
-
-static void QMC_initPixel(QMCSampler *qsa, int thread)
-{
- if (qsa->type==SAMP_TYPE_HAMMERSLEY) {
- /* hammersley sequence is fixed, already created in QMCSampler init.
- * per pixel, gets a random offset. We create separate offsets per thread, for write-safety */
- qsa->offs[thread][0] = 0.5f * BLI_thread_frand(thread);
- qsa->offs[thread][1] = 0.5f * BLI_thread_frand(thread);
- }
- else { /* SAMP_TYPE_HALTON */
-
- /* generate a new randomized halton sequence per pixel
- * to alleviate qmc artifacts and make it reproducible
- * between threads/frames */
- double ht_offset[2];
- unsigned int ht_primes[2] = {2, 3};
-
- ht_offset[0] = BLI_thread_frand(thread);
- ht_offset[1] = BLI_thread_frand(thread);
-
- BLI_halton_2D_sequence(ht_primes, ht_offset, qsa->tot, qsa->samp2d);
- }
-}
-
-static void QMC_freeSampler(QMCSampler *qsa)
-{
- MEM_freeN(qsa->samp2d);
- MEM_freeN(qsa);
-}
-
-static void QMC_getSample(double *s, QMCSampler *qsa, int thread, int num)
-{
- if (qsa->type == SAMP_TYPE_HAMMERSLEY) {
- s[0] = fmod(qsa->samp2d[2*num+0] + qsa->offs[thread][0], 1.0f);
- s[1] = fmod(qsa->samp2d[2*num+1] + qsa->offs[thread][1], 1.0f);
- }
- else { /* SAMP_TYPE_HALTON */
- s[0] = qsa->samp2d[2*num+0];
- s[1] = qsa->samp2d[2*num+1];
- }
-}
-
-/* phong weighted disc using 'blur' for exponent, centred on 0,0 */
-static void QMC_samplePhong(float vec[3], QMCSampler *qsa, int thread, int num, float blur)
-{
- double s[2];
- float phi, pz, sqr;
-
- QMC_getSample(s, qsa, thread, num);
-
- phi = s[0]*2*M_PI;
- pz = pow(s[1], blur);
- sqr = sqrtf(1.0f - pz * pz);
-
- vec[0] = (float)(cosf(phi)*sqr);
- vec[1] = (float)(sinf(phi)*sqr);
- vec[2] = 0.0f;
-}
-
-/* rect of edge lengths sizex, sizey, centred on 0.0,0.0 i.e. ranging from -sizex/2 to +sizey/2 */
-static void QMC_sampleRect(float vec[3], QMCSampler *qsa, int thread, int num, float sizex, float sizey)
-{
- double s[2];
-
- QMC_getSample(s, qsa, thread, num);
-
- vec[0] = (float)(s[0] - 0.5) * sizex;
- vec[1] = (float)(s[1] - 0.5) * sizey;
- vec[2] = 0.0f;
-}
-
-/* disc of radius 'radius', centred on 0,0 */
-static void QMC_sampleDisc(float vec[3], QMCSampler *qsa, int thread, int num, float radius)
-{
- double s[2];
- float phi, sqr;
-
- QMC_getSample(s, qsa, thread, num);
-
- phi = s[0]*2*M_PI;
- sqr = sqrt(s[1]);
-
- vec[0] = cosf(phi)*sqr* radius/2.0f;
- vec[1] = sinf(phi)*sqr* radius/2.0f;
- vec[2] = 0.0f;
-}
-
-/* uniform hemisphere sampling */
-static void QMC_sampleHemi(float vec[3], QMCSampler *qsa, int thread, int num)
-{
- double s[2];
- float phi, sqr;
-
- QMC_getSample(s, qsa, thread, num);
-
- phi = s[0]*2.0*M_PI;
- sqr = sqrt(s[1]);
-
- vec[0] = cosf(phi)*sqr;
- vec[1] = sinf(phi)*sqr;
- vec[2] = (float)(1.0 - s[1]*s[1]);
-}
-
-#if 0 /* currently not used */
-/* cosine weighted hemisphere sampling */
-static void QMC_sampleHemiCosine(float vec[3], QMCSampler *qsa, int thread, int num)
-{
- double s[2];
- float phi, sqr;
-
- QMC_getSample(s, qsa, thread, num);
-
- phi = s[0]*2.f*M_PI;
- sqr = s[1]*sqrt(2-s[1]*s[1]);
-
- vec[0] = cos(phi)*sqr;
- vec[1] = sin(phi)*sqr;
- vec[2] = 1.f - s[1]*s[1];
-
-}
-#endif
-
-/* called from convertBlenderScene.c */
-void init_render_qmcsampler(Render *re)
-{
- const int num_threads = re->r.threads;
- re->qmcsamplers= MEM_callocN(sizeof(ListBase)*num_threads, "QMCListBase");
- re->num_qmc_samplers = num_threads;
-}
-
-static QMCSampler *get_thread_qmcsampler(Render *re, int thread, int type, int tot)
-{
- QMCSampler *qsa;
-
- /* create qmc samplers as needed, since recursion makes it hard to
- * predict how many are needed */
-
- for (qsa=re->qmcsamplers[thread].first; qsa; qsa=qsa->next) {
- if (qsa->type == type && qsa->tot == tot && !qsa->used) {
- qsa->used = true;
- return qsa;
- }
- }
-
- qsa= QMC_initSampler(type, tot);
- qsa->used = true;
- BLI_addtail(&re->qmcsamplers[thread], qsa);
-
- return qsa;
-}
-
-static void release_thread_qmcsampler(Render *UNUSED(re), int UNUSED(thread), QMCSampler *qsa)
-{
- qsa->used= 0;
-}
-
-void free_render_qmcsampler(Render *re)
-{
- if (re->qmcsamplers) {
- QMCSampler *qsa, *next;
- int a;
- for (a = 0; a < re->num_qmc_samplers; a++) {
- for (qsa=re->qmcsamplers[a].first; qsa; qsa=next) {
- next= qsa->next;
- QMC_freeSampler(qsa);
- }
-
- re->qmcsamplers[a].first= re->qmcsamplers[a].last= NULL;
- }
-
- MEM_freeN(re->qmcsamplers);
- re->qmcsamplers= NULL;
- }
-}
-
-static int adaptive_sample_variance(int samples, const float col[3], const float colsq[3], float thresh)
-{
- float var[3], mean[3];
-
- /* scale threshold just to give a bit more precision in input rather than dealing with
- * tiny tiny numbers in the UI */
- thresh /= 2;
-
- mean[0] = col[0] / (float)samples;
- mean[1] = col[1] / (float)samples;
- mean[2] = col[2] / (float)samples;
-
- var[0] = (colsq[0] / (float)samples) - (mean[0]*mean[0]);
- var[1] = (colsq[1] / (float)samples) - (mean[1]*mean[1]);
- var[2] = (colsq[2] / (float)samples) - (mean[2]*mean[2]);
-
- if ((var[0] * 0.4f < thresh) && (var[1] * 0.3f < thresh) && (var[2] * 0.6f < thresh))
- return 1;
- else
- return 0;
-}
-
-static int adaptive_sample_contrast_val(int samples, float prev, float val, float thresh)
-{
- /* if the last sample's contribution to the total value was below a small threshold
- * (i.e. the samples taken are very similar), then taking more samples that are probably
- * going to be the same is wasting effort */
- if (fabsf(prev / (float)(samples - 1) - val / (float)samples ) < thresh) {
- return 1;
- }
- else
- return 0;
-}
-
-static float get_avg_speed(ShadeInput *shi)
-{
- float pre_x, pre_y, post_x, post_y, speedavg;
-
- pre_x = (shi->winspeed[0] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[0];
- pre_y = (shi->winspeed[1] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[1];
- post_x = (shi->winspeed[2] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[2];
- post_y = (shi->winspeed[3] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[3];
-
- speedavg = (sqrtf(pre_x * pre_x + pre_y * pre_y) + sqrtf(post_x * post_x + post_y * post_y)) / 2.0f;
-
- return speedavg;
-}
-
-/* ***************** main calls ************** */
-
-
-static void trace_refract(float col[4], ShadeInput *shi, ShadeResult *shr)
-{
- QMCSampler *qsa=NULL;
- int samp_type;
- int traflag=0;
-
- float samp3d[3], orthx[3], orthy[3];
- float v_refract[3], v_refract_new[3];
- float sampcol[4], colsq[4];
-
- float blur = pow3f(1.0f - shi->mat->gloss_tra);
- short max_samples = shi->mat->samp_gloss_tra;
- float adapt_thresh = shi->mat->adapt_thresh_tra;
-
- int samples=0;
-
- colsq[0] = colsq[1] = colsq[2] = 0.0;
- col[0] = col[1] = col[2] = 0.0;
- col[3]= shr->alpha;
-
- if (blur > 0.0f) {
- if (adapt_thresh != 0.0f) samp_type = SAMP_TYPE_HALTON;
- else samp_type = SAMP_TYPE_HAMMERSLEY;
-
- /* all samples are generated per pixel */
- qsa = get_thread_qmcsampler(&R, shi->thread, samp_type, max_samples);
- QMC_initPixel(qsa, shi->thread);
- }
- else
- max_samples = 1;
-
-
- while (samples < max_samples) {
- if (refraction(v_refract, shi->vn, shi->view, shi->ang)) {
- traflag |= RAY_INSIDE;
- }
- else {
- /* total external reflection can happen for materials with IOR < 1.0 */
- if ((shi->vlr->flag & R_SMOOTH))
- reflection(v_refract, shi->vn, shi->view, shi->facenor);
- else
- reflection_simple(v_refract, shi->vn, shi->view);
-
- /* can't blur total external reflection */
- max_samples = 1;
- }
-
- if (max_samples > 1) {
- /* get a quasi-random vector from a phong-weighted disc */
- QMC_samplePhong(samp3d, qsa, shi->thread, samples, blur);
-
- ortho_basis_v3v3_v3(orthx, orthy, v_refract);
- mul_v3_fl(orthx, samp3d[0]);
- mul_v3_fl(orthy, samp3d[1]);
-
- /* and perturb the refraction vector in it */
- add_v3_v3v3(v_refract_new, v_refract, orthx);
- add_v3_v3(v_refract_new, orthy);
-
- normalize_v3(v_refract_new);
- }
- else {
- /* no blurriness, use the original normal */
- copy_v3_v3(v_refract_new, v_refract);
- }
-
- sampcol[0]= sampcol[1]= sampcol[2]= sampcol[3]= 0.0f;
-
- traceray(shi, shr, shi->mat->ray_depth_tra, shi->co, v_refract_new, sampcol, shi->obi, shi->vlr, traflag);
-
- col[0] += sampcol[0];
- col[1] += sampcol[1];
- col[2] += sampcol[2];
- col[3] += sampcol[3];
-
- /* for variance calc */
- colsq[0] += sampcol[0]*sampcol[0];
- colsq[1] += sampcol[1]*sampcol[1];
- colsq[2] += sampcol[2]*sampcol[2];
-
- samples++;
-
- /* adaptive sampling */
- if (adapt_thresh < 1.0f && samples > max_samples/2) {
- if (adaptive_sample_variance(samples, col, colsq, adapt_thresh))
- break;
-
- /* if the pixel so far is very dark, we can get away with less samples */
- if ( (col[0] + col[1] + col[2])/3.0f/(float)samples < 0.01f )
- max_samples--;
- }
- }
-
- col[0] /= (float)samples;
- col[1] /= (float)samples;
- col[2] /= (float)samples;
- col[3] /= (float)samples;
-
- if (qsa)
- release_thread_qmcsampler(&R, shi->thread, qsa);
-}
-
-static void trace_reflect(float col[3], ShadeInput *shi, ShadeResult *shr, float fresnelfac)
-{
- QMCSampler *qsa=NULL;
- int samp_type;
-
- float samp3d[3], orthx[3], orthy[3];
- float v_nor_new[3], v_reflect[3];
- float sampcol[4], colsq[4];
-
- float blur = pow3f(1.0f - shi->mat->gloss_mir);
- short max_samples = shi->mat->samp_gloss_mir;
- float adapt_thresh = shi->mat->adapt_thresh_mir;
- float aniso = 1.0f - shi->mat->aniso_gloss_mir;
-
- int samples=0;
-
- col[0] = col[1] = col[2] = 0.0;
- colsq[0] = colsq[1] = colsq[2] = 0.0;
-
- if (blur > 0.0f) {
- if (adapt_thresh != 0.0f) samp_type = SAMP_TYPE_HALTON;
- else samp_type = SAMP_TYPE_HAMMERSLEY;
-
- /* all samples are generated per pixel */
- qsa = get_thread_qmcsampler(&R, shi->thread, samp_type, max_samples);
- QMC_initPixel(qsa, shi->thread);
- }
- else
- max_samples = 1;
-
- while (samples < max_samples) {
-
- if (max_samples > 1) {
- /* get a quasi-random vector from a phong-weighted disc */
- QMC_samplePhong(samp3d, qsa, shi->thread, samples, blur);
-
- /* find the normal's perpendicular plane, blurring along tangents
- * if tangent shading enabled */
- if (shi->mat->mode & (MA_TANGENT_V)) {
- cross_v3_v3v3(orthx, shi->vn, shi->tang); // bitangent
- copy_v3_v3(orthy, shi->tang);
- mul_v3_fl(orthx, samp3d[0]);
- mul_v3_fl(orthy, samp3d[1]*aniso);
- }
- else {
- ortho_basis_v3v3_v3(orthx, orthy, shi->vn);
- mul_v3_fl(orthx, samp3d[0]);
- mul_v3_fl(orthy, samp3d[1]);
- }
-
- /* and perturb the normal in it */
- add_v3_v3v3(v_nor_new, shi->vn, orthx);
- add_v3_v3(v_nor_new, orthy);
- normalize_v3(v_nor_new);
- }
- else {
- /* no blurriness, use the original normal */
- copy_v3_v3(v_nor_new, shi->vn);
- }
-
- if ((shi->vlr->flag & R_SMOOTH))
- reflection(v_reflect, v_nor_new, shi->view, shi->facenor);
- else
- reflection_simple(v_reflect, v_nor_new, shi->view);
-
- sampcol[0]= sampcol[1]= sampcol[2]= sampcol[3]= 0.0f;
-
- traceray(shi, shr, shi->mat->ray_depth, shi->co, v_reflect, sampcol, shi->obi, shi->vlr, 0);
-
-
- col[0] += sampcol[0];
- col[1] += sampcol[1];
- col[2] += sampcol[2];
-
- /* for variance calc */
- colsq[0] += sampcol[0]*sampcol[0];
- colsq[1] += sampcol[1]*sampcol[1];
- colsq[2] += sampcol[2]*sampcol[2];
-
- samples++;
-
- /* adaptive sampling */
- if (adapt_thresh > 0.0f && samples > max_samples/3) {
- if (adaptive_sample_variance(samples, col, colsq, adapt_thresh))
- break;
-
- /* if the pixel so far is very dark, we can get away with less samples */
- if ( (col[0] + col[1] + col[2])/3.0f/(float)samples < 0.01f )
- max_samples--;
-
- /* reduce samples when reflection is dim due to low ray mirror blend value or fresnel factor
- * and when reflection is blurry */
- if (fresnelfac < 0.1f * (blur+1)) {
- max_samples--;
-
- /* even more for very dim */
- if (fresnelfac < 0.05f * (blur+1))
- max_samples--;
- }
- }
- }
-
- col[0] /= (float)samples;
- col[1] /= (float)samples;
- col[2] /= (float)samples;
-
- if (qsa)
- release_thread_qmcsampler(&R, shi->thread, qsa);
-}
-
-/* extern call from render loop */
-void ray_trace(ShadeInput *shi, ShadeResult *shr)
-{
- float f1, fr, fg, fb;
- float mircol[4], tracol[4];
- float diff[3];
- int do_tra, do_mir;
-
- do_tra = ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha != 1.0f && (shi->depth <= shi->mat->ray_depth_tra));
- do_mir = ((shi->mat->mode & MA_RAYMIRROR) && shi->ray_mirror != 0.0f && (shi->depth <= shi->mat->ray_depth));
-
- /* raytrace mirror and refract like to separate the spec color */
- if (shi->combinedflag & SCE_PASS_SPEC)
- sub_v3_v3v3(diff, shr->combined, shr->spec);
- else
- copy_v3_v3(diff, shr->combined);
-
- if (do_tra) {
- float olddiff[3], f;
-
- trace_refract(tracol, shi, shr);
-
- f= shr->alpha; f1= 1.0f-f;
- fr= 1.0f+ shi->mat->filter*(shi->r-1.0f);
- fg= 1.0f+ shi->mat->filter*(shi->g-1.0f);
- fb= 1.0f+ shi->mat->filter*(shi->b-1.0f);
-
- /* for refract pass */
- copy_v3_v3(olddiff, diff);
-
- diff[0]= f*diff[0] + f1*fr*tracol[0];
- diff[1]= f*diff[1] + f1*fg*tracol[1];
- diff[2]= f*diff[2] + f1*fb*tracol[2];
-
- if (shi->passflag & SCE_PASS_REFRACT)
- sub_v3_v3v3(shr->refr, diff, olddiff);
-
- if (!(shi->combinedflag & SCE_PASS_REFRACT))
- sub_v3_v3v3(diff, diff, shr->refr);
-
- shr->alpha = min_ff(1.0f, tracol[3]);
- }
-
- if (do_mir) {
- const float i= shi->ray_mirror*fresnel_fac(shi->view, shi->vn, shi->mat->fresnel_mir_i, shi->mat->fresnel_mir);
- if (i!=0.0f) {
-
- trace_reflect(mircol, shi, shr, i);
-
- fr= i*shi->mirr;
- fg= i*shi->mirg;
- fb= i*shi->mirb;
-
- if (shi->passflag & SCE_PASS_REFLECT) {
- /* mirror pass is not blocked out with spec */
- shr->refl[0]= fr*mircol[0] - fr*diff[0];
- shr->refl[1]= fg*mircol[1] - fg*diff[1];
- shr->refl[2]= fb*mircol[2] - fb*diff[2];
- }
-
- if (shi->combinedflag & SCE_PASS_REFLECT) {
- /* values in shr->spec can be greater than 1.0.
- * In this case the mircol uses a zero blending factor, so ignoring it is ok.
- * Fixes bug #18837 - when the spec is higher then 1.0,
- * diff can become a negative color - Campbell */
-
- f1= 1.0f-i;
-
- diff[0] *= f1;
- diff[1] *= f1;
- diff[2] *= f1;
-
- if (shr->spec[0]<1.0f) diff[0] += mircol[0] * (fr*(1.0f-shr->spec[0]));
- if (shr->spec[1]<1.0f) diff[1] += mircol[1] * (fg*(1.0f-shr->spec[1]));
- if (shr->spec[2]<1.0f) diff[2] += mircol[2] * (fb*(1.0f-shr->spec[2]));
- }
- }
- }
- /* put back together */
- if (shi->combinedflag & SCE_PASS_SPEC)
- add_v3_v3v3(shr->combined, diff, shr->spec);
- else
- copy_v3_v3(shr->combined, diff);
-}
-
-/* color 'shadfac' passes through 'col' with alpha and filter */
-/* filter is only applied on alpha defined transparent part */
-static void addAlphaLight(float shadfac[4], const float col[3], float alpha, float filter)
-{
- float fr, fg, fb;
-
- fr= 1.0f+ filter*(col[0]-1.0f);
- fg= 1.0f+ filter*(col[1]-1.0f);
- fb= 1.0f+ filter*(col[2]-1.0f);
-
- shadfac[0]= alpha*col[0] + fr*(1.0f-alpha)*shadfac[0];
- shadfac[1]= alpha*col[1] + fg*(1.0f-alpha)*shadfac[1];
- shadfac[2]= alpha*col[2] + fb*(1.0f-alpha)*shadfac[2];
-
- shadfac[3]= (1.0f-alpha)*shadfac[3];
-}
-
-static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int traflag, float col[4])
-{
- /* ray to lamp, find first face that intersects, check alpha properties,
- * if it has col[3]>0.0f continue. so exit when alpha is full */
- const float initial_dist = is->dist;
-
- if (RE_rayobject_raycast(R.raytree, is)) {
- /* Warning regarding initializing to zero's, This is not that nice,
- * and possibly a bit slow for every ray, however some variables were
- * not initialized properly in, unless using
- * shade_input_initialize(...), we need to zero them. */
- ShadeInput shi= {NULL};
- /* end warning! - Campbell */
-
- ShadeResult shr;
-
- /* we got a face */
-
- shi.depth= origshi->depth + 1; /* only used to indicate tracing */
- shi.mask= origshi->mask;
- shi.thread= origshi->thread;
- shi.passflag= SCE_PASS_COMBINED;
- shi.combinedflag= 0xFFFFFF; /* ray trace does all options */
-
- shi.xs= origshi->xs;
- shi.ys= origshi->ys;
- shi.do_manage= origshi->do_manage;
- shi.lay= origshi->lay;
- shi.nodes= origshi->nodes;
-
- RE_instance_rotate_ray_restore(origshi->obi, is);
-
- shade_ray(is, &shi, &shr);
- if (shi.mat->material_type == MA_TYPE_SURFACE) {
- const float d = (shi.mat->mode & MA_RAYTRANSP) ?
- ((traflag & RAY_TRA) ? shade_by_transmission(is, &shi, &shr) : 1.0f) :
- 0.0f;
- /* mix colors based on shadfac (rgb + amount of light factor) */
- addAlphaLight(col, shr.diff, shr.alpha, d*shi.mat->filter);
- }
- else if (shi.mat->material_type == MA_TYPE_VOLUME) {
- const float a = col[3];
-
- col[0] = a*col[0] + shr.alpha*shr.combined[0];
- col[1] = a*col[1] + shr.alpha*shr.combined[1];
- col[2] = a*col[2] + shr.alpha*shr.combined[2];
-
- col[3] = (1.0f - shr.alpha)*a;
- }
-
- if (depth>0 && col[3]>0.0f) {
-
- /* adapt isect struct */
- copy_v3_v3(is->start, shi.co);
- is->dist = initial_dist-is->dist;
- is->orig.ob = shi.obi;
- is->orig.face = shi.vlr;
-
- ray_trace_shadow_tra(is, origshi, depth-1, traflag | RAY_TRA, col);
- }
-
- RE_RC_MERGE(&origshi->raycounter, &shi.raycounter);
- }
-}
-
-
-/* aolight: function to create random unit sphere vectors for total random sampling */
-
-/* calc distributed spherical energy */
-static void DS_energy(float *sphere, int tot, float vec[3])
-{
- float *fp, fac, force[3], res[3];
- int a;
-
- res[0]= res[1]= res[2]= 0.0f;
-
- for (a=0, fp=sphere; a<tot; a++, fp+=3) {
- sub_v3_v3v3(force, vec, fp);
- fac = dot_v3v3(force, force);
- if (fac!=0.0f) {
- fac= 1.0f/fac;
- res[0]+= fac*force[0];
- res[1]+= fac*force[1];
- res[2]+= fac*force[2];
- }
- }
-
- mul_v3_fl(res, 0.5);
- add_v3_v3(vec, res);
- normalize_v3(vec);
-
-}
-
-/* called from convertBlenderScene.c */
-/* creates an equally distributed spherical sample pattern */
-/* and allocates threadsafe memory */
-void init_ao_sphere(Render *re, World *wrld)
-{
- /* fixed random */
- const int num_threads = re->r.threads;
- RNG *rng;
- float *fp;
- int a, tot, iter= 16;
-
- /* we make twice the amount of samples, because only a hemisphere is used */
- tot= 2*wrld->aosamp*wrld->aosamp;
-
- wrld->aosphere= MEM_mallocN(3*tot*sizeof(float), "AO sphere");
- rng = BLI_rng_new_srandom(tot);
-
- /* init */
- fp= wrld->aosphere;
- for (a=0; a<tot; a++, fp+= 3) {
- BLI_rng_get_float_unit_v3(rng, fp);
- }
-
- while (iter--) {
- for (a=0, fp= wrld->aosphere; a<tot; a++, fp+= 3) {
- DS_energy(wrld->aosphere, tot, fp);
- }
- }
-
- /* tables */
- wrld->aotables= MEM_mallocN(num_threads*3*tot*sizeof(float), "AO tables");
-
- BLI_rng_free(rng);
-}
-
-/* give per thread a table, we have to compare xs ys because of way OSA works... */
-static float *threadsafe_table_sphere(int test, int thread, int xs, int ys, int tot)
-{
- static int xso[BLENDER_MAX_THREADS], yso[BLENDER_MAX_THREADS];
- static int firsttime= 1;
-
- if (firsttime) {
- memset(xso, 255, sizeof(xso));
- memset(yso, 255, sizeof(yso));
- firsttime= 0;
- }
-
- if (xs==xso[thread] && ys==yso[thread]) return R.wrld.aotables+ thread*tot*3;
- if (test) return NULL;
- xso[thread]= xs; yso[thread]= ys;
- return R.wrld.aotables+ thread*tot*3;
-}
-
-static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, int reset)
-{
- int tot;
- float *vec;
-
- tot= 2*resol*resol;
-
- if (type & WO_AORNDSMP) {
- /* total random sampling. NOT THREADSAFE! (should be removed, is not useful) */
- RNG *rng = BLI_rng_new(BLI_thread_rand(thread));
- float *sphere;
- int a;
-
- /* always returns table */
- sphere= threadsafe_table_sphere(0, thread, xs, ys, tot);
-
- vec= sphere;
- for (a=0; a<tot; a++, vec+=3) {
- BLI_rng_get_float_unit_v3(rng, vec);
- }
-
- BLI_rng_free(rng);
-
- return sphere;
- }
- else {
- float *sphere;
- float *vec1;
-
- /* returns table if xs and ys were equal to last call, and not resetting */
- sphere= (reset)? NULL: threadsafe_table_sphere(1, thread, xs, ys, tot);
- if (sphere==NULL) {
- float cosfi, sinfi, cost, sint;
- float ang;
- int a;
-
- sphere= threadsafe_table_sphere(0, thread, xs, ys, tot);
-
- /* random rotation */
- ang = BLI_thread_frand(thread);
- sinfi = sinf(ang); cosfi = cosf(ang);
- ang = BLI_thread_frand(thread);
- sint = sinf(ang); cost = cosf(ang);
-
- vec= R.wrld.aosphere;
- vec1= sphere;
- for (a=0; a<tot; a++, vec+=3, vec1+=3) {
- vec1[0]= cost*cosfi*vec[0] - sinfi*vec[1] + sint*cosfi*vec[2];
- vec1[1]= cost*sinfi*vec[0] + cosfi*vec[1] + sint*sinfi*vec[2];
- vec1[2]= -sint*vec[0] + cost*vec[2];
- }
- }
- return sphere;
- }
-}
-
-static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3])
-{
- Isect isec;
- RayHint point_hint;
- QMCSampler *qsa=NULL;
- float samp3d[3];
- float up[3], side[3], dir[3], nrm[3];
-
- float maxdist = R.wrld.aodist;
- float fac=0.0f, prev=0.0f;
- float adapt_thresh = R.wrld.ao_adapt_thresh;
- float adapt_speed_fac = R.wrld.ao_adapt_speed_fac;
-
- int samples=0;
- int max_samples = R.wrld.aosamp*R.wrld.aosamp;
-
- float dxyview[3], skyadded=0;
- int envcolor;
-
- RE_RC_INIT(isec, *shi);
- isec.orig.ob = shi->obi;
- isec.orig.face = shi->vlr;
- isec.check = RE_CHECK_VLR_NON_SOLID_MATERIAL;
- isec.skip = RE_SKIP_VLR_NEIGHBOUR;
- isec.hint = NULL;
-
- isec.hit.ob = NULL;
- isec.hit.face = NULL;
-
- isec.last_hit = NULL;
-
- isec.mode= (R.wrld.aomode & WO_AODIST)?RE_RAY_SHADOW_TRA:RE_RAY_SHADOW;
- isec.lay= -1;
-
- copy_v3_v3(isec.start, shi->co);
-
- RE_instance_rotate_ray_start(shi->obi, &isec);
-
- RE_rayobject_hint_bb(R.raytree, &point_hint, isec.start, isec.start);
- isec.hint = &point_hint;
-
- zero_v3(ao);
- zero_v3(env);
-
- /* prevent sky colors to be added for only shadow (shadow becomes alpha) */
- envcolor= R.wrld.aocolor;
- if (shi->mat->mode & MA_ONLYSHADOW)
- envcolor= WO_AOPLAIN;
-
- if (envcolor == WO_AOSKYTEX) {
- dxyview[0]= 1.0f/(float)R.wrld.aosamp;
- dxyview[1]= 1.0f/(float)R.wrld.aosamp;
- dxyview[2]= 0.0f;
- }
-
- if (shi->vlr->flag & R_SMOOTH) {
- copy_v3_v3(nrm, shi->vn);
- }
- else {
- copy_v3_v3(nrm, shi->facenor);
- }
-
- ortho_basis_v3v3_v3(up, side, nrm);
-
- /* sampling init */
- if (R.wrld.ao_samp_method==WO_AOSAMP_HALTON) {
- float speedfac;
-
- speedfac = get_avg_speed(shi) * adapt_speed_fac;
- CLAMP(speedfac, 1.0f, 1000.0f);
- max_samples /= speedfac;
- if (max_samples < 5) max_samples = 5;
-
- qsa = get_thread_qmcsampler(&R, shi->thread, SAMP_TYPE_HALTON, max_samples);
- }
- else if (R.wrld.ao_samp_method==WO_AOSAMP_HAMMERSLEY)
- qsa = get_thread_qmcsampler(&R, shi->thread, SAMP_TYPE_HAMMERSLEY, max_samples);
-
- QMC_initPixel(qsa, shi->thread);
-
- while (samples < max_samples) {
-
- /* sampling, returns quasi-random vector in unit hemisphere */
- QMC_sampleHemi(samp3d, qsa, shi->thread, samples);
-
- dir[0] = (samp3d[0]*up[0] + samp3d[1]*side[0] + samp3d[2]*nrm[0]);
- dir[1] = (samp3d[0]*up[1] + samp3d[1]*side[1] + samp3d[2]*nrm[1]);
- dir[2] = (samp3d[0]*up[2] + samp3d[1]*side[2] + samp3d[2]*nrm[2]);
-
- normalize_v3(dir);
-
- isec.dir[0] = -dir[0];
- isec.dir[1] = -dir[1];
- isec.dir[2] = -dir[2];
- isec.dist = maxdist;
-
- RE_instance_rotate_ray_dir(shi->obi, &isec);
-
- prev = fac;
-
- if (RE_rayobject_raycast(R.raytree, &isec)) {
- if (R.wrld.aomode & WO_AODIST) fac+= expf(-isec.dist*R.wrld.aodistfac);
- else fac+= 1.0f;
- }
- else if (envcolor!=WO_AOPLAIN) {
- float skycol[4];
- float view[3];
-
- view[0]= -dir[0];
- view[1]= -dir[1];
- view[2]= -dir[2];
- normalize_v3(view);
-
- if (envcolor==WO_AOSKYCOL) {
- const float skyfac= 0.5f * (1.0f + dot_v3v3(view, R.grvec));
- env[0]+= (1.0f-skyfac)*R.wrld.horr + skyfac*R.wrld.zenr;
- env[1]+= (1.0f-skyfac)*R.wrld.horg + skyfac*R.wrld.zeng;
- env[2]+= (1.0f-skyfac)*R.wrld.horb + skyfac*R.wrld.zenb;
- }
- else { /* WO_AOSKYTEX */
- shadeSkyView(skycol, isec.start, view, dxyview, shi->thread);
- shadeSunView(skycol, shi->view);
- env[0]+= skycol[0];
- env[1]+= skycol[1];
- env[2]+= skycol[2];
- }
- skyadded++;
- }
-
- samples++;
-
- if (qsa && qsa->type == SAMP_TYPE_HALTON) {
- /* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */
- if (adapt_thresh > 0.0f && (samples > max_samples/2) ) {
-
- if (adaptive_sample_contrast_val(samples, prev, fac, adapt_thresh)) {
- break;
- }
- }
- }
- }
-
- /* average color times distances/hits formula */
- ao[0]= ao[1]= ao[2]= 1.0f - fac/(float)samples;
-
- if (envcolor!=WO_AOPLAIN && skyadded)
- mul_v3_fl(env, (1.0f - fac/(float)samples)/((float)skyadded));
- else
- copy_v3_v3(env, ao);
-
- if (qsa)
- release_thread_qmcsampler(&R, shi->thread, qsa);
-}
-
-/* extern call from shade_lamp_loop, ambient occlusion calculus */
-static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3])
-{
- Isect isec;
- RayHint point_hint;
- float *vec, *nrm, bias, sh=0.0f;
- float maxdist = R.wrld.aodist;
- float dxyview[3];
- int j= -1, tot, actual=0, skyadded=0, envcolor, resol= R.wrld.aosamp;
-
- RE_RC_INIT(isec, *shi);
- isec.orig.ob = shi->obi;
- isec.orig.face = shi->vlr;
- isec.check = RE_CHECK_VLR_RENDER;
- isec.skip = RE_SKIP_VLR_NEIGHBOUR;
- isec.hint = NULL;
-
- isec.hit.ob = NULL;
- isec.hit.face = NULL;
-
- isec.last_hit = NULL;
-
- isec.mode= (R.wrld.aomode & WO_AODIST)?RE_RAY_SHADOW_TRA:RE_RAY_SHADOW;
- isec.lay= -1;
-
- copy_v3_v3(isec.start, shi->co);
- RE_instance_rotate_ray_start(shi->obi, &isec);
-
- RE_rayobject_hint_bb(R.raytree, &point_hint, isec.start, isec.start);
- isec.hint = &point_hint;
-
- zero_v3(ao);
- zero_v3(env);
-
- /* bias prevents smoothed faces to appear flat */
- if (shi->vlr->flag & R_SMOOTH) {
- bias= R.wrld.aobias;
- nrm= shi->vn;
- }
- else {
- bias= 0.0f;
- nrm= shi->facenor;
- }
-
- /* prevent sky colors to be added for only shadow (shadow becomes alpha) */
- envcolor= R.wrld.aocolor;
- if (shi->mat->mode & MA_ONLYSHADOW)
- envcolor= WO_AOPLAIN;
-
- if (resol>32) resol= 32;
-
- /* get sphere samples. for faces we get the same samples for sample x/y values,
- * for strand render we always require a new sampler because x/y are not set */
- vec= sphere_sampler(R.wrld.aomode, resol, shi->thread, shi->xs, shi->ys, shi->strand != NULL);
-
- /* warning: since we use full sphere now, and dotproduct is below, we do twice as much */
- tot= 2*resol*resol;
-
- if (envcolor == WO_AOSKYTEX) {
- dxyview[0]= 1.0f/(float)resol;
- dxyview[1]= 1.0f/(float)resol;
- dxyview[2]= 0.0f;
- }
-
- while (tot--) {
-
- if (dot_v3v3(vec, nrm) > bias) {
- /* only ao samples for mask */
- if (R.r.mode & R_OSA) {
- j++;
- if (j==R.osa) j= 0;
- if (!(shi->mask & (1<<j))) {
- vec+=3;
- continue;
- }
- }
-
- actual++;
-
- /* always set start/vec/dist */
- isec.dir[0] = -vec[0];
- isec.dir[1] = -vec[1];
- isec.dir[2] = -vec[2];
- isec.dist = maxdist;
-
- RE_instance_rotate_ray_dir(shi->obi, &isec);
-
- /* do the trace */
- if (RE_rayobject_raycast(R.raytree, &isec)) {
- if (R.wrld.aomode & WO_AODIST) sh+= expf(-isec.dist*R.wrld.aodistfac);
- else sh+= 1.0f;
- }
- else if (envcolor!=WO_AOPLAIN) {
- float skycol[4];
- float view[3];
-
- view[0]= -vec[0];
- view[1]= -vec[1];
- view[2]= -vec[2];
- normalize_v3(view);
-
- if (envcolor==WO_AOSKYCOL) {
- const float fac = 0.5f * (1.0f + dot_v3v3(view, R.grvec));
- env[0]+= (1.0f-fac)*R.wrld.horr + fac*R.wrld.zenr;
- env[1]+= (1.0f-fac)*R.wrld.horg + fac*R.wrld.zeng;
- env[2]+= (1.0f-fac)*R.wrld.horb + fac*R.wrld.zenb;
- }
- else { /* WO_AOSKYTEX */
- shadeSkyView(skycol, isec.start, view, dxyview, shi->thread);
- shadeSunView(skycol, shi->view);
- env[0]+= skycol[0];
- env[1]+= skycol[1];
- env[2]+= skycol[2];
- }
- skyadded++;
- }
- }
- /* samples */
- vec+= 3;
- }
-
- if (actual==0) sh= 1.0f;
- else sh = 1.0f - sh/((float)actual);
-
- /* average color times distances/hits formula */
- ao[0]= ao[1]= ao[2]= sh;
-
- if (envcolor!=WO_AOPLAIN && skyadded)
- mul_v3_fl(env, sh/((float)skyadded));
- else
- copy_v3_v3(env, ao);
-}
-
-void ray_ao(ShadeInput *shi, float ao[3], float env[3])
-{
- /* Unfortunately, the unusual way that the sphere sampler calculates roughly twice as many
- * samples as are actually traced, and skips them based on bias and OSA settings makes it very difficult
- * to reuse code between these two functions. This is the easiest way I can think of to do it
- * --broken */
- if (ELEM(R.wrld.ao_samp_method, WO_AOSAMP_HAMMERSLEY, WO_AOSAMP_HALTON))
- ray_ao_qmc(shi, ao, env);
- else if (R.wrld.ao_samp_method == WO_AOSAMP_CONSTANT)
- ray_ao_spheresamp(shi, ao, env);
-}
-
-static void ray_shadow_jittered_coords(ShadeInput *shi, int max, float jitco[RE_MAX_OSA][3], int *totjitco)
-{
- /* magic numbers for reordering sample positions to give better
- * results with adaptive sample, when it usually only takes 4 samples */
- int order8[8] = {0, 1, 5, 6, 2, 3, 4, 7};
- int order11[11] = {1, 3, 8, 10, 0, 2, 4, 5, 6, 7, 9};
- int order16[16] = {1, 3, 9, 12, 0, 6, 7, 8, 13, 2, 4, 5, 10, 11, 14, 15};
- int count = count_mask(shi->mask);
-
- /* for better antialising shadow samples are distributed over the subpixel
- * sample coordinates, this only works for raytracing depth 0 though */
- if (!shi->strand && shi->depth == 0 && count > 1 && count <= max) {
- float xs, ys, zs, view[3];
- int samp, ordsamp, tot= 0;
-
- for (samp=0; samp<R.osa; samp++) {
- if (R.osa == 8) ordsamp = order8[samp];
- else if (R.osa == 11) ordsamp = order11[samp];
- else if (R.osa == 16) ordsamp = order16[samp];
- else ordsamp = samp;
-
- if (shi->mask & (1<<ordsamp)) {
- /* zbuffer has this inverse corrected, ensures xs,ys are inside pixel */
- xs= (float)shi->scanco[0] + R.jit[ordsamp][0] + 0.5f;
- ys= (float)shi->scanco[1] + R.jit[ordsamp][1] + 0.5f;
- zs= shi->scanco[2];
-
- shade_input_calc_viewco(shi, xs, ys, zs, view, NULL, jitco[tot], NULL, NULL);
- tot++;
- }
- }
-
- *totjitco= tot;
- }
- else {
- copy_v3_v3(jitco[0], shi->co);
- *totjitco= 1;
- }
-}
-
-static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3], float shadfac[4], Isect *isec)
-{
- QMCSampler *qsa=NULL;
- int samples=0;
- float samp3d[3];
-
- float fac=0.0f, vec[3], end[3];
- float colsq[4];
- float adapt_thresh = lar->adapt_thresh;
- int min_adapt_samples=4, max_samples = lar->ray_totsamp;
- float start[3];
- bool do_soft = true, full_osa = false;
- int i;
-
- float min[3], max[3];
- RayHint bb_hint;
-
- float jitco[RE_MAX_OSA][3];
- int totjitco;
-
- colsq[0] = colsq[1] = colsq[2] = 0.0;
- if (isec->mode==RE_RAY_SHADOW_TRA) {
- shadfac[0]= shadfac[1]= shadfac[2]= shadfac[3]= 0.0f;
- }
- else
- shadfac[3]= 1.0f;
-
- if (lar->ray_totsamp < 2) do_soft = false;
- if ((R.r.mode & R_OSA) && (R.osa > 0) && (shi->vlr->flag & R_FULL_OSA)) full_osa = true;
-
- if (full_osa) {
- if (do_soft) max_samples = max_samples/R.osa + 1;
- else max_samples = 1;
- }
- else {
- if (do_soft) max_samples = lar->ray_totsamp;
- else if (shi->depth == 0) max_samples = (R.osa > 4)?R.osa:5;
- else max_samples = 1;
- }
-
- ray_shadow_jittered_coords(shi, max_samples, jitco, &totjitco);
-
- /* sampling init */
- if (lar->ray_samp_method==LA_SAMP_HALTON)
- qsa = get_thread_qmcsampler(&R, shi->thread, SAMP_TYPE_HALTON, max_samples);
- else if (lar->ray_samp_method==LA_SAMP_HAMMERSLEY)
- qsa = get_thread_qmcsampler(&R, shi->thread, SAMP_TYPE_HAMMERSLEY, max_samples);
-
- QMC_initPixel(qsa, shi->thread);
-
- INIT_MINMAX(min, max);
- for (i = 0; i < totjitco; i++) {
- minmax_v3v3_v3(min, max, jitco[i]);
- }
- if (shi->obi->flag & R_ENV_TRANSFORMED) {
- mul_m4_v3(shi->obi->imat, min);
- mul_m4_v3(shi->obi->imat, max);
- }
- RE_rayobject_hint_bb(R.raytree, &bb_hint, min, max);
-
- isec->hint = &bb_hint;
- isec->check = RE_CHECK_VLR_RENDER;
- isec->skip = RE_SKIP_VLR_NEIGHBOUR;
- copy_v3_v3(vec, lampco);
-
- while (samples < max_samples) {
-
- isec->orig.ob = shi->obi;
- isec->orig.face = shi->vlr;
-
- /* manually jitter the start shading co-ord per sample
- * based on the pre-generated OSA texture sampling offsets,
- * for anti-aliasing sharp shadow edges. */
- copy_v3_v3(start, jitco[samples % totjitco]);
-
- if (do_soft) {
- /* sphere shadow source */
- if (lar->type == LA_LOCAL) {
- float ru[3], rv[3], v[3], s[3];
-
- /* calc tangent plane vectors */
- sub_v3_v3v3(v, start, lampco);
- normalize_v3(v);
- ortho_basis_v3v3_v3(ru, rv, v);
-
- /* sampling, returns quasi-random vector in area_size disc */
- QMC_sampleDisc(samp3d, qsa, shi->thread, samples, lar->area_size);
-
- /* distribute disc samples across the tangent plane */
- s[0] = samp3d[0]*ru[0] + samp3d[1]*rv[0];
- s[1] = samp3d[0]*ru[1] + samp3d[1]*rv[1];
- s[2] = samp3d[0]*ru[2] + samp3d[1]*rv[2];
-
- copy_v3_v3(samp3d, s);
- }
- else {
- /* sampling, returns quasi-random vector in [sizex,sizey]^2 plane */
- QMC_sampleRect(samp3d, qsa, shi->thread, samples, lar->area_size, lar->area_sizey);
-
- /* align samples to lamp vector */
- mul_m3_v3(lar->mat, samp3d);
- }
- end[0] = vec[0]+samp3d[0];
- end[1] = vec[1]+samp3d[1];
- end[2] = vec[2]+samp3d[2];
- }
- else {
- copy_v3_v3(end, vec);
- }
-
- if (shi->strand) {
- /* bias away somewhat to avoid self intersection */
- float jitbias= 0.5f*(len_v3(shi->dxco) + len_v3(shi->dyco));
- float v[3];
-
- sub_v3_v3v3(v, start, end);
- normalize_v3(v);
-
- start[0] -= jitbias*v[0];
- start[1] -= jitbias*v[1];
- start[2] -= jitbias*v[2];
- }
-
- copy_v3_v3(isec->start, start);
- sub_v3_v3v3(isec->dir, end, start);
- isec->dist = normalize_v3(isec->dir);
-
- RE_instance_rotate_ray(shi->obi, isec);
-
- /* trace the ray */
- if (isec->mode==RE_RAY_SHADOW_TRA) {
- float col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
-
- ray_trace_shadow_tra(isec, shi, DEPTH_SHADOW_TRA, 0, col);
- shadfac[0] += col[0];
- shadfac[1] += col[1];
- shadfac[2] += col[2];
- shadfac[3] += col[3];
-
- /* for variance calc */
- colsq[0] += col[0]*col[0];
- colsq[1] += col[1]*col[1];
- colsq[2] += col[2]*col[2];
- }
- else {
- if ( RE_rayobject_raycast(R.raytree, isec) ) fac+= 1.0f;
- }
-
- samples++;
-
- if (lar->ray_samp_method == LA_SAMP_HALTON) {
-
- /* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */
- if ((max_samples > min_adapt_samples) && (adapt_thresh > 0.0f) && (samples > max_samples / 3)) {
- if (isec->mode==RE_RAY_SHADOW_TRA) {
- if ((shadfac[3] / samples > (1.0f-adapt_thresh)) || (shadfac[3] / samples < adapt_thresh))
- break;
- else if (adaptive_sample_variance(samples, shadfac, colsq, adapt_thresh))
- break;
- }
- else {
- if ((fac / samples > (1.0f-adapt_thresh)) || (fac / samples < adapt_thresh))
- break;
- }
- }
- }
- }
-
- if (isec->mode==RE_RAY_SHADOW_TRA) {
- shadfac[0] /= samples;
- shadfac[1] /= samples;
- shadfac[2] /= samples;
- shadfac[3] /= samples;
- }
- else
- shadfac[3]= 1.0f-fac/samples;
-
- if (qsa)
- release_thread_qmcsampler(&R, shi->thread, qsa);
-}
-
-static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[3], float shadfac[4], Isect *isec)
-{
- /* area soft shadow */
- const float *jitlamp;
- float fac=0.0f, div=0.0f, vec[3];
- int a, j= -1, mask;
- RayHint point_hint;
-
- if (isec->mode==RE_RAY_SHADOW_TRA) {
- shadfac[0]= shadfac[1]= shadfac[2]= shadfac[3]= 0.0f;
- }
- else shadfac[3]= 1.0f;
-
- fac= 0.0f;
- jitlamp= give_jitter_plane(lar, shi->thread, shi->xs, shi->ys);
-
- a= lar->ray_totsamp;
-
- /* this correction to make sure we always take at least 1 sample */
- mask= shi->mask;
- if (a==4) mask |= (mask>>4)|(mask>>8);
- else if (a==9) mask |= (mask>>9);
-
- copy_v3_v3(isec->start, shi->co);
- RE_instance_rotate_ray_start(shi->obi, isec);
-
- isec->orig.ob = shi->obi;
- isec->orig.face = shi->vlr;
- RE_rayobject_hint_bb(R.raytree, &point_hint, isec->start, isec->start);
- isec->hint = &point_hint;
-
- while (a--) {
-
- if (R.r.mode & R_OSA) {
- j++;
- if (j>=R.osa) j= 0;
- if (!(mask & (1<<j))) {
- jitlamp+= 2;
- continue;
- }
- }
-
- vec[0]= jitlamp[0];
- vec[1]= jitlamp[1];
- vec[2]= 0.0f;
- mul_m3_v3(lar->mat, vec);
-
- /* set start and vec */
- isec->dir[0] = vec[0]+lampco[0]-shi->co[0];
- isec->dir[1] = vec[1]+lampco[1]-shi->co[1];
- isec->dir[2] = vec[2]+lampco[2]-shi->co[2];
-
- RE_instance_rotate_ray_dir(shi->obi, isec);
-
- isec->dist = 1.0f;
- isec->check = RE_CHECK_VLR_RENDER;
- isec->skip = RE_SKIP_VLR_NEIGHBOUR;
-
- if (isec->mode==RE_RAY_SHADOW_TRA) {
- /* isec.col is like shadfac, so defines amount of light (0.0 is full shadow) */
- float col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
-
- ray_trace_shadow_tra(isec, shi, DEPTH_SHADOW_TRA, 0, col);
- shadfac[0] += col[0];
- shadfac[1] += col[1];
- shadfac[2] += col[2];
- shadfac[3] += col[3];
- }
- else if ( RE_rayobject_raycast(R.raytree, isec) ) fac+= 1.0f;
-
- div+= 1.0f;
- jitlamp+= 2;
- }
-
- if (isec->mode==RE_RAY_SHADOW_TRA) {
- shadfac[0] /= div;
- shadfac[1] /= div;
- shadfac[2] /= div;
- shadfac[3] /= div;
- }
- else {
- /* sqrt makes nice umbra effect */
- if (lar->ray_samp_type & LA_SAMP_UMBRA)
- shadfac[3] = sqrtf(1.0f - fac / div);
- else
- shadfac[3] = 1.0f - fac / div;
- }
-}
-/* extern call from shade_lamp_loop */
-void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4])
-{
- Isect isec;
- float lampco[3];
-
- /* setup isec */
- RE_RC_INIT(isec, *shi);
- if (shi->mat->mode & MA_SHADOW_TRA) isec.mode= RE_RAY_SHADOW_TRA;
- else isec.mode= RE_RAY_SHADOW;
- isec.hint = NULL;
-
- if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW))
- isec.lay= lar->lay;
- else
- isec.lay= -1;
-
- /* only when not mir tracing, first hit optimm */
- if (shi->depth==0) {
- isec.last_hit = lar->last_hit[shi->thread];
- }
- else {
- isec.last_hit = NULL;
- }
-
- if (lar->type==LA_SUN || lar->type==LA_HEMI) {
- /* jitter and QMC sampling add a displace vector to the lamp position
- * that's incorrect because a SUN lamp does not has an exact position
- * and the displace should be done at the ray vector instead of the
- * lamp position.
- * This is easily verified by noticing that shadows of SUN lights change
- * with the scene BB.
- *
- * This was detected during SoC 2009 - Raytrace Optimization, but to keep
- * consistency with older render code it wasn't removed.
- *
- * If the render code goes through some recode/serious bug-fix then this
- * is something to consider!
- */
- lampco[0]= shi->co[0] - R.maxdist*lar->vec[0];
- lampco[1]= shi->co[1] - R.maxdist*lar->vec[1];
- lampco[2]= shi->co[2] - R.maxdist*lar->vec[2];
- }
- else {
- copy_v3_v3(lampco, lar->co);
- }
-
- if (ELEM(lar->ray_samp_method, LA_SAMP_HALTON, LA_SAMP_HAMMERSLEY)) {
-
- ray_shadow_qmc(shi, lar, lampco, shadfac, &isec);
-
- }
- else {
- if (lar->ray_totsamp<2) {
-
- isec.orig.ob = shi->obi;
- isec.orig.face = shi->vlr;
-
- shadfac[3]= 1.0f; /* 1.0=full light */
-
- /* set up isec.dir */
- copy_v3_v3(isec.start, shi->co);
- sub_v3_v3v3(isec.dir, lampco, isec.start);
- isec.dist = normalize_v3(isec.dir);
-
- RE_instance_rotate_ray(shi->obi, &isec);
-
- if (isec.mode==RE_RAY_SHADOW_TRA) {
- /* isec.col is like shadfac, so defines amount of light (0.0 is full shadow) */
- float col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
-
- ray_trace_shadow_tra(&isec, shi, DEPTH_SHADOW_TRA, 0, col);
- copy_v4_v4(shadfac, col);
- }
- else if (RE_rayobject_raycast(R.raytree, &isec))
- shadfac[3]= 0.0f;
- }
- else {
- ray_shadow_jitter(shi, lar, lampco, shadfac, &isec);
- }
- }
-
- /* for first hit optim, set last interesected shadow face */
- if (shi->depth==0) {
- lar->last_hit[shi->thread] = isec.last_hit;
- }
-
-}
-
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 5abef431f3d..ba12eac3efa 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -408,7 +408,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
}
FOREACH_VIEW_LAYER_TO_RENDER_END;
- /* sss, previewrender and envmap don't do layers, so we make a default one */
+ /* previewrender doesn't do layers, so we make a default one */
if (BLI_listbase_is_empty(&rr->layers) && !(layername && layername[0])) {
rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
@@ -505,23 +505,6 @@ void render_result_add_pass(RenderResult *rr, const char *name, int channels, co
}
}
-/* allocate osa new results for samples */
-RenderResult *render_result_new_full_sample(Render *re, ListBase *lb, rcti *partrct, int crop, int savebuffers, const char *viewname)
-{
- int a;
-
- if (re->osa == 0)
- return render_result_new(re, partrct, crop, savebuffers, RR_ALL_LAYERS, viewname);
-
- for (a = 0; a < re->osa; a++) {
- RenderResult *rr = render_result_new(re, partrct, crop, savebuffers, RR_ALL_LAYERS, viewname);
- BLI_addtail(lb, rr);
- rr->sample_nr = a;
- }
-
- return lb->first;
-}
-
static int passtype_from_name(const char *name)
{
const char delim[] = {'.', '\0'};
@@ -1090,8 +1073,8 @@ void render_result_save_empty_result_tiles(Render *re)
for (rl = rr->layers.first; rl; rl = rl->next) {
for (pa = re->parts.first; pa; pa = pa->next) {
if (pa->status != PART_STATUS_MERGED) {
- int party = pa->disprect.ymin - re->disprect.ymin + pa->crop;
- int partx = pa->disprect.xmin - re->disprect.xmin + pa->crop;
+ int party = pa->disprect.ymin - re->disprect.ymin;
+ int partx = pa->disprect.xmin - re->disprect.xmin;
IMB_exrtile_write_channels(rl->exrhandle, partx, party, 0, re->viewname, true);
}
}
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index cefa739a796..79d13ecab5b 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -65,23 +65,11 @@
#include "MEM_guardedalloc.h"
-#include "envmap.h"
-#include "pointdensity.h"
-#include "voxeldata.h"
#include "render_types.h"
-#include "shading.h"
#include "texture.h"
-#include "texture_ocean.h"
-
-#include "renderdatabase.h" /* needed for UV */
#include "RE_render_ext.h"
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+#include "RE_shader_ext.h"
static RNG_THREAD_ARRAY *random_tex_array;
@@ -97,63 +85,6 @@ void RE_texture_rng_exit(void)
}
-static void init_render_texture(Render *re, Tex *tex)
-{
- /* imap test */
- if (tex->ima && BKE_image_is_animated(tex->ima)) {
- BKE_image_user_frame_calc(&tex->iuser, re ? re->r.cfra : 0, re ? re->flag & R_SEC_FIELD:0);
- }
-
- else if (tex->type==TEX_ENVMAP) {
- /* just in case */
- tex->imaflag |= TEX_INTERPOL | TEX_MIPMAP;
- tex->extend= TEX_CLIP;
-
- if (tex->env) {
- if (tex->env->type==ENV_PLANE)
- tex->extend= TEX_EXTEND;
-
- /* only free envmap when rendermode was set to render envmaps, for previewrender */
- if (G.is_rendering && re) {
- if (re->r.mode & R_ENVMAP)
- if (tex->env->stype==ENV_ANIM)
- BKE_texture_envmap_free_data(tex->env);
- }
- }
- }
-
- if (tex->nodetree && tex->use_nodes) {
- ntreeTexBeginExecTree(tex->nodetree); /* has internal flag to detect it only does it once */
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-void init_render_textures(Render *re)
-{
- Tex *tex;
-
- tex= re->main->tex.first;
- while (tex) {
- if (tex->id.us) init_render_texture(re, tex);
- tex= tex->id.next;
- }
-}
-
-static void end_render_texture(Tex *tex)
-{
- if (tex && tex->use_nodes && tex->nodetree && tex->nodetree->execdata)
- ntreeTexEndExecTree(tex->nodetree->execdata);
-}
-
-void end_render_textures(Render *re)
-{
- Tex *tex;
- for (tex= re->main->tex.first; tex; tex= tex->id.next)
- if (tex->id.us)
- end_render_texture(tex);
-}
-
/* ------------------------------------------------------------------------- */
@@ -755,7 +686,6 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
else {
copy_v3_v3(nor, n);
}
- mul_mat3_m4_v3(R.viewinv, nor);
x1 = fabsf(nor[0]);
y1 = fabsf(nor[1]);
@@ -781,115 +711,20 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
/* ------------------------------------------------------------------------- */
-/* mtex argument only for projection switches */
-static int cubemap(
- const MTex *mtex, VlakRen *vlr, const float n[3], float x, float y, float z, float *adr1, float *adr2)
-{
- int proj[4]={0, ME_PROJXY, ME_PROJXZ, ME_PROJYZ}, ret= 0;
-
- if (vlr) {
- int index;
-
- /* Mesh vertices have such flags, for others we calculate it once based on orco */
- if ((vlr->puno & (ME_PROJXY|ME_PROJXZ|ME_PROJYZ))==0) {
- /* test for v1, vlr can be faked for baking */
- if (vlr->v1 && vlr->v1->orco) {
- float nor[3];
- normal_tri_v3(nor, vlr->v1->orco, vlr->v2->orco, vlr->v3->orco);
-
- if (fabsf(nor[0]) < fabsf(nor[2]) && fabsf(nor[1]) < fabsf(nor[2])) vlr->puno |= ME_PROJXY;
- else if (fabsf(nor[0]) < fabsf(nor[1]) && fabsf(nor[2]) < fabsf(nor[1])) vlr->puno |= ME_PROJXZ;
- else vlr->puno |= ME_PROJYZ;
- }
- else return cubemap_glob(n, x, y, z, adr1, adr2);
- }
-
- if (mtex) {
- /* the mtex->proj{xyz} have type char. maybe this should be wider? */
- /* casting to int ensures that the index type is right. */
- index = (int) mtex->projx;
- proj[index]= ME_PROJXY;
-
- index = (int) mtex->projy;
- proj[index]= ME_PROJXZ;
-
- index = (int) mtex->projz;
- proj[index]= ME_PROJYZ;
- }
-
- if (vlr->puno & proj[1]) {
- *adr1 = (x + 1.0f) / 2.0f;
- *adr2 = (y + 1.0f) / 2.0f;
- }
- else if (vlr->puno & proj[2]) {
- *adr1 = (x + 1.0f) / 2.0f;
- *adr2 = (z + 1.0f) / 2.0f;
- ret= 1;
- }
- else {
- *adr1 = (y + 1.0f) / 2.0f;
- *adr2 = (z + 1.0f) / 2.0f;
- ret= 2;
- }
- }
- else {
- return cubemap_glob(n, x, y, z, adr1, adr2);
- }
-
- return ret;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static int cubemap_ob(Object *ob, const float n[3], float x, float y, float z, float *adr1, float *adr2)
-{
- float x1, y1, z1, nor[3];
- int ret;
-
- if (n==NULL) return 0;
-
- copy_v3_v3(nor, n);
- if (ob) mul_mat3_m4_v3(ob->imat, nor);
-
- x1 = fabsf(nor[0]);
- y1 = fabsf(nor[1]);
- z1 = fabsf(nor[2]);
-
- if (z1>=x1 && z1>=y1) {
- *adr1 = (x + 1.0f) / 2.0f;
- *adr2 = (y + 1.0f) / 2.0f;
- ret= 0;
- }
- else if (y1>=x1 && y1>=z1) {
- *adr1 = (x + 1.0f) / 2.0f;
- *adr2 = (z + 1.0f) / 2.0f;
- ret= 1;
- }
- else {
- *adr1 = (y + 1.0f) / 2.0f;
- *adr2 = (z + 1.0f) / 2.0f;
- ret= 2;
- }
- return ret;
-}
-
/* ------------------------------------------------------------------------- */
static void do_2d_mapping(
- const MTex *mtex, float texvec[3], VlakRen *vlr, const float n[3], float dxt[3], float dyt[3])
+ const MTex *mtex, float texvec[3], const float n[3], float dxt[3], float dyt[3])
{
Tex *tex;
- Object *ob= NULL;
float fx, fy, fac1, area[8];
- int ok, proj, areaflag= 0, wrap, texco;
+ int ok, proj, areaflag= 0, wrap;
/* mtex variables localized, only cubemap doesn't cooperate yet... */
wrap= mtex->mapping;
tex= mtex->tex;
- ob= mtex->object;
- texco= mtex->texco;
- if (R.osa==0) {
+ if (!(dxt && dyt)) {
if (wrap==MTEX_FLAT) {
fx = (texvec[0] + 1.0f) / 2.0f;
@@ -898,9 +733,7 @@ static void do_2d_mapping(
else if (wrap == MTEX_TUBE) map_to_tube( &fx, &fy, texvec[0], texvec[1], texvec[2]);
else if (wrap == MTEX_SPHERE) map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
else {
- if (texco == TEXCO_OBJECT) cubemap_ob(ob, n, texvec[0], texvec[1], texvec[2], &fx, &fy);
- else if (texco == TEXCO_GLOB) cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
- else cubemap(mtex, vlr, n, texvec[0], texvec[1], texvec[2], &fx, &fy);
+ cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
}
/* repeat */
@@ -996,9 +829,7 @@ static void do_2d_mapping(
}
else {
- if (texco==TEXCO_OBJECT) proj = cubemap_ob(ob, n, texvec[0], texvec[1], texvec[2], &fx, &fy);
- else if (texco==TEXCO_GLOB) proj = cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
- else proj = cubemap(mtex, vlr, n, texvec[0], texvec[1], texvec[2], &fx, &fy);
+ proj = cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
if (proj==1) {
SWAP(float, dxt[1], dxt[2]);
@@ -1124,8 +955,9 @@ static int multitex(Tex *tex,
texres->talpha = false; /* is set when image texture returns alpha (considered premul) */
if (use_nodes && tex->use_nodes && tex->nodetree) {
+ const float cfra = 1.0f; /* This was only set for Blender Internal render before. */
retval = ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, osatex, thread,
- tex, which_output, R.r.cfra, texnode_preview, NULL, NULL);
+ tex, which_output, cfra, texnode_preview, NULL);
}
else {
switch (tex->type) {
@@ -1160,9 +992,6 @@ static int multitex(Tex *tex,
BKE_image_tag_time(tex->ima);
}
break;
- case TEX_ENVMAP:
- retval = envmaptex(tex, texvec, dxt, dyt, osatex, texres, pool, skip_load_image);
- break;
case TEX_MUSGRAVE:
/* newnoise: musgrave types */
@@ -1205,15 +1034,6 @@ static int multitex(Tex *tex,
retval = mg_distNoiseTex(tex, tmpvec, texres);
break;
- case TEX_POINTDENSITY:
- retval = pointdensitytex(tex, texvec, texres);
- break;
- case TEX_VOXELDATA:
- retval = voxeldatatex(tex, texvec, texres);
- break;
- case TEX_OCEAN:
- retval = ocean_texture(tex, texvec, texres);
- break;
}
}
@@ -1238,7 +1058,6 @@ static int multitex_nodes_intern(Tex *tex,
TexResult *texres,
const short thread,
short which_output,
- ShadeInput *shi,
MTex *mtex, struct
ImagePool *pool,
const bool scene_color_manage,
@@ -1259,7 +1078,7 @@ static int multitex_nodes_intern(Tex *tex,
if (mtex) {
/* we have mtex, use it for 2d mapping images only */
- do_2d_mapping(mtex, texvec, shi->vlr, shi->facenor, dxt, dyt);
+ do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
rgbnor = multitex(tex,
texvec,
dxt, dyt,
@@ -1272,7 +1091,7 @@ static int multitex_nodes_intern(Tex *tex,
texnode_preview,
use_nodes);
- if (mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) {
+ if (mtex->mapto & (MAP_COL)) {
ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool);
/* don't linearize float buffers, assumed to be linear */
@@ -1307,7 +1126,7 @@ static int multitex_nodes_intern(Tex *tex,
zero_v3(dyt_l);
}
- do_2d_mapping(&localmtex, texvec_l, NULL, NULL, dxt_l, dyt_l);
+ do_2d_mapping(&localmtex, texvec_l, NULL, dxt_l, dyt_l);
rgbnor = multitex(tex,
texvec_l,
dxt_l, dyt_l,
@@ -1357,41 +1176,15 @@ static int multitex_nodes_intern(Tex *tex,
* Use it from render pipeline only!
*/
int multitex_nodes(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres,
- const short thread, short which_output, ShadeInput *shi, MTex *mtex, struct ImagePool *pool)
+ const short thread, short which_output, MTex *mtex, struct ImagePool *pool)
{
return multitex_nodes_intern(tex, texvec, dxt, dyt, osatex, texres,
- thread, which_output, shi, mtex, pool, R.scene_color_manage,
- (R.r.scemode & R_NO_IMAGE_LOAD) != 0,
- (R.r.scemode & R_TEXNODE_PREVIEW) != 0,
+ thread, which_output, mtex, pool, true,
+ false,
+ false,
true);
}
-/* this is called for surface shading */
-static int multitex_mtex(ShadeInput *shi, MTex *mtex, float texvec[3], float dxt[3], float dyt[3], TexResult *texres, struct ImagePool *pool, const bool skip_load_image)
-{
- Tex *tex = mtex->tex;
- /* TODO(sergey): Texture preview should become an argument? */
- if (tex->use_nodes && tex->nodetree) {
- /* stupid exception here .. but we have to pass shi and mtex to
- * textures nodes for 2d mapping and color management for images */
- return ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, shi->osatex, shi->thread,
- tex, mtex->which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, shi, mtex);
- }
- else {
- return multitex(mtex->tex,
- texvec,
- dxt, dyt,
- shi->osatex,
- texres,
- shi->thread,
- mtex->which_output,
- pool,
- skip_load_image,
- (R.r.scemode & R_TEXNODE_PREVIEW) != 0,
- true);
- }
-}
-
/* Warning, if the texres's values are not declared zero, check the return value to be sure
* the color values are set before using the r/g/b values, otherwise you may use uninitialized values - Campbell
*
@@ -1414,7 +1207,7 @@ int multitex_ext(Tex *tex,
texres,
thread,
0,
- NULL, NULL,
+ NULL,
pool,
scene_color_manage,
skip_load_image,
@@ -1435,7 +1228,7 @@ int multitex_ext_safe(Tex *tex, float texvec[3], TexResult *texres, struct Image
texres,
0,
0,
- NULL, NULL,
+ NULL,
pool,
scene_color_manage,
skip_load_image,
@@ -1652,1949 +1445,6 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
return in;
}
-static void texco_mapping(ShadeInput *shi, Tex *tex, MTex *mtex,
- const float co[3], const float dx[3], const float dy[3], float texvec[3], float dxt[3], float dyt[3])
-{
- /* new: first swap coords, then map, then trans/scale */
- if (tex->type == TEX_IMAGE) {
- /* placement */
- texvec[0] = mtex->projx ? co[mtex->projx - 1] : 0.f;
- texvec[1] = mtex->projy ? co[mtex->projy - 1] : 0.f;
- texvec[2] = mtex->projz ? co[mtex->projz - 1] : 0.f;
-
- if (shi->osatex) {
- if (mtex->projx) {
- dxt[0] = dx[mtex->projx - 1];
- dyt[0] = dy[mtex->projx - 1];
- }
- else dxt[0] = dyt[0] = 0.f;
- if (mtex->projy) {
- dxt[1] = dx[mtex->projy - 1];
- dyt[1] = dy[mtex->projy - 1];
- }
- else dxt[1] = dyt[1] = 0.f;
- if (mtex->projz) {
- dxt[2] = dx[mtex->projz - 1];
- dyt[2] = dy[mtex->projz - 1];
- }
- else dxt[2] = dyt[2] = 0.f;
- }
- do_2d_mapping(mtex, texvec, shi->vlr, shi->facenor, dxt, dyt);
-
- /* translate and scale */
- texvec[0] = mtex->size[0]*(texvec[0] - 0.5f) + mtex->ofs[0] + 0.5f;
- texvec[1] = mtex->size[1]*(texvec[1] - 0.5f) + mtex->ofs[1] + 0.5f;
- if (shi->osatex) {
- dxt[0] = mtex->size[0] * dxt[0];
- dxt[1] = mtex->size[1] * dxt[1];
- dyt[0] = mtex->size[0] * dyt[0];
- dyt[1] = mtex->size[1] * dyt[1];
- }
-
- /* problem: repeat-mirror is not a 'repeat' but 'extend' in imagetexture.c */
- /* TXF: bug was here, only modify texvec when repeat mode set, old code affected other modes too.
- * New texfilters solve mirroring differently so that it also works correctly when
- * textures are scaled (sizeXYZ) as well as repeated. See also modification in do_2d_mapping().
- * (since currently only done in osa mode, results will look incorrect without osa TODO) */
- if (tex->extend == TEX_REPEAT && (tex->flag & TEX_REPEAT_XMIR)) {
- if (tex->texfilter == TXF_BOX)
- texvec[0] -= floorf(texvec[0]); /* this line equivalent to old code, same below */
- else if (texvec[0] < 0.f || texvec[0] > 1.f) {
- const float tx = 0.5f*texvec[0];
- texvec[0] = 2.f*(tx - floorf(tx));
- if (texvec[0] > 1.f) texvec[0] = 2.f - texvec[0];
- }
- }
- if (tex->extend == TEX_REPEAT && (tex->flag & TEX_REPEAT_YMIR)) {
- if (tex->texfilter == TXF_BOX)
- texvec[1] -= floorf(texvec[1]);
- else if (texvec[1] < 0.f || texvec[1] > 1.f) {
- const float ty = 0.5f*texvec[1];
- texvec[1] = 2.f*(ty - floorf(ty));
- if (texvec[1] > 1.f) texvec[1] = 2.f - texvec[1];
- }
- }
-
- }
- else { /* procedural */
- /* placement */
- texvec[0] = mtex->size[0]*(mtex->projx ? (co[mtex->projx - 1] + mtex->ofs[0]) : mtex->ofs[0]);
- texvec[1] = mtex->size[1]*(mtex->projy ? (co[mtex->projy - 1] + mtex->ofs[1]) : mtex->ofs[1]);
- texvec[2] = mtex->size[2]*(mtex->projz ? (co[mtex->projz - 1] + mtex->ofs[2]) : mtex->ofs[2]);
-
- if (shi->osatex) {
- if (mtex->projx) {
- dxt[0] = mtex->size[0]*dx[mtex->projx - 1];
- dyt[0] = mtex->size[0]*dy[mtex->projx - 1];
- }
- else dxt[0] = dyt[0] = 0.f;
- if (mtex->projy) {
- dxt[1] = mtex->size[1]*dx[mtex->projy - 1];
- dyt[1] = mtex->size[1]*dy[mtex->projy - 1];
- }
- else dxt[1] = dyt[1] = 0.f;
- if (mtex->projz) {
- dxt[2] = mtex->size[2]*dx[mtex->projz - 1];
- dyt[2] = mtex->size[2]*dy[mtex->projz - 1];
- }
- else dxt[2]= dyt[2] = 0.f;
- }
-
- if (mtex->tex->type == TEX_ENVMAP) {
- EnvMap *env = tex->env;
- if (!env->object) {
- // env->object is a view point for envmap rendering
- // if it's not set, return the result depending on the world_space_shading flag
- if (BKE_scene_use_world_space_shading(R.scene)) {
- mul_mat3_m4_v3(R.viewinv, texvec);
- if (shi->osatex) {
- mul_mat3_m4_v3(R.viewinv, dxt);
- mul_mat3_m4_v3(R.viewinv, dyt);
- }
- }
- }
- }
- }
-}
-
-/* Bump code from 2.5 development cycle, has a number of bugs, but here for compatibility */
-
-typedef struct CompatibleBump {
- float nu[3], nv[3], nn[3];
- float dudnu, dudnv, dvdnu, dvdnv;
- bool nunvdone;
-} CompatibleBump;
-
-static void compatible_bump_init(CompatibleBump *compat_bump)
-{
- memset(compat_bump, 0, sizeof(*compat_bump));
-
- compat_bump->dudnu = 1.0f;
- compat_bump->dvdnv = 1.0f;
-}
-
-static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, int i)
-{
- /* uvmapping only, calculation of normal tangent u/v partial derivatives
- * (should not be here, dudnu, dudnv, dvdnu & dvdnv should probably be part of ShadeInputUV struct,
- * nu/nv in ShadeInput and this calculation should then move to shadeinput.c,
- * shade_input_set_shade_texco() func.) */
-
- /* NOTE: test for shi->obr->ob here,
- * since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. */
-
- /* NOTE: shi->v1 is NULL when called from displace_render_vert,
- * assigning verts in this case is not trivial because the shi quad face side is not know. */
- if ((mtex->texflag & MTEX_COMPAT_BUMP) && shi->obr && shi->obr->ob && shi->v1) {
- if (mtex->mapto & (MAP_NORM|MAP_WARP) && !((mtex->tex->type==TEX_IMAGE) && (mtex->tex->imaflag & TEX_NORMALMAP))) {
- MTFace* tf = RE_vlakren_get_tface(shi->obr, shi->vlr, i, NULL, 0);
- int j1 = shi->i1, j2 = shi->i2, j3 = shi->i3;
-
- vlr_set_uv_indices(shi->vlr, &j1, &j2, &j3);
-
- /* compute ortho basis around normal */
- if (!compat_bump->nunvdone) {
- /* render normal is negated */
- compat_bump->nn[0] = -shi->vn[0];
- compat_bump->nn[1] = -shi->vn[1];
- compat_bump->nn[2] = -shi->vn[2];
- ortho_basis_v3v3_v3(compat_bump->nu, compat_bump->nv, compat_bump->nn);
- compat_bump->nunvdone = true;
- }
-
- if (tf) {
- const float *uv1 = tf->uv[j1], *uv2 = tf->uv[j2], *uv3 = tf->uv[j3];
- const float an[3] = {fabsf(compat_bump->nn[0]), fabsf(compat_bump->nn[1]), fabsf(compat_bump->nn[2])};
- const int a1 = (an[0] > an[1] && an[0] > an[2]) ? 1 : 0;
- const int a2 = (an[2] > an[0] && an[2] > an[1]) ? 1 : 2;
- const float dp1_a1 = shi->v1->co[a1] - shi->v3->co[a1];
- const float dp1_a2 = shi->v1->co[a2] - shi->v3->co[a2];
- const float dp2_a1 = shi->v2->co[a1] - shi->v3->co[a1];
- const float dp2_a2 = shi->v2->co[a2] - shi->v3->co[a2];
- const float du1 = uv1[0] - uv3[0], du2 = uv2[0] - uv3[0];
- const float dv1 = uv1[1] - uv3[1], dv2 = uv2[1] - uv3[1];
- const float dpdu_a1 = dv2*dp1_a1 - dv1*dp2_a1;
- const float dpdu_a2 = dv2*dp1_a2 - dv1*dp2_a2;
- const float dpdv_a1 = du1*dp2_a1 - du2*dp1_a1;
- const float dpdv_a2 = du1*dp2_a2 - du2*dp1_a2;
- float d = dpdu_a1*dpdv_a2 - dpdv_a1*dpdu_a2;
- float uvd = du1*dv2 - dv1*du2;
-
- if (uvd == 0.f) uvd = 1e-5f;
- if (d == 0.f) d = 1e-5f;
- d = uvd / d;
-
- compat_bump->dudnu = (dpdv_a2*compat_bump->nu[a1] - dpdv_a1*compat_bump->nu[a2])*d;
- compat_bump->dvdnu = (dpdu_a1*compat_bump->nu[a2] - dpdu_a2*compat_bump->nu[a1])*d;
- compat_bump->dudnv = (dpdv_a2*compat_bump->nv[a1] - dpdv_a1*compat_bump->nv[a2])*d;
- compat_bump->dvdnv = (dpdu_a1*compat_bump->nv[a2] - dpdu_a2*compat_bump->nv[a1])*d;
- }
- }
- }
-}
-
-static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres,
- float Tnor, const float co[3], const float dx[3], const float dy[3], float texvec[3], float dxt[3], float dyt[3],
- struct ImagePool *pool, const bool skip_load_image)
-{
- TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */
- float tco[3], texv[3], cd, ud, vd, du, dv, idu, idv;
- const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0));
- const float bf = -0.04f*Tnor*mtex->norfac;
- int rgbnor;
- /* disable internal bump eval */
- float *nvec = texres->nor;
- texres->nor = NULL;
- /* du & dv estimates, constant value defaults */
- du = dv = 0.01f;
-
- /* compute ortho basis around normal */
- if (!compat_bump->nunvdone) {
- /* render normal is negated */
- negate_v3_v3(compat_bump->nn, shi->vn);
- ortho_basis_v3v3_v3(compat_bump->nu, compat_bump->nv, compat_bump->nn);
- compat_bump->nunvdone = true;
- }
-
- /* two methods, either constant based on main image resolution,
- * (which also works without osa, though of course not always good (or even very bad) results),
- * or based on tex derivative max values (osa only). Not sure which is best... */
-
- if (!shi->osatex && (tex->type == TEX_IMAGE) && tex->ima) {
- /* in case we have no proper derivatives, fall back to
- * computing du/dv it based on image size */
- ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool);
- if (ibuf) {
- du = 1.f/(float)ibuf->x;
- dv = 1.f/(float)ibuf->y;
- }
- BKE_image_pool_release_ibuf(tex->ima, ibuf, pool);
- }
- else if (shi->osatex) {
- /* we have derivatives, can compute proper du/dv */
- if (tex->type == TEX_IMAGE) { /* 2d image, use u & v max. of dx/dy 2d vecs */
- const float adx[2] = {fabsf(dx[0]), fabsf(dx[1])};
- const float ady[2] = {fabsf(dy[0]), fabsf(dy[1])};
- du = MAX2(adx[0], ady[0]);
- dv = MAX2(adx[1], ady[1]);
- }
- else { /* 3d procedural, estimate from all dx/dy elems */
- const float adx[3] = {fabsf(dx[0]), fabsf(dx[1]), fabsf(dx[2])};
- const float ady[3] = {fabsf(dy[0]), fabsf(dy[1]), fabsf(dy[2])};
- du = max_fff(adx[0], adx[1], adx[2]);
- dv = max_fff(ady[0], ady[1], ady[2]);
- }
- }
-
- /* center, main return value */
- texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
- rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres, pool, skip_load_image);
- cd = fromrgb ? (texres->tr + texres->tg + texres->tb) / 3.0f : texres->tin;
-
- if (mtex->texco == TEXCO_UV) {
- /* for the uv case, use the same value for both du/dv,
- * since individually scaling the normal derivatives makes them useless... */
- du = min_ff(du, dv);
- idu = (du < 1e-5f) ? bf : (bf/du);
-
- /* +u val */
- tco[0] = co[0] + compat_bump->dudnu*du;
- tco[1] = co[1] + compat_bump->dvdnu*du;
- tco[2] = 0.f;
- texco_mapping(shi, tex, mtex, tco, dx, dy, texv, dxt, dyt);
- multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr, pool, skip_load_image);
- ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb) / 3.0f : ttexr.tin));
-
- /* +v val */
- tco[0] = co[0] + compat_bump->dudnv*du;
- tco[1] = co[1] + compat_bump->dvdnv*du;
- tco[2] = 0.f;
- texco_mapping(shi, tex, mtex, tco, dx, dy, texv, dxt, dyt);
- multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr, pool, skip_load_image);
- vd = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb) / 3.0f : ttexr.tin));
- }
- else {
- float tu[3], tv[3];
-
- copy_v3_v3(tu, compat_bump->nu);
- copy_v3_v3(tv, compat_bump->nv);
-
- idu = (du < 1e-5f) ? bf : (bf/du);
- idv = (dv < 1e-5f) ? bf : (bf/dv);
-
- if ((mtex->texco == TEXCO_ORCO) && shi->obr && shi->obr->ob) {
- mul_mat3_m4_v3(shi->obr->ob->imat_ren, tu);
- mul_mat3_m4_v3(shi->obr->ob->imat_ren, tv);
- normalize_v3(tu);
- normalize_v3(tv);
- }
- else if (mtex->texco == TEXCO_GLOB) {
- mul_mat3_m4_v3(R.viewinv, tu);
- mul_mat3_m4_v3(R.viewinv, tv);
- }
- else if (mtex->texco == TEXCO_OBJECT && mtex->object) {
- mul_mat3_m4_v3(mtex->object->imat_ren, tu);
- mul_mat3_m4_v3(mtex->object->imat_ren, tv);
- normalize_v3(tu);
- normalize_v3(tv);
- }
-
- /* +u val */
- tco[0] = co[0] + tu[0]*du;
- tco[1] = co[1] + tu[1]*du;
- tco[2] = co[2] + tu[2]*du;
- texco_mapping(shi, tex, mtex, tco, dx, dy, texv, dxt, dyt);
- multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr, pool, skip_load_image);
- ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb) / 3.0f : ttexr.tin));
-
- /* +v val */
- tco[0] = co[0] + tv[0]*dv;
- tco[1] = co[1] + tv[1]*dv;
- tco[2] = co[2] + tv[2]*dv;
- texco_mapping(shi, tex, mtex, tco, dx, dy, texv, dxt, dyt);
- multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr, pool, skip_load_image);
- vd = idv*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb) / 3.0f : ttexr.tin));
- }
-
- /* bumped normal */
- compat_bump->nu[0] += ud*compat_bump->nn[0];
- compat_bump->nu[1] += ud*compat_bump->nn[1];
- compat_bump->nu[2] += ud*compat_bump->nn[2];
- compat_bump->nv[0] += vd*compat_bump->nn[0];
- compat_bump->nv[1] += vd*compat_bump->nn[1];
- compat_bump->nv[2] += vd*compat_bump->nn[2];
- cross_v3_v3v3(nvec, compat_bump->nu, compat_bump->nv);
-
- nvec[0] = -nvec[0];
- nvec[1] = -nvec[1];
- nvec[2] = -nvec[2];
- texres->nor = nvec;
-
- rgbnor |= TEX_NOR;
- return rgbnor;
-}
-
-/* Improved bump code from later in 2.5 development cycle */
-
-typedef struct NTapBump {
- int init_done;
- int iPrevBumpSpace; /* 0: uninitialized, 1: objectspace, 2: texturespace, 4: viewspace */
- /* bumpmapping */
- float vNorg[3]; /* backup copy of shi->vn */
- float vNacc[3]; /* original surface normal minus the surface gradient of every bump map which is encountered */
- float vR1[3], vR2[3]; /* cross products (sigma_y, original_normal), (original_normal, sigma_x) */
- float sgn_det; /* sign of the determinant of the matrix {sigma_x, sigma_y, original_normal} */
- float fPrevMagnitude; /* copy of previous magnitude, used for multiple bumps in different spaces */
-} NTapBump;
-
-static void ntap_bump_init(NTapBump *ntap_bump)
-{
- memset(ntap_bump, 0, sizeof(*ntap_bump));
-}
-
-static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres,
- float Tnor, const float co[3], const float dx[3], const float dy[3],
- float texvec[3], float dxt[3], float dyt[3], struct ImagePool *pool,
- const bool skip_load_image)
-{
- TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */
-
- const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0));
-
- /* The negate on Hscale is done because the
- * normal in the renderer points inward which corresponds
- * to inverting the bump map. The normals are generated
- * this way in calc_vertexnormals(). Should this ever change
- * this negate must be removed. */
- float Hscale = -Tnor*mtex->norfac;
-
- int dimx=512, dimy=512;
- const int imag_tspace_dimension_x = 1024; /* only used for texture space variant */
- float aspect = 1.0f;
-
- /* 2 channels for 2D texture and 3 for 3D textures. */
- const int nr_channels = (mtex->texco == TEXCO_UV)? 2 : 3;
- int c, rgbnor, iBumpSpace;
- float dHdx, dHdy;
- int found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP);
-
- /* disable internal bump eval in sampler, save pointer */
- float *nvec = texres->nor;
- texres->nor = NULL;
-
- if (found_deriv_map==0) {
- if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
- if (tex->ima)
- Hscale *= 13.0f; /* appears to be a sensible default value */
- }
- else
- Hscale *= 0.1f; /* factor 0.1 proved to look like the previous bump code */
- }
-
- if ( !ntap_bump->init_done ) {
- copy_v3_v3(ntap_bump->vNacc, shi->vn);
- copy_v3_v3(ntap_bump->vNorg, shi->vn);
- ntap_bump->fPrevMagnitude = 1.0f;
- ntap_bump->iPrevBumpSpace = 0;
-
- ntap_bump->init_done = true;
- }
-
- /* resolve image dimensions */
- if (found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) {
- ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool);
- if (ibuf) {
- dimx = ibuf->x;
- dimy = ibuf->y;
- aspect = ((float) dimy) / dimx;
- }
- BKE_image_pool_release_ibuf(tex->ima, ibuf, pool);
- }
-
- if (found_deriv_map) {
- float dBdu, dBdv, auto_bump = 1.0f;
- float s = 1; /* negate this if flipped texture coordinate */
- texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
- rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres, pool, skip_load_image);
-
- if (shi->obr->ob->derivedFinal) {
- auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale;
- }
-
- {
- float fVirtDim = sqrtf(fabsf((float) (dimx*dimy)*mtex->size[0]*mtex->size[1]));
- auto_bump /= MAX2(fVirtDim, FLT_EPSILON);
- }
-
- /* this variant using a derivative map is described here
- * http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html */
- dBdu = auto_bump*Hscale*dimx*(2*texres->tr-1);
- dBdv = auto_bump*Hscale*dimy*(2*texres->tg-1);
-
- dHdx = dBdu*dxt[0] + s * dBdv*dxt[1];
- dHdy = dBdu*dyt[0] + s * dBdv*dyt[1];
- }
- else if (!(mtex->texflag & MTEX_5TAP_BUMP)) {
- /* compute height derivatives with respect to output image pixel coordinates x and y */
- float STll[3], STlr[3], STul[3];
- float Hll, Hlr, Hul;
-
- texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
-
- for (c=0; c<nr_channels; c++) {
- /* dx contains the derivatives (du/dx, dv/dx)
- * dy contains the derivatives (du/dy, dv/dy) */
- STll[c] = texvec[c];
- STlr[c] = texvec[c]+dxt[c];
- STul[c] = texvec[c]+dyt[c];
- }
-
- /* clear unused derivatives */
- for (c=nr_channels; c<3; c++) {
- STll[c] = 0.0f;
- STlr[c] = 0.0f;
- STul[c] = 0.0f;
- }
-
- /* use texres for the center sample, set rgbnor */
- rgbnor = multitex_mtex(shi, mtex, STll, dxt, dyt, texres, pool, skip_load_image);
- Hll = (fromrgb) ? IMB_colormanagement_get_luminance(&texres->tr) : texres->tin;
-
- /* use ttexr for the other 2 taps */
- multitex_mtex(shi, mtex, STlr, dxt, dyt, &ttexr, pool, skip_load_image);
- Hlr = (fromrgb) ? IMB_colormanagement_get_luminance(&ttexr.tr) : ttexr.tin;
-
- multitex_mtex(shi, mtex, STul, dxt, dyt, &ttexr, pool, skip_load_image);
- Hul = (fromrgb) ? IMB_colormanagement_get_luminance(&ttexr.tr) : ttexr.tin;
-
- dHdx = Hscale*(Hlr - Hll);
- dHdy = Hscale*(Hul - Hll);
- }
- else {
- /* same as above, but doing 5 taps, increasing quality at cost of speed */
- float STc[3], STl[3], STr[3], STd[3], STu[3];
- float /* Hc, */ /* UNUSED */ Hl, Hr, Hd, Hu;
-
- texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
-
- for (c=0; c<nr_channels; c++) {
- STc[c] = texvec[c];
- STl[c] = texvec[c] - 0.5f*dxt[c];
- STr[c] = texvec[c] + 0.5f*dxt[c];
- STd[c] = texvec[c] - 0.5f*dyt[c];
- STu[c] = texvec[c] + 0.5f*dyt[c];
- }
-
- /* clear unused derivatives */
- for (c=nr_channels; c<3; c++) {
- STc[c] = 0.0f;
- STl[c] = 0.0f;
- STr[c] = 0.0f;
- STd[c] = 0.0f;
- STu[c] = 0.0f;
- }
-
- /* use texres for the center sample, set rgbnor */
- rgbnor = multitex_mtex(shi, mtex, STc, dxt, dyt, texres, pool, skip_load_image);
- /* Hc = (fromrgb) ? IMB_colormanagement_get_luminance(&texres->tr) : texres->tin; */ /* UNUSED */
-
- /* use ttexr for the other taps */
- multitex_mtex(shi, mtex, STl, dxt, dyt, &ttexr, pool, skip_load_image);
- Hl = (fromrgb) ? IMB_colormanagement_get_luminance(&ttexr.tr) : ttexr.tin;
- multitex_mtex(shi, mtex, STr, dxt, dyt, &ttexr, pool, skip_load_image);
- Hr = (fromrgb) ? IMB_colormanagement_get_luminance(&ttexr.tr) : ttexr.tin;
- multitex_mtex(shi, mtex, STd, dxt, dyt, &ttexr, pool, skip_load_image);
- Hd = (fromrgb) ? IMB_colormanagement_get_luminance(&ttexr.tr) : ttexr.tin;
- multitex_mtex(shi, mtex, STu, dxt, dyt, &ttexr, pool, skip_load_image);
- Hu = (fromrgb) ? IMB_colormanagement_get_luminance(&ttexr.tr) : ttexr.tin;
-
- dHdx = Hscale*(Hr - Hl);
- dHdy = Hscale*(Hu - Hd);
- }
-
- /* restore pointer */
- texres->nor = nvec;
-
- /* replaced newbump with code based on listing 1 and 2 of
- * [Mik10] Mikkelsen M. S.: Bump Mapping Unparameterized Surfaces on the GPU.
- * -> http://jbit.net/~sparky/sfgrad_bump/mm_sfgrad_bump.pdf */
-
- if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE )
- iBumpSpace = 1;
- else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
- iBumpSpace = 2;
- else
- iBumpSpace = 4; /* ViewSpace */
-
- if ( ntap_bump->iPrevBumpSpace != iBumpSpace ) {
-
- /* initialize normal perturbation vectors */
- int xyz;
- float fDet, abs_fDet, fMagnitude;
- /* object2view and inverted matrix */
- float obj2view[3][3], view2obj[3][3], tmp[4][4];
- /* local copies of derivatives and normal */
- float dPdx[3], dPdy[3], vN[3];
- copy_v3_v3(dPdx, shi->dxco);
- copy_v3_v3(dPdy, shi->dyco);
- copy_v3_v3(vN, ntap_bump->vNorg);
-
- if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) {
- /* TODO: these calculations happen for every pixel!
- * -> move to shi->obi */
- mul_m4_m4m4(tmp, R.viewmat, shi->obr->ob->obmat);
- copy_m3_m4(obj2view, tmp); /* use only upper left 3x3 matrix */
- invert_m3_m3(view2obj, obj2view);
-
- /* generate the surface derivatives in object space */
- mul_m3_v3(view2obj, dPdx);
- mul_m3_v3(view2obj, dPdy);
- /* generate the unit normal in object space */
- mul_transposed_m3_v3(obj2view, vN);
- normalize_v3(vN);
- }
-
- cross_v3_v3v3(ntap_bump->vR1, dPdy, vN);
- cross_v3_v3v3(ntap_bump->vR2, vN, dPdx);
- fDet = dot_v3v3(dPdx, ntap_bump->vR1);
- ntap_bump->sgn_det = (fDet < 0)? -1.0f: 1.0f;
- abs_fDet = ntap_bump->sgn_det * fDet;
-
- if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
- if (tex->ima) {
- /* crazy hack solution that gives results similar to normal mapping - part 1 */
- normalize_v3(ntap_bump->vR1);
- normalize_v3(ntap_bump->vR2);
- abs_fDet = 1.0f;
- }
- }
-
- fMagnitude = abs_fDet;
- if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) {
- /* pre do transform of texres->nor by the inverse transposed of obj2view */
- mul_transposed_m3_v3(view2obj, vN);
- mul_transposed_m3_v3(view2obj, ntap_bump->vR1);
- mul_transposed_m3_v3(view2obj, ntap_bump->vR2);
-
- fMagnitude *= len_v3(vN);
- }
-
- if (ntap_bump->fPrevMagnitude > 0.0f)
- for (xyz=0; xyz<3; xyz++)
- ntap_bump->vNacc[xyz] *= fMagnitude / ntap_bump->fPrevMagnitude;
-
- ntap_bump->fPrevMagnitude = fMagnitude;
- ntap_bump->iPrevBumpSpace = iBumpSpace;
- }
-
- if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
- if (tex->ima) {
- /* crazy hack solution that gives results similar to normal mapping - part 2 */
- float vec[2];
- const float imag_tspace_dimension_y = aspect*imag_tspace_dimension_x;
-
- vec[0] = imag_tspace_dimension_x*dxt[0];
- vec[1] = imag_tspace_dimension_y*dxt[1];
- dHdx *= 1.0f/len_v2(vec);
- vec[0] = imag_tspace_dimension_x*dyt[0];
- vec[1] = imag_tspace_dimension_y*dyt[1];
- dHdy *= 1.0f/len_v2(vec);
- }
- }
-
- /* subtract the surface gradient from vNacc */
- for (c=0; c<3; c++) {
- float vSurfGrad_compi = ntap_bump->sgn_det * (dHdx * ntap_bump->vR1[c] + dHdy * ntap_bump->vR2[c]);
- ntap_bump->vNacc[c] -= vSurfGrad_compi;
- texres->nor[c] = ntap_bump->vNacc[c]; /* copy */
- }
-
- rgbnor |= TEX_NOR;
- return rgbnor;
-}
-
-void do_material_tex(ShadeInput *shi, Render *re)
-{
- const bool skip_load_image = (R.r.scemode & R_NO_IMAGE_LOAD) != 0;
- CompatibleBump compat_bump;
- NTapBump ntap_bump;
- MTex *mtex;
- Tex *tex;
- TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
- float *co = NULL, *dx = NULL, *dy = NULL;
- float fact, facm, factt, facmm, stencilTin=1.0;
- float texvec[3], dxt[3], dyt[3], tempvec[3], norvec[3], warpvec[3]={0.0f, 0.0f, 0.0f}, Tnor=1.0;
- int tex_nr, rgbnor= 0;
- bool warp_done = false, use_compat_bump = false, use_ntap_bump = false;
- bool found_nmapping = false, found_deriv_map = false;
- bool iFirstTimeNMap = true;
-
- compatible_bump_init(&compat_bump);
- ntap_bump_init(&ntap_bump);
-
- if (re->r.scemode & R_NO_TEX) return;
- /* here: test flag if there's a tex (todo) */
-
- for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
-
- /* separate tex switching */
- if (shi->mat->septex & (1<<tex_nr)) continue;
-
- if (shi->mat->mtex[tex_nr]) {
- mtex= shi->mat->mtex[tex_nr];
-
- tex= mtex->tex;
- if (tex == NULL) continue;
-
- found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP);
- use_compat_bump= (mtex->texflag & MTEX_COMPAT_BUMP) != 0;
- use_ntap_bump = ((mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP|MTEX_BICUBIC_BUMP))!=0 || found_deriv_map!=0) ? true : false;
-
- /* XXX texture node trees don't work for this yet */
- if (tex->nodetree && tex->use_nodes) {
- use_compat_bump = false;
- use_ntap_bump = false;
- }
-
- /* case displacement mapping */
- if (shi->osatex == 0 && use_ntap_bump) {
- use_ntap_bump = false;
- use_compat_bump = true;
- }
-
- /* case ocean */
- if (tex->type == TEX_OCEAN) {
- use_ntap_bump = false;
- use_compat_bump = false;
- }
-
- /* which coords */
- if (mtex->texco==TEXCO_ORCO) {
- if (mtex->texflag & MTEX_DUPLI_MAPTO) {
- co= shi->duplilo; dx= dxt; dy= dyt;
- dxt[0]= dxt[1]= dxt[2]= 0.0f;
- dyt[0]= dyt[1]= dyt[2]= 0.0f;
- }
- else {
- co= shi->lo; dx= shi->dxlo; dy= shi->dylo;
- }
- }
- else if (mtex->texco==TEXCO_OBJECT) {
- Object *ob= mtex->object;
- if (ob) {
- co= tempvec;
- dx= dxt;
- dy= dyt;
- copy_v3_v3(tempvec, shi->co);
- if (mtex->texflag & MTEX_OB_DUPLI_ORIG)
- if (shi->obi && shi->obi->duplitexmat)
- mul_m4_v3(shi->obi->duplitexmat, tempvec);
- mul_m4_v3(ob->imat_ren, tempvec);
- if (shi->osatex) {
- copy_v3_v3(dxt, shi->dxco);
- copy_v3_v3(dyt, shi->dyco);
- mul_mat3_m4_v3(ob->imat_ren, dxt);
- mul_mat3_m4_v3(ob->imat_ren, dyt);
- }
- }
- else {
- /* if object doesn't exist, do not use orcos (not initialized) */
- co= shi->co;
- dx= shi->dxco; dy= shi->dyco;
- }
- }
- else if (mtex->texco==TEXCO_REFL) {
- calc_R_ref(shi);
- co= shi->ref; dx= shi->dxref; dy= shi->dyref;
- }
- else if (mtex->texco==TEXCO_NORM) {
- co= shi->orn; dx= shi->dxno; dy= shi->dyno;
- }
- else if (mtex->texco==TEXCO_TANGENT) {
- co= shi->tang; dx= shi->dxno; dy= shi->dyno;
- }
- else if (mtex->texco==TEXCO_GLOB) {
- co= shi->gl; dx= shi->dxgl; dy= shi->dygl;
- }
- else if (mtex->texco==TEXCO_UV) {
- if (mtex->texflag & MTEX_DUPLI_MAPTO) {
- co= shi->dupliuv; dx= dxt; dy= dyt;
- dxt[0]= dxt[1]= dxt[2]= 0.0f;
- dyt[0]= dyt[1]= dyt[2]= 0.0f;
- }
- else {
- ShadeInputUV *suv= &shi->uv[shi->actuv];
- int i = shi->actuv;
-
- if (mtex->uvname[0] != 0) {
- for (i = 0; i < shi->totuv; i++) {
- if (STREQ(shi->uv[i].name, mtex->uvname)) {
- suv= &shi->uv[i];
- break;
- }
- }
- }
-
- co= suv->uv;
- dx= suv->dxuv;
- dy= suv->dyuv;
-
- compatible_bump_uv_derivs(&compat_bump, shi, mtex, i);
- }
- }
- else if (mtex->texco==TEXCO_WINDOW) {
- co= shi->winco; dx= shi->dxwin; dy= shi->dywin;
- }
- else if (mtex->texco==TEXCO_STRAND) {
- co= tempvec; dx= dxt; dy= dyt;
- co[0]= shi->strandco;
- co[1]= co[2]= 0.0f;
- dx[0]= shi->dxstrand;
- dx[1]= dx[2]= 0.0f;
- dy[0]= shi->dystrand;
- dy[1]= dy[2]= 0.0f;
- }
- else if (mtex->texco==TEXCO_STRESS) {
- co= tempvec; dx= dxt; dy= dyt;
- co[0]= shi->stress;
- co[1]= co[2]= 0.0f;
- dx[0]= 0.0f;
- dx[1]= dx[2]= 0.0f;
- dy[0]= 0.0f;
- dy[1]= dy[2]= 0.0f;
- }
- else {
- continue; /* can happen when texco defines disappear and it renders old files */
- }
-
- /* the pointer defines if bumping happens */
- if (mtex->mapto & (MAP_NORM|MAP_WARP)) {
- texres.nor= norvec;
- norvec[0]= norvec[1]= norvec[2]= 0.0;
- }
- else texres.nor= NULL;
-
- if (warp_done) {
- add_v3_v3v3(tempvec, co, warpvec);
- co= tempvec;
- }
-
- /* XXX texture node trees don't work for this yet */
- if (texres.nor && !((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP))) {
- if (use_compat_bump) {
- rgbnor = compatible_bump_compute(&compat_bump, shi, mtex, tex,
- &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt,
- re->pool, skip_load_image);
- }
- else if (use_ntap_bump) {
- rgbnor = ntap_bump_compute(&ntap_bump, shi, mtex, tex,
- &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt,
- re->pool, skip_load_image);
- }
- else {
- texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
- rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, &texres, re->pool, skip_load_image);
- }
- }
- else {
- texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
- rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, &texres, re->pool, skip_load_image);
- }
-
- /* texture output */
-
- if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
- rgbnor -= TEX_RGB;
- }
- if (mtex->texflag & MTEX_NEGATIVE) {
- if (rgbnor & TEX_RGB) {
- texres.tr= 1.0f-texres.tr;
- texres.tg= 1.0f-texres.tg;
- texres.tb= 1.0f-texres.tb;
- }
- texres.tin= 1.0f-texres.tin;
- }
- if (mtex->texflag & MTEX_STENCIL) {
- if (rgbnor & TEX_RGB) {
- fact= texres.ta;
- texres.ta*= stencilTin;
- stencilTin*= fact;
- }
- else {
- fact= texres.tin;
- texres.tin*= stencilTin;
- stencilTin*= fact;
- }
- }
- else {
- Tnor*= stencilTin;
- }
-
- if (texres.nor) {
- if ((rgbnor & TEX_NOR)==0) {
- /* make our own normal */
- if (rgbnor & TEX_RGB) {
- copy_v3_v3(texres.nor, &texres.tr);
- }
- else {
- float co_nor= 0.5f * cosf(texres.tin - 0.5f);
- float si = 0.5f * sinf(texres.tin - 0.5f);
- float f1, f2;
-
- f1= shi->vn[0];
- f2= shi->vn[1];
- texres.nor[0]= f1*co_nor+f2*si;
- f1= shi->vn[1];
- f2= shi->vn[2];
- texres.nor[1]= f1*co_nor+f2*si;
- texres.nor[2]= f2*co_nor-f1*si;
- }
- }
- /* warping, local space */
- if (mtex->mapto & MAP_WARP) {
- float *warpnor= texres.nor, warpnor_[3];
-
- if (use_ntap_bump) {
- copy_v3_v3(warpnor_, texres.nor);
- warpnor= warpnor_;
- normalize_v3(warpnor_);
- }
- warpvec[0]= mtex->warpfac*warpnor[0];
- warpvec[1]= mtex->warpfac*warpnor[1];
- warpvec[2]= mtex->warpfac*warpnor[2];
- warp_done = true;
- }
-#if 0
- if (mtex->texflag & MTEX_VIEWSPACE) {
- /* rotate to global coords */
- if (mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) {
- if (shi->vlr && shi->obr && shi->obr->ob) {
- float len= normalize_v3(texres.nor);
- /* can be optimized... (ton) */
- mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor);
- mul_mat3_m4_v3(re->viewmat, texres.nor);
- normalize_v3_length(texres.nor, len);
- }
- }
- }
-#endif
- }
-
- /* mapping */
- if (mtex->mapto & (MAP_COL | MAP_COLSPEC | MAP_COLMIR)) {
- float tcol[3];
-
- /* stencil maps on the texture control slider, not texture intensity value */
- copy_v3_v3(tcol, &texres.tr);
-
- if ((rgbnor & TEX_RGB) == 0) {
- copy_v3_v3(tcol, &mtex->r);
- }
- else if (mtex->mapto & MAP_ALPHA) {
- texres.tin = stencilTin;
- }
- else {
- texres.tin = texres.ta;
- }
-
- /* inverse gamma correction */
- if (tex->type==TEX_IMAGE) {
- Image *ima = tex->ima;
- ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, re->pool);
-
- /* don't linearize float buffers, assumed to be linear */
- if (ibuf != NULL &&
- ibuf->rect_float == NULL &&
- (rgbnor & TEX_RGB) &&
- R.scene_color_manage)
- {
- IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace);
- }
-
- BKE_image_pool_release_ibuf(ima, ibuf, re->pool);
- }
-
- if (mtex->mapto & MAP_COL) {
- float colfac= mtex->colfac*stencilTin;
- texture_rgb_blend(&shi->r, tcol, &shi->r, texres.tin, colfac, mtex->blendtype);
- }
- if (mtex->mapto & MAP_COLSPEC) {
- float colspecfac= mtex->colspecfac*stencilTin;
- texture_rgb_blend(&shi->specr, tcol, &shi->specr, texres.tin, colspecfac, mtex->blendtype);
- }
- if (mtex->mapto & MAP_COLMIR) {
- float mirrfac= mtex->mirrfac*stencilTin;
-
- /* exception for envmap only */
- if (tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) {
- fact= texres.tin*mirrfac;
- facm= 1.0f- fact;
- shi->refcol[0]= fact + facm*shi->refcol[0];
- shi->refcol[1]= fact*tcol[0] + facm*shi->refcol[1];
- shi->refcol[2]= fact*tcol[1] + facm*shi->refcol[2];
- shi->refcol[3]= fact*tcol[2] + facm*shi->refcol[3];
- }
- else {
- texture_rgb_blend(&shi->mirr, tcol, &shi->mirr, texres.tin, mirrfac, mtex->blendtype);
- }
- }
- }
- if ( (mtex->mapto & MAP_NORM) ) {
- if (texres.nor) {
- float norfac= mtex->norfac;
-
- /* we need to code blending modes for normals too once.. now 1 exception hardcoded */
-
- if ((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP)) {
-
- found_nmapping = 1;
-
- /* qdn: for normalmaps, to invert the normalmap vector,
- * it is better to negate x & y instead of subtracting the vector as was done before */
- if (norfac < 0.0f) {
- texres.nor[0] = -texres.nor[0];
- texres.nor[1] = -texres.nor[1];
- }
- fact = Tnor*fabsf(norfac);
- if (fact>1.f) fact = 1.f;
- facm = 1.f-fact;
- if (mtex->normapspace == MTEX_NSPACE_TANGENT) {
- /* qdn: tangent space */
- float B[3], tv[3];
- const float *no = iFirstTimeNMap ? shi->nmapnorm : shi->vn;
- iFirstTimeNMap = false;
- cross_v3_v3v3(B, no, shi->nmaptang); /* bitangent */
- mul_v3_fl(B, shi->nmaptang[3]);
- /* transform norvec from tangent space to object surface in camera space */
- tv[0] = texres.nor[0]*shi->nmaptang[0] + texres.nor[1]*B[0] + texres.nor[2]*no[0];
- tv[1] = texres.nor[0]*shi->nmaptang[1] + texres.nor[1]*B[1] + texres.nor[2]*no[1];
- tv[2] = texres.nor[0]*shi->nmaptang[2] + texres.nor[1]*B[2] + texres.nor[2]*no[2];
- shi->vn[0]= facm*no[0] + fact*tv[0];
- shi->vn[1]= facm*no[1] + fact*tv[1];
- shi->vn[2]= facm*no[2] + fact*tv[2];
- }
- else {
- float nor[3];
-
- copy_v3_v3(nor, texres.nor);
-
- if (mtex->normapspace == MTEX_NSPACE_CAMERA) {
- /* pass */
- }
- else if (mtex->normapspace == MTEX_NSPACE_WORLD) {
- mul_mat3_m4_v3(re->viewmat, nor);
- }
- else if (mtex->normapspace == MTEX_NSPACE_OBJECT) {
- if (shi->obr && shi->obr->ob)
- mul_mat3_m4_v3(shi->obr->ob->obmat, nor);
- mul_mat3_m4_v3(re->viewmat, nor);
- }
-
- normalize_v3(nor);
-
- /* qdn: worldspace */
- shi->vn[0]= facm*shi->vn[0] + fact*nor[0];
- shi->vn[1]= facm*shi->vn[1] + fact*nor[1];
- shi->vn[2]= facm*shi->vn[2] + fact*nor[2];
- }
- }
- else {
- /* XXX texture node trees don't work for this yet */
- if (use_compat_bump || use_ntap_bump) {
- shi->vn[0] = texres.nor[0];
- shi->vn[1] = texres.nor[1];
- shi->vn[2] = texres.nor[2];
- }
- else {
- float nor[3], dot;
-
- if (shi->mat->mode & MA_TANGENT_V) {
- shi->tang[0]+= Tnor*norfac*texres.nor[0];
- shi->tang[1]+= Tnor*norfac*texres.nor[1];
- shi->tang[2]+= Tnor*norfac*texres.nor[2];
- }
-
- /* prevent bump to become negative normal */
- nor[0]= Tnor*norfac*texres.nor[0];
- nor[1]= Tnor*norfac*texres.nor[1];
- nor[2]= Tnor*norfac*texres.nor[2];
-
- dot= 0.5f + 0.5f * dot_v3v3(nor, shi->vn);
-
- shi->vn[0]+= dot*nor[0];
- shi->vn[1]+= dot*nor[1];
- shi->vn[2]+= dot*nor[2];
- }
- }
- normalize_v3(shi->vn);
-
- /* this makes sure the bump is passed on to the next texture */
- shi->orn[0]= -shi->vn[0];
- shi->orn[1]= -shi->vn[1];
- shi->orn[2]= -shi->vn[2];
- }
- }
-
- if ( mtex->mapto & MAP_DISPLACE ) {
- /* Now that most textures offer both Nor and Intensity, allow */
- /* both to work, and let user select with slider. */
- if (texres.nor) {
- float norfac= mtex->norfac;
-
- shi->displace[0]+= 0.2f*Tnor*norfac*texres.nor[0];
- shi->displace[1]+= 0.2f*Tnor*norfac*texres.nor[1];
- shi->displace[2]+= 0.2f*Tnor*norfac*texres.nor[2];
- }
-
- if (rgbnor & TEX_RGB) {
- texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
- }
-
- factt= (0.5f-texres.tin)*mtex->dispfac*stencilTin; facmm= 1.0f-factt;
-
- if (mtex->blendtype==MTEX_BLEND) {
- shi->displace[0]= factt*shi->vn[0] + facmm*shi->displace[0];
- shi->displace[1]= factt*shi->vn[1] + facmm*shi->displace[1];
- shi->displace[2]= factt*shi->vn[2] + facmm*shi->displace[2];
- }
- else if (mtex->blendtype==MTEX_MUL) {
- shi->displace[0]*= factt*shi->vn[0];
- shi->displace[1]*= factt*shi->vn[1];
- shi->displace[2]*= factt*shi->vn[2];
- }
- else { /* add or sub */
- if (mtex->blendtype==MTEX_SUB) factt= -factt;
- shi->displace[0]+= factt*shi->vn[0];
- shi->displace[1]+= factt*shi->vn[1];
- shi->displace[2]+= factt*shi->vn[2];
- }
- }
-
- if (mtex->mapto & MAP_VARS) {
- /* stencil maps on the texture control slider, not texture intensity value */
-
- if (rgbnor & TEX_RGB) {
- if (texres.talpha) texres.tin = texres.ta;
- else texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
- }
-
- if (mtex->mapto & MAP_REF) {
- float difffac= mtex->difffac*stencilTin;
-
- shi->refl= texture_value_blend(mtex->def_var, shi->refl, texres.tin, difffac, mtex->blendtype);
- if (shi->refl<0.0f) shi->refl= 0.0f;
- }
- if (mtex->mapto & MAP_SPEC) {
- float specfac= mtex->specfac*stencilTin;
-
- shi->spec= texture_value_blend(mtex->def_var, shi->spec, texres.tin, specfac, mtex->blendtype);
- if (shi->spec<0.0f) shi->spec= 0.0f;
- }
- if (mtex->mapto & MAP_EMIT) {
- float emitfac= mtex->emitfac*stencilTin;
-
- shi->emit= texture_value_blend(mtex->def_var, shi->emit, texres.tin, emitfac, mtex->blendtype);
- if (shi->emit<0.0f) shi->emit= 0.0f;
- }
- if (mtex->mapto & MAP_ALPHA) {
- float alphafac= mtex->alphafac*stencilTin;
-
- shi->alpha= texture_value_blend(mtex->def_var, shi->alpha, texres.tin, alphafac, mtex->blendtype);
- if (shi->alpha<0.0f) shi->alpha= 0.0f;
- else if (shi->alpha>1.0f) shi->alpha= 1.0f;
- }
- if (mtex->mapto & MAP_HAR) {
- float har; /* have to map to 0-1 */
- float hardfac= mtex->hardfac*stencilTin;
-
- har= ((float)shi->har)/128.0f;
- har= 128.0f*texture_value_blend(mtex->def_var, har, texres.tin, hardfac, mtex->blendtype);
-
- if (har<1.0f) shi->har= 1;
- else if (har>511) shi->har= 511;
- else shi->har= (int)har;
- }
- if (mtex->mapto & MAP_RAYMIRR) {
- float raymirrfac= mtex->raymirrfac*stencilTin;
-
- shi->ray_mirror= texture_value_blend(mtex->def_var, shi->ray_mirror, texres.tin, raymirrfac, mtex->blendtype);
- if (shi->ray_mirror<0.0f) shi->ray_mirror= 0.0f;
- else if (shi->ray_mirror>1.0f) shi->ray_mirror= 1.0f;
- }
- if (mtex->mapto & MAP_TRANSLU) {
- float translfac= mtex->translfac*stencilTin;
-
- shi->translucency= texture_value_blend(mtex->def_var, shi->translucency, texres.tin, translfac, mtex->blendtype);
- if (shi->translucency<0.0f) shi->translucency= 0.0f;
- else if (shi->translucency>1.0f) shi->translucency= 1.0f;
- }
- if (mtex->mapto & MAP_AMB) {
- float ambfac= mtex->ambfac*stencilTin;
-
- shi->amb= texture_value_blend(mtex->def_var, shi->amb, texres.tin, ambfac, mtex->blendtype);
- if (shi->amb<0.0f) shi->amb= 0.0f;
- else if (shi->amb>1.0f) shi->amb= 1.0f;
-
- shi->ambr= shi->amb*re->wrld.ambr;
- shi->ambg= shi->amb*re->wrld.ambg;
- shi->ambb= shi->amb*re->wrld.ambb;
- }
- }
- }
- }
- if ((use_compat_bump || use_ntap_bump || found_nmapping) && (shi->mat->mode & MA_TANGENT_V) != 0) {
- const float fnegdot = -dot_v3v3(shi->vn, shi->tang);
- /* apply Gram-Schmidt projection */
- madd_v3_v3fl(shi->tang, shi->vn, fnegdot);
- normalize_v3(shi->tang);
- }
-}
-
-
-void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_r[3], float *val, Render *re)
-{
- const bool skip_load_image = (re->r.scemode & R_NO_IMAGE_LOAD) != 0;
- const bool texnode_preview = (re->r.scemode & R_TEXNODE_PREVIEW) != 0;
- MTex *mtex;
- Tex *tex;
- TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
- int tex_nr, rgbnor= 0;
- float co[3], texvec[3];
- float fact, stencilTin=1.0;
-
- if (re->r.scemode & R_NO_TEX) return;
- /* here: test flag if there's a tex (todo) */
-
- for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
- /* separate tex switching */
- if (shi->mat->septex & (1<<tex_nr)) continue;
-
- if (shi->mat->mtex[tex_nr]) {
- mtex= shi->mat->mtex[tex_nr];
- tex= mtex->tex;
- if (tex == NULL) continue;
-
- /* only process if this texture is mapped
- * to one that we're interested in */
- if (!(mtex->mapto & mapto_flag)) continue;
-
- /* which coords */
- if (mtex->texco==TEXCO_OBJECT) {
- Object *ob= mtex->object;
- if (ob) {
- copy_v3_v3(co, xyz);
- if (mtex->texflag & MTEX_OB_DUPLI_ORIG) {
- if (shi->obi && shi->obi->duplitexmat)
- mul_m4_v3(shi->obi->duplitexmat, co);
- }
- mul_m4_v3(ob->imat_ren, co);
-
- if (mtex->texflag & MTEX_MAPTO_BOUNDS && ob->bb) {
- /* use bb vec[0] as min and bb vec[6] as max */
- co[0] = (co[0] - ob->bb->vec[0][0]) / (ob->bb->vec[6][0]-ob->bb->vec[0][0]) * 2.0f - 1.0f;
- co[1] = (co[1] - ob->bb->vec[0][1]) / (ob->bb->vec[6][1]-ob->bb->vec[0][1]) * 2.0f - 1.0f;
- co[2] = (co[2] - ob->bb->vec[0][2]) / (ob->bb->vec[6][2]-ob->bb->vec[0][2]) * 2.0f - 1.0f;
- }
- }
- }
- /* not really orco, but 'local' */
- else if (mtex->texco==TEXCO_ORCO) {
-
- if (mtex->texflag & MTEX_DUPLI_MAPTO) {
- copy_v3_v3(co, shi->duplilo);
- }
- else {
- Object *ob= shi->obi->ob;
- copy_v3_v3(co, xyz);
- mul_m4_v3(ob->imat_ren, co);
-
- if (mtex->texflag & MTEX_MAPTO_BOUNDS && ob->bb) {
- /* use bb vec[0] as min and bb vec[6] as max */
- co[0] = (co[0] - ob->bb->vec[0][0]) / (ob->bb->vec[6][0]-ob->bb->vec[0][0]) * 2.0f - 1.0f;
- co[1] = (co[1] - ob->bb->vec[0][1]) / (ob->bb->vec[6][1]-ob->bb->vec[0][1]) * 2.0f - 1.0f;
- co[2] = (co[2] - ob->bb->vec[0][2]) / (ob->bb->vec[6][2]-ob->bb->vec[0][2]) * 2.0f - 1.0f;
- }
- }
- }
- else if (mtex->texco==TEXCO_GLOB) {
- copy_v3_v3(co, xyz);
- mul_m4_v3(re->viewinv, co);
- }
- else {
- continue; /* can happen when texco defines disappear and it renders old files */
- }
-
- texres.nor= NULL;
-
- if (tex->type == TEX_IMAGE) {
- continue; /* not supported yet */
- //do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt);
- }
- else {
- /* placement */
- if (mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
- if (mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
- if (mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
- }
-
- rgbnor = multitex(tex,
- texvec,
- NULL, NULL,
- 0,
- &texres,
- shi->thread,
- mtex->which_output,
- re->pool,
- skip_load_image,
- texnode_preview,
- true); /* NULL = dxt/dyt, 0 = shi->osatex - not supported */
-
- /* texture output */
-
- if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
- rgbnor -= TEX_RGB;
- }
- if (mtex->texflag & MTEX_NEGATIVE) {
- if (rgbnor & TEX_RGB) {
- texres.tr= 1.0f-texres.tr;
- texres.tg= 1.0f-texres.tg;
- texres.tb= 1.0f-texres.tb;
- }
- texres.tin= 1.0f-texres.tin;
- }
- if (mtex->texflag & MTEX_STENCIL) {
- if (rgbnor & TEX_RGB) {
- fact= texres.ta;
- texres.ta*= stencilTin;
- stencilTin*= fact;
- }
- else {
- fact= texres.tin;
- texres.tin*= stencilTin;
- stencilTin*= fact;
- }
- }
-
-
- if ((mapto_flag & (MAP_EMISSION_COL+MAP_TRANSMISSION_COL+MAP_REFLECTION_COL)) && (mtex->mapto & (MAP_EMISSION_COL+MAP_TRANSMISSION_COL+MAP_REFLECTION_COL))) {
- float tcol[3];
-
- /* stencil maps on the texture control slider, not texture intensity value */
-
- if ((rgbnor & TEX_RGB) == 0) {
- copy_v3_v3(tcol, &mtex->r);
- }
- else if (mtex->mapto & MAP_DENSITY) {
- copy_v3_v3(tcol, &texres.tr);
- if (texres.talpha) {
- texres.tin = stencilTin;
- }
- }
- else {
- copy_v3_v3(tcol, &texres.tr);
- if (texres.talpha) {
- texres.tin= texres.ta;
- }
- }
-
- /* used for emit */
- if ((mapto_flag & MAP_EMISSION_COL) && (mtex->mapto & MAP_EMISSION_COL)) {
- float colemitfac= mtex->colemitfac*stencilTin;
- texture_rgb_blend(col_r, tcol, col_r, texres.tin, colemitfac, mtex->blendtype);
- }
-
- if ((mapto_flag & MAP_REFLECTION_COL) && (mtex->mapto & MAP_REFLECTION_COL)) {
- float colreflfac= mtex->colreflfac*stencilTin;
- texture_rgb_blend(col_r, tcol, col_r, texres.tin, colreflfac, mtex->blendtype);
- }
-
- if ((mapto_flag & MAP_TRANSMISSION_COL) && (mtex->mapto & MAP_TRANSMISSION_COL)) {
- float coltransfac= mtex->coltransfac*stencilTin;
- texture_rgb_blend(col_r, tcol, col_r, texres.tin, coltransfac, mtex->blendtype);
- }
- }
-
- if ((mapto_flag & MAP_VARS) && (mtex->mapto & MAP_VARS)) {
- /* stencil maps on the texture control slider, not texture intensity value */
-
- /* convert RGB to intensity if intensity info isn't provided */
- if (rgbnor & TEX_RGB) {
- if (texres.talpha) texres.tin = texres.ta;
- else texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
- }
-
- if ((mapto_flag & MAP_EMISSION) && (mtex->mapto & MAP_EMISSION)) {
- float emitfac= mtex->emitfac*stencilTin;
-
- *val = texture_value_blend(mtex->def_var, *val, texres.tin, emitfac, mtex->blendtype);
- if (*val<0.0f) *val= 0.0f;
- }
- if ((mapto_flag & MAP_DENSITY) && (mtex->mapto & MAP_DENSITY)) {
- float densfac= mtex->densfac*stencilTin;
-
- *val = texture_value_blend(mtex->def_var, *val, texres.tin, densfac, mtex->blendtype);
- CLAMP(*val, 0.0f, 1.0f);
- }
- if ((mapto_flag & MAP_SCATTERING) && (mtex->mapto & MAP_SCATTERING)) {
- float scatterfac= mtex->scatterfac*stencilTin;
-
- *val = texture_value_blend(mtex->def_var, *val, texres.tin, scatterfac, mtex->blendtype);
- CLAMP(*val, 0.0f, 1.0f);
- }
- if ((mapto_flag & MAP_REFLECTION) && (mtex->mapto & MAP_REFLECTION)) {
- float reflfac= mtex->reflfac*stencilTin;
-
- *val = texture_value_blend(mtex->def_var, *val, texres.tin, reflfac, mtex->blendtype);
- CLAMP(*val, 0.0f, 1.0f);
- }
- }
- }
- }
-}
-
-
-/* ------------------------------------------------------------------------- */
-
-void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4])
-{
- const bool skip_load_image = har->skip_load_image;
- const bool texnode_preview = har->texnode_preview;
- MTex *mtex;
- TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
- float texvec[3], dxt[3], dyt[3], fact, facm, dx;
- int rgb, osatex;
-
- if (R.r.scemode & R_NO_TEX) return;
-
- mtex= har->mat->mtex[0];
- if (har->mat->septex & (1<<0)) return;
- if (mtex->tex==NULL) return;
-
- /* no normal mapping */
- texres.nor= NULL;
-
- texvec[0]= xn/har->rad;
- texvec[1]= yn/har->rad;
- texvec[2]= 0.0;
-
- osatex= (har->mat->texco & TEXCO_OSA);
-
- /* placement */
- if (mtex->projx) texvec[0]= mtex->size[0]*(texvec[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
- if (mtex->projy) texvec[1]= mtex->size[1]*(texvec[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
- if (mtex->projz) texvec[2]= mtex->size[2]*(texvec[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
-
- if (osatex) {
-
- dx= 1.0f/har->rad;
-
- if (mtex->projx) {
- dxt[0]= mtex->size[0]*dx;
- dyt[0]= mtex->size[0]*dx;
- }
- else dxt[0]= dyt[0]= 0.0;
-
- if (mtex->projy) {
- dxt[1]= mtex->size[1]*dx;
- dyt[1]= mtex->size[1]*dx;
- }
- else dxt[1]= dyt[1]= 0.0;
-
- if (mtex->projz) {
- dxt[2]= 0.0;
- dyt[2]= 0.0;
- }
- else dxt[2]= dyt[2]= 0.0;
-
- }
-
- if (mtex->tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt);
-
- rgb = multitex(mtex->tex,
- texvec,
- dxt, dyt,
- osatex,
- &texres,
- 0,
- mtex->which_output,
- har->pool,
- skip_load_image,
- texnode_preview,
- true);
-
- /* texture output */
- if (rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
- rgb= 0;
- }
- if (mtex->texflag & MTEX_NEGATIVE) {
- if (rgb) {
- texres.tr= 1.0f-texres.tr;
- texres.tg= 1.0f-texres.tg;
- texres.tb= 1.0f-texres.tb;
- }
- else texres.tin= 1.0f-texres.tin;
- }
-
- /* mapping */
- if (mtex->mapto & MAP_COL) {
-
- if (rgb==0) {
- texres.tr= mtex->r;
- texres.tg= mtex->g;
- texres.tb= mtex->b;
- }
- else if (mtex->mapto & MAP_ALPHA) {
- texres.tin= 1.0;
- }
- else texres.tin= texres.ta;
-
- /* inverse gamma correction */
- if (mtex->tex->type==TEX_IMAGE) {
- Image *ima = mtex->tex->ima;
- ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, &mtex->tex->iuser, har->pool);
-
- /* don't linearize float buffers, assumed to be linear */
- if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
- IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace);
-
- BKE_image_pool_release_ibuf(ima, ibuf, har->pool);
- }
-
- fact= texres.tin*mtex->colfac;
- facm= 1.0f-fact;
-
- if (mtex->blendtype==MTEX_MUL) {
- facm= 1.0f-mtex->colfac;
- }
-
- if (mtex->blendtype==MTEX_SUB) fact= -fact;
-
- if (mtex->blendtype==MTEX_BLEND) {
- col_r[0]= (fact*texres.tr + facm*har->r);
- col_r[1]= (fact*texres.tg + facm*har->g);
- col_r[2]= (fact*texres.tb + facm*har->b);
- }
- else if (mtex->blendtype==MTEX_MUL) {
- col_r[0]= (facm+fact*texres.tr)*har->r;
- col_r[1]= (facm+fact*texres.tg)*har->g;
- col_r[2]= (facm+fact*texres.tb)*har->b;
- }
- else {
- col_r[0]= (fact*texres.tr + har->r);
- col_r[1]= (fact*texres.tg + har->g);
- col_r[2]= (fact*texres.tb + har->b);
-
- CLAMP(col_r[0], 0.0f, 1.0f);
- CLAMP(col_r[1], 0.0f, 1.0f);
- CLAMP(col_r[2], 0.0f, 1.0f);
- }
- }
- if (mtex->mapto & MAP_ALPHA) {
- if (rgb) {
- if (texres.talpha) {
- texres.tin = texres.ta;
- }
- else {
- texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
- }
- }
-
- col_r[3]*= texres.tin;
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-/* hor and zen are RGB vectors, blend is 1 float, should all be initialized */
-void do_sky_tex(
- const float rco[3], const float view[3], const float lo[3], const float dxyview[2],
- float hor[3], float zen[3], float *blend, int skyflag, short thread)
-{
- const bool skip_load_image = (R.r.scemode & R_NO_IMAGE_LOAD) != 0;
- const bool texnode_preview = (R.r.scemode & R_TEXNODE_PREVIEW) != 0;
- MTex *mtex;
- Tex *tex;
- TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
- float fact, stencilTin=1.0;
- float tempvec[3], texvec[3], dxt[3], dyt[3];
- int tex_nr, rgb= 0;
-
- if (R.r.scemode & R_NO_TEX) return;
- /* todo: add flag to test if there's a tex */
- texres.nor= NULL;
-
- for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
- if (R.wrld.mtex[tex_nr]) {
- const float *co;
-
- mtex= R.wrld.mtex[tex_nr];
-
- tex= mtex->tex;
- if (tex == NULL) continue;
- /* if (mtex->mapto==0) continue; */
-
- /* which coords */
- co= lo;
-
- /* dxt dyt just from 1 value */
- if (dxyview) {
- dxt[0]= dxt[1]= dxt[2]= dxyview[0];
- dyt[0]= dyt[1]= dyt[2]= dxyview[1];
- }
- else {
- dxt[0]= dxt[1]= dxt[2]= 0.0;
- dyt[0]= dyt[1]= dyt[2]= 0.0;
- }
-
- /* Grab the mapping settings for this texture */
- switch (mtex->texco) {
- case TEXCO_ANGMAP:
- /* only works with texture being "real" */
- /* use saacos(), fixes bug [#22398], float precision caused lo[2] to be slightly less than -1.0 */
- if (lo[0] || lo[1]) { /* check for zero case [#24807] */
- fact= (1.0f/(float)M_PI)*saacos(lo[2])/(sqrtf(lo[0]*lo[0] + lo[1]*lo[1]));
- tempvec[0]= lo[0]*fact;
- tempvec[1]= lo[1]*fact;
- tempvec[2]= 0.0;
- }
- else {
- /* this value has no angle, the vector is directly along the view.
- * avoid divide by zero and use a dummy value. */
- tempvec[0]= 1.0f;
- tempvec[1]= 0.0;
- tempvec[2]= 0.0;
- }
- co= tempvec;
- break;
-
- case TEXCO_H_SPHEREMAP:
- case TEXCO_H_TUBEMAP:
- if (skyflag & WO_ZENUP) {
- if (mtex->texco==TEXCO_H_TUBEMAP) map_to_tube( tempvec, tempvec+1, lo[0], lo[2], lo[1]);
- else map_to_sphere(tempvec, tempvec+1, lo[0], lo[2], lo[1]);
- /* tube/spheremap maps for outside view, not inside */
- tempvec[0]= 1.0f-tempvec[0];
- /* only top half */
- tempvec[1]= 2.0f*tempvec[1]-1.0f;
- tempvec[2]= 0.0;
- /* and correction for do_2d_mapping */
- tempvec[0]= 2.0f*tempvec[0]-1.0f;
- tempvec[1]= 2.0f*tempvec[1]-1.0f;
- co= tempvec;
- }
- else {
- /* potentially dangerous... check with multitex! */
- continue;
- }
- break;
- case TEXCO_EQUIRECTMAP:
- tempvec[0]= -atan2f(lo[2], lo[0]) / (float)M_PI;
- tempvec[1]= atan2f(lo[1], hypot(lo[0], lo[2])) / (float)M_PI_2;
- tempvec[2]= 0.0f;
- co= tempvec;
- break;
- case TEXCO_OBJECT:
- if (mtex->object) {
- copy_v3_v3(tempvec, lo);
- mul_m4_v3(mtex->object->imat_ren, tempvec);
- co= tempvec;
- }
- break;
-
- case TEXCO_GLOB:
- if (rco) {
- copy_v3_v3(tempvec, rco);
- mul_m4_v3(R.viewinv, tempvec);
- co= tempvec;
- }
- else
- co= lo;
-
-// copy_v3_v3(shi->dxgl, shi->dxco);
-// mul_m3_v3(R.imat, shi->dxco);
-// copy_v3_v3(shi->dygl, shi->dyco);
-// mul_m3_v3(R.imat, shi->dyco);
- break;
- case TEXCO_VIEW:
- co = view;
- break;
- }
-
- /* placement */
- if (mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
- if (mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
- if (mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
-
- /* texture */
- if (tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt);
-
- rgb = multitex(mtex->tex,
- texvec,
- dxt, dyt,
- R.osa,
- &texres,
- thread,
- mtex->which_output,
- R.pool,
- skip_load_image,
- texnode_preview,
- true);
-
- /* texture output */
- if (rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
- rgb= 0;
- }
- if (mtex->texflag & MTEX_NEGATIVE) {
- if (rgb) {
- texres.tr= 1.0f-texres.tr;
- texres.tg= 1.0f-texres.tg;
- texres.tb= 1.0f-texres.tb;
- }
- else texres.tin= 1.0f-texres.tin;
- }
- if (mtex->texflag & MTEX_STENCIL) {
- if (rgb) {
- fact= texres.ta;
- texres.ta*= stencilTin;
- stencilTin*= fact;
- }
- else {
- fact= texres.tin;
- texres.tin*= stencilTin;
- stencilTin*= fact;
- }
- }
- else {
- if (rgb) texres.ta *= stencilTin;
- else texres.tin*= stencilTin;
- }
-
- /* color mapping */
- if (mtex->mapto & (WOMAP_HORIZ+WOMAP_ZENUP+WOMAP_ZENDOWN)) {
- float tcol[3];
-
- if (rgb==0) {
- texres.tr= mtex->r;
- texres.tg= mtex->g;
- texres.tb= mtex->b;
- }
- else texres.tin= texres.ta;
-
- tcol[0]= texres.tr; tcol[1]= texres.tg; tcol[2]= texres.tb;
-
- /* inverse gamma correction */
- if (tex->type==TEX_IMAGE) {
- Image *ima = tex->ima;
- ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, R.pool);
-
- /* don't linearize float buffers, assumed to be linear */
- if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
- IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace);
-
- BKE_image_pool_release_ibuf(ima, ibuf, R.pool);
- }
-
- if (mtex->mapto & WOMAP_HORIZ) {
- texture_rgb_blend(hor, tcol, hor, texres.tin, mtex->colfac, mtex->blendtype);
- }
- if (mtex->mapto & (WOMAP_ZENUP+WOMAP_ZENDOWN)) {
- float zenfac = 0.0f;
-
- if (R.wrld.skytype & WO_SKYREAL) {
- if ((skyflag & WO_ZENUP)) {
- if (mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac;
- }
- else if (mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac;
- }
- else {
- if (mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac;
- else if (mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac;
- }
-
- if (zenfac != 0.0f)
- texture_rgb_blend(zen, tcol, zen, texres.tin, zenfac, mtex->blendtype);
- }
- }
- if (mtex->mapto & WOMAP_BLEND) {
- if (rgb) texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
-
- *blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->blendfac, mtex->blendtype);
- }
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-/* col_r supposed to be initialized with la->r,g,b */
-
-void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r[3], int effect)
-{
- const bool skip_load_image = (R.r.scemode & R_NO_IMAGE_LOAD) != 0;
- const bool texnode_preview = (R.r.scemode & R_TEXNODE_PREVIEW) != 0;
- Object *ob;
- MTex *mtex;
- Tex *tex;
- TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
- float *co = NULL, *dx = NULL, *dy = NULL, fact, stencilTin=1.0;
- float texvec[3], dxt[3], dyt[3], tempvec[3];
- int i, tex_nr, rgb= 0;
-
- if (R.r.scemode & R_NO_TEX) return;
- tex_nr= 0;
-
- for (; tex_nr<MAX_MTEX; tex_nr++) {
-
- if (la->mtex[tex_nr]) {
- mtex= la->mtex[tex_nr];
-
- tex= mtex->tex;
- if (tex==NULL) continue;
- texres.nor= NULL;
-
- /* which coords */
- if (mtex->texco==TEXCO_OBJECT) {
- ob= mtex->object;
- if (ob) {
- co= tempvec;
- dx= dxt;
- dy= dyt;
- copy_v3_v3(tempvec, shi->co);
- mul_m4_v3(ob->imat_ren, tempvec);
- if (shi->osatex) {
- copy_v3_v3(dxt, shi->dxco);
- copy_v3_v3(dyt, shi->dyco);
- mul_mat3_m4_v3(ob->imat_ren, dxt);
- mul_mat3_m4_v3(ob->imat_ren, dyt);
- }
- }
- else {
- co= shi->co;
- dx= shi->dxco; dy= shi->dyco;
- }
- }
- else if (mtex->texco==TEXCO_GLOB) {
- co= shi->gl; dx= shi->dxco; dy= shi->dyco;
- copy_v3_v3(shi->gl, shi->co);
- mul_m4_v3(R.viewinv, shi->gl);
- }
- else if (mtex->texco==TEXCO_VIEW) {
-
- copy_v3_v3(tempvec, lavec);
- mul_m3_v3(la->imat, tempvec);
-
- if (la->type==LA_SPOT) {
- tempvec[0]*= la->spottexfac;
- tempvec[1]*= la->spottexfac;
- /* project from 3d to 2d */
- tempvec[0] /= -tempvec[2];
- tempvec[1] /= -tempvec[2];
- }
- co= tempvec;
-
- dx= dxt; dy= dyt;
- if (shi->osatex) {
- copy_v3_v3(dxt, shi->dxlv);
- copy_v3_v3(dyt, shi->dylv);
- /* need some matrix conversion here? la->imat is a [3][3] matrix!!! **/
- mul_m3_v3(la->imat, dxt);
- mul_m3_v3(la->imat, dyt);
-
- mul_v3_fl(dxt, la->spottexfac);
- mul_v3_fl(dyt, la->spottexfac);
- }
- }
-
-
- /* placement */
- if (mtex->projx && co) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
- if (mtex->projy && co) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
- if (mtex->projz && co) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
-
- if (shi->osatex) {
- if (!dx) {
- for (i=0;i<2;i++) {
- dxt[i] = dyt[i] = 0.0;
- }
- }
- else {
- if (mtex->projx) {
- dxt[0]= mtex->size[0]*dx[mtex->projx-1];
- dyt[0]= mtex->size[0]*dy[mtex->projx-1];
- }
- else {
- dxt[0]= 0.0;
- dyt[0]= 0.0;
- }
- if (mtex->projy) {
- dxt[1]= mtex->size[1]*dx[mtex->projy-1];
- dyt[1]= mtex->size[1]*dy[mtex->projy-1];
- }
- else {
- dxt[1]= 0.0;
- dyt[1]= 0.0;
- }
- if (mtex->projz) {
- dxt[2]= mtex->size[2]*dx[mtex->projz-1];
- dyt[2]= mtex->size[2]*dy[mtex->projz-1];
- }
- else {
- dxt[2]= 0.0;
- dyt[2]= 0.0;
- }
- }
- }
-
- /* texture */
- if (tex->type==TEX_IMAGE) {
- do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt);
- }
-
- rgb = multitex(tex,
- texvec,
- dxt, dyt,
- shi->osatex,
- &texres,
- shi->thread,
- mtex->which_output,
- R.pool,
- skip_load_image,
- texnode_preview,
- true);
-
- /* texture output */
- if (rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin = IMB_colormanagement_get_luminance(&texres.tr);
- rgb= 0;
- }
- if (mtex->texflag & MTEX_NEGATIVE) {
- if (rgb) {
- texres.tr= 1.0f-texres.tr;
- texres.tg= 1.0f-texres.tg;
- texres.tb= 1.0f-texres.tb;
- }
- else texres.tin= 1.0f-texres.tin;
- }
- if (mtex->texflag & MTEX_STENCIL) {
- if (rgb) {
- fact= texres.ta;
- texres.ta*= stencilTin;
- stencilTin*= fact;
- }
- else {
- fact= texres.tin;
- texres.tin*= stencilTin;
- stencilTin*= fact;
- }
- }
- else {
- if (rgb) texres.ta*= stencilTin;
- else texres.tin*= stencilTin;
- }
-
- /* mapping */
- if (((mtex->mapto & LAMAP_COL) && (effect & LA_TEXTURE))||((mtex->mapto & LAMAP_SHAD) && (effect & LA_SHAD_TEX))) {
- float col[3];
-
- if (rgb==0) {
- texres.tr= mtex->r;
- texres.tg= mtex->g;
- texres.tb= mtex->b;
- }
- else if (mtex->mapto & MAP_ALPHA) {
- texres.tin= stencilTin;
- }
- else texres.tin= texres.ta;
-
- /* inverse gamma correction */
- if (tex->type==TEX_IMAGE) {
- Image *ima = tex->ima;
- ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, R.pool);
-
- /* don't linearize float buffers, assumed to be linear */
- if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
- IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace);
-
- BKE_image_pool_release_ibuf(ima, ibuf, R.pool);
- }
-
- /* lamp colors were premultiplied with this */
- col[0]= texres.tr*la->energy;
- col[1]= texres.tg*la->energy;
- col[2]= texres.tb*la->energy;
-
- if (effect & LA_SHAD_TEX)
- texture_rgb_blend(col_r, col, col_r, texres.tin, mtex->shadowfac, mtex->blendtype);
- else
- texture_rgb_blend(col_r, col, col_r, texres.tin, mtex->colfac, mtex->blendtype);
- }
- }
- }
-}
-
/* ------------------------------------------------------------------------- */
int externtex(const MTex *mtex,
@@ -3626,7 +1476,7 @@ int externtex(const MTex *mtex,
/* texture */
if (tex->type==TEX_IMAGE) {
- do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt);
+ do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
}
rgb = multitex(tex,
@@ -3658,327 +1508,3 @@ int externtex(const MTex *mtex,
return (rgb != 0);
}
-
-/* ------------------------------------------------------------------------- */
-
-void render_realtime_texture(ShadeInput *shi, Image *ima)
-{
- const bool skip_load_image = (R.r.scemode & R_NO_IMAGE_LOAD) != 0;
- TexResult texr;
- static Tex imatex[BLENDER_MAX_THREADS]; /* threadsafe */
- static int firsttime= 1;
- Tex *tex;
- float texvec[3], dx[2], dy[2];
- ShadeInputUV *suv= &shi->uv[shi->actuv];
- int a;
-
- if (R.r.scemode & R_NO_TEX) return;
-
- if (firsttime) {
- BLI_thread_lock(LOCK_IMAGE);
- if (firsttime) {
- const int num_threads = BLI_system_thread_count();
- for (a = 0; a < num_threads; a++) {
- memset(&imatex[a], 0, sizeof(Tex));
- BKE_texture_default(&imatex[a]);
- imatex[a].type= TEX_IMAGE;
- }
-
- firsttime= 0;
- }
- BLI_thread_unlock(LOCK_IMAGE);
- }
-
- tex= &imatex[shi->thread];
- tex->iuser.ok= ima->ok;
- tex->ima = ima;
-
- texvec[0]= 0.5f+0.5f*suv->uv[0];
- texvec[1]= 0.5f+0.5f*suv->uv[1];
- texvec[2] = 0.0f; /* initalize it because imagewrap looks at it. */
- if (shi->osatex) {
- dx[0]= 0.5f*suv->dxuv[0];
- dx[1]= 0.5f*suv->dxuv[1];
- dy[0]= 0.5f*suv->dyuv[0];
- dy[1]= 0.5f*suv->dyuv[1];
- }
-
- texr.nor= NULL;
-
- if (shi->osatex) imagewraposa(tex, ima, NULL, texvec, dx, dy, &texr, R.pool, skip_load_image);
- else imagewrap(tex, ima, NULL, texvec, &texr, R.pool, skip_load_image);
-
- shi->vcol[0]*= texr.tr;
- shi->vcol[1]*= texr.tg;
- shi->vcol[2]*= texr.tb;
- shi->vcol[3]*= texr.ta;
-}
-
-/* A modified part of shadeinput.c -> shade_input_set_uv()
- * Used for sampling UV mapped texture color */
-static void textured_face_generate_uv(
- const float normal[3], const float hit[3],
- const float v1[3], const float v2[3], const float v3[3],
- float r_uv[2])
-{
-
- float detsh, t00, t10, t01, t11;
- int axis1, axis2;
-
- /* find most stable axis to project */
- axis_dominant_v3(&axis1, &axis2, normal);
-
- /* compute u,v and derivatives */
- t00= v3[axis1]-v1[axis1]; t01= v3[axis2]-v1[axis2];
- t10= v3[axis1]-v2[axis1]; t11= v3[axis2]-v2[axis2];
-
- detsh= 1.0f/(t00*t11-t10*t01);
- t00*= detsh; t01*=detsh;
- t10*=detsh; t11*=detsh;
-
- r_uv[0] = (hit[axis1] - v3[axis1]) * t11 - (hit[axis2] - v3[axis2]) * t10;
- r_uv[1] = (hit[axis2] - v3[axis2]) * t00 - (hit[axis1] - v3[axis1]) * t01;
-
- /* u and v are in range -1 to 0, we allow a little bit extra but not too much, screws up speedvectors */
- CLAMP(r_uv[0], -2.0f, 1.0f);
- CLAMP(r_uv[1], -2.0f, 1.0f);
-}
-
-/* Generate an updated copy of material to use for color sampling. */
-Material *RE_sample_material_init(const EvaluationContext *eval_ctx, Material *orig_mat, Scene *scene)
-{
- Tex *tex = NULL;
- Material *mat;
- int tex_nr;
-
- if (!orig_mat) return NULL;
-
- /* copy material */
- mat = BKE_material_localize(orig_mat);
-
- /* update material anims */
- BKE_animsys_evaluate_animdata(scene, &mat->id, mat->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM);
-
- /* strip material copy from unsupported flags */
- for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
-
- if (mat->mtex[tex_nr]) {
- MTex *mtex = mat->mtex[tex_nr];
-
- /* 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);
-
- /* depending of material type, strip non-compatible mapping modes */
- if (mat->material_type == MA_TYPE_SURFACE) {
- if (!ELEM(mtex->texco, TEXCO_ORCO, TEXCO_OBJECT, TEXCO_GLOB, TEXCO_UV)) {
- /* ignore this texture */
- mtex->texco = 0;
- continue;
- }
- /* strip all mapto flags except color and alpha */
- mtex->mapto = (mtex->mapto & MAP_COL) | (mtex->mapto & MAP_ALPHA);
- }
- else if (mat->material_type == MA_TYPE_VOLUME) {
- if (!ELEM(mtex->texco, TEXCO_OBJECT, TEXCO_ORCO, TEXCO_GLOB)) {
- /* ignore */
- mtex->texco = 0;
- continue;
- }
- /* strip all mapto flags except color and alpha */
- mtex->mapto = mtex->mapto & (MAP_TRANSMISSION_COL | MAP_REFLECTION_COL | MAP_DENSITY);
- }
-
- /* if mapped to an object, calculate inverse matrices */
- if (mtex->texco==TEXCO_OBJECT) {
- Object *ob= mtex->object;
- if (ob) {
- invert_m4_m4(ob->imat, ob->obmat);
- copy_m4_m4(ob->imat_ren, ob->imat);
- }
- }
-
- /* copy texture */
- tex= mtex->tex = BKE_texture_localize(cur_tex);
-
- /* update texture anims */
- BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM);
-
- /* update texture cache if required */
- if (tex->type==TEX_VOXELDATA) {
- cache_voxeldata(tex, (int)scene->r.cfra);
- }
- if (tex->type==TEX_POINTDENSITY) {
- /* set dummy values for render and do cache */
- Render dummy_re = {NULL};
- dummy_re.scene = scene;
- unit_m4(dummy_re.viewinv);
- unit_m4(dummy_re.viewmat);
- unit_m4(dummy_re.winmat);
- dummy_re.winx = dummy_re.winy = 128;
- cache_pointdensity(eval_ctx, &dummy_re, tex->pd);
- }
-
- /* update image sequences and movies */
- if (tex->ima && BKE_image_is_animated(tex->ima)) {
- BKE_image_user_check_frame_calc(&tex->iuser, (int)scene->r.cfra, 0);
- }
- }
- }
- return mat;
-}
-
-/* free all duplicate data allocated by RE_sample_material_init() */
-void RE_sample_material_free(Material *mat)
-{
- int tex_nr;
-
- /* free textures */
- 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) {
- /* don't update user counts as we are freeing a duplicate */
- BKE_texture_free(mtex->tex);
- MEM_freeN(mtex->tex);
- mtex->tex = NULL;
- }
- }
- }
-
- /* don't update user counts as we are freeing a duplicate */
- BKE_material_free(mat);
- MEM_freeN(mat);
-}
-
-/*
- * Get material diffuse color and alpha (including linked textures) in given coordinates
- *
- * color,alpha : input/output color values
- * volume_co : sample coordinate in global space. used by volumetric materials
- * surface_co : sample surface coordinate in global space. used by "surface" materials
- * tri_index : surface tri index
- * orcoDm : orco state derived mesh
- */
-void RE_sample_material_color(
- Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3],
- int tri_index, DerivedMesh *orcoDm, Object *ob)
-{
- int v1, v2, v3;
- MVert *mvert;
- MLoop *mloop;
- const MLoopTri *mlooptri;
- float normal[3];
- ShadeInput shi = {NULL};
- Render re = {NULL};
-
- /* Get face data */
- mvert = orcoDm->getVertArray(orcoDm);
- mloop = orcoDm->getLoopArray(orcoDm);
- mlooptri = orcoDm->getLoopTriArray(orcoDm);
-
- if (!mvert || !mlooptri || !mat) {
- return;
- }
-
- v1 = mloop[mlooptri[tri_index].tri[0]].v;
- v2 = mloop[mlooptri[tri_index].tri[1]].v;
- v3 = mloop[mlooptri[tri_index].tri[2]].v;
- normal_tri_v3(normal, mvert[v1].co, mvert[v2].co, mvert[v3].co);
-
- /* generate shadeinput with data required */
- shi.mat = mat;
-
- /* fill shadeinput data depending on material type */
- if (mat->material_type == MA_TYPE_SURFACE) {
- /* global coordinates */
- copy_v3_v3(shi.gl, surface_co);
- /* object space coordinates */
- copy_v3_v3(shi.co, surface_co);
- mul_m4_v3(ob->imat, shi.co);
- /* orco coordinates */
- {
- float uv[2];
- float l;
- /* Get generated UV */
- textured_face_generate_uv(normal, shi.co, mvert[v1].co, mvert[v2].co, mvert[v3].co, uv);
- l= 1.0f+uv[0]+uv[1];
-
- /* calculate generated coordinate */
- shi.lo[0]= l*mvert[v3].co[0]-uv[0]*mvert[v1].co[0]-uv[1]*mvert[v2].co[0];
- shi.lo[1]= l*mvert[v3].co[1]-uv[0]*mvert[v1].co[1]-uv[1]*mvert[v2].co[1];
- shi.lo[2]= l*mvert[v3].co[2]-uv[0]*mvert[v1].co[2]-uv[1]*mvert[v2].co[2];
- }
- /* uv coordinates */
- {
- const int layers = CustomData_number_of_layers(&orcoDm->loopData, CD_MLOOPUV);
- const int layer_index = CustomData_get_layer_index(&orcoDm->loopData, CD_MLOOPUV);
- int i;
-
- /* for every uv map set coords and name */
- for (i=0; i<layers; i++) {
- if (layer_index >= 0) {
- const float *uv1, *uv2, *uv3;
- const CustomData *data = &orcoDm->loopData;
- const MLoopUV *mloopuv = data->layers[layer_index + i].data;
- float uv[2];
- float l;
-
- /* point layer name from actual layer data */
- shi.uv[i].name = data->layers[i].name;
- /* Get generated coordinates to calculate UV from */
- textured_face_generate_uv(normal, shi.co, mvert[v1].co, mvert[v2].co, mvert[v3].co, uv);
- /* Get UV mapping coordinate */
- l= 1.0f+uv[0]+uv[1];
-
- uv1 = mloopuv[mlooptri[tri_index].tri[0]].uv;
- uv2 = mloopuv[mlooptri[tri_index].tri[1]].uv;
- uv3 = mloopuv[mlooptri[tri_index].tri[2]].uv;
-
- shi.uv[i].uv[0]= -1.0f + 2.0f*(l*uv3[0]-uv[0]*uv1[0]-uv[1]*uv2[0]);
- shi.uv[i].uv[1]= -1.0f + 2.0f*(l*uv3[1]-uv[0]*uv1[1]-uv[1]*uv2[1]);
- shi.uv[i].uv[2]= 0.0f; /* texture.c assumes there are 3 coords */
- }
- }
- /* active uv map */
- shi.actuv = CustomData_get_active_layer_index(&orcoDm->loopData, CD_MLOOPUV) - layer_index;
- shi.totuv = layers;
- }
-
- /* apply initial values from material */
- shi.r = mat->r;
- shi.g = mat->g;
- shi.b = mat->b;
- shi.alpha = mat->alpha;
-
- /* do texture */
- do_material_tex(&shi, &re);
-
- /* apply result */
- color[0] = shi.r;
- color[1] = shi.g;
- color[2] = shi.b;
- *alpha = shi.alpha;
- }
- else if (mat->material_type == MA_TYPE_VOLUME) {
- ObjectInstanceRen obi = {NULL};
- obi.ob = ob;
- shi.obi = &obi;
- unit_m4(re.viewinv);
- copy_v3_v3(color, mat->vol.reflection_col);
- *alpha = mat->vol.density;
-
- /* do texture */
- do_volume_tex(&shi, volume_co, (MAP_TRANSMISSION_COL | MAP_REFLECTION_COL | MAP_DENSITY),
- color, alpha, &re);
- }
-}
-
-/* eof */
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
deleted file mode 100644
index c9072105dd9..00000000000
--- a/source/blender/render/intern/source/rendercore.c
+++ /dev/null
@@ -1,2028 +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.
- *
- * Contributors: Hos, Robert Wenzlaff.
- * Contributors: 2004/2005/2006 Blender Foundation, full recode
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/rendercore.c
- * \ingroup render
- */
-
-
-/* system includes */
-#include <stdio.h>
-#include <math.h>
-#include <float.h>
-#include <string.h>
-#include <assert.h>
-
-/* External modules: */
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_rand.h"
-#include "BLI_threads.h"
-#include "BLI_utildefines.h"
-
-#include "DNA_image_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_material_types.h"
-#include "DNA_group_types.h"
-
-/* local include */
-#include "renderpipeline.h"
-#include "render_result.h"
-#include "render_types.h"
-#include "renderdatabase.h"
-#include "occlusion.h"
-#include "pixelblending.h"
-#include "pixelshading.h"
-#include "shadbuf.h"
-#include "shading.h"
-#include "sss.h"
-#include "zbuf.h"
-
-/* own include */
-#include "rendercore.h"
-
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-/* x and y are current pixels in rect to be rendered */
-/* do not normalize! */
-void calc_view_vector(float view[3], float x, float y)
-{
-
- view[2]= -ABS(R.clipsta);
-
- if (R.r.mode & R_ORTHO) {
- view[0]= view[1]= 0.0f;
- }
- else {
-
- if (R.r.mode & R_PANORAMA) {
- x-= R.panodxp;
- }
-
- /* move x and y to real viewplane coords */
- x = (x / (float)R.winx);
- view[0] = R.viewplane.xmin + x * BLI_rctf_size_x(&R.viewplane);
-
- y = (y / (float)R.winy);
- view[1] = R.viewplane.ymin + y * BLI_rctf_size_y(&R.viewplane);
-
-// if (R.flag & R_SEC_FIELD) {
-// if (R.r.mode & R_ODDFIELD) view[1]= (y+R.ystart)*R.ycor;
-// else view[1]= (y+R.ystart+1.0)*R.ycor;
-// }
-// else view[1]= (y+R.ystart+R.bluroffsy+0.5)*R.ycor;
-
- if (R.r.mode & R_PANORAMA) {
- float u= view[0] + R.panodxv; float v= view[2];
- view[0]= R.panoco*u + R.panosi*v;
- view[2]= -R.panosi*u + R.panoco*v;
- }
- }
-}
-
-void calc_renderco_ortho(float co[3], float x, float y, int z)
-{
- /* x and y 3d coordinate can be derived from pixel coord and winmat */
- float fx= 2.0f/(R.winx*R.winmat[0][0]);
- float fy= 2.0f/(R.winy*R.winmat[1][1]);
- float zco;
-
- co[0]= (x - 0.5f*R.winx)*fx - R.winmat[3][0]/R.winmat[0][0];
- co[1]= (y - 0.5f*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1];
-
- zco= ((float)z)/2147483647.0f;
- co[2]= R.winmat[3][2]/( R.winmat[2][3]*zco - R.winmat[2][2] );
-}
-
-void calc_renderco_zbuf(float co[3], const float view[3], int z)
-{
- float fac, zco;
-
- /* inverse of zbuf calc: zbuf = MAXZ*hoco_z/hoco_w */
- zco= ((float)z)/2147483647.0f;
- co[2]= R.winmat[3][2]/( R.winmat[2][3]*zco - R.winmat[2][2] );
-
- fac= co[2]/view[2];
- co[0]= fac*view[0];
- co[1]= fac*view[1];
-}
-
-/* also used in zbuf.c and shadbuf.c */
-int count_mask(unsigned short mask)
-{
- if (R.samples)
- return (R.samples->cmask[mask & 255]+R.samples->cmask[mask>>8]);
- return 0;
-}
-
-static int calchalo_z(HaloRen *har, int zz)
-{
-
- if (har->type & HA_ONLYSKY) {
- if (zz < 0x7FFFFFF0) zz= - 0x7FFFFF; /* edge render messes zvalues */
- }
- else {
- zz= (zz>>8);
- }
- return zz;
-}
-
-
-
-static void halo_pixelstruct(HaloRen *har, RenderLayer **rlpp, int totsample, int od, float dist, float xn, float yn, PixStr *ps)
-{
- float col[4], accol[4], fac;
- int amount, amountm, zz, flarec, sample, fullsample, mask=0;
-
- fullsample= (totsample > 1);
- amount= 0;
- accol[0] = accol[1] = accol[2] = accol[3]= 0.0f;
- col[0] = col[1] = col[2] = col[3]= 0.0f;
- flarec= har->flarec;
-
- while (ps) {
- amountm= count_mask(ps->mask);
- amount+= amountm;
-
- zz= calchalo_z(har, ps->z);
- if ((zz> har->zs) || (har->mat && (har->mat->mode & MA_HALO_SOFT))) {
- if (shadeHaloFloat(har, col, zz, dist, xn, yn, flarec)) {
- flarec= 0;
-
- if (fullsample) {
- for (sample=0; sample<totsample; sample++) {
- if (ps->mask & (1 << sample)) {
- float *pass = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname);
- addalphaAddfacFloat(pass + od*4, col, har->add);
- }
- }
- }
- else {
- fac= ((float)amountm)/(float)R.osa;
- accol[0]+= fac*col[0];
- accol[1]+= fac*col[1];
- accol[2]+= fac*col[2];
- accol[3]+= fac*col[3];
- }
- }
- }
-
- mask |= ps->mask;
- ps= ps->next;
- }
-
- /* now do the sky sub-pixels */
- amount= R.osa-amount;
- if (amount) {
- if (shadeHaloFloat(har, col, 0x7FFFFF, dist, xn, yn, flarec)) {
- if (!fullsample) {
- fac= ((float)amount)/(float)R.osa;
- accol[0]+= fac*col[0];
- accol[1]+= fac*col[1];
- accol[2]+= fac*col[2];
- accol[3]+= fac*col[3];
- }
- }
- }
-
- if (fullsample) {
- for (sample=0; sample<totsample; sample++) {
- if (!(mask & (1 << sample))) {
- float *pass = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname);
- addalphaAddfacFloat(pass + od*4, col, har->add);
- }
- }
- }
- else {
- col[0]= accol[0];
- col[1]= accol[1];
- col[2]= accol[2];
- col[3]= accol[3];
-
- for (sample=0; sample<totsample; sample++) {
- float *pass = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname);
- addalphaAddfacFloat(pass + od*4, col, har->add);
- }
- }
-}
-
-static void halo_tile(RenderPart *pa, RenderLayer *rl)
-{
- RenderLayer *rlpp[RE_MAX_OSA];
- HaloRen *har;
- rcti disprect= pa->disprect, testrect= pa->disprect;
- float dist, xsq, ysq, xn, yn;
- float col[4];
- intptr_t *rd= NULL;
- int a, *rz, zz, y, sample, totsample, od;
- short minx, maxx, miny, maxy, x;
- unsigned int lay= (1 << 20) - 1;
-
- /* we don't render halos in the cropped area, gives errors in flare counter */
- if (pa->crop) {
- testrect.xmin+= pa->crop;
- testrect.xmax-= pa->crop;
- testrect.ymin+= pa->crop;
- testrect.ymax-= pa->crop;
- }
-
- totsample= get_sample_layers(pa, rl, rlpp);
-
- for (a=0; a<R.tothalo; a++) {
- har= R.sortedhalos[a];
-
- /* layer test, clip halo with y */
- if ((har->lay & lay) == 0) {
- /* pass */
- }
- else if (testrect.ymin > har->maxy) {
- /* pass */
- }
- else if (testrect.ymax < har->miny) {
- /* pass */
- }
- else {
-
- minx= floor(har->xs-har->rad);
- maxx= ceil(har->xs+har->rad);
-
- if (testrect.xmin > maxx) {
- /* pass */
- }
- else if (testrect.xmax < minx) {
- /* pass */
- }
- else {
-
- minx = max_ii(minx, testrect.xmin);
- maxx = min_ii(maxx, testrect.xmax);
-
- miny = max_ii(har->miny, testrect.ymin);
- maxy = min_ii(har->maxy, testrect.ymax);
-
- for (y=miny; y<maxy; y++) {
- int rectofs= (y-disprect.ymin)*pa->rectx + (minx - disprect.xmin);
- rz= pa->rectz + rectofs;
- od= rectofs;
-
- if (pa->rectdaps)
- rd= pa->rectdaps + rectofs;
-
- yn= (y-har->ys)*R.ycor;
- ysq= yn*yn;
-
- for (x=minx; x<maxx; x++, rz++, od++) {
- xn= x- har->xs;
- xsq= xn*xn;
- dist= xsq+ysq;
- if (dist<har->radsq) {
- if (rd && *rd) {
- halo_pixelstruct(har, rlpp, totsample, od, dist, xn, yn, (PixStr *)*rd);
- }
- else {
- zz= calchalo_z(har, *rz);
- if ((zz> har->zs) || (har->mat && (har->mat->mode & MA_HALO_SOFT))) {
- if (shadeHaloFloat(har, col, zz, dist, xn, yn, har->flarec)) {
- for (sample=0; sample<totsample; sample++) {
- float * rect= RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname);
- addalphaAddfacFloat(rect + od*4, col, har->add);
- }
- }
- }
- }
- }
- if (rd) rd++;
- }
- }
- }
- }
- if (R.test_break(R.tbh) ) break;
- }
-}
-
-static void lamphalo_tile(RenderPart *pa, RenderLayer *rl)
-{
- RenderLayer *rlpp[RE_MAX_OSA];
- ShadeInput shi;
- float *pass;
- float fac, col[4];
- intptr_t *rd= pa->rectdaps;
- const int *rz= pa->rectz;
- int x, y, sample, totsample, fullsample, od;
-
- totsample= get_sample_layers(pa, rl, rlpp);
- fullsample= (totsample > 1);
-
- shade_input_initialize(&shi, pa, rl, 0); /* this zero's ShadeInput for us */
-
- for (od=0, y=pa->disprect.ymin; y<pa->disprect.ymax; y++) {
- for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, rz++, od++) {
-
- calc_view_vector(shi.view, x, y);
-
- if (rd && *rd) {
- PixStr *ps= (PixStr *)*rd;
- int count, totsamp= 0, mask= 0;
-
- while (ps) {
- if (R.r.mode & R_ORTHO)
- calc_renderco_ortho(shi.co, (float)x, (float)y, ps->z);
- else
- calc_renderco_zbuf(shi.co, shi.view, ps->z);
-
- totsamp+= count= count_mask(ps->mask);
- mask |= ps->mask;
-
- col[0]= col[1]= col[2]= col[3]= 0.0f;
- renderspothalo(&shi, col, 1.0f);
-
- if (fullsample) {
- for (sample=0; sample<totsample; sample++) {
- if (ps->mask & (1 << sample)) {
- pass = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname);
- pass += od * 4;
- pass[0]+= col[0];
- pass[1]+= col[1];
- pass[2]+= col[2];
- pass[3]+= col[3];
- if (pass[3]>1.0f) pass[3]= 1.0f;
- }
- }
- }
- else {
- fac= ((float)count)/(float)R.osa;
- pass = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, R.viewname);
- pass += od * 4;
- pass[0]+= fac*col[0];
- pass[1]+= fac*col[1];
- pass[2]+= fac*col[2];
- pass[3]+= fac*col[3];
- if (pass[3]>1.0f) pass[3]= 1.0f;
- }
-
- ps= ps->next;
- }
-
- if (totsamp<R.osa) {
- shi.co[2]= 0.0f;
-
- col[0]= col[1]= col[2]= col[3]= 0.0f;
- renderspothalo(&shi, col, 1.0f);
-
- if (fullsample) {
- for (sample=0; sample<totsample; sample++) {
- if (!(mask & (1 << sample))) {
-
- pass = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname);
- pass += od * 4;
- pass[0]+= col[0];
- pass[1]+= col[1];
- pass[2]+= col[2];
- pass[3]+= col[3];
- if (pass[3]>1.0f) pass[3]= 1.0f;
- }
- }
- }
- else {
- fac= ((float)R.osa-totsamp)/(float)R.osa;
- pass = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, R.viewname);
- pass += od * 4;
- pass[0]+= fac*col[0];
- pass[1]+= fac*col[1];
- pass[2]+= fac*col[2];
- pass[3]+= fac*col[3];
- if (pass[3]>1.0f) pass[3]= 1.0f;
- }
- }
- }
- else {
- if (R.r.mode & R_ORTHO)
- calc_renderco_ortho(shi.co, (float)x, (float)y, *rz);
- else
- calc_renderco_zbuf(shi.co, shi.view, *rz);
-
- col[0]= col[1]= col[2]= col[3]= 0.0f;
- renderspothalo(&shi, col, 1.0f);
-
- for (sample=0; sample<totsample; sample++) {
- pass = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname);
- pass += od * 4;
- pass[0]+= col[0];
- pass[1]+= col[1];
- pass[2]+= col[2];
- pass[3]+= col[3];
- if (pass[3]>1.0f) pass[3]= 1.0f;
- }
- }
-
- if (rd) rd++;
- }
- if (y&1)
- if (R.test_break(R.tbh)) break;
- }
-}
-
-
-/* ********************* MAINLOOPS ******************** */
-
-/* osa version */
-static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, ShadeInput *shi, ShadeResult *shr)
-{
- RenderPass *rpass;
-
- for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- float *fp, *col= NULL;
- int pixsize= 3;
-
- if (STREQ(rpass->name, RE_PASSNAME_COMBINED)) {
- add_filt_fmask(curmask, shr->combined, rpass->rect + 4*offset, rectx);
- }
- else if (STREQ(rpass->name, RE_PASSNAME_Z)) {
- fp = rpass->rect + offset;
- *fp = shr->z;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_RGBA)) {
- col = shr->col;
- pixsize = 4;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_EMIT)) {
- col = shr->emit;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_DIFFUSE)) {
- col = shr->diff;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_SPEC)) {
- col = shr->spec;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_SHADOW)) {
- col = shr->shad;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_AO)) {
- col = shr->ao;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_ENVIRONMENT)) {
- col = shr->env;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_INDIRECT)) {
- col = shr->indirect;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_REFLECT)) {
- col = shr->refl;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_REFRACT)) {
- col = shr->refr;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_NORMAL)) {
- col = shr->nor;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_UV)) {
- /* box filter only, gauss will screwup UV too much */
- if (shi->totuv) {
- float mult = (float)count_mask(curmask)/(float)R.osa;
- fp = rpass->rect + 3*offset;
- fp[0]+= mult*(0.5f + 0.5f*shi->uv[shi->actuv].uv[0]);
- fp[1]+= mult*(0.5f + 0.5f*shi->uv[shi->actuv].uv[1]);
- fp[2]+= mult;
- }
- }
- else if (STREQ(rpass->name, RE_PASSNAME_INDEXOB)) {
- /* no filter */
- if (shi->vlr) {
- fp = rpass->rect + offset;
- if (*fp==0.0f)
- *fp = (float)shi->obr->ob->index;
- }
- }
- else if (STREQ(rpass->name, RE_PASSNAME_INDEXMA)) {
- /* no filter */
- if (shi->vlr) {
- fp = rpass->rect + offset;
- if (*fp==0.0f)
- *fp = (float)shi->mat->index;
- }
- }
- else if (STREQ(rpass->name, RE_PASSNAME_MIST)) {
- /* */
- col = &shr->mist;
- pixsize = 1;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_VECTOR)) {
- /* add minimum speed in pixel, no filter */
- fp = rpass->rect + 4*offset;
- if ( (ABS(shr->winspeed[0]) + ABS(shr->winspeed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) {
- fp[0] = shr->winspeed[0];
- fp[1] = shr->winspeed[1];
- }
- if ( (ABS(shr->winspeed[2]) + ABS(shr->winspeed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) {
- fp[2] = shr->winspeed[2];
- fp[3] = shr->winspeed[3];
- }
- }
- else if (STREQ(rpass->name, RE_PASSNAME_RAYHITS)) {
- /* */
- col = shr->rayhits;
- pixsize= 4;
- }
-
- if (col) {
- fp= rpass->rect + pixsize*offset;
- add_filt_fmask_pixsize(curmask, col, fp, rectx, pixsize);
- }
- }
-}
-
-/* non-osa version */
-static void add_passes(RenderLayer *rl, int offset, ShadeInput *shi, ShadeResult *shr)
-{
- RenderPass *rpass;
- float *fp;
-
- for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- float *col= NULL, uvcol[3];
- int a, pixsize= 3;
-
- if (STREQ(rpass->name, RE_PASSNAME_COMBINED)) {
- /* copy combined to use for preview */
- copy_v4_v4(rpass->rect + 4*offset, shr->combined);
- }
- else if (STREQ(rpass->name, RE_PASSNAME_Z)) {
- fp = rpass->rect + offset;
- *fp = shr->z;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_RGBA)) {
- col = shr->col;
- pixsize = 4;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_EMIT)) {
- col = shr->emit;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_DIFFUSE)) {
- col = shr->diff;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_SPEC)) {
- col = shr->spec;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_SHADOW)) {
- col = shr->shad;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_AO)) {
- col = shr->ao;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_ENVIRONMENT)) {
- col = shr->env;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_INDIRECT)) {
- col = shr->indirect;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_REFLECT)) {
- col = shr->refl;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_REFRACT)) {
- col = shr->refr;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_NORMAL)) {
- col = shr->nor;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_UV)) {
- if (shi->totuv) {
- uvcol[0] = 0.5f + 0.5f*shi->uv[shi->actuv].uv[0];
- uvcol[1] = 0.5f + 0.5f*shi->uv[shi->actuv].uv[1];
- uvcol[2] = 1.0f;
- col = uvcol;
- }
- }
- else if (STREQ(rpass->name, RE_PASSNAME_VECTOR)) {
- col = shr->winspeed;
- pixsize = 4;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_INDEXOB)) {
- if (shi->vlr) {
- fp = rpass->rect + offset;
- *fp = (float)shi->obr->ob->index;
- }
- }
- else if (STREQ(rpass->name, RE_PASSNAME_INDEXMA)) {
- if (shi->vlr) {
- fp = rpass->rect + offset;
- *fp = (float)shi->mat->index;
- }
- }
- else if (STREQ(rpass->name, RE_PASSNAME_MIST)) {
- fp = rpass->rect + offset;
- *fp = shr->mist;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_RAYHITS)) {
- col = shr->rayhits;
- pixsize = 4;
- }
-
- if (col) {
- fp = rpass->rect + pixsize*offset;
- for (a=0; a<pixsize; a++)
- fp[a] = col[a];
- }
- }
-}
-
-int get_sample_layers(RenderPart *pa, RenderLayer *rl, RenderLayer **rlpp)
-{
-
- if (pa->fullresult.first) {
- int sample, nr= BLI_findindex(&pa->result->layers, rl);
-
- for (sample=0; sample<R.osa; sample++) {
- RenderResult *rr= BLI_findlink(&pa->fullresult, sample);
-
- rlpp[sample]= BLI_findlink(&rr->layers, nr);
- }
- return R.osa;
- }
- else {
- rlpp[0]= rl;
- return 1;
- }
-}
-
-
-/* only do sky, is default in the solid layer (shade_tile) btw */
-static void sky_tile(RenderPart *pa, RenderLayer *rl)
-{
- RenderLayer *rlpp[RE_MAX_OSA];
- int x, y, od=0, totsample;
-
- if (R.r.alphamode!=R_ADDSKY)
- return;
-
- totsample= get_sample_layers(pa, rl, rlpp);
-
- for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++) {
- for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, od+=4) {
- float col[4];
- int sample;
- bool done = false;
-
- for (sample= 0; sample<totsample; sample++) {
- float *pass = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname);
- pass += od;
-
- if (pass[3]<1.0f) {
-
- if (done==0) {
- shadeSkyPixel(col, x, y, pa->thread);
- done = true;
- }
-
- if (pass[3]==0.0f) {
- copy_v4_v4(pass, col);
- pass[3] = 1.0f;
- }
- else {
- addAlphaUnderFloat(pass, col);
- pass[3] = 1.0f;
- }
- }
- }
- }
-
- if (y&1)
- if (R.test_break(R.tbh)) break;
- }
-}
-
-static void atm_tile(RenderPart *pa, RenderLayer *rl)
-{
- RenderPass *zpass;
- GroupObject *go;
- LampRen *lar;
- RenderLayer *rlpp[RE_MAX_OSA];
- int totsample;
- int x, y, od= 0;
-
- totsample= get_sample_layers(pa, rl, rlpp);
-
- /* check that z pass is enabled */
- if (pa->rectz==NULL) return;
- for (zpass= rl->passes.first; zpass; zpass= zpass->next)
- if (STREQ(zpass->name, RE_PASSNAME_Z))
- break;
-
- if (zpass==NULL) return;
-
- /* check for at least one sun lamp that its atmosphere flag is enabled */
- for (go=R.lights.first; go; go= go->next) {
- lar= go->lampren;
- if (lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_AP))
- break;
- }
- /* do nothign and return if there is no sun lamp */
- if (go==NULL)
- return;
-
- /* for each x,y and each sample, and each sun lamp*/
- for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++) {
- for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, od++) {
- int sample;
-
- for (sample=0; sample<totsample; sample++) {
- const float *zrect = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_Z, R.viewname) + od;
- float *rgbrect = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname) + 4*od;
- float rgb[3] = {0};
- bool done = false;
-
- for (go=R.lights.first; go; go= go->next) {
-
-
- lar= go->lampren;
- if (lar->type==LA_SUN && lar->sunsky) {
-
- /* if it's sky continue and don't apply atmosphere effect on it */
- if (*zrect >= 9.9e10f || rgbrect[3]==0.0f) {
- continue;
- }
-
- if ((lar->sunsky->effect_type & LA_SUN_EFFECT_AP)) {
- float tmp_rgb[3];
-
- /* skip if worldspace lamp vector is below horizon */
- if (go->ob->obmat[2][2] < 0.f) {
- continue;
- }
-
- copy_v3_v3(tmp_rgb, rgbrect);
- if (rgbrect[3]!=1.0f) { /* de-premul */
- mul_v3_fl(tmp_rgb, 1.0f/rgbrect[3]);
- }
- shadeAtmPixel(lar->sunsky, tmp_rgb, x, y, *zrect);
- if (rgbrect[3]!=1.0f) { /* premul */
- mul_v3_fl(tmp_rgb, rgbrect[3]);
- }
-
- if (done==0) {
- copy_v3_v3(rgb, tmp_rgb);
- done = true;
- }
- else {
- rgb[0] = 0.5f*rgb[0] + 0.5f*tmp_rgb[0];
- rgb[1] = 0.5f*rgb[1] + 0.5f*tmp_rgb[1];
- rgb[2] = 0.5f*rgb[2] + 0.5f*tmp_rgb[2];
- }
- }
- }
- }
-
- /* if at least for one sun lamp aerial perspective was applied*/
- if (done) {
- copy_v3_v3(rgbrect, rgb);
- }
- }
- }
- }
-}
-
-static void shadeDA_tile(RenderPart *pa, RenderLayer *rl)
-{
- RenderResult *rr= pa->result;
- ShadeSample ssamp;
- intptr_t *rd, *rectdaps= pa->rectdaps;
- int samp;
- int x, y, seed, crop=0, offs=0, od;
-
- if (R.test_break(R.tbh)) return;
-
- /* irregular shadowb buffer creation */
- if (R.r.mode & R_SHADOW)
- ISB_create(pa, NULL);
-
- /* we set per pixel a fixed seed, for random AO and shadow samples */
- seed= pa->rectx*pa->disprect.ymin;
-
- /* general shader info, passes */
- shade_sample_initialize(&ssamp, pa, rl);
-
- /* occlusion caching */
- if (R.occlusiontree)
- cache_occ_samples(&R, pa, &ssamp);
-
- /* filtered render, for now we assume only 1 filter size */
- if (pa->crop) {
- crop= 1;
- rectdaps+= pa->rectx + 1;
- offs= pa->rectx + 1;
- }
-
- /* scanline updates have to be 2 lines behind */
- rr->renrect.ymin = 0;
- rr->renrect.ymax = -2*crop;
- rr->renlay= rl;
-
- for (y=pa->disprect.ymin+crop; y<pa->disprect.ymax-crop; y++, rr->renrect.ymax++) {
- rd= rectdaps;
- od= offs;
-
- for (x=pa->disprect.xmin+crop; x<pa->disprect.xmax-crop; x++, rd++, od++) {
- BLI_thread_srandom(pa->thread, seed++);
-
- if (*rd) {
- if (shade_samples(&ssamp, (PixStr *)(*rd), x, y)) {
-
- /* multisample buffers or filtered mask filling? */
- if (pa->fullresult.first) {
- int a;
- for (samp=0; samp<ssamp.tot; samp++) {
- int smask= ssamp.shi[samp].mask;
- for (a=0; a<R.osa; a++) {
- int mask= 1<<a;
- if (smask & mask)
- add_passes(ssamp.rlpp[a], od, &ssamp.shi[samp], &ssamp.shr[samp]);
- }
- }
- }
- else {
- for (samp=0; samp<ssamp.tot; samp++)
- add_filt_passes(rl, ssamp.shi[samp].mask, pa->rectx, od, &ssamp.shi[samp], &ssamp.shr[samp]);
- }
- }
- }
- }
-
- rectdaps+= pa->rectx;
- offs+= pa->rectx;
-
- if (y&1) if (R.test_break(R.tbh)) break;
- }
-
- /* disable scanline updating */
- rr->renlay= NULL;
-
- if (R.r.mode & R_SHADOW)
- ISB_free(pa);
-
- if (R.occlusiontree)
- free_occ_samples(&R, pa);
-}
-
-/* ************* pixel struct ******** */
-
-
-static PixStrMain *addpsmain(ListBase *lb)
-{
- PixStrMain *psm;
-
- psm= (PixStrMain *)MEM_mallocN(sizeof(PixStrMain), "pixstrMain");
- BLI_addtail(lb, psm);
-
- psm->ps= (PixStr *)MEM_mallocN(4096*sizeof(PixStr), "pixstr");
- psm->counter= 0;
-
- return psm;
-}
-
-static void freeps(ListBase *lb)
-{
- PixStrMain *psm, *psmnext;
-
- for (psm= lb->first; psm; psm= psmnext) {
- psmnext= psm->next;
- if (psm->ps)
- MEM_freeN(psm->ps);
- MEM_freeN(psm);
- }
- BLI_listbase_clear(lb);
-}
-
-static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int maskz, unsigned short mask)
-{
- PixStrMain *psm;
- PixStr *ps, *last= NULL;
-
- if (*rd) {
- ps= (PixStr *)(*rd);
-
- while (ps) {
- if ( ps->obi == obi && ps->facenr == facenr ) {
- ps->mask |= mask;
- return;
- }
- last= ps;
- ps= ps->next;
- }
- }
-
- /* make new PS (pixel struct) */
- psm= lb->last;
-
- if (psm->counter==4095)
- psm= addpsmain(lb);
-
- ps= psm->ps + psm->counter++;
-
- if (last) last->next= ps;
- else *rd= (intptr_t)ps;
-
- ps->next= NULL;
- ps->obi= obi;
- ps->facenr= facenr;
- ps->z= z;
- ps->maskz= maskz;
- ps->mask = mask;
- 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)
-{
- RenderLayer *rlpp[RE_MAX_OSA];
- int y, sample, totsample;
-
- totsample= get_sample_layers(pa, rl, rlpp);
-
- /* not for full sample, there we clamp after compositing */
- if (totsample > 1)
- return;
-
- for (sample= 0; sample<totsample; sample++) {
- float *rectf = RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_COMBINED, R.viewname);
-
- for (y= pa->rectx*pa->recty; y>0; y--, rectf+=4) {
- rectf[0] = MAX2(rectf[0], 0.0f);
- rectf[1] = MAX2(rectf[1], 0.0f);
- rectf[2] = MAX2(rectf[2], 0.0f);
- CLAMP(rectf[3], 0.0f, 1.0f);
- }
- }
-}
-
-/* adds only alpha values */
-static void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz)
-{
- /* 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 */
- RenderLayer *rlpp[RE_MAX_OSA];
- float *fp;
- int a, sample, totsample;
-
- totsample= get_sample_layers(pa, rl, rlpp);
-
- for (sample= 0; sample<totsample; sample++) {
- fp= RE_RenderLayerGetPass(rlpp[sample], RE_PASSNAME_VECTOR, R.viewname);
- if (fp==NULL) break;
-
- for (a= 4*pa->rectx*pa->recty - 1; a>=0; a--)
- if (fp[a] == PASS_VECTOR_MAX) fp[a]= 0.0f;
- }
-}
-
-static unsigned short *make_solid_mask(RenderPart *pa)
-{
- intptr_t *rd= pa->rectdaps;
- unsigned short *solidmask, *sp;
- int x;
-
- if (rd==NULL) return NULL;
-
- sp=solidmask= MEM_mallocN(sizeof(short)*pa->rectx*pa->recty, "solidmask");
-
- for (x=pa->rectx*pa->recty; x>0; x--, rd++, sp++) {
- if (*rd) {
- PixStr *ps= (PixStr *)*rd;
-
- *sp= ps->mask;
- for (ps= ps->next; ps; ps= ps->next)
- *sp |= ps->mask;
- }
- else
- *sp= 0;
- }
-
- return solidmask;
-}
-
-static void addAlphaOverFloatMask(float *dest, float *source, unsigned short dmask, unsigned short smask)
-{
- unsigned short shared= dmask & smask;
- float mul= 1.0f - source[3];
-
- if (shared) { /* overlapping masks */
-
- /* masks differ, we make a mixture of 'add' and 'over' */
- if (shared!=dmask) {
- float shared_bits= (float)count_mask(shared); /* alpha over */
- float tot_bits= (float)count_mask(smask|dmask); /* alpha add */
-
- float add= (tot_bits - shared_bits)/tot_bits; /* add level */
- mul= add + (1.0f-add)*mul;
- }
- }
- else if (dmask && smask) {
- /* works for premul only, of course */
- dest[0]+= source[0];
- dest[1]+= source[1];
- dest[2]+= source[2];
- dest[3]+= source[3];
-
- return;
- }
-
- dest[0]= (mul*dest[0]) + source[0];
- dest[1]= (mul*dest[1]) + source[1];
- dest[2]= (mul*dest[2]) + source[2];
- dest[3]= (mul*dest[3]) + source[3];
-}
-
-typedef struct ZbufSolidData {
- RenderLayer *rl;
- ListBase *psmlist;
- float *edgerect;
-} ZbufSolidData;
-
-static void make_pixelstructs(RenderPart *pa, ZSpan *zspan, int sample, void *data)
-{
- ZbufSolidData *sdata = (ZbufSolidData *)data;
- ListBase *lb= sdata->psmlist;
- intptr_t *rd= pa->rectdaps;
- const int *ro= zspan->recto;
- const int *rp= zspan->rectp;
- const int *rz= zspan->rectz;
- const int *rm= zspan->rectmask;
- int x, y;
- int mask= 1<<sample;
-
- for (y=0; y<pa->recty; y++) {
- for (x=0; x<pa->rectx; x++, rd++, rp++, ro++, rz++, rm++) {
- if (*rp) {
- addps(lb, rd, *ro, *rp, *rz, (zspan->rectmask)? *rm: 0, mask);
- }
- }
- }
-
- 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 */
-/* supposed to be fully threadable! */
-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 */
- pa->recto= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "recto");
- pa->rectp= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectp");
- pa->rectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectz");
- for (rl= rr->layers.first; rl; rl= rl->next) {
- float *rect = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, R.viewname);
-
- 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 */
- 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;
- }
-
- /* shades solid */
- if (rl->layflag & SCE_LAY_SOLID)
- shadeDA_tile(pa, rl);
-
- /* lamphalo after solid, before ztra, looks nicest because ztra does own halo */
- if (R.flag & R_LAMPHALO)
- if (rl->layflag & SCE_LAY_HALO)
- lamphalo_tile(pa, rl);
-
- /* halo before ztra, because ztra fills in zbuffer now */
- if (R.flag & R_HALO)
- if (rl->layflag & SCE_LAY_HALO)
- halo_tile(pa, rl);
-
- /* transp layer */
- if (R.flag & R_ZTRA || R.totstrand) {
- if (rl->layflag & (SCE_LAY_ZTRA|SCE_LAY_STRAND)) {
- if (pa->fullresult.first) {
- zbuffer_transp_shade(pa, rl, rect, &psmlist);
- }
- else {
- unsigned short *ztramask, *solidmask= NULL; /* 16 bits, MAX_OSA */
-
- /* allocate, but not free here, for asynchronous display of this rect in main thread */
- rl->acolrect= MEM_callocN(4*sizeof(float)*pa->rectx*pa->recty, "alpha layer");
-
- /* swap for live updates, and it is used in zbuf.c!!! */
- SWAP(float *, rl->acolrect, rect);
- ztramask = zbuffer_transp_shade(pa, rl, rect, &psmlist);
- SWAP(float *, rl->acolrect, rect);
-
- /* zbuffer transp only returns ztramask if there's solid rendered */
- if (ztramask)
- solidmask= make_solid_mask(pa);
-
- if (ztramask && solidmask) {
- unsigned short *sps= solidmask, *spz= ztramask;
- unsigned short fullmask= (1<<R.osa)-1;
- float *fcol= rect;
- float *acol= rl->acolrect;
- int x;
-
- for (x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4, sps++, spz++) {
- if (*sps == fullmask)
- addAlphaOverFloat(fcol, acol);
- else
- addAlphaOverFloatMask(fcol, acol, *sps, *spz);
- }
- }
- else {
- float *fcol= rect;
- float *acol= rl->acolrect;
- int x;
- for (x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4) {
- addAlphaOverFloat(fcol, acol);
- }
- }
- if (solidmask) MEM_freeN(solidmask);
- if (ztramask) MEM_freeN(ztramask);
- }
- }
- }
-
- /* sun/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, rect, edgerect);
-
- if (rl->passflag & SCE_PASS_VECTOR)
- reset_sky_speed(pa, rl);
-
- /* clamp alpha to 0..1 range, can go outside due to filter */
- clamp_alpha_rgb_range(pa, rl);
-
- /* 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);
- pa->rectmask= NULL;
- }
- }
-
- /* free all */
- MEM_freeN(pa->recto); pa->recto= NULL;
- MEM_freeN(pa->rectp); pa->rectp= NULL;
- MEM_freeN(pa->rectz); pa->rectz= NULL;
-
- /* display active layer */
- rr->renrect.ymin=rr->renrect.ymax = 0;
- rr->renlay= render_get_active_layer(&R, rr);
-}
-
-
-/* ------------------------------------------------------------------------ */
-
-/* non OSA case, full tile render */
-/* supposed to be fully threadable! */
-void zbufshade_tile(RenderPart *pa)
-{
- ShadeSample ssamp;
- RenderResult *rr= pa->result;
- RenderLayer *rl;
- PixStr ps;
- float *edgerect= NULL;
-
- /* fake pixel struct, to comply to osa render */
- ps.next= NULL;
- ps.mask= 0xFFFF;
-
- /* zbuffer code clears/inits rects */
- pa->recto= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "recto");
- pa->rectp= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectp");
- pa->rectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectz");
-
- for (rl= rr->layers.first; rl; rl= rl->next) {
- float *rect= RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, R.viewname);
- if ((rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK))
- pa->rectmask= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectmask");
-
- /* general shader info, passes */
- shade_sample_initialize(&ssamp, pa, rl);
-
- zbuffer_solid(pa, rl, NULL, NULL);
-
- 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;
-
- if (rl->layflag & SCE_LAY_SOLID) {
- const float *fcol = rect;
- const int *ro= pa->recto, *rp= pa->rectp, *rz= pa->rectz;
- int x, y, offs=0, seed;
-
- /* we set per pixel a fixed seed, for random AO and shadow samples */
- seed= pa->rectx*pa->disprect.ymin;
-
- /* irregular shadowb buffer creation */
- if (R.r.mode & R_SHADOW)
- ISB_create(pa, NULL);
-
- if (R.occlusiontree)
- cache_occ_samples(&R, pa, &ssamp);
-
- for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++, rr->renrect.ymax++) {
- for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, ro++, rz++, rp++, fcol+=4, offs++) {
- /* per pixel fixed seed */
- BLI_thread_srandom(pa->thread, seed++);
-
- if (*rp) {
- ps.obi= *ro;
- ps.facenr= *rp;
- ps.z= *rz;
- if (shade_samples(&ssamp, &ps, x, y)) {
- /* combined and passes */
- add_passes(rl, offs, ssamp.shi, ssamp.shr);
- }
- }
- }
- if (y&1)
- if (R.test_break(R.tbh)) break;
- }
-
- if (R.occlusiontree)
- free_occ_samples(&R, pa);
-
- if (R.r.mode & R_SHADOW)
- ISB_free(pa);
- }
-
- /* disable scanline updating */
- rr->renlay= NULL;
- }
-
- /* lamphalo after solid, before ztra, looks nicest because ztra does own halo */
- if (R.flag & R_LAMPHALO)
- if (rl->layflag & SCE_LAY_HALO)
- lamphalo_tile(pa, rl);
-
- /* halo before ztra, because ztra fills in zbuffer now */
- if (R.flag & R_HALO)
- if (rl->layflag & SCE_LAY_HALO)
- halo_tile(pa, rl);
-
- if (R.flag & R_ZTRA || R.totstrand) {
- if (rl->layflag & (SCE_LAY_ZTRA|SCE_LAY_STRAND)) {
- float *fcol, *acol;
- int x;
-
- /* allocate, but not free here, for asynchronous display of this rect in main thread */
- rl->acolrect= MEM_callocN(4*sizeof(float)*pa->rectx*pa->recty, "alpha layer");
-
- /* swap for live updates */
- SWAP(float *, rl->acolrect, rect);
- zbuffer_transp_shade(pa, rl, rect, NULL);
- SWAP(float *, rl->acolrect, rect);
-
- fcol= rect; acol= rl->acolrect;
- for (x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4) {
- addAlphaOverFloat(fcol, acol);
- }
- }
- }
-
- /* sun/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, rect, 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);
- pa->rectmask= NULL;
- }
- }
-
- /* display active layer */
- rr->renrect.ymin=rr->renrect.ymax = 0;
- rr->renlay= render_get_active_layer(&R, rr);
-
- MEM_freeN(pa->recto); pa->recto= NULL;
- MEM_freeN(pa->rectp); pa->rectp= NULL;
- MEM_freeN(pa->rectz); pa->rectz= NULL;
-}
-
-/* SSS preprocess tile render, fully threadable */
-typedef struct ZBufSSSHandle {
- RenderPart *pa;
- ListBase psmlist;
- int totps;
-} ZBufSSSHandle;
-
-static void addps_sss(void *cb_handle, int obi, int facenr, int x, int y, int z)
-{
- ZBufSSSHandle *handle = cb_handle;
- RenderPart *pa= handle->pa;
-
- /* extra border for filter gives double samples on part edges,
- * don't use those */
- if (x<pa->crop || x>=pa->rectx-pa->crop)
- return;
- if (y<pa->crop || y>=pa->recty-pa->crop)
- return;
-
- if (pa->rectall) {
- intptr_t *rs= pa->rectall + pa->rectx*y + x;
-
- addps(&handle->psmlist, rs, obi, facenr, z, 0, 0);
- handle->totps++;
- }
- if (pa->rectz) {
- int *rz= pa->rectz + pa->rectx*y + x;
- int *rp= pa->rectp + pa->rectx*y + x;
- int *ro= pa->recto + pa->rectx*y + x;
-
- if (z < *rz) {
- if (*rp == 0)
- handle->totps++;
- *rz= z;
- *rp= facenr;
- *ro= obi;
- }
- }
- if (pa->rectbackz) {
- int *rz= pa->rectbackz + pa->rectx*y + x;
- int *rp= pa->rectbackp + pa->rectx*y + x;
- int *ro= pa->rectbacko + pa->rectx*y + x;
-
- if (z >= *rz) {
- if (*rp == 0)
- handle->totps++;
- *rz= z;
- *rp= facenr;
- *ro= obi;
- }
- }
-}
-
-static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRen *obi, VlakRen *vlr, int quad, float x, float y, float z, float *co, float color[3], float *area)
-{
- ShadeInput *shi= ssamp->shi;
- ShadeResult shr;
- float /* texfac,*/ /* UNUSED */ orthoarea, nor[3], alpha, sx, sy;
-
- /* cache for shadow */
- shi->samplenr= R.shadowsamplenr[shi->thread]++;
-
- if (quad)
- shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3);
- else
- shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2);
-
- /* center pixel */
- sx = x + 0.5f;
- sy = y + 0.5f;
-
- /* we estimate the area here using shi->dxco and shi->dyco. we need to
- * enabled shi->osatex these are filled. we compute two areas, one with
- * the normal pointed at the camera and one with the original normal, and
- * then clamp to avoid a too large contribution from a single pixel */
- shi->osatex= 1;
-
- copy_v3_v3(nor, shi->facenor);
- calc_view_vector(shi->facenor, sx, sy);
- normalize_v3(shi->facenor);
- shade_input_set_viewco(shi, x, y, sx, sy, z);
- orthoarea= len_v3(shi->dxco)*len_v3(shi->dyco);
-
- copy_v3_v3(shi->facenor, nor);
- shade_input_set_viewco(shi, x, y, sx, sy, z);
- *area = min_ff(len_v3(shi->dxco) * len_v3(shi->dyco), 2.0f * orthoarea);
-
- shade_input_set_uv(shi);
- shade_input_set_normals(shi);
-
- /* we don't want flipped normals, they screw up back scattering */
- if (shi->flippednor)
- shade_input_flip_normals(shi);
-
- /* not a pretty solution, but fixes common cases */
- if (shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) {
- negate_v3(shi->vn);
- negate_v3(shi->vno);
- negate_v3(shi->nmapnorm);
- }
-
- /* if nodetree, use the material that we are currently preprocessing
- * instead of the node material */
- if (shi->mat->nodetree && shi->mat->use_nodes)
- shi->mat= mat;
-
- /* init material vars */
- shade_input_init_material(shi);
-
- /* render */
- shade_input_set_shade_texco(shi);
-
- shade_samples_do_AO(ssamp);
- shade_material_loop(shi, &shr);
-
- copy_v3_v3(co, shi->co);
- copy_v3_v3(color, shr.combined);
-
- /* texture blending */
- /* texfac= shi->mat->sss_texfac; */ /* UNUSED */
-
- alpha= shr.combined[3];
- *area *= alpha;
-}
-
-static void zbufshade_sss_free(RenderPart *pa)
-{
-#if 0
- MEM_freeN(pa->rectall); pa->rectall= NULL;
- freeps(&handle.psmlist);
-#else
- MEM_freeN(pa->rectz); pa->rectz= NULL;
- MEM_freeN(pa->rectp); pa->rectp= NULL;
- MEM_freeN(pa->recto); pa->recto= NULL;
- MEM_freeN(pa->rectbackz); pa->rectbackz= NULL;
- MEM_freeN(pa->rectbackp); pa->rectbackp= NULL;
- MEM_freeN(pa->rectbacko); pa->rectbacko= NULL;
-#endif
-}
-
-void zbufshade_sss_tile(RenderPart *pa)
-{
- Render *re= &R;
- ShadeSample ssamp;
- ZBufSSSHandle handle;
- RenderResult *rr= pa->result;
- RenderLayer *rl;
- VlakRen *vlr;
- Material *mat= re->sss_mat;
- float (*co)[3], (*color)[3], *area, *fcol;
- int x, y, seed, quad, totpoint;
- const bool display = (re->r.scemode & (R_BUTS_PREVIEW | R_VIEWPORT_PREVIEW)) == 0;
- int *ro, *rz, *rp, *rbo, *rbz, *rbp, lay;
-#if 0
- PixStr *ps;
- intptr_t *rs;
- int z;
-#endif
-
- /* setup pixelstr list and buffer for zbuffering */
- handle.pa= pa;
- handle.totps= 0;
-
-#if 0
- handle.psmlist.first= handle.psmlist.last= NULL;
- addpsmain(&handle.psmlist);
-
- pa->rectall= MEM_callocN(sizeof(intptr_t)*pa->rectx*pa->recty+4, "rectall");
-#else
- pa->recto= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "recto");
- pa->rectp= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectp");
- pa->rectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectz");
- pa->rectbacko= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectbacko");
- pa->rectbackp= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectbackp");
- pa->rectbackz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectbackz");
-#endif
-
- /* setup shade sample with correct passes */
- memset(&ssamp, 0, sizeof(ssamp));
- shade_sample_initialize(&ssamp, pa, rr->layers.first);
- ssamp.tot= 1;
-
- for (rl=rr->layers.first; rl; rl=rl->next) {
- ssamp.shi[0].lay |= (1 << 20) - 1;
- ssamp.shi[0].layflag |= rl->layflag;
- ssamp.shi[0].passflag |= rl->passflag;
- ssamp.shi[0].combinedflag |= ~rl->pass_xor;
- }
-
- rl= rr->layers.first;
- ssamp.shi[0].passflag |= SCE_PASS_RGBA|SCE_PASS_COMBINED;
- ssamp.shi[0].combinedflag &= ~(SCE_PASS_SPEC);
- lay= ssamp.shi[0].lay;
-
- /* create the pixelstrs to be used later */
- zbuffer_sss(pa, lay, &handle, addps_sss);
-
- if (handle.totps==0) {
- zbufshade_sss_free(pa);
- return;
- }
-
- fcol= RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, R.viewname);
-
- co= MEM_mallocN(sizeof(float)*3*handle.totps, "SSSCo");
- color= MEM_mallocN(sizeof(float)*3*handle.totps, "SSSColor");
- area= MEM_mallocN(sizeof(float)*handle.totps, "SSSArea");
-
-#if 0
- /* create ISB (does not work currently!) */
- if (re->r.mode & R_SHADOW)
- ISB_create(pa, NULL);
-#endif
-
- if (display) {
- /* initialize scanline updates for main thread */
- rr->renrect.ymin = 0;
- rr->renlay= rl;
- }
-
- seed= pa->rectx*pa->disprect.ymin;
-#if 0
- rs= pa->rectall;
-#else
- rz= pa->rectz;
- rp= pa->rectp;
- ro= pa->recto;
- rbz= pa->rectbackz;
- rbp= pa->rectbackp;
- rbo= pa->rectbacko;
-#endif
- totpoint= 0;
-
- for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++, rr->renrect.ymax++) {
- for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, fcol+=4) {
- /* per pixel fixed seed */
- BLI_thread_srandom(pa->thread, seed++);
-
-#if 0
- if (rs) {
- /* for each sample in this pixel, shade it */
- for (ps = (PixStr *)(*rs); ps; ps=ps->next) {
- ObjectInstanceRen *obi= &re->objectinstance[ps->obi];
- ObjectRen *obr= obi->obr;
- vlr= RE_findOrAddVlak(obr, (ps->facenr-1) & RE_QUAD_MASK);
- quad= (ps->facenr & RE_QUAD_OFFS);
- z= ps->z;
-
- shade_sample_sss(&ssamp, mat, obi, vlr, quad, x, y, z,
- co[totpoint], color[totpoint], &area[totpoint]);
-
- totpoint++;
-
- add_v3_v3(fcol, color);
- fcol[3]= 1.0f;
- }
-
- rs++;
- }
-#else
- if (rp) {
- if (*rp != 0) {
- ObjectInstanceRen *obi= &re->objectinstance[*ro];
- ObjectRen *obr= obi->obr;
-
- /* shade front */
- vlr= RE_findOrAddVlak(obr, (*rp-1) & RE_QUAD_MASK);
- quad= ((*rp) & RE_QUAD_OFFS);
-
- shade_sample_sss(&ssamp, mat, obi, vlr, quad, x, y, *rz,
- co[totpoint], color[totpoint], &area[totpoint]);
-
- add_v3_v3(fcol, color[totpoint]);
- fcol[3]= 1.0f;
- totpoint++;
- }
-
- rp++; rz++; ro++;
- }
-
- if (rbp) {
- if (*rbp != 0 && !(*rbp == *(rp-1) && *rbo == *(ro-1))) {
- ObjectInstanceRen *obi= &re->objectinstance[*rbo];
- ObjectRen *obr= obi->obr;
-
- /* shade back */
- vlr= RE_findOrAddVlak(obr, (*rbp-1) & RE_QUAD_MASK);
- quad= ((*rbp) & RE_QUAD_OFFS);
-
- shade_sample_sss(&ssamp, mat, obi, vlr, quad, x, y, *rbz,
- co[totpoint], color[totpoint], &area[totpoint]);
-
- /* to indicate this is a back sample */
- area[totpoint]= -area[totpoint];
-
- add_v3_v3(fcol, color[totpoint]);
- fcol[3]= 1.0f;
- totpoint++;
- }
-
- rbz++; rbp++; rbo++;
- }
-#endif
- }
-
- if (y&1)
- if (re->test_break(re->tbh)) break;
- }
-
- /* note: after adding we do not free these arrays, sss keeps them */
- if (totpoint > 0) {
- sss_add_points(re, co, color, area, totpoint);
- }
- else {
- MEM_freeN(co);
- MEM_freeN(color);
- MEM_freeN(area);
- }
-
-#if 0
- if (re->r.mode & R_SHADOW)
- ISB_free(pa);
-#endif
-
- if (display) {
- /* display active layer */
- rr->renrect.ymin=rr->renrect.ymax = 0;
- rr->renlay= render_get_active_layer(&R, rr);
- }
-
- zbufshade_sss_free(pa);
-}
-
-/* ------------------------------------------------------------------------ */
-
-static void renderhalo_post(RenderResult *rr, float *rectf, HaloRen *har) /* postprocess version */
-{
- float dist, xsq, ysq, xn, yn, colf[4], *rectft, *rtf;
- float haloxs, haloys;
- int minx, maxx, miny, maxy, x, y;
-
- /* calculate the disprect mapped coordinate for halo. note: rectx is disprect corrected */
- haloxs= har->xs - R.disprect.xmin;
- haloys= har->ys - R.disprect.ymin;
-
- har->miny= miny= haloys - har->rad/R.ycor;
- har->maxy= maxy= haloys + har->rad/R.ycor;
-
- if (maxy < 0) {
- /* pass */
- }
- else if (rr->recty < miny) {
- /* pass */
- }
- else {
- minx = floor(haloxs - har->rad);
- maxx = ceil(haloxs + har->rad);
-
- if (maxx < 0) {
- /* pass */
- }
- else if (rr->rectx < minx) {
- /* pass */
- }
- else {
- if (minx<0) minx= 0;
- if (maxx>=rr->rectx) maxx= rr->rectx-1;
- if (miny<0) miny= 0;
- if (maxy>rr->recty) maxy= rr->recty;
-
- rectft= rectf+ 4*rr->rectx*miny;
-
- for (y=miny; y<maxy; y++) {
-
- rtf= rectft+4*minx;
-
- yn= (y - haloys)*R.ycor;
- ysq= yn*yn;
-
- for (x=minx; x<=maxx; x++) {
- xn= x - haloxs;
- xsq= xn*xn;
- dist= xsq+ysq;
- if (dist<har->radsq) {
-
- if (shadeHaloFloat(har, colf, 0x7FFFFF, dist, xn, yn, har->flarec))
- addalphaAddfacFloat(rtf, colf, har->add);
- }
- rtf+=4;
- }
-
- rectft+= 4*rr->rectx;
-
- if (R.test_break(R.tbh)) break;
- }
- }
- }
-}
-/* ------------------------------------------------------------------------ */
-
-static void renderflare(RenderResult *rr, float *rectf, HaloRen *har)
-{
- extern const float hashvectf[];
- HaloRen fla;
- Material *ma;
- const float *rc;
- float rad, alfa, visifac, vec[3];
- int b, type;
-
- fla= *har;
- fla.linec= fla.ringc= fla.flarec= 0;
-
- rad= har->rad;
- alfa= har->alfa;
-
- visifac= R.ycor*(har->pixels);
- /* all radials added / r^3 == 1.0f! */
- visifac /= (har->rad*har->rad*har->rad);
- visifac*= visifac;
-
- ma= har->mat;
-
- /* first halo: just do */
-
- har->rad= rad*ma->flaresize*visifac;
- har->radsq= har->rad*har->rad;
- har->zs= fla.zs= 0;
-
- har->alfa= alfa*visifac;
-
- renderhalo_post(rr, rectf, har);
-
- /* next halo's: the flares */
- rc= hashvectf + ma->seed2;
-
- for (b=1; b<har->flarec; b++) {
-
- fla.r = fabsf(rc[0]);
- fla.g = fabsf(rc[1]);
- fla.b = fabsf(rc[2]);
- fla.alfa= ma->flareboost*fabsf(alfa*visifac*rc[3]);
- fla.hard= 20.0f + fabsf(70.0f*rc[7]);
- fla.tex= 0;
-
- type= (int)(fabsf(3.9f*rc[6]));
-
- fla.rad = ma->subsize * sqrtf(fabsf(2.0f * har->rad * rc[4]));
-
- if (type==3) {
- fla.rad*= 3.0f;
- fla.rad+= R.rectx/10;
- }
-
- fla.radsq= fla.rad*fla.rad;
-
- vec[0]= 1.4f*rc[5]*(har->xs-R.winx/2);
- vec[1]= 1.4f*rc[5]*(har->ys-R.winy/2);
- vec[2]= 32.0f*sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + 1.0f);
-
- fla.xs= R.winx/2 + vec[0] + (1.2f+rc[8])*R.rectx*vec[0]/vec[2];
- fla.ys= R.winy/2 + vec[1] + (1.2f+rc[8])*R.rectx*vec[1]/vec[2];
-
- if (R.flag & R_SEC_FIELD) {
- if (R.r.mode & R_ODDFIELD) fla.ys += 0.5f;
- else fla.ys -= 0.5f;
- }
- if (type & 1) fla.type= HA_FLARECIRC;
- else fla.type= 0;
- renderhalo_post(rr, rectf, &fla);
-
- fla.alfa*= 0.5f;
- if (type & 2) fla.type= HA_FLARECIRC;
- else fla.type= 0;
- renderhalo_post(rr, rectf, &fla);
-
- rc+= 7;
- }
-}
-
-/* needs recode... integrate this better! */
-void add_halo_flare(Render *re)
-{
- RenderResult *rr= re->result;
- RenderLayer *rl;
- HaloRen *har;
- int a, mode;
- float *rect;
-
- /* for now, we get the first renderlayer in list with halos set */
- for (rl= rr->layers.first; rl; rl= rl->next) {
- bool do_draw = false;
-
- if ((rl->layflag & SCE_LAY_HALO) == 0)
- continue;
-
- rect = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, re->viewname);
-
- if (rect==NULL)
- continue;
-
- mode= R.r.mode;
- R.r.mode &= ~R_PANORAMA;
-
- project_renderdata(&R, projectverto, 0, 0, 0);
-
- for (a=0; a<R.tothalo; a++) {
- har= R.sortedhalos[a];
-
- if (har->flarec && (har->lay & ((1 << 20) - 1))) {
- do_draw = true;
- renderflare(rr, rect, har);
- }
- }
-
- if (do_draw) {
- /* weak... the display callback wants an active renderlayer pointer... */
- rr->renlay= rl;
- re->display_update(re->duh, rr, NULL);
- }
-
- R.r.mode= mode;
- }
-}
-
-void render_internal_update_passes(RenderEngine *engine, Scene *scene, ViewLayer *view_layer)
-{
- int type;
-
- RE_engine_register_pass(engine, scene, view_layer, RE_PASSNAME_COMBINED, 4, "RGBA", SOCK_RGBA);
-
-#define CHECK_PASS(name, channels, chanid) \
- if (view_layer->passflag & (SCE_PASS_ ## name)) { \
- if (channels == 4) type = SOCK_RGBA; \
- else if (channels == 3) type = SOCK_VECTOR; \
- else type = SOCK_FLOAT; \
- RE_engine_register_pass(engine, scene, view_layer, RE_PASSNAME_ ## name, channels, chanid, type); \
- }
-
- CHECK_PASS(Z, 1, "Z");
- CHECK_PASS(VECTOR, 4, "XYZW");
- CHECK_PASS(NORMAL, 3, "XYZ");
- CHECK_PASS(UV, 3, "UVA");
- CHECK_PASS(RGBA, 4, "RGBA");
- CHECK_PASS(EMIT, 3, "RGB");
- CHECK_PASS(DIFFUSE, 3, "RGB");
- CHECK_PASS(SPEC, 3, "RGB");
- CHECK_PASS(AO, 3, "RGB");
- CHECK_PASS(ENVIRONMENT, 3, "RGB");
- CHECK_PASS(INDIRECT, 3, "RGB");
- CHECK_PASS(SHADOW, 3, "RGB");
- CHECK_PASS(REFLECT, 3, "RGB");
- CHECK_PASS(REFRACT, 3, "RGB");
- CHECK_PASS(INDEXOB, 1, "X");
- CHECK_PASS(INDEXMA, 1, "X");
- CHECK_PASS(MIST, 1, "Z");
-
-#undef CHECK_PASS
-}
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c
deleted file mode 100644
index 2fbfcc64c8f..00000000000
--- a/source/blender/render/intern/source/renderdatabase.c
+++ /dev/null
@@ -1,1603 +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.
- *
- * Contributor(s): 2004-2006, Blender Foundation, full recode
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/renderdatabase.c
- * \ingroup render
- */
-
-
-/*
- * Storage, retrieval and query of render specific data.
- *
- * All data from a Blender scene is converted by the renderconverter/
- * into a special format that is used by the render module to make
- * images out of. These functions interface to the render-specific
- * database.
- *
- * The blo{ha/ve/vl} arrays store pointers to blocks of 256 data
- * entries each.
- *
- * The index of an entry is >>8 (the highest 24 * bits), to find an
- * offset in a 256-entry block.
- *
- * - If the 256-entry block entry has an entry in the
- * vertnodes/vlaknodes/bloha array of the current block, the i-th entry in
- * that block is allocated to this entry.
- *
- * - If the entry has no block allocated for it yet, memory is
- * allocated.
- *
- * The pointer to the correct entry is returned. Memory is guaranteed
- * to exist (as long as the malloc does not break). Since guarded
- * allocation is used, memory _must_ be available. Otherwise, an
- * exit(0) would occur.
- *
- */
-
-#include <limits.h>
-#include <math.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-#include "BLI_hash.h"
-
-#include "DNA_material_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_listBase.h"
-#include "DNA_particle_types.h"
-
-#include "BKE_customdata.h"
-#include "BKE_DerivedMesh.h"
-
-#include "RE_render_ext.h" /* externtex */
-
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "render_types.h"
-#include "renderdatabase.h"
-#include "zbuf.h"
-
-/* ------------------------------------------------------------------------- */
-
-/* More dynamic allocation of options for render vertices and faces, so we don't
- * have to reserve this space inside vertices.
- * Important; vertices and faces, should have been created already (to get tables
- * checked) that's a reason why the calls demand VertRen/VlakRen * as arg, not
- * the index */
-
-/* NOTE! the hardcoded table size 256 is used still in code for going quickly over vertices/faces */
-#define RE_STRESS_ELEMS 1
-#define RE_RAD_ELEMS 4
-#define RE_STRAND_ELEMS 1
-#define RE_TANGENT_ELEMS 3
-#define RE_WINSPEED_ELEMS 4
-#define RE_MTFACE_ELEMS 1
-#define RE_MCOL_ELEMS 4
-#define RE_UV_ELEMS 2
-#define RE_VLAK_ORIGINDEX_ELEMS 1
-#define RE_VERT_ORIGINDEX_ELEMS 1
-#define RE_SURFNOR_ELEMS 3
-#define RE_RADFACE_ELEMS 1
-#define RE_SIMPLIFY_ELEMS 2
-#define RE_FACE_ELEMS 1
-#define RE_NMAP_TANGENT_ELEMS 16
-
-float *RE_vertren_get_stress(ObjectRen *obr, VertRen *ver, int verify)
-{
- float *stress;
- int nr= ver->index>>8;
-
- stress= obr->vertnodes[nr].stress;
- if (stress==NULL) {
- if (verify)
- stress= obr->vertnodes[nr].stress= MEM_mallocN(256*RE_STRESS_ELEMS*sizeof(float), "stress table");
- else
- return NULL;
- }
- return stress + (ver->index & 255)*RE_STRESS_ELEMS;
-}
-
-/* this one callocs! */
-float *RE_vertren_get_rad(ObjectRen *obr, VertRen *ver, int verify)
-{
- float *rad;
- int nr= ver->index>>8;
-
- rad= obr->vertnodes[nr].rad;
- if (rad==NULL) {
- if (verify)
- rad= obr->vertnodes[nr].rad= MEM_callocN(256*RE_RAD_ELEMS*sizeof(float), "rad table");
- else
- return NULL;
- }
- return rad + (ver->index & 255)*RE_RAD_ELEMS;
-}
-
-float *RE_vertren_get_strand(ObjectRen *obr, VertRen *ver, int verify)
-{
- float *strand;
- int nr= ver->index>>8;
-
- strand= obr->vertnodes[nr].strand;
- if (strand==NULL) {
- if (verify)
- strand= obr->vertnodes[nr].strand= MEM_mallocN(256*RE_STRAND_ELEMS*sizeof(float), "strand table");
- else
- return NULL;
- }
- return strand + (ver->index & 255)*RE_STRAND_ELEMS;
-}
-
-/* needs calloc */
-float *RE_vertren_get_tangent(ObjectRen *obr, VertRen *ver, int verify)
-{
- float *tangent;
- int nr= ver->index>>8;
-
- tangent= obr->vertnodes[nr].tangent;
- if (tangent==NULL) {
- if (verify)
- tangent= obr->vertnodes[nr].tangent= MEM_callocN(256*RE_TANGENT_ELEMS*sizeof(float), "tangent table");
- else
- return NULL;
- }
- return tangent + (ver->index & 255)*RE_TANGENT_ELEMS;
-}
-
-/* needs calloc! not all renderverts have them */
-/* also winspeed is exception, it is stored per instance */
-float *RE_vertren_get_winspeed(ObjectInstanceRen *obi, VertRen *ver, int verify)
-{
- float *winspeed;
- int totvector;
-
- winspeed= obi->vectors;
- if (winspeed==NULL) {
- if (verify) {
- totvector= obi->obr->totvert + obi->obr->totstrand;
- winspeed= obi->vectors= MEM_callocN(totvector*RE_WINSPEED_ELEMS*sizeof(float), "winspeed table");
- }
- else
- return NULL;
- }
- return winspeed + ver->index*RE_WINSPEED_ELEMS;
-}
-
-int *RE_vertren_get_origindex(ObjectRen *obr, VertRen *ver, int verify)
-{
- int *origindex;
- int nr= ver->index>>8;
-
- origindex= obr->vertnodes[nr].origindex;
- if (origindex==NULL) {
- if (verify)
- origindex= obr->vertnodes[nr].origindex= MEM_mallocN(256*RE_VERT_ORIGINDEX_ELEMS*sizeof(int), "origindex table");
- else
- return NULL;
- }
- return origindex + (ver->index & 255)*RE_VERT_ORIGINDEX_ELEMS;
-}
-
-VertRen *RE_vertren_copy(ObjectRen *obr, VertRen *ver)
-{
- VertRen *v1= RE_findOrAddVert(obr, obr->totvert++);
- float *fp1, *fp2;
- int *int1, *int2;
- int index= v1->index;
-
- *v1= *ver;
- v1->index= index;
-
- fp1= RE_vertren_get_stress(obr, ver, 0);
- if (fp1) {
- fp2= RE_vertren_get_stress(obr, v1, 1);
- memcpy(fp2, fp1, RE_STRESS_ELEMS*sizeof(float));
- }
- fp1= RE_vertren_get_rad(obr, ver, 0);
- if (fp1) {
- fp2= RE_vertren_get_rad(obr, v1, 1);
- memcpy(fp2, fp1, RE_RAD_ELEMS*sizeof(float));
- }
- fp1= RE_vertren_get_strand(obr, ver, 0);
- if (fp1) {
- fp2= RE_vertren_get_strand(obr, v1, 1);
- memcpy(fp2, fp1, RE_STRAND_ELEMS*sizeof(float));
- }
- fp1= RE_vertren_get_tangent(obr, ver, 0);
- if (fp1) {
- fp2= RE_vertren_get_tangent(obr, v1, 1);
- memcpy(fp2, fp1, RE_TANGENT_ELEMS*sizeof(float));
- }
- int1= RE_vertren_get_origindex(obr, ver, 0);
- if (int1) {
- int2= RE_vertren_get_origindex(obr, v1, 1);
- memcpy(int2, int1, RE_VERT_ORIGINDEX_ELEMS*sizeof(int));
- }
- return v1;
-}
-
-VertRen *RE_findOrAddVert(ObjectRen *obr, int nr)
-{
- VertTableNode *temp;
- VertRen *v;
- int a;
-
- if (nr<0) {
- printf("error in findOrAddVert: %d\n", nr);
- return NULL;
- }
- a= nr>>8;
-
- if (a>=obr->vertnodeslen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */
- temp= obr->vertnodes;
-
- obr->vertnodes= MEM_mallocN(sizeof(VertTableNode)*(obr->vertnodeslen+TABLEINITSIZE), "vertnodes");
- if (temp) memcpy(obr->vertnodes, temp, obr->vertnodeslen*sizeof(VertTableNode));
- memset(obr->vertnodes+obr->vertnodeslen, 0, TABLEINITSIZE*sizeof(VertTableNode));
-
- obr->vertnodeslen+=TABLEINITSIZE;
- if (temp) MEM_freeN(temp);
- }
-
- v= obr->vertnodes[a].vert;
- if (v==NULL) {
- int i;
-
- v= (VertRen *)MEM_callocN(256*sizeof(VertRen), "findOrAddVert");
- obr->vertnodes[a].vert= v;
-
- for (i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++) {
- v[a].index= i;
- }
- }
- v+= (nr & 255);
- return v;
-}
-
-/* ------------------------------------------------------------------------ */
-
-MTFace *RE_vlakren_get_tface(ObjectRen *obr, VlakRen *vlr, int n, char **name, int verify)
-{
- VlakTableNode *node;
- int nr= vlr->index>>8, vlakindex= (vlr->index&255);
- int index= (n<<8) + vlakindex;
-
- node= &obr->vlaknodes[nr];
-
- if (verify) {
- if (n>=node->totmtface) {
- MTFace *mtface= node->mtface;
- int size= (n+1)*256;
-
- node->mtface= MEM_callocN(size*sizeof(MTFace), "Vlak mtface");
-
- if (mtface) {
- size= node->totmtface*256;
- memcpy(node->mtface, mtface, size*sizeof(MTFace));
- MEM_freeN(mtface);
- }
-
- node->totmtface= n+1;
- }
- }
- else {
- if (n>=node->totmtface)
- return NULL;
-
- if (name) *name= obr->mtface[n];
- }
-
- return node->mtface + index;
-}
-
-MCol *RE_vlakren_get_mcol(ObjectRen *obr, VlakRen *vlr, int n, char **name, int verify)
-{
- VlakTableNode *node;
- int nr= vlr->index>>8, vlakindex= (vlr->index&255);
- int index= (n<<8) + vlakindex;
-
- node= &obr->vlaknodes[nr];
-
- if (verify) {
- if (n>=node->totmcol) {
- MCol *mcol= node->mcol;
- int size= (n+1)*256;
-
- node->mcol= MEM_callocN(size*sizeof(MCol)*RE_MCOL_ELEMS, "Vlak mcol");
-
- if (mcol) {
- size= node->totmcol*256;
- memcpy(node->mcol, mcol, size*sizeof(MCol)*RE_MCOL_ELEMS);
- MEM_freeN(mcol);
- }
-
- node->totmcol= n+1;
- }
- }
- else {
- if (n>=node->totmcol)
- return NULL;
-
- if (name) *name= obr->mcol[n];
- }
-
- return node->mcol + index*RE_MCOL_ELEMS;
-}
-
-int *RE_vlakren_get_origindex(ObjectRen *obr, VlakRen *vlak, int verify)
-{
- int *origindex;
- int nr= vlak->index>>8;
-
- origindex= obr->vlaknodes[nr].origindex;
- if (origindex==NULL) {
- if (verify)
- origindex= obr->vlaknodes[nr].origindex= MEM_callocN(256*RE_VLAK_ORIGINDEX_ELEMS*sizeof(int), "origindex table");
- else
- return NULL;
- }
- return origindex + (vlak->index & 255)*RE_VLAK_ORIGINDEX_ELEMS;
-}
-
-float *RE_vlakren_get_surfnor(ObjectRen *obr, VlakRen *vlak, int verify)
-{
- float *surfnor;
- int nr= vlak->index>>8;
-
- surfnor= obr->vlaknodes[nr].surfnor;
- if (surfnor==NULL) {
- if (verify)
- surfnor= obr->vlaknodes[nr].surfnor= MEM_callocN(256*RE_SURFNOR_ELEMS*sizeof(float), "surfnor table");
- else
- return NULL;
- }
- return surfnor + (vlak->index & 255)*RE_SURFNOR_ELEMS;
-}
-
-float *RE_vlakren_get_nmap_tangent(ObjectRen *obr, VlakRen *vlak, int index, bool verify)
-{
- float **tangents;
- int nr= vlak->index>>8;
-
- tangents = obr->vlaknodes[nr].tangent_arrays;
-
- if (index + 1 > 8) {
- return NULL;
- }
-
- index = index < 0 ? 0: index;
-
- if (tangents[index] == NULL) {
- if (verify) {
- tangents[index] = MEM_callocN(256*RE_NMAP_TANGENT_ELEMS*sizeof(float), "tangent table");
- }
- else
- return NULL;
- }
-
- return tangents[index] + (vlak->index & 255)*RE_NMAP_TANGENT_ELEMS;
-}
-
-RadFace **RE_vlakren_get_radface(ObjectRen *obr, VlakRen *vlak, int verify)
-{
- RadFace **radface;
- int nr= vlak->index>>8;
-
- radface= obr->vlaknodes[nr].radface;
- if (radface==NULL) {
- if (verify)
- radface = obr->vlaknodes[nr].radface= MEM_callocN(256 * RE_RADFACE_ELEMS * sizeof(void *), "radface table");
- else
- return NULL;
- }
- return radface + (vlak->index & 255)*RE_RADFACE_ELEMS;
-}
-
-VlakRen *RE_vlakren_copy(ObjectRen *obr, VlakRen *vlr)
-{
- VlakRen *vlr1 = RE_findOrAddVlak(obr, obr->totvlak++);
- MTFace *mtface, *mtface1;
- MCol *mcol, *mcol1;
- float *surfnor, *surfnor1;
- float *tangent, *tangent1;
- int *origindex, *origindex1;
- RadFace **radface, **radface1;
- int i, index = vlr1->index;
- char *name;
-
- *vlr1= *vlr;
- vlr1->index= index;
-
- for (i=0; (mtface=RE_vlakren_get_tface(obr, vlr, i, &name, 0)) != NULL; i++) {
- mtface1= RE_vlakren_get_tface(obr, vlr1, i, &name, 1);
- memcpy(mtface1, mtface, sizeof(MTFace)*RE_MTFACE_ELEMS);
- }
-
- for (i=0; (mcol=RE_vlakren_get_mcol(obr, vlr, i, &name, 0)) != NULL; i++) {
- mcol1= RE_vlakren_get_mcol(obr, vlr1, i, &name, 1);
- memcpy(mcol1, mcol, sizeof(MCol)*RE_MCOL_ELEMS);
- }
-
- origindex= RE_vlakren_get_origindex(obr, vlr, 0);
- if (origindex) {
- origindex1= RE_vlakren_get_origindex(obr, vlr1, 1);
- /* Just an int, but memcpy for consistency. */
- memcpy(origindex1, origindex, sizeof(int)*RE_VLAK_ORIGINDEX_ELEMS);
- }
-
- surfnor= RE_vlakren_get_surfnor(obr, vlr, 0);
- if (surfnor) {
- surfnor1= RE_vlakren_get_surfnor(obr, vlr1, 1);
- copy_v3_v3(surfnor1, surfnor);
- }
-
- for (i=0; i < MAX_MTFACE; i++) {
- tangent = RE_vlakren_get_nmap_tangent(obr, vlr, i, false);
- if (!tangent)
- continue;
- tangent1 = RE_vlakren_get_nmap_tangent(obr, vlr1, i, true);
- memcpy(tangent1, tangent, sizeof(float)*RE_NMAP_TANGENT_ELEMS);
- }
-
- radface= RE_vlakren_get_radface(obr, vlr, 0);
- if (radface) {
- radface1= RE_vlakren_get_radface(obr, vlr1, 1);
- *radface1= *radface;
- }
-
- return vlr1;
-}
-
-void RE_vlakren_get_normal(Render *UNUSED(re), ObjectInstanceRen *obi, VlakRen *vlr, float r_nor[3])
-{
- float (*nmat)[3]= obi->nmat;
-
- if (obi->flag & R_TRANSFORMED) {
- mul_v3_m3v3(r_nor, nmat, vlr->n);
- normalize_v3(r_nor);
- }
- else {
- copy_v3_v3(r_nor, vlr->n);
- }
-}
-
-void RE_set_customdata_names(ObjectRen *obr, CustomData *data)
-{
- /* CustomData layer names are stored per object here, because the
- * DerivedMesh which stores the layers is freed */
-
- CustomDataLayer *layer;
- int numtf = 0, numcol = 0, i, mtfn, mcn;
-
- if (CustomData_has_layer(data, CD_MTFACE)) {
- numtf= CustomData_number_of_layers(data, CD_MTFACE);
- obr->mtface= MEM_callocN(sizeof(*obr->mtface)*numtf, "mtfacenames");
- }
-
- if (CustomData_has_layer(data, CD_MCOL)) {
- numcol= CustomData_number_of_layers(data, CD_MCOL);
- obr->mcol= MEM_callocN(sizeof(*obr->mcol)*numcol, "mcolnames");
- }
-
- for (i=0, mtfn=0, mcn=0; i < data->totlayer; i++) {
- layer= &data->layers[i];
-
- if (layer->type == CD_MTFACE) {
- BLI_strncpy(obr->mtface[mtfn++], layer->name, sizeof(layer->name));
- obr->actmtface= CLAMPIS(layer->active_rnd, 0, numtf);
- obr->bakemtface= layer->active;
- }
- else if (layer->type == CD_MCOL) {
- BLI_strncpy(obr->mcol[mcn++], layer->name, sizeof(layer->name));
- obr->actmcol= CLAMPIS(layer->active_rnd, 0, numcol);
- }
- }
-}
-
-VlakRen *RE_findOrAddVlak(ObjectRen *obr, int nr)
-{
- VlakTableNode *temp;
- VlakRen *v;
- int a;
-
- if (nr<0) {
- printf("error in findOrAddVlak: %d\n", nr);
- return obr->vlaknodes[0].vlak;
- }
- a= nr>>8;
-
- if (a>=obr->vlaknodeslen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */
- temp= obr->vlaknodes;
-
- obr->vlaknodes= MEM_mallocN(sizeof(VlakTableNode)*(obr->vlaknodeslen+TABLEINITSIZE), "vlaknodes");
- if (temp) memcpy(obr->vlaknodes, temp, obr->vlaknodeslen*sizeof(VlakTableNode));
- memset(obr->vlaknodes+obr->vlaknodeslen, 0, TABLEINITSIZE*sizeof(VlakTableNode));
-
- obr->vlaknodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/
- if (temp) MEM_freeN(temp);
- }
-
- v= obr->vlaknodes[a].vlak;
-
- if (v==NULL) {
- int i;
-
- v= (VlakRen *)MEM_callocN(256*sizeof(VlakRen), "findOrAddVlak");
- obr->vlaknodes[a].vlak= v;
-
- for (i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++)
- v[a].index= i;
- }
- v+= (nr & 255);
- return v;
-}
-
-/* ------------------------------------------------------------------------ */
-
-float *RE_strandren_get_surfnor(ObjectRen *obr, StrandRen *strand, int verify)
-{
- float *surfnor;
- int nr= strand->index>>8;
-
- surfnor= obr->strandnodes[nr].surfnor;
- if (surfnor==NULL) {
- if (verify)
- surfnor= obr->strandnodes[nr].surfnor= MEM_callocN(256*RE_SURFNOR_ELEMS*sizeof(float), "surfnor strand table");
- else
- return NULL;
- }
- return surfnor + (strand->index & 255)*RE_SURFNOR_ELEMS;
-}
-
-float *RE_strandren_get_uv(ObjectRen *obr, StrandRen *strand, int n, char **name, int verify)
-{
- StrandTableNode *node;
- int nr= strand->index>>8, strandindex= (strand->index&255);
- int index= (n<<8) + strandindex;
-
- node= &obr->strandnodes[nr];
-
- if (verify) {
- if (n>=node->totuv) {
- float *uv= node->uv;
- int size= (n+1)*256;
-
- node->uv= MEM_callocN(size*sizeof(float)*RE_UV_ELEMS, "strand uv table");
-
- if (uv) {
- size= node->totuv*256;
- memcpy(node->uv, uv, size*sizeof(float)*RE_UV_ELEMS);
- MEM_freeN(uv);
- }
-
- node->totuv= n+1;
- }
- }
- else {
- if (n>=node->totuv)
- return NULL;
-
- if (name) *name= obr->mtface[n];
- }
-
- return node->uv + index*RE_UV_ELEMS;
-}
-
-MCol *RE_strandren_get_mcol(ObjectRen *obr, StrandRen *strand, int n, char **name, int verify)
-{
- StrandTableNode *node;
- int nr= strand->index>>8, strandindex= (strand->index&255);
- int index= (n<<8) + strandindex;
-
- node= &obr->strandnodes[nr];
-
- if (verify) {
- if (n>=node->totmcol) {
- MCol *mcol= node->mcol;
- int size= (n+1)*256;
-
- node->mcol= MEM_callocN(size*sizeof(MCol)*RE_MCOL_ELEMS, "strand mcol table");
-
- if (mcol) {
- size= node->totmcol*256;
- memcpy(node->mcol, mcol, size*sizeof(MCol)*RE_MCOL_ELEMS);
- MEM_freeN(mcol);
- }
-
- node->totmcol= n+1;
- }
- }
- else {
- if (n>=node->totmcol)
- return NULL;
-
- if (name) *name= obr->mcol[n];
- }
-
- return node->mcol + index*RE_MCOL_ELEMS;
-}
-
-float *RE_strandren_get_simplify(struct ObjectRen *obr, struct StrandRen *strand, int verify)
-{
- float *simplify;
- int nr= strand->index>>8;
-
- simplify= obr->strandnodes[nr].simplify;
- if (simplify==NULL) {
- if (verify)
- simplify= obr->strandnodes[nr].simplify= MEM_callocN(256*RE_SIMPLIFY_ELEMS*sizeof(float), "simplify strand table");
- else
- return NULL;
- }
- return simplify + (strand->index & 255)*RE_SIMPLIFY_ELEMS;
-}
-
-int *RE_strandren_get_face(ObjectRen *obr, StrandRen *strand, int verify)
-{
- int *face;
- int nr= strand->index>>8;
-
- face= obr->strandnodes[nr].face;
- if (face==NULL) {
- if (verify)
- face= obr->strandnodes[nr].face= MEM_callocN(256*RE_FACE_ELEMS*sizeof(int), "face strand table");
- else
- return NULL;
- }
- return face + (strand->index & 255)*RE_FACE_ELEMS;
-}
-
-/* winspeed is exception, it is stored per instance */
-float *RE_strandren_get_winspeed(ObjectInstanceRen *obi, StrandRen *strand, int verify)
-{
- float *winspeed;
- int totvector;
-
- winspeed= obi->vectors;
- if (winspeed==NULL) {
- if (verify) {
- totvector= obi->obr->totvert + obi->obr->totstrand;
- winspeed= obi->vectors= MEM_callocN(totvector*RE_WINSPEED_ELEMS*sizeof(float), "winspeed strand table");
- }
- else
- return NULL;
- }
- return winspeed + (obi->obr->totvert + strand->index)*RE_WINSPEED_ELEMS;
-}
-
-StrandRen *RE_findOrAddStrand(ObjectRen *obr, int nr)
-{
- StrandTableNode *temp;
- StrandRen *v;
- int a;
-
- if (nr<0) {
- printf("error in findOrAddStrand: %d\n", nr);
- return obr->strandnodes[0].strand;
- }
- a= nr>>8;
-
- if (a>=obr->strandnodeslen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */
- temp= obr->strandnodes;
-
- obr->strandnodes= MEM_mallocN(sizeof(StrandTableNode)*(obr->strandnodeslen+TABLEINITSIZE), "strandnodes");
- if (temp) memcpy(obr->strandnodes, temp, obr->strandnodeslen*sizeof(StrandTableNode));
- memset(obr->strandnodes+obr->strandnodeslen, 0, TABLEINITSIZE*sizeof(StrandTableNode));
-
- obr->strandnodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/
- if (temp) MEM_freeN(temp);
- }
-
- v= obr->strandnodes[a].strand;
-
- if (v==NULL) {
- int i;
-
- v= (StrandRen *)MEM_callocN(256*sizeof(StrandRen), "findOrAddStrand");
- obr->strandnodes[a].strand= v;
-
- for (i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++)
- v[a].index= i;
- }
- v+= (nr & 255);
- return v;
-}
-
-StrandBuffer *RE_addStrandBuffer(ObjectRen *obr, int totvert)
-{
- StrandBuffer *strandbuf;
-
- strandbuf= MEM_callocN(sizeof(StrandBuffer), "StrandBuffer");
- strandbuf->vert= MEM_callocN(sizeof(StrandVert)*totvert, "StrandVert");
- strandbuf->totvert= totvert;
- strandbuf->obr= obr;
-
- obr->strandbuf= strandbuf;
-
- return strandbuf;
-}
-
-/* ------------------------------------------------------------------------ */
-
-ObjectRen *RE_addRenderObject(Render *re, Object *ob, Object *par, int index, int psysindex, int lay)
-{
- ObjectRen *obr= MEM_callocN(sizeof(ObjectRen), "object render struct");
-
- BLI_addtail(&re->objecttable, obr);
- obr->ob= ob;
- obr->par= par;
- obr->index= index;
- obr->psysindex= psysindex;
- obr->lay= lay;
-
- return obr;
-}
-
-void free_renderdata_vertnodes(VertTableNode *vertnodes)
-{
- int a;
-
- if (vertnodes==NULL) return;
-
- for (a=0; vertnodes[a].vert; a++) {
- MEM_freeN(vertnodes[a].vert);
-
- if (vertnodes[a].rad)
- MEM_freeN(vertnodes[a].rad);
- if (vertnodes[a].strand)
- MEM_freeN(vertnodes[a].strand);
- if (vertnodes[a].tangent)
- MEM_freeN(vertnodes[a].tangent);
- if (vertnodes[a].stress)
- MEM_freeN(vertnodes[a].stress);
- if (vertnodes[a].winspeed)
- MEM_freeN(vertnodes[a].winspeed);
- if (vertnodes[a].origindex)
- MEM_freeN(vertnodes[a].origindex);
- }
-
- MEM_freeN(vertnodes);
-}
-
-void free_renderdata_vlaknodes(VlakTableNode *vlaknodes)
-{
- int a;
-
- if (vlaknodes==NULL) return;
-
- for (a=0; vlaknodes[a].vlak; a++) {
- MEM_freeN(vlaknodes[a].vlak);
-
- if (vlaknodes[a].mtface)
- MEM_freeN(vlaknodes[a].mtface);
- if (vlaknodes[a].mcol)
- MEM_freeN(vlaknodes[a].mcol);
- if (vlaknodes[a].origindex)
- MEM_freeN(vlaknodes[a].origindex);
- if (vlaknodes[a].surfnor)
- MEM_freeN(vlaknodes[a].surfnor);
- for (int b = 0; b < MAX_MTFACE; b++) {
- if (vlaknodes[a].tangent_arrays[b])
- MEM_freeN(vlaknodes[a].tangent_arrays[b]);
- }
- if (vlaknodes[a].radface)
- MEM_freeN(vlaknodes[a].radface);
- }
-
- MEM_freeN(vlaknodes);
-}
-
-static void free_renderdata_strandnodes(StrandTableNode *strandnodes)
-{
- int a;
-
- if (strandnodes==NULL) return;
-
- for (a=0; strandnodes[a].strand; a++) {
- MEM_freeN(strandnodes[a].strand);
-
- if (strandnodes[a].uv)
- MEM_freeN(strandnodes[a].uv);
- if (strandnodes[a].mcol)
- MEM_freeN(strandnodes[a].mcol);
- if (strandnodes[a].winspeed)
- MEM_freeN(strandnodes[a].winspeed);
- if (strandnodes[a].surfnor)
- MEM_freeN(strandnodes[a].surfnor);
- if (strandnodes[a].simplify)
- MEM_freeN(strandnodes[a].simplify);
- if (strandnodes[a].face)
- MEM_freeN(strandnodes[a].face);
- }
-
- MEM_freeN(strandnodes);
-}
-
-void free_renderdata_tables(Render *re)
-{
- ObjectInstanceRen *obi;
- ObjectRen *obr;
- StrandBuffer *strandbuf;
- int a=0;
-
- for (obr=re->objecttable.first; obr; obr=obr->next) {
- if (obr->vertnodes) {
- free_renderdata_vertnodes(obr->vertnodes);
- obr->vertnodes= NULL;
- obr->vertnodeslen= 0;
- }
-
- if (obr->vlaknodes) {
- free_renderdata_vlaknodes(obr->vlaknodes);
- obr->vlaknodes= NULL;
- obr->vlaknodeslen= 0;
- obr->totvlak= 0;
- }
-
- if (obr->bloha) {
- for (a=0; obr->bloha[a]; a++)
- MEM_freeN(obr->bloha[a]);
-
- MEM_freeN(obr->bloha);
- obr->bloha= NULL;
- obr->blohalen= 0;
- }
-
- if (obr->strandnodes) {
- free_renderdata_strandnodes(obr->strandnodes);
- obr->strandnodes= NULL;
- obr->strandnodeslen= 0;
- }
-
- strandbuf= obr->strandbuf;
- if (strandbuf) {
- if (strandbuf->vert) MEM_freeN(strandbuf->vert);
- if (strandbuf->bound) MEM_freeN(strandbuf->bound);
- MEM_freeN(strandbuf);
- }
-
- if (obr->mtface)
- MEM_freeN(obr->mtface);
-
- if (obr->mcol)
- MEM_freeN(obr->mcol);
-
- if (obr->rayfaces) {
- MEM_freeN(obr->rayfaces);
- obr->rayfaces = NULL;
- }
-
- if (obr->rayprimitives) {
- MEM_freeN(obr->rayprimitives);
- obr->rayprimitives = NULL;
- }
-
- if (obr->raytree) {
- RE_rayobject_free(obr->raytree);
- obr->raytree = NULL;
- }
- }
-
- if (re->objectinstance) {
- for (obi=re->instancetable.first; obi; obi=obi->next) {
- if (obi->vectors)
- MEM_freeN(obi->vectors);
-
- if (obi->raytree)
- RE_rayobject_free(obi->raytree);
- }
-
- MEM_freeN(re->objectinstance);
- re->objectinstance= NULL;
- re->totinstance= 0;
- re->instancetable.first= re->instancetable.last= NULL;
- }
-
- if (re->sortedhalos) {
- MEM_freeN(re->sortedhalos);
- re->sortedhalos= NULL;
- }
-
- BLI_freelistN(&re->customdata_names);
- BLI_freelistN(&re->objecttable);
- BLI_freelistN(&re->instancetable);
-}
-
-/* ------------------------------------------------------------------------ */
-
-HaloRen *RE_findOrAddHalo(ObjectRen *obr, int nr)
-{
- HaloRen *h, **temp;
- int a;
-
- if (nr<0) {
- printf("error in findOrAddHalo: %d\n", nr);
- return NULL;
- }
- a= nr>>8;
-
- if (a>=obr->blohalen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */
- //printf("Allocating %i more halo groups. %i total.\n",
- // TABLEINITSIZE, obr->blohalen+TABLEINITSIZE );
- temp=obr->bloha;
-
- obr->bloha = (HaloRen **)MEM_callocN(sizeof(void *) * (obr->blohalen + TABLEINITSIZE), "Bloha");
- if (temp) memcpy(obr->bloha, temp, obr->blohalen*sizeof(void *));
- memset(&(obr->bloha[obr->blohalen]), 0, TABLEINITSIZE * sizeof(void *));
- obr->blohalen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/
- if (temp) MEM_freeN(temp);
- }
-
- h= obr->bloha[a];
- if (h==NULL) {
- h= (HaloRen *)MEM_callocN(256*sizeof(HaloRen), "findOrAdHalo");
- obr->bloha[a]= h;
- }
- h+= (nr & 255);
- return h;
-}
-
-/* ------------------------------------------------------------------------- */
-
-HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma,
- const float vec[3], const float vec1[3],
- const float *orco, float hasize, float vectsize, int seed)
-{
- const bool skip_load_image = (re->r.scemode & R_NO_IMAGE_LOAD) != 0;
- const bool texnode_preview = (re->r.scemode & R_TEXNODE_PREVIEW) != 0;
- HaloRen *har;
- MTex *mtex;
- float tin, tr, tg, tb, ta;
- float xn, yn, zn, texvec[3], hoco[4], hoco1[4];
-
- if (hasize==0.0f) return NULL;
-
- projectverto(vec, re->winmat, hoco);
- if (hoco[3]==0.0f) return NULL;
- if (vec1) {
- projectverto(vec1, re->winmat, hoco1);
- if (hoco1[3]==0.0f) return NULL;
- }
-
- har= RE_findOrAddHalo(obr, obr->tothalo++);
- copy_v3_v3(har->co, vec);
- har->hasize= hasize;
-
- /* actual projectvert is done in function project_renderdata() because of parts/border/pano */
- /* we do it here for sorting of halos */
- zn= hoco[3];
- har->xs= 0.5f*re->winx*(hoco[0]/zn);
- har->ys= 0.5f*re->winy*(hoco[1]/zn);
- har->zs= 0x7FFFFF*(hoco[2]/zn);
-
- har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn);
-
- /* halovect */
- if (vec1) {
-
- har->type |= HA_VECT;
-
- xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]);
- yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]);
- if (yn == 0.0f && xn >= 0.0f) zn = 0.0f;
- else zn = atan2f(yn, xn);
-
- har->sin = sinf(zn);
- har->cos = cosf(zn);
- zn= len_v3v3(vec1, vec);
-
- har->hasize= vectsize*zn + (1.0f-vectsize)*hasize;
-
- sub_v3_v3v3(har->no, vec, vec1);
- normalize_v3(har->no);
- }
-
- if (ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA;
-
- har->alfa= ma->alpha;
- har->r= ma->r;
- har->g= ma->g;
- har->b= ma->b;
- har->add= (255.0f*ma->add);
- har->mat= ma;
- har->hard= ma->har;
- har->seed= seed % 256;
-
- if (ma->mode & MA_STAR) har->starpoints= ma->starc;
- if (ma->mode & MA_HALO_LINES) har->linec= ma->linec;
- if (ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc;
- if (ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec;
-
-
- if (ma->mtex[0]) {
-
- if (ma->mode & MA_HALOTEX) {
- har->tex = 1;
- }
- else if (har->mat->septex & (1 << 0)) {
- /* only 1 level textures */
- }
- else {
- mtex= ma->mtex[0];
- copy_v3_v3(texvec, vec);
-
- if (mtex->texco & TEXCO_NORM) {
- ;
- }
- else if (mtex->texco & TEXCO_OBJECT) {
- /* texvec[0]+= imatbase->ivec[0]; */
- /* texvec[1]+= imatbase->ivec[1]; */
- /* texvec[2]+= imatbase->ivec[2]; */
- /* mul_m3_v3(imatbase->imat, texvec); */
- }
- else {
- if (orco) {
- copy_v3_v3(texvec, orco);
- }
- }
-
- externtex(mtex,
- texvec,
- &tin, &tr, &tg, &tb, &ta,
- 0,
- re->pool,
- skip_load_image,
- texnode_preview);
-
- yn= tin*mtex->colfac;
- //zn= tin*mtex->alphafac;
-
- if (mtex->mapto & MAP_COL) {
- zn= 1.0f-yn;
- har->r= (yn*tr+ zn*ma->r);
- har->g= (yn*tg+ zn*ma->g);
- har->b= (yn*tb+ zn*ma->b);
- }
- if (mtex->texco & TEXCO_UV) {
- har->alfa= tin;
- }
- if (mtex->mapto & MAP_ALPHA)
- har->alfa= tin;
- }
- }
-
- har->pool = re->pool;
- har->skip_load_image = skip_load_image;
- har->texnode_preview = texnode_preview;
-
- return har;
-}
-
-HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Material *ma,
- const float vec[3], const float vec1[3],
- const float *orco, const float *uvco, float hasize, float vectsize, int seed, const float pa_co[3])
-{
- const bool skip_load_image = (re->r.scemode & R_NO_IMAGE_LOAD) != 0;
- const bool texnode_preview = (re->r.scemode & R_TEXNODE_PREVIEW) != 0;
- HaloRen *har;
- MTex *mtex;
- float tin, tr, tg, tb, ta;
- float xn, yn, zn, texvec[3], hoco[4], hoco1[4], in[3], tex[3], out[3];
- int i, hasrgb;
-
- if (hasize==0.0f) return NULL;
-
- projectverto(vec, re->winmat, hoco);
- if (hoco[3]==0.0f) return NULL;
- if (vec1) {
- projectverto(vec1, re->winmat, hoco1);
- if (hoco1[3]==0.0f) return NULL;
- }
-
- har= RE_findOrAddHalo(obr, obr->tothalo++);
- copy_v3_v3(har->co, vec);
- har->hasize= hasize;
-
- /* actual projectvert is done in function project_renderdata() because of parts/border/pano */
- /* we do it here for sorting of halos */
- zn= hoco[3];
- har->xs= 0.5f*re->winx*(hoco[0]/zn);
- har->ys= 0.5f*re->winy*(hoco[1]/zn);
- har->zs= 0x7FFFFF*(hoco[2]/zn);
-
- har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn);
-
- /* halovect */
- if (vec1) {
-
- har->type |= HA_VECT;
-
- xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]);
- yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]);
- if (yn == 0.0f && xn >= 0.0f) zn = 0.0f;
- else zn = atan2f(yn, xn);
-
- har->sin = sinf(zn);
- har->cos = cosf(zn);
- zn= len_v3v3(vec1, vec)*0.5f;
-
- har->hasize= vectsize*zn + (1.0f-vectsize)*hasize;
-
- sub_v3_v3v3(har->no, vec, vec1);
- normalize_v3(har->no);
- }
-
- if (ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA;
-
- har->alfa= ma->alpha;
- har->r= ma->r;
- har->g= ma->g;
- har->b= ma->b;
- har->add= (255.0f*ma->add);
- har->mat= ma;
- har->hard= ma->har;
- har->seed= seed % 256;
-
- if (ma->mode & MA_STAR) har->starpoints= ma->starc;
- if (ma->mode & MA_HALO_LINES) har->linec= ma->linec;
- if (ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc;
- if (ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec;
-
- if ((ma->mode & MA_HALOTEX) && ma->mtex[0])
- har->tex= 1;
-
- for (i=0; i<MAX_MTEX; i++)
- if (ma->mtex[i] && (ma->septex & (1<<i))==0) {
- mtex= ma->mtex[i];
- copy_v3_v3(texvec, vec);
-
- if (mtex->texco & TEXCO_NORM) {
- ;
- }
- else if (mtex->texco & TEXCO_OBJECT) {
- if (mtex->object)
- mul_m4_v3(mtex->object->imat_ren, texvec);
- }
- else if (mtex->texco & TEXCO_GLOB) {
- copy_v3_v3(texvec, vec);
- }
- else if (mtex->texco & TEXCO_UV && uvco) {
- int uv_index=CustomData_get_named_layer_index(&dm->faceData, CD_MTFACE, mtex->uvname);
- if (uv_index<0)
- uv_index=CustomData_get_active_layer_index(&dm->faceData, CD_MTFACE);
-
- uv_index-=CustomData_get_layer_index(&dm->faceData, CD_MTFACE);
-
- texvec[0]=2.0f*uvco[2*uv_index]-1.0f;
- texvec[1]=2.0f*uvco[2*uv_index+1]-1.0f;
- texvec[2]=0.0f;
- }
- else if (mtex->texco & TEXCO_PARTICLE) {
- /* particle coordinates in range [0, 1] */
- texvec[0] = 2.f * pa_co[0] - 1.f;
- texvec[1] = 2.f * pa_co[1] - 1.f;
- texvec[2] = pa_co[2];
- }
- else if (orco) {
- copy_v3_v3(texvec, orco);
- }
-
- hasrgb = externtex(mtex,
- texvec,
- &tin, &tr, &tg, &tb, &ta,
- 0,
- re->pool,
- skip_load_image,
- texnode_preview);
-
- //yn= tin*mtex->colfac;
- //zn= tin*mtex->alphafac;
- if (mtex->mapto & MAP_COL) {
- tex[0]=tr;
- tex[1]=tg;
- tex[2]=tb;
- out[0]=har->r;
- out[1]=har->g;
- out[2]=har->b;
-
- texture_rgb_blend(in, tex, out, tin, mtex->colfac, mtex->blendtype);
- // zn= 1.0-yn;
- //har->r= (yn*tr+ zn*ma->r);
- //har->g= (yn*tg+ zn*ma->g);
- //har->b= (yn*tb+ zn*ma->b);
- har->r= in[0];
- har->g= in[1];
- har->b= in[2];
- }
-
- /* alpha returned, so let's use it instead of intensity */
- if (hasrgb)
- tin = ta;
-
- if (mtex->mapto & MAP_ALPHA)
- har->alfa = texture_value_blend(mtex->def_var, har->alfa, tin, mtex->alphafac, mtex->blendtype);
- if (mtex->mapto & MAP_HAR)
- har->hard = 1.0f+126.0f*texture_value_blend(mtex->def_var, ((float)har->hard)/127.0f, tin, mtex->hardfac, mtex->blendtype);
- if (mtex->mapto & MAP_RAYMIRR)
- har->hasize = 100.0f*texture_value_blend(mtex->def_var, har->hasize/100.0f, tin, mtex->raymirrfac, mtex->blendtype);
- if (mtex->mapto & MAP_TRANSLU) {
- float add = texture_value_blend(mtex->def_var, (float)har->add/255.0f, tin, mtex->translfac, mtex->blendtype);
- CLAMP(add, 0.f, 1.f);
- har->add = 255.0f*add;
- }
- /* now what on earth is this good for?? */
- //if (mtex->texco & 16) {
- // har->alfa= tin;
- //}
- }
-
- har->pool = re->pool;
- har->skip_load_image = (re->r.scemode & R_NO_IMAGE_LOAD) != 0;
- har->texnode_preview = (re->r.scemode & R_TEXNODE_PREVIEW) != 0;
-
- return har;
-}
-
-/* -------------------------- operations on entire database ----------------------- */
-
-/* ugly function for halos in panorama */
-static int panotestclip(Render *re, bool do_pano, float v[4])
-{
- /* part size (ensure we run RE_parts_clamp first) */
- BLI_assert(re->partx == min_ii(re->r.tilex, re->rectx));
- BLI_assert(re->party == min_ii(re->r.tiley, re->recty));
-
- if (do_pano == false) {
- return testclip(v);
- }
- else {
- /* to be used for halos en infos */
- float abs4;
- short c = 0;
-
- int xparts = (re->rectx + re->partx - 1) / re->partx;
-
- abs4= fabsf(v[3]);
-
- if (v[2]< -abs4) c=16; /* this used to be " if (v[2]<0) ", see clippz() */
- else if (v[2]> abs4) c+= 32;
-
- if ( v[1]>abs4) c+=4;
- else if ( v[1]< -abs4) c+=8;
-
- abs4*= xparts;
- if ( v[0]>abs4) c+=2;
- else if ( v[0]< -abs4) c+=1;
-
- return c;
- }
-}
-
-/**
- * This adds the hcs coordinates to vertices. It iterates over all
- * vertices, halos and faces. After the conversion, we clip in hcs.
- *
- * Elsewhere, all primites are converted to vertices.
- * Called in
- * - envmapping (envmap.c)
- * - shadow buffering (shadbuf.c)
- */
-
-void project_renderdata(Render *re,
- void (*projectfunc)(const float *, float mat[4][4], float *),
- bool do_pano, float xoffs, bool UNUSED(do_buckets))
-{
- ObjectRen *obr;
- HaloRen *har = NULL;
- float zn, vec[3], hoco[4];
- int a;
-
- if (do_pano) {
- float panophi= xoffs;
-
- re->panosi = sinf(panophi);
- re->panoco = cosf(panophi);
- }
-
- for (obr=re->objecttable.first; obr; obr=obr->next) {
- /* calculate view coordinates (and zbuffer value) */
- for (a=0; a<obr->tothalo; a++) {
- if ((a & 255)==0) har= obr->bloha[a>>8];
- else har++;
-
- if (do_pano) {
- vec[0]= re->panoco*har->co[0] + re->panosi*har->co[2];
- vec[1]= har->co[1];
- vec[2]= -re->panosi*har->co[0] + re->panoco*har->co[2];
- }
- else {
- copy_v3_v3(vec, har->co);
- }
-
- projectfunc(vec, re->winmat, hoco);
-
- /* we clip halos less critical, but not for the Z */
- hoco[0]*= 0.5f;
- hoco[1]*= 0.5f;
-
- if ( panotestclip(re, do_pano, hoco) ) {
- har->miny= har->maxy= -10000; /* that way render clips it */
- }
- else if (hoco[3]<0.0f) {
- har->miny= har->maxy= -10000; /* render clips it */
- }
- else { /* do the projection...*/
- /* bring back hocos */
- hoco[0]*= 2.0f;
- hoco[1]*= 2.0f;
-
- zn= hoco[3];
- har->xs= 0.5f*re->winx*(1.0f+hoco[0]/zn); /* the 0.5 negates the previous 2...*/
- har->ys= 0.5f*re->winy*(1.0f+hoco[1]/zn);
-
- /* this should be the zbuffer coordinate */
- har->zs= 0x7FFFFF*(hoco[2]/zn);
- /* taking this from the face clip functions? seems ok... */
- har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn);
-
- vec[0]+= har->hasize;
- projectfunc(vec, re->winmat, hoco);
- vec[0]-= har->hasize;
- zn= hoco[3];
- har->rad= fabsf(har->xs- 0.5f*re->winx*(1.0f+hoco[0]/zn));
-
- /* this clip is not really OK, to prevent stars to become too large */
- if (har->type & HA_ONLYSKY) {
- if (har->rad>3.0f) har->rad= 3.0f;
- }
-
- har->radsq= har->rad*har->rad;
-
- har->miny= har->ys - har->rad/re->ycor;
- har->maxy= har->ys + har->rad/re->ycor;
-
- /* the Zd value is still not really correct for pano */
-
- vec[2] -= har->hasize; /* z negative, otherwise it's clipped */
- projectfunc(vec, re->winmat, hoco);
- zn = hoco[3];
- zn = fabsf((float)har->zs - 0x7FFFFF * (hoco[2] / zn));
- har->zd = CLAMPIS(zn, 0, INT_MAX);
-
- }
-
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-void RE_updateRenderInstance(Render *re, ObjectInstanceRen *obi, int flag)
-{
- /* flag specifies what things have changed. */
- if (flag & RE_OBJECT_INSTANCES_UPDATE_OBMAT) {
- copy_m4_m4(obi->obmat, obi->ob->obmat);
- invert_m4_m4(obi->obinvmat, obi->obmat);
- }
- if (flag & RE_OBJECT_INSTANCES_UPDATE_VIEW) {
- mul_m4_m4m4(obi->localtoviewmat, re->viewmat, obi->obmat);
- mul_m4_m4m4(obi->localtoviewinvmat, obi->obinvmat, re->viewinv);
- }
-}
-
-void RE_updateRenderInstances(Render *re, int flag)
-{
- int i = 0;
- for (i = 0; i < re->totinstance; i++)
- RE_updateRenderInstance(re, &re->objectinstance[i], flag);
-}
-
-ObjectInstanceRen *RE_addRenderInstance(
- Render *re, ObjectRen *obr, Object *ob, Object *par,
- int index, int psysindex, float mat[4][4], int lay, const DupliObject *dob)
-{
- ObjectInstanceRen *obi;
- float mat3[3][3];
-
- obi= MEM_callocN(sizeof(ObjectInstanceRen), "ObjectInstanceRen");
- obi->obr= obr;
- obi->ob= ob;
- obi->par= par;
- obi->index= index;
- obi->psysindex= psysindex;
- obi->lay= lay;
-
- /* Fill particle info */
- if (par && dob) {
- const ParticleSystem *psys = dob->particle_system;
- if (psys) {
- int part_index;
- if (obi->index < psys->totpart) {
- part_index = obi->index;
- }
- else if (psys->child) {
- part_index = psys->child[obi->index - psys->totpart].parent;
- }
- else {
- part_index = -1;
- }
-
- if (part_index >= 0) {
- const ParticleData *p = &psys->particles[part_index];
- obi->part_index = part_index;
- obi->part_size = p->size;
- obi->part_age = RE_GetStats(re)->cfra - p->time;
- obi->part_lifetime = p->lifetime;
-
- copy_v3_v3(obi->part_co, p->state.co);
- copy_v3_v3(obi->part_vel, p->state.vel);
- copy_v3_v3(obi->part_avel, p->state.ave);
- }
- }
- }
-
- /* Fill object info */
- if (dob) {
- obi->random_id = dob->random_id;
- }
- else {
- obi->random_id = BLI_hash_int_2d(BLI_hash_string(obi->ob->id.name + 2), 0);
- }
-
- RE_updateRenderInstance(re, obi, RE_OBJECT_INSTANCES_UPDATE_OBMAT | RE_OBJECT_INSTANCES_UPDATE_VIEW);
-
- if (mat) {
- copy_m4_m4(obi->mat, mat);
- copy_m3_m4(mat3, mat);
- invert_m3_m3(obi->nmat, mat3);
- transpose_m3(obi->nmat);
- obi->flag |= R_DUPLI_TRANSFORMED;
- }
-
- BLI_addtail(&re->instancetable, obi);
-
- return obi;
-}
-
-void RE_instance_get_particle_info(struct ObjectInstanceRen *obi, float *index, float *random, float *age, float *lifetime, float co[3], float *size, float vel[3], float angvel[3])
-{
- *index = obi->part_index;
- *random = BLI_hash_int_01(obi->part_index);
- *age = obi->part_age;
- *lifetime = obi->part_lifetime;
- copy_v3_v3(co, obi->part_co);
- *size = obi->part_size;
- copy_v3_v3(vel, obi->part_vel);
- copy_v3_v3(angvel, obi->part_avel);
-}
-
-
-void RE_makeRenderInstances(Render *re)
-{
- ObjectInstanceRen *obi, *oldobi;
- ListBase newlist;
- int tot;
-
- /* convert list of object instances to an array for index based lookup */
- tot= BLI_listbase_count(&re->instancetable);
- re->objectinstance= MEM_callocN(sizeof(ObjectInstanceRen)*tot, "ObjectInstance");
- re->totinstance= tot;
- newlist.first= newlist.last= NULL;
-
- obi= re->objectinstance;
- for (oldobi=re->instancetable.first; oldobi; oldobi=oldobi->next) {
- *obi= *oldobi;
-
- if (obi->obr) {
- obi->prev= obi->next= NULL;
- BLI_addtail(&newlist, obi);
- obi++;
- }
- else
- re->totinstance--;
- }
-
- BLI_freelistN(&re->instancetable);
- re->instancetable= newlist;
-}
-
-/* four functions to facilitate envmap rotation for raytrace */
-void RE_instance_rotate_ray_start(ObjectInstanceRen *obi, Isect *is)
-{
- if (obi && (obi->flag & R_ENV_TRANSFORMED)) {
- copy_v3_v3(is->origstart, is->start);
- mul_m4_v3(obi->imat, is->start);
- }
-}
-
-void RE_instance_rotate_ray_dir(ObjectInstanceRen *obi, Isect *is)
-{
- if (obi && (obi->flag & R_ENV_TRANSFORMED)) {
- float end[3];
-
- copy_v3_v3(is->origdir, is->dir);
- add_v3_v3v3(end, is->origstart, is->dir);
-
- mul_m4_v3(obi->imat, end);
- sub_v3_v3v3(is->dir, end, is->start);
- }
-}
-
-void RE_instance_rotate_ray(ObjectInstanceRen *obi, Isect *is)
-{
- RE_instance_rotate_ray_start(obi, is);
- RE_instance_rotate_ray_dir(obi, is);
-}
-
-void RE_instance_rotate_ray_restore(ObjectInstanceRen *obi, Isect *is)
-{
- if (obi && (obi->flag & R_ENV_TRANSFORMED)) {
- copy_v3_v3(is->start, is->origstart);
- copy_v3_v3(is->dir, is->origdir);
- }
-}
-
-int clip_render_object(float boundbox[2][3], float bounds[4], float winmat[4][4])
-{
- float mat[4][4], vec[4];
- int a, fl, flag = -1;
-
- copy_m4_m4(mat, winmat);
-
- for (a=0; a < 8; a++) {
- vec[0]= (a & 1)? boundbox[0][0]: boundbox[1][0];
- vec[1]= (a & 2)? boundbox[0][1]: boundbox[1][1];
- vec[2]= (a & 4)? boundbox[0][2]: boundbox[1][2];
- vec[3]= 1.0;
- mul_m4_v4(mat, vec);
-
- fl = 0;
- if (bounds) {
- if (vec[0] < bounds[0] * vec[3]) fl |= 1;
- else if (vec[0] > bounds[1] * vec[3]) fl |= 2;
-
- if (vec[1] > bounds[3] * vec[3]) fl |= 4;
- else if (vec[1] < bounds[2] * vec[3]) fl |= 8;
- }
- else {
- if (vec[0] < -vec[3]) fl |= 1;
- else if (vec[0] > vec[3]) fl |= 2;
-
- if (vec[1] > vec[3]) fl |= 4;
- else if (vec[1] < -vec[3]) fl |= 8;
- }
- if (vec[2] < -vec[3]) fl |= 16;
- else if (vec[2] > vec[3]) fl |= 32;
-
- flag &= fl;
- if (flag == 0) {
- return 0;
- }
- }
-
- return flag;
-}
-
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
deleted file mode 100644
index fb441662829..00000000000
--- a/source/blender/render/intern/source/shadbuf.c
+++ /dev/null
@@ -1,2647 +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.
- *
- * Contributor(s): 2004-2006, Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/shadbuf.c
- * \ingroup render
- */
-
-
-#include <math.h>
-#include <string.h>
-
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_group_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_material_types.h"
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_jitter_2d.h"
-#include "BLI_memarena.h"
-#include "BLI_rand.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_global.h"
-#include "BKE_scene.h"
-
-#include "PIL_time.h"
-
-#include "render_types.h"
-#include "renderdatabase.h"
-#include "rendercore.h"
-#include "shadbuf.h"
-#include "shading.h"
-#include "zbuf.h"
-
-/* XXX, could be better implemented... this is for endian issues */
-#ifdef __BIG_ENDIAN__
-//# define RCOMP 3
-# define GCOMP 2
-# define BCOMP 1
-# define ACOMP 0
-#else
-//# define RCOMP 0
-# define GCOMP 1
-# define BCOMP 2
-# define ACOMP 3
-#endif
-
-#define RCT_SIZE_X(rct) ((rct)->xmax - (rct)->xmin)
-#define RCT_SIZE_Y(rct) ((rct)->ymax - (rct)->ymin)
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-/* ------------------------------------------------------------------------- */
-
-/* initshadowbuf() in convertBlenderScene.c */
-
-/* ------------------------------------------------------------------------- */
-
-static void copy_to_ztile(int *rectz, int size, int x1, int y1, int tile, char *r1)
-{
- int len4, *rz;
- int x2, y2;
-
- x2= x1+tile;
- y2= y1+tile;
- if (x2>=size) x2= size-1;
- if (y2>=size) y2= size-1;
-
- if (x1>=x2 || y1>=y2) return;
-
- len4= 4*(x2- x1);
- rz= rectz + size*y1 + x1;
- for (; y1<y2; y1++) {
- memcpy(r1, rz, len4);
- rz+= size;
- r1+= len4;
- }
-}
-
-#if 0
-static int sizeoflampbuf(ShadBuf *shb)
-{
- int num, count=0;
- char *cp;
-
- cp= shb->cbuf;
- num= (shb->size*shb->size)/256;
-
- while (num--) count+= *(cp++);
-
- return 256*count;
-}
-#endif
-
-/* not threadsafe... */
-static float *give_jitter_tab(int samp)
-{
- /* these are all possible jitter tables, takes up some
- * 12k, not really bad!
- * For soft shadows, it saves memory and render time
- */
- static int tab[17]={1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256};
- static float jit[1496][2];
- static char ctab[17]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- int a, offset=0;
-
- if (samp<2) samp= 2;
- else if (samp>16) samp= 16;
-
- for (a=0; a<samp-1; a++) offset+= tab[a];
-
- if (ctab[samp]==0) {
- ctab[samp]= 1;
- BLI_jitter_init((float (*)[2])jit[offset], samp*samp);
- }
-
- return jit[offset];
-
-}
-
-static void make_jitter_weight_tab(Render *re, ShadBuf *shb, short filtertype)
-{
- float *jit, totw= 0.0f;
- int samp= get_render_shadow_samples(&re->r, shb->samp);
- int a, tot=samp*samp;
-
- shb->weight= MEM_mallocN(sizeof(float)*tot, "weight tab lamp");
-
- for (jit= shb->jit, a=0; a<tot; a++, jit+=2) {
- if (filtertype==LA_SHADBUF_TENT)
- shb->weight[a] = 0.71f - sqrtf(jit[0] * jit[0] + jit[1] * jit[1]);
- else if (filtertype==LA_SHADBUF_GAUSS)
- shb->weight[a] = RE_filter_value(R_FILTER_GAUSS, 1.8f * sqrtf(jit[0] * jit[0] + jit[1] * jit[1]));
- else
- shb->weight[a]= 1.0f;
-
- totw+= shb->weight[a];
- }
-
- totw= 1.0f/totw;
- for (a=0; a<tot; a++) {
- shb->weight[a]*= totw;
- }
-}
-
-static int verg_deepsample(const void *poin1, const void *poin2)
-{
- const DeepSample *ds1= (const DeepSample*)poin1;
- const DeepSample *ds2= (const DeepSample*)poin2;
-
- if (ds1->z < ds2->z) return -1;
- else if (ds1->z == ds2->z) return 0;
- else return 1;
-}
-
-static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon)
-{
- /* uses doubles to avoid overflows and other numerical issues,
- * could be improved */
- DeepSample *ds, *newds;
- float v;
- double slope, slopemin, slopemax, min, max, div, newmin, newmax;
- int a, first, z, newtot= 0;
-
-#if 0
- if (print) {
- for (a=0, ds=dsample; a<tot; a++, ds++)
- printf("%lf, %f ", ds->z/(double)0x7FFFFFFF, ds->v);
- printf("\n");
- }
-#endif
-
- /* read from and write into same array */
- ds= dsample;
- newds= dsample;
- a= 0;
-
- /* as long as we are not at the end of the array */
- for (a++, ds++; a<tot; a++, ds++) {
- slopemin= 0.0f;
- slopemax= 0.0f;
- first= 1;
-
- for (; a<tot; a++, ds++) {
- //dz= ds->z - newds->z;
- if (ds->z == newds->z) {
- /* still in same z position, simply check
- * visibility difference against epsilon */
- if (!(fabsf(newds->v - ds->v) <= epsilon)) {
- break;
- }
- }
- else {
- /* compute slopes */
- div= (double)0x7FFFFFFF / ((double)ds->z - (double)newds->z);
- min= (double)((ds->v - epsilon) - newds->v) * div;
- max= (double)((ds->v + epsilon) - newds->v) * div;
-
- /* adapt existing slopes */
- if (first) {
- newmin= min;
- newmax= max;
- first= 0;
- }
- else {
- newmin= MAX2(slopemin, min);
- newmax= MIN2(slopemax, max);
-
- /* verify if there is still space between the slopes */
- if (newmin > newmax) {
- ds--;
- a--;
- break;
- }
- }
-
- slopemin= newmin;
- slopemax= newmax;
- }
- }
-
- if (a == tot) {
- ds--;
- a--;
- }
-
- /* always previous z */
- z= ds->z;
-
- if (first || a==tot-1) {
- /* if slopes were not initialized, use last visibility */
- v= ds->v;
- }
- else {
- /* compute visibility at center between slopes at z */
- slope = (slopemin + slopemax) * 0.5;
- v = (double)newds->v + slope * ((double)(z - newds->z) / (double)0x7FFFFFFF);
- }
-
- newds++;
- newtot++;
-
- newds->z= z;
- newds->v= v;
- }
-
- if (newtot == 0 || (newds->v != (newds-1)->v))
- newtot++;
-
-#if 0
- if (print) {
- for (a=0, ds=dsample; a<newtot; a++, ds++)
- printf("%lf, %f ", ds->z/(double)0x7FFFFFFF, ds->v);
- printf("\n");
- }
-#endif
-
- return newtot;
-}
-
-static float deep_alpha(Render *re, int obinr, int facenr, bool use_strand)
-{
- ObjectInstanceRen *obi= &re->objectinstance[obinr];
- Material *ma;
-
- if (use_strand) {
- StrandRen *strand= RE_findOrAddStrand(obi->obr, facenr-1);
- ma= strand->buffer->ma;
- }
- else {
- VlakRen *vlr= RE_findOrAddVlak(obi->obr, (facenr-1) & RE_QUAD_MASK);
- ma= vlr->mat;
- }
-
- return ma->shad_alpha;
-}
-
-static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, APixstrand *apixbufstrand)
-{
- ShadSampleBuf *shsample;
- DeepSample *ds[RE_MAX_OSA], *sampleds[RE_MAX_OSA], *dsb, *newbuf;
- APixstr *ap, *apn;
- APixstrand *aps, *apns;
- float visibility;
-
- const int totbuf= shb->totbuf;
- const float totbuf_f= (float)shb->totbuf;
- const float totbuf_f_inv= 1.0f/totbuf_f;
- const int size= shb->size;
-
- int a, b, c, tot, minz, found, prevtot, newtot;
- int sampletot[RE_MAX_OSA], totsample = 0, totsamplec = 0;
-
- shsample= MEM_callocN(sizeof(ShadSampleBuf), "shad sample buf");
- BLI_addtail(&shb->buffers, shsample);
-
- shsample->totbuf = MEM_callocN(sizeof(int) * size * size, "deeptotbuf");
- shsample->deepbuf = MEM_callocN(sizeof(DeepSample *) * size * size, "deepbuf");
-
- ap= apixbuf;
- aps= apixbufstrand;
- for (a=0; a<size*size; a++, ap++, aps++) {
- /* count number of samples */
- for (c=0; c<totbuf; c++)
- sampletot[c]= 0;
-
- tot= 0;
- for (apn=ap; apn; apn=apn->next)
- for (b=0; b<4; b++)
- if (apn->p[b])
- for (c=0; c<totbuf; c++)
- if (apn->mask[b] & (1<<c))
- sampletot[c]++;
-
- if (apixbufstrand) {
- for (apns=aps; apns; apns=apns->next)
- for (b=0; b<4; b++)
- if (apns->p[b])
- for (c=0; c<totbuf; c++)
- if (apns->mask[b] & (1<<c))
- sampletot[c]++;
- }
-
- for (c=0; c<totbuf; c++)
- tot += sampletot[c];
-
- if (tot == 0) {
- shsample->deepbuf[a]= NULL;
- shsample->totbuf[a]= 0;
- continue;
- }
-
- /* fill samples */
- ds[0]= sampleds[0]= MEM_callocN(sizeof(DeepSample)*tot*2, "deepsample");
- for (c=1; c<totbuf; c++)
- ds[c]= sampleds[c]= sampleds[c-1] + sampletot[c-1]*2;
-
- for (apn=ap; apn; apn=apn->next) {
- for (b=0; b<4; b++) {
- if (apn->p[b]) {
- for (c=0; c<totbuf; c++) {
- if (apn->mask[b] & (1<<c)) {
- /* two entries to create step profile */
- ds[c]->z= apn->z[b];
- ds[c]->v= 1.0f; /* not used */
- ds[c]++;
- ds[c]->z= apn->z[b];
- ds[c]->v= deep_alpha(re, apn->obi[b], apn->p[b], 0);
- ds[c]++;
- }
- }
- }
- }
- }
-
- if (apixbufstrand) {
- for (apns=aps; apns; apns=apns->next) {
- for (b=0; b<4; b++) {
- if (apns->p[b]) {
- for (c=0; c<totbuf; c++) {
- if (apns->mask[b] & (1<<c)) {
- /* two entries to create step profile */
- ds[c]->z= apns->z[b];
- ds[c]->v= 1.0f; /* not used */
- ds[c]++;
- ds[c]->z= apns->z[b];
- ds[c]->v= deep_alpha(re, apns->obi[b], apns->p[b], 1);
- ds[c]++;
- }
- }
- }
- }
- }
- }
-
- for (c=0; c<totbuf; c++) {
- /* sort by increasing z */
- qsort(sampleds[c], sampletot[c], sizeof(DeepSample)*2, verg_deepsample);
-
- /* sum visibility, replacing alpha values */
- visibility= 1.0f;
- ds[c]= sampleds[c];
-
- for (b=0; b<sampletot[c]; b++) {
- /* two entries creating step profile */
- ds[c]->v= visibility;
- ds[c]++;
-
- visibility *= 1.0f-ds[c]->v;
- ds[c]->v= visibility;
- ds[c]++;
- }
-
- /* halfway trick, probably won't work well for volumes? */
- ds[c]= sampleds[c];
- for (b=0; b<sampletot[c]; b++) {
- if (b+1 < sampletot[c]) {
- ds[c]->z= (ds[c]->z>>1) + ((ds[c]+2)->z>>1);
- ds[c]++;
- ds[c]->z= (ds[c]->z>>1) + ((ds[c]+2)->z>>1);
- ds[c]++;
- }
- else {
- ds[c]->z= (ds[c]->z>>1) + (0x7FFFFFFF>>1);
- ds[c]++;
- ds[c]->z= (ds[c]->z>>1) + (0x7FFFFFFF>>1);
- ds[c]++;
- }
- }
-
- /* init for merge loop */
- ds[c]= sampleds[c];
- sampletot[c] *= 2;
- }
-
- shsample->deepbuf[a]= MEM_callocN(sizeof(DeepSample)*tot*2, "deepsample");
- shsample->totbuf[a]= 0;
-
- /* merge buffers */
- dsb= shsample->deepbuf[a];
- while (1) {
- minz= 0;
- found= 0;
-
- for (c=0; c<totbuf; c++) {
- if (sampletot[c] && (!found || ds[c]->z < minz)) {
- minz= ds[c]->z;
- found= 1;
- }
- }
-
- if (!found)
- break;
-
- dsb->z= minz;
- dsb->v= 0.0f;
-
- visibility= 0.0f;
- for (c=0; c<totbuf; c++) {
- if (sampletot[c] && ds[c]->z == minz) {
- ds[c]++;
- sampletot[c]--;
- }
-
- if (sampleds[c] == ds[c])
- visibility += totbuf_f_inv;
- else
- visibility += (ds[c]-1)->v / totbuf_f;
- }
-
- dsb->v= visibility;
- dsb++;
- shsample->totbuf[a]++;
- }
-
- prevtot= shsample->totbuf[a];
- totsample += prevtot;
-
- newtot= compress_deepsamples(shsample->deepbuf[a], prevtot, shb->compressthresh);
- shsample->totbuf[a]= newtot;
- totsamplec += newtot;
-
- if (newtot < prevtot) {
- newbuf= MEM_mallocN(sizeof(DeepSample)*newtot, "cdeepsample");
- memcpy(newbuf, shsample->deepbuf[a], sizeof(DeepSample)*newtot);
- MEM_freeN(shsample->deepbuf[a]);
- shsample->deepbuf[a]= newbuf;
- }
-
- MEM_freeN(sampleds[0]);
- }
-
- //printf("%d -> %d, ratio %f\n", totsample, totsamplec, (float)totsamplec/(float)totsample);
-}
-
-/* create Z tiles (for compression): this system is 24 bits!!! */
-static void compress_shadowbuf(ShadBuf *shb, int *rectz, int square)
-{
- ShadSampleBuf *shsample;
- float dist;
- uintptr_t *ztile;
- int *rz, *rz1, verg, verg1, size= shb->size;
- int a, x, y, minx, miny, byt1, byt2;
- char *rc, *rcline, *ctile, *zt;
-
- shsample= MEM_callocN(sizeof(ShadSampleBuf), "shad sample buf");
- BLI_addtail(&shb->buffers, shsample);
-
- shsample->zbuf= MEM_mallocN(sizeof(uintptr_t)*(size*size)/256, "initshadbuf2");
- shsample->cbuf= MEM_callocN((size*size)/256, "initshadbuf3");
-
- ztile= (uintptr_t *)shsample->zbuf;
- ctile= shsample->cbuf;
-
- /* help buffer */
- rcline= MEM_mallocN(256*4+sizeof(int), "makeshadbuf2");
-
- for (y=0; y<size; y+=16) {
- if (y< size/2) miny= y+15-size/2;
- else miny= y-size/2;
-
- for (x=0; x<size; x+=16) {
-
- /* is tile within spotbundle? */
- a= size/2;
- if (x< a) minx= x+15-a;
- else minx= x-a;
-
- dist = sqrtf((float)(minx * minx + miny * miny));
-
- if (square==0 && dist>(float)(a+12)) { /* 12, tested with a onlyshadow lamp */
- a= 256; verg= 0; /* 0x80000000; */ /* 0x7FFFFFFF; */
- rz1= (&verg)+1;
- }
- else {
- copy_to_ztile(rectz, size, x, y, 16, rcline);
- rz1= (int *)rcline;
-
- verg= (*rz1 & 0xFFFFFF00);
-
- for (a=0;a<256;a++, rz1++) {
- if ( (*rz1 & 0xFFFFFF00) !=verg) break;
- }
- }
- if (a==256) { /* complete empty tile */
- *ctile= 0;
- *ztile= *(rz1-1);
- }
- else {
-
- /* ACOMP etc. are defined to work L/B endian */
-
- rc= rcline;
- rz1= (int *)rcline;
- verg= rc[ACOMP];
- verg1= rc[BCOMP];
- rc+= 4;
- byt1= 1; byt2= 1;
- for (a=1;a<256;a++, rc+=4) {
- byt1 &= (verg==rc[ACOMP]);
- byt2 &= (verg1==rc[BCOMP]);
-
- if (byt1==0) break;
- }
- if (byt1 && byt2) { /* only store byte */
- *ctile= 1;
- *ztile= (uintptr_t)MEM_mallocN(256+4, "tile1");
- rz= (int *)*ztile;
- *rz= *rz1;
-
- zt= (char *)(rz+1);
- rc= rcline;
- for (a=0; a<256; a++, zt++, rc+=4) *zt= rc[GCOMP];
- }
- else if (byt1) { /* only store short */
- *ctile= 2;
- *ztile= (uintptr_t)MEM_mallocN(2*256+4, "Tile2");
- rz= (int *)*ztile;
- *rz= *rz1;
-
- zt= (char *)(rz+1);
- rc= rcline;
- for (a=0; a<256; a++, zt+=2, rc+=4) {
- zt[0]= rc[BCOMP];
- zt[1]= rc[GCOMP];
- }
- }
- else { /* store triple */
- *ctile= 3;
- *ztile= (uintptr_t)MEM_mallocN(3*256, "Tile3");
-
- zt= (char *)*ztile;
- rc= rcline;
- for (a=0; a<256; a++, zt+=3, rc+=4) {
- zt[0]= rc[ACOMP];
- zt[1]= rc[BCOMP];
- zt[2]= rc[GCOMP];
- }
- }
- }
- ztile++;
- ctile++;
- }
- }
-
- MEM_freeN(rcline);
-}
-
-/* sets start/end clipping. lar->shb should be initialized */
-static void shadowbuf_autoclip(Render *re, LampRen *lar)
-{
- ObjectInstanceRen *obi;
- ObjectRen *obr;
- VlakRen *vlr= NULL;
- VertRen *ver= NULL;
- Material *ma= NULL;
- float minz, maxz, vec[3], viewmat[4][4], obviewmat[4][4];
- unsigned int lay = -1;
- int i, a, maxtotvert, ok= 1;
- char *clipflag;
-
- minz= 1.0e30f; maxz= -1.0e30f;
- copy_m4_m4(viewmat, lar->shb->viewmat);
-
- if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay;
-
- maxtotvert= 0;
- for (obr=re->objecttable.first; obr; obr=obr->next)
- maxtotvert = max_ii(obr->totvert, maxtotvert);
-
- clipflag= MEM_callocN(sizeof(char)*maxtotvert, "autoclipflag");
-
- /* set clip in vertices when face visible */
- for (i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) {
- obr= obi->obr;
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obviewmat, viewmat, obi->mat);
- else
- copy_m4_m4(obviewmat, viewmat);
-
- memset(clipflag, 0, sizeof(char)*obr->totvert);
-
- /* clear clip, is being set if face is visible (clip is calculated for real later) */
- for (a=0; a<obr->totvlak; a++) {
- if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
- else vlr++;
-
- /* note; these conditions are copied from zbuffer_shadow() */
- if (vlr->mat!= ma) {
- ma= vlr->mat;
- ok= 1;
- if ((ma->mode2 & MA_CASTSHADOW)==0 || (ma->mode & MA_SHADBUF)==0) ok= 0;
- }
-
- if (ok && (obi->lay & lay)) {
- clipflag[vlr->v1->index]= 1;
- clipflag[vlr->v2->index]= 1;
- clipflag[vlr->v3->index]= 1;
- if (vlr->v4) clipflag[vlr->v4->index]= 1;
- }
- }
-
- /* calculate min and max */
- for (a=0; a< obr->totvert;a++) {
- if ((a & 255)==0) ver= RE_findOrAddVert(obr, a);
- else ver++;
-
- if (clipflag[a]) {
- copy_v3_v3(vec, ver->co);
- mul_m4_v3(obviewmat, vec);
- /* Z on visible side of lamp space */
- if (vec[2] < 0.0f) {
- float inpr, z= -vec[2];
-
- /* since vec is rotated in lampspace, this is how to get the cosine of angle */
- /* precision is set 20% larger */
- vec[2]*= 1.2f;
- normalize_v3(vec);
- inpr= - vec[2];
-
- if (inpr>=lar->spotsi) {
- if (z<minz) minz= z;
- if (z>maxz) maxz= z;
- }
- }
- }
- }
- }
-
- MEM_freeN(clipflag);
-
- /* set clipping min and max */
- if (minz < maxz) {
- float delta= (maxz - minz); /* threshold to prevent precision issues */
-
- //printf("minz %f maxz %f delta %f\n", minz, maxz, delta);
- if (lar->bufflag & LA_SHADBUF_AUTO_START)
- lar->shb->d= minz - delta*0.02f; /* 0.02 is arbitrary... needs more thinking! */
- if (lar->bufflag & LA_SHADBUF_AUTO_END)
- lar->shb->clipend= maxz + delta*0.1f;
-
- /* bias was calculated as percentage, we scale it to prevent animation issues */
- delta= (lar->clipend-lar->clipsta)/(lar->shb->clipend-lar->shb->d);
- //printf("bias delta %f\n", delta);
- lar->shb->bias= (int) (delta*(float)lar->shb->bias);
- }
-}
-
-static void makeflatshadowbuf(Render *re, LampRen *lar, float *jitbuf)
-{
- ShadBuf *shb= lar->shb;
- int *rectz, samples;
-
- /* zbuffering */
- rectz= MEM_mapallocN(sizeof(int)*shb->size*shb->size, "makeshadbuf");
-
- for (samples=0; samples<shb->totbuf; samples++) {
- zbuffer_shadow(re, shb->persmat, lar, rectz, shb->size, jitbuf[2*samples], jitbuf[2*samples+1]);
- /* create Z tiles (for compression): this system is 24 bits!!! */
- compress_shadowbuf(shb, rectz, lar->mode & LA_SQUARE);
-
- if (re->test_break(re->tbh))
- break;
- }
-
- MEM_freeN(rectz);
-}
-
-static void makedeepshadowbuf(Render *re, LampRen *lar, float *jitbuf)
-{
- ShadBuf *shb= lar->shb;
- APixstr *apixbuf;
- APixstrand *apixbufstrand= NULL;
- ListBase apsmbase= {NULL, NULL};
-
- /* zbuffering */
- apixbuf= MEM_callocN(sizeof(APixstr)*shb->size*shb->size, "APixbuf");
- if (re->totstrand)
- apixbufstrand= MEM_callocN(sizeof(APixstrand)*shb->size*shb->size, "APixbufstrand");
-
- zbuffer_abuf_shadow(re, lar, shb->persmat, apixbuf, apixbufstrand, &apsmbase, shb->size,
- shb->totbuf, (float(*)[2])jitbuf);
-
- /* create Z tiles (for compression): this system is 24 bits!!! */
- compress_deepshadowbuf(re, shb, apixbuf, apixbufstrand);
-
- MEM_freeN(apixbuf);
- if (apixbufstrand)
- MEM_freeN(apixbufstrand);
- freepsA(&apsmbase);
-}
-
-void makeshadowbuf(Render *re, LampRen *lar)
-{
- ShadBuf *shb= lar->shb;
- float wsize, *jitbuf, twozero[2]= {0.0f, 0.0f}, angle, temp;
-
- if (lar->bufflag & (LA_SHADBUF_AUTO_START|LA_SHADBUF_AUTO_END))
- shadowbuf_autoclip(re, lar);
-
- /* just to enforce identical behavior of all irregular buffers */
- if (lar->buftype==LA_SHADBUF_IRREGULAR)
- shb->size= 1024;
-
- /* matrices and window: in winmat the transformation is being put,
- * transforming from observer view to lamp view, including lamp window matrix */
-
- angle= saacos(lar->spotsi);
- temp = 0.5f * shb->size * cosf(angle) / sinf(angle);
- shb->pixsize= (shb->d)/temp;
- wsize= shb->pixsize*(shb->size/2.0f);
-
- perspective_m4(shb->winmat, -wsize, wsize, -wsize, wsize, shb->d, shb->clipend);
- mul_m4_m4m4(shb->persmat, shb->winmat, shb->viewmat);
-
- if (ELEM(lar->buftype, LA_SHADBUF_REGULAR, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) {
- shb->totbuf= lar->buffers;
-
- /* jitter, weights - not threadsafe! */
- BLI_thread_lock(LOCK_CUSTOM1);
- shb->jit= give_jitter_tab(get_render_shadow_samples(&re->r, shb->samp));
- make_jitter_weight_tab(re, shb, lar->filtertype);
- BLI_thread_unlock(LOCK_CUSTOM1);
-
- if (shb->totbuf==4) jitbuf= give_jitter_tab(2);
- else if (shb->totbuf==9) jitbuf= give_jitter_tab(3);
- else jitbuf= twozero;
-
- /* zbuffering */
- if (lar->buftype == LA_SHADBUF_DEEP) {
- makedeepshadowbuf(re, lar, jitbuf);
- shb->totbuf= 1;
- }
- else
- makeflatshadowbuf(re, lar, jitbuf);
-
- /* printf("lampbuf %d\n", sizeoflampbuf(shb)); */
- }
-}
-
-static void *do_shadow_thread(void *re_v)
-{
- Render *re = (Render *)re_v;
- LampRen *lar;
-
- do {
- BLI_thread_lock(LOCK_CUSTOM1);
- for (lar=re->lampren.first; lar; lar=lar->next) {
- if (lar->shb && !lar->thread_assigned) {
- lar->thread_assigned= 1;
- break;
- }
- }
- BLI_thread_unlock(LOCK_CUSTOM1);
-
- /* if type is irregular, this only sets the perspective matrix and autoclips */
- if (lar) {
- makeshadowbuf(re, lar);
- BLI_thread_lock(LOCK_CUSTOM1);
- lar->thread_ready= 1;
- BLI_thread_unlock(LOCK_CUSTOM1);
- }
- } while (lar && !re->test_break(re->tbh));
-
- return NULL;
-}
-
-static volatile int g_break= 0;
-static int thread_break(void *UNUSED(arg))
-{
- return g_break;
-}
-
-void threaded_makeshadowbufs(Render *re)
-{
- ListBase threads;
- LampRen *lar;
- int a, totthread= 0;
- int (*test_break)(void *);
-
- /* count number of threads to use */
- if (G.is_rendering) {
- for (lar=re->lampren.first; lar; lar= lar->next)
- if (lar->shb)
- totthread++;
-
- totthread = min_ii(totthread, re->r.threads);
- }
- else
- totthread = 1; /* preview render */
-
- if (totthread <= 1) {
- for (lar=re->lampren.first; lar; lar= lar->next) {
- if (re->test_break(re->tbh)) break;
- if (lar->shb) {
- /* if type is irregular, this only sets the perspective matrix and autoclips */
- makeshadowbuf(re, lar);
- }
- }
- }
- else {
- /* swap test break function */
- test_break= re->test_break;
- re->test_break= thread_break;
-
- for (lar=re->lampren.first; lar; lar= lar->next) {
- lar->thread_assigned= 0;
- lar->thread_ready= 0;
- }
-
- BLI_threadpool_init(&threads, do_shadow_thread, totthread);
-
- for (a=0; a<totthread; a++)
- BLI_threadpool_insert(&threads, re);
-
- /* keep rendering as long as there are shadow buffers not ready */
- do {
- if ((g_break=test_break(re->tbh)))
- break;
-
- PIL_sleep_ms(50);
-
- BLI_thread_lock(LOCK_CUSTOM1);
- for (lar=re->lampren.first; lar; lar= lar->next)
- if (lar->shb && !lar->thread_ready)
- break;
- BLI_thread_unlock(LOCK_CUSTOM1);
- } while (lar);
-
- BLI_threadpool_end(&threads);
-
- /* unset threadsafety */
- re->test_break= test_break;
- g_break= 0;
- }
-}
-
-void freeshadowbuf(LampRen *lar)
-{
- if (lar->shb) {
- ShadBuf *shb= lar->shb;
- ShadSampleBuf *shsample;
- int b, v;
-
- for (shsample= shb->buffers.first; shsample; shsample= shsample->next) {
- if (shsample->deepbuf) {
- v= shb->size*shb->size;
- for (b=0; b<v; b++)
- if (shsample->deepbuf[b])
- MEM_freeN(shsample->deepbuf[b]);
-
- MEM_freeN(shsample->deepbuf);
- MEM_freeN(shsample->totbuf);
- }
- else {
- intptr_t *ztile= shsample->zbuf;
- const char *ctile= shsample->cbuf;
-
- v= (shb->size*shb->size)/256;
- for (b=0; b<v; b++, ztile++, ctile++)
- if (*ctile) MEM_freeN((void *) *ztile);
-
- MEM_freeN(shsample->zbuf);
- MEM_freeN(shsample->cbuf);
- }
- }
- BLI_freelistN(&shb->buffers);
-
- if (shb->weight) MEM_freeN(shb->weight);
- MEM_freeN(lar->shb);
-
- lar->shb= NULL;
- }
-}
-
-
-static int firstreadshadbuf(ShadBuf *shb, ShadSampleBuf *shsample, int **rz, int xs, int ys, int nr)
-{
- /* return a 1 if fully compressed shadbuf-tile && z==const */
- int ofs;
- const char *ct;
-
- if (shsample->deepbuf)
- return 0;
-
- /* always test borders of shadowbuffer */
- if (xs<0) xs= 0; else if (xs>=shb->size) xs= shb->size-1;
- if (ys<0) ys= 0; else if (ys>=shb->size) ys= shb->size-1;
-
- /* calc z */
- ofs= (ys>>4)*(shb->size>>4) + (xs>>4);
- ct= shsample->cbuf+ofs;
- if (*ct==0) {
- if (nr==0) {
- *rz= *( (int **)(shsample->zbuf+ofs) );
- return 1;
- }
- else if (*rz!= *( (int **)(shsample->zbuf+ofs) )) return 0;
-
- return 1;
- }
-
- return 0;
-}
-
-static float readdeepvisibility(DeepSample *dsample, int tot, int z, int bias, float *biast)
-{
- DeepSample *ds, *prevds;
- float t;
- int a;
-
- /* tricky stuff here; we use ints which can overflow easily with bias values */
-
- ds= dsample;
- for (a=0; a<tot && (z-bias > ds->z); a++, ds++) {}
-
- if (a == tot) {
- if (biast)
- *biast= 0.0f;
- return (ds-1)->v; /* completely behind all samples */
- }
-
- /* check if this read needs bias blending */
- if (biast) {
- if (z > ds->z)
- *biast= (float)(z - ds->z)/(float)bias;
- else
- *biast= 0.0f;
- }
-
- if (a == 0)
- return 1.0f; /* completely in front of all samples */
-
- /* converting to float early here because ds->z - prevds->z can overflow */
- prevds= ds-1;
- t= ((float)(z-bias) - (float)prevds->z)/((float)ds->z - (float)prevds->z);
- return t*ds->v + (1.0f-t)*prevds->v;
-}
-
-static float readdeepshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int xs, int ys, int zs)
-{
- float v, biasv, biast;
- int ofs, tot;
-
- if (zs < - 0x7FFFFE00 + bias)
- return 1.0; /* extreme close to clipstart */
-
- /* calc z */
- ofs= ys*shb->size + xs;
- tot= shsample->totbuf[ofs];
- if (tot == 0)
- return 1.0f;
-
- v= readdeepvisibility(shsample->deepbuf[ofs], tot, zs, bias, &biast);
-
- if (biast != 0.0f) {
- /* in soft bias area */
- biasv = readdeepvisibility(shsample->deepbuf[ofs], tot, zs, 0, NULL);
-
- biast= biast*biast;
- return (1.0f-biast)*v + biast*biasv;
- }
-
- return v;
-}
-
-/* return 1.0 : fully in light */
-static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int xs, int ys, int zs)
-{
- float temp;
- int *rz, ofs;
- int zsamp=0;
- char *ct, *cz;
-
- /* simpleclip */
- /* if (xs<0 || ys<0) return 1.0; */
- /* if (xs>=shb->size || ys>=shb->size) return 1.0; */
-
- /* always test borders of shadowbuffer */
- if (xs<0) xs= 0; else if (xs>=shb->size) xs= shb->size-1;
- if (ys<0) ys= 0; else if (ys>=shb->size) ys= shb->size-1;
-
- if (shsample->deepbuf)
- return readdeepshadowbuf(shb, shsample, bias, xs, ys, zs);
-
- /* calc z */
- ofs= (ys>>4)*(shb->size>>4) + (xs>>4);
- ct= shsample->cbuf+ofs;
- rz= *( (int **)(shsample->zbuf+ofs) );
-
- if (*ct==3) {
- ct= ((char *)rz)+3*16*(ys & 15)+3*(xs & 15);
- cz= (char *)&zsamp;
- cz[ACOMP]= ct[0];
- cz[BCOMP]= ct[1];
- cz[GCOMP]= ct[2];
- }
- else if (*ct==2) {
- ct= ((char *)rz);
- ct+= 4+2*16*(ys & 15)+2*(xs & 15);
- zsamp= *rz;
-
- cz= (char *)&zsamp;
- cz[BCOMP]= ct[0];
- cz[GCOMP]= ct[1];
- }
- else if (*ct==1) {
- ct= ((char *)rz);
- ct+= 4+16*(ys & 15)+(xs & 15);
- zsamp= *rz;
-
- cz= (char *)&zsamp;
- cz[GCOMP]= ct[0];
-
- }
- else {
- /* got warning on this for 64 bits.... */
- /* but it's working code! in this case rz is not a pointer but zvalue (ton) */
- zsamp= GET_INT_FROM_POINTER(rz);
- }
-
- /* tricky stuff here; we use ints which can overflow easily with bias values */
-
- if (zsamp > zs) return 1.0; /* absolute no shadow */
- else if (zs < - 0x7FFFFE00 + bias) return 1.0; /* extreme close to clipstart */
- else if (zsamp < zs-bias) return 0.0; /* absolute in shadow */
- else { /* soft area */
-
- temp= ( (float)(zs- zsamp) )/(float)bias;
- return 1.0f - temp*temp;
-
- }
-}
-
-static void shadowbuf_project_co(float *x, float *y, float *z, ShadBuf *shb, const float co[3])
-{
- float hco[4], size= 0.5f*(float)shb->size;
-
- copy_v3_v3(hco, co);
- hco[3]= 1.0f;
-
- mul_m4_v4(shb->persmat, hco);
-
- *x= size*(1.0f+hco[0]/hco[3]);
- *y= size*(1.0f+hco[1]/hco[3]);
- if (z) *z= (hco[2]/hco[3]);
-}
-
-/* the externally called shadow testing (reading) function */
-/* return 1.0: no shadow at all */
-float testshadowbuf(Render *re, ShadBuf *shb, const float co[3], const float dxco[3], const float dyco[3], float inp, float mat_bias)
-{
- ShadSampleBuf *shsample;
- float fac, dco[3], dx[3], dy[3], shadfac=0.0f;
- float xs1, ys1, zs1, *jit, *weight, xres, yres, biasf;
- int xs, ys, zs, bias, *rz;
- short a, num;
-
- /* crash preventer */
- if (shb->buffers.first==NULL)
- return 1.0f;
-
- /* when facing away, assume fully in shadow */
- if (inp <= 0.0f)
- return 0.0f;
-
- /* project coordinate to pixel space */
- shadowbuf_project_co(&xs1, &ys1, &zs1, shb, co);
-
- /* clip z coordinate, z is projected so that (-1.0, 1.0) matches
- * (clipstart, clipend), so we can do this simple test */
- if (zs1>=1.0f)
- return 0.0f;
- else if (zs1<= -1.0f)
- return 1.0f;
-
- zs= ((float)0x7FFFFFFF)*zs1;
-
- /* take num*num samples, increase area with fac */
- num= get_render_shadow_samples(&re->r, shb->samp);
- num= num*num;
- fac= shb->soft;
-
- /* compute z bias */
- if (mat_bias!=0.0f) biasf= shb->bias*mat_bias;
- else biasf= shb->bias;
- /* with inp==1.0, bias is half the size. correction value was 1.1, giving errors
- * on cube edges, with one side being almost frontal lighted (ton) */
- bias= (1.5f-inp*inp)*biasf;
-
- /* in case of no filtering we can do things simpler */
- if (num==1) {
- for (shsample= shb->buffers.first; shsample; shsample= shsample->next)
- shadfac += readshadowbuf(shb, shsample, bias, (int)xs1, (int)ys1, zs);
-
- return shadfac/(float)shb->totbuf;
- }
-
- /* calculate filter size */
- add_v3_v3v3(dco, co, dxco);
- shadowbuf_project_co(&dx[0], &dx[1], NULL, shb, dco);
- dx[0]= xs1 - dx[0];
- dx[1]= ys1 - dx[1];
-
- add_v3_v3v3(dco, co, dyco);
- shadowbuf_project_co(&dy[0], &dy[1], NULL, shb, dco);
- dy[0]= xs1 - dy[0];
- dy[1]= ys1 - dy[1];
-
- xres = fac * (fabsf(dx[0]) + fabsf(dy[0]));
- yres = fac * (fabsf(dx[1]) + fabsf(dy[1]));
- if (xres<1.0f) xres= 1.0f;
- if (yres<1.0f) yres= 1.0f;
-
- /* make xs1/xs1 corner of sample area */
- xs1 -= xres*0.5f;
- ys1 -= yres*0.5f;
-
- /* in case we have a constant value in a tile, we can do quicker lookup */
- if (xres<16.0f && yres<16.0f) {
- shsample= shb->buffers.first;
- if (firstreadshadbuf(shb, shsample, &rz, (int)xs1, (int)ys1, 0)) {
- if (firstreadshadbuf(shb, shsample, &rz, (int)(xs1+xres), (int)ys1, 1)) {
- if (firstreadshadbuf(shb, shsample, &rz, (int)xs1, (int)(ys1+yres), 1)) {
- if (firstreadshadbuf(shb, shsample, &rz, (int)(xs1+xres), (int)(ys1+yres), 1)) {
- return readshadowbuf(shb, shsample, bias, (int)xs1, (int)ys1, zs);
- }
- }
- }
- }
- }
-
- /* full jittered shadow buffer lookup */
- for (shsample= shb->buffers.first; shsample; shsample= shsample->next) {
- jit= shb->jit;
- weight= shb->weight;
-
- for (a=num; a>0; a--, jit+=2, weight++) {
- /* instead of jit i tried random: ugly! */
- /* note: the plus 0.5 gives best sampling results, jit goes from -0.5 to 0.5 */
- /* xs1 and ys1 are already corrected to be corner of sample area */
- xs= xs1 + xres*(jit[0] + 0.5f);
- ys= ys1 + yres*(jit[1] + 0.5f);
-
- shadfac+= *weight * readshadowbuf(shb, shsample, bias, xs, ys, zs);
- }
- }
-
- /* Renormalizes for the sample number: */
- return shadfac/(float)shb->totbuf;
-}
-
-/* different function... sampling behind clipend can be LIGHT, bias is negative! */
-/* return: light */
-static float readshadowbuf_halo(ShadBuf *shb, ShadSampleBuf *shsample, int xs, int ys, int zs)
-{
- float temp;
- int *rz, ofs;
- int bias, zbias, zsamp;
- char *ct, *cz;
-
- /* negative! The other side is more important */
- bias= -shb->bias;
-
- /* simpleclip */
- if (xs<0 || ys<0) return 0.0;
- if (xs>=shb->size || ys>=shb->size) return 0.0;
-
- /* calc z */
- ofs= (ys>>4)*(shb->size>>4) + (xs>>4);
- ct= shsample->cbuf+ofs;
- rz= *( (int **)(shsample->zbuf+ofs) );
-
- if (*ct==3) {
- ct= ((char *)rz)+3*16*(ys & 15)+3*(xs & 15);
- cz= (char *)&zsamp;
- zsamp= 0;
- cz[ACOMP]= ct[0];
- cz[BCOMP]= ct[1];
- cz[GCOMP]= ct[2];
- }
- else if (*ct==2) {
- ct= ((char *)rz);
- ct+= 4+2*16*(ys & 15)+2*(xs & 15);
- zsamp= *rz;
-
- cz= (char *)&zsamp;
- cz[BCOMP]= ct[0];
- cz[GCOMP]= ct[1];
- }
- else if (*ct==1) {
- ct= ((char *)rz);
- ct+= 4+16*(ys & 15)+(xs & 15);
- zsamp= *rz;
-
- cz= (char *)&zsamp;
- cz[GCOMP]= ct[0];
-
- }
- else {
- /* same as before */
- /* still working code! (ton) */
- zsamp= GET_INT_FROM_POINTER(rz);
- }
-
- /* NO schadow when sampled at 'eternal' distance */
-
- if (zsamp >= 0x7FFFFE00) return 1.0;
-
- if (zsamp > zs) return 1.0; /* absolute no shadww */
- else {
- /* bias is negative, so the (zs-bias) can be beyond 0x7fffffff */
- zbias= 0x7fffffff - zs;
- if (zbias > -bias) {
- if ( zsamp < zs-bias) return 0.0; /* absolute in shadow */
- }
- else return 0.0; /* absolute shadow */
- }
-
- /* soft area */
-
- temp= ( (float)(zs- zsamp) )/(float)bias;
- return 1.0f - temp*temp;
-}
-
-
-float shadow_halo(LampRen *lar, const float p1[3], const float p2[3])
-{
- /* p1 p2 already are rotated in spot-space */
- ShadBuf *shb= lar->shb;
- ShadSampleBuf *shsample;
- float co[4], siz;
- float lambda, lambda_o, lambda_x, lambda_y, ldx, ldy;
- float zf, xf1, yf1, zf1, xf2, yf2, zf2;
- float count, lightcount;
- int x, y, z, xs1, ys1;
- int dx = 0, dy = 0;
-
- siz= 0.5f*(float)shb->size;
-
- co[0]= p1[0];
- co[1]= p1[1];
- co[2]= p1[2]/lar->sh_zfac;
- co[3]= 1.0;
- mul_m4_v4(shb->winmat, co); /* rational hom co */
- xf1= siz*(1.0f+co[0]/co[3]);
- yf1= siz*(1.0f+co[1]/co[3]);
- zf1= (co[2]/co[3]);
-
-
- co[0]= p2[0];
- co[1]= p2[1];
- co[2]= p2[2]/lar->sh_zfac;
- co[3]= 1.0;
- mul_m4_v4(shb->winmat, co); /* rational hom co */
- xf2= siz*(1.0f+co[0]/co[3]);
- yf2= siz*(1.0f+co[1]/co[3]);
- zf2= (co[2]/co[3]);
-
- /* the 2dda (a pixel line formula) */
-
- xs1= (int)xf1;
- ys1= (int)yf1;
-
- if (xf1 != xf2) {
- if (xf2-xf1 > 0.0f) {
- lambda_x= (xf1-xs1-1.0f)/(xf1-xf2);
- ldx= -shb->shadhalostep/(xf1-xf2);
- dx= shb->shadhalostep;
- }
- else {
- lambda_x= (xf1-xs1)/(xf1-xf2);
- ldx= shb->shadhalostep/(xf1-xf2);
- dx= -shb->shadhalostep;
- }
- }
- else {
- lambda_x= 1.0;
- ldx= 0.0;
- }
-
- if (yf1 != yf2) {
- if (yf2-yf1 > 0.0f) {
- lambda_y= (yf1-ys1-1.0f)/(yf1-yf2);
- ldy= -shb->shadhalostep/(yf1-yf2);
- dy= shb->shadhalostep;
- }
- else {
- lambda_y= (yf1-ys1)/(yf1-yf2);
- ldy= shb->shadhalostep/(yf1-yf2);
- dy= -shb->shadhalostep;
- }
- }
- else {
- lambda_y= 1.0;
- ldy= 0.0;
- }
-
- x= xs1;
- y= ys1;
- lambda= count= lightcount= 0.0;
-
-/* printf("start %x %x \n", (int)(0x7FFFFFFF*zf1), (int)(0x7FFFFFFF*zf2)); */
-
- do {
- lambda_o= lambda;
-
- if (lambda_x==lambda_y) {
- lambda_x+= ldx;
- x+= dx;
- lambda_y+= ldy;
- y+= dy;
- }
- else {
- if (lambda_x<lambda_y) {
- lambda_x+= ldx;
- x+= dx;
- }
- else {
- lambda_y+= ldy;
- y+= dy;
- }
- }
-
- lambda = min_ff(lambda_x, lambda_y);
-
- /* not making any progress? */
- if (lambda==lambda_o) break;
-
- /* clip to end of volume */
- lambda = min_ff(lambda, 1.0f);
-
- zf= zf1 + lambda*(zf2-zf1);
- count+= (float)shb->totbuf;
-
- if (zf<= -1.0f) lightcount += 1.0f; /* close to the spot */
- else {
-
- /* make sure, behind the clipend we extend halolines. */
- if (zf>=1.0f) z= 0x7FFFF000;
- else z= (int)(0x7FFFF000*zf);
-
- for (shsample= shb->buffers.first; shsample; shsample= shsample->next)
- lightcount+= readshadowbuf_halo(shb, shsample, x, y, z);
-
- }
- }
- while (lambda < 1.0f);
-
- if (count!=0.0f) return (lightcount/count);
- return 0.0f;
-
-}
-
-
-/* ********************* Irregular Shadow Buffer (ISB) ************* */
-/* ********** storage of all view samples in a raster of lists ***** */
-
-/* based on several articles describing this method, like:
- * The Irregular Z-Buffer and its Application to Shadow Mapping
- * Gregory S. Johnson - William R. Mark - Christopher A. Burns
- * and
- * Alias-Free Shadow Maps
- * Timo Aila and Samuli Laine
- */
-
-/* bsp structure (actually kd tree) */
-
-#define BSPMAX_SAMPLE 128
-#define BSPMAX_DEPTH 32
-
-/* aligned with struct rctf */
-typedef struct Boxf {
- float xmin, xmax;
- float ymin, ymax;
- float zmin, zmax;
-} Boxf;
-
-typedef struct ISBBranch {
- struct ISBBranch *left, *right;
- float divider[2];
- Boxf box;
- short totsamp, index, full, unused;
- ISBSample **samples;
-} ISBBranch;
-
-typedef struct BSPFace {
- Boxf box;
- const float *v1, *v2, *v3, *v4;
- int obi; /* object for face lookup */
- int facenr; /* index to retrieve VlakRen */
- int type; /* only for strand now */
- short shad_alpha, is_full;
-
- /* strand caching data, optimize for point_behind_strand() */
- float radline, radline_end, len;
- float vec1[3], vec2[3], rc[3];
-} BSPFace;
-
-/* boxes are in lamp projection */
-static void init_box(Boxf *box)
-{
- box->xmin = 1000000.0f;
- box->xmax = 0;
- box->ymin = 1000000.0f;
- box->ymax = 0;
- box->zmin= 0x7FFFFFFF;
- box->zmax= - 0x7FFFFFFF;
-}
-
-/* use v1 to calculate boundbox */
-static void bound_boxf(Boxf *box, const float v1[3])
-{
- if (v1[0] < box->xmin) box->xmin = v1[0];
- if (v1[0] > box->xmax) box->xmax = v1[0];
- if (v1[1] < box->ymin) box->ymin = v1[1];
- if (v1[1] > box->ymax) box->ymax = v1[1];
- if (v1[2] < box->zmin) box->zmin= v1[2];
- if (v1[2] > box->zmax) box->zmax= v1[2];
-}
-
-/* use v1 to calculate boundbox */
-static void bound_rectf(rctf *box, const float v1[2])
-{
- if (v1[0] < box->xmin) box->xmin = v1[0];
- if (v1[0] > box->xmax) box->xmax = v1[0];
- if (v1[1] < box->ymin) box->ymin = v1[1];
- if (v1[1] > box->ymax) box->ymax = v1[1];
-}
-
-
-/* halfway splitting, for initializing a more regular tree */
-static void isb_bsp_split_init(ISBBranch *root, MemArena *mem, int level)
-{
-
- /* if level > 0 we create new branches and go deeper */
- if (level > 0) {
- ISBBranch *left, *right;
- int i;
-
- /* splitpoint */
- root->divider[0]= 0.5f*(root->box.xmin+root->box.xmax);
- root->divider[1]= 0.5f*(root->box.ymin+root->box.ymax);
-
- /* find best splitpoint */
- if (RCT_SIZE_X(&root->box) > RCT_SIZE_Y(&root->box))
- i = root->index = 0;
- else
- i = root->index = 1;
-
- left= root->left= BLI_memarena_alloc(mem, sizeof(ISBBranch));
- right= root->right= BLI_memarena_alloc(mem, sizeof(ISBBranch));
-
- /* box info */
- left->box= root->box;
- right->box= root->box;
- if (i==0) {
- left->box.xmax = root->divider[0];
- right->box.xmin = root->divider[0];
- }
- else {
- left->box.ymax = root->divider[1];
- right->box.ymin = root->divider[1];
- }
- isb_bsp_split_init(left, mem, level-1);
- isb_bsp_split_init(right, mem, level-1);
- }
- else {
- /* we add sample array */
- root->samples= BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *));
- }
-}
-
-/* note; if all samples on same location we just spread them over 2 new branches */
-static void isb_bsp_split(ISBBranch *root, MemArena *mem)
-{
- ISBBranch *left, *right;
- ISBSample *samples[BSPMAX_SAMPLE];
- int a, i;
-
- /* splitpoint */
- root->divider[0]= root->divider[1]= 0.0f;
- for (a=BSPMAX_SAMPLE-1; a>=0; a--) {
- root->divider[0]+= root->samples[a]->zco[0];
- root->divider[1]+= root->samples[a]->zco[1];
- }
- root->divider[0]/= BSPMAX_SAMPLE;
- root->divider[1]/= BSPMAX_SAMPLE;
-
- /* find best splitpoint */
- if (RCT_SIZE_X(&root->box) > RCT_SIZE_Y(&root->box))
- i = root->index = 0;
- else
- i = root->index = 1;
-
- /* new branches */
- left= root->left= BLI_memarena_alloc(mem, sizeof(ISBBranch));
- right= root->right= BLI_memarena_alloc(mem, sizeof(ISBBranch));
-
- /* new sample array */
- left->samples = BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *));
- right->samples = samples; /* tmp */
-
- /* split samples */
- for (a=BSPMAX_SAMPLE-1; a>=0; a--) {
- int comp= 0;
- /* this prevents adding samples all to 1 branch when divider is equal to samples */
- if (root->samples[a]->zco[i] == root->divider[i])
- comp= a & 1;
- else if (root->samples[a]->zco[i] < root->divider[i])
- comp= 1;
-
- if (comp==1) {
- left->samples[left->totsamp]= root->samples[a];
- left->totsamp++;
- }
- else {
- right->samples[right->totsamp]= root->samples[a];
- right->totsamp++;
- }
- }
-
- /* copy samples from tmp */
- memcpy(root->samples, samples, right->totsamp*(sizeof(void *)));
- right->samples= root->samples;
- root->samples= NULL;
-
- /* box info */
- left->box= root->box;
- right->box= root->box;
- if (i==0) {
- left->box.xmax = root->divider[0];
- right->box.xmin = root->divider[0];
- }
- else {
- left->box.ymax = root->divider[1];
- right->box.ymin = root->divider[1];
- }
-}
-
-/* inserts sample in main tree, also splits on threshold */
-/* returns 1 if error */
-static int isb_bsp_insert(ISBBranch *root, MemArena *memarena, ISBSample *sample)
-{
- ISBBranch *bspn= root;
- const float *zco= sample->zco;
- int i= 0;
-
- /* debug counter, also used to check if something was filled in ever */
- root->totsamp++;
-
- /* going over branches until last one found */
- while (bspn->left) {
- if (zco[bspn->index] <= bspn->divider[bspn->index])
- bspn= bspn->left;
- else
- bspn= bspn->right;
- i++;
- }
- /* bspn now is the last branch */
-
- if (bspn->totsamp==BSPMAX_SAMPLE) {
- printf("error in bsp branch\n"); /* only for debug, cannot happen */
- return 1;
- }
-
- /* insert */
- bspn->samples[bspn->totsamp]= sample;
- bspn->totsamp++;
-
- /* split if allowed and needed */
- if (bspn->totsamp==BSPMAX_SAMPLE) {
- if (i==BSPMAX_DEPTH) {
- bspn->totsamp--; /* stop filling in... will give errors */
- return 1;
- }
- isb_bsp_split(bspn, memarena);
- }
- return 0;
-}
-
-/* initialize vars in face, for optimal point-in-face test */
-static void bspface_init_strand(BSPFace *face)
-{
-
- face->radline= 0.5f* len_v2v2(face->v1, face->v2);
-
- mid_v3_v3v3(face->vec1, face->v1, face->v2);
- if (face->v4)
- mid_v3_v3v3(face->vec2, face->v3, face->v4);
- else
- copy_v3_v3(face->vec2, face->v3);
-
- face->rc[0]= face->vec2[0]-face->vec1[0];
- face->rc[1]= face->vec2[1]-face->vec1[1];
- face->rc[2]= face->vec2[2]-face->vec1[2];
-
- face->len= face->rc[0]*face->rc[0]+ face->rc[1]*face->rc[1];
-
- if (face->len != 0.0f) {
- face->radline_end = face->radline / sqrtf(face->len);
- face->len = 1.0f / face->len;
- }
-}
-
-/* brought back to a simple 2d case */
-static int point_behind_strand(const float p[3], BSPFace *face)
-{
- /* v1 - v2 is radius, v1 - v3 length */
- float dist, rc[2], pt[2];
-
- /* using code from dist_to_line_segment_v2(), distance vec to line-piece */
-
- if (face->len==0.0f) {
- rc[0]= p[0]-face->vec1[0];
- rc[1]= p[1]-face->vec1[1];
- dist = len_v2(rc);
-
- if (dist < face->radline)
- return 1;
- }
- else {
- float lambda= ( face->rc[0]*(p[0]-face->vec1[0]) + face->rc[1]*(p[1]-face->vec1[1]) )*face->len;
-
- if (lambda > -face->radline_end && lambda < 1.0f+face->radline_end) {
- /* hesse for dist: */
- //dist= (float)(fabs( (p[0]-vec2[0])*rc[1] + (p[1]-vec2[1])*rc[0])/len);
-
- pt[0]= lambda*face->rc[0]+face->vec1[0];
- pt[1]= lambda*face->rc[1]+face->vec1[1];
-
- rc[0]= pt[0]-p[0];
- rc[1]= pt[1]-p[1];
- dist = len_v2(rc);
-
- if (dist < face->radline) {
- float zval= face->vec1[2] + lambda*face->rc[2];
- if (p[2] > zval)
- return 1;
- }
- }
- }
- return 0;
-}
-
-
-/* return 1 if inside. code derived from src/parametrizer.c */
-static int point_behind_tria2d(const float p[3], const float v1[3], const float v2[3], const float v3[3])
-{
- float a[2], c[2], h[2], div;
- float u, v;
-
- a[0] = v2[0] - v1[0];
- a[1] = v2[1] - v1[1];
- c[0] = v3[0] - v1[0];
- c[1] = v3[1] - v1[1];
-
- div = a[0]*c[1] - a[1]*c[0];
- if (div==0.0f)
- return 0;
-
- h[0] = p[0] - v1[0];
- h[1] = p[1] - v1[1];
-
- div = 1.0f/div;
-
- u = (h[0]*c[1] - h[1]*c[0])*div;
- if (u >= 0.0f) {
- v = (a[0]*h[1] - a[1]*h[0])*div;
- if (v >= 0.0f) {
- if ( u + v <= 1.0f) {
- /* inside, now check if point p is behind */
- float z= (1.0f-u-v)*v1[2] + u*v2[2] + v*v3[2];
- if (z <= p[2])
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-#if 0
-/* tested these calls, but it gives inaccuracy, 'side' cannot be found reliably using v3 */
-
-/* check if line v1-v2 has all rect points on other side of point v3 */
-static int rect_outside_line(rctf *rect, const float v1[3], const float v2[3], const float v3[3])
-{
- float a, b, c;
- int side;
-
- /* line formula for v1-v2 */
- a= v2[1]-v1[1];
- b= v1[0]-v2[0];
- c= -a*v1[0] - b*v1[1];
- side= a*v3[0] + b*v3[1] + c < 0.0f;
-
- /* the four quad points */
- if ( side==(rect->xmin*a + rect->ymin*b + c >= 0.0f) )
- if ( side==(rect->xmax*a + rect->ymin*b + c >= 0.0f) )
- if ( side==(rect->xmax*a + rect->ymax*b + c >= 0.0f) )
- if ( side==(rect->xmin*a + rect->ymax*b + c >= 0.0f) )
- return 1;
- return 0;
-}
-
-/* check if one of the triangle edges separates all rect points on 1 side */
-static int rect_isect_tria(rctf *rect, const float v1[3], const float v2[3], const float v3[3])
-{
- if (rect_outside_line(rect, v1, v2, v3))
- return 0;
- if (rect_outside_line(rect, v2, v3, v1))
- return 0;
- if (rect_outside_line(rect, v3, v1, v2))
- return 0;
- return 1;
-}
-#endif
-
-/* if face overlaps a branch, it executes func. recursive */
-static void isb_bsp_face_inside(ISBBranch *bspn, BSPFace *face)
-{
-
- /* are we descending? */
- if (bspn->left) {
- /* hrmf, the box struct cannot be addressed with index */
- if (bspn->index==0) {
- if (face->box.xmin <= bspn->divider[0])
- isb_bsp_face_inside(bspn->left, face);
- if (face->box.xmax > bspn->divider[0])
- isb_bsp_face_inside(bspn->right, face);
- }
- else {
- if (face->box.ymin <= bspn->divider[1])
- isb_bsp_face_inside(bspn->left, face);
- if (face->box.ymax > bspn->divider[1])
- isb_bsp_face_inside(bspn->right, face);
- }
- }
- else {
- /* else: end branch reached */
- int a;
-
- if (bspn->totsamp==0) return;
-
- /* check for nodes entirely in shadow, can be skipped */
- if (bspn->totsamp==bspn->full)
- return;
-
- /* if bsp node is entirely in front of face, give up */
- if (bspn->box.zmax < face->box.zmin)
- return;
-
- /* if face boundbox is outside of branch rect, give up */
- if (0==BLI_rctf_isect((rctf *)&face->box, (rctf *)&bspn->box, NULL))
- return;
-
- /* test all points inside branch */
- for (a=bspn->totsamp-1; a>=0; a--) {
- ISBSample *samp= bspn->samples[a];
-
- if ((samp->facenr!=face->facenr || samp->obi!=face->obi) && samp->shadfac) {
- if (face->box.zmin < samp->zco[2]) {
- if (BLI_rctf_isect_pt_v((rctf *)&face->box, samp->zco)) {
- int inshadow= 0;
-
- if (face->type) {
- if (point_behind_strand(samp->zco, face))
- inshadow= 1;
- }
- else if ( point_behind_tria2d(samp->zco, face->v1, face->v2, face->v3))
- inshadow= 1;
- else if (face->v4 && point_behind_tria2d(samp->zco, face->v1, face->v3, face->v4))
- inshadow= 1;
-
- if (inshadow) {
- *(samp->shadfac) += face->shad_alpha;
- /* optimize; is_full means shad_alpha==4096 */
- if (*(samp->shadfac) >= 4096 || face->is_full) {
- bspn->full++;
- samp->shadfac= NULL;
- }
- }
- }
- }
- }
- }
- }
-}
-
-/* based on available samples, recalculate the bounding box for bsp nodes, recursive */
-static void isb_bsp_recalc_box(ISBBranch *root)
-{
- if (root->left) {
- isb_bsp_recalc_box(root->left);
- isb_bsp_recalc_box(root->right);
- }
- else if (root->totsamp) {
- int a;
-
- init_box(&root->box);
- for (a=root->totsamp-1; a>=0; a--)
- bound_boxf(&root->box, root->samples[a]->zco);
- }
-}
-
-/* callback function for zbuf clip */
-static void isb_bsp_test_strand(ZSpan *zspan, int obi, int zvlnr,
- const float *v1, const float *v2, const float *v3, const float *v4)
-{
- BSPFace face;
-
- face.v1= v1;
- face.v2= v2;
- face.v3= v3;
- face.v4= v4;
- face.obi= obi;
- face.facenr= zvlnr & ~RE_QUAD_OFFS;
- face.type= R_STRAND;
- if (R.osa)
- face.shad_alpha= (short)ceil(4096.0f*zspan->shad_alpha/(float)R.osa);
- else
- face.shad_alpha= (short)ceil(4096.0f*zspan->shad_alpha);
-
- face.is_full= (zspan->shad_alpha==1.0f);
-
- /* setup boundbox */
- init_box(&face.box);
- bound_boxf(&face.box, v1);
- bound_boxf(&face.box, v2);
- bound_boxf(&face.box, v3);
- if (v4)
- bound_boxf(&face.box, v4);
-
- /* optimize values */
- bspface_init_strand(&face);
-
- isb_bsp_face_inside((ISBBranch *)zspan->rectz, &face);
-
-}
-
-/* callback function for zbuf clip */
-static void isb_bsp_test_face(ZSpan *zspan, int obi, int zvlnr,
- const float *v1, const float *v2, const float *v3, const float *v4)
-{
- BSPFace face;
-
- face.v1= v1;
- face.v2= v2;
- face.v3= v3;
- face.v4= v4;
- face.obi= obi;
- face.facenr= zvlnr & ~RE_QUAD_OFFS;
- face.type= 0;
- if (R.osa)
- face.shad_alpha= (short)ceil(4096.0f*zspan->shad_alpha/(float)R.osa);
- else
- face.shad_alpha= (short)ceil(4096.0f*zspan->shad_alpha);
-
- face.is_full= (zspan->shad_alpha==1.0f);
-
- /* setup boundbox */
- init_box(&face.box);
- bound_boxf(&face.box, v1);
- bound_boxf(&face.box, v2);
- bound_boxf(&face.box, v3);
- if (v4)
- bound_boxf(&face.box, v4);
-
- isb_bsp_face_inside((ISBBranch *)zspan->rectz, &face);
-}
-
-static int testclip_minmax(const float ho[4], const float minmax[4])
-{
- float wco= ho[3];
- int flag= 0;
-
- if ( ho[0] > minmax[1]*wco) flag = 1;
- else if ( ho[0]< minmax[0]*wco) flag = 2;
-
- if ( ho[1] > minmax[3]*wco) flag |= 4;
- else if ( ho[1]< minmax[2]*wco) flag |= 8;
-
- return flag;
-}
-
-/* main loop going over all faces and check in bsp overlaps, fill in shadfac values */
-static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root)
-{
- ObjectInstanceRen *obi;
- ObjectRen *obr;
- ShadBuf *shb= lar->shb;
- ZSpan zspan, zspanstrand;
- VlakRen *vlr= NULL;
- Material *ma= NULL;
- float minmaxf[4], winmat[4][4];
- int size= shb->size;
- int i, a, ok=1, lay= -1;
-
- /* further optimize, also sets minz maxz */
- isb_bsp_recalc_box(root);
-
- /* extra clipping for minmax */
- minmaxf[0]= (2.0f*root->box.xmin - size-2.0f)/size;
- minmaxf[1]= (2.0f*root->box.xmax - size+2.0f)/size;
- minmaxf[2]= (2.0f*root->box.ymin - size-2.0f)/size;
- minmaxf[3]= (2.0f*root->box.ymax - size+2.0f)/size;
-
- if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay;
-
- /* (ab)use zspan, since we use zbuffer clipping code */
- zbuf_alloc_span(&zspan, size, size, re->clipcrop);
-
- zspan.zmulx= ((float)size)/2.0f;
- zspan.zmuly= ((float)size)/2.0f;
- zspan.zofsx= -0.5f;
- zspan.zofsy= -0.5f;
-
- /* pass on bsp root to zspan */
- zspan.rectz= (int *)root;
-
- /* filling methods */
- zspanstrand= zspan;
- // zspan.zbuflinefunc= zbufline_onlyZ;
- zspan.zbuffunc= isb_bsp_test_face;
- zspanstrand.zbuffunc= isb_bsp_test_strand;
-
- for (i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) {
- obr= obi->obr;
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(winmat, shb->persmat, obi->mat);
- else
- copy_m4_m4(winmat, shb->persmat);
-
- for (a=0; a<obr->totvlak; a++) {
-
- if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
- else vlr++;
-
- /* note, these conditions are copied in shadowbuf_autoclip() */
- if (vlr->mat!= ma) {
- ma= vlr->mat;
- ok= 1;
- if ((ma->mode2 & MA_CASTSHADOW)==0 || (ma->mode & MA_SHADBUF)==0) ok= 0;
- if (ma->material_type == MA_TYPE_WIRE) ok= 0;
- zspanstrand.shad_alpha= zspan.shad_alpha= ma->shad_alpha;
- }
-
- if (ok && (obi->lay & lay)) {
- float hoco[4][4];
- int c1, c2, c3, c4=0;
- int d1, d2, d3, d4=0;
- int partclip;
-
- /* create hocos per face, it is while render */
- projectvert(vlr->v1->co, winmat, hoco[0]); d1= testclip_minmax(hoco[0], minmaxf);
- projectvert(vlr->v2->co, winmat, hoco[1]); d2= testclip_minmax(hoco[1], minmaxf);
- projectvert(vlr->v3->co, winmat, hoco[2]); d3= testclip_minmax(hoco[2], minmaxf);
- if (vlr->v4) {
- projectvert(vlr->v4->co, winmat, hoco[3]); d4= testclip_minmax(hoco[3], minmaxf);
- }
-
- /* minmax clipping */
- if (vlr->v4) partclip= d1 & d2 & d3 & d4;
- else partclip= d1 & d2 & d3;
-
- if (partclip==0) {
-
- /* window clipping */
- c1= testclip(hoco[0]);
- c2= testclip(hoco[1]);
- c3= testclip(hoco[2]);
- if (vlr->v4)
- c4= testclip(hoco[3]);
-
- /* ***** NO WIRE YET */
- if (ma->material_type == MA_TYPE_WIRE) {
- if (vlr->v4)
- zbufclipwire(&zspan, i, a+1, vlr->ec, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4);
- else
- zbufclipwire(&zspan, i, a+1, vlr->ec, hoco[0], hoco[1], hoco[2], NULL, c1, c2, c3, 0);
- }
- else if (vlr->v4) {
- if (vlr->flag & R_STRAND)
- zbufclip4(&zspanstrand, i, a+1, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4);
- else
- zbufclip4(&zspan, i, a+1, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4);
- }
- else
- zbufclip(&zspan, i, a+1, hoco[0], hoco[1], hoco[2], c1, c2, c3);
-
- }
- }
- }
- }
-
- zbuf_free_span(&zspan);
-}
-
-/* returns 1 when the viewpixel is visible in lampbuffer */
-static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *vlr, float x, float y, float co_r[3])
-{
- float hoco[4], v1[3], nor[3];
- float dface, fac, siz;
-
- RE_vlakren_get_normal(&R, obi, vlr, nor);
- copy_v3_v3(v1, vlr->v1->co);
- if (obi->flag & R_TRANSFORMED)
- mul_m4_v3(obi->mat, v1);
-
- /* from shadepixel() */
- dface = dot_v3v3(v1, nor);
- hoco[3]= 1.0f;
-
- /* ortho viewplane cannot intersect using view vector originating in (0, 0, 0) */
- if (R.r.mode & R_ORTHO) {
- /* x and y 3d coordinate can be derived from pixel coord and winmat */
- float fx= 2.0f/(R.winx*R.winmat[0][0]);
- float fy= 2.0f/(R.winy*R.winmat[1][1]);
-
- hoco[0]= (x - 0.5f*R.winx)*fx - R.winmat[3][0]/R.winmat[0][0];
- hoco[1]= (y - 0.5f*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1];
-
- /* using a*x + b*y + c*z = d equation, (a b c) is normal */
- if (nor[2]!=0.0f)
- hoco[2]= (dface - nor[0]*hoco[0] - nor[1]*hoco[1])/nor[2];
- else
- hoco[2]= 0.0f;
- }
- else {
- float div, view[3];
-
- calc_view_vector(view, x, y);
-
- div = dot_v3v3(nor, view);
- if (div==0.0f)
- return 0;
-
- fac= dface/div;
-
- hoco[0]= fac*view[0];
- hoco[1]= fac*view[1];
- hoco[2]= fac*view[2];
- }
-
- /* move 3d vector to lampbuf */
- mul_m4_v4(shb->persmat, hoco); /* rational hom co */
-
- /* clip We can test for -1.0/1.0 because of the properties of the
- * coordinate transformations. */
- fac = fabsf(hoco[3]);
- if (hoco[0]<-fac || hoco[0]>fac)
- return 0;
- if (hoco[1]<-fac || hoco[1]>fac)
- return 0;
- if (hoco[2]<-fac || hoco[2]>fac)
- return 0;
-
- siz= 0.5f*(float)shb->size;
- co_r[0]= siz*(1.0f+hoco[0]/hoco[3]) -0.5f;
- co_r[1]= siz*(1.0f+hoco[1]/hoco[3]) -0.5f;
- co_r[2]= ((float)0x7FFFFFFF)*(hoco[2]/hoco[3]);
-
- /* XXXX bias, much less than normal shadbuf, or do we need a constant? */
- co_r[2] -= 0.05f*shb->bias;
-
- return 1;
-}
-
-/* storage of shadow results, solid osa and transp case */
-static void isb_add_shadfac(ISBShadfacA **isbsapp, MemArena *mem, int obi, int facenr, short shadfac, short samples)
-{
- ISBShadfacA *new;
- float shadfacf;
-
- /* in osa case, the samples were filled in with factor 1.0/R.osa. if fewer samples we have to correct */
- if (R.osa)
- shadfacf= ((float)shadfac*R.osa)/(4096.0f*samples);
- else
- shadfacf= ((float)shadfac)/(4096.0f);
-
- new= BLI_memarena_alloc(mem, sizeof(ISBShadfacA));
- new->obi= obi;
- new->facenr= facenr & ~RE_QUAD_OFFS;
- new->shadfac= shadfacf;
- if (*isbsapp)
- new->next= (*isbsapp);
- else
- new->next= NULL;
-
- *isbsapp= new;
-}
-
-/* adding samples, solid case */
-static int isb_add_samples(RenderPart *pa, ISBBranch *root, MemArena *memarena, ISBSample **samplebuf)
-{
- int xi, yi, *xcos, *ycos;
- int sample, bsp_err= 0;
-
- /* bsp split doesn't like to handle regular sequences */
- xcos= MEM_mallocN(pa->rectx*sizeof(int), "xcos");
- ycos= MEM_mallocN(pa->recty*sizeof(int), "ycos");
- for (xi=0; xi<pa->rectx; xi++)
- xcos[xi]= xi;
- for (yi=0; yi<pa->recty; yi++)
- ycos[yi]= yi;
- BLI_array_randomize(xcos, sizeof(int), pa->rectx, 12345);
- BLI_array_randomize(ycos, sizeof(int), pa->recty, 54321);
-
- for (sample=0; sample<(R.osa?R.osa:1); sample++) {
- ISBSample *samp= samplebuf[sample], *samp1;
-
- for (yi=0; yi<pa->recty; yi++) {
- int y= ycos[yi];
- for (xi=0; xi<pa->rectx; xi++) {
- int x= xcos[xi];
- samp1= samp + y*pa->rectx + x;
- if (samp1->facenr)
- bsp_err |= isb_bsp_insert(root, memarena, samp1);
- }
- if (bsp_err) break;
- }
- }
-
- MEM_freeN(xcos);
- MEM_freeN(ycos);
-
- return bsp_err;
-}
-
-/* solid version */
-/* lar->shb, pa->rectz and pa->rectp should exist */
-static void isb_make_buffer(RenderPart *pa, LampRen *lar)
-{
- ShadBuf *shb= lar->shb;
- ISBData *isbdata;
- ISBSample *samp, *samplebuf[16]; /* should be RE_MAX_OSA */
- ISBBranch root;
- MemArena *memarena;
- intptr_t *rd;
- int *recto, *rectp, x, y, sindex, sample, bsp_err=0;
-
- /* storage for shadow, per thread */
- isbdata= shb->isb_result[pa->thread];
-
- /* to map the shi->xs and ys coordinate */
- isbdata->minx= pa->disprect.xmin;
- isbdata->miny= pa->disprect.ymin;
- isbdata->rectx= pa->rectx;
- isbdata->recty= pa->recty;
-
- /* branches are added using memarena (32k branches) */
- memarena = BLI_memarena_new(0x8000 * sizeof(ISBBranch), "isb arena");
- BLI_memarena_use_calloc(memarena);
-
- /* samplebuf is in camera view space (pixels) */
- for (sample=0; sample<(R.osa?R.osa:1); sample++)
- samplebuf[sample]= MEM_callocN(sizeof(ISBSample)*pa->rectx*pa->recty, "isb samplebuf");
-
- /* for end result, ISBSamples point to this in non OSA case, otherwise to pixstruct->shadfac */
- if (R.osa==0)
- isbdata->shadfacs= MEM_callocN(pa->rectx*pa->recty*sizeof(short), "isb shadfacs");
-
- /* setup bsp root */
- memset(&root, 0, sizeof(ISBBranch));
- root.box.xmin = (float)shb->size;
- root.box.ymin = (float)shb->size;
-
- /* create the sample buffers */
- for (sindex=0, y=0; y<pa->recty; y++) {
- for (x=0; x<pa->rectx; x++, sindex++) {
-
- /* this makes it a long function, but splitting it out would mean 10+ arguments */
- /* first check OSA case */
- if (R.osa) {
- rd= pa->rectdaps + sindex;
- if (*rd) {
- float xs= (float)(x + pa->disprect.xmin);
- float ys= (float)(y + pa->disprect.ymin);
-
- for (sample=0; sample<R.osa; sample++) {
- PixStr *ps= (PixStr *)(*rd);
- int mask= (1<<sample);
-
- while (ps) {
- if (ps->mask & mask)
- break;
- ps= ps->next;
- }
- if (ps && ps->facenr>0) {
- ObjectInstanceRen *obi= &R.objectinstance[ps->obi];
- ObjectRen *obr= obi->obr;
- VlakRen *vlr= RE_findOrAddVlak(obr, (ps->facenr-1) & RE_QUAD_MASK);
-
- samp= samplebuf[sample] + sindex;
- /* convert image plane pixel location to lamp buffer space */
- if (viewpixel_to_lampbuf(shb, obi, vlr, xs + R.jit[sample][0], ys + R.jit[sample][1], samp->zco)) {
- samp->obi= ps->obi;
- samp->facenr= ps->facenr & ~RE_QUAD_OFFS;
- ps->shadfac= 0;
- samp->shadfac= &ps->shadfac;
- bound_rectf((rctf *)&root.box, samp->zco);
- }
- }
- }
- }
- }
- else {
- rectp= pa->rectp + sindex;
- recto= pa->recto + sindex;
- if (*rectp>0) {
- ObjectInstanceRen *obi= &R.objectinstance[*recto];
- ObjectRen *obr= obi->obr;
- VlakRen *vlr= RE_findOrAddVlak(obr, (*rectp-1) & RE_QUAD_MASK);
- float xs= (float)(x + pa->disprect.xmin);
- float ys= (float)(y + pa->disprect.ymin);
-
- samp= samplebuf[0] + sindex;
- /* convert image plane pixel location to lamp buffer space */
- if (viewpixel_to_lampbuf(shb, obi, vlr, xs, ys, samp->zco)) {
- samp->obi= *recto;
- samp->facenr= *rectp & ~RE_QUAD_OFFS;
- samp->shadfac= isbdata->shadfacs + sindex;
- bound_rectf((rctf *)&root.box, samp->zco);
- }
- }
- }
- }
- }
-
- /* simple method to see if we have samples */
- if (root.box.xmin != (float)shb->size) {
- /* now create a regular split, root.box has the initial bounding box of all pixels */
- /* split bsp 8 levels deep, in regular grid (16 x 16) */
- isb_bsp_split_init(&root, memarena, 8);
-
- /* insert all samples in BSP now */
- bsp_err= isb_add_samples(pa, &root, memarena, samplebuf);
-
- if (bsp_err==0) {
- /* go over all faces and fill in shadow values */
-
- isb_bsp_fillfaces(&R, lar, &root); /* shb->persmat should have been calculated */
-
- /* copy shadow samples to persistent buffer, reduce memory overhead */
- if (R.osa) {
- ISBShadfacA **isbsa= isbdata->shadfaca= MEM_callocN(pa->rectx*pa->recty*sizeof(void *), "isb shadfacs");
-
- isbdata->memarena = BLI_memarena_new(0x8000 * sizeof(ISBSampleA), "isb arena");
- BLI_memarena_use_calloc(isbdata->memarena);
-
- for (rd= pa->rectdaps, x=pa->rectx*pa->recty; x>0; x--, rd++, isbsa++) {
-
- if (*rd) {
- PixStr *ps= (PixStr *)(*rd);
- while (ps) {
- if (ps->shadfac)
- isb_add_shadfac(isbsa, isbdata->memarena, ps->obi, ps->facenr, ps->shadfac, count_mask(ps->mask));
- ps= ps->next;
- }
- }
- }
- }
- }
- }
- else {
- if (isbdata->shadfacs) {
- MEM_freeN(isbdata->shadfacs);
- isbdata->shadfacs= NULL;
- }
- }
-
- /* free BSP */
- BLI_memarena_free(memarena);
-
- /* free samples */
- for (x=0; x<(R.osa?R.osa:1); x++)
- MEM_freeN(samplebuf[x]);
-
- if (bsp_err) printf("error in filling bsp\n");
-}
-
-/* add sample to buffer, isbsa is the root sample in a buffer */
-static ISBSampleA *isb_alloc_sample_transp(ISBSampleA **isbsa, MemArena *mem)
-{
- ISBSampleA *new;
-
- new= BLI_memarena_alloc(mem, sizeof(ISBSampleA));
- if (*isbsa)
- new->next= (*isbsa);
- else
- new->next= NULL;
-
- *isbsa= new;
- return new;
-}
-
-/* adding samples in BSP, transparent case */
-static int isb_add_samples_transp(RenderPart *pa, ISBBranch *root, MemArena *memarena, ISBSampleA ***samplebuf)
-{
- int xi, yi, *xcos, *ycos;
- int sample, bsp_err= 0;
-
- /* bsp split doesn't like to handle regular sequences */
- xcos= MEM_mallocN(pa->rectx*sizeof(int), "xcos");
- ycos= MEM_mallocN(pa->recty*sizeof(int), "ycos");
- for (xi=0; xi<pa->rectx; xi++)
- xcos[xi]= xi;
- for (yi=0; yi<pa->recty; yi++)
- ycos[yi]= yi;
- BLI_array_randomize(xcos, sizeof(int), pa->rectx, 12345);
- BLI_array_randomize(ycos, sizeof(int), pa->recty, 54321);
-
- for (sample=0; sample<(R.osa?R.osa:1); sample++) {
- ISBSampleA **samp= samplebuf[sample], *samp1;
-
- for (yi=0; yi<pa->recty; yi++) {
- int y= ycos[yi];
- for (xi=0; xi<pa->rectx; xi++) {
- int x= xcos[xi];
-
- samp1= *(samp + y*pa->rectx + x);
- while (samp1) {
- bsp_err |= isb_bsp_insert(root, memarena, (ISBSample *)samp1);
- samp1= samp1->next;
- }
- }
- if (bsp_err) break;
- }
- }
-
- MEM_freeN(xcos);
- MEM_freeN(ycos);
-
- return bsp_err;
-}
-
-
-/* Ztransp version */
-/* lar->shb, pa->rectz and pa->rectp should exist */
-static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *lar)
-{
- ShadBuf *shb= lar->shb;
- ISBData *isbdata;
- ISBSampleA *samp, **samplebuf[16]; /* MAX_OSA */
- ISBBranch root;
- MemArena *memarena;
- APixstr *ap;
- int x, y, sindex, sample, bsp_err=0;
-
- /* storage for shadow, per thread */
- isbdata= shb->isb_result[pa->thread];
-
- /* to map the shi->xs and ys coordinate */
- isbdata->minx= pa->disprect.xmin;
- isbdata->miny= pa->disprect.ymin;
- isbdata->rectx= pa->rectx;
- isbdata->recty= pa->recty;
-
- /* branches are added using memarena (32k branches) */
- memarena = BLI_memarena_new(0x8000 * sizeof(ISBBranch), "isb arena");
- BLI_memarena_use_calloc(memarena);
-
- /* samplebuf is in camera view space (pixels) */
- for (sample=0; sample<(R.osa?R.osa:1); sample++)
- samplebuf[sample]= MEM_callocN(sizeof(void *)*pa->rectx*pa->recty, "isb alpha samplebuf");
-
- /* setup bsp root */
- memset(&root, 0, sizeof(ISBBranch));
- root.box.xmin = (float)shb->size;
- root.box.ymin = (float)shb->size;
-
- /* create the sample buffers */
- for (ap= apixbuf, sindex=0, y=0; y<pa->recty; y++) {
- for (x=0; x<pa->rectx; x++, sindex++, ap++) {
-
- if (ap->p[0]) {
- APixstr *apn;
- float xs= (float)(x + pa->disprect.xmin);
- float ys= (float)(y + pa->disprect.ymin);
-
- for (apn=ap; apn; apn= apn->next) {
- int a;
- for (a=0; a<4; a++) {
- if (apn->p[a]) {
- ObjectInstanceRen *obi= &R.objectinstance[apn->obi[a]];
- ObjectRen *obr= obi->obr;
- VlakRen *vlr= RE_findOrAddVlak(obr, (apn->p[a]-1) & RE_QUAD_MASK);
- float zco[3];
-
- /* here we store shadfac, easier to create the end storage buffer. needs zero'ed, multiple shadowbufs use it */
- apn->shadfac[a]= 0;
-
- if (R.osa) {
- for (sample=0; sample<R.osa; sample++) {
- int mask= (1<<sample);
-
- if (apn->mask[a] & mask) {
-
- /* convert image plane pixel location to lamp buffer space */
- if (viewpixel_to_lampbuf(shb, obi, vlr, xs + R.jit[sample][0], ys + R.jit[sample][1], zco)) {
- samp= isb_alloc_sample_transp(samplebuf[sample] + sindex, memarena);
- samp->obi= apn->obi[a];
- samp->facenr= apn->p[a] & ~RE_QUAD_OFFS;
- samp->shadfac= &apn->shadfac[a];
-
- copy_v3_v3(samp->zco, zco);
- bound_rectf((rctf *)&root.box, samp->zco);
- }
- }
- }
- }
- else {
-
- /* convert image plane pixel location to lamp buffer space */
- if (viewpixel_to_lampbuf(shb, obi, vlr, xs, ys, zco)) {
-
- samp= isb_alloc_sample_transp(samplebuf[0] + sindex, memarena);
- samp->obi= apn->obi[a];
- samp->facenr= apn->p[a] & ~RE_QUAD_OFFS;
- samp->shadfac= &apn->shadfac[a];
-
- copy_v3_v3(samp->zco, zco);
- bound_rectf((rctf *)&root.box, samp->zco);
- }
- }
- }
- }
- }
- }
- }
- }
-
- /* simple method to see if we have samples */
- if (root.box.xmin != (float)shb->size) {
- /* now create a regular split, root.box has the initial bounding box of all pixels */
- /* split bsp 8 levels deep, in regular grid (16 x 16) */
- isb_bsp_split_init(&root, memarena, 8);
-
- /* insert all samples in BSP now */
- bsp_err= isb_add_samples_transp(pa, &root, memarena, samplebuf);
-
- if (bsp_err==0) {
- ISBShadfacA **isbsa;
-
- /* go over all faces and fill in shadow values */
- isb_bsp_fillfaces(&R, lar, &root); /* shb->persmat should have been calculated */
-
- /* copy shadow samples to persistent buffer, reduce memory overhead */
- isbsa= isbdata->shadfaca= MEM_callocN(pa->rectx*pa->recty*sizeof(void *), "isb shadfacs");
-
- isbdata->memarena = BLI_memarena_new(0x8000 * sizeof(ISBSampleA), "isb arena");
-
- for (ap= apixbuf, x=pa->rectx*pa->recty; x>0; x--, ap++, isbsa++) {
-
- if (ap->p[0]) {
- APixstr *apn;
- for (apn=ap; apn; apn= apn->next) {
- int a;
- for (a=0; a<4; a++) {
- if (apn->p[a] && apn->shadfac[a]) {
- if (R.osa)
- isb_add_shadfac(isbsa, isbdata->memarena, apn->obi[a], apn->p[a], apn->shadfac[a], count_mask(apn->mask[a]));
- else
- isb_add_shadfac(isbsa, isbdata->memarena, apn->obi[a], apn->p[a], apn->shadfac[a], 0);
- }
- }
- }
- }
- }
- }
- }
-
- /* free BSP */
- BLI_memarena_free(memarena);
-
- /* free samples */
- for (x=0; x<(R.osa?R.osa:1); x++)
- MEM_freeN(samplebuf[x]);
-
- if (bsp_err) printf("error in filling bsp\n");
-}
-
-
-
-/* exported */
-
-/* returns amount of light (1.0 = no shadow) */
-/* note, shadepixel() rounds the coordinate, not the real sample info */
-float ISB_getshadow(ShadeInput *shi, ShadBuf *shb)
-{
- /* if raytracing, we can't accept irregular shadow */
- if (shi->depth==0) {
- ISBData *isbdata= shb->isb_result[shi->thread];
-
- if (isbdata) {
- if (isbdata->shadfacs || isbdata->shadfaca) {
- int x= shi->xs - isbdata->minx;
-
- if (x >= 0 && x < isbdata->rectx) {
- int y= shi->ys - isbdata->miny;
-
- if (y >= 0 && y < isbdata->recty) {
- if (isbdata->shadfacs) {
- const short *sp= isbdata->shadfacs + y*isbdata->rectx + x;
- return *sp>=4096?0.0f:1.0f - ((float)*sp)/4096.0f;
- }
- else {
- int sindex= y*isbdata->rectx + x;
- int obi= shi->obi - R.objectinstance;
- ISBShadfacA *isbsa= *(isbdata->shadfaca + sindex);
-
- while (isbsa) {
- if (isbsa->facenr==shi->facenr+1 && isbsa->obi==obi)
- return isbsa->shadfac>=1.0f?0.0f:1.0f - isbsa->shadfac;
- isbsa= isbsa->next;
- }
- }
- }
- }
- }
- }
- }
- return 1.0f;
-}
-
-/* part is supposed to be solid zbuffered (apixbuf==NULL) or transparent zbuffered */
-void ISB_create(RenderPart *pa, APixstr *apixbuf)
-{
- GroupObject *go;
-
- /* go over all lamps, and make the irregular buffers */
- for (go=R.lights.first; go; go= go->next) {
- LampRen *lar= go->lampren;
-
- if (lar->type==LA_SPOT && lar->shb && lar->buftype==LA_SHADBUF_IRREGULAR) {
-
- /* create storage for shadow, per thread */
- lar->shb->isb_result[pa->thread]= MEM_callocN(sizeof(ISBData), "isb data");
-
- if (apixbuf)
- isb_make_buffer_transp(pa, apixbuf, lar);
- else
- isb_make_buffer(pa, lar);
- }
- }
-}
-
-
-/* end of part rendering, free stored shadow data for this thread from all lamps */
-void ISB_free(RenderPart *pa)
-{
- GroupObject *go;
-
- /* go over all lamps, and free the irregular buffers */
- for (go=R.lights.first; go; go= go->next) {
- LampRen *lar= go->lampren;
-
- if (lar->type==LA_SPOT && lar->shb && lar->buftype==LA_SHADBUF_IRREGULAR) {
- ISBData *isbdata= lar->shb->isb_result[pa->thread];
-
- if (isbdata) {
- if (isbdata->shadfacs)
- MEM_freeN(isbdata->shadfacs);
- if (isbdata->shadfaca)
- MEM_freeN(isbdata->shadfaca);
-
- if (isbdata->memarena)
- BLI_memarena_free(isbdata->memarena);
-
- MEM_freeN(isbdata);
- lar->shb->isb_result[pa->thread]= NULL;
- }
- }
- }
-}
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
deleted file mode 100644
index 6cad37c3e78..00000000000
--- a/source/blender/render/intern/source/shadeinput.c
+++ /dev/null
@@ -1,1451 +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) 2006 Blender Foundation
- * All rights reserved.
- *
- * Contributors: Hos, Robert Wenzlaff.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/shadeinput.c
- * \ingroup render
- */
-
-
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "DNA_lamp_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_material_types.h"
-#include "DNA_particle_types.h"
-
-#include "BKE_scene.h"
-
-#include "BKE_node.h"
-
-/* local include */
-#include "raycounter.h"
-#include "render_types.h"
-#include "renderdatabase.h"
-#include "rendercore.h"
-#include "shading.h"
-#include "strand.h"
-#include "texture.h"
-#include "volumetric.h"
-#include "zbuf.h"
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-/* Shade Sample order:
- *
- * - shade_samples_fill_with_ps()
- * - for each sample
- * - shade_input_set_triangle() <- if prev sample-face is same, use shade_input_copy_triangle()
- * - if vlr
- * - shade_input_set_viewco() <- not for ray or bake
- * - shade_input_set_uv() <- not for ray or bake
- * - shade_input_set_normals()
- * - shade_samples()
- * - if AO
- * - shade_samples_do_AO()
- * - if shading happens
- * - for each sample
- * - shade_input_set_shade_texco()
- * - shade_samples_do_shade()
- * - OSA: distribute sample result with filter masking
- *
- */
-
-/* initialize material variables in shadeinput,
- * doing inverse gamma correction where applicable */
-void shade_input_init_material(ShadeInput *shi)
-{
- /* note, keep this synced with render_types.h */
- memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float));
- shi->har = shi->mat->har;
-}
-
-/* also used as callback for nodes */
-/* delivers a fully filled in ShadeResult, for all passes */
-void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
-{
-
- shade_lamp_loop(shi, shr); /* clears shr */
-
- if (shi->translucency != 0.0f) {
- ShadeResult shr_t;
- float fac = shi->translucency;
-
- shade_input_init_material(shi);
- negate_v3_v3(shi->vn, shi->vno);
- negate_v3(shi->facenor);
- shi->depth++; /* hack to get real shadow now */
- shade_lamp_loop(shi, &shr_t);
- shi->depth--;
-
- /* a couple of passes */
- madd_v3_v3fl(shr->combined, shr_t.combined, fac);
- if (shi->passflag & SCE_PASS_SPEC)
- madd_v3_v3fl(shr->spec, shr_t.spec, fac);
- if (shi->passflag & SCE_PASS_DIFFUSE) {
- madd_v3_v3fl(shr->diff, shr_t.diff, fac);
- madd_v3_v3fl(shr->diffshad, shr_t.diffshad, fac);
- }
- if (shi->passflag & SCE_PASS_SHADOW)
- madd_v3_v3fl(shr->shad, shr_t.shad, fac);
-
- negate_v3(shi->vn);
- negate_v3(shi->facenor);
- }
-
- /* depth >= 1 when ray-shading */
- if (shi->depth == 0 || shi->volume_depth > 0) {
- if (R.r.mode & R_RAYTRACE) {
- if (shi->ray_mirror != 0.0f || ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha != 1.0f)) {
- /* ray trace works on combined, but gives pass info */
- ray_trace(shi, shr);
- }
- }
- /* disable adding of sky for raytransp */
- if ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP))
- if ((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode == R_ADDSKY))
- shr->alpha = 1.0f;
- }
-
- if (R.r.mode & R_RAYTRACE) {
- if (R.render_volumes_inside.first)
- shade_volume_inside(shi, shr);
- }
-}
-
-
-/* do a shade, finish up some passes, apply mist */
-void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr)
-{
- bool compat = false;
- float alpha;
-
- /* ------ main shading loop -------- */
-#ifdef RE_RAYCOUNTER
- memset(&shi->raycounter, 0, sizeof(shi->raycounter));
-#endif
-
- if (shi->mat->nodetree && shi->mat->use_nodes) {
- compat = ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
- }
-
- /* also run this when node shaders fail, due to incompatible shader nodes */
- if (compat == false) {
- /* copy all relevant material vars, note, keep this synced with render_types.h */
- shade_input_init_material(shi);
-
- if (shi->mat->material_type == MA_TYPE_VOLUME) {
- if (R.r.mode & R_RAYTRACE) {
- shade_volume_outside(shi, shr);
- }
- }
- else { /* MA_TYPE_SURFACE, MA_TYPE_WIRE */
- shade_material_loop(shi, shr);
- }
- }
-
- /* copy additional passes */
- if (shi->passflag & (SCE_PASS_VECTOR | SCE_PASS_NORMAL)) {
- copy_v4_v4(shr->winspeed, shi->winspeed);
- copy_v3_v3(shr->nor, shi->vn);
- }
-
- /* MIST */
- if ((shi->passflag & SCE_PASS_MIST) || ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST) == 0)) {
- if (R.r.mode & R_ORTHO)
- shr->mist = mistfactor(-shi->co[2], shi->co);
- else
- shr->mist = mistfactor(len_v3(shi->co), shi->co);
- }
- else shr->mist = 0.0f;
-
- if ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST) == 0) {
- alpha = shr->mist;
- }
- else alpha = 1.0f;
-
- /* add mist and premul color */
- if (shr->alpha != 1.0f || alpha != 1.0f) {
- float fac = alpha * (shr->alpha);
- shr->combined[3] = fac;
-
- if (shi->mat->material_type != MA_TYPE_VOLUME)
- mul_v3_fl(shr->combined, fac);
- }
- else
- shr->combined[3] = 1.0f;
-
- /* add z */
- shr->z = -shi->co[2];
-
- /* RAYHITS */
-#if 0
- if (1 || shi->passflag & SCE_PASS_RAYHITS) {
- shr->rayhits[0] = (float)shi->raycounter.faces.test;
- shr->rayhits[1] = (float)shi->raycounter.bb.hit;
- shr->rayhits[2] = 0.0;
- shr->rayhits[3] = 1.0;
- }
-#endif
-
- RE_RC_MERGE(&re_rc_counter[shi->thread], &shi->raycounter);
-}
-
-/* **************************************************************************** */
-/* ShadeInput */
-/* **************************************************************************** */
-
-
-void vlr_set_uv_indices(VlakRen *vlr, int *i1, int *i2, int *i3)
-{
- /* to prevent storing new tfaces or vcols, we check a split runtime */
- /* 4---3 4---3 */
- /* |\ 1| or |1 /| */
- /* |0\ | |/ 0| */
- /* 1---2 1---2 0 = orig face, 1 = new face */
-
- /* Update vert nums to point to correct verts of original face */
- if (vlr->flag & R_DIVIDE_24) {
- if (vlr->flag & R_FACE_SPLIT) {
- (*i1)++; (*i2)++; (*i3)++;
- }
- else {
- (*i3)++;
- }
- }
- else if (vlr->flag & R_FACE_SPLIT) {
- (*i2)++; (*i3)++;
- }
-}
-
-/* copy data from face to ShadeInput, general case */
-/* indices 0 1 2 3 only */
-void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen *vlr, short i1, short i2, short i3)
-{
- VertRen **vpp = &vlr->v1;
-
- shi->vlr = vlr;
- shi->obi = obi;
- shi->obr = obi->obr;
-
- shi->v1 = vpp[i1];
- shi->v2 = vpp[i2];
- shi->v3 = vpp[i3];
-
- shi->i1 = i1;
- shi->i2 = i2;
- shi->i3 = i3;
-
- /* note, shi->mat is set in node shaders */
- shi->mat = vlr->mat;
-
- shi->osatex = (shi->mat->texco & TEXCO_OSA);
- shi->mode = shi->mat->mode_l; /* or-ed result for all nodes */
- shi->mode2 = shi->mat->mode2_l;
-
- /* facenormal copy, can get flipped */
- shi->flippednor = 0;
- RE_vlakren_get_normal(&R, obi, vlr, shi->facenor);
-
- /* calculate vertexnormals */
- if (vlr->flag & R_SMOOTH) {
- copy_v3_v3(shi->n1, shi->v1->n);
- copy_v3_v3(shi->n2, shi->v2->n);
- copy_v3_v3(shi->n3, shi->v3->n);
-
- if (obi->flag & R_TRANSFORMED) {
- mul_m3_v3(obi->nmat, shi->n1); normalize_v3(shi->n1);
- mul_m3_v3(obi->nmat, shi->n2); normalize_v3(shi->n2);
- mul_m3_v3(obi->nmat, shi->n3); normalize_v3(shi->n3);
- }
- }
-}
-
-/* copy data from face to ShadeInput, scanline case */
-void shade_input_set_triangle(ShadeInput *shi, int obi, int facenr, int UNUSED(normal_flip))
-{
- if (facenr > 0) {
- shi->obi = &R.objectinstance[obi];
- shi->obr = shi->obi->obr;
- shi->facenr = (facenr - 1) & RE_QUAD_MASK;
- if (shi->facenr < shi->obr->totvlak) {
- VlakRen *vlr = RE_findOrAddVlak(shi->obr, shi->facenr);
-
- if (facenr & RE_QUAD_OFFS)
- shade_input_set_triangle_i(shi, shi->obi, vlr, 0, 2, 3);
- else
- shade_input_set_triangle_i(shi, shi->obi, vlr, 0, 1, 2);
- }
- else
- shi->vlr = NULL; /* general signal we got sky */
- }
- else
- shi->vlr = NULL; /* general signal we got sky */
-}
-
-/* full osa case: copy static info */
-void shade_input_copy_triangle(ShadeInput *shi, ShadeInput *from)
-{
- /* not so nice, but works... warning is in RE_shader_ext.h */
- memcpy(shi, from, sizeof(struct ShadeInputCopy));
-}
-
-/* copy data from strand to shadeinput */
-void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spoint)
-{
- /* note, shi->mat is set in node shaders */
- shi->mat = strand->buffer->ma;
-
- shi->osatex = (shi->mat->texco & TEXCO_OSA);
- shi->mode = shi->mat->mode_l; /* or-ed result for all nodes */
-
- /* shade_input_set_viewco equivalent */
- copy_v3_v3(shi->co, spoint->co);
- copy_v3_v3(shi->view, shi->co);
- normalize_v3(shi->view);
-
- shi->xs = (int)spoint->x;
- shi->ys = (int)spoint->y;
-
- if (shi->osatex || (R.r.mode & R_SHADOW)) {
- copy_v3_v3(shi->dxco, spoint->dtco);
- copy_v3_v3(shi->dyco, spoint->dsco);
- }
-
- /* dxview, dyview, not supported */
-
- /* facenormal, simply viewco flipped */
- copy_v3_v3(shi->facenor, spoint->nor);
-
- /* shade_input_set_normals equivalent */
- if (shi->mat->mode & MA_TANGENT_STR) {
- copy_v3_v3(shi->vn, spoint->tan);
- }
- else {
- float cross[3];
-
- cross_v3_v3v3(cross, spoint->co, spoint->tan);
- cross_v3_v3v3(shi->vn, cross, spoint->tan);
- normalize_v3(shi->vn);
-
- if (dot_v3v3(shi->vn, shi->view) < 0.0f)
- negate_v3(shi->vn);
- }
-
- copy_v3_v3(shi->vno, shi->vn);
-}
-
-void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert *svert, StrandPoint *spoint)
-{
- StrandBuffer *strandbuf = strand->buffer;
- ObjectRen *obr = strandbuf->obr;
- StrandVert *sv;
- int mode = shi->mode; /* or-ed result for all nodes */
- short texco = shi->mat->texco;
-
- if ((shi->mat->texco & TEXCO_REFL)) {
- /* shi->dxview, shi->dyview, not supported */
- }
-
- if (shi->osatex && (texco & (TEXCO_NORM | TEXCO_REFL))) {
- /* not supported */
- }
-
- if (mode & (MA_TANGENT_V | MA_NORMAP_TANG)) {
- copy_v3_v3(shi->tang, spoint->tan);
- copy_v3_v3(shi->nmaptang, spoint->tan);
- }
-
- if (mode & MA_STR_SURFDIFF) {
- const float *surfnor = RE_strandren_get_surfnor(obr, strand, 0);
-
- if (surfnor)
- copy_v3_v3(shi->surfnor, surfnor);
- else
- copy_v3_v3(shi->surfnor, shi->vn);
-
- if (shi->mat->strand_surfnor > 0.0f) {
- shi->surfdist = 0.0f;
- for (sv = strand->vert; sv != svert; sv++)
- shi->surfdist += len_v3v3(sv->co, (sv + 1)->co);
- shi->surfdist += spoint->t * len_v3v3(sv->co, (sv + 1)->co);
- }
- }
-
- if (R.r.mode & R_SPEED) {
- const float *speed;
-
- speed = RE_strandren_get_winspeed(shi->obi, strand, 0);
- if (speed)
- copy_v4_v4(shi->winspeed, speed);
- else
- shi->winspeed[0] = shi->winspeed[1] = shi->winspeed[2] = shi->winspeed[3] = 0.0f;
- }
-
- /* shade_input_set_shade_texco equivalent */
- if (texco & NEED_UV) {
- if (texco & TEXCO_ORCO) {
- copy_v3_v3(shi->lo, strand->orco);
- /* no shi->osatex, orco derivatives are zero */
- }
-
- if (texco & TEXCO_GLOB) {
- mul_v3_m4v3(shi->gl, R.viewinv, shi->co);
-
- if (shi->osatex) {
- mul_v3_mat3_m4v3(shi->dxgl, R.viewinv, shi->dxco);
- mul_v3_mat3_m4v3(shi->dygl, R.viewinv, shi->dyco);
- }
- }
-
- if (texco & TEXCO_STRAND) {
- shi->strandco = spoint->strandco;
-
- if (shi->osatex) {
- shi->dxstrand = spoint->dtstrandco;
- shi->dystrand = 0.0f;
- }
- }
-
- if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP))) {
- MCol *mcol;
- const float *uv;
- char *name;
- int i;
-
- shi->totuv = 0;
- shi->totcol = 0;
- shi->actuv = obr->actmtface;
- shi->actcol = obr->actmcol;
-
- if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) {
- for (i = 0; (mcol = RE_strandren_get_mcol(obr, strand, i, &name, 0)); i++) {
- ShadeInputCol *scol = &shi->col[i];
- const char *cp = (char *)mcol;
-
- shi->totcol++;
- scol->name = name;
-
- scol->col[0] = cp[3] / 255.0f;
- scol->col[1] = cp[2] / 255.0f;
- scol->col[2] = cp[1] / 255.0f;
- scol->col[3] = cp[0] / 255.0f;
- }
-
- if (shi->totcol) {
- shi->vcol[0] = shi->col[shi->actcol].col[0];
- shi->vcol[1] = shi->col[shi->actcol].col[1];
- shi->vcol[2] = shi->col[shi->actcol].col[2];
- shi->vcol[3] = shi->col[shi->actcol].col[3];
- }
- else {
- shi->vcol[0] = 0.0f;
- shi->vcol[1] = 0.0f;
- shi->vcol[2] = 0.0f;
- shi->vcol[3] = 0.0f;
- }
- }
-
- for (i = 0; (uv = RE_strandren_get_uv(obr, strand, i, &name, 0)); i++) {
- ShadeInputUV *suv = &shi->uv[i];
-
- shi->totuv++;
- suv->name = name;
-
- if (strandbuf->overrideuv == i) {
- suv->uv[0] = -1.0f;
- suv->uv[1] = spoint->strandco;
- suv->uv[2] = 0.0f;
- }
- else {
- suv->uv[0] = -1.0f + 2.0f * uv[0];
- suv->uv[1] = -1.0f + 2.0f * uv[1];
- suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */
- }
-
- if (shi->osatex) {
- suv->dxuv[0] = 0.0f;
- suv->dxuv[1] = 0.0f;
- suv->dyuv[0] = 0.0f;
- suv->dyuv[1] = 0.0f;
- }
- }
-
- if (shi->totuv == 0) {
- ShadeInputUV *suv = &shi->uv[0];
-
- suv->uv[0] = 0.0f;
- suv->uv[1] = spoint->strandco;
- suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */
- }
-
- }
-
- if (texco & TEXCO_NORM) {
- shi->orn[0] = -shi->vn[0];
- shi->orn[1] = -shi->vn[1];
- shi->orn[2] = -shi->vn[2];
- }
-
- if (texco & TEXCO_STRESS) {
- /* not supported */
- }
-
- if (texco & TEXCO_TANGENT) {
- if ((mode & MA_TANGENT_V) == 0) {
- /* just prevent surprises */
- shi->tang[0] = shi->tang[1] = shi->tang[2] = 0.0f;
- shi->nmaptang[0] = shi->nmaptang[1] = shi->nmaptang[2] = 0.0f;
- }
- }
- }
-
- /* this only avalailable for scanline renders */
- if (shi->depth == 0) {
- if (texco & TEXCO_WINDOW) {
- shi->winco[0] = -1.0f + 2.0f * spoint->x / (float)R.winx;
- shi->winco[1] = -1.0f + 2.0f * spoint->y / (float)R.winy;
- shi->winco[2] = 0.0f;
-
- /* not supported */
- if (shi->osatex) {
- shi->dxwin[0] = 0.0f;
- shi->dywin[1] = 0.0f;
- shi->dxwin[0] = 0.0f;
- shi->dywin[1] = 0.0f;
- }
- }
- }
-
- if (shi->do_manage) {
- if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) {
- srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol);
- }
- }
-
-}
-
-/* from scanline pixel coordinates to 3d coordinates, requires set_triangle */
-void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float view[3], float dxyview[2], float co[3], float dxco[3], float dyco[3])
-{
- /* returns not normalized, so is in viewplane coords */
- calc_view_vector(view, x, y);
-
- if (shi->mat->material_type == MA_TYPE_WIRE) {
- /* wire cannot use normal for calculating shi->co, so
- * we reconstruct the coordinate less accurate */
- if (R.r.mode & R_ORTHO)
- calc_renderco_ortho(co, x, y, z);
- else
- calc_renderco_zbuf(co, view, z);
- }
- else {
- /* for non-wire, intersect with the triangle to get the exact coord */
- float fac, dface, v1[3];
-
- copy_v3_v3(v1, shi->v1->co);
- if (shi->obi->flag & R_TRANSFORMED)
- mul_m4_v3(shi->obi->mat, v1);
-
- dface = dot_v3v3(v1, shi->facenor);
-
- /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */
- if (R.r.mode & R_ORTHO) {
- /* x and y 3d coordinate can be derived from pixel coord and winmat */
- float fx = 2.0f / (R.winx * R.winmat[0][0]);
- float fy = 2.0f / (R.winy * R.winmat[1][1]);
-
- co[0] = (x - 0.5f * R.winx) * fx - R.winmat[3][0] / R.winmat[0][0];
- co[1] = (y - 0.5f * R.winy) * fy - R.winmat[3][1] / R.winmat[1][1];
-
- /* using a*x + b*y + c*z = d equation, (a b c) is normal */
- if (shi->facenor[2] != 0.0f)
- co[2] = (dface - shi->facenor[0] * co[0] - shi->facenor[1] * co[1]) / shi->facenor[2];
- else
- co[2] = 0.0f;
-
- if (dxco && dyco) {
- dxco[0] = fx;
- dxco[1] = 0.0f;
- if (shi->facenor[2] != 0.0f)
- dxco[2] = -(shi->facenor[0] * fx) / shi->facenor[2];
- else
- dxco[2] = 0.0f;
-
- dyco[0] = 0.0f;
- dyco[1] = fy;
- if (shi->facenor[2] != 0.0f)
- dyco[2] = -(shi->facenor[1] * fy) / shi->facenor[2];
- else
- dyco[2] = 0.0f;
-
- if (dxyview) {
- fac = (co[2] != 0.0f) ? (1.0f / co[2]) : 0.0f;
- dxyview[0] = -R.viewdx * fac;
- dxyview[1] = -R.viewdy * fac;
- }
- }
- }
- else {
- float div;
-
- div = dot_v3v3(shi->facenor, view);
- if (div != 0.0f) fac = dface / div;
- else fac = 0.0f;
-
- co[0] = fac * view[0];
- co[1] = fac * view[1];
- co[2] = fac * view[2];
-
- /* pixel dx/dy for render coord */
- if (dxco && dyco) {
- float u = dface / (div - R.viewdx * shi->facenor[0]);
- float v = dface / (div - R.viewdy * shi->facenor[1]);
-
- dxco[0] = co[0] - (view[0] - R.viewdx) * u;
- dxco[1] = co[1] - (view[1]) * u;
- dxco[2] = co[2] - (view[2]) * u;
-
- dyco[0] = co[0] - (view[0]) * v;
- dyco[1] = co[1] - (view[1] - R.viewdy) * v;
- dyco[2] = co[2] - (view[2]) * v;
-
- if (dxyview) {
- if (fac != 0.0f) fac = 1.0f / fac;
- dxyview[0] = -R.viewdx * fac;
- dxyview[1] = -R.viewdy * fac;
- }
- }
- }
- }
-
- /* set camera coords - for scanline, it's always 0.0,0.0,0.0 (render is in camera space)
- * however for raytrace it can be different - the position of the last intersection */
- shi->camera_co[0] = shi->camera_co[1] = shi->camera_co[2] = 0.0f;
-
- /* cannot normalize earlier, code above needs it at viewplane level */
- normalize_v3(view);
-}
-
-/* from scanline pixel coordinates to 3d coordinates, requires set_triangle */
-void shade_input_set_viewco(ShadeInput *shi, float x, float y, float xs, float ys, float z)
-{
- float *dxyview = NULL, *dxco = NULL, *dyco = NULL;
-
- /* currently in use for dithering (soft shadow), node preview, irregular shad */
- shi->xs = (int)xs;
- shi->ys = (int)ys;
-
- /* original scanline coordinate without jitter */
- shi->scanco[0] = x;
- shi->scanco[1] = y;
- shi->scanco[2] = z;
-
- /* check if we need derivatives */
- if (shi->osatex || (R.r.mode & R_SHADOW)) {
- dxco = shi->dxco;
- dyco = shi->dyco;
-
- if ((shi->mat->texco & TEXCO_REFL))
- dxyview = &shi->dxview;
- }
-
- shade_input_calc_viewco(shi, xs, ys, z, shi->view, dxyview, shi->co, dxco, dyco);
-}
-
-void barycentric_differentials_from_position(
- const float co[3], const float v1[3], const float v2[3], const float v3[3],
- const float dxco[3], const float dyco[3], const float facenor[3], const bool differentials,
- float *u, float *v, float *dx_u, float *dx_v, float *dy_u, float *dy_v)
-{
- /* find most stable axis to project */
- int axis1, axis2;
- axis_dominant_v3(&axis1, &axis2, facenor);
-
- /* compute u,v and derivatives */
- float t00 = v3[axis1] - v1[axis1];
- float t01 = v3[axis2] - v1[axis2];
- float t10 = v3[axis1] - v2[axis1];
- float t11 = v3[axis2] - v2[axis2];
-
- float detsh = (t00 * t11 - t10 * t01);
- detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f;
- t00 *= detsh; t01 *= detsh;
- t10 *= detsh; t11 *= detsh;
-
- *u = (v3[axis1] - co[axis1]) * t11 - (v3[axis2] - co[axis2]) * t10;
- *v = (v3[axis2] - co[axis2]) * t00 - (v3[axis1] - co[axis1]) * t01;
- if (differentials) {
- *dx_u = dxco[axis1] * t11 - dxco[axis2] * t10;
- *dx_v = dxco[axis2] * t00 - dxco[axis1] * t01;
- *dy_u = dyco[axis1] * t11 - dyco[axis2] * t10;
- *dy_v = dyco[axis2] * t00 - dyco[axis1] * t01;
- }
-}
-/* calculate U and V, for scanline (silly render face u and v are in range -1 to 0) */
-void shade_input_set_uv(ShadeInput *shi)
-{
- VlakRen *vlr = shi->vlr;
-
- if ((vlr->flag & R_SMOOTH) || (shi->mat->texco & NEED_UV) || (shi->passflag & SCE_PASS_UV)) {
- float v1[3], v2[3], v3[3];
-
- copy_v3_v3(v1, shi->v1->co);
- copy_v3_v3(v2, shi->v2->co);
- copy_v3_v3(v3, shi->v3->co);
-
- if (shi->obi->flag & R_TRANSFORMED) {
- mul_m4_v3(shi->obi->mat, v1);
- mul_m4_v3(shi->obi->mat, v2);
- mul_m4_v3(shi->obi->mat, v3);
- }
-
- /* exception case for wire render of edge */
- if (vlr->v2 == vlr->v3) {
- float lend, lenc;
-
- lend = len_v3v3(v2, v1);
- lenc = len_v3v3(shi->co, v1);
-
- if (lend == 0.0f) {
- shi->u = shi->v = 0.0f;
- }
- else {
- shi->u = -(1.0f - lenc / lend);
- shi->v = 0.0f;
- }
-
- if (shi->osatex) {
- shi->dx_u = 0.0f;
- shi->dx_v = 0.0f;
- shi->dy_u = 0.0f;
- shi->dy_v = 0.0f;
- }
- }
- else {
- barycentric_differentials_from_position(
- shi->co, v1, v2, v3, shi->dxco, shi->dyco, shi->facenor, shi->osatex,
- &shi->u, &shi->v, &shi->dx_u, &shi->dx_v, &shi->dy_u, &shi->dy_v);
-
- shi->u = -shi->u;
- shi->v = -shi->v;
-
- /* u and v are in range -1 to 0, we allow a little bit extra but not too much, screws up speedvectors */
- CLAMP(shi->u, -2.0f, 1.0f);
- CLAMP(shi->v, -2.0f, 1.0f);
- }
- }
-}
-
-void shade_input_set_normals(ShadeInput *shi)
-{
- float u = shi->u, v = shi->v;
- float l = 1.0f + u + v;
-
- shi->flippednor = 0;
-
- /* test flip normals to viewing direction */
- if (!(shi->vlr->flag & R_TANGENT)) {
- if (dot_v3v3(shi->facenor, shi->view) < 0.0f) {
- negate_v3(shi->facenor);
- shi->flippednor = 1;
- }
- }
-
- /* calculate vertexnormals */
- if (shi->vlr->flag & R_SMOOTH) {
- float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3;
-
- if (shi->flippednor) {
- negate_v3(n1);
- negate_v3(n2);
- negate_v3(n3);
- }
-
- shi->vn[0] = l * n3[0] - u * n1[0] - v * n2[0];
- shi->vn[1] = l * n3[1] - u * n1[1] - v * n2[1];
- shi->vn[2] = l * n3[2] - u * n1[2] - v * n2[2];
-
- /* use unnormalized normal (closer to games) */
- copy_v3_v3(shi->nmapnorm, shi->vn);
-
- normalize_v3(shi->vn);
- }
- else {
- copy_v3_v3(shi->vn, shi->facenor);
- copy_v3_v3(shi->nmapnorm, shi->vn);
- }
-
- /* used in nodes */
- copy_v3_v3(shi->vno, shi->vn);
-
- /* flip normals to viewing direction */
- if (!(shi->vlr->flag & R_TANGENT))
- if (dot_v3v3(shi->facenor, shi->view) < 0.0f)
- shade_input_flip_normals(shi);
-}
-
-/* XXX shi->flippednor messes up otherwise */
-void shade_input_set_vertex_normals(ShadeInput *shi)
-{
- float u = shi->u, v = shi->v;
- float l = 1.0f + u + v;
-
- /* calculate vertexnormals */
- if (shi->vlr->flag & R_SMOOTH) {
- const float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3;
-
- shi->vn[0] = l * n3[0] - u * n1[0] - v * n2[0];
- shi->vn[1] = l * n3[1] - u * n1[1] - v * n2[1];
- shi->vn[2] = l * n3[2] - u * n1[2] - v * n2[2];
-
- /* use unnormalized normal (closer to games) */
- copy_v3_v3(shi->nmapnorm, shi->vn);
-
- normalize_v3(shi->vn);
- }
- else {
- copy_v3_v3(shi->vn, shi->facenor);
- copy_v3_v3(shi->nmapnorm, shi->vn);
- }
-
- /* used in nodes */
- copy_v3_v3(shi->vno, shi->vn);
-}
-
-
-/* use by raytrace, sss, bake to flip into the right direction */
-void shade_input_flip_normals(ShadeInput *shi)
-{
- negate_v3(shi->facenor);
- negate_v3(shi->vn);
- negate_v3(shi->vno);
- negate_v3(shi->nmapnorm);
- shi->flippednor = !shi->flippednor;
-}
-
-void shade_input_set_shade_texco(ShadeInput *shi)
-{
- ObjectInstanceRen *obi = shi->obi;
- ObjectRen *obr = shi->obr;
- VertRen *v1 = shi->v1, *v2 = shi->v2, *v3 = shi->v3;
- float u = shi->u, v = shi->v;
- float l = 1.0f + u + v, dl;
- int mode = shi->mode; /* or-ed result for all nodes */
- int mode2 = shi->mode2;
- short texco = shi->mat->texco;
- const bool need_mikk_tangent = (mode & MA_NORMAP_TANG || R.flag & R_NEED_TANGENT);
- const bool need_mikk_tangent_concrete = (mode2 & MA_TANGENT_CONCRETE) != 0;
-
- /* calculate dxno */
- if (shi->vlr->flag & R_SMOOTH) {
-
- if (shi->osatex && (texco & (TEXCO_NORM | TEXCO_REFL)) ) {
- const float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3;
-
- dl = shi->dx_u + shi->dx_v;
- shi->dxno[0] = dl * n3[0] - shi->dx_u * n1[0] - shi->dx_v * n2[0];
- shi->dxno[1] = dl * n3[1] - shi->dx_u * n1[1] - shi->dx_v * n2[1];
- shi->dxno[2] = dl * n3[2] - shi->dx_u * n1[2] - shi->dx_v * n2[2];
- dl = shi->dy_u + shi->dy_v;
- shi->dyno[0] = dl * n3[0] - shi->dy_u * n1[0] - shi->dy_v * n2[0];
- shi->dyno[1] = dl * n3[1] - shi->dy_u * n1[1] - shi->dy_v * n2[1];
- shi->dyno[2] = dl * n3[2] - shi->dy_u * n1[2] - shi->dy_v * n2[2];
-
- }
- }
-
- /* calc tangents */
- if (mode & (MA_TANGENT_V | MA_NORMAP_TANG) || mode2 & MA_TANGENT_CONCRETE || R.flag & R_NEED_TANGENT) {
- const float *s1, *s2, *s3;
- float tl, tu, tv;
-
- if (shi->vlr->flag & R_SMOOTH) {
- tl = l;
- tu = u;
- tv = v;
- }
- else {
- /* qdn: flat faces have tangents too,
- * could pick either one, using average here */
- tl = 1.0f / 3.0f;
- tu = -1.0f / 3.0f;
- tv = -1.0f / 3.0f;
- }
-
- shi->tang[0] = shi->tang[1] = shi->tang[2] = 0.0f;
- shi->nmaptang[0] = shi->nmaptang[1] = shi->nmaptang[2] = 0.0f;
-
- if (mode & MA_TANGENT_V) {
- s1 = RE_vertren_get_tangent(obr, v1, 0);
- s2 = RE_vertren_get_tangent(obr, v2, 0);
- s3 = RE_vertren_get_tangent(obr, v3, 0);
-
- if (s1 && s2 && s3) {
- shi->tang[0] = (tl * s3[0] - tu * s1[0] - tv * s2[0]);
- shi->tang[1] = (tl * s3[1] - tu * s1[1] - tv * s2[1]);
- shi->tang[2] = (tl * s3[2] - tu * s1[2] - tv * s2[2]);
-
- if (obi->flag & R_TRANSFORMED)
- mul_m3_v3(obi->nmat, shi->tang);
-
- normalize_v3(shi->tang);
- copy_v3_v3(shi->nmaptang, shi->tang);
- }
- }
-
- if (need_mikk_tangent || need_mikk_tangent_concrete) {
- int j1 = shi->i1, j2 = shi->i2, j3 = shi->i3;
- float c0[3], c1[3], c2[3];
- int acttang = obr->actmtface;
-
- vlr_set_uv_indices(shi->vlr, &j1, &j2, &j3);
-
- /* cycle through all tangent in vlakren */
- for (int i = 0; i < MAX_MTFACE; i++) {
- const float *tangent = RE_vlakren_get_nmap_tangent(obr, shi->vlr, i, false);
- if (!tangent)
- continue;
-
- copy_v3_v3(c0, &tangent[j1 * 4]);
- copy_v3_v3(c1, &tangent[j2 * 4]);
- copy_v3_v3(c2, &tangent[j3 * 4]);
-
- /* keeping tangents normalized at vertex level
- * corresponds better to how it's done in game engines */
- if (obi->flag & R_TRANSFORMED) {
- mul_mat3_m4_v3(obi->mat, c0); normalize_v3(c0);
- mul_mat3_m4_v3(obi->mat, c1); normalize_v3(c1);
- mul_mat3_m4_v3(obi->mat, c2); normalize_v3(c2);
- }
-
- /* we don't normalize the interpolated TBN tangent
- * corresponds better to how it's done in game engines */
- shi->tangents[i][0] = (tl * c2[0] - tu * c0[0] - tv * c1[0]);
- shi->tangents[i][1] = (tl * c2[1] - tu * c0[1] - tv * c1[1]);
- shi->tangents[i][2] = (tl * c2[2] - tu * c0[2] - tv * c1[2]);
-
- /* the sign is the same for all 3 vertices of any
- * non degenerate triangle. */
- shi->tangents[i][3] = tangent[j1 * 4 + 3];
-
- if (acttang == i && need_mikk_tangent) {
- for (int m = 0; m < 4; m++) {
- shi->nmaptang[m] = shi->tangents[i][m];
- }
- }
- }
- }
- }
-
- if (mode & MA_STR_SURFDIFF) {
- const float *surfnor = RE_vlakren_get_surfnor(obr, shi->vlr, 0);
-
- if (surfnor) {
- copy_v3_v3(shi->surfnor, surfnor);
- if (obi->flag & R_TRANSFORMED)
- mul_m3_v3(obi->nmat, shi->surfnor);
- }
- else
- copy_v3_v3(shi->surfnor, shi->vn);
-
- shi->surfdist = 0.0f;
- }
-
- if (R.r.mode & R_SPEED) {
- const float *s1, *s2, *s3;
-
- s1 = RE_vertren_get_winspeed(obi, v1, 0);
- s2 = RE_vertren_get_winspeed(obi, v2, 0);
- s3 = RE_vertren_get_winspeed(obi, v3, 0);
- if (s1 && s2 && s3) {
- shi->winspeed[0] = (l * s3[0] - u * s1[0] - v * s2[0]);
- shi->winspeed[1] = (l * s3[1] - u * s1[1] - v * s2[1]);
- shi->winspeed[2] = (l * s3[2] - u * s1[2] - v * s2[2]);
- shi->winspeed[3] = (l * s3[3] - u * s1[3] - v * s2[3]);
- }
- else {
- shi->winspeed[0] = shi->winspeed[1] = shi->winspeed[2] = shi->winspeed[3] = 0.0f;
- }
- }
-
- /* pass option forces UV calc */
- if ((shi->passflag & SCE_PASS_UV) || (R.flag & R_NEED_VCOL))
- texco |= (NEED_UV | TEXCO_UV);
-
- /* texture coordinates. shi->dxuv shi->dyuv have been set */
- if (texco & NEED_UV) {
-
- if (texco & TEXCO_ORCO) {
- if (v1->orco) {
- const float *o1, *o2, *o3;
-
- o1 = v1->orco;
- o2 = v2->orco;
- o3 = v3->orco;
-
- shi->lo[0] = l * o3[0] - u * o1[0] - v * o2[0];
- shi->lo[1] = l * o3[1] - u * o1[1] - v * o2[1];
- shi->lo[2] = l * o3[2] - u * o1[2] - v * o2[2];
-
- if (shi->osatex) {
- dl = shi->dx_u + shi->dx_v;
- shi->dxlo[0] = dl * o3[0] - shi->dx_u * o1[0] - shi->dx_v * o2[0];
- shi->dxlo[1] = dl * o3[1] - shi->dx_u * o1[1] - shi->dx_v * o2[1];
- shi->dxlo[2] = dl * o3[2] - shi->dx_u * o1[2] - shi->dx_v * o2[2];
- dl = shi->dy_u + shi->dy_v;
- shi->dylo[0] = dl * o3[0] - shi->dy_u * o1[0] - shi->dy_v * o2[0];
- shi->dylo[1] = dl * o3[1] - shi->dy_u * o1[1] - shi->dy_v * o2[1];
- shi->dylo[2] = dl * o3[2] - shi->dy_u * o1[2] - shi->dy_v * o2[2];
- }
- }
-
- copy_v3_v3(shi->duplilo, obi->dupliorco);
- }
-
- if (texco & TEXCO_GLOB) {
- copy_v3_v3(shi->gl, shi->co);
- mul_m4_v3(R.viewinv, shi->gl);
- if (shi->osatex) {
- copy_v3_v3(shi->dxgl, shi->dxco);
- mul_mat3_m4_v3(R.viewinv, shi->dxgl);
- copy_v3_v3(shi->dygl, shi->dyco);
- mul_mat3_m4_v3(R.viewinv, shi->dygl);
- }
- }
-
- if (texco & TEXCO_STRAND) {
- shi->strandco = (l * v3->accum - u * v1->accum - v * v2->accum);
- if (shi->osatex) {
- dl = shi->dx_u + shi->dx_v;
- shi->dxstrand = dl * v3->accum - shi->dx_u * v1->accum - shi->dx_v * v2->accum;
- dl = shi->dy_u + shi->dy_v;
- shi->dystrand = dl * v3->accum - shi->dy_u * v1->accum - shi->dy_v * v2->accum;
- }
- }
-
- if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) || (R.flag & R_NEED_VCOL)) {
- VlakRen *vlr = shi->vlr;
- MTFace *tface;
- MCol *mcol;
- char *name;
- int i, j1 = shi->i1, j2 = shi->i2, j3 = shi->i3;
-
- /* uv and vcols are not copied on split, so set them according vlr divide flag */
- vlr_set_uv_indices(vlr, &j1, &j2, &j3);
-
- shi->totuv = 0;
- shi->totcol = 0;
- shi->actuv = obr->actmtface;
- shi->actcol = obr->actmcol;
-
- if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) || (R.flag & R_NEED_VCOL)) {
- for (i = 0; (mcol = RE_vlakren_get_mcol(obr, vlr, i, &name, 0)); i++) {
- ShadeInputCol *scol = &shi->col[i];
- const char *cp1, *cp2, *cp3;
- float a[3];
-
- shi->totcol++;
- scol->name = name;
-
- cp1 = (char *)(mcol + j1);
- cp2 = (char *)(mcol + j2);
- cp3 = (char *)(mcol + j3);
-
- /* alpha values */
- a[0] = ((float)cp1[0]) / 255.f;
- a[1] = ((float)cp2[0]) / 255.f;
- a[2] = ((float)cp3[0]) / 255.f;
- scol->col[3] = l * a[2] - u * a[0] - v * a[1];
-
- /* sample premultiplied color value */
- scol->col[0] = (l * ((float)cp3[3]) * a[2] - u * ((float)cp1[3]) * a[0] - v * ((float)cp2[3]) * a[1]) / 255.f;
- scol->col[1] = (l * ((float)cp3[2]) * a[2] - u * ((float)cp1[2]) * a[0] - v * ((float)cp2[2]) * a[1]) / 255.f;
- scol->col[2] = (l * ((float)cp3[1]) * a[2] - u * ((float)cp1[1]) * a[0] - v * ((float)cp2[1]) * a[1]) / 255.f;
-
- /* if not zero alpha, restore non-multiplied color */
- if (scol->col[3]) {
- mul_v3_fl(scol->col, 1.0f / scol->col[3]);
- }
- }
-
- if (shi->totcol) {
- shi->vcol[0] = shi->col[shi->actcol].col[0];
- shi->vcol[1] = shi->col[shi->actcol].col[1];
- shi->vcol[2] = shi->col[shi->actcol].col[2];
- shi->vcol[3] = shi->col[shi->actcol].col[3];
- }
- else {
- shi->vcol[0] = 0.0f;
- shi->vcol[1] = 0.0f;
- shi->vcol[2] = 0.0f;
- shi->vcol[3] = 1.0f;
- }
- }
-
- for (i = 0; (tface = RE_vlakren_get_tface(obr, vlr, i, &name, 0)); i++) {
- ShadeInputUV *suv = &shi->uv[i];
- const float *uv1 = tface->uv[j1];
- const float *uv2 = tface->uv[j2];
- const float *uv3 = tface->uv[j3];
-
- shi->totuv++;
- suv->name = name;
-
- if ((shi->mat->mapflag & MA_MAPFLAG_UVPROJECT) && (shi->depth == 0)) {
- float x = shi->xs;
- float y = shi->ys;
-
- float s1[2] = {-1.0f + 2.0f * uv1[0], -1.0f + 2.0f * uv1[1]};
- float s2[2] = {-1.0f + 2.0f * uv2[0], -1.0f + 2.0f * uv2[1]};
- float s3[2] = {-1.0f + 2.0f * uv3[0], -1.0f + 2.0f * uv3[1]};
-
-
- float obwinmat[4][4], winmat[4][4], ho1[4], ho2[4], ho3[4];
- float Zmulx, Zmuly;
- float hox, hoy, l_proj, dl_proj, u_proj, v_proj;
- float s00, s01, s10, s11, detsh;
-
- /* old globals, localized now */
- Zmulx = ((float)R.winx) / 2.0f;
- Zmuly = ((float)R.winy) / 2.0f;
-
- zbuf_make_winmat(&R, winmat);
- if (shi->obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, winmat, obi->mat);
- else
- copy_m4_m4(obwinmat, winmat);
-
- zbuf_render_project(obwinmat, v1->co, ho1);
- zbuf_render_project(obwinmat, v2->co, ho2);
- zbuf_render_project(obwinmat, v3->co, ho3);
-
- s00 = ho3[0] / ho3[3] - ho1[0] / ho1[3];
- s01 = ho3[1] / ho3[3] - ho1[1] / ho1[3];
- s10 = ho3[0] / ho3[3] - ho2[0] / ho2[3];
- s11 = ho3[1] / ho3[3] - ho2[1] / ho2[3];
-
- detsh = s00 * s11 - s10 * s01;
- detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f;
- s00 *= detsh; s01 *= detsh;
- s10 *= detsh; s11 *= detsh;
-
- /* recalc u and v again */
- hox = x / Zmulx - 1.0f;
- hoy = y / Zmuly - 1.0f;
- u_proj = (hox - ho3[0] / ho3[3]) * s11 - (hoy - ho3[1] / ho3[3]) * s10;
- v_proj = (hoy - ho3[1] / ho3[3]) * s00 - (hox - ho3[0] / ho3[3]) * s01;
- l_proj = 1.0f + u_proj + v_proj;
-
- suv->uv[0] = l_proj * s3[0] - u_proj * s1[0] - v_proj * s2[0];
- suv->uv[1] = l_proj * s3[1] - u_proj * s1[1] - v_proj * s2[1];
- suv->uv[2] = 0.0f;
-
- if (shi->osatex) {
- float dxuv[2], dyuv[2];
- dxuv[0] = s11 / Zmulx;
- dxuv[1] = -s01 / Zmulx;
- dyuv[0] = -s10 / Zmuly;
- dyuv[1] = s00 / Zmuly;
-
- dl_proj = dxuv[0] + dxuv[1];
- suv->dxuv[0] = dl_proj * s3[0] - dxuv[0] * s1[0] - dxuv[1] * s2[0];
- suv->dxuv[1] = dl_proj * s3[1] - dxuv[0] * s1[1] - dxuv[1] * s2[1];
- dl_proj = dyuv[0] + dyuv[1];
- suv->dyuv[0] = dl_proj * s3[0] - dyuv[0] * s1[0] - dyuv[1] * s2[0];
- suv->dyuv[1] = dl_proj * s3[1] - dyuv[0] * s1[1] - dyuv[1] * s2[1];
- }
- }
- else {
-
- suv->uv[0] = -1.0f + 2.0f * (l * uv3[0] - u * uv1[0] - v * uv2[0]);
- suv->uv[1] = -1.0f + 2.0f * (l * uv3[1] - u * uv1[1] - v * uv2[1]);
- suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */
-
- if (shi->osatex) {
- float duv[2];
-
- dl = shi->dx_u + shi->dx_v;
- duv[0] = shi->dx_u;
- duv[1] = shi->dx_v;
-
- suv->dxuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]);
- suv->dxuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]);
-
- dl = shi->dy_u + shi->dy_v;
- duv[0] = shi->dy_u;
- duv[1] = shi->dy_v;
-
- suv->dyuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]);
- suv->dyuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]);
- }
- }
- }
-
- shi->dupliuv[0] = -1.0f + 2.0f * obi->dupliuv[0];
- shi->dupliuv[1] = -1.0f + 2.0f * obi->dupliuv[1];
- shi->dupliuv[2] = 0.0f;
-
- if (shi->totuv == 0) {
- ShadeInputUV *suv = &shi->uv[0];
-
- suv->uv[0] = 2.0f * (u + .5f);
- suv->uv[1] = 2.0f * (v + .5f);
- suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */
- }
- }
-
- if (texco & TEXCO_NORM) {
- shi->orn[0] = -shi->vn[0];
- shi->orn[1] = -shi->vn[1];
- shi->orn[2] = -shi->vn[2];
- }
-
- if (texco & TEXCO_STRESS) {
- const float *s1, *s2, *s3;
-
- s1 = RE_vertren_get_stress(obr, v1, 0);
- s2 = RE_vertren_get_stress(obr, v2, 0);
- s3 = RE_vertren_get_stress(obr, v3, 0);
- if (s1 && s2 && s3) {
- shi->stress = l * s3[0] - u * s1[0] - v * s2[0];
- if (shi->stress < 1.0f) shi->stress -= 1.0f;
- else shi->stress = (shi->stress - 1.0f) / shi->stress;
- }
- else shi->stress = 0.0f;
- }
-
- if (texco & TEXCO_TANGENT) {
- if ((mode & MA_TANGENT_V) == 0) {
- /* just prevent surprises */
- shi->tang[0] = shi->tang[1] = shi->tang[2] = 0.0f;
- shi->nmaptang[0] = shi->nmaptang[1] = shi->nmaptang[2] = 0.0f;
- }
- }
- }
-
- /* this only avalailable for scanline renders */
- if (shi->depth == 0) {
- float x = shi->xs;
- float y = shi->ys;
-
- if (texco & TEXCO_WINDOW) {
- shi->winco[0] = -1.0f + 2.0f * x / (float)R.winx;
- shi->winco[1] = -1.0f + 2.0f * y / (float)R.winy;
- shi->winco[2] = 0.0f;
- if (shi->osatex) {
- shi->dxwin[0] = 2.0f / (float)R.winx;
- shi->dywin[1] = 2.0f / (float)R.winy;
- shi->dxwin[1] = shi->dxwin[2] = 0.0f;
- shi->dywin[0] = shi->dywin[2] = 0.0f;
- }
- }
- }
- /* else {
- * Note! For raytracing winco is not set,
- * important because thus means all shader input's need to have their variables set to zero
- * else un-initialized values are used
- */
- if (shi->do_manage) {
- if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) || (R.flag & R_NEED_VCOL)) {
- srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol);
- }
- }
-
-}
-
-/* ****************** ShadeSample ************************************** */
-
-/* initialize per part, not per pixel! */
-void shade_input_initialize(ShadeInput *shi, RenderPart *pa, RenderLayer *rl, int sample)
-{
-
- memset(shi, 0, sizeof(ShadeInput));
-
- shi->sample = sample;
- shi->thread = pa->thread;
- shi->do_preview = (R.r.scemode & R_MATNODE_PREVIEW) != 0;
-
- shi->do_manage = BKE_scene_check_color_management_enabled(R.scene);
- shi->use_world_space_shading = BKE_scene_use_world_space_shading(R.scene);
-
- shi->lay = (1 << 20) - 1;
- shi->layflag = rl->layflag;
- shi->passflag = rl->passflag;
- shi->combinedflag = ~rl->pass_xor;
-// shi->rl= rl;
- /* note shi.depth==0 means first hit, not raytracing */
-
-}
-
-/* initialize per part, not per pixel! */
-void shade_sample_initialize(ShadeSample *ssamp, RenderPart *pa, RenderLayer *rl)
-{
- int a, tot;
-
- tot = R.osa == 0 ? 1 : R.osa;
-
- for (a = 0; a < tot; a++) {
- shade_input_initialize(&ssamp->shi[a], pa, rl, a);
- memset(&ssamp->shr[a], 0, sizeof(ShadeResult));
- }
-
- get_sample_layers(pa, rl, ssamp->rlpp);
-}
-
-/* Do AO or (future) GI */
-void shade_samples_do_AO(ShadeSample *ssamp)
-{
- if (!(R.r.mode & R_SHADOW))
- return;
- if (!(R.r.mode & R_RAYTRACE) && !(R.wrld.ao_gather_method == WO_AOGATHER_APPROX))
- return;
-
- if (R.wrld.mode & (WO_AMB_OCC | WO_ENV_LIGHT | WO_INDIRECT_LIGHT)) {
- ShadeInput *shi = &ssamp->shi[0];
- int sample;
-
- if (((shi->passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO | SCE_PASS_ENVIRONMENT | SCE_PASS_INDIRECT))) ||
- (shi->passflag & (SCE_PASS_AO | SCE_PASS_ENVIRONMENT | SCE_PASS_INDIRECT)))
- {
- for (sample = 0; sample < ssamp->tot; shi++, sample++)
- if (!(shi->mode & MA_SHLESS))
- ambient_occlusion(shi); /* stores in shi->ao[] */
- }
- }
-}
-
-
-void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y)
-{
- ShadeInput *shi;
- float xs, ys;
-
- ssamp->tot = 0;
-
- for (shi = ssamp->shi; ps; ps = ps->next) {
- shade_input_set_triangle(shi, ps->obi, ps->facenr, 1);
-
- if (shi->vlr) { /* NULL happens for env material or for 'all z' */
- unsigned short curmask = ps->mask;
-
- /* full osa is only set for OSA renders */
- if (shi->vlr->flag & R_FULL_OSA) {
- short shi_cp = 0, samp;
-
- for (samp = 0; samp < R.osa; samp++) {
- if (curmask & (1 << samp)) {
- /* zbuffer has this inverse corrected, ensures xs,ys are inside pixel */
- xs = (float)x + R.jit[samp][0] + 0.5f;
- ys = (float)y + R.jit[samp][1] + 0.5f;
-
- if (shi_cp)
- shade_input_copy_triangle(shi, shi - 1);
-
- shi->mask = (1 << samp);
-// shi->rl= ssamp->rlpp[samp];
- shi->samplenr = R.shadowsamplenr[shi->thread]++; /* this counter is not being reset per pixel */
- shade_input_set_viewco(shi, x, y, xs, ys, (float)ps->z);
- shade_input_set_uv(shi);
- if (shi_cp == 0)
- shade_input_set_normals(shi);
- else /* XXX shi->flippednor messes up otherwise */
- shade_input_set_vertex_normals(shi);
-
- shi_cp = 1;
- shi++;
- }
- }
- }
- else {
- if (R.osa) {
- short b = R.samples->centmask[curmask];
- xs = (float)x + R.samples->centLut[b & 15] + 0.5f;
- ys = (float)y + R.samples->centLut[b >> 4] + 0.5f;
- }
- else if (R.i.curblur) {
- xs= (float)x + R.mblur_jit[R.i.curblur-1][0] + 0.5f;
- ys= (float)y + R.mblur_jit[R.i.curblur-1][1] + 0.5f;
- }
- else {
- xs = (float)x + 0.5f;
- ys = (float)y + 0.5f;
- }
-
- shi->mask = curmask;
- shi->samplenr = R.shadowsamplenr[shi->thread]++;
- shade_input_set_viewco(shi, x, y, xs, ys, (float)ps->z);
- shade_input_set_uv(shi);
- shade_input_set_normals(shi);
- shi++;
- }
-
- /* total sample amount, shi->sample is static set in initialize */
- if (shi != ssamp->shi)
- ssamp->tot = (shi - 1)->sample + 1;
- }
- }
-}
-
-/* shades samples, returns true if anything happened */
-int shade_samples(ShadeSample *ssamp, PixStr *ps, int x, int y)
-{
- shade_samples_fill_with_ps(ssamp, ps, x, y);
-
- if (ssamp->tot) {
- ShadeInput *shi = ssamp->shi;
- ShadeResult *shr = ssamp->shr;
- int samp;
-
- /* if shadow or AO? */
- shade_samples_do_AO(ssamp);
-
- /* if shade (all shadepinputs have same passflag) */
- if (ssamp->shi[0].passflag & ~(SCE_PASS_Z | SCE_PASS_INDEXOB | SCE_PASS_INDEXMA)) {
-
- for (samp = 0; samp < ssamp->tot; samp++, shi++, shr++) {
- shade_input_set_shade_texco(shi);
- shade_input_do_shade(shi, shr);
- }
- }
- else if (shi->passflag & SCE_PASS_Z) {
- for (samp = 0; samp < ssamp->tot; samp++, shi++, shr++)
- shr->z = -shi->co[2];
- }
-
- return 1;
- }
- return 0;
-}
-
diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c
deleted file mode 100644
index c2d5c060530..00000000000
--- a/source/blender/render/intern/source/shadeoutput.c
+++ /dev/null
@@ -1,2162 +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) 2006 Blender Foundation
- * All rights reserved.
- *
- * Contributors: Hos, Robert Wenzlaff.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/shadeoutput.c
- * \ingroup render
- */
-
-#include <stdio.h>
-#include <float.h>
-#include <math.h>
-#include <string.h>
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_colorband.h"
-#include "BKE_colortools.h"
-#include "BKE_material.h"
-
-#include "DNA_group_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_material_types.h"
-
-/* local include */
-#include "occlusion.h"
-#include "render_types.h"
-#include "rendercore.h"
-#include "shadbuf.h"
-#include "sss.h"
-#include "texture.h"
-
-#include "shading.h" /* own include */
-
-#include "IMB_colormanagement.h"
-
-/* could enable at some point but for now there are far too many conversions */
-#ifdef __GNUC__
-# pragma GCC diagnostic ignored "-Wdouble-promotion"
-#endif
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-ListBase *get_lights(ShadeInput *shi)
-{
-
- if (R.r.scemode & R_BUTS_PREVIEW)
- return &R.lights;
- if (shi->mat && shi->mat->group)
- return &shi->mat->group->gobject;
-
- return &R.lights;
-}
-
-#if 0
-static void fogcolor(const float colf[3], float *rco, float *view)
-{
- float alpha, stepsize, startdist, dist, hor[4], zen[3], vec[3], dview[3];
- float div=0.0f, distfac;
-
- hor[0]= R.wrld.horr; hor[1]= R.wrld.horg; hor[2]= R.wrld.horb;
- zen[0]= R.wrld.zenr; zen[1]= R.wrld.zeng; zen[2]= R.wrld.zenb;
-
- copy_v3_v3(vec, rco);
-
- /* we loop from cur coord to mist start in steps */
- stepsize= 1.0f;
-
- div= ABS(view[2]);
- dview[0]= view[0]/(stepsize*div);
- dview[1]= view[1]/(stepsize*div);
- dview[2]= -stepsize;
-
- startdist= -rco[2] + BLI_frand();
- for (dist= startdist; dist>R.wrld.miststa; dist-= stepsize) {
-
- hor[0]= R.wrld.horr; hor[1]= R.wrld.horg; hor[2]= R.wrld.horb;
- alpha= 1.0f;
- do_sky_tex(vec, vec, NULL, hor, zen, &alpha);
-
- distfac= (dist-R.wrld.miststa)/R.wrld.mistdist;
-
- hor[3]= hor[0]*distfac*distfac;
-
- /* premul! */
- alpha= hor[3];
- hor[0]= hor[0]*alpha;
- hor[1]= hor[1]*alpha;
- hor[2]= hor[2]*alpha;
- addAlphaOverFloat(colf, hor);
-
- sub_v3_v3(vec, dview);
- }
-}
-#endif
-
-/* zcor is distance, co the 3d coordinate in eye space, return alpha */
-float mistfactor(float zcor, float const co[3])
-{
- float fac, hi;
-
- fac = zcor - R.wrld.miststa; /* zcor is calculated per pixel */
-
- /* fac= -co[2]-R.wrld.miststa; */
-
- if (fac > 0.0f) {
- if (fac < R.wrld.mistdist) {
-
- fac = (fac / R.wrld.mistdist);
-
- if (R.wrld.mistype == 0) {
- fac *= fac;
- }
- else if (R.wrld.mistype == 1) {
- /* pass */
- }
- else {
- fac = sqrtf(fac);
- }
- }
- else {
- fac = 1.0f;
- }
- }
- else {
- fac = 0.0f;
- }
-
- /* height switched off mist */
- if (R.wrld.misthi!=0.0f && fac!=0.0f) {
- /* at height misthi the mist is completely gone */
-
- hi = R.viewinv[0][2] * co[0] +
- R.viewinv[1][2] * co[1] +
- R.viewinv[2][2] * co[2] +
- R.viewinv[3][2];
-
- if (hi > R.wrld.misthi) {
- fac = 0.0f;
- }
- else if (hi>0.0f) {
- hi= (R.wrld.misthi-hi)/R.wrld.misthi;
- fac*= hi*hi;
- }
- }
-
- return (1.0f-fac)* (1.0f-R.wrld.misi);
-}
-
-static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
-{
- double a, b, c, disc, nray[3], npos[3];
- double t0, t1 = 0.0f, t2= 0.0f, t3;
- float p1[3], p2[3], ladist, maxz = 0.0f, maxy = 0.0f, haint;
- int cuts;
- bool do_clip = true, use_yco = false;
-
- *intens= 0.0f;
- haint= lar->haint;
-
- if (R.r.mode & R_ORTHO) {
- /* camera pos (view vector) cannot be used... */
- /* camera position (cox,coy,0) rotate around lamp */
- p1[0]= shi->co[0]-lar->co[0];
- p1[1]= shi->co[1]-lar->co[1];
- p1[2]= -lar->co[2];
- mul_m3_v3(lar->imat, p1);
- copy_v3db_v3fl(npos, p1); /* npos is double! */
-
- /* pre-scale */
- npos[2] *= (double)lar->sh_zfac;
- }
- else {
- copy_v3db_v3fl(npos, lar->sh_invcampos); /* in initlamp calculated */
- }
-
- /* rotate view */
- copy_v3db_v3fl(nray, shi->view);
- mul_m3_v3_double(lar->imat, nray);
-
- if (R.wrld.mode & WO_MIST) {
- /* patchy... */
- haint *= mistfactor(-lar->co[2], lar->co);
- if (haint==0.0f) {
- return;
- }
- }
-
-
- /* rotate maxz */
- if (shi->co[2]==0.0f) {
- do_clip = false; /* for when halo at sky */
- }
- else {
- p1[0]= shi->co[0]-lar->co[0];
- p1[1]= shi->co[1]-lar->co[1];
- p1[2]= shi->co[2]-lar->co[2];
-
- maxz= lar->imat[0][2]*p1[0]+lar->imat[1][2]*p1[1]+lar->imat[2][2]*p1[2];
- maxz*= lar->sh_zfac;
- maxy= lar->imat[0][1]*p1[0]+lar->imat[1][1]*p1[1]+lar->imat[2][1]*p1[2];
-
- if (fabs(nray[2]) < FLT_EPSILON) {
- use_yco = true;
- }
- }
-
- /* scale z to make sure volume is normalized */
- nray[2] *= (double)lar->sh_zfac;
- /* nray does not need normalization */
-
- ladist= lar->sh_zfac*lar->dist;
-
- /* solve */
- a = nray[0] * nray[0] + nray[1] * nray[1] - nray[2]*nray[2];
- b = nray[0] * npos[0] + nray[1] * npos[1] - nray[2]*npos[2];
- c = npos[0] * npos[0] + npos[1] * npos[1] - npos[2]*npos[2];
-
- cuts= 0;
- if (fabs(a) < DBL_EPSILON) {
- /*
- * Only one intersection point...
- */
- return;
- }
- else {
- disc = b*b - a*c;
-
- if (disc==0.0) {
- t1=t2= (-b)/ a;
- cuts= 2;
- }
- else if (disc > 0.0) {
- disc = sqrt(disc);
- t1 = (-b + disc) / a;
- t2 = (-b - disc) / a;
- cuts= 2;
- }
- }
- if (cuts==2) {
- int ok1=0, ok2=0;
-
- /* sort */
- if (t1>t2) {
- a= t1; t1= t2; t2= a;
- }
-
- /* z of intersection points with diabolo */
- p1[2]= npos[2] + t1*nray[2];
- p2[2]= npos[2] + t2*nray[2];
-
- /* evaluate both points */
- if (p1[2]<=0.0f) ok1= 1;
- if (p2[2]<=0.0f && t1!=t2) ok2= 1;
-
- /* at least 1 point with negative z */
- if (ok1==0 && ok2==0) return;
-
- /* intersction point with -ladist, the bottom of the cone */
- if (use_yco == false) {
- t3= ((double)(-ladist)-npos[2])/nray[2];
-
- /* de we have to replace one of the intersection points? */
- if (ok1) {
- if (p1[2]<-ladist) t1= t3;
- }
- else {
- t1= t3;
- }
- if (ok2) {
- if (p2[2]<-ladist) t2= t3;
- }
- else {
- t2= t3;
- }
- }
- else if (ok1==0 || ok2==0) return;
-
- /* at least 1 visible interesction point */
- if (t1<0.0 && t2<0.0) return;
-
- if (t1<0.0) t1= 0.0;
- if (t2<0.0) t2= 0.0;
-
- if (t1==t2) return;
-
- /* sort again to be sure */
- if (t1>t2) {
- a= t1; t1= t2; t2= a;
- }
-
- /* calculate t0: is the maximum visible z (when halo is intersected by face) */
- if (do_clip) {
- if (use_yco == false) t0 = ((double)maxz - npos[2]) / nray[2];
- else t0 = ((double)maxy - npos[1]) / nray[1];
-
- if (t0 < t1) return;
- if (t0 < t2) t2= t0;
- }
-
- /* calc points */
- p1[0]= npos[0] + t1*nray[0];
- p1[1]= npos[1] + t1*nray[1];
- p1[2]= npos[2] + t1*nray[2];
- p2[0]= npos[0] + t2*nray[0];
- p2[1]= npos[1] + t2*nray[1];
- p2[2]= npos[2] + t2*nray[2];
-
-
- /* now we have 2 points, make three lengths with it */
-
- a = len_v3(p1);
- b = len_v3(p2);
- c = len_v3v3(p1, p2);
-
- a/= ladist;
- a= sqrt(a);
- b/= ladist;
- b= sqrt(b);
- c/= ladist;
-
- *intens= c*( (1.0-a)+(1.0-b) );
-
- /* WATCH IT: do not clip a,b en c at 1.0, this gives nasty little overflows
- * at the edges (especially with narrow halos) */
- if (*intens<=0.0f) return;
-
- /* soft area */
- /* not needed because t0 has been used for p1/p2 as well */
- /* if (doclip && t0<t2) { */
- /* *intens *= (t0-t1)/(t2-t1); */
- /* } */
-
- *intens *= haint;
-
- if (lar->shb && lar->shb->shadhalostep) {
- *intens *= shadow_halo(lar, p1, p2);
- }
-
- }
-}
-
-void renderspothalo(ShadeInput *shi, float col[4], float alpha)
-{
- ListBase *lights;
- GroupObject *go;
- LampRen *lar;
- float i;
-
- if (alpha==0.0f) return;
-
- lights= get_lights(shi);
- for (go=lights->first; go; go= go->next) {
- lar= go->lampren;
- if (lar==NULL) continue;
-
- if (lar->type==LA_SPOT && (lar->mode & LA_HALO) && (lar->buftype != LA_SHADBUF_DEEP) && lar->haint>0) {
-
- if (lar->mode & LA_LAYER)
- if (shi->vlr && (lar->lay & shi->obi->lay)==0)
- continue;
- if ((lar->lay & shi->lay)==0)
- continue;
-
- spothalo(lar, shi, &i);
- if (i > 0.0f) {
- const float i_alpha = i * alpha;
- col[0] += i_alpha * lar->r;
- col[1] += i_alpha * lar->g;
- col[2] += i_alpha * lar->b;
- col[3] += i_alpha; /* all premul */
- }
- }
- }
- /* clip alpha, is needed for unified 'alpha threshold' (vanillaRenderPipe.c) */
- if (col[3]>1.0f) col[3]= 1.0f;
-}
-
-
-
-/* ---------------- shaders ----------------------- */
-
-static double Normalize_d(double *n)
-{
- double d;
-
- d= n[0]*n[0]+n[1]*n[1]+n[2]*n[2];
-
- if (d>0.00000000000000001) {
- d= sqrt(d);
-
- n[0]/=d;
- n[1]/=d;
- n[2]/=d;
- }
- else {
- n[0]=n[1]=n[2]= 0.0;
- d= 0.0;
- }
- return d;
-}
-
-/* mix of 'real' fresnel and allowing control. grad defines blending gradient */
-float fresnel_fac(const float view[3], const float vn[3], float grad, float fac)
-{
- float t1, t2;
-
- if (fac==0.0f) return 1.0f;
-
- t1 = dot_v3v3(view, vn);
- if (t1>0.0f) t2= 1.0f+t1;
- else t2= 1.0f-t1;
-
- t2= grad + (1.0f-grad)*powf(t2, fac);
-
- if (t2<0.0f) return 0.0f;
- else if (t2>1.0f) return 1.0f;
- return t2;
-}
-
-static double saacos_d(double fac)
-{
- if (fac<= -1.0) return M_PI;
- else if (fac>=1.0) return 0.0;
- else return acos(fac);
-}
-
-/* Stoke's form factor. Need doubles here for extreme small area sizes */
-static float area_lamp_energy(float (*area)[3], const float co[3], const float vn[3])
-{
- double fac;
- double vec[4][3]; /* vectors of rendered co to vertices lamp */
- double cross[4][3]; /* cross products of this */
- double rad[4]; /* angles between vecs */
-
- VECSUB(vec[0], co, area[0]);
- VECSUB(vec[1], co, area[1]);
- VECSUB(vec[2], co, area[2]);
- VECSUB(vec[3], co, area[3]);
-
- Normalize_d(vec[0]);
- Normalize_d(vec[1]);
- Normalize_d(vec[2]);
- Normalize_d(vec[3]);
-
- /* cross product */
-#define CROSS(dest, a, b) \
- { \
- dest[0]= a[1] * b[2] - a[2] * b[1]; \
- dest[1]= a[2] * b[0] - a[0] * b[2]; \
- dest[2]= a[0] * b[1] - a[1] * b[0]; \
- } (void)0
-
- CROSS(cross[0], vec[0], vec[1]);
- CROSS(cross[1], vec[1], vec[2]);
- CROSS(cross[2], vec[2], vec[3]);
- CROSS(cross[3], vec[3], vec[0]);
-
-#undef CROSS
-
- Normalize_d(cross[0]);
- Normalize_d(cross[1]);
- Normalize_d(cross[2]);
- Normalize_d(cross[3]);
-
- /* angles */
- rad[0]= vec[0][0]*vec[1][0]+ vec[0][1]*vec[1][1]+ vec[0][2]*vec[1][2];
- rad[1]= vec[1][0]*vec[2][0]+ vec[1][1]*vec[2][1]+ vec[1][2]*vec[2][2];
- rad[2]= vec[2][0]*vec[3][0]+ vec[2][1]*vec[3][1]+ vec[2][2]*vec[3][2];
- rad[3]= vec[3][0]*vec[0][0]+ vec[3][1]*vec[0][1]+ vec[3][2]*vec[0][2];
-
- rad[0]= saacos_d(rad[0]);
- rad[1]= saacos_d(rad[1]);
- rad[2]= saacos_d(rad[2]);
- rad[3]= saacos_d(rad[3]);
-
- /* Stoke formula */
- fac= rad[0]*(vn[0]*cross[0][0]+ vn[1]*cross[0][1]+ vn[2]*cross[0][2]);
- fac+= rad[1]*(vn[0]*cross[1][0]+ vn[1]*cross[1][1]+ vn[2]*cross[1][2]);
- fac+= rad[2]*(vn[0]*cross[2][0]+ vn[1]*cross[2][1]+ vn[2]*cross[2][2]);
- fac+= rad[3]*(vn[0]*cross[3][0]+ vn[1]*cross[3][1]+ vn[2]*cross[3][2]);
-
- if (fac<=0.0) return 0.0;
- return fac;
-}
-
-static float area_lamp_energy_multisample(LampRen *lar, const float co[3], float *vn)
-{
- /* corner vectors are moved around according lamp jitter */
- float *jitlamp= lar->jitter, vec[3];
- float area[4][3], intens= 0.0f;
- int a= lar->ray_totsamp;
-
- /* test if co is behind lamp */
- sub_v3_v3v3(vec, co, lar->co);
- if (dot_v3v3(vec, lar->vec) < 0.0f)
- return 0.0f;
-
- while (a--) {
- vec[0]= jitlamp[0];
- vec[1]= jitlamp[1];
- vec[2]= 0.0f;
- mul_m3_v3(lar->mat, vec);
-
- add_v3_v3v3(area[0], lar->area[0], vec);
- add_v3_v3v3(area[1], lar->area[1], vec);
- add_v3_v3v3(area[2], lar->area[2], vec);
- add_v3_v3v3(area[3], lar->area[3], vec);
-
- intens+= area_lamp_energy(area, co, vn);
-
- jitlamp+= 2;
- }
- intens /= (float)lar->ray_totsamp;
-
- return pow(intens * lar->areasize, lar->k); /* corrected for buttons size and lar->dist^2 */
-}
-
-static float spec(float inp, int hard)
-{
- float b1;
-
- if (inp>=1.0f) return 1.0f;
- else if (inp<=0.0f) return 0.0f;
-
- b1= inp*inp;
- /* avoid FPE */
- if (b1<0.01f) b1= 0.01f;
-
- if ((hard & 1)==0) inp= 1.0f;
- if (hard & 2) inp*= b1;
- b1*= b1;
- if (hard & 4) inp*= b1;
- b1*= b1;
- if (hard & 8) inp*= b1;
- b1*= b1;
- if (hard & 16) inp*= b1;
- b1*= b1;
-
- /* avoid FPE */
- if (b1<0.001f) b1= 0.0f;
-
- if (hard & 32) inp*= b1;
- b1*= b1;
- if (hard & 64) inp*=b1;
- b1*= b1;
- if (hard & 128) inp*=b1;
-
- if (b1<0.001f) b1= 0.0f;
-
- if (hard & 256) {
- b1*= b1;
- inp*=b1;
- }
-
- return inp;
-}
-
-static float Phong_Spec(const float n[3], const float l[3], const float v[3], int hard, int tangent )
-{
- float h[3];
- float rslt;
-
- h[0] = l[0] + v[0];
- h[1] = l[1] + v[1];
- h[2] = l[2] + v[2];
- normalize_v3(h);
-
- rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2];
- if (tangent) rslt= sasqrt(1.0f - rslt*rslt);
-
- if ( rslt > 0.0f ) rslt= spec(rslt, hard);
- else rslt = 0.0f;
-
- return rslt;
-}
-
-
-/* reduced cook torrance spec (for off-specular peak) */
-static float CookTorr_Spec(const float n[3], const float l[3], const float v[3], int hard, int tangent)
-{
- float i, nh, nv, h[3];
-
- h[0]= v[0]+l[0];
- h[1]= v[1]+l[1];
- h[2]= v[2]+l[2];
- normalize_v3(h);
-
- nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2];
- if (tangent) nh= sasqrt(1.0f - nh*nh);
- else if (nh<0.0f) return 0.0f;
-
- nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2];
- if (tangent) nv= sasqrt(1.0f - nv*nv);
- else if (nv<0.0f) nv= 0.0f;
-
- i= spec(nh, hard);
-
- i= i/(0.1f+nv);
- return i;
-}
-
-/* Blinn spec */
-static float Blinn_Spec(const float n[3], const float l[3], const float v[3], float refrac, float spec_power, int tangent)
-{
- float i, nh, nv, nl, vh, h[3];
- float a, b, c, g=0.0f, p, f, ang;
-
- if (refrac < 1.0f) return 0.0f;
- if (spec_power == 0.0f) return 0.0f;
-
- /* conversion from 'hardness' (1-255) to 'spec_power' (50 maps at 0.1) */
- if (spec_power<100.0f)
- spec_power = sqrtf(1.0f / spec_power);
- else spec_power= 10.0f/spec_power;
-
- h[0]= v[0]+l[0];
- h[1]= v[1]+l[1];
- h[2]= v[2]+l[2];
- normalize_v3(h);
-
- nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */
- if (tangent) nh= sasqrt(1.0f - nh*nh);
- else if (nh<0.0f) return 0.0f;
-
- nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */
- if (tangent) nv= sasqrt(1.0f - nv*nv);
- if (nv<=0.01f) nv= 0.01f; /* hrms... */
-
- nl= n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */
- if (tangent) nl= sasqrt(1.0f - nl*nl);
- if (nl<=0.01f) {
- return 0.0f;
- }
-
- vh= v[0]*h[0]+v[1]*h[1]+v[2]*h[2]; /* Dot product between view vector and half-way vector */
- if (vh<=0.0f) vh= 0.01f;
-
- a = 1.0f;
- b = (2.0f*nh*nv)/vh;
- c = (2.0f*nh*nl)/vh;
-
- if ( a < b && a < c ) g = a;
- else if ( b < a && b < c ) g = b;
- else if ( c < a && c < b ) g = c;
-
- p = sqrt((double)((refrac * refrac)+(vh * vh) - 1.0f));
- f = (((p-vh)*(p-vh))/((p+vh)*(p+vh)))*(1+((((vh*(p+vh))-1.0f)*((vh*(p+vh))-1.0f))/(((vh*(p-vh))+1.0f)*((vh*(p-vh))+1.0f))));
- ang = saacos(nh);
-
- i= f * g * exp((double)(-(ang*ang) / (2.0f*spec_power*spec_power)));
- if (i<0.0f) i= 0.0f;
-
- return i;
-}
-
-/* cartoon render spec */
-static float Toon_Spec(const float n[3], const float l[3], const float v[3], float size, float smooth, int tangent)
-{
- float h[3];
- float ang;
- float rslt;
-
- h[0] = l[0] + v[0];
- h[1] = l[1] + v[1];
- h[2] = l[2] + v[2];
- normalize_v3(h);
-
- rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2];
- if (tangent) rslt = sasqrt(1.0f - rslt*rslt);
-
- ang = saacos( rslt );
-
- if ( ang < size ) rslt = 1.0f;
- else if ( ang >= (size + smooth) || smooth == 0.0f ) rslt = 0.0f;
- else rslt = 1.0f - ((ang - size) / smooth);
-
- return rslt;
-}
-
-/* Ward isotropic gaussian spec */
-static float WardIso_Spec(const float n[3], const float l[3], const float v[3], float rms, int tangent)
-{
- float i, nh, nv, nl, h[3], angle, alpha;
-
-
- /* half-way vector */
- h[0] = l[0] + v[0];
- h[1] = l[1] + v[1];
- h[2] = l[2] + v[2];
- normalize_v3(h);
-
- nh = n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */
- if (tangent) nh = sasqrt(1.0f - nh*nh);
- if (nh<=0.0f) nh = 0.001f;
-
- nv = n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */
- if (tangent) nv = sasqrt(1.0f - nv*nv);
- if (nv<=0.0f) nv = 0.001f;
-
- nl = n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */
- if (tangent) nl = sasqrt(1.0f - nl*nl);
- if (nl<=0.0f) nl = 0.001f;
-
- angle = tanf(saacos(nh));
- alpha = MAX2(rms, 0.001f);
-
- i= nl * (1.0f/(4.0f*(float)M_PI*alpha*alpha)) * (expf( -(angle*angle)/(alpha*alpha))/(sqrtf(nv*nl)));
-
- return i;
-}
-
-/* cartoon render diffuse */
-static float Toon_Diff(const float n[3], const float l[3], const float UNUSED(v[3]), float size, float smooth)
-{
- float rslt, ang;
-
- rslt = n[0]*l[0] + n[1]*l[1] + n[2]*l[2];
-
- ang = saacos(rslt);
-
- if ( ang < size ) rslt = 1.0f;
- else if ( ang >= (size + smooth) || smooth == 0.0f ) rslt = 0.0f;
- else rslt = 1.0f - ((ang - size) / smooth);
-
- return rslt;
-}
-
-/* Oren Nayar diffuse */
-
-/* 'nl' is either dot product, or return value of area light */
-/* in latter case, only last multiplication uses 'nl' */
-static float OrenNayar_Diff(float nl, const float n[3], const float l[3], const float v[3], float rough )
-{
- float i/*, nh*/, nv /*, vh */, realnl, h[3];
- float a, b, t, A, B;
- float Lit_A, View_A, Lit_B[3], View_B[3];
-
- h[0]= v[0]+l[0];
- h[1]= v[1]+l[1];
- h[2]= v[2]+l[2];
- normalize_v3(h);
-
- /* nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; */ /* Dot product between surface normal and half-way vector */
- /* if (nh<0.0f) nh = 0.0f; */
-
- nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */
- if (nv<=0.0f) nv= 0.0f;
-
- realnl= n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */
- if (realnl<=0.0f) return 0.0f;
- if (nl<0.0f) return 0.0f; /* value from area light */
-
- /* vh= v[0]*h[0]+v[1]*h[1]+v[2]*h[2]; */ /* Dot product between view vector and halfway vector */
- /* if (vh<=0.0f) vh= 0.0f; */
-
- Lit_A = saacos(realnl);
- View_A = saacos( nv );
-
- Lit_B[0] = l[0] - (realnl * n[0]);
- Lit_B[1] = l[1] - (realnl * n[1]);
- Lit_B[2] = l[2] - (realnl * n[2]);
- normalize_v3(Lit_B);
-
- View_B[0] = v[0] - (nv * n[0]);
- View_B[1] = v[1] - (nv * n[1]);
- View_B[2] = v[2] - (nv * n[2]);
- normalize_v3(View_B);
-
- t = Lit_B[0]*View_B[0] + Lit_B[1]*View_B[1] + Lit_B[2]*View_B[2];
- if ( t < 0 ) t = 0;
-
- if ( Lit_A > View_A ) {
- a = Lit_A;
- b = View_A;
- }
- else {
- a = View_A;
- b = Lit_A;
- }
-
- A = 1.0f - (0.5f * ((rough * rough) / ((rough * rough) + 0.33f)));
- B = 0.45f * ((rough * rough) / ((rough * rough) + 0.09f));
-
- b*= 0.95f; /* prevent tangens from shooting to inf, 'nl' can be not a dot product here. */
- /* overflow only happens with extreme size area light, and higher roughness */
- i = nl * ( A + ( B * t * sinf(a) * tanf(b) ) );
-
- return i;
-}
-
-/* Minnaert diffuse */
-static float Minnaert_Diff(float nl, const float n[3], const float v[3], float darkness)
-{
- float i, nv;
-
- /* nl = dot product between surface normal and light vector */
- if (nl <= 0.0f)
- return 0.0f;
-
- /* nv = dot product between surface normal and view vector */
- nv = dot_v3v3(n, v);
- if (nv < 0.0f)
- nv = 0.0f;
-
- if (darkness <= 1.0f)
- i = nl * pow(max_ff(nv * nl, 0.1f), (darkness - 1.0f) ); /*The Real model*/
- else
- i = nl * pow( (1.001f - nv), (darkness - 1.0f) ); /*Nvidia model*/
-
- return i;
-}
-
-static float Fresnel_Diff(float *vn, float *lv, float *UNUSED(view), float fac_i, float fac)
-{
- return fresnel_fac(lv, vn, fac_i, fac);
-}
-
-/* --------------------------------------------- */
-/* also called from texture.c */
-void calc_R_ref(ShadeInput *shi)
-{
- float i;
-
- /* shi->vn dot shi->view */
- i= -2*(shi->vn[0]*shi->view[0]+shi->vn[1]*shi->view[1]+shi->vn[2]*shi->view[2]);
-
- shi->ref[0]= (shi->view[0]+i*shi->vn[0]);
- shi->ref[1]= (shi->view[1]+i*shi->vn[1]);
- shi->ref[2]= (shi->view[2]+i*shi->vn[2]);
- if (shi->osatex) {
- if (shi->vlr->flag & R_SMOOTH) {
- i= -2*( (shi->vn[0]+shi->dxno[0])*(shi->view[0]+shi->dxview) +
- (shi->vn[1]+shi->dxno[1])*shi->view[1]+ (shi->vn[2]+shi->dxno[2])*shi->view[2] );
-
- shi->dxref[0]= shi->ref[0]- ( shi->view[0]+shi->dxview+i*(shi->vn[0]+shi->dxno[0]));
- shi->dxref[1]= shi->ref[1]- (shi->view[1]+ i*(shi->vn[1]+shi->dxno[1]));
- shi->dxref[2]= shi->ref[2]- (shi->view[2]+ i*(shi->vn[2]+shi->dxno[2]));
-
- i= -2*( (shi->vn[0]+shi->dyno[0])*shi->view[0]+
- (shi->vn[1]+shi->dyno[1])*(shi->view[1]+shi->dyview)+ (shi->vn[2]+shi->dyno[2])*shi->view[2] );
-
- shi->dyref[0]= shi->ref[0]- (shi->view[0]+ i*(shi->vn[0]+shi->dyno[0]));
- shi->dyref[1]= shi->ref[1]- (shi->view[1]+shi->dyview+i*(shi->vn[1]+shi->dyno[1]));
- shi->dyref[2]= shi->ref[2]- (shi->view[2]+ i*(shi->vn[2]+shi->dyno[2]));
-
- }
- else {
-
- i= -2*( shi->vn[0]*(shi->view[0]+shi->dxview) +
- shi->vn[1]*shi->view[1]+ shi->vn[2]*shi->view[2] );
-
- shi->dxref[0]= shi->ref[0]- (shi->view[0]+shi->dxview+i*shi->vn[0]);
- shi->dxref[1]= shi->ref[1]- (shi->view[1]+ i*shi->vn[1]);
- shi->dxref[2]= shi->ref[2]- (shi->view[2]+ i*shi->vn[2]);
-
- i= -2*( shi->vn[0]*shi->view[0]+
- shi->vn[1]*(shi->view[1]+shi->dyview)+ shi->vn[2]*shi->view[2] );
-
- shi->dyref[0]= shi->ref[0]- (shi->view[0]+ i*shi->vn[0]);
- shi->dyref[1]= shi->ref[1]- (shi->view[1]+shi->dyview+i*shi->vn[1]);
- shi->dyref[2]= shi->ref[2]- (shi->view[2]+ i*shi->vn[2]);
- }
- }
-
-}
-
-/* called from rayshade.c */
-void shade_color(ShadeInput *shi, ShadeResult *shr)
-{
- Material *ma= shi->mat;
-
- if (ma->mode & (MA_VERTEXCOLP)) {
- float neg_alpha = 1.0f - shi->vcol[3];
- shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3];
- shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3];
- shi->b= shi->b*neg_alpha + shi->vcol[2]*shi->vcol[3];
- }
-
- if (ma->texco)
- do_material_tex(shi, &R);
-
- if (ma->fresnel_tra!=0.0f)
- shi->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra);
-
- if (!(shi->mode & MA_TRANSP)) shi->alpha= 1.0f;
-
- shr->diff[0]= shi->r;
- shr->diff[1]= shi->g;
- shr->diff[2]= shi->b;
- shr->alpha= shi->alpha;
-
- /* modulate by the object color */
- if ((ma->shade_flag & MA_OBCOLOR) && shi->obr->ob) {
- float obcol[4];
-
- copy_v4_v4(obcol, shi->obr->ob->col);
- CLAMP(obcol[3], 0.0f, 1.0f);
-
- shr->diff[0] *= obcol[0];
- shr->diff[1] *= obcol[1];
- shr->diff[2] *= obcol[2];
- if (shi->mode & MA_TRANSP) shr->alpha *= obcol[3];
- }
-
- copy_v3_v3(shr->diffshad, shr->diff);
-}
-
-/* ramp for at end of shade */
-static void ramp_diffuse_result(float *diff, ShadeInput *shi)
-{
- Material *ma= shi->mat;
- float col[4];
-
- if (ma->ramp_col) {
- if (ma->rampin_col==MA_RAMP_IN_RESULT) {
- float fac = IMB_colormanagement_get_luminance(diff);
- BKE_colorband_evaluate(ma->ramp_col, fac, col);
-
- /* blending method */
- fac= col[3]*ma->rampfac_col;
-
- ramp_blend(ma->rampblend_col, diff, fac, col);
- }
- }
-}
-
-/* r,g,b denote energy, ramp is used with different values to make new material color */
-static void add_to_diffuse(float diff[3], const ShadeInput *shi, const float is, const float rgb[3])
-{
- Material *ma= shi->mat;
-
- if (ma->ramp_col && (ma->mode & MA_RAMP_COL)) {
-
- /* MA_RAMP_IN_RESULT is exceptional */
- if (ma->rampin_col==MA_RAMP_IN_RESULT) {
- /* normal add */
- diff[0] += rgb[0] * shi->r;
- diff[1] += rgb[1] * shi->g;
- diff[2] += rgb[2] * shi->b;
- }
- else {
- float colt[3], col[4];
- float fac;
-
- /* input */
- switch (ma->rampin_col) {
- case MA_RAMP_IN_ENERGY:
- fac = IMB_colormanagement_get_luminance(rgb);
- break;
- case MA_RAMP_IN_SHADER:
- fac = is;
- break;
- case MA_RAMP_IN_NOR:
- fac = dot_v3v3(shi->view, shi->vn);
- break;
- default:
- fac = 0.0f;
- break;
- }
-
- BKE_colorband_evaluate(ma->ramp_col, fac, col);
-
- /* blending method */
- fac = col[3] * ma->rampfac_col;
- copy_v3_v3(colt, &shi->r);
-
- ramp_blend(ma->rampblend_col, colt, fac, col);
-
- /* output to */
- diff[0] += rgb[0] * colt[0];
- diff[1] += rgb[1] * colt[1];
- diff[2] += rgb[2] * colt[2];
- }
- }
- else {
- diff[0] += rgb[0] * shi->r;
- diff[1] += rgb[1] * shi->g;
- diff[2] += rgb[2] * shi->b;
- }
-}
-
-static void ramp_spec_result(float spec_col[3], ShadeInput *shi)
-{
- Material *ma= shi->mat;
-
- if (ma->ramp_spec && (ma->rampin_spec==MA_RAMP_IN_RESULT)) {
- float col[4];
- float fac = IMB_colormanagement_get_luminance(spec_col);
-
- BKE_colorband_evaluate(ma->ramp_spec, fac, col);
-
- /* blending method */
- fac= col[3]*ma->rampfac_spec;
-
- ramp_blend(ma->rampblend_spec, spec_col, fac, col);
-
- }
-}
-
-/* is = dot product shade, t = spec energy */
-static void do_specular_ramp(ShadeInput *shi, float is, float t, float spec[3])
-{
- Material *ma= shi->mat;
-
- spec[0]= shi->specr;
- spec[1]= shi->specg;
- spec[2]= shi->specb;
-
- /* MA_RAMP_IN_RESULT is exception */
- if (ma->ramp_spec && (ma->rampin_spec!=MA_RAMP_IN_RESULT)) {
- float fac;
- float col[4];
-
- /* input */
- switch (ma->rampin_spec) {
- case MA_RAMP_IN_ENERGY:
- fac= t;
- break;
- case MA_RAMP_IN_SHADER:
- fac= is;
- break;
- case MA_RAMP_IN_NOR:
- fac= shi->view[0]*shi->vn[0] + shi->view[1]*shi->vn[1] + shi->view[2]*shi->vn[2];
- break;
- default:
- fac= 0.0f;
- break;
- }
-
- BKE_colorband_evaluate(ma->ramp_spec, fac, col);
-
- /* blending method */
- fac= col[3]*ma->rampfac_spec;
-
- ramp_blend(ma->rampblend_spec, spec, fac, col);
- }
-}
-
-/* pure AO, check for raytrace and world should have been done */
-/* preprocess, textures were not done, don't use shi->amb for that reason */
-void ambient_occlusion(ShadeInput *shi)
-{
- if ((R.wrld.ao_gather_method == WO_AOGATHER_APPROX) && shi->mat->amb!=0.0f) {
- sample_occ(&R, shi);
- }
- else if ((R.r.mode & R_RAYTRACE) && shi->mat->amb!=0.0f) {
- ray_ao(shi, shi->ao, shi->env);
- }
- else {
- shi->ao[0]= shi->ao[1]= shi->ao[2]= 1.0f;
- zero_v3(shi->env);
- zero_v3(shi->indirect);
- }
-}
-
-
-/* wrld mode was checked for */
-static void ambient_occlusion_apply(ShadeInput *shi, ShadeResult *shr)
-{
- float f= R.wrld.aoenergy;
- float tmp[3], tmpspec[3];
-
- if (!((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX))
- return;
- if (f == 0.0f)
- return;
-
- if (R.wrld.aomix==WO_AOADD) {
- shr->combined[0] += shi->ao[0]*shi->r*shi->refl*f;
- shr->combined[1] += shi->ao[1]*shi->g*shi->refl*f;
- shr->combined[2] += shi->ao[2]*shi->b*shi->refl*f;
- }
- else if (R.wrld.aomix==WO_AOMUL) {
- mul_v3_v3v3(tmp, shr->combined, shi->ao);
- mul_v3_v3v3(tmpspec, shr->spec, shi->ao);
-
- if (f == 1.0f) {
- copy_v3_v3(shr->combined, tmp);
- copy_v3_v3(shr->spec, tmpspec);
- }
- else {
- interp_v3_v3v3(shr->combined, shr->combined, tmp, f);
- interp_v3_v3v3(shr->spec, shr->spec, tmpspec, f);
- }
- }
-}
-
-void environment_lighting_apply(ShadeInput *shi, ShadeResult *shr)
-{
- float f= R.wrld.ao_env_energy*shi->amb;
-
- if (!((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX))
- return;
- if (f == 0.0f)
- return;
-
- shr->combined[0] += shi->env[0]*shi->r*shi->refl*f;
- shr->combined[1] += shi->env[1]*shi->g*shi->refl*f;
- shr->combined[2] += shi->env[2]*shi->b*shi->refl*f;
-}
-
-static void indirect_lighting_apply(ShadeInput *shi, ShadeResult *shr)
-{
- float f= R.wrld.ao_indirect_energy;
-
- if (!((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX))
- return;
- if (f == 0.0f)
- return;
-
- shr->combined[0] += shi->indirect[0]*shi->r*shi->refl*f;
- shr->combined[1] += shi->indirect[1]*shi->g*shi->refl*f;
- shr->combined[2] += shi->indirect[2]*shi->b*shi->refl*f;
-}
-
-/* result written in shadfac */
-void lamp_get_shadow(LampRen *lar, ShadeInput *shi, float inp, float shadfac[4], int do_real)
-{
- LampShadowSubSample *lss= &(lar->shadsamp[shi->thread].s[shi->sample]);
-
- if (do_real || lss->samplenr!=shi->samplenr) {
-
- shadfac[0]= shadfac[1]= shadfac[2]= shadfac[3]= 1.0f;
-
- if (lar->shb) {
- if (lar->buftype==LA_SHADBUF_IRREGULAR)
- shadfac[3]= ISB_getshadow(shi, lar->shb);
- else
- shadfac[3] = testshadowbuf(&R, lar->shb, shi->co, shi->dxco, shi->dyco, inp, shi->mat->lbias);
- }
- else if (lar->mode & LA_SHAD_RAY) {
- ray_shadow(shi, lar, shadfac);
- }
-
- if (shi->depth==0) {
- copy_v4_v4(lss->shadfac, shadfac);
- lss->samplenr= shi->samplenr;
- }
- }
- else {
- copy_v4_v4(shadfac, lss->shadfac);
- }
-}
-
-/* lampdistance and spot angle, writes in lv and dist */
-float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *dist)
-{
- if (lar->type==LA_SUN || lar->type==LA_HEMI) {
- *dist= 1.0f;
- copy_v3_v3(lv, lar->vec);
- return 1.0f;
- }
- else {
- float visifac= 1.0f, visifac_r;
-
- sub_v3_v3v3(lv, co, lar->co);
- mul_v3_fl(lv, 1.0f / (*dist = len_v3(lv)));
-
- /* area type has no quad or sphere option */
- if (lar->type==LA_AREA) {
- /* area is single sided */
- //if (dot_v3v3(lv, lar->vec) > 0.0f)
- // visifac= 1.0f;
- //else
- // visifac= 0.0f;
- }
- else {
- switch (lar->falloff_type) {
- case LA_FALLOFF_CONSTANT:
- visifac = 1.0f;
- break;
- case LA_FALLOFF_INVLINEAR:
- visifac = lar->dist/(lar->dist + dist[0]);
- break;
- case LA_FALLOFF_INVSQUARE:
- /* NOTE: This seems to be a hack since commit r12045 says this
- * option is similar to old Quad, but with slight changes.
- * Correct inv square would be (which would be old Quad):
- * visifac = lar->distkw / (lar->distkw + dist[0]*dist[0]);
- */
- visifac = lar->dist / (lar->dist + dist[0]*dist[0]);
- break;
- case LA_FALLOFF_SLIDERS:
- if (lar->ld1>0.0f)
- visifac= lar->dist/(lar->dist+lar->ld1*dist[0]);
- if (lar->ld2>0.0f)
- visifac*= lar->distkw/(lar->distkw+lar->ld2*dist[0]*dist[0]);
- break;
- case LA_FALLOFF_INVCOEFFICIENTS:
- visifac_r = lar->coeff_const +
- lar->coeff_lin * dist[0] +
- lar->coeff_quad * dist[0] * dist[0];
- if (visifac_r > 0.0)
- visifac = 1.0 / visifac_r;
- else
- visifac = 0.0;
- break;
- case LA_FALLOFF_CURVE:
- /* curvemapping_initialize is called from #add_render_lamp */
- visifac = curvemapping_evaluateF(lar->curfalloff, 0, dist[0]/lar->dist);
- break;
- }
-
- if (lar->mode & LA_SPHERE) {
- float t= lar->dist - dist[0];
- if (t<=0.0f)
- visifac= 0.0f;
- else
- visifac*= t/lar->dist;
- }
-
- if (visifac > 0.0f) {
- if (lar->type==LA_SPOT) {
- float inpr, t;
-
- if (lar->mode & LA_SQUARE) {
- if (dot_v3v3(lv, lar->vec) > 0.0f) {
- float lvrot[3], x;
-
- /* rotate view to lampspace */
- copy_v3_v3(lvrot, lv);
- mul_m3_v3(lar->imat, lvrot);
-
- x = max_ff(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2]));
- /* 1.0f/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */
-
- inpr = 1.0f / (sqrtf(1.0f + x * x));
- }
- else inpr= 0.0f;
- }
- else {
- inpr= lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2];
- }
-
- t= lar->spotsi;
- if (inpr<=t)
- visifac= 0.0f;
- else {
- t= inpr-t;
- if (t<lar->spotbl && lar->spotbl!=0.0f) {
- /* soft area */
- float i= t/lar->spotbl;
- t= i*i;
- inpr*= (3.0f*t-2.0f*t*i);
- }
- visifac*= inpr;
- }
- }
- }
- }
- if (visifac <= 0.001f) visifac = 0.0f;
- return visifac;
- }
-}
-
-/* function returns raw diff, spec and full shadowed diff in the 'shad' pass */
-static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int passflag)
-{
- Material *ma= shi->mat;
- VlakRen *vlr= shi->vlr;
- float lv[3], lampdist, lacol[3], shadfac[4], lashdw[3];
- float i, is, i_noshad, inp, *vn, *view, vnor[3], phongcorr=1.0f;
- float visifac;
-
- vn= shi->vn;
- view= shi->view;
-
-
- if (lar->energy == 0.0f) return;
- /* only shadow lamps shouldn't affect shadow-less materials at all */
- if ((lar->mode & LA_ONLYSHADOW) && (!(ma->mode & MA_SHADOW) || !(R.r.mode & R_SHADOW)))
- return;
- /* optimization, don't render fully black lamps */
- if (!(lar->mode & LA_TEXTURE) && (lar->r + lar->g + lar->b == 0.0f))
- return;
-
- /* lampdist, spot angle, area side, ... */
- visifac= lamp_get_visibility(lar, shi->co, lv, &lampdist);
- if (visifac==0.0f)
- return;
-
- if (lar->type==LA_SPOT) {
- if (lar->mode & LA_OSATEX) {
- shi->osatex= 1; /* signal for multitex() */
-
- shi->dxlv[0]= lv[0] - (shi->co[0]-lar->co[0]+shi->dxco[0])/lampdist;
- shi->dxlv[1]= lv[1] - (shi->co[1]-lar->co[1]+shi->dxco[1])/lampdist;
- shi->dxlv[2]= lv[2] - (shi->co[2]-lar->co[2]+shi->dxco[2])/lampdist;
-
- shi->dylv[0]= lv[0] - (shi->co[0]-lar->co[0]+shi->dyco[0])/lampdist;
- shi->dylv[1]= lv[1] - (shi->co[1]-lar->co[1]+shi->dyco[1])/lampdist;
- shi->dylv[2]= lv[2] - (shi->co[2]-lar->co[2]+shi->dyco[2])/lampdist;
- }
- }
-
- /* lamp color texture */
- lacol[0]= lar->r;
- lacol[1]= lar->g;
- lacol[2]= lar->b;
-
- lashdw[0]= lar->shdwr;
- lashdw[1]= lar->shdwg;
- lashdw[2]= lar->shdwb;
-
- if (lar->mode & LA_TEXTURE) do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE);
- if (lar->mode & LA_SHAD_TEX) do_lamp_tex(lar, lv, shi, lashdw, LA_SHAD_TEX);
-
- /* tangent case; calculate fake face normal, aligned with lampvector */
- /* note, vnor==vn is used as tangent trigger for buffer shadow */
- if (vlr->flag & R_TANGENT) {
- float cross[3], nstrand[3], blend;
-
- if (ma->mode & MA_STR_SURFDIFF) {
- cross_v3_v3v3(cross, shi->surfnor, vn);
- cross_v3_v3v3(nstrand, vn, cross);
-
- blend= dot_v3v3(nstrand, shi->surfnor);
- blend= 1.0f - blend;
- CLAMP(blend, 0.0f, 1.0f);
-
- interp_v3_v3v3(vnor, nstrand, shi->surfnor, blend);
- normalize_v3(vnor);
- }
- else {
- cross_v3_v3v3(cross, lv, vn);
- cross_v3_v3v3(vnor, cross, vn);
- normalize_v3(vnor);
- }
-
- if (ma->strand_surfnor > 0.0f) {
- if (ma->strand_surfnor > shi->surfdist) {
- blend= (ma->strand_surfnor - shi->surfdist)/ma->strand_surfnor;
- interp_v3_v3v3(vnor, vnor, shi->surfnor, blend);
- normalize_v3(vnor);
- }
- }
-
- vnor[0]= -vnor[0];vnor[1]= -vnor[1];vnor[2]= -vnor[2];
- vn= vnor;
- }
- else if (ma->mode & MA_TANGENT_V) {
- float cross[3];
- cross_v3_v3v3(cross, lv, shi->tang);
- cross_v3_v3v3(vnor, cross, shi->tang);
- normalize_v3(vnor);
- vnor[0]= -vnor[0];vnor[1]= -vnor[1];vnor[2]= -vnor[2];
- vn= vnor;
- }
-
- /* dot product and reflectivity */
- /* inp = dotproduct, is = shader result, i = lamp energy (with shadow), i_noshad = i without shadow */
- inp= dot_v3v3(vn, lv);
-
- /* phong threshold to prevent backfacing faces having artifacts on ray shadow (terminator problem) */
- /* this complex construction screams for a nicer implementation! (ton) */
- if (R.r.mode & R_SHADOW) {
- if (ma->mode & MA_SHADOW) {
- if (lar->type == LA_HEMI || lar->type == LA_AREA) {
- /* pass */
- }
- else if ((ma->mode & MA_RAYBIAS) && (lar->mode & LA_SHAD_RAY) && (vlr->flag & R_SMOOTH)) {
- float thresh= shi->obr->ob->smoothresh;
- if (inp>thresh)
- phongcorr= (inp-thresh)/(inp*(1.0f-thresh));
- else
- phongcorr= 0.0f;
- }
- else if (ma->sbias!=0.0f && ((lar->mode & LA_SHAD_RAY) || lar->shb)) {
- if (inp>ma->sbias)
- phongcorr= (inp-ma->sbias)/(inp*(1.0f-ma->sbias));
- else
- phongcorr= 0.0f;
- }
- }
- }
-
- /* diffuse shaders */
- if (lar->mode & LA_NO_DIFF) {
- is = 0.0f; /* skip shaders */
- }
- else if (lar->type==LA_HEMI) {
- is = 0.5f * inp + 0.5f;
- }
- else {
-
- if (lar->type==LA_AREA)
- inp= area_lamp_energy_multisample(lar, shi->co, vn);
-
- /* diffuse shaders (oren nayer gets inp from area light) */
- if (ma->diff_shader==MA_DIFF_ORENNAYAR) is= OrenNayar_Diff(inp, vn, lv, view, ma->roughness);
- else if (ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(vn, lv, view, ma->param[0], ma->param[1]);
- else if (ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(inp, vn, view, ma->darkness);
- else if (ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(vn, lv, view, ma->param[0], ma->param[1]);
- else is= inp; /* Lambert */
- }
-
- /* 'is' is diffuse */
- if ((ma->shade_flag & MA_CUBIC) && is > 0.0f && is < 1.0f) {
- is= 3.0f * is * is - 2.0f * is * is * is; /* nicer termination of shades */
- }
-
- i= is*phongcorr;
-
- if (i>0.0f) {
- i*= visifac*shi->refl;
- }
- i_noshad= i;
-
- vn = shi->vn; /* bring back original vector, we use special specular shaders for tangent */
- if (ma->mode & MA_TANGENT_V)
- vn= shi->tang;
-
- /* init transp shadow */
- shadfac[0]= shadfac[1]= shadfac[2]= shadfac[3]= 1.0f;
-
- /* shadow and spec, (visifac==0 outside spot) */
- if (visifac> 0.0f) {
-
- if ((R.r.mode & R_SHADOW)) {
- if (ma->mode & MA_SHADOW) {
- if (lar->shb || (lar->mode & LA_SHAD_RAY)) {
-
- if (vn==vnor) /* tangent trigger */
- lamp_get_shadow(lar, shi, dot_v3v3(shi->vn, lv), shadfac, shi->depth);
- else
- lamp_get_shadow(lar, shi, inp, shadfac, shi->depth);
-
- /* warning, here it skips the loop */
- if ((lar->mode & LA_ONLYSHADOW) && i>0.0f) {
-
- shadfac[3]= i*lar->energy*(1.0f-shadfac[3]);
- shr->shad[0] -= shadfac[3]*shi->r*(1.0f-lashdw[0]);
- shr->shad[1] -= shadfac[3]*shi->g*(1.0f-lashdw[1]);
- shr->shad[2] -= shadfac[3]*shi->b*(1.0f-lashdw[2]);
-
- if (!(lar->mode & LA_NO_SPEC)) {
- shr->spec[0] -= shadfac[3]*shi->specr*(1.0f-lashdw[0]);
- shr->spec[1] -= shadfac[3]*shi->specg*(1.0f-lashdw[1]);
- shr->spec[2] -= shadfac[3]*shi->specb*(1.0f-lashdw[2]);
- }
-
- return;
- }
-
- i*= shadfac[3];
- shr->shad[3] = shadfac[3]; /* store this for possible check in troublesome cases */
- }
- else {
- shr->shad[3] = 1.0f; /* No shadow at all! */
- }
- }
- }
-
- /* in case 'no diffuse' we still do most calculus, spec can be in shadow.*/
- if (!(lar->mode & LA_NO_DIFF)) {
- if (i>0.0f) {
- if (ma->mode & MA_SHADOW_TRA) {
- const float tcol[3] = {
- i * shadfac[0] * lacol[0],
- i * shadfac[1] * lacol[1],
- i * shadfac[2] * lacol[2],
- };
- add_to_diffuse(shr->shad, shi, is, tcol);
- }
- else {
- const float tcol[3] = {
- i * lacol[0],
- i * lacol[1],
- i * lacol[2],
- };
- add_to_diffuse(shr->shad, shi, is, tcol);
- }
- }
- /* add light for colored shadow */
- if (i_noshad>i && !(lashdw[0]==0 && lashdw[1]==0 && lashdw[2]==0)) {
- const float tcol[3] = {
- lashdw[0] * (i_noshad - i) * lacol[0],
- lashdw[1] * (i_noshad - i) * lacol[1],
- lashdw[2] * (i_noshad - i) * lacol[2],
- };
- add_to_diffuse(shr->shad, shi, is, tcol);
- }
- if (i_noshad>0.0f) {
- if (passflag & (SCE_PASS_DIFFUSE|SCE_PASS_SHADOW) ||
- ((passflag & SCE_PASS_COMBINED) && !(shi->combinedflag & SCE_PASS_SHADOW)))
- {
- const float tcol[3] = {
- i_noshad * lacol[0],
- i_noshad * lacol[1],
- i_noshad * lacol[2]
- };
- add_to_diffuse(shr->diff, shi, is, tcol);
- }
- else {
- copy_v3_v3(shr->diff, shr->shad);
- }
- }
- }
-
- /* specularity */
- shadfac[3]*= phongcorr; /* note, shadfac not allowed to be stored nonlocal */
-
- if (shadfac[3]>0.0f && shi->spec!=0.0f && !(lar->mode & LA_NO_SPEC) && !(lar->mode & LA_ONLYSHADOW)) {
-
- if (!(passflag & (SCE_PASS_COMBINED | SCE_PASS_SPEC))) {
- /* pass */
- }
- else if (lar->type == LA_HEMI) {
- float t;
- /* hemi uses no spec shaders (yet) */
-
- lv[0]+= view[0];
- lv[1]+= view[1];
- lv[2]+= view[2];
-
- normalize_v3(lv);
-
- t= vn[0]*lv[0]+vn[1]*lv[1]+vn[2]*lv[2];
-
- if (lar->type==LA_HEMI) {
- t= 0.5f*t+0.5f;
- }
-
- t= shadfac[3]*shi->spec*spec(t, shi->har);
-
- shr->spec[0]+= t*(lacol[0] * shi->specr);
- shr->spec[1]+= t*(lacol[1] * shi->specg);
- shr->spec[2]+= t*(lacol[2] * shi->specb);
- }
- else {
- /* specular shaders */
- float specfac, t;
-
- if (ma->spec_shader==MA_SPEC_PHONG)
- specfac= Phong_Spec(vn, lv, view, shi->har, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V));
- else if (ma->spec_shader==MA_SPEC_COOKTORR)
- specfac= CookTorr_Spec(vn, lv, view, shi->har, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V));
- else if (ma->spec_shader==MA_SPEC_BLINN)
- specfac= Blinn_Spec(vn, lv, view, ma->refrac, (float)shi->har, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V));
- else if (ma->spec_shader==MA_SPEC_WARDISO)
- specfac= WardIso_Spec( vn, lv, view, ma->rms, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V));
- else
- specfac= Toon_Spec(vn, lv, view, ma->param[2], ma->param[3], (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V));
-
- /* area lamp correction */
- if (lar->type==LA_AREA) specfac*= inp;
-
- t= shadfac[3]*shi->spec*visifac*specfac;
-
- if (ma->mode & MA_RAMP_SPEC) {
- float spec[3];
- do_specular_ramp(shi, specfac, t, spec);
- shr->spec[0]+= t*(lacol[0] * spec[0]);
- shr->spec[1]+= t*(lacol[1] * spec[1]);
- shr->spec[2]+= t*(lacol[2] * spec[2]);
- }
- else {
- shr->spec[0]+= t*(lacol[0] * shi->specr);
- shr->spec[1]+= t*(lacol[1] * shi->specg);
- shr->spec[2]+= t*(lacol[2] * shi->specb);
- }
- }
- }
- }
-}
-
-static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr)
-{
-
- if (R.r.mode & R_SHADOW) {
- ListBase *lights;
- LampRen *lar;
- GroupObject *go;
- float inpr, lv[3];
- float /* *view, */ shadfac[4];
- float ir, accum, visifac, lampdist;
- float shaded = 0.0f, lightness = 0.0f;
-
-
- /* view= shi->view; */ /* UNUSED */
- accum= ir= 0.0f;
-
- lights= get_lights(shi);
- for (go=lights->first; go; go= go->next) {
- lar= go->lampren;
- if (lar==NULL) continue;
-
- if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay)==0) continue;
- if ((lar->lay & shi->lay)==0) continue;
-
- if (lar->shb || (lar->mode & LA_SHAD_RAY)) {
- visifac= lamp_get_visibility(lar, shi->co, lv, &lampdist);
- ir+= 1.0f;
-
- if (visifac <= 0.0f) {
- if (shi->mat->shadowonly_flag == MA_SO_OLD)
- accum+= 1.0f;
-
- continue;
- }
- inpr= dot_v3v3(shi->vn, lv);
- if (inpr <= 0.0f) {
- if (shi->mat->shadowonly_flag == MA_SO_OLD)
- accum+= 1.0f;
-
- continue;
- }
-
- lamp_get_shadow(lar, shi, inpr, shadfac, shi->depth);
-
- if (shi->mat->shadowonly_flag == MA_SO_OLD) {
- /* Old "Shadows Only" */
- accum+= (1.0f-visifac) + (visifac)*IMB_colormanagement_get_luminance(shadfac)*shadfac[3];
- }
- else {
- shaded += IMB_colormanagement_get_luminance(shadfac)*shadfac[3] * visifac * lar->energy;
-
- if (shi->mat->shadowonly_flag == MA_SO_SHADOW) {
- lightness += visifac * lar->energy;
- }
- }
- }
- }
-
- /* Apply shadows as alpha */
- if (ir>0.0f) {
- if (shi->mat->shadowonly_flag == MA_SO_OLD) {
- accum = 1.0f - accum/ir;
- }
- else {
- if (shi->mat->shadowonly_flag == MA_SO_SHADOW) {
- if (lightness > 0.0f) {
- /* Get shadow value from between 0.0f and non-shadowed lightness */
- accum = (lightness - shaded) / (lightness);
- }
- else {
- accum = 0.0f;
- }
- }
- else { /* shadowonly_flag == MA_SO_SHADED */
- /* Use shaded value */
- accum = 1.0f - shaded;
- }
- }
-
- shr->alpha= (shi->alpha)*(accum);
- if (shr->alpha<0.0f) shr->alpha=0.0f;
- }
- else {
- /* If "fully shaded", use full alpha even on areas that have no lights */
- if (shi->mat->shadowonly_flag == MA_SO_SHADED) shr->alpha=shi->alpha;
- else shr->alpha= 0.f;
- }
- }
-
- /* quite disputable this... also note it doesn't mirror-raytrace */
- if ((R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT)) && shi->amb!=0.0f) {
- float f;
-
- if (R.wrld.mode & WO_AMB_OCC) {
- f= R.wrld.aoenergy*shi->amb;
-
- if (R.wrld.aomix==WO_AOADD) {
- if (shi->mat->shadowonly_flag == MA_SO_OLD) {
- f= f*(1.0f - IMB_colormanagement_get_luminance(shi->ao));
- shr->alpha= (shr->alpha + f)*f;
- }
- else {
- shr->alpha -= f*IMB_colormanagement_get_luminance(shi->ao);
- if (shr->alpha<0.0f) shr->alpha=0.0f;
- }
- }
- else /* AO Multiply */
- shr->alpha= (1.0f - f)*shr->alpha + f*(1.0f - (1.0f - shr->alpha)*IMB_colormanagement_get_luminance(shi->ao));
- }
-
- if (R.wrld.mode & WO_ENV_LIGHT) {
- if (shi->mat->shadowonly_flag == MA_SO_OLD) {
- f= R.wrld.ao_env_energy*shi->amb*(1.0f - IMB_colormanagement_get_luminance(shi->env));
- shr->alpha= (shr->alpha + f)*f;
- }
- else {
- f= R.wrld.ao_env_energy*shi->amb;
- shr->alpha -= f*IMB_colormanagement_get_luminance(shi->env);
- if (shr->alpha<0.0f) shr->alpha=0.0f;
- }
- }
- }
-}
-
-/* let's map negative light as if it mirrors positive light, otherwise negative values disappear */
-static void wrld_exposure_correct(float diff[3])
-{
-
- diff[0]= R.wrld.linfac*(1.0f-expf( diff[0]*R.wrld.logfac) );
- diff[1]= R.wrld.linfac*(1.0f-expf( diff[1]*R.wrld.logfac) );
- diff[2]= R.wrld.linfac*(1.0f-expf( diff[2]*R.wrld.logfac) );
-}
-
-void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
-{
- /* Passes which might need to know material color.
- *
- * It seems to be faster to just calculate material color
- * even if the pass doesn't really need it than trying to
- * figure out whether color is really needed or not.
- */
- const int color_passes =
- SCE_PASS_COMBINED | SCE_PASS_RGBA | SCE_PASS_DIFFUSE | SCE_PASS_SPEC |
- SCE_PASS_REFLECT | SCE_PASS_NORMAL | SCE_PASS_REFRACT | SCE_PASS_EMIT | SCE_PASS_SHADOW;
-
- Material *ma= shi->mat;
- int passflag= shi->passflag;
-
- memset(shr, 0, sizeof(ShadeResult));
-
- if (!(shi->mode & MA_TRANSP)) shi->alpha = 1.0f;
-
- /* separate loop */
- if (ma->mode & MA_ONLYSHADOW) {
- shade_lamp_loop_only_shadow(shi, shr);
- return;
- }
-
- /* envmap hack, always reset */
- shi->refcol[0]= shi->refcol[1]= shi->refcol[2]= shi->refcol[3]= 0.0f;
-
- /* material color itself */
- if (passflag & color_passes) {
- if (false) {
- /* pass */
- }
-#ifdef WITH_FREESTYLE
- else if (ma->vcol_alpha) {
- shi->r= shi->vcol[0];
- shi->g= shi->vcol[1];
- shi->b= shi->vcol[2];
- shi->alpha= shi->vcol[3];
- }
-#endif
- else if (ma->mode & (MA_VERTEXCOLP)) {
- float neg_alpha = 1.0f - shi->vcol[3];
- shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3];
- shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3];
- shi->b= shi->b*neg_alpha + shi->vcol[2]*shi->vcol[3];
- }
- if (ma->texco) {
- do_material_tex(shi, &R);
- if (!(shi->mode & MA_TRANSP)) shi->alpha = 1.0f;
- }
-
- shr->col[0]= shi->r*shi->alpha;
- shr->col[1]= shi->g*shi->alpha;
- shr->col[2]= shi->b*shi->alpha;
- shr->col[3]= shi->alpha;
-
- if ((ma->sss_flag & MA_DIFF_SSS) && !sss_pass_done(&R, ma)) {
- if (ma->sss_texfac == 0.0f) {
- shi->r= shi->g= shi->b= shi->alpha= 1.0f;
- shr->col[0]= shr->col[1]= shr->col[2]= shr->col[3]= 1.0f;
- }
- else {
- shi->r= pow(max_ff(shi->r, 0.0f), ma->sss_texfac);
- shi->g= pow(max_ff(shi->g, 0.0f), ma->sss_texfac);
- shi->b= pow(max_ff(shi->b, 0.0f), ma->sss_texfac);
- shi->alpha= pow(max_ff(shi->alpha, 0.0f), ma->sss_texfac);
-
- shr->col[0]= pow(max_ff(shr->col[0], 0.0f), ma->sss_texfac);
- shr->col[1]= pow(max_ff(shr->col[1], 0.0f), ma->sss_texfac);
- shr->col[2]= pow(max_ff(shr->col[2], 0.0f), ma->sss_texfac);
- shr->col[3]= pow(max_ff(shr->col[3], 0.0f), ma->sss_texfac);
- }
- }
- }
-
- if (ma->mode & MA_SHLESS) {
- shr->combined[0]= shi->r;
- shr->combined[1]= shi->g;
- shr->combined[2]= shi->b;
- shr->alpha= shi->alpha;
- goto finally_shadeless;
- }
-
- if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { /* vertexcolor light */
- shr->emit[0]= shi->r*(shi->emit+shi->vcol[0]*shi->vcol[3]);
- shr->emit[1]= shi->g*(shi->emit+shi->vcol[1]*shi->vcol[3]);
- shr->emit[2]= shi->b*(shi->emit+shi->vcol[2]*shi->vcol[3]);
- }
- else {
- shr->emit[0]= shi->r*shi->emit;
- shr->emit[1]= shi->g*shi->emit;
- shr->emit[2]= shi->b*shi->emit;
- }
-
- /* AO pass */
- 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);
- }
- }
-
- /* lighting pass */
- if (passflag & (SCE_PASS_COMBINED|SCE_PASS_DIFFUSE|SCE_PASS_SPEC|SCE_PASS_SHADOW)) {
- GroupObject *go;
- ListBase *lights;
- LampRen *lar;
-
- lights= get_lights(shi);
- for (go=lights->first; go; go= go->next) {
- lar= go->lampren;
- if (lar==NULL) continue;
-
- /* test for lamp layer */
- if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay)==0) continue;
- if ((lar->lay & shi->lay)==0) continue;
-
- /* accumulates in shr->diff and shr->spec and shr->shad (diffuse with shadow!) */
- shade_one_light(lar, shi, shr, passflag);
- }
-
- /* this check is to prevent only shadow lamps from producing negative
- * colors.*/
- if (shr->spec[0] < 0) shr->spec[0] = 0;
- if (shr->spec[1] < 0) shr->spec[1] = 0;
- if (shr->spec[2] < 0) shr->spec[2] = 0;
-
- if (shr->shad[0] < 0) shr->shad[0] = 0;
- if (shr->shad[1] < 0) shr->shad[1] = 0;
- if (shr->shad[2] < 0) shr->shad[2] = 0;
-
- if (ma->sss_flag & MA_DIFF_SSS) {
- float sss[3], col[3], invalpha, texfac= ma->sss_texfac;
-
- /* this will return false in the preprocess stage */
- if (sample_sss(&R, ma, shi->co, sss)) {
- invalpha= (shr->col[3] > FLT_EPSILON)? 1.0f/shr->col[3]: 1.0f;
-
- if (texfac==0.0f) {
- copy_v3_v3(col, shr->col);
- mul_v3_fl(col, invalpha);
- }
- else if (texfac==1.0f) {
- col[0]= col[1]= col[2]= 1.0f;
- mul_v3_fl(col, invalpha);
- }
- else {
- copy_v3_v3(col, shr->col);
- mul_v3_fl(col, invalpha);
- col[0]= pow(max_ff(col[0], 0.0f), 1.0f-texfac);
- col[1]= pow(max_ff(col[1], 0.0f), 1.0f-texfac);
- col[2]= pow(max_ff(col[2], 0.0f), 1.0f-texfac);
- }
-
- shr->diff[0]= sss[0]*col[0];
- shr->diff[1]= sss[1]*col[1];
- shr->diff[2]= sss[2]*col[2];
-
- if (shi->combinedflag & SCE_PASS_SHADOW) {
- shr->shad[0]= shr->diff[0];
- shr->shad[1]= shr->diff[1];
- shr->shad[2]= shr->diff[2];
- }
- }
- }
-
- if (shi->combinedflag & SCE_PASS_SHADOW)
- copy_v3_v3(shr->diffshad, shr->shad);
- else
- copy_v3_v3(shr->diffshad, shr->diff);
-
- copy_v3_v3(shr->combined, shr->diffshad);
-
- /* calculate shadow pass, we use a multiplication mask */
- /* Even if diff = 0,0,0, it does matter what the shadow pass is, since we may want it 'for itself'! */
- if (passflag & SCE_PASS_SHADOW) {
- if (shr->diff[0]!=0.0f) shr->shad[0]= shr->shad[0]/shr->diff[0];
- /* can't determine proper shadow from shad/diff (0/0), so use shadow intensity */
- else if (shr->shad[0]==0.0f) shr->shad[0]= shr->shad[3];
-
- if (shr->diff[1]!=0.0f) shr->shad[1]= shr->shad[1]/shr->diff[1];
- else if (shr->shad[1]==0.0f) shr->shad[1]= shr->shad[3];
-
- if (shr->diff[2]!=0.0f) shr->shad[2]= shr->shad[2]/shr->diff[2];
- else if (shr->shad[2]==0.0f) shr->shad[2]= shr->shad[3];
- }
-
- /* exposure correction */
- if ((R.wrld.exp!=0.0f || R.wrld.range!=1.0f) && !R.sss_points) {
- wrld_exposure_correct(shr->combined); /* has no spec! */
- wrld_exposure_correct(shr->spec);
- }
- }
-
- /* alpha in end, spec can influence it */
- if (passflag & (SCE_PASS_COMBINED)) {
- if ((ma->fresnel_tra!=0.0f) && (shi->mode & MA_TRANSP))
- shi->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra);
-
- /* note: shi->mode! */
- if (shi->mode & MA_TRANSP && (shi->mode & (MA_ZTRANSP|MA_RAYTRANSP))) {
- if (shi->spectra!=0.0f) {
- float t = max_fff(shr->spec[0], shr->spec[1], shr->spec[2]);
- t *= shi->spectra;
- if (t>1.0f) t= 1.0f;
- shi->alpha= (1.0f-t)*shi->alpha+t;
- }
- }
- }
- shr->alpha= shi->alpha;
-
- /* from now stuff everything in shr->combined: ambient, AO, ramps, exposure */
- if (!(ma->sss_flag & MA_DIFF_SSS) || !sss_pass_done(&R, ma)) {
- if (R.r.mode & R_SHADOW) {
- /* add AO in combined? */
- if (R.wrld.mode & WO_AMB_OCC)
- if (shi->combinedflag & SCE_PASS_AO)
- ambient_occlusion_apply(shi, shr);
-
- if (R.wrld.mode & WO_ENV_LIGHT)
- if (shi->combinedflag & SCE_PASS_ENVIRONMENT)
- environment_lighting_apply(shi, shr);
-
- if (R.wrld.mode & WO_INDIRECT_LIGHT)
- if (shi->combinedflag & SCE_PASS_INDIRECT)
- indirect_lighting_apply(shi, shr);
- }
-
- shr->combined[0]+= shi->ambr;
- shr->combined[1]+= shi->ambg;
- shr->combined[2]+= shi->ambb;
-
- if (ma->mode & MA_RAMP_COL) ramp_diffuse_result(shr->combined, shi);
- }
-
- if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shr->spec, shi);
-
- /* refcol is for envmap only */
- if (shi->refcol[0]!=0.0f) {
- float result[3];
-
- result[0]= shi->mirr*shi->refcol[1] + (1.0f - shi->mirr*shi->refcol[0])*shr->combined[0];
- result[1]= shi->mirg*shi->refcol[2] + (1.0f - shi->mirg*shi->refcol[0])*shr->combined[1];
- result[2]= shi->mirb*shi->refcol[3] + (1.0f - shi->mirb*shi->refcol[0])*shr->combined[2];
-
- if (passflag & SCE_PASS_REFLECT)
- sub_v3_v3v3(shr->refl, result, shr->combined);
-
- if (shi->combinedflag & SCE_PASS_REFLECT)
- copy_v3_v3(shr->combined, result);
-
- }
-
- /* and add emit and spec */
- if (shi->combinedflag & SCE_PASS_EMIT)
- add_v3_v3(shr->combined, shr->emit);
- if (shi->combinedflag & SCE_PASS_SPEC)
- add_v3_v3(shr->combined, shr->spec);
-
-
- /* Last section of this function applies to shadeless colors too */
-finally_shadeless:
-
- /* modulate by the object color */
- if ((ma->shade_flag & MA_OBCOLOR) && shi->obr->ob) {
- if (!(ma->sss_flag & MA_DIFF_SSS) || !sss_pass_done(&R, ma)) {
- float obcol[4];
-
- copy_v4_v4(obcol, shi->obr->ob->col);
- CLAMP(obcol[3], 0.0f, 1.0f);
-
- shr->combined[0] *= obcol[0];
- shr->combined[1] *= obcol[1];
- shr->combined[2] *= obcol[2];
- if (shi->mode & MA_TRANSP) shr->alpha *= obcol[3];
- }
- }
-
- shr->combined[3]= shr->alpha;
-}
-
-/* used for "Lamp Data" shader node */
-static float lamp_get_data_internal(ShadeInput *shi, GroupObject *go, float col[4], float lv[3], float *dist, float shadow[4])
-{
- LampRen *lar = go->lampren;
- float visifac, inp;
-
- if (!lar
- || ((lar->mode & LA_LAYER) && (lar->lay & shi->obi->lay) == 0)
- || (lar->lay & shi->lay) == 0)
- return 0.0f;
-
- if (lar->mode & LA_TEXTURE)
- do_lamp_tex(lar, lv, shi, col, LA_TEXTURE);
-
- visifac = lamp_get_visibility(lar, shi->co, lv, dist);
-
- if (visifac == 0.0f
- || lar->type == LA_HEMI
- || (lar->type != LA_SPOT && !(lar->mode & LA_SHAD_RAY))
- || (R.r.scemode & R_BUTS_PREVIEW))
- return visifac;
-
- inp = dot_v3v3(shi->vn, lv);
-
- if (inp > 0.0f) {
- float shadfac[4];
-
- shadow[0] = lar->shdwr;
- shadow[1] = lar->shdwg;
- shadow[2] = lar->shdwb;
-
- if (lar->mode & LA_SHAD_TEX)
- do_lamp_tex(lar, lv, shi, shadow, LA_SHAD_TEX);
-
- if (R.r.mode & R_SHADOW) {
- lamp_get_shadow(lar, shi, inp, shadfac, shi->depth);
-
- shadow[0] = 1.0f - ((1.0f - shadfac[0] * shadfac[3]) * (1.0f - shadow[0]));
- shadow[1] = 1.0f - ((1.0f - shadfac[1] * shadfac[3]) * (1.0f - shadow[1]));
- shadow[2] = 1.0f - ((1.0f - shadfac[2] * shadfac[3]) * (1.0f - shadow[2]));
- }
- }
-
- return visifac;
-}
-
-float RE_lamp_get_data(ShadeInput *shi, Object *lamp_obj, float col[4], float lv[3], float *dist, float shadow[4])
-{
- col[0] = col[1] = col[2] = 0.0f;
- col[3] = 1.0f;
- copy_v3_v3(lv, shi->vn);
- *dist = 1.0f;
- shadow[0] = shadow[1] = shadow[2] = shadow[3] = 1.0f;
-
- if (lamp_obj->type == OB_LAMP) {
- GroupObject *go;
- Lamp *lamp = (Lamp *)lamp_obj->data;
-
- col[0] = lamp->r * lamp->energy;
- col[1] = lamp->g * lamp->energy;
- col[2] = lamp->b * lamp->energy;
-
- if (R.r.scemode & R_BUTS_PREVIEW) {
- for (go = R.lights.first; go; go = go->next) {
- /* "Lamp.002" is main key light of material preview */
- if (STREQ(go->ob->id.name + 2, "Lamp.002"))
- return lamp_get_data_internal(shi, go, col, lv, dist, shadow);
- }
- return 0.0f;
- }
-
- if (shi->mat && shi->mat->group) {
- for (go = shi->mat->group->gobject.first; go; go = go->next) {
- if (go->ob == lamp_obj)
- return lamp_get_data_internal(shi, go, col, lv, dist, shadow);
- }
- }
-
- for (go = R.lights.first; go; go = go->next) {
- if (go->ob == lamp_obj)
- return lamp_get_data_internal(shi, go, col, lv, dist, shadow);
- }
- }
-
- return 0.0f;
-}
-
-const float (*RE_object_instance_get_matrix(struct ObjectInstanceRen *obi, int matrix_id))[4]
-{
- if (obi) {
- switch (matrix_id) {
- case RE_OBJECT_INSTANCE_MATRIX_OB:
- return (const float(*)[4])obi->obmat;
- case RE_OBJECT_INSTANCE_MATRIX_OBINV:
- return (const float(*)[4])obi->obinvmat;
- case RE_OBJECT_INSTANCE_MATRIX_LOCALTOVIEW:
- return (const float(*)[4])obi->localtoviewmat;
- case RE_OBJECT_INSTANCE_MATRIX_LOCALTOVIEWINV:
- return (const float(*)[4])obi->localtoviewinvmat;
- }
- }
- return NULL;
-}
-
-float RE_object_instance_get_object_pass_index(struct ObjectInstanceRen *obi)
-{
- return obi->ob->index;
-}
-
-float RE_object_instance_get_random_id(struct ObjectInstanceRen *obi)
-{
- return obi->random_id;
-}
-
-const float (*RE_render_current_get_matrix(int matrix_id))[4]
-{
- switch (matrix_id) {
- case RE_VIEW_MATRIX:
- return (const float(*)[4])R.viewmat;
- case RE_VIEWINV_MATRIX:
- return (const float(*)[4])R.viewinv;
- }
- return NULL;
-}
-
-float RE_fresnel_dielectric(float incoming[3], float normal[3], float eta)
-{
- /* compute fresnel reflectance without explicitly computing
- * the refracted direction */
- float c = fabs(dot_v3v3(incoming, normal));
- float g = eta * eta - 1.0 + c * c;
- float result;
-
- if (g > 0.0) {
- g = sqrtf(g);
- float A = (g - c) / (g + c);
- float B = (c * (g + c) - 1.0) / (c * (g - c) + 1.0);
- result = 0.5 * A * A * (1.0 + B * B);
- }
- else {
- result = 1.0; /* TIR (no refracted component) */
- }
-
- return result;
-}
diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c
deleted file mode 100644
index c29da9b17c6..00000000000
--- a/source/blender/render/intern/source/sss.c
+++ /dev/null
@@ -1,1074 +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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/sss.c
- * \ingroup render
- */
-
-/* Possible Improvements:
- * - add fresnel terms
- * - adapt Rd table to scale, now with small scale there are a lot of misses?
- * - possible interesting method: perform sss on all samples in the tree,
- * and then use those values interpolated somehow later. can also do this
- * filtering on demand for speed. since we are doing things in screen
- * space now there is an exact correspondence
- * - avoid duplicate shading (filtering points in advance, irradiance cache
- * like lookup?)
- * - lower resolution samples
- */
-
-#include <math.h>
-#include <string.h>
-#include <stdio.h>
-#include <string.h>
-
-/* external modules: */
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-#include "BLI_memarena.h"
-
-#include "BLT_translation.h"
-
-
-#include "DNA_material_types.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_scene.h"
-
-
-/* this module */
-#include "render_types.h"
-#include "sss.h"
-
-/* Generic Multiple Scattering API */
-
-/* Relevant papers:
- * [1] A Practical Model for Subsurface Light Transport
- * [2] A Rapid Hierarchical Rendering Technique for Translucent Materials
- * [3] Efficient Rendering of Local Subsurface Scattering
- * [4] Implementing a skin BSSRDF (or several...)
- */
-
-/* Defines */
-
-#define RD_TABLE_RANGE 100.0f
-#define RD_TABLE_RANGE_2 10000.0f
-#define RD_TABLE_SIZE 10000
-
-#define MAX_OCTREE_NODE_POINTS 8
-#define MAX_OCTREE_DEPTH 15
-
-/* Struct Definitions */
-
-struct ScatterSettings {
- float eta; /* index of refraction */
- float sigma_a; /* absorption coefficient */
- float sigma_s_; /* reduced scattering coefficient */
- float sigma_t_; /* reduced extinction coefficient */
- float sigma; /* effective extinction coefficient */
- float Fdr; /* diffuse fresnel reflectance */
- float D; /* diffusion constant */
- float A;
- float alpha_; /* reduced albedo */
- float zr; /* distance of virtual lightsource above surface */
- float zv; /* distance of virtual lightsource below surface */
- float ld; /* mean free path */
- float ro; /* diffuse reflectance */
- float color;
- float invsigma_t_;
- float frontweight;
- float backweight;
-
- float *tableRd; /* lookup table to avoid computing Rd */
- float *tableRd2; /* lookup table to avoid computing Rd for bigger values */
-};
-
-typedef struct ScatterPoint {
- float co[3];
- float rad[3];
- float area;
- int back;
-} ScatterPoint;
-
-typedef struct ScatterNode {
- float co[3];
- float rad[3];
- float backrad[3];
- float area, backarea;
-
- int totpoint;
- ScatterPoint *points;
-
- float split[3];
- struct ScatterNode *child[8];
-} ScatterNode;
-
-struct ScatterTree {
- MemArena *arena;
-
- ScatterSettings *ss[3];
- float error, scale;
-
- ScatterNode *root;
- ScatterPoint *points;
- ScatterPoint **refpoints;
- ScatterPoint **tmppoints;
- int totpoint;
- float min[3], max[3];
-};
-
-typedef struct ScatterResult {
- float rad[3];
- float backrad[3];
- float rdsum[3];
- float backrdsum[3];
-} ScatterResult;
-
-/* Functions for BSSRDF reparametrization in to more intuitive parameters,
- * see [2] section 4 for more info. */
-
-static float f_Rd(float alpha_, float A, float ro)
-{
- float sq;
-
- sq = sqrtf(3.0f * (1.0f - alpha_));
- return (alpha_/2.0f)*(1.0f + expf((-4.0f/3.0f)*A*sq))*expf(-sq) - ro;
-}
-
-static float compute_reduced_albedo(ScatterSettings *ss)
-{
- const float tolerance= 1e-8;
- const int max_iteration_count= 20;
- float d, fsub, xn_1= 0.0f, xn= 1.0f, fxn, fxn_1;
- int i;
-
- /* use secant method to compute reduced albedo using Rd function inverse
- * with a given reflectance */
- fxn= f_Rd(xn, ss->A, ss->ro);
- fxn_1= f_Rd(xn_1, ss->A, ss->ro);
-
- for (i= 0; i < max_iteration_count; i++) {
- fsub= (fxn - fxn_1);
- if (fabsf(fsub) < tolerance)
- break;
- d= ((xn - xn_1)/fsub)*fxn;
- if (fabsf(d) < tolerance)
- break;
-
- xn_1= xn;
- fxn_1= fxn;
- xn= xn - d;
-
- if (xn > 1.0f) xn= 1.0f;
- if (xn_1 > 1.0f) xn_1= 1.0f;
-
- fxn= f_Rd(xn, ss->A, ss->ro);
- }
-
- /* avoid division by zero later */
- if (xn <= 0.0f)
- xn= 0.00001f;
-
- return xn;
-}
-
-/* Exponential falloff functions */
-
-static float Rd_rsquare(ScatterSettings *ss, float rr)
-{
- float sr, sv, Rdr, Rdv;
-
- sr = sqrtf(rr + ss->zr * ss->zr);
- sv = sqrtf(rr + ss->zv * ss->zv);
-
- Rdr= ss->zr*(1.0f + ss->sigma*sr)*expf(-ss->sigma*sr)/(sr*sr*sr);
- Rdv= ss->zv*(1.0f + ss->sigma*sv)*expf(-ss->sigma*sv)/(sv*sv*sv);
-
- return /*ss->alpha_*/(1.0f/(4.0f*(float)M_PI))*(Rdr + Rdv);
-}
-
-static float Rd(ScatterSettings *ss, float r)
-{
- return Rd_rsquare(ss, r*r);
-}
-
-/* table lookups for Rd. this avoids expensive exp calls. we use two
- * separate tables as well for lower and higher numbers to improve
- * precision, since the number are poorly distributed because we do
- * a lookup with the squared distance for smaller distances, saving
- * another sqrt. */
-
-static void approximate_Rd_rgb(ScatterSettings **ss, float rr, float *rd)
-{
- float indexf, t, idxf;
- int index;
-
- if (rr > (RD_TABLE_RANGE_2 * RD_TABLE_RANGE_2)) {
- /* pass */
- }
- else if (rr > RD_TABLE_RANGE) {
- rr = sqrtf(rr);
- indexf= rr*(RD_TABLE_SIZE/RD_TABLE_RANGE_2);
- index= (int)indexf;
- idxf= (float)index;
- t= indexf - idxf;
-
- if (index >= 0 && index < RD_TABLE_SIZE) {
- rd[0]= (ss[0]->tableRd2[index]*(1-t) + ss[0]->tableRd2[index+1]*t);
- rd[1]= (ss[1]->tableRd2[index]*(1-t) + ss[1]->tableRd2[index+1]*t);
- rd[2]= (ss[2]->tableRd2[index]*(1-t) + ss[2]->tableRd2[index+1]*t);
- return;
- }
- }
- else {
- indexf= rr*(RD_TABLE_SIZE/RD_TABLE_RANGE);
- index= (int)indexf;
- idxf= (float)index;
- t= indexf - idxf;
-
- if (index >= 0 && index < RD_TABLE_SIZE) {
- rd[0]= (ss[0]->tableRd[index]*(1-t) + ss[0]->tableRd[index+1]*t);
- rd[1]= (ss[1]->tableRd[index]*(1-t) + ss[1]->tableRd[index+1]*t);
- rd[2]= (ss[2]->tableRd[index]*(1-t) + ss[2]->tableRd[index+1]*t);
- return;
- }
- }
-
- /* fallback to slow Rd computation */
- rd[0]= Rd_rsquare(ss[0], rr);
- rd[1]= Rd_rsquare(ss[1], rr);
- rd[2]= Rd_rsquare(ss[2], rr);
-}
-
-static void build_Rd_table(ScatterSettings *ss)
-{
- float r;
- int i, size = RD_TABLE_SIZE+1;
-
- ss->tableRd= MEM_mallocN(sizeof(float)*size, "scatterTableRd");
- ss->tableRd2= MEM_mallocN(sizeof(float)*size, "scatterTableRd");
-
- for (i= 0; i < size; i++) {
- r= i*(RD_TABLE_RANGE/RD_TABLE_SIZE);
-#if 0
- if (r < ss->invsigma_t_*ss->invsigma_t_) {
- r= ss->invsigma_t_*ss->invsigma_t_;
- }
-#endif
- ss->tableRd[i]= Rd(ss, sqrtf(r));
-
- r= i*(RD_TABLE_RANGE_2/RD_TABLE_SIZE);
-#if 0
- if (r < ss->invsigma_t_) {
- r= ss->invsigma_t_;
- }
-#endif
- ss->tableRd2[i]= Rd(ss, r);
- }
-}
-
-ScatterSettings *scatter_settings_new(float refl, float radius, float ior, float reflfac, float frontweight, float backweight)
-{
- ScatterSettings *ss;
-
- ss= MEM_callocN(sizeof(ScatterSettings), "ScatterSettings");
-
- /* see [1] and [3] for these formulas */
- ss->eta= ior;
- ss->Fdr= -1.440f/ior*ior + 0.710f/ior + 0.668f + 0.0636f*ior;
- ss->A= (1.0f + ss->Fdr)/(1.0f - ss->Fdr);
- ss->ld= radius;
- ss->ro= min_ff(refl, 0.99f);
- ss->color= ss->ro*reflfac + (1.0f-reflfac);
-
- ss->alpha_= compute_reduced_albedo(ss);
-
- ss->sigma= 1.0f/ss->ld;
- ss->sigma_t_= ss->sigma/sqrtf(3.0f*(1.0f - ss->alpha_));
- ss->sigma_s_= ss->alpha_*ss->sigma_t_;
- ss->sigma_a= ss->sigma_t_ - ss->sigma_s_;
-
- ss->D= 1.0f/(3.0f*ss->sigma_t_);
-
- ss->zr= 1.0f/ss->sigma_t_;
- ss->zv= ss->zr + 4.0f*ss->A*ss->D;
-
- ss->invsigma_t_= 1.0f/ss->sigma_t_;
-
- ss->frontweight= frontweight;
- ss->backweight= backweight;
-
- /* precompute a table of Rd values for quick lookup */
- build_Rd_table(ss);
-
- return ss;
-}
-
-void scatter_settings_free(ScatterSettings *ss)
-{
- MEM_freeN(ss->tableRd);
- MEM_freeN(ss->tableRd2);
- MEM_freeN(ss);
-}
-
-/* Hierarchical method as in [2]. */
-
-/* traversal */
-
-#define SUBNODE_INDEX(co, split) \
- ((co[0]>=split[0]) + (co[1]>=split[1])*2 + (co[2]>=split[2])*4)
-
-static void add_radiance(ScatterTree *tree, float *frontrad, float *backrad, float area, float backarea, float rr, ScatterResult *result)
-{
- float rd[3], frontrd[3], backrd[3];
-
- approximate_Rd_rgb(tree->ss, rr, rd);
-
- if (frontrad && area) {
- frontrd[0] = rd[0]*area;
- frontrd[1] = rd[1]*area;
- frontrd[2] = rd[2]*area;
-
- result->rad[0] += frontrad[0]*frontrd[0];
- result->rad[1] += frontrad[1]*frontrd[1];
- result->rad[2] += frontrad[2]*frontrd[2];
-
- result->rdsum[0] += frontrd[0];
- result->rdsum[1] += frontrd[1];
- result->rdsum[2] += frontrd[2];
- }
- if (backrad && backarea) {
- backrd[0] = rd[0]*backarea;
- backrd[1] = rd[1]*backarea;
- backrd[2] = rd[2]*backarea;
-
- result->backrad[0] += backrad[0]*backrd[0];
- result->backrad[1] += backrad[1]*backrd[1];
- result->backrad[2] += backrad[2]*backrd[2];
-
- result->backrdsum[0] += backrd[0];
- result->backrdsum[1] += backrd[1];
- result->backrdsum[2] += backrd[2];
- }
-}
-
-static void traverse_octree(ScatterTree *tree, ScatterNode *node, const float co[3], int self, ScatterResult *result)
-{
- float sub[3], dist;
- int i, index = 0;
-
- if (node->totpoint > 0) {
- /* leaf - add radiance from all samples */
- for (i=0; i<node->totpoint; i++) {
- ScatterPoint *p= &node->points[i];
-
- sub_v3_v3v3(sub, co, p->co);
- dist= dot_v3v3(sub, sub);
-
- if (p->back)
- add_radiance(tree, NULL, p->rad, 0.0f, p->area, dist, result);
- else
- add_radiance(tree, p->rad, NULL, p->area, 0.0f, dist, result);
- }
- }
- else {
- /* branch */
- if (self)
- index = SUBNODE_INDEX(co, node->split);
-
- for (i=0; i<8; i++) {
- if (node->child[i]) {
- ScatterNode *subnode= node->child[i];
-
- if (self && index == i) {
- /* always traverse node containing the point */
- traverse_octree(tree, subnode, co, 1, result);
- }
- else {
- /* decide subnode traversal based on maximum solid angle */
- sub_v3_v3v3(sub, co, subnode->co);
- dist= dot_v3v3(sub, sub);
-
- /* actually area/dist > error, but this avoids division */
- if (subnode->area+subnode->backarea>tree->error*dist) {
- traverse_octree(tree, subnode, co, 0, result);
- }
- else {
- add_radiance(tree, subnode->rad, subnode->backrad,
- subnode->area, subnode->backarea, dist, result);
- }
- }
- }
- }
- }
-}
-
-static void compute_radiance(ScatterTree *tree, const float co[3], float *rad)
-{
- ScatterResult result;
- float rdsum[3], backrad[3], backrdsum[3];
-
- memset(&result, 0, sizeof(result));
-
- traverse_octree(tree, tree->root, co, 1, &result);
-
- /* the original paper doesn't do this, but we normalize over the
- * sampled area and multiply with the reflectance. this is because
- * our point samples are incomplete, there are no samples on parts
- * of the mesh not visible from the camera. this can not only make
- * it darker, but also lead to ugly color shifts */
-
- mul_v3_fl(result.rad, tree->ss[0]->frontweight);
- mul_v3_fl(result.backrad, tree->ss[0]->backweight);
-
- copy_v3_v3(rad, result.rad);
- add_v3_v3v3(backrad, result.rad, result.backrad);
-
- copy_v3_v3(rdsum, result.rdsum);
- add_v3_v3v3(backrdsum, result.rdsum, result.backrdsum);
-
- if (rdsum[0] > 1e-16f) rad[0]= tree->ss[0]->color*rad[0]/rdsum[0];
- if (rdsum[1] > 1e-16f) rad[1]= tree->ss[1]->color*rad[1]/rdsum[1];
- if (rdsum[2] > 1e-16f) rad[2]= tree->ss[2]->color*rad[2]/rdsum[2];
-
- if (backrdsum[0] > 1e-16f) backrad[0]= tree->ss[0]->color*backrad[0]/backrdsum[0];
- if (backrdsum[1] > 1e-16f) backrad[1]= tree->ss[1]->color*backrad[1]/backrdsum[1];
- if (backrdsum[2] > 1e-16f) backrad[2]= tree->ss[2]->color*backrad[2]/backrdsum[2];
-
- rad[0]= MAX2(rad[0], backrad[0]);
- rad[1]= MAX2(rad[1], backrad[1]);
- rad[2]= MAX2(rad[2], backrad[2]);
-}
-
-/* building */
-
-static void sum_leaf_radiance(ScatterTree *UNUSED(tree), ScatterNode *node)
-{
- ScatterPoint *p;
- float rad, totrad= 0.0f, inv;
- int i;
-
- node->co[0]= node->co[1]= node->co[2]= 0.0;
- node->rad[0]= node->rad[1]= node->rad[2]= 0.0;
- node->backrad[0]= node->backrad[1]= node->backrad[2]= 0.0;
-
- /* compute total rad, rad weighted average position,
- * and total area */
- for (i=0; i<node->totpoint; i++) {
- p= &node->points[i];
-
- rad= p->area*fabsf(p->rad[0] + p->rad[1] + p->rad[2]);
- totrad += rad;
-
- node->co[0] += rad*p->co[0];
- node->co[1] += rad*p->co[1];
- node->co[2] += rad*p->co[2];
-
- if (p->back) {
- node->backrad[0] += p->rad[0]*p->area;
- node->backrad[1] += p->rad[1]*p->area;
- node->backrad[2] += p->rad[2]*p->area;
-
- node->backarea += p->area;
- }
- else {
- node->rad[0] += p->rad[0]*p->area;
- node->rad[1] += p->rad[1]*p->area;
- node->rad[2] += p->rad[2]*p->area;
-
- node->area += p->area;
- }
- }
-
- if (node->area > 1e-16f) {
- inv= 1.0f/node->area;
- node->rad[0] *= inv;
- node->rad[1] *= inv;
- node->rad[2] *= inv;
- }
- if (node->backarea > 1e-16f) {
- inv= 1.0f/node->backarea;
- node->backrad[0] *= inv;
- node->backrad[1] *= inv;
- node->backrad[2] *= inv;
- }
-
- if (totrad > 1e-16f) {
- inv= 1.0f/totrad;
- node->co[0] *= inv;
- node->co[1] *= inv;
- node->co[2] *= inv;
- }
- else {
- /* make sure that if radiance is 0.0f, we still have these points in
- * the tree at a good position, they count for rdsum too */
- for (i=0; i<node->totpoint; i++) {
- p= &node->points[i];
-
- node->co[0] += p->co[0];
- node->co[1] += p->co[1];
- node->co[2] += p->co[2];
- }
-
- node->co[0] /= node->totpoint;
- node->co[1] /= node->totpoint;
- node->co[2] /= node->totpoint;
- }
-}
-
-static void sum_branch_radiance(ScatterTree *UNUSED(tree), ScatterNode *node)
-{
- ScatterNode *subnode;
- float rad, totrad= 0.0f, inv;
- int i, totnode;
-
- node->co[0]= node->co[1]= node->co[2]= 0.0;
- node->rad[0]= node->rad[1]= node->rad[2]= 0.0;
- node->backrad[0]= node->backrad[1]= node->backrad[2]= 0.0;
-
- /* compute total rad, rad weighted average position,
- * and total area */
- for (i=0; i<8; i++) {
- if (node->child[i] == NULL)
- continue;
-
- subnode= node->child[i];
-
- rad= subnode->area*fabsf(subnode->rad[0] + subnode->rad[1] + subnode->rad[2]);
- rad += subnode->backarea*fabsf(subnode->backrad[0] + subnode->backrad[1] + subnode->backrad[2]);
- totrad += rad;
-
- node->co[0] += rad*subnode->co[0];
- node->co[1] += rad*subnode->co[1];
- node->co[2] += rad*subnode->co[2];
-
- node->rad[0] += subnode->rad[0]*subnode->area;
- node->rad[1] += subnode->rad[1]*subnode->area;
- node->rad[2] += subnode->rad[2]*subnode->area;
-
- node->backrad[0] += subnode->backrad[0]*subnode->backarea;
- node->backrad[1] += subnode->backrad[1]*subnode->backarea;
- node->backrad[2] += subnode->backrad[2]*subnode->backarea;
-
- node->area += subnode->area;
- node->backarea += subnode->backarea;
- }
-
- if (node->area > 1e-16f) {
- inv= 1.0f/node->area;
- node->rad[0] *= inv;
- node->rad[1] *= inv;
- node->rad[2] *= inv;
- }
- if (node->backarea > 1e-16f) {
- inv= 1.0f/node->backarea;
- node->backrad[0] *= inv;
- node->backrad[1] *= inv;
- node->backrad[2] *= inv;
- }
-
- if (totrad > 1e-16f) {
- inv= 1.0f/totrad;
- node->co[0] *= inv;
- node->co[1] *= inv;
- node->co[2] *= inv;
- }
- else {
- /* make sure that if radiance is 0.0f, we still have these points in
- * the tree at a good position, they count for rdsum too */
- totnode= 0;
-
- for (i=0; i<8; i++) {
- if (node->child[i]) {
- subnode= node->child[i];
-
- node->co[0] += subnode->co[0];
- node->co[1] += subnode->co[1];
- node->co[2] += subnode->co[2];
-
- totnode++;
- }
- }
-
- node->co[0] /= totnode;
- node->co[1] /= totnode;
- node->co[2] /= totnode;
- }
-}
-
-static void sum_radiance(ScatterTree *tree, ScatterNode *node)
-{
- if (node->totpoint > 0) {
- sum_leaf_radiance(tree, node);
- }
- else {
- int i;
-
- for (i=0; i<8; i++)
- if (node->child[i])
- sum_radiance(tree, node->child[i]);
-
- sum_branch_radiance(tree, node);
- }
-}
-
-static void subnode_middle(int i, float *mid, float *subsize, float *submid)
-{
- int x= i & 1, y= i & 2, z= i & 4;
-
- submid[0]= mid[0] + ((x)? subsize[0]: -subsize[0]);
- submid[1]= mid[1] + ((y)? subsize[1]: -subsize[1]);
- submid[2]= mid[2] + ((z)? subsize[2]: -subsize[2]);
-}
-
-static void create_octree_node(ScatterTree *tree, ScatterNode *node, float *mid, float *size, ScatterPoint **refpoints, int depth)
-{
- ScatterNode *subnode;
- ScatterPoint **subrefpoints, **tmppoints= tree->tmppoints;
- int index, nsize[8], noffset[8], i, subco, used_nodes, usedi;
- float submid[3], subsize[3];
-
- /* stopping condition */
- if (node->totpoint <= MAX_OCTREE_NODE_POINTS || depth == MAX_OCTREE_DEPTH) {
- for (i=0; i<node->totpoint; i++)
- node->points[i]= *(refpoints[i]);
-
- return;
- }
-
- subsize[0]= size[0]*0.5f;
- subsize[1]= size[1]*0.5f;
- subsize[2]= size[2]*0.5f;
-
- node->split[0]= mid[0];
- node->split[1]= mid[1];
- node->split[2]= mid[2];
-
- memset(nsize, 0, sizeof(nsize));
- memset(noffset, 0, sizeof(noffset));
-
- /* count points in subnodes */
- for (i=0; i<node->totpoint; i++) {
- index= SUBNODE_INDEX(refpoints[i]->co, node->split);
- tmppoints[i]= refpoints[i];
- nsize[index]++;
- }
-
- /* here we check if only one subnode is used. if this is the case, we don't
- * create a new node, but rather call this function again, with different
- * size and middle position for the same node. */
- for (usedi=0, used_nodes=0, i=0; i<8; i++) {
- if (nsize[i]) {
- used_nodes++;
- usedi = i;
- }
- if (i != 0)
- noffset[i]= noffset[i-1]+nsize[i-1];
- }
-
- if (used_nodes <= 1) {
- subnode_middle(usedi, mid, subsize, submid);
- create_octree_node(tree, node, submid, subsize, refpoints, depth+1);
- return;
- }
-
- /* reorder refpoints by subnode */
- for (i=0; i<node->totpoint; i++) {
- index= SUBNODE_INDEX(tmppoints[i]->co, node->split);
- refpoints[noffset[index]]= tmppoints[i];
- noffset[index]++;
- }
-
- /* create subnodes */
- for (subco=0, i=0; i<8; subco+=nsize[i], i++) {
- if (nsize[i] > 0) {
- subnode= BLI_memarena_alloc(tree->arena, sizeof(ScatterNode));
- node->child[i]= subnode;
- subnode->points= node->points + subco;
- subnode->totpoint= nsize[i];
- subrefpoints= refpoints + subco;
-
- subnode_middle(i, mid, subsize, submid);
-
- create_octree_node(tree, subnode, submid, subsize, subrefpoints,
- depth+1);
- }
- else
- node->child[i]= NULL;
- }
-
- node->points= NULL;
- node->totpoint= 0;
-}
-
-/* public functions */
-
-ScatterTree *scatter_tree_new(ScatterSettings *ss[3], float scale, float error,
- float (*co)[3], float (*color)[3], float *area, int totpoint)
-{
- ScatterTree *tree;
- ScatterPoint *points, **refpoints;
- int i;
-
- /* allocate tree */
- tree= MEM_callocN(sizeof(ScatterTree), "ScatterTree");
- tree->scale= scale;
- tree->error= error;
- tree->totpoint= totpoint;
-
- tree->ss[0]= ss[0];
- tree->ss[1]= ss[1];
- tree->ss[2]= ss[2];
-
- points = MEM_callocN(sizeof(ScatterPoint) * totpoint, "ScatterPoints");
- refpoints = MEM_callocN(sizeof(ScatterPoint *) * totpoint, "ScatterRefPoints");
-
- tree->points= points;
- tree->refpoints= refpoints;
-
- /* build points */
- INIT_MINMAX(tree->min, tree->max);
-
- for (i=0; i<totpoint; i++) {
- copy_v3_v3(points[i].co, co[i]);
- copy_v3_v3(points[i].rad, color[i]);
- points[i].area= fabsf(area[i])/(tree->scale*tree->scale);
- points[i].back= (area[i] < 0.0f);
-
- mul_v3_fl(points[i].co, 1.0f / tree->scale);
- minmax_v3v3_v3(tree->min, tree->max, points[i].co);
-
- refpoints[i]= points + i;
- }
-
- return tree;
-}
-
-void scatter_tree_build(ScatterTree *tree)
-{
- ScatterPoint *newpoints, **tmppoints;
- float mid[3], size[3];
- int totpoint= tree->totpoint;
-
- newpoints = MEM_callocN(sizeof(ScatterPoint) * totpoint, "ScatterPoints");
- tmppoints = MEM_callocN(sizeof(ScatterPoint *) * totpoint, "ScatterTmpPoints");
- tree->tmppoints= tmppoints;
-
- tree->arena= BLI_memarena_new(0x8000 * sizeof(ScatterNode), "sss tree arena");
- BLI_memarena_use_calloc(tree->arena);
-
- /* build tree */
- tree->root= BLI_memarena_alloc(tree->arena, sizeof(ScatterNode));
- tree->root->points= newpoints;
- tree->root->totpoint= totpoint;
-
- mid[0]= (tree->min[0]+tree->max[0])*0.5f;
- mid[1]= (tree->min[1]+tree->max[1])*0.5f;
- mid[2]= (tree->min[2]+tree->max[2])*0.5f;
-
- size[0]= (tree->max[0]-tree->min[0])*0.5f;
- size[1]= (tree->max[1]-tree->min[1])*0.5f;
- size[2]= (tree->max[2]-tree->min[2])*0.5f;
-
- create_octree_node(tree, tree->root, mid, size, tree->refpoints, 0);
-
- MEM_freeN(tree->points);
- MEM_freeN(tree->refpoints);
- MEM_freeN(tree->tmppoints);
- tree->refpoints= NULL;
- tree->tmppoints= NULL;
- tree->points= newpoints;
-
- /* sum radiance at nodes */
- sum_radiance(tree, tree->root);
-}
-
-void scatter_tree_sample(ScatterTree *tree, const float co[3], float color[3])
-{
- float sco[3];
-
- copy_v3_v3(sco, co);
- mul_v3_fl(sco, 1.0f / tree->scale);
-
- compute_radiance(tree, sco, color);
-}
-
-void scatter_tree_free(ScatterTree *tree)
-{
- if (tree->arena) BLI_memarena_free(tree->arena);
- if (tree->points) MEM_freeN(tree->points);
- if (tree->refpoints) MEM_freeN(tree->refpoints);
-
- MEM_freeN(tree);
-}
-
-/* Internal Renderer API */
-
-/* sss tree building */
-
-typedef struct SSSData {
- ScatterTree *tree;
- ScatterSettings *ss[3];
-} SSSData;
-
-typedef struct SSSPoints {
- struct SSSPoints *next, *prev;
-
- float (*co)[3];
- float (*color)[3];
- float *area;
- int totpoint;
-} SSSPoints;
-
-static void sss_create_tree_mat(Render *re, Material *mat)
-{
- SSSPoints *p;
- RenderResult *rr;
- ListBase points;
- float (*co)[3] = NULL, (*color)[3] = NULL, *area = NULL;
- int totpoint = 0, osa, osaflag, frsflag, partsdone;
-
- if (re->test_break(re->tbh))
- return;
-
- points.first= points.last= NULL;
-
- /* TODO: this is getting a bit ugly, copying all those variables and
- * setting them back, maybe we need to create our own Render? */
-
- /* do SSS preprocessing render */
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- rr= re->result;
- osa= re->osa;
- osaflag= re->r.mode & R_OSA;
- frsflag= re->r.mode & R_EDGE_FRS;
- partsdone= re->i.partsdone;
-
- re->osa= 0;
- re->r.mode &= ~(R_OSA | R_EDGE_FRS);
- re->sss_points= &points;
- re->sss_mat= mat;
- re->i.partsdone = 0;
-
- if (!(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW)))
- re->result= NULL;
- BLI_rw_mutex_unlock(&re->resultmutex);
-
- RE_TileProcessor(re);
-
- BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- if (!(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))) {
- RE_FreeRenderResult(re->result);
- re->result= rr;
- }
- BLI_rw_mutex_unlock(&re->resultmutex);
-
- re->i.partsdone= partsdone;
- re->sss_mat= NULL;
- re->sss_points= NULL;
- re->osa= osa;
- if (osaflag) re->r.mode |= R_OSA;
- if (frsflag) re->r.mode |= R_EDGE_FRS;
-
- /* no points? no tree */
- if (!points.first)
- return;
-
- /* merge points together into a single buffer */
- if (!re->test_break(re->tbh)) {
- for (totpoint=0, p=points.first; p; p=p->next)
- totpoint += p->totpoint;
-
- co= MEM_mallocN(sizeof(*co)*totpoint, "SSSCo");
- color= MEM_mallocN(sizeof(*color)*totpoint, "SSSColor");
- area= MEM_mallocN(sizeof(*area)*totpoint, "SSSArea");
-
- for (totpoint=0, p=points.first; p; p=p->next) {
- memcpy(co+totpoint, p->co, sizeof(*co)*p->totpoint);
- memcpy(color+totpoint, p->color, sizeof(*color)*p->totpoint);
- memcpy(area+totpoint, p->area, sizeof(*area)*p->totpoint);
- totpoint += p->totpoint;
- }
- }
-
- /* free points */
- for (p=points.first; p; p=p->next) {
- MEM_freeN(p->co);
- MEM_freeN(p->color);
- MEM_freeN(p->area);
- }
- BLI_freelistN(&points);
-
- /* build tree */
- if (!re->test_break(re->tbh)) {
- SSSData *sss= MEM_callocN(sizeof(*sss), "SSSData");
- float ior= mat->sss_ior, cfac= mat->sss_colfac;
- const float *radius = mat->sss_radius;
- float fw= mat->sss_front, bw= mat->sss_back;
- float error = mat->sss_error;
-
- error= get_render_aosss_error(&re->r, error);
- if ((re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW)) && error < 0.5f)
- error= 0.5f;
-
- sss->ss[0]= scatter_settings_new(mat->sss_col[0], radius[0], ior, cfac, fw, bw);
- sss->ss[1]= scatter_settings_new(mat->sss_col[1], radius[1], ior, cfac, fw, bw);
- sss->ss[2]= scatter_settings_new(mat->sss_col[2], radius[2], ior, cfac, fw, bw);
- sss->tree= scatter_tree_new(sss->ss, mat->sss_scale, error,
- co, color, area, totpoint);
-
- MEM_freeN(co);
- MEM_freeN(color);
- MEM_freeN(area);
-
- scatter_tree_build(sss->tree);
-
- BLI_ghash_insert(re->sss_hash, mat, sss);
- }
- else {
- if (co) MEM_freeN(co);
- if (color) MEM_freeN(color);
- if (area) MEM_freeN(area);
- }
-}
-
-void sss_add_points(Render *re, float (*co)[3], float (*color)[3], float *area, int totpoint)
-{
- SSSPoints *p;
-
- if (totpoint > 0) {
- p= MEM_callocN(sizeof(SSSPoints), "SSSPoints");
-
- p->co= co;
- p->color= color;
- p->area= area;
- p->totpoint= totpoint;
-
- BLI_thread_lock(LOCK_CUSTOM1);
- BLI_addtail(re->sss_points, p);
- BLI_thread_unlock(LOCK_CUSTOM1);
- }
-}
-
-static void sss_free_tree(SSSData *sss)
-{
- scatter_tree_free(sss->tree);
- scatter_settings_free(sss->ss[0]);
- scatter_settings_free(sss->ss[1]);
- scatter_settings_free(sss->ss[2]);
- MEM_freeN(sss);
-}
-
-/* public functions */
-
-void make_sss_tree(Render *re)
-{
- Material *mat;
- bool infostr_set = false;
- const char *prevstr = NULL;
-
- free_sss(re);
-
- re->sss_hash= BLI_ghash_ptr_new("make_sss_tree gh");
-
- re->stats_draw(re->sdh, &re->i);
-
- for (mat= re->main->mat.first; mat; mat= mat->id.next) {
- if (mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS)) {
- if (!infostr_set) {
- prevstr = re->i.infostr;
- re->i.infostr = IFACE_("SSS preprocessing");
- infostr_set = true;
- }
-
- sss_create_tree_mat(re, mat);
- }
- }
-
- /* XXX preview exception */
- /* localizing preview render data is not fun for node trees :( */
- if (re->main!=G.main) {
- for (mat= G.main->mat.first; mat; mat= mat->id.next) {
- if (mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS)) {
- if (!infostr_set) {
- prevstr = re->i.infostr;
- re->i.infostr = IFACE_("SSS preprocessing");
- infostr_set = true;
- }
-
- sss_create_tree_mat(re, mat);
- }
- }
- }
-
- if (infostr_set)
- re->i.infostr = prevstr;
-}
-
-void free_sss(Render *re)
-{
- if (re->sss_hash) {
- GHashIterator gh_iter;
-
- GHASH_ITER (gh_iter, re->sss_hash) {
- sss_free_tree(BLI_ghashIterator_getValue(&gh_iter));
- }
-
- BLI_ghash_free(re->sss_hash, NULL, NULL);
- re->sss_hash= NULL;
- }
-}
-
-int sample_sss(Render *re, Material *mat, const float co[3], float color[3])
-{
- if (re->sss_hash) {
- SSSData *sss= BLI_ghash_lookup(re->sss_hash, mat);
-
- if (sss) {
- scatter_tree_sample(sss->tree, co, color);
- return 1;
- }
- else {
- color[0]= 0.0f;
- color[1]= 0.0f;
- color[2]= 0.0f;
- }
- }
-
- return 0;
-}
-
-int sss_pass_done(struct Render *re, struct Material *mat)
-{
- return ((re->flag & R_BAKING) || !(re->r.mode & R_SSS) || (re->sss_hash && BLI_ghash_lookup(re->sss_hash, mat)));
-}
-
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
deleted file mode 100644
index 6b52d4aa419..00000000000
--- a/source/blender/render/intern/source/strand.c
+++ /dev/null
@@ -1,1069 +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.
- *
- * Contributors: Brecht Van Lommel.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/strand.c
- * \ingroup render
- */
-
-
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_key_types.h"
-#include "DNA_material_types.h"
-#include "DNA_meshdata_types.h"
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-#include "BLI_memarena.h"
-#include "BLI_rand.h"
-
-#include "BKE_DerivedMesh.h"
-#include "BKE_key.h"
-
-
-#include "render_types.h"
-#include "rendercore.h"
-#include "renderdatabase.h"
-#include "shading.h"
-#include "strand.h"
-#include "zbuf.h"
-
-/* *************** */
-
-static float strand_eval_width(Material *ma, float strandco)
-{
- float fac;
-
- strandco= 0.5f*(strandco + 1.0f);
-
- if (ma->strand_ease!=0.0f) {
- if (ma->strand_ease<0.0f)
- fac= pow(strandco, 1.0f+ma->strand_ease);
- else
- fac= pow(strandco, 1.0f/(1.0f-ma->strand_ease));
- }
- else fac= strandco;
-
- return ((1.0f-fac)*ma->strand_sta + (fac)*ma->strand_end);
-}
-
-void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint)
-{
- Material *ma;
- StrandBuffer *strandbuf;
- const float *simplify;
- float p[4][3], data[4], cross[3], w, dx, dy, t;
- int type;
-
- strandbuf= sseg->buffer;
- ma= sseg->buffer->ma;
- t= spoint->t;
- type= (strandbuf->flag & R_STRAND_BSPLINE)? KEY_BSPLINE: KEY_CARDINAL;
-
- copy_v3_v3(p[0], sseg->v[0]->co);
- copy_v3_v3(p[1], sseg->v[1]->co);
- copy_v3_v3(p[2], sseg->v[2]->co);
- copy_v3_v3(p[3], sseg->v[3]->co);
-
- if (sseg->obi->flag & R_TRANSFORMED) {
- mul_m4_v3(sseg->obi->mat, p[0]);
- mul_m4_v3(sseg->obi->mat, p[1]);
- mul_m4_v3(sseg->obi->mat, p[2]);
- mul_m4_v3(sseg->obi->mat, p[3]);
- }
-
- if (t == 0.0f) {
- copy_v3_v3(spoint->co, p[1]);
- spoint->strandco= sseg->v[1]->strandco;
-
- spoint->dtstrandco= (sseg->v[2]->strandco - sseg->v[0]->strandco);
- if (sseg->v[0] != sseg->v[1])
- spoint->dtstrandco *= 0.5f;
- }
- else if (t == 1.0f) {
- copy_v3_v3(spoint->co, p[2]);
- spoint->strandco= sseg->v[2]->strandco;
-
- spoint->dtstrandco= (sseg->v[3]->strandco - sseg->v[1]->strandco);
- if (sseg->v[3] != sseg->v[2])
- spoint->dtstrandco *= 0.5f;
- }
- else {
- key_curve_position_weights(t, data, type);
- spoint->co[0]= data[0]*p[0][0] + data[1]*p[1][0] + data[2]*p[2][0] + data[3]*p[3][0];
- spoint->co[1]= data[0]*p[0][1] + data[1]*p[1][1] + data[2]*p[2][1] + data[3]*p[3][1];
- spoint->co[2]= data[0]*p[0][2] + data[1]*p[1][2] + data[2]*p[2][2] + data[3]*p[3][2];
- spoint->strandco= (1.0f-t)*sseg->v[1]->strandco + t*sseg->v[2]->strandco;
- }
-
- key_curve_tangent_weights(t, data, type);
- spoint->dtco[0]= data[0]*p[0][0] + data[1]*p[1][0] + data[2]*p[2][0] + data[3]*p[3][0];
- spoint->dtco[1]= data[0]*p[0][1] + data[1]*p[1][1] + data[2]*p[2][1] + data[3]*p[3][1];
- spoint->dtco[2]= data[0]*p[0][2] + data[1]*p[1][2] + data[2]*p[2][2] + data[3]*p[3][2];
-
- normalize_v3_v3(spoint->tan, spoint->dtco);
- normalize_v3_v3(spoint->nor, spoint->co);
- negate_v3(spoint->nor);
-
- spoint->width= strand_eval_width(ma, spoint->strandco);
-
- /* simplification */
- simplify= RE_strandren_get_simplify(strandbuf->obr, sseg->strand, 0);
- spoint->alpha= (simplify)? simplify[1]: 1.0f;
-
- /* outer points */
- cross_v3_v3v3(cross, spoint->co, spoint->tan);
-
- w= spoint->co[2]*strandbuf->winmat[2][3] + strandbuf->winmat[3][3];
- dx= strandbuf->winx*cross[0]*strandbuf->winmat[0][0]/w;
- dy= strandbuf->winy*cross[1]*strandbuf->winmat[1][1]/w;
- w = sqrtf(dx * dx + dy * dy);
-
- if (w > 0.0f) {
- if (strandbuf->flag & R_STRAND_B_UNITS) {
- const float crosslen= len_v3(cross);
- w= 2.0f*crosslen*strandbuf->minwidth/w;
-
- if (spoint->width < w) {
- spoint->alpha= spoint->width/w;
- spoint->width= w;
- }
-
- if (simplify)
- /* squared because we only change width, not length */
- spoint->width *= simplify[0]*simplify[0];
-
- mul_v3_fl(cross, spoint->width*0.5f/crosslen);
- }
- else
- mul_v3_fl(cross, spoint->width/w);
- }
-
- sub_v3_v3v3(spoint->co1, spoint->co, cross);
- add_v3_v3v3(spoint->co2, spoint->co, cross);
-
- copy_v3_v3(spoint->dsco, cross);
-}
-
-/* *************** */
-
-static void interpolate_vec1(float *v1, float *v2, float t, float negt, float *v)
-{
- v[0]= negt*v1[0] + t*v2[0];
-}
-
-static void interpolate_vec3(float *v1, float *v2, float t, float negt, float *v)
-{
- v[0]= negt*v1[0] + t*v2[0];
- v[1]= negt*v1[1] + t*v2[1];
- v[2]= negt*v1[2] + t*v2[2];
-}
-
-static void interpolate_vec4(float *v1, float *v2, float t, float negt, float *v)
-{
- v[0]= negt*v1[0] + t*v2[0];
- v[1]= negt*v1[1] + t*v2[1];
- v[2]= negt*v1[2] + t*v2[2];
- v[3]= negt*v1[3] + t*v2[3];
-}
-
-static void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float t, ShadeResult *shr, int addpassflag)
-{
- float negt= 1.0f - t;
-
- interpolate_vec4(shr1->combined, shr2->combined, t, negt, shr->combined);
-
- if (addpassflag & SCE_PASS_VECTOR) {
- interpolate_vec4(shr1->winspeed, shr2->winspeed, t, negt, shr->winspeed);
- }
- /* optim... */
- if (addpassflag & ~(SCE_PASS_VECTOR)) {
- if (addpassflag & SCE_PASS_Z)
- interpolate_vec1(&shr1->z, &shr2->z, t, negt, &shr->z);
- if (addpassflag & SCE_PASS_RGBA)
- interpolate_vec4(shr1->col, shr2->col, t, negt, shr->col);
- if (addpassflag & SCE_PASS_NORMAL) {
- interpolate_vec3(shr1->nor, shr2->nor, t, negt, shr->nor);
- normalize_v3(shr->nor);
- }
- if (addpassflag & SCE_PASS_EMIT)
- interpolate_vec3(shr1->emit, shr2->emit, t, negt, shr->emit);
- if (addpassflag & SCE_PASS_DIFFUSE) {
- interpolate_vec3(shr1->diff, shr2->diff, t, negt, shr->diff);
- interpolate_vec3(shr1->diffshad, shr2->diffshad, t, negt, shr->diffshad);
- }
- if (addpassflag & SCE_PASS_SPEC)
- interpolate_vec3(shr1->spec, shr2->spec, t, negt, shr->spec);
- if (addpassflag & SCE_PASS_SHADOW)
- interpolate_vec3(shr1->shad, shr2->shad, t, negt, shr->shad);
- if (addpassflag & SCE_PASS_AO)
- interpolate_vec3(shr1->ao, shr2->ao, t, negt, shr->ao);
- if (addpassflag & SCE_PASS_ENVIRONMENT)
- interpolate_vec3(shr1->env, shr2->env, t, negt, shr->env);
- if (addpassflag & SCE_PASS_INDIRECT)
- interpolate_vec3(shr1->indirect, shr2->indirect, t, negt, shr->indirect);
- if (addpassflag & SCE_PASS_REFLECT)
- interpolate_vec3(shr1->refl, shr2->refl, t, negt, shr->refl);
- if (addpassflag & SCE_PASS_REFRACT)
- interpolate_vec3(shr1->refr, shr2->refr, t, negt, shr->refr);
- if (addpassflag & SCE_PASS_MIST)
- interpolate_vec1(&shr1->mist, &shr2->mist, t, negt, &shr->mist);
- }
-}
-
-static void strand_apply_shaderesult_alpha(ShadeResult *shr, float alpha)
-{
- if (alpha < 1.0f) {
- shr->combined[0] *= alpha;
- shr->combined[1] *= alpha;
- shr->combined[2] *= alpha;
- shr->combined[3] *= alpha;
-
- shr->col[0] *= alpha;
- shr->col[1] *= alpha;
- shr->col[2] *= alpha;
- shr->col[3] *= alpha;
-
- shr->alpha *= alpha;
- }
-}
-
-static void strand_shade_point(Render *re, ShadeSample *ssamp, StrandSegment *sseg, StrandVert *svert, StrandPoint *spoint)
-{
- ShadeInput *shi= ssamp->shi;
- ShadeResult *shr= ssamp->shr;
- VlakRen vlr;
- int seed;
-
- memset(&vlr, 0, sizeof(vlr));
- vlr.flag= R_SMOOTH;
- if (sseg->buffer->ma->mode & MA_TANGENT_STR)
- vlr.flag |= R_TANGENT;
-
- shi->vlr= &vlr;
- shi->v1= NULL;
- shi->v2= NULL;
- shi->v3= NULL;
- shi->strand= sseg->strand;
- shi->obi= sseg->obi;
- shi->obr= sseg->obi->obr;
-
- /* cache for shadow */
- shi->samplenr= re->shadowsamplenr[shi->thread]++;
-
- /* all samples */
- shi->mask= 0xFFFF;
-
- /* seed RNG for consistent results across tiles */
- seed = shi->strand->index + (svert - shi->strand->vert);
- BLI_thread_srandom(shi->thread, seed);
-
- shade_input_set_strand(shi, sseg->strand, spoint);
- shade_input_set_strand_texco(shi, sseg->strand, sseg->v[1], spoint);
-
- /* init material vars */
- shade_input_init_material(shi);
-
- /* shade */
- shade_samples_do_AO(ssamp);
- shade_input_do_shade(shi, shr);
-
- /* apply simplification */
- strand_apply_shaderesult_alpha(shr, spoint->alpha);
-
- /* include lamphalos for strand, since halo layer was added already */
- if (re->flag & R_LAMPHALO)
- if (shi->layflag & SCE_LAY_HALO)
- renderspothalo(shi, shr->combined, shr->combined[3]);
-
- shi->strand= NULL;
-}
-
-/* *************** */
-
-struct StrandShadeCache {
- GHash *resulthash;
- GHash *refcounthash;
- MemArena *memarena;
-};
-
-typedef struct StrandCacheEntry {
- GHashPair pair;
- ShadeResult shr;
-} StrandCacheEntry;
-
-StrandShadeCache *strand_shade_cache_create(void)
-{
- StrandShadeCache *cache;
-
- cache= MEM_callocN(sizeof(StrandShadeCache), "StrandShadeCache");
- cache->resulthash= BLI_ghash_pair_new("strand_shade_cache_create1 gh");
- cache->refcounthash= BLI_ghash_pair_new("strand_shade_cache_create2 gh");
- cache->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "strand shade cache arena");
-
- return cache;
-}
-
-void strand_shade_cache_free(StrandShadeCache *cache)
-{
- BLI_ghash_free(cache->refcounthash, NULL, NULL);
- BLI_ghash_free(cache->resulthash, MEM_freeN, NULL);
- BLI_memarena_free(cache->memarena);
- MEM_freeN(cache);
-}
-
-static GHashPair strand_shade_hash_pair(ObjectInstanceRen *obi, StrandVert *svert)
-{
- GHashPair pair = {obi, svert};
- return pair;
-}
-
-static void strand_shade_get(Render *re, StrandShadeCache *cache, ShadeSample *ssamp, StrandSegment *sseg, StrandVert *svert)
-{
- StrandCacheEntry *entry;
- StrandPoint p;
- int *refcount;
- GHashPair pair = strand_shade_hash_pair(sseg->obi, svert);
-
- entry= BLI_ghash_lookup(cache->resulthash, &pair);
- refcount= BLI_ghash_lookup(cache->refcounthash, &pair);
-
- if (!entry) {
- /* not shaded yet, shade and insert into hash */
- p.t= (sseg->v[1] == svert)? 0.0f: 1.0f;
- strand_eval_point(sseg, &p);
- strand_shade_point(re, ssamp, sseg, svert, &p);
-
- entry= MEM_callocN(sizeof(StrandCacheEntry), "StrandCacheEntry");
- entry->pair = pair;
- entry->shr = ssamp->shr[0];
- BLI_ghash_insert(cache->resulthash, entry, entry);
- }
- else
- /* already shaded, just copy previous result from hash */
- ssamp->shr[0]= entry->shr;
-
- /* lower reference count and remove if not needed anymore by any samples */
- (*refcount)--;
- if (*refcount == 0) {
- BLI_ghash_remove(cache->resulthash, &pair, MEM_freeN, NULL);
- BLI_ghash_remove(cache->refcounthash, &pair, NULL, NULL);
- }
-}
-
-void strand_shade_segment(Render *re, StrandShadeCache *cache, StrandSegment *sseg, ShadeSample *ssamp, float t, float s, int addpassflag)
-{
- ShadeResult shr1, shr2;
-
- /* get shading for two endpoints and interpolate */
- strand_shade_get(re, cache, ssamp, sseg, sseg->v[1]);
- shr1= ssamp->shr[0];
- strand_shade_get(re, cache, ssamp, sseg, sseg->v[2]);
- shr2= ssamp->shr[0];
-
- interpolate_shade_result(&shr1, &shr2, t, ssamp->shr, addpassflag);
-
- /* apply alpha along width */
- if (sseg->buffer->widthfade != -1.0f) {
- s = 1.0f - powf(fabsf(s), sseg->buffer->widthfade);
-
- strand_apply_shaderesult_alpha(ssamp->shr, s);
- }
-}
-
-void strand_shade_unref(StrandShadeCache *cache, ObjectInstanceRen *obi, StrandVert *svert)
-{
- GHashPair pair = strand_shade_hash_pair(obi, svert);
- int *refcount;
-
- /* lower reference count and remove if not needed anymore by any samples */
- refcount= BLI_ghash_lookup(cache->refcounthash, &pair);
-
- (*refcount)--;
- if (*refcount == 0) {
- BLI_ghash_remove(cache->resulthash, &pair, MEM_freeN, NULL);
- BLI_ghash_remove(cache->refcounthash, &pair, NULL, NULL);
- }
-}
-
-static void strand_shade_refcount(StrandShadeCache *cache, StrandSegment *sseg, StrandVert *svert)
-{
- GHashPair pair = strand_shade_hash_pair(sseg->obi, svert);
- GHashPair *key;
- int *refcount= BLI_ghash_lookup(cache->refcounthash, &pair);
-
- if (!refcount) {
- key= BLI_memarena_alloc(cache->memarena, sizeof(GHashPair));
- *key = pair;
- refcount= BLI_memarena_alloc(cache->memarena, sizeof(int));
- *refcount= 1;
- BLI_ghash_insert(cache->refcounthash, key, refcount);
- }
- else
- (*refcount)++;
-}
-
-/* *************** */
-
-typedef struct StrandPart {
- Render *re;
- ZSpan *zspan;
-
- APixstrand *apixbuf;
- int *totapixbuf;
- int *rectz;
- int *rectmask;
- intptr_t *rectdaps;
- int rectx, recty;
- int sample;
- int shadow;
- float (*jit)[2];
- int samples;
-
- StrandSegment *segment;
- float t[3], s[3];
-
- StrandShadeCache *cache;
-} StrandPart;
-
-typedef struct StrandSortSegment {
- struct StrandSortSegment *next;
- int obi, strand, segment;
- float z;
-} StrandSortSegment;
-
-static int compare_strand_segment(const void *poin1, const void *poin2)
-{
- const StrandSortSegment *seg1= (const StrandSortSegment*)poin1;
- const StrandSortSegment *seg2= (const StrandSortSegment*)poin2;
-
- if (seg1->z < seg2->z)
- return -1;
- else if (seg1->z == seg2->z)
- return 0;
- else
- return 1;
-}
-
-static void do_strand_point_project(float winmat[4][4], ZSpan *zspan, float *co, float *hoco, float *zco)
-{
- projectvert(co, winmat, hoco);
- hoco_to_zco(zspan, zco, hoco);
-}
-
-static void strand_project_point(float winmat[4][4], float winx, float winy, StrandPoint *spoint)
-{
- float div;
-
- projectvert(spoint->co, winmat, spoint->hoco);
-
- div= 1.0f/spoint->hoco[3];
- spoint->x= spoint->hoco[0]*div*winx*0.5f;
- spoint->y= spoint->hoco[1]*div*winy*0.5f;
-}
-
-static APixstrand *addpsmainAstrand(ListBase *lb)
-{
- APixstrMain *psm;
-
- psm= MEM_mallocN(sizeof(APixstrMain), "addpsmainA");
- BLI_addtail(lb, psm);
- psm->ps = MEM_callocN(4096 * sizeof(APixstrand), "pixstr");
-
- return psm->ps;
-}
-
-static APixstrand *addpsAstrand(ZSpan *zspan)
-{
- /* make new PS */
- if (zspan->apstrandmcounter==0) {
- zspan->curpstrand= addpsmainAstrand(zspan->apsmbase);
- zspan->apstrandmcounter= 4095;
- }
- else {
- zspan->curpstrand++;
- zspan->apstrandmcounter--;
- }
- return zspan->curpstrand;
-}
-
-#define MAX_ZROW 2000
-
-static void do_strand_fillac(void *handle, int x, int y, float u, float v, float z)
-{
- StrandPart *spart= (StrandPart *)handle;
- StrandShadeCache *cache= spart->cache;
- StrandSegment *sseg= spart->segment;
- APixstrand *apn, *apnew;
- float t, s;
- int offset, mask, obi, strnr, seg, zverg, bufferz, maskz=0;
-
- offset = y*spart->rectx + x;
- obi= sseg->obi - spart->re->objectinstance;
- strnr= sseg->strand->index + 1;
- seg= sseg->v[1] - sseg->strand->vert;
- mask= (1<<spart->sample);
-
- /* check against solid z-buffer */
- zverg= (int)z;
-
- if (spart->rectdaps) {
- /* find the z of the sample */
- PixStr *ps;
- intptr_t *rd= spart->rectdaps + offset;
-
- bufferz= 0x7FFFFFFF;
- if (spart->rectmask) maskz= 0x7FFFFFFF;
-
- if (*rd) {
- for (ps= (PixStr *)(*rd); ps; ps= ps->next) {
- if (mask & ps->mask) {
- bufferz= ps->z;
- if (spart->rectmask)
- maskz= ps->maskz;
- break;
- }
- }
- }
- }
- else {
- bufferz= (spart->rectz)? spart->rectz[offset]: 0x7FFFFFFF;
- if (spart->rectmask)
- maskz= spart->rectmask[offset];
- }
-
-#define CHECK_ADD(n) \
- if (apn->p[n]==strnr && apn->obi[n]==obi && apn->seg[n]==seg) \
- { if (!(apn->mask[n] & mask)) { apn->mask[n] |= mask; apn->v[n] += t; apn->u[n] += s; } break; } (void)0
-#define CHECK_ASSIGN(n) \
- if (apn->p[n]==0) \
- {apn->obi[n]= obi; apn->p[n]= strnr; apn->z[n]= zverg; apn->mask[n]= mask; apn->v[n]= t; apn->u[n]= s; apn->seg[n]= seg; break; } (void)0
-
- /* add to pixel list */
- if (zverg < bufferz && (spart->totapixbuf[offset] < MAX_ZROW)) {
- if (!spart->rectmask || zverg > maskz) {
- t = u * spart->t[0] + v * spart->t[1] + (1.0f - u - v) * spart->t[2];
- s = fabsf(u * spart->s[0] + v * spart->s[1] + (1.0f - u - v) * spart->s[2]);
-
- apn= spart->apixbuf + offset;
- while (apn) {
- CHECK_ADD(0);
- CHECK_ADD(1);
- CHECK_ADD(2);
- CHECK_ADD(3);
- CHECK_ASSIGN(0);
- CHECK_ASSIGN(1);
- CHECK_ASSIGN(2);
- CHECK_ASSIGN(3);
-
- apnew= addpsAstrand(spart->zspan);
- SWAP(APixstrand, *apnew, *apn);
- apn->next= apnew;
- CHECK_ASSIGN(0);
- }
-
- if (cache) {
- strand_shade_refcount(cache, sseg, sseg->v[1]);
- strand_shade_refcount(cache, sseg, sseg->v[2]);
- }
- spart->totapixbuf[offset]++;
- }
- }
-}
-
-/* width is calculated in hoco space, to ensure strands are visible */
-static int strand_test_clip(float winmat[4][4], ZSpan *UNUSED(zspan), float *bounds, float *co, float *zcomp, float widthx, float widthy)
-{
- float hoco[4];
- int clipflag= 0;
-
- projectvert(co, winmat, hoco);
-
- /* we compare z without perspective division for segment sorting */
- *zcomp= hoco[2];
-
- if (hoco[0]+widthx < bounds[0]*hoco[3]) clipflag |= 1;
- else if (hoco[0]-widthx > bounds[1]*hoco[3]) clipflag |= 2;
-
- if (hoco[1]-widthy > bounds[3]*hoco[3]) clipflag |= 4;
- else if (hoco[1]+widthy < bounds[2]*hoco[3]) clipflag |= 8;
-
- clipflag |= testclip(hoco);
-
- return clipflag;
-}
-
-static void do_scanconvert_strand(Render *UNUSED(re), StrandPart *spart, ZSpan *zspan, float t, float dt, float *co1, float *co2, float *co3, float *co4, int sample)
-{
- float jco1[3], jco2[3], jco3[3], jco4[3], jx, jy;
-
- copy_v3_v3(jco1, co1);
- copy_v3_v3(jco2, co2);
- copy_v3_v3(jco3, co3);
- copy_v3_v3(jco4, co4);
-
- if (spart->jit) {
- jx= -spart->jit[sample][0];
- jy= -spart->jit[sample][1];
-
- jco1[0] += jx; jco1[1] += jy;
- jco2[0] += jx; jco2[1] += jy;
- jco3[0] += jx; jco3[1] += jy;
- jco4[0] += jx; jco4[1] += jy;
-
- /* XXX mblur? */
- }
-
- spart->sample= sample;
-
- spart->t[0]= t-dt;
- spart->s[0]= -1.0f;
- spart->t[1]= t-dt;
- spart->s[1]= 1.0f;
- spart->t[2]= t;
- spart->s[2]= 1.0f;
- zspan_scanconvert_strand(zspan, spart, jco1, jco2, jco3, do_strand_fillac);
- spart->t[0]= t-dt;
- spart->s[0]= -1.0f;
- spart->t[1]= t;
- spart->s[1]= 1.0f;
- spart->t[2]= t;
- spart->s[2]= -1.0f;
- zspan_scanconvert_strand(zspan, spart, jco1, jco3, jco4, do_strand_fillac);
-}
-
-static void strand_render(Render *re, StrandSegment *sseg, float winmat[4][4], StrandPart *spart, ZSpan *zspan, int totzspan, StrandPoint *p1, StrandPoint *p2)
-{
- if (spart) {
- float t= p2->t;
- float dt= p2->t - p1->t;
- int a;
-
- for (a=0; a<spart->samples; a++)
- do_scanconvert_strand(re, spart, zspan, t, dt, p1->zco2, p1->zco1, p2->zco1, p2->zco2, a);
- }
- else {
- float hoco1[4], hoco2[4];
- int a, obi, index;
-
- obi= sseg->obi - re->objectinstance;
- index= sseg->strand->index;
-
- projectvert(p1->co, winmat, hoco1);
- projectvert(p2->co, winmat, hoco2);
-
-
- for (a=0; a<totzspan; a++) {
-#if 0
- /* render both strand and single pixel wire to counter aliasing */
- zbufclip4(re, &zspan[a], obi, index, p1->hoco2, p1->hoco1, p2->hoco1, p2->hoco2, p1->clip2, p1->clip1, p2->clip1, p2->clip2);
-#endif
- /* only render a line for now, which makes the shadow map more
- * similar across frames, and so reduces flicker */
- zbufsinglewire(&zspan[a], obi, index, hoco1, hoco2);
- }
- }
-}
-
-static int strand_segment_recursive(Render *re, float winmat[4][4], StrandPart *spart, ZSpan *zspan, int totzspan, StrandSegment *sseg, StrandPoint *p1, StrandPoint *p2, int depth)
-{
- StrandPoint p;
- StrandBuffer *buffer= sseg->buffer;
- float dot, d1[2], d2[2], len1, len2;
-
- if (depth == buffer->maxdepth)
- return 0;
-
- p.t= (p1->t + p2->t)*0.5f;
- strand_eval_point(sseg, &p);
- strand_project_point(buffer->winmat, buffer->winx, buffer->winy, &p);
-
- d1[0]= (p.x - p1->x);
- d1[1]= (p.y - p1->y);
- len1= d1[0]*d1[0] + d1[1]*d1[1];
-
- d2[0]= (p2->x - p.x);
- d2[1]= (p2->y - p.y);
- len2= d2[0]*d2[0] + d2[1]*d2[1];
-
- if (len1 == 0.0f || len2 == 0.0f)
- return 0;
-
- dot= d1[0]*d2[0] + d1[1]*d2[1];
- if (dot*dot > sseg->sqadaptcos*len1*len2)
- return 0;
-
- if (spart) {
- do_strand_point_project(winmat, zspan, p.co1, p.hoco1, p.zco1);
- do_strand_point_project(winmat, zspan, p.co2, p.hoco2, p.zco2);
- }
- else {
-#if 0
- projectvert(p.co1, winmat, p.hoco1);
- projectvert(p.co2, winmat, p.hoco2);
- p.clip1= testclip(p.hoco1);
- p.clip2= testclip(p.hoco2);
-#endif
- }
-
- if (!strand_segment_recursive(re, winmat, spart, zspan, totzspan, sseg, p1, &p, depth+1))
- strand_render(re, sseg, winmat, spart, zspan, totzspan, p1, &p);
- if (!strand_segment_recursive(re, winmat, spart, zspan, totzspan, sseg, &p, p2, depth+1))
- strand_render(re, sseg, winmat, spart, zspan, totzspan, &p, p2);
-
- return 1;
-}
-
-void render_strand_segment(Render *re, float winmat[4][4], StrandPart *spart, ZSpan *zspan, int totzspan, StrandSegment *sseg)
-{
- StrandBuffer *buffer= sseg->buffer;
- StrandPoint *p1= &sseg->point1;
- StrandPoint *p2= &sseg->point2;
-
- p1->t= 0.0f;
- p2->t= 1.0f;
-
- strand_eval_point(sseg, p1);
- strand_project_point(buffer->winmat, buffer->winx, buffer->winy, p1);
- strand_eval_point(sseg, p2);
- strand_project_point(buffer->winmat, buffer->winx, buffer->winy, p2);
-
- if (spart) {
- do_strand_point_project(winmat, zspan, p1->co1, p1->hoco1, p1->zco1);
- do_strand_point_project(winmat, zspan, p1->co2, p1->hoco2, p1->zco2);
- do_strand_point_project(winmat, zspan, p2->co1, p2->hoco1, p2->zco1);
- do_strand_point_project(winmat, zspan, p2->co2, p2->hoco2, p2->zco2);
- }
- else {
-#if 0
- projectvert(p1->co1, winmat, p1->hoco1);
- projectvert(p1->co2, winmat, p1->hoco2);
- projectvert(p2->co1, winmat, p2->hoco1);
- projectvert(p2->co2, winmat, p2->hoco2);
- p1->clip1= testclip(p1->hoco1);
- p1->clip2= testclip(p1->hoco2);
- p2->clip1= testclip(p2->hoco1);
- p2->clip2= testclip(p2->hoco2);
-#endif
- }
-
- if (!strand_segment_recursive(re, winmat, spart, zspan, totzspan, sseg, p1, p2, 0))
- strand_render(re, sseg, winmat, spart, zspan, totzspan, p1, p2);
-}
-
-/* render call to fill in strands */
-int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBase *apsmbase, unsigned int lay, int UNUSED(negzmask), float winmat[4][4], int winx, int winy, int samples, float (*jit)[2], float clipcrop, int shadow, StrandShadeCache *cache)
-{
- ObjectRen *obr;
- ObjectInstanceRen *obi;
- ZSpan zspan;
- StrandRen *strand = NULL;
- StrandVert *svert;
- StrandBound *sbound;
- StrandPart spart;
- StrandSegment sseg;
- StrandSortSegment *sortsegments = NULL, *sortseg, *firstseg;
- MemArena *memarena;
- float z[4], bounds[4], obwinmat[4][4];
- int a, b, c, i, totsegment, clip[4];
-
- if (re->test_break(re->tbh))
- return 0;
- if (re->totstrand == 0)
- return 0;
-
- /* setup StrandPart */
- memset(&spart, 0, sizeof(spart));
-
- spart.re= re;
- spart.rectx= pa->rectx;
- spart.recty= pa->recty;
- spart.apixbuf= apixbuf;
- spart.zspan= &zspan;
- spart.rectdaps= pa->rectdaps;
- spart.rectz= pa->rectz;
- spart.rectmask= pa->rectmask;
- spart.cache= cache;
- spart.shadow= shadow;
- spart.jit= jit;
- spart.samples= samples;
-
- zbuf_alloc_span(&zspan, pa->rectx, pa->recty, clipcrop);
-
- /* needed for transform from hoco to zbuffer co */
- zspan.zmulx= ((float)winx)/2.0f;
- zspan.zmuly= ((float)winy)/2.0f;
-
- zspan.zofsx= -pa->disprect.xmin;
- zspan.zofsy= -pa->disprect.ymin;
-
- /* to center the sample position */
- if (!shadow) {
- zspan.zofsx -= 0.5f;
- zspan.zofsy -= 0.5f;
- }
-
- zspan.apsmbase= apsmbase;
-
- /* clipping setup */
- bounds[0]= (2*pa->disprect.xmin - winx-1)/(float)winx;
- bounds[1]= (2*pa->disprect.xmax - winx+1)/(float)winx;
- bounds[2]= (2*pa->disprect.ymin - winy-1)/(float)winy;
- bounds[3]= (2*pa->disprect.ymax - winy+1)/(float)winy;
-
- memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "strand sort arena");
- firstseg= NULL;
- totsegment= 0;
-
- /* for all object instances */
- for (obi=re->instancetable.first, i=0; obi; obi=obi->next, i++) {
- Material *ma;
- float widthx, widthy;
-
- obr= obi->obr;
-
- if (!obr->strandbuf || !(obr->strandbuf->lay & lay))
- continue;
-
- /* compute matrix and try clipping whole object */
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, winmat, obi->mat);
- else
- copy_m4_m4(obwinmat, winmat);
-
- /* test if we should skip it */
- ma = obr->strandbuf->ma;
-
- if (shadow && (!(ma->mode2 & MA_CASTSHADOW) || !(ma->mode & MA_SHADBUF)))
- continue;
- else if (!shadow && (ma->mode & MA_ONLYCAST))
- continue;
-
- if (clip_render_object(obi->obr->boundbox, bounds, obwinmat))
- continue;
-
- widthx= obr->strandbuf->maxwidth*obwinmat[0][0];
- widthy= obr->strandbuf->maxwidth*obwinmat[1][1];
-
- /* for each bounding box containing a number of strands */
- sbound= obr->strandbuf->bound;
- for (c=0; c<obr->strandbuf->totbound; c++, sbound++) {
- if (clip_render_object(sbound->boundbox, bounds, obwinmat))
- continue;
-
- /* for each strand in this bounding box */
- for (a=sbound->start; a<sbound->end; a++) {
- strand= RE_findOrAddStrand(obr, a);
- svert= strand->vert;
-
- /* keep clipping and z depth for 4 control points */
- clip[1]= strand_test_clip(obwinmat, &zspan, bounds, svert->co, &z[1], widthx, widthy);
- clip[2]= strand_test_clip(obwinmat, &zspan, bounds, (svert+1)->co, &z[2], widthx, widthy);
- clip[0]= clip[1]; z[0]= z[1];
-
- for (b=0; b<strand->totvert-1; b++, svert++) {
- /* compute 4th point clipping and z depth */
- if (b < strand->totvert-2) {
- clip[3]= strand_test_clip(obwinmat, &zspan, bounds, (svert+2)->co, &z[3], widthx, widthy);
- }
- else {
- clip[3]= clip[2]; z[3]= z[2];
- }
-
- /* check clipping and add to sortsegments buffer */
- if (!(clip[0] & clip[1] & clip[2] & clip[3])) {
- sortseg= BLI_memarena_alloc(memarena, sizeof(StrandSortSegment));
- sortseg->obi= i;
- sortseg->strand= strand->index;
- sortseg->segment= b;
-
- sortseg->z= 0.5f*(z[1] + z[2]);
-
- sortseg->next= firstseg;
- firstseg= sortseg;
- totsegment++;
- }
-
- /* shift clipping and z depth */
- clip[0]= clip[1]; z[0]= z[1];
- clip[1]= clip[2]; z[1]= z[2];
- clip[2]= clip[3]; z[2]= z[3];
- }
- }
- }
- }
-
- if (!re->test_break(re->tbh)) {
- /* convert list to array and sort */
- sortsegments= MEM_mallocN(sizeof(StrandSortSegment)*totsegment, "StrandSortSegment");
- for (a=0, sortseg=firstseg; a<totsegment; a++, sortseg=sortseg->next)
- sortsegments[a]= *sortseg;
- qsort(sortsegments, totsegment, sizeof(StrandSortSegment), compare_strand_segment);
- }
-
- BLI_memarena_free(memarena);
-
- spart.totapixbuf= MEM_callocN(sizeof(int)*pa->rectx*pa->recty, "totapixbuf");
-
- if (!re->test_break(re->tbh)) {
- /* render segments in sorted order */
- sortseg= sortsegments;
- for (a=0; a<totsegment; a++, sortseg++) {
- if (re->test_break(re->tbh))
- break;
-
- obi= &re->objectinstance[sortseg->obi];
- obr= obi->obr;
-
- sseg.obi= obi;
- sseg.strand= RE_findOrAddStrand(obr, sortseg->strand);
- sseg.buffer= sseg.strand->buffer;
- sseg.sqadaptcos= sseg.buffer->adaptcos;
- sseg.sqadaptcos *= sseg.sqadaptcos;
-
- svert= sseg.strand->vert + sortseg->segment;
- sseg.v[0]= (sortseg->segment > 0)? (svert-1): svert;
- sseg.v[1]= svert;
- sseg.v[2]= svert+1;
- sseg.v[3]= (sortseg->segment < sseg.strand->totvert-2)? svert+2: svert+1;
- sseg.shaded= 0;
-
- spart.segment= &sseg;
-
- render_strand_segment(re, winmat, &spart, &zspan, 1, &sseg);
- }
- }
-
- if (sortsegments)
- MEM_freeN(sortsegments);
- MEM_freeN(spart.totapixbuf);
-
- zbuf_free_span(&zspan);
-
- return totsegment;
-}
-
-/* *************** */
-
-StrandSurface *cache_strand_surface(Render *re, ObjectRen *obr, DerivedMesh *dm, float mat[4][4], int timeoffset)
-{
- StrandSurface *mesh;
- MFace *mface;
- MVert *mvert;
- float (*co)[3];
- int a, totvert, totface;
-
- totvert= dm->getNumVerts(dm);
- totface= dm->getNumTessFaces(dm);
-
- for (mesh = re->strandsurface.first; mesh; mesh = mesh->next) {
- if ((mesh->obr.ob == obr->ob) &&
- (mesh->obr.par == obr->par) &&
- (mesh->obr.index == obr->index) &&
- (mesh->totvert == totvert) &&
- (mesh->totface == totface))
- {
- break;
- }
- }
-
- if (!mesh) {
- mesh= MEM_callocN(sizeof(StrandSurface), "StrandSurface");
- mesh->obr= *obr;
- mesh->totvert= totvert;
- mesh->totface= totface;
- mesh->face= MEM_callocN(sizeof(int)*4*mesh->totface, "StrandSurfFaces");
- mesh->ao= MEM_callocN(sizeof(float)*3*mesh->totvert, "StrandSurfAO");
- mesh->env= MEM_callocN(sizeof(float)*3*mesh->totvert, "StrandSurfEnv");
- mesh->indirect= MEM_callocN(sizeof(float)*3*mesh->totvert, "StrandSurfIndirect");
- BLI_addtail(&re->strandsurface, mesh);
- }
-
- if (timeoffset == -1 && !mesh->prevco)
- mesh->prevco= co= MEM_callocN(sizeof(float)*3*mesh->totvert, "StrandSurfCo");
- else if (timeoffset == 0 && !mesh->co)
- mesh->co= co= MEM_callocN(sizeof(float)*3*mesh->totvert, "StrandSurfCo");
- else if (timeoffset == 1 && !mesh->nextco)
- mesh->nextco= co= MEM_callocN(sizeof(float)*3*mesh->totvert, "StrandSurfCo");
- else
- return mesh;
-
- mvert= dm->getVertArray(dm);
- for (a=0; a<mesh->totvert; a++, mvert++) {
- copy_v3_v3(co[a], mvert->co);
- mul_m4_v3(mat, co[a]);
- }
-
- mface= dm->getTessFaceArray(dm);
- for (a=0; a<mesh->totface; a++, mface++) {
- mesh->face[a][0]= mface->v1;
- mesh->face[a][1]= mface->v2;
- mesh->face[a][2]= mface->v3;
- mesh->face[a][3]= mface->v4;
- }
-
- return mesh;
-}
-
-void free_strand_surface(Render *re)
-{
- StrandSurface *mesh;
-
- for (mesh=re->strandsurface.first; mesh; mesh=mesh->next) {
- if (mesh->co) MEM_freeN(mesh->co);
- if (mesh->prevco) MEM_freeN(mesh->prevco);
- if (mesh->nextco) MEM_freeN(mesh->nextco);
- if (mesh->ao) MEM_freeN(mesh->ao);
- if (mesh->env) MEM_freeN(mesh->env);
- if (mesh->indirect) MEM_freeN(mesh->indirect);
- if (mesh->face) MEM_freeN(mesh->face);
- }
-
- BLI_freelistN(&re->strandsurface);
-}
-
-void strand_minmax(StrandRen *strand, float min[3], float max[3], const float width)
-{
- StrandVert *svert;
- const float width2 = width * 2.0f;
- float vec[3];
- int a;
-
- for (a=0, svert=strand->vert; a<strand->totvert; a++, svert++) {
- copy_v3_v3(vec, svert->co);
- minmax_v3v3_v3(min, max, vec);
-
- if (width!=0.0f) {
- add_v3_fl(vec, width);
- minmax_v3v3_v3(min, max, vec);
- add_v3_fl(vec, -width2);
- minmax_v3v3_v3(min, max, vec);
- }
- }
-}
-
diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c
deleted file mode 100644
index f0cf29e98ca..00000000000
--- a/source/blender/render/intern/source/sunsky.c
+++ /dev/null
@@ -1,506 +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 blender/render/intern/source/sunsky.c
- * \ingroup render
- *
- * This feature comes from Preetham paper on "A Practical Analytic Model for Daylight"
- * and example code from Brian Smits, another author of that paper in
- * http://www.cs.utah.edu/vissim/papers/sunsky/code/
- */
-
-#include "sunsky.h"
-#include "BLI_math.h"
-
-/**
- * These macros are defined for vector operations
- * */
-
-/**
- * compute v1 = v2 op v3
- * v1, v2 and v3 are vectors contains 3 float
- * */
-#define VEC3OPV(v1, v2, op, v3) \
- { \
- v1[0] = (v2[0] op v3[0]); \
- v1[1] = (v2[1] op v3[1]); \
- v1[2] = (v2[2] op v3[2]); \
- } (void)0
-
-/**
- * compute v1 = v2 op f1
- * v1, v2 are vectors contains 3 float
- * and f1 is a float
- * */
-#define VEC3OPF(v1, v2, op, f1) \
- { \
- v1[0] = (v2[0] op(f1)); \
- v1[1] = (v2[1] op(f1)); \
- v1[2] = (v2[2] op(f1)); \
- } (void)0
-
-/**
- * compute v1 = f1 op v2
- * v1, v2 are vectors contains 3 float
- * and f1 is a float
- * */
-#define FOPVEC3(v1, f1, op, v2) \
- { \
- v1[0] = ((f1) op v2[0]); \
- v1[1] = ((f1) op v2[1]); \
- v1[2] = ((f1) op v2[2]); \
- } (void)0
-
-/**
- * ClipColor:
- * clip a color to range [0, 1];
- * */
-void ClipColor(float c[3])
-{
- if (c[0] > 1.0f) c[0] = 1.0f;
- if (c[0] < 0.0f) c[0] = 0.0f;
- if (c[1] > 1.0f) c[1] = 1.0f;
- if (c[1] < 0.0f) c[1] = 0.0f;
- if (c[2] > 1.0f) c[2] = 1.0f;
- if (c[2] < 0.0f) c[2] = 0.0f;
-}
-
-/**
- * AngleBetween:
- * compute angle between to direction
- * all angles are in radians
- * */
-static float AngleBetween(float thetav, float phiv, float theta, float phi)
-{
- float cospsi = sinf(thetav) * sinf(theta) * cosf(phi - phiv) + cosf(thetav) * cosf(theta);
-
- if (cospsi > 1.0f)
- return 0;
- if (cospsi < -1.0f)
- return M_PI;
-
- return acosf(cospsi);
-}
-
-/**
- * DirectionToThetaPhi:
- * this function convert a direction to it's theta and phi value
- * parameters:
- * toSun: contains direction information
- * theta, phi, are return values from this conversion
- * */
-static void DirectionToThetaPhi(float *toSun, float *theta, float *phi)
-{
- *theta = acosf(toSun[2]);
- if (fabsf(*theta) < 1e-5f)
- *phi = 0;
- else
- *phi = atan2f(toSun[1], toSun[0]);
-}
-
-/**
- * PerezFunction:
- * compute perez function value based on input parameters
- */
-static float PerezFunction(struct SunSky *sunsky, const float *lam, float theta, float gamma, float lvz)
-{
- float den, num;
-
- den = ((1 + lam[0] * expf(lam[1])) *
- (1 + lam[2] * expf(lam[3] * sunsky->theta) + lam[4] * cosf(sunsky->theta) * cosf(sunsky->theta)));
-
- num = ((1 + lam[0] * expf(lam[1] / cosf(theta))) *
- (1 + lam[2] * expf(lam[3] * gamma) + lam[4] * cosf(gamma) * cosf(gamma)));
-
- return(lvz * num / den);
-}
-
-/**
- * InitSunSky:
- * this function compute some sun,sky parameters according to input parameters and also initiate some other sun, sky parameters
- * parameters:
- * sunSky, is a structure that contains information about sun, sky and atmosphere, in this function, most of its values initiated
- * turb, is atmosphere turbidity
- * toSun, contains sun direction
- * horizon_brighness, controls the brightness of the horizon colors
- * spread, controls colors spreed at horizon
- * sun_brightness, controls sun's brightness
- * sun_size, controls sun's size
- * back_scatter, controls back scatter light
- * */
-void InitSunSky(struct SunSky *sunsky, float turb, const float toSun[3], float horizon_brightness,
- float spread, float sun_brightness, float sun_size, float back_scatter,
- float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace)
-{
- float theta2;
- float theta3;
- float T;
- float T2;
- float chi;
-
- sunsky->turbidity = turb;
-
- sunsky->horizon_brightness = horizon_brightness;
- sunsky->spread = spread;
- sunsky->sun_brightness = sun_brightness;
- sunsky->sun_size = sun_size;
- sunsky->backscattered_light = back_scatter;
- sunsky->skyblendfac = skyblendfac;
- sunsky->skyblendtype = skyblendtype;
- sunsky->sky_exposure = -sky_exposure;
- sunsky->sky_colorspace = sky_colorspace;
-
- sunsky->toSun[0] = toSun[0];
- sunsky->toSun[1] = toSun[1];
- sunsky->toSun[2] = toSun[2];
-
- DirectionToThetaPhi(sunsky->toSun, &sunsky->theta, &sunsky->phi);
-
- sunsky->sunSolidAngle = 0.25 * M_PI * 1.39 * 1.39 / (150 * 150); /* = 6.7443e-05 */
-
- theta2 = sunsky->theta * sunsky->theta;
- theta3 = theta2 * sunsky->theta;
- T = turb;
- T2 = turb * turb;
-
- chi = (4.0f / 9.0f - T / 120.0f) * ((float)M_PI - 2.0f * sunsky->theta);
- sunsky->zenith_Y = (4.0453f * T - 4.9710f) * tanf(chi) - 0.2155f * T + 2.4192f;
- sunsky->zenith_Y *= 1000; /* conversion from kcd/m^2 to cd/m^2 */
-
- if (sunsky->zenith_Y <= 0)
- sunsky->zenith_Y = 1e-6;
-
- sunsky->zenith_x =
- (+0.00165f * theta3 - 0.00374f * theta2 + 0.00208f * sunsky->theta + 0.0f) * T2 +
- (-0.02902f * theta3 + 0.06377f * theta2 - 0.03202f * sunsky->theta + 0.00394f) * T +
- (+0.11693f * theta3 - 0.21196f * theta2 + 0.06052f * sunsky->theta + 0.25885f);
-
- sunsky->zenith_y =
- (+0.00275f * theta3 - 0.00610f * theta2 + 0.00316f * sunsky->theta + 0.0f) * T2 +
- (-0.04214f * theta3 + 0.08970f * theta2 - 0.04153f * sunsky->theta + 0.00515f) * T +
- (+0.15346f * theta3 - 0.26756f * theta2 + 0.06669f * sunsky->theta + 0.26688f);
-
-
- sunsky->perez_Y[0] = 0.17872f * T - 1.46303f;
- sunsky->perez_Y[1] = -0.35540f * T + 0.42749f;
- sunsky->perez_Y[2] = -0.02266f * T + 5.32505f;
- sunsky->perez_Y[3] = 0.12064f * T - 2.57705f;
- sunsky->perez_Y[4] = -0.06696f * T + 0.37027f;
-
- sunsky->perez_x[0] = -0.01925f * T - 0.25922f;
- sunsky->perez_x[1] = -0.06651f * T + 0.00081f;
- sunsky->perez_x[2] = -0.00041f * T + 0.21247f;
- sunsky->perez_x[3] = -0.06409f * T - 0.89887f;
- sunsky->perez_x[4] = -0.00325f * T + 0.04517f;
-
- sunsky->perez_y[0] = -0.01669f * T - 0.26078f;
- sunsky->perez_y[1] = -0.09495f * T + 0.00921f;
- sunsky->perez_y[2] = -0.00792f * T + 0.21023f;
- sunsky->perez_y[3] = -0.04405f * T - 1.65369f;
- sunsky->perez_y[4] = -0.01092f * T + 0.05291f;
-
- /* suggested by glome in patch [#8063] */
- sunsky->perez_Y[0] *= sunsky->horizon_brightness;
- sunsky->perez_x[0] *= sunsky->horizon_brightness;
- sunsky->perez_y[0] *= sunsky->horizon_brightness;
-
- sunsky->perez_Y[1] *= sunsky->spread;
- sunsky->perez_x[1] *= sunsky->spread;
- sunsky->perez_y[1] *= sunsky->spread;
-
- sunsky->perez_Y[2] *= sunsky->sun_brightness;
- sunsky->perez_x[2] *= sunsky->sun_brightness;
- sunsky->perez_y[2] *= sunsky->sun_brightness;
-
- sunsky->perez_Y[3] *= sunsky->sun_size;
- sunsky->perez_x[3] *= sunsky->sun_size;
- sunsky->perez_y[3] *= sunsky->sun_size;
-
- sunsky->perez_Y[4] *= sunsky->backscattered_light;
- sunsky->perez_x[4] *= sunsky->backscattered_light;
- sunsky->perez_y[4] *= sunsky->backscattered_light;
-}
-
-/**
- * GetSkyXYZRadiance:
- * this function compute sky radiance according to a view parameters `theta' and `phi'and sunSky values
- * parameters:
- * sunSky, sontains sun and sky parameters
- * theta, is sun's theta
- * phi, is sun's phi
- * color_out, is computed color that shows sky radiance in XYZ color format
- * */
-void GetSkyXYZRadiance(struct SunSky *sunsky, float theta, float phi, float color_out[3])
-{
- float gamma;
- float x, y, Y, X, Z;
- float hfade = 1, nfade = 1;
-
-
- if (theta > (float)M_PI_2) {
- hfade = 1.0f - (theta * (float)M_1_PI - 0.5f) * 2.0f;
- hfade = hfade * hfade * (3.0f - 2.0f * hfade);
- theta = M_PI_2;
- }
-
- if (sunsky->theta > (float)M_PI_2) {
- if (theta <= (float)M_PI_2) {
- nfade = 1.0f - (0.5f - theta * (float)M_1_PI) * 2.0f;
- nfade *= 1.0f - (sunsky->theta * (float)M_1_PI - 0.5f) * 2.0f;
- nfade = nfade * nfade * (3.0f - 2.0f * nfade);
- }
- }
-
- gamma = AngleBetween(theta, phi, sunsky->theta, sunsky->phi);
-
- /* Compute xyY values */
- x = PerezFunction(sunsky, sunsky->perez_x, theta, gamma, sunsky->zenith_x);
- y = PerezFunction(sunsky, sunsky->perez_y, theta, gamma, sunsky->zenith_y);
- Y = 6.666666667e-5f * nfade * hfade * PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y);
-
- if (sunsky->sky_exposure != 0.0f)
- Y = 1.0 - exp(Y * sunsky->sky_exposure);
-
- X = (x / y) * Y;
- Z = ((1 - x - y) / y) * Y;
-
- color_out[0] = X;
- color_out[1] = Y;
- color_out[2] = Z;
-}
-
-/**
- * GetSkyXYZRadiancef:
- * this function compute sky radiance according to a view direction `varg' and sunSky values
- * parameters:
- * sunSky, sontains sun and sky parameters
- * varg, shows direction
- * color_out, is computed color that shows sky radiance in XYZ color format
- * */
-void GetSkyXYZRadiancef(struct SunSky *sunsky, const float varg[3], float color_out[3])
-{
- float theta, phi;
- float v[3];
-
- normalize_v3_v3(v, varg);
-
- if (v[2] < 0.001f) {
- v[2] = 0.001f;
- normalize_v3(v);
- }
-
- DirectionToThetaPhi(v, &theta, &phi);
- GetSkyXYZRadiance(sunsky, theta, phi, color_out);
-}
-
-/**
- * ComputeAttenuatedSunlight:
- * this function compute attenuated sun light based on sun's theta and atmosphere turbidity
- * parameters:
- * theta, is sun's theta
- * turbidity: is atmosphere turbidity
- * fTau: contains computed attenuated sun light
- * */
-static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3])
-{
- float fBeta;
- float fTauR, fTauA;
- float m;
- float fAlpha;
-
- int i;
- float fLambda[3];
- fLambda[0] = 0.65f;
- fLambda[1] = 0.57f;
- fLambda[2] = 0.475f;
-
- fAlpha = 1.3f;
- fBeta = 0.04608365822050f * turbidity - 0.04586025928522f;
-
- m = 1.0f / (cosf(theta) + 0.15f * powf(93.885f - theta / (float)M_PI * 180.0f, -1.253f));
-
- for (i = 0; i < 3; i++) {
- /* Rayleigh Scattering */
- fTauR = expf(-m * 0.008735f * powf(fLambda[i], (float)(-4.08f)));
-
- /* Aerosal (water + dust) attenuation */
- fTauA = exp(-m * fBeta * powf(fLambda[i], -fAlpha));
-
- fTau[i] = fTauR * fTauA;
- }
-}
-
-/**
- * InitAtmosphere:
- * this function initiate sunSky structure with user input parameters.
- * parameters:
- * sunSky, contains information about sun, and in this function some atmosphere parameters will initiated
- * sun_intens, shows sun intensity value
- * mief, Mie scattering factor this factor currently call with 1.0
- * rayf, Rayleigh scattering factor, this factor currently call with 1.0
- * inscattf, inscatter light factor that range from 0.0 to 1.0, 0.0 means no inscatter light and 1.0 means full inscatter light
- * extincf, extinction light factor that range from 0.0 to 1.0, 0.0 means no extinction and 1.0 means full extinction
- * disf, is distance factor, multiplied to pixle's z value to compute each pixle's distance to camera,
- * */
-void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float rayf,
- float inscattf, float extincf, float disf)
-{
- const float pi = M_PI;
- const float n = 1.003f; /* refractive index */
- const float N = 2.545e25;
- const float pn = 0.035f;
- const float T = 2.0f;
- float fTemp, fTemp2, fTemp3, fBeta, fBetaDash;
- float c = (6.544f * T - 6.51f) * 1e-17f;
- float K[3] = {0.685f, 0.679f, 0.670f};
- float vBetaMieTemp[3];
-
- float fLambda[3], fLambda2[3], fLambda4[3];
- float vLambda2[3];
- float vLambda4[3];
-
- int i;
-
- sunSky->atm_SunIntensity = sun_intens;
- sunSky->atm_BetaMieMultiplier = mief;
- sunSky->atm_BetaRayMultiplier = rayf;
- sunSky->atm_InscatteringMultiplier = inscattf;
- sunSky->atm_ExtinctionMultiplier = extincf;
- sunSky->atm_DistanceMultiplier = disf;
-
- sunSky->atm_HGg = 0.8;
-
- fLambda[0] = 1 / 650e-9f;
- fLambda[1] = 1 / 570e-9f;
- fLambda[2] = 1 / 475e-9f;
- for (i = 0; i < 3; i++) {
- fLambda2[i] = fLambda[i] * fLambda[i];
- fLambda4[i] = fLambda2[i] * fLambda2[i];
- }
-
- vLambda2[0] = fLambda2[0];
- vLambda2[1] = fLambda2[1];
- vLambda2[2] = fLambda2[2];
-
- vLambda4[0] = fLambda4[0];
- vLambda4[1] = fLambda4[1];
- vLambda4[2] = fLambda4[2];
-
- /* Rayleigh scattering constants. */
- fTemp = pi * pi * (n * n - 1) * (n * n - 1) * (6 + 3 * pn) / (6 - 7 * pn) / N;
- fBeta = 8 * fTemp * pi / 3;
-
- VEC3OPF(sunSky->atm_BetaRay, vLambda4, *, fBeta);
- fBetaDash = fTemp / 2;
- VEC3OPF(sunSky->atm_BetaDashRay, vLambda4, *, fBetaDash);
-
-
- /* Mie scattering constants. */
- fTemp2 = 0.434f * c * (2 * pi) * (2 * pi) * 0.5f;
- VEC3OPF(sunSky->atm_BetaDashMie, vLambda2, *, fTemp2);
-
- fTemp3 = 0.434f * c * pi * (2 * pi) * (2 * pi);
-
- VEC3OPV(vBetaMieTemp, K, *, fLambda);
- VEC3OPF(sunSky->atm_BetaMie, vBetaMieTemp, *, fTemp3);
-
-}
-
-/**
- * AtmospherePixleShader:
- * this function apply atmosphere effect on a pixle color `rgb' at distance `s'
- * parameters:
- * sunSky, contains information about sun parameters and user values
- * view, is camera view vector
- * s, is distance
- * rgb, contains rendered color value for a pixle
- * */
-void AtmospherePixleShader(struct SunSky *sunSky, float view[3], float s, float rgb[3])
-{
- float costheta;
- float Phase_1;
- float Phase_2;
- float sunColor[3];
-
- float E[3];
- float E1[3];
-
-
- float I[3];
- float fTemp;
- float vTemp1[3], vTemp2[3];
-
- float sunDirection[3];
-
- s *= sunSky->atm_DistanceMultiplier;
-
- sunDirection[0] = sunSky->toSun[0];
- sunDirection[1] = sunSky->toSun[1];
- sunDirection[2] = sunSky->toSun[2];
-
- costheta = dot_v3v3(view, sunDirection); /* cos(theta) */
- Phase_1 = 1 + (costheta * costheta); /* Phase_1 */
-
- VEC3OPF(sunSky->atm_BetaRay, sunSky->atm_BetaRay, *, sunSky->atm_BetaRayMultiplier);
- VEC3OPF(sunSky->atm_BetaMie, sunSky->atm_BetaMie, *, sunSky->atm_BetaMieMultiplier);
- VEC3OPV(sunSky->atm_BetaRM, sunSky->atm_BetaRay, +, sunSky->atm_BetaMie);
-
- /* e^(-(beta_1 + beta_2) * s) = E1 */
- VEC3OPF(E1, sunSky->atm_BetaRM, *, -s / (float)M_LN2);
- E1[0] = exp(E1[0]);
- E1[1] = exp(E1[1]);
- E1[2] = exp(E1[2]);
-
- copy_v3_v3(E, E1);
-
- /* Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2) */
- fTemp = 1 + sunSky->atm_HGg - 2 * sunSky->atm_HGg * costheta;
- fTemp = fTemp * sqrtf(fTemp);
- Phase_2 = (1 - sunSky->atm_HGg * sunSky->atm_HGg) / fTemp;
-
- VEC3OPF(vTemp1, sunSky->atm_BetaDashRay, *, Phase_1);
- VEC3OPF(vTemp2, sunSky->atm_BetaDashMie, *, Phase_2);
-
- VEC3OPV(vTemp1, vTemp1, +, vTemp2);
- FOPVEC3(vTemp2, 1.0f, -, E1);
- VEC3OPV(vTemp1, vTemp1, *, vTemp2);
-
- FOPVEC3(vTemp2, 1.0f, /, sunSky->atm_BetaRM);
-
- VEC3OPV(I, vTemp1, *, vTemp2);
-
- VEC3OPF(I, I, *, sunSky->atm_InscatteringMultiplier);
- VEC3OPF(E, E, *, sunSky->atm_ExtinctionMultiplier);
-
- /* scale to color sun */
- ComputeAttenuatedSunlight(sunSky->theta, sunSky->turbidity, sunColor);
- VEC3OPV(E, E, *, sunColor);
-
- VEC3OPF(I, I, *, sunSky->atm_SunIntensity);
-
- VEC3OPV(rgb, rgb, *, E);
- VEC3OPV(rgb, rgb, +, I);
-}
-
-#undef VEC3OPV
-#undef VEC3OPF
-#undef FOPVEC3
-
-/* EOF */
diff --git a/source/blender/render/intern/source/texture_ocean.c b/source/blender/render/intern/source/texture_ocean.c
deleted file mode 100644
index a932123243d..00000000000
--- a/source/blender/render/intern/source/texture_ocean.c
+++ /dev/null
@@ -1,160 +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.
- *
- * Contributors: Matt Ebb
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/texture_ocean.c
- * \ingroup bke
- */
-
-#include <stddef.h>
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "DNA_modifier_types.h"
-#include "DNA_object_types.h"
-#include "DNA_texture_types.h"
-
-#include "BKE_global.h" /* XXX */
-
-#include "BKE_modifier.h"
-#include "BKE_ocean.h"
-
-#include "render_types.h"
-#include "RE_shader_ext.h"
-
-#include "texture.h"
-
-#include "texture_ocean.h" /* own include */
-
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-
-/* ***** actual texture sampling ***** */
-int ocean_texture(Tex *tex, const float texvec[2], TexResult *texres)
-{
- OceanTex *ot = tex->ot;
- ModifierData *md;
- OceanModifierData *omd;
-
- texres->tin = 0.0f;
-
- if ( !(ot) ||
- !(ot->object) ||
- !(md = (ModifierData *)modifiers_findByType(ot->object, eModifierType_Ocean)) ||
- !(omd = (OceanModifierData *)md)->ocean)
- {
- return 0;
- }
- else {
- const bool do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS) != 0;
- int cfra = R.r.cfra;
- int retval = TEX_INT;
-
- OceanResult ocr;
- const float u = 0.5f + 0.5f * texvec[0];
- const float v = 0.5f + 0.5f * texvec[1];
-
- if (omd->oceancache && omd->cached == true) {
-
- CLAMP(cfra, omd->bakestart, omd->bakeend);
- cfra -= omd->bakestart; /* shift to 0 based */
-
- BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v);
-
- }
- else { /* non-cached */
-
- if (G.is_rendering)
- BKE_ocean_eval_uv_catrom(omd->ocean, &ocr, u, v);
- else
- BKE_ocean_eval_uv(omd->ocean, &ocr, u, v);
-
- ocr.foam = BKE_ocean_jminus_to_foam(ocr.Jminus, omd->foam_coverage);
- }
-
- switch (ot->output) {
- case TEX_OCN_DISPLACEMENT:
- /* XYZ displacement */
- texres->tr = 0.5f + 0.5f * ocr.disp[0];
- texres->tg = 0.5f + 0.5f * ocr.disp[2];
- texres->tb = 0.5f + 0.5f * ocr.disp[1];
-
- texres->tr = MAX2(0.0f, texres->tr);
- texres->tg = MAX2(0.0f, texres->tg);
- texres->tb = MAX2(0.0f, texres->tb);
-
- BRICONTRGB;
-
- retval = TEX_RGB;
- break;
-
- case TEX_OCN_EMINUS:
- /* -ve eigenvectors ? */
- texres->tr = ocr.Eminus[0];
- texres->tg = ocr.Eminus[2];
- texres->tb = ocr.Eminus[1];
- retval = TEX_RGB;
- break;
-
- case TEX_OCN_EPLUS:
- /* -ve eigenvectors ? */
- texres->tr = ocr.Eplus[0];
- texres->tg = ocr.Eplus[2];
- texres->tb = ocr.Eplus[1];
- retval = TEX_RGB;
- break;
-
- case TEX_OCN_JPLUS:
- texres->tin = ocr.Jplus;
- retval = TEX_INT;
- break;
-
- case TEX_OCN_FOAM:
-
- texres->tin = ocr.foam;
-
- BRICONT;
-
- retval = TEX_INT;
- break;
- }
-
- /* if normals needed */
-
- if (texres->nor && do_normals) {
- normalize_v3_v3(texres->nor, ocr.normal);
- retval |= TEX_NOR;
- }
-
- texres->ta = 1.0f;
-
- return retval;
- }
-}
diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c
deleted file mode 100644
index 752a9df0b79..00000000000
--- a/source/blender/render/intern/source/volume_precache.c
+++ /dev/null
@@ -1,855 +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): Matt Ebb, Ra˙l Fern·ndez Hern·ndez (Farsthary).
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/volume_precache.c
- * \ingroup render
- */
-
-
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include <float.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_task.h"
-#include "BLI_threads.h"
-#include "BLI_voxel.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "PIL_time.h"
-
-#include "RE_shader_ext.h"
-
-#include "DNA_material_types.h"
-
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "render_types.h"
-#include "rendercore.h"
-#include "renderdatabase.h"
-#include "volumetric.h"
-#include "volume_precache.h"
-
-#include "atomic_ops.h"
-
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-/* *** utility code to set up an individual raytree for objectinstance, for checking inside/outside *** */
-
-/* Recursive test for intersections, from a point inside the mesh, to outside
- * Number of intersections (depth) determine if a point is inside or outside the mesh */
-static int intersect_outside_volume(RayObject *tree, Isect *isect, float *offset, int limit, int depth)
-{
- if (limit == 0) return depth;
-
- if (RE_rayobject_raycast(tree, isect)) {
-
- isect->start[0] = isect->start[0] + isect->dist*isect->dir[0];
- isect->start[1] = isect->start[1] + isect->dist*isect->dir[1];
- isect->start[2] = isect->start[2] + isect->dist*isect->dir[2];
-
- isect->dist = FLT_MAX;
- isect->skip = RE_SKIP_VLR_NEIGHBOUR;
- isect->orig.face= isect->hit.face;
- isect->orig.ob= isect->hit.ob;
-
- return intersect_outside_volume(tree, isect, offset, limit-1, depth+1);
- }
- else {
- return depth;
- }
-}
-
-/* Uses ray tracing to check if a point is inside or outside an ObjectInstanceRen */
-static int point_inside_obi(RayObject *tree, ObjectInstanceRen *obi, const float co[3])
-{
- Isect isect= {{0}};
- float dir[3] = {0.0f, 0.0f, 1.0f};
- int final_depth=0, depth=0, limit=20;
-
- /* set up the isect */
- copy_v3_v3(isect.start, co);
- copy_v3_v3(isect.dir, dir);
- isect.mode= RE_RAY_MIRROR;
- isect.last_hit= NULL;
- isect.lay= -1;
-
- isect.dist = FLT_MAX;
- isect.orig.face= NULL;
- isect.orig.ob = NULL;
-
- RE_instance_rotate_ray(obi, &isect);
- final_depth = intersect_outside_volume(tree, &isect, dir, limit, depth);
- RE_instance_rotate_ray_restore(obi, &isect);
-
- /* even number of intersections: point is outside
- * odd number: point is inside */
- if (final_depth % 2 == 0) return 0;
- else return 1;
-}
-
-/* find the bounding box of an objectinstance in global space */
-void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float bbmin[3], float bbmax[3])
-{
- ObjectRen *obr = obi->obr;
- VolumePrecache *vp = obi->volume_precache;
- VertRen *ver= NULL;
- float co[3];
- int a;
-
- if (vp->bbmin != NULL && vp->bbmax != NULL) {
- copy_v3_v3(bbmin, vp->bbmin);
- copy_v3_v3(bbmax, vp->bbmax);
- return;
- }
-
- vp->bbmin = MEM_callocN(sizeof(float)*3, "volume precache min boundbox corner");
- vp->bbmax = MEM_callocN(sizeof(float)*3, "volume precache max boundbox corner");
-
- INIT_MINMAX(bbmin, bbmax);
-
- for (a=0; a<obr->totvert; a++) {
- if ((a & 255)==0) ver= obr->vertnodes[a>>8].vert;
- else ver++;
-
- copy_v3_v3(co, ver->co);
-
- /* transformed object instance in camera space */
- if (obi->flag & R_TRANSFORMED)
- mul_m4_v3(obi->mat, co);
-
- /* convert to global space */
- mul_m4_v3(re->viewinv, co);
-
- minmax_v3v3_v3(vp->bbmin, vp->bbmax, co);
- }
-
- copy_v3_v3(bbmin, vp->bbmin);
- copy_v3_v3(bbmax, vp->bbmax);
-
-}
-
-/* *** light cache filtering *** */
-
-static float get_avg_surrounds(float *cache, int *res, int xx, int yy, int zz)
-{
- int x, y, z, x_, y_, z_;
- int added=0;
- float tot=0.0f;
-
- for (z=-1; z <= 1; z++) {
- z_ = zz+z;
- if (z_ >= 0 && z_ <= res[2]-1) {
-
- for (y=-1; y <= 1; y++) {
- y_ = yy+y;
- if (y_ >= 0 && y_ <= res[1]-1) {
-
- for (x=-1; x <= 1; x++) {
- x_ = xx+x;
- if (x_ >= 0 && x_ <= res[0]-1) {
- const int64_t i = BLI_VOXEL_INDEX(x_, y_, z_, res);
-
- if (cache[i] > 0.0f) {
- tot += cache[i];
- added++;
- }
-
- }
- }
- }
- }
- }
- }
-
- if (added > 0) tot /= added;
-
- return tot;
-}
-
-/* function to filter the edges of the light cache, where there was no volume originally.
- * For each voxel which was originally external to the mesh, it finds the average values of
- * the surrounding internal voxels and sets the original external voxel to that average amount.
- * Works almost a bit like a 'dilate' filter */
-static void lightcache_filter(VolumePrecache *vp)
-{
- int x, y, z;
-
- for (z=0; z < vp->res[2]; z++) {
- for (y=0; y < vp->res[1]; y++) {
- for (x=0; x < vp->res[0]; x++) {
- /* trigger for outside mesh */
- const int64_t i = BLI_VOXEL_INDEX(x, y, z, vp->res);
-
- if (vp->data_r[i] < -0.f)
- vp->data_r[i] = get_avg_surrounds(vp->data_r, vp->res, x, y, z);
- if (vp->data_g[i] < -0.f)
- vp->data_g[i] = get_avg_surrounds(vp->data_g, vp->res, x, y, z);
- if (vp->data_b[i] < -0.f)
- vp->data_b[i] = get_avg_surrounds(vp->data_b, vp->res, x, y, z);
- }
- }
- }
-}
-
-#if 0
-static void lightcache_filter2(VolumePrecache *vp)
-{
- int x, y, z;
- float *new_r, *new_g, *new_b;
- int field_size = vp->res[0]*vp->res[1]*vp->res[2]*sizeof(float);
-
- new_r = MEM_mallocN(field_size, "temp buffer for light cache filter r channel");
- new_g = MEM_mallocN(field_size, "temp buffer for light cache filter g channel");
- new_b = MEM_mallocN(field_size, "temp buffer for light cache filter b channel");
-
- memcpy(new_r, vp->data_r, field_size);
- memcpy(new_g, vp->data_g, field_size);
- memcpy(new_b, vp->data_b, field_size);
-
- for (z=0; z < vp->res[2]; z++) {
- for (y=0; y < vp->res[1]; y++) {
- for (x=0; x < vp->res[0]; x++) {
- /* trigger for outside mesh */
- const int64_t i = BLI_VOXEL_INDEX(x, y, z, vp->res);
- if (vp->data_r[i] < -0.f)
- new_r[i] = get_avg_surrounds(vp->data_r, vp->res, x, y, z);
- if (vp->data_g[i] < -0.f)
- new_g[i] = get_avg_surrounds(vp->data_g, vp->res, x, y, z);
- if (vp->data_b[i] < -0.f)
- new_b[i] = get_avg_surrounds(vp->data_b, vp->res, x, y, z);
- }
- }
- }
-
- SWAP(float *, vp->data_r, new_r);
- SWAP(float *, vp->data_g, new_g);
- SWAP(float *, vp->data_b, new_b);
-
- if (new_r) { MEM_freeN(new_r); new_r=NULL; }
- if (new_g) { MEM_freeN(new_g); new_g=NULL; }
- if (new_b) { MEM_freeN(new_b); new_b=NULL; }
-}
-#endif
-
-/* has a pad of 1 voxel surrounding the core for boundary simulation */
-BLI_INLINE int64_t ms_I(int x, int y, int z, const int *n)
-{
- /* different ordering to light cache */
- return ((int64_t)x * (int64_t)(n[1] + 2) * (int64_t)(n[2] + 2) +
- (int64_t)y * (int64_t)(n[2] + 2) +
- (int64_t)z);
-}
-
-/* has a pad of 1 voxel surrounding the core for boundary simulation */
-BLI_INLINE int64_t v_I_pad(int x, int y, int z, const int *n)
-{
- /* same ordering to light cache, with padding */
- return ((int64_t)z * (int64_t)(n[1] + 2) * (int64_t)(n[0] + 2) +
- (int64_t)y * (int64_t)(n[0] + 2) +
- (int64_t)x);
-}
-
-BLI_INLINE int64_t lc_to_ms_I(int x, int y, int z, const int *n)
-{
- /* converting light cache index to multiple scattering index */
- return ((int64_t)(x - 1) * ((int64_t)n[1] * (int64_t)n[2]) +
- (int64_t)(y - 1) * ((int64_t)n[2]) +
- (int64_t)(z - 1));
-}
-
-/* *** multiple scattering approximation *** */
-
-/* get the total amount of light energy in the light cache. used to normalize after multiple scattering */
-static float total_ss_energy(Render *re, int do_test_break, VolumePrecache *vp)
-{
- int x, y, z;
- const int *res = vp->res;
- float energy=0.f;
-
- for (z=0; z < res[2]; z++) {
- for (y=0; y < res[1]; y++) {
- for (x=0; x < res[0]; x++) {
- const int64_t i = BLI_VOXEL_INDEX(x, y, z, res);
-
- if (vp->data_r[i] > 0.f) energy += vp->data_r[i];
- if (vp->data_g[i] > 0.f) energy += vp->data_g[i];
- if (vp->data_b[i] > 0.f) energy += vp->data_b[i];
- }
- }
-
- if (do_test_break && re->test_break(re->tbh)) break;
- }
-
- return energy;
-}
-
-static float total_ms_energy(Render *re, int do_test_break, float *sr, float *sg, float *sb, const int res[3])
-{
- int x, y, z;
- float energy=0.f;
-
- for (z=1;z<=res[2];z++) {
- for (y=1;y<=res[1];y++) {
- for (x=1;x<=res[0];x++) {
- const int64_t i = ms_I(x, y, z, res);
-
- if (sr[i] > 0.f) energy += sr[i];
- if (sg[i] > 0.f) energy += sg[i];
- if (sb[i] > 0.f) energy += sb[i];
- }
- }
-
- if (do_test_break && re->test_break(re->tbh)) break;
- }
-
- return energy;
-}
-
-/**
- * \param n: the unpadded resolution
- */
-static void ms_diffuse(Render *re, int do_test_break, const float *x0, float *x, float diff, const int n[3])
-{
- int i, j, k, l;
- const float dt = VOL_MS_TIMESTEP;
- int64_t size = (int64_t)n[0] * (int64_t)n[1] * (int64_t)n[2];
- const float a = dt * diff * size;
-
- for (l=0; l<20; l++) {
- for (k=1; k<=n[2]; k++) {
- for (j=1; j<=n[1]; j++) {
- for (i=1; i<=n[0]; i++) {
- x[v_I_pad(i, j, k, n)] =
- ((x0[v_I_pad(i, j, k, n)]) + (
- (x0[v_I_pad(i - 1, j, k, n)] +
- x0[v_I_pad(i + 1, j, k, n)] +
- x0[v_I_pad(i, j - 1, k, n)] +
- x0[v_I_pad(i, j + 1, k, n)] +
- x0[v_I_pad(i, j, k - 1, n)] +
- x0[v_I_pad(i, j, k + 1, n)]) * a) / (1 + 6 * a));
- }
- }
-
- if (do_test_break && re->test_break(re->tbh)) break;
- }
-
- if (re->test_break(re->tbh)) break;
- }
-}
-
-static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Material *ma)
-{
- const float diff = ma->vol.ms_diff * 0.001f; /* compensate for scaling for a nicer UI range */
- const int simframes = (int)(ma->vol.ms_spread * (float)max_iii(vp->res[0], vp->res[1], vp->res[2]));
- const int shade_type = ma->vol.shade_type;
- float fac = ma->vol.ms_intensity;
-
- int x, y, z, m;
- const int *n = vp->res;
- const int size = (n[0]+2)*(n[1]+2)*(n[2]+2);
- const int do_test_break = (size > 100000);
- double time, lasttime= PIL_check_seconds_timer();
- float total;
- float c=1.0f;
- float origf; /* factor for blending in original light cache */
- float energy_ss, energy_ms;
-
- float *sr0=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer");
- float *sr=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer");
- float *sg0=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer");
- float *sg=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer");
- float *sb0=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer");
- float *sb=(float *)MEM_callocN(size*sizeof(float), "temporary multiple scattering buffer");
-
- total = (float)(n[0]*n[1]*n[2]*simframes);
-
- energy_ss = total_ss_energy(re, do_test_break, vp);
-
- /* Scattering as diffusion pass */
- for (m=0; m<simframes; m++) {
- /* add sources */
- for (z=1; z<=n[2]; z++) {
- for (y=1; y<=n[1]; y++) {
- for (x=1; x<=n[0]; x++) {
- const int64_t i = lc_to_ms_I(x, y, z, n); //lc index
- const int64_t j = ms_I(x, y, z, n); //ms index
-
- time= PIL_check_seconds_timer();
- c++;
- if (vp->data_r[i] > 0.0f)
- sr[j] += vp->data_r[i];
- if (vp->data_g[i] > 0.0f)
- sg[j] += vp->data_g[i];
- if (vp->data_b[i] > 0.0f)
- sb[j] += vp->data_b[i];
-
- /* Displays progress every second */
- if (time-lasttime>1.0) {
- char str[64];
- BLI_snprintf(str, sizeof(str), IFACE_("Simulating multiple scattering: %d%%"),
- (int)(100.0f * (c / total)));
- re->i.infostr = str;
- re->stats_draw(re->sdh, &re->i);
- re->i.infostr = NULL;
- lasttime= time;
- }
- }
- }
-
- if (do_test_break && re->test_break(re->tbh)) break;
- }
-
- if (re->test_break(re->tbh)) break;
-
- SWAP(float *, sr, sr0);
- SWAP(float *, sg, sg0);
- SWAP(float *, sb, sb0);
-
- /* main diffusion simulation */
- ms_diffuse(re, do_test_break, sr0, sr, diff, n);
- ms_diffuse(re, do_test_break, sg0, sg, diff, n);
- ms_diffuse(re, do_test_break, sb0, sb, diff, n);
-
- if (re->test_break(re->tbh)) break;
- }
-
- /* normalization factor to conserve energy */
- energy_ms = total_ms_energy(re, do_test_break, sr, sg, sb, n);
- fac *= (energy_ss / energy_ms);
-
- /* blend multiple scattering back in the light cache */
- if (shade_type == MA_VOL_SHADE_SHADEDPLUSMULTIPLE) {
- /* conserve energy - half single, half multiple */
- origf = 0.5f;
- fac *= 0.5f;
- }
- else {
- origf = 0.0f;
- }
-
- for (z=1;z<=n[2];z++) {
- for (y=1;y<=n[1];y++) {
- for (x=1;x<=n[0];x++) {
- const int64_t i = lc_to_ms_I(x, y, z, n); //lc index
- const int64_t j = ms_I(x, y, z, n); //ms index
-
- vp->data_r[i] = origf * vp->data_r[i] + fac * sr[j];
- vp->data_g[i] = origf * vp->data_g[i] + fac * sg[j];
- vp->data_b[i] = origf * vp->data_b[i] + fac * sb[j];
- }
- }
-
- if (do_test_break && re->test_break(re->tbh)) break;
- }
-
- MEM_freeN(sr0);
- MEM_freeN(sr);
- MEM_freeN(sg0);
- MEM_freeN(sg);
- MEM_freeN(sb0);
- MEM_freeN(sb);
-}
-
-
-
-#if 0 /* debug stuff */
-static void *vol_precache_part_test(void *data)
-{
- VolPrecachePart *pa = data;
-
- printf("part number: %d\n", pa->num);
- printf("done: %d\n", pa->done);
- printf("x min: %d x max: %d\n", pa->minx, pa->maxx);
- printf("y min: %d y max: %d\n", pa->miny, pa->maxy);
- printf("z min: %d z max: %d\n", pa->minz, pa->maxz);
-
- return NULL;
-}
-#endif
-
-/* Iterate over the 3d voxel grid, and fill the voxels with scattering information
- *
- * It's stored in memory as 3 big float grids next to each other, one for each RGB channel.
- * I'm guessing the memory alignment may work out better this way for the purposes
- * of doing linear interpolation, but I haven't actually tested this theory! :)
- */
-typedef struct VolPrecacheState {
- double lasttime;
- unsigned int doneparts;
- unsigned int totparts;
-} VolPrecacheState;
-
-static void vol_precache_part(TaskPool * __restrict pool, void *taskdata, int UNUSED(threadid))
-{
- VolPrecacheState *state = (VolPrecacheState *)BLI_task_pool_userdata(pool);
- VolPrecachePart *pa = (VolPrecachePart *)taskdata;
- Render *re = pa->re;
-
- ObjectInstanceRen *obi = pa->obi;
- RayObject *tree = pa->tree;
- ShadeInput *shi = pa->shi;
- float scatter_col[3] = {0.f, 0.f, 0.f};
- float co[3], cco[3], view[3];
- int x, y, z;
- int res[3];
- double time;
-
- if (re->test_break && re->test_break(re->tbh))
- return;
-
- //printf("thread id %d\n", threadid);
-
- res[0]= pa->res[0];
- res[1]= pa->res[1];
- res[2]= pa->res[2];
-
- for (z= pa->minz; z < pa->maxz; z++) {
- co[2] = pa->bbmin[2] + (pa->voxel[2] * (z + 0.5f));
-
- for (y= pa->miny; y < pa->maxy; y++) {
- co[1] = pa->bbmin[1] + (pa->voxel[1] * (y + 0.5f));
-
- for (x=pa->minx; x < pa->maxx; x++) {
- int64_t i;
- co[0] = pa->bbmin[0] + (pa->voxel[0] * (x + 0.5f));
-
- if (re->test_break && re->test_break(re->tbh))
- break;
-
- /* convert from world->camera space for shading */
- mul_v3_m4v3(cco, pa->viewmat, co);
-
- i = BLI_VOXEL_INDEX(x, y, z, res);
-
- /* don't bother if the point is not inside the volume mesh */
- if (!point_inside_obi(tree, obi, cco)) {
- obi->volume_precache->data_r[i] = -1.0f;
- obi->volume_precache->data_g[i] = -1.0f;
- obi->volume_precache->data_b[i] = -1.0f;
- continue;
- }
-
- copy_v3_v3(view, cco);
- normalize_v3(view);
- vol_get_scattering(shi, scatter_col, cco, view);
-
- obi->volume_precache->data_r[i] = scatter_col[0];
- obi->volume_precache->data_g[i] = scatter_col[1];
- obi->volume_precache->data_b[i] = scatter_col[2];
-
- }
- }
- }
-
- unsigned int doneparts = atomic_add_and_fetch_u(&state->doneparts, 1);
-
- time = PIL_check_seconds_timer();
- if (time - state->lasttime > 1.0) {
- ThreadMutex *mutex = BLI_task_pool_user_mutex(pool);
-
- if (BLI_mutex_trylock(mutex)) {
- char str[64];
- float ratio = (float)doneparts/(float)state->totparts;
- BLI_snprintf(str, sizeof(str), IFACE_("Precaching volume: %d%%"), (int)(100.0f * ratio));
- re->i.infostr = str;
- re->stats_draw(re->sdh, &re->i);
- re->i.infostr = NULL;
- state->lasttime = time;
-
- BLI_mutex_unlock(mutex);
- }
- }
-}
-
-static void precache_setup_shadeinput(Render *re, ObjectInstanceRen *obi, Material *ma, ShadeInput *shi)
-{
- memset(shi, 0, sizeof(ShadeInput));
- shi->depth= 1;
- shi->mask= 1;
- shi->mat = ma;
- shi->vlr = NULL;
- memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); /* note, keep this synced with render_types.h */
- shi->har= shi->mat->har;
- shi->obi= obi;
- shi->obr= obi->obr;
- shi->lay = re->lay;
-}
-
-static void precache_launch_parts(Render *re, RayObject *tree, ShadeInput *shi, ObjectInstanceRen *obi)
-{
- TaskScheduler *task_scheduler;
- TaskPool *task_pool;
- VolumePrecache *vp = obi->volume_precache;
- VolPrecacheState state;
- int i=0, x, y, z;
- float voxel[3];
- int sizex, sizey, sizez;
- float bbmin[3], bbmax[3];
- const int *res;
- int minx, maxx;
- int miny, maxy;
- int minz, maxz;
- int totthread = re->r.threads;
- int parts[3];
-
- if (!vp) return;
-
- /* currently we just subdivide the box, number of threads per side */
- parts[0] = parts[1] = parts[2] = totthread;
- res = vp->res;
-
- /* setup task scheduler */
- memset(&state, 0, sizeof(state));
- state.doneparts = 0;
- state.totparts = parts[0]*parts[1]*parts[2];
- state.lasttime = PIL_check_seconds_timer();
-
- task_scheduler = BLI_task_scheduler_create(totthread);
- task_pool = BLI_task_pool_create(task_scheduler, &state);
-
- /* using boundbox in worldspace */
- global_bounds_obi(re, obi, bbmin, bbmax);
- sub_v3_v3v3(voxel, bbmax, bbmin);
-
- voxel[0] /= (float)res[0];
- voxel[1] /= (float)res[1];
- voxel[2] /= (float)res[2];
-
- for (x=0; x < parts[0]; x++) {
- sizex = ceil(res[0] / (float)parts[0]);
- minx = x * sizex;
- maxx = minx + sizex;
- maxx = (maxx>res[0])?res[0]:maxx;
-
- for (y=0; y < parts[1]; y++) {
- sizey = ceil(res[1] / (float)parts[1]);
- miny = y * sizey;
- maxy = miny + sizey;
- maxy = (maxy>res[1])?res[1]:maxy;
-
- for (z=0; z < parts[2]; z++) {
- VolPrecachePart *pa= MEM_callocN(sizeof(VolPrecachePart), "new precache part");
-
- sizez = ceil(res[2] / (float)parts[2]);
- minz = z * sizez;
- maxz = minz + sizez;
- maxz = (maxz>res[2])?res[2]:maxz;
-
- pa->re = re;
- pa->num = i;
- pa->tree = tree;
- pa->shi = shi;
- pa->obi = obi;
- copy_m4_m4(pa->viewmat, re->viewmat);
-
- copy_v3_v3(pa->bbmin, bbmin);
- copy_v3_v3(pa->voxel, voxel);
- copy_v3_v3_int(pa->res, res);
-
- pa->minx = minx; pa->maxx = maxx;
- pa->miny = miny; pa->maxy = maxy;
- pa->minz = minz; pa->maxz = maxz;
-
- BLI_task_pool_push(task_pool, vol_precache_part, pa, true, TASK_PRIORITY_HIGH);
-
- i++;
- }
- }
- }
-
- /* work and wait until tasks are done */
- BLI_task_pool_work_and_wait(task_pool);
-
- /* free */
- BLI_task_pool_free(task_pool);
- BLI_task_scheduler_free(task_scheduler);
-}
-
-/* calculate resolution from bounding box in world space */
-static int precache_resolution(Render *re, VolumePrecache *vp, ObjectInstanceRen *obi, int res)
-{
- float dim[3], div;
- float bbmin[3], bbmax[3];
-
- /* bound box in global space */
- global_bounds_obi(re, obi, bbmin, bbmax);
- sub_v3_v3v3(dim, bbmax, bbmin);
-
- div = max_fff(dim[0], dim[1], dim[2]);
- dim[0] /= div;
- dim[1] /= div;
- dim[2] /= div;
-
- vp->res[0] = ceil(dim[0] * res);
- vp->res[1] = ceil(dim[1] * res);
- vp->res[2] = ceil(dim[2] * res);
-
- if ((vp->res[0] < 1) || (vp->res[1] < 1) || (vp->res[2] < 1))
- return 0;
-
- return 1;
-}
-
-/* Precache a volume into a 3D voxel grid.
- * The voxel grid is stored in the ObjectInstanceRen,
- * in camera space, aligned with the ObjectRen's bounding box.
- * Resolution is defined by the user.
- */
-static void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *obi, Material *ma)
-{
- VolumePrecache *vp;
- RayObject *tree;
- ShadeInput shi;
-
- R = *re;
-
- /* create a raytree with just the faces of the instanced ObjectRen,
- * used for checking if the cached point is inside or outside. */
- tree = makeraytree_object(&R, obi);
- if (!tree) return;
-
- vp = MEM_callocN(sizeof(VolumePrecache), "volume light cache");
- obi->volume_precache = vp;
-
- if (!precache_resolution(re, vp, obi, ma->vol.precache_resolution)) {
- MEM_freeN(vp);
- vp = NULL;
- return;
- }
-
- vp->data_r = MEM_callocN(sizeof(float)*vp->res[0]*vp->res[1]*vp->res[2], "volume light cache data red channel");
- vp->data_g = MEM_callocN(sizeof(float)*vp->res[0]*vp->res[1]*vp->res[2], "volume light cache data green channel");
- vp->data_b = MEM_callocN(sizeof(float)*vp->res[0]*vp->res[1]*vp->res[2], "volume light cache data blue channel");
- if (vp->data_r==NULL || vp->data_g==NULL || vp->data_b==NULL) {
- MEM_freeN(vp);
- return;
- }
-
- /* Need a shadeinput to calculate scattering */
- precache_setup_shadeinput(re, obi, ma, &shi);
-
- precache_launch_parts(re, tree, &shi, obi);
-
- if (tree) {
- /* TODO: makeraytree_object creates a tree and saves it on OBI,
- * if we free this tree we should also clear other pointers to it */
- //RE_rayobject_free(tree);
- //tree= NULL;
- }
-
- if (ELEM(ma->vol.shade_type, MA_VOL_SHADE_MULTIPLE, MA_VOL_SHADE_SHADEDPLUSMULTIPLE)) {
- /* this should be before the filtering */
- multiple_scattering_diffusion(re, obi->volume_precache, ma);
- }
-
- lightcache_filter(obi->volume_precache);
-}
-
-static int using_lightcache(Material *ma)
-{
- return (((ma->vol.shadeflag & MA_VOL_PRECACHESHADING) && (ma->vol.shade_type == MA_VOL_SHADE_SHADED)) ||
- (ELEM(ma->vol.shade_type, MA_VOL_SHADE_MULTIPLE, MA_VOL_SHADE_SHADEDPLUSMULTIPLE)));
-}
-
-/* loop through all objects (and their associated materials)
- * marked for pre-caching in convertblender.c, and pre-cache them */
-void volume_precache(Render *re)
-{
- ObjectInstanceRen *obi;
- VolumeOb *vo;
-
- re->i.infostr = IFACE_("Volume preprocessing");
- re->stats_draw(re->sdh, &re->i);
-
- for (vo= re->volumes.first; vo; vo= vo->next) {
- if (using_lightcache(vo->ma)) {
- for (obi= re->instancetable.first; obi; obi= obi->next) {
- if (obi->obr == vo->obr) {
- vol_precache_objectinstance_threads(re, obi, vo->ma);
-
- if (re->test_break && re->test_break(re->tbh))
- break;
- }
- }
-
- if (re->test_break && re->test_break(re->tbh))
- break;
- }
- }
-
- re->i.infostr = NULL;
- re->stats_draw(re->sdh, &re->i);
-}
-
-void free_volume_precache(Render *re)
-{
- ObjectInstanceRen *obi;
-
- for (obi= re->instancetable.first; obi; obi= obi->next) {
- if (obi->volume_precache != NULL) {
- MEM_freeN(obi->volume_precache->data_r);
- MEM_freeN(obi->volume_precache->data_g);
- MEM_freeN(obi->volume_precache->data_b);
- MEM_freeN(obi->volume_precache->bbmin);
- MEM_freeN(obi->volume_precache->bbmax);
- MEM_freeN(obi->volume_precache);
- obi->volume_precache = NULL;
- }
- }
-
- BLI_freelistN(&re->volumes);
-}
-
-int point_inside_volume_objectinstance(Render *re, ObjectInstanceRen *obi, const float co[3])
-{
- RayObject *tree;
- int inside=0;
-
- tree = makeraytree_object(re, obi);
- if (!tree) return 0;
-
- inside = point_inside_obi(tree, obi, co);
-
- //TODO: makeraytree_object creates a tree and saves it on OBI, if we free this tree we should also clear other pointers to it
- //RE_rayobject_free(tree);
- //tree= NULL;
-
- return inside;
-}
-
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
deleted file mode 100644
index e12a7246254..00000000000
--- a/source/blender/render/intern/source/volumetric.c
+++ /dev/null
@@ -1,834 +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): Matt Ebb, Raul Fernandez Hernandez (Farsthary)
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/volumetric.c
- * \ingroup render
- */
-
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include <float.h>
-
-#include "BLI_math.h"
-#include "BLI_rand.h"
-#include "BLI_voxel.h"
-#include "BLI_utildefines.h"
-
-#include "RE_shader_ext.h"
-
-#include "IMB_colormanagement.h"
-
-#include "DNA_material_types.h"
-#include "DNA_group_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_meta_types.h"
-
-
-#include "render_types.h"
-#include "pixelshading.h"
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "renderdatabase.h"
-#include "shading.h"
-#include "shadbuf.h"
-#include "texture.h"
-#include "volumetric.h"
-#include "volume_precache.h"
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-/* tracing */
-static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3])
-{
- float visibility = 1.f;
-
- if (lar->shb) {
- float dxco[3] = {0.f, 0.f, 0.f}, dyco[3] = {0.f, 0.f, 0.f};
-
- visibility = testshadowbuf(&R, lar->shb, co, dxco, dyco, 1.0, 0.0);
- }
- else if (lar->mode & LA_SHAD_RAY) {
- /* trace shadow manually, no good lamp api atm */
- Isect is;
-
- copy_v3_v3(is.start, co);
- if (lar->type == LA_SUN || lar->type == LA_HEMI) {
- is.dir[0] = -lar->vec[0];
- is.dir[1] = -lar->vec[1];
- is.dir[2] = -lar->vec[2];
- is.dist = R.maxdist;
- }
- else {
- sub_v3_v3v3(is.dir, lar->co, is.start);
- is.dist = normalize_v3(is.dir);
- }
-
- is.mode = RE_RAY_MIRROR;
- is.check = RE_CHECK_VLR_NON_SOLID_MATERIAL;
- is.skip = 0;
-
- if (lar->mode & (LA_LAYER | LA_LAYER_SHADOW))
- is.lay = lar->lay;
- else
- is.lay = -1;
-
- is.orig.ob = NULL;
- is.orig.face = NULL;
- is.last_hit = lar->last_hit[shi->thread];
-
- RE_instance_rotate_ray(shi->obi, &is);
-
- if (RE_rayobject_raycast(R.raytree, &is)) {
- RE_instance_rotate_ray_restore(shi->obi, &is);
-
- visibility = 0.f;
- }
-
- lar->last_hit[shi->thread] = is.last_hit;
- }
- return visibility;
-}
-
-static int vol_get_bounds(ShadeInput *shi, const float co[3], const float vec[3], float hitco[3], Isect *isect, int intersect_type)
-{
-
- copy_v3_v3(isect->start, co);
- copy_v3_v3(isect->dir, vec);
- isect->dist = FLT_MAX;
- isect->mode = RE_RAY_MIRROR;
- isect->last_hit = NULL;
- isect->lay = -1;
- isect->check = RE_CHECK_VLR_NONE;
-
- if (intersect_type == VOL_BOUNDS_DEPTH) {
- isect->skip = RE_SKIP_VLR_NEIGHBOUR;
- isect->orig.face = (void *)shi->vlr;
- isect->orig.ob = (void *)shi->obi;
- }
- else { // if (intersect_type == VOL_BOUNDS_SS) {
- isect->skip = 0;
- isect->orig.face = NULL;
- isect->orig.ob = NULL;
- }
-
- RE_instance_rotate_ray(shi->obi, isect);
-
- if (RE_rayobject_raycast(R.raytree, isect)) {
- RE_instance_rotate_ray_restore(shi->obi, isect);
-
- hitco[0] = isect->start[0] + isect->dist * isect->dir[0];
- hitco[1] = isect->start[1] + isect->dist * isect->dir[1];
- hitco[2] = isect->start[2] + isect->dist * isect->dir[2];
- return 1;
- }
- else {
- return 0;
- }
-}
-
-static void shade_intersection(ShadeInput *shi, float col_r[4], Isect *is)
-{
- ShadeInput shi_new;
- ShadeResult shr_new;
-
- memset(&shi_new, 0, sizeof(ShadeInput));
-
- shi_new.mask = shi->mask;
- shi_new.osatex = shi->osatex;
- shi_new.thread = shi->thread;
- shi_new.depth = shi->depth + 1;
- shi_new.volume_depth = shi->volume_depth + 1;
- shi_new.xs = shi->xs;
- shi_new.ys = shi->ys;
- shi_new.lay = shi->lay;
- shi_new.passflag = SCE_PASS_COMBINED; /* result of tracing needs no pass info */
- shi_new.combinedflag = 0xFFFFFF; /* ray trace does all options */
-
- copy_v3_v3(shi_new.camera_co, is->start);
-
- memset(&shr_new, 0, sizeof(ShadeResult));
-
- /* hardcoded limit of 100 for now - prevents problems in weird geometry */
- if (shi->volume_depth < 100) {
- shade_ray(is, &shi_new, &shr_new);
- }
-
- copy_v3_v3(col_r, shr_new.combined);
- col_r[3] = shr_new.alpha;
-}
-
-static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], float col_r[4])
-{
- Isect isect;
-
- copy_v3_v3(isect.start, co);
- copy_v3_v3(isect.dir, shi->view);
- isect.dist = FLT_MAX;
-
- isect.mode = RE_RAY_MIRROR;
- isect.check = RE_CHECK_VLR_NONE;
- isect.skip = RE_SKIP_VLR_NEIGHBOUR;
- isect.orig.ob = (void *) shi->obi;
- isect.orig.face = (void *)vlr;
- isect.last_hit = NULL;
- isect.lay = -1;
-
- /* check to see if there's anything behind the volume, otherwise shade the sky */
- RE_instance_rotate_ray(shi->obi, &isect);
-
- if (RE_rayobject_raycast(R.raytree, &isect)) {
- RE_instance_rotate_ray_restore(shi->obi, &isect);
-
- shade_intersection(shi, col_r, &isect);
- }
- else {
- shadeSkyView(col_r, co, shi->view, NULL, shi->thread);
- shadeSunView(col_r, shi->view);
- }
-}
-
-
-/* trilinear interpolation */
-static void vol_get_precached_scattering(Render *re, ShadeInput *shi, float scatter_col[3], const float co[3])
-{
- VolumePrecache *vp = shi->obi->volume_precache;
- float bbmin[3], bbmax[3], dim[3];
- float world_co[3], sample_co[3];
-
- if (!vp) return;
-
- /* find sample point in global space bounding box 0.0-1.0 */
- global_bounds_obi(re, shi->obi, bbmin, bbmax);
- sub_v3_v3v3(dim, bbmax, bbmin);
- mul_v3_m4v3(world_co, re->viewinv, co);
-
- /* sample_co in 0.0-1.0 */
- sample_co[0] = (world_co[0] - bbmin[0]) / dim[0];
- sample_co[1] = (world_co[1] - bbmin[1]) / dim[1];
- sample_co[2] = (world_co[2] - bbmin[2]) / dim[2];
-
- scatter_col[0] = BLI_voxel_sample_triquadratic(vp->data_r, vp->res, sample_co);
- scatter_col[1] = BLI_voxel_sample_triquadratic(vp->data_g, vp->res, sample_co);
- scatter_col[2] = BLI_voxel_sample_triquadratic(vp->data_b, vp->res, sample_co);
-}
-
-/* Meta object density, brute force for now
- * (might be good enough anyway, don't need huge number of metaobs to model volumetric objects */
-static float metadensity(Object *ob, const float co[3])
-{
- float mat[4][4], imat[4][4], dens = 0.f;
- MetaBall *mb = (MetaBall *)ob->data;
- MetaElem *ml;
-
- /* transform co to meta-element */
- float tco[3] = {co[0], co[1], co[2]};
- mul_m4_m4m4(mat, R.viewmat, ob->obmat);
- invert_m4_m4(imat, mat);
- mul_m4_v3(imat, tco);
-
- for (ml = mb->elems.first; ml; ml = ml->next) {
- float bmat[3][3], dist2;
-
- /* element rotation transform */
- float tp[3] = {ml->x - tco[0], ml->y - tco[1], ml->z - tco[2]};
- quat_to_mat3(bmat, ml->quat);
- transpose_m3(bmat); /* rot.only, so inverse == transpose */
- mul_m3_v3(bmat, tp);
-
- /* MB_BALL default */
- switch (ml->type) {
- case MB_ELIPSOID:
- tp[0] /= ml->expx;
- tp[1] /= ml->expy;
- tp[2] /= ml->expz;
- break;
- case MB_CUBE:
- tp[2] = (tp[2] > ml->expz) ? (tp[2] - ml->expz) : ((tp[2] < -ml->expz) ? (tp[2] + ml->expz) : 0.f);
- /* no break, xy as plane */
- ATTR_FALLTHROUGH;
- case MB_PLANE:
- tp[1] = (tp[1] > ml->expy) ? (tp[1] - ml->expy) : ((tp[1] < -ml->expy) ? (tp[1] + ml->expy) : 0.f);
- /* no break, x as tube */
- ATTR_FALLTHROUGH;
- case MB_TUBE:
- tp[0] = (tp[0] > ml->expx) ? (tp[0] - ml->expx) : ((tp[0] < -ml->expx) ? (tp[0] + ml->expx) : 0.f);
- }
-
- /* ml->rad2 is not set */
- dist2 = 1.0f - (dot_v3v3(tp, tp) / (ml->rad * ml->rad));
- if (dist2 > 0.f)
- dens += (ml->flag & MB_NEGATIVE) ? -ml->s * dist2 * dist2 * dist2 : ml->s * dist2 * dist2 * dist2;
- }
-
- dens -= mb->thresh;
- return (dens < 0.f) ? 0.f : dens;
-}
-
-float vol_get_density(struct ShadeInput *shi, const float co[3])
-{
- float density = shi->mat->vol.density;
- float density_scale = shi->mat->vol.density_scale;
-
- if (shi->mat->mapto_textured & MAP_DENSITY)
- do_volume_tex(shi, co, MAP_DENSITY, NULL, &density, &R);
-
- /* if meta-object, modulate by metadensity without increasing it */
- if (shi->obi->obr->ob->type == OB_MBALL) {
- const float md = metadensity(shi->obi->obr->ob, co);
- if (md < 1.f) density *= md;
- }
-
- return density * density_scale;
-}
-
-
-/* Color of light that gets scattered out by the volume */
-/* Uses same physically based scattering parameter as in transmission calculations,
- * along with artificial reflection scale/reflection color tint */
-static void vol_get_reflection_color(ShadeInput *shi, float ref_col[3], const float co[3])
-{
- float scatter = shi->mat->vol.scattering;
- float reflection = shi->mat->vol.reflection;
- copy_v3_v3(ref_col, shi->mat->vol.reflection_col);
-
- if (shi->mat->mapto_textured & (MAP_SCATTERING + MAP_REFLECTION_COL))
- do_volume_tex(shi, co, MAP_SCATTERING + MAP_REFLECTION_COL, ref_col, &scatter, &R);
-
- /* only one single float parameter at a time... :s */
- if (shi->mat->mapto_textured & (MAP_REFLECTION))
- do_volume_tex(shi, co, MAP_REFLECTION, NULL, &reflection, &R);
-
- ref_col[0] = reflection * ref_col[0] * scatter;
- ref_col[1] = reflection * ref_col[1] * scatter;
- ref_col[2] = reflection * ref_col[2] * scatter;
-}
-
-/* compute emission component, amount of radiance to add per segment
- * can be textured with 'emit' */
-static void vol_get_emission(ShadeInput *shi, float emission_col[3], const float co[3])
-{
- float emission = shi->mat->vol.emission;
- copy_v3_v3(emission_col, shi->mat->vol.emission_col);
-
- if (shi->mat->mapto_textured & (MAP_EMISSION + MAP_EMISSION_COL))
- do_volume_tex(shi, co, MAP_EMISSION + MAP_EMISSION_COL, emission_col, &emission, &R);
-
- emission_col[0] = emission_col[0] * emission;
- emission_col[1] = emission_col[1] * emission;
- emission_col[2] = emission_col[2] * emission;
-}
-
-
-/* A combination of scattering and absorption -> known as sigma T.
- * This can possibly use a specific scattering color,
- * and absorption multiplier factor too, but these parameters are left out for simplicity.
- * It's easy enough to get a good wide range of results with just these two parameters. */
-static void vol_get_sigma_t(ShadeInput *shi, float sigma_t[3], const float co[3])
-{
- /* technically absorption, but named transmission color
- * since it describes the effect of the coloring *after* absorption */
- float transmission_col[3] = {shi->mat->vol.transmission_col[0], shi->mat->vol.transmission_col[1], shi->mat->vol.transmission_col[2]};
- float scattering = shi->mat->vol.scattering;
-
- if (shi->mat->mapto_textured & (MAP_SCATTERING + MAP_TRANSMISSION_COL))
- do_volume_tex(shi, co, MAP_SCATTERING + MAP_TRANSMISSION_COL, transmission_col, &scattering, &R);
-
- sigma_t[0] = (1.0f - transmission_col[0]) + scattering;
- sigma_t[1] = (1.0f - transmission_col[1]) + scattering;
- sigma_t[2] = (1.0f - transmission_col[2]) + scattering;
-}
-
-/* phase function - determines in which directions the light
- * is scattered in the volume relative to incoming direction
- * and view direction */
-static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3], const float wp[3])
-{
- const float normalize = 0.25f; // = 1.f/4.f = M_PI/(4.f*M_PI)
-
- /* normalization constant is 1/4 rather than 1/4pi, since
- * Blender's shading system doesn't normalize for
- * energy conservation - eg. multiplying by pdf ( 1/pi for a lambert brdf ).
- * This means that lambert surfaces in Blender are pi times brighter than they 'should be'
- * and therefore, with correct energy conservation, volumes will darker than other solid objects,
- * for the same lighting intensity.
- * To correct this, scale up the phase function values by pi
- * until Blender's shading system supports this better. --matt
- */
-
- if (g == 0.f) { /* isotropic */
- return normalize * 1.f;
- }
- else { /* schlick */
- const float k = 1.55f * g - 0.55f * g * g * g;
- const float kcostheta = k * dot_v3v3(w, wp);
- return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta));
- }
-
- /* not used, but here for reference: */
-#if 0
- switch (phasefunc_type) {
- case MA_VOL_PH_MIEHAZY:
- return normalize * (0.5f + 4.5f * powf(0.5 * (1.f + costheta), 8.f));
- case MA_VOL_PH_MIEMURKY:
- return normalize * (0.5f + 16.5f * powf(0.5 * (1.f + costheta), 32.f));
- case MA_VOL_PH_RAYLEIGH:
- return normalize * 3.f / 4.f * (1 + costheta * costheta);
- case MA_VOL_PH_HG:
- return normalize * (1.f - g * g) / powf(1.f + g * g - 2.f * g * costheta, 1.5f);
- case MA_VOL_PH_SCHLICK:
- {
- const float k = 1.55f * g - 0.55f * g * g * g;
- const float kcostheta = k * costheta;
- return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta));
- }
- case MA_VOL_PH_ISOTROPIC:
- default:
- return normalize * 1.f;
- }
-#endif
-}
-
-/* Compute transmittance = e^(-attenuation) */
-static void vol_get_transmittance_seg(ShadeInput *shi, float tr[3], float stepsize, const float co[3], float density)
-{
- /* input density = density at co */
- float tau[3] = {0.f, 0.f, 0.f};
- const float stepd = density * stepsize;
- float sigma_t[3];
-
- vol_get_sigma_t(shi, sigma_t, co);
-
- /* homogeneous volume within the sampled distance */
- tau[0] += stepd * sigma_t[0];
- tau[1] += stepd * sigma_t[1];
- tau[2] += stepd * sigma_t[2];
-
- tr[0] *= expf(-tau[0]);
- tr[1] *= expf(-tau[1]);
- tr[2] *= expf(-tau[2]);
-}
-
-/* Compute transmittance = e^(-attenuation) */
-static void vol_get_transmittance(ShadeInput *shi, float tr[3], const float co[3], const float endco[3])
-{
- float p[3] = {co[0], co[1], co[2]};
- float step_vec[3] = {endco[0] - co[0], endco[1] - co[1], endco[2] - co[2]};
- float tau[3] = {0.f, 0.f, 0.f};
-
- float t0 = 0.f;
- float t1 = normalize_v3(step_vec);
- float pt0 = t0;
-
- t0 += shi->mat->vol.stepsize * ((shi->mat->vol.stepsize_type == MA_VOL_STEP_CONSTANT) ? 0.5f : BLI_thread_frand(shi->thread));
- p[0] += t0 * step_vec[0];
- p[1] += t0 * step_vec[1];
- p[2] += t0 * step_vec[2];
- mul_v3_fl(step_vec, shi->mat->vol.stepsize);
-
- for (; t0 < t1; pt0 = t0, t0 += shi->mat->vol.stepsize) {
- const float d = vol_get_density(shi, p);
- const float stepd = (t0 - pt0) * d;
- float sigma_t[3];
-
- vol_get_sigma_t(shi, sigma_t, p);
-
- tau[0] += stepd * sigma_t[0];
- tau[1] += stepd * sigma_t[1];
- tau[2] += stepd * sigma_t[2];
-
- add_v3_v3(p, step_vec);
- }
-
- /* return transmittance */
- tr[0] = expf(-tau[0]);
- tr[1] = expf(-tau[1]);
- tr[2] = expf(-tau[2]);
-}
-
-static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const float view[3], LampRen *lar, float lacol[3])
-{
- float visifac, lv[3], lampdist;
- float tr[3] = {1.0, 1.0, 1.0};
- float hitco[3], *atten_co;
- float p, ref_col[3];
-
- if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay) == 0) return;
- if ((lar->lay & shi->lay) == 0) return;
- if (lar->energy == 0.0f) return;
-
- if ((visifac = lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return;
-
- copy_v3_v3(lacol, &lar->r);
-
- if (lar->mode & LA_TEXTURE) {
- shi->osatex = 0;
- do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE);
- }
-
- mul_v3_fl(lacol, visifac);
-
- if (ELEM(lar->type, LA_SUN, LA_HEMI))
- copy_v3_v3(lv, lar->vec);
- negate_v3(lv);
-
- if (shi->mat->vol.shade_type == MA_VOL_SHADE_SHADOWED) {
- mul_v3_fl(lacol, vol_get_shadow(shi, lar, co));
- }
- else if (ELEM(shi->mat->vol.shade_type, MA_VOL_SHADE_SHADED, MA_VOL_SHADE_MULTIPLE, MA_VOL_SHADE_SHADEDPLUSMULTIPLE)) {
- Isect is;
-
- if (shi->mat->vol.shadeflag & MA_VOL_RECV_EXT_SHADOW) {
- mul_v3_fl(lacol, vol_get_shadow(shi, lar, co));
- if (IMB_colormanagement_get_luminance(lacol) < 0.001f) return;
- }
-
- /* find minimum of volume bounds, or lamp coord */
- if (vol_get_bounds(shi, co, lv, hitco, &is, VOL_BOUNDS_SS)) {
- float dist = len_v3v3(co, hitco);
- VlakRen *vlr = (VlakRen *)is.hit.face;
-
- /* simple internal shadowing */
- if (vlr->mat->material_type == MA_TYPE_SURFACE) {
- lacol[0] = lacol[1] = lacol[2] = 0.0f;
- return;
- }
-
- if (ELEM(lar->type, LA_SUN, LA_HEMI))
- /* infinite lights, can never be inside volume */
- atten_co = hitco;
- else if (lampdist < dist) {
- atten_co = lar->co;
- }
- else
- atten_co = hitco;
-
- vol_get_transmittance(shi, tr, co, atten_co);
-
- mul_v3_v3v3(lacol, lacol, tr);
- }
- else {
- /* Point is on the outside edge of the volume,
- * therefore no attenuation, full transmission.
- * Radiance from lamp remains unchanged */
- }
- }
-
- if (IMB_colormanagement_get_luminance(lacol) < 0.001f) return;
-
- normalize_v3(lv);
- p = vol_get_phasefunc(shi, shi->mat->vol.asymmetry, view, lv);
-
- /* physically based scattering with non-physically based RGB gain */
- vol_get_reflection_color(shi, ref_col, co);
-
- lacol[0] *= p * ref_col[0];
- lacol[1] *= p * ref_col[1];
- lacol[2] *= p * ref_col[2];
-}
-
-/* single scattering only for now */
-void vol_get_scattering(ShadeInput *shi, float scatter_col[3], const float co[3], const float view[3])
-{
- ListBase *lights;
- GroupObject *go;
- LampRen *lar;
-
- zero_v3(scatter_col);
-
- lights = get_lights(shi);
- for (go = lights->first; go; go = go->next) {
- float lacol[3] = {0.f, 0.f, 0.f};
- lar = go->lampren;
-
- if (lar) {
- vol_shade_one_lamp(shi, co, view, lar, lacol);
- add_v3_v3(scatter_col, lacol);
- }
- }
-}
-
-
-/*
- * The main volumetric integrator, using an emission/absorption/scattering model.
- *
- * Incoming radiance =
- *
- * outgoing radiance from behind surface * beam transmittance/attenuation
- * + added radiance from all points along the ray due to participating media
- * --> radiance for each segment =
- * (radiance added by scattering + radiance added by emission) * beam transmittance/attenuation
- */
-
-/* For ease of use, I've also introduced a 'reflection' and 'reflection color' parameter, which isn't
- * physically correct. This works as an RGB tint/gain on out-scattered light, but doesn't affect the light
- * that is transmitted through the volume. While having wavelength dependent absorption/scattering is more correct,
- * it also makes it harder to control the overall look of the volume since coloring the outscattered light results
- * in the inverse color being transmitted through the rest of the volume.
- */
-static void volumeintegrate(struct ShadeInput *shi, float col[4], const float co[3], const float endco[3])
-{
- float radiance[3] = {0.f, 0.f, 0.f};
- float tr[3] = {1.f, 1.f, 1.f};
- float p[3] = {co[0], co[1], co[2]};
- float step_vec[3] = {endco[0] - co[0], endco[1] - co[1], endco[2] - co[2]};
- const float stepsize = shi->mat->vol.stepsize;
-
- float t0 = 0.f;
- float pt0 = t0;
- float t1 = normalize_v3(step_vec); /* returns vector length */
-
- t0 += stepsize * ((shi->mat->vol.stepsize_type == MA_VOL_STEP_CONSTANT) ? 0.5f : BLI_thread_frand(shi->thread));
- p[0] += t0 * step_vec[0];
- p[1] += t0 * step_vec[1];
- p[2] += t0 * step_vec[2];
- mul_v3_fl(step_vec, stepsize);
-
- for (; t0 < t1; pt0 = t0, t0 += stepsize) {
- const float density = vol_get_density(shi, p);
-
- if (density > 0.00001f) {
- float scatter_col[3] = {0.f, 0.f, 0.f}, emit_col[3];
- const float stepd = (t0 - pt0) * density;
-
- /* transmittance component (alpha) */
- vol_get_transmittance_seg(shi, tr, stepsize, co, density);
-
- if (t0 > t1 * 0.25f) {
- /* only use depth cutoff after we've traced a little way into the volume */
- if (IMB_colormanagement_get_luminance(tr) < shi->mat->vol.depth_cutoff) break;
- }
-
- vol_get_emission(shi, emit_col, p);
-
- if (shi->obi->volume_precache) {
- float p2[3];
-
- p2[0] = p[0] + (step_vec[0] * 0.5f);
- p2[1] = p[1] + (step_vec[1] * 0.5f);
- p2[2] = p[2] + (step_vec[2] * 0.5f);
-
- vol_get_precached_scattering(&R, shi, scatter_col, p2);
- }
- else
- vol_get_scattering(shi, scatter_col, p, shi->view);
-
- radiance[0] += stepd * tr[0] * (emit_col[0] + scatter_col[0]);
- radiance[1] += stepd * tr[1] * (emit_col[1] + scatter_col[1]);
- radiance[2] += stepd * tr[2] * (emit_col[2] + scatter_col[2]);
- }
- add_v3_v3(p, step_vec);
- }
-
- /* multiply original color (from behind volume) with transmittance over entire distance */
- mul_v3_v3v3(col, tr, col);
- add_v3_v3(col, radiance);
-
- /* alpha <-- transmission luminance */
- col[3] = 1.0f - IMB_colormanagement_get_luminance(tr);
-}
-
-/* the main entry point for volume shading */
-static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int inside_volume)
-{
- float hitco[3], col[4] = {0.f, 0.f, 0.f, 0.f};
- const float *startco, *endco;
- int trace_behind = 1;
- const int ztransp = ((shi->depth == 0) && (shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_ZTRANSP));
- Isect is;
-
- /* check for shading an internal face a volume object directly */
- if (inside_volume == VOL_SHADE_INSIDE)
- trace_behind = 0;
- else if (inside_volume == VOL_SHADE_OUTSIDE) {
- if (shi->flippednor)
- inside_volume = VOL_SHADE_INSIDE;
- }
-
- if (ztransp && inside_volume == VOL_SHADE_INSIDE) {
- MatInside *mi;
- int render_this = 0;
-
- /* don't render the backfaces of ztransp volume materials.
- *
- * volume shading renders the internal volume from between the
- * ' view intersection of the solid volume to the
- * intersection on the other side, as part of the shading of
- * the front face.
- *
- * Because ztransp renders both front and back faces independently
- * this will double up, so here we prevent rendering the backface as well,
- * which would otherwise render the volume in between the camera and the backface
- * --matt */
-
- for (mi = R.render_volumes_inside.first; mi; mi = mi->next) {
- /* weak... */
- if (mi->ma == shi->mat) render_this = 1;
- }
- if (!render_this) return;
- }
-
-
- if (inside_volume == VOL_SHADE_INSIDE) {
- startco = shi->camera_co;
- endco = shi->co;
-
- if (trace_behind) {
- if (!ztransp)
- /* trace behind the volume object */
- vol_trace_behind(shi, shi->vlr, endco, col);
- }
- else {
- /* we're tracing through the volume between the camera
- * and a solid surface, so use that pre-shaded radiance */
- copy_v4_v4(col, shr->combined);
- }
-
- /* shade volume from 'camera' to 1st hit point */
- volumeintegrate(shi, col, startco, endco);
- }
- /* trace to find a backface, the other side bounds of the volume */
- /* (ray intersect ignores front faces here) */
- else if (vol_get_bounds(shi, shi->co, shi->view, hitco, &is, VOL_BOUNDS_DEPTH)) {
- VlakRen *vlr = (VlakRen *)is.hit.face;
-
- startco = shi->co;
- endco = hitco;
-
- if (!ztransp) {
- /* if it's another face in the same material */
- if (vlr->mat == shi->mat) {
- /* trace behind the 2nd (raytrace) hit point */
- vol_trace_behind(shi, (VlakRen *)is.hit.face, endco, col);
- }
- else {
- shade_intersection(shi, col, &is);
- }
- }
-
- /* shade volume from 1st hit point to 2nd hit point */
- volumeintegrate(shi, col, startco, endco);
- }
-
- if (ztransp)
- col[3] = col[3] > 1.f ? 1.f : col[3];
- else
- col[3] = 1.f;
-
- copy_v3_v3(shr->combined, col);
- shr->alpha = col[3];
-
- copy_v3_v3(shr->diff, shr->combined);
- copy_v3_v3(shr->diffshad, shr->diff);
-}
-
-/* Traces a shadow through the object,
- * pretty much gets the transmission over a ray path */
-void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct Isect *last_is)
-{
- float hitco[3];
- float tr[3] = {1.0, 1.0, 1.0};
- Isect is = {{0}};
- const float *startco, *endco;
-
- memset(shr, 0, sizeof(ShadeResult));
-
- /* if 1st hit normal is facing away from the camera,
- * then we're inside the volume already. */
- if (shi->flippednor) {
- startco = last_is->start;
- endco = shi->co;
- }
-
- /* trace to find a backface, the other side bounds of the volume */
- /* (ray intersect ignores front faces here) */
- else if (vol_get_bounds(shi, shi->co, shi->view, hitco, &is, VOL_BOUNDS_DEPTH)) {
- startco = shi->co;
- endco = hitco;
- }
- else {
- shr->combined[0] = shr->combined[1] = shr->combined[2] = 0.f;
- shr->alpha = shr->combined[3] = 1.f;
- return;
- }
-
- vol_get_transmittance(shi, tr, startco, endco);
-
-
- /* if we hit another face in the same volume bounds */
- /* shift raytrace coordinates to the hit point, to avoid shading volume twice */
- /* due to idiosyncracy in ray_trace_shadow_tra() */
- if (is.hit.ob == shi->obi) {
- copy_v3_v3(shi->co, hitco);
- last_is->dist += is.dist;
- shi->vlr = (VlakRen *)is.hit.face;
- }
-
-
- copy_v3_v3(shr->combined, tr);
- shr->combined[3] = 1.0f - IMB_colormanagement_get_luminance(tr);
- shr->alpha = shr->combined[3];
-}
-
-
-/* delivers a fully filled in ShadeResult, for all passes */
-void shade_volume_outside(ShadeInput *shi, ShadeResult *shr)
-{
- memset(shr, 0, sizeof(ShadeResult));
- volume_trace(shi, shr, VOL_SHADE_OUTSIDE);
-}
-
-
-void shade_volume_inside(ShadeInput *shi, ShadeResult *shr)
-{
- MatInside *m;
- Material *mat_backup;
- ObjectInstanceRen *obi_backup;
- float prev_alpha = shr->alpha;
-
- /* XXX: extend to multiple volumes perhaps later */
- mat_backup = shi->mat;
- obi_backup = shi->obi;
-
- m = R.render_volumes_inside.first;
- shi->mat = m->ma;
- shi->obi = m->obi;
- shi->obr = m->obi->obr;
-
- volume_trace(shi, shr, VOL_SHADE_INSIDE);
-
- shr->alpha = shr->alpha + prev_alpha;
- CLAMP(shr->alpha, 0.0f, 1.0f);
-
- shi->mat = mat_backup;
- shi->obi = obi_backup;
- shi->obr = obi_backup->obr;
-}
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
deleted file mode 100644
index c45bde300e7..00000000000
--- a/source/blender/render/intern/source/voxeldata.c
+++ /dev/null
@@ -1,571 +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): Raul Fernandez Hernandez (Farsthary), Matt Ebb.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/voxeldata.c
- * \ingroup render
- */
-
-
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#endif
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_threads.h"
-#include "BLI_voxel.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-
-#include "BKE_cloth.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_main.h"
-#include "BKE_modifier.h"
-
-#include "smoke_API.h"
-#include "BPH_mass_spring.h"
-
-#include "DNA_texture_types.h"
-#include "DNA_object_force_types.h"
-#include "DNA_object_types.h"
-#include "DNA_particle_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_smoke_types.h"
-
-
-#include "render_types.h"
-#include "texture.h"
-#include "voxeldata.h"
-
-static bool is_vd_res_ok(VoxelData *vd)
-{
- /* arbitrary large value so corrupt headers don't break */
- const int min = 1, max = 100000;
- return (vd->resol[0] >= min && vd->resol[0] <= max) &&
- (vd->resol[1] >= min && vd->resol[1] <= max) &&
- (vd->resol[2] >= min && vd->resol[2] <= max);
-}
-
-/* use size_t because the result may exceed INT_MAX */
-static size_t vd_resol_size(VoxelData *vd)
-{
- return (size_t)vd->resol[0] * (size_t)vd->resol[1] * (size_t)vd->resol[2];
-}
-
-static int load_frame_blendervoxel(VoxelData *vd, FILE *fp, int frame)
-{
- const size_t size = vd_resol_size(vd);
- size_t offset = sizeof(VoxelDataHeader);
-
- if (is_vd_res_ok(vd) == false)
- return 0;
-
- vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset");
- if (vd->dataset == NULL) return 0;
-
- if (fseek(fp, frame * size * sizeof(float) + offset, 0) == -1)
- return 0;
- if (fread(vd->dataset, sizeof(float), size, fp) != size)
- return 0;
-
- vd->cachedframe = frame;
- vd->ok = 1;
- return 1;
-}
-
-static int load_frame_raw8(VoxelData *vd, FILE *fp, int frame)
-{
- const size_t size = vd_resol_size(vd);
- size_t i;
- char *data_c;
-
- if (is_vd_res_ok(vd) == false)
- return 0;
-
- vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset");
- if (vd->dataset == NULL) return 0;
- data_c = (char *)MEM_mallocN(sizeof(char) * size, "temporary voxel file reading storage");
- if (data_c == NULL) {
- MEM_freeN(vd->dataset);
- vd->dataset = NULL;
- return 0;
- }
-
- if (fseek(fp, (frame - 1) * size * sizeof(char), 0) == -1) {
- MEM_freeN(data_c);
- MEM_freeN(vd->dataset);
- vd->dataset = NULL;
- return 0;
- }
- if (fread(data_c, sizeof(char), size, fp) != size) {
- MEM_freeN(data_c);
- MEM_freeN(vd->dataset);
- vd->dataset = NULL;
- return 0;
- }
-
- for (i = 0; i < size; i++) {
- vd->dataset[i] = (float)data_c[i] / 255.f;
- }
- MEM_freeN(data_c);
-
- vd->cachedframe = frame;
- vd->ok = 1;
- return 1;
-}
-
-static void load_frame_image_sequence(VoxelData *vd, Tex *tex)
-{
- ImBuf *ibuf;
- Image *ima = tex->ima;
- ImageUser *tiuser = &tex->iuser;
- ImageUser iuser = *(tiuser);
- int x = 0, y = 0, z = 0;
- const float *rf;
-
- if (!ima) return;
- if (iuser.frames == 0) return;
-
- ima->source = IMA_SRC_SEQUENCE;
- iuser.framenr = 1 + iuser.offset;
-
- /* find the first valid ibuf and use it to initialize the resolution of the data set */
- /* need to do this in advance so we know how much memory to allocate */
- ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
- while (!ibuf && (iuser.framenr < iuser.frames)) {
- iuser.framenr++;
- ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
- }
- if (!ibuf) return;
- if (!ibuf->rect_float) IMB_float_from_rect(ibuf);
-
- vd->flag |= TEX_VD_STILL;
- vd->resol[0] = ibuf->x;
- vd->resol[1] = ibuf->y;
- vd->resol[2] = iuser.frames;
- vd->dataset = MEM_mapallocN(sizeof(float) * vd_resol_size(vd), "voxel dataset");
-
- for (z = 0; z < iuser.frames; z++) {
- /* get a new ibuf for each frame */
- if (z > 0) {
- iuser.framenr++;
- BKE_image_release_ibuf(ima, ibuf, NULL);
- ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
- if (!ibuf) break;
- if (!ibuf->rect_float) IMB_float_from_rect(ibuf);
- }
- rf = ibuf->rect_float;
-
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- /* currently averaged to monchrome */
- vd->dataset[BLI_VOXEL_INDEX(x, y, z, vd->resol)] = (rf[0] + rf[1] + rf[2]) / 3.0f;
- rf += 4;
- }
- }
-
- BKE_image_free_anim_ibufs(ima, iuser.framenr);
- }
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
-
- vd->ok = 1;
- return;
-}
-
-static int read_voxeldata_header(FILE *fp, struct VoxelData *vd)
-{
- VoxelDataHeader *h = (VoxelDataHeader *)MEM_mallocN(sizeof(VoxelDataHeader), "voxel data header");
-
- rewind(fp);
- if (fread(h, sizeof(VoxelDataHeader), 1, fp) != 1) {
- MEM_freeN(h);
- return 0;
- }
-
- vd->resol[0] = h->resolX;
- vd->resol[1] = h->resolY;
- vd->resol[2] = h->resolZ;
-
- MEM_freeN(h);
- return 1;
-}
-
-static void init_frame_smoke(VoxelData *vd, int cfra)
-{
-#ifdef WITH_SMOKE
- Object *ob;
- ModifierData *md;
-
- vd->dataset = NULL;
- if (vd->object == NULL) return;
- ob = vd->object;
-
- /* draw code for smoke */
- if ((md = (ModifierData *)modifiers_findByType(ob, eModifierType_Smoke))) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- SmokeDomainSettings *sds = smd->domain;
-
- if (sds && sds->fluid) {
- BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
-
- if (!sds->fluid) {
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- return;
- }
-
- if (cfra < sds->point_cache[0]->startframe)
- ; /* don't show smoke before simulation starts, this could be made an option in the future */
- else if (vd->smoked_type == TEX_VD_SMOKEHEAT) {
- size_t totRes;
- size_t i;
- float *heat;
-
- if (!smoke_has_heat(sds->fluid)) {
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- return;
- }
-
- copy_v3_v3_int(vd->resol, sds->res);
- totRes = vd_resol_size(vd);
- vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
- /* get heat data */
- heat = smoke_get_heat(sds->fluid);
-
- /* scale heat values from -2.0-2.0 to 0.0-1.0 */
- for (i = 0; i < totRes; i++) {
- vd->dataset[i] = (heat[i] + 2.0f) / 4.0f;
- }
- }
- else if (vd->smoked_type == TEX_VD_SMOKEVEL) {
- size_t totRes;
- size_t i;
- float *xvel, *yvel, *zvel;
-
- copy_v3_v3_int(vd->resol, sds->res);
- totRes = vd_resol_size(vd);
- vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
- /* get velocity data */
- xvel = smoke_get_velocity_x(sds->fluid);
- yvel = smoke_get_velocity_y(sds->fluid);
- zvel = smoke_get_velocity_z(sds->fluid);
-
- /* map velocities between 0 and 0.3f */
- for (i = 0; i < totRes; i++) {
- vd->dataset[i] = sqrtf(xvel[i] * xvel[i] + yvel[i] * yvel[i] + zvel[i] * zvel[i]) * 3.0f;
- }
-
- }
- else if (vd->smoked_type == TEX_VD_SMOKEFLAME) {
- size_t totRes;
- float *flame;
-
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- if (!smoke_turbulence_has_fuel(sds->wt)) {
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- return;
- }
- smoke_turbulence_get_res(sds->wt, vd->resol);
- flame = smoke_turbulence_get_flame(sds->wt);
- }
- else {
- if (!smoke_has_fuel(sds->fluid)) {
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- return;
- }
- copy_v3_v3_int(vd->resol, sds->res);
- flame = smoke_get_flame(sds->fluid);
- }
-
- /* always store copy, as smoke internal data can change */
- totRes = vd_resol_size(vd);
- vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data");
- memcpy(vd->dataset, flame, sizeof(float)*totRes);
- }
- else {
- size_t totCells;
- int depth = 4;
- vd->data_type = TEX_VD_RGBA_PREMUL;
-
- /* data resolution */
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- smoke_turbulence_get_res(sds->wt, vd->resol);
- }
- else {
- copy_v3_v3_int(vd->resol, sds->res);
- }
-
- /* TODO: is_vd_res_ok(rvd) doesnt check this resolution */
- totCells = vd_resol_size(vd) * depth;
- /* always store copy, as smoke internal data can change */
- vd->dataset = MEM_mapallocN(sizeof(float) * totCells, "smoke data");
-
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- if (smoke_turbulence_has_colors(sds->wt)) {
- smoke_turbulence_get_rgba(sds->wt, vd->dataset, 1);
- }
- else {
- smoke_turbulence_get_rgba_from_density(sds->wt, sds->active_color, vd->dataset, 1);
- }
- }
- else {
- if (smoke_has_colors(sds->fluid)) {
- smoke_get_rgba(sds->fluid, vd->dataset, 1);
- }
- else {
- smoke_get_rgba_from_density(sds->fluid, sds->active_color, vd->dataset, 1);
- }
- }
- } /* end of fluid condition */
-
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- }
- }
-
- vd->ok = 1;
-
-#else // WITH_SMOKE
- (void)vd;
- (void)cfra;
-
- vd->dataset = NULL;
-#endif
-}
-
-static void init_frame_hair(VoxelData *vd, int UNUSED(cfra))
-{
- Object *ob;
- ModifierData *md;
-
- vd->dataset = NULL;
- if (vd->object == NULL) return;
- ob = vd->object;
-
- if ((md = (ModifierData *)modifiers_findByType(ob, eModifierType_ParticleSystem))) {
- ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
-
- if (pmd->psys && pmd->psys->clmd) {
- vd->ok |= BPH_cloth_solver_get_texture_data(ob, pmd->psys->clmd, vd);
- }
- }
-}
-
-void cache_voxeldata(Tex *tex, int scene_frame)
-{
- VoxelData *vd = tex->vd;
- FILE *fp;
- int curframe;
- char path[sizeof(vd->source_path)];
-
- /* only re-cache if dataset needs updating */
- if ((vd->flag & TEX_VD_STILL) || (vd->cachedframe == scene_frame))
- if (vd->ok) return;
-
- /* clear out old cache, ready for new */
- if (vd->dataset) {
- MEM_freeN(vd->dataset);
- vd->dataset = NULL;
- }
- /* reset data_type */
- vd->data_type = TEX_VD_INTENSITY;
-
- if (vd->flag & TEX_VD_STILL)
- curframe = vd->still_frame;
- else
- curframe = scene_frame;
-
- BLI_strncpy(path, vd->source_path, sizeof(path));
-
- /* each type is responsible for setting to true */
- vd->ok = false;
-
- switch (vd->file_format) {
- case TEX_VD_IMAGE_SEQUENCE:
- load_frame_image_sequence(vd, tex);
- return;
- case TEX_VD_SMOKE:
- init_frame_smoke(vd, scene_frame);
- return;
- case TEX_VD_HAIR:
- init_frame_hair(vd, scene_frame);
- return;
- case TEX_VD_BLENDERVOXEL:
- BLI_path_abs(path, G.main->name);
- fp = BLI_fopen(path, "rb");
- if (!fp) return;
-
- if (read_voxeldata_header(fp, vd))
- load_frame_blendervoxel(vd, fp, curframe - 1);
-
- fclose(fp);
- return;
- case TEX_VD_RAW_8BIT:
- BLI_path_abs(path, G.main->name);
- fp = BLI_fopen(path, "rb");
- if (!fp) return;
-
- load_frame_raw8(vd, fp, curframe);
- fclose(fp);
- return;
- }
-}
-
-void make_voxeldata(struct Render *re)
-{
- Tex *tex;
-
- re->i.infostr = IFACE_("Loading voxel datasets");
- re->stats_draw(re->sdh, &re->i);
-
- /* XXX: should be doing only textures used in this render */
- for (tex = re->main->tex.first; tex; tex = tex->id.next) {
- if (tex->id.us && tex->type == TEX_VOXELDATA) {
- cache_voxeldata(tex, re->r.cfra);
- }
- }
-
- re->i.infostr = NULL;
- re->stats_draw(re->sdh, &re->i);
-
-}
-
-int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres)
-{
- VoxelData *vd = tex->vd;
- float co[3], offset[3] = {0.5, 0.5, 0.5}, a;
- int retval = (vd->data_type == TEX_VD_RGBA_PREMUL) ? TEX_RGB : TEX_INT;
- int depth = (vd->data_type == TEX_VD_RGBA_PREMUL) ? 4 : 1;
- int ch;
-
- if (vd->dataset == NULL) {
- texres->tin = 0.0f;
- return 0;
- }
-
- /* scale lookup from 0.0-1.0 (original location) to -1.0, 1.0, consistent with image texture tex coords */
- /* in implementation this works backwards, bringing sample locations from -1.0, 1.0
- * to the range 0.0, 1.0, before looking up in the voxel structure. */
- copy_v3_v3(co, texvec);
- mul_v3_fl(co, 0.5f);
- add_v3_v3(co, offset);
-
- /* co is now in the range 0.0, 1.0 */
- switch (vd->extend) {
- case TEX_CLIP:
- {
- if ((co[0] < 0.f || co[0] > 1.f) || (co[1] < 0.f || co[1] > 1.f) || (co[2] < 0.f || co[2] > 1.f)) {
- texres->tin = 0.f;
- return retval;
- }
- break;
- }
- case TEX_REPEAT:
- {
- co[0] = co[0] - floorf(co[0]);
- co[1] = co[1] - floorf(co[1]);
- co[2] = co[2] - floorf(co[2]);
- break;
- }
- case TEX_EXTEND:
- {
- CLAMP(co[0], 0.f, 1.f);
- CLAMP(co[1], 0.f, 1.f);
- CLAMP(co[2], 0.f, 1.f);
- break;
- }
- }
-
- for (ch = 0; ch < depth; ch++) {
- float *dataset = vd->dataset + ch*vd->resol[0]*vd->resol[1]*vd->resol[2];
- float *result = &texres->tin;
-
- if (vd->data_type == TEX_VD_RGBA_PREMUL) {
- switch (ch) {
- case 0:
- result = &texres->tr;
- break;
- case 1:
- result = &texres->tg;
- break;
- case 2:
- result = &texres->tb;
- break;
- }
- }
-
- switch (vd->interp_type) {
- case TEX_VD_NEARESTNEIGHBOR:
- *result = BLI_voxel_sample_nearest(dataset, vd->resol, co);
- break;
- case TEX_VD_LINEAR:
- *result = BLI_voxel_sample_trilinear(dataset, vd->resol, co);
- break;
- case TEX_VD_QUADRATIC:
- *result = BLI_voxel_sample_triquadratic(dataset, vd->resol, co);
- break;
- case TEX_VD_TRICUBIC_CATROM:
- case TEX_VD_TRICUBIC_BSPLINE:
- *result = BLI_voxel_sample_tricubic(dataset, vd->resol, co, (vd->interp_type == TEX_VD_TRICUBIC_BSPLINE));
- break;
- }
- }
-
- a = texres->tin;
- texres->tin *= vd->int_multiplier;
- BRICONT;
-
- if (vd->data_type == TEX_VD_RGBA_PREMUL) {
- /* unmultiply */
- if (a>0.001f) {
- texres->tr /= a;
- texres->tg /= a;
- texres->tb /= a;
- }
- texres->talpha = 1;
- }
- else {
- texres->tr = texres->tin;
- texres->tg = texres->tin;
- texres->tb = texres->tin;
- }
-
- texres->ta = texres->tin;
- BRICONTRGB;
-
- return retval;
-}
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index e948662df00..3837383c4c7 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -34,40 +34,11 @@
/* Common includes */
/*---------------------------------------------------------------------------*/
-#include <math.h>
-#include <float.h>
-#include <stdlib.h>
-#include <limits.h>
#include <string.h>
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_jitter_2d.h"
-#include "BLI_threads.h"
-#include "BLI_utildefines.h"
-
#include "MEM_guardedalloc.h"
-#include "DNA_lamp_types.h"
-#include "DNA_node_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_material_types.h"
-
-#include "BKE_global.h"
-#include "BKE_material.h"
-
-
-#include "RE_render_ext.h"
-
-/* local includes */
-#include "pixelblending.h"
-#include "render_result.h"
-#include "render_types.h"
-#include "renderdatabase.h"
-#include "rendercore.h"
-#include "shadbuf.h"
-#include "shading.h"
-#include "strand.h"
+#include "BLI_math_base.h"
/* own includes */
#include "zbuf.h"
@@ -77,17 +48,10 @@
# pragma GCC diagnostic ignored "-Wdouble-promotion"
#endif
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-
/* ****************** Spans ******************************* */
/* each zbuffer has coordinates transformed to local rect coordinates, so we can simply clip */
-void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop)
+void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty)
{
memset(zspan, 0, sizeof(ZSpan));
@@ -96,8 +60,6 @@ void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop)
zspan->span1= MEM_mallocN(recty*sizeof(float), "zspan");
zspan->span2= MEM_mallocN(recty*sizeof(float), "zspan");
-
- zspan->clipcrop= clipcrop;
}
void zbuf_free_span(ZSpan *zspan)
@@ -200,1312 +162,6 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
/* Functions */
/*-----------------------------------------------------------*/
-void fillrect(int *rect, int x, int y, int val)
-{
- int len, *drect;
-
- len= x*y;
- drect= rect;
- while (len>0) {
- len--;
- *drect= val;
- drect++;
- }
-}
-
-/* based on Liang&Barsky, for clipping of pyramidical volume */
-static short cliptestf(float a, float b, float c, float d, float *u1, float *u2)
-{
- float p= a + b, q= c + d, r;
-
- if (p<0.0f) {
- if (q<p) return 0;
- else if (q<0.0f) {
- r= q/p;
- if (r>*u2) return 0;
- else if (r>*u1) *u1=r;
- }
- }
- else {
- if (p>0.0f) {
- if (q<0.0f) return 0;
- else if (q<p) {
- r= q/p;
- if (r<*u1) return 0;
- else if (r<*u2) *u2=r;
- }
- }
- else if (q<0.0f) return 0;
- }
- return 1;
-}
-
-int testclip(const float v[4])
-{
- float abs4; /* WATCH IT: this function should do the same as cliptestf, otherwise troubles in zbufclip()*/
- short c=0;
-
- /* if we set clip flags, the clipping should be at least larger than epsilon.
- * prevents issues with vertices lying exact on borders */
- abs4= fabsf(v[3]) + FLT_EPSILON;
-
- if ( v[0] < -abs4) c+=1;
- else if ( v[0] > abs4) c+=2;
-
- if ( v[1] > abs4) c+=4;
- else if ( v[1] < -abs4) c+=8;
-
- if (v[2] < -abs4) c+=16; /* this used to be " if (v[2]<0) ", see clippz() */
- else if (v[2]> abs4) c+= 32;
-
- return c;
-}
-
-
-
-/* ************* ACCUMULATION ZBUF ************ */
-
-
-static APixstr *addpsmainA(ListBase *lb)
-{
- APixstrMain *psm;
-
- psm= MEM_mallocN(sizeof(APixstrMain), "addpsmainA");
- BLI_addtail(lb, psm);
- psm->ps= MEM_callocN(4096*sizeof(APixstr), "pixstr");
-
- return psm->ps;
-}
-
-void freepsA(ListBase *lb)
-{
- APixstrMain *psm, *psmnext;
-
- for (psm= lb->first; psm; psm= psmnext) {
- psmnext= psm->next;
- if (psm->ps)
- MEM_freeN(psm->ps);
- MEM_freeN(psm);
- }
-}
-
-static APixstr *addpsA(ZSpan *zspan)
-{
- /* make new PS */
- if (zspan->apsmcounter==0) {
- zspan->curpstr= addpsmainA(zspan->apsmbase);
- zspan->apsmcounter= 4095;
- }
- else {
- zspan->curpstr++;
- zspan->apsmcounter--;
- }
- return zspan->curpstr;
-}
-
-static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr,
- const float *v1, const float *v2, const float *v3, const float *v4)
-{
- APixstr *ap, *apofs, *apn;
- double zxd, zyd, zy0, zverg;
- float x0, y0, z0;
- float x1, y1, z1, x2, y2, z2, xx1;
- const float *span1, *span2;
- int *rz, *rm, x, y;
- int sn1, sn2, rectx, *rectzofs, *rectmaskofs, my0, my2, mask;
-
- /* init */
- zbuf_init_span(zspan);
-
- /* set spans */
- zbuf_add_to_span(zspan, v1, v2);
- zbuf_add_to_span(zspan, v2, v3);
- if (v4) {
- zbuf_add_to_span(zspan, v3, v4);
- zbuf_add_to_span(zspan, v4, v1);
- }
- else
- zbuf_add_to_span(zspan, v3, v1);
-
- /* clipped */
- if (zspan->minp2==NULL || zspan->maxp2==NULL) return;
-
- my0 = max_ii(zspan->miny1, zspan->miny2);
- my2 = min_ii(zspan->maxy1, zspan->maxy2);
-
- if (my2<my0) return;
-
- /* ZBUF DX DY, in floats still */
- x1= v1[0]- v2[0];
- x2= v2[0]- v3[0];
- y1= v1[1]- v2[1];
- y2= v2[1]- v3[1];
- z1= v1[2]- v2[2];
- z2= v2[2]- v3[2];
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
- z0= x1*y2-y1*x2;
-
- if (z0==0.0f) return;
-
- xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
-
- zxd= -(double)x0/(double)z0;
- zyd= -(double)y0/(double)z0;
- zy0= ((double)my2)*zyd + (double)xx1;
-
- /* start-offset in rect */
- rectx= zspan->rectx;
- rectzofs= (int *)(zspan->arectz+rectx*(my2));
- rectmaskofs= (int *)(zspan->rectmask+rectx*(my2));
- apofs= (zspan->apixbuf+ rectx*(my2));
- mask= zspan->mask;
-
- /* correct span */
- sn1= (my0 + my2)/2;
- if (zspan->span1[sn1] < zspan->span2[sn1]) {
- span1= zspan->span1+my2;
- span2= zspan->span2+my2;
- }
- else {
- span1= zspan->span2+my2;
- span2= zspan->span1+my2;
- }
-
- for (y=my2; y>=my0; y--, span1--, span2--) {
-
- sn1= floor(*span1);
- sn2= floor(*span2);
- sn1++;
-
- if (sn2>=rectx) sn2= rectx-1;
- if (sn1<0) sn1= 0;
-
- if (sn2>=sn1) {
- int intzverg;
-
- zverg= (double)sn1*zxd + zy0;
- rz= rectzofs+sn1;
- rm= rectmaskofs+sn1;
- ap= apofs+sn1;
- x= sn2-sn1;
-
- zverg-= zspan->polygon_offset;
-
- while (x>=0) {
- intzverg = round_db_to_int_clamp(zverg);
-
- if ( intzverg < *rz) {
- if (!zspan->rectmask || intzverg > *rm) {
-
- apn= ap;
- while (apn) {
- if (apn->p[0]==0) {apn->obi[0]= obi; apn->p[0]= zvlnr; apn->z[0]= intzverg; apn->mask[0]= mask; break; }
- if (apn->p[0]==zvlnr && apn->obi[0]==obi) {apn->mask[0]|= mask; break; }
- if (apn->p[1]==0) {apn->obi[1]= obi; apn->p[1]= zvlnr; apn->z[1]= intzverg; apn->mask[1]= mask; break; }
- if (apn->p[1]==zvlnr && apn->obi[1]==obi) {apn->mask[1]|= mask; break; }
- if (apn->p[2]==0) {apn->obi[2]= obi; apn->p[2]= zvlnr; apn->z[2]= intzverg; apn->mask[2]= mask; break; }
- if (apn->p[2]==zvlnr && apn->obi[2]==obi) {apn->mask[2]|= mask; break; }
- if (apn->p[3]==0) {apn->obi[3]= obi; apn->p[3]= zvlnr; apn->z[3]= intzverg; apn->mask[3]= mask; break; }
- if (apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; }
- if (apn->next==NULL) apn->next= addpsA(zspan);
- apn= apn->next;
- }
- }
- }
- zverg+= zxd;
- rz++;
- rm++;
- ap++;
- x--;
- }
- }
-
- zy0-=zyd;
- rectzofs-= rectx;
- rectmaskofs-= rectx;
- apofs-= rectx;
- }
-}
-
-
-
-static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], const float vec2[3])
-{
- APixstr *ap, *apn;
- const int *rectz, *rectmask;
- int start, end, x, y, oldx, oldy, ofs;
- int dz, vergz, mask, maxtest=0;
- float dx, dy;
- float v1[3], v2[3];
-
- dx= vec2[0]-vec1[0];
- dy= vec2[1]-vec1[1];
-
- mask= zspan->mask;
-
- if (fabsf(dx) > fabsf(dy)) {
-
- /* all lines from left to right */
- if (vec1[0]<vec2[0]) {
- copy_v3_v3(v1, vec1);
- copy_v3_v3(v2, vec2);
- }
- else {
- copy_v3_v3(v2, vec1);
- copy_v3_v3(v1, vec2);
- dx= -dx; dy= -dy;
- }
-
- start= floor(v1[0]);
- end= start+floor(dx);
- if (end>=zspan->rectx) end= zspan->rectx-1;
-
- oldy= floor(v1[1]);
- dy/= dx;
-
- vergz= v1[2];
- vergz-= zspan->polygon_offset;
- dz= (v2[2]-v1[2])/dx;
- if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
-
- rectz= (int *)(zspan->arectz+zspan->rectx*(oldy) +start);
- rectmask= (int *)(zspan->rectmask+zspan->rectx*(oldy) +start);
- ap= (zspan->apixbuf+ zspan->rectx*(oldy) +start);
-
- if (dy<0) ofs= -zspan->rectx;
- else ofs= zspan->rectx;
-
- for (x= start; x<=end; x++, rectz++, rectmask++, ap++) {
-
- y= floor(v1[1]);
- if (y!=oldy) {
- oldy= y;
- rectz+= ofs;
- rectmask+= ofs;
- ap+= ofs;
- }
-
- if (x>=0 && y>=0 && y<zspan->recty) {
- if (vergz<*rectz) {
- if (!zspan->rectmask || vergz>*rectmask) {
-
- apn= ap;
- while (apn) { /* loop unrolled */
- if (apn->p[0]==0) {apn->obi[0]= obi; apn->p[0]= zvlnr; apn->z[0]= vergz; apn->mask[0]= mask; break; }
- if (apn->p[0]==zvlnr && apn->obi[0]==obi) {apn->mask[0]|= mask; break; }
- if (apn->p[1]==0) {apn->obi[1]= obi; apn->p[1]= zvlnr; apn->z[1]= vergz; apn->mask[1]= mask; break; }
- if (apn->p[1]==zvlnr && apn->obi[1]==obi) {apn->mask[1]|= mask; break; }
- if (apn->p[2]==0) {apn->obi[2]= obi; apn->p[2]= zvlnr; apn->z[2]= vergz; apn->mask[2]= mask; break; }
- if (apn->p[2]==zvlnr && apn->obi[2]==obi) {apn->mask[2]|= mask; break; }
- if (apn->p[3]==0) {apn->obi[3]= obi; apn->p[3]= zvlnr; apn->z[3]= vergz; apn->mask[3]= mask; break; }
- if (apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; }
- if (apn->next == NULL) apn->next = addpsA(zspan);
- apn= apn->next;
- }
- }
- }
- }
-
- v1[1]+= dy;
- if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0;
- else vergz+= dz;
- }
- }
- else {
-
- /* all lines from top to bottom */
- if (vec1[1]<vec2[1]) {
- copy_v3_v3(v1, vec1);
- copy_v3_v3(v2, vec2);
- }
- else {
- copy_v3_v3(v2, vec1);
- copy_v3_v3(v1, vec2);
- dx= -dx; dy= -dy;
- }
-
- start= floor(v1[1]);
- end= start+floor(dy);
-
- if (start>=zspan->recty || end<0) return;
-
- if (end>=zspan->recty) end= zspan->recty-1;
-
- oldx= floor(v1[0]);
- dx/= dy;
-
- vergz= v1[2];
- vergz-= zspan->polygon_offset;
- dz= (v2[2]-v1[2])/dy;
- if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
-
- rectz= (int *)( zspan->arectz+ (start)*zspan->rectx+ oldx );
- rectmask= (int *)( zspan->rectmask+ (start)*zspan->rectx+ oldx );
- ap= (zspan->apixbuf+ zspan->rectx*(start) +oldx);
-
- if (dx<0) ofs= -1;
- else ofs= 1;
-
- for (y= start; y<=end; y++, rectz+=zspan->rectx, rectmask+=zspan->rectx, ap+=zspan->rectx) {
-
- x= floor(v1[0]);
- if (x!=oldx) {
- oldx= x;
- rectz+= ofs;
- rectmask+= ofs;
- ap+= ofs;
- }
-
- if (x>=0 && y>=0 && x<zspan->rectx) {
- if (vergz<*rectz) {
- if (!zspan->rectmask || vergz>*rectmask) {
-
- apn= ap;
- while (apn) { /* loop unrolled */
- if (apn->p[0]==0) {apn->obi[0]= obi; apn->p[0]= zvlnr; apn->z[0]= vergz; apn->mask[0]= mask; break; }
- if (apn->p[0]==zvlnr) {apn->mask[0]|= mask; break; }
- if (apn->p[1]==0) {apn->obi[1]= obi; apn->p[1]= zvlnr; apn->z[1]= vergz; apn->mask[1]= mask; break; }
- if (apn->p[1]==zvlnr) {apn->mask[1]|= mask; break; }
- if (apn->p[2]==0) {apn->obi[2]= obi; apn->p[2]= zvlnr; apn->z[2]= vergz; apn->mask[2]= mask; break; }
- if (apn->p[2]==zvlnr) {apn->mask[2]|= mask; break; }
- if (apn->p[3]==0) {apn->obi[3]= obi; apn->p[3]= zvlnr; apn->z[3]= vergz; apn->mask[3]= mask; break; }
- if (apn->p[3]==zvlnr) {apn->mask[3]|= mask; break; }
- if (apn->next == NULL) apn->next = addpsA(zspan);
- apn= apn->next;
- }
- }
- }
- }
-
- v1[0]+= dx;
- if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0;
- else vergz+= dz;
- }
- }
-}
-
-/* ************* NORMAL ZBUFFER ************ */
-
-static void zbufline(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], const float vec2[3])
-{
- int *rectz, *rectp, *recto, *rectmask;
- int start, end, x, y, oldx, oldy, ofs;
- int dz, vergz, maxtest= 0;
- float dx, dy;
- float v1[3], v2[3];
-
- dx= vec2[0]-vec1[0];
- dy= vec2[1]-vec1[1];
-
- if (fabsf(dx) > fabsf(dy)) {
-
- /* all lines from left to right */
- if (vec1[0]<vec2[0]) {
- copy_v3_v3(v1, vec1);
- copy_v3_v3(v2, vec2);
- }
- else {
- copy_v3_v3(v2, vec1);
- copy_v3_v3(v1, vec2);
- dx= -dx; dy= -dy;
- }
-
- start= floor(v1[0]);
- end= start+floor(dx);
- if (end>=zspan->rectx) end= zspan->rectx-1;
-
- oldy= floor(v1[1]);
- dy/= dx;
-
- vergz= floor(v1[2]);
- dz= floor((v2[2]-v1[2])/dx);
- if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
-
- rectz= zspan->rectz + oldy*zspan->rectx+ start;
- rectp= zspan->rectp + oldy*zspan->rectx+ start;
- recto= zspan->recto + oldy*zspan->rectx+ start;
- rectmask= zspan->rectmask + oldy*zspan->rectx+ start;
-
- if (dy<0) ofs= -zspan->rectx;
- else ofs= zspan->rectx;
-
- for (x= start; x<=end; x++, rectz++, rectp++, recto++, rectmask++) {
-
- y= floor(v1[1]);
- if (y!=oldy) {
- oldy= y;
- rectz+= ofs;
- rectp+= ofs;
- recto+= ofs;
- rectmask+= ofs;
- }
-
- if (x>=0 && y>=0 && y<zspan->recty) {
- if (vergz<*rectz) {
- if (!zspan->rectmask || vergz>*rectmask) {
- *recto= obi;
- *rectz= vergz;
- *rectp= zvlnr;
- }
- }
- }
-
- v1[1]+= dy;
-
- if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0;
- else vergz+= dz;
- }
- }
- else {
- /* all lines from top to bottom */
- if (vec1[1]<vec2[1]) {
- copy_v3_v3(v1, vec1);
- copy_v3_v3(v2, vec2);
- }
- else {
- copy_v3_v3(v2, vec1);
- copy_v3_v3(v1, vec2);
- dx= -dx; dy= -dy;
- }
-
- start= floor(v1[1]);
- end= start+floor(dy);
-
- if (end>=zspan->recty) end= zspan->recty-1;
-
- oldx= floor(v1[0]);
- dx/= dy;
-
- vergz= floor(v1[2]);
- dz= floor((v2[2]-v1[2])/dy);
- if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
-
- rectz= zspan->rectz + start*zspan->rectx+ oldx;
- rectp= zspan->rectp + start*zspan->rectx+ oldx;
- recto= zspan->recto + start*zspan->rectx+ oldx;
- rectmask= zspan->rectmask + start*zspan->rectx+ oldx;
-
- if (dx<0) ofs= -1;
- else ofs= 1;
-
- for (y= start; y<=end; y++, rectz+=zspan->rectx, rectp+=zspan->rectx, recto+=zspan->rectx, rectmask+=zspan->rectx) {
-
- x= floor(v1[0]);
- if (x!=oldx) {
- oldx= x;
- rectz+= ofs;
- rectp+= ofs;
- recto+= ofs;
- rectmask+= ofs;
- }
-
- if (x>=0 && y>=0 && x<zspan->rectx) {
- if (vergz<*rectz) {
- if (!zspan->rectmask || vergz>*rectmask) {
- *rectz= vergz;
- *rectp= zvlnr;
- *recto= obi;
- }
- }
- }
-
- v1[0]+= dx;
- if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0;
- else vergz+= dz;
- }
- }
-}
-
-static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), const float vec1[3], const float vec2[3])
-{
- int *rectz, *rectz1= NULL;
- int start, end, x, y, oldx, oldy, ofs;
- int dz, vergz, maxtest= 0;
- float dx, dy;
- float v1[3], v2[3];
-
- dx= vec2[0]-vec1[0];
- dy= vec2[1]-vec1[1];
-
- if (fabsf(dx) > fabsf(dy)) {
-
- /* all lines from left to right */
- if (vec1[0]<vec2[0]) {
- copy_v3_v3(v1, vec1);
- copy_v3_v3(v2, vec2);
- }
- else {
- copy_v3_v3(v2, vec1);
- copy_v3_v3(v1, vec2);
- dx= -dx; dy= -dy;
- }
-
- start= floor(v1[0]);
- end= start+floor(dx);
- if (end>=zspan->rectx) end= zspan->rectx-1;
-
- oldy= floor(v1[1]);
- dy/= dx;
-
- vergz= floor(v1[2]);
- dz= floor((v2[2]-v1[2])/dx);
- if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
-
- rectz= zspan->rectz + oldy*zspan->rectx+ start;
- if (zspan->rectz1)
- rectz1= zspan->rectz1 + oldy*zspan->rectx+ start;
-
- if (dy<0) ofs= -zspan->rectx;
- else ofs= zspan->rectx;
-
- for (x= start; x<=end; x++, rectz++) {
-
- y= floor(v1[1]);
- if (y!=oldy) {
- oldy= y;
- rectz+= ofs;
- if (rectz1) rectz1+= ofs;
- }
-
- if (x>=0 && y>=0 && y<zspan->recty) {
- if (vergz < *rectz) {
- if (rectz1) *rectz1= *rectz;
- *rectz= vergz;
- }
- else if (rectz1 && vergz < *rectz1)
- *rectz1= vergz;
- }
-
- v1[1]+= dy;
-
- if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0;
- else vergz+= dz;
-
- if (rectz1) rectz1++;
- }
- }
- else {
- /* all lines from top to bottom */
- if (vec1[1]<vec2[1]) {
- copy_v3_v3(v1, vec1);
- copy_v3_v3(v2, vec2);
- }
- else {
- copy_v3_v3(v2, vec1);
- copy_v3_v3(v1, vec2);
- dx= -dx; dy= -dy;
- }
-
- start= floor(v1[1]);
- end= start+floor(dy);
-
- if (end>=zspan->recty) end= zspan->recty-1;
-
- oldx= floor(v1[0]);
- dx/= dy;
-
- vergz= floor(v1[2]);
- dz= floor((v2[2]-v1[2])/dy);
- if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
-
- rectz= zspan->rectz + start*zspan->rectx+ oldx;
- if (zspan->rectz1)
- rectz1= zspan->rectz1 + start*zspan->rectx+ oldx;
-
- if (dx<0) ofs= -1;
- else ofs= 1;
-
- for (y= start; y<=end; y++, rectz+=zspan->rectx) {
-
- x= floor(v1[0]);
- if (x!=oldx) {
- oldx= x;
- rectz+= ofs;
- if (rectz1) rectz1+= ofs;
- }
-
- if (x>=0 && y>=0 && x<zspan->rectx) {
- if (vergz < *rectz) {
- if (rectz1) *rectz1= *rectz;
- *rectz= vergz;
- }
- else if (rectz1 && vergz < *rectz1)
- *rectz1= vergz;
- }
-
- v1[0]+= dx;
- if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0;
- else vergz+= dz;
-
- if (rectz1)
- rectz1+=zspan->rectx;
- }
- }
-}
-
-
-static int clipline(float v1[4], float v2[4]) /* return 0: do not draw */
-{
- float dz, dw, u1=0.0, u2=1.0;
- float dx, dy, v13;
-
- dz= v2[2]-v1[2];
- dw= v2[3]-v1[3];
-
- /* this 1.01 is for clipping x and y just a tinsy larger. that way it is
- * filled in with zbufwire correctly when rendering in parts. otherwise
- * you see line endings at edges... */
-
- if (cliptestf(-dz, -dw, v1[3], v1[2], &u1, &u2)) {
- if (cliptestf(dz, -dw, v1[3], -v1[2], &u1, &u2)) {
-
- dx= v2[0]-v1[0];
- dz= 1.01f*(v2[3]-v1[3]);
- v13= 1.01f*v1[3];
-
- if (cliptestf(-dx, -dz, v1[0], v13, &u1, &u2)) {
- if (cliptestf(dx, -dz, v13, -v1[0], &u1, &u2)) {
-
- dy= v2[1]-v1[1];
-
- if (cliptestf(-dy, -dz, v1[1], v13, &u1, &u2)) {
- if (cliptestf(dy, -dz, v13, -v1[1], &u1, &u2)) {
-
- if (u2<1.0f) {
- v2[0]= v1[0]+u2*dx;
- v2[1]= v1[1]+u2*dy;
- v2[2]= v1[2]+u2*dz;
- v2[3]= v1[3]+u2*dw;
- }
- if (u1>0.0f) {
- v1[0]= v1[0]+u1*dx;
- v1[1]= v1[1]+u1*dy;
- v1[2]= v1[2]+u1*dz;
- v1[3]= v1[3]+u1*dw;
- }
- return 1;
- }
- }
- }
- }
- }
- }
-
- return 0;
-}
-
-void hoco_to_zco(ZSpan *zspan, float zco[3], const float hoco[4])
-{
- float div;
-
- div= 1.0f/hoco[3];
- zco[0]= zspan->zmulx*(1.0f+hoco[0]*div) + zspan->zofsx;
- zco[1]= zspan->zmuly*(1.0f+hoco[1]*div) + zspan->zofsy;
- zco[2]= 0x7FFFFFFF *(hoco[2]*div);
-}
-
-void zbufclipwire(ZSpan *zspan, int obi, int zvlnr, int ec,
- const float ho1[4], const float ho2[4], const float ho3[4], const float ho4[4],
- const int c1, const int c2, const int c3, const int c4)
-{
- float vez[20];
- int and, or;
-
- /* edgecode: 1= draw */
- if (ec==0) return;
-
- if (ho4) {
- and= (c1 & c2 & c3 & c4);
- or= (c1 | c2 | c3 | c4);
- }
- else {
- and= (c1 & c2 & c3);
- or= (c1 | c2 | c3);
- }
-
- if (or) { /* not in the middle */
- if (and) { /* out completely */
- return;
- }
- else { /* clipping */
-
- if (ec & ME_V1V2) {
- copy_v4_v4(vez, ho1);
- copy_v4_v4(vez+4, ho2);
- if ( clipline(vez, vez+4)) {
- hoco_to_zco(zspan, vez, vez);
- hoco_to_zco(zspan, vez+4, vez+4);
- zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4);
- }
- }
- if (ec & ME_V2V3) {
- copy_v4_v4(vez, ho2);
- copy_v4_v4(vez+4, ho3);
- if ( clipline(vez, vez+4)) {
- hoco_to_zco(zspan, vez, vez);
- hoco_to_zco(zspan, vez+4, vez+4);
- zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4);
- }
- }
- if (ho4) {
- if (ec & ME_V3V4) {
- copy_v4_v4(vez, ho3);
- copy_v4_v4(vez+4, ho4);
- if ( clipline(vez, vez+4)) {
- hoco_to_zco(zspan, vez, vez);
- hoco_to_zco(zspan, vez+4, vez+4);
- zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4);
- }
- }
- if (ec & ME_V4V1) {
- copy_v4_v4(vez, ho4);
- copy_v4_v4(vez+4, ho1);
- if ( clipline(vez, vez+4)) {
- hoco_to_zco(zspan, vez, vez);
- hoco_to_zco(zspan, vez+4, vez+4);
- zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4);
- }
- }
- }
- else {
- if (ec & ME_V3V1) {
- copy_v4_v4(vez, ho3);
- copy_v4_v4(vez+4, ho1);
- if ( clipline(vez, vez+4)) {
- hoco_to_zco(zspan, vez, vez);
- hoco_to_zco(zspan, vez+4, vez+4);
- zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4);
- }
- }
- }
-
- return;
- }
- }
-
- hoco_to_zco(zspan, vez, ho1);
- hoco_to_zco(zspan, vez+4, ho2);
- hoco_to_zco(zspan, vez+8, ho3);
- if (ho4) {
- hoco_to_zco(zspan, vez+12, ho4);
-
- if (ec & ME_V3V4) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+8, vez+12);
- if (ec & ME_V4V1) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+12, vez);
- }
- else {
- if (ec & ME_V3V1) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+8, vez);
- }
-
- if (ec & ME_V1V2) zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4);
- if (ec & ME_V2V3) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+4, vez+8);
-
-}
-
-void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, const float ho1[4], const float ho2[4])
-{
- float f1[4], f2[4];
- int c1, c2;
-
- c1= testclip(ho1);
- c2= testclip(ho2);
-
- if (c1 | c2) { /* not in the middle */
- if (!(c1 & c2)) { /* not out completely */
- copy_v4_v4(f1, ho1);
- copy_v4_v4(f2, ho2);
-
- if (clipline(f1, f2)) {
- hoco_to_zco(zspan, f1, f1);
- hoco_to_zco(zspan, f2, f2);
- zspan->zbuflinefunc(zspan, obi, zvlnr, f1, f2);
- }
- }
- }
- else {
- hoco_to_zco(zspan, f1, ho1);
- hoco_to_zco(zspan, f2, ho2);
-
- zspan->zbuflinefunc(zspan, obi, zvlnr, f1, f2);
- }
-}
-
-/**
- * Fill the z buffer, but invert z order, and add the face index to
- * the corresponding face buffer.
- *
- * This is one of the z buffer fill functions called in zbufclip() and
- * zbufwireclip().
- *
- * \param v1 [4 floats, world coordinates] first vertex
- * \param v2 [4 floats, world coordinates] second vertex
- * \param v3 [4 floats, world coordinates] third vertex
- */
-
-/* WATCH IT: zbuffillGLinv4 and zbuffillGL4 are identical except for a 2 lines,
- * commented below */
-static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr,
- const float *v1, const float *v2, const float *v3, const float *v4)
-{
- double zxd, zyd, zy0, zverg;
- float x0, y0, z0;
- float x1, y1, z1, x2, y2, z2, xx1;
- const float *span1, *span2;
- int *rectoofs, *ro;
- int *rectpofs, *rp;
- const int *rectmaskofs, *rm;
- int *rz, x, y;
- int sn1, sn2, rectx, *rectzofs, my0, my2;
-
- /* init */
- zbuf_init_span(zspan);
-
- /* set spans */
- zbuf_add_to_span(zspan, v1, v2);
- zbuf_add_to_span(zspan, v2, v3);
- if (v4) {
- zbuf_add_to_span(zspan, v3, v4);
- zbuf_add_to_span(zspan, v4, v1);
- }
- else
- zbuf_add_to_span(zspan, v3, v1);
-
- /* clipped */
- if (zspan->minp2==NULL || zspan->maxp2==NULL) return;
-
- my0 = max_ii(zspan->miny1, zspan->miny2);
- my2 = min_ii(zspan->maxy1, zspan->maxy2);
-
- // printf("my %d %d\n", my0, my2);
- if (my2<my0) return;
-
-
- /* ZBUF DX DY, in floats still */
- x1= v1[0]- v2[0];
- x2= v2[0]- v3[0];
- y1= v1[1]- v2[1];
- y2= v2[1]- v3[1];
- z1= v1[2]- v2[2];
- z2= v2[2]- v3[2];
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
- z0= x1*y2-y1*x2;
-
- if (z0==0.0f) return;
-
- xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
-
- zxd= -(double)x0/(double)z0;
- zyd= -(double)y0/(double)z0;
- zy0= ((double)my2)*zyd + (double)xx1;
-
- /* start-offset in rect */
- rectx= zspan->rectx;
- rectzofs= (zspan->rectz+rectx*my2);
- rectpofs= (zspan->rectp+rectx*my2);
- rectoofs= (zspan->recto+rectx*my2);
- rectmaskofs= (zspan->rectmask+rectx*my2);
-
- /* correct span */
- sn1= (my0 + my2)/2;
- if (zspan->span1[sn1] < zspan->span2[sn1]) {
- span1= zspan->span1+my2;
- span2= zspan->span2+my2;
- }
- else {
- span1= zspan->span2+my2;
- span2= zspan->span1+my2;
- }
-
- for (y=my2; y>=my0; y--, span1--, span2--) {
-
- sn1= floor(*span1);
- sn2= floor(*span2);
- sn1++;
-
- if (sn2>=rectx) sn2= rectx-1;
- if (sn1<0) sn1= 0;
-
- if (sn2>=sn1) {
- int intzverg;
-
- zverg= (double)sn1*zxd + zy0;
- rz= rectzofs+sn1;
- rp= rectpofs+sn1;
- ro= rectoofs+sn1;
- rm= rectmaskofs+sn1;
- x= sn2-sn1;
-
- while (x>=0) {
- intzverg = round_db_to_int_clamp(zverg);
-
- if ( intzverg > *rz || *rz==0x7FFFFFFF) { /* UNIQUE LINE: see comment above */
- if (!zspan->rectmask || intzverg > *rm) {
- *ro= obi; /* UNIQUE LINE: see comment above (order differs) */
- *rz= intzverg;
- *rp= zvlnr;
- }
- }
- zverg+= zxd;
- rz++;
- rp++;
- ro++;
- rm++;
- x--;
- }
- }
-
- zy0-=zyd;
- rectzofs-= rectx;
- rectpofs-= rectx;
- rectoofs-= rectx;
- rectmaskofs-= rectx;
- }
-}
-
-/* uses spanbuffers */
-
-/* WATCH IT: zbuffillGLinv4 and zbuffillGL4 are identical except for a 2 lines,
- * commented below */
-static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr,
- const float *v1, const float *v2, const float *v3, const float *v4)
-{
- double zxd, zyd, zy0, zverg;
- float x0, y0, z0;
- float x1, y1, z1, x2, y2, z2, xx1;
- const float *span1, *span2;
- int *rectoofs, *ro;
- int *rectpofs, *rp;
- const int *rectmaskofs, *rm;
- int *rz, x, y;
- int sn1, sn2, rectx, *rectzofs, my0, my2;
-
- /* init */
- zbuf_init_span(zspan);
-
- /* set spans */
- zbuf_add_to_span(zspan, v1, v2);
- zbuf_add_to_span(zspan, v2, v3);
- if (v4) {
- zbuf_add_to_span(zspan, v3, v4);
- zbuf_add_to_span(zspan, v4, v1);
- }
- else
- zbuf_add_to_span(zspan, v3, v1);
-
- /* clipped */
- if (zspan->minp2==NULL || zspan->maxp2==NULL) return;
-
- my0 = max_ii(zspan->miny1, zspan->miny2);
- my2 = min_ii(zspan->maxy1, zspan->maxy2);
-
- // printf("my %d %d\n", my0, my2);
- if (my2<my0) return;
-
-
- /* ZBUF DX DY, in floats still */
- x1= v1[0]- v2[0];
- x2= v2[0]- v3[0];
- y1= v1[1]- v2[1];
- y2= v2[1]- v3[1];
- z1= v1[2]- v2[2];
- z2= v2[2]- v3[2];
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
- z0= x1*y2-y1*x2;
-
- if (z0==0.0f) return;
-
- xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
-
- zxd= -(double)x0/(double)z0;
- zyd= -(double)y0/(double)z0;
- zy0= ((double)my2)*zyd + (double)xx1;
-
- /* start-offset in rect */
- rectx= zspan->rectx;
- rectzofs= (zspan->rectz+rectx*my2);
- rectpofs= (zspan->rectp+rectx*my2);
- rectoofs= (zspan->recto+rectx*my2);
- rectmaskofs= (zspan->rectmask+rectx*my2);
-
- /* correct span */
- sn1= (my0 + my2)/2;
- if (zspan->span1[sn1] < zspan->span2[sn1]) {
- span1= zspan->span1+my2;
- span2= zspan->span2+my2;
- }
- else {
- span1= zspan->span2+my2;
- span2= zspan->span1+my2;
- }
-
- for (y=my2; y>=my0; y--, span1--, span2--) {
-
- sn1= floor(*span1);
- sn2= floor(*span2);
- sn1++;
-
- if (sn2>=rectx) sn2= rectx-1;
- if (sn1<0) sn1= 0;
-
- if (sn2>=sn1) {
- int intzverg;
-
- zverg= (double)sn1*zxd + zy0;
- rz= rectzofs+sn1;
- rp= rectpofs+sn1;
- ro= rectoofs+sn1;
- rm= rectmaskofs+sn1;
- x= sn2-sn1;
-
- while (x>=0) {
- intzverg = round_db_to_int_clamp(zverg);
-
- if (intzverg < *rz) { /* ONLY UNIQUE LINE: see comment above */
- if (!zspan->rectmask || intzverg > *rm) {
- *rz= intzverg;
- *rp= zvlnr;
- *ro= obi; /* UNIQUE LINE: see comment above (order differs) */
- }
- }
- zverg+= zxd;
- rz++;
- rp++;
- ro++;
- rm++;
- x--;
- }
- }
-
- zy0-=zyd;
- rectzofs-= rectx;
- rectpofs-= rectx;
- rectoofs-= rectx;
- rectmaskofs-= rectx;
- }
-}
-
-/**
- * Fill the z buffer. The face buffer is not operated on!
- *
- * This is one of the z buffer fill functions called in zbufclip() and
- * zbufwireclip().
- *
- * \param v1 [4 floats, world coordinates] first vertex
- * \param v2 [4 floats, world coordinates] second vertex
- * \param v3 [4 floats, world coordinates] third vertex
- */
-
-/* now: filling two Z values, the closest and 2nd closest */
-static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr),
- const float *v1, const float *v2, const float *v3, const float *v4)
-{
- double zxd, zyd, zy0, zverg;
- float x0, y0, z0;
- float x1, y1, z1, x2, y2, z2, xx1;
- const float *span1, *span2;
- int *rz, *rz1, x, y;
- int sn1, sn2, rectx, *rectzofs, *rectzofs1= NULL, my0, my2;
-
- /* init */
- zbuf_init_span(zspan);
-
- /* set spans */
- zbuf_add_to_span(zspan, v1, v2);
- zbuf_add_to_span(zspan, v2, v3);
- if (v4) {
- zbuf_add_to_span(zspan, v3, v4);
- zbuf_add_to_span(zspan, v4, v1);
- }
- else
- zbuf_add_to_span(zspan, v3, v1);
-
- /* clipped */
- if (zspan->minp2==NULL || zspan->maxp2==NULL) return;
-
- my0 = max_ii(zspan->miny1, zspan->miny2);
- my2 = min_ii(zspan->maxy1, zspan->maxy2);
-
- // printf("my %d %d\n", my0, my2);
- if (my2<my0) return;
-
-
- /* ZBUF DX DY, in floats still */
- x1= v1[0]- v2[0];
- x2= v2[0]- v3[0];
- y1= v1[1]- v2[1];
- y2= v2[1]- v3[1];
- z1= v1[2]- v2[2];
- z2= v2[2]- v3[2];
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
- z0= x1*y2-y1*x2;
-
- if (z0==0.0f) return;
-
- xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
-
- zxd= -(double)x0/(double)z0;
- zyd= -(double)y0/(double)z0;
- zy0= ((double)my2)*zyd + (double)xx1;
-
- /* start-offset in rect */
- rectx= zspan->rectx;
- rectzofs= (zspan->rectz+rectx*my2);
- if (zspan->rectz1)
- rectzofs1= (zspan->rectz1+rectx*my2);
-
- /* correct span */
- sn1= (my0 + my2)/2;
- if (zspan->span1[sn1] < zspan->span2[sn1]) {
- span1= zspan->span1+my2;
- span2= zspan->span2+my2;
- }
- else {
- span1= zspan->span2+my2;
- span2= zspan->span1+my2;
- }
-
- for (y=my2; y>=my0; y--, span1--, span2--) {
-
- sn1= floor(*span1);
- sn2= floor(*span2);
- sn1++;
-
- if (sn2>=rectx) sn2= rectx-1;
- if (sn1<0) sn1= 0;
-
- if (sn2>=sn1) {
- zverg= (double)sn1*zxd + zy0;
- rz= rectzofs+sn1;
- rz1= rectzofs1+sn1;
- x= sn2-sn1;
-
- while (x>=0) {
- int zvergi = round_db_to_int_clamp(zverg);
-
- /* option: maintain two depth values, closest and 2nd closest */
- if (zvergi < *rz) {
- if (rectzofs1) *rz1= *rz;
- *rz= zvergi;
- }
- else if (rectzofs1 && zvergi < *rz1)
- *rz1= zvergi;
-
- zverg+= zxd;
-
- rz++;
- rz1++;
- x--;
- }
- }
-
- zy0-=zyd;
- rectzofs-= rectx;
- if (rectzofs1) rectzofs1-= rectx;
- }
-}
-
-/* 2d scanconvert for tria, calls func for each x, y coordinate and gives UV barycentrics */
-void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, float *v3, void (*func)(void *, int, int, float, float, float) )
-{
- float x0, y0, x1, y1, x2, y2, z0, z1, z2, z;
- float u, v, uxd, uyd, vxd, vyd, uy0, vy0, zxd, zyd, zy0, xx1;
- const float *span1, *span2;
- int x, y, sn1, sn2, rectx= zspan->rectx, my0, my2;
-
- /* init */
- zbuf_init_span(zspan);
-
- /* set spans */
- zbuf_add_to_span(zspan, v1, v2);
- zbuf_add_to_span(zspan, v2, v3);
- zbuf_add_to_span(zspan, v3, v1);
-
- /* clipped */
- if (zspan->minp2==NULL || zspan->maxp2==NULL) return;
-
- my0 = max_ii(zspan->miny1, zspan->miny2);
- my2 = min_ii(zspan->maxy1, zspan->maxy2);
-
- // printf("my %d %d\n", my0, my2);
- if (my2<my0) return;
-
- /* ZBUF DX DY, in floats still */
- x1= v1[0]- v2[0];
- x2= v2[0]- v3[0];
- y1= v1[1]- v2[1];
- y2= v2[1]- v3[1];
- z1= v1[2]- v2[2];
- z2= v2[2]- v3[2];
-
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
- z0= x1*y2-y1*x2;
-
- if (z0==0.0f) return;
-
- xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
- zxd= -(double)x0/(double)z0;
- zyd= -(double)y0/(double)z0;
- zy0= ((double)my2)*zyd + (double)xx1;
-
- z1= 1.0f; /* (u1 - u2) */
- z2= 0.0f; /* (u2 - u3) */
-
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
-
- xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f;
- uxd= -(double)x0/(double)z0;
- uyd= -(double)y0/(double)z0;
- uy0= ((double)my2)*uyd + (double)xx1;
-
- z1= -1.0f; /* (v1 - v2) */
- z2= 1.0f; /* (v2 - v3) */
-
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
-
- xx1= (x0*v1[0] + y0*v1[1])/z0;
- vxd= -(double)x0/(double)z0;
- vyd= -(double)y0/(double)z0;
- vy0= ((double)my2)*vyd + (double)xx1;
-
- /* correct span */
- sn1= (my0 + my2)/2;
- if (zspan->span1[sn1] < zspan->span2[sn1]) {
- span1= zspan->span1+my2;
- span2= zspan->span2+my2;
- }
- else {
- span1= zspan->span2+my2;
- span2= zspan->span1+my2;
- }
-
- for (y=my2; y>=my0; y--, span1--, span2--) {
-
- sn1= floor(*span1);
- sn2= floor(*span2);
- sn1++;
-
- if (sn2>=rectx) sn2= rectx-1;
- if (sn1<0) sn1= 0;
-
- u= (double)sn1*uxd + uy0;
- v= (double)sn1*vxd + vy0;
- z= (double)sn1*zxd + zy0;
-
- for (x= sn1; x<=sn2; x++, u+=uxd, v+=vxd, z+=zxd)
- func(handle, x, y, u, v, z);
-
- uy0 -= uyd;
- vy0 -= vyd;
- zy0 -= zyd;
- }
-}
-
/* scanconvert for strand triangles, calls func for each x, y coordinate and gives UV barycentrics and z */
void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float *v3, void (*func)(void *, int, int, float, float) )
@@ -1585,2154 +241,4 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float *
}
}
-
-
-/**
- * (clip pyramid)
- * Sets lambda: flag, and parametrize the clipping of vertices in
- * viewspace coordinates. lambda = -1 means no clipping, lambda in [0, 1] means a clipping.
- * Note: uses globals.
- * \param v1 start coordinate s
- * \param v2 target coordinate t
- * \param b2
- * \param b3
- * \param a index for coordinate (x, y, or z)
- */
-
-static void clippyra(float *lambda, float *v1, float *v2, int *b2, int *b3, int a, float clipcrop)
-{
- float da, dw, u1=0.0, u2=1.0;
- float v13;
-
- lambda[0]= -1.0;
- lambda[1]= -1.0;
-
- da= v2[a]-v1[a];
- /* prob; we clip slightly larger, osa renders add 2 pixels on edges, should become variable? */
- /* or better; increase r.winx/y size, but thats quite a complex one. do it later */
- if (a==2) {
- dw= (v2[3]-v1[3]);
- v13= v1[3];
- }
- else {
- dw= clipcrop*(v2[3]-v1[3]);
- v13= clipcrop*v1[3];
- }
- /* according the original article by Liang&Barsky, for clipping of
- * homogeneous coordinates with viewplane, the value of "0" is used instead of "-w" .
- * This differs from the other clipping cases (like left or top) and I considered
- * it to be not so 'homogenic'. But later it has proven to be an error,
- * who would have thought that of L&B!
- */
-
- if (cliptestf(-da, -dw, v13, v1[a], &u1, &u2)) {
- if (cliptestf(da, -dw, v13, -v1[a], &u1, &u2)) {
- *b3=1;
- if (u2<1.0f) {
- lambda[1]= u2;
- *b2=1;
- }
- else lambda[1]=1.0; /* u2 */
- if (u1>0.0f) {
- lambda[0] = u1;
- *b2 = 1;
- }
- else {
- lambda[0] = 0.0;
- }
- }
- }
-}
-
-/**
- * (make vertex pyramide clip)
- * Checks lambda and uses this to make decision about clipping the line
- * segment from v1 to v2. lambda is the factor by which the vector is
- * cut. ( calculate s + l * ( t - s )). The result is appended to the
- * vertex list of this face.
- *
- *
- * \param v1 start coordinate s
- * \param v2 target coordinate t
- * \param b1
- * \param b2
- * \param clve vertex vector.
- */
-
-static void makevertpyra(float *vez, float *lambda, float **trias, float *v1, float *v2, int *b1, int *clve)
-{
- float l1, l2, *adr;
-
- l1= lambda[0];
- l2= lambda[1];
-
- if (l1!= -1.0f) {
- if (l1!= 0.0f) {
- adr= vez+4*(*clve);
- trias[*b1]=adr;
- (*clve)++;
- adr[0]= v1[0]+l1*(v2[0]-v1[0]);
- adr[1]= v1[1]+l1*(v2[1]-v1[1]);
- adr[2]= v1[2]+l1*(v2[2]-v1[2]);
- adr[3]= v1[3]+l1*(v2[3]-v1[3]);
- }
- else trias[*b1]= v1;
-
- (*b1)++;
- }
- if (l2!= -1.0f) {
- if (l2!= 1.0f) {
- adr= vez+4*(*clve);
- trias[*b1]=adr;
- (*clve)++;
- adr[0]= v1[0]+l2*(v2[0]-v1[0]);
- adr[1]= v1[1]+l2*(v2[1]-v1[1]);
- adr[2]= v1[2]+l2*(v2[2]-v1[2]);
- adr[3]= v1[3]+l2*(v2[3]-v1[3]);
- (*b1)++;
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-void projectverto(const float v1[3], float winmat[4][4], float adr[4])
-{
- /* calcs homogenic coord of vertex v1 */
- float x, y, z;
-
- x = v1[0];
- y = v1[1];
- z = v1[2];
- adr[0] = x * winmat[0][0] + z * winmat[2][0] + winmat[3][0];
- adr[1] = y * winmat[1][1] + z * winmat[2][1] + winmat[3][1];
- adr[2] = z * winmat[2][2] + winmat[3][2];
- adr[3] = z * winmat[2][3] + winmat[3][3];
-
- //printf("hoco %f %f %f %f\n", adr[0], adr[1], adr[2], adr[3]);
-}
-
-/* ------------------------------------------------------------------------- */
-
-void projectvert(const float v1[3], float winmat[4][4], float adr[4])
-{
- /* calcs homogenic coord of vertex v1 */
- float x, y, z;
-
- x = v1[0];
- y = v1[1];
- z = v1[2];
- adr[0] = x * winmat[0][0] + y * winmat[1][0] + z * winmat[2][0] + winmat[3][0];
- adr[1] = x * winmat[0][1] + y * winmat[1][1] + z * winmat[2][1] + winmat[3][1];
- adr[2] = x * winmat[0][2] + y * winmat[1][2] + z * winmat[2][2] + winmat[3][2];
- adr[3] = x * winmat[0][3] + y * winmat[1][3] + z * winmat[2][3] + winmat[3][3];
-}
-
-/* ------------------------------------------------------------------------- */
-
-#define ZBUF_PROJECT_CACHE_SIZE 256
-
-typedef struct ZbufProjectCache {
- int index, clip;
- float ho[4];
-} ZbufProjectCache;
-
-static void zbuf_project_cache_clear(ZbufProjectCache *cache, int size)
-{
- int i;
-
- if (size > ZBUF_PROJECT_CACHE_SIZE)
- size= ZBUF_PROJECT_CACHE_SIZE;
-
- memset(cache, 0, sizeof(ZbufProjectCache)*size);
- for (i=0; i<size; i++)
- cache[i].index= -1;
-}
-
-static int zbuf_shadow_project(ZbufProjectCache *cache, int index, float winmat[4][4], float *co, float *ho)
-{
- int cindex= index & 255;
-
- if (cache[cindex].index == index) {
- copy_v4_v4(ho, cache[cindex].ho);
- return cache[cindex].clip;
- }
- else {
- int clipflag;
- projectvert(co, winmat, ho);
- clipflag= testclip(ho);
-
- copy_v4_v4(cache[cindex].ho, ho);
- cache[cindex].clip= clipflag;
- cache[cindex].index= index;
-
- return clipflag;
- }
-}
-
-static void zbuffer_part_bounds(int winx, int winy, RenderPart *pa, float *bounds)
-{
- bounds[0]= (2*pa->disprect.xmin - winx-1)/(float)winx;
- bounds[1]= (2*pa->disprect.xmax - winx+1)/(float)winx;
- bounds[2]= (2*pa->disprect.ymin - winy-1)/(float)winy;
- bounds[3]= (2*pa->disprect.ymax - winy+1)/(float)winy;
-}
-
-static int zbuf_part_project(ZbufProjectCache *cache, int index, float winmat[4][4], float *bounds, float *co, float *ho)
-{
- float vec[3];
- int cindex= index & 255;
-
- if (cache[cindex].index == index) {
- copy_v4_v4(ho, cache[cindex].ho);
- return cache[cindex].clip;
- }
- else {
- float wco;
- int clipflag= 0;
- copy_v3_v3(vec, co);
- projectvert(co, winmat, ho);
-
- wco= ho[3];
- if (ho[0] < bounds[0]*wco) clipflag |= 1;
- else if (ho[0] > bounds[1]*wco) clipflag |= 2;
- if (ho[1] > bounds[3]*wco) clipflag |= 4;
- else if (ho[1] < bounds[2]*wco) clipflag |= 8;
-
- copy_v4_v4(cache[cindex].ho, ho);
- cache[cindex].clip= clipflag;
- cache[cindex].index= index;
-
- return clipflag;
- }
-}
-
-void zbuf_render_project(float winmat[4][4], const float co[3], float ho[4])
-{
- float vec[3];
-
- copy_v3_v3(vec, co);
- projectvert(vec, winmat, ho);
-}
-
-void zbuf_make_winmat(Render *re, float winmat[4][4])
-{
- if (re->r.mode & R_PANORAMA) {
- float panomat[4][4];
-
- unit_m4(panomat);
-
- panomat[0][0]= re->panoco;
- panomat[0][2]= re->panosi;
- panomat[2][0]= -re->panosi;
- panomat[2][2]= re->panoco;
-
- mul_m4_m4m4(winmat, re->winmat, panomat);
- }
- else
- copy_m4_m4(winmat, re->winmat);
-}
-
-/* do zbuffering and clip, f1 f2 f3 are hocos, c1 c2 c3 are clipping flags */
-
-void zbufclip(ZSpan *zspan, int obi, int zvlnr,
- const float f1[4], const float f2[4], const float f3[4],
- const int c1, const int c2, const int c3)
-{
- float *vlzp[32][3], lambda[3][2];
- float vez[400], *trias[40];
-
- if (c1 | c2 | c3) { /* not in middle */
- if (c1 & c2 & c3) { /* completely out */
- return;
- }
- else { /* clipping */
- int arg, v, b, clipflag[3], b1, b2, b3, c4, clve=3, clvlo, clvl=1;
- float *fp;
-
- vez[0]= f1[0]; vez[1]= f1[1]; vez[2]= f1[2]; vez[3]= f1[3];
- vez[4]= f2[0]; vez[5]= f2[1]; vez[6]= f2[2]; vez[7]= f2[3];
- vez[8]= f3[0]; vez[9]= f3[1]; vez[10]= f3[2];vez[11]= f3[3];
-
- vlzp[0][0]= vez;
- vlzp[0][1]= vez+4;
- vlzp[0][2]= vez+8;
-
- clipflag[0]= ( (c1 & 48) | (c2 & 48) | (c3 & 48) );
- if (clipflag[0]==0) { /* othwerwise it needs to be calculated again, after the first (z) clip */
- clipflag[1]= ( (c1 & 3) | (c2 & 3) | (c3 & 3) );
- clipflag[2]= ( (c1 & 12) | (c2 & 12) | (c3 & 12) );
- }
- else clipflag[1]=clipflag[2]= 0;
-
- for (b=0;b<3;b++) {
-
- if (clipflag[b]) {
-
- clvlo= clvl;
-
- for (v=0; v<clvlo; v++) {
-
- if (vlzp[v][0]!=NULL) { /* face is still there */
- b2= b3 =0; /* clip flags */
-
- if (b==0) arg= 2;
- else if (b==1) arg= 0;
- else arg= 1;
-
- clippyra(lambda[0], vlzp[v][0], vlzp[v][1], &b2, &b3, arg, zspan->clipcrop);
- clippyra(lambda[1], vlzp[v][1], vlzp[v][2], &b2, &b3, arg, zspan->clipcrop);
- clippyra(lambda[2], vlzp[v][2], vlzp[v][0], &b2, &b3, arg, zspan->clipcrop);
-
- if (b2==0 && b3==1) {
- /* completely 'in', but we copy because of last for () loop in this section */;
- vlzp[clvl][0]= vlzp[v][0];
- vlzp[clvl][1]= vlzp[v][1];
- vlzp[clvl][2]= vlzp[v][2];
- vlzp[v][0]= NULL;
- clvl++;
- }
- else if (b3==0) {
- vlzp[v][0]= NULL;
- /* completely 'out' */;
- }
- else {
- b1=0;
- makevertpyra(vez, lambda[0], trias, vlzp[v][0], vlzp[v][1], &b1, &clve);
- makevertpyra(vez, lambda[1], trias, vlzp[v][1], vlzp[v][2], &b1, &clve);
- makevertpyra(vez, lambda[2], trias, vlzp[v][2], vlzp[v][0], &b1, &clve);
-
- /* after front clip done: now set clip flags */
- if (b==0) {
- clipflag[1]= clipflag[2]= 0;
- f1= vez;
- for (b3=0; b3<clve; b3++) {
- c4= testclip(f1);
- clipflag[1] |= (c4 & 3);
- clipflag[2] |= (c4 & 12);
- f1+= 4;
- }
- }
-
- vlzp[v][0]= NULL;
- if (b1>2) {
- for (b3=3; b3<=b1; b3++) {
- vlzp[clvl][0]= trias[0];
- vlzp[clvl][1]= trias[b3-2];
- vlzp[clvl][2]= trias[b3-1];
- clvl++;
- }
- }
- }
- }
- }
- }
- }
-
- /* warning, clip overflow, this should never happen! */
- BLI_assert(!(clve > 38 || clvl > 31));
-
- /* perspective division */
- fp = vez;
- for (b = 0; b < clve; b++) {
- hoco_to_zco(zspan, fp, fp);
- fp += 4;
- }
- for (b = 1; b < clvl; b++) {
- if (vlzp[b][0]) {
- zspan->zbuffunc(zspan, obi, zvlnr, vlzp[b][0], vlzp[b][1], vlzp[b][2], NULL);
- }
- }
- return;
- }
- }
-
- /* perspective division: HCS to ZCS */
- hoco_to_zco(zspan, vez, f1);
- hoco_to_zco(zspan, vez+4, f2);
- hoco_to_zco(zspan, vez+8, f3);
- zspan->zbuffunc(zspan, obi, zvlnr, vez, vez+4, vez+8, NULL);
-}
-
-void zbufclip4(ZSpan *zspan, int obi, int zvlnr,
- const float f1[4], const float f2[4], const float f3[4], const float f4[4],
- const int c1, const int c2, const int c3, const int c4)
-{
- float vez[16];
-
- if (c1 | c2 | c3 | c4) { /* not in middle */
- if (c1 & c2 & c3 & c4) { /* completely out */
- return;
- }
- else { /* clipping */
- zbufclip(zspan, obi, zvlnr, f1, f2, f3, c1, c2, c3);
- zbufclip(zspan, obi, zvlnr, f1, f3, f4, c1, c3, c4);
- }
- return;
- }
-
- /* perspective division: HCS to ZCS */
- hoco_to_zco(zspan, vez, f1);
- hoco_to_zco(zspan, vez+4, f2);
- hoco_to_zco(zspan, vez+8, f3);
- hoco_to_zco(zspan, vez+12, f4);
-
- zspan->zbuffunc(zspan, obi, zvlnr, vez, vez+4, vez+8, vez+12);
-}
-
-/* ************** ZMASK ******************************** */
-
-#define EXTEND_PIXEL(a) if (temprectp[a]) { z += rectz[a]; tot++; } (void)0
-
-/* changes the zbuffer to be ready for z-masking: applies an extend-filter, and then clears */
-static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg)
-{
- int len=0, x, y;
- int *temprectp;
- int row1, row2, row3, *curp, *curz;
-
- temprectp= MEM_dupallocN(rectp);
-
- /* extend: if pixel is not filled in, we check surrounding pixels and average z value */
-
- for (y=1; y<=ys; y++) {
- /* setup row indices */
- row1= (y-2)*xs;
- row2= row1 + xs;
- row3= row2 + xs;
- if (y==1)
- row1= row2;
- else if (y==ys)
- row3= row2;
-
- curp= rectp + (y-1)*xs;
- curz= rectz + (y-1)*xs;
-
- for (x=0; x<xs; x++, curp++, curz++) {
- if (curp[0]==0) {
- int tot= 0;
- float z= 0.0f;
-
- EXTEND_PIXEL(row1);
- EXTEND_PIXEL(row2);
- EXTEND_PIXEL(row3);
- EXTEND_PIXEL(row1 + 1);
- EXTEND_PIXEL(row3 + 1);
- if (x!=xs-1) {
- EXTEND_PIXEL(row1 + 2);
- EXTEND_PIXEL(row2 + 2);
- EXTEND_PIXEL(row3 + 2);
- }
- if (tot) {
- len++;
- curz[0]= (int)(z/(float)tot);
- curp[0]= -1; /* env */
- }
- }
-
- if (x!=0) {
- row1++; row2++; row3++;
- }
- }
- }
-
- MEM_freeN(temprectp);
-
- if (neg) {
- /* z values for negative are already correct */
- }
- else {
- /* clear not filled z values */
- for (len= xs*ys -1; len>=0; len--) {
- if (rectp[len]==0) {
- rectz[len] = -0x7FFFFFFF;
- rectp[len]= -1; /* env code */
- }
- }
- }
-}
-
-
-/* ***************** ZBUFFER MAIN ROUTINES **************** */
-
-void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart *, ZSpan *, int, void *), void *data)
-{
- ZbufProjectCache cache[ZBUF_PROJECT_CACHE_SIZE];
- ZSpan zspans[16], *zspan; /* 16 = RE_MAX_OSA */
- VlakRen *vlr= NULL;
- VertRen *v1, *v2, *v3, *v4;
- Material *ma = NULL;
- ObjectInstanceRen *obi;
- ObjectRen *obr;
- float obwinmat[4][4], winmat[4][4], bounds[4];
- float ho1[4], ho2[4], ho3[4], ho4[4]={0};
- unsigned int lay= (1 << 20) - 1, lay_zmask= 0;
- int i, v, zvlnr, zsample, samples, c1, c2, c3, c4=0;
- short nofill=0, env=0, wire=0, zmaskpass=0;
- const bool all_z = (rl->layflag & SCE_LAY_ALL_Z) && !(rl->layflag & SCE_LAY_ZMASK);
- const bool neg_zmask = (rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK);
-
- zbuf_make_winmat(&R, winmat);
-
- samples= (R.osa? R.osa: 1);
- samples= MIN2(4, samples-pa->sample);
-
- for (zsample=0; zsample<samples; zsample++) {
- zspan= &zspans[zsample];
-
- zbuffer_part_bounds(R.winx, R.winy, pa, bounds);
- zbuf_alloc_span(zspan, pa->rectx, pa->recty, R.clipcrop);
-
- /* needed for transform from hoco to zbuffer co */
- zspan->zmulx= ((float)R.winx)/2.0f;
- zspan->zmuly= ((float)R.winy)/2.0f;
-
- if (R.osa) {
- zspan->zofsx= -pa->disprect.xmin - R.jit[pa->sample+zsample][0];
- zspan->zofsy= -pa->disprect.ymin - R.jit[pa->sample+zsample][1];
- }
- else if (R.i.curblur) {
- zspan->zofsx= -pa->disprect.xmin - R.mblur_jit[R.i.curblur-1][0];
- zspan->zofsy= -pa->disprect.ymin - R.mblur_jit[R.i.curblur-1][1];
- }
- else {
- zspan->zofsx= -pa->disprect.xmin;
- zspan->zofsy= -pa->disprect.ymin;
- }
- /* to center the sample position */
- zspan->zofsx -= 0.5f;
- zspan->zofsy -= 0.5f;
-
- /* the buffers */
- if (zsample == samples-1) {
- zspan->rectp= pa->rectp;
- zspan->recto= pa->recto;
-
- if (neg_zmask)
- zspan->rectz= pa->rectmask;
- else
- zspan->rectz= pa->rectz;
- }
- else {
- zspan->recto= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "recto");
- zspan->rectp= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectp");
- zspan->rectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectz");
- }
-
- fillrect(zspan->rectz, pa->rectx, pa->recty, 0x7FFFFFFF);
- fillrect(zspan->rectp, pa->rectx, pa->recty, 0);
- fillrect(zspan->recto, pa->rectx, pa->recty, 0);
- }
-
- /* in case zmask we fill Z for objects in lay_zmask first, then clear Z, and then do normal zbuffering */
- if (rl->layflag & SCE_LAY_ZMASK)
- zmaskpass= 1;
-
- for (; zmaskpass >=0; zmaskpass--) {
- ma= NULL;
-
- /* filling methods */
- for (zsample=0; zsample<samples; zsample++) {
- zspan= &zspans[zsample];
-
- if (zmaskpass && neg_zmask)
- zspan->zbuffunc= zbuffillGLinv4;
- else
- zspan->zbuffunc= zbuffillGL4;
- zspan->zbuflinefunc= zbufline;
- }
-
- /* regular zbuffering loop, does all sample buffers */
- for (i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) {
- obr= obi->obr;
-
- /* continue happens in 2 different ways... zmaskpass only does lay_zmask stuff */
- if (zmaskpass) {
- if ((obi->lay & lay_zmask)==0)
- continue;
- }
- else if (!all_z && !(obi->lay & (lay|lay_zmask)))
- continue;
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, winmat, obi->mat);
- else
- copy_m4_m4(obwinmat, winmat);
-
- if (clip_render_object(obi->obr->boundbox, bounds, obwinmat))
- continue;
-
- zbuf_project_cache_clear(cache, obr->totvert);
-
- for (v=0; v<obr->totvlak; v++) {
- if ((v & 255)==0) vlr= obr->vlaknodes[v>>8].vlak;
- else vlr++;
-
- /* the cases: visible for render, only z values, zmask, nothing */
- if (obi->lay & lay) {
- if (vlr->mat!=ma) {
- ma= vlr->mat;
- nofill= (ma->mode & MA_ONLYCAST) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP));
- env= (ma->mode & MA_ENV);
- wire= (ma->material_type == MA_TYPE_WIRE);
-
- for (zsample=0; zsample<samples; zsample++) {
- if (ma->mode & MA_ZINV || (zmaskpass && neg_zmask))
- zspans[zsample].zbuffunc= zbuffillGLinv4;
- else
- zspans[zsample].zbuffunc= zbuffillGL4;
- }
- }
- }
- else if (all_z || (obi->lay & lay_zmask)) {
- env= 1;
- nofill= 0;
- ma= NULL;
- }
- else {
- nofill= 1;
- ma= NULL; /* otherwise nofill can hang */
- }
-
- if (!(vlr->flag & R_HIDDEN) && nofill==0) {
- unsigned short partclip;
-
- v1= vlr->v1;
- v2= vlr->v2;
- v3= vlr->v3;
- v4= vlr->v4;
-
- c1= zbuf_part_project(cache, v1->index, obwinmat, bounds, v1->co, ho1);
- c2= zbuf_part_project(cache, v2->index, obwinmat, bounds, v2->co, ho2);
- c3= zbuf_part_project(cache, v3->index, obwinmat, bounds, v3->co, ho3);
-
- /* partclipping doesn't need viewplane clipping */
- partclip= c1 & c2 & c3;
- if (v4) {
- c4= zbuf_part_project(cache, v4->index, obwinmat, bounds, v4->co, ho4);
- partclip &= c4;
- }
-
- if (partclip==0) {
-
- if (env) zvlnr= -1;
- else zvlnr= v+1;
-
- c1= testclip(ho1);
- c2= testclip(ho2);
- c3= testclip(ho3);
- if (v4)
- c4= testclip(ho4);
-
- for (zsample=0; zsample<samples; zsample++) {
- zspan= &zspans[zsample];
-
- if (wire) {
- if (v4)
- zbufclipwire(zspan, i, zvlnr, vlr->ec, ho1, ho2, ho3, ho4, c1, c2, c3, c4);
- else
- zbufclipwire(zspan, i, zvlnr, vlr->ec, ho1, ho2, ho3, NULL, c1, c2, c3, 0);
- }
- else {
- /* strands allow to be filled in as quad */
- if (v4 && (vlr->flag & R_STRAND)) {
- zbufclip4(zspan, i, zvlnr, ho1, ho2, ho3, ho4, c1, c2, c3, c4);
- }
- else {
- zbufclip(zspan, i, zvlnr, ho1, ho2, ho3, c1, c2, c3);
- if (v4)
- zbufclip(zspan, i, (env)? zvlnr: zvlnr+RE_QUAD_OFFS, ho1, ho3, ho4, c1, c3, c4);
- }
- }
- }
- }
- }
- }
- }
-
- /* clear all z to close value, so it works as mask for next passes (ztra+strand) */
- if (zmaskpass) {
- for (zsample=0; zsample<samples; zsample++) {
- zspan= &zspans[zsample];
-
- if (neg_zmask) {
- zspan->rectmask= zspan->rectz;
- if (zsample == samples-1)
- zspan->rectz= pa->rectz;
- else
- zspan->rectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectz");
- fillrect(zspan->rectz, pa->rectx, pa->recty, 0x7FFFFFFF);
-
- zmask_rect(zspan->rectmask, zspan->rectp, pa->rectx, pa->recty, 1);
- }
- else
- zmask_rect(zspan->rectz, zspan->rectp, pa->rectx, pa->recty, 0);
- }
- }
- }
-
- for (zsample=0; zsample<samples; zsample++) {
- zspan= &zspans[zsample];
-
- if (fillfunc)
- fillfunc(pa, zspan, pa->sample+zsample, data);
-
- if (zsample != samples-1) {
- MEM_freeN(zspan->rectz);
- MEM_freeN(zspan->rectp);
- MEM_freeN(zspan->recto);
- if (zspan->rectmask)
- MEM_freeN(zspan->rectmask);
- }
-
- zbuf_free_span(zspan);
- }
-}
-
-void zbuffer_shadow(Render *re, float winmat[4][4], LampRen *lar, int *rectz, int size, float jitx, float jity)
-{
- ZbufProjectCache cache[ZBUF_PROJECT_CACHE_SIZE];
- ZSpan zspan;
- ObjectInstanceRen *obi;
- ObjectRen *obr;
- VlakRen *vlr= NULL;
- Material *ma= NULL;
- StrandSegment sseg;
- StrandRen *strand= NULL;
- StrandVert *svert;
- StrandBound *sbound;
- float obwinmat[4][4], ho1[4], ho2[4], ho3[4], ho4[4];
- int a, b, c, i, c1, c2, c3, c4, ok=1, lay= -1;
-
- if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay;
-
- /* 1.0f for clipping in clippyra()... bad stuff actually */
- zbuf_alloc_span(&zspan, size, size, 1.0f);
- zspan.zmulx= ((float)size)/2.0f;
- zspan.zmuly= ((float)size)/2.0f;
- /* -0.5f to center the sample position */
- zspan.zofsx= jitx - 0.5f;
- zspan.zofsy= jity - 0.5f;
-
- /* the buffers */
- zspan.rectz= rectz;
- fillrect(rectz, size, size, 0x7FFFFFFE);
- if (lar->buftype==LA_SHADBUF_HALFWAY) {
- zspan.rectz1= MEM_mallocN(size*size*sizeof(int), "seconday z buffer");
- fillrect(zspan.rectz1, size, size, 0x7FFFFFFE);
- }
-
- /* filling methods */
- zspan.zbuflinefunc= zbufline_onlyZ;
- zspan.zbuffunc= zbuffillGL_onlyZ;
-
- for (i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) {
- obr= obi->obr;
-
- if (obr->ob==re->excludeob)
- continue;
- else if (!(obi->lay & lay))
- continue;
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, winmat, obi->mat);
- else
- copy_m4_m4(obwinmat, winmat);
-
- if (clip_render_object(obi->obr->boundbox, NULL, obwinmat))
- continue;
-
- zbuf_project_cache_clear(cache, obr->totvert);
-
- /* faces */
- for (a=0; a<obr->totvlak; a++) {
-
- if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
- else vlr++;
-
- /* note, these conditions are copied in shadowbuf_autoclip() */
- if (vlr->mat!= ma) {
- ma= vlr->mat;
- ok= 1;
- if ((ma->mode2 & MA_CASTSHADOW)==0 || (ma->mode & MA_SHADBUF)==0) ok= 0;
- }
-
- if (ok && (obi->lay & lay) && !(vlr->flag & R_HIDDEN)) {
- c1= zbuf_shadow_project(cache, vlr->v1->index, obwinmat, vlr->v1->co, ho1);
- c2= zbuf_shadow_project(cache, vlr->v2->index, obwinmat, vlr->v2->co, ho2);
- c3= zbuf_shadow_project(cache, vlr->v3->index, obwinmat, vlr->v3->co, ho3);
-
- if ((ma->material_type == MA_TYPE_WIRE) || (vlr->flag & R_STRAND)) {
- if (vlr->v4) {
- c4= zbuf_shadow_project(cache, vlr->v4->index, obwinmat, vlr->v4->co, ho4);
- zbufclipwire(&zspan, 0, a+1, vlr->ec, ho1, ho2, ho3, ho4, c1, c2, c3, c4);
- }
- else
- zbufclipwire(&zspan, 0, a+1, vlr->ec, ho1, ho2, ho3, NULL, c1, c2, c3, 0);
- }
- else {
- if (vlr->v4) {
- c4= zbuf_shadow_project(cache, vlr->v4->index, obwinmat, vlr->v4->co, ho4);
- zbufclip4(&zspan, 0, 0, ho1, ho2, ho3, ho4, c1, c2, c3, c4);
- }
- else
- zbufclip(&zspan, 0, 0, ho1, ho2, ho3, c1, c2, c3);
- }
- }
-
- if ((a & 255)==255 && re->test_break(re->tbh))
- break;
- }
-
- /* strands */
- if (obr->strandbuf) {
- /* for each bounding box containing a number of strands */
- sbound= obr->strandbuf->bound;
- for (c=0; c<obr->strandbuf->totbound; c++, sbound++) {
- if (clip_render_object(sbound->boundbox, NULL, obwinmat))
- continue;
-
- /* for each strand in this bounding box */
- for (a=sbound->start; a<sbound->end; a++) {
- strand= RE_findOrAddStrand(obr, a);
-
- sseg.obi= obi;
- sseg.buffer= strand->buffer;
- sseg.sqadaptcos= sseg.buffer->adaptcos;
- sseg.sqadaptcos *= sseg.sqadaptcos;
- sseg.strand= strand;
- svert= strand->vert;
-
- /* note, these conditions are copied in shadowbuf_autoclip() */
- if (sseg.buffer->ma!= ma) {
- ma= sseg.buffer->ma;
- ok= 1;
- if ((ma->mode2 & MA_CASTSHADOW)==0 || (ma->mode & MA_SHADBUF)==0) ok= 0;
- }
-
- if (ok && (sseg.buffer->lay & lay)) {
- zbuf_project_cache_clear(cache, strand->totvert);
-
- for (b=0; b<strand->totvert-1; b++, svert++) {
- sseg.v[0]= (b > 0)? (svert-1): svert;
- sseg.v[1]= svert;
- sseg.v[2]= svert+1;
- sseg.v[3]= (b < strand->totvert-2)? svert+2: svert+1;
-
- c1= zbuf_shadow_project(cache, sseg.v[0]-strand->vert, obwinmat, sseg.v[0]->co, ho1);
- c2= zbuf_shadow_project(cache, sseg.v[1]-strand->vert, obwinmat, sseg.v[1]->co, ho2);
- c3= zbuf_shadow_project(cache, sseg.v[2]-strand->vert, obwinmat, sseg.v[2]->co, ho3);
- c4= zbuf_shadow_project(cache, sseg.v[3]-strand->vert, obwinmat, sseg.v[3]->co, ho4);
-
- if (!(c1 & c2 & c3 & c4))
- render_strand_segment(re, winmat, NULL, &zspan, 1, &sseg);
- }
- }
-
- if ((a & 255)==255 && re->test_break(re->tbh))
- break;
- }
- }
- }
-
- if (re->test_break(re->tbh))
- break;
- }
-
- /* merge buffers */
- if (lar->buftype==LA_SHADBUF_HALFWAY) {
- for (a=size*size -1; a>=0; a--)
- rectz[a]= (rectz[a]>>1) + (zspan.rectz1[a]>>1);
-
- MEM_freeN(zspan.rectz1);
- }
-
- zbuf_free_span(&zspan);
-}
-
-static void zbuffill_sss(ZSpan *zspan, int obi, int zvlnr,
- const float *v1, const float *v2, const float *v3, const float *v4)
-{
- double zxd, zyd, zy0, z;
- float x0, y0, x1, y1, x2, y2, z0, z1, z2, xx1, *span1, *span2;
- int x, y, sn1, sn2, rectx= zspan->rectx, my0, my2;
- /* init */
- zbuf_init_span(zspan);
-
- /* set spans */
- zbuf_add_to_span(zspan, v1, v2);
- zbuf_add_to_span(zspan, v2, v3);
- if (v4) {
- zbuf_add_to_span(zspan, v3, v4);
- zbuf_add_to_span(zspan, v4, v1);
- }
- else
- zbuf_add_to_span(zspan, v3, v1);
-
- /* clipped */
- if (zspan->minp2==NULL || zspan->maxp2==NULL) return;
-
- my0 = max_ii(zspan->miny1, zspan->miny2);
- my2 = min_ii(zspan->maxy1, zspan->maxy2);
-
- if (my2<my0) return;
-
- /* ZBUF DX DY, in floats still */
- x1= v1[0]- v2[0];
- x2= v2[0]- v3[0];
- y1= v1[1]- v2[1];
- y2= v2[1]- v3[1];
- z1= v1[2]- v2[2];
- z2= v2[2]- v3[2];
-
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
- z0= x1*y2-y1*x2;
-
- if (z0==0.0f) return;
-
- xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
- zxd= -(double)x0/(double)z0;
- zyd= -(double)y0/(double)z0;
- zy0= ((double)my2)*zyd + (double)xx1;
-
- /* correct span */
- sn1= (my0 + my2)/2;
- if (zspan->span1[sn1] < zspan->span2[sn1]) {
- span1= zspan->span1+my2;
- span2= zspan->span2+my2;
- }
- else {
- span1= zspan->span2+my2;
- span2= zspan->span1+my2;
- }
-
- for (y=my2; y>=my0; y--, span1--, span2--) {
- sn1= floor(*span1);
- sn2= floor(*span2);
- sn1++;
-
- if (sn2>=rectx) sn2= rectx-1;
- if (sn1<0) sn1= 0;
-
- z= (double)sn1*zxd + zy0;
-
- for (x= sn1; x<=sn2; x++, z+=zxd)
- zspan->sss_func(zspan->sss_handle, obi, zvlnr, x, y, z);
-
- zy0 -= zyd;
- }
-}
-
-void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(void *, int, int, int, int, int))
-{
- ZbufProjectCache cache[ZBUF_PROJECT_CACHE_SIZE];
- ZSpan zspan;
- ObjectInstanceRen *obi;
- ObjectRen *obr;
- VlakRen *vlr= NULL;
- VertRen *v1, *v2, *v3, *v4;
- Material *ma = NULL, *sss_ma = R.sss_mat;
- float obwinmat[4][4], winmat[4][4], bounds[4];
- float ho1[4], ho2[4], ho3[4], ho4[4]={0};
- int i, v, zvlnr, c1, c2, c3, c4=0;
- short nofill=0, env=0, wire=0;
-
- zbuf_make_winmat(&R, winmat);
- zbuffer_part_bounds(R.winx, R.winy, pa, bounds);
- zbuf_alloc_span(&zspan, pa->rectx, pa->recty, R.clipcrop);
-
- zspan.sss_handle= handle;
- zspan.sss_func= func;
-
- /* needed for transform from hoco to zbuffer co */
- zspan.zmulx= ((float)R.winx)/2.0f;
- zspan.zmuly= ((float)R.winy)/2.0f;
-
- /* -0.5f to center the sample position */
- zspan.zofsx= -pa->disprect.xmin - 0.5f;
- zspan.zofsy= -pa->disprect.ymin - 0.5f;
-
- /* filling methods */
- zspan.zbuffunc= zbuffill_sss;
-
- /* fill front and back zbuffer */
- if (pa->rectz) {
- fillrect(pa->recto, pa->rectx, pa->recty, 0);
- fillrect(pa->rectp, pa->rectx, pa->recty, 0);
- fillrect(pa->rectz, pa->rectx, pa->recty, 0x7FFFFFFF);
- }
- if (pa->rectbackz) {
- fillrect(pa->rectbacko, pa->rectx, pa->recty, 0);
- fillrect(pa->rectbackp, pa->rectx, pa->recty, 0);
- fillrect(pa->rectbackz, pa->rectx, pa->recty, -0x7FFFFFFF);
- }
-
- for (i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) {
- obr= obi->obr;
-
- if (!(obi->lay & lay))
- continue;
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, winmat, obi->mat);
- else
- copy_m4_m4(obwinmat, winmat);
-
- if (clip_render_object(obi->obr->boundbox, bounds, obwinmat))
- continue;
-
- zbuf_project_cache_clear(cache, obr->totvert);
-
- for (v=0; v<obr->totvlak; v++) {
- if ((v & 255)==0) vlr= obr->vlaknodes[v>>8].vlak;
- else vlr++;
-
- if (material_in_material(vlr->mat, sss_ma)) {
- /* three cases, visible for render, only z values and nothing */
- if (obi->lay & lay) {
- if (vlr->mat!=ma) {
- ma= vlr->mat;
- nofill= ma->mode & MA_ONLYCAST;
- env= (ma->mode & MA_ENV);
- wire= (ma->material_type == MA_TYPE_WIRE);
- }
- }
- else {
- nofill= 1;
- ma= NULL; /* otherwise nofill can hang */
- }
-
- if (nofill==0 && wire==0 && env==0) {
- unsigned short partclip;
-
- v1= vlr->v1;
- v2= vlr->v2;
- v3= vlr->v3;
- v4= vlr->v4;
-
- c1= zbuf_part_project(cache, v1->index, obwinmat, bounds, v1->co, ho1);
- c2= zbuf_part_project(cache, v2->index, obwinmat, bounds, v2->co, ho2);
- c3= zbuf_part_project(cache, v3->index, obwinmat, bounds, v3->co, ho3);
-
- /* partclipping doesn't need viewplane clipping */
- partclip= c1 & c2 & c3;
- if (v4) {
- c4= zbuf_part_project(cache, v4->index, obwinmat, bounds, v4->co, ho4);
- partclip &= c4;
- }
-
- if (partclip==0) {
- c1= testclip(ho1);
- c2= testclip(ho2);
- c3= testclip(ho3);
-
- zvlnr= v+1;
- zbufclip(&zspan, i, zvlnr, ho1, ho2, ho3, c1, c2, c3);
- if (v4) {
- c4= testclip(ho4);
- zbufclip(&zspan, i, zvlnr+RE_QUAD_OFFS, ho1, ho3, ho4, c1, c3, c4);
- }
- }
- }
- }
- }
- }
-
- zbuf_free_span(&zspan);
-}
-
-/* ******************** ABUF ************************* */
-
-/**
- * Copy results from the solid face z buffering to the transparent
- * buffer.
- */
-static void copyto_abufz(RenderPart *pa, int *arectz, int *rectmask, int sample)
-{
- PixStr *ps;
- int x, y, *rza, *rma;
- intptr_t *rd;
-
- if (R.osa==0) {
- if (!pa->rectz)
- fillrect(arectz, pa->rectx, pa->recty, 0x7FFFFFFE);
- else
- memcpy(arectz, pa->rectz, sizeof(int)*pa->rectx*pa->recty);
-
- if (rectmask && pa->rectmask)
- memcpy(rectmask, pa->rectmask, sizeof(int)*pa->rectx*pa->recty);
-
- return;
- }
- else if (!pa->rectdaps) {
- fillrect(arectz, pa->rectx, pa->recty, 0x7FFFFFFE);
- return;
- }
-
- rza= arectz;
- rma= rectmask;
- rd= pa->rectdaps;
-
- sample= (1<<sample);
-
- for (y=0; y<pa->recty; y++) {
- for (x=0; x<pa->rectx; x++) {
-
- *rza= 0x7FFFFFFF;
- if (rectmask) *rma= 0x7FFFFFFF;
- if (*rd) {
- /* when there's a sky pixstruct, fill in sky-Z, otherwise solid Z */
- for (ps= (PixStr *)(*rd); ps; ps= ps->next) {
- if (sample & ps->mask) {
- *rza= ps->z;
- if (rectmask) *rma= ps->maskz;
- break;
- }
- }
- }
-
- rza++;
- rma++;
- rd++;
- }
- }
-}
-
-
-/* ------------------------------------------------------------------------ */
-
-/**
- * Do accumulation z buffering.
- */
-
-static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, unsigned int lay, int negzmask, float winmat[4][4], int winx, int winy, int samples, float (*jit)[2], float UNUSED(clipcrop), int shadow)
-{
- ZbufProjectCache cache[ZBUF_PROJECT_CACHE_SIZE];
- ZSpan zspans[16], *zspan; /* MAX_OSA */
- Material *ma=NULL;
- ObjectInstanceRen *obi;
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- VertRen *v1, *v2, *v3, *v4;
- float vec[3], hoco[4], mul, zval, fval;
- float obwinmat[4][4], bounds[4], ho1[4], ho2[4], ho3[4], ho4[4]={0};
- int i, v, zvlnr, c1, c2, c3, c4=0, dofill= 0;
- int zsample, polygon_offset;
-
- zbuffer_part_bounds(winx, winy, pa, bounds);
-
- for (zsample=0; zsample<samples; zsample++) {
- zspan= &zspans[zsample];
-
- zbuf_alloc_span(zspan, pa->rectx, pa->recty, re->clipcrop);
-
- /* needed for transform from hoco to zbuffer co */
- zspan->zmulx= ((float)winx)/2.0f;
- zspan->zmuly= ((float)winy)/2.0f;
-
- /* the buffers */
- zspan->arectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "Arectz");
- zspan->apixbuf= APixbuf;
- zspan->apsmbase= apsmbase;
-
- if (negzmask)
- zspan->rectmask= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "Arectmask");
-
- /* filling methods */
- zspan->zbuffunc= zbuffillAc4;
- zspan->zbuflinefunc= zbuflineAc;
-
- copyto_abufz(pa, zspan->arectz, zspan->rectmask, zsample); /* init zbuffer */
- zspan->mask= 1<<zsample;
-
- if (jit) {
- zspan->zofsx= -pa->disprect.xmin - jit[zsample][0];
- zspan->zofsy= -pa->disprect.ymin - jit[zsample][1];
- }
- else {
- zspan->zofsx= -pa->disprect.xmin;
- zspan->zofsy= -pa->disprect.ymin;
- }
-
- /* to center the sample position */
- zspan->zofsx -= 0.5f;
- zspan->zofsy -= 0.5f;
- }
-
- /* we use this to test if nothing was filled in */
- zvlnr= 0;
-
- for (i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) {
- obr= obi->obr;
-
- if (!(obi->lay & lay))
- continue;
-
- if (obi->flag & R_TRANSFORMED)
- mul_m4_m4m4(obwinmat, winmat, obi->mat);
- else
- copy_m4_m4(obwinmat, winmat);
-
- if (clip_render_object(obi->obr->boundbox, bounds, obwinmat))
- continue;
-
- zbuf_project_cache_clear(cache, obr->totvert);
-
- for (v=0; v<obr->totvlak; v++) {
- if ((v & 255)==0)
- vlr= obr->vlaknodes[v>>8].vlak;
- else vlr++;
-
- if (vlr->mat!=ma) {
- ma= vlr->mat;
- if (shadow)
- dofill= (ma->mode2 & MA_CASTSHADOW) && (ma->mode & MA_SHADBUF);
- else
- dofill= (((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) && !(ma->mode & MA_ONLYCAST));
- }
-
- if (dofill) {
- if (!(vlr->flag & R_HIDDEN) && (obi->lay & lay)) {
- unsigned short partclip;
-
- v1= vlr->v1;
- v2= vlr->v2;
- v3= vlr->v3;
- v4= vlr->v4;
-
- c1= zbuf_part_project(cache, v1->index, obwinmat, bounds, v1->co, ho1);
- c2= zbuf_part_project(cache, v2->index, obwinmat, bounds, v2->co, ho2);
- c3= zbuf_part_project(cache, v3->index, obwinmat, bounds, v3->co, ho3);
-
- /* partclipping doesn't need viewplane clipping */
- partclip= c1 & c2 & c3;
- if (v4) {
- c4= zbuf_part_project(cache, v4->index, obwinmat, bounds, v4->co, ho4);
- partclip &= c4;
- }
-
- if (partclip==0) {
- /* a little advantage for transp rendering (a z offset) */
- if (!shadow && ma->zoffs != 0.0f) {
- mul= 0x7FFFFFFF;
- zval= mul*(1.0f+ho1[2]/ho1[3]);
-
- copy_v3_v3(vec, v1->co);
- /* z is negative, otherwise its being clipped */
- vec[2]-= ma->zoffs;
- projectverto(vec, obwinmat, hoco);
- fval= mul*(1.0f+hoco[2]/hoco[3]);
-
- polygon_offset= (int)fabsf(zval - fval);
- }
- else polygon_offset= 0;
-
- zvlnr= v+1;
-
- c1= testclip(ho1);
- c2= testclip(ho2);
- c3= testclip(ho3);
- if (v4)
- c4= testclip(ho4);
-
- for (zsample=0; zsample<samples; zsample++) {
- zspan= &zspans[zsample];
- zspan->polygon_offset= polygon_offset;
-
- if (ma->material_type == MA_TYPE_WIRE) {
- if (v4)
- zbufclipwire(zspan, i, zvlnr, vlr->ec, ho1, ho2, ho3, ho4, c1, c2, c3, c4);
- else
- zbufclipwire(zspan, i, zvlnr, vlr->ec, ho1, ho2, ho3, NULL, c1, c2, c3, 0);
- }
- else {
- if (v4 && (vlr->flag & R_STRAND)) {
- zbufclip4(zspan, i, zvlnr, ho1, ho2, ho3, ho4, c1, c2, c3, c4);
- }
- else {
- zbufclip(zspan, i, zvlnr, ho1, ho2, ho3, c1, c2, c3);
- if (v4)
- zbufclip(zspan, i, zvlnr+RE_QUAD_OFFS, ho1, ho3, ho4, c1, c3, c4);
- }
- }
- }
- }
- if ((v & 255)==255)
- if (re->test_break(re->tbh))
- break;
- }
- }
- }
-
- if (re->test_break(re->tbh)) break;
- }
-
- for (zsample=0; zsample<samples; zsample++) {
- zspan= &zspans[zsample];
- MEM_freeN(zspan->arectz);
- if (zspan->rectmask)
- MEM_freeN(zspan->rectmask);
- zbuf_free_span(zspan);
- }
-
- return zvlnr;
-}
-
-static int zbuffer_abuf_render(RenderPart *pa, APixstr *APixbuf, APixstrand *APixbufstrand, ListBase *apsmbase, RenderLayer *rl, StrandShadeCache *sscache)
-{
- float winmat[4][4], (*jit)[2];
- int samples, negzmask, doztra= 0;
-
- samples= (R.osa)? R.osa: 1;
- negzmask= ((rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK));
-
- if (R.osa)
- jit= R.jit;
- else if (R.i.curblur)
- jit= &R.mblur_jit[R.i.curblur-1];
- else
- jit= NULL;
-
- zbuf_make_winmat(&R, winmat);
-
- if (rl->layflag & SCE_LAY_ZTRA)
- doztra+= zbuffer_abuf(&R, pa, APixbuf, apsmbase, (1 << 20) - 1, negzmask, winmat, R.winx, R.winy, samples, jit, R.clipcrop, 0);
- if ((rl->layflag & SCE_LAY_STRAND) && APixbufstrand)
- doztra+= zbuffer_strands_abuf(&R, pa, APixbufstrand, apsmbase, (1 << 20) - 1, negzmask, winmat, R.winx, R.winy, samples, jit, R.clipcrop, 0, sscache);
-
- return doztra;
-}
-
-void zbuffer_abuf_shadow(Render *re, LampRen *lar, float winmat[4][4], APixstr *APixbuf, APixstrand *APixbufstrand, ListBase *apsmbase, int size, int samples, float (*jit)[2])
-{
- RenderPart pa;
- int lay= -1;
-
- if (lar->mode & LA_LAYER) lay= lar->lay;
-
- memset(&pa, 0, sizeof(RenderPart));
- pa.rectx= size;
- pa.recty= size;
- pa.disprect.xmin = 0;
- pa.disprect.ymin = 0;
- pa.disprect.xmax = size;
- pa.disprect.ymax = size;
-
- zbuffer_abuf(re, &pa, APixbuf, apsmbase, lay, 0, winmat, size, size, samples, jit, 1.0f, 1);
- if (APixbufstrand)
- zbuffer_strands_abuf(re, &pa, APixbufstrand, apsmbase, lay, 0, winmat, size, size, samples, jit, 1.0f, 1, NULL);
-}
-
-/* different rules for speed in transparent pass... */
-/* speed pointer NULL = sky, we clear */
-/* else if either alpha is full or no solid was filled in: copy speed */
-/* else fill in minimum speed */
-static void add_transp_speed(RenderLayer *rl, int offset, float speed[4], float alpha, intptr_t *rdrect)
-{
- RenderPass *rpass;
-
- for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- if (STREQ(rpass->name, RE_PASSNAME_VECTOR)) {
- float *fp= rpass->rect + 4*offset;
-
- if (speed==NULL) {
- /* clear */
- if (fp[0]==PASS_VECTOR_MAX) fp[0]= 0.0f;
- if (fp[1]==PASS_VECTOR_MAX) fp[1]= 0.0f;
- if (fp[2]==PASS_VECTOR_MAX) fp[2]= 0.0f;
- if (fp[3]==PASS_VECTOR_MAX) fp[3]= 0.0f;
- }
- else if (rdrect==NULL || rdrect[offset]==0 || alpha>0.95f) {
- copy_v4_v4(fp, speed);
- }
- else {
- /* add minimum speed in pixel */
- if ( (ABS(speed[0]) + ABS(speed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) {
- fp[0]= speed[0];
- fp[1]= speed[1];
- }
- if ( (ABS(speed[2]) + ABS(speed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) {
- fp[2]= speed[2];
- fp[3]= speed[3];
- }
- }
- break;
- }
- }
-}
-
-static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob)
-{
- RenderPass *rpass;
-
- for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- if (STREQ(rpass->name, RE_PASSNAME_INDEXOB)) {
- float *fp= rpass->rect + offset;
- *fp= (float)ob->index;
- break;
- }
- }
-}
-
-static void add_transp_material_index(RenderLayer *rl, int offset, Material *mat)
-{
- RenderPass *rpass;
-
- for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- if (STREQ(rpass->name, RE_PASSNAME_INDEXMA)) {
- float *fp= rpass->rect + offset;
- *fp= (float)mat->index;
- break;
- }
- }
-}
-
-/* ONLY OSA! merge all shaderesult samples to one */
-/* target should have been cleared */
-static void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
-{
- RenderPass *rpass;
- float weight= 1.0f/((float)R.osa);
- int delta= sizeof(ShadeResult)/4;
-
- for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- float *col = NULL;
- int pixsize = 3;
-
- if (STREQ(rpass->name, RE_PASSNAME_RGBA)) {
- col = shr->col;
- pixsize = 4;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_EMIT)) {
- col = shr->emit;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_DIFFUSE)) {
- col = shr->diff;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_SPEC)) {
- col = shr->spec;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_SHADOW)) {
- col = shr->shad;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_AO)) {
- col = shr->ao;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_ENVIRONMENT)) {
- col = shr->env;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_INDIRECT)) {
- col = shr->indirect;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_REFLECT)) {
- col = shr->refl;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_REFRACT)) {
- col = shr->refr;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_NORMAL)) {
- col = shr->nor;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_MIST)) {
- col = &shr->mist;
- pixsize = 1;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_Z)) {
- col = &shr->z;
- pixsize = 1;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_VECTOR)) {
- ShadeResult *shr_t = shr+1;
- float *fp = shr->winspeed; /* was initialized */
- int samp;
-
- /* add minimum speed in pixel */
- for (samp = 1; samp<R.osa; samp++, shr_t++) {
-
- if (shr_t->combined[3] > 0.0f) {
- const float *speed = shr_t->winspeed;
-
- if ( (ABS(speed[0]) + ABS(speed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) {
- fp[0] = speed[0];
- fp[1] = speed[1];
- }
- if ( (ABS(speed[2]) + ABS(speed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) {
- fp[2] = speed[2];
- fp[3] = speed[3];
- }
- }
- }
- }
-
- if (col) {
- const float *fp= col+delta;
- int samp;
-
- for (samp= 1; samp<R.osa; samp++, fp+=delta) {
- col[0]+= fp[0];
- if (pixsize>1) {
- col[1]+= fp[1];
- col[2]+= fp[2];
- if (pixsize==4) col[3]+= fp[3];
- }
- }
- col[0]*= weight;
- if (pixsize>1) {
- col[1]*= weight;
- col[2]*= weight;
- if (pixsize==4) col[3]*= weight;
- }
- }
- }
-
-}
-
-static void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alpha)
-{
- RenderPass *rpass;
-
- for (rpass= rl->passes.first; rpass; rpass= rpass->next) {
- float *fp, *col= NULL;
- int pixsize= 3;
-
- if (STREQ(rpass->name, RE_PASSNAME_Z)) {
- fp = rpass->rect + offset;
- if (shr->z < *fp)
- *fp = shr->z;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_RGBA)) {
- fp = rpass->rect + 4*offset;
- addAlphaOverFloat(fp, shr->col);
- }
- else if (STREQ(rpass->name, RE_PASSNAME_EMIT)) {
- col = shr->emit;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_DIFFUSE)) {
- col = shr->diff;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_SPEC)) {
- col = shr->spec;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_SHADOW)) {
- col = shr->shad;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_AO)) {
- col = shr->ao;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_ENVIRONMENT)) {
- col = shr->env;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_INDIRECT)) {
- col = shr->indirect;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_REFLECT)) {
- col = shr->refl;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_REFRACT)) {
- col = shr->refr;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_NORMAL)) {
- col = shr->nor;
- }
- else if (STREQ(rpass->name, RE_PASSNAME_MIST)) {
- col = &shr->mist;
- pixsize = 1;
- }
-
- if (col) {
- fp= rpass->rect + pixsize*offset;
- fp[0]= col[0] + (1.0f-alpha)*fp[0];
- if (pixsize==3) {
- fp[1]= col[1] + (1.0f-alpha)*fp[1];
- fp[2]= col[2] + (1.0f-alpha)*fp[2];
- }
- }
- }
-}
-
-typedef struct ZTranspRow {
- int obi;
- int z;
- int p;
- int mask;
- int segment;
- float u, v;
-} ZTranspRow;
-
-static int vergzvlak(const void *a1, const void *a2)
-{
- const ZTranspRow *r1 = a1, *r2 = a2;
-
- if (r1->z < r2->z) return 1;
- else if (r1->z > r2->z) return -1;
- return 0;
-}
-
-static void shade_strand_samples(StrandShadeCache *cache, ShadeSample *ssamp, int UNUSED(x), int UNUSED(y), ZTranspRow *row, int addpassflag)
-{
- StrandSegment sseg;
- StrandVert *svert;
- ObjectInstanceRen *obi;
- ObjectRen *obr;
-
- obi= R.objectinstance + row->obi;
- obr= obi->obr;
-
- sseg.obi= obi;
- sseg.strand= RE_findOrAddStrand(obr, row->p-1);
- sseg.buffer= sseg.strand->buffer;
-
- svert= sseg.strand->vert + row->segment;
- sseg.v[0]= (row->segment > 0)? (svert-1): svert;
- sseg.v[1]= svert;
- sseg.v[2]= svert+1;
- sseg.v[3]= (row->segment < sseg.strand->totvert-2)? svert+2: svert+1;
-
- ssamp->tot= 1;
- strand_shade_segment(&R, cache, &sseg, ssamp, row->v, row->u, addpassflag);
- ssamp->shi[0].mask= row->mask;
-}
-
-static void unref_strand_samples(StrandShadeCache *cache, ZTranspRow *row, int totface)
-{
- StrandVert *svert;
- ObjectInstanceRen *obi;
- ObjectRen *obr;
- StrandRen *strand;
-
- /* remove references to samples that are not being rendered, but we still
- * need to remove them so that the reference count of strand vertex shade
- * samples correctly drops to zero */
- while (totface > 0) {
- totface--;
-
- if (row[totface].segment != -1) {
- obi= R.objectinstance + row[totface].obi;
- obr= obi->obr;
- strand= RE_findOrAddStrand(obr, row[totface].p-1);
- svert= strand->vert + row[totface].segment;
-
- strand_shade_unref(cache, obi, svert);
- strand_shade_unref(cache, obi, svert+1);
- }
- }
-}
-
-static void shade_tra_samples_fill(ShadeSample *ssamp, int x, int y, int z, int obi, int facenr, int curmask)
-{
- ShadeInput *shi= ssamp->shi;
- float xs, ys;
-
- ssamp->tot= 0;
-
- shade_input_set_triangle(shi, obi, facenr, 1);
-
- /* officially should always be true... we have no sky info */
- if (shi->vlr) {
-
- /* full osa is only set for OSA renders */
- if (shi->vlr->flag & R_FULL_OSA) {
- short shi_inc= 0, samp;
-
- for (samp=0; samp<R.osa; samp++) {
- if (curmask & (1<<samp)) {
- xs= (float)x + R.jit[samp][0] + 0.5f; /* zbuffer has this inverse corrected, ensures (xs, ys) are inside pixel */
- ys= (float)y + R.jit[samp][1] + 0.5f;
-
- if (shi_inc) {
- shade_input_copy_triangle(shi+1, shi);
- shi++;
- }
- shi->mask= (1<<samp);
- shi->samplenr= R.shadowsamplenr[shi->thread]++;
- shade_input_set_viewco(shi, x, y, xs, ys, (float)z);
- shade_input_set_uv(shi);
- if (shi_inc==0)
- shade_input_set_normals(shi);
- else /* XXX shi->flippednor messes up otherwise */
- shade_input_set_vertex_normals(shi);
-
- shi_inc= 1;
- }
- }
- }
- else {
- if (R.osa) {
- short b= R.samples->centmask[curmask];
- xs= (float)x + R.samples->centLut[b & 15] + 0.5f;
- ys= (float)y + R.samples->centLut[b>>4] + 0.5f;
- }
- else if (R.i.curblur) {
- xs= (float)x + R.mblur_jit[R.i.curblur-1][0] + 0.5f;
- ys= (float)y + R.mblur_jit[R.i.curblur-1][1] + 0.5f;
- }
- else {
- xs= (float)x + 0.5f;
- ys= (float)y + 0.5f;
- }
- shi->mask= curmask;
- shi->samplenr= R.shadowsamplenr[shi->thread]++;
- shade_input_set_viewco(shi, x, y, xs, ys, (float)z);
- shade_input_set_uv(shi);
- shade_input_set_normals(shi);
- }
-
- /* total sample amount, shi->sample is static set in initialize */
- ssamp->tot= shi->sample+1;
- }
-}
-
-static int shade_tra_samples(ShadeSample *ssamp, StrandShadeCache *cache, int x, int y, ZTranspRow *row, int addpassflag)
-{
- if (row->segment != -1) {
- shade_strand_samples(cache, ssamp, x, y, row, addpassflag);
- return 1;
- }
-
- shade_tra_samples_fill(ssamp, x, y, row->z, row->obi, row->p, row->mask);
-
- if (ssamp->tot) {
- ShadeInput *shi= ssamp->shi;
- ShadeResult *shr= ssamp->shr;
- int samp;
-
- /* if AO? */
- shade_samples_do_AO(ssamp);
-
- /* if shade (all shadepinputs have same passflag) */
- if (shi->passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB|SCE_PASS_INDEXMA)) {
- for (samp=0; samp<ssamp->tot; samp++, shi++, shr++) {
- shade_input_set_shade_texco(shi);
- shade_input_do_shade(shi, shr);
-
- /* include lamphalos for ztra, since halo layer was added already */
- if (R.flag & R_LAMPHALO)
- if (shi->layflag & SCE_LAY_HALO)
- renderspothalo(shi, shr->combined, shr->combined[3]);
- }
- }
- else if (shi->passflag & SCE_PASS_Z) {
- for (samp=0; samp<ssamp->tot; samp++, shi++, shr++)
- shr->z= -shi->co[2];
- }
-
- return 1;
- }
- return 0;
-}
-
-static int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassflag)
-{
- int a, sample, osa = (R.osa? R.osa: 1), retval = osa;
-
- for (a=0; a < osa; a++, samp_shr++) {
- ShadeInput *shi= ssamp->shi;
- ShadeResult *shr= ssamp->shr;
-
- for (sample=0; sample<ssamp->tot; sample++, shi++, shr++) {
-
- if (shi->mask & (1<<a)) {
- float fac= (1.0f - samp_shr->combined[3])*shr->combined[3];
-
- addAlphaUnderFloat(samp_shr->combined, shr->combined);
-
- samp_shr->z = min_ff(samp_shr->z, shr->z);
-
- if (addpassflag & SCE_PASS_VECTOR) {
- copy_v4_v4(samp_shr->winspeed, shr->winspeed);
- }
- /* optim... */
- if (addpassflag & ~(SCE_PASS_VECTOR)) {
-
- if (addpassflag & SCE_PASS_RGBA)
- addAlphaUnderFloat(samp_shr->col, shr->col);
-
- if (addpassflag & SCE_PASS_NORMAL)
- madd_v3_v3fl(samp_shr->nor, shr->nor, fac);
-
- if (addpassflag & SCE_PASS_EMIT)
- madd_v3_v3fl(samp_shr->emit, shr->emit, fac);
-
- if (addpassflag & SCE_PASS_DIFFUSE)
- madd_v3_v3fl(samp_shr->diff, shr->diff, fac);
-
- if (addpassflag & SCE_PASS_SPEC)
- madd_v3_v3fl(samp_shr->spec, shr->spec, fac);
-
- if (addpassflag & SCE_PASS_SHADOW)
- madd_v3_v3fl(samp_shr->shad, shr->shad, fac);
-
- if (addpassflag & SCE_PASS_AO)
- madd_v3_v3fl(samp_shr->ao, shr->ao, fac);
-
- if (addpassflag & SCE_PASS_ENVIRONMENT)
- madd_v3_v3fl(samp_shr->env, shr->env, fac);
-
- if (addpassflag & SCE_PASS_INDIRECT)
- madd_v3_v3fl(samp_shr->indirect, shr->indirect, fac);
-
- if (addpassflag & SCE_PASS_REFLECT)
- madd_v3_v3fl(samp_shr->refl, shr->refl, fac);
-
- if (addpassflag & SCE_PASS_REFRACT)
- madd_v3_v3fl(samp_shr->refr, shr->refr, fac);
-
- if (addpassflag & SCE_PASS_MIST)
- samp_shr->mist= samp_shr->mist+fac*shr->mist;
-
- }
- }
- }
-
- if (samp_shr->combined[3]>0.999f) retval--;
- }
- return retval;
-}
-
-static void reset_sky_speedvectors(RenderPart *pa, RenderLayer *rl, float *rectf)
-{
- /* speed vector exception... if solid render was done, sky pixels are set to zero already */
- /* for all pixels with alpha zero, we re-initialize speed again then */
- float *fp, *col;
- int a;
-
- fp = RE_RenderLayerGetPass(rl, RE_PASSNAME_VECTOR, R.viewname);
- if (fp==NULL) return;
- col= rectf+3;
-
- for (a= 4*pa->rectx*pa->recty -4; a>=0; a-=4) {
- if (col[a]==0.0f) {
- fp[a]= PASS_VECTOR_MAX;
- fp[a+1]= PASS_VECTOR_MAX;
- fp[a+2]= PASS_VECTOR_MAX;
- fp[a+3]= PASS_VECTOR_MAX;
- }
- }
-}
-
-#define MAX_ZROW 2000
-
-/* main render call to do the z-transparent layer */
-/* returns a mask, only if a) transp rendered and b) solid was rendered */
-unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pass, ListBase *UNUSED(psmlist))
-{
- RenderResult *rr= pa->result;
- ShadeSample ssamp;
- APixstr *APixbuf; /* Zbuffer: linked list of face samples */
- APixstrand *APixbufstrand = NULL;
- APixstr *ap, *aprect, *apn;
- APixstrand *apstrand, *aprectstrand, *apnstrand;
- ListBase apsmbase={NULL, NULL};
- ShadeResult samp_shr[16]; /* MAX_OSA */
- ZTranspRow zrow[MAX_ZROW];
- StrandShadeCache *sscache= NULL;
- RenderLayer *rlpp[RE_MAX_OSA];
- float sampalpha, alpha, *passrect= pass;
- intptr_t *rdrect;
- int x, y, crop=0, a, b, totface, totfullsample, totsample, doztra;
- int addpassflag, offs= 0, od, osa = (R.osa? R.osa: 1);
- unsigned short *ztramask= NULL, filled;
-
- /* looks nicer for calling code */
- if (R.test_break(R.tbh))
- return NULL;
-
- if (R.osa > 16) { /* MAX_OSA */
- printf("zbuffer_transp_shade: osa too large\n");
- G.is_break = true;
- return NULL;
- }
-
- APixbuf= MEM_callocN(pa->rectx*pa->recty*sizeof(APixstr), "APixbuf");
- if (R.totstrand && (rl->layflag & SCE_LAY_STRAND)) {
- APixbufstrand= MEM_callocN(pa->rectx*pa->recty*sizeof(APixstrand), "APixbufstrand");
- sscache= strand_shade_cache_create();
- }
-
- /* general shader info, passes */
- shade_sample_initialize(&ssamp, pa, rl);
- addpassflag= rl->passflag & ~(SCE_PASS_COMBINED);
-
- if (R.osa)
- sampalpha= 1.0f/(float)R.osa;
- else
- sampalpha= 1.0f;
-
- /* fill the Apixbuf */
- doztra= zbuffer_abuf_render(pa, APixbuf, APixbufstrand, &apsmbase, rl, sscache);
-
- if (doztra == 0) {
- /* nothing filled in */
- MEM_freeN(APixbuf);
- if (APixbufstrand)
- MEM_freeN(APixbufstrand);
- if (sscache)
- strand_shade_cache_free(sscache);
- freepsA(&apsmbase);
- return NULL;
- }
-
- aprect= APixbuf;
- aprectstrand= APixbufstrand;
- rdrect= pa->rectdaps;
-
- /* needed for correct zbuf/index pass */
- totfullsample= get_sample_layers(pa, rl, rlpp);
-
- /* irregular shadowb buffer creation */
- if (R.r.mode & R_SHADOW)
- ISB_create(pa, APixbuf);
-
- /* masks, to have correct alpha combine */
- if (R.osa && (rl->layflag & SCE_LAY_SOLID) && pa->fullresult.first==NULL)
- ztramask= MEM_callocN(pa->rectx*pa->recty*sizeof(short), "ztramask");
-
- /* zero alpha pixels get speed vector max again */
- if (addpassflag & SCE_PASS_VECTOR)
- if (rl->layflag & SCE_LAY_SOLID) {
- float *rect = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, R.viewname);
- reset_sky_speedvectors(pa, rl, rl->acolrect ? rl->acolrect : rect); /* if acolrect is set we use it */
- }
- /* filtered render, for now we assume only 1 filter size */
- if (pa->crop) {
- crop= 1;
- offs= pa->rectx + 1;
- passrect+= 4*offs;
- aprect+= offs;
- aprectstrand+= offs;
- }
-
- /* init scanline updates */
- rr->renrect.ymin = 0;
- rr->renrect.ymax = -pa->crop;
- rr->renlay= rl;
-
- /* render the tile */
- for (y=pa->disprect.ymin+crop; y<pa->disprect.ymax-crop; y++, rr->renrect.ymax++) {
- pass= passrect;
- ap= aprect;
- apstrand= aprectstrand;
- od= offs;
-
- if (R.test_break(R.tbh))
- break;
-
- for (x=pa->disprect.xmin+crop; x<pa->disprect.xmax-crop; x++, ap++, apstrand++, pass+=4, od++) {
-
- if (ap->p[0]==0 && (!APixbufstrand || apstrand->p[0]==0)) {
- if (addpassflag & SCE_PASS_VECTOR)
- add_transp_speed(rl, od, NULL, 0.0f, rdrect);
- }
- else {
- /* sort in z */
- totface= 0;
- apn= ap;
- while (apn) {
- for (a=0; a<4; a++) {
- if (apn->p[a]) {
- zrow[totface].obi= apn->obi[a];
- zrow[totface].z= apn->z[a];
- zrow[totface].p= apn->p[a];
- zrow[totface].mask= apn->mask[a];
- zrow[totface].segment= -1;
- totface++;
- if (totface>=MAX_ZROW) totface= MAX_ZROW-1;
- }
- else break;
- }
- apn= apn->next;
- }
-
- apnstrand= (APixbufstrand)? apstrand: NULL;
- while (apnstrand) {
- for (a=0; a<4; a++) {
- if (apnstrand->p[a]) {
- zrow[totface].obi= apnstrand->obi[a];
- zrow[totface].z= apnstrand->z[a];
- zrow[totface].p= apnstrand->p[a];
- zrow[totface].mask= apnstrand->mask[a];
- zrow[totface].segment= apnstrand->seg[a];
-
- if (R.osa) {
- totsample= 0;
- for (b=0; b<R.osa; b++)
- if (zrow[totface].mask & (1<<b))
- totsample++;
- }
- else
- totsample= 1;
-
- zrow[totface].u= apnstrand->u[a]/totsample;
- zrow[totface].v= apnstrand->v[a]/totsample;
- totface++;
- if (totface>=MAX_ZROW) totface= MAX_ZROW-1;
- }
- }
- apnstrand= apnstrand->next;
- }
-
- if (totface==2) {
- if (zrow[0].z < zrow[1].z) {
- SWAP(ZTranspRow, zrow[0], zrow[1]);
- }
-
- }
- else if (totface>2) {
- qsort(zrow, totface, sizeof(ZTranspRow), vergzvlak);
- }
-
- /* front face does index pass for transparent, no AA or filters, but yes FSA */
- if (addpassflag & SCE_PASS_INDEXOB) {
- ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr;
- if (obr->ob) {
- for (a= 0; a<totfullsample; a++)
- add_transp_obindex(rlpp[a], od, obr->ob);
- }
- }
- if (addpassflag & SCE_PASS_INDEXMA) {
- ObjectRen *obr = R.objectinstance[zrow[totface-1].obi].obr;
- int p = zrow[totface-1].p;
- Material *mat = NULL;
-
- if (zrow[totface-1].segment == -1) {
- int facenr = (p - 1) & RE_QUAD_MASK;
- VlakRen *vlr = NULL;
-
- if (facenr >= 0 && facenr < obr->totvlak)
- vlr = RE_findOrAddVlak(obr, facenr);
-
- if (vlr)
- mat = vlr->mat;
- }
- else {
- StrandRen *strand = RE_findOrAddStrand(obr, p - 1);
-
- if (strand)
- mat = strand->buffer->ma;
- }
-
- if (mat) {
- for (a= 0; a<totfullsample; a++)
- add_transp_material_index(rlpp[a], od, mat);
- }
- }
-
- /* for each mask-sample we alpha-under colors. then in end it's added using filter */
- memset(samp_shr, 0, sizeof(ShadeResult)*osa);
- for (a=0; a<osa; a++) {
- samp_shr[a].z= 10e10f;
- if (addpassflag & SCE_PASS_VECTOR) {
- samp_shr[a].winspeed[0]= PASS_VECTOR_MAX;
- samp_shr[a].winspeed[1]= PASS_VECTOR_MAX;
- samp_shr[a].winspeed[2]= PASS_VECTOR_MAX;
- samp_shr[a].winspeed[3]= PASS_VECTOR_MAX;
- }
- }
-
- if (R.osa==0) {
- while (totface>0) {
- totface--;
-
- if (shade_tra_samples(&ssamp, sscache, x, y, &zrow[totface], addpassflag)) {
- filled= addtosamp_shr(samp_shr, &ssamp, addpassflag);
- addAlphaUnderFloat(pass, ssamp.shr[0].combined);
-
- if (filled == 0) {
- if (sscache)
- unref_strand_samples(sscache, zrow, totface);
- break;
- }
- }
- }
-
- alpha= samp_shr->combined[3];
- if (alpha!=0.0f) {
- add_transp_passes(rl, od, samp_shr, alpha);
- if (addpassflag & SCE_PASS_VECTOR)
- add_transp_speed(rl, od, samp_shr->winspeed, alpha, rdrect);
- }
- }
- else {
- short *sp= (short *)(ztramask+od);
-
- while (totface>0) {
- totface--;
-
- if (shade_tra_samples(&ssamp, sscache, x, y, &zrow[totface], addpassflag)) {
- filled= addtosamp_shr(samp_shr, &ssamp, addpassflag);
-
- if (ztramask)
- *sp |= zrow[totface].mask;
- if (filled==0) {
- if (sscache)
- unref_strand_samples(sscache, zrow, totface);
- break;
- }
- }
- }
-
- /* multisample buffers or filtered mask filling? */
- if (pa->fullresult.first) {
- for (a=0; a<R.osa; a++) {
- alpha= samp_shr[a].combined[3];
- if (alpha != 0.0f) {
- RenderLayer *rl_other = ssamp.rlpp[a];
-
- float *rect = RE_RenderLayerGetPass(rl_other , RE_PASSNAME_COMBINED, R.viewname);
- addAlphaOverFloat(rect + 4 * od, samp_shr[a].combined);
-
- add_transp_passes(rl_other , od, &samp_shr[a], alpha);
- if (addpassflag & SCE_PASS_VECTOR)
- add_transp_speed(rl_other , od, samp_shr[a].winspeed, alpha, rdrect);
- }
- }
- }
- else {
- alpha= 0.0f;
-
- /* note; cannot use pass[3] for alpha due to filtermask */
- for (a=0; a<R.osa; a++) {
- add_filt_fmask(1<<a, samp_shr[a].combined, pass, rr->rectx);
- alpha+= samp_shr[a].combined[3];
- }
-
- if (addpassflag) {
- alpha*= sampalpha;
-
- /* merge all in one, and then add */
- merge_transp_passes(rl, samp_shr);
- add_transp_passes(rl, od, samp_shr, alpha);
-
- if (addpassflag & SCE_PASS_VECTOR)
- add_transp_speed(rl, od, samp_shr[0].winspeed, alpha, rdrect);
- }
- }
- }
- }
- }
-
- aprect+= pa->rectx;
- aprectstrand+= pa->rectx;
- passrect+= 4*pa->rectx;
- offs+= pa->rectx;
- }
-
- /* disable scanline updating */
- rr->renlay= NULL;
-
- MEM_freeN(APixbuf);
- if (APixbufstrand)
- MEM_freeN(APixbufstrand);
- if (sscache)
- strand_shade_cache_free(sscache);
- freepsA(&apsmbase);
-
- if (R.r.mode & R_SHADOW)
- ISB_free(pa);
-
- return ztramask;
-}
-
-
/* end of zbuf.c */
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index da61a201ef6..d74cf15d78b 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -42,7 +42,6 @@ set(INC
../makesrna
../nodes
../render/extern/include
- ../../gameengine/BlenderRoutines
../../../intern/clog
../../../intern/ghost
../../../intern/guardedalloc
@@ -143,10 +142,6 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
-if(WITH_GAMEENGINE)
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
if(WITH_BUILDINFO)
add_definitions(-DWITH_BUILDINFO)
endif()
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 377d274a712..652cdac6315 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -91,15 +91,16 @@ void WM_exit (struct bContext *C) ATTR_NORETURN;
void WM_main (struct bContext *C) ATTR_NORETURN;
-bool WM_init_game (struct bContext *C);
void WM_init_splash (struct bContext *C);
void WM_check (struct bContext *C);
-int WM_window_pixels_x (struct wmWindow *win);
-int WM_window_pixels_y (struct wmWindow *win);
-bool WM_window_is_fullscreen (struct wmWindow *win);
+int WM_window_pixels_x(const struct wmWindow *win);
+int WM_window_pixels_y(const struct wmWindow *win);
+int WM_window_screen_pixels_x(const struct wmWindow *win);
+int WM_window_screen_pixels_y(const struct wmWindow *win);
+bool WM_window_is_fullscreen(struct wmWindow *win);
void WM_windows_scene_data_sync(const ListBase *win_lb, struct Scene *scene) ATTR_NONNULL();
struct Scene *WM_windows_scene_get_from_screen(const struct wmWindowManager *wm, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 383744b898a..44434e10838 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -279,6 +279,7 @@ typedef struct wmNotifier {
#define ND_LAYOUTSET (7<<16)
#define ND_SKETCH (8<<16)
#define ND_WORKSPACE_SET (9<<16)
+#define ND_WORKSPACE_DELETE (10<<16)
/* NC_SCENE Scene */
#define ND_SCENEBROWSE (1<<16)
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 27107299863..91e47b67130 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -165,6 +165,11 @@ void wm_operator_register(bContext *C, wmOperator *op)
wmWindowManager *wm = CTX_wm_manager(C);
int tot = 0;
+#ifdef WITH_REDO_REGION_REMOVAL
+ op->execution_area = CTX_wm_area(C);
+ op->execution_region = CTX_wm_region(C);
+#endif
+
BLI_addtail(&wm->operators, op);
/* only count registered operators */
@@ -465,7 +470,8 @@ void wm_add_default(Main *bmain, bContext *C)
WM_window_set_active_workspace(win, workspace);
WM_window_set_active_layout(win, workspace, layout);
screen->winid = win->winid;
-
+ ED_screen_global_areas_create(win);
+
wm->winactive = win;
wm->file_saved = 1;
wm_window_make_drawable(wm, win);
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index ed276aa690d..99319e009c8 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -135,7 +135,7 @@ static bool wm_area_test_invalid_backbuf(ScrArea *sa)
return true;
}
-static void wm_region_test_render_do_draw(const Scene *scene, const struct Depsgraph *depsgraph,
+static void wm_region_test_render_do_draw(const Scene *scene, struct Depsgraph *depsgraph,
ScrArea *sa, ARegion *ar)
{
/* tag region for redraw from render engine preview running inside of it */
@@ -162,6 +162,14 @@ static void wm_region_test_render_do_draw(const Scene *scene, const struct Depsg
}
}
+static void wm_draw_region(bContext *C, ARegion *ar)
+{
+ CTX_wm_region_set(C, ar);
+ ED_region_do_draw(C, ar);
+ ar->do_draw = false;
+ CTX_wm_region_set(C, NULL);
+}
+
/********************** draw all **************************/
/* - reference method, draw all each time */
@@ -208,11 +216,10 @@ static void wm_draw_callbacks(wmWindow *win)
static void wm_method_draw_full(bContext *C, wmWindow *win)
{
bScreen *screen = WM_window_get_active_screen(win);
- ScrArea *sa;
ARegion *ar;
/* draw area regions */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
CTX_wm_area_set(C, sa);
for (ar = sa->regionbase.first; ar; ar = ar->next) {
@@ -254,12 +261,11 @@ static void wm_method_draw_full(bContext *C, wmWindow *win)
/* same buffer as we swapped to the front */
/* mark area-regions to redraw if overlapped with rect */
-static void wm_flush_regions_down(bScreen *screen, rcti *dirty)
+static void wm_flush_regions_down(wmWindow *win, bScreen *screen, rcti *dirty)
{
- ScrArea *sa;
ARegion *ar;
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (BLI_rcti_isect(dirty, &ar->winrct, NULL)) {
ar->do_draw = RGN_DRAW;
@@ -288,24 +294,25 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
{
wmWindowManager *wm = CTX_wm_manager(C);
bScreen *screen = WM_window_get_active_screen(win);
- ScrArea *sa;
ARegion *ar;
static rcti rect = {0, 0, 0, 0};
/* after backbuffer selection draw, we need to redraw */
- for (sa = screen->areabase.first; sa; sa = sa->next)
+ ED_screen_areas_iter(win, screen, sa) {
for (ar = sa->regionbase.first; ar; ar = ar->next)
if (ar->visible && !wm_area_test_invalid_backbuf(sa))
ED_region_tag_redraw(ar);
+ }
/* flush overlapping regions */
if (screen->regionbase.first) {
/* flush redraws of area regions up to overlapping regions */
- for (sa = screen->areabase.first; sa; sa = sa->next)
+ ED_screen_areas_iter(win, screen, sa) {
for (ar = sa->regionbase.first; ar; ar = ar->next)
if (ar->visible && ar->do_draw)
wm_flush_regions_up(screen, &ar->winrct);
-
+ }
+
/* flush between overlapping regions */
for (ar = screen->regionbase.last; ar; ar = ar->prev)
if (ar->visible && ar->do_draw)
@@ -314,12 +321,12 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
/* flush redraws of overlapping regions down to area regions */
for (ar = screen->regionbase.last; ar; ar = ar->prev)
if (ar->visible && ar->do_draw)
- wm_flush_regions_down(screen, &ar->winrct);
+ wm_flush_regions_down(win, screen, &ar->winrct);
}
/* flush drag item */
if (rect.xmin != rect.xmax) {
- wm_flush_regions_down(screen, &rect);
+ wm_flush_regions_down(win, screen, &rect);
rect.xmin = rect.xmax = 0;
}
if (wm->drags.first) {
@@ -328,7 +335,7 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
}
/* draw marked area regions */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
CTX_wm_area_set(C, sa);
for (ar = sa->regionbase.first; ar; ar = ar->next) {
@@ -526,7 +533,6 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
wmWindowManager *wm = CTX_wm_manager(C);
wmDrawData *dd, *dd_next, *drawdata = win->drawdata.first;
bScreen *screen = WM_window_get_active_screen(win);
- ScrArea *sa;
ARegion *ar;
bool copytex = false;
@@ -567,17 +573,14 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
wmDrawTriple *triple = drawdata->triple;
- /* draw marked area regions */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ /* draw marked area regions (also global ones) */
+ ED_screen_areas_iter(win, screen, sa) {
CTX_wm_area_set(C, sa);
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->visible && ar->do_draw) {
if (ar->overlap == false) {
- CTX_wm_region_set(C, ar);
- ED_region_do_draw(C, ar);
- ar->do_draw = false;
- CTX_wm_region_set(C, NULL);
+ wm_draw_region(C, ar);
copytex = true;
}
}
@@ -594,7 +597,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
}
if (wm->paintcursors.first) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->visible && ar == screen->active_region) {
CTX_wm_area_set(C, sa);
@@ -614,16 +617,12 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
}
/* draw overlapping area regions (always like popups) */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
CTX_wm_area_set(C, sa);
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->visible && ar->overlap) {
- CTX_wm_region_set(C, ar);
- ED_region_do_draw(C, ar);
- ar->do_draw = false;
- CTX_wm_region_set(C, NULL);
-
+ wm_draw_region(C, ar);
wm_draw_region_blend(win, ar, triple);
}
}
@@ -662,7 +661,6 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
wmDrawData *drawdata;
wmDrawTriple *triple_data, *triple_all;
bScreen *screen = WM_window_get_active_screen(win);
- ScrArea *sa;
ARegion *ar;
int copytex = false;
int id;
@@ -703,7 +701,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
triple_all = ((wmDrawData *) BLI_findlink(&win->drawdata, (sview * 2) + 1))->triple;
/* draw marked area regions */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
CTX_wm_area_set(C, sa);
switch (sa->spacetype) {
@@ -769,7 +767,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
}
if (wm->paintcursors.first) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->visible && ar == screen->active_region) {
CTX_wm_area_set(C, sa);
@@ -789,7 +787,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
}
/* draw overlapping area regions (always like popups) */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
CTX_wm_area_set(C, sa);
for (ar = sa->regionbase.first; ar; ar = ar->next) {
@@ -849,7 +847,6 @@ static bool wm_draw_update_test_window(wmWindow *win)
/*const*/ ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
const bScreen *screen = WM_window_get_active_screen(win);
- ScrArea *sa;
ARegion *ar;
bool do_draw = false;
@@ -862,7 +859,7 @@ static bool wm_draw_update_test_window(wmWindow *win)
do_draw = true;
}
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
wm_region_test_render_do_draw(scene, depsgraph, sa, ar);
@@ -963,8 +960,7 @@ void wm_draw_update(bContext *C)
wm_window_make_drawable(wm, win);
/* notifiers for screen redraw */
- if (screen->do_refresh)
- ED_screen_refresh(wm, win);
+ ED_screen_ensure_updated(wm, win, screen);
int drawmethod = wm_automatic_draw_method(win);
@@ -1011,17 +1007,18 @@ void wm_draw_data_free(wmWindow *win)
void wm_draw_window_clear(wmWindow *win)
{
bScreen *screen = WM_window_get_active_screen(win);
- ScrArea *sa;
ARegion *ar;
wm_draw_data_free(win);
/* clear screen swap flags */
if (screen) {
- for (sa = screen->areabase.first; sa; sa = sa->next)
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ ED_screen_areas_iter(win, screen, sa) {
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ar->swap = WIN_NONE_OK;
-
+ }
+ }
+
screen->swap = WIN_NONE_OK;
}
}
@@ -1032,7 +1029,7 @@ void wm_draw_region_clear(wmWindow *win, ARegion *ar)
int drawmethod = wm_automatic_draw_method(win);
if (ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP))
- wm_flush_regions_down(screen, &ar->winrct);
+ wm_flush_regions_down(win, screen, &ar->winrct);
screen->do_draw = true;
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 6ec68614116..218f48e9be6 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -386,6 +386,13 @@ void wm_event_do_notifiers(bContext *C)
if (G.debug & G_DEBUG_EVENTS)
printf("%s: Workspace set %p\n", __func__, note->reference);
}
+ else if (note->data == ND_WORKSPACE_DELETE) {
+ WorkSpace *workspace = note->reference;
+
+ ED_workspace_delete(workspace, CTX_data_main(C), C, wm); // XXX hrms, think this over!
+ if (G.debug & G_DEBUG_EVENTS)
+ printf("%s: Workspace delete %p\n", __func__, workspace);
+ }
else if (note->data == ND_LAYOUTBROWSE) {
bScreen *ref_screen = BKE_workspace_layout_screen_get(note->reference);
@@ -455,7 +462,6 @@ void wm_event_do_notifiers(bContext *C)
/* pass */
}
else {
- ScrArea *sa;
ARegion *ar;
/* XXX context in notifiers? */
@@ -467,8 +473,8 @@ void wm_event_do_notifiers(bContext *C)
for (ar = screen->regionbase.first; ar; ar = ar->next) {
ED_region_do_listen(screen, NULL, ar, note, scene);
}
-
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+
+ ED_screen_areas_iter(win, screen, sa) {
ED_area_do_listen(screen, sa, note, scene, workspace);
for (ar = sa->regionbase.first; ar; ar = ar->next) {
ED_region_do_listen(screen, sa, ar, note, scene);
@@ -938,7 +944,18 @@ int WM_operator_call_notest(bContext *C, wmOperator *op)
*/
int WM_operator_repeat(bContext *C, wmOperator *op)
{
+#ifdef WITH_REDO_REGION_REMOVAL
+ const OperatorRepeatContextHandle *context_info;
+ int retval;
+
+ context_info = ED_operator_repeat_prepare_context(C, op);
+ retval = wm_operator_exec(C, op, true, true);
+ ED_operator_repeat_reset_context(C, context_info);
+
+ return retval;
+#else
return wm_operator_exec(C, op, true, true);
+#endif
}
/**
* \return true if #WM_operator_repeat can run
@@ -1528,17 +1545,22 @@ void wm_event_free_handler(wmEventHandler *handler)
/* only set context when area/region is part of screen */
static void wm_handler_op_context(bContext *C, wmEventHandler *handler, const wmEvent *event)
{
+ wmWindow *win = CTX_wm_window(C);
bScreen *screen = CTX_wm_screen(C);
if (screen && handler->op) {
if (handler->op_area == NULL)
CTX_wm_area_set(C, NULL);
else {
- ScrArea *sa;
-
- for (sa = screen->areabase.first; sa; sa = sa->next)
- if (sa == handler->op_area)
+ ScrArea *sa = NULL;
+
+ ED_screen_areas_iter(win, screen, sa_iter) {
+ if (sa_iter == handler->op_area) {
+ sa = sa_iter;
break;
+ }
+ }
+
if (sa == NULL) {
/* when changing screen layouts with running modal handlers (like render display), this
* is not an error to print */
@@ -2493,13 +2515,15 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect)
static ScrArea *area_event_inside(bContext *C, const int xy[2])
{
+ wmWindow *win = CTX_wm_window(C);
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa;
- if (screen)
- for (sa = screen->areabase.first; sa; sa = sa->next)
+ if (screen) {
+ ED_screen_areas_iter(win, screen, sa) {
if (BLI_rcti_isect_pt_v(&sa->totrct, xy))
return sa;
+ }
+ }
return NULL;
}
@@ -2739,7 +2763,6 @@ void wm_event_do_handlers(bContext *C)
wm_tweakevent_test(C, event, action);
if ((action & WM_HANDLER_BREAK) == 0) {
- ScrArea *sa;
ARegion *ar;
/* Note: setting subwin active should be done here, after modal handlers have been done */
@@ -2755,7 +2778,7 @@ void wm_event_do_handlers(bContext *C)
}
#endif
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
/* after restoring a screen from SCREENMAXIMIZED we have to wait
* with the screen handling till the region coordinates are updated */
if (screen->skip_handling == true) {
@@ -2935,24 +2958,26 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
if (handler->type == WM_HANDLER_FILESELECT) {
bScreen *screen = CTX_wm_screen(C);
- ScrArea *sa;
+ bool cancel_handler = true;
/* find the area with the file selector for this handler */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
if (sa->spacetype == SPACE_FILE) {
SpaceFile *sfile = sa->spacedata.first;
if (sfile->op == handler->op) {
CTX_wm_area_set(C, sa);
wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL);
+ cancel_handler = false;
break;
}
}
}
/* if not found we stop the handler without changing the screen */
- if (!sa)
+ if (cancel_handler) {
wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL);
+ }
}
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 6591a8c9f59..e30028eb3d3 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -443,9 +443,8 @@ void wm_file_read_report(bContext *C)
Scene *sce;
for (sce = G.main->scene.first; sce; sce = sce->id.next) {
- ViewRender *view_render = &sce->view_render;
- if (view_render->engine_id[0] &&
- BLI_findstring(&R_engines, view_render->engine_id, offsetof(RenderEngineType, idname)) == NULL)
+ if (sce->r.engine[0] &&
+ BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL)
{
if (reports == NULL) {
reports = CTX_wm_reports(C);
@@ -453,7 +452,7 @@ void wm_file_read_report(bContext *C)
BKE_reportf(reports, RPT_ERROR,
"Engine '%s' not available for scene '%s' (an add-on may need to be installed or enabled)",
- view_render->engine_id, sce->id.name + 2);
+ sce->r.engine, sce->id.name + 2);
}
}
@@ -872,17 +871,8 @@ int wm_homefile_read(
G.main->name[0] = '\0';
- if (use_userdef) {
- /* When loading factory settings, the reset solid OpenGL lights need to be applied. */
- if (!G.background) {
- GPU_default_lights();
- }
- }
-
/* start with save preference untitled.blend */
G.save_over = 0;
- /* disable auto-play in startup.blend... */
- G.fileflags &= ~G_FILE_AUTOPLAY;
wm_file_read_post(C, true, use_userdef);
@@ -1013,7 +1003,7 @@ static void wm_history_file_update(void)
/* screen can be NULL */
-static ImBuf *blend_file_thumb(const bContext *C, Scene *scene, ViewLayer *view_layer, bScreen *screen, BlendThumbnail **thumb_pt)
+static ImBuf *blend_file_thumb(const bContext *C, Scene *scene, bScreen *screen, BlendThumbnail **thumb_pt)
{
/* will be scaled down, but gives some nice oversampling */
ImBuf *ibuf;
@@ -1025,10 +1015,6 @@ static ImBuf *blend_file_thumb(const bContext *C, Scene *scene, ViewLayer *view_
ARegion *ar = NULL;
View3D *v3d = NULL;
- EvaluationContext eval_ctx;
-
- CTX_data_eval_ctx(C, &eval_ctx);
-
/* In case we are given a valid thumbnail data, just generate image from it. */
if (*thumb_pt) {
thumb = *thumb_pt;
@@ -1052,18 +1038,18 @@ static ImBuf *blend_file_thumb(const bContext *C, Scene *scene, ViewLayer *view_
}
/* gets scaled to BLEN_THUMB_SIZE */
- RenderEngineType *engine_type = CTX_data_engine_type(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
if (scene->camera) {
ibuf = ED_view3d_draw_offscreen_imbuf_simple(
- &eval_ctx, scene, view_layer, engine_type, scene->camera,
+ depsgraph, scene, OB_SOLID, scene->camera,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
- IB_rect, V3D_OFSDRAW_NONE, OB_SOLID, R_ALPHAPREMUL, 0, NULL,
+ IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL,
NULL, err_out);
}
else {
ibuf = ED_view3d_draw_offscreen_imbuf(
- &eval_ctx, scene, view_layer, engine_type, v3d, ar,
+ depsgraph, scene, OB_SOLID, v3d, ar,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL,
NULL, err_out);
@@ -1159,7 +1145,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
/* Main now can store a .blend thumbnail, usefull for background mode or thumbnail customization. */
main_thumb = thumb = CTX_data_main(C)->blen_thumb;
if ((U.flag & USER_SAVE_PREVIEWS) && BLI_thread_is_main()) {
- ibuf_thumb = blend_file_thumb(C, CTX_data_scene(C), CTX_data_view_layer(C), CTX_wm_screen(C), &thumb);
+ ibuf_thumb = blend_file_thumb(C, CTX_data_scene(C), CTX_wm_screen(C), &thumb);
}
/* operator now handles overwrite checks */
@@ -1195,7 +1181,6 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
}
SET_FLAG_FROM_TEST(G.fileflags, fileflags & G_FILE_COMPRESS, G_FILE_COMPRESS);
- SET_FLAG_FROM_TEST(G.fileflags, fileflags & G_FILE_AUTOPLAY, G_FILE_AUTOPLAY);
/* prevent background mode scripts from clobbering history */
if (do_history) {
@@ -1303,7 +1288,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
}
else {
/* save as regular blend file */
- int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_HISTORY);
+ int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY);
ED_editors_flush_edits(C, false);
@@ -1430,7 +1415,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
ED_editors_flush_edits(C, false);
/* force save as regular blend file */
- fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_HISTORY);
+ fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY);
if (BLO_write_file(CTX_data_main(C), filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) {
printf("fail\n");
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index a33df1bc1f2..97f738f37da 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -76,8 +76,6 @@
#include "ED_screen.h"
-#include "GPU_material.h"
-
#include "RNA_access.h"
#include "RNA_define.h"
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 4c7c2cc96e4..3cf2575cfc7 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -86,9 +86,6 @@
#include "BPY_extern.h"
#endif
-#ifdef WITH_GAMEENGINE
-# include "BL_System.h"
-#endif
#include "GHOST_Path-api.h"
#include "GHOST_C-api.h"
@@ -121,7 +118,6 @@
#include "BLT_lang.h"
#include "GPU_material.h"
-#include "GPU_buffers.h"
#include "GPU_draw.h"
#include "GPU_init_exit.h"
@@ -193,7 +189,7 @@ void WM_init(bContext *C, int argc, const char **argv)
ED_file_init(); /* for fsmenu */
ED_node_init_butfuncs();
- BLF_init(); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
+ BLF_init();
BLT_lang_init();
/* reports cant be initialized before the wm,
@@ -218,7 +214,7 @@ void WM_init(bContext *C, int argc, const char **argv)
GPU_init();
- GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
+ GPU_set_mipmap(true);
GPU_set_linear_mipmap(true);
GPU_set_anisotropic(U.anisotropic_filter);
GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
@@ -324,96 +320,6 @@ void WM_init_splash(bContext *C)
}
}
-bool WM_init_game(bContext *C)
-{
- wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win;
-
- ScrArea *sa;
- ARegion *ar = NULL;
-
- Scene *scene = CTX_data_scene(C);
-
- if (!scene) {
- /* XXX, this should not be needed. */
- Main *bmain = CTX_data_main(C);
- scene = bmain->scene.first;
- }
-
- win = wm->windows.first;
-
- /* first to get a valid window */
- if (win)
- CTX_wm_window_set(C, win);
-
- sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0);
- ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-
- /* if we have a valid 3D view */
- if (sa && ar) {
- ARegion *arhide;
-
- CTX_wm_area_set(C, sa);
- CTX_wm_region_set(C, ar);
-
- /* disable quad view */
- if (ar->alignment == RGN_ALIGN_QSPLIT)
- WM_operator_name_call(C, "SCREEN_OT_region_quadview", WM_OP_EXEC_DEFAULT, NULL);
-
- /* toolbox, properties panel and header are hidden */
- for (arhide = sa->regionbase.first; arhide; arhide = arhide->next) {
- if (arhide->regiontype != RGN_TYPE_WINDOW) {
- if (!(arhide->flag & RGN_FLAG_HIDDEN)) {
- ED_region_toggle_hidden(C, arhide);
- }
- }
- }
-
- /* full screen the area */
- if (!sa->full) {
- ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED);
- }
-
- /* Fullscreen */
- if ((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) {
- WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", WM_OP_EXEC_DEFAULT, NULL);
- wm_get_screensize(&ar->winrct.xmax, &ar->winrct.ymax);
- ar->winx = ar->winrct.xmax + 1;
- ar->winy = ar->winrct.ymax + 1;
- }
- else {
- GHOST_RectangleHandle rect = GHOST_GetClientBounds(win->ghostwin);
- ar->winrct.ymax = GHOST_GetHeightRectangle(rect);
- ar->winrct.xmax = GHOST_GetWidthRectangle(rect);
- ar->winx = ar->winrct.xmax + 1;
- ar->winy = ar->winrct.ymax + 1;
- GHOST_DisposeRectangle(rect);
- }
-
- WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL);
-
- BKE_sound_exit();
-
- return true;
- }
- else {
- ReportTimerInfo *rti;
-
- BKE_report(&wm->reports, RPT_ERROR, "No valid 3D View found, game auto start is not possible");
-
- /* After adding the report to the global list, reset the report timer. */
- WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);
-
- /* Records time since last report was added */
- wm->reports.reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.02);
-
- rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
- wm->reports.reporttimer->customdata = rti;
-
- return false;
- }
-}
-
/* free strings of open recent files */
static void free_openrecent(void)
{
@@ -491,7 +397,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
/* save the undo state as quit.blend */
char filename[FILE_MAX];
bool has_edited;
- int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_HISTORY);
+ int fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY);
BLI_make_file_string("/", filename, BKE_tempdir_base(), BLENDER_QUIT_FILE);
@@ -528,11 +434,6 @@ void WM_exit_ext(bContext *C, const bool do_python)
ED_undosys_type_free();
-// XXX
-// BIF_GlobalReebFree();
-// BIF_freeRetarget();
- BIF_freeTemplates(C);
-
free_openrecent();
BKE_mball_cubeTable_free();
@@ -560,7 +461,6 @@ void WM_exit_ext(bContext *C, const bool do_python)
BKE_subsurf_osd_cleanup();
#endif
- GPU_global_buffer_pool_free();
GPU_free_unused_buffers();
GPU_exit();
@@ -625,9 +525,6 @@ void WM_exit_ext(bContext *C, const bool do_python)
wm_ghost_exit();
CTX_free(C);
-#ifdef WITH_GAMEENGINE
- SYS_DeleteSystem(SYS_GetSystem());
-#endif
GHOST_DisposeSystemPaths();
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 6f42de73e61..71aee97a53d 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -1820,10 +1820,6 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
break;
}
}
- /* Timeline */
- else if (STRPREFIX(opname, "TIME_OT")) {
- km = WM_keymap_find_all(C, "Timeline", sl->spacetype, 0);
- }
/* Image Editor */
else if (STRPREFIX(opname, "IMAGE_OT")) {
km = WM_keymap_find_all(C, "Image", sl->spacetype, 0);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 9679a55bc7a..4c96afff9a1 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1498,13 +1498,15 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
if (op->type->flag & OPTYPE_MACRO) {
for (op = op->macro.first; op; op = op->next) {
- uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'H', UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
+ uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
+ UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
if (op->next)
uiItemS(layout);
}
}
else {
- uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'H', UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
+ uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
+ UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
}
UI_block_bounds_set_popup(block, 4, 0, 0);
@@ -1573,7 +1575,8 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData)
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
- uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'H', UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
+ uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
+ UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
/* clear so the OK button is left alone */
UI_block_func_set(block, NULL, NULL, NULL);
@@ -1612,7 +1615,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData)
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
/* since ui is defined the auto-layout args are not used */
- uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'V', 0);
+ uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0);
UI_block_func_set(block, NULL, NULL, NULL);
@@ -3988,10 +3991,6 @@ void wm_window_keymap(wmKeyConfig *keyconf)
#endif
/* Space switching */
- kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", F2KEY, KM_PRESS, KM_SHIFT, 0); /* new in 2.5x, was DXF export */
- RNA_string_set(kmi->ptr, "data_path", "area.type");
- RNA_string_set(kmi->ptr, "value", "LOGIC_EDITOR");
-
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", F3KEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path", "area.type");
RNA_string_set(kmi->ptr, "value", "NODE_EDITOR");
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 9b0d8db68ce..166d97d6b5e 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -208,6 +208,8 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
CTX_wm_window_set(C, NULL);
}
+ BKE_screen_area_map_free(&win->global_areas);
+
/* end running jobs, a job end also removes its timer */
for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext = wt->next;
@@ -302,6 +304,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la
WM_window_set_active_workspace(win_dst, workspace);
layout_new = duplicate_layout ? ED_workspace_layout_duplicate(workspace, layout_old, win_dst) : layout_old;
WM_window_set_active_layout(win_dst, workspace, layout_new);
+ ED_screen_global_areas_create(win_dst);
win_dst->drawmethod = U.wmdrawmethod;
@@ -782,6 +785,11 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
WM_event_add_dropbox_handler(&win->handlers, lb);
}
wm_window_title(wm, win);
+
+ /* add topbar */
+ if (BLI_listbase_is_empty(&win->global_areas.areabase)) {
+ ED_screen_global_areas_create(win);
+ }
}
}
@@ -1008,6 +1016,8 @@ int wm_window_new_exec(bContext *C, wmOperator *op)
win_dst->scene = win_src->scene;
screen_new->winid = win_dst->winid;
CTX_wm_window_set(C, win_dst);
+
+ ED_screen_global_areas_create(win_dst);
ED_screen_refresh(CTX_wm_manager(C), win_dst);
}
@@ -2074,19 +2084,35 @@ float WM_cursor_pressure(const struct wmWindow *win)
/* support for native pixel size */
/* mac retina opens window in size X, but it has up to 2 x more pixels */
-int WM_window_pixels_x(wmWindow *win)
+int WM_window_pixels_x(const wmWindow *win)
{
float f = GHOST_GetNativePixelSize(win->ghostwin);
return (int)(f * (float)win->sizex);
}
-
-int WM_window_pixels_y(wmWindow *win)
+int WM_window_pixels_y(const wmWindow *win)
{
float f = GHOST_GetNativePixelSize(win->ghostwin);
return (int)(f * (float)win->sizey);
-
+}
+
+/**
+ * Get the total pixels that are usable by the screen-layouts, excluding global areas.
+ */
+int WM_window_screen_pixels_x(const wmWindow *win)
+{
+ return WM_window_pixels_x(win);
+}
+int WM_window_screen_pixels_y(const wmWindow *win)
+{
+ short screen_size_y = WM_window_pixels_y(win);
+
+ for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) {
+ screen_size_y -= ED_area_global_size_y(sa);
+ }
+
+ return screen_size_y;
}
bool WM_window_is_fullscreen(wmWindow *win)
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
index d774c4e4a2e..d032cb79edc 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
@@ -487,7 +487,6 @@ static int manipulator_find_intersected_3d_intern(
ListBase *visible_manipulators, const bContext *C, const int co[2],
const int hotspot)
{
- EvaluationContext eval_ctx;
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = sa->spacedata.first;
@@ -499,9 +498,7 @@ static int manipulator_find_intersected_3d_intern(
BLI_rcti_init_pt_radius(&rect, co, hotspot);
- CTX_data_eval_ctx(C, &eval_ctx);
-
- ED_view3d_draw_setup_view(CTX_wm_window(C), &eval_ctx, CTX_data_scene(C), ar, v3d, NULL, NULL, &rect);
+ ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, &rect);
if (do_passes)
GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0);
@@ -518,7 +515,7 @@ static int manipulator_find_intersected_3d_intern(
GPU_select_end();
}
- ED_view3d_draw_setup_view(CTX_wm_window(C), &eval_ctx, CTX_data_scene(C), ar, v3d, NULL, NULL, NULL);
+ ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, NULL);
const GLuint *hit_near = GPU_select_buffer_near(buffer, hits);
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
index c9b43cc2a91..67b96f3d8b3 100644
--- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
+++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
@@ -18,10 +18,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/windowmanager/intern/wm_message_bus_rna.c
+/** \file blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
* \ingroup wm
*/
+
#include <stdio.h>
#include "DNA_ID.h"
diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt
deleted file mode 100644
index 60abf0806d3..00000000000
--- a/source/blenderplayer/CMakeLists.txt
+++ /dev/null
@@ -1,274 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-# message(STATUS "Configuring blenderplayer")
-
-setup_libdirs()
-
-if(WIN32 AND NOT UNIX)
- string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
- string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
- string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
- add_definitions(
- -DBLEN_VER_RC_STR=${BLENDER_VERSION}
- -DBLEN_VER_RC_1=${bver1}
- -DBLEN_VER_RC_2=${bver2}
- -DBLEN_VER_RC_3=${bver3}
- -DBLEN_VER_RC_4=0
- )
-
- add_executable(
- blenderplayer ${EXETYPE}
- bad_level_call_stubs/stubs.c
- ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.rc)
- WINDOWS_SIGN_TARGET(blenderplayer)
- install(TARGETS blenderplayer
- COMPONENT Blenderplayer
- DESTINATION ".")
-
-add_cc_flags_custom_test(blenderplayer)
-
-elseif(APPLE)
- add_executable(blenderplayer ${EXETYPE} bad_level_call_stubs/stubs.c)
- # setup Info.plist
- execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blenderplayer.app)
- set(PLAYER_SOURCEINFO ${PLAYER_SOURCEDIR}/Contents/Info.plist)
- set_target_properties(blenderplayer PROPERTIES
- MACOSX_BUNDLE_INFO_PLIST ${PLAYER_SOURCEINFO}
- MACOSX_BUNDLE_SHORT_VERSION_STRING "${BLENDER_VERSION}${BLENDER_VERSION_CHAR}"
- MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION}${BLENDER_VERSION_CHAR} ${BLENDER_DATE}")
-
-else()
- add_executable(blenderplayer bad_level_call_stubs/stubs.c)
-
- if(NOT WITH_INSTALL_PORTABLE)
- install(
- TARGETS blenderplayer
- DESTINATION bin
- )
- else()
- install(
- TARGETS blenderplayer
- DESTINATION "."
- )
- endif()
-endif()
-
-add_dependencies(blenderplayer makesdna)
-
-get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
-
-list(APPEND BLENDER_LINK_LIBS
- ge_player_common
- ge_player_ghost
- blenkernel_blc
-)
-
-if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
- list(APPEND BLENDER_LINK_LIBS
- audaspace
- audaspace-py)
-endif()
-
-if(CMAKE_SYSTEM_NAME MATCHES "Linux")
- list(APPEND BLENDER_LINK_LIBS extern_binreloc)
-endif()
-
-# if(UNIX)
- # Sort libraries
- set(BLENDER_SORTED_LIBS
- ge_player_ghost
- ge_player_common
- bf_intern_string
- bf_intern_ghost
- bf_rna
- bf_blenkernel
- bf_depsgraph
- bf_physics
- bf_intern_rigidbody
- bf_blenloader
- ge_blen_routines
- bf_editor_datafiles
- ge_converter
- ge_logic_ketsji
- ge_phys_bullet
- ge_phys_dummy
- ge_logic
- ge_rasterizer
- ge_oglrasterizer
- ge_logic_expressions
- ge_scenegraph
- bf_ikplugin
- bf_intern_itasc
- bf_intern_iksolver
- bf_intern_smoke
- bf_modifiers
- bf_intern_moto
- bf_nodes
- bf_gpu
- bf_intern_gawain
- bf_imbuf
- bf_avi
- ge_logic_network
- ge_logic_ngnetwork
- ge_logic_loopbacknetwork
- extern_bullet
- bf_intern_guardedalloc
- bf_intern_memutil
- bf_python_ext
- bf_python_mathutils
- bf_python_bmesh
- bf_intern_utfconv
- bf_imbuf_cineon
- bf_imbuf_openexr
- bf_imbuf_openimageio
- extern_openjpeg
- bf_imbuf_dds
- bf_dna
- ge_videotex
- bf_blenfont
- bf_blentranslation
- bf_intern_audaspace
- audaspace
- audaspace-py
- blenkernel_blc
- bf_bmesh
- bf_blenlib
- bf_intern_utfconv
- extern_binreloc
- extern_minilzo
- bf_intern_ghost # duplicate for linking
- bf_blenkernel # duplicate for linking
- bf_intern_mikktspace
- extern_recastnavigation
- bf_intern_opencolorio
- bf_intern_glew_mx
- bf_intern_eigen
- extern_rangetree
- extern_wcwidth
- bf_intern_libmv
- extern_sdlew
- )
-
- if(NOT WITH_SYSTEM_GLOG)
- list(APPEND BLENDER_SORTED_LIBS extern_glog)
- endif()
-
- if(NOT WITH_SYSTEM_GFLAGS)
- list(APPEND BLENDER_SORTED_LIBS extern_gflags)
- endif()
-
- if(WITH_MOD_CLOTH_ELTOPO)
- list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
- endif()
-
- if(NOT WITH_SYSTEM_GLEW)
- list(APPEND BLENDER_SORTED_LIBS ${BLENDER_GLEW_LIBRARIES})
- endif()
-
- if(WITH_LZMA)
- list(APPEND BLENDER_SORTED_LIBS extern_lzma)
- endif()
-
- if(WITH_LIBMV)
- list(APPEND BLENDER_SORTED_LIBS extern_ceres)
- endif()
-
- if(WITH_GHOST_XDND)
- list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
- endif()
-
- if(WITH_CXX_GUARDEDALLOC)
- list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
- endif()
-
- if(WITH_INTERNATIONAL)
- list(APPEND BLENDER_SORTED_LIBS bf_intern_locale)
- endif()
-
- if(WITH_GAMEENGINE_DECKLINK)
- list(APPEND BLENDER_SORTED_LIBS bf_intern_decklink)
- endif()
-
- if(WIN32)
- list(APPEND BLENDER_SORTED_LIBS bf_intern_gpudirect)
- endif()
-
- if(WITH_OPENSUBDIV)
- list(APPEND BLENDER_SORTED_LIBS bf_intern_opensubdiv)
- endif()
-
- if(WITH_OPENVDB)
- list(APPEND BLENDER_SORTED_LIBS bf_intern_openvdb)
- endif()
-
- if(WITH_ALEMBIC)
- list(APPEND BLENDER_SORTED_LIBS bf_alembic)
- endif()
-
- foreach(SORTLIB ${BLENDER_SORTED_LIBS})
- set(REMLIB ${SORTLIB})
- foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
- if(${SEARCHLIB} STREQUAL ${SORTLIB})
- set(REMLIB "")
- endif()
- endforeach()
- if(REMLIB)
- # message(STATUS "Removing library ${REMLIB} from blenderplayer linking because: not configured")
- list(APPEND REM_MSG ${REMLIB})
- list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
- endif()
- endforeach()
- if(REM_MSG)
- list(SORT REM_MSG)
- message(STATUS "Player Skipping: (${REM_MSG})")
- endif()
- target_link_libraries(blenderplayer ${BLENDER_SORTED_LIBS})
-
- unset(SEARCHLIB)
- unset(SORTLIB)
- unset(REMLIB)
- unset(REM_MSG)
-
-# else()
-# target_link_libraries(blenderplayer ${BLENDER_LINK_LIBS})
-# endif()
-
-if(WITH_PLAYER)
- add_subdirectory(bad_level_call_stubs)
-endif()
-
-setup_liblinks(blenderplayer)
-
-# We put CLEW and CUEW here because OPENSUBDIV_LIBRARIES dpeends on them..
-if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
- target_link_libraries(blenderplayer "extern_clew")
- if(WITH_CUDA_DYNLOAD)
- target_link_libraries(blenderplayer "extern_cuew")
- else()
- target_link_libraries(${target} ${CUDA_CUDA_LIBRARY})
- endif()
-endif()
diff --git a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt
deleted file mode 100644
index 0a50c0876fb..00000000000
--- a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt
+++ /dev/null
@@ -1,79 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-# this warning on generated files gets annoying
-remove_strict_flags()
-
-set(INC
- .
- ..
- ../../blender/blenlib
- ../../blender/blenkernel
- ../../blender/blenloader
- ../../blender/depsgraph
- ../../blender/makesdna
- ../../blender/makesrna
- ../../../intern/glew-mx
- ../../../intern/guardedalloc
-)
-
-set(INC_SYS
- ${GLEW_INCLUDE_PATH}
-)
-
-set(SRC
- stubs.c
-)
-
-if(WITH_BUILDINFO)
- list(APPEND SRC
- ../../creator/buildinfo.c
- )
- add_definitions(-DBUILD_DATE="\"\""
- -DBUILD_TIME="\"\""
- -DBUILD_COMMIT_TIMESTAMP=0
- -DBUILD_COMMIT_DATE="\"\""
- -DBUILD_COMMIT_TIME="\"\""
- -DBUILD_HASH="\"\""
- -DBUILD_PLATFORM="\"\""
- -DBUILD_BRANCH="\"\""
- -DBUILD_TYPE="\"\""
- )
-endif()
-
-if(WITH_GAMEENGINE)
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
-if(WITH_FREESTYLE)
- add_definitions(-DWITH_FREESTYLE)
-endif()
-
-if(WITH_INPUT_NDOF)
- add_definitions(-DWITH_INPUT_NDOF)
-endif()
-
-blender_add_lib_nolist(blenkernel_blc "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
deleted file mode 100644
index 96242c229d1..00000000000
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ /dev/null
@@ -1,869 +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 *****
- * BKE_bad_level_calls function stubs
- */
-
-/** \file blenderplayer/bad_level_call_stubs/stubs.c
- * \ingroup blc
- */
-
-#ifdef WITH_GAMEENGINE
-
-#define ASSERT_STUBS 0
-#if ASSERT_STUBS
-# include <assert.h>
-# define STUB_ASSERT(x) (assert(x))
-#else
-# define STUB_ASSERT(x)
-#endif
-
-
-struct ARegion;
-struct ARegionType;
-struct bFaceMap;
-struct BMEditMesh;
-struct Base;
-struct bContext;
-struct BoundBox;
-struct Brush;
-struct CSG_FaceIteratorDescriptor;
-struct CSG_VertexIteratorDescriptor;
-struct ChannelDriver;
-struct ColorBand;
-struct Context;
-struct Curve;
-struct CurveMapping;
-struct DerivedMesh;
-struct EditBone;
-struct EnvMap;
-struct FCurve;
-struct Heap;
-struct HeapNode;
-struct ID;
-struct ImBuf;
-struct Image;
-struct ImageUser;
-struct KeyingSet;
-struct KeyingSetInfo;
-struct MCol;
-struct MTex;
-struct Main;
-struct Mask;
-struct Material;
-struct MenuType;
-struct Mesh;
-struct MetaBall;
-struct Lattice;
-struct ModifierData;
-struct MovieClip;
-struct MultiresModifierData;
-struct HookModifierData;
-struct NodeBlurData;
-struct Nurb;
-struct Object;
-struct PBVHNode;
-struct PyObject;
-struct Render;
-struct RenderEngine;
-struct RenderEngineType;
-struct RenderLayer;
-struct RenderResult;
-struct Scene;
-struct Scene;
-struct ScrArea;
-struct SculptSession;
-struct ShadeInput;
-struct ShadeResult;
-struct SpaceButs;
-struct SpaceClip;
-struct SpaceImage;
-struct SpaceNode;
-struct Tex;
-struct TexResult;
-struct Text;
-struct ToolSettings;
-struct View2D;
-struct View3D;
-struct bAction;
-struct bArmature;
-struct bConstraint;
-struct bConstraintOb;
-struct bConstraintTarget;
-struct bContextDataResult;
-struct bGPDlayer;
-struct bFaceMap;
-struct bNode;
-struct bNodeType;
-struct bNodeSocket;
-struct bNodeSocketType;
-struct bNodeTree;
-struct bNodeTreeType;
-struct bPoseChannel;
-struct bPythonConstraint;
-struct bTheme;
-struct uiLayout;
-struct wmEvent;
-struct wmKeyConfig;
-struct wmKeyMap;
-struct wmOperator;
-struct wmOperatorType;
-struct wmWindow;
-struct wmWindowManager;
-struct wmManipulatorGroupType;
-struct wmManipulatorMap;
-
-
-/* -------------------------------------------------------------------- */
-/* Declarations */
-
-/* may cause troubles... enable for now so args match for certain */
-#if 1
-#if defined(__GNUC__)
-# pragma GCC diagnostic error "-Wmissing-prototypes"
-# pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-
-#include <stdio.h> /* FILE */
-
-#include "../../intern/dualcon/dualcon.h"
-#include "../../intern/elbeem/extern/elbeem.h"
-#include "../blender/blenkernel/BKE_modifier.h"
-#include "../blender/blenkernel/BKE_paint.h"
-#include "../blender/compositor/COM_compositor.h"
-#include "../blender/editors/include/ED_armature.h"
-#include "../blender/editors/include/ED_anim_api.h"
-#include "../blender/editors/include/ED_buttons.h"
-#include "../blender/editors/include/ED_clip.h"
-#include "../blender/editors/include/ED_curve.h"
-#include "../blender/editors/include/ED_fileselect.h"
-#include "../blender/editors/include/ED_gpencil.h"
-#include "../blender/editors/include/ED_image.h"
-#include "../blender/editors/include/ED_info.h"
-#include "../blender/editors/include/ED_keyframes_edit.h"
-#include "../blender/editors/include/ED_keyframing.h"
-#include "../blender/editors/include/ED_lattice.h"
-#include "../blender/editors/include/ED_manipulator_library.h"
-#include "../blender/editors/include/ED_mball.h"
-#include "../blender/editors/include/ED_mesh.h"
-#include "../blender/editors/include/ED_node.h"
-#include "../blender/editors/include/ED_object.h"
-#include "../blender/editors/include/ED_particle.h"
-#include "../blender/editors/include/ED_render.h"
-#include "../blender/editors/include/ED_scene.h"
-#include "../blender/editors/include/ED_screen.h"
-#include "../blender/editors/include/ED_space_api.h"
-#include "../blender/editors/include/ED_text.h"
-#include "../blender/editors/include/ED_transform.h"
-#include "../blender/editors/include/ED_transform_snap_object_context.h"
-#include "../blender/editors/include/ED_uvedit.h"
-#include "../blender/editors/include/ED_view3d.h"
-#include "../blender/editors/include/UI_interface.h"
-#include "../blender/editors/include/UI_interface_icons.h"
-#include "../blender/editors/include/UI_resources.h"
-#include "../blender/editors/include/UI_view2d.h"
-#include "../blender/freestyle/FRS_freestyle.h"
-#include "../blender/gpu/GPU_immediate.h"
-#include "../blender/gpu/GPU_matrix.h"
-#include "../blender/python/BPY_extern.h"
-#include "../blender/python/intern/bpy_manipulator_wrap.h"
-#include "../blender/render/extern/include/RE_engine.h"
-#include "../blender/render/extern/include/RE_pipeline.h"
-#include "../blender/render/extern/include/RE_render_ext.h"
-#include "../blender/render/extern/include/RE_shader_ext.h"
-#include "../blender/draw/DRW_engine.h"
-#include "../blender/windowmanager/WM_api.h"
-#include "../blender/windowmanager/WM_types.h"
-#include "../blender/windowmanager/WM_message.h"
-
-
-/* -------------------------------------------------------------------- */
-/* Externs
- * (ideally we wouldn't have _any_ but we can't include all directly)
- */
-
-/* bpy_operator_wrap.h */
-extern void macro_wrapper(struct wmOperatorType *ot, void *userdata);
-extern void operator_wrapper(struct wmManipulatorGroupType *wgt, void *userdata);
-
-/* bpy_widgetgroup_wrap.h */
-extern void widgetgroup_wrapper(struct wmOperatorType *ot, void *userdata);
-
-/* bpy_rna.h */
-extern bool pyrna_id_FromPyObject(struct PyObject *obj, struct ID **id);
-extern const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid);
-extern const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid);
-extern struct PyObject *pyrna_id_CreatePyObject(struct ID *id);
-extern bool pyrna_id_CheckPyObject(struct PyObject *obj);
-/* bpy_interface.c */
-bool BPY_string_is_keyword(const char *str) { return false; }
-
-#endif
-/* end declarations */
-
-
-/* -------------------------------------------------------------------- */
-/* Return Macro's */
-
-#include <string.h> /* memset */
-#define RET_NULL {STUB_ASSERT(0); return (void *) NULL;}
-#define RET_ZERO {STUB_ASSERT(0); return 0;}
-#define RET_MINUSONE {STUB_ASSERT(0); return -1;}
-#define RET_STRUCT(t) {struct t v; STUB_ASSERT(0); memset(&v, 0, sizeof(v)); return v;}
-#define RET_ARG(arg) {STUB_ASSERT(0); return arg; }
-#define RET_NONE {STUB_ASSERT(0);}
-
-/* -------------------------------------------------------------------- */
-/* Stubs */
-
-void DRW_deferred_shader_remove(struct GPUMaterial *mat) RET_NONE
-
-/*new render funcs */
-void EDBM_selectmode_set(struct BMEditMesh *em) RET_NONE
-void EDBM_mesh_load(struct Object *ob) RET_NONE
-void EDBM_mesh_make(struct Object *ob, const int select_mode, const bool use_key_index) RET_NONE
-void EDBM_mesh_normals_update(struct BMEditMesh *em) RET_NONE
-void *g_system;
-bool EDBM_uv_check(struct BMEditMesh *em) RET_ZERO
-
-float *RE_RenderLayerGetPass(volatile struct RenderLayer *rl, const char *name, const char *viewname) RET_NULL
-float RE_filter_value(int type, float x) RET_ZERO
-struct RenderLayer *RE_GetRenderLayer(struct RenderResult *rr, const char *name) RET_NULL
-void RE_texture_rng_init() RET_NONE
-void RE_texture_rng_exit() RET_NONE
-
-bool RE_layers_have_name(struct RenderResult *result) RET_ZERO
-const char *RE_engine_active_view_get(struct RenderEngine *engine) RET_NULL
-void RE_engine_active_view_set(struct RenderEngine *engine, const char *viewname) RET_NONE
-void RE_engine_get_camera_model_matrix(struct RenderEngine *engine, struct Object *camera, int use_spherical_stereo, float *r_modelmat) RET_NONE
-float RE_engine_get_camera_shift_x(struct RenderEngine *engine, struct Object *camera, int use_spherical_stereo) RET_ZERO
-int RE_engine_get_spherical_stereo(struct RenderEngine *engine, struct Object *camera) RET_ZERO
-void RE_SetActiveRenderView(struct Render *re, const char *viewname) RET_NONE
-
-struct RenderPass *RE_pass_find_by_name(volatile struct RenderLayer *rl, const char *name, const char *viewname) RET_NULL
-struct RenderPass *RE_pass_find_by_type(volatile struct RenderLayer *rl, int passtype, const char *viewname) RET_NULL
-bool RE_HasCombinedLayer(RenderResult *res) RET_ZERO
-
-/* imagetexture.c stub */
-void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float *result) RET_NONE
-
-/* Freestyle */
-bool ED_texture_context_check_linestyle(const struct bContext *C) RET_ZERO
-void FRS_free_view_map_cache(void) RET_NONE
-
-/* texture.c */
-int multitex_ext(struct Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres, const short thread, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image) RET_ZERO
-int multitex_ext_safe(struct Tex *tex, float texvec[3], struct TexResult *texres, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image) RET_ZERO
-int multitex_nodes(struct Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres, const short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex, struct ImagePool *pool) RET_ZERO
-
-struct Material *RE_sample_material_init(const struct EvaluationContext *eval_ctx, struct Material *orig_mat, struct Scene *scene) RET_NULL
-void RE_sample_material_free(struct Material *mat) RET_NONE
-void RE_sample_material_color(
- struct Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3],
- int tri_index, struct DerivedMesh *orcoDm, struct Object *ob) RET_NONE
-/* nodes */
-struct Render *RE_GetRender(const char *name) RET_NULL
-struct Render *RE_GetSceneRender(const struct Scene *scene) RET_NULL
-struct Object *RE_GetCamera(struct Render *re) RET_NULL
-float RE_lamp_get_data(struct ShadeInput *shi, struct Object *lamp_obj, float col[4], float lv[3], float *dist, float shadow[4]) RET_ZERO
-const float (*RE_object_instance_get_matrix(struct ObjectInstanceRen *obi, int matrix_id))[4] RET_NULL
-const float (*RE_render_current_get_matrix(int matrix_id))[4] RET_NULL
-float RE_object_instance_get_object_pass_index(struct ObjectInstanceRen *obi) RET_ZERO
-float RE_object_instance_get_random_id(struct ObjectInstanceRen *obi) RET_ZERO
-
-/* blenkernel */
-bool BKE_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool *uvs, bool *mat, bool *tex, bool *stencil) RET_ZERO
-
-/* render */
-void RE_FreeRenderResult(struct RenderResult *res) RET_NONE
-void RE_FreeAllRenderResults(void) RET_NONE
-struct RenderResult *RE_MultilayerConvert(void *exrhandle, const char *colorspace, bool predivide, int rectx, int recty) RET_NULL
-struct Scene *RE_GetScene(struct Render *re) RET_NULL
-void RE_Database_Free(struct Render *re) RET_NONE
-void RE_FreeRender(struct Render *re) RET_NONE
-void RE_DataBase_GetView(struct Render *re, float mat[4][4]) RET_NONE
-int externtex(
- const struct MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, float *tb, float *ta,
- const int thread, struct ImagePool *pool, const bool skip_load_image, const bool texnode_preview) RET_ZERO
-float texture_value_blend(float tex, float out, float fact, float facg, int blendtype) RET_ZERO
-void texture_rgb_blend(float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype) RET_NONE
-double elbeemEstimateMemreq(int res, float sx, float sy, float sz, int refine, char *retstr) RET_ZERO
-struct Render *RE_NewRender(const char *name) RET_NULL
-struct Render *RE_NewSceneRender(const struct Scene *scene) RET_NULL
-void RE_SwapResult(struct Render *re, struct RenderResult **rr) RET_NONE
-void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, struct Object *camera_override, unsigned int lay_override, int frame, const bool write_still) RET_NONE
-bool RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]) RET_ZERO
-
-/* rna */
-float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d) RET_NULL
-void WM_menutype_free(void) RET_NONE
-void WM_menutype_freelink(struct MenuType *mt) RET_NONE
-bool WM_menutype_add(struct MenuType *mt) RET_ZERO
-int WM_operator_props_dialog_popup(struct bContext *C, struct wmOperator *op, int width, int height) RET_ZERO
-int WM_operator_confirm(struct bContext *C, struct wmOperator *op, const struct wmEvent *event) RET_ZERO
-struct MenuType *WM_menutype_find(const char *idname, bool quiet) RET_NULL
-void WM_operator_stack_clear(struct wmWindowManager *wm) RET_NONE
-void WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot) RET_NONE
-bool WM_operator_is_repeat(const struct bContext *C, const struct wmOperator *op) RET_ZERO;
-void WM_windows_scene_data_sync(const struct ListBase *win_lb, struct Scene *scene) RET_NONE
-struct Scene *WM_windows_scene_get_from_screen(const struct wmWindowManager *wm, const struct bScreen *screen) RET_NULL
-struct WorkSpace *WM_windows_workspace_get_from_screen(const struct wmWindowManager *wm, const struct bScreen *screen) RET_NULL
-struct bScreen *WM_window_get_active_screen(const struct wmWindow *win) RET_NULL
-struct Scene *WM_window_get_active_scene(const struct wmWindow *win) RET_NULL
-struct WorkSpace *WM_window_get_active_workspace(const wmWindow *win) RET_NULL
-
-struct ViewLayer *WM_window_get_active_view_layer_ex(const struct wmWindow *win, struct Scene **r_scene) RET_NULL
-struct ViewLayer *WM_window_get_active_view_layer(const struct wmWindow *win) RET_NULL
-
-void WM_window_change_active_scene(struct Main *bmain, struct bContext *C, struct wmWindow *win, struct Scene *scene_new) RET_NONE
-bool WM_window_is_temp_screen(const struct wmWindow *win) RET_ZERO
-
-void WM_autosave_init(wmWindowManager *wm) RET_NONE
-void WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner) RET_NONE
-
-void WM_lib_reload(struct Library *lib, struct bContext *C, struct ReportList *reports) RET_NONE
-
-void WM_msg_publish_rna(struct wmMsgBus *mbus, PointerRNA *ptr, PropertyRNA *prop) RET_NONE
-
-
-char *WM_clipboard_text_get(bool selection, int *r_len) RET_NULL
-char *WM_clipboard_text_get_firstline(bool selection, int *r_len) RET_NULL
-void WM_clipboard_text_set(const char *buf, bool selection) RET_NONE
-
-void WM_cursor_set(struct wmWindow *win, int curor) RET_NONE
-void WM_cursor_modal_set(struct wmWindow *win, int curor) RET_NONE
-void WM_cursor_modal_restore(struct wmWindow *win) RET_NONE
-void WM_cursor_time(struct wmWindow *win, int nr) RET_NONE
-void WM_cursor_warp(struct wmWindow *win, int x, int y) RET_NONE
-
-struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner, const char *name, int flag, int job_type) RET_NULL
-void WM_jobs_customdata_set(struct wmJob *job, void *customdata, void (*free)(void *)) RET_NONE
-void WM_jobs_timer(struct wmJob *job, double timestep, unsigned int note, unsigned int endnote) RET_NONE
-
-void WM_jobs_callbacks(struct wmJob *job,
- void (*startjob)(void *, short *, short *, float *),
- void (*initjob)(void *),
- void (*update)(void *),
- void (*endjob)(void *)) RET_NONE
-
-void WM_jobs_start(struct wmWindowManager *wm, struct wmJob *job) RET_NONE
-void WM_report(ReportType type, const char *message) RET_NONE
-
-void BPY_RNA_manipulatorgroup_wrapper(struct wmManipulatorGroupType *wgt, void *userdata) RET_NONE
-void BPY_RNA_manipulator_wrapper(struct wmManipulatorType *wgt, void *userdata) RET_NONE
-
-struct PointerRNA *WM_manipulator_operator_set(struct wmManipulator *mpr, int part_index, struct wmOperatorType *ot, struct IDProperty *properties) RET_NULL
-const struct wmManipulatorPropertyType *WM_manipulatortype_target_property_find(const struct wmManipulatorType *wt, const char *idname) RET_NULL
-const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) RET_NULL
-struct wmManipulator *WM_manipulator_new_ptr(const struct wmManipulatorType *wt, struct wmManipulatorGroup *mgroup, struct PointerRNA *properties) RET_NULL
-struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(void (*mnpfunc)(struct wmManipulatorGroupType *, void *), void *userdata) RET_NULL
-struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet) RET_NULL
-void WM_manipulator_unlink(ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr, struct bContext *C) RET_NONE
-void WM_manipulator_group_type_add_ptr(struct wmManipulatorGroupType *wgt) RET_NONE
-void WM_manipulator_group_type_add_ptr_ex(struct wmManipulatorGroupType *wgt, struct wmManipulatorMapType *mmap_type) RET_NONE
-void WM_manipulator_group_type_remove_ptr(struct Main *bmain, struct wmManipulatorGroupType *wgt) RET_NONE
-void WM_manipulator_name_set(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr, const char *name) RET_NONE
-bool WM_manipulator_select_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select) RET_ZERO
-void WM_manipulator_target_property_def_rna_ptr(struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, struct PointerRNA *ptr, struct PropertyRNA *prop, int index) RET_NONE
-void WM_manipulatorgrouptype_free_ptr(struct wmManipulatorGroupType *wt) RET_NONE
-void WM_manipulatormaptype_group_unlink(struct bContext *C, struct Main *bmain, struct wmManipulatorMapType *mmap_type, const struct wmManipulatorGroupType *wgt) RET_NONE
-void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata) RET_NONE
-void WM_manipulatortype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmManipulatorType *wt) RET_NONE
-
-void ED_manipulator_draw_preset_box(const struct wmManipulator *mpr, float mat[4][4], int select_id) RET_NONE
-void ED_manipulator_draw_preset_arrow(const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) RET_NONE
-void ED_manipulator_draw_preset_circle(const struct wmManipulator *mpr, float mat[4][4], int axis, int select_id) RET_NONE
-void ED_manipulator_draw_preset_facemap(const struct bContext *C, const struct wmManipulator *mpr, struct Scene *scene, struct Object *ob, const int facemap, int select_id) RET_NONE
-
-struct wmManipulatorMapType *WM_manipulatormaptype_find(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
-struct wmManipulatorMapType *WM_manipulatormaptype_ensure(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
-struct wmManipulatorMap *WM_manipulatormap_new_from_type(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
-void WM_manipulatormaptype_group_init_runtime(
- const struct Main *bmain, struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt) RET_NONE
-const struct ListBase *WM_manipulatormap_group_list(struct wmManipulatorMap *mmap) RET_NULL
-void WM_manipulator_calc_matrix_final(const struct wmManipulator *mpr, float r_mat[4][4]) RET_NONE
-struct wmManipulatorProperty *WM_manipulator_target_property_find(struct wmManipulator *mpr, const char *idname) RET_NULL
-bool WM_manipulator_target_property_is_valid(const struct wmManipulatorProperty *mpr_prop) RET_ZERO
-
-#ifdef WITH_INPUT_NDOF
- void WM_ndof_deadzone_set(float deadzone) RET_NONE
-#endif
-
-void WM_uilisttype_init(void) RET_NONE
-struct uiListType *WM_uilisttype_find(const char *idname, bool quiet) RET_NULL
-bool WM_uilisttype_add(struct uiListType *ult) RET_ZERO
-void WM_uilisttype_freelink(struct uiListType *ult) RET_NONE
-void WM_uilisttype_free(void) RET_NONE
-
-struct wmKeyMapItem *WM_keymap_item_find_id(struct wmKeyMap *keymap, int id) RET_NULL
-int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event) RET_ZERO
-void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference) RET_NONE
-void WM_main_add_notifier(unsigned int type, void *reference) RET_NONE
-void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep) RET_NONE
-void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props) RET_NONE
-struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op) RET_NULL
-struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep) RET_NULL
-void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer) RET_NONE
-float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]) RET_ZERO
-bool WM_event_is_tablet(const struct wmEvent *event) RET_ZERO
-void ED_armature_edit_bone_remove(struct bArmature *arm, struct EditBone *exBone) RET_NONE
-void object_test_constraints(struct Object *owner) RET_NONE
-void ED_armature_ebone_to_mat4(struct EditBone *ebone, float mat[4][4]) RET_NONE
-void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]) RET_NONE
-void ED_object_parent(struct Object *ob, struct Object *par, const int type, const char *substr) RET_NONE
-void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con) RET_NONE
-void ED_object_facemap_face_add(struct Object *ob, struct bFaceMap *fmap, int facenum) RET_NONE
-void ED_object_facemap_face_remove(struct Object *ob, struct bFaceMap *fmap, int facenum) RET_NONE
-void ED_node_composit_default(const struct bContext *C, struct Scene *scene) RET_NONE
-void *ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *custumdata, int type) RET_ZERO /* XXX this one looks weird */
-void *ED_region_draw_cb_customdata(void *handle) RET_ZERO /* XXX This one looks wrong also */
-void ED_region_draw_cb_exit(struct ARegionType *art, void *handle) RET_NONE
-void ED_area_headerprint(struct ScrArea *sa, const char *str) RET_NONE
-void ED_gpencil_parent_location(struct bGPDlayer *gpl, float diff_mat[4][4]) RET_NONE
-void UI_view2d_region_to_view(struct View2D *v2d, float x, float y, float *viewx, float *viewy) RET_NONE
-bool UI_view2d_view_to_region_clip(struct View2D *v2d, float x, float y, int *regionx, int *regiony) RET_ZERO
-void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *region_y) RET_NONE
-void UI_view2d_sync(struct bScreen *screen, struct ScrArea *sa, struct View2D *v2dcur, int flag) RET_NONE
-
-struct EditBone *ED_armature_bone_get_mirrored(const struct ListBase *edbo, EditBone *ebo) RET_NULL
-struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name) RET_NULL
-struct ListBase *get_active_constraints (struct Object *ob) RET_NULL
-struct ListBase *get_constraint_lb(struct Object *ob, struct bConstraint *con, struct bPoseChannel **r_pchan) RET_NULL
-
-bool ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit) RET_ZERO
-bool ED_space_image_show_render(struct SpaceImage *sima) RET_ZERO
-bool ED_space_image_show_paint(struct SpaceImage *sima) RET_ZERO
-void ED_space_image_paint_update(struct wmWindowManager *wm, struct Scene *scene) RET_NONE
-void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima) RET_NONE
-void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct Scene *scene) RET_NONE
-void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *sima, struct ImBuf *ibuf, bool use_view_settings) RET_NONE
-
-void ED_uvedit_get_aspect(struct Scene *scene, struct Object *ob, struct BMesh *em, float *aspx, float *aspy) RET_NONE
-
-struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc) RET_NULL
-void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip) RET_NONE
-void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask) RET_NONE
-void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask) RET_NONE
-
-void ED_area_tag_redraw_regiontype(struct ScrArea *sa, int regiontype) RET_NONE
-void ED_render_engine_changed(struct Main *bmain) RET_NONE
-
-void ED_file_read_bookmarks(void) RET_NONE
-void ED_file_change_dir(struct bContext *C) RET_NONE
-void ED_preview_kill_jobs(struct wmWindowManager *wm, struct Main *bmain) RET_NONE
-struct FSMenu *ED_fsmenu_get(void) RET_NULL
-struct FSMenuEntry *ED_fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory category) RET_NULL
-int ED_fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category) RET_ZERO
-struct FSMenuEntry *ED_fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index) RET_NULL
-char *ED_fsmenu_entry_get_path(struct FSMenuEntry *fsentry) RET_NULL
-void ED_fsmenu_entry_set_path(struct FSMenuEntry *fsentry, const char *name) RET_NONE
-char *ED_fsmenu_entry_get_name(struct FSMenuEntry *fsentry) RET_NULL
-void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name) RET_NONE
-
-struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob) RET_NULL
-void PE_current_changed(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob) RET_NONE
-
-/* rna keymap */
-struct wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap) RET_NULL
-struct wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) RET_NULL
-struct wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) RET_NULL
-struct wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid) RET_NULL
-struct wmKeyConfig *WM_keyconfig_new(struct wmWindowManager *wm, const char *idname) RET_NULL
-struct wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, const char *idname) RET_NULL
-bool WM_keyconfig_remove(struct wmWindowManager *wm, struct wmKeyConfig *keyconf) RET_ZERO
-bool WM_keymap_remove(struct wmKeyConfig *keyconfig, struct wmKeyMap *keymap) RET_ZERO
-void WM_keyconfig_set_active(struct wmWindowManager *wm, const char *idname) RET_NONE
-bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi) RET_ZERO
-void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C) RET_NONE
-void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi) RET_NONE
-void WM_keymap_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties) RET_NONE
-void WM_keyconfig_update_tag(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi) RET_NONE
-int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2) RET_ZERO
-int WM_keymap_map_type_get(struct wmKeyMapItem *kmi) RET_ZERO
-
-
-/* rna editors */
-
-struct FCurve *verify_fcurve(struct bAction *act, const char group[], struct PointerRNA *ptr, const char rna_path[], const int array_index, short add) RET_NULL
-int insert_vert_fcurve(struct FCurve *fcu, float x, float y, char keytype, short flag) RET_ZERO
-void delete_fcurve_key(struct FCurve *fcu, int index, bool do_recalc) RET_NONE
-struct KeyingSetInfo *ANIM_keyingset_info_find_name (const char name[]) RET_NULL
-struct KeyingSet *ANIM_scene_get_active_keyingset (struct Scene *scene) RET_NULL
-int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks) RET_ZERO
-void ANIM_id_update(struct Scene *scene, struct ID *id) RET_NONE
-struct ListBase builtin_keyingsets;
-void ANIM_keyingset_info_register(struct KeyingSetInfo *ksi) RET_NONE
-void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi) RET_NONE
-short ANIM_validate_keyingset(struct bContext *C, struct ListBase *dsources, struct KeyingSet *ks) RET_ZERO
-int ANIM_add_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag, int type) RET_ZERO
-bool ANIM_remove_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag) RET_ZERO
-void ED_space_image_release_buffer(struct SpaceImage *sima, struct ImBuf *ibuf, void *lock) RET_NONE
-struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **r_lock) RET_NULL
-void ED_space_image_get_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy) RET_NONE
-const char *ED_info_stats_string(struct Scene *scene, struct ViewLayer *view_layer) RET_NULL
-void ED_area_tag_redraw(struct ScrArea *sa) RET_NONE
-void ED_area_tag_refresh(struct ScrArea *sa) RET_NONE
-void ED_area_newspace(struct bContext *C, struct ScrArea *sa, int type, const bool skip_ar_exit) RET_NONE
-void ED_region_tag_redraw(struct ARegion *ar) RET_NONE
-void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op) RET_NONE
-void WM_cursor_wait(bool val) RET_NONE
-void ED_node_texture_default(const struct bContext *C, struct Tex *tex) RET_NONE
-void ED_node_tag_update_id(struct ID *id) RET_NONE
-void ED_node_tag_update_nodetree(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node) RET_NONE
-void ED_node_tree_update(const struct bContext *C) RET_NONE
-void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typeinfo) RET_NONE
-void ED_init_custom_node_type(struct bNodeType *ntype) RET_NONE
-void ED_init_custom_node_socket_type(struct bNodeSocketType *stype) RET_NONE
-void ED_init_standard_node_socket_type(struct bNodeSocketType *stype) RET_NONE
-void ED_init_node_socket_type_virtual(struct bNodeSocketType *stype) RET_NONE
-int ED_node_tree_path_length(struct SpaceNode *snode) RET_ZERO
-void ED_node_tree_path_get(struct SpaceNode *snode, char *value) RET_NONE
-void ED_node_tree_path_get_fixedbuf(struct SpaceNode *snode, char *value, int max_length) RET_NONE
-void ED_node_tree_start(struct SpaceNode *snode, struct bNodeTree *ntree, struct ID *id, struct ID *from) RET_NONE
-void ED_node_tree_push(struct SpaceNode *snode, struct bNodeTree *ntree, struct bNode *gnode) RET_NONE
-void ED_node_tree_pop(struct SpaceNode *snode) RET_NONE
-int ED_view3d_view_layer_set(int lay, const int *values, int *active) RET_ZERO
-void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, bool do_clip) RET_NONE
-void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist) RET_NONE
-void ED_view3d_update_viewmat(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct View3D *v3d, struct ARegion *ar, float viewmat[4][4], float winmat[4][4], const struct rcti *rect) RET_NONE
-float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit) RET_ZERO
-void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa) RET_NONE
-void ED_node_shader_default(const struct bContext *C, struct ID *id) RET_NONE
-void ED_screen_animation_timer_update(struct bScreen *screen, int redraws, int refresh) RET_NONE
-struct bScreen *ED_screen_animation_playing(const struct wmWindowManager *wm) RET_NULL
-struct Scene *ED_screen_scene_find(const struct bScreen *screen, const struct wmWindowManager *wm) RET_NULL
-struct Scene *ED_screen_scene_find_with_window(const struct bScreen *screen, const struct wmWindowManager *wm, struct wmWindow **r_window) RET_NULL
-struct wmWindow *ED_screen_window_find(const struct bScreen *screen, const struct wmWindowManager *wm) RET_NULL;
-bool ED_scene_view_layer_delete(struct Main *bmain, Scene *scene, ViewLayer *layer, ReportList *reports) RET_ZERO
-void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode) RET_NONE
-void ED_object_base_activate(struct bContext *C, struct Base *base) RET_NONE
-bool ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain, struct Object *ob, struct ModifierData *md) RET_ZERO
-struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name, int type) RET_ZERO
-void ED_object_modifier_clear(struct Main *bmain, struct Object *ob) RET_NONE
-void ED_object_editmode_enter(struct bContext *C, int flag) RET_NONE
-void ED_object_editmode_exit(struct bContext *C, int flag) RET_NONE
-void ED_object_editmode_exit_ex(struct bContext *C, struct Scene *scene, struct Object *obedit, int flag) RET_NONE
-bool ED_object_editmode_load(struct Object *obedit) RET_ZERO
-void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object) RET_NONE
-bool uiLayoutGetActive(struct uiLayout *layout) RET_ZERO
-int uiLayoutGetOperatorContext(struct uiLayout *layout) RET_ZERO
-int uiLayoutGetAlignment(struct uiLayout *layout) RET_ZERO
-bool uiLayoutGetEnabled(struct uiLayout *layout) RET_ZERO
-float uiLayoutGetScaleX(struct uiLayout *layout) RET_ZERO
-float uiLayoutGetScaleY(struct uiLayout *layout) RET_ZERO
-void uiLayoutSetActive(struct uiLayout *layout, bool active) RET_NONE
-void uiLayoutSetOperatorContext(struct uiLayout *layout, int opcontext) RET_NONE
-void uiLayoutSetEnabled(uiLayout *layout, bool enabled) RET_NONE
-void uiLayoutSetAlignment(uiLayout *layout, char alignment) RET_NONE
-void uiLayoutSetScaleX(struct uiLayout *layout, float scale) RET_NONE
-void uiLayoutSetScaleY(struct uiLayout *layout, float scale) RET_NONE
-void uiTemplateIconView(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, int show_labels, float icon_scale) RET_NONE
-void ED_object_base_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Object *base) RET_NONE
-void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface) RET_NONE
-void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE
-void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE
-void ED_mesh_tessfaces_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE
-void ED_mesh_loops_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE
-void ED_mesh_polys_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE
-void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE
-void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE
-void ED_mesh_faces_remove(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE
-int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set) RET_MINUSONE
-int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set) RET_MINUSONE
-bool ED_mesh_color_remove_named(struct Mesh *me, const char *name) RET_ZERO
-bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name) RET_ZERO
-void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *ob) RET_NONE
-void ED_object_constraint_dependency_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con) RET_NONE
-void ED_object_constraint_update(struct Object *ob) RET_NONE
-void ED_object_constraint_tag_update(struct Object *ob, struct bConstraint *con) RET_NONE
-void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode) RET_NONE
-void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum) RET_NONE
-float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum) RET_ZERO
-int ED_mesh_mirror_topo_table(struct Object *ob, struct DerivedMesh *dm, char mode) RET_ZERO
-int ED_mesh_mirror_spatial_table(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, const float co[3], char mode) RET_ZERO
-
-float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const bool axis_only) RET_ZERO
-void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height) RET_NONE
-bool ED_space_image_check_show_maskedit(struct SpaceImage *sima, struct ViewLayer *view_layer) RET_ZERO
-
-bool ED_texture_context_check_world(const struct bContext *C) RET_ZERO
-bool ED_texture_context_check_material(const struct bContext *C) RET_ZERO
-bool ED_texture_context_check_lamp(const struct bContext *C) RET_ZERO
-bool ED_texture_context_check_particles(const struct bContext *C) RET_ZERO
-bool ED_texture_context_check_others(const struct bContext *C) RET_ZERO
-
-bool ED_text_region_location_from_cursor(SpaceText *st, ARegion *ar, const int cursor_co[2], int r_pixel_co[2]) RET_ZERO
-
-SnapObjectContext *ED_transform_snap_object_context_create(
- struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, struct RenderEngineType *engine, int flag) RET_NULL
-SnapObjectContext *ED_transform_snap_object_context_create_view3d(
- struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, struct RenderEngineType *engine, int flag,
- const struct ARegion *ar, const struct View3D *v3d) RET_NULL
-void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx) RET_NONE
-bool ED_transform_snap_object_project_ray_ex(
- struct SnapObjectContext *sctx,
- const struct SnapObjectParams *params,
- const float ray_start[3], const float ray_normal[3], float *ray_depth,
- /* return args */
- float r_loc[3], float r_no[3], int *r_index,
- struct Object **r_ob, float r_obmat[4][4]) RET_ZERO
-void BIF_selectTransformOrientationValue(struct View3D *v3d, int orientation) RET_NONE
-
-void ED_curve_editnurb_load(struct Object *obedit) RET_NONE
-void ED_curve_editnurb_make(struct Object *obedit) RET_NONE
-
-void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon) RET_NONE
-
-void uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag, struct PointerRNA *r_opptr) RET_NONE
-void uiItemFullO_ptr(struct uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, struct IDProperty *properties, int context, int flag, struct PointerRNA *r_opptr) RET_NONE
-void uiItemFullOMenuHold_ptr( uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, struct IDProperty *properties, int context, int flag, const char *menu_id, /* extra menu arg. */ PointerRNA *r_opptr) RET_NONE
-struct uiLayout *uiLayoutRow(uiLayout *layout, int align) RET_NULL
-struct uiLayout *uiLayoutColumn(uiLayout *layout, int align) RET_NULL
-struct uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align) RET_NULL
-struct uiLayout *uiLayoutBox(struct uiLayout *layout) RET_NULL
-struct uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) RET_NULL
-bool uiLayoutGetRedAlert(struct uiLayout *layout) RET_ZERO
-void uiLayoutSetRedAlert(uiLayout *layout, bool redalert) RET_NONE
-void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE
-void uiItemMenuEnumR_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon) RET_NONE
-void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon) RET_NONE
-void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon) RET_NONE
-void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon) RET_NONE
-void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) RET_NONE
-void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value) RET_NONE
-void uiItemMenuEnumO(uiLayout *layout, struct bContext *C, const char *opname, const char *propname, const char *name, int icon) RET_NONE
-void uiItemMenuEnumO_ptr(uiLayout *layout, struct bContext *C, struct wmOperatorType *ot, const char *propname, const char *name, int icon) RET_NONE
-void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) RET_NONE
-void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) RET_NONE
-void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value) RET_NONE
-void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value) RET_NONE
-void uiItemL(struct uiLayout *layout, const char *name, int icon) RET_NONE
-void uiItemM(uiLayout *layout, struct bContext *C, const char *menuname, const char *name, int icon) RET_NONE
-void uiItemS(struct uiLayout *layout) RET_NONE
-void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon) RET_NONE
-void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr) RET_NONE
-const char *uiLayoutIntrospect(uiLayout *layout) RET_NULL
-void UI_reinit_font(void) RET_NONE
-int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon, const bool big) RET_ZERO
-struct bTheme *UI_GetTheme(void) RET_NULL
-void UI_GetThemeColor3fv(int colorid, float col[4]) RET_NONE
-void UI_GetThemeColor4fv(int colorid, float col[4]) RET_NONE
-void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]) RET_NONE
-void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]) RET_NONE
-void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int offset, float col[3]) RET_NONE
-void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4]) RET_NONE
-void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]) RET_NONE
-void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset, unsigned char col[4]) RET_NONE
-void UI_widgetbase_draw_cache_flush(void) RET_NONE
-
-/* rna template */
-void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *proptypename, const char *text) RET_NONE
-void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *root_ptr, const char *text) RET_NONE
-void uiTemplateHeader(struct uiLayout *layout, struct bContext *C) RET_NONE
-void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter) RET_NONE
-struct uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr) RET_NULL
-struct uiLayout *uiTemplateConstraint(struct uiLayout *layout, struct PointerRNA *ptr) RET_NULL
-void uiTemplatePreview(struct uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
- struct MTex *slot, const char *preview_id) RET_NONE
-void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int rows, int cols, int filter) RET_NONE
-void uiTemplateSearch(
- uiLayout *layout, struct bContext *C,
- PointerRNA *ptr, const char *propname,
- PointerRNA *searchptr, const char *searchpropname,
- const char *newop, const char *unlinkop) RET_NONE
-void uiTemplateSearchPreview(
- uiLayout *layout, struct bContext *C,
- PointerRNA *ptr, const char *propname,
- PointerRNA *searchptr, const char *searchpropname,
- const char *newop, const char *unlinkop,
- const int rows, const int cols) RET_NONE
-void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, int levels, int brush, int neg_slope) RET_NONE
-void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int expand) RET_NONE
-void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer) RET_NONE
-void uiTemplateImageLayers(struct uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser) RET_NONE
-void uiTemplateList(struct uiLayout *layout, struct bContext *C, const char *listtype_name, const char *list_id,
- PointerRNA *dataptr, const char *propname, PointerRNA *active_dataptr, const char *active_propname,
- const char *item_dyntip_propname, int rows, int maxrows, int layout_type, int columns) RET_NONE
-void uiTemplateRunningJobs(struct uiLayout *layout, struct bContext *C) RET_NONE
-void uiTemplateOperatorSearch(struct uiLayout *layout) RET_NONE
-void uiTemplateHeader3D(struct uiLayout *layout, struct bContext *C) RET_NONE
-void uiTemplateEditModeSelection(struct uiLayout *layout, struct bContext *C) RET_NONE
-void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact, int multiview) RET_NONE
-void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic) RET_NONE
-void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE
-void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C) RET_NONE
-void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE
-void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE
-void uiTemplateNodeLink(struct uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) RET_NONE
-void uiTemplateNodeView(struct uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) RET_NONE
-void uiTemplateTextureUser(struct uiLayout *layout, struct bContext *C) RET_NONE
-void uiTemplateTextureShow(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop) RET_NONE
-void uiTemplateKeymapItemProperties(struct uiLayout *layout, struct PointerRNA *ptr) RET_NONE
-void uiTemplateOverrideProperty(struct uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr, const char *propname, const char *name, const char *text_ctxt, int translate, int icon, const char *custom_template) RET_NONE
-void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, int compact) RET_NONE
-void uiTemplateMovieclipInformation(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr) RET_NONE
-void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE
-void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int compact) RET_NONE
-void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int color_management) RET_NONE
-void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE
-void uiTemplateColormanagedViewSettings(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname) RET_NONE
-void uiTemplateComponentMenu(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name) RET_NONE
-void uiTemplateNodeSocket(struct uiLayout *layout, struct bContext *C, float *color) RET_NONE
-void uiTemplatePalette(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, int color) RET_NONE
-void uiTemplateImageStereo3d(struct uiLayout *layout, struct PointerRNA *stereo3d_format_ptr) RET_NONE
-void uiTemplateCacheFile(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname) RET_NONE
-
-/* rna render */
-struct RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname) RET_NULL
-struct RenderResult *RE_AcquireResultRead(struct Render *re) RET_NULL
-struct RenderResult *RE_AcquireResultWrite(struct Render *re) RET_NULL
-struct RenderResult *RE_engine_get_result(struct RenderEngine *re) RET_NULL
-struct RenderStats *RE_GetStats(struct Render *re) RET_NULL
-struct RenderData *RE_engine_get_render_data(struct Render *re) RET_NULL
-void RE_engine_update_result(struct RenderEngine *engine, struct RenderResult *result) RET_NONE
-void RE_engine_update_progress(struct RenderEngine *engine, float progress) RET_NONE
-void RE_engine_set_error_message(RenderEngine *engine, const char *msg) RET_NONE
-void RE_engine_add_pass(RenderEngine *engine, const char *name, int channels, const char *chan_id, const char *layername) RET_NONE
-void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result, int cancel, int highlight, int merge_results) RET_NONE
-void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info) RET_NONE
-void RE_layer_load_from_file(struct RenderLayer *layer, struct ReportList *reports, const char *filename, int x, int y) RET_NONE
-void RE_result_load_from_file(struct RenderResult *result, struct ReportList *reports, const char *filename) RET_NONE
-void RE_AcquireResultImage(struct Render *re, struct RenderResult *rr, const int view_id) RET_NONE
-void RE_ReleaseResult(struct Render *re) RET_NONE
-void RE_ReleaseResultImage(struct Render *re) RET_NONE
-int RE_engine_test_break(struct RenderEngine *engine) RET_ZERO
-void RE_engines_init() RET_NONE
-void RE_engines_exit() RET_NONE
-void RE_engines_register(struct Main *bmain, RenderEngineType *render_type) RET_NONE
-void RE_engine_report(struct RenderEngine *engine, int type, const char *msg) RET_NONE
-ListBase R_engines = {NULL, NULL};
-void RE_engine_free(struct RenderEngine *engine) RET_NONE
-struct RenderEngineType *RE_engines_find(const char *idname) RET_NULL
-void RE_engine_update_memory_stats(struct RenderEngine *engine, float mem_used, float mem_peak) RET_NONE
-struct RenderEngine *RE_engine_create(struct RenderEngineType *type) RET_NULL
-void RE_engine_frame_set(struct RenderEngine *engine, int frame, float subframe) RET_NONE
-void RE_FreePersistentData(void) RET_NONE
-void RE_point_density_cache(const struct EvaluationContext *eval_ctx, struct PointDensity *pd) RET_NONE
-void RE_point_density_minmax(const struct EvaluationContext *eval_ctx, struct PointDensity *pd, float r_min[3], float r_max[3]) RET_NONE
-void RE_point_density_sample(const struct EvaluationContext *eval_ctx, struct PointDensity *pd, const int resolution, float *values) RET_NONE
-void RE_point_density_free(struct PointDensity *pd) RET_NONE
-void RE_instance_get_particle_info(struct ObjectInstanceRen *obi, float *index, float *random, float *age, float *lifetime, float co[3], float *size, float vel[3], float angvel[3]) RET_NONE
-void RE_FreeAllPersistentData(void) RET_NONE
-float RE_fresnel_dielectric(float incoming[3], float normal[3], float eta) RET_ZERO
-void RE_engine_register_pass(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer, const char *name, int channels, const char *chanid, int type) RET_NONE
-
-/* Draw */
-void OBJECT_collection_settings_create(struct IDProperty *properties) RET_NONE
-void EDIT_MESH_collection_settings_create(struct IDProperty *properties) RET_NONE
-void EDIT_ARMATURE_collection_settings_create(struct IDProperty *properties) RET_NONE
-void PAINT_WEIGHT_collection_settings_create(struct IDProperty *properties) RET_NONE
-void PAINT_VERTEX_collection_settings_create(struct IDProperty *properties) RET_NONE
-
-/* python */
-struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet) RET_NULL
-void WM_operatortype_iter(struct GHashIterator *ghi) RET_NONE
-struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname) RET_NULL
-int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short context, struct PointerRNA *properties, struct ReportList *reports, const bool is_undo) RET_ZERO
-void WM_operatortype_remove_ptr(struct wmOperatorType *ot) RET_NONE
-bool WM_operatortype_remove(const char *idname) RET_ZERO
-int WM_operator_poll(struct bContext *C, struct wmOperatorType *ot) RET_ZERO
-int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, short context) RET_ZERO
-int WM_operator_props_popup(struct bContext *C, struct wmOperator *op, const struct wmEvent *event) RET_ZERO
-void WM_operator_properties_free(struct PointerRNA *ptr) RET_NONE
-void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring) RET_NONE
-void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot) RET_NONE
-void WM_operator_properties_sanitize(struct PointerRNA *ptr, const bool no_context) RET_NONE
-void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata) RET_NONE
-void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata) RET_NONE
-void WM_operator_bl_idname(char *to, const char *from) RET_NONE
-void WM_operator_py_idname(char *to, const char *from) RET_NONE
-bool WM_operator_py_idname_ok_or_report(struct ReportList *reports, const char *classname, const char *idname) RET_ZERO
-int WM_operator_ui_popup(struct bContext *C, struct wmOperator *op, int width, int height) RET_ZERO
-void update_autoflags_fcurve(struct FCurve *fcu, struct bContext *C, struct ReportList *reports, struct PointerRNA *ptr) RET_NONE
-short insert_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, char keytype, short flag) RET_ZERO
-short delete_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag) RET_ZERO
-struct bAction *verify_adt_action(struct ID *id, short add) RET_NULL
-char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, const bool all_args, const bool macro_args, struct wmOperatorType *ot, struct PointerRNA *opptr) RET_NULL
-char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, const bool all_args, const bool macro_args) RET_NULL
-struct wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value) RET_NULL
-struct wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value) RET_NULL
-struct wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, const struct EnumPropertyItem *items) RET_NULL
-struct uiPopupMenu *UI_popup_menu_begin(struct bContext *C, const char *title, int icon) RET_NULL
-void UI_popup_menu_end(struct bContext *C, struct uiPopupMenu *head) RET_NONE
-struct uiLayout *UI_popup_menu_layout(struct uiPopupMenu *head) RET_NULL
-struct uiLayout *UI_pie_menu_layout(struct uiPieMenu *pie) RET_NULL
-int UI_pie_menu_invoke(struct bContext *C, const char *idname, const struct wmEvent *event) RET_ZERO
-struct uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, const struct wmEvent *event) RET_NULL
-void UI_pie_menu_end(struct bContext *C, uiPieMenu *pie) RET_NONE
-struct uiLayout *uiLayoutRadial(struct uiLayout *layout) RET_NULL
-int UI_pie_menu_invoke_from_operator_enum(struct bContext *C, const char *title, const char *opname,
- const char *propname, const struct wmEvent *event) RET_ZERO
-
-void ED_mesh_calc_tessface(struct Mesh *mesh, bool free_mpoly) RET_NONE
-
-/* bpy/python internal api */
-extern void BPY_RNA_operator_wrapper(struct wmOperatorType *ot, void *userdata);
-extern void BPY_RNA_operator_macro_wrapper(struct wmOperatorType *ot, void *userdata);
-void BPY_RNA_operator_wrapper(struct wmOperatorType *ot, void *userdata) RET_NONE
-void BPY_RNA_operator_macro_wrapper(struct wmOperatorType *ot, void *userdata) RET_NONE
-void BPY_text_free_code(struct Text *text) RET_NONE
-void BPY_id_release(struct ID *id) RET_NONE
-void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr) RET_NONE
-int BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result) RET_ZERO
-void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct) RET_NONE
-float BPY_driver_exec(PathResolvedRNA *anim_rna, struct ChannelDriver *driver, const float evaltime) RET_ZERO /* might need this one! */
-void BPY_DECREF(void *pyob_ptr) RET_NONE
-void BPY_pyconstraint_exec(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets) RET_NONE
-bool pyrna_id_FromPyObject(struct PyObject *obj, struct ID **id) RET_ZERO
-struct PyObject *pyrna_id_CreatePyObject(struct ID *id) RET_NULL
-bool pyrna_id_CheckPyObject(struct PyObject *obj) RET_ZERO
-void BPY_context_update(struct bContext *C) RET_NONE
-const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid) RET_ARG(msgid)
-
-/* intern/dualcon */
-
-void *dualcon(const DualConInput *input_mesh,
- /* callbacks for output */
- DualConAllocOutput alloc_output,
- DualConAddVert add_vert,
- DualConAddQuad add_quad,
-
- DualConFlags flags,
- DualConMode mode,
- float threshold,
- float hermite_num,
- float scale,
- int depth) RET_ZERO
-
-/* compositor */
-void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rendering,
- const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings,
- const char *viewName) RET_NONE
-
-/*multiview*/
-bool RE_RenderResult_is_stereo(RenderResult *res) RET_ZERO
-void uiTemplateImageViews(uiLayout *layout, struct PointerRNA *imfptr) RET_NONE
-
-#endif // WITH_GAMEENGINE
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 1adef28f2c8..c5d1a55dfd6 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -76,12 +76,6 @@ if(WITH_HEADLESS)
add_definitions(-DWITH_HEADLESS)
endif()
-if(WITH_GAMEENGINE)
- blender_include_dirs(../gameengine/BlenderRoutines)
-
- add_definitions(-DWITH_GAMEENGINE)
-endif()
-
if(WITH_SDL)
if(WITH_SDL_DYNLOAD)
add_definitions(-DWITH_SDL_DYNLOAD)
@@ -930,53 +924,6 @@ elseif(APPLE)
)
unset(_py_inc_suffix)
endif()
-
- # install blenderplayer bundle - copy of blender.app above. re-using macros et al
- # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
- if(WITH_GAMEENGINE AND WITH_PLAYER)
- set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blenderplayer.app)
- set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist)
- set(PLAYER_TARGETDIR_VER blenderplayer.app/Contents/Resources/${BLENDER_VERSION})
-
-
- # important to make a clean install each time else old scripts get loaded.
- install(
- CODE
- "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
- )
-
- # Give the bundle actual creation/modification date
- execute_process(COMMAND SetFile -d ${SETFILE_DATE} -m ${SETFILE_DATE}
- ${EXECUTABLE_OUTPUT_PATH}/blenderplayer.app)
-
- install(
- FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
- DESTINATION blenderplayer.app/Contents
- )
-
- install_dir(
- ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Resources
- blenderplayer.app/Contents/
- )
-
- if(WITH_OPENMP AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT ${CMAKE_C_COMPILER_VERSION} VERSION_LESS '3.4')
- install(
- FILES ${LIBDIR}/openmp/lib/libiomp5.dylib
- DESTINATION blenderplayer.app/Contents/Resources/lib/
- )
- endif()
-
-
- # python
- if(WITH_PYTHON AND NOT WITH_PYTHON_FRAMEWORK)
- # Copy the python libs into the install directory
- install_dir(
- ${PYTHON_LIBPATH}
- ${PLAYER_TARGETDIR_VER}/python/lib
- )
- endif()
-
- endif()
endif()
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 2aa60c3e2a7..d3fecad2e03 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -85,13 +85,6 @@
# include "FRS_freestyle.h"
#endif
-/* for passing information between creator and gameengine */
-#ifdef WITH_GAMEENGINE
-# include "BL_System.h"
-#else /* dummy */
-# define SYS_SystemHandle int
-#endif
-
#include <signal.h>
#ifdef __FreeBSD__
@@ -226,7 +219,6 @@ int main(
)
{
bContext *C;
- SYS_SystemHandle syshandle;
#ifndef WITH_PYTHON_MODULE
bArgs *ba;
@@ -381,12 +373,6 @@ int main(
BLI_callback_global_init();
-#ifdef WITH_GAMEENGINE
- syshandle = SYS_GetSystem();
-#else
- syshandle = 0;
-#endif
-
/* first test for background */
#ifndef WITH_PYTHON_MODULE
ba = BLI_argsInit(argc, (const char **)argv); /* skip binary path */
@@ -394,7 +380,7 @@ int main(
/* ensure we free on early exit */
app_init_data.ba = ba;
- main_args_setup(C, ba, &syshandle);
+ main_args_setup(C, ba);
BLI_argsParse(ba, 1, NULL, NULL);
@@ -402,7 +388,6 @@ int main(
#else
G.factory_startup = true; /* using preferences or user startup makes no sense for py-as-module */
- (void)syshandle;
#endif
#ifdef WITH_FFMPEG
@@ -517,20 +502,6 @@ int main(
WM_exit(C);
}
else {
- if (G.fileflags & G_FILE_AUTOPLAY) {
- if (G.f & G_SCRIPT_AUTOEXEC) {
- if (WM_init_game(C)) {
- return 0;
- }
- }
- else {
- if (!(G.f & G_SCRIPT_AUTOEXEC_FAIL_QUIET)) {
- G.f |= G_SCRIPT_AUTOEXEC_FAIL;
- BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Game AutoStart");
- }
- }
- }
-
if (!G.file_loaded) {
WM_init_splash(C);
}
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index dac22322361..1f3dd1903c1 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -76,13 +76,6 @@
#include "GPU_draw.h"
-/* for passing information between creator and gameengine */
-#ifdef WITH_GAMEENGINE
-# include "BL_System.h"
-#else /* dummy */
-# define SYS_SystemHandle int
-#endif
-
#ifdef WITH_LIBMV
# include "libmv-capi.h"
#endif
@@ -511,11 +504,6 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
BLI_argsPrintArgDoc(ba, "--start-console");
BLI_argsPrintArgDoc(ba, "--no-native-pixels");
-
- printf("\n");
- printf("Game Engine Specific Options:\n");
- BLI_argsPrintArgDoc(ba, "-g");
-
printf("\n");
printf("Python Options:\n");
BLI_argsPrintArgDoc(ba, "--enable-autoexec");
@@ -581,7 +569,6 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
BLI_argsPrintArgDoc(ba, "--env-system-scripts");
BLI_argsPrintArgDoc(ba, "--env-system-python");
printf("\n");
- BLI_argsPrintArgDoc(ba, "-nojoystick");
BLI_argsPrintArgDoc(ba, "-noaudio");
BLI_argsPrintArgDoc(ba, "-setaudio");
@@ -1125,27 +1112,6 @@ static int arg_handle_register_extension(int UNUSED(argc), const char **UNUSED(a
return 0;
}
-static const char arg_handle_joystick_disable_doc[] =
-"\n\tDisable joystick support."
-;
-static int arg_handle_joystick_disable(int UNUSED(argc), const char **UNUSED(argv), void *data)
-{
-#ifndef WITH_GAMEENGINE
- (void)data;
-#else
- SYS_SystemHandle *syshandle = data;
-
- /**
- * don't initialize joysticks if user doesn't want to use joysticks
- * failed joystick initialization delays over 5 seconds, before game engine start
- */
- SYS_WriteCommandLineInt(*syshandle, "nojoystick", 1);
- if (G.debug & G_DEBUG) printf("disabling nojoystick\n");
-#endif
-
- return 0;
-}
-
static const char arg_handle_audio_disable_doc[] =
"\n\tForce sound system to None."
;
@@ -1224,7 +1190,7 @@ static int arg_handle_engine_set(int argc, const char **argv, void *data)
Scene *scene = CTX_data_scene(C);
if (scene) {
if (BLI_findstring(&R_engines, argv[1], offsetof(RenderEngineType, idname))) {
- BLI_strncpy_utf8(scene->view_render.engine_id, argv[1], sizeof(scene->view_render.engine_id));
+ BLI_strncpy_utf8(scene->r.engine, argv[1], sizeof(scene->r.engine));
}
else {
printf("\nError: engine not found '%s'\n", argv[1]);
@@ -1379,76 +1345,6 @@ static int arg_handle_extension_set(int argc, const char **argv, void *data)
}
}
-static const char arg_handle_ge_parameters_set_doc[] =
-"Game Engine specific options\n"
-"\n"
-"\t'fixedtime'\n"
-"\t\tRun on 50 hertz without dropping frames.\n"
-"\t'vertexarrays'\n"
-"\t\tUse Vertex Arrays for rendering (usually faster).\n"
-"\t'nomipmap'\n"
-"\t\tNo Texture Mipmapping.\n"
-"\t'linearmipmap'\n"
-"\t\tLinear Texture Mipmapping instead of Nearest (default)."
-;
-static int arg_handle_ge_parameters_set(int argc, const char **argv, void *data)
-{
- int a = 0;
-#ifdef WITH_GAMEENGINE
- SYS_SystemHandle syshandle = *(SYS_SystemHandle *)data;
-#else
- (void)data;
-#endif
-
- /**
- * gameengine parameters are automatically put into system
- * -g [paramname = value]
- * -g [boolparamname]
- * example:
- * -g novertexarrays
- * -g maxvertexarraysize = 512
- */
-
- if (argc >= 1) {
- const char *paramname = argv[a];
- /* check for single value versus assignment */
- if (a + 1 < argc && (*(argv[a + 1]) == '=')) {
- a++;
- if (a + 1 < argc) {
- a++;
- /* assignment */
-#ifdef WITH_GAMEENGINE
- SYS_WriteCommandLineString(syshandle, paramname, argv[a]);
-#endif
- }
- else {
- printf("Error: argument assignment (%s) without value.\n", paramname);
- return 0;
- }
- /* name arg eaten */
-
- }
- else {
-#ifdef WITH_GAMEENGINE
- SYS_WriteCommandLineInt(syshandle, argv[a], 1);
-#endif
- /* doMipMap */
- if (STREQ(argv[a], "nomipmap")) {
- GPU_set_mipmap(0); //doMipMap = 0;
- }
- /* linearMipMap */
- if (STREQ(argv[a], "linearmipmap")) {
- GPU_set_mipmap(1);
- GPU_set_linear_mipmap(1); //linearMipMap = 1;
- }
-
-
- } /* if (*(argv[a + 1]) == '=') */
- }
-
- return a;
-}
-
static const char arg_handle_render_frame_doc[] =
"<frame>\n"
"\tRender frame <frame> and save it.\n"
@@ -1890,7 +1786,7 @@ static int arg_handle_load_file(int UNUSED(argc), const char **argv, void *data)
}
-void main_args_setup(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
+void main_args_setup(bContext *C, bArgs *ba)
{
#define CB(a) a##_doc, a
@@ -2004,12 +1900,10 @@ void main_args_setup(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
BLI_argsAdd(ba, 2, NULL, "--no-native-pixels", CB(arg_handle_native_pixels_set), ba);
/* third pass: disabling things and forcing settings */
- BLI_argsAddCase(ba, 3, "-nojoystick", 1, NULL, 0, CB(arg_handle_joystick_disable), syshandle);
BLI_argsAddCase(ba, 3, "-noaudio", 1, NULL, 0, CB(arg_handle_audio_disable), NULL);
BLI_argsAddCase(ba, 3, "-setaudio", 1, NULL, 0, CB(arg_handle_audio_set), NULL);
/* fourth pass: processing arguments */
- BLI_argsAdd(ba, 4, "-g", NULL, CB(arg_handle_ge_parameters_set), syshandle);
BLI_argsAdd(ba, 4, "-f", "--render-frame", CB(arg_handle_render_frame), C);
BLI_argsAdd(ba, 4, "-a", "--render-anim", CB(arg_handle_render_animation), C);
BLI_argsAdd(ba, 4, "-S", "--scene", CB(arg_handle_scene_set), C);
diff --git a/source/creator/creator_intern.h b/source/creator/creator_intern.h
index a972a926677..311c8b74006 100644
--- a/source/creator/creator_intern.h
+++ b/source/creator/creator_intern.h
@@ -33,7 +33,7 @@ struct bContext;
#ifndef WITH_PYTHON_MODULE
/* creator_args.c */
-void main_args_setup(struct bContext *C, struct bArgs *ba, SYS_SystemHandle *syshandle);
+void main_args_setup(struct bContext *C, struct bArgs *ba);
void main_args_setup_post(struct bContext *C, struct bArgs *ba);
diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c
index feb108da289..55f9777f55a 100644
--- a/source/creator/creator_signals.c
+++ b/source/creator/creator_signals.c
@@ -65,13 +65,6 @@
#include "BKE_report.h"
-/* for passing information between creator and gameengine */
-#ifdef WITH_GAMEENGINE
-# include "BL_System.h"
-#else /* dummy */
-# define SYS_SystemHandle int
-#endif
-
#include <signal.h>
#include "creator_intern.h" /* own include */
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
deleted file mode 100644
index 4e8f0eba9b7..00000000000
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ /dev/null
@@ -1,683 +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 *****
- * Blender's Ketsji startpoint
- */
-
-/** \file gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
- * \ingroup blroutines
- */
-
-
-#include <signal.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef _MSC_VER
- /* don't show stl-warnings */
-# pragma warning (disable:4786)
-#endif
-
-#include "GPU_glew.h"
-
-#include "KX_BlenderCanvas.h"
-#include "KX_BlenderKeyboardDevice.h"
-#include "KX_BlenderMouseDevice.h"
-#include "KX_BlenderSystem.h"
-#include "BL_Material.h"
-
-#include "KX_KetsjiEngine.h"
-#include "KX_BlenderSceneConverter.h"
-#include "KX_PythonInit.h"
-#include "KX_PyConstraintBinding.h"
-#include "KX_PythonMain.h"
-
-#include "RAS_OpenGLRasterizer.h"
-#include "RAS_ListRasterizer.h"
-
-#include "NG_LoopBackNetworkDeviceInterface.h"
-
-#include "BL_System.h"
-
-#include "GPU_extensions.h"
-#include "EXP_Value.h"
-
-
-extern "C" {
- #include "DNA_object_types.h"
- #include "DNA_view3d_types.h"
- #include "DNA_screen_types.h"
- #include "DNA_userdef_types.h"
- #include "DNA_scene_types.h"
- #include "DNA_windowmanager_types.h"
-
- #include "BKE_global.h"
- #include "BKE_report.h"
- #include "BKE_ipo.h"
- #include "BKE_main.h"
- #include "BKE_context.h"
- #include "BKE_sound.h"
-
- /* avoid c++ conflict with 'new' */
- #define new _new
- #include "BKE_screen.h"
- #undef new
-
- #include "MEM_guardedalloc.h"
-
- #include "BLI_blenlib.h"
- #include "BLO_readfile.h"
-
- #include "../../blender/windowmanager/WM_types.h"
- #include "../../blender/windowmanager/wm_window.h"
-
-/* avoid more includes (not used by BGE) */
-typedef void * wmUIHandlerFunc;
-typedef void * wmUIHandlerRemoveFunc;
-
- #include "../../blender/windowmanager/wm_event_system.h"
-}
-
-#ifdef WITH_AUDASPACE
-# include <AUD_Device.h>
-#endif
-
-static BlendFileData *load_game_data(const char *filename)
-{
- ReportList reports;
- BlendFileData *bfd;
-
- BKE_reports_init(&reports, RPT_STORE);
- bfd= BLO_read_from_file(filename, &reports, BLO_READ_SKIP_USERDEF);
-
- if (!bfd) {
- printf("Loading %s failed: ", filename);
- BKE_reports_print(&reports, RPT_ERROR);
- }
-
- BKE_reports_clear(&reports);
-
- return bfd;
-}
-
-static int BL_KetsjiNextFrame(KX_KetsjiEngine *ketsjiengine, bContext *C, wmWindow *win, Scene *scene, ARegion *ar,
- KX_BlenderKeyboardDevice* keyboarddevice, KX_BlenderMouseDevice* mousedevice, int draw_letterbox)
-{
- int exitrequested;
-
- // first check if we want to exit
- exitrequested = ketsjiengine->GetExitCode();
-
- // kick the engine
- bool render = ketsjiengine->NextFrame();
-
- if (render) {
- if (draw_letterbox) {
- // Clear screen to border color
- // We do this here since we set the canvas to be within the frames. This means the engine
- // itself is unaware of the extra space, so we clear the whole region for it.
- glClearColor(scene->gm.framing.col[0], scene->gm.framing.col[1], scene->gm.framing.col[2], 1.0f);
- glViewport(ar->winrct.xmin, ar->winrct.ymin,
- BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
- glClear(GL_COLOR_BUFFER_BIT);
- }
-
- // render the frame
- ketsjiengine->Render();
- }
-
- wm_window_process_events_nosleep();
-
- // test for the ESC key
- //XXX while (qtest())
- while (wmEvent *event= (wmEvent *)win->queue.first) {
- short val = 0;
- //unsigned short event = 0; //XXX extern_qread(&val);
- unsigned int unicode = event->utf8_buf[0] ? BLI_str_utf8_as_unicode(event->utf8_buf) : event->ascii;
-
- if (keyboarddevice->ConvertBlenderEvent(event->type, event->val, unicode))
- exitrequested = KX_EXIT_REQUEST_BLENDER_ESC;
-
- /* Coordinate conversion... where
- * should this really be?
- */
- if (event->type == MOUSEMOVE) {
- /* Note, not nice! XXX 2.5 event hack */
- val = event->x - ar->winrct.xmin;
- mousedevice->ConvertBlenderEvent(MOUSEX, val, 0);
-
- val = ar->winy - (event->y - ar->winrct.ymin) - 1;
- mousedevice->ConvertBlenderEvent(MOUSEY, val, 0);
- }
- else {
- mousedevice->ConvertBlenderEvent(event->type, event->val, 0);
- }
-
- BLI_remlink(&win->queue, event);
- wm_event_free(event);
- }
-
- if (win != CTX_wm_window(C)) {
- exitrequested= KX_EXIT_REQUEST_OUTSIDE; /* window closed while bge runs */
- }
- return exitrequested;
-}
-
-
-#ifdef WITH_PYTHON
-static struct BL_KetsjiNextFrameState {
- class KX_KetsjiEngine* ketsjiengine;
- struct bContext *C;
- struct wmWindow* win;
- struct Scene* scene;
- struct ARegion *ar;
- KX_BlenderKeyboardDevice* keyboarddevice;
- KX_BlenderMouseDevice* mousedevice;
- int draw_letterbox;
-} ketsjinextframestate;
-
-static int BL_KetsjiPyNextFrame(void *state0)
-{
- BL_KetsjiNextFrameState *state = (BL_KetsjiNextFrameState *) state0;
- return BL_KetsjiNextFrame(
- state->ketsjiengine,
- state->C,
- state->win,
- state->scene,
- state->ar,
- state->keyboarddevice,
- state->mousedevice,
- state->draw_letterbox);
-}
-#endif
-
-
-extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *cam_frame, int always_use_expand_framing)
-{
- /* context values */
- struct wmWindowManager *wm= CTX_wm_manager(C);
- struct wmWindow *win= CTX_wm_window(C);
- struct Scene *startscene= CTX_data_scene(C);
- struct Main* maggie1= CTX_data_main(C);
-
-
- RAS_Rect area_rect;
- area_rect.SetLeft(cam_frame->xmin);
- area_rect.SetBottom(cam_frame->ymin);
- area_rect.SetRight(cam_frame->xmax);
- area_rect.SetTop(cam_frame->ymax);
-
- int exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
- Main* blenderdata = maggie1;
-
- char* startscenename = startscene->id.name+2;
- char pathname[FILE_MAXDIR+FILE_MAXFILE], oldsce[FILE_MAXDIR+FILE_MAXFILE];
- STR_String exitstring = "";
- BlendFileData *bfd= NULL;
-
- BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
- BLI_strncpy(oldsce, G.main->name, sizeof(oldsce));
-#ifdef WITH_PYTHON
- resetGamePythonPath(); // need this so running a second time wont use an old blendfiles path
- setGamePythonPath(G.main->name);
-
- // Acquire Python's GIL (global interpreter lock)
- // so we can safely run Python code and API calls
- PyGILState_STATE gilstate = PyGILState_Ensure();
-
- PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */
-#endif
-
- // Globals to be carried on over blender files
- GlobalSettings gs;
- gs.matmode= startscene->gm.matmode;
- gs.glslflag= startscene->gm.flag;
-
- do
- {
- View3D *v3d= CTX_wm_view3d(C);
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
-
- // get some preferences
- SYS_SystemHandle syshandle = SYS_GetSystem();
- bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0);
- bool usefixed = (SYS_GetCommandLineInt(syshandle, "fixedtime", 0) != 0);
- bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);
- bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
- bool animation_record = (SYS_GetCommandLineInt(syshandle, "animation_record", 0) != 0);
- bool displaylists = false; // (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0) && GPU_display_list_support();
-#ifdef WITH_PYTHON
- bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
-#endif
- // bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0);
- bool mouse_state = (startscene->gm.flag & GAME_SHOW_MOUSE) != 0;
- bool restrictAnimFPS = (startscene->gm.flag & GAME_RESTRICT_ANIM_UPDATES) != 0;
-
- short drawtype = v3d->drawtype;
-
- /* we do not support material mode in game engine, force change to texture mode */
- if (drawtype == OB_MATERIAL) drawtype = OB_TEXTURE;
- if (animation_record) usefixed= false; /* override since you don't want to run full-speed for sim recording */
-
- // create the canvas and rasterizer
- RAS_ICanvas* canvas = new KX_BlenderCanvas(wm, win, area_rect, ar);
-
- // default mouse state set on render panel
- if (mouse_state)
- canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
- else
- canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
-
- // Setup vsync
- int previous_vsync = 0;
- canvas->GetSwapInterval(previous_vsync);
- if (startscene->gm.vsync == VSYNC_ADAPTIVE)
- canvas->SetSwapInterval(-1);
- else
- canvas->SetSwapInterval((startscene->gm.vsync == VSYNC_ON) ? 1 : 0);
-
- RAS_IRasterizer* rasterizer = NULL;
- RAS_STORAGE_TYPE raster_storage = RAS_AUTO_STORAGE;
-
- if (startscene->gm.raster_storage == RAS_STORE_VBO) {
- raster_storage = RAS_VBO;
- }
- else if (startscene->gm.raster_storage == RAS_STORE_VA) {
- raster_storage = RAS_VA;
- }
- //Don't use displaylists with VBOs
- //If auto starts using VBOs, make sure to check for that here
- if (displaylists && raster_storage != RAS_VBO)
- rasterizer = new RAS_ListRasterizer(canvas, true, raster_storage);
- else
- rasterizer = new RAS_OpenGLRasterizer(canvas, raster_storage);
-
- RAS_IRasterizer::MipmapOption mipmapval = rasterizer->GetMipmapping();
-
-
- // create the inputdevices
- KX_BlenderKeyboardDevice* keyboarddevice = new KX_BlenderKeyboardDevice();
- KX_BlenderMouseDevice* mousedevice = new KX_BlenderMouseDevice();
-
- // create a networkdevice
- NG_NetworkDeviceInterface* networkdevice = new
- NG_LoopBackNetworkDeviceInterface();
-
- //
- // create a ketsji/blendersystem (only needed for timing and stuff)
- KX_BlenderSystem* kxsystem = new KX_BlenderSystem();
-
- // create the ketsjiengine
- KX_KetsjiEngine* ketsjiengine = new KX_KetsjiEngine(kxsystem);
-
- // set the devices
- ketsjiengine->SetKeyboardDevice(keyboarddevice);
- ketsjiengine->SetMouseDevice(mousedevice);
- ketsjiengine->SetNetworkDevice(networkdevice);
- ketsjiengine->SetCanvas(canvas);
- ketsjiengine->SetRasterizer(rasterizer);
- ketsjiengine->SetUseFixedTime(usefixed);
- ketsjiengine->SetTimingDisplay(frameRate, profile, properties);
- ketsjiengine->SetRestrictAnimationFPS(restrictAnimFPS);
- ketsjiengine->SetRender(true);
- KX_KetsjiEngine::SetExitKey(ConvertKeyCode(startscene->gm.exitkey));
-
- //set the global settings (carried over if restart/load new files)
- ketsjiengine->SetGlobalSettings(&gs);
-
-#ifdef WITH_PYTHON
- CValue::SetDeprecationWarnings(nodepwarnings);
-#endif
-
- //lock frame and camera enabled - storing global values
- int tmp_lay= startscene->lay;
- Object *tmp_camera = startscene->camera;
-
- if (v3d->scenelock==0) {
- startscene->lay= v3d->lay;
- startscene->camera= v3d->camera;
- }
-
- // some blender stuff
- float camzoom = 1.0f;
- int draw_letterbox = 0;
-
- if (rv3d->persp==RV3D_CAMOB) {
- if (startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) { /* Letterbox */
- draw_letterbox = 1;
- }
- else {
- camzoom = 1.0f / BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
- }
- }
-
- rasterizer->SetDrawingMode(drawtype);
- ketsjiengine->SetCameraZoom(camzoom);
- ketsjiengine->SetCameraOverrideZoom(2.0f);
-
- // if we got an exitcode 3 (KX_EXIT_REQUEST_START_OTHER_GAME) load a different file
- if (exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME || exitrequested == KX_EXIT_REQUEST_RESTART_GAME)
- {
- exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
- if (bfd) BLO_blendfiledata_free(bfd);
-
- char basedpath[FILE_MAX];
- // base the actuator filename with respect
- // to the original file working directory
-
- if (exitstring != "")
- BLI_strncpy(basedpath, exitstring.ReadPtr(), sizeof(basedpath));
-
- // load relative to the last loaded file, this used to be relative
- // to the first file but that makes no sense, relative paths in
- // blend files should be relative to that file, not some other file
- // that happened to be loaded first
- BLI_path_abs(basedpath, pathname);
- bfd = load_game_data(basedpath);
-
- // if it wasn't loaded, try it forced relative
- if (!bfd)
- {
- // just add "//" in front of it
- char temppath[FILE_MAX] = "//";
- BLI_strncpy(temppath + 2, basedpath, FILE_MAX - 2);
-
- BLI_path_abs(temppath, pathname);
- bfd = load_game_data(temppath);
- }
-
- // if we got a loaded blendfile, proceed
- if (bfd)
- {
- blenderdata = bfd->main;
- startscenename = bfd->curscene->id.name + 2;
-
- if (blenderdata) {
- BLI_strncpy(G.main->name, blenderdata->name, sizeof(G.main->name));
- BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
-#ifdef WITH_PYTHON
- setGamePythonPath(G.main->name);
-#endif
- }
- }
- // else forget it, we can't find it
- else
- {
- exitrequested = KX_EXIT_REQUEST_QUIT_GAME;
- }
- }
-
- Scene *scene= bfd ? bfd->curscene : (Scene *)BLI_findstring(&blenderdata->scene, startscenename, offsetof(ID, name) + 2);
-
- if (scene)
- {
- int startFrame = scene->r.cfra;
- ketsjiengine->SetAnimRecordMode(animation_record, startFrame);
-
- // Quad buffered needs a special window.
- if (scene->gm.stereoflag == STEREO_ENABLED) {
- if (scene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
- rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) scene->gm.stereomode);
-
- rasterizer->SetEyeSeparation(scene->gm.eyeseparation);
- }
-
- rasterizer->SetBackColor(scene->gm.framing.col);
- }
-
- if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
- {
- if (rv3d->persp != RV3D_CAMOB)
- {
- ketsjiengine->EnableCameraOverride(startscenename);
- ketsjiengine->SetCameraOverrideUseOrtho((rv3d->persp == RV3D_ORTHO));
- ketsjiengine->SetCameraOverrideProjectionMatrix(MT_CmMatrix4x4(rv3d->winmat));
- ketsjiengine->SetCameraOverrideViewMatrix(MT_CmMatrix4x4(rv3d->viewmat));
- ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far);
- ketsjiengine->SetCameraOverrideLens(v3d->lens);
- }
-
- // create a scene converter, create and convert the startingscene
- KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(blenderdata, ketsjiengine);
- ketsjiengine->SetSceneConverter(sceneconverter);
- if (always_use_expand_framing)
- sceneconverter->SetAlwaysUseExpandFraming(true);
-
- sceneconverter->SetMaterials(true);
-
- if (gs.matmode == GAME_MAT_GLSL)
- sceneconverter->SetGLSLMaterials(true);
- if (scene->gm.flag & GAME_NO_MATERIAL_CACHING)
- sceneconverter->SetCacheMaterials(false);
-
- KX_Scene* startscene = new KX_Scene(keyboarddevice,
- mousedevice,
- networkdevice,
- startscenename,
- scene,
- canvas);
-
-#ifdef WITH_PYTHON
- // some python things
- PyObject *gameLogic, *gameLogic_keys;
- setupGamePython(ketsjiengine, startscene, blenderdata, pyGlobalDict, &gameLogic, &gameLogic_keys, 0, NULL);
-#endif // WITH_PYTHON
-
- //initialize Dome Settings
- if (scene->gm.stereoflag == STEREO_DOME)
- ketsjiengine->InitDome(scene->gm.dome.res, scene->gm.dome.mode, scene->gm.dome.angle, scene->gm.dome.resbuf, scene->gm.dome.tilt, scene->gm.dome.warptext);
-
- // initialize 3D Audio Settings
- AUD_Device* device = BKE_sound_get_device();
- AUD_Device_setSpeedOfSound(device, scene->audio.speed_of_sound);
- AUD_Device_setDopplerFactor(device, scene->audio.doppler_factor);
- AUD_Device_setDistanceModel(device, AUD_DistanceModel(scene->audio.distance_model));
-
- // from see blender.c:
- // FIXME: this version patching should really be part of the file-reading code,
- // but we still get too many unrelated data-corruption crashes otherwise...
- if (blenderdata->versionfile < 250)
- do_versions_ipos_to_animato(blenderdata);
-
- if (sceneconverter)
- {
- // convert and add scene
- sceneconverter->ConvertScene(
- startscene,
- rasterizer,
- canvas);
- ketsjiengine->AddScene(startscene);
-
- // init the rasterizer
- rasterizer->Init();
-
- // start the engine
- ketsjiengine->StartEngine(true);
-
-
- // Set the animation playback rate for ipo's and actions
- // the framerate below should patch with FPS macro defined in blendef.h
- // Could be in StartEngine set the framerate, we need the scene to do this
- ketsjiengine->SetAnimFrameRate(FPS);
-
-#ifdef WITH_PYTHON
- char *python_main = NULL;
- pynextframestate.state = NULL;
- pynextframestate.func = NULL;
- python_main = KX_GetPythonMain(scene);
-
- // the mainloop
- printf("\nBlender Game Engine Started\n");
- if (python_main) {
- char *python_code = KX_GetPythonCode(blenderdata, python_main);
- if (python_code) {
- // Set python environement variable.
- KX_SetActiveScene(startscene);
- PHY_SetActiveEnvironment(startscene->GetPhysicsEnvironment());
-
- ketsjinextframestate.ketsjiengine = ketsjiengine;
- ketsjinextframestate.C = C;
- ketsjinextframestate.win = win;
- ketsjinextframestate.scene = scene;
- ketsjinextframestate.ar = ar;
- ketsjinextframestate.keyboarddevice = keyboarddevice;
- ketsjinextframestate.mousedevice = mousedevice;
- ketsjinextframestate.draw_letterbox = draw_letterbox;
-
- pynextframestate.state = &ketsjinextframestate;
- pynextframestate.func = &BL_KetsjiPyNextFrame;
- printf("Yielding control to Python script '%s'...\n", python_main);
- PyRun_SimpleString(python_code);
- printf("Exit Python script '%s'\n", python_main);
- MEM_freeN(python_code);
- }
- }
- else
-#endif /* WITH_PYTHON */
- {
- while (!exitrequested)
- {
- exitrequested = BL_KetsjiNextFrame(ketsjiengine, C, win, scene, ar, keyboarddevice, mousedevice, draw_letterbox);
- }
- }
- printf("Blender Game Engine Finished\n");
- exitstring = ketsjiengine->GetExitString();
-#ifdef WITH_PYTHON
- if (python_main) MEM_freeN(python_main);
-#endif /* WITH_PYTHON */
-
- gs = *(ketsjiengine->GetGlobalSettings());
-
- // when exiting the mainloop
-#ifdef WITH_PYTHON
- // Clears the dictionary by hand:
- // This prevents, extra references to global variables
- // inside the GameLogic dictionary when the python interpreter is finalized.
- // which allows the scene to safely delete them :)
- // see: (space.c)->start_game
-
- //PyDict_Clear(PyModule_GetDict(gameLogic));
-
- // Keep original items, means python plugins will autocomplete members
- PyObject *gameLogic_keys_new = PyDict_Keys(PyModule_GetDict(gameLogic));
- const Py_ssize_t numitems= PyList_GET_SIZE(gameLogic_keys_new);
- Py_ssize_t listIndex;
- for (listIndex=0; listIndex < numitems; listIndex++) {
- PyObject *item = PyList_GET_ITEM(gameLogic_keys_new, listIndex);
- if (!PySequence_Contains(gameLogic_keys, item)) {
- PyDict_DelItem( PyModule_GetDict(gameLogic), item);
- }
- }
- Py_DECREF(gameLogic_keys_new);
- gameLogic_keys_new = NULL;
-#endif
- ketsjiengine->StopEngine();
-#ifdef WITH_PYTHON
- exitGamePythonScripting();
-#endif
- networkdevice->Disconnect();
- }
- if (sceneconverter)
- {
- delete sceneconverter;
- sceneconverter = NULL;
- }
-
-#ifdef WITH_PYTHON
- Py_DECREF(gameLogic_keys);
- gameLogic_keys = NULL;
-#endif
- }
- //lock frame and camera enabled - restoring global values
- if (v3d->scenelock==0) {
- startscene->lay= tmp_lay;
- startscene->camera= tmp_camera;
- }
-
- if (exitrequested != KX_EXIT_REQUEST_OUTSIDE)
- {
- // set the cursor back to normal
- canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
-
- // set mipmap setting back to its original value
- rasterizer->SetMipmapping(mipmapval);
- }
-
- // clean up some stuff
- if (ketsjiengine)
- {
- delete ketsjiengine;
- ketsjiengine = NULL;
- }
- if (kxsystem)
- {
- delete kxsystem;
- kxsystem = NULL;
- }
- if (networkdevice)
- {
- delete networkdevice;
- networkdevice = NULL;
- }
- if (keyboarddevice)
- {
- delete keyboarddevice;
- keyboarddevice = NULL;
- }
- if (mousedevice)
- {
- delete mousedevice;
- mousedevice = NULL;
- }
- if (rasterizer)
- {
- delete rasterizer;
- rasterizer = NULL;
- }
- if (canvas)
- {
- canvas->SetSwapInterval(previous_vsync); // Set the swap interval back
- delete canvas;
- canvas = NULL;
- }
-
- // stop all remaining playing sounds
- AUD_Device_stopAll(BKE_sound_get_device());
-
- } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
-
- if (bfd) BLO_blendfiledata_free(bfd);
-
- BLI_strncpy(G.main->name, oldsce, sizeof(G.main->name));
-
-#ifdef WITH_PYTHON
- PyDict_Clear(pyGlobalDict);
- Py_DECREF(pyGlobalDict);
-
- // Release Python's GIL
- PyGILState_Release(gilstate);
-#endif
-
-}
diff --git a/source/gameengine/BlenderRoutines/BL_System.cpp b/source/gameengine/BlenderRoutines/BL_System.cpp
deleted file mode 100644
index 251182a07aa..00000000000
--- a/source/gameengine/BlenderRoutines/BL_System.cpp
+++ /dev/null
@@ -1,102 +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 *****
- * Interface to the commandline arguments
- */
-
-/** \file gameengine/BlenderRoutines/BL_System.cpp
- * \ingroup blroutines
- */
-
-#include "CTR_Map.h"
-#include "STR_HashedString.h"
-#include "BL_System.h"
-
-struct SingletonSystem {
- CTR_Map<STR_HashedString,int> int_params;
- CTR_Map<STR_HashedString,float> float_params;
- CTR_Map<STR_HashedString,STR_String> string_params;
-};
-
-static SingletonSystem *_system_instance = NULL;
-
-SYS_SystemHandle SYS_GetSystem()
-{
- if (!_system_instance)
- _system_instance = new SingletonSystem();
-
- return (SYS_SystemHandle)_system_instance;
-}
-
-void SYS_DeleteSystem(SYS_SystemHandle sys)
-{
- if (_system_instance) {
- delete _system_instance;
- _system_instance = NULL;
- }
-}
-
-int SYS_GetCommandLineInt(SYS_SystemHandle sys, const char *paramname, int defaultvalue)
-{
- int *result = ((SingletonSystem *)sys)->int_params[paramname];
- if (result)
- return *result;
-
- return defaultvalue;
-}
-
-float SYS_GetCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float defaultvalue)
-{
- float *result = ((SingletonSystem *)sys)->float_params[paramname];
- if (result)
- return *result;
-
- return defaultvalue;
-}
-
-const char *SYS_GetCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *defaultvalue)
-{
- STR_String *result = ((SingletonSystem *)sys)->string_params[paramname];
- if (result)
- return *result;
-
- return defaultvalue;
-}
-
-void SYS_WriteCommandLineInt(SYS_SystemHandle sys, const char *paramname, int value)
-{
- ((SingletonSystem *)sys)->int_params.insert(paramname, value);
-}
-
-void SYS_WriteCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float value)
-{
- ((SingletonSystem *)sys)->float_params.insert(paramname, value);
-}
-
-void SYS_WriteCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *value)
-{
- ((SingletonSystem *)sys)->string_params.insert(paramname, value);
-}
-
diff --git a/source/gameengine/BlenderRoutines/BL_System.h b/source/gameengine/BlenderRoutines/BL_System.h
deleted file mode 100644
index b9f51393f44..00000000000
--- a/source/gameengine/BlenderRoutines/BL_System.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 *****
- * System specific information / access.
- * Interface to the commandline arguments
- */
-
-/** \file gameengine/BlenderRoutines/BL_System.h
- * \ingroup blroutines
- */
-
-#ifndef __BL_SYSTEM_H__
-#define __BL_SYSTEM_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Game Engine command line parameters */
-
-typedef void* SYS_SystemHandle;
-
-extern SYS_SystemHandle SYS_GetSystem(void);
-extern void SYS_DeleteSystem(SYS_SystemHandle sys);
-
-extern int SYS_GetCommandLineInt(SYS_SystemHandle sys, const char *paramname, int defaultvalue);
-extern float SYS_GetCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float defaultvalue);
-extern const char *SYS_GetCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *defaultvalue);
-
-extern void SYS_WriteCommandLineInt(SYS_SystemHandle sys, const char *paramname, int value);
-extern void SYS_WriteCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float value);
-extern void SYS_WriteCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *value);
-
-/* Start game engine */
-
-struct bContext;
-struct ARegion;
-struct rcti;
-
-extern void StartKetsjiShell(struct bContext *C, struct ARegion *ar,
- struct rcti *cam_frame, int always_use_expand_framing);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __BL_SYSTEM_H__ */
-
diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt
deleted file mode 100644
index 42293050753..00000000000
--- a/source/gameengine/BlenderRoutines/CMakeLists.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-
-set(INC
- .
- ../Converter
- ../Expressions
- ../GameLogic
- ../Ketsji
- ../Network
- ../Network/LoopBackNetwork
- ../Physics/Bullet
- ../Physics/common
- ../Rasterizer
- ../Rasterizer/RAS_OpenGLRasterizer
- ../SceneGraph
- ../../blender
- ../../blender/blenfont
- ../../blender/blenkernel
- ../../blender/blenlib
- ../../blender/blenloader
- ../../blender/editors/include
- ../../blender/gpu
- ../../blender/imbuf
- ../../blender/makesdna
- ../../blender/makesrna
- ../../blender/windowmanager
- ../../../intern/container
- ../../../intern/glew-mx
- ../../../intern/guardedalloc
- ../../../intern/string
-)
-
-set(INC_SYS
- ../../../intern/moto/include
- ${PTHREADS_INCLUDE_DIRS}
- ${GLEW_INCLUDE_PATH}
- ${BOOST_INCLUDE_DIR}
-)
-
-set(SRC
- BL_KetsjiEmbedStart.cpp
- BL_System.cpp
- KX_BlenderCanvas.cpp
- KX_BlenderInputDevice.cpp
- KX_BlenderKeyboardDevice.cpp
- KX_BlenderMouseDevice.cpp
- KX_BlenderSystem.cpp
-
- BL_System.h
- KX_BlenderCanvas.h
- KX_BlenderInputDevice.h
- KX_BlenderKeyboardDevice.h
- KX_BlenderMouseDevice.h
- KX_BlenderSystem.h
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-if(WITH_AUDASPACE)
- add_definitions(-DWITH_AUDASPACE)
-
- list(APPEND INC_SYS
- ${AUDASPACE_C_INCLUDE_DIRS}
- )
-endif()
-
-if(WITH_CODEC_FFMPEG)
- add_definitions(-DWITH_FFMPEG)
-endif()
-
-if(WITH_BULLET)
- list(APPEND INC_SYS
- ${BULLET_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_BULLET)
-endif()
-
-
-blender_add_lib(ge_blen_routines "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
deleted file mode 100644
index 6fdc823ba1a..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
+++ /dev/null
@@ -1,352 +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_BlenderCanvas.cpp
- * \ingroup blroutines
- */
-
-#include "GPU_glew.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "KX_BlenderCanvas.h"
-
-#include "DNA_screen_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_windowmanager_types.h"
-
-#include "BKE_image.h"
-
-#include <assert.h>
-#include <iostream>
-
-extern "C" {
-#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),
-m_win(win),
-m_frame_rect(rect)
-{
- // initialize area so that it's available for game logic on frame 1 (ImageViewport)
- m_area_rect = rect;
- // area boundaries needed for mouse coordinates in Letterbox framing mode
- m_area_left = ar->winrct.xmin;
- m_area_top = ar->winrct.ymax;
- m_frame = 1;
-
- glGetIntegerv(GL_VIEWPORT, (GLint *)m_viewport);
-}
-
-KX_BlenderCanvas::~KX_BlenderCanvas()
-{
-}
-
-void KX_BlenderCanvas::Init()
-{
- glDepthFunc(GL_LEQUAL);
-}
-
-
-void KX_BlenderCanvas::SwapBuffers()
-{
- wm_window_swap_buffers(m_win);
-}
-
-void KX_BlenderCanvas::SetSwapInterval(int interval)
-{
- wm_window_set_swap_interval(m_win, interval);
-}
-
-bool KX_BlenderCanvas::GetSwapInterval(int &intervalOut)
-{
- return wm_window_get_swap_interval(m_win, &intervalOut);
-}
-
-void KX_BlenderCanvas::GetDisplayDimensions(int &width, int &height)
-{
- wm_get_screensize(&width, &height);
-}
-
-void KX_BlenderCanvas::ResizeWindow(int width, int height)
-{
- // Not implemented for the embedded player
-}
-
-void KX_BlenderCanvas::SetFullScreen(bool enable)
-{
- // Not implemented for the embedded player
-}
-
-bool KX_BlenderCanvas::GetFullScreen()
-{
- // Not implemented for the embedded player
- return false;
-}
-
-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
- wm_window_make_drawable(m_wm, m_win);
- return true;
-}
-
-
-void KX_BlenderCanvas::EndDraw()
-{
- // nothing needs to be done here
-}
-
-void KX_BlenderCanvas::BeginFrame()
-{
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
-}
-
-
-void KX_BlenderCanvas::EndFrame()
-{
- glDisable(GL_FOG);
-}
-
-
-
-void KX_BlenderCanvas::ClearColor(float r,float g,float b,float a)
-{
- glClearColor(r,g,b,a);
-}
-
-
-
-void KX_BlenderCanvas::ClearBuffer(int type)
-{
- int ogltype = 0;
-
- if (type & RAS_ICanvas::COLOR_BUFFER )
- ogltype |= GL_COLOR_BUFFER_BIT;
-
- if (type & RAS_ICanvas::DEPTH_BUFFER )
- ogltype |= GL_DEPTH_BUFFER_BIT;
- glClear(ogltype);
-}
-
-int KX_BlenderCanvas::GetWidth(
-) const {
- return m_frame_rect.GetWidth();
-}
-
-int KX_BlenderCanvas::GetHeight(
-) const {
- return m_frame_rect.GetHeight();
-}
-
-int KX_BlenderCanvas::GetMouseX(int x)
-{
- int left = GetWindowArea().GetLeft();
- return x - (left - m_area_left);
-}
-
-int KX_BlenderCanvas::GetMouseY(int y)
-{
- int top = GetWindowArea().GetTop();
- return y - (m_area_top - top);
-}
-
-float KX_BlenderCanvas::GetMouseNormalizedX(int x)
-{
- int can_x = GetMouseX(x);
- return float(can_x)/this->GetWidth();
-}
-
-float KX_BlenderCanvas::GetMouseNormalizedY(int y)
-{
- int can_y = GetMouseY(y);
- return float(can_y)/this->GetHeight();
-}
-
-RAS_Rect &
-KX_BlenderCanvas::
-GetWindowArea(
-) {
- return m_area_rect;
-}
-
- void
-KX_BlenderCanvas::
-SetViewPort(
- int x1, int y1,
- int x2, int y2
-) {
- /* x1 and y1 are the min pixel coordinate (e.g. 0)
- * x2 and y2 are the max pixel coordinate
- * the width,height is calculated including both pixels
- * therefore: max - min + 1
- */
- int vp_width = (x2 - x1) + 1;
- int vp_height = (y2 - y1) + 1;
- int minx = m_frame_rect.GetLeft();
- int miny = m_frame_rect.GetBottom();
-
- m_area_rect.SetLeft(minx + x1);
- m_area_rect.SetBottom(miny + y1);
- m_area_rect.SetRight(minx + x2);
- m_area_rect.SetTop(miny + y2);
-
- m_viewport[0] = minx+x1;
- m_viewport[1] = miny+y1;
- m_viewport[2] = vp_width;
- m_viewport[3] = vp_height;
-
- glViewport(minx + x1, miny + y1, vp_width, vp_height);
- glScissor(minx + x1, miny + y1, vp_width, vp_height);
-}
-
- void
-KX_BlenderCanvas::
-UpdateViewPort(
- int x1, int y1,
- int x2, int y2
-) {
- m_viewport[0] = x1;
- m_viewport[1] = y1;
- m_viewport[2] = x2;
- m_viewport[3] = y2;
-}
-
- const int*
-KX_BlenderCanvas::
-GetViewPort() {
-#ifdef DEBUG
- // If we're in a debug build, we might as well make sure our values don't differ
- // from what the gpu thinks we have. This could lead to nasty, hard to find bugs.
- int viewport[4];
- glGetIntegerv(GL_VIEWPORT, viewport);
- assert(viewport[0] == m_viewport[0]);
- assert(viewport[1] == m_viewport[1]);
- assert(viewport[2] == m_viewport[2]);
- assert(viewport[3] == m_viewport[3]);
-#endif
-
- return m_viewport;
-}
-
-void KX_BlenderCanvas::SetMouseState(RAS_MouseState mousestate)
-{
- m_mousestate = mousestate;
-
- switch (mousestate)
- {
- case MOUSE_INVISIBLE:
- {
- WM_cursor_set(m_win, CURSOR_NONE);
- break;
- }
- case MOUSE_WAIT:
- {
- WM_cursor_set(m_win, CURSOR_WAIT);
- break;
- }
- case MOUSE_NORMAL:
- {
- WM_cursor_set(m_win, CURSOR_STD);
- break;
- }
- default:
- {
- }
- }
-}
-
-
-
-// (0,0) is top left, (width,height) is bottom right
-void KX_BlenderCanvas::SetMousePosition(int x,int y)
-{
- int winX = m_frame_rect.GetLeft();
- int winY = m_frame_rect.GetBottom();
- int winH = m_frame_rect.GetHeight();
-
- 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};
- 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();
-
- dumprect = screenshot(&area_dummy, &dumpsx, &dumpsy);
- if (!dumprect) {
- std::cerr << "KX_BlenderCanvas: Unable to take screenshot!" << std::endl;
- return;
- }
-
- /* initialize image file format data */
- Scene *scene = WM_window_get_active_scene(m_win);
- ImageFormatData *im_format = (ImageFormatData *)MEM_mallocN(sizeof(ImageFormatData), "im_format");
-
- if (scene)
- *im_format = scene->r.im_format;
- else
- BKE_imformat_defaults(im_format);
-
- /* save_screenshot() frees dumprect and im_format */
- save_screenshot(filename, dumpsx, dumpsy, dumprect, im_format);
-}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
deleted file mode 100644
index 6f408f86551..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
+++ /dev/null
@@ -1,222 +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_BlenderCanvas.h
- * \ingroup blroutines
- */
-
-#ifndef __KX_BLENDERCANVAS_H__
-#define __KX_BLENDERCANVAS_H__
-
-#ifdef WIN32
-#include <windows.h>
-#endif
-
-#include "RAS_ICanvas.h"
-#include "RAS_Rect.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-struct ARegion;
-struct wmWindow;
-struct wmWindowManager;
-
-/**
- * 2D Blender device context abstraction.
- * The connection from 3d rendercontext to 2d Blender surface embedding.
- */
-
-class KX_BlenderCanvas : public RAS_ICanvas
-{
-private:
- /**
- * Rect that defines the area used for rendering,
- * relative to the context */
- RAS_Rect m_displayarea;
- int m_viewport[4];
-
-public:
- /* Construct a new canvas.
- *
- * \param area The Blender ARegion to run the game within.
- */
- KX_BlenderCanvas(struct wmWindowManager *wm, struct wmWindow* win, RAS_Rect &rect, struct ARegion* ar);
- ~KX_BlenderCanvas();
-
- void
- Init(
- );
-
- void
- SwapBuffers(
- );
-
- void
- SetSwapInterval(
- int interval
- );
-
- bool
- GetSwapInterval(
- int &intervalOut
- );
-
- void GetDisplayDimensions(int &width, int &height);
-
- void
- ResizeWindow(
- int width,
- int height
- );
-
- void
- SetFullScreen(
- bool enable
- );
-
- bool
- GetFullScreen();
-
- void
- BeginFrame(
- );
-
- void
- EndFrame(
- );
-
- void
- ClearColor(
- float r,
- float g,
- float b,
- float a
- );
-
- void
- ClearBuffer(
- int type
- );
-
- int
- GetWidth(
- ) const;
-
- int
- GetHeight(
- ) const;
-
- int
- GetMouseX(int x
- );
-
- int
- GetMouseY(int y
- );
-
- float
- GetMouseNormalizedX(int x
- );
-
- float
- GetMouseNormalizedY(int y
- );
-
- const
- RAS_Rect &
- GetDisplayArea(
- ) const {
- return m_displayarea;
- };
-
- void
- SetDisplayArea(RAS_Rect *rect
- ) {
- m_displayarea= *rect;
- };
-
- RAS_Rect &
- GetWindowArea(
- );
-
- void
- SetViewPort(
- int x1, int y1,
- int x2, int y2
- );
-
- void
- UpdateViewPort(
- int x1, int y1,
- int x2, int y2
- );
-
- const int*
- GetViewPort();
-
- void
- SetMouseState(
- RAS_MouseState mousestate
- );
-
- void
- SetMousePosition(
- int x,
- int y
- );
-
- void
- MakeScreenShot(
- const char* filename
- );
-
- bool
- BeginDraw(
- );
-
- void
- EndDraw(
- );
-
-private:
- /** Blender area the game engine is running within */
- struct wmWindowManager *m_wm;
- struct wmWindow* m_win;
- RAS_Rect m_frame_rect;
- RAS_Rect m_area_rect;
- int m_area_left;
- int m_area_top;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderCanvas")
-#endif
-};
-
-#endif /* __KX_BLENDERCANVAS_H__ */
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.cpp
deleted file mode 100644
index 8d224051df4..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.cpp
+++ /dev/null
@@ -1,33 +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_BlenderInputDevice.cpp
- * \ingroup blroutines
- */
-
-#include "KX_BlenderInputDevice.h"
-
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
deleted file mode 100644
index a936f328545..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h
+++ /dev/null
@@ -1,80 +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_BlenderInputDevice.h
- * \ingroup blroutines
- */
-
-#ifndef __KX_BLENDERINPUTDEVICE_H__
-#define __KX_BLENDERINPUTDEVICE_H__
-
-#ifdef _MSC_VER
-# pragma warning(disable:4786) // shut off 255 char limit debug template warning
-#endif
-
-#include <map>
-
-#include "wm_event_types.h"
-#include "WM_types.h"
-#include "SCA_IInputDevice.h"
-#include "BL_BlenderDataConversion.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/**
- * Base Class for Blender specific inputdevices.
- * Blender specific inputdevices are used when the gameengine is running in embedded mode instead of standalone mode.
- */
-class BL_BlenderInputDevice : public SCA_IInputDevice
-{
-public:
- BL_BlenderInputDevice()
- {
- }
-
- virtual ~BL_BlenderInputDevice()
- {
-
- }
-
- KX_EnumInputs ToNative(unsigned short incode) {
- return ConvertKeyCode(incode);
- }
-
- virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
- // virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
- virtual bool ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode)=0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_BlenderInputDevice")
-#endif
-};
-
-#endif /* __KX_BLENDERINPUTDEVICE_H__ */
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
deleted file mode 100644
index ea78d2d389e..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp
+++ /dev/null
@@ -1,169 +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_BlenderKeyboardDevice.cpp
- * \ingroup blroutines
- */
-
-
-#ifdef _MSC_VER
- /* annoying warnings about truncated STL debug info */
-# pragma warning (disable:4786)
-#endif
-
-#include "KX_BlenderKeyboardDevice.h"
-#include "KX_KetsjiEngine.h"
-
-KX_BlenderKeyboardDevice::KX_BlenderKeyboardDevice()
- : m_hookesc(false)
-{
-
-}
-KX_BlenderKeyboardDevice::~KX_BlenderKeyboardDevice()
-{
-
-}
-
-/**
- * IsPressed gives boolean information about keyboard status, true if pressed, false if not
- */
-
-bool KX_BlenderKeyboardDevice::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
-{
- const SCA_InputEvent & inevent = m_eventStatusTables[m_currentTable][inputcode];
- bool pressed = (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- inevent.m_status == SCA_InputEvent::KX_ACTIVE);
- return pressed;
-}
-/*const SCA_InputEvent& KX_BlenderKeyboardDevice::GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)
-{
- return m_eventStatusTables[m_currentTable][inputcode];
-}
-*/
-/**
- * NextFrame toggles currentTable with previousTable,
- * and copy relevant event information from previous to current
- * (pressed keys need to be remembered)
- */
-void KX_BlenderKeyboardDevice::NextFrame()
-{
- SCA_IInputDevice::NextFrame();
-
- // now convert justpressed keyevents into regular (active) keyevents
- int previousTable = 1-m_currentTable;
- for (int keyevent= KX_BEGINKEY; keyevent<= KX_ENDKEY;keyevent++)
- {
- SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][keyevent];
- if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- oldevent.m_status == SCA_InputEvent::KX_ACTIVE )
- {
- m_eventStatusTables[m_currentTable][keyevent] = oldevent;
- m_eventStatusTables[m_currentTable][keyevent].m_status = SCA_InputEvent::KX_ACTIVE;
- }
- }
-}
-
-/**
- * ConvertBlenderEvent translates blender keyboard events into ketsji kbd events
- * extra event information is stored, like ramp-mode (just released/pressed)
-*/
-bool KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode)
-{
- bool result = false;
-
- // convert event
- KX_EnumInputs kxevent = this->ToNative(incode);
-
- // only process it, if it's a key
- if (kxevent >= KX_BEGINKEY && kxevent <= KX_ENDKEY)
- {
- int previousTable = 1-m_currentTable;
-
- if (val == KM_PRESS || val == KM_DBL_CLICK)
- {
- if (kxevent == KX_KetsjiEngine::GetExitKey() && val != 0 && !m_hookesc)
- result = true;
- if (kxevent == KX_PAUSEKEY && val && (IsPressed(KX_LEFTCTRLKEY) || IsPressed(KX_RIGHTCTRLKEY)))
- result = true;
-
- // todo: convert val ??
- m_eventStatusTables[m_currentTable][kxevent].m_eventval = val ; //???
- m_eventStatusTables[m_currentTable][kxevent].m_unicode = unicode;
-
- switch (m_eventStatusTables[previousTable][kxevent].m_status)
- {
- case SCA_InputEvent::KX_JUSTACTIVATED:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
- break;
- }
- case SCA_InputEvent::KX_ACTIVE:
-
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
- break;
- }
- case SCA_InputEvent::KX_NO_INPUTSTATUS:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
- break;
- }
- default:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
- }
- }
-
- } else if (val == KM_RELEASE)
- {
- // blender eventval == 0
- switch (m_eventStatusTables[previousTable][kxevent].m_status)
- {
- case SCA_InputEvent::KX_JUSTACTIVATED:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED;
- break;
- }
- case SCA_InputEvent::KX_ACTIVE:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED;
- break;
- }
- default:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS;
- }
- }
- }
- }
- return result;
-}
-
-void KX_BlenderKeyboardDevice::HookEscape()
-{
- m_hookesc = true;
-}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h
deleted file mode 100644
index 10a5b00937d..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h
+++ /dev/null
@@ -1,62 +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_BlenderKeyboardDevice.h
- * \ingroup blroutines
- */
-
-#ifndef __KX_BLENDERKEYBOARDDEVICE_H__
-#define __KX_BLENDERKEYBOARDDEVICE_H__
-
-#include "KX_BlenderInputDevice.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class KX_BlenderKeyboardDevice : public BL_BlenderInputDevice
-{
- bool m_hookesc;
-public:
- KX_BlenderKeyboardDevice();
- virtual ~KX_BlenderKeyboardDevice();
-
- virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
-// virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode);
- virtual bool ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode);
- virtual void NextFrame();
- virtual void HookEscape();
-private:
- /* short m_exit_key; */ /* UNUSED */
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderKeyboardDevice")
-#endif
-};
-
-#endif /* __KX_BLENDERKEYBOARDDEVICE_H__ */
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp
deleted file mode 100644
index 9df06e83b92..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp
+++ /dev/null
@@ -1,192 +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_BlenderMouseDevice.cpp
- * \ingroup blroutines
- */
-
-#ifdef _MSC_VER
- /* annoying warnings about truncated STL debug info */
-# pragma warning (disable:4786)
-#endif
-
-#include "KX_BlenderMouseDevice.h"
-
-KX_BlenderMouseDevice::KX_BlenderMouseDevice()
-{
-
-}
-KX_BlenderMouseDevice::~KX_BlenderMouseDevice()
-{
-
-}
-
-/**
- * IsPressed gives boolean information about mouse status, true if pressed, false if not
- */
-
-bool KX_BlenderMouseDevice::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
-{
- const SCA_InputEvent & inevent = m_eventStatusTables[m_currentTable][inputcode];
- bool pressed = (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- inevent.m_status == SCA_InputEvent::KX_ACTIVE);
- return pressed;
-}
-/*const SCA_InputEvent& KX_BlenderMouseDevice::GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)
-{
- return m_eventStatusTables[m_currentTable][inputcode];
-}
-*/
-
-/**
- * NextFrame toggles currentTable with previousTable,
- * and copy relevant event information from previous to current
- * (pressed keys need to be remembered)
- */
-void KX_BlenderMouseDevice::NextFrame()
-{
- SCA_IInputDevice::NextFrame();
-
- // now convert justpressed keyevents into regular (active) keyevents
- int previousTable = 1-m_currentTable;
- for (int mouseevent= KX_BEGINMOUSE; mouseevent< KX_ENDMOUSEBUTTONS;mouseevent++)
- {
- SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][mouseevent];
- if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- oldevent.m_status == SCA_InputEvent::KX_ACTIVE )
- {
- m_eventStatusTables[m_currentTable][mouseevent] = oldevent;
- m_eventStatusTables[m_currentTable][mouseevent].m_status = SCA_InputEvent::KX_ACTIVE;
- }
- }
- for (int mousemove= KX_ENDMOUSEBUTTONS; mousemove< KX_ENDMOUSE;mousemove++)
- {
- SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][mousemove];
- m_eventStatusTables[m_currentTable][mousemove] = oldevent;
- if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- oldevent.m_status == SCA_InputEvent::KX_ACTIVE )
- {
-
- m_eventStatusTables[m_currentTable][mousemove].m_status = SCA_InputEvent::KX_JUSTRELEASED;
- } else
- {
- if (oldevent.m_status == SCA_InputEvent::KX_JUSTRELEASED)
- {
-
- m_eventStatusTables[m_currentTable][mousemove].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS;
- }
- }
- }
-}
-
-
-/**
- * ConvertBlenderEvent translates blender mouse events into ketsji kbd events
- * extra event information is stored, like ramp-mode (just released/pressed)
- */
-bool KX_BlenderMouseDevice::ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode)
-{
- bool result = false;
-
- // convert event
- KX_EnumInputs kxevent = this->ToNative(incode);
- int previousTable = 1-m_currentTable;
-
- // only process it, if it's a key
- if (kxevent > KX_BEGINMOUSE && kxevent < KX_ENDMOUSEBUTTONS)
- {
- if (val == KM_PRESS || val == KM_DBL_CLICK)
- {
- m_eventStatusTables[m_currentTable][kxevent].m_eventval = val ; //???
-
- switch (m_eventStatusTables[previousTable][kxevent].m_status)
- {
-
- case SCA_InputEvent::KX_ACTIVE:
- case SCA_InputEvent::KX_JUSTACTIVATED:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
- break;
- }
- case SCA_InputEvent::KX_JUSTRELEASED:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
- break;
- }
- default:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
- }
- }
-
- } else if (val == KM_RELEASE)
- {
- // blender eventval == 0
- switch (m_eventStatusTables[previousTable][kxevent].m_status)
- {
- case SCA_InputEvent::KX_JUSTACTIVATED:
- case SCA_InputEvent::KX_ACTIVE:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED;
- break;
- }
- default:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS;
- }
- }
- }
- }
-
- if (kxevent > KX_ENDMOUSEBUTTONS && kxevent < KX_ENDMOUSE)
- {
- m_eventStatusTables[m_currentTable][kxevent].m_eventval = val ; //remember mouse position
-
- switch (m_eventStatusTables[previousTable][kxevent].m_status)
- {
-
- case SCA_InputEvent::KX_ACTIVE:
- case SCA_InputEvent::KX_JUSTACTIVATED:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
- break;
- }
- case SCA_InputEvent::KX_JUSTRELEASED:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
- break;
- }
- default:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
- }
- }
- }
-
-
- return result;
-}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h
deleted file mode 100644
index 04b78aff05c..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h
+++ /dev/null
@@ -1,58 +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_BlenderMouseDevice.h
- * \ingroup blroutines
- */
-
-#ifndef __KX_BLENDERMOUSEDEVICE_H__
-#define __KX_BLENDERMOUSEDEVICE_H__
-
-#include "KX_BlenderInputDevice.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class KX_BlenderMouseDevice : public BL_BlenderInputDevice
-{
-public:
- KX_BlenderMouseDevice();
- virtual ~KX_BlenderMouseDevice();
-
- virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
-// virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode);
- virtual bool ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode);
- virtual void NextFrame();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderMouseDevice")
-#endif
-};
-
-#endif /* __KX_BLENDERMOUSEDEVICE_H__ */
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp b/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp
deleted file mode 100644
index 0582e79d269..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderSystem.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/BlenderRoutines/KX_BlenderSystem.cpp
- * \ingroup blroutines
- */
-
-
-#include "KX_ISystem.h"
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#ifdef WIN32
-#include <windows.h>
-#endif
-
-#include <iostream>
-#include <stdio.h>
-#include "KX_BlenderInputDevice.h"
-#include "KX_BlenderSystem.h"
-
-#include "PIL_time.h"
-
-KX_BlenderSystem::KX_BlenderSystem()
-: KX_ISystem()
-{
- m_starttime = PIL_check_seconds_timer();
-}
-
-double KX_BlenderSystem::GetTimeInSeconds()
-{
- return PIL_check_seconds_timer() - m_starttime;
-}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderSystem.h b/source/gameengine/BlenderRoutines/KX_BlenderSystem.h
deleted file mode 100644
index 0867ef2421f..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderSystem.h
+++ /dev/null
@@ -1,56 +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_BlenderSystem.h
- * \ingroup blroutines
- * \brief Blender System embedding. Needed when gameengine runs embedded within Blender.
- */
-
-#ifndef __KX_BLENDERSYSTEM_H__
-#define __KX_BLENDERSYSTEM_H__
-
-#include "KX_ISystem.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class KX_BlenderSystem : public KX_ISystem
-{
- double m_starttime;
-
-public:
- KX_BlenderSystem();
- virtual ~KX_BlenderSystem() {}
- virtual double GetTimeInSeconds();
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderSystem")
-#endif
-};
-
-#endif /* __KX_BLENDERSYSTEM_H__ */
diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt
deleted file mode 100644
index 62523175f46..00000000000
--- a/source/gameengine/CMakeLists.txt
+++ /dev/null
@@ -1,57 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-remove_extra_strict_flags()
-
-# there are too many inter-includes so best define here
-if(WITH_PYTHON)
- blender_include_dirs_sys("${PYTHON_INCLUDE_DIRS}")
- add_definitions(-DWITH_PYTHON)
-endif()
-
-add_subdirectory(BlenderRoutines)
-add_subdirectory(Converter)
-add_subdirectory(Expressions)
-add_subdirectory(GameLogic)
-add_subdirectory(Ketsji)
-add_subdirectory(Ketsji/KXNetwork)
-add_subdirectory(Network)
-add_subdirectory(Network/LoopBackNetwork)
-add_subdirectory(Physics/Dummy)
-add_subdirectory(Rasterizer)
-add_subdirectory(Rasterizer/RAS_OpenGLRasterizer)
-add_subdirectory(SceneGraph)
-
-if(WITH_BULLET)
- add_subdirectory(Physics/Bullet)
-endif()
-
-if(WITH_PYTHON)
- add_subdirectory(VideoTexture)
-endif()
-
-if(WITH_PLAYER)
- add_subdirectory(GamePlayer)
-endif()
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
deleted file mode 100644
index d28cdb84275..00000000000
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ /dev/null
@@ -1,664 +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/Converter/BL_ActionActuator.cpp
- * \ingroup bgeconv
- */
-
-
-#include "SCA_LogicManager.h"
-#include "BL_ActionActuator.h"
-#include "BL_ArmatureObject.h"
-#include "BL_SkinDeformer.h"
-#include "BL_Action.h"
-#include "BL_ActionManager.h"
-#include "KX_GameObject.h"
-#include "STR_HashedString.h"
-#include "MEM_guardedalloc.h"
-#include "DNA_nla_types.h"
-#include "DNA_action_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_scene_types.h"
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-#include "MT_Matrix4x4.h"
-
-#include "BKE_action.h"
-#include "EXP_FloatValue.h"
-#include "EXP_PyObjectPlus.h"
-#include "KX_PyMath.h"
-
-extern "C" {
-#include "BKE_animsys.h"
-#include "BKE_action.h"
-#include "RNA_access.h"
-#include "RNA_define.h"
-}
-
-BL_ActionActuator::BL_ActionActuator(SCA_IObject *gameobj,
- const STR_String& propname,
- const STR_String& framepropname,
- float starttime,
- float endtime,
- struct bAction *action,
- short playtype,
- short blend_mode,
- short blendin,
- short priority,
- short layer,
- float layer_weight,
- short ipo_flags,
- short end_reset,
- float stride)
- : SCA_IActuator(gameobj, KX_ACT_ACTION),
-
- m_lastpos(0, 0, 0),
- m_blendframe(0),
- m_flag(0),
- m_startframe (starttime),
- m_endframe(endtime) ,
- m_starttime(0),
- m_localtime(starttime),
- m_lastUpdate(-1),
- m_blendin(blendin),
- m_blendstart(0),
- m_stridelength(stride),
- m_layer_weight(layer_weight),
- m_playtype(playtype),
- m_blendmode(blend_mode),
- m_priority(priority),
- m_layer(layer),
- m_ipo_flags(ipo_flags),
- m_action(action),
- m_propname(propname),
- m_framepropname(framepropname)
-{
- if (!end_reset)
- m_flag |= ACT_FLAG_CONTINUE;
-};
-
-BL_ActionActuator::~BL_ActionActuator()
-{
-}
-
-void BL_ActionActuator::ProcessReplica()
-{
- SCA_IActuator::ProcessReplica();
-
- m_localtime=m_startframe;
- m_lastUpdate=-1;
-
-}
-
-void BL_ActionActuator::SetBlendTime(float newtime)
-{
- m_blendframe = newtime;
-}
-
-void BL_ActionActuator::SetLocalTime(float curtime)
-{
- float dt = (curtime-m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
-
- if (m_endframe < m_startframe)
- dt = -dt;
-
- m_localtime = m_startframe + dt;
-
- // Handle wrap around
- if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe))
- {
- switch (m_playtype) {
- case ACT_ACTION_PLAY:
- // Clamp
- m_localtime = m_endframe;
- break;
- case ACT_ACTION_LOOP_END:
- // Put the time back to the beginning
- m_localtime = m_startframe;
- m_starttime = curtime;
- break;
- case ACT_ACTION_PINGPONG:
- // Swap the start and end frames
- float temp = m_startframe;
- m_startframe = m_endframe;
- m_endframe = temp;
-
- m_starttime = curtime;
-
- m_flag ^= ACT_FLAG_REVERSE;
-
- break;
- }
- }
-}
-
-void BL_ActionActuator::ResetStartTime(float curtime)
-{
- float dt = m_localtime - m_startframe;
-
- m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate());
- //SetLocalTime(curtime);
-}
-
-CValue* BL_ActionActuator::GetReplica()
-{
- BL_ActionActuator* replica = new BL_ActionActuator(*this);//m_float,GetName());
- replica->ProcessReplica();
- return replica;
-}
-
-bool BL_ActionActuator::Update(double curtime, bool frame)
-{
- bool bNegativeEvent = false;
- bool bPositiveEvent = false;
- bool bUseContinue = false;
- KX_GameObject *obj = (KX_GameObject*)GetParent();
- short playtype = BL_Action::ACT_MODE_PLAY;
- short blendmode = (m_blendmode == ACT_ACTION_ADD) ? BL_Action::ACT_BLEND_ADD : BL_Action::ACT_BLEND_BLEND;
- float start = m_startframe;
- float end = m_endframe;
-
- // If we don't have an action, we can't do anything
- if (!m_action)
- return false;
-
- // Convert our playtype to one that BL_Action likes
- switch (m_playtype) {
- case ACT_ACTION_LOOP_END:
- case ACT_ACTION_LOOP_STOP:
- playtype = BL_Action::ACT_MODE_LOOP;
- break;
-
- case ACT_ACTION_PINGPONG:
- // We handle ping pong ourselves to increase compabitility
- // with files made prior to animation changes from GSoC 2011.
- playtype = BL_Action::ACT_MODE_PLAY;
-
- if (m_flag & ACT_FLAG_REVERSE)
- {
- start = m_endframe;
- end = m_startframe;
- }
-
- break;
- case ACT_ACTION_FROM_PROP:
- CValue* prop = GetParent()->GetProperty(m_propname);
-
- // If we don't have a property, we can't do anything, so just bail
- if (!prop) return false;
-
- playtype = BL_Action::ACT_MODE_PLAY;
- start = end = prop->GetNumber();
-
- break;
- }
-
- if (m_flag & ACT_FLAG_CONTINUE)
- bUseContinue = true;
-
-
- // Handle events
- if (frame)
- {
- bNegativeEvent = m_negevent;
- bPositiveEvent = m_posevent;
- RemoveAllEvents();
- }
-
- // "Active" actions need to keep updating their current frame
- if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE))
- m_localtime = obj->GetActionFrame(m_layer);
-
- if (m_flag & ACT_FLAG_ATTEMPT_PLAY)
- SetLocalTime(curtime);
- else
- ResetStartTime(curtime);
-
- // Handle a frame property if it's defined
- if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0)
- {
- CValue* oldprop = obj->GetProperty(m_framepropname);
- CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer));
- if (oldprop)
- oldprop->SetValue(newval);
- else
- obj->SetProperty(m_framepropname, newval);
-
- newval->Release();
- }
-
- // Handle a finished animation
- if ((m_flag & ACT_FLAG_PLAY_END) && (m_flag & ACT_FLAG_ACTIVE) && obj->IsActionDone(m_layer))
- {
- m_flag &= ~ACT_FLAG_ACTIVE;
-
- if (m_playtype == ACT_ACTION_PINGPONG) {
- m_flag ^= ACT_FLAG_REVERSE;
- }
- else {
- m_flag &= ~ACT_FLAG_ATTEMPT_PLAY;
- return false;
- }
- }
-
- // If a different action is playing, we've been overruled and are no longer active
- if (obj->GetCurrentAction(m_layer) != m_action && !obj->IsActionDone(m_layer))
- m_flag &= ~ACT_FLAG_ACTIVE;
-
- if (bPositiveEvent || (m_flag & ACT_FLAG_ATTEMPT_PLAY && !(m_flag & ACT_FLAG_ACTIVE)))
- {
- if (bPositiveEvent && m_playtype == ACT_ACTION_PLAY)
- {
- if (obj->IsActionDone(m_layer))
- m_localtime = start;
- ResetStartTime(curtime);
- }
-
- if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags, 1.f, blendmode))
- {
- m_flag |= ACT_FLAG_ACTIVE;
- if (bUseContinue)
- obj->SetActionFrame(m_layer, m_localtime);
-
- if (m_playtype == ACT_ACTION_PLAY || m_playtype == ACT_ACTION_PINGPONG)
- m_flag |= ACT_FLAG_PLAY_END;
- else
- m_flag &= ~ACT_FLAG_PLAY_END;
- }
- m_flag |= ACT_FLAG_ATTEMPT_PLAY;
- }
- else if ((m_flag & ACT_FLAG_ACTIVE) && bNegativeEvent)
- {
- m_flag &= ~ACT_FLAG_ATTEMPT_PLAY;
- m_localtime = obj->GetActionFrame(m_layer);
- bAction *curr_action = obj->GetCurrentAction(m_layer);
- if (curr_action && curr_action != m_action)
- {
- // Someone changed the action on us, so we wont mess with it
- // Hopefully there wont be too many problems with two actuators using
- // the same action...
- m_flag &= ~ACT_FLAG_ACTIVE;
- return false;
- }
-
- switch (m_playtype) {
- case ACT_ACTION_FROM_PROP:
- case ACT_ACTION_LOOP_STOP:
- obj->StopAction(m_layer); // Stop the action after getting the frame
-
- // We're done
- m_flag &= ~ACT_FLAG_ACTIVE;
- return false;
- case ACT_ACTION_LOOP_END:
- // Convert into a play and let it finish
- obj->SetPlayMode(m_layer, BL_Action::ACT_MODE_PLAY);
-
- m_flag |= ACT_FLAG_PLAY_END;
- break;
-
- case ACT_ACTION_FLIPPER:
- // Convert into a play action and play back to the beginning
- float temp = end;
- end = start;
- start = curr_action ? obj->GetActionFrame(m_layer) : temp;
- obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags, 1.f, blendmode);
-
- m_flag |= ACT_FLAG_PLAY_END;
- break;
- }
- }
-
- return m_flag & ACT_FLAG_ACTIVE;
-}
-
-void BL_ActionActuator::DecLink()
-{
- SCA_IActuator::DecLink();
- /* In this case no controllers use this action actuator,
- and it should stop its action. */
- if (m_links == 0) {
- KX_GameObject *obj = (KX_GameObject *)GetParent();
- obj->StopAction(m_layer);
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-PyObject *BL_ActionActuator::PyGetChannel(PyObject *value)
-{
- PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.getChannel() no longer works, please use BL_ArmatureObject.channels instead");
- return NULL;
-#if 0 // XXX To be removed in a later version (first removed in 2.64)
- const char *string= _PyUnicode_AsString(value);
-
- if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
- {
- PyErr_SetString(PyExc_NotImplementedError, "actuator.getChannel(): Only armatures support channels");
- return NULL;
- }
-
- if (!string) {
- PyErr_SetString(PyExc_TypeError, "expected a single string");
- return NULL;
- }
-
- bPoseChannel *pchan;
-
- if (m_userpose==NULL && m_pose==NULL) {
- BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
- obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
- }
-
- // BKE_pose_channel_find_name accounts for NULL pose, run on both in case one exists but
- // the channel doesnt
- if ( !(pchan=BKE_pose_channel_find_name(m_userpose, string)) &&
- !(pchan=BKE_pose_channel_find_name(m_pose, string)) )
- {
- PyErr_SetString(PyExc_ValueError, "channel doesnt exist");
- return NULL;
- }
-
- PyObject *ret = PyTuple_New(3);
-
- PyObject *list = PyList_New(3);
- PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->loc[0]));
- PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->loc[1]));
- PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->loc[2]));
- PyTuple_SET_ITEM(ret, 0, list);
-
- list = PyList_New(3);
- PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->size[0]));
- PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->size[1]));
- PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->size[2]));
- PyTuple_SET_ITEM(ret, 1, list);
-
- list = PyList_New(4);
- PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->quat[0]));
- PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->quat[1]));
- PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->quat[2]));
- PyList_SET_ITEM(list, 3, PyFloat_FromDouble(pchan->quat[3]));
- PyTuple_SET_ITEM(ret, 2, list);
-
- return ret;
-#if 0
- return Py_BuildValue("([fff][fff][ffff])",
- pchan->loc[0], pchan->loc[1], pchan->loc[2],
- pchan->size[0], pchan->size[1], pchan->size[2],
- pchan->quat[0], pchan->quat[1], pchan->quat[2], pchan->quat[3] );
-#endif
-#endif
-}
-
-/* setChannel */
-KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
-"setChannel(channel, matrix)\n"
-"\t - channel : A string specifying the name of the bone channel.\n"
-"\t - matrix : A 4x4 matrix specifying the overriding transformation\n"
-"\t as an offset from the bone's rest position.\n")
-{
- PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.setChannel() no longer works, please use BL_ArmatureObject.channels instead");
- return NULL;
-
-#if 0 // XXX To be removed in a later version (first removed in 2.64)
- BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
- char *string;
- PyObject *pymat= NULL;
- PyObject *pyloc= NULL, *pysize= NULL, *pyquat= NULL;
- bPoseChannel *pchan;
-
- if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
- {
- PyErr_SetString(PyExc_NotImplementedError, "actuator.setChannel(): Only armatures support channels");
- return NULL;
- }
-
- if (PyTuple_Size(args)==2) {
- if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix
- return NULL;
- }
- else if (PyTuple_Size(args)==4) {
- if (!PyArg_ParseTuple(args,"sOOO:setChannel", &string, &pyloc, &pysize, &pyquat)) // loc/size/quat
- return NULL;
- }
- else {
- PyErr_SetString(PyExc_ValueError, "Expected a string and a 4x4 matrix (2 args) or a string and loc/size/quat sequences (4 args)");
- return NULL;
- }
-
- if (pymat) {
- float matrix[4][4];
- MT_Matrix4x4 mat;
-
- if (!PyMatTo(pymat, mat))
- return NULL;
-
- mat.getValue((float*)matrix);
-
- BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
-
- if (!m_userpose) {
- if (!m_pose)
- obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
- game_copy_pose(&m_userpose, m_pose, 0);
- }
- // pchan= BKE_pose_channel_verify(m_userpose, string); // adds the channel if its not there.
- pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there.
-
- if (pchan) {
- copy_v3_v3(pchan->loc, matrix[3]);
- mat4_to_size(pchan->size, matrix);
- mat4_to_quat(pchan->quat, matrix);
- }
- }
- else {
- MT_Vector3 loc;
- MT_Vector3 size;
- MT_Quaternion quat;
-
- if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyQuatTo(pyquat, quat))
- return NULL;
-
- // same as above
- if (!m_userpose) {
- if (!m_pose)
- obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
- game_copy_pose(&m_userpose, m_pose, 0);
- }
- // pchan= BKE_pose_channel_verify(m_userpose, string);
- pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there.
-
- // for some reason loc.setValue(pchan->loc) fails
- if (pchan) {
- pchan->loc[0] = loc[0]; pchan->loc[1] = loc[1]; pchan->loc[2] = loc[2];
- pchan->size[0] = size[0]; pchan->size[1] = size[1]; pchan->size[2] = size[2];
- pchan->quat[0] = quat[3]; pchan->quat[1] = quat[0]; pchan->quat[2] = quat[1]; pchan->quat[3] = quat[2]; /* notice xyzw -> wxyz is intentional */
- }
- }
-
- if (pchan==NULL) {
- PyErr_SetString(PyExc_ValueError, "Channel could not be found, use the 'channelNames' attribute to get a list of valid channels");
- return NULL;
- }
-
- Py_RETURN_NONE;
-#endif
-}
-
-/* ------------------------------------------------------------------------- */
-/* Python Integration Hooks */
-/* ------------------------------------------------------------------------- */
-
-PyTypeObject BL_ActionActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "BL_ActionActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef BL_ActionActuator::Methods[] = {
- {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_O},
- KX_PYMETHODTABLE(BL_ActionActuator, setChannel),
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef BL_ActionActuator::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RW("frameStart", 0, MAXFRAMEF, BL_ActionActuator, m_startframe),
- KX_PYATTRIBUTE_FLOAT_RW("frameEnd", 0, MAXFRAMEF, BL_ActionActuator, m_endframe),
- KX_PYATTRIBUTE_FLOAT_RW("blendIn", 0, MAXFRAMEF, BL_ActionActuator, m_blendin),
- KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action),
- KX_PYATTRIBUTE_RO_FUNCTION("channelNames", BL_ActionActuator, pyattr_get_channel_names),
- KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
- KX_PYATTRIBUTE_SHORT_RW("layer", 0, MAX_ACTION_LAYERS-1, true, BL_ActionActuator, m_layer),
- KX_PYATTRIBUTE_FLOAT_RW("layerWeight", 0, 1.0, BL_ActionActuator, m_layer_weight),
- KX_PYATTRIBUTE_RW_FUNCTION("frame", BL_ActionActuator, pyattr_get_frame, pyattr_set_frame),
- KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, BL_ActionActuator, m_propname),
- KX_PYATTRIBUTE_STRING_RW("framePropName", 0, MAX_PROP_NAME, false, BL_ActionActuator, m_framepropname),
- KX_PYATTRIBUTE_RW_FUNCTION("useContinue", BL_ActionActuator, pyattr_get_use_continue, pyattr_set_use_continue),
- KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
- KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",0,100,false,BL_ActionActuator,m_playtype,CheckType),
- { NULL } //Sentinel
-};
-
-PyObject *BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
- return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
-}
-
-int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
-
- if (!PyUnicode_Check(value))
- {
- PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action");
- return PY_SET_ATTR_FAIL;
- }
-
- bAction *action= NULL;
- STR_String val = _PyUnicode_AsString(value);
-
- if (val != "")
- {
- action= (bAction*)self->GetLogicManager()->GetActionByName(val);
- if (!action)
- {
- PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!");
- return PY_SET_ATTR_FAIL;
- }
- }
-
- self->SetAction(action);
- return PY_SET_ATTR_SUCCESS;
-
-}
-
-PyObject *BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.channelNames no longer works, please use BL_ArmatureObject.channels instead");
- return NULL;
-
-#if 0 // XXX To be removed in a later version (first removed in 2.64)
- BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
- PyObject *ret= PyList_New(0);
- PyObject *item;
-
- if (self->GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
- {
- PyErr_SetString(PyExc_NotImplementedError, "actuator.channelNames: Only armatures support channels");
- return NULL;
- }
-
- bPose *pose= ((BL_ArmatureObject*)self->GetParent())->GetOrigPose();
-
- if (pose) {
- bPoseChannel *pchan;
- for (pchan= (bPoseChannel *)pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) {
- item= PyUnicode_FromString(pchan->name);
- PyList_Append(ret, item);
- Py_DECREF(item);
- }
- }
-
- return ret;
-#endif
-}
-
-PyObject *BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
- return PyBool_FromLong(self->m_flag & ACT_FLAG_CONTINUE);
-}
-
-int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
-
- if (PyObject_IsTrue(value))
- self->m_flag |= ACT_FLAG_CONTINUE;
- else
- self->m_flag &= ~ACT_FLAG_CONTINUE;
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *BL_ActionActuator::pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
- return PyFloat_FromDouble(((KX_GameObject*)self->m_gameobj)->GetActionFrame(self->m_layer));
-}
-
-int BL_ActionActuator::pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
-
- ((KX_GameObject*)self->m_gameobj)->SetActionFrame(self->m_layer, PyFloat_AsDouble(value));
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
deleted file mode 100644
index a43cf0f0a7b..00000000000
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ /dev/null
@@ -1,158 +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 BL_ActionActuator.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_ACTIONACTUATOR_H__
-#define __BL_ACTIONACTUATOR_H__
-
-#include "CTR_HashedPtr.h"
-#include "SCA_IActuator.h"
-#include "DNA_actuator_types.h"
-#include "MT_Point3.h"
-
-class BL_ActionActuator : public SCA_IActuator
-{
-public:
- Py_Header
- BL_ActionActuator(SCA_IObject* gameobj,
- const STR_String& propname,
- const STR_String& framepropname,
- float starttime,
- float endtime,
- struct bAction *action,
- short playtype,
- short blend_mode,
- short blendin,
- short priority,
- short layer,
- float layer_weight,
- short ipo_flags,
- short end_reset,
- float stride);
-
- virtual ~BL_ActionActuator();
- virtual bool Update(double curtime, bool frame);
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
-
- void SetBlendTime(float newtime);
- void SetLocalTime(float curtime);
- void ResetStartTime(float curtime);
-
- bAction* GetAction() { return m_action; }
- void SetAction(bAction* act) { m_action= act; }
-
- virtual void DecLink();
-
-#ifdef WITH_PYTHON
-
- KX_PYMETHOD_O(BL_ActionActuator,GetChannel)
- KX_PYMETHOD_DOC(BL_ActionActuator,setChannel)
-
- static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static int CheckBlendTime(void *self, const PyAttributeDef*)
- {
- BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
-
- if (act->m_blendframe > act->m_blendin)
- act->m_blendframe = act->m_blendin;
-
- return 0;
- }
-
- static int CheckType(void *self, const PyAttributeDef*)
- {
- BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
-
- switch (act->m_playtype) {
- case ACT_ACTION_PLAY:
- case ACT_ACTION_PINGPONG:
- case ACT_ACTION_FLIPPER:
- case ACT_ACTION_LOOP_STOP:
- case ACT_ACTION_LOOP_END:
- case ACT_ACTION_FROM_PROP:
- return 0;
- default:
- PyErr_SetString(PyExc_ValueError, "Action Actuator, invalid play type supplied");
- return 1;
- }
- }
-#endif /* WITH_PYTHON */
-
-protected:
- MT_Point3 m_lastpos;
- float m_blendframe;
- int m_flag;
- /** The frame this action starts */
- float m_startframe;
- /** The frame this action ends */
- float m_endframe;
- /** The time this action started */
- float m_starttime;
- /** The current time of the action */
- float m_localtime;
-
- float m_lastUpdate;
- float m_blendin;
- float m_blendstart;
- float m_stridelength;
- float m_layer_weight;
- short m_playtype;
- short m_blendmode;
- short m_priority;
- short m_layer;
- short m_ipo_flags;
- struct bAction *m_action;
- STR_String m_propname;
- STR_String m_framepropname;
-};
-
-// Not all of these values are used in BL_ActionActuator anymore,
-// but BL_ShapeActionActuator still uses them, so we keep them around
-// for now.
-enum {
- ACT_FLAG_REVERSE = 1<<0,
- ACT_FLAG_LOCKINPUT = 1<<1,
- ACT_FLAG_KEYUP = 1<<2,
- ACT_FLAG_ACTIVE = 1<<3,
- ACT_FLAG_CONTINUE = 1<<4,
- ACT_FLAG_PLAY_END = 1<<5,
- ACT_FLAG_ATTEMPT_PLAY = 1<<6,
-};
-
-#endif
-
diff --git a/source/gameengine/Converter/BL_ArmatureActuator.cpp b/source/gameengine/Converter/BL_ArmatureActuator.cpp
deleted file mode 100644
index 67cc7d2c291..00000000000
--- a/source/gameengine/Converter/BL_ArmatureActuator.cpp
+++ /dev/null
@@ -1,271 +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/Converter/BL_ArmatureActuator.cpp
- * \ingroup bgeconv
- */
-
-
-#include "DNA_action_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_actuator_types.h"
-#include "BKE_constraint.h"
-#include "BL_ArmatureActuator.h"
-#include "BL_ArmatureObject.h"
-#include "BLI_math.h"
-
-/**
- * This class is the conversion of the Pose channel constraint.
- * It makes a link between the pose constraint and the KX scene.
- * The main purpose is to give access to the constraint target
- * to link it to a game object.
- * It also allows to activate/deactivate constraints during the game.
- * Later it will also be possible to create constraint on the fly
- */
-
-BL_ArmatureActuator::BL_ArmatureActuator(SCA_IObject* obj,
- int type,
- const char *posechannel,
- const char *constraintname,
- KX_GameObject* targetobj,
- KX_GameObject* subtargetobj,
- float weight,
- float influence) :
- SCA_IActuator(obj, KX_ACT_ARMATURE),
- m_constraint(NULL),
- m_gametarget(targetobj),
- m_gamesubtarget(subtargetobj),
- m_posechannel(posechannel),
- m_constraintname(constraintname),
- m_weight(weight),
- m_influence(influence),
- m_type(type)
-{
- if (m_gametarget)
- m_gametarget->RegisterActuator(this);
- if (m_gamesubtarget)
- m_gamesubtarget->RegisterActuator(this);
- FindConstraint();
-}
-
-BL_ArmatureActuator::~BL_ArmatureActuator()
-{
- if (m_gametarget)
- m_gametarget->UnregisterActuator(this);
- if (m_gamesubtarget)
- m_gamesubtarget->UnregisterActuator(this);
-}
-
-void BL_ArmatureActuator::ProcessReplica()
-{
- // the replica is tracking the same object => register it (this may be changed in Relnk())
- if (m_gametarget)
- m_gametarget->RegisterActuator(this);
- if (m_gamesubtarget)
- m_gamesubtarget->UnregisterActuator(this);
- SCA_IActuator::ProcessReplica();
-}
-
-void BL_ArmatureActuator::ReParent(SCA_IObject* parent)
-{
- SCA_IActuator::ReParent(parent);
- // must remap the constraint
- FindConstraint();
-}
-
-bool BL_ArmatureActuator::UnlinkObject(SCA_IObject* clientobj)
-{
- bool res=false;
- if (clientobj == m_gametarget)
- {
- // this object is being deleted, we cannot continue to track it.
- m_gametarget = NULL;
- res = true;
- }
- if (clientobj == m_gamesubtarget)
- {
- // this object is being deleted, we cannot continue to track it.
- m_gamesubtarget = NULL;
- res = true;
- }
- return res;
-}
-
-void BL_ArmatureActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_gametarget];
- if (h_obj) {
- if (m_gametarget)
- m_gametarget->UnregisterActuator(this);
- m_gametarget = (KX_GameObject*)(*h_obj);
- m_gametarget->RegisterActuator(this);
- }
- h_obj = (*obj_map)[m_gamesubtarget];
- if (h_obj) {
- if (m_gamesubtarget)
- m_gamesubtarget->UnregisterActuator(this);
- m_gamesubtarget = (KX_GameObject*)(*h_obj);
- m_gamesubtarget->RegisterActuator(this);
- }
-}
-
-void BL_ArmatureActuator::FindConstraint()
-{
- m_constraint = NULL;
-
- if (m_gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) {
- BL_ArmatureObject* armobj = (BL_ArmatureObject*)m_gameobj;
- m_constraint = armobj->GetConstraint(m_posechannel, m_constraintname);
- }
-}
-
-bool BL_ArmatureActuator::Update(double curtime, bool frame)
-{
- // the only role of this actuator is to ensure that the armature pose will be evaluated
- bool result = false;
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (!bNegativeEvent) {
- BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
- switch (m_type) {
- case ACT_ARM_RUN:
- result = true;
- obj->UpdateTimestep(curtime);
- break;
- case ACT_ARM_ENABLE:
- if (m_constraint)
- m_constraint->ClrConstraintFlag(CONSTRAINT_OFF);
- break;
- case ACT_ARM_DISABLE:
- if (m_constraint)
- m_constraint->SetConstraintFlag(CONSTRAINT_OFF);
- break;
- case ACT_ARM_SETTARGET:
- if (m_constraint) {
- m_constraint->SetTarget(m_gametarget);
- m_constraint->SetSubtarget(m_gamesubtarget);
- }
- break;
- case ACT_ARM_SETWEIGHT:
- if (m_constraint)
- m_constraint->SetWeight(m_weight);
- break;
- case ACT_ARM_SETINFLUENCE:
- if (m_constraint)
- m_constraint->SetInfluence(m_influence);
- break;
- }
- }
- return result;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python Integration Hooks */
-/* ------------------------------------------------------------------------- */
-
-PyTypeObject BL_ArmatureActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "BL_ArmatureActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-
-PyMethodDef BL_ArmatureActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef BL_ArmatureActuator::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("constraint", BL_ArmatureActuator, pyattr_get_constraint),
- KX_PYATTRIBUTE_RW_FUNCTION("target", BL_ArmatureActuator, pyattr_get_object, pyattr_set_object),
- KX_PYATTRIBUTE_RW_FUNCTION("subtarget", BL_ArmatureActuator, pyattr_get_object, pyattr_set_object),
- KX_PYATTRIBUTE_FLOAT_RW("weight",0.0f,1.0f,BL_ArmatureActuator,m_weight),
- KX_PYATTRIBUTE_FLOAT_RW("influence",0.0f,1.0f,BL_ArmatureActuator,m_influence),
- KX_PYATTRIBUTE_INT_RW("type",0,ACT_ARM_MAXTYPE,false,BL_ArmatureActuator,m_type),
- { NULL } //Sentinel
-};
-
-PyObject *BL_ArmatureActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- BL_ArmatureActuator* actuator = static_cast<BL_ArmatureActuator*>(self);
- KX_GameObject *target = (!strcmp(attrdef->m_name, "target")) ? actuator->m_gametarget : actuator->m_gamesubtarget;
- if (!target)
- Py_RETURN_NONE;
- else
- return target->GetProxy();
-}
-
-int BL_ArmatureActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- BL_ArmatureActuator* actuator = static_cast<BL_ArmatureActuator*>(self);
- KX_GameObject* &target = (!strcmp(attrdef->m_name, "target")) ? actuator->m_gametarget : actuator->m_gamesubtarget;
- KX_GameObject *gameobj;
-
- if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: BL_ArmatureActuator"))
- return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
-
- if (target != NULL)
- target->UnregisterActuator(actuator);
-
- target = gameobj;
-
- if (target)
- target->RegisterActuator(actuator);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *BL_ArmatureActuator::pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- BL_ArmatureActuator* actuator = static_cast<BL_ArmatureActuator*>(self);
- BL_ArmatureConstraint* constraint = actuator->m_constraint;
- if (!constraint)
- Py_RETURN_NONE;
- else
- return constraint->GetProxy();
-}
-
-#endif // WITH_PYTHON
-
diff --git a/source/gameengine/Converter/BL_ArmatureActuator.h b/source/gameengine/Converter/BL_ArmatureActuator.h
deleted file mode 100644
index ba02c5aa362..00000000000
--- a/source/gameengine/Converter/BL_ArmatureActuator.h
+++ /dev/null
@@ -1,96 +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 BL_ArmatureActuator.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_ARMATUREACTUATOR_H__
-#define __BL_ARMATUREACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "BL_ArmatureConstraint.h"
-
-/**
- * This class is the conversion of the Pose channel constraint.
- * It makes a link between the pose constraint and the KX scene.
- * The main purpose is to give access to the constraint target
- * to link it to a game object.
- * It also allows to activate/deactivate constraints during the game.
- * Later it will also be possible to create constraint on the fly
- */
-
-class BL_ArmatureActuator : public SCA_IActuator
-{
- Py_Header
-public:
- BL_ArmatureActuator(SCA_IObject* gameobj,
- int type,
- const char *posechannel,
- const char *constraintname,
- KX_GameObject* targetobj,
- KX_GameObject* subtargetobj,
- float weight,
- float influence);
-
- virtual ~BL_ArmatureActuator();
-
- virtual CValue* GetReplica() {
- BL_ArmatureActuator* replica = new BL_ArmatureActuator(*this);
- replica->ProcessReplica();
- return replica;
- };
- virtual void ProcessReplica();
- virtual bool UnlinkObject(SCA_IObject* clientobj);
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
- virtual bool Update(double curtime, bool frame);
- virtual void ReParent(SCA_IObject* parent);
-
-#ifdef WITH_PYTHON
-
- /* These are used to get and set m_target */
- static PyObject *pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
-#endif /* WITH_PYTHON */
-
-private:
- // identify the constraint that this actuator controls
- void FindConstraint();
-
- BL_ArmatureConstraint* m_constraint;
- KX_GameObject* m_gametarget;
- KX_GameObject* m_gamesubtarget;
- STR_String m_posechannel;
- STR_String m_constraintname;
- float m_weight;
- float m_influence;
- int m_type;
-};
-
-#endif /* __BL_ARMATUREACTUATOR_H__ */
diff --git a/source/gameengine/Converter/BL_ArmatureChannel.cpp b/source/gameengine/Converter/BL_ArmatureChannel.cpp
deleted file mode 100644
index 2b8dfd8f8d1..00000000000
--- a/source/gameengine/Converter/BL_ArmatureChannel.cpp
+++ /dev/null
@@ -1,469 +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/Converter/BL_ArmatureChannel.cpp
- * \ingroup bgeconv
- */
-
-
-#include "DNA_armature_types.h"
-#include "BL_ArmatureChannel.h"
-#include "BL_ArmatureObject.h"
-#include "BL_ArmatureConstraint.h"
-#include "BLI_math.h"
-#include "BLI_string.h"
-#include <stddef.h>
-
-#ifdef WITH_PYTHON
-
-PyTypeObject BL_ArmatureChannel::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "BL_ArmatureChannel",
- 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,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyObject *BL_ArmatureChannel::py_repr(void)
-{
- return PyUnicode_FromString(m_posechannel->name);
-}
-
-PyObject *BL_ArmatureChannel::GetProxy()
-{
- return GetProxyPlus_Ext(this, &Type, m_posechannel);
-}
-
-PyObject *BL_ArmatureChannel::NewProxy(bool py_owns)
-{
- return NewProxyPlus_Ext(this, &Type, m_posechannel, py_owns);
-}
-
-#endif // WITH_PYTHON
-
-BL_ArmatureChannel::BL_ArmatureChannel(
- BL_ArmatureObject *armature,
- bPoseChannel *posechannel)
- : PyObjectPlus(), m_posechannel(posechannel), m_armature(armature)
-{
-}
-
-BL_ArmatureChannel::~BL_ArmatureChannel()
-{
-}
-
-#ifdef WITH_PYTHON
-
-// PYTHON
-
-PyMethodDef BL_ArmatureChannel::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-// order of definition of attributes, must match Attributes[] array
-#define BCA_BONE 0
-#define BCA_PARENT 1
-
-PyAttributeDef BL_ArmatureChannel::Attributes[] = {
- // Keep these attributes in order of BCA_ defines!!! used by py_attr_getattr and py_attr_setattr
- KX_PYATTRIBUTE_RO_FUNCTION("bone",BL_ArmatureChannel,py_attr_getattr),
- KX_PYATTRIBUTE_RO_FUNCTION("parent",BL_ArmatureChannel,py_attr_getattr),
-
- { NULL } //Sentinel
-};
-
-/* attributes directly taken from bPoseChannel */
-PyAttributeDef BL_ArmatureChannel::AttributesPtr[] = {
- KX_PYATTRIBUTE_CHAR_RO("name",bPoseChannel,name),
- KX_PYATTRIBUTE_FLAG_RO("has_ik",bPoseChannel,flag, POSE_CHAIN),
- KX_PYATTRIBUTE_FLAG_NEGATIVE_RO("ik_dof_x",bPoseChannel,ikflag, BONE_IK_NO_XDOF),
- KX_PYATTRIBUTE_FLAG_NEGATIVE_RO("ik_dof_y",bPoseChannel,ikflag, BONE_IK_NO_YDOF),
- KX_PYATTRIBUTE_FLAG_NEGATIVE_RO("ik_dof_z",bPoseChannel,ikflag, BONE_IK_NO_ZDOF),
- KX_PYATTRIBUTE_FLAG_RO("ik_limit_x",bPoseChannel,ikflag, BONE_IK_XLIMIT),
- KX_PYATTRIBUTE_FLAG_RO("ik_limit_y",bPoseChannel,ikflag, BONE_IK_YLIMIT),
- KX_PYATTRIBUTE_FLAG_RO("ik_limit_z",bPoseChannel,ikflag, BONE_IK_ZLIMIT),
- KX_PYATTRIBUTE_FLAG_RO("ik_rot_control",bPoseChannel,ikflag, BONE_IK_ROTCTL),
- KX_PYATTRIBUTE_FLAG_RO("ik_lin_control",bPoseChannel,ikflag, BONE_IK_LINCTL),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RW("location",-FLT_MAX,FLT_MAX,bPoseChannel,loc,3),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RW("scale",-FLT_MAX,FLT_MAX,bPoseChannel,size,3),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RW("rotation_quaternion",-1.0f,1.0f,bPoseChannel,quat,4),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RW("rotation_euler",-10.f,10.f,bPoseChannel,eul,3),
- KX_PYATTRIBUTE_SHORT_RW("rotation_mode",ROT_MODE_MIN,ROT_MODE_MAX,false,bPoseChannel,rotmode),
- KX_PYATTRIBUTE_FLOAT_MATRIX_RO("channel_matrix",bPoseChannel,chan_mat,4),
- KX_PYATTRIBUTE_FLOAT_MATRIX_RO("pose_matrix",bPoseChannel,pose_mat,4),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RO("pose_head",bPoseChannel,pose_head,3),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RO("pose_tail",bPoseChannel,pose_tail,3),
- KX_PYATTRIBUTE_FLOAT_RO("ik_min_x",bPoseChannel,limitmin[0]),
- KX_PYATTRIBUTE_FLOAT_RO("ik_max_x",bPoseChannel,limitmax[0]),
- KX_PYATTRIBUTE_FLOAT_RO("ik_min_y",bPoseChannel,limitmin[1]),
- KX_PYATTRIBUTE_FLOAT_RO("ik_max_y",bPoseChannel,limitmax[1]),
- KX_PYATTRIBUTE_FLOAT_RO("ik_min_z",bPoseChannel,limitmin[2]),
- KX_PYATTRIBUTE_FLOAT_RO("ik_max_z",bPoseChannel,limitmax[2]),
- KX_PYATTRIBUTE_FLOAT_RO("ik_stiffness_x",bPoseChannel,stiffness[0]),
- KX_PYATTRIBUTE_FLOAT_RO("ik_stiffness_y",bPoseChannel,stiffness[1]),
- KX_PYATTRIBUTE_FLOAT_RO("ik_stiffness_z",bPoseChannel,stiffness[2]),
- KX_PYATTRIBUTE_FLOAT_RO("ik_stretch",bPoseChannel,ikstretch),
- KX_PYATTRIBUTE_FLOAT_RW("ik_rot_weight",0,1.0f,bPoseChannel,ikrotweight),
- KX_PYATTRIBUTE_FLOAT_RW("ik_lin_weight",0,1.0f,bPoseChannel,iklinweight),
- KX_PYATTRIBUTE_RW_FUNCTION("joint_rotation",BL_ArmatureChannel,py_attr_get_joint_rotation,py_attr_set_joint_rotation),
- { NULL } //Sentinel
-};
-
-PyObject *BL_ArmatureChannel::py_attr_getattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- BL_ArmatureChannel* self = static_cast<BL_ArmatureChannel*>(self_v);
- bPoseChannel* channel = self->m_posechannel;
- int attr_order = attrdef-Attributes;
-
- if (!channel) {
- PyErr_SetString(PyExc_AttributeError, "channel is NULL");
- return NULL;
- }
-
- switch (attr_order) {
- case BCA_BONE:
- // bones are standalone proxy
- return NewProxyPlus_Ext(NULL,&BL_ArmatureBone::Type,channel->bone,false);
- case BCA_PARENT:
- {
- BL_ArmatureChannel* parent = self->m_armature->GetChannel(channel->parent);
- if (parent)
- return parent->GetProxy();
- else
- Py_RETURN_NONE;
- }
- }
- PyErr_SetString(PyExc_AttributeError, "channel unknown attribute");
- return NULL;
-}
-
-int BL_ArmatureChannel::py_attr_setattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- BL_ArmatureChannel* self = static_cast<BL_ArmatureChannel*>(self_v);
- bPoseChannel* channel = self->m_posechannel;
- int attr_order = attrdef-Attributes;
-
-// int ival;
-// double dval;
-// char* sval;
-// KX_GameObject *oval;
-
- if (!channel) {
- PyErr_SetString(PyExc_AttributeError, "channel is NULL");
- return PY_SET_ATTR_FAIL;
- }
-
- switch (attr_order) {
- default:
- break;
- }
-
- PyErr_SetString(PyExc_AttributeError, "channel unknown attribute");
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- bPoseChannel* pchan = static_cast<bPoseChannel*>(self_v);
- // decompose the pose matrix in euler rotation
- float rest_mat[3][3];
- float pose_mat[3][3];
- float joint_mat[3][3];
- float joints[3];
- float norm;
- double sa, ca;
- // get rotation in armature space
- copy_m3_m4(pose_mat, pchan->pose_mat);
- normalize_m3(pose_mat);
- if (pchan->parent) {
- // bone has a parent, compute the rest pose of the bone taking actual pose of parent
- mul_m3_m3m4(rest_mat, pchan->parent->pose_mat, pchan->bone->bone_mat);
- normalize_m3(rest_mat);
- } else {
- // otherwise, the bone matrix in armature space is the rest pose
- copy_m3_m4(rest_mat, pchan->bone->arm_mat);
- }
- // remove the rest pose to get the joint movement
- transpose_m3(rest_mat);
- mul_m3_m3m3(joint_mat, rest_mat, pose_mat);
- joints[0] = joints[1] = joints[2] = 0.f;
- // returns a 3 element list that gives corresponding joint
- int flag = 0;
- if (!(pchan->ikflag & BONE_IK_NO_XDOF))
- flag |= 1;
- if (!(pchan->ikflag & BONE_IK_NO_YDOF))
- flag |= 2;
- if (!(pchan->ikflag & BONE_IK_NO_ZDOF))
- flag |= 4;
- switch (flag) {
- case 0: // fixed joint
- break;
- case 1: // X only
- mat3_to_eulO( joints, EULER_ORDER_XYZ,joint_mat);
- joints[1] = joints[2] = 0.f;
- break;
- case 2: // Y only
- mat3_to_eulO( joints, EULER_ORDER_XYZ,joint_mat);
- joints[0] = joints[2] = 0.f;
- break;
- case 3: // X+Y
- mat3_to_eulO( joints, EULER_ORDER_ZYX,joint_mat);
- joints[2] = 0.f;
- break;
- case 4: // Z only
- mat3_to_eulO( joints, EULER_ORDER_XYZ,joint_mat);
- joints[0] = joints[1] = 0.f;
- break;
- case 5: // X+Z
- // decompose this as an equivalent rotation vector in X/Z plane
- joints[0] = joint_mat[1][2];
- joints[2] = -joint_mat[1][0];
- norm = normalize_v3(joints);
- if (norm < FLT_EPSILON) {
- norm = (joint_mat[1][1] < 0.0f) ? (float)M_PI : 0.0f;
- } else {
- norm = acos(joint_mat[1][1]);
- }
- mul_v3_fl(joints, norm);
- break;
- case 6: // Y+Z
- mat3_to_eulO( joints, EULER_ORDER_XYZ,joint_mat);
- joints[0] = 0.f;
- break;
- case 7: // X+Y+Z
- // equivalent axis
- joints[0] = (joint_mat[1][2]-joint_mat[2][1])*0.5f;
- joints[1] = (joint_mat[2][0]-joint_mat[0][2])*0.5f;
- joints[2] = (joint_mat[0][1]-joint_mat[1][0])*0.5f;
- sa = len_v3(joints);
- ca = (joint_mat[0][0]+joint_mat[1][1]+joint_mat[1][1]-1.0f)*0.5f;
- if (sa > (double)FLT_EPSILON) {
- norm = atan2(sa,ca)/sa;
- } else {
- if (ca < 0.0) {
- norm = M_PI;
- mul_v3_fl(joints,0.f);
- if (joint_mat[0][0] > 0.f) {
- joints[0] = 1.0f;
- } else if (joint_mat[1][1] > 0.f) {
- joints[1] = 1.0f;
- } else {
- joints[2] = 1.0f;
- }
- } else {
- norm = 0.0;
- }
- }
- mul_v3_fl(joints,norm);
- break;
- }
- return Vector_CreatePyObject(joints, 3, NULL);
-}
-
-int BL_ArmatureChannel::py_attr_set_joint_rotation(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- BL_ArmatureChannel* self = static_cast<BL_ArmatureChannel*>(self_v);
- bPoseChannel* pchan = self->m_posechannel;
- PyObject *item;
- float joints[3];
- float quat[4];
-
- if (!PySequence_Check(value) || PySequence_Size(value) != 3) {
- PyErr_SetString(PyExc_AttributeError, "expected a sequence of 3 floats");
- return PY_SET_ATTR_FAIL;
- }
- for (int i=0; i<3; i++) {
- item = PySequence_GetItem(value, i); /* new ref */
- joints[i] = PyFloat_AsDouble(item);
- Py_DECREF(item);
- if (joints[i] == -1.0f && PyErr_Occurred()) {
- PyErr_SetString(PyExc_AttributeError, "expected a sequence of 3 floats");
- return PY_SET_ATTR_FAIL;
- }
- }
-
- int flag = 0;
- if (!(pchan->ikflag & BONE_IK_NO_XDOF))
- flag |= 1;
- if (!(pchan->ikflag & BONE_IK_NO_YDOF))
- flag |= 2;
- if (!(pchan->ikflag & BONE_IK_NO_ZDOF))
- flag |= 4;
- unit_qt(quat);
- switch (flag) {
- case 0: // fixed joint
- break;
- case 1: // X only
- joints[1] = joints[2] = 0.f;
- eulO_to_quat( quat,joints, EULER_ORDER_XYZ);
- break;
- case 2: // Y only
- joints[0] = joints[2] = 0.f;
- eulO_to_quat( quat,joints, EULER_ORDER_XYZ);
- break;
- case 3: // X+Y
- joints[2] = 0.f;
- eulO_to_quat( quat,joints, EULER_ORDER_ZYX);
- break;
- case 4: // Z only
- joints[0] = joints[1] = 0.f;
- eulO_to_quat( quat,joints, EULER_ORDER_XYZ);
- break;
- case 5: // X+Z
- // X and Z are components of an equivalent rotation axis
- joints[1] = 0;
- axis_angle_to_quat( quat,joints, len_v3(joints));
- break;
- case 6: // Y+Z
- joints[0] = 0.f;
- eulO_to_quat( quat,joints, EULER_ORDER_XYZ);
- break;
- case 7: // X+Y+Z
- // equivalent axis
- axis_angle_to_quat( quat,joints, len_v3(joints));
- break;
- }
- if (pchan->rotmode > 0) {
- quat_to_eulO( joints, pchan->rotmode,quat);
- copy_v3_v3(pchan->eul, joints);
- } else
- copy_qt_qt(pchan->quat, quat);
- return PY_SET_ATTR_SUCCESS;
-}
-
-// *************************
-// BL_ArmatureBone
-//
-// Access to Bone structure
-PyTypeObject BL_ArmatureBone::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "BL_ArmatureBone",
- sizeof(PyObjectPlus_Proxy),
- 0,
- py_base_dealloc,
- 0,
- 0,
- 0,
- 0,
- py_bone_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,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-// not used since this class is never instantiated
-PyObject *BL_ArmatureBone::GetProxy()
-{
- return NULL;
-}
-PyObject *BL_ArmatureBone::NewProxy(bool py_owns)
-{
- return NULL;
-}
-
-PyObject *BL_ArmatureBone::py_bone_repr(PyObject *self)
-{
- Bone* bone = static_cast<Bone*>BGE_PROXY_PTR(self);
- return PyUnicode_FromString(bone->name);
-}
-
-PyMethodDef BL_ArmatureBone::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-/* no attributes on C++ class since it is never instantiated */
-PyAttributeDef BL_ArmatureBone::Attributes[] = {
- { NULL } //Sentinel
-};
-
-// attributes that work on proxy ptr (points to a Bone structure)
-PyAttributeDef BL_ArmatureBone::AttributesPtr[] = {
- KX_PYATTRIBUTE_CHAR_RO("name",Bone,name),
- KX_PYATTRIBUTE_FLAG_RO("connected",Bone,flag, BONE_CONNECTED),
- KX_PYATTRIBUTE_FLAG_RO("hinge",Bone,flag, BONE_HINGE),
- KX_PYATTRIBUTE_FLAG_NEGATIVE_RO("inherit_scale",Bone,flag, BONE_NO_SCALE),
- KX_PYATTRIBUTE_SHORT_RO("bbone_segments",Bone,segments),
- KX_PYATTRIBUTE_FLOAT_RO("roll",Bone,roll),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RO("head",Bone,head,3),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RO("tail",Bone,tail,3),
- KX_PYATTRIBUTE_FLOAT_RO("length",Bone,length),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RO("arm_head",Bone,arm_head,3),
- KX_PYATTRIBUTE_FLOAT_VECTOR_RO("arm_tail",Bone,arm_tail,3),
- KX_PYATTRIBUTE_FLOAT_MATRIX_RO("arm_mat",Bone,arm_mat,4),
- KX_PYATTRIBUTE_FLOAT_MATRIX_RO("bone_mat",Bone,bone_mat,3),
- KX_PYATTRIBUTE_RO_FUNCTION("parent",BL_ArmatureBone,py_bone_get_parent),
- KX_PYATTRIBUTE_RO_FUNCTION("children",BL_ArmatureBone,py_bone_get_children),
- { NULL } //Sentinel
-};
-
-PyObject *BL_ArmatureBone::py_bone_get_parent(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- Bone* bone = reinterpret_cast<Bone*>(self);
- if (bone->parent) {
- // create a proxy unconnected to any GE object
- return NewProxyPlus_Ext(NULL,&Type,bone->parent,false);
- }
- Py_RETURN_NONE;
-}
-
-PyObject *BL_ArmatureBone::py_bone_get_children(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- Bone* bone = reinterpret_cast<Bone*>(self);
- Bone* child;
- int count = 0;
- for (child = (Bone *)bone->childbase.first; child; child = child->next)
- count++;
-
- PyObject *childrenlist = PyList_New(count);
-
- for (count = 0, child = (Bone *)bone->childbase.first; child; child = child->next, ++count)
- PyList_SET_ITEM(childrenlist,count,NewProxyPlus_Ext(NULL,&Type,child,false));
-
- return childrenlist;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Converter/BL_ArmatureChannel.h b/source/gameengine/Converter/BL_ArmatureChannel.h
deleted file mode 100644
index a07097f8178..00000000000
--- a/source/gameengine/Converter/BL_ArmatureChannel.h
+++ /dev/null
@@ -1,101 +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 BL_ArmatureChannel.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_ARMATURECHANNEL_H__
-#define __BL_ARMATURECHANNEL_H__
-
-#include "DNA_action_types.h"
-#include "CTR_HashedPtr.h"
-#include "CTR_Map.h"
-#include "EXP_PyObjectPlus.h"
-
-class SCA_IObject;
-class KX_GameObject;
-class BL_ArmatureObject;
-struct bConstraint;
-struct bPoseChannel;
-struct Object;
-struct bPose;
-
-class BL_ArmatureChannel : public PyObjectPlus
-{
- // use Py_HeaderPtr since we use generic pointer in proxy
- Py_HeaderPtr;
-
-private:
- friend class BL_ArmatureObject;
- struct bPoseChannel* m_posechannel;
- BL_ArmatureObject* m_armature;
-
-public:
- BL_ArmatureChannel(class BL_ArmatureObject *armature,
- struct bPoseChannel *posechannel);
- virtual ~BL_ArmatureChannel();
-
- inline const char *GetName()
- {
- return m_posechannel->name;
- }
-
-#ifdef WITH_PYTHON
- // Python access
- virtual PyObject *py_repr(void);
-
- static PyObject *py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *py_attr_get_joint_rotation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int py_attr_set_joint_rotation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif /* WITH_PYTHON */
-};
-
-/* this is a factory class to access bBone data field in the GE.
- * It's not supposed to be instantiated, we only need it for the Attributes and Method array.
- * The actual proxy object will be manually created using NewProxyPtr */
-class BL_ArmatureBone : public PyObjectPlus
-{
- // use Py_HeaderPtr since we use generic pointer in proxy
- Py_HeaderPtr;
-private:
- // make constructor private to make sure no one tries to instantiate this class
- BL_ArmatureBone() {}
- virtual ~BL_ArmatureBone() {}
-
-public:
-
-#ifdef WITH_PYTHON
- static PyObject *py_bone_repr(PyObject *self);
- static PyObject *py_bone_get_parent(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *py_bone_get_children(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
-#endif
-
-};
-
-#endif /* __BL_ARMATURECHANNEL_H__ */
diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.cpp b/source/gameengine/Converter/BL_ArmatureConstraint.cpp
deleted file mode 100644
index d0c7e061fb7..00000000000
--- a/source/gameengine/Converter/BL_ArmatureConstraint.cpp
+++ /dev/null
@@ -1,456 +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/Converter/BL_ArmatureConstraint.cpp
- * \ingroup bgeconv
- */
-
-
-#include "DNA_constraint_types.h"
-#include "DNA_action_types.h"
-#include "BL_ArmatureConstraint.h"
-#include "BL_ArmatureObject.h"
-#include "BLI_math.h"
-#include "BLI_string.h"
-#include "KX_PythonInit.h"
-
-#ifdef WITH_PYTHON
-
-PyTypeObject BL_ArmatureConstraint::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "BL_ArmatureConstraint",
- 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,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyObject *BL_ArmatureConstraint::py_repr(void)
-{
- return PyUnicode_FromString(m_name);
-}
-
-#endif // WITH_PYTHON
-
-BL_ArmatureConstraint::BL_ArmatureConstraint(
- BL_ArmatureObject *armature,
- bPoseChannel *posechannel,
- bConstraint *constraint,
- KX_GameObject* target,
- KX_GameObject* subtarget)
- : PyObjectPlus(), m_constraint(constraint), m_posechannel(posechannel), m_armature(armature)
-{
- m_target = target;
- m_blendtarget = (target) ? target->GetBlenderObject() : NULL;
- m_subtarget = subtarget;
- m_blendsubtarget = (subtarget) ? subtarget->GetBlenderObject() : NULL;
- m_pose = m_subpose = NULL;
- if (m_blendtarget) {
- copy_m4_m4(m_blendmat, m_blendtarget->obmat);
- if (m_blendtarget->type == OB_ARMATURE)
- m_pose = m_blendtarget->pose;
- }
- if (m_blendsubtarget) {
- copy_m4_m4(m_blendsubmat, m_blendsubtarget->obmat);
- if (m_blendsubtarget->type == OB_ARMATURE)
- m_subpose = m_blendsubtarget->pose;
- }
- if (m_target)
- m_target->RegisterObject(m_armature);
- if (m_subtarget)
- m_subtarget->RegisterObject(m_armature);
- BLI_snprintf(m_name, sizeof(m_name), "%s:%s", m_posechannel->name, m_constraint->name);
-}
-
-BL_ArmatureConstraint::~BL_ArmatureConstraint()
-{
- if (m_target)
- m_target->UnregisterObject(m_armature);
- if (m_subtarget)
- m_subtarget->UnregisterObject(m_armature);
-}
-
-BL_ArmatureConstraint* BL_ArmatureConstraint::GetReplica() const
-{
- BL_ArmatureConstraint* replica = new BL_ArmatureConstraint(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-void BL_ArmatureConstraint::ReParent(BL_ArmatureObject* armature)
-{
- m_armature = armature;
- if (m_target)
- m_target->RegisterObject(armature);
- if (m_subtarget)
- m_subtarget->RegisterObject(armature);
- // find the corresponding constraint in the new armature object
- if (m_constraint) {
- bPose* newpose = armature->GetOrigPose();
- char* constraint = m_constraint->name;
- char* posechannel = m_posechannel->name;
- bPoseChannel* pchan;
- bConstraint* pcon;
- m_constraint = NULL;
- m_posechannel = NULL;
- // and locate the constraint
- for (pchan = (bPoseChannel*)newpose->chanbase.first; pchan; pchan = (bPoseChannel*)pchan->next) {
- if (!strcmp(pchan->name, posechannel)) {
- // now locate the constraint
- for (pcon = (bConstraint *)pchan->constraints.first; pcon; pcon = (bConstraint *)pcon->next) {
- if (!strcmp(pcon->name, constraint)) {
- m_constraint = pcon;
- m_posechannel = pchan;
- break;
- }
- }
- break;
- }
- }
- }
-}
-
-void BL_ArmatureConstraint::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_target];
- if (h_obj) {
- m_target->UnregisterObject(m_armature);
- m_target = (KX_GameObject*)(*h_obj);
- m_target->RegisterObject(m_armature);
- }
- h_obj = (*obj_map)[m_subtarget];
- if (h_obj) {
- m_subtarget->UnregisterObject(m_armature);
- m_subtarget = (KX_GameObject*)(*h_obj);
- m_subtarget->RegisterObject(m_armature);
- }
-}
-
-bool BL_ArmatureConstraint::UnlinkObject(SCA_IObject* clientobj)
-{
- bool res=false;
- if (clientobj == m_target) {
- m_target = NULL;
- res = true;
- }
- if (clientobj == m_subtarget) {
- m_subtarget = NULL;
- res = true;
- }
- return res;
-}
-
-void BL_ArmatureConstraint::UpdateTarget()
-{
- if (m_constraint && !(m_constraint->flag&CONSTRAINT_OFF) && (!m_blendtarget || m_target)) {
- if (m_blendtarget) {
- // external target, must be updated
- m_target->UpdateBlenderObjectMatrix(m_blendtarget);
- if (m_pose && m_target->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
- // update the pose in case a bone is specified in the constraint target
- m_blendtarget->pose = ((BL_ArmatureObject*)m_target)->GetOrigPose();
- }
- if (m_blendsubtarget && m_subtarget) {
- m_subtarget->UpdateBlenderObjectMatrix(m_blendsubtarget);
- if (m_subpose && m_subtarget->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
- m_blendsubtarget->pose = ((BL_ArmatureObject*)m_subtarget)->GetOrigPose();
- }
- }
-}
-
-void BL_ArmatureConstraint::RestoreTarget()
-{
- if (m_constraint && !(m_constraint->flag&CONSTRAINT_OFF) && (!m_blendtarget || m_target)) {
- if (m_blendtarget) {
- copy_m4_m4(m_blendtarget->obmat, m_blendmat);
- if (m_pose)
- m_blendtarget->pose = m_pose;
- }
- if (m_blendsubtarget && m_subtarget) {
- copy_m4_m4(m_blendsubtarget->obmat, m_blendsubmat);
- if (m_subpose)
- m_blendsubtarget->pose = m_subpose;
- }
- }
-}
-
-bool BL_ArmatureConstraint::Match(const char* posechannel, const char* constraint)
-{
- return (!strcmp(m_posechannel->name, posechannel) && !strcmp(m_constraint->name, constraint));
-}
-
-void BL_ArmatureConstraint::SetTarget(KX_GameObject* target)
-{
- if (m_blendtarget) {
- if (target != m_target) {
- m_target->UnregisterObject(m_armature);
- m_target = target;
- if (m_target)
- m_target->RegisterObject(m_armature);
- }
- }
-
-}
-
-void BL_ArmatureConstraint::SetSubtarget(KX_GameObject* subtarget)
-{
- if (m_blendsubtarget) {
- if (subtarget != m_subtarget) {
- m_subtarget->UnregisterObject(m_armature);
- m_subtarget = subtarget;
- if (m_subtarget)
- m_subtarget->RegisterObject(m_armature);
- }
- }
-
-}
-
-#ifdef WITH_PYTHON
-
-// PYTHON
-
-PyMethodDef BL_ArmatureConstraint::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-// order of definition of attributes, must match Attributes[] array
-#define BCA_TYPE 0
-#define BCA_NAME 1
-#define BCA_ENFORCE 2
-#define BCA_HEADTAIL 3
-#define BCA_LINERROR 4
-#define BCA_ROTERROR 5
-#define BCA_TARGET 6
-#define BCA_SUBTARGET 7
-#define BCA_ACTIVE 8
-#define BCA_IKWEIGHT 9
-#define BCA_IKTYPE 10
-#define BCA_IKFLAG 11
-#define BCA_IKDIST 12
-#define BCA_IKMODE 13
-
-PyAttributeDef BL_ArmatureConstraint::Attributes[] = {
- // Keep these attributes in order of BCA_ defines!!! used by py_attr_getattr and py_attr_setattr
- KX_PYATTRIBUTE_RO_FUNCTION("type",BL_ArmatureConstraint,py_attr_getattr),
- KX_PYATTRIBUTE_RO_FUNCTION("name",BL_ArmatureConstraint,py_attr_getattr),
- KX_PYATTRIBUTE_RW_FUNCTION("enforce",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
- KX_PYATTRIBUTE_RW_FUNCTION("headtail",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
- KX_PYATTRIBUTE_RO_FUNCTION("lin_error",BL_ArmatureConstraint,py_attr_getattr),
- KX_PYATTRIBUTE_RO_FUNCTION("rot_error",BL_ArmatureConstraint,py_attr_getattr),
- KX_PYATTRIBUTE_RW_FUNCTION("target",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
- KX_PYATTRIBUTE_RW_FUNCTION("subtarget",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
- KX_PYATTRIBUTE_RW_FUNCTION("active",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
- KX_PYATTRIBUTE_RW_FUNCTION("ik_weight",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
- KX_PYATTRIBUTE_RO_FUNCTION("ik_type",BL_ArmatureConstraint,py_attr_getattr),
- KX_PYATTRIBUTE_RO_FUNCTION("ik_flag",BL_ArmatureConstraint,py_attr_getattr),
- KX_PYATTRIBUTE_RW_FUNCTION("ik_dist",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
- KX_PYATTRIBUTE_RW_FUNCTION("ik_mode",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
-
- { NULL } //Sentinel
-};
-
-
-PyObject *BL_ArmatureConstraint::py_attr_getattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- BL_ArmatureConstraint* self = static_cast<BL_ArmatureConstraint*>(self_v);
- bConstraint* constraint = self->m_constraint;
- bKinematicConstraint* ikconstraint = (constraint && constraint->type == CONSTRAINT_TYPE_KINEMATIC) ? (bKinematicConstraint*)constraint->data : NULL;
- int attr_order = attrdef-Attributes;
-
- if (!constraint) {
- PyErr_SetString(PyExc_AttributeError, "constraint is NULL");
- return NULL;
- }
-
- switch (attr_order) {
- case BCA_TYPE:
- return PyLong_FromLong(constraint->type);
- case BCA_NAME:
- return PyUnicode_FromString(constraint->name);
- case BCA_ENFORCE:
- return PyFloat_FromDouble(constraint->enforce);
- case BCA_HEADTAIL:
- return PyFloat_FromDouble(constraint->headtail);
- case BCA_LINERROR:
- return PyFloat_FromDouble(constraint->lin_error);
- case BCA_ROTERROR:
- return PyFloat_FromDouble(constraint->rot_error);
- case BCA_TARGET:
- if (!self->m_target)
- Py_RETURN_NONE;
- else
- return self->m_target->GetProxy();
- case BCA_SUBTARGET:
- if (!self->m_subtarget)
- Py_RETURN_NONE;
- else
- return self->m_subtarget->GetProxy();
- case BCA_ACTIVE:
- return PyBool_FromLong((constraint->flag & CONSTRAINT_OFF) == 0);
- case BCA_IKWEIGHT:
- case BCA_IKTYPE:
- case BCA_IKFLAG:
- case BCA_IKDIST:
- case BCA_IKMODE:
- if (!ikconstraint) {
- PyErr_SetString(PyExc_AttributeError, "constraint is not of IK type");
- return NULL;
- }
- switch (attr_order) {
- case BCA_IKWEIGHT:
- return PyFloat_FromDouble(ikconstraint->weight);
- case BCA_IKTYPE:
- return PyLong_FromLong(ikconstraint->type);
- case BCA_IKFLAG:
- return PyLong_FromLong(ikconstraint->flag);
- case BCA_IKDIST:
- return PyFloat_FromDouble(ikconstraint->dist);
- case BCA_IKMODE:
- return PyLong_FromLong(ikconstraint->mode);
- }
- // should not come here
- break;
- }
- PyErr_SetString(PyExc_AttributeError, "constraint unknown attribute");
- return NULL;
-}
-
-int BL_ArmatureConstraint::py_attr_setattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- BL_ArmatureConstraint* self = static_cast<BL_ArmatureConstraint*>(self_v);
- bConstraint* constraint = self->m_constraint;
- bKinematicConstraint* ikconstraint = (constraint && constraint->type == CONSTRAINT_TYPE_KINEMATIC) ? (bKinematicConstraint*)constraint->data : NULL;
- int attr_order = attrdef-Attributes;
- int ival;
- double dval;
-// char* sval;
- SCA_LogicManager *logicmgr = KX_GetActiveScene()->GetLogicManager();
- KX_GameObject *oval;
-
- if (!constraint) {
- PyErr_SetString(PyExc_AttributeError, "constraint is NULL");
- return PY_SET_ATTR_FAIL;
- }
-
- switch (attr_order) {
- case BCA_ENFORCE:
- dval = PyFloat_AsDouble(value);
- if (dval < 0.0 || dval > 1.0) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError, "constraint.enforce = float: BL_ArmatureConstraint, expected a float between 0 and 1");
- return PY_SET_ATTR_FAIL;
- }
- constraint->enforce = dval;
- return PY_SET_ATTR_SUCCESS;
-
- case BCA_HEADTAIL:
- dval = PyFloat_AsDouble(value);
- if (dval < 0.0 || dval > 1.0) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError, "constraint.headtail = float: BL_ArmatureConstraint, expected a float between 0 and 1");
- return PY_SET_ATTR_FAIL;
- }
- constraint->headtail = dval;
- return PY_SET_ATTR_SUCCESS;
-
- case BCA_TARGET:
- if (!ConvertPythonToGameObject(logicmgr, value, &oval, true, "constraint.target = value: BL_ArmatureConstraint"))
- return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
- self->SetTarget(oval);
- return PY_SET_ATTR_SUCCESS;
-
- case BCA_SUBTARGET:
- if (!ConvertPythonToGameObject(logicmgr, value, &oval, true, "constraint.subtarget = value: BL_ArmatureConstraint"))
- return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
- self->SetSubtarget(oval);
- return PY_SET_ATTR_SUCCESS;
-
- case BCA_ACTIVE:
- ival = PyObject_IsTrue( value );
- if (ival == -1) {
- PyErr_SetString(PyExc_AttributeError, "constraint.active = bool: BL_ArmatureConstraint, expected True or False");
- return PY_SET_ATTR_FAIL;
- }
- self->m_constraint->flag = (self->m_constraint->flag & ~CONSTRAINT_OFF) | ((ival)?0:CONSTRAINT_OFF);
- return PY_SET_ATTR_SUCCESS;
-
- case BCA_IKWEIGHT:
- case BCA_IKDIST:
- case BCA_IKMODE:
- if (!ikconstraint) {
- PyErr_SetString(PyExc_AttributeError, "constraint is not of IK type");
- return PY_SET_ATTR_FAIL;
- }
- switch (attr_order) {
- case BCA_IKWEIGHT:
- dval = PyFloat_AsDouble(value);
- if (dval < 0.0 || dval > 1.0) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError, "constraint.weight = float: BL_ArmatureConstraint, expected a float between 0 and 1");
- return PY_SET_ATTR_FAIL;
- }
- ikconstraint->weight = dval;
- return PY_SET_ATTR_SUCCESS;
-
- case BCA_IKDIST:
- dval = PyFloat_AsDouble(value);
- if (dval < 0.0) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError, "constraint.ik_dist = float: BL_ArmatureConstraint, expected a positive float");
- return PY_SET_ATTR_FAIL;
- }
- ikconstraint->dist = dval;
- return PY_SET_ATTR_SUCCESS;
-
- case BCA_IKMODE:
- ival = PyLong_AsLong(value);
- if (ival < 0) {
- PyErr_SetString(PyExc_AttributeError, "constraint.ik_mode = integer: BL_ArmatureConstraint, expected a positive integer");
- return PY_SET_ATTR_FAIL;
- }
- ikconstraint->mode = ival;
- return PY_SET_ATTR_SUCCESS;
- }
- // should not come here
- break;
-
- }
-
- PyErr_SetString(PyExc_AttributeError, "constraint unknown attribute");
- return PY_SET_ATTR_FAIL;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.h b/source/gameengine/Converter/BL_ArmatureConstraint.h
deleted file mode 100644
index 1d9f7f0d548..00000000000
--- a/source/gameengine/Converter/BL_ArmatureConstraint.h
+++ /dev/null
@@ -1,125 +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 BL_ArmatureConstraint.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_ARMATURECONSTRAINT_H__
-#define __BL_ARMATURECONSTRAINT_H__
-
-#include "DNA_constraint_types.h"
-#include "CTR_HashedPtr.h"
-#include "CTR_Map.h"
-#include "EXP_PyObjectPlus.h"
-
-class SCA_IObject;
-class KX_GameObject;
-class BL_ArmatureObject;
-struct bConstraint;
-struct bPoseChannel;
-struct Object;
-struct bPose;
-
-/**
- * SG_DList : element of controlled constraint list
- * head = BL_ArmatureObject::m_controlledConstraints
- * SG_QList : not used
- */
-class BL_ArmatureConstraint : public PyObjectPlus
-{
- Py_Header
-
-private:
- struct bConstraint* m_constraint;
- struct bPoseChannel* m_posechannel;
- class BL_ArmatureObject* m_armature;
- char m_name[64];
- KX_GameObject* m_target;
- KX_GameObject* m_subtarget;
- struct Object* m_blendtarget;
- struct Object* m_blendsubtarget;
- float m_blendmat[4][4];
- float m_blendsubmat[4][4];
- struct bPose* m_pose;
- struct bPose* m_subpose;
-
-public:
- BL_ArmatureConstraint(class BL_ArmatureObject *armature,
- struct bPoseChannel *posechannel,
- struct bConstraint *constraint,
- KX_GameObject* target,
- KX_GameObject* subtarget);
- virtual ~BL_ArmatureConstraint();
-
- BL_ArmatureConstraint* GetReplica() const;
- void ReParent(BL_ArmatureObject* armature);
- void Relink(CTR_Map<CTR_HashedPtr, void*> *map);
- bool UnlinkObject(SCA_IObject* clientobj);
-
- void UpdateTarget();
- void RestoreTarget();
-
- bool Match(const char* posechannel, const char* constraint);
- const char* GetName() { return m_name; }
-
- void SetConstraintFlag(int flag)
- {
- if (m_constraint)
- m_constraint->flag |= flag;
- }
- void ClrConstraintFlag(int flag)
- {
- if (m_constraint)
- m_constraint->flag &= ~flag;
- }
- void SetWeight(float weight)
- {
- if (m_constraint && m_constraint->type == CONSTRAINT_TYPE_KINEMATIC && m_constraint->data) {
- bKinematicConstraint* con = (bKinematicConstraint*)m_constraint->data;
- con->weight = weight;
- }
- }
- void SetInfluence(float influence)
- {
- if (m_constraint)
- m_constraint->enforce = influence;
- }
- void SetTarget(KX_GameObject* target);
- void SetSubtarget(KX_GameObject* subtarget);
-
-#ifdef WITH_PYTHON
-
- // Python access
- virtual PyObject *py_repr(void);
-
- static PyObject *py_attr_getattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int py_attr_setattr(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif /* WITH_PYTHON */
-};
-
-#endif /* __BL_ARMATURECONSTRAINT_H__ */
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
deleted file mode 100644
index 049fd49cab9..00000000000
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ /dev/null
@@ -1,691 +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/Converter/BL_ArmatureObject.cpp
- * \ingroup bgeconv
- */
-
-
-#include "BL_ArmatureObject.h"
-#include "BL_ActionActuator.h"
-#include "BL_Action.h"
-#include "KX_BlenderSceneConverter.h"
-#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-#include "BIK_api.h"
-#include "BKE_action.h"
-#include "BKE_armature.h"
-#include "BKE_object.h"
-#include "BKE_library.h"
-#include "BKE_global.h"
-
-extern "C" {
-#include "BKE_animsys.h"
-}
-
-#include "BKE_constraint.h"
-#include "CTR_Map.h"
-#include "CTR_HashedPtr.h"
-#include "MEM_guardedalloc.h"
-#include "DNA_action_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_constraint_types.h"
-#include "RNA_access.h"
-#include "KX_PythonInit.h"
-#include "KX_KetsjiEngine.h"
-
-#include "EXP_ListWrapper.h"
-
-#include "MT_Matrix4x4.h"
-
-/**
- * Move here pose function for game engine so that we can mix with GE objects
- * Principle is as follow:
- * Use Blender structures so that BKE_pose_where_is can be used unchanged
- * Copy the constraint so that they can be enabled/disabled/added/removed at runtime
- * Don't copy the constraints for the pose used by the Action actuator, it does not need them.
- * Scan the constraint structures so that the KX equivalent of target objects are identified and
- * stored in separate list.
- * When it is about to evaluate the pose, set the KX object position in the obmat of the corresponding
- * Blender objects and restore after the evaluation.
- */
-static void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
-{
- bPose *out;
- bPoseChannel *pchan, *outpchan;
- GHash *ghash;
-
- /* the game engine copies the current armature pose and then swaps
- * the object pose pointer. this makes it possible to change poses
- * without affecting the original blender data. */
-
- if (!src) {
- *dst=NULL;
- return;
- }
- else if (*dst==src) {
- printf("game_copy_pose source and target are the same\n");
- *dst=NULL;
- return;
- }
-
- out= (bPose*)MEM_dupallocN(src);
- out->chanhash = NULL;
- out->agroups.first= out->agroups.last= NULL;
- out->ikdata = NULL;
- out->ikparam = MEM_dupallocN(src->ikparam);
- out->flag |= POSE_GAME_ENGINE;
- BLI_duplicatelist(&out->chanbase, &src->chanbase);
-
- /* remap pointers */
- ghash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "game_copy_pose gh");
-
- pchan= (bPoseChannel *)src->chanbase.first;
- outpchan= (bPoseChannel *)out->chanbase.first;
- for (; pchan; pchan=pchan->next, outpchan=outpchan->next)
- BLI_ghash_insert(ghash, pchan, outpchan);
-
- for (pchan = (bPoseChannel *)out->chanbase.first; pchan; pchan = pchan->next) {
- pchan->parent= (bPoseChannel *)BLI_ghash_lookup(ghash, pchan->parent);
- pchan->child= (bPoseChannel *)BLI_ghash_lookup(ghash, pchan->child);
-
- if (copy_constraint) {
- ListBase listb;
- // copy all constraint for backward compatibility
- // BKE_constraints_copy NULLs listb, no need to make extern for this operation.
- BKE_constraints_copy(&listb, &pchan->constraints, false);
- pchan->constraints= listb;
- }
- else {
- BLI_listbase_clear(&pchan->constraints);
- }
-
- 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)
- pchan->prop= IDP_CopyProperty(pchan->prop);
-#endif
- pchan->prop = NULL;
- pchan->draw_data = NULL;
- }
-
- BLI_ghash_free(ghash, NULL, NULL);
- // set acceleration structure for channel lookup
- BKE_pose_channels_hash_make(out);
- *dst=out;
-}
-
-
-
-/* Only allowed for Poses with identical channels */
-static void game_blend_poses(bPose *dst, bPose *src, float srcweight, short mode)
-{
- bPoseChannel *dchan;
- const bPoseChannel *schan;
- bConstraint *dcon, *scon;
- float dstweight;
- int i;
-
- if (mode == BL_Action::ACT_BLEND_BLEND)
- {
- dstweight = 1.0f - srcweight;
- } else if (mode == BL_Action::ACT_BLEND_ADD)
- {
- dstweight = 1.0f;
- } else {
- dstweight = 1.0f;
- }
-
- schan= (bPoseChannel *)src->chanbase.first;
- for (dchan = (bPoseChannel *)dst->chanbase.first; dchan; dchan=(bPoseChannel *)dchan->next, schan= (bPoseChannel *)schan->next) {
- // always blend on all channels since we don't know which one has been set
- /* quat interpolation done separate */
- if (schan->rotmode == ROT_MODE_QUAT) {
- float dquat[4], squat[4];
-
- copy_qt_qt(dquat, dchan->quat);
- copy_qt_qt(squat, schan->quat);
- // Normalize quaternions so that interpolation/multiplication result is correct.
- normalize_qt(dquat);
- normalize_qt(squat);
-
- if (mode==BL_Action::ACT_BLEND_BLEND)
- interp_qt_qtqt(dchan->quat, dquat, squat, srcweight);
- else {
- mul_fac_qt_fl(squat, srcweight);
- mul_qt_qtqt(dchan->quat, dquat, squat);
- }
-
- normalize_qt(dchan->quat);
- }
-
- for (i=0; i<3; i++) {
- /* blending for loc and scale are pretty self-explanatory... */
- dchan->loc[i] = (dchan->loc[i]*dstweight) + (schan->loc[i]*srcweight);
- dchan->size[i] = 1.0f + ((dchan->size[i]-1.0f)*dstweight) + ((schan->size[i]-1.0f)*srcweight);
-
- /* euler-rotation interpolation done here instead... */
- // FIXME: are these results decent?
- if (schan->rotmode)
- dchan->eul[i] = (dchan->eul[i]*dstweight) + (schan->eul[i]*srcweight);
- }
- for (dcon= (bConstraint *)dchan->constraints.first, scon= (bConstraint *)schan->constraints.first;
- dcon && scon;
- dcon = dcon->next, scon = scon->next)
- {
- /* no 'add' option for constraint blending */
- dcon->enforce= dcon->enforce*(1.0f-srcweight) + scon->enforce*srcweight;
- }
- }
-
- /* this pose is now in src time */
- dst->ctime= src->ctime;
-}
-
-BL_ArmatureObject::BL_ArmatureObject(
- void* sgReplicationInfo,
- SG_Callbacks callbacks,
- Object *armature,
- Scene *scene,
- int vert_deform_type)
-
-: KX_GameObject(sgReplicationInfo,callbacks),
- m_controlledConstraints(),
- m_poseChannels(),
- m_scene(scene), // maybe remove later. needed for BKE_pose_where_is
- m_lastframe(0.0),
- m_timestep(0.040),
- m_vert_deform_type(vert_deform_type),
- m_constraintNumber(0),
- m_channelNumber(0),
- m_lastapplyframe(0.0)
-{
- m_origObjArma = armature; // Keep a copy of the original armature so we can fix drivers later
- m_objArma = BKE_object_copy(G.main, armature);
- m_objArma->data = BKE_armature_copy(G.main, (bArmature *)armature->data);
- // During object replication ob->data is increase, we decrease it now because we get a copy.
- id_us_min(&((bArmature *)m_origObjArma->data)->id);
- m_pose = m_objArma->pose;
- // need this to get iTaSC working ok in the BGE
- m_pose->flag |= POSE_GAME_ENGINE;
- memcpy(m_obmat, m_objArma->obmat, sizeof(m_obmat));
-
- // The side-effect of this method registers this object as "animatable" with the KX_Scene.
- GetActionManager();
-}
-
-BL_ArmatureObject::~BL_ArmatureObject()
-{
- BL_ArmatureConstraint* constraint;
- while ((constraint = m_controlledConstraints.Remove()) != NULL) {
- delete constraint;
- }
- BL_ArmatureChannel* channel;
- while ((channel = static_cast<BL_ArmatureChannel*>(m_poseChannels.Remove())) != NULL) {
- delete channel;
- }
-
- if (m_objArma) {
- BKE_libblock_free(G.main, m_objArma->data);
- BKE_libblock_free(G.main, m_objArma);
- }
-}
-
-
-void BL_ArmatureObject::LoadConstraints(KX_BlenderSceneConverter* converter)
-{
- // first delete any existing constraint (should not have any)
- while (!m_controlledConstraints.Empty()) {
- BL_ArmatureConstraint* constraint = m_controlledConstraints.Remove();
- delete constraint;
- }
- m_constraintNumber = 0;
-
- // list all the constraint and convert them to BL_ArmatureConstraint
- // get the persistent pose structure
- bPoseChannel* pchan;
- bConstraint* pcon;
- const bConstraintTypeInfo* cti;
- Object* blendtarget;
- KX_GameObject* gametarget;
- KX_GameObject* gamesubtarget;
-
- // and locate the constraint
- for (pchan = (bPoseChannel *)m_pose->chanbase.first; pchan; pchan = pchan->next) {
- for (pcon = (bConstraint *)pchan->constraints.first; pcon; pcon = pcon->next) {
- if (pcon->flag & CONSTRAINT_DISABLE)
- continue;
- // which constraint should we support?
- switch (pcon->type) {
- case CONSTRAINT_TYPE_TRACKTO:
- case CONSTRAINT_TYPE_DAMPTRACK:
- case CONSTRAINT_TYPE_KINEMATIC:
- case CONSTRAINT_TYPE_ROTLIKE:
- case CONSTRAINT_TYPE_LOCLIKE:
- case CONSTRAINT_TYPE_MINMAX:
- case CONSTRAINT_TYPE_SIZELIKE:
- case CONSTRAINT_TYPE_LOCKTRACK:
- case CONSTRAINT_TYPE_STRETCHTO:
- case CONSTRAINT_TYPE_CLAMPTO:
- case CONSTRAINT_TYPE_TRANSFORM:
- case CONSTRAINT_TYPE_DISTLIMIT:
- case CONSTRAINT_TYPE_TRANSLIKE:
- cti = BKE_constraint_typeinfo_get(pcon);
- gametarget = gamesubtarget = NULL;
- if (cti && cti->get_constraint_targets) {
- ListBase listb = { NULL, NULL };
- cti->get_constraint_targets(pcon, &listb);
- if (listb.first) {
- bConstraintTarget* target = (bConstraintTarget*)listb.first;
- if (target->tar && target->tar != m_objArma) {
- // only remember external objects, self target is handled automatically
- blendtarget = target->tar;
- gametarget = converter->FindGameObject(blendtarget);
- }
- if (target->next != NULL) {
- // secondary target
- target = target->next;
- if (target->tar && target->tar != m_objArma) {
- // only track external object
- blendtarget = target->tar;
- gamesubtarget = converter->FindGameObject(blendtarget);
- }
- }
- }
- if (cti->flush_constraint_targets)
- cti->flush_constraint_targets(pcon, &listb, 1);
- }
- BL_ArmatureConstraint* constraint = new BL_ArmatureConstraint(this, pchan, pcon, gametarget, gamesubtarget);
- m_controlledConstraints.AddBack(constraint);
- m_constraintNumber++;
- }
- }
- }
-
- // If we have constraints, make sure we get treated as an "animated" object
- if (m_constraintNumber > 0)
- GetActionManager();
-}
-
-BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const char* posechannel, const char* constraintname)
-{
- SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
- for (cit.begin(); !cit.end(); ++cit) {
- BL_ArmatureConstraint* constraint = *cit;
- if (constraint->Match(posechannel, constraintname))
- return constraint;
- }
- return NULL;
-}
-
-BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const char* posechannelconstraint)
-{
- // performance: use hash string instead of plain string compare
- SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
- for (cit.begin(); !cit.end(); ++cit) {
- BL_ArmatureConstraint* constraint = *cit;
- if (!strcmp(constraint->GetName(), posechannelconstraint))
- return constraint;
- }
- return NULL;
-}
-
-BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(int index)
-{
- SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
- for (cit.begin(); !cit.end() && index; ++cit, --index);
- return (cit.end()) ? NULL : *cit;
-}
-
-/* this function is called to populate the m_poseChannels list */
-void BL_ArmatureObject::LoadChannels()
-{
- if (m_poseChannels.Empty()) {
- bPoseChannel* pchan;
- BL_ArmatureChannel* proxy;
-
- m_channelNumber = 0;
- for (pchan = (bPoseChannel *)m_pose->chanbase.first; pchan; pchan=(bPoseChannel *)pchan->next) {
- proxy = new BL_ArmatureChannel(this, pchan);
- m_poseChannels.AddBack(proxy);
- m_channelNumber++;
- }
- }
-}
-
-BL_ArmatureChannel* BL_ArmatureObject::GetChannel(bPoseChannel* pchan)
-{
- LoadChannels();
- SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
- for (cit.begin(); !cit.end(); ++cit)
- {
- BL_ArmatureChannel* channel = *cit;
- if (channel->m_posechannel == pchan)
- return channel;
- }
- return NULL;
-}
-
-BL_ArmatureChannel* BL_ArmatureObject::GetChannel(const char* str)
-{
- LoadChannels();
- SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
- for (cit.begin(); !cit.end(); ++cit)
- {
- BL_ArmatureChannel* channel = *cit;
- if (!strcmp(channel->m_posechannel->name, str))
- return channel;
- }
- return NULL;
-}
-
-BL_ArmatureChannel* BL_ArmatureObject::GetChannel(int index)
-{
- LoadChannels();
- if (index < 0 || index >= m_channelNumber)
- return NULL;
- SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
- for (cit.begin(); !cit.end() && index; ++cit, --index);
- return (cit.end()) ? NULL : *cit;
-}
-
-CValue* BL_ArmatureObject::GetReplica()
-{
- BL_ArmatureObject* replica = new BL_ArmatureObject(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-void BL_ArmatureObject::ProcessReplica()
-{
- KX_GameObject::ProcessReplica();
-
- bArmature* tmp = (bArmature*)m_objArma->data;
- m_objArma = BKE_object_copy(G.main, m_objArma);
- m_objArma->data = BKE_armature_copy(G.main, tmp);
- m_pose = m_objArma->pose;
-}
-
-void BL_ArmatureObject::ReParentLogic()
-{
- SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
- for (cit.begin(); !cit.end(); ++cit) {
- (*cit)->ReParent(this);
- }
- KX_GameObject::ReParentLogic();
-}
-
-void BL_ArmatureObject::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
- for (cit.begin(); !cit.end(); ++cit) {
- (*cit)->Relink(obj_map);
- }
- KX_GameObject::Relink(obj_map);
-}
-
-bool BL_ArmatureObject::UnlinkObject(SCA_IObject* clientobj)
-{
- // clientobj is being deleted, make sure we don't hold any reference to it
- bool res = false;
- SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
- for (cit.begin(); !cit.end(); ++cit) {
- res |= (*cit)->UnlinkObject(clientobj);
- }
- return res;
-}
-
-void BL_ArmatureObject::ApplyPose()
-{
- /* TODO: This doesn't work currently because of eval_ctx. */
-#if 0
- m_armpose = m_objArma->pose;
- m_objArma->pose = m_pose;
- // in the GE, we use ctime to store the timestep
- m_pose->ctime = (float)m_timestep;
- //m_scene->r.cfra++;
- if (m_lastapplyframe != m_lastframe) {
- // update the constraint if any, first put them all off so that only the active ones will be updated
- SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
- for (cit.begin(); !cit.end(); ++cit) {
- (*cit)->UpdateTarget();
- }
- // update ourself
- UpdateBlenderObjectMatrix(m_objArma);
- BKE_pose_where_is(m_scene, m_objArma); // XXX
- // restore ourself
- memcpy(m_objArma->obmat, m_obmat, sizeof(m_obmat));
- // restore active targets
- for (cit.begin(); !cit.end(); ++cit) {
- (*cit)->RestoreTarget();
- }
- m_lastapplyframe = m_lastframe;
- }
-#endif
-}
-
-void BL_ArmatureObject::RestorePose()
-{
- m_objArma->pose = m_armpose;
- m_armpose = NULL;
-}
-
-void BL_ArmatureObject::SetPose(bPose *pose)
-{
- extract_pose_from_pose(m_pose, pose);
- m_lastapplyframe = -1.0;
-}
-
-void BL_ArmatureObject::SetPoseByAction(bAction *action, float localtime)
-{
- Object *arm = GetArmatureObject();
-
- PointerRNA ptrrna;
- RNA_id_pointer_create(&arm->id, &ptrrna);
-
- animsys_evaluate_action(&ptrrna, action, NULL, localtime);
-}
-
-void BL_ArmatureObject::BlendInPose(bPose *blend_pose, float weight, short mode)
-{
- game_blend_poses(m_pose, blend_pose, weight, mode);
-}
-
-bool BL_ArmatureObject::UpdateTimestep(double curtime)
-{
- if (curtime != m_lastframe) {
- // compute the timestep for the underlying IK algorithm
- m_timestep = curtime-m_lastframe;
- m_lastframe= curtime;
- }
-
- return false;
-}
-
-void BL_ArmatureObject::GetPose(bPose **pose)
-{
- /* If the caller supplies a null pose, create a new one. */
- /* Otherwise, copy the armature's pose channels into the caller-supplied pose */
-
- if (!*pose) {
- /* probably not to good of an idea to
- * duplicate everything, but it clears up
- * a crash and memory leakage when
- * &BL_ActionActuator::m_pose is freed
- */
- game_copy_pose(pose, m_pose, 0);
- }
- else {
- if (*pose == m_pose)
- // no need to copy if the pointers are the same
- return;
-
- extract_pose_from_pose(*pose, m_pose);
- }
-}
-
-double BL_ArmatureObject::GetLastFrame()
-{
- return m_lastframe;
-}
-
-bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix)
-{
- bPoseChannel *pchan;
-
- ApplyPose();
- pchan = BKE_pose_channel_find_name(m_objArma->pose, bone->name);
- if (pchan)
- matrix.setValue(&pchan->pose_mat[0][0]);
- RestorePose();
-
- return (pchan != NULL);
-}
-
-float BL_ArmatureObject::GetBoneLength(Bone* bone) const
-{
- return (float)(MT_Point3(bone->head) - MT_Point3(bone->tail)).length();
-}
-
-#ifdef WITH_PYTHON
-
-// PYTHON
-
-PyTypeObject BL_ArmatureObject::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "BL_ArmatureObject",
- sizeof(PyObjectPlus_Proxy),
- 0,
- py_base_dealloc,
- 0,
- 0,
- 0,
- 0,
- py_base_repr,
- 0,
- &KX_GameObject::Sequence,
- &KX_GameObject::Mapping,
- 0,0,0,
- NULL,
- NULL,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- 0,0,0,0,0,0,0,
- Methods,
- 0,
- 0,
- &KX_GameObject::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef BL_ArmatureObject::Methods[] = {
- KX_PYMETHODTABLE_NOARGS(BL_ArmatureObject, update),
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef BL_ArmatureObject::Attributes[] = {
-
- KX_PYATTRIBUTE_RO_FUNCTION("constraints", BL_ArmatureObject, pyattr_get_constraints),
- KX_PYATTRIBUTE_RO_FUNCTION("channels", BL_ArmatureObject, pyattr_get_channels),
- {NULL} //Sentinel
-};
-
-static int bl_armature_object_get_constraints_size_cb(void *self_v)
-{
- return ((BL_ArmatureObject *)self_v)->GetConstraintNumber();
-}
-
-static PyObject *bl_armature_object_get_constraints_item_cb(void *self_v, int index)
-{
- return ((BL_ArmatureObject *)self_v)->GetConstraint(index)->GetProxy();
-}
-
-static const char *bl_armature_object_get_constraints_item_name_cb(void *self_v, int index)
-{
- return ((BL_ArmatureObject *)self_v)->GetConstraint(index)->GetName();
-}
-
-PyObject *BL_ArmatureObject::pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- return (new CListWrapper(self_v,
- ((BL_ArmatureObject *)self_v)->GetProxy(),
- NULL,
- bl_armature_object_get_constraints_size_cb,
- bl_armature_object_get_constraints_item_cb,
- bl_armature_object_get_constraints_item_name_cb,
- NULL))->NewProxy(true);
-}
-
-static int bl_armature_object_get_channels_size_cb(void *self_v)
-{
- return ((BL_ArmatureObject *)self_v)->GetChannelNumber();
-}
-
-static PyObject *bl_armature_object_get_channels_item_cb(void *self_v, int index)
-{
- return ((BL_ArmatureObject *)self_v)->GetChannel(index)->GetProxy();
-}
-
-static const char *bl_armature_object_get_channels_item_name_cb(void *self_v, int index)
-{
- return ((BL_ArmatureObject *)self_v)->GetChannel(index)->GetName();
-}
-
-PyObject *BL_ArmatureObject::pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- BL_ArmatureObject *self = static_cast<BL_ArmatureObject *>(self_v);
- self->LoadChannels(); // make sure we have the channels
- return (new CListWrapper(self_v,
- self->GetProxy(),
- NULL,
- bl_armature_object_get_channels_size_cb,
- bl_armature_object_get_channels_item_cb,
- bl_armature_object_get_channels_item_name_cb,
- NULL))->NewProxy(true);
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(BL_ArmatureObject, update,
- "update()\n"
- "Make sure that the armature will be updated on next graphic frame.\n"
- "This is automatically done if a KX_ArmatureActuator with mode run is active\n"
- "or if an action is playing. This function is useful in other cases.\n")
-{
- UpdateTimestep(KX_GetActiveEngine()->GetFrameTime());
- Py_RETURN_NONE;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h
deleted file mode 100644
index 691e73d6bde..00000000000
--- a/source/gameengine/Converter/BL_ArmatureObject.h
+++ /dev/null
@@ -1,145 +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 BL_ArmatureObject.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_ARMATUREOBJECT_H__
-#define __BL_ARMATUREOBJECT_H__
-
-#include "KX_GameObject.h"
-#include "BL_ArmatureConstraint.h"
-#include "BL_ArmatureChannel.h"
-
-#include "SG_IObject.h"
-#include <vector>
-#include <algorithm>
-
-struct bArmature;
-struct Bone;
-struct bConstraint;
-class BL_ActionActuator;
-class BL_ArmatureActuator;
-class MT_Matrix4x4;
-struct Object;
-class KX_BlenderSceneConverter;
-
-class BL_ArmatureObject : public KX_GameObject
-{
- Py_Header
-public:
-
- double GetLastFrame ();
- virtual void ProcessReplica();
- virtual void ReParentLogic();
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
- virtual bool UnlinkObject(SCA_IObject* clientobj);
-
- BL_ArmatureObject(
- void* sgReplicationInfo,
- SG_Callbacks callbacks,
- Object *armature,
- Scene *scene,
- int vert_deform_type
- );
- virtual ~BL_ArmatureObject();
-
- virtual CValue* GetReplica();
- void GetPose(struct bPose **pose);
- void SetPose (struct bPose *pose);
- struct bPose *GetOrigPose() {return m_pose;} // never edit this, only for accessing names
-
- void ApplyPose();
- void SetPoseByAction(struct bAction* action, float localtime);
- void BlendInPose(struct bPose *blend_pose, float weight, short mode);
- void RestorePose();
-
- bool UpdateTimestep(double curtime);
-
- struct bArmature *GetArmature() { return (bArmature*)m_objArma->data; }
- const struct bArmature * GetArmature() const { return (bArmature*)m_objArma->data; }
- const struct Scene * GetScene() const { return m_scene; }
-
- Object* GetArmatureObject() {return m_objArma;}
- Object* GetOrigArmatureObject() {return m_origObjArma;}
-
- int GetVertDeformType() {return m_vert_deform_type;}
-
- // for constraint python API
- void LoadConstraints(KX_BlenderSceneConverter* converter);
- size_t GetConstraintNumber() const { return m_constraintNumber; }
- BL_ArmatureConstraint* GetConstraint(const char* posechannel, const char* constraint);
- BL_ArmatureConstraint* GetConstraint(const char* posechannelconstraint);
- BL_ArmatureConstraint* GetConstraint(int index);
- // for pose channel python API
- void LoadChannels();
- size_t GetChannelNumber() const { return m_channelNumber; }
- BL_ArmatureChannel* GetChannel(bPoseChannel* channel);
- BL_ArmatureChannel* GetChannel(const char* channel);
- BL_ArmatureChannel* GetChannel(int index);
-
- /// Retrieve the pose matrix for the specified bone.
- /// Returns true on success.
- bool GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix);
-
- /// Returns the bone length. The end of the bone is in the local y direction.
- float GetBoneLength(Bone* bone) const;
-
- virtual int GetGameObjectType() { return OBJ_ARMATURE; }
-
-#ifdef WITH_PYTHON
-
- // PYTHON
- static PyObject *pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- KX_PYMETHOD_DOC_NOARGS(BL_ArmatureObject, update);
-
-#endif /* WITH_PYTHON */
-
-protected:
- /* list element: BL_ArmatureConstraint. Use SG_DListHead to have automatic list replication */
- SG_DListHead<BL_ArmatureConstraint> m_controlledConstraints;
- /* list element: BL_ArmatureChannel. Use SG_DList to avoid list replication */
- SG_DList m_poseChannels;
- Object *m_objArma;
- Object *m_origObjArma;
- struct bPose *m_pose;
- struct bPose *m_armpose;
- struct Scene *m_scene; // need for BKE_pose_where_is
- double m_lastframe;
- double m_timestep; // delta since last pose evaluation.
- int m_vert_deform_type;
- size_t m_constraintNumber;
- size_t m_channelNumber;
- // store the original armature object matrix
- float m_obmat[4][4];
-
- double m_lastapplyframe;
-};
-
-#endif /* __BL_ARMATUREOBJECT_H__ */
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
deleted file mode 100644
index 39f517e03e8..00000000000
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ /dev/null
@@ -1,2473 +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 *****
- * Convert blender data to ketsji
- */
-
-/** \file gameengine/Converter/BL_BlenderDataConversion.cpp
- * \ingroup bgeconv
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-/* Since threaded object update we've disabled in-place
- * curve evaluation (in cases when applying curve modifier
- * with target curve non-evaluated yet).
- *
- * This requires game engine to take care of DAG and object
- * evaluation (currently it's designed to export only objects
- * it able to render).
- *
- * This workaround will make sure that curve_cache for curves
- * is up-to-date.
- */
-
-/* TODO: Disabled for now, because of eval_ctx. */
-//#define THREADED_DAG_WORKAROUND
-
-#include <math.h>
-#include <vector>
-#include <algorithm>
-
-#include "BL_BlenderDataConversion.h"
-
-#include "MT_Transform.h"
-#include "MT_MinMax.h"
-
-#include "PHY_Pro.h"
-#include "PHY_IPhysicsEnvironment.h"
-
-#include "RAS_MeshObject.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_ILightObject.h"
-
-#include "KX_ConvertActuators.h"
-#include "KX_ConvertControllers.h"
-#include "KX_ConvertSensors.h"
-#include "SCA_LogicManager.h"
-#include "SCA_TimeEventManager.h"
-
-#include "KX_ClientObjectInfo.h"
-#include "KX_Scene.h"
-#include "KX_GameObject.h"
-#include "KX_Light.h"
-#include "KX_Camera.h"
-#include "KX_EmptyObject.h"
-#include "KX_FontObject.h"
-
-#include "RAS_TexMatrix.h"
-#include "RAS_ICanvas.h"
-#include "RAS_Polygon.h"
-#include "RAS_TexVert.h"
-#include "RAS_BucketManager.h"
-#include "RAS_IPolygonMaterial.h"
-#include "BL_Material.h"
-#include "KX_BlenderMaterial.h"
-#include "BL_Texture.h"
-
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_object.h"
-#include "BL_ModifierDeformer.h"
-#include "BL_ShapeDeformer.h"
-#include "BL_SkinDeformer.h"
-#include "BL_MeshDeformer.h"
-#include "KX_SoftBodyDeformer.h"
-#include "BLI_utildefines.h"
-#include "BLI_listbase.h"
-
-#include "KX_WorldInfo.h"
-
-#include "KX_KetsjiEngine.h"
-#include "KX_BlenderSceneConverter.h"
-
-/* This little block needed for linking to Blender... */
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#endif
-
-/* This list includes only data type definitions */
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_image_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_group_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_property_types.h"
-#include "DNA_text_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_world_types.h"
-#include "DNA_sound_types.h"
-#include "DNA_key_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_action_types.h"
-#include "DNA_object_force_types.h"
-#include "DNA_constraint_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BKE_key.h"
-#include "BKE_mesh.h"
-
-#include "BLI_math.h"
-
-extern "C" {
-#include "BKE_scene.h"
-#include "BKE_customdata.h"
-#include "BKE_cdderivedmesh.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_group.h"
-#include "BKE_layer.h"
-#include "BKE_material.h" /* give_current_material */
-#include "BKE_image.h"
-#include "IMB_imbuf_types.h"
-#include "BKE_displist.h"
-
-extern Material defmaterial; /* material.c */
-}
-
-/* end of blender include block */
-
-#include "KX_BlenderInputDevice.h"
-#include "KX_ConvertProperties.h"
-
-#include "SG_Node.h"
-#include "SG_BBox.h"
-#include "SG_Tree.h"
-#include "KX_SG_NodeRelationships.h"
-#include "KX_SG_BoneParentNodeRelationship.h"
-
-#ifdef WITH_BULLET
-#include "CcdPhysicsEnvironment.h"
-#include "CcdGraphicController.h"
-#endif
-
-#include "KX_MotionState.h"
-
-#include "BL_ArmatureObject.h"
-#include "BL_DeformableGameObject.h"
-
-#include "KX_NavMeshObject.h"
-#include "KX_ObstacleSimulation.h"
-
-#include "BLI_threads.h"
-
-
-static bool default_light_mode = 0;
-
-static std::map<int, SCA_IInputDevice::KX_EnumInputs> create_translate_table()
-{
- std::map<int, SCA_IInputDevice::KX_EnumInputs> m;
-
- /* The reverse table. In order to not confuse ourselves, we */
- /* immediately convert all events that come in to KX codes. */
- m[LEFTMOUSE ] = SCA_IInputDevice::KX_LEFTMOUSE;
- m[MIDDLEMOUSE ] = SCA_IInputDevice::KX_MIDDLEMOUSE;
- m[RIGHTMOUSE ] = SCA_IInputDevice::KX_RIGHTMOUSE;
- m[WHEELUPMOUSE ] = SCA_IInputDevice::KX_WHEELUPMOUSE;
- m[WHEELDOWNMOUSE ] = SCA_IInputDevice::KX_WHEELDOWNMOUSE;
- m[MOUSEX ] = SCA_IInputDevice::KX_MOUSEX;
- m[MOUSEY ] = SCA_IInputDevice::KX_MOUSEY;
-
- // TIMERS
-
- m[TIMER0 ] = SCA_IInputDevice::KX_TIMER0;
- m[TIMER1 ] = SCA_IInputDevice::KX_TIMER1;
- m[TIMER2 ] = SCA_IInputDevice::KX_TIMER2;
-
- // SYSTEM
-
-#if 0
- /* **** XXX **** */
- m[KEYBD ] = SCA_IInputDevice::KX_KEYBD;
- m[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD;
- m[REDRAW ] = SCA_IInputDevice::KX_REDRAW;
- m[INPUTCHANGE ] = SCA_IInputDevice::KX_INPUTCHANGE;
- m[QFULL ] = SCA_IInputDevice::KX_QFULL;
- m[WINFREEZE ] = SCA_IInputDevice::KX_WINFREEZE;
- m[WINTHAW ] = SCA_IInputDevice::KX_WINTHAW;
- m[WINCLOSE ] = SCA_IInputDevice::KX_WINCLOSE;
- m[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT;
- m[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME;
- /* **** XXX **** */
-#endif
-
- // standard keyboard
-
- m[AKEY ] = SCA_IInputDevice::KX_AKEY;
- m[BKEY ] = SCA_IInputDevice::KX_BKEY;
- m[CKEY ] = SCA_IInputDevice::KX_CKEY;
- m[DKEY ] = SCA_IInputDevice::KX_DKEY;
- m[EKEY ] = SCA_IInputDevice::KX_EKEY;
- m[FKEY ] = SCA_IInputDevice::KX_FKEY;
- m[GKEY ] = SCA_IInputDevice::KX_GKEY;
- m[HKEY ] = SCA_IInputDevice::KX_HKEY;
- m[IKEY ] = SCA_IInputDevice::KX_IKEY;
- m[JKEY ] = SCA_IInputDevice::KX_JKEY;
- m[KKEY ] = SCA_IInputDevice::KX_KKEY;
- m[LKEY ] = SCA_IInputDevice::KX_LKEY;
- m[MKEY ] = SCA_IInputDevice::KX_MKEY;
- m[NKEY ] = SCA_IInputDevice::KX_NKEY;
- m[OKEY ] = SCA_IInputDevice::KX_OKEY;
- m[PKEY ] = SCA_IInputDevice::KX_PKEY;
- m[QKEY ] = SCA_IInputDevice::KX_QKEY;
- m[RKEY ] = SCA_IInputDevice::KX_RKEY;
- m[SKEY ] = SCA_IInputDevice::KX_SKEY;
- m[TKEY ] = SCA_IInputDevice::KX_TKEY;
- m[UKEY ] = SCA_IInputDevice::KX_UKEY;
- m[VKEY ] = SCA_IInputDevice::KX_VKEY;
- m[WKEY ] = SCA_IInputDevice::KX_WKEY;
- m[XKEY ] = SCA_IInputDevice::KX_XKEY;
- m[YKEY ] = SCA_IInputDevice::KX_YKEY;
- m[ZKEY ] = SCA_IInputDevice::KX_ZKEY;
-
- m[ZEROKEY ] = SCA_IInputDevice::KX_ZEROKEY;
- m[ONEKEY ] = SCA_IInputDevice::KX_ONEKEY;
- m[TWOKEY ] = SCA_IInputDevice::KX_TWOKEY;
- m[THREEKEY ] = SCA_IInputDevice::KX_THREEKEY;
- m[FOURKEY ] = SCA_IInputDevice::KX_FOURKEY;
- m[FIVEKEY ] = SCA_IInputDevice::KX_FIVEKEY;
- m[SIXKEY ] = SCA_IInputDevice::KX_SIXKEY;
- m[SEVENKEY ] = SCA_IInputDevice::KX_SEVENKEY;
- m[EIGHTKEY ] = SCA_IInputDevice::KX_EIGHTKEY;
- m[NINEKEY ] = SCA_IInputDevice::KX_NINEKEY;
-
- m[CAPSLOCKKEY ] = SCA_IInputDevice::KX_CAPSLOCKKEY;
-
- m[LEFTCTRLKEY ] = SCA_IInputDevice::KX_LEFTCTRLKEY;
- m[LEFTALTKEY ] = SCA_IInputDevice::KX_LEFTALTKEY;
- m[RIGHTALTKEY ] = SCA_IInputDevice::KX_RIGHTALTKEY;
- m[RIGHTCTRLKEY ] = SCA_IInputDevice::KX_RIGHTCTRLKEY;
- m[RIGHTSHIFTKEY ] = SCA_IInputDevice::KX_RIGHTSHIFTKEY;
- m[LEFTSHIFTKEY ] = SCA_IInputDevice::KX_LEFTSHIFTKEY;
-
- m[ESCKEY ] = SCA_IInputDevice::KX_ESCKEY;
- m[TABKEY ] = SCA_IInputDevice::KX_TABKEY;
- m[RETKEY ] = SCA_IInputDevice::KX_RETKEY;
- m[SPACEKEY ] = SCA_IInputDevice::KX_SPACEKEY;
- m[LINEFEEDKEY ] = SCA_IInputDevice::KX_LINEFEEDKEY;
- m[BACKSPACEKEY ] = SCA_IInputDevice::KX_BACKSPACEKEY;
- m[DELKEY ] = SCA_IInputDevice::KX_DELKEY;
- m[SEMICOLONKEY ] = SCA_IInputDevice::KX_SEMICOLONKEY;
- m[PERIODKEY ] = SCA_IInputDevice::KX_PERIODKEY;
- m[COMMAKEY ] = SCA_IInputDevice::KX_COMMAKEY;
- m[QUOTEKEY ] = SCA_IInputDevice::KX_QUOTEKEY;
- m[ACCENTGRAVEKEY ] = SCA_IInputDevice::KX_ACCENTGRAVEKEY;
- m[MINUSKEY ] = SCA_IInputDevice::KX_MINUSKEY;
- m[PLUSKEY ] = SCA_IInputDevice::KX_PLUSKEY;
- m[SLASHKEY ] = SCA_IInputDevice::KX_SLASHKEY;
- m[BACKSLASHKEY ] = SCA_IInputDevice::KX_BACKSLASHKEY;
- m[EQUALKEY ] = SCA_IInputDevice::KX_EQUALKEY;
- m[LEFTBRACKETKEY ] = SCA_IInputDevice::KX_LEFTBRACKETKEY;
- m[RIGHTBRACKETKEY ] = SCA_IInputDevice::KX_RIGHTBRACKETKEY;
-
- m[LEFTARROWKEY ] = SCA_IInputDevice::KX_LEFTARROWKEY;
- m[DOWNARROWKEY ] = SCA_IInputDevice::KX_DOWNARROWKEY;
- m[RIGHTARROWKEY ] = SCA_IInputDevice::KX_RIGHTARROWKEY;
- m[UPARROWKEY ] = SCA_IInputDevice::KX_UPARROWKEY;
-
- m[PAD2 ] = SCA_IInputDevice::KX_PAD2;
- m[PAD4 ] = SCA_IInputDevice::KX_PAD4;
- m[PAD6 ] = SCA_IInputDevice::KX_PAD6;
- m[PAD8 ] = SCA_IInputDevice::KX_PAD8;
-
- m[PAD1 ] = SCA_IInputDevice::KX_PAD1;
- m[PAD3 ] = SCA_IInputDevice::KX_PAD3;
- m[PAD5 ] = SCA_IInputDevice::KX_PAD5;
- m[PAD7 ] = SCA_IInputDevice::KX_PAD7;
- m[PAD9 ] = SCA_IInputDevice::KX_PAD9;
-
- m[PADPERIOD ] = SCA_IInputDevice::KX_PADPERIOD;
- m[PADSLASHKEY ] = SCA_IInputDevice::KX_PADSLASHKEY;
- m[PADASTERKEY ] = SCA_IInputDevice::KX_PADASTERKEY;
-
- m[PAD0 ] = SCA_IInputDevice::KX_PAD0;
- m[PADMINUS ] = SCA_IInputDevice::KX_PADMINUS;
- m[PADENTER ] = SCA_IInputDevice::KX_PADENTER;
- m[PADPLUSKEY ] = SCA_IInputDevice::KX_PADPLUSKEY;
-
-
- m[F1KEY ] = SCA_IInputDevice::KX_F1KEY;
- m[F2KEY ] = SCA_IInputDevice::KX_F2KEY;
- m[F3KEY ] = SCA_IInputDevice::KX_F3KEY;
- m[F4KEY ] = SCA_IInputDevice::KX_F4KEY;
- m[F5KEY ] = SCA_IInputDevice::KX_F5KEY;
- m[F6KEY ] = SCA_IInputDevice::KX_F6KEY;
- m[F7KEY ] = SCA_IInputDevice::KX_F7KEY;
- m[F8KEY ] = SCA_IInputDevice::KX_F8KEY;
- m[F9KEY ] = SCA_IInputDevice::KX_F9KEY;
- m[F10KEY ] = SCA_IInputDevice::KX_F10KEY;
- m[F11KEY ] = SCA_IInputDevice::KX_F11KEY;
- m[F12KEY ] = SCA_IInputDevice::KX_F12KEY;
- m[F13KEY ] = SCA_IInputDevice::KX_F13KEY;
- m[F14KEY ] = SCA_IInputDevice::KX_F14KEY;
- m[F15KEY ] = SCA_IInputDevice::KX_F15KEY;
- m[F16KEY ] = SCA_IInputDevice::KX_F16KEY;
- m[F17KEY ] = SCA_IInputDevice::KX_F17KEY;
- m[F18KEY ] = SCA_IInputDevice::KX_F18KEY;
- m[F19KEY ] = SCA_IInputDevice::KX_F19KEY;
-
- m[OSKEY ] = SCA_IInputDevice::KX_OSKEY;
-
- m[PAUSEKEY ] = SCA_IInputDevice::KX_PAUSEKEY;
- m[INSERTKEY ] = SCA_IInputDevice::KX_INSERTKEY;
- m[HOMEKEY ] = SCA_IInputDevice::KX_HOMEKEY;
- m[PAGEUPKEY ] = SCA_IInputDevice::KX_PAGEUPKEY;
- m[PAGEDOWNKEY ] = SCA_IInputDevice::KX_PAGEDOWNKEY;
- m[ENDKEY ] = SCA_IInputDevice::KX_ENDKEY;
-
- return m;
-}
-
-static std::map<int, SCA_IInputDevice::KX_EnumInputs> gReverseKeyTranslateTable = create_translate_table();
-
-SCA_IInputDevice::KX_EnumInputs ConvertKeyCode(int key_code)
-{
- return gReverseKeyTranslateTable[key_code];
-}
-
-static unsigned int KX_rgbaint2uint_new(unsigned int icol)
-{
- union
- {
- unsigned int integer;
- unsigned char cp[4];
- } out_color, in_color;
-
- in_color.integer = icol;
- out_color.cp[0] = in_color.cp[3]; // red
- out_color.cp[1] = in_color.cp[2]; // green
- out_color.cp[2] = in_color.cp[1]; // blue
- out_color.cp[3] = in_color.cp[0]; // alpha
-
- return out_color.integer;
-}
-
-/* Now the real converting starts... */
-static unsigned int KX_Mcol2uint_new(MCol col)
-{
- /* color has to be converted without endian sensitivity. So no shifting! */
- union
- {
- MCol col;
- unsigned int integer;
- unsigned char cp[4];
- } out_color, in_color;
-
- in_color.col = col;
- out_color.cp[0] = in_color.cp[3]; // red
- out_color.cp[1] = in_color.cp[2]; // green
- out_color.cp[2] = in_color.cp[1]; // blue
- out_color.cp[3] = in_color.cp[0]; // alpha
-
- return out_color.integer;
-}
-
-static void SetDefaultLightMode(Scene* scene)
-{
- default_light_mode = false;
- Scene *sce_iter;
- Base *base;
-
- for (SETLOOPER(scene, sce_iter, base))
- {
- if (base->object->type == OB_LAMP)
- {
- default_light_mode = true;
- return;
- }
- }
-}
-
-
-static bool GetMaterialUseVColor(Material *ma, const bool glslmat)
-{
- if (ma) {
- /* glsl uses vertex colors, otherwise use material setting
- * defmaterial doesn't have VERTEXCOLP as default [#34505] */
- return (glslmat || ma == &defmaterial || (ma->mode & MA_VERTEXCOLP) != 0);
- }
- else {
- /* no material, use vertex colors */
- return true;
- }
-}
-
-// --
-static void GetRGB(
- const bool use_vcol,
- MFace* mface,
- MCol* mmcol,
- Material *mat,
- unsigned int c[4])
-{
- unsigned int color = 0xFFFFFFFFL;
- if (use_vcol == true) {
- if (mmcol) {
- c[0] = KX_Mcol2uint_new(mmcol[0]);
- c[1] = KX_Mcol2uint_new(mmcol[1]);
- c[2] = KX_Mcol2uint_new(mmcol[2]);
- if (mface->v4)
- c[3] = KX_Mcol2uint_new(mmcol[3]);
- }
- else { // backup white
- c[0] = KX_rgbaint2uint_new(color);
- c[1] = KX_rgbaint2uint_new(color);
- c[2] = KX_rgbaint2uint_new(color);
- if (mface->v4)
- c[3] = KX_rgbaint2uint_new( color );
- }
- }
- else {
- /* material rgba */
- if (mat) {
- union {
- unsigned char cp[4];
- unsigned int integer;
- } col_converter;
- col_converter.cp[3] = (unsigned char) (mat->r * 255.0f);
- col_converter.cp[2] = (unsigned char) (mat->g * 255.0f);
- col_converter.cp[1] = (unsigned char) (mat->b * 255.0f);
- col_converter.cp[0] = (unsigned char) (mat->alpha * 255.0f);
- color = col_converter.integer;
- }
- c[0] = KX_rgbaint2uint_new(color);
- c[1] = KX_rgbaint2uint_new(color);
- c[2] = KX_rgbaint2uint_new(color);
- if (mface->v4) {
- c[3] = KX_rgbaint2uint_new(color);
- }
- }
-
-#if 0 /* white, unused */
- {
- c[0] = KX_rgbaint2uint_new(color);
- c[1] = KX_rgbaint2uint_new(color);
- c[2] = KX_rgbaint2uint_new(color);
- if (mface->v4)
- c[3] = KX_rgbaint2uint_new(color);
- }
-#endif
-}
-
-typedef struct MTF_localLayer {
- MTFace *face;
- const char *name;
-} MTF_localLayer;
-
-static void GetUVs(BL_Material *material, MTF_localLayer *layers, MFace *mface, MTFace *tface, MT_Point2 uvs[4][MAXTEX])
-{
- int unit = 0;
- 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]);
- }
- else
- {
- uvs[0][0] = uvs[1][0] = uvs[2][0] = uvs[3][0] = MT_Point2(0.f, 0.f);
- }
-
- vector<STR_String> found_layers;
-
- for (int vind = 0; vind<MAXTEX; vind++)
- {
- BL_Mapping &map = material->mapping[vind];
-
- if (!(map.mapping & USEUV)) continue;
-
- if (std::find(found_layers.begin(), found_layers.end(), map.uvCoName) != found_layers.end())
- continue;
-
- //If no UVSet is specified, try grabbing one from the UV/Image editor
- if (map.uvCoName.IsEmpty() && tface)
- {
- uvs[0][unit].setValue(tface->uv[0]);
- uvs[1][unit].setValue(tface->uv[1]);
- uvs[2][unit].setValue(tface->uv[2]);
-
- if (mface->v4)
- uvs[3][unit].setValue(tface->uv[3]);
-
- ++unit;
- continue;
- }
-
-
- for (int lay=0; lay<MAX_MTFACE; lay++)
- {
- MTF_localLayer& layer = layers[lay];
- if (layer.face == 0) break;
-
- if (map.uvCoName.IsEmpty() || strcmp(map.uvCoName.ReadPtr(), layer.name)==0)
- {
- uvs[0][unit].setValue(layer.face->uv[0]);
- uvs[1][unit].setValue(layer.face->uv[1]);
- uvs[2][unit].setValue(layer.face->uv[2]);
-
- if (mface->v4)
- uvs[3][unit].setValue(layer.face->uv[3]);
- else
- uvs[3][unit].setValue(0.0f, 0.0f);
-
- ++unit;
- found_layers.push_back(map.uvCoName);
- break;
- }
- }
- }
-}
-
-// ------------------------------------
-static bool ConvertMaterial(
- BL_Material *material,
- Material *mat,
- MTFace *tface,
- const char *tfaceName,
- MFace *mface,
- MCol *mmcol,
- bool glslmat)
-{
- material->Initialize();
- int texalpha = 0;
- const bool validmat = (mat != NULL);
- const bool validface = (tface != NULL);
- const bool use_vcol = GetMaterialUseVColor(mat, glslmat);
-
- material->IdMode = DEFAULT_BLENDER;
- material->glslmat = (validmat) ? glslmat: false;
- material->materialindex = mface->mat_nr;
-
- // --------------------------------
- if (validmat) {
-
- // use lighting?
- material->ras_mode |= (mat->mode & MA_SHLESS) ? 0 : USE_LIGHT;
- material->ras_mode |= (mat->game.flag & GEMAT_BACKCULL) ? 0 : TWOSIDED;
-
- // cast shadows?
- material->ras_mode |= ((mat->mode2 & MA_CASTSHADOW) && (mat->mode & MA_SHADBUF)) ? CAST_SHADOW : 0;
-
- // only shadows?
- material->ras_mode |= (mat->mode & MA_ONLYCAST) ? ONLY_SHADOW : 0;
-
- MTex *mttmp = NULL;
- int valid_index = 0;
-
- /* In Multitexture use the face texture if and only if
- * it is set in the buttons
- * In GLSL is not working yet :/ 3.2011 */
-
- // foreach MTex
- for (int i = 0; i < MAXTEX; i++) {
- // use face tex
- if (i == 0) {
-#if 0
- Image *tmp = (Image *)(tface->tpage);
-#else
- /* weak but better then nothing */
- Image *tmp = mat ? mat->edit_image : NULL;
-#endif
-
- if (tmp) {
- material->img[i] = tmp;
- material->texname[i] = material->img[i]->id.name;
- material->flag[i] |= MIPMAP;
-
- material->flag[i] |= (mat->game.alpha_blend & GEMAT_ALPHA_SORT) ? USEALPHA : 0;
- material->flag[i] |= (mat->game.alpha_blend & GEMAT_ALPHA) ? USEALPHA : 0;
- material->flag[i] |= (mat->game.alpha_blend & GEMAT_ADD) ? CALCALPHA : 0;
-
- if (material->img[i]->flag & IMA_REFLECT) {
- material->mapping[i].mapping |= USEREFL;
- }
- else {
- mttmp = getMTexFromMaterial(mat, i);
- if (mttmp && (mttmp->texco & TEXCO_UV)) {
- /* string may be "" but thats detected as empty after */
- material->mapping[i].uvCoName = mttmp->uvname;
- }
- material->mapping[i].mapping |= USEUV;
- }
-
- valid_index++;
- }
- else {
- material->img[i] = 0;
- material->texname[i] = "";
- }
- continue;
- }
-
- mttmp = getMTexFromMaterial(mat, i);
- if (mttmp) {
- if (mttmp->tex) {
- if (mttmp->tex->type == TEX_IMAGE) {
- material->mtexname[i] = mttmp->tex->id.name;
- material->img[i] = mttmp->tex->ima;
- if (material->img[i]) {
-
- material->texname[i] = material->img[i]->id.name;
- material->flag[i] |= (mttmp->tex->imaflag &TEX_MIPMAP) ? MIPMAP : 0;
- if (material->img[i] && (material->img[i]->flag & IMA_IGNORE_ALPHA) == 0) {
- material->flag[i] |= USEALPHA;
- }
- if (mttmp->tex->imaflag & TEX_CALCALPHA) {
- material->flag[i] |= CALCALPHA;
- }
- else if (mttmp->tex->flag & TEX_NEGALPHA) {
- material->flag[i] |= USENEGALPHA;
- }
-
- material->color_blend[i] = mttmp->colfac;
- material->flag[i] |= (mttmp->mapto & MAP_ALPHA) ? TEXALPHA : 0;
- material->flag[i] |= (mttmp->texflag & MTEX_NEGATIVE) ? TEXNEG : 0;
-
- if (!glslmat && (material->flag[i] & TEXALPHA)) {
- texalpha = 1;
- }
- }
- }
- else if (mttmp->tex->type == TEX_ENVMAP) {
- if (mttmp->tex->env->stype == ENV_LOAD) {
- material->mtexname[i] = mttmp->tex->id.name;
- EnvMap *env = mttmp->tex->env;
- env->ima = mttmp->tex->ima;
- material->cubemap[i] = env;
-
- if (material->cubemap[i]) {
- if (!material->cubemap[i]->cube[0]) {
- BL_Texture::SplitEnvMap(material->cubemap[i]);
- }
-
- material->texname[i] = material->cubemap[i]->ima->id.name;
- material->mapping[i].mapping |= USEENV;
- }
- }
- }
-#if 0 /* this flag isn't used anymore */
- material->flag[i] |= (BKE_animdata_from_id(mat->id) != NULL) ? HASIPO : 0;
-#endif
- /// --------------------------------
- // mapping methods
- if (mat->septex & (1 << i)) {
- // If this texture slot isn't in use, set it to disabled to prevent multi-uv problems
- material->mapping[i].mapping = DISABLE;
- }
- else {
- material->mapping[i].mapping |= (mttmp->texco & TEXCO_REFL) ? USEREFL : 0;
-
- if (mttmp->texco & TEXCO_OBJECT) {
- material->mapping[i].mapping |= USEOBJ;
- if (mttmp->object) {
- material->mapping[i].objconame = mttmp->object->id.name;
- }
- }
- else if (mttmp->texco & TEXCO_REFL) {
- material->mapping[i].mapping |= USEREFL;
- }
- else if (mttmp->texco & (TEXCO_ORCO | TEXCO_GLOB)) {
- material->mapping[i].mapping |= USEORCO;
- }
- else if (mttmp->texco & TEXCO_UV) {
- /* string may be "" but thats detected as empty after */
- material->mapping[i].uvCoName = mttmp->uvname;
- material->mapping[i].mapping |= USEUV;
- }
- else if (mttmp->texco & TEXCO_NORM) {
- material->mapping[i].mapping |= USENORM;
- }
- else if (mttmp->texco & TEXCO_TANGENT) {
- material->mapping[i].mapping |= USETANG;
- }
- else {
- material->mapping[i].mapping |= DISABLE;
- }
-
- material->mapping[i].scale[0] = mttmp->size[0];
- material->mapping[i].scale[1] = mttmp->size[1];
- material->mapping[i].scale[2] = mttmp->size[2];
- material->mapping[i].offsets[0] = mttmp->ofs[0];
- material->mapping[i].offsets[1] = mttmp->ofs[1];
- material->mapping[i].offsets[2] = mttmp->ofs[2];
-
- material->mapping[i].projplane[0] = mttmp->projx;
- material->mapping[i].projplane[1] = mttmp->projy;
- material->mapping[i].projplane[2] = mttmp->projz;
- }
- /// --------------------------------
-
- switch (mttmp->blendtype) {
- case MTEX_BLEND:
- material->blend_mode[i] = BLEND_MIX;
- break;
- case MTEX_MUL:
- material->blend_mode[i] = BLEND_MUL;
- break;
- case MTEX_ADD:
- material->blend_mode[i] = BLEND_ADD;
- break;
- case MTEX_SUB:
- material->blend_mode[i] = BLEND_SUB;
- break;
- case MTEX_SCREEN:
- material->blend_mode[i] = BLEND_SCR;
- break;
- }
- valid_index++;
- }
- }
- }
-
- // above one tex the switches here
- // are not used
- switch (valid_index) {
- case 0:
- material->IdMode = DEFAULT_BLENDER;
- break;
- case 1:
- material->IdMode = ONETEX;
- break;
- default:
- material->IdMode = GREATERTHAN2;
- break;
- }
- material->SetUsers(mat->id.us);
-
- material->num_enabled = valid_index;
-
- material->speccolor[0] = mat->specr;
- material->speccolor[1] = mat->specg;
- material->speccolor[2] = mat->specb;
- material->hard = (float)mat->har / 4.0f;
- material->matcolor[0] = mat->r;
- material->matcolor[1] = mat->g;
- material->matcolor[2] = mat->b;
- material->matcolor[3] = mat->alpha;
- material->alpha = mat->alpha;
- material->emit = mat->emit;
- material->spec_f = mat->spec;
- material->ref = mat->ref;
- material->amb = mat->amb;
-
- material->ras_mode |= (mat->material_type == MA_TYPE_WIRE) ? WIRE : 0;
- }
- else { // No Material
- int valid = 0;
-
- // check for tface tex to fallback on
- if (validface) {
-#if 0
- material->img[0] = (Image *)(tface->tpage);
-#else
- material->img[0] = mat ? mat->edit_image : NULL;
-#endif
- // ------------------------
- if (material->img[0]) {
- material->texname[0] = material->img[0]->id.name;
- material->mapping[0].mapping |= ((material->img[0]->flag & IMA_REFLECT) != 0) ? USEREFL : 0;
-
- /* see if depth of the image is 32bits */
- if (BKE_image_has_alpha(material->img[0])) {
- material->flag[0] |= USEALPHA;
- material->alphablend = GEMAT_ALPHA;
- }
- else {
- material->alphablend = GEMAT_SOLID;
- }
- valid++;
- }
- }
- else {
- material->alphablend = GEMAT_SOLID;
- }
-
- material->SetUsers(-1);
- material->num_enabled = valid;
- material->IdMode = TEXFACE;
- material->speccolor[0] = 1.0f;
- material->speccolor[1] = 1.0f;
- material->speccolor[2] = 1.0f;
- material->hard = 35.0f;
- material->matcolor[0] = 0.5f;
- material->matcolor[1] = 0.5f;
- material->matcolor[2] = 0.5f;
- material->spec_f = 0.5f;
- material->ref = 0.8f;
-
- // No material - old default TexFace properties
- material->ras_mode |= USE_LIGHT;
- }
-
- /* No material, what to do? let's see what is in the UV and set the material accordingly
- * light and visible is always on */
- if (validface) {
- /* nop */
- }
- else {
- // nothing at all
- material->alphablend = GEMAT_SOLID;
- material->tile = 0;
- }
-
- if (validmat && validface) {
- material->alphablend = mat->game.alpha_blend;
- }
-
- // with ztransp enabled, enforce alpha blending mode
- if (validmat && (mat->mode & MA_TRANSP) && (mat->mode & MA_ZTRANSP) && (material->alphablend == GEMAT_SOLID)) {
- material->alphablend = GEMAT_ALPHA;
- }
-
- // always zsort alpha + add
- if ((ELEM(material->alphablend, GEMAT_ALPHA, GEMAT_ALPHA_SORT, GEMAT_ADD) || texalpha) && (material->alphablend != GEMAT_CLIP)) {
- material->ras_mode |= ALPHA;
- material->ras_mode |= (mat && (mat->game.alpha_blend & GEMAT_ALPHA_SORT)) ? ZSORT : 0;
- }
-
- // XXX The RGB values here were meant to be temporary storage for the conversion process,
- // but fonts now make use of them too, so we leave them in for now.
- unsigned int rgb[4];
- GetRGB(use_vcol, mface, mmcol, mat, rgb);
-
- // swap the material color, so MCol on bitmap font works
- if (validmat && (use_vcol == false) && (mat->game.flag & GEMAT_TEXT)) {
- material->rgb[0] = KX_rgbaint2uint_new(rgb[0]);
- material->rgb[1] = KX_rgbaint2uint_new(rgb[1]);
- material->rgb[2] = KX_rgbaint2uint_new(rgb[2]);
- material->rgb[3] = KX_rgbaint2uint_new(rgb[3]);
- }
-
- if (validmat) {
- material->matname =(mat->id.name);
- }
- material->material = mat;
- return true;
-}
-
-static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace *tface, MCol *mcol, MTF_localLayer *layers, int lightlayer, unsigned int *rgb, MT_Point2 uvs[4][RAS_TexVert::MAX_UNIT], const char *tfaceName, KX_Scene* scene, KX_BlenderSceneConverter *converter)
-{
- RAS_IPolyMaterial* polymat = converter->FindCachedPolyMaterial(scene, ma);
- BL_Material* bl_mat = converter->FindCachedBlenderMaterial(scene, ma);
- KX_BlenderMaterial* kx_blmat = NULL;
-
- /* 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)
- converter->CacheBlenderMaterial(scene, ma, bl_mat);
- }
-
- const bool use_vcol = GetMaterialUseVColor(ma, bl_mat->glslmat);
- GetRGB(use_vcol, mface, mcol, ma, rgb);
-
- GetUVs(bl_mat, layers, mface, tface, uvs);
-
- /* 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)
- converter->CachePolyMaterial(scene, ma, polymat);
- }
-
- // see if a bucket was reused or a new one was created
- // this way only one KX_BlenderMaterial object has to exist per bucket
- bool bucketCreated;
- RAS_MaterialBucket* bucket = scene->FindBucket(polymat, bucketCreated);
-
- // this is needed to free up memory afterwards.
- // the converter will also prevent duplicates from being registered,
- // so just register everything.
- converter->RegisterPolyMaterial(polymat);
- converter->RegisterBlenderMaterial(bl_mat);
-
- return bucket;
-}
-
-/* blenderobj can be NULL, make sure its checked for */
-RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, KX_BlenderSceneConverter *converter, bool libloading)
-{
- RAS_MeshObject *meshobj;
- int lightlayer = blenderobj ? blenderobj->lay:(1<<20)-1; // all layers if no object.
-
- // Without checking names, we get some reuse we don't want that can cause
- // problems with material LoDs.
- if (blenderobj && ((meshobj = converter->FindGameMesh(mesh/*, ob->lay*/)) != NULL)) {
- const char *bge_name = meshobj->GetName().ReadPtr();
- const char *blender_name = ((ID *)blenderobj->data)->name + 2;
- if (STREQ(bge_name, blender_name)) {
- return meshobj;
- }
- }
-
- // Get DerivedMesh data
- DerivedMesh *dm = CDDM_from_mesh(mesh);
- DM_ensure_tessface(dm);
-
- MVert *mvert = dm->getVertArray(dm);
- int totvert = dm->getNumVerts(dm);
-
- MFace *mface = dm->getTessFaceArray(dm);
- MTFace *tface = static_cast<MTFace*>(dm->getTessFaceDataArray(dm, CD_MTFACE));
- MCol *mcol = static_cast<MCol*>(dm->getTessFaceDataArray(dm, CD_MCOL));
- float (*tangent)[4] = NULL;
- int totface = dm->getNumTessFaces(dm);
- const char *tfaceName = "";
-
- /* needs to be rewritten for loopdata */
- if (tface) {
- if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1) {
- bool generate_data = false;
- if (CustomData_get_layer_index(&dm->loopData, CD_TANGENT) == -1) {
- DM_calc_loop_tangents(dm, true, NULL, 0);
- generate_data = true;
- }
- DM_generate_tangent_tessface_data(dm, generate_data);
- }
- tangent = (float(*)[4])dm->getTessFaceDataArray(dm, CD_TANGENT);
- }
-
- meshobj = new RAS_MeshObject(mesh);
-
- // Extract avaiable layers
- MTF_localLayer *layers = new MTF_localLayer[MAX_MTFACE];
- for (int lay=0; lay<MAX_MTFACE; lay++) {
- layers[lay].face = 0;
- layers[lay].name = "";
- }
-
- int validLayers = 0;
- for (int i=0; i<dm->faceData.totlayer; i++)
- {
- if (dm->faceData.layers[i].type == CD_MTFACE)
- {
- if (validLayers >= MAX_MTFACE) {
- printf("%s: corrupted mesh %s - too many CD_MTFACE layers\n", __func__, mesh->id.name);
- break;
- }
-
- layers[validLayers].face = (MTFace*)(dm->faceData.layers[i].data);
- layers[validLayers].name = dm->faceData.layers[i].name;
- if (tface == layers[validLayers].face)
- tfaceName = layers[validLayers].name;
- validLayers++;
- }
- }
-
- meshobj->SetName(mesh->id.name + 2);
- meshobj->m_sharedvertex_map.resize(totvert);
-
- Material* ma = 0;
- MT_Point2 uvs[4][RAS_TexVert::MAX_UNIT];
- unsigned int rgb[4] = {0};
-
- MT_Point3 pt[4];
- MT_Vector3 no[4];
- MT_Vector4 tan[4];
-
- /* ugh, if there is a less annoying way to do this please use that.
- * since these are converted from floats to floats, theres no real
- * advantage to use MT_ types - campbell */
- for (unsigned int i = 0; i < 4; i++) {
- const float zero_vec[4] = {0.0f};
- pt[i].setValue(zero_vec);
- no[i].setValue(zero_vec);
- tan[i].setValue(zero_vec);
- }
-
- /* we need to manually initialize the uvs (MoTo doesn't do that) [#34550] */
- for (unsigned int i = 0; i < RAS_TexVert::MAX_UNIT; i++) {
- uvs[0][i] = uvs[1][i] = uvs[2][i] = uvs[3][i] = MT_Point2(0.f, 0.f);
- }
-
- for (int f=0;f<totface;f++,mface++)
- {
- /* get coordinates, normals and tangents */
- pt[0].setValue(mvert[mface->v1].co);
- pt[1].setValue(mvert[mface->v2].co);
- pt[2].setValue(mvert[mface->v3].co);
- if (mface->v4) pt[3].setValue(mvert[mface->v4].co);
-
- if (mface->flag & ME_SMOOTH) {
- float n0[3], n1[3], n2[3], n3[3];
-
- normal_short_to_float_v3(n0, mvert[mface->v1].no);
- normal_short_to_float_v3(n1, mvert[mface->v2].no);
- normal_short_to_float_v3(n2, mvert[mface->v3].no);
- no[0] = n0;
- no[1] = n1;
- no[2] = n2;
-
- if (mface->v4) {
- normal_short_to_float_v3(n3, mvert[mface->v4].no);
- no[3] = n3;
- }
- }
- else {
- float fno[3];
-
- if (mface->v4)
- normal_quad_v3(fno,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co);
- else
- normal_tri_v3(fno,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co);
-
- no[0] = no[1] = no[2] = no[3] = MT_Vector3(fno);
- }
-
- if (tangent) {
- tan[0] = tangent[f*4 + 0];
- tan[1] = tangent[f*4 + 1];
- tan[2] = tangent[f*4 + 2];
-
- if (mface->v4)
- tan[3] = tangent[f*4 + 3];
- }
- if (blenderobj)
- ma = give_current_material(blenderobj, mface->mat_nr+1);
- else
- ma = mesh->mat ? mesh->mat[mface->mat_nr]:NULL;
-
- // Check for blender material
- if (ma == NULL) {
- ma= &defmaterial;
- }
-
- {
-
- RAS_MaterialBucket* bucket = material_from_mesh(ma, mface, tface, mcol, layers, lightlayer, rgb, uvs, tfaceName, scene, converter);
-
- // set render flags
- bool visible = ((ma->game.flag & GEMAT_INVISIBLE)==0);
- bool twoside = ((ma->game.flag & GEMAT_BACKCULL)==0);
- bool collider = ((ma->game.flag & GEMAT_NOPHYSICS)==0);
-
- /* mark face as flat, so vertices are split */
- bool flat = (mface->flag & ME_SMOOTH) == 0;
-
- int nverts = (mface->v4)? 4: 3;
-
- RAS_Polygon *poly = meshobj->AddPolygon(bucket, nverts);
-
- poly->SetVisible(visible);
- poly->SetCollider(collider);
- poly->SetTwoside(twoside);
- //poly->SetEdgeCode(mface->edcode);
-
- meshobj->AddVertex(poly,0,pt[0],uvs[0],tan[0],rgb[0],no[0],flat,mface->v1);
- meshobj->AddVertex(poly,1,pt[1],uvs[1],tan[1],rgb[1],no[1],flat,mface->v2);
- meshobj->AddVertex(poly,2,pt[2],uvs[2],tan[2],rgb[2],no[2],flat,mface->v3);
-
- if (nverts==4)
- meshobj->AddVertex(poly,3,pt[3],uvs[3],tan[3],rgb[3],no[3],flat,mface->v4);
- }
-
- if (tface)
- tface++;
- if (mcol)
- mcol+=4;
-
- for (int lay=0; lay<MAX_MTFACE; lay++)
- {
- MTF_localLayer &layer = layers[lay];
- if (layer.face == 0) break;
-
- layer.face++;
- }
- }
- // keep meshobj->m_sharedvertex_map for reinstance phys mesh.
- // 2.49a and before it did: meshobj->m_sharedvertex_map.clear();
- // but this didnt save much ram. - Campbell
- meshobj->EndConversion();
-
- // pre calculate texture generation
- // However, we want to delay this if we're libloading so we can make sure we have the right scene.
- if (!libloading) {
- for (list<RAS_MeshMaterial>::iterator mit = meshobj->GetFirstMaterial();
- mit != meshobj->GetLastMaterial(); ++ mit) {
- mit->m_bucket->GetPolyMaterial()->OnConstruction();
- }
- }
-
- if (layers)
- delete []layers;
-
- dm->release(dm);
-
- converter->RegisterGameMesh(meshobj, mesh);
- return meshobj;
-}
-
-
-
-static PHY_MaterialProps *CreateMaterialFromBlenderObject(struct Object* blenderobject)
-{
- PHY_MaterialProps *materialProps = new PHY_MaterialProps;
-
- MT_assert(materialProps && "Create physics material properties failed");
-
- Material* blendermat = give_current_material(blenderobject, 1);
-
- if (blendermat)
- {
- MT_assert(0.0f <= blendermat->reflect && blendermat->reflect <= 1.0f);
-
- materialProps->m_restitution = blendermat->reflect;
- materialProps->m_friction = blendermat->friction;
- materialProps->m_fh_spring = blendermat->fh;
- materialProps->m_fh_damping = blendermat->xyfrict;
- materialProps->m_fh_distance = blendermat->fhdist;
- materialProps->m_fh_normal = (blendermat->dynamode & MA_FH_NOR) != 0;
- }
- else {
- //give some defaults
- materialProps->m_restitution = 0.f;
- materialProps->m_friction = 0.5;
- materialProps->m_fh_spring = 0.f;
- materialProps->m_fh_damping = 0.f;
- materialProps->m_fh_distance = 0.f;
- materialProps->m_fh_normal = false;
-
- }
-
- return materialProps;
-}
-
-static PHY_ShapeProps *CreateShapePropsFromBlenderObject(struct Object* blenderobject)
-{
- PHY_ShapeProps *shapeProps = new PHY_ShapeProps;
-
- MT_assert(shapeProps);
-
- shapeProps->m_mass = blenderobject->mass;
-
-// This needs to be fixed in blender. For now, we use:
-
-// in Blender, inertia stands for the size value which is equivalent to
-// the sphere radius
- shapeProps->m_inertia = blenderobject->formfactor;
-
- MT_assert(0.0f <= blenderobject->damping && blenderobject->damping <= 1.0f);
- MT_assert(0.0f <= blenderobject->rdamping && blenderobject->rdamping <= 1.0f);
-
- shapeProps->m_lin_drag = 1.0f - blenderobject->damping;
- shapeProps->m_ang_drag = 1.0f - blenderobject->rdamping;
-
- shapeProps->m_friction_scaling[0] = blenderobject->anisotropicFriction[0];
- shapeProps->m_friction_scaling[1] = blenderobject->anisotropicFriction[1];
- shapeProps->m_friction_scaling[2] = blenderobject->anisotropicFriction[2];
- shapeProps->m_do_anisotropic = ((blenderobject->gameflag & OB_ANISOTROPIC_FRICTION) != 0);
-
- shapeProps->m_do_fh = (blenderobject->gameflag & OB_DO_FH) != 0;
- shapeProps->m_do_rot_fh = (blenderobject->gameflag & OB_ROT_FH) != 0;
-
-// velocity clamping XXX
- shapeProps->m_clamp_vel_min = blenderobject->min_vel;
- shapeProps->m_clamp_vel_max = blenderobject->max_vel;
- shapeProps->m_clamp_angvel_min = blenderobject->min_angvel;
- shapeProps->m_clamp_angvel_max = blenderobject->max_angvel;
-
-// Character physics properties
- shapeProps->m_step_height = blenderobject->step_height;
- shapeProps->m_jump_speed = blenderobject->jump_speed;
- shapeProps->m_fall_speed = blenderobject->fall_speed;
- shapeProps->m_max_jumps = blenderobject->max_jumps;
-
- return shapeProps;
-}
-
-
-
-
-
-//////////////////////////////////////////////////////////
-
-
-
-static float my_boundbox_mesh(Mesh *me, float *loc, float *size)
-{
- MVert *mvert;
- BoundBox *bb;
- float min[3], max[3];
- float mloc[3], msize[3];
- float radius_sq=0.0f, vert_radius_sq, *co;
- int a;
-
- if (me->bb==0) {
- me->bb = BKE_boundbox_alloc_unit();
- }
- bb= me->bb;
-
- INIT_MINMAX(min, max);
-
- if (!loc) loc= mloc;
- if (!size) size= msize;
-
- mvert= me->mvert;
- for (a = 0; a<me->totvert; a++, mvert++) {
- co = mvert->co;
-
- /* bounds */
- minmax_v3v3_v3(min, max, co);
-
- /* radius */
-
- vert_radius_sq = len_squared_v3(co);
- if (vert_radius_sq > radius_sq)
- radius_sq = vert_radius_sq;
- }
-
- if (me->totvert) {
- loc[0] = (min[0] + max[0]) / 2.0f;
- loc[1] = (min[1] + max[1]) / 2.0f;
- loc[2] = (min[2] + max[2]) / 2.0f;
-
- size[0] = (max[0] - min[0]) / 2.0f;
- size[1] = (max[1] - min[1]) / 2.0f;
- size[2] = (max[2] - min[2]) / 2.0f;
- }
- else {
- loc[0] = loc[1] = loc[2] = 0.0f;
- size[0] = size[1] = size[2] = 0.0f;
- }
-
- bb->vec[0][0] = bb->vec[1][0] = bb->vec[2][0] = bb->vec[3][0] = loc[0]-size[0];
- bb->vec[4][0] = bb->vec[5][0] = bb->vec[6][0] = bb->vec[7][0] = loc[0]+size[0];
-
- bb->vec[0][1] = bb->vec[1][1] = bb->vec[4][1] = bb->vec[5][1] = loc[1]-size[1];
- bb->vec[2][1] = bb->vec[3][1] = bb->vec[6][1] = bb->vec[7][1] = loc[1]+size[1];
-
- bb->vec[0][2] = bb->vec[3][2] = bb->vec[4][2] = bb->vec[7][2] = loc[2]-size[2];
- bb->vec[1][2] = bb->vec[2][2] = bb->vec[5][2] = bb->vec[6][2] = loc[2]+size[2];
-
- return sqrtf_signed(radius_sq);
-}
-
-//////////////////////////////////////////////////////
-
-
-static void BL_CreateGraphicObjectNew(KX_GameObject* gameobj,
- const MT_Point3& localAabbMin,
- const MT_Point3& localAabbMax,
- KX_Scene* kxscene,
- bool isActive,
- e_PhysicsEngine physics_engine)
-{
- if (gameobj->GetMeshCount() > 0)
- {
- switch (physics_engine)
- {
-#ifdef WITH_BULLET
- case UseBullet:
- {
- CcdPhysicsEnvironment* env = (CcdPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
- assert(env);
- 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);
- if (isActive) {
- // add first, this will create the proxy handle, only if the object is visible
- if (gameobj->GetVisible())
- 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)
- deformer->UpdateBuckets();
- }
- }
- break;
-#endif
- default:
- break;
- }
- }
-}
-
-static void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
- struct Object* blenderobject,
- RAS_MeshObject* meshobj,
- KX_Scene* kxscene,
- int activeLayerBitInfo,
- KX_BlenderSceneConverter *converter,
- bool processCompoundChildren
- )
-
-{
- //SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/
- //int userigidbody = SYS_GetCommandLineInt(syshandle,"norigidbody",0);
- //bool bRigidBody = (userigidbody == 0);
-
- // object has physics representation?
- if (!(blenderobject->gameflag & OB_COLLISION)) {
- // Respond to all collisions so that Near sensors work on No Collision
- // objects.
- gameobj->SetUserCollisionGroup(0xffff);
- gameobj->SetUserCollisionMask(0xffff);
- return;
- }
-
- gameobj->SetUserCollisionGroup(blenderobject->col_group);
- gameobj->SetUserCollisionMask(blenderobject->col_mask);
-
- // get Root Parent of blenderobject
- struct Object* parent= blenderobject->parent;
- while (parent && parent->parent) {
- parent= parent->parent;
- }
-
- bool isCompoundChild = false;
- bool hasCompoundChildren = !parent && (blenderobject->gameflag & OB_CHILD) && !(blenderobject->gameflag & OB_SOFT_BODY);
-
- /* When the parent is not OB_DYNAMIC and has no OB_COLLISION then it gets no bullet controller
- * and cant be apart of the parents compound shape, same goes for OB_SOFT_BODY */
- if (parent && (parent->gameflag & (OB_DYNAMIC | OB_COLLISION))) {
- if ((parent->gameflag & OB_CHILD)!=0 && (blenderobject->gameflag & OB_CHILD) && !(parent->gameflag & OB_SOFT_BODY)) {
- isCompoundChild = true;
- }
- }
- if (processCompoundChildren != isCompoundChild)
- return;
-
-
- PHY_ShapeProps* shapeprops =
- CreateShapePropsFromBlenderObject(blenderobject);
-
-
- PHY_MaterialProps* smmaterial =
- CreateMaterialFromBlenderObject(blenderobject);
-
- DerivedMesh* dm = NULL;
- if (gameobj->GetDeformer())
- dm = gameobj->GetDeformer()->GetPhysicsMesh();
-
- class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
-
- kxscene->GetPhysicsEnvironment()->ConvertObject(gameobj, meshobj, dm, kxscene, shapeprops, smmaterial, motionstate, activeLayerBitInfo, isCompoundChild, hasCompoundChildren);
-
- bool isActor = (blenderobject->gameflag & OB_ACTOR)!=0;
- bool isSensor = (blenderobject->gameflag & OB_SENSOR) != 0;
- gameobj->getClientInfo()->m_type =
- (isSensor) ? ((isActor) ? KX_ClientObjectInfo::OBACTORSENSOR : KX_ClientObjectInfo::OBSENSOR) :
- (isActor) ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC;
-
- // should we record animation for this object?
- if ((blenderobject->gameflag & OB_RECORD_ANIMATION) != 0)
- gameobj->SetRecordAnimation(true);
-
- delete shapeprops;
- delete smmaterial;
- if (dm) {
- dm->needsFree = 1;
- dm->release(dm);
- }
-}
-
-
-
-
-
-static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRasterizer *rasterizer, KX_BlenderSceneConverter *converter)
-{
- RAS_ILightObject *lightobj = rasterizer->CreateLight();
- KX_LightObject *gamelight;
-
- lightobj->m_att1 = la->att1;
- lightobj->m_att2 = (la->mode & LA_QUAD) ? la->att2 : 0.0f;
- lightobj->m_coeff_const = la->coeff_const;
- lightobj->m_coeff_lin = la->coeff_lin;
- lightobj->m_coeff_quad = la->coeff_quad;
- lightobj->m_color[0] = la->r;
- lightobj->m_color[1] = la->g;
- lightobj->m_color[2] = la->b;
- lightobj->m_distance = la->dist;
- lightobj->m_energy = la->energy;
- lightobj->m_shadowclipstart = la->clipsta;
- lightobj->m_shadowclipend = la->clipend;
- lightobj->m_shadowbias = la->bias;
- lightobj->m_shadowbleedbias = la->bleedbias;
- lightobj->m_shadowmaptype = la->shadowmap_type;
- lightobj->m_shadowfrustumsize = la->shadow_frustum_size;
- lightobj->m_shadowcolor[0] = la->shdwr;
- lightobj->m_shadowcolor[1] = la->shdwg;
- lightobj->m_shadowcolor[2] = la->shdwb;
- lightobj->m_layer = layerflag;
- lightobj->m_spotblend = la->spotblend;
- lightobj->m_spotsize = la->spotsize;
-
- lightobj->m_nodiffuse = (la->mode & LA_NO_DIFF) != 0;
- lightobj->m_nospecular = (la->mode & LA_NO_SPEC) != 0;
-
- bool glslmat = converter->GetGLSLMaterials();
-
- // in GLSL NEGATIVE LAMP is handled inside the lamp update function
- if (glslmat==0) {
- if (la->mode & LA_NEG)
- {
- lightobj->m_color[0] = -lightobj->m_color[0];
- lightobj->m_color[1] = -lightobj->m_color[1];
- lightobj->m_color[2] = -lightobj->m_color[2];
- }
- }
-
- if (la->type==LA_SUN) {
- lightobj->m_type = RAS_ILightObject::LIGHT_SUN;
- } else if (la->type==LA_SPOT) {
- lightobj->m_type = RAS_ILightObject::LIGHT_SPOT;
- } else {
- lightobj->m_type = RAS_ILightObject::LIGHT_NORMAL;
- }
-
- gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rasterizer,
- lightobj, glslmat);
-
- return gamelight;
-}
-
-static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_BlenderSceneConverter *converter)
-{
- Camera* ca = static_cast<Camera*>(ob->data);
- RAS_CameraData camdata(ca->lens, ca->ortho_scale, ca->sensor_x, ca->sensor_y, ca->sensor_fit, ca->shiftx, ca->shifty, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, ca->YF_dofdist);
- KX_Camera *gamecamera;
-
- gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata);
- gamecamera->SetName(ca->id.name + 2);
-
- return gamecamera;
-}
-
-static KX_GameObject *gameobject_from_blenderobject(
- Object *ob,
- KX_Scene *kxscene,
- RAS_IRasterizer *rendertools,
- KX_BlenderSceneConverter *converter,
- bool libloading)
-{
- KX_GameObject *gameobj = NULL;
- Scene *blenderscene = kxscene->GetBlenderScene();
-
- switch (ob->type) {
- case OB_LAMP:
- {
- KX_LightObject* gamelight = gamelight_from_blamp(ob, static_cast<Lamp*>(ob->data), ob->lay, kxscene, rendertools, converter);
- gameobj = gamelight;
-
- if (blenderscene->lay & ob->lay)
- {
- gamelight->AddRef();
- kxscene->GetLightList()->Add(gamelight);
- }
-
- break;
- }
-
- case OB_CAMERA:
- {
- KX_Camera* gamecamera = gamecamera_from_bcamera(ob, kxscene, converter);
- gameobj = gamecamera;
-
- //don't add a reference: the camera list in kxscene->m_cameras is not released at the end
- //gamecamera->AddRef();
- kxscene->AddCamera(gamecamera);
-
- break;
- }
-
- case OB_MESH:
- {
- Mesh* mesh = static_cast<Mesh*>(ob->data);
- float center[3], extents[3];
- float radius = my_boundbox_mesh((Mesh*) ob->data, center, extents);
- RAS_MeshObject* meshobj = BL_ConvertMesh(mesh,ob,kxscene,converter, libloading);
-
- // needed for python scripting
- kxscene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
-
- if (ob->gameflag & OB_NAVMESH)
- {
- gameobj = new KX_NavMeshObject(kxscene,KX_Scene::m_callbacks);
- gameobj->AddMesh(meshobj);
- break;
- }
-
- gameobj = new BL_DeformableGameObject(ob,kxscene,KX_Scene::m_callbacks);
-
- // set transformation
- gameobj->AddMesh(meshobj);
-
- // gather levels of detail
- if (BLI_listbase_count_at_most(&ob->lodlevels, 2) > 1) {
- LodLevel *lod = ((LodLevel*)ob->lodlevels.first)->next;
- Mesh* lodmesh = mesh;
- Object* lodmatob = ob;
- gameobj->AddLodMesh(meshobj);
- for (; lod; lod = lod->next) {
- if (!lod->source || lod->source->type != OB_MESH) continue;
- if (lod->flags & OB_LOD_USE_MESH) {
- lodmesh = static_cast<Mesh*>(lod->source->data);
- }
- if (lod->flags & OB_LOD_USE_MAT) {
- lodmatob = lod->source;
- }
- gameobj->AddLodMesh(BL_ConvertMesh(lodmesh, lodmatob, kxscene, converter, libloading));
- }
- if (blenderscene->gm.lodflag & SCE_LOD_USE_HYST) {
- kxscene->SetLodHysteresis(true);
- kxscene->SetLodHysteresisValue(blenderscene->gm.scehysteresis);
- }
- }
-
- // for all objects: check whether they want to
- // respond to updates
- bool ignoreActivityCulling =
- ((ob->gameflag2 & OB_NEVER_DO_ACTIVITY_CULLING)!=0);
- gameobj->SetIgnoreActivityCulling(ignoreActivityCulling);
- gameobj->SetOccluder((ob->gameflag & OB_OCCLUDER) != 0, false);
-
- // we only want obcolor used if there is a material in the mesh
- // that requires it
- Material *mat= NULL;
- bool bUseObjectColor=false;
-
- for (int i=0;i<mesh->totcol;i++) {
- mat=mesh->mat[i];
- if (!mat) break;
- if ((mat->shade_flag & MA_OBCOLOR)) {
- bUseObjectColor = true;
- break;
- }
- }
- if (bUseObjectColor)
- gameobj->SetObjectColor(ob->col);
-
- // two options exists for deform: shape keys and armature
- // only support relative shape key
- bool bHasShapeKey = mesh->key != NULL && mesh->key->type==KEY_RELATIVE;
- bool bHasDvert = mesh->dvert != NULL && ob->defbase.first;
- bool bHasArmature = (BL_ModifierDeformer::HasArmatureDeformer(ob) && ob->parent && ob->parent->type == OB_ARMATURE && bHasDvert);
- bool bHasModifier = BL_ModifierDeformer::HasCompatibleDeformer(ob);
-#ifdef WITH_BULLET
- bool bHasSoftBody = (!ob->parent && (ob->gameflag & OB_SOFT_BODY));
-#endif
- if (bHasModifier) {
- BL_ModifierDeformer *dcont = new BL_ModifierDeformer((BL_DeformableGameObject *)gameobj,
- kxscene->GetBlenderScene(), ob, meshobj);
- ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
- } else if (bHasShapeKey) {
- // not that we can have shape keys without dvert!
- BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj,
- ob, meshobj);
- ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
- } else if (bHasArmature) {
- BL_SkinDeformer *dcont = new BL_SkinDeformer((BL_DeformableGameObject*)gameobj,
- ob, meshobj);
- ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
- } else if (bHasDvert) {
- // this case correspond to a mesh that can potentially deform but not with the
- // object to which it is attached for the moment. A skin mesh was created in
- // BL_ConvertMesh() so must create a deformer too!
- BL_MeshDeformer *dcont = new BL_MeshDeformer((BL_DeformableGameObject*)gameobj,
- ob, meshobj);
- ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
-#ifdef WITH_BULLET
- } else if (bHasSoftBody) {
- KX_SoftBodyDeformer *dcont = new KX_SoftBodyDeformer(meshobj, (BL_DeformableGameObject*)gameobj);
- ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
-#endif
- }
-
- MT_Point3 min = MT_Point3(center) - MT_Vector3(extents);
- MT_Point3 max = MT_Point3(center) + MT_Vector3(extents);
- SG_BBox bbox = SG_BBox(min, max);
- gameobj->GetSGNode()->SetBBox(bbox);
- gameobj->GetSGNode()->SetRadius(radius);
-
- break;
- }
-
- case OB_ARMATURE:
- {
- bArmature *arm = (bArmature*)ob->data;
- gameobj = new BL_ArmatureObject(
- kxscene,
- KX_Scene::m_callbacks,
- ob,
- kxscene->GetBlenderScene(), // handle
- arm->gevertdeformer
- );
- /* Get the current pose from the armature object and apply it as the rest pose */
- break;
- }
-
- case OB_EMPTY:
- {
- gameobj = new KX_EmptyObject(kxscene,KX_Scene::m_callbacks);
- // set transformation
- break;
- }
-
- case OB_FONT:
- {
- bool do_color_management = BKE_scene_check_color_management_enabled(blenderscene);
- /* font objects have no bounding box */
- gameobj = new KX_FontObject(kxscene,KX_Scene::m_callbacks, rendertools, ob, do_color_management);
-
- /* add to the list only the visible fonts */
- if ((ob->lay & kxscene->GetBlenderScene()->lay) != 0)
- kxscene->AddFont(static_cast<KX_FontObject*>(gameobj));
- break;
- }
-
-#ifdef THREADED_DAG_WORKAROUND
- case OB_CURVE:
- {
- if (ob->curve_cache == NULL) {
- BKE_displist_make_curveTypes(blenderscene, ob, false);
- }
- }
-#endif
-
- }
- if (gameobj)
- {
- gameobj->SetLayer(ob->lay);
- gameobj->SetBlenderObject(ob);
- /* set the visibility state based on the objects render option in the outliner */
- if (ob->restrictflag & OB_RESTRICT_RENDER) gameobj->SetVisible(0, 0);
- }
- return gameobj;
-}
-
-struct parentChildLink {
- struct Object* m_blenderchild;
- SG_Node* m_gamechildnode;
-};
-
-#if 0
-static bPoseChannel *get_active_posechannel2(Object *ob)
-{
- bArmature *arm= (bArmature*)ob->data;
- bPoseChannel *pchan;
-
- /* find active */
- for (pchan= (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- if (pchan->bone && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer))
- return pchan;
- }
-
- return NULL;
-}
-#endif
-
-static ListBase *get_active_constraints2(Object *ob)
-{
- if (!ob)
- return NULL;
-
- // XXX - shouldnt we care about the pose data and not the mode???
-#if 0
- if (ob->mode & OB_MODE_POSE) {
- bPoseChannel *pchan;
-
- pchan = get_active_posechannel2(ob);
- if (pchan)
- return &pchan->constraints;
- }
- else
-#endif
- {
- return &ob->constraints;
- }
-
- return NULL;
-}
-
-static void UNUSED_FUNCTION(print_active_constraints2)(Object *ob) //not used, use to debug
-{
- bConstraint* curcon;
- ListBase* conlist = get_active_constraints2(ob);
-
- if (conlist) {
- for (curcon = (bConstraint *)conlist->first; curcon; curcon = (bConstraint *)curcon->next) {
- printf("%i\n",curcon->type);
- }
- }
-}
-
-// Copy base layer to object layer like in BKE_scene_set_background
-static void blenderSceneSetBackground(Scene *blenderscene)
-{
- Scene *it;
- Base *base;
-
- for (SETLOOPER(blenderscene, it, base)) {
- base->object->lay = base->lay;
- BKE_scene_object_base_flag_sync_from_base(base);
- }
-}
-
-static KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist)
-{
-
- for (int j=0;j<sumolist->GetCount();j++)
- {
- KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j);
- if (gameobje->GetName()==busc)
- return gameobje;
- }
-
- return 0;
-
-}
-
-static bool bl_isConstraintInList(KX_GameObject *gameobj, set<KX_GameObject*> convertedlist)
-{
- set<KX_GameObject*>::iterator gobit;
- for (gobit = convertedlist.begin(); gobit != convertedlist.end(); gobit++) {
- if ((*gobit)->GetName() == gameobj->GetName())
- return true;
- }
- return false;
-}
-
-/* helper for BL_ConvertBlenderObjects, avoids code duplication
- * note: all var names match args are passed from the caller */
-static void bl_ConvertBlenderObject_Single(
- KX_BlenderSceneConverter *converter,
- Object *blenderobject,
- vector<parentChildLink> &vec_parent_child,
- CListValue* logicbrick_conversionlist,
- CListValue* objectlist, CListValue* inactivelist, CListValue* sumolist,
- KX_Scene* kxscene, KX_GameObject* gameobj,
- SCA_LogicManager* logicmgr, SCA_TimeEventManager* timemgr,
- bool isInActiveLayer
- )
-{
- MT_Point3 pos(
- blenderobject->loc[0]+blenderobject->dloc[0],
- blenderobject->loc[1]+blenderobject->dloc[1],
- blenderobject->loc[2]+blenderobject->dloc[2]
- );
-
- MT_Matrix3x3 rotation;
- float rotmat[3][3];
- BKE_object_rot_to_mat3(blenderobject, rotmat, false);
- rotation.setValue3x3((float*)rotmat);
-
- MT_Vector3 scale(blenderobject->size);
-
- gameobj->NodeSetLocalPosition(pos);
- gameobj->NodeSetLocalOrientation(rotation);
- gameobj->NodeSetLocalScale(scale);
- gameobj->NodeUpdateGS(0);
-
- sumolist->Add(gameobj->AddRef());
-
- BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer);
-
- gameobj->SetName(blenderobject->id.name + 2);
-
- // update children/parent hierarchy
- if (blenderobject->parent != 0)
- {
- // blender has an additional 'parentinverse' offset in each object
- SG_Callbacks callback(NULL,NULL,NULL,KX_Scene::KX_ScenegraphUpdateFunc,KX_Scene::KX_ScenegraphRescheduleFunc);
- SG_Node* parentinversenode = new SG_Node(NULL,kxscene,callback);
-
- // define a normal parent relationship for this node.
- KX_NormalParentRelation * parent_relation = KX_NormalParentRelation::New();
- parentinversenode->SetParentRelation(parent_relation);
-
- parentChildLink pclink;
- pclink.m_blenderchild = blenderobject;
- pclink.m_gamechildnode = parentinversenode;
- vec_parent_child.push_back(pclink);
-
- float* fl = (float*) blenderobject->parentinv;
- MT_Transform parinvtrans(fl);
- parentinversenode->SetLocalPosition(parinvtrans.getOrigin());
- // problem here: the parent inverse transform combines scaling and rotation
- // in the basis but the scenegraph needs separate rotation and scaling.
- // This is not important for OpenGL (it uses 4x4 matrix) but it is important
- // for the physic engine that needs a separate scaling
- //parentinversenode->SetLocalOrientation(parinvtrans.getBasis());
-
- // Extract the rotation and the scaling from the basis
- MT_Matrix3x3 ori(parinvtrans.getBasis());
- MT_Vector3 x(ori.getColumn(0));
- MT_Vector3 y(ori.getColumn(1));
- MT_Vector3 z(ori.getColumn(2));
- MT_Vector3 parscale(x.length(), y.length(), z.length());
- if (!MT_fuzzyZero(parscale[0]))
- x /= parscale[0];
- if (!MT_fuzzyZero(parscale[1]))
- y /= parscale[1];
- if (!MT_fuzzyZero(parscale[2]))
- z /= parscale[2];
- ori.setColumn(0, x);
- ori.setColumn(1, y);
- ori.setColumn(2, z);
- parentinversenode->SetLocalOrientation(ori);
- parentinversenode->SetLocalScale(parscale);
-
- parentinversenode->AddChild(gameobj->GetSGNode());
- }
-
- // needed for python scripting
- logicmgr->RegisterGameObjectName(gameobj->GetName(),gameobj);
-
- // needed for group duplication
- logicmgr->RegisterGameObj(blenderobject, gameobj);
- for (int i = 0; i < gameobj->GetMeshCount(); i++)
- logicmgr->RegisterGameMeshName(gameobj->GetMesh(i)->GetName(), blenderobject);
-
- converter->RegisterGameObject(gameobj, blenderobject);
- // this was put in rapidly, needs to be looked at more closely
- // only draw/use objects in active 'blender' layers
-
- logicbrick_conversionlist->Add(gameobj->AddRef());
-
- if (isInActiveLayer)
- {
- objectlist->Add(gameobj->AddRef());
- //tf.Add(gameobj->GetSGNode());
-
- gameobj->NodeUpdateGS(0);
- gameobj->AddMeshUser();
- }
- else
- {
- //we must store this object otherwise it will be deleted
- //at the end of this function if it is not a root object
- inactivelist->Add(gameobj->AddRef());
- }
-}
-
-
-// convert blender objects into ketsji gameobjects
-void BL_ConvertBlenderObjects(struct Main* maggie,
- KX_Scene* kxscene,
- KX_KetsjiEngine* ketsjiEngine,
- e_PhysicsEngine physics_engine,
- RAS_IRasterizer* rendertools,
- RAS_ICanvas* canvas,
- KX_BlenderSceneConverter* converter,
- bool alwaysUseExpandFraming,
- bool libloading
- )
-{
-
-#define BL_CONVERTBLENDEROBJECT_SINGLE \
- bl_ConvertBlenderObject_Single(converter, \
- blenderobject, \
- vec_parent_child, \
- logicbrick_conversionlist, \
- objectlist, inactivelist, sumolist, \
- kxscene, gameobj, \
- logicmgr, timemgr, \
- isInActiveLayer \
- )
-
-
-
- Scene *blenderscene = kxscene->GetBlenderScene();
- // for SETLOOPER
- Scene *sce_iter;
- Base *base;
-
- // Get the frame settings of the canvas.
- // Get the aspect ratio of the canvas as designed by the user.
-
- RAS_FrameSettings::RAS_FrameType frame_type;
- int aspect_width;
- int aspect_height;
- set<Group*> grouplist; // list of groups to be converted
- set<Object*> allblobj; // all objects converted
- set<Object*> groupobj; // objects from groups (never in active layer)
-
- // This is bad, but we use this to make sure the first time this is called
- // is not in a separate thread.
- BL_Texture::GetMaxUnits();
-
- /* We have to ensure that group definitions are only converted once
- * push all converted group members to this set.
- * This will happen when a group instance is made from a linked group instance
- * and both are on the active layer. */
- set<KX_GameObject*> convertedlist;
-
- if (alwaysUseExpandFraming) {
- frame_type = RAS_FrameSettings::e_frame_extend;
- aspect_width = canvas->GetWidth();
- aspect_height = canvas->GetHeight();
- } else {
- if (blenderscene->gm.framing.type == SCE_GAMEFRAMING_BARS) {
- frame_type = RAS_FrameSettings::e_frame_bars;
- } else if (blenderscene->gm.framing.type == SCE_GAMEFRAMING_EXTEND) {
- frame_type = RAS_FrameSettings::e_frame_extend;
- } else {
- frame_type = RAS_FrameSettings::e_frame_scale;
- }
-
- aspect_width = (int)(blenderscene->r.xsch * blenderscene->r.xasp);
- aspect_height = (int)(blenderscene->r.ysch * blenderscene->r.yasp);
- }
-
- RAS_FrameSettings frame_settings(
- frame_type,
- blenderscene->gm.framing.col[0],
- blenderscene->gm.framing.col[1],
- blenderscene->gm.framing.col[2],
- aspect_width,
- aspect_height
- );
- kxscene->SetFramingType(frame_settings);
-
- kxscene->SetGravity(MT_Vector3(0,0, -blenderscene->gm.gravity));
-
- /* set activity culling parameters */
- kxscene->SetActivityCulling( (blenderscene->gm.mode & WO_ACTIVITY_CULLING) != 0);
- kxscene->SetActivityCullingRadius(blenderscene->gm.activityBoxRadius);
- kxscene->SetDbvtCulling((blenderscene->gm.mode & WO_DBVT_CULLING) != 0);
-
- // no occlusion culling by default
- kxscene->SetDbvtOcclusionRes(0);
-
- int activeLayerBitInfo = blenderscene->lay;
-
- // list of all object converted, active and inactive
- CListValue* sumolist = new CListValue();
-
- vector<parentChildLink> vec_parent_child;
-
- CListValue* objectlist = kxscene->GetObjectList();
- CListValue* inactivelist = kxscene->GetInactiveList();
- CListValue* parentlist = kxscene->GetRootParentList();
-
- SCA_LogicManager* logicmgr = kxscene->GetLogicManager();
- SCA_TimeEventManager* timemgr = kxscene->GetTimeEventManager();
-
- CListValue* logicbrick_conversionlist = new CListValue();
-
- //SG_TreeFactory tf;
-
- // Convert actions to actionmap
- bAction *curAct;
- for (curAct = (bAction*)maggie->action.first; curAct; curAct=(bAction*)curAct->id.next)
- {
- logicmgr->RegisterActionName(curAct->id.name + 2, curAct);
- }
-
- SetDefaultLightMode(blenderscene);
-
- blenderSceneSetBackground(blenderscene);
-
- // Let's support scene set.
- // Beware of name conflict in linked data, it will not crash but will create confusion
- // in Python scripting and in certain actuators (replace mesh). Linked scene *should* have
- // no conflicting name for Object, Object data and Action.
- for (SETLOOPER(blenderscene, sce_iter, base))
- {
- Object* blenderobject = base->object;
- allblobj.insert(blenderobject);
-
- KX_GameObject* gameobj = gameobject_from_blenderobject(
- base->object,
- kxscene,
- rendertools,
- converter,
- libloading);
-
- bool isInActiveLayer = (blenderobject->lay & activeLayerBitInfo) !=0;
- if (gameobj)
- {
- /* macro calls object conversion funcs */
- BL_CONVERTBLENDEROBJECT_SINGLE;
-
- if (gameobj->IsDupliGroup()) {
- grouplist.insert(blenderobject->dup_group);
- }
-
- /* Note about memory leak issues:
- * When a CValue derived class is created, m_refcount is initialized to 1
- * so the class must be released after being used to make sure that it won't
- * hang in memory. If the object needs to be stored for a long time,
- * use AddRef() so that this Release() does not free the object.
- * Make sure that for any AddRef() there is a Release()!!!!
- * Do the same for any object derived from CValue, CExpression and NG_NetworkMessage
- */
- gameobj->Release();
- }
- }
-
- if (!grouplist.empty())
- {
- // now convert the group referenced by dupli group object
- // keep track of all groups already converted
- set<Group*> allgrouplist = grouplist;
- set<Group*> tempglist;
- // recurse
- while (!grouplist.empty())
- {
- set<Group*>::iterator git;
- tempglist.clear();
- tempglist.swap(grouplist);
- for (git=tempglist.begin(); git!=tempglist.end(); git++)
- {
- Group* group = *git;
- FOREACH_GROUP_OBJECT_BEGIN(group, blenderobject)
- {
- if (converter->FindGameObject(blenderobject) == NULL)
- {
- allblobj.insert(blenderobject);
- groupobj.insert(blenderobject);
- KX_GameObject* gameobj = gameobject_from_blenderobject(
- blenderobject,
- kxscene,
- rendertools,
- converter,
- libloading);
-
- bool isInActiveLayer = false;
- if (gameobj) {
- /* Insert object to the constraint game object list
- * so we can check later if there is a instance in the scene or
- * an instance and its actual group definition. */
- convertedlist.insert((KX_GameObject*)gameobj->AddRef());
-
- /* macro calls object conversion funcs */
- BL_CONVERTBLENDEROBJECT_SINGLE;
-
- if (gameobj->IsDupliGroup())
- {
- if (allgrouplist.insert(blenderobject->dup_group).second)
- {
- grouplist.insert(blenderobject->dup_group);
- }
- }
-
- /* see comment above re: mem leaks */
- gameobj->Release();
- }
- }
- }
- FOREACH_GROUP_OBJECT_END;
- }
- }
- }
-
- // non-camera objects not supported as camera currently
- if (blenderscene->camera && blenderscene->camera->type == OB_CAMERA) {
- KX_Camera *gamecamera= (KX_Camera*) converter->FindGameObject(blenderscene->camera);
-
- if (gamecamera)
- kxscene->SetActiveCamera(gamecamera);
- }
-
- // Set up armatures
- set<Object*>::iterator oit;
- for (oit=allblobj.begin(); oit!=allblobj.end(); oit++)
- {
- Object* blenderobj = *oit;
- if (blenderobj->type==OB_MESH) {
- Mesh *me = (Mesh*)blenderobj->data;
-
- if (me->dvert) {
- BL_DeformableGameObject *obj = (BL_DeformableGameObject*)converter->FindGameObject(blenderobj);
-
- if (obj && BL_ModifierDeformer::HasArmatureDeformer(blenderobj) && blenderobj->parent && blenderobj->parent->type==OB_ARMATURE) {
- KX_GameObject *par = converter->FindGameObject(blenderobj->parent);
- if (par && obj->GetDeformer())
- ((BL_SkinDeformer*)obj->GetDeformer())->SetArmature((BL_ArmatureObject*) par);
- }
- }
- }
- }
-
- // create hierarchy information
- int i;
- vector<parentChildLink>::iterator pcit;
-
- for (pcit = vec_parent_child.begin();!(pcit==vec_parent_child.end());++pcit)
- {
-
- struct Object* blenderchild = pcit->m_blenderchild;
- struct Object* blenderparent = blenderchild->parent;
- KX_GameObject* parentobj = converter->FindGameObject(blenderparent);
- KX_GameObject* childobj = converter->FindGameObject(blenderchild);
-
- assert(childobj);
-
- if (!parentobj || objectlist->SearchValue(childobj) != objectlist->SearchValue(parentobj))
- {
- // special case: the parent and child object are not in the same layer.
- // This weird situation is used in Apricot for test purposes.
- // Resolve it by not converting the child
- childobj->GetSGNode()->DisconnectFromParent();
- delete pcit->m_gamechildnode;
- // Now destroy the child object but also all its descendent that may already be linked
- // Remove the child reference in the local list!
- // Note: there may be descendents already if the children of the child were processed
- // by this loop before the child. In that case, we must remove the children also
- CListValue* childrenlist = childobj->GetChildrenRecursive();
- childrenlist->Add(childobj->AddRef());
- for ( i=0;i<childrenlist->GetCount();i++)
- {
- KX_GameObject* obj = static_cast<KX_GameObject*>(childrenlist->GetValue(i));
- if (sumolist->RemoveValue(obj))
- obj->Release();
- if (logicbrick_conversionlist->RemoveValue(obj))
- obj->Release();
- }
- childrenlist->Release();
-
- // now destroy recursively
- converter->UnregisterGameObject(childobj); // removing objects during conversion make sure this runs too
- kxscene->RemoveObject(childobj);
-
- continue;
- }
-
- switch (blenderchild->partype)
- {
- case PARVERT1:
- {
- // creat a new vertex parent relationship for this node.
- KX_VertexParentRelation * vertex_parent_relation = KX_VertexParentRelation::New();
- pcit->m_gamechildnode->SetParentRelation(vertex_parent_relation);
- break;
- }
- case PARSLOW:
- {
- // creat a new slow parent relationship for this node.
- KX_SlowParentRelation * slow_parent_relation = KX_SlowParentRelation::New(blenderchild->sf);
- pcit->m_gamechildnode->SetParentRelation(slow_parent_relation);
- break;
- }
- case PARBONE:
- {
- // parent this to a bone
- Bone *parent_bone = BKE_armature_find_bone_name(BKE_armature_from_object(blenderchild->parent),
- blenderchild->parsubstr);
-
- if (parent_bone) {
- KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone);
- pcit->m_gamechildnode->SetParentRelation(bone_parent_relation);
- }
-
- break;
- }
- case PARSKEL: // skinned - ignore
- break;
- case PAROBJECT:
- case PARVERT3:
- default:
- // unhandled
- break;
- }
-
- parentobj-> GetSGNode()->AddChild(pcit->m_gamechildnode);
- }
- vec_parent_child.clear();
-
- // find 'root' parents (object that has not parents in SceneGraph)
- for (i=0;i<sumolist->GetCount();++i)
- {
- KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
- if (gameobj->GetSGNode()->GetSGParent() == 0)
- {
- parentlist->Add(gameobj->AddRef());
- gameobj->NodeUpdateGS(0);
- }
- }
-
- // create graphic controller for culling
- if (kxscene->GetDbvtCulling())
- {
- bool occlusion = false;
- for (i=0; i<sumolist->GetCount();i++)
- {
- KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
- if (gameobj->GetMeshCount() > 0)
- {
- MT_Point3 box[2];
- gameobj->GetSGNode()->BBox().getmm(box, MT_Transform::Identity());
- // box[0] is the min, box[1] is the max
- bool isactive = objectlist->SearchValue(gameobj);
- BL_CreateGraphicObjectNew(gameobj,box[0],box[1],kxscene,isactive,physics_engine);
- if (gameobj->GetOccluder())
- occlusion = true;
- }
- }
- if (occlusion)
- kxscene->SetDbvtOcclusionRes(blenderscene->gm.occlusionRes);
- }
- if (blenderscene->world)
- 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
- for (i=0;i<sumolist->GetCount();++i)
- {
- KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
- if (gameobj->GetDeformer())
- gameobj->GetDeformer()->UpdateBuckets();
- }
-
- // Set up armature constraints and shapekey drivers
- for (i=0;i<sumolist->GetCount();++i)
- {
- KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
- if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
- {
- BL_ArmatureObject *armobj = (BL_ArmatureObject*)gameobj;
- armobj->LoadConstraints(converter);
-
- CListValue *children = armobj->GetChildren();
- for (int j=0; j<children->GetCount();++j)
- {
- BL_ShapeDeformer *deform = dynamic_cast<BL_ShapeDeformer*>(((KX_GameObject*)children->GetValue(j))->GetDeformer());
- if (deform)
- deform->LoadShapeDrivers(armobj);
- }
-
- children->Release();
- }
- }
-
- bool processCompoundChildren = false;
- // create physics information
- for (i=0;i<sumolist->GetCount();i++)
- {
- KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
- struct Object* blenderobject = gameobj->GetBlenderObject();
- int nummeshes = gameobj->GetMeshCount();
- RAS_MeshObject* meshobj = 0;
- if (nummeshes > 0)
- {
- meshobj = gameobj->GetMesh(0);
- }
- int layerMask = (groupobj.find(blenderobject) == groupobj.end()) ? activeLayerBitInfo : 0;
- BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,converter,processCompoundChildren);
- }
-
- processCompoundChildren = true;
- // create physics information
- for (i=0;i<sumolist->GetCount();i++)
- {
- KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
- struct Object* blenderobject = gameobj->GetBlenderObject();
- int nummeshes = gameobj->GetMeshCount();
- RAS_MeshObject* meshobj = 0;
- if (nummeshes > 0)
- {
- meshobj = gameobj->GetMesh(0);
- }
- int layerMask = (groupobj.find(blenderobject) == groupobj.end()) ? activeLayerBitInfo : 0;
- BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,converter,processCompoundChildren);
- }
-
- // create physics joints
- for (i=0;i<sumolist->GetCount();i++)
- {
- PHY_IPhysicsEnvironment *physEnv = kxscene->GetPhysicsEnvironment();
- KX_GameObject *gameobj = (KX_GameObject *)sumolist->GetValue(i);
- struct Object *blenderobject = gameobj->GetBlenderObject();
- ListBase *conlist = get_active_constraints2(blenderobject);
- bConstraint *curcon;
-
- if (!conlist)
- continue;
-
- for (curcon = (bConstraint *)conlist->first; curcon; curcon = (bConstraint *)curcon->next) {
- if (curcon->type != CONSTRAINT_TYPE_RIGIDBODYJOINT)
- continue;
-
- bRigidBodyJointConstraint *dat = (bRigidBodyJointConstraint *)curcon->data;
-
- /* Skip if no target or a child object is selected or constraints are deactivated */
- if (!dat->tar || dat->child || (curcon->flag & CONSTRAINT_OFF))
- continue;
-
- /* Store constraints of grouped and instanced objects for all layers */
- gameobj->AddConstraint(dat);
-
- /** if it's during libload we only add constraints in the object but
- * doesn't create it. Constraint will be replicated later in scene->MergeScene
- */
- if (libloading)
- continue;
-
- /* Skipped already converted constraints.
- * This will happen when a group instance is made from a linked group instance
- * and both are on the active layer. */
- if (bl_isConstraintInList(gameobj, convertedlist))
- continue;
-
- KX_GameObject *gotar = getGameOb(dat->tar->id.name + 2, sumolist);
-
- if (gotar && (gotar->GetLayer()&activeLayerBitInfo) && gotar->GetPhysicsController() &&
- (gameobj->GetLayer()&activeLayerBitInfo) && gameobj->GetPhysicsController())
- {
- physEnv->SetupObjectConstraints(gameobj, gotar, dat);
- }
- }
- }
-
- /* cleanup converted set of group objects */
- set<KX_GameObject*>::iterator gobit;
- for (gobit = convertedlist.begin(); gobit != convertedlist.end(); gobit++)
- (*gobit)->Release();
-
- convertedlist.clear();
- sumolist->Release();
-
- // convert world
- KX_WorldInfo* worldinfo = new KX_WorldInfo(blenderscene, blenderscene->world);
- converter->RegisterWorldInfo(worldinfo);
- kxscene->SetWorldInfo(worldinfo);
-
- //create object representations for obstacle simulation
- KX_ObstacleSimulation* obssimulation = kxscene->GetObstacleSimulation();
- if (obssimulation)
- {
- for ( i=0;i<objectlist->GetCount();i++)
- {
- KX_GameObject* gameobj = static_cast<KX_GameObject*>(objectlist->GetValue(i));
- struct Object* blenderobject = gameobj->GetBlenderObject();
- if (blenderobject->gameflag & OB_HASOBSTACLE)
- {
- obssimulation->AddObstacleForObj(gameobj);
- }
- }
- }
-
- //process navigation mesh objects
- for ( i=0; i<objectlist->GetCount();i++)
- {
- KX_GameObject* gameobj = static_cast<KX_GameObject*>(objectlist->GetValue(i));
- struct Object* blenderobject = gameobj->GetBlenderObject();
- if (blenderobject->type==OB_MESH && (blenderobject->gameflag & OB_NAVMESH))
- {
- KX_NavMeshObject* navmesh = static_cast<KX_NavMeshObject*>(gameobj);
- navmesh->SetVisible(0, true);
- navmesh->BuildNavMesh();
- if (obssimulation)
- obssimulation->AddObstaclesForNavMesh(navmesh);
- }
- }
- for ( i=0; i<inactivelist->GetCount();i++)
- {
- KX_GameObject* gameobj = static_cast<KX_GameObject*>(inactivelist->GetValue(i));
- struct Object* blenderobject = gameobj->GetBlenderObject();
- if (blenderobject->type==OB_MESH && (blenderobject->gameflag & OB_NAVMESH))
- {
- KX_NavMeshObject* navmesh = static_cast<KX_NavMeshObject*>(gameobj);
- navmesh->SetVisible(0, true);
- }
- }
-
- // convert logic bricks, sensors, controllers and actuators
- for (i=0;i<logicbrick_conversionlist->GetCount();i++)
- {
- KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i));
- struct Object* blenderobj = gameobj->GetBlenderObject();
- int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
- bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
- BL_ConvertActuators(maggie->name, blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,layerMask,isInActiveLayer,converter);
- }
- for ( i=0;i<logicbrick_conversionlist->GetCount();i++)
- {
- KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i));
- struct Object* blenderobj = gameobj->GetBlenderObject();
- int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
- bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
- BL_ConvertControllers(blenderobj,gameobj,logicmgr, layerMask,isInActiveLayer,converter, libloading);
- }
- for ( i=0;i<logicbrick_conversionlist->GetCount();i++)
- {
- KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i));
- struct Object* blenderobj = gameobj->GetBlenderObject();
- int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
- bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
- BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,layerMask,isInActiveLayer,canvas,converter);
- // set the init state to all objects
- gameobj->SetInitState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state);
- }
- // apply the initial state to controllers, only on the active objects as this registers the sensors
- for ( i=0;i<objectlist->GetCount();i++)
- {
- KX_GameObject* gameobj = static_cast<KX_GameObject*>(objectlist->GetValue(i));
- gameobj->ResetState();
- }
-
- logicbrick_conversionlist->Release();
-
- // Calculate the scene btree -
- // too slow - commented out.
- //kxscene->SetNodeTree(tf.MakeTree());
-
- // instantiate dupli group, we will loop trough the object
- // that are in active layers. Note that duplicating group
- // has the effect of adding objects at the end of objectlist.
- // Only loop through the first part of the list.
- int objcount = objectlist->GetCount();
- for (i=0;i<objcount;i++)
- {
- KX_GameObject* gameobj = (KX_GameObject*) objectlist->GetValue(i);
- if (gameobj->IsDupliGroup())
- {
- kxscene->DupliGroupRecurse(gameobj, 0);
- }
- }
-
- KX_Camera *activecam = kxscene->GetActiveCamera();
- MT_Scalar distance = (activecam)? activecam->GetCameraFar() - activecam->GetCameraNear(): 100.0f;
- RAS_BucketManager *bucketmanager = kxscene->GetBucketManager();
- bucketmanager->OptimizeBuckets(distance);
-}
-
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.h b/source/gameengine/Converter/BL_BlenderDataConversion.h
deleted file mode 100644
index 22210cc6035..00000000000
--- a/source/gameengine/Converter/BL_BlenderDataConversion.h
+++ /dev/null
@@ -1,56 +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 BL_BlenderDataConversion.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_BLENDERDATACONVERSION_H__
-#define __BL_BLENDERDATACONVERSION_H__
-
-#include "CTR_HashedPtr.h"
-#include "STR_String.h"
-#include "EXP_Python.h"
-#include "KX_PhysicsEngineEnums.h"
-#include "SCA_IInputDevice.h"
-
-class RAS_MeshObject* BL_ConvertMesh(struct Mesh* mesh,struct Object* lightobj,class KX_Scene* scene, class KX_BlenderSceneConverter *converter, bool libloading);
-
-void BL_ConvertBlenderObjects(struct Main* maggie,
- class KX_Scene* kxscene,
- class KX_KetsjiEngine* ketsjiEngine,
- e_PhysicsEngine physics_engine,
- class RAS_IRasterizer* rendertools,
- class RAS_ICanvas* canvas,
- class KX_BlenderSceneConverter* sceneconverter,
- bool alwaysUseExpandFraming,
- bool libloading=false
- );
-
-SCA_IInputDevice::KX_EnumInputs ConvertKeyCode(int key_code);
-
-#endif /* __BL_BLENDERDATACONVERSION_H__ */
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp
deleted file mode 100644
index 3a4a27a6722..00000000000
--- a/source/gameengine/Converter/BL_DeformableGameObject.cpp
+++ /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 gameengine/Converter/BL_DeformableGameObject.cpp
- * \ingroup bgeconv
- */
-
-
-#include "BL_DeformableGameObject.h"
-#include "BL_ShapeDeformer.h"
-#include "BL_ShapeActionActuator.h"
-#include "RAS_MaterialBucket.h"
-
-
-BL_DeformableGameObject::~BL_DeformableGameObject()
-{
- if (m_pDeformer)
- delete m_pDeformer; // __NLA : Temporary until we decide where to put this
-}
-
-void BL_DeformableGameObject::ProcessReplica()
-{
- KX_GameObject::ProcessReplica();
-
- if (m_pDeformer)
- m_pDeformer= (BL_MeshDeformer*)m_pDeformer->GetReplica();
-}
-
-CValue* BL_DeformableGameObject::GetReplica()
-{
-
- BL_DeformableGameObject* replica = new BL_DeformableGameObject(*this);//m_float,GetName());
- replica->ProcessReplica();
- return replica;
-}
-
-bool BL_DeformableGameObject::SetActiveAction(BL_ShapeActionActuator *act, short priority, double curtime)
-{
- if (curtime != m_lastframe) {
- m_activePriority = 9999;
- m_lastframe= curtime;
- m_activeAct = NULL;
- }
-
- if (priority<=m_activePriority)
- {
- if (m_activeAct && (m_activeAct!=act))
- m_activeAct->SetBlendTime(0.0f); /* Reset the blend timer */
- m_activeAct = act;
- m_activePriority = priority;
- m_lastframe = curtime;
-
- return true;
- }
- else {
- act->SetBlendTime(0.0f);
- return false;
- }
-}
-
-bool BL_DeformableGameObject::GetShape(vector<float> &shape)
-{
- shape.clear();
- BL_ShapeDeformer* shape_deformer = dynamic_cast<BL_ShapeDeformer*>(m_pDeformer);
- if (shape_deformer)
- {
- // this check is normally superfluous: a shape deformer can only be created if the mesh
- // has relative keys
- Key* key = shape_deformer->GetKey();
- if (key && key->type==KEY_RELATIVE)
- {
- KeyBlock *kb;
- for (kb = (KeyBlock *)key->block.first; kb; kb = (KeyBlock *)kb->next)
- {
- shape.push_back(kb->curval);
- }
- }
- }
- return !shape.empty();
-}
-
-void BL_DeformableGameObject::SetDeformer(class RAS_Deformer* deformer)
-{
- m_pDeformer = deformer;
-
- SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
- for (mit.begin(); !mit.end(); ++mit)
- {
- (*mit)->SetDeformer(deformer);
- }
-}
-
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h
deleted file mode 100644
index 95e3b7c517d..00000000000
--- a/source/gameengine/Converter/BL_DeformableGameObject.h
+++ /dev/null
@@ -1,107 +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 BL_DeformableGameObject.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_DEFORMABLEGAMEOBJECT_H__
-#define __BL_DEFORMABLEGAMEOBJECT_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
-#endif
-
-#include "DNA_mesh_types.h"
-#include "KX_GameObject.h"
-#include "BL_MeshDeformer.h"
-#include "KX_SoftBodyDeformer.h"
-#include <vector>
-
-class BL_ShapeActionActuator;
-struct Key;
-
-class BL_DeformableGameObject : public KX_GameObject
-{
-public:
- CValue* GetReplica();
-
- double GetLastFrame ()
- {
- return m_lastframe;
- }
- Object* GetBlendObject()
- {
- return m_blendobj;
- }
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*>*map)
- {
- if (m_pDeformer)
- m_pDeformer->Relink (map);
- KX_GameObject::Relink(map);
- };
- void ProcessReplica();
-
- BL_DeformableGameObject(Object* blendobj, void* sgReplicationInfo, SG_Callbacks callbacks) :
- KX_GameObject(sgReplicationInfo,callbacks),
- m_pDeformer(NULL),
- m_activeAct(NULL),
- m_lastframe(0.0),
- m_blendobj(blendobj),
- m_activePriority(9999)
- {
- m_isDeformable = true;
- };
- virtual ~BL_DeformableGameObject();
- bool SetActiveAction(class BL_ShapeActionActuator *act, short priority, double curtime);
-
- bool GetShape(vector<float> &shape);
-
- virtual void SetDeformer(class RAS_Deformer* deformer);
- virtual class RAS_Deformer* GetDeformer()
- {
- return m_pDeformer;
- }
-
-public:
-
-protected:
-
- RAS_Deformer *m_pDeformer;
-
- class BL_ShapeActionActuator *m_activeAct;
- double m_lastframe;
- Object* m_blendobj;
- short m_activePriority;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_DeformableGameObject")
-#endif
-};
-
-#endif /* __BL_DEFORMABLEGAMEOBJECT_H__ */
diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp
deleted file mode 100644
index 911ff245ab4..00000000000
--- a/source/gameengine/Converter/BL_MeshDeformer.cpp
+++ /dev/null
@@ -1,239 +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 *****
- * Simple deformation controller that restores a mesh to its rest position
- */
-
-/** \file gameengine/Converter/BL_MeshDeformer.cpp
- * \ingroup bgeconv
- */
-
-#ifdef _MSC_VER
- /* This warning tells us about truncation of __long__ stl-generated names.
- * It can occasionally cause DevStudio to have internal compiler warnings. */
-# pragma warning( disable:4786 )
-#endif
-
-#include "RAS_IPolygonMaterial.h"
-#include "BL_DeformableGameObject.h"
-#include "BL_MeshDeformer.h"
-#include "RAS_MeshObject.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-
-#include "CTR_Map.h"
-#include "STR_HashedString.h"
-#include "BLI_math.h"
-
-bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*)
-{
- size_t i;
-
- // only apply once per frame if the mesh is actually modified
- if (m_pMeshObject->MeshModified() &&
- m_lastDeformUpdate != m_gameobj->GetLastFrame())
- {
- // For each material
- for (list<RAS_MeshMaterial>::iterator mit= m_pMeshObject->GetFirstMaterial();
- mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
- if (!mit->m_slots[(void*)m_gameobj])
- continue;
-
- RAS_MeshSlot *slot = *mit->m_slots[(void*)m_gameobj];
- RAS_MeshSlot::iterator it;
-
- // for each array
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- // For each vertex
- for (i=it.startvertex; i<it.endvertex; i++) {
- RAS_TexVert& v = it.vertex[i];
- v.SetXYZ(m_bmesh->mvert[v.getOrigIndex()].co);
- }
- }
- }
-
- m_lastDeformUpdate = m_gameobj->GetLastFrame();
-
- return true;
- }
-
- return false;
-}
-
-BL_MeshDeformer::~BL_MeshDeformer()
-{
- if (m_transverts)
- delete [] m_transverts;
- if (m_transnors)
- delete [] m_transnors;
-}
-
-void BL_MeshDeformer::ProcessReplica()
-{
- m_transverts = NULL;
- m_transnors = NULL;
- m_tvtot = 0;
- m_bDynamic=false;
- m_lastDeformUpdate = -1;
-}
-
-void BL_MeshDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
-{
- void **h_obj = (*map)[m_gameobj];
-
- if (h_obj)
- m_gameobj = (BL_DeformableGameObject*)(*h_obj);
- else
- m_gameobj = NULL;
-}
-
-/**
- * \warning This function is expensive!
- */
-void BL_MeshDeformer::RecalcNormals()
-{
- /* We don't normalize for performance, not doing it for faces normals
- * gives area-weight normals which often look better anyway, and use
- * GL_NORMALIZE so we don't have to do per vertex normalization either
- * since the GPU can do it faster */
- list<RAS_MeshMaterial>::iterator mit;
- RAS_MeshSlot::iterator it;
- size_t i;
-
- /* set vertex normals to zero */
- memset(m_transnors, 0, sizeof(float)*3*m_bmesh->totvert);
-
- /* add face normals to vertices. */
- for (mit = m_pMeshObject->GetFirstMaterial();
- mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
- if (!mit->m_slots[(void*)m_gameobj])
- continue;
-
- RAS_MeshSlot *slot = *mit->m_slots[(void*)m_gameobj];
-
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- int nvert = (int)it.array->m_type;
-
- for (i=0; i<it.totindex; i+=nvert) {
- RAS_TexVert& v1 = it.vertex[it.index[i]];
- RAS_TexVert& v2 = it.vertex[it.index[i+1]];
- RAS_TexVert& v3 = it.vertex[it.index[i+2]];
- RAS_TexVert *v4 = NULL;
-
- const float *co1 = m_transverts[v1.getOrigIndex()];
- const float *co2 = m_transverts[v2.getOrigIndex()];
- const float *co3 = m_transverts[v3.getOrigIndex()];
- const float *co4 = NULL;
-
- /* compute face normal */
- float fnor[3], n1[3], n2[3];
-
- if (nvert == 4) {
- v4 = &it.vertex[it.index[i+3]];
- co4 = m_transverts[v4->getOrigIndex()];
-
- n1[0] = co1[0] - co3[0];
- n1[1] = co1[1] - co3[1];
- n1[2] = co1[2] - co3[2];
-
- n2[0] = co2[0] - co4[0];
- n2[1] = co2[1] - co4[1];
- n2[2] = co2[2] - co4[2];
- }
- else {
- n1[0] = co1[0] - co2[0];
- n2[0] = co2[0] - co3[0];
- n1[1] = co1[1] - co2[1];
-
- n2[1] = co2[1] - co3[1];
- n1[2] = co1[2] - co2[2];
- n2[2] = co2[2] - co3[2];
- }
-
- fnor[0] = n1[1] * n2[2] - n1[2] * n2[1];
- fnor[1] = n1[2] * n2[0] - n1[0] * n2[2];
- fnor[2] = n1[0] * n2[1] - n1[1] * n2[0];
- normalize_v3(fnor);
-
- /* add to vertices for smooth normals */
- float *vn1 = m_transnors[v1.getOrigIndex()];
- float *vn2 = m_transnors[v2.getOrigIndex()];
- float *vn3 = m_transnors[v3.getOrigIndex()];
-
- vn1[0] += fnor[0]; vn1[1] += fnor[1]; vn1[2] += fnor[2];
- vn2[0] += fnor[0]; vn2[1] += fnor[1]; vn2[2] += fnor[2];
- vn3[0] += fnor[0]; vn3[1] += fnor[1]; vn3[2] += fnor[2];
-
- if (v4) {
- float *vn4 = m_transnors[v4->getOrigIndex()];
- vn4[0] += fnor[0]; vn4[1] += fnor[1]; vn4[2] += fnor[2];
- }
-
- /* in case of flat - just assign, the vertices are split */
- if (v1.getFlag() & RAS_TexVert::FLAT) {
- v1.SetNormal(fnor);
- v2.SetNormal(fnor);
- v3.SetNormal(fnor);
- if (v4)
- v4->SetNormal(fnor);
- }
- }
- }
- }
-
- /* assign smooth vertex normals */
- for (mit = m_pMeshObject->GetFirstMaterial();
- mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
- if (!mit->m_slots[(void*)m_gameobj])
- continue;
-
- RAS_MeshSlot *slot = *mit->m_slots[(void*)m_gameobj];
-
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- for (i=it.startvertex; i<it.endvertex; i++) {
- RAS_TexVert& v = it.vertex[i];
-
- if (!(v.getFlag() & RAS_TexVert::FLAT))
- v.SetNormal(m_transnors[v.getOrigIndex()]); //.safe_normalized()
- }
- }
- }
-}
-
-void BL_MeshDeformer::VerifyStorage()
-{
- /* Ensure that we have the right number of verts assigned */
- if (m_tvtot!=m_bmesh->totvert) {
- if (m_transverts)
- delete [] m_transverts;
- if (m_transnors)
- delete [] m_transnors;
-
- m_transverts=new float[m_bmesh->totvert][3];
- m_transnors=new float[m_bmesh->totvert][3];
- m_tvtot = m_bmesh->totvert;
- }
-}
-
diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h
deleted file mode 100644
index 6e84cdf03f8..00000000000
--- a/source/gameengine/Converter/BL_MeshDeformer.h
+++ /dev/null
@@ -1,98 +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 BL_MeshDeformer.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_MESHDEFORMER_H__
-#define __BL_MESHDEFORMER_H__
-
-#include "RAS_Deformer.h"
-#include "DNA_object_types.h"
-#include "DNA_key_types.h"
-#include "MT_Point3.h"
-#include <stdlib.h>
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* get rid of stupid stl-visual compiler debug warning */
-#endif
-
-class BL_DeformableGameObject;
-
-class BL_MeshDeformer : public RAS_Deformer
-{
-public:
- void VerifyStorage();
- void RecalcNormals();
- virtual void Relink(CTR_Map<class CTR_HashedPtr, void*>*map);
- BL_MeshDeformer(BL_DeformableGameObject *gameobj,
- struct Object* obj,
- class RAS_MeshObject *meshobj ):
- m_pMeshObject(meshobj),
- m_bmesh((struct Mesh*)(obj->data)),
- m_transverts(0),
- m_transnors(0),
- m_objMesh(obj),
- m_tvtot(0),
- m_gameobj(gameobj),
- m_lastDeformUpdate(-1)
- {};
- virtual ~BL_MeshDeformer();
- virtual void SetSimulatedTime(double time) {}
- virtual bool Apply(class RAS_IPolyMaterial *mat);
- virtual bool Update(void) { return false; }
- virtual bool UpdateBuckets(void) { return false; }
- virtual RAS_Deformer* GetReplica() {return NULL;}
- virtual void ProcessReplica();
- struct Mesh* GetMesh() { return m_bmesh; }
- virtual class RAS_MeshObject* GetRasMesh() { return m_pMeshObject; }
- virtual float (* GetTransVerts(int *tot))[3] { *tot= m_tvtot; return m_transverts; }
- // virtual void InitDeform(double time) {}
-
-protected:
- class RAS_MeshObject* m_pMeshObject;
- struct Mesh* m_bmesh;
-
- // this is so m_transverts doesn't need to be converted
- // before deformation
- float (*m_transverts)[3];
- float (*m_transnors)[3];
- struct Object* m_objMesh;
- // --
- int m_tvtot;
- BL_DeformableGameObject* m_gameobj;
- double m_lastDeformUpdate;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_MeshDeformer")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp
deleted file mode 100644
index 3be2c1aff43..00000000000
--- a/source/gameengine/Converter/BL_ModifierDeformer.cpp
+++ /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 gameengine/Converter/BL_ModifierDeformer.cpp
- * \ingroup bgeconv
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "MEM_guardedalloc.h"
-#include "BL_ModifierDeformer.h"
-#include "CTR_Map.h"
-#include "STR_HashedString.h"
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_MeshObject.h"
-#include "PHY_IGraphicController.h"
-
-#include "DNA_armature_types.h"
-#include "DNA_action_types.h"
-#include "DNA_key_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_scene_types.h"
-#include "BLI_utildefines.h"
-#include "BKE_armature.h"
-#include "BKE_action.h"
-#include "BKE_key.h"
-#include "BKE_ipo.h"
-#include "MT_Point3.h"
-
-extern "C"{
- #include "BKE_customdata.h"
- #include "BKE_DerivedMesh.h"
- #include "BKE_lattice.h"
- #include "BKE_modifier.h"
-}
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-
-BL_ModifierDeformer::~BL_ModifierDeformer()
-{
- if (m_dm) {
- // deformedOnly is used as a user counter
- if (--m_dm->deformedOnly == 0) {
- m_dm->needsFree = 1;
- m_dm->release(m_dm);
- }
- }
-};
-
-RAS_Deformer *BL_ModifierDeformer::GetReplica()
-{
- BL_ModifierDeformer *result;
-
- result = new BL_ModifierDeformer(*this);
- result->ProcessReplica();
- return result;
-}
-
-void BL_ModifierDeformer::ProcessReplica()
-{
- /* Note! - This is not inherited from PyObjectPlus */
- BL_ShapeDeformer::ProcessReplica();
- if (m_dm)
- // by default try to reuse mesh, deformedOnly is used as a user count
- m_dm->deformedOnly++;
- // this will force an update and if the mesh cannot be reused, a new one will be created
- m_lastModifierUpdate = -1;
-}
-
-bool BL_ModifierDeformer::HasCompatibleDeformer(Object *ob)
-{
- if (!ob->modifiers.first)
- return false;
- // soft body cannot use mesh modifiers
- if ((ob->gameflag & OB_SOFT_BODY) != 0)
- return false;
- ModifierData* md;
- for (md = (ModifierData *)ob->modifiers.first; md; md = md->next) {
- if (modifier_dependsOnTime(md))
- continue;
- if (!(md->mode & eModifierMode_Realtime))
- continue;
- /* armature modifier are handled by SkinDeformer, not ModifierDeformer */
- if (md->type == eModifierType_Armature )
- continue;
- return true;
- }
- return false;
-}
-
-bool BL_ModifierDeformer::HasArmatureDeformer(Object *ob)
-{
- if (!ob->modifiers.first)
- return false;
-
- ModifierData* md = (ModifierData*)ob->modifiers.first;
- if (md->type == eModifierType_Armature )
- return true;
-
- return false;
-}
-
-// return a deformed mesh that supports mapping (with a valid CD_ORIGINDEX layer)
-struct DerivedMesh* BL_ModifierDeformer::GetPhysicsMesh()
-{
- /* TODO: This doesn't work currently because of eval_ctx. */
-#if 0
- /* we need to compute the deformed mesh taking into account the current
- * shape and skin deformers, we cannot just call mesh_create_derived_physics()
- * because that would use the m_transvers already deformed previously by BL_ModifierDeformer::Update(),
- * so restart from scratch by forcing a full update the shape/skin deformers
- * (will do nothing if there is no such deformer) */
- BL_ShapeDeformer::ForceUpdate();
- BL_ShapeDeformer::Update();
- // now apply the modifiers but without those that don't support mapping
- Object* blendobj = m_gameobj->GetBlendObject();
- /* hack: the modifiers require that the mesh is attached to the object
- * It may not be the case here because of replace mesh actuator */
- Mesh *oldmesh = (Mesh*)blendobj->data;
- blendobj->data = m_bmesh;
- DerivedMesh *dm = mesh_create_derived_physics(m_scene, blendobj, m_transverts, CD_MASK_MESH);
- /* restore object data */
- blendobj->data = oldmesh;
- /* m_transverts is correct here (takes into account deform only modifiers) */
- /* the derived mesh returned by this function must be released by the caller !!! */
- return dm;
-#endif
- return NULL;
-}
-
-bool BL_ModifierDeformer::Update(void)
-{
- /* TODO: This doesn't work currently because of eval_ctx. */
-#if 0
- bool bShapeUpdate = BL_ShapeDeformer::Update();
-
- if (bShapeUpdate || m_lastModifierUpdate != m_gameobj->GetLastFrame()) {
- // static derived mesh are not updated
- if (m_dm == NULL || m_bDynamic) {
- /* execute the modifiers */
- Object* blendobj = m_gameobj->GetBlendObject();
- /* hack: the modifiers require that the mesh is attached to the object
- * It may not be the case here because of replace mesh actuator */
- Mesh *oldmesh = (Mesh*)blendobj->data;
- blendobj->data = m_bmesh;
- /* execute the modifiers */
- DerivedMesh *dm = mesh_create_derived_no_virtual(m_scene, blendobj, m_transverts, CD_MASK_MESH);
- /* restore object data */
- blendobj->data = oldmesh;
- /* free the current derived mesh and replace, (dm should never be NULL) */
- if (m_dm != NULL) {
- // HACK! use deformedOnly as a user counter
- if (--m_dm->deformedOnly == 0) {
- m_dm->needsFree = 1;
- m_dm->release(m_dm);
- }
- }
- m_dm = dm;
- // get rid of temporary data
- m_dm->needsFree = 0;
- m_dm->release(m_dm);
- // HACK! use deformedOnly as a user counter
- m_dm->deformedOnly = 1;
- DM_update_materials(m_dm, blendobj);
- /* update the graphic controller */
- PHY_IGraphicController *ctrl = m_gameobj->GetGraphicController();
- if (ctrl) {
- float min[3], max[3];
- INIT_MINMAX(min, max);
- m_dm->getMinMax(m_dm, min, max);
- ctrl->SetLocalAabb(min, max);
- }
- }
- m_lastModifierUpdate=m_gameobj->GetLastFrame();
- bShapeUpdate = true;
-
- int nmat = m_pMeshObject->NumMaterials();
- for (int imat=0; imat<nmat; imat++) {
- RAS_MeshMaterial *mmat = m_pMeshObject->GetMeshMaterial(imat);
- RAS_MeshSlot **slot = mmat->m_slots[(void*)m_gameobj];
- if (!slot || !*slot)
- continue;
- (*slot)->m_pDerivedMesh = m_dm;
- }
- }
- return bShapeUpdate;
-#endif
- return false;
-}
-
-bool BL_ModifierDeformer::Apply(RAS_IPolyMaterial *mat)
-{
- if (!Update())
- return false;
-
- return true;
-}
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.h b/source/gameengine/Converter/BL_ModifierDeformer.h
deleted file mode 100644
index 4efe4ca5bfc..00000000000
--- a/source/gameengine/Converter/BL_ModifierDeformer.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 BL_ModifierDeformer.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_MODIFIERDEFORMER_H__
-#define __BL_MODIFIERDEFORMER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* get rid of stupid stl-visual compiler debug warning */
-#endif
-
-#include "BL_ShapeDeformer.h"
-#include "BL_DeformableGameObject.h"
-#include <vector>
-
-struct DerivedMesh;
-struct Object;
-
-class BL_ModifierDeformer : public BL_ShapeDeformer
-{
-public:
- static bool HasCompatibleDeformer(Object *ob);
- static bool HasArmatureDeformer(Object *ob);
-
-
- BL_ModifierDeformer(BL_DeformableGameObject *gameobj,
- Scene *scene,
- Object *bmeshobj,
- RAS_MeshObject *mesh)
- :
- BL_ShapeDeformer(gameobj,bmeshobj, mesh),
- m_lastModifierUpdate(-1),
- m_scene(scene),
- m_dm(NULL)
- {
- m_recalcNormal = false;
- }
-
- /* this second constructor is needed for making a mesh deformable on the fly. */
- BL_ModifierDeformer(BL_DeformableGameObject *gameobj,
- struct Scene *scene,
- struct Object *bmeshobj_old,
- struct Object *bmeshobj_new,
- class RAS_MeshObject *mesh,
- bool release_object,
- BL_ArmatureObject* arma = NULL)
- :
- BL_ShapeDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, false, arma),
- m_lastModifierUpdate(-1),
- m_scene(scene),
- m_dm(NULL)
- {
- /* pass */
- }
-
- virtual void ProcessReplica();
- virtual RAS_Deformer *GetReplica();
- virtual ~BL_ModifierDeformer();
- virtual bool UseVertexArray()
- {
- return false;
- }
-
- bool Update (void);
- bool Apply(RAS_IPolyMaterial *mat);
- void ForceUpdate()
- {
- m_lastModifierUpdate = -1.0;
- };
- virtual struct DerivedMesh* GetFinalMesh()
- {
- return m_dm;
- }
- // The derived mesh returned by this function must be released!
- virtual struct DerivedMesh* GetPhysicsMesh();
-
-protected:
- double m_lastModifierUpdate;
- Scene *m_scene;
- DerivedMesh *m_dm;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ModifierDeformer")
-#endif
-};
-
-#endif /* __BL_MODIFIERDEFORMER_H__ */
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
deleted file mode 100644
index f21db419ebc..00000000000
--- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp
+++ /dev/null
@@ -1,563 +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/Converter/BL_ShapeActionActuator.cpp
- * \ingroup bgeconv
- */
-
-
-#include <cmath>
-
-#include "SCA_LogicManager.h"
-#include "BL_ShapeActionActuator.h"
-#include "BL_ShapeDeformer.h"
-#include "KX_GameObject.h"
-#include "STR_HashedString.h"
-#include "DNA_nla_types.h"
-#include "DNA_action_types.h"
-#include "DNA_anim_types.h"
-#include "DNA_scene_types.h"
-#include "BKE_action.h"
-#include "DNA_armature_types.h"
-#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "MT_Matrix4x4.h"
-
-#include "EXP_FloatValue.h"
-#include "EXP_PyObjectPlus.h"
-
-extern "C" {
- #include "BKE_animsys.h"
- #include "BKE_key.h"
- #include "RNA_access.h"
-}
-
-BL_ShapeActionActuator::BL_ShapeActionActuator(SCA_IObject* gameobj,
- const STR_String& propname,
- const STR_String& framepropname,
- float starttime,
- float endtime,
- struct bAction *action,
- short playtype,
- short blendin,
- short priority,
- float stride)
- : SCA_IActuator(gameobj, KX_ACT_SHAPEACTION),
-
- m_lastpos(0, 0, 0),
- m_blendframe(0),
- m_flag(0),
- m_startframe (starttime),
- m_endframe(endtime) ,
- m_starttime(0),
- m_localtime(starttime),
- m_lastUpdate(-1),
- m_blendin(blendin),
- m_blendstart(0),
- m_stridelength(stride),
- m_playtype(playtype),
- m_priority(priority),
- m_action(action),
- m_framepropname(framepropname),
- m_propname(propname)
-{
- m_idptr = new PointerRNA();
- BL_DeformableGameObject *obj = (BL_DeformableGameObject*)GetParent();
- BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
- RNA_id_pointer_create(&shape_deformer->GetKey()->id, m_idptr);
-};
-
-BL_ShapeActionActuator::~BL_ShapeActionActuator()
-{
- if (m_idptr)
- delete m_idptr;
-}
-
-void BL_ShapeActionActuator::ProcessReplica()
-{
- SCA_IActuator::ProcessReplica();
- m_localtime=m_startframe;
- m_lastUpdate=-1;
-}
-
-void BL_ShapeActionActuator::SetBlendTime(float newtime)
-{
- m_blendframe = newtime;
-}
-
-CValue* BL_ShapeActionActuator::GetReplica()
-{
- BL_ShapeActionActuator* replica = new BL_ShapeActionActuator(*this);//m_float,GetName());
- replica->ProcessReplica();
- return replica;
-}
-
-bool BL_ShapeActionActuator::ClampLocalTime()
-{
- if (m_startframe < m_endframe) {
- if (m_localtime < m_startframe)
- {
- m_localtime = m_startframe;
- return true;
- }
- else if (m_localtime > m_endframe)
- {
- m_localtime = m_endframe;
- return true;
- }
- } else {
- if (m_localtime > m_startframe)
- {
- m_localtime = m_startframe;
- return true;
- }
- else if (m_localtime < m_endframe)
- {
- m_localtime = m_endframe;
- return true;
- }
- }
- return false;
-}
-
-void BL_ShapeActionActuator::SetStartTime(float curtime)
-{
- float direction = m_startframe < m_endframe ? 1.0 : -1.0;
-
- if (!(m_flag & ACT_FLAG_REVERSE))
- m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
- else
- m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate();
-}
-
-void BL_ShapeActionActuator::SetLocalTime(float curtime)
-{
- float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
-
- if (m_endframe < m_startframe)
- delta_time = -delta_time;
-
- if (!(m_flag & ACT_FLAG_REVERSE))
- m_localtime = m_startframe + delta_time;
- else
- m_localtime = m_endframe - delta_time;
-}
-
-void BL_ShapeActionActuator::BlendShape(Key* key, float srcweight)
-{
- vector<float>::const_iterator it;
- float dstweight;
- KeyBlock *kb;
-
- dstweight = 1.0F - srcweight;
-
- for (it=m_blendshape.begin(), kb = (KeyBlock *)key->block.first;
- kb && it != m_blendshape.end();
- kb = (KeyBlock *)kb->next, it++)
- {
- kb->curval = kb->curval * dstweight + (*it) * srcweight;
- }
-}
-
-bool BL_ShapeActionActuator::Update(double curtime, bool frame)
-{
- bool bNegativeEvent = false;
- bool bPositiveEvent = false;
- bool keepgoing = true;
- bool wrap = false;
- bool apply=true;
- int priority;
- float newweight;
-
- curtime -= KX_KetsjiEngine::GetSuspendedDelta();
-
- // result = true if animation has to be continued, false if animation stops
- // maybe there are events for us in the queue !
- if (frame)
- {
- bNegativeEvent = m_negevent;
- bPositiveEvent = m_posevent;
- RemoveAllEvents();
-
- if (bPositiveEvent)
- m_flag |= ACT_FLAG_ACTIVE;
-
- if (bNegativeEvent)
- {
- if (!(m_flag & ACT_FLAG_ACTIVE))
- return false;
- m_flag &= ~ACT_FLAG_ACTIVE;
- }
- }
-
- /* This action can only be attached to a deform object */
- BL_DeformableGameObject *obj = (BL_DeformableGameObject*)GetParent();
- float length = m_endframe - m_startframe;
-
- priority = m_priority;
-
- /* Determine pre-incrementation behavior and set appropriate flags */
- switch (m_playtype) {
- case ACT_ACTION_MOTION:
- if (bNegativeEvent) {
- keepgoing=false;
- apply=false;
- };
- break;
- case ACT_ACTION_FROM_PROP:
- if (bNegativeEvent) {
- apply=false;
- keepgoing=false;
- }
- break;
- case ACT_ACTION_LOOP_END:
- if (bPositiveEvent) {
- if (!(m_flag & ACT_FLAG_LOCKINPUT)) {
- m_flag &= ~ACT_FLAG_KEYUP;
- m_flag &= ~ACT_FLAG_REVERSE;
- m_flag |= ACT_FLAG_LOCKINPUT;
- m_localtime = m_startframe;
- m_starttime = curtime;
- }
- }
- if (bNegativeEvent) {
- m_flag |= ACT_FLAG_KEYUP;
- }
- break;
- case ACT_ACTION_LOOP_STOP:
- if (bPositiveEvent) {
- if (!(m_flag & ACT_FLAG_LOCKINPUT)) {
- m_flag &= ~ACT_FLAG_REVERSE;
- m_flag &= ~ACT_FLAG_KEYUP;
- m_flag |= ACT_FLAG_LOCKINPUT;
- SetStartTime(curtime);
- }
- }
- if (bNegativeEvent) {
- m_flag |= ACT_FLAG_KEYUP;
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- keepgoing=false;
- apply=false;
- }
- break;
- case ACT_ACTION_PINGPONG:
- if (bPositiveEvent) {
- if (!(m_flag & ACT_FLAG_LOCKINPUT)) {
- m_flag &= ~ACT_FLAG_KEYUP;
- m_localtime = m_starttime;
- m_starttime = curtime;
- m_flag |= ACT_FLAG_LOCKINPUT;
- }
- }
- break;
- case ACT_ACTION_FLIPPER:
- if (bPositiveEvent) {
- if (!(m_flag & ACT_FLAG_LOCKINPUT)) {
- m_flag &= ~ACT_FLAG_REVERSE;
- m_flag |= ACT_FLAG_LOCKINPUT;
- SetStartTime(curtime);
- }
- }
- else if (bNegativeEvent) {
- m_flag |= ACT_FLAG_REVERSE;
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- SetStartTime(curtime);
- }
- break;
- case ACT_ACTION_PLAY:
- if (bPositiveEvent) {
- if (!(m_flag & ACT_FLAG_LOCKINPUT)) {
- m_flag &= ~ACT_FLAG_REVERSE;
- m_localtime = m_starttime;
- m_starttime = curtime;
- m_flag |= ACT_FLAG_LOCKINPUT;
- }
- }
- break;
- default:
- break;
- }
-
- /* Perform increment */
- if (keepgoing) {
- if (m_playtype == ACT_ACTION_MOTION) {
- MT_Point3 newpos;
- MT_Point3 deltapos;
-
- newpos = obj->NodeGetWorldPosition();
-
- /* Find displacement */
- deltapos = newpos-m_lastpos;
- m_localtime += (length/m_stridelength) * deltapos.length();
- m_lastpos = newpos;
- }
- else {
- SetLocalTime(curtime);
- }
- }
-
- /* Check if a wrapping response is needed */
- if (length) {
- if (m_localtime < m_startframe || m_localtime > m_endframe)
- {
- m_localtime = m_startframe + fmod(m_localtime, length);
- wrap = true;
- }
- }
- else
- m_localtime = m_startframe;
-
- /* Perform post-increment tasks */
- switch (m_playtype) {
- case ACT_ACTION_FROM_PROP:
- {
- CValue* propval = GetParent()->GetProperty(m_propname);
- if (propval)
- m_localtime = propval->GetNumber();
-
- if (bNegativeEvent) {
- keepgoing=false;
- }
- }
- break;
- case ACT_ACTION_MOTION:
- break;
- case ACT_ACTION_LOOP_STOP:
- break;
- case ACT_ACTION_PINGPONG:
- if (wrap) {
- if (!(m_flag & ACT_FLAG_REVERSE))
- m_localtime = m_endframe;
- else
- m_localtime = m_startframe;
-
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- m_flag ^= ACT_FLAG_REVERSE; //flip direction
- keepgoing = false;
- }
- break;
- case ACT_ACTION_FLIPPER:
- if (wrap) {
- if (!(m_flag & ACT_FLAG_REVERSE)) {
- m_localtime=m_endframe;
- //keepgoing = false;
- }
- else {
- m_localtime=m_startframe;
- keepgoing = false;
- }
- }
- break;
- case ACT_ACTION_LOOP_END:
- if (wrap) {
- if (m_flag & ACT_FLAG_KEYUP) {
- keepgoing = false;
- m_localtime = m_endframe;
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- }
- SetStartTime(curtime);
- }
- break;
- case ACT_ACTION_PLAY:
- if (wrap) {
- m_localtime = m_endframe;
- keepgoing = false;
- m_flag &= ~ACT_FLAG_LOCKINPUT;
- }
- break;
- default:
- keepgoing = false;
- break;
- }
-
- /* Set the property if its defined */
- if (m_framepropname[0] != '\0') {
- CValue* propowner = GetParent();
- CValue* oldprop = propowner->GetProperty(m_framepropname);
- CValue* newval = new CFloatValue(m_localtime);
- if (oldprop) {
- oldprop->SetValue(newval);
- } else {
- propowner->SetProperty(m_framepropname, newval);
- }
- newval->Release();
- }
-
- if (bNegativeEvent)
- m_blendframe=0.0f;
-
- /* Apply the pose if necessary*/
- if (apply) {
-
- /* Priority test */
- if (obj->SetActiveAction(this, priority, curtime)) {
- BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
- Key *key = NULL;
-
- if (shape_deformer)
- key = shape_deformer->GetKey();
-
- if (!key) {
- // this could happen if the mesh was changed in the middle of an action
- // and the new mesh has no key, stop the action
- keepgoing = false;
- }
- else {
- ListBase tchanbase= {NULL, NULL};
-
- if (m_blendin && m_blendframe==0.0f) {
- // this is the start of the blending, remember the startup shape
- obj->GetShape(m_blendshape);
- m_blendstart = curtime;
- }
-
- KeyBlock *kb;
- // We go through and clear out the keyblocks so there isn't any interference
- // from other shape actions
- for (kb=(KeyBlock *)key->block.first; kb; kb=(KeyBlock *)kb->next)
- kb->curval = 0.f;
-
- animsys_evaluate_action(m_idptr, m_action, NULL, m_localtime);
-
- // XXX - in 2.5 theres no way to do this. possibly not that important to support - Campbell
- if (0) { // XXX !execute_ipochannels(&tchanbase)) {
- // no update, this is possible if action does not match the keys, stop the action
- keepgoing = false;
- }
- else {
- // the key have changed, apply blending if needed
- if (m_blendin && (m_blendframe<m_blendin)) {
- newweight = (m_blendframe/(float)m_blendin);
-
- BlendShape(key, 1.0f - newweight);
-
- /* Increment current blending percentage */
- m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate();
- if (m_blendframe>m_blendin)
- m_blendframe = m_blendin;
- }
- m_lastUpdate = m_localtime;
- }
- BLI_freelistN(&tchanbase);
- }
- }
- else {
- m_blendframe = 0.0f;
- }
- }
-
- if (!keepgoing) {
- m_blendframe = 0.0f;
- }
- return keepgoing;
-};
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-
-PyTypeObject BL_ShapeActionActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "BL_ShapeActionActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-
-PyMethodDef BL_ShapeActionActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef BL_ShapeActionActuator::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RW("frameStart", 0, MAXFRAMEF, BL_ShapeActionActuator, m_startframe),
- KX_PYATTRIBUTE_FLOAT_RW("frameEnd", 0, MAXFRAMEF, BL_ShapeActionActuator, m_endframe),
- KX_PYATTRIBUTE_FLOAT_RW("blendIn", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendin),
- KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ShapeActionActuator, pyattr_get_action, pyattr_set_action),
- KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ShapeActionActuator, m_priority),
- KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ShapeActionActuator, m_localtime, CheckFrame),
- KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, BL_ShapeActionActuator, m_propname),
- KX_PYATTRIBUTE_STRING_RW("framePropName", 0, MAX_PROP_NAME, false, BL_ShapeActionActuator, m_framepropname),
- KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendframe, CheckBlendTime),
- KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",0,100,false,BL_ShapeActionActuator,m_playtype,CheckType),
- { NULL } //Sentinel
-};
-
-PyObject *BL_ShapeActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- BL_ShapeActionActuator* self = static_cast<BL_ShapeActionActuator*>(self_v);
- return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
-}
-
-int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- BL_ShapeActionActuator* self = static_cast<BL_ShapeActionActuator*>(self_v);
- /* exact copy of BL_ActionActuator's function from here down */
- if (!PyUnicode_Check(value))
- {
- PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, expected the string name of the action");
- return PY_SET_ATTR_FAIL;
- }
-
- bAction *action= NULL;
- STR_String val = _PyUnicode_AsString(value);
-
- if (val != "")
- {
- action= (bAction*)self->GetLogicManager()->GetActionByName(val);
- if (action==NULL)
- {
- PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, action not found!");
- return PY_SET_ATTR_FAIL;
- }
- }
-
- self->SetAction(action);
- return PY_SET_ATTR_SUCCESS;
-
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h
deleted file mode 100644
index e96d0e0ebb4..00000000000
--- a/source/gameengine/Converter/BL_ShapeActionActuator.h
+++ /dev/null
@@ -1,144 +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 BL_ShapeActionActuator.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_SHAPEACTIONACTUATOR_H__
-#define __BL_SHAPEACTIONACTUATOR_H__
-
-#include "CTR_HashedPtr.h"
-#include "SCA_IActuator.h"
-#include "BL_ActionActuator.h"
-#include "MT_Point3.h"
-#include <vector>
-
-struct Key;
-class BL_ShapeActionActuator : public SCA_IActuator
-{
-public:
- Py_Header
- BL_ShapeActionActuator(SCA_IObject* gameobj,
- const STR_String& propname,
- const STR_String& framepropname,
- float starttime,
- float endtime,
- struct bAction *action,
- short playtype,
- short blendin,
- short priority,
- float stride);
- virtual ~BL_ShapeActionActuator();
- virtual bool Update(double curtime, bool frame);
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
-
- void SetBlendTime (float newtime);
- void BlendShape(struct Key* key, float weight);
-
- bAction* GetAction() { return m_action; }
- void SetAction(bAction* act) { m_action= act; }
-
-#ifdef WITH_PYTHON
-
- static PyObject* pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static int CheckBlendTime(void *self, const PyAttributeDef*)
- {
- BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
-
- if (act->m_blendframe > act->m_blendin)
- act->m_blendframe = act->m_blendin;
-
- return 0;
- }
- static int CheckFrame(void *self, const PyAttributeDef*)
- {
- BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
-
- if (act->m_localtime < act->m_startframe)
- act->m_localtime = act->m_startframe;
- else if (act->m_localtime > act->m_endframe)
- act->m_localtime = act->m_endframe;
-
- return 0;
- }
- static int CheckType(void *self, const PyAttributeDef*)
- {
- BL_ShapeActionActuator* act = reinterpret_cast<BL_ShapeActionActuator*>(self);
-
- switch (act->m_playtype) {
- case ACT_ACTION_PLAY:
- case ACT_ACTION_PINGPONG:
- case ACT_ACTION_FLIPPER:
- case ACT_ACTION_LOOP_STOP:
- case ACT_ACTION_LOOP_END:
- case ACT_ACTION_FROM_PROP:
- return 0;
- default:
- PyErr_SetString(PyExc_ValueError, "Shape Action Actuator, invalid play type supplied");
- return 1;
- }
-
- }
-
-#endif /* WITH_PYTHON */
-
-protected:
-
- void SetStartTime(float curtime);
- void SetLocalTime(float curtime);
- bool ClampLocalTime();
-
- MT_Point3 m_lastpos;
- float m_blendframe;
- int m_flag;
- /** The frame this action starts */
- float m_startframe;
- /** The frame this action ends */
- float m_endframe;
- /** The time this action started */
- float m_starttime;
- /** The current time of the action */
- float m_localtime;
-
- float m_lastUpdate;
- float m_blendin;
- float m_blendstart;
- float m_stridelength;
- short m_playtype;
- short m_priority;
- struct bAction *m_action;
- STR_String m_framepropname;
- STR_String m_propname;
- vector<float> m_blendshape;
- struct PointerRNA *m_idptr;
-};
-
-#endif /* __BL_SHAPEACTIONACTUATOR_H__ */
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp
deleted file mode 100644
index 94256a64d75..00000000000
--- a/source/gameengine/Converter/BL_ShapeDeformer.cpp
+++ /dev/null
@@ -1,237 +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/Converter/BL_ShapeDeformer.cpp
- * \ingroup bgeconv
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "MEM_guardedalloc.h"
-#include "BL_ShapeDeformer.h"
-#include "CTR_Map.h"
-#include "STR_HashedString.h"
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_MeshObject.h"
-
-#include "DNA_anim_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_action_types.h"
-#include "DNA_key_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "BKE_armature.h"
-#include "BKE_action.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_key.h"
-#include "BKE_fcurve.h"
-#include "BKE_ipo.h"
-#include "BKE_library.h"
-#include "MT_Point3.h"
-
-extern "C"{
- #include "BKE_lattice.h"
- #include "BKE_animsys.h"
-}
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-
-#define __NLA_DEFNORMALS
-//#undef __NLA_DEFNORMALS
-
-BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
- Object *bmeshobj,
- RAS_MeshObject *mesh)
- :
- BL_SkinDeformer(gameobj,bmeshobj, mesh),
- m_useShapeDrivers(false),
- m_lastShapeUpdate(-1)
-{
- m_key = m_bmesh->key ? BKE_key_copy(G.main, m_bmesh->key) : NULL;
-};
-
-/* this second constructor is needed for making a mesh deformable on the fly. */
-BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
- Object *bmeshobj_old,
- Object *bmeshobj_new,
- RAS_MeshObject *mesh,
- bool release_object,
- bool recalc_normal,
- BL_ArmatureObject* arma)
- :
- BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, recalc_normal, arma),
- m_useShapeDrivers(false),
- m_lastShapeUpdate(-1)
-{
- m_key = m_bmesh->key ? BKE_key_copy(G.main, m_bmesh->key) : NULL;
-};
-
-BL_ShapeDeformer::~BL_ShapeDeformer()
-{
- if (m_key)
- {
- BKE_libblock_free(G.main, m_key);
- m_key = NULL;
- }
-};
-
-RAS_Deformer *BL_ShapeDeformer::GetReplica()
-{
- BL_ShapeDeformer *result;
-
- result = new BL_ShapeDeformer(*this);
- result->ProcessReplica();
- return result;
-}
-
-void BL_ShapeDeformer::ProcessReplica()
-{
- BL_SkinDeformer::ProcessReplica();
- m_lastShapeUpdate = -1;
-
- m_key = m_key ? BKE_key_copy(G.main, m_key) : NULL;
-}
-
-bool BL_ShapeDeformer::LoadShapeDrivers(KX_GameObject* parent)
-{
- // Only load shape drivers if we have a key
- if (GetKey() == NULL) {
- m_useShapeDrivers = false;
- return false;
- }
-
- // Fix drivers since BL_ArmatureObject makes copies
- if (parent->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE && GetKey()->adt) {
- BL_ArmatureObject *arma = (BL_ArmatureObject*)parent;
- FCurve *fcu;
-
- for (fcu = (FCurve*)GetKey()->adt->drivers.first; fcu; fcu = (FCurve*)fcu->next) {
-
- DriverVar *dvar;
- for (dvar = (DriverVar*)fcu->driver->variables.first; dvar; dvar = (DriverVar*)dvar->next) {
- DRIVER_TARGETS_USED_LOOPER(dvar)
- {
- if (dtar->id) {
- if ((Object*)dtar->id == arma->GetOrigArmatureObject())
- dtar->id = (ID*)arma->GetArmatureObject();
- }
- }
- DRIVER_TARGETS_LOOPER_END
- }
- }
- }
-
- // This used to check if we had drivers from this armature,
- // now we just assume we want to use shape drivers
- // and let the animsys handle things.
- m_useShapeDrivers = true;
-
- return true;
-}
-
-bool BL_ShapeDeformer::ExecuteShapeDrivers(void)
-{
- if (m_useShapeDrivers && PoseUpdated()) {
- // We don't need an actual time, just use 0
- BKE_animsys_evaluate_animdata(NULL, &GetKey()->id, GetKey()->adt, 0.f, ADT_RECALC_DRIVERS);
-
- ForceUpdate();
- m_bDynamic = true;
- return true;
- }
- return false;
-}
-
-bool BL_ShapeDeformer::Update(void)
-{
- bool bShapeUpdate = false;
- bool bSkinUpdate = false;
-
- ExecuteShapeDrivers();
-
- /* See if the object shape has changed */
- if (m_lastShapeUpdate != m_gameobj->GetLastFrame()) {
- /* the key coefficient have been set already, we just need to blend the keys */
- Object* blendobj = m_gameobj->GetBlendObject();
-
- /* we will blend the key directly in m_transverts array: it is used by armature as the start position */
- /* m_key can be NULL in case of Modifier deformer */
- if (m_key) {
- WeightsArrayCache cache = {0, NULL};
- float **per_keyblock_weights;
-
- /* store verts locally */
- VerifyStorage();
-
- per_keyblock_weights = BKE_keyblock_get_per_block_weights(blendobj, m_key, &cache);
- BKE_key_evaluate_relative(0, m_bmesh->totvert, m_bmesh->totvert, (char *)(float *)m_transverts,
- m_key, NULL, per_keyblock_weights, 0); /* last arg is ignored */
- BKE_keyblock_free_per_block_weights(m_key, per_keyblock_weights, &cache);
-
- m_bDynamic = true;
- }
-
- // Don't release the weight array as in Blender, it will most likely be reusable on next frame
- // The weight array are ultimately deleted when the skin mesh is destroyed
-
- /* Update the current frame */
- m_lastShapeUpdate=m_gameobj->GetLastFrame();
-
- // As we have changed, the mesh, the skin deformer must update as well.
- // This will force the update
- BL_SkinDeformer::ForceUpdate();
- bShapeUpdate = true;
- }
- // check for armature deform
- bSkinUpdate = BL_SkinDeformer::UpdateInternal(bShapeUpdate && m_bDynamic);
-
- // non dynamic deformer = Modifer without armature and shape keys, no need to create storage
- if (!bSkinUpdate && bShapeUpdate && m_bDynamic) {
- // this means that there is no armature, we still need to
- // update the normal (was not done after shape key calculation)
-
-#ifdef __NLA_DEFNORMALS
- if (m_recalcNormal)
- RecalcNormals();
-#endif
-
- // We also need to handle transverts now (used to be in BL_SkinDeformer::Apply())
- UpdateTransverts();
- bSkinUpdate = true;
- }
-
- return bSkinUpdate;
-}
-
-Key *BL_ShapeDeformer::GetKey()
-{
- return m_key;
-}
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h
deleted file mode 100644
index f6746dd2302..00000000000
--- a/source/gameengine/Converter/BL_ShapeDeformer.h
+++ /dev/null
@@ -1,86 +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 BL_ShapeDeformer.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_SHAPEDEFORMER_H__
-#define __BL_SHAPEDEFORMER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* get rid of stupid stl-visual compiler debug warning */
-#endif
-
-#include "BL_SkinDeformer.h"
-#include "BL_DeformableGameObject.h"
-#include <vector>
-
-class BL_ShapeDeformer : public BL_SkinDeformer
-{
-public:
- BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
- Object *bmeshobj,
- RAS_MeshObject *mesh);
-
- /* this second constructor is needed for making a mesh deformable on the fly. */
- BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
- struct Object *bmeshobj_old,
- struct Object *bmeshobj_new,
- class RAS_MeshObject *mesh,
- bool release_object,
- bool recalc_normal,
- BL_ArmatureObject* arma = NULL);
-
- virtual RAS_Deformer *GetReplica();
- virtual void ProcessReplica();
- virtual ~BL_ShapeDeformer();
-
- bool Update (void);
- bool LoadShapeDrivers(KX_GameObject* parent);
- bool ExecuteShapeDrivers(void);
-
- struct Key *GetKey();
-
- void ForceUpdate()
- {
- m_lastShapeUpdate = -1.0;
- };
-
-protected:
- bool m_useShapeDrivers;
- double m_lastShapeUpdate;
- struct Key* m_key;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ShapeDeformer")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp
deleted file mode 100644
index 68da99f9fa5..00000000000
--- a/source/gameengine/Converter/BL_SkinDeformer.cpp
+++ /dev/null
@@ -1,384 +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/Converter/BL_SkinDeformer.cpp
- * \ingroup bgeconv
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-// Eigen3 stuff used for BGEDeformVerts
-#include <Eigen/Core>
-#include <Eigen/LU>
-
-#include "BL_SkinDeformer.h"
-#include "CTR_Map.h"
-#include "STR_HashedString.h"
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_MeshObject.h"
-
-//#include "BL_ArmatureController.h"
-#include "DNA_armature_types.h"
-#include "DNA_action_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_modifier_types.h"
-#include "BLI_utildefines.h"
-#include "BKE_armature.h"
-#include "BKE_action.h"
-#include "MT_Point3.h"
-
-extern "C"{
- #include "BKE_lattice.h"
- #include "BKE_deform.h"
-}
-
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-
-#define __NLA_DEFNORMALS
-//#undef __NLA_DEFNORMALS
-
-static short get_deformflags(struct Object *bmeshobj)
-{
- short flags = ARM_DEF_VGROUP;
-
- ModifierData *md;
- for (md = (ModifierData *)bmeshobj->modifiers.first; md; md = md->next)
- {
- if (md->type == eModifierType_Armature)
- {
- flags |= ((ArmatureModifierData*)md)->deformflag;
- break;
- }
- }
-
- return flags;
-}
-
-BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj,
- struct Object *bmeshobj,
- class RAS_MeshObject *mesh,
- BL_ArmatureObject* arma)
- : //
- BL_MeshDeformer(gameobj, bmeshobj, mesh),
- m_armobj(arma),
- m_lastArmaUpdate(-1),
- //m_defbase(&bmeshobj->defbase),
- m_releaseobject(false),
- m_poseApplied(false),
- m_recalcNormal(true),
- m_copyNormals(false),
- m_dfnrToPC(NULL)
-{
- copy_m4_m4(m_obmat, bmeshobj->obmat);
- m_deformflags = get_deformflags(bmeshobj);
-};
-
-BL_SkinDeformer::BL_SkinDeformer(
- BL_DeformableGameObject *gameobj,
- struct Object *bmeshobj_old, // Blender object that owns the new mesh
- struct Object *bmeshobj_new, // Blender object that owns the original mesh
- class RAS_MeshObject *mesh,
- bool release_object,
- bool recalc_normal,
- BL_ArmatureObject* arma) :
- BL_MeshDeformer(gameobj, bmeshobj_old, mesh),
- m_armobj(arma),
- m_lastArmaUpdate(-1),
- //m_defbase(&bmeshobj_old->defbase),
- m_releaseobject(release_object),
- m_recalcNormal(recalc_normal),
- m_copyNormals(false),
- m_dfnrToPC(NULL)
- {
- // this is needed to ensure correct deformation of mesh:
- // the deformation is done with Blender's armature_deform_verts() function
- // that takes an object as parameter and not a mesh. The object matrice is used
- // in the calculation, so we must use the matrix of the original object to
- // simulate a pure replacement of the mesh.
- copy_m4_m4(m_obmat, bmeshobj_new->obmat);
- m_deformflags = get_deformflags(bmeshobj_new);
- }
-
-BL_SkinDeformer::~BL_SkinDeformer()
-{
- if (m_releaseobject && m_armobj)
- m_armobj->Release();
- if (m_dfnrToPC)
- delete [] m_dfnrToPC;
-}
-
-void BL_SkinDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
-{
- if (m_armobj) {
- void **h_obj = (*map)[m_armobj];
-
- if (h_obj)
- m_armobj = (BL_ArmatureObject*)(*h_obj);
- else
- m_armobj=NULL;
- }
-
- BL_MeshDeformer::Relink(map);
-}
-
-bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
-{
- // We do everything in UpdateInternal() now so we can thread it.
- // All that is left is telling the rasterizer if we've changed the mesh
- bool retval = !m_poseApplied;
- m_poseApplied = true;
- return retval;
-}
-
-RAS_Deformer *BL_SkinDeformer::GetReplica()
-{
- BL_SkinDeformer *result;
-
- result = new BL_SkinDeformer(*this);
- /* there is m_armobj that must be fixed but we cannot do it now, it will be done in Relink */
- result->ProcessReplica();
- return result;
-}
-
-void BL_SkinDeformer::ProcessReplica()
-{
- BL_MeshDeformer::ProcessReplica();
- m_lastArmaUpdate = -1;
- m_releaseobject = false;
- m_dfnrToPC = NULL;
-}
-
-void BL_SkinDeformer::BlenderDeformVerts()
-{
- float obmat[4][4]; // the original object matrix
- Object* par_arma = m_armobj->GetArmatureObject();
-
- // save matrix first
- copy_m4_m4(obmat, m_objMesh->obmat);
- // set reference matrix
- copy_m4_m4(m_objMesh->obmat, m_obmat);
-
- armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, m_deformflags, NULL, NULL );
-
- // restore matrix
- copy_m4_m4(m_objMesh->obmat, obmat);
-
-#ifdef __NLA_DEFNORMALS
- if (m_recalcNormal)
- RecalcNormals();
-#endif
-}
-
-void BL_SkinDeformer::BGEDeformVerts()
-{
- Object *par_arma = m_armobj->GetArmatureObject();
- MDeformVert *dverts = m_bmesh->dvert;
- bDeformGroup *dg;
- int defbase_tot;
- Eigen::Matrix4f pre_mat, post_mat, chan_mat, norm_chan_mat;
-
- if (!dverts)
- return;
-
- defbase_tot = BLI_listbase_count(&m_objMesh->defbase);
-
- if (m_dfnrToPC == NULL)
- {
- m_dfnrToPC = new bPoseChannel*[defbase_tot];
- int i;
- for (i=0, dg=(bDeformGroup*)m_objMesh->defbase.first;
- dg;
- ++i, dg = dg->next)
- {
- m_dfnrToPC[i] = BKE_pose_channel_find_name(par_arma->pose, dg->name);
-
- if (m_dfnrToPC[i] && m_dfnrToPC[i]->bone->flag & BONE_NO_DEFORM)
- m_dfnrToPC[i] = NULL;
- }
- }
-
- post_mat = Eigen::Matrix4f::Map((float*)m_obmat).inverse() * Eigen::Matrix4f::Map((float*)m_armobj->GetArmatureObject()->obmat);
- pre_mat = post_mat.inverse();
-
- MDeformVert *dv= dverts;
- MDeformWeight *dw;
-
- for (int i=0; i<m_bmesh->totvert; ++i, dv++)
- {
- float contrib = 0.f, weight, max_weight=-1.f;
- bPoseChannel *pchan=NULL;
- Eigen::Map<Eigen::Vector3f> norm = Eigen::Vector3f::Map(m_transnors[i]);
- Eigen::Vector4f vec(0, 0, 0, 1);
- Eigen::Vector4f co(m_transverts[i][0],
- m_transverts[i][1],
- m_transverts[i][2],
- 1.f);
-
- if (!dv->totweight)
- continue;
-
- co = pre_mat * co;
-
- dw= dv->dw;
-
- for (unsigned int j= dv->totweight; j != 0; j--, dw++)
- {
- const int index = dw->def_nr;
-
- if (index < defbase_tot && (pchan=m_dfnrToPC[index]))
- {
- weight = dw->weight;
-
- if (weight)
- {
- chan_mat = Eigen::Matrix4f::Map((float*)pchan->chan_mat);
-
- // Update Vertex Position
- vec.noalias() += (chan_mat*co - co)*weight;
-
- // Save the most influential channel so we can use it to update the vertex normal
- if (weight > max_weight)
- {
- max_weight = weight;
- norm_chan_mat = chan_mat;
- }
-
- contrib += weight;
- }
- }
- }
-
- // Update Vertex Normal
- norm = norm_chan_mat.topLeftCorner<3, 3>()*norm;
-
- co.noalias() += vec/contrib;
- co[3] = 1.f; // Make sure we have a 1 for the w component!
-
- co = post_mat * co;
-
- m_transverts[i][0] = co[0];
- m_transverts[i][1] = co[1];
- m_transverts[i][2] = co[2];
- }
- m_copyNormals = true;
-}
-
-void BL_SkinDeformer::UpdateTransverts()
-{
- RAS_MeshSlot::iterator it;
- RAS_MeshMaterial *mmat;
- RAS_MeshSlot *slot;
- size_t i, nmat, imat;
-
- if (m_transverts) {
- // the vertex cache is unique to this deformer, no need to update it
- // if it wasn't updated! We must update all the materials at once
- // because we will not get here again for the other material
- nmat = m_pMeshObject->NumMaterials();
- for (imat=0; imat<nmat; imat++) {
- mmat = m_pMeshObject->GetMeshMaterial(imat);
- if (!mmat->m_slots[(void*)m_gameobj])
- continue;
-
- slot = *mmat->m_slots[(void*)m_gameobj];
-
- // for each array
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- // for each vertex
- // copy the untransformed data from the original mvert
- for (i=it.startvertex; i<it.endvertex; i++) {
- RAS_TexVert& v = it.vertex[i];
- v.SetXYZ(m_transverts[v.getOrigIndex()]);
- if (m_copyNormals)
- v.SetNormal(m_transnors[v.getOrigIndex()]);
- }
- }
- }
-
- if (m_copyNormals)
- m_copyNormals = false;
- }
-}
-
-bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
-{
- /* See if the armature has been updated for this frame */
- if (PoseUpdated()) {
-
- if (!shape_applied) {
- /* store verts locally */
- VerifyStorage();
-
- /* duplicate */
- for (int v =0; v<m_bmesh->totvert; v++)
- {
- copy_v3_v3(m_transverts[v], m_bmesh->mvert[v].co);
- normal_short_to_float_v3(m_transnors[v], m_bmesh->mvert[v].no);
- }
- }
-
- m_armobj->ApplyPose();
-
- if (m_armobj->GetVertDeformType() == ARM_VDEF_BGE_CPU)
- BGEDeformVerts();
- else
- BlenderDeformVerts();
-
- /* Update the current frame */
- m_lastArmaUpdate=m_armobj->GetLastFrame();
-
- m_armobj->RestorePose();
- /* dynamic vertex, cannot use display list */
- m_bDynamic = true;
-
- UpdateTransverts();
-
- m_poseApplied = false;
-
- /* indicate that the m_transverts and normals are up to date */
- return true;
- }
-
- return false;
-}
-
-bool BL_SkinDeformer::Update(void)
-{
- return UpdateInternal(false);
-}
-
-/* XXX note: I propose to drop this function */
-void BL_SkinDeformer::SetArmature(BL_ArmatureObject *armobj)
-{
- // only used to set the object now
- m_armobj = armobj;
-}
diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h
deleted file mode 100644
index 79043f60db8..00000000000
--- a/source/gameengine/Converter/BL_SkinDeformer.h
+++ /dev/null
@@ -1,125 +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 BL_SkinDeformer.h
- * \ingroup bgeconv
- */
-
-#ifndef __BL_SKINDEFORMER_H__
-#define __BL_SKINDEFORMER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* get rid of stupid stl-visual compiler debug warning */
-#endif /* WIN32 */
-
-#include "CTR_HashedPtr.h"
-#include "BL_MeshDeformer.h"
-#include "BL_ArmatureObject.h"
-
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-#include "BKE_armature.h"
-
-#include "RAS_Deformer.h"
-
-
-class BL_SkinDeformer : public BL_MeshDeformer
-{
-public:
-// void SetArmatureController (BL_ArmatureController *cont);
- virtual void Relink(CTR_Map<class CTR_HashedPtr, void*>*map);
- void SetArmature (class BL_ArmatureObject *armobj);
-
- BL_SkinDeformer(BL_DeformableGameObject *gameobj,
- struct Object *bmeshobj,
- class RAS_MeshObject *mesh,
- BL_ArmatureObject* arma = NULL);
-
- /* this second constructor is needed for making a mesh deformable on the fly. */
- BL_SkinDeformer(BL_DeformableGameObject *gameobj,
- struct Object *bmeshobj_old,
- struct Object *bmeshobj_new,
- class RAS_MeshObject *mesh,
- bool release_object,
- bool recalc_normal,
- BL_ArmatureObject* arma = NULL);
-
- virtual RAS_Deformer *GetReplica();
- virtual void ProcessReplica();
-
- virtual ~BL_SkinDeformer();
- bool Update (void);
- bool UpdateInternal (bool shape_applied);
- bool Apply (class RAS_IPolyMaterial *polymat);
- bool UpdateBuckets(void)
- {
- // update the deformer and all the mesh slots; Apply() does it well, so just call it.
- return Apply(NULL);
- }
- bool PoseUpdated(void)
- {
- if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) {
- return true;
- }
- return false;
- }
-
- void ForceUpdate()
- {
- m_lastArmaUpdate = -1.0;
- };
- virtual bool ShareVertexArray()
- {
- return false;
- }
-
-protected:
- BL_ArmatureObject* m_armobj; // Our parent object
- float m_time;
- double m_lastArmaUpdate;
- //ListBase* m_defbase;
- float m_obmat[4][4]; // the reference matrix for skeleton deform
- bool m_releaseobject;
- bool m_poseApplied;
- bool m_recalcNormal;
- bool m_copyNormals; // dirty flag so we know if Apply() needs to copy normal information (used for BGEDeformVerts())
- struct bPoseChannel** m_dfnrToPC;
- short m_deformflags;
-
- void BlenderDeformVerts();
- void BGEDeformVerts();
-
- void UpdateTransverts();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_SkinDeformer")
-#endif
-};
-
-#endif /* __BL_SKINDEFORMER_H__ */
diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt
deleted file mode 100644
index 7d6195e3c38..00000000000
--- a/source/gameengine/Converter/CMakeLists.txt
+++ /dev/null
@@ -1,123 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../BlenderRoutines
- ../Expressions
- ../GameLogic
- ../Ketsji
- ../Ketsji/KXNetwork
- ../Network
- ../Network/LoopBackNetwork
- ../Physics/Bullet
- ../Physics/Dummy
- ../Physics/common
- ../Rasterizer
- ../Rasterizer/RAS_OpenGLRasterizer
- ../SceneGraph
- ../../blender
- ../../blender/blenkernel
- ../../blender/blenlib
- ../../blender/blenloader
- ../../blender/gpu
- ../../blender/ikplugin
- ../../blender/imbuf
- ../../blender/makesdna
- ../../blender/makesrna
- ../../blender/windowmanager
- ../../../intern/container
- ../../../intern/guardedalloc
- ../../../intern/string
-)
-
-set(INC_SYS
- ../../../intern/moto/include
- ../../../extern/recastnavigation/Detour/Include
- ${EIGEN3_INCLUDE_DIRS}
- ${PTHREADS_INCLUDE_DIRS}
- ${BOOST_INCLUDE_DIR}
-)
-
-set(SRC
- BL_ActionActuator.cpp
- BL_ArmatureActuator.cpp
- BL_ArmatureChannel.cpp
- BL_ArmatureConstraint.cpp
- BL_ArmatureObject.cpp
- BL_BlenderDataConversion.cpp
- BL_DeformableGameObject.cpp
- BL_MeshDeformer.cpp
- BL_ModifierDeformer.cpp
- BL_ShapeActionActuator.cpp
- BL_ShapeDeformer.cpp
- BL_SkinDeformer.cpp
- KX_BlenderScalarInterpolator.cpp
- KX_BlenderSceneConverter.cpp
- KX_ConvertActuators.cpp
- KX_ConvertControllers.cpp
- KX_ConvertProperties.cpp
- KX_ConvertSensors.cpp
- KX_LibLoadStatus.cpp
- KX_SoftBodyDeformer.cpp
-
- BL_ActionActuator.h
- BL_ArmatureActuator.h
- BL_ArmatureChannel.h
- BL_ArmatureConstraint.h
- BL_ArmatureObject.h
- BL_BlenderDataConversion.h
- BL_DeformableGameObject.h
- BL_MeshDeformer.h
- BL_ModifierDeformer.h
- BL_ShapeActionActuator.h
- BL_ShapeDeformer.h
- BL_SkinDeformer.h
- KX_BlenderScalarInterpolator.h
- KX_BlenderSceneConverter.h
- KX_ConvertActuators.h
- KX_ConvertControllers.h
- KX_ConvertProperties.h
- KX_ConvertSensors.h
- KX_LibLoadStatus.h
- KX_SoftBodyDeformer.h
-)
-
-if(WITH_BULLET)
- list(APPEND INC_SYS
- ${BULLET_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_BULLET)
-endif()
-
-if(WITH_AUDASPACE)
- add_definitions(-DWITH_AUDASPACE)
-
- list(APPEND INC_SYS
- ${AUDASPACE_C_INCLUDE_DIRS}
- )
-endif()
-
-blender_add_lib(ge_converter "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
deleted file mode 100644
index 4d344cdf16a..00000000000
--- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
+++ /dev/null
@@ -1,81 +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/Converter/KX_BlenderScalarInterpolator.cpp
- * \ingroup bgeconv
- */
-
-
-#include "KX_BlenderScalarInterpolator.h"
-
-#include <cstring>
-
-extern "C" {
-#include "DNA_action_types.h"
-#include "DNA_anim_types.h"
-#include "BKE_fcurve.h"
-}
-
-float BL_ScalarInterpolator::GetValue(float currentTime) const
-{
- // XXX 2.4x IPO_GetFloatValue(m_blender_adt, m_channel, currentTime);
- return evaluate_fcurve(m_fcu, currentTime);
-}
-
-BL_InterpolatorList::BL_InterpolatorList(bAction *action)
-{
- if (action==NULL)
- return;
-
- for (FCurve *fcu = (FCurve *)action->curves.first; fcu; fcu = fcu->next) {
- if (fcu->rna_path) {
- BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu);
- //assert(new_ipo);
- push_back(new_ipo);
- }
- }
-}
-
-BL_InterpolatorList::~BL_InterpolatorList()
-{
- BL_InterpolatorList::iterator i;
- for (i = begin(); !(i == end()); ++i) {
- delete *i;
- }
-}
-
-KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const char *rna_path, int array_index)
-{
- for (BL_InterpolatorList::iterator i = begin(); (i != end()) ; i++ )
- {
- FCurve *fcu= (static_cast<BL_ScalarInterpolator *>(*i))->GetFCurve();
- if (array_index==fcu->array_index && strcmp(rna_path, fcu->rna_path)==0)
- return *i;
- }
- return NULL;
-}
-
diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
deleted file mode 100644
index d828910233f..00000000000
--- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
+++ /dev/null
@@ -1,76 +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_BlenderScalarInterpolator.h
- * \ingroup bgeconv
- */
-
-#ifndef __KX_BLENDERSCALARINTERPOLATOR_H__
-#define __KX_BLENDERSCALARINTERPOLATOR_H__
-
-#include <vector>
-
-#include "KX_IScalarInterpolator.h"
-
-typedef unsigned short BL_IpoChannel;
-
-class BL_ScalarInterpolator : public KX_IScalarInterpolator {
-public:
- BL_ScalarInterpolator() {} // required for use in STL list
- BL_ScalarInterpolator(struct FCurve* fcu) :
- m_fcu(fcu)
- {}
-
- virtual ~BL_ScalarInterpolator() {}
-
- virtual float GetValue(float currentTime) const;
- struct FCurve *GetFCurve() { return m_fcu; }
-
-private:
- struct FCurve *m_fcu;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ScalarInterpolator")
-#endif
-};
-
-
-class BL_InterpolatorList : public std::vector<KX_IScalarInterpolator *> {
-public:
- BL_InterpolatorList(struct bAction *action);
- ~BL_InterpolatorList();
-
- KX_IScalarInterpolator *GetScalarInterpolator(const char *rna_path, int array_index);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_InterpolatorList")
-#endif
-};
-
-#endif /* __KX_BLENDERSCALARINTERPOLATOR_H__ */
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
deleted file mode 100644
index 08b569fa4c2..00000000000
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ /dev/null
@@ -1,1477 +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/Converter/KX_BlenderSceneConverter.cpp
- * \ingroup bgeconv
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* suppress stl-MSVC debug info warning */
-#endif
-
-#include "KX_Scene.h"
-#include "KX_GameObject.h"
-#include "KX_IpoConvert.h"
-#include "RAS_MeshObject.h"
-#include "KX_PhysicsEngineEnums.h"
-#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 "BL_Material.h"
-#include "BL_ActionActuator.h"
-#include "KX_BlenderMaterial.h"
-
-
-#include "BL_System.h"
-
-#include "DummyPhysicsEnvironment.h"
-
-
-#ifdef WITH_BULLET
-#include "CcdPhysicsEnvironment.h"
-#endif
-
-#include "KX_LibLoadStatus.h"
-#include "KX_BlenderScalarInterpolator.h"
-#include "BL_BlenderDataConversion.h"
-#include "KX_WorldInfo.h"
-
-/* This little block needed for linking to Blender... */
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#endif
-
-/* This list includes only data type definitions */
-#include "DNA_scene_types.h"
-#include "DNA_world_types.h"
-#include "BKE_main.h"
-#include "BKE_fcurve.h"
-
-#include "BLI_math.h"
-
-extern "C"
-{
-#include "DNA_object_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_material_types.h"
-#include "BLI_blenlib.h"
-#include "MEM_guardedalloc.h"
-#include "BKE_global.h"
-#include "BKE_animsys.h"
-#include "BKE_library.h"
-#include "BKE_material.h" // BKE_material_copy
-#include "BKE_mesh.h" // BKE_mesh_copy
-#include "DNA_space_types.h"
-#include "DNA_anim_types.h"
-#include "DNA_action_types.h"
-#include "RNA_define.h"
-#include "../../blender/editors/include/ED_keyframing.h"
-}
-
-/* Only for dynamic loading and merging */
-#include "RAS_BucketManager.h" // XXX cant stay
-#include "KX_BlenderSceneConverter.h"
-#include "KX_MeshProxy.h"
-extern "C" {
- #include "PIL_time.h"
- #include "BKE_context.h"
- #include "BLO_readfile.h"
- #include "BKE_idcode.h"
- #include "BKE_report.h"
- #include "DNA_space_types.h"
- #include "DNA_windowmanager_types.h" /* report api */
- #include "../../blender/blenlib/BLI_linklist.h"
-}
-
-#include "BLI_task.h"
-
-// This is used to avoid including BLI_task.h in KX_BlenderSceneConverter.h
-typedef struct ThreadInfo {
- TaskPool *m_pool;
- ThreadMutex m_mutex;
-} ThreadInfo;
-
-KX_BlenderSceneConverter::KX_BlenderSceneConverter(
- Main *maggie,
- KX_KetsjiEngine *engine)
- :m_maggie(maggie),
- m_ketsjiEngine(engine),
- m_alwaysUseExpandFraming(false),
- m_usemat(false),
- m_useglslmat(false),
- m_use_mat_cache(true)
-{
- BKE_main_id_tag_all(maggie, LIB_TAG_DOIT, false); /* avoid re-tagging later on */
- m_newfilename = "";
- m_threadinfo = new ThreadInfo();
- m_threadinfo->m_pool = BLI_task_pool_create(engine->GetTaskScheduler(), NULL);
- BLI_mutex_init(&m_threadinfo->m_mutex);
-}
-
-KX_BlenderSceneConverter::~KX_BlenderSceneConverter()
-{
- // clears meshes, and hashmaps from blender to gameengine data
- // delete sumoshapes
-
- int numAdtLists = m_map_blender_to_gameAdtList.size();
- for (int i = 0; i < numAdtLists; i++) {
- BL_InterpolatorList *adtList = *m_map_blender_to_gameAdtList.at(i);
-
- delete (adtList);
- }
-
- vector<pair<KX_Scene *, KX_WorldInfo *> >::iterator itw = m_worldinfos.begin();
- while (itw != m_worldinfos.end()) {
- delete itw->second;
- itw++;
- }
- m_worldinfos.clear();
-
- vector<pair<KX_Scene *,RAS_IPolyMaterial *> >::iterator itp = m_polymaterials.begin();
- while (itp != m_polymaterials.end()) {
- delete itp->second;
- itp++;
- }
- m_polymaterials.clear();
-
- // delete after RAS_IPolyMaterial
- vector<pair<KX_Scene *,BL_Material *> >::iterator itmat = m_materials.begin();
- while (itmat != m_materials.end()) {
- delete itmat->second;
- itmat++;
- }
- m_materials.clear();
-
- vector<pair<KX_Scene *,RAS_MeshObject *> >::iterator itm = m_meshobjects.begin();
- while (itm != m_meshobjects.end()) {
- delete itm->second;
- itm++;
- }
- m_meshobjects.clear();
-
- /* free any data that was dynamically loaded */
- while (m_DynamicMaggie.size() != 0) {
- FreeBlendFile(m_DynamicMaggie[0]);
- }
-
- m_DynamicMaggie.clear();
-
- if (m_threadinfo) {
- /* Thread infos like mutex must be freed after FreeBlendFile function.
- Because it needs to lock the mutex, even if there's no active task when it's
- in the scene converter destructor. */
- BLI_task_pool_free(m_threadinfo->m_pool);
- BLI_mutex_end(&m_threadinfo->m_mutex);
- delete m_threadinfo;
- }
-}
-
-void KX_BlenderSceneConverter::SetNewFileName(const STR_String &filename)
-{
- m_newfilename = filename;
-}
-
-bool KX_BlenderSceneConverter::TryAndLoadNewFile()
-{
- bool result = false;
-
- return result;
-}
-
-Scene *KX_BlenderSceneConverter::GetBlenderSceneForName(const STR_String &name)
-{
- Scene *sce;
-
- /**
- * Find the specified scene by name, or NULL if nothing matches.
- */
- if ((sce = (Scene *)BLI_findstring(&m_maggie->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
- return sce;
-
- for (vector<Main *>::iterator it=m_DynamicMaggie.begin(); !(it == m_DynamicMaggie.end()); it++) {
- Main *main = *it;
-
- if ((sce= (Scene *)BLI_findstring(&main->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
- return sce;
- }
-
- return NULL;
-}
-
-void KX_BlenderSceneConverter::ConvertScene(KX_Scene *destinationscene, RAS_IRasterizer *rendertools,
- RAS_ICanvas *canvas, bool libloading)
-{
- //find out which physics engine
- Scene *blenderscene = destinationscene->GetBlenderScene();
-
- PHY_IPhysicsEnvironment *phy_env = NULL;
-
- e_PhysicsEngine physics_engine = UseBullet;
- // hook for registration function during conversion.
- m_currentScene = destinationscene;
- destinationscene->SetSceneConverter(this);
-
- // This doesn't really seem to do anything except cause potential issues
- // when doing threaded conversion, so it's disabled for now.
- // SG_SetActiveStage(SG_STAGE_CONVERTER);
-
- switch (blenderscene->gm.physicsEngine) {
-#ifdef WITH_BULLET
- case WOPHY_BULLET:
- {
- SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/
- int visualizePhysics = SYS_GetCommandLineInt(syshandle, "show_physics", 0);
-
- phy_env = CcdPhysicsEnvironment::Create(blenderscene, visualizePhysics);
- physics_engine = UseBullet;
- break;
- }
-#endif
- default:
- case WOPHY_NONE:
- {
- // We should probably use some sort of factory here
- phy_env = new DummyPhysicsEnvironment();
- physics_engine = UseNone;
- break;
- }
- }
-
- destinationscene->SetPhysicsEnvironment(phy_env);
-
- BL_ConvertBlenderObjects(
- m_maggie,
- destinationscene,
- m_ketsjiEngine,
- physics_engine,
- rendertools,
- canvas,
- this,
- m_alwaysUseExpandFraming,
- libloading);
-
- //These lookup are not needed during game
- m_map_blender_to_gameactuator.clear();
- m_map_blender_to_gamecontroller.clear();
- m_map_blender_to_gameobject.clear();
-
- //Clearing this lookup table has the effect of disabling the cache of meshes
- //between scenes, even if they are shared in the blend file.
- //This cache mecanism is buggy so I leave it disable and the memory leak
- //that would result from this is fixed in RemoveScene()
- m_map_mesh_to_gamemesh.clear();
-}
-
-// This function removes all entities stored in the converter for that scene
-// It should be used instead of direct delete scene
-// Note that there was some provision for sharing entities (meshes...) between
-// scenes but that is now disabled so all scene will have their own copy
-// and we can delete them here. If the sharing is reactivated, change this code too..
-// (see KX_BlenderSceneConverter::ConvertScene)
-void KX_BlenderSceneConverter::RemoveScene(KX_Scene *scene)
-{
- int i, size;
- // delete the scene first as it will stop the use of entities
- delete scene;
- // delete the entities of this scene
- vector<pair<KX_Scene *, KX_WorldInfo *> >::iterator worldit;
- size = m_worldinfos.size();
- for (i = 0, worldit = m_worldinfos.begin(); i < size; ) {
- if (worldit->first == scene) {
- delete worldit->second;
- *worldit = m_worldinfos.back();
- m_worldinfos.pop_back();
- size--;
- }
- else {
- i++;
- worldit++;
- }
- }
-
- vector<pair<KX_Scene *, RAS_IPolyMaterial *> >::iterator polymit;
- size = m_polymaterials.size();
- for (i = 0, polymit = m_polymaterials.begin(); i < size; ) {
- if (polymit->first == scene) {
- m_polymat_cache[scene].erase(polymit->second->GetBlenderMaterial());
- delete polymit->second;
- *polymit = m_polymaterials.back();
- m_polymaterials.pop_back();
- size--;
- }
- else {
- i++;
- polymit++;
- }
- }
-
- m_polymat_cache.erase(scene);
-
- vector<pair<KX_Scene *, BL_Material *> >::iterator matit;
- size = m_materials.size();
- for (i = 0, matit = m_materials.begin(); i < size; ) {
- if (matit->first == scene) {
- m_mat_cache[scene].erase(matit->second->material);
- delete matit->second;
- *matit = m_materials.back();
- m_materials.pop_back();
- size--;
- }
- else {
- i++;
- matit++;
- }
- }
-
- m_mat_cache.erase(scene);
-
- vector<pair<KX_Scene *, RAS_MeshObject *> >::iterator meshit;
- size = m_meshobjects.size();
- for (i = 0, meshit = m_meshobjects.begin(); i < size; ) {
- if (meshit->first == scene) {
- delete meshit->second;
- *meshit = m_meshobjects.back();
- m_meshobjects.pop_back();
- size--;
- }
- else {
- i++;
- meshit++;
- }
- }
-}
-
-// use blender materials
-void KX_BlenderSceneConverter::SetMaterials(bool val)
-{
- m_usemat = val;
- m_useglslmat = false;
-}
-
-void KX_BlenderSceneConverter::SetGLSLMaterials(bool val)
-{
- m_usemat = val;
- m_useglslmat = val;
-}
-
-void KX_BlenderSceneConverter::SetCacheMaterials(bool val)
-{
- m_use_mat_cache = val;
-}
-
-bool KX_BlenderSceneConverter::GetMaterials()
-{
- return m_usemat;
-}
-
-bool KX_BlenderSceneConverter::GetGLSLMaterials()
-{
- return m_useglslmat;
-}
-
-bool KX_BlenderSceneConverter::GetCacheMaterials()
-{
- return m_use_mat_cache;
-}
-
-void KX_BlenderSceneConverter::RegisterBlenderMaterial(BL_Material *mat)
-{
- // First make sure we don't register the material twice
- vector<pair<KX_Scene *, BL_Material *> >::iterator it;
- for (it = m_materials.begin(); it != m_materials.end(); ++it)
- if (it->second == mat)
- return;
-
- m_materials.push_back(pair<KX_Scene *, BL_Material *> (m_currentScene, mat));
-}
-
-void KX_BlenderSceneConverter::SetAlwaysUseExpandFraming(bool to_what)
-{
- m_alwaysUseExpandFraming= to_what;
-}
-
-void KX_BlenderSceneConverter::RegisterGameObject(KX_GameObject *gameobject, Object *for_blenderobject)
-{
- /* only maintained while converting, freed during game runtime */
- m_map_blender_to_gameobject.insert(CHashedPtr(for_blenderobject), gameobject);
-}
-
-/* only need to run this during conversion since
- * m_map_blender_to_gameobject is freed after conversion */
-void KX_BlenderSceneConverter::UnregisterGameObject(KX_GameObject *gameobject)
-{
- Object *bobp = gameobject->GetBlenderObject();
- if (bobp) {
- CHashedPtr bptr(bobp);
- KX_GameObject **gobp = m_map_blender_to_gameobject[bptr];
- if (gobp && *gobp == gameobject) {
- // also maintain m_map_blender_to_gameobject if the gameobject
- // being removed is matching the blender object
- m_map_blender_to_gameobject.remove(bptr);
- }
- }
-}
-
-KX_GameObject *KX_BlenderSceneConverter::FindGameObject(Object *for_blenderobject)
-{
- KX_GameObject **obp = m_map_blender_to_gameobject[CHashedPtr(for_blenderobject)];
-
- return obp ? *obp : NULL;
-}
-
-void KX_BlenderSceneConverter::RegisterGameMesh(RAS_MeshObject *gamemesh, Mesh *for_blendermesh)
-{
- if (for_blendermesh) { /* dynamically loaded meshes we don't want to keep lookups for */
- m_map_mesh_to_gamemesh.insert(CHashedPtr(for_blendermesh),gamemesh);
- }
- m_meshobjects.push_back(pair<KX_Scene *, RAS_MeshObject *> (m_currentScene,gamemesh));
-}
-
-RAS_MeshObject *KX_BlenderSceneConverter::FindGameMesh(Mesh *for_blendermesh)
-{
- RAS_MeshObject **meshp = m_map_mesh_to_gamemesh[CHashedPtr(for_blendermesh)];
-
- if (meshp) {
- return *meshp;
- }
- else {
- return NULL;
- }
-}
-
-void KX_BlenderSceneConverter::RegisterPolyMaterial(RAS_IPolyMaterial *polymat)
-{
- // First make sure we don't register the material twice
- vector<pair<KX_Scene *, RAS_IPolyMaterial *> >::iterator it;
- for (it = m_polymaterials.begin(); it != m_polymaterials.end(); ++it)
- if (it->second == polymat)
- return;
- m_polymaterials.push_back(pair<KX_Scene *, RAS_IPolyMaterial *> (m_currentScene, polymat));
-}
-
-void KX_BlenderSceneConverter::CachePolyMaterial(KX_Scene *scene, Material *mat, RAS_IPolyMaterial *polymat)
-{
- if (m_use_mat_cache && mat)
- m_polymat_cache[scene][mat] = polymat;
-}
-
-RAS_IPolyMaterial *KX_BlenderSceneConverter::FindCachedPolyMaterial(KX_Scene *scene, Material *mat)
-{
- return (m_use_mat_cache) ? m_polymat_cache[scene][mat] : NULL;
-}
-
-void KX_BlenderSceneConverter::CacheBlenderMaterial(KX_Scene *scene, Material *mat, BL_Material *blmat)
-{
- if (m_use_mat_cache && mat)
- m_mat_cache[scene][mat] = blmat;
-}
-
-BL_Material *KX_BlenderSceneConverter::FindCachedBlenderMaterial(KX_Scene *scene, Material *mat)
-{
- return (m_use_mat_cache) ? m_mat_cache[scene][mat] : NULL;
-}
-
-void KX_BlenderSceneConverter::RegisterInterpolatorList(BL_InterpolatorList *actList, bAction *for_act)
-{
- m_map_blender_to_gameAdtList.insert(CHashedPtr(for_act), actList);
-}
-
-BL_InterpolatorList *KX_BlenderSceneConverter::FindInterpolatorList(bAction *for_act)
-{
- BL_InterpolatorList **listp = m_map_blender_to_gameAdtList[CHashedPtr(for_act)];
- return listp ? *listp : NULL;
-}
-
-void KX_BlenderSceneConverter::RegisterGameActuator(SCA_IActuator *act, bActuator *for_actuator)
-{
- m_map_blender_to_gameactuator.insert(CHashedPtr(for_actuator), act);
-}
-
-SCA_IActuator *KX_BlenderSceneConverter::FindGameActuator(bActuator *for_actuator)
-{
- SCA_IActuator **actp = m_map_blender_to_gameactuator[CHashedPtr(for_actuator)];
- return actp ? *actp : NULL;
-}
-
-void KX_BlenderSceneConverter::RegisterGameController(SCA_IController *cont, bController *for_controller)
-{
- m_map_blender_to_gamecontroller.insert(CHashedPtr(for_controller), cont);
-}
-
-SCA_IController *KX_BlenderSceneConverter::FindGameController(bController *for_controller)
-{
- SCA_IController **contp = m_map_blender_to_gamecontroller[CHashedPtr(for_controller)];
- return contp ? *contp : NULL;
-}
-
-void KX_BlenderSceneConverter::RegisterWorldInfo(KX_WorldInfo *worldinfo)
-{
- m_worldinfos.push_back(pair<KX_Scene *, KX_WorldInfo *> (m_currentScene, worldinfo));
-}
-
-void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
-{
- //TODO this entire function is deprecated, written for 2.4x
- //the functionality should be rewritten, currently it does nothing
-
- KX_SceneList *scenes = m_ketsjiEngine->CurrentScenes();
- int numScenes = scenes->size();
- int i;
- for (i = 0; i < numScenes; i++) {
- KX_Scene *scene = scenes->at(i);
- CListValue *parentList = scene->GetRootParentList();
- int numObjects = parentList->GetCount();
- int g;
- for (g = 0; g < numObjects; g++) {
- KX_GameObject *gameObj = (KX_GameObject *)parentList->GetValue(g);
- if (gameObj->IsRecordAnimation()) {
- Object *blenderObject = gameObj->GetBlenderObject();
- if (blenderObject) {
-#if 0
- //erase existing ipo's
- Ipo* ipo = blenderObject->ipo;//findIpoForName(blenderObject->id.name+2);
- if (ipo) { //clear the curve data
- if (clearIpo) {//rcruiz
- IpoCurve *icu1;
-
- int numCurves = 0;
- for ( icu1 = (IpoCurve*)ipo->curve.first; icu1; ) {
-
- IpoCurve* tmpicu = icu1;
-
- /*int i;
- BezTriple *bezt;
- for ( bezt = tmpicu->bezt, i = 0; i < tmpicu->totvert; i++, bezt++) {
- printf("(%f,%f,%f),(%f,%f,%f),(%f,%f,%f)\n",bezt->vec[0][0],bezt->vec[0][1],bezt->vec[0][2],bezt->vec[1][0],bezt->vec[1][1],bezt->vec[1][2],bezt->vec[2][0],bezt->vec[2][1],bezt->vec[2][2]);
- }*/
-
- icu1 = icu1->next;
- numCurves++;
-
- BLI_remlink( &( blenderObject->ipo->curve ), tmpicu );
- if ( tmpicu->bezt )
- MEM_freeN( tmpicu->bezt );
- MEM_freeN( tmpicu );
- localDel_ipoCurve( tmpicu );
- }
- }
- }
- else {
- ipo = NULL; // XXX add_ipo(blenderObject->id.name+2, ID_OB);
- blenderObject->ipo = ipo;
- }
-#endif
- }
- }
- }
- }
-}
-
-void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo()
-{
- //TODO the functionality should be rewritten
-}
-
-// this generates ipo curves for position, rotation, allowing to use game physics in animation
-void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
-{
- KX_SceneList *scenes = m_ketsjiEngine->CurrentScenes();
- int numScenes = scenes->size();
- int i;
- for (i = 0; i < numScenes; i++) {
- KX_Scene *scene = scenes->at(i);
- //PHY_IPhysicsEnvironment* physEnv = scene->GetPhysicsEnvironment();
- CListValue *parentList = scene->GetObjectList();
- int numObjects = parentList->GetCount();
- int g;
- for (g = 0; g < numObjects; g++) {
- KX_GameObject *gameObj = (KX_GameObject *)parentList->GetValue(g);
- Object *blenderObject = gameObj->GetBlenderObject();
- if (blenderObject && blenderObject->parent == NULL && gameObj->IsRecordAnimation()) {
- if (blenderObject->adt == NULL)
- BKE_animdata_add_id(&blenderObject->id);
-
- if (blenderObject->adt) {
- const MT_Point3 &position = gameObj->NodeGetWorldPosition();
- //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
- const MT_Matrix3x3 &orn = gameObj->NodeGetWorldOrientation();
-
- position.getValue(blenderObject->loc);
-
- float tmat[3][3];
- for (int r = 0; r < 3; r++)
- for (int c = 0; c < 3; c++)
- tmat[r][c] = (float)orn[c][r];
-
- mat3_to_compatible_eul(blenderObject->rot, blenderObject->rot, tmat);
-
- insert_keyframe(NULL, &blenderObject->id, NULL, NULL, "location", -1, (float)frameNumber, BEZT_KEYTYPE_JITTER, INSERTKEY_FAST);
- insert_keyframe(NULL, &blenderObject->id, NULL, NULL, "rotation_euler", -1, (float)frameNumber, BEZT_KEYTYPE_JITTER, INSERTKEY_FAST);
-
-#if 0
- const MT_Point3& position = gameObj->NodeGetWorldPosition();
- //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
- const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation();
-
- float eulerAngles[3];
- float eulerAnglesOld[3] = {0.0f, 0.0f, 0.0f};
- float tmat[3][3];
-
- // XXX animato
- Ipo* ipo = blenderObject->ipo;
-
- //create the curves, if not existing, set linear if new
-
- IpoCurve *icu_lx = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
- if (!icu_lx) {
- icu_lx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1);
- if (icu_lx) icu_lx->ipo = IPO_LIN;
- }
- IpoCurve *icu_ly = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
- if (!icu_ly) {
- icu_ly = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1);
- if (icu_ly) icu_ly->ipo = IPO_LIN;
- }
- IpoCurve *icu_lz = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
- if (!icu_lz) {
- icu_lz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1);
- if (icu_lz) icu_lz->ipo = IPO_LIN;
- }
- IpoCurve *icu_rx = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
- if (!icu_rx) {
- icu_rx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1);
- if (icu_rx) icu_rx->ipo = IPO_LIN;
- }
- IpoCurve *icu_ry = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
- if (!icu_ry) {
- icu_ry = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1);
- if (icu_ry) icu_ry->ipo = IPO_LIN;
- }
- IpoCurve *icu_rz = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
- if (!icu_rz) {
- icu_rz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);
- if (icu_rz) icu_rz->ipo = IPO_LIN;
- }
-
- if (icu_rx) eulerAnglesOld[0] = eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
- if (icu_ry) eulerAnglesOld[1] = eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
- if (icu_rz) eulerAnglesOld[2] = eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
-
- // orn.getValue((float *)tmat); // uses the wrong ordering, cant use this
- for (int r = 0; r < 3; r++)
- for (int c = 0; c < 3; c++)
- tmat[r][c] = orn[c][r];
-
- // mat3_to_eul( eulerAngles,tmat); // better to use Mat3ToCompatibleEul
- mat3_to_compatible_eul( eulerAngles, eulerAnglesOld,tmat);
-
- //eval_icu
- for (int x = 0; x < 3; x++)
- eulerAngles[x] *= (float) ((180 / 3.14159265f) / 10.0);
-
- //fill the curves with data
- if (icu_lx) insert_vert_icu(icu_lx, frameNumber, position.x(), 1);
- if (icu_ly) insert_vert_icu(icu_ly, frameNumber, position.y(), 1);
- if (icu_lz) insert_vert_icu(icu_lz, frameNumber, position.z(), 1);
- if (icu_rx) insert_vert_icu(icu_rx, frameNumber, eulerAngles[0], 1);
- if (icu_ry) insert_vert_icu(icu_ry, frameNumber, eulerAngles[1], 1);
- if (icu_rz) insert_vert_icu(icu_rz, frameNumber, eulerAngles[2], 1);
-
- // Handles are corrected at the end, testhandles_ipocurve isn't needed yet
-#endif
- }
- }
- }
- }
-}
-
-void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
-{
- KX_SceneList *scenes = m_ketsjiEngine->CurrentScenes();
- int numScenes = scenes->size();
- int i;
- for (i = 0; i < numScenes; i++) {
- KX_Scene *scene = scenes->at(i);
- //PHY_IPhysicsEnvironment* physEnv = scene->GetPhysicsEnvironment();
- CListValue *parentList = scene->GetRootParentList();
- int numObjects = parentList->GetCount();
- int g;
- for (g = 0; g < numObjects; g++) {
- KX_GameObject *gameObj = (KX_GameObject *)parentList->GetValue(g);
- if (gameObj->IsRecordAnimation()) {
- Object *blenderObject = gameObj->GetBlenderObject();
- if (blenderObject && blenderObject->adt) {
- bAction *act = verify_adt_action(&blenderObject->id, false);
- FCurve *fcu;
-
- if (!act) {
- continue;
- }
-
- /* for now, not much choice but to run this on all curves... */
- for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) {
- /* Note: calling `sort_time_fcurve()` here is not needed, since
- * all keys have been added in 'right' order. */
- calchandles_fcurve(fcu);
- }
-#if 0
- // XXX animato
- Ipo* ipo = blenderObject->ipo;
-
- //create the curves, if not existing
- //testhandles_ipocurve checks for NULL
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"LocX"));
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"LocY"));
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ"));
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotX"));
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotY"));
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ"));
-#endif
- }
- }
- }
- }
-}
-
-#ifdef WITH_PYTHON
-PyObject *KX_BlenderSceneConverter::GetPyNamespace()
-{
- return m_ketsjiEngine->GetPyNamespace();
-}
-#endif
-
-vector<Main *> &KX_BlenderSceneConverter::GetMainDynamic()
-{
- return m_DynamicMaggie;
-}
-
-Main *KX_BlenderSceneConverter::GetMainDynamicPath(const char *path)
-{
- for (vector<Main *>::iterator it = m_DynamicMaggie.begin(); !(it == m_DynamicMaggie.end()); it++)
- if (BLI_path_cmp((*it)->name, path) == 0)
- return *it;
-
- return NULL;
-}
-
-void KX_BlenderSceneConverter::MergeAsyncLoads()
-{
- vector<KX_Scene *> *merge_scenes;
-
- vector<KX_LibLoadStatus *>::iterator mit;
- vector<KX_Scene *>::iterator sit;
-
- BLI_mutex_lock(&m_threadinfo->m_mutex);
-
- for (mit = m_mergequeue.begin(); mit != m_mergequeue.end(); ++mit) {
- merge_scenes = (vector<KX_Scene *> *)(*mit)->GetData();
-
- for (sit=merge_scenes->begin(); sit!=merge_scenes->end(); ++sit) {
- (*mit)->GetMergeScene()->MergeScene(*sit);
- delete (*sit);
- }
-
- delete merge_scenes;
- (*mit)->SetData(NULL);
-
- (*mit)->Finish();
- }
-
- m_mergequeue.clear();
-
- BLI_mutex_unlock(&m_threadinfo->m_mutex);
-}
-
-void KX_BlenderSceneConverter::FinalizeAsyncLoads()
-{
- // Finish all loading libraries.
- if (m_threadinfo) {
- BLI_task_pool_work_and_wait(m_threadinfo->m_pool);
- }
- // Merge all libraries data in the current scene, to avoid memory leak of unmerged scenes.
- MergeAsyncLoads();
-}
-
-void KX_BlenderSceneConverter::AddScenesToMergeQueue(KX_LibLoadStatus *status)
-{
- BLI_mutex_lock(&m_threadinfo->m_mutex);
- m_mergequeue.push_back(status);
- BLI_mutex_unlock(&m_threadinfo->m_mutex);
-}
-
-static void async_convert(TaskPool *pool, void *ptr, int UNUSED(threadid))
-{
- KX_Scene *new_scene = NULL;
- KX_LibLoadStatus *status = (KX_LibLoadStatus *)ptr;
- vector<Scene *> *scenes = (vector<Scene *> *)status->GetData();
- vector<KX_Scene *> *merge_scenes = new vector<KX_Scene *>(); // Deleted in MergeAsyncLoads
-
- for (unsigned int i = 0; i < scenes->size(); ++i) {
- new_scene = status->GetEngine()->CreateScene((*scenes)[i], true);
-
- if (new_scene)
- merge_scenes->push_back(new_scene);
-
- status->AddProgress((1.0f / scenes->size()) * 0.9f); // We'll call conversion 90% and merging 10% for now
- }
-
- delete scenes;
- status->SetData(merge_scenes);
-
- status->GetConverter()->AddScenesToMergeQueue(status);
-}
-
-KX_LibLoadStatus *KX_BlenderSceneConverter::LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options)
-{
- BlendHandle *bpy_openlib = BLO_blendhandle_from_memory(data, length);
-
- // Error checking is done in LinkBlendFile
- return LinkBlendFile(bpy_openlib, path, group, scene_merge, err_str, options);
-}
-
-KX_LibLoadStatus *KX_BlenderSceneConverter::LinkBlendFilePath(const char *filepath, char *group, KX_Scene *scene_merge, char **err_str, short options)
-{
- BlendHandle *bpy_openlib = BLO_blendhandle_from_file(filepath, NULL);
-
- // Error checking is done in LinkBlendFile
- return LinkBlendFile(bpy_openlib, filepath, group, scene_merge, err_str, options);
-}
-
-static void load_datablocks(Main *main_tmp, BlendHandle *bpy_openlib, const char *path, int idcode)
-{
- LinkNode *names = NULL;
-
- int totnames_dummy;
- names = BLO_blendhandle_get_datablock_names(bpy_openlib, idcode, &totnames_dummy);
-
- int i = 0;
- LinkNode *n = names;
- while (n) {
- BLO_library_link_named_part(main_tmp, &bpy_openlib, idcode, (char *)n->link);
- n = (LinkNode *)n->next;
- i++;
- }
- BLI_linklist_free(names, free); /* free linklist *and* each node's data */
-}
-
-KX_LibLoadStatus *KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options)
-{
- Main *main_newlib; /* stored as a dynamic 'main' until we free it */
- const int idcode = BKE_idcode_from_name(group);
- ReportList reports;
- static char err_local[255];
-
-// TIMEIT_START(bge_link_blend_file);
-
- KX_LibLoadStatus *status;
-
- /* only scene and mesh supported right now */
- if (idcode != ID_SCE && idcode != ID_ME && idcode != ID_AC) {
- snprintf(err_local, sizeof(err_local), "invalid ID type given \"%s\"\n", group);
- *err_str = err_local;
- BLO_blendhandle_close(bpy_openlib);
- return NULL;
- }
-
- if (GetMainDynamicPath(path)) {
- snprintf(err_local, sizeof(err_local), "blend file already open \"%s\"\n", path);
- *err_str = err_local;
- BLO_blendhandle_close(bpy_openlib);
- return NULL;
- }
-
- if (bpy_openlib == NULL) {
- snprintf(err_local, sizeof(err_local), "could not open blendfile \"%s\"\n", path);
- *err_str = err_local;
- return NULL;
- }
-
- main_newlib = BKE_main_new();
- BKE_reports_init(&reports, RPT_STORE);
-
- short flag = 0; /* don't need any special options */
- /* created only for linking, then freed */
- Main *main_tmp = BLO_library_link_begin(main_newlib, &bpy_openlib, (char *)path);
-
- load_datablocks(main_tmp, bpy_openlib, path, idcode);
-
- if (idcode == ID_SCE && options & LIB_LOAD_LOAD_SCRIPTS) {
- load_datablocks(main_tmp, bpy_openlib, path, ID_TXT);
- }
-
- /* now do another round of linking for Scenes so all actions are properly loaded */
- if (idcode == ID_SCE && options & LIB_LOAD_LOAD_ACTIONS) {
- load_datablocks(main_tmp, bpy_openlib, path, ID_AC);
- }
-
- BLO_library_link_end(main_tmp, &bpy_openlib, flag, NULL, NULL);
-
- BLO_blendhandle_close(bpy_openlib);
-
- BKE_reports_clear(&reports);
- /* done linking */
-
- /* needed for lookups*/
- GetMainDynamic().push_back(main_newlib);
- BLI_strncpy(main_newlib->name, path, sizeof(main_newlib->name));
-
-
- status = new KX_LibLoadStatus(this, m_ketsjiEngine, scene_merge, path);
-
- if (idcode == ID_ME) {
- /* Convert all new meshes into BGE meshes */
- ID *mesh;
-
- for (mesh = (ID *)main_newlib->mesh.first; mesh; mesh = (ID *)mesh->next ) {
- if (options & LIB_LOAD_VERBOSE)
- printf("MeshName: %s\n", mesh->name + 2);
- RAS_MeshObject *meshobj = BL_ConvertMesh((Mesh *)mesh, NULL, scene_merge, this, false); // For now only use the libloading option for scenes, which need to handle materials/shaders
- scene_merge->GetLogicManager()->RegisterMeshName(meshobj->GetName(), meshobj);
- }
- }
- else if (idcode == ID_AC) {
- /* Convert all actions */
- ID *action;
-
- for (action= (ID *)main_newlib->action.first; action; action = (ID *)action->next) {
- if (options & LIB_LOAD_VERBOSE)
- printf("ActionName: %s\n", action->name + 2);
- scene_merge->GetLogicManager()->RegisterActionName(action->name + 2, action);
- }
- }
- else if (idcode == ID_SCE) {
- /* Merge all new linked in scene into the existing one */
- ID *scene;
- // scenes gets deleted by the thread when it's done using it (look in async_convert())
- vector<Scene *> *scenes = (options & LIB_LOAD_ASYNC) ? new vector<Scene *>() : NULL;
-
- for (scene = (ID *)main_newlib->scene.first; scene; scene = (ID *)scene->next ) {
- if (options & LIB_LOAD_VERBOSE)
- printf("SceneName: %s\n", scene->name + 2);
-
- if (options & LIB_LOAD_ASYNC) {
- scenes->push_back((Scene *)scene);
- }
- else {
- /* merge into the base scene */
- KX_Scene* other = m_ketsjiEngine->CreateScene((Scene *)scene, true);
- scene_merge->MergeScene(other);
-
- // RemoveScene(other); // Don't run this, it frees the entire scene converter data, just delete the scene
- delete other;
- }
- }
-
- if (options & LIB_LOAD_ASYNC) {
- status->SetData(scenes);
- BLI_task_pool_push(m_threadinfo->m_pool, async_convert, (void *)status, false, TASK_PRIORITY_LOW);
- }
-
-#ifdef WITH_PYTHON
- /* Handle any text datablocks */
- if (options & LIB_LOAD_LOAD_SCRIPTS)
- addImportMain(main_newlib);
-#endif
-
- /* Now handle all the actions */
- if (options & LIB_LOAD_LOAD_ACTIONS) {
- ID *action;
-
- for (action = (ID *)main_newlib->action.first; action; action = (ID *)action->next) {
- if (options & LIB_LOAD_VERBOSE)
- printf("ActionName: %s\n", action->name + 2);
- scene_merge->GetLogicManager()->RegisterActionName(action->name + 2, action);
- }
- }
- }
-
- if (!(options & LIB_LOAD_ASYNC))
- status->Finish();
-
-// TIMEIT_END(bge_link_blend_file);
-
- m_status_map[main_newlib->name] = status;
- return status;
-}
-
-/* Note m_map_*** are all ok and don't need to be freed
- * most are temp and NewRemoveObject frees m_map_gameobject_to_blender */
-bool KX_BlenderSceneConverter::FreeBlendFile(Main *maggie)
-{
- int maggie_index = -1;
- int i = 0;
-
- if (maggie == NULL)
- return false;
-
- // If the given library is currently in loading, we do nothing.
- if (m_status_map.count(maggie->name)) {
- BLI_mutex_lock(&m_threadinfo->m_mutex);
- const bool finished = m_status_map[maggie->name]->IsFinished();
- BLI_mutex_unlock(&m_threadinfo->m_mutex);
-
- if (!finished) {
- printf("Library (%s) is currently being loaded asynchronously, and cannot be freed until this process is done\n", maggie->name);
- return false;
- }
- }
-
- /* tag all false except the one we remove */
- for (vector<Main *>::iterator it = m_DynamicMaggie.begin(); !(it == m_DynamicMaggie.end()); it++) {
- Main *main = *it;
- if (main != maggie) {
- BKE_main_id_tag_all(main, LIB_TAG_DOIT, false);
- }
- else {
- maggie_index = i;
- }
- i++;
- }
-
- /* should never happen but just to be safe */
- if (maggie_index == -1)
- return false;
-
- m_DynamicMaggie.erase(m_DynamicMaggie.begin() + maggie_index);
- BKE_main_id_tag_all(maggie, LIB_TAG_DOIT, true);
-
- /* free all tagged objects */
- KX_SceneList *scenes = m_ketsjiEngine->CurrentScenes();
- int numScenes = scenes->size();
-
- for (int scene_idx = 0; scene_idx < numScenes; scene_idx++) {
- KX_Scene *scene = scenes->at(scene_idx);
- if (IS_TAGGED(scene->GetBlenderScene())) {
- m_ketsjiEngine->RemoveScene(scene->GetName());
- m_mat_cache.erase(scene);
- m_polymat_cache.erase(scene);
- scene_idx--;
- numScenes--;
- }
- else {
- /* in case the mesh might be refered to later */
- {
- CTR_Map<STR_HashedString, void *> &mapStringToMeshes = scene->GetLogicManager()->GetMeshMap();
-
- for (int i = 0; i < mapStringToMeshes.size(); i++) {
- RAS_MeshObject *meshobj = (RAS_MeshObject *) *mapStringToMeshes.at(i);
- if (meshobj && IS_TAGGED(meshobj->GetMesh())) {
- STR_HashedString mn = meshobj->GetName();
- mapStringToMeshes.remove(mn);
- m_map_mesh_to_gamemesh.remove(CHashedPtr(meshobj->GetMesh()));
- i--;
- }
- }
- }
-
- /* Now unregister actions */
- {
- CTR_Map<STR_HashedString, void *> &mapStringToActions = scene->GetLogicManager()->GetActionMap();
-
- for (int i = 0; i < mapStringToActions.size(); i++) {
- ID *action = (ID*) *mapStringToActions.at(i);
-
- if (IS_TAGGED(action)) {
- STR_HashedString an = action->name + 2;
- mapStringToActions.remove(an);
- m_map_blender_to_gameAdtList.remove(CHashedPtr(action));
- i--;
- }
- }
- }
-
- //scene->FreeTagged(); /* removed tagged objects and meshes*/
- CListValue *obj_lists[] = {scene->GetObjectList(), scene->GetInactiveList(), NULL};
-
- for (int ob_ls_idx = 0; obj_lists[ob_ls_idx]; ob_ls_idx++) {
- CListValue *obs = obj_lists[ob_ls_idx];
- RAS_MeshObject *mesh;
-
- for (int ob_idx = 0; ob_idx < obs->GetCount(); ob_idx++) {
- KX_GameObject *gameobj = (KX_GameObject*)obs->GetValue(ob_idx);
- if (IS_TAGGED(gameobj->GetBlenderObject())) {
- int size_before = obs->GetCount();
-
- /* Eventually calls RemoveNodeDestructObject
- * frees m_map_gameobject_to_blender from UnregisterGameObject */
- scene->RemoveObject(gameobj);
-
- if (size_before != obs->GetCount())
- ob_idx--;
- else {
- printf("ERROR COULD NOT REMOVE \"%s\"\n", gameobj->GetName().ReadPtr());
- }
- }
- else {
- gameobj->RemoveTaggedActions();
- /* free the mesh, we could be referecing a linked one! */
- int mesh_index = gameobj->GetMeshCount();
- while (mesh_index--) {
- mesh = gameobj->GetMesh(mesh_index);
- if (IS_TAGGED(mesh->GetMesh())) {
- gameobj->RemoveMeshes(); /* XXX - slack, should only remove meshes that are library items but mostly objects only have 1 mesh */
- break;
- }
- else {
- /* also free the mesh if it's using a tagged material */
- int mat_index = mesh->NumMaterials();
- while (mat_index--) {
- if (IS_TAGGED(mesh->GetMeshMaterial(mat_index)->m_bucket->GetPolyMaterial()->GetBlenderMaterial())) {
- gameobj->RemoveMeshes(); /* XXX - slack, same as above */
- break;
- }
- }
- }
- }
-
- /* make sure action actuators are not referencing tagged actions */
- for (unsigned int act_idx = 0; act_idx < gameobj->GetActuators().size(); act_idx++) {
- if (gameobj->GetActuators()[act_idx]->IsType(SCA_IActuator::KX_ACT_ACTION)) {
- BL_ActionActuator *act = (BL_ActionActuator *)gameobj->GetActuators()[act_idx];
- if (IS_TAGGED(act->GetAction()))
- act->SetAction(NULL);
- }
- }
- }
- }
- }
- }
- }
-
- int size;
-
- // delete the entities of this scene
- /* TODO - */
-#if 0
- vector<pair<KX_Scene*,KX_WorldInfo*> >::iterator worldit;
- size = m_worldinfos.size();
- for (i=0, worldit=m_worldinfos.begin(); i<size; ) {
- if ((*worldit).second) {
- delete (*worldit).second;
- *worldit = m_worldinfos.back();
- m_worldinfos.pop_back();
- size--;
- } else {
- i++;
- worldit++;
- }
- }
-#endif
-
-
- /* Worlds don't reference original blender data so we need to make a set from them */
- typedef std::set<KX_WorldInfo *> KX_WorldInfoSet;
- KX_WorldInfoSet worldset;
- for (int scene_idx = 0; scene_idx < numScenes; scene_idx++) {
- KX_Scene *scene = scenes->at(scene_idx);
- if (scene->GetWorldInfo())
- worldset.insert(scene->GetWorldInfo());
- }
-
- vector<pair<KX_Scene *, KX_WorldInfo *> >::iterator worldit;
- size = m_worldinfos.size();
- for (i = 0, worldit = m_worldinfos.begin(); i < size;) {
- if (worldit->second && (worldset.count(worldit->second)) == 0) {
- delete worldit->second;
- *worldit = m_worldinfos.back();
- m_worldinfos.pop_back();
- size--;
- }
- else {
- i++;
- worldit++;
- }
- }
- worldset.clear();
- /* done freeing the worlds */
-
- vector<pair<KX_Scene *, RAS_IPolyMaterial *> >::iterator polymit;
- size = m_polymaterials.size();
-
- for (i = 0, polymit = m_polymaterials.begin(); i < size; ) {
- RAS_IPolyMaterial *mat = polymit->second;
- Material *bmat = NULL;
-
- KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial *>(mat);
- bmat = bl_mat->GetBlenderMaterial();
-
- if (IS_TAGGED(bmat)) {
- /* only remove from bucket */
- polymit->first->GetBucketManager()->RemoveMaterial(mat);
- }
-
- i++;
- polymit++;
- }
-
- for (i = 0, polymit = m_polymaterials.begin(); i < size; ) {
- RAS_IPolyMaterial *mat = polymit->second;
- Material *bmat = NULL;
-
- KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(mat);
- bmat = bl_mat->GetBlenderMaterial();
-
- if (IS_TAGGED(bmat)) {
- // Remove the poly material coresponding to this Blender Material.
- m_polymat_cache[polymit->first].erase(bmat);
- delete polymit->second;
- *polymit = m_polymaterials.back();
- m_polymaterials.pop_back();
- size--;
- } else {
- i++;
- polymit++;
- }
- }
-
- vector<pair<KX_Scene *, BL_Material *> >::iterator matit;
- size = m_materials.size();
- for (i = 0, matit = m_materials.begin(); i < size; ) {
- BL_Material *mat = matit->second;
- if (IS_TAGGED(mat->material)) {
- // Remove the bl material coresponding to this Blender Material.
- m_mat_cache[matit->first].erase(mat->material);
- delete matit->second;
- *matit = m_materials.back();
- m_materials.pop_back();
- size--;
- }
- else {
- i++;
- matit++;
- }
- }
-
- vector<pair<KX_Scene *, RAS_MeshObject *> >::iterator meshit;
- RAS_BucketManager::BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator msit;
- RAS_BucketManager::BucketList buckets;
-
- size = m_meshobjects.size();
- for (i = 0, meshit = m_meshobjects.begin(); i < size;) {
- RAS_MeshObject *me = meshit->second;
- if (IS_TAGGED(me->GetMesh())) {
- // Before deleting the mesh object, make sure the rasterizer is
- // no longer referencing it.
- buckets = meshit->first->GetBucketManager()->GetSolidBuckets();
- for (bit = buckets.begin(); bit != buckets.end(); bit++) {
- msit = (*bit)->msBegin();
-
- while (msit != (*bit)->msEnd()) {
- if (msit->m_mesh == meshit->second)
- (*bit)->RemoveMesh(&(*msit++));
- else
- msit++;
- }
- }
-
- // And now the alpha buckets
- buckets = meshit->first->GetBucketManager()->GetAlphaBuckets();
- for (bit = buckets.begin(); bit != buckets.end(); bit++) {
- msit = (*bit)->msBegin();
-
- while (msit != (*bit)->msEnd()) {
- if (msit->m_mesh == meshit->second)
- (*bit)->RemoveMesh(&(*msit++));
- else
- msit++;
- }
- }
-
- // Now it should be safe to delete
- delete meshit->second;
- *meshit = m_meshobjects.back();
- m_meshobjects.pop_back();
- size--;
- }
- else {
- i++;
- meshit++;
- }
- }
-
-#ifdef WITH_PYTHON
- /* make sure this maggie is removed from the import list if it's there
- * (this operation is safe if it isn't in the list) */
- removeImportMain(maggie);
-#endif
-
- delete m_status_map[maggie->name];
- m_status_map.erase(maggie->name);
-
- BKE_main_free(maggie);
-
- return true;
-}
-
-bool KX_BlenderSceneConverter::FreeBlendFile(const char *path)
-{
- return FreeBlendFile(GetMainDynamicPath(path));
-}
-
-bool KX_BlenderSceneConverter::MergeScene(KX_Scene *to, KX_Scene *from)
-{
- {
- vector<pair<KX_Scene *, KX_WorldInfo *> >::iterator itp = m_worldinfos.begin();
- while (itp != m_worldinfos.end()) {
- if (itp->first == from)
- itp->first = to;
- itp++;
- }
- }
-
- {
- vector<pair<KX_Scene *, RAS_IPolyMaterial *> >::iterator itp = m_polymaterials.begin();
- while (itp != m_polymaterials.end()) {
- if (itp->first == from) {
- itp->first = to;
-
- /* also switch internal data */
- RAS_IPolyMaterial *mat = itp->second;
- mat->Replace_IScene(to);
- }
- itp++;
- }
- }
-
- {
- vector<pair<KX_Scene *, RAS_MeshObject *> >::iterator itp = m_meshobjects.begin();
- while (itp != m_meshobjects.end()) {
- if (itp->first == from)
- itp->first = to;
- itp++;
- }
- }
-
- {
- vector<pair<KX_Scene *, BL_Material *> >::iterator itp = m_materials.begin();
- while (itp != m_materials.end()) {
- if (itp->first == from)
- itp->first = to;
- itp++;
- }
- }
-
- MaterialCache::iterator matcacheit = m_mat_cache.find(from);
- if (matcacheit != m_mat_cache.end()) {
- // Merge cached BL_Material map.
- m_mat_cache[to].insert(matcacheit->second.begin(), matcacheit->second.end());
- m_mat_cache.erase(matcacheit);
- }
-
- PolyMaterialCache::iterator polymatcacheit = m_polymat_cache.find(from);
- if (polymatcacheit != m_polymat_cache.end()) {
- // Merge cached RAS_IPolyMaterial map.
- m_polymat_cache[to].insert(polymatcacheit->second.begin(), polymatcacheit->second.end());
- m_polymat_cache.erase(polymatcacheit);
- }
-
- return true;
-}
-
-/* This function merges a mesh from the current scene into another main
- * it does not convert */
-RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene *kx_scene, Main *maggie, const char *name)
-{
- /* Find a mesh in the current main */
- ID *me= static_cast<ID *>(BLI_findstring(&m_maggie->mesh, name, offsetof(ID, name) + 2));
- Main *from_maggie = m_maggie;
-
- if (me == NULL) {
- // The mesh wasn't in the current main, try any dynamic (i.e., LibLoaded) ones
- vector<Main *>::iterator it;
-
- for (it = GetMainDynamic().begin(); it != GetMainDynamic().end(); it++) {
- me = static_cast<ID *>(BLI_findstring(&(*it)->mesh, name, offsetof(ID, name) + 2));
- from_maggie = *it;
-
- if (me)
- break;
- }
- }
-
- if (me == NULL) {
- printf("Could not be found \"%s\"\n", name);
- return NULL;
- }
-
- /* Watch this!, if its used in the original scene can cause big troubles */
- if (me->us > 0) {
-#ifdef DEBUG
- printf("Mesh has a user \"%s\"\n", name);
-#endif
- me = (ID*)BKE_mesh_copy(from_maggie, (Mesh*)me);
- id_us_min(me);
- }
- BLI_remlink(&from_maggie->mesh, me); /* even if we made the copy it needs to be removed */
- BLI_addtail(&maggie->mesh, me);
-
- /* Must copy the materials this uses else we cant free them */
- {
- Mesh *mesh = (Mesh *)me;
-
- /* ensure all materials are tagged */
- for (int i = 0; i < mesh->totcol; i++) {
- if (mesh->mat[i])
- mesh->mat[i]->id.tag &= ~LIB_TAG_DOIT;
- }
-
- for (int i = 0; i < mesh->totcol; i++) {
- Material *mat_old = mesh->mat[i];
-
- /* if its tagged its a replaced material */
- if (mat_old && (mat_old->id.tag & LIB_TAG_DOIT) == 0) {
- Material *mat_old = mesh->mat[i];
- Material *mat_new = BKE_material_copy(from_maggie, mat_old);
-
- mat_new->id.tag |= LIB_TAG_DOIT;
- id_us_min(&mat_old->id);
-
- BLI_remlink(&from_maggie->mat, mat_new); // BKE_material_copy uses G.main, and there is no BKE_material_copy_ex
- BLI_addtail(&maggie->mat, mat_new);
-
- mesh->mat[i] = mat_new;
-
- /* the same material may be used twice */
- for (int j = i + 1; j < mesh->totcol; j++) {
- if (mesh->mat[j] == mat_old) {
- mesh->mat[j] = mat_new;
- id_us_plus(&mat_new->id);
- id_us_min(&mat_old->id);
- }
- }
- }
- }
- }
-
- m_currentScene = kx_scene; // This needs to be set in case we LibLoaded earlier
- RAS_MeshObject *meshobj = BL_ConvertMesh((Mesh *)me, NULL, kx_scene, this, false);
- kx_scene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
- m_map_mesh_to_gamemesh.clear(); /* This is at runtime so no need to keep this, BL_ConvertMesh adds */
- return meshobj;
-}
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h
deleted file mode 100644
index 40c71a4d74b..00000000000
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.h
+++ /dev/null
@@ -1,232 +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_BlenderSceneConverter.h
- * \ingroup bgeconv
- */
-
-#ifndef __KX_BLENDERSCENECONVERTER_H__
-#define __KX_BLENDERSCENECONVERTER_H__
-
-#include "EXP_HashedPtr.h"
-#include "CTR_Map.h"
-#include <stdio.h>
-
-#include "KX_ISceneConverter.h"
-#include "KX_IpoConvert.h"
-
-#include <map>
-
-using namespace std;
-
-class KX_WorldInfo;
-class SCA_IActuator;
-class SCA_IController;
-class RAS_MeshObject;
-class RAS_IPolyMaterial;
-class BL_InterpolatorList;
-class BL_Material;
-struct Main;
-struct Scene;
-struct ThreadInfo;
-struct Material;
-
-typedef map<KX_Scene*, map<Material*, BL_Material*> > MaterialCache;
-typedef map<KX_Scene*, map<Material*, RAS_IPolyMaterial*> > PolyMaterialCache;
-
-class KX_BlenderSceneConverter : public KX_ISceneConverter
-{
- // Use vector of pairs to allow removal of entities between scene switch
- vector<pair<KX_Scene*,KX_WorldInfo*> > m_worldinfos;
- vector<pair<KX_Scene*,RAS_IPolyMaterial*> > m_polymaterials;
- vector<pair<KX_Scene*,RAS_MeshObject*> > m_meshobjects;
- vector<pair<KX_Scene*,BL_Material *> > m_materials;
-
- vector<class KX_LibLoadStatus*> m_mergequeue;
- ThreadInfo *m_threadinfo;
-
- // Cached material conversions
- MaterialCache m_mat_cache;
- PolyMaterialCache m_polymat_cache;
-
- // Saved KX_LibLoadStatus objects
- map<char *, class KX_LibLoadStatus*> m_status_map;
-
- // Should also have a list of collision shapes.
- // For the time being this is held in KX_Scene::m_shapes
-
- CTR_Map<CHashedPtr,KX_GameObject*> m_map_blender_to_gameobject; /* cleared after conversion */
- CTR_Map<CHashedPtr,RAS_MeshObject*> m_map_mesh_to_gamemesh; /* cleared after conversion */
- CTR_Map<CHashedPtr,SCA_IActuator*> m_map_blender_to_gameactuator; /* cleared after conversion */
- CTR_Map<CHashedPtr,SCA_IController*>m_map_blender_to_gamecontroller; /* cleared after conversion */
-
- CTR_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameAdtList;
-
- Main* m_maggie;
- vector<struct Main*> m_DynamicMaggie;
-
- STR_String m_newfilename;
- class KX_KetsjiEngine* m_ketsjiEngine;
- class KX_Scene* m_currentScene; // Scene being converted
- bool m_alwaysUseExpandFraming;
- bool m_usemat;
- bool m_useglslmat;
- bool m_use_mat_cache;
-
-public:
- KX_BlenderSceneConverter(
- Main* maggie,
- class KX_KetsjiEngine* engine
- );
-
- virtual ~KX_BlenderSceneConverter();
-
- /* Scenename: name of the scene to be converted.
- * destinationscene: pass an empty scene, everything goes into this
- * dictobj: python dictionary (for pythoncontrollers)
- */
- virtual void ConvertScene(
- class KX_Scene* destinationscene,
- class RAS_IRasterizer* rendertools,
- class RAS_ICanvas* canvas,
- bool libloading=false
- );
- virtual void RemoveScene(class KX_Scene *scene);
-
- void SetNewFileName(const STR_String& filename);
- bool TryAndLoadNewFile();
-
- void SetAlwaysUseExpandFraming(bool to_what);
-
- void RegisterGameObject(KX_GameObject *gameobject, struct Object *for_blenderobject);
- void UnregisterGameObject(KX_GameObject *gameobject);
- KX_GameObject *FindGameObject(struct Object *for_blenderobject);
-
- void RegisterGameMesh(RAS_MeshObject *gamemesh, struct Mesh *for_blendermesh);
- RAS_MeshObject *FindGameMesh(struct Mesh *for_blendermesh/*, unsigned int onlayer*/);
-
- void RegisterPolyMaterial(RAS_IPolyMaterial *polymat);
- void CachePolyMaterial(KX_Scene *scene, Material *mat, RAS_IPolyMaterial *polymat);
- RAS_IPolyMaterial *FindCachedPolyMaterial(KX_Scene *scene, Material *mat);
-
- void RegisterBlenderMaterial(BL_Material *mat);
- void CacheBlenderMaterial(KX_Scene *scene, Material *mat, BL_Material *blmat);
- BL_Material *FindCachedBlenderMaterial(KX_Scene *scene, Material *mat);
-
- void RegisterInterpolatorList(BL_InterpolatorList *actList, struct bAction *for_act);
- BL_InterpolatorList *FindInterpolatorList(struct bAction *for_act);
-
- void RegisterGameActuator(SCA_IActuator *act, struct bActuator *for_actuator);
- SCA_IActuator *FindGameActuator(struct bActuator *for_actuator);
-
- void RegisterGameController(SCA_IController *cont, struct bController *for_controller);
- SCA_IController *FindGameController(struct bController *for_controller);
-
- void RegisterWorldInfo(KX_WorldInfo *worldinfo);
-
- virtual void ResetPhysicsObjectsAnimationIpo(bool clearIpo);
-
- ///this is for reseting the position,rotation and scale of the gameobjet that is not dynamic
- virtual void resetNoneDynamicObjectToIpo();
-
- ///this generates ipo curves for position, rotation, allowing to use game physics in animation
- virtual void WritePhysicsObjectToAnimationIpo(int frameNumber);
- virtual void TestHandlesPhysicsObjectToAnimationIpo();
-
- // use blender materials
- virtual void SetMaterials(bool val);
- virtual bool GetMaterials();
-
- // use blender glsl materials
- virtual void SetGLSLMaterials(bool val);
- virtual bool GetGLSLMaterials();
-
- // cache materials during conversion
- virtual void SetCacheMaterials(bool val);
- virtual bool GetCacheMaterials();
-
- struct Scene* GetBlenderSceneForName(const STR_String& name);
-
-// struct Main* GetMain() { return m_maggie; }
- struct Main* GetMainDynamicPath(const char *path);
- vector<struct Main*> &GetMainDynamic();
-
- class KX_LibLoadStatus *LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
- class KX_LibLoadStatus *LinkBlendFilePath(const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
- class KX_LibLoadStatus *LinkBlendFile(struct BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
- bool MergeScene(KX_Scene *to, KX_Scene *from);
- RAS_MeshObject *ConvertMeshSpecial(KX_Scene* kx_scene, Main *maggie, const char *name);
- bool FreeBlendFile(struct Main *maggie);
- bool FreeBlendFile(const char *path);
-
- virtual void MergeAsyncLoads();
- virtual void FinalizeAsyncLoads();
- void AddScenesToMergeQueue(class KX_LibLoadStatus *status);
-
- void PrintStats() {
- printf("BGE STATS!\n");
-
- printf("\nAssets...\n");
- printf("\t m_worldinfos: %d\n", (int)m_worldinfos.size());
- printf("\t m_polymaterials: %d\n", (int)m_polymaterials.size());
- printf("\t m_meshobjects: %d\n", (int)m_meshobjects.size());
- printf("\t m_materials: %d\n", (int)m_materials.size());
-
- printf("\nMappings...\n");
- printf("\t m_map_blender_to_gameobject: %d\n", m_map_blender_to_gameobject.size());
- printf("\t m_map_mesh_to_gamemesh: %d\n", m_map_mesh_to_gamemesh.size());
- printf("\t m_map_blender_to_gameactuator: %d\n", m_map_blender_to_gameactuator.size());
- printf("\t m_map_blender_to_gamecontroller: %d\n", m_map_blender_to_gamecontroller.size());
- printf("\t m_map_blender_to_gameAdtList: %d\n", m_map_blender_to_gameAdtList.size());
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_printmemlist_pydict();
-#endif
-// /printf("\t m_ketsjiEngine->m_scenes: %d\n", m_ketsjiEngine->CurrentScenes()->size());
- }
-
- /* LibLoad Options */
- enum
- {
- LIB_LOAD_LOAD_ACTIONS = 1,
- LIB_LOAD_VERBOSE = 2,
- LIB_LOAD_LOAD_SCRIPTS = 4,
- LIB_LOAD_ASYNC = 8,
- };
-
-
-
-#ifdef WITH_PYTHON
- PyObject *GetPyNamespace();
-#endif
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderSceneConverter")
-#endif
-};
-
-#endif /* __KX_BLENDERSCENECONVERTER_H__ */
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
deleted file mode 100644
index d78ea4eed54..00000000000
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ /dev/null
@@ -1,1146 +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 *****
- * Convert Blender actuators for use in the GameEngine
- */
-
-/** \file gameengine/Converter/KX_ConvertActuators.cpp
- * \ingroup bgeconv
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "KX_BlenderSceneConverter.h"
-#include "KX_ConvertActuators.h"
-
-#ifdef WITH_AUDASPACE
-# include <AUD_Sound.h>
-#endif
-
-// Actuators
-//SCA logiclibrary native logicbricks
-#include "SCA_PropertyActuator.h"
-#include "SCA_LogicManager.h"
-#include "SCA_RandomActuator.h"
-#include "SCA_2DFilterActuator.h"
-
-// Ketsji specific logicbricks
-#include "KX_SceneActuator.h"
-#include "KX_SoundActuator.h"
-#include "KX_ObjectActuator.h"
-#include "KX_TrackToActuator.h"
-#include "KX_ConstraintActuator.h"
-#include "KX_CameraActuator.h"
-#include "KX_GameActuator.h"
-#include "KX_StateActuator.h"
-#include "KX_VisibilityActuator.h"
-#include "KX_SCA_AddObjectActuator.h"
-#include "KX_SCA_EndObjectActuator.h"
-#include "KX_SCA_ReplaceMeshActuator.h"
-#include "KX_ParentActuator.h"
-#include "KX_SCA_DynamicActuator.h"
-#include "KX_SteeringActuator.h"
-#include "KX_MouseActuator.h"
-
-#include "KX_Scene.h"
-#include "KX_KetsjiEngine.h"
-
-#include "EXP_IntValue.h"
-#include "KX_GameObject.h"
-
-/* This little block needed for linking to Blender... */
-#include "BKE_text.h"
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_path_util.h"
-
-#include "KX_NetworkMessageActuator.h"
-
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#endif
-
-#include "DNA_object_types.h"
-#include "DNA_sound_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_packedFile_types.h"
-#include "BL_ActionActuator.h"
-#include "BL_ShapeActionActuator.h"
-#include "BL_ArmatureActuator.h"
-#include "RNA_access.h"
-#include "BL_Action.h"
-/* end of blender include block */
-
-#include "BL_BlenderDataConversion.h"
-
-/**
- * KX_flt_trunc needed to round 'almost' zero values to zero, else velocities etc. are incorrectly set
- */
-
-BLI_INLINE float KX_flt_trunc(const float x)
-{
- return ( x < 0.0001f && x > -0.0001f ) ? 0.0f : x;
-}
-
-void BL_ConvertActuators(const char* maggiename,
- struct Object* blenderobject,
- KX_GameObject* gameobj,
- SCA_LogicManager* logicmgr,
- KX_Scene* scene,
- KX_KetsjiEngine* ketsjiEngine,
- int activeLayerBitInfo,
- bool isInActiveLayer,
- KX_BlenderSceneConverter* converter
- )
-{
-
- int uniqueint = 0;
- int actcount = 0;
- int executePriority = 0;
- bActuator* bact = (bActuator*) blenderobject->actuators.first;
- while (bact)
- {
- actcount++;
- bact = bact->next;
- }
- gameobj->ReserveActuator(actcount);
- bact = (bActuator*) blenderobject->actuators.first;
- while (bact)
- {
- STR_String uniquename = bact->name;
- STR_String& objectname = gameobj->GetName();
-
- SCA_IActuator* baseact = NULL;
- switch (bact->type)
- {
- case ACT_OBJECT:
- {
- bObjectActuator* obact = (bObjectActuator*) bact->data;
- KX_GameObject* obref = NULL;
- MT_Vector3 forcevec(KX_flt_trunc(obact->forceloc[0]),
- KX_flt_trunc(obact->forceloc[1]),
- KX_flt_trunc(obact->forceloc[2]));
- MT_Vector3 torquevec(obact->forcerot[0],
- obact->forcerot[1],
- obact->forcerot[2]);
- MT_Vector3 dlocvec(KX_flt_trunc(obact->dloc[0]),
- KX_flt_trunc(obact->dloc[1]),
- KX_flt_trunc(obact->dloc[2]));
- MT_Vector3 drotvec(KX_flt_trunc(obact->drot[0]),
- obact->drot[1],obact->drot[2]);
- MT_Vector3 linvelvec(KX_flt_trunc(obact->linearvelocity[0]),
- KX_flt_trunc(obact->linearvelocity[1]),
- KX_flt_trunc(obact->linearvelocity[2]));
- MT_Vector3 angvelvec(KX_flt_trunc(obact->angularvelocity[0]),
- KX_flt_trunc(obact->angularvelocity[1]),
- KX_flt_trunc(obact->angularvelocity[2]));
- short damping = obact->damping;
-
- /* Blender uses a bit vector internally for the local-flags. In */
- /* KX, we have four bools. The compiler should be smart enough */
- /* to do the right thing. We need to explicitly convert here! */
-
- KX_LocalFlags bitLocalFlag;
-
- bitLocalFlag.Force = bool((obact->flag & ACT_FORCE_LOCAL)!=0);
- bitLocalFlag.Torque = bool((obact->flag & ACT_TORQUE_LOCAL) !=0);//rlocal;
- bitLocalFlag.DLoc = bool((obact->flag & ACT_DLOC_LOCAL)!=0);
- bitLocalFlag.DRot = bool((obact->flag & ACT_DROT_LOCAL)!=0);
- bitLocalFlag.LinearVelocity = bool((obact->flag & ACT_LIN_VEL_LOCAL)!=0);
- bitLocalFlag.AngularVelocity = bool((obact->flag & ACT_ANG_VEL_LOCAL)!=0);
- bitLocalFlag.ServoControl = bool(obact->type == ACT_OBJECT_SERVO);
- bitLocalFlag.CharacterMotion = bool(obact->type == ACT_OBJECT_CHARACTER);
- bitLocalFlag.CharacterJump = bool((obact->flag & ACT_CHAR_JUMP)!=0);
- bitLocalFlag.AddOrSetLinV = bool((obact->flag & ACT_ADD_LIN_VEL)!=0);
- bitLocalFlag.AddOrSetCharLoc = bool((obact->flag & ACT_ADD_CHAR_LOC)!=0);
- if (obact->reference && bitLocalFlag.ServoControl)
- {
- obref = converter->FindGameObject(obact->reference);
- }
-
- KX_ObjectActuator* tmpbaseact = new KX_ObjectActuator(
- gameobj,
- obref,
- forcevec.getValue(),
- torquevec.getValue(),
- dlocvec.getValue(),
- drotvec.getValue(),
- linvelvec.getValue(),
- angvelvec.getValue(),
- damping,
- bitLocalFlag);
- baseact = tmpbaseact;
- break;
- }
- case ACT_ACTION:
- {
- bActionActuator* actact = (bActionActuator*) bact->data;
- STR_String propname = actact->name;
- STR_String propframe = actact->frameProp;
-
- short ipo_flags = 0;
-
- // Convert flags
- if (actact->flag & ACT_IPOFORCE) ipo_flags |= BL_Action::ACT_IPOFLAG_FORCE;
- if (actact->flag & ACT_IPOLOCAL) ipo_flags |= BL_Action::ACT_IPOFLAG_LOCAL;
- if (actact->flag & ACT_IPOADD) ipo_flags |= BL_Action::ACT_IPOFLAG_ADD;
- if (actact->flag & ACT_IPOCHILD) ipo_flags |= BL_Action::ACT_IPOFLAG_CHILD;
-
- BL_ActionActuator* tmpbaseact = new BL_ActionActuator(
- gameobj,
- propname,
- propframe,
- actact->sta,
- actact->end,
- actact->act,
- actact->type, // + 1, because Blender starts to count at zero,
- actact->blend_mode,
- actact->blendin,
- actact->priority,
- actact->layer,
- actact->layer_weight,
- ipo_flags,
- actact->end_reset,
- actact->stridelength
- // Ketsji at 1, because zero is reserved for "NoDef"
- );
- baseact= tmpbaseact;
- break;
- }
- case ACT_SHAPEACTION:
- {
- if (blenderobject->type==OB_MESH) {
- bActionActuator* actact = (bActionActuator*) bact->data;
- STR_String propname = actact->name;
- STR_String propframe = actact->frameProp;
-
- BL_ShapeActionActuator* tmpbaseact = new BL_ShapeActionActuator(
- gameobj,
- propname,
- propframe,
- actact->sta,
- actact->end,
- actact->act,
- actact->type, // + 1, because Blender starts to count at zero,
- actact->blendin,
- actact->priority,
- actact->stridelength);
- // Ketsji at 1, because zero is reserved for "NoDef"
- baseact= tmpbaseact;
- break;
- }
- else
- printf ("Discarded shape action actuator from non-mesh object [%s]\n", blenderobject->id.name+2);
- }
- case ACT_LAMP:
- {
- break;
- }
- case ACT_CAMERA:
- {
- bCameraActuator *camact = (bCameraActuator *) bact->data;
- if (camact->ob) {
- KX_GameObject *tmpgob = converter->FindGameObject(camact->ob);
-
- /* visifac, fac and axis are not copied from the struct... */
- /* that's some internal state... */
- KX_CameraActuator *tmpcamact = new KX_CameraActuator(
- gameobj,
- tmpgob,
- camact->height,
- camact->min,
- camact->max,
- camact->axis,
- camact->damping);
- baseact = tmpcamact;
- }
- break;
- }
- case ACT_MESSAGE:
- {
- bMessageActuator *msgAct = (bMessageActuator *) bact->data;
-
- /* Get the name of the properties that objects must own that
- * we're sending to, if present
- */
- STR_String toPropName = msgAct->toPropName;
-
- /* Get the Message Subject to send.
- */
- STR_String subject = msgAct->subject;
-
- /* Get the bodyType
- */
- int bodyType = msgAct->bodyType;
-
- /* Get the body (text message or property name whose value
- * we'll be sending, might be empty
- */
- const STR_String body = msgAct->body;
-
- KX_NetworkMessageActuator *tmpmsgact = new KX_NetworkMessageActuator(
- gameobj, // actuator controlling object
- scene->GetNetworkScene(), // needed for replication
- toPropName,
- subject,
- bodyType,
- body);
- baseact = tmpmsgact;
- break;
- }
- case ACT_MATERIAL:
- {
- break;
- }
- case ACT_SOUND:
- {
- bSoundActuator* soundact = (bSoundActuator*) bact->data;
- /* get type, and possibly a start and end frame */
- KX_SoundActuator::KX_SOUNDACT_TYPE
- soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
-
- switch (soundact->type) {
- case ACT_SND_PLAY_STOP_SOUND:
- soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYSTOP;
- break;
- case ACT_SND_PLAY_END_SOUND:
- soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYEND;
- break;
- case ACT_SND_LOOP_STOP_SOUND:
- soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPSTOP;
- break;
- case ACT_SND_LOOP_END_SOUND:
- soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPEND;
- break;
- case ACT_SND_LOOP_BIDIRECTIONAL_SOUND:
- soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL;
- break;
- case ACT_SND_LOOP_BIDIRECTIONAL_STOP_SOUND:
- soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP;
- break;
-
- default:
- /* This is an error!!! */
- soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
- }
-
- if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF)
- {
- bSound* sound = soundact->sound;
- bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
- AUD_Sound* snd_sound = NULL;
- KX_3DSoundSettings settings;
- settings.cone_inner_angle = RAD2DEGF(soundact->sound3D.cone_inner_angle);
- settings.cone_outer_angle = RAD2DEGF(soundact->sound3D.cone_outer_angle);
- settings.cone_outer_gain = soundact->sound3D.cone_outer_gain;
- settings.max_distance = soundact->sound3D.max_distance;
- settings.max_gain = soundact->sound3D.max_gain;
- settings.min_gain = soundact->sound3D.min_gain;
- settings.reference_distance = soundact->sound3D.reference_distance;
- settings.rolloff_factor = soundact->sound3D.rolloff_factor;
-
- if (!sound)
- {
- std::cout << "WARNING: Sound actuator \"" << bact->name <<
- "\" from object \"" << blenderobject->id.name+2 <<
- "\" has no sound datablock." << std::endl;
- }
- else
- {
- snd_sound = sound->playback_handle;
-
- // if sound shall be 3D but isn't mono, we have to make it mono!
- if (is3d)
- {
- snd_sound = AUD_Sound_rechannel(snd_sound, AUD_CHANNELS_MONO);
- }
- }
- KX_SoundActuator* tmpsoundact =
- new KX_SoundActuator(gameobj,
- snd_sound,
- soundact->volume,
- (float)(expf((soundact->pitch / 12.0f) * (float)M_LN2)),
- is3d,
- settings,
- soundActuatorType);
-
- // if we made it mono, we have to free it
- if (sound && snd_sound && snd_sound != sound->playback_handle) {
- AUD_Sound_free(snd_sound);
- }
-
- tmpsoundact->SetName(bact->name);
- baseact = tmpsoundact;
- }
- break;
- }
- case ACT_PROPERTY:
- {
- bPropertyActuator* propact = (bPropertyActuator*) bact->data;
- SCA_IObject* destinationObj = NULL;
-
- /*
- * here the destinationobject is searched. problem with multiple scenes: other scenes
- * have not been converted yet, so the destobj will not be found, so the prop will
- * not be copied.
- * possible solutions:
- * - convert everything when possible and not realtime only when needed.
- * - let the object-with-property report itself to the act when converted
- */
- if (propact->ob)
- destinationObj = converter->FindGameObject(propact->ob);
-
- SCA_PropertyActuator* tmppropact = new SCA_PropertyActuator(
- gameobj,
- destinationObj,
- propact->name,
- propact->value,
- propact->type + 1); // + 1 because Ketsji Logic starts
- // with 0 for KX_ACT_PROP_NODEF
- baseact = tmppropact;
- break;
- }
- case ACT_EDIT_OBJECT:
- {
- bEditObjectActuator *editobact
- = (bEditObjectActuator *) bact->data;
- /* There are four different kinds of 'edit object' thingies */
- /* The alternative to this lengthy conversion is packing */
- /* several actuators in one, which is not very nice design.. */
- switch (editobact->type) {
- case ACT_EDOB_ADD_OBJECT:
- {
-
- // does the 'original' for replication exists, and
- // is it in a non-active layer ?
- SCA_IObject* originalval = NULL;
- if (editobact->ob)
- {
- if (editobact->ob->lay & activeLayerBitInfo)
- {
- fprintf(stderr, "Warning, object \"%s\" from AddObject actuator \"%s\" is not in a hidden layer.\n", objectname.Ptr(), uniquename.Ptr());
- }
- else {
- originalval = converter->FindGameObject(editobact->ob);
- }
- }
-
- KX_SCA_AddObjectActuator* tmpaddact = new KX_SCA_AddObjectActuator(
- gameobj,
- originalval,
- editobact->time,
- scene,
- editobact->linVelocity,
- (editobact->localflag & ACT_EDOB_LOCAL_LINV) != 0,
- editobact->angVelocity,
- (editobact->localflag & ACT_EDOB_LOCAL_ANGV) != 0);
-
- //editobact->ob to gameobj
- baseact = tmpaddact;
- }
- break;
- case ACT_EDOB_END_OBJECT:
- {
- KX_SCA_EndObjectActuator* tmpendact
- = new KX_SCA_EndObjectActuator(gameobj,scene);
- baseact = tmpendact;
- }
- break;
- case ACT_EDOB_REPLACE_MESH:
- {
- RAS_MeshObject *tmpmesh = converter->FindGameMesh(editobact->me);
-
- if (!tmpmesh) {
- std::cout << "Warning: object \"" << objectname <<
- "\" from ReplaceMesh actuator \"" << uniquename <<
- "\" uses a mesh not owned by an object in scene \"" <<
- scene->GetName() << "\"." << std::endl;
- }
-
- KX_SCA_ReplaceMeshActuator* tmpreplaceact = new KX_SCA_ReplaceMeshActuator(
- gameobj,
- tmpmesh,
- scene,
- (editobact->flag & ACT_EDOB_REPLACE_MESH_NOGFX) == 0,
- (editobact->flag & ACT_EDOB_REPLACE_MESH_PHYS) != 0);
-
- baseact = tmpreplaceact;
- }
- break;
- case ACT_EDOB_TRACK_TO:
- {
- SCA_IObject* originalval = NULL;
- if (editobact->ob)
- originalval = converter->FindGameObject(editobact->ob);
-
- KX_TrackToActuator* tmptrackact = new KX_TrackToActuator(
- gameobj,
- originalval,
- editobact->time,
- editobact->flag,
- editobact->trackflag,
- editobact->upflag);
- baseact = tmptrackact;
- break;
- }
- case ACT_EDOB_DYNAMICS:
- {
- KX_SCA_DynamicActuator* tmpdynact = new KX_SCA_DynamicActuator(
- gameobj,
- editobact->dyn_operation,
- editobact->mass);
- baseact = tmpdynact;
- }
- }
- break;
- }
- case ACT_CONSTRAINT:
- {
- float min = 0.0, max = 0.0;
- char *prop = NULL;
- KX_ConstraintActuator::KX_CONSTRAINTTYPE locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF;
- bConstraintActuator *conact
- = (bConstraintActuator*) bact->data;
- /* convert settings... degrees in the ui become radians */
- /* internally */
- if (conact->type == ACT_CONST_TYPE_ORI) {
- min = conact->minloc[0];
- max = conact->maxloc[0];
- switch (conact->mode) {
- case ACT_CONST_DIRPX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX;
- break;
- case ACT_CONST_DIRPY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY;
- break;
- case ACT_CONST_DIRPZ:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ;
- break;
- }
- } else if (conact->type == ACT_CONST_TYPE_DIST) {
- switch (conact->mode) {
- case ACT_CONST_DIRPX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX;
- min = conact->minloc[0];
- max = conact->maxloc[0];
- break;
- case ACT_CONST_DIRPY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY;
- min = conact->minloc[1];
- max = conact->maxloc[1];
- break;
- case ACT_CONST_DIRPZ:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPZ;
- min = conact->minloc[2];
- max = conact->maxloc[2];
- break;
- case ACT_CONST_DIRNX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX;
- min = conact->minloc[0];
- max = conact->maxloc[0];
- break;
- case ACT_CONST_DIRNY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY;
- min = conact->minloc[1];
- max = conact->maxloc[1];
- break;
- case ACT_CONST_DIRNZ:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNZ;
- min = conact->minloc[2];
- max = conact->maxloc[2];
- break;
- }
- prop = conact->matprop;
- } else if (conact->type == ACT_CONST_TYPE_FH) {
- switch (conact->mode) {
- case ACT_CONST_DIRPX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPX;
- min = conact->minloc[0];
- max = conact->maxloc[0];
- break;
- case ACT_CONST_DIRPY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPY;
- min = conact->minloc[1];
- max = conact->maxloc[1];
- break;
- case ACT_CONST_DIRPZ:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPZ;
- min = conact->minloc[2];
- max = conact->maxloc[2];
- break;
- case ACT_CONST_DIRNX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNX;
- min = conact->minloc[0];
- max = conact->maxloc[0];
- break;
- case ACT_CONST_DIRNY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNY;
- min = conact->minloc[1];
- max = conact->maxloc[1];
- break;
- case ACT_CONST_DIRNZ:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNZ;
- min = conact->minloc[2];
- max = conact->maxloc[2];
- break;
- }
- prop = conact->matprop;
- } else {
- switch (conact->flag) {
- case ACT_CONST_LOCX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX;
- min = conact->minloc[0];
- max = conact->maxloc[0];
- break;
- case ACT_CONST_LOCY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY;
- min = conact->minloc[1];
- max = conact->maxloc[1];
- break;
- case ACT_CONST_LOCZ:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ;
- min = conact->minloc[2];
- max = conact->maxloc[2];
- break;
- case ACT_CONST_ROTX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX;
- min = conact->minrot[0] * (float)MT_RADS_PER_DEG;
- max = conact->maxrot[0] * (float)MT_RADS_PER_DEG;
- break;
- case ACT_CONST_ROTY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY;
- min = conact->minrot[1] * (float)MT_RADS_PER_DEG;
- max = conact->maxrot[1] * (float)MT_RADS_PER_DEG;
- break;
- case ACT_CONST_ROTZ:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ;
- min = conact->minrot[2] * (float)MT_RADS_PER_DEG;
- max = conact->maxrot[2] * (float)MT_RADS_PER_DEG;
- break;
- default:
- ; /* error */
- }
- }
- KX_ConstraintActuator *tmpconact = new KX_ConstraintActuator(
- gameobj,
- conact->damp,
- conact->rotdamp,
- min,
- max,
- conact->maxrot,
- locrot,
- conact->time,
- conact->flag,
- prop);
- baseact = tmpconact;
- break;
- }
- case ACT_GROUP:
- {
- // deprecated
- }
- break;
- case ACT_SCENE:
- {
- bSceneActuator *sceneact = (bSceneActuator *) bact->data;
- STR_String nextSceneName("");
-
- KX_SceneActuator* tmpsceneact;
- int mode = KX_SceneActuator::KX_SCENE_NODEF;
- KX_Camera *cam = NULL;
- //KX_Scene* scene = NULL;
- switch (sceneact->type)
- {
- case ACT_SCENE_RESUME:
- case ACT_SCENE_SUSPEND:
- case ACT_SCENE_ADD_FRONT:
- case ACT_SCENE_ADD_BACK:
- case ACT_SCENE_REMOVE:
- case ACT_SCENE_SET:
- {
- switch (sceneact->type)
- {
- case ACT_SCENE_RESUME:
- mode = KX_SceneActuator::KX_SCENE_RESUME;
- break;
- case ACT_SCENE_SUSPEND:
- mode = KX_SceneActuator::KX_SCENE_SUSPEND;
- break;
- case ACT_SCENE_ADD_FRONT:
- mode = KX_SceneActuator::KX_SCENE_ADD_FRONT_SCENE;
- break;
- case ACT_SCENE_ADD_BACK:
- mode = KX_SceneActuator::KX_SCENE_ADD_BACK_SCENE;
- break;
- case ACT_SCENE_REMOVE:
- mode = KX_SceneActuator::KX_SCENE_REMOVE_SCENE;
- break;
- case ACT_SCENE_SET:
- default:
- mode = KX_SceneActuator::KX_SCENE_SET_SCENE;
- break;
- };
-
- if (sceneact->scene) {
- nextSceneName = sceneact->scene->id.name + 2;
- }
-
- break;
- }
- case ACT_SCENE_CAMERA:
- mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
- if (sceneact->camera)
- {
- KX_GameObject *tmp = converter->FindGameObject(sceneact->camera);
- if (tmp && tmp->GetGameObjectType() == SCA_IObject::OBJ_CAMERA)
- cam = (KX_Camera*)tmp;
- }
- break;
- case ACT_SCENE_RESTART:
- {
-
- mode = KX_SceneActuator::KX_SCENE_RESTART;
- break;
- }
- default:
- ; /* flag error */
- }
- tmpsceneact = new KX_SceneActuator(
- gameobj,
- mode,
- scene,
- ketsjiEngine,
- nextSceneName,
- cam);
- baseact = tmpsceneact;
- break;
- }
- case ACT_GAME:
- {
- bGameActuator *gameact = (bGameActuator *) bact->data;
- KX_GameActuator* tmpgameact;
- STR_String filename = maggiename;
- STR_String loadinganimationname = "";
- int mode = KX_GameActuator::KX_GAME_NODEF;
- switch (gameact->type)
- {
- case ACT_GAME_LOAD:
- {
- mode = KX_GameActuator::KX_GAME_LOAD;
- filename = gameact->filename;
- loadinganimationname = gameact->loadaniname;
- break;
- }
- case ACT_GAME_START:
- {
- mode = KX_GameActuator::KX_GAME_START;
- filename = gameact->filename;
- loadinganimationname = gameact->loadaniname;
- break;
- }
- case ACT_GAME_RESTART:
- {
- mode = KX_GameActuator::KX_GAME_RESTART;
- break;
- }
- case ACT_GAME_QUIT:
- {
- mode = KX_GameActuator::KX_GAME_QUIT;
- break;
- }
- case ACT_GAME_SAVECFG:
- {
- mode = KX_GameActuator::KX_GAME_SAVECFG;
- break;
- }
- case ACT_GAME_LOADCFG:
- {
- mode = KX_GameActuator::KX_GAME_LOADCFG;
- break;
- }
- case ACT_GAME_SCREENSHOT:
- {
- mode = KX_GameActuator::KX_GAME_SCREENSHOT;
- filename = gameact->filename;
- break;
- }
- default:
- ; /* flag error */
- }
- tmpgameact = new KX_GameActuator(
- gameobj,
- mode,
- filename,
- loadinganimationname,
- scene,
- ketsjiEngine);
- baseact = tmpgameact;
-
- break;
- }
- case ACT_RANDOM:
- {
- bRandomActuator *randAct
- = (bRandomActuator *) bact->data;
-
- unsigned long seedArg = randAct->seed;
- if (seedArg == 0)
- {
- seedArg = (int)(ketsjiEngine->GetRealTime()*100000.0);
- seedArg ^= (intptr_t)randAct;
- }
- SCA_RandomActuator::KX_RANDOMACT_MODE modeArg
- = SCA_RandomActuator::KX_RANDOMACT_NODEF;
- SCA_RandomActuator *tmprandomact;
- float paraArg1 = 0.0;
- float paraArg2 = 0.0;
-
- switch (randAct->distribution) {
- case ACT_RANDOM_BOOL_CONST:
- modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST;
- paraArg1 = (float) randAct->int_arg_1;
- break;
- case ACT_RANDOM_BOOL_UNIFORM:
- modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_UNIFORM;
- break;
- case ACT_RANDOM_BOOL_BERNOUILLI:
- paraArg1 = randAct->float_arg_1;
- modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_BERNOUILLI;
- break;
- case ACT_RANDOM_INT_CONST:
- modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_CONST;
- paraArg1 = (float) randAct->int_arg_1;
- break;
- case ACT_RANDOM_INT_UNIFORM:
- paraArg1 = (float) randAct->int_arg_1;
- paraArg2 = (float) randAct->int_arg_2;
- modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_UNIFORM;
- break;
- case ACT_RANDOM_INT_POISSON:
- paraArg1 = randAct->float_arg_1;
- modeArg = SCA_RandomActuator::KX_RANDOMACT_INT_POISSON;
- break;
- case ACT_RANDOM_FLOAT_CONST:
- paraArg1 = randAct->float_arg_1;
- modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_CONST;
- break;
- case ACT_RANDOM_FLOAT_UNIFORM:
- paraArg1 = randAct->float_arg_1;
- paraArg2 = randAct->float_arg_2;
- modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_UNIFORM;
- break;
- case ACT_RANDOM_FLOAT_NORMAL:
- paraArg1 = randAct->float_arg_1;
- paraArg2 = randAct->float_arg_2;
- modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NORMAL;
- break;
- case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL:
- paraArg1 = randAct->float_arg_1;
- modeArg = SCA_RandomActuator::KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL;
- break;
- default:
- ; /* error */
- }
- tmprandomact = new SCA_RandomActuator(
- gameobj,
- seedArg,
- modeArg,
- paraArg1,
- paraArg2,
- randAct->propname);
- baseact = tmprandomact;
- }
- break;
-
- case ACT_VISIBILITY:
- {
- bVisibilityActuator *vis_act = (bVisibilityActuator *) bact->data;
- KX_VisibilityActuator * tmp_vis_act = NULL;
- bool v = ((vis_act->flag & ACT_VISIBILITY_INVISIBLE) != 0);
- bool o = ((vis_act->flag & ACT_VISIBILITY_OCCLUSION) != 0);
- bool recursive = ((vis_act->flag & ACT_VISIBILITY_RECURSIVE) != 0);
-
- tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, o, recursive);
-
- baseact = tmp_vis_act;
- }
- break;
-
- case ACT_STATE:
- {
- bStateActuator *sta_act = (bStateActuator *) bact->data;
- KX_StateActuator * tmp_sta_act = NULL;
-
- tmp_sta_act =
- new KX_StateActuator(gameobj, sta_act->type, sta_act->mask);
-
- baseact = tmp_sta_act;
- }
- break;
-
- case ACT_2DFILTER:
- {
- bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data;
- SCA_2DFilterActuator *tmp = NULL;
-
- RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode;
- switch (_2dfilter->type) {
- case ACT_2DFILTER_MOTIONBLUR:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR;
- break;
- case ACT_2DFILTER_BLUR:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_BLUR;
- break;
- case ACT_2DFILTER_SHARPEN:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_SHARPEN;
- break;
- case ACT_2DFILTER_DILATION:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_DILATION;
- break;
- case ACT_2DFILTER_EROSION:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_EROSION;
- break;
- case ACT_2DFILTER_LAPLACIAN:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN;
- break;
- case ACT_2DFILTER_SOBEL:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_SOBEL;
- break;
- case ACT_2DFILTER_PREWITT:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_PREWITT;
- break;
- case ACT_2DFILTER_GRAYSCALE:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE;
- break;
- case ACT_2DFILTER_SEPIA:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_SEPIA;
- break;
- case ACT_2DFILTER_INVERT:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT;
- break;
- case ACT_2DFILTER_CUSTOMFILTER:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER;
- break;
- case ACT_2DFILTER_NOFILTER:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
- break;
- case ACT_2DFILTER_DISABLED:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_DISABLED;
- break;
- case ACT_2DFILTER_ENABLED:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED;
- break;
- default:
- filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
- break;
- }
-
- tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag,
- _2dfilter->float_arg, _2dfilter->int_arg,
- ketsjiEngine->GetRasterizer(), scene);
-
- if (_2dfilter->text)
- {
- char *buf;
- // this is some blender specific code
- buf = txt_to_buf(_2dfilter->text);
- if (buf)
- {
- tmp->SetShaderText(buf);
- MEM_freeN(buf);
- }
- }
-
- baseact = tmp;
-
- }
- break;
- case ACT_PARENT:
- {
- bParentActuator *parAct = (bParentActuator *) bact->data;
- int mode = KX_ParentActuator::KX_PARENT_NODEF;
- bool addToCompound = true;
- bool ghost = true;
- KX_GameObject *tmpgob = NULL;
-
- switch (parAct->type) {
- case ACT_PARENT_SET:
- mode = KX_ParentActuator::KX_PARENT_SET;
- tmpgob = converter->FindGameObject(parAct->ob);
- addToCompound = !(parAct->flag & ACT_PARENT_COMPOUND);
- ghost = !(parAct->flag & ACT_PARENT_GHOST);
- break;
- case ACT_PARENT_REMOVE:
- mode = KX_ParentActuator::KX_PARENT_REMOVE;
- tmpgob = NULL;
- break;
- }
-
- KX_ParentActuator *tmpparact
- = new KX_ParentActuator(gameobj,
- mode,
- addToCompound,
- ghost,
- tmpgob);
- baseact = tmpparact;
- break;
- }
-
- case ACT_ARMATURE:
- {
- bArmatureActuator* armAct = (bArmatureActuator*) bact->data;
- KX_GameObject *tmpgob = converter->FindGameObject(armAct->target);
- KX_GameObject *subgob = converter->FindGameObject(armAct->subtarget);
- BL_ArmatureActuator* tmparmact = new BL_ArmatureActuator(
- gameobj,
- armAct->type,
- armAct->posechannel,
- armAct->constraint,
- tmpgob,
- subgob,
- armAct->weight,
- armAct->influence);
- baseact = tmparmact;
- break;
- }
- case ACT_STEERING:
- {
- bSteeringActuator *stAct = (bSteeringActuator *) bact->data;
- KX_GameObject *navmeshob = NULL;
- if (stAct->navmesh)
- {
- PointerRNA settings_ptr;
- RNA_pointer_create((ID *)stAct->navmesh, &RNA_GameObjectSettings, stAct->navmesh, &settings_ptr);
- if (RNA_enum_get(&settings_ptr, "physics_type") == OB_BODY_TYPE_NAVMESH)
- navmeshob = converter->FindGameObject(stAct->navmesh);
- }
- KX_GameObject *targetob = converter->FindGameObject(stAct->target);
-
- int mode = KX_SteeringActuator::KX_STEERING_NODEF;
- switch (stAct->type) {
- case ACT_STEERING_SEEK:
- mode = KX_SteeringActuator::KX_STEERING_SEEK;
- break;
- case ACT_STEERING_FLEE:
- mode = KX_SteeringActuator::KX_STEERING_FLEE;
- break;
- case ACT_STEERING_PATHFOLLOWING:
- mode = KX_SteeringActuator::KX_STEERING_PATHFOLLOWING;
- break;
- }
-
- bool selfTerminated = (stAct->flag & ACT_STEERING_SELFTERMINATED) !=0;
- bool enableVisualization = (stAct->flag & ACT_STEERING_ENABLEVISUALIZATION) !=0;
- short facingMode = (stAct->flag & ACT_STEERING_AUTOMATICFACING) ? stAct->facingaxis : 0;
- bool normalup = (stAct->flag & ACT_STEERING_NORMALUP) !=0;
- bool lockzvel = (stAct->flag & ACT_STEERING_LOCKZVEL) !=0;
- KX_SteeringActuator *tmpstact
- = new KX_SteeringActuator(gameobj, mode, targetob, navmeshob,stAct->dist,
- stAct->velocity, stAct->acceleration, stAct->turnspeed,
- selfTerminated, stAct->updateTime,
- scene->GetObstacleSimulation(), facingMode, normalup, enableVisualization, lockzvel);
- baseact = tmpstact;
- break;
- }
- case ACT_MOUSE:
- {
- bMouseActuator* mouAct = (bMouseActuator*) bact->data;
- int mode = KX_MouseActuator::KX_ACT_MOUSE_NODEF;
-
- switch (mouAct->type) {
- case ACT_MOUSE_VISIBILITY:
- {
- mode = KX_MouseActuator::KX_ACT_MOUSE_VISIBILITY;
- break;
- }
- case ACT_MOUSE_LOOK:
- {
- mode = KX_MouseActuator::KX_ACT_MOUSE_LOOK;
- break;
- }
- }
-
- bool visible = (mouAct->flag & ACT_MOUSE_VISIBLE) != 0;
- bool use_axis[2] = {(mouAct->flag & ACT_MOUSE_USE_AXIS_X) != 0, (mouAct->flag & ACT_MOUSE_USE_AXIS_Y) != 0};
- bool reset[2] = {(mouAct->flag & ACT_MOUSE_RESET_X) != 0, (mouAct->flag & ACT_MOUSE_RESET_Y) != 0};
- bool local[2] = {(mouAct->flag & ACT_MOUSE_LOCAL_X) != 0, (mouAct->flag & ACT_MOUSE_LOCAL_Y) != 0};
-
- SCA_MouseManager* eventmgr = (SCA_MouseManager*) logicmgr->FindEventManager(SCA_EventManager::MOUSE_EVENTMGR);
- if (eventmgr) {
- KX_MouseActuator* tmpbaseact = new KX_MouseActuator(gameobj,
- ketsjiEngine,
- eventmgr,
- mode,
- visible,
- use_axis,
- mouAct->threshold,
- reset,
- mouAct->object_axis,
- local,
- mouAct->sensitivity,
- mouAct->limit_x,
- mouAct->limit_y);
- baseact = tmpbaseact;
- } else {
- //cout << "\n Couldn't find mouse event manager..."; - should throw an error here...
- }
- break;
- }
- default:
- ; /* generate some error */
- }
-
- if (baseact && !(bact->flag & ACT_DEACTIVATE))
- {
- baseact->SetExecutePriority(executePriority++);
- uniquename += "#ACT#";
- uniqueint++;
- CIntValue* uniqueval = new CIntValue(uniqueint);
- uniquename += uniqueval->GetText();
- uniqueval->Release();
- baseact->SetName(bact->name);
- baseact->SetLogicManager(logicmgr);
- //gameobj->SetProperty(uniquename,baseact);
- gameobj->AddActuator(baseact);
-
- converter->RegisterGameActuator(baseact, bact);
- // done with baseact, release it
- baseact->Release();
- }
- else if (baseact)
- baseact->Release();
-
- bact = bact->next;
- }
-}
-
-
diff --git a/source/gameengine/Converter/KX_ConvertActuators.h b/source/gameengine/Converter/KX_ConvertActuators.h
deleted file mode 100644
index 688b5db50ce..00000000000
--- a/source/gameengine/Converter/KX_ConvertActuators.h
+++ /dev/null
@@ -1,45 +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_ConvertActuators.h
- * \ingroup bgeconv
- */
-
-#ifndef __KX_CONVERTACTUATORS_H__
-#define __KX_CONVERTACTUATORS_H__
-
-void BL_ConvertActuators(const char* maggiename,
- struct Object* blenderobject,
- class KX_GameObject* gameobj,
- class SCA_LogicManager* logicmgr,
- class KX_Scene* scene,
- class KX_KetsjiEngine* ketsjiEngine,
- int activeLayerBitInfo,
- bool isInActiveLayer,
- class KX_BlenderSceneConverter* converter);
-
-#endif /* __KX_CONVERTACTUATORS_H__ */
diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp
deleted file mode 100644
index f55d81adb80..00000000000
--- a/source/gameengine/Converter/KX_ConvertControllers.cpp
+++ /dev/null
@@ -1,250 +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/Converter/KX_ConvertControllers.cpp
- * \ingroup bgeconv
- */
-
-
-#include "MEM_guardedalloc.h"
-
-#include "KX_BlenderSceneConverter.h"
-#include "KX_ConvertControllers.h"
-#include "EXP_Python.h"
-
-// Controller
-#include "SCA_ANDController.h"
-#include "SCA_ORController.h"
-#include "SCA_NANDController.h"
-#include "SCA_NORController.h"
-#include "SCA_XORController.h"
-#include "SCA_XNORController.h"
-#include "SCA_PythonController.h"
-#include "SCA_ExpressionController.h"
-
-#include "SCA_LogicManager.h"
-#include "KX_GameObject.h"
-#include "EXP_IntValue.h"
-
-/* This little block needed for linking to Blender... */
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#endif
-
-#include "DNA_object_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_text_types.h"
-
-#include "BKE_text.h"
-
-#include "BLI_blenlib.h"
-
-/* end of blender include block */
-
-
- static void
-LinkControllerToActuators(
- SCA_IController *game_controller,
- bController* bcontr,
- SCA_LogicManager* logicmgr,
- KX_BlenderSceneConverter* converter
-) {
- // Iterate through the actuators of the game blender
- // controller and find the corresponding ketsji actuator.
-
- game_controller->ReserveActuator(bcontr->totlinks);
- for (int i=0;i<bcontr->totlinks;i++)
- {
- bActuator* bact = (bActuator*) bcontr->links[i];
- SCA_IActuator *game_actuator = converter->FindGameActuator(bact);
- if (game_actuator) {
- logicmgr->RegisterToActuator(game_controller, game_actuator);
- }
- }
-}
-
-
-void BL_ConvertControllers(
- struct Object* blenderobject,
- class KX_GameObject* gameobj,
- SCA_LogicManager* logicmgr,
- int activeLayerBitInfo,
- bool isInActiveLayer,
- KX_BlenderSceneConverter* converter,
- bool libloading
-) {
- int uniqueint=0;
- int count = 0;
- int executePriority=0;
- bController* bcontr = (bController*)blenderobject->controllers.first;
- while (bcontr)
- {
- bcontr = bcontr->next;
- count++;
- }
- gameobj->ReserveController(count);
- bcontr = (bController*)blenderobject->controllers.first;
- while (bcontr)
- {
- SCA_IController* gamecontroller = NULL;
- switch (bcontr->type) {
- case CONT_LOGIC_AND:
- {
- gamecontroller = new SCA_ANDController(gameobj);
- break;
- }
- case CONT_LOGIC_OR:
- {
- gamecontroller = new SCA_ORController(gameobj);
- break;
- }
- case CONT_LOGIC_NAND:
- {
- gamecontroller = new SCA_NANDController(gameobj);
- break;
- }
- case CONT_LOGIC_NOR:
- {
- gamecontroller = new SCA_NORController(gameobj);
- break;
- }
- case CONT_LOGIC_XOR:
- {
- gamecontroller = new SCA_XORController(gameobj);
- break;
- }
- case CONT_LOGIC_XNOR:
- {
- gamecontroller = new SCA_XNORController(gameobj);
- break;
- }
- case CONT_EXPRESSION:
- {
- bExpressionCont* bexpcont = (bExpressionCont*) bcontr->data;
- STR_String expressiontext = STR_String(bexpcont->str);
- if (expressiontext.Length() > 0)
- {
- gamecontroller = new SCA_ExpressionController(gameobj,expressiontext);
- }
- break;
- }
- case CONT_PYTHON:
- {
- bPythonCont* pycont = (bPythonCont*) bcontr->data;
- SCA_PythonController* pyctrl = new SCA_PythonController(gameobj, pycont->mode);
- gamecontroller = pyctrl;
-#ifdef WITH_PYTHON
- // When libloading, this is delayed to KX_Scene::MergeScene_LogicBrick to avoid GIL issues
- if (!libloading)
- pyctrl->SetNamespace(converter->GetPyNamespace());
-
- if (pycont->mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) {
- if (pycont->text)
- {
- char *buf;
- // this is some blender specific code
- buf= txt_to_buf(pycont->text);
- if (buf)
- {
- pyctrl->SetScriptText(STR_String(buf));
- pyctrl->SetScriptName(pycont->text->id.name+2);
- MEM_freeN(buf);
- }
-
- }
- }
- else {
- /* let the controller print any warnings here when importing */
- pyctrl->SetScriptText(STR_String(pycont->module));
- pyctrl->SetScriptName(pycont->module); /* will be something like module.func so using it as the name is OK */
-
- if (pycont->flag & CONT_PY_DEBUG) {
- printf("\nDebuging \"%s\", module for object %s\n\texpect worse performance.\n", pycont->module, blenderobject->id.name+2);
- pyctrl->SetDebug(true);
- }
- }
-#endif // WITH_PYTHON
-
- break;
- }
- default:
- {
-
- }
- }
-
- if (gamecontroller && !(bcontr->flag & CONT_DEACTIVATE))
- {
- LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
- gamecontroller->SetExecutePriority(executePriority++);
- gamecontroller->SetBookmark((bcontr->flag & CONT_PRIO) != 0);
- gamecontroller->SetState(bcontr->state_mask);
- STR_String uniquename = bcontr->name;
- uniquename += "#CONTR#";
- uniqueint++;
- CIntValue* uniqueval = new CIntValue(uniqueint);
- uniquename += uniqueval->GetText();
- uniqueval->Release();
- //unique name was never implemented for sensors and actuators, only for controllers
- //and it's producing difference in the keys for the lists: obj.controllers/sensors/actuators
- //at some point it should either be implemented globally (and saved as a separate var) or removed.
- //gamecontroller->SetName(uniquename);
- gamecontroller->SetName(bcontr->name);
- gamecontroller->SetLogicManager(logicmgr);
- gameobj->AddController(gamecontroller);
-
- converter->RegisterGameController(gamecontroller, bcontr);
-
-#ifdef WITH_PYTHON
- // When libloading, this is delayed to KX_Scene::MergeScene_LogicBrick to avoid GIL issues
- if (!libloading && bcontr->type==CONT_PYTHON) {
- SCA_PythonController *pyctrl= static_cast<SCA_PythonController*>(gamecontroller);
- /* not strictly needed but gives syntax errors early on and
- * gives more predictable performance for larger scripts */
- if (pyctrl->m_mode==SCA_PythonController::SCA_PYEXEC_SCRIPT)
- pyctrl->Compile();
- else {
- /* We cant do this because importing runs the script which could end up accessing
- * internal BGE functions, this is unstable while we're converting the scene.
- * This is a pity because its useful to see errors at startup but cant help it */
-
- // pyctrl->Import();
- }
- }
-
-#endif // WITH_PYTHON
-
- //done with gamecontroller
- gamecontroller->Release();
- }
- else if (gamecontroller)
- gamecontroller->Release();
-
- bcontr = bcontr->next;
- }
-
-}
diff --git a/source/gameengine/Converter/KX_ConvertControllers.h b/source/gameengine/Converter/KX_ConvertControllers.h
deleted file mode 100644
index 2f93d70a6f9..00000000000
--- a/source/gameengine/Converter/KX_ConvertControllers.h
+++ /dev/null
@@ -1,47 +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_ConvertControllers.h
- * \ingroup bgeconv
- */
-
-#ifndef __KX_CONVERTCONTROLLERS_H__
-#define __KX_CONVERTCONTROLLERS_H__
-
-#include "EXP_Python.h"
-
-void BL_ConvertControllers(
- struct Object* blenderobject,
- class KX_GameObject* gameobj,
- class SCA_LogicManager* logicmgr,
- int activeLayerBitInfo,
- bool isInActiveLayer,
- class KX_BlenderSceneConverter* converter,
- bool libloading
-);
-
-#endif /* __KX_CONVERTCONTROLLERS_H__ */
diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp
deleted file mode 100644
index 2cb61207fb5..00000000000
--- a/source/gameengine/Converter/KX_ConvertProperties.cpp
+++ /dev/null
@@ -1,243 +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/Converter/KX_ConvertProperties.cpp
- * \ingroup bgeconv
- */
-
-
-#include "KX_ConvertProperties.h"
-
-
-#include "DNA_object_types.h"
-#include "DNA_property_types.h"
-/* end of blender include block */
-
-
-#include "EXP_Value.h"
-#include "EXP_VectorValue.h"
-#include "EXP_BoolValue.h"
-#include "EXP_StringValue.h"
-#include "EXP_FloatValue.h"
-#include "KX_GameObject.h"
-#include "EXP_IntValue.h"
-#include "SCA_TimeEventManager.h"
-#include "SCA_IScene.h"
-
-#include "KX_FontObject.h"
-#include "DNA_curve_types.h"
-
-/* This little block needed for linking to Blender... */
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#endif
-
-extern "C" {
- #include "BKE_property.h"
-}
-
-/* prototype */
-void BL_ConvertTextProperty(Object* object, KX_FontObject* fontobj,SCA_TimeEventManager* timemgr,SCA_IScene* scene, bool isInActiveLayer);
-
-void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventManager* timemgr,SCA_IScene* scene, bool isInActiveLayer)
-{
-
- bProperty* prop = (bProperty*)object->prop.first;
- CValue* propval;
- bool show_debug_info;
-
- while (prop) {
- propval = NULL;
- show_debug_info = bool (prop->flag & PROP_DEBUG);
-
- switch (prop->type) {
- case GPROP_BOOL:
- {
- propval = new CBoolValue((bool)(prop->data != 0));
- gameobj->SetProperty(prop->name,propval);
- //promp->poin= &prop->data;
- break;
- }
- case GPROP_INT:
- {
- propval = new CIntValue((int)prop->data);
- gameobj->SetProperty(prop->name,propval);
- break;
- }
- case GPROP_FLOAT:
- {
- //prop->poin= &prop->data;
- float floatprop = *((float*)&prop->data);
- propval = new CFloatValue(floatprop);
- gameobj->SetProperty(prop->name,propval);
- }
- break;
- case GPROP_STRING:
- {
- //prop->poin= callocN(MAX_PROPSTRING, "property string");
- propval = new CStringValue((char*)prop->poin,"");
- gameobj->SetProperty(prop->name,propval);
- break;
- }
- case GPROP_TIME:
- {
- float floatprop = *((float*)&prop->data);
-
- CValue* timeval = new CFloatValue(floatprop);
- // set a subproperty called 'timer' so that
- // we can register the replica of this property
- // at the time a game object is replicated (AddObjectActuator triggers this)
- CValue *bval = new CBoolValue(true);
- timeval->SetProperty("timer",bval);
- bval->Release();
- if (isInActiveLayer)
- {
- timemgr->AddTimeProperty(timeval);
- }
-
- propval = timeval;
- gameobj->SetProperty(prop->name,timeval);
-
- }
- default:
- {
- // todo make an assert etc.
- }
- }
-
- if (propval)
- {
- if (show_debug_info && isInActiveLayer)
- {
- scene->AddDebugProperty(gameobj,STR_String(prop->name));
- }
- // done with propval, release it
- propval->Release();
- }
-
-#ifdef WITH_PYTHON
- /* Warn if we double up on attributes, this isn't quite right since it wont find inherited attributes however there arnt many */
- for (PyAttributeDef *attrdef = KX_GameObject::Attributes; attrdef->m_name; attrdef++) {
- if (strcmp(prop->name, attrdef->m_name)==0) {
- printf("Warning! user defined property name \"%s\" is also a python attribute for object \"%s\"\n\tUse ob[\"%s\"] syntax to avoid conflict\n", prop->name, object->id.name+2, prop->name);
- break;
- }
- }
- for (PyMethodDef *methdef = KX_GameObject::Methods; methdef->ml_name; methdef++) {
- if (strcmp(prop->name, methdef->ml_name)==0) {
- printf("Warning! user defined property name \"%s\" is also a python method for object \"%s\"\n\tUse ob[\"%s\"] syntax to avoid conflict\n", prop->name, object->id.name+2, prop->name);
- break;
- }
- }
- /* end warning check */
-#endif // WITH_PYTHON
-
- prop = prop->next;
- }
- // check if state needs to be debugged
- if (object->scaflag & OB_DEBUGSTATE && isInActiveLayer)
- {
- // reserve name for object state
- scene->AddDebugProperty(gameobj,STR_String("__state__"));
- }
-
- /* Font Objects need to 'copy' the Font Object data body to ["Text"] */
- if (object->type == OB_FONT)
- {
- BL_ConvertTextProperty(object, (KX_FontObject *)gameobj, timemgr, scene, isInActiveLayer);
- }
-}
-
-void BL_ConvertTextProperty(Object* object, KX_FontObject* fontobj,SCA_TimeEventManager* timemgr,SCA_IScene* scene, bool isInActiveLayer)
-{
- CValue* tprop = fontobj->GetProperty("Text");
- if (!tprop) return;
- bProperty* prop = BKE_bproperty_object_get(object, "Text");
- if (!prop) return;
-
- Curve *curve = static_cast<Curve *>(object->data);
- STR_String str = curve->str;
- CValue* propval = NULL;
-
- switch (prop->type) {
- case GPROP_BOOL:
- {
- int value = atoi(str);
- propval = new CBoolValue((bool)(value != 0));
- tprop->SetValue(propval);
- break;
- }
- case GPROP_INT:
- {
- int value = atoi(str);
- propval = new CIntValue(value);
- tprop->SetValue(propval);
- break;
- }
- case GPROP_FLOAT:
- {
- float floatprop = (float)atof(str);
- propval = new CFloatValue(floatprop);
- tprop->SetValue(propval);
- break;
- }
- case GPROP_STRING:
- {
- propval = new CStringValue(str, "");
- tprop->SetValue(propval);
- break;
- }
- case GPROP_TIME:
- {
- float floatprop = (float)atof(str);
-
- CValue* timeval = new CFloatValue(floatprop);
- // set a subproperty called 'timer' so that
- // we can register the replica of this property
- // at the time a game object is replicated (AddObjectActuator triggers this)
- CValue *bval = new CBoolValue(true);
- timeval->SetProperty("timer",bval);
- bval->Release();
- if (isInActiveLayer)
- {
- timemgr->AddTimeProperty(timeval);
- }
-
- propval = timeval;
- tprop->SetValue(timeval);
- }
- default:
- {
- // todo make an assert etc.
- }
- }
-
- if (propval) {
- propval->Release();
- }
-}
-
diff --git a/source/gameengine/Converter/KX_ConvertProperties.h b/source/gameengine/Converter/KX_ConvertProperties.h
deleted file mode 100644
index 8f96cc21af6..00000000000
--- a/source/gameengine/Converter/KX_ConvertProperties.h
+++ /dev/null
@@ -1,41 +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_ConvertProperties.h
- * \ingroup bgeconv
- */
-
-#ifndef __KX_CONVERTPROPERTIES_H__
-#define __KX_CONVERTPROPERTIES_H__
-
-void BL_ConvertProperties(struct Object* object,
- class KX_GameObject* gameobj,
- class SCA_TimeEventManager* timemgr,
- class SCA_IScene* scene,
- bool isInActiveLayer);
-
-#endif /* __KX_CONVERTPROPERTIES_H__ */
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
deleted file mode 100644
index 5e897bb4a62..00000000000
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ /dev/null
@@ -1,663 +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/Converter/KX_ConvertSensors.cpp
- * \ingroup bgeconv
- *
- * Conversion of Blender data blocks to KX sensor system
- */
-
-#include <stdio.h>
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "wm_event_types.h"
-#include "KX_BlenderSceneConverter.h"
-#include "KX_ConvertSensors.h"
-
-/* This little block needed for linking to Blender... */
-#ifdef _MSC_VER
-# include "BLI_winstuff.h"
-#endif
-
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h" /* for SENS_ALL_KEYS ? this define is
- * probably misplaced */
-/* end of blender include block */
-
-#include "RAS_IPolygonMaterial.h"
-// Sensors
-#include "KX_GameObject.h"
-#include "RAS_MeshObject.h"
-#include "SCA_KeyboardSensor.h"
-#include "SCA_MouseSensor.h"
-#include "SCA_AlwaysSensor.h"
-#include "KX_TouchSensor.h"
-#include "KX_NearSensor.h"
-#include "KX_RadarSensor.h"
-#include "KX_MouseFocusSensor.h"
-#include "KX_ArmatureSensor.h"
-#include "SCA_JoystickSensor.h"
-#include "KX_NetworkMessageSensor.h"
-#include "SCA_ActuatorSensor.h"
-#include "SCA_DelaySensor.h"
-
-
-#include "SCA_PropertySensor.h"
-#include "SCA_RandomSensor.h"
-#include "KX_RaySensor.h"
-#include "SCA_EventManager.h"
-#include "SCA_LogicManager.h"
-#include "KX_BlenderInputDevice.h"
-#include "KX_Scene.h"
-#include "EXP_IntValue.h"
-#include "KX_BlenderKeyboardDevice.h"
-#include "RAS_ICanvas.h"
-#include "PHY_IPhysicsEnvironment.h"
-
-#include "KX_KetsjiEngine.h"
-#include "BL_BlenderDataConversion.h"
-
-void BL_ConvertSensors(struct Object* blenderobject,
- class KX_GameObject* gameobj,
- SCA_LogicManager* logicmgr,
- KX_Scene* kxscene,
- KX_KetsjiEngine* kxengine,
- int activeLayerBitInfo,
- bool isInActiveLayer,
- RAS_ICanvas* canvas,
- KX_BlenderSceneConverter* converter
- )
-{
-
- int executePriority = 0;
- int uniqueint = 0;
- int count = 0;
- bSensor* sens = (bSensor*)blenderobject->sensors.first;
- bool pos_pulsemode = false;
- bool neg_pulsemode = false;
- int skipped_ticks = 0;
- bool invert = false;
- bool level = false;
- bool tap = false;
-
- while (sens)
- {
- sens = sens->next;
- count++;
- }
- gameobj->ReserveSensor(count);
- sens = (bSensor*)blenderobject->sensors.first;
-
- while (sens) {
- if (!(sens->flag & SENS_DEACTIVATE)) {
- SCA_ISensor* gamesensor=NULL;
- /* All sensors have a pulse toggle, skipped ticks parameter, and invert field. */
- /* These are extracted here, and set when the sensor is added to the */
- /* list. */
- pos_pulsemode = (sens->pulse & SENS_PULSE_REPEAT)!=0;
- neg_pulsemode = (sens->pulse & SENS_NEG_PULSE_MODE)!=0;
-
- skipped_ticks = sens->freq;
- invert = !(sens->invert == 0);
- level = !(sens->level == 0);
- tap = !(sens->tap == 0);
-
- switch (sens->type)
- {
- case SENS_ALWAYS:
- {
-
- SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::BASIC_EVENTMGR);
- if (eventmgr)
- {
- gamesensor = new SCA_AlwaysSensor(eventmgr, gameobj);
- }
-
- break;
- }
-
- case SENS_DELAY:
- {
- // we can reuse the Always event manager for the delay sensor
- SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::BASIC_EVENTMGR);
- if (eventmgr)
- {
- bDelaySensor* delaysensor = (bDelaySensor*)sens->data;
- gamesensor = new SCA_DelaySensor(eventmgr,
- gameobj,
- delaysensor->delay,
- delaysensor->duration,
- (delaysensor->flag & SENS_DELAY_REPEAT) != 0);
- }
- break;
- }
-
- case SENS_COLLISION:
- {
- SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::TOUCH_EVENTMGR);
- if (eventmgr)
- {
- // collision sensor can sense both materials and properties.
-
- bool bFindMaterial = false, bTouchPulse = false;
-
- bCollisionSensor* blendertouchsensor = (bCollisionSensor*)sens->data;
-
- bFindMaterial = (blendertouchsensor->mode & SENS_COLLISION_MATERIAL);
- bTouchPulse = (blendertouchsensor->mode & SENS_COLLISION_PULSE);
-
-
- const STR_String touchPropOrMatName = bFindMaterial ?
- blendertouchsensor->materialName : blendertouchsensor->name;
-
-
- if (gameobj->GetPhysicsController())
- {
- gamesensor = new KX_TouchSensor(eventmgr,
- gameobj,
- bFindMaterial,
- bTouchPulse,
- touchPropOrMatName);
- }
-
- }
-
- break;
- }
- case SENS_MESSAGE:
- {
- KX_NetworkEventManager* eventmgr = (KX_NetworkEventManager*)
- logicmgr->FindEventManager(SCA_EventManager::NETWORK_EVENTMGR);
- if (eventmgr) {
- bMessageSensor* msgSens = (bMessageSensor*) sens->data;
-
- /* Get our NetworkScene */
- NG_NetworkScene *NetworkScene = kxscene->GetNetworkScene();
- /* filter on the incoming subjects, might be empty */
- const STR_String subject = msgSens->subject;
-
- gamesensor = new KX_NetworkMessageSensor(
- eventmgr, // our eventmanager
- NetworkScene, // our NetworkScene
- gameobj, // the sensor controlling object
- subject); // subject to filter on
- }
- break;
- }
- case SENS_NEAR:
- {
-
- SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::TOUCH_EVENTMGR);
- if (eventmgr)
- {
- bNearSensor* blendernearsensor = (bNearSensor*)sens->data;
- const STR_String nearpropertyname = (char *)blendernearsensor->name;
-
- //DT_ShapeHandle shape = DT_Sphere(0.0);
-
- // this sumoObject is not deleted by a gameobj, so delete it ourself
- // later (memleaks)!
- float radius = blendernearsensor->dist;
- const MT_Vector3& wpos = gameobj->NodeGetWorldPosition();
- bool bFindMaterial = false;
- PHY_IPhysicsController* physCtrl = kxscene->GetPhysicsEnvironment()->CreateSphereController(radius,wpos);
-
- //will be done in KX_TouchEventManager::RegisterSensor()
- //if (isInActiveLayer)
- // kxscene->GetPhysicsEnvironment()->addSensor(physCtrl);
-
-
-
- gamesensor = new KX_NearSensor(eventmgr,gameobj,
- blendernearsensor->dist,
- blendernearsensor->resetdist,
- bFindMaterial,
- nearpropertyname,
- physCtrl);
-
- }
- break;
- }
-
-
- case SENS_KEYBOARD:
- {
- /* temporary input device, for converting the code for the keyboard sensor */
-
- bKeyboardSensor* blenderkeybdsensor = (bKeyboardSensor*)sens->data;
- SCA_KeyboardManager* eventmgr = (SCA_KeyboardManager*) logicmgr->FindEventManager(SCA_EventManager::KEYBOARD_EVENTMGR);
- if (eventmgr)
- {
- gamesensor = new SCA_KeyboardSensor(eventmgr,
- ConvertKeyCode(blenderkeybdsensor->key),
- ConvertKeyCode(blenderkeybdsensor->qual),
- ConvertKeyCode(blenderkeybdsensor->qual2),
- (blenderkeybdsensor->type == SENS_ALL_KEYS),
- blenderkeybdsensor->targetName,
- blenderkeybdsensor->toggleName,
- gameobj,
- KX_KetsjiEngine::GetExitKey()); // blenderkeybdsensor->pad);
-
- }
-
- break;
- }
- case SENS_MOUSE:
- {
- int keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_NODEF;
- int trackfocus = 0;
- bMouseSensor *bmouse = (bMouseSensor *)sens->data;
-
- /* There are two main types of mouse sensors. If there is
- * no focus-related behavior requested, we can make do
- * with a basic sensor. This cuts down memory usage and
- * gives a slight performance gain. */
-
- SCA_MouseManager *eventmgr
- = (SCA_MouseManager*) logicmgr->FindEventManager(SCA_EventManager::MOUSE_EVENTMGR);
- if (eventmgr) {
-
- /* Determine key mode. There is at most one active mode. */
- switch (bmouse->type) {
- case BL_SENS_MOUSE_LEFT_BUTTON:
- keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_LEFTBUTTON;
- break;
- case BL_SENS_MOUSE_MIDDLE_BUTTON:
- keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_MIDDLEBUTTON;
- break;
- case BL_SENS_MOUSE_RIGHT_BUTTON:
- keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_RIGHTBUTTON;
- break;
- case BL_SENS_MOUSE_WHEEL_UP:
- keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_WHEELUP;
- break;
- case BL_SENS_MOUSE_WHEEL_DOWN:
- keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_WHEELDOWN;
- break;
- case BL_SENS_MOUSE_MOVEMENT:
- keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_MOVEMENT;
- break;
- case BL_SENS_MOUSE_MOUSEOVER:
- trackfocus = 1;
- break;
- case BL_SENS_MOUSE_MOUSEOVER_ANY:
- trackfocus = 2;
- break;
-
- default:
- ; /* error */
- }
-
- /* initial mouse position */
- int startx = canvas->GetWidth()/2;
- int starty = canvas->GetHeight()/2;
-
- if (!trackfocus) {
- /* plain, simple mouse sensor */
- gamesensor = new SCA_MouseSensor(eventmgr,
- startx,starty,
- keytype,
- gameobj);
- } else {
- /* give us a focus-aware sensor */
- bool bFindMaterial = (bmouse->mode & SENS_COLLISION_MATERIAL);
- bool bXRay = (bmouse->flag & SENS_RAY_XRAY);
- STR_String checkname = (bFindMaterial? bmouse->matname : bmouse->propname);
-
- gamesensor = new KX_MouseFocusSensor(eventmgr,
- startx,
- starty,
- keytype,
- trackfocus,
- (bmouse->flag & SENS_MOUSE_FOCUS_PULSE) ? true:false,
- checkname,
- bFindMaterial,
- bXRay,
- kxscene,
- kxengine,
- gameobj);
- }
- } else {
- // cout << "\n Could't find mouse event manager..."; - should throw an error here...
- }
- break;
- }
- case SENS_PROPERTY:
- {
- bPropertySensor* blenderpropsensor = (bPropertySensor*) sens->data;
- SCA_EventManager* eventmgr
- = logicmgr->FindEventManager(SCA_EventManager::BASIC_EVENTMGR);
- if (eventmgr)
- {
- STR_String propname=blenderpropsensor->name;
- STR_String propval=blenderpropsensor->value;
- STR_String propmaxval=blenderpropsensor->maxvalue;
-
- SCA_PropertySensor::KX_PROPSENSOR_TYPE
- propchecktype = SCA_PropertySensor::KX_PROPSENSOR_NODEF;
-
- /* Better do an explicit conversion here! (was implicit */
- /* before...) */
- switch (blenderpropsensor->type) {
- case SENS_PROP_EQUAL:
- propchecktype = SCA_PropertySensor::KX_PROPSENSOR_EQUAL;
- break;
- case SENS_PROP_NEQUAL:
- propchecktype = SCA_PropertySensor::KX_PROPSENSOR_NOTEQUAL;
- break;
- case SENS_PROP_INTERVAL:
- propchecktype = SCA_PropertySensor::KX_PROPSENSOR_INTERVAL;
- break;
- case SENS_PROP_CHANGED:
- propchecktype = SCA_PropertySensor::KX_PROPSENSOR_CHANGED;
- break;
- case SENS_PROP_EXPRESSION:
- propchecktype = SCA_PropertySensor::KX_PROPSENSOR_EXPRESSION;
- /* error */
- break;
- case SENS_PROP_LESSTHAN:
- propchecktype = SCA_PropertySensor::KX_PROPSENSOR_LESSTHAN;
- break;
- case SENS_PROP_GREATERTHAN:
- propchecktype = SCA_PropertySensor::KX_PROPSENSOR_GREATERTHAN;
- break;
- default:
- ; /* error */
- }
- gamesensor = new SCA_PropertySensor(eventmgr,gameobj,propname,propval,propmaxval,propchecktype);
- }
-
- break;
- }
- case SENS_ACTUATOR:
- {
- bActuatorSensor* blenderactsensor = (bActuatorSensor*) sens->data;
- // we will reuse the property event manager, there is nothing special with this sensor
- SCA_EventManager* eventmgr
- = logicmgr->FindEventManager(SCA_EventManager::ACTUATOR_EVENTMGR);
- if (eventmgr)
- {
- STR_String propname=blenderactsensor->name;
- gamesensor = new SCA_ActuatorSensor(eventmgr,gameobj,propname);
- }
- break;
- }
-
- case SENS_ARMATURE:
- {
- bArmatureSensor* blenderarmsensor = (bArmatureSensor*) sens->data;
- // we will reuse the property event manager, there is nothing special with this sensor
- SCA_EventManager* eventmgr
- = logicmgr->FindEventManager(SCA_EventManager::BASIC_EVENTMGR);
- if (eventmgr)
- {
- STR_String bonename=blenderarmsensor->posechannel;
- STR_String constraintname=blenderarmsensor->constraint;
- gamesensor = new KX_ArmatureSensor(eventmgr,gameobj,bonename,constraintname, blenderarmsensor->type, blenderarmsensor->value);
- }
- break;
- }
-
- case SENS_RADAR:
- {
-
- SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::TOUCH_EVENTMGR);
- if (eventmgr)
- {
- bRadarSensor* blenderradarsensor = (bRadarSensor*) sens->data;
- const STR_String radarpropertyname = blenderradarsensor->name;
-
- int radaraxis = blenderradarsensor->axis;
-
- MT_Scalar coneheight = blenderradarsensor->range;
-
- // janco: the angle was doubled, so should I divide the factor in 2
- // or the blenderradarsensor->angle?
- // nzc: the angle is the opening angle. We need to init with
- // the axis-hull angle,so /2.0.
- MT_Scalar factor = tan(blenderradarsensor->angle * 0.5f);
- //MT_Scalar coneradius = coneheight * (factor / 2);
- MT_Scalar coneradius = coneheight * factor;
-
-
- // this sumoObject is not deleted by a gameobj, so delete it ourself
- // later (memleaks)!
- MT_Scalar smallmargin = 0.0;
- MT_Scalar largemargin = 0.0;
-
- bool bFindMaterial = false;
- PHY_IPhysicsController* ctrl = kxscene->GetPhysicsEnvironment()->CreateConeController((float)coneradius, (float)coneheight);
-
- gamesensor = new KX_RadarSensor(
- eventmgr,
- gameobj,
- ctrl,
- coneradius,
- coneheight,
- radaraxis,
- smallmargin,
- largemargin,
- bFindMaterial,
- radarpropertyname);
-
- }
-
- break;
- }
- case SENS_RAY:
- {
- bRaySensor* blenderraysensor = (bRaySensor*) sens->data;
-
- //blenderradarsensor->angle;
- SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::BASIC_EVENTMGR);
- if (eventmgr)
- {
- bool bFindMaterial = (blenderraysensor->mode & SENS_COLLISION_MATERIAL);
- bool bXRay = (blenderraysensor->mode & SENS_RAY_XRAY);
-
- STR_String checkname = (bFindMaterial? blenderraysensor->matname : blenderraysensor->propname);
-
- // don't want to get rays of length 0.0 or so
- double distance = (blenderraysensor->range < 0.01f ? 0.01f : blenderraysensor->range);
- int axis = blenderraysensor->axisflag;
-
-
- gamesensor = new KX_RaySensor(eventmgr,
- gameobj,
- checkname,
- bFindMaterial,
- bXRay,
- distance,
- axis,
- kxscene);
-
- }
- break;
- }
-
- case SENS_RANDOM:
- {
- bRandomSensor* blenderrndsensor = (bRandomSensor*) sens->data;
- // some files didn't write randomsensor, avoid crash now for NULL ptr's
- if (blenderrndsensor)
- {
- SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::BASIC_EVENTMGR);
- if (eventmgr)
- {
- int randomSeed = blenderrndsensor->seed;
- if (randomSeed == 0)
- {
- randomSeed = (int)(kxengine->GetRealTime()*100000.0);
- randomSeed ^= (intptr_t)blenderrndsensor;
- }
- gamesensor = new SCA_RandomSensor(eventmgr, gameobj, randomSeed);
- }
- }
- break;
- }
- case SENS_JOYSTICK:
- {
- int joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_NODEF;
-
- bJoystickSensor* bjoy = (bJoystickSensor*) sens->data;
-
- SCA_JoystickManager *eventmgr
- = (SCA_JoystickManager*) logicmgr->FindEventManager(SCA_EventManager::JOY_EVENTMGR);
- if (eventmgr)
- {
- int axis =0;
- int axisf =0;
- int button =0;
- int hat =0;
- int hatf =0;
- int prec =0;
-
- switch (bjoy->type) {
- case SENS_JOY_AXIS:
- axis = bjoy->axis;
- axisf = bjoy->axisf;
- prec = bjoy->precision;
- joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_AXIS;
- break;
- case SENS_JOY_BUTTON:
- button = bjoy->button;
- joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_BUTTON;
- break;
- case SENS_JOY_HAT:
- hat = bjoy->hat;
- hatf = bjoy->hatf;
- joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_HAT;
- break;
- case SENS_JOY_AXIS_SINGLE:
- axis = bjoy->axis_single;
- prec = bjoy->precision;
- joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_AXIS_SINGLE;
- break;
- default:
- printf("Error: bad case statement\n");
- break;
- }
- gamesensor = new SCA_JoystickSensor(
- eventmgr,
- gameobj,
- bjoy->joyindex,
- joysticktype,
- axis,axisf,
- prec,
- button,
- hat,hatf,
- (bjoy->flag & SENS_JOY_ANY_EVENT));
- }
- else
- {
- printf("Error there was a problem finding the event manager\n");
- }
-
- break;
- }
- default:
- {
- }
- }
-
- if (gamesensor)
- {
- gamesensor->SetExecutePriority(executePriority++);
- STR_String uniquename = sens->name;
- uniquename += "#SENS#";
- uniqueint++;
- CIntValue* uniqueval = new CIntValue(uniqueint);
- uniquename += uniqueval->GetText();
- uniqueval->Release();
-
- /* Conversion succeeded, so we can set the generic props here. */
- gamesensor->SetPulseMode(pos_pulsemode,
- neg_pulsemode,
- skipped_ticks);
- gamesensor->SetInvert(invert);
- gamesensor->SetLevel(level);
- gamesensor->SetTap(tap);
- gamesensor->SetName(sens->name);
- gamesensor->SetLogicManager(logicmgr);
-
- gameobj->AddSensor(gamesensor);
-
- // only register to manager if it's in an active layer
- // Make registration dynamic: only when sensor is activated
- //if (isInActiveLayer)
- // gamesensor->RegisterToManager();
-
- gamesensor->ReserveController(sens->totlinks);
- for (int i=0;i<sens->totlinks;i++)
- {
- bController* linkedcont = (bController*) sens->links[i];
- if (linkedcont) {
- // If the controller is deactived doesn't register it
- if (!(linkedcont->flag & CONT_DEACTIVATE)) {
- SCA_IController* gamecont = converter->FindGameController(linkedcont);
-
- if (gamecont) {
- logicmgr->RegisterToSensor(gamecont,gamesensor);
- }
- else {
- printf("Warning, sensor \"%s\" could not find its controller "
- "(link %d of %d) from object \"%s\"\n"
- "\tthere has been an error converting the blender controller for the game engine,"
- "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2);
- }
- }
- }
- else {
- printf("Warning, sensor \"%s\" has lost a link to a controller "
- "(link %d of %d) from object \"%s\"\n"
- "\tpossible causes are partially appended objects or an error reading the file,"
- "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2);
- }
- }
- // special case: Keyboard sensor with no link
- // this combination is usually used for key logging.
- if (sens->type == SENS_KEYBOARD && sens->totlinks == 0) {
- // Force the registration so that the sensor runs
- gamesensor->IncLink();
- }
-
- // done with gamesensor
- gamesensor->Release();
-
- }
- }
-
- sens=sens->next;
- }
-}
-
diff --git a/source/gameengine/Converter/KX_ConvertSensors.h b/source/gameengine/Converter/KX_ConvertSensors.h
deleted file mode 100644
index 56248721a37..00000000000
--- a/source/gameengine/Converter/KX_ConvertSensors.h
+++ /dev/null
@@ -1,45 +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_ConvertSensors.h
- * \ingroup bgeconv
- */
-
-#ifndef __KX_CONVERTSENSORS_H__
-#define __KX_CONVERTSENSORS_H__
-
-void BL_ConvertSensors(struct Object* blenderobject,
- class KX_GameObject* gameobj,
- class SCA_LogicManager* logicmgr,
- class KX_Scene* kxscene,
- class KX_KetsjiEngine* kxengine,
- int activeLayerBitInfo,
- bool isInActiveLayer,
- class RAS_ICanvas* canvas,
- class KX_BlenderSceneConverter* converter);
-
-#endif /* __KX_CONVERTSENSORS_H__ */
diff --git a/source/gameengine/Converter/KX_LibLoadStatus.cpp b/source/gameengine/Converter/KX_LibLoadStatus.cpp
deleted file mode 100644
index 66fcd998269..00000000000
--- a/source/gameengine/Converter/KX_LibLoadStatus.cpp
+++ /dev/null
@@ -1,255 +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.
- *
- * Contributor(s): Mitchell Stokes
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_LibLoadStatus.cpp
- * \ingroup bgeconv
- */
-
-#include "KX_LibLoadStatus.h"
-#include "PIL_time.h"
-
-KX_LibLoadStatus::KX_LibLoadStatus(class KX_BlenderSceneConverter* kx_converter,
- class KX_KetsjiEngine* kx_engine,
- class KX_Scene* merge_scene,
- const char *path) :
- m_converter(kx_converter),
- m_engine(kx_engine),
- m_mergescene(merge_scene),
- m_data(NULL),
- m_libname(path),
- m_progress(0.0f),
- m_finished(false)
-#ifdef WITH_PYTHON
- ,
- m_finish_cb(NULL),
- m_progress_cb(NULL)
-#endif
-{
- m_endtime = m_starttime = PIL_check_seconds_timer();
-}
-
-void KX_LibLoadStatus::Finish()
-{
- m_finished = true;
- m_progress = 1.f;
- m_endtime = PIL_check_seconds_timer();
-
- RunFinishCallback();
- RunProgressCallback();
-}
-
-void KX_LibLoadStatus::RunFinishCallback()
-{
-#ifdef WITH_PYTHON
- if (m_finish_cb) {
- PyObject* args = Py_BuildValue("(O)", GetProxy());
-
- if (!PyObject_Call(m_finish_cb, args, NULL)) {
- PyErr_Print();
- PyErr_Clear();
- }
-
- Py_DECREF(args);
- }
-#endif
-}
-
-void KX_LibLoadStatus::RunProgressCallback()
-{
-// Progess callbacks are causing threading problems with Python, so they're disabled for now
-#if 0
-#ifdef WITH_PYTHON
- if (m_progress_cb) {
- //PyGILState_STATE gstate = PyGILState_Ensure();
- PyObject* args = Py_BuildValue("(O)", GetProxy());
-
- if (!PyObject_Call(m_progress_cb, args, NULL)) {
- PyErr_Print();
- PyErr_Clear();
- }
-
- Py_DECREF(args);
- //PyGILState_Release(gstate);
- }
-#endif
-#endif
-}
-
-class KX_BlenderSceneConverter *KX_LibLoadStatus::GetConverter()
-{
- return m_converter;
-}
-
-class KX_KetsjiEngine *KX_LibLoadStatus::GetEngine()
-{
- return m_engine;
-}
-
-class KX_Scene *KX_LibLoadStatus::GetMergeScene()
-{
- return m_mergescene;
-}
-
-void KX_LibLoadStatus::SetLibName(const char *name)
-{
- m_libname = name;
-}
-
-const char *KX_LibLoadStatus::GetLibName()
-{
- return m_libname;
-}
-
-void KX_LibLoadStatus::SetData(void *data)
-{
- m_data = data;
-}
-
-void *KX_LibLoadStatus::GetData()
-{
- return m_data;
-}
-
-void KX_LibLoadStatus::SetProgress(float progress)
-{
- m_progress = progress;
- RunProgressCallback();
-}
-
-float KX_LibLoadStatus::GetProgress()
-{
- return m_progress;
-}
-
-void KX_LibLoadStatus::AddProgress(float progress)
-{
- m_progress += progress;
- RunProgressCallback();
-}
-
-#ifdef WITH_PYTHON
-
-PyMethodDef KX_LibLoadStatus::Methods[] =
-{
- {NULL} //Sentinel
-};
-
-PyAttributeDef KX_LibLoadStatus::Attributes[] = {
- KX_PYATTRIBUTE_RW_FUNCTION("onFinish", KX_LibLoadStatus, pyattr_get_onfinish, pyattr_set_onfinish),
- // KX_PYATTRIBUTE_RW_FUNCTION("onProgress", KX_LibLoadStatus, pyattr_get_onprogress, pyattr_set_onprogress),
- KX_PYATTRIBUTE_FLOAT_RO("progress", KX_LibLoadStatus, m_progress),
- KX_PYATTRIBUTE_STRING_RO("libraryName", KX_LibLoadStatus, m_libname),
- KX_PYATTRIBUTE_RO_FUNCTION("timeTaken", KX_LibLoadStatus, pyattr_get_timetaken),
- KX_PYATTRIBUTE_BOOL_RO("finished", KX_LibLoadStatus, m_finished),
- { NULL } //Sentinel
-};
-
-PyTypeObject KX_LibLoadStatus::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_LibLoadStatus",
- 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
-};
-
-
-PyObject* KX_LibLoadStatus::pyattr_get_onfinish(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LibLoadStatus* self = static_cast<KX_LibLoadStatus*>(self_v);
-
- if (self->m_finish_cb) {
- Py_INCREF(self->m_finish_cb);
- return self->m_finish_cb;
- }
-
- Py_RETURN_NONE;
-}
-
-int KX_LibLoadStatus::pyattr_set_onfinish(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LibLoadStatus* self = static_cast<KX_LibLoadStatus*>(self_v);
-
- if (!PyCallable_Check(value)) {
- PyErr_SetString(PyExc_TypeError, "KX_LibLoadStatus.onFinished requires a callable object");
- return PY_SET_ATTR_FAIL;
- }
-
- if (self->m_finish_cb)
- Py_DECREF(self->m_finish_cb);
-
- Py_INCREF(value);
- self->m_finish_cb = value;
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject* KX_LibLoadStatus::pyattr_get_onprogress(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LibLoadStatus* self = static_cast<KX_LibLoadStatus*>(self_v);
-
- if (self->m_progress_cb) {
- Py_INCREF(self->m_progress_cb);
- return self->m_progress_cb;
- }
-
- Py_RETURN_NONE;
-}
-
-int KX_LibLoadStatus::pyattr_set_onprogress(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LibLoadStatus* self = static_cast<KX_LibLoadStatus*>(self_v);
-
- if (!PyCallable_Check(value)) {
- PyErr_SetString(PyExc_TypeError, "KX_LibLoadStatus.onProgress requires a callable object");
- return PY_SET_ATTR_FAIL;
- }
-
- if (self->m_progress_cb)
- Py_DECREF(self->m_progress_cb);
-
- Py_INCREF(value);
- self->m_progress_cb = value;
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject* KX_LibLoadStatus::pyattr_get_timetaken(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LibLoadStatus* self = static_cast<KX_LibLoadStatus*>(self_v);
-
- return PyFloat_FromDouble(self->m_endtime - self->m_starttime);
-}
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Converter/KX_LibLoadStatus.h b/source/gameengine/Converter/KX_LibLoadStatus.h
deleted file mode 100644
index fd51bfddd85..00000000000
--- a/source/gameengine/Converter/KX_LibLoadStatus.h
+++ /dev/null
@@ -1,93 +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.
- *
- * Contributor(s): Mitchell Stokes
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_LibLoadStatus.h
- * \ingroup bgeconv
- */
-
-#ifndef __KX_LIBLOADSTATUS_H__
-#define __KX_LIBLOADSTATUS_H__
-
-#include "EXP_PyObjectPlus.h"
-
-class KX_LibLoadStatus : public PyObjectPlus
-{
- Py_Header
-private:
- class KX_BlenderSceneConverter* m_converter;
- class KX_KetsjiEngine* m_engine;
- class KX_Scene* m_mergescene;
- void* m_data;
- STR_String m_libname;
-
- float m_progress;
- double m_starttime;
- double m_endtime;
-
- // The current status of this libload, used by the scene converter.
- bool m_finished;
-
-#ifdef WITH_PYTHON
- PyObject* m_finish_cb;
- PyObject* m_progress_cb;
-#endif
-
-public:
- KX_LibLoadStatus(class KX_BlenderSceneConverter* kx_converter,
- class KX_KetsjiEngine* kx_engine,
- class KX_Scene* merge_scene,
- const char *path);
-
- void Finish(); // Called when the libload is done
- void RunFinishCallback();
- void RunProgressCallback();
-
- class KX_BlenderSceneConverter *GetConverter();
- class KX_KetsjiEngine *GetEngine();
- class KX_Scene *GetMergeScene();
-
- void SetLibName(const char *name);
- const char *GetLibName();
-
- void SetData(void *data);
- void *GetData();
-
- inline bool IsFinished() const
- {
- return m_finished;
- }
-
- void SetProgress(float progress);
- float GetProgress();
- void AddProgress(float progress);
-
-#ifdef WITH_PYTHON
- static PyObject* pyattr_get_onfinish(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_onfinish(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_onprogress(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_onprogress(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static PyObject* pyattr_get_timetaken(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-#endif
-};
-
-#endif // __KX_LIBLOADSTATUS_H__
diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
deleted file mode 100644
index 877aebff556..00000000000
--- a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp
+++ /dev/null
@@ -1,121 +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/Converter/KX_SoftBodyDeformer.cpp
- * \ingroup bgeconv
- */
-
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif //WIN32
-
-#include "MT_assert.h"
-
-#include "KX_SoftBodyDeformer.h"
-#include "RAS_MeshObject.h"
-#include "CTR_Map.h"
-#include "CTR_HashedPtr.h"
-
-#ifdef WITH_BULLET
-
-#include "CcdPhysicsEnvironment.h"
-#include "CcdPhysicsController.h"
-#include "BulletSoftBody/btSoftBody.h"
-
-#include "btBulletDynamicsCommon.h"
-
-void KX_SoftBodyDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
-{
- void **h_obj = (*map)[m_gameobj];
-
- if (h_obj) {
- m_gameobj = (BL_DeformableGameObject*)(*h_obj);
- m_pMeshObject = m_gameobj->GetMesh(0);
- } else {
- m_gameobj = NULL;
- m_pMeshObject = NULL;
- }
-}
-
-bool KX_SoftBodyDeformer::Apply(class RAS_IPolyMaterial *polymat)
-{
- CcdPhysicsController* ctrl = (CcdPhysicsController*) m_gameobj->GetPhysicsController();
- if (!ctrl)
- return false;
-
- btSoftBody* softBody= ctrl->GetSoftBody();
- if (!softBody)
- return false;
-
- //printf("apply\n");
- RAS_MeshSlot::iterator it;
- RAS_MeshMaterial *mmat;
- RAS_MeshSlot *slot;
- size_t i;
-
- // update the vertex in m_transverts
- Update();
-
- // The vertex cache can only be updated for this deformer:
- // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object)
- // share the same mesh (=the same cache). As the rendering is done per polymaterial
- // cycling through the objects, the entire mesh cache cannot be updated in one shot.
- mmat = m_pMeshObject->GetMeshMaterial(polymat);
- if (!mmat->m_slots[(void*)m_gameobj])
- return true;
-
- slot = *mmat->m_slots[(void*)m_gameobj];
-
- // for each array
- for (slot->begin(it); !slot->end(it); slot->next(it))
- {
- btSoftBody::tNodeArray& nodes(softBody->m_nodes);
-
- int index = 0;
- for (i=it.startvertex; i<it.endvertex; i++,index++) {
- RAS_TexVert& v = it.vertex[i];
- btAssert(v.getSoftBodyIndex() >= 0);
-
- MT_Point3 pt (
- nodes[v.getSoftBodyIndex()].m_x.getX(),
- nodes[v.getSoftBodyIndex()].m_x.getY(),
- nodes[v.getSoftBodyIndex()].m_x.getZ());
- v.SetXYZ(pt);
-
- MT_Vector3 normal (
- nodes[v.getSoftBodyIndex()].m_n.getX(),
- nodes[v.getSoftBodyIndex()].m_n.getY(),
- nodes[v.getSoftBodyIndex()].m_n.getZ());
- v.SetNormal(normal);
-
- }
- }
- return true;
-}
-
-#endif
diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.h b/source/gameengine/Converter/KX_SoftBodyDeformer.h
deleted file mode 100644
index d7bc088e1c0..00000000000
--- a/source/gameengine/Converter/KX_SoftBodyDeformer.h
+++ /dev/null
@@ -1,102 +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_SoftBodyDeformer.h
- * \ingroup bgeconv
- */
-
-#ifndef __KX_SOFTBODYDEFORMER_H__
-#define __KX_SOFTBODYDEFORMER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* get rid of stupid stl-visual compiler debug warning */
-#endif
-
-#include "RAS_Deformer.h"
-#include "BL_DeformableGameObject.h"
-#include <vector>
-
-
-class KX_SoftBodyDeformer : public RAS_Deformer
-{
- class RAS_MeshObject* m_pMeshObject;
- class BL_DeformableGameObject* m_gameobj;
-
-public:
- KX_SoftBodyDeformer(RAS_MeshObject* pMeshObject,BL_DeformableGameObject* gameobj)
- :m_pMeshObject(pMeshObject),
- m_gameobj(gameobj)
- {
- //printf("KX_SoftBodyDeformer\n");
- };
-
- virtual ~KX_SoftBodyDeformer()
- {
- //printf("~KX_SoftBodyDeformer\n");
- };
- virtual void Relink(CTR_Map<class CTR_HashedPtr, void*>*map);
- virtual bool Apply(class RAS_IPolyMaterial *polymat);
- virtual bool Update(void)
- {
- //printf("update\n");
- m_bDynamic = true;
- return true;//??
- }
- virtual bool UpdateBuckets(void)
- {
- // this is to update the mesh slots outside the rasterizer,
- // no need to do it for this deformer, it's done in any case in Apply()
- return false;
- }
-
- virtual RAS_Deformer *GetReplica()
- {
- KX_SoftBodyDeformer* deformer = new KX_SoftBodyDeformer(*this);
- deformer->ProcessReplica();
- return deformer;
- }
- virtual void ProcessReplica()
- {
- // we have two pointers to deal with but we cannot do it now, will be done in Relink
- m_bDynamic = false;
- }
- virtual bool SkipVertexTransform()
- {
- return true;
- }
-
-protected:
- //class RAS_MeshObject *m_pMesh;
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ShapeDeformer")
-#endif
-};
-
-
-#endif
-
diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt
deleted file mode 100644
index 9c563a46ea2..00000000000
--- a/source/gameengine/Expressions/CMakeLists.txt
+++ /dev/null
@@ -1,91 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../SceneGraph
- ../../blender/blenlib
- ../../../intern/guardedalloc
- ../../../intern/string
-)
-
-set(INC_SYS
- ../../../intern/moto/include
-)
-
-set(SRC
- intern/BoolValue.cpp
- intern/ConstExpr.cpp
- intern/EmptyValue.cpp
- intern/ErrorValue.cpp
- intern/Expression.cpp
- intern/FloatValue.cpp
- intern/IdentifierExpr.cpp
- intern/IfExpr.cpp
- intern/InputParser.cpp
- intern/IntValue.cpp
- intern/HashedPtr.cpp
- intern/ListValue.cpp
- intern/Operator1Expr.cpp
- intern/Operator2Expr.cpp
- intern/PyObjectPlus.cpp
- intern/StringValue.cpp
- intern/Value.cpp
- intern/VectorValue.cpp
- intern/ListWrapper.cpp
-
- EXP_BoolValue.h
- EXP_ConstExpr.h
- EXP_EmptyValue.h
- EXP_ErrorValue.h
- EXP_Expression.h
- EXP_FloatValue.h
- EXP_HashedPtr.h
- EXP_IdentifierExpr.h
- EXP_IfExpr.h
- EXP_InputParser.h
- EXP_IntValue.h
- EXP_ListValue.h
- EXP_Operator1Expr.h
- EXP_Operator2Expr.h
- EXP_PyObjectPlus.h
- EXP_Python.h
- EXP_StringValue.h
- EXP_Value.h
- EXP_VectorValue.h
- EXP_VoidValue.h
- EXP_ListWrapper.h
-
-)
-
-if(WITH_PYTHON)
- list(APPEND SRC
- intern/PythonCallBack.cpp
-
- EXP_PythonCallBack.h
- )
-endif()
-
-blender_add_lib(ge_logic_expressions "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Expressions/EXP_BoolValue.h b/source/gameengine/Expressions/EXP_BoolValue.h
deleted file mode 100644
index 98ba1d75e52..00000000000
--- a/source/gameengine/Expressions/EXP_BoolValue.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * BoolValue.h: interface for the CBoolValue class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_BoolValue.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_BOOLVALUE_H__
-#define __EXP_BOOLVALUE_H__
-
-#include "EXP_Value.h"
-
-/**
- * Smart Boolean Value class.
- * Is used by parser when an expression tree is build containing booleans.
- */
-
-class CBoolValue : public CPropValue
-{
-
- //PLUGIN_DECLARE_SERIAL(CBoolValue,CValue)
-
-public:
- static const STR_String sTrueString;
- static const STR_String sFalseString;
-
- CBoolValue();
- CBoolValue(bool inBool);
- CBoolValue(bool innie, const char *name, AllocationTYPE alloctype = CValue::HEAPVALUE);
-
- virtual const STR_String& GetText();
- virtual double GetNumber();
- virtual int GetValueType();
- bool GetBool();
- virtual void SetValue(CValue* newval);
-
- virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
-
- void Configure(CValue* menuvalue);
- virtual CValue* GetReplica();
-#ifdef WITH_PYTHON
- virtual PyObject* ConvertValueToPython();
-#endif
-
-private:
- bool m_bool;
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CBoolValue")
-#endif
-};
-
-#endif /* __EXP_BOOLVALUE_H__ */
diff --git a/source/gameengine/Expressions/EXP_ConstExpr.h b/source/gameengine/Expressions/EXP_ConstExpr.h
deleted file mode 100644
index b4456dacdf3..00000000000
--- a/source/gameengine/Expressions/EXP_ConstExpr.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ConstExpr.h: interface for the CConstExpr class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_ConstExpr.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_CONSTEXPR_H__
-#define __EXP_CONSTEXPR_H__
-
-#include "EXP_Expression.h"
-#include "EXP_Value.h" // Added by ClassView
-
-class CConstExpr : public CExpression
-{
- //PLUGIN_DECLARE_SERIAL_EXPRESSION (CConstExpr,CExpression)
-public:
- virtual bool MergeExpression(CExpression* otherexpr);
-
- void BroadcastOperators(VALUE_OPERATOR op);
-
- virtual unsigned char GetExpressionID();
- CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
- //bool IsInside(float x,float y,float z,bool bBorderInclude=true);
- bool NeedsRecalculated();
- void ClearModified();
- virtual double GetNumber();
- virtual CValue* Calculate();
- CConstExpr(CValue* constval);
- CConstExpr();
- virtual ~CConstExpr();
-
-
-private:
- CValue* m_value;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CConstExpr")
-#endif
-};
-
-#endif /* __EXP_CONSTEXPR_H__ */
diff --git a/source/gameengine/Expressions/EXP_EmptyValue.h b/source/gameengine/Expressions/EXP_EmptyValue.h
deleted file mode 100644
index d23addb9f9f..00000000000
--- a/source/gameengine/Expressions/EXP_EmptyValue.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * EmptyValue.h: interface for the CEmptyValue class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_EmptyValue.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_EMPTYVALUE_H__
-#define __EXP_EMPTYVALUE_H__
-
-#include "EXP_Value.h"
-
-class CListValue;
-
-class CEmptyValue : public CPropValue
-{
- //PLUGIN_DECLARE_SERIAL (CEmptyValue,CValue)
-public:
- CEmptyValue();
- virtual ~CEmptyValue();
-
- virtual const STR_String & GetText();
- virtual double GetNumber();
- virtual int GetValueType();
- CListValue* GetPolySoup();
- virtual double* GetVector3(bool bGetTransformedVec=false);
- bool IsInside(CValue* testpoint,bool bBorderInclude=true);
- CValue * Calc(VALUE_OPERATOR op, CValue *val);
- CValue * CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
- virtual CValue* GetReplica();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CEmptyValue")
-#endif
-};
-
-#endif /* __EXP_EMPTYVALUE_H__ */
diff --git a/source/gameengine/Expressions/EXP_ErrorValue.h b/source/gameengine/Expressions/EXP_ErrorValue.h
deleted file mode 100644
index a6f91ca200a..00000000000
--- a/source/gameengine/Expressions/EXP_ErrorValue.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ErrorValue.h: interface for the CErrorValue class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_ErrorValue.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_ERRORVALUE_H__
-#define __EXP_ERRORVALUE_H__
-
-#include "EXP_Value.h"
-
-class CErrorValue : public CPropValue
-{
-
-public:
- virtual const STR_String & GetText();
- virtual double GetNumber();
- virtual int GetValueType();
- CErrorValue();
- CErrorValue(const char *errmsg);
- virtual ~CErrorValue();
- virtual CValue* Calc(VALUE_OPERATOR op, CValue* val);
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
- virtual CValue* GetReplica();
-
-private:
- STR_String m_strErrorText;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CErrorValue")
-#endif
-};
-
-#endif /* __EXP_ERRORVALUE_H__ */
diff --git a/source/gameengine/Expressions/EXP_Expression.h b/source/gameengine/Expressions/EXP_Expression.h
deleted file mode 100644
index 66a6e9476ff..00000000000
--- a/source/gameengine/Expressions/EXP_Expression.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Expression.h: interface for the CExpression class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_Expression.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_EXPRESSION_H__
-#define __EXP_EXPRESSION_H__
-
-#include "EXP_Value.h"
-
-//extern int gRefCountExpr; // only for debugging purposes (detect mem.leaks)
-
-
-#define PLUGIN_DECLARE_SERIAL_EXPRESSION(class_name, base_class_name) \
-public: \
- virtual base_class_name * Copy() { \
- return new class_name; \
- } \
- virtual bool EdSerialize(CompressorArchive& arch, \
- class CFactoryManager* facmgr, \
- bool bIsStoring); \
- virtual bool EdIdSerialize(CompressorArchive& arch, \
- class CFactoryManager* facmgr, \
- bool bIsStoring) \
- { \
- if (bIsStoring) \
- { \
- unsigned char exprID = GetExpressionID(); \
- arch << exprID; \
- } \
- return true; \
- } \
-
-
-
-class CExpression;
-
-
-// for undo/redo system the deletion in the expressiontree can be restored by replacing broken links 'inplace'
-class CBrokenLinkInfo
-{
- public:
- CBrokenLinkInfo(CExpression** pmemexpr,CExpression* expr)
- :m_pmemExpr(pmemexpr),
- m_pExpr(expr)
- {
- assertd(pmemexpr);
- m_bRestored=false;
- };
-
- virtual ~CBrokenLinkInfo();
- void RestoreLink();
- void BreakLink();
-
-
- // members vars
- private:
- CExpression** m_pmemExpr;
- CExpression* m_pExpr;
- bool m_bRestored;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CBrokenLinkInfo")
-#endif
-};
-
-
-
-
-
-
-
-
-class CExpression
-{
-public:
- enum {
- COPERATOR1EXPRESSIONID = 1,
- COPERATOR2EXPRESSIONID = 2,
- CCONSTEXPRESSIONID = 3,
- CIFEXPRESSIONID = 4,
- COPERATORVAREXPRESSIONID = 5,
- CIDENTIFIEREXPRESSIONID = 6
- };
-
-
-protected:
- virtual ~CExpression() = 0; //pure virtual
-public:
- virtual bool MergeExpression(CExpression* otherexpr) = 0;
- CExpression();
-
-
- virtual CValue* Calculate() = 0; //pure virtual
- virtual unsigned char GetExpressionID() = 0;
- //virtual bool IsInside(float x,float y,float z,bool bBorderInclude=true) = 0; //pure virtual
- virtual bool NeedsRecalculated() = 0; // another pure one
- virtual CExpression * CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks) =0; // another pure one
- virtual void ClearModified() = 0; // another pure one
- //virtual CExpression * Copy() =0;
- virtual void BroadcastOperators(VALUE_OPERATOR op) =0;
-
- virtual CExpression * AddRef() { // please leave multiline, for debugger !!!
-
-#ifdef DEBUG
- //gRefCountExpr++;
- assertd(m_refcount < 255);
-#endif
- m_refcount++;
- return this;
- };
- virtual CExpression* Release(CExpression* complicatedtrick=NULL) {
-#ifdef DEBUG
- //gRefCountExpr--;
-#endif
- if (--m_refcount < 1)
- {
- delete this;
- } //else
- // return this;
- return complicatedtrick;
- };
-
-
-protected:
-
- int m_refcount;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CExpression")
-#endif
-};
-
-#endif /* __EXP_EXPRESSION_H__ */
diff --git a/source/gameengine/Expressions/EXP_FloatValue.h b/source/gameengine/Expressions/EXP_FloatValue.h
deleted file mode 100644
index 3c16c57d16d..00000000000
--- a/source/gameengine/Expressions/EXP_FloatValue.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * FloatValue.h: interface for the CFloatValue class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_FloatValue.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_FLOATVALUE_H__
-#define __EXP_FLOATVALUE_H__
-
-#include "EXP_Value.h"
-
-class CFloatValue : public CPropValue
-{
- //PLUGIN_DECLARE_SERIAL (CFloatValue,CValue)
-public:
- CFloatValue();
- CFloatValue(float fl);
- CFloatValue(float fl,const char *name,AllocationTYPE alloctype=CValue::HEAPVALUE);
-
- virtual const STR_String & GetText();
-
- void Configure(CValue* menuvalue);
- virtual double GetNumber();
- virtual int GetValueType();
- virtual void SetValue(CValue* newval);
- float GetFloat();
- void SetFloat(float fl);
- virtual ~CFloatValue();
- virtual CValue* GetReplica();
- virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
-#ifdef WITH_PYTHON
- virtual PyObject* ConvertValueToPython();
-#endif
-
-protected:
- float m_float;
- STR_String* m_pstrRep;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CFloatValue")
-#endif
-};
-
-#endif /* __EXP_FLOATVALUE_H__ */
diff --git a/source/gameengine/Expressions/EXP_HashedPtr.h b/source/gameengine/Expressions/EXP_HashedPtr.h
deleted file mode 100644
index 7c7c5f6e5ec..00000000000
--- a/source/gameengine/Expressions/EXP_HashedPtr.h
+++ /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 EXP_HashedPtr.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_HASHEDPTR_H__
-#define __EXP_HASHEDPTR_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class CHashedPtr
-{
- void* m_valptr;
-
-public:
- CHashedPtr(void* val);
-
- unsigned int hash() const;
-
- inline friend bool operator ==( const CHashedPtr & rhs,const CHashedPtr & lhs)
- {
- return rhs.m_valptr == lhs.m_valptr;
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CHashedPtr")
-#endif
-};
-
-#endif /* __EXP_HASHEDPTR_H__ */
diff --git a/source/gameengine/Expressions/EXP_IdentifierExpr.h b/source/gameengine/Expressions/EXP_IdentifierExpr.h
deleted file mode 100644
index 96ef3677cf3..00000000000
--- a/source/gameengine/Expressions/EXP_IdentifierExpr.h
+++ /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 EXP_IdentifierExpr.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_IDENTIFIEREXPR_H__
-#define __EXP_IDENTIFIEREXPR_H__
-
-#include "EXP_Expression.h"
-
-class CIdentifierExpr : public CExpression
-{
- CValue* m_idContext;
- STR_String m_identifier;
-public:
- CIdentifierExpr(const STR_String& identifier,CValue* id_context);
- virtual ~CIdentifierExpr();
-
- virtual CValue* Calculate();
- virtual bool MergeExpression(CExpression* otherexpr);
- virtual unsigned char GetExpressionID();
- virtual bool NeedsRecalculated();
- virtual CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
- virtual void ClearModified();
- virtual void BroadcastOperators(VALUE_OPERATOR op);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CIdentifierExpr")
-#endif
-};
-
-#endif /* __EXP_IDENTIFIEREXPR_H__ */
diff --git a/source/gameengine/Expressions/EXP_IfExpr.h b/source/gameengine/Expressions/EXP_IfExpr.h
deleted file mode 100644
index 43b4b8faf53..00000000000
--- a/source/gameengine/Expressions/EXP_IfExpr.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * IfExpr.h: interface for the CIfExpr class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_IfExpr.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_IFEXPR_H__
-#define __EXP_IFEXPR_H__
-
-#include "EXP_Expression.h"
-
-class CIfExpr : public CExpression
-{
- //PLUGIN_DECLARE_SERIAL_EXPRESSION (CIfExpr,CExpression)
-
-private:
- CExpression *m_guard, *m_e1, *m_e2;
-
-public:
- virtual bool MergeExpression(CExpression* otherexpr);
- CIfExpr(CExpression *guard, CExpression *e1, CExpression *e2);
- CIfExpr();
-
- virtual unsigned char GetExpressionID();
- virtual ~CIfExpr();
- virtual CValue* Calculate();
-
- virtual bool IsInside(float x,float y,float z,bool bBorderInclude=true);
- virtual bool NeedsRecalculated();
-
-
- virtual CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
- virtual void ClearModified();
- virtual void BroadcastOperators(VALUE_OPERATOR op);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CIfExpr")
-#endif
-};
-
-#endif /* __EXP_IFEXPR_H__ */
diff --git a/source/gameengine/Expressions/EXP_InputParser.h b/source/gameengine/Expressions/EXP_InputParser.h
deleted file mode 100644
index 80471009a16..00000000000
--- a/source/gameengine/Expressions/EXP_InputParser.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Parser.h: interface for the CParser class.
- * Eindhoven University of Technology 1997
- * OOPS team (Serge vd Boom, Erwin Coumans, Tom Geelen, Wynke Stuylemeier)
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_InputParser.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_INPUTPARSER_H__
-#define __EXP_INPUTPARSER_H__
-
-class CParser;
-#include "EXP_Expression.h"
-
-
-class CParser
-{
-public:
- CParser();
- virtual ~CParser();
-
- float GetFloat(STR_String& txt);
- CValue* GetValue(STR_String& txt, bool bFallbackToText=false);
- CExpression* ProcessText(const char *intext);
- void SetContext(CValue* context);
-
-private:
- enum symbols {
- errorsym,
- lbracksym,
- rbracksym,
- cellsym,
- commasym,
- opsym,
- constsym,
- sumsym,
- ifsym,
- whocodedsym,
- eolsym,
- idsym
- }; // all kinds of symbols
-
- enum optype {
- OPmodulus,
- OPplus,
- OPminus,
- OPtimes,
- OPdivide,
- OPand,
- OPor,
- OPequal,
- OPunequal,
- OPgreater,
- OPless,
- OPgreaterequal,
- OPlessequal,
- OPnot
- }; // all kinds of operators
-
- enum consttype {
- booltype,
- inttype,
- floattype,
- stringtype
- }; // all kinds of constants
-
- int sym, // current symbol
- opkind, // kind of operator, if symbol is an operator
- constkind; // kind of operator, if symbol is a constant
-
- char ch; // current character
- int chcount; // index to character in input string
- CExpression *errmsg; // contains a errormessage, if scanner error
-
- STR_String text, // contains a copy of the original text
- const_as_string; // string representation of the symbol, if symbol is a constant
- bool boolvalue; // value of the boolean, if symbol is a constant of type boolean
- CValue* m_identifierContext;// context in which identifiers are looked up
-
-
- void ScanError(const char *str);
- CExpression* Error(const char *str);
- void NextCh();
- void TermChar(char c);
- void DigRep();
- void CharRep();
- void GrabString(int start);
- void GrabRealString(int start);
- void NextSym();
-#if 0 /* not used yet */
- int MakeInt();
-#endif
- const char *Symbol2Str(int s);
- void Term(int s);
- int Priority(int optor);
- CExpression *Ex(int i);
- CExpression *Expr();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CParser")
-#endif
-};
-
-#endif /* __EXP_INPUTPARSER_H__ */
-
diff --git a/source/gameengine/Expressions/EXP_IntValue.h b/source/gameengine/Expressions/EXP_IntValue.h
deleted file mode 100644
index a1cd96a888e..00000000000
--- a/source/gameengine/Expressions/EXP_IntValue.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * IntValue.h: interface for the CIntValue class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_IntValue.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_INTVALUE_H__
-#define __EXP_INTVALUE_H__
-
-
-#include "EXP_Value.h"
-
-typedef long long cInt;
-
-class CIntValue : public CPropValue
-{
- //PLUGIN_DECLARE_SERIAL (CIntValue,CValue)
-
-public:
- virtual const STR_String& GetText();
- virtual double GetNumber();
- virtual int GetValueType();
-
- cInt GetInt();
- CIntValue();
- CIntValue(cInt innie);
- CIntValue(cInt innie,
- const char *name,
- AllocationTYPE alloctype=CValue::HEAPVALUE);
-
- virtual CValue* Calc(VALUE_OPERATOR op,
- CValue *val);
-
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype,
- VALUE_OPERATOR op,
- CValue *val);
-
- virtual void SetValue(CValue* newval);
-
- void Configure(CValue* menuvalue);
- void AddConfigurationData(CValue* menuvalue);
- virtual CValue* GetReplica();
-
-#ifdef WITH_PYTHON
- virtual PyObject* ConvertValueToPython();
-#endif
-
-protected:
- virtual ~CIntValue();
-
-private:
- cInt m_int;
- STR_String* m_pstrRep;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CIntValue")
-#endif
-};
-
-#endif /* __EXP_INTVALUE_H__ */
diff --git a/source/gameengine/Expressions/EXP_ListValue.h b/source/gameengine/Expressions/EXP_ListValue.h
deleted file mode 100644
index f5421066f62..00000000000
--- a/source/gameengine/Expressions/EXP_ListValue.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * ListValue.h: interface for the CListValue class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_ListValue.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_LISTVALUE_H__
-#define __EXP_LISTVALUE_H__
-
-#include "EXP_Value.h"
-
-class CListValue : public CPropValue
-{
- Py_Header
- //PLUGIN_DECLARE_SERIAL (CListValue,CValue)
-
-public:
- CListValue();
- virtual ~CListValue();
-
- void AddConfigurationData(CValue* menuvalue);
- void Configure(CValue* menuvalue);
- void Add(CValue* value);
-
- /** \attention not implemented yet :( */
- virtual CValue* Calc(VALUE_OPERATOR op,CValue *val);
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype,
- VALUE_OPERATOR op,
- CValue* val);
- virtual double GetNumber();
- virtual int GetValueType();
- virtual CValue* GetReplica();
-
-public:
- void MergeList(CListValue* otherlist);
- bool RemoveValue(CValue* val);
- void SetReleaseOnDestruct(bool bReleaseContents);
- bool SearchValue(CValue* val);
-
- CValue* FindValue(const STR_String & name);
- CValue* FindValue(const char *name);
-
- void ReleaseAndRemoveAll();
- virtual void SetModified(bool bModified);
- virtual inline bool IsModified();
- void Remove(int i);
- void Resize(int num);
- void SetValue(int i,CValue* val);
- CValue* GetValue(int i) { assertd(i < m_pValueArray.size()); return m_pValueArray[i]; }
- int GetCount() { return m_pValueArray.size(); }
- virtual const STR_String & GetText();
-
- bool CheckEqual(CValue* first,CValue* second);
-
-#ifdef WITH_PYTHON
- virtual PyObject *py_repr(void) {
- PyObject *py_proxy= this->GetProxy();
- PyObject *py_list= PySequence_List(py_proxy);
- PyObject *py_string= PyObject_Repr(py_list);
- Py_DECREF(py_list);
- Py_DECREF(py_proxy);
- return py_string;
- }
-
- KX_PYMETHOD_O(CListValue,append);
- KX_PYMETHOD_NOARGS(CListValue,reverse);
- KX_PYMETHOD_O(CListValue,index);
- KX_PYMETHOD_O(CListValue,count);
- KX_PYMETHOD_VARARGS(CListValue,get);
- KX_PYMETHOD_O(CListValue,from_id);
-#endif
-
-private:
-
- std::vector<CValue*> m_pValueArray;
- bool m_bReleaseContents;
-};
-
-#endif /* __EXP_LISTVALUE_H__ */
-
diff --git a/source/gameengine/Expressions/EXP_ListWrapper.h b/source/gameengine/Expressions/EXP_ListWrapper.h
deleted file mode 100644
index e4c97691acb..00000000000
--- a/source/gameengine/Expressions/EXP_ListWrapper.h
+++ /dev/null
@@ -1,109 +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.
- *
- * Contributor(s): Porteries Tristan.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file EXP_ListWrapper.h
- * \ingroup expressions
- */
-
-#ifdef WITH_PYTHON
-
-#ifndef __EXP_LISTWRAPPER_H__
-#define __EXP_LISTWRAPPER_H__
-
-#include "EXP_Value.h"
-
-class CListWrapper : public CValue
-{
- Py_Header
-private:
- /** The client instance passed as first argument of each callback.
- * We use a void * instead of a template to avoid to declare this class
- * for each use in KX_PythonInitTypes.
- */
- void *m_client;
-
- // The python object which owned this list.
- PyObject *m_base;
-
- /// Returns true if the list is still valid, else each call will raise an error.
- bool (*m_checkValid)(void *);
-
- /// Returns the list size.
- int (*m_getSize)(void *);
-
- /// Returns the list item for the giving index.
- PyObject *(*m_getItem)(void *, int);
-
- /// Returns name item for the giving index, used for python operator list["name"].
- const char *(*m_getItemName)(void *, int);
-
- /// Sets the nex item to the index place, return false when failed item conversion.
- bool (*m_setItem)(void *, int, PyObject *);
-
-public:
- CListWrapper(void *client,
- PyObject *base,
- bool (*checkValid)(void *),
- int (*getSize)(void *),
- PyObject *(*getItem)(void *, int),
- const char *(*getItemName)(void *, int),
- bool (*setItem)(void *, int, PyObject *));
- ~CListWrapper();
-
- /// \section Python Interface
- bool CheckValid();
- int GetSize();
- PyObject *GetItem(int index);
- const char *GetItemName(int index);
- bool SetItem(int index, PyObject *item);
- bool AllowSetItem();
- bool AllowGetItemByName();
-
- /// \section CValue Inherited Functions.
- virtual const STR_String &GetText();
- virtual void SetName(const char *name);
- virtual STR_String &GetName();
- virtual CValue *GetReplica();
- virtual CValue *Calc(VALUE_OPERATOR op, CValue *val);
- virtual CValue *CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
- virtual double GetNumber();
- virtual int GetValueType();
- virtual PyObject *py_repr();
-
- // Python list operators.
- static PySequenceMethods py_as_sequence;
- // Python dictionnary operators.
- static PyMappingMethods py_as_mapping;
-
- static Py_ssize_t py_len(PyObject *self);
- static PyObject *py_get_item(PyObject *self, Py_ssize_t index);
- static int py_set_item(PyObject *self, Py_ssize_t index, PyObject *value);
- static PyObject *py_mapping_subscript(PyObject *self, PyObject *key);
- static int py_mapping_ass_subscript(PyObject *self, PyObject *key, PyObject *value);
- static int py_contains(PyObject *self, PyObject *key);
-
- KX_PYMETHOD_VARARGS(CListWrapper, Get);
-};
-
-#endif // __EXP_LISTWRAPPER_H__
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Expressions/EXP_Operator1Expr.h b/source/gameengine/Expressions/EXP_Operator1Expr.h
deleted file mode 100644
index 9a05ce9c0c4..00000000000
--- a/source/gameengine/Expressions/EXP_Operator1Expr.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Operator1Expr.h: interface for the COperator1Expr class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_Operator1Expr.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_OPERATOR1EXPR_H__
-#define __EXP_OPERATOR1EXPR_H__
-
-#include "EXP_Expression.h"
-
-class COperator1Expr : public CExpression
-{
- //PLUGIN_DECLARE_SERIAL_EXPRESSION (COperator1Expr,CExpression)
-
-
-
-public:
- virtual bool MergeExpression(CExpression* otherexpr);
- virtual void BroadcastOperators(VALUE_OPERATOR op);
-
- virtual unsigned char GetExpressionID() { return COPERATOR1EXPRESSIONID; }
- CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
- //virtual bool IsInside(float x,float y,float z,bool bBorderInclude = true);
- virtual bool NeedsRecalculated();
- void ClearModified() {
- if (m_lhs)
- m_lhs->ClearModified();
- }
- virtual CValue* Calculate();
- COperator1Expr(VALUE_OPERATOR op, CExpression *lhs);
- COperator1Expr();
- virtual ~COperator1Expr();
-
-
-
-private:
- VALUE_OPERATOR m_op;
- CExpression * m_lhs;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:")
-#endif
-};
-
-#endif /* __EXP_OPERATOR1EXPR_H__ */
diff --git a/source/gameengine/Expressions/EXP_Operator2Expr.h b/source/gameengine/Expressions/EXP_Operator2Expr.h
deleted file mode 100644
index cd7a492fde0..00000000000
--- a/source/gameengine/Expressions/EXP_Operator2Expr.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Operator2Expr.h: interface for the COperator2Expr class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_Operator2Expr.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_OPERATOR2EXPR_H__
-#define __EXP_OPERATOR2EXPR_H__
-
-
-#include "EXP_Expression.h"
-#include "EXP_Value.h" // Added by ClassView
-
-class COperator2Expr : public CExpression
-{
- //PLUGIN_DECLARE_SERIAL_EXPRESSION (COperator2Expr,CExpression)
-
-public:
- virtual bool MergeExpression(CExpression* otherexpr);
- virtual unsigned char GetExpressionID() { return COPERATOR2EXPRESSIONID; }
- virtual void BroadcastOperators(VALUE_OPERATOR op);
- CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
- //virtual bool IsInside(float x,float y,float z,bool bBorderInclude=true);
- //virtual bool IsLeftInside(float x,float y,float z,bool bBorderInclude);
- //virtual bool IsRightInside(float x,float y,float z,bool bBorderInclude);
- bool NeedsRecalculated();
- void ClearModified() {
- if (m_lhs)
- m_lhs->ClearModified();
- if (m_rhs)
- m_rhs->ClearModified();
- }
- virtual CValue* Calculate();
- COperator2Expr(VALUE_OPERATOR op, CExpression *lhs, CExpression *rhs);
- COperator2Expr();
- virtual ~COperator2Expr();
-
-
-protected:
- CExpression * m_rhs;
- CExpression * m_lhs;
- CValue* m_cached_calculate; // cached result
-
-private:
- VALUE_OPERATOR m_op;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:COperator2Expr")
-#endif
-};
-
-#endif /* __EXP_OPERATOR2EXPR_H__ */
-
diff --git a/source/gameengine/Expressions/EXP_PyObjectPlus.h b/source/gameengine/Expressions/EXP_PyObjectPlus.h
deleted file mode 100644
index 32dc79cf6eb..00000000000
--- a/source/gameengine/Expressions/EXP_PyObjectPlus.h
+++ /dev/null
@@ -1,648 +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 EXP_PyObjectPlus.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_PYOBJECTPLUS_H__
-#define __EXP_PYOBJECTPLUS_H__
-
-/* for now keep weakrefs optional */
-#define USE_WEAKREFS
-
-
-#ifndef __cplusplus // c++ only
-#error Must be compiled with C++
-#endif
-
-#include "EXP_Python.h"
-#include "STR_String.h"
-#include "MT_Vector3.h"
-#include "SG_QList.h"
-#include <stddef.h>
-
-#ifdef WITH_PYTHON
-#ifdef USE_MATHUTILS
-extern "C" {
-#include "../../blender/python/mathutils/mathutils.h" /* so we can have mathutils callbacks */
-#include "../../blender/python/generic/py_capi_utils.h" /* for PyC_LineSpit only */
-}
-#endif
-
-#define MAX_PROP_NAME 64
-
-/* Use with ShowDeprecationWarning macro */
-typedef struct {
- bool warn_done;
- void *link;
-} WarnLink;
-
-#define ShowDeprecationWarning(old_way, new_way) \
-{ \
- static WarnLink wlink = {false, NULL}; \
- if ((PyObjectPlus::m_ignore_deprecation_warnings || wlink.warn_done)==0) \
- { \
- PyObjectPlus::ShowDeprecationWarning_func(old_way, new_way); \
- \
- WarnLink *wlink_last= PyObjectPlus::GetDeprecationWarningLinkLast(); \
- wlink.warn_done = true; \
- wlink.link = NULL; \
- \
- if (wlink_last) { \
- wlink_last->link= (void *)&(wlink); \
- PyObjectPlus::SetDeprecationWarningLinkLast(&(wlink)); \
- } \
- else { \
- PyObjectPlus::SetDeprecationWarningFirst(&(wlink)); \
- PyObjectPlus::SetDeprecationWarningLinkLast(&(wlink)); \
- } \
- } \
-} \
-
-
-
-typedef struct PyObjectPlus_Proxy {
- PyObject_HEAD /* required python macro */
- class PyObjectPlus *ref; // pointer to GE object, it holds a reference to this proxy
- void *ptr; // optional pointer to generic structure, the structure holds no reference to this proxy
- bool py_owns; // true if the object pointed by ref should be deleted when the proxy is deleted
- bool py_ref; // true if proxy is connected to a GE object (ref is used)
-#ifdef USE_WEAKREFS
- PyObject *in_weakreflist; // weak reference enabler
-#endif
-} PyObjectPlus_Proxy;
-
-#define BGE_PROXY_ERROR_MSG "Blender Game Engine data has been freed, cannot use this python variable"
-#define BGE_PROXY_REF(_self) (((PyObjectPlus_Proxy *)_self)->ref)
-#define BGE_PROXY_PTR(_self) (((PyObjectPlus_Proxy *)_self)->ptr)
-#define BGE_PROXY_PYOWNS(_self) (((PyObjectPlus_Proxy *)_self)->py_owns)
-#define BGE_PROXY_PYREF(_self) (((PyObjectPlus_Proxy *)_self)->py_ref)
-#ifdef USE_WEAKREFS
-# define BGE_PROXY_WKREF(_self) (((PyObjectPlus_Proxy *)_self)->in_weakreflist)
-#endif
-
-/* Note, sometimes we don't care what BGE type this is as long as its a proxy */
-#define BGE_PROXY_CHECK_TYPE(_type) ((_type)->tp_dealloc == PyObjectPlus::py_base_dealloc)
-
-/* Opposite of BGE_PROXY_REF */
-#define BGE_PROXY_FROM_REF(_self) (((PyObjectPlus *)_self)->GetProxy())
-/* Same as 'BGE_PROXY_REF' but doesn't incref. */
-#define BGE_PROXY_FROM_REF_BORROW(_self) _bge_proxy_from_ref_borrow((void *)_self)
-
-
-// This must be the first line of each
-// PyC++ class
-// AttributesPtr correspond to attributes of proxy generic pointer
-// each PyC++ class must be registered in KX_PythonInitTypes.cpp
-#define __Py_Header \
-public: \
- static PyTypeObject Type; \
- static PyMethodDef Methods[]; \
- static PyAttributeDef Attributes[]; \
- virtual PyTypeObject *GetType(void) { \
- return &Type; \
- } \
- virtual PyObject *GetProxy() { \
- return GetProxyPlus_Ext(this, &Type, NULL); \
- } \
- virtual PyObject *NewProxy(bool py_owns) { \
- return NewProxyPlus_Ext(this, &Type, NULL, py_owns); \
- } \
-
-// leave above line empty (macro)!
-// use this macro for class that use generic pointer in proxy
-// GetProxy() and NewProxy() must be defined to set the correct pointer in the proxy
-#define __Py_HeaderPtr \
-public: \
- static PyTypeObject Type; \
- static PyMethodDef Methods[]; \
- static PyAttributeDef Attributes[]; \
- static PyAttributeDef AttributesPtr[]; \
- virtual PyTypeObject *GetType(void) { \
- return &Type; \
- } \
- virtual PyObject *GetProxy(); \
- virtual PyObject *NewProxy(bool py_owns); \
-
-// leave above line empty (macro)!
-#ifdef WITH_CXX_GUARDEDALLOC
-#define Py_Header __Py_Header \
- void *operator new(size_t num_bytes) { \
- return MEM_mallocN(num_bytes, Type.tp_name); \
- } \
- void operator delete(void *mem) { \
- MEM_freeN(mem); \
- } \
-
-#else
-# define Py_Header __Py_Header
-#endif
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#define Py_HeaderPtr __Py_HeaderPtr \
- void *operator new(size_t num_bytes) { \
- return MEM_mallocN(num_bytes, Type.tp_name); \
- } \
- void operator delete(void *mem) { \
- MEM_freeN(mem); \
- } \
-
-#else
-# define Py_HeaderPtr __Py_HeaderPtr
-#endif
-
-/*
- * nonzero values are an error for setattr
- * however because of the nested lookups we need to know if the errors
- * was because the attribute didnt exits of if there was some problem setting the value
- */
-
-#define PY_SET_ATTR_COERCE_FAIL 2
-#define PY_SET_ATTR_FAIL 1
-#define PY_SET_ATTR_MISSING -1
-#define PY_SET_ATTR_SUCCESS 0
-
-/**
- * These macros are helpful when embedding Python routines. The second
- * macro is one that also requires a documentation string
- */
-#define KX_PYMETHOD(class_name, method_name) \
- PyObject *Py##method_name(PyObject *args, PyObject *kwds); \
- static PyObject * \
- sPy##method_name(PyObject *self, PyObject *args, PyObject *kwds) { \
- if (BGE_PROXY_REF(self)==NULL) { \
- PyErr_SetString(PyExc_RuntimeError, \
- #class_name "." #method_name "() - " \
- BGE_PROXY_ERROR_MSG); \
- return NULL; \
- } \
- return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \
- } \
-
-#define KX_PYMETHOD_VARARGS(class_name, method_name) \
- PyObject *Py##method_name(PyObject *args); \
- static PyObject* \
- sPy##method_name(PyObject *self, PyObject *args) { \
- if (BGE_PROXY_REF(self)==NULL) { \
- PyErr_SetString(PyExc_RuntimeError, \
- #class_name "." #method_name "() - " \
- BGE_PROXY_ERROR_MSG); return NULL; \
- } \
- return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \
- } \
-
-#define KX_PYMETHOD_NOARGS(class_name, method_name) \
- PyObject *Py##method_name(); \
- static PyObject* \
- sPy##method_name(PyObject *self) { \
- if (BGE_PROXY_REF(self)==NULL) { \
- PyErr_SetString(PyExc_RuntimeError, \
- #class_name "." #method_name "() - " \
- BGE_PROXY_ERROR_MSG); return NULL; \
- } \
- return((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \
- } \
-
-#define KX_PYMETHOD_O(class_name, method_name) \
- PyObject *Py##method_name(PyObject *value); \
- static PyObject* \
- sPy##method_name(PyObject *self, PyObject *value) { \
- if (BGE_PROXY_REF(self)==NULL) { \
- PyErr_SetString(PyExc_RuntimeError, \
- #class_name "." #method_name "(value) - " \
- BGE_PROXY_ERROR_MSG); return NULL; \
- } \
- return((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \
- } \
-
-#define KX_PYMETHOD_DOC(class_name, method_name) \
- PyObject *Py##method_name(PyObject *args, PyObject *kwds); \
- static PyObject* \
- sPy##method_name(PyObject *self, PyObject *args, PyObject *kwds) { \
- if (BGE_PROXY_REF(self)==NULL) { \
- PyErr_SetString(PyExc_RuntimeError, \
- #class_name "." #method_name "(...) - " \
- BGE_PROXY_ERROR_MSG); return NULL; \
- } \
- return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \
- } \
- static const char method_name##_doc[]; \
-
-#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \
- PyObject *Py##method_name(PyObject *args); \
- static PyObject* \
- sPy##method_name(PyObject *self, PyObject *args) { \
- if (BGE_PROXY_REF(self)==NULL) { \
- PyErr_SetString(PyExc_RuntimeError, \
- #class_name "." #method_name "(...) - " \
- BGE_PROXY_ERROR_MSG); \
- return NULL; \
- } \
- return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args); \
- } \
- static const char method_name##_doc[]; \
-
-#define KX_PYMETHOD_DOC_O(class_name, method_name) \
- PyObject *Py##method_name(PyObject *value); \
- static PyObject * \
- sPy##method_name(PyObject *self, PyObject *value) { \
- if (BGE_PROXY_REF(self)==NULL) { \
- PyErr_SetString(PyExc_RuntimeError, \
- #class_name "." #method_name "(value) - " \
- BGE_PROXY_ERROR_MSG); \
- return NULL; \
- } \
- return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value); \
- } \
- static const char method_name##_doc[]; \
-
-#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \
- PyObject *Py##method_name(); \
- static PyObject * \
- sPy##method_name(PyObject *self) { \
- if (BGE_PROXY_REF(self)==NULL) { \
- PyErr_SetString(PyExc_RuntimeError, \
- #class_name "." #method_name "() - " \
- BGE_PROXY_ERROR_MSG); \
- return NULL; \
- } \
- return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(); \
- } \
- static const char method_name##_doc[]; \
-
-
-/* The line above should remain empty */
-/**
- * Method table macro (with doc)
- */
-#define KX_PYMETHODTABLE(class_name, method_name) \
- {#method_name, (PyCFunction) class_name::sPy##method_name, METH_VARARGS, (const char *)class_name::method_name##_doc}
-
-#define KX_PYMETHODTABLE_O(class_name, method_name) \
- {#method_name, (PyCFunction) class_name::sPy##method_name, METH_O, (const char *)class_name::method_name##_doc}
-
-#define KX_PYMETHODTABLE_NOARGS(class_name, method_name) \
- {#method_name, (PyCFunction) class_name::sPy##method_name, METH_NOARGS, (const char *)class_name::method_name##_doc}
-
-#define KX_PYMETHODTABLE_KEYWORDS(class_name, method_name) \
- {#method_name, (PyCFunction) class_name::sPy##method_name, METH_VARARGS|METH_KEYWORDS, (const char *)class_name::method_name##_doc}
-
-/**
- * Function implementation macro
- */
-#define KX_PYMETHODDEF_DOC(class_name, method_name, doc_string) \
-const char class_name::method_name##_doc[] = doc_string; \
-PyObject *class_name::Py##method_name(PyObject *args, PyObject *kwds)
-
-#define KX_PYMETHODDEF_DOC_VARARGS(class_name, method_name, doc_string) \
-const char class_name::method_name##_doc[] = doc_string; \
-PyObject *class_name::Py##method_name(PyObject *args)
-
-#define KX_PYMETHODDEF_DOC_O(class_name, method_name, doc_string) \
-const char class_name::method_name##_doc[] = doc_string; \
-PyObject *class_name::Py##method_name(PyObject *value)
-
-#define KX_PYMETHODDEF_DOC_NOARGS(class_name, method_name, doc_string) \
-const char class_name::method_name##_doc[] = doc_string; \
-PyObject *class_name::Py##method_name()
-
-/**
- * Attribute management
- */
-enum KX_PYATTRIBUTE_TYPE {
- KX_PYATTRIBUTE_TYPE_BOOL,
- KX_PYATTRIBUTE_TYPE_ENUM,
- KX_PYATTRIBUTE_TYPE_SHORT,
- KX_PYATTRIBUTE_TYPE_INT,
- KX_PYATTRIBUTE_TYPE_FLOAT,
- KX_PYATTRIBUTE_TYPE_STRING,
- KX_PYATTRIBUTE_TYPE_DUMMY,
- KX_PYATTRIBUTE_TYPE_FUNCTION,
- KX_PYATTRIBUTE_TYPE_VECTOR,
- KX_PYATTRIBUTE_TYPE_FLAG,
- KX_PYATTRIBUTE_TYPE_CHAR
-};
-
-enum KX_PYATTRIBUTE_ACCESS {
- KX_PYATTRIBUTE_RW,
- KX_PYATTRIBUTE_RO
-};
-
-struct KX_PYATTRIBUTE_DEF;
-typedef int (*KX_PYATTRIBUTE_CHECK_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
-typedef int (*KX_PYATTRIBUTE_SET_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-typedef PyObject *(*KX_PYATTRIBUTE_GET_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
-
-typedef struct KX_PYATTRIBUTE_DEF {
- const char *m_name; // name of the python attribute
- KX_PYATTRIBUTE_TYPE m_type; // type of value
- KX_PYATTRIBUTE_ACCESS m_access; // read/write access or read-only
- int m_imin; // minimum value in case of integer attributes
- // (for string: minimum string length, for flag: mask value, for float: matrix row size)
- int m_imax; // maximum value in case of integer attributes
- // (for string: maximum string length, for flag: 1 if flag is negative, float: vector/matrix col size)
- float m_fmin; // minimum value in case of float attributes
- float m_fmax; // maximum value in case of float attributes
- bool m_clamp; // enforce min/max value by clamping
- bool m_usePtr; // the attribute uses the proxy generic pointer, set at runtime
- size_t m_offset; // position of field in structure
- size_t m_size; // size of field for runtime verification (enum only)
- size_t m_length; // length of array, 1=simple attribute
- KX_PYATTRIBUTE_CHECK_FUNCTION m_checkFunction; // static function to check the assignment, returns 0 if no error
- KX_PYATTRIBUTE_SET_FUNCTION m_setFunction; // static function to check the assignment, returns 0 if no error
- KX_PYATTRIBUTE_GET_FUNCTION m_getFunction; // static function to check the assignment, returns 0 if no error
-
- // The following pointers are just used to have compile time check for attribute type.
- // It would have been good to use a union but that would require C99 compatibility
- // to initialize specific union fields through designated initializers.
- struct {
- bool *m_boolPtr;
- short int *m_shortPtr;
- int *m_intPtr;
- float *m_floatPtr;
- STR_String *m_stringPtr;
- MT_Vector3 *m_vectorPtr;
- char *m_charPtr;
- } m_typeCheck;
-} PyAttributeDef;
-
-#define KX_PYATTRIBUTE_BOOL_RW(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_BOOL_RW_CHECK(name, object, field, function) \
- { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, false, offsetof(object, field), 0, 1, &object::function, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_BOOL_RO(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RO, 0, 1, 0.f, 0.f, false, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL, NULL} }
-
-/* attribute points to a single bit of an integer field, attribute=true if bit is set */
-#define KX_PYATTRIBUTE_FLAG_RW(name, object, field, bit) \
- { name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RW, bit, 0, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLAG_RW_CHECK(name, object, field, bit, function) \
- { name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RW, bit, 0, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLAG_RO(name, object, field, bit) \
- { name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RO, bit, 0, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-
-/* attribute points to a single bit of an integer field, attribute=true if bit is set*/
-#define KX_PYATTRIBUTE_FLAG_NEGATIVE_RW(name, object, field, bit) \
- { name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RW, bit, 1, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLAG_NEGATIVE_RW_CHECK(name, object, field, bit, function) \
- { name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RW, bit, 1, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLAG_NEGATIVE_RO(name, object, field, bit) \
- { name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RO, bit, 1, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-
-// enum field cannot be mapped to pointer (because we would need a pointer for each enum)
-// use field size to verify mapping at runtime only, assuming enum size is equal to int size.
-#define KX_PYATTRIBUTE_ENUM_RW(name, min, max, clamp, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_ENUM_RW_CHECK(name, min, max, clamp, object, field, function) \
- { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_ENUM_RO(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-
-#define KX_PYATTRIBUTE_SHORT_RW(name, min, max, clamp, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_SHORT_RW_CHECK(name, min, max, clamp, object, field, function) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, 1, &object::function, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_SHORT_RO(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_SHORT_ARRAY_RW(name, min, max, clamp, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_SHORT_ARRAY_RW_CHECK(name, min, max, clamp, object, field, length, function) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, length, &object::function, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_SHORT_ARRAY_RO(name, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
-// SHORT_LIST
-#define KX_PYATTRIBUTE_SHORT_LIST_RW(name, min, max, clamp, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_SHORT_LIST_RW_CHECK(name, min, max, clamp, object, field, length, function) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, length, &object::function, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_SHORT_LIST_RO(name, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} }
-
-#define KX_PYATTRIBUTE_INT_RW(name, min, max, clamp, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_INT_RW_CHECK(name, min, max, clamp, object, field, function) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_INT_RO(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_INT_ARRAY_RW(name, min, max, clamp, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_INT_ARRAY_RW_CHECK(name, min, max, clamp, object, field, length, function) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, length, &object::function, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_INT_ARRAY_RO(name, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL, NULL, NULL} }
-// INT_LIST
-#define KX_PYATTRIBUTE_INT_LIST_RW(name, min, max, clamp, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_INT_LIST_RW_CHECK(name, min, max, clamp, object, field, length, function) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, length, &object::function, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_INT_LIST_RO(name, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} }
-
-// always clamp for float
-#define KX_PYATTRIBUTE_FLOAT_RW(name, min, max, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLOAT_RW_CHECK(name, min, max, object, field, function) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object, field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLOAT_RO(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} }
-// field must be float[n], returns a sequence
-#define KX_PYATTRIBUTE_FLOAT_ARRAY_RW(name, min, max, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLOAT_ARRAY_RW_CHECK(name, min, max, object, field, length, function) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object, field), 0, length, &object::function, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLOAT_ARRAY_RO(name, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, length, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} }
-// field must be float[n], returns a vector
-#define KX_PYATTRIBUTE_FLOAT_VECTOR_RW(name, min, max, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, length, min, max, true, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLOAT_VECTOR_RW_CHECK(name, min, max, object, field, length, function) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, length, min, max, true, false, offsetof(object, field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLOAT_VECTOR_RO(name, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, length, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} }
-// field must be float[n][n], returns a matrix
-#define KX_PYATTRIBUTE_FLOAT_MATRIX_RW(name, min, max, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, length, length, min, max, true, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field[0], NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLOAT_MATRIX_RW_CHECK(name, min, max, object, field, length, function) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, length, length, min, max, true, false, offsetof(object, field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field[0], NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_FLOAT_MATRIX_RO(name, object, field, length) \
- { name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, length, length, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field[0], NULL, NULL, NULL} }
-
-// only for STR_String member
-#define KX_PYATTRIBUTE_STRING_RW(name, min, max, clamp, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} }
-#define KX_PYATTRIBUTE_STRING_RW_CHECK(name, min, max, clamp, object, field, function) \
- { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object, field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} }
-#define KX_PYATTRIBUTE_STRING_RO(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, 1 , NULL, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} }
-
-// only for char [] array
-#define KX_PYATTRIBUTE_CHAR_RW(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_CHAR, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0.f, true, false, offsetof(object, field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, ((object *)0)->field} }
-#define KX_PYATTRIBUTE_CHAR_RW_CHECK(name, object, field, function) \
- { name, KX_PYATTRIBUTE_TYPE_CHAR, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0.f, true, false, offsetof(object, field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, ((object *)0)->field} }
-#define KX_PYATTRIBUTE_CHAR_RO(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_CHAR, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), sizeof(((object *)0)->field), 1 , NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, ((object *)0)->field} }
-
-// for MT_Vector3 member
-#define KX_PYATTRIBUTE_VECTOR_RW(name, min, max, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object, field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, &((object *)0)->field, NULL} }
-#define KX_PYATTRIBUTE_VECTOR_RW_CHECK(name, min, max, clamp, object, field, function) \
- { name, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object, field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, &((object *)0)->field, NULL} }
-#define KX_PYATTRIBUTE_VECTOR_RO(name, object, field) \
- { name, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object, field), 0, 1 , NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, &((object *)0)->field, NULL} }
-
-#define KX_PYATTRIBUTE_RW_FUNCTION(name, object, getfunction, setfunction) \
- { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0.f, false, false, 0, 0, 1, NULL, &object::setfunction, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_RO_FUNCTION(name, object, getfunction) \
- { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, 0, 0, 1, NULL, NULL, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_ARRAY_RW_FUNCTION(name, object, length, getfunction, setfunction) \
- { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0, f, false, false, 0, 0, length, NULL, &object::setfunction, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-#define KX_PYATTRIBUTE_ARRAY_RO_FUNCTION(name, object, length, getfunction) \
- { name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0, f, false, false, 0, 0, length, NULL, NULL, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
-
-
-/*------------------------------
- * PyObjectPlus
- *------------------------------ */
-typedef PyTypeObject *PyParentObject; /* Define the PyParent Object */
-
-#else // WITH_PYTHON
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#define Py_Header \
-public: \
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PyObjectPlus") \
-
-
-#define Py_HeaderPtr \
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PyObjectPlusPtr") \
-
-#else // WITH_CXX_GUARDEDALLOC
-
-#define Py_Header \
-public: \
-
-#define Py_HeaderPtr \
-public: \
-
-#endif /* WITH_CXX_GUARDEDALLOC */
-
-#endif
-
-
-// By making SG_QList the ultimate parent for PyObjectPlus objects, it
-// allows to put them in 2 different dynamic lists at the same time
-// The use of these links is interesting because they free of memory allocation
-// but it's very important not to mess up with them. If you decide that
-// the SG_QList or SG_DList component is used for something for a certain class,
-// they cannot can be used for anything else at a parent level!
-// What these lists are and what they are used for must be carefully documented
-// at the level where they are used.
-// DON'T MAKE ANY USE OF THESE LIST AT THIS LEVEL, they are already used
-// at SCA_IActuator, SCA_ISensor, SCA_IController level which rules out the
-// possibility to use them at SCA_ILogicBrick, CValue and PyObjectPlus level.
-class PyObjectPlus : public SG_QList
-{ // The PyObjectPlus abstract class
- Py_Header // Always start with Py_Header
-
-public:
- PyObjectPlus();
-
- virtual ~PyObjectPlus(); // destructor
-
-#ifdef WITH_PYTHON
- PyObject *m_proxy; /* actually a PyObjectPlus_Proxy */
-
- /* These static functions are referenced by ALL PyObjectPlus_Proxy types
- * they take the C++ reference from the PyObjectPlus_Proxy and call
- * its own virtual py_repr, py_base_dealloc, etc. functions.
- */
-
- static PyObject* py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds); /* allows subclassing */
- static void py_base_dealloc(PyObject *self);
- static PyObject* py_base_repr(PyObject *self);
-
- /* These are all virtual python methods that are defined in each class
- * Our own fake subclassing calls these on each class, then calls the parent */
- virtual PyObject* py_repr(void);
- /* subclass may overwrite this function to implement more sophisticated method of validating a proxy */
- virtual bool py_is_valid(void) { return true; }
-
- static PyObject* py_get_attrdef(PyObject *self_py, const PyAttributeDef *attrdef);
- static int py_set_attrdef(PyObject *self_py, PyObject *value, const PyAttributeDef *attrdef);
-
- /* Kindof dumb, always returns True, the false case is checked for, before this function gets accessed */
- static PyObject* pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- static PyObject *GetProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, void *ptr);
- /* self=NULL => proxy to generic pointer detached from GE object
- * if py_owns is true, the memory pointed by ptr will be deleted automatically with MEM_freeN
- * self!=NULL=> proxy attached to GE object, ptr is optional and point to a struct from which attributes can be defined
- * if py_owns is true, the object will be deleted automatically, ptr will NOT be deleted
- * (assume object destructor takes care of it) */
- static PyObject *NewProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, void *ptr, bool py_owns);
-
- static WarnLink* GetDeprecationWarningLinkFirst(void);
- static WarnLink* GetDeprecationWarningLinkLast(void);
- static void SetDeprecationWarningFirst(WarnLink* wlink);
- static void SetDeprecationWarningLinkLast(WarnLink* wlink);
- static void NullDeprecationWarning();
-
- /** enable/disable display of deprecation warnings */
- static void SetDeprecationWarnings(bool ignoreDeprecationWarnings);
- /** Shows a deprecation warning */
- static void ShowDeprecationWarning_func(const char *method, const char *prop);
- static void ClearDeprecationWarning();
-
-#endif
-
- void InvalidateProxy();
-
- /**
- * Makes sure any internal data owned by this class is deep copied.
- */
- virtual void ProcessReplica();
-
- static bool m_ignore_deprecation_warnings;
-};
-
-#ifdef WITH_PYTHON
-PyObject *PyUnicode_From_STR_String(const STR_String& str);
-
-inline PyObject *_bge_proxy_from_ref_borrow(void *self_v)
-{
- PyObject *self_proxy = BGE_PROXY_FROM_REF(self_v);
- /* this is typically _very_ bad practice,
- * however we know the proxy is owned by 'self_v' */
- self_proxy->ob_refcnt--;
- return self_proxy;
-}
-
-#endif
-
-#endif /* __EXP_PYOBJECTPLUS_H__ */
diff --git a/source/gameengine/Expressions/EXP_Python.h b/source/gameengine/Expressions/EXP_Python.h
deleted file mode 100644
index f904151085e..00000000000
--- a/source/gameengine/Expressions/EXP_Python.h
+++ /dev/null
@@ -1,82 +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 EXP_Python.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_PYTHON_H__
-#define __EXP_PYTHON_H__
-
-//#define USE_DL_EXPORT
-
-/* python redefines, quiet the compiler */
-#ifdef _XOPEN_SOURCE
-#undef _XOPEN_SOURCE
-#endif
-
-#ifdef _POSIX_C_SOURCE
-#undef _POSIX_C_SOURCE
-#endif
-
-#ifdef WITH_PYTHON
-#include "Python.h"
-
-#define USE_MATHUTILS // Blender 2.5x api will use mathutils, for a while we might want to test without it
-
-#endif
-
-#ifdef __FreeBSD__
-#include <osreldate.h>
-#if __FreeBSD_version > 500039
-#undef isalnum
-#undef isalpha
-#undef iscntrl
-#undef isdigit
-#undef isgraph
-#undef islower
-#undef isprint
-#undef ispunct
-#undef isspace
-#undef isupper
-#undef isxdigit
-#undef tolower
-#undef toupper
-#endif
-#endif
-
-#ifdef __APPLE__
-#undef isalnum
-#undef isalpha
-#undef islower
-#undef isspace
-#undef isupper
-#undef tolower
-#undef toupper
-#endif
-
-#endif /* __EXP_PYTHON_H__ */
diff --git a/source/gameengine/Expressions/EXP_PythonCallBack.h b/source/gameengine/Expressions/EXP_PythonCallBack.h
deleted file mode 100644
index f0cbcac0c6f..00000000000
--- a/source/gameengine/Expressions/EXP_PythonCallBack.h
+++ /dev/null
@@ -1,40 +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.
- *
- * Contributor(s): Porteries Tristan.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file EXP_PythonCallBack.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_PYTHON_CALLBACK_H__
-#define __EXP_PYTHON_CALLBACK_H__
-
-#include "EXP_Python.h"
-
-/** Execute each functions with at least one argument
- * \param functionlist The python list which contains callbacks.
- * \param arglist The first item in the tuple to execute callbacks (can be NULL for no arguments).
- * \param minargcount The minimum of quantity of arguments possible.
- * \param maxargcount The maximum of quantity of arguments possible.
- */
-void RunPythonCallBackList(PyObject *functionlist, PyObject **arglist, unsigned int minargcount, unsigned int maxargcount);
-
-#endif // __EXP_PYTHON_CALLBACK_H__
diff --git a/source/gameengine/Expressions/EXP_StringValue.h b/source/gameengine/Expressions/EXP_StringValue.h
deleted file mode 100644
index ca59ebf1f82..00000000000
--- a/source/gameengine/Expressions/EXP_StringValue.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * StringValue.h: interface for the CStringValue class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_StringValue.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_STRINGVALUE_H__
-#define __EXP_STRINGVALUE_H__
-
-#include "EXP_Value.h"
-
-class CStringValue : public CPropValue
-{
-
-
- //PLUGIN_DECLARE_SERIAL(CStringValue,CValue)
-public:
- /// Construction / destruction
- CStringValue();
- CStringValue(const char *txt, const char *name, AllocationTYPE alloctype = CValue::HEAPVALUE);
-
- virtual ~CStringValue() {}
- /// CValue implementation
- virtual bool IsEqual(const STR_String & other);
- virtual const STR_String & GetText();
- virtual double GetNumber();
- virtual int GetValueType();
-
- virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
- virtual void SetValue(CValue* newval) { m_strString = newval->GetText(); SetModified(true); }
- virtual CValue* GetReplica();
-#ifdef WITH_PYTHON
- virtual PyObject* ConvertValueToPython() {
- return PyUnicode_From_STR_String(m_strString);
- }
-#endif /* WITH_PYTHON */
-
-private:
- // data member
- STR_String m_strString;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CStringValue")
-#endif
-};
-
-#endif /* __EXP_STRINGVALUE_H__ */
diff --git a/source/gameengine/Expressions/EXP_Value.h b/source/gameengine/Expressions/EXP_Value.h
deleted file mode 100644
index 014fc59405f..00000000000
--- a/source/gameengine/Expressions/EXP_Value.h
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * Value.h: interface for the CValue class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_Value.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_VALUE_H__
-#define __EXP_VALUE_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include <map> // array functionality for the propertylist
-#include "STR_String.h" // STR_String class
-
-using namespace std;
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-#ifndef GEN_NO_ASSERT
-#undef assert
-#define assert(exp) ((void)NULL)
-#endif
-
-
-#ifndef GEN_NO_TRACE
-#undef trace
-#define trace(exp) ((void)NULL)
-#endif
-
-#ifndef GEN_NO_DEBUG
-#undef debug
-#define debug(exp) ((void)NULL)
-#endif
-
-#ifndef GEN_NO_ASSERTD
-#undef assertd
-#define assertd(exp) ((void)NULL)
-#endif
-
-enum VALUE_OPERATOR {
-
- VALUE_MOD_OPERATOR, // %
- VALUE_ADD_OPERATOR, // +
- VALUE_SUB_OPERATOR, // -
- VALUE_MUL_OPERATOR, // *
- VALUE_DIV_OPERATOR, // /
- VALUE_NEG_OPERATOR, // -
- VALUE_POS_OPERATOR, // +
- VALUE_AND_OPERATOR, // &&
- VALUE_OR_OPERATOR, // ||
- VALUE_EQL_OPERATOR, // ==
- VALUE_NEQ_OPERATOR, // !=
- VALUE_GRE_OPERATOR, // >
- VALUE_LES_OPERATOR, // <
- VALUE_GEQ_OPERATOR, // >=
- VALUE_LEQ_OPERATOR, // <=
- VALUE_NOT_OPERATOR, // !
- VALUE_NO_OPERATOR // no operation at all
-};
-
-enum VALUE_DATA_TYPE {
- VALUE_NO_TYPE, // abstract baseclass
- VALUE_INT_TYPE,
- VALUE_FLOAT_TYPE,
- VALUE_STRING_TYPE,
- VALUE_BOOL_TYPE,
- VALUE_ERROR_TYPE,
- VALUE_EMPTY_TYPE,
- VALUE_LIST_TYPE,
- VALUE_VOID_TYPE,
- VALUE_VECTOR_TYPE,
- VALUE_MAX_TYPE //only here to provide number of types
-};
-
-
-
-#ifdef DEBUG
-//extern int gRefCountValue; // debugonly variable to check if all CValue Refences are Dereferenced at programexit
-#endif
-
-struct HashableInt
-{
- HashableInt(int id) : mData(id) { }
-
- unsigned long Hash() const { return 0;} ////}gHash(&mData, sizeof(int));}
-
- bool operator==(HashableInt rhs) { return mData == rhs.mData; }
-
- int mData;
-};
-
-
-//
-// Bitfield that stores the flags for each CValue derived class
-//
-struct ValueFlags {
- ValueFlags() :
- Modified(true),
- Selected(false),
- Affected(false),
- ReleaseRequested(false),
- Error(false),
- RefCountDisabled(false),
- HasProperties(false),
- HasName(false),
- Visible(true),
- CustomFlag1(false),
- CustomFlag2(false)
- {
- }
-
- unsigned short Modified : 1;
- unsigned short Selected : 1;
- unsigned short Affected : 1;
- unsigned short ReleaseRequested : 1;
- unsigned short Error : 1;
- unsigned short RefCountDisabled : 1;
- unsigned short HasProperties : 1;
- unsigned short HasName : 1;
- unsigned short Visible : 1;
- unsigned short CustomFlag1 : 1;
- unsigned short CustomFlag2 : 1;
-
-
-};
-
-/**
- * Base Class for all Actions performed on CValue's. Can be extended for undo/redo system in future.
- */
-class CAction
-{
-public:
- CAction() {
- };
- virtual ~CAction() {
- };
- virtual void Execute() const =0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CAction")
-#endif
-};
-
-
-#include "EXP_PyObjectPlus.h"
-#ifdef WITH_PYTHON
-#include "object.h"
-#endif
-
-/**
- * Baseclass CValue
- *
- * Together with CExpression, CValue and it's derived classes can be used to
- * parse expressions into a parsetree with error detecting/correcting capabilities
- * also expandable by a CFactory pluginsystem
- *
- * Base class for all editor functionality, flexible object type that allows
- * calculations and uses reference counting for memory management.
- *
- * Features:
- * - Reference Counting (AddRef() / Release())
- * - Calculations (Calc() / CalcFinal())
- * - Configuration (Configure())
- * - Serialization (EdSerialize() / EdIdSerialize() / EdPtrSerialize() and macro PLUGIN_DECLARE_SERIAL
- * - Property system (SetProperty() / GetProperty() / FindIdentifier())
- * - Replication (GetReplica())
- * - Flags (IsSelected() / IsModified() / SetSelected()...)
- *
- * - Some small editor-specific things added
- * - A helperclass CompressorArchive handles the serialization
- *
- */
-class CValue : public PyObjectPlus
-
-{
-Py_Header
-public:
- enum AllocationTYPE {
- STACKVALUE = 0,
- HEAPVALUE = 1
- };
-
- enum DrawTYPE {
- STARTFRAME = 0,
- ENDFRAME = 1,
- INTERFRAME = 2
- };
-
-
- // Construction / Destruction
- CValue();
-
-#ifdef WITH_PYTHON
- //static PyObject *PyMake(PyObject *, PyObject *);
- virtual PyObject *py_repr(void)
- {
- return PyUnicode_From_STR_String(GetText());
- }
-
- virtual PyObject *ConvertValueToPython() {
- return NULL;
- }
-
- virtual CValue *ConvertPythonToValue(PyObject *pyobj, const bool do_type_exception, const char *error_prefix);
-
- static PyObject *pyattr_get_name(void *self, const KX_PYATTRIBUTE_DEF *attrdef);
-
- virtual PyObject *ConvertKeysToPython( void );
-#endif /* WITH_PYTHON */
-
-
-
- // Expression Calculation
- virtual CValue* Calc(VALUE_OPERATOR op, CValue *val) = 0;
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val) = 0;
- virtual void SetOwnerExpression(class CExpression* expr);
-
-
-
- void Execute(const CAction& a)
- {
- a.Execute();
- };
-
- /// Reference Counting
- int GetRefCount()
- {
- return m_refcount;
- }
-
- // Add a reference to this value
- CValue *AddRef()
- {
- // Increase global reference count, used to see at the end of the program
- // if all CValue-derived classes have been dereferenced to 0
- //debug(gRefCountValue++);
-#ifdef DEBUG
- //gRefCountValue++;
-#endif
- m_refcount++;
- return this;
- }
-
- // Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
- int Release()
- {
- // Decrease global reference count, used to see at the end of the program
- // if all CValue-derived classes have been dereferenced to 0
- //debug(gRefCountValue--);
-#ifdef DEBUG
- //gRefCountValue--;
-#endif
- // Decrease local reference count, if it reaches 0 the object should be freed
- if (--m_refcount > 0)
- {
- // Reference count normal, return new reference count
- return m_refcount;
- }
- else
- {
- // Reference count reached 0, delete ourselves and return 0
- // MT_assert(m_refcount==0, "Reference count reached sub-zero, object released too much");
-
- delete this;
- return 0;
- }
- }
-
-
- /// Property Management
- virtual void SetProperty(const STR_String& name,CValue* ioProperty); // Set property <ioProperty>, overwrites and releases a previous property with the same name if needed
- virtual void SetProperty(const char* name,CValue* ioProperty);
- virtual CValue* GetProperty(const char* inName); // Get pointer to a property with name <inName>, returns NULL if there is no property named <inName>
- virtual CValue* GetProperty(const STR_String & inName);
- const STR_String& GetPropertyText(const STR_String & inName); // Get text description of property with name <inName>, returns an empty string if there is no property named <inName>
- float GetPropertyNumber(const STR_String& inName,float defnumber);
- virtual bool RemoveProperty(const char *inName); // Remove the property named <inName>, returns true if the property was succesfully removed, false if property was not found or could not be removed
- virtual vector<STR_String> GetPropertyNames();
- virtual void ClearProperties(); // Clear all properties
-
- virtual void SetPropertiesModified(bool inModified); // Set all properties' modified flag to <inModified>
- virtual bool IsAnyPropertyModified(); // Check if any of the properties in this value have been modified
-
- virtual CValue* GetProperty(int inIndex); // Get property number <inIndex>
- virtual int GetPropertyCount(); // Get the amount of properties assiocated with this value
-
- virtual CValue* FindIdentifier(const STR_String& identifiername);
- /** Set the wireframe color of this value depending on the CSG
- * operator type <op>
- * \attention: not implemented */
- virtual void SetColorOperator(VALUE_OPERATOR op);
-
- virtual const STR_String & GetText() = 0;
- virtual double GetNumber() = 0;
- virtual int GetValueType(); // Get Prop value type
- double* ZeroVector() { return m_sZeroVec; }
- virtual double* GetVector3(bool bGetTransformedVec = false);
-
- virtual STR_String& GetName() = 0; // Retrieve the name of the value
- virtual void SetName(const char *name) = 0; // Set the name of the value
- /** Sets the value to this cvalue.
- * \attention this particular function should never be called. Why not abstract? */
- virtual void SetValue(CValue* newval);
- virtual CValue* GetReplica() =0;
- virtual void ProcessReplica();
- //virtual CValue* Copy() = 0;
-
- STR_String op2str(VALUE_OPERATOR op);
-
- // setting / getting flags
- inline void SetSelected(bool bSelected) { m_ValFlags.Selected = bSelected; }
- virtual void SetModified(bool bModified) { m_ValFlags.Modified = bModified; }
- virtual void SetAffected(bool bAffected=true) { m_ValFlags.Affected = bAffected; }
- inline void SetReleaseRequested(bool bReleaseRequested) { m_ValFlags.ReleaseRequested=bReleaseRequested; }
- inline void SetError(bool err) { m_ValFlags.Error=err; }
- inline void SetVisible (bool vis) { m_ValFlags.Visible=vis; }
-
- virtual bool IsModified() { return m_ValFlags.Modified; }
- inline bool IsError() { return m_ValFlags.Error; }
- virtual bool IsAffected() { return m_ValFlags.Affected || m_ValFlags.Modified; }
- virtual bool IsSelected() { return m_ValFlags.Selected; }
- inline bool IsReleaseRequested() { return m_ValFlags.ReleaseRequested; }
- virtual bool IsVisible() { return m_ValFlags.Visible;}
- virtual void SetCustomFlag1(bool bCustomFlag) { m_ValFlags.CustomFlag1 = bCustomFlag;}
- virtual bool IsCustomFlag1() { return m_ValFlags.CustomFlag1;}
-
- virtual void SetCustomFlag2(bool bCustomFlag) { m_ValFlags.CustomFlag2 = bCustomFlag;}
- virtual bool IsCustomFlag2() { return m_ValFlags.CustomFlag2;}
-
-protected:
- virtual void DisableRefCount(); // Disable reference counting for this value
- //virtual void AddDataToReplica(CValue* replica);
- virtual ~CValue();
-private:
- // Member variables
- std::map<STR_String,CValue*>* m_pNamedPropertyArray; // Properties for user/game etc
- ValueFlags m_ValFlags; // Frequently used flags in a bitfield (low memoryusage)
- int m_refcount; // Reference Counter
- static double m_sZeroVec[3];
-
-};
-
-
-
-//
-// Declare a CValue or CExpression or CWhatever to be serialized by the editor.
-//
-// This macro introduces the EdSerialize() function (which must be implemented by
-// the client) and the EdIdSerialize() function (which is implemented by this macro).
-//
-// The generated Copy() function returns a pointer to <root_base_class_name> type
-// of object. So, for *any* CValue-derived object this should be set to CValue,
-// for *any* CExpression-derived object this should be set to CExpression.
-//
-#define PLUGIN_DECLARE_SERIAL(class_name, root_base_class_name) \
-public: \
- virtual root_base_class_name *Copy() { \
- return new class_name; \
- } \
- virtual bool EdSerialize(CompressorArchive& arch, \
- class CFactoryManager* facmgr, \
- bool bIsStoring); \
- virtual bool EdIdSerialize(CompressorArchive& arch, \
- class CFactoryManager* facmgr, \
- bool bIsStoring) \
- { \
- if (bIsStoring) \
- arch.StoreString(#class_name); \
- return false; \
- } \
-
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-
-// CPropValue is a CValue derived class, that implements the identification (String name)
-// SetName() / GetName(),
-// normal classes should derive from CPropValue, real lightweight classes straight from CValue
-
-
-class CPropValue : public CValue
-{
-public:
- CPropValue() :
- CValue(),
- m_strNewName()
-
- {
- }
-
- virtual ~CPropValue()
- {
- }
-
- virtual void SetName(const char *name) {
- m_strNewName = name;
- }
-
- virtual STR_String& GetName() {
- //STR_String namefromprop = GetPropertyText("Name");
- //if (namefromprop.Length() > 0)
- // return namefromprop;
- return m_strNewName;
- } // name of Value
-
-protected:
- STR_String m_strNewName; // Identification
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CPropValue")
-#endif
-};
-
-#endif /* __EXP_VALUE_H__ */
diff --git a/source/gameengine/Expressions/EXP_VectorValue.h b/source/gameengine/Expressions/EXP_VectorValue.h
deleted file mode 100644
index d87d5097156..00000000000
--- a/source/gameengine/Expressions/EXP_VectorValue.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * VectorValue.h: interface for the CVectorValue class.
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-/** \file EXP_VectorValue.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_VECTORVALUE_H__
-#define __EXP_VECTORVALUE_H__
-
-#include "EXP_Value.h"
-
-#define KX_X 0
-#define KX_Y 1
-#define KX_Z 2
-
-
-class CVectorValue : public CPropValue
-{
- //PLUGIN_DECLARE_SERIAL(CVectorValue,CValue)
-
-public:
- //void Transform(rcMatrix4x4 mat);
- virtual void SetValue(CValue* newval);
- void SetVector(double newvec[]);
- void Configure(CValue* menuvalue);
- virtual double* GetVector3(bool bGetTransformedVec=false);
- virtual double GetNumber();
- virtual int GetValueType();
-
- CValue* Calc(VALUE_OPERATOR op, CValue *val) {
- return val->CalcFinal(VALUE_VECTOR_TYPE, op, this);
- }
-
- CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
-
-
- CVectorValue(double vec[3], const char *name,AllocationTYPE alloctype=CValue::HEAPVALUE);
- CVectorValue() {};
-
- CVectorValue(double vec[3], AllocationTYPE alloctype=CValue::HEAPVALUE);
- CVectorValue(float x,float y,float z, AllocationTYPE alloctype = CValue::HEAPVALUE);
- virtual ~CVectorValue();
- //virtual bool ExportT3D(File *txtfile,bool bNoName=false);
- void AddConfigurationData(CValue* menuvalue);
-
-
-
- virtual CValue* GetReplica();
- virtual const STR_String & GetText();
-
-#if 0
- void SnapPoint(float num,int snap)
- {
- if (num > 0) num += ((float)snap / 2);
- else num -= ((float)snap / 2);
- num = (long)(((long)(num / snap)) * snap);
- };
-
- void SnapPosition(const double snapvec[])
- {
-
- if (snapvec[KX_X] >= 1)
- SnapPoint(m_vec[KX_X],snapvec[KX_X]);
- if (snapvec[KX_Y] >= 1)
- SnapPoint(m_vec[KX_Y],snapvec[KX_Y]);
- if (snapvec[KX_Z] >= 1)
- SnapPoint(m_vec[KX_Z],snapvec[KX_Z]);
-
- }
-#endif
-
-protected:
- double m_vec[3];
- double m_transformedvec[3];
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CVectorValue")
-#endif
-};
-
-#endif /* __EXP_VECTORVALUE_H__ */
diff --git a/source/gameengine/Expressions/EXP_VoidValue.h b/source/gameengine/Expressions/EXP_VoidValue.h
deleted file mode 100644
index 8b2c29488d7..00000000000
--- a/source/gameengine/Expressions/EXP_VoidValue.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * VoidValue.h: interface for the CVoidValue class.
- *
- * ***** 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 EXP_VoidValue.h
- * \ingroup expressions
- */
-
-#ifndef __EXP_VOIDVALUE_H__
-#define __EXP_VOIDVALUE_H__
-
-#include "EXP_Value.h"
-
-//
-// Void value, used to transport *any* type of data
-//
-class CVoidValue : public CPropValue
-{
- //PLUGIN_DECLARE_SERIAL (CVoidValue,CValue)
-
-public:
- /// Construction/destruction
- CVoidValue() : m_bDeleteOnDestruct(false), m_pAnything(NULL) { }
- CVoidValue(void *voidptr, bool bDeleteOnDestruct, AllocationTYPE alloctype) :
- m_bDeleteOnDestruct(bDeleteOnDestruct),
- m_pAnything(voidptr)
- {
- if (alloctype == STACKVALUE) {
- CValue::DisableRefCount();
- }
- }
- virtual ~CVoidValue(); /* Destruct void value, delete memory if we're owning it */
-
- /// Value -> String or number
- virtual const STR_String & GetText(); /* Get string description of void value (unimplemented) */
- virtual double GetNumber() { return -1; }
- virtual int GetValueType() { return VALUE_VOID_TYPE; }
-
- /// Value calculation
- virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue* val);
-
- /// Value replication
- virtual CValue* GetReplica();
-
- /// Data members
- bool m_bDeleteOnDestruct;
- void* m_pAnything;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CVoidValue")
-#endif
-};
-
-#endif /* __EXP_VOIDVALUE_H__ */
diff --git a/source/gameengine/Expressions/intern/BoolValue.cpp b/source/gameengine/Expressions/intern/BoolValue.cpp
deleted file mode 100644
index 1523a9212ba..00000000000
--- a/source/gameengine/Expressions/intern/BoolValue.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/** \file gameengine/Expressions/BoolValue.cpp
- * \ingroup expressions
- */
-
-// BoolValue.cpp: implementation of the CBoolValue class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include "EXP_BoolValue.h"
-#include "EXP_StringValue.h"
-#include "EXP_ErrorValue.h"
-#include "EXP_VoidValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-const STR_String CBoolValue::sTrueString = "TRUE";
-const STR_String CBoolValue::sFalseString = "FALSE";
-
-CBoolValue::CBoolValue()
-/*
- * pre: false
- * effect: constructs a new CBoolValue
- */
-{
- trace("Bool constructor error");
-}
-
-
-
-CBoolValue::CBoolValue(bool inBool)
-: m_bool(inBool)
-{
-} // Constructs a new CBoolValue containing <inBool>
-
-
-
-CBoolValue::CBoolValue(bool innie,const char *name,AllocationTYPE alloctype)
-{
- m_bool = innie;
- SetName(name);
-
- if (alloctype == CValue::STACKVALUE)
- CValue::DisableRefCount();
-}
-
-
-
-void CBoolValue::SetValue(CValue* newval)
-{
- m_bool = (newval->GetNumber() != 0);
- SetModified(true);
-}
-
-
-
-CValue* CBoolValue::Calc(VALUE_OPERATOR op, CValue *val)
-/*
-pre:
-ret: a new object containing the result of applying operator op to this
-object and val
-*/
-{
- switch (op)
- {
- case VALUE_POS_OPERATOR:
- case VALUE_NEG_OPERATOR:
- {
- return new CErrorValue (op2str(op) + GetText());
- break;
- }
- case VALUE_NOT_OPERATOR:
- {
- return new CBoolValue (!m_bool);
- break;
- }
- default:
- {
- return val->CalcFinal(VALUE_BOOL_TYPE, op, this);
- break;
- }
- }
-}
-
-
-
-CValue* CBoolValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
-/*
-pre: the type of val is dtype
-ret: a new object containing the result of applying operator op to val and
-this object
-*/
-{
- CValue *ret;
-
- switch (dtype) {
- case VALUE_EMPTY_TYPE:
- case VALUE_BOOL_TYPE:
- {
- switch (op) {
- case VALUE_AND_OPERATOR:
- {
- ret = new CBoolValue (((CBoolValue *) val)->GetBool() && m_bool);
- break;
- }
- case VALUE_OR_OPERATOR:
- {
- ret = new CBoolValue (((CBoolValue *) val)->GetBool() || m_bool);
- break;
- }
- case VALUE_EQL_OPERATOR:
- {
- ret = new CBoolValue (((CBoolValue *) val)->GetBool() == m_bool);
- break;
- }
- case VALUE_NEQ_OPERATOR:
- {
- ret = new CBoolValue (((CBoolValue *) val)->GetBool() != m_bool);
- break;
- }
- case VALUE_NOT_OPERATOR:
- {
- return new CBoolValue (!m_bool);
- break;
- }
- default:
- {
- ret = new CErrorValue(val->GetText() + op2str(op) +
- "[operator not allowed on booleans]");
- break;
- }
- }
- break;
- }
- case VALUE_STRING_TYPE:
- {
- switch (op) {
- case VALUE_ADD_OPERATOR:
- {
- ret = new CStringValue(val->GetText() + GetText(),"");
- break;
- }
- default:
- {
- ret = new CErrorValue(val->GetText() + op2str(op) + "[Only + allowed on boolean and string]");
- break;
- }
- }
- break;
- }
- default:
- ret = new CErrorValue("[type mismatch]" + op2str(op) + GetText());
- }
-
- return ret;
-}
-
-
-
-bool CBoolValue::GetBool()
-/*
-pre:
-ret: the bool stored in the object
-*/
-{
- return m_bool;
-}
-
-
-
-double CBoolValue::GetNumber()
-{
- return (double)m_bool;
-}
-
-
-
-int CBoolValue::GetValueType()
-{
- return VALUE_BOOL_TYPE;
-}
-
-
-
-const STR_String& CBoolValue::GetText()
-{
- return m_bool ? sTrueString : sFalseString;
-}
-
-
-
-CValue* CBoolValue::GetReplica()
-{
- CBoolValue* replica = new CBoolValue(*this);
- replica->ProcessReplica();
-
- return replica;
-}
-
-#ifdef WITH_PYTHON
-PyObject *CBoolValue::ConvertValueToPython()
-{
- return PyBool_FromLong(m_bool != 0);
-}
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Expressions/intern/ConstExpr.cpp b/source/gameengine/Expressions/intern/ConstExpr.cpp
deleted file mode 100644
index 597427ecfe5..00000000000
--- a/source/gameengine/Expressions/intern/ConstExpr.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/** \file gameengine/Expressions/ConstExpr.cpp
- * \ingroup expressions
- */
-// ConstExpr.cpp: implementation of the CConstExpr class.
-
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include "EXP_Value.h" // for precompiled header
-#include "EXP_ConstExpr.h"
-#include "EXP_VectorValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-CConstExpr::CConstExpr()
-{
-}
-
-
-
-CConstExpr::CConstExpr(CValue* constval)
-/*
-pre:
-effect: constructs a CConstExpr cointing the value constval
-*/
-{
- m_value = constval;
-// m_bModified=true;
-}
-
-
-
-CConstExpr::~CConstExpr()
-/*
-pre:
-effect: deletes the object
-*/
-{
- if (m_value)
- m_value->Release();
-}
-
-
-
-unsigned char CConstExpr::GetExpressionID()
-{
- return CCONSTEXPRESSIONID;
-}
-
-
-
-CValue* CConstExpr::Calculate()
-/*
-pre:
-ret: a new object containing the value of the stored CValue
-*/
-{
- return m_value->AddRef();
-}
-
-
-
-void CConstExpr::ClearModified()
-{
- if (m_value)
- {
- m_value->SetModified(false);
- m_value->SetAffected(false);
- }
-}
-
-
-
-double CConstExpr::GetNumber()
-{
- return -1;
-}
-
-
-
-bool CConstExpr::NeedsRecalculated()
-{
- return m_value->IsAffected(); // IsAffected is m_bModified OR m_bAffected !!!
-}
-
-
-
-CExpression* CConstExpr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks)
-{
-// parent checks if child is still useful.
-// When for example it's value it's deleted flag set
-// then release Value, and return NULL in case of constexpression
-// else return this...
-
- assertd(m_value);
- if (m_value->IsReleaseRequested())
- {
- AddRef(); //numchanges++;
- return Release();
- }
- else
- return this;
-}
-
-
-
-void CConstExpr::BroadcastOperators(VALUE_OPERATOR op)
-{
- assertd(m_value);
- m_value->SetColorOperator(op);
-}
-
-
-
-bool CConstExpr::MergeExpression(CExpression *otherexpr)
-{
- assertd(false);
- return false;
-}
diff --git a/source/gameengine/Expressions/intern/EmptyValue.cpp b/source/gameengine/Expressions/intern/EmptyValue.cpp
deleted file mode 100644
index 9227626777d..00000000000
--- a/source/gameengine/Expressions/intern/EmptyValue.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/** \file gameengine/Expressions/EmptyValue.cpp
- * \ingroup expressions
- */
-
-// EmptyValue.cpp: implementation of the CEmptyValue class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include "EXP_EmptyValue.h"
-#include "EXP_IntValue.h"
-#include "EXP_FloatValue.h"
-#include "EXP_StringValue.h"
-#include "EXP_ErrorValue.h"
-#include "EXP_ListValue.h"
-#include "EXP_VoidValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-CEmptyValue::CEmptyValue()
-/*
- * pre:
- * effect: constructs a new CEmptyValue
- */
-{
- SetModified(false);
-}
-
-
-
-CEmptyValue::~CEmptyValue()
-/*
- * pre:
- * effect: deletes the object
- */
-{
-
-}
-
-
-
-CValue *CEmptyValue::Calc(VALUE_OPERATOR op, CValue *val)
-/*
- * pre:
- * ret: a new object containing the result of applying operator op to this
- * object and val
- */
-{
- return val->CalcFinal(VALUE_EMPTY_TYPE, op, this);
-
-}
-
-
-
-CValue * CEmptyValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
-/*
- * pre: the type of val is dtype
- * ret: a new object containing the result of applying operator op to val and
- * this object
- */
-{
- return val->AddRef();
-}
-
-
-
-double CEmptyValue::GetNumber()
-{
- return 0;
-}
-
-
-
-int CEmptyValue::GetValueType()
-{
- return VALUE_EMPTY_TYPE;
-}
-
-
-
-CListValue* CEmptyValue::GetPolySoup()
-{
- CListValue* soup = new CListValue();
- //don't add any poly, while it's an empty value
- return soup;
-}
-
-
-
-bool CEmptyValue::IsInside(CValue* testpoint,bool bBorderInclude)
-{
- // empty space is solid, so always inside
- return true;
-}
-
-
-
-double* CEmptyValue::GetVector3(bool bGetTransformedVec)
-{
- assertd(false); // don't get vector from me
- return ZeroVector();
-}
-
-
-
-static STR_String emptyString = STR_String("");
-
-
-const STR_String & CEmptyValue::GetText()
-{
- return emptyString;
-}
-
-
-
-CValue* CEmptyValue::GetReplica()
-{
- CEmptyValue* replica = new CEmptyValue(*this);
- replica->ProcessReplica();
- return replica;
-}
-
diff --git a/source/gameengine/Expressions/intern/ErrorValue.cpp b/source/gameengine/Expressions/intern/ErrorValue.cpp
deleted file mode 100644
index c03ceb88073..00000000000
--- a/source/gameengine/Expressions/intern/ErrorValue.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/** \file gameengine/Expressions/ErrorValue.cpp
- * \ingroup expressions
- */
-// ErrorValue.cpp: implementation of the CErrorValue class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include "EXP_ErrorValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-CErrorValue::CErrorValue()
-/*
-pre:
-effect: constructs a new CErrorValue containing errormessage "Error"
-*/
-{
- m_strErrorText = "Error";
- SetError(true);
-}
-
-
-
-CErrorValue::CErrorValue(const char *errmsg)
-/*
-pre:
-effect: constructs a new CErrorValue containing errormessage errmsg
-*/
-{
- m_strErrorText = "[";
- m_strErrorText += errmsg;
- m_strErrorText += "]";
- SetError(true);
-}
-
-
-
-CErrorValue::~CErrorValue()
-/*
-pre:
-effect: deletes the object
-*/
-{
-
-}
-
-
-
-CValue* CErrorValue::Calc(VALUE_OPERATOR op, CValue *val)
-/*
-pre:
-ret: a new object containing the result of applying operator op to this
- object and val
-*/
-{
- CValue* errorval;
-
- switch (op)
- {
- case VALUE_POS_OPERATOR:
- case VALUE_NEG_OPERATOR:
- case VALUE_NOT_OPERATOR:
- {
- errorval = new CErrorValue (op2str(op) + GetText());
- break;
- }
- default:
- {
- errorval = val->CalcFinal(VALUE_ERROR_TYPE, op, this);
- break;
- }
- }
-
- return errorval;
-}
-
-
-
-CValue* CErrorValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
-/*
-pre: the type of val is dtype
-ret: a new object containing the result of applying operator op to val and
- this object
-*/
-{
- return new CErrorValue (val->GetText() + op2str(op) + GetText());
-}
-
-
-
-double CErrorValue::GetNumber()
-{
- return -1;
-}
-
-
-
-int CErrorValue::GetValueType()
-{
- return VALUE_ERROR_TYPE;
-}
-
-
-
-const STR_String & CErrorValue::GetText()
-{
- return m_strErrorText;
-}
-
-
-
-CValue* CErrorValue::GetReplica()
-{
- // who would want a copy of an error ?
- trace ("Error: ErrorValue::GetReplica() not implemented yet");
- assertd(false);
-
- return NULL;
-}
diff --git a/source/gameengine/Expressions/intern/Expression.cpp b/source/gameengine/Expressions/intern/Expression.cpp
deleted file mode 100644
index 6a98a15aa12..00000000000
--- a/source/gameengine/Expressions/intern/Expression.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/** \file gameengine/Expressions/Expression.cpp
- * \ingroup expressions
- */
-// Expression.cpp: implementation of the CExpression class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include "EXP_Expression.h"
-#include "EXP_ErrorValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-#ifdef DEBUG
-//int gRefCountExpr;
-#endif
-CExpression::CExpression()// : m_cached_calculate(NULL)
-{
- m_refcount = 1;
-#ifdef DEBUG
- //gRefCountExpr++;
-#endif
-}
-
-CExpression::~CExpression()
-{
- assert (m_refcount == 0);
-}
-
-
-
-// destuctor for CBrokenLinkInfo
-CBrokenLinkInfo::~CBrokenLinkInfo()
-{
- if (m_pExpr && !m_bRestored)
- m_pExpr->Release();
-}
-
-
-void CBrokenLinkInfo::RestoreLink()
-{
-
-
- assertd(m_pExpr);
-
- if (m_pExpr)
- {
- if (!m_bRestored) {
- m_bRestored=true;
-
- }
- if (*m_pmemExpr)
- {
- (*m_pmemExpr)->Release();
- }
- *m_pmemExpr = m_pExpr;
-
-// m_pExpr=NULL;
- }
-}
-
-void CBrokenLinkInfo::BreakLink()
-{
- m_bRestored=false;
- m_pExpr->AddRef();
-}
-
diff --git a/source/gameengine/Expressions/intern/FloatValue.cpp b/source/gameengine/Expressions/intern/FloatValue.cpp
deleted file mode 100644
index 0f86a429d81..00000000000
--- a/source/gameengine/Expressions/intern/FloatValue.cpp
+++ /dev/null
@@ -1,329 +0,0 @@
-/** \file gameengine/Expressions/FloatValue.cpp
- * \ingroup expressions
- */
-// FloatValue.cpp: implementation of the CFloatValue class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include "EXP_FloatValue.h"
-#include "EXP_IntValue.h"
-#include "EXP_StringValue.h"
-#include "EXP_BoolValue.h"
-#include "EXP_ErrorValue.h"
-#include "EXP_VoidValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-CFloatValue::CFloatValue()
-/*
-pre: false
-effect: constructs a new CFloatValue
-*/
-{
- m_pstrRep=NULL;
-}
-
-
-
-CFloatValue::CFloatValue(float fl)
-/*
-pre:
-effect: constructs a new CFloatValue containing value fl
-*/
-{
- m_float = fl;
- m_pstrRep=NULL;
-}
-
-
-
-CFloatValue::CFloatValue(float fl,const char *name,AllocationTYPE alloctype)
-/*
-pre:
-effect: constructs a new CFloatValue containing value fl
-*/
-{
-
- m_float = fl;
- SetName(name);
- if (alloctype==CValue::STACKVALUE)
- {
- CValue::DisableRefCount();
-
- }
- m_pstrRep=NULL;
-}
-
-
-
-CFloatValue::~CFloatValue()
-/*
-pre:
-effect: deletes the object
-*/
-{
- if (m_pstrRep)
- delete m_pstrRep;
-}
-
-
-
-CValue* CFloatValue::Calc(VALUE_OPERATOR op, CValue *val)
-/*
-pre:
-ret: a new object containing the result of applying operator op to this
- object and val
-*/
-{
- //return val->CalcFloat(op, this);
- switch (op)
- {
- case VALUE_POS_OPERATOR:
- return new CFloatValue (m_float);
- break;
- case VALUE_NEG_OPERATOR:
- return new CFloatValue (-m_float);
- break;
- case VALUE_NOT_OPERATOR:
- return new CBoolValue (m_float == 0.f);
- break;
- case VALUE_AND_OPERATOR:
- case VALUE_OR_OPERATOR:
- return new CErrorValue(val->GetText() + op2str(op) + "only allowed on booleans");
- break;
- default:
- return val->CalcFinal(VALUE_FLOAT_TYPE, op, this);
- break;
- }
-}
-
-
-
-CValue* CFloatValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
-/*
-pre: the type of val is dtype
-ret: a new object containing the result of applying operator op to val and
- this object
-*/
-{
- CValue *ret;
-
- switch (dtype) {
- case VALUE_INT_TYPE:
- {
- switch (op) {
- case VALUE_MOD_OPERATOR:
- ret = new CFloatValue(fmod(((CIntValue *) val)->GetInt(), m_float));
- break;
- case VALUE_ADD_OPERATOR:
- ret = new CFloatValue(((CIntValue *) val)->GetInt() + m_float);
- break;
- case VALUE_SUB_OPERATOR:
- ret = new CFloatValue(((CIntValue *) val)->GetInt() - m_float);
- break;
- case VALUE_MUL_OPERATOR:
- ret = new CFloatValue(((CIntValue *) val)->GetInt() * m_float);
- break;
- case VALUE_DIV_OPERATOR:
- if (m_float == 0)
- ret = new CErrorValue("Division by zero");
- else
- ret = new CFloatValue (((CIntValue *) val)->GetInt() / m_float);
- break;
- case VALUE_EQL_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() == m_float);
- break;
- case VALUE_NEQ_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() != m_float);
- break;
- case VALUE_GRE_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() > m_float);
- break;
- case VALUE_LES_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() < m_float);
- break;
- case VALUE_GEQ_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() >= m_float);
- break;
- case VALUE_LEQ_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() <= m_float);
- break;
- case VALUE_NOT_OPERATOR:
- ret = new CBoolValue(m_float == 0);
- break;
- default:
- ret = new CErrorValue("illegal operator. please send a bug report.");
- break;
- }
- break;
- }
- case VALUE_EMPTY_TYPE:
- case VALUE_FLOAT_TYPE:
- {
- switch (op) {
- case VALUE_MOD_OPERATOR:
- ret = new CFloatValue(fmod(((CFloatValue *) val)->GetFloat(), m_float));
- break;
- case VALUE_ADD_OPERATOR:
- ret = new CFloatValue(((CFloatValue *) val)->GetFloat() + m_float);
- break;
- case VALUE_SUB_OPERATOR:
- ret = new CFloatValue(((CFloatValue *) val)->GetFloat() - m_float);
- break;
- case VALUE_MUL_OPERATOR:
- ret = new CFloatValue(((CFloatValue *) val)->GetFloat() * m_float);
- break;
- case VALUE_DIV_OPERATOR:
- if (m_float == 0)
- ret = new CErrorValue("Division by zero");
- else
- ret = new CFloatValue (((CFloatValue *) val)->GetFloat() / m_float);
- break;
- case VALUE_EQL_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() == m_float);
- break;
- case VALUE_NEQ_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() != m_float);
- break;
- case VALUE_GRE_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() > m_float);
- break;
- case VALUE_LES_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() < m_float);
- break;
- case VALUE_GEQ_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() >= m_float);
- break;
- case VALUE_LEQ_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() <= m_float);
- break;
- case VALUE_NEG_OPERATOR:
- ret = new CFloatValue (-m_float);
- break;
- case VALUE_POS_OPERATOR:
- ret = new CFloatValue (m_float);
- break;
- case VALUE_NOT_OPERATOR:
- ret = new CBoolValue(m_float == 0);
- break;
- default:
- ret = new CErrorValue("illegal operator. please send a bug report.");
- break;
- }
- break;
- }
- case VALUE_STRING_TYPE:
- {
- switch (op) {
- case VALUE_ADD_OPERATOR:
- ret = new CStringValue(val->GetText() + GetText(),"");
- break;
- case VALUE_EQL_OPERATOR:
- case VALUE_NEQ_OPERATOR:
- case VALUE_GRE_OPERATOR:
- case VALUE_LES_OPERATOR:
- case VALUE_GEQ_OPERATOR:
- case VALUE_LEQ_OPERATOR:
- ret = new CErrorValue("[Cannot compare string with float]" + op2str(op) + GetText());
- break;
- default:
- ret = new CErrorValue("[operator not allowed on strings]" + op2str(op) + GetText());
- break;
- }
- break;
- }
- case VALUE_BOOL_TYPE:
- ret = new CErrorValue("[operator not valid on boolean and float]" + op2str(op) + GetText());
- break;
- case VALUE_ERROR_TYPE:
- ret = new CErrorValue(val->GetText() + op2str(op) + GetText());
- break;
- default:
- ret = new CErrorValue("illegal type. contact your dealer (if any)");
- break;
- }
- return ret;
-}
-
-
-
-void CFloatValue::SetFloat(float fl)
-{
- m_float = fl;
- SetModified(true);
-}
-
-
-
-float CFloatValue::GetFloat()
-/*
-pre:
-ret: the float stored in the object
-*/
-{
- return m_float;
-}
-
-
-
-double CFloatValue::GetNumber()
-{
- return m_float;
-}
-
-
-
-int CFloatValue::GetValueType()
-{
- return VALUE_FLOAT_TYPE;
-}
-
-
-
-void CFloatValue::SetValue(CValue* newval)
-{
- m_float = (float)newval->GetNumber();
- SetModified(true);
-}
-
-
-
-const STR_String & CFloatValue::GetText()
-{
- if (!m_pstrRep)
- m_pstrRep = new STR_String();
-
- m_pstrRep->Format("%f",m_float);
- return *m_pstrRep;
-}
-
-
-
-CValue* CFloatValue::GetReplica()
-{
- CFloatValue* replica = new CFloatValue(*this);
- replica->m_pstrRep = NULL; /* should be in CFloatValue::ProcessReplica() but its not defined, no matter */
- replica->ProcessReplica();
-
- return replica;
-}
-
-
-#ifdef WITH_PYTHON
-PyObject *CFloatValue::ConvertValueToPython()
-{
- return PyFloat_FromDouble(m_float);
-}
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Expressions/intern/HashedPtr.cpp b/source/gameengine/Expressions/intern/HashedPtr.cpp
deleted file mode 100644
index 11d9482f993..00000000000
--- a/source/gameengine/Expressions/intern/HashedPtr.cpp
+++ /dev/null
@@ -1,57 +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/Expressions/KX_HashedPtr.cpp
- * \ingroup expressions
- */
-
-
-#include "EXP_HashedPtr.h"
-
-
-CHashedPtr::CHashedPtr(void* val) : m_valptr(val)
-{
-}
-
-
-unsigned int CHashedPtr::hash() const
-{
-#if defined(_WIN64)
- unsigned __int64 key = (unsigned __int64)m_valptr;
-#else
- unsigned long key = (unsigned long)m_valptr;
-#endif
-
- key += ~(key << 16);
- key ^= (key >> 5);
- key += (key << 3);
- key ^= (key >> 13);
- key += ~(key << 9);
- key ^= (key >> 17);
-
- return (unsigned int)(key & 0xffffffff);
-}
diff --git a/source/gameengine/Expressions/intern/IdentifierExpr.cpp b/source/gameengine/Expressions/intern/IdentifierExpr.cpp
deleted file mode 100644
index 8fbbf41cd63..00000000000
--- a/source/gameengine/Expressions/intern/IdentifierExpr.cpp
+++ /dev/null
@@ -1,103 +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/Expressions/IdentifierExpr.cpp
- * \ingroup expressions
- */
-
-
-#include "EXP_IdentifierExpr.h"
-
-CIdentifierExpr::CIdentifierExpr(const STR_String& identifier,CValue* id_context)
-:m_identifier(identifier)
-{
- if (id_context)
- m_idContext = id_context->AddRef();
- else
- m_idContext=NULL;
-}
-
-
-CIdentifierExpr::~CIdentifierExpr()
-{
- if (m_idContext)
- m_idContext->Release();
-}
-
-
-
-CValue* CIdentifierExpr::Calculate()
-{
- CValue* result = NULL;
- if (m_idContext)
- result = m_idContext->FindIdentifier(m_identifier);
-
- return result;
-}
-
-
-
-bool CIdentifierExpr::MergeExpression(CExpression* otherexpr)
-{
- return false;
-}
-
-
-
-unsigned char CIdentifierExpr::GetExpressionID()
-{
- return CIDENTIFIEREXPRESSIONID;
-}
-
-
-
-bool CIdentifierExpr::NeedsRecalculated()
-{
- return true;
-}
-
-
-
-CExpression* CIdentifierExpr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks)
-{
- assertd(false); // not implemented yet
- return NULL;
-}
-
-
-
-void CIdentifierExpr::ClearModified()
-{
- assertd(false); // not implemented yet
-}
-
-
-
-void CIdentifierExpr::BroadcastOperators(VALUE_OPERATOR op)
-{
- assertd(false); // not implemented yet
-}
diff --git a/source/gameengine/Expressions/intern/IfExpr.cpp b/source/gameengine/Expressions/intern/IfExpr.cpp
deleted file mode 100644
index b4e2fe7315b..00000000000
--- a/source/gameengine/Expressions/intern/IfExpr.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/** \file gameengine/Expressions/IfExpr.cpp
- * \ingroup expressions
- */
-// IfExpr.cpp: implementation of the CIfExpr class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include "EXP_IfExpr.h"
-#include "EXP_EmptyValue.h"
-#include "EXP_ErrorValue.h"
-#include "EXP_BoolValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-
-CIfExpr::CIfExpr()
-{
-}
-
-
-
-/*
- * pre:
- * effect: constructs an CifExpr-object corresponding to IF(guard, e1, e2)
- */
-CIfExpr::CIfExpr(CExpression *guard, CExpression *e1, CExpression *e2)
-{
- m_guard = guard;
- m_e1 = e1;
- m_e2 = e2;
-}
-
-
-
-/*
- * pre:
- * effect: dereferences the object
- */
-CIfExpr::~CIfExpr()
-{
- if (m_guard)
- m_guard->Release();
-
- if (m_e1)
- m_e1->Release();
-
- if (m_e2)
- m_e2->Release();
-}
-
-
-
-/**
- * pre:
- * ret: a new object containing the value of m_e1 if m_guard is a boolean true
- * a new object containing the value of m_e2 if m_guard is a boolean false
- * an new errorvalue if m_guard is not a boolean
- */
-CValue* CIfExpr::Calculate()
-{
- CValue *guardval;
- guardval = m_guard->Calculate();
- const STR_String& text = guardval->GetText();
- guardval->Release();
-
- if (&text == &CBoolValue::sTrueString)
- {
- return m_e1->Calculate();
- }
- else if (&text == &CBoolValue::sFalseString)
- {
- return m_e2->Calculate();
- }
- else
- {
- return new CErrorValue("Guard should be of boolean type");
- }
-}
-
-
-
-bool CIfExpr::MergeExpression(CExpression *otherexpr)
-{
- assertd(false);
- return false;
-}
-
-
-
-bool CIfExpr::IsInside(float x,float y,float z,bool bBorderInclude)
-{
- assertd(false);
- return false;
-}
-
-
-
-bool CIfExpr::NeedsRecalculated()
-{
- return (m_guard->NeedsRecalculated() ||
- m_e1->NeedsRecalculated() ||
- m_e2->NeedsRecalculated());
-}
-
-
-
-CExpression* CIfExpr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks)
-{
- assertd(false);
- return NULL;
-}
-
-
-
-void CIfExpr::ClearModified()
-{
- assertd(false);
-}
-
-
-
-void CIfExpr::BroadcastOperators(VALUE_OPERATOR op)
-{
- assertd(false);
-}
-
-
-
-unsigned char CIfExpr::GetExpressionID()
-{
- return CIFEXPRESSIONID;
-}
diff --git a/source/gameengine/Expressions/intern/InputParser.cpp b/source/gameengine/Expressions/intern/InputParser.cpp
deleted file mode 100644
index 583d8da63cb..00000000000
--- a/source/gameengine/Expressions/intern/InputParser.cpp
+++ /dev/null
@@ -1,669 +0,0 @@
-/** \file gameengine/Expressions/InputParser.cpp
- * \ingroup expressions
- */
-// Parser.cpp: implementation of the CParser class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include <stdlib.h>
-
-#include "MT_assert.h"
-
-#include "EXP_Value.h"
-#include "EXP_InputParser.h"
-#include "EXP_ErrorValue.h"
-#include "EXP_IntValue.h"
-#include "EXP_StringValue.h"
-#include "EXP_FloatValue.h"
-#include "EXP_BoolValue.h"
-#include "EXP_EmptyValue.h"
-#include "EXP_ConstExpr.h"
-#include "EXP_Operator2Expr.h"
-#include "EXP_Operator1Expr.h"
-#include "EXP_IdentifierExpr.h"
-
-// this is disable at the moment, I expected a memleak from it, but the error-cleanup was the reason
-// well, looks we don't need it anyway, until maybe the Curved Surfaces are integrated into CSG
-// cool things like (IF(LOD==1,CCurvedValue,IF(LOD==2,CCurvedValue2)) etc...
-#include "EXP_IfExpr.h"
-
-#if defined(WIN32) || defined(WIN64)
-#define strcasecmp _stricmp
-
-#ifndef strtoll
-#define strtoll _strtoi64
-#endif
-
-#endif /* Def WIN32 or Def WIN64 */
-
-#define NUM_PRIORITY 6
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-CParser::CParser() : m_identifierContext(NULL)
-{
-}
-
-
-
-CParser::~CParser()
-{
- if (m_identifierContext)
- m_identifierContext->Release();
-}
-
-
-
-void CParser::ScanError(const char *str)
-{
- // sets the global variable errmsg to an errormessage with
- // contents str, appending if it already exists
- // AfxMessageBox("Parse Error:"+str,MB_ICONERROR);
- if (errmsg)
- errmsg = new COperator2Expr(VALUE_ADD_OPERATOR, errmsg, Error(str));
- else
- errmsg = Error(str);
-
- sym = errorsym;
-}
-
-
-
-CExpression* CParser::Error(const char *str)
-{
- // makes and returns a new CConstExpr filled with an CErrorValue
- // with string str
- // AfxMessageBox("Error:"+str,MB_ICONERROR);
- return new CConstExpr(new CErrorValue(str));
-}
-
-
-
-void CParser::NextCh()
-{
- // sets the global variable ch to the next character, if it exists
- // and increases the global variable chcount
- chcount++;
-
- if (chcount < text.Length())
- ch = text[chcount];
- else
- ch = 0x00;
-}
-
-
-
-void CParser::TermChar(char c)
-{
- // generates an error if the next char isn't the specified char c,
- // otherwise, skip the char
- if (ch == c)
- {
- NextCh();
- }
- else
- {
- STR_String str;
- str.Format("Warning: %c expected\ncontinuing without it", c);
- trace(str);
- }
-}
-
-
-
-void CParser::DigRep()
-{
- // changes the current character to the first character that
- // isn't a decimal
- while ((ch >= '0') && (ch <= '9'))
- NextCh();
-}
-
-
-
-void CParser::CharRep()
-{
- // changes the current character to the first character that
- // isn't an alphanumeric character
- while (((ch >= '0') && (ch <= '9'))
- || ((ch >= 'a') && (ch <= 'z'))
- || ((ch >= 'A') && (ch <= 'Z'))
- || (ch == '.') || (ch == '_'))
- NextCh();
-}
-
-
-
-void CParser::GrabString(int start)
-{
- // puts part of the input string into the global variable
- // const_as_string, from position start, to position chchount
- const_as_string = text.Mid(start, chcount-start);
-}
-
-
-
-void CParser::GrabRealString(int start)
-{
- // works like GrabString but converting \\n to \n
- // puts part of the input string into the global variable
- // const_as_string, from position start, to position chchount
-
- int i;
- char tmpch;
-
- const_as_string = STR_String();
- for (i=start;i<chcount;i++) {
- tmpch= text[i];
- if ((tmpch =='\\') && (text[i+1] == 'n')) {
- tmpch = '\n';
- i++;
- }
- const_as_string += tmpch;
- }
-}
-
-
-
-void CParser::NextSym()
-{
- // sets the global variable sym to the next symbol, and
- // if it is an operator
- // sets the global variable opkind to the kind of operator
- // if it is a constant
- // sets the global variable constkind to the kind of operator
- // if it is a reference to a cell
- // sets the global variable cellcoord to the kind of operator
-
- errmsg = NULL;
- while (ch == ' ' || ch == 0x9)
- NextCh();
-
- switch (ch) {
- case '(':
- sym = lbracksym; NextCh();
- break;
- case ')':
- sym = rbracksym; NextCh();
- break;
- case ',':
- sym = commasym; NextCh();
- break;
- case '%' :
- sym = opsym; opkind = OPmodulus; NextCh();
- break;
- case '+' :
- sym = opsym; opkind = OPplus; NextCh();
- break;
- case '-' :
- sym = opsym; opkind = OPminus; NextCh();
- break;
- case '*' :
- sym = opsym; opkind = OPtimes; NextCh();
- break;
- case '/' :
- sym = opsym; opkind = OPdivide; NextCh();
- break;
- case '&' :
- sym = opsym; opkind = OPand; NextCh(); TermChar('&');
- break;
- case '|' :
- sym = opsym; opkind = OPor; NextCh(); TermChar('|');
- break;
- case '=' :
- sym = opsym; opkind = OPequal; NextCh(); TermChar('=');
- break;
- case '!' :
- sym = opsym;
- NextCh();
- if (ch == '=')
- {
- opkind = OPunequal;
- NextCh();
- }
- else
- {
- opkind = OPnot;
- }
- break;
- case '>':
- sym = opsym;
- NextCh();
- if (ch == '=')
- {
- opkind = OPgreaterequal;
- NextCh();
- }
- else
- {
- opkind = OPgreater;
- }
- break;
- case '<':
- sym = opsym;
- NextCh();
- if (ch == '=') {
- opkind = OPlessequal;
- NextCh();
- } else {
- opkind = OPless;
- }
- break;
- case '\"' :
- {
- int start;
- sym = constsym;
- constkind = stringtype;
- NextCh();
- start = chcount;
- while ((ch != '\"') && (ch != 0x0))
- NextCh();
- GrabRealString(start);
- TermChar('\"'); // check for eol before '\"'
- break;
- }
- case 0x0: sym = eolsym; break;
- default:
- {
- int start;
- start = chcount;
- DigRep();
- if ((start != chcount) || (ch == '.')) { // number
- sym = constsym;
- if (ch == '.') {
- constkind = floattype;
- NextCh();
- DigRep();
- }
- else constkind = inttype;
- if ((ch == 'e') || (ch == 'E')) {
- int mark;
- constkind = floattype;
- NextCh();
- if ((ch == '+') || (ch == '-')) NextCh();
- mark = chcount;
- DigRep();
- if (mark == chcount) {
- ScanError("Number expected after 'E'");
- return;
- }
- }
- GrabString(start);
- } else if (((ch >= 'a') && (ch <= 'z'))
- || ((ch >= 'A') && (ch <= 'Z')))
- { // reserved word?
-
- start = chcount;
- CharRep();
- GrabString(start);
- if (!strcasecmp(const_as_string, "SUM")) {
- sym = sumsym;
- }
- else if (!strcasecmp(const_as_string, "NOT")) {
- sym = opsym;
- opkind = OPnot;
- }
- else if (!strcasecmp(const_as_string, "AND")) {
- sym = opsym; opkind = OPand;
- }
- else if (!strcasecmp(const_as_string, "OR")) {
- sym = opsym; opkind = OPor;
- }
- else if (!strcasecmp(const_as_string, "IF"))
- sym = ifsym;
- else if (!strcasecmp(const_as_string, "WHOMADE"))
- sym = whocodedsym;
- else if (!strcasecmp(const_as_string, "FALSE")) {
- sym = constsym; constkind = booltype; boolvalue = false;
- } else if (!strcasecmp(const_as_string, "TRUE")) {
- sym = constsym; constkind = booltype; boolvalue = true;
- } else {
- sym = idsym;
- //STR_String str;
- //str.Format("'%s' makes no sense here", (const char*)funstr);
- //ScanError(str);
- }
- } else { // unknown symbol
- STR_String str;
- str.Format("Unexpected character '%c'", ch);
- NextCh();
- ScanError(str);
- return;
- }
- }
- }
-}
-
-#if 0
-int CParser::MakeInt()
-{
- // returns the integer representation of the value in the global
- // variable const_as_string
- // pre: const_as_string contains only numercal chars
- return atoi(const_as_string);
-}
-#endif
-
-const char *CParser::Symbol2Str(int s)
-{
- // returns a string representation of of symbol s,
- // for use in Term when generating an error
- switch (s) {
- case errorsym: return "error";
- case lbracksym: return "(";
- case rbracksym: return ")";
- case commasym: return ",";
- case opsym: return "operator";
- case constsym: return "constant";
- case sumsym: return "SUM";
- case ifsym: return "IF";
- case whocodedsym: return "WHOMADE";
- case eolsym: return "end of line";
- case idsym: return "identifier";
- }
- return "unknown"; // should not happen
-}
-
-void CParser::Term(int s)
-{
- // generates an error if the next symbol isn't the specified symbol s
- // otherwise, skip the symbol
- if (s == sym) {
- NextSym();
- }
- else {
- STR_String msg;
- msg.Format("Warning: %s expected\ncontinuing without it", Symbol2Str(s));
-
-// AfxMessageBox(msg,MB_ICONERROR);
-
- trace(msg);
- }
-}
-
-int CParser::Priority(int optorkind)
-{
- // returns the priority of an operator
- // higher number means higher priority
- switch (optorkind) {
- case OPor: return 1;
- case OPand: return 2;
- case OPgreater:
- case OPless:
- case OPgreaterequal:
- case OPlessequal:
- case OPequal:
- case OPunequal: return 3;
- case OPplus:
- case OPminus: return 4;
- case OPmodulus:
- case OPtimes:
- case OPdivide: return 5;
- }
- MT_assert(false);
- return 0; // should not happen
-}
-
-CExpression *CParser::Ex(int i)
-{
- // parses an expression in the imput, starting at priority i, and
- // returns an CExpression, containing the parsed input
- CExpression *e1 = NULL, *e2 = NULL;
- int opkind2;
-
- if (i < NUM_PRIORITY) {
- e1 = Ex(i + 1);
- while ((sym == opsym) && (Priority(opkind) == i)) {
- opkind2 = opkind;
- NextSym();
- e2 = Ex(i + 1);
- switch (opkind2) {
- case OPmodulus: e1 = new COperator2Expr(VALUE_MOD_OPERATOR,e1, e2); break;
- case OPplus: e1 = new COperator2Expr(VALUE_ADD_OPERATOR,e1, e2); break;
- case OPminus: e1 = new COperator2Expr(VALUE_SUB_OPERATOR,e1, e2); break;
- case OPtimes: e1 = new COperator2Expr(VALUE_MUL_OPERATOR,e1, e2); break;
- case OPdivide: e1 = new COperator2Expr(VALUE_DIV_OPERATOR,e1, e2); break;
- case OPand: e1 = new COperator2Expr(VALUE_AND_OPERATOR,e1, e2); break;
- case OPor: e1 = new COperator2Expr(VALUE_OR_OPERATOR,e1, e2); break;
- case OPequal: e1 = new COperator2Expr(VALUE_EQL_OPERATOR,e1, e2); break;
- case OPunequal: e1 = new COperator2Expr(VALUE_NEQ_OPERATOR,e1, e2); break;
- case OPgreater: e1 = new COperator2Expr(VALUE_GRE_OPERATOR,e1, e2); break;
- case OPless: e1 = new COperator2Expr(VALUE_LES_OPERATOR,e1, e2); break;
- case OPgreaterequal: e1 = new COperator2Expr(VALUE_GEQ_OPERATOR,e1, e2); break;
- case OPlessequal: e1 = new COperator2Expr(VALUE_LEQ_OPERATOR,e1, e2); break;
- default: MT_assert(false); break; // should not happen
- }
- }
- } else if (i == NUM_PRIORITY) {
- if ((sym == opsym)
- && ( (opkind == OPminus) || (opkind == OPnot) || (opkind == OPplus) )
- )
- {
- NextSym();
- switch (opkind) {
- /* +1 is also a valid number! */
- case OPplus: e1 = new COperator1Expr(VALUE_POS_OPERATOR, Ex(NUM_PRIORITY)); break;
- case OPminus: e1 = new COperator1Expr(VALUE_NEG_OPERATOR, Ex(NUM_PRIORITY)); break;
- case OPnot: e1 = new COperator1Expr(VALUE_NOT_OPERATOR, Ex(NUM_PRIORITY)); break;
- default:
- {
- // should not happen
- e1 = Error("operator +, - or ! expected");
- }
- }
- }
- else {
- switch (sym) {
- case constsym:
- {
- switch (constkind) {
- case booltype:
- e1 = new CConstExpr(new CBoolValue(boolvalue));
- break;
- case inttype:
- {
- cInt temp;
- temp = strtoll(const_as_string, NULL, 10); /* atoi is for int only */
- e1 = new CConstExpr(new CIntValue(temp));
- break;
- }
- case floattype:
- {
- double temp;
- temp = atof(const_as_string);
- e1 = new CConstExpr(new CFloatValue(temp));
- break;
- }
- case stringtype:
- e1 = new CConstExpr(new CStringValue(const_as_string,""));
- break;
- default :
- MT_assert(false);
- break;
- }
- NextSym();
- break;
- }
- case lbracksym:
- NextSym();
- e1 = Ex(1);
- Term(rbracksym);
- break;
- case ifsym:
- {
- CExpression *e3;
- NextSym();
- Term(lbracksym);
- e1 = Ex(1);
- Term(commasym);
- e2 = Ex(1);
- if (sym == commasym) {
- NextSym();
- e3 = Ex(1);
- } else {
- e3 = new CConstExpr(new CEmptyValue());
- }
- Term(rbracksym);
- e1 = new CIfExpr(e1, e2, e3);
- break;
- }
- case idsym:
- {
- e1 = new CIdentifierExpr(const_as_string,m_identifierContext);
- NextSym();
-
- break;
- }
- case errorsym:
- {
- MT_assert(!e1);
- STR_String errtext="[no info]";
- if (errmsg)
- {
- CValue* errmsgval = errmsg->Calculate();
- errtext=errmsgval->GetText();
- errmsgval->Release();
-
- //e1 = Error(errmsg->Calculate()->GetText());//new CConstExpr(errmsg->Calculate());
-
- if ( !(errmsg->Release()) )
- {
- errmsg=NULL;
- } else {
- // does this happen ?
- MT_assert("does this happen");
- }
- }
- e1 = Error(errtext);
-
- break;
- }
- default:
- NextSym();
- //return Error("Expression expected");
- MT_assert(!e1);
- e1 = Error("Expression expected");
- }
- }
- }
- return e1;
-}
-
-CExpression *CParser::Expr()
-{
- // parses an expression in the imput, and
- // returns an CExpression, containing the parsed input
- return Ex(1);
-}
-
-CExpression* CParser::ProcessText
-(const char *intext) {
-
- // and parses the string in intext and returns it.
-
-
- CExpression* expr;
- text = intext;
-
-
- chcount = 0;
- if (text.Length() == 0) {
- return NULL;
- }
-
- ch = text[0];
- /* if (ch != '=') {
- * expr = new CConstExpr(new CStringValue(text));
- * *dependent = deplist;
- * return expr;
- * } else
- */
- // NextCh();
- NextSym();
- expr = Expr();
- if (sym != eolsym) {
- CExpression* oldexpr = expr;
- expr = new COperator2Expr(VALUE_ADD_OPERATOR,
- oldexpr, Error(STR_String("Extra characters after expression")));//new CConstExpr(new CErrorValue("Extra characters after expression")));
- }
- if (errmsg)
- errmsg->Release();
-
- return expr;
-}
-
-
-
-float CParser::GetFloat(STR_String& txt)
-{
- // returns parsed text into a float
- // empty string returns -1
-
-// AfxMessageBox("parsed string="+txt);
- CValue* val=NULL;
- float result=-1;
-// String tmpstr;
-
- CExpression* expr = ProcessText(txt);
- if (expr) {
- val = expr->Calculate();
- result=(float)val->GetNumber();
-
-
-
- val->Release();
- expr->Release();
- }
-// tmpstr.Format("parseresult=%g",result);
-// AfxMessageBox(tmpstr);
- return result;
-}
-
-CValue* CParser::GetValue(STR_String& txt, bool bFallbackToText)
-{
- // returns parsed text into a value,
- // empty string returns NULL value !
- // if bFallbackToText then unparsed stuff is put into text
-
- CValue* result=NULL;
- CExpression* expr = ProcessText(txt);
- if (expr) {
- result = expr->Calculate();
- expr->Release();
- }
- if (result)
- {
- // if the parsed stuff lead to an errorvalue, don't return errors, just NULL
- if (result->IsError()) {
- result->Release();
- result=NULL;
- if (bFallbackToText) {
- if (txt.Length()>0)
- {
- result = new CStringValue(txt,"");
- }
- }
- }
- }
- return result;
-}
-
-void CParser::SetContext(CValue* context)
-{
- if (m_identifierContext)
- {
- m_identifierContext->Release();
- }
- m_identifierContext = context;
-}
diff --git a/source/gameengine/Expressions/intern/IntValue.cpp b/source/gameengine/Expressions/intern/IntValue.cpp
deleted file mode 100644
index 7b2e841f13f..00000000000
--- a/source/gameengine/Expressions/intern/IntValue.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/** \file gameengine/Expressions/IntValue.cpp
- * \ingroup expressions
- */
-// IntValue.cpp: implementation of the CIntValue class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include <stdio.h>
-
-#include "EXP_IntValue.h"
-#include "EXP_ErrorValue.h"
-#include "EXP_FloatValue.h"
-#include "EXP_BoolValue.h"
-#include "EXP_StringValue.h"
-#include "EXP_VoidValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-CIntValue::CIntValue()
-/*
-pre: false
-effect: constructs a new CIntValue
-*/
-{
-
-#ifdef DEBUG_
- m_textval = "Int illegal constructor";
-#endif
- m_pstrRep=NULL;
-}
-
-
-
-CIntValue::CIntValue(cInt innie)
-/*
-pre:
-effect: constructs a new CIntValue containing cInt innie
-*/
-{
- m_int = innie;
- m_pstrRep=NULL;
-}
-
-
-
-CIntValue::CIntValue(cInt innie,const char *name,AllocationTYPE alloctype)
-{
- m_int = innie;
- SetName(name);
-
- if (alloctype==CValue::STACKVALUE)
- {
- CValue::DisableRefCount();
- }
- m_pstrRep=NULL;
-
-}
-
-
-
-CIntValue::~CIntValue()
-/*
-pre:
-effect: deletes the object
-*/
-{
- if (m_pstrRep)
- delete m_pstrRep;
-}
-
-
-
-CValue* CIntValue::Calc(VALUE_OPERATOR op, CValue *val)
-/*
-pre:
-ret: a new object containing the result of applying operator op to this
-object and val
-*/
-{
- //return val->CalcInt(op, this);
- switch (op) {
- case VALUE_POS_OPERATOR:
- return new CIntValue (m_int);
- break;
- case VALUE_NEG_OPERATOR:
- return new CIntValue (-m_int);
- break;
- case VALUE_NOT_OPERATOR:
- return new CBoolValue (m_int == 0);
- break;
- case VALUE_AND_OPERATOR:
- case VALUE_OR_OPERATOR:
- return new CErrorValue(val->GetText() + op2str(op) + "only allowed on booleans");
- break;
- default:
- return val->CalcFinal(VALUE_INT_TYPE, op, this);
- break;
- }
-}
-
-/*
- * pre: the type of val is dtype
- * ret: a new object containing the result of applying operator op to val and
- * this object
- */
-CValue* CIntValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
-{
- CValue *ret;
-
- switch (dtype) {
- case VALUE_EMPTY_TYPE:
- case VALUE_INT_TYPE:
- {
- switch (op) {
- case VALUE_MOD_OPERATOR:
- ret = new CIntValue (((CIntValue *) val)->GetInt() % m_int);
- break;
- case VALUE_ADD_OPERATOR:
- ret = new CIntValue (((CIntValue *) val)->GetInt() + m_int);
- break;
- case VALUE_SUB_OPERATOR:
- ret = new CIntValue (((CIntValue *) val)->GetInt() - m_int);
- break;
- case VALUE_MUL_OPERATOR:
- ret = new CIntValue (((CIntValue *) val)->GetInt() * m_int);
- break;
- case VALUE_DIV_OPERATOR:
- if (m_int == 0) {
- if (val->GetNumber() == 0) {
- ret = new CErrorValue("Not a Number");
- }
- else {
- ret = new CErrorValue("Division by zero");
- }
- }
- else
- ret = new CIntValue (((CIntValue *) val)->GetInt() / m_int);
- break;
- case VALUE_EQL_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() == m_int);
- break;
- case VALUE_NEQ_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() != m_int);
- break;
- case VALUE_GRE_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() > m_int);
- break;
- case VALUE_LES_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() < m_int);
- break;
- case VALUE_GEQ_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() >= m_int);
- break;
- case VALUE_LEQ_OPERATOR:
- ret = new CBoolValue(((CIntValue *) val)->GetInt() <= m_int);
- break;
- case VALUE_NEG_OPERATOR:
- ret = new CIntValue (-m_int);
- break;
- case VALUE_POS_OPERATOR:
- ret = new CIntValue (m_int);
- break;
- case VALUE_NOT_OPERATOR:
- ret = new CBoolValue(m_int == 0);
- break;
- default:
- printf("Found op: %d\n", op);
- ret = new CErrorValue("illegal operator. please send a bug report.");
- break;
- }
- break;
- }
- case VALUE_FLOAT_TYPE:
- {
- switch (op) {
- case VALUE_MOD_OPERATOR:
- ret = new CFloatValue(fmod(((CFloatValue *) val)->GetFloat(), m_int));
- break;
- case VALUE_ADD_OPERATOR:
- ret = new CFloatValue (((CFloatValue *) val)->GetFloat() + m_int);
- break;
- case VALUE_SUB_OPERATOR:
- ret = new CFloatValue (((CFloatValue *) val)->GetFloat() - m_int);
- break;
- case VALUE_MUL_OPERATOR:
- ret = new CFloatValue (((CFloatValue *) val)->GetFloat() * m_int);
- break;
- case VALUE_DIV_OPERATOR:
- if (m_int == 0)
- ret = new CErrorValue("Division by zero");
- else
- ret = new CFloatValue (((CFloatValue *) val)->GetFloat() / m_int);
- break;
- case VALUE_EQL_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() == m_int);
- break;
- case VALUE_NEQ_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() != m_int);
- break;
- case VALUE_GRE_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() > m_int);
- break;
- case VALUE_LES_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() < m_int);
- break;
- case VALUE_GEQ_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() >= m_int);
- break;
- case VALUE_LEQ_OPERATOR:
- ret = new CBoolValue(((CFloatValue *) val)->GetFloat() <= m_int);
- break;
- case VALUE_NOT_OPERATOR:
- ret = new CBoolValue(m_int == 0);
- break;
- default:
- ret = new CErrorValue("illegal operator. please send a bug report.");
- break;
- }
- break;
- }
- case VALUE_STRING_TYPE:
- {
- switch (op) {
- case VALUE_ADD_OPERATOR:
- ret = new CStringValue(val->GetText() + GetText(),"");
- break;
- case VALUE_EQL_OPERATOR:
- case VALUE_NEQ_OPERATOR:
- case VALUE_GRE_OPERATOR:
- case VALUE_LES_OPERATOR:
- case VALUE_GEQ_OPERATOR:
- case VALUE_LEQ_OPERATOR:
- ret = new CErrorValue("[Cannot compare string with integer]" + op2str(op) + GetText());
- break;
- default:
- ret = new CErrorValue("[operator not allowed on strings]" + op2str(op) + GetText());
- break;
- }
- break;
- }
- case VALUE_BOOL_TYPE:
- ret = new CErrorValue("[operator not valid on boolean and integer]" + op2str(op) + GetText());
- break;
-#if 0
- case VALUE_EMPTY_TYPE:
- {
- switch (op) {
- case VALUE_ADD_OPERATOR:
- ret = new CIntValue (m_int);
- break;
- case VALUE_SUB_OPERATOR:
- ret = new CIntValue (-m_int);
- break;
- default:
- {
- ret = new CErrorValue(op2str(op) + GetText());
- }
- }
- break;
- }
-#endif
- case VALUE_ERROR_TYPE:
- ret = new CErrorValue(val->GetText() + op2str(op) + GetText());
- break;
- default:
- ret = new CErrorValue("illegal type. contact your dealer (if any)");
- break;
- }
- return ret;
-}
-
-
-/**
- * pre:
- * ret: the cInt stored in the object
- */
-cInt CIntValue::GetInt()
-{
- return m_int;
-}
-
-
-
-double CIntValue::GetNumber()
-{
- return (double) m_int;
-}
-
-
-
-int CIntValue::GetValueType()
-{
- return VALUE_INT_TYPE;
-}
-
-
-
-const STR_String & CIntValue::GetText()
-{
- if (!m_pstrRep)
- m_pstrRep=new STR_String();
- m_pstrRep->Format("%lld",m_int);
-
- return *m_pstrRep;
-}
-
-
-
-CValue* CIntValue::GetReplica()
-{
- CIntValue* replica = new CIntValue(*this);
- replica->ProcessReplica();
- replica->m_pstrRep = NULL;
-
- return replica;
-}
-
-
-
-void CIntValue::SetValue(CValue* newval)
-{
- m_int = (cInt)newval->GetNumber();
- SetModified(true);
-}
-
-
-#ifdef WITH_PYTHON
-PyObject *CIntValue::ConvertValueToPython()
-{
- return PyLong_FromLongLong(m_int);
-}
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Expressions/intern/ListValue.cpp b/source/gameengine/Expressions/intern/ListValue.cpp
deleted file mode 100644
index 557ce7be300..00000000000
--- a/source/gameengine/Expressions/intern/ListValue.cpp
+++ /dev/null
@@ -1,702 +0,0 @@
-/** \file gameengine/Expressions/ListValue.cpp
- * \ingroup expressions
- */
-// ListValue.cpp: implementation of the CListValue class.
-//
-//////////////////////////////////////////////////////////////////////
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include <stdio.h>
-
-#include "EXP_ListValue.h"
-#include "EXP_StringValue.h"
-#include "EXP_VoidValue.h"
-#include <algorithm>
-#include "EXP_BoolValue.h"
-
-#include "BLI_sys_types.h" /* for intptr_t support */
-
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-CListValue::CListValue()
-: CPropValue()
-{
- m_bReleaseContents=true;
-}
-
-
-
-CListValue::~CListValue()
-{
-
- if (m_bReleaseContents) {
- for (unsigned int i=0;i<m_pValueArray.size();i++) {
- m_pValueArray[i]->Release();
- }
- }
-}
-
-
-static STR_String gstrListRep=STR_String("List");
-
-const STR_String & CListValue::GetText()
-{
- gstrListRep = "[";
- STR_String commastr = "";
-
- for (int i=0;i<GetCount();i++)
- {
- gstrListRep += commastr;
- gstrListRep += GetValue(i)->GetText();
- commastr = ",";
- }
- gstrListRep += "]";
-
- return gstrListRep;
-}
-
-
-
-CValue* CListValue::GetReplica()
-{
- CListValue* replica = new CListValue(*this);
-
- replica->ProcessReplica();
-
- replica->m_bReleaseContents=true; // for copy, complete array is copied for now...
- // copy all values
- int numelements = m_pValueArray.size();
- unsigned int i=0;
- replica->m_pValueArray.resize(numelements);
- for (i=0;i<m_pValueArray.size();i++)
- replica->m_pValueArray[i] = m_pValueArray[i]->GetReplica();
-
-
- return replica;
-};
-
-
-
-void CListValue::SetValue(int i, CValue *val)
-{
- assertd(i < m_pValueArray.size());
- m_pValueArray[i]=val;
-}
-
-
-
-void CListValue::Resize(int num)
-{
- m_pValueArray.resize(num);
-}
-
-
-
-void CListValue::Remove(int i)
-{
- assertd(i<m_pValueArray.size());
- m_pValueArray.erase(m_pValueArray.begin()+i);
-}
-
-
-
-void CListValue::ReleaseAndRemoveAll()
-{
- for (unsigned int i=0;i<m_pValueArray.size();i++)
- m_pValueArray[i]->Release();
- m_pValueArray.clear();//.Clear();
-}
-
-
-
-CValue* CListValue::FindValue(const STR_String &name)
-{
- for (int i=0; i < GetCount(); i++)
- if (GetValue(i)->GetName() == name)
- return GetValue(i);
-
- return NULL;
-}
-
-CValue* CListValue::FindValue(const char *name)
-{
- for (int i=0; i < GetCount(); i++)
- if (GetValue(i)->GetName() == name)
- return GetValue(i);
-
- return NULL;
-}
-
-bool CListValue::SearchValue(CValue *val)
-{
- for (int i=0;i<GetCount();i++)
- if (val == GetValue(i))
- return true;
- return false;
-}
-
-
-
-void CListValue::SetReleaseOnDestruct(bool bReleaseContents)
-{
- m_bReleaseContents = bReleaseContents;
-}
-
-
-
-bool CListValue::RemoveValue(CValue *val)
-{
- bool result=false;
-
- for (int i=GetCount()-1;i>=0;i--)
- if (val == GetValue(i))
- {
- Remove(i);
- result=true;
- }
- return result;
-}
-
-
-
-void CListValue::MergeList(CListValue *otherlist)
-{
-
- int numelements = this->GetCount();
- int numotherelements = otherlist->GetCount();
-
-
- Resize(numelements+numotherelements);
-
- for (int i=0;i<numotherelements;i++)
- {
- SetValue(i+numelements,otherlist->GetValue(i)->AddRef());
- }
-}
-
-bool CListValue::CheckEqual(CValue* first,CValue* second)
-{
- bool result = false;
-
- CValue* eqval = ((CValue*)first)->Calc(VALUE_EQL_OPERATOR,(CValue*)second);
-
- if (eqval==NULL)
- return false;
- const STR_String& text = eqval->GetText();
- if (&text==&CBoolValue::sTrueString)
- {
- result = true;
- }
- eqval->Release();
- return result;
-
-}
-
-
-/* ---------------------------------------------------------------------
- * Some stuff taken from the header
- * --------------------------------------------------------------------- */
-CValue* CListValue::Calc(VALUE_OPERATOR op,CValue *val)
-{
- //assert(false); // todo: implement me!
- static int error_printed = 0;
- if (error_printed==0) {
- fprintf(stderr, "CValueList::Calc not yet implemented\n");
- error_printed = 1;
- }
- return NULL;
-}
-
-CValue* CListValue::CalcFinal(VALUE_DATA_TYPE dtype,
- VALUE_OPERATOR op,
- CValue* val)
-{
- //assert(false); // todo: implement me!
- static int error_printed = 0;
- if (error_printed==0) {
- fprintf(stderr, "CValueList::CalcFinal not yet implemented\n");
- error_printed = 1;
- }
- return NULL;
-}
-
-
-
-void CListValue::Add(CValue* value)
-{
- m_pValueArray.push_back(value);
-}
-
-
-
-double CListValue::GetNumber()
-{
- return -1;
-}
-
-
-
-int CListValue::GetValueType()
-{
- return VALUE_LIST_TYPE;
-}
-
-
-
-void CListValue::SetModified(bool bModified)
-{
- CValue::SetModified(bModified);
- int numels = GetCount();
-
- for (int i=0;i<numels;i++)
- GetValue(i)->SetModified(bModified);
-}
-
-
-
-bool CListValue::IsModified()
-{
- bool bmod = CValue::IsModified(); //normal own flag
- int numels = GetCount();
-
- for (int i=0;i<numels;i++)
- bmod = bmod || GetValue(i)->IsModified();
-
- return bmod;
-}
-
-#ifdef WITH_PYTHON
-
-/* --------------------------------------------------------------------- */
-/* Python interface ---------------------------------------------------- */
-/* --------------------------------------------------------------------- */
-
-static Py_ssize_t listvalue_bufferlen(PyObject *self)
-{
- CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self));
- if (list==NULL)
- return 0;
-
- return (Py_ssize_t)list->GetCount();
-}
-
-static PyObject *listvalue_buffer_item(PyObject *self, Py_ssize_t index)
-{
- CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self));
- CValue *cval;
-
- if (list==NULL) {
- PyErr_SetString(PyExc_SystemError, "val = CList[i], " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- int count = list->GetCount();
-
- if (index < 0)
- index = count+index;
-
- if (index < 0 || index >= count) {
- PyErr_SetString(PyExc_IndexError, "CList[i]: Python ListIndex out of range in CValueList");
- return NULL;
- }
-
- cval= list->GetValue(index);
-
- PyObject *pyobj = cval->ConvertValueToPython();
- if (pyobj)
- return pyobj;
- else
- return cval->GetProxy();
-}
-
-
-/* just slice it into a python list... */
-static PyObject *listvalue_buffer_slice(CListValue *list, Py_ssize_t start, Py_ssize_t stop)
-{
- PyObject *newlist;
- Py_ssize_t i, j;
-
- /* caller needs to validate negative index */
-#if 0
- Py_ssize_t len = list->GetCount();
-
- if (start > len) start = len;
- if (stop > len) stop = len;
-#endif
-
- newlist = PyList_New(stop - start);
- if (!newlist)
- return NULL;
-
- for (i = start, j = 0; i < stop; i++, j++) {
- PyObject *pyobj = list->GetValue(i)->ConvertValueToPython();
- if (!pyobj) {
- pyobj = list->GetValue(i)->GetProxy();
- }
- PyList_SET_ITEM(newlist, j, pyobj);
- }
- return newlist;
-}
-
-
-static PyObject *listvalue_mapping_subscript(PyObject *self, PyObject *key)
-{
- CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self));
- if (list==NULL) {
- PyErr_SetString(PyExc_SystemError, "value = CList[i], " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- if (PyUnicode_Check(key)) {
- CValue *item = ((CListValue*) list)->FindValue(_PyUnicode_AsString(key));
- if (item) {
- PyObject *pyobj = item->ConvertValueToPython();
- if (pyobj)
- return pyobj;
- else
- return item->GetProxy();
- }
- }
- else if (PyIndex_Check(key)) {
- Py_ssize_t index = PyLong_AsSsize_t(key);
- return listvalue_buffer_item(self, index); /* wont add a ref */
- }
- else if (PySlice_Check(key)) {
- Py_ssize_t start, stop, step, slicelength;
-
- if (PySlice_GetIndicesEx(key, list->GetCount(), &start, &stop, &step, &slicelength) < 0)
- return NULL;
-
- if (slicelength <= 0) {
- return PyList_New(0);
- }
- else if (step == 1) {
- return listvalue_buffer_slice(list, start, stop);
- }
- else {
- PyErr_SetString(PyExc_TypeError, "CList[slice]: slice steps not supported");
- return NULL;
- }
- }
-
- PyErr_Format(PyExc_KeyError,
- "CList[key]: '%R' key not in list", key);
- return NULL;
-}
-
-/* clist + list, return a list that python owns */
-static PyObject *listvalue_buffer_concat(PyObject *self, PyObject *other)
-{
- CListValue *listval= static_cast<CListValue *>(BGE_PROXY_REF(self));
- Py_ssize_t i, numitems, numitems_orig;
-
- if (listval==NULL) {
- PyErr_SetString(PyExc_SystemError, "CList+other, " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- numitems_orig= listval->GetCount();
-
- // for now, we support CListValue concatenated with items
- // and CListValue concatenated to Python Lists
- // and CListValue concatenated with another CListValue
-
- /* Shallow copy, don't use listval->GetReplica(), it will screw up with KX_GameObjects */
- CListValue* listval_new = new CListValue();
-
- if (PyList_Check(other))
- {
- CValue* listitemval;
- bool error = false;
-
- numitems = PyList_GET_SIZE(other);
-
- /* copy the first part of the list */
- listval_new->Resize(numitems_orig + numitems);
- for (i=0;i<numitems_orig;i++)
- listval_new->SetValue(i, listval->GetValue(i)->AddRef());
-
- for (i=0;i<numitems;i++)
- {
- listitemval = listval->ConvertPythonToValue(PyList_GET_ITEM(other, i), true, "cList + pyList: CListValue, ");
-
- if (listitemval) {
- listval_new->SetValue(i+numitems_orig, listitemval);
- } else {
- error= true;
- break;
- }
- }
-
- if (error) {
- listval_new->Resize(numitems_orig+i); /* resize so we don't try release NULL pointers */
- listval_new->Release();
- return NULL; /* ConvertPythonToValue above sets the error */
- }
-
- }
- else if (PyObject_TypeCheck(other, &CListValue::Type)) {
- // add items from otherlist to this list
- CListValue* otherval = static_cast<CListValue *>(BGE_PROXY_REF(other));
- if (otherval==NULL) {
- listval_new->Release();
- PyErr_SetString(PyExc_SystemError, "CList+other, " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- numitems = otherval->GetCount();
-
- /* copy the first part of the list */
- listval_new->Resize(numitems_orig + numitems); /* resize so we don't try release NULL pointers */
- for (i=0;i<numitems_orig;i++)
- listval_new->SetValue(i, listval->GetValue(i)->AddRef());
-
- /* now copy the other part of the list */
- for (i=0;i<numitems;i++)
- listval_new->SetValue(i+numitems_orig, otherval->GetValue(i)->AddRef());
-
- }
- return listval_new->NewProxy(true); /* python owns this list */
-}
-
-static int listvalue_buffer_contains(PyObject *self_v, PyObject *value)
-{
- CListValue *self = static_cast<CListValue *>(BGE_PROXY_REF(self_v));
-
- if (self == NULL) {
- PyErr_SetString(PyExc_SystemError, "val in CList, " BGE_PROXY_ERROR_MSG);
- return -1;
- }
-
- if (PyUnicode_Check(value)) {
- if (self->FindValue((const char *)_PyUnicode_AsString(value))) {
- return 1;
- }
- }
- else if (PyObject_TypeCheck(value, &CValue::Type)) { /* not dict like at all but this worked before __contains__ was used */
- CValue *item= static_cast<CValue *>(BGE_PROXY_REF(value));
- for (int i=0; i < self->GetCount(); i++)
- if (self->GetValue(i) == item) // Com
- return 1;
-
- } // not using CheckEqual
-
- return 0;
-}
-
-
-static PySequenceMethods listvalue_as_sequence = {
- listvalue_bufferlen,//(inquiry)buffer_length, /*sq_length*/
- listvalue_buffer_concat, /*sq_concat*/
- NULL, /*sq_repeat*/
- listvalue_buffer_item, /*sq_item*/
-// TODO, slicing in py3
- NULL, // listvalue_buffer_slice, /*sq_slice*/
- NULL, /*sq_ass_item*/
- NULL, /*sq_ass_slice*/
- (objobjproc)listvalue_buffer_contains, /* sq_contains */
- (binaryfunc) NULL, /* sq_inplace_concat */
- (ssizeargfunc) NULL, /* sq_inplace_repeat */
-};
-
-
-
-/* Is this one used ? */
-static PyMappingMethods instance_as_mapping = {
- listvalue_bufferlen, /*mp_length*/
- listvalue_mapping_subscript, /*mp_subscript*/
- NULL /*mp_ass_subscript*/
-};
-
-
-
-PyTypeObject CListValue::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "CListValue", /*tp_name*/
- sizeof(PyObjectPlus_Proxy), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- py_base_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- py_base_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- &listvalue_as_sequence, /*tp_as_sequence*/
- &instance_as_mapping, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call */
- 0,
- NULL,
- NULL,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- 0,0,0,0,0,0,0,
- Methods,
- 0,
- 0,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef CListValue::Methods[] = {
- /* List style access */
- {"append", (PyCFunction)CListValue::sPyappend,METH_O},
- {"reverse", (PyCFunction)CListValue::sPyreverse,METH_NOARGS},
- {"index", (PyCFunction)CListValue::sPyindex,METH_O},
- {"count", (PyCFunction)CListValue::sPycount,METH_O},
-
- /* Dict style access */
- {"get", (PyCFunction)CListValue::sPyget,METH_VARARGS},
-
- /* Own cvalue funcs */
- {"from_id", (PyCFunction)CListValue::sPyfrom_id,METH_O},
-
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef CListValue::Attributes[] = {
- { NULL } //Sentinel
-};
-
-PyObject *CListValue::Pyappend(PyObject *value)
-{
- CValue *objval = ConvertPythonToValue(value, true, "CList.append(i): CValueList, ");
-
- if (!objval) /* ConvertPythonToValue sets the error */
- return NULL;
-
- if (!BGE_PROXY_PYOWNS(m_proxy)) {
- PyErr_SetString(PyExc_TypeError,
- "CList.append(i): internal values can't be modified");
- return NULL;
- }
-
- Add(objval);
-
- Py_RETURN_NONE;
-}
-
-PyObject *CListValue::Pyreverse()
-{
- if (!BGE_PROXY_PYOWNS(m_proxy)) {
- PyErr_SetString(PyExc_TypeError,
- "CList.reverse(): internal values can't be modified");
- return NULL;
- }
-
- std::reverse(m_pValueArray.begin(),m_pValueArray.end());
- Py_RETURN_NONE;
-}
-
-PyObject *CListValue::Pyindex(PyObject *value)
-{
- PyObject *result = NULL;
-
- CValue *checkobj = ConvertPythonToValue(value, true, "val = cList[i]: CValueList, ");
- if (checkobj==NULL)
- return NULL; /* ConvertPythonToValue sets the error */
-
- int numelem = GetCount();
- for (int i=0;i<numelem;i++)
- {
- CValue* elem = GetValue(i);
- if (checkobj==elem || CheckEqual(checkobj,elem))
- {
- result = PyLong_FromLong(i);
- break;
- }
- }
- checkobj->Release();
-
- if (result==NULL) {
- PyErr_SetString(PyExc_ValueError, "CList.index(x): x not in CListValue");
- }
- return result;
-
-}
-
-
-
-PyObject *CListValue::Pycount(PyObject *value)
-{
- int numfound = 0;
-
- CValue *checkobj = ConvertPythonToValue(value, false, ""); /* error ignored */
-
- if (checkobj==NULL) { /* in this case just return that there are no items in the list */
- PyErr_Clear();
- return PyLong_FromLong(0);
- }
-
- int numelem = GetCount();
- for (int i=0;i<numelem;i++)
- {
- CValue* elem = GetValue(i);
- if (checkobj==elem || CheckEqual(checkobj,elem))
- {
- numfound ++;
- }
- }
- checkobj->Release();
-
- return PyLong_FromLong(numfound);
-}
-
-/* Matches python dict.get(key, [default]) */
-PyObject *CListValue::Pyget(PyObject *args)
-{
- char *key;
- PyObject *def = Py_None;
-
- if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
- return NULL;
-
- CValue *item = FindValue((const char *)key);
- if (item) {
- PyObject *pyobj = item->ConvertValueToPython();
- if (pyobj)
- return pyobj;
- else
- return item->GetProxy();
- }
- Py_INCREF(def);
- return def;
-}
-
-
-PyObject *CListValue::Pyfrom_id(PyObject *value)
-{
- uintptr_t id= (uintptr_t)PyLong_AsVoidPtr(value);
-
- if (PyErr_Occurred())
- return NULL;
-
- int numelem = GetCount();
- for (int i=0;i<numelem;i++)
- {
- if (reinterpret_cast<uintptr_t>(m_pValueArray[i]->m_proxy) == id)
- return GetValue(i)->GetProxy();
- }
- PyErr_SetString(PyExc_IndexError, "from_id(#): id not found in CValueList");
- return NULL;
-
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Expressions/intern/ListWrapper.cpp b/source/gameengine/Expressions/intern/ListWrapper.cpp
deleted file mode 100644
index db1518a4388..00000000000
--- a/source/gameengine/Expressions/intern/ListWrapper.cpp
+++ /dev/null
@@ -1,424 +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.
- *
- * Contributor(s): Porteries Tristan.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ListWrapper.cpp
- * \ingroup expressions
- */
-
-#ifdef WITH_PYTHON
-
-#include "EXP_ListWrapper.h"
-
-static STR_String pythonGeneratorList = "ListWrapper";
-
-CListWrapper::CListWrapper(void *client,
- PyObject *base,
- bool (*checkValid)(void *),
- int (*getSize)(void *),
- PyObject *(*getItem)(void *, int),
- const char *(*getItemName)(void *, int),
- bool (*setItem)(void *, int, PyObject *))
-:m_client(client),
-m_base(base),
-m_checkValid(checkValid),
-m_getSize(getSize),
-m_getItem(getItem),
-m_getItemName(getItemName),
-m_setItem(setItem)
-{
- // Incref to always have a existing pointer.
- Py_INCREF(m_base);
-}
-
-CListWrapper::~CListWrapper()
-{
- Py_DECREF(m_base);
-}
-
-bool CListWrapper::CheckValid()
-{
- if (m_base && !BGE_PROXY_REF(m_base)) {
- return false;
- }
- return m_checkValid ? (*m_checkValid)(m_client) : true;
-}
-
-int CListWrapper::GetSize()
-{
- return (*m_getSize)(m_client);
-}
-
-PyObject *CListWrapper::GetItem(int index)
-{
- return (*m_getItem)(m_client, index);
-}
-
-const char *CListWrapper::GetItemName(int index)
-{
- return (*m_getItemName)(m_client, index);
-}
-
-bool CListWrapper::SetItem(int index, PyObject *item)
-{
- return (*m_setItem)(m_client, index, item);
-}
-
-bool CListWrapper::AllowSetItem()
-{
- return m_setItem != NULL;
-}
-
-bool CListWrapper::AllowGetItemByName()
-{
- return m_getItemName != NULL;
-}
-
-// ================================================================
-
-const STR_String &CListWrapper::GetText()
-{
- return pythonGeneratorList;
-}
-
-void CListWrapper::SetName(const char *name)
-{
-}
-
-STR_String &CListWrapper::GetName()
-{
- return pythonGeneratorList;
-}
-
-CValue *CListWrapper::GetReplica()
-{
- return NULL;
-}
-
-CValue *CListWrapper::Calc(VALUE_OPERATOR op, CValue *val)
-{
- return NULL;
-}
-
-CValue *CListWrapper::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
-{
- return NULL;
-}
-
-double CListWrapper::GetNumber()
-{
- return -1;
-}
-
-int CListWrapper::GetValueType()
-{
- return -1;
-}
-
-// We convert all elements to python objects to make a proper repr string.
-PyObject *CListWrapper::py_repr()
-{
- if (!CheckValid()) {
- PyErr_SetString(PyExc_SystemError, "CListWrapper : repr, " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- PyObject *py_proxy = GetProxy();
- PyObject *py_list = PySequence_List(py_proxy);
- PyObject *py_string = PyObject_Repr(py_list);
- Py_DECREF(py_list);
- Py_DECREF(py_proxy);
- return py_string;
-}
-
-
-Py_ssize_t CListWrapper::py_len(PyObject *self)
-{
- CListWrapper *list = (CListWrapper *)BGE_PROXY_REF(self);
- // Invalid list.
- if (!list->CheckValid()) {
- PyErr_SetString(PyExc_SystemError, "len(CListWrapper), " BGE_PROXY_ERROR_MSG);
- return 0;
- }
-
- return (Py_ssize_t)list->GetSize();
-}
-
-PyObject *CListWrapper::py_get_item(PyObject *self, Py_ssize_t index)
-{
- CListWrapper *list = (CListWrapper *)BGE_PROXY_REF(self);
- // Invalid list.
- if (!list->CheckValid()) {
- PyErr_SetString(PyExc_SystemError, "val = CListWrapper[i], " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- int size = list->GetSize();
-
- if (index < 0) {
- index = size + index;
- }
- if (index < 0 || index >= size) {
- PyErr_SetString(PyExc_IndexError, "CListWrapper[i]: List index out of range in CListWrapper");
- return NULL;
- }
-
- PyObject *pyobj = list->GetItem(index);
-
- return pyobj;
-}
-
-int CListWrapper::py_set_item(PyObject *self, Py_ssize_t index, PyObject *value)
-{
- CListWrapper *list = (CListWrapper *)BGE_PROXY_REF(self);
- // Invalid list.
- if (!list->CheckValid()) {
- PyErr_SetString(PyExc_SystemError, "CListWrapper[i] = val, " BGE_PROXY_ERROR_MSG);
- return -1;
- }
-
- if (!list->AllowSetItem()) {
- PyErr_SetString(PyExc_TypeError, "CListWrapper's item type doesn't support assignment");
- return -1;
- }
-
- if (!value) {
- PyErr_SetString(PyExc_TypeError, "CListWrapper doesn't support item deletion");
- return -1;
- }
-
- int size = list->GetSize();
-
- if (index < 0) {
- index = size + index;
- }
- if (index < 0 || index >= size) {
- PyErr_SetString(PyExc_IndexError, "CListWrapper[i]: List index out of range in CListWrapper");
- return -1;
- }
-
- if (!list->SetItem(index, value)) {
- return -1;
- }
- return 0;
-}
-
-PyObject *CListWrapper::py_mapping_subscript(PyObject *self, PyObject *key)
-{
- CListWrapper *list = (CListWrapper *)BGE_PROXY_REF(self);
- // Invalid list.
- if (!list->CheckValid()) {
- PyErr_SetString(PyExc_SystemError, "val = CListWrapper[key], " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- if (PyIndex_Check(key)) {
- Py_ssize_t index = PyLong_AsSsize_t(key);
- return py_get_item(self, index);
- }
- else if (PyUnicode_Check(key)) {
- if (!list->AllowGetItemByName()) {
- PyErr_SetString(PyExc_SystemError, "CListWrapper's item type doesn't support access by key");
- return NULL;
- }
-
- const char *name = _PyUnicode_AsString(key);
- int size = list->GetSize();
-
- for (unsigned int i = 0; i < size; ++i) {
- if (strcmp(list->GetItemName(i), name) == 0) {
- return list->GetItem(i);
- }
- }
-
- PyErr_Format(PyExc_KeyError, "requested item \"%s\" does not exist", name);
- return NULL;
- }
-
- PyErr_Format(PyExc_KeyError, "CListWrapper[key]: '%R' key not in list", key);
- return NULL;
-}
-
-int CListWrapper::py_mapping_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
-{
- CListWrapper *list = (CListWrapper *)BGE_PROXY_REF(self);
- // Invalid list.
- if (!list->CheckValid()) {
- PyErr_SetString(PyExc_SystemError, "val = CListWrapper[key], " BGE_PROXY_ERROR_MSG);
- return -1;
- }
-
- if (!list->AllowSetItem()) {
- PyErr_SetString(PyExc_TypeError, "CListWrapper's item type doesn't support assignment");
- return -1;
- }
-
- if (PyIndex_Check(key)) {
- Py_ssize_t index = PyLong_AsSsize_t(key);
- return py_set_item(self, index, value);
- }
- else if (PyUnicode_Check(key)) {
- if (!list->AllowGetItemByName()) {
- PyErr_SetString(PyExc_SystemError, "CListWrapper's item type doesn't support access by key");
- return -1;
- }
-
- const char *name = _PyUnicode_AsString(key);
- int size = list->GetSize();
-
- for (unsigned int i = 0; i < size; ++i) {
- if (strcmp(list->GetItemName(i), name) == 0) {
- if (!list->SetItem(i, value)) {
- return -1;
- }
- return 0;
- }
- }
-
- PyErr_Format(PyExc_KeyError, "requested item \"%s\" does not exist", name);
- return -1;
- }
-
- PyErr_Format(PyExc_KeyError, "CListWrapper[key]: '%R' key not in list", key);
- return -1;
-}
-
-int CListWrapper::py_contains(PyObject *self, PyObject *key)
-{
- CListWrapper *list = (CListWrapper *)BGE_PROXY_REF(self);
- // Invalid list.
- if (!list->CheckValid()) {
- PyErr_SetString(PyExc_SystemError, "val = CListWrapper[i], " BGE_PROXY_ERROR_MSG);
- return -1;
- }
-
- if (!list->AllowGetItemByName()) {
- PyErr_SetString(PyExc_SystemError, "CListWrapper's item type doesn't support access by key");
- return -1;
- }
-
- if (!PyUnicode_Check(key)) {
- PyErr_SetString(PyExc_SystemError, "key in list, CListWrapper: key must be a string");
- return -1;
- }
-
- const char *name = _PyUnicode_AsString(key);
- int size = list->GetSize();
-
- for (unsigned int i = 0; i < size; ++i) {
- if (strcmp(list->GetItemName(i), name) == 0) {
- return 1;
- }
- }
-
- return 0;
-}
-
-PySequenceMethods CListWrapper::py_as_sequence = {
- py_len, // sq_length
- NULL, // sq_concat
- NULL, // sq_repeat
- py_get_item, // sq_item
- NULL, // sq_slice
- py_set_item, // sq_ass_item
- NULL, // sq_ass_slice
- (objobjproc)py_contains, // sq_contains
- (binaryfunc) NULL, // sq_inplace_concat
- (ssizeargfunc) NULL, // sq_inplace_repeat
-};
-
-PyMappingMethods CListWrapper::py_as_mapping = {
- py_len, // mp_length
- py_mapping_subscript, // mp_subscript
- py_mapping_ass_subscript // mp_ass_subscript
-};
-
-PyTypeObject CListWrapper::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "CListWrapper", // tp_name
- sizeof(PyObjectPlus_Proxy), // tp_basicsize
- 0, // tp_itemsize
- py_base_dealloc, // tp_dealloc
- 0, // tp_print
- 0, // tp_getattr
- 0, // tp_setattr
- 0, // tp_compare
- py_base_repr, // tp_repr
- 0, // tp_as_number
- &py_as_sequence, // tp_as_sequence
- &py_as_mapping, // tp_as_mapping
- 0, // tp_hash
- 0, // tp_call
- 0,
- NULL,
- NULL,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- 0,0,0,0,0,0,0,
- Methods,
- 0,
- 0,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef CListWrapper::Methods[] = {
- {"get", (PyCFunction)CListWrapper::sPyGet, METH_VARARGS},
- {NULL, NULL} //Sentinel
-};
-
-PyAttributeDef CListWrapper::Attributes[] = {
- {NULL} //Sentinel
-};
-
-/* Matches python dict.get(key, [default]) */
-PyObject *CListWrapper::PyGet(PyObject *args)
-{
- char *name;
- PyObject *def = Py_None;
-
- // Invalid list.
- if (!CheckValid()) {
- PyErr_SetString(PyExc_SystemError, "val = CListWrapper[i], " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- if (!AllowGetItemByName()) {
- PyErr_SetString(PyExc_SystemError, "CListWrapper's item type doesn't support access by key");
- return NULL;
- }
-
- if (!PyArg_ParseTuple(args, "s|O:get", &name, &def)) {
- return NULL;
- }
-
- for (unsigned int i = 0; i < GetSize(); ++i) {
- if (strcmp(GetItemName(i), name) == 0) {
- return GetItem(i);
- }
- }
-
- Py_INCREF(def);
- return def;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Expressions/intern/Operator1Expr.cpp b/source/gameengine/Expressions/intern/Operator1Expr.cpp
deleted file mode 100644
index add0376f487..00000000000
--- a/source/gameengine/Expressions/intern/Operator1Expr.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/** \file gameengine/Expressions/Operator1Expr.cpp
- * \ingroup expressions
- */
-// Operator1Expr.cpp: implementation of the COperator1Expr class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include "EXP_Operator1Expr.h"
-#include "EXP_EmptyValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-COperator1Expr::COperator1Expr()
-/*
-pre:
-effect: constucts an empty COperator1Expr
-*/
-{
- m_lhs = NULL;
-}
-
-COperator1Expr::COperator1Expr(VALUE_OPERATOR op, CExpression *lhs)
-/*
-pre:
-effect: constucts a COperator1Expr with op and lhs in it
-*/
-{
- m_lhs = lhs;
- m_op = op;
-}
-
-COperator1Expr::~COperator1Expr()
-/*
-pre:
-effect: deletes the object
-*/
-{
- if (m_lhs) m_lhs->Release();
-}
-
-CValue * COperator1Expr::Calculate()
-/*
-pre:
-ret: a new object containing the result of applying the operator m_op to the
- value of m_lhs
-*/
-{
- CValue *ret;
- CValue *temp = m_lhs->Calculate();
- CValue* empty = new CEmptyValue();
- ret = empty->Calc(m_op, temp);
- empty->Release();
- temp->Release();
-
- return ret;
-}
-
-/*
-bool COperator1Expr::IsInside(float x, float y, float z,bool bBorderInclude)
-{
-
- bool result = true;
- switch (m_op)
- {
-
- case VALUE_ADD_OPERATOR:
- {
-
- if (m_lhs)
- {
- result = result || m_lhs->IsInside(x,y,z,bBorderInclude);
- }
- break;
- }
- case VALUE_SUB_OPERATOR:
- {
- result = true;
- if (m_lhs)
- {
- result = result && (!m_lhs->IsInside(x,y,z,bBorderInclude));
- }
- break;
- }
- }
- return result;
-}
-
-*/
-bool COperator1Expr::NeedsRecalculated()
-{
- return m_lhs->NeedsRecalculated();
-}
-
-CExpression* COperator1Expr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks)
-{
-
- CExpression* newlhs = m_lhs->CheckLink(brokenlinks);
-
- if (newlhs)
- {
- if (newlhs==m_lhs) {
- // not changed
- } else {
- // changed
- //numchanges++;
- newlhs->AddRef();
-
- //m_lhs->Release();
- brokenlinks.push_back(new CBrokenLinkInfo(&m_lhs,m_lhs));
-
- m_lhs = newlhs;
- }
- return this;
- } else {
- //numchanges++;
- AddRef();
-
- return Release();
- }
-
-}
-
-void COperator1Expr::BroadcastOperators(VALUE_OPERATOR op)
-{
- if (m_lhs)
- m_lhs->BroadcastOperators(m_op);
-}
-
-
-
-
-bool COperator1Expr::MergeExpression(CExpression *otherexpr)
-{
- if (m_lhs)
- return m_lhs->MergeExpression(otherexpr);
-
- assertd(false); // should not get here, expression is not compatible for merge
- return false;
-}
diff --git a/source/gameengine/Expressions/intern/Operator2Expr.cpp b/source/gameengine/Expressions/intern/Operator2Expr.cpp
deleted file mode 100644
index 0a7f30b8cc8..00000000000
--- a/source/gameengine/Expressions/intern/Operator2Expr.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-/** \file gameengine/Expressions/Operator2Expr.cpp
- * \ingroup expressions
- */
-// Operator2Expr.cpp: implementation of the COperator2Expr class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-// 31 dec 1998 - big update: try to use the cached data for updating, instead of
-// rebuilding completely it from left and right node. Modified flags and bounding boxes
-// have to do the trick
-// when expression is cached, there will be a call to UpdateCalc() instead of Calc()
-
-#include "EXP_Operator2Expr.h"
-#include "EXP_StringValue.h"
-#include "EXP_VoidValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-COperator2Expr::COperator2Expr(VALUE_OPERATOR op, CExpression *lhs, CExpression *rhs)
-:
-m_rhs(rhs),
-m_lhs(lhs),
-m_cached_calculate(NULL),
-m_op(op)
-/*
-pre:
-effect: constucts a COperator2Expr with op, lhs and rhs in it
-*/
-{
-
-}
-
-COperator2Expr::COperator2Expr():
-m_rhs(NULL),
-m_lhs(NULL),
-m_cached_calculate(NULL)
-
-/*
-pre:
-effect: constucts an empty COperator2Expr
-*/
-{
-
-}
-
-COperator2Expr::~COperator2Expr()
-/*
-pre:
-effect: deletes the object
-*/
-{
- if (m_lhs)
- m_lhs->Release();
- if (m_rhs)
- m_rhs->Release();
- if (m_cached_calculate)
- m_cached_calculate->Release();
-
-}
-CValue* COperator2Expr::Calculate()
-/*
-pre:
-ret: a new object containing the result of applying operator m_op to m_lhs
-and m_rhs
-*/
-{
-
- bool leftmodified,rightmodified;
- leftmodified = m_lhs->NeedsRecalculated();
- rightmodified = m_rhs->NeedsRecalculated();
-
- // if no modifications on both left and right subtree, and result is already calculated
- // then just return cached result...
- if (!leftmodified && !rightmodified && (m_cached_calculate))
- {
- // not modified, just return m_cached_calculate
- } else {
- // if not yet calculated, or modified...
-
-
- if (m_cached_calculate) {
- m_cached_calculate->Release();
- m_cached_calculate=NULL;
- }
-
- CValue* ffleft = m_lhs->Calculate();
- CValue* ffright = m_rhs->Calculate();
-
- ffleft->SetOwnerExpression(this);//->m_pOwnerExpression=this;
- ffright->SetOwnerExpression(this);//->m_pOwnerExpression=this;
-
- m_cached_calculate = ffleft->Calc(m_op,ffright);
-
- //if (m_cached_calculate)
- // m_cached_calculate->Action(CValue::SETOWNEREXPR,&CVoidValue(this,false,CValue::STACKVALUE));
-
- ffleft->Release();
- ffright->Release();
- }
-
- return m_cached_calculate->AddRef();
-
-}
-
-#if 0
-bool COperator2Expr::IsInside(float x, float y, float z,bool bBorderInclude)
-{
- bool inside;
- inside = false;
-
- switch (m_op) {
- case VALUE_ADD_OPERATOR:
- {
- // inside = first || second; // optimized with early out if first is inside
- // todo: calculate smallest leaf first ! is much faster...
-
- bool second;//first ;//,second;
-
- //first = m_lhs->IsInside(x,y,z);
- second = m_rhs->IsInside(x,y,z,bBorderInclude);
- if (second)
- return true; //early out
-
- // second = m_rhs->IsInside(x,y,z);
-
- return m_lhs->IsInside(x,y,z,bBorderInclude);
-
- break;
- }
-
- case VALUE_SUB_OPERATOR:
- {
- //inside = first && !second; // optimized with early out
- // todo: same as with add_operator: calc smallest leaf first
-
- bool second;//first ;//,second;
- //first = m_lhs->IsInside(x,y,z);
- second = m_rhs->IsInside(x,y,z,bBorderInclude);
- if (second)
- return false;
-
- // second space get subtracted -> negate!
- //second = m_rhs->IsInside(x,y,z);
-
- return (m_lhs->IsInside(x,y,z,bBorderInclude));
-
-
- break;
- }
- default:
- {
- assert(false);
- // not yet implemented, only add or sub csg operations
- }
- }
-
- return inside;
-}
-
-bool COperator2Expr::IsRightInside(float x, float y, float z,bool bBorderInclude)
-{
- return m_rhs->IsInside(x,y,z,bBorderInclude);
-}
-
-bool COperator2Expr::IsLeftInside(float x, float y, float z,bool bBorderInclude)
-{
- return m_lhs->IsInside(x,y,z,bBorderInclude);
-}
-#endif
-
-bool COperator2Expr::NeedsRecalculated()
-{
- // added some lines, just for debugging purposes, it could be a one-liner :)
- //bool modleft
- //bool modright;
- assertd(m_lhs);
- assertd(m_rhs);
-
- //modright = m_rhs->NeedsRecalculated();
- if (m_rhs->NeedsRecalculated()) // early out
- return true;
- return m_lhs->NeedsRecalculated();
- //modleft = m_lhs->NeedsRecalculated();
- //return (modleft || modright);
-
-}
-
-
-
-CExpression* COperator2Expr::CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks)
-{
-// if both children are 'dead', return NULL
-// if only one child is alive, return that child
-// if both childresn are alive, return this
-
-
-// bool leftalive = true,rightalive=true;
- /* Does this mean the function will always bomb? */
- assertd(false);
- assert(m_lhs);
- assert(m_rhs);
-/*
- if (m_cached_calculate)
- m_cached_calculate->Action(CValue::REFRESH_CACHE);
-
- CExpression* newlhs = m_lhs->CheckLink(brokenlinks);
- CExpression* newrhs = m_rhs->CheckLink(brokenlinks);
-
- if (m_lhs != newlhs)
- {
- brokenlinks.push_back(new CBrokenLinkInfo(&m_lhs,m_lhs));
- }
-
- if (m_rhs != newrhs)
- {
- brokenlinks.push_back(new CBrokenLinkInfo(&m_rhs,m_rhs));
- }
-
-
-
- m_lhs = newlhs;
- m_rhs = newrhs;
-
- if (m_lhs && m_rhs) {
- return this;
- }
-
- AddRef();
- if (m_lhs)
- return Release(m_lhs->AddRef());
-
- if (m_rhs)
- return Release(m_rhs->AddRef());
-/
-
- */
- return Release();
-}
-
-
-bool COperator2Expr::MergeExpression(CExpression *otherexpr)
-{
- if (m_lhs)
- {
- if (m_lhs->GetExpressionID() == CExpression::CCONSTEXPRESSIONID)
- {
- // cross fingers ;) replace constexpr by new tree...
- m_lhs->Release();
- m_lhs = otherexpr->AddRef();
- return true;
- }
- }
-
- assertd(false);
- return false;
-}
-
-
-void COperator2Expr::BroadcastOperators(VALUE_OPERATOR op)
-{
- if (m_lhs)
- m_lhs->BroadcastOperators(m_op);
- if (m_rhs)
- m_rhs->BroadcastOperators(m_op);
-}
diff --git a/source/gameengine/Expressions/intern/PyObjectPlus.cpp b/source/gameengine/Expressions/intern/PyObjectPlus.cpp
deleted file mode 100644
index 1e4a59aeb5c..00000000000
--- a/source/gameengine/Expressions/intern/PyObjectPlus.cpp
+++ /dev/null
@@ -1,1226 +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/Expressions/PyObjectPlus.cpp
- * \ingroup expressions
- */
-
-
-/*------------------------------
- * PyObjectPlus cpp
- *
- * C++ library routines for Crawl 3.2
- *
- * Derived from work by
- * David Redish
- * graduate student
- * Computer Science Department
- * Carnegie Mellon University (CMU)
- * Center for the Neural Basis of Cognition (CNBC)
- * http://www.python.org/doc/PyCPP.html
- *
- * ----------------------------- */
-#include <stdlib.h>
-#include <stddef.h>
-
-#include "EXP_PyObjectPlus.h"
-#include "STR_String.h"
-#include "MT_Vector3.h"
-#include "MEM_guardedalloc.h"
-
-PyObjectPlus::~PyObjectPlus()
-{
-#ifdef WITH_PYTHON
- if (m_proxy) {
- BGE_PROXY_REF(m_proxy)= NULL;
- Py_DECREF(m_proxy); /* Remove own reference, python may still have 1 */
- }
-// assert(ob_refcnt==0);
-#endif
-}
-
-PyObjectPlus::PyObjectPlus() : SG_QList() // constructor
-{
-#ifdef WITH_PYTHON
- m_proxy= NULL;
-#endif
-};
-
-void PyObjectPlus::ProcessReplica()
-{
-#ifdef WITH_PYTHON
- /* Clear the proxy, will be created again if needed with GetProxy()
- * otherwise the PyObject will point to the wrong reference */
- m_proxy= NULL;
-#endif
-}
-
-/* Sometimes we might want to manually invalidate a BGE type even if
- * it hasn't been released by the BGE, say for example when an object
- * is removed from a scene, accessing it may cause problems.
- *
- * In this case the current proxy is made invalid, disowned,
- * and will raise an error on access. However if python can get access
- * to this class again it will make a new proxy and work as expected.
- */
-void PyObjectPlus::InvalidateProxy() // check typename of each parent
-{
-#ifdef WITH_PYTHON
- if (m_proxy) {
- BGE_PROXY_REF(m_proxy)=NULL;
- Py_DECREF(m_proxy);
- m_proxy= NULL;
- }
-#endif
-}
-
-
-#ifdef WITH_PYTHON
-
-/*------------------------------
- * PyObjectPlus Type -- Every class, even the abstract one should have a Type
- * ----------------------------- */
-
-
-PyTypeObject PyObjectPlus::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "PyObjectPlus", /*tp_name*/
- sizeof(PyObjectPlus_Proxy), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- py_base_dealloc, /* tp_dealloc */
- 0, /* printfunc tp_print; */
- 0, /* getattrfunc tp_getattr; */
- 0, /* setattrfunc tp_setattr; */
- 0, /* tp_compare */ /* DEPRECATED in python 3.0! */
- py_base_repr, /* tp_repr */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Method suites for standard classes */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
- 0, 0, 0, 0,
- /* weak reference enabler */
-#ifdef USE_WEAKREFS
- offsetof(PyObjectPlus_Proxy, in_weakreflist), /* long tp_weaklistoffset; */
-#else
- 0,
-#endif
- 0, 0,
- Methods,
- 0,
- 0,
- NULL // no subtype
-};
-
-PyObject *PyObjectPlus::py_base_repr(PyObject *self) // This should be the entry in Type.
-{
- PyObjectPlus *self_plus= BGE_PROXY_REF(self);
- if (self_plus==NULL) {
- PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
- return NULL;
- }
- return self_plus->py_repr();
-}
-
-
-PyObject *PyObjectPlus::py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- PyTypeObject *base_type;
-
- /* one or more args is needed */
- if (!PyTuple_GET_SIZE(args)) {
- PyErr_SetString(PyExc_TypeError,
- "Expected at least one argument");
- return NULL;
- }
-
- PyObjectPlus_Proxy *base = (PyObjectPlus_Proxy *)PyTuple_GET_ITEM(args, 0);
-
- /**
- * the 'base' PyObject may be subclassed (multiple times even)
- * we need to find the first C++ defined class to check 'type'
- * is a subclass of the base arguments type.
- *
- * This way we can share one tp_new function for every PyObjectPlus
- *
- * eg.
- *
- * # CustomOb is called 'type' in this C code
- * \code{.py}
- * class CustomOb(GameTypes.KX_GameObject):
- * pass
- *
- * # this calls py_base_new(...), the type of 'CustomOb' is checked to be a subclass of the 'cont.owner' type
- * ob = CustomOb(cont.owner)
- * \endcode
- * */
- base_type= Py_TYPE(base);
- while (base_type && !BGE_PROXY_CHECK_TYPE(base_type))
- base_type= base_type->tp_base;
-
- if (base_type==NULL || !BGE_PROXY_CHECK_TYPE(base_type)) {
- PyErr_SetString(PyExc_TypeError, "can't subclass from a blender game type because the argument given is not a game class or subclass");
- return NULL;
- }
-
- /* use base_type rather than Py_TYPE(base) because we could already be subtyped */
- if (!PyType_IsSubtype(type, base_type)) {
- PyErr_Format(PyExc_TypeError, "can't subclass blender game type <%s> from <%s> because it is not a subclass", base_type->tp_name, type->tp_name);
- return NULL;
- }
-
- /* invalidate the existing base and return a new subclassed one,
- * this is a bit dodgy in that it also attaches its self to the existing object
- * which is not really 'correct' python OO but for our use its OK. */
-
- PyObjectPlus_Proxy *ret = (PyObjectPlus_Proxy *) type->tp_alloc(type, 0); /* starts with 1 ref, used for the return ref' */
- ret->ref= base->ref;
- ret->ptr= base->ptr;
- ret->py_owns= base->py_owns;
- ret->py_ref = base->py_ref;
-
- if (ret->py_ref) {
- base->ref= NULL; /* invalidate! disallow further access */
- base->ptr = NULL;
- if (ret->ref)
- ret->ref->m_proxy= NULL;
- /* 'base' may be freed after this func finished but not necessarily
- * there is no reference to the BGE data now so it will throw an error on access */
- Py_DECREF(base);
- if (ret->ref) {
- ret->ref->m_proxy= (PyObject *)ret; /* no need to add a ref because one is added when creating. */
- Py_INCREF(ret); /* we return a new ref but m_proxy holds a ref so we need to add one */
- }
- } else {
- // generic structures don't hold a reference to this proxy, so don't increment ref count
- if (ret->py_owns)
- // but if the proxy owns the structure, there can be only one owner
- base->ptr= NULL;
- }
-
- return (PyObject *)ret;
-}
-
-/**
- * \param self A PyObjectPlus_Proxy
- */
-void PyObjectPlus::py_base_dealloc(PyObject *self) // python wrapper
-{
-#ifdef USE_WEAKREFS
- if (BGE_PROXY_WKREF(self) != NULL)
- PyObject_ClearWeakRefs((PyObject *) self);
-#endif
-
- if (BGE_PROXY_PYREF(self)) {
- PyObjectPlus *self_plus= BGE_PROXY_REF(self);
- if (self_plus) {
- if (BGE_PROXY_PYOWNS(self)) { /* Does python own this?, then delete it */
- self_plus->m_proxy = NULL; /* Need this to stop ~PyObjectPlus from decrefing m_proxy otherwise its decref'd twice and py-debug crashes */
- delete self_plus;
- }
- BGE_PROXY_REF(self)= NULL; // not really needed
- }
- // the generic pointer is not deleted directly, only through self_plus
- BGE_PROXY_PTR(self)= NULL; // not really needed
- } else {
- void *ptr= BGE_PROXY_PTR(self);
- if (ptr) {
- if (BGE_PROXY_PYOWNS(self)) { /* Does python own this?, then delete it */
- // generic structure owned by python MUST be created though MEM_alloc
- MEM_freeN(ptr);
- }
- BGE_PROXY_PTR(self)= NULL; // not really needed
- }
- }
-#if 0
- /* is ok normally but not for subtyping, use tp_free instead. */
- PyObject_DEL( self );
-#else
- Py_TYPE(self)->tp_free(self);
-#endif
-};
-
-/*------------------------------
- * PyObjectPlus Methods -- Every class, even the abstract one should have a Methods
-------------------------------*/
-PyMethodDef PyObjectPlus::Methods[] = {
- {NULL, NULL} /* Sentinel */
-};
-
-#define BGE_PY_ATTR_INVALID (&(PyObjectPlus::Attributes[0]))
-PyAttributeDef PyObjectPlus::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("invalid", PyObjectPlus, pyattr_get_invalid),
- {NULL} //Sentinel
-};
-
-
-
-PyObject *PyObjectPlus::pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- return PyBool_FromLong(self_v ? 0:1);
-}
-
-/* note, this is called as a python 'getset, where the PyAttributeDef is the closure */
-PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef *attrdef)
-{
- PyObjectPlus *ref= (BGE_PROXY_REF(self_py));
- char* ptr = (attrdef->m_usePtr) ? (char*)BGE_PROXY_PTR(self_py) : (char*)ref;
- if (ptr == NULL || (BGE_PROXY_PYREF(self_py) && (ref==NULL || !ref->py_is_valid()))) {
- if (attrdef == BGE_PY_ATTR_INVALID)
- Py_RETURN_TRUE; // don't bother running the function
-
- PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)
- {
- // fake attribute, ignore
- return NULL;
- }
- if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_FUNCTION)
- {
- // the attribute has no field correspondence, handover processing to function.
- if (attrdef->m_getFunction == NULL)
- return NULL;
- return (*attrdef->m_getFunction)(ptr, attrdef);
- }
- ptr += attrdef->m_offset;
- if (attrdef->m_length > 1)
- {
- PyObject *resultlist = PyList_New(attrdef->m_length);
- for (unsigned int i=0; i<attrdef->m_length; i++)
- {
- switch (attrdef->m_type) {
- case KX_PYATTRIBUTE_TYPE_BOOL:
- {
- bool *val = reinterpret_cast<bool*>(ptr);
- ptr += sizeof(bool);
- PyList_SET_ITEM(resultlist, i, PyBool_FromLong(*val));
- break;
- }
- case KX_PYATTRIBUTE_TYPE_SHORT:
- {
- short int *val = reinterpret_cast<short int*>(ptr);
- ptr += sizeof(short int);
- PyList_SET_ITEM(resultlist, i, PyLong_FromLong(*val));
- break;
- }
- case KX_PYATTRIBUTE_TYPE_ENUM:
- // enum are like int, just make sure the field size is the same
- if (sizeof(int) != attrdef->m_size)
- {
- Py_DECREF(resultlist);
- return NULL;
- }
- ATTR_FALLTHROUGH;
- case KX_PYATTRIBUTE_TYPE_INT:
- {
- int *val = reinterpret_cast<int*>(ptr);
- ptr += sizeof(int);
- PyList_SET_ITEM(resultlist, i, PyLong_FromLong(*val));
- break;
- }
- case KX_PYATTRIBUTE_TYPE_FLOAT:
- {
- float *val = reinterpret_cast<float*>(ptr);
- ptr += sizeof(float);
- PyList_SET_ITEM(resultlist, i, PyFloat_FromDouble(*val));
- break;
- }
- default:
- // no support for array of complex data
- Py_DECREF(resultlist);
- return NULL;
- }
- }
- return resultlist;
- }
- else
- {
- switch (attrdef->m_type) {
- case KX_PYATTRIBUTE_TYPE_FLAG:
- {
- bool bval;
- switch (attrdef->m_size) {
- case 1:
- {
- unsigned char *val = reinterpret_cast<unsigned char*>(ptr);
- bval = (*val & attrdef->m_imin);
- break;
- }
- case 2:
- {
- unsigned short *val = reinterpret_cast<unsigned short*>(ptr);
- bval = (*val & attrdef->m_imin);
- break;
- }
- case 4:
- {
- unsigned int *val = reinterpret_cast<unsigned int*>(ptr);
- bval = (*val & attrdef->m_imin);
- break;
- }
- default:
- return NULL;
- }
- if (attrdef->m_imax)
- bval = !bval;
- return PyBool_FromLong(bval);
- }
- case KX_PYATTRIBUTE_TYPE_BOOL:
- {
- bool *val = reinterpret_cast<bool*>(ptr);
- return PyBool_FromLong(*val);
- }
- case KX_PYATTRIBUTE_TYPE_SHORT:
- {
- short int *val = reinterpret_cast<short int*>(ptr);
- return PyLong_FromLong(*val);
- }
- case KX_PYATTRIBUTE_TYPE_ENUM:
- // enum are like int, just make sure the field size is the same
- if (sizeof(int) != attrdef->m_size)
- {
- return NULL;
- }
- ATTR_FALLTHROUGH;
- case KX_PYATTRIBUTE_TYPE_INT:
- {
- int *val = reinterpret_cast<int*>(ptr);
- return PyLong_FromLong(*val);
- }
- case KX_PYATTRIBUTE_TYPE_FLOAT:
- {
- float *val = reinterpret_cast<float*>(ptr);
- if (attrdef->m_imin == 0) {
- if (attrdef->m_imax == 0) {
- return PyFloat_FromDouble(*val);
- } else {
- // vector, verify size
- if (attrdef->m_size != attrdef->m_imax*sizeof(float))
- {
- return NULL;
- }
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject(val, attrdef->m_imax, NULL);
-#else
- PyObject *resultlist = PyList_New(attrdef->m_imax);
- for (unsigned int i=0; i<attrdef->m_imax; i++)
- {
- PyList_SET_ITEM(resultlist, i, PyFloat_FromDouble(val[i]));
- }
- return resultlist;
-#endif
- }
- } else {
- // matrix case
- if (attrdef->m_size != attrdef->m_imax*attrdef->m_imin*sizeof(float))
- {
- return NULL;
- }
-#ifdef USE_MATHUTILS
- return Matrix_CreatePyObject_wrap(val, attrdef->m_imin, attrdef->m_imax, NULL);
-#else
- PyObject *collist = PyList_New(attrdef->m_imin);
- for (unsigned int i=0; i<attrdef->m_imin; i++)
- {
- PyObject *col = PyList_New(attrdef->m_imax);
- for (unsigned int j=0; j<attrdef->m_imax; j++)
- {
- PyList_SET_ITEM(col, j, PyFloat_FromDouble(val[j]));
- }
- PyList_SET_ITEM(collist, i, col);
- val += attrdef->m_imax;
- }
- return collist;
-#endif
- }
- }
- case KX_PYATTRIBUTE_TYPE_VECTOR:
- {
- MT_Vector3 *val = reinterpret_cast<MT_Vector3*>(ptr);
-#ifdef USE_MATHUTILS
- float fval[3];
- val->getValue(fval);
- return Vector_CreatePyObject(fval, 3, NULL);
-#else
- PyObject *resultlist = PyList_New(3);
- for (unsigned int i=0; i<3; i++)
- {
- PyList_SET_ITEM(resultlist, i, PyFloat_FromDouble((*val)[i]));
- }
- return resultlist;
-#endif
- }
- case KX_PYATTRIBUTE_TYPE_STRING:
- {
- STR_String *val = reinterpret_cast<STR_String*>(ptr);
- return PyUnicode_From_STR_String(*val);
- }
- case KX_PYATTRIBUTE_TYPE_CHAR:
- {
- return PyUnicode_FromString(ptr);
- }
- default:
- return NULL;
- }
- }
-}
-
-
-static bool py_check_attr_float(float *var, PyObject *value, const PyAttributeDef *attrdef)
-{
- float val = PyFloat_AsDouble(value);
- if (val == -1.0f && PyErr_Occurred())
- {
- PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name);
- return false;
- }
- if (attrdef->m_clamp)
- {
- if (val < attrdef->m_fmin)
- val = attrdef->m_fmin;
- else if (val > attrdef->m_fmax)
- val = attrdef->m_fmax;
- }
- else if (val < attrdef->m_fmin || val > attrdef->m_fmax)
- {
- PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name);
- return false;
- }
- *var = (float)val;
- return true;
-}
-
-/* note, this is called as a python getset */
-int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAttributeDef *attrdef)
-{
- PyObjectPlus *ref= (BGE_PROXY_REF(self_py));
- char* ptr = (attrdef->m_usePtr) ? (char*)BGE_PROXY_PTR(self_py) : (char*)ref;
- if (ref==NULL || !ref->py_is_valid() || ptr==NULL) {
- PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
- return PY_SET_ATTR_FAIL;
- }
-
- void *undoBuffer = NULL;
- void *sourceBuffer = NULL;
- size_t bufferSize = 0;
- PyObject *item = NULL; // to store object that must be dereferenced in case of error
- PyObject *list = NULL; // to store object that must be dereferenced in case of error
-
- ptr += attrdef->m_offset;
- if (attrdef->m_length > 1)
- {
- if (!PySequence_Check(value))
- {
- PyErr_Format(PyExc_TypeError, "expected a sequence for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
- if (PySequence_Size(value) != attrdef->m_length)
- {
- PyErr_Format(PyExc_TypeError, "incorrect number of elements in sequence for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
- switch (attrdef->m_type)
- {
- case KX_PYATTRIBUTE_TYPE_FUNCTION:
- if (attrdef->m_setFunction == NULL)
- {
- PyErr_Format(PyExc_AttributeError, "function attribute without function for attribute \"%s\", report to blender.org", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
- return (*attrdef->m_setFunction)(ref, attrdef, value);
- case KX_PYATTRIBUTE_TYPE_BOOL:
- bufferSize = sizeof(bool);
- break;
- case KX_PYATTRIBUTE_TYPE_SHORT:
- bufferSize = sizeof(short int);
- break;
- case KX_PYATTRIBUTE_TYPE_ENUM:
- case KX_PYATTRIBUTE_TYPE_INT:
- bufferSize = sizeof(int);
- break;
- case KX_PYATTRIBUTE_TYPE_FLOAT:
- bufferSize = sizeof(float);
- break;
- default:
- // should not happen
- PyErr_Format(PyExc_AttributeError, "Unsupported attribute type for attribute \"%s\", report to blender.org", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
- // let's implement a smart undo method
- bufferSize *= attrdef->m_length;
- undoBuffer = malloc(bufferSize);
- sourceBuffer = ptr;
- if (undoBuffer)
- {
- memcpy(undoBuffer, sourceBuffer, bufferSize);
- }
- for (int i=0; i<attrdef->m_length; i++)
- {
- item = PySequence_GetItem(value, i); /* new ref */
- switch (attrdef->m_type)
- {
- case KX_PYATTRIBUTE_TYPE_BOOL:
- {
- bool *var = reinterpret_cast<bool*>(ptr);
- ptr += sizeof(bool);
- if (PyLong_Check(item))
- {
- *var = (PyLong_AsLong(item) != 0);
- }
- else if (PyBool_Check(item))
- {
- *var = (item == Py_True);
- }
- else
- {
- PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name);
- goto UNDO_AND_ERROR;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_SHORT:
- {
- short int *var = reinterpret_cast<short int*>(ptr);
- ptr += sizeof(short int);
- if (PyLong_Check(item))
- {
- int val = PyLong_AsLong(item);
- if (attrdef->m_clamp)
- {
- if (val < attrdef->m_imin)
- val = attrdef->m_imin;
- else if (val > attrdef->m_imax)
- val = attrdef->m_imax;
- }
- else if (val < attrdef->m_imin || val > attrdef->m_imax)
- {
- PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name);
- goto UNDO_AND_ERROR;
- }
- *var = (short int)val;
- }
- else
- {
- PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name);
- goto UNDO_AND_ERROR;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_ENUM:
- // enum are equivalent to int, just make sure that the field size matches:
- if (sizeof(int) != attrdef->m_size)
- {
- PyErr_Format(PyExc_AttributeError, "Size check error for attribute, \"%s\", report to blender.org", attrdef->m_name);
- goto UNDO_AND_ERROR;
- }
- ATTR_FALLTHROUGH;
- case KX_PYATTRIBUTE_TYPE_INT:
- {
- int *var = reinterpret_cast<int*>(ptr);
- ptr += sizeof(int);
- if (PyLong_Check(item))
- {
- int val = PyLong_AsLong(item);
- if (attrdef->m_clamp)
- {
- if (val < attrdef->m_imin)
- val = attrdef->m_imin;
- else if (val > attrdef->m_imax)
- val = attrdef->m_imax;
- }
- else if (val < attrdef->m_imin || val > attrdef->m_imax)
- {
- PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name);
- goto UNDO_AND_ERROR;
- }
- *var = (int)val;
- }
- else
- {
- PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name);
- goto UNDO_AND_ERROR;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_FLOAT:
- {
- float *var = reinterpret_cast<float*>(ptr);
- ptr += sizeof(float);
- float val = PyFloat_AsDouble(item);
- if (val == -1.0f && PyErr_Occurred())
- {
- PyErr_Format(PyExc_TypeError, "expected a float for attribute \"%s\"", attrdef->m_name);
- goto UNDO_AND_ERROR;
- }
- else if (attrdef->m_clamp)
- {
- if (val < attrdef->m_fmin)
- val = attrdef->m_fmin;
- else if (val > attrdef->m_fmax)
- val = attrdef->m_fmax;
- }
- else if (val < attrdef->m_fmin || val > attrdef->m_fmax)
- {
- PyErr_Format(PyExc_ValueError, "item value out of range for attribute \"%s\"", attrdef->m_name);
- goto UNDO_AND_ERROR;
- }
- *var = (float)val;
- break;
- }
- default:
- // should not happen
- PyErr_Format(PyExc_AttributeError, "type check error for attribute \"%s\", report to blender.org", attrdef->m_name);
- goto UNDO_AND_ERROR;
- }
- // finished using item, release
- Py_DECREF(item);
- item = NULL;
- }
- // no error, call check function if any
- if (attrdef->m_checkFunction != NULL)
- {
- if ((*attrdef->m_checkFunction)(ref, attrdef) != 0)
- {
- // if the checing function didnt set an error then set a generic one here so we don't set an error with no exception
- if (PyErr_Occurred()==0)
- PyErr_Format(PyExc_AttributeError, "type check error for attribute \"%s\", reasion unknown", attrdef->m_name);
-
- // post check returned an error, restore values
- UNDO_AND_ERROR:
- if (undoBuffer)
- {
- memcpy(sourceBuffer, undoBuffer, bufferSize);
- free(undoBuffer);
- }
- if (item)
- Py_DECREF(item);
- return PY_SET_ATTR_FAIL;
- }
- }
- if (undoBuffer)
- free(undoBuffer);
- return PY_SET_ATTR_SUCCESS;
- }
- else // simple attribute value
- {
- if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_FUNCTION)
- {
- if (attrdef->m_setFunction == NULL)
- {
- PyErr_Format(PyExc_AttributeError, "function attribute without function \"%s\", report to blender.org", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
- return (*attrdef->m_setFunction)(ref, attrdef, value);
- }
- if (attrdef->m_checkFunction != NULL || attrdef->m_type == KX_PYATTRIBUTE_TYPE_VECTOR)
- {
- // post check function is provided, prepare undo buffer
- sourceBuffer = ptr;
- switch (attrdef->m_type)
- {
- case KX_PYATTRIBUTE_TYPE_BOOL:
- bufferSize = sizeof(bool);
- break;
- case KX_PYATTRIBUTE_TYPE_SHORT:
- bufferSize = sizeof(short);
- break;
- case KX_PYATTRIBUTE_TYPE_ENUM:
- case KX_PYATTRIBUTE_TYPE_FLAG:
- case KX_PYATTRIBUTE_TYPE_CHAR:
- bufferSize = attrdef->m_size;
- break;
- case KX_PYATTRIBUTE_TYPE_INT:
- bufferSize = sizeof(int);
- break;
- case KX_PYATTRIBUTE_TYPE_FLOAT:
- bufferSize = sizeof(float);
- if (attrdef->m_imax)
- bufferSize *= attrdef->m_imax;
- if (attrdef->m_imin)
- bufferSize *= attrdef->m_imin;
- break;
- case KX_PYATTRIBUTE_TYPE_STRING:
- sourceBuffer = reinterpret_cast<STR_String*>(ptr)->Ptr();
- if (sourceBuffer)
- bufferSize = strlen(reinterpret_cast<char*>(sourceBuffer))+1;
- break;
- case KX_PYATTRIBUTE_TYPE_VECTOR:
- bufferSize = sizeof(MT_Vector3);
- break;
- default:
- PyErr_Format(PyExc_AttributeError, "unknown type for attribute \"%s\", report to blender.org", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
- if (bufferSize)
- {
- undoBuffer = malloc(bufferSize);
- if (undoBuffer)
- {
- memcpy(undoBuffer, sourceBuffer, bufferSize);
- }
- }
- }
-
- switch (attrdef->m_type)
- {
- case KX_PYATTRIBUTE_TYPE_BOOL:
- {
- bool *var = reinterpret_cast<bool*>(ptr);
- if (PyLong_Check(value))
- {
- *var = (PyLong_AsLong(value) != 0);
- }
- else if (PyBool_Check(value))
- {
- *var = (value == Py_True);
- }
- else
- {
- PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_FLAG:
- {
- bool bval;
- if (PyLong_Check(value))
- {
- bval = (PyLong_AsLong(value) != 0);
- }
- else if (PyBool_Check(value))
- {
- bval = (value == Py_True);
- }
- else
- {
- PyErr_Format(PyExc_TypeError, "expected an integer or a bool for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- if (attrdef->m_imax)
- bval = !bval;
- switch (attrdef->m_size) {
- case 1:
- {
- unsigned char *val = reinterpret_cast<unsigned char*>(ptr);
- *val = (*val & ~attrdef->m_imin) | ((bval)?attrdef->m_imin:0);
- break;
- }
- case 2:
- {
- unsigned short *val = reinterpret_cast<unsigned short*>(ptr);
- *val = (*val & ~attrdef->m_imin) | ((bval)?attrdef->m_imin:0);
- break;
- }
- case 4:
- {
- unsigned int *val = reinterpret_cast<unsigned int*>(ptr);
- *val = (*val & ~attrdef->m_imin) | ((bval)?attrdef->m_imin:0);
- break;
- }
- default:
- PyErr_Format(PyExc_TypeError, "internal error: unsupported flag field \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_SHORT:
- {
- short int *var = reinterpret_cast<short int*>(ptr);
- if (PyLong_Check(value))
- {
- int val = PyLong_AsLong(value);
- if (attrdef->m_clamp)
- {
- if (val < attrdef->m_imin)
- val = attrdef->m_imin;
- else if (val > attrdef->m_imax)
- val = attrdef->m_imax;
- }
- else if (val < attrdef->m_imin || val > attrdef->m_imax)
- {
- PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- *var = (short int)val;
- }
- else
- {
- PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_ENUM:
- // enum are equivalent to int, just make sure that the field size matches:
- if (sizeof(int) != attrdef->m_size)
- {
- PyErr_Format(PyExc_AttributeError, "attribute size check error for attribute \"%s\", report to blender.org", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- ATTR_FALLTHROUGH;
- case KX_PYATTRIBUTE_TYPE_INT:
- {
- int *var = reinterpret_cast<int*>(ptr);
- if (PyLong_Check(value))
- {
- int val = PyLong_AsLong(value);
- if (attrdef->m_clamp)
- {
- if (val < attrdef->m_imin)
- val = attrdef->m_imin;
- else if (val > attrdef->m_imax)
- val = attrdef->m_imax;
- }
- else if (val < attrdef->m_imin || val > attrdef->m_imax)
- {
- PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- *var = (int)val;
- }
- else
- {
- PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_FLOAT:
- {
- float *var = reinterpret_cast<float*>(ptr);
- if (attrdef->m_imin != 0)
- {
- if (attrdef->m_size != attrdef->m_imin*attrdef->m_imax*sizeof(float))
- {
- PyErr_Format(PyExc_TypeError, "internal error: incorrect field size for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- if (!PySequence_Check(value) || PySequence_Size(value) != attrdef->m_imin)
- {
- PyErr_Format(PyExc_TypeError, "expected a sequence of [%d][%d] floats for attribute \"%s\"", attrdef->m_imin, attrdef->m_imax, attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- for (int i=0; i<attrdef->m_imin; i++)
- {
- PyObject *list = PySequence_GetItem(value, i); /* new ref */
- if (!PySequence_Check(list) || PySequence_Size(list) != attrdef->m_imax)
- {
- PyErr_Format(PyExc_TypeError, "expected a sequence of [%d][%d] floats for attribute \"%s\"", attrdef->m_imin, attrdef->m_imax, attrdef->m_name);
- goto RESTORE_AND_ERROR;
- }
- for (int j=0; j<attrdef->m_imax; j++)
- {
- item = PySequence_GetItem(list, j); /* new ref */
- if (!py_check_attr_float(var, item, attrdef))
- {
- PyErr_Format(PyExc_TypeError, "expected a sequence of [%d][%d] floats for attribute \"%s\"", attrdef->m_imin, attrdef->m_imax, attrdef->m_name);
- goto RESTORE_AND_ERROR;
- }
- Py_DECREF(item);
- item = NULL;
- ++var;
- }
- Py_DECREF(list);
- list = NULL;
- }
- }
- else if (attrdef->m_imax != 0)
- {
- if (attrdef->m_size != attrdef->m_imax*sizeof(float))
- {
- PyErr_Format(PyExc_TypeError, "internal error: incorrect field size for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- if (!PySequence_Check(value) || PySequence_Size(value) != attrdef->m_imax)
- {
- PyErr_Format(PyExc_TypeError, "expected a sequence of [%d] floats for attribute \"%s\"", attrdef->m_imax, attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- for (int i=0; i<attrdef->m_imax; i++)
- {
- item = PySequence_GetItem(value, i); /* new ref */
- if (!py_check_attr_float(var, item, attrdef))
- {
- goto RESTORE_AND_ERROR;
- }
- Py_DECREF(item);
- item = NULL;
- ++var;
- }
- }
- else
- {
- if (!py_check_attr_float(var, value, attrdef))
- goto FREE_AND_ERROR;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_VECTOR:
- {
- if (!PySequence_Check(value) || PySequence_Size(value) != 3)
- {
- PyErr_Format(PyExc_TypeError, "expected a sequence of 3 floats for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- MT_Vector3 *var = reinterpret_cast<MT_Vector3*>(ptr);
- for (int i=0; i<3; i++)
- {
- item = PySequence_GetItem(value, i); /* new ref */
- float val = PyFloat_AsDouble(item);
- Py_DECREF(item);
- item = NULL;
- if (val == -1.0f && PyErr_Occurred())
- {
- PyErr_Format(PyExc_TypeError, "expected a sequence of 3 floats for attribute \"%s\"", attrdef->m_name);
- goto RESTORE_AND_ERROR;
- }
- else if (attrdef->m_clamp)
- {
- if (val < attrdef->m_fmin)
- val = attrdef->m_fmin;
- else if (val > attrdef->m_fmax)
- val = attrdef->m_fmax;
- }
- else if (val < attrdef->m_fmin || val > attrdef->m_fmax)
- {
- PyErr_Format(PyExc_ValueError, "value out of range for attribute \"%s\"", attrdef->m_name);
- goto RESTORE_AND_ERROR;
- }
- (*var)[i] = (MT_Scalar)val;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_CHAR:
- {
- if (PyUnicode_Check(value))
- {
- Py_ssize_t val_size;
- const char *val = _PyUnicode_AsStringAndSize(value, &val_size);
- strncpy(ptr, val, attrdef->m_size);
- ptr[attrdef->m_size-1] = 0;
- }
- else
- {
- PyErr_Format(PyExc_TypeError, "expected a string for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- break;
- }
- case KX_PYATTRIBUTE_TYPE_STRING:
- {
- STR_String *var = reinterpret_cast<STR_String*>(ptr);
- if (PyUnicode_Check(value))
- {
- Py_ssize_t val_len;
- const char *val = _PyUnicode_AsStringAndSize(value, &val_len); /* XXX, should be 'const' but we do a silly trick to have a shorter string */
- if (attrdef->m_clamp)
- {
- if (val_len < attrdef->m_imin)
- {
- // can't increase the length of the string
- PyErr_Format(PyExc_ValueError, "string length too short for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- else if (val_len > attrdef->m_imax)
- {
- // trim the string
- var->SetLength(attrdef->m_imax);
- memcpy(var->Ptr(), val, attrdef->m_imax - 1);
- break;
- }
- } else if (val_len < attrdef->m_imin || val_len > attrdef->m_imax)
- {
- PyErr_Format(PyExc_ValueError, "string length out of range for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- *var = val;
- }
- else
- {
- PyErr_Format(PyExc_TypeError, "expected a string for attribute \"%s\"", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- break;
- }
- default:
- // should not happen
- PyErr_Format(PyExc_AttributeError, "unknown type for attribute \"%s\", report to blender.org", attrdef->m_name);
- goto FREE_AND_ERROR;
- }
- }
- // check if post processing is needed
- if (attrdef->m_checkFunction != NULL)
- {
- if ((*attrdef->m_checkFunction)(ref, attrdef) != 0)
- {
- // restore value
- RESTORE_AND_ERROR:
- if (undoBuffer)
- {
- if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_STRING)
- {
- // special case for STR_String: restore the string
- STR_String *var = reinterpret_cast<STR_String*>(ptr);
- *var = reinterpret_cast<char*>(undoBuffer);
- }
- else
- {
- // other field type have direct values
- memcpy(ptr, undoBuffer, bufferSize);
- }
- }
- FREE_AND_ERROR:
- if (undoBuffer)
- free(undoBuffer);
- if (list)
- Py_DECREF(list);
- if (item)
- Py_DECREF(item);
- return 1;
- }
- }
- if (undoBuffer)
- free(undoBuffer);
- return 0;
-}
-
-
-
-/*------------------------------
- * PyObjectPlus repr -- representations
-------------------------------*/
-PyObject *PyObjectPlus::py_repr(void)
-{
- PyErr_SetString(PyExc_SystemError, "Representation not overridden by object.");
- return NULL;
-}
-
-PyObject *PyObjectPlus::GetProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, void *ptr)
-{
- if (self->m_proxy==NULL)
- {
- self->m_proxy = reinterpret_cast<PyObject *>PyObject_NEW( PyObjectPlus_Proxy, tp);
- BGE_PROXY_PYOWNS(self->m_proxy) = false;
- BGE_PROXY_PYREF(self->m_proxy) = true;
-#ifdef USE_WEAKREFS
- BGE_PROXY_WKREF(self->m_proxy) = NULL;
-#endif
- }
- //PyObject_Print(self->m_proxy, stdout, 0);
- //printf("ref %d\n", self->m_proxy->ob_refcnt);
-
- BGE_PROXY_REF(self->m_proxy) = self; /* Its possible this was set to NULL, so set it back here */
- BGE_PROXY_PTR(self->m_proxy) = ptr;
- Py_INCREF(self->m_proxy); /* we own one, thos ones fore the return */
- return self->m_proxy;
-}
-
-PyObject *PyObjectPlus::NewProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, void *ptr, bool py_owns)
-{
- if (!self)
- {
- // in case of proxy without reference to game object
- PyObject *proxy = reinterpret_cast<PyObject *>PyObject_NEW( PyObjectPlus_Proxy, tp);
- BGE_PROXY_PYREF(proxy) = false;
- BGE_PROXY_PYOWNS(proxy) = py_owns;
- BGE_PROXY_REF(proxy) = NULL;
- BGE_PROXY_PTR(proxy) = ptr;
-#ifdef USE_WEAKREFS
- BGE_PROXY_WKREF(proxy) = NULL;
-#endif
- return proxy;
- }
- if (self->m_proxy)
- {
- if (py_owns)
- { /* Free */
- BGE_PROXY_REF(self->m_proxy) = NULL;
- Py_DECREF(self->m_proxy);
- self->m_proxy= NULL;
- }
- else {
- Py_INCREF(self->m_proxy);
- return self->m_proxy;
- }
-
- }
-
- GetProxyPlus_Ext(self, tp, ptr);
- if (py_owns) {
- BGE_PROXY_PYOWNS(self->m_proxy) = py_owns;
- Py_DECREF(self->m_proxy); /* could avoid thrashing here but for now its ok */
- }
- return self->m_proxy;
-}
-
-PyObject *PyUnicode_From_STR_String(const STR_String& str)
-{
- return PyUnicode_FromStringAndSize(str.ReadPtr(), str.Length());
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-/* deprecation warning management */
-
-bool PyObjectPlus::m_ignore_deprecation_warnings(false);
-void PyObjectPlus::SetDeprecationWarnings(bool ignoreDeprecationWarnings)
-{
- m_ignore_deprecation_warnings = ignoreDeprecationWarnings;
-}
-
-void PyObjectPlus::ShowDeprecationWarning_func(const char *old_way, const char *new_way)
-{
- printf("Method %s is deprecated, please use %s instead.\n", old_way, new_way);
- PyC_LineSpit();
-}
-
-void PyObjectPlus::ClearDeprecationWarning()
-{
- WarnLink *wlink_next;
- WarnLink *wlink = GetDeprecationWarningLinkFirst();
-
- while (wlink) {
- wlink->warn_done= false; /* no need to NULL the link, its cleared before adding to the list next time round */
- wlink_next= reinterpret_cast<WarnLink *>(wlink->link);
- wlink->link= NULL;
- wlink= wlink_next;
- }
- NullDeprecationWarning();
-}
-
-static WarnLink *m_base_wlink_first = NULL;
-static WarnLink *m_base_wlink_last = NULL;
-
-WarnLink* PyObjectPlus::GetDeprecationWarningLinkFirst(void) {return m_base_wlink_first;}
-WarnLink* PyObjectPlus::GetDeprecationWarningLinkLast(void) {return m_base_wlink_last;}
-void PyObjectPlus::SetDeprecationWarningFirst(WarnLink* wlink) {m_base_wlink_first= wlink;}
-void PyObjectPlus::SetDeprecationWarningLinkLast(WarnLink* wlink) {m_base_wlink_last= wlink;}
-void PyObjectPlus::NullDeprecationWarning() {m_base_wlink_first= m_base_wlink_last= NULL;}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Expressions/intern/PythonCallBack.cpp b/source/gameengine/Expressions/intern/PythonCallBack.cpp
deleted file mode 100644
index 3fb84569eca..00000000000
--- a/source/gameengine/Expressions/intern/PythonCallBack.cpp
+++ /dev/null
@@ -1,119 +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.
- *
- * Contributor(s): Porteries Tristan.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Expressions/intern/PythonCallBack.cpp
- * \ingroup expressions
- */
-
-#include "EXP_PythonCallBack.h"
-#include <iostream>
-#include <stdarg.h>
-
-#include "BLI_alloca.h"
-
-/** Check if a python value is a function and have the correct number of arguments.
- * \param value The python value to check.
- * \param minargcount The minimum of arguments possible.
- * \param maxargcount The maximum of arguments possible.
- * \param r_argcount The number of argument of this function, this variable will be
- * changed in the function.
- */
-static PyObject *CheckPythonFunction(PyObject *value, unsigned int minargcount, unsigned int maxargcount, unsigned int &r_argcount)
-{
- if (PyMethod_Check(value)) {
- PyCodeObject *code = ((PyCodeObject *)PyFunction_GET_CODE(PyMethod_GET_FUNCTION(value)));
- // *args support
- r_argcount = (code->co_flags & CO_VARARGS) ? maxargcount : (code->co_argcount - 1);
- }
- else if (PyFunction_Check(value)) {
- PyCodeObject *code = ((PyCodeObject *)PyFunction_GET_CODE(value));
- // *args support
- r_argcount = (code->co_flags & CO_VARARGS) ? maxargcount : code->co_argcount;
- }
- else { // is not a methode or a function
- PyErr_Format(PyExc_TypeError, "items must be functions or methodes, not %s",
- Py_TYPE(value)->tp_name);
- return NULL;
- }
-
- if (r_argcount < minargcount || r_argcount > maxargcount) {
- // wrong number of arguments
- PyErr_Format(PyExc_TypeError, "methode or function (%s) has invalid number of arguments (%i) must be between %i and %i",
- Py_TYPE(value)->tp_name, r_argcount, minargcount, maxargcount);
- return NULL;
- }
-
- return value;
-}
-
-/** Create a python tuple to call a python function
- * \param argcount The lenght of the tuple.
- * \param arglist The fully list of python arguments [size >= argcount].
- */
-static PyObject *CreatePythonTuple(unsigned int argcount, PyObject **arglist)
-{
- PyObject *tuple = PyTuple_New(argcount);
-
- for (unsigned int i = 0; i < argcount; ++i) {
- PyObject *item = arglist[i];
- // increment reference and copy it in a new tuple
- Py_INCREF(item);
- PyTuple_SET_ITEM(tuple, i, item);
- }
-
- return tuple;
-}
-
-void RunPythonCallBackList(PyObject *functionlist, PyObject **arglist, unsigned int minargcount, unsigned int maxargcount)
-{
- unsigned int size = PyList_Size(functionlist);
- PyObject **argTuples = (PyObject **)BLI_array_alloca(argTuples, maxargcount - minargcount + 1);
- memset(argTuples, 0, sizeof(PyObject *) * (maxargcount - minargcount + 1));
-
- for (unsigned int i = 0; i < size; ++i) {
- unsigned int funcargcount = 0;
-
- PyObject *item = PyList_GET_ITEM(functionlist, i);
- PyObject *func = CheckPythonFunction(item, minargcount, maxargcount, funcargcount);
- if (!func) { // this item fails the check
- PyErr_Print();
- PyErr_Clear();
- continue;
- }
-
- // get correct argument tuple.
- PyObject *tuple = argTuples[funcargcount - minargcount];
- if (!tuple)
- argTuples[funcargcount - minargcount] = tuple = CreatePythonTuple(funcargcount, arglist);
-
- PyObject *ret = PyObject_Call(func, tuple, NULL);
- if (!ret) { // if ret is NULL this seems that the function doesn't work !
- PyErr_Print();
- PyErr_Clear();
- }
- else
- Py_DECREF(ret);
- }
-
- for (unsigned int i = 0; i <= (maxargcount - minargcount); ++i)
- Py_XDECREF(argTuples[i]);
-}
diff --git a/source/gameengine/Expressions/intern/StringValue.cpp b/source/gameengine/Expressions/intern/StringValue.cpp
deleted file mode 100644
index ddf61dc441c..00000000000
--- a/source/gameengine/Expressions/intern/StringValue.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/** \file gameengine/Expressions/StringValue.cpp
- * \ingroup expressions
- */
-// StringValue.cpp: implementation of the CStringValue class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#include "EXP_StringValue.h"
-#include "EXP_BoolValue.h"
-#include "EXP_ErrorValue.h"
-#include "EXP_VoidValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-/**
- * pre: false
- * effect: constructs a new CStringValue
- */
-CStringValue::CStringValue()
-{
- m_strString = "[Illegal String constructor call]";
-}
-
-/**
- * pre:
- * effect: constructs a new CStringValue containing text txt
- */
-CStringValue::CStringValue(const char *txt,const char *name,AllocationTYPE alloctype)
-{
- m_strString = txt;
- SetName(name);
-
- if (alloctype==CValue::STACKVALUE)
- {
- CValue::DisableRefCount();
-
- }
-
-
-}
-
-
-/**
- * pre:
- * ret: a new object containing the result of applying operator op to this
- * object and val
- */
-CValue* CStringValue::Calc(VALUE_OPERATOR op, CValue *val)
-{
- //return val->CalrcString(op, this);
- return val->CalcFinal(VALUE_STRING_TYPE, op, this);
-}
-
-/**
- * pre: the type of val is dtype
- * ret: a new object containing the result of applying operator op to val and
- * this object
- */
-CValue* CStringValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
-{
- CValue *ret;
-
- if (op == VALUE_ADD_OPERATOR) {
- if (dtype == VALUE_ERROR_TYPE)
- ret = new CErrorValue(val->GetText() + op2str(op) + GetText());
- else
- ret = new CStringValue(val->GetText() + GetText(),"");
- }
- else {
- if (dtype == VALUE_STRING_TYPE || dtype == VALUE_EMPTY_TYPE) {
- switch (op) {
- case VALUE_EQL_OPERATOR:
- ret = new CBoolValue(val->GetText() == GetText());
- break;
- case VALUE_NEQ_OPERATOR:
- ret = new CBoolValue(val->GetText() != GetText());
- break;
- case VALUE_GRE_OPERATOR:
- ret = new CBoolValue(val->GetText() > GetText());
- break;
- case VALUE_LES_OPERATOR:
- ret = new CBoolValue(val->GetText() < GetText());
- break;
- case VALUE_GEQ_OPERATOR:
- ret = new CBoolValue(val->GetText() >= GetText());
- break;
- case VALUE_LEQ_OPERATOR:
- ret = new CBoolValue(val->GetText() <= GetText());
- break;
- default:
- ret = new CErrorValue(val->GetText() + op2str(op) + "[operator not allowed on strings]");
- break;
- }
- }
- else {
- ret = new CErrorValue(val->GetText() + op2str(op) + "[operator not allowed on strings]");
- }
- }
- return ret;
-}
-
-
-
-double CStringValue::GetNumber()
-{
- return -1;
-}
-
-
-
-int CStringValue::GetValueType()
-{
- return VALUE_STRING_TYPE;
-}
-
-
-
-const STR_String & CStringValue::GetText()
-{
- return m_strString;
-}
-
-bool CStringValue::IsEqual(const STR_String & other)
-{
- return (m_strString == other);
-}
-
-CValue* CStringValue::GetReplica()
-{
- CStringValue* replica = new CStringValue(*this);
- replica->ProcessReplica();
- return replica;
-};
-
-
diff --git a/source/gameengine/Expressions/intern/Value.cpp b/source/gameengine/Expressions/intern/Value.cpp
deleted file mode 100644
index f8796a76e76..00000000000
--- a/source/gameengine/Expressions/intern/Value.cpp
+++ /dev/null
@@ -1,672 +0,0 @@
-/** \file gameengine/Expressions/Value.cpp
- * \ingroup expressions
- */
-// Value.cpp: implementation of the CValue class.
-// developed at Eindhoven University of Technology, 1997
-// by the OOPS team
-//////////////////////////////////////////////////////////////////////
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-#include "EXP_Value.h"
-#include "EXP_BoolValue.h"
-#include "EXP_FloatValue.h"
-#include "EXP_IntValue.h"
-#include "EXP_VectorValue.h"
-#include "EXP_VoidValue.h"
-#include "EXP_StringValue.h"
-#include "EXP_ErrorValue.h"
-#include "EXP_ListValue.h"
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-double CValue::m_sZeroVec[3] = {0.0,0.0,0.0};
-
-#ifdef WITH_PYTHON
-
-PyTypeObject CValue::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "CValue",
- sizeof(PyObjectPlus_Proxy),
- 0,
- py_base_dealloc,
- 0,
- 0,
- 0,
- 0,
- py_base_repr,
- 0,
- 0,0,0,0,0,
- NULL,
- NULL,
- 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
-};
-
-PyMethodDef CValue::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-#endif // WITH_PYTHON
-
-
-/*#define CVALUE_DEBUG*/
-#ifdef CVALUE_DEBUG
-int gRefCount;
-struct SmartCValueRef
-{
- CValue *m_ref;
- int m_count;
- SmartCValueRef(CValue *ref)
- {
- m_ref = ref;
- m_count = gRefCount++;
- }
-};
-
-#include <vector>
-
-std::vector<SmartCValueRef> gRefList;
-#endif
-
-#ifdef DEBUG
-//int gRefCountValue;
-#endif
-
-CValue::CValue()
- : PyObjectPlus(),
-
-m_pNamedPropertyArray(NULL),
-m_refcount(1)
-/*
-pre: false
-effect: constucts a CValue
-*/
-{
- //debug(gRefCountValue++) // debugging
-#ifdef DEBUG
- //gRefCountValue++;
-#ifdef CVALUE_DEBUG
- gRefList.push_back(SmartCValueRef(this));
-#endif
-#endif
-}
-
-
-
-CValue::~CValue()
-/*
-pre:
-effect: deletes the object
-*/
-{
- ClearProperties();
-
- assertd (m_refcount==0);
-#ifdef CVALUE_DEBUG
- std::vector<SmartCValueRef>::iterator it;
- for (it=gRefList.begin(); it!=gRefList.end(); it++)
- {
- if (it->m_ref == this)
- {
- *it = gRefList.back();
- gRefList.pop_back();
- break;
- }
- }
-#endif
-}
-
-
-/* UNUSED */
-#if 0
-#define VALUE_SUB(val1, val2) (val1)->Calc(VALUE_SUB_OPERATOR, val2)
-#define VALUE_MUL(val1, val2) (val1)->Calc(VALUE_MUL_OPERATOR, val2)
-#define VALUE_DIV(val1, val2) (val1)->Calc(VALUE_DIV_OPERATOR, val2)
-#define VALUE_NEG(val1) (val1)->Calc(VALUE_NEG_OPERATOR, val1)
-#define VALUE_POS(val1) (val1)->Calc(VALUE_POS_OPERATOR, val1)
-#endif
-
-STR_String CValue::op2str(VALUE_OPERATOR op)
-{
- //pre:
- //ret: the stringrepresentation of operator op
-
- STR_String opmsg;
- switch (op) {
- case VALUE_MOD_OPERATOR:
- opmsg = " % ";
- break;
- case VALUE_ADD_OPERATOR:
- opmsg = " + ";
- break;
- case VALUE_SUB_OPERATOR:
- opmsg = " - ";
- break;
- case VALUE_MUL_OPERATOR:
- opmsg = " * ";
- break;
- case VALUE_DIV_OPERATOR:
- opmsg = " / ";
- break;
- case VALUE_NEG_OPERATOR:
- opmsg = " -";
- break;
- case VALUE_POS_OPERATOR:
- opmsg = " +";
- break;
- case VALUE_AND_OPERATOR:
- opmsg = " & ";
- break;
- case VALUE_OR_OPERATOR:
- opmsg = " | ";
- break;
- case VALUE_EQL_OPERATOR:
- opmsg = " = ";
- break;
- case VALUE_NEQ_OPERATOR:
- opmsg = " != ";
- break;
- case VALUE_NOT_OPERATOR:
- opmsg = " !";
- break;
- default:
- opmsg="Error in Errorhandling routine.";
- // AfxMessageBox("Invalid operator");
- break;
- }
- return opmsg;
-}
-
-
-
-
-
-//---------------------------------------------------------------------------------------------------------------------
-// Property Management
-//---------------------------------------------------------------------------------------------------------------------
-
-
-
-//
-// Set property <ioProperty>, overwrites and releases a previous property with the same name if needed
-//
-void CValue::SetProperty(const STR_String & name,CValue* ioProperty)
-{
- if (ioProperty==NULL)
- { // Check if somebody is setting an empty property
- trace("Warning:trying to set empty property!");
- return;
- }
-
- if (m_pNamedPropertyArray)
- { // Try to replace property (if so -> exit as soon as we replaced it)
- CValue* oldval = (*m_pNamedPropertyArray)[name];
- if (oldval)
- oldval->Release();
- }
- else { // Make sure we have a property array
- m_pNamedPropertyArray = new std::map<STR_String,CValue *>;
- }
-
- // Add property at end of array
- (*m_pNamedPropertyArray)[name] = ioProperty->AddRef();//->Add(ioProperty);
-}
-
-void CValue::SetProperty(const char* name,CValue* ioProperty)
-{
- if (ioProperty==NULL)
- { // Check if somebody is setting an empty property
- trace("Warning:trying to set empty property!");
- return;
- }
-
- if (m_pNamedPropertyArray)
- { // Try to replace property (if so -> exit as soon as we replaced it)
- CValue* oldval = (*m_pNamedPropertyArray)[name];
- if (oldval)
- oldval->Release();
- }
- else { // Make sure we have a property array
- m_pNamedPropertyArray = new std::map<STR_String,CValue *>;
- }
-
- // Add property at end of array
- (*m_pNamedPropertyArray)[name] = ioProperty->AddRef();//->Add(ioProperty);
-}
-
-//
-// Get pointer to a property with name <inName>, returns NULL if there is no property named <inName>
-//
-CValue* CValue::GetProperty(const STR_String & inName)
-{
- if (m_pNamedPropertyArray) {
- std::map<STR_String,CValue*>::iterator it = m_pNamedPropertyArray->find(inName);
- if (it != m_pNamedPropertyArray->end())
- return (*it).second;
- }
- return NULL;
-}
-
-CValue* CValue::GetProperty(const char *inName)
-{
- if (m_pNamedPropertyArray) {
- std::map<STR_String,CValue*>::iterator it = m_pNamedPropertyArray->find(inName);
- if (it != m_pNamedPropertyArray->end())
- return (*it).second;
- }
- return NULL;
-}
-
-//
-// Get text description of property with name <inName>, returns an empty string if there is no property named <inName>
-//
-const STR_String& CValue::GetPropertyText(const STR_String & inName)
-{
- const static STR_String sEmpty("");
-
- CValue *property = GetProperty(inName);
- if (property)
- return property->GetText();
- else
- return sEmpty;
-}
-
-float CValue::GetPropertyNumber(const STR_String& inName,float defnumber)
-{
- CValue *property = GetProperty(inName);
- if (property)
- return property->GetNumber();
- else
- return defnumber;
-}
-
-
-
-//
-// Remove the property named <inName>, returns true if the property was succesfully removed, false if property was not found or could not be removed
-//
-bool CValue::RemoveProperty(const char *inName)
-{
- // Check if there are properties at all which can be removed
- if (m_pNamedPropertyArray)
- {
- std::map<STR_String,CValue*>::iterator it = m_pNamedPropertyArray->find(inName);
- if (it != m_pNamedPropertyArray->end())
- {
- ((*it).second)->Release();
- m_pNamedPropertyArray->erase(it);
- return true;
- }
- }
-
- return false;
-}
-
-//
-// Get Property Names
-//
-vector<STR_String> CValue::GetPropertyNames()
-{
- vector<STR_String> result;
- if (!m_pNamedPropertyArray) return result;
- result.reserve(m_pNamedPropertyArray->size());
-
- std::map<STR_String,CValue*>::iterator it;
- for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++)
- {
- result.push_back((*it).first);
- }
- return result;
-}
-
-//
-// Clear all properties
-//
-void CValue::ClearProperties()
-{
- // Check if we have any properties
- if (m_pNamedPropertyArray == NULL)
- return;
-
- // Remove all properties
- std::map<STR_String,CValue*>::iterator it;
- for (it= m_pNamedPropertyArray->begin();(it != m_pNamedPropertyArray->end()); it++)
- {
- CValue* tmpval = (*it).second;
- //STR_String name = (*it).first;
- tmpval->Release();
- }
-
- // Delete property array
- delete m_pNamedPropertyArray;
- m_pNamedPropertyArray=NULL;
-}
-
-
-
-//
-// Set all properties' modified flag to <inModified>
-//
-void CValue::SetPropertiesModified(bool inModified)
-{
- if (!m_pNamedPropertyArray) return;
- std::map<STR_String,CValue*>::iterator it;
-
- for (it= m_pNamedPropertyArray->begin();(it != m_pNamedPropertyArray->end()); it++)
- ((*it).second)->SetModified(inModified);
-}
-
-
-
-//
-// Check if any of the properties in this value have been modified
-//
-bool CValue::IsAnyPropertyModified()
-{
- if (!m_pNamedPropertyArray) return false;
- std::map<STR_String,CValue*>::iterator it;
-
- for (it= m_pNamedPropertyArray->begin();(it != m_pNamedPropertyArray->end()); it++)
- if (((*it).second)->IsModified())
- return true;
-
- return false;
-}
-
-
-
-//
-// Get property number <inIndex>
-//
-CValue* CValue::GetProperty(int inIndex)
-{
-
- int count=0;
- CValue* result = NULL;
-
- if (m_pNamedPropertyArray)
- {
- std::map<STR_String,CValue*>::iterator it;
- for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++)
- {
- if (count++ == inIndex)
- {
- result = (*it).second;
- break;
- }
- }
-
- }
- return result;
-}
-
-
-
-//
-// Get the amount of properties assiocated with this value
-//
-int CValue::GetPropertyCount()
-{
- if (m_pNamedPropertyArray)
- return m_pNamedPropertyArray->size();
- else
- return 0;
-}
-
-
-double* CValue::GetVector3(bool bGetTransformedVec)
-{
- assertd(false); // don't get vector from me
- return m_sZeroVec;//::sZero;
-}
-
-
-/*---------------------------------------------------------------------------------------------------------------------
- Reference Counting
----------------------------------------------------------------------------------------------------------------------*/
-
-
-
-//
-// Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
-//
-
-
-
-//
-// Disable reference counting for this value
-//
-void CValue::DisableRefCount()
-{
- assertd(m_refcount == 1);
- m_refcount--;
-
- //debug(gRefCountValue--);
-#ifdef DEBUG
- //gRefCountValue--;
-#endif
- m_ValFlags.RefCountDisabled=true;
-}
-
-
-
-void CValue::ProcessReplica() /* was AddDataToReplica in 2.48 */
-{
- m_refcount = 1;
-
-#ifdef DEBUG
- //gRefCountValue++;
-#endif
- PyObjectPlus::ProcessReplica();
-
- m_ValFlags.RefCountDisabled = false;
-
- /* copy all props */
- if (m_pNamedPropertyArray)
- {
- std::map<STR_String,CValue*> *pOldArray = m_pNamedPropertyArray;
- m_pNamedPropertyArray=NULL;
- std::map<STR_String,CValue*>::iterator it;
- for (it= pOldArray->begin(); (it != pOldArray->end()); it++)
- {
- CValue *val = (*it).second->GetReplica();
- SetProperty((*it).first,val);
- val->Release();
- }
- }
-}
-
-
-
-int CValue::GetValueType()
-{
- return VALUE_NO_TYPE;
-}
-
-
-
-CValue* CValue::FindIdentifier(const STR_String& identifiername)
-{
-
- CValue* result = NULL;
-
- int pos = 0;
- // if a dot exists, explode the name into pieces to get the subcontext
- if ((pos=identifiername.Find('.'))>=0)
- {
- const STR_String rightstring = identifiername.Right(identifiername.Length() -1 - pos);
- const STR_String leftstring = identifiername.Left(pos);
- CValue* tempresult = GetProperty(leftstring);
- if (tempresult)
- {
- result=tempresult->FindIdentifier(rightstring);
- }
- } else
- {
- result = GetProperty(identifiername);
- if (result)
- return result->AddRef();
- }
- if (!result)
- {
- // warning here !!!
- result = new CErrorValue(identifiername+" not found");
- }
- return result;
-}
-
-#ifdef WITH_PYTHON
-
-PyAttributeDef CValue::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("name", CValue, pyattr_get_name),
- { NULL } //Sentinel
-};
-
-PyObject *CValue::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- CValue * self = static_cast<CValue *> (self_v);
- return PyUnicode_From_STR_String(self->GetName());
-}
-
-/**
- * There are 2 reasons this could return NULL
- * - unsupported type.
- * - error converting (overflow).
- *
- * \param do_type_exception Use to skip raising an exception for unknown types.
- */
-CValue *CValue::ConvertPythonToValue(PyObject *pyobj, const bool do_type_exception, const char *error_prefix)
-{
-
- CValue *vallie;
- /* refcounting is broking here! - this crashes anyway, just store a python list for KX_GameObject */
-#if 0
- if (PyList_Check(pyobj))
- {
- CListValue* listval = new CListValue();
- bool error = false;
-
- Py_ssize_t i;
- Py_ssize_t numitems = PyList_GET_SIZE(pyobj);
- for (i=0;i<numitems;i++)
- {
- PyObject *listitem = PyList_GET_ITEM(pyobj,i); /* borrowed ref */
- CValue* listitemval = ConvertPythonToValue(listitem, error_prefix);
- if (listitemval)
- {
- listval->Add(listitemval);
- } else
- {
- error = true;
- }
- }
- if (!error)
- {
- // jippie! could be converted
- vallie = listval;
- } else
- {
- // list could not be converted... bad luck
- listval->Release();
- }
-
- } else
-#endif
- /* note: Boolean check should go before Int check [#34677] */
- if (PyBool_Check(pyobj))
- {
- vallie = new CBoolValue( (bool)PyLong_AsLongLong(pyobj) );
- } else
- if (PyFloat_Check(pyobj))
- {
- const double tval = PyFloat_AsDouble(pyobj);
- if (tval > (double)FLT_MAX || tval < (double)-FLT_MAX) {
- PyErr_Format(PyExc_OverflowError, "%soverflow converting from float, out of internal range", error_prefix);
- vallie = NULL;
- }
- else {
- vallie = new CFloatValue((float)tval);
- }
- } else
- if (PyLong_Check(pyobj))
- {
- vallie = new CIntValue( (cInt)PyLong_AsLongLong(pyobj) );
- } else
- if (PyUnicode_Check(pyobj))
- {
- vallie = new CStringValue(_PyUnicode_AsString(pyobj),"");
- } else
- if (PyObject_TypeCheck(pyobj, &CValue::Type)) /* Note, don't let these get assigned to GameObject props, must check elsewhere */
- {
- vallie = (static_cast<CValue *>(BGE_PROXY_REF(pyobj)))->AddRef();
- }
- else {
- if (do_type_exception) {
- /* return an error value from the caller */
- PyErr_Format(PyExc_TypeError, "%scould convert python value to a game engine property", error_prefix);
- }
- vallie = NULL;
- }
- return vallie;
-
-}
-
-PyObject *CValue::ConvertKeysToPython(void)
-{
- if (m_pNamedPropertyArray)
- {
- PyObject *pylist= PyList_New(m_pNamedPropertyArray->size());
- Py_ssize_t i= 0;
-
- std::map<STR_String,CValue*>::iterator it;
- for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++)
- {
- PyList_SET_ITEM(pylist, i++, PyUnicode_From_STR_String((*it).first));
- }
-
- return pylist;
- }
- else {
- return PyList_New(0);
- }
-}
-
-#endif // WITH_PYTHON
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-/* These implementations were moved out of the header */
-
-void CValue::SetOwnerExpression(class CExpression* expr)
-{
- /* intentionally empty */
-}
-
-void CValue::SetColorOperator(VALUE_OPERATOR op)
-{
- /* intentionally empty */
-}
-void CValue::SetValue(CValue* newval)
-{
- // no one should get here
- assertd(newval->GetNumber() == 10121969);
-}
diff --git a/source/gameengine/Expressions/intern/VectorValue.cpp b/source/gameengine/Expressions/intern/VectorValue.cpp
deleted file mode 100644
index a3d44116317..00000000000
--- a/source/gameengine/Expressions/intern/VectorValue.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/** \file gameengine/Expressions/VectorValue.cpp
- * \ingroup expressions
- */
-// VectorValue.cpp: implementation of the CVectorValue class.
-/*
- * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation. Erwin Coumans makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "EXP_Value.h"
-#include "EXP_VectorValue.h"
-#include "EXP_ErrorValue.h"
-//#include "MatrixValue.h"
-#include "EXP_VoidValue.h"
-#include "EXP_StringValue.h"
-//#include "FactoryManager.h"
-
-
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-CVectorValue::CVectorValue(float x,float y,float z, AllocationTYPE alloctype)
-{
- SetCustomFlag1(false);//FancyOutput=false;
-
- if (alloctype == STACKVALUE)
- {
- CValue::DisableRefCount();
- };
-
- m_vec[KX_X] = m_transformedvec[KX_X] = x;
- m_vec[KX_Y] = m_transformedvec[KX_Y] = y;
- m_vec[KX_Z] = m_transformedvec[KX_Z] = z;
-
-}
-CVectorValue::CVectorValue(double vec[3], const char *name,AllocationTYPE alloctype)
-{
-
- SetCustomFlag1(false);//FancyOutput=false;
-
- m_vec[KX_X] = m_transformedvec[KX_X] = vec[KX_X];
- m_vec[KX_Y] = m_transformedvec[KX_Y] = vec[KX_Y];
- m_vec[KX_Z] = m_transformedvec[KX_Z] = vec[KX_Z];
-
- if (alloctype == STACKVALUE)
- {
- CValue::DisableRefCount();
-
- }
-
- SetName(name);
-}
-
-CVectorValue::CVectorValue(double vec[3], AllocationTYPE alloctype)
-{
-
- SetCustomFlag1(false);//FancyOutput=false;
-
- m_vec[KX_X] = m_transformedvec[KX_X] = vec[KX_X];
- m_vec[KX_Y] = m_transformedvec[KX_Y] = vec[KX_Y];
- m_vec[KX_Z] = m_transformedvec[KX_Z] = vec[KX_Z];
-
- if (alloctype == STACKVALUE)
- {
- CValue::DisableRefCount();
-
- }
-
-
-}
-CVectorValue::~CVectorValue()
-{
-
-}
-
-/**
- * pre: the type of val is dtype
- * ret: a new object containing the result of applying operator op to val and
- * this object
- */
-CValue* CVectorValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
-{
- CValue *ret = NULL;
-
- switch (op) {
- case VALUE_ADD_OPERATOR:
- {
- switch (dtype)
- {
- case VALUE_EMPTY_TYPE:
- case VALUE_VECTOR_TYPE:
- {
- ret = new CVectorValue(
- val->GetVector3()[KX_X] + GetVector3()[KX_X],
- val->GetVector3()[KX_Y] + GetVector3()[KX_Y],
- val->GetVector3()[KX_Z] + GetVector3()[KX_Z],
- CValue::HEAPVALUE);
- ret->SetName(GetName());
- break;
- }
-
- default:
- ret = new CErrorValue(val->GetText() + op2str(op) + GetText());
- }
- break;
- }
- case VALUE_MUL_OPERATOR:
- {
- switch (dtype)
- {
-
- case VALUE_EMPTY_TYPE:
- case VALUE_VECTOR_TYPE:
- {
- //MT_Vector3 supports 'scaling' by another vector, instead of using general transform, Gino?
- //ret = new CVectorValue(val->GetVector3().Scaled(GetVector3()),GetName());
- break;
- }
- case VALUE_FLOAT_TYPE:
- {
- ret = new CVectorValue(
- val->GetVector3()[KX_X] * GetVector3()[KX_X],
- val->GetVector3()[KX_Y] * GetVector3()[KX_Y],
- val->GetVector3()[KX_Z] * GetVector3()[KX_Z],
- CValue::HEAPVALUE);
- ret->SetName(GetName());
- break;
- }
-
- default:
- ret = new CErrorValue(val->GetText() + op2str(op) + GetText());
- }
- break;
-
- }
-
- default:
- ret = new CErrorValue(val->GetText() + op2str(op) + GetText());
- }
-
-
- return ret;
-}
-
-double CVectorValue::GetNumber()
-{
- return m_vec[KX_X];
-}
-
-
-
-int CVectorValue::GetValueType()
-{
- return VALUE_VECTOR_TYPE;
-}
-
-
-
-double* CVectorValue::GetVector3(bool bGetTransformedVec)
-{
- if (bGetTransformedVec)
- return m_transformedvec;
- // else
- return m_vec;
-}
-
-
-
-
-
-void CVectorValue::SetVector(double newvec[])
-{
- m_vec[KX_X] = m_transformedvec[KX_X] = newvec[KX_X];
- m_vec[KX_Y] = m_transformedvec[KX_Y] = newvec[KX_Y];
- m_vec[KX_Z] = m_transformedvec[KX_Z] = newvec[KX_Z];
-
- SetModified(true);
-}
-
-
-void CVectorValue::SetValue(CValue *newval)
-{
-
- double* newvec = ((CVectorValue*)newval)->GetVector3();
- m_vec[KX_X] = m_transformedvec[KX_X] = newvec[KX_X];
- m_vec[KX_Y] = m_transformedvec[KX_Y] = newvec[KX_Y];
- m_vec[KX_Z] = m_transformedvec[KX_Z] = newvec[KX_Z];
-
- SetModified(true);
-}
-
-static const STR_String gstrVectorStr=STR_String();
-const STR_String & CVectorValue::GetText()
-{
- assertd(false);
- return gstrVectorStr;
-}
-
-CValue* CVectorValue::GetReplica()
-{
- CVectorValue* replica = new CVectorValue(*this);
- replica->ProcessReplica();
- return replica;
-};
-
-#if 0
-void CVectorValue::Transform(rcMatrix4x4 mat)
-{
- m_transformedvec = mat*m_vec;
-}
-#endif
diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt
deleted file mode 100644
index b9eec74f6f4..00000000000
--- a/source/gameengine/GameLogic/CMakeLists.txt
+++ /dev/null
@@ -1,147 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../Expressions
- ../Rasterizer
- ../SceneGraph
- ../../blender/blenlib
- ../../../intern/container
- ../../../intern/string
- ../../../intern/ghost
-)
-
-set(INC_SYS
- ../../../intern/moto/include
-)
-
-set(SRC
- SCA_2DFilterActuator.cpp
- SCA_ANDController.cpp
- SCA_ActuatorEventManager.cpp
- SCA_ActuatorSensor.cpp
- SCA_AlwaysEventManager.cpp
- SCA_AlwaysSensor.cpp
- SCA_BasicEventManager.cpp
- SCA_DelaySensor.cpp
- SCA_EventManager.cpp
- SCA_ExpressionController.cpp
- SCA_IActuator.cpp
- SCA_IController.cpp
- SCA_IInputDevice.cpp
- SCA_ILogicBrick.cpp
- SCA_IObject.cpp
- SCA_IScene.cpp
- SCA_ISensor.cpp
- SCA_JoystickManager.cpp
- SCA_JoystickSensor.cpp
- SCA_KeyboardManager.cpp
- SCA_KeyboardSensor.cpp
- SCA_LogicManager.cpp
- SCA_MouseManager.cpp
- SCA_MouseSensor.cpp
- SCA_NANDController.cpp
- SCA_NORController.cpp
- SCA_ORController.cpp
- SCA_PropertyActuator.cpp
- SCA_PropertyEventManager.cpp
- SCA_PropertySensor.cpp
- SCA_PythonController.cpp
- SCA_PythonJoystick.cpp
- SCA_PythonKeyboard.cpp
- SCA_PythonMouse.cpp
- SCA_RandomActuator.cpp
- SCA_RandomEventManager.cpp
- SCA_RandomNumberGenerator.cpp
- SCA_RandomSensor.cpp
- SCA_TimeEventManager.cpp
- SCA_XNORController.cpp
- SCA_XORController.cpp
- Joystick/SCA_Joystick.cpp
- Joystick/SCA_JoystickEvents.cpp
-
- SCA_2DFilterActuator.h
- SCA_ANDController.h
- SCA_ActuatorEventManager.h
- SCA_ActuatorSensor.h
- SCA_AlwaysEventManager.h
- SCA_AlwaysSensor.h
- SCA_BasicEventManager.h
- SCA_DelaySensor.h
- SCA_EventManager.h
- SCA_ExpressionController.h
- SCA_IActuator.h
- SCA_IController.h
- SCA_IInputDevice.h
- SCA_ILogicBrick.h
- SCA_IObject.h
- SCA_IScene.h
- SCA_ISensor.h
- SCA_JoystickManager.h
- SCA_JoystickSensor.h
- SCA_KeyboardManager.h
- SCA_KeyboardSensor.h
- SCA_LogicManager.h
- SCA_MouseManager.h
- SCA_MouseSensor.h
- SCA_NANDController.h
- SCA_NORController.h
- SCA_ORController.h
- SCA_PropertyActuator.h
- SCA_PropertyEventManager.h
- SCA_PropertySensor.h
- SCA_PythonController.h
- SCA_PythonJoystick.h
- SCA_PythonKeyboard.h
- SCA_PythonMouse.h
- SCA_RandomActuator.h
- SCA_RandomEventManager.h
- SCA_RandomNumberGenerator.h
- SCA_RandomSensor.h
- SCA_TimeEventManager.h
- SCA_XNORController.h
- SCA_XORController.h
- Joystick/SCA_Joystick.h
- Joystick/SCA_JoystickDefines.h
- Joystick/SCA_JoystickPrivate.h
-)
-
-if(WITH_SDL)
- list(APPEND INC_SYS
- ${SDL_INCLUDE_DIR}
- )
-
- add_definitions(-DWITH_SDL)
-
- if(WITH_GHOST_SDL)
- add_definitions(-DWITH_GHOST_SDL)
- endif()
- if(WITH_SDL_DYNLOAD)
- add_definitions(-DWITH_SDL_DYNLOAD)
- endif()
-endif()
-
-blender_add_lib(ge_logic "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
deleted file mode 100644
index 9f532527a80..00000000000
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
+++ /dev/null
@@ -1,382 +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): snailrose.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/GameLogic/Joystick/SCA_Joystick.cpp
- * \ingroup gamelogic
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "SCA_Joystick.h"
-#include "SCA_JoystickPrivate.h"
-
-#include "BLI_path_util.h"
-
-#ifdef WITH_SDL
-# ifdef WITH_SDL_DYNLOAD
-# define SDL_CHECK(x) ((x) != (void *)0)
-# else
-# define SDL_CHECK(x) true
-# endif
-#endif
-
-SCA_Joystick::SCA_Joystick(short int index)
- :
- m_joyindex(index),
- m_prec(3200),
- m_axismax(-1),
- m_buttonmax(-1),
- m_hatmax(-1),
- m_isinit(0),
- m_istrig_axis(0),
- m_istrig_button(0),
- m_istrig_hat(0)
-{
- for (int i=0; i < JOYAXIS_MAX; i++)
- m_axis_array[i] = 0;
-
- for (int i=0; i < JOYHAT_MAX; i++)
- m_hat_array[i] = 0;
-
-#ifdef WITH_SDL
- m_private = new PrivateData();
-#endif
-}
-
-
-SCA_Joystick::~SCA_Joystick()
-
-{
-#ifdef WITH_SDL
- delete m_private;
-#endif
-}
-
-SCA_Joystick *SCA_Joystick::m_instance[JOYINDEX_MAX];
-int SCA_Joystick::m_joynum = 0;
-int SCA_Joystick::m_refCount = 0;
-
-SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex )
-{
-#ifndef WITH_SDL
- return NULL;
-#else /* WITH_SDL */
- if (!SDL_CHECK(SDL_InitSubSystem)) {
- return NULL;
- }
- if (joyindex < 0 || joyindex >= JOYINDEX_MAX) {
- JOYSTICK_ECHO("Error-invalid joystick index: " << joyindex);
- return NULL;
- }
-
- if (m_refCount == 0)
- {
- int i;
-
- /* The video subsystem is required for joystick input to work. However,
- * when GHOST is running under SDL, video is initialized elsewhere. We
- * also need to set the videodriver to dummy, and do it here to avoid
- * interfering with addons that may use SDL too.
- *
- * We also init SDL once only. */
-# ifdef WITH_GHOST_SDL
- int success = (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1 );
-# else
- /* set and restore environment variable */
- char *videodriver = getenv("SDL_VIDEODRIVER");
- BLI_setenv("SDL_VIDEODRIVER", "dummy");
-
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- int success = (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1 );
-#else
- int success = (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO) != -1 );
-#endif
-
- BLI_setenv("SDL_VIDEODRIVER", videodriver);
-# endif
-
- if (!success) {
- JOYSTICK_ECHO("Error-Initializing-SDL: " << SDL_GetError());
- return NULL;
- }
-
- m_joynum = SDL_NumJoysticks();
-
- for (i = 0; i < m_joynum; i++) {
- m_instance[i] = new SCA_Joystick(i);
- m_instance[i]->CreateJoystickDevice();
- }
- m_refCount = 1;
- }
- else
- {
- m_refCount++;
- }
- return m_instance[joyindex];
-#endif /* WITH_SDL */
-}
-
-void SCA_Joystick::ReleaseInstance()
-{
- if (--m_refCount == 0)
- {
-#ifdef WITH_SDL
- if (!SDL_CHECK(SDL_QuitSubSystem)) {
- return;
- }
- for (int i = 0; i < m_joynum; i++) {
- if (m_instance[i]) {
- m_instance[i]->DestroyJoystickDevice();
- delete m_instance[i];
- }
- m_instance[i] = NULL;
- }
-
- /* The video subsystem is required for joystick input to work. However,
- * when GHOST is running under SDL, video is freed elsewhere.
- * Do this once only. */
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
-#else
- SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO);
-#endif
-#endif /* WITH_SDL */
- }
-}
-
-void SCA_Joystick::cSetPrecision(int val)
-{
- m_prec = val;
-}
-
-
-bool SCA_Joystick::aAxisPairIsPositive(int axis)
-{
- return (pAxisTest(axis) > m_prec) ? true:false;
-}
-
-bool SCA_Joystick::aAxisPairDirectionIsPositive(int axis, int dir)
-{
-
- int res;
-
- if (dir==JOYAXIS_UP || dir==JOYAXIS_DOWN)
- res = pGetAxis(axis, 1);
- else /* JOYAXIS_LEFT || JOYAXIS_RIGHT */
- res = pGetAxis(axis, 0);
-
- if (dir==JOYAXIS_DOWN || dir==JOYAXIS_RIGHT)
- return (res > m_prec) ? true : false;
- else /* JOYAXIS_UP || JOYAXIS_LEFT */
- return (res < -m_prec) ? true : false;
-}
-
-bool SCA_Joystick::aAxisIsPositive(int axis_single)
-{
- return abs(m_axis_array[axis_single]) > m_prec ? true:false;
-}
-
-bool SCA_Joystick::aAnyButtonPressIsPositive(void)
-{
-#ifdef WITH_SDL
- if (!SDL_CHECK(SDL_JoystickGetButton)) {
- return false;
- }
- /* this is needed for the "all events" option
- * so we know if there are no buttons pressed */
- for (int i=0; i<m_buttonmax; i++)
- if (SDL_JoystickGetButton(m_private->m_joystick, i))
- return true;
-#endif
- return false;
-}
-
-bool SCA_Joystick::aButtonPressIsPositive(int button)
-{
-#ifndef WITH_SDL
- return false;
-#else
- bool result;
- result = SDL_CHECK(SDL_JoystickGetButton) && SDL_JoystickGetButton(m_private->m_joystick, button);
- return result;
-#endif
-}
-
-
-bool SCA_Joystick::aButtonReleaseIsPositive(int button)
-{
-#ifndef WITH_SDL
- return false;
-#else
- bool result;
- result = !(SDL_CHECK(SDL_JoystickGetButton) && SDL_JoystickGetButton(m_private->m_joystick, button));
- return result;
-#endif
-}
-
-
-bool SCA_Joystick::aHatIsPositive(int hatnum, int dir)
-{
- return (GetHat(hatnum)==dir) ? true : false;
-}
-
-int SCA_Joystick::GetNumberOfAxes()
-{
- return m_axismax;
-}
-
-
-int SCA_Joystick::GetNumberOfButtons()
-{
- return m_buttonmax;
-}
-
-
-int SCA_Joystick::GetNumberOfHats()
-{
- return m_hatmax;
-}
-
-bool SCA_Joystick::CreateJoystickDevice(void)
-{
-#ifndef WITH_SDL
- m_isinit = true;
- m_axismax = m_buttonmax = m_hatmax = 0;
- return false;
-#else /* WITH_SDL */
- if (m_isinit == false && SDL_CHECK(SDL_JoystickOpen)) {
- if (m_joyindex>=m_joynum) {
- /* don't print a message, because this is done anyway */
- //JOYSTICK_ECHO("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)");
-
- /* Need this so python args can return empty lists */
- m_axismax = m_buttonmax = m_hatmax = 0;
- return false;
- }
-
- m_private->m_joystick = SDL_JoystickOpen(m_joyindex);
- SDL_JoystickEventState(SDL_ENABLE);
- m_isinit = true;
-
- JOYSTICK_ECHO("Joystick " << m_joyindex << " initialized");
-
- /* must run after being initialized */
- m_axismax = SDL_JoystickNumAxes(m_private->m_joystick);
- m_buttonmax = SDL_JoystickNumButtons(m_private->m_joystick);
- m_hatmax = SDL_JoystickNumHats(m_private->m_joystick);
-
- if (m_axismax > JOYAXIS_MAX) m_axismax = JOYAXIS_MAX; /* very unlikely */
- else if (m_axismax < 0) m_axismax = 0;
-
- if (m_hatmax > JOYHAT_MAX) m_hatmax = JOYHAT_MAX; /* very unlikely */
- else if (m_hatmax < 0) m_hatmax = 0;
-
- if (m_buttonmax < 0) m_buttonmax = 0;
-
- }
- return true;
-#endif /* WITH_SDL */
-}
-
-
-void SCA_Joystick::DestroyJoystickDevice(void)
-{
-#ifdef WITH_SDL
- if (m_isinit) {
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- if (SDL_CHECK(SDL_JoystickGetAttached) && SDL_JoystickGetAttached(m_private->m_joystick))
-#else
- if (SDL_CHECK(SDL_JoystickOpened) && SDL_JoystickOpened(m_joyindex))
-#endif
- {
- JOYSTICK_ECHO("Closing-joystick " << m_joyindex);
- SDL_JoystickClose(m_private->m_joystick);
- }
- m_isinit = false;
- }
-#endif /* WITH_SDL */
-}
-
-int SCA_Joystick::Connected(void)
-{
-#ifdef WITH_SDL
- if (m_isinit &&
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- SDL_CHECK(SDL_JoystickGetAttached) && SDL_JoystickGetAttached(m_private->m_joystick)
-#else
- SDL_CHECK(SDL_JoystickOpened) && SDL_JoystickOpened(m_joyindex)
-#endif
- )
- {
- return 1;
- }
-#endif
- return 0;
-}
-
-int SCA_Joystick::pGetAxis(int axisnum, int udlr)
-{
-#ifdef WITH_SDL
- return m_axis_array[(axisnum*2)+udlr];
-#endif
- return 0;
-}
-
-int SCA_Joystick::pAxisTest(int axisnum)
-{
-#ifdef WITH_SDL
- /* Use ints instead of shorts here to avoid problems when we get -32768.
- * When we take the negative of that later, we should get 32768, which is greater
- * than what a short can hold. In other words, abs(MIN_SHORT) > MAX_SHRT. */
- int i1 = m_axis_array[(axisnum * 2)];
- int i2 = m_axis_array[(axisnum * 2) + 1];
-
- /* long winded way to do:
- * return max_ff(absf(i1), absf(i2))
- * ...avoid abs from math.h */
- if (i1 < 0) i1 = -i1;
- if (i2 < 0) i2 = -i2;
- if (i1 <i2) return i2;
- else return i1;
-#else /* WITH_SDL */
- return 0;
-#endif /* WITH_SDL */
-}
-
-const char *SCA_Joystick::GetName()
-{
-#ifdef WITH_SDL
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- return (SDL_CHECK(SDL_JoystickName)) ? SDL_JoystickName(m_private->m_joystick) : "";
-#else
- return (SDL_CHECK(SDL_JoystickName)) ? SDL_JoystickName(m_joyindex) : "";
-#endif
-#else /* WITH_SDL */
- return "";
-#endif /* WITH_SDL */
-}
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
deleted file mode 100644
index c9221753d45..00000000000
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
+++ /dev/null
@@ -1,214 +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): snailrose.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file SCA_Joystick.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_JOYSTICK_H__
-#define __SCA_JOYSTICK_H__
-
-#include "SCA_JoystickDefines.h"
-#ifdef WITH_SDL
-/* SDL force defines __SSE__ and __SSE2__ flags, which generates warnings
- * because we pass those defines via command line as well. For until there's
- * proper ifndef added to SDL headers we ignore the redefinition warning.
- */
-# ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable : 4005)
-# endif
-# include "SDL.h"
-# ifdef _MSC_VER
-# pragma warning(pop)
-# endif
-#endif
-
-/**
- * Basic Joystick class
- * I will make this class a singleton because there should be only one joystick
- * even if there are more than one scene using it and count how many scene are using it.
- * The underlying joystick should only be removed when the last scene is removed
- */
-
-class SCA_Joystick
-
-{
- static SCA_Joystick *m_instance[JOYINDEX_MAX];
- static int m_joynum;
- static int m_refCount;
-
- class PrivateData;
-#ifdef WITH_SDL
- PrivateData *m_private;
-#endif
- int m_joyindex;
-
- /**
- *support for JOYAXIS_MAX axes (in pairs)
- */
- int m_axis_array[JOYAXIS_MAX];
-
- /**
- *support for JOYHAT_MAX hats (each is a direction)
- */
- int m_hat_array[JOYHAT_MAX];
-
- /**
- * Precision or range of the axes
- */
- int m_prec;
-
- /**
- * max # of buttons avail
- */
-
- int m_axismax;
- int m_buttonmax;
- int m_hatmax;
-
- /** is the joystick initialized ?*/
- bool m_isinit;
-
-
- /** is triggered for each event type */
- bool m_istrig_axis;
- bool m_istrig_button;
- bool m_istrig_hat;
-
-#ifdef WITH_SDL
- /**
- * event callbacks
- */
- void OnAxisMotion(SDL_Event *sdl_event);
- void OnHatMotion(SDL_Event *sdl_event);
- void OnButtonUp(SDL_Event *sdl_event);
- void OnButtonDown(SDL_Event *sdl_event);
- void OnNothing(SDL_Event *sdl_event);
-#if 0 /* not used yet */
- void OnBallMotion(SDL_Event *sdl_event) {}
-#endif
-
-#endif /* WITH_SDL */
- /**
- * Open the joystick
- */
- bool CreateJoystickDevice(void);
-
- /**
- * Close the joystick
- */
- void DestroyJoystickDevice(void);
-
- /**
- * fills the axis member values
- */
- void pFillButtons(void);
-
- /**
- * returns m_axis_array
- */
-
- int pAxisTest(int axisnum);
- /**
- * returns m_axis_array
- */
- int pGetAxis(int axisnum, int udlr);
-
- SCA_Joystick(short int index);
-
- ~SCA_Joystick();
-
-public:
-
- static SCA_Joystick *GetInstance(short int joyindex);
- static void HandleEvents(void);
- void ReleaseInstance();
-
-
- /*
- */
- bool aAxisPairIsPositive(int axis);
- bool aAxisPairDirectionIsPositive(int axis, int dir); /* function assumes joysticks are in axis pairs */
- bool aAxisIsPositive(int axis_single); /* check a single axis only */
-
- bool aAnyButtonPressIsPositive(void);
- bool aButtonPressIsPositive(int button);
- bool aButtonReleaseIsPositive(int button);
- bool aHatIsPositive(int hatnum, int dir);
-
- /**
- * precision is default '3200' which is overridden by input
- */
-
- void cSetPrecision(int val);
-
- int GetAxisPosition(int index) {
- return m_axis_array[index];
- }
-
- int GetHat(int index) {
- return m_hat_array[index];
- }
-
- int GetThreshold(void) {
- return m_prec;
- }
-
- bool IsTrigAxis(void) {
- return m_istrig_axis;
- }
-
- bool IsTrigButton(void) {
- return m_istrig_button;
- }
-
- bool IsTrigHat(void) {
- return m_istrig_hat;
- }
-
- /**
- * returns the # of...
- */
-
- int GetNumberOfAxes(void);
- int GetNumberOfButtons(void);
- int GetNumberOfHats(void);
-
- /**
- * Test if the joystick is connected
- */
- int Connected(void);
-
- /**
- * Name of the joytsick
- */
- const char *GetName();
-};
-
-#endif
-
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
deleted file mode 100644
index 566e5567507..00000000000
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
+++ /dev/null
@@ -1,56 +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): snailrose.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file SCA_JoystickDefines.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_JOYSTICKDEFINES_H__
-#define __SCA_JOYSTICKDEFINES_H__
-
-#ifdef main
-#undef main
-#endif
-
-#ifndef DEBUG
-# define JOYSTICK_ECHO(x)
-#else
-# include <iostream>
-# define JOYSTICK_ECHO(x) std::cout << x << std::endl;
-#endif
-
-#define JOYINDEX_MAX 8
-#define JOYAXIS_MAX 16
-#define JOYBUT_MAX 18
-#define JOYHAT_MAX 4
-
-#define JOYAXIS_RIGHT 0
-#define JOYAXIS_UP 1
-#define JOYAXIS_DOWN 3
-#define JOYAXIS_LEFT 2
-
-#endif
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
deleted file mode 100644
index 1dee1de9de2..00000000000
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
+++ /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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): snailrose.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
- * \ingroup gamelogic
- */
-
-#include "SCA_Joystick.h"
-#include "SCA_JoystickPrivate.h"
-
-#ifdef _MSC_VER
-# include <cstdio> /* printf */
-#endif
-
-#ifdef WITH_SDL
-void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event)
-{
- if (sdl_event->jaxis.axis >= JOYAXIS_MAX)
- return;
-
- m_axis_array[sdl_event->jaxis.axis] = sdl_event->jaxis.value;
- m_istrig_axis = 1;
-}
-
-/* See notes below in the event loop */
-void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event)
-{
- if (sdl_event->jhat.hat >= JOYHAT_MAX)
- return;
-
- m_hat_array[sdl_event->jhat.hat] = sdl_event->jhat.value;
- m_istrig_hat = 1;
-}
-
-/* See notes below in the event loop */
-void SCA_Joystick::OnButtonUp(SDL_Event* sdl_event)
-{
- m_istrig_button = 1;
-}
-
-
-void SCA_Joystick::OnButtonDown(SDL_Event* sdl_event)
-{
- //if (sdl_event->jbutton.button > m_buttonmax) /* unsigned int so always above 0 */
- // return;
- // sdl_event->jbutton.button;
-
- m_istrig_button = 1;
-}
-
-
-void SCA_Joystick::OnNothing(SDL_Event* sdl_event)
-{
- m_istrig_axis = m_istrig_button = m_istrig_hat = 0;
-}
-
-void SCA_Joystick::HandleEvents(void)
-{
- SDL_Event sdl_event;
-
-#ifdef WITH_SDL_DYNLOAD
- if (SDL_PollEvent == (void*)0) {
- return;
- }
-#endif
-
- int i;
- for (i=0; i<m_joynum; i++) { /* could use JOYINDEX_MAX but no reason to */
- if (SCA_Joystick::m_instance[i])
- SCA_Joystick::m_instance[i]->OnNothing(&sdl_event);
- }
-
- while (SDL_PollEvent(&sdl_event)) {
- /* Note! m_instance[sdl_event.jaxis.which]
- * will segfault if over JOYINDEX_MAX, not too nice but what are the chances? */
-
- /* Note!, with buttons, this wont care which button is pressed,
- * only to set 'm_istrig_button', actual pressed buttons are detected by SDL_JoystickGetButton */
-
- /* Note!, if you manage to press and release a button within 1 logic tick
- * it wont work as it should */
-
- switch (sdl_event.type) {
- case SDL_JOYAXISMOTION:
- SCA_Joystick::m_instance[sdl_event.jaxis.which]->OnAxisMotion(&sdl_event);
- break;
- case SDL_JOYHATMOTION:
- SCA_Joystick::m_instance[sdl_event.jhat.which]->OnHatMotion(&sdl_event);
- break;
- case SDL_JOYBUTTONUP:
- SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonUp(&sdl_event);
- break;
- case SDL_JOYBUTTONDOWN:
- SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonDown(&sdl_event);
- break;
-#if 0 /* Not used yet */
- case SDL_JOYBALLMOTION:
- SCA_Joystick::m_instance[sdl_event.jball.which]->OnBallMotion(&sdl_event);
- break;
-#endif
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- case SDL_JOYDEVICEADDED:
- case SDL_JOYDEVICEREMOVED:
- /* pass */
- break;
-#endif
- default:
- printf("SCA_Joystick::HandleEvents, Unknown SDL event (%d), this should not happen\n", sdl_event.type);
- break;
- }
- }
-}
-#endif /* WITH_SDL */
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h
deleted file mode 100644
index 472a7353190..00000000000
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h
+++ /dev/null
@@ -1,52 +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): snailrose.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file SCA_JoystickPrivate.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_JOYSTICKPRIVATE_H__
-#define __SCA_JOYSTICKPRIVATE_H__
-#include "SCA_Joystick.h"
-
-#ifdef WITH_SDL
-class SCA_Joystick::PrivateData
-{
-public:
- /*
- * The Joystick
- */
- SDL_Joystick* m_joystick;
-
- PrivateData()
- : m_joystick(NULL)
- {
- }
-};
-#endif /* WITH_SDL */
-
-#endif
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
deleted file mode 100644
index 6a87d3ccb98..00000000000
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * SCA_2DFilterActuator.cpp
- *
- *
- * ***** 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/GameLogic/SCA_2DFilterActuator.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include "SCA_IActuator.h"
-#include "SCA_2DFilterActuator.h"
-
-#include <iostream>
-
-SCA_2DFilterActuator::~SCA_2DFilterActuator()
-{
-}
-
-SCA_2DFilterActuator::SCA_2DFilterActuator(
- SCA_IObject *gameobj,
- RAS_2DFilterManager::RAS_2DFILTER_MODE type,
- short flag,
- float float_arg,
- int int_arg,
- RAS_IRasterizer* rasterizer,
- SCA_IScene* scene)
- : SCA_IActuator(gameobj, KX_ACT_2DFILTER),
- m_type(type),
- m_disableMotionBlur(flag),
- m_float_arg(float_arg),
- m_int_arg(int_arg),
- m_rasterizer(rasterizer),
- m_scene(scene)
-{
- m_gameobj = NULL;
- if (gameobj) {
- m_propNames = gameobj->GetPropertyNames();
- m_gameobj = gameobj;
- }
-}
-
-
-CValue* SCA_2DFilterActuator::GetReplica()
-{
- SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-
-bool SCA_2DFilterActuator::Update()
-{
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
-
- if ( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR )
- {
- if (!m_disableMotionBlur)
- m_rasterizer->EnableMotionBlur(m_float_arg);
- else
- m_rasterizer->DisableMotionBlur();
-
- return false;
- }
- else if (m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS)
- {
- m_scene->Update2DFilter(m_propNames, m_gameobj, m_type, m_int_arg, m_shaderText);
- }
- // once the filter is in place, no need to update it again => disable the actuator
- return false;
-}
-
-
-void SCA_2DFilterActuator::SetScene(SCA_IScene *scene)
-{
- m_scene = scene;
-}
-
-void SCA_2DFilterActuator::SetShaderText(const char *text)
-{
- m_shaderText = text;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_2DFilterActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_2DFilterActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_2DFilterActuator::Methods[] = {
- /* add python functions to deal with m_msg... */
- {NULL,NULL}
-};
-
-PyAttributeDef SCA_2DFilterActuator::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW("shaderText", 0, 64000, false, SCA_2DFilterActuator, m_shaderText),
- KX_PYATTRIBUTE_SHORT_RW("disableMotionBlur", 0, 1, true, SCA_2DFilterActuator, m_disableMotionBlur),
- KX_PYATTRIBUTE_ENUM_RW("mode",RAS_2DFilterManager::RAS_2DFILTER_ENABLED,RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS,false,SCA_2DFilterActuator,m_type),
- KX_PYATTRIBUTE_INT_RW("passNumber", 0, 100, true, SCA_2DFilterActuator, m_int_arg),
- KX_PYATTRIBUTE_FLOAT_RW("value", 0.0, 100.0, SCA_2DFilterActuator, m_float_arg),
- { NULL } //Sentinel
-};
-
-#endif
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
deleted file mode 100644
index 4635a8ad9f8..00000000000
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SCA_2DFilterActuator.h
- *
- *
- * ***** 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 SCA_2DFilterActuator.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_2DFILTERACTUATOR_H__
-#define __SCA_2DFILTERACTUATOR_H__
-
-#include "RAS_IRasterizer.h"
-#include "SCA_IActuator.h"
-#include "SCA_IScene.h"
-
-class SCA_2DFilterActuator : public SCA_IActuator
-{
- Py_Header
-
-private:
- vector<STR_String> m_propNames;
- RAS_2DFilterManager::RAS_2DFILTER_MODE m_type;
- short m_disableMotionBlur;
- float m_float_arg;
- int m_int_arg;
- STR_String m_shaderText;
- RAS_IRasterizer* m_rasterizer;
- SCA_IScene* m_scene;
-
-public:
-
- SCA_2DFilterActuator(
- class SCA_IObject* gameobj,
- RAS_2DFilterManager::RAS_2DFILTER_MODE type,
- short flag,
- float float_arg,
- int int_arg,
- RAS_IRasterizer* rasterizer,
- SCA_IScene* scene);
-
- void SetShaderText(const char *text);
- virtual ~SCA_2DFilterActuator();
- virtual bool Update();
-
- void SetScene(SCA_IScene *scene);
-
- virtual CValue* GetReplica();
-};
-#endif
diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp
deleted file mode 100644
index 2cb7406779c..00000000000
--- a/source/gameengine/GameLogic/SCA_ANDController.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 'And' together all inputs
- *
- *
- * ***** 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/GameLogic/SCA_ANDController.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_ANDController.h"
-#include "SCA_ISensor.h"
-#include "SCA_LogicManager.h"
-#include "EXP_BoolValue.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_ANDController::SCA_ANDController(SCA_IObject* gameobj)
- :
- SCA_IController(gameobj)
-{
-}
-
-
-
-SCA_ANDController::~SCA_ANDController()
-{
-}
-
-
-
-void SCA_ANDController::Trigger(SCA_LogicManager* logicmgr)
-{
-
- bool sensorresult = true;
-
- for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
- !(is==m_linkedsensors.end());is++)
- {
- SCA_ISensor* sensor = *is;
- if (!sensor->GetState())
- {
- sensorresult = false;
- break;
- }
- }
-
- for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
- !(i==m_linkedactuators.end());i++)
- {
- SCA_IActuator* actua = *i;
- logicmgr->AddActiveActuator(actua,sensorresult);
- }
-}
-
-
-
-CValue* SCA_ANDController::GetReplica()
-{
- CValue* replica = new SCA_ANDController(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_ANDController::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_ANDController",
- 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,
- &SCA_IController::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_ANDController::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_ANDController::Attributes[] = {
- { NULL } //Sentinel
-};
-#endif // WITH_PYTHON
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ANDController.h b/source/gameengine/GameLogic/SCA_ANDController.h
deleted file mode 100644
index ff152d6d2fb..00000000000
--- a/source/gameengine/GameLogic/SCA_ANDController.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * SCA_ANDController.h
- *
- *
- * ***** 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 SCA_ANDController.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_ANDCONTROLLER_H__
-#define __SCA_ANDCONTROLLER_H__
-
-#include "SCA_IController.h"
-
-class SCA_ANDController : public SCA_IController
-{
- Py_Header
- //virtual void Trigger(class SCA_LogicManager* logicmgr);
-public:
- SCA_ANDController(SCA_IObject* gameobj);
- virtual ~SCA_ANDController();
- virtual CValue* GetReplica();
- virtual void Trigger(SCA_LogicManager* logicmgr);
-};
-
-#endif /* __SCA_ANDCONTROLLER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
deleted file mode 100644
index fcb236f0913..00000000000
--- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
+++ /dev/null
@@ -1,68 +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/GameLogic/SCA_ActuatorEventManager.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_ISensor.h"
-#include "SCA_ActuatorEventManager.h"
-#include "SCA_ActuatorSensor.h"
-
-
-SCA_ActuatorEventManager::SCA_ActuatorEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(logicmgr, ACTUATOR_EVENTMGR)
-{
-}
-
-
-
-SCA_ActuatorEventManager::~SCA_ActuatorEventManager()
-{
-
-}
-
-void SCA_ActuatorEventManager::NextFrame()
-{
- // check for changed actuator
- SG_DList::iterator<SCA_ISensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- (*it)->Activate(m_logicmgr);
- }
-}
-
-void SCA_ActuatorEventManager::UpdateFrame()
-{
- // update the state of actuator before executing them
- SG_DList::iterator<SCA_ActuatorSensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- (*it)->Update();
- }
-}
diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h
deleted file mode 100644
index 997be1145db..00000000000
--- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h
+++ /dev/null
@@ -1,56 +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 SCA_ActuatorEventManager.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_ACTUATOREVENTMANAGER_H__
-#define __SCA_ACTUATOREVENTMANAGER_H__
-
-#include "SCA_EventManager.h"
-
-#include <vector>
-
-using namespace std;
-
-class SCA_ActuatorEventManager : public SCA_EventManager
-{
-public:
- SCA_ActuatorEventManager(class SCA_LogicManager* logicmgr);
- virtual ~SCA_ActuatorEventManager();
- virtual void NextFrame();
- virtual void UpdateFrame();
- //SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_ActuatorEventManager")
-#endif
-};
-
-#endif /* __SCA_ACTUATOREVENTMANAGER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
deleted file mode 100644
index 8b7702228ce..00000000000
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Actuator sensor
- *
- *
- * ***** 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/GameLogic/SCA_ActuatorSensor.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include <iostream>
-#include "SCA_ActuatorSensor.h"
-#include "SCA_EventManager.h"
-#include "SCA_LogicManager.h"
-
-SCA_ActuatorSensor::SCA_ActuatorSensor(SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- const STR_String& actname)
- : SCA_ISensor(gameobj,eventmgr),
- m_checkactname(actname)
-{
- m_actuator = GetParent()->FindActuator(m_checkactname);
- Init();
-}
-
-void SCA_ActuatorSensor::Init()
-{
- m_lastresult = m_invert?true:false;
- m_midresult = m_lastresult;
- m_reset = true;
-}
-
-CValue* SCA_ActuatorSensor::GetReplica()
-{
- SCA_ActuatorSensor* replica = new SCA_ActuatorSensor(*this);
- // m_range_expr must be recalculated on replica!
- replica->ProcessReplica();
- replica->Init();
-
- return replica;
-}
-
-void SCA_ActuatorSensor::ReParent(SCA_IObject* parent)
-{
- m_actuator = parent->FindActuator(m_checkactname);
- SCA_ISensor::ReParent(parent);
-}
-
-bool SCA_ActuatorSensor::IsPositiveTrigger()
-{
- bool result = m_lastresult;
- if (m_invert)
- result = !result;
-
- return result;
-}
-
-
-
-SCA_ActuatorSensor::~SCA_ActuatorSensor()
-{
-}
-
-
-
-bool SCA_ActuatorSensor::Evaluate()
-{
- if (m_actuator)
- {
- bool result = m_actuator->IsActive();
- bool reset = m_reset && m_level;
-
- m_reset = false;
- if (m_lastresult != result || m_midresult != result)
- {
- m_lastresult = m_midresult = result;
- return true;
- }
- return (reset) ? true : false;
- }
- return false;
-}
-
-void SCA_ActuatorSensor::Update()
-{
- if (m_actuator)
- {
- m_midresult = m_actuator->IsActive() && !m_actuator->IsNegativeEvent();
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_ActuatorSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_ActuatorSensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_ActuatorSensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_ActuatorSensor::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW_CHECK("actuator",0,MAX_PROP_NAME,false,SCA_ActuatorSensor,m_checkactname,CheckActuator),
- { NULL } //Sentinel
-};
-
-int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
-{
- SCA_ActuatorSensor* sensor = reinterpret_cast<SCA_ActuatorSensor*>(self);
- SCA_IActuator* act = sensor->GetParent()->FindActuator(sensor->m_checkactname);
- if (act) {
- sensor->m_actuator = act;
- return 0;
- }
- PyErr_SetString(PyExc_AttributeError, "string does not correspond to an actuator");
- return 1;
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
deleted file mode 100644
index 6005bd3ac6c..00000000000
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.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 *****
- */
-
-#ifndef __SCA_ACTUATORSENSOR_H__
-#define __SCA_ACTUATORSENSOR_H__
-
-/** \file SCA_ActuatorSensor.h
- * \ingroup gamelogic
- */
-
-#include "SCA_ISensor.h"
-#include "SCA_IActuator.h"
-
-class SCA_ActuatorSensor : public SCA_ISensor
-{
- Py_Header
- STR_String m_checkactname;
- bool m_lastresult;
- bool m_midresult;
- protected:
- SCA_IActuator* m_actuator;
-public:
- SCA_ActuatorSensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- const STR_String& actname);
-
- virtual ~SCA_ActuatorSensor();
- virtual CValue* GetReplica();
- virtual void Init();
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
- virtual void ReParent(SCA_IObject* parent);
- void Update();
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- static int CheckActuator(void *self, const PyAttributeDef*);
-
-#endif /* WITH_PYTHON */
-};
-
-#endif /* __SCA_ACTUATORSENSOR_H__ */
diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
deleted file mode 100644
index 22746953a27..00000000000
--- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Manager for 'always' events. Since always sensors can operate in pulse
- * mode, they need to be activated.
- *
- *
- * ***** 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/GameLogic/SCA_AlwaysEventManager.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_AlwaysEventManager.h"
-#include "SCA_LogicManager.h"
-#include <vector>
-#include "SCA_ISensor.h"
-
-using namespace std;
-
-SCA_AlwaysEventManager::SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(logicmgr, ALWAYS_EVENTMGR)
-{
-}
-
-
-
-void SCA_AlwaysEventManager::NextFrame()
-{
- SG_DList::iterator<SCA_ISensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- (*it)->Activate(m_logicmgr);
- }
-}
-
diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
deleted file mode 100644
index 47293c75726..00000000000
--- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
+++ /dev/null
@@ -1,50 +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 SCA_AlwaysEventManager.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_ALWAYSEVENTMANAGER_H__
-#define __SCA_ALWAYSEVENTMANAGER_H__
-#include "SCA_EventManager.h"
-#include <vector>
-
-using namespace std;
-class SCA_AlwaysEventManager : public SCA_EventManager
-{
-public:
- SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr);
- virtual void NextFrame();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_AlwaysEventManager")
-#endif
-};
-
-#endif /* __SCA_ALWAYSEVENTMANAGER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
deleted file mode 100644
index 1a6a82a33eb..00000000000
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Always trigger
- *
- *
- * ***** 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/GameLogic/SCA_AlwaysSensor.cpp
- * \ingroup gamelogic
- */
-
-#ifdef _MSC_VER
- /* This warning tells us about truncation of __long__ stl-generated names.
- * It can occasionally cause DevStudio to have internal compiler warnings. */
-# pragma warning( disable:4786 )
-#endif
-
-#include "SCA_AlwaysSensor.h"
-#include "SCA_LogicManager.h"
-#include "SCA_EventManager.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_AlwaysSensor::SCA_AlwaysSensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj)
- : SCA_ISensor(gameobj,eventmgr)
-{
- //SetDrawColor(255,0,0);
- Init();
-}
-
-void SCA_AlwaysSensor::Init()
-{
- m_alwaysresult = true;
-}
-
-SCA_AlwaysSensor::~SCA_AlwaysSensor()
-{
- /* intentionally empty */
-}
-
-
-
-CValue* SCA_AlwaysSensor::GetReplica()
-{
- CValue* replica = new SCA_AlwaysSensor(*this);//m_float,GetName());
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-
-
-bool SCA_AlwaysSensor::IsPositiveTrigger()
-{
- return (m_invert ? false : true);
-}
-
-
-
-bool SCA_AlwaysSensor::Evaluate()
-{
- /* Nice! :) */
- //return true;
- /* even nicer ;) */
- //return false;
-
- /* nicest ! */
- bool result = m_alwaysresult;
- m_alwaysresult = false;
- return result;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_AlwaysSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_AlwaysSensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_AlwaysSensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_AlwaysSensor::Attributes[] = {
- { NULL } //Sentinel
-};
-
-#endif
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.h b/source/gameengine/GameLogic/SCA_AlwaysSensor.h
deleted file mode 100644
index e0ab4279b1c..00000000000
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SCA_AlwaysSensor.h
- *
- *
- * ***** 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 SCA_AlwaysSensor.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_ALWAYSSENSOR_H__
-#define __SCA_ALWAYSSENSOR_H__
-#include "SCA_ISensor.h"
-
-class SCA_AlwaysSensor : public SCA_ISensor
-{
- Py_Header
- bool m_alwaysresult;
-public:
- SCA_AlwaysSensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj);
- virtual ~SCA_AlwaysSensor();
- virtual CValue* GetReplica();
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
- virtual void Init();
-};
-
-#endif /* __SCA_ALWAYSSENSOR_H__ */
diff --git a/source/gameengine/GameLogic/SCA_BasicEventManager.cpp b/source/gameengine/GameLogic/SCA_BasicEventManager.cpp
deleted file mode 100644
index e87f9b8f0e4..00000000000
--- a/source/gameengine/GameLogic/SCA_BasicEventManager.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Manager for 'always' events. Since always sensors can operate in pulse
- * mode, they need to be activated.
- *
- *
- * ***** 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/GameLogic/SCA_BasicEventManager.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_BasicEventManager.h"
-#include "SCA_LogicManager.h"
-#include <vector>
-#include "SCA_ISensor.h"
-
-using namespace std;
-
-SCA_BasicEventManager::SCA_BasicEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(logicmgr, BASIC_EVENTMGR)
-{
-}
-
-SCA_BasicEventManager::~SCA_BasicEventManager()
-{
-}
-
-void SCA_BasicEventManager::NextFrame()
-{
- SG_DList::iterator<SCA_ISensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- (*it)->Activate(m_logicmgr);
- }
-}
-
diff --git a/source/gameengine/GameLogic/SCA_BasicEventManager.h b/source/gameengine/GameLogic/SCA_BasicEventManager.h
deleted file mode 100644
index a015233454b..00000000000
--- a/source/gameengine/GameLogic/SCA_BasicEventManager.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Manager for sensor that only need to call Update
- *
- *
- * ***** 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 SCA_BasicEventManager.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_BASICEVENTMANAGER_H__
-#define __SCA_BASICEVENTMANAGER_H__
-
-#include "SCA_EventManager.h"
-#include <vector>
-
-using namespace std;
-
-class SCA_BasicEventManager : public SCA_EventManager
-{
-public:
- SCA_BasicEventManager(class SCA_LogicManager* logicmgr);
- ~SCA_BasicEventManager();
-
- virtual void NextFrame();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_BasicEventManager")
-#endif
-};
-
-#endif /* __SCA_BASICEVENTMANAGER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
deleted file mode 100644
index af751cffc2e..00000000000
--- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Delay trigger
- *
- *
- * ***** 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/GameLogic/SCA_DelaySensor.cpp
- * \ingroup gamelogic
- */
-
-#ifdef _MSC_VER
- /* This warning tells us about truncation of __long__ stl-generated names.
- * It can occasionally cause DevStudio to have internal compiler warnings. */
-# pragma warning( disable:4786 )
-#endif
-
-#include <stddef.h>
-
-#include "SCA_DelaySensor.h"
-#include "SCA_LogicManager.h"
-#include "SCA_EventManager.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_DelaySensor::SCA_DelaySensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- int delay,
- int duration,
- bool repeat)
- : SCA_ISensor(gameobj,eventmgr),
- m_repeat(repeat),
- m_delay(delay),
- m_duration(duration)
-{
- Init();
-}
-
-void SCA_DelaySensor::Init()
-{
- m_lastResult = false;
- m_frameCount = -1;
- m_reset = true;
-}
-
-SCA_DelaySensor::~SCA_DelaySensor()
-{
- /* intentionally empty */
-}
-
-CValue* SCA_DelaySensor::GetReplica()
-{
- CValue* replica = new SCA_DelaySensor(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-
-
-bool SCA_DelaySensor::IsPositiveTrigger()
-{
- return (m_invert ? !m_lastResult : m_lastResult);
-}
-
-bool SCA_DelaySensor::Evaluate()
-{
- bool trigger = false;
- bool result;
-
- if (m_frameCount==-1) {
- // this is needed to ensure ON trigger in case delay==0
- // and avoid spurious OFF trigger when duration==0
- m_lastResult = false;
- m_frameCount = 0;
- }
-
- if (m_frameCount<m_delay) {
- m_frameCount++;
- result = false;
- } else if (m_duration > 0) {
- if (m_frameCount < m_delay+m_duration) {
- m_frameCount++;
- result = true;
- } else {
- result = false;
- if (m_repeat)
- m_frameCount = -1;
- }
- } else {
- result = true;
- if (m_repeat)
- m_frameCount = -1;
- }
- if ((m_reset && m_level) || result != m_lastResult)
- trigger = true;
- m_reset = false;
- m_lastResult = result;
- return trigger;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_DelaySensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_DelaySensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_DelaySensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_DelaySensor::Attributes[] = {
- KX_PYATTRIBUTE_INT_RW("delay",0,100000,true,SCA_DelaySensor,m_delay),
- KX_PYATTRIBUTE_INT_RW("duration",0,100000,true,SCA_DelaySensor,m_duration),
- KX_PYATTRIBUTE_BOOL_RW("repeat",SCA_DelaySensor,m_repeat),
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h
deleted file mode 100644
index 9b39de7e099..00000000000
--- a/source/gameengine/GameLogic/SCA_DelaySensor.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * SCA_DelaySensor.h
- *
- *
- * ***** 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 SCA_DelaySensor.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_DELAYSENSOR_H__
-#define __SCA_DELAYSENSOR_H__
-#include "SCA_ISensor.h"
-
-class SCA_DelaySensor : public SCA_ISensor
-{
- Py_Header
- bool m_lastResult;
- bool m_repeat;
- int m_delay;
- int m_duration;
- int m_frameCount;
-
-public:
- SCA_DelaySensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- int delay,
- int duration,
- bool repeat);
- virtual ~SCA_DelaySensor();
- virtual CValue* GetReplica();
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
- virtual void Init();
-
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-};
-
-#endif /* __SCA_DELAYSENSOR_H__ */
diff --git a/source/gameengine/GameLogic/SCA_EventManager.cpp b/source/gameengine/GameLogic/SCA_EventManager.cpp
deleted file mode 100644
index ffe1ea2dc30..00000000000
--- a/source/gameengine/GameLogic/SCA_EventManager.cpp
+++ /dev/null
@@ -1,83 +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/GameLogic/SCA_EventManager.cpp
- * \ingroup gamelogic
- */
-
-
-#include <assert.h>
-#include "SCA_EventManager.h"
-#include "SCA_ISensor.h"
-
-
-SCA_EventManager::SCA_EventManager(SCA_LogicManager* logicmgr, EVENT_MANAGER_TYPE mgrtype)
- :m_logicmgr(logicmgr),
- m_mgrtype(mgrtype)
-{
-}
-
-
-
-SCA_EventManager::~SCA_EventManager()
-{
- // all sensors should be removed
- assert(m_sensors.Empty());
-}
-
-void SCA_EventManager::RegisterSensor(class SCA_ISensor* sensor)
-{
- m_sensors.AddBack(sensor);
-}
-
-void SCA_EventManager::RemoveSensor(class SCA_ISensor* sensor)
-{
- sensor->Delink();
-}
-
-void SCA_EventManager::NextFrame(double curtime, double fixedtime)
-{
- NextFrame();
-}
-
-void SCA_EventManager::NextFrame()
-{
- assert(false); // && "Event managers should override a NextFrame method");
-}
-
-void SCA_EventManager::EndFrame()
-{
-}
-
-void SCA_EventManager::UpdateFrame()
-{
-}
-
-int SCA_EventManager::GetType()
-{
- return (int) m_mgrtype;
-}
diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h
deleted file mode 100644
index eb9a6d9aca1..00000000000
--- a/source/gameengine/GameLogic/SCA_EventManager.h
+++ /dev/null
@@ -1,91 +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 SCA_EventManager.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_EVENTMANAGER_H__
-#define __SCA_EVENTMANAGER_H__
-
-#include <vector>
-#include <set>
-#include <algorithm>
-
-#include "SG_DList.h"
-
-class SCA_EventManager
-{
-protected:
- class SCA_LogicManager* m_logicmgr; /* all event manager subclasses use this (other then TimeEventManager) */
-
- // use a set to speed-up insertion/removal
- //std::set <class SCA_ISensor*> m_sensors;
- SG_DList m_sensors;
-
-public:
- enum EVENT_MANAGER_TYPE {
- KEYBOARD_EVENTMGR = 0,
- MOUSE_EVENTMGR,
- ALWAYS_EVENTMGR,
- TOUCH_EVENTMGR,
- PROPERTY_EVENTMGR,
- TIME_EVENTMGR,
- RANDOM_EVENTMGR,
- RAY_EVENTMGR,
- NETWORK_EVENTMGR,
- JOY_EVENTMGR,
- ACTUATOR_EVENTMGR,
- BASIC_EVENTMGR
- };
-
- SCA_EventManager(SCA_LogicManager* logicmgr, EVENT_MANAGER_TYPE mgrtype);
- virtual ~SCA_EventManager();
-
- virtual void RemoveSensor(class SCA_ISensor* sensor);
- virtual void NextFrame(double curtime, double fixedtime);
- virtual void NextFrame();
- virtual void UpdateFrame();
- virtual void EndFrame();
- virtual void RegisterSensor(class SCA_ISensor* sensor);
- int GetType();
- //SG_DList &GetSensors() { return m_sensors; }
-
-
- void Replace_LogicManager(SCA_LogicManager* logicmgr) { m_logicmgr= logicmgr; }
-
-protected:
- EVENT_MANAGER_TYPE m_mgrtype;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_EventManager")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
deleted file mode 100644
index ef058e215d6..00000000000
--- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * 'Expression Controller enables to calculate an expression that wires inputs to output
- *
- *
- * ***** 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/GameLogic/SCA_ExpressionController.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_ExpressionController.h"
-#include "SCA_ISensor.h"
-#include "SCA_LogicManager.h"
-#include "EXP_BoolValue.h"
-#include "EXP_InputParser.h"
-#include "MT_Transform.h" // for fuzzyZero
-
-#include <stdio.h>
-
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_ExpressionController::SCA_ExpressionController(SCA_IObject* gameobj,
- const STR_String& exprtext)
- :SCA_IController(gameobj),
- m_exprText(exprtext),
- m_exprCache(NULL)
-{
-}
-
-
-
-SCA_ExpressionController::~SCA_ExpressionController()
-{
- if (m_exprCache)
- m_exprCache->Release();
-}
-
-
-
-CValue* SCA_ExpressionController::GetReplica()
-{
- SCA_ExpressionController* replica = new SCA_ExpressionController(*this);
- replica->m_exprText = m_exprText;
- replica->m_exprCache = NULL;
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-
-// Forced deletion of precalculated expression to break reference loop
-// Use this function when you know that you won't use the sensor anymore
-void SCA_ExpressionController::Delete()
-{
- if (m_exprCache)
- {
- m_exprCache->Release();
- m_exprCache = NULL;
- }
- Release();
-}
-
-
-void SCA_ExpressionController::Trigger(SCA_LogicManager* logicmgr)
-{
-
- bool expressionresult = false;
- if (!m_exprCache)
- {
- CParser parser;
- parser.SetContext(this->AddRef());
- m_exprCache = parser.ProcessText(m_exprText);
- }
- if (m_exprCache)
- {
- CValue* value = m_exprCache->Calculate();
- if (value)
- {
- if (value->IsError())
- {
- printf("%s\n", value->GetText().ReadPtr());
- } else
- {
- float num = (float)value->GetNumber();
- expressionresult = !MT_fuzzyZero(num);
- }
- value->Release();
-
- }
- }
-
- for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
- !(i==m_linkedactuators.end());i++)
- {
- SCA_IActuator* actua = *i;
- logicmgr->AddActiveActuator(actua,expressionresult);
- }
-}
-
-
-
-CValue* SCA_ExpressionController::FindIdentifier(const STR_String& identifiername)
-{
-
- CValue* identifierval = NULL;
-
- for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
- !(is==m_linkedsensors.end());is++)
- {
- SCA_ISensor* sensor = *is;
- if (sensor->GetName() == identifiername)
- {
- identifierval = new CBoolValue(sensor->GetState());
- //identifierval = sensor->AddRef();
- break;
- }
-
- //if (!sensor->IsPositiveTrigger())
- //{
- // sensorresult = false;
- // break;
- //}
- }
-
- if (identifierval)
- return identifierval;
-
- return GetParent()->FindIdentifier(identifiername);
-
-}
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h
deleted file mode 100644
index c16944ccde1..00000000000
--- a/source/gameengine/GameLogic/SCA_ExpressionController.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * KX_EXPRESSIONController.h
- *
- *
- * ***** 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 SCA_ExpressionController.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_EXPRESSIONCONTROLLER_H__
-#define __SCA_EXPRESSIONCONTROLLER_H__
-
-#include "SCA_IController.h"
-
-class SCA_ExpressionController : public SCA_IController
-{
-// Py_Header
- STR_String m_exprText;
- CExpression* m_exprCache;
-
-public:
- SCA_ExpressionController(SCA_IObject* gameobj,
- const STR_String& exprtext);
-
- virtual ~SCA_ExpressionController();
- virtual CValue* GetReplica();
- virtual void Trigger(SCA_LogicManager* logicmgr);
- virtual CValue* FindIdentifier(const STR_String& identifiername);
- /**
- * used to release the expression cache
- * so that self references are removed before the controller itself is released
- */
- virtual void Delete();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_ExpressionController")
-#endif
-};
-
-#endif /* __SCA_EXPRESSIONCONTROLLER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp
deleted file mode 100644
index 9a355fdf3c9..00000000000
--- a/source/gameengine/GameLogic/SCA_IActuator.cpp
+++ /dev/null
@@ -1,140 +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/GameLogic/SCA_IActuator.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_IActuator.h"
-#include <stdio.h>
-
-using namespace std;
-
-SCA_IActuator::SCA_IActuator(SCA_IObject* gameobj, KX_ACTUATOR_TYPE type) :
- SCA_ILogicBrick(gameobj),
- m_type(type),
- m_links(0),
- m_posevent(false),
- m_negevent(false)
-{
- // nothing to do
-}
-
-bool SCA_IActuator::Update(double curtime, bool frame)
-{
- if (frame)
- return Update();
-
- return true;
-}
-
-bool SCA_IActuator::Update()
-{
- assert(false && "Actuators should override an Update method.");
- return false;
-}
-
-void SCA_IActuator::Activate(SG_DList& head)
-{
- if (QEmpty())
- {
- InsertActiveQList(m_gameobj->m_activeActuators);
- head.AddBack(&m_gameobj->m_activeActuators);
- }
-}
-
-// this function is only used to deactivate actuators outside the logic loop
-// e.g. when an object is deleted.
-void SCA_IActuator::Deactivate()
-{
- if (QDelink())
- {
- // the actuator was in the active list
- if (m_gameobj->m_activeActuators.QEmpty())
- // the owner object has no more active actuators, remove it from the global list
- m_gameobj->m_activeActuators.Delink();
- }
-}
-
-
-void SCA_IActuator::ProcessReplica()
-{
- SCA_ILogicBrick::ProcessReplica();
- RemoveAllEvents();
- m_linkedcontrollers.clear();
-}
-
-
-
-SCA_IActuator::~SCA_IActuator()
-{
- RemoveAllEvents();
-}
-
-void SCA_IActuator::DecLink()
-{
- m_links--;
- if (m_links < 0)
- {
- printf("Warning: actuator %s has negative m_links: %d\n", m_name.Ptr(), m_links);
- m_links = 0;
- }
-}
-
-void SCA_IActuator::LinkToController(SCA_IController* controller)
-{
- m_linkedcontrollers.push_back(controller);
-}
-
-void SCA_IActuator::UnlinkController(SCA_IController* controller)
-{
- std::vector<class SCA_IController*>::iterator contit;
- for (contit = m_linkedcontrollers.begin();!(contit==m_linkedcontrollers.end());++contit)
- {
- if ((*contit) == controller)
- {
- *contit = m_linkedcontrollers.back();
- m_linkedcontrollers.pop_back();
- return;
- }
- }
- printf("Missing link from actuator %s:%s to controller %s:%s\n",
- m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(),
- controller->GetParent()->GetName().ReadPtr(), controller->GetName().ReadPtr());
-}
-
-void SCA_IActuator::UnlinkAllControllers()
-{
- std::vector<class SCA_IController*>::iterator contit;
- for (contit = m_linkedcontrollers.begin();!(contit==m_linkedcontrollers.end());++contit)
- {
- (*contit)->UnlinkActuator(this);
- }
- m_linkedcontrollers.clear();
-}
-
diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h
deleted file mode 100644
index b63cb633b4e..00000000000
--- a/source/gameengine/GameLogic/SCA_IActuator.h
+++ /dev/null
@@ -1,168 +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 SCA_IActuator.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_IACTUATOR_H__
-#define __SCA_IACTUATOR_H__
-
-#include "SCA_IController.h"
-#include <vector>
-
-/**
- * Use of SG_DList : None
- * Use of SG_QList : element of activated actuator list of their owner
- * Head: SCA_IObject::m_activeActuators
- */
-class SCA_IActuator : public SCA_ILogicBrick
-{
- friend class SCA_LogicManager;
-protected:
- int m_type;
- int m_links; // number of active links to controllers
- // when 0, the actuator is automatically stopped
- //std::vector<CValue*> m_events;
- bool m_posevent;
- bool m_negevent;
-
- std::vector<class SCA_IController*> m_linkedcontrollers;
-
- void RemoveAllEvents()
- {
- m_posevent = false;
- m_negevent = false;
- }
-
-
-public:
- /**
- * This class also inherits the default copy constructors
- */
- enum KX_ACTUATOR_TYPE {
- KX_ACT_OBJECT,
- KX_ACT_IPO,
- KX_ACT_CAMERA,
- KX_ACT_SOUND,
- KX_ACT_PROPERTY,
- KX_ACT_ADD_OBJECT,
- KX_ACT_END_OBJECT,
- KX_ACT_DYNAMIC,
- KX_ACT_REPLACE_MESH,
- KX_ACT_TRACKTO,
- KX_ACT_CONSTRAINT,
- KX_ACT_SCENE,
- KX_ACT_RANDOM,
- KX_ACT_MESSAGE,
- KX_ACT_ACTION,
- KX_ACT_CD,
- KX_ACT_GAME,
- KX_ACT_VISIBILITY,
- KX_ACT_2DFILTER,
- KX_ACT_PARENT,
- KX_ACT_SHAPEACTION,
- KX_ACT_STATE,
- KX_ACT_ARMATURE,
- KX_ACT_STEERING,
- KX_ACT_MOUSE,
- };
-
- SCA_IActuator(SCA_IObject* gameobj, KX_ACTUATOR_TYPE type);
-
- /**
- * UnlinkObject(...)
- * Certain actuator use gameobject pointers (like TractTo actuator)
- * This function can be called when an object is removed to make
- * sure that the actuator will not use it anymore.
- */
-
- virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; }
-
- /**
- * Update(...)
- * Update the actuator based upon the events received since
- * the last call to Update, the current time and deltatime the
- * time elapsed in this frame ?
- * It is the responsibility of concrete Actuators to clear
- * their event's. This is usually done in the Update() method via
- * a call to RemoveAllEvents()
- */
-
-
- virtual bool Update(double curtime, bool frame);
- virtual bool Update();
-
- /**
- * Add an event to an actuator.
- */
- //void AddEvent(CValue* event)
- void AddEvent(bool event)
- {
- if (event)
- m_posevent = true;
- else
- m_negevent = true;
- }
-
- virtual void ProcessReplica();
-
- /**
- * Return true if all the current events
- * are negative. The definition of negative event is
- * not immediately clear. But usually refers to key-up events
- * or events where no action is required.
- */
- bool IsNegativeEvent() const
- {
- return !m_posevent && m_negevent;
- }
-
- virtual ~SCA_IActuator();
-
- /**
- * remove this actuator from the list of active actuators
- */
- virtual void Deactivate();
- virtual void Activate(SG_DList& head);
-
- void LinkToController(SCA_IController* controller);
- void UnlinkController(class SCA_IController* cont);
- void UnlinkAllControllers();
-
- void ClrLink() { m_links=0; }
- void IncLink() { m_links++; }
- virtual void DecLink();
- bool IsNoLink() const { return !m_links; }
- bool IsType(KX_ACTUATOR_TYPE type) { return m_type == type; }
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_IActuator")
-#endif
-};
-
-#endif /* __SCA_IACTUATOR_H__ */
diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp
deleted file mode 100644
index c4176d66688..00000000000
--- a/source/gameengine/GameLogic/SCA_IController.cpp
+++ /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 gameengine/GameLogic/SCA_IController.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include "SCA_IController.h"
-#include "SCA_LogicManager.h"
-#include "SCA_IActuator.h"
-#include "SCA_ISensor.h"
-#include "EXP_PyObjectPlus.h"
-#include "EXP_ListWrapper.h"
-
-#include <stdio.h>
-
-SCA_IController::SCA_IController(SCA_IObject* gameobj)
- :
- SCA_ILogicBrick(gameobj),
- m_statemask(0),
- m_justActivated(false)
-{
-}
-
-
-
-SCA_IController::~SCA_IController()
-{
- //UnlinkAllActuators();
-}
-
-
-
-std::vector<class SCA_ISensor*>& SCA_IController::GetLinkedSensors()
-{
- return m_linkedsensors;
-}
-
-
-
-std::vector<class SCA_IActuator*>& SCA_IController::GetLinkedActuators()
-{
- return m_linkedactuators;
-}
-
-
-
-void SCA_IController::UnlinkAllSensors()
-{
- std::vector<class SCA_ISensor*>::iterator sensit;
- for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
- {
- if (IsActive())
- {
- (*sensit)->DecLink();
- }
- (*sensit)->UnlinkController(this);
- }
- m_linkedsensors.clear();
-}
-
-
-
-void SCA_IController::UnlinkAllActuators()
-{
- std::vector<class SCA_IActuator*>::iterator actit;
- for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
- {
- if (IsActive())
- {
- (*actit)->DecLink();
- }
- (*actit)->UnlinkController(this);
- }
- m_linkedactuators.clear();
-}
-
-void SCA_IController::LinkToActuator(SCA_IActuator* actua)
-{
- m_linkedactuators.push_back(actua);
- if (IsActive())
- {
- actua->IncLink();
- }
-}
-
-void SCA_IController::UnlinkActuator(class SCA_IActuator* actua)
-{
- std::vector<class SCA_IActuator*>::iterator actit;
- for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
- {
- if ((*actit) == actua)
- {
- if (IsActive())
- {
- (*actit)->DecLink();
- }
- *actit = m_linkedactuators.back();
- m_linkedactuators.pop_back();
- return;
- }
- }
- printf("Missing link from controller %s:%s to actuator %s:%s\n",
- m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(),
- actua->GetParent()->GetName().ReadPtr(), actua->GetName().ReadPtr());
-}
-
-void SCA_IController::LinkToSensor(SCA_ISensor* sensor)
-{
- m_linkedsensors.push_back(sensor);
- if (IsActive())
- {
- sensor->IncLink();
- }
-}
-
-void SCA_IController::UnlinkSensor(class SCA_ISensor* sensor)
-{
- std::vector<class SCA_ISensor*>::iterator sensit;
- for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
- {
- if ((*sensit) == sensor)
- {
- if (IsActive())
- {
- sensor->DecLink();
- }
- *sensit = m_linkedsensors.back();
- m_linkedsensors.pop_back();
- return;
- }
- }
- printf("Missing link from controller %s:%s to sensor %s:%s\n",
- m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(),
- sensor->GetParent()->GetName().ReadPtr(), sensor->GetName().ReadPtr());
-}
-
-
-void SCA_IController::ApplyState(unsigned int state)
-{
- std::vector<class SCA_IActuator*>::iterator actit;
- std::vector<class SCA_ISensor*>::iterator sensit;
-
- if (m_statemask & state)
- {
- if (!IsActive())
- {
- // reactive the controller, all the links to actuator are valid again
- for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
- {
- (*actit)->IncLink();
- }
-
- for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
- {
- (*sensit)->IncLink();
- }
- SetActive(true);
- m_justActivated = true;
- }
- } else if (IsActive())
- {
- for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
- {
- (*actit)->DecLink();
- }
- for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
- {
- (*sensit)->DecLink();
- }
- SetActive(false);
- m_justActivated = false;
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* Python api */
-
-PyTypeObject SCA_IController::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_IController",
- 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,
- &SCA_ILogicBrick::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_IController::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_IController::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("state", SCA_IController, pyattr_get_state),
- KX_PYATTRIBUTE_RO_FUNCTION("sensors", SCA_IController, pyattr_get_sensors),
- KX_PYATTRIBUTE_RO_FUNCTION("actuators", SCA_IController, pyattr_get_actuators),
- KX_PYATTRIBUTE_BOOL_RW("useHighPriority",SCA_IController,m_bookmark),
- { NULL } //Sentinel
-};
-
-PyObject *SCA_IController::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_IController* self = static_cast<SCA_IController*>(self_v);
- return PyLong_FromLong(self->m_statemask);
-}
-
-static int sca_icontroller_get_sensors_size_cb(void *self_v)
-{
- return ((SCA_IController *)self_v)->GetLinkedSensors().size();
-}
-
-static PyObject *sca_icontroller_get_sensors_item_cb(void *self_v, int index)
-{
- return ((SCA_IController *)self_v)->GetLinkedSensors()[index]->GetProxy();
-}
-
-static const char *sca_icontroller_get_sensors_item_name_cb(void *self_v, int index)
-{
- return ((SCA_IController *)self_v)->GetLinkedSensors()[index]->GetName().ReadPtr();
-}
-
-PyObject *SCA_IController::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- return (new CListWrapper(self_v,
- ((SCA_IController *)self_v)->GetProxy(),
- NULL,
- sca_icontroller_get_sensors_size_cb,
- sca_icontroller_get_sensors_item_cb,
- sca_icontroller_get_sensors_item_name_cb,
- NULL))->NewProxy(true);
-}
-
-static int sca_icontroller_get_actuators_size_cb(void *self_v)
-{
- return ((SCA_IController *)self_v)->GetLinkedActuators().size();
-}
-
-static PyObject *sca_icontroller_get_actuators_item_cb(void *self_v, int index)
-{
- return ((SCA_IController *)self_v)->GetLinkedActuators()[index]->GetProxy();
-}
-
-static const char *sca_icontroller_get_actuators_item_name_cb(void *self_v, int index)
-{
- return ((SCA_IController *)self_v)->GetLinkedActuators()[index]->GetName().ReadPtr();
-}
-
-PyObject *SCA_IController::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- return (new CListWrapper(self_v,
- ((SCA_IController *)self_v)->GetProxy(),
- NULL,
- sca_icontroller_get_actuators_size_cb,
- sca_icontroller_get_actuators_item_cb,
- sca_icontroller_get_actuators_item_name_cb,
- NULL))->NewProxy(true);
-}
-#endif // WITH_PYTHON
diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h
deleted file mode 100644
index 4ec872c2316..00000000000
--- a/source/gameengine/GameLogic/SCA_IController.h
+++ /dev/null
@@ -1,112 +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 SCA_IController.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_ICONTROLLER_H__
-#define __SCA_ICONTROLLER_H__
-
-#include "SCA_ILogicBrick.h"
-#include "EXP_PyObjectPlus.h"
-
-/**
- * Use of SG_DList element: none
- * Use of SG_QList element: build ordered list of activated controller on the owner object
- * Head: SCA_IObject::m_activeControllers
- */
-class SCA_IController : public SCA_ILogicBrick
-{
- Py_Header
-protected:
- std::vector<class SCA_ISensor*> m_linkedsensors;
- std::vector<class SCA_IActuator*> m_linkedactuators;
- unsigned int m_statemask;
- bool m_justActivated;
- bool m_bookmark;
-public:
- SCA_IController(SCA_IObject* gameobj);
- virtual ~SCA_IController();
- virtual void Trigger(class SCA_LogicManager* logicmgr)=0;
- void LinkToSensor(SCA_ISensor* sensor);
- void LinkToActuator(SCA_IActuator*);
- std::vector<class SCA_ISensor*>& GetLinkedSensors();
- std::vector<class SCA_IActuator*>& GetLinkedActuators();
- void ReserveActuator(int num)
- {
- m_linkedactuators.reserve(num);
- }
- void UnlinkAllSensors();
- void UnlinkAllActuators();
- void UnlinkActuator(class SCA_IActuator* actua);
- void UnlinkSensor(class SCA_ISensor* sensor);
- void SetState(unsigned int state) { m_statemask = state; }
- void ApplyState(unsigned int state);
- void Deactivate()
- {
- // the controller can only be part of a sensor m_newControllers list
- Delink();
- }
- bool IsJustActivated()
- {
- return m_justActivated;
- }
- void ClrJustActivated()
- {
- m_justActivated = false;
- }
- void SetBookmark(bool bookmark)
- {
- m_bookmark = bookmark;
- }
- void Activate(SG_DList& head)
- {
- if (QEmpty())
- {
- if (m_bookmark)
- {
- m_gameobj->m_activeBookmarkedControllers.QAddBack(this);
- head.AddFront(&m_gameobj->m_activeBookmarkedControllers);
- }
- else
- {
- InsertActiveQList(m_gameobj->m_activeControllers);
- head.AddBack(&m_gameobj->m_activeControllers);
- }
- }
- }
-
-
-#ifdef WITH_PYTHON
- static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-#endif /* WITH_PYTHON */
-};
-
-#endif /* __SCA_ICONTROLLER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.cpp b/source/gameengine/GameLogic/SCA_IInputDevice.cpp
deleted file mode 100644
index f4fce034c87..00000000000
--- a/source/gameengine/GameLogic/SCA_IInputDevice.cpp
+++ /dev/null
@@ -1,139 +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/GameLogic/SCA_IInputDevice.cpp
- * \ingroup gamelogic
- */
-
-
-#include <assert.h>
-#include "SCA_IInputDevice.h"
-
-SCA_IInputDevice::SCA_IInputDevice()
- :
- m_currentTable(0)
-{
- ClearStatusTable(0);
- ClearStatusTable(1);
-}
-
-
-
-SCA_IInputDevice::~SCA_IInputDevice()
-{
-}
-
-void SCA_IInputDevice::HookEscape()
-{
- assert(false && "This device does not support hooking escape.");
-}
-
-void SCA_IInputDevice::ClearStatusTable(int tableid)
-{
- for (int i=0;i<SCA_IInputDevice::KX_MAX_KEYS;i++)
- m_eventStatusTables[tableid][i]=SCA_InputEvent(SCA_InputEvent::KX_NO_INPUTSTATUS,0);
-}
-
-
-
-const SCA_InputEvent& SCA_IInputDevice::GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)
-{
-// cerr << "SCA_IInputDevice::GetEventValue" << endl;
- return m_eventStatusTables[m_currentTable][inputcode];
-}
-
-
-
-int SCA_IInputDevice::GetNumActiveEvents()
-{
- int num = 0;
-
- // cerr << "SCA_IInputDevice::GetNumActiveEvents" << endl;
-
- for (int i=0;i<SCA_IInputDevice::KX_MAX_KEYS;i++)
- {
- const SCA_InputEvent& event = m_eventStatusTables[m_currentTable][i];
- if ((event.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
- || (event.m_status == SCA_InputEvent::KX_ACTIVE))
- num++;
- }
-
- return num;
-}
-
-
-
-int SCA_IInputDevice::GetNumJustEvents()
-{
- int num = 0;
-
- // cerr << "SCA_IInputDevice::GetNumJustEvents" << endl;
-
- for (int i=0;i<SCA_IInputDevice::KX_MAX_KEYS;i++)
- {
- const SCA_InputEvent& event = m_eventStatusTables[m_currentTable][i];
- if ((event.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
- || (event.m_status == SCA_InputEvent::KX_JUSTRELEASED))
- num++;
- }
-
- return num;
-}
-
-
-
-void SCA_IInputDevice::NextFrame()
-{
- m_currentTable = 1 - m_currentTable;
-
- // cerr << "SCA_IInputDevice::NextFrame " << GetNumActiveEvents() << endl;
-
- for (int i=0;i<SCA_IInputDevice::KX_MAX_KEYS;i++)
- {
- switch (m_eventStatusTables[1 - m_currentTable][i].m_status)
- {
- case SCA_InputEvent::KX_NO_INPUTSTATUS:
- m_eventStatusTables[m_currentTable][i]
- = SCA_InputEvent(SCA_InputEvent::KX_NO_INPUTSTATUS, 1);
- break;
- case SCA_InputEvent::KX_JUSTACTIVATED:
- m_eventStatusTables[m_currentTable][i]
- = SCA_InputEvent(SCA_InputEvent::KX_ACTIVE, 1);
- break;
- case SCA_InputEvent::KX_ACTIVE:
- m_eventStatusTables[m_currentTable][i]
- = SCA_InputEvent(SCA_InputEvent::KX_ACTIVE, 1);
- break;
- case SCA_InputEvent::KX_JUSTRELEASED:
- m_eventStatusTables[m_currentTable][i]
- = SCA_InputEvent(SCA_InputEvent::KX_NO_INPUTSTATUS, 1);
- break;
- default:
- ; /* error */
- }
- }
-}
diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h
deleted file mode 100644
index f306ae4f26b..00000000000
--- a/source/gameengine/GameLogic/SCA_IInputDevice.h
+++ /dev/null
@@ -1,334 +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 SCA_IInputDevice.h
- * \ingroup gamelogic
- * \brief Interface for input devices. The defines for keyboard/system/mouse events
- * here are for internal use in the KX module.
- *
- */
-
-#ifndef __SCA_IINPUTDEVICE_H__
-#define __SCA_IINPUTDEVICE_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class SCA_InputEvent
-{
-
-public:
- enum SCA_EnumInputs {
-
- KX_NO_INPUTSTATUS = 0,
- KX_JUSTACTIVATED,
- KX_ACTIVE,
- KX_JUSTRELEASED,
- };
-
- SCA_InputEvent(SCA_EnumInputs status=KX_NO_INPUTSTATUS,int eventval=0, int unicode=0)
- : m_status(status),
- m_eventval(eventval),
- m_unicode(unicode)
- {
-
- }
-
- SCA_EnumInputs m_status;
- int m_eventval;
- unsigned int m_unicode;
-};
-
-/* Originally from wm_event_types.h, now only used by GameEngine */
-#define MOUSEX MOUSEMOVE
-#define MOUSEY ACTIONMOUSE
-
-class SCA_IInputDevice
-{
-
-
-public:
-
- SCA_IInputDevice();
- virtual ~SCA_IInputDevice();
-
- enum KX_EnumInputs {
-
- KX_NOKEY = 0,
-
- // TIMERS
-
- KX_TIMER0,
- KX_TIMER1,
- KX_TIMER2,
-
- // SYSTEM
-
- /* Moved to avoid clashes with KX_RETKEY */
- KX_KEYBD,
- KX_RAWKEYBD,
- KX_REDRAW,
- KX_INPUTCHANGE,
- KX_QFULL,
- KX_WINFREEZE,
- KX_WINTHAW,
- /* thaw is 11 */
-
- /* move past retkey*/
- KX_WINCLOSE = 14,
- KX_WINQUIT,
- KX_Q_FIRSTTIME,
- /* sequence ends on 16 */
-
- // standard keyboard
-
- /* Because of the above preamble, KX_BEGINKEY is 15 ! This
- * means that KX_RETKEY on 13d (0Dh)) will double up with
- * KX_WINQUIT! Why is it 13? Because ascii 13d is Ctrl-M aka
- * CR! Its little brother, LF has 10d (0Ah). This is
- * dangerous, since the keyboards start scanning at
- * KX_BEGINKEY. I think the keyboard system should push its
- * key events instead of demanding the user to poll the
- * table... But that's for another time... The fix for now is
- * to move the above system events into a 'safe' (ie. unused)
- * range. I am loathe to move it away from this 'magical'
- * coincidence.. it's probably exploited somewhere. I hope the
- * close and quit events don't mess up 'normal' kb code
- * scanning.
- * */
- KX_BEGINKEY = 12,
-
- KX_RETKEY = 13,
- KX_SPACEKEY = 32,
- KX_PADASTERKEY = 42,
- KX_COMMAKEY = 44,
- KX_MINUSKEY = 45,
- KX_PERIODKEY = 46,
- KX_PLUSKEY = 47,
- KX_ZEROKEY = 48,
-
- KX_ONEKEY, // =49
- KX_TWOKEY,
- KX_THREEKEY,
- KX_FOURKEY,
- KX_FIVEKEY,
- KX_SIXKEY,
- KX_SEVENKEY,
- KX_EIGHTKEY,
- KX_NINEKEY, // = 57
-
- KX_AKEY = 97,
- KX_BKEY,
- KX_CKEY,
- KX_DKEY,
- KX_EKEY,
- KX_FKEY,
- KX_GKEY,
- KX_HKEY,
- KX_IKEY,
- KX_JKEY,
- KX_KKEY,
- KX_LKEY,
- KX_MKEY,
- KX_NKEY, // =110
- KX_OKEY,
- KX_PKEY,
- KX_QKEY,
- KX_RKEY,
- KX_SKEY,
- KX_TKEY,
- KX_UKEY,
- KX_VKEY,
- KX_WKEY,
- KX_XKEY, // =120
- KX_YKEY,
- KX_ZKEY, // =122
-
-
-
- KX_CAPSLOCKKEY, // 123
-
- KX_LEFTCTRLKEY, // 124
- KX_LEFTALTKEY,
- KX_RIGHTALTKEY,
- KX_RIGHTCTRLKEY,
- KX_RIGHTSHIFTKEY,
- KX_LEFTSHIFTKEY,// 129
-
- KX_ESCKEY, // 130
- KX_TABKEY, //131
-
-
- KX_LINEFEEDKEY, // 132
- KX_BACKSPACEKEY,
- KX_DELKEY,
- KX_SEMICOLONKEY, // 135
-
-
- KX_QUOTEKEY, //136
- KX_ACCENTGRAVEKEY, //137
-
- KX_SLASHKEY, //138
- KX_BACKSLASHKEY,
- KX_EQUALKEY,
- KX_LEFTBRACKETKEY,
- KX_RIGHTBRACKETKEY, // 142
-
- KX_LEFTARROWKEY, // 145
- KX_DOWNARROWKEY,
- KX_RIGHTARROWKEY,
- KX_UPARROWKEY, // 148
-
- KX_PAD2 ,
- KX_PAD4 ,
- KX_PAD6 ,
- KX_PAD8 ,
-
- KX_PAD1 ,
- KX_PAD3 ,
- KX_PAD5 ,
- KX_PAD7 ,
- KX_PAD9 ,
-
- KX_PADPERIOD,
- KX_PADSLASHKEY,
-
-
-
- KX_PAD0 ,
- KX_PADMINUS,
- KX_PADENTER,
- KX_PADPLUSKEY,
-
-
- KX_F1KEY ,
- KX_F2KEY ,
- KX_F3KEY ,
- KX_F4KEY ,
- KX_F5KEY ,
- KX_F6KEY ,
- KX_F7KEY ,
- KX_F8KEY ,
- KX_F9KEY ,
- KX_F10KEY,
- KX_F11KEY,
- KX_F12KEY,
- KX_F13KEY,
- KX_F14KEY,
- KX_F15KEY,
- KX_F16KEY,
- KX_F17KEY,
- KX_F18KEY,
- KX_F19KEY,
-
- KX_OSKEY,
-
- KX_PAUSEKEY,
- KX_INSERTKEY,
- KX_HOMEKEY ,
- KX_PAGEUPKEY,
- KX_PAGEDOWNKEY,
- KX_ENDKEY,
-
- // MOUSE
- KX_BEGINMOUSE,
-
- KX_BEGINMOUSEBUTTONS,
-
- KX_LEFTMOUSE,
- KX_MIDDLEMOUSE,
- KX_RIGHTMOUSE,
-
- KX_ENDMOUSEBUTTONS,
-
- KX_WHEELUPMOUSE,
- KX_WHEELDOWNMOUSE,
-
- KX_MOUSEX,
- KX_MOUSEY,
-
- KX_ENDMOUSE,
-
-
-
- KX_MAX_KEYS
-
- }; // enum
-
-
-protected:
- /**
- * m_eventStatusTables are two tables that contain current and previous
- * status of all events
- */
-
- SCA_InputEvent m_eventStatusTables[2][SCA_IInputDevice::KX_MAX_KEYS];
- /**
- * m_currentTable is index for m_keyStatusTable that toggle between 0 or 1
- */
- int m_currentTable;
- void ClearStatusTable(int tableid);
-
-public:
- virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
- virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode);
-
- /**
- * Count active events(active and just_activated)
- */
- virtual int GetNumActiveEvents();
-
- /**
- * Get the number of remapping events (just_activated, just_released)
- */
- virtual int GetNumJustEvents();
-
- virtual void HookEscape();
-
- /**
- * Next frame: we calculate the new key states. This goes as follows:
- *
- * KX_NO_INPUTSTATUS -> KX_NO_INPUTSTATUS
- * KX_JUSTACTIVATED -> KX_ACTIVE
- * KX_ACTIVE -> KX_ACTIVE
- * KX_JUSTRELEASED -> KX_NO_INPUTSTATUS
- *
- * Getting new events provides the
- * KX_NO_INPUTSTATUS->KX_JUSTACTIVATED and
- * KX_ACTIVE->KX_JUSTRELEASED transitions.
- */
- virtual void NextFrame();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_InputEvent")
-#endif
-};
-
-#endif /* __SCA_IINPUTDEVICE_H__ */
-
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
deleted file mode 100644
index d0a6e4540c9..00000000000
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
+++ /dev/null
@@ -1,271 +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/GameLogic/SCA_ILogicBrick.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include "SCA_ILogicBrick.h"
-#include "EXP_PyObjectPlus.h"
-
-SCA_ILogicBrick::SCA_ILogicBrick(SCA_IObject* gameobj)
- :
- CValue(),
- m_gameobj(gameobj),
- m_logicManager(NULL),
- m_Execute_Priority(0),
- m_Execute_Ueber_Priority(0),
- m_bActive(false),
- m_eventval(0)
-{
- m_text = "KX_LogicBrick";
-}
-
-
-
-SCA_ILogicBrick::~SCA_ILogicBrick()
-{
- RemoveEvent();
-}
-
-
-
-void SCA_ILogicBrick::SetExecutePriority(int execute_Priority)
-{
- m_Execute_Priority = execute_Priority;
-}
-
-
-
-void SCA_ILogicBrick::SetUeberExecutePriority(int execute_Priority)
-{
- m_Execute_Ueber_Priority = execute_Priority;
-}
-
-
-
-void SCA_ILogicBrick::ReParent(SCA_IObject* parent)
-{
- m_gameobj = parent;
-}
-
-void SCA_ILogicBrick::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- // nothing to do
-}
-
-CValue* SCA_ILogicBrick::Calc(VALUE_OPERATOR op, CValue *val)
-{
- CValue* temp = new CBoolValue(false,"");
- CValue* result = temp->Calc(op,val);
- temp->Release();
-
- return result;
-}
-
-
-
-CValue* SCA_ILogicBrick::CalcFinal(VALUE_DATA_TYPE dtype,
- VALUE_OPERATOR op,
- CValue *val)
-{
- // same as bool implementation, so...
- CValue* temp = new CBoolValue(false,"");
- CValue* result = temp->CalcFinal(dtype,op,val);
- temp->Release();
-
- return result;
-}
-
-
-
-const STR_String& SCA_ILogicBrick::GetText()
-{
- if (m_name.Length())
- return m_name;
-
- return m_text;
-}
-
-
-
-double SCA_ILogicBrick::GetNumber()
-{
- return -1;
-}
-
-
-
-STR_String& SCA_ILogicBrick::GetName()
-{
- return m_name;
-}
-
-
-
-void SCA_ILogicBrick::SetName(const char *name)
-{
- m_name = name;
-}
-
-bool SCA_ILogicBrick::LessComparedTo(SCA_ILogicBrick* other)
-{
- return (this->m_Execute_Ueber_Priority < other->m_Execute_Ueber_Priority)
- || ((this->m_Execute_Ueber_Priority == other->m_Execute_Ueber_Priority) &&
- (this->m_Execute_Priority < other->m_Execute_Priority));
-}
-
-void SCA_ILogicBrick::SetLogicManager(SCA_LogicManager *logicmgr)
-{
- m_logicManager = logicmgr;
-}
-
-SCA_LogicManager *SCA_ILogicBrick::GetLogicManager()
-{
- return m_logicManager;
-}
-
-void SCA_ILogicBrick::RegisterEvent(CValue* eventval)
-{
- if (m_eventval)
- m_eventval->Release();
-
- m_eventval = eventval->AddRef();
-}
-
-
-void SCA_ILogicBrick::RemoveEvent()
-{
- if (m_eventval)
- {
- m_eventval->Release();
- m_eventval = NULL;
- }
-}
-
-
-
-CValue* SCA_ILogicBrick::GetEvent()
-{
- if (m_eventval)
- {
- return m_eventval->AddRef();
- }
-
- return NULL;
-}
-
-
-
-#ifdef WITH_PYTHON
-
-/* python stuff */
-
-PyTypeObject SCA_ILogicBrick::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_ILogicBrick",
- 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,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_ILogicBrick::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_ILogicBrick::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("owner", SCA_ILogicBrick, pyattr_get_owner),
- KX_PYATTRIBUTE_INT_RW("executePriority",0,100000,false,SCA_ILogicBrick,m_Execute_Priority),
- KX_PYATTRIBUTE_STRING_RO("name", SCA_ILogicBrick, m_name),
- {NULL} //Sentinel
-};
-
-int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef)
-{
- if (attrdef->m_type != KX_PYATTRIBUTE_TYPE_STRING || attrdef->m_length != 1) {
- PyErr_SetString(PyExc_AttributeError, "inconsistent check function for attribute type, report to blender.org");
- return 1;
- }
- SCA_ILogicBrick* brick = reinterpret_cast<SCA_ILogicBrick*>(self);
- STR_String* var = reinterpret_cast<STR_String*>((char*)self+attrdef->m_offset);
- CValue* prop = brick->GetParent()->FindIdentifier(*var);
- bool error = prop->IsError();
- prop->Release();
- if (error) {
- PyErr_SetString(PyExc_ValueError, "string does not correspond to a property");
- return 1;
- }
- return 0;
-}
-
-/*Attribute functions */
-PyObject *SCA_ILogicBrick::pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_ILogicBrick* self = static_cast<SCA_ILogicBrick*>(self_v);
- CValue* parent = self->GetParent();
-
- if (parent)
- return parent->GetProxy();
-
- Py_RETURN_NONE;
-}
-
-
-
-/* Conversions for making life better. */
-bool SCA_ILogicBrick::PyArgToBool(int boolArg)
-{
- if (boolArg) {
- return true;
- } else {
- return false;
- }
-}
-
-PyObject *SCA_ILogicBrick::BoolToPyArg(bool boolarg)
-{
- return PyLong_FromLong(boolarg ? KX_TRUE: KX_FALSE);
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h
deleted file mode 100644
index f9ef18cc348..00000000000
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.h
+++ /dev/null
@@ -1,167 +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 SCA_ILogicBrick.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_ILOGICBRICK_H__
-#define __SCA_ILOGICBRICK_H__
-
-#include "EXP_Value.h"
-#include "SCA_IObject.h"
-#include "EXP_BoolValue.h"
-#include "CTR_Map.h"
-#include "CTR_HashedPtr.h"
-
-class NG_NetworkScene;
-class SCA_IScene;
-class SCA_LogicManager;
-
-class SCA_ILogicBrick : public CValue
-{
- Py_Header
-protected:
- SCA_IObject* m_gameobj;
- SCA_LogicManager *m_logicManager;
- int m_Execute_Priority;
- int m_Execute_Ueber_Priority;
-
- bool m_bActive;
- CValue* m_eventval;
- STR_String m_text;
- STR_String m_name;
- //unsigned long m_drawcolor;
- void RegisterEvent(CValue* eventval);
- void RemoveEvent();
- CValue* GetEvent();
-
-public:
- SCA_ILogicBrick(SCA_IObject* gameobj);
- virtual ~SCA_ILogicBrick();
-
- void SetExecutePriority(int execute_Priority);
- void SetUeberExecutePriority(int execute_Priority);
-
- SCA_IObject* GetParent() { return m_gameobj; }
-
- virtual void ReParent(SCA_IObject* parent);
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
- virtual void Delete() { Release(); }
-
- // act as a BoolValue (with value IsPositiveTrigger)
- virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
-
- virtual const STR_String & GetText();
- virtual double GetNumber();
- virtual STR_String& GetName();
- virtual void SetName(const char *);
-
- bool IsActive()
- {
- return m_bActive;
- }
-
- void SetActive(bool active)
- {
- m_bActive=active;
- }
-
- // insert in a QList at position corresponding to m_Execute_Priority
- void InsertActiveQList(SG_QList& head)
- {
- SG_QList::iterator<SCA_ILogicBrick> it(head);
- for (it.begin(); !it.end() && m_Execute_Priority > (*it)->m_Execute_Priority; ++it);
- it.add_back(this);
- }
-
- // insert in a QList at position corresponding to m_Execute_Priority
- // inside a longer list that contains elements of other objects.
- // Sorting is done only between the elements of the same object.
- // head is the head of the combined list
- // current points to the first element of the object in the list, NULL if none yet
- void InsertSelfActiveQList(SG_QList& head, SG_QList** current)
- {
- if (!*current)
- {
- // first element can be put anywhere
- head.QAddBack(this);
- *current = this;
- return;
- }
- // note: we assume current points actually to one o our element, skip the tests
- SG_QList::iterator<SCA_ILogicBrick> it(head,*current);
- if (m_Execute_Priority <= (*it)->m_Execute_Priority)
- {
- // this element comes before the first
- *current = this;
- }
- else {
- for (++it; !it.end() && (*it)->m_gameobj == m_gameobj && m_Execute_Priority > (*it)->m_Execute_Priority; ++it);
- }
- it.add_back(this);
- }
-
- virtual bool LessComparedTo(SCA_ILogicBrick* other);
-
- virtual void SetLogicManager(SCA_LogicManager *logicmgr);
- SCA_LogicManager *GetLogicManager();
-
- /* for moving logic bricks between scenes */
- virtual void Replace_IScene(SCA_IScene *val) {}
- virtual void Replace_NetworkScene(NG_NetworkScene *val) {}
-
-#ifdef WITH_PYTHON
- // python methods
-
- static PyObject* pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- // check that attribute is a property
- static int CheckProperty(void *self, const PyAttributeDef *attrdef);
-
- enum KX_BOOL_TYPE {
- KX_BOOL_NODEF = 0,
- KX_TRUE,
- KX_FALSE,
- KX_BOOL_MAX
- };
-
-
-protected:
- /* Some conversions to go with the bool type. */
- /** Convert a KX_TRUE, KX_FALSE in Python to a c++ value. */
- bool PyArgToBool(int boolArg);
-
- /** Convert a a c++ value to KX_TRUE, KX_FALSE in Python. */
- PyObject *BoolToPyArg(bool);
-
-#endif /* WITH_PYTHON */
-
-};
-
-#endif /* __SCA_ILOGICBRICK_H__ */
diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp
deleted file mode 100644
index 526e695e792..00000000000
--- a/source/gameengine/GameLogic/SCA_IObject.cpp
+++ /dev/null
@@ -1,349 +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/GameLogic/SCA_IObject.cpp
- * \ingroup gamelogic
- */
-
-#include <iostream>
-#include <algorithm>
-
-#include "SCA_IObject.h"
-#include "SCA_ISensor.h"
-#include "SCA_IController.h"
-#include "SCA_IActuator.h"
-#include "MT_Point3.h"
-#include "EXP_ListValue.h"
-
-MT_Point3 SCA_IObject::m_sDummy=MT_Point3(0,0,0);
-SG_QList SCA_IObject::m_activeBookmarkedControllers;
-
-SCA_IObject::SCA_IObject():
- CValue(),
- m_initState(0),
- m_state(0),
- m_firstState(NULL)
-{
- m_suspended = false;
-}
-
-SCA_IObject::~SCA_IObject()
-{
- SCA_SensorList::iterator its;
- for (its = m_sensors.begin(); !(its == m_sensors.end()); ++its)
- {
- //Use Delete for sensor to ensure proper cleaning
- (*its)->Delete();
- //((CValue*)(*its))->Release();
- }
- SCA_ControllerList::iterator itc;
- for (itc = m_controllers.begin(); !(itc == m_controllers.end()); ++itc)
- {
- //Use Delete for controller to ensure proper cleaning (expression controller)
- (*itc)->Delete();
- //((CValue*)(*itc))->Release();
- }
- SCA_ActuatorList::iterator ita;
- for (ita = m_registeredActuators.begin(); !(ita==m_registeredActuators.end()); ++ita)
- {
- (*ita)->UnlinkObject(this);
- }
- for (ita = m_actuators.begin(); !(ita==m_actuators.end()); ++ita)
- {
- (*ita)->Delete();
- }
-
- SCA_ObjectList::iterator ito;
- for (ito = m_registeredObjects.begin(); !(ito==m_registeredObjects.end()); ++ito)
- {
- (*ito)->UnlinkObject(this);
- }
-
- //T_InterpolatorList::iterator i;
- //for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- // delete *i;
- //}
-}
-
-void SCA_IObject::AddSensor(SCA_ISensor* act)
-{
- act->AddRef();
- m_sensors.push_back(act);
-}
-
-
-
-void SCA_IObject::AddController(SCA_IController* act)
-{
- act->AddRef();
- m_controllers.push_back(act);
-}
-
-
-
-void SCA_IObject::AddActuator(SCA_IActuator* act)
-{
- act->AddRef();
- m_actuators.push_back(act);
-}
-
-void SCA_IObject::RegisterActuator(SCA_IActuator* act)
-{
- // don't increase ref count, it would create dead lock
- m_registeredActuators.push_back(act);
-}
-
-void SCA_IObject::UnregisterActuator(SCA_IActuator* act)
-{
- SCA_ActuatorList::iterator ita;
- for (ita = m_registeredActuators.begin(); ita != m_registeredActuators.end(); ++ita)
- {
- if ((*ita) == act) {
- (*ita) = m_registeredActuators.back();
- m_registeredActuators.pop_back();
- break;
- }
- }
-}
-
-void SCA_IObject::RegisterObject(SCA_IObject* obj)
-{
- // one object may be registered multiple times via constraint target
- // store multiple reference, this will serve as registration counter
- m_registeredObjects.push_back(obj);
-}
-
-void SCA_IObject::UnregisterObject(SCA_IObject* obj)
-{
- SCA_ObjectList::iterator ito;
- for (ito = m_registeredObjects.begin(); ito != m_registeredObjects.end(); ++ito)
- {
- if ((*ito) == obj) {
- (*ito) = m_registeredObjects.back();
- m_registeredObjects.pop_back();
- break;
- }
- }
-}
-
-void SCA_IObject::ReParentLogic()
-{
- SCA_ActuatorList& oldactuators = GetActuators();
- int act = 0;
- SCA_ActuatorList::iterator ita;
- for (ita = oldactuators.begin(); !(ita==oldactuators.end()); ++ita)
- {
- SCA_IActuator* newactuator = (SCA_IActuator*) (*ita)->GetReplica();
- newactuator->ReParent(this);
- // actuators are initially not connected to any controller
- newactuator->SetActive(false);
- newactuator->ClrLink();
- oldactuators[act++] = newactuator;
- }
-
- SCA_ControllerList& oldcontrollers = GetControllers();
- int con = 0;
- SCA_ControllerList::iterator itc;
- for (itc = oldcontrollers.begin(); !(itc==oldcontrollers.end()); ++itc)
- {
- SCA_IController* newcontroller = (SCA_IController*)(*itc)->GetReplica();
- newcontroller->ReParent(this);
- newcontroller->SetActive(false);
- oldcontrollers[con++]=newcontroller;
-
- }
- // convert sensors last so that actuators are already available for Actuator sensor
- SCA_SensorList& oldsensors = GetSensors();
- int sen = 0;
- SCA_SensorList::iterator its;
- for (its = oldsensors.begin(); !(its==oldsensors.end()); ++its)
- {
- SCA_ISensor* newsensor = (SCA_ISensor*)(*its)->GetReplica();
- newsensor->ReParent(this);
- newsensor->SetActive(false);
- // sensors are initially not connected to any controller
- newsensor->ClrLink();
- oldsensors[sen++] = newsensor;
- }
-
- // a new object cannot be client of any actuator
- m_registeredActuators.clear();
- m_registeredObjects.clear();
-}
-
-
-
-SCA_ISensor* SCA_IObject::FindSensor(const STR_String& sensorname)
-{
- SCA_ISensor* foundsensor = NULL;
-
- for (SCA_SensorList::iterator its = m_sensors.begin();!(its==m_sensors.end());++its)
- {
- if ((*its)->GetName() == sensorname)
- {
- foundsensor = (*its);
- break;
- }
- }
- return foundsensor;
-}
-
-
-
-SCA_IController* SCA_IObject::FindController(const STR_String& controllername)
-{
- SCA_IController* foundcontroller = NULL;
-
- for (SCA_ControllerList::iterator itc = m_controllers.begin();!(itc==m_controllers.end());++itc)
- {
- if ((*itc)->GetName() == controllername)
- {
- foundcontroller = (*itc);
- break;
- }
- }
- return foundcontroller;
-}
-
-
-
-SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname)
-{
- SCA_IActuator* foundactuator = NULL;
-
- for (SCA_ActuatorList::iterator ita = m_actuators.begin();!(ita==m_actuators.end());++ita)
- {
- if ((*ita)->GetName() == actuatorname)
- {
- foundactuator = (*ita);
- break;
- }
- }
-
- return foundactuator;
-}
-
-
-void SCA_IObject::Suspend()
-{
- if ((!m_ignore_activity_culling)
- && (!m_suspended)) {
- m_suspended = true;
- /* flag suspend for all sensors */
- SCA_SensorList::iterator i = m_sensors.begin();
- while (i != m_sensors.end()) {
- (*i)->Suspend();
- ++i;
- }
- }
-}
-
-
-
-void SCA_IObject::Resume(void)
-{
- if (m_suspended) {
- m_suspended = false;
- /* unflag suspend for all sensors */
- SCA_SensorList::iterator i = m_sensors.begin();
- while (i != m_sensors.end()) {
- (*i)->Resume();
- ++i;
- }
- }
-}
-
-void SCA_IObject::SetState(unsigned int state)
-{
- unsigned int tmpstate;
- SCA_ControllerList::iterator contit;
-
- // we will update the state in two steps:
- // 1) set the new state bits that are 1
- // 2) clr the new state bits that are 0
- // This to ensure continuity if a sensor is attached to two states
- // that are switching state: no need to deactive and reactive the sensor
-
- tmpstate = m_state | state;
- if (tmpstate != m_state)
- {
- // update the status of the controllers
- for (contit = m_controllers.begin(); contit != m_controllers.end(); ++contit)
- {
- (*contit)->ApplyState(tmpstate);
- }
- }
- m_state = state;
- if (m_state != tmpstate)
- {
- for (contit = m_controllers.begin(); contit != m_controllers.end(); ++contit)
- {
- (*contit)->ApplyState(m_state);
- }
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_IObject::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_IObject",
- 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,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_IObject::Methods[] = {
- //{"setOrientation", (PyCFunction) SCA_IObject::sPySetOrientation, METH_VARARGS},
- //{"getOrientation", (PyCFunction) SCA_IObject::sPyGetOrientation, METH_VARARGS},
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_IObject::Attributes[] = {
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h
deleted file mode 100644
index 29a21fd8708..00000000000
--- a/source/gameengine/GameLogic/SCA_IObject.h
+++ /dev/null
@@ -1,229 +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 SCA_IObject.h
- * \ingroup gamelogic
- * \brief An abstract object that has some logic, python scripting and
- * reference counting Note: transformation stuff has been moved to
- * SceneGraph
- */
-
-#ifndef __SCA_IOBJECT_H__
-#define __SCA_IOBJECT_H__
-
-#include "EXP_Value.h"
-#include <vector>
-
-class SCA_IObject;
-class SCA_ISensor;
-class SCA_IController;
-class SCA_IActuator;
-
-#ifdef WITH_PYTHON
-template<class T> T PyVecTo(PyObject *);
-#endif
-
-typedef std::vector<SCA_ISensor *> SCA_SensorList;
-typedef std::vector<SCA_IController *> SCA_ControllerList;
-typedef std::vector<SCA_IActuator *> SCA_ActuatorList;
-typedef std::vector<SCA_IObject *> SCA_ObjectList;
-
-class SCA_IObject : public CValue
-{
-
- Py_Header
-
-protected:
- friend class KX_StateActuator;
- friend class SCA_IActuator;
- friend class SCA_IController;
- SCA_SensorList m_sensors;
- SCA_ControllerList m_controllers;
- SCA_ActuatorList m_actuators;
- SCA_ActuatorList m_registeredActuators; // actuators that use a pointer to this object
- SCA_ObjectList m_registeredObjects; // objects that hold reference to this object
-
- // SG_Dlist: element of objects with active actuators
- // Head: SCA_LogicManager::m_activeActuators
- // SG_QList: Head of active actuators list on this object
- // Elements: SCA_IActuator
- SG_QList m_activeActuators;
- // SG_Dlist: element of list os lists with active controllers
- // Head: SCA_LogicManager::m_activeControllers
- // SG_QList: Head of active controller list on this object
- // Elements: SCA_IController
- SG_QList m_activeControllers;
- // SG_Dlist: element of list of lists of active controllers
- // Head: SCA_LogicManager::m_activeControllers
- // SG_QList: Head of active bookmarked controller list globally
- // Elements: SCA_IController with bookmark option
- static SG_QList m_activeBookmarkedControllers;
-
- static class MT_Point3 m_sDummy;
-
- /**
- * Ignore activity culling requests?
- */
- bool m_ignore_activity_culling;
-
- /**
- * Ignore updates?
- */
- bool m_suspended;
-
- /**
- * init state of object (used when object is created)
- */
- unsigned int m_initState;
-
- /**
- * current state = bit mask of state that are active
- */
- unsigned int m_state;
-
- /**
- * pointer inside state actuator list for sorting
- */
- SG_QList* m_firstState;
-
-public:
-
- SCA_IObject();
- virtual ~SCA_IObject();
-
- SCA_ControllerList& GetControllers()
- {
- return m_controllers;
- }
- SCA_SensorList& GetSensors()
- {
- return m_sensors;
- }
- SCA_ActuatorList& GetActuators()
- {
- return m_actuators;
- }
- SG_QList& GetActiveActuators()
- {
- return m_activeActuators;
- }
-
- void AddSensor(SCA_ISensor* act);
- void ReserveSensor(int num)
- {
- m_sensors.reserve(num);
- }
- void AddController(SCA_IController* act);
- void ReserveController(int num)
- {
- m_controllers.reserve(num);
- }
- void AddActuator(SCA_IActuator* act);
- void ReserveActuator(int num)
- {
- m_actuators.reserve(num);
- }
- void RegisterActuator(SCA_IActuator* act);
- void UnregisterActuator(SCA_IActuator* act);
-
- void RegisterObject(SCA_IObject* objs);
- void UnregisterObject(SCA_IObject* objs);
- /**
- * UnlinkObject(...)
- * this object is informed that one of the object to which it holds a reference is deleted
- * returns true if there was indeed a reference.
- */
- virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; }
-
- SCA_ISensor* FindSensor(const STR_String& sensorname);
- SCA_IActuator* FindActuator(const STR_String& actuatorname);
- SCA_IController* FindController(const STR_String& controllername);
-
- void SetCurrentTime(float currentTime) {}
-
- virtual void ReParentLogic();
-
- /**
- * Set whether or not to ignore activity culling requests
- */
- void SetIgnoreActivityCulling(bool b)
- {
- m_ignore_activity_culling = b;
- }
-
- /**
- * Set whether or not this object wants to ignore activity culling
- * requests
- */
- bool GetIgnoreActivityCulling()
- {
- return m_ignore_activity_culling;
- }
-
- /**
- * Suspend all progress.
- */
- void Suspend(void);
-
- /**
- * Resume progress
- */
- void Resume(void);
-
- /**
- * Set init state
- */
- void SetInitState(unsigned int initState) { m_initState = initState; }
-
- /**
- * initialize the state when object is created
- */
- void ResetState(void) { SetState(m_initState); }
-
- /**
- * Set the object state
- */
- void SetState(unsigned int state);
-
- /**
- * Get the object state
- */
- unsigned int GetState(void) { return m_state; }
-
-// const class MT_Point3& ConvertPythonPylist(PyObject *pylist);
-
- virtual int GetGameObjectType() {return -1;}
-
- typedef enum ObjectTypes {
- OBJ_ARMATURE=0,
- OBJ_CAMERA=1,
- OBJ_LIGHT=2,
- OBJ_TEXT=3
- } ObjectTypes;
-
-};
-
-#endif /* __SCA_IOBJECT_H__ */
diff --git a/source/gameengine/GameLogic/SCA_IScene.cpp b/source/gameengine/GameLogic/SCA_IScene.cpp
deleted file mode 100644
index a4c905096d7..00000000000
--- a/source/gameengine/GameLogic/SCA_IScene.cpp
+++ /dev/null
@@ -1,145 +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/GameLogic/SCA_IScene.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_IScene.h"
-#include "EXP_Value.h"
-
-SCA_DebugProp::SCA_DebugProp(): m_obj(NULL)
-{
-}
-
-SCA_DebugProp::~SCA_DebugProp()
-{
- if (m_obj)
- m_obj->Release();
-}
-
-SCA_IScene::SCA_IScene()
-{
-}
-
-void SCA_IScene::RemoveAllDebugProperties()
-{
- for (std::vector<SCA_DebugProp*>::iterator it = m_debugList.begin();
- !(it==m_debugList.end());++it)
- {
- delete (*it);
- }
- m_debugList.clear();
-}
-
-
-SCA_IScene::~SCA_IScene()
-{
- RemoveAllDebugProperties();
-}
-
-
-std::vector<SCA_DebugProp*>& SCA_IScene::GetDebugProperties()
-{
- return m_debugList;
-}
-
-
-bool SCA_IScene::PropertyInDebugList( class CValue *gameobj, const STR_String &name )
-{
- for (std::vector<SCA_DebugProp*>::iterator it = m_debugList.begin();
- !(it==m_debugList.end());++it) {
- STR_String debugname = (*it)->m_name;
- CValue *debugobj = (*it)->m_obj;
-
- if (debugobj == gameobj && debugname == name)
- return true;
- }
- return false;
-}
-
-
-bool SCA_IScene::ObjectInDebugList( class CValue *gameobj )
-{
- for (std::vector<SCA_DebugProp*>::iterator it = m_debugList.begin();
- !(it==m_debugList.end());++it) {
- CValue* debugobj = (*it)->m_obj;
-
- if (debugobj == gameobj)
- return true;
- }
- return false;
-}
-
-
-void SCA_IScene::AddDebugProperty(class CValue* debugprop,
- const STR_String &name)
-{
- if (m_debugList.size() < DEBUG_MAX_DISPLAY) {
- SCA_DebugProp* dprop = new SCA_DebugProp();
- dprop->m_obj = debugprop;
- debugprop->AddRef();
- dprop->m_name = name;
- m_debugList.push_back(dprop);
- }
-}
-
-
-void SCA_IScene::RemoveDebugProperty(class CValue *gameobj,
- const STR_String &name)
-{
- vector<SCA_DebugProp*>::iterator it = m_debugList.begin();
- while (it != m_debugList.end()) {
- STR_String debugname = (*it)->m_name;
- CValue *debugobj = (*it)->m_obj;
-
- if (debugobj == gameobj && debugname == name) {
- delete (*it);
- m_debugList.erase(it);
- break;
- }
- ++it;
- }
-}
-
-
-void SCA_IScene::RemoveObjectDebugProperties(class CValue* gameobj)
-{
- vector<SCA_DebugProp*>::iterator it = m_debugList.begin();
- while (it != m_debugList.end()) {
- CValue* debugobj = (*it)->m_obj;
-
- if (debugobj == gameobj) {
- delete (*it);
- m_debugList.erase(it);
- continue;
- }
- ++it;
- }
-}
-
diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h
deleted file mode 100644
index b76b5636b13..00000000000
--- a/source/gameengine/GameLogic/SCA_IScene.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) 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 SCA_IScene.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_ISCENE_H__
-#define __SCA_ISCENE_H__
-
-#include <vector>
-
-#include "STR_String.h"
-#include "RAS_2DFilterManager.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-#define DEBUG_MAX_DISPLAY 100
-
-struct SCA_DebugProp
-{
- class CValue* m_obj;
- STR_String m_name;
- SCA_DebugProp();
- ~SCA_DebugProp();
-};
-
-class SCA_IScene
-{
- std::vector<SCA_DebugProp*> m_debugList;
-public:
- SCA_IScene();
- virtual ~SCA_IScene();
- virtual class SCA_IObject* AddReplicaObject(class CValue* gameobj,
- class CValue* locationobj,
- int lifespan=0)=0;
- virtual void RemoveObject(class CValue* gameobj)=0;
- virtual void DelayedRemoveObject(class CValue* gameobj)=0;
- //virtual void DelayedReleaseObject(class CValue* gameobj)=0;
-
- virtual void ReplaceMesh(class CValue* gameobj,
- void* meshobj, bool use_gfx, bool use_phys)=0;
- std::vector<SCA_DebugProp*>& GetDebugProperties();
- bool PropertyInDebugList(class CValue *gameobj, const STR_String &name);
- bool ObjectInDebugList(class CValue *gameobj);
- void RemoveAllDebugProperties();
- void AddDebugProperty(class CValue* debugprop, const STR_String &name);
- void RemoveDebugProperty(class CValue *gameobj, const STR_String &name);
- void RemoveObjectDebugProperties(class CValue* gameobj);
-
- virtual void Update2DFilter(std::vector<STR_String>& propNames, void* gameObj,
- RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode,
- int pass, STR_String& text) {}
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_IScene")
-#endif
-};
-
-#endif /* __SCA_ISCENE_H__ */
diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp
deleted file mode 100644
index 66dd69f93c4..00000000000
--- a/source/gameengine/GameLogic/SCA_ISensor.cpp
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Abstract class for sensor logic bricks
- *
- *
- * ***** 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/GameLogic/SCA_ISensor.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include "SCA_ISensor.h"
-#include "SCA_EventManager.h"
-#include "SCA_LogicManager.h"
-// needed for IsTriggered()
-#include "SCA_PythonController.h"
-
-#include <stdio.h>
-
-/* Native functions */
-void SCA_ISensor::ReParent(SCA_IObject* parent)
-{
- SCA_ILogicBrick::ReParent(parent);
- // will be done when the sensor is activated
- //m_eventmgr->RegisterSensor(this);
- //this->SetActive(false);
-}
-
-
-SCA_ISensor::SCA_ISensor(SCA_IObject* gameobj,
- class SCA_EventManager* eventmgr) :
- SCA_ILogicBrick(gameobj)
-{
- m_links = 0;
- m_suspended = false;
- m_invert = false;
- m_level = false;
- m_tap = false;
- m_reset = false;
- m_pos_ticks = 0;
- m_neg_ticks = 0;
- m_pos_pulsemode = false;
- m_neg_pulsemode = false;
- m_skipped_ticks = 0;
- m_state = false;
- m_prev_state = false;
-
- m_eventmgr = eventmgr;
-}
-
-
-SCA_ISensor::~SCA_ISensor()
-{
- // intentionally empty
-}
-
-void SCA_ISensor::ProcessReplica()
-{
- SCA_ILogicBrick::ProcessReplica();
- m_linkedcontrollers.clear();
-}
-
-bool SCA_ISensor::IsPositiveTrigger()
-{
- bool result = false;
-
- if (m_eventval) {
- result = (m_eventval->GetNumber() != 0.0);
- }
- if (m_invert) {
- result = !result;
- }
-
- return result;
-}
-
-void SCA_ISensor::SetPulseMode(bool posmode,
- bool negmode,
- int skippedticks)
-{
- m_pos_pulsemode = posmode;
- m_neg_pulsemode = negmode;
- m_skipped_ticks = skippedticks;
-}
-
-void SCA_ISensor::SetInvert(bool inv)
-{
- m_invert = inv;
-}
-
-void SCA_ISensor::SetLevel(bool lvl)
-{
- m_level = lvl;
-}
-
-void SCA_ISensor::SetTap(bool tap)
-{
- m_tap = tap;
-}
-
-
-double SCA_ISensor::GetNumber()
-{
- return GetState();
-}
-
-void SCA_ISensor::Suspend()
-{
- m_suspended = true;
-}
-
-bool SCA_ISensor::IsSuspended()
-{
- return m_suspended;
-}
-
-void SCA_ISensor::Resume()
-{
- m_suspended = false;
-}
-
-void SCA_ISensor::Init()
-{
- printf("Sensor %s has no init function, please report this bug to Blender.org\n", m_name.Ptr());
-}
-
-void SCA_ISensor::DecLink()
-{
- m_links--;
- if (m_links < 0)
- {
- printf("Warning: sensor %s has negative m_links: %d\n", m_name.Ptr(), m_links);
- m_links = 0;
- }
- if (!m_links)
- {
- // sensor is detached from all controllers, remove it from manager
- UnregisterToManager();
- }
-}
-
-void SCA_ISensor::RegisterToManager()
-{
- // sensor is just activated, initialize it
- Init();
- m_state = false;
- m_eventmgr->RegisterSensor(this);
-}
-
-void SCA_ISensor::Replace_EventManager(class SCA_LogicManager* logicmgr)
-{
- if (m_links) { /* true if we're used currently */
-
- m_eventmgr->RemoveSensor(this);
- m_eventmgr= logicmgr->FindEventManager(m_eventmgr->GetType());
- m_eventmgr->RegisterSensor(this);
- }
- else {
- m_eventmgr= logicmgr->FindEventManager(m_eventmgr->GetType());
- }
-}
-
-void SCA_ISensor::LinkToController(SCA_IController* controller)
-{
- m_linkedcontrollers.push_back(controller);
-}
-
-void SCA_ISensor::UnlinkController(SCA_IController* controller)
-{
- std::vector<class SCA_IController*>::iterator contit;
- for (contit = m_linkedcontrollers.begin();!(contit==m_linkedcontrollers.end());++contit)
- {
- if ((*contit) == controller)
- {
- *contit = m_linkedcontrollers.back();
- m_linkedcontrollers.pop_back();
- return;
- }
- }
- printf("Missing link from sensor %s:%s to controller %s:%s\n",
- m_gameobj->GetName().ReadPtr(), GetName().ReadPtr(),
- controller->GetParent()->GetName().ReadPtr(), controller->GetName().ReadPtr());
-}
-
-void SCA_ISensor::UnlinkAllControllers()
-{
- std::vector<class SCA_IController*>::iterator contit;
- for (contit = m_linkedcontrollers.begin();!(contit==m_linkedcontrollers.end());++contit)
- {
- (*contit)->UnlinkSensor(this);
- }
- m_linkedcontrollers.clear();
-}
-
-void SCA_ISensor::UnregisterToManager()
-{
- m_eventmgr->RemoveSensor(this);
- m_links = 0;
-}
-
-void SCA_ISensor::ActivateControllers(class SCA_LogicManager* logicmgr)
-{
- for (vector<SCA_IController*>::const_iterator c= m_linkedcontrollers.begin();
- c!=m_linkedcontrollers.end();++c)
- {
- SCA_IController* contr = *c;
- if (contr->IsActive())
- logicmgr->AddTriggeredController(contr, this);
- }
-}
-
-void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr)
-{
-
- // calculate if a __triggering__ is wanted
- // don't evaluate a sensor that is not connected to any controller
- if (m_links && !m_suspended) {
- bool result = this->Evaluate();
- // store the state for the rest of the logic system
- m_prev_state = m_state;
- m_state = this->IsPositiveTrigger();
- if (result) {
- // the sensor triggered this frame
- if (m_state || !m_tap) {
- ActivateControllers(logicmgr);
- // reset these counters so that pulse are synchronized with transition
- m_pos_ticks = 0;
- m_neg_ticks = 0;
- } else
- {
- result = false;
- }
- } else
- {
- /* First, the pulsing behavior, if pulse mode is
- * active. It seems something goes wrong if pulse mode is
- * not set :( */
- if (m_pos_pulsemode) {
- m_pos_ticks++;
- if (m_pos_ticks > m_skipped_ticks) {
- if ( m_state )
- {
- ActivateControllers(logicmgr);
- result = true;
- }
- m_pos_ticks = 0;
- }
- }
- // negative pulse doesn't make sense in tap mode, skip
- if (m_neg_pulsemode && !m_tap)
- {
- m_neg_ticks++;
- if (m_neg_ticks > m_skipped_ticks) {
- if (!m_state )
- {
- ActivateControllers(logicmgr);
- result = true;
- }
- m_neg_ticks = 0;
- }
- }
- }
- if (m_tap)
- {
- // in tap mode: we send always a negative pulse immediately after a positive pulse
- if (!result)
- {
- // the sensor did not trigger on this frame
- if (m_prev_state)
- {
- // but it triggered on previous frame => send a negative pulse
- ActivateControllers(logicmgr);
- result = true;
- }
- // in any case, absence of trigger means sensor off
- m_state = false;
- }
- }
- if (!result && m_level)
- {
- // This level sensor is connected to at least one controller that was just made
- // active but it did not generate an event yet, do it now to those controllers only
- for (vector<SCA_IController*>::const_iterator c= m_linkedcontrollers.begin();
- c!=m_linkedcontrollers.end();++c)
- {
- SCA_IController* contr = *c;
- if (contr->IsJustActivated())
- logicmgr->AddTriggeredController(contr, this);
- }
- }
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ----------------------------------------------- */
-/* Python Functions */
-/* ----------------------------------------------- */
-
-KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset,
-"reset()\n"
-"\tReset sensor internal state, effect depends on the type of sensor and settings.\n"
-"\tThe sensor is put in its initial state as if it was just activated.\n")
-{
- Init();
- m_prev_state = false;
- Py_RETURN_NONE;
-}
-
-/* ----------------------------------------------- */
-/* Python Integration Hooks */
-/* ----------------------------------------------- */
-
-PyTypeObject SCA_ISensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_ISensor",
- 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,
- &SCA_ILogicBrick::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_ISensor::Methods[] = {
- KX_PYMETHODTABLE_NOARGS(SCA_ISensor, reset),
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_ISensor::Attributes[] = {
- KX_PYATTRIBUTE_BOOL_RW("usePosPulseMode",SCA_ISensor,m_pos_pulsemode),
- KX_PYATTRIBUTE_BOOL_RW("useNegPulseMode",SCA_ISensor,m_neg_pulsemode),
- KX_PYATTRIBUTE_INT_RW("skippedTicks",0,100000,true,SCA_ISensor,m_skipped_ticks),
- KX_PYATTRIBUTE_BOOL_RW("invert",SCA_ISensor,m_invert),
- KX_PYATTRIBUTE_BOOL_RW_CHECK("level",SCA_ISensor,m_level,pyattr_check_level),
- KX_PYATTRIBUTE_BOOL_RW_CHECK("tap",SCA_ISensor,m_tap,pyattr_check_tap),
- KX_PYATTRIBUTE_RO_FUNCTION("triggered", SCA_ISensor, pyattr_get_triggered),
- KX_PYATTRIBUTE_RO_FUNCTION("positive", SCA_ISensor, pyattr_get_positive),
- KX_PYATTRIBUTE_RO_FUNCTION("status", SCA_ISensor, pyattr_get_status),
- KX_PYATTRIBUTE_RO_FUNCTION("pos_ticks", SCA_ISensor, pyattr_get_posTicks),
- KX_PYATTRIBUTE_RO_FUNCTION("neg_ticks", SCA_ISensor, pyattr_get_negTicks),
- KX_PYATTRIBUTE_RW_FUNCTION("frequency", SCA_ISensor, pyattr_get_frequency, pyattr_set_frequency),
- { NULL } //Sentinel
-};
-
-
-PyObject *SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v);
- bool retval = false;
- if (SCA_PythonController::m_sCurrentController)
- retval = SCA_PythonController::m_sCurrentController->IsTriggered(self);
- return PyBool_FromLong(retval);
-}
-
-PyObject *SCA_ISensor::pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v);
- return PyBool_FromLong(self->GetState());
-}
-
-PyObject *SCA_ISensor::pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v);
- int status = 0;
- if (self->GetState())
- {
- if (self->GetState() == self->GetPrevState())
- {
- status = 2;
- }
- else
- {
- status = 1;
- }
- }
- else if (self->GetState() != self->GetPrevState())
- {
- status = 3;
- }
- return PyLong_FromLong(status);
-}
-
-PyObject *SCA_ISensor::pyattr_get_posTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v);
- return PyLong_FromLong(self->GetPosTicks());
-}
-
-PyObject *SCA_ISensor::pyattr_get_negTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v);
- return PyLong_FromLong(self->GetNegTicks());
-}
-
-int SCA_ISensor::pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v);
- if (self->m_level)
- self->m_tap = false;
- return 0;
-}
-
-int SCA_ISensor::pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v);
- if (self->m_tap)
- self->m_level = false;
- return 0;
-}
-
-PyObject *SCA_ISensor::pyattr_get_frequency(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_ISensor *self = static_cast<SCA_ISensor*>(self_v);
- ShowDeprecationWarning("SCA_ISensor.frequency", "SCA_ISensor.skippedTicks");
- return PyLong_FromLong(self->m_skipped_ticks);
-}
-
-int SCA_ISensor::pyattr_set_frequency(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- SCA_ISensor *self = static_cast<SCA_ISensor*>(self_v);
- ShowDeprecationWarning("SCA_ISensor.frequency", "SCA_ISensor.skippedTicks");
- if (PyLong_Check(value)) {
- self->m_skipped_ticks = PyLong_AsLong(value);
- return PY_SET_ATTR_SUCCESS;
- }
- else {
- PyErr_SetString(PyExc_TypeError, "sensor.frequency = int: Sensor, expected an integer");
- return PY_SET_ATTR_FAIL;
- }
-}
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h
deleted file mode 100644
index 1e82f3ab11f..00000000000
--- a/source/gameengine/GameLogic/SCA_ISensor.h
+++ /dev/null
@@ -1,220 +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 SCA_ISensor.h
- * \ingroup gamelogic
- * \brief Interface Class for all logic Sensors. Implements
- * pulsemode and pulsefrequency, and event suppression.
- */
-
-#ifndef __SCA_ISENSOR_H__
-#define __SCA_ISENSOR_H__
-
-#include "SCA_IController.h"
-
-#include <vector>
-
-/**
- * Interface Class for all logic Sensors. Implements
- * pulsemode,pulsefrequency
- * Use of SG_DList element: link sensors to their respective event manager
- * Head: SCA_EventManager::m_sensors
- * Use of SG_QList element: not used
- */
-class SCA_ISensor : public SCA_ILogicBrick
-{
- Py_Header
-protected:
- class SCA_EventManager* m_eventmgr;
-
- /** Pulse positive pulses? */
- bool m_pos_pulsemode;
-
- /** Pulse negative pulses? */
- bool m_neg_pulsemode;
-
- /** Number of skipped ticks between two active pulses. */
- int m_skipped_ticks;
-
- /** Number of ticks since the last positive pulse. */
- int m_pos_ticks;
-
- /** Number of ticks since the last negative pulse. */
- int m_neg_ticks;
-
- /** invert the output signal*/
- bool m_invert;
-
- /** detect level instead of edge*/
- bool m_level;
-
- /** tap mode */
- bool m_tap;
-
- /** sensor has been reset */
- bool m_reset;
-
- /** Sensor must ignore updates? */
- bool m_suspended;
-
- /** number of connections to controller */
- int m_links;
-
- /** current sensor state */
- bool m_state;
-
- /** previous state (for tap option) */
- bool m_prev_state;
-
- std::vector<class SCA_IController*> m_linkedcontrollers;
-
-public:
-
- enum sensortype {
- ST_NONE = 0,
- ST_TOUCH,
- ST_NEAR,
- ST_RADAR,
- // to be updated as needed
- };
-
- SCA_ISensor(SCA_IObject* gameobj,
- class SCA_EventManager* eventmgr);
- ~SCA_ISensor();
- virtual void ReParent(SCA_IObject* parent);
-
- /** Because we want sensors to share some behavior, the Activate has */
- /* an implementation on this level. It requires an evaluate on the lower */
- /* level of individual sensors. Mapping the old activate()s is easy. */
- /* The IsPosTrig() also has to change, to keep things consistent. */
- void Activate(class SCA_LogicManager* logicmgr);
- virtual bool Evaluate() = 0;
- virtual bool IsPositiveTrigger();
- virtual void Init();
-
- virtual CValue* GetReplica()=0;
-
- /** Set parameters for the pulsing behavior.
- * \param posmode Trigger positive pulses?
- * \param negmode Trigger negative pulses?
- * \param freq Frequency to use when doing pulsing.
- */
- void SetPulseMode(bool posmode,
- bool negmode,
- int skippedticks);
-
- /** Set inversion of pulses on or off. */
- void SetInvert(bool inv);
- /** set the level detection on or off */
- void SetLevel(bool lvl);
- void SetTap(bool tap);
-
- virtual void RegisterToManager();
- virtual void UnregisterToManager();
- void Replace_EventManager(class SCA_LogicManager* logicmgr);
- void ReserveController(int num)
- {
- m_linkedcontrollers.reserve(num);
- }
- void LinkToController(SCA_IController* controller);
- void UnlinkController(SCA_IController* controller);
- void UnlinkAllControllers();
- void ActivateControllers(class SCA_LogicManager* logicmgr);
-
- virtual void ProcessReplica();
-
- virtual double GetNumber();
-
- virtual sensortype GetSensorType() { return ST_NONE; }
-
- /** Stop sensing for a while. */
- void Suspend();
-
- /** Is this sensor switched off? */
- bool IsSuspended();
-
- /** get the state of the sensor: positive or negative */
- bool GetState()
- {
- return m_state;
- }
-
- /** get the previous state of the sensor: positive or negative */
- bool GetPrevState()
- {
- return m_prev_state;
- }
-
- /** get the number of ticks since the last positive pulse */
- int GetPosTicks()
- {
- return m_pos_ticks;
- }
-
- /** get the number of ticks since the last negative pulse */
- int GetNegTicks()
- {
- return m_neg_ticks;
- }
-
- /** Resume sensing. */
- void Resume();
-
- void ClrLink()
- { m_links = 0; }
- void IncLink()
- { if (!m_links++) RegisterToManager(); }
- void DecLink();
- bool IsNoLink() const
- { return !m_links; }
-
-#ifdef WITH_PYTHON
- /* Python functions: */
- KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,reset);
-
- static PyObject* pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_posTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_negTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_frequency(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_frequency(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static int pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- enum SensorStatus {
- KX_SENSOR_INACTIVE = 0,
- KX_SENSOR_JUST_ACTIVATED,
- KX_SENSOR_ACTIVE,
- KX_SENSOR_JUST_DEACTIVATED
-
- };
-#endif /* WITH_PYTHON */
-};
-
-#endif /* __SCA_ISENSOR_H__ */
diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp
deleted file mode 100644
index 780e4e9ce88..00000000000
--- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp
+++ /dev/null
@@ -1,92 +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/GameLogic/SCA_JoystickManager.cpp
- * \ingroup gamelogic
- */
-
-#include "SCA_JoystickSensor.h"
-#include "SCA_JoystickManager.h"
-#include "SCA_LogicManager.h"
-//#include <vector>
-#include "SCA_ISensor.h"
-
-//using namespace std;
-
-
-SCA_JoystickManager::SCA_JoystickManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(logicmgr, JOY_EVENTMGR)
-{
- int i;
- for (i=0; i<JOYINDEX_MAX; i++) {
- m_joystick[i] = SCA_Joystick::GetInstance( i );
- }
-}
-
-
-SCA_JoystickManager::~SCA_JoystickManager()
-{
- int i;
- for (i=0; i<JOYINDEX_MAX; i++) {
- if (m_joystick[i])
- m_joystick[i]->ReleaseInstance();
- }
-}
-
-
-void SCA_JoystickManager::NextFrame(double curtime,double deltatime)
-{
- // We should always handle events in case we want to grab them with Python
-#ifdef WITH_SDL
- SCA_Joystick::HandleEvents(); /* Handle all SDL Joystick events */
-#endif
-
- if (m_sensors.Empty()) {
- return;
- }
- else {
- ;
- SG_DList::iterator<SCA_JoystickSensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- SCA_JoystickSensor* joysensor = *it;
- if (!joysensor->IsSuspended())
- {
- joysensor->Activate(m_logicmgr);
- }
- }
- }
-}
-
-
-SCA_Joystick *SCA_JoystickManager::GetJoystickDevice( short int joyindex)
-{
- /*
- *Return the instance of SCA_Joystick for use
- */
- return m_joystick[joyindex];
-}
diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h
deleted file mode 100644
index 60dcaea4ef2..00000000000
--- a/source/gameengine/GameLogic/SCA_JoystickManager.h
+++ /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 SCA_JoystickManager.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_JOYSTICKMANAGER_H__
-#define __SCA_JOYSTICKMANAGER_H__
-
-#include "SCA_EventManager.h"
-#include "Joystick/SCA_Joystick.h"
-#include <vector>
-
-using namespace std;
-class SCA_JoystickManager : public SCA_EventManager
-{
- /**
- * SDL Joystick Class Instance
- */
- SCA_Joystick *m_joystick[JOYINDEX_MAX];
-public:
- SCA_JoystickManager(class SCA_LogicManager* logicmgr);
- virtual ~SCA_JoystickManager();
- virtual void NextFrame(double curtime,double deltatime);
- SCA_Joystick* GetJoystickDevice(short int joyindex);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_JoystickManager")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
deleted file mode 100644
index 56df9692e72..00000000000
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ /dev/null
@@ -1,428 +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/GameLogic/SCA_JoystickSensor.cpp
- * \ingroup gamelogic
- */
-
-#include "SCA_JoystickManager.h"
-#include "SCA_JoystickSensor.h"
-
-#include "SCA_EventManager.h"
-#include "SCA_LogicManager.h"
-
-#include "EXP_PyObjectPlus.h"
-
-#include <stdio.h>
-#include <stddef.h>
-#include <iostream>
-
-
-
-SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr,
- SCA_IObject* gameobj,
- short int joyindex,
- short int joymode,
- int axis, int axisf,int prec,
- int button,
- int hat, int hatf, bool allevents)
- :SCA_ISensor(gameobj,eventmgr),
- m_axis(axis),
- m_axisf(axisf),
- m_button(button),
- m_hat(hat),
- m_hatf(hatf),
- m_precision(prec),
- m_joymode(joymode),
- m_joyindex(joyindex),
- m_bAllEvents(allevents)
-{
-/*
-std::cout << " axis " << m_axis << std::endl;
-std::cout << " axis flag " << m_axisf << std::endl;
-std::cout << " precision " << m_precision << std::endl;
-std::cout << " button " << m_button << std::endl;
-std::cout << " hat " << m_hat << std::endl;
-std::cout << " hat flag " << m_hatf << std::endl;
-*/
- Init();
-}
-
-void SCA_JoystickSensor::Init()
-{
- m_istrig=(m_invert)?1:0;
- m_istrig_prev=0;
- m_reset = true;
-}
-
-SCA_JoystickSensor::~SCA_JoystickSensor()
-{
-}
-
-
-CValue* SCA_JoystickSensor::GetReplica()
-{
- SCA_JoystickSensor* replica = new SCA_JoystickSensor(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
- replica->Init();
- return replica;
-}
-
-
-bool SCA_JoystickSensor::IsPositiveTrigger()
-{
- bool result = m_istrig;
- if (m_invert)
- result = !result;
- return result;
-}
-
-
-bool SCA_JoystickSensor::Evaluate()
-{
- SCA_Joystick *js = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex);
- bool result = false;
- bool reset = m_reset && m_level;
-
- if (js==NULL) /* no joystick - don't do anything */
- return false;
-
- m_reset = false;
-
- switch (m_joymode) {
- case KX_JOYSENSORMODE_AXIS:
- {
- /* what is what!
- * m_axisf == JOYAXIS_RIGHT, JOYAXIS_UP, JOYAXIS_DOWN, JOYAXIS_LEFT
- * m_axisf == 1 == up
- * m_axisf == 2 == left
- * m_axisf == 3 == down
- *
- * numberof== m_axis (1-4), range is half of JOYAXIS_MAX since
- * it assumes the axis joysticks are axis parirs (0,1), (2,3), etc
- * also note that this starts at 1 where functions its used
- * with expect a zero index.
- */
-
- if (!js->IsTrigAxis() && !reset) /* No events from SDL? - don't bother */
- return false;
-
- js->cSetPrecision(m_precision);
- if (m_bAllEvents) {
- if (js->aAxisPairIsPositive(m_axis-1)) { /* use zero based axis index internally */
- m_istrig = 1;
- result = true;
- }
- else {
- if (m_istrig) {
- m_istrig = 0;
- result = true;
- }
- }
- }
- else {
- if (js->aAxisPairDirectionIsPositive(m_axis-1, m_axisf)) { /* use zero based axis index internally */
- m_istrig = 1;
- result = true;
- }
- else {
- if (m_istrig) {
- m_istrig = 0;
- result = true;
- }
- }
- }
- break;
- }
- case KX_JOYSENSORMODE_AXIS_SINGLE:
- {
- /* Like KX_JOYSENSORMODE_AXIS but don't pair up axis */
- if (!js->IsTrigAxis() && !reset) /* No events from SDL? - don't bother */
- return false;
-
- /* No need for 'm_bAllEvents' check here since were only checking 1 axis */
- js->cSetPrecision(m_precision);
- if (js->aAxisIsPositive(m_axis-1)) { /* use zero based axis index internally */
- m_istrig = 1;
- result = true;
- }
- else {
- if (m_istrig) {
- m_istrig = 0;
- result = true;
- }
- }
- break;
- }
-
- case KX_JOYSENSORMODE_BUTTON:
- {
- /* what is what!
- * m_button = the actual button in question
- */
- if (!js->IsTrigButton() && !reset) /* No events from SDL? - don't bother */
- return false;
-
- if (( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) {
- m_istrig = 1;
- result = true;
- }
- else {
- if (m_istrig) {
- m_istrig = 0;
- result = true;
- }
- }
- break;
- }
- case KX_JOYSENSORMODE_HAT:
- {
- /* what is what!
- * numberof = m_hat -- max 4
- * direction= m_hatf -- max 12
- */
-
- if (!js->IsTrigHat() && !reset) /* No events from SDL? - don't bother */
- return false;
-
- if ((m_bAllEvents && js->GetHat(m_hat-1)) || js->aHatIsPositive(m_hat-1, m_hatf)) {
- m_istrig = 1;
- result = true;
- }
- else {
- if (m_istrig) {
- m_istrig = 0;
- result = true;
- }
- }
- break;
- }
- /* test for ball anyone ?*/
- default:
- printf("Error invalid switch statement\n");
- break;
- }
-
- /* if not all events are enabled, only send a positive pulse when
- * the button state changes */
- if (!m_bAllEvents) {
- if (m_istrig_prev == m_istrig) {
- result = false;
- }
- else {
- m_istrig_prev = m_istrig;
- }
- }
-
- if (reset)
- result = true;
-
- return result;
-}
-
-
-bool SCA_JoystickSensor::isValid(SCA_JoystickSensor::KX_JOYSENSORMODE m)
-{
- bool res = false;
- res = ((m > KX_JOYSENSORMODE_NODEF) && (m < KX_JOYSENSORMODE_MAX));
- return res;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_JoystickSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_JoystickSensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_JoystickSensor::Methods[] = {
- {"getButtonActiveList",(PyCFunction) SCA_JoystickSensor::sPyGetButtonActiveList, METH_NOARGS,(const char *)GetButtonActiveList_doc},
- {"getButtonStatus",(PyCFunction) SCA_JoystickSensor::sPyGetButtonStatus, METH_VARARGS,(const char *)GetButtonStatus_doc},
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_JoystickSensor::Attributes[] = {
- KX_PYATTRIBUTE_SHORT_RW("index",0,JOYINDEX_MAX-1,true,SCA_JoystickSensor,m_joyindex),
- KX_PYATTRIBUTE_INT_RW("threshold",0,32768,true,SCA_JoystickSensor,m_precision),
- KX_PYATTRIBUTE_INT_RW("button",0,100,false,SCA_JoystickSensor,m_button),
- KX_PYATTRIBUTE_INT_LIST_RW_CHECK("axis",0,3,true,SCA_JoystickSensor,m_axis,2,CheckAxis),
- KX_PYATTRIBUTE_INT_LIST_RW_CHECK("hat",0,12,true,SCA_JoystickSensor,m_hat,2,CheckHat),
- KX_PYATTRIBUTE_RO_FUNCTION("axisValues", SCA_JoystickSensor, pyattr_get_axis_values),
- KX_PYATTRIBUTE_RO_FUNCTION("axisSingle", SCA_JoystickSensor, pyattr_get_axis_single),
- KX_PYATTRIBUTE_RO_FUNCTION("hatValues", SCA_JoystickSensor, pyattr_get_hat_values),
- KX_PYATTRIBUTE_RO_FUNCTION("hatSingle", SCA_JoystickSensor, pyattr_get_hat_single),
- KX_PYATTRIBUTE_RO_FUNCTION("numAxis", SCA_JoystickSensor, pyattr_get_num_axis),
- KX_PYATTRIBUTE_RO_FUNCTION("numButtons", SCA_JoystickSensor, pyattr_get_num_buttons),
- KX_PYATTRIBUTE_RO_FUNCTION("numHats", SCA_JoystickSensor, pyattr_get_num_hats),
- KX_PYATTRIBUTE_RO_FUNCTION("connected", SCA_JoystickSensor, pyattr_get_connected),
- { NULL } //Sentinel
-};
-
-/* get button active list -------------------------------------------------- */
-const char SCA_JoystickSensor::GetButtonActiveList_doc[] =
-"getButtonActiveList\n"
-"\tReturns a list containing the indices of the button currently pressed.\n";
-PyObject *SCA_JoystickSensor::PyGetButtonActiveList( )
-{
- SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex);
- PyObject *ls = PyList_New(0);
- PyObject *value;
- int i;
-
- if (joy) {
- for (i=0; i < joy->GetNumberOfButtons(); i++) {
- if (joy->aButtonPressIsPositive(i)) {
- value = PyLong_FromLong(i);
- PyList_Append(ls, value);
- Py_DECREF(value);
- }
- }
- }
- return ls;
-}
-
-/* get button status -------------------------------------------------- */
-const char SCA_JoystickSensor::GetButtonStatus_doc[] =
-"getButtonStatus(buttonIndex)\n"
-"\tReturns a bool of the current pressed state of the specified button.\n";
-PyObject *SCA_JoystickSensor::PyGetButtonStatus( PyObject *args )
-{
- SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex);
- int index;
-
- if (!PyArg_ParseTuple(args, "i:getButtonStatus", &index)) {
- return NULL;
- }
- if (joy && index >= 0 && index < joy->GetNumberOfButtons()) {
- return PyBool_FromLong(joy->aButtonPressIsPositive(index) ? 1 : 0);
- }
- return PyBool_FromLong(0);
-}
-
-PyObject *SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
- SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
-
- int axis_index = (joy ? joy->GetNumberOfAxes() : 0);
- PyObject *list = PyList_New(axis_index);
-
- while (axis_index--) {
- PyList_SET_ITEM(list, axis_index, PyLong_FromLong(joy->GetAxisPosition(axis_index)));
- }
-
- return list;
-}
-
-PyObject *SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
- SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
-
- if (self->m_joymode != KX_JOYSENSORMODE_AXIS_SINGLE) {
- PyErr_SetString(PyExc_AttributeError, "val = sensor.axisSingle: Joystick Sensor, not 'Single Axis' type");
- return NULL;
- }
-
- return PyLong_FromLong(joy ? joy->GetAxisPosition(self->m_axis - 1) : 0);
-}
-
-PyObject *SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
- SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
-
- int hat_index = (joy ? joy->GetNumberOfHats() : 0);
- PyObject *list = PyList_New(hat_index);
-
- while (hat_index--) {
- PyList_SET_ITEM(list, hat_index, PyLong_FromLong(joy->GetHat(hat_index)));
- }
-
- return list;
-}
-
-PyObject *SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
- SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
-
- return PyLong_FromLong(joy ? joy->GetHat(self->m_hat - 1) : 0);
-}
-
-PyObject *SCA_JoystickSensor::pyattr_get_num_axis(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
- SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
- return PyLong_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
-}
-
-PyObject *SCA_JoystickSensor::pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
- SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
- return PyLong_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
-}
-
-PyObject *SCA_JoystickSensor::pyattr_get_num_hats(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
- SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
- return PyLong_FromLong( joy ? joy->GetNumberOfHats() : 0 );
-}
-
-PyObject *SCA_JoystickSensor::pyattr_get_connected(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v);
- SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
- return PyBool_FromLong( joy ? joy->Connected() : 0 );
-}
-
-#endif
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
deleted file mode 100644
index 6c6dc019a5e..00000000000
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ /dev/null
@@ -1,168 +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 SCA_JoystickSensor.h
- * \ingroup gamelogic
- */
-
-
-#ifndef __JOYSENSOR_H__
-#define __JOYSENSOR_H__
-
-#include "SCA_ISensor.h"
-#include "Joystick/SCA_JoystickDefines.h"
-
-class SCA_JoystickSensor :public SCA_ISensor
-{
- Py_Header
-
- /**
- * Axis 1-JOYAXIS_MAX, MUST be followed by m_axisf
- */
- int m_axis;
- /**
- * Axis flag to find direction, MUST be an int
- */
- int m_axisf;
- /**
- * The actual button
- */
- int m_button;
- /**
- * Flag for a pressed or released button
- */
- int m_buttonf;
- /**
- * The actual hat 1-JOYHAT_MAX. MUST be followed by m_hatf
- */
- int m_hat;
- /**
- * Flag to find direction 1-12, MUST be an int
- */
- int m_hatf;
- /**
- * The threshold value the axis acts upon
- */
- int m_precision;
- /**
- * Is an event triggered ?
- */
- bool m_istrig;
- /**
- * Last trigger state for this sensors joystick,
- * Otherwise it will trigger all the time
- * this is used to see if the trigger state changes.
- */
- bool m_istrig_prev;
- /**
- * The mode to determine axis,button or hat
- */
- short int m_joymode;
- /**
- * Select which joystick to use
- */
- short int m_joyindex;
-
- /**
- * Detect all events for the currently selected type
- */
- bool m_bAllEvents;
-
- enum KX_JOYSENSORMODE {
- KX_JOYSENSORMODE_NODEF = 0,
- KX_JOYSENSORMODE_AXIS,
- KX_JOYSENSORMODE_BUTTON,
- KX_JOYSENSORMODE_HAT,
- KX_JOYSENSORMODE_AXIS_SINGLE,
- KX_JOYSENSORMODE_MAX
- };
- bool isValid(KX_JOYSENSORMODE);
-
-public:
- SCA_JoystickSensor(class SCA_JoystickManager* eventmgr,
- SCA_IObject* gameobj,
- short int joyindex,
- short int joymode,
- int axis, int axisf,int prec,
- int button,
- int hat, int hatf, bool allevents);
- virtual ~SCA_JoystickSensor();
- virtual CValue* GetReplica();
-
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
- virtual void Init();
-
- short int GetJoyIndex(void) {
- return m_joyindex;
- }
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- /* Joystick Index */
- KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonActiveList)
- KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,GetButtonStatus)
-
- static PyObject* pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_hat_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_num_axis(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_num_hats(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_connected(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
-
- /* attribute check */
- static int CheckAxis(void *self, const PyAttributeDef*)
- {
- SCA_JoystickSensor* sensor = reinterpret_cast<SCA_JoystickSensor*>(self);
- if (sensor->m_axis < 1)
- sensor->m_axis = 1;
- else if (sensor->m_axis > JOYAXIS_MAX)
- sensor->m_axis = JOYAXIS_MAX;
- return 0;
- }
- static int CheckHat(void *self, const PyAttributeDef*)
- {
- SCA_JoystickSensor* sensor = reinterpret_cast<SCA_JoystickSensor*>(self);
- if (sensor->m_hat < 1)
- sensor->m_hat = 1;
- else if (sensor->m_hat > JOYHAT_MAX)
- sensor->m_hat = JOYHAT_MAX;
- return 0;
- }
-
-#endif /* WITH_PYTHON */
-
-};
-
-#endif /* __JOYSENSOR_H__ */
diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
deleted file mode 100644
index 778ba9e9a2c..00000000000
--- a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Manager for keyboard events
- *
- *
- * ***** 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/GameLogic/SCA_KeyboardManager.cpp
- * \ingroup gamelogic
- */
-
-
-#include "EXP_BoolValue.h"
-#include "SCA_KeyboardManager.h"
-#include "SCA_KeyboardSensor.h"
-#include "EXP_IntValue.h"
-#include <vector>
-
-SCA_KeyboardManager::SCA_KeyboardManager(SCA_LogicManager* logicmgr,
- SCA_IInputDevice* inputdev)
- : SCA_EventManager(logicmgr, KEYBOARD_EVENTMGR),
- m_inputDevice(inputdev)
-{
-}
-
-
-
-SCA_KeyboardManager::~SCA_KeyboardManager()
-{
-}
-
-
-
-SCA_IInputDevice* SCA_KeyboardManager::GetInputDevice()
-{
- return m_inputDevice;
-}
-
-
-
-void SCA_KeyboardManager::NextFrame()
-{
- //const SCA_InputEvent& event = GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
-// cerr << "SCA_KeyboardManager::NextFrame"<< endl;
- SG_DList::iterator<SCA_ISensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- (*it)->Activate(m_logicmgr);
- }
-}
-
-bool SCA_KeyboardManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
-{
- return false;
- //return m_kxsystem->IsPressed(inputcode);
-}
-
diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h
deleted file mode 100644
index cd1cbf4adee..00000000000
--- a/source/gameengine/GameLogic/SCA_KeyboardManager.h
+++ /dev/null
@@ -1,66 +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 SCA_KeyboardManager.h
- * \ingroup gamelogic
- * \brief Manager for keyboard events
- *
- */
-
-#ifndef __SCA_KEYBOARDMANAGER_H__
-#define __SCA_KEYBOARDMANAGER_H__
-
-
-#include "SCA_EventManager.h"
-
-#include <vector>
-
-using namespace std;
-
-#include "SCA_IInputDevice.h"
-
-
-class SCA_KeyboardManager : public SCA_EventManager
-{
- class SCA_IInputDevice* m_inputDevice;
-
-public:
- SCA_KeyboardManager(class SCA_LogicManager* logicmgr,class SCA_IInputDevice* inputdev);
- virtual ~SCA_KeyboardManager();
-
- bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
-
- virtual void NextFrame();
- SCA_IInputDevice* GetInputDevice();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_KeyboardManager")
-#endif
-};
-
-#endif /* __SCA_KEYBOARDMANAGER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
deleted file mode 100644
index 414a685d358..00000000000
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ /dev/null
@@ -1,668 +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 *****
- * Sensor for keyboard input
- */
-
-/** \file gameengine/GameLogic/SCA_KeyboardSensor.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include "SCA_KeyboardSensor.h"
-#include "SCA_KeyboardManager.h"
-#include "SCA_LogicManager.h"
-#include "EXP_StringValue.h"
-#include "SCA_IInputDevice.h"
-
-extern "C" {
- #include "BLI_string_utf8.h"
- #include "BLI_string_cursor_utf8.h"
-}
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_KeyboardSensor::SCA_KeyboardSensor(SCA_KeyboardManager* keybdmgr,
- short int hotkey,
- short int qual,
- short int qual2,
- bool bAllKeys,
- const STR_String& targetProp,
- const STR_String& toggleProp,
- SCA_IObject* gameobj,
- short int exitKey)
- :SCA_ISensor(gameobj,keybdmgr),
- m_hotkey(hotkey),
- m_qual(qual),
- m_qual2(qual2),
- m_bAllKeys(bAllKeys),
- m_targetprop(targetProp),
- m_toggleprop(toggleProp)
-{
- if (hotkey == exitKey)
- keybdmgr->GetInputDevice()->HookEscape();
-// SetDrawColor(0xff0000ff);
- Init();
-}
-
-
-
-SCA_KeyboardSensor::~SCA_KeyboardSensor()
-{
-}
-
-void SCA_KeyboardSensor::Init()
-{
- // this function is used when the sensor is disconnected from all controllers
- // by the state engine. It reinitializes the sensor as if it was just created.
- // However, if the target key is pressed when the sensor is reactivated, it
- // will not generated an event (see remark in Evaluate()).
- m_val = (m_invert)?1:0;
- m_reset = true;
-}
-
-CValue* SCA_KeyboardSensor::GetReplica()
-{
- SCA_KeyboardSensor* replica = new SCA_KeyboardSensor(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
- replica->Init();
- return replica;
-}
-
-
-
-short int SCA_KeyboardSensor::GetHotkey()
-{
- return m_hotkey;
-}
-
-
-
-bool SCA_KeyboardSensor::IsPositiveTrigger()
-{
- bool result = (m_val != 0);
-
- if (m_invert)
- result = !result;
-
- return result;
-}
-
-
-
-bool SCA_KeyboardSensor::TriggerOnAllKeys()
-{
- return m_bAllKeys;
-}
-
-
-
-bool SCA_KeyboardSensor::Evaluate()
-{
- bool result = false;
- bool reset = m_reset && m_level;
- bool qual = true;
- bool qual_change = false;
- short int m_val_orig = m_val;
-
- SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
- // cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n";
-
- /* See if we need to do logging: togPropState exists and is
- * different from 0 */
- CValue* myparent = GetParent();
- CValue* togPropState = myparent->GetProperty(m_toggleprop);
- if (togPropState &&
- (((int)togPropState->GetNumber()) != 0) )
- {
- LogKeystrokes();
- }
-
- m_reset = false;
-
- /* Now see whether events must be bounced. */
- if (m_bAllKeys)
- {
- bool justactivated = false;
- bool justreleased = false;
- bool active = false;
-
- for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++)
- {
- const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
- switch (inevent.m_status)
- {
- case SCA_InputEvent::KX_JUSTACTIVATED:
- justactivated = true;
- break;
- case SCA_InputEvent::KX_JUSTRELEASED:
- justreleased = true;
- break;
- case SCA_InputEvent::KX_ACTIVE:
- active = true;
- break;
- case SCA_InputEvent::KX_NO_INPUTSTATUS:
- /* do nothing */
- break;
- }
- }
-
- if (justactivated)
- {
- m_val=1;
- result = true;
- } else
- {
- if (justreleased)
- {
- m_val=(active)?1:0;
- result = true;
- } else
- {
- if (active)
- {
- if (m_val == 0)
- {
- m_val = 1;
- if (m_level) {
- result = true;
- }
- }
- } else
- {
- if (m_val == 1)
- {
- m_val = 0;
- result = true;
- }
- }
- }
- if (m_tap)
- // special case for tap mode: only generate event for new activation
- result = false;
- }
-
-
- } else
- {
-
- // cerr << "======= SCA_KeyboardSensor::Evaluate:: peeking at key status" << endl;
- const SCA_InputEvent & inevent = inputdev->GetEventValue(
- (SCA_IInputDevice::KX_EnumInputs) m_hotkey);
-
- // cerr << "======= SCA_KeyboardSensor::Evaluate:: status: " << inevent.m_status << endl;
-
-
- /* Check qualifier keys
- * - see if the qualifiers we request are pressed - 'qual' true/false
- * - see if the qualifiers we request changed their state - 'qual_change' true/false
- */
- if (m_qual > 0) {
- const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual);
- switch (qualevent.m_status) {
- case SCA_InputEvent::KX_NO_INPUTSTATUS:
- qual = false;
- break;
- case SCA_InputEvent::KX_JUSTRELEASED:
- qual_change = true;
- qual = false;
- break;
- case SCA_InputEvent::KX_JUSTACTIVATED:
- qual_change = true;
- case SCA_InputEvent::KX_ACTIVE:
- /* do nothing */
- break;
- }
- }
- if (m_qual2 > 0 && qual==true) {
- const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual2);
- /* copy of above */
- switch (qualevent.m_status) {
- case SCA_InputEvent::KX_NO_INPUTSTATUS:
- qual = false;
- break;
- case SCA_InputEvent::KX_JUSTRELEASED:
- qual_change = true;
- qual = false;
- break;
- case SCA_InputEvent::KX_JUSTACTIVATED:
- qual_change = true;
- case SCA_InputEvent::KX_ACTIVE:
- /* do nothing */
- break;
- }
- }
- /* done reading qualifiers */
-
- if (inevent.m_status == SCA_InputEvent::KX_NO_INPUTSTATUS)
- {
- if (m_val == 1)
- {
- // this situation may occur after a scene suspend: the keyboard release
- // event was not captured, produce now the event off
- m_val = 0;
- result = true;
- }
- } else
- {
- if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
- {
- m_val=1;
- result = true;
- } else
- {
- if (inevent.m_status == SCA_InputEvent::KX_JUSTRELEASED)
- {
- m_val = 0;
- result = true;
- } else
- {
- if (inevent.m_status == SCA_InputEvent::KX_ACTIVE)
- {
- if (m_val == 0)
- {
- m_val = 1;
- if (m_level)
- {
- result = true;
- }
- }
- }
- }
- }
- }
-
- /* Modify the key state based on qual(s)
- * Tested carefully. don't touch unless your really sure.
- * note, this will only change the results if key modifiers are set.
- *
- * When all modifiers and keys are positive
- * - pulse true
- *
- * When ANY of the modifiers or main key become inactive,
- * - pulse false
- */
- if (qual==false) { /* one of the qualifiers are not pressed */
- if (m_val_orig && qual_change) { /* we were originally enabled, but a qualifier changed */
- result = true;
- } else {
- result = false;
- }
- m_val = 0; /* since one of the qualifiers is not on, set the state to false */
- } else { /* we done have any qualifiers or they are all pressed */
- if (m_val && qual_change) { /* the main key state is true and our qualifier just changed */
- result = true;
- }
- }
- /* done with key quals */
-
- }
-
- if (reset)
- // force an event
- result = true;
- return result;
-
-}
-
-void SCA_KeyboardSensor::AddToTargetProp(int keyIndex, int unicode)
-{
- if (IsPrintable(keyIndex)) {
- CValue* tprop = GetParent()->GetProperty(m_targetprop);
-
- if (IsDelete(keyIndex)) {
- /* Make a new property. Deletes can be ignored. */
- if (tprop) {
- /* overwrite the old property */
- /* strip one char, if possible */
- STR_String newprop = tprop->GetText();
- int oldlength = newprop.Length();
- if (oldlength >= 1 ) {
- int newlength=oldlength;
-
- BLI_str_cursor_step_prev_utf8(newprop, newprop.Length(), &newlength);
- newprop.SetLength(newlength);
-
- CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
- GetParent()->SetProperty(m_targetprop, newstringprop);
- newstringprop->Release();
- }
- }
- }
- else {
- char utf8_buf[7];
- size_t utf8_len;
-
- utf8_len = BLI_str_utf8_from_unicode(unicode, utf8_buf);
- utf8_buf[utf8_len] = '\0';
-
- STR_String newprop = tprop ? (tprop->GetText() + utf8_buf) : utf8_buf;
-
- CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
- GetParent()->SetProperty(m_targetprop, newstringprop);
- newstringprop->Release();
- }
- }
-}
-
-/**
- * Tests whether shift is pressed
- */
-bool SCA_KeyboardSensor::IsShifted(void)
-{
- SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
-
- if ( (inputdev->GetEventValue(SCA_IInputDevice::KX_RIGHTSHIFTKEY).m_status
- == SCA_InputEvent::KX_ACTIVE)
- || (inputdev->GetEventValue(SCA_IInputDevice::KX_RIGHTSHIFTKEY).m_status
- == SCA_InputEvent::KX_JUSTACTIVATED)
- || (inputdev->GetEventValue(SCA_IInputDevice::KX_LEFTSHIFTKEY).m_status
- == SCA_InputEvent::KX_ACTIVE)
- || (inputdev->GetEventValue(SCA_IInputDevice::KX_LEFTSHIFTKEY).m_status
- == SCA_InputEvent::KX_JUSTACTIVATED)
- ) {
- return true;
- }
- else {
- return false;
- }
-}
-
-void SCA_KeyboardSensor::LogKeystrokes(void)
-{
- SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
- int num = inputdev->GetNumActiveEvents();
-
- /* weird loop, this one... */
- if (num > 0)
- {
-
- int index = 0;
- /* Check on all keys whether they were pushed. This does not
- * untangle the ordering, so don't type too fast :) */
- for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++)
- {
- const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
- if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED) //NO_INPUTSTATUS)
- {
- if (index < num)
- {
- AddToTargetProp(i, inevent.m_unicode);
- index++;
- }
- }
- }
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python Functions */
-/* ------------------------------------------------------------------------- */
-
-KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
-"getKeyStatus(keycode)\n"
-"\tGet the given key's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n")
-{
- if (!PyLong_Check(value)) {
- PyErr_SetString(PyExc_ValueError, "sensor.getKeyStatus(int): Keyboard Sensor, expected an int");
- return NULL;
- }
-
- SCA_IInputDevice::KX_EnumInputs keycode = (SCA_IInputDevice::KX_EnumInputs)PyLong_AsLong(value);
-
- if ((keycode < SCA_IInputDevice::KX_BEGINKEY) ||
- (keycode > SCA_IInputDevice::KX_ENDKEY))
- {
- PyErr_SetString(PyExc_AttributeError, "sensor.getKeyStatus(int): Keyboard Sensor, invalid keycode specified!");
- return NULL;
- }
-
- SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
- const SCA_InputEvent & inevent = inputdev->GetEventValue(keycode);
- return PyLong_FromLong(inevent.m_status);
-}
-
-/* ------------------------------------------------------------------------- */
-/* Python Integration Hooks */
-/* ------------------------------------------------------------------------- */
-
-PyTypeObject SCA_KeyboardSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_KeyboardSensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_KeyboardSensor::Methods[] = {
- KX_PYMETHODTABLE_O(SCA_KeyboardSensor, getKeyStatus),
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_KeyboardSensor, pyattr_get_events),
- KX_PYATTRIBUTE_BOOL_RW("useAllKeys",SCA_KeyboardSensor,m_bAllKeys),
- KX_PYATTRIBUTE_INT_RW("key",0,SCA_IInputDevice::KX_ENDKEY,true,SCA_KeyboardSensor,m_hotkey),
- KX_PYATTRIBUTE_SHORT_RW("hold1",0,SCA_IInputDevice::KX_ENDKEY,true,SCA_KeyboardSensor,m_qual),
- KX_PYATTRIBUTE_SHORT_RW("hold2",0,SCA_IInputDevice::KX_ENDKEY,true,SCA_KeyboardSensor,m_qual2),
- KX_PYATTRIBUTE_STRING_RW("toggleProperty",0,MAX_PROP_NAME,false,SCA_KeyboardSensor,m_toggleprop),
- KX_PYATTRIBUTE_STRING_RW("targetProperty",0,MAX_PROP_NAME,false,SCA_KeyboardSensor,m_targetprop),
- { NULL } //Sentinel
-};
-
-
-PyObject *SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_KeyboardSensor* self = static_cast<SCA_KeyboardSensor*>(self_v);
-
- SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)self->m_eventmgr)->GetInputDevice();
-
- PyObject *resultlist = PyList_New(0);
-
- for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++)
- {
- const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
- if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
- {
- PyObject *keypair = PyList_New(2);
- PyList_SET_ITEM(keypair,0,PyLong_FromLong(i));
- PyList_SET_ITEM(keypair,1,PyLong_FromLong(inevent.m_status));
- PyList_Append(resultlist,keypair);
- Py_DECREF(keypair);
- }
- }
- return resultlist;
-}
-
-#endif // WITH_PYTHON
-
-/* Accessed from python */
-
-// this code looks ugly, please use an ordinary hashtable
-
-char ToCharacter(int keyIndex, bool shifted)
-{
- /* numerals */
- if ( (keyIndex >= SCA_IInputDevice::KX_ZEROKEY)
- && (keyIndex <= SCA_IInputDevice::KX_NINEKEY) ) {
- if (shifted) {
- char numshift[] = ")!@#$%^&*(";
- return numshift[keyIndex - '0'];
- } else {
- return keyIndex - SCA_IInputDevice::KX_ZEROKEY + '0';
- }
- }
-
- /* letters... always lowercase... is that desirable? */
- if ( (keyIndex >= SCA_IInputDevice::KX_AKEY)
- && (keyIndex <= SCA_IInputDevice::KX_ZKEY) ) {
- if (shifted) {
- return keyIndex - SCA_IInputDevice::KX_AKEY + 'A';
- } else {
- return keyIndex - SCA_IInputDevice::KX_AKEY + 'a';
- }
- }
-
- if (keyIndex == SCA_IInputDevice::KX_SPACEKEY) {
- return ' ';
- }
- if (keyIndex == SCA_IInputDevice::KX_RETKEY || keyIndex == SCA_IInputDevice::KX_PADENTER) {
- return '\n';
- }
-
-
- if (keyIndex == SCA_IInputDevice::KX_PADASTERKEY) {
- return '*';
- }
-
- if (keyIndex == SCA_IInputDevice::KX_TABKEY) {
- return '\t';
- }
-
- /* comma to period */
- char commatoperiod[] = ",-.";
- char commatoperiodshifted[] = "<_>";
- if (keyIndex == SCA_IInputDevice::KX_COMMAKEY) {
- if (shifted) {
- return commatoperiodshifted[0];
- } else {
- return commatoperiod[0];
- }
- }
- if (keyIndex == SCA_IInputDevice::KX_MINUSKEY) {
- if (shifted) {
- return commatoperiodshifted[1];
- } else {
- return commatoperiod[1];
- }
- }
- if (keyIndex == SCA_IInputDevice::KX_PERIODKEY) {
- if (shifted) {
- return commatoperiodshifted[2];
- } else {
- return commatoperiod[2];
- }
- }
-
- /* semicolon to rightbracket */
- char semicolontorightbracket[] = ";\'`/\\=[]";
- char semicolontorightbracketshifted[] = ":\"~\?|+{}";
- if ((keyIndex >= SCA_IInputDevice::KX_SEMICOLONKEY)
- && (keyIndex <= SCA_IInputDevice::KX_RIGHTBRACKETKEY)) {
- if (shifted) {
- return semicolontorightbracketshifted[keyIndex - SCA_IInputDevice::KX_SEMICOLONKEY];
- } else {
- return semicolontorightbracket[keyIndex - SCA_IInputDevice::KX_SEMICOLONKEY];
- }
- }
-
- /* keypad2 to padplus */
- char pad2topadplus[] = "246813579. 0- +";
- if ((keyIndex >= SCA_IInputDevice::KX_PAD2)
- && (keyIndex <= SCA_IInputDevice::KX_PADPLUSKEY)) {
- return pad2topadplus[keyIndex - SCA_IInputDevice::KX_PAD2];
- }
-
- return '!';
-}
-
-
-
-/**
- * Determine whether this character can be printed. We cannot use
- * the library functions here, because we need to test our own
- * keycodes. */
-bool IsPrintable(int keyIndex)
-{
- /* only print
- * - numerals: KX_ZEROKEY to KX_NINEKEY
- * - alphas: KX_AKEY to KX_ZKEY.
- * - specials: KX_RETKEY, KX_PADASTERKEY, KX_PADCOMMAKEY to KX_PERIODKEY,
- * KX_TABKEY, KX_SEMICOLONKEY to KX_RIGHTBRACKETKEY,
- * KX_PAD2 to KX_PADPLUSKEY
- * - delete and backspace: also printable in the sense that they modify
- * the string
- * - retkey: should this be printable?
- * - virgule: prints a space... don't know which key that's supposed
- * to be...
- */
- if ( ((keyIndex >= SCA_IInputDevice::KX_ZEROKEY)
- && (keyIndex <= SCA_IInputDevice::KX_NINEKEY))
- || ((keyIndex >= SCA_IInputDevice::KX_AKEY)
- && (keyIndex <= SCA_IInputDevice::KX_ZKEY))
- || (keyIndex == SCA_IInputDevice::KX_SPACEKEY)
- || (keyIndex == SCA_IInputDevice::KX_RETKEY)
- || (keyIndex == SCA_IInputDevice::KX_PADENTER)
- || (keyIndex == SCA_IInputDevice::KX_PADASTERKEY)
- || (keyIndex == SCA_IInputDevice::KX_TABKEY)
- || ((keyIndex >= SCA_IInputDevice::KX_COMMAKEY)
- && (keyIndex <= SCA_IInputDevice::KX_PERIODKEY))
- || ((keyIndex >= SCA_IInputDevice::KX_SEMICOLONKEY)
- && (keyIndex <= SCA_IInputDevice::KX_RIGHTBRACKETKEY))
- || ((keyIndex >= SCA_IInputDevice::KX_PAD2)
- && (keyIndex <= SCA_IInputDevice::KX_PADPLUSKEY))
- || (keyIndex == SCA_IInputDevice::KX_DELKEY)
- || (keyIndex == SCA_IInputDevice::KX_BACKSPACEKEY)
- )
- {
- return true;
- } else {
- return false;
- }
-}
-
-/**
- * Tests whether this is a delete key.
- */
-bool IsDelete(int keyIndex)
-{
- if ( (keyIndex == SCA_IInputDevice::KX_DELKEY)
- || (keyIndex == SCA_IInputDevice::KX_BACKSPACEKEY) ) {
- return true;
- } else {
- return false;
- }
-}
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
deleted file mode 100644
index 51d7756bd1f..00000000000
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h
+++ /dev/null
@@ -1,141 +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 SCA_KeyboardSensor.h
- * \ingroup gamelogic
- * \brief Sensor for keyboard input
- */
-
-#ifndef __SCA_KEYBOARDSENSOR_H__
-#define __SCA_KEYBOARDSENSOR_H__
-
-#include "SCA_ISensor.h"
-#include "EXP_BoolValue.h"
-#include <list>
-
-/**
- * The keyboard sensor listens to the keyboard, and passes on events
- * on selected keystrokes. It has an alternate mode in which it logs
- * keypresses to a property. Note that these modes are not mutually
- * exclusive. */
-class SCA_KeyboardSensor : public SCA_ISensor
-{
- Py_Header
-
- /**
- * the key this sensor is sensing for
- */
- int m_hotkey;
- short int m_qual,m_qual2;
- short int m_val;
- /**
- * If this toggle is true, all incoming key events generate a
- * response.
- */
- bool m_bAllKeys;
-
- /**
- * The name of the property to which logged text is appended. If
- * this property is not defined, no logging takes place.
- */
- STR_String m_targetprop;
- /**
- * The property that indicates whether or not to log text when in
- * logging mode. If the property equals 0, no logging is done. For
- * all other values, logging is active. Logging can only become
- * active if there is a property to log to. Logging is independent
- * from hotkey settings. */
- STR_String m_toggleprop;
-
- /**
- * Log the keystrokes from the current input buffer.
- */
- void LogKeystrokes(void);
-
- /**
- * Adds this key-code to the target prop.
- */
- void AddToTargetProp(int keyIndex, int unicode);
-
- /**
- * Tests whether shift is pressed.
- */
- bool IsShifted(void);
-
-public:
- SCA_KeyboardSensor(class SCA_KeyboardManager* keybdmgr,
- short int hotkey,
- short int qual,
- short int qual2,
- bool bAllKeys,
- const STR_String& targetProp,
- const STR_String& toggleProp,
- SCA_IObject* gameobj,
- short int exitKey);
- virtual ~SCA_KeyboardSensor();
- virtual CValue* GetReplica();
- virtual void Init();
-
-
- short int GetHotkey();
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
- bool TriggerOnAllKeys();
-
-#ifdef WITH_PYTHON
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- // KeyEvents:
- KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,getEventList);
- // KeyStatus:
- KX_PYMETHOD_DOC_O(SCA_KeyboardSensor,getKeyStatus);
-
- static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-#endif
-};
-
-
-/**
- * Transform keycodes to something printable.
- */
-char ToCharacter(int keyIndex, bool shifted);
-
-/**
- * Determine whether this character can be printed. We cannot use
- * the library functions here, because we need to test our own
- * keycodes. */
-bool IsPrintable(int keyIndex);
-
-/**
- * Tests whether this is a delete key.
- */
-bool IsDelete(int keyIndex);
-
-
-#endif /* __SCA_KEYBOARDSENSOR_H__ */
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp
deleted file mode 100644
index 978f6d6b836..00000000000
--- a/source/gameengine/GameLogic/SCA_LogicManager.cpp
+++ /dev/null
@@ -1,342 +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 *****
- * Regulates the top-level logic behavior for one scene.
- */
-
-/** \file gameengine/GameLogic/SCA_LogicManager.cpp
- * \ingroup gamelogic
- */
-
-#include "EXP_Value.h"
-#include "SCA_LogicManager.h"
-#include "SCA_ISensor.h"
-#include "SCA_IController.h"
-#include "SCA_IActuator.h"
-#include "SCA_EventManager.h"
-#include "SCA_PythonController.h"
-#include <set>
-
-
-SCA_LogicManager::SCA_LogicManager()
-{
-}
-
-
-
-SCA_LogicManager::~SCA_LogicManager()
-{
- for (vector<SCA_EventManager*>::iterator it = m_eventmanagers.begin();!(it==m_eventmanagers.end());++it)
- {
- delete (*it);
- }
- m_eventmanagers.clear();
- assert(m_activeActuators.Empty());
-}
-
-#if 0
-// this kind of fixes bug 398 but breakes games, so better leave it out for now.
-// a removed object's gameobject (and logicbricks and stuff) didn't get released
-// because it was still in the m_mapStringToGameObjects map.
-void SCA_LogicManager::RemoveGameObject(const STR_String& gameobjname)
-{
- int numgameobj = m_mapStringToGameObjects.size();
- for (int i = 0; i < numgameobj; i++)
- {
- CValue** gameobjptr = m_mapStringToGameObjects.at(i);
- assert(gameobjptr);
-
- if (gameobjptr)
- {
- if ((*gameobjptr)->GetName() == gameobjname)
- (*gameobjptr)->Release();
- }
- }
-
- m_mapStringToGameObjects.remove(gameobjname);
-}
-#endif
-
-
-void SCA_LogicManager::RegisterEventManager(SCA_EventManager* eventmgr)
-{
- m_eventmanagers.push_back(eventmgr);
-}
-
-
-
-void SCA_LogicManager::RegisterGameObjectName(const STR_String& gameobjname,
- CValue* gameobj)
-{
- STR_HashedString mn = gameobjname;
- m_mapStringToGameObjects.insert(mn,gameobj);
-}
-
-
-
-void SCA_LogicManager::RegisterGameMeshName(const STR_String& gamemeshname, void* blendobj)
-{
- STR_HashedString mn = gamemeshname;
- m_map_gamemeshname_to_blendobj.insert(mn, blendobj);
-}
-
-
-
-void SCA_LogicManager::RegisterGameObj(void* blendobj, CValue* gameobj)
-{
- m_map_blendobj_to_gameobj.insert(CHashedPtr(blendobj), gameobj);
-}
-
-void SCA_LogicManager::UnregisterGameObj(void* blendobj, CValue* gameobj)
-{
- void **obp = m_map_blendobj_to_gameobj[CHashedPtr(blendobj)];
- if (obp && (CValue*)(*obp) == gameobj)
- m_map_blendobj_to_gameobj.remove(CHashedPtr(blendobj));
-}
-
-CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname)
-{
- STR_HashedString mn = gameobjname;
- CValue** gameptr = m_mapStringToGameObjects[mn];
-
- if (gameptr)
- return *gameptr;
-
- return NULL;
-}
-
-
-CValue* SCA_LogicManager::FindGameObjByBlendObj(void* blendobj)
-{
- void **obp= m_map_blendobj_to_gameobj[CHashedPtr(blendobj)];
- return obp?(CValue*)(*obp):NULL;
-}
-
-
-
-void* SCA_LogicManager::FindBlendObjByGameMeshName(const STR_String& gamemeshname)
-{
- STR_HashedString mn = gamemeshname;
- void **obp= m_map_gamemeshname_to_blendobj[mn];
- return obp?*obp:NULL;
-}
-
-
-
-void SCA_LogicManager::RemoveSensor(SCA_ISensor* sensor)
-{
- sensor->UnlinkAllControllers();
- sensor->UnregisterToManager();
-}
-
-void SCA_LogicManager::RemoveController(SCA_IController* controller)
-{
- controller->UnlinkAllSensors();
- controller->UnlinkAllActuators();
- controller->Deactivate();
-}
-
-
-void SCA_LogicManager::RemoveActuator(SCA_IActuator* actuator)
-{
- actuator->UnlinkAllControllers();
- actuator->Deactivate();
- actuator->SetActive(false);
-}
-
-
-
-void SCA_LogicManager::RegisterToSensor(SCA_IController* controller,SCA_ISensor* sensor)
-{
- sensor->LinkToController(controller);
- controller->LinkToSensor(sensor);
-}
-
-
-
-void SCA_LogicManager::RegisterToActuator(SCA_IController* controller,SCA_IActuator* actua)
-{
- actua->LinkToController(controller);
- controller->LinkToActuator(actua);
-}
-
-
-
-void SCA_LogicManager::BeginFrame(double curtime, double fixedtime)
-{
- for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin(); !(ie==m_eventmanagers.end()); ie++)
- (*ie)->NextFrame(curtime, fixedtime);
-
- for (SG_QList* obj = (SG_QList*)m_triggeredControllerSet.Remove();
- obj != NULL;
- obj = (SG_QList*)m_triggeredControllerSet.Remove())
- {
- for (SCA_IController* contr = (SCA_IController*)obj->QRemove();
- contr != NULL;
- contr = (SCA_IController*)obj->QRemove())
- {
- contr->Trigger(this);
- contr->ClrJustActivated();
- }
- }
-}
-
-
-
-void SCA_LogicManager::UpdateFrame(double curtime, bool frame)
-{
- for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin(); !(ie==m_eventmanagers.end()); ie++)
- (*ie)->UpdateFrame();
-
- SG_DList::iterator<SG_QList> io(m_activeActuators);
- for (io.begin(); !io.end(); )
- {
- SG_QList* ahead = *io;
- // increment now so that we can remove the current element
- ++io;
- SG_QList::iterator<SCA_IActuator> ia(*ahead);
- for (ia.begin(); !ia.end(); )
- {
- SCA_IActuator* actua = *ia;
- // increment first to allow removal of inactive actuators.
- ++ia;
- if (!actua->Update(curtime, frame))
- {
- // this actuator is not active anymore, remove
- actua->QDelink();
- actua->SetActive(false);
- } else if (actua->IsNoLink())
- {
- // This actuator has no more links but it still active
- // make sure it will get a negative event on next frame to stop it
- // Do this check after Update() rather than before to make sure
- // that all the actuators that are activated at same time than a state
- // actuator have a chance to execute.
- bool event = false;
- actua->RemoveAllEvents();
- actua->AddEvent(event);
- }
- }
- if (ahead->QEmpty())
- {
- // no more active controller, remove from main list
- ahead->Delink();
- }
- }
-}
-
-
-
-void *SCA_LogicManager::GetActionByName(const STR_String& actname)
-{
- STR_HashedString an = actname;
- void** actptr = m_mapStringToActions[an];
-
- if (actptr)
- return *actptr;
-
- return NULL;
-}
-
-
-
-void* SCA_LogicManager::GetMeshByName(const STR_String& meshname)
-{
- STR_HashedString mn = meshname;
- void** meshptr = m_mapStringToMeshes[mn];
-
- if (meshptr)
- return *meshptr;
-
- return NULL;
-}
-
-
-
-void SCA_LogicManager::RegisterMeshName(const STR_String& meshname,void* mesh)
-{
- STR_HashedString mn = meshname;
- m_mapStringToMeshes.insert(mn,mesh);
-}
-
-void SCA_LogicManager::UnregisterMeshName(const STR_String& meshname,void* mesh)
-{
- STR_HashedString mn = meshname;
- m_mapStringToMeshes.remove(mn);
-}
-
-
-void SCA_LogicManager::RegisterActionName(const STR_String& actname,void* action)
-{
- STR_HashedString an = actname;
- m_mapStringToActions.insert(an, action);
-}
-
-
-
-void SCA_LogicManager::EndFrame()
-{
- for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin();
- !(ie==m_eventmanagers.end());ie++)
- {
- (*ie)->EndFrame();
- }
-}
-
-
-void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor)
-{
- controller->Activate(m_triggeredControllerSet);
-
-#ifdef WITH_PYTHON
-
- // so that the controller knows which sensor has activited it
- // only needed for python controller
- // Note that this is safe even if the controller is subclassed.
- if (controller->GetType() == &SCA_PythonController::Type)
- {
- SCA_PythonController* pythonController = (SCA_PythonController*)controller;
- pythonController->AddTriggeredSensor(sensor);
- }
-#endif
-}
-
-SCA_EventManager* SCA_LogicManager::FindEventManager(int eventmgrtype)
-{
- // find an eventmanager of a certain type
- SCA_EventManager* eventmgr = NULL;
-
- for (vector<SCA_EventManager*>::const_iterator i=
- m_eventmanagers.begin();!(i==m_eventmanagers.end());i++)
- {
- SCA_EventManager* emgr = *i;
- if (emgr->GetType() == eventmgrtype)
- {
- eventmgr = emgr;
- break;
- }
- }
- return eventmgr;
-}
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h
deleted file mode 100644
index 7319bb537dd..00000000000
--- a/source/gameengine/GameLogic/SCA_LogicManager.h
+++ /dev/null
@@ -1,154 +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 SCA_LogicManager.h
- * \ingroup gamelogic
- * \brief Regulates the top-level logic behavior for one scene.
- */
-#ifndef __SCA_LOGICMANAGER_H__
-#define __SCA_LOGICMANAGER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include <vector>
-//#include "CTR_Map.h"
-#include <set>
-#include <map>
-#include <list>
-
-#include "CTR_Map.h"
-#include "STR_HashedString.h"
-#include "EXP_Value.h"
-#include "SG_QList.h"
-
-#include "EXP_HashedPtr.h"
-
-using namespace std;
-typedef std::list<class SCA_IController*> controllerlist;
-typedef std::map<class SCA_ISensor*,controllerlist > sensormap_t;
-
-/**
- * This manager handles sensor, controllers and actuators.
- * logic executes each frame the following way:
- * find triggering sensors
- * build list of controllers that are triggered by these triggering sensors
- * process all triggered controllers
- * during this phase actuators can be added to the active actuator list
- * process all active actuators
- * clear triggering sensors
- * clear triggered controllers
- * (actuators may be active during a longer timeframe)
- */
-
-#include "SCA_ILogicBrick.h"
-#include "SCA_IActuator.h"
-#include "SCA_EventManager.h"
-
-
-class SCA_LogicManager
-{
- vector<class SCA_EventManager*> m_eventmanagers;
-
- // SG_DList: Head of objects having activated actuators
- // element: SCA_IObject::m_activeActuators
- SG_DList m_activeActuators;
- // SG_DList: Head of objects having activated controllers
- // element: SCA_IObject::m_activeControllers
- SG_DList m_triggeredControllerSet;
-
- // need to find better way for this
- // also known as FactoryManager...
- CTR_Map<STR_HashedString,CValue*> m_mapStringToGameObjects;
- CTR_Map<STR_HashedString,void*> m_mapStringToMeshes;
- CTR_Map<STR_HashedString,void*> m_mapStringToActions;
-
- CTR_Map<STR_HashedString,void*> m_map_gamemeshname_to_blendobj;
- CTR_Map<CHashedPtr,void*> m_map_blendobj_to_gameobj;
-public:
- SCA_LogicManager();
- virtual ~SCA_LogicManager();
-
- //void SetKeyboardManager(SCA_KeyboardManager* keyboardmgr) { m_keyboardmgr=keyboardmgr;}
- void RegisterEventManager(SCA_EventManager* eventmgr);
- void RegisterToSensor(SCA_IController* controller,
- class SCA_ISensor* sensor);
- void RegisterToActuator(SCA_IController* controller,
- class SCA_IActuator* actuator);
-
- void BeginFrame(double curtime, double fixedtime);
- void UpdateFrame(double curtime, bool frame);
- void EndFrame();
- void AddActiveActuator(SCA_IActuator* actua,bool event)
- {
- actua->SetActive(true);
- actua->Activate(m_activeActuators);
- actua->AddEvent(event);
- }
-
- void AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor);
- SCA_EventManager* FindEventManager(int eventmgrtype);
- vector<class SCA_EventManager*> GetEventManagers() { return m_eventmanagers; }
-
- void RemoveGameObject(const STR_String& gameobjname);
-
- /**
- * remove Logic Bricks from the running logicmanager
- */
- void RemoveSensor(SCA_ISensor* sensor);
- void RemoveController(SCA_IController* controller);
- void RemoveActuator(SCA_IActuator* actuator);
-
-
- // for the scripting... needs a FactoryManager later (if we would have time... ;)
- void RegisterMeshName(const STR_String& meshname,void* mesh);
- void UnregisterMeshName(const STR_String& meshname,void* mesh);
- CTR_Map<STR_HashedString,void*>& GetMeshMap() { return m_mapStringToMeshes; }
- CTR_Map<STR_HashedString,void*>& GetActionMap() { return m_mapStringToActions; }
-
- void RegisterActionName(const STR_String& actname,void* action);
-
- void* GetActionByName (const STR_String& actname);
- void* GetMeshByName(const STR_String& meshname);
-
- void RegisterGameObjectName(const STR_String& gameobjname,CValue* gameobj);
- class CValue* GetGameObjectByName(const STR_String& gameobjname);
-
- void RegisterGameMeshName(const STR_String& gamemeshname, void* blendobj);
- void* FindBlendObjByGameMeshName(const STR_String& gamemeshname);
-
- void RegisterGameObj(void* blendobj, CValue* gameobj);
- void UnregisterGameObj(void* blendobj, CValue* gameobj);
- CValue* FindGameObjByBlendObj(void* blendobj);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_LogicManager")
-#endif
-};
-
-#endif /* __SCA_LOGICMANAGER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp
deleted file mode 100644
index 51c03d1e350..00000000000
--- a/source/gameengine/GameLogic/SCA_MouseManager.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Manager for mouse events
- *
- *
- *
- * ***** 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/GameLogic/SCA_MouseManager.cpp
- * \ingroup gamelogic
- */
-
-
-#ifdef _MSC_VER
- /* This warning tells us about truncation of __long__ stl-generated names.
- * It can occasionally cause DevStudio to have internal compiler warnings. */
-# pragma warning( disable:4786 )
-#endif
-
-#include "EXP_BoolValue.h"
-#include "SCA_MouseManager.h"
-#include "SCA_MouseSensor.h"
-#include "EXP_IntValue.h"
-#include "RAS_ICanvas.h"
-
-
-SCA_MouseManager::SCA_MouseManager(SCA_LogicManager* logicmgr,
- SCA_IInputDevice* mousedev,
- RAS_ICanvas* canvas)
- : SCA_EventManager(logicmgr, MOUSE_EVENTMGR),
- m_mousedevice (mousedev),
- m_canvas(canvas)
-{
- m_xpos = 0;
- m_ypos = 0;
-}
-
-
-
-SCA_MouseManager::~SCA_MouseManager()
-{
-}
-
-
-
-SCA_IInputDevice* SCA_MouseManager::GetInputDevice()
-{
- return m_mousedevice;
-}
-
-
-
-void SCA_MouseManager::NextFrame()
-{
- if (m_mousedevice)
- {
- SG_DList::iterator<SCA_ISensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- SCA_MouseSensor* mousesensor = (SCA_MouseSensor*)(*it);
- // (0,0) is the Upper Left corner in our local window
- // coordinates
- if (!mousesensor->IsSuspended())
- {
- const SCA_InputEvent& event1 =
- m_mousedevice->GetEventValue(SCA_IInputDevice::KX_MOUSEX);
- const SCA_InputEvent& event2 =
- m_mousedevice->GetEventValue(SCA_IInputDevice::KX_MOUSEY);
-
- int mx = this->m_canvas->GetMouseX(event1.m_eventval);
- int my = this->m_canvas->GetMouseY(event2.m_eventval);
-
- mousesensor->setX(mx);
- mousesensor->setY(my);
-
- mousesensor->Activate(m_logicmgr);
- }
- }
- }
-}
-
-bool SCA_MouseManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
-{
- /* We should guard for non-mouse events maybe? A rather silly side */
- /* effect here is that position-change events are considered presses as */
- /* well. */
-
- return m_mousedevice->IsPressed(inputcode);
-}
diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h
deleted file mode 100644
index a57e52070a7..00000000000
--- a/source/gameengine/GameLogic/SCA_MouseManager.h
+++ /dev/null
@@ -1,75 +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 SCA_MouseManager.h
- * \ingroup gamelogic
- * \brief Manager for mouse events.
- *
- */
-
-
-#ifndef __SCA_MOUSEMANAGER_H__
-#define __SCA_MOUSEMANAGER_H__
-
-
-#include "SCA_EventManager.h"
-
-#include <vector>
-
-using namespace std;
-
-#include "SCA_IInputDevice.h"
-
-
-class SCA_MouseManager : public SCA_EventManager
-{
-
- class SCA_IInputDevice* m_mousedevice;
- class RAS_ICanvas* m_canvas;
-
- unsigned short m_xpos; // Cached location of the mouse pointer
- unsigned short m_ypos;
-
-public:
- SCA_MouseManager(class SCA_LogicManager* logicmgr,class SCA_IInputDevice* mousedev, class RAS_ICanvas* canvas);
- virtual ~SCA_MouseManager();
-
- /**
- * Checks whether a mouse button is depressed. Ignores requests on non-
- * mouse related events. Can also flag mouse movement.
- */
- bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
- virtual void NextFrame();
- SCA_IInputDevice* GetInputDevice();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_MouseManager")
-#endif
-};
-
-#endif /* __SCA_MOUSEMANAGER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
deleted file mode 100644
index 2479e859dea..00000000000
--- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Sensor for mouse input
- *
- *
- *
- * ***** 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): José I. Romero (cleanup and fixes)
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/GameLogic/SCA_MouseSensor.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include "SCA_MouseSensor.h"
-#include "SCA_EventManager.h"
-#include "SCA_MouseManager.h"
-#include "SCA_LogicManager.h"
-#include "SCA_IInputDevice.h"
-#include "EXP_ConstExpr.h"
-#include <iostream>
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
- int startx,int starty,
- short int mousemode,
- SCA_IObject* gameobj)
- : SCA_ISensor(gameobj,eventmgr),
- m_x(startx),
- m_y(starty)
-{
- m_mousemode = mousemode;
- m_triggermode = true;
-
- UpdateHotkey(this);
- Init();
-}
-
-void SCA_MouseSensor::Init()
-{
- m_val = (m_invert)?1:0; /* stores the latest attribute */
- m_reset = true;
-}
-
-SCA_MouseSensor::~SCA_MouseSensor()
-{
- /* Nothing to be done here. */
-}
-
-void SCA_MouseSensor::UpdateHotkey(void *self)
-{
- // gosh, this function is so damn stupid
- // its here because of a design mistake in the mouse sensor, it should only
- // have 3 trigger modes (button, wheel, move), and let the user set the
- // hotkey separately, like the other sensors. but instead it has a mode for
- // each friggin key and i have to update the hotkey based on it... genius!
- SCA_MouseSensor* sensor = reinterpret_cast<SCA_MouseSensor*>(self);
-
- switch (sensor->m_mousemode) {
- case KX_MOUSESENSORMODE_LEFTBUTTON:
- sensor->m_hotkey = SCA_IInputDevice::KX_LEFTMOUSE;
- break;
- case KX_MOUSESENSORMODE_MIDDLEBUTTON:
- sensor->m_hotkey = SCA_IInputDevice::KX_MIDDLEMOUSE;
- break;
- case KX_MOUSESENSORMODE_RIGHTBUTTON:
- sensor->m_hotkey = SCA_IInputDevice::KX_RIGHTMOUSE;
- break;
- case KX_MOUSESENSORMODE_WHEELUP:
- sensor->m_hotkey = SCA_IInputDevice::KX_WHEELUPMOUSE;
- break;
- case KX_MOUSESENSORMODE_WHEELDOWN:
- sensor->m_hotkey = SCA_IInputDevice::KX_WHEELDOWNMOUSE;
- break;
- default:
- ; /* ignore, no hotkey */
- }
-}
-
-CValue* SCA_MouseSensor::GetReplica()
-{
- SCA_MouseSensor* replica = new SCA_MouseSensor(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
- replica->Init();
-
- return replica;
-}
-
-
-
-bool SCA_MouseSensor::IsPositiveTrigger()
-{
- bool result = (m_val != 0);
- if (m_invert)
- result = !result;
-
- return result;
-}
-
-
-
-short int SCA_MouseSensor::GetModeKey()
-{
- return m_mousemode;
-}
-
-
-
-SCA_IInputDevice::KX_EnumInputs SCA_MouseSensor::GetHotKey()
-{
- return m_hotkey;
-}
-
-
-
-bool SCA_MouseSensor::Evaluate()
-{
- bool result = false;
- bool reset = m_reset && m_level;
- SCA_IInputDevice* mousedev = ((SCA_MouseManager *)m_eventmgr)->GetInputDevice();
-
- m_reset = false;
- switch (m_mousemode) {
- case KX_MOUSESENSORMODE_LEFTBUTTON:
- case KX_MOUSESENSORMODE_MIDDLEBUTTON:
- case KX_MOUSESENSORMODE_RIGHTBUTTON:
- case KX_MOUSESENSORMODE_WHEELUP:
- case KX_MOUSESENSORMODE_WHEELDOWN:
- {
- const SCA_InputEvent& mevent = mousedev->GetEventValue(m_hotkey);
- switch (mevent.m_status) {
- case SCA_InputEvent::KX_JUSTACTIVATED:
- m_val = 1;
- result = true;
- break;
- case SCA_InputEvent::KX_JUSTRELEASED:
- m_val = 0;
- result = true;
- break;
- case SCA_InputEvent::KX_ACTIVE:
- if (m_val == 0)
- {
- m_val = 1;
- if (m_level)
- result = true;
- }
- break;
- default:
- if (m_val == 1)
- {
- m_val = 0;
- result = true;
- }
- break;
- }
- break;
- }
- case KX_MOUSESENSORMODE_MOVEMENT:
- {
- const SCA_InputEvent& eventX = mousedev->GetEventValue(SCA_IInputDevice::KX_MOUSEX);
- const SCA_InputEvent& eventY = mousedev->GetEventValue(SCA_IInputDevice::KX_MOUSEY);
-
- if (eventX.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- eventY.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- eventX.m_status == SCA_InputEvent::KX_ACTIVE ||
- eventY.m_status == SCA_InputEvent::KX_ACTIVE)
- {
- m_val = 1;
- result = true;
- }
- else if (eventX.m_status == SCA_InputEvent::KX_JUSTRELEASED ||
- eventY.m_status == SCA_InputEvent::KX_JUSTRELEASED )
- {
- m_val = 0;
- result = true;
- }
- else //KX_NO_IMPUTSTATUS
- {
- if (m_val == 1)
- {
- m_val = 0;
- result = true;
- }
- }
-
- break;
- }
- default:
- ; /* error */
- }
-
- if (reset)
- // force an event
- result = true;
- return result;
-}
-
-void SCA_MouseSensor::setX(short x)
-{
- m_x = x;
-}
-
-void SCA_MouseSensor::setY(short y)
-{
- m_y = y;
-}
-
-bool SCA_MouseSensor::isValid(SCA_MouseSensor::KX_MOUSESENSORMODE m)
-{
- return ((m > KX_MOUSESENSORMODE_NODEF) && (m < KX_MOUSESENSORMODE_MAX));
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
-"getButtonStatus(button)\n"
-"\tGet the given button's status (KX_INPUT_NONE, KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED).\n")
-{
- if (PyLong_Check(value))
- {
- SCA_IInputDevice::KX_EnumInputs button = (SCA_IInputDevice::KX_EnumInputs)PyLong_AsLong(value);
-
- if ((button < SCA_IInputDevice::KX_LEFTMOUSE) ||
- (button > SCA_IInputDevice::KX_RIGHTMOUSE))
- {
- PyErr_SetString(PyExc_ValueError, "sensor.getButtonStatus(int): Mouse Sensor, invalid button specified!");
- return NULL;
- }
-
- SCA_IInputDevice* mousedev = ((SCA_MouseManager *)m_eventmgr)->GetInputDevice();
- const SCA_InputEvent& event = mousedev->GetEventValue(button);
- return PyLong_FromLong(event.m_status);
- }
-
- Py_RETURN_NONE;
-}
-
-/* ------------------------------------------------------------------------- */
-/* Python Integration Hooks */
-/* ------------------------------------------------------------------------- */
-
-PyTypeObject SCA_MouseSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_MouseSensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_MouseSensor::Methods[] = {
- KX_PYMETHODTABLE_O(SCA_MouseSensor, getButtonStatus),
- {NULL,NULL} //Sentinel
-};
-
-int SCA_MouseSensor::UpdateHotkeyPy(void *self, const PyAttributeDef*)
-{
- UpdateHotkey(self);
- // return value is used in py_setattro(),
- // 0=attribute checked ok (see Attributes array definition)
- return 0;
-}
-
-PyAttributeDef SCA_MouseSensor::Attributes[] = {
- KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkeyPy),
- KX_PYATTRIBUTE_SHORT_LIST_RO("position",SCA_MouseSensor,m_x,2),
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h
deleted file mode 100644
index 2660aaeacb5..00000000000
--- a/source/gameengine/GameLogic/SCA_MouseSensor.h
+++ /dev/null
@@ -1,120 +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): José I. Romero (cleanup and fixes)
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file SCA_MouseSensor.h
- * \ingroup gamelogic
- * \brief Senses mouse events
- */
-
-#ifndef __SCA_MOUSESENSOR_H__
-#define __SCA_MOUSESENSOR_H__
-
-#include "SCA_ISensor.h"
-#include "EXP_BoolValue.h"
-#include "SCA_IInputDevice.h"
-
-class SCA_MouseSensor : public SCA_ISensor
-{
- Py_Header
-
- /**
- * Use SCA_IInputDevice values to encode the mouse mode for now.
- */
- short int m_mousemode;
- /**
- * Triggermode true means all mouse events trigger. Useful mainly
- * for button presses.
- */
- bool m_triggermode;
- /**
- * Remember the last state update
- */
- int m_val;
-
- SCA_IInputDevice::KX_EnumInputs m_hotkey;
-
- /**
- * valid x coordinate, MUST be followed by y coordinate
- */
- short m_x;
-
- /**
- * valid y coordinate
- */
- short m_y;
-
- public:
- /**
- * Allowable modes for the trigger status of the mouse sensor.
- */
- enum KX_MOUSESENSORMODE {
- KX_MOUSESENSORMODE_NODEF = 0,
- KX_MOUSESENSORMODE_LEFTBUTTON,
- KX_MOUSESENSORMODE_MIDDLEBUTTON,
- KX_MOUSESENSORMODE_RIGHTBUTTON,
- KX_MOUSESENSORMODE_WHEELUP,
- KX_MOUSESENSORMODE_WHEELDOWN,
- KX_MOUSESENSORMODE_POSITION,
- KX_MOUSESENSORMODE_POSITIONX,
- KX_MOUSESENSORMODE_POSITIONY,
- KX_MOUSESENSORMODE_MOVEMENT,
- KX_MOUSESENSORMODE_MAX
- };
-
- bool isValid(KX_MOUSESENSORMODE);
-
- SCA_MouseSensor(class SCA_MouseManager* keybdmgr,
- int startx,int starty,
- short int mousemode,
- SCA_IObject* gameobj);
-
- virtual ~SCA_MouseSensor();
- virtual CValue* GetReplica();
- virtual bool Evaluate();
- virtual void Init();
- virtual bool IsPositiveTrigger();
- short int GetModeKey();
- SCA_IInputDevice::KX_EnumInputs GetHotKey();
- void setX(short x);
- void setY(short y);
-
- static void UpdateHotkey(void *self);
-
-
-#ifdef WITH_PYTHON
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- static int UpdateHotkeyPy(void *self, const PyAttributeDef *);
-
- // get button status
- KX_PYMETHOD_DOC_O(SCA_MouseSensor,getButtonStatus);
-#endif
-};
-
-#endif /* __SCA_MOUSESENSOR_H__ */
diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp
deleted file mode 100644
index 6a00c110e2b..00000000000
--- a/source/gameengine/GameLogic/SCA_NANDController.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 'Nand' together all inputs
- *
- *
- * ***** 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/GameLogic/SCA_NANDController.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_NANDController.h"
-#include "SCA_ISensor.h"
-#include "SCA_LogicManager.h"
-#include "EXP_BoolValue.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_NANDController::SCA_NANDController(SCA_IObject* gameobj)
- :
- SCA_IController(gameobj)
-{
-}
-
-
-
-SCA_NANDController::~SCA_NANDController()
-{
-}
-
-
-
-void SCA_NANDController::Trigger(SCA_LogicManager* logicmgr)
-{
-
- bool sensorresult = false;
-
- for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
- !(is==m_linkedsensors.end());is++)
- {
- SCA_ISensor* sensor = *is;
- if (!sensor->GetState())
- {
- sensorresult = true;
- break;
- }
- }
-
- for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
- !(i==m_linkedactuators.end());i++)
- {
- SCA_IActuator* actua = *i;
- logicmgr->AddActiveActuator(actua,sensorresult);
- }
-}
-
-
-
-CValue* SCA_NANDController::GetReplica()
-{
- CValue* replica = new SCA_NANDController(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_NANDController::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_NANDController",
- 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,
- &SCA_IController::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_NANDController::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_NANDController::Attributes[] = {
- { NULL } //Sentinel
-};
-
-#endif
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_NANDController.h b/source/gameengine/GameLogic/SCA_NANDController.h
deleted file mode 100644
index a3f02908dd2..00000000000
--- a/source/gameengine/GameLogic/SCA_NANDController.h
+++ /dev/null
@@ -1,52 +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 SCA_NANDController.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_NANDCONTROLLER_H__
-#define __SCA_NANDCONTROLLER_H__
-
-#include "SCA_IController.h"
-
-class SCA_NANDController : public SCA_IController
-{
- Py_Header
- //virtual void Trigger(class SCA_LogicManager* logicmgr);
-public:
- SCA_NANDController(SCA_IObject* gameobj);
- virtual ~SCA_NANDController();
- virtual CValue* GetReplica();
- virtual void Trigger(SCA_LogicManager* logicmgr);
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-};
-
-#endif /* __SCA_NANDCONTROLLER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp
deleted file mode 100644
index fb09617e060..00000000000
--- a/source/gameengine/GameLogic/SCA_NORController.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 'Nor' together all inputs
- *
- *
- * ***** 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/GameLogic/SCA_NORController.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_NORController.h"
-#include "SCA_ISensor.h"
-#include "SCA_LogicManager.h"
-#include "EXP_BoolValue.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_NORController::SCA_NORController(SCA_IObject* gameobj)
- :
- SCA_IController(gameobj)
-{
-}
-
-
-
-SCA_NORController::~SCA_NORController()
-{
-}
-
-
-
-void SCA_NORController::Trigger(SCA_LogicManager* logicmgr)
-{
-
- bool sensorresult = true;
-
- for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
- !(is==m_linkedsensors.end());is++)
- {
- SCA_ISensor* sensor = *is;
- if (sensor->GetState())
- {
- sensorresult = false;
- break;
- }
- }
-
- for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
- !(i==m_linkedactuators.end());i++)
- {
- SCA_IActuator* actua = *i;
- logicmgr->AddActiveActuator(actua,sensorresult);
- }
-}
-
-
-
-CValue* SCA_NORController::GetReplica()
-{
- CValue* replica = new SCA_NORController(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_NORController::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_NORController",
- 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,
- &SCA_IController::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_NORController::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_NORController::Attributes[] = {
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_NORController.h b/source/gameengine/GameLogic/SCA_NORController.h
deleted file mode 100644
index ec8159de8d1..00000000000
--- a/source/gameengine/GameLogic/SCA_NORController.h
+++ /dev/null
@@ -1,48 +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 SCA_NORController.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_NORCONTROLLER_H__
-#define __SCA_NORCONTROLLER_H__
-
-#include "SCA_IController.h"
-
-class SCA_NORController : public SCA_IController
-{
- Py_Header
- //virtual void Trigger(class SCA_LogicManager* logicmgr);
-public:
- SCA_NORController(SCA_IObject* gameobj);
- virtual ~SCA_NORController();
- virtual CValue* GetReplica();
- virtual void Trigger(SCA_LogicManager* logicmgr);
-};
-
-#endif /* __SCA_NORCONTROLLER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp
deleted file mode 100644
index 8a59bdf1b89..00000000000
--- a/source/gameengine/GameLogic/SCA_ORController.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 'Or' together all inputs
- *
- *
- * ***** 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/GameLogic/SCA_ORController.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_ORController.h"
-#include "SCA_ISensor.h"
-#include "SCA_LogicManager.h"
-#include "EXP_BoolValue.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_ORController::SCA_ORController(SCA_IObject* gameobj)
- :SCA_IController(gameobj)
-{
-}
-
-
-
-SCA_ORController::~SCA_ORController()
-{
-}
-
-
-
-CValue* SCA_ORController::GetReplica()
-{
- CValue* replica = new SCA_ORController(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-
-void SCA_ORController::Trigger(SCA_LogicManager* logicmgr)
-{
-
- bool sensorresult = false;
- SCA_ISensor* sensor;
-
- vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
- while ( (!sensorresult) && (!(is==m_linkedsensors.end())) )
- {
- sensor = *is;
- if (sensor->GetState()) sensorresult = true;
- is++;
- }
-
- for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
- !(i==m_linkedactuators.end());i++)
- {
- SCA_IActuator* actua = *i;
- logicmgr->AddActiveActuator(actua,sensorresult);
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_ORController::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_ORController",
- 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,
- &SCA_IController::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_ORController::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_ORController::Attributes[] = {
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ORController.h b/source/gameengine/GameLogic/SCA_ORController.h
deleted file mode 100644
index 9499c893c72..00000000000
--- a/source/gameengine/GameLogic/SCA_ORController.h
+++ /dev/null
@@ -1,49 +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 SCA_ORController.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_ORCONTROLLER_H__
-#define __SCA_ORCONTROLLER_H__
-
-#include "SCA_IController.h"
-
-class SCA_ORController : public SCA_IController
-{
- Py_Header
- //virtual void Trigger(class SCA_LogicManager* logicmgr);
-public:
- SCA_ORController(SCA_IObject* gameobj);
-
- virtual ~SCA_ORController();
- virtual CValue* GetReplica();
- virtual void Trigger(SCA_LogicManager* logicmgr);
-};
-
-#endif /* __SCA_ORCONTROLLER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
deleted file mode 100644
index f2907ca6361..00000000000
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Assign, change, copy properties
- *
- *
- * ***** 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/GameLogic/SCA_PropertyActuator.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include "SCA_PropertyActuator.h"
-#include "EXP_InputParser.h"
-#include "EXP_Operator2Expr.h"
-#include "EXP_ConstExpr.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,SCA_IObject* sourceObj,const STR_String& propname,const STR_String& expr,int acttype)
- : SCA_IActuator(gameobj, KX_ACT_PROPERTY),
- m_type(acttype),
- m_propname(propname),
- m_exprtxt(expr),
- m_sourceObj(sourceObj)
-{
- // protect ourselves against someone else deleting the source object
- // don't protect against ourselves: it would create a dead lock
- if (m_sourceObj)
- m_sourceObj->RegisterActuator(this);
-}
-
-SCA_PropertyActuator::~SCA_PropertyActuator()
-{
- if (m_sourceObj)
- m_sourceObj->UnregisterActuator(this);
-}
-
-bool SCA_PropertyActuator::Update()
-{
- bool result = false;
-
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
- CValue* propowner = GetParent();
-
- if (bNegativeEvent)
- {
- if (m_type==KX_ACT_PROP_LEVEL)
- {
- CValue* newval = new CBoolValue(false);
- CValue* oldprop = propowner->GetProperty(m_propname);
- if (oldprop)
- {
- oldprop->SetValue(newval);
- }
- newval->Release();
- }
- return false;
- }
-
-
- CParser parser;
- parser.SetContext( propowner->AddRef());
-
- CExpression* userexpr= NULL;
-
- if (m_type==KX_ACT_PROP_TOGGLE)
- {
- /* don't use */
- CValue* newval;
- CValue* oldprop = propowner->GetProperty(m_propname);
- if (oldprop)
- {
- newval = new CBoolValue((oldprop->GetNumber()==0.0) ? true:false);
- oldprop->SetValue(newval);
- } else
- { /* as not been assigned, evaluate as false, so assign true */
- newval = new CBoolValue(true);
- propowner->SetProperty(m_propname,newval);
- }
- newval->Release();
- }
- else if (m_type==KX_ACT_PROP_LEVEL)
- {
- CValue* newval = new CBoolValue(true);
- CValue* oldprop = propowner->GetProperty(m_propname);
- if (oldprop)
- {
- oldprop->SetValue(newval);
- } else
- {
- propowner->SetProperty(m_propname,newval);
- }
- newval->Release();
- }
- else if ((userexpr = parser.ProcessText(m_exprtxt))) {
- switch (m_type)
- {
-
- case KX_ACT_PROP_ASSIGN:
- {
-
- CValue* newval = userexpr->Calculate();
- CValue* oldprop = propowner->GetProperty(m_propname);
- if (oldprop)
- {
- oldprop->SetValue(newval);
- } else
- {
- propowner->SetProperty(m_propname,newval);
- }
- newval->Release();
- break;
- }
- case KX_ACT_PROP_ADD:
- {
- CValue* oldprop = propowner->GetProperty(m_propname);
- if (oldprop)
- {
- // int waarde = (int)oldprop->GetNumber(); /*unused*/
- CExpression* expr = new COperator2Expr(VALUE_ADD_OPERATOR,new CConstExpr(oldprop->AddRef()),
- userexpr->AddRef());
-
- CValue* newprop = expr->Calculate();
- oldprop->SetValue(newprop);
- newprop->Release();
- expr->Release();
-
- }
-
- break;
- }
- case KX_ACT_PROP_COPY:
- {
- if (m_sourceObj)
- {
- CValue* copyprop = m_sourceObj->GetProperty(m_exprtxt);
- if (copyprop)
- {
- CValue *val = copyprop->GetReplica();
- GetParent()->SetProperty(
- m_propname,
- val);
- val->Release();
-
- }
- }
- break;
- }
- /* case KX_ACT_PROP_TOGGLE: */ /* accounted for above, no need for userexpr */
- default:
- {
-
- }
- }
-
- userexpr->Release();
- }
-
- return result;
-}
-
- bool
-
-SCA_PropertyActuator::
-
-isValid(
-
- SCA_PropertyActuator::KX_ACT_PROP_MODE mode
-
-) {
- bool res = false;
- res = ((mode > KX_ACT_PROP_NODEF) && (mode < KX_ACT_PROP_MAX));
- return res;
-}
-
-
- CValue*
-
-SCA_PropertyActuator::
-
-GetReplica()
-{
-
- SCA_PropertyActuator* replica = new SCA_PropertyActuator(*this);
-
- replica->ProcessReplica();
- return replica;
-
-};
-
-void SCA_PropertyActuator::ProcessReplica()
-{
- // no need to check for self reference like in the constructor:
- // the replica will always have a different parent
- if (m_sourceObj)
- m_sourceObj->RegisterActuator(this);
- SCA_IActuator::ProcessReplica();
-}
-
-bool SCA_PropertyActuator::UnlinkObject(SCA_IObject* clientobj)
-{
- if (clientobj == m_sourceObj)
- {
- // this object is being deleted, we cannot continue to track it.
- m_sourceObj = NULL;
- return true;
- }
- return false;
-}
-
-void SCA_PropertyActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_sourceObj];
- if (h_obj) {
- if (m_sourceObj)
- m_sourceObj->UnregisterActuator(this);
- m_sourceObj = (SCA_IObject*)(*h_obj);
- m_sourceObj->RegisterActuator(this);
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_PropertyActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_PropertyActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_PropertyActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_PropertyActuator::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,MAX_PROP_NAME,false,SCA_PropertyActuator,m_propname,CheckProperty),
- KX_PYATTRIBUTE_STRING_RW("value",0,100,false,SCA_PropertyActuator,m_exprtxt),
- KX_PYATTRIBUTE_INT_RW("mode", KX_ACT_PROP_NODEF+1, KX_ACT_PROP_MAX-1, false, SCA_PropertyActuator, m_type), /* ATTR_TODO add constents to game logic dict */
- { NULL } //Sentinel
-};
-
-#endif
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
deleted file mode 100644
index 228ecf94bc4..00000000000
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ /dev/null
@@ -1,90 +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 SCA_PropertyActuator.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_PROPERTYACTUATOR_H__
-#define __SCA_PROPERTYACTUATOR_H__
-
-#include "SCA_IActuator.h"
-
-class SCA_PropertyActuator : public SCA_IActuator
-{
- Py_Header
-
- enum KX_ACT_PROP_MODE {
- KX_ACT_PROP_NODEF = 0,
- KX_ACT_PROP_ASSIGN,
- KX_ACT_PROP_ADD,
- KX_ACT_PROP_COPY,
- KX_ACT_PROP_TOGGLE,
- KX_ACT_PROP_LEVEL,
- KX_ACT_PROP_MAX
- };
-
- /**check whether this value is valid */
- bool isValid(KX_ACT_PROP_MODE mode);
-
- int m_type;
- STR_String m_propname;
- STR_String m_exprtxt;
- SCA_IObject* m_sourceObj; // for copy property actuator
-
-public:
-
-
-
- SCA_PropertyActuator(
- SCA_IObject* gameobj,
- SCA_IObject* sourceObj,
- const STR_String& propname,
- const STR_String& expr,
- int acttype);
-
-
- ~SCA_PropertyActuator();
-
- CValue*
- GetReplica(
- );
-
- virtual void ProcessReplica();
- virtual bool UnlinkObject(SCA_IObject* clientobj);
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
-
- virtual bool
- Update();
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
-};
-
-#endif /* __KX_PROPERTYACTUATOR_DOC */
diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
deleted file mode 100644
index 854069690da..00000000000
--- a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
+++ /dev/null
@@ -1,57 +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/GameLogic/SCA_PropertyEventManager.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_ISensor.h"
-#include "SCA_PropertyEventManager.h"
-
-
-SCA_PropertyEventManager::SCA_PropertyEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(logicmgr, PROPERTY_EVENTMGR)
-{
-}
-
-
-
-SCA_PropertyEventManager::~SCA_PropertyEventManager()
-{
-
-}
-
-void SCA_PropertyEventManager::NextFrame()
-{
- // check for changed properties
- SG_DList::iterator<SCA_ISensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- (*it)->Activate(m_logicmgr);
- }
-}
diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h
deleted file mode 100644
index 554fe686df2..00000000000
--- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h
+++ /dev/null
@@ -1,55 +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 SCA_PropertyEventManager.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_PROPERTYEVENTMANAGER_H__
-#define __SCA_PROPERTYEVENTMANAGER_H__
-
-#include "SCA_EventManager.h"
-
-#include <vector>
-
-using namespace std;
-
-class SCA_PropertyEventManager : public SCA_EventManager
-{
-public:
- SCA_PropertyEventManager(class SCA_LogicManager* logicmgr);
- virtual ~SCA_PropertyEventManager();
- virtual void NextFrame();
- //SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_PropertyEventManager")
-#endif
-};
-
-#endif /* __SCA_PROPERTYEVENTMANAGER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
deleted file mode 100644
index e34a5296139..00000000000
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Property sensor
- *
- *
- * ***** 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/GameLogic/SCA_PropertySensor.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include <iostream>
-#include "SCA_PropertySensor.h"
-#include "EXP_Operator2Expr.h"
-#include "EXP_ConstExpr.h"
-#include "EXP_InputParser.h"
-#include "EXP_StringValue.h"
-#include "SCA_EventManager.h"
-#include "SCA_LogicManager.h"
-#include "EXP_BoolValue.h"
-#include "EXP_FloatValue.h"
-#include <stdio.h>
-
-SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- const STR_String& propname,
- const STR_String& propval,
- const STR_String& propmaxval,
- KX_PROPSENSOR_TYPE checktype)
- : SCA_ISensor(gameobj,eventmgr),
- m_checktype(checktype),
- m_checkpropval(propval),
- m_checkpropmaxval(propmaxval),
- m_checkpropname(propname)
-{
- //CParser pars;
- //pars.SetContext(this->AddRef());
- //CValue* resultval = m_rightexpr->Calculate();
-
- CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
- if (!orgprop->IsError())
- {
- m_previoustext = orgprop->GetText();
- }
- orgprop->Release();
-
- Init();
-}
-
-void SCA_PropertySensor::Init()
-{
- m_recentresult = false;
- m_lastresult = m_invert?true:false;
- m_reset = true;
-}
-
-CValue* SCA_PropertySensor::GetReplica()
-{
- SCA_PropertySensor* replica = new SCA_PropertySensor(*this);
- // m_range_expr must be recalculated on replica!
- replica->ProcessReplica();
- replica->Init();
-
- return replica;
-}
-
-
-
-bool SCA_PropertySensor::IsPositiveTrigger()
-{
- bool result = m_recentresult;//CheckPropertyCondition();
- if (m_invert)
- result = !result;
-
- return result;
-}
-
-
-
-SCA_PropertySensor::~SCA_PropertySensor()
-{
-}
-
-
-
-bool SCA_PropertySensor::Evaluate()
-{
- bool result = CheckPropertyCondition();
- bool reset = m_reset && m_level;
-
- m_reset = false;
- if (m_lastresult!=result)
- {
- m_lastresult = result;
- return true;
- }
- return (reset) ? true : false;
-}
-
-
-bool SCA_PropertySensor::CheckPropertyCondition()
-{
- m_recentresult=false;
- bool result=false;
- bool reverse = false;
- switch (m_checktype)
- {
- case KX_PROPSENSOR_NOTEQUAL:
- reverse = true;
- ATTR_FALLTHROUGH;
- case KX_PROPSENSOR_EQUAL:
- {
- CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
- if (!orgprop->IsError())
- {
- const STR_String& testprop = orgprop->GetText();
- // Force strings to upper case, to avoid confusion in
- // bool tests. It's stupid the prop's identity is lost
- // on the way here...
- if ((&testprop == &CBoolValue::sTrueString) || (&testprop == &CBoolValue::sFalseString)) {
- m_checkpropval.Upper();
- }
- result = (testprop == m_checkpropval);
-
- /* Patch: floating point values cant use strings usefully since you can have "0.0" == "0.0000"
- * this could be made into a generic Value class function for comparing values with a string.
- */
- if (result==false && (orgprop->GetValueType() == VALUE_FLOAT_TYPE)) {
- float f;
- if (sscanf(m_checkpropval.ReadPtr(), "%f", &f) == 1) {
- result = (f == ((CFloatValue *)orgprop)->GetFloat());
- }
- else {
- /* error */
- }
- }
- /* end patch */
- }
- orgprop->Release();
-
- if (reverse)
- result = !result;
- break;
-
- }
-
- case KX_PROPSENSOR_EXPRESSION:
- {
-#if 0
- if (m_rightexpr)
- {
- CValue* resultval = m_rightexpr->Calculate();
- if (resultval->IsError())
- {
- int i=0;
- STR_String errortest = resultval->GetText();
- printf(errortest);
-
- } else
- {
- result = resultval->GetNumber() != 0;
- }
- }
-#endif
- break;
- }
- case KX_PROPSENSOR_INTERVAL:
- {
- CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
- if (!orgprop->IsError())
- {
- const float min = m_checkpropval.ToFloat();
- const float max = m_checkpropmaxval.ToFloat();
- float val;
-
- if (orgprop->GetValueType() == VALUE_STRING_TYPE) {
- val = orgprop->GetText().ToFloat();
- }
- else {
- val = orgprop->GetNumber();
- }
-
- result = (min <= val) && (val <= max);
- }
- orgprop->Release();
-
- break;
- }
- case KX_PROPSENSOR_CHANGED:
- {
- CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
-
- if (!orgprop->IsError())
- {
- if (m_previoustext != orgprop->GetText())
- {
- m_previoustext = orgprop->GetText();
- result = true;
- }
- }
- orgprop->Release();
-
- //cout << " \nSens:Prop:changed!"; /* need implementation here!!! */
- break;
- }
- case KX_PROPSENSOR_LESSTHAN:
- reverse = true;
- ATTR_FALLTHROUGH;
- case KX_PROPSENSOR_GREATERTHAN:
- {
- CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
- if (!orgprop->IsError())
- {
- const float ref = m_checkpropval.ToFloat();
- float val;
-
- if (orgprop->GetValueType() == VALUE_STRING_TYPE) {
- val = orgprop->GetText().ToFloat();
- }
- else {
- val = orgprop->GetNumber();
- }
-
- if (reverse) {
- result = val < ref;
- }
- else {
- result = val > ref;
- }
-
- }
- orgprop->Release();
-
- break;
- }
- default:
- ; /* error */
- }
-
- //the concept of Edge and Level triggering has unwanted effect for KX_PROPSENSOR_CHANGED
- //see Game Engine bugtracker [ #3809 ]
- m_recentresult = result;
-
- return result;
-}
-
-CValue* SCA_PropertySensor::FindIdentifier(const STR_String& identifiername)
-{
- return GetParent()->FindIdentifier(identifiername);
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*)
-{
- /* If someone actually do type checking please make sure the 'max' and 'min'
- * are checked as well (currently they are calling the PrecalculateRangeExpression
- * function directly */
-
- /* There is no type checking at this moment, unfortunately... */
- return 0;
-}
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_PropertySensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_PropertySensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_PropertySensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_PropertySensor::Attributes[] = {
- KX_PYATTRIBUTE_INT_RW("mode",KX_PROPSENSOR_NODEF,KX_PROPSENSOR_MAX-1,false,SCA_PropertySensor,m_checktype),
- KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,MAX_PROP_NAME,false,SCA_PropertySensor,m_checkpropname,CheckProperty),
- KX_PYATTRIBUTE_STRING_RW_CHECK("value",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForProperty),
- KX_PYATTRIBUTE_STRING_RW_CHECK("min",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForProperty),
- KX_PYATTRIBUTE_STRING_RW_CHECK("max",0,100,false,SCA_PropertySensor,m_checkpropmaxval,validValueForProperty),
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h
deleted file mode 100644
index f9cfb5fb1d2..00000000000
--- a/source/gameengine/GameLogic/SCA_PropertySensor.h
+++ /dev/null
@@ -1,98 +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 SCA_PropertySensor.h
- * \ingroup gamelogic
- * \brief Property sensor
- */
-
-#ifndef __SCA_PROPERTYSENSOR_H__
-#define __SCA_PROPERTYSENSOR_H__
-
-#include "SCA_ISensor.h"
-
-class SCA_PropertySensor : public SCA_ISensor
-{
- Py_Header
- //class CExpression* m_rightexpr;
- int m_checktype;
- STR_String m_checkpropval;
- STR_String m_checkpropmaxval;
- STR_String m_checkpropname;
- STR_String m_previoustext;
- bool m_lastresult;
- bool m_recentresult;
-
- protected:
-
-public:
- enum KX_PROPSENSOR_TYPE {
- KX_PROPSENSOR_NODEF = 0,
- KX_PROPSENSOR_EQUAL,
- KX_PROPSENSOR_NOTEQUAL,
- KX_PROPSENSOR_INTERVAL,
- KX_PROPSENSOR_CHANGED,
- KX_PROPSENSOR_EXPRESSION,
- KX_PROPSENSOR_LESSTHAN,
- KX_PROPSENSOR_GREATERTHAN,
- KX_PROPSENSOR_MAX
- };
-
- const STR_String S_KX_PROPSENSOR_EQ_STRING;
-
- SCA_PropertySensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- const STR_String& propname,
- const STR_String& propval,
- const STR_String& propmaxval,
- KX_PROPSENSOR_TYPE checktype);
-
- virtual ~SCA_PropertySensor();
- virtual CValue* GetReplica();
- virtual void Init();
- bool CheckPropertyCondition();
-
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
- virtual CValue* FindIdentifier(const STR_String& identifiername);
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- /**
- * Test whether this is a sensible value (type check)
- */
- static int validValueForProperty(void* self, const PyAttributeDef*);
-
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
deleted file mode 100644
index fd2e723741c..00000000000
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- * Execute Python scripts
- *
- *
- * ***** 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/GameLogic/SCA_PythonController.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include "SCA_PythonController.h"
-#include "SCA_LogicManager.h"
-#include "SCA_ISensor.h"
-#include "SCA_IActuator.h"
-#include "EXP_PyObjectPlus.h"
-
-#ifdef WITH_PYTHON
-#include "compile.h"
-#include "eval.h"
-#endif // WITH_PYTHON
-
-#include <algorithm>
-
-
-// initialize static member variables
-SCA_PythonController* SCA_PythonController::m_sCurrentController = NULL;
-
-
-SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode)
- : SCA_IController(gameobj),
-#ifdef WITH_PYTHON
- m_bytecode(NULL),
- m_function(NULL),
-#endif
- m_function_argc(0),
- m_bModified(true),
- m_debug(false),
- m_mode(mode)
-#ifdef WITH_PYTHON
- , m_pythondictionary(NULL)
-#endif
-
-{
-
-}
-
-#if 0
-//debugging
-CValue *SCA_PythonController::AddRef()
-{
- //printf("AddRef refcount = %i\n",GetRefCount());
- return CValue::AddRef();
-}
-int SCA_PythonController::Release()
-{
- //printf("Release refcount = %i\n",GetRefCount());
- return CValue::Release();
-}
-#endif
-
-SCA_PythonController::~SCA_PythonController()
-{
-
-#ifdef WITH_PYTHON
- //printf("released python byte script\n");
-
- Py_XDECREF(m_bytecode);
- Py_XDECREF(m_function);
-
- if (m_pythondictionary) {
- // break any circular references in the dictionary
- PyDict_Clear(m_pythondictionary);
- Py_DECREF(m_pythondictionary);
- }
-#endif
-}
-
-
-
-CValue* SCA_PythonController::GetReplica()
-{
- SCA_PythonController* replica = new SCA_PythonController(*this);
-
-#ifdef WITH_PYTHON
- /* why is this needed at all??? - m_bytecode is NULL'd below so this doesnt make sense
- * but removing it crashes blender (with YoFrankie). so leave in for now - Campbell */
- Py_XINCREF(replica->m_bytecode);
-
- Py_XINCREF(replica->m_function); // this is ok since its not set to NULL
- replica->m_bModified = replica->m_bytecode == NULL;
-
- // The replica->m_pythondictionary is stolen - replace with a copy.
- if (m_pythondictionary)
- replica->m_pythondictionary = PyDict_Copy(m_pythondictionary);
-
-#if 0
- // The other option is to incref the replica->m_pythondictionary -
- // the replica objects can then share data.
- if (m_pythondictionary)
- Py_INCREF(replica->m_pythondictionary);
-#endif
-
-#endif /* WITH_PYTHON */
-
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-
-
-void SCA_PythonController::SetScriptText(const STR_String& text)
-{
- m_scriptText = text;
- m_bModified = true;
-}
-
-
-
-void SCA_PythonController::SetScriptName(const STR_String& name)
-{
- m_scriptName = name;
-}
-
-
-#ifdef WITH_PYTHON
-void SCA_PythonController::SetNamespace(PyObject* pythondictionary)
-{
- if (m_pythondictionary)
- {
- PyDict_Clear(m_pythondictionary);
- Py_DECREF(m_pythondictionary);
- }
- m_pythondictionary = PyDict_Copy(pythondictionary); /* new reference */
-
- /* Without __file__ set the sys.argv[0] is used for the filename
- * which ends up with lines from the blender binary being printed in the console */
- PyObject *value = PyUnicode_From_STR_String(m_scriptName);
- PyDict_SetItemString(m_pythondictionary, "__file__", value);
- Py_DECREF(value);
-
-}
-#endif
-
-bool SCA_PythonController::IsTriggered(class SCA_ISensor* sensor)
-{
- if (std::find(m_triggeredSensors.begin(), m_triggeredSensors.end(), sensor) !=
- m_triggeredSensors.end())
- {
- return true;
- }
- else {
- return false;
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */
-PyObject *SCA_PythonController::sPyGetCurrentController(PyObject *self)
-{
- if (m_sCurrentController==NULL)
- {
- PyErr_SetString(PyExc_SystemError, "bge.logic.getCurrentController(), this function is being run outside the python controllers context, or blenders internal state is corrupt.");
- return NULL;
- }
- return m_sCurrentController->GetProxy();
-}
-
-SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
-{
- // for safety, todo: only allow for registered actuators (pointertable)
- // we don't want to crash gameengine/blender by python scripts
- std::vector<SCA_IActuator*> lacts = m_sCurrentController->GetLinkedActuators();
- std::vector<SCA_IActuator*>::iterator it;
-
- if (PyUnicode_Check(value)) {
- /* get the actuator from the name */
- const char *name= _PyUnicode_AsString(value);
- for (it = lacts.begin(); it!= lacts.end(); ++it) {
- if ( name == (*it)->GetName() ) {
- return *it;
- }
- }
- }
- else if (PyObject_TypeCheck(value, &SCA_IActuator::Type)) {
- PyObjectPlus *value_plus= BGE_PROXY_REF(value);
- for (it = lacts.begin(); it!= lacts.end(); ++it) {
- if (static_cast<SCA_IActuator*>(value_plus) == (*it)) {
- return *it;
- }
- }
- }
-
- /* set the exception */
- PyErr_Format(PyExc_ValueError,
- "%R not in this python controllers actuator list", value);
-
- return NULL;
-}
-
-const char* SCA_PythonController::sPyGetCurrentController__doc__ = "getCurrentController()";
-
-PyTypeObject SCA_PythonController::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_PythonController",
- 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,
- &SCA_IController::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_PythonController::Methods[] = {
- {"activate", (PyCFunction) SCA_PythonController::sPyActivate, METH_O},
- {"deactivate", (PyCFunction) SCA_PythonController::sPyDeActivate, METH_O},
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_PythonController::Attributes[] = {
- KX_PYATTRIBUTE_RW_FUNCTION("script", SCA_PythonController, pyattr_get_script, pyattr_set_script),
- KX_PYATTRIBUTE_INT_RO("mode", SCA_PythonController, m_mode),
- { NULL } //Sentinel
-};
-
-void SCA_PythonController::ErrorPrint(const char *error_msg)
-{
- // If GetParent() is NULL, then most likely the object this controller
- // was attached to is gone (e.g., removed by LibFree()). Also, GetName()
- // can be a bad pointer if GetParent() is NULL, so better be safe and
- // flag it as unavailable as well
- const char *obj_name, *ctr_name;
- if (GetParent()) {
- obj_name = GetParent()->GetName().ReadPtr();
- ctr_name = GetName().ReadPtr();
- } else {
- obj_name = ctr_name = "Unavailable";
- }
- printf("%s - object '%s', controller '%s':\n", error_msg, obj_name, ctr_name);
- PyErr_Print();
-
- /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
- * their user count. Not to mention holding references to wrapped data.
- * This is especially bad when the PyObject for the wrapped data is freed, after blender
- * has already dealocated the pointer */
- PySys_SetObject("last_traceback", NULL);
- PyErr_Clear(); /* just to be sure */
-}
-
-bool SCA_PythonController::Compile()
-{
- //printf("py script modified '%s'\n", m_scriptName.Ptr());
- m_bModified= false;
-
- // if a script already exists, decref it before replace the pointer to a new script
- if (m_bytecode) {
- Py_DECREF(m_bytecode);
- m_bytecode=NULL;
- }
-
- // recompile the scripttext into bytecode
- m_bytecode = Py_CompileString(m_scriptText.Ptr(), m_scriptName.Ptr(), Py_file_input);
-
- if (m_bytecode) {
- return true;
- } else {
- ErrorPrint("Python error compiling script");
- return false;
- }
-}
-
-bool SCA_PythonController::Import()
-{
- //printf("py module modified '%s'\n", m_scriptName.Ptr());
- m_bModified= false;
-
- /* in case we re-import */
- Py_XDECREF(m_function);
- m_function= NULL;
-
- STR_String mod_path_str= m_scriptText; /* just for storage, use C style string access */
- char *mod_path= mod_path_str.Ptr();
- char *function_string;
-
- function_string= strrchr(mod_path, '.');
-
- if (function_string == NULL) {
- printf("Python module name formatting error in object '%s', controller '%s':\n\texpected 'SomeModule.Func', got '%s'\n", GetParent()->GetName().Ptr(), GetName().Ptr(), m_scriptText.Ptr());
- return false;
- }
-
- *function_string= '\0';
- function_string++;
-
- // Import the module and print an error if it's not found
- PyObject *mod = PyImport_ImportModule(mod_path);
-
- if (mod == NULL) {
- ErrorPrint("Python module can't be imported");
- return false;
- }
-
- if (m_debug)
- mod = PyImport_ReloadModule(mod);
-
- if (mod == NULL) {
- ErrorPrint("Python module can't be reloaded");
- return false;
- }
-
- // Get the function object
- m_function = PyObject_GetAttrString(mod, function_string);
-
- // DECREF the module as we don't need it anymore
- Py_DECREF(mod);
-
- if (m_function==NULL) {
- if (PyErr_Occurred())
- ErrorPrint("Python controller found the module but could not access the function");
- else
- printf("Python module error in object '%s', controller '%s':\n '%s' module found but function missing\n", GetParent()->GetName().Ptr(), GetName().Ptr(), m_scriptText.Ptr());
- return false;
- }
-
- if (!PyCallable_Check(m_function)) {
- Py_DECREF(m_function);
- m_function = NULL;
- printf("Python module function error in object '%s', controller '%s':\n '%s' not callable\n", GetParent()->GetName().Ptr(), GetName().Ptr(), m_scriptText.Ptr());
- return false;
- }
-
- m_function_argc = 0; /* rare cases this could be a function that isn't defined in python, assume zero args */
- if (PyFunction_Check(m_function)) {
- m_function_argc= ((PyCodeObject *)PyFunction_GET_CODE(m_function))->co_argcount;
- }
-
- if (m_function_argc > 1) {
- Py_DECREF(m_function);
- m_function = NULL;
- printf("Python module function in object '%s', controller '%s':\n '%s' takes %d args, should be zero or 1 controller arg\n", GetParent()->GetName().Ptr(), GetName().Ptr(), m_scriptText.Ptr(), m_function_argc);
- return false;
- }
-
- return true;
-}
-
-
-void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
-{
- m_sCurrentController = this;
-
- PyObject *excdict= NULL;
- PyObject *resultobj= NULL;
-
- switch (m_mode) {
- case SCA_PYEXEC_SCRIPT:
- {
- if (m_bModified)
- if (Compile()==false) // sets m_bModified to false
- return;
- if (!m_bytecode)
- return;
-
- /*
- * This part here with excdict is a temporary patch
- * to avoid python/gameengine crashes when python
- * inadvertently holds references to game objects
- * in global variables.
- *
- * The idea is always make a fresh dictionary, and
- * destroy it right after it is used to make sure
- * python won't hold any gameobject references.
- *
- * Note that the PyDict_Clear _is_ necessary before
- * the Py_DECREF() because it is possible for the
- * variables inside the dictionary to hold references
- * to the dictionary (ie. generate a cycle), so we
- * break it by hand, then DECREF (which in this case
- * should always ensure excdict is cleared).
- */
-
- excdict= PyDict_Copy(m_pythondictionary);
-
- resultobj = PyEval_EvalCode((PyObject *)m_bytecode, excdict, excdict);
-
- /* PyRun_SimpleString(m_scriptText.Ptr()); */
- break;
- }
- case SCA_PYEXEC_MODULE:
- {
- if (m_bModified || m_debug)
- if (Import()==false) // sets m_bModified to false
- return;
- if (!m_function)
- return;
-
- PyObject *args= NULL;
-
- if (m_function_argc==1) {
- args = PyTuple_New(1);
- PyTuple_SET_ITEM(args, 0, GetProxy());
- }
-
- resultobj = PyObject_CallObject(m_function, args);
- Py_XDECREF(args);
- break;
- }
-
- } /* end switch */
-
-
- /* Free the return value and print the error */
- if (resultobj)
- Py_DECREF(resultobj);
- else
- ErrorPrint("Python script error");
-
- if (excdict) /* Only for SCA_PYEXEC_SCRIPT types */
- {
- /* clear after PyErrPrint - seems it can be using
- * something in this dictionary and crash? */
- // This doesn't appear to be needed anymore
- //PyDict_Clear(excdict);
- Py_DECREF(excdict);
- }
-
- m_triggeredSensors.clear();
- m_sCurrentController = NULL;
-}
-
-PyObject *SCA_PythonController::PyActivate(PyObject *value)
-{
- if (m_sCurrentController != this) {
- PyErr_SetString(PyExc_SystemError, "Cannot activate an actuator from a non-active controller");
- return NULL;
- }
-
- SCA_IActuator* actu = LinkedActuatorFromPy(value);
- if (actu==NULL)
- return NULL;
-
- m_logicManager->AddActiveActuator((SCA_IActuator*)actu, true);
- Py_RETURN_NONE;
-}
-
-PyObject *SCA_PythonController::PyDeActivate(PyObject *value)
-{
- if (m_sCurrentController != this) {
- PyErr_SetString(PyExc_SystemError, "Cannot deactivate an actuator from a non-active controller");
- return NULL;
- }
-
- SCA_IActuator* actu = LinkedActuatorFromPy(value);
- if (actu==NULL)
- return NULL;
-
- m_logicManager->AddActiveActuator((SCA_IActuator*)actu, false);
- Py_RETURN_NONE;
-}
-
-PyObject *SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- //SCA_PythonController* self = static_cast<SCA_PythonController*>(static_cast<SCA_IController*>(static_cast<SCA_ILogicBrick*>(static_cast<CValue*>(static_cast<PyObjectPlus*>(self_v)))));
- // static_cast<void *>(dynamic_cast<Derived *>(obj)) - static_cast<void *>(obj)
-
- SCA_PythonController* self = static_cast<SCA_PythonController*>(self_v);
- return PyUnicode_From_STR_String(self->m_scriptText);
-}
-
-
-
-int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- SCA_PythonController* self = static_cast<SCA_PythonController*>(self_v);
-
- const char *scriptArg = _PyUnicode_AsString(value);
-
- if (scriptArg==NULL) {
- PyErr_SetString(PyExc_TypeError, "controller.script = string: Python Controller, expected a string script text");
- return PY_SET_ATTR_FAIL;
- }
-
- /* set scripttext sets m_bModified to true,
- * so next time the script is needed, a reparse into byte code is done */
- self->SetScriptText(scriptArg);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-#else // WITH_PYTHON
-
-void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
-{
- /* intentionally blank */
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h
deleted file mode 100644
index 11241da9117..00000000000
--- a/source/gameengine/GameLogic/SCA_PythonController.h
+++ /dev/null
@@ -1,118 +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 SCA_PythonController.h
- * \ingroup gamelogic
- * \brief Execute Python scripts
- */
-
-#ifndef __SCA_PYTHONCONTROLLER_H__
-#define __SCA_PYTHONCONTROLLER_H__
-
-#include "SCA_IController.h"
-#include "SCA_LogicManager.h"
-#include "EXP_BoolValue.h"
-
-#include <vector>
-
-class SCA_IObject;
-class SCA_PythonController : public SCA_IController
-{
- Py_Header
-#ifdef WITH_PYTHON
- struct _object * m_bytecode; /* SCA_PYEXEC_SCRIPT only */
- PyObject* m_function; /* SCA_PYEXEC_MODULE only */
-#endif
- int m_function_argc;
- bool m_bModified;
- bool m_debug; /* use with SCA_PYEXEC_MODULE for reloading every logic run */
- int m_mode;
-
-
- protected:
- STR_String m_scriptText;
- STR_String m_scriptName;
-#ifdef WITH_PYTHON
- PyObject* m_pythondictionary; /* for SCA_PYEXEC_SCRIPT only */
- PyObject* m_pythonfunction; /* for SCA_PYEXEC_MODULE only */
-#endif
- std::vector<class SCA_ISensor*> m_triggeredSensors;
-
- public:
- enum SCA_PyExecMode
- {
- SCA_PYEXEC_SCRIPT = 0,
- SCA_PYEXEC_MODULE,
- SCA_PYEXEC_MAX
- };
-
- static SCA_PythonController* m_sCurrentController; // protected !!!
-
- //for debugging
- //virtual CValue* AddRef();
- //virtual int Release(); // Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
-
- SCA_PythonController(SCA_IObject* gameobj, int mode);
- virtual ~SCA_PythonController();
-
- virtual CValue* GetReplica();
- virtual void Trigger(class SCA_LogicManager* logicmgr);
-
- void SetScriptText(const STR_String& text);
- void SetScriptName(const STR_String& name);
-#ifdef WITH_PYTHON
- void SetNamespace(PyObject* pythondictionary);
-#endif
- void SetDebug(bool debug) { m_debug = debug; }
- void AddTriggeredSensor(class SCA_ISensor* sensor)
- { m_triggeredSensors.push_back(sensor); }
- bool IsTriggered(class SCA_ISensor* sensor);
- bool Compile();
- bool Import();
- void ErrorPrint(const char *error_msg);
-
-#ifdef WITH_PYTHON
- static const char *sPyGetCurrentController__doc__;
- static PyObject *sPyGetCurrentController(PyObject *self);
- static const char *sPyAddActiveActuator__doc__;
- static PyObject *sPyAddActiveActuator(PyObject *self,
- PyObject *args);
- static SCA_IActuator* LinkedActuatorFromPy(PyObject *value);
-
-
- KX_PYMETHOD_O(SCA_PythonController,Activate);
- KX_PYMETHOD_O(SCA_PythonController,DeActivate);
- KX_PYMETHOD_O(SCA_PythonController,SetScript);
- KX_PYMETHOD_NOARGS(SCA_PythonController,GetScript);
-
-
- static PyObject* pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif
-};
-
-#endif /* __SCA_PYTHONCONTROLLER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_PythonJoystick.cpp b/source/gameengine/GameLogic/SCA_PythonJoystick.cpp
deleted file mode 100644
index 9b24ad7bcf2..00000000000
--- a/source/gameengine/GameLogic/SCA_PythonJoystick.cpp
+++ /dev/null
@@ -1,188 +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.
- *
- * Contributor(s): Mitchell Stokes.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/GameLogic/SCA_PythonJoystick.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_PythonJoystick.h"
-#include "./Joystick/SCA_Joystick.h"
-#include "SCA_IInputDevice.h"
-
-//#include "GHOST_C-api.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_PythonJoystick::SCA_PythonJoystick(SCA_Joystick* joystick)
-: PyObjectPlus(),
-m_joystick(joystick)
-{
-#ifdef WITH_PYTHON
- m_event_dict = PyDict_New();
-#endif
-}
-
-SCA_PythonJoystick::~SCA_PythonJoystick()
-{
- // The joystick reference we got in the constructor was a new instance,
- // so we release it here
- m_joystick->ReleaseInstance();
-
-#ifdef WITH_PYTHON
- PyDict_Clear(m_event_dict);
- Py_DECREF(m_event_dict);
-#endif
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-PyObject* SCA_PythonJoystick::py_repr(void)
-{
- return PyUnicode_FromString(m_joystick->GetName());
-}
-
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_PythonJoystick::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_PythonJoystick",
- 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
-};
-
-PyMethodDef SCA_PythonJoystick::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_PythonJoystick::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("numButtons", SCA_PythonJoystick, pyattr_get_num_x),
- KX_PYATTRIBUTE_RO_FUNCTION("numHats", SCA_PythonJoystick, pyattr_get_num_x),
- KX_PYATTRIBUTE_RO_FUNCTION("numAxis", SCA_PythonJoystick, pyattr_get_num_x),
- KX_PYATTRIBUTE_RO_FUNCTION("activeButtons", SCA_PythonJoystick, pyattr_get_active_buttons),
- KX_PYATTRIBUTE_RO_FUNCTION("hatValues", SCA_PythonJoystick, pyattr_get_hat_values),
- KX_PYATTRIBUTE_RO_FUNCTION("axisValues", SCA_PythonJoystick, pyattr_get_axis_values),
- KX_PYATTRIBUTE_RO_FUNCTION("name", SCA_PythonJoystick, pyattr_get_name),
- { NULL } //Sentinel
-};
-
-// Use one function for numAxis, numButtons, and numHats
-PyObject* SCA_PythonJoystick::pyattr_get_num_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonJoystick* self = static_cast<SCA_PythonJoystick*>(self_v);
-
- if (strcmp(attrdef->m_name, "numButtons") == 0)
- return PyLong_FromLong(self->m_joystick->GetNumberOfButtons());
- else if (strcmp(attrdef->m_name, "numAxis") == 0)
- return PyLong_FromLong(self->m_joystick->GetNumberOfAxes());
- else if (strcmp(attrdef->m_name, "numHats") == 0)
- return PyLong_FromLong(self->m_joystick->GetNumberOfHats());
-
- // If we got here, we have a problem...
- PyErr_SetString(PyExc_AttributeError, "invalid attribute");
- return NULL;
-}
-
-PyObject* SCA_PythonJoystick::pyattr_get_active_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonJoystick* self = static_cast<SCA_PythonJoystick*>(self_v);
-
- const int button_number = self->m_joystick->GetNumberOfButtons();
-
- PyObject *list = PyList_New(0);
- PyObject *value;
-
- for (int i=0; i < button_number; i++) {
- if (self->m_joystick->aButtonPressIsPositive(i)) {
- value = PyLong_FromLong(i);
- PyList_Append(list, value);
- Py_DECREF(value);
- }
- }
-
- return list;
-}
-
-PyObject* SCA_PythonJoystick::pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonJoystick* self = static_cast<SCA_PythonJoystick*>(self_v);
-
- int hat_index = self->m_joystick->GetNumberOfHats();
- PyObject *list = PyList_New(hat_index);
-
- while (hat_index--) {
- PyList_SET_ITEM(list, hat_index, PyLong_FromLong(self->m_joystick->GetHat(hat_index)));
- }
-
- return list;
-}
-
-PyObject* SCA_PythonJoystick::pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonJoystick* self = static_cast<SCA_PythonJoystick*>(self_v);
-
- int axis_index = self->m_joystick->GetNumberOfAxes();
- PyObject *list = PyList_New(axis_index);
- int position;
-
- while (axis_index--) {
- position = self->m_joystick->GetAxisPosition(axis_index);
-
- // We get back a range from -32768 to 32767, so we use an if here to
- // get a perfect -1.0 to 1.0 mapping. Some oddball system might have an
- // actual min of -32767 for shorts, so we use SHRT_MIN/MAX to be safe.
- if (position < 0)
- PyList_SET_ITEM(list, axis_index, PyFloat_FromDouble(position/((double)-SHRT_MIN)));
- else
- PyList_SET_ITEM(list, axis_index, PyFloat_FromDouble(position/(double)SHRT_MAX));
- }
-
- return list;
-}
-
-PyObject* SCA_PythonJoystick::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonJoystick* self = static_cast<SCA_PythonJoystick*>(self_v);
-
- return PyUnicode_FromString(self->m_joystick->GetName());
-}
-#endif
diff --git a/source/gameengine/GameLogic/SCA_PythonJoystick.h b/source/gameengine/GameLogic/SCA_PythonJoystick.h
deleted file mode 100644
index ecde00d28b9..00000000000
--- a/source/gameengine/GameLogic/SCA_PythonJoystick.h
+++ /dev/null
@@ -1,56 +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.
- *
- * Contributor(s): Mitchell Stokes.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file SCA_PythonJoystick.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_PYTHONJOYSTICK_H__
-#define __SCA_PYTHONJOYSTICK_H__
-
-#include "EXP_PyObjectPlus.h"
-
-class SCA_PythonJoystick : public PyObjectPlus
-{
- Py_Header
-private:
- class SCA_Joystick *m_joystick;
-#ifdef WITH_PYTHON
- PyObject* m_event_dict;
-#endif
-public:
- SCA_PythonJoystick(class SCA_Joystick* joystick);
- virtual ~SCA_PythonJoystick();
-
-#ifdef WITH_PYTHON
- virtual PyObject* py_repr(void);
-
- static PyObject* pyattr_get_num_x(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_active_buttons(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_hat_values(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_axis_values(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-#endif
-};
-
-#endif //__SCA_PYTHONJOYSTICK_H__
-
diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
deleted file mode 100644
index 9a96a7b0334..00000000000
--- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp
+++ /dev/null
@@ -1,153 +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.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/GameLogic/SCA_PythonKeyboard.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_PythonKeyboard.h"
-#include "SCA_IInputDevice.h"
-
-#include "GHOST_C-api.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_PythonKeyboard::SCA_PythonKeyboard(SCA_IInputDevice* keyboard)
-: PyObjectPlus(),
-m_keyboard(keyboard)
-{
-#ifdef WITH_PYTHON
- m_event_dict = PyDict_New();
-#endif
-}
-
-SCA_PythonKeyboard::~SCA_PythonKeyboard()
-{
-#ifdef WITH_PYTHON
- PyDict_Clear(m_event_dict);
- Py_DECREF(m_event_dict);
-#endif
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* clipboard */
-static PyObject *gPyGetClipboard(PyObject *args, PyObject *kwds)
-{
- char *buf = (char *)GHOST_getClipboard(0);
- return PyUnicode_FromString(buf?buf:"");
-}
-
-static PyObject *gPySetClipboard(PyObject *args, PyObject *value)
-{
- char* buf;
- if (!PyArg_ParseTuple(value,"s:setClipboard",&buf))
- Py_RETURN_NONE;
-
- GHOST_putClipboard((GHOST_TInt8 *)buf, 0);
- Py_RETURN_NONE;
-}
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_PythonKeyboard::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_PythonKeyboard",
- 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
-};
-
-PyMethodDef SCA_PythonKeyboard::Methods[] = {
- {"getClipboard", (PyCFunction) gPyGetClipboard, METH_VARARGS, "getCliboard doc"},
- {"setClipboard", (PyCFunction) gPySetClipboard, METH_VARARGS, "setCliboard doc"},
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_PythonKeyboard::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_PythonKeyboard, pyattr_get_events),
- KX_PYATTRIBUTE_RO_FUNCTION("active_events", SCA_PythonKeyboard, pyattr_get_active_events),
- { NULL } //Sentinel
-};
-
-PyObject *SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonKeyboard* self = static_cast<SCA_PythonKeyboard*>(self_v);
-
- for (int i = SCA_IInputDevice::KX_BEGINKEY; i <= SCA_IInputDevice::KX_ENDKEY; i++) {
- const SCA_InputEvent & inevent = self->m_keyboard->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
- PyObject *key = PyLong_FromLong(i);
- PyObject *value = PyLong_FromLong(inevent.m_status);
-
- PyDict_SetItem(self->m_event_dict, key, value);
-
- Py_DECREF(key);
- Py_DECREF(value);
- }
- Py_INCREF(self->m_event_dict);
- return self->m_event_dict;
-}
-
-PyObject *SCA_PythonKeyboard::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonKeyboard* self = static_cast<SCA_PythonKeyboard*>(self_v);
-
- PyDict_Clear(self->m_event_dict);
-
- for (int i = SCA_IInputDevice::KX_BEGINKEY; i <= SCA_IInputDevice::KX_ENDKEY; i++) {
- const SCA_InputEvent & inevent = self->m_keyboard->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
-
- if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS) {
- PyObject *key = PyLong_FromLong(i);
- PyObject *value = PyLong_FromLong(inevent.m_status);
-
- PyDict_SetItem(self->m_event_dict, key, value);
-
- Py_DECREF(key);
- Py_DECREF(value);
- }
- }
- Py_INCREF(self->m_event_dict);
- return self->m_event_dict;
-}
-
-#endif
diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.h b/source/gameengine/GameLogic/SCA_PythonKeyboard.h
deleted file mode 100644
index 3cbe250378c..00000000000
--- a/source/gameengine/GameLogic/SCA_PythonKeyboard.h
+++ /dev/null
@@ -1,50 +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.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file SCA_PythonKeyboard.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_PYTHONKEYBOARD_H__
-#define __SCA_PYTHONKEYBOARD_H__
-
-#include "EXP_PyObjectPlus.h"
-
-class SCA_PythonKeyboard : public PyObjectPlus
-{
- Py_Header
-private:
- class SCA_IInputDevice *m_keyboard;
-#ifdef WITH_PYTHON
- PyObject *m_event_dict;
-#endif
-public:
- SCA_PythonKeyboard(class SCA_IInputDevice* keyboard);
- virtual ~SCA_PythonKeyboard();
-
-#ifdef WITH_PYTHON
- static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-#endif
-};
-
-#endif /* __SCA_PYTHONKEYBOARD_H__ */
diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.cpp b/source/gameengine/GameLogic/SCA_PythonMouse.cpp
deleted file mode 100644
index 184b306a665..00000000000
--- a/source/gameengine/GameLogic/SCA_PythonMouse.cpp
+++ /dev/null
@@ -1,206 +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.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/GameLogic/SCA_PythonMouse.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_PythonMouse.h"
-#include "SCA_IInputDevice.h"
-#include "RAS_ICanvas.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_PythonMouse::SCA_PythonMouse(SCA_IInputDevice* mouse, RAS_ICanvas* canvas)
-: PyObjectPlus(),
-m_mouse(mouse),
-m_canvas(canvas)
-{
-#ifdef WITH_PYTHON
- m_event_dict = PyDict_New();
-#endif
-}
-
-SCA_PythonMouse::~SCA_PythonMouse()
-{
-#ifdef WITH_PYTHON
- PyDict_Clear(m_event_dict);
- Py_DECREF(m_event_dict);
-#endif
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_PythonMouse::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_PythonMouse",
- 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
-};
-
-PyMethodDef SCA_PythonMouse::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_PythonMouse::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_PythonMouse, pyattr_get_events),
- KX_PYATTRIBUTE_RO_FUNCTION("active_events", SCA_PythonMouse, pyattr_get_active_events),
- KX_PYATTRIBUTE_RW_FUNCTION("position", SCA_PythonMouse, pyattr_get_position, pyattr_set_position),
- KX_PYATTRIBUTE_RW_FUNCTION("visible", SCA_PythonMouse, pyattr_get_visible, pyattr_set_visible),
- { NULL } //Sentinel
-};
-
-PyObject *SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);
-
- for (int i = SCA_IInputDevice::KX_BEGINMOUSE; i <= SCA_IInputDevice::KX_ENDMOUSE; i++) {
- const SCA_InputEvent &inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
- PyObject *key = PyLong_FromLong(i);
- PyObject *value = PyLong_FromLong(inevent.m_status);
-
- PyDict_SetItem(self->m_event_dict, key, value);
-
- Py_DECREF(key);
- Py_DECREF(value);
- }
- Py_INCREF(self->m_event_dict);
- return self->m_event_dict;
-}
-
-PyObject *SCA_PythonMouse::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);
-
- PyDict_Clear(self->m_event_dict);
-
- for (int i = SCA_IInputDevice::KX_BEGINMOUSE; i <= SCA_IInputDevice::KX_ENDMOUSE; i++) {
- const SCA_InputEvent &inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i);
-
- if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS) {
-
- PyObject *key = PyLong_FromLong(i);
- PyObject *value = PyLong_FromLong(inevent.m_status);
-
- PyDict_SetItem(self->m_event_dict, key, value);
-
- Py_DECREF(key);
- Py_DECREF(value);
- }
- }
- Py_INCREF(self->m_event_dict);
- return self->m_event_dict;
-}
-
-PyObject *SCA_PythonMouse::pyattr_get_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);
- const SCA_InputEvent & xevent = self->m_mouse->GetEventValue(SCA_IInputDevice::KX_MOUSEX);
- const SCA_InputEvent & yevent = self->m_mouse->GetEventValue(SCA_IInputDevice::KX_MOUSEY);
-
- float x_coord, y_coord;
-
- x_coord = self->m_canvas->GetMouseNormalizedX(xevent.m_eventval);
- y_coord = self->m_canvas->GetMouseNormalizedY(yevent.m_eventval);
-
- PyObject *ret = PyTuple_New(2);
-
- PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(x_coord));
- PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(y_coord));
-
- return ret;
-}
-
-int SCA_PythonMouse::pyattr_set_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);
- int x, y;
- float pyx, pyy;
- if (!PyArg_ParseTuple(value, "ff:position", &pyx, &pyy))
- return PY_SET_ATTR_FAIL;
-
- x = (int)(pyx*self->m_canvas->GetWidth());
- y = (int)(pyy*self->m_canvas->GetHeight());
-
- self->m_canvas->SetMousePosition(x, y);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *SCA_PythonMouse::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);
-
- int visible;
-
- if (self->m_canvas->GetMouseState() == RAS_ICanvas::MOUSE_INVISIBLE)
- visible = 0;
- else
- visible = 1;
-
- return PyBool_FromLong(visible);
-}
-
-int SCA_PythonMouse::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- SCA_PythonMouse* self = static_cast<SCA_PythonMouse*>(self_v);
-
- int visible = PyObject_IsTrue(value);
-
- if (visible == -1)
- {
- PyErr_SetString(PyExc_AttributeError, "SCA_PythonMouse.visible = bool: SCA_PythonMouse, expected True or False");
- return PY_SET_ATTR_FAIL;
- }
-
- if (visible)
- self->m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
- else
- self->m_canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif
diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.h b/source/gameengine/GameLogic/SCA_PythonMouse.h
deleted file mode 100644
index 6dde90b3482..00000000000
--- a/source/gameengine/GameLogic/SCA_PythonMouse.h
+++ /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.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file SCA_PythonMouse.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_PYTHONMOUSE_H__
-#define __SCA_PYTHONMOUSE_H__
-
-#include "EXP_PyObjectPlus.h"
-
-class SCA_PythonMouse : public PyObjectPlus
-{
- Py_Header
-private:
- class SCA_IInputDevice *m_mouse;
- class RAS_ICanvas *m_canvas;
-#ifdef WITH_PYTHON
- PyObject *m_event_dict;
-#endif
-public:
- SCA_PythonMouse(class SCA_IInputDevice* mouse, class RAS_ICanvas* canvas);
- virtual ~SCA_PythonMouse();
-
- void Show(bool visible);
-
-#ifdef WITH_PYTHON
- KX_PYMETHOD_DOC(SCA_PythonMouse, show);
-
- static PyObject *pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_visible(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_visible(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif
-};
-
-#endif /* __SCA_PYTHONMOUSE_H__ */
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
deleted file mode 100644
index 8d75be9089d..00000000000
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ /dev/null
@@ -1,543 +0,0 @@
-/*
- * Set random/camera stuff
- *
- *
- * ***** 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/GameLogic/SCA_RandomActuator.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-#include <math.h>
-
-#include "EXP_BoolValue.h"
-#include "EXP_IntValue.h"
-#include "EXP_FloatValue.h"
-#include "SCA_IActuator.h"
-#include "SCA_RandomActuator.h"
-#include "MT_Transform.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj,
- long seed,
- SCA_RandomActuator::KX_RANDOMACT_MODE mode,
- float para1,
- float para2,
- const STR_String &propName)
- : SCA_IActuator(gameobj, KX_ACT_RANDOM),
- m_propname(propName),
- m_parameter1(para1),
- m_parameter2(para2),
- m_distribution(mode)
-{
- m_base = new SCA_RandomNumberGenerator(seed);
- m_counter = 0;
- enforceConstraints();
-}
-
-
-
-SCA_RandomActuator::~SCA_RandomActuator()
-{
- m_base->Release();
-}
-
-
-
-CValue* SCA_RandomActuator::GetReplica()
-{
- SCA_RandomActuator* replica = new SCA_RandomActuator(*this);
- // replication just copy the m_base pointer => common random generator
- replica->ProcessReplica();
- return replica;
-}
-
-void SCA_RandomActuator::ProcessReplica()
-{
- SCA_IActuator::ProcessReplica();
- // increment reference count so that we can release the generator at the end
- m_base->AddRef();
-}
-
-
-
-bool SCA_RandomActuator::Update()
-{
- //bool result = false; /*unused*/
- bool bNegativeEvent = IsNegativeEvent();
-
- RemoveAllEvents();
-
-
- CValue *tmpval = NULL;
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
-
- switch (m_distribution) {
- case KX_RANDOMACT_BOOL_CONST: {
- /* un petit peu filthy */
- bool res = !(m_parameter1 < 0.5);
- tmpval = new CBoolValue(res);
- }
- break;
- case KX_RANDOMACT_BOOL_UNIFORM: {
- /* flip a coin */
- bool res;
- if (m_counter > 31) {
- m_previous = m_base->Draw();
- res = ((m_previous & 0x1) == 0);
- m_counter = 1;
- } else {
- res = (((m_previous >> m_counter) & 0x1) == 0);
- m_counter++;
- }
- tmpval = new CBoolValue(res);
- }
- break;
- case KX_RANDOMACT_BOOL_BERNOUILLI: {
- /* 'percentage' */
- bool res;
- res = (m_base->DrawFloat() < m_parameter1);
- tmpval = new CBoolValue(res);
- }
- break;
- case KX_RANDOMACT_INT_CONST: {
- /* constant */
- tmpval = new CIntValue((int) floor(m_parameter1));
- }
- break;
- case KX_RANDOMACT_INT_UNIFORM: {
- /* uniform (toss a die) */
- int res;
- /* The [0, 1] interval is projected onto the [min, max+1] domain, */
- /* and then rounded. */
- res = (int)floor( ((m_parameter2 - m_parameter1 + 1) * m_base->DrawFloat()) + m_parameter1);
- tmpval = new CIntValue(res);
- }
- break;
- case KX_RANDOMACT_INT_POISSON: {
- /* poisson (queues) */
- /* If x_1, x_2, ... is a sequence of random numbers with uniform */
- /* distribution between zero and one, k is the first integer for */
- /* which the product x_1*x_2*...*x_k < exp(-\lamba). */
- float a, b;
- int res = 0;
- /* The - sign is important here! The number to test for, a, must be */
- /* between 0 and 1. */
- a = exp(-m_parameter1);
- /* a quickly reaches 0.... so we guard explicitly for that. */
- if (a < FLT_MIN) a = FLT_MIN;
- b = m_base->DrawFloat();
- while (b >= a) {
- b = b * m_base->DrawFloat();
- res++;
- };
- tmpval = new CIntValue(res);
- }
- break;
- case KX_RANDOMACT_FLOAT_CONST: {
- /* constant */
- tmpval = new CFloatValue(m_parameter1);
- }
- break;
- case KX_RANDOMACT_FLOAT_UNIFORM: {
- float res = ((m_parameter2 - m_parameter1) * m_base->DrawFloat()) + m_parameter1;
- tmpval = new CFloatValue(res);
- }
- break;
- case KX_RANDOMACT_FLOAT_NORMAL: {
- /* normal (big numbers): para1 = mean, para2 = std dev */
-
- /* 070301 - nzc: Changed the termination condition. I think I
- * made a small mistake here, but it only affects distro's where
- * the seed equals 0. In that case, the algorithm locks. Let's
- * just guard that case separately.
- */
-
- float x = 0.0, y = 0.0, s = 0.0, t = 0.0;
- if (m_base->GetSeed() == 0) {
- /* 070301 - nzc: Just taking the mean here seems reasonable. */
- tmpval = new CFloatValue(m_parameter1);
- }
- else {
- /* 070301 - nzc
- * Now, with seed != 0, we will most assuredly get some
- * sensible values. The termination condition states two
- * things:
- * 1. s >= 0 is not allowed: to prevent the distro from
- * getting a bias towards high values. This is a small
- * correction, really, and might also be left out.
- * 2. s == 0 is not allowed: to prevent a division by zero
- * when renormalising the drawn value to the desired
- * distribution shape. As a side effect, the distro will
- * never yield the exact mean.
- * I am not sure whether this is consistent, since the error
- * cause by #2 is of the same magnitude as the one
- * prevented by #1. The error introduced into the SD will be
- * improved, though. By how much? Hard to say... If you like
- * the maths, feel free to analyse. Be aware that this is
- * one of the really old standard algorithms. I think the
- * original came in Fortran, was translated to Pascal, and
- * then someone came up with the C code. My guess it that
- * this will be quite sufficient here.
- */
- do {
- x = 2.0f * m_base->DrawFloat() - 1.0f;
- y = 2.0f * m_base->DrawFloat() - 1.0f;
- s = x * x + y * y;
- } while ((s >= 1.0f) || (s == 0.0f));
- t = x * sqrtf((-2.0 * log(s)) / s);
- tmpval = new CFloatValue(m_parameter1 + m_parameter2 * t);
- }
- }
- break;
- case KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL: {
- /* 1st order fall-off. I am very partial to using the half-life as */
- /* controlling parameter. Using the 'normal' exponent is not very */
- /* intuitive... */
- /* tmpval = new CFloatValue( (1.0 / m_parameter1) */
- tmpval = new CFloatValue((m_parameter1) * (-log(1.0 - m_base->DrawFloat())));
-
- }
- break;
- default:
- {
- /* unknown distribution... */
- static bool randomWarning = false;
- if (!randomWarning) {
- randomWarning = true;
- std::cout << "RandomActuator '" << GetName() << "' has an unknown distribution." << std::endl;
- }
- return false;
- }
- }
-
- /* Round up: assign it */
- CValue *prop = GetParent()->GetProperty(m_propname);
- if (prop) {
- prop->SetValue(tmpval);
- }
- tmpval->Release();
-
- return false;
-}
-
-void SCA_RandomActuator::enforceConstraints()
-{
- /* The constraints that are checked here are the ones fundamental to */
- /* the various distributions. Limitations of the algorithms are checked */
- /* elsewhere (or they should be... ). */
- switch (m_distribution) {
- case KX_RANDOMACT_BOOL_CONST:
- case KX_RANDOMACT_BOOL_UNIFORM:
- case KX_RANDOMACT_INT_CONST:
- case KX_RANDOMACT_INT_UNIFORM:
- case KX_RANDOMACT_FLOAT_UNIFORM:
- case KX_RANDOMACT_FLOAT_CONST:
- ; /* Nothing to be done here. We allow uniform distro's to have */
- /* 'funny' domains, i.e. max < min. This does not give problems. */
- break;
- case KX_RANDOMACT_BOOL_BERNOUILLI:
- /* clamp to [0, 1] */
- if (m_parameter1 < 0.0) {
- m_parameter1 = 0.0;
- } else if (m_parameter1 > 1.0) {
- m_parameter1 = 1.0;
- }
- break;
- case KX_RANDOMACT_INT_POISSON:
- /* non-negative */
- if (m_parameter1 < 0.0) {
- m_parameter1 = 0.0;
- }
- break;
- case KX_RANDOMACT_FLOAT_NORMAL:
- /* standard dev. is non-negative */
- if (m_parameter2 < 0.0) {
- m_parameter2 = 0.0;
- }
- break;
- case KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL:
- /* halflife must be non-negative */
- if (m_parameter1 < 0.0) {
- m_parameter1 = 0.0;
- }
- break;
- default:
- ; /* unknown distribution... */
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_RandomActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_RandomActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_RandomActuator::Methods[] = {
- KX_PYMETHODTABLE(SCA_RandomActuator, setBoolConst),
- KX_PYMETHODTABLE_NOARGS(SCA_RandomActuator, setBoolUniform),
- KX_PYMETHODTABLE(SCA_RandomActuator, setBoolBernouilli),
-
- KX_PYMETHODTABLE(SCA_RandomActuator, setIntConst),
- KX_PYMETHODTABLE(SCA_RandomActuator, setIntUniform),
- KX_PYMETHODTABLE(SCA_RandomActuator, setIntPoisson),
-
- KX_PYMETHODTABLE(SCA_RandomActuator, setFloatConst),
- KX_PYMETHODTABLE(SCA_RandomActuator, setFloatUniform),
- KX_PYMETHODTABLE(SCA_RandomActuator, setFloatNormal),
- KX_PYMETHODTABLE(SCA_RandomActuator, setFloatNegativeExponential),
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_RandomActuator::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RO("para1",SCA_RandomActuator,m_parameter1),
- KX_PYATTRIBUTE_FLOAT_RO("para2",SCA_RandomActuator,m_parameter2),
- KX_PYATTRIBUTE_ENUM_RO("distribution",SCA_RandomActuator,m_distribution),
- KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,MAX_PROP_NAME,false,SCA_RandomActuator,m_propname,CheckProperty),
- KX_PYATTRIBUTE_RW_FUNCTION("seed",SCA_RandomActuator,pyattr_get_seed,pyattr_set_seed),
- { NULL } //Sentinel
-};
-
-PyObject *SCA_RandomActuator::pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_RandomActuator* act = static_cast<SCA_RandomActuator*>(self);
- return PyLong_FromLong(act->m_base->GetSeed());
-}
-
-int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- SCA_RandomActuator* act = static_cast<SCA_RandomActuator*>(self);
- if (PyLong_Check(value)) {
- act->m_base->SetSeed(PyLong_AsLong(value));
- return PY_SET_ATTR_SUCCESS;
- }
- else {
- PyErr_SetString(PyExc_TypeError, "actuator.seed = int: Random Actuator, expected an integer");
- return PY_SET_ATTR_FAIL;
- }
-}
-
-/* 11. setBoolConst */
-KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setBoolConst,
-"setBoolConst(value)\n"
-"\t- value: 0 or 1\n"
-"\tSet this generator to produce a constant boolean value.\n")
-{
- int paraArg;
- if (!PyArg_ParseTuple(args, "i:setBoolConst", &paraArg)) {
- return NULL;
- }
-
- m_distribution = KX_RANDOMACT_BOOL_CONST;
- m_parameter1 = (paraArg) ? 1.0 : 0.0;
-
- Py_RETURN_NONE;
-}
-/* 12. setBoolUniform, */
-KX_PYMETHODDEF_DOC_NOARGS(SCA_RandomActuator, setBoolUniform,
-"setBoolUniform()\n"
-"\tSet this generator to produce true and false, each with 50%% chance of occurring\n")
-{
- /* no args */
- m_distribution = KX_RANDOMACT_BOOL_UNIFORM;
- enforceConstraints();
- Py_RETURN_NONE;
-}
-/* 13. setBoolBernouilli, */
-KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setBoolBernouilli,
-"setBoolBernouilli(value)\n"
-"\t- value: a float between 0 and 1\n"
-"\tReturn false value * 100%% of the time.\n")
-{
- float paraArg;
- if (!PyArg_ParseTuple(args, "f:setBoolBernouilli", &paraArg)) {
- return NULL;
- }
-
- m_distribution = KX_RANDOMACT_BOOL_BERNOUILLI;
- m_parameter1 = paraArg;
- enforceConstraints();
- Py_RETURN_NONE;
-}
-/* 14. setIntConst,*/
-KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setIntConst,
-"setIntConst(value)\n"
-"\t- value: integer\n"
-"\tAlways return value\n")
-{
- int paraArg;
- if (!PyArg_ParseTuple(args, "i:setIntConst", &paraArg)) {
- return NULL;
- }
-
- m_distribution = KX_RANDOMACT_INT_CONST;
- m_parameter1 = paraArg;
- enforceConstraints();
- Py_RETURN_NONE;
-}
-/* 15. setIntUniform,*/
-KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setIntUniform,
-"setIntUniform(lower_bound, upper_bound)\n"
-"\t- lower_bound: integer\n"
-"\t- upper_bound: integer\n"
-"\tReturn a random integer between lower_bound and\n"
-"\tupper_bound. The boundaries are included.\n")
-{
- int paraArg1, paraArg2;
- if (!PyArg_ParseTuple(args, "ii:setIntUniform", &paraArg1, &paraArg2)) {
- return NULL;
- }
-
- m_distribution = KX_RANDOMACT_INT_UNIFORM;
- m_parameter1 = paraArg1;
- m_parameter2 = paraArg2;
- enforceConstraints();
- Py_RETURN_NONE;
-}
-/* 16. setIntPoisson, */
-KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setIntPoisson,
-"setIntPoisson(value)\n"
-"\t- value: float\n"
-"\tReturn a Poisson-distributed number. This performs a series\n"
-"\tof Bernouilli tests with parameter value. It returns the\n"
-"\tnumber of tries needed to achieve succes.\n")
-{
- float paraArg;
- if (!PyArg_ParseTuple(args, "f:setIntPoisson", &paraArg)) {
- return NULL;
- }
-
- m_distribution = KX_RANDOMACT_INT_POISSON;
- m_parameter1 = paraArg;
- enforceConstraints();
- Py_RETURN_NONE;
-}
-/* 17. setFloatConst */
-KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatConst,
-"setFloatConst(value)\n"
-"\t- value: float\n"
-"\tAlways return value\n")
-{
- float paraArg;
- if (!PyArg_ParseTuple(args, "f:setFloatConst", &paraArg)) {
- return NULL;
- }
-
- m_distribution = KX_RANDOMACT_FLOAT_CONST;
- m_parameter1 = paraArg;
- enforceConstraints();
- Py_RETURN_NONE;
-}
-/* 18. setFloatUniform, */
-KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatUniform,
-"setFloatUniform(lower_bound, upper_bound)\n"
-"\t- lower_bound: float\n"
-"\t- upper_bound: float\n"
-"\tReturn a random integer between lower_bound and\n"
-"\tupper_bound.\n")
-{
- float paraArg1, paraArg2;
- if (!PyArg_ParseTuple(args, "ff:setFloatUniform", &paraArg1, &paraArg2)) {
- return NULL;
- }
-
- m_distribution = KX_RANDOMACT_FLOAT_UNIFORM;
- m_parameter1 = paraArg1;
- m_parameter2 = paraArg2;
- enforceConstraints();
- Py_RETURN_NONE;
-}
-/* 19. setFloatNormal, */
-KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNormal,
-"setFloatNormal(mean, standard_deviation)\n"
-"\t- mean: float\n"
-"\t- standard_deviation: float\n"
-"\tReturn normal-distributed numbers. The average is mean, and the\n"
-"\tdeviation from the mean is characterized by standard_deviation.\n")
-{
- float paraArg1, paraArg2;
- if (!PyArg_ParseTuple(args, "ff:setFloatNormal", &paraArg1, &paraArg2)) {
- return NULL;
- }
-
- m_distribution = KX_RANDOMACT_FLOAT_NORMAL;
- m_parameter1 = paraArg1;
- m_parameter2 = paraArg2;
- enforceConstraints();
- Py_RETURN_NONE;
-}
-/* 20. setFloatNegativeExponential, */
-KX_PYMETHODDEF_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential,
-"setFloatNegativeExponential(half_life)\n"
-"\t- half_life: float\n"
-"\tReturn negative-exponentially distributed numbers. The half-life 'time'\n"
-"\tis characterized by half_life.\n")
-{
- float paraArg;
- if (!PyArg_ParseTuple(args, "f:setFloatNegativeExponential", &paraArg)) {
- return NULL;
- }
-
- m_distribution = KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL;
- m_parameter1 = paraArg;
- enforceConstraints();
- Py_RETURN_NONE;
-}
-
-#endif
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h
deleted file mode 100644
index 32b29fc4f43..00000000000
--- a/source/gameengine/GameLogic/SCA_RandomActuator.h
+++ /dev/null
@@ -1,120 +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 SCA_RandomActuator.h
- * \ingroup gamelogic
- * \brief Draw a random number, and put it in a property
- */
-
-#ifndef __SCA_RANDOMACTUATOR_H__
-#define __SCA_RANDOMACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "SCA_RandomNumberGenerator.h"
-
-class SCA_RandomActuator : public SCA_IActuator
-{
- Py_Header
- /** Property to assign to */
- STR_String m_propname;
-
- /** First parameter. The meaning of the parameters depends on the
- * distribution */
- float m_parameter1;
- /** Second parameter. The meaning of the parameters depends on the
- * distribution */
- float m_parameter2;
-
- /** The base generator */
- SCA_RandomNumberGenerator *m_base;
-
- /** just a generic, persistent counter */
- int m_counter;
-
- /** cache for the previous draw */
- long m_previous;
-
- /** apply constraints for the chosen distribution to the parameters */
- void enforceConstraints(void);
-
- public:
-
- enum KX_RANDOMACT_MODE {
- KX_RANDOMACT_NODEF,
- KX_RANDOMACT_BOOL_CONST,
- KX_RANDOMACT_BOOL_UNIFORM,
- KX_RANDOMACT_BOOL_BERNOUILLI,
- KX_RANDOMACT_INT_CONST,
- KX_RANDOMACT_INT_UNIFORM,
- KX_RANDOMACT_INT_POISSON,
- KX_RANDOMACT_FLOAT_CONST,
- KX_RANDOMACT_FLOAT_UNIFORM,
- KX_RANDOMACT_FLOAT_NORMAL,
- KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL,
- KX_RANDOMACT_MAX
- };
- /** distribution type */
- KX_RANDOMACT_MODE m_distribution;
-
- SCA_RandomActuator(class SCA_IObject* gameobj,
- long seed,
- KX_RANDOMACT_MODE mode,
- float para1,
- float para2,
- const STR_String &propName);
- virtual ~SCA_RandomActuator();
- virtual bool Update();
-
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- static PyObject *pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setBoolConst);
- KX_PYMETHOD_DOC_NOARGS(SCA_RandomActuator, setBoolUniform);
- KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setBoolBernouilli);
- KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setIntConst);
- KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setIntUniform);
- KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setIntPoisson);
- KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatConst);
- KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatUniform);
- KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatNormal);
- KX_PYMETHOD_DOC_VARARGS(SCA_RandomActuator, setFloatNegativeExponential);
-
-#endif /* WITH_PYTHON */
-
-}; /* end of class KX_EditObjectActuator : public SCA_PropertyActuator */
-
-#endif
-
diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
deleted file mode 100644
index 2ec6eb1db1b..00000000000
--- a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Manager for random events
- *
- *
- * ***** 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/GameLogic/SCA_RandomEventManager.cpp
- * \ingroup gamelogic
- */
-
-#include "SCA_RandomEventManager.h"
-#include "SCA_LogicManager.h"
-#include "SCA_ISensor.h"
-#include <vector>
-using namespace std;
-
-#include <iostream>
-#include <stdio.h>
-
-SCA_RandomEventManager::SCA_RandomEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(logicmgr, RANDOM_EVENTMGR)
-{
-}
-
-
-void SCA_RandomEventManager::NextFrame()
-{
- SG_DList::iterator<SCA_ISensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- (*it)->Activate(m_logicmgr);
- }
-}
-
diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.h b/source/gameengine/GameLogic/SCA_RandomEventManager.h
deleted file mode 100644
index 2d83c5fcdca..00000000000
--- a/source/gameengine/GameLogic/SCA_RandomEventManager.h
+++ /dev/null
@@ -1,54 +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 SCA_RandomEventManager.h
- * \ingroup gamelogic
- * \brief Manager for random events
- */
-
-#ifndef __SCA_RANDOMEVENTMANAGER_H__
-#define __SCA_RANDOMEVENTMANAGER_H__
-
-#include "SCA_EventManager.h"
-#include <vector>
-
-using namespace std;
-
-class SCA_RandomEventManager : public SCA_EventManager
-{
-public:
- SCA_RandomEventManager(class SCA_LogicManager* logicmgr);
-
- virtual void NextFrame();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_RandomEventManager")
-#endif
-};
-
-#endif /* __SCA_RANDOMEVENTMANAGER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp
deleted file mode 100644
index eca678f4e89..00000000000
--- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/** \file gameengine/GameLogic/SCA_RandomNumberGenerator.cpp
- * \ingroup gamelogic
- */
-/**
- * Generate random numbers that can be used by other components. We
- * convert to different types/distributions elsewhere. This just
- * delivers a clean, random bitvector.
- *
- */
-
-/* A C-program for MT19937: Real number version */
-/* genrand() generates one pseudorandom real number (double) */
-/* which is uniformly distributed on [0,1]-interval, for each */
-/* call. sgenrand(seed) set initial values to the working area */
-/* of 624 words. Before genrand(), sgenrand(seed) must be */
-/* called once. (seed is any 32-bit integer except for 0). */
-/* Integer generator is obtained by modifying two lines. */
-/* Coded by Takuji Nishimura, considering the suggestions by */
-/* Topher Cooper and Marc Rieffel in July-Aug. 1997. */
-
-/* This library is free software; you can redistribute it and/or */
-/* modify it under the terms of the GNU Library General Public */
-/* License as published by the Free Software Foundation; either */
-/* version 2 of the License, or (at your option) any later */
-/* version. */
-/* 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 GNU Library General Public License for more details. */
-/* You should have received a copy of the GNU Library General */
-/* Public License along with this library; if not, write to the */
-/* Free Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA */
-/* 02110-1301, USA */
-
-/* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. */
-/* When you use this, send an email to: matumoto@math.keio.ac.jp */
-/* with an appropriate reference to your work. */
-
-#include <limits.h>
-#include "SCA_RandomNumberGenerator.h"
-
-/* Period parameters */
-#define N 624
-#define M 397
-#define MATRIX_A 0x9908b0df /* constant vector a */
-#define UPPER_MASK 0x80000000 /* most significant w-r bits */
-#define LOWER_MASK 0x7fffffff /* least significant r bits */
-
-/* Tempering parameters */
-#define TEMPERING_MASK_B 0x9d2c5680
-#define TEMPERING_MASK_C 0xefc60000
-#define TEMPERING_SHIFT_U(y) (y >> 11)
-#define TEMPERING_SHIFT_S(y) (y << 7)
-#define TEMPERING_SHIFT_T(y) (y << 15)
-#define TEMPERING_SHIFT_L(y) (y >> 18)
-
-SCA_RandomNumberGenerator::SCA_RandomNumberGenerator(long seed)
-{
- // int mti = N + 1; /*unused*/
- m_seed = seed;
- m_refcount = 1;
- SetStartVector();
-}
-
-SCA_RandomNumberGenerator::~SCA_RandomNumberGenerator()
-{
- /* intentionally empty */
-}
-
-void SCA_RandomNumberGenerator::SetStartVector(void)
-{
- /* setting initial seeds to mt[N] using */
- /* the generator Line 25 of Table 1 in */
- /* [KNUTH 1981, The Art of Computer Programming */
- /* Vol. 2 (2nd Ed.), pp102] */
- mt[0] = m_seed & 0xffffffff;
- for (mti = 1; mti < N; mti++)
- mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
-}
-
-long SCA_RandomNumberGenerator::GetSeed() { return m_seed; }
-void SCA_RandomNumberGenerator::SetSeed(long newseed)
-{
- m_seed = newseed;
- SetStartVector();
-}
-
-/**
- * This is the important part: copied verbatim :)
- */
-unsigned long SCA_RandomNumberGenerator::Draw()
-{
- static unsigned long mag01[2] = { 0x0, MATRIX_A };
- /* mag01[x] = x * MATRIX_A for x=0,1 */
-
- unsigned long y;
-
- if (mti >= N) { /* generate N words at one time */
- int kk;
-
- /* I set this in the constructor, so it is always satisfied ! */
- // if (mti == N+1) /* if sgenrand() has not been called, */
- // GEN_srand(4357); /* a default initial seed is used */
-
- for (kk = 0; kk < N - M; kk++) {
- y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
- mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1];
- }
- for (; kk < N-1; kk++) {
- y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
- mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1];
- }
- y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK);
- mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1];
-
- mti = 0;
- }
-
- y = mt[mti++];
- y ^= TEMPERING_SHIFT_U(y);
- y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B;
- y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
- y ^= TEMPERING_SHIFT_L(y);
-
- return y;
-}
-
-float SCA_RandomNumberGenerator::DrawFloat()
-{
- return ( (float) Draw()/ (unsigned long) 0xffffffff );
-}
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h
deleted file mode 100644
index 10818cb4e8f..00000000000
--- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h
+++ /dev/null
@@ -1,85 +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 SCA_RandomNumberGenerator.h
- * \ingroup gamelogic
- * \brief Generate random numbers that can be used by other components. Each
- * generator needs its own generator, so that the seed can be set
- * on a per-generator basis.
- */
-
-#ifndef __SCA_RANDOMNUMBERGENERATOR_H__
-#define __SCA_RANDOMNUMBERGENERATOR_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class SCA_RandomNumberGenerator {
-
- /* reference counted for memleak */
- int m_refcount;
-
- /** base seed */
- long m_seed;
-
- /* A bit silly.. The N parameter is a define in the .cpp file */
- /** the array for the state vector */
- /* unsigned long mt[N]; */
- unsigned long mt[624];
-
- /** mti==N+1 means mt[KX_MT_VectorLength] is not initialized */
- int mti; /* initialized in the cpp file */
-
- /** Calculate a start vector */
- void SetStartVector(void);
- public:
- SCA_RandomNumberGenerator(long seed);
- ~SCA_RandomNumberGenerator();
- unsigned long Draw();
- float DrawFloat();
- long GetSeed();
- void SetSeed(long newseed);
- SCA_RandomNumberGenerator* AddRef()
- {
- ++m_refcount;
- return this;
- }
- void Release()
- {
- if (--m_refcount == 0)
- delete this;
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_RandomNumberGenerator")
-#endif
-};
-
-#endif /* __SCA_RANDOMNUMBERGENERATOR_H__ */
-
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
deleted file mode 100644
index 8f2dc8d80f5..00000000000
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Generate random pulses
- *
- *
- * ***** 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/GameLogic/SCA_RandomSensor.cpp
- * \ingroup gamelogic
- */
-
-
-#include <stddef.h>
-
-#include "SCA_RandomSensor.h"
-#include "SCA_EventManager.h"
-#include "SCA_RandomEventManager.h"
-#include "SCA_LogicManager.h"
-#include "EXP_ConstExpr.h"
-#include <iostream>
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- int startseed)
- : SCA_ISensor(gameobj,eventmgr)
-{
- m_basegenerator = new SCA_RandomNumberGenerator(startseed);
- Init();
-}
-
-
-
-SCA_RandomSensor::~SCA_RandomSensor()
-{
- m_basegenerator->Release();
-}
-
-void SCA_RandomSensor::Init()
-{
- m_iteration = 0;
- m_interval = 0;
- m_lastdraw = false;
- m_currentDraw = m_basegenerator->Draw();
-}
-
-
-CValue* SCA_RandomSensor::GetReplica()
-{
- CValue* replica = new SCA_RandomSensor(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-void SCA_RandomSensor::ProcessReplica()
-{
- SCA_ISensor::ProcessReplica();
- // increment reference count so that we can release the generator at this end
- m_basegenerator->AddRef();
-}
-
-
-bool SCA_RandomSensor::IsPositiveTrigger()
-{
- return (m_invert !=m_lastdraw);
-}
-
-
-bool SCA_RandomSensor::Evaluate()
-{
- /* Random generator is the generator from Line 25 of Table 1 in */
- /* [KNUTH 1981, The Art of Computer Programming Vol. 2 */
- /* (2nd Ed.), pp102] */
- /* It's a very simple max. length sequence generator. We can */
- /* draw 32 bool values before having to generate the next */
- /* sequence value. There are some theorems that will tell you */
- /* this is a reasonable way of generating bools. Check Knuth. */
- /* Furthermore, we only draw each <delay>-eth frame. */
-
- bool evaluateResult = false;
-
- if (++m_interval > m_skipped_ticks) {
- bool drawResult = false;
- m_interval = 0;
- if (m_iteration > 31) {
- m_currentDraw = m_basegenerator->Draw();
- drawResult = (m_currentDraw & 0x1) == 0;
- m_iteration = 1;
- } else {
- drawResult = ((m_currentDraw >> m_iteration) & 0x1) == 0;
- m_iteration++;
- }
- evaluateResult = drawResult != m_lastdraw;
- m_lastdraw = drawResult;
- }
-
- /* now pass this result to some controller */
- return evaluateResult;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_RandomSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_RandomSensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_RandomSensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_RandomSensor::Attributes[] = {
- KX_PYATTRIBUTE_BOOL_RO("lastDraw",SCA_RandomSensor,m_lastdraw),
- KX_PYATTRIBUTE_RW_FUNCTION("seed", SCA_RandomSensor, pyattr_get_seed, pyattr_set_seed),
- {NULL} //Sentinel
-};
-
-PyObject *SCA_RandomSensor::pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- SCA_RandomSensor* self = static_cast<SCA_RandomSensor*>(self_v);
- return PyLong_FromLong(self->m_basegenerator->GetSeed());
-}
-
-int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- SCA_RandomSensor* self = static_cast<SCA_RandomSensor*>(self_v);
- if (!PyLong_Check(value)) {
- PyErr_SetString(PyExc_TypeError, "sensor.seed = int: Random Sensor, expected an integer");
- return PY_SET_ATTR_FAIL;
- }
- self->m_basegenerator->SetSeed(PyLong_AsLong(value));
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h
deleted file mode 100644
index 66107b7b74b..00000000000
--- a/source/gameengine/GameLogic/SCA_RandomSensor.h
+++ /dev/null
@@ -1,71 +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 SCA_RandomSensor.h
- * \ingroup gamelogic
- * \brief Generate random pulses
- */
-
-#ifndef __SCA_RANDOMSENSOR_H__
-#define __SCA_RANDOMSENSOR_H__
-
-#include "SCA_ISensor.h"
-#include "EXP_BoolValue.h"
-#include "SCA_RandomNumberGenerator.h"
-
-class SCA_RandomSensor : public SCA_ISensor
-{
- Py_Header
-
- unsigned int m_currentDraw;
- int m_iteration;
- int m_interval;
- SCA_RandomNumberGenerator *m_basegenerator;
- bool m_lastdraw;
-public:
- SCA_RandomSensor(class SCA_EventManager* rndmgr,
- SCA_IObject* gameobj,
- int startseed);
- virtual ~SCA_RandomSensor();
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
- virtual void Init();
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- static PyObject* pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif
-};
-
-#endif /* __SCA_RANDOMSENSOR_H__ */
diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
deleted file mode 100644
index c56a1496823..00000000000
--- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
+++ /dev/null
@@ -1,120 +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/GameLogic/SCA_TimeEventManager.cpp
- * \ingroup gamelogic
- */
-
-#ifdef _MSC_VER
- /* This warning tells us about truncation of __long__ stl-generated names.
- * It can occasionally cause DevStudio to have internal compiler warnings. */
-# pragma warning(disable:4786)
-#endif
-
-#include "SCA_TimeEventManager.h"
-
-#include "SCA_LogicManager.h"
-#include "EXP_FloatValue.h"
-
-SCA_TimeEventManager::SCA_TimeEventManager(SCA_LogicManager* logicmgr)
-: SCA_EventManager(NULL, TIME_EVENTMGR)
-{
-}
-
-
-
-SCA_TimeEventManager::~SCA_TimeEventManager()
-{
- for (vector<CValue*>::iterator it = m_timevalues.begin();
- !(it == m_timevalues.end()); ++it)
- {
- (*it)->Release();
- }
-}
-
-
-
-void SCA_TimeEventManager::RegisterSensor(SCA_ISensor* sensor)
-{
- // not yet
-}
-
-void SCA_TimeEventManager::RemoveSensor(SCA_ISensor* sensor)
-{
- // empty
-}
-
-
-
-void SCA_TimeEventManager::NextFrame(double curtime, double fixedtime)
-{
- if (m_timevalues.size() > 0 && fixedtime > 0.0)
- {
- CFloatValue* floatval = new CFloatValue(curtime);
-
- // update sensors, but ... need deltatime !
- for (vector<CValue*>::iterator it = m_timevalues.begin();
- !(it == m_timevalues.end()); ++it)
- {
- float newtime = (*it)->GetNumber() + fixedtime;
- floatval->SetFloat(newtime);
- (*it)->SetValue(floatval);
- }
-
- floatval->Release();
- }
-}
-
-
-
-void SCA_TimeEventManager::AddTimeProperty(CValue* timeval)
-{
- timeval->AddRef();
- m_timevalues.push_back(timeval);
-}
-
-
-
-void SCA_TimeEventManager::RemoveTimeProperty(CValue* timeval)
-{
- for (vector<CValue*>::iterator it = m_timevalues.begin();
- !(it == m_timevalues.end()); ++it)
- {
- if ((*it) == timeval)
- {
- this->m_timevalues.erase(it);
- timeval->Release();
- break;
- }
- }
-}
-
-vector<CValue*> SCA_TimeEventManager::GetTimeValues()
-{
- return m_timevalues;
-}
-
diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.h b/source/gameengine/GameLogic/SCA_TimeEventManager.h
deleted file mode 100644
index 38d7e3fc4d4..00000000000
--- a/source/gameengine/GameLogic/SCA_TimeEventManager.h
+++ /dev/null
@@ -1,62 +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 SCA_TimeEventManager.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_TIMEEVENTMANAGER_H__
-#define __SCA_TIMEEVENTMANAGER_H__
-
-#include "SCA_EventManager.h"
-#include "EXP_Value.h"
-#include <vector>
-
-using namespace std;
-
-class SCA_TimeEventManager : public SCA_EventManager
-{
- vector<CValue*> m_timevalues; // values that need their time updated regularly
-
-public:
- SCA_TimeEventManager(class SCA_LogicManager* logicmgr);
- virtual ~SCA_TimeEventManager();
-
- virtual void NextFrame(double curtime, double fixedtime);
- virtual void RegisterSensor(class SCA_ISensor* sensor);
- virtual void RemoveSensor(class SCA_ISensor* sensor);
- void AddTimeProperty(CValue* timeval);
- void RemoveTimeProperty(CValue* timeval);
-
- vector<CValue*> GetTimeValues();
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_TimeEventManager")
-#endif
-};
-
-#endif /* __SCA_TIMEEVENTMANAGER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp
deleted file mode 100644
index f97d11cabf3..00000000000
--- a/source/gameengine/GameLogic/SCA_XNORController.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 'Xnor' together all inputs
- *
- *
- * ***** 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/GameLogic/SCA_XNORController.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_XNORController.h"
-#include "SCA_ISensor.h"
-#include "SCA_LogicManager.h"
-#include "EXP_BoolValue.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_XNORController::SCA_XNORController(SCA_IObject* gameobj)
- :
- SCA_IController(gameobj)
-{
-}
-
-
-
-SCA_XNORController::~SCA_XNORController()
-{
-}
-
-
-
-void SCA_XNORController::Trigger(SCA_LogicManager* logicmgr)
-{
-
- bool sensorresult = true;
-
- for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
- !(is==m_linkedsensors.end());is++)
- {
- SCA_ISensor* sensor = *is;
- if (sensor->GetState())
- {
- if (sensorresult == false)
- {
- sensorresult = true;
- break;
- }
- sensorresult = false;
- }
- }
-
- for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
- !(i==m_linkedactuators.end());i++)
- {
- SCA_IActuator* actua = *i;
- logicmgr->AddActiveActuator(actua,sensorresult);
- }
-}
-
-
-
-CValue* SCA_XNORController::GetReplica()
-{
- CValue* replica = new SCA_XNORController(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_XNORController::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_XNORController",
- 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,
- &SCA_IController::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_XNORController::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_XNORController::Attributes[] = {
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_XNORController.h b/source/gameengine/GameLogic/SCA_XNORController.h
deleted file mode 100644
index c257b71273e..00000000000
--- a/source/gameengine/GameLogic/SCA_XNORController.h
+++ /dev/null
@@ -1,53 +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 SCA_XNORController.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_XNORCONTROLLER_H__
-#define __SCA_XNORCONTROLLER_H__
-
-#include "SCA_IController.h"
-
-class SCA_XNORController : public SCA_IController
-{
- Py_Header
- //virtual void Trigger(class SCA_LogicManager* logicmgr);
-public:
- SCA_XNORController(SCA_IObject* gameobj);
- virtual ~SCA_XNORController();
- virtual CValue* GetReplica();
- virtual void Trigger(SCA_LogicManager* logicmgr);
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
-};
-
-#endif /* __SCA_XNORCONTROLLER_H__ */
diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp
deleted file mode 100644
index bb1ea822bd8..00000000000
--- a/source/gameengine/GameLogic/SCA_XORController.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 'Xor' together all inputs
- *
- *
- * ***** 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/GameLogic/SCA_XORController.cpp
- * \ingroup gamelogic
- */
-
-
-#include "SCA_XORController.h"
-#include "SCA_ISensor.h"
-#include "SCA_LogicManager.h"
-#include "EXP_BoolValue.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-SCA_XORController::SCA_XORController(SCA_IObject* gameobj)
- :
- SCA_IController(gameobj)
-{
-}
-
-
-
-SCA_XORController::~SCA_XORController()
-{
-}
-
-
-
-void SCA_XORController::Trigger(SCA_LogicManager* logicmgr)
-{
-
- bool sensorresult = false;
-
- for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
- !(is==m_linkedsensors.end());is++)
- {
- SCA_ISensor* sensor = *is;
- if (sensor->GetState())
- {
- if (sensorresult == true)
- {
- sensorresult = false;
- break;
- }
- sensorresult = true;
- }
- }
-
- for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
- !(i==m_linkedactuators.end());i++)
- {
- SCA_IActuator* actua = *i;
- logicmgr->AddActiveActuator(actua,sensorresult);
- }
-}
-
-
-
-CValue* SCA_XORController::GetReplica()
-{
- CValue* replica = new SCA_XORController(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject SCA_XORController::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SCA_XORController",
- 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,
- &SCA_IController::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef SCA_XORController::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef SCA_XORController::Attributes[] = {
- { NULL } //Sentinel
-};
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/GameLogic/SCA_XORController.h b/source/gameengine/GameLogic/SCA_XORController.h
deleted file mode 100644
index c64a3380ede..00000000000
--- a/source/gameengine/GameLogic/SCA_XORController.h
+++ /dev/null
@@ -1,48 +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 SCA_XORController.h
- * \ingroup gamelogic
- */
-
-#ifndef __SCA_XORCONTROLLER_H__
-#define __SCA_XORCONTROLLER_H__
-
-#include "SCA_IController.h"
-
-class SCA_XORController : public SCA_IController
-{
- Py_Header
- //virtual void Trigger(class SCA_LogicManager* logicmgr);
-public:
- SCA_XORController(SCA_IObject* gameobj);
- virtual ~SCA_XORController();
- virtual CValue* GetReplica();
- virtual void Trigger(SCA_LogicManager* logicmgr);
-};
-
-#endif /* __SCA_XORCONTROLLER_H__ */
diff --git a/source/gameengine/GamePlayer/CMakeLists.txt b/source/gameengine/GamePlayer/CMakeLists.txt
deleted file mode 100644
index e77609985dc..00000000000
--- a/source/gameengine/GamePlayer/CMakeLists.txt
+++ /dev/null
@@ -1,27 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-add_subdirectory(common)
-add_subdirectory(ghost)
diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt
deleted file mode 100644
index e6c980de566..00000000000
--- a/source/gameengine/GamePlayer/common/CMakeLists.txt
+++ /dev/null
@@ -1,75 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../ghost
- ../../BlenderRoutines
- ../../Converter
- ../../Expressions
- ../../GameLogic
- ../../Ketsji
- ../../Network
- ../../Network/LoopBackNetwork
- ../../Physics/common
- ../../Rasterizer
- ../../Rasterizer/RAS_OpenGLRasterizer
- ../../SceneGraph
- ../../../blender
- ../../../blender/blenfont
- ../../../blender/blenkernel
- ../../../blender/blenlib
- ../../../blender/blenloader
- ../../../blender/gpu
- ../../../blender/imbuf
- ../../../blender/makesdna
- ../../../../intern/container
- ../../../../intern/ghost
- ../../../../intern/glew-mx
- ../../../../intern/guardedalloc
- ../../../../intern/string
-)
-
-set(INC_SYS
- ../../../../intern/moto/include
- ${GLEW_INCLUDE_PATH}
- ${PYTHON_INCLUDE_DIRS}
- ${PNG_INCLUDE_DIRS}
- ${ZLIB_INCLUDE_DIRS}
-)
-
-set(SRC
- GPC_Canvas.cpp
- GPC_KeyboardDevice.cpp
- GPC_MouseDevice.cpp
-
- GPC_Canvas.h
- GPC_KeyboardDevice.h
- GPC_MouseDevice.h
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-blender_add_lib_nolist(ge_player_common "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
deleted file mode 100644
index 2b355407d46..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
+++ /dev/null
@@ -1,168 +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_Canvas.cpp
- * \ingroup player
- */
-
-
-#include "RAS_IPolygonMaterial.h"
-#include "GPC_Canvas.h"
-
-#include "DNA_scene_types.h"
-#include "DNA_space_types.h"
-
-#include "BKE_image.h"
-#include "MEM_guardedalloc.h"
-
-
-GPC_Canvas::GPC_Canvas(
- int width,
- int height
-) :
- m_width(width),
- m_height(height)
-{
- // initialize area so that it's available for game logic on frame 1 (ImageViewport)
- m_displayarea.m_x1 = 0;
- m_displayarea.m_y1 = 0;
- m_displayarea.m_x2 = width;
- m_displayarea.m_y2 = height;
- m_frame = 1;
-
- glGetIntegerv(GL_VIEWPORT, (GLint*)m_viewport);
-}
-
-
-GPC_Canvas::~GPC_Canvas()
-{
-}
-
-
-void GPC_Canvas::Resize(int width, int height)
-{
- m_width = width;
- m_height = height;
-
- // initialize area so that it's available for game logic on frame 1 (ImageViewport)
- m_displayarea.m_x1 = 0;
- m_displayarea.m_y1 = 0;
- m_displayarea.m_x2 = width;
- m_displayarea.m_y2 = height;
-}
-
-
-void GPC_Canvas::ClearColor(float r, float g, float b, float a)
-{
- ::glClearColor(r,g,b,a);
-}
-
-void GPC_Canvas::SetViewPort(int x1, int y1, int x2, int y2)
-{
- /* x1 and y1 are the min pixel coordinate (e.g. 0)
- x2 and y2 are the max pixel coordinate
- the width,height is calculated including both pixels
- therefore: max - min + 1
- */
-
- /* XXX, nasty, this needs to go somewhere else,
- * but where... definitely need to clean up this
- * whole canvas/rendertools mess.
- */
- glEnable(GL_SCISSOR_TEST);
-
- m_viewport[0] = x1;
- m_viewport[1] = y1;
- m_viewport[2] = x2-x1 + 1;
- m_viewport[3] = y2-y1 + 1;
-
- glViewport(x1,y1,x2-x1 + 1,y2-y1 + 1);
- glScissor(x1,y1,x2-x1 + 1,y2-y1 + 1);
-}
-
-void GPC_Canvas::UpdateViewPort(int x1, int y1, int x2, int y2)
-{
- m_viewport[0] = x1;
- m_viewport[1] = y1;
- m_viewport[2] = x2;
- m_viewport[3] = y2;
-}
-
-const int *GPC_Canvas::GetViewPort()
-{
-#ifdef DEBUG
- // If we're in a debug build, we might as well make sure our values don't differ
- // from what the gpu thinks we have. This could lead to nasty, hard to find bugs.
- int viewport[4];
- glGetIntegerv(GL_VIEWPORT, viewport);
- assert(viewport[0] == m_viewport[0]);
- assert(viewport[1] == m_viewport[1]);
- assert(viewport[2] == m_viewport[2]);
- assert(viewport[3] == m_viewport[3]);
-#endif
-
- return m_viewport;
-}
-
-void GPC_Canvas::ClearBuffer(
- int type
-) {
-
- int ogltype = 0;
- if (type & RAS_ICanvas::COLOR_BUFFER )
- ogltype |= GL_COLOR_BUFFER_BIT;
- if (type & RAS_ICanvas::DEPTH_BUFFER )
- ogltype |= GL_DEPTH_BUFFER_BIT;
-
- ::glClear(ogltype);
-}
-
- void
-GPC_Canvas::
-MakeScreenShot(
- const char* filename
-) {
- // copy image data
- unsigned int dumpsx = GetWidth();
- unsigned int dumpsy = GetHeight();
- unsigned int *pixels = (unsigned int *)MEM_mallocN(sizeof(int) * dumpsx * dumpsy, "pixels");
-
- if (!pixels) {
- std::cout << "Cannot allocate pixels array" << std::endl;
- return;
- }
-
- glReadPixels(0, 0, dumpsx, dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-
- // initialize image file format data
- ImageFormatData *im_format = (ImageFormatData *)MEM_mallocN(sizeof(ImageFormatData), "im_format");
- BKE_imformat_defaults(im_format);
-
- /* save_screenshot() frees dumprect and im_format */
- save_screenshot(filename, dumpsx, dumpsy, pixels, im_format);
-}
-
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h
deleted file mode 100644
index 688ed8ac0f4..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_Canvas.h
+++ /dev/null
@@ -1,147 +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_Canvas.h
- * \ingroup player
- */
-
-#ifndef __GPC_CANVAS_H__
-#define __GPC_CANVAS_H__
-
-#include "RAS_ICanvas.h"
-#include "RAS_Rect.h"
-
-#ifdef WIN32
-# pragma warning (disable:4786) // suppress stl-MSVC debug info warning
-# include <windows.h>
-#endif /* WIN32 */
-
-#include "GPU_glew.h"
-
-#include <map>
-
-
-class GPC_Canvas : public RAS_ICanvas
-{
-protected:
-
- /** Width of the context. */
- int m_width;
- /** Height of the context. */
- int m_height;
- /** Rect that defines the area used for rendering,
- * relative to the context */
- RAS_Rect m_displayarea;
-
- int m_viewport[4];
-
-public:
-
- GPC_Canvas(int width, int height);
-
- virtual ~GPC_Canvas();
-
- void Resize(int width, int height);
-
- virtual void ResizeWindow(int width, int height) {}
-
- virtual void GetDisplayDimensions(int &width, int &height) {}
-
- /**
- * \section Methods inherited from abstract base class RAS_ICanvas.
- */
-
- int
- GetWidth(
- ) const {
- return m_width;
- }
-
- int
- GetHeight(
- ) const {
- return m_height;
- }
-
- const
- RAS_Rect &
- GetDisplayArea(
- ) const {
- return m_displayarea;
- };
-
- void
- SetDisplayArea(
- RAS_Rect *rect
- ) {
- m_displayarea= *rect;
- };
-
- RAS_Rect &
- GetWindowArea(
- ) {
- return m_displayarea;
- }
-
- void
- BeginFrame(
- ) {};
-
- /**
- * Draws overlay banners and progress bars.
- */
- void
- EndFrame(
- ) {};
-
- void SetViewPort(int x1, int y1, int x2, int y2);
- void UpdateViewPort(int x1, int y1, int x2, int y2);
- const int *GetViewPort();
-
- void ClearColor(float r, float g, float b, float a);
-
- /**
- * \section Methods inherited from abstract base class RAS_ICanvas.
- * Semantics are not yet honored.
- */
-
- void SetMouseState(RAS_MouseState mousestate)
- {
- // not yet
- }
-
- void SetMousePosition(int x, int y)
- {
- // not yet
- }
-
- virtual void MakeScreenShot(const char* filename);
-
- void ClearBuffer(int type);
-};
-
-#endif /* __GPC_CANVAS_H__ */
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
deleted file mode 100644
index 0821d1d3b23..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
+++ /dev/null
@@ -1,128 +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_KeyboardDevice.cpp
- * \ingroup player
- */
-
-
-#include "GPC_KeyboardDevice.h"
-
-#include <cstdlib>
-
-/**
- * NextFrame toggles currentTable with previousTable,
- * and copies relevant event information from previous to current table
- * (pressed keys need to be remembered).
- */
-void GPC_KeyboardDevice::NextFrame()
-{
- SCA_IInputDevice::NextFrame();
-
- // Now convert justpressed key events into regular (active) keyevents
- int previousTable = 1-m_currentTable;
- for (int keyevent= KX_BEGINKEY; keyevent<= KX_ENDKEY;keyevent++)
- {
- SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][keyevent];
- if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- oldevent.m_status == SCA_InputEvent::KX_ACTIVE )
- {
- m_eventStatusTables[m_currentTable][keyevent] = oldevent;
- m_eventStatusTables[m_currentTable][keyevent].m_status = SCA_InputEvent::KX_ACTIVE;
- //m_eventStatusTables[m_currentTable][keyevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
- }
- }
-}
-
-
-
-/**
- * ConvertBPEvent translates Windows keyboard events into ketsji kbd events.
- * Extra event information is stored, like ramp-mode (just released/pressed)
- */
-bool GPC_KeyboardDevice::ConvertEvent(int incode, int val, unsigned int unicode)
-{
- bool result = false;
-
- // convert event
- KX_EnumInputs kxevent = this->ToNative(incode);
-
- // only process it, if it's a key
- if (kxevent >= KX_BEGINKEY && kxevent <= KX_ENDKEY)
- {
- int previousTable = 1-m_currentTable;
-
- if (val > 0)
- {
- if (kxevent == SCA_IInputDevice::KX_ESCKEY && val != 0 && !m_hookesc)
- result = true;
-
- // todo: convert val ??
- m_eventStatusTables[m_currentTable][kxevent].m_eventval = val ; //???
- m_eventStatusTables[m_currentTable][kxevent].m_unicode = unicode ;
-
- switch (m_eventStatusTables[previousTable][kxevent].m_status)
- {
- case SCA_InputEvent::KX_JUSTACTIVATED:
- case SCA_InputEvent::KX_ACTIVE:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
- break;
- }
-
- case SCA_InputEvent::KX_NO_INPUTSTATUS:
- default:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
- }
- }
-
- } else
- {
-
- switch (m_eventStatusTables[previousTable][kxevent].m_status)
- {
- case SCA_InputEvent::KX_JUSTACTIVATED:
- case SCA_InputEvent::KX_ACTIVE:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED;
- break;
- }
- default:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS;
- }
- }
- }
- }
- return result;
-}
-
-void GPC_KeyboardDevice::HookEscape()
-{
- m_hookesc = true;
-}
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
deleted file mode 100644
index d9842a42e0a..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
+++ /dev/null
@@ -1,90 +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_KeyboardDevice.h
- * \ingroup player
- */
-
-#ifndef __GPC_KEYBOARDDEVICE_H__
-#define __GPC_KEYBOARDDEVICE_H__
-
-#ifdef WIN32
-#pragma warning (disable:4786)
-#endif /* WIN32 */
-
-#include "SCA_IInputDevice.h"
-
-#include <map>
-
-
-/**
- * System independent implementation of SCA_IInputDevice.
- * System dependent keyboard devices need only to inherit this class
- * and fill the m_reverseKeyTranslateTable key translation map.
- * \see SCA_IInputDevice
- */
-
-class GPC_KeyboardDevice : public SCA_IInputDevice
-{
-protected:
-
- /**
- * This map converts system dependent keyboard codes into Ketsji codes.
- * System dependent keyboard codes are stored as ints.
- */
- std::map<int, KX_EnumInputs> m_reverseKeyTranslateTable;
- short m_exitkey;
-
-public:
- bool m_hookesc;
- GPC_KeyboardDevice()
- : m_hookesc(false)
- {
- }
-
- virtual ~GPC_KeyboardDevice(void)
- {
- }
-
- virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
- {
- return false;
- }
-
- virtual void NextFrame();
-
- virtual KX_EnumInputs ToNative(int incode)
- {
- return m_reverseKeyTranslateTable[incode];
- }
-
- virtual bool ConvertEvent(int incode, int val, unsigned int unicode);
-
- virtual void HookEscape();
-};
-
-#endif /* __GPC_KEYBOARDDEVICE_H__ */
diff --git a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp b/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp
deleted file mode 100644
index 94045d532af..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp
+++ /dev/null
@@ -1,214 +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_MouseDevice.cpp
- * \ingroup player
- */
-
-
-#include "GPC_MouseDevice.h"
-
-GPC_MouseDevice::GPC_MouseDevice()
-{
-
-}
-GPC_MouseDevice::~GPC_MouseDevice()
-{
-
-}
-
-/**
- * IsPressed gives boolean information about mouse status, true if pressed, false if not.
- */
-bool GPC_MouseDevice::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
-{
- const SCA_InputEvent & inevent = m_eventStatusTables[m_currentTable][inputcode];
- bool pressed = (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- inevent.m_status == SCA_InputEvent::KX_ACTIVE);
- return pressed;
-}
-
-
-/**
- * NextFrame toggles currentTable with previousTable,
- * and copies relevant event information from previous to current table
- * (pressed keys need to be remembered).
- */
-void GPC_MouseDevice::NextFrame()
-{
- SCA_IInputDevice::NextFrame();
-
- // Convert just pressed events into regular (active) events
- int previousTable = 1-m_currentTable;
- for (int mouseevent= KX_BEGINMOUSE; mouseevent< KX_ENDMOUSEBUTTONS; mouseevent++) {
- SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][mouseevent];
- if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- oldevent.m_status == SCA_InputEvent::KX_ACTIVE)
- {
- m_eventStatusTables[m_currentTable][mouseevent] = oldevent;
- m_eventStatusTables[m_currentTable][mouseevent].m_status = SCA_InputEvent::KX_ACTIVE;
- }
- }
- for (int mousemove= KX_ENDMOUSEBUTTONS; mousemove< KX_ENDMOUSE; mousemove++) {
- SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][mousemove];
- m_eventStatusTables[m_currentTable][mousemove] = oldevent;
- if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
- oldevent.m_status == SCA_InputEvent::KX_ACTIVE)
- {
- m_eventStatusTables[m_currentTable][mousemove].m_status = SCA_InputEvent::KX_JUSTRELEASED;
- }
- else {
- if (oldevent.m_status == SCA_InputEvent::KX_JUSTRELEASED) {
- m_eventStatusTables[m_currentTable][mousemove].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS;
- }
- }
- }
-}
-
-
-bool GPC_MouseDevice::ConvertButtonEvent(TButtonId button, bool isDown)
-{
- bool result = false;
-
- switch (button)
- {
- case buttonLeft:
- result = ConvertEvent(KX_LEFTMOUSE, isDown, 0);
- break;
- case buttonMiddle:
- result = ConvertEvent(KX_MIDDLEMOUSE, isDown, 0);
- break;
- case buttonRight:
- result = ConvertEvent(KX_RIGHTMOUSE, isDown, 0);
- break;
- case buttonWheelUp:
- result = ConvertEvent(KX_WHEELUPMOUSE, isDown, 0);
- break;
- case buttonWheelDown:
- result = ConvertEvent(KX_WHEELDOWNMOUSE, isDown, 0);
- break;
- default:
- // Should not happen!
- break;
- }
-
- return result;
-}
-
-/**
- * Splits combined button and x,y cursor move events into separate Ketsji
- * x and y move and button events.
- */
-bool GPC_MouseDevice::ConvertButtonEvent(TButtonId button, bool isDown, int x, int y)
-{
- // First update state tables for cursor move.
- bool result = ConvertMoveEvent(x, y);
-
- // Now update for button state.
- if (result) {
- result = ConvertButtonEvent(button, isDown);
- }
-
- return result;
-}
-
-/**
- * Splits combined x,y move into separate Ketsji x and y move events.
- */
-bool GPC_MouseDevice::ConvertMoveEvent(int x, int y)
-{
- bool result;
-
- // Convert to local coordinates?
- result = ConvertEvent(KX_MOUSEX, x, 0);
- if (result) {
- result = ConvertEvent(KX_MOUSEY, y, 0);
- }
-
- return result;
-}
-
-
-bool GPC_MouseDevice::ConvertEvent(KX_EnumInputs kxevent, int eventval, unsigned int unicode)
-{
- bool result = true;
-
- // Only process it, if it's a mouse event
- if (kxevent > KX_BEGINMOUSE && kxevent < KX_ENDMOUSE) {
- int previousTable = 1-m_currentTable;
-
- if (eventval > 0) {
- m_eventStatusTables[m_currentTable][kxevent].m_eventval = eventval;
-
- switch (m_eventStatusTables[previousTable][kxevent].m_status)
- {
- case SCA_InputEvent::KX_ACTIVE:
- case SCA_InputEvent::KX_JUSTACTIVATED:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
- break;
- }
- case SCA_InputEvent::KX_JUSTRELEASED:
- {
- if ( kxevent > KX_BEGINMOUSEBUTTONS && kxevent < KX_ENDMOUSEBUTTONS)
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
- } else
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
-
- }
- break;
- }
- default:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
- }
- }
-
- }
- else {
- switch (m_eventStatusTables[previousTable][kxevent].m_status)
- {
- case SCA_InputEvent::KX_JUSTACTIVATED:
- case SCA_InputEvent::KX_ACTIVE:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED;
- break;
- }
- default:
- {
- m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS;
- }
- }
- }
- }
- else {
- result = false;
- }
- return result;
-}
diff --git a/source/gameengine/GamePlayer/common/GPC_MouseDevice.h b/source/gameengine/GamePlayer/common/GPC_MouseDevice.h
deleted file mode 100644
index 24922197723..00000000000
--- a/source/gameengine/GamePlayer/common/GPC_MouseDevice.h
+++ /dev/null
@@ -1,103 +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_MouseDevice.h
- * \ingroup player
- */
-
-#ifndef __GPC_MOUSEDEVICE_H__
-#define __GPC_MOUSEDEVICE_H__
-
-#ifdef WIN32
-#pragma warning (disable:4786)
-#endif /* WIN32 */
-
-#include "SCA_IInputDevice.h"
-
-
-/**
- * Generic Ketsji mouse device.
- * \see SCA_IInputDevice
- */
-class GPC_MouseDevice : public SCA_IInputDevice
-{
-public:
- /**
- * Button identifier.
- */
- typedef enum {
- buttonLeft,
- buttonMiddle,
- buttonRight,
- buttonWheelUp,
- buttonWheelDown
- } TButtonId;
-
- GPC_MouseDevice();
- virtual ~GPC_MouseDevice(void);
-
- virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
- virtual void NextFrame();
-
- /**
- * Call this routine to update the mouse device when a button state changes.
- * \param button Which button state changes.
- * \param isDown The new state of the button.
- * \return Indication as to whether the event was processed.
- */
- virtual bool ConvertButtonEvent(TButtonId button, bool isDown);
-
- /**
- * Call this routine to update the mouse device when a button state and
- * cursor position changes at the same time (e.g. in Win32 messages).
- * \param button Which button state changes.
- * \param isDown The new state of the button.
- * \param x Position x-coordinate of the cursor at the time of the state change.
- * \param y Position y-coordinate of the cursor at the time of the state change.
- * \return Indication as to whether the event was processed.
- */
- virtual bool ConvertButtonEvent(TButtonId button, bool isDown, int x, int y);
-
- /**
- * Call this routine to update the mouse device when the cursor has moved.
- * \param x Position x-coordinate of the cursor.
- * \param y Position y-coordinate of the cursor.
- * \return Indication as to whether the event was processed.
- */
- virtual bool ConvertMoveEvent(int x, int y);
-
-protected:
- /**
- * This routine converts a single mouse event to a Ketsji mouse event.
- * \param kxevent Ketsji event code.
- * \param eventval Value for this event.
- * \return Indication as to whether the event was processed.
- */
- virtual bool ConvertEvent(KX_EnumInputs kxevent, int eventval, unsigned int unicode);
-};
-
-#endif /* __GPC_MOUSEDEVICE_H__ */
diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
deleted file mode 100644
index 5bce9fcd248..00000000000
--- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt
+++ /dev/null
@@ -1,112 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../common
- ../../BlenderRoutines
- ../../Converter
- ../../Expressions
- ../../GameLogic
- ../../Ketsji
- ../../Network
- ../../Network/LoopBackNetwork
- ../../Physics/common
- ../../Rasterizer
- ../../Rasterizer/RAS_OpenGLRasterizer
- ../../SceneGraph
- ../../../blender
- ../../../blender/blenfont
- ../../../blender/blenkernel
- ../../../blender/blenlib
- ../../../blender/blenloader
- ../../../blender/blentranslation
- ../../../blender/depsgraph
- ../../../blender/gpu
- ../../../blender/imbuf
- ../../../blender/makesdna
- ../../../blender/makesrna
- ../../../../intern/container
- ../../../../intern/ghost
- ../../../../intern/glew-mx
- ../../../../intern/guardedalloc
- ../../../../intern/string
- ../../../../intern/memutil
-)
-
-set(INC_SYS
- ../../../../intern/moto/include
- ${GLEW_INCLUDE_PATH}
- ${PYTHON_INCLUDE_DIRS}
- ${BOOST_INCLUDE_DIR}
-)
-
-set(SRC
- GPG_Application.cpp
- GPG_Canvas.cpp
- GPG_KeyboardDevice.cpp
- GPG_System.cpp
- GPG_ghost.cpp
-
- GPG_Application.h
- GPG_Canvas.h
- GPG_KeyboardDevice.h
- GPG_System.h
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-if(WIN32)
- blender_include_dirs(../../../../intern/utfconv)
-endif()
-
-if(WITH_INPUT_NDOF)
- add_definitions(-DWITH_INPUT_NDOF)
-endif(WITH_INPUT_NDOF)
-
-if(WITH_CODEC_FFMPEG)
- add_definitions(-DWITH_FFMPEG)
-endif()
-
-if(WITH_INTERNATIONAL)
- add_definitions(-DWITH_INTERNATIONAL)
-endif()
-
-if(WITH_AUDASPACE)
- add_definitions(-DWITH_AUDASPACE)
-
- list(APPEND INC_SYS
- ${AUDASPACE_C_INCLUDE_DIRS}
- )
-endif()
-
-if(WITH_SDL AND WITH_SDL_DYNLOAD)
- list(APPEND INC
- ../../../../extern/sdlew/include
- )
- add_definitions(-DWITH_SDL_DYNLOAD)
-endif()
-
-blender_add_lib_nolist(ge_player_ghost "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
deleted file mode 100644
index 1b6b6defdf9..00000000000
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ /dev/null
@@ -1,998 +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 *****
- * GHOST Blender Player application implementation file.
- */
-
-/** \file gameengine/GamePlayer/ghost/GPG_Application.cpp
- * \ingroup player
- */
-
-
-#ifdef WIN32
-# pragma warning (disable:4786) // suppress stl-MSVC debug info warning
-# include <windows.h>
-#endif
-
-#include "GPU_glew.h"
-#include "GPU_extensions.h"
-#include "GPU_init_exit.h"
-
-#include "GPG_Application.h"
-#include "BL_BlenderDataConversion.h"
-
-#include <iostream>
-#include <MT_assert.h>
-#include <stdlib.h>
-
-/**********************************
- * Begin Blender include block
- **********************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif // __cplusplus
-#include "BLI_blenlib.h"
-#include "BLO_readfile.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_sound.h"
-#include "IMB_imbuf.h"
-#include "DNA_scene_types.h"
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-/**********************************
- * End Blender include block
- **********************************/
-
-
-#include "BL_System.h"
-#include "KX_KetsjiEngine.h"
-
-// include files needed by "KX_BlenderSceneConverter.h"
-#include "CTR_Map.h"
-#include "SCA_IActuator.h"
-#include "RAS_MeshObject.h"
-#include "RAS_OpenGLRasterizer.h"
-#include "RAS_ListRasterizer.h"
-#include "KX_PythonInit.h"
-#include "KX_PyConstraintBinding.h"
-#include "BL_Material.h" // MAXTEX
-
-#include "KX_BlenderSceneConverter.h"
-#include "NG_LoopBackNetworkDeviceInterface.h"
-
-#include "GPC_MouseDevice.h"
-#include "GPG_Canvas.h"
-#include "GPG_KeyboardDevice.h"
-#include "GPG_System.h"
-
-#include "STR_String.h"
-
-#include "GHOST_ISystem.h"
-#include "GHOST_IEvent.h"
-#include "GHOST_IEventConsumer.h"
-#include "GHOST_IWindow.h"
-#include "GHOST_Rect.h"
-
-#ifdef WITH_AUDASPACE
-# include <AUD_Device.h>
-#endif
-
-static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time);
-
-static GHOST_ISystem* fSystem = 0;
-static const int kTimerFreq = 10;
-
-GPG_Application::GPG_Application(GHOST_ISystem* system)
- : m_startSceneName(""),
- m_startScene(0),
- m_maggie(0),
- m_kxStartScene(NULL),
- m_exitRequested(0),
- m_system(system),
- m_mainWindow(0),
- m_frameTimer(0),
- m_cursor(GHOST_kStandardCursorFirstCursor),
- m_engineInitialized(0),
- m_engineRunning(0),
- m_isEmbedded(false),
- m_ketsjiengine(0),
- m_kxsystem(0),
- m_keyboard(0),
- m_mouse(0),
- m_canvas(0),
- m_rasterizer(0),
- m_sceneconverter(0),
- m_networkdevice(0),
- m_blendermat(0),
- m_blenderglslmat(0),
- m_pyGlobalDictString(0),
- m_pyGlobalDictString_Length(0)
-{
- fSystem = system;
-}
-
-
-
-GPG_Application::~GPG_Application(void)
-{
- if (m_pyGlobalDictString) {
- delete [] m_pyGlobalDictString;
- m_pyGlobalDictString = 0;
- m_pyGlobalDictString_Length = 0;
- }
-
- exitEngine();
- fSystem->disposeWindow(m_mainWindow);
-}
-
-
-
-bool GPG_Application::SetGameEngineData(struct Main* maggie, Scene *scene, GlobalSettings *gs, int argc, char **argv)
-{
- bool result = false;
-
- if (maggie != NULL && scene != NULL)
- {
-// XXX G.scene = scene;
- m_maggie = maggie;
- m_startSceneName = scene->id.name+2;
- m_startScene = scene;
- result = true;
- }
-
- /* Python needs these */
- m_argc= argc;
- m_argv= argv;
-
- /* Global Settings */
- m_globalSettings= gs;
-
- return result;
-}
-
-
-#ifdef WIN32
-#define SCR_SAVE_MOUSE_MOVE_THRESHOLD 15
-
-static HWND found_ghost_window_hwnd;
-static GHOST_IWindow* ghost_window_to_find;
-static WNDPROC ghost_wnd_proc;
-static POINT scr_save_mouse_pos;
-
-static LRESULT CALLBACK screenSaverWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- BOOL close = false;
- switch (uMsg)
- {
- case WM_MOUSEMOVE:
- {
- POINT pt;
- GetCursorPos(&pt);
- LONG dx = scr_save_mouse_pos.x - pt.x;
- LONG dy = scr_save_mouse_pos.y - pt.y;
- if (abs(dx) > SCR_SAVE_MOUSE_MOVE_THRESHOLD
- || abs(dy) > SCR_SAVE_MOUSE_MOVE_THRESHOLD)
- {
- close = true;
- }
- scr_save_mouse_pos = pt;
- break;
- }
- case WM_LBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_RBUTTONDOWN:
- case WM_KEYDOWN:
- close = true;
- }
- if (close)
- PostMessage(hwnd,WM_CLOSE,0,0);
- return CallWindowProc(ghost_wnd_proc, hwnd, uMsg, wParam, lParam);
-}
-
-BOOL CALLBACK findGhostWindowHWNDProc(HWND hwnd, LPARAM lParam)
-{
- GHOST_IWindow *p = (GHOST_IWindow*) GetWindowLongPtr(hwnd, GWLP_USERDATA);
- BOOL ret = true;
- if (p == ghost_window_to_find)
- {
- found_ghost_window_hwnd = hwnd;
- ret = false;
- }
- return ret;
-}
-
-static HWND findGhostWindowHWND(GHOST_IWindow* window)
-{
- found_ghost_window_hwnd = NULL;
- ghost_window_to_find = window;
- EnumWindows(findGhostWindowHWNDProc, NULL);
- return found_ghost_window_hwnd;
-}
-
-bool GPG_Application::startScreenSaverPreview(
- HWND parentWindow,
- const bool stereoVisual,
- const int stereoMode,
- const GHOST_TUns16 samples)
-{
- bool success = false;
-
- RECT rc;
- if (GetWindowRect(parentWindow, &rc))
- {
- int windowWidth = rc.right - rc.left;
- int windowHeight = rc.bottom - rc.top;
- STR_String title = "";
- GHOST_GLSettings glSettings = {0};
-
- if (stereoVisual) {
- glSettings.flags |= GHOST_glStereoVisual;
- }
- glSettings.numOfAASamples = samples;
-
- m_mainWindow = fSystem->createWindow(title, 0, 0, windowWidth, windowHeight, GHOST_kWindowStateMinimized,
- GHOST_kDrawingContextTypeOpenGL, glSettings);
- if (!m_mainWindow) {
- printf("error: could not create main window\n");
- exit(-1);
- }
-
- HWND ghost_hwnd = findGhostWindowHWND(m_mainWindow);
- if (!ghost_hwnd) {
- printf("error: could find main window\n");
- exit(-1);
- }
-
- SetParent(ghost_hwnd, parentWindow);
- LONG_PTR style = GetWindowLongPtr(ghost_hwnd, GWL_STYLE);
- LONG_PTR exstyle = GetWindowLongPtr(ghost_hwnd, GWL_EXSTYLE);
-
- RECT adjrc = { 0, 0, windowWidth, windowHeight };
- AdjustWindowRectEx(&adjrc, style, false, exstyle);
-
- style = (style & (~(WS_POPUP|WS_OVERLAPPEDWINDOW|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_TILEDWINDOW ))) | WS_CHILD;
- SetWindowLongPtr(ghost_hwnd, GWL_STYLE, style);
- SetWindowPos(ghost_hwnd, NULL, adjrc.left, adjrc.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
-
- /* Check the size of the client rectangle of the window and resize the window
- * so that the client rectangle has the size requested.
- */
- m_mainWindow->setClientSize(windowWidth, windowHeight);
-
- success = initEngine(m_mainWindow, stereoMode);
- if (success) {
- success = startEngine();
- }
-
- }
- return success;
-}
-
-bool GPG_Application::startScreenSaverFullScreen(
- int width,
- int height,
- int bpp,int frequency,
- const bool stereoVisual,
- const int stereoMode,
- const GHOST_TUns16 samples)
-{
- bool ret = startFullScreen(width, height, bpp, frequency, stereoVisual, stereoMode, 0, samples);
- if (ret)
- {
- HWND ghost_hwnd = findGhostWindowHWND(m_mainWindow);
- if (ghost_hwnd != NULL)
- {
- GetCursorPos(&scr_save_mouse_pos);
- ghost_wnd_proc = (WNDPROC) GetWindowLongPtr(ghost_hwnd, GWLP_WNDPROC);
- SetWindowLongPtr(ghost_hwnd,GWLP_WNDPROC, (uintptr_t) screenSaverWindowProc);
- }
- }
- return ret;
-}
-
-#endif
-
-bool GPG_Application::startWindow(
- STR_String& title,
- int windowLeft,
- int windowTop,
- int windowWidth,
- int windowHeight,
- const bool stereoVisual,
- const int stereoMode,
- const int alphaBackground,
- const GHOST_TUns16 samples)
-{
- GHOST_GLSettings glSettings = {0};
- bool success;
- // Create the main window
- //STR_String title ("Blender Player - GHOST");
- if (stereoVisual)
- glSettings.flags |= GHOST_glStereoVisual;
- if (alphaBackground)
- glSettings.flags |= GHOST_glAlphaBackground;
- glSettings.numOfAASamples = samples;
-
- m_mainWindow = fSystem->createWindow(title, windowLeft, windowTop, windowWidth, windowHeight, GHOST_kWindowStateNormal,
- GHOST_kDrawingContextTypeOpenGL, glSettings);
- if (!m_mainWindow) {
- printf("error: could not create main window\n");
- exit(-1);
- }
-
- /* Check the size of the client rectangle of the window and resize the window
- * so that the client rectangle has the size requested.
- */
- m_mainWindow->setClientSize(windowWidth, windowHeight);
- m_mainWindow->setCursorVisibility(false);
-
- success = initEngine(m_mainWindow, stereoMode);
- if (success) {
- success = startEngine();
- }
- return success;
-}
-
-bool GPG_Application::startEmbeddedWindow(
- STR_String& title,
- const GHOST_TEmbedderWindowID parentWindow,
- const bool stereoVisual,
- const int stereoMode,
- const int alphaBackground,
- const GHOST_TUns16 samples)
-{
- GHOST_TWindowState state = GHOST_kWindowStateNormal;
- GHOST_GLSettings glSettings = {0};
-
- if (stereoVisual)
- glSettings.flags |= GHOST_glStereoVisual;
- if (alphaBackground)
- glSettings.flags |= GHOST_glAlphaBackground;
- glSettings.numOfAASamples = samples;
-
- if (parentWindow != 0)
- state = GHOST_kWindowStateEmbedded;
- m_mainWindow = fSystem->createWindow(title, 0, 0, 0, 0, state,
- GHOST_kDrawingContextTypeOpenGL, glSettings, parentWindow);
-
- if (!m_mainWindow) {
- printf("error: could not create main window\n");
- exit(-1);
- }
- m_isEmbedded = true;
-
- bool success = initEngine(m_mainWindow, stereoMode);
- if (success) {
- success = startEngine();
- }
- return success;
-}
-
-
-bool GPG_Application::startFullScreen(
- int width,
- int height,
- int bpp,int frequency,
- const bool stereoVisual,
- const int stereoMode,
- const int alphaBackground,
- const GHOST_TUns16 samples,
- bool useDesktop)
-{
- bool success;
- GHOST_TUns32 sysWidth=0, sysHeight=0;
- fSystem->getMainDisplayDimensions(sysWidth, sysHeight);
- // Create the main window
- GHOST_DisplaySetting setting;
- setting.xPixels = (useDesktop) ? sysWidth : width;
- setting.yPixels = (useDesktop) ? sysHeight : height;
- setting.bpp = bpp;
- setting.frequency = frequency;
-
- fSystem->beginFullScreen(setting, &m_mainWindow, stereoVisual, alphaBackground, samples);
- m_mainWindow->setCursorVisibility(false);
- /* note that X11 ignores this (it uses a window internally for fullscreen) */
- m_mainWindow->setState(GHOST_kWindowStateFullScreen);
-
- success = initEngine(m_mainWindow, stereoMode);
- if (success) {
- success = startEngine();
- }
- return success;
-}
-
-
-
-
-bool GPG_Application::StartGameEngine(int stereoMode)
-{
- bool success = initEngine(m_mainWindow, stereoMode);
-
- if (success)
- success = startEngine();
-
- return success;
-}
-
-
-
-void GPG_Application::StopGameEngine()
-{
- exitEngine();
-}
-
-
-
-bool GPG_Application::processEvent(GHOST_IEvent* event)
-{
- bool handled = true;
-
- switch (event->getType())
- {
- case GHOST_kEventUnknown:
- break;
-
- case GHOST_kEventButtonDown:
- handled = handleButton(event, true);
- break;
-
- case GHOST_kEventButtonUp:
- handled = handleButton(event, false);
- break;
-
- case GHOST_kEventWheel:
- handled = handleWheel(event);
- break;
-
- case GHOST_kEventCursorMove:
- handled = handleCursorMove(event);
- break;
-
- case GHOST_kEventKeyDown:
- handleKey(event, true);
- break;
-
- case GHOST_kEventKeyUp:
- handleKey(event, false);
- break;
-
-
- case GHOST_kEventWindowClose:
- case GHOST_kEventQuit:
- m_exitRequested = KX_EXIT_REQUEST_OUTSIDE;
- break;
-
- case GHOST_kEventWindowActivate:
- handled = false;
- break;
- case GHOST_kEventWindowDeactivate:
- handled = false;
- break;
-
- // The player now runs as often as it can (repsecting vsync and fixedtime).
- // This allows the player to break 100fps, but this code is being left here
- // as reference. (see EngineNextFrame)
- //case GHOST_kEventWindowUpdate:
- // {
- // GHOST_IWindow* window = event->getWindow();
- // if (!m_system->validWindow(window)) break;
- // // Update the state of the game engine
- // if (m_kxsystem && !m_exitRequested)
- // {
- // // Proceed to next frame
- // window->activateDrawingContext();
-
- // // first check if we want to exit
- // m_exitRequested = m_ketsjiengine->GetExitCode();
- //
- // // kick the engine
- // bool renderFrame = m_ketsjiengine->NextFrame();
- // if (renderFrame)
- // {
- // // render the frame
- // m_ketsjiengine->Render();
- // }
- // }
- // m_exitString = m_ketsjiengine->GetExitString();
- // }
- // break;
- //
- case GHOST_kEventWindowSize:
- {
- GHOST_IWindow* window = event->getWindow();
- if (!m_system->validWindow(window)) break;
- if (m_canvas) {
- GHOST_Rect bnds;
- window->getClientBounds(bnds);
- m_canvas->Resize(bnds.getWidth(), bnds.getHeight());
- m_ketsjiengine->Resize();
- }
- }
- break;
-
- default:
- handled = false;
- break;
- }
- return handled;
-}
-
-
-
-int GPG_Application::getExitRequested(void)
-{
- return m_exitRequested;
-}
-
-
-GlobalSettings* GPG_Application::getGlobalSettings(void)
-{
- return m_ketsjiengine->GetGlobalSettings();
-}
-
-
-
-const STR_String& GPG_Application::getExitString(void)
-{
- return m_exitString;
-}
-
-
-
-bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
-{
- if (!m_engineInitialized)
- {
- GPU_init();
-
- // get and set the preferences
- SYS_SystemHandle syshandle = SYS_GetSystem();
- if (!syshandle)
- return false;
-
- // SYS_WriteCommandLineInt(syshandle, "fixedtime", 0);
- // SYS_WriteCommandLineInt(syshandle, "vertexarrays",1);
- GameData *gm= &m_startScene->gm;
- bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0);
- bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);
-
- bool showPhysics = (gm->flag & GAME_SHOW_PHYSICS);
- SYS_WriteCommandLineInt(syshandle, "show_physics", showPhysics);
-
- bool fixed_framerate= (SYS_GetCommandLineInt(syshandle, "fixedtime", (gm->flag & GAME_ENABLE_ALL_FRAMES)) != 0);
- bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
- bool useLists = false; // (SYS_GetCommandLineInt(syshandle, "displaylists", gm->flag & GAME_DISPLAY_LISTS) != 0) && GPU_display_list_support();
- bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 1) != 0);
- bool restrictAnimFPS = (gm->flag & GAME_RESTRICT_ANIM_UPDATES) != 0;
-
- m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0);
- m_blenderglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 1) != 0);
-
- // create the canvas, rasterizer and rendertools
- m_canvas = new GPG_Canvas(window);
- if (!m_canvas)
- return false;
-
- if (gm->vsync == VSYNC_ADAPTIVE)
- m_canvas->SetSwapInterval(-1);
- else
- m_canvas->SetSwapInterval((gm->vsync == VSYNC_ON) ? 1 : 0);
-
- m_canvas->Init();
- if (gm->flag & GAME_SHOW_MOUSE)
- m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
-
- RAS_STORAGE_TYPE raster_storage = RAS_AUTO_STORAGE;
-
- if (gm->raster_storage == RAS_STORE_VBO) {
- raster_storage = RAS_VBO;
- }
- else if (gm->raster_storage == RAS_STORE_VA) {
- raster_storage = RAS_VA;
- }
- //Don't use displaylists with VBOs
- //If auto starts using VBOs, make sure to check for that here
- if (useLists && raster_storage != RAS_VBO)
- m_rasterizer = new RAS_ListRasterizer(m_canvas, true, raster_storage);
- else
- m_rasterizer = new RAS_OpenGLRasterizer(m_canvas, raster_storage);
-
- /* Stereo parameters - Eye Separation from the UI - stereomode from the command-line/UI */
- m_rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) stereoMode);
- m_rasterizer->SetEyeSeparation(m_startScene->gm.eyeseparation);
-
- if (!m_rasterizer)
- goto initFailed;
-
- m_rasterizer->PrintHardwareInfo();
-
- // create the inputdevices
- m_keyboard = new GPG_KeyboardDevice();
- if (!m_keyboard)
- goto initFailed;
-
- m_mouse = new GPC_MouseDevice();
- if (!m_mouse)
- goto initFailed;
-
- // create a networkdevice
- m_networkdevice = new NG_LoopBackNetworkDeviceInterface();
- if (!m_networkdevice)
- goto initFailed;
-
- BKE_sound_init(m_maggie);
-
- // create a ketsjisystem (only needed for timing and stuff)
- m_kxsystem = new GPG_System (m_system);
- if (!m_kxsystem)
- goto initFailed;
-
- // create the ketsjiengine
- m_ketsjiengine = new KX_KetsjiEngine(m_kxsystem);
-
- // set the devices
- m_ketsjiengine->SetKeyboardDevice(m_keyboard);
- m_ketsjiengine->SetMouseDevice(m_mouse);
- m_ketsjiengine->SetNetworkDevice(m_networkdevice);
- m_ketsjiengine->SetCanvas(m_canvas);
- m_ketsjiengine->SetRasterizer(m_rasterizer);
-
- KX_KetsjiEngine::SetExitKey(ConvertKeyCode(gm->exitkey));
-#ifdef WITH_PYTHON
- CValue::SetDeprecationWarnings(nodepwarnings);
-#else
- (void)nodepwarnings;
-#endif
-
- m_ketsjiengine->SetUseFixedTime(fixed_framerate);
- m_ketsjiengine->SetTimingDisplay(frameRate, profile, properties);
- m_ketsjiengine->SetRestrictAnimationFPS(restrictAnimFPS);
-
- //set the global settings (carried over if restart/load new files)
- m_ketsjiengine->SetGlobalSettings(m_globalSettings);
- m_ketsjiengine->SetRender(true);
-
- m_engineInitialized = true;
- }
-
- return m_engineInitialized;
-initFailed:
- BKE_sound_exit();
- delete m_kxsystem;
- delete m_networkdevice;
- delete m_mouse;
- delete m_keyboard;
- delete m_rasterizer;
- delete m_canvas;
- m_canvas = NULL;
- m_rasterizer = NULL;
- m_keyboard = NULL;
- m_mouse = NULL;
- m_networkdevice = NULL;
- m_kxsystem = NULL;
- return false;
-}
-
-
-
-bool GPG_Application::startEngine(void)
-{
- if (m_engineRunning) {
- return false;
- }
-
- // Temporary hack to disable banner display for NaN approved content.
- /*
- m_canvas->SetBannerDisplayEnabled(true);
- Camera* cam;
- cam = (Camera*)scene->camera->data;
- if (cam) {
- if (((cam->flag) & 48)==48) {
- m_canvas->SetBannerDisplayEnabled(false);
- }
- }
- else {
- showError(CString("Camera data invalid."));
- return false;
- }
- */
-
- // create a scene converter, create and convert the stratingscene
- m_sceneconverter = new KX_BlenderSceneConverter(m_maggie, m_ketsjiengine);
- if (m_sceneconverter)
- {
- STR_String m_kxStartScenename = m_startSceneName.Ptr();
- m_ketsjiengine->SetSceneConverter(m_sceneconverter);
-
- // if (always_use_expand_framing)
- // sceneconverter->SetAlwaysUseExpandFraming(true);
- if (m_blendermat)
- m_sceneconverter->SetMaterials(true);
- if (m_blenderglslmat && (m_globalSettings->matmode == GAME_MAT_GLSL))
- m_sceneconverter->SetGLSLMaterials(true);
- if (m_startScene->gm.flag & GAME_NO_MATERIAL_CACHING)
- m_sceneconverter->SetCacheMaterials(false);
-
- m_kxStartScene = new KX_Scene(m_keyboard,
- m_mouse,
- m_networkdevice,
- m_kxStartScenename,
- m_startScene,
- m_canvas);
-
-#ifdef WITH_PYTHON
- // some python things
- PyObject *gameLogic, *gameLogic_keys;
- setupGamePython(m_ketsjiengine, m_kxStartScene, m_maggie, NULL, &gameLogic, &gameLogic_keys, m_argc, m_argv);
-#endif // WITH_PYTHON
-
- //initialize Dome Settings
- if (m_startScene->gm.stereoflag == STEREO_DOME)
- m_ketsjiengine->InitDome(m_startScene->gm.dome.res, m_startScene->gm.dome.mode, m_startScene->gm.dome.angle, m_startScene->gm.dome.resbuf, m_startScene->gm.dome.tilt, m_startScene->gm.dome.warptext);
-
- // initialize 3D Audio Settings
- AUD_Device* device = BKE_sound_get_device();
- AUD_Device_setSpeedOfSound(device, m_startScene->audio.speed_of_sound);
- AUD_Device_setDopplerFactor(device, m_startScene->audio.doppler_factor);
- AUD_Device_setDistanceModel(device, AUD_DistanceModel(m_startScene->audio.distance_model));
-
-#ifdef WITH_PYTHON
- // Set the GameLogic.globalDict from marshal'd data, so we can
- // load new blend files and keep data in GameLogic.globalDict
- loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length);
-#endif
- m_sceneconverter->ConvertScene(
- m_kxStartScene,
- m_rasterizer,
- m_canvas);
- m_ketsjiengine->AddScene(m_kxStartScene);
-
- // Create a timer that is used to kick the engine
- if (!m_frameTimer) {
- m_frameTimer = m_system->installTimer(0, kTimerFreq, frameTimerProc, m_mainWindow);
- }
- m_rasterizer->Init();
- m_ketsjiengine->StartEngine(true);
- m_engineRunning = true;
-
- // Set the animation playback rate for ipo's and actions
- // the framerate below should patch with FPS macro defined in blendef.h
- // Could be in StartEngine set the framerate, we need the scene to do this
- Scene *scene= m_kxStartScene->GetBlenderScene(); // needed for macro
- m_ketsjiengine->SetAnimFrameRate(FPS);
- }
-
- if (!m_engineRunning)
- {
- stopEngine();
- }
-
- return m_engineRunning;
-}
-
-
-void GPG_Application::stopEngine()
-{
-#ifdef WITH_PYTHON
- // GameLogic.globalDict gets converted into a buffer, and sorted in
- // m_pyGlobalDictString so we can restore after python has stopped
- // and started between .blend file loads.
- if (m_pyGlobalDictString) {
- delete [] m_pyGlobalDictString;
- m_pyGlobalDictString = 0;
- }
-
- m_pyGlobalDictString_Length = saveGamePythonConfig(&m_pyGlobalDictString);
-#endif
-
- m_ketsjiengine->StopEngine();
- m_networkdevice->Disconnect();
-
- if (m_sceneconverter) {
- delete m_sceneconverter;
- m_sceneconverter = 0;
- }
- if (m_system && m_frameTimer) {
- m_system->removeTimer(m_frameTimer);
- m_frameTimer = 0;
- }
-
- m_engineRunning = false;
-}
-
-void GPG_Application::EngineNextFrame()
-{
- // Update the state of the game engine
- if (m_kxsystem && !m_exitRequested)
- {
- // Proceed to next frame
- if (m_mainWindow)
- m_mainWindow->activateDrawingContext();
-
- // first check if we want to exit
- m_exitRequested = m_ketsjiengine->GetExitCode();
-
- // kick the engine
- bool renderFrame = m_ketsjiengine->NextFrame();
- if (renderFrame && m_mainWindow)
- {
- // render the frame
- m_ketsjiengine->Render();
- }
- }
- m_exitString = m_ketsjiengine->GetExitString();
-}
-
-void GPG_Application::exitEngine()
-{
- // We only want to kill the engine if it has been initialized
- if (!m_engineInitialized)
- return;
-
- BKE_sound_exit();
- if (m_ketsjiengine)
- {
- stopEngine();
- delete m_ketsjiengine;
- m_ketsjiengine = 0;
- }
- if (m_kxsystem)
- {
- delete m_kxsystem;
- m_kxsystem = 0;
- }
- if (m_networkdevice)
- {
- delete m_networkdevice;
- m_networkdevice = 0;
- }
- if (m_mouse)
- {
- delete m_mouse;
- m_mouse = 0;
- }
- if (m_keyboard)
- {
- delete m_keyboard;
- m_keyboard = 0;
- }
- if (m_rasterizer)
- {
- delete m_rasterizer;
- m_rasterizer = 0;
- }
- if (m_canvas)
- {
- delete m_canvas;
- m_canvas = 0;
- }
-
- GPU_exit();
-
-#ifdef WITH_PYTHON
- // Call this after we're sure nothing needs Python anymore (e.g., destructors)
- exitGamePlayerPythonScripting();
-#endif
-
- m_exitRequested = 0;
- m_engineInitialized = false;
-}
-
-bool GPG_Application::handleWheel(GHOST_IEvent* event)
-{
- bool handled = false;
- MT_assert(event);
- if (m_mouse)
- {
- GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData();
- GHOST_TEventWheelData* wheelData = static_cast<GHOST_TEventWheelData*>(eventData);
- GPC_MouseDevice::TButtonId button;
- if (wheelData->z > 0)
- button = GPC_MouseDevice::buttonWheelUp;
- else
- button = GPC_MouseDevice::buttonWheelDown;
- m_mouse->ConvertButtonEvent(button, true);
- handled = true;
- }
- return handled;
-}
-
-bool GPG_Application::handleButton(GHOST_IEvent* event, bool isDown)
-{
- bool handled = false;
- MT_assert(event);
- if (m_mouse)
- {
- GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData();
- GHOST_TEventButtonData* buttonData = static_cast<GHOST_TEventButtonData*>(eventData);
- GPC_MouseDevice::TButtonId button;
- switch (buttonData->button)
- {
- case GHOST_kButtonMaskMiddle:
- button = GPC_MouseDevice::buttonMiddle;
- break;
- case GHOST_kButtonMaskRight:
- button = GPC_MouseDevice::buttonRight;
- break;
- case GHOST_kButtonMaskLeft:
- default:
- button = GPC_MouseDevice::buttonLeft;
- break;
- }
- m_mouse->ConvertButtonEvent(button, isDown);
- handled = true;
- }
- return handled;
-}
-
-
-bool GPG_Application::handleCursorMove(GHOST_IEvent* event)
-{
- bool handled = false;
- MT_assert(event);
- if (m_mouse && m_mainWindow)
- {
- GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData();
- GHOST_TEventCursorData* cursorData = static_cast<GHOST_TEventCursorData*>(eventData);
- GHOST_TInt32 x, y;
- m_mainWindow->screenToClient(cursorData->x, cursorData->y, x, y);
- m_mouse->ConvertMoveEvent(x, y);
- handled = true;
- }
- return handled;
-}
-
-
-bool GPG_Application::handleKey(GHOST_IEvent* event, bool isDown)
-{
- bool handled = false;
- MT_assert(event);
- if (m_keyboard)
- {
- GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData();
- GHOST_TEventKeyData* keyData = static_cast<GHOST_TEventKeyData*>(eventData);
- unsigned int unicode = keyData->utf8_buf[0] ? BLI_str_utf8_as_unicode(keyData->utf8_buf) : keyData->ascii;
-
- if (m_keyboard->ToNative(keyData->key) == KX_KetsjiEngine::GetExitKey() && !m_keyboard->m_hookesc && !m_isEmbedded) {
- m_exitRequested = KX_EXIT_REQUEST_OUTSIDE;
- }
- m_keyboard->ConvertEvent(keyData->key, isDown, unicode);
- handled = true;
- }
- return handled;
-}
-
-
-
-static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time)
-{
- GHOST_IWindow* window = (GHOST_IWindow*)task->getUserData();
- if (fSystem->validWindow(window)) {
- window->invalidate();
- }
-}
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h
deleted file mode 100644
index e757cc10e32..00000000000
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.h
+++ /dev/null
@@ -1,181 +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 GPG_Application.h
- * \ingroup player
- * \brief GHOST Blender Player application declaration file.
- */
-
-#include "GHOST_IEventConsumer.h"
-#include "STR_String.h"
-
-#ifdef WIN32
-#include <wtypes.h>
-#endif
-
-#include "KX_KetsjiEngine.h"
-
-class KX_KetsjiEngine;
-class KX_Scene;
-class KX_ISceneConverter;
-class NG_LoopBackNetworkDeviceInterface;
-class RAS_IRasterizer;
-class GHOST_IEvent;
-class GHOST_ISystem;
-class GHOST_ITimerTask;
-class GHOST_IWindow;
-class GPC_MouseDevice;
-class GPG_Canvas;
-class GPG_KeyboardDevice;
-class GPG_System;
-struct Main;
-struct Scene;
-
-class GPG_Application : public GHOST_IEventConsumer
-{
-public:
- GPG_Application(GHOST_ISystem* system);
- ~GPG_Application(void);
-
- bool SetGameEngineData(struct Main* maggie, struct Scene* scene, GlobalSettings* gs, int argc, char** argv);
- bool startWindow(STR_String& title,
- int windowLeft, int windowTop,
- int windowWidth, int windowHeight,
- const bool stereoVisual, const int stereoMode, const int alphaBackground=0, const GHOST_TUns16 samples=0);
- bool startFullScreen(int width, int height,
- int bpp, int frequency,
- const bool stereoVisual, const int stereoMode, const int alphaBackground = 0,
- const GHOST_TUns16 samples=0, bool useDesktop=false);
- bool startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parent_window,
- const bool stereoVisual, const int stereoMode, const int alphaBackground=0, const GHOST_TUns16 samples=0);
-#ifdef WIN32
- bool startScreenSaverFullScreen(int width, int height,
- int bpp, int frequency,
- const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0);
- bool startScreenSaverPreview(HWND parentWindow,
- const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0);
-#endif
-
- virtual bool processEvent(GHOST_IEvent* event);
- int getExitRequested(void);
- const STR_String& getExitString(void);
- GlobalSettings* getGlobalSettings(void);
-
- inline KX_Scene *GetStartScene() const
- {
- return m_kxStartScene;
- }
-
- bool StartGameEngine(int stereoMode);
- void StopGameEngine();
- void EngineNextFrame();
-
-protected:
- bool handleWheel(GHOST_IEvent* event);
- bool handleButton(GHOST_IEvent* event, bool isDown);
- bool handleCursorMove(GHOST_IEvent* event);
- bool handleKey(GHOST_IEvent* event, bool isDown);
-
- /**
- * Initializes the game engine.
- */
- bool initEngine(GHOST_IWindow* window, int stereoMode);
-
- /**
- * Starts the game engine.
- */
- bool startEngine(void);
-
- /**
- * Stop the game engine.
- */
- void stopEngine(void);
-
- /**
- * Shuts the game engine down.
- */
- void exitEngine(void);
- short m_exitkey;
-
- /* The game data */
- STR_String m_startSceneName;
- struct Scene* m_startScene;
- struct Main* m_maggie;
- KX_Scene *m_kxStartScene;
-
- /* Exit state. */
- int m_exitRequested;
- STR_String m_exitString;
- GlobalSettings* m_globalSettings;
-
- /* GHOST system abstraction. */
- GHOST_ISystem* m_system;
- /* Main window. */
- GHOST_IWindow* m_mainWindow;
- /* Timer to advance frames. */
- GHOST_ITimerTask* m_frameTimer;
- /* The cursor shape displayed. */
- GHOST_TStandardCursor m_cursor;
-
- /** Engine construction state. */
- bool m_engineInitialized;
- /** Engine state. */
- bool m_engineRunning;
- /** Running on embedded window */
- bool m_isEmbedded;
-
- /** the gameengine itself */
- KX_KetsjiEngine* m_ketsjiengine;
- /** The game engine's system abstraction. */
- GPG_System* m_kxsystem;
- /** The game engine's keyboard abstraction. */
- GPG_KeyboardDevice* m_keyboard;
- /** The game engine's mouse abstraction. */
- GPC_MouseDevice* m_mouse;
- /** The game engine's canvas abstraction. */
- GPG_Canvas* m_canvas;
- /** the rasterizer */
- RAS_IRasterizer* m_rasterizer;
- /** Converts Blender data files. */
- KX_ISceneConverter* m_sceneconverter;
- /** Network interface. */
- NG_LoopBackNetworkDeviceInterface* m_networkdevice;
-
- bool m_blendermat;
- bool m_blenderglslmat;
-
- /*
- * GameLogic.globalDict as a string so that loading new blend files can use the same dict.
- * Do this because python starts/stops when loading blend files.
- */
- char* m_pyGlobalDictString;
- int m_pyGlobalDictString_Length;
-
- /* argc and argv need to be passed on to python */
- int m_argc;
- char** m_argv;
-};
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
deleted file mode 100644
index 09eb1691dae..00000000000
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
+++ /dev/null
@@ -1,177 +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/ghost/GPG_Canvas.cpp
- * \ingroup player
- */
-
-
-#include "GPG_Canvas.h"
-#include <assert.h>
-#include "GHOST_ISystem.h"
-
-GPG_Canvas::GPG_Canvas(GHOST_IWindow* window)
-: GPC_Canvas(0, 0), m_window(window)
-{
- if (m_window)
- {
- GHOST_Rect bnds;
- m_window->getClientBounds(bnds);
- this->Resize(bnds.getWidth(), bnds.getHeight());
- }
-}
-
-
-GPG_Canvas::~GPG_Canvas(void)
-{
-}
-
-
-void GPG_Canvas::Init()
-{
- if (m_window)
- {
- m_window->setDrawingContextType(GHOST_kDrawingContextTypeOpenGL);
- assert(m_window->getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL);
- }
-}
-
-void GPG_Canvas::SetMousePosition(int x, int y)
-{
- GHOST_ISystem* system = GHOST_ISystem::getSystem();
- if (system && m_window)
- {
- GHOST_TInt32 gx = (GHOST_TInt32)x;
- GHOST_TInt32 gy = (GHOST_TInt32)y;
- GHOST_TInt32 cx;
- GHOST_TInt32 cy;
- m_window->clientToScreen(gx, gy, cx, cy);
- system->setCursorPosition(cx, cy);
- }
-}
-
-
-void GPG_Canvas::SetMouseState(RAS_MouseState mousestate)
-{
- m_mousestate = mousestate;
-
- if (m_window)
- {
- switch (mousestate)
- {
- case MOUSE_INVISIBLE:
- m_window->setCursorVisibility(false);
- break;
- case MOUSE_WAIT:
- m_window->setCursorShape(GHOST_kStandardCursorWait);
- m_window->setCursorVisibility(true);
- break;
- case MOUSE_NORMAL:
- m_window->setCursorShape(GHOST_kStandardCursorDefault);
- m_window->setCursorVisibility(true);
- break;
- }
- }
-}
-
-
-void GPG_Canvas::SwapBuffers()
-{
- if (m_window)
- {
- m_window->swapBuffers();
- }
-}
-
-void GPG_Canvas::SetSwapInterval(int interval)
-{
- if (m_window)
- m_window->setSwapInterval(interval);
-}
-
-bool GPG_Canvas::GetSwapInterval(int& intervalOut)
-{
- if (m_window)
- return (bool)m_window->getSwapInterval(intervalOut);
-
- return false;
-}
-
-void GPG_Canvas::GetDisplayDimensions(int &width, int &height)
- {
- unsigned int uiwidth;
- unsigned int uiheight;
-
- GHOST_ISystem *system = GHOST_ISystem::getSystem();
- system->getMainDisplayDimensions(uiwidth, uiheight);
-
- width = uiwidth;
- height = uiheight;
-}
-
-void GPG_Canvas::ResizeWindow(int width, int height)
-{
- if (m_window->getState() == GHOST_kWindowStateFullScreen)
- {
- GHOST_ISystem* system = GHOST_ISystem::getSystem();
- GHOST_DisplaySetting setting;
- setting.xPixels = width;
- setting.yPixels = height;
- //XXX allow these to be changed or kept from previous state
- setting.bpp = 32;
- setting.frequency = 60;
-
- system->updateFullScreen(setting, &m_window);
- }
-
- m_window->setClientSize(width, height);
-
- Resize(width, height);
-}
-
-void GPG_Canvas::SetFullScreen(bool enable)
-{
- if (enable)
- m_window->setState(GHOST_kWindowStateFullScreen);
- else
- m_window->setState(GHOST_kWindowStateNormal);
-}
-
-bool GPG_Canvas::GetFullScreen()
-{
- return m_window->getState() == GHOST_kWindowStateFullScreen;
-}
-
-float GPG_Canvas::GetMouseNormalizedX(int x)
-{
- return float(x)/this->GetWidth();
-}
-
-float GPG_Canvas::GetMouseNormalizedY(int y)
-{
- return float(y)/this->GetHeight();
-}
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
deleted file mode 100644
index 18afbf6cd9e..00000000000
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
+++ /dev/null
@@ -1,76 +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 GPG_Canvas.h
- * \ingroup player
- */
-
-#ifndef __GPG_CANVAS_H__
-#define __GPG_CANVAS_H__
-
-#ifdef WIN32
-#pragma warning (disable:4786)
-#endif /* WIN32 */
-
-#include "GPC_Canvas.h"
-
-#include "GHOST_IWindow.h"
-
-
-class GPG_Canvas : public GPC_Canvas
-{
-protected:
- /** GHOST window. */
- GHOST_IWindow* m_window;
-
-public:
- GPG_Canvas(GHOST_IWindow* window);
- virtual ~GPG_Canvas(void);
-
- virtual void Init(void);
- virtual void SetMousePosition(int x, int y);
- virtual void SetMouseState(RAS_MouseState mousestate);
- virtual void SwapBuffers();
- virtual void SetSwapInterval(int interval);
- virtual bool GetSwapInterval(int& intervalOut);
-
- virtual int GetMouseX(int x) { return x; }
- virtual int GetMouseY(int y) { return y; }
- virtual float GetMouseNormalizedX(int x);
- virtual float GetMouseNormalizedY(int y);
-
- virtual void GetDisplayDimensions(int &width, int &height);
-
- virtual void ResizeWindow(int width, int height);
- virtual void SetFullScreen(bool enable);
- virtual bool GetFullScreen();
-
- bool BeginDraw() { return true; }
- void EndDraw() {};
-};
-
-#endif /* __GPG_CANVAS_H__ */
diff --git a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp b/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp
deleted file mode 100644
index eefaa3730cf..00000000000
--- a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp
+++ /dev/null
@@ -1,165 +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 *****
- * GHOST Blender Player keyboard device implementation.
- */
-
-/** \file gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp
- * \ingroup player
- */
-
-
-#include "GPG_KeyboardDevice.h"
-
-GPG_KeyboardDevice::GPG_KeyboardDevice(void)
-{
- m_reverseKeyTranslateTable[GHOST_kKeyA ] = KX_AKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyB ] = KX_BKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyC ] = KX_CKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyD ] = KX_DKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyE ] = KX_EKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF ] = KX_FKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyG ] = KX_GKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyH ] = KX_HKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyI ] = KX_IKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyJ ] = KX_JKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyK ] = KX_KKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyL ] = KX_LKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyM ] = KX_MKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyN ] = KX_NKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyO ] = KX_OKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyP ] = KX_PKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyQ ] = KX_QKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyR ] = KX_RKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyS ] = KX_SKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyT ] = KX_TKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyU ] = KX_UKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyV ] = KX_VKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyW ] = KX_WKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyX ] = KX_XKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyY ] = KX_YKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyZ ] = KX_ZKEY ;
-
- m_reverseKeyTranslateTable[GHOST_kKey0 ] = KX_ZEROKEY ;
- m_reverseKeyTranslateTable[GHOST_kKey1 ] = KX_ONEKEY ;
- m_reverseKeyTranslateTable[GHOST_kKey2 ] = KX_TWOKEY ;
- m_reverseKeyTranslateTable[GHOST_kKey3 ] = KX_THREEKEY ;
- m_reverseKeyTranslateTable[GHOST_kKey4 ] = KX_FOURKEY ;
- m_reverseKeyTranslateTable[GHOST_kKey5 ] = KX_FIVEKEY ;
- m_reverseKeyTranslateTable[GHOST_kKey6 ] = KX_SIXKEY ;
- m_reverseKeyTranslateTable[GHOST_kKey7 ] = KX_SEVENKEY ;
- m_reverseKeyTranslateTable[GHOST_kKey8 ] = KX_EIGHTKEY ;
- m_reverseKeyTranslateTable[GHOST_kKey9 ] = KX_NINEKEY ;
-
- // Middle keyboard area keys
- m_reverseKeyTranslateTable[GHOST_kKeyPause ] = KX_PAUSEKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyInsert ] = KX_INSERTKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyDelete ] = KX_DELKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyHome ] = KX_HOMEKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyEnd ] = KX_ENDKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyUpPage ] = KX_PAGEUPKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyDownPage ] = KX_PAGEDOWNKEY ;
-
- // Arrow keys
- m_reverseKeyTranslateTable[GHOST_kKeyUpArrow ] = KX_UPARROWKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyDownArrow ] = KX_DOWNARROWKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyLeftArrow ] = KX_LEFTARROWKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyRightArrow ] = KX_RIGHTARROWKEY ;
-
- // Function keys
- m_reverseKeyTranslateTable[GHOST_kKeyF1 ] = KX_F1KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF2 ] = KX_F2KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF3 ] = KX_F3KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF4 ] = KX_F4KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF5 ] = KX_F5KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF6 ] = KX_F6KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF7 ] = KX_F7KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF8 ] = KX_F8KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF9 ] = KX_F9KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF10 ] = KX_F10KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF11 ] = KX_F11KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF12 ] = KX_F12KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF13 ] = KX_F13KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF14 ] = KX_F14KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF15 ] = KX_F15KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF16 ] = KX_F16KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF17 ] = KX_F17KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF18 ] = KX_F18KEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyF19 ] = KX_F19KEY ;
-
-
- // Numpad keys
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad0 ] = KX_PAD0 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad1 ] = KX_PAD1 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad2 ] = KX_PAD2 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad3 ] = KX_PAD3 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad4 ] = KX_PAD4 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad5 ] = KX_PAD5 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad6 ] = KX_PAD6 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad7 ] = KX_PAD7 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad8 ] = KX_PAD8 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpad9 ] = KX_PAD9 ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpadAsterisk ] = KX_PADASTERKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpadPlus ] = KX_PADPLUSKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpadPeriod ] = KX_PADPERIOD ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpadMinus ] = KX_PADMINUS ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpadSlash ] = KX_PADSLASHKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyNumpadEnter ] = KX_PADENTER ;
-
- // Other keys
- m_reverseKeyTranslateTable[GHOST_kKeyCapsLock ] = KX_CAPSLOCKKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyEsc ] = KX_ESCKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyTab ] = KX_TABKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeySpace ] = KX_SPACEKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyEnter ] = KX_RETKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyBackSpace ] = KX_BACKSPACEKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeySemicolon ] = KX_SEMICOLONKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyPeriod ] = KX_PERIODKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyComma ] = KX_COMMAKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyQuote ] = KX_QUOTEKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyAccentGrave ] = KX_ACCENTGRAVEKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyMinus ] = KX_MINUSKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyPlus ] = KX_PLUSKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeySlash ] = KX_SLASHKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyBackslash ] = KX_BACKSLASHKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyEqual ] = KX_EQUALKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyLeftBracket ] = KX_LEFTBRACKETKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyRightBracket ] = KX_RIGHTBRACKETKEY ;
-
- m_reverseKeyTranslateTable[GHOST_kKeyOS ] = KX_OSKEY ;
-
- // Modifier keys.
- m_reverseKeyTranslateTable[GHOST_kKeyLeftControl ] = KX_LEFTCTRLKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyRightControl ] = KX_RIGHTCTRLKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyLeftAlt ] = KX_LEFTALTKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyRightAlt ] = KX_RIGHTALTKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyLeftShift ] = KX_LEFTSHIFTKEY ;
- m_reverseKeyTranslateTable[GHOST_kKeyRightShift ] = KX_RIGHTSHIFTKEY ;
-}
-
-
-GPG_KeyboardDevice::~GPG_KeyboardDevice(void)
-{
-}
diff --git a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.h b/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.h
deleted file mode 100644
index ff8d56db40a..00000000000
--- a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.h
+++ /dev/null
@@ -1,56 +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 GPG_KeyboardDevice.h
- * \ingroup player
- * \brief GHOST Blender Player keyboard device.
- */
-
-#ifndef __GPG_KEYBOARDDEVICE_H__
-#define __GPG_KEYBOARDDEVICE_H__
-
-#ifdef WIN32
-#pragma warning (disable:4786)
-#endif /* WIN32 */
-
-#include "GHOST_Types.h"
-#include "GPC_KeyboardDevice.h"
-
-/**
- * GHOST implementation of GPC_KeyboardDevice.
- * The contructor fills the keyboard code translation map.
- * Base class GPC_KeyboardDevice does the rest.
- * \see SCA_IInputDevice
- */
-class GPG_KeyboardDevice : public GPC_KeyboardDevice
-{
-public:
- GPG_KeyboardDevice(void);
- virtual ~GPG_KeyboardDevice(void);
-};
-
-#endif /* __GPG_KEYBOARDDEVICE_H__ */
diff --git a/source/gameengine/GamePlayer/ghost/GPG_System.cpp b/source/gameengine/GamePlayer/ghost/GPG_System.cpp
deleted file mode 100644
index 669ab0532d9..00000000000
--- a/source/gameengine/GamePlayer/ghost/GPG_System.cpp
+++ /dev/null
@@ -1,53 +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 *****
- * Blender Player system on GHOST.
- */
-
-/** \file gameengine/GamePlayer/ghost/GPG_System.cpp
- * \ingroup player
- */
-
-
-#include "GPG_System.h"
-#include <assert.h>
-#include "GHOST_ISystem.h"
-
-GPG_System::GPG_System(GHOST_ISystem* system)
-: m_system(system)
-{
- assert(m_system);
-}
-
-
-double GPG_System::GetTimeInSeconds()
-{
- GHOST_TInt64 millis = (GHOST_TInt64)m_system->getMilliSeconds();
- double time = (double)millis;
- time /= 1000.0;
- return time;
-}
-
-
diff --git a/source/gameengine/GamePlayer/ghost/GPG_System.h b/source/gameengine/GamePlayer/ghost/GPG_System.h
deleted file mode 100644
index 1ec7a06d1cf..00000000000
--- a/source/gameengine/GamePlayer/ghost/GPG_System.h
+++ /dev/null
@@ -1,54 +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 GPG_System.h
- * \ingroup player
- * \brief Blender Player system on GHOST.
- */
-
-#ifndef __GPG_SYSTEM_H__
-#define __GPG_SYSTEM_H__
-
-#ifdef WIN32
-#pragma warning (disable:4786) // suppress stl-MSVC debug info warning
-#endif /* WIN32 */
-
-#include "KX_ISystem.h"
-
-class GHOST_ISystem;
-
-class GPG_System : public KX_ISystem
-{
- GHOST_ISystem* m_system;
-
-public:
- GPG_System(GHOST_ISystem* system);
-
- virtual double GetTimeInSeconds();
-};
-
-#endif /* __GPG_SYSTEM_H__ */
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
deleted file mode 100644
index 998058193bb..00000000000
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ /dev/null
@@ -1,1228 +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 *****
- * Start up of the Blender Player on GHOST.
- */
-
-/** \file gameengine/GamePlayer/ghost/GPG_ghost.cpp
- * \ingroup player
- */
-
-
-#include <iostream>
-#include <math.h>
-
-#ifdef __linux__
-#ifdef __alpha__
-#include <signal.h>
-#endif /* __alpha__ */
-#endif /* __linux__ */
-
-#include "KX_KetsjiEngine.h"
-#include "KX_PythonInit.h"
-#include "KX_PythonMain.h"
-#include "KX_PyConstraintBinding.h" // for PHY_SetActiveEnvironment
-
-/**********************************
- * Begin Blender include block
- **********************************/
-#ifdef __cplusplus
-extern "C"
-{
-#endif // __cplusplus
-#include "MEM_guardedalloc.h"
-#include "MEM_CacheLimiterC-Api.h"
-
-#include "BLI_threads.h"
-#include "BLI_mempool.h"
-#include "BLI_blenlib.h"
-
-#include "DNA_scene_types.h"
-#include "DNA_userdef_types.h"
-#include "DNA_genfile.h"
-
-#include "BLO_readfile.h"
-#include "BLO_runtime.h"
-
-#include "BKE_appdir.h"
-#include "BKE_blender.h"
-#include "BKE_global.h"
-#include "BKE_icons.h"
-#include "BKE_image.h"
-#include "BKE_node.h"
-#include "BKE_report.h"
-#include "BKE_library.h"
-#include "BKE_library_remap.h"
-#include "BKE_modifier.h"
-#include "BKE_material.h"
-#include "BKE_text.h"
-#include "BKE_sound.h"
-
-#include "DEG_depsgraph.h"
-
-#include "IMB_imbuf.h"
-#include "IMB_moviecache.h"
-
-#ifdef __APPLE__
- int GHOST_HACK_getFirstFile(char buf[]);
-#endif
-
-// For BLF
-#include "BLF_api.h"
-#include "BLT_translation.h"
-#include "BLT_lang.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
-}
-#endif // __cplusplus
-
-#include "GPU_draw.h"
-
-/**********************************
- * End Blender include block
- **********************************/
-
-#include "BL_System.h"
-#include "GPG_Application.h"
-
-#include "GHOST_ISystem.h"
-#include "RAS_IRasterizer.h"
-
-#include "BKE_main.h"
-
-#include "RNA_define.h"
-
-#ifdef WIN32
-# include <windows.h>
-# if !defined(DEBUG)
-# include <wincon.h>
-# endif // !defined(DEBUG)
-# if defined(_MSC_VER) && defined(_M_X64)
-# include <math.h> /* needed for _set_FMA3_enable */
-# endif
-# include "utfconv.h"
-#endif // WIN32
-
-#ifdef WITH_SDL_DYNLOAD
-# include "sdlew.h"
-#endif
-
-const int kMinWindowWidth = 100;
-const int kMinWindowHeight = 100;
-
-static void mem_error_cb(const char *errorStr)
-{
- fprintf(stderr, "%s", errorStr);
- fflush(stderr);
-}
-
-// library.c will only free window managers with a callback function.
-// We don't actually use a wmWindowManager, but loading a blendfile
-// loads wmWindows, so we need to free those.
-static void wm_free(bContext *C, wmWindowManager *wm)
-{
- BLI_freelistN(&wm->windows);
-}
-
-#ifdef WIN32
-typedef enum {
- SCREEN_SAVER_MODE_NONE = 0,
- SCREEN_SAVER_MODE_PREVIEW,
- SCREEN_SAVER_MODE_SAVER,
- SCREEN_SAVER_MODE_CONFIGURATION,
- SCREEN_SAVER_MODE_PASSWORD,
-} ScreenSaverMode;
-
-static ScreenSaverMode scr_saver_mode = SCREEN_SAVER_MODE_NONE;
-static HWND scr_saver_hwnd = NULL;
-
-static BOOL scr_saver_init(int argc, char **argv)
-{
- scr_saver_mode = SCREEN_SAVER_MODE_NONE;
- scr_saver_hwnd = NULL;
- BOOL ret = false;
-
- int len = ::strlen(argv[0]);
- if (len > 4 && !::stricmp(".scr", argv[0] + len - 4))
- {
- scr_saver_mode = SCREEN_SAVER_MODE_CONFIGURATION;
- ret = true;
- if (argc >= 2)
- {
- if (argc >= 3)
- {
- scr_saver_hwnd = (HWND) ::atoi(argv[2]);
- }
- if (!::stricmp("/c", argv[1]))
- {
- scr_saver_mode = SCREEN_SAVER_MODE_CONFIGURATION;
- if (scr_saver_hwnd == NULL)
- scr_saver_hwnd = ::GetForegroundWindow();
- }
- else if (!::stricmp("/s", argv[1]))
- {
- scr_saver_mode = SCREEN_SAVER_MODE_SAVER;
- }
- else if (!::stricmp("/a", argv[1]))
- {
- scr_saver_mode = SCREEN_SAVER_MODE_PASSWORD;
- }
- else if (!::stricmp("/p", argv[1])
- || !::stricmp("/l", argv[1]))
- {
- scr_saver_mode = SCREEN_SAVER_MODE_PREVIEW;
- }
- }
- }
- return ret;
-}
-
-#endif /* WIN32 */
-
-static void usage(const char* program, bool isBlenderPlayer)
-{
- const char * consoleoption;
- const char * example_filename = "";
- const char * example_pathname = "";
-
-#ifdef _WIN32
- consoleoption = "[-c] ";
-#else
- consoleoption = "";
-#endif
-
- if (isBlenderPlayer) {
- example_filename = "filename.blend";
-#ifdef _WIN32
- example_pathname = "c:\\";
-#else
- example_pathname = "/home/user/";
-#endif
- }
- printf("\n");
- printf("usage: %s [--options] %s\n\n", program, example_filename);
- printf("Available options are: [-w [w h l t]] [-f [fw fh fb ff]] %s[-g gamengineoptions] ", consoleoption);
- printf("[-s stereomode] [-m aasamples]\n");
- printf("Optional parameters must be passed in order.\n");
- printf("Default values are set in the blend file.\n\n");
- printf(" -h: Prints this command summary\n\n");
- printf(" -w: display in a window\n");
- printf(" --Optional parameters--\n");
- printf(" w = window width\n");
- printf(" h = window height\n");
- printf(" l = window left coordinate\n");
- printf(" t = window top coordinate\n");
- printf(" Note: To define 'w' or 'h', both must be used.");
- printf("Also, to define 'l' or 't', all four parameters must be used.\n");
- printf(" Example: -w or -w 500 300 or -w 500 300 0 0\n\n");
- printf(" -f: start game in fullscreen mode\n");
- printf(" --Optional parameters--\n");
- printf(" fw = fullscreen mode pixel width (use 0 to detect automatically)\n");
- printf(" fh = fullscreen mode pixel height (use 0 to detect automatically)\n");
- printf(" fb = fullscreen mode bits per pixel (default unless set in the blend file: 32)\n");
- printf(" ff = fullscreen mode frequency (default unless set in the blend file: 60)\n");
- printf(" Note: To define 'fw'' or 'fh'', both must be used.\n");
- printf(" Example: -f or -f 1024 768 or -f 0 0 16 or -f 1024 728 16 30\n\n");
- printf(" -s: start player in stereoscopy mode (requires 3D capable hardware)\n");
- printf(" stereomode: nostereo (default unless stereo is set in the blend file)\n");
- printf(" anaglyph (Red-Blue glasses)\n");
- printf(" sidebyside (Left Right)\n");
- printf(" syncdoubling (Above Below)\n");
- printf(" 3dtvtopbottom (Squashed Top-Bottom for passive glasses)\n");
- printf(" interlace (Interlace horizontally)\n");
- printf(" vinterlace (Vertical interlace for autostereo display)\n");
- printf(" hwpageflip (Quad buffered shutter glasses)\n");
- printf(" Example: -s sidebyside or -s vinterlace\n\n");
- printf(" -D: start player in dome mode\n");
- printf(" --Optional parameters--\n");
- printf(" angle = field of view in degrees\n");
- printf(" tilt = tilt angle in degrees\n");
- printf(" warpdata = a file to use for warping the image (absolute path)\n");
- printf(" mode: fisheye (Fisheye)\n");
- printf(" truncatedfront (Front-Truncated)\n");
- printf(" truncatedrear (Rear-Truncated)\n");
- printf(" cubemap (Cube Map)\n");
- printf(" sphericalpanoramic (Spherical Panoramic)\n");
- printf(" Example: -D or -D mode cubemap\n\n");
- printf(" -m: maximum anti-aliasing (eg. 2,4,8,16)\n\n");
- printf(" -i: parent window's ID\n\n");
-#ifdef _WIN32
- printf(" -c: keep console window open\n\n");
-#endif
- printf(" -d: turn debugging on\n\n");
- printf(" -g: game engine options:\n\n");
- printf(" Name Default Description\n");
- printf(" ------------------------------------------------------------------------\n");
- printf(" fixedtime 0 \"Enable all frames\"\n");
- printf(" nomipmap 0 Disable mipmaps\n");
- printf(" show_framerate 0 Show the frame rate\n");
- printf(" show_properties 0 Show debug properties\n");
- printf(" show_profile 0 Show profiling information\n");
- printf(" blender_material 0 Enable material settings\n");
- printf(" ignore_deprecation_warnings 1 Ignore deprecation warnings\n");
- printf("\n");
- printf(" - : all arguments after this are ignored, allowing python to access them from sys.argv\n");
- printf("\n");
- printf("example: %s -w 320 200 10 10 -g noaudio %s%s\n", program, example_pathname, example_filename);
- printf("example: %s -g show_framerate = 0 %s%s\n", program, example_pathname, example_filename);
- printf("example: %s -i 232421 -m 16 %s%s\n\n", program, example_pathname, example_filename);
-}
-
-static void get_filename(int argc, char **argv, char *filename)
-{
-#ifdef __APPLE__
- /* On Mac we park the game file (called game.blend) in the application bundle.
- * The executable is located in the bundle as well.
- * Therefore, we can locate the game relative to the executable.
- */
- int srclen = ::strlen(argv[0]);
- int len = 0;
- char *gamefile = NULL;
-
- filename[0] = '\0';
-
- if (argc > 1) {
- if (BLI_exists(argv[argc-1])) {
- BLI_strncpy(filename, argv[argc-1], FILE_MAX);
- }
- if (::strncmp(argv[argc-1], "-psn_", 5)==0) {
- static char firstfilebuf[512];
- if (GHOST_HACK_getFirstFile(firstfilebuf)) {
- BLI_strncpy(filename, firstfilebuf, FILE_MAX);
- }
- }
- }
-
- srclen -= ::strlen("MacOS/blenderplayer");
- if (srclen > 0) {
- len = srclen + ::strlen("Resources/game.blend");
- gamefile = new char [len + 1];
- ::strcpy(gamefile, argv[0]);
- ::strcpy(gamefile + srclen, "Resources/game.blend");
- //::printf("looking for file: %s\n", filename);
-
- if (BLI_exists(gamefile))
- BLI_strncpy(filename, gamefile, FILE_MAX);
-
- delete [] gamefile;
- }
-
-#else
- filename[0] = '\0';
-
- if (argc > 1)
- BLI_strncpy(filename, argv[argc-1], FILE_MAX);
-#endif // !_APPLE
-}
-
-static BlendFileData *load_game_data(const char *progname, char *filename = NULL, char *relativename = NULL)
-{
- ReportList reports;
- BlendFileData *bfd = NULL;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- /* try to load ourself, will only work if we are a runtime */
- if (BLO_is_a_runtime(progname)) {
- bfd= BLO_read_runtime(progname, &reports);
- if (bfd) {
- bfd->type= BLENFILETYPE_RUNTIME;
- BLI_strncpy(bfd->main->name, progname, sizeof(bfd->main->name));
- }
- } else {
- bfd= BLO_read_from_file(progname, &reports, BLO_READ_SKIP_NONE);
- }
-
- if (!bfd && filename) {
- bfd = load_game_data(filename);
- if (!bfd) {
- printf("Loading %s failed: ", filename);
- BKE_reports_print(&reports, RPT_ERROR);
- }
- }
-
- BKE_reports_clear(&reports);
-
- return bfd;
-}
-
-static bool GPG_NextFrame(GHOST_ISystem* system, GPG_Application *app, int &exitcode, STR_String &exitstring, GlobalSettings *gs)
-{
- bool run = true;
- system->processEvents(false);
- system->dispatchEvents();
- app->EngineNextFrame();
- if ((exitcode = app->getExitRequested())) {
- run = false;
- exitstring = app->getExitString();
- *gs = *app->getGlobalSettings();
- }
- return run;
-}
-
-struct GPG_NextFrameState {
- GHOST_ISystem* system;
- GPG_Application *app;
- GlobalSettings *gs;
-} gpg_nextframestate;
-
-static int GPG_PyNextFrame(void *state0)
-{
- GPG_NextFrameState *state = (GPG_NextFrameState *) state0;
- int exitcode;
- STR_String exitstring;
- bool run = GPG_NextFrame(state->system, state->app, exitcode, exitstring, state->gs);
- if (run) return 0;
- else {
- if (exitcode)
- fprintf(stderr, "Exit code %d: %s\n", exitcode, exitstring.ReadPtr());
- return 1;
- }
-}
-
-int main(
- int argc,
-#ifdef WIN32
- char **UNUSED(argv_c)
-#else
- char **argv
-#endif
- )
-{
- int i;
- int argc_py_clamped= argc; /* use this so python args can be added after ' - ' */
- bool error = false;
- SYS_SystemHandle syshandle = SYS_GetSystem();
- bool fullScreen = false;
- bool fullScreenParFound = false;
- bool windowParFound = false;
-#ifdef WIN32
- bool closeConsole = true;
-#endif
- RAS_IRasterizer::StereoMode stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
- bool stereoWindow = false;
- bool stereoParFound = false;
- int stereoFlag = STEREO_NOSTEREO;
- int domeFov = -1;
- int domeTilt = -200;
- int domeMode = 0;
- char* domeWarp = NULL;
- Text *domeText = NULL;
- int windowLeft = 100;
- int windowTop = 100;
- int windowWidth = 640;
- int windowHeight = 480;
- GHOST_TUns32 fullScreenWidth = 0;
- GHOST_TUns32 fullScreenHeight= 0;
- int fullScreenBpp = 32;
- int fullScreenFrequency = 60;
- GHOST_TEmbedderWindowID parentWindow = 0;
- bool isBlenderPlayer = false; //true when lauching from blender or command line. false for bundled player
- int validArguments=0;
- bool samplesParFound = false;
- GHOST_TUns16 aasamples = 0;
- int alphaBackground = 0;
-
-#ifdef WIN32
- char **argv;
- int argv_num;
-
- /* We delay loading of openmp so we can set the policy here. */
-# if defined(_MSC_VER)
- _putenv_s("OMP_WAIT_POLICY", "PASSIVE");
-# endif
-
- /* FMA3 support in the 2013 CRT is broken on Vista and Windows 7 RTM (fixed in SP1). Just disable it. */
-# if defined(_MSC_VER) && defined(_M_X64)
- _set_FMA3_enable(0);
-# endif
-
- /* Win32 Unicode Args */
- /* 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);
- argv = (char**)malloc(argc * sizeof(char *));
- for (argv_num = 0; argv_num < argc; argv_num++) {
- argv[argv_num] = alloc_utf_8_from_16(argv_16[argv_num], 0);
- }
- LocalFree(argv_16);
- }
-#endif /* WIN32 */
-
-#ifdef __linux__
-#ifdef __alpha__
- signal (SIGFPE, SIG_IGN);
-#endif /* __alpha__ */
-#endif /* __linux__ */
-
-#ifdef WITH_SDL_DYNLOAD
- sdlewInit();
-#endif
-
- BKE_appdir_program_path_init(argv[0]);
- BKE_tempdir_init(NULL);
-
- // We don't use threads directly in the BGE, but we need to call this so things like
- // freeing up GPU_Textures works correctly.
- BLI_threadapi_init();
-
- DNA_sdna_current_init();
-
- RNA_init();
-
- init_nodesystem();
-
- BKE_blender_globals_init();
-
- // We load our own G.main, so free the one that BKE_blender_globals_init() gives us
- BKE_main_free(G.main);
- G.main = NULL;
-
- MEM_CacheLimiter_set_disabled(true);
- IMB_init();
- BKE_images_init();
- BKE_modifier_init();
- DEG_register_node_types();
-
-#ifdef WITH_FFMPEG
- IMB_ffmpeg_init();
-#endif
-
- // Setup builtin font for BLF (mostly copied from creator.c, wm_init_exit.c and interface_style.c)
- BLF_init();
- BLT_lang_init();
- BLT_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)
- printf("argv[0] = '%s'\n", argv[0]);
-#endif
-
-#ifdef WIN32
- if (scr_saver_init(argc, argv))
- {
- switch (scr_saver_mode)
- {
- case SCREEN_SAVER_MODE_CONFIGURATION:
- MessageBox(scr_saver_hwnd, "This screen saver has no options that you can set", "Screen Saver", MB_OK);
- break;
- case SCREEN_SAVER_MODE_PASSWORD:
- /* This is W95 only, which we currently do not support.
- * Fall-back to normal screen saver behavior in that case... */
- case SCREEN_SAVER_MODE_SAVER:
- fullScreen = true;
- fullScreenParFound = true;
- break;
-
- case SCREEN_SAVER_MODE_PREVIEW:
- /* This will actually be handled somewhere below... */
- break;
- }
- }
-#endif
- // XXX add the ability to change this values to the command line parsing.
- U.mixbufsize = 2048;
- U.audiodevice = 2;
- U.audiorate = 44100;
- U.audioformat = 0x24;
- U.audiochannels = 2;
-
- // XXX this one too
- U.anisotropic_filter = 2;
- // enable fast mipmap generation
- U.use_gpu_mipmap = 1;
-
- BKE_sound_init_once();
-
- // Initialize a default material for meshes without materials.
- init_def_material();
-
- BKE_library_callback_free_window_manager_set(wm_free);
-
- /* if running blenderplayer the last argument can't be parsed since it has to be the filename. else it is bundled */
- isBlenderPlayer = !BLO_is_a_runtime(argv[0]);
- if (isBlenderPlayer)
- validArguments = argc - 1;
- else
- validArguments = argc;
-
-
- /* Parsing command line arguments (can be set from WM_OT_blenderplayer_start) */
-#if defined(DEBUG)
- printf("Parsing command line arguments...\n");
- printf("Num of arguments is: %i\n", validArguments-1); //-1 because i starts at 1
-#endif
-
- for (i = 1; (i < validArguments) && !error
-#ifdef WIN32
- && scr_saver_mode == SCREEN_SAVER_MODE_NONE
-#endif
- ;)
-
- {
-#if defined(DEBUG)
- printf("argv[%d] = '%s'\n", i, argv[i]);
-#endif
- if (argv[i][0] == '-')
- {
- /* ignore all args after " - ", allow python to have own args */
- if (argv[i][1]=='\0') {
- argc_py_clamped= i;
- break;
- }
-
- switch (argv[i][1])
- {
- case 'g': //game engine options (show_framerate, fixedtime, etc)
- {
- i++;
- if (i <= validArguments)
- {
- char* paramname = argv[i];
- // Check for single value versus assignment
- if (i+1 <= validArguments && (*(argv[i+1]) == '='))
- {
- i++;
- if (i + 1 <= validArguments)
- {
- i++;
- // Assignment
- SYS_WriteCommandLineInt(syshandle, paramname, atoi(argv[i]));
- SYS_WriteCommandLineFloat(syshandle, paramname, atof(argv[i]));
- SYS_WriteCommandLineString(syshandle, paramname, argv[i]);
-#if defined(DEBUG)
- printf("%s = '%s'\n", paramname, argv[i]);
-#endif
- i++;
- }
- else
- {
- error = true;
- printf("error: argument assignment %s without value.\n", paramname);
- }
- }
- else
- {
-// SYS_WriteCommandLineInt(syshandle, argv[i++], 1);
- }
- }
- break;
- }
- case 'd': //debug on
- {
- i++;
- G.debug |= G_DEBUG;
- MEM_set_memory_debug();
-#ifndef NDEBUG
- BLI_mempool_set_memory_debug();
-#endif
- break;
- }
- case 'f': //fullscreen mode
- {
- i++;
- fullScreen = true;
- fullScreenParFound = true;
- if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
- {
- fullScreenWidth = atoi(argv[i++]);
- fullScreenHeight = atoi(argv[i++]);
- if ((i + 1) <= validArguments && argv[i][0] != '-')
- {
- fullScreenBpp = atoi(argv[i++]);
- if ((i + 1) <= validArguments && argv[i][0] != '-')
- fullScreenFrequency = atoi(argv[i++]);
- }
- }
- else if ((i + 1) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
- {
- error = true;
- printf("error: to define fullscreen width or height, both options must be used.\n");
- }
- break;
- }
- case 'w': //display in a window
- {
- i++;
- fullScreen = false;
- windowParFound = true;
-
- // Parse window position and size options
- if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
- {
- windowWidth = atoi(argv[i++]);
- windowHeight = atoi(argv[i++]);
-
- if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
- {
- windowLeft = atoi(argv[i++]);
- windowTop = atoi(argv[i++]);
- }
- else if ((i + 1) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
- {
- error = true;
- printf("error: to define the window left or right coordinates, both options must be used.\n");
- }
- }
- else if ((i + 1) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-')
- {
- error = true;
- printf("error: to define the window's width or height, both options must be used.\n");
- }
- break;
- }
- case 'h': //display help
- {
- usage(argv[0], isBlenderPlayer);
- return 0;
- break;
- }
- case 'i': //parent window ID
- {
- i++;
- if ( (i + 1) <= validArguments )
- parentWindow = (GHOST_TEmbedderWindowID)atoll(argv[i++]);
- else {
- error = true;
- printf("error: too few options for parent window argument.\n");
- }
-#if defined(DEBUG)
- printf("XWindows ID = %d\n", parentWindow);
-#endif // defined(DEBUG)
- break;
- }
- case 'm': //maximum anti-aliasing (eg. 2,4,8,16)
- {
- i++;
- samplesParFound = true;
- if ((i+1) <= validArguments )
- aasamples = atoi(argv[i++]);
- else
- {
- error = true;
- printf("error: No argument supplied for -m");
- }
- break;
- }
- case 'c': //keep console (windows only)
- {
- i++;
-#ifdef WIN32
- closeConsole = false;
-#endif
- break;
- }
- case 's': //stereo mode
- {
- i++;
- if ((i + 1) <= validArguments)
- {
- stereoParFound = true;
- stereoFlag = STEREO_ENABLED;
-
- if (!strcmp(argv[i], "nostereo")) // may not be redundant if the file has different setting
- {
- stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
- stereoFlag = STEREO_NOSTEREO;
- }
-
- // only the hardware pageflip method needs a stereo window
- else if (!strcmp(argv[i], "hwpageflip")) {
- stereomode = RAS_IRasterizer::RAS_STEREO_QUADBUFFERED;
- stereoWindow = true;
- }
- else if (!strcmp(argv[i], "syncdoubling"))
- stereomode = RAS_IRasterizer::RAS_STEREO_ABOVEBELOW;
-
- else if (!strcmp(argv[i], "3dtvtopbottom"))
- stereomode = RAS_IRasterizer::RAS_STEREO_3DTVTOPBOTTOM;
-
- else if (!strcmp(argv[i], "anaglyph"))
- stereomode = RAS_IRasterizer::RAS_STEREO_ANAGLYPH;
-
- else if (!strcmp(argv[i], "sidebyside"))
- stereomode = RAS_IRasterizer::RAS_STEREO_SIDEBYSIDE;
-
- else if (!strcmp(argv[i], "interlace"))
- stereomode = RAS_IRasterizer::RAS_STEREO_INTERLACED;
-
- else if (!strcmp(argv[i], "vinterlace"))
- stereomode = RAS_IRasterizer::RAS_STEREO_VINTERLACE;
-
-#if 0
-// // future stuff
-// else if (!strcmp(argv[i], "stencil")
-// stereomode = RAS_STEREO_STENCIL;
-#endif
- else
- {
- error = true;
- printf("error: stereomode '%s' unrecognized.\n", argv[i]);
- }
-
- i++;
- }
- else
- {
- error = true;
- printf("error: too few options for stereo argument.\n");
- }
- break;
- }
- case 'D': //dome mode
- {
- stereoFlag = STEREO_DOME;
- stereomode = RAS_IRasterizer::RAS_STEREO_DOME;
- i++;
- if ((i + 1) <= validArguments)
- {
- if (!strcmp(argv[i], "angle")) {
- i++;
- domeFov = atoi(argv[i++]);
- }
- if (!strcmp(argv[i], "tilt")) {
- i++;
- domeTilt = atoi(argv[i++]);
- }
- if (!strcmp(argv[i], "warpdata")) {
- i++;
- domeWarp = argv[i++];
- }
- if (!strcmp(argv[i], "mode")) {
- i++;
- if (!strcmp(argv[i], "fisheye"))
- domeMode = DOME_FISHEYE;
-
- else if (!strcmp(argv[i], "truncatedfront"))
- domeMode = DOME_TRUNCATED_FRONT;
-
- else if (!strcmp(argv[i], "truncatedrear"))
- domeMode = DOME_TRUNCATED_REAR;
-
- else if (!strcmp(argv[i], "cubemap"))
- domeMode = DOME_ENVMAP;
-
- else if (!strcmp(argv[i], "sphericalpanoramic"))
- domeMode = DOME_PANORAM_SPH;
-
- else
- printf("error: %s is not a valid dome mode.\n", argv[i]);
- }
- i++;
- }
- break;
- }
- case 'a': // allow window to blend with display background
- {
- i++;
- alphaBackground = 1;
- break;
- }
- default: //not recognized
- {
- printf("Unknown argument: %s\n", argv[i++]);
- break;
- }
- }
- }
- else
- {
- i++;
- }
- }
-
- if ((windowWidth < kMinWindowWidth) || (windowHeight < kMinWindowHeight))
- {
- error = true;
- printf("error: window size too small.\n");
- }
-
- if (error )
- {
- usage(argv[0], isBlenderPlayer);
- return 0;
- }
-
-#ifdef WIN32
- if (scr_saver_mode != SCREEN_SAVER_MODE_CONFIGURATION)
-#endif
- {
- // Create the system
- if (GHOST_ISystem::createSystem() == GHOST_kSuccess) {
- GHOST_ISystem* system = GHOST_ISystem::getSystem();
- assertd(system);
-
- if (!fullScreenWidth || !fullScreenHeight)
- system->getMainDisplayDimensions(fullScreenWidth, fullScreenHeight);
- // process first batch of events. If the user
- // drops a file on top off the blenderplayer icon, we
- // receive an event with the filename
-
- system->processEvents(0);
-
- // this bracket is needed for app (see below) to get out
- // of scope before GHOST_ISystem::disposeSystem() is called.
- {
- int exitcode = KX_EXIT_REQUEST_NO_REQUEST;
- STR_String exitstring = "";
- GPG_Application app(system);
- bool firstTimeRunning = true;
- char filename[FILE_MAX];
- char pathname[FILE_MAX];
- char *titlename;
-
- get_filename(argc_py_clamped, argv, filename);
- if (filename[0])
- BLI_path_cwd(filename, sizeof(filename));
-
-
- // fill the GlobalSettings with the first scene files
- // those may change during the game and persist after using Game Actuator
- GlobalSettings gs;
-
- do {
- // Read the Blender file
- BlendFileData *bfd;
-
- // if we got an exitcode 3 (KX_EXIT_REQUEST_START_OTHER_GAME) load a different file
- if (exitcode == KX_EXIT_REQUEST_START_OTHER_GAME)
- {
- char basedpath[FILE_MAX];
-
- // base the actuator filename relative to the last file
- BLI_strncpy(basedpath, exitstring.Ptr(), sizeof(basedpath));
- BLI_path_abs(basedpath, pathname);
-
- bfd = load_game_data(basedpath);
-
- if (!bfd) {
- // just add "//" in front of it
- char temppath[FILE_MAX] = "//";
- BLI_strncpy(temppath + 2, basedpath, FILE_MAX - 2);
-
- BLI_path_abs(temppath, pathname);
- bfd = load_game_data(temppath);
- }
- }
- else {
- bfd = load_game_data(BKE_appdir_program_path(), filename[0]? filename: NULL);
- }
-
-#if defined(DEBUG)
- printf("Game data loaded from %s\n", filename);
-#endif
-
- if (!bfd) {
- usage(argv[0], isBlenderPlayer);
- error = true;
- exitcode = KX_EXIT_REQUEST_QUIT_GAME;
- }
- else {
- /* Setting options according to the blend file if not overriden in the command line */
-#ifdef WIN32
-#if !defined(DEBUG)
- if (closeConsole) {
- system->toggleConsole(0); // Close a console window
- }
-#endif // !defined(DEBUG)
-#endif // WIN32
- Main *maggie = bfd->main;
- Scene *scene = bfd->curscene;
- G.main = maggie;
-
- if (firstTimeRunning) {
- G.fileflags = bfd->fileflags;
-
- gs.matmode= scene->gm.matmode;
- gs.glslflag= scene->gm.flag;
- }
-
- //Seg Fault; icon.c gIcons == 0
- BKE_icons_init(1);
-
- titlename = maggie->name;
-
- // Check whether the game should be displayed full-screen
- if ((!fullScreenParFound) && (!windowParFound)) {
- // Only use file settings when command line did not override
- if ((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) {
- //printf("fullscreen option found in Blender file\n");
- fullScreen = true;
- fullScreenWidth= scene->gm.xplay;
- fullScreenHeight= scene->gm.yplay;
- fullScreenFrequency= scene->gm.freqplay;
- fullScreenBpp = scene->gm.depth;
- }
- else
- {
- fullScreen = false;
- windowWidth = scene->gm.xplay;
- windowHeight = scene->gm.yplay;
- }
- }
-
-
- // Check whether the game should be displayed in stereo (dome included)
- if (!stereoParFound) {
- // Only use file settings when command line did not override
- if (scene->gm.stereoflag == STEREO_ENABLED) {
- stereomode = (RAS_IRasterizer::StereoMode) scene->gm.stereomode;
- if (stereomode == RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
- stereoWindow = true;
- }
- }
- else {
- scene->gm.stereoflag = STEREO_ENABLED;
- }
-
- if (!samplesParFound)
- aasamples = scene->gm.aasamples;
-
- // Dome specific settings
- if (stereoFlag == STEREO_DOME) {
- stereomode = RAS_IRasterizer::RAS_STEREO_DOME;
- scene->gm.stereoflag = STEREO_DOME;
- if (domeFov > 89)
- scene->gm.dome.angle = domeFov;
- if (domeTilt > -180)
- scene->gm.dome.tilt = domeTilt;
- if (domeMode > 0)
- scene->gm.dome.mode = domeMode;
- if (domeWarp) {
- //XXX to do: convert relative to absolute path
- domeText= BKE_text_load(G.main, domeWarp, "");
- if (!domeText)
- printf("error: invalid warpdata text file - %s\n", domeWarp);
- else
- scene->gm.dome.warptext = domeText;
- }
- }
-
- // GPG_Application app (system, maggie, startscenename);
- app.SetGameEngineData(maggie, scene, &gs, argc, argv); /* this argc cant be argc_py_clamped, since python uses it */
- BLI_strncpy(pathname, maggie->name, sizeof(pathname));
- if (G.main != maggie) {
- BLI_strncpy(G.main->name, maggie->name, sizeof(G.main->name));
- }
-#ifdef WITH_PYTHON
- setGamePythonPath(G.main->name);
-#endif
- if (firstTimeRunning) {
- firstTimeRunning = false;
-
- if (fullScreen) {
-#ifdef WIN32
- if (scr_saver_mode == SCREEN_SAVER_MODE_SAVER)
- {
- app.startScreenSaverFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
- stereoWindow, stereomode, aasamples);
- }
- else
-#endif
- {
- app.startFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
- stereoWindow, stereomode, alphaBackground, aasamples, (scene->gm.playerflag & GAME_PLAYER_DESKTOP_RESOLUTION));
- }
- }
- else
- {
-#ifdef __APPLE__
- // on Mac's we'll show the executable name instead of the 'game.blend' name
- char tempname[1024], *appstring;
- ::strcpy(tempname, titlename);
-
- appstring = strstr(tempname, ".app/");
- if (appstring) {
- appstring[2] = 0;
- titlename = &tempname[0];
- }
-#endif
- // Strip the path so that we have the name of the game file
- STR_String path = titlename;
-#ifndef WIN32
- vector<STR_String> parts = path.Explode('/');
-#else // WIN32
- vector<STR_String> parts = path.Explode('\\');
-#endif // WIN32
- STR_String title;
- if (parts.size()) {
- title = parts[parts.size()-1];
- parts = title.Explode('.');
- if (parts.size() > 1)
- {
- title = parts[0];
- }
- }
- else {
- title = "blenderplayer";
- }
-#ifdef WIN32
- if (scr_saver_mode == SCREEN_SAVER_MODE_PREVIEW)
- {
- app.startScreenSaverPreview(scr_saver_hwnd, stereoWindow, stereomode, aasamples);
- }
- else
-#endif
- {
- if (parentWindow != 0)
- app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode, aasamples);
- else
- app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight,
- stereoWindow, stereomode, alphaBackground, aasamples);
-
- if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) {
- GPU_set_mipmap(0);
- }
-
- GPU_set_anisotropic(U.anisotropic_filter);
- GPU_set_gpu_mipmapping(U.use_gpu_mipmap);
- }
- }
- }
- else {
- app.StartGameEngine(stereomode);
- exitcode = KX_EXIT_REQUEST_NO_REQUEST;
- }
-
- // Add the application as event consumer
- system->addEventConsumer(&app);
-
- // Enter main loop
- bool run = true;
- char *python_main = NULL;
- pynextframestate.state = NULL;
- pynextframestate.func = NULL;
-#ifdef WITH_PYTHON
- python_main = KX_GetPythonMain(scene);
-#endif // WITH_PYTHON
- if (python_main) {
- char *python_code = KX_GetPythonCode(maggie, python_main);
- if (python_code) {
-#ifdef WITH_PYTHON
- // Set python environement variable.
- KX_Scene *startscene = app.GetStartScene();
- KX_SetActiveScene(startscene);
- PHY_SetActiveEnvironment(startscene->GetPhysicsEnvironment());
-
- gpg_nextframestate.system = system;
- gpg_nextframestate.app = &app;
- gpg_nextframestate.gs = &gs;
- pynextframestate.state = &gpg_nextframestate;
- pynextframestate.func = &GPG_PyNextFrame;
-
- printf("Yielding control to Python script '%s'...\n", python_main);
- PyRun_SimpleString(python_code);
- printf("Exit Python script '%s'\n", python_main);
-#endif // WITH_PYTHON
- MEM_freeN(python_code);
- }
- else {
- fprintf(stderr, "ERROR: cannot yield control to Python: no Python text data-block named '%s'\n", python_main);
- }
- }
- else {
- while (run) {
- run = GPG_NextFrame(system, &app, exitcode, exitstring, &gs);
- }
- }
- app.StopGameEngine();
-
- /* 'app' is freed automatic when out of scope.
- * removal is needed else the system will free an already freed value */
- system->removeEventConsumer(&app);
-
- BLO_blendfiledata_free(bfd);
- /* G.main == bfd->main, it gets referenced in free_nodesystem so we can't have a dangling pointer */
- G.main = NULL;
- if (python_main) MEM_freeN(python_main);
- }
- } while (exitcode == KX_EXIT_REQUEST_RESTART_GAME || exitcode == KX_EXIT_REQUEST_START_OTHER_GAME);
- }
-
- // Seg Fault; icon.c gIcons == 0
- BKE_icons_free();
-
- // Dispose the system
- GHOST_ISystem::disposeSystem();
- }
- else {
- error = true;
- printf("error: couldn't create a system.\n");
- }
- }
-
- /* refer to WM_exit_ext() and BKE_blender_free(),
- * these are not called in the player but we need to match some of there behavior here,
- * if the order of function calls or blenders state isn't matching that of blender proper,
- * we may get troubles later on */
-
- free_nodesystem();
-
- // Cleanup
- RNA_exit();
- BLF_exit();
-
-#ifdef WITH_INTERNATIONAL
- BLF_free_unifont();
- BLF_free_unifont_mono();
- BLT_lang_free();
-#endif
-
- IMB_exit();
- BKE_images_exit();
- DEG_free_node_types();
- IMB_moviecache_destruct();
-
- SYS_DeleteSystem(syshandle);
-
- int totblock= MEM_get_memory_blocks_in_use();
- if (totblock!=0) {
- printf("Error Totblock: %d\n",totblock);
- MEM_set_error_callback(mem_error_cb);
- MEM_printmemlist();
- }
-
- BKE_tempdir_session_purge();
-
-#ifdef WIN32
- while (argv_num) {
- free(argv[--argv_num]);
- }
- free(argv);
- argv = NULL;
-#endif
-
- return error ? -1 : 0;
-}
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
deleted file mode 100644
index 7175eb877dd..00000000000
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ /dev/null
@@ -1,534 +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.
- *
- * Contributor(s): Mitchell Stokes.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file BL_Action.cpp
- * \ingroup ketsji
- */
-
-#include <cstdlib>
-#include <stdio.h>
-
-#include "BL_Action.h"
-#include "BL_ArmatureObject.h"
-#include "BL_DeformableGameObject.h"
-#include "BL_ShapeDeformer.h"
-#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"
-
-extern "C" {
-#include "BKE_animsys.h"
-#include "BKE_action.h"
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-// Needed for material IPOs
-#include "BKE_material.h"
-#include "DNA_material_types.h"
-#include "DNA_scene_types.h"
-}
-
-#include "MEM_guardedalloc.h"
-#include "BKE_library.h"
-#include "BKE_global.h"
-
-#include "BLI_threads.h" // for lock
-
-/* Lock to solve animation thread issues.
- * A spin lock is better than a mutex in case of short wait
- * because spin lock stop the thread by a loop contrary to mutex
- * which switch all memory, process.
- */
-static SpinLock BL_ActionLock;
-
-BL_Action::BL_Action(class KX_GameObject* gameobj)
-:
- m_action(NULL),
- m_tmpaction(NULL),
- m_blendpose(NULL),
- m_blendinpose(NULL),
- m_obj(gameobj),
- m_startframe(0.f),
- m_endframe(0.f),
- m_localframe(0.f),
- m_blendin(0.f),
- m_blendframe(0.f),
- m_blendstart(0.f),
- m_speed(0.f),
- m_priority(0),
- m_playmode(ACT_MODE_PLAY),
- m_blendmode(ACT_BLEND_BLEND),
- m_ipo_flags(0),
- m_done(true),
- m_calc_localtime(true),
- m_initializedTime(false)
-{
-}
-
-BL_Action::~BL_Action()
-{
- if (m_blendpose)
- BKE_pose_free(m_blendpose);
- if (m_blendinpose)
- BKE_pose_free(m_blendinpose);
- ClearControllerList();
-
- if (m_tmpaction) {
- BKE_libblock_free(G.main, m_tmpaction);
- m_tmpaction = NULL;
- }
-}
-
-void BL_Action::ClearControllerList()
-{
- // Clear out the controller list
- std::vector<SG_Controller*>::iterator it;
- for (it = m_sg_contr_list.begin(); it != m_sg_contr_list.end(); it++)
- {
- m_obj->GetSGNode()->RemoveSGController((*it));
- delete *it;
- }
-
- m_sg_contr_list.clear();
-}
-
-bool BL_Action::Play(const char* name,
- float start,
- float end,
- short priority,
- float blendin,
- short play_mode,
- float layer_weight,
- short ipo_flags,
- float playback_speed,
- short blend_mode)
-{
-
- // Only start playing a new action if we're done, or if
- // the new action has a higher priority
- if (!IsDone() && priority > m_priority)
- return false;
- m_priority = priority;
- bAction* prev_action = m_action;
-
- KX_Scene* kxscene = m_obj->GetScene();
-
- // First try to load the action
- m_action = (bAction*)kxscene->GetLogicManager()->GetActionByName(name);
- if (!m_action)
- {
- printf("Failed to load action: %s\n", name);
- m_done = true;
- return false;
- }
-
- // If we have the same settings, don't play again
- // This is to resolve potential issues with pulses on sensors such as the ones
- // reported in bug #29412. The fix is here so it works for both logic bricks and Python.
- // However, this may eventually lead to issues where a user wants to override an already
- // playing action with the same action and settings. If this becomes an issue,
- // then this fix may have to be re-evaluated.
- if (!IsDone() && m_action == prev_action && m_startframe == start && m_endframe == end
- && m_priority == priority && m_speed == playback_speed)
- return false;
-
- // Keep a copy of the action for threading purposes
- if (m_tmpaction) {
- BKE_libblock_free(G.main, m_tmpaction);
- m_tmpaction = NULL;
- }
- m_tmpaction = BKE_action_copy(G.main, m_action);
-
- // First get rid of any old controllers
- ClearControllerList();
-
- // Create an SG_Controller
- SG_Controller *sg_contr = BL_CreateIPO(m_action, m_obj, kxscene->GetSceneConverter());
- m_sg_contr_list.push_back(sg_contr);
- m_obj->GetSGNode()->AddSGController(sg_contr);
- sg_contr->SetObject(m_obj->GetSGNode());
-
- // World
- sg_contr = BL_CreateWorldIPO(m_action, kxscene->GetBlenderScene()->world, kxscene->GetSceneConverter());
- if (sg_contr) {
- m_sg_contr_list.push_back(sg_contr);
- m_obj->GetSGNode()->AddSGController(sg_contr);
- sg_contr->SetObject(m_obj->GetSGNode());
- }
-
- // Try obcolor
- sg_contr = BL_CreateObColorIPO(m_action, m_obj, kxscene->GetSceneConverter());
- if (sg_contr) {
- m_sg_contr_list.push_back(sg_contr);
- m_obj->GetSGNode()->AddSGController(sg_contr);
- sg_contr->SetObject(m_obj->GetSGNode());
- }
-
- // Now try materials
- if (m_obj->GetBlenderObject()->totcol==1) {
- Material *mat = give_current_material(m_obj->GetBlenderObject(), 1);
- if (mat) {
- sg_contr = BL_CreateMaterialIpo(m_action, mat, 0, m_obj, kxscene->GetSceneConverter());
- if (sg_contr) {
- m_sg_contr_list.push_back(sg_contr);
- m_obj->GetSGNode()->AddSGController(sg_contr);
- sg_contr->SetObject(m_obj->GetSGNode());
- }
- }
- } else {
- Material *mat;
- STR_HashedString matname;
-
- for (int matidx = 1; matidx <= m_obj->GetBlenderObject()->totcol; ++matidx) {
- mat = give_current_material(m_obj->GetBlenderObject(), matidx);
- if (mat) {
- matname = mat->id.name;
- sg_contr = BL_CreateMaterialIpo(m_action, mat, matname.hash(), m_obj, kxscene->GetSceneConverter());
- if (sg_contr) {
- m_sg_contr_list.push_back(sg_contr);
- m_obj->GetSGNode()->AddSGController(sg_contr);
- sg_contr->SetObject(m_obj->GetSGNode());
- }
- }
- }
- }
-
- // Extra controllers
- if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT)
- {
- sg_contr = BL_CreateLampIPO(m_action, m_obj, kxscene->GetSceneConverter());
- m_sg_contr_list.push_back(sg_contr);
- m_obj->GetSGNode()->AddSGController(sg_contr);
- sg_contr->SetObject(m_obj->GetSGNode());
- }
- else if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_CAMERA)
- {
- sg_contr = BL_CreateCameraIPO(m_action, m_obj, kxscene->GetSceneConverter());
- m_sg_contr_list.push_back(sg_contr);
- m_obj->GetSGNode()->AddSGController(sg_contr);
- sg_contr->SetObject(m_obj->GetSGNode());
- }
-
- m_ipo_flags = ipo_flags;
- InitIPO();
-
- // Setup blendin shapes/poses
- if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
- {
- BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
- obj->GetPose(&m_blendinpose);
- }
- else
- {
- BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
- BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
-
- if (shape_deformer && shape_deformer->GetKey())
- {
- obj->GetShape(m_blendinshape);
-
- // Now that we have the previous blend shape saved, we can clear out the key to avoid any
- // further interference.
- KeyBlock *kb;
- for (kb=(KeyBlock *)shape_deformer->GetKey()->block.first; kb; kb=(KeyBlock *)kb->next)
- kb->curval = 0.f;
- }
- }
-
- // Now that we have an action, we have something we can play
- m_starttime = -1.f; // We get the start time on our first update
- m_startframe = m_localframe = start;
- m_endframe = end;
- m_blendin = blendin;
- m_playmode = play_mode;
- m_blendmode = blend_mode;
- m_blendframe = 0.f;
- m_blendstart = 0.f;
- m_speed = playback_speed;
- m_layer_weight = layer_weight;
-
- m_done = false;
- m_initializedTime = false;
-
- return true;
-}
-
-bool BL_Action::IsDone()
-{
- return m_done;
-}
-
-void BL_Action::InitIPO()
-{
- // Initialize the IPOs
- std::vector<SG_Controller*>::iterator it;
- for (it = m_sg_contr_list.begin(); it != m_sg_contr_list.end(); it++)
- {
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true);
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, m_ipo_flags & ACT_IPOFLAG_FORCE);
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, m_ipo_flags & ACT_IPOFLAG_ADD);
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, m_ipo_flags & ACT_IPOFLAG_LOCAL);
- }
-}
-
-bAction *BL_Action::GetAction()
-{
- return (IsDone()) ? NULL : m_action;
-}
-
-float BL_Action::GetFrame()
-{
- return m_localframe;
-}
-
-const char *BL_Action::GetName()
-{
- if (m_action != NULL) {
- return m_action->id.name + 2;
- }
- else {
- return "";
- }
-
-
-}
-
-void BL_Action::SetFrame(float frame)
-{
- // Clamp the frame to the start and end frame
- if (frame < min(m_startframe, m_endframe))
- frame = min(m_startframe, m_endframe);
- else if (frame > max(m_startframe, m_endframe))
- frame = max(m_startframe, m_endframe);
-
- m_localframe = frame;
- m_calc_localtime = false;
-}
-
-void BL_Action::SetPlayMode(short play_mode)
-{
- m_playmode = play_mode;
-}
-
-void BL_Action::SetTimes(float start, float end)
-{
- m_startframe = start;
- m_endframe = end;
-}
-
-void BL_Action::SetLocalTime(float curtime)
-{
- float dt = (curtime-m_starttime)*(float)KX_KetsjiEngine::GetAnimFrameRate()*m_speed;
-
- if (m_endframe < m_startframe)
- dt = -dt;
-
- m_localframe = m_startframe + dt;
-}
-
-void BL_Action::ResetStartTime(float curtime)
-{
- float dt = (m_localframe > m_startframe) ? m_localframe - m_startframe : m_startframe - m_localframe;
-
- m_starttime = curtime - dt / ((float)KX_KetsjiEngine::GetAnimFrameRate()*m_speed);
- SetLocalTime(curtime);
-}
-
-void BL_Action::IncrementBlending(float curtime)
-{
- // Setup m_blendstart if we need to
- if (m_blendstart == 0.f)
- m_blendstart = curtime;
-
- // Bump the blend frame
- m_blendframe = (curtime - m_blendstart)*(float)KX_KetsjiEngine::GetAnimFrameRate();
-
- // Clamp
- if (m_blendframe>m_blendin)
- m_blendframe = m_blendin;
-}
-
-
-void BL_Action::BlendShape(Key* key, float srcweight, std::vector<float>& blendshape)
-{
- vector<float>::const_iterator it;
- float dstweight;
- KeyBlock *kb;
-
- dstweight = 1.0F - srcweight;
- //printf("Dst: %f\tSrc: %f\n", srcweight, dstweight);
- for (it=blendshape.begin(), kb = (KeyBlock *)key->block.first;
- kb && it != blendshape.end();
- kb = (KeyBlock *)kb->next, it++)
- {
- //printf("OirgKeys: %f\t%f\n", kb->curval, (*it));
- kb->curval = kb->curval * dstweight + (*it) * srcweight;
- //printf("NewKey: %f\n", kb->curval);
- }
- //printf("\n");
-}
-
-void BL_Action::Update(float curtime)
-{
- // Don't bother if we're done with the animation
- if (m_done)
- return;
-
- curtime -= (float)KX_KetsjiEngine::GetSuspendedDelta();
-
- // Grab the start time here so we don't end up with a negative m_localframe when
- // suspending and resuming scenes.
- if (!m_initializedTime) {
- m_starttime = curtime;
- m_initializedTime = true;
- }
-
- if (m_calc_localtime)
- SetLocalTime(curtime);
- else
- {
- ResetStartTime(curtime);
- m_calc_localtime = true;
- }
-
- // Handle wrap around
- if (m_localframe < min(m_startframe, m_endframe) || m_localframe > max(m_startframe, m_endframe)) {
- switch (m_playmode) {
- case ACT_MODE_PLAY:
- // Clamp
- m_localframe = m_endframe;
- m_done = true;
- break;
- case ACT_MODE_LOOP:
- // Put the time back to the beginning
- m_localframe = m_startframe;
- m_starttime = curtime;
- break;
- case ACT_MODE_PING_PONG:
- // Swap the start and end frames
- float temp = m_startframe;
- m_startframe = m_endframe;
- m_endframe = temp;
-
- m_starttime = curtime;
-
- break;
- }
- }
-
- if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
- {
- BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
-
- if (m_layer_weight >= 0)
- obj->GetPose(&m_blendpose);
-
- // Extract the pose from the action
- obj->SetPoseByAction(m_tmpaction, m_localframe);
-
- // Handle blending between armature actions
- if (m_blendin && m_blendframe<m_blendin)
- {
- IncrementBlending(curtime);
-
- // Calculate weight
- float weight = 1.f - (m_blendframe/m_blendin);
-
- // Blend the poses
- obj->BlendInPose(m_blendinpose, weight, ACT_BLEND_BLEND);
- }
-
-
- // Handle layer blending
- if (m_layer_weight >= 0)
- obj->BlendInPose(m_blendpose, m_layer_weight, m_blendmode);
-
- obj->UpdateTimestep(curtime);
- }
- else
- {
- BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
- BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
-
- // Handle shape actions if we have any
- if (shape_deformer && shape_deformer->GetKey())
- {
- Key *key = shape_deformer->GetKey();
-
- PointerRNA ptrrna;
- RNA_id_pointer_create(&key->id, &ptrrna);
-
- animsys_evaluate_action(&ptrrna, m_tmpaction, NULL, m_localframe);
-
- // Handle blending between shape actions
- if (m_blendin && m_blendframe < m_blendin)
- {
- IncrementBlending(curtime);
-
- float weight = 1.f - (m_blendframe/m_blendin);
-
- // We go through and clear out the keyblocks so there isn't any interference
- // from other shape actions
- KeyBlock *kb;
- for (kb=(KeyBlock *)key->block.first; kb; kb=(KeyBlock *)kb->next)
- kb->curval = 0.f;
-
- // Now blend the shape
- BlendShape(key, weight, m_blendinshape);
- }
-
- // Handle layer blending
- if (m_layer_weight >= 0)
- {
- obj->GetShape(m_blendshape);
- BlendShape(key, m_layer_weight, m_blendshape);
- }
-
- obj->SetActiveAction(NULL, 0, curtime);
- }
- }
-
- BLI_spin_lock(&BL_ActionLock);
- /* This function is not thread safe because of recursive scene graph transform
- * updates on children. e.g: If an object and one of its children is animated,
- * the both can write transform at the same time. A thread lock avoid problems. */
- m_obj->UpdateIPO(m_localframe, m_ipo_flags & ACT_IPOFLAG_CHILD);
- BLI_spin_unlock(&BL_ActionLock);
-
- if (m_done)
- ClearControllerList();
-}
-
-void BL_Action::InitLock()
-{
- BLI_spin_init(&BL_ActionLock);
-}
-
-void BL_Action::EndLock()
-{
- BLI_spin_end(&BL_ActionLock);
-}
diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h
deleted file mode 100644
index f4c2975a547..00000000000
--- a/source/gameengine/Ketsji/BL_Action.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.
- *
- * Contributor(s): Mitchell Stokes.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file BL_Action.h
- * \ingroup ketsji
- */
-
-#ifndef __BL_ACTION_H__
-#define __BL_ACTION_H__
-
-
-#include <vector>
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class BL_Action
-{
-private:
- struct bAction* m_action;
- struct bAction* m_tmpaction;
- struct bPose* m_blendpose;
- struct bPose* m_blendinpose;
- std::vector<class SG_Controller*> m_sg_contr_list;
- class KX_GameObject* m_obj;
- std::vector<float> m_blendshape;
- std::vector<float> m_blendinshape;
-
- float m_startframe;
- float m_endframe;
- /// The current action frame.
- float m_localframe;
- float m_starttime;
-
- float m_blendin;
- float m_blendframe;
- float m_blendstart;
-
- float m_layer_weight;
-
- float m_speed;
-
- short m_priority;
-
- short m_playmode;
- short m_blendmode;
-
- short m_ipo_flags;
-
- bool m_done;
- bool m_calc_localtime;
- /// Set to true when m_starttime is initialized in Update.
- bool m_initializedTime;
-
- void ClearControllerList();
- void InitIPO();
- void SetLocalTime(float curtime);
- void ResetStartTime(float curtime);
- void IncrementBlending(float curtime);
- void BlendShape(struct Key* key, float srcweight, std::vector<float>& blendshape);
-public:
- BL_Action(class KX_GameObject* gameobj);
- ~BL_Action();
-
- /**
- * Play an action
- */
- bool Play(const char* name,
- float start,
- float end,
- short priority,
- float blendin,
- short play_mode,
- float layer_weight,
- short ipo_flags,
- float playback_speed,
- short blend_mode);
- /**
- * Whether or not the action is still playing
- */
- bool IsDone();
- /**
- * Update the action's frame, etc.
- */
- void Update(float curtime);
-
- // Accessors
- float GetFrame();
- const char *GetName();
-
- struct bAction *GetAction();
-
- // Mutators
- void SetFrame(float frame);
- void SetPlayMode(short play_mode);
- void SetTimes(float start, float end);
-
- enum
- {
- ACT_MODE_PLAY = 0,
- ACT_MODE_LOOP,
- ACT_MODE_PING_PONG,
- ACT_MODE_MAX,
- };
-
- enum
- {
- ACT_BLEND_BLEND=0,
- ACT_BLEND_ADD=1,
- ACT_BLEND_MAX,
- };
-
- enum
- {
- ACT_IPOFLAG_FORCE = 1,
- ACT_IPOFLAG_LOCAL = 2,
- ACT_IPOFLAG_ADD = 4,
- ACT_IPOFLAG_CHILD = 8,
- };
-
- /// Initialize a lock for animation thread issues.
- static void InitLock();
- /// Finalize a lock for animation thread issues.
- static void EndLock();
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Action")
-#endif
-};
-
-#endif /* BL_ACTION */
diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp
deleted file mode 100644
index 35f605f1a5f..00000000000
--- a/source/gameengine/Ketsji/BL_ActionManager.cpp
+++ /dev/null
@@ -1,164 +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.
- *
- * Contributor(s): Mitchell Stokes.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file BL_ActionManager.cpp
- * \ingroup ketsji
- */
-
-#include "BL_Action.h"
-#include "BL_ActionManager.h"
-#include "DNA_ID.h"
-
-#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT))
-
-BL_ActionManager::BL_ActionManager(class KX_GameObject *obj):
- m_obj(obj),
- m_prevUpdate(-1.0f)
-{
-}
-
-BL_ActionManager::~BL_ActionManager()
-{
- BL_ActionMap::iterator it;
-
- for (it = m_layers.begin(); it != m_layers.end(); it++)
- delete it->second;
-
- m_layers.clear();
-}
-
-BL_Action *BL_ActionManager::GetAction(short layer)
-{
- BL_ActionMap::iterator it = m_layers.find(layer);
-
- return (it != m_layers.end()) ? it->second : 0;
-}
-
-float BL_ActionManager::GetActionFrame(short layer)
-{
- BL_Action *action = GetAction(layer);
-
- return action ? action->GetFrame() : 0.f;
-}
-
-const char *BL_ActionManager::GetActionName(short layer)
-{
- BL_Action *action = GetAction(layer);
- return action ? action->GetName() : "";
-}
-
-void BL_ActionManager::SetActionFrame(short layer, float frame)
-{
- BL_Action *action = GetAction(layer);
-
- if (action) action->SetFrame(frame);
-}
-
-struct bAction *BL_ActionManager::GetCurrentAction(short layer)
-{
- BL_Action *action = GetAction(layer);
-
- return action ? action->GetAction() : 0;
-}
-
-void BL_ActionManager::SetPlayMode(short layer, short mode)
-{
- BL_Action *action = GetAction(layer);
-
- if (action) action->SetPlayMode(mode);
-}
-
-void BL_ActionManager::SetTimes(short layer, float start, float end)
-{
- BL_Action *action = GetAction(layer);
-
- if (action) action->SetTimes(start, end);
-}
-
-bool BL_ActionManager::PlayAction(const char* name,
- float start,
- float end,
- short layer,
- short priority,
- float blendin,
- short play_mode,
- float layer_weight,
- short ipo_flags,
- float playback_speed,
- short blend_mode)
-{
- // Only this method will create layer if non-existent
- BL_Action *action = GetAction(layer);
- if (!action) {
- action = new BL_Action(m_obj);
- m_layers[layer] = action;
- }
-
- // Disable layer blending on the first layer
- if (layer == 0) layer_weight = -1.f;
-
- return action->Play(name, start, end, priority, blendin, play_mode, layer_weight, ipo_flags, playback_speed, blend_mode);
-}
-
-void BL_ActionManager::StopAction(short layer)
-{
- BL_Action *action = GetAction(layer);
-
- if (action) {
- m_layers.erase(layer);
- delete action;
- }
-}
-
-void BL_ActionManager::RemoveTaggedActions()
-{
- for (BL_ActionMap::iterator it = m_layers.begin(); it != m_layers.end();) {
- if (IS_TAGGED(it->second->GetAction())) {
- delete it->second;
- m_layers.erase(it++);
- }
- else
- ++it;
- }
-}
-
-bool BL_ActionManager::IsActionDone(short layer)
-{
- BL_Action *action = GetAction(layer);
-
- return action ? action->IsDone() : true;
-}
-
-void BL_ActionManager::Update(float curtime)
-{
- if (m_prevUpdate == curtime)
- return;
- m_prevUpdate = curtime;
-
- BL_ActionMap::iterator it;
- for (it = m_layers.begin(); it != m_layers.end(); ++it)
- {
- if (!it->second->IsDone()) {
- it->second->Update(curtime);
- }
- }
-}
diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h
deleted file mode 100644
index 69c6d611df0..00000000000
--- a/source/gameengine/Ketsji/BL_ActionManager.h
+++ /dev/null
@@ -1,132 +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.
- *
- * Contributor(s): Mitchell Stokes.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file BL_ActionManager.h
- * \ingroup ketsji
- */
-
-#ifndef __BL_ACTIONMANAGER_H__
-#define __BL_ACTIONMANAGER_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
- #include "MEM_guardedalloc.h"
-#endif
-
-#include <map>
-
-// Currently, we use the max value of a short.
-// We should switch to unsigned short; doesn't make sense to support negative layers.
-// This will also give us 64k layers instead of 32k.
-#define MAX_ACTION_LAYERS 32767
-
-class BL_Action;
-
-/**
- * BL_ActionManager is responsible for handling a KX_GameObject's actions.
- */
-class BL_ActionManager
-{
-private:
- typedef std::map<short,BL_Action*> BL_ActionMap;
-
- class KX_GameObject* m_obj;
- BL_ActionMap m_layers;
-
- // The last update time to avoid double animation update.
- float m_prevUpdate;
-
- /**
- * Check if an action exists
- */
- BL_Action* GetAction(short layer);
-
-public:
- BL_ActionManager(class KX_GameObject* obj);
- ~BL_ActionManager();
-
- bool PlayAction(const char* name,
- float start,
- float end,
- short layer=0,
- short priority=0,
- float blendin=0.f,
- short play_mode=0,
- float layer_weight=0.f,
- short ipo_flags=0,
- float playback_speed=1.f,
- short blend_mode=0);
- /**
- * Gets the current frame of an action
- */
- float GetActionFrame(short layer);
-
- /**
- * Gets the name of the current action
- */
- const char *GetActionName(short layer);
-
- /**
- * Sets the current frame of an action
- */
- void SetActionFrame(short layer, float frame);
-
- /**
- * Gets the currently running action on the given layer
- */
- struct bAction *GetCurrentAction(short layer);
-
- /**
- * Sets play mode of the action on the given layer
- */
- void SetPlayMode(short layer, short mode);
-
- /**
- * Sets the start and end times of the action on the given layer
- */
- void SetTimes(short layer, float start, float end);
-
- /**
- * Stop playing the action on the given layer
- */
- void StopAction(short layer);
-
- /**
- * Remove playing tagged actions.
- */
- void RemoveTaggedActions();
-
- /**
- * Check if an action has finished playing
- */
- bool IsActionDone(short layer);
-
- /**
- * Update any running actions
- */
- void Update(float);
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ActionManager")
-#endif
-};
-
-#endif /* BL_ACTIONMANAGER */
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp
deleted file mode 100644
index 572218e691d..00000000000
--- a/source/gameengine/Ketsji/BL_BlenderShader.cpp
+++ /dev/null
@@ -1,188 +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/BL_BlenderShader.cpp
- * \ingroup ketsji
- */
-
-#include "DNA_customdata_types.h"
-#include "DNA_material_types.h"
-#include "DNA_scene_types.h"
-
-#include "BLI_utildefines.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_DerivedMesh.h"
-
-#include "BL_BlenderShader.h"
-#include "BL_Material.h"
-
-#include "GPU_material.h"
-#include "GPU_shader.h"
-
-#include "RAS_BucketManager.h"
-#include "RAS_MeshObject.h"
-#include "RAS_IRasterizer.h"
-
-BL_BlenderShader::BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer)
-:
- mMat(ma),
- mLightLayer(lightlayer),
- mGPUMat(NULL)
-{
- mBlenderScene = scene->GetBlenderScene();
- mAlphaBlend = GPU_BLEND_SOLID;
-
- ReloadMaterial();
-}
-
-BL_BlenderShader::~BL_BlenderShader()
-{
- if (mGPUMat)
- GPU_material_unbind(mGPUMat);
-}
-
-void BL_BlenderShader::ReloadMaterial()
-{
- mGPUMat = (mMat) ? GPU_material_from_blender(mBlenderScene, mMat, false) : NULL;
-}
-
-void BL_BlenderShader::SetProg(bool enable, double time, RAS_IRasterizer* rasty)
-{
- if (VerifyShader()) {
- if (enable) {
- assert(rasty != NULL); // XXX Kinda hacky, but SetProg() should always have the rasterizer if enable is true
-
- float viewmat[4][4], viewinvmat[4][4];
- const MT_Matrix4x4& view = rasty->GetViewMatrix();
- const MT_Matrix4x4& viewinv = rasty->GetViewInvMatrix();
- view.getValue(&viewmat[0][0]);
- viewinv.getValue(&viewinvmat[0][0]);
-
- GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time, 1, viewmat, viewinvmat, NULL);
- }
- else
- GPU_material_unbind(mGPUMat);
- }
-}
-
-int BL_BlenderShader::GetAttribNum()
-{
- GPUVertexAttribs attribs;
- int i, enabled = 0;
-
- if (!VerifyShader())
- return enabled;
-
- GPU_material_vertex_attributes(mGPUMat, &attribs);
-
- for (i = 0; i < attribs.totlayer; i++)
- if (attribs.layer[i].glindex+1 > enabled)
- enabled= attribs.layer[i].glindex+1;
-
- if (enabled > BL_MAX_ATTRIB)
- enabled = BL_MAX_ATTRIB;
-
- return enabled;
-}
-
-void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat)
-{
- GPUVertexAttribs attribs;
- GPUMaterial *gpumat;
- int i, attrib_num, uv = 0;
-
- ras->SetAttribNum(0);
-
- if (!VerifyShader())
- return;
-
- gpumat = mGPUMat;
- if (ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED || (ras->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW &&
- mat->alphablend != GEMAT_SOLID && !ras->GetUsingOverrideShader())) {
- GPU_material_vertex_attributes(gpumat, &attribs);
- attrib_num = GetAttribNum();
-
- ras->SetTexCoordNum(0);
- ras->SetAttribNum(attrib_num);
- for (i = 0; i < attrib_num; i++)
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, i);
-
- for (i = 0; i < attribs.totlayer; i++) {
- if (attribs.layer[i].glindex > attrib_num)
- continue;
-
- if (attribs.layer[i].type == CD_MTFACE)
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV, attribs.layer[i].glindex, uv++);
- else if (attribs.layer[i].type == CD_TANGENT)
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, attribs.layer[i].glindex);
- else if (attribs.layer[i].type == CD_ORCO)
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_ORCO, attribs.layer[i].glindex);
- else if (attribs.layer[i].type == CD_NORMAL)
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_NORM, attribs.layer[i].glindex);
- else if (attribs.layer[i].type == CD_MCOL)
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_VCOL, attribs.layer[i].glindex);
- else
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, attribs.layer[i].glindex);
- }
- }
-}
-
-void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty )
-{
- float obmat[4][4], viewmat[4][4], obcol[4];
- GPUMaterial *gpumat;
-
- gpumat = mGPUMat;
-
- if (!gpumat || !GPU_material_bound(gpumat))
- return;
-
- MT_Matrix4x4 model;
- model.setValue(ms.m_OpenGLMatrix);
-
- // note: getValue gives back column major as needed by OpenGL
- model.getValue(&obmat[0][0]);
-
- if (ms.m_bObjectColor)
- ms.m_RGBAcolor.getValue(&obcol[0]);
- else
- obcol[0] = obcol[1] = obcol[2] = obcol[3] = 1.0f;
-
- rasty->GetViewMatrix().getValue(&viewmat[0][0]);
- float auto_bump_scale = ms.m_pDerivedMesh!=0 ? ms.m_pDerivedMesh->auto_bump_scale : 1.0f;
- GPU_material_bind_uniforms(gpumat, obmat, viewmat, obcol, auto_bump_scale, NULL, NULL);
-
- mAlphaBlend = GPU_material_alpha_blend(gpumat, obcol);
-}
-
-int BL_BlenderShader::GetAlphaBlend()
-{
- return mAlphaBlend;
-}
-
-bool BL_BlenderShader::Equals(BL_BlenderShader *blshader)
-{
- /* to avoid unneeded state switches */
- return (blshader && mMat == blshader->mMat && mLightLayer == blshader->mLightLayer);
-}
-
-// eof
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h
deleted file mode 100644
index e03bb5a11d9..00000000000
--- a/source/gameengine/Ketsji/BL_BlenderShader.h
+++ /dev/null
@@ -1,96 +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) Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file BL_BlenderShader.h
- * \ingroup ketsji
- */
-
-#ifndef __BL_BLENDERSHADER_H__
-#define __BL_BLENDERSHADER_H__
-
-#include "GPU_material.h"
-
-#include "MT_Matrix4x4.h"
-#include "MT_Matrix3x3.h"
-#include "MT_Tuple2.h"
-#include "MT_Tuple3.h"
-#include "MT_Tuple4.h"
-
-#include "RAS_IPolygonMaterial.h"
-
-#include "KX_Scene.h"
-
-struct Material;
-struct Scene;
-class BL_Material;
-
-#define BL_MAX_ATTRIB 16
-
-/**
- * BL_BlenderShader
- * Blender GPU shader material
- */
-class BL_BlenderShader
-{
-private:
- struct Scene *mBlenderScene;
- struct Material *mMat;
- int mLightLayer;
- int mAlphaBlend;
- GPUMaterial *mGPUMat;
-
- bool VerifyShader()
- {
- return (NULL != mGPUMat);
- }
-
-public:
- BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer);
- virtual ~BL_BlenderShader();
-
- bool Ok()
- {
- // same as VerifyShared
- return (NULL != mGPUMat);
- }
- void SetProg(bool enable, double time=0.0, RAS_IRasterizer* rasty=NULL);
-
- int GetAttribNum();
- void SetAttribs(class RAS_IRasterizer* ras, const BL_Material *mat);
- void Update(const class RAS_MeshSlot & ms, class RAS_IRasterizer* rasty);
- void ReloadMaterial();
- int GetAlphaBlend();
-
- bool Equals(BL_BlenderShader *blshader);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_BlenderShader")
-#endif
-};
-
-#endif /* __BL_BLENDERSHADER_H__ */
diff --git a/source/gameengine/Ketsji/BL_Material.cpp b/source/gameengine/Ketsji/BL_Material.cpp
deleted file mode 100644
index 40384b43054..00000000000
--- a/source/gameengine/Ketsji/BL_Material.cpp
+++ /dev/null
@@ -1,123 +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/BL_Material.cpp
- * \ingroup ketsji
- */
-
-#include "BL_Material.h"
-#include "DNA_material_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_image_types.h"
-#include "DNA_mesh_types.h"
-#include "IMB_imbuf_types.h"
-#include "IMB_imbuf.h"
-
-MTex* getMTexFromMaterial(Material *mat, int index)
-{
- if (mat && (index >= 0) && (index < MAX_MTEX)) {
- return mat->mtex[index];
- }
- else {
- return NULL;
- }
-}
-
-BL_Material::BL_Material()
-{
- Initialize();
-}
-
-void BL_Material::Initialize()
-{
- rgb[0] = 0xFFFFFFFFL;
- rgb[1] = 0xFFFFFFFFL;
- rgb[2] = 0xFFFFFFFFL;
- rgb[3] = 0xFFFFFFFFL;
- IdMode = 0;
- ras_mode = 0;
- glslmat = 0;
- tile = 0;
- matname = "NoMaterial";
- matcolor[0] = 0.5f;
- matcolor[1] = 0.5f;
- matcolor[2] = 0.5f;
- matcolor[3] = 0.5f;
- speccolor[0] = 1.f;
- speccolor[1] = 1.f;
- speccolor[2] = 1.f;
- alphablend = 0;
- hard = 50.f;
- spec_f = 0.5f;
- alpha = 1.f;
- emit = 0.f;
- material = 0;
- materialindex = 0;
- amb=0.5f;
- num_enabled = 0;
- num_users = 1;
- share = false;
-
- int i;
-
- for (i = 0; i < MAXTEX; i++) // :(
- {
- mapping[i].mapping = 0;
- mapping[i].offsets[0] = 0.f;
- mapping[i].offsets[1] = 0.f;
- mapping[i].offsets[2] = 0.f;
- mapping[i].scale[0] = 1.f;
- mapping[i].scale[1] = 1.f;
- mapping[i].scale[2] = 1.f;
- mapping[i].projplane[0] = PROJX;
- mapping[i].projplane[1] = PROJY;
- mapping[i].projplane[2] = PROJZ;
- mapping[i].objconame = "";
- mtexname[i] = "NULL";
- imageId[i]="NULL";
- flag[i] = 0;
- texname[i] = "NULL";
- tilexrep[i] = 1;
- tileyrep[i] = 1;
- color_blend[i] = 1.f;
- blend_mode[i] = 0;
- img[i] = 0;
- cubemap[i] = 0;
- }
-}
-
-void BL_Material::SetSharedMaterial(bool v)
-{
- if ((v && num_users == -1) || num_users > 1 )
- share = true;
- else
- share = false;
-}
-
-bool BL_Material::IsShared()
-{
- return share;
-}
-
-void BL_Material::SetUsers(int num)
-{
- num_users = num;
-}
-
diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h
deleted file mode 100644
index 710c02f4871..00000000000
--- a/source/gameengine/Ketsji/BL_Material.h
+++ /dev/null
@@ -1,182 +0,0 @@
-
-/** \file BL_Material.h
- * \ingroup ketsji
- */
-
-#ifndef __BL_MATERIAL_H__
-#define __BL_MATERIAL_H__
-
-#include "STR_String.h"
-#include "MT_Point2.h"
-#include "DNA_meshdata_types.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-// --
-struct MTex;
-struct Material;
-struct Image;
-struct MTFace;
-struct MTex;
-struct Material;
-struct EnvMap;
-// --
-
-/** max units
- * this will default to users available units
- * to build with more available, just increment this value
- * although the more you add the slower the search time will be.
- * we will go for eight, which should be enough
- */
-#define MAXTEX 8 //match in RAS_TexVert & RAS_OpenGLRasterizer
-
-// different mapping modes
-class BL_Mapping
-{
-public:
- int mapping;
- float scale[3];
- float offsets[3];
- int projplane[3];
- STR_String objconame;
- STR_String uvCoName;
-};
-
-// base material struct
-class BL_Material
-{
-private:
- int num_users;
- bool share;
-
-public:
- // -----------------------------------
- BL_Material();
- void Initialize();
-
- int IdMode;
- unsigned int ras_mode;
- bool glslmat;
-
- STR_String texname[MAXTEX];
- unsigned int flag[MAXTEX];
- int tile,tilexrep[MAXTEX],tileyrep[MAXTEX];
- STR_String matname;
- STR_String mtexname[MAXTEX];
- int materialindex;
-
- float matcolor[4];
- float speccolor[3];
- short alphablend, pad;
-
- float hard, spec_f;
- float alpha, emit, color_blend[MAXTEX], ref;
- float amb;
-
- int blend_mode[MAXTEX];
-
- int num_enabled;
-
- BL_Mapping mapping[MAXTEX];
- STR_String imageId[MAXTEX];
-
-
- Material* material;
- Image* img[MAXTEX];
- EnvMap* cubemap[MAXTEX];
-
- unsigned int rgb[4];
-
- void SetSharedMaterial(bool v);
- bool IsShared();
- void SetUsers(int num);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Material")
-#endif
-};
-
-// BL_Material::IdMode
-enum BL_IdMode {
- DEFAULT_BLENDER=-1,
- TEXFACE,
- ONETEX,
- TWOTEX,
- GREATERTHAN2
-};
-
-// BL_Material::blend_mode[index]
-enum BL_BlendMode
-{
- BLEND_MIX=1,
- BLEND_ADD,
- BLEND_SUB,
- BLEND_MUL,
- BLEND_SCR
-};
-
-// -------------------------------------
-// BL_Material::flag[index]
-enum BL_flag
-{
- MIPMAP=1, // set to use mipmaps
- CALCALPHA=2, // additive
- USEALPHA=4, // use actual alpha channel
- TEXALPHA=8, // use alpha combiner functions
- TEXNEG=16, // negate blending
- /*HASIPO=32,*/ // unused, commeted for now.
- USENEGALPHA=64
-};
-
-// BL_Material::ras_mode
-enum BL_ras_mode
-{
- // POLY_VIS=1,
- COLLIDER=2,
- ZSORT=4,
- ALPHA=8,
- // TRIANGLE=16,
- USE_LIGHT=32,
- WIRE=64,
- CAST_SHADOW=128,
- TEX=256,
- TWOSIDED=512,
- ONLY_SHADOW=1024,
-};
-
-// -------------------------------------
-// BL_Material::mapping[index]::mapping
-enum BL_MappingFlag
-{
- USEENV =1,
- // --
- USEREFL =2,
- USEOBJ =4,
- USENORM =8,
- USEORCO =16,
- USEUV =32,
- USETANG =64,
- DISABLE =128,
- USECUSTOMUV=256
-};
-
-// BL_Material::BL_Mapping::projplane
-enum BL_MappingProj
-{
- PROJN=0,
- PROJX,
- PROJY,
- PROJZ
-};
-
-// ------------------------------------
-//extern void initBL_Material(BL_Material* mat);
-extern MTex* getMTexFromMaterial(Material *mat, int index);
-// ------------------------------------
-
-#endif
-
-
diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp
deleted file mode 100644
index d344e18c313..00000000000
--- a/source/gameengine/Ketsji/BL_Shader.cpp
+++ /dev/null
@@ -1,1478 +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/BL_Shader.cpp
- * \ingroup ketsji
- */
-
-#include "GPU_glew.h"
-
-#include <iostream>
-#include "BL_Shader.h"
-#include "BL_Material.h"
-
-#include "MT_assert.h"
-#include "MT_Matrix4x4.h"
-#include "MT_Matrix3x3.h"
-#include "KX_PyMath.h"
-#include "KX_PythonInit.h"
-#include "MEM_guardedalloc.h"
-
-#include "RAS_MeshObject.h"
-#include "RAS_IRasterizer.h"
-
-#define spit(x) std::cout << x << std::endl;
-
-#define SORT_UNIFORMS 1
-#define UNIFORM_MAX_LEN (int)sizeof(float) * 16
-#define MAX_LOG_LEN 262144 // bounds
-
-BL_Uniform::BL_Uniform(int data_size)
- :
- mLoc(-1),
- mDirty(true),
- mType(UNI_NONE),
- mTranspose(0),
- mDataLen(data_size)
-{
-#ifdef SORT_UNIFORMS
- MT_assert((int)mDataLen <= UNIFORM_MAX_LEN);
- mData = (void *)MEM_mallocN(mDataLen, "shader-uniform-alloc");
-#endif
-}
-
-BL_Uniform::~BL_Uniform()
-{
-#ifdef SORT_UNIFORMS
- if (mData) {
- MEM_freeN(mData);
- mData = NULL;
- }
-#endif
-}
-
-bool BL_Uniform::Apply(class BL_Shader *shader)
-{
-#ifdef SORT_UNIFORMS
- RAS_IRasterizer *ras;
- MT_assert(mType > UNI_NONE && mType < UNI_MAX && mData);
-
- if (!mDirty)
- return false;
-
- mDirty = false;
- switch (mType) {
- case UNI_FLOAT:
- {
- float *f = (float *)mData;
- glUniform1fARB(mLoc, (GLfloat)*f);
- break;
- }
- case UNI_FLOAT_EYE:
- {
- float *f = (float*)mData;
- ras = KX_GetActiveEngine()->GetRasterizer();
- *f = (ras->GetEye() == RAS_IRasterizer::RAS_STEREO_LEFTEYE) ? 0.0f : 0.5f;
- glUniform1fARB(mLoc, (GLfloat)*f);
- mDirty = (ras->Stereo()) ? true : false;
- break;
- }
- case UNI_INT:
- {
- int *f = (int *)mData;
- glUniform1iARB(mLoc, (GLint)*f);
- break;
- }
- case UNI_FLOAT2:
- {
- float *f = (float *)mData;
- glUniform2fvARB(mLoc, 1, (GLfloat *)f);
- break;
- }
- case UNI_FLOAT3:
- {
- float *f = (float *)mData;
- glUniform3fvARB(mLoc, 1, (GLfloat *)f);
- break;
- }
- case UNI_FLOAT4:
- {
- float *f = (float *)mData;
- glUniform4fvARB(mLoc, 1, (GLfloat *)f);
- break;
- }
- case UNI_INT2:
- {
- int *f = (int *)mData;
- glUniform2ivARB(mLoc, 1, (GLint *)f);
- break;
- }
- case UNI_INT3:
- {
- int *f = (int *)mData;
- glUniform3ivARB(mLoc, 1, (GLint *)f);
- break;
- }
- case UNI_INT4:
- {
- int *f = (int *)mData;
- glUniform4ivARB(mLoc, 1, (GLint *)f);
- break;
- }
- case UNI_MAT4:
- {
- float *f = (float *)mData;
- glUniformMatrix4fvARB(mLoc, 1, mTranspose ? GL_TRUE : GL_FALSE, (GLfloat *)f);
- break;
- }
- case UNI_MAT3:
- {
- float *f = (float *)mData;
- glUniformMatrix3fvARB(mLoc, 1, mTranspose ? GL_TRUE : GL_FALSE, (GLfloat *)f);
- break;
- }
- }
- return mDirty;
-#endif
-}
-
-void BL_Uniform::SetData(int location, int type, bool transpose)
-{
-#ifdef SORT_UNIFORMS
- mType = type;
- mLoc = location;
- mDirty = true;
-#endif
-}
-
-bool BL_Shader::Ok()const
-{
- return (mShader != 0 && mOk && mUse);
-}
-
-BL_Shader::BL_Shader()
- :
- PyObjectPlus(),
- mShader(0),
- mPass(1),
- mOk(0),
- mUse(0),
- mAttr(0),
- vertProg(NULL),
- fragProg(NULL),
- mError(0),
- mDirty(true)
-{
- // if !GLEW_ARB_shader_objects this class will not be used
- //for (int i=0; i<MAXTEX; i++) {
- // mSampler[i] = BL_Sampler();
- //}
-}
-
-BL_Shader::~BL_Shader()
-{
- //for (int i=0; i<MAXTEX; i++) {
- // if (mSampler[i].mOwn) {
- // if (mSampler[i].mTexture)
- // mSampler[i].mTexture->DeleteTex();
- // }
- //}
- ClearUniforms();
-
- if (mShader) {
- glDeleteObjectARB(mShader);
- mShader = 0;
- }
-
- vertProg = NULL;
- fragProg = NULL;
- mOk = 0;
- glUseProgramObjectARB(0);
-}
-
-void BL_Shader::ClearUniforms()
-{
- BL_UniformVec::iterator it = mUniforms.begin();
- while (it != mUniforms.end()) {
- delete *it;
- it++;
- }
- mUniforms.clear();
-
- BL_UniformVecDef::iterator itp = mPreDef.begin();
- while (itp != mPreDef.end()) {
- delete *itp;
- itp++;
- }
- mPreDef.clear();
-}
-
-BL_Uniform *BL_Shader::FindUniform(const int location)
-{
-#ifdef SORT_UNIFORMS
- BL_UniformVec::iterator it = mUniforms.begin();
- while (it != mUniforms.end()) {
- if ((*it)->GetLocation() == location) {
- return *it;
- }
- it++;
- }
-#endif
- return NULL;
-}
-
-void BL_Shader::SetUniformfv(int location, int type, float *param, int size, bool transpose)
-{
-#ifdef SORT_UNIFORMS
- BL_Uniform *uni = FindUniform(location);
-
- if (uni) {
- memcpy(uni->getData(), param, size);
- uni->SetData(location, type, transpose);
- }
- else {
- uni = new BL_Uniform(size);
- memcpy(uni->getData(), param, size);
- uni->SetData(location, type, transpose);
- mUniforms.push_back(uni);
- }
-
- mDirty = true;
-#endif
-}
-
-void BL_Shader::SetUniformiv(int location, int type, int *param, int size, bool transpose)
-{
-#ifdef SORT_UNIFORMS
- BL_Uniform *uni = FindUniform(location);
-
- if (uni) {
- memcpy(uni->getData(), param, size);
- uni->SetData(location, type, transpose);
- }
- else {
- uni = new BL_Uniform(size);
- memcpy(uni->getData(), param, size);
- uni->SetData(location, type, transpose);
- mUniforms.push_back(uni);
- }
-
- mDirty = true;
-#endif
-}
-
-void BL_Shader::ApplyShader()
-{
-#ifdef SORT_UNIFORMS
- if (!mDirty) {
- return;
- }
-
- mDirty = false;
- for (unsigned int i=0; i<mUniforms.size(); i++) {
- mDirty |= mUniforms[i]->Apply(this);
- }
-#endif
-}
-
-void BL_Shader::UnloadShader()
-{
- //
-}
-
-bool BL_Shader::LinkProgram()
-{
- int vertlen = 0, fraglen = 0, proglen = 0;
- int vertstatus = 0, fragstatus = 0, progstatus = 0;
- unsigned int tmpVert = 0, tmpFrag = 0, tmpProg = 0;
- int char_len = 0;
- char *logInf = NULL;
-
- if (mError) {
- goto programError;
- }
-
- if (!vertProg || !fragProg) {
- spit("Invalid GLSL sources");
- return false;
- }
-
- if (!GLEW_ARB_fragment_shader) {
- spit("Fragment shaders not supported");
- return false;
- }
-
- if (!GLEW_ARB_vertex_shader) {
- spit("Vertex shaders not supported");
- return false;
- }
-
- if (vertProg[0] != 0) {
- // -- vertex shader ------------------
- tmpVert = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
- glShaderSourceARB(tmpVert, 1, (const char**)&vertProg, 0);
- glCompileShaderARB(tmpVert);
- glGetObjectParameterivARB(tmpVert, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*)&vertlen);
-
- // print info if any
- if (vertlen > 0 && vertlen < MAX_LOG_LEN) {
- logInf = (char*)MEM_mallocN(vertlen, "vert-log");
- glGetInfoLogARB(tmpVert, vertlen, (GLsizei*)&char_len, logInf);
- if (char_len > 0) {
- spit("---- Vertex Shader Error ----");
- spit(logInf);
- }
- MEM_freeN(logInf);
- logInf = 0;
- }
- // check for compile errors
- glGetObjectParameterivARB(tmpVert, GL_OBJECT_COMPILE_STATUS_ARB, (GLint*)&vertstatus);
- if (!vertstatus) {
- spit("---- Vertex shader failed to compile ----");
- goto programError;
- }
- }
-
- if (fragProg[0] != 0) {
- // -- fragment shader ----------------
- tmpFrag = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
- glShaderSourceARB(tmpFrag, 1, (const char**)&fragProg, 0);
- glCompileShaderARB(tmpFrag);
- glGetObjectParameterivARB(tmpFrag, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*)&fraglen);
- if (fraglen > 0 && fraglen < MAX_LOG_LEN) {
- logInf = (char*)MEM_mallocN(fraglen, "frag-log");
- glGetInfoLogARB(tmpFrag, fraglen, (GLsizei*)&char_len, logInf);
- if (char_len > 0) {
- spit("---- Fragment Shader Error ----");
- spit(logInf);
- }
- MEM_freeN(logInf);
- logInf = 0;
- }
-
- glGetObjectParameterivARB(tmpFrag, GL_OBJECT_COMPILE_STATUS_ARB, (GLint*)&fragstatus);
- if (!fragstatus) {
- spit("---- Fragment shader failed to compile ----");
- goto programError;
- }
- }
-
- if (!tmpFrag && !tmpVert) {
- spit("---- No shader given ----");
- goto programError;
- }
-
- // -- program ------------------------
- // set compiled vert/frag shader & link
- tmpProg = glCreateProgramObjectARB();
- if (tmpVert) {
- glAttachObjectARB(tmpProg, tmpVert);
- }
- if (tmpFrag) {
- glAttachObjectARB(tmpProg, tmpFrag);
- }
- glLinkProgramARB(tmpProg);
- glGetObjectParameterivARB(tmpProg, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint *)&proglen);
- glGetObjectParameterivARB(tmpProg, GL_OBJECT_LINK_STATUS_ARB, (GLint *)&progstatus);
-
- if (proglen > 0 && proglen < MAX_LOG_LEN) {
- logInf = (char *)MEM_mallocN(proglen, "prog-log");
- glGetInfoLogARB(tmpProg, proglen, (GLsizei *)&char_len, logInf);
-
- if (char_len > 0) {
- spit("---- GLSL Program ----");
- spit(logInf);
- }
-
- MEM_freeN(logInf);
- logInf = 0;
- }
-
- if (!progstatus) {
- spit("---- GLSL program failed to link ----");
- goto programError;
- }
-
- // set
- mShader = tmpProg;
- if (tmpVert) {
- glDeleteObjectARB(tmpVert);
- }
- if (tmpFrag) {
- glDeleteObjectARB(tmpFrag);
- }
- mOk = 1;
- mError = 0;
- return true;
-
-programError:
- if (tmpVert) {
- glDeleteObjectARB(tmpVert);
- tmpVert = 0;
- }
-
- if (tmpFrag) {
- glDeleteObjectARB(tmpFrag);
- tmpFrag = 0;
- }
-
- if (tmpProg) {
- glDeleteObjectARB(tmpProg);
- tmpProg = 0;
- }
-
- mOk = 0;
- mUse = 0;
- mError = 1;
- return false;
-}
-
-const char *BL_Shader::GetVertPtr()
-{
- return vertProg ? vertProg : NULL;
-}
-
-const char *BL_Shader::GetFragPtr()
-{
- return fragProg ? fragProg : NULL;
-}
-
-void BL_Shader::SetVertPtr(char *vert)
-{
- vertProg = vert;
-}
-
-void BL_Shader::SetFragPtr(char *frag)
-{
- fragProg = frag;
-}
-
-unsigned int BL_Shader::GetProg()
-{
- return mShader;
-}
-
-//const BL_Sampler *BL_Shader::GetSampler(int i)
-//{
-// MT_assert(i<=MAXTEX);
-// return &mSampler[i];
-//}
-
-void BL_Shader::SetSampler(int loc, int unit)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- glUniform1iARB(loc, unit);
- }
-}
-
-//void BL_Shader::InitializeSampler(int unit, BL_Texture *texture)
-//{
-// MT_assert(unit <= MAXTEX);
-// mSampler[unit].mTexture = texture;
-// mSampler[unit].mLoc = -1;
-// mSampler[unit].mOwn = 0;
-//}
-
-void BL_Shader::SetProg(bool enable)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- if (mShader != 0 && mOk && enable) {
- glUseProgramObjectARB(mShader);
- }
- else {
- glUseProgramObjectARB(0);
- }
- }
-}
-
-void BL_Shader::Update(const RAS_MeshSlot &ms, RAS_IRasterizer *rasty)
-{
- if (!Ok() || !mPreDef.size()) {
- return;
- }
-
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- MT_Matrix4x4 model;
- model.setValue(ms.m_OpenGLMatrix);
- const MT_Matrix4x4 &view = rasty->GetViewMatrix();
-
- if (mAttr == SHD_TANGENT) {
- ms.m_mesh->SetMeshModified(true);
- }
-
- BL_UniformVecDef::iterator it;
- for (it = mPreDef.begin(); it != mPreDef.end(); it++) {
- BL_DefUniform *uni = (*it);
-
- if (uni->mLoc == -1) {
- continue;
- }
-
- switch (uni->mType) {
- case MODELMATRIX:
- {
- SetUniform(uni->mLoc, model);
- break;
- }
- case MODELMATRIX_TRANSPOSE:
- {
- SetUniform(uni->mLoc, model, true);
- break;
- }
- case MODELMATRIX_INVERSE:
- {
- model.invert();
- SetUniform(uni->mLoc, model);
- break;
- }
- case MODELMATRIX_INVERSETRANSPOSE:
- {
- model.invert();
- SetUniform(uni->mLoc, model, true);
- break;
- }
- case MODELVIEWMATRIX:
- {
- SetUniform(uni->mLoc, view * model);
- break;
- }
- case MODELVIEWMATRIX_TRANSPOSE:
- {
- MT_Matrix4x4 mat(view * model);
- SetUniform(uni->mLoc, mat, true);
- break;
- }
- case MODELVIEWMATRIX_INVERSE:
- {
- MT_Matrix4x4 mat(view * model);
- mat.invert();
- SetUniform(uni->mLoc, mat);
- break;
- }
- case MODELVIEWMATRIX_INVERSETRANSPOSE:
- {
- MT_Matrix4x4 mat(view * model);
- mat.invert();
- SetUniform(uni->mLoc, mat, true);
- break;
- }
- case CAM_POS:
- {
- MT_Point3 pos(rasty->GetCameraPosition());
- SetUniform(uni->mLoc, pos);
- break;
- }
- case VIEWMATRIX:
- {
- SetUniform(uni->mLoc, view);
- break;
- }
- case VIEWMATRIX_TRANSPOSE:
- {
- SetUniform(uni->mLoc, view, true);
- break;
- }
- case VIEWMATRIX_INVERSE:
- {
- MT_Matrix4x4 viewinv = view;
- viewinv.invert();
- SetUniform(uni->mLoc, view);
- break;
- }
- case VIEWMATRIX_INVERSETRANSPOSE:
- {
- MT_Matrix4x4 viewinv = view;
- viewinv.invert();
- SetUniform(uni->mLoc, view, true);
- break;
- }
- case CONSTANT_TIMER:
- {
- SetUniform(uni->mLoc, (float)rasty->GetTime());
- break;
- }
- default:
- break;
- }
- }
- }
-}
-
-int BL_Shader::GetAttribLocation(const char *name)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- return glGetAttribLocationARB(mShader, name);
- }
-
- return -1;
-}
-
-void BL_Shader::BindAttribute(const char *attr, int loc)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- glBindAttribLocationARB(mShader, loc, attr);
- }
-}
-
-int BL_Shader::GetUniformLocation(const char *name)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- MT_assert(mShader != 0);
- int location = glGetUniformLocationARB(mShader, name);
-
- if (location == -1) {
- spit("Invalid uniform value: " << name << ".");
- }
-
- return location;
- }
- return -1;
-}
-
-void BL_Shader::SetUniform(int uniform, const MT_Tuple2 &vec)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- float value[2];
- vec.getValue(value);
- glUniform2fvARB(uniform, 1, value);
- }
-}
-
-void BL_Shader::SetUniform(int uniform, const MT_Tuple3 &vec)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- float value[3];
- vec.getValue(value);
- glUniform3fvARB(uniform, 1, value);
- }
-}
-
-void BL_Shader::SetUniform(int uniform, const MT_Tuple4 &vec)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- float value[4];
- vec.getValue(value);
- glUniform4fvARB(uniform, 1, value);
- }
-}
-
-void BL_Shader::SetUniform(int uniform, const unsigned int &val)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- glUniform1iARB(uniform, val);
- }
-}
-
-void BL_Shader::SetUniform(int uniform, const int val)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- glUniform1iARB(uniform, val);
- }
-}
-
-void BL_Shader::SetUniform(int uniform, const float &val)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- glUniform1fARB(uniform, val);
- }
-}
-
-void BL_Shader::SetUniform(int uniform, const MT_Matrix4x4 &vec, bool transpose)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- float value[16];
- // note: getValue gives back column major as needed by OpenGL
- vec.getValue(value);
- glUniformMatrix4fvARB(uniform, 1, transpose ? GL_TRUE : GL_FALSE, value);
- }
-}
-
-void BL_Shader::SetUniform(int uniform, const MT_Matrix3x3 &vec, bool transpose)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- float value[9];
- value[0] = (float)vec[0][0];
- value[1] = (float)vec[1][0];
- value[2] = (float)vec[2][0];
- value[3] = (float)vec[0][1];
- value[4] = (float)vec[1][1];
- value[5] = (float)vec[2][1];
- value[6] = (float)vec[0][2];
- value[7] = (float)vec[1][2];
- value[8] = (float)vec[2][2];
- glUniformMatrix3fvARB(uniform, 1, transpose ? GL_TRUE : GL_FALSE, value);
- }
-}
-
-void BL_Shader::SetUniform(int uniform, const float *val, int len)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- if (len == 2) {
- glUniform2fvARB(uniform, 1, (GLfloat *)val);
- }
- else if (len == 3) {
- glUniform3fvARB(uniform, 1, (GLfloat *)val);
- }
- else if (len == 4) {
- glUniform4fvARB(uniform, 1, (GLfloat *)val);
- }
- else {
- MT_assert(0);
- }
- }
-}
-
-void BL_Shader::SetUniform(int uniform, const int *val, int len)
-{
- if (GLEW_ARB_fragment_shader && GLEW_ARB_vertex_shader && GLEW_ARB_shader_objects) {
- if (len == 2) {
- glUniform2ivARB(uniform, 1, (GLint *)val);
- }
- else if (len == 3) {
- glUniform3ivARB(uniform, 1, (GLint *)val);
- }
- else if (len == 4) {
- glUniform4ivARB(uniform, 1, (GLint *)val);
- }
- else {
- MT_assert(0);
- }
- }
-}
-
-#ifdef WITH_PYTHON
-PyMethodDef BL_Shader::Methods[] = {
- // creation
- KX_PYMETHODTABLE(BL_Shader, setSource),
- KX_PYMETHODTABLE(BL_Shader, delSource),
- KX_PYMETHODTABLE(BL_Shader, getVertexProg),
- KX_PYMETHODTABLE(BL_Shader, getFragmentProg),
- KX_PYMETHODTABLE(BL_Shader, setNumberOfPasses),
- KX_PYMETHODTABLE(BL_Shader, validate),
- // access functions
- KX_PYMETHODTABLE(BL_Shader, isValid),
- KX_PYMETHODTABLE(BL_Shader, setUniformEyef),
- KX_PYMETHODTABLE(BL_Shader, setUniform1f),
- KX_PYMETHODTABLE(BL_Shader, setUniform2f),
- KX_PYMETHODTABLE(BL_Shader, setUniform3f),
- KX_PYMETHODTABLE(BL_Shader, setUniform4f),
- KX_PYMETHODTABLE(BL_Shader, setUniform1i),
- KX_PYMETHODTABLE(BL_Shader, setUniform2i),
- KX_PYMETHODTABLE(BL_Shader, setUniform3i),
- KX_PYMETHODTABLE(BL_Shader, setUniform4i),
- KX_PYMETHODTABLE(BL_Shader, setAttrib),
- KX_PYMETHODTABLE(BL_Shader, setUniformfv),
- KX_PYMETHODTABLE(BL_Shader, setUniformiv),
- KX_PYMETHODTABLE(BL_Shader, setUniformDef),
- KX_PYMETHODTABLE(BL_Shader, setSampler),
- KX_PYMETHODTABLE(BL_Shader, setUniformMatrix4),
- KX_PYMETHODTABLE(BL_Shader, setUniformMatrix3),
- {NULL, NULL} //Sentinel
-};
-
-PyAttributeDef BL_Shader::Attributes[] = {
- {NULL} //Sentinel
-};
-
-PyTypeObject BL_Shader::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "BL_Shader",
- 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(BL_Shader, setSource, " setSource(vertexProgram, fragmentProgram)")
-{
- if (mShader != 0 && mOk) {
- // already set...
- Py_RETURN_NONE;
- }
-
- char *v, *f;
- int apply = 0;
-
- if (PyArg_ParseTuple(args, "ssi:setSource", &v, &f, &apply)) {
- vertProg = v;
- fragProg = f;
-
- if (LinkProgram()) {
- glUseProgramObjectARB(mShader);
- mUse = apply != 0;
- Py_RETURN_NONE;
- }
-
- vertProg = NULL;
- fragProg = NULL;
- mUse = 0;
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-
-KX_PYMETHODDEF_DOC(BL_Shader, delSource, "delSource( )")
-{
- ClearUniforms();
- glUseProgramObjectARB(0);
- glDeleteObjectARB(mShader);
- mShader = 0;
- mOk = 0;
- mUse = 0;
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, isValid, "isValid()")
-{
- return PyBool_FromLong((mShader != 0 && mOk));
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, getVertexProg, "getVertexProg( )")
-{
- return PyUnicode_FromString(vertProg ? vertProg : "");
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, getFragmentProg, "getFragmentProg( )")
-{
- return PyUnicode_FromString(fragProg ? fragProg : "");
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, validate, "validate()")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- if (mShader == 0) {
- PyErr_SetString(PyExc_TypeError, "shader.validate(): BL_Shader, invalid shader object");
- return NULL;
- }
-
- int stat = 0;
- glValidateProgramARB(mShader);
- glGetObjectParameterivARB(mShader, GL_OBJECT_VALIDATE_STATUS_ARB, (GLint *)&stat);
-
- if (stat > 0 && stat < MAX_LOG_LEN) {
- int char_len = 0;
- char *logInf = (char *)MEM_mallocN(stat, "validate-log");
-
- glGetInfoLogARB(mShader, stat, (GLsizei *)&char_len, logInf);
-
- if (char_len > 0) {
- spit("---- GLSL Validation ----");
- spit(logInf);
- }
- MEM_freeN(logInf);
- logInf = NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-KX_PYMETHODDEF_DOC(BL_Shader, setSampler, "setSampler(name, index)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- int index = -1;
-
- if (PyArg_ParseTuple(args, "si:setSampler", &uniform, &index)) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
- if (index >= MAXTEX || index < 0) {
- spit("Invalid texture sample index: " << index);
- }
-#ifdef SORT_UNIFORMS
- SetUniformiv(loc, BL_Uniform::UNI_INT, &index, (sizeof(int)));
-#else
- SetUniform(loc, index);
-#endif
- //if (index <= MAXTEX)
- // mSampler[index].mLoc = loc;
- //else
- // spit("Invalid texture sample index: " << index);
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setNumberOfPasses, "setNumberOfPasses( max-pass )")
-{
- int pass = 1;
-
- if (!PyArg_ParseTuple(args, "i:setNumberOfPasses", &pass)) {
- return NULL;
- }
-
- mPass = 1;
- Py_RETURN_NONE;
-}
-
-/// access functions
-KX_PYMETHODDEF_DOC(BL_Shader, setUniform1f, "setUniform1f(name, fx)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- float value = 0.0f;
-
- if (PyArg_ParseTuple(args, "sf:setUniform1f", &uniform, &value)) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
-#ifdef SORT_UNIFORMS
- SetUniformfv(loc, BL_Uniform::UNI_FLOAT, &value, sizeof(float));
-#else
- SetUniform(loc, (float)value);
-#endif
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniform2f, "setUniform2f(name, fx, fy)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- float array[2] = {0.0f, 0.0f};
-
- if (PyArg_ParseTuple(args, "sff:setUniform2f", &uniform, &array[0], &array[1])) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
-#ifdef SORT_UNIFORMS
- SetUniformfv(loc, BL_Uniform::UNI_FLOAT2, array, (sizeof(float) * 2));
-#else
- SetUniform(loc, array, 2);
-#endif
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- float array[3] = {0.0f, 0.0f, 0.0f};
-
- if (PyArg_ParseTuple(args, "sfff:setUniform3f", &uniform, &array[0], &array[1], &array[2])) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
-#ifdef SORT_UNIFORMS
- SetUniformfv(loc, BL_Uniform::UNI_FLOAT3, array, (sizeof(float) * 3));
-#else
- SetUniform(loc, array, 3);
-#endif
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) ")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- float array[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-
- if (PyArg_ParseTuple(args, "sffff:setUniform4f", &uniform, &array[0], &array[1], &array[2], &array[3])) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
-#ifdef SORT_UNIFORMS
- SetUniformfv(loc, BL_Uniform::UNI_FLOAT4, array, (sizeof(float) * 4));
-#else
- SetUniform(loc, array, 4);
-#endif
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniformEyef, "setUniformEyef(name)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
- const char *uniform;
- float value = 0.0f;
- if (PyArg_ParseTuple(args, "s:setUniformEyef", &uniform)) {
- int loc = GetUniformLocation(uniform);
- if (loc != -1) {
-#ifdef SORT_UNIFORMS
- SetUniformfv(loc, BL_Uniform::UNI_FLOAT_EYE, &value, sizeof(float));
-#else
- SetUniform(loc, (int)value);
-#endif
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniform1i, "setUniform1i(name, ix)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- int value = 0;
-
- if (PyArg_ParseTuple(args, "si:setUniform1i", &uniform, &value)) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
-#ifdef SORT_UNIFORMS
- SetUniformiv(loc, BL_Uniform::UNI_INT, &value, sizeof(int));
-#else
- SetUniform(loc, (int)value);
-#endif
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniform2i, "setUniform2i(name, ix, iy)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- int array[2] = {0, 0};
-
- if (PyArg_ParseTuple(args, "sii:setUniform2i", &uniform, &array[0], &array[1])) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
-#ifdef SORT_UNIFORMS
- SetUniformiv(loc, BL_Uniform::UNI_INT2, array, sizeof(int) * 2);
-#else
- SetUniform(loc, array, 2);
-#endif
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- int array[3] = {0, 0, 0};
-
- if (PyArg_ParseTuple(args, "siii:setUniform3i", &uniform, &array[0], &array[1], &array[2])) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
-#ifdef SORT_UNIFORMS
- SetUniformiv(loc, BL_Uniform::UNI_INT3, array, sizeof(int) * 3);
-#else
- SetUniform(loc, array, 3);
-#endif
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) ")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- int array[4] = {0, 0, 0, 0};
-
- if (PyArg_ParseTuple(args, "siiii:setUniform4i", &uniform, &array[0], &array[1], &array[2], &array[3])) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
-#ifdef SORT_UNIFORMS
- SetUniformiv(loc, BL_Uniform::UNI_INT4, array, sizeof(int) * 4);
-#else
- SetUniform(loc, array, 4);
-#endif
- }
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniformfv, "setUniformfv(float (list2 or list3 or list4))")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform = "";
- PyObject *listPtr = NULL;
- float array_data[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-
- if (PyArg_ParseTuple(args, "sO:setUniformfv", &uniform, &listPtr)) {
- int loc = GetUniformLocation(uniform);
- if (loc != -1) {
- if (PySequence_Check(listPtr)) {
- unsigned int list_size = PySequence_Size(listPtr);
-
- for (unsigned int i = 0; (i < list_size && i < 4); i++) {
- PyObject *item = PySequence_GetItem(listPtr, i);
- array_data[i] = (float)PyFloat_AsDouble(item);
- Py_DECREF(item);
- }
-
- switch (list_size) {
- case 2:
- {
- float array2[2] = {array_data[0], array_data[1]};
-#ifdef SORT_UNIFORMS
- SetUniformfv(loc, BL_Uniform::UNI_FLOAT2, array2, sizeof(float) * 2);
-#else
- SetUniform(loc, array2, 2);
-#endif
- Py_RETURN_NONE;
- break;
- }
- case 3:
- {
- float array3[3] = {array_data[0], array_data[1], array_data[2]};
-#ifdef SORT_UNIFORMS
- SetUniformfv(loc, BL_Uniform::UNI_FLOAT3, array3, sizeof(float) * 3);
-#else
- SetUniform(loc, array3, 3);
-#endif
- Py_RETURN_NONE;
- break;
- }
- case 4:
- {
- float array4[4] = {array_data[0], array_data[1], array_data[2], array_data[3]};
-#ifdef SORT_UNIFORMS
- SetUniformfv(loc, BL_Uniform::UNI_FLOAT4, array4, sizeof(float) * 4);
-#else
- SetUniform(loc, array4, 4);
-#endif
- Py_RETURN_NONE;
- break;
- }
- default:
- {
- PyErr_SetString(PyExc_TypeError,
- "shader.setUniform4i(name, ix,iy,iz, iw): BL_Shader. invalid list size");
- return NULL;
- break;
- }
- }
- }
- }
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniformiv, "setUniformiv(uniform_name, (list2 or list3 or list4))")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform = "";
- PyObject *listPtr = NULL;
- int array_data[4] = {0, 0, 0, 0};
-
- if (!PyArg_ParseTuple(args, "sO:setUniformiv", &uniform, &listPtr)) {
- return NULL;
- }
-
- int loc = GetUniformLocation(uniform);
-
- if (loc == -1) {
- PyErr_SetString(PyExc_TypeError,
- "shader.setUniformiv(...): BL_Shader, first string argument is not a valid uniform value");
- return NULL;
- }
-
- if (!PySequence_Check(listPtr)) {
- PyErr_SetString(PyExc_TypeError, "shader.setUniformiv(...): BL_Shader, second argument is not a sequence");
- return NULL;
- }
-
- unsigned int list_size = PySequence_Size(listPtr);
-
- for (unsigned int i = 0; (i < list_size && i < 4); i++) {
- PyObject *item = PySequence_GetItem(listPtr, i);
- array_data[i] = PyLong_AsLong(item);
- Py_DECREF(item);
- }
-
- if (PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "shader.setUniformiv(...): BL_Shader, one or more values in the list is not an int");
- return NULL;
- }
-
- // Sanity checks done!
- switch (list_size) {
- case 2:
- {
- int array2[2] = {array_data[0], array_data[1]};
-#ifdef SORT_UNIFORMS
- SetUniformiv(loc, BL_Uniform::UNI_INT2, array2, sizeof(int) * 2);
-#else
- SetUniform(loc, array2, 2);
-#endif
- Py_RETURN_NONE;
- break;
- }
- case 3:
- {
- int array3[3] = {array_data[0], array_data[1], array_data[2]};
-#ifdef SORT_UNIFORMS
- SetUniformiv(loc, BL_Uniform::UNI_INT3, array3, sizeof(int) * 3);
-#else
- SetUniform(loc, array3, 3);
-#endif
- Py_RETURN_NONE;
- break;
- }
- case 4:
- {
- int array4[4] = {array_data[0], array_data[1], array_data[2], array_data[3]};
-#ifdef SORT_UNIFORMS
- SetUniformiv(loc, BL_Uniform::UNI_INT4, array4, sizeof(int) * 4);
-#else
- SetUniform(loc, array4, 4);
-#endif
- Py_RETURN_NONE;
- break;
- }
- default:
- {
- PyErr_SetString(PyExc_TypeError,
- "shader.setUniformiv(...): BL_Shader, second argument, invalid list size, expected an int "
- "list between 2 and 4");
- return NULL;
- break;
- }
- }
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniformMatrix4,
- "setUniformMatrix4(uniform_name, mat-4x4, transpose(row-major=true, col-major=false)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- float matr[16] = {
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
- };
-
- const char *uniform;
- PyObject *matrix = NULL;
- int transp = 0; // python use column major by default, so no transpose....
-
- if (!PyArg_ParseTuple(args, "sO|i:setUniformMatrix4", &uniform, &matrix, &transp)) {
- return NULL;
- }
-
- int loc = GetUniformLocation(uniform);
-
- if (loc == -1) {
- PyErr_SetString(PyExc_TypeError,
- "shader.setUniformMatrix4(...): BL_Shader, first string argument is not a valid uniform value");
- return NULL;
- }
-
- MT_Matrix4x4 mat;
-
- if (!PyMatTo(matrix, mat)) {
- PyErr_SetString(PyExc_TypeError,
- "shader.setUniformMatrix4(...): BL_Shader, second argument cannot be converted into a 4x4 matrix");
- return NULL;
- }
-
- // Sanity checks done!
-#ifdef SORT_UNIFORMS
- mat.getValue(matr);
- SetUniformfv(loc, BL_Uniform::UNI_MAT4, matr, (sizeof(float) * 16), (transp != 0));
-#else
- SetUniform(loc, mat, (transp != 0));
-#endif
- Py_RETURN_NONE;
-}
-
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniformMatrix3,
- "setUniformMatrix3(uniform_name, list[3x3], transpose(row-major=true, col-major=false)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- float matr[9] = {
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f,
- };
-
- const char *uniform;
- PyObject *matrix = NULL;
- int transp = 0; // python use column major by default, so no transpose....
-
- if (!PyArg_ParseTuple(args, "sO|i:setUniformMatrix3", &uniform, &matrix, &transp)) {
- return NULL;
- }
-
- int loc = GetUniformLocation(uniform);
-
- if (loc == -1) {
- PyErr_SetString(PyExc_TypeError,
- "shader.setUniformMatrix3(...): BL_Shader, first string argument is not a valid uniform value");
- return NULL;
- }
-
- MT_Matrix3x3 mat;
-
- if (!PyMatTo(matrix, mat)) {
- PyErr_SetString(PyExc_TypeError,
- "shader.setUniformMatrix3(...): BL_Shader, second argument cannot be converted into a 3x3 matrix");
- return NULL;
- }
-
-#ifdef SORT_UNIFORMS
- mat.getValue3x3(matr);
- SetUniformfv(loc, BL_Uniform::UNI_MAT3, matr, (sizeof(float) * 9), (transp != 0));
-#else
- SetUniform(loc, mat, (transp != 0));
-#endif
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(BL_Shader, setAttrib, "setAttrib(enum)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- int attr = 0;
-
- if (!PyArg_ParseTuple(args, "i:setAttrib", &attr)) {
- return NULL;
- }
-
- attr = SHD_TANGENT; // user input is ignored for now, there is only 1 attr
-
- if (mShader == 0) {
- PyErr_SetString(PyExc_ValueError, "shader.setAttrib() BL_Shader, invalid shader object");
- return NULL;
- }
-
- mAttr = attr;
- glUseProgramObjectARB(mShader);
- glBindAttribLocationARB(mShader, mAttr, "Tangent");
- Py_RETURN_NONE;
-}
-
-
-KX_PYMETHODDEF_DOC(BL_Shader, setUniformDef, "setUniformDef(name, enum)")
-{
- if (mError) {
- Py_RETURN_NONE;
- }
-
- const char *uniform;
- int nloc = 0;
- if (PyArg_ParseTuple(args, "si:setUniformDef", &uniform, &nloc)) {
- int loc = GetUniformLocation(uniform);
-
- if (loc != -1) {
- bool defined = false;
- BL_UniformVecDef::iterator it = mPreDef.begin();
- while (it != mPreDef.end()) {
- if ((*it)->mLoc == loc) {
- defined = true;
- break;
- }
- it++;
- }
-
- if (defined) {
- Py_RETURN_NONE;
- }
-
- BL_DefUniform *uni = new BL_DefUniform();
- uni->mLoc = loc;
- uni->mType = nloc;
- uni->mFlag = 0;
- mPreDef.push_back(uni);
- Py_RETURN_NONE;
- }
- }
- return NULL;
-}
-
-#endif // WITH_PYTHON
-
-// eof
diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h
deleted file mode 100644
index 5de715d67d4..00000000000
--- a/source/gameengine/Ketsji/BL_Shader.h
+++ /dev/null
@@ -1,241 +0,0 @@
-
-/** \file BL_Shader.h
- * \ingroup ketsji
- */
-
-#ifndef __BL_SHADER_H__
-#define __BL_SHADER_H__
-
-#include "EXP_PyObjectPlus.h"
-#include "BL_Material.h"
-#include "BL_Texture.h"
-#include "MT_Matrix4x4.h"
-#include "MT_Matrix3x3.h"
-#include "MT_Tuple2.h"
-#include "MT_Tuple3.h"
-#include "MT_Tuple4.h"
-
-/**
- * BL_Sampler
- * Sampler access
- */
-class BL_Sampler
-{
-public:
- BL_Sampler()
- :
- mLoc(-1)
- {
- }
-
- int mLoc; // Sampler location
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Sampler")
-#endif
-};
-
-/**
- * BL_Uniform
- * uniform storage
- */
-class BL_Uniform
-{
-private:
- int mLoc; // Uniform location
- void *mData; // Memory allocated for variable
- bool mDirty; // Caching variable
- int mType; // Enum UniformTypes
- bool mTranspose; // Transpose matrices
- const int mDataLen; // Length of our data
-public:
- BL_Uniform(int data_size);
- ~BL_Uniform();
-
- enum UniformTypes {
- UNI_NONE = 0,
- UNI_INT,
- UNI_FLOAT,
- UNI_INT2,
- UNI_FLOAT2,
- UNI_INT3,
- UNI_FLOAT3,
- UNI_INT4,
- UNI_FLOAT4,
- UNI_MAT3,
- UNI_MAT4,
- UNI_FLOAT_EYE,
- UNI_MAX
- };
-
- bool Apply(class BL_Shader *shader);
- void SetData(int location, int type, bool transpose = false);
- int GetLocation() { return mLoc; }
- void *getData() { return mData; }
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Uniform")
-#endif
-};
-
-/**
- * BL_DefUniform
- * pre defined uniform storage
- */
-class BL_DefUniform
-{
-public:
- BL_DefUniform()
- :
- mType(0),
- mLoc(0),
- mFlag(0)
- {
- }
-
- int mType;
- int mLoc;
- unsigned int mFlag;
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_DefUniform")
-#endif
-};
-
-/**
- * BL_Shader
- * shader access
- */
-class BL_Shader : public PyObjectPlus
-{
- Py_Header
-private:
- typedef std::vector<BL_Uniform *> BL_UniformVec;
- typedef std::vector<BL_DefUniform *> BL_UniformVecDef;
-
- unsigned int mShader; // Shader object
- int mPass; // 1.. unused
- bool mOk; // Valid and ok
- bool mUse;
- //BL_Sampler mSampler[MAXTEX]; // Number of samplers
- int mAttr; // Tangent attribute
- const char *vertProg; // Vertex program string
- const char *fragProg; // Fragment program string
- bool mError;
- bool mDirty;
-
- // Stored uniform variables
- BL_UniformVec mUniforms;
- BL_UniformVecDef mPreDef;
-
- // Compiles and links the shader
- bool LinkProgram();
-
- // search by location
- BL_Uniform *FindUniform(const int location);
-
- // clears uniform data
- void ClearUniforms();
-
-public:
- BL_Shader();
- virtual ~BL_Shader();
-
- // Unused for now tangent is set as tex coords
- enum AttribTypes {
- SHD_TANGENT = 1
- };
-
- enum GenType {
- MODELVIEWMATRIX,
- MODELVIEWMATRIX_TRANSPOSE,
- MODELVIEWMATRIX_INVERSE,
- MODELVIEWMATRIX_INVERSETRANSPOSE,
- MODELMATRIX,
- MODELMATRIX_TRANSPOSE,
- MODELMATRIX_INVERSE,
- MODELMATRIX_INVERSETRANSPOSE,
- VIEWMATRIX,
- VIEWMATRIX_TRANSPOSE,
- VIEWMATRIX_INVERSE,
- VIEWMATRIX_INVERSETRANSPOSE,
- CAM_POS,
- CONSTANT_TIMER
- };
-
- const char *GetVertPtr();
- const char *GetFragPtr();
- void SetVertPtr(char *vert);
- void SetFragPtr(char *frag);
- int getNumPass() { return mPass; }
- bool GetError() { return mError; }
-
- //const BL_Sampler *GetSampler(int i);
- void SetSampler(int loc, int unit);
- bool Ok() const;
- unsigned int GetProg();
- void SetProg(bool enable);
- int GetAttribute() { return mAttr; }
-
- // Apply methods : sets colected uniforms
- void ApplyShader();
- void UnloadShader();
-
- // Update predefined uniforms each render call
- void Update(const class RAS_MeshSlot &ms, class RAS_IRasterizer *rasty);
-
- // Set sampler units (copied)
- //void InitializeSampler(int unit, BL_Texture *texture);
- void SetUniformfv(int location, int type, float *param, int size, bool transpose = false);
- void SetUniformiv(int location, int type, int *param, int size, bool transpose = false);
- int GetAttribLocation(const char *name);
- void BindAttribute(const char *attr, int loc);
- int GetUniformLocation(const char *name);
- void SetUniform(int uniform, const MT_Tuple2 &vec);
- void SetUniform(int uniform, const MT_Tuple3 &vec);
- void SetUniform(int uniform, const MT_Tuple4 &vec);
- void SetUniform(int uniform, const MT_Matrix4x4 &vec, bool transpose = false);
- void SetUniform(int uniform, const MT_Matrix3x3 &vec, bool transpose = false);
- void SetUniform(int uniform, const float &val);
- void SetUniform(int uniform, const float *val, int len);
- void SetUniform(int uniform, const int *val, int len);
- void SetUniform(int uniform, const unsigned int &val);
- void SetUniform(int uniform, const int val);
-
- // Python interface
-#ifdef WITH_PYTHON
- virtual PyObject *py_repr()
- {
- return PyUnicode_FromFormat("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n", vertProg, fragProg);
- }
-
- // -----------------------------------
- KX_PYMETHOD_DOC(BL_Shader, setSource);
- KX_PYMETHOD_DOC(BL_Shader, delSource);
- KX_PYMETHOD_DOC(BL_Shader, getVertexProg);
- KX_PYMETHOD_DOC(BL_Shader, getFragmentProg);
- KX_PYMETHOD_DOC(BL_Shader, setNumberOfPasses);
- KX_PYMETHOD_DOC(BL_Shader, isValid);
- KX_PYMETHOD_DOC(BL_Shader, validate);
-
- // -----------------------------------
- KX_PYMETHOD_DOC(BL_Shader, setUniform4f);
- KX_PYMETHOD_DOC(BL_Shader, setUniform3f);
- KX_PYMETHOD_DOC(BL_Shader, setUniform2f);
- KX_PYMETHOD_DOC(BL_Shader, setUniform1f);
- KX_PYMETHOD_DOC(BL_Shader, setUniform4i);
- KX_PYMETHOD_DOC(BL_Shader, setUniform3i);
- KX_PYMETHOD_DOC(BL_Shader, setUniform2i);
- KX_PYMETHOD_DOC(BL_Shader, setUniform1i);
- KX_PYMETHOD_DOC(BL_Shader, setUniformEyef);
- KX_PYMETHOD_DOC(BL_Shader, setUniformfv);
- KX_PYMETHOD_DOC(BL_Shader, setUniformiv);
- KX_PYMETHOD_DOC(BL_Shader, setUniformMatrix4);
- KX_PYMETHOD_DOC(BL_Shader, setUniformMatrix3);
- KX_PYMETHOD_DOC(BL_Shader, setUniformDef);
- KX_PYMETHOD_DOC(BL_Shader, setAttrib);
- KX_PYMETHOD_DOC(BL_Shader, setSampler);
-#endif
-};
-
-#endif /* __BL_SHADER_H__ */
diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp
deleted file mode 100644
index c3b799b9424..00000000000
--- a/source/gameengine/Ketsji/BL_Texture.cpp
+++ /dev/null
@@ -1,759 +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/BL_Texture.cpp
- * \ingroup ketsji
- */
-
-#include "GPU_glew.h"
-
-#include <iostream>
-#include <map>
-#include <stdlib.h>
-
-#include "BL_Material.h"
-#include "BL_Texture.h"
-#include "MT_assert.h"
-
-#include "DNA_texture_types.h"
-#include "DNA_image_types.h"
-#include "IMB_imbuf_types.h"
-#include "BKE_image.h"
-#include "BLI_blenlib.h"
-
-#include "RAS_ICanvas.h"
-#include "RAS_Rect.h"
-
-#include "KX_GameObject.h"
-
-#define spit(x) std::cout << x << std::endl;
-
-#include "MEM_guardedalloc.h"
-#include "GPU_draw.h"
-#include "GPU_extensions.h"
-
-extern "C" {
- // envmaps
- #include "IMB_imbuf.h"
- void my_envmap_split_ima(EnvMap *env, ImBuf *ibuf);
- void my_free_envmapdata(EnvMap *env);
-}
-
-// (n&(n-1)) zeros the least significant bit of n
-static int is_power_of_2_i(int num)
-{
- return ((num)&(num-1))==0;
-}
-static int power_of_2_min_i(int num)
-{
- while (!is_power_of_2_i(num))
- num= num&(num-1);
- return num;
-}
-
-// Place holder for a full texture manager
-class BL_TextureObject
-{
-public:
- unsigned int gl_texture;
- void* ref_buffer;
-};
-
-typedef std::map<char*, BL_TextureObject> BL_TextureMap;
-static BL_TextureMap g_textureManager;
-static GLint g_max_units = -1;
-
-
-BL_Texture::BL_Texture()
-: mTexture(0),
- mOk(0),
- mNeedsDeleted(0),
- mType(0),
- mUnit(0),
- mEnvState(0)
-{
- // --
-}
-
-BL_Texture::~BL_Texture()
-{
- // --
-}
-
-void BL_Texture::DeleteTex()
-{
- if ( mNeedsDeleted ) {
- glDeleteTextures(1, (GLuint*)&mTexture);
- mNeedsDeleted = 0;
- mOk = 0;
- }
-
- if (mEnvState) {
- glDeleteLists((GLuint)mEnvState, 1);
- mEnvState =0;
- }
-
- if (mDisableState) {
- glDeleteLists((GLuint)mDisableState, 1);
- mDisableState =0;
- }
- g_textureManager.clear();
-}
-
-
-bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap)
-{
-
- ImBuf *ibuf;
- if (!img || img->ok==0)
- {
- mOk = false;
- return mOk;
- }
-
- ibuf= BKE_image_acquire_ibuf(img, NULL, NULL);
- if (ibuf==NULL)
- {
- img->ok = 0;
- mOk = false;
- return mOk;
- }
-
- mipmap = mipmap && GPU_get_mipmap();
-
- mTexture = img->bindcode[TEXTARGET_TEXTURE_2D];
- mType = GL_TEXTURE_2D;
- mUnit = unit;
-
- ActivateUnit(mUnit);
-
- if (mTexture != 0) {
- glBindTexture(GL_TEXTURE_2D, mTexture );
- Validate();
- BKE_image_release_ibuf(img, ibuf, NULL);
- return mOk;
- }
-
- // look for an existing gl image
- BL_TextureMap::iterator mapLook = g_textureManager.find(img->id.name);
- if (mapLook != g_textureManager.end())
- {
- if (mapLook->second.gl_texture != 0)
- {
- mTexture = mapLook->second.gl_texture;
- glBindTexture(GL_TEXTURE_2D, mTexture);
- mOk = IsValid();
- BKE_image_release_ibuf(img, ibuf, NULL);
- return mOk;
- }
- }
-
- mNeedsDeleted = 1;
- glGenTextures(1, (GLuint*)&mTexture);
-
-#ifdef WITH_DDS
- if (ibuf->ftype == IMB_FTYPE_DDS)
- InitGLCompressedTex(ibuf, mipmap);
- else
- InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap);
-#else
- InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap);
-#endif
-
- // track created units
- BL_TextureObject obj;
- obj.gl_texture = mTexture;
- obj.ref_buffer = img;
- g_textureManager.insert(std::pair<char*, BL_TextureObject>((char*)img->id.name, obj));
-
-
- glDisable(GL_TEXTURE_2D);
- ActivateUnit(0);
- Validate();
-
- BKE_image_release_ibuf(img, ibuf, NULL);
-
- return mOk;
-}
-
-void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap)
-{
- if (!GPU_full_non_power_of_two_support() && (!is_power_of_2_i(x) || !is_power_of_2_i(y)) ) {
- InitNonPow2Tex(pix, x,y,mipmap);
- return;
- }
-
- glBindTexture(GL_TEXTURE_2D, mTexture );
- if ( mipmap ) {
- int i;
- ImBuf *ibuf;
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- ibuf = IMB_allocFromBuffer(pix, NULL, x, y);
-
- IMB_makemipmap(ibuf, true);
-
- for (i = 0; i < ibuf->miptot; i++) {
- ImBuf *mip = IMB_getmipmap(ibuf, i);
-
- glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, mip->x, mip->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect);
- }
- IMB_freeImBuf(ibuf);
- }
- else {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix );
- }
-
- if (GLEW_EXT_texture_filter_anisotropic)
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-}
-
-void BL_Texture::InitGLCompressedTex(ImBuf *ibuf, bool mipmap)
-{
-#ifndef WITH_DDS
- // Fall back to uncompressed if DDS isn't enabled
- InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap);
- return;
-#else
- glBindTexture(GL_TEXTURE_2D, mTexture);
-
- if (GPU_upload_dxt_texture(ibuf) == 0) {
- InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap);
- return;
- }
-#endif
-}
-
-void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap)
-{
- int nx= power_of_2_min_i(x);
- int ny= power_of_2_min_i(y);
-
- ImBuf *ibuf = IMB_allocFromBuffer(pix, NULL, x, y);
- IMB_scaleImBuf(ibuf, nx, ny);
-
- glBindTexture(GL_TEXTURE_2D, mTexture );
-
- if ( mipmap ) {
- int i;
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- IMB_makemipmap(ibuf, true);
-
- for (i = 0; i < ibuf->miptot; i++) {
- ImBuf *mip = IMB_getmipmap(ibuf, i);
-
- glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, mip->x, mip->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect);
- }
- }
- else {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nx, ny, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect );
- }
-
- if (GLEW_EXT_texture_filter_anisotropic)
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- IMB_freeImBuf(ibuf);
-}
-
-
-bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap)
-{
- if (!GLEW_ARB_texture_cube_map)
- {
- spit("cubemaps not supported");
- mOk = false;
- return mOk;
- }
- else if (!cubemap || cubemap->ima->ok==0)
- {
- mOk = false;
- return mOk;
- }
-
- ImBuf *ibuf= BKE_image_acquire_ibuf(cubemap->ima, NULL, NULL);
- if (ibuf==0)
- {
- cubemap->ima->ok = 0;
- mOk = false;
- return mOk;
- }
-
- mNeedsDeleted = 1;
- mType = GL_TEXTURE_CUBE_MAP_ARB;
- mTexture = 0;
- mUnit = unit;
-
- ActivateUnit(mUnit);
-
- BL_TextureMap::iterator mapLook = g_textureManager.find(cubemap->ima->id.name);
- if (mapLook != g_textureManager.end())
- {
- if (mapLook->second.gl_texture != 0 && mapLook->second.ref_buffer == cubemap->ima)
- {
- mTexture = mapLook->second.gl_texture;
- glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mTexture);
- mOk = IsValid();
- BKE_image_release_ibuf(cubemap->ima, ibuf, NULL);
- return mOk;
- }
- }
-
-
- glGenTextures(1, (GLuint*)&mTexture);
- glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mTexture);
-
-
- // track created units
- BL_TextureObject obj;
- obj.gl_texture = mTexture;
- obj.ref_buffer = cubemap->ima;
- g_textureManager.insert(std::pair<char*, BL_TextureObject>((char*)cubemap->ima->id.name, obj));
-
-
- bool needs_split = false;
- if (!cubemap->cube[0])
- {
- needs_split = true;
- spit ("Re-Generating texture buffer");
- }
-
- if (needs_split)
- my_envmap_split_ima(cubemap, ibuf);
-
-
- if (!is_power_of_2_i(cubemap->cube[0]->x) || !is_power_of_2_i(cubemap->cube[0]->y))
- {
- spit("invalid envmap size please render with CubeRes @ power of two");
-
- my_free_envmapdata(cubemap);
- mOk = false;
- BKE_image_release_ibuf(cubemap->ima, ibuf, NULL);
- return mOk;
- }
-
-
-#define SetCubeMapFace(face, num) \
- glTexImage2D(face, 0,GL_RGBA, \
- cubemap->cube[num]->x, \
- cubemap->cube[num]->y, \
- 0, GL_RGBA, GL_UNSIGNED_BYTE, \
- cubemap->cube[num]->rect)
-
- SetCubeMapFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 5);
- SetCubeMapFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, 3);
- SetCubeMapFace(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, 0);
- SetCubeMapFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, 1);
- SetCubeMapFace(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, 2);
- SetCubeMapFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, 4);
-
- glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- if (GLEW_VERSION_1_2)
- glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE );
-
- if (needs_split)
- my_free_envmapdata(cubemap);
-
-
-
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
- ActivateUnit(0);
-
- mOk = IsValid();
-
- BKE_image_release_ibuf(cubemap->ima, ibuf, NULL);
-
- return mOk;
-}
-
-bool BL_Texture::IsValid()
-{
- return (mTexture!= 0)?glIsTexture(mTexture)!=0:false;
-}
-
-
-void BL_Texture::Validate()
-{
- mOk = IsValid();
-}
-
-
-bool BL_Texture::Ok()
-{
- return (mTexture!= 0);
-}
-
-
-unsigned int BL_Texture::GetTextureType() const
-{
- return mType;
-}
-
-int BL_Texture::GetMaxUnits()
-{
- if (g_max_units < 0) {
- GLint unit = 0;
- glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &unit);
- g_max_units = (MAXTEX >= unit) ? unit : MAXTEX;
- }
-
- return g_max_units;
-}
-
-void BL_Texture::ActivateFirst()
-{
- if (GLEW_ARB_multitexture)
- glActiveTextureARB(GL_TEXTURE0_ARB);
-}
-
-void BL_Texture::ActivateUnit(int unit)
-{
- if (GLEW_ARB_multitexture)
- if (unit <= MAXTEX)
- glActiveTextureARB(GL_TEXTURE0_ARB+unit);
-}
-
-
-void BL_Texture::DisableUnit()
-{
- if (GLEW_ARB_multitexture)
- glActiveTextureARB(GL_TEXTURE0_ARB+mUnit);
-
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
-
- if (GLEW_ARB_texture_cube_map && glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
- else
- {
- if (glIsEnabled(GL_TEXTURE_2D))
- glDisable(GL_TEXTURE_2D);
- }
-
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- glDisable(GL_TEXTURE_GEN_R);
- glDisable(GL_TEXTURE_GEN_Q);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-}
-
-
-void BL_Texture::DisableAllTextures()
-{
- for (int i=0; i<MAXTEX; i++) {
- if (GLEW_ARB_multitexture)
- glActiveTextureARB(GL_TEXTURE0_ARB+i);
-
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- glDisable(GL_TEXTURE_GEN_R);
- glDisable(GL_TEXTURE_GEN_Q);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- }
-
- if (GLEW_ARB_multitexture)
- glActiveTextureARB(GL_TEXTURE0_ARB);
-}
-
-
-void BL_Texture::ActivateTexture()
-{
- if (GLEW_ARB_multitexture)
- glActiveTextureARB(GL_TEXTURE0_ARB+mUnit);
-
- if (mType == GL_TEXTURE_CUBE_MAP_ARB && GLEW_ARB_texture_cube_map)
- {
- glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, mTexture );
- glEnable(GL_TEXTURE_CUBE_MAP_ARB);
- }
- else {
- if (GLEW_ARB_texture_cube_map )
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
-
- glBindTexture( GL_TEXTURE_2D, mTexture );
- glEnable(GL_TEXTURE_2D);
- }
-}
-
-void BL_Texture::SetMapping(int mode)
-{
-
- if (!(mode &USEREFL)) {
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- glDisable(GL_TEXTURE_GEN_R);
- glDisable(GL_TEXTURE_GEN_Q);
- return;
- }
-
- if ( mType == GL_TEXTURE_CUBE_MAP_ARB &&
- GLEW_ARB_texture_cube_map &&
- mode &USEREFL)
- {
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB );
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB );
- glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB );
-
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
- glEnable(GL_TEXTURE_GEN_R);
- glDisable(GL_TEXTURE_GEN_Q);
- return;
- }
- else
- {
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );
-
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
- glDisable(GL_TEXTURE_GEN_R);
- glDisable(GL_TEXTURE_GEN_Q);
- }
-}
-
-
-void BL_Texture::setTexEnv(BL_Material *mat, bool modulate)
-{
- if (modulate || !GLEW_ARB_texture_env_combine) {
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- return;
- }
-
- if (glIsList(mEnvState))
- {
- glCallList(mEnvState);
- return;
- }
- if (!mEnvState)
- mEnvState = glGenLists(1);
-
- glNewList(mEnvState, GL_COMPILE_AND_EXECUTE);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
-
- GLfloat blend_operand = GL_SRC_COLOR;
- GLfloat blend_operand_prev = GL_SRC_COLOR;
- GLfloat alphaOp = GL_SRC_ALPHA;
-
- GLenum combiner = GL_COMBINE_RGB_ARB;
- GLenum source0 = GL_SOURCE0_RGB_ARB;
- GLenum source1 = GL_SOURCE1_RGB_ARB;
- GLenum source2 = GL_SOURCE2_RGB_ARB;
- GLenum op0 = GL_OPERAND0_RGB_ARB;
- GLenum op1 = GL_OPERAND1_RGB_ARB;
- GLenum op2 = GL_OPERAND2_RGB_ARB;
-
- // switch to alpha combiners
- if ( mat->flag[mUnit] &TEXALPHA ) {
- combiner = GL_COMBINE_ALPHA_ARB;
- source0 = GL_SOURCE0_ALPHA_ARB;
- source1 = GL_SOURCE1_ALPHA_ARB;
- source2 = GL_SOURCE2_ALPHA_ARB;
- op0 = GL_OPERAND0_ALPHA_ARB;
- op1 = GL_OPERAND1_ALPHA_ARB;
- op2 = GL_OPERAND2_ALPHA_ARB;
- blend_operand = GL_SRC_ALPHA;
- blend_operand_prev = GL_SRC_ALPHA;
- // invert
- if (mat->flag[mUnit] &TEXNEG) {
- blend_operand_prev = GL_ONE_MINUS_SRC_ALPHA;
- blend_operand = GL_ONE_MINUS_SRC_ALPHA;
- }
- }
- else {
- if (mat->flag[mUnit] &TEXNEG) {
- blend_operand_prev=GL_ONE_MINUS_SRC_COLOR;
- blend_operand = GL_ONE_MINUS_SRC_COLOR;
- }
- }
- bool using_alpha = false;
-
- if (mat->flag[mUnit] &USEALPHA) {
- alphaOp = GL_ONE_MINUS_SRC_ALPHA;
- using_alpha=true;
- }
- else if (mat->flag[mUnit] &USENEGALPHA) {
- alphaOp = GL_SRC_ALPHA;
- using_alpha = true;
- }
-
- switch (mat->blend_mode[mUnit]) {
- case BLEND_MIX:
- {
- // ------------------------------
- if (!using_alpha) {
- GLfloat base_col[4];
- base_col[0] = base_col[1] = base_col[2] = 0.f;
- base_col[3] = 1.f-mat->color_blend[mUnit];
- glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR,base_col );
- }
- glTexEnvf( GL_TEXTURE_ENV, combiner, GL_INTERPOLATE_ARB);
- glTexEnvf( GL_TEXTURE_ENV, source0, GL_PREVIOUS_ARB);
- glTexEnvf( GL_TEXTURE_ENV, op0, blend_operand_prev );
- glTexEnvf( GL_TEXTURE_ENV, source1, GL_TEXTURE );
- glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand);
- if (!using_alpha)
- glTexEnvf( GL_TEXTURE_ENV, source2, GL_CONSTANT_ARB );
- else
- glTexEnvf( GL_TEXTURE_ENV, source2, GL_TEXTURE );
-
- glTexEnvf( GL_TEXTURE_ENV, op2, alphaOp);
- }break;
- case BLEND_MUL:
- {
- // ------------------------------
- glTexEnvf( GL_TEXTURE_ENV, combiner, GL_MODULATE);
- glTexEnvf( GL_TEXTURE_ENV, source0, GL_PREVIOUS_ARB);
- glTexEnvf( GL_TEXTURE_ENV, op0, blend_operand_prev);
- glTexEnvf( GL_TEXTURE_ENV, source1, GL_TEXTURE );
- if (using_alpha)
- glTexEnvf( GL_TEXTURE_ENV, op1, alphaOp);
- else
- glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand);
- }break;
- case BLEND_ADD:
- {
- // ------------------------------
- glTexEnvf( GL_TEXTURE_ENV, combiner, GL_ADD_SIGNED_ARB);
- glTexEnvf( GL_TEXTURE_ENV, source0, GL_PREVIOUS_ARB );
- glTexEnvf( GL_TEXTURE_ENV, op0, blend_operand_prev );
- glTexEnvf( GL_TEXTURE_ENV, source1, GL_TEXTURE );
- if (using_alpha)
- glTexEnvf( GL_TEXTURE_ENV, op1, alphaOp);
- else
- glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand);
- }break;
- case BLEND_SUB:
- {
- // ------------------------------
- glTexEnvf( GL_TEXTURE_ENV, combiner, GL_SUBTRACT_ARB);
- glTexEnvf( GL_TEXTURE_ENV, source0, GL_PREVIOUS_ARB );
- glTexEnvf( GL_TEXTURE_ENV, op0, blend_operand_prev );
- glTexEnvf( GL_TEXTURE_ENV, source1, GL_TEXTURE );
- glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand);
- }break;
- case BLEND_SCR:
- {
- // ------------------------------
- glTexEnvf( GL_TEXTURE_ENV, combiner, GL_ADD);
- glTexEnvf( GL_TEXTURE_ENV, source0, GL_PREVIOUS_ARB );
- glTexEnvf( GL_TEXTURE_ENV, op0, blend_operand_prev );
- glTexEnvf( GL_TEXTURE_ENV, source1, GL_TEXTURE );
- if (using_alpha)
- glTexEnvf( GL_TEXTURE_ENV, op1, alphaOp);
- else
- glTexEnvf( GL_TEXTURE_ENV, op1, blend_operand);
- } break;
- }
- glTexEnvf( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f);
-
- glEndList();
-}
-
-int BL_Texture::GetPow2(int n)
-{
- if (!is_power_of_2_i(n))
- n = power_of_2_min_i(n);
-
- return n;
-}
-
-void BL_Texture::SplitEnvMap(EnvMap *map)
-{
- if (!map || !map->ima || (map->ima && !map->ima->ok)) return;
- ImBuf *ibuf= BKE_image_acquire_ibuf(map->ima, NULL, NULL);
- if (ibuf) {
- my_envmap_split_ima(map, ibuf);
- BKE_image_release_ibuf(map->ima, ibuf, NULL);
- }
-}
-
-unsigned int BL_Texture::mDisableState = 0;
-
-extern "C" {
-
-void my_envmap_split_ima(EnvMap *env, ImBuf *ibuf)
-{
- int dx, part;
-
- my_free_envmapdata(env);
-
- dx= ibuf->y;
- dx/= 2;
- if (3*dx != ibuf->x) {
- printf("Incorrect envmap size\n");
- env->ok= 0;
- env->ima->ok= 0;
- }
- else {
- for (part=0; part<6; part++) {
- env->cube[part] = IMB_allocImBuf(dx, dx, 24, IB_rect);
- }
- IMB_rectcpy(env->cube[0], ibuf,
- 0, 0, 0, 0, dx, dx);
- IMB_rectcpy(env->cube[1], ibuf,
- 0, 0, dx, 0, dx, dx);
- IMB_rectcpy(env->cube[2], ibuf,
- 0, 0, 2*dx, 0, dx, dx);
- IMB_rectcpy(env->cube[3], ibuf,
- 0, 0, 0, dx, dx, dx);
- IMB_rectcpy(env->cube[4], ibuf,
- 0, 0, dx, dx, dx, dx);
- IMB_rectcpy(env->cube[5], ibuf,
- 0, 0, 2*dx, dx, dx, dx);
-
- env->ok= 2;// ENV_OSA
- }
-}
-
-
-void my_free_envmapdata(EnvMap *env)
-{
- unsigned int part;
-
- for (part=0; part<6; part++) {
- ImBuf *ibuf= env->cube[part];
- if (ibuf) {
- IMB_freeImBuf(ibuf);
- env->cube[part] = NULL;
- }
- }
- env->ok= 0;
-}
-
-
-} // extern C
-
diff --git a/source/gameengine/Ketsji/BL_Texture.h b/source/gameengine/Ketsji/BL_Texture.h
deleted file mode 100644
index cd18ef93822..00000000000
--- a/source/gameengine/Ketsji/BL_Texture.h
+++ /dev/null
@@ -1,82 +0,0 @@
-
-/** \file BL_Texture.h
- * \ingroup ketsji
- */
-
-#ifndef __BL_TEXTURE_H__
-#define __BL_TEXTURE_H__
-
-// #include <vector>
-// #include <map>
-
-#include "MT_Matrix4x4.h"
-#include "KX_Camera.h"
-
-// --
-struct Image;
-struct EnvMap;
-class BL_Material;
-class RAS_Rect;
-class RAS_ICanvas;
-//class RTData;
-
-#include "STR_String.h"
-
-class BL_Texture
-{
-private:
- unsigned int mTexture; // Bound texture unit data
- bool mOk; // ...
- bool mNeedsDeleted; // If generated
- unsigned int mType; // enum TEXTURE_2D | CUBE_MAP
- int mUnit; // Texture unit associated with mTexture
- unsigned int mEnvState; // cache textureEnv
- static unsigned int mDisableState; // speed up disabling calls
-
- void InitNonPow2Tex(unsigned int *p,int x,int y,bool mipmap );
- void InitGLTex(unsigned int *p,int x,int y,bool mipmap );
- void InitGLCompressedTex(struct ImBuf *p, bool mipmap);
-public:
- BL_Texture();
- ~BL_Texture( );
-
- bool Ok();
- int GetUnit() {return mUnit;}
- void SetUnit(int unit) {mUnit = unit;}
-
- unsigned int GetTextureType() const;
- void DeleteTex();
-
- bool InitFromImage(int unit, Image *img, bool mipmap);
- bool InitCubeMap(int unit,EnvMap *cubemap );
-
- bool IsValid();
- void Validate();
-
- static void ActivateFirst();
- static void DisableAllTextures();
- static void ActivateUnit(int unit);
- static int GetMaxUnits();
- static int GetPow2(int x);
- static void SplitEnvMap(EnvMap *map);
-
-
- void ActivateTexture();
- void SetMapping(int mode);
- void DisableUnit();
- void setTexEnv(BL_Material *mat, bool modulate=false);
- unsigned int swapTexture (unsigned int newTex) {
- // swap texture codes
- unsigned int tmp = mTexture;
- mTexture = newTex;
- // return original texture code
- return tmp;
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Texture")
-#endif
-};
-
-#endif /* __BL_TEXTURE_H__ */
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
deleted file mode 100644
index cb7c0180f30..00000000000
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ /dev/null
@@ -1,265 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- KXNetwork
- ../BlenderRoutines
- ../Converter
- ../Expressions
- ../GameLogic
- ../Network
- ../Network/LoopBackNetwork
- ../Physics/common
- ../Rasterizer
- ../Rasterizer/RAS_OpenGLRasterizer
- ../SceneGraph
- ../../blender
- ../../blender/blenfont
- ../../blender/blenkernel
- ../../blender/blenlib
- ../../blender/blenloader
- ../../blender/gpu
- ../../blender/imbuf
- ../../blender/makesdna
- ../../blender/makesrna
- ../../blender/python
- ../../blender/python/generic
- ../../blender/python/mathutils
- ../../../intern/container
- ../../../intern/glew-mx
- ../../../intern/guardedalloc
- ../../../intern/string
-)
-
-set(INC_SYS
- ../../../intern/moto/include
- ../../../extern/recastnavigation/Recast/Include
- ../../../extern/recastnavigation/Detour/Include
- ${PTHREADS_INCLUDE_DIRS}
- ${GLEW_INCLUDE_PATH}
- ${BOOST_INCLUDE_DIR}
-)
-
-set(SRC
- BL_Action.cpp
- BL_ActionManager.cpp
- BL_BlenderShader.cpp
- BL_Material.cpp
- BL_Shader.cpp
- BL_Texture.cpp
- KX_ArmatureSensor.cpp
- KX_BlenderMaterial.cpp
- KX_Camera.cpp
- KX_CameraActuator.cpp
- KX_CameraIpoSGController.cpp
- KX_CharacterWrapper.cpp
- KX_ConstraintActuator.cpp
- KX_ConstraintWrapper.cpp
- KX_Dome.cpp
- KX_EmptyObject.cpp
- KX_FontObject.cpp
- KX_GameActuator.cpp
- KX_GameObject.cpp
- KX_IpoConvert.cpp
- KX_IPO_SGController.cpp
- KX_KetsjiEngine.cpp
- KX_Light.cpp
- KX_LightIpoSGController.cpp
- KX_MaterialIpoController.cpp
- KX_MeshProxy.cpp
- KX_MotionState.cpp
- KX_MouseActuator.cpp
- KX_MouseFocusSensor.cpp
- KX_NavMeshObject.cpp
- KX_NearSensor.cpp
- KX_ObColorIpoSGController.cpp
- KX_ObjectActuator.cpp
- KX_ObstacleSimulation.cpp
- KX_OrientationInterpolator.cpp
- KX_ParentActuator.cpp
- KX_PolyProxy.cpp
- KX_PositionInterpolator.cpp
- KX_PyConstraintBinding.cpp
- KX_PyMath.cpp
- KX_PythonInit.cpp
- KX_PythonInitTypes.cpp
- KX_PythonMain.cpp
- KX_RadarSensor.cpp
- KX_RayCast.cpp
- KX_RayEventManager.cpp
- KX_RaySensor.cpp
- KX_SCA_AddObjectActuator.cpp
- KX_SCA_DynamicActuator.cpp
- KX_SCA_EndObjectActuator.cpp
- KX_SCA_ReplaceMeshActuator.cpp
- KX_SG_BoneParentNodeRelationship.cpp
- KX_SG_NodeRelationships.cpp
- KX_ScalarInterpolator.cpp
- KX_ScalingInterpolator.cpp
- KX_Scene.cpp
- KX_SceneActuator.cpp
- KX_SoundActuator.cpp
- KX_StateActuator.cpp
- KX_SteeringActuator.cpp
- KX_TimeCategoryLogger.cpp
- KX_TimeLogger.cpp
- KX_TouchEventManager.cpp
- KX_TouchSensor.cpp
- KX_TrackToActuator.cpp
- KX_VehicleWrapper.cpp
- KX_VertexProxy.cpp
- KX_VisibilityActuator.cpp
- KX_WorldInfo.cpp
- KX_WorldIpoController.cpp
-
- BL_Action.h
- BL_ActionManager.h
- BL_BlenderShader.h
- BL_Material.h
- BL_Shader.h
- BL_Texture.h
- KX_ArmatureSensor.h
- KX_BlenderMaterial.h
- KX_Camera.h
- KX_CameraActuator.h
- KX_CameraIpoSGController.h
- KX_CharacterWrapper.h
- KX_ClientObjectInfo.h
- KX_ConstraintActuator.h
- KX_ConstraintWrapper.h
- KX_Dome.h
- KX_EmptyObject.h
- KX_FontObject.h
- KX_GameActuator.h
- KX_GameObject.h
- KX_IInterpolator.h
- KX_IpoConvert.h
- KX_IPOTransform.h
- KX_IPO_SGController.h
- KX_IScalarInterpolator.h
- KX_ISceneConverter.h
- KX_ISystem.h
- KX_KetsjiEngine.h
- KX_Light.h
- KX_LightIpoSGController.h
- KX_MaterialIpoController.h
- KX_MeshProxy.h
- KX_MotionState.h
- KX_MouseActuator.h
- KX_MouseFocusSensor.h
- KX_NavMeshObject.h
- KX_NearSensor.h
- KX_ObColorIpoSGController.h
- KX_ObjectActuator.h
- KX_ObstacleSimulation.h
- KX_OrientationInterpolator.h
- KX_ParentActuator.h
- KX_PhysicsEngineEnums.h
- KX_PolyProxy.h
- KX_PositionInterpolator.h
- KX_PyConstraintBinding.h
- KX_PyMath.h
- KX_PythonInit.h
- KX_PythonInitTypes.h
- KX_PythonMain.h
- KX_RadarSensor.h
- KX_RayCast.h
- KX_RayEventManager.h
- KX_RaySensor.h
- KX_SCA_AddObjectActuator.h
- KX_SCA_DynamicActuator.h
- KX_SCA_EndObjectActuator.h
- KX_SCA_ReplaceMeshActuator.h
- KX_SG_BoneParentNodeRelationship.h
- KX_SG_NodeRelationships.h
- KX_ScalarInterpolator.h
- KX_ScalingInterpolator.h
- KX_Scene.h
- KX_SceneActuator.h
- KX_SoundActuator.h
- KX_StateActuator.h
- KX_SteeringActuator.h
- KX_TimeCategoryLogger.h
- KX_TimeLogger.h
- KX_TouchEventManager.h
- KX_TouchSensor.h
- KX_TrackToActuator.h
- KX_VehicleWrapper.h
- KX_VertexProxy.h
- KX_VisibilityActuator.h
- KX_WorldInfo.h
- KX_WorldIpoController.h
-
- # orphan headers (not apart of a library)
- ../Physics/common/PHY_DynamicTypes.h
- ../Physics/common/PHY_ICharacter.h
- ../Physics/common/PHY_IController.h
- ../Physics/common/PHY_IGraphicController.h
- ../Physics/common/PHY_IMotionState.h
- ../Physics/common/PHY_IPhysicsController.h
- ../Physics/common/PHY_IPhysicsEnvironment.h
- ../Physics/common/PHY_IVehicle.h
- ../Physics/common/PHY_Pro.h
-
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-if(WITH_IMAGE_DDS)
- add_definitions(-DWITH_DDS)
-endif()
-
-if(WITH_SDL)
- list(APPEND INC_SYS
- ${SDL_INCLUDE_DIR}
- )
- add_definitions(-DWITH_SDL)
-endif()
-
-if(WITH_CODEC_FFMPEG)
- add_definitions(-DWITH_FFMPEG)
-endif()
-
-if(WITH_AUDASPACE)
- add_definitions(-DWITH_AUDASPACE)
-
- list(APPEND INC_SYS
- ${AUDASPACE_C_INCLUDE_DIRS}
- ${AUDASPACE_PY_INCLUDE_DIRS}
- )
-endif()
-
-if(WITH_BULLET)
- list(APPEND INC
- ../Physics/Bullet
- )
- list(APPEND INC_SYS
- ${BULLET_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_BULLET)
-endif()
-
-blender_add_lib(ge_logic_ketsji "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt
deleted file mode 100644
index cfc6ded4e65..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt
+++ /dev/null
@@ -1,56 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ..
- ../../Expressions
- ../../GameLogic
- ../../Network
- ../../SceneGraph
- ../../../blender/blenlib
- ../../../../intern/container
- ../../../../intern/string
-)
-
-set(INC_SYS
- ../../../../intern/moto/include
-)
-
-set(SRC
- KX_NetworkEventManager.cpp
- KX_NetworkMessageActuator.cpp
- KX_NetworkMessageSensor.cpp
- KX_NetworkObjectActuator.cpp
- KX_NetworkObjectSensor.cpp
-
- KX_NetworkEventManager.h
- KX_NetworkMessageActuator.h
- KX_NetworkMessageSensor.h
- KX_NetworkObjectActuator.h
- KX_NetworkObjectSensor.h
-)
-
-blender_add_lib(ge_logic_network "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
deleted file mode 100644
index 8c6392ee825..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
+++ /dev/null
@@ -1,77 +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 *****
- * Ketsji Logic Extension: Network Event Manager generic implementation
- */
-
-/** \file gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
- * \ingroup ketsjinet
- */
-
-
-// Ketsji specific sensor part
-#include "SCA_ISensor.h"
-
-// Ketsji specific network part
-#include "KX_NetworkEventManager.h"
-
-// Network module specific
-#include "NG_NetworkDeviceInterface.h"
-#include "NG_NetworkMessage.h"
-#include "NG_NetworkObject.h"
-
-KX_NetworkEventManager::KX_NetworkEventManager(class SCA_LogicManager*
-logicmgr, class NG_NetworkDeviceInterface *ndi) :
-SCA_EventManager(logicmgr, NETWORK_EVENTMGR), m_ndi(ndi)
-{
- //printf("KX_NetworkEventManager constructor\n");
-}
-
-KX_NetworkEventManager::~KX_NetworkEventManager()
-{
- //printf("KX_NetworkEventManager destructor\n");
-}
-
-void KX_NetworkEventManager::NextFrame()
-{
-// printf("KX_NetworkEventManager::proceed %.2f - %.2f\n", curtime, deltatime);
- // each frame, the logicmanager will call the network
- // eventmanager to look for network events, and process it's
- // 'network' sensors
- SG_DList::iterator<SCA_ISensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
-// printf("KX_NetworkEventManager::proceed sensor %.2f\n", curtime);
- // process queue
- (*it)->Activate(m_logicmgr);
- }
-
- // now a list of triggerer sensors has been built
-}
-
-void KX_NetworkEventManager::EndFrame()
-{
-}
-
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h
deleted file mode 100644
index 9a13b6d53e2..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h
+++ /dev/null
@@ -1,55 +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_NetworkEventManager.h
- * \ingroup ketsjinet
- * \brief Ketsji Logic Extension: Network Event Manager class
- */
-
-#ifndef __KX_NETWORKEVENTMANAGER_H__
-#define __KX_NETWORKEVENTMANAGER_H__
-
-#include "SCA_EventManager.h"
-
-class KX_NetworkEventManager : public SCA_EventManager
-{
- class NG_NetworkDeviceInterface* m_ndi;
-
-public:
- KX_NetworkEventManager(class SCA_LogicManager* logicmgr,
- class NG_NetworkDeviceInterface *ndi);
- virtual ~KX_NetworkEventManager ();
-
- virtual void NextFrame();
- virtual void EndFrame();
-
- SCA_LogicManager* GetLogicManager() { return m_logicmgr; }
- class NG_NetworkDeviceInterface* GetNetworkDevice() {
- return m_ndi; }
-};
-
-#endif /* __KX_NETWORKEVENTMANAGER_H__ */
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
deleted file mode 100644
index 2741907bfe6..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
+++ /dev/null
@@ -1,139 +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 *****
- * Ketsji Logic Extension: Network Message Actuator generic implementation
- */
-
-/** \file gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
- * \ingroup ketsjinet
- */
-
-
-#include <stddef.h>
-
-#include "NG_NetworkScene.h"
-#include "KX_NetworkMessageActuator.h"
-
-KX_NetworkMessageActuator::KX_NetworkMessageActuator(
- SCA_IObject* gameobj, // the actuator controlling object
- NG_NetworkScene* networkscene, // needed for replication
- const STR_String &toPropName,
- const STR_String &subject,
- int bodyType,
- const STR_String &body) :
- SCA_IActuator(gameobj, KX_ACT_MESSAGE),
- m_networkscene(networkscene),
- m_toPropName(toPropName),
- m_subject(subject),
- m_bPropBody(bodyType),
- m_body(body)
-{
-}
-
-KX_NetworkMessageActuator::~KX_NetworkMessageActuator()
-{
-}
-
-// returns true if the actuators needs to be running over several frames
-bool KX_NetworkMessageActuator::Update()
-{
- //printf("update messageactuator\n");
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent) {
- return false; // do nothing on negative events
- //printf("messageactuator false event\n");
- }
- //printf("messageactuator true event\n");
-
- if (m_bPropBody) // ACT_MESG_PROP in DNA_actuator_types.h
- {
- m_networkscene->SendMessage(
- m_toPropName,
- GetParent()->GetName(),
- m_subject,
- GetParent()->GetPropertyText(m_body));
- } else
- {
- m_networkscene->SendMessage(
- m_toPropName,
- GetParent()->GetName(),
- m_subject,
- m_body);
- }
- return false;
-}
-
-CValue* KX_NetworkMessageActuator::GetReplica()
-{
- KX_NetworkMessageActuator* replica = new KX_NetworkMessageActuator(*this);
- replica->ProcessReplica();
-
- return replica;
-}
-
-#ifdef WITH_PYTHON
-
-/* -------------------------------------------------------------------- */
-/* Python interface --------------------------------------------------- */
-/* -------------------------------------------------------------------- */
-
-/* Integration hooks -------------------------------------------------- */
-PyTypeObject KX_NetworkMessageActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_NetworkMessageActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_NetworkMessageActuator::Methods[] = {
- {NULL,NULL} // Sentinel
-};
-
-PyAttributeDef KX_NetworkMessageActuator::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, KX_NetworkMessageActuator, m_toPropName),
- KX_PYATTRIBUTE_STRING_RW("subject", 0, 100, false, KX_NetworkMessageActuator, m_subject),
- KX_PYATTRIBUTE_BOOL_RW("usePropBody", KX_NetworkMessageActuator, m_bPropBody),
- KX_PYATTRIBUTE_STRING_RW("body", 0, 16384, false, KX_NetworkMessageActuator, m_body),
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
deleted file mode 100644
index 325a7be9bd7..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
+++ /dev/null
@@ -1,72 +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_NetworkMessageActuator.h
- * \ingroup ketsjinet
- * \brief Ketsji Logic Extension: Network Message Actuator class
- */
-
-#ifndef __KX_NETWORKMESSAGEACTUATOR_H__
-#define __KX_NETWORKMESSAGEACTUATOR_H__
-
-#include "STR_String.h"
-#include "SCA_IActuator.h"
-#include "NG_NetworkMessage.h"
-
-class KX_NetworkMessageActuator : public SCA_IActuator
-{
- Py_Header
- bool m_lastEvent;
- class NG_NetworkScene* m_networkscene; // needed for replication
- STR_String m_toPropName;
- STR_String m_subject;
- bool m_bPropBody;
- STR_String m_body;
-public:
- KX_NetworkMessageActuator(
- SCA_IObject* gameobj,
- NG_NetworkScene* networkscene,
- const STR_String &toPropName,
- const STR_String &subject,
- int bodyType,
- const STR_String &body);
- virtual ~KX_NetworkMessageActuator();
-
- virtual bool Update();
- virtual CValue* GetReplica();
- virtual void Replace_NetworkScene(NG_NetworkScene *val)
- {
- m_networkscene= val;
- };
-
- /* ------------------------------------------------------------ */
- /* Python interface ------------------------------------------- */
- /* ------------------------------------------------------------ */
-
-};
-
-#endif /* __KX_NETWORKMESSAGEACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
deleted file mode 100644
index 1fadd9382e0..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
+++ /dev/null
@@ -1,224 +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 *****
- * Ketsji Logic Extension: Network Message Sensor generic implementation
- */
-
-/** \file gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
- * \ingroup ketsjinet
- */
-
-
-#include <stddef.h>
-
-#include "KX_NetworkMessageSensor.h"
-#include "KX_NetworkEventManager.h"
-#include "NG_NetworkMessage.h"
-#include "NG_NetworkScene.h"
-#include "NG_NetworkObject.h"
-#include "SCA_IObject.h"
-#include "EXP_InputParser.h"
-#include "EXP_ListValue.h"
-#include "EXP_StringValue.h"
-
-#ifdef NAN_NET_DEBUG
- #include <iostream>
-#endif
-
-KX_NetworkMessageSensor::KX_NetworkMessageSensor(
- class KX_NetworkEventManager* eventmgr, // our eventmanager
- class NG_NetworkScene *NetworkScene, // our scene
- SCA_IObject* gameobj, // the sensor controlling object
- const STR_String &subject
- ) :
- SCA_ISensor(gameobj,eventmgr),
- m_NetworkScene(NetworkScene),
- m_subject(subject),
- m_frame_message_count (0),
- m_BodyList(NULL),
- m_SubjectList(NULL)
-{
- Init();
-}
-
-void KX_NetworkMessageSensor::Init()
-{
- m_IsUp = false;
-}
-
-KX_NetworkMessageSensor::~KX_NetworkMessageSensor()
-{
-}
-
-CValue* KX_NetworkMessageSensor::GetReplica()
-{
- // This is the standard sensor implementation of GetReplica
- // There may be more network message sensor specific stuff to do here.
- CValue* replica = new KX_NetworkMessageSensor(*this);
-
- if (replica == NULL) return NULL;
- replica->ProcessReplica();
-
- return replica;
-}
-
-// Return true only for flank (UP and DOWN)
-bool KX_NetworkMessageSensor::Evaluate()
-{
- bool result = false;
- bool WasUp = m_IsUp;
-
- m_IsUp = false;
-
- if (m_BodyList) {
- m_BodyList->Release();
- m_BodyList = NULL;
- }
-
- if (m_SubjectList) {
- m_SubjectList->Release();
- m_SubjectList = NULL;
- }
-
- STR_String& toname=GetParent()->GetName();
- STR_String& subject = this->m_subject;
-
- vector<NG_NetworkMessage*> messages =
- m_NetworkScene->FindMessages(toname,"",subject,true);
-
- m_frame_message_count = messages.size();
-
- if (!messages.empty()) {
-#ifdef NAN_NET_DEBUG
- printf("KX_NetworkMessageSensor found one or more messages\n");
-#endif
- m_IsUp = true;
- m_BodyList = new CListValue();
- m_SubjectList = new CListValue();
- }
-
- vector<NG_NetworkMessage*>::iterator mesit;
- for (mesit=messages.begin();mesit!=messages.end();mesit++)
- {
- // save the body
- const STR_String& body = (*mesit)->GetMessageText();
- // save the subject
- const STR_String& messub = (*mesit)->GetSubject();
-#ifdef NAN_NET_DEBUG
- if (body) {
- cout << "body [" << body << "]\n";
- }
-#endif
- m_BodyList->Add(new CStringValue(body,"body"));
- // Store Subject
- m_SubjectList->Add(new CStringValue(messub,"subject"));
-
- // free the message
- (*mesit)->Release();
- }
- messages.clear();
-
- result = (WasUp != m_IsUp);
-
- // Return always true if a message was received otherwise we can loose messages
- if (m_IsUp)
- return true;
- // Is it useful to return also true when the first frame without a message??
- // This will cause a fast on/off cycle that seems useless!
- return result;
-}
-
-// return true for being up (no flank needed)
-bool KX_NetworkMessageSensor::IsPositiveTrigger()
-{
-// printf("KX_NetworkMessageSensor IsPositiveTrigger\n");
- //attempt to fix [ #3809 ] IPO Actuator does not work with some Sensors
- //a better solution is to properly introduce separate Edge and Level triggering concept
-
- return m_IsUp;
-}
-
-#ifdef WITH_PYTHON
-
-/* --------------------------------------------------------------------- */
-/* Python interface ---------------------------------------------------- */
-/* --------------------------------------------------------------------- */
-
-/* Integration hooks --------------------------------------------------- */
-PyTypeObject KX_NetworkMessageSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_NetworkMessageSensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_NetworkMessageSensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_NetworkMessageSensor::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW("subject", 0, 100, false, KX_NetworkMessageSensor, m_subject),
- KX_PYATTRIBUTE_INT_RO("frameMessageCount", KX_NetworkMessageSensor, m_frame_message_count),
- KX_PYATTRIBUTE_RO_FUNCTION("bodies", KX_NetworkMessageSensor, pyattr_get_bodies),
- KX_PYATTRIBUTE_RO_FUNCTION("subjects", KX_NetworkMessageSensor, pyattr_get_subjects),
- { NULL } //Sentinel
-};
-
-PyObject *KX_NetworkMessageSensor::pyattr_get_bodies(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_NetworkMessageSensor *self = static_cast<KX_NetworkMessageSensor*>(self_v);
- if (self->m_BodyList) {
- return self->m_BodyList->GetProxy();
- } else {
- return (new CListValue())->NewProxy(true);
- }
-}
-
-PyObject *KX_NetworkMessageSensor::pyattr_get_subjects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_NetworkMessageSensor *self = static_cast<KX_NetworkMessageSensor*>(self_v);
- if (self->m_SubjectList) {
- return self->m_SubjectList->GetProxy();
- } else {
- return (new CListValue())->NewProxy(true);
- }
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
deleted file mode 100644
index a1f0692b7b3..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
+++ /dev/null
@@ -1,90 +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_NetworkMessageSensor.h
- * \ingroup ketsjinet
- * \brief Ketsji Logic Extension: Network Message Sensor class
- */
-#ifndef __KX_NETWORKMESSAGESENSOR_H__
-#define __KX_NETWORKMESSAGESENSOR_H__
-
-#include "SCA_ISensor.h"
-
-class KX_NetworkEventManager;
-class NG_NetworkScene;
-
-class KX_NetworkMessageSensor : public SCA_ISensor
-{
- // note: Py_Header MUST BE the first listed here
- Py_Header
- NG_NetworkScene *m_NetworkScene;
-
- // The subject we filter on.
- STR_String m_subject;
-
- // The number of messages caught since the last frame.
- int m_frame_message_count;
-
- bool m_IsUp;
-
- class CListValue* m_BodyList;
- class CListValue* m_SubjectList;
-public:
- KX_NetworkMessageSensor(
- KX_NetworkEventManager* eventmgr, // our eventmanager
- NG_NetworkScene *NetworkScene, // our scene
- SCA_IObject* gameobj, // the sensor controlling object
- const STR_String &subject
- );
- virtual ~KX_NetworkMessageSensor();
-
- virtual CValue* GetReplica();
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
- virtual void Init();
- void EndFrame();
-
- virtual void Replace_NetworkScene(NG_NetworkScene *val)
- {
- m_NetworkScene= val;
- };
-
-#ifdef WITH_PYTHON
-
- /* ------------------------------------------------------------- */
- /* Python interface -------------------------------------------- */
- /* ------------------------------------------------------------- */
-
- /* attributes */
- static PyObject* pyattr_get_bodies(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_subjects(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
-#endif /* WITH_PYTHON */
-
-};
-
-#endif /* __KX_NETWORKMESSAGESENSOR_H__ */
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp
deleted file mode 100644
index b8032f8e037..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp
+++ /dev/null
@@ -1,31 +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/KXNetwork/KX_NetworkObjectActuator.cpp
- * \ingroup ketsjinet
- */
-
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h
deleted file mode 100644
index 36e0e6c39ec..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h
+++ /dev/null
@@ -1,32 +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/KXNetwork/KX_NetworkObjectActuator.h
- * \ingroup ketsjinet
- */
-
-
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp
deleted file mode 100644
index bc6da2e4143..00000000000
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp
+++ /dev/null
@@ -1,32 +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/KXNetwork/KX_NetworkObjectSensor.cpp
- * \ingroup ketsjinet
- */
-
-
diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.cpp b/source/gameengine/Ketsji/KX_ArmatureSensor.cpp
deleted file mode 100644
index c111a4de0eb..00000000000
--- a/source/gameengine/Ketsji/KX_ArmatureSensor.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Armature sensor
- *
- *
- * ***** 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_ArmatureSensor.cpp
- * \ingroup ketsji
- */
-
-
-#include "DNA_action_types.h"
-#include "DNA_constraint_types.h"
-#include "BKE_constraint.h"
-#include "DNA_sensor_types.h"
-
-#include "BL_ArmatureObject.h"
-#include "KX_ArmatureSensor.h"
-#include "SCA_EventManager.h"
-#include "SCA_LogicManager.h"
-
-KX_ArmatureSensor::KX_ArmatureSensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- const char *posechannel,
- const char *constraintname,
- int type,
- float value)
- : SCA_ISensor(gameobj,eventmgr),
- m_constraint(NULL),
- m_posechannel(posechannel),
- m_constraintname(constraintname),
- m_type(type),
- m_value(value)
-{
- FindConstraint();
-}
-
-void KX_ArmatureSensor::Init()
-{
- m_lastresult = m_invert?true:false;
- m_result = false;
- m_reset = true;
-}
-
-void KX_ArmatureSensor::FindConstraint()
-{
- m_constraint = NULL;
-
- if (m_gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) {
- BL_ArmatureObject* armobj = (BL_ArmatureObject*)m_gameobj;
- // get the persistent pose structure
- bPose* pose = armobj->GetOrigPose();
- bPoseChannel* pchan;
- bConstraint* pcon;
- // and locate the constraint
- for (pchan = (bPoseChannel*)pose->chanbase.first; pchan; pchan=(bPoseChannel*)pchan->next) {
- if (!strcmp(pchan->name, m_posechannel)) {
- // now locate the constraint
- for (pcon = (bConstraint *)pchan->constraints.first; pcon; pcon = (bConstraint *)pcon->next) {
- if (!strcmp(pcon->name, m_constraintname)) {
- if (pcon->flag & CONSTRAINT_DISABLE)
- /* this constraint is not valid, can't use it */
- break;
- m_constraint = pcon;
- break;
- }
- }
- break;
- }
- }
- }
-}
-
-
-CValue* KX_ArmatureSensor::GetReplica()
-{
- KX_ArmatureSensor* replica = new KX_ArmatureSensor(*this);
- // m_range_expr must be recalculated on replica!
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_ArmatureSensor::ReParent(SCA_IObject* parent)
-{
- SCA_ISensor::ReParent(parent);
- // must remap the constraint
- FindConstraint();
-}
-
-bool KX_ArmatureSensor::IsPositiveTrigger()
-{
- return (m_invert) ? !m_result : m_result;
-}
-
-
-KX_ArmatureSensor::~KX_ArmatureSensor()
-{
-}
-
-bool KX_ArmatureSensor::Evaluate()
-{
- bool reset = m_reset && m_level;
-
- m_reset = false;
- if (!m_constraint)
- return false;
- switch (m_type) {
- case SENS_ARM_STATE_CHANGED:
- m_result = !(m_constraint->flag & CONSTRAINT_OFF);
- break;
- case SENS_ARM_LIN_ERROR_BELOW:
- m_result = (m_constraint->lin_error < m_value);
- break;
- case SENS_ARM_LIN_ERROR_ABOVE:
- m_result = (m_constraint->lin_error > m_value);
- break;
- case SENS_ARM_ROT_ERROR_BELOW:
- m_result = (m_constraint->rot_error < m_value);
- break;
- case SENS_ARM_ROT_ERROR_ABOVE:
- m_result = (m_constraint->rot_error > m_value);
- break;
- }
- if (m_lastresult!=m_result)
- {
- m_lastresult = m_result;
- return true;
- }
- return (reset) ? true : false;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_ArmatureSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_ArmatureSensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_ArmatureSensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_ArmatureSensor::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("constraint", KX_ArmatureSensor, pyattr_get_constraint),
- KX_PYATTRIBUTE_FLOAT_RW("value",-FLT_MAX,FLT_MAX,KX_ArmatureSensor,m_value),
- KX_PYATTRIBUTE_INT_RW("type",0,SENS_ARM_MAXTYPE,false,KX_ArmatureSensor,m_type),
- { NULL } //Sentinel
-};
-
-PyObject *KX_ArmatureSensor::pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_ArmatureSensor* sensor = static_cast<KX_ArmatureSensor*>(self);
- if (sensor->m_gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) {
- BL_ArmatureObject* armobj = (BL_ArmatureObject*)sensor->m_gameobj;
- BL_ArmatureConstraint* constraint = armobj->GetConstraint(sensor->m_posechannel, sensor->m_constraintname);
- if (constraint)
- return constraint->GetProxy();
- }
- Py_RETURN_NONE;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_ArmatureSensor.h b/source/gameengine/Ketsji/KX_ArmatureSensor.h
deleted file mode 100644
index b3ea905d198..00000000000
--- a/source/gameengine/Ketsji/KX_ArmatureSensor.h
+++ /dev/null
@@ -1,90 +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_ArmatureSensor.h
- * \ingroup ketsji
- * \brief Property sensor
- */
-
-#ifndef __KX_ARMATURESENSOR_H__
-#define __KX_ARMATURESENSOR_H__
-
-struct bConstraint;
-
-#include "SCA_ISensor.h"
-#include "DNA_sensor_types.h"
-
-class KX_ArmatureSensor : public SCA_ISensor
-{
- Py_Header
- //class CExpression* m_rightexpr;
-
-protected:
-
-public:
- KX_ArmatureSensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- const char *posechannel,
- const char *constraintname,
- int type,
- float value);
-
- /**
- * For property sensor, it is used to release the pre-calculated expression
- * so that self references are removed before the sensor itself is released
- */
- virtual ~KX_ArmatureSensor();
- virtual CValue* GetReplica();
- virtual void ReParent(SCA_IObject* parent);
- virtual void Init();
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
-
- // identify the constraint that this actuator controls
- void FindConstraint();
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
- static PyObject *pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
-
-#endif /* WITH_PYTHON */
-
-private:
- struct bConstraint* m_constraint;
- STR_String m_posechannel;
- STR_String m_constraintname;
- int m_type;
- float m_value;
- bool m_result;
- bool m_lastresult;
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
deleted file mode 100644
index 98d27ef3685..00000000000
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
+++ /dev/null
@@ -1,1334 +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_BlenderMaterial.cpp
- * \ingroup ketsji
- */
-
-#include "GPU_glew.h"
-
-#include "KX_BlenderMaterial.h"
-#include "BL_Material.h"
-#include "KX_Scene.h"
-#include "KX_Light.h"
-#include "KX_GameObject.h"
-#include "KX_MeshProxy.h"
-#include "KX_PyMath.h"
-
-#include "MT_Vector3.h"
-#include "MT_Vector4.h"
-#include "MT_Matrix4x4.h"
-
-#include "RAS_BucketManager.h"
-#include "RAS_MeshObject.h"
-#include "RAS_IRasterizer.h"
-
-#include "GPU_draw.h"
-
-#include "STR_HashedString.h"
-
-// ------------------------------------
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_image_types.h"
-#include "DNA_meshdata_types.h"
-#include "BKE_mesh.h"
-// ------------------------------------
-#include "BLI_utildefines.h"
-#include "BLI_math.h"
-
-#define spit(x) std::cout << x << std::endl;
-
-BL_Shader *KX_BlenderMaterial::mLastShader = NULL;
-BL_BlenderShader *KX_BlenderMaterial::mLastBlenderShader = NULL;
-
-//static PyObject *gTextureDict = 0;
-
-KX_BlenderMaterial::KX_BlenderMaterial()
-: PyObjectPlus(),
- RAS_IPolyMaterial(),
- mMaterial(NULL),
- mShader(0),
- mBlenderShader(0),
- mScene(NULL),
- mUserDefBlend(0),
- mModified(0),
- mConstructed(false),
- mPass(0)
-{
-}
-
-void KX_BlenderMaterial::Initialize(
- KX_Scene *scene,
- BL_Material *data,
- GameSettings *game,
- int lightlayer)
-{
- RAS_IPolyMaterial::Initialize(
- data->texname[0],
- data->matname,
- data->materialindex,
- data->tile,
- data->tilexrep[0],
- data->tileyrep[0],
- data->alphablend,
- ((data->ras_mode &ALPHA)!=0),
- ((data->ras_mode &ZSORT)!=0),
- ((data->ras_mode &USE_LIGHT)!=0),
- ((data->ras_mode &TEX)),
- game
- );
- Material *ma = data->material;
-
- // Save material data to restore on exit
- mSavedData.r = ma->r;
- mSavedData.g = ma->g;
- mSavedData.b = ma->b;
- mSavedData.a = ma->alpha;
- mSavedData.specr = ma->specr;
- mSavedData.specg = ma->specg;
- mSavedData.specb = ma->specb;
- mSavedData.spec = ma->spec;
- mSavedData.ref = ma->ref;
- mSavedData.hardness = ma->har;
- mSavedData.emit = ma->emit;
-
- mMaterial = data;
- mShader = 0;
- mBlenderShader = 0;
- mScene = scene;
- mUserDefBlend = 0;
- mModified = 0;
- mConstructed = false;
- mPass = 0;
- mLightLayer = lightlayer;
- // --------------------------------
- // RAS_IPolyMaterial variables...
- m_flag |= RAS_BLENDERMAT;
- m_flag |= (mMaterial->IdMode>=ONETEX)? RAS_MULTITEX: 0;
- m_flag |= ((mMaterial->ras_mode & USE_LIGHT)!=0)? RAS_MULTILIGHT: 0;
- m_flag |= (mMaterial->glslmat)? RAS_BLENDERGLSL: 0;
- m_flag |= ((mMaterial->ras_mode & CAST_SHADOW)!=0)? RAS_CASTSHADOW: 0;
- m_flag |= ((mMaterial->ras_mode & ONLY_SHADOW)!=0)? RAS_ONLYSHADOW: 0;
-
- // test the sum of the various modes for equality
- // so we can ether accept or reject this material
- // as being equal, this is rather important to
- // prevent material bleeding
- for (int i=0; i<BL_Texture::GetMaxUnits(); i++) {
- m_multimode += (mMaterial->flag[i] + mMaterial->blend_mode[i]);
- }
- m_multimode += mMaterial->IdMode+ (mMaterial->ras_mode & ~(USE_LIGHT));
-}
-
-KX_BlenderMaterial::~KX_BlenderMaterial()
-{
- Material *ma = mMaterial->material;
- // Restore Blender material data
- ma->r = mSavedData.r;
- ma->g = mSavedData.g;
- ma->b = mSavedData.b;
- ma->alpha = mSavedData.a;
- ma->specr = mSavedData.specr;
- ma->specg = mSavedData.specg;
- ma->specb = mSavedData.specb;
- ma->spec = mSavedData.spec;
- ma->ref = mSavedData.ref;
- ma->har = mSavedData.hardness;
- ma->emit = mSavedData.emit;
-
- // cleanup work
- if (mConstructed)
- // clean only if material was actually used
- OnExit();
-}
-
-unsigned int* KX_BlenderMaterial::GetMCol() const
-{
- // fonts on polys
- return mMaterial->rgb;
-}
-
-void KX_BlenderMaterial::GetMaterialRGBAColor(unsigned char *rgba) const
-{
- if (mMaterial) {
- *rgba++ = (unsigned char)(mMaterial->matcolor[0] * 255.0f);
- *rgba++ = (unsigned char)(mMaterial->matcolor[1] * 255.0f);
- *rgba++ = (unsigned char)(mMaterial->matcolor[2] * 255.0f);
- *rgba++ = (unsigned char)(mMaterial->matcolor[3] * 255.0f);
- } else
- RAS_IPolyMaterial::GetMaterialRGBAColor(rgba);
-}
-
-Material *KX_BlenderMaterial::GetBlenderMaterial() const
-{
- return mMaterial->material;
-}
-
-Image *KX_BlenderMaterial::GetBlenderImage() const
-{
- return mMaterial->material ? mMaterial->material->edit_image : NULL;
-}
-
-Scene* KX_BlenderMaterial::GetBlenderScene() const
-{
- return mScene->GetBlenderScene();
-}
-
-void KX_BlenderMaterial::ReleaseMaterial()
-{
- if (mBlenderShader)
- mBlenderShader->ReloadMaterial();
-}
-
-void KX_BlenderMaterial::InitTextures()
-{
- // for each unique material...
- int i;
- for (i=0; i<BL_Texture::GetMaxUnits(); i++) {
- if ( mMaterial->mapping[i].mapping & USEENV ) {
- if (!GLEW_ARB_texture_cube_map) {
- spit("CubeMap textures not supported");
- continue;
- }
- if (!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) )
- spit("unable to initialize image("<<i<<") in "<<
- mMaterial->matname<< ", image will not be available");
- }
- /* If we're using glsl materials, the textures are handled by bf_gpu, so don't load them twice!
- * However, if we're using a custom shader, then we still need to load the textures ourselves. */
- else if (!mMaterial->glslmat || mShader) {
- if ( mMaterial->img[i] ) {
- if ( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 ))
- spit("unable to initialize image("<<i<<") in "<<
- mMaterial->matname<< ", image will not be available");
- }
- }
- }
-}
-
-void KX_BlenderMaterial::OnConstruction()
-{
- if (mConstructed)
- // when material are reused between objects
- return;
-
- if (mMaterial->glslmat)
- SetBlenderGLSLShader();
-
- InitTextures();
-
- mBlendFunc[0] =0;
- mBlendFunc[1] =0;
- mConstructed = true;
-}
-
-void KX_BlenderMaterial::EndFrame()
-{
- if (mLastBlenderShader) {
- mLastBlenderShader->SetProg(false);
- mLastBlenderShader = NULL;
- }
-
- if (mLastShader) {
- mLastShader->SetProg(false);
- mLastShader = NULL;
- }
-}
-
-void KX_BlenderMaterial::OnExit()
-{
- if ( mShader ) {
- //note, the shader here is allocated, per unique material
- //and this function is called per face
- if (mShader == mLastShader) {
- mShader->SetProg(false);
- mLastShader = NULL;
- }
-
- delete mShader;
- mShader = 0;
- }
-
- if ( mBlenderShader ) {
- if (mBlenderShader == mLastBlenderShader) {
- mBlenderShader->SetProg(false);
- mLastBlenderShader = NULL;
- }
-
- delete mBlenderShader;
- mBlenderShader = 0;
- }
-
- BL_Texture::ActivateFirst();
- for (int i=0; i<BL_Texture::GetMaxUnits(); i++) {
- if (!mTextures[i].Ok()) continue;
- BL_Texture::ActivateUnit(i);
- mTextures[i].DeleteTex();
- mTextures[i].DisableUnit();
- }
-}
-
-
-void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras)
-{
- MT_assert(GLEW_ARB_shader_objects && mShader);
-
- int i;
- if ( !enable || !mShader->Ok() ) {
- // frame cleanup.
- if (mShader == mLastShader) {
- mShader->SetProg(false);
- mLastShader = NULL;
- }
-
- ras->SetAlphaBlend(GPU_BLEND_SOLID);
- BL_Texture::DisableAllTextures();
- return;
- }
-
- BL_Texture::DisableAllTextures();
- mShader->SetProg(true);
- mLastShader = mShader;
-
- BL_Texture::ActivateFirst();
-
- mShader->ApplyShader();
-
- // for each enabled unit
- for (i=0; i<BL_Texture::GetMaxUnits(); i++) {
- if (!mTextures[i].Ok()) continue;
- mTextures[i].ActivateTexture();
- mTextures[0].SetMapping(mMaterial->mapping[i].mapping);
- }
-
- if (!mUserDefBlend) {
- ras->SetAlphaBlend(mMaterial->alphablend);
- }
- else {
- ras->SetAlphaBlend(GPU_BLEND_SOLID);
- ras->SetAlphaBlend(-1); // indicates custom mode
-
- // tested to be valid enums
- glEnable(GL_BLEND);
- glBlendFunc(mBlendFunc[0], mBlendFunc[1]);
- }
-}
-
-void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras)
-{
- if ( !enable || !mBlenderShader->Ok() ) {
- ras->SetAlphaBlend(GPU_BLEND_SOLID);
-
- // frame cleanup.
- if (mLastBlenderShader) {
- mLastBlenderShader->SetProg(false);
- mLastBlenderShader= NULL;
- }
- else
- BL_Texture::DisableAllTextures();
-
- return;
- }
-
- if (!mBlenderShader->Equals(mLastBlenderShader)) {
- ras->SetAlphaBlend(mMaterial->alphablend);
-
- if (mLastBlenderShader)
- mLastBlenderShader->SetProg(false);
- else
- BL_Texture::DisableAllTextures();
-
- mBlenderShader->SetProg(true, ras->GetTime(), ras);
- mLastBlenderShader= mBlenderShader;
- }
-}
-
-void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras)
-{
- BL_Texture::DisableAllTextures();
-
- if ( !enable ) {
- ras->SetAlphaBlend(GPU_BLEND_SOLID);
- return;
- }
-
- BL_Texture::ActivateFirst();
-
- if ( mMaterial->IdMode == DEFAULT_BLENDER ) {
- ras->SetAlphaBlend(mMaterial->alphablend);
- return;
- }
-
- if ( mMaterial->IdMode == TEXFACE ) {
- // no material connected to the object
- if ( mTextures[0].Ok() ) {
- mTextures[0].ActivateTexture();
- mTextures[0].setTexEnv(0, true);
- mTextures[0].SetMapping(mMaterial->mapping[0].mapping);
- ras->SetAlphaBlend(mMaterial->alphablend);
- }
- return;
- }
-
- int mode = 0,i=0;
- for (i=0; i<BL_Texture::GetMaxUnits(); i++) {
- if ( !mTextures[i].Ok() ) continue;
-
- mTextures[i].ActivateTexture();
- mTextures[i].setTexEnv(mMaterial);
- mode = mMaterial->mapping[i].mapping;
-
- if (mode &USEOBJ)
- setObjectMatrixData(i, ras);
- else
- mTextures[i].SetMapping(mode);
-
- if (!(mode &USEOBJ))
- setTexMatrixData( i );
- }
-
- if (!mUserDefBlend) {
- ras->SetAlphaBlend(mMaterial->alphablend);
- }
- else {
- ras->SetAlphaBlend(GPU_BLEND_SOLID);
- ras->SetAlphaBlend(-1); // indicates custom mode
-
- glEnable(GL_BLEND);
- glBlendFunc(mBlendFunc[0], mBlendFunc[1]);
- }
-}
-
-void
-KX_BlenderMaterial::ActivatShaders(
- RAS_IRasterizer* rasty,
- TCachingInfo& cachingInfo)const
-{
- KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this);
-
- // reset...
- if (tmp->mMaterial->IsShared())
- cachingInfo =0;
-
- if (mLastBlenderShader) {
- mLastBlenderShader->SetProg(false);
- mLastBlenderShader= NULL;
- }
-
- if (GetCachingInfo() != cachingInfo) {
-
- if (!cachingInfo)
- tmp->setShaderData(false, rasty);
-
- cachingInfo = GetCachingInfo();
-
- if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
- tmp->setShaderData(true, rasty);
- else if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && mMaterial->alphablend != GEMAT_SOLID && !rasty->GetUsingOverrideShader())
- tmp->setShaderData(true, rasty);
- else
- tmp->setShaderData(false, rasty);
-
- if (mMaterial->ras_mode &TWOSIDED)
- rasty->SetCullFace(false);
- else
- rasty->SetCullFace(true);
-
- if ((mMaterial->ras_mode &WIRE) ||
- (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME))
- {
- if (mMaterial->ras_mode &WIRE)
- rasty->SetCullFace(false);
- rasty->SetLines(true);
- }
- else
- rasty->SetLines(false);
- ActivatGLMaterials(rasty);
- ActivateTexGen(rasty);
- }
-
- //ActivatGLMaterials(rasty);
- //ActivateTexGen(rasty);
-}
-
-void
-KX_BlenderMaterial::ActivateBlenderShaders(
- RAS_IRasterizer* rasty,
- TCachingInfo& cachingInfo)const
-{
- KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this);
-
- if (mLastShader) {
- mLastShader->SetProg(false);
- mLastShader= NULL;
- }
-
- if (GetCachingInfo() != cachingInfo) {
- if (!cachingInfo)
- tmp->setBlenderShaderData(false, rasty);
-
- cachingInfo = GetCachingInfo();
-
- if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
- tmp->setBlenderShaderData(true, rasty);
- else if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && mMaterial->alphablend != GEMAT_SOLID && !rasty->GetUsingOverrideShader())
- tmp->setBlenderShaderData(true, rasty);
- else
- tmp->setBlenderShaderData(false, rasty);
-
- if (mMaterial->ras_mode &TWOSIDED)
- rasty->SetCullFace(false);
- else
- rasty->SetCullFace(true);
-
- if ((mMaterial->ras_mode &WIRE) ||
- (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME))
- {
- if (mMaterial->ras_mode &WIRE)
- rasty->SetCullFace(false);
- rasty->SetLines(true);
- }
- else
- rasty->SetLines(false);
-
- ActivatGLMaterials(rasty);
- mBlenderShader->SetAttribs(rasty, mMaterial);
- }
-}
-
-void
-KX_BlenderMaterial::ActivateMat(
- RAS_IRasterizer* rasty,
- TCachingInfo& cachingInfo
- )const
-{
- KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this);
-
- if (mLastShader) {
- mLastShader->SetProg(false);
- mLastShader= NULL;
- }
-
- if (mLastBlenderShader) {
- mLastBlenderShader->SetProg(false);
- mLastBlenderShader= NULL;
- }
-
- if (GetCachingInfo() != cachingInfo) {
- if (!cachingInfo)
- tmp->setTexData( false,rasty );
-
- cachingInfo = GetCachingInfo();
-
- if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
- tmp->setTexData( true,rasty );
- else if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && mMaterial->alphablend != GEMAT_SOLID && !rasty->GetUsingOverrideShader())
- tmp->setTexData(true, rasty);
- else
- tmp->setTexData( false,rasty);
-
- if (mMaterial->ras_mode &TWOSIDED)
- rasty->SetCullFace(false);
- else
- rasty->SetCullFace(true);
-
- if ((mMaterial->ras_mode &WIRE) ||
- (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME))
- {
- if (mMaterial->ras_mode &WIRE)
- rasty->SetCullFace(false);
- rasty->SetLines(true);
- }
- else
- rasty->SetLines(false);
- ActivatGLMaterials(rasty);
- ActivateTexGen(rasty);
- }
-
- //ActivatGLMaterials(rasty);
- //ActivateTexGen(rasty);
-}
-
-bool
-KX_BlenderMaterial::Activate(
- RAS_IRasterizer* rasty,
- TCachingInfo& cachingInfo
- )const
-{
- if (GLEW_ARB_shader_objects && (mShader && mShader->Ok())) {
- if ((mPass++) < mShader->getNumPass() ) {
- ActivatShaders(rasty, cachingInfo);
- return true;
- }
- else {
- if (mShader == mLastShader) {
- mShader->SetProg(false);
- mLastShader = NULL;
- }
- mPass = 0;
- return false;
- }
- }
- else if ( GLEW_ARB_shader_objects && (mBlenderShader && mBlenderShader->Ok() ) ) {
- if (mPass++ == 0) {
- ActivateBlenderShaders(rasty, cachingInfo);
- return true;
- }
- else {
- mPass = 0;
- return false;
- }
- }
- else {
- if (mPass++ == 0) {
- ActivateMat(rasty, cachingInfo);
- return true;
- }
- else {
- mPass = 0;
- return false;
- }
- }
-}
-
-bool KX_BlenderMaterial::UsesLighting(RAS_IRasterizer *rasty) const
-{
- if (!RAS_IPolyMaterial::UsesLighting(rasty))
- return false;
-
- if (mShader && mShader->Ok())
- return true;
- else if (mBlenderShader && mBlenderShader->Ok())
- return false;
- else
- return true;
-}
-
-void KX_BlenderMaterial::ActivateMeshSlot(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty) const
-{
- if (mShader && GLEW_ARB_shader_objects) {
- mShader->Update(ms, rasty);
- }
- else if (mBlenderShader && GLEW_ARB_shader_objects) {
- int alphablend;
-
- mBlenderShader->Update(ms, rasty);
-
- /* we do blend modes here, because they can change per object
- * with the same material due to obcolor/obalpha */
- alphablend = mBlenderShader->GetAlphaBlend();
- if (ELEM(alphablend, GEMAT_SOLID, GEMAT_ALPHA, GEMAT_ALPHA_SORT) && mMaterial->alphablend != GEMAT_SOLID)
- alphablend = mMaterial->alphablend;
-
- rasty->SetAlphaBlend(alphablend);
- }
-}
-
-void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const
-{
- if (mShader || !mBlenderShader) {
- rasty->SetSpecularity(
- mMaterial->speccolor[0]*mMaterial->spec_f,
- mMaterial->speccolor[1]*mMaterial->spec_f,
- mMaterial->speccolor[2]*mMaterial->spec_f,
- mMaterial->spec_f
- );
-
- rasty->SetShinyness( mMaterial->hard );
-
- rasty->SetDiffuse(
- mMaterial->matcolor[0]*mMaterial->ref+mMaterial->emit,
- mMaterial->matcolor[1]*mMaterial->ref+mMaterial->emit,
- mMaterial->matcolor[2]*mMaterial->ref+mMaterial->emit,
- 1.0f);
-
- rasty->SetEmissive(
- mMaterial->matcolor[0]*mMaterial->emit,
- mMaterial->matcolor[1]*mMaterial->emit,
- mMaterial->matcolor[2]*mMaterial->emit,
- 1.0f );
-
- rasty->SetAmbient(mMaterial->amb);
- }
-
- if (mMaterial->material)
- rasty->SetPolygonOffset(-mMaterial->material->zoffs, 0.0f);
-}
-
-
-void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const
-{
- if (ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED ||
- (ras->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && mMaterial->alphablend != GEMAT_SOLID && !ras->GetUsingOverrideShader())) {
- ras->SetAttribNum(0);
- if (mShader && GLEW_ARB_shader_objects) {
- if (mShader->GetAttribute() == BL_Shader::SHD_TANGENT) {
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, 0);
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, 1);
- ras->SetAttribNum(2);
- }
- }
-
- ras->SetTexCoordNum(mMaterial->num_enabled);
-
- for (int i=0; i<BL_Texture::GetMaxUnits(); i++) {
- int mode = mMaterial->mapping[i].mapping;
-
- if ( mode &(USEREFL|USEOBJ))
- ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_GEN, i);
- else if (mode &USEORCO)
- ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_ORCO, i);
- else if (mode &USENORM)
- ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_NORM, i);
- else if (mode &USEUV)
- ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV, i);
- else if (mode &USETANG)
- ras->SetTexCoord(RAS_IRasterizer::RAS_TEXTANGENT, i);
- else
- ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_DISABLE, i);
- }
- }
-}
-
-void KX_BlenderMaterial::setTexMatrixData(int i)
-{
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
-
- if ( GLEW_ARB_texture_cube_map &&
- mTextures[i].GetTextureType() == GL_TEXTURE_CUBE_MAP_ARB &&
- mMaterial->mapping[i].mapping & USEREFL) {
- glScalef(
- mMaterial->mapping[i].scale[0],
- -mMaterial->mapping[i].scale[1],
- -mMaterial->mapping[i].scale[2]
- );
- }
- else
- {
- glScalef(
- mMaterial->mapping[i].scale[0],
- mMaterial->mapping[i].scale[1],
- mMaterial->mapping[i].scale[2]
- );
- }
- glTranslatef(
- mMaterial->mapping[i].offsets[0],
- mMaterial->mapping[i].offsets[1],
- mMaterial->mapping[i].offsets[2]
- );
-
- glMatrixMode(GL_MODELVIEW);
-
-}
-
-static void GetProjPlane(BL_Material *mat, int index,int num, float*param)
-{
- param[0]=param[1]=param[2]=param[3]=0.f;
- if ( mat->mapping[index].projplane[num] == PROJX )
- param[0] = 1.f;
- else if ( mat->mapping[index].projplane[num] == PROJY )
- param[1] = 1.f;
- else if ( mat->mapping[index].projplane[num] == PROJZ)
- param[2] = 1.f;
-}
-
-void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras)
-{
- KX_GameObject *obj =
- (KX_GameObject*)
- mScene->GetObjectList()->FindValue(mMaterial->mapping[i].objconame);
-
- if (!obj) return;
-
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
- glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
-
- GLenum plane = GL_EYE_PLANE;
-
- // figure plane gen
- float proj[4] = {0.f,0.f,0.f,0.f};
- GetProjPlane(mMaterial, i, 0, proj);
- glTexGenfv(GL_S, plane, proj);
-
- GetProjPlane(mMaterial, i, 1, proj);
- glTexGenfv(GL_T, plane, proj);
-
- GetProjPlane(mMaterial, i, 2, proj);
- glTexGenfv(GL_R, plane, proj);
-
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
- glEnable(GL_TEXTURE_GEN_R);
-
- const MT_Matrix4x4& mvmat = ras->GetViewMatrix();
-
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glScalef(
- mMaterial->mapping[i].scale[0],
- mMaterial->mapping[i].scale[1],
- mMaterial->mapping[i].scale[2]
- );
-
- MT_Point3 pos = obj->NodeGetWorldPosition();
- MT_Vector4 matmul = MT_Vector4(pos[0], pos[1], pos[2], 1.f);
- MT_Vector4 t = mvmat*matmul;
-
- glTranslatef( (float)(-t[0]), (float)(-t[1]), (float)(-t[2]) );
-
- glMatrixMode(GL_MODELVIEW);
-
-}
-
-// ------------------------------------
-void KX_BlenderMaterial::UpdateIPO(
- MT_Vector4 rgba,
- MT_Vector3 specrgb,
- MT_Scalar hard,
- MT_Scalar spec,
- MT_Scalar ref,
- MT_Scalar emit,
- MT_Scalar alpha
- )
-{
- // only works one deep now
-
- // GLSL Multitexture Input
- mMaterial->material->specr = mMaterial->speccolor[0] = (float)(specrgb)[0];
- mMaterial->material->specg = mMaterial->speccolor[1] = (float)(specrgb)[1];
- mMaterial->material->specb = mMaterial->speccolor[2] = (float)(specrgb)[2];
- mMaterial->material->r = mMaterial->matcolor[0] = (float)(rgba[0]);
- mMaterial->material->g = mMaterial->matcolor[1] = (float)(rgba[1]);
- mMaterial->material->b = mMaterial->matcolor[2] = (float)(rgba[2]);
- mMaterial->material->alpha = mMaterial->alpha = (float)(rgba[3]);
- mMaterial->material->har = mMaterial->hard = (float)(hard);
- mMaterial->material->emit = mMaterial->emit = (float)(emit);
- mMaterial->material->spec = mMaterial->spec_f = (float)(spec);
- mMaterial->material->ref = mMaterial->ref = (float)(ref);
-}
-
-void KX_BlenderMaterial::Replace_IScene(SCA_IScene *val)
-{
- mScene= static_cast<KX_Scene *>(val);
-
- OnConstruction();
-}
-
-BL_Material *KX_BlenderMaterial::GetBLMaterial()
-{
- return mMaterial;
-}
-
-void KX_BlenderMaterial::SetBlenderGLSLShader()
-{
- if (!mBlenderShader)
- mBlenderShader = new BL_BlenderShader(mScene, mMaterial->material, mLightLayer);
-
- if (!mBlenderShader->Ok()) {
- delete mBlenderShader;
- mBlenderShader = 0;
- }
-}
-
-#ifdef USE_MATHUTILS
-
-#define MATHUTILS_COL_CB_MATERIAL_SPECULAR_COLOR 1
-#define MATHUTILS_COL_CB_MATERIAL_DIFFUSE_COLOR 2
-
-static unsigned char mathutils_kxblendermaterial_color_cb_index = -1; /* index for our callbacks */
-
-static int mathutils_kxblendermaterial_generic_check(BaseMathObject *bmo)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>BGE_PROXY_REF(bmo->cb_user);
- if (!self)
- return -1;
-
- return 0;
-}
-
-static int mathutils_kxblendermaterial_color_get(BaseMathObject *bmo, int subtype)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial*>BGE_PROXY_REF(bmo->cb_user);
- if (!self)
- return -1;
-
- switch (subtype) {
- case MATHUTILS_COL_CB_MATERIAL_DIFFUSE_COLOR:
- {
- copy_v3_v3(bmo->data, self->GetBLMaterial()->matcolor);
- break;
- }
- case MATHUTILS_COL_CB_MATERIAL_SPECULAR_COLOR:
- {
- copy_v3_v3(bmo->data, self->GetBLMaterial()->speccolor);
- break;
- }
- }
-
- return 0;
-}
-
-static int mathutils_kxblendermaterial_color_set(BaseMathObject *bmo, int subtype)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>BGE_PROXY_REF(bmo->cb_user);
- if (!self)
- return -1;
-
- switch (subtype) {
- case MATHUTILS_COL_CB_MATERIAL_DIFFUSE_COLOR:
- {
- BL_Material *mat = self->GetBLMaterial();
- copy_v3_v3(mat->matcolor, bmo->data);
- mat->material->r = bmo->data[0];
- mat->material->g = bmo->data[1];
- mat->material->b = bmo->data[2];
- break;
- }
- case MATHUTILS_COL_CB_MATERIAL_SPECULAR_COLOR:
- {
- BL_Material *mat = self->GetBLMaterial();
- copy_v3_v3(mat->speccolor, bmo->data);
- mat->material->specr = bmo->data[0];
- mat->material->specg = bmo->data[1];
- mat->material->specb = bmo->data[2];
- break;
- }
- }
-
- return 0;
-}
-
-static int mathutils_kxblendermaterial_color_get_index(BaseMathObject *bmo, int subtype, int index)
-{
- /* lazy, avoid repeteing the case statement */
- if (mathutils_kxblendermaterial_color_get(bmo, subtype) == -1)
- return -1;
- return 0;
-}
-
-static int mathutils_kxblendermaterial_color_set_index(BaseMathObject *bmo, int subtype, int index)
-{
- float f = bmo->data[index];
-
- /* lazy, avoid repeateing the case statement */
- if (mathutils_kxblendermaterial_color_get(bmo, subtype) == -1)
- return -1;
-
- bmo->data[index] = f;
- return mathutils_kxblendermaterial_color_set(bmo, subtype);
-}
-
-static Mathutils_Callback mathutils_kxblendermaterial_color_cb = {
- mathutils_kxblendermaterial_generic_check,
- mathutils_kxblendermaterial_color_get,
- mathutils_kxblendermaterial_color_set,
- mathutils_kxblendermaterial_color_get_index,
- mathutils_kxblendermaterial_color_set_index
-};
-
-
-void KX_BlenderMaterial_Mathutils_Callback_Init()
-{
- // register mathutils callbacks, ok to run more than once.
- mathutils_kxblendermaterial_color_cb_index = Mathutils_RegisterCallback(&mathutils_kxblendermaterial_color_cb);
-}
-
-#endif // USE_MATHUTILS
-
-#ifdef WITH_PYTHON
-
-PyMethodDef KX_BlenderMaterial::Methods[] =
-{
- KX_PYMETHODTABLE( KX_BlenderMaterial, getShader ),
- KX_PYMETHODTABLE( KX_BlenderMaterial, getMaterialIndex ),
- KX_PYMETHODTABLE( KX_BlenderMaterial, getTextureBindcode ),
- KX_PYMETHODTABLE( KX_BlenderMaterial, setBlending ),
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_BlenderMaterial::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("shader", KX_BlenderMaterial, pyattr_get_shader),
- KX_PYATTRIBUTE_RO_FUNCTION("material_index", KX_BlenderMaterial, pyattr_get_materialIndex),
- KX_PYATTRIBUTE_RW_FUNCTION("blending", KX_BlenderMaterial, pyattr_get_blending, pyattr_set_blending),
- KX_PYATTRIBUTE_RW_FUNCTION("alpha", KX_BlenderMaterial, pyattr_get_alpha, pyattr_set_alpha),
- KX_PYATTRIBUTE_RW_FUNCTION("hardness", KX_BlenderMaterial, pyattr_get_hardness, pyattr_set_hardness),
- KX_PYATTRIBUTE_RW_FUNCTION("specularIntensity", KX_BlenderMaterial, pyattr_get_specular_intensity, pyattr_set_specular_intensity),
- KX_PYATTRIBUTE_RW_FUNCTION("specularColor", KX_BlenderMaterial, pyattr_get_specular_color, pyattr_set_specular_color),
- KX_PYATTRIBUTE_RW_FUNCTION("diffuseIntensity", KX_BlenderMaterial, pyattr_get_diffuse_intensity, pyattr_set_diffuse_intensity),
- KX_PYATTRIBUTE_RW_FUNCTION("diffuseColor", KX_BlenderMaterial, pyattr_get_diffuse_color, pyattr_set_diffuse_color),
- KX_PYATTRIBUTE_RW_FUNCTION("emit", KX_BlenderMaterial, pyattr_get_emit, pyattr_set_emit),
-
- { NULL } //Sentinel
-};
-
-PyTypeObject KX_BlenderMaterial::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_BlenderMaterial",
- 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
-};
-
-PyObject *KX_BlenderMaterial::pyattr_get_shader(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_BlenderMaterial* self = static_cast<KX_BlenderMaterial*>(self_v);
- return self->PygetShader(NULL, NULL);
-}
-
-PyObject *KX_BlenderMaterial::pyattr_get_materialIndex(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_BlenderMaterial* self = static_cast<KX_BlenderMaterial*>(self_v);
- return PyLong_FromLong(self->GetMaterialIndex());
-}
-
-PyObject *KX_BlenderMaterial::pyattr_get_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_BlenderMaterial* self = static_cast<KX_BlenderMaterial*>(self_v);
- unsigned int* bfunc = self->getBlendFunc();
- return Py_BuildValue("(ll)", (long int)bfunc[0], (long int)bfunc[1]);
-}
-
-PyObject *KX_BlenderMaterial::pyattr_get_alpha(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- return PyFloat_FromDouble(self->GetBLMaterial()->alpha);
-}
-
-int KX_BlenderMaterial::pyattr_set_alpha(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- float val = PyFloat_AsDouble(value);
-
- if (val == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
-
- CLAMP(val, 0.0f, 1.0f);
-
- BL_Material *mat = self->GetBLMaterial();
- mat->alpha = mat->material->alpha = val;
- return PY_SET_ATTR_SUCCESS;
-}
-PyObject *KX_BlenderMaterial::pyattr_get_hardness(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- return PyLong_FromLong(self->GetBLMaterial()->hard);
-}
-
-int KX_BlenderMaterial::pyattr_set_hardness(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- int val = PyLong_AsLong(value);
-
- if (val == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_AttributeError, "material.%s = int: KX_BlenderMaterial, expected a int", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
-
- CLAMP(val, 1, 511);
-
- BL_Material *mat = self->GetBLMaterial();
- mat->hard = mat->material->har = val;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_BlenderMaterial::pyattr_get_specular_intensity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- return PyFloat_FromDouble(self->GetBLMaterial()->spec_f);
-}
-
-int KX_BlenderMaterial::pyattr_set_specular_intensity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- float val = PyFloat_AsDouble(value);
-
- if (val == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
-
- CLAMP(val, 0.0f, 1.0f);
-
- BL_Material *mat = self->GetBLMaterial();
- mat->spec_f = mat->material->spec = val;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_BlenderMaterial::pyattr_get_specular_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Color_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), mathutils_kxblendermaterial_color_cb_index, MATHUTILS_COL_CB_MATERIAL_SPECULAR_COLOR);
-#else
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- return PyColorFromVector(MT_Vector3(self->GetBLMaterial()->speccolor));
-#endif
-}
-
-int KX_BlenderMaterial::pyattr_set_specular_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- MT_Vector3 color;
- if (!PyVecTo(value, color))
- return PY_SET_ATTR_FAIL;
-
- BL_Material *mat = self->GetBLMaterial();
- color.getValue(mat->speccolor);
- mat->material->specr = color[0];
- mat->material->specg = color[1];
- mat->material->specb = color[2];
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_BlenderMaterial::pyattr_get_diffuse_intensity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- return PyFloat_FromDouble(self->GetBLMaterial()->ref);
-}
-
-int KX_BlenderMaterial::pyattr_set_diffuse_intensity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- float val = PyFloat_AsDouble(value);
-
- if (val == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
-
- CLAMP(val, 0.0f, 1.0f);
-
- BL_Material *mat = self->GetBLMaterial();
- mat->ref = mat->material->ref = val;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_BlenderMaterial::pyattr_get_diffuse_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Color_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), mathutils_kxblendermaterial_color_cb_index, MATHUTILS_COL_CB_MATERIAL_DIFFUSE_COLOR);
-#else
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- return PyColorFromVector(MT_Vector3(self->GetBLMaterial()->matcolor));
-#endif
-}
-
-int KX_BlenderMaterial::pyattr_set_diffuse_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- MT_Vector3 color;
- if (!PyVecTo(value, color))
- return PY_SET_ATTR_FAIL;
-
- BL_Material *mat = self->GetBLMaterial();
- color.getValue(mat->matcolor);
- mat->material->r = color[0];
- mat->material->g = color[1];
- mat->material->b = color[2];
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_BlenderMaterial::pyattr_get_emit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- return PyFloat_FromDouble(self->GetBLMaterial()->emit);
-}
-
-int KX_BlenderMaterial::pyattr_set_emit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_BlenderMaterial *self = static_cast<KX_BlenderMaterial *>(self_v);
- float val = PyFloat_AsDouble(value);
-
- if (val == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_AttributeError, "material.%s = float: KX_BlenderMaterial, expected a float", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
-
- CLAMP(val, 0.0f, 2.0f);
-
- BL_Material *mat = self->GetBLMaterial();
- mat->emit = mat->material->emit = val;
- return PY_SET_ATTR_SUCCESS;
-}
-
-int KX_BlenderMaterial::pyattr_set_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_BlenderMaterial* self = static_cast<KX_BlenderMaterial*>(self_v);
- PyObject *obj = self->PysetBlending(value, NULL);
- if (obj)
- {
- Py_DECREF(obj);
- return 0;
- }
- return -1;
-}
-
-KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
-{
- if ( !GLEW_ARB_fragment_shader) {
- if (!mModified)
- spit("Fragment shaders not supported");
-
- mModified = true;
- Py_RETURN_NONE;
- }
-
- if ( !GLEW_ARB_vertex_shader) {
- if (!mModified)
- spit("Vertex shaders not supported");
-
- mModified = true;
- Py_RETURN_NONE;
- }
-
- if (!GLEW_ARB_shader_objects) {
- if (!mModified)
- spit("GLSL not supported");
- mModified = true;
- Py_RETURN_NONE;
- }
- else {
- // returns Py_None on error
- // the calling script will need to check
-
- if (!mShader && !mModified) {
- mShader = new BL_Shader();
- mModified = true;
-
- // Using a custom shader, make sure to initialize textures
- InitTextures();
- }
-
- if (mShader && !mShader->GetError()) {
- m_flag &= ~RAS_BLENDERGLSL;
- mMaterial->SetSharedMaterial(true);
- mScene->GetBucketManager()->ReleaseDisplayLists(this);
- return mShader->GetProxy();
- }
- else {
- // decref all references to the object
- // then delete it!
- // We will then go back to fixed functionality
- // for this material
- if (mShader) {
- delete mShader; /* will handle python de-referencing */
- mShader=0;
- }
- }
- Py_RETURN_NONE;
- }
- PyErr_SetString(PyExc_ValueError, "material.getShader(): KX_BlenderMaterial, GLSL Error");
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()")
-{
- return PyLong_FromLong(GetMaterialIndex());
-}
-
-KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getTexture, "getTexture( index )" )
-{
- // TODO: enable python switching
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setTexture , "setTexture( index, tex)")
-{
- // TODO: enable python switching
- return NULL;
-}
-
-static const unsigned int GL_array[11] = {
- GL_ZERO,
- GL_ONE,
- GL_SRC_COLOR,
- GL_ONE_MINUS_SRC_COLOR,
- GL_DST_COLOR,
- GL_ONE_MINUS_DST_COLOR,
- GL_SRC_ALPHA,
- GL_ONE_MINUS_SRC_ALPHA,
- GL_DST_ALPHA,
- GL_ONE_MINUS_DST_ALPHA,
- GL_SRC_ALPHA_SATURATE
-};
-
-KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setBlending , "setBlending( bge.logic.src, bge.logic.dest)")
-{
- unsigned int b[2];
- if (PyArg_ParseTuple(args, "ii:setBlending", &b[0], &b[1]))
- {
- bool value_found[2] = {false, false};
- for (int i=0; i<11; i++)
- {
- if (b[0] == GL_array[i]) {
- value_found[0] = true;
- mBlendFunc[0] = b[0];
- }
- if (b[1] == GL_array[i]) {
- value_found[1] = true;
- mBlendFunc[1] = b[1];
- }
- if (value_found[0] && value_found[1]) break;
- }
- if (!value_found[0] || !value_found[1]) {
- PyErr_SetString(PyExc_ValueError, "material.setBlending(int, int): KX_BlenderMaterial, invalid enum.");
- return NULL;
- }
- mUserDefBlend = true;
- Py_RETURN_NONE;
- }
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC(KX_BlenderMaterial, getTextureBindcode, "getTextureBindcode(texslot)")
-{
- unsigned int texslot;
- if (!PyArg_ParseTuple(args, "i:texslot", &texslot)) {
- PyErr_SetString(PyExc_ValueError, "material.getTextureBindcode(texslot): KX_BlenderMaterial, expected an int.");
- return NULL;
- }
- Image *ima = getImage(texslot);
- if (ima) {
- unsigned int *bindcode = ima->bindcode;
- return PyLong_FromLong(*bindcode);
- }
- PyErr_SetString(PyExc_ValueError, "material.getTextureBindcode(texslot): KX_BlenderMaterial, invalid texture slot.");
- return NULL;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h
deleted file mode 100644
index c562ee0c583..00000000000
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.h
+++ /dev/null
@@ -1,200 +0,0 @@
-
-/** \file KX_BlenderMaterial.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_BLENDERMATERIAL_H__
-#define __KX_BLENDERMATERIAL_H__
-
-#include <vector>
-
-
-#include "RAS_IPolygonMaterial.h"
-#include "BL_Material.h"
-#include "BL_Texture.h"
-#include "BL_Shader.h"
-#include "BL_BlenderShader.h"
-
-#include "EXP_PyObjectPlus.h"
-
-#include "MT_Vector3.h"
-#include "MT_Vector4.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-#include "SCA_IScene.h" /* only for Replace_IScene */
-#include "KX_Scene.h"
-
-struct MTFace;
-class KX_Scene;
-
-
-#ifdef USE_MATHUTILS
-void KX_BlenderMaterial_Mathutils_Callback_Init(void);
-#endif
-
-class KX_BlenderMaterial : public PyObjectPlus, public RAS_IPolyMaterial
-{
- Py_Header
-public:
- // --------------------------------
- KX_BlenderMaterial();
- void Initialize(
- class KX_Scene* scene,
- BL_Material* mat,
- GameSettings* game,
- int lightlayer
- );
-
- virtual ~KX_BlenderMaterial();
-
- // --------------------------------
- virtual TCachingInfo GetCachingInfo(void) const {
- return (void*) this;
- }
-
- virtual
- bool Activate(
- RAS_IRasterizer* rasty,
- TCachingInfo& cachingInfo
- ) const;
-
- virtual
- void ActivateMeshSlot(
- const RAS_MeshSlot & ms,
- RAS_IRasterizer* rasty
- ) const;
-
- void ActivateMat(
- RAS_IRasterizer* rasty,
- TCachingInfo& cachingInfo
- )const;
-
- void ActivatShaders(
- RAS_IRasterizer* rasty,
- TCachingInfo& cachingInfo
- )const;
-
- void ActivateBlenderShaders(
- RAS_IRasterizer* rasty,
- TCachingInfo& cachingInfo
- )const;
-
- Material* GetBlenderMaterial() const;
- Image* GetBlenderImage() const;
- unsigned int* GetMCol() const;
- BL_Texture * getTex (unsigned int idx) {
- return (idx < MAXTEX) ? mTextures + idx : NULL;
- }
- Image * getImage (unsigned int idx) {
- return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : NULL;
- }
- unsigned int* getBlendFunc() {
- return mBlendFunc;
- }
- // for ipos
- void UpdateIPO(
- MT_Vector4 rgba, MT_Vector3 specrgb,
- MT_Scalar hard, MT_Scalar spec,
- MT_Scalar ref, MT_Scalar emit, MT_Scalar alpha
- );
-
- virtual void Replace_IScene(SCA_IScene *val);
-
- BL_Material *GetBLMaterial();
-
-#ifdef WITH_PYTHON
- // --------------------------------
- virtual PyObject *py_repr(void) { return PyUnicode_From_STR_String(mMaterial->matname); }
-
- static PyObject *pyattr_get_shader(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_materialIndex(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_alpha(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_alpha(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_hardness(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_hardness(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_specular_intensity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_specular_intensity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_specular_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_specular_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_diffuse_intensity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_diffuse_intensity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_diffuse_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_diffuse_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_emit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_emit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- KX_PYMETHOD_DOC(KX_BlenderMaterial, getShader);
- KX_PYMETHOD_DOC(KX_BlenderMaterial, getMaterialIndex);
- KX_PYMETHOD_DOC(KX_BlenderMaterial, getTexture);
- KX_PYMETHOD_DOC(KX_BlenderMaterial, setTexture);
- KX_PYMETHOD_DOC(KX_BlenderMaterial, getTextureBindcode);
-
- KX_PYMETHOD_DOC(KX_BlenderMaterial, setBlending);
-#endif /* WITH_PYTHON */
-
- // --------------------------------
- // pre calculate to avoid pops/lag at startup
- virtual void OnConstruction();
-
- static void EndFrame();
-
-private:
- BL_Material* mMaterial;
- BL_Shader* mShader;
- BL_BlenderShader* mBlenderShader;
- KX_Scene* mScene;
- BL_Texture mTextures[MAXTEX]; // texture array
- bool mUserDefBlend;
- unsigned int mBlendFunc[2];
- bool mModified;
- bool mConstructed; // if false, don't clean on exit
- int mLightLayer;
-
- struct {
- float r, g, b, a;
- float specr, specg, specb;
- float spec;
- float ref;
- float hardness;
- float emit;
- } mSavedData;
-
- void InitTextures();
-
- void SetBlenderGLSLShader();
-
- void ActivatGLMaterials( RAS_IRasterizer* rasty )const;
- void ActivateTexGen( RAS_IRasterizer *ras ) const;
-
- bool UsesLighting(RAS_IRasterizer *rasty) const;
- void GetMaterialRGBAColor(unsigned char *rgba) const;
- Scene* GetBlenderScene() const;
- void ReleaseMaterial();
-
- // message centers
- void setTexData( bool enable,RAS_IRasterizer *ras);
- void setBlenderShaderData( bool enable, RAS_IRasterizer *ras);
- void setShaderData( bool enable, RAS_IRasterizer *ras);
-
- void setObjectMatrixData(int i, RAS_IRasterizer *ras);
- void setTexMatrixData(int i);
-
- void setLightData();
-
- // cleanup stuff
- void OnExit();
-
- // shader chacing
- static BL_BlenderShader *mLastBlenderShader;
- static BL_Shader *mLastShader;
-
- mutable int mPass;
-};
-
-
-#endif
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
deleted file mode 100644
index b22873aa862..00000000000
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ /dev/null
@@ -1,1166 +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 *****
- * Camera in the gameengine. Cameras are also used for views.
- */
-
-/** \file gameengine/Ketsji/KX_Camera.cpp
- * \ingroup ketsji
- */
-
-#include "GPU_glew.h"
-#include "GPU_matrix.h"
-#include "KX_Camera.h"
-#include "KX_Scene.h"
-#include "KX_PythonInit.h"
-#include "EXP_Python.h"
-#include "KX_PyMath.h"
-
-#include "RAS_ICanvas.h"
-
-KX_Camera::KX_Camera(void* sgReplicationInfo,
- SG_Callbacks callbacks,
- const RAS_CameraData& camdata,
- bool frustum_culling,
- bool delete_node)
- :
- KX_GameObject(sgReplicationInfo,callbacks),
- m_camdata(camdata),
- m_dirty(true),
- m_normalized(false),
- m_frustum_culling(frustum_culling),
- m_set_projection_matrix(false),
- m_set_frustum_center(false),
- m_delete_node(delete_node)
-{
- // setting a name would be nice...
- m_name = "cam";
- m_projection_matrix.setIdentity();
- m_modelview_matrix.setIdentity();
-}
-
-
-KX_Camera::~KX_Camera()
-{
- if (m_delete_node && m_pSGNode)
- {
- // for shadow camera, avoids memleak
- delete m_pSGNode;
- m_pSGNode = NULL;
- }
-}
-
-
-CValue* KX_Camera::GetReplica()
-{
- KX_Camera* replica = new KX_Camera(*this);
-
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-void KX_Camera::ProcessReplica()
-{
- KX_GameObject::ProcessReplica();
- // replicated camera are always registered in the scene
- m_delete_node = false;
-}
-
-MT_Transform KX_Camera::GetWorldToCamera() const
-{
- MT_Transform camtrans;
- camtrans.invert(MT_Transform(NodeGetWorldPosition(), NodeGetWorldOrientation()));
-
- return camtrans;
-}
-
-
-
-MT_Transform KX_Camera::GetCameraToWorld() const
-{
- return MT_Transform(NodeGetWorldPosition(), NodeGetWorldOrientation());
-}
-
-
-
-void KX_Camera::CorrectLookUp(MT_Scalar speed)
-{
-}
-
-
-
-const MT_Point3 KX_Camera::GetCameraLocation() const
-{
- /* this is the camera locatio in cam coords... */
- //return m_trans1.getOrigin();
- //return MT_Point3(0,0,0); <-----
- /* .... I want it in world coords */
- //MT_Transform trans;
- //trans.setBasis(NodeGetWorldOrientation());
-
- return NodeGetWorldPosition();
-}
-
-
-
-/* I want the camera orientation as well. */
-const MT_Quaternion KX_Camera::GetCameraOrientation() const
-{
- return NodeGetWorldOrientation().getRotation();
-}
-
-
-
-/**
- * Sets the projection matrix that is used by the rasterizer.
- */
-void KX_Camera::SetProjectionMatrix(const MT_Matrix4x4 & mat)
-{
- m_projection_matrix = mat;
- m_dirty = true;
- m_set_projection_matrix = true;
- m_set_frustum_center = false;
-}
-
-
-
-/**
- * Sets the modelview matrix that is used by the rasterizer.
- */
-void KX_Camera::SetModelviewMatrix(const MT_Matrix4x4 & mat)
-{
- m_modelview_matrix = mat;
- m_dirty = true;
- m_set_frustum_center = false;
-}
-
-
-
-/**
- * Gets the projection matrix that is used by the rasterizer.
- */
-const MT_Matrix4x4& KX_Camera::GetProjectionMatrix() const
-{
- return m_projection_matrix;
-}
-
-
-
-/**
- * Gets the modelview matrix that is used by the rasterizer.
- */
-const MT_Matrix4x4& KX_Camera::GetModelviewMatrix() const
-{
- return m_modelview_matrix;
-}
-
-
-bool KX_Camera::hasValidProjectionMatrix() const
-{
- return m_set_projection_matrix;
-}
-
-void KX_Camera::InvalidateProjectionMatrix(bool valid)
-{
- m_set_projection_matrix = valid;
-}
-
-
-/**
- * These getters retrieve the clip data and the focal length
- */
-float KX_Camera::GetLens() const
-{
- return m_camdata.m_lens;
-}
-
-float KX_Camera::GetScale() const
-{
- return m_camdata.m_scale;
-}
-
-/**
- * Gets the horizontal size of the sensor - for camera matching.
- */
-float KX_Camera::GetSensorWidth() const
-{
- return m_camdata.m_sensor_x;
-}
-
-/**
- * Gets the vertical size of the sensor - for camera matching.
- */
-float KX_Camera::GetSensorHeight() const
-{
- return m_camdata.m_sensor_y;
-}
-/** Gets the mode FOV is calculating from sensor dimensions */
-short KX_Camera::GetSensorFit() const
-{
- return m_camdata.m_sensor_fit;
-}
-
-/**
- * Gets the horizontal shift of the sensor - for camera matching.
- */
-float KX_Camera::GetShiftHorizontal() const
-{
- return m_camdata.m_shift_x;
-}
-
-/**
- * Gets the vertical shift of the sensor - for camera matching.
- */
-float KX_Camera::GetShiftVertical() const
-{
- return m_camdata.m_shift_y;
-}
-
-float KX_Camera::GetCameraNear() const
-{
- return m_camdata.m_clipstart;
-}
-
-
-
-float KX_Camera::GetCameraFar() const
-{
- return m_camdata.m_clipend;
-}
-
-float KX_Camera::GetFocalLength() const
-{
- return m_camdata.m_focallength;
-}
-
-
-
-RAS_CameraData* KX_Camera::GetCameraData()
-{
- return &m_camdata;
-}
-
-void KX_Camera::ExtractClipPlanes()
-{
- if (!m_dirty)
- return;
-
- MT_Matrix4x4 m = m_projection_matrix * m_modelview_matrix;
- // Left clip plane
- m_planes[0] = m[3] + m[0];
- // Right clip plane
- m_planes[1] = m[3] - m[0];
- // Top clip plane
- m_planes[2] = m[3] - m[1];
- // Bottom clip plane
- m_planes[3] = m[3] + m[1];
- // Near clip plane
- m_planes[4] = m[3] + m[2];
- // Far clip plane
- m_planes[5] = m[3] - m[2];
-
- m_dirty = false;
- m_normalized = false;
-}
-
-void KX_Camera::NormalizeClipPlanes()
-{
- if (m_normalized)
- return;
-
- for (unsigned int p = 0; p < 6; p++)
- {
- MT_Scalar factor = sqrtf(m_planes[p][0]*m_planes[p][0] + m_planes[p][1]*m_planes[p][1] + m_planes[p][2]*m_planes[p][2]);
- if (!MT_fuzzyZero(factor))
- m_planes[p] /= factor;
- }
-
- m_normalized = true;
-}
-
-void KX_Camera::ExtractFrustumSphere()
-{
- if (m_set_frustum_center)
- return;
-
- // compute sphere for the general case and not only symmetric frustum:
- // the mirror code in ImageRender can use very asymmetric frustum.
- // We will put the sphere center on the line that goes from origin to the center of the far clipping plane
- // This is the optimal position if the frustum is symmetric or very asymmetric and probably close
- // to optimal for the general case. The sphere center position is computed so that the distance to
- // the near and far extreme frustum points are equal.
-
- // get the transformation matrix from device coordinate to camera coordinate
- MT_Matrix4x4 clip_camcs_matrix = m_projection_matrix;
- clip_camcs_matrix.invert();
-
- if (m_projection_matrix[3][3] == MT_Scalar(0.0f))
- {
- // frustum projection
- // detect which of the corner of the far clipping plane is the farthest to the origin
- MT_Vector4 nfar; // far point in device normalized coordinate
- MT_Point3 farpoint; // most extreme far point in camera coordinate
- MT_Point3 nearpoint;// most extreme near point in camera coordinate
- MT_Point3 farcenter(0.0f, 0.0f, 0.0f);// center of far cliping plane in camera coordinate
- MT_Scalar F=-1.0f, N; // square distance of far and near point to origin
- MT_Scalar f, n; // distance of far and near point to z axis. f is always > 0 but n can be < 0
- MT_Scalar e, s; // far and near clipping distance (<0)
- MT_Scalar c; // slope of center line = distance of far clipping center to z axis / far clipping distance
- MT_Scalar z; // projection of sphere center on z axis (<0)
- // tmp value
- MT_Vector4 npoint(1.0f, 1.0f, 1.0f, 1.0f);
- MT_Vector4 hpoint;
- MT_Point3 point;
- MT_Scalar len;
- for (int i=0; i<4; i++)
- {
- hpoint = clip_camcs_matrix*npoint;
- point.setValue(hpoint[0]/hpoint[3], hpoint[1]/hpoint[3], hpoint[2]/hpoint[3]);
- len = point.dot(point);
- if (len > F)
- {
- nfar = npoint;
- farpoint = point;
- F = len;
- }
- // rotate by 90 degree along the z axis to walk through the 4 extreme points of the far clipping plane
- len = npoint[0];
- npoint[0] = -npoint[1];
- npoint[1] = len;
- farcenter += point;
- }
- // the far center is the average of the far clipping points
- farcenter *= 0.25f;
- // the extreme near point is the opposite point on the near clipping plane
- nfar.setValue(-nfar[0], -nfar[1], -1.0f, 1.0f);
- nfar = clip_camcs_matrix*nfar;
- nearpoint.setValue(nfar[0]/nfar[3], nfar[1]/nfar[3], nfar[2]/nfar[3]);
- // this is a frustum projection
- N = nearpoint.dot(nearpoint);
- e = farpoint[2];
- s = nearpoint[2];
- // projection on XY plane for distance to axis computation
- MT_Point2 farxy(farpoint[0], farpoint[1]);
- // f is forced positive by construction
- f = farxy.length();
- // get corresponding point on the near plane
- farxy *= s/e;
- // this formula preserve the sign of n
- n = f*s/e - MT_Point2(nearpoint[0]-farxy[0], nearpoint[1]-farxy[1]).length();
- c = MT_Point2(farcenter[0], farcenter[1]).length()/e;
- // the big formula, it simplifies to (F-N)/(2(e-s)) for the symmetric case
- z = (F-N)/(2.0f*(e-s+c*(f-n)));
- m_frustum_center = MT_Point3(farcenter[0]*z/e, farcenter[1]*z/e, z);
- m_frustum_radius = m_frustum_center.distance(farpoint);
- }
- else
- {
- // orthographic projection
- // The most extreme points on the near and far plane. (normalized device coords)
- MT_Vector4 hnear(1.0f, 1.0f, 1.0f, 1.0f), hfar(-1.0f, -1.0f, -1.0f, 1.0f);
-
- // Transform to hom camera local space
- hnear = clip_camcs_matrix*hnear;
- hfar = clip_camcs_matrix*hfar;
-
- // Tranform to 3d camera local space.
- MT_Point3 nearpoint(hnear[0]/hnear[3], hnear[1]/hnear[3], hnear[2]/hnear[3]);
- MT_Point3 farpoint(hfar[0]/hfar[3], hfar[1]/hfar[3], hfar[2]/hfar[3]);
-
- // just use mediant point
- m_frustum_center = (farpoint + nearpoint)*0.5f;
- m_frustum_radius = m_frustum_center.distance(farpoint);
- }
- // Transform to world space.
- m_frustum_center = GetCameraToWorld()(m_frustum_center);
- m_frustum_radius /= fabsf(NodeGetWorldScaling()[NodeGetWorldScaling().closestAxis()]);
-
- m_set_frustum_center = true;
-}
-
-bool KX_Camera::PointInsideFrustum(const MT_Point3& x)
-{
- ExtractClipPlanes();
-
- for ( unsigned int i = 0; i < 6 ; i++ )
- {
- if (m_planes[i][0] * x[0] + m_planes[i][1] * x[1] + m_planes[i][2] * x[2] + m_planes[i][3] < 0.0f)
- return false;
- }
- return true;
-}
-
-int KX_Camera::BoxInsideFrustum(const MT_Point3 *box)
-{
- ExtractClipPlanes();
-
- unsigned int insideCount = 0;
- // 6 view frustum planes
- for ( unsigned int p = 0; p < 6 ; p++ )
- {
- unsigned int behindCount = 0;
- // 8 box vertices.
- for (unsigned int v = 0; v < 8 ; v++)
- {
- if (m_planes[p][0] * box[v][0] + m_planes[p][1] * box[v][1] + m_planes[p][2] * box[v][2] + m_planes[p][3] < 0.0f)
- behindCount++;
- }
-
- // 8 points behind this plane
- if (behindCount == 8)
- return OUTSIDE;
-
- // Every box vertex is on the front side of this plane
- if (!behindCount)
- insideCount++;
- }
-
- // All box vertices are on the front side of all frustum planes.
- if (insideCount == 6)
- return INSIDE;
-
- return INTERSECT;
-}
-
-int KX_Camera::SphereInsideFrustum(const MT_Point3& center, const MT_Scalar &radius)
-{
- ExtractFrustumSphere();
- if (center.distance2(m_frustum_center) > (radius + m_frustum_radius)*(radius + m_frustum_radius))
- return OUTSIDE;
-
- unsigned int p;
- ExtractClipPlanes();
- NormalizeClipPlanes();
-
- MT_Scalar distance;
- int intersect = INSIDE;
- // distance: <-------- OUTSIDE -----|----- INTERSECT -----0----- INTERSECT -----|----- INSIDE -------->
- // -radius radius
- for (p = 0; p < 6; p++)
- {
- distance = m_planes[p][0]*center[0] + m_planes[p][1]*center[1] + m_planes[p][2]*center[2] + m_planes[p][3];
- if (fabsf(distance) <= radius)
- intersect = INTERSECT;
- else if (distance < -radius)
- return OUTSIDE;
- }
-
- return intersect;
-}
-
-bool KX_Camera::GetFrustumCulling() const
-{
- return m_frustum_culling;
-}
-
-void KX_Camera::EnableViewport(bool viewport)
-{
- InvalidateProjectionMatrix(false); // We need to reset projection matrix
- m_camdata.m_viewport = viewport;
-}
-
-void KX_Camera::SetViewport(int left, int bottom, int right, int top)
-{
- m_camdata.m_viewportleft = left;
- m_camdata.m_viewportbottom = bottom;
- m_camdata.m_viewportright = right;
- m_camdata.m_viewporttop = top;
-}
-
-bool KX_Camera::GetViewport() const
-{
- return m_camdata.m_viewport;
-}
-
-int KX_Camera::GetViewportLeft() const
-{
- return m_camdata.m_viewportleft;
-}
-
-int KX_Camera::GetViewportBottom() const
-{
- return m_camdata.m_viewportbottom;
-}
-
-int KX_Camera::GetViewportRight() const
-{
- return m_camdata.m_viewportright;
-}
-
-int KX_Camera::GetViewportTop() const
-{
- return m_camdata.m_viewporttop;
-}
-
-#ifdef WITH_PYTHON
-//----------------------------------------------------------------------------
-//Python
-
-
-PyMethodDef KX_Camera::Methods[] = {
- KX_PYMETHODTABLE(KX_Camera, sphereInsideFrustum),
- KX_PYMETHODTABLE_O(KX_Camera, boxInsideFrustum),
- KX_PYMETHODTABLE_O(KX_Camera, pointInsideFrustum),
- KX_PYMETHODTABLE_NOARGS(KX_Camera, getCameraToWorld),
- KX_PYMETHODTABLE_NOARGS(KX_Camera, getWorldToCamera),
- KX_PYMETHODTABLE(KX_Camera, setViewport),
- KX_PYMETHODTABLE_NOARGS(KX_Camera, setOnTop),
- KX_PYMETHODTABLE_O(KX_Camera, getScreenPosition),
- KX_PYMETHODTABLE(KX_Camera, getScreenVect),
- KX_PYMETHODTABLE(KX_Camera, getScreenRay),
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_Camera::Attributes[] = {
-
- KX_PYATTRIBUTE_BOOL_RW("frustum_culling", KX_Camera, m_frustum_culling),
- KX_PYATTRIBUTE_RW_FUNCTION("perspective", KX_Camera, pyattr_get_perspective, pyattr_set_perspective),
-
- KX_PYATTRIBUTE_RW_FUNCTION("lens", KX_Camera, pyattr_get_lens, pyattr_set_lens),
- KX_PYATTRIBUTE_RW_FUNCTION("fov", KX_Camera, pyattr_get_fov, pyattr_set_fov),
- KX_PYATTRIBUTE_RW_FUNCTION("ortho_scale", KX_Camera, pyattr_get_ortho_scale, pyattr_set_ortho_scale),
- KX_PYATTRIBUTE_RW_FUNCTION("near", KX_Camera, pyattr_get_near, pyattr_set_near),
- KX_PYATTRIBUTE_RW_FUNCTION("far", KX_Camera, pyattr_get_far, pyattr_set_far),
- KX_PYATTRIBUTE_RW_FUNCTION("shift_x", KX_Camera, pyattr_get_shift_x, pyattr_set_shift_x),
- KX_PYATTRIBUTE_RW_FUNCTION("shift_y", KX_Camera, pyattr_get_shift_y, pyattr_set_shift_y),
-
- KX_PYATTRIBUTE_RW_FUNCTION("useViewport", KX_Camera, pyattr_get_use_viewport, pyattr_set_use_viewport),
-
- KX_PYATTRIBUTE_RW_FUNCTION("projection_matrix", KX_Camera, pyattr_get_projection_matrix, pyattr_set_projection_matrix),
- KX_PYATTRIBUTE_RO_FUNCTION("modelview_matrix", KX_Camera, pyattr_get_modelview_matrix),
- KX_PYATTRIBUTE_RO_FUNCTION("camera_to_world", KX_Camera, pyattr_get_camera_to_world),
- KX_PYATTRIBUTE_RO_FUNCTION("world_to_camera", KX_Camera, pyattr_get_world_to_camera),
-
- /* Grrr, functions for constants? */
- KX_PYATTRIBUTE_RO_FUNCTION("INSIDE", KX_Camera, pyattr_get_INSIDE),
- KX_PYATTRIBUTE_RO_FUNCTION("OUTSIDE", KX_Camera, pyattr_get_OUTSIDE),
- KX_PYATTRIBUTE_RO_FUNCTION("INTERSECT", KX_Camera, pyattr_get_INTERSECT),
-
- { NULL } //Sentinel
-};
-
-PyTypeObject KX_Camera::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_Camera",
- sizeof(PyObjectPlus_Proxy),
- 0,
- py_base_dealloc,
- 0,
- 0,
- 0,
- 0,
- py_base_repr,
- 0,
- &KX_GameObject::Sequence,
- &KX_GameObject::Mapping,
- 0,0,0,
- NULL,
- NULL,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- 0,0,0,0,0,0,0,
- Methods,
- 0,
- 0,
- &KX_GameObject::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum,
-"sphereInsideFrustum(center, radius) -> Integer\n"
-"\treturns INSIDE, OUTSIDE or INTERSECT if the given sphere is\n"
-"\tinside/outside/intersects this camera's viewing frustum.\n\n"
-"\tcenter = the center of the sphere (in world coordinates.)\n"
-"\tradius = the radius of the sphere\n\n"
-"\tExample:\n"
-"\timport bge.logic\n\n"
-"\tco = bge.logic.getCurrentController()\n"
-"\tcam = co.GetOwner()\n\n"
-"\t# A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]\n"
-"\tif (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):\n"
-"\t\t# Sphere is inside frustum !\n"
-"\t\t# Do something useful !\n"
-"\telse:\n"
-"\t\t# Sphere is outside frustum\n"
-)
-{
- PyObject *pycenter;
- float radius;
- if (PyArg_ParseTuple(args, "Of:sphereInsideFrustum", &pycenter, &radius))
- {
- MT_Point3 center;
- if (PyVecTo(pycenter, center))
- {
- return PyLong_FromLong(SphereInsideFrustum(center, radius)); /* new ref */
- }
- }
-
- PyErr_SetString(PyExc_TypeError, "camera.sphereInsideFrustum(center, radius): KX_Camera, expected arguments: (center, radius)");
-
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC_O(KX_Camera, boxInsideFrustum,
-"boxInsideFrustum(box) -> Integer\n"
-"\treturns INSIDE, OUTSIDE or INTERSECT if the given box is\n"
-"\tinside/outside/intersects this camera's viewing frustum.\n\n"
-"\tbox = a list of the eight (8) corners of the box (in world coordinates.)\n\n"
-"\tExample:\n"
-"\timport bge.logic\n\n"
-"\tco = bge.logic.getCurrentController()\n"
-"\tcam = co.GetOwner()\n\n"
-"\tbox = []\n"
-"\tbox.append([-1.0, -1.0, -1.0])\n"
-"\tbox.append([-1.0, -1.0, 1.0])\n"
-"\tbox.append([-1.0, 1.0, -1.0])\n"
-"\tbox.append([-1.0, 1.0, 1.0])\n"
-"\tbox.append([ 1.0, -1.0, -1.0])\n"
-"\tbox.append([ 1.0, -1.0, 1.0])\n"
-"\tbox.append([ 1.0, 1.0, -1.0])\n"
-"\tbox.append([ 1.0, 1.0, 1.0])\n\n"
-"\tif (cam.boxInsideFrustum(box) != cam.OUTSIDE):\n"
-"\t\t# Box is inside/intersects frustum !\n"
-"\t\t# Do something useful !\n"
-"\telse:\n"
-"\t\t# Box is outside the frustum !\n"
-)
-{
- unsigned int num_points = PySequence_Size(value);
- if (num_points != 8)
- {
- PyErr_Format(PyExc_TypeError, "camera.boxInsideFrustum(box): KX_Camera, expected eight (8) points, got %d", num_points);
- return NULL;
- }
-
- MT_Point3 box[8];
- for (unsigned int p = 0; p < 8 ; p++)
- {
- PyObject *item = PySequence_GetItem(value, p); /* new ref */
- bool error = !PyVecTo(item, box[p]);
- Py_DECREF(item);
- if (error)
- return NULL;
- }
-
- return PyLong_FromLong(BoxInsideFrustum(box)); /* new ref */
-}
-
-KX_PYMETHODDEF_DOC_O(KX_Camera, pointInsideFrustum,
-"pointInsideFrustum(point) -> Bool\n"
-"\treturns 1 if the given point is inside this camera's viewing frustum.\n\n"
-"\tpoint = The point to test (in world coordinates.)\n\n"
-"\tExample:\n"
-"\timport bge.logic\n\n"
-"\tco = bge.logic.getCurrentController()\n"
-"\tcam = co.GetOwner()\n\n"
-"\t# Test point [0.0, 0.0, 0.0]"
-"\tif (cam.pointInsideFrustum([0.0, 0.0, 0.0])):\n"
-"\t\t# Point is inside frustum !\n"
-"\t\t# Do something useful !\n"
-"\telse:\n"
-"\t\t# Box is outside the frustum !\n"
-)
-{
- MT_Point3 point;
- if (PyVecTo(value, point))
- {
- return PyLong_FromLong(PointInsideFrustum(point)); /* new ref */
- }
-
- PyErr_SetString(PyExc_TypeError, "camera.pointInsideFrustum(point): KX_Camera, expected point argument.");
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_Camera, getCameraToWorld,
-"getCameraToWorld() -> Matrix4x4\n"
-"\treturns the camera to world transformation matrix, as a list of four lists of four values.\n\n"
-"\tie: [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])\n"
-)
-{
- return PyObjectFrom(GetCameraToWorld()); /* new ref */
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_Camera, getWorldToCamera,
-"getWorldToCamera() -> Matrix4x4\n"
-"\treturns the world to camera transformation matrix, as a list of four lists of four values.\n\n"
-"\tie: [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])\n"
-)
-{
- return PyObjectFrom(GetWorldToCamera()); /* new ref */
-}
-
-KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, setViewport,
-"setViewport(left, bottom, right, top)\n"
-"Sets this camera's viewport\n")
-{
- int left, bottom, right, top;
- if (!PyArg_ParseTuple(args,"iiii:setViewport",&left, &bottom, &right, &top))
- return NULL;
-
- SetViewport(left, bottom, right, top);
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_Camera, setOnTop,
-"setOnTop()\n"
-"Sets this camera's viewport on top\n")
-{
- class KX_Scene* scene = KX_GetActiveScene();
- scene->SetCameraOnTop(this);
- Py_RETURN_NONE;
-}
-
-PyObject *KX_Camera::pyattr_get_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyBool_FromLong(self->m_camdata.m_perspective);
-}
-
-int KX_Camera::pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- int param = PyObject_IsTrue( value );
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "camera.perspective = bool: KX_Camera, expected True/False or 0/1");
- return PY_SET_ATTR_FAIL;
- }
-
- self->m_camdata.m_perspective= param;
- self->InvalidateProjectionMatrix();
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Camera::pyattr_get_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyFloat_FromDouble(self->m_camdata.m_lens);
-}
-
-int KX_Camera::pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- float param = PyFloat_AsDouble(value);
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "camera.lens = float: KX_Camera, expected a float greater than zero");
- return PY_SET_ATTR_FAIL;
- }
-
- self->m_camdata.m_lens= param;
- self->m_set_projection_matrix = false;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Camera::pyattr_get_fov(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
-
- float lens = self->m_camdata.m_lens;
- float width = self->m_camdata.m_sensor_x;
- float fov = 2.0f * atanf(0.5f * width / lens);
-
- return PyFloat_FromDouble(fov * MT_DEGS_PER_RAD);
-}
-
-int KX_Camera::pyattr_set_fov(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- float fov = PyFloat_AsDouble(value);
- if (fov <= 0.0f) {
- PyErr_SetString(PyExc_AttributeError, "camera.fov = float: KX_Camera, expected a float greater than zero");
- return PY_SET_ATTR_FAIL;
- }
-
- fov *= MT_RADS_PER_DEG;
- float width = self->m_camdata.m_sensor_x;
- float lens = width / (2.0f * tanf(0.5f * fov));
-
- self->m_camdata.m_lens= lens;
- self->m_set_projection_matrix = false;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Camera::pyattr_get_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyFloat_FromDouble(self->m_camdata.m_scale);
-}
-
-int KX_Camera::pyattr_set_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- float param = PyFloat_AsDouble(value);
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "camera.ortho_scale = float: KX_Camera, expected a float greater than zero");
- return PY_SET_ATTR_FAIL;
- }
-
- self->m_camdata.m_scale= param;
- self->m_set_projection_matrix = false;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Camera::pyattr_get_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyFloat_FromDouble(self->m_camdata.m_clipstart);
-}
-
-int KX_Camera::pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- float param = PyFloat_AsDouble(value);
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "camera.near = float: KX_Camera, expected a float greater than zero");
- return PY_SET_ATTR_FAIL;
- }
-
- self->m_camdata.m_clipstart= param;
- self->m_set_projection_matrix = false;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Camera::pyattr_get_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyFloat_FromDouble(self->m_camdata.m_clipend);
-}
-
-int KX_Camera::pyattr_set_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- float param = PyFloat_AsDouble(value);
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "camera.far = float: KX_Camera, expected a float greater than zero");
- return PY_SET_ATTR_FAIL;
- }
-
- self->m_camdata.m_clipend= param;
- self->m_set_projection_matrix = false;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Camera::pyattr_get_shift_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyFloat_FromDouble(self->m_camdata.m_shift_x);
-}
-
-int KX_Camera::pyattr_set_shift_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- float param = PyFloat_AsDouble(value);
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "camera.shift_x = float: KX_Camera, expected a float greater than zero");
- return PY_SET_ATTR_FAIL;
- }
-
- self->m_camdata.m_shift_x = param;
- self->m_set_projection_matrix = false;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Camera::pyattr_get_shift_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyFloat_FromDouble(self->m_camdata.m_shift_y);
-}
-
-int KX_Camera::pyattr_set_shift_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- float param = PyFloat_AsDouble(value);
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "camera.shift_y = float: KX_Camera, expected a float greater than zero");
- return PY_SET_ATTR_FAIL;
- }
-
- self->m_camdata.m_shift_y = param;
- self->m_set_projection_matrix = false;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Camera::pyattr_get_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyBool_FromLong(self->GetViewport());
-}
-
-int KX_Camera::pyattr_set_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- int param = PyObject_IsTrue( value );
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "camera.useViewport = bool: KX_Camera, expected True or False");
- return PY_SET_ATTR_FAIL;
- }
- self->EnableViewport((bool)param);
- return PY_SET_ATTR_SUCCESS;
-}
-
-
-PyObject *KX_Camera::pyattr_get_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyObjectFrom(self->GetProjectionMatrix());
-}
-
-int KX_Camera::pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- MT_Matrix4x4 mat;
- if (!PyMatTo(value, mat))
- return PY_SET_ATTR_FAIL;
-
- self->SetProjectionMatrix(mat);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Camera::pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyObjectFrom(self->GetWorldToCamera());
-}
-
-PyObject *KX_Camera::pyattr_get_camera_to_world(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyObjectFrom(self->GetCameraToWorld());
-}
-
-PyObject *KX_Camera::pyattr_get_world_to_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Camera* self = static_cast<KX_Camera*>(self_v);
- return PyObjectFrom(self->GetWorldToCamera());
-}
-
-
-PyObject *KX_Camera::pyattr_get_INSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{ return PyLong_FromLong(INSIDE); }
-PyObject *KX_Camera::pyattr_get_OUTSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{ return PyLong_FromLong(OUTSIDE); }
-PyObject *KX_Camera::pyattr_get_INTERSECT(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{ return PyLong_FromLong(INTERSECT); }
-
-
-bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok, const char *error_prefix)
-{
- if (value==NULL) {
- PyErr_Format(PyExc_TypeError, "%s, python pointer NULL, should never happen", error_prefix);
- *object = NULL;
- return false;
- }
-
- if (value==Py_None) {
- *object = NULL;
-
- if (py_none_ok) {
- return true;
- } else {
- PyErr_Format(PyExc_TypeError, "%s, expected KX_Camera or a KX_Camera name, None is invalid", error_prefix);
- return false;
- }
- }
-
- if (PyUnicode_Check(value)) {
- STR_String value_str = _PyUnicode_AsString(value);
- *object = KX_GetActiveScene()->FindCamera(value_str);
-
- if (*object) {
- return true;
- } else {
- PyErr_Format(PyExc_ValueError,
- "%s, requested name \"%s\" did not match any KX_Camera in this scene",
- error_prefix, _PyUnicode_AsString(value));
- return false;
- }
- }
-
- if (PyObject_TypeCheck(value, &KX_Camera::Type)) {
- *object = static_cast<KX_Camera*>BGE_PROXY_REF(value);
-
- /* sets the error */
- if (*object==NULL) {
- PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix);
- return false;
- }
-
- return true;
- }
-
- *object = NULL;
-
- if (py_none_ok) {
- PyErr_Format(PyExc_TypeError, "%s, expect a KX_Camera, a string or None", error_prefix);
- } else {
- PyErr_Format(PyExc_TypeError, "%s, expect a KX_Camera or a string", error_prefix);
- }
-
- return false;
-}
-
-KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition,
-"getScreenPosition()\n"
-)
-
-{
- MT_Vector3 vect;
- KX_GameObject *obj = NULL;
-
- if (!PyVecTo(value, vect))
- {
- PyErr_Clear();
-
- if (ConvertPythonToGameObject(GetScene()->GetLogicManager(), value, &obj, true, ""))
- {
- PyErr_Clear();
- vect = MT_Vector3(obj->NodeGetWorldPosition());
- }
- else
- {
- PyErr_SetString(PyExc_TypeError, "Error in getScreenPosition. Expected a Vector3 or a KX_GameObject or a string for a name of a KX_GameObject");
- return NULL;
- }
- }
-
- const GLint *viewport;
- GLfloat vec[3];
- GLfloat win[3];
- GLfloat modelmatrix[4][4];
- GLfloat projmatrix[4][4];
-
- MT_Matrix4x4 m_modelmatrix = this->GetWorldToCamera();
- MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix();
-
- vect.getValue(vec);
- m_modelmatrix.getValue((float*) modelmatrix);
- m_projmatrix.getValue((float*) projmatrix);
-
- viewport = KX_GetActiveEngine()->GetCanvas()->GetViewPort();
-
- gpuProject(vec, modelmatrix, projmatrix, viewport, win);
-
- vect[0] = (win[0] - viewport[0]) / viewport[2];
- vect[1] = (win[1] - viewport[1]) / viewport[3];
-
- vect[1] = 1.0f - vect[1]; //to follow Blender window coordinate system (Top-Down)
-
- PyObject *ret = PyTuple_New(2);
- if (ret) {
- PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(vect[0]));
- PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(vect[1]));
- return ret;
- }
-
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenVect,
-"getScreenVect()\n"
-)
-{
- double x,y;
- if (!PyArg_ParseTuple(args,"dd:getScreenVect",&x,&y))
- return NULL;
-
- y = 1.0 - y; //to follow Blender window coordinate system (Top-Down)
-
- const GLint *viewport;
- GLfloat vec[3];
- GLfloat win[3];
- GLfloat modelmatrix[4][4];
- GLfloat projmatrix[4][4];
-
- MT_Matrix4x4 m_modelmatrix = this->GetWorldToCamera();
- MT_Matrix4x4 m_projmatrix = this->GetProjectionMatrix();
-
- m_modelmatrix.getValue((float*) modelmatrix);
- m_projmatrix.getValue((float*) projmatrix);
-
- viewport = KX_GetActiveEngine()->GetCanvas()->GetViewPort();
-
- vec[0] = x * viewport[2];
- vec[1] = y * viewport[3];
-
- vec[0] += viewport[0];
- vec[1] += viewport[1];
-
- vec[2] = 0.f;
-
- gpuUnProject(vec, modelmatrix, projmatrix, viewport, win);
-
- MT_Point3 campos = this->GetCameraLocation();
- MT_Point3 screenpos(win[0], win[1], win[2]);
- MT_Vector3 vect = campos - screenpos;
- vect.normalize();
- return PyObjectFrom(vect);
-}
-
-KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenRay,
-"getScreenRay()\n"
-)
-{
- MT_Vector3 vect;
- double x,y,dist;
- char *propName = NULL;
-
- if (!PyArg_ParseTuple(args,"ddd|s:getScreenRay",&x,&y,&dist,&propName))
- return NULL;
-
- PyObject *argValue = PyTuple_New(2);
- PyTuple_SET_ITEM(argValue, 0, PyFloat_FromDouble(x));
- PyTuple_SET_ITEM(argValue, 1, PyFloat_FromDouble(y));
-
- if (!PyVecTo(PygetScreenVect(argValue), vect))
- {
- Py_DECREF(argValue);
- PyErr_SetString(PyExc_TypeError,
- "Error in getScreenRay. Invalid 2D coordinate. "
- "Expected a normalized 2D screen coordinate, "
- "a distance and an optional property argument");
- return NULL;
- }
- Py_DECREF(argValue);
-
- dist = -dist;
- vect += this->GetCameraLocation();
-
- argValue = (propName?PyTuple_New(3):PyTuple_New(2));
- if (argValue) {
- PyTuple_SET_ITEM(argValue, 0, PyObjectFrom(vect));
- PyTuple_SET_ITEM(argValue, 1, PyFloat_FromDouble(dist));
- if (propName)
- PyTuple_SET_ITEM(argValue, 2, PyUnicode_FromString(propName));
-
- PyObject *ret= this->PyrayCastTo(argValue,NULL);
- Py_DECREF(argValue);
- return ret;
- }
-
- return NULL;
-}
-#endif
diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h
deleted file mode 100644
index 8addf0b7aed..00000000000
--- a/source/gameengine/Ketsji/KX_Camera.h
+++ /dev/null
@@ -1,334 +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_Camera.h
- * \ingroup ketsji
- * \brief Camera in the gameengine. Cameras are also used for views.
- */
-
-#ifndef __KX_CAMERA_H__
-#define __KX_CAMERA_H__
-
-
-#include "MT_Transform.h"
-#include "MT_Matrix3x3.h"
-#include "MT_Matrix4x4.h"
-#include "MT_Vector3.h"
-#include "MT_Point3.h"
-#include "KX_GameObject.h"
-#include "EXP_IntValue.h"
-#include "RAS_CameraData.h"
-
-#ifdef WITH_PYTHON
-/* utility conversion function */
-bool ConvertPythonToCamera(PyObject *value, KX_Camera **object, bool py_none_ok, const char *error_prefix);
-#endif
-
-class KX_Camera : public KX_GameObject
-{
- Py_Header
-protected:
- friend class KX_Scene;
- /** Camera parameters (clips distances, focal length). These
- * params are closely tied to Blender. In the gameengine, only the
- * projection and modelview matrices are relevant. There's a
- * conversion being done in the engine class. Why is it stored
- * here? It doesn't really have a function here. */
- RAS_CameraData m_camdata;
-
- // Never used, I think...
-// void MoveTo(const MT_Point3& movevec)
-// {
-#if 0
- MT_Transform camtrans;
- camtrans.invert(m_trans1);
- MT_Matrix3x3 camorient = camtrans.getBasis();
- camtrans.translate(camorient.inverse()*movevec);
- m_trans1.invert(camtrans);
-#endif
-// }
-
- /**
- * Storage for the projection matrix that is passed to the
- * rasterizer. */
- MT_Matrix4x4 m_projection_matrix;
- //MT_Matrix4x4 m_projection_matrix1;
-
- /**
- * Storage for the modelview matrix that is passed to the
- * rasterizer. */
- MT_Matrix4x4 m_modelview_matrix;
-
- /**
- * true if the view frustum (modelview/projection matrix)
- * has changed - the clip planes (m_planes) will have to be
- * regenerated.
- */
- bool m_dirty;
- /**
- * true if the frustum planes have been normalized.
- */
- bool m_normalized;
-
- /**
- * View Frustum clip planes.
- */
- MT_Vector4 m_planes[6];
-
- /**
- * This camera is frustum culling.
- * Some cameras (ie if the game was started from a non camera view should not cull.)
- */
- bool m_frustum_culling;
-
- /**
- * true if this camera has a valid projection matrix.
- */
- bool m_set_projection_matrix;
-
- /**
- * The center point of the frustum.
- */
- MT_Point3 m_frustum_center;
- MT_Scalar m_frustum_radius;
- bool m_set_frustum_center;
-
- /**
- * whether the camera should delete the node itself (only for shadow camera)
- */
- bool m_delete_node;
-
- /**
- * Extracts the camera clip frames from the projection and world-to-camera matrices.
- */
- void ExtractClipPlanes();
- /**
- * Normalize the camera clip frames.
- */
- void NormalizeClipPlanes();
- /**
- * Extracts the bound sphere of the view frustum.
- */
- void ExtractFrustumSphere();
- /**
- * return the clip plane
- */
- MT_Vector4 *GetNormalizedClipPlanes()
- {
- ExtractClipPlanes();
- NormalizeClipPlanes();
- return m_planes;
- }
-
-public:
-
- enum { INSIDE, INTERSECT, OUTSIDE };
-
- KX_Camera(void* sgReplicationInfo,SG_Callbacks callbacks,const RAS_CameraData& camdata, bool frustum_culling = true, bool delete_node = false);
- virtual ~KX_Camera();
-
- /**
- * Inherited from CValue -- return a new copy of this
- * instance allocated on the heap. Ownership of the new
- * object belongs with the caller.
- */
- virtual CValue*
- GetReplica(
- );
- virtual void ProcessReplica();
-
- MT_Transform GetWorldToCamera() const;
- MT_Transform GetCameraToWorld() const;
-
- /**
- * Not implemented.
- */
- void CorrectLookUp(MT_Scalar speed);
- const MT_Point3 GetCameraLocation() const;
-
- /* I want the camera orientation as well. */
- const MT_Quaternion GetCameraOrientation() const;
-
- /** Sets the projection matrix that is used by the rasterizer. */
- void SetProjectionMatrix(const MT_Matrix4x4 & mat);
-
- /** Sets the modelview matrix that is used by the rasterizer. */
- void SetModelviewMatrix(const MT_Matrix4x4 & mat);
-
- /** Gets the projection matrix that is used by the rasterizer. */
- const MT_Matrix4x4& GetProjectionMatrix() const;
-
- /** returns true if this camera has been set a projection matrix. */
- bool hasValidProjectionMatrix() const;
-
- /** Sets the validity of the projection matrix. Call this if you change camera
- * data (eg lens, near plane, far plane) and require the projection matrix to be
- * recalculated.
- */
- void InvalidateProjectionMatrix(bool valid = false);
-
- /** Gets the modelview matrix that is used by the rasterizer.
- * \warning If the Camera is a dynamic object then this method may return garbage. Use GetWorldToCamera() instead.
- */
- const MT_Matrix4x4& GetModelviewMatrix() const;
-
- /** Gets the aperture. */
- float GetLens() const;
- /** Gets the ortho scale. */
- float GetScale() const;
- /** Gets the horizontal size of the sensor - for camera matching */
- float GetSensorWidth() const;
- /** Gets the vertical size of the sensor - for camera matching */
- float GetSensorHeight() const;
- /** Gets the mode FOV is calculating from sensor dimensions */
- short GetSensorFit() const;
- /** Gets the horizontal shift of the sensor - for camera matching */
- float GetShiftHorizontal() const;
- /** Gets the vertical shift of the sensor - for camera matching */
- float GetShiftVertical() const;
- /** Gets the near clip distance. */
- float GetCameraNear() const;
- /** Gets the far clip distance. */
- float GetCameraFar() const;
- /** Gets the focal length (only used for stereo rendering) */
- float GetFocalLength() const;
- /** Gets all camera data. */
- RAS_CameraData* GetCameraData();
-
- /**
- * Tests if the given sphere is inside this camera's view frustum.
- *
- * \param center The center of the sphere, in world coordinates.
- * \param radius The radius of the sphere.
- * \return INSIDE, INTERSECT, or OUTSIDE depending on the sphere's relation to the frustum.
- */
- int SphereInsideFrustum(const MT_Point3& center, const MT_Scalar &radius);
- /**
- * Tests the given eight corners of a box with the view frustum.
- *
- * \param box a pointer to eight MT_Point3 representing the world coordinates of the corners of the box.
- * \return INSIDE, INTERSECT, or OUTSIDE depending on the box's relation to the frustum.
- */
- int BoxInsideFrustum(const MT_Point3 *box);
- /**
- * Tests the given point against the view frustum.
- * \return true if the given point is inside or on the view frustum; false if it is outside.
- */
- bool PointInsideFrustum(const MT_Point3& x);
-
- /**
- * Gets this camera's culling status.
- */
- bool GetFrustumCulling() const;
-
- /**
- * Sets this camera's viewport status.
- */
- void EnableViewport(bool viewport);
-
- /**
- * Sets this camera's viewport.
- */
- void SetViewport(int left, int bottom, int right, int top);
-
- /**
- * Gets this camera's viewport status.
- */
- bool GetViewport() const;
-
- /**
- * Gets this camera's viewport left.
- */
- int GetViewportLeft() const;
-
- /**
- * Gets this camera's viewport bottom.
- */
- int GetViewportBottom() const;
-
- /**
- * Gets this camera's viewport right.
- */
- int GetViewportRight() const;
-
- /**
- * Gets this camera's viewport top.
- */
- int GetViewportTop() const;
-
- virtual int GetGameObjectType() { return OBJ_CAMERA; }
-
-#ifdef WITH_PYTHON
- KX_PYMETHOD_DOC_VARARGS(KX_Camera, sphereInsideFrustum);
- KX_PYMETHOD_DOC_O(KX_Camera, boxInsideFrustum);
- KX_PYMETHOD_DOC_O(KX_Camera, pointInsideFrustum);
-
- KX_PYMETHOD_DOC_NOARGS(KX_Camera, getCameraToWorld);
- KX_PYMETHOD_DOC_NOARGS(KX_Camera, getWorldToCamera);
-
- KX_PYMETHOD_DOC_VARARGS(KX_Camera, setViewport);
- KX_PYMETHOD_DOC_NOARGS(KX_Camera, setOnTop);
-
- KX_PYMETHOD_DOC_O(KX_Camera, getScreenPosition);
- KX_PYMETHOD_DOC_VARARGS(KX_Camera, getScreenVect);
- KX_PYMETHOD_DOC_VARARGS(KX_Camera, getScreenRay);
-
- static PyObject* pyattr_get_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static PyObject* pyattr_get_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_fov(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_fov(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_shift_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_shift_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_shift_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_shift_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static PyObject* pyattr_get_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static PyObject* pyattr_get_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static PyObject* pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_camera_to_world(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_world_to_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- static PyObject* pyattr_get_INSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_OUTSIDE(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_INTERSECT(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-#endif
-};
-
-#endif /* __KX_CAMERA_H__ */
diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp
deleted file mode 100644
index e488bf3c30a..00000000000
--- a/source/gameengine/Ketsji/KX_CameraActuator.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * KX_CameraActuator.cpp
- *
- *
- * ***** 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_CameraActuator.cpp
- * \ingroup ketsji
- */
-
-#include "BLI_math_vector.h"
-
-#include "KX_CameraActuator.h"
-#include <math.h>
-#include <float.h>
-#include "KX_GameObject.h"
-
-#include "EXP_PyObjectPlus.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_CameraActuator::KX_CameraActuator(
- SCA_IObject* gameobj,
- SCA_IObject *obj,
- float hght,
- float minhght,
- float maxhght,
- short axis,
- float damping
-):
- SCA_IActuator(gameobj, KX_ACT_CAMERA),
- m_ob (obj),
- m_height (hght),
- m_minHeight (minhght),
- m_maxHeight (maxhght),
- m_axis(axis),
- m_damping (damping)
-{
- if (m_ob)
- m_ob->RegisterActuator(this);
-}
-
-KX_CameraActuator::~KX_CameraActuator()
-{
- if (m_ob)
- m_ob->UnregisterActuator(this);
-}
-
- CValue*
-KX_CameraActuator::
-GetReplica(
-) {
- KX_CameraActuator* replica = new KX_CameraActuator(*this);
- replica->ProcessReplica();
- return replica;
-};
-
-void KX_CameraActuator::ProcessReplica()
-{
- if (m_ob)
- m_ob->RegisterActuator(this);
- SCA_IActuator::ProcessReplica();
-}
-
-bool KX_CameraActuator::UnlinkObject(SCA_IObject* clientobj)
-{
- if (clientobj == m_ob)
- {
- // this object is being deleted, we cannot continue to track it.
- m_ob = NULL;
- return true;
- }
- return false;
-}
-
-
-void KX_CameraActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_ob];
- if (h_obj) {
- if (m_ob)
- m_ob->UnregisterActuator(this);
- m_ob = (SCA_IObject*)(*h_obj);
- m_ob->RegisterActuator(this);
- }
-}
-
-/* copied from blender BLI_math ... don't know if there's an equivalent */
-
-static void Kx_VecUpMat3(float vec[3], float mat[3][3], short axis)
-{
-
- // Construct a camera matrix s.t. the specified axis
-
- // maps to the given vector (*vec). Also defines the rotation
-
- // about this axis by mapping one of the other axis to the y-axis.
-
-
- float inp;
- short cox = 0, coy = 0, coz = 0;
-
- /* up range has no meaning, is not really up!
- * see: VecUpMat3old
- */
-
- if (axis==0) {
- cox= 0; coy= 1; coz= 2; /* Y up Z tr */
- }
- if (axis==1) {
- cox= 1; coy= 2; coz= 0; /* Z up X tr */
- }
- if (axis==2) {
- cox= 2; coy= 0; coz= 1; /* X up Y tr */
- }
- if (axis==3) {
- cox= 0; coy= 1; coz= 2; /* Y op -Z tr */
- vec[0] = -vec[0];
- vec[1] = -vec[1];
- vec[2] = -vec[2];
- }
- if (axis==4) {
- cox= 1; coy= 0; coz= 2; /* */
- }
- if (axis==5) {
- cox= 2; coy= 1; coz= 0; /* Y up X tr */
- }
-
- mat[coz][0] = vec[0];
- mat[coz][1] = vec[1];
- mat[coz][2] = vec[2];
- if (normalize_v3((float *)mat[coz]) == 0.f) {
- /* this is a very abnormal situation: the camera has reach the object center exactly
- * We will choose a completely arbitrary direction */
- mat[coz][0] = 1.0f;
- mat[coz][1] = 0.0f;
- mat[coz][2] = 0.0f;
- }
-
- inp = mat[coz][2];
- mat[coy][0] = - inp * mat[coz][0];
- mat[coy][1] = - inp * mat[coz][1];
- mat[coy][2] = 1.0f - inp * mat[coz][2];
-
- if (normalize_v3((float *)mat[coy]) == 0.f) {
- /* the camera is vertical, chose the y axis arbitrary */
- mat[coy][0] = 0.f;
- mat[coy][1] = 1.f;
- mat[coy][2] = 0.f;
- }
-
- cross_v3_v3v3(mat[cox], mat[coy], mat[coz]);
-}
-
-bool KX_CameraActuator::Update(double curtime, bool frame)
-{
- /* wondering... is it really necessary/desirable to suppress negative */
- /* events here? */
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent || !m_ob)
- return false;
-
- KX_GameObject *obj = (KX_GameObject*) GetParent();
- MT_Point3 from = obj->NodeGetWorldPosition();
- MT_Matrix3x3 frommat = obj->NodeGetWorldOrientation();
- /* These casts are _very_ dangerous!!! */
- MT_Point3 lookat = ((KX_GameObject*)m_ob)->NodeGetWorldPosition();
- MT_Matrix3x3 actormat = ((KX_GameObject*)m_ob)->NodeGetWorldOrientation();
-
- float fp1[3]={0}, fp2[3]={0}, rc[3];
- float inp, fac; //, factor = 0.0; /* some factor... */
- float mindistsq, maxdistsq, distsq;
- float mat[3][3];
-
- /* The rules: */
- /* CONSTRAINT 1: not implemented */
- /* CONSTRAINT 2: can camera see actor? */
- /* CONSTRAINT 3: fixed height relative to floor below actor. */
- /* CONSTRAINT 4: camera rotates behind actor */
- /* CONSTRAINT 5: minimum / maximum distance */
- /* CONSTRAINT 6: again: fixed height relative to floor below actor */
- /* CONSTRAINT 7: track to floor below actor */
- /* CONSTRAINT 8: look a little bit left or right, depending on how the
- *
- * character is looking (horizontal x)
- */
-
- /* ...and then set the camera position. Since we assume the parent of */
- /* this actuator is always a camera, just set the parent position and */
- /* rotation. We do not check whether we really have a camera as parent. */
- /* It may be better to turn this into a general tracking actuator later */
- /* on, since lots of plausible relations can be filled in here. */
-
- /* ... set up some parameters ... */
- /* missing here: the 'floorloc' of the actor's shadow */
-
- mindistsq= m_minHeight*m_minHeight;
- maxdistsq= m_maxHeight*m_maxHeight;
-
- /* C1: not checked... is a future option */
-
- /* C2: blender test_visibility function. Can this be a ray-test? */
-
- /* C3: fixed height */
- from[2] = (15.0f * from[2] + lookat[2] + m_height) / 16.0f;
-
-
- /* C4: camera behind actor */
- switch (m_axis) {
- case OB_POSX:
- /* X */
- fp1[0] = actormat[0][0];
- fp1[1] = actormat[1][0];
- fp1[2] = actormat[2][0];
-
- fp2[0] = frommat[0][0];
- fp2[1] = frommat[1][0];
- fp2[2] = frommat[2][0];
- break;
- case OB_POSY:
- /* Y */
- fp1[0] = actormat[0][1];
- fp1[1] = actormat[1][1];
- fp1[2] = actormat[2][1];
-
- fp2[0] = frommat[0][1];
- fp2[1] = frommat[1][1];
- fp2[2] = frommat[2][1];
- break;
- case OB_NEGX:
- /* -X */
- fp1[0] = -actormat[0][0];
- fp1[1] = -actormat[1][0];
- fp1[2] = -actormat[2][0];
-
- fp2[0] = frommat[0][0];
- fp2[1] = frommat[1][0];
- fp2[2] = frommat[2][0];
- break;
- case OB_NEGY:
- /* -Y */
- fp1[0] = -actormat[0][1];
- fp1[1] = -actormat[1][1];
- fp1[2] = -actormat[2][1];
-
- fp2[0] = frommat[0][1];
- fp2[1] = frommat[1][1];
- fp2[2] = frommat[2][1];
- break;
- default:
- assert(0);
- break;
- }
-
- inp = fp1[0]*fp2[0] + fp1[1]*fp2[1] + fp1[2]*fp2[2];
- fac = (-1.0f + inp) * m_damping;
-
- from[0] += fac * fp1[0];
- from[1] += fac * fp1[1];
- from[2] += fac * fp1[2];
-
- /* only for it lies: cross test and perpendicular bites up */
- if (inp < 0.0f) {
- /* Don't do anything if the cross product is too small.
- * The camera up-axis becomes unstable and starts to oscillate.
- * The 0.01f threshold is arbitrary but seems to work well in practice. */
- float cross = fp1[0] * fp2[1] - fp1[1] * fp2[0];
- if (cross > 0.01f) {
- from[0] -= fac * fp1[1];
- from[1] += fac * fp1[0];
- }
- else if (cross < -0.01f) {
- from[0] += fac * fp1[1];
- from[1] -= fac * fp1[0];
- }
- }
-
- /* CONSTRAINT 5: minimum / maximum distance */
-
- rc[0] = (lookat[0]-from[0]);
- rc[1] = (lookat[1]-from[1]);
- rc[2] = (lookat[2]-from[2]);
- distsq = rc[0]*rc[0] + rc[1]*rc[1] + rc[2]*rc[2];
-
- if (distsq > maxdistsq) {
- distsq = 0.15f * (distsq - maxdistsq) / distsq;
-
- from[0] += distsq*rc[0];
- from[1] += distsq*rc[1];
- from[2] += distsq*rc[2];
- }
- else if (distsq < mindistsq) {
- distsq = 0.15f * (mindistsq - distsq) / mindistsq;
-
- from[0] -= distsq*rc[0];
- from[1] -= distsq*rc[1];
- from[2] -= distsq*rc[2];
- }
-
-
- /* CONSTRAINT 7: track to floor below actor */
- rc[0] = (lookat[0]-from[0]);
- rc[1] = (lookat[1]-from[1]);
- rc[2] = (lookat[2]-from[2]);
- Kx_VecUpMat3(rc, mat, 3); /* y up Track -z */
-
-
-
-
- /* now set the camera position and rotation */
-
- obj->NodeSetLocalPosition(from);
-
- actormat[0][0] = mat[0][0]; actormat[0][1] = mat[1][0]; actormat[0][2] = mat[2][0];
- actormat[1][0] = mat[0][1]; actormat[1][1] = mat[1][1]; actormat[1][2] = mat[2][1];
- actormat[2][0] = mat[0][2]; actormat[2][1] = mat[1][2]; actormat[2][2] = mat[2][2];
- obj->NodeSetLocalOrientation(actormat);
-
- return true;
-}
-
-CValue *KX_CameraActuator::findObject(const char *obName)
-{
- /* hook to object system */
- return NULL;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_CameraActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_CameraActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_CameraActuator::Methods[] = {
- {NULL, NULL} //Sentinel
-};
-
-PyAttributeDef KX_CameraActuator::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RW("min",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_minHeight),
- KX_PYATTRIBUTE_FLOAT_RW("max",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_maxHeight),
- KX_PYATTRIBUTE_FLOAT_RW("height",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_height),
- KX_PYATTRIBUTE_SHORT_RW("axis", 0, 5, true, KX_CameraActuator, m_axis),
- KX_PYATTRIBUTE_RW_FUNCTION("object", KX_CameraActuator, pyattr_get_object, pyattr_set_object),
- KX_PYATTRIBUTE_FLOAT_RW("damping",0.f,10.f,KX_CameraActuator,m_damping),
- {NULL}
-};
-
-PyObject *KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_CameraActuator* self = static_cast<KX_CameraActuator*>(self_v);
- if (self->m_ob==NULL)
- Py_RETURN_NONE;
- else
- return self->m_ob->GetProxy();
-}
-
-int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_CameraActuator* self = static_cast<KX_CameraActuator*>(self_v);
- KX_GameObject *gameobj;
-
- if (!ConvertPythonToGameObject(self->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_CameraActuator"))
- return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
-
- if (self->m_ob)
- self->m_ob->UnregisterActuator(self);
-
- if ((self->m_ob = (SCA_IObject*)gameobj))
- self->m_ob->RegisterActuator(self);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h
deleted file mode 100644
index fb0a7d88dd9..00000000000
--- a/source/gameengine/Ketsji/KX_CameraActuator.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * KX_CameraActuator.h
- *
- *
- * ***** 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_CameraActuator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_CAMERAACTUATOR_H__
-#define __KX_CAMERAACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "MT_Scalar.h"
-#include "SCA_LogicManager.h"
-
-/**
- * The camera actuator does a Robbie Muller perspective for you. This is a
- * weird set of rules that positions the camera sort of behind the object,
- * tracking, while avoiding any objects between the 'ideal' position and the
- * actor being tracked.
- */
-
-
-class KX_CameraActuator : public SCA_IActuator
-{
- Py_Header
-private :
- /** Object that will be tracked. */
- SCA_IObject *m_ob;
-
- /** height (float), */
- //const MT_Scalar m_height;
- /** min (float), */
- //const MT_Scalar m_minHeight;
- /** max (float), */
- //const MT_Scalar m_maxHeight;
-
- /** height (float), */
- float m_height;
-
- /** min (float), */
- float m_minHeight;
-
- /** max (float), */
- float m_maxHeight;
-
- /** axis the camera tries to get behind: +x/+y/-x/-y */
- short m_axis;
-
- /** damping (float), */
- float m_damping;
-
- /* get the KX_IGameObject with this name */
- CValue *findObject(const char *obName);
-
- /* parse x or y to a toggle pick */
- bool string2axischoice(const char *axisString);
-
- public:
- static STR_String X_AXIS_STRING;
- static STR_String Y_AXIS_STRING;
-
- /**
- * Set the bool toggle to true to use x lock, false for y lock
- */
- KX_CameraActuator(
-
- SCA_IObject *gameobj,
- //const CValue *ob,
- SCA_IObject *ob,
- float hght,
- float minhght,
- float maxhght,
- short axis,
- float damping
- );
-
-
- ~KX_CameraActuator();
-
-
-
- /** Methods Inherited from CValue */
- CValue* GetReplica();
- virtual void ProcessReplica();
-
-
- /** Methods inherited from SCA_IActuator */
- virtual bool Update(
- double curtime,
- bool frame
- );
- virtual bool UnlinkObject(SCA_IObject* clientobj);
-
- /** Methods inherited from SCA_ILogicBrick */
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- /* set object to look at */
- static PyObject* pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
-#endif /* WITH_PYTHON */
-
-};
-
-#endif /* __KX_CAMERAACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp b/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp
deleted file mode 100644
index a1c726209e1..00000000000
--- a/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp
+++ /dev/null
@@ -1,126 +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_CameraIpoSGController.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_CameraIpoSGController.h"
-#include "KX_ScalarInterpolator.h"
-#include "KX_Camera.h"
-#include "RAS_CameraData.h"
-
-#if defined(_WIN64)
-typedef unsigned __int64 uint_ptr;
-#else
-typedef unsigned long uint_ptr;
-#endif
-
-bool KX_CameraIpoSGController::Update(double currentTime)
-{
- if (m_modified)
- {
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- (*i)->Execute(m_ipotime);
- }
-
- SG_Spatial* ob = (SG_Spatial*)m_pObject;
- KX_Camera* kxcamera = (KX_Camera*) ob->GetSGClientObject();
- RAS_CameraData* camdata = kxcamera->GetCameraData();
-
- if (m_modify_lens)
- camdata->m_lens = m_lens;
-
- if (m_modify_clipstart )
- camdata->m_clipstart = m_clipstart;
-
- if (m_modify_clipend)
- camdata->m_clipend = m_clipend;
-
- if (m_modify_lens || m_modify_clipstart || m_modify_clipend)
- kxcamera->InvalidateProjectionMatrix();
-
- m_modified=false;
- }
- return false;
-}
-
-
-void KX_CameraIpoSGController::AddInterpolator(KX_IInterpolator* interp)
-{
- this->m_interpolators.push_back(interp);
-}
-
-SG_Controller* KX_CameraIpoSGController::GetReplica(class SG_Node* destnode)
-{
- KX_CameraIpoSGController* iporeplica = new KX_CameraIpoSGController(*this);
- // clear object that ipo acts on
- iporeplica->ClearObject();
-
- // dirty hack, ask Gino for a better solution in the ipo implementation
- // hacken en zagen, in what we call datahiding, not written for replication :(
-
- T_InterpolatorList oldlist = m_interpolators;
- iporeplica->m_interpolators.clear();
-
- T_InterpolatorList::iterator i;
- for (i = oldlist.begin(); !(i == oldlist.end()); ++i) {
- KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i));
- iporeplica->AddInterpolator(copyipo);
-
- MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
- uint_ptr orgbase = (uint_ptr)this;
- uint_ptr orgloc = (uint_ptr)scaal;
- uint_ptr offset = orgloc-orgbase;
- uint_ptr newaddrbase = (uint_ptr)iporeplica + offset;
- MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
- copyipo->SetNewTarget((MT_Scalar*)blaptr);
- }
-
- return iporeplica;
-}
-
-KX_CameraIpoSGController::~KX_CameraIpoSGController()
-{
-
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- delete (*i);
- }
-
-}
-
- void
-KX_CameraIpoSGController::SetOption(
- int option,
- int value)
-{
- /* Setting options */
-
-}
diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.h b/source/gameengine/Ketsji/KX_CameraIpoSGController.h
deleted file mode 100644
index 1f6f211622c..00000000000
--- a/source/gameengine/Ketsji/KX_CameraIpoSGController.h
+++ /dev/null
@@ -1,97 +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_CameraIpoSGController.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_CAMERAIPOSGCONTROLLER_H__
-#define __KX_CAMERAIPOSGCONTROLLER_H__
-
-#include "SG_Controller.h"
-#include "SG_Spatial.h"
-
-#include "KX_IInterpolator.h"
-
-struct RAS_CameraData;
-
-class KX_CameraIpoSGController : public SG_Controller
-{
-public:
- MT_Scalar m_lens;
- MT_Scalar m_clipstart;
- MT_Scalar m_clipend;
-
-private:
- T_InterpolatorList m_interpolators;
- unsigned short m_modify_lens : 1;
- unsigned short m_modify_clipstart : 1;
- unsigned short m_modify_clipend : 1;
- bool m_modified;
-
- double m_ipotime;
-public:
- KX_CameraIpoSGController() :
- m_modify_lens(false),
- m_modify_clipstart(false),
- m_modify_clipend(false),
- m_modified(true),
- m_ipotime(0.0)
- {}
-
- ~KX_CameraIpoSGController();
- SG_Controller* GetReplica(class SG_Node* destnode);
- bool Update(double time);
-
- void
- SetOption(
- int option,
- int value
- );
-
- void SetSimulatedTime(double time) {
- m_ipotime = time;
- m_modified = true;
- }
- void SetModifyLens(bool modify) {
- m_modify_lens = modify;
- }
- void SetModifyClipEnd(bool modify) {
- m_modify_clipend = modify;
- }
- void SetModifyClipStart(bool modify) {
- m_modify_clipstart = modify;
- }
- void AddInterpolator(KX_IInterpolator* interp);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_CameraIpoSGController")
-#endif
-};
-
-#endif /* __KX_CAMERAIPOSGCONTROLLER_H__ */
diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
deleted file mode 100644
index 44f06a9f1eb..00000000000
--- a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp
+++ /dev/null
@@ -1,167 +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_CharacterWrapper.cpp
- * \ingroup ketsji
- */
-
-#include "KX_CharacterWrapper.h"
-#include "PHY_ICharacter.h"
-#include "KX_PyMath.h"
-#include "BLI_utildefines.h"
-
-KX_CharacterWrapper::KX_CharacterWrapper(PHY_ICharacter* character) :
- PyObjectPlus(),
- m_character(character)
-{
-}
-
-KX_CharacterWrapper::~KX_CharacterWrapper()
-{
-}
-
-#ifdef WITH_PYTHON
-
-PyTypeObject KX_CharacterWrapper::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_CharacterWrapper",
- 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
-};
-
-PyAttributeDef KX_CharacterWrapper::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("onGround", KX_CharacterWrapper, pyattr_get_onground),
- KX_PYATTRIBUTE_RW_FUNCTION("gravity", KX_CharacterWrapper, pyattr_get_gravity, pyattr_set_gravity),
- KX_PYATTRIBUTE_RW_FUNCTION("maxJumps", KX_CharacterWrapper, pyattr_get_max_jumps, pyattr_set_max_jumps),
- KX_PYATTRIBUTE_RO_FUNCTION("jumpCount", KX_CharacterWrapper, pyattr_get_jump_count),
- KX_PYATTRIBUTE_RW_FUNCTION("walkDirection", KX_CharacterWrapper, pyattr_get_walk_dir, pyattr_set_walk_dir),
- { NULL } //Sentinel
-};
-
-PyObject *KX_CharacterWrapper::pyattr_get_onground(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
-
- return PyBool_FromLong(self->m_character->OnGround());
-}
-
-PyObject *KX_CharacterWrapper::pyattr_get_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
-
- return PyFloat_FromDouble(self->m_character->GetGravity());
-}
-
-int KX_CharacterWrapper::pyattr_set_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
- double param = PyFloat_AsDouble(value);
-
- if (param == -1)
- {
- PyErr_SetString(PyExc_ValueError, "KX_CharacterWrapper.gravity: expected a float");
- return PY_SET_ATTR_FAIL;
- }
-
- self->m_character->SetGravity((float)param);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_CharacterWrapper::pyattr_get_max_jumps(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
-
- return PyLong_FromLong(self->m_character->GetMaxJumps());
-}
-
-int KX_CharacterWrapper::pyattr_set_max_jumps(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
- long param = PyLong_AsLong(value);
-
- if (param == -1)
- {
- PyErr_SetString(PyExc_ValueError, "KX_CharacterWrapper.maxJumps: expected an integer");
- return PY_SET_ATTR_FAIL;
- }
-
- CLAMP(param, 0, 255);
-
- self->m_character->SetMaxJumps(param);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_CharacterWrapper::pyattr_get_jump_count(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
-
- return PyLong_FromLong(self->m_character->GetJumpCount());
-}
-
-PyObject *KX_CharacterWrapper::pyattr_get_walk_dir(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
-
- return PyObjectFrom(self->m_character->GetWalkDirection());
-}
-
-int KX_CharacterWrapper::pyattr_set_walk_dir(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_CharacterWrapper* self = static_cast<KX_CharacterWrapper*>(self_v);
- MT_Vector3 dir;
- if (!PyVecTo(value, dir)) {
- PyErr_SetString(PyExc_TypeError, "KX_CharacterWrapper.walkDirection: expected a vector");
- return PY_SET_ATTR_FAIL;
- }
-
- self->m_character->SetWalkDirection(dir);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyMethodDef KX_CharacterWrapper::Methods[] = {
- KX_PYMETHODTABLE_NOARGS(KX_CharacterWrapper, jump),
- {NULL,NULL} //Sentinel
-};
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_CharacterWrapper, jump,
- "jump()\n"
- "makes the character jump.\n")
-{
- m_character->Jump();
-
- Py_RETURN_NONE;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.h b/source/gameengine/Ketsji/KX_CharacterWrapper.h
deleted file mode 100644
index dd7ba680ec7..00000000000
--- a/source/gameengine/Ketsji/KX_CharacterWrapper.h
+++ /dev/null
@@ -1,40 +0,0 @@
-
-/** \file KX_CharacterWrapper.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_CHARACTERWRAPPER_H__
-#define __KX_CHARACTERWRAPPER_H__
-
-#include "EXP_Value.h"
-#include "PHY_DynamicTypes.h"
-class PHY_ICharacter;
-
-
-///Python interface to character physics
-class KX_CharacterWrapper : public PyObjectPlus
-{
- Py_Header
-
-public:
- KX_CharacterWrapper(PHY_ICharacter* character);
- virtual ~KX_CharacterWrapper();
-#ifdef WITH_PYTHON
- KX_PYMETHOD_DOC_NOARGS(KX_CharacterWrapper, jump);
-
- static PyObject* pyattr_get_onground(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- static PyObject* pyattr_get_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_max_jumps(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_max_jumps(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_jump_count(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_walk_dir(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_walk_dir(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif // WITH_PYTHON
-
-private:
- PHY_ICharacter* m_character;
-};
-
-#endif /* __KX_CHARACTERWRAPPER_H__ */
diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h
deleted file mode 100644
index 81ae5b58009..00000000000
--- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h
+++ /dev/null
@@ -1,84 +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_ClientObjectInfo.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_CLIENTOBJECTINFO_H__
-#define __KX_CLIENTOBJECTINFO_H__
-
-/* Note, the way this works with/without sumo is a bit odd */
-
-#include <list>
-
-class SCA_ISensor;
-class KX_GameObject;
-/**
- * Client Type and Additional Info. This structure can be use instead of a bare void* pointer, for safeness, and additional info for callbacks
- */
-struct KX_ClientObjectInfo
-{
- enum clienttype {
- STATIC,
- ACTOR,
- RESERVED1,
- SENSOR,
- OBSENSOR,
- OBACTORSENSOR
- } m_type;
- KX_GameObject* m_gameobject;
- std::list<SCA_ISensor*> m_sensors;
-public:
- KX_ClientObjectInfo(KX_GameObject *gameobject, clienttype type = STATIC) :
- m_type(type),
- m_gameobject(gameobject)
- {}
-
- KX_ClientObjectInfo(const KX_ClientObjectInfo &copy) :
- m_type(copy.m_type),
- m_gameobject(copy.m_gameobject)
- {
- }
-
- virtual ~KX_ClientObjectInfo() {}
-
- virtual bool hasCollisionCallback()
- {
- return m_sensors.size() != 0;
- }
-
- bool isActor() { return m_type <= ACTOR; }
- bool isSensor() { return m_type >= SENSOR && m_type <= OBACTORSENSOR; }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ClientObjectInfo")
-#endif
-};
-
-#endif /* __KX_CLIENTOBJECTINFO_H__ */
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
deleted file mode 100644
index 27c074393b4..00000000000
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
+++ /dev/null
@@ -1,629 +0,0 @@
-/*
- * Apply a constraint to a position or rotation value
- *
- *
- * ***** 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_ConstraintActuator.cpp
- * \ingroup ketsji
- */
-
-
-#include "SCA_IActuator.h"
-#include "KX_ConstraintActuator.h"
-#include "SCA_IObject.h"
-#include "MT_Point3.h"
-#include "MT_Matrix3x3.h"
-#include "KX_GameObject.h"
-#include "KX_RayCast.h"
-#include "KX_PythonInit.h" // KX_GetActiveScene
-#include "RAS_MeshObject.h"
-
-#include <stdio.h>
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj,
- int posDampTime,
- int rotDampTime,
- float minBound,
- float maxBound,
- float refDir[3],
- int locrotxyz,
- int time,
- int option,
- char *property) :
- SCA_IActuator(gameobj, KX_ACT_CONSTRAINT),
- m_refDirVector(refDir),
- m_currentTime(0)
-{
- m_refDirection[0] = refDir[0];
- m_refDirection[1] = refDir[1];
- m_refDirection[2] = refDir[2];
- m_posDampTime = posDampTime;
- m_rotDampTime = rotDampTime;
- m_locrot = locrotxyz;
- m_option = option;
- m_activeTime = time;
- if (property) {
- m_property = property;
- } else {
- m_property = "";
- }
- /* The units of bounds are determined by the type of constraint. To */
- /* make the constraint application easier and more transparent later on, */
- /* I think converting the bounds to the applicable domain makes more */
- /* sense. */
- switch (m_locrot) {
- case KX_ACT_CONSTRAINT_ORIX:
- case KX_ACT_CONSTRAINT_ORIY:
- case KX_ACT_CONSTRAINT_ORIZ:
- {
- MT_Scalar len = m_refDirVector.length();
- if (MT_fuzzyZero(len)) {
- // missing a valid direction
- std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no valid reference direction!" << std::endl;
- m_locrot = KX_ACT_CONSTRAINT_NODEF;
- } else {
- m_refDirection[0] /= len;
- m_refDirection[1] /= len;
- m_refDirection[2] /= len;
- m_refDirVector /= len;
- }
- m_minimumBound = cosf(minBound);
- m_maximumBound = cosf(maxBound);
- m_minimumSine = sinf(minBound);
- m_maximumSine = sinf(maxBound);
- }
- break;
- default:
- m_minimumBound = minBound;
- m_maximumBound = maxBound;
- m_minimumSine = 0.f;
- m_maximumSine = 0.f;
- break;
- }
-
-} /* End of constructor */
-
-KX_ConstraintActuator::~KX_ConstraintActuator()
-{
- // there's nothing to be done here, really....
-} /* end of destructor */
-
-bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void *UNUSED(data))
-{
-
- m_hitObject = client->m_gameobject;
-
- bool bFound = false;
-
- if (m_property.IsEmpty())
- {
- bFound = true;
- }
- else
- {
- if (m_option & KX_ACT_CONSTRAINT_MATERIAL) {
- for (unsigned int i = 0; i < m_hitObject->GetMeshCount(); ++i) {
- RAS_MeshObject *meshObj = m_hitObject->GetMesh(i);
- for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
- bFound = strcmp(m_property.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
- if (bFound)
- break;
- }
- }
- }
- else {
- bFound = m_hitObject->GetProperty(m_property) != NULL;
- }
- }
- // update the hit status
- result->m_hitFound = bFound;
- // stop looking
- return true;
-}
-
-/* This function is used to pre-filter the object before casting the ray on them.
- * This is useful for "X-Ray" option when we want to see "through" unwanted object.
- */
-bool KX_ConstraintActuator::NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data))
-{
- if (client->m_type > KX_ClientObjectInfo::ACTOR)
- {
- // Unknown type of object, skip it.
- // Should not occur as the sensor objects are filtered in RayTest()
- printf("Invalid client type %d found in ray casting\n", client->m_type);
- return false;
- }
- // no X-Ray function yet
- return true;
-}
-
-bool KX_ConstraintActuator::Update(double curtime, bool frame)
-{
-
- bool result = false;
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (!bNegativeEvent) {
- /* Constraint clamps the values to the specified range, with a sort of */
- /* low-pass filtered time response, if the damp time is unequal to 0. */
-
- /* Having to retrieve location/rotation and setting it afterwards may not */
- /* be efficient enough... Something to look at later. */
- KX_GameObject *obj = (KX_GameObject*) GetParent();
- MT_Point3 position = obj->NodeGetWorldPosition();
- MT_Point3 newposition;
- MT_Vector3 normal, direction, refDirection;
- MT_Matrix3x3 rotation = obj->NodeGetWorldOrientation();
- MT_Scalar filter, newdistance, cosangle;
- int axis, sign;
-
- if (m_posDampTime) {
- filter = m_posDampTime/(1.0f+m_posDampTime);
- } else {
- filter = 0.0f;
- }
- switch (m_locrot) {
- case KX_ACT_CONSTRAINT_ORIX:
- case KX_ACT_CONSTRAINT_ORIY:
- case KX_ACT_CONSTRAINT_ORIZ:
- switch (m_locrot) {
- case KX_ACT_CONSTRAINT_ORIX:
- direction[0] = rotation[0][0];
- direction[1] = rotation[1][0];
- direction[2] = rotation[2][0];
- axis = 0;
- break;
- case KX_ACT_CONSTRAINT_ORIY:
- direction[0] = rotation[0][1];
- direction[1] = rotation[1][1];
- direction[2] = rotation[2][1];
- axis = 1;
- break;
- default:
- direction[0] = rotation[0][2];
- direction[1] = rotation[1][2];
- direction[2] = rotation[2][2];
- axis = 2;
- break;
- }
- if ((m_maximumBound < (1.0f-FLT_EPSILON)) || (m_minimumBound < (1.0f-FLT_EPSILON))) {
- // reference direction needs to be evaluated
- // 1. get the cosine between current direction and target
- cosangle = direction.dot(m_refDirVector);
- if (cosangle >= (m_maximumBound-FLT_EPSILON) && cosangle <= (m_minimumBound+FLT_EPSILON)) {
- // no change to do
- result = true;
- goto CHECK_TIME;
- }
- // 2. define a new reference direction
- // compute local axis with reference direction as X and
- // Y in direction X refDirection plane
- MT_Vector3 zaxis = m_refDirVector.cross(direction);
- if (MT_fuzzyZero2(zaxis.length2())) {
- // direction and refDirection are identical,
- // choose any other direction to define plane
- if (direction[0] < 0.9999f)
- zaxis = m_refDirVector.cross(MT_Vector3(1.0f,0.0f,0.0f));
- else
- zaxis = m_refDirVector.cross(MT_Vector3(0.0f,1.0f,0.0f));
- }
- MT_Vector3 yaxis = zaxis.cross(m_refDirVector);
- yaxis.normalize();
- if (cosangle > m_minimumBound) {
- // angle is too close to reference direction,
- // choose a new reference that is exactly at minimum angle
- refDirection = m_minimumBound * m_refDirVector + m_minimumSine * yaxis;
- } else {
- // angle is too large, choose new reference direction at maximum angle
- refDirection = m_maximumBound * m_refDirVector + m_maximumSine * yaxis;
- }
- } else {
- refDirection = m_refDirVector;
- }
- // apply damping on the direction
- direction = filter*direction + (1.0f-filter)*refDirection;
- obj->AlignAxisToVect(direction, axis);
- result = true;
- goto CHECK_TIME;
- case KX_ACT_CONSTRAINT_DIRPX:
- case KX_ACT_CONSTRAINT_DIRPY:
- case KX_ACT_CONSTRAINT_DIRPZ:
- case KX_ACT_CONSTRAINT_DIRNX:
- case KX_ACT_CONSTRAINT_DIRNY:
- case KX_ACT_CONSTRAINT_DIRNZ:
- switch (m_locrot) {
- case KX_ACT_CONSTRAINT_DIRPX:
- normal[0] = rotation[0][0];
- normal[1] = rotation[1][0];
- normal[2] = rotation[2][0];
- axis = 0; // axis according to KX_GameObject::AlignAxisToVect()
- sign = 0; // X axis will be parrallel to direction of ray
- break;
- case KX_ACT_CONSTRAINT_DIRPY:
- normal[0] = rotation[0][1];
- normal[1] = rotation[1][1];
- normal[2] = rotation[2][1];
- axis = 1;
- sign = 0;
- break;
- case KX_ACT_CONSTRAINT_DIRPZ:
- normal[0] = rotation[0][2];
- normal[1] = rotation[1][2];
- normal[2] = rotation[2][2];
- axis = 2;
- sign = 0;
- break;
- case KX_ACT_CONSTRAINT_DIRNX:
- normal[0] = -rotation[0][0];
- normal[1] = -rotation[1][0];
- normal[2] = -rotation[2][0];
- axis = 0;
- sign = 1;
- break;
- case KX_ACT_CONSTRAINT_DIRNY:
- normal[0] = -rotation[0][1];
- normal[1] = -rotation[1][1];
- normal[2] = -rotation[2][1];
- axis = 1;
- sign = 1;
- break;
- case KX_ACT_CONSTRAINT_DIRNZ:
- normal[0] = -rotation[0][2];
- normal[1] = -rotation[1][2];
- normal[2] = -rotation[2][2];
- axis = 2;
- sign = 1;
- break;
- }
- normal.normalize();
- if (m_option & KX_ACT_CONSTRAINT_LOCAL) {
- // direction of the ray is along the local axis
- direction = normal;
- } else {
- switch (m_locrot) {
- case KX_ACT_CONSTRAINT_DIRPX:
- direction = MT_Vector3(1.0f,0.0f,0.0f);
- break;
- case KX_ACT_CONSTRAINT_DIRPY:
- direction = MT_Vector3(0.0f,1.0f,0.0f);
- break;
- case KX_ACT_CONSTRAINT_DIRPZ:
- direction = MT_Vector3(0.0f,0.0f,1.0f);
- break;
- case KX_ACT_CONSTRAINT_DIRNX:
- direction = MT_Vector3(-1.0f,0.0f,0.0f);
- break;
- case KX_ACT_CONSTRAINT_DIRNY:
- direction = MT_Vector3(0.0f,-1.0f,0.0f);
- break;
- case KX_ACT_CONSTRAINT_DIRNZ:
- direction = MT_Vector3(0.0f,0.0f,-1.0f);
- break;
- }
- }
- {
- MT_Point3 topoint = position + (m_maximumBound) * direction;
- PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
- 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) {
- // the object is not physical, we probably want to avoid hitting its own parent
- KX_GameObject *parent = obj->GetParent();
- if (parent) {
- spc = parent->GetPhysicsController();
- }
- }
- KX_RayCast::Callback<KX_ConstraintActuator, void> callback(this,dynamic_cast<PHY_IPhysicsController*>(spc));
- result = KX_RayCast::RayTest(pe, position, topoint, callback);
- if (result) {
- MT_Vector3 newnormal = callback.m_hitNormal;
- // compute new position & orientation
- if ((m_option & (KX_ACT_CONSTRAINT_NORMAL|KX_ACT_CONSTRAINT_DISTANCE)) == 0) {
- // if none option is set, the actuator does nothing but detect ray
- // (works like a sensor)
- goto CHECK_TIME;
- }
- if (m_option & KX_ACT_CONSTRAINT_NORMAL) {
- MT_Scalar rotFilter;
- // apply damping on the direction
- if (m_rotDampTime) {
- rotFilter = m_rotDampTime/(1.0f+m_rotDampTime);
- } else {
- rotFilter = filter;
- }
- newnormal = rotFilter*normal - (1.0f-rotFilter)*newnormal;
- obj->AlignAxisToVect((sign)?-newnormal:newnormal, axis);
- if (m_option & KX_ACT_CONSTRAINT_LOCAL) {
- direction = newnormal;
- direction.normalize();
- }
- }
- if (m_option & KX_ACT_CONSTRAINT_DISTANCE) {
- if (m_posDampTime) {
- newdistance = filter*(position-callback.m_hitPoint).length()+(1.0f-filter)*m_minimumBound;
- } else {
- newdistance = m_minimumBound;
- }
- // logically we should cancel the speed along the ray direction as we set the
- // position along that axis
- spc = obj->GetPhysicsController();
- if (spc && spc->IsDynamic()) {
- MT_Vector3 linV = spc->GetLinearVelocity();
- // cancel the projection along the ray direction
- MT_Scalar fallspeed = linV.dot(direction);
- if (!MT_fuzzyZero(fallspeed))
- spc->SetLinearVelocity(linV-fallspeed*direction,false);
- }
- } else {
- newdistance = (position-callback.m_hitPoint).length();
- }
- newposition = callback.m_hitPoint-newdistance*direction;
- } else if (m_option & KX_ACT_CONSTRAINT_PERMANENT) {
- // no contact but still keep running
- result = true;
- goto CHECK_TIME;
- }
- }
- break;
- case KX_ACT_CONSTRAINT_FHPX:
- case KX_ACT_CONSTRAINT_FHPY:
- case KX_ACT_CONSTRAINT_FHPZ:
- case KX_ACT_CONSTRAINT_FHNX:
- case KX_ACT_CONSTRAINT_FHNY:
- case KX_ACT_CONSTRAINT_FHNZ:
- switch (m_locrot) {
- case KX_ACT_CONSTRAINT_FHPX:
- normal[0] = -rotation[0][0];
- normal[1] = -rotation[1][0];
- normal[2] = -rotation[2][0];
- direction = MT_Vector3(1.0f,0.0f,0.0f);
- break;
- case KX_ACT_CONSTRAINT_FHPY:
- normal[0] = -rotation[0][1];
- normal[1] = -rotation[1][1];
- normal[2] = -rotation[2][1];
- direction = MT_Vector3(0.0f,1.0f,0.0f);
- break;
- case KX_ACT_CONSTRAINT_FHPZ:
- normal[0] = -rotation[0][2];
- normal[1] = -rotation[1][2];
- normal[2] = -rotation[2][2];
- direction = MT_Vector3(0.0f,0.0f,1.0f);
- break;
- case KX_ACT_CONSTRAINT_FHNX:
- normal[0] = rotation[0][0];
- normal[1] = rotation[1][0];
- normal[2] = rotation[2][0];
- direction = MT_Vector3(-1.0f,0.0f,0.0f);
- break;
- case KX_ACT_CONSTRAINT_FHNY:
- normal[0] = rotation[0][1];
- normal[1] = rotation[1][1];
- normal[2] = rotation[2][1];
- direction = MT_Vector3(0.0f,-1.0f,0.0f);
- break;
- case KX_ACT_CONSTRAINT_FHNZ:
- normal[0] = rotation[0][2];
- normal[1] = rotation[1][2];
- normal[2] = rotation[2][2];
- direction = MT_Vector3(0.0f,0.0f,-1.0f);
- break;
- }
- normal.normalize();
- {
- PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
- 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->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, void> callback(this, spc);
- result = KX_RayCast::RayTest(pe, position, topoint, callback);
- // we expect a hit object
- if (!m_hitObject)
- result = false;
- if (result)
- {
- MT_Vector3 newnormal = callback.m_hitNormal;
- // compute new position & orientation
- MT_Scalar distance = (callback.m_hitPoint-position).length()-spc->GetRadius();
- // estimate the velocity of the hit point
- MT_Point3 relativeHitPoint;
- relativeHitPoint = (callback.m_hitPoint-m_hitObject->NodeGetWorldPosition());
- MT_Vector3 velocityHitPoint = m_hitObject->GetVelocity(relativeHitPoint);
- MT_Vector3 relativeVelocity = spc->GetLinearVelocity() - velocityHitPoint;
- MT_Scalar relativeVelocityRay = direction.dot(relativeVelocity);
- MT_Scalar springExtent = 1.0f - distance/m_minimumBound;
- // Fh force is stored in m_maximum
- MT_Scalar springForce = springExtent * m_maximumBound;
- // damping is stored in m_refDirection [0] = damping, [1] = rot damping
- MT_Scalar springDamp = relativeVelocityRay * m_refDirVector[0];
- MT_Vector3 newVelocity = spc->GetLinearVelocity()-(springForce+springDamp)*direction;
- if (m_option & KX_ACT_CONSTRAINT_NORMAL)
- {
- newVelocity+=(springForce+springDamp)*(newnormal-newnormal.dot(direction)*direction);
- }
- spc->SetLinearVelocity(newVelocity, false);
- if (m_option & KX_ACT_CONSTRAINT_DOROTFH)
- {
- MT_Vector3 angSpring = (normal.cross(newnormal))*m_maximumBound;
- MT_Vector3 angVelocity = spc->GetAngularVelocity();
- // remove component that is parallel to normal
- angVelocity -= angVelocity.dot(newnormal)*newnormal;
- MT_Vector3 angDamp = angVelocity * ((m_refDirVector[1]>MT_EPSILON)?m_refDirVector[1]:m_refDirVector[0]);
- spc->SetAngularVelocity(spc->GetAngularVelocity()+(angSpring-angDamp), false);
- }
- } else if (m_option & KX_ACT_CONSTRAINT_PERMANENT) {
- // no contact but still keep running
- result = true;
- }
- // don't set the position with this constraint
- goto CHECK_TIME;
- }
- break;
- case KX_ACT_CONSTRAINT_LOCX:
- case KX_ACT_CONSTRAINT_LOCY:
- case KX_ACT_CONSTRAINT_LOCZ:
- newposition = position = obj->GetSGNode()->GetLocalPosition();
- switch (m_locrot) {
- case KX_ACT_CONSTRAINT_LOCX:
- Clamp(newposition[0], m_minimumBound, m_maximumBound);
- break;
- case KX_ACT_CONSTRAINT_LOCY:
- Clamp(newposition[1], m_minimumBound, m_maximumBound);
- break;
- case KX_ACT_CONSTRAINT_LOCZ:
- Clamp(newposition[2], m_minimumBound, m_maximumBound);
- break;
- }
- result = true;
- if (m_posDampTime) {
- newposition = filter*position + (1.0f-filter)*newposition;
- }
- obj->NodeSetLocalPosition(newposition);
- goto CHECK_TIME;
- }
- if (result) {
- // set the new position but take into account parent if any
- obj->NodeSetWorldPosition(newposition);
- }
- CHECK_TIME:
- if (result && m_activeTime > 0 ) {
- if (++m_currentTime >= m_activeTime)
- result = false;
- }
- }
- if (!result) {
- m_currentTime = 0;
- }
- return result;
-} /* end of KX_ConstraintActuator::Update(double curtime,double deltatime) */
-
-void KX_ConstraintActuator::Clamp(MT_Scalar &var,
- float min,
- float max) {
- if (var < min) {
- var = min;
- } else if (var > max) {
- var = max;
- }
-}
-
-
-bool KX_ConstraintActuator::IsValidMode(KX_ConstraintActuator::KX_CONSTRAINTTYPE m)
-{
- bool res = false;
-
- if ( (m > KX_ACT_CONSTRAINT_NODEF) && (m < KX_ACT_CONSTRAINT_MAX)) {
- res = true;
- }
-
- return res;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_ConstraintActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_ConstraintActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_ConstraintActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_ConstraintActuator::Attributes[] = {
- KX_PYATTRIBUTE_INT_RW("damp",0,100,true,KX_ConstraintActuator,m_posDampTime),
- KX_PYATTRIBUTE_INT_RW("rotDamp",0,100,true,KX_ConstraintActuator,m_rotDampTime),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RW_CHECK("direction",-FLT_MAX,FLT_MAX,KX_ConstraintActuator,m_refDirection,3,pyattr_check_direction),
- KX_PYATTRIBUTE_INT_RW("option",0,0xFFFF,false,KX_ConstraintActuator,m_option),
- KX_PYATTRIBUTE_INT_RW("time",0,1000,true,KX_ConstraintActuator,m_activeTime),
- KX_PYATTRIBUTE_STRING_RW("propName",0,MAX_PROP_NAME,true,KX_ConstraintActuator,m_property),
- KX_PYATTRIBUTE_FLOAT_RW("min",-FLT_MAX,FLT_MAX,KX_ConstraintActuator,m_minimumBound),
- KX_PYATTRIBUTE_FLOAT_RW("distance",-FLT_MAX,FLT_MAX,KX_ConstraintActuator,m_minimumBound),
- KX_PYATTRIBUTE_FLOAT_RW("max",-FLT_MAX,FLT_MAX,KX_ConstraintActuator,m_maximumBound),
- KX_PYATTRIBUTE_FLOAT_RW("rayLength",0,2000.f,KX_ConstraintActuator,m_maximumBound),
- KX_PYATTRIBUTE_INT_RW("limit",KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF+1,KX_ConstraintActuator::KX_ACT_CONSTRAINT_MAX-1,false,KX_ConstraintActuator,m_locrot),
- { NULL } //Sentinel
-};
-
-int KX_ConstraintActuator::pyattr_check_direction(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_ConstraintActuator* act = static_cast<KX_ConstraintActuator*>(self);
- MT_Vector3 dir(act->m_refDirection);
- MT_Scalar len = dir.length();
- if (MT_fuzzyZero(len)) {
- PyErr_SetString(PyExc_ValueError, "actuator.direction = vec: KX_ConstraintActuator, invalid direction");
- return 1;
- }
- act->m_refDirVector = dir/len;
- return 0;
-}
-
-#endif
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h
deleted file mode 100644
index af617655d5e..00000000000
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.h
+++ /dev/null
@@ -1,152 +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_ConstraintActuator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_CONSTRAINTACTUATOR_H__
-#define __KX_CONSTRAINTACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "MT_Scalar.h"
-#include "MT_Vector3.h"
-#include "KX_ClientObjectInfo.h"
-
-#include "BLI_utildefines.h"
-
-class KX_RayCast;
-class KX_GameObject;
-
-class KX_ConstraintActuator : public SCA_IActuator
-{
- Py_Header
-protected:
- // Damp time (int),
- int m_posDampTime;
- int m_rotDampTime;
- // min (float)
- float m_minimumBound;
- // max (float)
- float m_maximumBound;
- // sinus of minimum angle
- float m_minimumSine;
- // sinus of maximum angle
- float m_maximumSine;
- // reference direction
- float m_refDirection[3];
- MT_Vector3 m_refDirVector; // same as m_refDirection
- // locrotxyz choice (pick one): only one choice allowed at a time!
- int m_locrot;
- // active time of actuator
- int m_activeTime;
- int m_currentTime;
- // option
- int m_option;
- // property to check
- STR_String m_property;
- // hit object
- KX_GameObject* m_hitObject;
-
- /**
- * Clamp <var> to <min>, <max>. Borders are included (in as far as
- * float comparisons are good for equality...).
- */
- void Clamp(MT_Scalar &var, float min, float max);
-
-
- public:
- // m_locrot
- enum KX_CONSTRAINTTYPE {
- KX_ACT_CONSTRAINT_NODEF = 0,
- KX_ACT_CONSTRAINT_LOCX,
- KX_ACT_CONSTRAINT_LOCY,
- KX_ACT_CONSTRAINT_LOCZ,
- KX_ACT_CONSTRAINT_ROTX,
- KX_ACT_CONSTRAINT_ROTY,
- KX_ACT_CONSTRAINT_ROTZ,
- KX_ACT_CONSTRAINT_DIRPX,
- KX_ACT_CONSTRAINT_DIRPY,
- KX_ACT_CONSTRAINT_DIRPZ,
- KX_ACT_CONSTRAINT_DIRNX,
- KX_ACT_CONSTRAINT_DIRNY,
- KX_ACT_CONSTRAINT_DIRNZ,
- KX_ACT_CONSTRAINT_ORIX,
- KX_ACT_CONSTRAINT_ORIY,
- KX_ACT_CONSTRAINT_ORIZ,
- KX_ACT_CONSTRAINT_FHPX,
- KX_ACT_CONSTRAINT_FHPY,
- KX_ACT_CONSTRAINT_FHPZ,
- KX_ACT_CONSTRAINT_FHNX,
- KX_ACT_CONSTRAINT_FHNY,
- KX_ACT_CONSTRAINT_FHNZ,
- KX_ACT_CONSTRAINT_MAX
- };
- // match ACT_CONST_... values from BIF_interface.h
- enum KX_CONSTRAINTOPT {
- KX_ACT_CONSTRAINT_NORMAL = 64,
- KX_ACT_CONSTRAINT_MATERIAL = 128,
- KX_ACT_CONSTRAINT_PERMANENT = 256,
- KX_ACT_CONSTRAINT_DISTANCE = 512,
- KX_ACT_CONSTRAINT_LOCAL = 1024,
- KX_ACT_CONSTRAINT_DOROTFH = 2048
- };
- bool IsValidMode(KX_CONSTRAINTTYPE m);
- /// \see KX_RayCast
- bool RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void *UNUSED(data));
- /// \see KX_RayCast
- bool NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data));
-
- KX_ConstraintActuator(SCA_IObject* gameobj,
- int posDamptime,
- int rotDampTime,
- float min,
- float max,
- float refDir[3],
- int locrot,
- int time,
- int option,
- char *property);
- virtual ~KX_ConstraintActuator();
- virtual CValue* GetReplica() {
- KX_ConstraintActuator* replica = new KX_ConstraintActuator(*this);
- replica->ProcessReplica();
- return replica;
- };
-
- virtual bool Update(double curtime, bool frame);
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- static int pyattr_check_direction(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_check_min(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
-
-};
-
-#endif /* __KX_CONSTRAINTACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
deleted file mode 100644
index 2f32b5e3216..00000000000
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
+++ /dev/null
@@ -1,133 +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_ConstraintWrapper.cpp
- * \ingroup ketsji
- */
-
-
-#include "EXP_PyObjectPlus.h"
-#include "KX_ConstraintWrapper.h"
-#include "PHY_IPhysicsEnvironment.h"
-
-KX_ConstraintWrapper::KX_ConstraintWrapper(
- PHY_ConstraintType ctype,
- int constraintId,
- PHY_IPhysicsEnvironment* physenv) :
- PyObjectPlus(),
- m_constraintId(constraintId),
- m_constraintType(ctype),
- m_physenv(physenv)
-{
-}
-KX_ConstraintWrapper::~KX_ConstraintWrapper()
-{
-}
-
-#ifdef WITH_PYTHON
-
-PyObject *KX_ConstraintWrapper::PyGetConstraintId()
-{
- return PyLong_FromLong(m_constraintId);
-}
-
-
-PyObject *KX_ConstraintWrapper::PyGetParam(PyObject *args, PyObject *kwds)
-{
- int dof;
- float value;
-
- if (!PyArg_ParseTuple(args,"i:getParam",&dof))
- return NULL;
-
- value = m_physenv->GetConstraintParam(m_constraintId,dof);
- return PyFloat_FromDouble(value);
-
-}
-
-PyObject *KX_ConstraintWrapper::PySetParam(PyObject *args, PyObject *kwds)
-{
- int dof;
- float minLimit,maxLimit;
-
- if (!PyArg_ParseTuple(args,"iff:setParam",&dof,&minLimit,&maxLimit))
- return NULL;
-
- m_physenv->SetConstraintParam(m_constraintId,dof,minLimit,maxLimit);
- Py_RETURN_NONE;
-}
-
-
-//python specific stuff
-PyTypeObject KX_ConstraintWrapper::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_ConstraintWrapper",
- 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
-};
-
-PyMethodDef KX_ConstraintWrapper::Methods[] = {
- {"getConstraintId",(PyCFunction) KX_ConstraintWrapper::sPyGetConstraintId, METH_NOARGS},
- {"setParam",(PyCFunction) KX_ConstraintWrapper::sPySetParam, METH_VARARGS},
- {"getParam",(PyCFunction) KX_ConstraintWrapper::sPyGetParam, METH_VARARGS},
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_ConstraintWrapper::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("constraint_id", KX_ConstraintWrapper, pyattr_get_constraintId),
- KX_PYATTRIBUTE_RO_FUNCTION("constraint_type", KX_ConstraintWrapper, pyattr_get_constraintType),
- { NULL } //Sentinel
-};
-
-PyObject *KX_ConstraintWrapper::pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_ConstraintWrapper* self = static_cast<KX_ConstraintWrapper*>(self_v);
- return self->PyGetConstraintId();
-}
-
-PyObject *KX_ConstraintWrapper::pyattr_get_constraintType(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_ConstraintWrapper* self = static_cast<KX_ConstraintWrapper*>(self_v);
- return PyLong_FromLong(self->m_constraintType);
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h
deleted file mode 100644
index 5e20b7a9aca..00000000000
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h
+++ /dev/null
@@ -1,61 +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_ConstraintWrapper.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_CONSTRAINTWRAPPER_H__
-#define __KX_CONSTRAINTWRAPPER_H__
-
-#include "EXP_Value.h"
-#include "PHY_DynamicTypes.h"
-
-class KX_ConstraintWrapper : public PyObjectPlus
-{
- Py_Header
-public:
- KX_ConstraintWrapper(PHY_ConstraintType ctype,int constraintId,class PHY_IPhysicsEnvironment* physenv);
- virtual ~KX_ConstraintWrapper ();
- int getConstraintId() { return m_constraintId; }
-
-#ifdef WITH_PYTHON
- KX_PYMETHOD_NOARGS(KX_ConstraintWrapper,GetConstraintId);
- KX_PYMETHOD(KX_ConstraintWrapper,SetParam);
- KX_PYMETHOD(KX_ConstraintWrapper,GetParam);
-
- static PyObject *pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_constraintType(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-#endif
-
-private:
- int m_constraintId;
- PHY_ConstraintType m_constraintType;
- PHY_IPhysicsEnvironment* m_physenv;
-};
-
-#endif /* __KX_CONSTRAINTWRAPPER_H__ */
diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp
deleted file mode 100644
index 7abff85d39c..00000000000
--- a/source/gameengine/Ketsji/KX_Dome.cpp
+++ /dev/null
@@ -1,2051 +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.
- *
- * Contributor(s): Dalai Felinto
- *
- * This code is originally inspired on some of the ideas and codes from Paul Bourke.
- * Developed as part of a Research and Development project for
- * SAT - La Société des arts technologiques.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_Dome.cpp
- * \ingroup ketsji
- */
-
-#include "KX_Dome.h"
-
-#ifdef WITH_PYTHON
-#include <structmember.h>
-#endif
-
-#include <float.h>
-#include <math.h>
-
-#include "DNA_scene_types.h"
-#include "RAS_CameraData.h"
-#include "BLI_math.h"
-
-#include "GPU_matrix.h"
-
-// constructor
-KX_Dome::KX_Dome (
- RAS_ICanvas* canvas,
- /// rasterizer
- RAS_IRasterizer* rasterizer,
- /// engine
- KX_KetsjiEngine* engine,
-
- short res, //resolution of the mesh
- short mode, //mode - fisheye, truncated, warped, panoramic, ...
- short angle,
- float resbuf, //size adjustment of the buffer
- short tilt,
- struct Text* warptext
-
- ):
- dlistSupported(false),
- canvaswidth(-1), canvasheight(-1),
- m_drawingmode(rasterizer->GetDrawingMode()),
- m_resolution(res),
- m_mode(mode),
- m_angle(angle),
- m_resbuffer(resbuf),
- m_tilt(tilt),
- m_canvas(canvas),
- m_rasterizer(rasterizer),
- m_engine(engine)
-{
- warp.usemesh = false;
- fboSupported = false;
-
- if (mode >= DOME_NUM_MODES)
- m_mode = DOME_FISHEYE;
-
- if (warptext) // it there is a text data try to warp it
- {
- char *buf;
- buf = txt_to_buf(warptext);
- if (buf)
- {
- warp.usemesh = ParseWarpMesh(STR_String(buf));
- MEM_freeN(buf);
- }
- }
-
- //setting the viewport size
- const int *viewport = m_canvas->GetViewPort();
-
- SetViewPort(viewport);
-
- switch (m_mode) {
- case DOME_FISHEYE:
- if (m_angle <= 180) {
- cubetop.resize(1);
- cubebottom.resize(1);
- cubeleft.resize(2);
- cuberight.resize(2);
-
- CreateMeshDome180();
- m_numfaces = 4;
- }
- else if (m_angle > 180) {
- cubetop.resize(2);
- cubebottom.resize(2);
- cubeleft.resize(2);
- cubefront.resize(2);
- cuberight.resize(2);
-
- CreateMeshDome250();
- m_numfaces = 5;
- } break;
- case DOME_ENVMAP:
- m_angle = 360;
- m_numfaces = 6;
- break;
- case DOME_PANORAM_SPH:
- cubeleft.resize(2);
- cubeleftback.resize(2);
- cuberight.resize(2);
- cuberightback.resize(2);
- cubetop.resize(2);
- cubebottom.resize(2);
-
- m_angle = 360;
- CreateMeshPanorama();
- m_numfaces = 6;
- break;
- default: //DOME_TRUNCATED_FRONT and DOME_TRUNCATED_REAR
- if (m_angle <= 180) {
- cubetop.resize(1);
- cubebottom.resize(1);
- cubeleft.resize(2);
- cuberight.resize(2);
-
- CreateMeshDome180();
- m_numfaces = 4;
- }
- else if (m_angle > 180) {
- cubetop.resize(2);
- cubebottom.resize(2);
- cubeleft.resize(2);
- cubefront.resize(2);
- cuberight.resize(2);
-
- CreateMeshDome250();
- m_numfaces = 5;
- } break;
- }
-
- m_numimages =(warp.usemesh?m_numfaces+1:m_numfaces);
-
- CalculateCameraOrientation();
-
- CreateGLImages();
-
- if (warp.usemesh)
- fboSupported = CreateFBO();
-
- dlistSupported = CreateDL();
-}
-
-// destructor
-KX_Dome::~KX_Dome (void)
-{
- ClearGLImages();
-
- if (fboSupported)
- glDeleteFramebuffersEXT(1, &warp.fboId);
-
- if (dlistSupported)
- glDeleteLists(dlistId, (GLsizei) m_numimages);
-}
-
-void KX_Dome::SetViewPort(const int viewport[4])
-{
- if (canvaswidth != m_viewport.GetWidth() || canvasheight != m_viewport.GetHeight())
- {
- m_viewport.SetLeft(viewport[0]);
- m_viewport.SetBottom(viewport[1]);
- m_viewport.SetRight(viewport[2]);
- m_viewport.SetTop(viewport[3]);
-
- CalculateImageSize();
- }
-}
-
-void KX_Dome::CreateGLImages(void)
-{
- glGenTextures(m_numimages, (GLuint*)&domefacesId);
-
- for (int j=0;j<m_numfaces;j++) {
- glBindTexture(GL_TEXTURE_2D, domefacesId[j]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, m_imagesize, m_imagesize, 0, GL_RGB8,
- GL_UNSIGNED_BYTE, NULL);
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, m_imagesize, m_imagesize, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
- if (warp.usemesh) {
- glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, warp.imagesize, warp.imagesize, 0, GL_RGB8,
- GL_UNSIGNED_BYTE, NULL);
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, warp.imagesize, warp.imagesize, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
-}
-
-void KX_Dome::ClearGLImages(void)
-{
- glDeleteTextures(m_numimages, (GLuint*)&domefacesId);
-#if 0
- for (int i=0;i<m_numimages;i++)
- if (glIsTexture(domefacesId[i]))
- glDeleteTextures(1, (GLuint*)&domefacesId[i]);
-#endif
-}
-
-void KX_Dome::CalculateImageSize(void)
-{
- /*
- * - determine the minimum buffer size
- * - reduce the buffer for better performance
- * - create a power of 2 texture bigger than the buffer
- */
- canvaswidth = m_canvas->GetWidth();
- canvasheight = m_canvas->GetHeight();
-
- m_buffersize = (canvaswidth > canvasheight?canvasheight:canvaswidth);
- m_buffersize = (int)(m_buffersize*m_resbuffer); //reduce buffer size for better performance
-
- int i = 0;
- while ((1 << i) <= m_buffersize)
- i++;
- m_imagesize = (1 << i);
-
- if (warp.usemesh) {
- // warp FBO needs to be up to twice as big as m_buffersize to get more resolution
- warp.imagesize = m_imagesize;
- if (m_buffersize == m_imagesize)
- warp.imagesize *= 2;
-
- //if FBO is not working/supported, we use the canvas dimension as buffer
- warp.bufferwidth = canvaswidth;
- warp.bufferheight = canvasheight;
- }
-}
-
-bool KX_Dome::CreateDL()
-{
- dlistId = glGenLists((GLsizei) m_numimages);
- if (dlistId != 0) {
- if (m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED_FRONT || m_mode == DOME_TRUNCATED_REAR) {
- glNewList(dlistId, GL_COMPILE);
- GLDrawTriangles(cubetop, nfacestop);
- glEndList();
-
- glNewList(dlistId+1, GL_COMPILE);
- GLDrawTriangles(cubebottom, nfacesbottom);
- glEndList();
-
- glNewList(dlistId+2, GL_COMPILE);
- GLDrawTriangles(cubeleft, nfacesleft);
- glEndList();
-
- glNewList(dlistId+3, GL_COMPILE);
- GLDrawTriangles(cuberight, nfacesright);
- glEndList();
-
- if (m_angle > 180) {
- glNewList(dlistId+4, GL_COMPILE);
- GLDrawTriangles(cubefront, nfacesfront);
- glEndList();
- }
- }
- else if (m_mode == DOME_PANORAM_SPH)
- {
- glNewList(dlistId, GL_COMPILE);
- GLDrawTriangles(cubetop, nfacestop);
- glEndList();
-
- glNewList(dlistId+1, GL_COMPILE);
- GLDrawTriangles(cubebottom, nfacesbottom);
- glEndList();
-
- glNewList(dlistId+2, GL_COMPILE);
- GLDrawTriangles(cubeleft, nfacesleft);
- glEndList();
-
- glNewList(dlistId+3, GL_COMPILE);
- GLDrawTriangles(cuberight, nfacesright);
- glEndList();
-
- glNewList(dlistId+4, GL_COMPILE);
- GLDrawTriangles(cubeleftback, nfacesleftback);
- glEndList();
-
- glNewList(dlistId+5, GL_COMPILE);
- GLDrawTriangles(cuberightback, nfacesrightback);
- glEndList();
- }
-
- if (warp.usemesh) {
- glNewList((dlistId + m_numfaces), GL_COMPILE);
- GLDrawWarpQuads();
- glEndList();
- }
-
- //clearing the vectors
- cubetop.clear();
- cubebottom.clear();
- cuberight.clear();
- cubeleft.clear();
- cubefront.clear();
- cubeleftback.clear();
- cuberightback.clear();
- warp.nodes.clear();
-
- } else // genList failed
- return false;
-
- return true;
-}
-
-bool KX_Dome::CreateFBO(void)
-{
- if (!GLEW_EXT_framebuffer_object)
- {
- printf("Dome Error: FrameBuffer unsupported. Using low resolution warp image.");
- return false;
- }
-
- glGenFramebuffersEXT(1, &warp.fboId);
- if (warp.fboId==0)
- {
- printf("Dome Error: Invalid frame buffer object. Using low resolution warp image.");
- return false;
- }
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, warp.fboId);
-
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, domefacesId[m_numfaces], 0);
-
- GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-
- if (status == GL_FRAMEBUFFER_UNSUPPORTED_EXT)
- {
- printf("Dome Error: FrameBuffer settings unsupported. Using low resolution warp image.");
- return false;
- }
- else if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
- {
- glDeleteFramebuffersEXT(1, &warp.fboId);
- return false;
- }
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-
- //nothing failed: we can use the whole FBO as buffersize
- warp.bufferwidth = warp.bufferheight = warp.imagesize;
- return true;
-}
-
-void KX_Dome::GLDrawTriangles(vector <DomeFace>& face, int nfaces)
-{
- int i,j;
- glBegin(GL_TRIANGLES);
- for (i=0;i<nfaces;i++) {
- for (j=0;j<3;j++) {
- glTexCoord2f(face[i].u[j],face[i].v[j]);
- glVertex3f((GLfloat)face[i].verts[j][0],(GLfloat)face[i].verts[j][1],(GLfloat)face[i].verts[j][2]);
- }
- }
- glEnd();
-}
-
-void KX_Dome::GLDrawWarpQuads(void)
-{
- int i, j, i2;
-
- float uv_width = (float)(warp.bufferwidth) / warp.imagesize;
- float uv_height = (float)(warp.bufferheight) / warp.imagesize;
-
- if (warp.mode ==2 ) {
- glBegin(GL_QUADS);
- for (i=0;i<warp.n_height-1;i++) {
- for (j=0;j<warp.n_width-1;j++) {
- if (warp.nodes[i][j].i < 0 || warp.nodes[i+1][j].i < 0 || warp.nodes[i+1][j+1].i < 0 || warp.nodes[i][j+1].i < 0)
- continue;
-
- glColor3f(warp.nodes[i][j+1].i, warp.nodes[i][j+1].i, warp.nodes[i][j+1].i);
- glTexCoord2f((warp.nodes[i][j+1].u * uv_width), (warp.nodes[i][j+1].v * uv_height));
- glVertex3f(warp.nodes[i][j+1].x, warp.nodes[i][j+1].y,0.0f);
-
- glColor3f(warp.nodes[i+1][j+1].i, warp.nodes[i+1][j+1].i, warp.nodes[i+1][j+1].i);
- glTexCoord2f((warp.nodes[i+1][j+1].u * uv_width), (warp.nodes[i+1][j+1].v * uv_height));
- glVertex3f(warp.nodes[i+1][j+1].x, warp.nodes[i+1][j+1].y,0.0f);
-
- glColor3f(warp.nodes[i+1][j].i, warp.nodes[i+1][j].i, warp.nodes[i+1][j].i);
- glTexCoord2f((warp.nodes[i+1][j].u * uv_width), (warp.nodes[i+1][j].v * uv_height));
- glVertex3f(warp.nodes[i+1][j].x, warp.nodes[i+1][j].y,0.0f);
-
- glColor3f(warp.nodes[i][j].i, warp.nodes[i][j].i, warp.nodes[i][j].i);
- glTexCoord2f((warp.nodes[i][j].u * uv_width), (warp.nodes[i][j].v * uv_height));
- glVertex3f(warp.nodes[i][j].x, warp.nodes[i][j].y,0.0f);
- }
- }
- glEnd();
- }
- else if (warp.mode == 1) {
- glBegin(GL_QUADS);
- for (i=0;i<warp.n_height-1;i++) {
- for (j=0;j<warp.n_width-1;j++) {
- i2 = (i+1) % warp.n_width; // Wrap around, i = warp.n_width = 0
-
- if (warp.nodes[i][j].i < 0 || warp.nodes[i2][j].i < 0 || warp.nodes[i2][j+1].i < 0 || warp.nodes[i][j+1].i < 0)
- continue;
-
- glColor3f(warp.nodes[i][j].i,warp.nodes[i][j].i,warp.nodes[i][j].i);
- glTexCoord2f((warp.nodes[i][j].u * uv_width), (warp.nodes[i][j].v * uv_height));
- glVertex3f(warp.nodes[i][j].x,warp.nodes[i][j].y,0.0f);
-
- glColor3f(warp.nodes[i2][j].i,warp.nodes[i2][j].i,warp.nodes[i2][j].i);
- glTexCoord2f((warp.nodes[i2][j].u * uv_width), (warp.nodes[i2][j].v * uv_height));
- glVertex3f(warp.nodes[i2][j].x,warp.nodes[i2][j].y,0.0f);
-
- glColor3f(warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i);
- glTexCoord2f((warp.nodes[i2][j+1].u * uv_width), (warp.nodes[i2][j+1].v * uv_height));
- glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0f);
-
- glColor3f(warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i,warp.nodes[i2][j+1].i);
- glTexCoord2f((warp.nodes[i2][j+1].u * uv_width), (warp.nodes[i2][j+1].v * uv_height));
- glVertex3f(warp.nodes[i2][j+1].x,warp.nodes[i2][j+1].y,0.0f);
-
- }
- }
- glEnd();
- }
- else {
- printf("Dome Error: Warp Mode %d unsupported. Try 1 for Polar Mesh or 2 for Fisheye.\n", warp.mode);
- }
-}
-
-
-bool KX_Dome::ParseWarpMesh(STR_String text)
-{
- /*
- * //Notes about the supported data format:
- * File example::
- * mode
- * width height
- * n0_x n0_y n0_u n0_v n0_i
- * n1_x n1_y n1_u n1_v n1_i
- * n2_x n1_y n2_u n2_v n2_i
- * n3_x n3_y n3_u n3_v n3_i
- * (...)
- * First line is the image type the mesh is support to be applied to: 2 = fisheye, 1=radial
- * The next line has the mesh dimensions
- * Rest of the lines are the nodes of the mesh. Each line has x y u v i
- * (x,y) are the normalized screen coordinates
- * (u,v) texture coordinates
- * i a multiplicative intensity factor
- *
- * x varies from -screen aspect to screen aspect
- * y varies from -1 to 1
- * u and v vary from 0 to 1
- * i ranges from 0 to 1, if negative don't draw that mesh node
- */
- int i;
- int nodeX=0, nodeY=0;
-
- vector<STR_String> columns, lines;
-
- lines = text.Explode('\n');
- if (lines.size() < 6) {
- printf("Dome Error: Warp Mesh File with insufficient data!\n");
- return false;
- }
- columns = lines[1].Explode(' ');
- if (columns.size() == 1)
- columns = lines[1].Explode('\t');
-
- if (columns.size() !=2) {
- printf("Dome Error: Warp Mesh File incorrect. The second line should contain: width height.\n");
- return false;
- }
-
- warp.mode = atoi(lines[0]);// 1 = radial, 2 = fisheye
-
- warp.n_width = atoi(columns[0]);
- warp.n_height = atoi(columns[1]);
-
- if ((int)lines.size() < 2 + (warp.n_width * warp.n_height)) {
- printf("Dome Error: Warp Mesh File with insufficient data!\n");
- return false;
- }
- else {
- warp.nodes = vector<vector<WarpMeshNode> > (warp.n_height, vector<WarpMeshNode>(warp.n_width));
-
- for (i=2; i-2 < (warp.n_width*warp.n_height); i++) {
- columns = lines[i].Explode(' ');
- if (columns.size() == 1)
- columns = lines[i].Explode('\t');
-
- if (columns.size() == 5) {
- nodeX = (i-2)%warp.n_width;
- nodeY = ((i-2) - nodeX) / warp.n_width;
-
- warp.nodes[nodeY][nodeX].x = atof(columns[0]);
- warp.nodes[nodeY][nodeX].y = atof(columns[1]);
- warp.nodes[nodeY][nodeX].u = atof(columns[2]);
- warp.nodes[nodeY][nodeX].v = atof(columns[3]);
- warp.nodes[nodeY][nodeX].i = atof(columns[4]);
- }
- else {
- warp.nodes.clear();
- printf("Dome Error: Warp Mesh File with wrong number of fields. You should use 5: x y u v i.\n");
- return false;
- }
- }
- }
- return true;
-}
-
-void KX_Dome::CreateMeshDome180(void)
-{
- /*
- * 1)- Define the faces of half of a cube
- * - each face is made out of 2 triangles
- * 2) Subdivide the faces
- * - more resolution == more curved lines
- * 3) Spherize the cube
- * - normalize the verts
- * 4) Flatten onto xz plane
- * - transform it onto an equidistant spherical projection techniques to transform the sphere onto a dome image
- */
- int i,j;
- float uv_ratio = (float)(m_buffersize-1) / m_imagesize;
-
- m_radangle = DEG2RADF(m_angle); //calculates the radians angle, used for flattening
-
- //creating faces for the env mapcube 180deg Dome
- // Top Face - just a triangle
- cubetop[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f;
- cubetop[0].verts[0][1] = 0.0f;
- cubetop[0].verts[0][2] = 0.5f;
- cubetop[0].u[0] = 0.0;
- cubetop[0].v[0] = uv_ratio;
-
- cubetop[0].verts[1][0] = 0.0f;
- cubetop[0].verts[1][1] = (float)M_SQRT2 / 2.0f;
- cubetop[0].verts[1][2] = 0.5f;
- cubetop[0].u[1] = 0.0;
- cubetop[0].v[1] = 0.0;
-
- cubetop[0].verts[2][0] = (float)M_SQRT2 / 2.0f;
- cubetop[0].verts[2][1] = 0.0f;
- cubetop[0].verts[2][2] = 0.5f;
- cubetop[0].u[2] = uv_ratio;
- cubetop[0].v[2] = 0.0;
-
- nfacestop = 1;
-
- /* Bottom face - just a triangle */
- cubebottom[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f;
- cubebottom[0].verts[0][1] = 0.0f;
- cubebottom[0].verts[0][2] = -0.5f;
- cubebottom[0].u[0] = uv_ratio;
- cubebottom[0].v[0] = 0.0;
-
- cubebottom[0].verts[1][0] = (float)M_SQRT2 / 2.0f;
- cubebottom[0].verts[1][1] = 0;
- cubebottom[0].verts[1][2] = -0.5f;
- cubebottom[0].u[1] = 0.0;
- cubebottom[0].v[1] = uv_ratio;
-
- cubebottom[0].verts[2][0] = 0.0f;
- cubebottom[0].verts[2][1] = (float)M_SQRT2 / 2.0f;
- cubebottom[0].verts[2][2] = -0.5f;
- cubebottom[0].u[2] = 0.0;
- cubebottom[0].v[2] = 0.0;
-
- nfacesbottom = 1;
-
- /* Left face - two triangles */
-
- cubeleft[0].verts[0][0] = (float)(-M_SQRT2) / 2.0f;
- cubeleft[0].verts[0][1] = 0.0f;
- cubeleft[0].verts[0][2] = -0.5f;
- cubeleft[0].u[0] = 0.0;
- cubeleft[0].v[0] = 0.0;
-
- cubeleft[0].verts[1][0] = 0.0f;
- cubeleft[0].verts[1][1] = (float)M_SQRT2 / 2.0f;
- cubeleft[0].verts[1][2] = -0.5f;
- cubeleft[0].u[1] = uv_ratio;
- cubeleft[0].v[1] = 0.0;
-
- cubeleft[0].verts[2][0] = (float)(-M_SQRT2) / 2.0f;
- cubeleft[0].verts[2][1] = 0.0f;
- cubeleft[0].verts[2][2] = 0.5f;
- cubeleft[0].u[2] = 0.0;
- cubeleft[0].v[2] = uv_ratio;
-
- //second triangle
- cubeleft[1].verts[0][0] = (float)(-M_SQRT2) / 2.0f;
- cubeleft[1].verts[0][1] = 0.0f;
- cubeleft[1].verts[0][2] = 0.5f;
- cubeleft[1].u[0] = 0.0;
- cubeleft[1].v[0] = uv_ratio;
-
- cubeleft[1].verts[1][0] = 0.0f;
- cubeleft[1].verts[1][1] = (float)M_SQRT2 / 2.0f;
- cubeleft[1].verts[1][2] = -0.5f;
- cubeleft[1].u[1] = uv_ratio;
- cubeleft[1].v[1] = 0.0;
-
- cubeleft[1].verts[2][0] = 0.0f;
- cubeleft[1].verts[2][1] = (float)M_SQRT2 / 2.0f;
- cubeleft[1].verts[2][2] = 0.5f;
- cubeleft[1].u[2] = uv_ratio;
- cubeleft[1].v[2] = uv_ratio;
-
- nfacesleft = 2;
-
- /* Right face - two triangles */
- cuberight[0].verts[0][0] = 0.0f;
- cuberight[0].verts[0][1] = (float)M_SQRT2 / 2.0f;
- cuberight[0].verts[0][2] = -0.5f;
- cuberight[0].u[0] = 0.0;
- cuberight[0].v[0] = 0.0;
-
- cuberight[0].verts[1][0] = (float)M_SQRT2 / 2.0f;
- cuberight[0].verts[1][1] = 0.0f;
- cuberight[0].verts[1][2] = -0.5f;
- cuberight[0].u[1] = uv_ratio;
- cuberight[0].v[1] = 0.0;
-
- cuberight[0].verts[2][0] = (float)M_SQRT2 / 2.0f;
- cuberight[0].verts[2][1] = 0.0f;
- cuberight[0].verts[2][2] = 0.5f;
- cuberight[0].u[2] = uv_ratio;
- cuberight[0].v[2] = uv_ratio;
-
- //second triangle
- cuberight[1].verts[0][0] = 0.0f;
- cuberight[1].verts[0][1] = (float)M_SQRT2 / 2.0f;
- cuberight[1].verts[0][2] = -0.5f;
- cuberight[1].u[0] = 0.0;
- cuberight[1].v[0] = 0.0;
-
- cuberight[1].verts[1][0] = (float)M_SQRT2 / 2.0f;
- cuberight[1].verts[1][1] = 0.0f;
- cuberight[1].verts[1][2] = 0.5f;
- cuberight[1].u[1] = uv_ratio;
- cuberight[1].v[1] = uv_ratio;
-
- cuberight[1].verts[2][0] = 0.0f;
- cuberight[1].verts[2][1] = (float)M_SQRT2 / 2.0f;
- cuberight[1].verts[2][2] = 0.5f;
- cuberight[1].u[2] = 0.0;
- cuberight[1].v[2] = uv_ratio;
-
- nfacesright = 2;
-
- //Refine a triangular mesh by bisecting each edge forms 3 new triangles for each existing triangle on each iteration
- //Could be made more efficient for drawing if the triangles were ordered in a fan. Not that important since we are using DisplayLists
-
- for (i=0;i<m_resolution;i++) {
- cubetop.resize(4*nfacestop);
- SplitFace(cubetop,&nfacestop);
- cubebottom.resize(4*nfacesbottom);
- SplitFace(cubebottom,&nfacesbottom);
- cubeleft.resize(4*nfacesleft);
- SplitFace(cubeleft,&nfacesleft);
- cuberight.resize(4*nfacesright);
- SplitFace(cuberight,&nfacesright);
- }
-
- // Turn into a hemisphere
- for (j=0;j<3;j++) {
- for (i=0;i<nfacestop;i++)
- cubetop[i].verts[j].normalize();
- for (i=0;i<nfacesbottom;i++)
- cubebottom[i].verts[j].normalize();
- for (i=0;i<nfacesleft;i++)
- cubeleft[i].verts[j].normalize();
- for (i=0;i<nfacesright;i++)
- cuberight[i].verts[j].normalize();
- }
-
- //flatten onto xz plane
- for (i=0;i<nfacestop;i++)
- FlattenDome(cubetop[i].verts);
- for (i=0;i<nfacesbottom;i++)
- FlattenDome(cubebottom[i].verts);
- for (i=0;i<nfacesleft;i++)
- FlattenDome(cubeleft[i].verts);
- for (i=0;i<nfacesright;i++)
- FlattenDome(cuberight[i].verts);
-
-}
-
-void KX_Dome::CreateMeshDome250(void)
-{
- /*
- * 1)- Define the faces of a cube without the back face
- * - each face is made out of 2 triangles
- * 2) Subdivide the faces
- * - more resolution == more curved lines
- * 3) Spherize the cube
- * - normalize the verts
- * 4) Flatten onto xz plane
- * - transform it onto an equidistant spherical projection techniques to transform the sphere onto a dome image
- */
-
- int i,j;
- float uv_height, uv_base;
- float verts_height;
-
- float rad_ang = m_angle * MT_PI / 180.0f;
- float uv_ratio = (float)(m_buffersize-1) / m_imagesize;
-
- m_radangle = m_angle * (float)M_PI/180.0f;//calculates the radians angle, used for flattening
- /*
- * verts_height is the exactly needed height of the cube faces (not always 1.0).
- * When we want some horizontal information (e.g. for horizontal 220deg domes) we don't need to create and tessellate the whole cube.
- * Therefore the lateral cube faces could be small, and the tessellate mesh would be completely used.
- * (if we always worked with verts_height = 1.0, we would be discarding a lot of the calculated and tessellated geometry).
- *
- * So I came out with this formula:
- * verts_height = tan((rad_ang/2) - (MT_PI/2))*sqrt(2.0);
- *
- * Here we take half the sphere(rad_ang/2) and subtract a quarter of it (MT_PI/2)
- * Therefore we have the length in radians of the dome/sphere over the horizon.
- * Once we take the tangent of that angle, you have the verts coordinate corresponding to the verts on the side faces.
- * Then we need to multiply it by sqrt(2.0) to get the coordinate of the verts on the diagonal of the original cube.
- */
- verts_height = tanf((rad_ang / 2.0f) - (MT_PI / 2.0f)) * (float)M_SQRT2;
-
- uv_height = uv_ratio * ( (verts_height / 2.0f) + 0.5f);
- uv_base = uv_ratio * (1.0f - ((verts_height / 2.0f) + 0.5f));
-
- //creating faces for the env mapcube 180deg Dome
- // Front Face - 2 triangles
- cubefront[0].verts[0][0] =-1.0f;
- cubefront[0].verts[0][1] = 1.0f;
- cubefront[0].verts[0][2] =-1.0f;
- cubefront[0].u[0] = 0.0;
- cubefront[0].v[0] = 0.0;
-
- cubefront[0].verts[1][0] = 1.0f;
- cubefront[0].verts[1][1] = 1.0f;
- cubefront[0].verts[1][2] = 1.0f;
- cubefront[0].u[1] = uv_ratio;
- cubefront[0].v[1] = uv_ratio;
-
- cubefront[0].verts[2][0] =-1.0f;
- cubefront[0].verts[2][1] = 1.0f;
- cubefront[0].verts[2][2] = 1.0f;
- cubefront[0].u[2] = 0.0;
- cubefront[0].v[2] = uv_ratio;
-
- //second triangle
- cubefront[1].verts[0][0] = 1.0f;
- cubefront[1].verts[0][1] = 1.0f;
- cubefront[1].verts[0][2] = 1.0f;
- cubefront[1].u[0] = uv_ratio;
- cubefront[1].v[0] = uv_ratio;
-
- cubefront[1].verts[1][0] =-1.0f;
- cubefront[1].verts[1][1] = 1.0f;
- cubefront[1].verts[1][2] =-1.0f;
- cubefront[1].u[1] = 0.0;
- cubefront[1].v[1] = 0.0;
-
- cubefront[1].verts[2][0] = 1.0f;
- cubefront[1].verts[2][1] = 1.0f;
- cubefront[1].verts[2][2] =-1.0f;
- cubefront[1].u[2] = uv_ratio;
- cubefront[1].v[2] = 0.0;
-
- nfacesfront = 2;
-
- // Left Face - 2 triangles
- cubeleft[0].verts[0][0] =-1.0f;
- cubeleft[0].verts[0][1] = 1.0f;
- cubeleft[0].verts[0][2] =-1.0f;
- cubeleft[0].u[0] = uv_ratio;
- cubeleft[0].v[0] = 0.0;
-
- cubeleft[0].verts[1][0] =-1.0f;
- cubeleft[0].verts[1][1] =-verts_height;
- cubeleft[0].verts[1][2] = 1.0f;
- cubeleft[0].u[1] = uv_base;
- cubeleft[0].v[1] = uv_ratio;
-
- cubeleft[0].verts[2][0] =-1.0f;
- cubeleft[0].verts[2][1] =-verts_height;
- cubeleft[0].verts[2][2] =-1.0f;
- cubeleft[0].u[2] = uv_base;
- cubeleft[0].v[2] = 0.0;
-
- //second triangle
- cubeleft[1].verts[0][0] =-1.0f;
- cubeleft[1].verts[0][1] =-verts_height;
- cubeleft[1].verts[0][2] = 1.0f;
- cubeleft[1].u[0] = uv_base;
- cubeleft[1].v[0] = uv_ratio;
-
- cubeleft[1].verts[1][0] =-1.0f;
- cubeleft[1].verts[1][1] = 1.0f;
- cubeleft[1].verts[1][2] =-1.0f;
- cubeleft[1].u[1] = uv_ratio;
- cubeleft[1].v[1] = 0.0;
-
- cubeleft[1].verts[2][0] =-1.0f;
- cubeleft[1].verts[2][1] = 1.0f;
- cubeleft[1].verts[2][2] = 1.0f;
- cubeleft[1].u[2] = uv_ratio;
- cubeleft[1].v[2] = uv_ratio;
-
- nfacesleft = 2;
-
- // right Face - 2 triangles
- cuberight[0].verts[0][0] = 1.0f;
- cuberight[0].verts[0][1] = 1.0f;
- cuberight[0].verts[0][2] = 1.0f;
- cuberight[0].u[0] = 0.0;
- cuberight[0].v[0] = uv_ratio;
-
- cuberight[0].verts[1][0] = 1.0f;
- cuberight[0].verts[1][1] =-verts_height;
- cuberight[0].verts[1][2] =-1.0f;
- cuberight[0].u[1] = uv_height;
- cuberight[0].v[1] = 0.0;
-
- cuberight[0].verts[2][0] = 1.0f;
- cuberight[0].verts[2][1] =-verts_height;
- cuberight[0].verts[2][2] = 1.0f;
- cuberight[0].u[2] = uv_height;
- cuberight[0].v[2] = uv_ratio;
-
- //second triangle
- cuberight[1].verts[0][0] = 1.0f;
- cuberight[1].verts[0][1] =-verts_height;
- cuberight[1].verts[0][2] =-1.0f;
- cuberight[1].u[0] = uv_height;
- cuberight[1].v[0] = 0.0;
-
- cuberight[1].verts[1][0] = 1.0f;
- cuberight[1].verts[1][1] = 1.0f;
- cuberight[1].verts[1][2] = 1.0f;
- cuberight[1].u[1] = 0.0;
- cuberight[1].v[1] = uv_ratio;
-
- cuberight[1].verts[2][0] = 1.0f;
- cuberight[1].verts[2][1] = 1.0f;
- cuberight[1].verts[2][2] =-1.0f;
- cuberight[1].u[2] = 0.0;
- cuberight[1].v[2] = 0.0;
-
- nfacesright = 2;
-
- // top Face - 2 triangles
- cubetop[0].verts[0][0] =-1.0f;
- cubetop[0].verts[0][1] = 1.0f;
- cubetop[0].verts[0][2] = 1.0f;
- cubetop[0].u[0] = 0.0;
- cubetop[0].v[0] = 0.0;
-
- cubetop[0].verts[1][0] = 1.0f;
- cubetop[0].verts[1][1] =-verts_height;
- cubetop[0].verts[1][2] = 1.0f;
- cubetop[0].u[1] = uv_ratio;
- cubetop[0].v[1] = uv_height;
-
- cubetop[0].verts[2][0] =-1.0f;
- cubetop[0].verts[2][1] =-verts_height;
- cubetop[0].verts[2][2] = 1.0f;
- cubetop[0].u[2] = 0.0;
- cubetop[0].v[2] = uv_height;
-
- //second triangle
- cubetop[1].verts[0][0] = 1.0f;
- cubetop[1].verts[0][1] =-verts_height;
- cubetop[1].verts[0][2] = 1.0f;
- cubetop[1].u[0] = uv_ratio;
- cubetop[1].v[0] = uv_height;
-
- cubetop[1].verts[1][0] =-1.0f;
- cubetop[1].verts[1][1] = 1.0f;
- cubetop[1].verts[1][2] = 1.0f;
- cubetop[1].u[1] = 0.0;
- cubetop[1].v[1] = 0.0;
-
- cubetop[1].verts[2][0] = 1.0f;
- cubetop[1].verts[2][1] = 1.0f;
- cubetop[1].verts[2][2] = 1.0f;
- cubetop[1].u[2] = uv_ratio;
- cubetop[1].v[2] = 0.0;
-
- nfacestop = 2;
-
- // bottom Face - 2 triangles
- cubebottom[0].verts[0][0] =-1.0f;
- cubebottom[0].verts[0][1] =-verts_height;
- cubebottom[0].verts[0][2] =-1.0f;
- cubebottom[0].u[0] = 0.0;
- cubebottom[0].v[0] = uv_base;
-
- cubebottom[0].verts[1][0] = 1.0f;
- cubebottom[0].verts[1][1] = 1.0f;
- cubebottom[0].verts[1][2] =-1.0f;
- cubebottom[0].u[1] = uv_ratio;
- cubebottom[0].v[1] = uv_ratio;
-
- cubebottom[0].verts[2][0] =-1.0f;
- cubebottom[0].verts[2][1] = 1.0f;
- cubebottom[0].verts[2][2] =-1.0f;
- cubebottom[0].u[2] = 0.0;
- cubebottom[0].v[2] = uv_ratio;
-
- //second triangle
- cubebottom[1].verts[0][0] = 1.0f;
- cubebottom[1].verts[0][1] = 1.0f;
- cubebottom[1].verts[0][2] =-1.0f;
- cubebottom[1].u[0] = uv_ratio;
- cubebottom[1].v[0] = uv_ratio;
-
- cubebottom[1].verts[1][0] =-1.0f;
- cubebottom[1].verts[1][1] =-verts_height;
- cubebottom[1].verts[1][2] =-1.0f;
- cubebottom[1].u[1] = 0.0;
- cubebottom[1].v[1] = uv_base;
-
- cubebottom[1].verts[2][0] = 1.0f;
- cubebottom[1].verts[2][1] =-verts_height;
- cubebottom[1].verts[2][2] =-1.0f;
- cubebottom[1].u[2] = uv_ratio;
- cubebottom[1].v[2] = uv_base;
-
- nfacesbottom = 2;
-
- //Refine a triangular mesh by bisecting each edge forms 3 new triangles for each existing triangle on each iteration
- //It could be made more efficient for drawing if the triangles were ordered in a strip!
-
- for (i=0;i<m_resolution;i++) {
- cubefront.resize(4*nfacesfront);
- SplitFace(cubefront,&nfacesfront);
- cubetop.resize(4*nfacestop);
- SplitFace(cubetop,&nfacestop);
- cubebottom.resize(4*nfacesbottom);
- SplitFace(cubebottom,&nfacesbottom);
- cubeleft.resize(4*nfacesleft);
- SplitFace(cubeleft,&nfacesleft);
- cuberight.resize(4*nfacesright);
- SplitFace(cuberight,&nfacesright);
- }
-
- // Turn into a hemisphere/sphere
- for (j=0;j<3;j++) {
- for (i=0;i<nfacesfront;i++)
- cubefront[i].verts[j].normalize();
- for (i=0;i<nfacestop;i++)
- cubetop[i].verts[j].normalize();
- for (i=0;i<nfacesbottom;i++)
- cubebottom[i].verts[j].normalize();
- for (i=0;i<nfacesleft;i++)
- cubeleft[i].verts[j].normalize();
- for (i=0;i<nfacesright;i++)
- cuberight[i].verts[j].normalize();
- }
-
- //flatten onto xz plane
- for (i=0;i<nfacesfront;i++)
- FlattenDome(cubefront[i].verts);
- for (i=0;i<nfacestop;i++)
- FlattenDome(cubetop[i].verts);
- for (i=0;i<nfacesbottom;i++)
- FlattenDome(cubebottom[i].verts);
- for (i=0;i<nfacesleft;i++)
- FlattenDome(cubeleft[i].verts);
- for (i=0;i<nfacesright;i++)
- FlattenDome(cuberight[i].verts);
-}
-
-void KX_Dome::CreateMeshPanorama(void)
-{
- /*
- * 1)- Define the faces of a cube without the top and bottom faces
- * - each face is made out of 2 triangles
- * 2) Subdivide the faces
- * - more resolution == more curved lines
- * 3) Spherize the cube
- * - normalize the verts t
- * 4) Flatten onto xz plane
- * - use spherical projection techniques to transform the sphere onto a flat panorama
- */
- int i,j;
-
- float uv_ratio = (float)(m_buffersize-1) / m_imagesize;
-
- /* Top face - two triangles */
- cubetop[0].verts[0][0] = (float)(-M_SQRT2);
- cubetop[0].verts[0][1] = 0.0f;
- cubetop[0].verts[0][2] = 1.0f;
- cubetop[0].u[0] = 0.0;
- cubetop[0].v[0] = uv_ratio;
-
- cubetop[0].verts[1][0] = 0.0f;
- cubetop[0].verts[1][1] = (float)M_SQRT2;
- cubetop[0].verts[1][2] = 1.0f;
- cubetop[0].u[1] = 0.0;
- cubetop[0].v[1] = 0.0;
-
- //second triangle
- cubetop[0].verts[2][0] = (float)M_SQRT2;
- cubetop[0].verts[2][1] = 0.0f;
- cubetop[0].verts[2][2] = 1.0f;
- cubetop[0].u[2] = uv_ratio;
- cubetop[0].v[2] = 0.0;
-
- cubetop[1].verts[0][0] = (float)M_SQRT2;
- cubetop[1].verts[0][1] = 0.0f;
- cubetop[1].verts[0][2] = 1.0f;
- cubetop[1].u[0] = uv_ratio;
- cubetop[1].v[0] = 0.0;
-
- cubetop[1].verts[1][0] = 0.0f;
- cubetop[1].verts[1][1] = (float)(-M_SQRT2);
- cubetop[1].verts[1][2] = 1.0f;
- cubetop[1].u[1] = uv_ratio;
- cubetop[1].v[1] = uv_ratio;
-
- cubetop[1].verts[2][0] = (float)(-M_SQRT2);
- cubetop[1].verts[2][1] = 0.0f;
- cubetop[1].verts[2][2] = 1.0f;
- cubetop[1].u[2] = 0.0;
- cubetop[1].v[2] = uv_ratio;
-
- nfacestop = 2;
-
- /* Bottom face - two triangles */
- cubebottom[0].verts[0][0] = (float)(-M_SQRT2);
- cubebottom[0].verts[0][1] = 0.0f;
- cubebottom[0].verts[0][2] = -1.0f;
- cubebottom[0].u[0] = uv_ratio;
- cubebottom[0].v[0] = 0.0;
-
- cubebottom[0].verts[1][0] = (float)M_SQRT2;
- cubebottom[0].verts[1][1] = 0.0f;
- cubebottom[0].verts[1][2] = -1.0f;
- cubebottom[0].u[1] = 0.0;
- cubebottom[0].v[1] = uv_ratio;
-
- cubebottom[0].verts[2][0] = 0.0f;
- cubebottom[0].verts[2][1] = (float)M_SQRT2;
- cubebottom[0].verts[2][2] = -1.0f;
- cubebottom[0].u[2] = 0.0;
- cubebottom[0].v[2] = 0.0;
-
- //second triangle
- cubebottom[1].verts[0][0] = (float)M_SQRT2;
- cubebottom[1].verts[0][1] = 0.0f;
- cubebottom[1].verts[0][2] = -1.0f;
- cubebottom[1].u[0] = 0.0;
- cubebottom[1].v[0] = uv_ratio;
-
- cubebottom[1].verts[1][0] = (float)(-M_SQRT2);
- cubebottom[1].verts[1][1] = 0.0f;
- cubebottom[1].verts[1][2] = -1.0f;
- cubebottom[1].u[1] = uv_ratio;
- cubebottom[1].v[1] = 0.0;
-
- cubebottom[1].verts[2][0] = 0.0f;
- cubebottom[1].verts[2][1] = (float)(-M_SQRT2);
- cubebottom[1].verts[2][2] = -1.0f;
- cubebottom[1].u[2] = uv_ratio;
- cubebottom[1].v[2] = uv_ratio;
-
- nfacesbottom = 2;
-
- /* Left Back (135deg) face - two triangles */
-
- cubeleftback[0].verts[0][0] = 0.0f;
- cubeleftback[0].verts[0][1] = (float)(-M_SQRT2);
- cubeleftback[0].verts[0][2] = -1.0f;
- cubeleftback[0].u[0] = 0.0;
- cubeleftback[0].v[0] = 0.0;
-
- cubeleftback[0].verts[1][0] = (float)(-M_SQRT2);
- cubeleftback[0].verts[1][1] = 0.0f;
- cubeleftback[0].verts[1][2] = -1.0f;
- cubeleftback[0].u[1] = uv_ratio;
- cubeleftback[0].v[1] = 0.0;
-
- cubeleftback[0].verts[2][0] = 0.0f;
- cubeleftback[0].verts[2][1] = (float)(-M_SQRT2);
- cubeleftback[0].verts[2][2] = 1.0f;
- cubeleftback[0].u[2] = 0.0;
- cubeleftback[0].v[2] = uv_ratio;
-
- //second triangle
- cubeleftback[1].verts[0][0] = 0.0f;
- cubeleftback[1].verts[0][1] = (float)(-M_SQRT2);
- cubeleftback[1].verts[0][2] = 1.0f;
- cubeleftback[1].u[0] = 0.0;
- cubeleftback[1].v[0] = uv_ratio;
-
- cubeleftback[1].verts[1][0] = (float)(-M_SQRT2);
- cubeleftback[1].verts[1][1] = 0.0f;
- cubeleftback[1].verts[1][2] = -1.0f;
- cubeleftback[1].u[1] = uv_ratio;
- cubeleftback[1].v[1] = 0.0;
-
- cubeleftback[1].verts[2][0] = (float)(-M_SQRT2);
- cubeleftback[1].verts[2][1] = 0.0f;
- cubeleftback[1].verts[2][2] = 1.0f;
- cubeleftback[1].u[2] = uv_ratio;
- cubeleftback[1].v[2] = uv_ratio;
-
- nfacesleftback = 2;
-
- /* Left face - two triangles */
-
- cubeleft[0].verts[0][0] = (float)(-M_SQRT2);
- cubeleft[0].verts[0][1] = 0.0f;
- cubeleft[0].verts[0][2] = -1.0f;
- cubeleft[0].u[0] = 0.0;
- cubeleft[0].v[0] = 0.0;
-
- cubeleft[0].verts[1][0] = 0.0f;
- cubeleft[0].verts[1][1] = (float)M_SQRT2;
- cubeleft[0].verts[1][2] = -1.0f;
- cubeleft[0].u[1] = uv_ratio;
- cubeleft[0].v[1] = 0.0;
-
- cubeleft[0].verts[2][0] = (float)(-M_SQRT2);
- cubeleft[0].verts[2][1] = 0.0f;
- cubeleft[0].verts[2][2] = 1.0f;
- cubeleft[0].u[2] = 0.0;
- cubeleft[0].v[2] = uv_ratio;
-
- //second triangle
- cubeleft[1].verts[0][0] = (float)(-M_SQRT2);
- cubeleft[1].verts[0][1] = 0.0f;
- cubeleft[1].verts[0][2] = 1.0f;
- cubeleft[1].u[0] = 0.0;
- cubeleft[1].v[0] = uv_ratio;
-
- cubeleft[1].verts[1][0] = 0.0f;
- cubeleft[1].verts[1][1] = (float)M_SQRT2;
- cubeleft[1].verts[1][2] = -1.0f;
- cubeleft[1].u[1] = uv_ratio;
- cubeleft[1].v[1] = 0.0;
-
- cubeleft[1].verts[2][0] = 0.0f;
- cubeleft[1].verts[2][1] = (float)M_SQRT2;
- cubeleft[1].verts[2][2] = 1.0f;
- cubeleft[1].u[2] = uv_ratio;
- cubeleft[1].v[2] = uv_ratio;
-
- nfacesleft = 2;
-
- /* Right face - two triangles */
- cuberight[0].verts[0][0] = 0.0f;
- cuberight[0].verts[0][1] = (float)M_SQRT2;
- cuberight[0].verts[0][2] = -1.0f;
- cuberight[0].u[0] = 0.0;
- cuberight[0].v[0] = 0.0;
-
- cuberight[0].verts[1][0] = (float)M_SQRT2;
- cuberight[0].verts[1][1] = 0.0f;
- cuberight[0].verts[1][2] = -1.0f;
- cuberight[0].u[1] = uv_ratio;
- cuberight[0].v[1] = 0.0;
-
- cuberight[0].verts[2][0] = (float)M_SQRT2;
- cuberight[0].verts[2][1] = 0.0f;
- cuberight[0].verts[2][2] = 1.0f;
- cuberight[0].u[2] = uv_ratio;
- cuberight[0].v[2] = uv_ratio;
-
- //second triangle
- cuberight[1].verts[0][0] = 0.0f;
- cuberight[1].verts[0][1] = (float)M_SQRT2;
- cuberight[1].verts[0][2] = -1.0f;
- cuberight[1].u[0] = 0.0;
- cuberight[1].v[0] = 0.0;
-
- cuberight[1].verts[1][0] = (float)M_SQRT2;
- cuberight[1].verts[1][1] = 0.0f;
- cuberight[1].verts[1][2] = 1.0f;
- cuberight[1].u[1] = uv_ratio;
- cuberight[1].v[1] = uv_ratio;
-
- cuberight[1].verts[2][0] = 0.0f;
- cuberight[1].verts[2][1] = (float)M_SQRT2;
- cuberight[1].verts[2][2] = 1.0f;
- cuberight[1].u[2] = 0.0f;
- cuberight[1].v[2] = uv_ratio;
-
- nfacesright = 2;
-
- /* Right Back (-135deg) face - two triangles */
- cuberightback[0].verts[0][0] = (float)M_SQRT2;
- cuberightback[0].verts[0][1] = 0.0f;
- cuberightback[0].verts[0][2] = -1.0f;
- cuberightback[0].u[0] = 0.0;
- cuberightback[0].v[0] = 0.0;
-
- cuberightback[0].verts[1][0] = 0.0f;
- cuberightback[0].verts[1][1] = (float)(-M_SQRT2);
- cuberightback[0].verts[1][2] = -1.0f;
- cuberightback[0].u[1] = uv_ratio;
- cuberightback[0].v[1] = 0.0;
-
- cuberightback[0].verts[2][0] = 0.0f;
- cuberightback[0].verts[2][1] = (float)(-M_SQRT2);
- cuberightback[0].verts[2][2] = 1.0f;
- cuberightback[0].u[2] = uv_ratio;
- cuberightback[0].v[2] = uv_ratio;
-
- //second triangle
- cuberightback[1].verts[0][0] = (float)M_SQRT2;
- cuberightback[1].verts[0][1] = 0.0f;
- cuberightback[1].verts[0][2] = -1.0f;
- cuberightback[1].u[0] = 0.0;
- cuberightback[1].v[0] = 0.0;
-
- cuberightback[1].verts[1][0] = 0.0f;
- cuberightback[1].verts[1][1] = (float)(-M_SQRT2);
- cuberightback[1].verts[1][2] = 1.0f;
- cuberightback[1].u[1] = uv_ratio;
- cuberightback[1].v[1] = uv_ratio;
-
- cuberightback[1].verts[2][0] = (float)M_SQRT2;
- cuberightback[1].verts[2][1] = 0.0f;
- cuberightback[1].verts[2][2] = 1.0f;
- cuberightback[1].u[2] = 0.0;
- cuberightback[1].v[2] = uv_ratio;
-
- nfacesrightback = 2;
-
- // Subdivide the faces
- for (i=0;i<m_resolution;i++)
- {
- cubetop.resize(4*nfacestop);
- SplitFace(cubetop,&nfacestop);
-
- cubebottom.resize(4*nfacesbottom);
- SplitFace(cubebottom,&nfacesbottom);
-
- cubeleft.resize(4*nfacesleft);
- SplitFace(cubeleft,&nfacesleft);
-
- cuberight.resize(4*nfacesright);
- SplitFace(cuberight,&nfacesright);
-
- cubeleftback.resize(4*nfacesleftback);
- SplitFace(cubeleftback,&nfacesleftback);
-
- cuberightback.resize(4*nfacesrightback);
- SplitFace(cuberightback,&nfacesrightback);
- }
-
- // Spherize the cube
- for (j=0;j<3;j++)
- {
- for (i=0;i<nfacestop;i++)
- cubetop[i].verts[j].normalize();
-
- for (i=0;i<nfacesbottom;i++)
- cubebottom[i].verts[j].normalize();
-
- for (i=0;i<nfacesleftback;i++)
- cubeleftback[i].verts[j].normalize();
-
- for (i=0;i<nfacesleft;i++)
- cubeleft[i].verts[j].normalize();
-
- for (i=0;i<nfacesright;i++)
- cuberight[i].verts[j].normalize();
-
- for (i=0;i<nfacesrightback;i++)
- cuberightback[i].verts[j].normalize();
- }
-
- //Flatten onto xz plane
- for (i=0;i<nfacesleftback;i++)
- FlattenPanorama(cubeleftback[i].verts);
-
- for (i=0;i<nfacesleft;i++)
- FlattenPanorama(cubeleft[i].verts);
-
- for (i=0;i<nfacesright;i++)
- FlattenPanorama(cuberight[i].verts);
-
- for (i=0;i<nfacesrightback;i++)
- FlattenPanorama(cuberightback[i].verts);
-
- for (i=0;i<nfacestop;i++)
- FlattenPanorama(cubetop[i].verts);
-
- for (i=0;i<nfacesbottom;i++)
- FlattenPanorama(cubebottom[i].verts);
-}
-
-void KX_Dome::FlattenDome(MT_Vector3 verts[3])
-{
- double phi, r;
-
- for (int i=0;i<3;i++) {
- r = atan2(sqrt(verts[i][0]*verts[i][0] + verts[i][2]*verts[i][2]), verts[i][1]);
- r /= (double)this->m_radangle / 2.0;
-
- phi = atan2(verts[i][2], verts[i][0]);
-
- verts[i][0] = r * cos(phi);
- verts[i][1] = 0.0f;
- verts[i][2] = r * sin(phi);
-
- if (r > 1.0) {
- //round the border
- verts[i][0] = cos(phi);
- verts[i][1] = -3.0f;
- verts[i][2] = sin(phi);
- }
- }
-}
-
-void KX_Dome::FlattenPanorama(MT_Vector3 verts[3])
-{
-// it creates a full spherical panoramic (360deg)
- int i;
- double phi, theta;
- bool edge=false;
-
- for (i=0;i<3;i++) {
- phi = atan2(verts[i][1], verts[i][0]);
- phi *= -1.0; //flipping
-
- if (phi == -MT_PI) //It's on the edge
- edge=true;
-
- verts[i][0] = phi / MT_PI;
- verts[i][1] = 0.0f;
-
- theta = asin(verts[i][2]);
- verts[i][2] = theta / MT_PI;
- }
- if (edge) {
- bool right=false;
-
- for (i=0;i<3;i++) {
- if (fmodf(verts[i][0],1.0f) > 0.0f) {
- right=true;
- break;
- }
- }
- if (right) {
- for (i=0;i<3;i++) {
- if (verts[i][0] < 0.0f)
- verts[i][0] *= -1.0f;
- }
- }
- }
-}
-
-void KX_Dome::SplitFace(vector <DomeFace>& face, int *nfaces)
-{
- int i;
- int n1, n2;
-
- n1 = n2 = *nfaces;
-
- for (i=0;i<n1;i++) {
-
- face[n2].verts[0] = (face[i].verts[0] + face[i].verts[1]) /2;
- face[n2].verts[1] = face[i].verts[1];
- face[n2].verts[2] = (face[i].verts[1] + face[i].verts[2]) /2;
- face[n2].u[0] = (face[i].u[0] + face[i].u[1]) /2;
- face[n2].u[1] = face[i].u[1];
- face[n2].u[2] = (face[i].u[1] + face[i].u[2]) /2;
- face[n2].v[0] = (face[i].v[0] + face[i].v[1]) /2;
- face[n2].v[1] = face[i].v[1];
- face[n2].v[2] = (face[i].v[1] + face[i].v[2]) /2;
-
- face[n2+1].verts[0] = (face[i].verts[1] + face[i].verts[2]) /2;
- face[n2+1].verts[1] = face[i].verts[2];
- face[n2+1].verts[2] = (face[i].verts[2] + face[i].verts[0]) /2;
- face[n2+1].u[0] = (face[i].u[1] + face[i].u[2]) /2;
- face[n2+1].u[1] = face[i].u[2];
- face[n2+1].u[2] = (face[i].u[2] + face[i].u[0]) /2;
- face[n2+1].v[0] = (face[i].v[1] + face[i].v[2]) /2;
- face[n2+1].v[1] = face[i].v[2];
- face[n2+1].v[2] = (face[i].v[2] + face[i].v[0]) /2;
-
- face[n2+2].verts[0] = (face[i].verts[0] + face[i].verts[1]) /2;
- face[n2+2].verts[1] = (face[i].verts[1] + face[i].verts[2]) /2;
- face[n2+2].verts[2] = (face[i].verts[2] + face[i].verts[0]) /2;
- face[n2+2].u[0] = (face[i].u[0] + face[i].u[1]) /2;
- face[n2+2].u[1] = (face[i].u[1] + face[i].u[2]) /2;
- face[n2+2].u[2] = (face[i].u[2] + face[i].u[0]) /2;
- face[n2+2].v[0] = (face[i].v[0] + face[i].v[1]) /2;
- face[n2+2].v[1] = (face[i].v[1] + face[i].v[2]) /2;
- face[n2+2].v[2] = (face[i].v[2] + face[i].v[0]) /2;
-
- //face[i].verts[0] = face[i].verts[0];
- face[i].verts[1] = (face[i].verts[0] + face[i].verts[1]) /2;
- face[i].verts[2] = (face[i].verts[0] + face[i].verts[2]) /2;
- //face[i].u[0] = face[i].u[0];
- face[i].u[1] = (face[i].u[0] + face[i].u[1]) /2;
- face[i].u[2] = (face[i].u[0] + face[i].u[2]) /2;
- //face[i].v[0] = face[i].v[0];
- face[i].v[1] = (face[i].v[0] + face[i].v[1]) /2;
- face[i].v[2] = (face[i].v[0] + face[i].v[2]) /2;
-
- n2 += 3; // number of faces
- }
- *nfaces = n2;
-}
-
-void KX_Dome::CalculateFrustum(KX_Camera *cam)
-{
-#if 0
- // manually creating a 90deg Field of View Frustum
-
- // the original formula:
- top = tan(fov*3.14159f/30.0f)) * near [for fov in degrees]
- fov*0.5f = arctan ((top-bottom)*0.5f / near) [for fov in radians]
- bottom = -top
- left = aspect * bottom
- right = aspect * top
-
- // the equivalent GLU call is:
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(90.0f,1.0f,cam->GetCameraNear(),cam->GetCameraFar());
-#endif
-
- RAS_FrameFrustum m_frustum; //90 deg. Frustum
-
- m_frustum.camnear = cam->GetCameraNear();
- m_frustum.camfar = cam->GetCameraFar();
-
-// float top = tan(90.0f*MT_PI/360.0f) * m_frustum.camnear;
- float top = m_frustum.camnear; // for deg = 90deg, tan = 1
-
- m_frustum.x1 = -top;
- m_frustum.x2 = top;
- m_frustum.y1 = -top;
- m_frustum.y2 = top;
-
- m_projmat = m_rasterizer->GetFrustumMatrix(
- m_frustum.x1, m_frustum.x2, m_frustum.y1, m_frustum.y2, m_frustum.camnear, m_frustum.camfar);
-}
-
-void KX_Dome::CalculateCameraOrientation()
-{
-/*
- * Uses 4 cameras for angles up to 180deg
- * Uses 5 cameras for angles up to 250deg
- * Uses 6 cameras for angles up to 360deg
- */
- int i;
- float deg45 = MT_PI / 4.0f;
- MT_Scalar c = cosf(deg45);
- MT_Scalar s = sinf(deg45);
-
- if (m_angle <= 180 && (m_mode == DOME_FISHEYE
- || m_mode == DOME_TRUNCATED_FRONT
- || m_mode == DOME_TRUNCATED_REAR)) {
-
- m_locRot[0] = MT_Matrix3x3( // 90deg - Top
- c, -s, 0.0f,
- 0.0f,0.0f, -1.0f,
- s, c, 0.0f);
-
- m_locRot[1] = MT_Matrix3x3( // 90deg - Bottom
- -s, c, 0.0f,
- 0.0f,0.0f, 1.0f,
- s, c, 0.0f);
-
- m_locRot[2] = MT_Matrix3x3( // 45deg - Left
- c, 0.0f, s,
- 0, 1.0f, 0.0f,
- -s, 0.0f, c);
-
- m_locRot[3] = MT_Matrix3x3( // 45deg - Right
- c, 0.0f, -s,
- 0.0f, 1.0f, 0.0f,
- s, 0.0f, c);
-
- } else if (m_mode == DOME_ENVMAP || (m_angle > 180 && (m_mode == DOME_FISHEYE
- || m_mode == DOME_TRUNCATED_FRONT
- || m_mode == DOME_TRUNCATED_REAR))) {
-
- m_locRot[0] = MT_Matrix3x3( // 90deg - Top
- 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f,-1.0f,
- 0.0f, 1.0f, 0.0f);
-
- m_locRot[1] = MT_Matrix3x3( // 90deg - Bottom
- 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f,
- 0.0f,-1.0f, 0.0f);
-
- m_locRot[2] = MT_Matrix3x3( // -90deg - Left
- 0.0f, 0.0f, 1.0f,
- 0.0f, 1.0f, 0.0f,
- -1.0f, 0.0f, 0.0f);
-
- m_locRot[3] = MT_Matrix3x3( // 90deg - Right
- 0.0f, 0.0f,-1.0f,
- 0.0f, 1.0f, 0.0f,
- 1.0f, 0.0f, 0.0f);
-
- m_locRot[4] = MT_Matrix3x3( // 0deg - Front
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f);
-
- m_locRot[5] = MT_Matrix3x3( // 180deg - Back - USED for ENVMAP only
- -1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f,-1.0f);
-
- } else if (m_mode == DOME_PANORAM_SPH) {
-
- m_locRot[0] = MT_Matrix3x3( // Top
- c, s, 0.0f,
- 0.0f,0.0f, -1.0f,
- -s, c, 0.0f);
-
- m_locRot[1] = MT_Matrix3x3( // Bottom
- c, s, 0.0f,
- 0.0f, 0.0f, 1.0f,
- s, -c, 0.0f);
-
- m_locRot[2] = MT_Matrix3x3( // 45deg - Left
- -s, 0.0f, c,
- 0, 1.0f, 0.0f,
- -c, 0.0f, -s);
-
- m_locRot[3] = MT_Matrix3x3( // 45deg - Right
- c, 0.0f, s,
- 0, 1.0f, 0.0f,
- -s, 0.0f, c);
-
- m_locRot[4] = MT_Matrix3x3( // 135deg - LeftBack
- -s, 0.0f, -c,
- 0.0f, 1.0f, 0.0f,
- c, 0.0f, -s);
-
- m_locRot[5] = MT_Matrix3x3( // 135deg - RightBack
- c, 0.0f, -s,
- 0.0f, 1.0f, 0.0f,
- s, 0.0f, c);
- }
-
- // rotating the camera in horizontal axis
- if (m_tilt)
- {
- float tiltdeg = ((m_tilt % 360) * 2 * MT_PI) / 360;
- c = cosf(tiltdeg);
- s = sinf(tiltdeg);
-
- MT_Matrix3x3 tilt_mat = MT_Matrix3x3(
- 1.0f, 0.0f, 0.0f,
- 0.0f, c, -s,
- 0.0f, s, c
- );
-
- for (i =0;i<6;i++)
- m_locRot[i] = tilt_mat * m_locRot[i];
- }
-}
-
-void KX_Dome::RotateCamera(KX_Camera* cam, int i)
-{
-// I'm not using it, I'm doing inline calls for these commands
-// but it's nice to have it here in case I need it
-
- MT_Matrix3x3 camori = cam->GetSGNode()->GetLocalOrientation();
-
- cam->NodeSetLocalOrientation(camori*m_locRot[i]);
- cam->NodeUpdateGS(0.f);
-
- MT_Transform camtrans(cam->GetWorldToCamera());
- MT_Matrix4x4 viewmat(camtrans);
- m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->NodeGetLocalScaling(), cam->GetCameraData()->m_perspective);
- cam->SetModelviewMatrix(viewmat);
-
- // restore the original orientation
- cam->NodeSetLocalOrientation(camori);
- cam->NodeUpdateGS(0.f);
-}
-
-void KX_Dome::Draw(void)
-{
-
- if (fboSupported) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, warp.fboId);
-
- glViewport(0,0,warp.imagesize, warp.imagesize);
- glScissor(0,0,warp.imagesize, warp.imagesize);
- }
-
- switch (m_mode) {
- case DOME_FISHEYE:
- DrawDomeFisheye();
- break;
- case DOME_ENVMAP:
- DrawEnvMap();
- break;
- case DOME_PANORAM_SPH:
- DrawPanorama();
- break;
- case DOME_TRUNCATED_FRONT:
- DrawDomeFisheye();
- break;
- case DOME_TRUNCATED_REAR:
- DrawDomeFisheye();
- break;
- }
-
- if (warp.usemesh)
- {
- if (fboSupported)
- {
- m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- }
- else
- {
- glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]);
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_viewport.GetLeft(), m_viewport.GetBottom(), warp.bufferwidth, warp.bufferheight);
- }
- DrawDomeWarped();
- }
-}
-
-void KX_Dome::DrawEnvMap(void)
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- // Making the viewport always square
-
- int can_width = m_viewport.GetRight();
- int can_height = m_viewport.GetTop();
-
- float ortho_width, ortho_height;
-
- if (warp.usemesh)
- glOrtho((-1.0), 1.0, (-0.66), 0.66, 0.0, 0.0); //stretch the image to reduce resolution lost
-
- else {
- if (can_width/3 <= can_height/2) {
- ortho_width = 1.0f;
- ortho_height = (float)can_height/can_width;
- }
- else {
- ortho_height = 2.0f / 3;
- ortho_width = (float)can_width/can_height * ortho_height;
- }
-
- glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f);
- }
-
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gpuLookAt(0.0f,0.0f,1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f);
-
- glPolygonMode(GL_FRONT, GL_FILL);
- glShadeModel(GL_SMOOTH);
- glDisable(GL_LIGHTING);
- glDisable(GL_DEPTH_TEST);
-
- glEnable(GL_TEXTURE_2D);
- glColor3f(1.0f,1.0f,1.0f);
-
- float uv_ratio = (float)(m_buffersize-1) / m_imagesize;
- double onebythree = 1.0f / 3;
-
- // domefacesId[0] => (top)
- glBindTexture(GL_TEXTURE_2D, domefacesId[0]);
- glBegin(GL_QUADS);
- glTexCoord2f(uv_ratio,uv_ratio);
- glVertex3f( onebythree, 0.0f, 3.0f);
- glTexCoord2f(0.0f,uv_ratio);
- glVertex3f(-onebythree, 0.0f, 3.0f);
- glTexCoord2f(0.0f,0.0f);
- glVertex3f(-onebythree,-2 * onebythree, 3.0f);
- glTexCoord2f(uv_ratio,0.0f);
- glVertex3f(onebythree,-2 * onebythree, 3.0f);
- glEnd();
-
- // domefacesId[1] => (bottom)
- glBindTexture(GL_TEXTURE_2D, domefacesId[1]);
- glBegin(GL_QUADS);
- glTexCoord2f(uv_ratio,uv_ratio);
- glVertex3f(-onebythree, 0.0f, 3.0f);
- glTexCoord2f(0.0f,uv_ratio);
- glVertex3f(-1.0f, 0.0f, 3.0f);
- glTexCoord2f(0.0f,0.0f);
- glVertex3f(-1.0f,-2 * onebythree, 3.0f);
- glTexCoord2f(uv_ratio,0.0f);
- glVertex3f(-onebythree,-2 * onebythree, 3.0f);
- glEnd();
-
- // domefacesId[2] => -90deg (left)
- glBindTexture(GL_TEXTURE_2D, domefacesId[2]);
- glBegin(GL_QUADS);
- glTexCoord2f(uv_ratio,uv_ratio);
- glVertex3f(-onebythree, 2 * onebythree, 3.0f);
- glTexCoord2f(0.0f,uv_ratio);
- glVertex3f(-1.0f, 2 * onebythree, 3.0f);
- glTexCoord2f(0.0f,0.0f);
- glVertex3f(-1.0f, 0.0f, 3.0f);
- glTexCoord2f(uv_ratio,0.0f);
- glVertex3f(-onebythree, 0.0f, 3.0f);
- glEnd();
-
- // domefacesId[3] => 90deg (right)
- glBindTexture(GL_TEXTURE_2D, domefacesId[3]);
- glBegin(GL_QUADS);
- glTexCoord2f(uv_ratio,uv_ratio);
- glVertex3f( 1.0f, 2 * onebythree, 3.0f);
- glTexCoord2f(0.0f,uv_ratio);
- glVertex3f( onebythree, 2 * onebythree, 3.0f);
- glTexCoord2f(0.0f,0.0f);
- glVertex3f( onebythree, 0.0f, 3.0f);
- glTexCoord2f(uv_ratio,0.0f);
- glVertex3f(1.0f, 0.0f, 3.0f);
- glEnd();
-
- // domefacesId[4] => 0deg (front)
- glBindTexture(GL_TEXTURE_2D, domefacesId[4]);
- glBegin(GL_QUADS);
- glTexCoord2f(uv_ratio,uv_ratio);
- glVertex3f( 1.0f, 0.0f, 3.0f);
- glTexCoord2f(0.0f,uv_ratio);
- glVertex3f( onebythree, 0.0f, 3.0f);
- glTexCoord2f(0.0f,0.0f);
- glVertex3f( onebythree,-2 * onebythree, 3.0f);
- glTexCoord2f(uv_ratio,0.0f);
- glVertex3f(1.0f, -2 * onebythree, 3.0f);
- glEnd();
-
- // domefacesId[5] => 180deg (back)
- glBindTexture(GL_TEXTURE_2D, domefacesId[5]);
- glBegin(GL_QUADS);
- glTexCoord2f(uv_ratio,uv_ratio);
- glVertex3f( onebythree, 2 * onebythree, 3.0f);
- glTexCoord2f(0.0f,uv_ratio);
- glVertex3f(-onebythree, 2 * onebythree, 3.0f);
- glTexCoord2f(0.0f,0.0f);
- glVertex3f(-onebythree, 0.0f, 3.0f);
- glTexCoord2f(uv_ratio,0.0f);
- glVertex3f(onebythree, 0.0f, 3.0f);
- glEnd();
-
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_DEPTH_TEST);
-}
-
-void KX_Dome::DrawDomeFisheye(void)
-{
- int i;
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- // Making the viewport always square
-
- int can_width = m_viewport.GetRight();
- int can_height = m_viewport.GetTop();
-
- float ortho_width, ortho_height;
-
- if (m_mode == DOME_FISHEYE) {
- if (warp.usemesh)
- glOrtho((-1.0f), 1.0f, (-1.0f), 1.0f, -20.0f, 10.0f); //stretch the image to reduce resolution lost
-
- else {
- if (can_width < can_height) {
- ortho_width = 1.0f;
- ortho_height = (float)can_height/can_width;
- }
- else {
- ortho_width = (float)can_width/can_height;
- ortho_height = 1.0f;
- }
-
- glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f);
- }
- }
- else if (m_mode == DOME_TRUNCATED_FRONT)
- {
- ortho_width = 1.0f;
- ortho_height = 2.0f * ((float)can_height / can_width) - 1.0f;
-
- glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_width, -20.0f, 10.0f);
- }
- else { //m_mode == DOME_TRUNCATED_REAR
- ortho_width = 1.0f;
- ortho_height = 2.0f * ((float)can_height / can_width) - 1.0f;
-
- glOrtho((-ortho_width), ortho_width, (-ortho_width), ortho_height, -20.0f, 10.0f);
- }
-
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gpuLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f);
-
- if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME)
- glPolygonMode(GL_FRONT, GL_LINE);
- else
- glPolygonMode(GL_FRONT, GL_FILL);
-
- glShadeModel(GL_SMOOTH);
- glDisable(GL_LIGHTING);
- glDisable(GL_DEPTH_TEST);
-
- glEnable(GL_TEXTURE_2D);
- glColor3f(1.0f,1.0f,1.0f);
-
- if (dlistSupported) {
- for (i=0;i<m_numfaces;i++) {
- glBindTexture(GL_TEXTURE_2D, domefacesId[i]);
- glCallList(dlistId+i);
- }
- }
- else { // DisplayLists not supported
- // top triangle
- glBindTexture(GL_TEXTURE_2D, domefacesId[0]);
- GLDrawTriangles(cubetop, nfacestop);
-
- // bottom triangle
- glBindTexture(GL_TEXTURE_2D, domefacesId[1]);
- GLDrawTriangles(cubebottom, nfacesbottom);
-
- // left triangle
- glBindTexture(GL_TEXTURE_2D, domefacesId[2]);
- GLDrawTriangles(cubeleft, nfacesleft);
-
- // right triangle
- glBindTexture(GL_TEXTURE_2D, domefacesId[3]);
- GLDrawTriangles(cuberight, nfacesright);
-
- if (m_angle > 180) {
- // front triangle
- glBindTexture(GL_TEXTURE_2D, domefacesId[4]);
- GLDrawTriangles(cubefront, nfacesfront);
- }
- }
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_DEPTH_TEST);
-}
-
-void KX_Dome::DrawPanorama(void)
-{
- int i;
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- // Making the viewport always square
-
- int can_width = m_viewport.GetRight();
- int can_height = m_viewport.GetTop();
-
- float ortho_height = 1.0f;
- float ortho_width = 1.0f;
-
- if (warp.usemesh)
- glOrtho((-1.0f), 1.0f, (-0.5f), 0.5f, -20.0f, 10.0f); //stretch the image to reduce resolution lost
-
- else {
- //using all the screen
- if ((can_width / 2) <= (can_height)) {
- ortho_width = 1.0f;
- ortho_height = (float)can_height/can_width;
- }
- else {
- ortho_width = (float)can_width / can_height * 0.5f;
- ortho_height = 0.5f;
- }
-
- glOrtho((-ortho_width), ortho_width, (-ortho_height), ortho_height, -20.0f, 10.0f);
- }
-
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gpuLookAt(0.0f,-1.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,1.0f);
-
- if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME)
- glPolygonMode(GL_FRONT, GL_LINE);
- else
- glPolygonMode(GL_FRONT, GL_FILL);
-
- glShadeModel(GL_SMOOTH);
- glDisable(GL_LIGHTING);
- glDisable(GL_DEPTH_TEST);
-
- glEnable(GL_TEXTURE_2D);
- glColor3f(1.0f,1.0f,1.0f);
-
- if (dlistSupported) {
- for (i=0;i<m_numfaces;i++) {
- glBindTexture(GL_TEXTURE_2D, domefacesId[i]);
- glCallList(dlistId+i);
- }
- }
- else {
- // domefacesId[4] => (top)
- glBindTexture(GL_TEXTURE_2D, domefacesId[0]);
- GLDrawTriangles(cubetop, nfacestop);
-
- // domefacesId[5] => (bottom)
- glBindTexture(GL_TEXTURE_2D, domefacesId[1]);
- GLDrawTriangles(cubebottom, nfacesbottom);
-
- // domefacesId[1] => -45deg (left)
- glBindTexture(GL_TEXTURE_2D, domefacesId[2]);
- GLDrawTriangles(cubeleft, nfacesleft);
-
- // domefacesId[2] => 45deg (right)
- glBindTexture(GL_TEXTURE_2D, domefacesId[3]);
- GLDrawTriangles(cuberight, nfacesright);
-
- // domefacesId[0] => -135deg (leftback)
- glBindTexture(GL_TEXTURE_2D, domefacesId[4]);
- GLDrawTriangles(cubeleftback, nfacesleftback);
-
- // domefacesId[3] => 135deg (rightback)
- glBindTexture(GL_TEXTURE_2D, domefacesId[5]);
- GLDrawTriangles(cuberightback, nfacesrightback);
- }
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_DEPTH_TEST);
-}
-
-void KX_Dome::DrawDomeWarped(void)
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- // Making the viewport always square
- int can_width = m_viewport.GetRight();
- int can_height = m_viewport.GetTop();
-
- double screen_ratio = can_width/ (double) can_height;
-
- glOrtho(-screen_ratio,screen_ratio,-1.0f,1.0f,-20.0f,10.0f);
-
-
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gpuLookAt(0.0f, 0.0f, 1.0f, 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f);
-
- if (m_drawingmode == RAS_IRasterizer::KX_WIREFRAME)
- glPolygonMode(GL_FRONT, GL_LINE);
- else
- glPolygonMode(GL_FRONT, GL_FILL);
-
- glShadeModel(GL_SMOOTH);
- glDisable(GL_LIGHTING);
- glDisable(GL_DEPTH_TEST);
-
- glEnable(GL_TEXTURE_2D);
- glColor3f(1.0f,1.0f,1.0f);
-
- if (dlistSupported) {
- glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]);
- glCallList(dlistId + m_numfaces);
- }
- else {
- glBindTexture(GL_TEXTURE_2D, domefacesId[m_numfaces]);
- GLDrawWarpQuads();
- }
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_DEPTH_TEST);
-}
-
-void KX_Dome::BindImages(int i)
-{
- glBindTexture(GL_TEXTURE_2D, domefacesId[i]);
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_viewport.GetLeft(), m_viewport.GetBottom(), m_buffersize, m_buffersize);
-}
-
-void KX_Dome::RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i)
-{
- if (!cam)
- return;
-
- m_canvas->SetViewPort(0,0,m_buffersize-1,m_buffersize-1);
-
-// m_rasterizer->SetAmbient();
- m_rasterizer->DisplayFog();
-
- CalculateFrustum(cam); //calculates m_projmat
- cam->SetProjectionMatrix(m_projmat);
- m_rasterizer->SetProjectionMatrix(cam->GetProjectionMatrix());
-// Dome_RotateCamera(cam,i);
-
- MT_Matrix3x3 camori = cam->GetSGNode()->GetLocalOrientation();
-
- cam->NodeSetLocalOrientation(camori*m_locRot[i]);
- cam->NodeUpdateGS(0.f);
-
- MT_Transform camtrans(cam->GetWorldToCamera());
- MT_Matrix4x4 viewmat(camtrans);
- m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->NodeGetLocalScaling(), 1.0f);
- cam->SetModelviewMatrix(viewmat);
-
- // restore the original orientation
- cam->NodeSetLocalOrientation(camori);
- cam->NodeUpdateGS(0.f);
-
- scene->CalculateVisibleMeshes(m_rasterizer,cam);
-
- m_engine->UpdateAnimations(scene);
-
- scene->RenderBuckets(camtrans, m_rasterizer);
-}
-
diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h
deleted file mode 100644
index 5a0c4588ae2..00000000000
--- a/source/gameengine/Ketsji/KX_Dome.h
+++ /dev/null
@@ -1,197 +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.
- *
- * Contributor(s): Dalai Felinto
- *
- * This source uses some of the ideas and code from Paul Bourke.
- * Developed as part of a Research and Development project for
- * SAT - La Société des arts technologiques.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_Dome.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_DOME_H__
-#define __KX_DOME_H__
-
-#include "KX_Scene.h"
-#include "KX_Camera.h"
-#include "DNA_screen_types.h"
-#include "RAS_ICanvas.h"
-#include "RAS_IRasterizer.h"
-#include "KX_KetsjiEngine.h"
-
-#include "GPU_glew.h"
-#include <vector>
-
-#include "MEM_guardedalloc.h"
-#include "BKE_text.h"
-
-//Dome modes: limit hardcoded in buttons_scene.c
-#define DOME_FISHEYE 1
-#define DOME_TRUNCATED_FRONT 2
-#define DOME_TRUNCATED_REAR 3
-#define DOME_ENVMAP 4
-#define DOME_PANORAM_SPH 5
-#define DOME_NUM_MODES 6
-
-
-/// class for render 3d scene
-class KX_Dome
-{
-public:
- /// constructor
- KX_Dome (RAS_ICanvas* m_canvas,
- /// rasterizer
- RAS_IRasterizer* m_rasterizer,
- /// engine
- KX_KetsjiEngine* m_engine,
-
- short res,
- short mode,
- short angle,
- float resbuf,
- short tilt,
- struct Text* warptext
- );
-
- /// destructor
- virtual ~KX_Dome (void);
-
- //openGL checks:
- bool dlistSupported;
- bool fboSupported;
-
- //openGL names:
- GLuint domefacesId[7]; /* ID of the images -- room for 7 images, using only 4 for 180deg x 360deg dome,
- * 6 for panoramic and +1 for warp mesh */
- GLuint dlistId; /* ID of the Display Lists of the images (used as an offset) */
-
- typedef struct {
- double u[3], v[3];
- MT_Vector3 verts[3]; //three verts
- } DomeFace;
-
- //mesh warp functions
- typedef struct {
- double x, y, u, v, i;
- } WarpMeshNode;
-
- struct {
- bool usemesh;
- int mode;
- int n_width, n_height; //nodes width and height
- int imagesize;
- int bufferwidth, bufferheight;
- GLuint fboId;
- vector <vector <WarpMeshNode> > nodes;
- } warp;
-
- bool ParseWarpMesh(STR_String text);
-
- vector <DomeFace> cubetop, cubebottom, cuberight, cubeleft, cubefront, cubeback; //for fisheye
- vector <DomeFace> cubeleftback, cuberightback; //for panorama
-
- int nfacestop, nfacesbottom, nfacesleft, nfacesright, nfacesfront, nfacesback;
- int nfacesleftback, nfacesrightback;
-
- int GetNumberRenders() { return m_numfaces; }
-
- void RenderDome(void);
- void RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i);
- void BindImages(int i);
-
- void SetViewPort(const int viewport[4]);
- void CalculateFrustum(KX_Camera* cam);
- void RotateCamera(KX_Camera* cam, int i);
-
- //Mesh creation Functions
- void CreateMeshDome180(void);
- void CreateMeshDome250(void);
- void CreateMeshPanorama(void);
-
- void SplitFace(vector <DomeFace>& face, int *nfaces);
-
- void FlattenDome(MT_Vector3 verts[3]);
- void FlattenPanorama(MT_Vector3 verts[3]);
-
- //Draw functions
- void GLDrawTriangles(vector <DomeFace>& face, int nfaces);
- void GLDrawWarpQuads(void);
- void Draw(void);
- void DrawDomeFisheye(void);
- void DrawEnvMap(void);
- void DrawPanorama(void);
- void DrawDomeWarped(void);
-
- //setting up openGL
- void CreateGLImages(void);
- void ClearGLImages(void);//called on resize
- bool CreateDL(void); //create Display Lists
- void ClearDL(void); //remove Display Lists
- bool CreateFBO(void);//create FBO (for warp mesh)
- void ClearFBO(void); //remove FBO
-
- void CalculateCameraOrientation();
- void CalculateImageSize(); //set m_imagesize
-
- int canvaswidth;
- int canvasheight;
-
-protected:
- int m_drawingmode;
-
- int m_imagesize;
- int m_buffersize; // canvas small dimension
- int m_numfaces; // 4 to 6 depending on the kind of dome image
- int m_numimages; //numfaces +1 if we have warp mesh
-
- short m_resolution; //resolution to tessellate the mesh
- short m_mode; // the mode (truncated, warped, panoramic,...)
- short m_angle; //the angle of the fisheye
- float m_radangle; //the angle of the fisheye in radians
- float m_resbuffer; //the resolution of the buffer
- short m_tilt; //the dome tilt (camera rotation on horizontal axis)
-
- RAS_Rect m_viewport;
-
- MT_Matrix4x4 m_projmat;
-
- MT_Matrix3x3 m_locRot[6]; // the rotation matrix
-
- /// rendered scene
- KX_Scene * m_scene;
-
- /// canvas
- RAS_ICanvas* m_canvas;
- /// rasterizer
- RAS_IRasterizer* m_rasterizer;
- /// render tools
- RAS_IRenderTools* m_rendertools;
- /// engine
- KX_KetsjiEngine* m_engine;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_Dome")
-#endif
-};
-
-#endif /* __KX_DOME_H__ */
diff --git a/source/gameengine/Ketsji/KX_EmptyObject.cpp b/source/gameengine/Ketsji/KX_EmptyObject.cpp
deleted file mode 100644
index 670329a4350..00000000000
--- a/source/gameengine/Ketsji/KX_EmptyObject.cpp
+++ /dev/null
@@ -1,37 +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_EmptyObject.cpp
- * \ingroup ketsji
- */
-
-#include "KX_EmptyObject.h"
-
-KX_EmptyObject::~KX_EmptyObject()
-{
-
-}
diff --git a/source/gameengine/Ketsji/KX_EmptyObject.h b/source/gameengine/Ketsji/KX_EmptyObject.h
deleted file mode 100644
index 63a0782a544..00000000000
--- a/source/gameengine/Ketsji/KX_EmptyObject.h
+++ /dev/null
@@ -1,50 +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_EmptyObject.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_EMPTYOBJECT_H__
-#define __KX_EMPTYOBJECT_H__
-#include "KX_GameObject.h"
-
-class KX_EmptyObject : public KX_GameObject
-{
-public:
- KX_EmptyObject(void* sgReplicationInfo,SG_Callbacks callbacks) :
- KX_GameObject(sgReplicationInfo,callbacks)
- {};
- virtual ~KX_EmptyObject();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_EmptyObject")
-#endif
-};
-
-#endif /* __KX_EMPTYOBJECT_H__ */
diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp
deleted file mode 100644
index ae79284288d..00000000000
--- a/source/gameengine/Ketsji/KX_FontObject.cpp
+++ /dev/null
@@ -1,300 +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_FontObject.cpp
- * \ingroup ketsji
- */
-
-#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 "EXP_StringValue.h"
-#include "RAS_IRasterizer.h"
-
-/* paths needed for font load */
-#include "BLI_blenlib.h"
-#include "BKE_global.h"
-#include "BKE_font.h"
-#include "BKE_main.h"
-#include "DNA_packedFile_types.h"
-
-extern "C" {
-#include "BLF_api.h"
-}
-
-#define BGE_FONT_RES 100
-
-/* proptotype */
-int GetFontId(VFont *font);
-
-static std::vector<STR_String> split_string(STR_String str)
-{
- std::vector<STR_String> text = std::vector<STR_String>();
-
- /* Split the string upon new lines */
- int begin=0, end=0;
- while (end < str.Length())
- {
- if (str.GetAt(end) == '\n')
- {
- text.push_back(str.Mid(begin, end-begin));
- begin = end+1;
- }
- end++;
- }
- //Now grab the last line
- text.push_back(str.Mid(begin, end-begin));
-
- return text;
-}
-
-KX_FontObject::KX_FontObject(void* sgReplicationInfo,
- SG_Callbacks callbacks,
- RAS_IRasterizer* rasterizer,
- Object *ob,
- bool do_color_management):
- KX_GameObject(sgReplicationInfo, callbacks),
- m_object(ob),
- m_dpi(72),
- m_resolution(1.f),
- m_rasterizer(rasterizer),
- m_do_color_management(do_color_management)
-{
- Curve *text = static_cast<Curve *> (ob->data);
- m_text = split_string(text->str);
- m_fsize = text->fsize;
- m_line_spacing = text->linedist;
- m_offset = MT_Vector3(text->xof, text->yof, 0);
-
- m_fontid = GetFontId(text->vfont);
-
- /* initialize the color with the object color and store it in the KX_Object class
- * This is a workaround waiting for the fix:
- * [#25487] BGE: Object Color only works when it has a keyed frame */
- copy_v4_v4(m_color, (const float*) ob->col);
- this->SetObjectColor((const MT_Vector4&) m_color);
-}
-
-KX_FontObject::~KX_FontObject()
-{
- //remove font from the scene list
- //it's handled in KX_Scene::NewRemoveObject
-}
-
-CValue* KX_FontObject::GetReplica()
-{
- KX_FontObject* replica = new KX_FontObject(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_FontObject::ProcessReplica()
-{
- KX_GameObject::ProcessReplica();
-}
-
-int GetFontId(VFont *vfont)
-{
- PackedFile *packedfile=NULL;
- int fontid = -1;
-
- if (vfont->packedfile) {
- packedfile= vfont->packedfile;
- fontid= BLF_load_mem(vfont->name, (unsigned char*)packedfile->data, packedfile->size);
-
- if (fontid == -1) {
- printf("ERROR: packed font \"%s\" could not be loaded.\n", vfont->name);
- fontid = BLF_load("default");
- }
- return fontid;
- }
-
- /* once we have packed working we can load the builtin font */
- const char *filepath = vfont->name;
- if (BKE_vfont_is_builtin(vfont)) {
- fontid = BLF_load("default");
-
- /* XXX the following code is supposed to work (after you add get_builtin_packedfile to BKE_font.h )
- * unfortunately it's crashing on blf_glyph.c:173 because gc->glyph_width_max is 0
- */
- // packedfile=get_builtin_packedfile();
- // fontid= BLF_load_mem(font->name, (unsigned char*)packedfile->data, packedfile->size);
- // return fontid;
-
- return BLF_load("default");
- }
-
- /* convert from absolute to relative */
- char expanded[256]; // font names can be bigger than FILE_MAX (240)
- BLI_strncpy(expanded, filepath, 256);
- BLI_path_abs(expanded, G.main->name);
-
- fontid = BLF_load(expanded);
-
- /* fallback */
- if (fontid == -1)
- fontid = BLF_load("default");
-
- return fontid;
-}
-
-void KX_FontObject::DrawFontText()
-{
- /* Allow for some logic brick control */
- if (this->GetProperty("Text"))
- m_text = split_string(this->GetProperty("Text")->GetText());
-
- /* only draws the text if visible */
- if (this->GetVisible() == 0) return;
-
- /* update the animated color */
- this->GetObjectColor().getValue(m_color);
-
- /* Font Objects don't use the glsl shader, this color management code is copied from gpu_shader_material.glsl */
- float color[4];
- if (m_do_color_management) {
- linearrgb_to_srgb_v4(color, m_color);
- }
- else {
- copy_v4_v4(color, m_color);
- }
-
- /* HARDCODED MULTIPLICATION FACTOR - this will affect the render resolution directly */
- const float RES = BGE_FONT_RES * m_resolution;
-
- const float size = m_fsize * this->NodeGetWorldScaling()[0] * RES;
- const float aspect = m_fsize / size;
-
- /* Get a working copy of the OpenGLMatrix to use */
- float *mat = GetOpenGLMatrix();
-
- /* Account for offset */
- MT_Vector3 offset = this->NodeGetWorldOrientation() * m_offset * this->NodeGetWorldScaling();
- mat[12] += offset[0]; mat[13] += offset[1]; mat[14] += offset[2];
-
- /* Orient the spacing vector */
- MT_Vector3 spacing = MT_Vector3(0.0f, m_fsize*m_line_spacing, 0.0f);
- spacing = this->NodeGetWorldOrientation() * spacing * this->NodeGetWorldScaling()[1];
-
- /* Draw each line, taking spacing into consideration */
- for (int i=0; i<m_text.size(); ++i)
- {
- if (i!=0)
- {
- mat[12] -= spacing[0];
- mat[13] -= spacing[1];
- mat[14] -= spacing[2];
- }
- m_rasterizer->RenderText3D(m_fontid, m_text[i], int(size), m_dpi, color, mat, aspect);
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python Integration Hooks */
-/* ------------------------------------------------------------------------- */
-
-PyTypeObject KX_FontObject::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_FontObject",
- sizeof(PyObjectPlus_Proxy),
- 0,
- py_base_dealloc,
- 0,
- 0,
- 0,
- 0,
- py_base_repr,
- 0,
- &KX_GameObject::Sequence,
- &KX_GameObject::Mapping,
- 0,0,0,
- NULL,
- NULL,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- 0,0,0,0,0,0,0,
- Methods,
- 0,
- 0,
- &KX_GameObject::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_FontObject::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_FontObject::Attributes[] = {
- //KX_PYATTRIBUTE_STRING_RW("text", 0, 280, false, KX_FontObject, m_text[0]), //arbitrary limit. 280 = 140 unicode chars in unicode
- KX_PYATTRIBUTE_RW_FUNCTION("text", KX_FontObject, pyattr_get_text, pyattr_set_text),
- KX_PYATTRIBUTE_FLOAT_RW("size", 0.0001f, 10000.0f, KX_FontObject, m_fsize),
- KX_PYATTRIBUTE_FLOAT_RW("resolution", 0.0001f, 10000.0f, KX_FontObject, m_resolution),
- /* KX_PYATTRIBUTE_INT_RW("dpi", 0, 10000, false, KX_FontObject, m_dpi), */// no real need for expose this I think
- { NULL } //Sentinel
-};
-
-PyObject *KX_FontObject::pyattr_get_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_FontObject* self = static_cast<KX_FontObject*>(self_v);
- STR_String str = STR_String();
- for (int i=0; i<self->m_text.size(); ++i)
- {
- if (i!=0)
- str += '\n';
- str += self->m_text[i];
- }
- return PyUnicode_From_STR_String(str);
-}
-
-int KX_FontObject::pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_FontObject* self = static_cast<KX_FontObject*>(self_v);
- if (!PyUnicode_Check(value))
- return PY_SET_ATTR_FAIL;
- const char *chars = _PyUnicode_AsString(value);
-
- /* Allow for some logic brick control */
- CValue* tprop = self->GetProperty("Text");
- if (tprop) {
- CValue *newstringprop = new CStringValue(STR_String(chars), "Text");
- self->SetProperty("Text", newstringprop);
- newstringprop->Release();
- }
- else {
- self->m_text = split_string(STR_String(chars));
- }
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h
deleted file mode 100644
index bf70eedfde6..00000000000
--- a/source/gameengine/Ketsji/KX_FontObject.h
+++ /dev/null
@@ -1,81 +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_FontObject.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_FONTOBJECT_H__
-#define __KX_FONTOBJECT_H__
-#include "KX_GameObject.h"
-
-class KX_FontObject : public KX_GameObject
-{
-public:
- Py_Header
- KX_FontObject(void* sgReplicationInfo,
- SG_Callbacks callbacks,
- RAS_IRasterizer* rasterizer,
- Object *ob,
- bool do_color_management);
-
- virtual ~KX_FontObject();
-
- void DrawFontText();
-
- /**
- * Inherited from CValue -- return a new copy of this
- * instance allocated on the heap. Ownership of the new
- * object belongs with the caller.
- */
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
- virtual int GetGameObjectType() { return OBJ_TEXT; }
-
-protected:
- std::vector<STR_String> m_text;
- Object* m_object;
- int m_fontid;
- int m_dpi;
- float m_fsize;
- float m_resolution;
- float m_color[4];
- float m_line_spacing;
- MT_Vector3 m_offset;
-
- class RAS_IRasterizer* m_rasterizer; //needed for drawing routine
-
- bool m_do_color_management;
-
-#ifdef WITH_PYTHON
- static PyObject* pyattr_get_text(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif
-
-};
-
-#endif /* __KX_FONTOBJECT_H__ */
diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp
deleted file mode 100644
index f1bd253f8b3..00000000000
--- a/source/gameengine/Ketsji/KX_GameActuator.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * global game stuff
- *
- *
- * ***** 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_GameActuator.cpp
- * \ingroup ketsji
- */
-
-
-#include <stddef.h>
-
-#include "SCA_IActuator.h"
-#include "KX_GameActuator.h"
-//#include <iostream>
-#include "KX_Scene.h"
-#include "KX_KetsjiEngine.h"
-#include "KX_PythonInit.h" /* for config load/saving */
-#include "RAS_ICanvas.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_GameActuator::KX_GameActuator(SCA_IObject *gameobj,
- int mode,
- const STR_String& filename,
- const STR_String& loadinganimationname,
- SCA_IScene* scene,
- KX_KetsjiEngine* ketsjiengine)
- : SCA_IActuator(gameobj, KX_ACT_GAME)
-{
- m_mode = mode;
- m_filename = filename;
- m_loadinganimationname = loadinganimationname;
- m_scene = scene;
- m_ketsjiengine = ketsjiengine;
-} /* End of constructor */
-
-
-
-KX_GameActuator::~KX_GameActuator()
-{
- // there's nothing to be done here, really....
-} /* end of destructor */
-
-
-
-CValue* KX_GameActuator::GetReplica()
-{
- KX_GameActuator* replica = new KX_GameActuator(*this);
- replica->ProcessReplica();
-
- return replica;
-}
-
-
-
-bool KX_GameActuator::Update()
-{
- // bool result = false; /*unused*/
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
-
- switch (m_mode)
- {
- case KX_GAME_LOAD:
- case KX_GAME_START:
- {
- if (m_ketsjiengine)
- {
- STR_String exitstring = "start other game";
- m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_START_OTHER_GAME);
- m_ketsjiengine->SetNameNextGame(m_filename);
- m_scene->AddDebugProperty((this)->GetParent(), exitstring);
- }
-
- break;
- }
- case KX_GAME_RESTART:
- {
- if (m_ketsjiengine)
- {
- STR_String exitstring = "restarting game";
- m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_RESTART_GAME);
- m_ketsjiengine->SetNameNextGame(m_filename);
- m_scene->AddDebugProperty((this)->GetParent(), exitstring);
- }
- break;
- }
- case KX_GAME_QUIT:
- {
- if (m_ketsjiengine)
- {
- STR_String exitstring = "quiting game";
- m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_QUIT_GAME);
- m_scene->AddDebugProperty((this)->GetParent(), exitstring);
- }
- break;
- }
- case KX_GAME_SAVECFG:
- {
-#ifdef WITH_PYTHON
- if (m_ketsjiengine)
- {
- char mashal_path[512];
- char *marshal_buffer = NULL;
- unsigned int marshal_length;
- FILE *fp = NULL;
-
- pathGamePythonConfig(mashal_path);
- marshal_length = saveGamePythonConfig(&marshal_buffer);
-
- if (marshal_length && marshal_buffer) {
- fp = fopen(mashal_path, "wb");
- if (fp) {
- if (fwrite(marshal_buffer, 1, marshal_length, fp) != marshal_length) {
- printf("Warning: could not write marshal data\n");
- }
- fclose(fp);
- } else {
- printf("Warning: could not open marshal file\n");
- }
- } else {
- printf("Warning: could not create marshal buffer\n");
- }
- if (marshal_buffer)
- delete [] marshal_buffer;
- }
- break;
-#endif // WITH_PYTHON
- }
- case KX_GAME_LOADCFG:
- {
-#ifdef WITH_PYTHON
- if (m_ketsjiengine)
- {
- char mashal_path[512];
- char *marshal_buffer;
- int marshal_length;
- FILE *fp = NULL;
- int result;
-
- pathGamePythonConfig(mashal_path);
-
- fp = fopen(mashal_path, "rb");
- if (fp) {
- // obtain file size:
- fseek (fp , 0 , SEEK_END);
- marshal_length = ftell(fp);
- if (marshal_length == -1) {
- printf("warning: could not read position of '%s'\n", mashal_path);
- fclose(fp);
- break;
- }
- rewind(fp);
-
- marshal_buffer = (char*) malloc (sizeof(char)*marshal_length);
-
- result = fread (marshal_buffer, 1, marshal_length, fp);
-
- if (result == marshal_length) {
- loadGamePythonConfig(marshal_buffer, marshal_length);
- } else {
- printf("warning: could not read all of '%s'\n", mashal_path);
- }
-
- free(marshal_buffer);
- fclose(fp);
- } else {
- printf("warning: could not open '%s'\n", mashal_path);
- }
- }
- break;
-#endif // WITH_PYTHON
- }
- case KX_GAME_SCREENSHOT:
- {
- RAS_ICanvas *canvas = m_ketsjiengine->GetCanvas();
- if (canvas) {
- canvas->MakeScreenShot(m_filename);
- }
- else {
- printf("KX_GAME_SCREENSHOT error: Rasterizer not available");
- }
- break;
- }
- default:
- ; /* do nothing? this is an internal error !!! */
- }
-
- return false;
-}
-
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_GameActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_GameActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_GameActuator::Methods[] =
-{
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_GameActuator::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW("fileName",0,100,false,KX_GameActuator,m_filename),
- KX_PYATTRIBUTE_INT_RW("mode", KX_GAME_NODEF+1, KX_GAME_MAX-1, true, KX_GameActuator, m_mode),
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h
deleted file mode 100644
index 57472836bb2..00000000000
--- a/source/gameengine/Ketsji/KX_GameActuator.h
+++ /dev/null
@@ -1,91 +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_GameActuator.h
- * \ingroup ketsji
- * \brief actuator for global game stuff
- */
-
-#ifndef __KX_GAMEACTUATOR_H__
-#define __KX_GAMEACTUATOR_H__
-
-#include "SCA_IActuator.h"
-
-#include "SCA_IScene.h" /* Replace_IScene only */
-#include "KX_Scene.h" /* Replace_IScene only */
-
-class KX_GameActuator : public SCA_IActuator
-{
- Py_Header
-protected:
- int m_mode;
- bool m_restart;
- STR_String m_filename;
- STR_String m_loadinganimationname;
- class SCA_IScene* m_scene;
- class KX_KetsjiEngine* m_ketsjiengine;
-
- public:
- enum KX_GameActuatorMode
- {
- KX_GAME_NODEF = 0,
- KX_GAME_LOAD,
- KX_GAME_START,
- KX_GAME_RESTART,
- KX_GAME_QUIT,
- KX_GAME_SAVECFG,
- KX_GAME_LOADCFG,
- KX_GAME_SCREENSHOT,
- KX_GAME_MAX
-
- };
-
- KX_GameActuator(SCA_IObject* gameobj,
- int mode,
- const STR_String& filename,
- const STR_String& loadinganimationname,
- SCA_IScene* scene,
- KX_KetsjiEngine* ketsjiEngine);
- virtual ~KX_GameActuator();
-
- virtual CValue* GetReplica();
-
- virtual bool Update();
-
- virtual void Replace_IScene(SCA_IScene *val)
- {
- m_scene= val;
- };
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
-}; /* end of class KX_GameActuator */
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
deleted file mode 100644
index 3244400e1bd..00000000000
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ /dev/null
@@ -1,4203 +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 *****
- * Game object wrapper
- */
-
-/** \file gameengine/Ketsji/KX_GameObject.cpp
- * \ingroup ketsji
- */
-
-#ifdef _MSC_VER
- /* This warning tells us about truncation of __long__ stl-generated names.
- * It can occasionally cause DevStudio to have internal compiler warnings. */
-# pragma warning( disable:4786 )
-#endif
-
-#include "RAS_IPolygonMaterial.h"
-#include "KX_BlenderMaterial.h"
-#include "KX_GameObject.h"
-#include "KX_Camera.h" // only for their ::Type
-#include "KX_Light.h" // only for their ::Type
-#include "KX_FontObject.h" // only for their ::Type
-#include "RAS_MeshObject.h"
-#include "KX_NavMeshObject.h"
-#include "KX_MeshProxy.h"
-#include "KX_PolyProxy.h"
-#include <stdio.h> // printf
-#include "SG_Controller.h"
-#include "PHY_IGraphicController.h"
-#include "SG_Node.h"
-#include "KX_ClientObjectInfo.h"
-#include "RAS_BucketManager.h"
-#include "KX_RayCast.h"
-#include "KX_PythonInit.h"
-#include "KX_PyMath.h"
-#include "SCA_IActuator.h"
-#include "SCA_ISensor.h"
-#include "SCA_IController.h"
-#include "NG_NetworkScene.h" //Needed for sendMessage()
-#include "KX_ObstacleSimulation.h"
-#include "KX_Scene.h"
-
-#include "BKE_object.h"
-
-#include "BL_ActionManager.h"
-#include "BL_Action.h"
-
-#include "EXP_PyObjectPlus.h" /* python stuff */
-#include "EXP_ListWrapper.h"
-#include "BLI_utildefines.h"
-
-#ifdef WITH_PYTHON
-# include "EXP_PythonCallBack.h"
-# include "python_utildefines.h"
-#endif
-
-// This file defines relationships between parents and children
-// in the game engine.
-
-#include "KX_SG_NodeRelationships.h"
-
-#include "BLI_math.h"
-
-static MT_Point3 dummy_point= MT_Point3(0.0f, 0.0f, 0.0f);
-static MT_Vector3 dummy_scaling = MT_Vector3(1.0f, 1.0f, 1.0f);
-static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3(1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f);
-
-KX_GameObject::KX_GameObject(
- void* sgReplicationInfo,
- SG_Callbacks callbacks)
- : SCA_IObject(),
- m_bDyna(false),
- m_layer(0),
- m_currentLodLevel(0),
- m_previousLodLevel(0),
- m_pBlenderObject(NULL),
- m_pBlenderGroupObject(NULL),
- m_bUseObjectColor(false),
- m_bIsNegativeScaling(false),
- m_objectColor(1.0f, 1.0f, 1.0f, 1.0f),
- m_bVisible(true),
- m_bCulled(true),
- m_bOccluder(false),
- m_pPhysicsController(NULL),
- m_pGraphicController(NULL),
- m_pObstacleSimulation(NULL),
- m_pInstanceObjects(NULL),
- m_pDupliGroupObject(NULL),
- m_actionManager(NULL),
- m_bRecordAnimation(false),
- m_isDeformable(false)
-
-#ifdef WITH_PYTHON
- , m_attr_dict(NULL),
- m_collisionCallbacks(NULL)
-#endif
-{
- m_ignore_activity_culling = false;
- m_pClient_info = new KX_ClientObjectInfo(this, KX_ClientObjectInfo::ACTOR);
- m_pSGNode = new SG_Node(this,sgReplicationInfo,callbacks);
-
- // define the relationship between this node and it's parent.
-
- KX_NormalParentRelation * parent_relation =
- KX_NormalParentRelation::New();
- m_pSGNode->SetParentRelation(parent_relation);
-};
-
-
-
-KX_GameObject::~KX_GameObject()
-{
-#ifdef WITH_PYTHON
- if (m_attr_dict) {
- PyDict_Clear(m_attr_dict); /* in case of circular refs or other weird cases */
- /* Py_CLEAR: Py_DECREF's and NULL's */
- Py_CLEAR(m_attr_dict);
- }
- // Unregister collision callbacks
- // Do this before we start freeing physics information like m_pClient_info
- if (m_collisionCallbacks) {
- UnregisterCollisionCallbacks();
- Py_CLEAR(m_collisionCallbacks);
- }
-#endif // WITH_PYTHON
-
- RemoveMeshes();
-
- // is this delete somewhere ?
- //if (m_sumoObj)
- // delete m_sumoObj;
- delete m_pClient_info;
- //if (m_pSGNode)
- // delete m_pSGNode;
- if (m_pSGNode)
- {
- // must go through controllers and make sure they will not use us anymore
- // This is important for KX_BulletPhysicsControllers that unregister themselves
- // from the object when they are deleted.
- SGControllerList::iterator contit;
- SGControllerList& controllers = m_pSGNode->GetSGControllerList();
- for (contit = controllers.begin();contit!=controllers.end();++contit)
- {
- (*contit)->ClearObject();
- }
- m_pSGNode->SetSGClientObject(NULL);
-
- /* m_pSGNode is freed in KX_Scene::RemoveNodeDestructObject */
- }
- if (m_pGraphicController)
- {
- delete m_pGraphicController;
- }
-
- if (m_pPhysicsController)
- {
- delete m_pPhysicsController;
- }
-
- if (m_pObstacleSimulation)
- {
- m_pObstacleSimulation->DestroyObstacleForObj(this);
- }
-
- if (m_actionManager)
- {
- delete m_actionManager;
- }
-
- if (m_pDupliGroupObject)
- {
- m_pDupliGroupObject->Release();
- }
-
- if (m_pInstanceObjects)
- {
- m_pInstanceObjects->Release();
- }
-}
-
-KX_GameObject* KX_GameObject::GetClientObject(KX_ClientObjectInfo *info)
-{
- if (!info)
- return NULL;
- return info->m_gameobject;
-}
-
-CValue* KX_GameObject:: Calc(VALUE_OPERATOR op, CValue *val)
-{
- return NULL;
-}
-
-
-
-CValue* KX_GameObject::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
-{
- return NULL;
-}
-
-
-
-const STR_String & KX_GameObject::GetText()
-{
- return m_text;
-}
-
-
-
-double KX_GameObject::GetNumber()
-{
- return 0;
-}
-
-
-
-STR_String& KX_GameObject::GetName()
-{
- return m_name;
-}
-
-
-/* Set the name of the value */
-void KX_GameObject::SetName(const char *name)
-{
- m_name = name;
-}
-
-PHY_IPhysicsController* KX_GameObject::GetPhysicsController()
-{
- return m_pPhysicsController;
-}
-
-KX_GameObject* KX_GameObject::GetDupliGroupObject()
-{
- return m_pDupliGroupObject;
-}
-
-CListValue* KX_GameObject::GetInstanceObjects()
-{
- return m_pInstanceObjects;
-}
-
-void KX_GameObject::AddInstanceObjects(KX_GameObject* obj)
-{
- if (!m_pInstanceObjects)
- m_pInstanceObjects = new CListValue();
-
- obj->AddRef();
- m_pInstanceObjects->Add(obj);
-}
-
-void KX_GameObject::RemoveInstanceObject(KX_GameObject* obj)
-{
- assert(m_pInstanceObjects);
- m_pInstanceObjects->RemoveValue(obj);
- obj->Release();
-}
-
-void KX_GameObject::RemoveDupliGroupObject()
-{
- if (m_pDupliGroupObject) {
- m_pDupliGroupObject->Release();
- m_pDupliGroupObject = NULL;
- }
-}
-
-void KX_GameObject::SetDupliGroupObject(KX_GameObject* obj)
-{
- obj->AddRef();
- m_pDupliGroupObject = obj;
-}
-
-void KX_GameObject::AddConstraint(bRigidBodyJointConstraint *cons)
-{
- m_constraints.push_back(cons);
-}
-
-std::vector<bRigidBodyJointConstraint*> KX_GameObject::GetConstraints()
-{
- return m_constraints;
-}
-
-void KX_GameObject::ClearConstraints()
-{
- m_constraints.clear();
-}
-
-KX_GameObject* KX_GameObject::GetParent()
-{
- KX_GameObject* result = NULL;
- SG_Node* node = m_pSGNode;
-
- while (node && !result)
- {
- node = node->GetSGParent();
- if (node)
- result = (KX_GameObject*)node->GetSGClientObject();
- }
-
- return result;
-
-}
-
-void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCompound, bool ghost)
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (obj &&
- GetSGNode() && // object is not zombi
- obj->GetSGNode() && // object is not zombi
- GetSGNode()->GetSGParent() != obj->GetSGNode() && // not already parented to same object
- !GetSGNode()->IsAncessor(obj->GetSGNode()) && // no parenting loop
- this != obj) // not the object itself
- {
- // Make sure the objects have some scale
- MT_Vector3 scale1 = NodeGetWorldScaling();
- MT_Vector3 scale2 = obj->NodeGetWorldScaling();
- if (fabs(scale2[0]) < (MT_Scalar)FLT_EPSILON ||
- fabs(scale2[1]) < (MT_Scalar)FLT_EPSILON ||
- fabs(scale2[2]) < (MT_Scalar)FLT_EPSILON ||
- fabs(scale1[0]) < (MT_Scalar)FLT_EPSILON ||
- fabs(scale1[1]) < (MT_Scalar)FLT_EPSILON ||
- fabs(scale1[2]) < (MT_Scalar)FLT_EPSILON) { return; }
-
- // Remove us from our old parent and set our new parent
- RemoveParent(scene);
- obj->GetSGNode()->AddChild(GetSGNode());
-
- if (m_pPhysicsController)
- {
- m_pPhysicsController->SuspendDynamics(ghost);
- }
- // Set us to our new scale, position, and orientation
- scale2[0] = 1.0f/scale2[0];
- scale2[1] = 1.0f/scale2[1];
- scale2[2] = 1.0f/scale2[2];
- scale1 = scale1 * scale2;
- MT_Matrix3x3 invori = obj->NodeGetWorldOrientation().inverse();
- MT_Vector3 newpos = invori*(NodeGetWorldPosition()-obj->NodeGetWorldPosition())*scale2;
-
- NodeSetLocalScale(scale1);
- NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2]));
- NodeSetLocalOrientation(invori*NodeGetWorldOrientation());
- NodeUpdateGS(0.f);
- // object will now be a child, it must be removed from the parent list
- CListValue* rootlist = scene->GetRootParentList();
- if (rootlist->RemoveValue(this))
- // the object was in parent list, decrement ref count as it's now removed
- 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_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_pPhysicsController != NULL &&
- rootobj->m_pPhysicsController->IsCompound())
- {
- rootobj->m_pPhysicsController->AddCompoundChild(m_pPhysicsController);
- }
- }
- // graphically, the object hasn't change place, no need to update m_pGraphicController
- }
-}
-
-void KX_GameObject::RemoveParent(KX_Scene *scene)
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (GetSGNode() && GetSGNode()->GetSGParent())
- {
- // get the root object to remove us from compound object if needed
- KX_GameObject* rootobj = (KX_GameObject*)GetSGNode()->GetRootSGParent()->GetSGClientObject();
- // Set us to the right spot
- GetSGNode()->SetLocalScale(GetSGNode()->GetWorldScaling());
- GetSGNode()->SetLocalOrientation(GetSGNode()->GetWorldOrientation());
- GetSGNode()->SetLocalPosition(GetSGNode()->GetWorldPosition());
-
- // Remove us from our parent
- GetSGNode()->DisconnectFromParent();
- NodeUpdateGS(0.f);
- // the object is now a root object, add it to the parentlist
- CListValue* rootlist = scene->GetRootParentList();
- if (!rootlist->SearchValue(this))
- // object was not in root list, add it now and increment ref count
- rootlist->Add(AddRef());
- if (m_pPhysicsController)
- {
- // in case this controller was added as a child shape to the parent
- if (rootobj != NULL &&
- rootobj->m_pPhysicsController != NULL &&
- rootobj->m_pPhysicsController->IsCompound())
- {
- rootobj->m_pPhysicsController->RemoveCompoundChild(m_pPhysicsController);
- }
- 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_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
- }
-}
-
-BL_ActionManager* KX_GameObject::GetActionManager()
-{
- // We only want to create an action manager if we need it
- if (!m_actionManager)
- {
- GetScene()->AddAnimatedObject(this);
- m_actionManager = new BL_ActionManager(this);
- }
- return m_actionManager;
-}
-
-bool KX_GameObject::PlayAction(const char* name,
- float start,
- float end,
- short layer,
- short priority,
- float blendin,
- short play_mode,
- float layer_weight,
- short ipo_flags,
- float playback_speed,
- short blend_mode)
-{
- return GetActionManager()->PlayAction(name, start, end, layer, priority, blendin, play_mode, layer_weight, ipo_flags, playback_speed, blend_mode);
-}
-
-void KX_GameObject::StopAction(short layer)
-{
- GetActionManager()->StopAction(layer);
-}
-
-void KX_GameObject::RemoveTaggedActions()
-{
- GetActionManager()->RemoveTaggedActions();
-}
-
-bool KX_GameObject::IsActionDone(short layer)
-{
- return GetActionManager()->IsActionDone(layer);
-}
-
-void KX_GameObject::UpdateActionManager(float curtime)
-{
- GetActionManager()->Update(curtime);
-}
-
-float KX_GameObject::GetActionFrame(short layer)
-{
- return GetActionManager()->GetActionFrame(layer);
-}
-
-const char *KX_GameObject::GetActionName(short layer)
-{
- return GetActionManager()->GetActionName(layer);
-}
-
-void KX_GameObject::SetActionFrame(short layer, float frame)
-{
- GetActionManager()->SetActionFrame(layer, frame);
-}
-
-bAction *KX_GameObject::GetCurrentAction(short layer)
-{
- return GetActionManager()->GetCurrentAction(layer);
-}
-
-void KX_GameObject::SetPlayMode(short layer, short mode)
-{
- GetActionManager()->SetPlayMode(layer, mode);
-}
-
-void KX_GameObject::SetTimes(short layer, float start, float end)
-{
- GetActionManager()->SetTimes(layer, start, end);
-}
-
-void KX_GameObject::ProcessReplica()
-{
- SCA_IObject::ProcessReplica();
-
- m_pGraphicController = NULL;
- m_pPhysicsController = NULL;
- m_pSGNode = NULL;
-
- /* Dupli group and instance list are set later in replication.
- * See KX_Scene::DupliGroupRecurse. */
- m_pDupliGroupObject = NULL;
- m_pInstanceObjects = NULL;
- m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info);
- m_pClient_info->m_gameobject = this;
- m_actionManager = NULL;
- m_state = 0;
-
- KX_Scene* scene = KX_GetActiveScene();
- KX_ObstacleSimulation* obssimulation = scene->GetObstacleSimulation();
- struct Object* blenderobject = GetBlenderObject();
- if (obssimulation && (blenderobject->gameflag & OB_HASOBSTACLE))
- {
- obssimulation->AddObstacleForObj(this);
- }
-
-#ifdef WITH_PYTHON
- if (m_attr_dict)
- m_attr_dict= PyDict_Copy(m_attr_dict);
-#endif
-
-}
-
-static void setGraphicController_recursive(SG_Node* node)
-{
- NodeList& children = node->GetSGChildren();
-
- for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
- {
- SG_Node* childnode = (*childit);
- KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj != NULL) // This is a GameObject
- clientgameobj->ActivateGraphicController(false);
-
- // if the childobj is NULL then this may be an inverse parent link
- // so a non recursive search should still look down this node.
- setGraphicController_recursive(childnode);
- }
-}
-
-
-void KX_GameObject::ActivateGraphicController(bool recurse)
-{
- if (m_pGraphicController)
- {
- m_pGraphicController->Activate(m_bVisible);
- }
- if (recurse)
- {
- setGraphicController_recursive(GetSGNode());
- }
-}
-
-void KX_GameObject::SetUserCollisionGroup(unsigned short group)
-{
- m_userCollisionGroup = group;
- if (m_pPhysicsController)
- m_pPhysicsController->RefreshCollisions();
-}
-void KX_GameObject::SetUserCollisionMask(unsigned short mask)
-{
- m_userCollisionMask = mask;
- if (m_pPhysicsController)
- m_pPhysicsController->RefreshCollisions();
-}
-
-unsigned short KX_GameObject::GetUserCollisionGroup()
-{
- return m_userCollisionGroup;
-}
-unsigned short KX_GameObject::GetUserCollisionMask()
-{
- return m_userCollisionMask;
-}
-
-bool KX_GameObject::CheckCollision(KX_GameObject* other)
-{
- return this->m_userCollisionGroup & other->m_userCollisionMask;
-}
-
-CValue* KX_GameObject::GetReplica()
-{
- KX_GameObject* replica = new KX_GameObject(*this);
-
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-bool KX_GameObject::IsDynamicsSuspended() const
-{
- if (m_pPhysicsController)
- return m_pPhysicsController->IsSuspended();
- return false;
-}
-
-float KX_GameObject::getLinearDamping() const
-{
- if (m_pPhysicsController)
- return m_pPhysicsController->GetLinearDamping();
- return 0;
-}
-
-float KX_GameObject::getAngularDamping() const
-{
- if (m_pPhysicsController)
- return m_pPhysicsController->GetAngularDamping();
- return 0;
-}
-
-void KX_GameObject::setLinearDamping(float damping)
-{
- if (m_pPhysicsController)
- m_pPhysicsController->SetLinearDamping(damping);
-}
-
-
-void KX_GameObject::setAngularDamping(float damping)
-{
- if (m_pPhysicsController)
- m_pPhysicsController->SetAngularDamping(damping);
-}
-
-
-void KX_GameObject::setDamping(float linear, float angular)
-{
- if (m_pPhysicsController)
- m_pPhysicsController->SetDamping(linear, angular);
-}
-
-
-void KX_GameObject::ApplyForce(const MT_Vector3& force,bool local)
-{
- if (m_pPhysicsController)
- m_pPhysicsController->ApplyForce(force,local);
-}
-
-
-
-void KX_GameObject::ApplyTorque(const MT_Vector3& torque,bool local)
-{
- if (m_pPhysicsController)
- m_pPhysicsController->ApplyTorque(torque,local);
-}
-
-
-
-void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local)
-{
- if (GetSGNode())
- {
- if (m_pPhysicsController) // (IsDynamic())
- {
- m_pPhysicsController->RelativeTranslate(dloc,local);
- }
- GetSGNode()->RelativeTranslate(dloc,GetSGNode()->GetSGParent(),local);
- }
-}
-
-
-
-void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local)
-{
- MT_Matrix3x3 rotmat(drot);
-
- if (GetSGNode()) {
- GetSGNode()->RelativeRotate(rotmat,local);
-
- if (m_pPhysicsController) { // (IsDynamic())
- m_pPhysicsController->RelativeRotate(rotmat,local);
- }
- }
-}
-
-
-
-/**
- * GetOpenGL Matrix, returns an OpenGL 'compatible' matrix
- */
-float *KX_GameObject::GetOpenGLMatrix()
-{
- // todo: optimize and only update if necessary
- float *fl = m_OpenGL_4x4Matrix.getPointer();
- if (GetSGNode()) {
- MT_Transform trans;
-
- trans.setOrigin(GetSGNode()->GetWorldPosition());
- trans.setBasis(GetSGNode()->GetWorldOrientation());
-
- MT_Vector3 scaling = GetSGNode()->GetWorldScaling();
- m_bIsNegativeScaling = ((scaling[0] < 0.0f) ^ (scaling[1] < 0.0f) ^ (scaling[2] < 0.0f)) ? true : false;
- trans.scale(scaling[0], scaling[1], scaling[2]);
- trans.getValue(fl);
- GetSGNode()->ClearDirty();
- }
- return fl;
-}
-
-void KX_GameObject::UpdateBlenderObjectMatrix(Object* blendobj)
-{
- if (!blendobj)
- blendobj = m_pBlenderObject;
- if (blendobj) {
- const MT_Matrix3x3& rot = NodeGetWorldOrientation();
- const MT_Vector3& scale = NodeGetWorldScaling();
- const MT_Vector3& pos = NodeGetWorldPosition();
- rot.getValue(blendobj->obmat[0]);
- pos.getValue(blendobj->obmat[3]);
- mul_v3_fl(blendobj->obmat[0], scale[0]);
- mul_v3_fl(blendobj->obmat[1], scale[1]);
- mul_v3_fl(blendobj->obmat[2], scale[2]);
- }
-}
-
-void KX_GameObject::AddMeshUser()
-{
- for (size_t i=0;i<m_meshes.size();i++)
- {
- m_meshes[i]->AddMeshUser(this, &m_meshSlots, GetDeformer());
- }
- // set the part of the mesh slot that never change
- float *fl = GetOpenGLMatrixPtr()->getPointer();
-
- SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
-// RAS_MeshSlot* ms;
- for (mit.begin(); !mit.end(); ++mit)
- {
- (*mit)->m_OpenGLMatrix = fl;
- }
- UpdateBuckets(false);
-}
-
-static void UpdateBuckets_recursive(SG_Node* node)
-{
- NodeList& children = node->GetSGChildren();
-
- for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
- {
- SG_Node* childnode = (*childit);
- KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj != NULL) // This is a GameObject
- clientgameobj->UpdateBuckets(0);
-
- // if the childobj is NULL then this may be an inverse parent link
- // so a non recursive search should still look down this node.
- UpdateBuckets_recursive(childnode);
- }
-}
-
-void KX_GameObject::UpdateBuckets( bool recursive )
-{
- if (GetSGNode()) {
- RAS_MeshSlot *ms;
-
- if (GetSGNode()->IsDirty())
- GetOpenGLMatrix();
-
- SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
- for (mit.begin(); !mit.end(); ++mit)
- {
- ms = *mit;
- ms->m_bObjectColor = m_bUseObjectColor;
- ms->m_RGBAcolor = m_objectColor;
- ms->m_bVisible = m_bVisible;
- ms->m_bCulled = m_bCulled || !m_bVisible;
- if (!ms->m_bCulled)
- ms->m_bucket->ActivateMesh(ms);
-
- /* split if necessary */
-#ifdef USE_SPLIT
- ms->Split();
-#endif
- }
-
- if (recursive) {
- UpdateBuckets_recursive(GetSGNode());
- }
- }
-}
-
-void KX_GameObject::RemoveMeshes()
-{
- for (size_t i=0;i<m_meshes.size();i++)
- m_meshes[i]->RemoveFromBuckets(this);
-
- //note: meshes can be shared, and are deleted by KX_BlenderSceneConverter
-
- m_meshes.clear();
-}
-
-void KX_GameObject::AddLodMesh(RAS_MeshObject* mesh)
-{
- m_lodmeshes.push_back(mesh);
-}
-
-
-static float calcHysteresis(KX_Scene *kxscene, LodLevel *lod)
-{
- float hystvariance = 0.0f;
-
- if (!kxscene->IsActivedLodHysteresis())
- return hystvariance;
-
- short hysteresis = 0;
- // if exists, LoD level hysteresis will override scene hysteresis
- if (lod->next->flags & OB_LOD_USE_HYST)
- hysteresis = lod->next->obhysteresis;
- else
- hysteresis = kxscene->GetLodHysteresisValue();
-
- return hystvariance = MT_abs(lod->next->distance - lod->distance) * hysteresis / 100;
-}
-
-void KX_GameObject::UpdateLod(MT_Vector3 &cam_pos)
-{
- // Handle dupligroups
- if (m_pInstanceObjects) {
- KX_GameObject *instob;
- int count = m_pInstanceObjects->GetCount();
- for (int i = 0; i < count; i++) {
- instob = (KX_GameObject*)m_pInstanceObjects->GetValue(i);
- instob->UpdateLod(cam_pos);
- }
- }
-
- if (m_lodmeshes.empty())
- return;
-
- MT_Vector3 delta = NodeGetWorldPosition() - cam_pos;
- float distance2 = delta.length2();
-
- int level = 0;
- float hystvariance = 0.0f;
- Object *bob = GetBlenderObject();
- LodLevel *lod = (LodLevel *)bob->lodlevels.first;
- KX_Scene *kxscene = GetScene();
-
- for (; lod; lod = lod->next, level++) {
- if (!lod->source || lod->source->type != OB_MESH)
- level--;
-
- if (!lod->next)
- break;
-
- if (level == m_previousLodLevel || level == (m_previousLodLevel + 1)) {
- hystvariance = calcHysteresis(kxscene, lod);
- float newdistance = lod->next->distance + hystvariance;
- if (newdistance * newdistance > distance2)
- break;
- }
- else if (level == (m_previousLodLevel - 1)) {
- hystvariance = calcHysteresis(kxscene, lod);
- float newdistance = lod->next->distance - hystvariance;
- if (newdistance * newdistance > distance2)
- break;
- }
- }
-
- RAS_MeshObject *mesh = m_lodmeshes[level];
- m_currentLodLevel = level;
- if (mesh != m_meshes[0]) {
- m_previousLodLevel = level;
- GetScene()->ReplaceMesh(this, mesh, true, false);
- }
-}
-
-void KX_GameObject::UpdateTransform()
-{
- // HACK: saves function call for dynamic object, they are handled differently
- if (m_pPhysicsController && !m_pPhysicsController->IsDynamic())
- m_pPhysicsController->SetTransform();
- if (m_pGraphicController)
- // update the culling tree
- m_pGraphicController->SetGraphicTransform();
-
-}
-
-void KX_GameObject::UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene)
-{
- ((KX_GameObject*)gameobj)->UpdateTransform();
-}
-
-void KX_GameObject::SynchronizeTransform()
-{
- // only used for sensor object, do full synchronization as bullet doesn't do it
- if (m_pPhysicsController)
- m_pPhysicsController->SetTransform();
- if (m_pGraphicController)
- m_pGraphicController->SetGraphicTransform();
-}
-
-void KX_GameObject::SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene)
-{
- ((KX_GameObject*)gameobj)->SynchronizeTransform();
-}
-
-
-void KX_GameObject::SetDebugColor(unsigned int bgra)
-{
- for (size_t i=0;i<m_meshes.size();i++)
- m_meshes[i]->DebugColor(bgra);
-}
-
-
-
-void KX_GameObject::ResetDebugColor()
-{
- SetDebugColor(0xff000000);
-}
-
-void KX_GameObject::InitIPO(bool ipo_as_force,
- bool ipo_add,
- bool ipo_local)
-{
- SGControllerList::iterator it = GetSGNode()->GetSGControllerList().begin();
-
- while (it != GetSGNode()->GetSGControllerList().end()) {
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true);
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, ipo_as_force);
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, ipo_add);
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, ipo_local);
- it++;
- }
-}
-
-void KX_GameObject::UpdateIPO(float curframetime,
- bool recurse)
-{
- /* This function shouldn't call BL_Action::Update, not even indirectly,
- * as it will cause deadlock due to the lock in BL_Action::Update. */
-
- // just the 'normal' update procedure.
- GetSGNode()->SetSimulatedTime(curframetime,recurse);
- GetSGNode()->UpdateWorldData(curframetime);
- UpdateTransform();
-}
-
-// IPO update
-void
-KX_GameObject::UpdateMaterialData(
- dword matname_hash,
- MT_Vector4 rgba,
- MT_Vector3 specrgb,
- MT_Scalar hard,
- MT_Scalar spec,
- MT_Scalar ref,
- MT_Scalar emit,
- MT_Scalar alpha
-
- )
-{
- int mesh = 0;
- if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0) {
- list<RAS_MeshMaterial>::iterator mit = m_meshes[mesh]->GetFirstMaterial();
-
- for (; mit != m_meshes[mesh]->GetLastMaterial(); ++mit)
- {
- RAS_IPolyMaterial* poly = mit->m_bucket->GetPolyMaterial();
-
- if (poly->GetFlag() & RAS_BLENDERMAT )
- {
- KX_BlenderMaterial *m = static_cast<KX_BlenderMaterial*>(poly);
-
- if (matname_hash == 0)
- {
- m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha);
- // if mesh has only one material attached to it then use original hack with no need to edit vertices (better performance)
- SetObjectColor(rgba);
- }
- else
- {
- if (matname_hash == poly->GetMaterialNameHash())
- {
- m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha);
- m_meshes[mesh]->SetVertexColor(poly,rgba);
-
- // no break here, because one blender material can be split into several game engine materials
- // (e.g. one uvsphere material is split into one material at poles with ras_mode TRIANGLE and one material for the body
- // if here was a break then would miss some vertices if material was split
- }
- }
- }
- }
- }
-}
-bool
-KX_GameObject::GetVisible(
- void
- )
-{
- return m_bVisible;
-}
-
-static void setVisible_recursive(SG_Node* node, bool v)
-{
- NodeList& children = node->GetSGChildren();
-
- for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
- {
- SG_Node* childnode = (*childit);
- KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj != NULL) // This is a GameObject
- clientgameobj->SetVisible(v, 0);
-
- // if the childobj is NULL then this may be an inverse parent link
- // so a non recursive search should still look down this node.
- setVisible_recursive(childnode, v);
- }
-}
-
-
-void
-KX_GameObject::SetVisible(
- bool v,
- bool recursive
- )
-{
- if (GetSGNode()) {
- m_bVisible = v;
- if (m_pGraphicController)
- m_pGraphicController->Activate(m_bVisible);
- if (recursive)
- setVisible_recursive(GetSGNode(), v);
- }
-}
-
-static void setOccluder_recursive(SG_Node* node, bool v)
-{
- NodeList& children = node->GetSGChildren();
-
- for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
- {
- SG_Node* childnode = (*childit);
- KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj != NULL) // This is a GameObject
- clientgameobj->SetOccluder(v, false);
-
- // if the childobj is NULL then this may be an inverse parent link
- // so a non recursive search should still look down this node.
- setOccluder_recursive(childnode, v);
- }
-}
-
-void
-KX_GameObject::SetOccluder(
- bool v,
- bool recursive
- )
-{
- if (GetSGNode()) {
- m_bOccluder = v;
- if (recursive)
- setOccluder_recursive(GetSGNode(), v);
- }
-}
-
-static void setDebug_recursive(SG_Node *node, bool debug)
-{
- NodeList& children = node->GetSGChildren();
- KX_Scene *scene = KX_GetActiveScene();
-
- for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit) {
- SG_Node *childnode = (*childit);
- KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj != NULL) {
- if (debug) {
- if (!scene->ObjectInDebugList(clientgameobj))
- scene->AddObjectDebugProperties(clientgameobj);
- }
- else
- scene->RemoveObjectDebugProperties(clientgameobj);
- }
-
- /* if the childobj is NULL then this may be an inverse parent link
- * so a non recursive search should still look down this node. */
- setDebug_recursive(childnode, debug);
- }
-}
-
-void KX_GameObject::SetUseDebugProperties( bool debug, bool recursive )
-{
- KX_Scene *scene = KX_GetActiveScene();
-
- if (debug) {
- if (!scene->ObjectInDebugList(this))
- scene->AddObjectDebugProperties(this);
- }
- else
- scene->RemoveObjectDebugProperties(this);
-
- if (recursive)
- setDebug_recursive(GetSGNode(), debug);
-}
-
-void
-KX_GameObject::SetLayer(
- int l
- )
-{
- m_layer = l;
-}
-
-int
-KX_GameObject::GetLayer(
- void
- )
-{
- return m_layer;
-}
-
-void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local)
-{
- if (m_pPhysicsController)
- {
- MT_Vector3 lv = local ? NodeGetWorldOrientation() * lin_vel : lin_vel;
- m_pPhysicsController->SetLinearVelocity(lv + m_pPhysicsController->GetLinearVelocity(), 0);
- }
-}
-
-
-
-void KX_GameObject::setLinearVelocity(const MT_Vector3& lin_vel,bool local)
-{
- if (m_pPhysicsController)
- m_pPhysicsController->SetLinearVelocity(lin_vel,local);
-}
-
-
-
-void KX_GameObject::setAngularVelocity(const MT_Vector3& ang_vel,bool local)
-{
- if (m_pPhysicsController)
- m_pPhysicsController->SetAngularVelocity(ang_vel,local);
-}
-
-
-void KX_GameObject::ResolveCombinedVelocities(
- const MT_Vector3 & lin_vel,
- const MT_Vector3 & ang_vel,
- bool lin_vel_local,
- bool ang_vel_local
-) {
- 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_pPhysicsController->ResolveCombinedVelocities(
- lv.x(),lv.y(),lv.z(),av.x(),av.y(),av.z());
- }
-}
-
-
-void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec)
-{
- m_bUseObjectColor = true;
- m_objectColor = rgbavec;
-}
-
-const MT_Vector4& KX_GameObject::GetObjectColor()
-{
- return m_objectColor;
-}
-
-void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
-{
- const MT_Scalar eps = 3.0f * MT_EPSILON;
- MT_Matrix3x3 orimat;
- MT_Vector3 vect,ori,z,x,y;
- MT_Scalar len;
-
- // check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return;
-
- vect = dir;
- len = vect.length();
- if (MT_fuzzyZero(len))
- {
- cout << "alignAxisToVect() Error: Null vector!\n";
- return;
- }
-
- if (fac <= 0.0f) {
- return;
- }
-
- // normalize
- vect /= len;
- orimat = GetSGNode()->GetWorldOrientation();
- switch (axis)
- {
- case 0: // align x axis of new coord system to vect
- ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); // pivot axis
- if (1.0f - MT_abs(vect.dot(ori)) < eps) { // vect parallel to pivot?
- ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); // change the pivot!
- }
-
- if (fac == 1.0f) {
- x = vect;
- } else {
- x = (vect * fac) + ((orimat * MT_Vector3(1.0f, 0.0f, 0.0f)) * (1.0f - fac));
- len = x.length();
- if (MT_fuzzyZero(len)) x = vect;
- else x /= len;
- }
- y = ori.cross(x);
- z = x.cross(y);
- break;
- case 1: // y axis
- ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]);
- if (1.0f - MT_abs(vect.dot(ori)) < eps) {
- ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]);
- }
-
- if (fac == 1.0f) {
- y = vect;
- } else {
- y = (vect * fac) + ((orimat * MT_Vector3(0.0f, 1.0f, 0.0f)) * (1.0f - fac));
- len = y.length();
- if (MT_fuzzyZero(len)) y = vect;
- else y /= len;
- }
- z = ori.cross(y);
- x = y.cross(z);
- break;
- case 2: // z axis
- ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]);
- if (1.0f - MT_abs(vect.dot(ori)) < eps) {
- ori.setValue(orimat[0][0], orimat[1][0], orimat[2][0]);
- }
-
- if (fac == 1.0f) {
- z = vect;
- } else {
- z = (vect * fac) + ((orimat * MT_Vector3(0.0f, 0.0f, 1.0f)) * (1.0f - fac));
- len = z.length();
- if (MT_fuzzyZero(len)) z = vect;
- else z /= len;
- }
- x = ori.cross(z);
- y = z.cross(x);
- break;
- default: // invalid axis specified
- cout << "alignAxisToVect(): Invalid axis '" << axis <<"'\n";
- return;
- }
- x.normalize(); // normalize the new base vectors
- y.normalize();
- z.normalize();
- orimat.setValue(x[0], y[0], z[0],
- x[1], y[1], z[1],
- x[2], y[2], z[2]);
-
- if (GetSGNode()->GetSGParent() != NULL)
- {
- // the object is a child, adapt its local orientation so that
- // the global orientation is aligned as we want (cancelling out the parent orientation)
- MT_Matrix3x3 invori = GetSGNode()->GetSGParent()->GetWorldOrientation().inverse();
- NodeSetLocalOrientation(invori*orimat);
- }
- else {
- NodeSetLocalOrientation(orimat);
- }
-}
-
-MT_Scalar KX_GameObject::GetMass()
-{
- if (m_pPhysicsController)
- {
- return m_pPhysicsController->GetMass();
- }
- return 0.0f;
-}
-
-MT_Vector3 KX_GameObject::GetLocalInertia()
-{
- MT_Vector3 local_inertia(0.0f,0.0f,0.0f);
- if (m_pPhysicsController)
- {
- local_inertia = m_pPhysicsController->GetLocalInertia();
- }
- return local_inertia;
-}
-
-MT_Vector3 KX_GameObject::GetLinearVelocity(bool local)
-{
- MT_Vector3 velocity(0.0f,0.0f,0.0f), locvel;
- MT_Matrix3x3 ori;
- if (m_pPhysicsController)
- {
- velocity = m_pPhysicsController->GetLinearVelocity();
-
- if (local)
- {
- ori = GetSGNode()->GetWorldOrientation();
-
- locvel = velocity * ori;
- return locvel;
- }
- }
- return velocity;
-}
-
-MT_Vector3 KX_GameObject::GetAngularVelocity(bool local)
-{
- MT_Vector3 velocity(0.0f,0.0f,0.0f), locvel;
- MT_Matrix3x3 ori;
- if (m_pPhysicsController)
- {
- velocity = m_pPhysicsController->GetAngularVelocity();
-
- if (local)
- {
- ori = GetSGNode()->GetWorldOrientation();
-
- locvel = velocity * ori;
- return locvel;
- }
- }
- return velocity;
-}
-
-MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point)
-{
- if (m_pPhysicsController)
- {
- return m_pPhysicsController->GetVelocity(point);
- }
- return MT_Vector3(0.0f,0.0f,0.0f);
-}
-
-// scenegraph node stuff
-
-void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans)
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return;
-
- 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_pPhysicsController->SetPosition(trans);
- }
-
- GetSGNode()->SetLocalPosition(trans);
-
-}
-
-
-
-void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot)
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return;
-
- if (m_pPhysicsController && !GetSGNode()->GetSGParent())
- {
- // see note above
- m_pPhysicsController->SetOrientation(rot);
- }
- GetSGNode()->SetLocalOrientation(rot);
-}
-
-void KX_GameObject::NodeSetGlobalOrientation(const MT_Matrix3x3& rot)
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return;
-
- if (GetSGNode()->GetSGParent())
- GetSGNode()->SetLocalOrientation(GetSGNode()->GetSGParent()->GetWorldOrientation().inverse()*rot);
- else
- NodeSetLocalOrientation(rot);
-}
-
-void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale)
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return;
-
- if (m_pPhysicsController && !GetSGNode()->GetSGParent())
- {
- // see note above
- m_pPhysicsController->SetScaling(scale);
- }
- GetSGNode()->SetLocalScale(scale);
-}
-
-
-
-void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale)
-{
- if (GetSGNode())
- {
- GetSGNode()->RelativeScale(scale);
- 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_pPhysicsController->SetScaling(newscale);
- }
- }
-}
-
-void KX_GameObject::NodeSetWorldScale(const MT_Vector3& scale)
-{
- if (!GetSGNode())
- return;
- SG_Node* parent = GetSGNode()->GetSGParent();
- if (parent != NULL)
- {
- // Make sure the objects have some scale
- MT_Vector3 p_scale = parent->GetWorldScaling();
- if (fabs(p_scale[0]) < (MT_Scalar)FLT_EPSILON ||
- fabs(p_scale[1]) < (MT_Scalar)FLT_EPSILON ||
- fabs(p_scale[2]) < (MT_Scalar)FLT_EPSILON)
- {
- return;
- }
-
- p_scale[0] = 1/p_scale[0];
- p_scale[1] = 1/p_scale[1];
- p_scale[2] = 1/p_scale[2];
-
- NodeSetLocalScale(scale * p_scale);
- }
- else
- {
- NodeSetLocalScale(scale);
- }
-}
-
-void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans)
-{
- if (!GetSGNode())
- return;
- SG_Node* parent = GetSGNode()->GetSGParent();
- if (parent != NULL)
- {
- // Make sure the objects have some scale
- MT_Vector3 scale = parent->GetWorldScaling();
- if (fabs(scale[0]) < (MT_Scalar)FLT_EPSILON ||
- fabs(scale[1]) < (MT_Scalar)FLT_EPSILON ||
- fabs(scale[2]) < (MT_Scalar)FLT_EPSILON)
- {
- return;
- }
- scale[0] = 1.0f/scale[0];
- scale[1] = 1.0f/scale[1];
- scale[2] = 1.0f/scale[2];
- MT_Matrix3x3 invori = parent->GetWorldOrientation().inverse();
- MT_Vector3 newpos = invori*(trans-parent->GetWorldPosition())*scale;
- NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2]));
- }
- else
- {
- NodeSetLocalPosition(trans);
- }
-}
-
-
-void KX_GameObject::NodeUpdateGS(double time)
-{
- if (GetSGNode())
- GetSGNode()->UpdateWorldData(time);
-}
-
-
-
-const MT_Matrix3x3& KX_GameObject::NodeGetWorldOrientation() const
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return dummy_orientation;
- return GetSGNode()->GetWorldOrientation();
-}
-
-const MT_Matrix3x3& KX_GameObject::NodeGetLocalOrientation() const
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return dummy_orientation;
- return GetSGNode()->GetLocalOrientation();
-}
-
-const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return dummy_scaling;
-
- return GetSGNode()->GetWorldScaling();
-}
-
-const MT_Vector3& KX_GameObject::NodeGetLocalScaling() const
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (!GetSGNode())
- return dummy_scaling;
-
- return GetSGNode()->GetLocalScale();
-}
-
-const MT_Point3& KX_GameObject::NodeGetWorldPosition() const
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (GetSGNode())
- return GetSGNode()->GetWorldPosition();
- else
- return dummy_point;
-}
-
-const MT_Point3& KX_GameObject::NodeGetLocalPosition() const
-{
- // check on valid node in case a python controller holds a reference to a deleted object
- if (GetSGNode())
- return GetSGNode()->GetLocalPosition();
- else
- return dummy_point;
-}
-
-
-void KX_GameObject::UnregisterCollisionCallbacks()
-{
- if (!GetPhysicsController()) {
- printf("Warning, trying to unregister collision callbacks for object without collisions: %s!\n", GetName().ReadPtr());
- return;
- }
-
- // Unregister from callbacks
- KX_Scene* scene = GetScene();
- PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment();
- PHY_IPhysicsController* spc = GetPhysicsController();
- // If we are the last to unregister on this physics controller
- if (pe->RemoveCollisionCallback(spc)) {
- // If we are a sensor object
- if (m_pClient_info->isSensor())
- // Remove sensor body from physics world
- pe->RemoveSensor(spc);
- }
-}
-
-void KX_GameObject::RegisterCollisionCallbacks()
-{
- if (!GetPhysicsController()) {
- printf("Warning, trying to register collision callbacks for object without collisions: %s!\n", GetName().ReadPtr());
- return;
- }
-
- // Register from callbacks
- KX_Scene* scene = GetScene();
- PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment();
- PHY_IPhysicsController* spc = GetPhysicsController();
- // If we are the first to register on this physics controller
- if (pe->RequestCollisionCallback(spc)) {
- // If we are a sensor object
- if (m_pClient_info->isSensor())
- // Add sensor body to physics world
- pe->AddSensor(spc);
- }
-}
-void KX_GameObject::RunCollisionCallbacks(KX_GameObject *collider, const MT_Vector3 &point, const MT_Vector3 &normal)
-{
-#ifdef WITH_PYTHON
- if (!m_collisionCallbacks || PyList_GET_SIZE(m_collisionCallbacks) == 0)
- return;
-
- PyObject *args[] = {collider->GetProxy(), PyObjectFrom(point), PyObjectFrom(normal)};
- RunPythonCallBackList(m_collisionCallbacks, args, 1, ARRAY_SIZE(args));
-
- for (unsigned int i = 0; i < ARRAY_SIZE(args); ++i) {
- Py_DECREF(args[i]);
- }
-#endif
-}
-
-/* Suspend/ resume: for the dynamic behavior, there is a simple
- * method. For the residual motion, there is not. I wonder what the
- * correct solution is for Sumo. Remove from the motion-update tree?
- *
- * So far, only switch the physics and logic.
- * */
-
-void KX_GameObject::Resume(void)
-{
- if (m_suspended) {
- SCA_IObject::Resume();
- // Child objects must be static, so we block changing to dynamic
- if (GetPhysicsController() && !GetParent())
- GetPhysicsController()->RestoreDynamics();
-
- m_suspended = false;
- }
-}
-
-void KX_GameObject::Suspend()
-{
- if ((!m_ignore_activity_culling) && (!m_suspended)) {
- SCA_IObject::Suspend();
- if (GetPhysicsController())
- GetPhysicsController()->SuspendDynamics();
- m_suspended = true;
- }
-}
-
-static void walk_children(SG_Node* node, CListValue* list, bool recursive)
-{
- if (!node)
- return;
- NodeList& children = node->GetSGChildren();
-
- for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
- {
- SG_Node* childnode = (*childit);
- CValue* childobj = (CValue*)childnode->GetSGClientObject();
- if (childobj != NULL) // This is a GameObject
- {
- // add to the list
- list->Add(childobj->AddRef());
- }
-
- // if the childobj is NULL then this may be an inverse parent link
- // so a non recursive search should still look down this node.
- if (recursive || childobj==NULL) {
- walk_children(childnode, list, recursive);
- }
- }
-}
-
-CListValue* KX_GameObject::GetChildren()
-{
- CListValue* list = new CListValue();
- walk_children(GetSGNode(), list, 0); /* GetSGNode() is always valid or it would have raised an exception before this */
- return list;
-}
-
-CListValue* KX_GameObject::GetChildrenRecursive()
-{
- CListValue* list = new CListValue();
- walk_children(GetSGNode(), list, 1);
- return list;
-}
-
-KX_Scene* KX_GameObject::GetScene()
-{
- SG_Node* node = this->GetSGNode();
- if (node == NULL) {
- // this happens for object in non active layers, rely on static scene then
- return KX_GetActiveScene();
- }
- return static_cast<KX_Scene*>(node->GetSGClientInfo());
-}
-
-/* ---------------------------------------------------------------------
- * Some stuff taken from the header
- * --------------------------------------------------------------------- */
-void KX_GameObject::Relink(CTR_Map<CTR_HashedPtr, void*> *map_parameter)
-{
- // we will relink the sensors and actuators that use object references
- // if the object is part of the replicated hierarchy, use the new
- // object reference instead
- SCA_SensorList& sensorlist = GetSensors();
- SCA_SensorList::iterator sit;
- for (sit=sensorlist.begin(); sit != sensorlist.end(); sit++)
- {
- (*sit)->Relink(map_parameter);
- }
- SCA_ActuatorList& actuatorlist = GetActuators();
- SCA_ActuatorList::iterator ait;
- for (ait=actuatorlist.begin(); ait != actuatorlist.end(); ait++)
- {
- (*ait)->Relink(map_parameter);
- }
-}
-
-#ifdef USE_MATHUTILS
-
-/* These require an SGNode */
-#define MATHUTILS_VEC_CB_POS_LOCAL 1
-#define MATHUTILS_VEC_CB_POS_GLOBAL 2
-#define MATHUTILS_VEC_CB_SCALE_LOCAL 3
-#define MATHUTILS_VEC_CB_SCALE_GLOBAL 4
-#define MATHUTILS_VEC_CB_INERTIA_LOCAL 5
-#define MATHUTILS_VEC_CB_OBJECT_COLOR 6
-#define MATHUTILS_VEC_CB_LINVEL_LOCAL 7
-#define MATHUTILS_VEC_CB_LINVEL_GLOBAL 8
-#define MATHUTILS_VEC_CB_ANGVEL_LOCAL 9
-#define MATHUTILS_VEC_CB_ANGVEL_GLOBAL 10
-
-static unsigned char mathutils_kxgameob_vector_cb_index= -1; /* index for our callbacks */
-
-static int mathutils_kxgameob_generic_check(BaseMathObject *bmo)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
- return 0;
-}
-
-static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
-#define PHYS_ERR(attr) PyErr_SetString(PyExc_AttributeError, "KX_GameObject." attr ", is missing a physics controller")
-
- switch (subtype) {
- case MATHUTILS_VEC_CB_POS_LOCAL:
- self->NodeGetLocalPosition().getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_POS_GLOBAL:
- self->NodeGetWorldPosition().getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_SCALE_LOCAL:
- self->NodeGetLocalScaling().getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_SCALE_GLOBAL:
- self->NodeGetWorldScaling().getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_INERTIA_LOCAL:
- if (!self->GetPhysicsController()) return PHYS_ERR("localInertia"), -1;
- self->GetPhysicsController()->GetLocalInertia().getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_OBJECT_COLOR:
- self->GetObjectColor().getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_LINVEL_LOCAL:
- if (!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), -1;
- self->GetLinearVelocity(true).getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_LINVEL_GLOBAL:
- if (!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), -1;
- self->GetLinearVelocity(false).getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_ANGVEL_LOCAL:
- if (!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), -1;
- self->GetAngularVelocity(true).getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_ANGVEL_GLOBAL:
- if (!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), -1;
- self->GetAngularVelocity(false).getValue(bmo->data);
- break;
-
- }
-
-#undef PHYS_ERR
-
- return 0;
-}
-
-static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
- switch (subtype) {
- case MATHUTILS_VEC_CB_POS_LOCAL:
- self->NodeSetLocalPosition(MT_Point3(bmo->data));
- self->NodeUpdateGS(0.f);
- break;
- case MATHUTILS_VEC_CB_POS_GLOBAL:
- self->NodeSetWorldPosition(MT_Point3(bmo->data));
- self->NodeUpdateGS(0.f);
- break;
- case MATHUTILS_VEC_CB_SCALE_LOCAL:
- self->NodeSetLocalScale(MT_Point3(bmo->data));
- self->NodeUpdateGS(0.f);
- break;
- case MATHUTILS_VEC_CB_SCALE_GLOBAL:
- PyErr_SetString(PyExc_AttributeError, "KX_GameObject.worldScale is read-only");
- return -1;
- case MATHUTILS_VEC_CB_INERTIA_LOCAL:
- /* read only */
- break;
- case MATHUTILS_VEC_CB_OBJECT_COLOR:
- self->SetObjectColor(MT_Vector4(bmo->data));
- break;
- case MATHUTILS_VEC_CB_LINVEL_LOCAL:
- self->setLinearVelocity(MT_Point3(bmo->data),true);
- break;
- case MATHUTILS_VEC_CB_LINVEL_GLOBAL:
- self->setLinearVelocity(MT_Point3(bmo->data),false);
- break;
- case MATHUTILS_VEC_CB_ANGVEL_LOCAL:
- self->setAngularVelocity(MT_Point3(bmo->data),true);
- break;
- case MATHUTILS_VEC_CB_ANGVEL_GLOBAL:
- self->setAngularVelocity(MT_Point3(bmo->data),false);
- break;
- }
-
- return 0;
-}
-
-static int mathutils_kxgameob_vector_get_index(BaseMathObject *bmo, int subtype, int index)
-{
- /* lazy, avoid repeteing the case statement */
- if (mathutils_kxgameob_vector_get(bmo, subtype) == -1)
- return -1;
- return 0;
-}
-
-static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype, int index)
-{
- float f= bmo->data[index];
-
- /* lazy, avoid repeteing the case statement */
- if (mathutils_kxgameob_vector_get(bmo, subtype) == -1)
- return -1;
-
- bmo->data[index] = f;
- return mathutils_kxgameob_vector_set(bmo, subtype);
-}
-
-static Mathutils_Callback mathutils_kxgameob_vector_cb = {
- mathutils_kxgameob_generic_check,
- mathutils_kxgameob_vector_get,
- mathutils_kxgameob_vector_set,
- mathutils_kxgameob_vector_get_index,
- mathutils_kxgameob_vector_set_index
-};
-
-/* Matrix */
-#define MATHUTILS_MAT_CB_ORI_LOCAL 1
-#define MATHUTILS_MAT_CB_ORI_GLOBAL 2
-
-static unsigned char mathutils_kxgameob_matrix_cb_index= -1; /* index for our callbacks */
-
-static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
- switch (subtype) {
- case MATHUTILS_MAT_CB_ORI_LOCAL:
- self->NodeGetLocalOrientation().getValue3x3(bmo->data);
- break;
- case MATHUTILS_MAT_CB_ORI_GLOBAL:
- self->NodeGetWorldOrientation().getValue3x3(bmo->data);
- break;
- }
-
- return 0;
-}
-
-
-static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
- MT_Matrix3x3 mat3x3;
- switch (subtype) {
- case MATHUTILS_MAT_CB_ORI_LOCAL:
- mat3x3.setValue3x3(bmo->data);
- self->NodeSetLocalOrientation(mat3x3);
- self->NodeUpdateGS(0.f);
- break;
- case MATHUTILS_MAT_CB_ORI_GLOBAL:
- mat3x3.setValue3x3(bmo->data);
- self->NodeSetLocalOrientation(mat3x3);
- self->NodeUpdateGS(0.f);
- break;
- }
-
- return 0;
-}
-
-static Mathutils_Callback mathutils_kxgameob_matrix_cb = {
- mathutils_kxgameob_generic_check,
- mathutils_kxgameob_matrix_get,
- mathutils_kxgameob_matrix_set,
- NULL,
- NULL
-};
-
-
-void KX_GameObject_Mathutils_Callback_Init(void)
-{
- // register mathutils callbacks, ok to run more than once.
- mathutils_kxgameob_vector_cb_index= Mathutils_RegisterCallback(&mathutils_kxgameob_vector_cb);
- mathutils_kxgameob_matrix_cb_index= Mathutils_RegisterCallback(&mathutils_kxgameob_matrix_cb);
-}
-
-#endif // USE_MATHUTILS
-
-#ifdef WITH_PYTHON
-/* ------- python stuff ---------------------------------------------------*/
-PyMethodDef KX_GameObject::Methods[] = {
- {"applyForce", (PyCFunction) KX_GameObject::sPyApplyForce, METH_VARARGS},
- {"applyTorque", (PyCFunction) KX_GameObject::sPyApplyTorque, METH_VARARGS},
- {"applyRotation", (PyCFunction) KX_GameObject::sPyApplyRotation, METH_VARARGS},
- {"applyMovement", (PyCFunction) KX_GameObject::sPyApplyMovement, METH_VARARGS},
- {"getLinearVelocity", (PyCFunction) KX_GameObject::sPyGetLinearVelocity, METH_VARARGS},
- {"setLinearVelocity", (PyCFunction) KX_GameObject::sPySetLinearVelocity, METH_VARARGS},
- {"getAngularVelocity", (PyCFunction) KX_GameObject::sPyGetAngularVelocity, METH_VARARGS},
- {"setAngularVelocity", (PyCFunction) KX_GameObject::sPySetAngularVelocity, METH_VARARGS},
- {"getVelocity", (PyCFunction) KX_GameObject::sPyGetVelocity, METH_VARARGS},
- {"setDamping", (PyCFunction) KX_GameObject::sPySetDamping, METH_VARARGS},
- {"getReactionForce", (PyCFunction) KX_GameObject::sPyGetReactionForce, METH_NOARGS},
- {"alignAxisToVect",(PyCFunction) KX_GameObject::sPyAlignAxisToVect, METH_VARARGS},
- {"getAxisVect",(PyCFunction) KX_GameObject::sPyGetAxisVect, METH_O},
- {"suspendDynamics", (PyCFunction)KX_GameObject::sPySuspendDynamics, METH_VARARGS},
- {"restoreDynamics", (PyCFunction)KX_GameObject::sPyRestoreDynamics,METH_NOARGS},
- {"enableRigidBody", (PyCFunction)KX_GameObject::sPyEnableRigidBody,METH_NOARGS},
- {"disableRigidBody", (PyCFunction)KX_GameObject::sPyDisableRigidBody,METH_NOARGS},
- {"applyImpulse", (PyCFunction) KX_GameObject::sPyApplyImpulse, METH_VARARGS},
- {"setCollisionMargin", (PyCFunction) KX_GameObject::sPySetCollisionMargin, METH_O},
- {"setParent", (PyCFunction)KX_GameObject::sPySetParent,METH_VARARGS},
- {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS},
- {"setOcclusion",(PyCFunction) KX_GameObject::sPySetOcclusion, METH_VARARGS},
- {"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_NOARGS},
-
-
- {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_NOARGS},
- {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS},
- {"replaceMesh",(PyCFunction) KX_GameObject::sPyReplaceMesh, METH_VARARGS},
- {"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_NOARGS},
- {"reinstancePhysicsMesh", (PyCFunction)KX_GameObject::sPyReinstancePhysicsMesh,METH_VARARGS},
-
- KX_PYMETHODTABLE(KX_GameObject, rayCastTo),
- KX_PYMETHODTABLE(KX_GameObject, rayCast),
- KX_PYMETHODTABLE_O(KX_GameObject, getDistanceTo),
- KX_PYMETHODTABLE_O(KX_GameObject, getVectTo),
- KX_PYMETHODTABLE(KX_GameObject, sendMessage),
- KX_PYMETHODTABLE(KX_GameObject, addDebugProperty),
-
- KX_PYMETHODTABLE_KEYWORDS(KX_GameObject, playAction),
- KX_PYMETHODTABLE(KX_GameObject, stopAction),
- KX_PYMETHODTABLE(KX_GameObject, getActionFrame),
- KX_PYMETHODTABLE(KX_GameObject, getActionName),
- KX_PYMETHODTABLE(KX_GameObject, setActionFrame),
- KX_PYMETHODTABLE(KX_GameObject, isPlayingAction),
-
- // dict style access for props
- {"get",(PyCFunction) KX_GameObject::sPyget, METH_VARARGS},
-
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_GameObject::Attributes[] = {
- KX_PYATTRIBUTE_INT_RO("currentLodLevel", KX_GameObject, m_currentLodLevel),
- KX_PYATTRIBUTE_RO_FUNCTION("name", KX_GameObject, pyattr_get_name),
- KX_PYATTRIBUTE_RO_FUNCTION("parent", KX_GameObject, pyattr_get_parent),
- KX_PYATTRIBUTE_RO_FUNCTION("groupMembers", KX_GameObject, pyattr_get_group_members),
- KX_PYATTRIBUTE_RO_FUNCTION("groupObject", KX_GameObject, pyattr_get_group_object),
- KX_PYATTRIBUTE_RO_FUNCTION("scene", KX_GameObject, pyattr_get_scene),
- KX_PYATTRIBUTE_RO_FUNCTION("life", KX_GameObject, pyattr_get_life),
- KX_PYATTRIBUTE_RW_FUNCTION("mass", KX_GameObject, pyattr_get_mass, pyattr_set_mass),
- KX_PYATTRIBUTE_RO_FUNCTION("isSuspendDynamics", KX_GameObject, pyattr_get_is_suspend_dynamics),
- KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMin", KX_GameObject, pyattr_get_lin_vel_min, pyattr_set_lin_vel_min),
- KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMax", KX_GameObject, pyattr_get_lin_vel_max, pyattr_set_lin_vel_max),
- KX_PYATTRIBUTE_RW_FUNCTION("angularVelocityMin", KX_GameObject, pyattr_get_ang_vel_min, pyattr_set_ang_vel_min),
- KX_PYATTRIBUTE_RW_FUNCTION("angularVelocityMax", KX_GameObject, pyattr_get_ang_vel_max, pyattr_set_ang_vel_max),
- KX_PYATTRIBUTE_RW_FUNCTION("visible", KX_GameObject, pyattr_get_visible, pyattr_set_visible),
- KX_PYATTRIBUTE_RW_FUNCTION("record_animation", KX_GameObject, pyattr_get_record_animation, pyattr_set_record_animation),
- KX_PYATTRIBUTE_BOOL_RW ("occlusion", KX_GameObject, m_bOccluder),
- KX_PYATTRIBUTE_RW_FUNCTION("position", KX_GameObject, pyattr_get_worldPosition, pyattr_set_localPosition),
- KX_PYATTRIBUTE_RO_FUNCTION("localInertia", KX_GameObject, pyattr_get_localInertia),
- KX_PYATTRIBUTE_RW_FUNCTION("orientation",KX_GameObject,pyattr_get_worldOrientation,pyattr_set_localOrientation),
- KX_PYATTRIBUTE_RW_FUNCTION("scaling", KX_GameObject, pyattr_get_worldScaling, pyattr_set_localScaling),
- KX_PYATTRIBUTE_RW_FUNCTION("timeOffset",KX_GameObject, pyattr_get_timeOffset,pyattr_set_timeOffset),
- KX_PYATTRIBUTE_RW_FUNCTION("collisionCallbacks", KX_GameObject, pyattr_get_collisionCallbacks, pyattr_set_collisionCallbacks),
- KX_PYATTRIBUTE_RW_FUNCTION("collisionGroup", KX_GameObject, pyattr_get_collisionGroup, pyattr_set_collisionGroup),
- KX_PYATTRIBUTE_RW_FUNCTION("collisionMask", KX_GameObject, pyattr_get_collisionMask, pyattr_set_collisionMask),
- KX_PYATTRIBUTE_RW_FUNCTION("state", KX_GameObject, pyattr_get_state, pyattr_set_state),
- KX_PYATTRIBUTE_RO_FUNCTION("meshes", KX_GameObject, pyattr_get_meshes),
- KX_PYATTRIBUTE_RW_FUNCTION("localOrientation",KX_GameObject,pyattr_get_localOrientation,pyattr_set_localOrientation),
- KX_PYATTRIBUTE_RW_FUNCTION("worldOrientation",KX_GameObject,pyattr_get_worldOrientation,pyattr_set_worldOrientation),
- KX_PYATTRIBUTE_RW_FUNCTION("localPosition", KX_GameObject, pyattr_get_localPosition, pyattr_set_localPosition),
- KX_PYATTRIBUTE_RW_FUNCTION("worldPosition", KX_GameObject, pyattr_get_worldPosition, pyattr_set_worldPosition),
- KX_PYATTRIBUTE_RW_FUNCTION("localScale", KX_GameObject, pyattr_get_localScaling, pyattr_set_localScaling),
- KX_PYATTRIBUTE_RW_FUNCTION("worldScale", KX_GameObject, pyattr_get_worldScaling, pyattr_set_worldScaling),
- KX_PYATTRIBUTE_RW_FUNCTION("localTransform", KX_GameObject, pyattr_get_localTransform, pyattr_set_localTransform),
- KX_PYATTRIBUTE_RW_FUNCTION("worldTransform", KX_GameObject, pyattr_get_worldTransform, pyattr_set_worldTransform),
- KX_PYATTRIBUTE_RW_FUNCTION("linearVelocity", KX_GameObject, pyattr_get_localLinearVelocity, pyattr_set_worldLinearVelocity),
- KX_PYATTRIBUTE_RW_FUNCTION("localLinearVelocity", KX_GameObject, pyattr_get_localLinearVelocity, pyattr_set_localLinearVelocity),
- KX_PYATTRIBUTE_RW_FUNCTION("worldLinearVelocity", KX_GameObject, pyattr_get_worldLinearVelocity, pyattr_set_worldLinearVelocity),
- KX_PYATTRIBUTE_RW_FUNCTION("angularVelocity", KX_GameObject, pyattr_get_localAngularVelocity, pyattr_set_worldAngularVelocity),
- KX_PYATTRIBUTE_RW_FUNCTION("localAngularVelocity", KX_GameObject, pyattr_get_localAngularVelocity, pyattr_set_localAngularVelocity),
- KX_PYATTRIBUTE_RW_FUNCTION("worldAngularVelocity", KX_GameObject, pyattr_get_worldAngularVelocity, pyattr_set_worldAngularVelocity),
- KX_PYATTRIBUTE_RW_FUNCTION("linearDamping", KX_GameObject, pyattr_get_linearDamping, pyattr_set_linearDamping),
- KX_PYATTRIBUTE_RW_FUNCTION("angularDamping", KX_GameObject, pyattr_get_angularDamping, pyattr_set_angularDamping),
- KX_PYATTRIBUTE_RO_FUNCTION("children", KX_GameObject, pyattr_get_children),
- KX_PYATTRIBUTE_RO_FUNCTION("childrenRecursive", KX_GameObject, pyattr_get_children_recursive),
- KX_PYATTRIBUTE_RO_FUNCTION("attrDict", KX_GameObject, pyattr_get_attrDict),
- KX_PYATTRIBUTE_RW_FUNCTION("color", KX_GameObject, pyattr_get_obcolor, pyattr_set_obcolor),
- KX_PYATTRIBUTE_RW_FUNCTION("debug", KX_GameObject, pyattr_get_debug, pyattr_set_debug),
- KX_PYATTRIBUTE_RW_FUNCTION("debugRecursive", KX_GameObject, pyattr_get_debugRecursive, pyattr_set_debugRecursive),
-
- /* experimental, don't rely on these yet */
- KX_PYATTRIBUTE_RO_FUNCTION("sensors", KX_GameObject, pyattr_get_sensors),
- KX_PYATTRIBUTE_RO_FUNCTION("controllers", KX_GameObject, pyattr_get_controllers),
- KX_PYATTRIBUTE_RO_FUNCTION("actuators", KX_GameObject, pyattr_get_actuators),
- {NULL} //Sentinel
-};
-
-PyObject *KX_GameObject::PyReplaceMesh(PyObject *args)
-{
- KX_Scene *scene = KX_GetActiveScene();
- SCA_LogicManager *logicmgr = GetScene()->GetLogicManager();
-
- PyObject *value;
- int use_gfx= 1, use_phys= 0;
- RAS_MeshObject *new_mesh;
-
- if (!PyArg_ParseTuple(args,"O|ii:replaceMesh", &value, &use_gfx, &use_phys))
- return NULL;
-
- if (!ConvertPythonToMesh(logicmgr, value, &new_mesh, false, "gameOb.replaceMesh(value): KX_GameObject"))
- return NULL;
-
- scene->ReplaceMesh(this, new_mesh, (bool)use_gfx, (bool)use_phys);
- Py_RETURN_NONE;
-}
-
-PyObject *KX_GameObject::PyEndObject()
-{
- KX_Scene* scene = GetScene();
-
- scene->DelayedRemoveObject(this);
-
- Py_RETURN_NONE;
-
-}
-
-PyObject *KX_GameObject::PyReinstancePhysicsMesh(PyObject *args)
-{
- KX_GameObject *gameobj= NULL;
- RAS_MeshObject *mesh= NULL;
- SCA_LogicManager *logicmgr = GetScene()->GetLogicManager();
-
- PyObject *gameobj_py= NULL;
- PyObject *mesh_py= NULL;
-
- if ( !PyArg_ParseTuple(args,"|OO:reinstancePhysicsMesh",&gameobj_py, &mesh_py) ||
- (gameobj_py && !ConvertPythonToGameObject(logicmgr, gameobj_py, &gameobj, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject")) ||
- (mesh_py && !ConvertPythonToMesh(logicmgr, mesh_py, &mesh, true, "gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject"))
- ) {
- return NULL;
- }
-
- /* gameobj and mesh can be NULL */
- if (GetPhysicsController() && GetPhysicsController()->ReinstancePhysicsShape(gameobj, mesh))
- Py_RETURN_TRUE;
-
- Py_RETURN_FALSE;
-}
-
-static PyObject *Map_GetItem(PyObject *self_v, PyObject *item)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
- const char *attr_str= _PyUnicode_AsString(item);
- CValue* resultattr;
- PyObject *pyconvert;
-
- if (self == NULL) {
- PyErr_SetString(PyExc_SystemError, "val = gameOb[key]: KX_GameObject, " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- /* first see if the attributes a string and try get the cvalue attribute */
- if (attr_str && (resultattr=self->GetProperty(attr_str))) {
- pyconvert = resultattr->ConvertValueToPython();
- return pyconvert ? pyconvert:resultattr->GetProxy();
- }
- /* no CValue attribute, try get the python only m_attr_dict attribute */
- else if (self->m_attr_dict && (pyconvert=PyDict_GetItem(self->m_attr_dict, item))) {
-
- if (attr_str)
- PyErr_Clear();
- Py_INCREF(pyconvert);
- return pyconvert;
- }
- else {
- if (attr_str) PyErr_Format(PyExc_KeyError, "value = gameOb[key]: KX_GameObject, key \"%s\" does not exist", attr_str);
- else PyErr_SetString(PyExc_KeyError, "value = gameOb[key]: KX_GameObject, key does not exist");
- return NULL;
- }
-
-}
-
-
-static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
- const char *attr_str= _PyUnicode_AsString(key);
- if (attr_str==NULL)
- PyErr_Clear();
-
- if (self == NULL) {
- PyErr_SetString(PyExc_SystemError, "gameOb[key] = value: KX_GameObject, " BGE_PROXY_ERROR_MSG);
- return -1;
- }
-
- if (val==NULL) { /* del ob["key"] */
- int del= 0;
-
- /* try remove both just in case */
- if (attr_str)
- del |= (self->RemoveProperty(attr_str)==true) ? 1:0;
-
- if (self->m_attr_dict)
- del |= (PyDict_DelItem(self->m_attr_dict, key)==0) ? 1:0;
-
- if (del==0) {
- if (attr_str) PyErr_Format(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key \"%s\" could not be set", attr_str);
- else PyErr_SetString(PyExc_KeyError, "del gameOb[key]: KX_GameObject, key could not be deleted");
- return -1;
- }
- else if (self->m_attr_dict) {
- PyErr_Clear(); /* PyDict_DelItem sets an error when it fails */
- }
- }
- else { /* ob["key"] = value */
- bool set = false;
-
- /* as CValue */
- if (attr_str && PyObject_TypeCheck(val, &PyObjectPlus::Type)==0) /* don't allow GameObjects for eg to be assigned to CValue props */
- {
- CValue *vallie = self->ConvertPythonToValue(val, false, "gameOb[key] = value: ");
-
- if (vallie) {
- CValue* oldprop = self->GetProperty(attr_str);
-
- if (oldprop)
- oldprop->SetValue(vallie);
- else
- self->SetProperty(attr_str, vallie);
-
- vallie->Release();
- set = true;
-
- /* try remove dict value to avoid double ups */
- if (self->m_attr_dict) {
- if (PyDict_DelItem(self->m_attr_dict, key) != 0)
- PyErr_Clear();
- }
- }
- else if (PyErr_Occurred()) {
- return -1;
- }
- }
-
- if (set == false) {
- if (self->m_attr_dict==NULL) /* lazy init */
- self->m_attr_dict= PyDict_New();
-
-
- if (PyDict_SetItem(self->m_attr_dict, key, val)==0)
- {
- if (attr_str)
- self->RemoveProperty(attr_str); /* overwrite the CValue if it exists */
- set = true;
- }
- else {
- if (attr_str) PyErr_Format(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key \"%s\" not be added to internal dictionary", attr_str);
- else PyErr_SetString(PyExc_KeyError, "gameOb[key] = value: KX_GameObject, key not be added to internal dictionary");
- }
- }
-
- if (set == false) {
- return -1; /* pythons error value */
- }
-
- }
-
- return 0; /* success */
-}
-
-static int Seq_Contains(PyObject *self_v, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
-
- if (self == NULL) {
- PyErr_SetString(PyExc_SystemError, "val in gameOb: KX_GameObject, " BGE_PROXY_ERROR_MSG);
- return -1;
- }
-
- if (PyUnicode_Check(value) && self->GetProperty(_PyUnicode_AsString(value)))
- return 1;
-
- if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value))
- return 1;
-
- return 0;
-}
-
-
-PyMappingMethods KX_GameObject::Mapping = {
- (lenfunc)NULL , /*inquiry mp_length */
- (binaryfunc)Map_GetItem, /*binaryfunc mp_subscript */
- (objobjargproc)Map_SetItem, /*objobjargproc mp_ass_subscript */
-};
-
-PySequenceMethods KX_GameObject::Sequence = {
- NULL, /* Cant set the len otherwise it can evaluate as false */
- NULL, /* sq_concat */
- NULL, /* sq_repeat */
- NULL, /* sq_item */
- NULL, /* sq_slice */
- NULL, /* sq_ass_item */
- NULL, /* sq_ass_slice */
- (objobjproc)Seq_Contains, /* sq_contains */
- (binaryfunc) NULL, /* sq_inplace_concat */
- (ssizeargfunc) NULL, /* sq_inplace_repeat */
-};
-
-PyTypeObject KX_GameObject::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_GameObject",
- sizeof(PyObjectPlus_Proxy),
- 0,
- py_base_dealloc,
- 0,
- 0,
- 0,
- 0,
- py_base_repr,
- 0,
- &Sequence,
- &Mapping,
- 0,0,0,
- NULL,
- NULL,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- 0,0,0,0,0,0,0,
- Methods,
- 0,
- 0,
- &SCA_IObject::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyObject *KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyUnicode_From_STR_String(self->GetName());
-}
-
-PyObject *KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- KX_GameObject* parent = self->GetParent();
- if (parent) {
- return parent->GetProxy();
- }
- Py_RETURN_NONE;
-}
-
-PyObject *KX_GameObject::pyattr_get_group_members(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- CListValue* instances = self->GetInstanceObjects();
- if (instances) {
- return instances->GetProxy();
- }
- Py_RETURN_NONE;
-}
-
-PyObject* KX_GameObject::pyattr_get_collisionCallbacks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-
- // Only objects with a physics controller should have collision callbacks
- if (!self->GetPhysicsController()) {
- PyErr_SetString(PyExc_AttributeError, "KX_GameObject.collisionCallbacks: attribute only available for objects with collisions enabled");
- return NULL;
- }
-
- // Return the existing callbacks
- if (self->m_collisionCallbacks == NULL)
- {
- self->m_collisionCallbacks = PyList_New(0);
- // Subscribe to collision update from KX_TouchManager
- self->RegisterCollisionCallbacks();
- }
- Py_INCREF(self->m_collisionCallbacks);
- return self->m_collisionCallbacks;
-}
-
-int KX_GameObject::pyattr_set_collisionCallbacks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-
- // Only objects with a physics controller should have collision callbacks
- if (!self->GetPhysicsController()) {
- PyErr_SetString(PyExc_AttributeError, "KX_GameObject.collisionCallbacks: attribute only available for objects with collisions enabled");
- return PY_SET_ATTR_FAIL;
- }
-
- if (!PyList_CheckExact(value))
- {
- PyErr_SetString(PyExc_ValueError, "Expected a list");
- return PY_SET_ATTR_FAIL;
- }
-
- if (self->m_collisionCallbacks == NULL) {
- self->RegisterCollisionCallbacks();
- } else {
- Py_DECREF(self->m_collisionCallbacks);
- }
-
- Py_INCREF(value);
-
-
- self->m_collisionCallbacks = value;
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_collisionGroup(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyLong_FromLong(self->GetUserCollisionGroup());
-}
-
-int KX_GameObject::pyattr_set_collisionGroup(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- int val = PyLong_AsLong(value);
-
- if (val == -1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError, "gameOb.collisionGroup = int: KX_GameObject, expected an int bit field");
- return PY_SET_ATTR_FAIL;
- }
-
- if (val == 0 || val & ~((1 << OB_MAX_COL_MASKS) - 1)) {
- PyErr_Format(PyExc_AttributeError, "gameOb.collisionGroup = int: KX_GameObject, expected a int bit field, 0 < group < %i", (1 << OB_MAX_COL_MASKS));
- return PY_SET_ATTR_FAIL;
- }
-
- self->SetUserCollisionGroup(val);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_collisionMask(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyLong_FromLong(self->GetUserCollisionMask());
-}
-
-int KX_GameObject::pyattr_set_collisionMask(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- int val = PyLong_AsLong(value);
-
- if (val == -1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError, "gameOb.collisionMask = int: KX_GameObject, expected an int bit field");
- return PY_SET_ATTR_FAIL;
- }
-
- if (val == 0 || val & ~((1 << OB_MAX_COL_MASKS) - 1)) {
- PyErr_Format(PyExc_AttributeError, "gameOb.collisionMask = int: KX_GameObject, expected a int bit field, 0 < mask < %i", (1 << OB_MAX_COL_MASKS));
- return PY_SET_ATTR_FAIL;
- }
-
- self->SetUserCollisionMask(val);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject* KX_GameObject::pyattr_get_scene(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
- KX_Scene *scene = self->GetScene();
- if (scene) {
- return scene->GetProxy();
- }
- Py_RETURN_NONE;
-}
-
-PyObject *KX_GameObject::pyattr_get_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- KX_GameObject* pivot = self->GetDupliGroupObject();
- if (pivot) {
- return pivot->GetProxy();
- }
- Py_RETURN_NONE;
-}
-
-PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-
- CValue *life = self->GetProperty("::timebomb");
- if (life)
- // this convert the timebomb seconds to frames, hard coded 50.0f (assuming 50fps)
- // value hardcoded in KX_Scene::AddReplicaObject()
- return PyFloat_FromDouble(life->GetNumber() * 50.0);
- else
- Py_RETURN_NONE;
-}
-
-PyObject *KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- PHY_IPhysicsController *spc = self->GetPhysicsController();
- return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0f);
-}
-
-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);
- PHY_IPhysicsController *spc = self->GetPhysicsController();
- MT_Scalar val = PyFloat_AsDouble(value);
- if (val < 0.0f) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above");
- return PY_SET_ATTR_FAIL;
- }
-
- if (spc)
- spc->SetMass(val);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_is_suspend_dynamics(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-
- // Only objects with a physics controller can be suspended
- if (!self->GetPhysicsController()) {
- PyErr_SetString(PyExc_AttributeError, "This object has not Physics Controller");
- return NULL;
- }
-
- return PyBool_FromLong(self->IsDynamicsSuspended());
-}
-
-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);
- 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);
- PHY_IPhysicsController *spc = self->GetPhysicsController();
- MT_Scalar val = PyFloat_AsDouble(value);
- if (val < 0.0f) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above");
- return PY_SET_ATTR_FAIL;
- }
-
- if (spc)
- spc->SetLinVelocityMin(val);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-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);
- 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);
- PHY_IPhysicsController *spc = self->GetPhysicsController();
- MT_Scalar val = PyFloat_AsDouble(value);
- if (val < 0.0f) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above");
- return PY_SET_ATTR_FAIL;
- }
-
- if (spc)
- spc->SetLinVelocityMax(val);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_ang_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
- PHY_IPhysicsController *spc = self->GetPhysicsController();
- return PyFloat_FromDouble(spc ? spc->GetAngularVelocityMin() : 0.0f);
-}
-
-int KX_GameObject::pyattr_set_ang_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
- PHY_IPhysicsController *spc = self->GetPhysicsController();
- MT_Scalar val = PyFloat_AsDouble(value);
- if (val < 0.0f) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError,
- "gameOb.angularVelocityMin = float: KX_GameObject, expected a nonnegative float");
- return PY_SET_ATTR_FAIL;
- }
-
- if (spc)
- spc->SetAngularVelocityMin(val);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_ang_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
- PHY_IPhysicsController *spc = self->GetPhysicsController();
- return PyFloat_FromDouble(spc ? spc->GetAngularVelocityMax() : 0.0f);
-}
-
-int KX_GameObject::pyattr_set_ang_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
- PHY_IPhysicsController *spc = self->GetPhysicsController();
- MT_Scalar val = PyFloat_AsDouble(value);
- if (val < 0.0f) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError,
- "gameOb.angularVelocityMax = float: KX_GameObject, expected a nonnegative float");
- return PY_SET_ATTR_FAIL;
- }
-
- if (spc)
- spc->SetAngularVelocityMax(val);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-
-PyObject *KX_GameObject::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyBool_FromLong(self->GetVisible());
-}
-
-int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- int param = PyObject_IsTrue( value );
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "gameOb.visible = bool: KX_GameObject, expected True or False");
- return PY_SET_ATTR_FAIL;
- }
-
- self->SetVisible(param, false);
- self->UpdateBuckets(false);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyBool_FromLong(self->IsRecordAnimation());
-}
-
-int KX_GameObject::pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- int param = PyObject_IsTrue(value);
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "gameOb.record_animation = bool: KX_GameObject, expected boolean");
- return PY_SET_ATTR_FAIL;
- }
-
- self->SetRecordAnimation(param);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-
-
-PyObject *KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(self->NodeGetWorldPosition());
-#endif
-}
-
-int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Point3 pos;
- if (!PyVecTo(value, pos))
- return PY_SET_ATTR_FAIL;
-
- self->NodeSetWorldPosition(pos);
- self->NodeUpdateGS(0.f);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(self->NodeGetLocalPosition());
-#endif
-}
-
-int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Point3 pos;
- if (!PyVecTo(value, pos))
- return PY_SET_ATTR_FAIL;
-
- self->NodeSetLocalPosition(pos);
- self->NodeUpdateGS(0.f);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(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->GetPhysicsController1())
- return PyObjectFrom(self->GetPhysicsController1()->GetLocalInertia());
- return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f);
-#endif
-}
-
-PyObject *KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Matrix_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3, 3,
- mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(self->NodeGetWorldOrientation());
-#endif
-}
-
-int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-
- /* if value is not a sequence PyOrientationTo makes an error */
- MT_Matrix3x3 rot;
- if (!PyOrientationTo(value, rot, "gameOb.worldOrientation = sequence: KX_GameObject, "))
- return PY_SET_ATTR_FAIL;
-
- self->NodeSetGlobalOrientation(rot);
-
- self->NodeUpdateGS(0.f);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Matrix_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3, 3,
- mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(self->NodeGetLocalOrientation());
-#endif
-}
-
-int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-
- /* if value is not a sequence PyOrientationTo makes an error */
- MT_Matrix3x3 rot;
- if (!PyOrientationTo(value, rot, "gameOb.localOrientation = sequence: KX_GameObject, "))
- return PY_SET_ATTR_FAIL;
-
- self->NodeSetLocalOrientation(rot);
- self->NodeUpdateGS(0.f);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(self->NodeGetWorldScaling());
-#endif
-}
-
-int KX_GameObject::pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Vector3 scale;
- if (!PyVecTo(value, scale))
- return PY_SET_ATTR_FAIL;
-
- self->NodeSetWorldScale(scale);
- self->NodeUpdateGS(0.f);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(self->NodeGetLocalScaling());
-#endif
-}
-
-int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Vector3 scale;
- if (!PyVecTo(value, scale))
- return PY_SET_ATTR_FAIL;
-
- self->NodeSetLocalScale(scale);
- self->NodeUpdateGS(0.f);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-
- float mat[16];
-
- MT_Transform trans;
-
- trans.setOrigin(self->GetSGNode()->GetLocalPosition());
- trans.setBasis(self->GetSGNode()->GetLocalOrientation());
-
- MT_Vector3 scaling = self->GetSGNode()->GetLocalScale();
- trans.scale(scaling[0], scaling[1], scaling[2]);
-
- trans.getValue(mat);
-
- return PyObjectFrom(MT_Matrix4x4(mat));
-}
-
-int KX_GameObject::pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Matrix4x4 temp;
- if (!PyMatTo(value, temp))
- return PY_SET_ATTR_FAIL;
-
- float transform[4][4];
- float loc[3], size[3];
- float rot[3][3];
- MT_Matrix3x3 orientation;
-
- temp.getValue(*transform);
- mat4_to_loc_rot_size(loc, rot, size, transform);
-
- self->NodeSetLocalPosition(MT_Point3(loc));
-
- //MT_Matrix3x3's constructor expects a 4x4 matrix
- orientation = MT_Matrix3x3();
- orientation.setValue3x3(*rot);
- self->NodeSetLocalOrientation(orientation);
-
- self->NodeSetLocalScale(MT_Vector3(size));
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-
- return PyObjectFrom(MT_Matrix4x4(self->GetOpenGLMatrix()));
-}
-
-int KX_GameObject::pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Matrix4x4 temp;
- if (!PyMatTo(value, temp))
- return PY_SET_ATTR_FAIL;
-
- float transform[4][4];
- float loc[3], size[3];
- float rot[3][3];
- MT_Matrix3x3 orientation;
-
- temp.getValue(*transform);
- mat4_to_loc_rot_size(loc, rot, size, transform);
-
- self->NodeSetWorldPosition(MT_Point3(loc));
-
- //MT_Matrix3x3's constructor expects a 4x4 matrix
- orientation = MT_Matrix3x3();
- orientation.setValue3x3(*rot);
- self->NodeSetGlobalOrientation(orientation);
-
- self->NodeSetWorldScale(MT_Vector3(size));
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_GLOBAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(GetLinearVelocity(false));
-#endif
-}
-
-int KX_GameObject::pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Vector3 velocity;
- if (!PyVecTo(value, velocity))
- return PY_SET_ATTR_FAIL;
-
- self->setLinearVelocity(velocity, false);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_LOCAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(GetLinearVelocity(true));
-#endif
-}
-
-int KX_GameObject::pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Vector3 velocity;
- if (!PyVecTo(value, velocity))
- return PY_SET_ATTR_FAIL;
-
- self->setLinearVelocity(velocity, true);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_GLOBAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(GetAngularVelocity(false));
-#endif
-}
-
-int KX_GameObject::pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Vector3 velocity;
- if (!PyVecTo(value, velocity))
- return PY_SET_ATTR_FAIL;
-
- self->setAngularVelocity(velocity, false);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_LOCAL);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(GetAngularVelocity(true));
-#endif
-}
-
-int KX_GameObject::pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Vector3 velocity;
- if (!PyVecTo(value, velocity))
- return PY_SET_ATTR_FAIL;
-
- self->setAngularVelocity(velocity, true);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyFloat_FromDouble(self->getLinearDamping());
-}
-
-int KX_GameObject::pyattr_set_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- float val = PyFloat_AsDouble(value);
- self->setLinearDamping(val);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyFloat_FromDouble(self->getAngularDamping());
-}
-
-int KX_GameObject::pyattr_set_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- float val = PyFloat_AsDouble(value);
- self->setAngularDamping(val);
- return PY_SET_ATTR_SUCCESS;
-}
-
-
-PyObject *KX_GameObject::pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- SG_Node* sg_parent;
- if (self->GetSGNode() && (sg_parent = self->GetSGNode()->GetSGParent()) != NULL && sg_parent->IsSlowParent()) {
- return PyFloat_FromDouble(static_cast<KX_SlowParentRelation *>(sg_parent->GetParentRelation())->GetTimeOffset());
- } else {
- return PyFloat_FromDouble(0.0f);
- }
-}
-
-int KX_GameObject::pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- if (self->GetSGNode()) {
- MT_Scalar val = PyFloat_AsDouble(value);
- SG_Node *sg_parent= self->GetSGNode()->GetSGParent();
- if (val < 0.0f) { /* also accounts for non float */
- PyErr_SetString(PyExc_AttributeError, "gameOb.timeOffset = float: KX_GameObject, expected a float zero or above");
- return PY_SET_ATTR_FAIL;
- }
- if (sg_parent && sg_parent->IsSlowParent())
- static_cast<KX_SlowParentRelation *>(sg_parent->GetParentRelation())->SetTimeOffset(val);
- }
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- int state = 0;
- state |= self->GetState();
- return PyLong_FromLong(state);
-}
-
-int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- int state_i = PyLong_AsLong(value);
- unsigned int state = 0;
-
- if (state_i == -1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError, "gameOb.state = int: KX_GameObject, expected an int bit field");
- return PY_SET_ATTR_FAIL;
- }
-
- state |= state_i;
- if ((state & ((1<<30)-1)) == 0) {
- PyErr_SetString(PyExc_AttributeError, "gameOb.state = int: KX_GameObject, state bitfield was not between 0 and 30 (1<<0 and 1<<29)");
- return PY_SET_ATTR_FAIL;
- }
- self->SetState(state);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- PyObject *meshes= PyList_New(self->m_meshes.size());
- int i;
-
- for (i=0; i < (int)self->m_meshes.size(); i++)
- {
- KX_MeshProxy* meshproxy = new KX_MeshProxy(self->m_meshes[i]);
- PyList_SET_ITEM(meshes, i, meshproxy->NewProxy(true));
- }
-
- return meshes;
-}
-
-PyObject *KX_GameObject::pyattr_get_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 4,
- mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_OBJECT_COLOR);
-#else
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return PyObjectFrom(self->GetObjectColor());
-#endif
-}
-
-int KX_GameObject::pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- MT_Vector4 obcolor;
- if (!PyVecTo(value, obcolor))
- return PY_SET_ATTR_FAIL;
-
- self->SetObjectColor(obcolor);
- return PY_SET_ATTR_SUCCESS;
-}
-
-static int kx_game_object_get_sensors_size_cb(void *self_v)
-{
- return ((KX_GameObject *)self_v)->GetSensors().size();
-}
-
-static PyObject *kx_game_object_get_sensors_item_cb(void *self_v, int index)
-{
- return ((KX_GameObject *)self_v)->GetSensors()[index]->GetProxy();
-}
-
-static const char *kx_game_object_get_sensors_item_name_cb(void *self_v, int index)
-{
- return ((KX_GameObject *)self_v)->GetSensors()[index]->GetName().ReadPtr();
-}
-
-/* These are experimental! */
-PyObject *KX_GameObject::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- return (new CListWrapper(self_v,
- ((KX_GameObject *)self_v)->GetProxy(),
- NULL,
- kx_game_object_get_sensors_size_cb,
- kx_game_object_get_sensors_item_cb,
- kx_game_object_get_sensors_item_name_cb,
- NULL))->NewProxy(true);
-}
-
-static int kx_game_object_get_controllers_size_cb(void *self_v)
-{
- return ((KX_GameObject *)self_v)->GetControllers().size();
-}
-
-static PyObject *kx_game_object_get_controllers_item_cb(void *self_v, int index)
-{
- return ((KX_GameObject *)self_v)->GetControllers()[index]->GetProxy();
-}
-
-static const char *kx_game_object_get_controllers_item_name_cb(void *self_v, int index)
-{
- return ((KX_GameObject *)self_v)->GetControllers()[index]->GetName().ReadPtr();
-}
-
-PyObject *KX_GameObject::pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- return (new CListWrapper(self_v,
- ((KX_GameObject *)self_v)->GetProxy(),
- NULL,
- kx_game_object_get_controllers_size_cb,
- kx_game_object_get_controllers_item_cb,
- kx_game_object_get_controllers_item_name_cb,
- NULL))->NewProxy(true);
-}
-
-static int kx_game_object_get_actuators_size_cb(void *self_v)
-{
- return ((KX_GameObject *)self_v)->GetActuators().size();
-}
-
-static PyObject *kx_game_object_get_actuators_item_cb(void *self_v, int index)
-{
- return ((KX_GameObject *)self_v)->GetActuators()[index]->GetProxy();
-}
-
-static const char *kx_game_object_get_actuators_item_name_cb(void *self_v, int index)
-{
- return ((KX_GameObject *)self_v)->GetActuators()[index]->GetName().ReadPtr();
-}
-
-PyObject *KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- return (new CListWrapper(self_v,
- ((KX_GameObject *)self_v)->GetProxy(),
- NULL,
- kx_game_object_get_actuators_size_cb,
- kx_game_object_get_actuators_item_cb,
- kx_game_object_get_actuators_item_name_cb,
- NULL))->NewProxy(true);
-}
-/* End experimental */
-
-PyObject *KX_GameObject::pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return self->GetChildren()->NewProxy(true);
-}
-
-PyObject *KX_GameObject::pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
- return self->GetChildrenRecursive()->NewProxy(true);
-}
-
-PyObject *KX_GameObject::pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
-
- if (self->m_attr_dict==NULL)
- self->m_attr_dict= PyDict_New();
-
- Py_INCREF(self->m_attr_dict);
- return self->m_attr_dict;
-}
-
-PyObject *KX_GameObject::pyattr_get_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene *scene = KX_GetActiveScene();
- KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
-
- return PyBool_FromLong(scene->ObjectInDebugList(self));
-}
-
-int KX_GameObject::pyattr_set_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
- int param = PyObject_IsTrue(value);
-
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "gameOb.debug = bool: KX_GameObject, expected True or False");
- return PY_SET_ATTR_FAIL;
- }
-
- self->SetUseDebugProperties(param, false);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::pyattr_get_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene *scene = KX_GetActiveScene();
- KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
-
- return PyBool_FromLong(scene->ObjectInDebugList(self));
-}
-
-int KX_GameObject::pyattr_set_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
- int param = PyObject_IsTrue(value);
-
- if (param == -1) {
- PyErr_SetString(PyExc_AttributeError, "gameOb.debugRecursive = bool: KX_GameObject, expected True or False");
- return PY_SET_ATTR_FAIL;
- }
-
- self->SetUseDebugProperties(param, true);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_GameObject::PyApplyForce(PyObject *args)
-{
- int local = 0;
- PyObject *pyvect;
-
- if (PyArg_ParseTuple(args, "O|i:applyForce", &pyvect, &local)) {
- MT_Vector3 force;
- if (PyVecTo(pyvect, force)) {
- ApplyForce(force, (local!=0));
- Py_RETURN_NONE;
- }
- }
- return NULL;
-}
-
-PyObject *KX_GameObject::PyApplyTorque(PyObject *args)
-{
- int local = 0;
- PyObject *pyvect;
-
- if (PyArg_ParseTuple(args, "O|i:applyTorque", &pyvect, &local)) {
- MT_Vector3 torque;
- if (PyVecTo(pyvect, torque)) {
- ApplyTorque(torque, (local!=0));
- Py_RETURN_NONE;
- }
- }
- return NULL;
-}
-
-PyObject *KX_GameObject::PyApplyRotation(PyObject *args)
-{
- int local = 0;
- PyObject *pyvect;
-
- if (PyArg_ParseTuple(args, "O|i:applyRotation", &pyvect, &local)) {
- MT_Vector3 rotation;
- if (PyVecTo(pyvect, rotation)) {
- ApplyRotation(rotation, (local!=0));
- Py_RETURN_NONE;
- }
- }
- return NULL;
-}
-
-PyObject *KX_GameObject::PyApplyMovement(PyObject *args)
-{
- int local = 0;
- PyObject *pyvect;
-
- if (PyArg_ParseTuple(args, "O|i:applyMovement", &pyvect, &local)) {
- MT_Vector3 movement;
- if (PyVecTo(pyvect, movement)) {
- ApplyMovement(movement, (local!=0));
- Py_RETURN_NONE;
- }
- }
- return NULL;
-}
-
-PyObject *KX_GameObject::PyGetLinearVelocity(PyObject *args)
-{
- // only can get the velocity if we have a physics object connected to us...
- int local = 0;
- if (PyArg_ParseTuple(args,"|i:getLinearVelocity",&local))
- {
- return PyObjectFrom(GetLinearVelocity((local!=0)));
- }
- else
- {
- return NULL;
- }
-}
-
-PyObject *KX_GameObject::PySetLinearVelocity(PyObject *args)
-{
- int local = 0;
- PyObject *pyvect;
-
- if (PyArg_ParseTuple(args,"O|i:setLinearVelocity",&pyvect,&local)) {
- MT_Vector3 velocity;
- if (PyVecTo(pyvect, velocity)) {
- setLinearVelocity(velocity, (local!=0));
- Py_RETURN_NONE;
- }
- }
- return NULL;
-}
-
-PyObject *KX_GameObject::PyGetAngularVelocity(PyObject *args)
-{
- // only can get the velocity if we have a physics object connected to us...
- int local = 0;
- if (PyArg_ParseTuple(args,"|i:getAngularVelocity",&local))
- {
- return PyObjectFrom(GetAngularVelocity((local!=0)));
- }
- else
- {
- return NULL;
- }
-}
-
-PyObject *KX_GameObject::PySetAngularVelocity(PyObject *args)
-{
- int local = 0;
- PyObject *pyvect;
-
- if (PyArg_ParseTuple(args,"O|i:setAngularVelocity",&pyvect,&local)) {
- MT_Vector3 velocity;
- if (PyVecTo(pyvect, velocity)) {
- setAngularVelocity(velocity, (local!=0));
- Py_RETURN_NONE;
- }
- }
- return NULL;
-}
-
-PyObject *KX_GameObject::PySetDamping(PyObject *args)
-{
- float linear;
- float angular;
-
- if (!PyArg_ParseTuple(args,"ff|i:setDamping", &linear, &angular))
- return NULL;
-
- setDamping(linear, angular);
- Py_RETURN_NONE;
-}
-
-PyObject *KX_GameObject::PySetVisible(PyObject *args)
-{
- int visible, recursive = 0;
- if (!PyArg_ParseTuple(args,"i|i:setVisible",&visible, &recursive))
- return NULL;
-
- SetVisible(visible ? true:false, recursive ? true:false);
- UpdateBuckets(recursive ? true:false);
- Py_RETURN_NONE;
-
-}
-
-PyObject *KX_GameObject::PySetOcclusion(PyObject *args)
-{
- int occlusion, recursive = 0;
- if (!PyArg_ParseTuple(args,"i|i:setOcclusion",&occlusion, &recursive))
- return NULL;
-
- SetOccluder(occlusion ? true:false, recursive ? true:false);
- Py_RETURN_NONE;
-}
-
-PyObject *KX_GameObject::PyGetVelocity(PyObject *args)
-{
- // only can get the velocity if we have a physics object connected to us...
- MT_Point3 point(0.0f,0.0f,0.0f);
- PyObject *pypos = NULL;
-
- if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point)))
- return NULL;
-
- return PyObjectFrom(GetVelocity(point));
-}
-
-PyObject *KX_GameObject::PyGetReactionForce()
-{
- // only can get the velocity if we have a physics object connected to us...
-
- // XXX - Currently not working with bullet intergration, see KX_BulletPhysicsController.cpp's getReactionForce
-#if 0
- if (GetPhysicsController1())
- return PyObjectFrom(GetPhysicsController1()->getReactionForce());
- return PyObjectFrom(dummy_point);
-#endif
-
- return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f);
-
-}
-
-
-
-PyObject *KX_GameObject::PyEnableRigidBody()
-{
- if (GetPhysicsController())
- GetPhysicsController()->SetRigidBody(true);
-
- Py_RETURN_NONE;
-}
-
-
-
-PyObject *KX_GameObject::PyDisableRigidBody()
-{
- if (GetPhysicsController())
- GetPhysicsController()->SetRigidBody(false);
-
- Py_RETURN_NONE;
-}
-
-
-PyObject *KX_GameObject::PySetParent(PyObject *args)
-{
- KX_Scene *scene = KX_GetActiveScene();
- SCA_LogicManager *logicmgr = GetScene()->GetLogicManager();
- PyObject *pyobj;
- KX_GameObject *obj;
- int addToCompound=1, ghost=1;
-
- if (!PyArg_ParseTuple(args,"O|ii:setParent", &pyobj, &addToCompound, &ghost)) {
- return NULL; // Python sets a simple error
- }
- if (!ConvertPythonToGameObject(logicmgr, pyobj, &obj, true, "gameOb.setParent(obj): KX_GameObject"))
- return NULL;
- if (obj)
- this->SetParent(scene, obj, addToCompound, ghost);
- Py_RETURN_NONE;
-}
-
-PyObject *KX_GameObject::PyRemoveParent()
-{
- KX_Scene *scene = KX_GetActiveScene();
-
- this->RemoveParent(scene);
- Py_RETURN_NONE;
-}
-
-
-PyObject *KX_GameObject::PySetCollisionMargin(PyObject *value)
-{
- float collisionMargin = PyFloat_AsDouble(value);
-
- if (collisionMargin==-1 && PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError, "expected a float");
- return NULL;
- }
-
- if (m_pPhysicsController)
- {
- m_pPhysicsController->SetMargin(collisionMargin);
- Py_RETURN_NONE;
- }
- PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller");
- return NULL;
-}
-
-
-
-PyObject *KX_GameObject::PyApplyImpulse(PyObject *args)
-{
- PyObject *pyattach;
- PyObject *pyimpulse;
- int local = 0;
-
- if (!m_pPhysicsController) {
- PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller");
- return NULL;
- }
-
- if (PyArg_ParseTuple(args, "OO|i:applyImpulse", &pyattach, &pyimpulse, &local))
- {
- MT_Point3 attach;
- MT_Vector3 impulse;
- if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse))
- {
- m_pPhysicsController->ApplyImpulse(attach, impulse, (local!=0));
- Py_RETURN_NONE;
- }
-
- }
-
- return NULL;
-}
-
-
-
-PyObject *KX_GameObject::PySuspendDynamics(PyObject *args)
-{
- bool ghost = false;
-
- if (!PyArg_ParseTuple(args, "|b", &ghost))
- return NULL;
-
- if (GetPhysicsController())
- GetPhysicsController()->SuspendDynamics(ghost);
-
- Py_RETURN_NONE;
-}
-
-
-
-PyObject *KX_GameObject::PyRestoreDynamics()
-{
- // Child objects must be static, so we block changing to dynamic
- if (GetPhysicsController() && !GetParent())
- GetPhysicsController()->RestoreDynamics();
- Py_RETURN_NONE;
-}
-
-
-PyObject *KX_GameObject::PyAlignAxisToVect(PyObject *args)
-{
- PyObject *pyvect;
- int axis = 2; //z axis is the default
- float fac = 1.0f;
-
- if (PyArg_ParseTuple(args,"O|if:alignAxisToVect",&pyvect,&axis, &fac))
- {
- MT_Vector3 vect;
- if (PyVecTo(pyvect, vect)) {
- if (fac > 0.0f) {
- if (fac> 1.0f) fac = 1.0f;
-
- AlignAxisToVect(vect, axis, fac);
- NodeUpdateGS(0.f);
- }
- Py_RETURN_NONE;
- }
- }
- return NULL;
-}
-
-PyObject *KX_GameObject::PyGetAxisVect(PyObject *value)
-{
- MT_Vector3 vect;
- if (PyVecTo(value, vect))
- {
- return PyObjectFrom(NodeGetWorldOrientation() * vect);
- }
- return NULL;
-}
-
-
-PyObject *KX_GameObject::PyGetPhysicsId()
-{
- PHY_IPhysicsController* ctrl = GetPhysicsController();
- unsigned long long physid = 0;
- if (ctrl)
- {
- physid = (unsigned long long)ctrl;
- }
- return PyLong_FromUnsignedLongLong(physid);
-}
-
-PyObject *KX_GameObject::PyGetPropertyNames()
-{
- PyObject *list= ConvertKeysToPython();
-
- if (m_attr_dict) {
- PyObject *key, *value;
- Py_ssize_t pos = 0;
-
- while (PyDict_Next(m_attr_dict, &pos, &key, &value)) {
- PyList_Append(list, key);
- }
- }
- return list;
-}
-
-KX_PYMETHODDEF_DOC_O(KX_GameObject, getDistanceTo,
-"getDistanceTo(other): get distance to another point/KX_GameObject")
-{
- MT_Point3 b;
- if (PyVecTo(value, b))
- {
- return PyFloat_FromDouble(NodeGetWorldPosition().distance(b));
- }
- PyErr_Clear();
-
- SCA_LogicManager *logicmgr = GetScene()->GetLogicManager();
- KX_GameObject *other;
- if (ConvertPythonToGameObject(logicmgr, value, &other, false, "gameOb.getDistanceTo(value): KX_GameObject"))
- {
- return PyFloat_FromDouble(NodeGetWorldPosition().distance(other->NodeGetWorldPosition()));
- }
-
- return NULL;
-}
-
-KX_PYMETHODDEF_DOC_O(KX_GameObject, getVectTo,
-"getVectTo(other): get vector and the distance to another point/KX_GameObject\n"
-"Returns a 3-tuple with (distance,worldVector,localVector)\n")
-{
- MT_Point3 toPoint, fromPoint;
- MT_Vector3 toDir, locToDir;
- MT_Scalar distance;
-
- SCA_LogicManager *logicmgr = GetScene()->GetLogicManager();
- PyObject *returnValue;
-
- if (!PyVecTo(value, toPoint))
- {
- PyErr_Clear();
-
- KX_GameObject *other;
- if (ConvertPythonToGameObject(logicmgr, value, &other, false, "")) /* error will be overwritten */
- {
- toPoint = other->NodeGetWorldPosition();
- } else
- {
- PyErr_SetString(PyExc_TypeError, "gameOb.getVectTo(other): KX_GameObject, expected a 3D Vector or KX_GameObject type");
- return NULL;
- }
- }
-
- fromPoint = NodeGetWorldPosition();
- toDir = toPoint-fromPoint;
- distance = toDir.length();
-
- if (MT_fuzzyZero(distance))
- {
- //cout << "getVectTo() Error: Null vector!\n";
- locToDir = toDir = MT_Vector3(0.0f,0.0f,0.0f);
- distance = 0.0f;
- } else {
- toDir.normalize();
- locToDir = toDir * NodeGetWorldOrientation();
- }
-
- returnValue = PyTuple_New(3);
- if (returnValue) { // very unlikely to fail, python sets a memory error here.
- PyTuple_SET_ITEM(returnValue, 0, PyFloat_FromDouble(distance));
- PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(toDir));
- PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(locToDir));
- }
- return returnValue;
-}
-
-struct KX_GameObject::RayCastData
-{
- RayCastData(STR_String prop, bool xray, short mask)
- :m_prop(prop),
- m_xray(xray),
- m_mask(mask),
- m_hitObject(NULL)
- {
- }
-
- STR_String m_prop;
- bool m_xray;
- unsigned short m_mask;
- KX_GameObject *m_hitObject;
-};
-
-bool KX_GameObject::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, RayCastData *rayData)
-{
- KX_GameObject* hitKXObj = client->m_gameobject;
-
- // if X-ray option is selected, the unwnted objects were not tested, so get here only with true hit
- // if not, all objects were tested and the front one may not be the correct one.
- if ((rayData->m_xray || rayData->m_prop.Length() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) &&
- hitKXObj->GetUserCollisionGroup() & rayData->m_mask)
- {
- rayData->m_hitObject = hitKXObj;
- return true;
- }
- // return true to stop RayCast::RayTest from looping, the above test was decisive
- // We would want to loop only if we want to get more than one hit point
- return true;
-}
-
-/* this function is used to pre-filter the object before casting the ray on them.
- * This is useful for "X-Ray" option when we want to see "through" unwanted object.
- */
-bool KX_GameObject::NeedRayCast(KX_ClientObjectInfo *client, RayCastData *rayData)
-{
- KX_GameObject* hitKXObj = client->m_gameobject;
-
- if (client->m_type > KX_ClientObjectInfo::ACTOR)
- {
- // Unknown type of object, skip it.
- // Should not occur as the sensor objects are filtered in RayTest()
- printf("Invalid client type %d found in ray casting\n", client->m_type);
- return false;
- }
-
- // if X-Ray option is selected, skip object that don't match the criteria as we see through them
- // if not, test all objects because we don't know yet which one will be on front
- if ((!rayData->m_xray || rayData->m_prop.Length() == 0 || hitKXObj->GetProperty(rayData->m_prop) != NULL) &&
- hitKXObj->GetUserCollisionGroup() & rayData->m_mask)
- {
- return true;
- }
- // skip the object
- return false;
-}
-
-KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
-"rayCastTo(other,dist,prop): look towards another point/KX_GameObject and return first object hit within dist that matches prop\n"
-" prop = property name that object must have; can be omitted => detect any object\n"
-" dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to other\n"
-" other = 3-tuple or object reference")
-{
- MT_Point3 toPoint;
- PyObject *pyarg;
- float dist = 0.0f;
- char *propName = NULL;
- SCA_LogicManager *logicmgr = GetScene()->GetLogicManager();
-
- if (!PyArg_ParseTuple(args,"O|fs:rayCastTo", &pyarg, &dist, &propName)) {
- return NULL; // python sets simple error
- }
-
- if (!PyVecTo(pyarg, toPoint))
- {
- KX_GameObject *other;
- PyErr_Clear();
-
- if (ConvertPythonToGameObject(logicmgr, pyarg, &other, false, "")) /* error will be overwritten */
- {
- toPoint = other->NodeGetWorldPosition();
- } else
- {
- PyErr_SetString(PyExc_TypeError, "gameOb.rayCastTo(other,dist,prop): KX_GameObject, the first argument to rayCastTo must be a vector or a KX_GameObject");
- return NULL;
- }
- }
- MT_Point3 fromPoint = NodeGetWorldPosition();
-
- if (dist != 0.0f)
- toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized();
-
- PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment();
- PHY_IPhysicsController *spc = GetPhysicsController();
- KX_GameObject *parent = GetParent();
- if (!spc && parent)
- spc = parent->GetPhysicsController();
-
- RayCastData rayData(propName, false, (1u << OB_MAX_COL_MASKS) - 1);
- KX_RayCast::Callback<KX_GameObject, RayCastData> callback(this, spc, &rayData);
- if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) {
- return rayData.m_hitObject->GetProxy();
- }
-
- Py_RETURN_NONE;
-}
-
-/* faster then Py_BuildValue since some scripts call raycast a lot */
-static PyObject *none_tuple_3()
-{
- PyObject *ret= PyTuple_New(3);
- PyTuple_SET_ITEM(ret, 0, Py_None);
- PyTuple_SET_ITEM(ret, 1, Py_None);
- PyTuple_SET_ITEM(ret, 2, Py_None);
-
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- return ret;
-}
-static PyObject *none_tuple_4()
-{
- PyObject *ret= PyTuple_New(4);
- PyTuple_SET_ITEM(ret, 0, Py_None);
- PyTuple_SET_ITEM(ret, 1, Py_None);
- PyTuple_SET_ITEM(ret, 2, Py_None);
- PyTuple_SET_ITEM(ret, 3, Py_None);
-
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- return ret;
-}
-
-static PyObject *none_tuple_5()
-{
- PyObject *ret= PyTuple_New(5);
- PyTuple_SET_ITEM(ret, 0, Py_None);
- PyTuple_SET_ITEM(ret, 1, Py_None);
- PyTuple_SET_ITEM(ret, 2, Py_None);
- PyTuple_SET_ITEM(ret, 3, Py_None);
- PyTuple_SET_ITEM(ret, 4, Py_None);
-
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- return ret;
-}
-
-KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
- "rayCast(to,from,dist,prop,face,xray,poly,mask): cast a ray and return 3-tuple (object,hit,normal) or 4-tuple (object,hit,normal,polygon) or 4-tuple (object,hit,normal,polygon,hituv) of contact point with object within dist that matches prop.\n"
- " If no hit, return (None,None,None) or (None,None,None,None) or (None,None,None,None,None).\n"
-" to = 3-tuple or object reference for destination of ray (if object, use center of object)\n"
-" from = 3-tuple or object reference for origin of ray (if object, use center of object)\n"
-" Can be None or omitted => start from self object center\n"
-" dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to to\n"
-" prop = property name that object must have; can be omitted => detect any object\n"
-" face = normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin\n"
-" xray = X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object\n"
-" poly = polygon option: 1=>return value is a 4-tuple and the 4th element is a KX_PolyProxy object\n"
-" which can be None if hit object has no mesh or if there is no hit\n"
-" 2=>return value is a 5-tuple, the 4th element is the KX_PolyProxy object\n"
-" and the 5th element is the vector of UV coordinates at the hit point of the None if there is no UV mapping\n"
-" If 0 or omitted, return value is a 3-tuple\n"
-" mask = collision mask: the collision mask that ray can hit, 0 < mask < 65536\n"
-"Note: The object on which you call this method matters: the ray will ignore it.\n"
-" prop and xray option interact as follow:\n"
-" prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray\n"
-" prop off, xray on : idem\n"
-" prop on, xray off: return closest hit if it matches prop, no hit otherwise\n"
-" prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray\n")
-{
- MT_Point3 toPoint;
- MT_Point3 fromPoint;
- PyObject *pyto;
- PyObject *pyfrom = NULL;
- float dist = 0.0f;
- char *propName = NULL;
- KX_GameObject *other;
- int face=0, xray=0, poly=0;
- int mask = (1 << OB_MAX_COL_MASKS) - 1;
- SCA_LogicManager *logicmgr = GetScene()->GetLogicManager();
-
- if (!PyArg_ParseTuple(args,"O|Ofsiiii:rayCast", &pyto, &pyfrom, &dist, &propName, &face, &xray, &poly, &mask)) {
- return NULL; // Python sets a simple error
- }
-
- if (!PyVecTo(pyto, toPoint))
- {
- PyErr_Clear();
-
- if (ConvertPythonToGameObject(logicmgr, pyto, &other, false, "")) /* error will be overwritten */
- {
- toPoint = other->NodeGetWorldPosition();
- } else
- {
- PyErr_SetString(PyExc_TypeError, "the first argument to rayCast must be a vector or a KX_GameObject");
- return NULL;
- }
- }
- if (!pyfrom || pyfrom == Py_None)
- {
- fromPoint = NodeGetWorldPosition();
- }
- else if (!PyVecTo(pyfrom, fromPoint))
- {
- PyErr_Clear();
-
- if (ConvertPythonToGameObject(logicmgr, pyfrom, &other, false, "")) /* error will be overwritten */
- {
- fromPoint = other->NodeGetWorldPosition();
- } else
- {
- PyErr_SetString(PyExc_TypeError, "gameOb.rayCast(to,from,dist,prop,face,xray,poly,mask): KX_GameObject, the second optional argument to rayCast must be a vector or a KX_GameObject");
- return NULL;
- }
- }
-
- if (mask == 0 || mask & ~((1 << OB_MAX_COL_MASKS) - 1)) {
- PyErr_Format(PyExc_TypeError, "gameOb.rayCast(to,from,dist,prop,face,xray,poly,mask): KX_GameObject, mask argument to rayCast must be a int bitfield, 0 < mask < %i", (1 << OB_MAX_COL_MASKS));
- return NULL;
- }
-
- if (dist != 0.0f) {
- MT_Vector3 toDir = toPoint-fromPoint;
- if (MT_fuzzyZero(toDir.length2())) {
- //return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
- return none_tuple_3();
- }
- toDir.normalize();
- toPoint = fromPoint + (dist) * toDir;
- } else if (MT_fuzzyZero((toPoint-fromPoint).length2())) {
- //return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
- return none_tuple_3();
- }
-
- PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment();
- PHY_IPhysicsController *spc = GetPhysicsController();
- KX_GameObject *parent = GetParent();
- if (!spc && parent)
- spc = parent->GetPhysicsController();
-
- // to get the hit results
- RayCastData rayData(propName, xray, mask);
- KX_RayCast::Callback<KX_GameObject, RayCastData> callback(this, spc, &rayData, face, (poly == 2));
-
- if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) {
- PyObject *returnValue = (poly == 2) ? PyTuple_New(5) : (poly) ? PyTuple_New(4) : PyTuple_New(3);
- if (returnValue) { // unlikely this would ever fail, if it does python sets an error
- PyTuple_SET_ITEM(returnValue, 0, rayData.m_hitObject->GetProxy());
- PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(callback.m_hitPoint));
- PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(callback.m_hitNormal));
- if (poly)
- {
- if (callback.m_hitMesh)
- {
- // if this field is set, then we can trust that m_hitPolygon is a valid polygon
- RAS_Polygon* polygon = callback.m_hitMesh->GetPolygon(callback.m_hitPolygon);
- KX_PolyProxy* polyproxy = new KX_PolyProxy(callback.m_hitMesh, polygon);
- PyTuple_SET_ITEM(returnValue, 3, polyproxy->NewProxy(true));
- if (poly == 2)
- {
- if (callback.m_hitUVOK)
- PyTuple_SET_ITEM(returnValue, 4, PyObjectFrom(callback.m_hitUV));
- else {
- Py_INCREF(Py_None);
- PyTuple_SET_ITEM(returnValue, 4, Py_None);
- }
- }
- }
- else
- {
- Py_INCREF(Py_None);
- PyTuple_SET_ITEM(returnValue, 3, Py_None);
- if (poly==2)
- {
- Py_INCREF(Py_None);
- PyTuple_SET_ITEM(returnValue, 4, Py_None);
- }
- }
- }
- }
- return returnValue;
- }
- // no hit
- if (poly == 2)
- return none_tuple_5();
- else if (poly)
- return none_tuple_4();
- else
- return none_tuple_3();
-}
-
-KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage,
- "sendMessage(subject, [body, to])\n"
-"sends a message in same manner as a message actuator"
-"subject = Subject of the message (string)"
-"body = Message body (string)"
-"to = Name of object to send the message to")
-{
- KX_Scene *scene = KX_GetActiveScene();
- char* subject;
- char* body = (char *)"";
- char* to = (char *)"";
- const STR_String& from = GetName();
-
- if (!PyArg_ParseTuple(args, "s|ss:sendMessage", &subject, &body, &to))
- return NULL;
-
- scene->GetNetworkScene()->SendMessage(to, from, subject, body);
- Py_RETURN_NONE;
-}
-
-static void layer_check(short &layer, const char *method_name)
-{
- if (layer < 0 || layer >= MAX_ACTION_LAYERS)
- {
- printf("KX_GameObject.%s(): given layer (%d) is out of range (0 - %d), setting to 0.\n", method_name, layer, MAX_ACTION_LAYERS-1);
- layer = 0;
- }
-}
-
-KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
- "playAction(name, start_frame, end_frame, layer=0, priority=0 blendin=0, play_mode=ACT_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0)\n"
- "Plays an action\n")
-{
- const char* name;
- float start, end, blendin=0.f, speed=1.f, layer_weight=0.f;
- short layer=0, priority=0;
- short ipo_flags=0;
- short play_mode=0;
- short blend_mode=0;
-
- static const char *kwlist[] = {"name", "start_frame", "end_frame", "layer", "priority", "blendin", "play_mode", "layer_weight", "ipo_flags", "speed", "blend_mode", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hhfhfhfh:playAction", const_cast<char**>(kwlist),
- &name, &start, &end, &layer, &priority, &blendin, &play_mode, &layer_weight, &ipo_flags, &speed, &blend_mode))
- return NULL;
-
- layer_check(layer, "playAction");
-
- if (play_mode < 0 || play_mode > BL_Action::ACT_MODE_MAX)
- {
- printf("KX_GameObject.playAction(): given play_mode (%d) is out of range (0 - %d), setting to ACT_MODE_PLAY", play_mode, BL_Action::ACT_MODE_MAX-1);
- play_mode = BL_Action::ACT_MODE_PLAY;
- }
-
- if (blend_mode < 0 || blend_mode > BL_Action::ACT_BLEND_MAX)
- {
- printf("KX_GameObject.playAction(): given blend_mode (%d) is out of range (0 - %d), setting to ACT_BLEND_BLEND", blend_mode, BL_Action::ACT_BLEND_MAX-1);
- blend_mode = BL_Action::ACT_BLEND_BLEND;
- }
-
- if (layer_weight < 0.f || layer_weight > 1.f)
- {
- printf("KX_GameObject.playAction(): given layer_weight (%f) is out of range (0.0 - 1.0), setting to 0.0", layer_weight);
- layer_weight = 0.f;
- }
-
- PlayAction(name, start, end, layer, priority, blendin, play_mode, layer_weight, ipo_flags, speed, blend_mode);
-
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(KX_GameObject, stopAction,
- "stopAction(layer=0)\n"
- "Stop playing the action on the given layer\n")
-{
- short layer = 0;
-
- if (!PyArg_ParseTuple(args, "|h:stopAction", &layer))
- return NULL;
-
- layer_check(layer, "stopAction");
-
- StopAction(layer);
-
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(KX_GameObject, getActionFrame,
- "getActionFrame(layer=0)\n"
- "Gets the current frame of the action playing in the supplied layer\n")
-{
- short layer = 0;
-
- if (!PyArg_ParseTuple(args, "|h:getActionFrame", &layer))
- return NULL;
-
- layer_check(layer, "getActionFrame");
-
- return PyFloat_FromDouble(GetActionFrame(layer));
-}
-
-KX_PYMETHODDEF_DOC(KX_GameObject, getActionName,
- "getActionName(layer=0)\n"
- "Gets the name of the current action playing in the supplied layer\n")
-{
- short layer = 0;
-
- if (!PyArg_ParseTuple(args, "|h:getActionName", &layer))
- return NULL;
-
- layer_check(layer, "getActionName");
-
- return PyUnicode_FromString(GetActionName(layer));
-}
-
-KX_PYMETHODDEF_DOC(KX_GameObject, setActionFrame,
- "setActionFrame(frame, layer=0)\n"
- "Set the current frame of the action playing in the supplied layer\n")
-{
- short layer = 0;
- float frame;
-
- if (!PyArg_ParseTuple(args, "f|h:setActionFrame", &frame, &layer))
- return NULL;
-
- layer_check(layer, "setActionFrame");
-
- SetActionFrame(layer, frame);
-
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(KX_GameObject, isPlayingAction,
- "isPlayingAction(layer=0)\n"
- "Checks to see if there is an action playing in the given layer\n")
-{
- short layer = 0;
-
- if (!PyArg_ParseTuple(args, "|h:isPlayingAction", &layer))
- return NULL;
-
- layer_check(layer, "isPlayingAction");
-
- return PyBool_FromLong(!IsActionDone(layer));
-}
-
-
-KX_PYMETHODDEF_DOC(KX_GameObject, addDebugProperty,
-"addDebugProperty(name, visible=1)\n"
-"Added or remove a debug property to the debug list.\n")
-{
- KX_Scene *scene = KX_GetActiveScene();
- char *name;
- int visible = 1;
-
- if (!PyArg_ParseTuple(args,"s|i:debugProperty", &name , &visible))
- return NULL;
-
- if (visible) {
- if (!scene->PropertyInDebugList(this, name))
- scene->AddDebugProperty(this, name);
- }
- else {
- scene->RemoveDebugProperty(this, name);
- }
-
- Py_RETURN_NONE;
-}
-
-
-/* dict style access */
-
-
-/* Matches python dict.get(key, [default]) */
-PyObject *KX_GameObject::Pyget(PyObject *args)
-{
- PyObject *key;
- PyObject *def = Py_None;
- PyObject *ret;
-
- if (!PyArg_ParseTuple(args, "O|O:get", &key, &def))
- return NULL;
-
-
- if (PyUnicode_Check(key)) {
- CValue *item = GetProperty(_PyUnicode_AsString(key));
- if (item) {
- ret = item->ConvertValueToPython();
- if (ret)
- return ret;
- else
- return item->GetProxy();
- }
- }
-
- if (m_attr_dict && (ret=PyDict_GetItem(m_attr_dict, key))) {
- Py_INCREF(ret);
- return ret;
- }
-
- Py_INCREF(def);
- return def;
-}
-
-bool ConvertPythonToGameObject(SCA_LogicManager *manager, PyObject *value, KX_GameObject **object, bool py_none_ok, const char *error_prefix)
-{
- if (value==NULL) {
- PyErr_Format(PyExc_TypeError, "%s, python pointer NULL, should never happen", error_prefix);
- *object = NULL;
- return false;
- }
-
- if (value==Py_None) {
- *object = NULL;
-
- if (py_none_ok) {
- return true;
- } else {
- PyErr_Format(PyExc_TypeError, "%s, expected KX_GameObject or a KX_GameObject name, None is invalid", error_prefix);
- return false;
- }
- }
-
- if (PyUnicode_Check(value)) {
- *object = (KX_GameObject*)manager->GetGameObjectByName(STR_String( _PyUnicode_AsString(value) ));
-
- if (*object) {
- return true;
- } else {
- PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_GameObject in this scene", error_prefix, _PyUnicode_AsString(value));
- return false;
- }
- }
-
- if (PyObject_TypeCheck(value, &KX_GameObject::Type) ||
- PyObject_TypeCheck(value, &KX_LightObject::Type) ||
- PyObject_TypeCheck(value, &KX_Camera::Type) ||
- PyObject_TypeCheck(value, &KX_FontObject::Type) ||
- PyObject_TypeCheck(value, &KX_NavMeshObject::Type))
- {
- *object = static_cast<KX_GameObject*>BGE_PROXY_REF(value);
-
- /* sets the error */
- if (*object==NULL) {
- PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix);
- return false;
- }
-
- return true;
- }
-
- *object = NULL;
-
- if (py_none_ok) {
- PyErr_Format(PyExc_TypeError, "%s, expect a KX_GameObject, a string or None", error_prefix);
- } else {
- PyErr_Format(PyExc_TypeError, "%s, expect a KX_GameObject or a string", error_prefix);
- }
-
- return false;
-}
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
deleted file mode 100644
index 9c582d3e27a..00000000000
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ /dev/null
@@ -1,1142 +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_GameObject.h
- * \ingroup ketsji
- * \brief General KX game object.
- */
-
-#ifndef __KX_GAMEOBJECT_H__
-#define __KX_GAMEOBJECT_H__
-
-#ifdef _MSC_VER
- /* get rid of this stupid "warning 'this' used in initialiser list", generated by VC when including Solid/Sumo */
-# pragma warning (disable:4355)
-#endif
-
-#include <stddef.h>
-
-#include "EXP_ListValue.h"
-#include "SCA_IObject.h"
-#include "SG_Node.h"
-#include "MT_Transform.h"
-#include "MT_CmMatrix4x4.h"
-#include "CTR_Map.h"
-#include "CTR_HashedPtr.h"
-#include "KX_Scene.h"
-#include "KX_KetsjiEngine.h" /* for m_anim_framerate */
-#include "DNA_constraint_types.h" /* for constraint replication */
-#include "DNA_object_types.h"
-#include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */
-
-//Forward declarations.
-struct KX_ClientObjectInfo;
-class KX_RayCast;
-class RAS_MeshObject;
-class PHY_IGraphicController;
-class PHY_IPhysicsEnvironment;
-class PHY_IPhysicsController;
-class BL_ActionManager;
-struct Object;
-class KX_ObstacleSimulation;
-struct bAction;
-
-#ifdef WITH_PYTHON
-/* utility conversion function */
-bool ConvertPythonToGameObject(SCA_LogicManager *logicmgr, PyObject *value, KX_GameObject **object, bool py_none_ok, const char *error_prefix);
-#endif
-
-#ifdef USE_MATHUTILS
-void KX_GameObject_Mathutils_Callback_Init(void);
-#endif
-
-/**
- * KX_GameObject is the main class for dynamic objects.
- */
-class KX_GameObject : public SCA_IObject
-{
- Py_Header
-protected:
-
- bool m_bDyna;
- KX_ClientObjectInfo* m_pClient_info;
- STR_String m_name;
- STR_String m_text;
- int m_layer;
- std::vector<RAS_MeshObject*> m_meshes;
- std::vector<RAS_MeshObject*> m_lodmeshes;
- int m_currentLodLevel;
- short m_previousLodLevel;
- SG_QList m_meshSlots; // head of mesh slots of this
- struct Object* m_pBlenderObject;
- struct Object* m_pBlenderGroupObject;
-
- bool m_bUseObjectColor;
- bool m_bIsNegativeScaling;
- MT_Vector4 m_objectColor;
-
- // Bit fields for user control over physics collisions
- unsigned short m_userCollisionGroup;
- unsigned short m_userCollisionMask;
-
- // visible = user setting
- // culled = while rendering, depending on camera
- bool m_bVisible;
- bool m_bCulled;
- bool m_bOccluder;
-
- PHY_IPhysicsController* m_pPhysicsController;
- PHY_IGraphicController* m_pGraphicController;
-
- SG_Node* m_pSGNode;
-
- MT_CmMatrix4x4 m_OpenGL_4x4Matrix;
- std::vector<bRigidBodyJointConstraint*> m_constraints;
-
- KX_ObstacleSimulation* m_pObstacleSimulation;
-
- CListValue* m_pInstanceObjects;
- KX_GameObject* m_pDupliGroupObject;
-
- // The action manager is used to play/stop/update actions
- BL_ActionManager* m_actionManager;
-
- BL_ActionManager* GetActionManager();
-
- bool m_bRecordAnimation;
-
-public:
- bool m_isDeformable;
-
- /**
- * KX_GameObject custom infos for ray cast, it contains property name,
- * collision mask, xray flag and hited object.
- * This structure is created during ray cast and passed as argument
- * "data" to functions KX_GameObject::NeedRayCast and KX_GameObject::RayHit.
- */
- struct RayCastData;
-
- /**
- * Helper function for modules that can't include KX_ClientObjectInfo.h
- */
- static KX_GameObject* GetClientObject(KX_ClientObjectInfo* info);
-
-#ifdef WITH_PYTHON
- // Python attributes that wont convert into CValue
- //
- // there are 2 places attributes can be stored, in the CValue,
- // where attributes are converted into BGE's CValue types
- // these can be used with property actuators
- //
- // For the python API, For types that cannot be converted into CValues (lists, dicts, GameObjects)
- // these will be put into "m_attr_dict", logic bricks cannot access them.
- //
- // rules for setting attributes.
- //
- // * there should NEVER be a CValue and a m_attr_dict attribute with matching names. get/sets make sure of this.
- // * if CValue conversion fails, use a PyObject in "m_attr_dict"
- // * when assigning a value, first see if it can be a CValue, if it can remove the "m_attr_dict" and set the CValue
- //
- PyObject* m_attr_dict;
- PyObject* m_collisionCallbacks;
-#endif
-
- virtual void /* This function should be virtual - derived classed override it */
- Relink(
- CTR_Map<CTR_HashedPtr, void*> *map
- );
-
- /**
- * Compute an OpenGl compatible 4x4 matrix. Has the
- * side effect of storing the result internally. The
- * memory for the matrix remains the property of this class.
- */
- float *
- GetOpenGLMatrix(
- );
-
- /**
- * Return a pointer to a MT_CmMatrix4x4 storing the
- * opengl transformation for this object. This is updated
- * by a call to GetOpenGLMatrix(). This class owns the
- * memory for the returned matrix.
- */
-
- MT_CmMatrix4x4 *
- GetOpenGLMatrixPtr(
- ) {
- return &m_OpenGL_4x4Matrix;
- };
-
- /**
- * Update the blender object obmat field from the object world position
- * if blendobj is NULL, update the object pointed by m_pBlenderObject
- * The user must take action to restore the matrix before leaving the GE.
- * Used in Armature evaluation
- */
- void
- UpdateBlenderObjectMatrix(Object* blendobj=NULL);
-
- /**
- * Used for constraint replication for group instances.
- * The list of constraints is filled during data conversion.
- */
- void AddConstraint(bRigidBodyJointConstraint *cons);
- std::vector<bRigidBodyJointConstraint*> GetConstraints();
- void ClearConstraints();
-
- /**
- * Get a pointer to the game object that is the parent of
- * this object. Or NULL if there is no parent. The returned
- * object is part of a reference counting scheme. Calling
- * this function ups the reference count on the returned
- * object. It is the responsibility of the caller to decrement
- * the reference count when you have finished with it.
- */
- KX_GameObject*
- GetParent(
- );
-
- /**
- * Sets the parent of this object to a game object
- */
- void SetParent(KX_Scene *scene, KX_GameObject *obj, bool addToCompound=true, bool ghost=true);
-
- /**
- * Removes the parent of this object to a game object
- */
- void RemoveParent(KX_Scene *scene);
-
- /*********************************
- * group reference API
- *********************************/
-
- KX_GameObject*
- GetDupliGroupObject(
- );
-
- CListValue*
- GetInstanceObjects(
- );
-
- void
- SetDupliGroupObject(KX_GameObject*
- );
-
- void
- AddInstanceObjects(KX_GameObject*
- );
-
- void
- RemoveDupliGroupObject(
- );
-
- void
- RemoveInstanceObject(KX_GameObject*
- );
- /*********************************
- * Animation API
- *********************************/
-
- /**
- * Adds an action to the object's action manager
- */
- bool PlayAction(const char* name,
- float start,
- float end,
- short layer=0,
- short priority=0,
- float blendin=0.f,
- short play_mode=0,
- float layer_weight=0.f,
- short ipo_flags=0,
- float playback_speed=1.f,
- short blend_mode=0);
-
- /**
- * Gets the current frame of an action
- */
- float GetActionFrame(short layer);
-
- /**
- * Gets the name of the current action
- */
- const char *GetActionName(short layer);
-
- /**
- * Sets the current frame of an action
- */
- void SetActionFrame(short layer, float frame);
-
- /**
- * Gets the currently running action on the given layer
- */
- bAction *GetCurrentAction(short layer);
-
- /**
- * Sets play mode of the action on the given layer
- */
- void SetPlayMode(short layer, short mode);
-
- /**
- * Sets the start and end times of the action on the given layer
- */
- void SetTimes(short layer, float start, float end);
-
- /**
- * Stop playing the action on the given layer
- */
- void StopAction(short layer);
-
- /**
- * Remove playing tagged actions.
- */
- void RemoveTaggedActions();
-
- /**
- * Check if an action has finished playing
- */
- bool IsActionDone(short layer);
-
- /**
- * Kick the object's action manager
- */
- void UpdateActionManager(float curtime);
-
- /*********************************
- * End Animation API
- *********************************/
-
- /**
- * Construct a game object. This class also inherits the
- * default constructors - use those with care!
- */
-
- KX_GameObject(
- void* sgReplicationInfo,
- SG_Callbacks callbacks
- );
-
- virtual
- ~KX_GameObject(
- );
-
- /**
- * \section Stuff which is here due to poor design.
- * Inherited from CValue and needs an implementation.
- * Do not expect these functions do to anything sensible.
- */
-
- /**
- * Inherited from CValue -- does nothing!
- */
- CValue*
- Calc(
- VALUE_OPERATOR op,
- CValue *val
- );
-
- /**
- * Inherited from CValue -- does nothing!
- */
- CValue*
- CalcFinal(
- VALUE_DATA_TYPE dtype,
- VALUE_OPERATOR op,
- CValue *val
- );
-
- /**
- * Inherited from CValue -- does nothing!
- */
- const
- STR_String &
- GetText(
- );
-
- /**
- * Inherited from CValue -- does nothing!
- */
- double
- GetNumber(
- );
-
- /**
- * \section Inherited from CValue. These are the useful
- * part of the CValue interface that this class implements.
- */
-
- /**
- * Inherited from CValue -- returns the name of this object.
- */
- STR_String&
- GetName(
- );
-
- /**
- * Inherited from CValue -- set the name of this object.
- */
- void
- SetName(
- const char *name
- );
-
- /**
- * Inherited from CValue -- return a new copy of this
- * instance allocated on the heap. Ownership of the new
- * object belongs with the caller.
- */
- virtual CValue*
- GetReplica(
- );
-
- /**
- * Inherited from CValue -- Makes sure any internal
- * data owned by this class is deep copied. Called internally
- */
- virtual void
- ProcessReplica();
-
- /**
- * Return the linear velocity of the game object.
- */
- MT_Vector3
- GetLinearVelocity(
- bool local=false
- );
-
- /**
- * Return the linear velocity of a given point in world coordinate
- * but relative to center of object ([0,0,0]=center of object)
- */
- MT_Vector3
- GetVelocity(
- const MT_Point3& position
- );
-
- /**
- * Return the mass of the object
- */
- MT_Scalar
- GetMass();
-
- /**
- * Return the local inertia vector of the object
- */
- MT_Vector3
- GetLocalInertia();
-
- /**
- * Return the angular velocity of the game object.
- */
- MT_Vector3
- GetAngularVelocity(
- bool local=false
- );
-
- /**
- * Align the object to a given normal.
- */
- void
- AlignAxisToVect(
- const MT_Vector3& vect,
- int axis = 2,
- float fac = 1.0
- );
-
- /**
- * Quick'n'dirty obcolor ipo stuff
- */
-
- void
- SetObjectColor(
- const MT_Vector4& rgbavec
- );
-
- const MT_Vector4&
- GetObjectColor();
-
-
- void
- ResolveCombinedVelocities(
- const MT_Vector3 & lin_vel,
- const MT_Vector3 & ang_vel,
- bool lin_vel_local,
- bool ang_vel_local
- );
-
- /**
- * \return a pointer to the physics controller owned by this class.
- */
-
- PHY_IPhysicsController* GetPhysicsController();
-
- void SetPhysicsController(PHY_IPhysicsController* physicscontroller,bool isDynamic)
- {
- m_bDyna = isDynamic;
- m_pPhysicsController = physicscontroller;
- }
-
- virtual class RAS_Deformer* GetDeformer()
- {
- return 0;
- }
- virtual void SetDeformer(class RAS_Deformer* deformer)
- {
-
- }
-
- /**
- * \return a pointer to the graphic controller owner by this class
- */
- PHY_IGraphicController* GetGraphicController()
- {
- return m_pGraphicController;
- }
-
- void SetGraphicController(PHY_IGraphicController* graphiccontroller)
- {
- m_pGraphicController = graphiccontroller;
- }
- /*
- * @add/remove the graphic controller to the physic system
- */
- void ActivateGraphicController(bool recurse);
-
- /** Set the object's collison group
- * \param filter The group bitfield
- */
- void SetUserCollisionGroup(unsigned short filter);
-
- /** Set the object's collison mask
- * \param filter The mask bitfield
- */
- void SetUserCollisionMask(unsigned short mask);
- unsigned short GetUserCollisionGroup();
- unsigned short GetUserCollisionMask();
- /**
- * Extra broadphase check for user controllable collisions
- */
- bool CheckCollision(KX_GameObject *other);
-
- /**
- * \section Coordinate system manipulation functions
- */
-
- void NodeSetLocalPosition(const MT_Point3& trans );
-
- void NodeSetLocalOrientation(const MT_Matrix3x3& rot );
- void NodeSetGlobalOrientation(const MT_Matrix3x3& rot );
-
- void NodeSetLocalScale( const MT_Vector3& scale );
- void NodeSetWorldScale( const MT_Vector3& scale );
-
- void NodeSetRelativeScale( const MT_Vector3& scale );
-
- // adapt local position so that world position is set to desired position
- void NodeSetWorldPosition(const MT_Point3& trans);
-
- void
- NodeUpdateGS(
- double time
- );
-
- const MT_Matrix3x3& NodeGetWorldOrientation( ) const;
- const MT_Vector3& NodeGetWorldScaling( ) const;
- const MT_Point3& NodeGetWorldPosition( ) const;
-
- const MT_Matrix3x3& NodeGetLocalOrientation( ) const;
- const MT_Vector3& NodeGetLocalScaling( ) const;
- const MT_Point3& NodeGetLocalPosition( ) const;
-
- /**
- * \section scene graph node accessor functions.
- */
-
- SG_Node* GetSGNode( )
- {
- return m_pSGNode;
- }
-
- const SG_Node* GetSGNode( ) const
- {
- return m_pSGNode;
- }
-
- /**
- * \section blender object accessor functions.
- */
-
- struct Object* GetBlenderObject( )
- {
- return m_pBlenderObject;
- }
-
- void SetBlenderObject(struct Object* obj)
- {
- m_pBlenderObject = obj;
- }
-
- struct Object* GetBlenderGroupObject( )
- {
- return m_pBlenderGroupObject;
- }
-
- void SetBlenderGroupObject(struct Object* obj)
- {
- m_pBlenderGroupObject = obj;
- }
-
- bool IsDupliGroup()
- {
- return (m_pBlenderObject &&
- (m_pBlenderObject->transflag & OB_DUPLIGROUP) &&
- m_pBlenderObject->dup_group != NULL) ? true : false;
- }
-
- /**
- * Set the Scene graph node for this game object.
- * warning - it is your responsibility to make sure
- * all controllers look at this new node. You must
- * also take care of the memory associated with the
- * old node. This class takes ownership of the new
- * node.
- */
- void SetSGNode(SG_Node* node )
- {
- m_pSGNode = node;
- }
-
- //Is it a dynamic/physics object ?
- bool IsDynamic() const
- {
- return m_bDyna;
- }
-
- bool IsDynamicsSuspended() const;
-
- /**
- * Should we record animation for this object?
- */
-
- void SetRecordAnimation(bool recordAnimation)
- {
- m_bRecordAnimation = recordAnimation;
- }
-
- bool IsRecordAnimation() const
- {
- return m_bRecordAnimation;
- }
-
- /**
- * Check if this object has a vertex parent relationship
- */
- bool IsVertexParent( )
- {
- return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent());
- }
-
- /// \see KX_RayCast
- bool RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, RayCastData *rayData);
- /// \see KX_RayCast
- bool NeedRayCast(KX_ClientObjectInfo *client, RayCastData *rayData);
-
-
- /**
- * \section Physics accessors for this node.
- *
- * All these calls get passed directly to the physics controller
- * owned by this object.
- * This is real interface bloat. Why not just use the physics controller
- * directly? I think this is because the python interface is in the wrong
- * place.
- */
-
- void
- ApplyForce(
- const MT_Vector3& force, bool local
- );
-
- void
- ApplyTorque(
- const MT_Vector3& torque,
- bool local
- );
-
- void
- ApplyRotation(
- const MT_Vector3& drot,
- bool local
- );
-
- void
- ApplyMovement(
- const MT_Vector3& dloc,
- bool local
- );
-
- void
- addLinearVelocity(
- const MT_Vector3& lin_vel,
- bool local
- );
-
- void
- setLinearVelocity(
- const MT_Vector3& lin_vel,
- bool local
- );
-
- void
- setAngularVelocity(
- const MT_Vector3& ang_vel,
- bool local
- );
-
- virtual float getLinearDamping() const;
- virtual float getAngularDamping() const;
- virtual void setLinearDamping(float damping);
- virtual void setAngularDamping(float damping);
- virtual void setDamping(float linear, float angular);
-
- /**
- * Update the physics object transform based upon the current SG_Node
- * position.
- */
- void
- UpdateTransform(
- );
-
- static void UpdateTransformFunc(SG_IObject* node, void* gameobj, void* scene);
-
- /**
- * only used for sensor objects
- */
- void SynchronizeTransform();
-
- static void SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene);
-
- /**
- * Function to set IPO option at start of IPO
- */
- void
- InitIPO(
- bool ipo_as_force,
- bool ipo_add,
- bool ipo_local
- );
-
- /**
- * Odd function to update an ipo. ???
- */
- void
- UpdateIPO(
- float curframetime,
- bool recurse
- );
- /**
- * Updates Material Ipo data
- */
- void
- UpdateMaterialData(
- dword matname_hash,
- MT_Vector4 rgba,
- MT_Vector3 specrgb,
- MT_Scalar hard,
- MT_Scalar spec,
- MT_Scalar ref,
- MT_Scalar emit,
- MT_Scalar alpha
- );
-
- /**
- * \section Mesh accessor functions.
- */
-
- /**
- * Update buckets to indicate that there is a new
- * user of this object's meshes.
- */
- void
- AddMeshUser(
- );
-
- /**
- * Update buckets with data about the mesh after
- * creating or duplicating the object, changing
- * visibility, object color, .. .
- */
- void
- UpdateBuckets(
- bool recursive
- );
-
- /**
- * Clear the meshes associated with this class
- * and remove from the bucketing system.
- * Don't think this actually deletes any of the meshes.
- */
- void
- RemoveMeshes(
- );
-
- /**
- * Add a mesh to the set of meshes associated with this
- * node. Meshes added in this way are not deleted by this class.
- * Make sure you call RemoveMeshes() before deleting the
- * mesh though,
- */
- void
- AddMesh(
- RAS_MeshObject* mesh
- ) {
- m_meshes.push_back(mesh);
- }
-
- /**
- * Add a level of detail mesh to the object. These should
- * be added in order.
- */
- void
- AddLodMesh(
- RAS_MeshObject* mesh
- );
-
- /**
- * Updates the current lod level based on distance from camera.
- */
- void
- UpdateLod(
- MT_Vector3 &cam_pos
- );
-
- /**
- * Pick out a mesh associated with the integer 'num'.
- */
- RAS_MeshObject*
- GetMesh(
- int num
- ) const {
- return m_meshes[num];
- }
-
- /**
- * Return the number of meshes currently associated with this
- * game object.
- */
- int
- GetMeshCount(
- ) const {
- return m_meshes.size();
- }
-
- /**
- * Set the debug color of the meshes associated with this
- * class. Does this still work?
- */
- void
- SetDebugColor(
- unsigned int bgra
- );
-
- /**
- * Reset the debug color of meshes associated with this class.
- */
- void
- ResetDebugColor(
- );
-
- /**
- * Was this object marked visible? (only for the explicit
- * visibility system).
- */
- bool
- GetVisible(
- void
- );
-
- /**
- * Set visibility flag of this object
- */
- void
- SetVisible(
- bool b,
- bool recursive
- );
-
- /**
- * Was this object culled?
- */
- inline bool
- GetCulled(
- void
- ) { return m_bCulled; }
-
- /**
- * Set culled flag of this object
- */
- inline void
- SetCulled(
- bool c
- ) { m_bCulled = c; }
-
- /**
- * Is this object an occluder?
- */
- inline bool
- GetOccluder(
- void
- ) { return m_bOccluder; }
-
- /**
- * Set occluder flag of this object
- */
- void
- SetOccluder(
- bool v,
- bool recursive
- );
-
- /**
- * Change the layer of the object (when it is added in another layer
- * than the original layer)
- */
- virtual void
- SetLayer(
- int l
- );
-
- /**
- * Get the object layer
- */
- int
- GetLayer(
- void
- );
-
- /**
- * Get the negative scaling state
- */
- bool
- IsNegativeScaling(
- void
- ) { return m_bIsNegativeScaling; }
-
- /**
- * \section Logic bubbling methods.
- */
-
- void RegisterCollisionCallbacks();
- void UnregisterCollisionCallbacks();
- void RunCollisionCallbacks(KX_GameObject *collider, const MT_Vector3 &point, const MT_Vector3 &normal);
- /**
- * Stop making progress
- */
- void Suspend(void);
-
- /**
- * Resume making progress
- */
- void Resume(void);
-
- void RegisterObstacle(KX_ObstacleSimulation* obstacleSimulation)
- {
- m_pObstacleSimulation = obstacleSimulation;
- }
-
- void UnregisterObstacle()
- {
- m_pObstacleSimulation = NULL;
- }
-
- /**
- * add debug object to the debuglist.
- */
- void SetUseDebugProperties(bool debug, bool recursive);
-
- KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; }
-
- CListValue* GetChildren();
- CListValue* GetChildrenRecursive();
-
- KX_Scene* GetScene();
-
-#ifdef WITH_PYTHON
- /**
- * \section Python interface functions.
- */
- virtual PyObject *py_repr(void)
- {
- return PyUnicode_From_STR_String(GetName());
- }
-
- KX_PYMETHOD_O(KX_GameObject,SetWorldPosition);
- KX_PYMETHOD_VARARGS(KX_GameObject, ApplyForce);
- KX_PYMETHOD_VARARGS(KX_GameObject, ApplyTorque);
- KX_PYMETHOD_VARARGS(KX_GameObject, ApplyRotation);
- KX_PYMETHOD_VARARGS(KX_GameObject, ApplyMovement);
- KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity);
- KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity);
- KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity);
- KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity);
- KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity);
- KX_PYMETHOD_VARARGS(KX_GameObject,SetDamping);
-
- KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce);
-
-
- KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible);
- KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible);
- KX_PYMETHOD_VARARGS(KX_GameObject,SetOcclusion);
- KX_PYMETHOD_NOARGS(KX_GameObject,GetState);
- KX_PYMETHOD_O(KX_GameObject,SetState);
- KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect);
- KX_PYMETHOD_O(KX_GameObject,GetAxisVect);
- KX_PYMETHOD_VARARGS(KX_GameObject,SuspendDynamics);
- KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics);
- KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody);
- KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody);
- KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse);
- KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin);
- KX_PYMETHOD_NOARGS(KX_GameObject,GetParent);
- KX_PYMETHOD_VARARGS(KX_GameObject,SetParent);
- KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent);
- KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren);
- KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive);
- KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
- KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
- KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
- KX_PYMETHOD_VARARGS(KX_GameObject,ReplaceMesh);
- KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
- KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
- KX_PYMETHOD_DOC(KX_GameObject,rayCast);
- KX_PYMETHOD_DOC_O(KX_GameObject,getDistanceTo);
- KX_PYMETHOD_DOC_O(KX_GameObject,getVectTo);
- KX_PYMETHOD_DOC_VARARGS(KX_GameObject, sendMessage);
- KX_PYMETHOD_VARARGS(KX_GameObject, ReinstancePhysicsMesh);
- KX_PYMETHOD_DOC(KX_GameObject, addDebugProperty);
-
- KX_PYMETHOD_DOC(KX_GameObject, playAction);
- KX_PYMETHOD_DOC(KX_GameObject, stopAction);
- KX_PYMETHOD_DOC(KX_GameObject, getActionFrame);
- KX_PYMETHOD_DOC(KX_GameObject, getActionName);
- KX_PYMETHOD_DOC(KX_GameObject, setActionFrame);
- KX_PYMETHOD_DOC(KX_GameObject, isPlayingAction);
-
- /* Dict access */
- KX_PYMETHOD_VARARGS(KX_GameObject,get);
-
- /* attributes */
- static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- static PyObject* pyattr_get_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_group_members(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_scene(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- static PyObject* pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_is_suspend_dynamics(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_ang_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_ang_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_ang_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_ang_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_obcolor(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_collisionCallbacks(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_collisionCallbacks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_collisionGroup(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_collisionGroup(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_collisionMask(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_collisionMask(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_debug(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_debugRecursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_linearDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_angularDamping(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- /* Experimental! */
- static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- /* getitem/setitem */
- static PyMappingMethods Mapping;
- static PySequenceMethods Sequence;
-#endif
-};
-
-
-
-#endif /* __KX_GAMEOBJECT_H__ */
diff --git a/source/gameengine/Ketsji/KX_IInterpolator.h b/source/gameengine/Ketsji/KX_IInterpolator.h
deleted file mode 100644
index 6c0bf2d85cc..00000000000
--- a/source/gameengine/Ketsji/KX_IInterpolator.h
+++ /dev/null
@@ -1,56 +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_IInterpolator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_IINTERPOLATOR_H__
-#define __KX_IINTERPOLATOR_H__
-
-#include <vector>
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class KX_IInterpolator {
-public:
- virtual ~KX_IInterpolator() {}
-
- virtual void Execute(float currentTime) const = 0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IInterpolator")
-#endif
-};
-
-typedef std::vector<KX_IInterpolator *> T_InterpolatorList;
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_IPOTransform.h b/source/gameengine/Ketsji/KX_IPOTransform.h
deleted file mode 100644
index a81c432b01e..00000000000
--- a/source/gameengine/Ketsji/KX_IPOTransform.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) 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_IPOTransform.h
- * \ingroup ketsji
- * \brief An abstract object you can move around in a 3d world, and has some logic
- */
-
-#ifndef __KX_IPOTRANSFORM_H__
-#define __KX_IPOTRANSFORM_H__
-
-#include "MT_Transform.h"
-
-class KX_IPOTransform {
-public:
- KX_IPOTransform() :
- m_position(0.0f, 0.0f, 0.0f),
- m_eulerAngles(0.0f, 0.0f, 0.0f),
- m_scaling(1.0f, 1.0f, 1.0f),
- m_deltaPosition(0.0f, 0.0f, 0.0f),
- m_deltaEulerAngles(0.0f, 0.0f, 0.0f),
- m_deltaScaling(0.0f, 0.0f, 0.0f)
- {}
-
- MT_Transform GetTransform() const {
- return MT_Transform(m_position + m_deltaPosition,
- MT_Matrix3x3(m_eulerAngles + m_deltaEulerAngles,
- m_scaling + m_deltaScaling));
- }
-
- MT_Point3& GetPosition() { return m_position; }
- MT_Vector3& GetEulerAngles() { return m_eulerAngles; }
- MT_Vector3& GetScaling() { return m_scaling; }
-
- const MT_Point3& GetPosition() const { return m_position; }
- const MT_Vector3& GetEulerAngles() const { return m_eulerAngles; }
- const MT_Vector3& GetScaling() const { return m_scaling; }
-
- MT_Vector3& GetDeltaPosition() { return m_deltaPosition; }
- MT_Vector3& GetDeltaEulerAngles() { return m_deltaEulerAngles; }
- MT_Vector3& GetDeltaScaling() { return m_deltaScaling; }
-
- void SetPosition(const MT_Point3& pos) { m_position = pos; }
- void SetEulerAngles(const MT_Vector3& eul) { m_eulerAngles = eul; }
- void SetScaling(const MT_Vector3& scaling) { m_scaling = scaling; }
-
- void ClearDeltaStuff() {
- m_deltaPosition.setValue(0.0f, 0.0f, 0.0f);
- m_deltaEulerAngles.setValue(0.0f, 0.0f, 0.0f);
- m_deltaScaling.setValue(0.0f, 0.0f, 0.0f);
- }
-
-protected:
- MT_Point3 m_position;
- MT_Vector3 m_eulerAngles;
- MT_Vector3 m_scaling;
- MT_Vector3 m_deltaPosition;
- MT_Vector3 m_deltaEulerAngles;
- MT_Vector3 m_deltaScaling;
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp
deleted file mode 100644
index be1a4b4ef3a..00000000000
--- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp
+++ /dev/null
@@ -1,373 +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 *****
- * Scenegraph controller for ipos.
- */
-
-/** \file gameengine/Ketsji/KX_IPO_SGController.cpp
- * \ingroup ketsji
- */
-
-
-#if defined(_WIN64)
-typedef unsigned __int64 uint_ptr;
-#else
-typedef unsigned long uint_ptr;
-#endif
-
-#ifdef _MSC_VER
- /* This warning tells us about truncation of __long__ stl-generated names.
- * It can occasionally cause DevStudio to have internal compiler warnings. */
-# pragma warning(disable:4786)
-#endif
-
-#include "KX_IPO_SGController.h"
-#include "KX_ScalarInterpolator.h"
-#include "KX_GameObject.h"
-#include "PHY_IPhysicsController.h"
-#include "DNA_ipo_types.h"
-#include "BLI_math.h"
-
-// All objects should start on frame 1! Will we ever need an object to
-// start on another frame, the 1.0 should change.
-KX_IpoSGController::KX_IpoSGController()
-: m_ipo_as_force(false),
- m_ipo_add(false),
- m_ipo_local(false),
- m_modified(true),
- m_ipotime(1.0),
- m_ipo_start_initialized(false),
- m_ipo_start_euler(0.0f, 0.0f, 0.0f),
- m_ipo_euler_initialized(false)
-{
- m_game_object = NULL;
- for (int i = 0; i < KX_MAX_IPO_CHANNELS; i++)
- m_ipo_channels_active[i] = false;
-}
-
-
-void KX_IpoSGController::SetOption(int option, int value)
-{
- switch (option) {
- case SG_CONTR_IPO_IPO_AS_FORCE:
- m_ipo_as_force = (value != 0);
- m_modified = true;
- break;
- case SG_CONTR_IPO_IPO_ADD:
- m_ipo_add = (value != 0);
- m_modified = true;
- break;
- case SG_CONTR_IPO_RESET:
- if (m_ipo_start_initialized && value) {
- m_ipo_start_initialized = false;
- m_modified = true;
- }
- break;
- case SG_CONTR_IPO_LOCAL:
- if (value/* && ((SG_Node*)m_pObject)->GetSGParent() == NULL*/) {
- // only accept local Ipo if the object has no parent
- m_ipo_local = true;
- }
- else {
- m_ipo_local = false;
- }
- m_modified = true;
- break;
- default:
- ; /* just ignore the rest */
- }
-}
-
-void KX_IpoSGController::UpdateSumoReference()
-{
- if (m_game_object) {
- }
-}
-
-void KX_IpoSGController::SetGameObject(KX_GameObject *go)
-{
- m_game_object = go;
-}
-
-bool KX_IpoSGController::Update(double currentTime)
-{
- if (m_modified) {
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); i != m_interpolators.end(); ++i) {
- (*i)->Execute(m_ipotime);//currentTime);
- }
-
- SG_Spatial *ob = (SG_Spatial *)m_pObject;
-
- //initialization on the first frame of the IPO
- if (!m_ipo_start_initialized) {
- m_ipo_start_point = ob->GetLocalPosition();
- m_ipo_start_orient = ob->GetLocalOrientation();
- m_ipo_start_scale = ob->GetLocalScale();
- m_ipo_start_initialized = true;
- if (!m_ipo_euler_initialized) {
- // do it only once to avoid angle discontinuities
- m_ipo_start_orient.getEuler(m_ipo_start_euler[0], m_ipo_start_euler[1], m_ipo_start_euler[2]);
- m_ipo_euler_initialized = true;
- }
- }
-
- //modifies position?
- if (m_ipo_channels_active[OB_LOC_X] || m_ipo_channels_active[OB_LOC_Y] || m_ipo_channels_active[OB_LOC_Z] ||
- m_ipo_channels_active[OB_DLOC_X] || m_ipo_channels_active[OB_DLOC_Y] || m_ipo_channels_active[OB_DLOC_Z])
- {
- if (m_ipo_as_force == true) {
- if (m_game_object && ob && m_game_object->GetPhysicsController()) {
- MT_Vector3 vec = m_ipo_local ?
- ob->GetWorldOrientation() * m_ipo_xform.GetPosition() :
- m_ipo_xform.GetPosition();
- m_game_object->GetPhysicsController()->ApplyForce(vec, false);
- }
- }
- else {
- // Local ipo should be defined with the object position at (0,0,0)
- // Local transform is applied to the object based on initial position
- MT_Point3 newPosition(0.0f, 0.0f, 0.0f);
-
- if (!m_ipo_add)
- newPosition = ob->GetLocalPosition();
- //apply separate IPO channels if there is any data in them
- //Loc and dLoc act by themselves or are additive
- //LocX and dLocX
- if (m_ipo_channels_active[OB_LOC_X]) {
- newPosition[0] = (m_ipo_channels_active[OB_DLOC_X] ? m_ipo_xform.GetPosition()[0] + m_ipo_xform.GetDeltaPosition()[0] : m_ipo_xform.GetPosition()[0]);
- }
- else if (m_ipo_channels_active[OB_DLOC_X] && m_ipo_start_initialized) {
- newPosition[0] = (((!m_ipo_add) ? m_ipo_start_point[0] : 0.0f) + m_ipo_xform.GetDeltaPosition()[0]);
- }
- //LocY and dLocY
- if (m_ipo_channels_active[OB_LOC_Y]) {
- newPosition[1] = (m_ipo_channels_active[OB_DLOC_Y] ? m_ipo_xform.GetPosition()[1] + m_ipo_xform.GetDeltaPosition()[1] : m_ipo_xform.GetPosition()[1]);
- }
- else if (m_ipo_channels_active[OB_DLOC_Y] && m_ipo_start_initialized) {
- newPosition[1] = (((!m_ipo_add) ? m_ipo_start_point[1] : 0.0f) + m_ipo_xform.GetDeltaPosition()[1]);
- }
- //LocZ and dLocZ
- if (m_ipo_channels_active[OB_LOC_Z]) {
- newPosition[2] = (m_ipo_channels_active[OB_DLOC_Z] ? m_ipo_xform.GetPosition()[2] + m_ipo_xform.GetDeltaPosition()[2] : m_ipo_xform.GetPosition()[2]);
- }
- else if (m_ipo_channels_active[OB_DLOC_Z] && m_ipo_start_initialized) {
- newPosition[2] = (((!m_ipo_add) ? m_ipo_start_point[2] : 0.0f) + m_ipo_xform.GetDeltaPosition()[2]);
- }
- if (m_ipo_add) {
- if (m_ipo_local)
- newPosition = m_ipo_start_point + m_ipo_start_scale*(m_ipo_start_orient*newPosition);
- else
- newPosition = m_ipo_start_point + newPosition;
- }
- if (m_game_object)
- m_game_object->NodeSetLocalPosition(newPosition);
- }
- }
- //modifies orientation?
- if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z] ||
- m_ipo_channels_active[OB_DROT_X] || m_ipo_channels_active[OB_DROT_Y] || m_ipo_channels_active[OB_DROT_Z])
- {
- if (m_ipo_as_force) {
- if (m_game_object && ob) {
- m_game_object->ApplyTorque(m_ipo_local ?
- ob->GetWorldOrientation() * m_ipo_xform.GetEulerAngles() :
- m_ipo_xform.GetEulerAngles(), false);
- }
- }
- else if (m_ipo_add) {
- if (m_ipo_start_initialized) {
- double yaw = 0.0, pitch = 0.0, roll = 0.0; //delta Euler angles
-
- //RotX and dRotX
- if (m_ipo_channels_active[OB_ROT_X])
- yaw += m_ipo_xform.GetEulerAngles()[0];
- if (m_ipo_channels_active[OB_DROT_X])
- yaw += m_ipo_xform.GetDeltaEulerAngles()[0];
-
- //RotY dRotY
- if (m_ipo_channels_active[OB_ROT_Y])
- pitch += m_ipo_xform.GetEulerAngles()[1];
- if (m_ipo_channels_active[OB_DROT_Y])
- pitch += m_ipo_xform.GetDeltaEulerAngles()[1];
-
- //RotZ and dRotZ
- if (m_ipo_channels_active[OB_ROT_Z])
- roll += m_ipo_xform.GetEulerAngles()[2];
- if (m_ipo_channels_active[OB_DROT_Z])
- roll += m_ipo_xform.GetDeltaEulerAngles()[2];
-
- MT_Matrix3x3 rotation(MT_Vector3(yaw, pitch, roll));
- if (m_ipo_local)
- rotation = m_ipo_start_orient * rotation;
- else
- rotation = rotation * m_ipo_start_orient;
- if (m_game_object)
- m_game_object->NodeSetLocalOrientation(rotation);
- }
- }
- else if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z]) {
- if (m_ipo_euler_initialized) {
- // assume all channel absolute
- // All 3 channels should be specified but if they are not, we will take
- // the value at the start of the game to avoid angle sign reversal
- double yaw = m_ipo_start_euler[0], pitch = m_ipo_start_euler[1], roll = m_ipo_start_euler[2];
-
- //RotX and dRotX
- if (m_ipo_channels_active[OB_ROT_X]) {
- yaw = (m_ipo_channels_active[OB_DROT_X] ? (m_ipo_xform.GetEulerAngles()[0] + m_ipo_xform.GetDeltaEulerAngles()[0]) : m_ipo_xform.GetEulerAngles()[0] );
- }
- else if (m_ipo_channels_active[OB_DROT_X]) {
- yaw += m_ipo_xform.GetDeltaEulerAngles()[0];
- }
-
- //RotY dRotY
- if (m_ipo_channels_active[OB_ROT_Y]) {
- pitch = (m_ipo_channels_active[OB_DROT_Y] ? (m_ipo_xform.GetEulerAngles()[1] + m_ipo_xform.GetDeltaEulerAngles()[1]) : m_ipo_xform.GetEulerAngles()[1] );
- }
- else if (m_ipo_channels_active[OB_DROT_Y]) {
- pitch += m_ipo_xform.GetDeltaEulerAngles()[1];
- }
-
- //RotZ and dRotZ
- if (m_ipo_channels_active[OB_ROT_Z]) {
- roll = (m_ipo_channels_active[OB_DROT_Z] ? (m_ipo_xform.GetEulerAngles()[2] + m_ipo_xform.GetDeltaEulerAngles()[2]) : m_ipo_xform.GetEulerAngles()[2] );
- }
- else if (m_ipo_channels_active[OB_DROT_Z]) {
- roll += m_ipo_xform.GetDeltaEulerAngles()[2];
- }
- if (m_game_object)
- m_game_object->NodeSetLocalOrientation(MT_Vector3(yaw, pitch, roll));
- }
- }
- else if (m_ipo_start_initialized) {
- // only DROT, treat as Add
- double yaw = 0.0, pitch = 0.0, roll = 0.0; //delta Euler angles
-
- //dRotX
- if (m_ipo_channels_active[OB_DROT_X])
- yaw = m_ipo_xform.GetDeltaEulerAngles()[0];
-
- //dRotY
- if (m_ipo_channels_active[OB_DROT_Y])
- pitch = m_ipo_xform.GetDeltaEulerAngles()[1];
-
- //dRotZ
- if (m_ipo_channels_active[OB_DROT_Z])
- roll = m_ipo_xform.GetDeltaEulerAngles()[2];
-
- // dRot are always local
- MT_Matrix3x3 rotation(MT_Vector3(yaw, pitch, roll));
- rotation = m_ipo_start_orient * rotation;
- if (m_game_object)
- m_game_object->NodeSetLocalOrientation(rotation);
- }
- }
- //modifies scale?
- if (m_ipo_channels_active[OB_SIZE_X] || m_ipo_channels_active[OB_SIZE_Y] || m_ipo_channels_active[OB_SIZE_Z] ||
- m_ipo_channels_active[OB_DSIZE_X] || m_ipo_channels_active[OB_DSIZE_Y] || m_ipo_channels_active[OB_DSIZE_Z])
- {
- //default is no scale change
- MT_Vector3 newScale(1.0f, 1.0f, 1.0f);
- if (!m_ipo_add)
- newScale = ob->GetLocalScale();
-
- if (m_ipo_channels_active[OB_SIZE_X]) {
- newScale[0] = (m_ipo_channels_active[OB_DSIZE_X] ? (m_ipo_xform.GetScaling()[0] + m_ipo_xform.GetDeltaScaling()[0]) : m_ipo_xform.GetScaling()[0]);
- }
- else if (m_ipo_channels_active[OB_DSIZE_X] && m_ipo_start_initialized) {
- newScale[0] = (m_ipo_xform.GetDeltaScaling()[0] + ((!m_ipo_add) ? m_ipo_start_scale[0] : 0.0f));
- }
-
- //RotY dRotY
- if (m_ipo_channels_active[OB_SIZE_Y]) {
- newScale[1] = (m_ipo_channels_active[OB_DSIZE_Y] ? (m_ipo_xform.GetScaling()[1] + m_ipo_xform.GetDeltaScaling()[1]): m_ipo_xform.GetScaling()[1]);
- }
- else if (m_ipo_channels_active[OB_DSIZE_Y] && m_ipo_start_initialized) {
- newScale[1] = (m_ipo_xform.GetDeltaScaling()[1] + ((!m_ipo_add)?m_ipo_start_scale[1] : 0.0f));
- }
-
- //RotZ and dRotZ
- if (m_ipo_channels_active[OB_SIZE_Z]) {
- newScale[2] = (m_ipo_channels_active[OB_DSIZE_Z] ? (m_ipo_xform.GetScaling()[2] + m_ipo_xform.GetDeltaScaling()[2]) : m_ipo_xform.GetScaling()[2]);
- }
- else if (m_ipo_channels_active[OB_DSIZE_Z] && m_ipo_start_initialized) {
- newScale[2] = (m_ipo_xform.GetDeltaScaling()[2] + ((!m_ipo_add)?m_ipo_start_scale[2] : 1.0f));
- }
-
- if (m_ipo_add) {
- newScale = m_ipo_start_scale * newScale;
- }
- if (m_game_object)
- m_game_object->NodeSetLocalScale(newScale);
- }
- m_modified = false;
- }
- return false;
-}
-
-void KX_IpoSGController::AddInterpolator(KX_IInterpolator *interp)
-{
- m_interpolators.push_back(interp);
-}
-
-SG_Controller *KX_IpoSGController::GetReplica(SG_Node *destnode)
-{
- KX_IpoSGController *iporeplica = new KX_IpoSGController(*this);
- // clear object that ipo acts on in the replica.
- iporeplica->ClearObject();
- iporeplica->SetGameObject((KX_GameObject *)destnode->GetSGClientObject());
-
- // dirty hack, ask Gino for a better solution in the ipo implementation
- // hacken en zagen, in what we call datahiding, not written for replication :(
-
- T_InterpolatorList oldlist = m_interpolators;
- iporeplica->m_interpolators.clear();
-
- T_InterpolatorList::iterator i;
- for (i = oldlist.begin(); i != oldlist.end(); ++i) {
- KX_ScalarInterpolator *copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator *)*i));
- iporeplica->AddInterpolator(copyipo);
-
- MT_Scalar *scaal = ((KX_ScalarInterpolator *)*i)->GetTarget();
- uint_ptr orgbase = (uint_ptr)&m_ipo_xform;
- uint_ptr orgloc = (uint_ptr)scaal;
- uint_ptr offset = orgloc - orgbase;
- uint_ptr newaddrbase = (uint_ptr)&iporeplica->m_ipo_xform;
- newaddrbase += offset;
- MT_Scalar *blaptr = (MT_Scalar *) newaddrbase;
- copyipo->SetNewTarget((MT_Scalar *)blaptr);
- }
-
- return iporeplica;
-}
-
-KX_IpoSGController::~KX_IpoSGController()
-{
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); i != m_interpolators.end(); ++i) {
- delete (*i);
- }
-}
diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h
deleted file mode 100644
index 3318761bb88..00000000000
--- a/source/gameengine/Ketsji/KX_IPO_SGController.h
+++ /dev/null
@@ -1,124 +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_IPO_SGController.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_IPO_SGCONTROLLER_H__
-#define __KX_IPO_SGCONTROLLER_H__
-
-#include "SG_Controller.h"
-#include "SG_Spatial.h"
-
-#include "KX_IPOTransform.h"
-#include "KX_IInterpolator.h"
-
-#define KX_MAX_IPO_CHANNELS 19 //note- [0] is not used
-
-class KX_IpoSGController : public SG_Controller
-{
- KX_IPOTransform m_ipo_xform;
- T_InterpolatorList m_interpolators;
-
- /** Flag for each IPO channel that can be applied to a game object */
- bool m_ipo_channels_active[KX_MAX_IPO_CHANNELS];
-
- /** Interpret the ipo as a force rather than a displacement? */
- bool m_ipo_as_force;
-
- /** Add Ipo curve to current loc/rot/scale */
- bool m_ipo_add;
-
- /** Ipo must be applied in local coordinate rather than in global coordinates (used for force and Add mode)*/
- bool m_ipo_local;
-
- /** Were settings altered since the last update? */
- bool m_modified;
-
- /** Local time of this ipo.*/
- double m_ipotime;
-
- /** Location of the object when the IPO is first fired (for local transformations) */
- MT_Point3 m_ipo_start_point;
-
- /** Orientation of the object when the IPO is first fired (for local transformations) */
- MT_Matrix3x3 m_ipo_start_orient;
-
- /** Scale of the object when the IPO is first fired (for local transformations) */
- MT_Vector3 m_ipo_start_scale;
-
- /** if IPO initial position has been set for local normal IPO */
- bool m_ipo_start_initialized;
-
- /** Euler angles at the start of the game, needed for incomplete ROT Ipo curves */
- MT_Vector3 m_ipo_start_euler;
-
- /** true is m_ipo_start_euler has been initialized */
- bool m_ipo_euler_initialized;
-
- /** A reference to the original game object. */
- class KX_GameObject *m_game_object;
-
-public:
- KX_IpoSGController();
-
- virtual ~KX_IpoSGController();
-
- virtual SG_Controller *GetReplica(class SG_Node *destnode);
-
- void SetOption(int option, int value);
-
- /** Set sumo data. */
- void UpdateSumoReference();
- /** Set reference to the corresponding game object. */
- void SetGameObject(class KX_GameObject *go);
-
- void SetIPOChannelActive(int index, bool value) {
- //indexes found in makesdna\DNA_ipo_types.h
- m_ipo_channels_active[index] = value;
- }
-
- KX_IPOTransform &GetIPOTransform()
- {
- return m_ipo_xform;
- }
-
- void AddInterpolator(KX_IInterpolator *interp);
- virtual bool Update(double time);
- virtual void SetSimulatedTime(double time)
- {
- m_ipotime = time;
- m_modified = true;
- }
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IpoSGController")
-#endif
-};
-
-#endif /* __KX_IPO_SGCONTROLLER_H__ */
diff --git a/source/gameengine/Ketsji/KX_IScalarInterpolator.h b/source/gameengine/Ketsji/KX_IScalarInterpolator.h
deleted file mode 100644
index 1e822c49c6d..00000000000
--- a/source/gameengine/Ketsji/KX_IScalarInterpolator.h
+++ /dev/null
@@ -1,52 +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_IScalarInterpolator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_ISCALARINTERPOLATOR_H__
-#define __KX_ISCALARINTERPOLATOR_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class KX_IScalarInterpolator {
-public:
- virtual ~KX_IScalarInterpolator() {}
-
- virtual float GetValue(float currentTime) const = 0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IScalarInterpolator")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h
deleted file mode 100644
index 1963fc7c48f..00000000000
--- a/source/gameengine/Ketsji/KX_ISceneConverter.h
+++ /dev/null
@@ -1,103 +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_ISceneConverter.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_ISCENECONVERTER_H__
-#define __KX_ISCENECONVERTER_H__
-
-#include "STR_String.h"
-#include "EXP_Python.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-struct Scene;
-
-class KX_ISceneConverter
-{
-
-public:
- KX_ISceneConverter() {}
- virtual ~KX_ISceneConverter () {}
-
- /*
- * scenename: name of the scene to be converted,
- * if the scenename is empty, convert the 'default' scene (whatever this means)
- * destinationscene: pass an empty scene, everything goes into this
- * dictobj: python dictionary (for pythoncontrollers)
- */
- virtual void ConvertScene(
- class KX_Scene* destinationscene,
- class RAS_IRasterizer* rendertools,
- class RAS_ICanvas* canvas,
- bool libloading=false)=0;
-
- virtual void RemoveScene(class KX_Scene *scene)=0;
-
- // handle any pending merges from asynchronous loads
- virtual void MergeAsyncLoads()=0;
- virtual void FinalizeAsyncLoads() = 0;
-
- virtual void SetAlwaysUseExpandFraming(bool to_what) = 0;
-
- virtual void SetNewFileName(const STR_String& filename) = 0;
- virtual bool TryAndLoadNewFile() = 0;
-
- virtual void ResetPhysicsObjectsAnimationIpo(bool clearIpo) = 0;
-
- ///this generates ipo curves for position, rotation, allowing to use game physics in animation
- virtual void WritePhysicsObjectToAnimationIpo(int frameNumber) = 0;
- virtual void TestHandlesPhysicsObjectToAnimationIpo() = 0;
-
- ///this is for reseting the position,rotation and scale of the gameobjet that is not dynamic
- virtual void resetNoneDynamicObjectToIpo()=0;
-
- // use blender materials
- virtual void SetMaterials(bool val) =0;
- virtual bool GetMaterials()=0;
-
- // use blender glsl materials
- virtual void SetGLSLMaterials(bool val) =0;
- virtual bool GetGLSLMaterials()=0;
-
- // cache materials during conversion
- virtual void SetCacheMaterials(bool val) =0;
- virtual bool GetCacheMaterials()=0;
-
- virtual struct Scene* GetBlenderSceneForName(const STR_String& name)=0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ISceneConverter")
-#endif
-};
-
-#endif /* __KX_ISCENECONVERTER_H__ */
diff --git a/source/gameengine/Ketsji/KX_ISystem.h b/source/gameengine/Ketsji/KX_ISystem.h
deleted file mode 100644
index 4ba71f8d239..00000000000
--- a/source/gameengine/Ketsji/KX_ISystem.h
+++ /dev/null
@@ -1,63 +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_ISystem.h
- * \ingroup ketsji
- * \brief Abstract system
- */
-
-#ifndef __KX_ISYSTEM_H__
-#define __KX_ISYSTEM_H__
-
-#include <vector>
-using namespace std;
-
-#include "STR_String.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/**
- * System Abstraction, needed only for getting some timing stuff from the host.
- */
-class KX_ISystem
-{
-public:
- KX_ISystem() {};
- virtual ~KX_ISystem() {};
-
- virtual double GetTimeInSeconds()=0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ISystem")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_IpoConvert.cpp b/source/gameengine/Ketsji/KX_IpoConvert.cpp
deleted file mode 100644
index 7b00760ee7b..00000000000
--- a/source/gameengine/Ketsji/KX_IpoConvert.cpp
+++ /dev/null
@@ -1,441 +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_IpoConvert.cpp
- * \ingroup bgeconv
- */
-
-#ifdef _MSC_VER
- /* don't show stl-warnings */
-# pragma warning (disable:4786)
-#endif
-
-#include "BKE_material.h" /* give_current_material */
-
-#include "KX_GameObject.h"
-#include "KX_IpoConvert.h"
-#include "KX_IInterpolator.h"
-#include "KX_ScalarInterpolator.h"
-
-#include "KX_BlenderScalarInterpolator.h"
-#include "KX_BlenderSceneConverter.h"
-
-
-/* This little block needed for linking to Blender... */
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#endif
-
-#include "DNA_object_types.h"
-#include "DNA_action_types.h"
-#include "DNA_anim_types.h"
-#include "DNA_ipo_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_world_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_material_types.h"
-/* end of blender include block */
-
-#include "KX_IPO_SGController.h"
-#include "KX_LightIpoSGController.h"
-#include "KX_CameraIpoSGController.h"
-#include "KX_WorldIpoController.h"
-#include "KX_ObColorIpoSGController.h"
-#include "KX_MaterialIpoController.h"
-
-#include "SG_Node.h"
-
-#include "STR_HashedString.h"
-
-static BL_InterpolatorList *GetAdtList(struct bAction *for_act, KX_BlenderSceneConverter *converter)
-{
- BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_act);
-
- if (!adtList) {
- adtList = new BL_InterpolatorList(for_act);
- converter->RegisterInterpolatorList(adtList, for_act);
- }
-
- return adtList;
-}
-
-SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_BlenderSceneConverter *converter)
-{
- KX_IpoSGController* ipocontr = new KX_IpoSGController();
- ipocontr->SetGameObject(gameobj);
-
- Object* blenderobject = gameobj->GetBlenderObject();
-
- ipocontr->GetIPOTransform().SetPosition(MT_Point3(blenderobject->loc));
- ipocontr->GetIPOTransform().SetEulerAngles(MT_Vector3(blenderobject->rot));
- ipocontr->GetIPOTransform().SetScaling(MT_Vector3(blenderobject->size));
-
- const char *rotmode, *drotmode;
-
- switch (blenderobject->rotmode) {
- case ROT_MODE_AXISANGLE:
- rotmode = "rotation_axis_angle";
- drotmode = "delta_rotation_axis_angle";
- break;
- case ROT_MODE_QUAT: /* XXX, this isn't working, currently only eulers are supported [#28853] */
- rotmode = "rotation_quaternion";
- drotmode = "delta_rotation_quaternion";
- break;
- default:
- rotmode = "rotation_euler";
- drotmode = "delta_rotation_euler";
- break;
- }
-
- BL_InterpolatorList *adtList= GetAdtList(action, converter);
-
- // For each active channel in the adtList add an
- // interpolator to the game object.
-
- KX_IInterpolator *interpolator;
- KX_IScalarInterpolator *interp;
-
- for (int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("location", i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetPosition()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_LOC_X+i, true);
- }
- }
- for (int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("delta_location", i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaPosition()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DLOC_X+i, true);
- }
- }
- for (int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator(rotmode, i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetEulerAngles()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_ROT_X+i, true);
- }
- }
- for (int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator(drotmode, i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DROT_X+i, true);
- }
- }
- for (int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("scale", i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetScaling()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_SIZE_X+i, true);
- }
- }
- for (int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("delta_scale", i))) {
- interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaScaling()[i]), interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetIPOChannelActive(OB_DSIZE_X+i, true);
- }
- }
-
-
- return ipocontr;
-}
-
-
-SG_Controller *BL_CreateObColorIPO(struct bAction *action, KX_GameObject* gameobj, KX_BlenderSceneConverter *converter)
-{
- KX_ObColorIpoSGController* ipocontr_obcol=NULL;
- KX_IInterpolator *interpolator;
- KX_IScalarInterpolator *interp;
- BL_InterpolatorList *adtList= GetAdtList(action, converter);
-
- for (int i=0; i<4; i++) {
- if ((interp = adtList->GetScalarInterpolator("color", i))) {
- if (!ipocontr_obcol) {
- ipocontr_obcol = new KX_ObColorIpoSGController();
- }
- interpolator= new KX_ScalarInterpolator(&ipocontr_obcol->m_rgba[i], interp);
- ipocontr_obcol->AddInterpolator(interpolator);
- }
- }
-
- return ipocontr_obcol;
-}
-
-SG_Controller *BL_CreateLampIPO(struct bAction *action, KX_GameObject* lightobj, KX_BlenderSceneConverter *converter)
-{
- KX_LightIpoSGController* ipocontr = new KX_LightIpoSGController();
-
- Lamp *blenderlamp = (Lamp*)lightobj->GetBlenderObject()->data;
-
- ipocontr->m_energy = blenderlamp->energy;
- ipocontr->m_col_rgb[0] = blenderlamp->r;
- ipocontr->m_col_rgb[1] = blenderlamp->g;
- ipocontr->m_col_rgb[2] = blenderlamp->b;
- ipocontr->m_dist = blenderlamp->dist;
-
- BL_InterpolatorList *adtList= GetAdtList(action, converter);
-
- // For each active channel in the adtList add an
- // interpolator to the game object.
-
- KX_IInterpolator *interpolator;
- KX_IScalarInterpolator *interp;
-
- if ((interp= adtList->GetScalarInterpolator("energy", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_energy, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyEnergy(true);
- }
-
- if ((interp = adtList->GetScalarInterpolator("distance", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_dist, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyDist(true);
- }
-
- for (int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("color", i))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_col_rgb[i], interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyColor(true);
- }
- }
-
- return ipocontr;
-}
-
-SG_Controller *BL_CreateCameraIPO(struct bAction *action, KX_GameObject* cameraobj, KX_BlenderSceneConverter *converter)
-{
- KX_CameraIpoSGController* ipocontr = new KX_CameraIpoSGController();
-
- Camera *blendercamera = (Camera*)cameraobj->GetBlenderObject()->data;
-
- ipocontr->m_lens = blendercamera->lens;
- ipocontr->m_clipstart = blendercamera->clipsta;
- ipocontr->m_clipend = blendercamera->clipend;
-
- BL_InterpolatorList *adtList= GetAdtList(action, converter);
-
- // For each active channel in the adtList add an
- // interpolator to the game object.
-
- KX_IInterpolator *interpolator;
- KX_IScalarInterpolator *interp;
-
- if ((interp = adtList->GetScalarInterpolator("lens", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_lens, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyLens(true);
- }
-
- if ((interp = adtList->GetScalarInterpolator("clip_start", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipstart, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyClipStart(true);
- }
-
- if ((interp = adtList->GetScalarInterpolator("clip_end", 0))) {
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipend, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyClipEnd(true);
- }
-
- return ipocontr;
-}
-
-
-SG_Controller * BL_CreateWorldIPO( bAction *action, struct World *blenderworld, KX_BlenderSceneConverter *converter )
-{
- KX_WorldIpoController *ipocontr = NULL;
-
- if (blenderworld) {
- BL_InterpolatorList *adtList = GetAdtList(action, converter);
-
- // For each active channel in the adtList add an interpolator to the game object.
- KX_IInterpolator *interpolator;
- KX_IScalarInterpolator *interp;
-
- for (int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("ambient_color", i))) {
- if (!ipocontr) {
- ipocontr = new KX_WorldIpoController();
- }
- interpolator = new KX_ScalarInterpolator(&ipocontr->m_ambi_rgb[i], interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyAmbientColor(true);
- }
- }
-
- for (int i=0; i<3; i++) {
- if ((interp = adtList->GetScalarInterpolator("horizon_color", i))) {
- if (!ipocontr) {
- ipocontr = new KX_WorldIpoController();
- }
- interpolator = new KX_ScalarInterpolator(&ipocontr->m_hori_rgb[i], interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyHorizonColor(true);
- }
- }
-
- if ((interp = adtList->GetScalarInterpolator("mist_settings.start", 0))) {
- if (!ipocontr) {
- ipocontr = new KX_WorldIpoController();
- }
- interpolator = new KX_ScalarInterpolator(&ipocontr->m_mist_start, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyMistStart(true);
- }
-
- if ((interp = adtList->GetScalarInterpolator("mist_settings.depth", 0))) {
- if (!ipocontr) {
- ipocontr = new KX_WorldIpoController();
- }
- interpolator = new KX_ScalarInterpolator(&ipocontr->m_mist_dist, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyMistDist(true);
- }
-
- if ((interp = adtList->GetScalarInterpolator("mist_settings.intensity", 0))) {
- if (!ipocontr) {
- ipocontr = new KX_WorldIpoController();
- }
- interpolator = new KX_ScalarInterpolator(&ipocontr->m_mist_intensity, interp);
- ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyMistIntensity(true);
- }
-
- if (ipocontr) {
- ipocontr->m_mist_start = blenderworld->miststa;
- ipocontr->m_mist_dist = blenderworld->mistdist;
- ipocontr->m_mist_intensity = blenderworld->misi;
- ipocontr->m_hori_rgb[0] = blenderworld->horr;
- ipocontr->m_hori_rgb[1] = blenderworld->horg;
- ipocontr->m_hori_rgb[2] = blenderworld->horb;
- ipocontr->m_ambi_rgb[0] = blenderworld->ambr;
- ipocontr->m_ambi_rgb[1] = blenderworld->ambg;
- ipocontr->m_ambi_rgb[2] = blenderworld->ambb;
- }
- }
- return ipocontr;
-}
-
-SG_Controller *BL_CreateMaterialIpo(
- struct bAction *action,
- Material* blendermaterial,
- dword matname_hash,
- KX_GameObject* gameobj,
- KX_BlenderSceneConverter *converter
- )
-{
- KX_MaterialIpoController* ipocontr = NULL;
-
- BL_InterpolatorList *adtList= GetAdtList(action, converter);
- KX_IInterpolator *interpolator;
- KX_IScalarInterpolator *sinterp;
-
- // --
- for (int i=0; i<3; i++) {
- if ((sinterp = adtList->GetScalarInterpolator("diffuse_color", i))) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- }
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_rgba[i], sinterp);
- ipocontr->AddInterpolator(interpolator);
- }
- }
-
- if ((sinterp = adtList->GetScalarInterpolator("alpha", 0))) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- }
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_rgba[3], sinterp);
- ipocontr->AddInterpolator(interpolator);
- }
-
- for (int i=0; i<3; i++) {
- if ((sinterp = adtList->GetScalarInterpolator("specular_color", i))) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- }
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_specrgb[i], sinterp);
- ipocontr->AddInterpolator(interpolator);
- }
- }
-
- if ((sinterp = adtList->GetScalarInterpolator("specular_hardness", 0))) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- }
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_hard, sinterp);
- ipocontr->AddInterpolator(interpolator);
- }
-
- if ((sinterp = adtList->GetScalarInterpolator("specular_intensity", 0))) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- }
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_spec, sinterp);
- ipocontr->AddInterpolator(interpolator);
- }
-
- if ((sinterp = adtList->GetScalarInterpolator("diffuse_intensity", 0))) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- }
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_ref, sinterp);
- ipocontr->AddInterpolator(interpolator);
- }
-
- if ((sinterp = adtList->GetScalarInterpolator("emit", 0))) {
- if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController(matname_hash);
- }
- interpolator= new KX_ScalarInterpolator(&ipocontr->m_emit, sinterp);
- ipocontr->AddInterpolator(interpolator);
- }
-
- if (ipocontr) {
- ipocontr->m_rgba[0] = blendermaterial->r;
- ipocontr->m_rgba[1] = blendermaterial->g;
- ipocontr->m_rgba[2] = blendermaterial->b;
- ipocontr->m_rgba[3] = blendermaterial->alpha;
-
- ipocontr->m_specrgb[0] = blendermaterial->specr;
- ipocontr->m_specrgb[1] = blendermaterial->specg;
- ipocontr->m_specrgb[2] = blendermaterial->specb;
-
- ipocontr->m_hard = blendermaterial->har;
- ipocontr->m_spec = blendermaterial->spec;
- ipocontr->m_ref = blendermaterial->ref;
- ipocontr->m_emit = blendermaterial->emit;
- ipocontr->m_alpha = blendermaterial->alpha;
- }
-
- return ipocontr;
-}
diff --git a/source/gameengine/Ketsji/KX_IpoConvert.h b/source/gameengine/Ketsji/KX_IpoConvert.h
deleted file mode 100644
index 6db43552811..00000000000
--- a/source/gameengine/Ketsji/KX_IpoConvert.h
+++ /dev/null
@@ -1,69 +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_IpoConvert.h
- * \ingroup bgeconv
- */
-
-#ifndef __KX_IPOCONVERT_H__
-#define __KX_IPOCONVERT_H__
-
-struct Object;
-struct bAction;
-class SG_Controller;
-class KX_GameObject;
-class KX_BlenderSceneConverter;
-
-SG_Controller *BL_CreateIPO(bAction *action,
- KX_GameObject* gameobj,
- KX_BlenderSceneConverter *converter);
-
-SG_Controller *BL_CreateObColorIPO(bAction *action,
- KX_GameObject* gameobj,
- KX_BlenderSceneConverter *converter);
-
-SG_Controller *BL_CreateLampIPO(bAction *action,
- KX_GameObject* lightobj,
- KX_BlenderSceneConverter *converter);
-
-SG_Controller *BL_CreateWorldIPO(bAction *action,
- struct World *blenderworld,
- KX_BlenderSceneConverter *converter);
-
-SG_Controller *BL_CreateCameraIPO(bAction *action,
- KX_GameObject* cameraobj,
- KX_BlenderSceneConverter *converter);
-
-SG_Controller *BL_CreateMaterialIpo(
- bAction *action,
- struct Material* blendermaterial,
- dword matname_hash,
- KX_GameObject* gameobj,
- KX_BlenderSceneConverter *converter);
-
-
-#endif /* __KX_IPOCONVERT_H__ */
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
deleted file mode 100644
index d82a0fd533b..00000000000
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ /dev/null
@@ -1,2081 +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 *****
- * The engine ties all game modules together.
- */
-
-/** \file gameengine/Ketsji/KX_KetsjiEngine.cpp
- * \ingroup ketsji
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include <iostream>
-#include <stdio.h>
-
-#include "BLI_task.h"
-
-#include "KX_KetsjiEngine.h"
-
-#include "EXP_ListValue.h"
-#include "EXP_IntValue.h"
-#include "EXP_VectorValue.h"
-#include "EXP_BoolValue.h"
-#include "EXP_FloatValue.h"
-
-#include "RAS_BucketManager.h"
-#include "RAS_Rect.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_ICanvas.h"
-#include "RAS_ILightObject.h"
-#include "MT_Vector3.h"
-#include "MT_Transform.h"
-#include "SCA_IInputDevice.h"
-#include "KX_Camera.h"
-#include "KX_Dome.h"
-#include "KX_Light.h"
-#include "KX_PythonInit.h"
-#include "KX_PyConstraintBinding.h"
-#include "PHY_IPhysicsEnvironment.h"
-
-#include "NG_NetworkScene.h"
-#include "NG_NetworkDeviceInterface.h"
-
-#include "KX_WorldInfo.h"
-#include "KX_ISceneConverter.h"
-#include "KX_TimeCategoryLogger.h"
-
-#include "RAS_FramingManager.h"
-#include "DNA_world_types.h"
-#include "DNA_scene_types.h"
-
-#include "KX_NavMeshObject.h"
-
-#include "BL_Action.h" // For managing action lock.
-
-#define DEFAULT_LOGIC_TIC_RATE 60.0
-//#define DEFAULT_PHYSICS_TIC_RATE 60.0
-
-const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = {
- "Physics:", // tc_physics
- "Logic:", // tc_logic
- "Animations:", // tc_animations
- "Network:", // tc_network
- "Scenegraph:", // tc_scenegraph
- "Rasterizer:", // tc_rasterizer
- "Services:", // tc_services
- "Overhead:", // tc_overhead
- "Outside:", // tc_outside
- "GPU Latency:" // tc_latency
-};
-
-double KX_KetsjiEngine::m_ticrate = DEFAULT_LOGIC_TIC_RATE;
-int KX_KetsjiEngine::m_maxLogicFrame = 5;
-int KX_KetsjiEngine::m_maxPhysicsFrame = 5;
-double KX_KetsjiEngine::m_anim_framerate = 25.0;
-double KX_KetsjiEngine::m_suspendedtime = 0.0;
-double KX_KetsjiEngine::m_suspendeddelta = 0.0;
-double KX_KetsjiEngine::m_average_framerate = 0.0;
-bool KX_KetsjiEngine::m_restrict_anim_fps = false;
-short KX_KetsjiEngine::m_exitkey = 130; // ESC Key
-bool KX_KetsjiEngine::m_doRender = true;
-
-/**
- * Constructor of the Ketsji Engine
- */
-KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
- : m_canvas(NULL),
- m_rasterizer(NULL),
- m_kxsystem(system),
- m_sceneconverter(NULL),
- m_networkdevice(NULL),
-#ifdef WITH_PYTHON
- m_pythondictionary(NULL),
-#endif
- m_keyboarddevice(NULL),
- m_mousedevice(NULL),
-
- m_bInitialized(false),
- m_activecam(0),
- m_bFixedTime(false),
- m_useExternalClock(false),
-
- m_firstframe(true),
-
- m_frameTime(0.f),
- m_clockTime(0.f),
- m_previousClockTime(0.f),
- m_previousAnimTime(0.f),
- m_timescale(1.0f),
- m_previousRealTime(0.0f),
-
-
- m_exitcode(KX_EXIT_REQUEST_NO_REQUEST),
- m_exitstring(""),
-
- m_cameraZoom(1.0f),
-
- m_overrideCam(false),
- m_overrideCamUseOrtho(false),
- m_overrideCamNear(0.0f),
- m_overrideCamFar(0.0f),
- m_overrideCamZoom(1.0f),
-
- m_stereo(false),
- m_curreye(0),
-
- m_logger(NULL),
-
- // Set up timing info display variables
- m_show_framerate(false),
- m_show_profile(false),
- m_showProperties(false),
- m_showBackground(false),
- m_show_debug_properties(false),
- m_autoAddDebugProperties(true),
-
- m_animation_record(false),
-
- // Default behavior is to hide the cursor every frame.
- m_hideCursor(false),
-
- m_overrideFrameColor(false),
- m_overrideFrameColorR(0.0f),
- m_overrideFrameColorG(0.0f),
- m_overrideFrameColorB(0.0f),
- m_overrideFrameColorA(0.0f),
-
- m_usedome(false)
-{
- // Initialize the time logger
- m_logger = new KX_TimeCategoryLogger (25);
-
- for (int i = tc_first; i < tc_numCategories; i++)
- m_logger->AddCategory((KX_TimeCategory)i);
-
-#ifdef WITH_PYTHON
- m_pyprofiledict = PyDict_New();
-#endif
-
- m_taskscheduler = BLI_task_scheduler_create(TASK_SCHEDULER_AUTO_THREADS);
-
- BL_Action::InitLock();
-}
-
-
-
-/**
- * Destructor of the Ketsji Engine, release all memory
- */
-KX_KetsjiEngine::~KX_KetsjiEngine()
-{
- delete m_logger;
- if (m_usedome)
- delete m_dome;
-
-#ifdef WITH_PYTHON
- Py_CLEAR(m_pyprofiledict);
-#endif
-
- if (m_taskscheduler)
- BLI_task_scheduler_free(m_taskscheduler);
-
- BL_Action::EndLock();
-}
-
-
-
-void KX_KetsjiEngine::SetKeyboardDevice(SCA_IInputDevice* keyboarddevice)
-{
- MT_assert(keyboarddevice);
- m_keyboarddevice = keyboarddevice;
-}
-
-
-
-void KX_KetsjiEngine::SetMouseDevice(SCA_IInputDevice* mousedevice)
-{
- MT_assert(mousedevice);
- m_mousedevice = mousedevice;
-}
-
-
-
-void KX_KetsjiEngine::SetNetworkDevice(NG_NetworkDeviceInterface* networkdevice)
-{
- MT_assert(networkdevice);
- m_networkdevice = networkdevice;
-}
-
-
-void KX_KetsjiEngine::SetCanvas(RAS_ICanvas* canvas)
-{
- MT_assert(canvas);
- m_canvas = canvas;
-}
-
-
-
-void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer)
-{
- MT_assert(rasterizer);
- m_rasterizer = rasterizer;
-}
-
-#ifdef WITH_PYTHON
-/*
- * At the moment the bge.logic module is imported into 'pythondictionary' after this function is called.
- * if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand.
- */
-void KX_KetsjiEngine::SetPyNamespace(PyObject *pythondictionary)
-{
- MT_assert(pythondictionary);
- m_pythondictionary = pythondictionary;
-}
-
-PyObject* KX_KetsjiEngine::GetPyProfileDict()
-{
- Py_INCREF(m_pyprofiledict);
- return m_pyprofiledict;
-}
-#endif
-
-
-void KX_KetsjiEngine::SetSceneConverter(KX_ISceneConverter* sceneconverter)
-{
- MT_assert(sceneconverter);
- m_sceneconverter = 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,this, res, mode, angle, resbuf, tilt, text);
- m_usedome = true;
-}
-
-void KX_KetsjiEngine::RenderDome()
-{
- const GLint *viewport = m_canvas->GetViewPort();
-
- m_dome->SetViewPort(viewport);
-
- KX_Scene* firstscene = *m_scenes.begin();
- const RAS_FrameSettings &framesettings = firstscene->GetFramingType();
-
- m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
-
- // hiding mouse cursor each frame
- // (came back when going out of focus and then back in again)
- if (m_hideCursor)
- m_canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
-
- // clear the entire game screen with the border color
- // only once per frame
-
- m_canvas->BeginDraw();
-
- // BeginFrame() sets the actual drawing area. You can use a part of the window
- if (!BeginFrame())
- return;
-
- KX_SceneList::iterator sceneit;
- KX_Scene* scene = NULL;
-
- int n_renders=m_dome->GetNumberRenders(); // usually 4 or 6
- for (int i=0;i<n_renders;i++) {
- m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER);
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
- // for each scene, call the proceed functions
- {
- scene = *sceneit;
- KX_SetActiveScene(scene);
- KX_Camera* cam = scene->GetActiveCamera();
-
- // pass the scene's worldsettings to the rasterizer
- scene->GetWorldInfo()->UpdateWorldSettings();
-
- // shadow buffers
- if (i == 0) {
- RenderShadowBuffers(scene);
- }
- // Avoid drawing the scene with the active camera twice when its viewport is enabled
- if (cam && !cam->GetViewport())
- {
- if (scene->IsClearingZBuffer())
- m_rasterizer->ClearDepthBuffer();
-
- m_rasterizer->SetAuxilaryClientInfo(scene);
-
- // do the rendering
- m_dome->RenderDomeFrame(scene,cam, i);
- // render all the font objects for this scene
- scene->RenderFonts();
- }
-
- list<class KX_Camera*>* cameras = scene->GetCameras();
-
- // Draw the scene once for each camera with an enabled viewport
- list<KX_Camera*>::iterator it = cameras->begin();
- while (it != cameras->end()) {
- if ((*it)->GetViewport())
- {
- if (scene->IsClearingZBuffer())
- m_rasterizer->ClearDepthBuffer();
-
- m_rasterizer->SetAuxilaryClientInfo(scene);
-
- // do the rendering
- m_dome->RenderDomeFrame(scene, (*it),i);
- // render all the font objects for this scene
- scene->RenderFonts();
- }
-
- it++;
- }
- // Part of PostRenderScene()
- m_rasterizer->MotionBlur();
- scene->Render2DFilters(m_canvas);
- // no RunDrawingCallBacks
- // no FlushDebugLines
- }
- m_dome->BindImages(i);
- }
-
- m_canvas->EndFrame();//XXX do we really need that?
-
- m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
-
- if (m_overrideFrameColor) //XXX why do we want
- {
- // Do not use the framing bar color set in the Blender scenes
- m_canvas->ClearColor(
- m_overrideFrameColorR,
- m_overrideFrameColorG,
- m_overrideFrameColorB,
- m_overrideFrameColorA
- );
- }
- else
- {
- // Use the framing bar color set in the Blender scenes
- m_canvas->ClearColor(
- framesettings.BarRed(),
- framesettings.BarGreen(),
- framesettings.BarBlue(),
- 1.0
- );
- }
- m_dome->Draw();
-
- // Draw Callback for the last scene
-#ifdef WITH_PYTHON
- PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
- scene->RunDrawingCallbacks(scene->GetPostDrawCB());
-#endif
- EndFrame();
-}
-
-/**
- * Ketsji Init(), Initializes data-structures and converts data from
- * Blender into Ketsji native (realtime) format also sets up the
- * graphics context
- */
-void KX_KetsjiEngine::StartEngine(bool clearIpo)
-{
- m_clockTime = m_kxsystem->GetTimeInSeconds();
- m_frameTime = m_kxsystem->GetTimeInSeconds();
- m_previousClockTime = m_kxsystem->GetTimeInSeconds();
- m_previousRealTime = m_kxsystem->GetTimeInSeconds();
-
- m_firstframe = true;
- m_bInitialized = true;
- // there is always one scene enabled at startup
- Scene* scene = m_scenes[0]->GetBlenderScene();
- if (scene)
- {
- m_ticrate = scene->gm.ticrate ? scene->gm.ticrate : DEFAULT_LOGIC_TIC_RATE;
- m_maxLogicFrame = scene->gm.maxlogicstep ? scene->gm.maxlogicstep : 5;
- m_maxPhysicsFrame = scene->gm.maxphystep ? scene->gm.maxlogicstep : 5;
- }
- else
- {
- m_ticrate = DEFAULT_LOGIC_TIC_RATE;
- m_maxLogicFrame = 5;
- m_maxPhysicsFrame = 5;
- }
-
- if (m_animation_record)
- {
- m_sceneconverter->ResetPhysicsObjectsAnimationIpo(clearIpo);
- m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame);
- }
-}
-
-void KX_KetsjiEngine::ClearFrame()
-{
- // clear unless we're drawing overlapping stereo
- if (m_rasterizer->InterlacedStereo() &&
- m_rasterizer->GetEye() == RAS_IRasterizer::RAS_STEREO_RIGHTEYE)
- return;
-
- // clear the viewports with the background color of the first scene
- bool doclear = false;
- KX_SceneList::iterator sceneit;
- RAS_Rect clearvp, area, viewport;
-
- for (sceneit = m_scenes.begin(); sceneit != m_scenes.end(); sceneit++)
- {
- KX_Scene* scene = *sceneit;
- //const RAS_FrameSettings &framesettings = scene->GetFramingType();
- list<class KX_Camera*>* cameras = scene->GetCameras();
-
- list<KX_Camera*>::iterator it;
- for (it = cameras->begin(); it != cameras->end(); it++)
- {
- GetSceneViewport(scene, (*it), area, viewport);
-
- if (!doclear) {
- clearvp = viewport;
- doclear = true;
- }
- else {
- if (viewport.GetLeft() < clearvp.GetLeft())
- clearvp.SetLeft(viewport.GetLeft());
- if (viewport.GetBottom() < clearvp.GetBottom())
- clearvp.SetBottom(viewport.GetBottom());
- if (viewport.GetRight() > clearvp.GetRight())
- clearvp.SetRight(viewport.GetRight());
- if (viewport.GetTop() > clearvp.GetTop())
- clearvp.SetTop(viewport.GetTop());
-
- }
- }
- }
-
- if (doclear) {
- KX_Scene* firstscene = *m_scenes.begin();
- firstscene->GetWorldInfo()->UpdateBackGround();
-
- m_canvas->SetViewPort(clearvp.GetLeft(), clearvp.GetBottom(),
- clearvp.GetRight(), clearvp.GetTop());
- m_rasterizer->ClearColorBuffer();
- }
-}
-
-bool KX_KetsjiEngine::BeginFrame()
-{
- // set the area used for rendering (stereo can assign only a subset)
- m_rasterizer->SetRenderArea();
-
- if (m_canvas->BeginDraw())
- {
- ClearFrame();
-
- m_rasterizer->BeginFrame(m_kxsystem->GetTimeInSeconds());
-
- return true;
- }
-
- return false;
-}
-
-
-void KX_KetsjiEngine::EndFrame()
-{
- m_rasterizer->MotionBlur();
-
- // Show profiling info
- m_logger->StartLog(tc_overhead, m_kxsystem->GetTimeInSeconds(), true);
- if (m_show_framerate || m_show_profile || (m_show_debug_properties))
- {
- RenderDebugProperties();
- }
-
- double tottime = m_logger->GetAverage();
- if (tottime < 1e-6)
- tottime = 1e-6;
-
-#ifdef WITH_PYTHON
- for (int i = tc_first; i < tc_numCategories; ++i) {
- double time = m_logger->GetAverage((KX_TimeCategory)i);
- PyObject *val = PyTuple_New(2);
- PyTuple_SetItem(val, 0, PyFloat_FromDouble(time*1000.0));
- PyTuple_SetItem(val, 1, PyFloat_FromDouble(time/tottime * 100.0));
-
- PyDict_SetItemString(m_pyprofiledict, m_profileLabels[i], val);
- Py_DECREF(val);
- }
-#endif
-
- m_average_framerate = 1.0/tottime;
-
- // Go to next profiling measurement, time spent after this call is shown in the next frame.
- m_logger->NextMeasurement(m_kxsystem->GetTimeInSeconds());
-
- m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
- m_rasterizer->EndFrame();
- // swap backbuffer (drawing into this buffer) <-> front/visible buffer
- m_logger->StartLog(tc_latency, m_kxsystem->GetTimeInSeconds(), true);
- m_rasterizer->SwapBuffers();
- m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
-
- m_canvas->EndDraw();
-}
-
-//#include "PIL_time.h"
-//#include "LinearMath/btQuickprof.h"
-
-
-bool KX_KetsjiEngine::NextFrame()
-{
- double timestep = m_timescale / m_ticrate;
- double framestep = timestep;
- // static hidden::Clock sClock;
-
- m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(),true);
-
- //float dt = sClock.getTimeMicroseconds() * 0.000001f;
- //sClock.reset();
-
- /*
- * Clock advancement. There is basically three case:
- * - m_useExternalClock is true, the user is responsible to advance the time
- * manually using setClockTime, so here, we do not do anything.
- * - m_useExternalClock is false, m_bFixedTime is true, we advance for one
- * timestep, which already handle the time scaling parameter
- * - m_useExternalClock is false, m_bFixedTime is false, we consider how much
- * time has elapsed since last call and we scale this time by the time
- * scaling parameter. If m_timescale is 1.0 (default value), the clock
- * corresponds to the computer clock.
- *
- * Once clockTime has been computed, we will compute how many logic frames
- * will be executed before the next rendering phase (which will occur at "clockTime").
- * The game time elapsing between two logic frames (called framestep)
- * depends on several variables:
- * - ticrate
- * - max_physic_frame
- * - max_logic_frame
- * XXX The logic over computation framestep is definitively not clear (and
- * I'm not even sure it is correct). If needed frame is strictly greater
- * than max_physics_frame, we are doing a jump in game time, but keeping
- * framestep = 1 / ticrate, while if frames is greater than
- * max_logic_frame, we increase framestep.
- *
- * XXX render.fps is not considred anywhere.
- */
- if (!m_useExternalClock) {
- if (m_bFixedTime) {
- m_clockTime += timestep;
- }
- else {
- double current_time = m_kxsystem->GetTimeInSeconds();
- double dt = current_time - m_previousRealTime;
- m_previousRealTime = current_time;
- // m_clockTime += dt;
- m_clockTime += dt * m_timescale;
- }
- }
-
- double deltatime = m_clockTime - m_frameTime;
- if (deltatime<0.0)
- {
- // We got here too quickly, which means there is nothing to do, just return and don't render.
- // Not sure if this is the best fix, but it seems to stop the jumping framerate issue (#33088)
- return false;
- }
-
- // Compute the number of logic frames to do each update (fixed tic bricks)
- int frames = int(deltatime * m_ticrate / m_timescale + 1e-6);
-// if (frames>1)
-// printf("****************************************");
-// printf("dt = %f, deltatime = %f, frames = %d\n",dt, deltatime,frames);
-
-// if (!frames)
-// PIL_sleep_ms(1);
- KX_SceneList::iterator sceneit;
-
- if (frames>m_maxPhysicsFrame)
- {
-
- // printf("framedOut: %d\n",frames);
- m_frameTime+=(frames-m_maxPhysicsFrame)*timestep;
- frames = m_maxPhysicsFrame;
- }
-
-
- bool doRender = frames>0;
-
- if (frames > m_maxLogicFrame)
- {
- framestep = (frames*timestep)/m_maxLogicFrame;
- frames = m_maxLogicFrame;
- }
-
- while (frames)
- {
-
-
- m_frameTime += framestep;
-
- m_sceneconverter->MergeAsyncLoads();
-
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit)
- // for each scene, call the proceed functions
- {
- KX_Scene* scene = *sceneit;
-
- /* Suspension holds the physics and logic processing for an
- * entire scene. Objects can be suspended individually, and
- * the settings for that precede the logic and physics
- * update. */
- m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
-
- m_sceneconverter->resetNoneDynamicObjectToIpo(); // this is for none dynamic objects with ipo
-
- scene->UpdateObjectActivity();
-
- if (!scene->IsSuspended())
- {
- // if the scene was suspended recalculate the delta tu "curtime"
- m_suspendedtime = scene->getSuspendedTime();
- if (scene->getSuspendedTime()!=0.0)
- scene->setSuspendedDelta(scene->getSuspendedDelta()+m_clockTime-scene->getSuspendedTime());
- m_suspendeddelta = scene->getSuspendedDelta();
-
-
- m_logger->StartLog(tc_network, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_NETWORK);
- scene->GetNetworkScene()->proceed(m_frameTime);
-
- //m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
- //SG_SetActiveStage(SG_STAGE_NETWORK_UPDATE);
- //scene->UpdateParents(m_frameTime);
-
- m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_PHYSICS1);
- // set Python hooks for each scene
-#ifdef WITH_PYTHON
- PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
-#endif
- KX_SetActiveScene(scene);
-
- scene->GetPhysicsEnvironment()->EndFrame();
-
- // Update scenegraph after physics step. This maps physics calculations
- // into node positions.
- //m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
- //SG_SetActiveStage(SG_STAGE_PHYSICS1_UPDATE);
- //scene->UpdateParents(m_frameTime);
-
- // Process sensors, and controllers
- m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_CONTROLLER);
- scene->LogicBeginFrame(m_frameTime);
-
- // Scenegraph needs to be updated again, because Logic Controllers
- // can affect the local matrices.
- m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_CONTROLLER_UPDATE);
- scene->UpdateParents(m_frameTime);
-
- // Process actuators
-
- // Do some cleanup work for this logic frame
- m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_ACTUATOR);
- scene->LogicUpdateFrame(m_frameTime, true);
-
- scene->LogicEndFrame();
-
- // Actuators can affect the scenegraph
- m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_ACTUATOR_UPDATE);
- scene->UpdateParents(m_frameTime);
-
- // update levels of detail
- scene->UpdateObjectLods();
-
- m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_PHYSICS2);
- 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);
-
- m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_PHYSICS2_UPDATE);
- scene->UpdateParents(m_frameTime);
-
-
- if (m_animation_record)
- {
- m_sceneconverter->WritePhysicsObjectToAnimationIpo(++m_currentFrame);
- }
-
- scene->setSuspendedTime(0.0);
- } // suspended
- else
- if (scene->getSuspendedTime()==0.0)
- scene->setSuspendedTime(m_clockTime);
-
- m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true);
-
- // invalidates the shadow buffer from previous render/ImageRender because the scene has changed
- scene->SetShadowDone(false);
- }
-
- // update system devices
- m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
- if (m_keyboarddevice)
- m_keyboarddevice->NextFrame();
-
- if (m_mousedevice)
- m_mousedevice->NextFrame();
-
- if (m_networkdevice)
- m_networkdevice->NextFrame();
-
- // scene management
- ProcessScheduledScenes();
-
- frames--;
- }
-
- // Start logging time spent outside main loop
- m_logger->StartLog(tc_outside, m_kxsystem->GetTimeInSeconds(), true);
-
- return doRender && m_doRender;
-}
-
-
-
-void KX_KetsjiEngine::Render()
-{
- if (m_usedome) {
- RenderDome();
- return;
- }
- KX_Scene* firstscene = *m_scenes.begin();
- const RAS_FrameSettings &framesettings = firstscene->GetFramingType();
-
- m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_RENDER);
-
- // hiding mouse cursor each frame
- // (came back when going out of focus and then back in again)
- if (m_hideCursor)
- m_canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
-
- // clear the entire game screen with the border color
- // only once per frame
- m_canvas->BeginDraw();
- if (m_rasterizer->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) {
- m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
- if (m_overrideFrameColor)
- {
- // Do not use the framing bar color set in the Blender scenes
- m_canvas->ClearColor(
- m_overrideFrameColorR,
- m_overrideFrameColorG,
- m_overrideFrameColorB,
- m_overrideFrameColorA
- );
- }
- else
- {
- // Use the framing bar color set in the Blender scenes
- m_canvas->ClearColor(
- framesettings.BarRed(),
- framesettings.BarGreen(),
- framesettings.BarBlue(),
- 1.0
- );
- }
- // clear the -whole- viewport
- m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER);
- }
-
- m_rasterizer->SetEye(RAS_IRasterizer::RAS_STEREO_LEFTEYE);
-
- // BeginFrame() sets the actual drawing area. You can use a part of the window
- if (!BeginFrame())
- return;
-
- KX_SceneList::iterator sceneit;
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
- // for each scene, call the proceed functions
- {
- KX_Scene* scene = *sceneit;
- KX_Camera* cam = scene->GetActiveCamera();
- // pass the scene's worldsettings to the rasterizer
- scene->GetWorldInfo()->UpdateWorldSettings();
-
- // this is now done incrementally in KX_Scene::CalculateVisibleMeshes
- //scene->UpdateMeshTransformations();
-
- // shadow buffers
- RenderShadowBuffers(scene);
-
- // Avoid drawing the scene with the active camera twice when its viewport is enabled
- if (cam && !cam->GetViewport())
- {
- if (scene->IsClearingZBuffer())
- m_rasterizer->ClearDepthBuffer();
-
- m_rasterizer->SetAuxilaryClientInfo(scene);
-
- // do the rendering
- RenderFrame(scene, cam);
- }
-
- list<class KX_Camera*>* cameras = scene->GetCameras();
-
- // Draw the scene once for each camera with an enabled viewport
- list<KX_Camera*>::iterator it = cameras->begin();
- while (it != cameras->end()) {
- if ((*it)->GetViewport())
- {
- if (scene->IsClearingZBuffer())
- m_rasterizer->ClearDepthBuffer();
-
- m_rasterizer->SetAuxilaryClientInfo(scene);
-
- // do the rendering
- RenderFrame(scene, (*it));
- }
-
- it++;
- }
- PostRenderScene(scene);
- }
-
- // only one place that checks for stereo
- if (m_rasterizer->Stereo())
- {
- m_rasterizer->SetEye(RAS_IRasterizer::RAS_STEREO_RIGHTEYE);
-
- if (!BeginFrame())
- return;
-
-
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++)
- // for each scene, call the proceed functions
- {
- KX_Scene* scene = *sceneit;
- KX_Camera* cam = scene->GetActiveCamera();
-
- // pass the scene's worldsettings to the rasterizer
- scene->GetWorldInfo()->UpdateWorldSettings();
-
- if (scene->IsClearingZBuffer())
- m_rasterizer->ClearDepthBuffer();
-
- // pass the scene, for picking and raycasting (shadows)
- m_rasterizer->SetAuxilaryClientInfo(scene);
-
- // do the rendering
- //RenderFrame(scene);
- RenderFrame(scene, cam);
-
- list<class KX_Camera*>* cameras = scene->GetCameras();
-
- // Draw the scene once for each camera with an enabled viewport
- list<KX_Camera*>::iterator it = cameras->begin();
- while (it != cameras->end()) {
- if ((*it)->GetViewport())
- {
- if (scene->IsClearingZBuffer())
- m_rasterizer->ClearDepthBuffer();
-
- m_rasterizer->SetAuxilaryClientInfo(scene);
-
- // do the rendering
- RenderFrame(scene, (*it));
- }
-
- it++;
- }
- PostRenderScene(scene);
- }
- } // if (m_rasterizer->Stereo())
-
- EndFrame();
-}
-
-
-
-void KX_KetsjiEngine::RequestExit(int exitrequestmode)
-{
- m_exitcode = exitrequestmode;
-}
-
-
-
-void KX_KetsjiEngine::SetNameNextGame(const STR_String& nextgame)
-{
- m_exitstring = nextgame;
-}
-
-
-
-int KX_KetsjiEngine::GetExitCode()
-{
- // if a game actuator has set an exit code or if there are no scenes left
- if (!m_exitcode)
- {
- if (m_scenes.begin() == m_scenes.end())
- m_exitcode = KX_EXIT_REQUEST_NO_SCENES_LEFT;
- }
-
- // check if the window has been closed.
- if (!m_exitcode)
- {
- //if (!m_canvas->Check()) {
- // m_exitcode = KX_EXIT_REQUEST_OUTSIDE;
- //}
- }
-
- return m_exitcode;
-}
-
-
-
-const STR_String& KX_KetsjiEngine::GetExitString()
-{
- return m_exitstring;
-}
-
-void KX_KetsjiEngine::EnableCameraOverride(const STR_String& forscene)
-{
- m_overrideCam = true;
- m_overrideSceneName = forscene;
-}
-
-void KX_KetsjiEngine::SetCameraZoom(float camzoom)
-{
- m_cameraZoom = camzoom;
-}
-
-void KX_KetsjiEngine::SetCameraOverrideUseOrtho(bool useOrtho)
-{
- m_overrideCamUseOrtho = useOrtho;
-}
-
-void KX_KetsjiEngine::SetCameraOverrideProjectionMatrix(const MT_CmMatrix4x4& mat)
-{
- m_overrideCamProjMat = mat;
-}
-
-void KX_KetsjiEngine::SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat)
-{
- m_overrideCamViewMat = mat;
-}
-
-void KX_KetsjiEngine::SetCameraOverrideClipping(float nearfrust, float farfrust)
-{
- m_overrideCamNear = nearfrust;
- m_overrideCamFar = farfrust;
-}
-
-void KX_KetsjiEngine::SetCameraOverrideLens(float lens)
-{
- m_overrideCamLens = lens;
-}
-
-void KX_KetsjiEngine::SetCameraOverrideZoom(float camzoom)
-{
- m_overrideCamZoom = camzoom;
-}
-
-void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport)
-{
- // In this function we make sure the rasterizer settings are up-to-date.
- // We compute the viewport so that logic using this information is up-to-date.
-
- // Note we postpone computation of the projection matrix
- // so that we are using the latest camera position.
- if (cam->GetViewport()) {
- RAS_Rect userviewport;
-
- userviewport.SetLeft(cam->GetViewportLeft());
- userviewport.SetBottom(cam->GetViewportBottom());
- userviewport.SetRight(cam->GetViewportRight());
- userviewport.SetTop(cam->GetViewportTop());
-
- // Don't do bars on user specified viewport
- RAS_FrameSettings settings = scene->GetFramingType();
- if (settings.FrameType() == RAS_FrameSettings::e_frame_bars)
- settings.SetFrameType(RAS_FrameSettings::e_frame_extend);
-
- RAS_FramingManager::ComputeViewport(
- scene->GetFramingType(),
- userviewport,
- viewport
- );
-
- area = userviewport;
- }
- else if ( !m_overrideCam || (scene->GetName() != m_overrideSceneName) || m_overrideCamUseOrtho ) {
- RAS_FramingManager::ComputeViewport(
- scene->GetFramingType(),
- m_canvas->GetDisplayArea(),
- viewport
- );
-
- area = m_canvas->GetDisplayArea();
- } else {
- viewport.SetLeft(0);
- viewport.SetBottom(0);
- viewport.SetRight(int(m_canvas->GetWidth()));
- viewport.SetTop(int(m_canvas->GetHeight()));
-
- area = m_canvas->GetDisplayArea();
- }
-}
-
-void KX_KetsjiEngine::UpdateAnimations(KX_Scene *scene)
-{
- if (scene->IsSuspended()) {
- return;
- }
-
- // Handle the animations independently of the logic time step
- if (GetRestrictAnimationFPS()) {
- double anim_timestep = 1.0 / KX_GetActiveScene()->GetAnimationFPS();
- if (m_frameTime - m_previousAnimTime > anim_timestep || m_frameTime == m_previousAnimTime) {
- // Sanity/debug print to make sure we're actually going at the fps we want (should be close to anim_timestep)
- // printf("Anim fps: %f\n", 1.0/(m_frameTime - m_previousAnimTime));
- m_previousAnimTime = m_frameTime;
- for (KX_SceneList::iterator sceneit = m_scenes.begin(); sceneit != m_scenes.end(); ++sceneit)
- (*sceneit)->UpdateAnimations(m_frameTime);
- }
- }
- else
- scene->UpdateAnimations(m_frameTime);
-}
-
-void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene)
-{
- CListValue *lightlist = scene->GetLightList();
- int i, drawmode;
-
- m_rasterizer->SetAuxilaryClientInfo(scene);
-
- for (i=0; i<lightlist->GetCount(); i++) {
- KX_GameObject *gameobj = (KX_GameObject*)lightlist->GetValue(i);
-
- KX_LightObject *light = (KX_LightObject*)gameobj;
- RAS_ILightObject *raslight = light->GetLightData();
-
- raslight->Update();
-
- if (light->GetVisible() && m_rasterizer->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED &&
- raslight->HasShadowBuffer())
- {
- /* make temporary camera */
- RAS_CameraData camdata = RAS_CameraData();
- KX_Camera *cam = new KX_Camera(scene, scene->m_callbacks, camdata, true, true);
- cam->SetName("__shadow__cam__");
-
- MT_Transform camtrans;
-
- /* switch drawmode for speed */
- drawmode = m_rasterizer->GetDrawingMode();
- m_rasterizer->SetDrawingMode(RAS_IRasterizer::KX_SHADOW);
-
- /* binds framebuffer object, sets up camera .. */
- raslight->BindShadowBuffer(m_canvas, cam, camtrans);
-
- /* update scene */
- scene->CalculateVisibleMeshes(m_rasterizer, cam, raslight->GetShadowLayer());
-
- m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
- UpdateAnimations(scene);
- m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_RENDER);
-
- /* render */
- m_rasterizer->ClearDepthBuffer();
- m_rasterizer->ClearColorBuffer();
- scene->RenderBuckets(camtrans, m_rasterizer);
-
- /* unbind framebuffer object, restore drawmode, free camera */
- raslight->UnbindShadowBuffer();
- m_rasterizer->SetDrawingMode(drawmode);
- cam->Release();
- }
- }
- /* remember that we have a valid shadow buffer for that scene */
- scene->SetShadowDone(true);
-}
-
-// update graphics
-void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
-{
- bool override_camera;
- RAS_Rect viewport, area;
- float nearfrust, farfrust, focallength;
-// KX_Camera* cam = scene->GetActiveCamera();
-
- if (!cam)
- return;
-
- KX_SetActiveScene(scene);
-
-#ifdef WITH_PYTHON
- scene->RunDrawingCallbacks(scene->GetPreDrawSetupCB());
-#endif
-
- GetSceneViewport(scene, cam, area, viewport);
-
- // store the computed viewport in the scene
- scene->SetSceneViewport(viewport);
-
- // set the viewport for this frame and scene
- m_canvas->SetViewPort(viewport.GetLeft(), viewport.GetBottom(),
- viewport.GetRight(), viewport.GetTop());
-
- // see KX_BlenderMaterial::Activate
- //m_rasterizer->SetAmbient();
- m_rasterizer->DisplayFog();
-
- override_camera = m_overrideCam && (scene->GetName() == m_overrideSceneName);
- override_camera = override_camera && (cam->GetName() == "__default__cam__");
-
- if (override_camera && m_overrideCamUseOrtho) {
- m_rasterizer->SetProjectionMatrix(m_overrideCamProjMat);
- if (!cam->hasValidProjectionMatrix()) {
- // needed to get frustum planes for culling
- MT_Matrix4x4 projmat;
- projmat.setValue(m_overrideCamProjMat.getPointer());
- cam->SetProjectionMatrix(projmat);
- }
- } else if (cam->hasValidProjectionMatrix())
- {
- m_rasterizer->SetProjectionMatrix(cam->GetProjectionMatrix());
- } else
- {
- RAS_FrameFrustum frustum;
- bool orthographic = !cam->GetCameraData()->m_perspective;
- nearfrust = cam->GetCameraNear();
- farfrust = cam->GetCameraFar();
- focallength = cam->GetFocalLength();
- MT_Matrix4x4 projmat;
-
- if (override_camera) {
- nearfrust = m_overrideCamNear;
- farfrust = m_overrideCamFar;
- }
-
- float camzoom = override_camera ? m_overrideCamZoom : m_cameraZoom;
- if (orthographic) {
-
- RAS_FramingManager::ComputeOrtho(
- scene->GetFramingType(),
- area,
- viewport,
- cam->GetScale(),
- nearfrust,
- farfrust,
- cam->GetSensorFit(),
- cam->GetShiftHorizontal(),
- cam->GetShiftVertical(),
- frustum
- );
- if (!cam->GetViewport()) {
- frustum.x1 *= camzoom;
- frustum.x2 *= camzoom;
- frustum.y1 *= camzoom;
- frustum.y2 *= camzoom;
- }
- projmat = m_rasterizer->GetOrthoMatrix(
- frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar);
-
- } else {
- RAS_FramingManager::ComputeFrustum(
- scene->GetFramingType(),
- area,
- viewport,
- cam->GetLens(),
- cam->GetSensorWidth(),
- cam->GetSensorHeight(),
- cam->GetSensorFit(),
- cam->GetShiftHorizontal(),
- cam->GetShiftVertical(),
- nearfrust,
- farfrust,
- frustum
- );
-
- if (!cam->GetViewport()) {
- frustum.x1 *= camzoom;
- frustum.x2 *= camzoom;
- frustum.y1 *= camzoom;
- frustum.y2 *= camzoom;
- }
- projmat = m_rasterizer->GetFrustumMatrix(
- frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar, focallength);
- }
- cam->SetProjectionMatrix(projmat);
-
- // Otherwise the projection matrix for each eye will be the same...
- if (!orthographic && m_rasterizer->Stereo())
- cam->InvalidateProjectionMatrix();
- }
-
- MT_Transform camtrans(cam->GetWorldToCamera());
- MT_Matrix4x4 viewmat(camtrans);
-
- m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->NodeGetLocalScaling(), cam->GetCameraData()->m_perspective);
- cam->SetModelviewMatrix(viewmat);
-
- // The following actually reschedules all vertices to be
- // redrawn. There is a cache between the actual rescheduling
- // and this call though. Visibility is imparted when this call
- // runs through the individual objects.
-
- m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_CULLING);
-
- scene->CalculateVisibleMeshes(m_rasterizer,cam);
-
- m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
- UpdateAnimations(scene);
-
- m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
- SG_SetActiveStage(SG_STAGE_RENDER);
-
-#ifdef WITH_PYTHON
- PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
- // Run any pre-drawing python callbacks
- scene->RunDrawingCallbacks(scene->GetPreDrawCB());
-#endif
-
- scene->RenderBuckets(camtrans, m_rasterizer);
-
- // render all the font objects for this scene
- scene->RenderFonts();
-
- if (scene->GetPhysicsEnvironment())
- scene->GetPhysicsEnvironment()->DebugDrawWorld();
-}
-
-/*
- * To run once per scene
- */
-void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene)
-{
- KX_SetActiveScene(scene);
-
- // We need to first make sure our viewport is correct (enabling multiple viewports can mess this up)
- m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
-
- m_rasterizer->FlushDebugShapes(scene);
- scene->Render2DFilters(m_canvas);
-
-#ifdef WITH_PYTHON
- PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
- scene->RunDrawingCallbacks(scene->GetPostDrawCB());
-
- // Python draw callback can also call debug draw functions, so we have to clear debug shapes.
- m_rasterizer->FlushDebugShapes(scene);
-#endif
-}
-
-void KX_KetsjiEngine::StopEngine()
-{
- if (m_bInitialized)
- {
- m_sceneconverter->FinalizeAsyncLoads();
-
- if (m_animation_record)
- {
-// printf("TestHandlesPhysicsObjectToAnimationIpo\n");
- m_sceneconverter->TestHandlesPhysicsObjectToAnimationIpo();
- }
-
- KX_SceneList::iterator sceneit;
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++)
- {
- KX_Scene* scene = *sceneit;
- m_sceneconverter->RemoveScene(scene);
- }
- m_scenes.clear();
-
- // cleanup all the stuff
- m_rasterizer->Exit();
- }
-}
-
-// Scene Management is able to switch between scenes
-// and have several scenes running in parallel
-void KX_KetsjiEngine::AddScene(KX_Scene* scene)
-{
- m_scenes.push_back(scene);
- PostProcessScene(scene);
-}
-
-
-
-void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene)
-{
- bool override_camera = (m_overrideCam && (scene->GetName() == m_overrideSceneName));
-
- SG_SetActiveStage(SG_STAGE_SCENE);
-
- // if there is no activecamera, or the camera is being
- // overridden we need to construct a temporary camera
- if (!scene->GetActiveCamera() || override_camera)
- {
- KX_Camera* activecam = NULL;
-
- RAS_CameraData camdata = RAS_CameraData();
- if (override_camera)
- {
- camdata.m_lens = m_overrideCamLens;
- camdata.m_clipstart = m_overrideCamNear;
- camdata.m_clipend = m_overrideCamFar;
-
- camdata.m_perspective= !m_overrideCamUseOrtho;
- }
- activecam = new KX_Camera(scene,KX_Scene::m_callbacks,camdata);
- activecam->SetName("__default__cam__");
-
- // set transformation
- if (override_camera) {
- const MT_CmMatrix4x4& cammatdata = m_overrideCamViewMat;
- MT_Transform trans = MT_Transform(cammatdata.getPointer());
- MT_Transform camtrans;
- camtrans.invert(trans);
-
- activecam->NodeSetLocalPosition(camtrans.getOrigin());
- activecam->NodeSetLocalOrientation(camtrans.getBasis());
- activecam->NodeUpdateGS(0);
- } else {
- activecam->NodeSetLocalPosition(MT_Point3(0.0f, 0.0f, 0.0f));
- activecam->NodeSetLocalOrientation(MT_Vector3(0.0f, 0.0f, 0.0f));
- activecam->NodeUpdateGS(0);
- }
-
- scene->AddCamera(activecam);
- scene->SetActiveCamera(activecam);
- scene->GetObjectList()->Add(activecam->AddRef());
- scene->GetRootParentList()->Add(activecam->AddRef());
- // done with activecam
- activecam->Release();
- }
-
- scene->UpdateParents(0.0);
-}
-
-
-
-void KX_KetsjiEngine::RenderDebugProperties()
-{
- STR_String debugtxt;
- int title_xmargin = -7;
- int title_y_top_margin = 4;
- int title_y_bottom_margin = 2;
-
- int const_xindent = 4;
- int const_ysize = 14;
-
- int xcoord = 12; // mmmm, these constants were taken from blender source
- int ycoord = 17; // to 'mimic' behavior
-
- int profile_indent = 72;
-
- float tottime = m_logger->GetAverage();
- if (tottime < 1e-6f) {
- tottime = 1e-6f;
- }
-
- // Set viewport to entire canvas
- RAS_Rect viewport;
- m_canvas->SetViewPort(0, 0, int(m_canvas->GetWidth()), int(m_canvas->GetHeight()));
-
- if (m_show_framerate || m_show_profile) {
- /* Title for profiling("Profile") */
- 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,
- m_canvas->GetWidth() /* RdV, TODO ?? */,
- m_canvas->GetHeight() /* RdV, TODO ?? */);
-
- // Increase the indent by default increase
- ycoord += const_ysize;
- // Add the title indent afterwards
- ycoord += title_y_bottom_margin;
- }
-
- /* Framerate display */
- if (m_show_framerate) {
- m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
- "Frametime :",
- xcoord + const_xindent,
- ycoord,
- m_canvas->GetWidth() /* RdV, TODO ?? */,
- m_canvas->GetHeight() /* RdV, TODO ?? */);
-
- debugtxt.Format("%5.1fms (%.1ffps)", tottime * 1000.0f, 1.0f/tottime);
- m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
- debugtxt.ReadPtr(),
- xcoord + const_xindent + profile_indent,
- ycoord,
- m_canvas->GetWidth() /* RdV, TODO ?? */,
- m_canvas->GetHeight() /* RdV, TODO ?? */);
- // Increase the indent by default increase
- ycoord += const_ysize;
- }
-
- /* Profile display */
- if (m_show_profile) {
- for (int j = tc_first; j < tc_numCategories; j++) {
- m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
- m_profileLabels[j],
- xcoord + const_xindent,
- ycoord,
- m_canvas->GetWidth(),
- m_canvas->GetHeight());
-
- double time = m_logger->GetAverage((KX_TimeCategory)j);
-
- debugtxt.Format("%5.2fms | %d%%", (float)time*1000.f, (int)((float)time/tottime * 100.f));
- m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
- debugtxt.ReadPtr(),
- xcoord + const_xindent + profile_indent, ycoord,
- m_canvas->GetWidth(),
- m_canvas->GetHeight());
-
- m_rasterizer->RenderBox2D(xcoord + (int)(2.2f * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), (float)time/tottime);
- ycoord += const_ysize;
- }
- }
- // Add the ymargin for titles below the other section of debug info
- ycoord += title_y_top_margin;
-
- /* Property display */
- if (m_show_debug_properties) {
-
- /* Title for debugging("Debug properties") */
- 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,
- m_canvas->GetWidth() /* RdV, TODO ?? */,
- m_canvas->GetHeight() /* RdV, TODO ?? */);
-
- // Increase the indent by default increase
- ycoord += const_ysize;
- // Add the title indent afterwards
- ycoord += title_y_bottom_margin;
-
- /* Calculate amount of properties that can displayed. */
- unsigned propsAct = 0;
- unsigned propsMax = (m_canvas->GetHeight() - ycoord) / const_ysize;
-
- KX_SceneList::iterator sceneit;
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++) {
- KX_Scene* scene = *sceneit;
- /* the 'normal' debug props */
- vector<SCA_DebugProp*>& debugproplist = scene->GetDebugProperties();
-
- for (unsigned i=0; i < debugproplist.size() && propsAct < propsMax; i++)
- {
- CValue *propobj = debugproplist[i]->m_obj;
- STR_String objname = propobj->GetName();
- STR_String propname = debugproplist[i]->m_name;
- propsAct++;
- if (propname == "__state__") {
- // reserve name for object state
- KX_GameObject* gameobj = static_cast<KX_GameObject*>(propobj);
- unsigned int state = gameobj->GetState();
- debugtxt = objname + "." + propname + " = ";
- bool first = true;
- for (int statenum=1;state;state >>= 1, statenum++)
- {
- if (state & 1)
- {
- if (!first)
- {
- debugtxt += ",";
- }
- debugtxt += STR_String(statenum);
- first = false;
- }
- }
- m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
- debugtxt.ReadPtr(),
- xcoord + const_xindent,
- ycoord,
- m_canvas->GetWidth(),
- m_canvas->GetHeight());
- ycoord += const_ysize;
- }
- else {
- CValue *propval = propobj->GetProperty(propname);
- if (propval) {
- STR_String text = propval->GetText();
- debugtxt = objname + ": '" + propname + "' = " + text;
- m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED,
- debugtxt.ReadPtr(),
- xcoord + const_xindent,
- ycoord,
- m_canvas->GetWidth(),
- m_canvas->GetHeight());
- ycoord += const_ysize;
- }
- }
- }
- }
- }
-}
-
-
-KX_SceneList* KX_KetsjiEngine::CurrentScenes()
-{
- return &m_scenes;
-}
-
-
-
-KX_Scene* KX_KetsjiEngine::FindScene(const STR_String& scenename)
-{
- KX_SceneList::iterator sceneit = m_scenes.begin();
-
- // bit risky :) better to split the second clause
- while ( (sceneit != m_scenes.end())
- && ((*sceneit)->GetName() != scenename))
- {
- sceneit++;
- }
-
- return ((sceneit == m_scenes.end()) ? NULL : *sceneit);
-}
-
-
-
-void KX_KetsjiEngine::ConvertAndAddScene(const STR_String& scenename,bool overlay)
-{
- // only add scene when it doesn't exist!
- if (FindScene(scenename)) {
- printf("warning: scene %s already exists, not added!\n",scenename.ReadPtr());
- }
- else {
- if (overlay) {
- m_addingOverlayScenes.push_back(scenename);
- }
- else {
- m_addingBackgroundScenes.push_back(scenename);
- }
- }
-}
-
-
-
-
-void KX_KetsjiEngine::RemoveScene(const STR_String& scenename)
-{
- if (FindScene(scenename))
- {
- m_removingScenes.push_back(scenename);
- }
- else
- {
-// STR_String tmpname = scenename;
- std::cout << "warning: scene " << scenename << " does not exist, not removed!" << std::endl;
- }
-}
-
-
-
-void KX_KetsjiEngine::RemoveScheduledScenes()
-{
- if (m_removingScenes.size())
- {
- vector<STR_String>::iterator scenenameit;
- for (scenenameit=m_removingScenes.begin();scenenameit != m_removingScenes.end();scenenameit++)
- {
- STR_String scenename = *scenenameit;
-
- KX_SceneList::iterator sceneit;
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++)
- {
- KX_Scene* scene = *sceneit;
- if (scene->GetName()==scenename)
- {
- m_sceneconverter->RemoveScene(scene);
- m_scenes.erase(sceneit);
- break;
- }
- }
- }
- m_removingScenes.clear();
- }
-}
-
-KX_Scene* KX_KetsjiEngine::CreateScene(Scene *scene, bool libloading)
-{
- KX_Scene* tmpscene = new KX_Scene(m_keyboarddevice,
- m_mousedevice,
- m_networkdevice,
- scene->id.name+2,
- scene,
- m_canvas);
-
- m_sceneconverter->ConvertScene(tmpscene,
- m_rasterizer,
- m_canvas,
- libloading);
-
- return tmpscene;
-}
-
-KX_Scene* KX_KetsjiEngine::CreateScene(const STR_String& scenename)
-{
- Scene *scene = m_sceneconverter->GetBlenderSceneForName(scenename);
- if (!scene)
- return NULL;
- return CreateScene(scene);
-}
-
-void KX_KetsjiEngine::AddScheduledScenes()
-{
- vector<STR_String>::iterator scenenameit;
-
- if (m_addingOverlayScenes.size())
- {
- for (scenenameit = m_addingOverlayScenes.begin();
- scenenameit != m_addingOverlayScenes.end();
- scenenameit++)
- {
- STR_String scenename = *scenenameit;
- KX_Scene* tmpscene = CreateScene(scenename);
- if (tmpscene) {
- m_scenes.push_back(tmpscene);
- PostProcessScene(tmpscene);
- } else {
- printf("warning: scene %s could not be found, not added!\n",scenename.ReadPtr());
- }
- }
- m_addingOverlayScenes.clear();
- }
-
- if (m_addingBackgroundScenes.size())
- {
- for (scenenameit = m_addingBackgroundScenes.begin();
- scenenameit != m_addingBackgroundScenes.end();
- scenenameit++)
- {
- STR_String scenename = *scenenameit;
- KX_Scene* tmpscene = CreateScene(scenename);
- if (tmpscene) {
- m_scenes.insert(m_scenes.begin(),tmpscene);
- PostProcessScene(tmpscene);
- } else {
- printf("warning: scene %s could not be found, not added!\n",scenename.ReadPtr());
- }
- }
- m_addingBackgroundScenes.clear();
- }
-}
-
-
-
-bool KX_KetsjiEngine::ReplaceScene(const STR_String& oldscene,const STR_String& newscene)
-{
- // Don't allow replacement if the new scene doesn't exist.
- // Allows smarter game design (used to have no check here).
- // Note that it creates a small backward compatbility issue
- // for a game that did a replace followed by a lib load with the
- // new scene in the lib => it won't work anymore, the lib
- // must be loaded before doing the replace.
- if (m_sceneconverter->GetBlenderSceneForName(newscene) != NULL) {
- m_replace_scenes.push_back(std::make_pair(oldscene,newscene));
- return true;
- }
- return false;
-}
-
-// replace scene is not the same as removing and adding because the
-// scene must be in exact the same place (to maintain drawingorder)
-// (nzc) - should that not be done with a scene-display list? It seems
-// stupid to rely on the mem allocation order...
-void KX_KetsjiEngine::ReplaceScheduledScenes()
-{
- if (m_replace_scenes.size())
- {
- vector<pair<STR_String,STR_String> >::iterator scenenameit;
-
- for (scenenameit = m_replace_scenes.begin();
- scenenameit != m_replace_scenes.end();
- scenenameit++)
- {
- STR_String oldscenename = (*scenenameit).first;
- STR_String newscenename = (*scenenameit).second;
- int i=0;
- /* Scenes are not supposed to be included twice... I think */
- KX_SceneList::iterator sceneit;
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++) {
- KX_Scene* scene = *sceneit;
- if (scene->GetName() == oldscenename) {
- // avoid crash if the new scene doesn't exist, just do nothing
- Scene *blScene = m_sceneconverter->GetBlenderSceneForName(newscenename);
- if (blScene) {
- m_sceneconverter->RemoveScene(scene);
- KX_Scene* tmpscene = CreateScene(blScene);
- m_scenes[i]=tmpscene;
- PostProcessScene(tmpscene);
- }
- else {
- printf("warning: scene %s could not be found, not replaced!\n",newscenename.ReadPtr());
- }
- }
- i++;
- }
- }
- m_replace_scenes.clear();
- }
-}
-
-
-
-void KX_KetsjiEngine::SuspendScene(const STR_String& scenename)
-{
- KX_Scene* scene = FindScene(scenename);
- if (scene) scene->Suspend();
-}
-
-
-
-void KX_KetsjiEngine::ResumeScene(const STR_String& scenename)
-{
- KX_Scene* scene = FindScene(scenename);
- if (scene) scene->Resume();
-}
-
-
-
-void KX_KetsjiEngine::SetUseFixedTime(bool bUseFixedTime)
-{
- m_bFixedTime = bUseFixedTime;
-}
-
-void KX_KetsjiEngine::SetUseExternalClock(bool useExternalClock)
-{
- m_useExternalClock = useExternalClock;
-}
-
-void KX_KetsjiEngine::SetAnimRecordMode(bool animation_record, int startFrame)
-{
- m_animation_record = animation_record;
- if (animation_record)
- {
- // when recording physics keyframes, run at a variable (capped) frame rate (fixed time == full speed)
- m_bFixedTime = false;
- }
- m_currentFrame = startFrame;
-}
-
-int KX_KetsjiEngine::getAnimRecordFrame() const
-{
- return m_currentFrame;
-}
-
-void KX_KetsjiEngine::setAnimRecordFrame(int framenr)
-{
- m_currentFrame = framenr;
-}
-
-bool KX_KetsjiEngine::GetUseFixedTime(void) const
-{
- return m_bFixedTime;
-}
-
-bool KX_KetsjiEngine::GetUseExternalClock(void) const
-{
- return m_useExternalClock;
-}
-
-double KX_KetsjiEngine::GetSuspendedDelta()
-{
- return m_suspendeddelta;
-}
-
-double KX_KetsjiEngine::GetTicRate()
-{
- return m_ticrate;
-}
-
-void KX_KetsjiEngine::SetTicRate(double ticrate)
-{
- m_ticrate = ticrate;
-}
-
-double KX_KetsjiEngine::GetTimeScale() const
-{
- return m_timescale;
-}
-
-void KX_KetsjiEngine::SetTimeScale(double timescale)
-{
- m_timescale = timescale;
-}
-
-int KX_KetsjiEngine::GetMaxLogicFrame()
-{
- return m_maxLogicFrame;
-}
-
-void KX_KetsjiEngine::SetMaxLogicFrame(int frame)
-{
- m_maxLogicFrame = frame;
-}
-
-int KX_KetsjiEngine::GetMaxPhysicsFrame()
-{
- return m_maxPhysicsFrame;
-}
-
-void KX_KetsjiEngine::SetMaxPhysicsFrame(int frame)
-{
- m_maxPhysicsFrame = frame;
-}
-
-bool KX_KetsjiEngine::GetRestrictAnimationFPS()
-{
- return m_restrict_anim_fps;
-}
-
-void KX_KetsjiEngine::SetRestrictAnimationFPS(bool bRestrictAnimFPS)
-{
- m_restrict_anim_fps = bRestrictAnimFPS;
-}
-
-double KX_KetsjiEngine::GetAnimFrameRate()
-{
- return m_anim_framerate;
-}
-
-double KX_KetsjiEngine::GetClockTime(void) const
-{
- return m_clockTime;
-}
-
-void KX_KetsjiEngine::SetClockTime(double externalClockTime)
-{
- m_clockTime = externalClockTime;
-}
-
-double KX_KetsjiEngine::GetFrameTime(void) const
-{
- return m_frameTime;
-}
-
-double KX_KetsjiEngine::GetRealTime(void) const
-{
- return m_kxsystem->GetTimeInSeconds();
-}
-
-void KX_KetsjiEngine::SetAnimFrameRate(double framerate)
-{
- m_anim_framerate = framerate;
-}
-
-double KX_KetsjiEngine::GetAverageFrameRate()
-{
- return m_average_framerate;
-}
-
-void KX_KetsjiEngine::SetExitKey(short key)
-{
- m_exitkey = key;
-}
-
-short KX_KetsjiEngine::GetExitKey()
-{
- return m_exitkey;
-}
-
-void KX_KetsjiEngine::SetRender(bool render)
-{
- m_doRender = render;
-}
-
-bool KX_KetsjiEngine::GetRender()
-{
- return m_doRender;
-}
-
-void KX_KetsjiEngine::SetShowFramerate(bool frameRate)
-{
- m_show_framerate = frameRate;
-}
-
-bool KX_KetsjiEngine::GetShowFramerate()
-{
- return m_show_framerate;
-}
-
-void KX_KetsjiEngine::SetShowProfile(bool profile)
-{
- m_show_profile = profile;
-}
-
-bool KX_KetsjiEngine::GetShowProfile()
-{
- return m_show_profile;
-}
-
-void KX_KetsjiEngine::SetShowProperties(bool properties)
-{
- m_show_debug_properties = properties;
-}
-
-bool KX_KetsjiEngine::GetShowProperties()
-{
- return m_show_debug_properties;
-}
-
-void KX_KetsjiEngine::SetAutoAddDebugProperties(bool add)
-{
- m_autoAddDebugProperties = add;
-}
-
-bool KX_KetsjiEngine::GetAutoAddDebugProperties()
-{
- return m_autoAddDebugProperties;
-}
-
-void KX_KetsjiEngine::SetTimingDisplay(bool frameRate, bool profile, bool properties)
-{
- m_show_framerate = frameRate;
- m_show_profile = profile;
- m_show_debug_properties = properties;
-}
-
-
-
-void KX_KetsjiEngine::GetTimingDisplay(bool& frameRate, bool& profile, bool& properties) const
-{
- frameRate = m_show_framerate;
- profile = m_show_profile;
- properties = m_show_debug_properties;
-}
-
-
-
-void KX_KetsjiEngine::ProcessScheduledScenes(void)
-{
- // Check whether there will be changes to the list of scenes
- if (m_addingOverlayScenes.size() ||
- m_addingBackgroundScenes.size() ||
- m_replace_scenes.size() ||
- m_removingScenes.size()) {
-
- // Change the scene list
- ReplaceScheduledScenes();
- RemoveScheduledScenes();
- AddScheduledScenes();
- }
-}
-
-
-void KX_KetsjiEngine::SetHideCursor(bool hideCursor)
-{
- m_hideCursor = hideCursor;
-}
-
-
-bool KX_KetsjiEngine::GetHideCursor(void) const
-{
- return m_hideCursor;
-}
-
-
-void KX_KetsjiEngine::SetUseOverrideFrameColor(bool overrideFrameColor)
-{
- m_overrideFrameColor = overrideFrameColor;
-}
-
-
-bool KX_KetsjiEngine::GetUseOverrideFrameColor(void) const
-{
- return m_overrideFrameColor;
-}
-
-
-void KX_KetsjiEngine::SetOverrideFrameColor(float r, float g, float b, float a)
-{
- m_overrideFrameColorR = r;
- m_overrideFrameColorG = g;
- m_overrideFrameColorB = b;
- m_overrideFrameColorA = a;
-}
-
-
-void KX_KetsjiEngine::GetOverrideFrameColor(float& r, float& g, float& b, float& a) const
-{
- r = m_overrideFrameColorR;
- g = m_overrideFrameColorG;
- b = m_overrideFrameColorB;
- a = m_overrideFrameColorA;
-}
-
-
-void KX_KetsjiEngine::Resize()
-{
- KX_SceneList::iterator sceneit;
-
- /* extended mode needs to recalculate camera frusta when */
- KX_Scene* firstscene = *m_scenes.begin();
- const RAS_FrameSettings &framesettings = firstscene->GetFramingType();
-
- if (framesettings.FrameType() == RAS_FrameSettings::e_frame_extend) {
- for (sceneit = m_scenes.begin(); sceneit != m_scenes.end(); sceneit++) {
- KX_Camera* cam = ((KX_Scene *)*sceneit)->GetActiveCamera();
- cam->InvalidateProjectionMatrix();
- }
- }
-}
-
-
-void KX_KetsjiEngine::SetGlobalSettings(GlobalSettings* gs)
-{
- m_globalsettings.matmode = gs->matmode;
- m_globalsettings.glslflag = gs->glslflag;
-}
-
-GlobalSettings* KX_KetsjiEngine::GetGlobalSettings(void)
-{
- return &m_globalsettings;
-}
-
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h
deleted file mode 100644
index 1756214b6dd..00000000000
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.h
+++ /dev/null
@@ -1,553 +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_KetsjiEngine.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_KETSJIENGINE_H__
-#define __KX_KETSJIENGINE_H__
-
-#include "MT_CmMatrix4x4.h"
-#include "MT_Matrix4x4.h"
-#include "STR_String.h"
-#include "KX_ISystem.h"
-#include "KX_Scene.h"
-#include "EXP_Python.h"
-#include "KX_WorldInfo.h"
-#include <vector>
-
-struct TaskScheduler;
-class KX_TimeCategoryLogger;
-
-#define LEFT_EYE 1
-#define RIGHT_EYE 2
-
-enum KX_ExitRequestMode
-{
- KX_EXIT_REQUEST_NO_REQUEST = 0,
- KX_EXIT_REQUEST_QUIT_GAME,
- KX_EXIT_REQUEST_RESTART_GAME,
- KX_EXIT_REQUEST_START_OTHER_GAME,
- KX_EXIT_REQUEST_NO_SCENES_LEFT,
- KX_EXIT_REQUEST_BLENDER_ESC,
- KX_EXIT_REQUEST_OUTSIDE,
- KX_EXIT_REQUEST_MAX
-};
-
-typedef struct {
- short matmode;
- short glslflag;
-} GlobalSettings;
-
-/**
- * KX_KetsjiEngine is the core game engine class.
- */
-class KX_KetsjiEngine
-{
-
-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 KX_ISceneConverter* m_sceneconverter;
- class NG_NetworkDeviceInterface* m_networkdevice;
-#ifdef WITH_PYTHON
- /* borrowed from sys.modules["__main__"], don't manage ref's */
- PyObject* m_pythondictionary;
- PyObject* m_pyprofiledict;
-#endif
- class SCA_IInputDevice* m_keyboarddevice;
- class SCA_IInputDevice* m_mousedevice;
- class KX_Dome* m_dome; // dome stereo mode
-
- /** Lists of scenes scheduled to be removed at the end of the frame. */
- std::vector<STR_String> m_removingScenes;
- /** Lists of overley scenes scheduled to be added at the end of the frame. */
- std::vector<STR_String> m_addingOverlayScenes;
- /** Lists of background scenes scheduled to be added at the end of the frame. */
- std::vector<STR_String> m_addingBackgroundScenes;
- /** Lists of scenes scheduled to be replaced at the end of the frame. */
- std::vector<std::pair<STR_String,STR_String> > m_replace_scenes;
-
- /* The current list of scenes. */
- KX_SceneList m_scenes;
- /* State variable recording the presence of object debug info in the current scene list. */
- bool m_propertiesPresent;
-
- bool m_bInitialized;
- int m_activecam;
- bool m_bFixedTime;
- bool m_useExternalClock;
-
-
- bool m_firstframe;
- int m_currentFrame;
-
- double m_frameTime; // current logic game time
- double m_clockTime; // game time for the next rendering step
- double m_previousClockTime; // game time of the previous rendering step
- double m_previousAnimTime; //game time when the animations were last updated
- double m_remainingTime;
- double m_timescale; // time scaling parameter. if > 1.0, time goes faster than real-time. If < 1.0, times goes slower than real-time.
- double m_previousRealTime;
-
- static int m_maxLogicFrame; /* maximum number of consecutive logic frame */
- static int m_maxPhysicsFrame; /* maximum number of consecutive physics frame */
- static double m_ticrate;
- static double m_anim_framerate; /* for animation playback only - ipo and action */
-
- static bool m_restrict_anim_fps;
-
- static double m_suspendedtime;
- static double m_suspendeddelta;
-
- static short m_exitkey; /* Key used to exit the BGE */
-
- static bool m_doRender; /* whether or not the scene should be rendered after the logic frame */
-
- int m_exitcode;
- STR_String m_exitstring;
-
- float m_cameraZoom;
-
- bool m_overrideCam;
- STR_String m_overrideSceneName;
-
- bool m_overrideCamUseOrtho;
- MT_CmMatrix4x4 m_overrideCamProjMat;
- MT_CmMatrix4x4 m_overrideCamViewMat;
- float m_overrideCamNear;
- float m_overrideCamFar;
- float m_overrideCamLens;
- /// Default camera zoom.
- float m_overrideCamZoom;
-
- bool m_stereo;
- int m_curreye;
-
- /** Categories for profiling display. */
- typedef enum {
- tc_first = 0,
- tc_physics = 0,
- tc_logic,
- tc_animations,
- tc_network,
- tc_scenegraph,
- tc_rasterizer,
- tc_services, // time spent in miscelaneous activities
- tc_overhead, // profile info drawing overhead
- tc_outside, // time spent outside main loop
- tc_latency, // time spent waiting on the gpu
- tc_numCategories
- } KX_TimeCategory;
-
- /** Time logger. */
- KX_TimeCategoryLogger* m_logger;
-
- /** Labels for profiling display. */
- static const char m_profileLabels[tc_numCategories][15];
- /** Last estimated framerate */
- static double m_average_framerate;
- /** Show the framerate on the game display? */
- bool m_show_framerate;
- /** Show profiling info on the game display? */
- bool m_show_profile;
- /** Show any debug (scene) object properties on the game display? */
- bool m_showProperties;
- /** Show background behind text for readability? */
- bool m_showBackground;
- /** Show debug properties on the game display*/
- bool m_show_debug_properties;
- /** Automatic add debug properties to the debug list*/
- bool m_autoAddDebugProperties;
-
- /** record physics into keyframes */
- bool m_animation_record;
-
- /** Hide cursor every frame? */
- bool m_hideCursor;
-
- /** Override framing bars color? */
- bool m_overrideFrameColor;
- /** Red component of framing bar color. */
- float m_overrideFrameColorR;
- /** Green component of framing bar color. */
- float m_overrideFrameColorG;
- /** Blue component of framing bar color. */
- float m_overrideFrameColorB;
- /** alpha component of framing bar color. */
- float m_overrideFrameColorA;
-
- /** Settings that doesn't go away with Game Actuator */
- GlobalSettings m_globalsettings;
-
- /** Task scheduler for multi-threading */
- TaskScheduler* m_taskscheduler;
-
- void RenderFrame(KX_Scene* scene, KX_Camera* cam);
- void PostRenderScene(KX_Scene* scene);
- void RenderDebugProperties();
-
-public:
- KX_KetsjiEngine(class KX_ISystem* system);
- virtual ~KX_KetsjiEngine();
-
- // set the devices and stuff. the client must take care of creating these
- void SetKeyboardDevice(SCA_IInputDevice* keyboarddevice);
- void SetMouseDevice(SCA_IInputDevice* mousedevice);
- void SetNetworkDevice(NG_NetworkDeviceInterface* networkdevice);
- void SetCanvas(RAS_ICanvas* canvas);
- void SetRasterizer(RAS_IRasterizer* rasterizer);
-#ifdef WITH_PYTHON
- void SetPyNamespace(PyObject *pythondictionary);
- PyObject* GetPyNamespace() { return m_pythondictionary; }
- PyObject* GetPyProfileDict();
-#endif
- void SetSceneConverter(KX_ISceneConverter* sceneconverter);
- KX_ISceneConverter* GetSceneConverter() { return m_sceneconverter; }
- void SetAnimRecordMode(bool animation_record, int startFrame);
-
- int getAnimRecordFrame() const;
- void setAnimRecordFrame(int framenr);
-
- RAS_IRasterizer* GetRasterizer() { return m_rasterizer; }
- RAS_ICanvas* GetCanvas() { return m_canvas; }
- SCA_IInputDevice* GetKeyboardDevice() { return m_keyboarddevice; }
- SCA_IInputDevice* GetMouseDevice() { return m_mousedevice; }
-
- TaskScheduler* GetTaskScheduler() { return m_taskscheduler; }
-
- /// Dome functions
- void InitDome(short res, short mode, short angle, float resbuf, short tilt, struct Text* text);
- void EndDome();
- void RenderDome();
- bool m_usedome;
-
- ///returns true if an update happened to indicate -> Render
- bool NextFrame();
- void Render();
- void RenderShadowBuffers(KX_Scene *scene);
-
- void StartEngine(bool clearIpo);
- void StopEngine();
- void Export(const STR_String& filename);
-
- void RequestExit(int exitrequestmode);
- void SetNameNextGame(const STR_String& nextgame);
- int GetExitCode();
- const STR_String& GetExitString();
-
- KX_SceneList* CurrentScenes();
- KX_Scene* FindScene(const STR_String& scenename);
- void AddScene(class KX_Scene* scene);
- void ConvertAndAddScene(const STR_String& scenename,bool overlay);
-
- void RemoveScene(const STR_String& scenename);
- bool ReplaceScene(const STR_String& oldscene,const STR_String& newscene);
- void SuspendScene(const STR_String& scenename);
- void ResumeScene(const STR_String& scenename);
-
- void GetSceneViewport(KX_Scene* scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport);
-
- /// Sets zoom for camera objects, useful only with extend and scale framing mode.
- void SetCameraZoom(float camzoom);
-
- void EnableCameraOverride(const STR_String& forscene);
-
- void SetCameraOverrideUseOrtho(bool useOrtho);
- void SetCameraOverrideProjectionMatrix(const MT_CmMatrix4x4& mat);
- void SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat);
- void SetCameraOverrideClipping(float near, float far);
- void SetCameraOverrideLens(float lens);
- /// Sets zoom for default camera, = 2 in embedded mode.
- void SetCameraOverrideZoom(float camzoom);
-
- // Update animations for object in this scene
- void UpdateAnimations(KX_Scene *scene);
-
- /**
- * Sets display of all frames.
- * \param bUseFixedTime New setting for display all frames.
- */
- void SetUseFixedTime(bool bUseFixedTime);
-
- /**
- * Returns display of all frames.
- * \return Current setting for display all frames.
- */
- bool GetUseFixedTime(void) const;
-
- /**
- * Sets if the BGE relies on a external clock or its own internal clock
- */
- void SetUseExternalClock(bool bUseExternalClock);
-
- /**
- * Returns if we rely on an external clock
- * \return Current setting
- */
- bool GetUseExternalClock(void) const;
-
- /**
- * Returns next render frame game time
- */
- double GetClockTime(void) const;
-
- /**
- * Set the next render frame game time. It will impact also frame time, as
- * this one is derived from clocktime
- */
- void SetClockTime(double externalClockTime);
-
- /**
- * Returns current logic frame game time
- */
- double GetFrameTime(void) const;
-
- /**
- * Returns the real (system) time
- */
- double GetRealTime(void) const;
-
- /**
- * Returns the difference between the local time of the scene (when it
- * was running and not suspended) and the "curtime"
- */
- static double GetSuspendedDelta();
-
- /**
- * Gets the number of logic updates per second.
- */
- static double GetTicRate();
- /**
- * Sets the number of logic updates per second.
- */
- static void SetTicRate(double ticrate);
- /**
- * Gets the maximum number of logic frame before render frame
- */
- static int GetMaxLogicFrame();
- /**
- * Sets the maximum number of logic frame before render frame
- */
- static void SetMaxLogicFrame(int frame);
- /**
- * Gets the maximum number of physics frame before render frame
- */
- static int GetMaxPhysicsFrame();
- /**
- * Sets the maximum number of physics frame before render frame
- */
- static void SetMaxPhysicsFrame(int frame);
-
- /**
- * Gets whether or not to lock animation updates to the animframerate
- */
- static bool GetRestrictAnimationFPS();
-
- /**
- * Sets whether or not to lock animation updates to the animframerate
- */
- static void SetRestrictAnimationFPS(bool bRestrictAnimFPS);
-
- /**
- * Gets the framerate for playing animations. (actions and ipos)
- */
- static double GetAnimFrameRate();
- /**
- * Sets the framerate for playing animations. (actions and ipos)
- */
- static void SetAnimFrameRate(double framerate);
-
- /**
- * Gets the last estimated average framerate
- */
- static double GetAverageFrameRate();
-
- /**
- * Gets the time scale multiplier
- */
- double GetTimeScale() const;
-
- /**
- * Sets the time scale multiplier
- */
- void SetTimeScale(double scale);
-
- static void SetExitKey(short key);
-
- static short GetExitKey();
-
- /**
- * Activate or deactivates the render of the scene after the logic frame
- * \param render true (render) or false (do not render)
- */
- static void SetRender(bool render);
- /**
- * Get the current render flag value
- */
- static bool GetRender();
-
- /**
- * \Sets the display for frame rate on or off.
- */
- void SetShowFramerate(bool frameRate);
-
- /**
- * \Gets the display for frame rate on or off.
- */
- bool GetShowFramerate();
-
- /**
- * \Sets the display for individual components on or off.
- */
- void SetShowProfile(bool profile);
-
- /**
- * \Gets the display for individual components on or off.
- */
- bool GetShowProfile();
-
- /**
- * \Sets the display of scene object debug properties on or off.
- */
- void SetShowProperties(bool properties);
-
- /**
- * \Gets the display of scene object debug properties on or off.
- */
- bool GetShowProperties();
-
- /**
- * \Sets if the auto adding of scene object debug properties on or off.
- */
- bool GetAutoAddDebugProperties();
-
- /**
- * \Sets the auto adding of scene object debug properties on or off.
- */
- void SetAutoAddDebugProperties(bool add);
-
- /**
- * Activates or deactivates timing information display.
- * \param frameRate Display for frame rate on or off.
- * \param profile Display for individual components on or off.
- * \param properties Display of scene object debug properties on or off.
- */
- void SetTimingDisplay(bool frameRate, bool profile, bool properties);
-
- /**
- * Returns status of timing information display.
- * \param frameRate Display for frame rate on or off.
- * \param profile Display for individual components on or off.
- * \param properties Display of scene object debug properties on or off.
- */
- void GetTimingDisplay(bool& frameRate, bool& profile, bool& properties) const;
-
- /**
- * Sets cursor hiding on every frame.
- * \param hideCursor Turns hiding on or off.
- */
- void SetHideCursor(bool hideCursor);
-
- /**
- * Returns the current setting for cursor hiding.
- * \return The current setting for cursor hiding.
- */
- bool GetHideCursor(void) const;
-
- /**
- * Enables/disables the use of the framing bar color of the Blender file's scenes.
- * \param overrideFrameColor The new setting.
- */
- void SetUseOverrideFrameColor(bool overrideFrameColor);
-
- /**
- * Check if the frame color is being overridden.
- */
- bool GetUseOverrideFrameColor(void) const;
-
- /**
- * Set the color used for framing bar color instead of the one in the Blender file's scenes.
- * \param r Red component of the override color.
- * \param g Green component of the override color.
- * \param b Blue component of the override color.
- */
- void SetOverrideFrameColor(float r, float g, float b, float a);
-
- /**
- * Returns the color used for framing bar color instead of the one in the Blender file's scenes.
- * \param r Red component of the override color.
- * \param g Green component of the override color.
- * \param b Blue component of the override color.
- */
- void GetOverrideFrameColor(float& r, float& g, float& b, float& a) const;
-
- KX_Scene* CreateScene(const STR_String& scenename);
- KX_Scene* CreateScene(Scene *scene, bool libloading=false);
-
- GlobalSettings* GetGlobalSettings(void);
- void SetGlobalSettings(GlobalSettings* gs);
-
- /**
- * Invalidate all the camera matrices and handle other
- * needed changes when resized.
- * It's only called from Blenderplayer.
- */
- void Resize();
-
-protected:
- /**
- * Processes all scheduled scene activity.
- * At the end, if the scene lists have changed,
- * SceneListsChanged(void) is called.
- * \see SceneListsChanged(void).
- */
- void ProcessScheduledScenes(void);
-
- /**
- * This method is invoked when the scene lists have changed.
- */
-
- void RemoveScheduledScenes(void);
- void AddScheduledScenes(void);
- void ReplaceScheduledScenes(void);
- void PostProcessScene(class KX_Scene* scene);
-
- bool BeginFrame();
- void ClearFrame();
- void EndFrame();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_KetsjiEngine")
-#endif
-};
-
-#endif /* __KX_KETSJIENGINE_H__ */
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
deleted file mode 100644
index fcdcdf4a02a..00000000000
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ /dev/null
@@ -1,479 +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_Light.cpp
- * \ingroup ketsji
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include <stdio.h>
-#include "DNA_scene_types.h"
-
-#include "KX_Light.h"
-#include "KX_Camera.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_ICanvas.h"
-#include "RAS_ILightObject.h"
-
-#include "KX_PyMath.h"
-
-#include "DNA_object_types.h"
-#include "DNA_lamp_types.h"
-
-#include "BKE_scene.h"
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-
-KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
- RAS_IRasterizer* rasterizer,
- RAS_ILightObject* lightobj,
- bool glsl)
- : KX_GameObject(sgReplicationInfo,callbacks),
- m_rasterizer(rasterizer)
-{
- m_lightobj = lightobj;
- m_lightobj->m_scene = sgReplicationInfo;
- m_lightobj->m_light = this;
- m_rasterizer->AddLight(m_lightobj);
- m_lightobj->m_glsl = glsl;
- m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene();
-};
-
-
-KX_LightObject::~KX_LightObject()
-{
- if (m_lightobj) {
- m_rasterizer->RemoveLight(m_lightobj);
- delete(m_lightobj);
- }
-}
-
-
-CValue* KX_LightObject::GetReplica()
-{
-
- KX_LightObject* replica = new KX_LightObject(*this);
-
- replica->ProcessReplica();
-
- replica->m_lightobj = m_lightobj->Clone();
- replica->m_lightobj->m_light = replica;
- m_rasterizer->AddLight(replica->m_lightobj);
-
- return replica;
-}
-
-void KX_LightObject::UpdateScene(KX_Scene *kxscene)
-{
- m_lightobj->m_scene = (void*)kxscene;
- m_blenderscene = kxscene->GetBlenderScene();
-}
-
-void KX_LightObject::SetLayer(int layer)
-{
- KX_GameObject::SetLayer(layer);
- m_lightobj->m_layer = layer;
-}
-
-#ifdef WITH_PYTHON
-/* ------------------------------------------------------------------------- */
-/* Python Integration Hooks */
-/* ------------------------------------------------------------------------- */
-
-PyTypeObject KX_LightObject::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_LightObject",
- sizeof(PyObjectPlus_Proxy),
- 0,
- py_base_dealloc,
- 0,
- 0,
- 0,
- 0,
- py_base_repr,
- 0,
- &KX_GameObject::Sequence,
- &KX_GameObject::Mapping,
- 0,0,0,
- NULL,
- NULL,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- 0,0,0,0,0,0,0,
- Methods,
- 0,
- 0,
- &KX_GameObject::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_LightObject::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_LightObject::Attributes[] = {
- KX_PYATTRIBUTE_RW_FUNCTION("layer", KX_LightObject, pyattr_get_layer, pyattr_set_layer),
- KX_PYATTRIBUTE_RW_FUNCTION("energy", KX_LightObject, pyattr_get_energy, pyattr_set_energy),
- KX_PYATTRIBUTE_RW_FUNCTION("distance", KX_LightObject, pyattr_get_distance, pyattr_set_distance),
- KX_PYATTRIBUTE_RW_FUNCTION("color", KX_LightObject, pyattr_get_color, pyattr_set_color),
- KX_PYATTRIBUTE_RW_FUNCTION("lin_attenuation", KX_LightObject, pyattr_get_lin_attenuation, pyattr_set_lin_attenuation),
- KX_PYATTRIBUTE_RW_FUNCTION("quad_attenuation", KX_LightObject, pyattr_get_quad_attenuation, pyattr_set_quad_attenuation),
- KX_PYATTRIBUTE_RW_FUNCTION("spotsize", KX_LightObject, pyattr_get_spotsize, pyattr_set_spotsize),
- KX_PYATTRIBUTE_RW_FUNCTION("spotblend", KX_LightObject, pyattr_get_spotblend, pyattr_set_spotblend),
- KX_PYATTRIBUTE_RO_FUNCTION("shadowClipStart", KX_LightObject, pyattr_get_shadow_clip_start),
- KX_PYATTRIBUTE_RO_FUNCTION("shadowClipEnd", KX_LightObject, pyattr_get_shadow_clip_end),
- KX_PYATTRIBUTE_RO_FUNCTION("shadowFrustumSize", KX_LightObject, pyattr_get_shadow_frustum_size),
- KX_PYATTRIBUTE_RO_FUNCTION("shadowBias", KX_LightObject, pyattr_get_shadow_bias),
- KX_PYATTRIBUTE_RO_FUNCTION("shadowBleedBias", KX_LightObject, pyattr_get_shadow_bleed_bias),
- KX_PYATTRIBUTE_RO_FUNCTION("shadowBindId", KX_LightObject, pyattr_get_shadow_bind_code),
- KX_PYATTRIBUTE_RO_FUNCTION("shadowMapType", KX_LightObject, pyattr_get_shadow_map_type),
- KX_PYATTRIBUTE_RO_FUNCTION("shadowColor", KX_LightObject, pyattr_get_shadow_color),
- KX_PYATTRIBUTE_RO_FUNCTION("useShadow", KX_LightObject, pyattr_get_shadow_active),
- KX_PYATTRIBUTE_RO_FUNCTION("shadowMatrix", KX_LightObject, pyattr_get_shadow_matrix),
- KX_PYATTRIBUTE_RO_FUNCTION("SPOT", KX_LightObject, pyattr_get_typeconst),
- KX_PYATTRIBUTE_RO_FUNCTION("SUN", KX_LightObject, pyattr_get_typeconst),
- KX_PYATTRIBUTE_RO_FUNCTION("NORMAL", KX_LightObject, pyattr_get_typeconst),
- KX_PYATTRIBUTE_RW_FUNCTION("type", KX_LightObject, pyattr_get_type, pyattr_set_type),
- { NULL } //Sentinel
-};
-
-PyObject *KX_LightObject::pyattr_get_layer(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyLong_FromLong(self->m_lightobj->m_layer);
-}
-
-int KX_LightObject::pyattr_set_layer(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- int layer = PyLong_AsLong(value);
-
- if (layer == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError, "expected an integer for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
-
- if (layer < 1) {
- PyErr_Format(PyExc_TypeError, "expected an integer greater than 1 for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
- else if (layer > MAX_LIGHT_LAYERS) {
- PyErr_Format(PyExc_TypeError, "expected an integer less than %i for attribute \"%s\"", MAX_LIGHT_LAYERS, attrdef->m_name);
- return PY_SET_ATTR_FAIL;
- }
-
- self->SetLayer(layer);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_LightObject::pyattr_get_energy(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_energy);
-}
-
-int KX_LightObject::pyattr_set_energy(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
-
- if (PyFloat_Check(value)) {
- float val = PyFloat_AsDouble(value);
- if (val < 0)
- val = 0;
- else if (val > 10)
- val = 10;
-
- self->m_lightobj->m_energy = val;
- return PY_SET_ATTR_SUCCESS;
- }
-
- PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_clip_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_shadowclipstart);
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_clip_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_shadowclipend);
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_frustum_size(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_shadowfrustumsize);
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_bind_code(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyLong_FromLong(self->m_lightobj->GetShadowBindCode());
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_bias(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_shadowbias);
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_bleed_bias(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_shadowbleedbias);
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_map_type(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyLong_FromLong(self->m_lightobj->m_shadowmaptype);
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyObjectFrom(self->m_lightobj->GetShadowMatrix());
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyColorFromVector(MT_Vector3(self->m_lightobj->m_shadowcolor));
-}
-
-PyObject *KX_LightObject::pyattr_get_shadow_active(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject *self = static_cast<KX_LightObject *>(self_v);
- return PyBool_FromLong(self->m_lightobj->HasShadowBuffer());
-}
-
-PyObject *KX_LightObject::pyattr_get_distance(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_distance);
-}
-
-int KX_LightObject::pyattr_set_distance(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
-
- if (PyFloat_Check(value)) {
- float val = PyFloat_AsDouble(value);
- if (val < 0.01f)
- val = 0.01f;
- else if (val > 5000.f)
- val = 5000.f;
-
- self->m_lightobj->m_distance = val;
- return PY_SET_ATTR_SUCCESS;
- }
-
- PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_LightObject::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- return Py_BuildValue("[fff]", self->m_lightobj->m_color[0], self->m_lightobj->m_color[1], self->m_lightobj->m_color[2]);
-}
-
-int KX_LightObject::pyattr_set_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
-
- MT_Vector3 color;
- if (PyVecTo(value, color))
- {
- self->m_lightobj->m_color[0] = color[0];
- self->m_lightobj->m_color[1] = color[1];
- self->m_lightobj->m_color[2] = color[2];
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_LightObject::pyattr_get_lin_attenuation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_att1);
-}
-
-int KX_LightObject::pyattr_set_lin_attenuation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
-
- if (PyFloat_Check(value)) {
- float val = PyFloat_AsDouble(value);
- if (val < 0.f)
- val = 0.f;
- else if (val > 1.f)
- val = 1.f;
-
- self->m_lightobj->m_att1 = val;
- return PY_SET_ATTR_SUCCESS;
- }
-
- PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_LightObject::pyattr_get_quad_attenuation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_att2);
-}
-
-int KX_LightObject::pyattr_set_quad_attenuation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
-
- if (PyFloat_Check(value)) {
- float val = PyFloat_AsDouble(value);
- if (val < 0.f)
- val = 0.f;
- else if (val > 1.f)
- val = 1.f;
-
- self->m_lightobj->m_att2 = val;
- return PY_SET_ATTR_SUCCESS;
- }
-
- PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_LightObject::pyattr_get_spotsize(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- return PyFloat_FromDouble(RAD2DEG(self->m_lightobj->m_spotsize));
-}
-
-int KX_LightObject::pyattr_set_spotsize(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
-
- if (PyFloat_Check(value)) {
- double val = PyFloat_AsDouble(value);
- if (val < 0.0)
- val = 0.0;
- else if (val > 180.0)
- val = 180.0;
-
- self->m_lightobj->m_spotsize = (float)DEG2RAD(val);
- return PY_SET_ATTR_SUCCESS;
- }
-
- PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
-}
-PyObject *KX_LightObject::pyattr_get_spotblend(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- return PyFloat_FromDouble(self->m_lightobj->m_spotblend);
-}
-
-int KX_LightObject::pyattr_set_spotblend(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
-
- if (PyFloat_Check(value)) {
- float val = (float)PyFloat_AsDouble(value);
- if (val < 0.f)
- val = 0.f;
- else if (val > 1.f)
- val = 1.f;
-
- self->m_lightobj->m_spotblend = val;
- return PY_SET_ATTR_SUCCESS;
- }
-
- PyErr_Format(PyExc_TypeError, "expected float value for attribute \"%s\"", attrdef->m_name);
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- PyObject *retvalue;
-
- const char* type = attrdef->m_name;
-
- if (!strcmp(type, "SPOT")) {
- retvalue = PyLong_FromLong(RAS_ILightObject::LIGHT_SPOT);
- } else if (!strcmp(type, "SUN")) {
- retvalue = PyLong_FromLong(RAS_ILightObject::LIGHT_SUN);
- } else if (!strcmp(type, "NORMAL")) {
- retvalue = PyLong_FromLong(RAS_ILightObject::LIGHT_NORMAL);
- }
- else {
- /* should never happen */
- PyErr_SetString(PyExc_TypeError, "light.type: internal error, invalid light type");
- retvalue = NULL;
- }
-
- return retvalue;
-}
-
-PyObject *KX_LightObject::pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- return PyLong_FromLong(self->m_lightobj->m_type);
-}
-
-int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
- const int val = PyLong_AsLong(value);
- if ((val==-1 && PyErr_Occurred()) || val<0 || val>2) {
- PyErr_SetString(PyExc_ValueError, "light.type= val: KX_LightObject, expected an int between 0 and 2");
- return PY_SET_ATTR_FAIL;
- }
-
- switch (val) {
- case 0:
- self->m_lightobj->m_type = self->m_lightobj->LIGHT_SPOT;
- break;
- case 1:
- self->m_lightobj->m_type = self->m_lightobj->LIGHT_SUN;
- break;
- case 2:
- self->m_lightobj->m_type = self->m_lightobj->LIGHT_NORMAL;
- break;
- }
-
- return PY_SET_ATTR_SUCCESS;
-}
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h
deleted file mode 100644
index b354fca4d41..00000000000
--- a/source/gameengine/Ketsji/KX_Light.h
+++ /dev/null
@@ -1,100 +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_Light.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_LIGHT_H__
-#define __KX_LIGHT_H__
-
-#include "KX_GameObject.h"
-
-#define MAX_LIGHT_LAYERS ((1 << 20) - 1)
-
-struct GPULamp;
-struct Scene;
-struct Base;
-class KX_Camera;
-class RAS_IRasterizer;
-class RAS_ILightObject;
-class MT_Transform;
-
-class KX_LightObject : public KX_GameObject
-{
- Py_Header
-protected:
- RAS_ILightObject* m_lightobj;
- class RAS_IRasterizer* m_rasterizer; //needed for registering and replication of lightobj
- Scene* m_blenderscene;
-
-public:
- KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,RAS_IRasterizer* rasterizer,RAS_ILightObject* lightobj, bool glsl);
- virtual ~KX_LightObject();
- virtual CValue* GetReplica();
- RAS_ILightObject* GetLightData() { return m_lightobj;}
-
- void UpdateScene(class KX_Scene *kxscene);
- virtual void SetLayer(int layer);
-
- virtual int GetGameObjectType() { return OBJ_LIGHT; }
-
-#ifdef WITH_PYTHON
- /* attributes */
- static PyObject* pyattr_get_layer(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_layer(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_energy(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_energy(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_shadow_clip_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_shadow_clip_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_shadow_frustum_size(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_shadow_bind_code(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_shadow_bias(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_shadow_bleed_bias(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_shadow_map_type(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_shadow_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_shadow_active(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_shadow_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_distance(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_distance(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_lin_attenuation(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_lin_attenuation(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_quad_attenuation(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_quad_attenuation(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_spotsize(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_spotsize(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_spotblend(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_spotblend(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_typeconst(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif
-};
-
-#endif /* __KX_LIGHT_H__ */
diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.cpp b/source/gameengine/Ketsji/KX_LightIpoSGController.cpp
deleted file mode 100644
index 6b641f7a63f..00000000000
--- a/source/gameengine/Ketsji/KX_LightIpoSGController.cpp
+++ /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 gameengine/Ketsji/KX_LightIpoSGController.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_LightIpoSGController.h"
-#include "KX_ScalarInterpolator.h"
-#include "KX_Light.h"
-#include "RAS_ILightObject.h"
-
-#if defined(_WIN64)
-typedef unsigned __int64 uint_ptr;
-#else
-typedef unsigned long uint_ptr;
-#endif
-
-bool KX_LightIpoSGController::Update(double currentTime)
-{
- if (m_modified)
- {
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- (*i)->Execute(m_ipotime);//currentTime);
- }
-
- RAS_ILightObject *lightobj;
-
- SG_Spatial* ob = (SG_Spatial*)m_pObject;
- KX_LightObject* kxlight = (KX_LightObject*) ob->GetSGClientObject();
- lightobj = kxlight->GetLightData();
- //lightobj = (KX_Light*)
-
- if (m_modify_energy) {
- lightobj->m_energy = m_energy;
- }
-
- if (m_modify_color) {
- lightobj->m_color[0] = m_col_rgb[0];
- lightobj->m_color[1] = m_col_rgb[1];
- lightobj->m_color[2] = m_col_rgb[2];
- }
-
- if (m_modify_dist) {
- lightobj->m_distance = m_dist;
- }
-
- m_modified=false;
- }
- return false;
-}
-
-
-void KX_LightIpoSGController::AddInterpolator(KX_IInterpolator* interp)
-{
- this->m_interpolators.push_back(interp);
-}
-
-SG_Controller* KX_LightIpoSGController::GetReplica(class SG_Node* destnode)
-{
- KX_LightIpoSGController* iporeplica = new KX_LightIpoSGController(*this);
- // clear object that ipo acts on
- iporeplica->ClearObject();
-
- // dirty hack, ask Gino for a better solution in the ipo implementation
- // hacken en zagen, in what we call datahiding, not written for replication :(
-
- T_InterpolatorList oldlist = m_interpolators;
- iporeplica->m_interpolators.clear();
-
- T_InterpolatorList::iterator i;
- for (i = oldlist.begin(); !(i == oldlist.end()); ++i) {
- KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i));
- iporeplica->AddInterpolator(copyipo);
-
- MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
- uint_ptr orgbase = (uint_ptr)this;
- uint_ptr orgloc = (uint_ptr)scaal;
- uint_ptr offset = orgloc-orgbase;
- uint_ptr newaddrbase = (uint_ptr)iporeplica + offset;
- MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
- copyipo->SetNewTarget((MT_Scalar*)blaptr);
- }
-
- return iporeplica;
-}
-
-KX_LightIpoSGController::~KX_LightIpoSGController()
-{
-
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- delete (*i);
- }
-
-}
diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.h b/source/gameengine/Ketsji/KX_LightIpoSGController.h
deleted file mode 100644
index 151ced6b8f8..00000000000
--- a/source/gameengine/Ketsji/KX_LightIpoSGController.h
+++ /dev/null
@@ -1,105 +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_LightIpoSGController.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_LIGHTIPOSGCONTROLLER_H__
-#define __KX_LIGHTIPOSGCONTROLLER_H__
-
-#include "SG_Controller.h"
-#include "SG_Spatial.h"
-
-#include "KX_IInterpolator.h"
-
-class RAS_ILightObject;
-
-class KX_LightIpoSGController : public SG_Controller
-{
-public:
- MT_Scalar m_energy;
- MT_Scalar m_col_rgb[3];
- MT_Scalar m_dist;
-
-private:
- T_InterpolatorList m_interpolators;
- unsigned short m_modify_energy : 1;
- unsigned short m_modify_color : 1;
- unsigned short m_modify_dist : 1;
- bool m_modified;
-
- double m_ipotime;
-public:
- KX_LightIpoSGController() :
- m_modify_energy(false),
- m_modify_color(false),
- m_modify_dist(false),
- m_modified(true),
- m_ipotime(0.0)
- {}
-
- virtual ~KX_LightIpoSGController();
-
- virtual SG_Controller* GetReplica(class SG_Node* destnode);
-
- virtual bool Update(double time);
-
- virtual void SetSimulatedTime(double time) {
- m_ipotime = time;
- m_modified = true;
- }
-
- void SetModifyEnergy(bool modify) {
- m_modify_energy = modify;
- }
-
- void SetModifyColor(bool modify) {
- m_modify_color = modify;
- }
-
- void SetModifyDist(bool modify) {
- m_modify_dist = modify;
- }
-
- void
- SetOption(
- int option,
- int value
- ) {
- // intentionally empty
- };
-
- void AddInterpolator(KX_IInterpolator* interp);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_LightIpoSGController")
-#endif
-};
-
-#endif /* __KX_LIGHTIPOSGCONTROLLER_H__ */
diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp
deleted file mode 100644
index 1faf8f17d54..00000000000
--- a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp
+++ /dev/null
@@ -1,105 +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_MaterialIpoController.cpp
- * \ingroup ketsji
- */
-
-#include "KX_MaterialIpoController.h"
-#include "KX_ScalarInterpolator.h"
-#include "KX_GameObject.h"
-
-#include "BLI_sys_types.h" // for intptr_t support
-
-bool KX_MaterialIpoController::Update(double currentTime)
-{
- if (m_modified)
- {
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- (*i)->Execute(m_ipotime);
- }
-
-
- SG_Spatial* ob = (SG_Spatial*)m_pObject;
- KX_GameObject* kxgameobj= (KX_GameObject*) ob->GetSGClientObject();
-
- //kxgameobj->SetObjectColor(m_rgba);
- kxgameobj->UpdateMaterialData(
- m_matname_hash,
- m_rgba,
- m_specrgb,
- m_hard,
- m_spec,
- m_ref,
- m_emit,
- m_alpha
- );
-
- m_modified=false;
- }
- return false;
-}
-
-
-void KX_MaterialIpoController::AddInterpolator(KX_IInterpolator* interp)
-{
- this->m_interpolators.push_back(interp);
-}
-
-SG_Controller* KX_MaterialIpoController::GetReplica(class SG_Node* destnode)
-{
- KX_MaterialIpoController* iporeplica = new KX_MaterialIpoController(*this);
- // clear object that ipo acts on
- iporeplica->ClearObject();
-
- // dirty hack, ask Gino for a better solution in the ipo implementation
- // hacken en zagen, in what we call datahiding, not written for replication :(
-
- T_InterpolatorList oldlist = m_interpolators;
- iporeplica->m_interpolators.clear();
-
- T_InterpolatorList::iterator i;
- for (i = oldlist.begin(); !(i == oldlist.end()); ++i) {
- KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i));
- iporeplica->AddInterpolator(copyipo);
-
- MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
- intptr_t orgbase = (intptr_t)this;
- intptr_t orgloc = (intptr_t)scaal;
- intptr_t offset = orgloc-orgbase;
- intptr_t newaddrbase = (intptr_t)iporeplica + offset;
- MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
- copyipo->SetNewTarget((MT_Scalar*)blaptr);
- }
-
- return iporeplica;
-}
-
-KX_MaterialIpoController::~KX_MaterialIpoController()
-{
-
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- delete (*i);
- }
-
-}
-
diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.h b/source/gameengine/Ketsji/KX_MaterialIpoController.h
deleted file mode 100644
index a7e9c2cc1c5..00000000000
--- a/source/gameengine/Ketsji/KX_MaterialIpoController.h
+++ /dev/null
@@ -1,65 +0,0 @@
-
-/** \file KX_MaterialIpoController.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_MATERIALIPOCONTROLLER_H__
-#define __KX_MATERIALIPOCONTROLLER_H__
-
-
-
-#include "SG_Controller.h"
-#include "SG_Spatial.h"
-#include "KX_IInterpolator.h"
-
-#include "STR_String.h" //typedef dword
-
-class KX_MaterialIpoController : public SG_Controller
-{
-public:
- MT_Vector4 m_rgba;
- MT_Vector3 m_specrgb;
- MT_Scalar m_hard;
- MT_Scalar m_spec;
- MT_Scalar m_ref;
- MT_Scalar m_emit;
- MT_Scalar m_alpha;
-
-private:
- T_InterpolatorList m_interpolators;
- bool m_modified;
-
- double m_ipotime;
- dword m_matname_hash;
-public:
- KX_MaterialIpoController(dword matname_hash) :
- m_modified(true),
- m_ipotime(0.0),
- m_matname_hash(matname_hash)
- {}
- virtual ~KX_MaterialIpoController();
- virtual SG_Controller* GetReplica(class SG_Node* destnode);
- virtual bool Update(double time);
- virtual void SetSimulatedTime(double time) {
- m_ipotime = time;
- m_modified = true;
- }
-
- void
- SetOption(
- int option,
- int value
- ) {
- // intentionally empty
- };
-
-
- void AddInterpolator(KX_IInterpolator* interp);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_MaterialIpoController")
-#endif
-};
-
-#endif /* __KX_MATERIALIPOCONTROLLER_H__ */
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
deleted file mode 100644
index 8da3542b4d6..00000000000
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ /dev/null
@@ -1,464 +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_MeshProxy.cpp
- * \ingroup ketsji
- */
-
-
-#ifdef WITH_PYTHON
-
-#include "KX_MeshProxy.h"
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_MeshObject.h"
-
-#include "KX_VertexProxy.h"
-#include "KX_PolyProxy.h"
-
-#include "KX_BlenderMaterial.h"
-
-#include "KX_PyMath.h"
-
-#include "SCA_LogicManager.h"
-
-#include "EXP_PyObjectPlus.h"
-
-PyTypeObject KX_MeshProxy::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_MeshProxy",
- 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,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_MeshProxy::Methods[] = {
- {"getMaterialName", (PyCFunction)KX_MeshProxy::sPyGetMaterialName,METH_VARARGS},
- {"getTextureName", (PyCFunction)KX_MeshProxy::sPyGetTextureName,METH_VARARGS},
- {"getVertexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetVertexArrayLength,METH_VARARGS},
- {"getVertex", (PyCFunction)KX_MeshProxy::sPyGetVertex,METH_VARARGS},
- {"getPolygon", (PyCFunction)KX_MeshProxy::sPyGetPolygon,METH_VARARGS},
- {"transform", (PyCFunction)KX_MeshProxy::sPyTransform,METH_VARARGS},
- {"transformUV", (PyCFunction)KX_MeshProxy::sPyTransformUV,METH_VARARGS},
- //{"getIndexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetIndexArrayLength,METH_VARARGS},
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_MeshProxy::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("materials", KX_MeshProxy, pyattr_get_materials),
- KX_PYATTRIBUTE_RO_FUNCTION("numPolygons", KX_MeshProxy, pyattr_get_numPolygons),
- KX_PYATTRIBUTE_RO_FUNCTION("numMaterials", KX_MeshProxy, pyattr_get_numMaterials),
-
- { NULL } //Sentinel
-};
-
-void KX_MeshProxy::SetMeshModified(bool v)
-{
- m_meshobj->SetMeshModified(v);
-}
-
-KX_MeshProxy::KX_MeshProxy(RAS_MeshObject* mesh)
- : CValue(), m_meshobj(mesh)
-{
-}
-
-KX_MeshProxy::~KX_MeshProxy()
-{
-}
-
-
-
-// stuff for cvalue related things
-CValue* KX_MeshProxy::Calc(VALUE_OPERATOR op, CValue *val) { return NULL;}
-CValue* KX_MeshProxy::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val) { return NULL;}
-
-const STR_String & KX_MeshProxy::GetText() {return m_meshobj->GetName();};
-double KX_MeshProxy::GetNumber() { return -1;}
-STR_String& KX_MeshProxy::GetName() { return m_meshobj->GetName();}
-void KX_MeshProxy::SetName(const char *name) { };
-CValue* KX_MeshProxy::GetReplica() { return NULL;}
-
-
-// stuff for python integration
-
-PyObject *KX_MeshProxy::PyGetMaterialName(PyObject *args, PyObject *kwds)
-{
- int matid= 1;
- STR_String matname;
-
- if (PyArg_ParseTuple(args,"i:getMaterialName",&matid))
- {
- matname = m_meshobj->GetMaterialName(matid);
- }
- else {
- return NULL;
- }
-
- return PyUnicode_From_STR_String(matname);
-
-}
-
-
-PyObject *KX_MeshProxy::PyGetTextureName(PyObject *args, PyObject *kwds)
-{
- int matid= 1;
- STR_String matname;
-
- if (PyArg_ParseTuple(args,"i:getTextureName",&matid))
- {
- matname = m_meshobj->GetTextureName(matid);
- }
- else {
- return NULL;
- }
-
- return PyUnicode_From_STR_String(matname);
-
-}
-
-PyObject *KX_MeshProxy::PyGetVertexArrayLength(PyObject *args, PyObject *kwds)
-{
- int matid= 0;
- int length = 0;
-
-
- if (!PyArg_ParseTuple(args,"i:getVertexArrayLength",&matid))
- return NULL;
-
-
- RAS_MeshMaterial *mmat = m_meshobj->GetMeshMaterial(matid); /* can be NULL*/
-
- if (mmat)
- {
- RAS_IPolyMaterial* mat = mmat->m_bucket->GetPolyMaterial();
- if (mat)
- length = m_meshobj->NumVertices(mat);
- }
-
- return PyLong_FromLong(length);
-}
-
-
-PyObject *KX_MeshProxy::PyGetVertex(PyObject *args, PyObject *kwds)
-{
- int vertexindex;
- int matindex;
-
- if (!PyArg_ParseTuple(args,"ii:getVertex",&matindex,&vertexindex))
- return NULL;
-
- RAS_TexVert* vertex = m_meshobj->GetVertex(matindex,vertexindex);
-
- if (vertex==NULL) {
- PyErr_SetString(PyExc_ValueError, "mesh.getVertex(mat_idx, vert_idx): KX_MeshProxy, could not get a vertex at the given indices");
- return NULL;
- }
-
- return (new KX_VertexProxy(this, vertex))->NewProxy(true);
-}
-
-PyObject *KX_MeshProxy::PyGetPolygon(PyObject *args, PyObject *kwds)
-{
- int polyindex= 1;
- PyObject *polyob = NULL;
-
- if (!PyArg_ParseTuple(args,"i:getPolygon",&polyindex))
- return NULL;
-
- if (polyindex<0 || polyindex >= m_meshobj->NumPolygons())
- {
- PyErr_SetString(PyExc_AttributeError, "mesh.getPolygon(int): KX_MeshProxy, invalid polygon index");
- return NULL;
- }
-
-
- RAS_Polygon* polygon = m_meshobj->GetPolygon(polyindex);
- if (polygon)
- {
- polyob = (new KX_PolyProxy(m_meshobj, polygon))->NewProxy(true);
- }
- else {
- PyErr_SetString(PyExc_AttributeError, "mesh.getPolygon(int): KX_MeshProxy, polygon is NULL, unknown reason");
- }
- return polyob;
-}
-
-PyObject *KX_MeshProxy::PyTransform(PyObject *args, PyObject *kwds)
-{
- int matindex;
- PyObject *pymat;
- bool ok = false;
-
- MT_Matrix4x4 transform;
-
- if (!PyArg_ParseTuple(args,"iO:transform", &matindex, &pymat) ||
- !PyMatTo(pymat, transform))
- {
- return NULL;
- }
-
- MT_Matrix4x4 ntransform = transform.inverse().transposed();
- ntransform[0][3] = ntransform[1][3] = ntransform[2][3] = 0.0f;
-
- /* transform mesh verts */
- unsigned int mit_index = 0;
- for (list<RAS_MeshMaterial>::iterator mit = m_meshobj->GetFirstMaterial();
- (mit != m_meshobj->GetLastMaterial());
- ++mit, ++mit_index)
- {
- if (matindex == -1) {
- /* always transform */
- }
- else if (matindex == mit_index) {
- /* we found the right index! */
- }
- else {
- continue;
- }
-
- RAS_MeshSlot *slot = mit->m_baseslot;
- RAS_MeshSlot::iterator it;
- ok = true;
-
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- size_t i;
- for (i = it.startvertex; i < it.endvertex; i++) {
- RAS_TexVert *vert = &it.vertex[i];
- vert->Transform(transform, ntransform);
- }
- }
-
- /* if we set a material index, quit when done */
- if (matindex == mit_index) {
- break;
- }
- }
-
- if (ok == false) {
- PyErr_Format(PyExc_ValueError,
- "mesh.transform(...): invalid material index %d", matindex);
- return NULL;
- }
-
- m_meshobj->SetMeshModified(true);
-
- Py_RETURN_NONE;
-}
-
-PyObject *KX_MeshProxy::PyTransformUV(PyObject *args, PyObject *kwds)
-{
- int matindex;
- PyObject *pymat;
- int uvindex = -1;
- int uvindex_from = -1;
- bool ok = false;
-
- MT_Matrix4x4 transform;
-
- if (!PyArg_ParseTuple(args,"iO|iii:transformUV", &matindex, &pymat, &uvindex, &uvindex_from) ||
- !PyMatTo(pymat, transform))
- {
- return NULL;
- }
-
- if (uvindex < -1 || uvindex > 1) {
- PyErr_Format(PyExc_ValueError,
- "mesh.transformUV(...): invalid uv_index %d", uvindex);
- return NULL;
- }
- if (uvindex_from < -1 || uvindex_from > 1) {
- PyErr_Format(PyExc_ValueError,
- "mesh.transformUV(...): invalid uv_index_from %d", uvindex);
- return NULL;
- }
- if (uvindex_from == uvindex) {
- uvindex_from = -1;
- }
-
- /* transform mesh verts */
- unsigned int mit_index = 0;
- for (list<RAS_MeshMaterial>::iterator mit = m_meshobj->GetFirstMaterial();
- (mit != m_meshobj->GetLastMaterial());
- ++mit, ++mit_index)
- {
- if (matindex == -1) {
- /* always transform */
- }
- else if (matindex == mit_index) {
- /* we found the right index! */
- }
- else {
- continue;
- }
-
- RAS_MeshSlot *slot = mit->m_baseslot;
- RAS_MeshSlot::iterator it;
- ok = true;
-
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- size_t i;
-
- for (i = it.startvertex; i < it.endvertex; i++) {
- RAS_TexVert *vert = &it.vertex[i];
- if (uvindex_from != -1) {
- if (uvindex_from == 0) vert->SetUV(1, vert->getUV(0));
- else vert->SetUV(0, vert->getUV(1));
- }
-
- switch (uvindex) {
- case 0:
- vert->TransformUV(0, transform);
- break;
- case 1:
- vert->TransformUV(1, transform);
- break;
- case -1:
- vert->TransformUV(0, transform);
- vert->TransformUV(1, transform);
- break;
- }
- }
- }
-
- /* if we set a material index, quit when done */
- if (matindex == mit_index) {
- break;
- }
- }
-
- if (ok == false) {
- PyErr_Format(PyExc_ValueError,
- "mesh.transformUV(...): invalid material index %d", matindex);
- return NULL;
- }
-
- m_meshobj->SetMeshModified(true);
-
- Py_RETURN_NONE;
-}
-
-PyObject *KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MeshProxy* self = static_cast<KX_MeshProxy*>(self_v);
-
- int tot= self->m_meshobj->NumMaterials();
- int i;
-
- PyObject *materials = PyList_New( tot );
-
- list<RAS_MeshMaterial>::iterator mit= self->m_meshobj->GetFirstMaterial();
-
-
- for (i=0; i<tot; mit++, i++) {
- RAS_IPolyMaterial *polymat = mit->m_bucket->GetPolyMaterial();
- KX_BlenderMaterial *mat = static_cast<KX_BlenderMaterial *>(polymat);
- PyList_SET_ITEM(materials, i, mat->GetProxy());
- }
- return materials;
-}
-
-PyObject *KX_MeshProxy::pyattr_get_numMaterials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MeshProxy * self = static_cast<KX_MeshProxy *> (self_v);
- return PyLong_FromLong(self->m_meshobj->NumMaterials());
-}
-
-PyObject *KX_MeshProxy::pyattr_get_numPolygons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MeshProxy * self = static_cast<KX_MeshProxy *> (self_v);
- return PyLong_FromLong(self->m_meshobj->NumPolygons());
-}
-
-/* a close copy of ConvertPythonToGameObject but for meshes */
-bool ConvertPythonToMesh(SCA_LogicManager *logicmgr, PyObject *value, RAS_MeshObject **object, bool py_none_ok, const char *error_prefix)
-{
- if (value==NULL) {
- PyErr_Format(PyExc_TypeError, "%s, python pointer NULL, should never happen", error_prefix);
- *object = NULL;
- return false;
- }
-
- if (value==Py_None) {
- *object = NULL;
-
- if (py_none_ok) {
- return true;
- } else {
- PyErr_Format(PyExc_TypeError, "%s, expected KX_MeshProxy or a KX_MeshProxy name, None is invalid", error_prefix);
- return false;
- }
- }
-
- if (PyUnicode_Check(value)) {
- *object = (RAS_MeshObject*)logicmgr->GetMeshByName(STR_String( _PyUnicode_AsString(value) ));
-
- if (*object) {
- return true;
- } else {
- PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_MeshProxy in this scene", error_prefix, _PyUnicode_AsString(value));
- return false;
- }
- }
-
- if (PyObject_TypeCheck(value, &KX_MeshProxy::Type)) {
- KX_MeshProxy *kx_mesh = static_cast<KX_MeshProxy*>BGE_PROXY_REF(value);
-
- /* sets the error */
- if (kx_mesh==NULL) {
- PyErr_Format(PyExc_SystemError, "%s, " BGE_PROXY_ERROR_MSG, error_prefix);
- return false;
- }
-
- *object = kx_mesh->GetMesh();
- return true;
- }
-
- *object = NULL;
-
- if (py_none_ok) {
- PyErr_Format(PyExc_TypeError, "%s, expect a KX_MeshProxy, a string or None", error_prefix);
- } else {
- PyErr_Format(PyExc_TypeError, "%s, expect a KX_MeshProxy or a string", error_prefix);
- }
-
- return false;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h
deleted file mode 100644
index dbd7987f785..00000000000
--- a/source/gameengine/Ketsji/KX_MeshProxy.h
+++ /dev/null
@@ -1,85 +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_MeshProxy.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_MESHPROXY_H__
-#define __KX_MESHPROXY_H__
-
-#ifdef WITH_PYTHON
-
-#include "SCA_IObject.h"
-
-class SCA_LogicManager;
-/* utility conversion function */
-bool ConvertPythonToMesh(SCA_LogicManager *logicmgr, PyObject *value, class RAS_MeshObject **object, bool py_none_ok, const char *error_prefix);
-
-class KX_MeshProxy : public CValue
-{
- Py_Header
-
- class RAS_MeshObject* m_meshobj;
-public:
- KX_MeshProxy(class RAS_MeshObject* mesh);
- virtual ~KX_MeshProxy();
-
- void SetMeshModified(bool v);
-
- // stuff for cvalue related things
- virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
- virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
- virtual const STR_String & GetText();
- virtual double GetNumber();
- virtual RAS_MeshObject* GetMesh() { return m_meshobj; }
- virtual STR_String& GetName();
- virtual void SetName(const char *name); // Set the name of the value
- virtual CValue* GetReplica();
-
-// stuff for python integration
-
- KX_PYMETHOD(KX_MeshProxy,GetNumMaterials); // Deprecated
- KX_PYMETHOD(KX_MeshProxy,GetMaterialName);
- KX_PYMETHOD(KX_MeshProxy,GetTextureName);
- KX_PYMETHOD_NOARGS(KX_MeshProxy,GetNumPolygons); // Deprecated
-
- // both take materialid (int)
- KX_PYMETHOD(KX_MeshProxy,GetVertexArrayLength);
- KX_PYMETHOD(KX_MeshProxy,GetVertex);
- KX_PYMETHOD(KX_MeshProxy,GetPolygon);
- KX_PYMETHOD(KX_MeshProxy,Transform);
- KX_PYMETHOD(KX_MeshProxy,TransformUV);
-
- static PyObject *pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_numMaterials(void *self, const KX_PYATTRIBUTE_DEF * attrdef);
- static PyObject *pyattr_get_numPolygons(void *self, const KX_PYATTRIBUTE_DEF * attrdef);
-};
-
-#endif /* WITH_PYTHON */
-
-#endif /* __KX_MESHPROXY_H__ */
diff --git a/source/gameengine/Ketsji/KX_MotionState.cpp b/source/gameengine/Ketsji/KX_MotionState.cpp
deleted file mode 100644
index 4728f71a6ea..00000000000
--- a/source/gameengine/Ketsji/KX_MotionState.cpp
+++ /dev/null
@@ -1,106 +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_MotionState.cpp
- * \ingroup ketsji
- */
-
-#include "KX_MotionState.h"
-#include "SG_Spatial.h"
-
-KX_MotionState::KX_MotionState(SG_Spatial* node) : m_node(node)
-{
-
-}
-
-KX_MotionState::~KX_MotionState()
-{
-}
-
-void KX_MotionState::GetWorldPosition(float& posX,float& posY,float& posZ)
-{
- const MT_Point3& pos = m_node->GetWorldPosition();
- posX = pos[0];
- posY = pos[1];
- posZ = pos[2];
-}
-
-void KX_MotionState::GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
-{
- const MT_Vector3& scale = m_node->GetWorldScaling();
- scaleX = scale[0];
- scaleY = scale[1];
- scaleZ = scale[2];
-}
-
-void KX_MotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
-{
- MT_Quaternion orn = m_node->GetWorldOrientation().getRotation();
- quatIma0 = orn[0];
- quatIma1 = orn[1];
- quatIma2 = orn[2];
- quatReal = orn[3];
-}
-
-void KX_MotionState::GetWorldOrientation(float* ori)
-{
- const MT_Matrix3x3& mat = m_node->GetWorldOrientation();
- mat.getValue(ori);
-}
-
-void KX_MotionState::SetWorldOrientation(const float* ori)
-{
- m_node->SetLocalOrientation(ori);
-}
-
-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)
-{
- MT_Quaternion orn;
- orn[0] = quatIma0;
- orn[1] = quatIma1;
- orn[2] = quatIma2;
- orn[3] = quatReal;
-
- m_node->SetLocalOrientation(orn);
- //m_node->SetWorldOrientation(orn);
-
-}
-
-void KX_MotionState::CalculateWorldTransformations()
-{
- //Not needed, will be done in KX_Scene::UpdateParents() after the physics simulation
- //bool parentUpdated = false;
- //m_node->ComputeWorldTransforms(NULL, parentUpdated);
-}
-
-
diff --git a/source/gameengine/Ketsji/KX_MotionState.h b/source/gameengine/Ketsji/KX_MotionState.h
deleted file mode 100644
index 38046fe4ff9..00000000000
--- a/source/gameengine/Ketsji/KX_MotionState.h
+++ /dev/null
@@ -1,65 +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_MotionState.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_MOTIONSTATE_H__
-#define __KX_MOTIONSTATE_H__
-
-#include "PHY_IMotionState.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class KX_MotionState : public PHY_IMotionState
-{
- class SG_Spatial* m_node;
-
-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 CalculateWorldTransformations();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_MotionState")
-#endif
-};
-
-#endif /* __KX_MOTIONSTATE_H__ */
diff --git a/source/gameengine/Ketsji/KX_MouseActuator.cpp b/source/gameengine/Ketsji/KX_MouseActuator.cpp
deleted file mode 100644
index 6aa0d588b50..00000000000
--- a/source/gameengine/Ketsji/KX_MouseActuator.cpp
+++ /dev/null
@@ -1,539 +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.
- *
- * Contributor(s): Geoffrey Gollmer, Jorge Bernal
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "KX_MouseActuator.h"
-#include "KX_KetsjiEngine.h"
-#include "SCA_MouseManager.h"
-#include "SCA_IInputDevice.h"
-#include "RAS_ICanvas.h"
-#include "KX_GameObject.h"
-#include "MT_Vector3.h"
-#include "MT_Scalar.h"
-#include "MT_assert.h"
-#include "limits.h"
-
-#include "BLI_math.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_MouseActuator::KX_MouseActuator(
- SCA_IObject* gameobj,
-
- KX_KetsjiEngine* ketsjiEngine,
- SCA_MouseManager* eventmgr,
- int acttype,
- bool visible,
- bool* use_axis,
- float* threshold,
- bool* reset,
- int* object_axis,
- bool* local,
- float* sensitivity,
- float* limit_x,
- float* limit_y
-):
- SCA_IActuator(gameobj, KX_ACT_MOUSE),
- m_ketsji(ketsjiEngine),
- m_eventmgr(eventmgr),
- m_type(acttype),
- m_visible(visible),
- m_use_axis_x(use_axis[0]),
- m_use_axis_y(use_axis[1]),
- m_reset_x(reset[0]),
- m_reset_y(reset[1]),
- m_local_x(local[0]),
- m_local_y(local[1])
-{
- m_canvas = m_ketsji->GetCanvas();
- m_oldposition[0] = m_oldposition[1] = -1.f;
- m_limit_x[0] = limit_x[0];
- m_limit_x[1] = limit_x[1];
- m_limit_y[0] = limit_y[0];
- m_limit_y[1] = limit_y[1];
- m_threshold[0] = threshold[0];
- m_threshold[1] = threshold[1];
- m_object_axis[0] = object_axis[0];
- m_object_axis[1] = object_axis[1];
- m_sensitivity[0] = sensitivity[0];
- m_sensitivity[1] = sensitivity[1];
- m_angle[0] = 0.f;
- m_angle[1] = 0.f;
-}
-
-KX_MouseActuator::~KX_MouseActuator()
-{
-}
-
-bool KX_MouseActuator::Update()
-{
- bool result = false;
-
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
-
- KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent());
-
- m_mouse = ((SCA_MouseManager *)m_eventmgr)->GetInputDevice();
-
- switch (m_type) {
- case KX_ACT_MOUSE_VISIBILITY:
- {
- if (m_visible) {
- if (m_canvas) {
- m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
- }
- }
- else {
- if (m_canvas) {
- m_canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
- }
- }
- break;
- }
- case KX_ACT_MOUSE_LOOK:
- {
- if (m_mouse) {
-
- float position[2];
- float movement[2];
- MT_Vector3 rotation;
- float setposition[2] = {0.0f};
- float center_x = 0.5f, center_y = 0.5f;
-
- getMousePosition(position);
-
- movement[0] = position[0];
- movement[1] = position[1];
-
- //preventing undesired drifting when resolution is odd
- if ((m_canvas->GetWidth() % 2) != 0) {
- center_x = ((m_canvas->GetWidth() - 1.0f) / 2.0f) / (m_canvas->GetWidth());
- }
- if ((m_canvas->GetHeight() % 2) != 0) {
- center_y = ((m_canvas->GetHeight() - 1.0f) / 2.0f) / (m_canvas->GetHeight());
- }
-
- //preventing initial skipping.
- if ((m_oldposition[0] <= -0.9f) && (m_oldposition[1] <= -0.9f)) {
-
- if (m_reset_x) {
- m_oldposition[0] = center_x;
- }
- else {
- m_oldposition[0] = position[0];
- }
-
- if (m_reset_y) {
- m_oldposition[1] = center_y;
- }
- else {
- m_oldposition[1] = position[1];
- }
- setMousePosition(m_oldposition[0], m_oldposition[1]);
- break;
- }
-
- //Calculating X axis.
- if (m_use_axis_x) {
-
- if (m_reset_x) {
- setposition[0] = center_x;
- movement[0] -= center_x;
- }
- else {
- setposition[0] = position[0];
- movement[0] -= m_oldposition[0];
- }
-
- movement[0] *= -1.0f;
-
- /* Don't apply the rotation when we are under a certain threshold for mouse
- movement */
-
- if (((movement[0] > (m_threshold[0] / 10.0f)) ||
- ((movement[0] * (-1.0f)) > (m_threshold[0] / 10.0f)))) {
-
- movement[0] *= m_sensitivity[0];
-
- if ((m_limit_x[0] != 0.0f) && ((m_angle[0] + movement[0]) <= m_limit_x[0])) {
- movement[0] = m_limit_x[0] - m_angle[0];
- }
-
- if ((m_limit_x[1] != 0.0f) && ((m_angle[0] + movement[0]) >= m_limit_x[1])) {
- movement[0] = m_limit_x[1] - m_angle[0];
- }
-
- m_angle[0] += movement[0];
-
- switch (m_object_axis[0]) {
- case KX_ACT_MOUSE_OBJECT_AXIS_X:
- {
- rotation = MT_Vector3(movement[0], 0.0f, 0.0f);
- break;
- }
- case KX_ACT_MOUSE_OBJECT_AXIS_Y:
- {
- rotation = MT_Vector3(0.0f, movement[0], 0.0f);
- break;
- }
- case KX_ACT_MOUSE_OBJECT_AXIS_Z:
- {
- rotation = MT_Vector3(0.0f, 0.0f, movement[0]);
- break;
- }
- default:
- break;
- }
- parent->ApplyRotation(rotation, m_local_x);
- }
- }
- else {
- setposition[0] = center_x;
- }
-
- //Calculating Y axis.
- if (m_use_axis_y) {
-
- if (m_reset_y) {
- setposition[1] = center_y;
- movement[1] -= center_y;
- }
- else {
- setposition[1] = position[1];
- movement[1] -= m_oldposition[1];
- }
-
- movement[1] *= -1.0f;
-
- /* Don't apply the rotation when we are under a certain threshold for mouse
- movement */
-
- if (((movement[1] > (m_threshold[1] / 10.0f)) ||
- ((movement[1] * (-1.0f)) > (m_threshold[1] / 10.0f)))) {
-
- movement[1] *= m_sensitivity[1];
-
- if ((m_limit_y[0] != 0.0f) && ((m_angle[1] + movement[1]) <= m_limit_y[0])) {
- movement[1] = m_limit_y[0] - m_angle[1];
- }
-
- if ((m_limit_y[1] != 0.0f) && ((m_angle[1] + movement[1]) >= m_limit_y[1])) {
- movement[1] = m_limit_y[1] - m_angle[1];
- }
-
- m_angle[1] += movement[1];
-
- switch (m_object_axis[1])
- {
- case KX_ACT_MOUSE_OBJECT_AXIS_X:
- {
- rotation = MT_Vector3(movement[1], 0.0f, 0.0f);
- break;
- }
- case KX_ACT_MOUSE_OBJECT_AXIS_Y:
- {
- rotation = MT_Vector3(0.0f, movement[1], 0.0f);
- break;
- }
- case KX_ACT_MOUSE_OBJECT_AXIS_Z:
- {
- rotation = MT_Vector3(0.0f, 0.0f, movement[1]);
- break;
- }
- default:
- break;
- }
- parent->ApplyRotation(rotation, m_local_y);
- }
- }
- else {
- setposition[1] = center_y;
- }
-
- // only trigger mouse event when it is necessary
- if (m_oldposition[0] != position[0] || m_oldposition[1] != position[1]) {
- setMousePosition(setposition[0], setposition[1]);
- }
-
- m_oldposition[0] = position[0];
- m_oldposition[1] = position[1];
-
- }
- else {
- //printf("\nNo input device detected for mouse actuator\n");
- }
- break;
- }
- default:
- break;
- }
- return result;
-}
-
-bool KX_MouseActuator::isValid(KX_MouseActuator::KX_ACT_MOUSE_MODE mode)
-{
- return ((mode > KX_ACT_MOUSE_NODEF) && (mode < KX_ACT_MOUSE_MAX));
-}
-
-
-CValue* KX_MouseActuator::GetReplica()
-{
- KX_MouseActuator* replica = new KX_MouseActuator(*this);
-
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_MouseActuator::ProcessReplica()
-{
- SCA_IActuator::ProcessReplica();
-}
-
-void KX_MouseActuator::getMousePosition(float* pos)
-{
- MT_assert(m_mouse);
- const SCA_InputEvent & xevent = m_mouse->GetEventValue(SCA_IInputDevice::KX_MOUSEX);
- const SCA_InputEvent & yevent = m_mouse->GetEventValue(SCA_IInputDevice::KX_MOUSEY);
-
- pos[0] = m_canvas->GetMouseNormalizedX(xevent.m_eventval);
- pos[1] = m_canvas->GetMouseNormalizedY(yevent.m_eventval);
-}
-
-void KX_MouseActuator::setMousePosition(float fx, float fy)
-{
- int x, y;
-
- x = (int)(fx * m_canvas->GetWidth());
- y = (int)(fy * m_canvas->GetHeight());
-
- m_canvas->SetMousePosition(x, y);
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_MouseActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_MouseActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_MouseActuator::Methods[] = {
- {"reset", (PyCFunction) KX_MouseActuator::sPyReset, METH_NOARGS,"reset() : undo rotation caused by actuator\n"},
- {NULL,NULL} //Sentinel
-};
-
-
-
-PyAttributeDef KX_MouseActuator::Attributes[] = {
- KX_PYATTRIBUTE_BOOL_RW("visible", KX_MouseActuator, m_visible),
- KX_PYATTRIBUTE_BOOL_RW("use_axis_x", KX_MouseActuator, m_use_axis_x),
- KX_PYATTRIBUTE_BOOL_RW("use_axis_y", KX_MouseActuator, m_use_axis_y),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RW("threshold", 0.0f, 0.5f, KX_MouseActuator, m_threshold, 2),
- KX_PYATTRIBUTE_BOOL_RW("reset_x", KX_MouseActuator, m_reset_x),
- KX_PYATTRIBUTE_BOOL_RW("reset_y", KX_MouseActuator, m_reset_y),
- KX_PYATTRIBUTE_INT_ARRAY_RW("object_axis", 0, 2, 1, KX_MouseActuator, m_object_axis, 2),
- KX_PYATTRIBUTE_BOOL_RW("local_x", KX_MouseActuator, m_local_x),
- KX_PYATTRIBUTE_BOOL_RW("local_y", KX_MouseActuator, m_local_y),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RW("sensitivity", -FLT_MAX, FLT_MAX, KX_MouseActuator, m_sensitivity, 2),
- KX_PYATTRIBUTE_RW_FUNCTION("limit_x", KX_MouseActuator, pyattr_get_limit_x, pyattr_set_limit_x),
- KX_PYATTRIBUTE_RW_FUNCTION("limit_y", KX_MouseActuator, pyattr_get_limit_y, pyattr_set_limit_y),
- KX_PYATTRIBUTE_RW_FUNCTION("angle", KX_MouseActuator, pyattr_get_angle, pyattr_set_angle),
- { NULL } //Sentinel
-};
-
-PyObject* KX_MouseActuator::pyattr_get_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v);
- return Py_BuildValue("[f,f]", (self->m_limit_x[0] / (float)M_PI * 180.0f), (self->m_limit_x[1] / (float)M_PI * 180.0f));
-}
-
-int KX_MouseActuator::pyattr_set_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- PyObject *item1, *item2;
- KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v);
-
- if (!PyList_Check(value))
- return PY_SET_ATTR_FAIL;
-
- if (PyList_Size(value) != 2)
- return PY_SET_ATTR_FAIL;
-
- item1 = PyList_GET_ITEM(value, 0);
- item2 = PyList_GET_ITEM(value, 1);
-
- if (!(PyFloat_Check(item1)) || !(PyFloat_Check(item2))) {
- return PY_SET_ATTR_FAIL;
- }
- else {
- self->m_limit_x[0] = (float)((PyFloat_AsDouble(item1) * M_PI) / 180.0f);
- self->m_limit_x[1] = (float)((PyFloat_AsDouble(item2) * M_PI) / 180.0f);
- }
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject* KX_MouseActuator::pyattr_get_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v);
- return Py_BuildValue("[f,f]", (self->m_limit_y[0] / (float)M_PI * 180.0f), (self->m_limit_y[1] / (float)M_PI * 180.0f));
-}
-
-int KX_MouseActuator::pyattr_set_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- PyObject *item1, *item2;
- KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v);
-
- if (!PyList_Check(value))
- return PY_SET_ATTR_FAIL;
-
- if (PyList_Size(value) != 2)
- return PY_SET_ATTR_FAIL;
-
- item1 = PyList_GET_ITEM(value, 0);
- item2 = PyList_GET_ITEM(value, 1);
-
- if (!(PyFloat_Check(item1)) || !(PyFloat_Check(item2))) {
- return PY_SET_ATTR_FAIL;
- }
- else {
- self->m_limit_y[0] = (float)((PyFloat_AsDouble(item1) * M_PI) / 180.0f);
- self->m_limit_y[1] = (float)((PyFloat_AsDouble(item2) * M_PI) / 180.0f);
- }
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject* KX_MouseActuator::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v);
- return Py_BuildValue("[f,f]", (self->m_angle[0] / (float)M_PI * 180.0f), (self->m_angle[1] / (float)M_PI * 180.0f));
-}
-
-int KX_MouseActuator::pyattr_set_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- PyObject *item1, *item2;
- KX_MouseActuator* self= static_cast<KX_MouseActuator*>(self_v);
-
- if (!PyList_Check(value))
- return PY_SET_ATTR_FAIL;
-
- if (PyList_Size(value) != 2)
- return PY_SET_ATTR_FAIL;
-
- item1 = PyList_GET_ITEM(value, 0);
- item2 = PyList_GET_ITEM(value, 1);
-
- if (!(PyFloat_Check(item1)) || !(PyFloat_Check(item2))) {
- return PY_SET_ATTR_FAIL;
- }
- else {
- self->m_angle[0] = ((float)(PyFloat_AsDouble(item1) * M_PI) / 180.0f);
- self->m_angle[1] = ((float)(PyFloat_AsDouble(item2) * M_PI) / 180.0f);
- }
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject* KX_MouseActuator::PyReset()
-{
- MT_Vector3 rotation;
- KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent());
-
- switch (m_object_axis[0]) {
- case KX_ACT_MOUSE_OBJECT_AXIS_X:
- {
- rotation = MT_Vector3(-1.0f * m_angle[0], 0.0f, 0.0f);
- break;
- }
- case KX_ACT_MOUSE_OBJECT_AXIS_Y:
- {
- rotation = MT_Vector3(0.0f, -1.0f * m_angle[0], 0.0f);
- break;
- }
- case KX_ACT_MOUSE_OBJECT_AXIS_Z:
- {
- rotation = MT_Vector3(0.0f, 0.0f, -1.0f * m_angle[0]);
- break;
- }
- default:
- break;
- }
- parent->ApplyRotation(rotation, m_local_x);
-
- switch (m_object_axis[1]) {
- case KX_ACT_MOUSE_OBJECT_AXIS_X:
- {
- rotation = MT_Vector3(-1.0f * m_angle[1], 0.0f, 0.0f);
- break;
- }
- case KX_ACT_MOUSE_OBJECT_AXIS_Y:
- {
- rotation = MT_Vector3(0.0f, -1.0f * m_angle[1], 0.0f);
- break;
- }
- case KX_ACT_MOUSE_OBJECT_AXIS_Z:
- {
- rotation = MT_Vector3(0.0f, 0.0f, -1.0f * m_angle[1]);
- break;
- }
- default:
- break;
- }
- parent->ApplyRotation(rotation, m_local_y);
-
- m_angle[0] = 0.0f;
- m_angle[1] = 0.0f;
-
- Py_RETURN_NONE;
-}
-
-#endif /* WITH_PYTHON */
diff --git a/source/gameengine/Ketsji/KX_MouseActuator.h b/source/gameengine/Ketsji/KX_MouseActuator.h
deleted file mode 100644
index e244e271428..00000000000
--- a/source/gameengine/Ketsji/KX_MouseActuator.h
+++ /dev/null
@@ -1,132 +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.
- *
- * Contributor(s): Geoffrey Gollmer, Jorge Bernal
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __KX_MOUSEACTUATOR
-#define __KX_MOUSEACTUATOR
-
-#include "SCA_IActuator.h"
-
-class KX_KetsjiEngine;
-class SCA_MouseManager;
-class SCA_IInputDevice;
-class RAS_ICanvas;
-
-class KX_MouseActuator : public SCA_IActuator
-{
- Py_Header
-
-private:
-
- KX_KetsjiEngine* m_ketsji;
- SCA_MouseManager* m_eventmgr;
- SCA_IInputDevice* m_mouse;
- RAS_ICanvas* m_canvas;
- int m_type;
-
- bool m_visible;
-
- bool m_use_axis_x; /* 0 for calculate axis, 1 for ignore axis */
- bool m_use_axis_y;
- float m_threshold[2];
- bool m_reset_x; /* 0=reset, 1=free */
- bool m_reset_y;
- int m_object_axis[2]; /* 0=x, 1=y, 2=z */
- bool m_local_x; /* 0=local, 1=global*/
- bool m_local_y;
- float m_sensitivity[2];
- float m_limit_x[2];
- float m_limit_y[2];
-
- float m_oldposition[2];
- float m_angle[2];
-
-public:
-
- enum KX_ACT_MOUSE_OBJECT_AXIS {
- KX_ACT_MOUSE_OBJECT_AXIS_X = 0,
- KX_ACT_MOUSE_OBJECT_AXIS_Y,
- KX_ACT_MOUSE_OBJECT_AXIS_Z
- };
-
- enum KX_ACT_MOUSE_MODE {
- KX_ACT_MOUSE_NODEF = 0,
- KX_ACT_MOUSE_VISIBILITY,
- KX_ACT_MOUSE_LOOK,
- KX_ACT_MOUSE_MAX
- };
-
- KX_MouseActuator(
- SCA_IObject* gameobj,
- KX_KetsjiEngine* ketsjiEngine,
- SCA_MouseManager* eventmgr,
- int acttype,
- bool visible,
- bool* use_axis,
- float* threshold,
- bool* reset,
- int* object_axis,
- bool* local,
- float* sensitivity,
- float* limit_x,
- float* limit_y
- );
-
-
- ~KX_MouseActuator();
-
- CValue* GetReplica();
- virtual void ProcessReplica();
-
- virtual bool Update();
-
- /* check whether this value is valid */
- bool isValid(KX_ACT_MOUSE_MODE mode);
-
- virtual void getMousePosition(float*);
- virtual void setMousePosition(float, float);
-
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- /* Methods */
-
- KX_PYMETHOD_DOC_NOARGS(KX_MouseActuator,Reset);
-
- /* Attributes */
-
- static PyObject* pyattr_get_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_limit_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static PyObject* pyattr_get_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_limit_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static PyObject* pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif /* WITH_PYTHON */
-
-};
-
-#endif //__KX_MOUSEACTUATOR_DOC
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
deleted file mode 100644
index 451078d4a36..00000000000
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ /dev/null
@@ -1,520 +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 *****
- * KX_MouseFocusSensor determines mouse in/out/over events.
- */
-
-/** \file gameengine/Ketsji/KX_MouseFocusSensor.cpp
- * \ingroup ketsji
- */
-
-#ifdef _MSC_VER
- /* This warning tells us about truncation of __long__ stl-generated names.
- * It can occasionally cause DevStudio to have internal compiler warnings. */
-# pragma warning(disable:4786)
-#endif
-
-#include <stdio.h>
-
-#include "MT_Point3.h"
-#include "RAS_FramingManager.h"
-#include "RAS_ICanvas.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_MeshObject.h"
-#include "SCA_IScene.h"
-#include "KX_Scene.h"
-#include "KX_Camera.h"
-#include "KX_MouseFocusSensor.h"
-#include "KX_PyMath.h"
-
-#include "KX_RayCast.h"
-#include "PHY_IPhysicsController.h"
-#include "PHY_IPhysicsEnvironment.h"
-
-
-#include "KX_ClientObjectInfo.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr,
- int startx,
- int starty,
- short int mousemode,
- int focusmode,
- bool bTouchPulse,
- const STR_String& propname,
- bool bFindMaterial,
- bool bXRay,
- KX_Scene* kxscene,
- KX_KetsjiEngine *kxengine,
- SCA_IObject* gameobj)
- : SCA_MouseSensor(eventmgr, startx, starty, mousemode, gameobj),
- m_focusmode(focusmode),
- m_bTouchPulse(bTouchPulse),
- m_bXRay(bXRay),
- m_bFindMaterial(bFindMaterial),
- m_propertyname(propname),
- m_kxscene(kxscene),
- m_kxengine(kxengine)
-{
- Init();
-}
-
-void KX_MouseFocusSensor::Init()
-{
- m_mouse_over_in_previous_frame = (m_invert)?true:false;
- m_positive_event = false;
- m_hitObject = 0;
- m_hitObject_Last = NULL;
- m_reset = true;
-
- m_hitPosition.setValue(0,0,0);
- m_prevTargetPoint.setValue(0,0,0);
- m_prevSourcePoint.setValue(0,0,0);
- m_hitNormal.setValue(0,0,1);
-}
-
-bool KX_MouseFocusSensor::Evaluate()
-{
- bool result = false;
- bool obHasFocus = false;
- bool reset = m_reset && m_level;
-
-// cout << "evaluate focus mouse sensor "<<endl;
- m_reset = false;
- if (m_focusmode) {
- /* Focus behavior required. Test mouse-on. The rest is
- * equivalent to handling a key. */
- obHasFocus = ParentObjectHasFocus();
-
- if (!obHasFocus) {
- m_positive_event = false;
- if (m_mouse_over_in_previous_frame) {
- result = true;
- }
- } else {
- m_positive_event = true;
- if (!m_mouse_over_in_previous_frame) {
- result = true;
- }
- else if (m_bTouchPulse && (m_hitObject != m_hitObject_Last)) {
- result = true;
- }
- }
- if (reset) {
- // force an event
- result = true;
- }
- } else {
- /* No focus behavior required: revert to the basic mode. This
- * mode is never used, because the converter never makes this
- * sensor for a mouse-key event. It is here for
- * completeness. */
- result = SCA_MouseSensor::Evaluate();
- m_positive_event = (m_val!=0);
- }
-
- m_mouse_over_in_previous_frame = obHasFocus;
- m_hitObject_Last = (void *)m_hitObject;
-
- return result;
-}
-
-bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo *client_info, KX_RayCast *result, void *UNUSED(data))
-{
- KX_GameObject* hitKXObj = client_info->m_gameobject;
-
- /* Is this me? In the ray test, there are a lot of extra checks
- * for aliasing artifacts from self-hits. That doesn't happen
- * here, so a simple test suffices. Or does the camera also get
- * self-hits? (No, and the raysensor shouldn't do it either, since
- * self-hits are excluded by setting the correct ignore-object.)
- * Hitspots now become valid. */
- KX_GameObject* thisObj = (KX_GameObject*) GetParent();
-
- bool bFound = false;
-
- if ((m_focusmode == 2) || hitKXObj == thisObj)
- {
- if (m_propertyname.Length() == 0)
- {
- bFound = true;
- }
- else
- {
- if (m_bFindMaterial) {
- for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) {
- RAS_MeshObject *meshObj = hitKXObj->GetMesh(i);
- for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
- bFound = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
- if (bFound)
- break;
- }
- }
- }
- else {
- bFound = hitKXObj->GetProperty(m_propertyname) != NULL;
- }
- }
-
- if (bFound)
- {
- m_hitObject = hitKXObj;
- m_hitPosition = result->m_hitPoint;
- m_hitNormal = result->m_hitNormal;
- m_hitUV = result->m_hitUV;
- return true;
- }
- }
-
- return true; // object must be visible to trigger
- //return false; // occluded objects can trigger
-}
-
-/* this function is used to pre-filter the object before casting the ray on them.
- * This is useful for "X-Ray" option when we want to see "through" unwanted object.
- */
-bool KX_MouseFocusSensor::NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data))
-{
- KX_GameObject *hitKXObj = client->m_gameobject;
-
- if (client->m_type > KX_ClientObjectInfo::ACTOR)
- {
- // Unknown type of object, skip it.
- // Should not occur as the sensor objects are filtered in RayTest()
- printf("Invalid client type %d found ray casting\n", client->m_type);
- return false;
- }
- if (m_bXRay && m_propertyname.Length() != 0)
- {
- if (m_bFindMaterial)
- {
- bool found = false;
- for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) {
- RAS_MeshObject *meshObj = hitKXObj->GetMesh(i);
- for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
- found = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
- if (found)
- break;
- }
- }
- if (!found)
- return false;
- }
- else
- {
- if (hitKXObj->GetProperty(m_propertyname) == NULL)
- return false;
- }
- }
- return true;
-}
-
-bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam)
-{
- /* All screen handling in the gameengine is done by GL,
- * specifically the model/view and projection parts. The viewport
- * part is in the creator.
- *
- * The theory is this:
- * WCS - world coordinates
- * -> wcs_camcs_trafo ->
- * camCS - camera coordinates
- * -> camcs_clip_trafo ->
- * clipCS - normalized device coordinates?
- * -> normview_win_trafo
- * winCS - window coordinates
- *
- * The first two transforms are respectively the model/view and
- * the projection matrix. These are passed to the rasterizer, and
- * we store them in the camera for easy access.
- *
- * For normalized device coords (xn = x/w, yn = y/w/zw) the
- * windows coords become (lb = left bottom)
- *
- * xwin = [(xn + 1.0) * width]/2 + x_lb
- * ywin = [(yn + 1.0) * height]/2 + y_lb
- *
- * Inverting (blender y is flipped!):
- *
- * xn = 2(xwin - x_lb)/width - 1.0
- * yn = 2(ywin - y_lb)/height - 1.0
- * = 2(height - y_blender - y_lb)/height - 1.0
- * = 1.0 - 2(y_blender - y_lb)/height
- *
- * */
-
-
- /* Because we don't want to worry about resize events, camera
- * changes and all that crap, we just determine this over and
- * over. Stop whining. We have lots of other calculations to do
- * here as well. These reads are not the main cost. If there is no
- * canvas, the test is irrelevant. The 1.0 makes sure the
- * calculations don't bomb. Maybe we should explicitly guard for
- * division by 0.0...*/
-
- RAS_Rect area, viewport;
- short m_y_inv = m_kxengine->GetCanvas()->GetHeight()-m_y;
-
- m_kxengine->GetSceneViewport(m_kxscene, cam, area, viewport);
-
- /* Check if the mouse is in the viewport */
- if (( m_x < viewport.m_x2 && // less than right
- m_x > viewport.m_x1 && // more than then left
- m_y_inv < viewport.m_y2 && // below top
- m_y_inv > viewport.m_y1) == 0) // above bottom
- {
- return false;
- }
-
- float height = float(viewport.m_y2 - viewport.m_y1 + 1);
- float width = float(viewport.m_x2 - viewport.m_x1 + 1);
-
- float x_lb = float(viewport.m_x1);
- float y_lb = float(viewport.m_y1);
-
- MT_Vector4 frompoint;
- MT_Vector4 topoint;
-
- /* m_y_inv - inverting for a bounds check is only part of it, now make relative to view bounds */
- m_y_inv = (viewport.m_y2 - m_y_inv) + viewport.m_y1;
-
-
- /* There's some strangeness I don't fully get here... These values
- * _should_ be wrong! - see from point Z values */
-
-
- /* build the from and to point in normalized device coordinates
- * Normalized device coordinates are [-1,1] in x, y, z
- *
- * The actual z coordinates used don't have to be exact just infront and
- * behind of the near and far clip planes.
- */
- frompoint.setValue( (2 * (m_x-x_lb) / width) - 1.0f,
- 1.0f - (2 * (m_y_inv - y_lb) / height),
- -1.0f,
- 1.0f );
-
- topoint.setValue( (2 * (m_x-x_lb) / width) - 1.0f,
- 1.0f - (2 * (m_y_inv-y_lb) / height),
- 1.0f,
- 1.0f );
-
- /* camera to world */
- MT_Matrix4x4 camcs_wcs_matrix = MT_Matrix4x4(cam->GetCameraToWorld());
-
- /* badly defined, the first time round.... I wonder why... I might
- * want to guard against floating point errors here.*/
- MT_Matrix4x4 clip_camcs_matrix = MT_Matrix4x4(cam->GetProjectionMatrix());
- clip_camcs_matrix.invert();
-
- /* shoot-points: clip to cam to wcs . win to clip was already done.*/
- frompoint = clip_camcs_matrix * frompoint;
- topoint = clip_camcs_matrix * topoint;
- /* clipstart = - (frompoint[2] / frompoint[3])
- * clipend = - (topoint[2] / topoint[3]) */
- frompoint = camcs_wcs_matrix * frompoint;
- topoint = camcs_wcs_matrix * topoint;
-
- /* from hom wcs to 3d wcs: */
- m_prevSourcePoint.setValue( frompoint[0]/frompoint[3],
- frompoint[1]/frompoint[3],
- frompoint[2]/frompoint[3]);
-
- m_prevTargetPoint.setValue( topoint[0]/topoint[3],
- topoint[1]/topoint[3],
- topoint[2]/topoint[3]);
-
- /* 2. Get the object from PhysicsEnvironment */
- /* Shoot! Beware that the first argument here is an
- * ignore-object. We don't ignore anything... */
- PHY_IPhysicsController* physics_controller = cam->GetPhysicsController();
- PHY_IPhysicsEnvironment* physics_environment = m_kxscene->GetPhysicsEnvironment();
-
- // get UV mapping
- KX_RayCast::Callback<KX_MouseFocusSensor, void> callback(this,physics_controller,NULL,false,true);
-
- KX_RayCast::RayTest(physics_environment, m_prevSourcePoint, m_prevTargetPoint, callback);
-
- if (m_hitObject)
- return true;
-
- return false;
-}
-
-bool KX_MouseFocusSensor::ParentObjectHasFocus()
-{
- m_hitObject = 0;
- m_hitPosition.setValue(0,0,0);
- m_hitNormal.setValue(1,0,0);
-
- KX_Camera *cam= m_kxscene->GetActiveCamera();
-
- if (ParentObjectHasFocusCamera(cam))
- return true;
-
- list<class KX_Camera*>* cameras = m_kxscene->GetCameras();
- list<KX_Camera*>::iterator it = cameras->begin();
-
- while (it != cameras->end()) {
- if (((*it) != cam) && (*it)->GetViewport())
- if (ParentObjectHasFocusCamera(*it))
- return true;
-
- it++;
- }
-
- return false;
-}
-
-const MT_Point3& KX_MouseFocusSensor::RaySource() const
-{
- return m_prevSourcePoint;
-}
-
-const MT_Point3& KX_MouseFocusSensor::RayTarget() const
-{
- return m_prevTargetPoint;
-}
-
-const MT_Point3& KX_MouseFocusSensor::HitPosition() const
-{
- return m_hitPosition;
-}
-
-const MT_Vector3& KX_MouseFocusSensor::HitNormal() const
-{
- return m_hitNormal;
-}
-
-const MT_Vector2& KX_MouseFocusSensor::HitUV() const
-{
- return m_hitUV;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_MouseFocusSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_MouseFocusSensor",
- 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,
- &SCA_MouseSensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_MouseFocusSensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_MouseFocusSensor::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("raySource", KX_MouseFocusSensor, pyattr_get_ray_source),
- KX_PYATTRIBUTE_RO_FUNCTION("rayTarget", KX_MouseFocusSensor, pyattr_get_ray_target),
- KX_PYATTRIBUTE_RO_FUNCTION("rayDirection", KX_MouseFocusSensor, pyattr_get_ray_direction),
- KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_MouseFocusSensor, pyattr_get_hit_object),
- KX_PYATTRIBUTE_RO_FUNCTION("hitPosition", KX_MouseFocusSensor, pyattr_get_hit_position),
- KX_PYATTRIBUTE_RO_FUNCTION("hitNormal", KX_MouseFocusSensor, pyattr_get_hit_normal),
- KX_PYATTRIBUTE_RO_FUNCTION("hitUV", KX_MouseFocusSensor, pyattr_get_hit_uv),
- KX_PYATTRIBUTE_BOOL_RW("usePulseFocus", KX_MouseFocusSensor, m_bTouchPulse),
- KX_PYATTRIBUTE_BOOL_RW("useXRay", KX_MouseFocusSensor, m_bXRay),
- KX_PYATTRIBUTE_BOOL_RW("useMaterial", KX_MouseFocusSensor, m_bFindMaterial),
- KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, KX_MouseFocusSensor, m_propertyname),
- { NULL } //Sentinel
-};
-
-/* Attributes */
-PyObject *KX_MouseFocusSensor::pyattr_get_ray_source(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
- return PyObjectFrom(self->RaySource());
-}
-
-PyObject *KX_MouseFocusSensor::pyattr_get_ray_target(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
- return PyObjectFrom(self->RayTarget());
-}
-
-PyObject *KX_MouseFocusSensor::pyattr_get_ray_direction(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
- MT_Vector3 dir = self->RayTarget() - self->RaySource();
- if (MT_fuzzyZero(dir)) dir.setValue(0,0,0);
- else dir.normalize();
- return PyObjectFrom(dir);
-}
-
-PyObject *KX_MouseFocusSensor::pyattr_get_hit_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
-
- if (self->m_hitObject)
- return self->m_hitObject->GetProxy();
-
- Py_RETURN_NONE;
-}
-
-PyObject *KX_MouseFocusSensor::pyattr_get_hit_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
- return PyObjectFrom(self->HitPosition());
-}
-
-PyObject *KX_MouseFocusSensor::pyattr_get_hit_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
- return PyObjectFrom(self->HitNormal());
-}
-
-PyObject *KX_MouseFocusSensor::pyattr_get_hit_uv(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
- return PyObjectFrom(self->HitUV());
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
-
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
deleted file mode 100644
index dd9295b2ff4..00000000000
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h
+++ /dev/null
@@ -1,208 +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_MouseFocusSensor.h
- * \ingroup ketsji
- * \brief KX_MouseFocusSensor determines mouse in/out/over events.
- */
-
-#ifndef __KX_MOUSEFOCUSSENSOR_H__
-#define __KX_MOUSEFOCUSSENSOR_H__
-
-#include "SCA_MouseSensor.h"
-
-#include "BLI_utildefines.h"
-
-class KX_RayCast;
-
-/**
- * The mouse focus sensor extends the basic SCA_MouseSensor. It has
- * been placed in KX because it needs access to the rasterizer and
- * SuMO.
- *
- * - extend the valid modes?
- * - */
-class KX_MouseFocusSensor : public SCA_MouseSensor
-{
-
- Py_Header
-
- public:
-
- KX_MouseFocusSensor(class SCA_MouseManager* eventmgr,
- int startx,
- int starty,
- short int mousemode,
- int focusmode,
- bool bTouchPulse,
- const STR_String& propname,
- bool bFindMaterial,
- bool bXRay,
- KX_Scene* kxscene,
- KX_KetsjiEngine* kxengine,
- SCA_IObject* gameobj);
-
- virtual ~KX_MouseFocusSensor() { }
- virtual CValue* GetReplica() {
- CValue* replica = new KX_MouseFocusSensor(*this);
- // this will copy properties and so on...
- replica->ProcessReplica();
- return replica;
- };
-
- virtual void Replace_IScene(SCA_IScene *val)
- {
- m_kxscene= static_cast<KX_Scene *>(val);
- };
-
-
- /**
- * \attention Overrides default evaluate.
- */
- virtual bool Evaluate();
- virtual void Init();
-
- virtual bool IsPositiveTrigger() {
- bool result = m_positive_event;
- if (m_invert) result = !result;
- return result;
- };
-
- /// \see KX_RayCast
- bool RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void *UNUSED(data));
- /// \see KX_RayCast
- bool NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data));
-
- const MT_Point3& RaySource() const;
- const MT_Point3& RayTarget() const;
- const MT_Point3& HitPosition() const;
- const MT_Vector3& HitNormal() const;
- const MT_Vector2& HitUV() const;
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- /* attributes */
- static PyObject* pyattr_get_ray_source(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_ray_target(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_ray_direction(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_hit_object(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_hit_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_hit_normal(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_hit_uv(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
-#endif /* WITH_PYTHON */
-
- /* --------------------------------------------------------------------- */
- SCA_IObject* m_hitObject;
- void* m_hitObject_Last; /* only use for comparison, never access */
-
- private:
- /**
- * The focus mode. 1 for handling focus, 0 for not handling, 2 for focus on any object
- */
- int m_focusmode;
-
- /**
- * Flags whether the previous test showed a mouse-over.
- */
- bool m_mouse_over_in_previous_frame;
-
- /**
- * Flags whether changes in hit object should trigger a pulse
- */
- bool m_bTouchPulse;
-
- /**
- * Flags get through other objects
- */
- bool m_bXRay;
-
- /**
- * Flags material
- */
- bool m_bFindMaterial;
-
- /**
- * Property or material name
- */
- STR_String m_propertyname;
-
- /**
- * Flags whether the previous test evaluated positive.
- */
- bool m_positive_event;
-
- /**
- * Tests whether the object is in mouse focus for this camera
- */
- bool ParentObjectHasFocusCamera(KX_Camera *cam);
-
- /**
- * Tests whether the object is in mouse focus in this scene.
- */
- bool ParentObjectHasFocus(void);
-
- /**
- * (in game world coordinates) the place where the object was hit.
- */
- MT_Point3 m_hitPosition;
-
- /**
- * (in game world coordinates) the position to which to shoot the ray.
- */
- MT_Point3 m_prevTargetPoint;
-
- /**
- * (in game world coordinates) the position from which to shoot the ray.
- */
- MT_Point3 m_prevSourcePoint;
-
- /**
- * (in game world coordinates) the face normal of the vertex where
- * the object was hit. */
- MT_Vector3 m_hitNormal;
-
- /**
- * UV texture coordinate of the hit point if any, (0,0) otherwise
- */
- MT_Vector2 m_hitUV;
-
- /**
- * The KX scene that holds the camera. The camera position
- * determines a part of the start location of the picking ray. */
- KX_Scene* m_kxscene;
-
- /**
- * The KX engine is needed for computing the viewport */
- KX_KetsjiEngine* m_kxengine;
-};
-
-#endif /* __KX_MOUSESENSOR */
diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp
deleted file mode 100644
index 83accb1d7a5..00000000000
--- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp
+++ /dev/null
@@ -1,747 +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 *****
- */
-
-#include "MEM_guardedalloc.h"
-
-#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"
-
-extern "C" {
-#include "BKE_scene.h"
-#include "BKE_customdata.h"
-#include "BKE_cdderivedmesh.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_navmesh_conversion.h"
-}
-
-#include "KX_PythonInit.h"
-#include "KX_PyMath.h"
-#include "EXP_Value.h"
-#include "Recast.h"
-#include "DetourStatNavMeshBuilder.h"
-#include "KX_ObstacleSimulation.h"
-
-#define MAX_PATH_LEN 256
-static const float polyPickExt[3] = {2, 4, 2};
-
-static void calcMeshBounds(const float* vert, int nverts, float* bmin, float* bmax)
-{
- bmin[0] = bmax[0] = vert[0];
- bmin[1] = bmax[1] = vert[1];
- bmin[2] = bmax[2] = vert[2];
- for (int i=1; i<nverts; i++)
- {
- if (bmin[0]>vert[3*i+0]) bmin[0] = vert[3*i+0];
- if (bmin[1]>vert[3*i+1]) bmin[1] = vert[3*i+1];
- if (bmin[2]>vert[3*i+2]) bmin[2] = vert[3*i+2];
-
- if (bmax[0]<vert[3*i+0]) bmax[0] = vert[3*i+0];
- if (bmax[1]<vert[3*i+1]) bmax[1] = vert[3*i+1];
- if (bmax[2]<vert[3*i+2]) bmax[2] = vert[3*i+2];
- }
-}
-
-inline void flipAxes(float* vec)
-{
- std::swap(vec[1],vec[2]);
-}
-KX_NavMeshObject::KX_NavMeshObject(void* sgReplicationInfo, SG_Callbacks callbacks)
-: KX_GameObject(sgReplicationInfo, callbacks)
-, m_navMesh(NULL)
-{
-
-}
-
-KX_NavMeshObject::~KX_NavMeshObject()
-{
- if (m_navMesh)
- delete m_navMesh;
-}
-
-CValue* KX_NavMeshObject::GetReplica()
-{
- KX_NavMeshObject* replica = new KX_NavMeshObject(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_NavMeshObject::ProcessReplica()
-{
- KX_GameObject::ProcessReplica();
- m_navMesh = NULL; /* without this, building frees the navmesh we copied from */
- if (!BuildNavMesh()) {
- std::cout << "Error in " << __func__ << ": unable to build navigation mesh" << std::endl;
- return;
- }
- KX_Scene* scene = KX_GetActiveScene();
- KX_ObstacleSimulation* obssimulation = scene->GetObstacleSimulation();
- if (obssimulation)
- obssimulation->AddObstaclesForNavMesh(this);
-}
-
-bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts,
- unsigned short* &polys, int& npolys, unsigned short *&dmeshes,
- float *&dvertices, int &ndvertsuniq, unsigned short *&dtris,
- int& ndtris, int &vertsPerPoly)
-{
- /* TODO: This doesn't work currently because of eval_ctx. */
-#if 0
- DerivedMesh* dm = mesh_create_derived_no_virtual(GetScene()->GetBlenderScene(), GetBlenderObject(),
- NULL, CD_MASK_MESH);
- CustomData *pdata = dm->getPolyDataLayout(dm);
- int* recastData = (int*) CustomData_get_layer(pdata, CD_RECAST);
- if (recastData)
- {
- int *dtrisToPolysMap=NULL, *dtrisToTrisMap=NULL, *trisToFacesMap=NULL;
- int nAllVerts = 0;
- float *allVerts = NULL;
- buildNavMeshDataByDerivedMesh(dm, &vertsPerPoly, &nAllVerts, &allVerts, &ndtris, &dtris,
- &npolys, &dmeshes, &polys, &dtrisToPolysMap, &dtrisToTrisMap, &trisToFacesMap);
-
- MEM_SAFE_FREE(dtrisToPolysMap);
- MEM_SAFE_FREE(dtrisToTrisMap);
- MEM_SAFE_FREE(trisToFacesMap);
-
- unsigned short *verticesMap = (unsigned short *)MEM_mallocN(sizeof(*verticesMap) * nAllVerts, __func__);
- memset(verticesMap, 0xff, sizeof(*verticesMap) * nAllVerts);
- int curIdx = 0;
- //vertices - mesh verts
- //iterate over all polys and create map for their vertices first...
- for (int polyidx=0; polyidx<npolys; polyidx++)
- {
- unsigned short* poly = &polys[polyidx*vertsPerPoly*2];
- for (int i=0; i<vertsPerPoly; i++)
- {
- unsigned short idx = poly[i];
- if (idx==0xffff)
- break;
- if (verticesMap[idx]==0xffff)
- {
- verticesMap[idx] = curIdx++;
- }
- poly[i] = verticesMap[idx];
- }
- }
- nverts = curIdx;
- //...then iterate over detailed meshes
- //transform indices to local ones (for each navigation polygon)
- for (int polyidx=0; polyidx<npolys; polyidx++)
- {
- unsigned short *poly = &polys[polyidx*vertsPerPoly*2];
- int nv = polyNumVerts(poly, vertsPerPoly);
- unsigned short *dmesh = &dmeshes[4*polyidx];
- unsigned short tribase = dmesh[2];
- unsigned short trinum = dmesh[3];
- unsigned short vbase = curIdx;
- for (int j=0; j<trinum; j++)
- {
- unsigned short* dtri = &dtris[(tribase+j)*3*2];
- for (int k=0; k<3; k++)
- {
- int newVertexIdx = verticesMap[dtri[k]];
- if (newVertexIdx==0xffff)
- {
- newVertexIdx = curIdx++;
- verticesMap[dtri[k]] = newVertexIdx;
- }
-
- if (newVertexIdx<nverts)
- {
- //it's polygon vertex ("shared")
- int idxInPoly = polyFindVertex(poly, vertsPerPoly, newVertexIdx);
- if (idxInPoly==-1)
- {
- printf("Building NavMeshObject: Error! Can't find vertex in polygon\n");
- return false;
- }
- dtri[k] = idxInPoly;
- }
- else
- {
- dtri[k] = newVertexIdx - vbase + nv;
- }
- }
- }
- dmesh[0] = vbase-nverts; //verts base
- dmesh[1] = curIdx-vbase; //verts num
- }
-
- vertices = new float[nverts*3];
- ndvertsuniq = curIdx - nverts;
- if (ndvertsuniq>0)
- {
- dvertices = new float[ndvertsuniq*3];
- }
- for (int vi=0; vi<nAllVerts; vi++)
- {
- int newIdx = verticesMap[vi];
- if (newIdx!=0xffff)
- {
- if (newIdx<nverts)
- {
- //navigation mesh vertex
- memcpy(vertices+3*newIdx, allVerts+3*vi, 3*sizeof(float));
- }
- else
- {
- //detailed mesh vertex
- memcpy(dvertices+3*(newIdx-nverts), allVerts+3*vi, 3*sizeof(float));
- }
- }
- }
-
- MEM_SAFE_FREE(allVerts);
-
- MEM_freeN(verticesMap);
- }
- else
- {
- //create from RAS_MeshObject (detailed mesh is fake)
- RAS_MeshObject* meshobj = GetMesh(0);
- vertsPerPoly = 3;
- nverts = meshobj->m_sharedvertex_map.size();
- if (nverts >= 0xffff)
- return false;
- //calculate count of tris
- int nmeshpolys = meshobj->NumPolygons();
- npolys = nmeshpolys;
- for (int p=0; p<nmeshpolys; p++)
- {
- int vertcount = meshobj->GetPolygon(p)->VertexCount();
- npolys+=vertcount-3;
- }
-
- //create verts
- vertices = new float[nverts*3];
- float* vert = vertices;
- for (int vi=0; vi<nverts; vi++)
- {
- const float* pos = !meshobj->m_sharedvertex_map[vi].empty() ? meshobj->GetVertexLocation(vi) : NULL;
- if (pos)
- copy_v3_v3(vert, pos);
- else
- {
- memset(vert, 0, 3*sizeof(float)); //vertex isn't in any poly, set dummy zero coordinates
- }
- vert+=3;
- }
-
- //create tris
- polys = (unsigned short *)MEM_callocN(sizeof(unsigned short)*3*2*npolys, "BuildVertIndArrays polys");
- memset(polys, 0xff, sizeof(unsigned short)*3*2*npolys);
- unsigned short *poly = polys;
- RAS_Polygon* raspoly;
- for (int p=0; p<nmeshpolys; p++)
- {
- raspoly = meshobj->GetPolygon(p);
- for (int v=0; v<raspoly->VertexCount()-2; v++)
- {
- poly[0] = raspoly->GetVertex(0)->getOrigIndex();
- for (size_t i=1; i<3; i++)
- {
- poly[i] = raspoly->GetVertex(v+i)->getOrigIndex();
- }
- poly += 6;
- }
- }
- dmeshes = NULL;
- dvertices = NULL;
- ndvertsuniq = 0;
- dtris = NULL;
- ndtris = npolys;
- }
- dm->release(dm);
-
- return true;
-#endif
- return false;
-}
-
-
-bool KX_NavMeshObject::BuildNavMesh()
-{
- if (m_navMesh)
- {
- delete m_navMesh;
- m_navMesh = NULL;
- }
-
- if (GetMeshCount()==0)
- {
- printf("Can't find mesh for navmesh object: %s\n", m_name.ReadPtr());
- return false;
- }
-
- float *vertices = NULL, *dvertices = NULL;
- unsigned short *polys = NULL, *dtris = NULL, *dmeshes = NULL;
- int nverts = 0, npolys = 0, ndvertsuniq = 0, ndtris = 0;
- int vertsPerPoly = 0;
- if (!BuildVertIndArrays(vertices, nverts, polys, npolys,
- dmeshes, dvertices, ndvertsuniq, dtris, ndtris, vertsPerPoly )
- || vertsPerPoly<3)
- {
- printf("Can't build navigation mesh data for object:%s\n", m_name.ReadPtr());
- if (vertices) {
- delete[] vertices;
- }
- if (dvertices) {
- delete[] dvertices;
- }
- return false;
- }
-
- MT_Point3 pos;
- if (dmeshes==NULL)
- {
- for (int i=0; i<nverts; i++)
- {
- flipAxes(&vertices[i*3]);
- }
- for (int i=0; i<ndvertsuniq; i++)
- {
- flipAxes(&dvertices[i*3]);
- }
- }
-
- if (!buildMeshAdjacency(polys, npolys, nverts, vertsPerPoly)) {
- std::cout << __func__ << ": unable to build mesh adjacency information." << std::endl;
- delete[] vertices;
- return false;
- }
-
- float cs = 0.2f;
-
- if (!nverts || !npolys)
- {
- if (vertices) delete[] vertices;
- return false;
- }
-
- float bmin[3], bmax[3];
- calcMeshBounds(vertices, nverts, bmin, bmax);
- //quantize vertex pos
- unsigned short* vertsi = new unsigned short[3*nverts];
- float ics = 1.f/cs;
- for (int i=0; i<nverts; i++)
- {
- vertsi[3*i+0] = static_cast<unsigned short>((vertices[3*i+0]-bmin[0])*ics);
- vertsi[3*i+1] = static_cast<unsigned short>((vertices[3*i+1]-bmin[1])*ics);
- vertsi[3*i+2] = static_cast<unsigned short>((vertices[3*i+2]-bmin[2])*ics);
- }
-
- // Calculate data size
- const int headerSize = sizeof(dtStatNavMeshHeader);
- const int vertsSize = sizeof(float)*3*nverts;
- const int polysSize = sizeof(dtStatPoly)*npolys;
- const int nodesSize = sizeof(dtStatBVNode)*npolys*2;
- const int detailMeshesSize = sizeof(dtStatPolyDetail)*npolys;
- const int detailVertsSize = sizeof(float)*3*ndvertsuniq;
- const int detailTrisSize = sizeof(unsigned char)*4*ndtris;
-
- const int dataSize = headerSize + vertsSize + polysSize + nodesSize +
- detailMeshesSize + detailVertsSize + detailTrisSize;
- unsigned char* data = new unsigned char[dataSize];
- if (!data)
- return false;
- memset(data, 0, dataSize);
-
- unsigned char* d = data;
- dtStatNavMeshHeader* header = (dtStatNavMeshHeader*)d; d += headerSize;
- float* navVerts = (float*)d; d += vertsSize;
- dtStatPoly* navPolys = (dtStatPoly*)d; d += polysSize;
- dtStatBVNode* navNodes = (dtStatBVNode*)d; d += nodesSize;
- dtStatPolyDetail* navDMeshes = (dtStatPolyDetail*)d; d += detailMeshesSize;
- float* navDVerts = (float*)d; d += detailVertsSize;
- unsigned char* navDTris = (unsigned char*)d; d += detailTrisSize;
-
- // Store header
- header->magic = DT_STAT_NAVMESH_MAGIC;
- header->version = DT_STAT_NAVMESH_VERSION;
- header->npolys = npolys;
- header->nverts = nverts;
- header->cs = cs;
- header->bmin[0] = bmin[0];
- header->bmin[1] = bmin[1];
- header->bmin[2] = bmin[2];
- header->bmax[0] = bmax[0];
- header->bmax[1] = bmax[1];
- header->bmax[2] = bmax[2];
- header->ndmeshes = npolys;
- header->ndverts = ndvertsuniq;
- header->ndtris = ndtris;
-
- // Store vertices
- for (int i = 0; i < nverts; ++i)
- {
- const unsigned short* iv = &vertsi[i*3];
- float* v = &navVerts[i*3];
- v[0] = bmin[0] + iv[0] * cs;
- v[1] = bmin[1] + iv[1] * cs;
- v[2] = bmin[2] + iv[2] * cs;
- }
- //memcpy(navVerts, vertices, nverts*3*sizeof(float));
-
- // Store polygons
- const unsigned short* src = polys;
- for (int i = 0; i < npolys; ++i)
- {
- dtStatPoly* p = &navPolys[i];
- p->nv = 0;
- for (int j = 0; j < vertsPerPoly; ++j)
- {
- if (src[j] == 0xffff) break;
- p->v[j] = src[j];
- p->n[j] = src[vertsPerPoly+j]+1;
- p->nv++;
- }
- src += vertsPerPoly*2;
- }
-
- header->nnodes = createBVTree(vertsi, nverts, polys, npolys, vertsPerPoly,
- cs, cs, npolys*2, navNodes);
-
-
- if (dmeshes==NULL)
- {
- //create fake detail meshes
- for (int i = 0; i < npolys; ++i)
- {
- dtStatPolyDetail& dtl = navDMeshes[i];
- dtl.vbase = 0;
- dtl.nverts = 0;
- dtl.tbase = i;
- dtl.ntris = 1;
- }
- // setup triangles.
- unsigned char* tri = navDTris;
- for (size_t i=0; i<ndtris; i++)
- {
- for (size_t j=0; j<3; j++)
- tri[4*i+j] = j;
- }
- }
- else
- {
- //verts
- memcpy(navDVerts, dvertices, ndvertsuniq*3*sizeof(float));
- //tris
- unsigned char* tri = navDTris;
- for (size_t i=0; i<ndtris; i++)
- {
- for (size_t j=0; j<3; j++)
- tri[4*i+j] = dtris[6*i+j];
- }
- //detailed meshes
- for (int i = 0; i < npolys; ++i)
- {
- dtStatPolyDetail& dtl = navDMeshes[i];
- dtl.vbase = dmeshes[i*4+0];
- dtl.nverts = dmeshes[i*4+1];
- dtl.tbase = dmeshes[i*4+2];
- dtl.ntris = dmeshes[i*4+3];
- }
- }
-
- m_navMesh = new dtStatNavMesh;
- m_navMesh->init(data, dataSize, true);
-
- delete [] vertices;
-
- /* navmesh conversion is using C guarded alloc for memory allocaitons */
- MEM_freeN(polys);
- if (dmeshes) MEM_freeN(dmeshes);
- if (dtris) MEM_freeN(dtris);
-
- if (dvertices)
- delete [] dvertices;
-
- if (vertsi)
- delete [] vertsi;
-
- return true;
-}
-
-dtStatNavMesh* KX_NavMeshObject::GetNavMesh()
-{
- return m_navMesh;
-}
-
-void KX_NavMeshObject::DrawNavMesh(NavMeshRenderMode renderMode)
-{
- if (!m_navMesh)
- return;
- MT_Vector3 color(0.f, 0.f, 0.f);
-
- switch (renderMode)
- {
- case RM_POLYS :
- case RM_WALLS :
- for (int pi=0; pi<m_navMesh->getPolyCount(); pi++)
- {
- const dtStatPoly* poly = m_navMesh->getPoly(pi);
-
- for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++)
- {
- if (poly->n[j] && renderMode==RM_WALLS)
- continue;
- const float* vif = m_navMesh->getVertex(poly->v[i]);
- const float* vjf = m_navMesh->getVertex(poly->v[j]);
- MT_Point3 vi(vif[0], vif[2], vif[1]);
- MT_Point3 vj(vjf[0], vjf[2], vjf[1]);
- vi = TransformToWorldCoords(vi);
- vj = TransformToWorldCoords(vj);
- KX_RasterizerDrawDebugLine(vi, vj, color);
- }
- }
- break;
- case RM_TRIS :
- for (int i = 0; i < m_navMesh->getPolyDetailCount(); ++i)
- {
- const dtStatPoly* p = m_navMesh->getPoly(i);
- const dtStatPolyDetail* pd = m_navMesh->getPolyDetail(i);
-
- for (int j = 0; j < pd->ntris; ++j)
- {
- const unsigned char* t = m_navMesh->getDetailTri(pd->tbase+j);
- MT_Point3 tri[3];
- for (int k = 0; k < 3; ++k)
- {
- const float* v;
- if (t[k] < p->nv)
- v = m_navMesh->getVertex(p->v[t[k]]);
- else
- v = m_navMesh->getDetailVertex(pd->vbase+(t[k]-p->nv));
- float pos[3];
- rcVcopy(pos, v);
- flipAxes(pos);
- tri[k].setValue(pos);
- }
-
- for (int k=0; k<3; k++)
- tri[k] = TransformToWorldCoords(tri[k]);
-
- for (int k=0; k<3; k++)
- KX_RasterizerDrawDebugLine(tri[k], tri[(k+1)%3], color);
- }
- }
- break;
- default:
- /* pass */
- break;
- }
-}
-
-MT_Point3 KX_NavMeshObject::TransformToLocalCoords(const MT_Point3& wpos)
-{
- MT_Matrix3x3 orientation = NodeGetWorldOrientation();
- const MT_Vector3& scaling = NodeGetWorldScaling();
- orientation.scale(scaling[0], scaling[1], scaling[2]);
- MT_Transform worldtr(NodeGetWorldPosition(), orientation);
- MT_Transform invworldtr;
- invworldtr.invert(worldtr);
- MT_Point3 lpos = invworldtr(wpos);
- return lpos;
-}
-
-MT_Point3 KX_NavMeshObject::TransformToWorldCoords(const MT_Point3& lpos)
-{
- MT_Matrix3x3 orientation = NodeGetWorldOrientation();
- const MT_Vector3& scaling = NodeGetWorldScaling();
- orientation.scale(scaling[0], scaling[1], scaling[2]);
- MT_Transform worldtr(NodeGetWorldPosition(), orientation);
- MT_Point3 wpos = worldtr(lpos);
- return wpos;
-}
-
-int KX_NavMeshObject::FindPath(const MT_Point3& from, const MT_Point3& to, float* path, int maxPathLen)
-{
- if (!m_navMesh)
- return 0;
- MT_Point3 localfrom = TransformToLocalCoords(from);
- MT_Point3 localto = TransformToLocalCoords(to);
- float spos[3], epos[3];
- localfrom.getValue(spos); flipAxes(spos);
- localto.getValue(epos); flipAxes(epos);
- dtStatPolyRef sPolyRef = m_navMesh->findNearestPoly(spos, polyPickExt);
- dtStatPolyRef ePolyRef = m_navMesh->findNearestPoly(epos, polyPickExt);
-
- int pathLen = 0;
- if (sPolyRef && ePolyRef)
- {
- dtStatPolyRef* polys = new dtStatPolyRef[maxPathLen];
- int npolys;
- npolys = m_navMesh->findPath(sPolyRef, ePolyRef, spos, epos, polys, maxPathLen);
- if (npolys)
- {
- pathLen = m_navMesh->findStraightPath(spos, epos, polys, npolys, path, maxPathLen);
- for (int i=0; i<pathLen; i++)
- {
- flipAxes(&path[i*3]);
- MT_Point3 waypoint(&path[i*3]);
- waypoint = TransformToWorldCoords(waypoint);
- waypoint.getValue(&path[i*3]);
- }
- }
-
- delete[] polys;
- }
-
- return pathLen;
-}
-
-float KX_NavMeshObject::Raycast(const MT_Point3& from, const MT_Point3& to)
-{
- if (!m_navMesh)
- return 0.f;
- MT_Point3 localfrom = TransformToLocalCoords(from);
- MT_Point3 localto = TransformToLocalCoords(to);
- float spos[3], epos[3];
- localfrom.getValue(spos); flipAxes(spos);
- localto.getValue(epos); flipAxes(epos);
- dtStatPolyRef sPolyRef = m_navMesh->findNearestPoly(spos, polyPickExt);
- float t=0;
- static dtStatPolyRef polys[MAX_PATH_LEN];
- m_navMesh->raycast(sPolyRef, spos, epos, t, polys, MAX_PATH_LEN);
- return t;
-}
-
-void KX_NavMeshObject::DrawPath(const float *path, int pathLen, const MT_Vector3& color)
-{
- MT_Vector3 a,b;
- for (int i=0; i<pathLen-1; i++)
- {
- a.setValue(&path[3*i]);
- b.setValue(&path[3*(i+1)]);
- KX_RasterizerDrawDebugLine(a, b, color);
- }
-}
-
-
-#ifdef WITH_PYTHON
-//----------------------------------------------------------------------------
-//Python
-
-PyTypeObject KX_NavMeshObject::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_NavMeshObject",
- 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,
- &KX_GameObject::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyAttributeDef KX_NavMeshObject::Attributes[] = {
- { NULL } //Sentinel
-};
-
-//KX_PYMETHODTABLE_NOARGS(KX_GameObject, getD),
-PyMethodDef KX_NavMeshObject::Methods[] = {
- KX_PYMETHODTABLE(KX_NavMeshObject, findPath),
- KX_PYMETHODTABLE(KX_NavMeshObject, raycast),
- KX_PYMETHODTABLE(KX_NavMeshObject, draw),
- KX_PYMETHODTABLE(KX_NavMeshObject, rebuild),
- {NULL,NULL} //Sentinel
-};
-
-KX_PYMETHODDEF_DOC(KX_NavMeshObject, findPath,
- "findPath(start, goal): find path from start to goal points\n"
- "Returns a path as list of points)\n")
-{
- PyObject *ob_from, *ob_to;
- if (!PyArg_ParseTuple(args,"OO:getPath",&ob_from,&ob_to))
- return NULL;
- MT_Point3 from, to;
- if (!PyVecTo(ob_from, from) || !PyVecTo(ob_to, to))
- return NULL;
-
- float path[MAX_PATH_LEN*3];
- int pathLen = FindPath(from, to, path, MAX_PATH_LEN);
- PyObject *pathList = PyList_New( pathLen );
- for (int i=0; i<pathLen; i++)
- {
- MT_Point3 point(&path[3*i]);
- PyList_SET_ITEM(pathList, i, PyObjectFrom(point));
- }
-
- return pathList;
-}
-
-KX_PYMETHODDEF_DOC(KX_NavMeshObject, raycast,
- "raycast(start, goal): raycast from start to goal points\n"
- "Returns hit factor)\n")
-{
- PyObject *ob_from, *ob_to;
- if (!PyArg_ParseTuple(args,"OO:getPath",&ob_from,&ob_to))
- return NULL;
- MT_Point3 from, to;
- if (!PyVecTo(ob_from, from) || !PyVecTo(ob_to, to))
- return NULL;
- float hit = Raycast(from, to);
- return PyFloat_FromDouble(hit);
-}
-
-KX_PYMETHODDEF_DOC(KX_NavMeshObject, draw,
- "draw(mode): navigation mesh debug drawing\n"
- "mode: WALLS, POLYS, TRIS\n")
-{
- int arg;
- NavMeshRenderMode renderMode = RM_TRIS;
- if (PyArg_ParseTuple(args,"i:rebuild",&arg) && arg>=0 && arg<RM_MAX)
- renderMode = (NavMeshRenderMode)arg;
- DrawNavMesh(renderMode);
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_NavMeshObject, rebuild,
- "rebuild(): rebuild navigation mesh\n")
-{
- BuildNavMesh();
- Py_RETURN_NONE;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.h b/source/gameengine/Ketsji/KX_NavMeshObject.h
deleted file mode 100644
index af178f9aaee..00000000000
--- a/source/gameengine/Ketsji/KX_NavMeshObject.h
+++ /dev/null
@@ -1,80 +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 *****
- */
-#ifndef __KX_NAVMESHOBJECT_H__
-#define __KX_NAVMESHOBJECT_H__
-#include "DetourStatNavMesh.h"
-#include "KX_GameObject.h"
-#include "EXP_PyObjectPlus.h"
-#include <vector>
-
-class RAS_MeshObject;
-class MT_Transform;
-
-class KX_NavMeshObject: public KX_GameObject
-{
- Py_Header
-
-protected:
- dtStatNavMesh* m_navMesh;
-
- bool BuildVertIndArrays(float *&vertices, int& nverts,
- unsigned short* &polys, int& npolys, unsigned short *&dmeshes,
- float *&dvertices, int &ndvertsuniq, unsigned short* &dtris,
- int& ndtris, int &vertsPerPoly);
-
-public:
- KX_NavMeshObject(void* sgReplicationInfo, SG_Callbacks callbacks);
- ~KX_NavMeshObject();
-
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
-
-
- bool BuildNavMesh();
- dtStatNavMesh* GetNavMesh();
- int FindPath(const MT_Point3& from, const MT_Point3& to, float* path, int maxPathLen);
- float Raycast(const MT_Point3& from, const MT_Point3& to);
-
- enum NavMeshRenderMode {RM_WALLS, RM_POLYS, RM_TRIS, RM_MAX};
- void DrawNavMesh(NavMeshRenderMode mode);
- void DrawPath(const float *path, int pathLen, const MT_Vector3& color);
-
- MT_Point3 TransformToLocalCoords(const MT_Point3& wpos);
- MT_Point3 TransformToWorldCoords(const MT_Point3& lpos);
-#ifdef WITH_PYTHON
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- KX_PYMETHOD_DOC(KX_NavMeshObject, findPath);
- KX_PYMETHOD_DOC(KX_NavMeshObject, raycast);
- KX_PYMETHOD_DOC(KX_NavMeshObject, draw);
- KX_PYMETHOD_DOC_NOARGS(KX_NavMeshObject, rebuild);
-#endif /* WITH_PYTHON */
-};
-
-#endif /* __KX_NAVMESHOBJECT_H__ */
diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp
deleted file mode 100644
index 92ab8f412d9..00000000000
--- a/source/gameengine/Ketsji/KX_NearSensor.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Sense if other objects are near
- *
- *
- * ***** 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_NearSensor.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_NearSensor.h"
-#include "SCA_LogicManager.h"
-#include "KX_GameObject.h"
-#include "KX_TouchEventManager.h"
-#include "KX_Scene.h" // needed to create a replica
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_IPhysicsController.h"
-#include "PHY_IMotionState.h"
-
-KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
- KX_GameObject* gameobj,
- float margin,
- float resetmargin,
- bool bFindMaterial,
- const STR_String& touchedpropname,
- PHY_IPhysicsController* ctrl)
- :KX_TouchSensor(eventmgr,
- gameobj,
- bFindMaterial,
- false,
- touchedpropname),
- m_Margin(margin),
- m_ResetMargin(resetmargin)
-
-{
-
- gameobj->getClientInfo()->m_sensors.remove(this);
- m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::SENSOR);
- m_client_info->m_sensors.push_back(this);
-
- //DT_ShapeHandle shape = (DT_ShapeHandle) vshape;
- m_physCtrl = ctrl;
- if (m_physCtrl)
- {
- m_physCtrl->SetMargin(m_Margin);
- m_physCtrl->SetNewClientInfo(m_client_info);
- }
- SynchronizeTransform();
-}
-
-void KX_NearSensor::SynchronizeTransform()
-{
- // The near and radar sensors are using a different physical object which is
- // not linked to the parent object, must synchronize it.
- if (m_physCtrl)
- {
- PHY_IMotionState* motionState = m_physCtrl->GetMotionState();
- KX_GameObject* parent = ((KX_GameObject*)GetParent());
- const MT_Point3& pos = parent->NodeGetWorldPosition();
- float ori[12];
- parent->NodeGetWorldOrientation().getValue(ori);
- motionState->SetWorldPosition(pos[0], pos[1], pos[2]);
- motionState->SetWorldOrientation(ori);
- m_physCtrl->WriteMotionStateToDynamics(true);
- }
-}
-
-CValue* KX_NearSensor::GetReplica()
-{
- KX_NearSensor* replica = new KX_NearSensor(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_NearSensor::ProcessReplica()
-{
- KX_TouchSensor::ProcessReplica();
-
- m_client_info = new KX_ClientObjectInfo(m_client_info->m_gameobject, KX_ClientObjectInfo::SENSOR);
-
- if (m_physCtrl)
- {
- 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);
- }
-
- }
-}
-
-void KX_NearSensor::ReParent(SCA_IObject* parent)
-{
- SCA_ISensor::ReParent(parent);
- m_client_info->m_gameobject = static_cast<KX_GameObject*>(parent);
- m_client_info->m_sensors.push_back(this);
- //Synchronize here with the actual parent.
- SynchronizeTransform();
-}
-
-
-
-KX_NearSensor::~KX_NearSensor()
-{
- // for nearsensor, the sensor is the 'owner' of sumoobj
- // for touchsensor, it's the parent
- if (m_physCtrl)
- {
- //static_cast<KX_TouchEventManager*>(m_eventmgr)->GetPhysicsEnvironment()->removeSensor(m_physCtrl);
- delete m_physCtrl;
- m_physCtrl = NULL;
- }
-
-
- if (m_client_info)
- delete m_client_info;
-}
-
-void KX_NearSensor::SetPhysCtrlRadius()
-{
- if (m_bTriggered)
- {
- if (m_physCtrl)
- {
- m_physCtrl->SetRadius(m_ResetMargin);
- }
- } else
- {
- if (m_physCtrl)
- {
- m_physCtrl->SetRadius(m_Margin);
- }
- }
-}
-
-bool KX_NearSensor::Evaluate()
-{
- bool result = false;
-// KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent());
-
- if (m_bTriggered != m_bLastTriggered)
- {
- m_bLastTriggered = m_bTriggered;
-
- SetPhysCtrlRadius();
-
- result = true;
- }
-
- return result;
-}
-
-// this function is called at broad phase stage to check if the two controller
-// need to interact at all. It is used for Near/Radar sensor that don't need to
-// check collision with object not included in filter
-bool KX_NearSensor::BroadPhaseFilterCollision(void*obj1,void*obj2)
-{
- KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent());
-
- // 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_GameObject* gameobj = ( client_info ?
- client_info->m_gameobject :
- NULL);
-
- if (gameobj && (gameobj != parent))
- {
- // only take valid colliders
- if (client_info->m_type == KX_ClientObjectInfo::ACTOR)
- {
- if ((m_touchedpropname.Length() == 0) ||
- (gameobj->GetProperty(m_touchedpropname)))
- {
- return true;
- }
- }
- }
-
- return false;
-}
-
-bool KX_NearSensor::NewHandleCollision(void *obj1, void *obj2, const PHY_CollData *coll_data)
-{
-// KX_TouchEventManager* toucheventmgr = static_cast<KX_TouchEventManager*>(m_eventmgr);
-// KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent());
-
- // 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());
-
- KX_GameObject* gameobj = ( client_info ?
- client_info->m_gameobject :
- NULL);
-
- // Add the same check as in SCA_ISensor::Activate(),
- // we don't want to record collision when the sensor is not active.
- if (m_links && !m_suspended &&
- gameobj /* done in BroadPhaseFilterCollision() && (gameobj != parent)*/)
- {
- if (!m_colliders->SearchValue(gameobj))
- m_colliders->Add(gameobj->AddRef());
- // only take valid colliders
- // These checks are done already in BroadPhaseFilterCollision()
- //if (client_info->m_type == KX_ClientObjectInfo::ACTOR)
- //{
- // if ((m_touchedpropname.Length() == 0) ||
- // (gameobj->GetProperty(m_touchedpropname)))
- // {
- m_bTriggered = true;
- m_hitObject = gameobj;
- // }
- //}
- }
-
- return false; // was DT_CONTINUE; but this was defined in Sumo as false
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python Functions */
-/* ------------------------------------------------------------------------- */
-
-/* ------------------------------------------------------------------------- */
-/* Python Integration Hooks */
-/* ------------------------------------------------------------------------- */
-
-PyTypeObject KX_NearSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_NearSensor",
- 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,
- &KX_TouchSensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_NearSensor::Methods[] = {
- //No methods
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_NearSensor::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_RW_CHECK("distance", 0, 10000, KX_NearSensor, m_Margin, CheckResetDistance),
- KX_PYATTRIBUTE_FLOAT_RW_CHECK("resetDistance", 0, 10000, KX_NearSensor, m_ResetMargin, CheckResetDistance),
- {NULL} //Sentinel
-};
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h
deleted file mode 100644
index ef6e15f602f..00000000000
--- a/source/gameengine/Ketsji/KX_NearSensor.h
+++ /dev/null
@@ -1,107 +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_NearSensor.h
- * \ingroup ketsji
- * \brief Sense if other objects are near
- */
-
-#ifndef __KX_NEARSENSOR_H__
-#define __KX_NEARSENSOR_H__
-
-#include "KX_TouchSensor.h"
-#include "KX_ClientObjectInfo.h"
-
-class KX_Scene;
-struct PHY_CollData;
-
-class KX_NearSensor : public KX_TouchSensor
-{
- Py_Header
-protected:
- float m_Margin;
- float m_ResetMargin;
-
- KX_ClientObjectInfo* m_client_info;
-public:
- KX_NearSensor(class SCA_EventManager* eventmgr,
- class KX_GameObject* gameobj,
- float margin,
- float resetmargin,
- bool bFindMaterial,
- const STR_String& touchedpropname,
- PHY_IPhysicsController* ctrl);
-#if 0
-public:
- KX_NearSensor(class SCA_EventManager* eventmgr,
- class KX_GameObject* gameobj,
- double margin,
- double resetmargin,
- bool bFindMaterial,
- const STR_String& touchedpropname,
- class KX_Scene* scene);
-#endif
- virtual ~KX_NearSensor();
- virtual void SynchronizeTransform();
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
- virtual void SetPhysCtrlRadius();
- virtual bool Evaluate();
-
- virtual void ReParent(SCA_IObject* parent);
- virtual bool NewHandleCollision(void* obj1,void* obj2,
- const PHY_CollData * coll_data);
- virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2);
- virtual bool BroadPhaseSensorFilterCollision(void* obj1,void* obj2) { return false; }
- virtual sensortype GetSensorType() { return ST_NEAR; }
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- //No methods
-
- //This method is used to make sure the distance does not exceed the reset distance
- static int CheckResetDistance(void *self, const PyAttributeDef*)
- {
- KX_NearSensor* sensor = reinterpret_cast<KX_NearSensor*>(self);
-
- if (sensor->m_Margin > sensor->m_ResetMargin)
- sensor->m_ResetMargin = sensor->m_Margin;
-
- sensor->SetPhysCtrlRadius();
-
- return 0;
- }
-
-#endif /* WITH_PYTHON */
-
-};
-
-#endif /* __KX_NEARSENSOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp b/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp
deleted file mode 100644
index 7f81f221c07..00000000000
--- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp
+++ /dev/null
@@ -1,110 +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_ObColorIpoSGController.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_ObColorIpoSGController.h"
-#include "KX_ScalarInterpolator.h"
-#include "KX_GameObject.h"
-
-#if defined(_WIN64)
-typedef unsigned __int64 uint_ptr;
-#else
-typedef unsigned long uint_ptr;
-#endif
-
-
-bool KX_ObColorIpoSGController::Update(double currentTime)
-{
- if (m_modified)
- {
- SG_Spatial* ob = (SG_Spatial*)m_pObject;
- KX_GameObject* kxgameobj= (KX_GameObject*) ob->GetSGClientObject();
-
- m_rgba = kxgameobj->GetObjectColor();
-
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- (*i)->Execute(m_ipotime);
- }
-
-
- kxgameobj->SetObjectColor(m_rgba);
-
-
- m_modified=false;
- }
- return false;
-}
-
-
-void KX_ObColorIpoSGController::AddInterpolator(KX_IInterpolator* interp)
-{
- this->m_interpolators.push_back(interp);
-}
-
-SG_Controller* KX_ObColorIpoSGController::GetReplica(class SG_Node* destnode)
-{
- KX_ObColorIpoSGController* iporeplica = new KX_ObColorIpoSGController(*this);
- // clear object that ipo acts on
- iporeplica->ClearObject();
-
- // dirty hack, ask Gino for a better solution in the ipo implementation
- // hacken en zagen, in what we call datahiding, not written for replication :(
-
- T_InterpolatorList oldlist = m_interpolators;
- iporeplica->m_interpolators.clear();
-
- T_InterpolatorList::iterator i;
- for (i = oldlist.begin(); !(i == oldlist.end()); ++i) {
- KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i));
- iporeplica->AddInterpolator(copyipo);
-
- MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
- uint_ptr orgbase = (uint_ptr)this;
- uint_ptr orgloc = (uint_ptr)scaal;
- uint_ptr offset = orgloc-orgbase;
- uint_ptr newaddrbase = (uint_ptr)iporeplica + offset;
- MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
- copyipo->SetNewTarget((MT_Scalar*)blaptr);
- }
-
- return iporeplica;
-}
-
-KX_ObColorIpoSGController::~KX_ObColorIpoSGController()
-{
-
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- delete (*i);
- }
-
-}
diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h
deleted file mode 100644
index a7b0b2c4ffc..00000000000
--- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h
+++ /dev/null
@@ -1,80 +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_ObColorIpoSGController.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_OBCOLORIPOSGCONTROLLER_H__
-#define __KX_OBCOLORIPOSGCONTROLLER_H__
-
-#include "SG_Controller.h"
-#include "SG_Spatial.h"
-#include "KX_IInterpolator.h"
-
-class KX_ObColorIpoSGController : public SG_Controller
-{
-public:
- MT_Vector4 m_rgba;
-
-
-private:
- T_InterpolatorList m_interpolators;
- bool m_modified;
-
- double m_ipotime;
-public:
- KX_ObColorIpoSGController() :
- m_modified(true),
- m_ipotime(0.0)
- {}
- virtual ~KX_ObColorIpoSGController();
- virtual SG_Controller* GetReplica(class SG_Node* destnode);
- virtual bool Update(double time);
- virtual void SetSimulatedTime(double time) {
- m_ipotime = time;
- m_modified = true;
- }
-
- void
- SetOption(
- int option,
- int value
- ) {
- // intentionally empty
- };
-
-
- void AddInterpolator(KX_IInterpolator* interp);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ObColorIpoSGController")
-#endif
-};
-
-#endif /* __KX_OBCOLORIPOSGCONTROLLER_H__ */
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
deleted file mode 100644
index 8c1dee7940f..00000000000
--- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp
+++ /dev/null
@@ -1,709 +0,0 @@
-/*
- * Do translation/rotation actions
- *
- *
- * ***** 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_ObjectActuator.cpp
- * \ingroup ketsji
- */
-
-#include <stdio.h>
-
-#include "KX_ObjectActuator.h"
-#include "KX_GameObject.h"
-#include "KX_PyMath.h" // For PyVecTo - should this include be put in PyObjectPlus?
-#include "PHY_IPhysicsController.h"
-#include "PHY_ICharacter.h"
-#include "PHY_IPhysicsEnvironment.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_ObjectActuator::
-KX_ObjectActuator(
- SCA_IObject* gameobj,
- KX_GameObject* refobj,
- const MT_Vector3& force,
- const MT_Vector3& torque,
- const MT_Vector3& dloc,
- const MT_Vector3& drot,
- const MT_Vector3& linV,
- const MT_Vector3& angV,
- const short damping,
- const KX_LocalFlags& flag
-) :
- SCA_IActuator(gameobj, KX_ACT_OBJECT),
- m_force(force),
- m_torque(torque),
- m_dloc(dloc),
- m_drot(drot),
- m_linear_velocity(linV),
- m_angular_velocity(angV),
- m_linear_length2(0.0f),
- m_current_linear_factor(0.0f),
- m_current_angular_factor(0.0f),
- m_damping(damping),
- m_previous_error(0.0f,0.0f,0.0f),
- m_error_accumulator(0.0f,0.0f,0.0f),
- m_bitLocalFlag (flag),
- m_reference(refobj),
- m_active_combined_velocity (false),
- m_linear_damping_active(false),
- m_angular_damping_active(false),
- m_jumping(false)
-{
- if (m_bitLocalFlag.ServoControl)
- {
- // in servo motion, the force is local if the target velocity is local
- m_bitLocalFlag.Force = m_bitLocalFlag.LinearVelocity;
-
- m_pid = m_torque;
- }
- if (m_bitLocalFlag.CharacterMotion)
- {
- KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent());
- PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent);
-
- if (!character)
- {
- printf("Character motion enabled on non-character object (%s), falling back to simple motion.\n", parent->GetName().Ptr());
- m_bitLocalFlag.CharacterMotion = false;
- }
- }
- if (m_reference)
- m_reference->RegisterActuator(this);
- UpdateFuzzyFlags();
-}
-
-KX_ObjectActuator::~KX_ObjectActuator()
-{
- if (m_reference)
- m_reference->UnregisterActuator(this);
-}
-
-bool KX_ObjectActuator::Update()
-{
-
- bool bNegativeEvent = IsNegativeEvent();
- 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
- // the physics controller that we no longer wish to apply it and that
- // it should reconcile the externally set velocity with it's
- // own velocity.
- if (m_active_combined_velocity) {
- if (parent)
- parent->ResolveCombinedVelocities(
- m_linear_velocity,
- m_angular_velocity,
- (m_bitLocalFlag.LinearVelocity) != 0,
- (m_bitLocalFlag.AngularVelocity) != 0
- );
- m_active_combined_velocity = false;
- }
-
- // Explicitly stop the movement if we're using character motion
- if (m_bitLocalFlag.CharacterMotion) {
- character->SetWalkDirection(MT_Vector3 (0.0f, 0.0f, 0.0f));
- }
-
- m_linear_damping_active = false;
- m_angular_damping_active = false;
- m_error_accumulator.setValue(0.0f,0.0f,0.0f);
- m_previous_error.setValue(0.0f,0.0f,0.0f);
- m_jumping = false;
- return false;
-
- } else if (parent)
- {
- if (m_bitLocalFlag.ServoControl)
- {
- // In this mode, we try to reach a target speed using force
- // As we don't know the friction, we must implement a generic
- // servo control to achieve the speed in a configurable
- // v = current velocity
- // V = target velocity
- // e = V-v = speed error
- // dt = time interval since previous update
- // I = sum(e(t)*dt)
- // dv = e(t) - e(t-1)
- // KP, KD, KI : coefficient
- // F = KP*e+KI*I+KD*dv
- MT_Scalar mass = parent->GetMass();
- if (mass < MT_EPSILON)
- return false;
- MT_Vector3 v = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity);
- if (m_reference)
- {
- const MT_Point3& mypos = parent->NodeGetWorldPosition();
- const MT_Point3& refpos = m_reference->NodeGetWorldPosition();
- MT_Point3 relpos;
- relpos = (mypos-refpos);
- MT_Vector3 vel= m_reference->GetVelocity(relpos);
- if (m_bitLocalFlag.LinearVelocity)
- // must convert in local space
- vel = parent->NodeGetWorldOrientation().transposed()*vel;
- v -= vel;
- }
- MT_Vector3 e = m_linear_velocity - v;
- MT_Vector3 dv = e - m_previous_error;
- MT_Vector3 I = m_error_accumulator + e;
-
- m_force = m_pid.x()*e+m_pid.y()*I+m_pid.z()*dv;
- // to automatically adapt the PID coefficient to mass;
- m_force *= mass;
- if (m_bitLocalFlag.Torque)
- {
- if (m_force[0] > m_dloc[0])
- {
- m_force[0] = m_dloc[0];
- I[0] = m_error_accumulator[0];
- } else if (m_force[0] < m_drot[0])
- {
- m_force[0] = m_drot[0];
- I[0] = m_error_accumulator[0];
- }
- }
- if (m_bitLocalFlag.DLoc)
- {
- if (m_force[1] > m_dloc[1])
- {
- m_force[1] = m_dloc[1];
- I[1] = m_error_accumulator[1];
- } else if (m_force[1] < m_drot[1])
- {
- m_force[1] = m_drot[1];
- I[1] = m_error_accumulator[1];
- }
- }
- if (m_bitLocalFlag.DRot)
- {
- if (m_force[2] > m_dloc[2])
- {
- m_force[2] = m_dloc[2];
- I[2] = m_error_accumulator[2];
- } else if (m_force[2] < m_drot[2])
- {
- m_force[2] = m_drot[2];
- I[2] = m_error_accumulator[2];
- }
- }
- m_previous_error = e;
- m_error_accumulator = I;
- parent->ApplyForce(m_force,(m_bitLocalFlag.LinearVelocity) != 0);
- }
- else if (m_bitLocalFlag.CharacterMotion) {
- MT_Vector3 dir = m_dloc;
-
- if (m_bitLocalFlag.DLoc) {
- MT_Matrix3x3 basis = parent->GetPhysicsController()->GetOrientation();
- dir = basis * dir;
- }
-
- if (m_bitLocalFlag.AddOrSetCharLoc) {
- MT_Vector3 old_dir = character->GetWalkDirection();
-
- if (!old_dir.fuzzyZero()) {
- MT_Scalar mag = old_dir.length();
-
- dir = dir + old_dir;
- if (!dir.fuzzyZero())
- dir = dir.normalized() * mag;
- }
- }
-
- // We always want to set the walk direction since a walk direction of (0, 0, 0) should stop the character
- character->SetWalkDirection(dir/parent->GetScene()->GetPhysicsEnvironment()->GetNumTimeSubSteps());
-
- if (!m_bitLocalFlag.ZeroDRot)
- {
- parent->ApplyRotation(m_drot,(m_bitLocalFlag.DRot) != 0);
- }
-
- if (m_bitLocalFlag.CharacterJump) {
- if (!m_jumping) {
- character->Jump();
- m_jumping = true;
- }
- else if (character->OnGround())
- m_jumping = false;
- }
- }
- else {
- if (!m_bitLocalFlag.ZeroForce)
- {
- parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0);
- }
- if (!m_bitLocalFlag.ZeroTorque)
- {
- parent->ApplyTorque(m_torque,(m_bitLocalFlag.Torque) != 0);
- }
- if (!m_bitLocalFlag.ZeroDLoc)
- {
- parent->ApplyMovement(m_dloc,(m_bitLocalFlag.DLoc) != 0);
- }
- if (!m_bitLocalFlag.ZeroDRot)
- {
- parent->ApplyRotation(m_drot,(m_bitLocalFlag.DRot) != 0);
- }
- if (!m_bitLocalFlag.ZeroLinearVelocity)
- {
- if (m_bitLocalFlag.AddOrSetLinV) {
- parent->addLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0);
- } else {
- m_active_combined_velocity = true;
- if (m_damping > 0) {
- MT_Vector3 linV;
- if (!m_linear_damping_active) {
- // delta and the start speed (depends on the existing speed in that direction)
- linV = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity);
- // keep only the projection along the desired direction
- m_current_linear_factor = linV.dot(m_linear_velocity)/m_linear_length2;
- m_linear_damping_active = true;
- }
- if (m_current_linear_factor < 1.0f)
- m_current_linear_factor += 1.0f/m_damping;
- if (m_current_linear_factor > 1.0f)
- m_current_linear_factor = 1.0f;
- linV = m_current_linear_factor * m_linear_velocity;
- parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0);
- } else {
- parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0);
- }
- }
- }
- if (!m_bitLocalFlag.ZeroAngularVelocity)
- {
- m_active_combined_velocity = true;
- if (m_damping > 0) {
- MT_Vector3 angV;
- if (!m_angular_damping_active) {
- // delta and the start speed (depends on the existing speed in that direction)
- angV = parent->GetAngularVelocity(m_bitLocalFlag.AngularVelocity);
- // keep only the projection along the desired direction
- m_current_angular_factor = angV.dot(m_angular_velocity)/m_angular_length2;
- m_angular_damping_active = true;
- }
- if (m_current_angular_factor < 1.0f)
- m_current_angular_factor += 1.0f/m_damping;
- if (m_current_angular_factor > 1.0f)
- m_current_angular_factor = 1.0f;
- angV = m_current_angular_factor * m_angular_velocity;
- parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0);
- } else {
- parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0);
- }
- }
- }
-
- }
- return true;
-}
-
-
-
-CValue* KX_ObjectActuator::GetReplica()
-{
- KX_ObjectActuator* replica = new KX_ObjectActuator(*this);//m_float,GetName());
- replica->ProcessReplica();
-
- return replica;
-}
-
-void KX_ObjectActuator::ProcessReplica()
-{
- SCA_IActuator::ProcessReplica();
- if (m_reference)
- m_reference->RegisterActuator(this);
-}
-
-bool KX_ObjectActuator::UnlinkObject(SCA_IObject* clientobj)
-{
- if (clientobj == (SCA_IObject*)m_reference)
- {
- // this object is being deleted, we cannot continue to use it as reference.
- m_reference = NULL;
- return true;
- }
- return false;
-}
-
-void KX_ObjectActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_reference];
- if (h_obj) {
- if (m_reference)
- m_reference->UnregisterActuator(this);
- m_reference = (KX_GameObject*)(*h_obj);
- m_reference->RegisterActuator(this);
- }
-}
-
-/* some 'standard' utilities... */
-bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type)
-{
- bool res = false;
- res = (type > KX_OBJECT_ACT_NODEF) && (type < KX_OBJECT_ACT_MAX);
- return res;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_ObjectActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_ObjectActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_ObjectActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_ObjectActuator::Attributes[] = {
- KX_PYATTRIBUTE_VECTOR_RW_CHECK("force", -1000, 1000, false, KX_ObjectActuator, m_force, PyUpdateFuzzyFlags),
- KX_PYATTRIBUTE_BOOL_RW("useLocalForce", KX_ObjectActuator, m_bitLocalFlag.Force),
- KX_PYATTRIBUTE_VECTOR_RW_CHECK("torque", -1000, 1000, false, KX_ObjectActuator, m_torque, PyUpdateFuzzyFlags),
- KX_PYATTRIBUTE_BOOL_RW("useLocalTorque", KX_ObjectActuator, m_bitLocalFlag.Torque),
- KX_PYATTRIBUTE_VECTOR_RW_CHECK("dLoc", -1000, 1000, false, KX_ObjectActuator, m_dloc, PyUpdateFuzzyFlags),
- KX_PYATTRIBUTE_BOOL_RW("useLocalDLoc", KX_ObjectActuator, m_bitLocalFlag.DLoc),
- KX_PYATTRIBUTE_VECTOR_RW_CHECK("dRot", -1000, 1000, false, KX_ObjectActuator, m_drot, PyUpdateFuzzyFlags),
- KX_PYATTRIBUTE_BOOL_RW("useLocalDRot", KX_ObjectActuator, m_bitLocalFlag.DRot),
-#ifdef USE_MATHUTILS
- KX_PYATTRIBUTE_RW_FUNCTION("linV", KX_ObjectActuator, pyattr_get_linV, pyattr_set_linV),
- KX_PYATTRIBUTE_RW_FUNCTION("angV", KX_ObjectActuator, pyattr_get_angV, pyattr_set_angV),
-#else
- KX_PYATTRIBUTE_VECTOR_RW_CHECK("linV", -1000, 1000, false, KX_ObjectActuator, m_linear_velocity, PyUpdateFuzzyFlags),
- KX_PYATTRIBUTE_VECTOR_RW_CHECK("angV", -1000, 1000, false, KX_ObjectActuator, m_angular_velocity, PyUpdateFuzzyFlags),
-#endif
- KX_PYATTRIBUTE_BOOL_RW("useLocalLinV", KX_ObjectActuator, m_bitLocalFlag.LinearVelocity),
- KX_PYATTRIBUTE_BOOL_RW("useLocalAngV", KX_ObjectActuator, m_bitLocalFlag.AngularVelocity),
- KX_PYATTRIBUTE_SHORT_RW("damping", 0, 1000, false, KX_ObjectActuator, m_damping),
- KX_PYATTRIBUTE_RW_FUNCTION("forceLimitX", KX_ObjectActuator, pyattr_get_forceLimitX, pyattr_set_forceLimitX),
- KX_PYATTRIBUTE_RW_FUNCTION("forceLimitY", KX_ObjectActuator, pyattr_get_forceLimitY, pyattr_set_forceLimitY),
- KX_PYATTRIBUTE_RW_FUNCTION("forceLimitZ", KX_ObjectActuator, pyattr_get_forceLimitZ, pyattr_set_forceLimitZ),
- KX_PYATTRIBUTE_VECTOR_RW_CHECK("pid", -100, 200, true, KX_ObjectActuator, m_pid, PyCheckPid),
- KX_PYATTRIBUTE_RW_FUNCTION("reference", KX_ObjectActuator,pyattr_get_reference,pyattr_set_reference),
- { NULL } //Sentinel
-};
-
-/* Attribute get/set functions */
-
-#ifdef USE_MATHUTILS
-
-/* These require an SGNode */
-#define MATHUTILS_VEC_CB_LINV 1
-#define MATHUTILS_VEC_CB_ANGV 2
-
-static unsigned char mathutils_kxobactu_vector_cb_index = -1; /* index for our callbacks */
-
-static int mathutils_obactu_generic_check(BaseMathObject *bmo)
-{
- KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
- return 0;
-}
-
-static int mathutils_obactu_vector_get(BaseMathObject *bmo, int subtype)
-{
- KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
- switch (subtype) {
- case MATHUTILS_VEC_CB_LINV:
- self->m_linear_velocity.getValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_ANGV:
- self->m_angular_velocity.getValue(bmo->data);
- break;
- }
-
- return 0;
-}
-
-static int mathutils_obactu_vector_set(BaseMathObject *bmo, int subtype)
-{
- KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
- switch (subtype) {
- case MATHUTILS_VEC_CB_LINV:
- self->m_linear_velocity.setValue(bmo->data);
- break;
- case MATHUTILS_VEC_CB_ANGV:
- self->m_angular_velocity.setValue(bmo->data);
- break;
- }
-
- return 0;
-}
-
-static int mathutils_obactu_vector_get_index(BaseMathObject *bmo, int subtype, int index)
-{
- /* lazy, avoid repeteing the case statement */
- if (mathutils_obactu_vector_get(bmo, subtype) == -1)
- return -1;
- return 0;
-}
-
-static int mathutils_obactu_vector_set_index(BaseMathObject *bmo, int subtype, int index)
-{
- float f = bmo->data[index];
-
- /* lazy, avoid repeteing the case statement */
- if (mathutils_obactu_vector_get(bmo, subtype) == -1)
- return -1;
-
- bmo->data[index] = f;
- return mathutils_obactu_vector_set(bmo, subtype);
-}
-
-static Mathutils_Callback mathutils_obactu_vector_cb = {
- mathutils_obactu_generic_check,
- mathutils_obactu_vector_get,
- mathutils_obactu_vector_set,
- mathutils_obactu_vector_get_index,
- mathutils_obactu_vector_set_index
-};
-
-PyObject *KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV);
-}
-
-int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>(self_v);
- if (!PyVecTo(value, self->m_linear_velocity))
- return PY_SET_ATTR_FAIL;
-
- self->UpdateFuzzyFlags();
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- return Vector_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v), 3,
- mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV);
-}
-
-int KX_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>(self_v);
- if (!PyVecTo(value, self->m_angular_velocity))
- return PY_SET_ATTR_FAIL;
-
- self->UpdateFuzzyFlags();
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-
-void KX_ObjectActuator_Mathutils_Callback_Init(void)
-{
- // register mathutils callbacks, ok to run more than once.
- mathutils_kxobactu_vector_cb_index = Mathutils_RegisterCallback(&mathutils_obactu_vector_cb);
-}
-
-#endif // USE_MATHUTILS
-
-PyObject *KX_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
- PyObject *retVal = PyList_New(3);
-
- PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[0]));
- PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[0]));
- PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.Torque));
-
- return retVal;
-}
-
-int KX_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
-
- PyObject *seq = PySequence_Fast(value, "");
- if (seq && PySequence_Fast_GET_SIZE(seq) == 3)
- {
- self->m_drot[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
- self->m_dloc[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
- self->m_bitLocalFlag.Torque = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0);
-
- if (!PyErr_Occurred())
- {
- Py_DECREF(seq);
- return PY_SET_ATTR_SUCCESS;
- }
- }
-
- Py_XDECREF(seq);
-
- PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool");
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_ObjectActuator::pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
- PyObject *retVal = PyList_New(3);
-
- PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[1]));
- PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[1]));
- PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DLoc));
-
- return retVal;
-}
-
-int KX_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
-
- PyObject *seq = PySequence_Fast(value, "");
- if (seq && PySequence_Fast_GET_SIZE(seq) == 3)
- {
- self->m_drot[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
- self->m_dloc[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
- self->m_bitLocalFlag.DLoc = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0);
-
- if (!PyErr_Occurred())
- {
- Py_DECREF(seq);
- return PY_SET_ATTR_SUCCESS;
- }
- }
-
- Py_XDECREF(seq);
-
- PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool");
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_ObjectActuator::pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
- PyObject *retVal = PyList_New(3);
-
- PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[2]));
- PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[2]));
- PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DRot));
-
- return retVal;
-}
-
-int KX_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v);
-
- PyObject *seq = PySequence_Fast(value, "");
- if (seq && PySequence_Fast_GET_SIZE(seq) == 3)
- {
- self->m_drot[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0));
- self->m_dloc[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1));
- self->m_bitLocalFlag.DRot = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0);
-
- if (!PyErr_Occurred())
- {
- Py_DECREF(seq);
- return PY_SET_ATTR_SUCCESS;
- }
- }
-
- Py_XDECREF(seq);
-
- PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool");
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_ObjectActuator::pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self);
- if (!actuator->m_reference)
- Py_RETURN_NONE;
-
- return actuator->m_reference->GetProxy();
-}
-
-int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self);
- KX_GameObject *refOb;
-
- if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &refOb, true, "actu.reference = value: KX_ObjectActuator"))
- return PY_SET_ATTR_FAIL;
-
- if (actuator->m_reference)
- actuator->m_reference->UnregisterActuator(actuator);
-
- if (refOb==NULL) {
- actuator->m_reference= NULL;
- }
- else {
- actuator->m_reference = refOb;
- actuator->m_reference->RegisterActuator(actuator);
- }
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h
deleted file mode 100644
index 919c6acf03b..00000000000
--- a/source/gameengine/Ketsji/KX_ObjectActuator.h
+++ /dev/null
@@ -1,234 +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_ObjectActuator.h
- * \ingroup ketsji
- * \brief Do translation/rotation actions
- */
-
-#ifndef __KX_OBJECTACTUATOR_H__
-#define __KX_OBJECTACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "MT_Vector3.h"
-
-#ifdef USE_MATHUTILS
-void KX_ObjectActuator_Mathutils_Callback_Init(void);
-#endif
-
-class KX_GameObject;
-
-//
-// Stores the flags for each CValue derived class
-//
-struct KX_LocalFlags {
- KX_LocalFlags() :
- Force(false),
- Torque(false),
- DRot(false),
- DLoc(false),
- LinearVelocity(false),
- AngularVelocity(false),
- AddOrSetLinV(false),
- AddOrSetCharLoc(false),
- ServoControl(false),
- CharacterMotion(false),
- CharacterJump(false),
- ZeroForce(false),
- ZeroTorque(false),
- ZeroDRot(false),
- ZeroDLoc(false),
- ZeroLinearVelocity(false),
- ZeroAngularVelocity(false)
- {
- }
-
- bool Force;
- bool Torque;
- bool DRot;
- bool DLoc;
- bool LinearVelocity;
- bool AngularVelocity;
- bool AddOrSetLinV;
- bool AddOrSetCharLoc;
- bool ServoControl;
- bool CharacterMotion;
- bool CharacterJump;
- bool ZeroForce;
- bool ZeroTorque;
- bool ZeroDRot;
- bool ZeroDLoc;
- bool ZeroLinearVelocity;
- bool ZeroAngularVelocity;
-};
-
-class KX_ObjectActuator : public SCA_IActuator
-{
- Py_Header
-
- MT_Vector3 m_force;
- MT_Vector3 m_torque;
- MT_Vector3 m_dloc;
- MT_Vector3 m_drot;
- MT_Vector3 m_linear_velocity;
- MT_Vector3 m_angular_velocity;
- MT_Vector3 m_pid;
- MT_Scalar m_linear_length2;
- MT_Scalar m_angular_length2;
- // used in damping
- MT_Scalar m_current_linear_factor;
- MT_Scalar m_current_angular_factor;
- short m_damping;
- // used in servo control
- MT_Vector3 m_previous_error;
- MT_Vector3 m_error_accumulator;
- KX_LocalFlags m_bitLocalFlag;
- KX_GameObject* m_reference;
- // A hack bool -- oh no sorry everyone
- // This bool is used to check if we have informed
- // the physics object that we are no longer
- // setting linear velocity.
-
- bool m_active_combined_velocity;
- bool m_linear_damping_active;
- bool m_angular_damping_active;
- bool m_jumping;
-
-public:
- enum KX_OBJECT_ACT_VEC_TYPE {
- KX_OBJECT_ACT_NODEF = 0,
- KX_OBJECT_ACT_FORCE,
- KX_OBJECT_ACT_TORQUE,
- KX_OBJECT_ACT_DLOC,
- KX_OBJECT_ACT_DROT,
- KX_OBJECT_ACT_LINEAR_VELOCITY,
- KX_OBJECT_ACT_ANGULAR_VELOCITY,
- KX_OBJECT_ACT_MAX
- };
-
- /**
- * Check whether this is a valid vector mode
- */
- bool isValid(KX_OBJECT_ACT_VEC_TYPE type);
-
- KX_ObjectActuator(
- SCA_IObject* gameobj,
- KX_GameObject* refobj,
- const MT_Vector3& force,
- const MT_Vector3& torque,
- const MT_Vector3& dloc,
- const MT_Vector3& drot,
- const MT_Vector3& linV,
- const MT_Vector3& angV,
- const short damping,
- const KX_LocalFlags& flag
- );
- ~KX_ObjectActuator();
- CValue* GetReplica();
- void ProcessReplica();
- bool UnlinkObject(SCA_IObject* clientobj);
- void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
-
- void SetForceLoc(const double force[3]) { /*m_force=force;*/ }
- void UpdateFuzzyFlags()
- {
- m_bitLocalFlag.ZeroForce = MT_fuzzyZero(m_force);
- m_bitLocalFlag.ZeroTorque = MT_fuzzyZero(m_torque);
- m_bitLocalFlag.ZeroDLoc = MT_fuzzyZero(m_dloc);
- m_bitLocalFlag.ZeroDRot = MT_fuzzyZero(m_drot);
- m_bitLocalFlag.ZeroLinearVelocity = MT_fuzzyZero(m_linear_velocity);
- m_linear_length2 = (m_bitLocalFlag.ZeroLinearVelocity) ? 0.0f : m_linear_velocity.length2();
- m_bitLocalFlag.ZeroAngularVelocity = MT_fuzzyZero(m_angular_velocity);
- m_angular_length2 = (m_bitLocalFlag.ZeroAngularVelocity) ? 0.0f : m_angular_velocity.length2();
- }
- virtual bool Update();
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- /* Attributes */
- static PyObject* pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
-#ifdef USE_MATHUTILS
- static PyObject* pyattr_get_linV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_linV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_angV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_angV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-#endif
-
- // This lets the attribute macros use UpdateFuzzyFlags()
- static int PyUpdateFuzzyFlags(void *self, const PyAttributeDef *attrdef)
- {
- KX_ObjectActuator* act = reinterpret_cast<KX_ObjectActuator*>(self);
- act->UpdateFuzzyFlags();
- return 0;
- }
-
- // This is the keep the PID values in check after they are assigned with Python
- static int PyCheckPid(void *self, const PyAttributeDef *attrdef)
- {
- KX_ObjectActuator* act = reinterpret_cast<KX_ObjectActuator*>(self);
-
- //P 0 to 200
- if (act->m_pid[0] < 0) {
- act->m_pid[0] = 0;
- } else if (act->m_pid[0] > 200) {
- act->m_pid[0] = 200;
- }
-
- //I 0 to 3
- if (act->m_pid[1] < 0) {
- act->m_pid[1] = 0;
- } else if (act->m_pid[1] > 3) {
- act->m_pid[1] = 3;
- }
-
- //D -100 to 100
- if (act->m_pid[2] < -100) {
- act->m_pid[2] = -100;
- } else if (act->m_pid[2] > 100) {
- act->m_pid[2] = 100;
- }
-
- return 0;
- }
-
-#endif /* WITH_PYTHON */
-
-};
-
-#endif /* __KX_OBJECTACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
deleted file mode 100644
index c84b2474c90..00000000000
--- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
+++ /dev/null
@@ -1,832 +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.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_ObstacleSimulation.cpp
- * \ingroup ketsji
- *
- * Simulation for obstacle avoidance behavior
- */
-
-#include "KX_ObstacleSimulation.h"
-#include "KX_NavMeshObject.h"
-#include "KX_PythonInit.h"
-#include "DNA_object_types.h"
-#include "BLI_math.h"
-
-namespace
-{
- inline float perp(const MT_Vector2& a, const MT_Vector2& b) { return a.x()*b.y() - a.y()*b.x(); }
-
- inline float sqr(float x) { return x * x; }
- inline float lerp(float a, float b, float t) { return a + (b - a) * t; }
- inline float clamp(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); }
- inline void vset(float v[2], float x, float y) { v[0] = x; v[1] = y; }
-}
-
-/* grr, seems moto provides no nice way to do this */
-#define MT_3D_AS_2D(v) MT_Vector2((v)[0], (v)[1])
-
-static int sweepCircleCircle(
- const MT_Vector2 &pos0, const MT_Scalar r0, const MT_Vector2 &v,
- const MT_Vector2 &pos1, const MT_Scalar r1,
- float& tmin, float& tmax)
-{
- static const float EPS = 0.0001f;
- MT_Vector2 c0(pos0.x(), pos0.y());
- MT_Vector2 c1(pos1.x(), pos1.y());
- MT_Vector2 s = c1 - c0;
- MT_Scalar r = r0+r1;
- float c = s.length2() - r*r;
- float a = v.length2();
- if (a < EPS) return 0; // not moving
-
- // Overlap, calc time to exit.
- float b = MT_dot(v,s);
- float d = b*b - a*c;
- if (d < 0.0f) return 0; // no intersection.
- tmin = (b - sqrtf(d)) / a;
- tmax = (b + sqrtf(d)) / a;
- return 1;
-}
-
-static int sweepCircleSegment(
- const MT_Vector2 &pos0, const MT_Scalar r0, const MT_Vector2 &v,
- const MT_Vector2& pa, const MT_Vector2 &pb, const MT_Scalar sr,
- float& tmin, float &tmax)
-{
- // equation parameters
- MT_Vector2 c0(pos0.x(), pos0.y());
- MT_Vector2 sa(pa.x(), pa.y());
- MT_Vector2 sb(pb.x(), pb.y());
- MT_Vector2 L = sb-sa;
- MT_Vector2 H = c0-sa;
- MT_Scalar radius = r0+sr;
- float l2 = L.length2();
- float r2 = radius * radius;
- float dl = perp(v, L);
- float hl = perp(H, L);
- float a = dl * dl;
- float b = 2.0f * hl * dl;
- float c = hl * hl - (r2 * l2);
- float d = (b*b) - (4.0f * a * c);
-
- // infinite line missed by infinite ray.
- if (d < 0.0f)
- return 0;
-
- d = sqrtf(d);
- tmin = (-b - d) / (2.0f * a);
- tmax = (-b + d) / (2.0f * a);
-
- // line missed by ray range.
- /* if (tmax < 0.0f || tmin > 1.0f)
- return 0;*/
-
- // find what part of the ray was collided.
- MT_Vector2 Pedge;
- Pedge = c0+v*tmin;
- H = Pedge - sa;
- float e0 = MT_dot(H, L) / l2;
- Pedge = c0 + v*tmax;
- H = Pedge - sa;
- float e1 = MT_dot(H, L) / l2;
-
- if (e0 < 0.0f || e1 < 0.0f)
- {
- float ctmin, ctmax;
- if (sweepCircleCircle(pos0, r0, v, pa, sr, ctmin, ctmax))
- {
- if (e0 < 0.0f && ctmin > tmin)
- tmin = ctmin;
- if (e1 < 0.0f && ctmax < tmax)
- tmax = ctmax;
- }
- else
- {
- return 0;
- }
- }
-
- if (e0 > 1.0f || e1 > 1.0f)
- {
- float ctmin, ctmax;
- if (sweepCircleCircle(pos0, r0, v, pb, sr, ctmin, ctmax))
- {
- if (e0 > 1.0f && ctmin > tmin)
- tmin = ctmin;
- if (e1 > 1.0f && ctmax < tmax)
- tmax = ctmax;
- }
- else
- {
- return 0;
- }
- }
-
- return 1;
-}
-
-static bool inBetweenAngle(float a, float amin, float amax, float& t)
-{
- if (amax < amin) amax += (float)M_PI*2;
- if (a < amin-(float)M_PI) a += (float)M_PI*2;
- if (a > amin+(float)M_PI) a -= (float)M_PI*2;
- if (a >= amin && a < amax)
- {
- t = (a-amin) / (amax-amin);
- return true;
- }
- return false;
-}
-
-static float interpolateToi(float a, const float* dir, const float* toi, const int ntoi)
-{
- for (int i = 0; i < ntoi; ++i)
- {
- int next = (i+1) % ntoi;
- float t;
- if (inBetweenAngle(a, dir[i], dir[next], t))
- {
- return lerp(toi[i], toi[next], t);
- }
- }
- return 0;
-}
-
-KX_ObstacleSimulation::KX_ObstacleSimulation(MT_Scalar levelHeight, bool enableVisualization)
-: m_levelHeight(levelHeight)
-, m_enableVisualization(enableVisualization)
-{
-
-}
-
-KX_ObstacleSimulation::~KX_ObstacleSimulation()
-{
- for (size_t i=0; i<m_obstacles.size(); i++)
- {
- KX_Obstacle* obs = m_obstacles[i];
- delete obs;
- }
- m_obstacles.clear();
-}
-KX_Obstacle* KX_ObstacleSimulation::CreateObstacle(KX_GameObject* gameobj)
-{
- KX_Obstacle* obstacle = new KX_Obstacle();
- obstacle->m_gameObj = gameobj;
-
- vset(obstacle->vel, 0,0);
- vset(obstacle->pvel, 0,0);
- vset(obstacle->dvel, 0,0);
- vset(obstacle->nvel, 0,0);
- for (int i = 0; i < VEL_HIST_SIZE; ++i)
- vset(&obstacle->hvel[i*2], 0,0);
- obstacle->hhead = 0;
-
- gameobj->RegisterObstacle(this);
- m_obstacles.push_back(obstacle);
- return obstacle;
-}
-
-void KX_ObstacleSimulation::AddObstacleForObj(KX_GameObject* gameobj)
-{
- KX_Obstacle* obstacle = CreateObstacle(gameobj);
- struct Object* blenderobject = gameobj->GetBlenderObject();
- obstacle->m_type = KX_OBSTACLE_OBJ;
- obstacle->m_shape = KX_OBSTACLE_CIRCLE;
- obstacle->m_rad = blenderobject->obstacleRad;
-}
-
-void KX_ObstacleSimulation::AddObstaclesForNavMesh(KX_NavMeshObject* navmeshobj)
-{
- dtStatNavMesh* navmesh = navmeshobj->GetNavMesh();
- if (navmesh)
- {
- int npoly = navmesh->getPolyCount();
- for (int pi=0; pi<npoly; pi++)
- {
- const dtStatPoly* poly = navmesh->getPoly(pi);
-
- for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++)
- {
- if (poly->n[j]) continue;
- const float* vj = navmesh->getVertex(poly->v[j]);
- const float* vi = navmesh->getVertex(poly->v[i]);
-
- KX_Obstacle* obstacle = CreateObstacle(navmeshobj);
- obstacle->m_type = KX_OBSTACLE_NAV_MESH;
- obstacle->m_shape = KX_OBSTACLE_SEGMENT;
- obstacle->m_pos = MT_Point3(vj[0], vj[2], vj[1]);
- obstacle->m_pos2 = MT_Point3(vi[0], vi[2], vi[1]);
- obstacle->m_rad = 0;
- }
- }
- }
-}
-
-void KX_ObstacleSimulation::DestroyObstacleForObj(KX_GameObject* gameobj)
-{
- for (size_t i=0; i<m_obstacles.size(); )
- {
- if (m_obstacles[i]->m_gameObj == gameobj)
- {
- KX_Obstacle* obstacle = m_obstacles[i];
- obstacle->m_gameObj->UnregisterObstacle();
- m_obstacles[i] = m_obstacles.back();
- m_obstacles.pop_back();
- delete obstacle;
- }
- else
- i++;
- }
-}
-
-void KX_ObstacleSimulation::UpdateObstacles()
-{
- for (size_t i=0; i<m_obstacles.size(); i++)
- {
- if (m_obstacles[i]->m_type==KX_OBSTACLE_NAV_MESH || m_obstacles[i]->m_shape==KX_OBSTACLE_SEGMENT)
- continue;
-
- KX_Obstacle* obs = m_obstacles[i];
- obs->m_pos = obs->m_gameObj->NodeGetWorldPosition();
- obs->vel[0] = obs->m_gameObj->GetLinearVelocity().x();
- obs->vel[1] = obs->m_gameObj->GetLinearVelocity().y();
-
- // Update velocity history and calculate perceived (average) velocity.
- copy_v2_v2(&obs->hvel[obs->hhead * 2], obs->vel);
- obs->hhead = (obs->hhead+1) % VEL_HIST_SIZE;
- vset(obs->pvel,0,0);
- for (int j = 0; j < VEL_HIST_SIZE; ++j)
- add_v2_v2v2(obs->pvel, obs->pvel, &obs->hvel[j * 2]);
- mul_v2_fl(obs->pvel, 1.0f / VEL_HIST_SIZE);
- }
-}
-
-KX_Obstacle* KX_ObstacleSimulation::GetObstacle(KX_GameObject* gameobj)
-{
- for (size_t i=0; i<m_obstacles.size(); i++)
- {
- if (m_obstacles[i]->m_gameObj == gameobj)
- return m_obstacles[i];
- }
-
- return NULL;
-}
-
-void KX_ObstacleSimulation::AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle)
-{
-}
-
-void KX_ObstacleSimulation::DrawObstacles()
-{
- if (!m_enableVisualization)
- return;
- static const MT_Vector3 bluecolor(0,0,1);
- static const MT_Vector3 normal(0.0f, 0.0f, 1.0f);
- static const int SECTORS_NUM = 32;
- for (size_t i=0; i<m_obstacles.size(); i++)
- {
- if (m_obstacles[i]->m_shape==KX_OBSTACLE_SEGMENT)
- {
- MT_Point3 p1 = m_obstacles[i]->m_pos;
- MT_Point3 p2 = m_obstacles[i]->m_pos2;
- //apply world transform
- if (m_obstacles[i]->m_type == KX_OBSTACLE_NAV_MESH)
- {
- KX_NavMeshObject* navmeshobj = static_cast<KX_NavMeshObject*>(m_obstacles[i]->m_gameObj);
- p1 = navmeshobj->TransformToWorldCoords(p1);
- p2 = navmeshobj->TransformToWorldCoords(p2);
- }
-
- KX_RasterizerDrawDebugLine(p1, p2, bluecolor);
- }
- else if (m_obstacles[i]->m_shape==KX_OBSTACLE_CIRCLE)
- {
- KX_RasterizerDrawDebugCircle(m_obstacles[i]->m_pos, m_obstacles[i]->m_rad, bluecolor,
- normal, SECTORS_NUM);
- }
- }
-}
-
-static MT_Point3 nearestPointToObstacle(MT_Point3& pos ,KX_Obstacle* obstacle)
-{
- switch (obstacle->m_shape)
- {
- case KX_OBSTACLE_SEGMENT :
- {
- MT_Vector3 ab = obstacle->m_pos2 - obstacle->m_pos;
- if (!ab.fuzzyZero())
- {
- const MT_Scalar dist = ab.length();
- MT_Vector3 abdir = ab.normalized();
- MT_Vector3 v = pos - obstacle->m_pos;
- MT_Scalar proj = abdir.dot(v);
- CLAMP(proj, 0, dist);
- MT_Point3 res = obstacle->m_pos + abdir*proj;
- return res;
- }
- ATTR_FALLTHROUGH;
- }
- case KX_OBSTACLE_CIRCLE :
- default:
- return obstacle->m_pos;
- }
-}
-
-static bool filterObstacle(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, KX_Obstacle* otherObst,
- float levelHeight)
-{
- //filter obstacles by type
- if ( (otherObst == activeObst) ||
- (otherObst->m_type==KX_OBSTACLE_NAV_MESH && otherObst->m_gameObj!=activeNavMeshObj) )
- return false;
-
- //filter obstacles by position
- MT_Point3 p = nearestPointToObstacle(activeObst->m_pos, otherObst);
- if ( fabsf(activeObst->m_pos.z() - p.z()) > levelHeight)
- return false;
-
- return true;
-}
-
-///////////*********TOI_rays**********/////////////////
-KX_ObstacleSimulationTOI::KX_ObstacleSimulationTOI(MT_Scalar levelHeight, bool enableVisualization)
-: KX_ObstacleSimulation(levelHeight, enableVisualization),
- m_maxSamples(32),
- m_minToi(0.0f),
- m_maxToi(0.0f),
- m_velWeight(1.0f),
- m_curVelWeight(1.0f),
- m_toiWeight(1.0f),
- m_collisionWeight(1.0f)
-{
-}
-
-
-void KX_ObstacleSimulationTOI::AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- MT_Vector3& velocity, MT_Scalar maxDeltaSpeed, MT_Scalar maxDeltaAngle)
-{
- int nobs = m_obstacles.size();
- int obstidx = std::find(m_obstacles.begin(), m_obstacles.end(), activeObst) - m_obstacles.begin();
- if (obstidx == nobs)
- return;
-
- vset(activeObst->dvel, velocity.x(), velocity.y());
-
- //apply RVO
- sampleRVO(activeObst, activeNavMeshObj, maxDeltaAngle);
-
- // Fake dynamic constraint.
- float dv[2];
- float vel[2];
- sub_v2_v2v2(dv, activeObst->nvel, activeObst->vel);
- float ds = len_v2(dv);
- if (ds > maxDeltaSpeed || ds<-maxDeltaSpeed)
- mul_v2_fl(dv, fabs(maxDeltaSpeed / ds));
- add_v2_v2v2(vel, activeObst->vel, dv);
-
- velocity.x() = vel[0];
- velocity.y() = vel[1];
-}
-
-///////////*********TOI_rays**********/////////////////
-static const int AVOID_MAX_STEPS = 128;
-struct TOICircle
-{
- TOICircle() : n(0), minToi(0), maxToi(1) {}
- float toi[AVOID_MAX_STEPS]; // Time of impact (seconds)
- float toie[AVOID_MAX_STEPS]; // Time of exit (seconds)
- float dir[AVOID_MAX_STEPS]; // Direction (radians)
- int n; // Number of samples
- float minToi, maxToi; // Min/max TOI (seconds)
-};
-
-KX_ObstacleSimulationTOI_rays::KX_ObstacleSimulationTOI_rays(MT_Scalar levelHeight, bool enableVisualization):
- KX_ObstacleSimulationTOI(levelHeight, enableVisualization)
-{
- m_maxSamples = 32;
- m_minToi = 0.5f;
- m_maxToi = 1.2f;
- m_velWeight = 4.0f;
- m_toiWeight = 1.0f;
- m_collisionWeight = 100.0f;
-}
-
-
-void KX_ObstacleSimulationTOI_rays::sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- const float maxDeltaAngle)
-{
- MT_Vector2 vel(activeObst->dvel[0], activeObst->dvel[1]);
- float vmax = (float) vel.length();
- float odir = (float) atan2(vel.y(), vel.x());
-
- MT_Vector2 ddir = vel;
- ddir.normalize();
-
- float bestScore = FLT_MAX;
- float bestDir = odir;
- float bestToi = 0;
-
- TOICircle tc;
- tc.n = m_maxSamples;
- tc.minToi = m_minToi;
- tc.maxToi = m_maxToi;
-
- const int iforw = m_maxSamples/2;
- const float aoff = (float)iforw / (float)m_maxSamples;
-
- size_t nobs = m_obstacles.size();
- for (int iter = 0; iter < m_maxSamples; ++iter)
- {
- // Calculate sample velocity
- const float ndir = ((float)iter/(float)m_maxSamples) - aoff;
- const float dir = odir+ndir*(float)M_PI*2.0f;
- MT_Vector2 svel;
- svel.x() = cosf(dir) * vmax;
- svel.y() = sinf(dir) * vmax;
-
- // Find min time of impact and exit amongst all obstacles.
- float tmin = m_maxToi;
- float tmine = 0.0f;
- for (int i = 0; i < nobs; ++i)
- {
- KX_Obstacle* ob = m_obstacles[i];
- bool res = filterObstacle(activeObst, activeNavMeshObj, ob, m_levelHeight);
- if (!res)
- continue;
-
- float htmin,htmax;
-
- if (ob->m_shape == KX_OBSTACLE_CIRCLE)
- {
- MT_Vector2 vab;
- if (len_v2(ob->vel) < 0.01f * 0.01f) {
- // Stationary, use VO
- vab = svel;
- }
- else
- {
- // Moving, use RVO
- vab = 2*svel - vel - ob->vel;
- }
-
- if (!sweepCircleCircle(MT_3D_AS_2D(activeObst->m_pos), activeObst->m_rad,
- vab, MT_3D_AS_2D(ob->m_pos), ob->m_rad, htmin, htmax))
- {
- continue;
- }
- }
- else if (ob->m_shape == KX_OBSTACLE_SEGMENT)
- {
- MT_Point3 p1 = ob->m_pos;
- MT_Point3 p2 = ob->m_pos2;
- //apply world transform
- if (ob->m_type == KX_OBSTACLE_NAV_MESH)
- {
- KX_NavMeshObject* navmeshobj = static_cast<KX_NavMeshObject*>(ob->m_gameObj);
- p1 = navmeshobj->TransformToWorldCoords(p1);
- p2 = navmeshobj->TransformToWorldCoords(p2);
- }
-
- if (!sweepCircleSegment(MT_3D_AS_2D(activeObst->m_pos), activeObst->m_rad, svel,
- MT_3D_AS_2D(p1), MT_3D_AS_2D(p2), ob->m_rad, htmin, htmax))
- {
- continue;
- }
- }
- else {
- continue;
- }
-
- if (htmin > 0.0f)
- {
- // The closest obstacle is somewhere ahead of us, keep track of nearest obstacle.
- if (htmin < tmin)
- tmin = htmin;
- }
- else if (htmax > 0.0f)
- {
- // The agent overlaps the obstacle, keep track of first safe exit.
- if (htmax > tmine)
- tmine = htmax;
- }
- }
-
- // Calculate sample penalties and final score.
- const float apen = m_velWeight * fabsf(ndir);
- const float tpen = m_toiWeight * (1.0f/(0.0001f+tmin/m_maxToi));
- const float cpen = m_collisionWeight * (tmine/m_minToi)*(tmine/m_minToi);
- const float score = apen + tpen + cpen;
-
- // Update best score.
- if (score < bestScore)
- {
- bestDir = dir;
- bestToi = tmin;
- bestScore = score;
- }
-
- tc.dir[iter] = dir;
- tc.toi[iter] = tmin;
- tc.toie[iter] = tmine;
- }
-
- if (len_v2(activeObst->vel) > 0.1f) {
- // Constrain max turn rate.
- float cura = atan2(activeObst->vel[1],activeObst->vel[0]);
- float da = bestDir - cura;
- if (da < -M_PI) da += (float)M_PI*2;
- if (da > M_PI) da -= (float)M_PI*2;
- if (da < -maxDeltaAngle)
- {
- bestDir = cura - maxDeltaAngle;
- bestToi = min(bestToi, interpolateToi(bestDir, tc.dir, tc.toi, tc.n));
- }
- else if (da > maxDeltaAngle)
- {
- bestDir = cura + maxDeltaAngle;
- bestToi = min(bestToi, interpolateToi(bestDir, tc.dir, tc.toi, tc.n));
- }
- }
-
- // Adjust speed when time of impact is less than min TOI.
- if (bestToi < m_minToi)
- vmax *= bestToi/m_minToi;
-
- // New steering velocity.
- activeObst->nvel[0] = cosf(bestDir) * vmax;
- activeObst->nvel[1] = sinf(bestDir) * vmax;
-}
-
-///////////********* TOI_cells**********/////////////////
-
-static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- KX_Obstacles& obstacles, float levelHeight, const float vmax,
- const float* spos, const float cs, const int nspos, float* res,
- float maxToi, float velWeight, float curVelWeight, float sideWeight,
- float toiWeight)
-{
- vset(res, 0,0);
-
- const float ivmax = 1.0f / vmax;
-
- float adir[2] /*, adist */;
- if (normalize_v2_v2(adir, activeObst->pvel) <= 0.01f) {
- zero_v2(adir);
- }
-
- float activeObstPos[2];
- vset(activeObstPos, activeObst->m_pos.x(), activeObst->m_pos.y());
- /* adist = vdot(adir, activeObstPos); */
-
- float minPenalty = FLT_MAX;
-
- for (int n = 0; n < nspos; ++n)
- {
- float vcand[2];
- copy_v2_v2(vcand, &spos[n * 2]);
-
- // Find min time of impact and exit amongst all obstacles.
- float tmin = maxToi;
- float side = 0;
- int nside = 0;
-
- for (int i = 0; i < obstacles.size(); ++i)
- {
- KX_Obstacle* ob = obstacles[i];
- bool res = filterObstacle(activeObst, activeNavMeshObj, ob, levelHeight);
- if (!res)
- continue;
- float htmin, htmax;
-
- if (ob->m_shape==KX_OBSTACLE_CIRCLE)
- {
- float vab[2];
-
- // Moving, use RVO
- mul_v2_v2fl(vab, vcand, 2);
- sub_v2_v2v2(vab, vab, activeObst->vel);
- sub_v2_v2v2(vab, vab, ob->vel);
-
- // Side
- // NOTE: dp, and dv are constant over the whole calculation,
- // they can be precomputed per object.
- const float* pa = activeObstPos;
- float pb[2];
- vset(pb, ob->m_pos.x(), ob->m_pos.y());
-
- const float orig[2] = {0, 0};
- float dp[2], dv[2], np[2];
- sub_v2_v2v2(dp, pb, pa);
- normalize_v2(dp);
- sub_v2_v2v2(dv, ob->dvel, activeObst->dvel);
-
- /* TODO: use line_point_side_v2 */
- if (area_tri_signed_v2(orig, dp, dv) < 0.01f) {
- np[0] = -dp[1];
- np[1] = dp[0];
- }
- else {
- np[0] = dp[1];
- np[1] = -dp[0];
- }
-
- side += clamp(min(dot_v2v2(dp, vab),
- dot_v2v2(np, vab)) * 2.0f, 0.0f, 1.0f);
- nside++;
-
- if (!sweepCircleCircle(MT_3D_AS_2D(activeObst->m_pos), activeObst->m_rad,
- vab, MT_3D_AS_2D(ob->m_pos), ob->m_rad, htmin, htmax))
- {
- continue;
- }
-
- // Handle overlapping obstacles.
- if (htmin < 0.0f && htmax > 0.0f)
- {
- // Avoid more when overlapped.
- htmin = -htmin * 0.5f;
- }
- }
- else if (ob->m_shape == KX_OBSTACLE_SEGMENT)
- {
- MT_Point3 p1 = ob->m_pos;
- MT_Point3 p2 = ob->m_pos2;
- //apply world transform
- if (ob->m_type == KX_OBSTACLE_NAV_MESH)
- {
- KX_NavMeshObject* navmeshobj = static_cast<KX_NavMeshObject*>(ob->m_gameObj);
- p1 = navmeshobj->TransformToWorldCoords(p1);
- p2 = navmeshobj->TransformToWorldCoords(p2);
- }
- float p[2], q[2];
- vset(p, p1.x(), p1.y());
- vset(q, p2.x(), p2.y());
-
- // NOTE: the segments are assumed to come from a navmesh which is shrunken by
- // the agent radius, hence the use of really small radius.
- // This can be handle more efficiently by using seg-seg test instead.
- // If the whole segment is to be treated as obstacle, use agent->rad instead of 0.01f!
- const float r = 0.01f; // agent->rad
- if (dist_squared_to_line_segment_v2(activeObstPos, p, q) < sqr(r + ob->m_rad)) {
- float sdir[2], snorm[2];
- sub_v2_v2v2(sdir, q, p);
- snorm[0] = sdir[1];
- snorm[1] = -sdir[0];
- // If the velocity is pointing towards the segment, no collision.
- if (dot_v2v2(snorm, vcand) < 0.0f)
- continue;
- // Else immediate collision.
- htmin = 0.0f;
- htmax = 10.0f;
- }
- else
- {
- if (!sweepCircleSegment(activeObstPos, r, vcand, p, q, ob->m_rad, htmin, htmax))
- continue;
- }
-
- // Avoid less when facing walls.
- htmin *= 2.0f;
- }
- else {
- continue;
- }
-
- if (htmin >= 0.0f)
- {
- // The closest obstacle is somewhere ahead of us, keep track of nearest obstacle.
- if (htmin < tmin)
- tmin = htmin;
- }
- }
-
- // Normalize side bias, to prevent it dominating too much.
- if (nside)
- side /= nside;
-
- const float vpen = velWeight * (len_v2v2(vcand, activeObst->dvel) * ivmax);
- const float vcpen = curVelWeight * (len_v2v2(vcand, activeObst->vel) * ivmax);
- const float spen = sideWeight * side;
- const float tpen = toiWeight * (1.0f/(0.1f+tmin/maxToi));
-
- const float penalty = vpen + vcpen + spen + tpen;
-
- if (penalty < minPenalty) {
- minPenalty = penalty;
- copy_v2_v2(res, vcand);
- }
- }
-}
-
-void KX_ObstacleSimulationTOI_cells::sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- const float maxDeltaAngle)
-{
- vset(activeObst->nvel, 0.f, 0.f);
- float vmax = len_v2(activeObst->dvel);
-
- float* spos = new float[2*m_maxSamples];
- int nspos = 0;
-
- if (!m_adaptive)
- {
- const float cvx = activeObst->dvel[0]*m_bias;
- const float cvy = activeObst->dvel[1]*m_bias;
- float vmax = len_v2(activeObst->dvel);
- const float vrange = vmax*(1-m_bias);
- const float cs = 1.0f / (float)m_sampleRadius*vrange;
-
- for (int y = -m_sampleRadius; y <= m_sampleRadius; ++y)
- {
- for (int x = -m_sampleRadius; x <= m_sampleRadius; ++x)
- {
- if (nspos < m_maxSamples)
- {
- const float vx = cvx + (float)(x+0.5f)*cs;
- const float vy = cvy + (float)(y+0.5f)*cs;
- if (vx*vx+vy*vy > sqr(vmax+cs/2)) continue;
- spos[nspos*2+0] = vx;
- spos[nspos*2+1] = vy;
- nspos++;
- }
- }
- }
- processSamples(activeObst, activeNavMeshObj, m_obstacles, m_levelHeight, vmax, spos, cs/2,
- nspos, activeObst->nvel, m_maxToi, m_velWeight, m_curVelWeight, m_collisionWeight, m_toiWeight);
- }
- else
- {
- int rad;
- float res[2];
- float cs;
- // First sample location.
- rad = 4;
- res[0] = activeObst->dvel[0]*m_bias;
- res[1] = activeObst->dvel[1]*m_bias;
- cs = vmax*(2-m_bias*2) / (float)(rad-1);
-
- for (int k = 0; k < 5; ++k)
- {
- const float half = (rad-1)*cs*0.5f;
-
- nspos = 0;
- for (int y = 0; y < rad; ++y)
- {
- for (int x = 0; x < rad; ++x)
- {
- const float v_xy[2] = {
- res[0] + x * cs - half,
- res[1] + y * cs - half};
-
- if (len_squared_v2(v_xy) > sqr(vmax + cs / 2))
- continue;
-
- copy_v2_v2(&spos[nspos * 2 + 0], v_xy);
- nspos++;
- }
- }
-
- processSamples(activeObst, activeNavMeshObj, m_obstacles, m_levelHeight, vmax, spos, cs/2,
- nspos, res, m_maxToi, m_velWeight, m_curVelWeight, m_collisionWeight, m_toiWeight);
-
- cs *= 0.5f;
- }
- copy_v2_v2(activeObst->nvel, res);
- }
-
- delete [] spos;
-}
-
-KX_ObstacleSimulationTOI_cells::KX_ObstacleSimulationTOI_cells(MT_Scalar levelHeight, bool enableVisualization)
-: KX_ObstacleSimulationTOI(levelHeight, enableVisualization)
-, m_bias(0.4f)
-, m_adaptive(true)
-, m_sampleRadius(15)
-{
- m_maxSamples = (m_sampleRadius*2+1)*(m_sampleRadius*2+1) + 100;
- m_maxToi = 1.5f;
- m_velWeight = 2.0f;
- m_curVelWeight = 0.75f;
- m_toiWeight = 2.5f;
- m_collisionWeight = 0.75f; //side_weight
-}
diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.h b/source/gameengine/Ketsji/KX_ObstacleSimulation.h
deleted file mode 100644
index 50589b5bc69..00000000000
--- a/source/gameengine/Ketsji/KX_ObstacleSimulation.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Simulation for obstacle avoidance behavior
- * (based on Cane Project - http://code.google.com/p/cane by Mikko Mononen (c) 2009)
- *
- * ***** 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): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __KX_OBSTACLESIMULATION_H__
-#define __KX_OBSTACLESIMULATION_H__
-
-#include <vector>
-#include "MT_Point2.h"
-#include "MT_Point3.h"
-
-class KX_GameObject;
-class KX_NavMeshObject;
-
-enum KX_OBSTACLE_TYPE
-{
- KX_OBSTACLE_OBJ,
- KX_OBSTACLE_NAV_MESH,
-};
-
-enum KX_OBSTACLE_SHAPE
-{
- KX_OBSTACLE_CIRCLE,
- KX_OBSTACLE_SEGMENT,
-};
-
-#define VEL_HIST_SIZE 6
-struct KX_Obstacle
-{
- KX_OBSTACLE_TYPE m_type;
- KX_OBSTACLE_SHAPE m_shape;
- MT_Point3 m_pos;
- MT_Point3 m_pos2;
- MT_Scalar m_rad;
-
- float vel[2];
- float pvel[2];
- float dvel[2];
- float nvel[2];
- float hvel[VEL_HIST_SIZE*2];
- int hhead;
-
-
- KX_GameObject* m_gameObj;
-};
-typedef std::vector<KX_Obstacle*> KX_Obstacles;
-
-class KX_ObstacleSimulation
-{
-protected:
- KX_Obstacles m_obstacles;
-
- MT_Scalar m_levelHeight;
- bool m_enableVisualization;
-
- KX_Obstacle* CreateObstacle(KX_GameObject* gameobj);
-public:
- KX_ObstacleSimulation(MT_Scalar levelHeight, bool enableVisualization);
- virtual ~KX_ObstacleSimulation();
-
- void DrawObstacles();
- //void DebugDraw();
-
- void AddObstacleForObj(KX_GameObject* gameobj);
- void DestroyObstacleForObj(KX_GameObject* gameobj);
- void AddObstaclesForNavMesh(KX_NavMeshObject* navmesh);
- KX_Obstacle* GetObstacle(KX_GameObject* gameobj);
- void UpdateObstacles();
- virtual void AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle);
-
-};
-class KX_ObstacleSimulationTOI: public KX_ObstacleSimulation
-{
-protected:
- int m_maxSamples; // Number of sample steps
- float m_minToi; // Min TOI
- float m_maxToi; // Max TOI
- float m_velWeight; // Sample selection angle weight
- float m_curVelWeight; // Sample selection current velocity weight
- float m_toiWeight; // Sample selection TOI weight
- float m_collisionWeight; // Sample selection collision weight
-
- virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- const float maxDeltaAngle) = 0;
-public:
- KX_ObstacleSimulationTOI(MT_Scalar levelHeight, bool enableVisualization);
- virtual void AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle);
-};
-
-class KX_ObstacleSimulationTOI_rays: public KX_ObstacleSimulationTOI
-{
-protected:
- virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- const float maxDeltaAngle);
-public:
- KX_ObstacleSimulationTOI_rays(MT_Scalar levelHeight, bool enableVisualization);
-};
-
-class KX_ObstacleSimulationTOI_cells: public KX_ObstacleSimulationTOI
-{
-protected:
- float m_bias;
- bool m_adaptive;
- int m_sampleRadius;
- virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- const float maxDeltaAngle);
-public:
- KX_ObstacleSimulationTOI_cells(MT_Scalar levelHeight, bool enableVisualization);
-};
-
-#endif
diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp
deleted file mode 100644
index bcaa1e60e92..00000000000
--- a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp
+++ /dev/null
@@ -1,56 +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_OrientationInterpolator.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_OrientationInterpolator.h"
-#include "MT_Matrix3x3.h"
-#include "KX_IScalarInterpolator.h"
-
-void KX_OrientationInterpolator::Execute(float currentTime) const
-{
- MT_Vector3 eul(m_ipos[0]->GetValue(currentTime),
- m_ipos[1]->GetValue(currentTime),
- m_ipos[2]->GetValue(currentTime));
- MT_Scalar ci = cosf(eul[0]);
- MT_Scalar cj = cosf(eul[1]);
- MT_Scalar ch = cosf(eul[2]);
- MT_Scalar si = sinf(eul[0]);
- MT_Scalar sj = sinf(eul[1]);
- MT_Scalar sh = sinf(eul[2]);
- MT_Scalar cc = ci*ch;
- MT_Scalar cs = ci*sh;
- MT_Scalar sc = si*ch;
- MT_Scalar ss = si*sh;
-
- m_target.setValue(cj*ch, sj*sc-cs, sj*cc+ss,
- cj*sh, sj*ss+cc, sj*cs-sc,
- -sj, cj*si, cj*ci);
-}
diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.h b/source/gameengine/Ketsji/KX_OrientationInterpolator.h
deleted file mode 100644
index 59014b70174..00000000000
--- a/source/gameengine/Ketsji/KX_OrientationInterpolator.h
+++ /dev/null
@@ -1,64 +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_OrientationInterpolator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_ORIENTATIONINTERPOLATOR_H__
-#define __KX_ORIENTATIONINTERPOLATOR_H__
-
-#include "KX_IInterpolator.h"
-
-class MT_Matrix3x3;
-class KX_IScalarInterpolator;
-
-class KX_OrientationInterpolator : public KX_IInterpolator {
-public:
- KX_OrientationInterpolator(MT_Matrix3x3& target,
- KX_IScalarInterpolator **ipos)
- : m_target(target)
- {
- m_ipos[0] = ipos[0];
- m_ipos[1] = ipos[1];
- m_ipos[2] = ipos[2];
- }
-
- virtual void Execute(float currentTime) const;
-
-private:
- MT_Matrix3x3& m_target;
- KX_IScalarInterpolator *m_ipos[3];
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_OrientationInterpolator")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp
deleted file mode 100644
index 0b133400920..00000000000
--- a/source/gameengine/Ketsji/KX_ParentActuator.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Set or remove an objects parent
- *
- *
- * ***** 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_ParentActuator.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_ParentActuator.h"
-#include "KX_GameObject.h"
-#include "KX_PythonInit.h"
-
-#include "EXP_PyObjectPlus.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_ParentActuator::KX_ParentActuator(SCA_IObject *gameobj,
- int mode,
- bool addToCompound,
- bool ghost,
- SCA_IObject *ob)
- : SCA_IActuator(gameobj, KX_ACT_PARENT),
- m_mode(mode),
- m_addToCompound(addToCompound),
- m_ghost(ghost),
- m_ob(ob)
-{
- if (m_ob)
- m_ob->RegisterActuator(this);
-}
-
-
-
-KX_ParentActuator::~KX_ParentActuator()
-{
- if (m_ob)
- m_ob->UnregisterActuator(this);
-}
-
-
-
-CValue* KX_ParentActuator::GetReplica()
-{
- KX_ParentActuator* replica = new KX_ParentActuator(*this);
- // replication just copy the m_base pointer => common random generator
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_ParentActuator::ProcessReplica()
-{
- if (m_ob)
- m_ob->RegisterActuator(this);
- SCA_IActuator::ProcessReplica();
-}
-
-
-bool KX_ParentActuator::UnlinkObject(SCA_IObject* clientobj)
-{
- if (clientobj == m_ob)
- {
- // this object is being deleted, we cannot continue to track it.
- m_ob = NULL;
- return true;
- }
- return false;
-}
-
-void KX_ParentActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_ob];
- if (h_obj) {
- if (m_ob)
- m_ob->UnregisterActuator(this);
- m_ob = (SCA_IObject*)(*h_obj);
- m_ob->RegisterActuator(this);
- }
-}
-
-
-
-bool KX_ParentActuator::Update()
-{
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
-
- KX_GameObject *obj = (KX_GameObject*) GetParent();
- KX_Scene *scene = KX_GetActiveScene();
- switch (m_mode) {
- case KX_PARENT_SET:
- if (m_ob)
- obj->SetParent(scene, (KX_GameObject*)m_ob, m_addToCompound, m_ghost);
- break;
- case KX_PARENT_REMOVE:
- obj->RemoveParent(scene);
- break;
- };
-
- return false;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_ParentActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_ParentActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_ParentActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_ParentActuator::Attributes[] = {
- KX_PYATTRIBUTE_RW_FUNCTION("object", KX_ParentActuator, pyattr_get_object, pyattr_set_object),
- KX_PYATTRIBUTE_INT_RW("mode", KX_PARENT_NODEF+1, KX_PARENT_MAX-1, true, KX_ParentActuator, m_mode),
- KX_PYATTRIBUTE_BOOL_RW("compound", KX_ParentActuator, m_addToCompound),
- KX_PYATTRIBUTE_BOOL_RW("ghost", KX_ParentActuator, m_ghost),
- { NULL } //Sentinel
-};
-
-PyObject *KX_ParentActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_ParentActuator* actuator = static_cast<KX_ParentActuator*>(self);
- if (!actuator->m_ob)
- Py_RETURN_NONE;
- else
- return actuator->m_ob->GetProxy();
-}
-
-int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_ParentActuator* actuator = static_cast<KX_ParentActuator*>(self);
- KX_GameObject *gameobj;
-
- if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_ParentActuator"))
- return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
-
- if (actuator->m_ob != NULL)
- actuator->m_ob->UnregisterActuator(actuator);
-
- actuator->m_ob = (SCA_IObject*) gameobj;
-
- if (actuator->m_ob)
- actuator->m_ob->RegisterActuator(actuator);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h
deleted file mode 100644
index 40baac6b2b2..00000000000
--- a/source/gameengine/Ketsji/KX_ParentActuator.h
+++ /dev/null
@@ -1,91 +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_ParentActuator.h
- * \ingroup ketsji
- * \brief Set or remove an objects parent
- */
-
-#ifndef __KX_PARENTACTUATOR_H__
-#define __KX_PARENTACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "SCA_LogicManager.h"
-
-class KX_ParentActuator : public SCA_IActuator
-{
- Py_Header
-
- /** Mode */
- int m_mode;
-
- /** option */
- bool m_addToCompound;
- bool m_ghost;
- /** Object to set as parent */
- SCA_IObject *m_ob;
-
-
-
-public:
- enum KX_PARENTACT_MODE
- {
- KX_PARENT_NODEF = 0,
- KX_PARENT_SET,
- KX_PARENT_REMOVE,
- KX_PARENT_MAX
-
- };
-
- KX_ParentActuator(class SCA_IObject* gameobj,
- int mode,
- bool addToCompound,
- bool ghost,
- SCA_IObject *ob);
- virtual ~KX_ParentActuator();
- virtual bool Update();
-
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
- virtual bool UnlinkObject(SCA_IObject* clientobj);
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- /* These are used to get and set m_ob */
- static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
-#endif /* WITH_PYTHON */
-
-}; /* end of class KX_ParentActuator : public SCA_PropertyActuator */
-
-#endif /* __KX_PARENTACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_PhysicsEngineEnums.h b/source/gameengine/Ketsji/KX_PhysicsEngineEnums.h
deleted file mode 100644
index ca99c2e7526..00000000000
--- a/source/gameengine/Ketsji/KX_PhysicsEngineEnums.h
+++ /dev/null
@@ -1,42 +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_PhysicsEngineEnums.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_PHYSICSENGINEENUMS_H__
-#define __KX_PHYSICSENGINEENUMS_H__
-
-enum e_PhysicsEngine
-{
- NoSelection = -1,
- UseNone = 0,
- UseBullet = 5,
-};
-
-#endif /* __KX_PHYSICSENGINEENUMS_H__ */
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp
deleted file mode 100644
index 4454543161b..00000000000
--- a/source/gameengine/Ketsji/KX_PolyProxy.cpp
+++ /dev/null
@@ -1,266 +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_PolyProxy.cpp
- * \ingroup ketsji
- */
-
-
-#ifdef WITH_PYTHON
-
-#include "KX_PolyProxy.h"
-#include "KX_MeshProxy.h"
-#include "RAS_MeshObject.h"
-#include "RAS_Polygon.h"
-#include "KX_BlenderMaterial.h"
-
-#include "KX_PyMath.h"
-
-PyTypeObject KX_PolyProxy::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_PolyProxy",
- 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,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_PolyProxy::Methods[] = {
- KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMaterialIndex),
- KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getNumVertex),
- KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,isVisible),
- KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,isCollider),
- KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMaterialName),
- KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getTextureName),
- KX_PYMETHODTABLE(KX_PolyProxy,getVertexIndex),
- KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMesh),
- KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMaterial),
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_PolyProxy::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("material_name", KX_PolyProxy, pyattr_get_material_name),
- KX_PYATTRIBUTE_RO_FUNCTION("texture_name", KX_PolyProxy, pyattr_get_texture_name),
- KX_PYATTRIBUTE_RO_FUNCTION("material", KX_PolyProxy, pyattr_get_material),
- KX_PYATTRIBUTE_RO_FUNCTION("material_id", KX_PolyProxy, pyattr_get_material_id),
- KX_PYATTRIBUTE_RO_FUNCTION("v1", KX_PolyProxy, pyattr_get_v1),
- KX_PYATTRIBUTE_RO_FUNCTION("v2", KX_PolyProxy, pyattr_get_v2),
- KX_PYATTRIBUTE_RO_FUNCTION("v3", KX_PolyProxy, pyattr_get_v3),
- KX_PYATTRIBUTE_RO_FUNCTION("v4", KX_PolyProxy, pyattr_get_v4),
- KX_PYATTRIBUTE_RO_FUNCTION("visible", KX_PolyProxy, pyattr_get_visible),
- KX_PYATTRIBUTE_RO_FUNCTION("collide", KX_PolyProxy, pyattr_get_collide),
- { NULL } //Sentinel
-};
-
-KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
-: m_polygon(polygon),
- m_mesh((RAS_MeshObject*)mesh)
-{
-}
-
-KX_PolyProxy::~KX_PolyProxy()
-{
-}
-
-
-// stuff for cvalue related things
-CValue* KX_PolyProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;}
-CValue* KX_PolyProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;}
-static STR_String sPolyName = "polygone";
-const STR_String & KX_PolyProxy::GetText() {return sPolyName;};
-double KX_PolyProxy::GetNumber() { return -1;}
-STR_String& KX_PolyProxy::GetName() { return sPolyName;}
-void KX_PolyProxy::SetName(const char *) { };
-CValue* KX_PolyProxy::GetReplica() { return NULL;}
-
-// stuff for python integration
-
-PyObject *KX_PolyProxy::pyattr_get_material_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
- return self->PygetMaterialName();
-}
-
-PyObject *KX_PolyProxy::pyattr_get_texture_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
- return self->PygetTextureName();
-}
-
-PyObject *KX_PolyProxy::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
- return self->PygetMaterial();
-}
-
-PyObject *KX_PolyProxy::pyattr_get_material_id(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
- return self->PygetMaterialIndex();
-}
-
-PyObject *KX_PolyProxy::pyattr_get_v1(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
-
- return PyLong_FromLong(self->m_polygon->GetVertexOffsetAbsolute(0));
-}
-
-PyObject *KX_PolyProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
-
- return PyLong_FromLong(self->m_polygon->GetVertexOffsetAbsolute(1));
-}
-
-PyObject *KX_PolyProxy::pyattr_get_v3(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
-
- return PyLong_FromLong(self->m_polygon->GetVertexOffsetAbsolute(2));
-}
-
-PyObject *KX_PolyProxy::pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
-
- if (3 < self->m_polygon->VertexCount())
- {
- return PyLong_FromLong(self->m_polygon->GetVertexOffsetAbsolute(3));
- }
- return PyLong_FromLong(0);
-}
-
-PyObject *KX_PolyProxy::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
- return self->PyisVisible();
-}
-
-PyObject *KX_PolyProxy::pyattr_get_collide(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v);
- return self->PyisCollider();
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialIndex,
-"getMaterialIndex() : return the material index of the polygon in the mesh\n")
-{
- RAS_MaterialBucket* polyBucket = m_polygon->GetMaterial();
- unsigned int matid;
- for (matid=0; matid<(unsigned int)m_mesh->NumMaterials(); matid++)
- {
- RAS_MeshMaterial* meshMat = m_mesh->GetMeshMaterial(matid);
- if (meshMat->m_bucket == polyBucket)
- // found it
- break;
- }
- return PyLong_FromLong(matid);
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getNumVertex,
-"getNumVertex() : returns the number of vertex of the polygon, 3 or 4\n")
-{
- return PyLong_FromLong(m_polygon->VertexCount());
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isVisible,
-"isVisible() : returns whether the polygon is visible or not\n")
-{
- return PyLong_FromLong(m_polygon->IsVisible());
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isCollider,
-"isCollider() : returns whether the polygon is receives collision or not\n")
-{
- return PyLong_FromLong(m_polygon->IsCollider());
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialName,
-"getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n")
-{
- return PyUnicode_From_STR_String(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getTextureName,
-"getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n")
-{
- return PyUnicode_From_STR_String(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
-}
-
-KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
-"getVertexIndex(vertex) : returns the mesh vertex index of a polygon vertex\n"
-"vertex: index of the vertex in the polygon: 0->3\n"
-"return value can be used to retrieve the vertex details through mesh proxy\n"
-"Note: getVertexIndex(3) on a triangle polygon returns 0\n")
-{
- int index;
- if (!PyArg_ParseTuple(args,"i:getVertexIndex",&index))
- {
- return NULL;
- }
- if (index < 0 || index > 3)
- {
- PyErr_SetString(PyExc_AttributeError, "poly.getVertexIndex(int): KX_PolyProxy, expected an index between 0-3");
- return NULL;
- }
- if (index < m_polygon->VertexCount())
- {
- return PyLong_FromLong(m_polygon->GetVertexOffsetAbsolute(index));
- }
- return PyLong_FromLong(0);
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMesh,
-"getMesh() : returns a mesh proxy\n")
-{
- KX_MeshProxy* meshproxy = new KX_MeshProxy((RAS_MeshObject*)m_mesh);
- return meshproxy->NewProxy(true);
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterial,
-"getMaterial() : returns a material\n")
-{
- RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
- KX_BlenderMaterial* mat = static_cast<KX_BlenderMaterial*>(polymat);
- return mat->GetProxy();
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h
deleted file mode 100644
index 837e7f8354c..00000000000
--- a/source/gameengine/Ketsji/KX_PolyProxy.h
+++ /dev/null
@@ -1,85 +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_PolyProxy.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_POLYPROXY_H__
-#define __KX_POLYPROXY_H__
-
-#ifdef WITH_PYTHON
-
-#include "SCA_IObject.h"
-
-class KX_PolyProxy : public CValue
-{
- Py_Header
-protected:
- class RAS_Polygon* m_polygon;
- class RAS_MeshObject* m_mesh;
-public:
- KX_PolyProxy(const class RAS_MeshObject*mesh, class RAS_Polygon* polygon);
- virtual ~KX_PolyProxy();
-
- // stuff for cvalue related things
- CValue* Calc(VALUE_OPERATOR op, CValue *val);
- CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
- const STR_String & GetText();
- double GetNumber();
- STR_String& GetName();
- void SetName(const char *name); // Set the name of the value
- CValue* GetReplica();
-
-
-// stuff for python integration
- static PyObject *pyattr_get_material_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_texture_name(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_material_id(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_v1(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_v3(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_collide(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
- KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialIndex)
- KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getNumVertex)
- KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,isVisible)
- KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,isCollider)
- KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialName)
- KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getTextureName)
- KX_PYMETHOD_DOC(KX_PolyProxy,getVertexIndex)
- KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMesh)
- KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterial)
-
-};
-
-#endif /* WITH_PYTHON */
-
-#endif /* __KX_POLYPROXY_H__ */
diff --git a/source/gameengine/Ketsji/KX_PositionInterpolator.cpp b/source/gameengine/Ketsji/KX_PositionInterpolator.cpp
deleted file mode 100644
index 1e217ecf616..00000000000
--- a/source/gameengine/Ketsji/KX_PositionInterpolator.cpp
+++ /dev/null
@@ -1,42 +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_PositionInterpolator.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_PositionInterpolator.h"
-#include "MT_Point3.h"
-#include "KX_IScalarInterpolator.h"
-
-void KX_PositionInterpolator::Execute(float currentTime) const
-{
- m_target.setValue(m_ipos[0]->GetValue(currentTime),
- m_ipos[1]->GetValue(currentTime),
- m_ipos[2]->GetValue(currentTime));
-}
diff --git a/source/gameengine/Ketsji/KX_PositionInterpolator.h b/source/gameengine/Ketsji/KX_PositionInterpolator.h
deleted file mode 100644
index b5ab053bb0e..00000000000
--- a/source/gameengine/Ketsji/KX_PositionInterpolator.h
+++ /dev/null
@@ -1,64 +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_PositionInterpolator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_POSITIONINTERPOLATOR_H__
-#define __KX_POSITIONINTERPOLATOR_H__
-
-#include "KX_IInterpolator.h"
-
-class MT_Point3;
-class KX_IScalarInterpolator;
-
-class KX_PositionInterpolator : public KX_IInterpolator {
-public:
- KX_PositionInterpolator(MT_Point3& target,
- KX_IScalarInterpolator *ipos[]) :
- m_target(target)
- {
- m_ipos[0] = ipos[0];
- m_ipos[1] = ipos[1];
- m_ipos[2] = ipos[2];
- }
-
- virtual void Execute(float currentTime) const;
-
-private:
- MT_Point3& m_target;
- KX_IScalarInterpolator *m_ipos[3];
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_PositionInterpolator")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
deleted file mode 100644
index 81fe3be1fcf..00000000000
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
+++ /dev/null
@@ -1,750 +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_PyConstraintBinding.cpp
- * \ingroup ketsji
- */
-
-#include "KX_PyConstraintBinding.h"
-#include "PHY_IPhysicsEnvironment.h"
-#include "KX_ConstraintWrapper.h"
-#include "KX_VehicleWrapper.h"
-#include "KX_CharacterWrapper.h"
-#include "PHY_IPhysicsController.h"
-#include "PHY_IVehicle.h"
-#include "PHY_DynamicTypes.h"
-#include "MT_Matrix3x3.h"
-
-#include "KX_GameObject.h" // ConvertPythonToGameObject()
-#include "KX_PythonInit.h"
-
-#include "EXP_PyObjectPlus.h"
-
-#ifdef WITH_BULLET
-# include "LinearMath/btIDebugDraw.h"
-#endif
-
-#ifdef WITH_PYTHON
-
-// macro copied from KX_PythonInit.cpp
-#define KX_MACRO_addTypesToDict(dict, name, name2) PyDict_SetItemString(dict, #name, item=PyLong_FromLong(name2)); Py_DECREF(item)
-
-// nasty glob variable to connect scripting language
-// if there is a better way (without global), please do so!
-static PHY_IPhysicsEnvironment* g_CurrentActivePhysicsEnvironment = NULL;
-
-
-PyDoc_STRVAR(PhysicsConstraints_module_documentation,
-"This is the Python API for the Physics Constraints"
-);
-
-PyDoc_STRVAR(gPySetGravity__doc__,
-"setGravity(float x,float y,float z)\n"
-""
-);
-PyDoc_STRVAR(gPySetDebugMode__doc__,
-"setDebugMode(int mode)\n"
-""
-);
-
-PyDoc_STRVAR(gPySetNumIterations__doc__,
-"setNumIterations(int numiter)\n"
-"This sets the number of iterations for an iterative constraint solver"
-);
-PyDoc_STRVAR(gPySetNumTimeSubSteps__doc__,
-"setNumTimeSubSteps(int numsubstep)\n"
-"This sets the number of substeps for each physics proceed. Tradeoff quality for performance."
-);
-
-PyDoc_STRVAR(gPySetDeactivationTime__doc__,
-"setDeactivationTime(float time)\n"
-"This sets the time after which a resting rigidbody gets deactived"
-);
-PyDoc_STRVAR(gPySetDeactivationLinearTreshold__doc__,
-"setDeactivationLinearTreshold(float linearTreshold)\n"
-""
-);
-PyDoc_STRVAR(gPySetDeactivationAngularTreshold__doc__,
-"setDeactivationAngularTreshold(float angularTreshold)\n"
-""
-);
-PyDoc_STRVAR(gPySetContactBreakingTreshold__doc__,
-"setContactBreakingTreshold(float breakingTreshold)\n"
-"Reasonable default is 0.02 (if units are meters)"
-);
-
-PyDoc_STRVAR(gPySetCcdMode__doc__,
-"setCcdMode(int ccdMode)\n"
-"Very experimental, not recommended"
-);
-PyDoc_STRVAR(gPySetSorConstant__doc__,
-"setSorConstant(float sor)\n"
-"Very experimental, not recommended"
-);
-PyDoc_STRVAR(gPySetSolverTau__doc__,
-"setTau(float tau)\n"
-"Very experimental, not recommended"
-);
-PyDoc_STRVAR(gPySetSolverDamping__doc__,
-"setDamping(float damping)\n"
-"Very experimental, not recommended"
-);
-PyDoc_STRVAR(gPySetLinearAirDamping__doc__,
-"setLinearAirDamping(float damping)\n"
-"Very experimental, not recommended"
-);
-PyDoc_STRVAR(gPySetUseEpa__doc__,
-"setUseEpa(int epa)\n"
-"Very experimental, not recommended"
-);
-PyDoc_STRVAR(gPySetSolverType__doc__,
-"setSolverType(int solverType)\n"
-"Very experimental, not recommended"
-);
-
-PyDoc_STRVAR(gPyCreateConstraint__doc__,
-"createConstraint(ob1,ob2,float restLength,float restitution,float damping)\n"
-""
-);
-PyDoc_STRVAR(gPyGetVehicleConstraint__doc__,
-"getVehicleConstraint(int constraintId)\n"
-""
-);
-PyDoc_STRVAR(gPyGetCharacter__doc__,
-"getCharacter(KX_GameObject obj)\n"
-""
-);
-PyDoc_STRVAR(gPyRemoveConstraint__doc__,
-"removeConstraint(int constraintId)\n"
-""
-);
-PyDoc_STRVAR(gPyGetAppliedImpulse__doc__,
-"getAppliedImpulse(int constraintId)\n"
-""
-);
-
-
-
-
-static PyObject *gPySetGravity(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float x,y,z;
- if (PyArg_ParseTuple(args,"fff",&x,&y,&z))
- {
- if (PHY_GetActiveEnvironment())
- PHY_GetActiveEnvironment()->SetGravity(x,y,z);
- }
- else {
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPySetDebugMode(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- int mode;
- if (PyArg_ParseTuple(args,"i",&mode))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetDebugMode(mode);
-
- }
-
- }
- else {
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-
-
-static PyObject *gPySetNumTimeSubSteps(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- int substep;
- if (PyArg_ParseTuple(args,"i",&substep))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetNumTimeSubSteps(substep);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-static PyObject *gPySetNumIterations(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- int iter;
- if (PyArg_ParseTuple(args,"i",&iter))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetNumIterations(iter);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-static PyObject *gPySetDeactivationTime(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float deactive_time;
- if (PyArg_ParseTuple(args,"f",&deactive_time))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetDeactivationTime(deactive_time);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-static PyObject *gPySetDeactivationLinearTreshold(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float linearDeactivationTreshold;
- if (PyArg_ParseTuple(args,"f",&linearDeactivationTreshold))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetDeactivationLinearTreshold( linearDeactivationTreshold);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-static PyObject *gPySetDeactivationAngularTreshold(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float angularDeactivationTreshold;
- if (PyArg_ParseTuple(args,"f",&angularDeactivationTreshold))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetDeactivationAngularTreshold( angularDeactivationTreshold);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *gPySetContactBreakingTreshold(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float contactBreakingTreshold;
- if (PyArg_ParseTuple(args,"f",&contactBreakingTreshold))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetContactBreakingTreshold( contactBreakingTreshold);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-static PyObject *gPySetCcdMode(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float ccdMode;
- if (PyArg_ParseTuple(args,"f",&ccdMode))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetCcdMode( ccdMode);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *gPySetSorConstant(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float sor;
- if (PyArg_ParseTuple(args,"f",&sor))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetSolverSorConstant( sor);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *gPySetSolverTau(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float tau;
- if (PyArg_ParseTuple(args,"f",&tau))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetSolverTau( tau);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-static PyObject *gPySetSolverDamping(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float damping;
- if (PyArg_ParseTuple(args,"f",&damping))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetSolverDamping( damping);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *gPySetLinearAirDamping(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float damping;
- if (PyArg_ParseTuple(args,"f",&damping))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetLinearAirDamping( damping);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-static PyObject *gPySetUseEpa(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- int epa;
- if (PyArg_ParseTuple(args,"i",&epa))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetUseEpa(epa);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-static PyObject *gPySetSolverType(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- int solverType;
- if (PyArg_ParseTuple(args,"i",&solverType))
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->SetSolverType(solverType);
- }
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-
-static PyObject *gPyGetVehicleConstraint(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
-#if defined(_WIN64)
- __int64 constraintid;
- if (PyArg_ParseTuple(args,"L",&constraintid))
-#else
- long constraintid;
- if (PyArg_ParseTuple(args,"l",&constraintid))
-#endif
- {
- if (PHY_GetActiveEnvironment())
- {
-
- PHY_IVehicle* vehicle = PHY_GetActiveEnvironment()->GetVehicleConstraint(constraintid);
- if (vehicle)
- {
- KX_VehicleWrapper* pyWrapper = new KX_VehicleWrapper(vehicle,PHY_GetActiveEnvironment());
- return pyWrapper->NewProxy(true);
- }
-
- }
- }
- else {
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject* gPyGetCharacter(PyObject* self,
- PyObject* args,
- PyObject* kwds)
-{
- PyObject* pyob;
- KX_GameObject *ob;
-
- if (!PyArg_ParseTuple(args,"O", &pyob))
- return NULL;
-
- if (!ConvertPythonToGameObject(KX_GetActiveScene()->GetLogicManager(), pyob, &ob, false, "bge.constraints.getCharacter(value)"))
- return NULL;
-
- if (PHY_GetActiveEnvironment())
- {
-
- PHY_ICharacter* character= PHY_GetActiveEnvironment()->GetCharacterController(ob);
- if (character)
- {
- KX_CharacterWrapper* pyWrapper = new KX_CharacterWrapper(character);
- return pyWrapper->NewProxy(true);
- }
-
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyCreateConstraint(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- /* FIXME - physicsid is a long being cast to a pointer, should at least use PyCapsule */
- unsigned long long physicsid = 0, physicsid2 = 0;
- int constrainttype = 0;
- int flag = 0;
- float pivotX = 0.0f, pivotY = 0.0f, pivotZ = 0.0f, axisX = 0.0f, axisY = 0.0f, axisZ = 0.0f;
-
- static const char *kwlist[] = {"physicsid_1", "physicsid_2", "constraint_type", "pivot_x", "pivot_y", "pivot_z",
- "axis_x", "axis_y", "axis_z", "flag", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "KKi|ffffffi:createConstraint", (char **)kwlist,
- &physicsid, &physicsid2, &constrainttype,
- &pivotX, &pivotY, &pivotZ, &axisX, &axisY, &axisZ, &flag))
- {
- return NULL;
- }
-
- if (PHY_GetActiveEnvironment()) {
- PHY_IPhysicsController *physctrl = (PHY_IPhysicsController*)physicsid;
- PHY_IPhysicsController *physctrl2 = (PHY_IPhysicsController*)physicsid2;
- if (physctrl) { //TODO:check for existence of this pointer!
- //convert from euler angle into axis
- const float deg2rad = 0.017453292f;
-
- //we need to pass a full constraint frame, not just axis
- //localConstraintFrameBasis
- MT_Matrix3x3 localCFrame(MT_Vector3(deg2rad*axisX, deg2rad*axisY, deg2rad*axisZ));
- MT_Vector3 axis0 = localCFrame.getColumn(0);
- MT_Vector3 axis1 = localCFrame.getColumn(1);
- MT_Vector3 axis2 = localCFrame.getColumn(2);
-
- int 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);
-
- KX_ConstraintWrapper *wrap = new KX_ConstraintWrapper(
- (enum PHY_ConstraintType)constrainttype, constraintid, PHY_GetActiveEnvironment());
-
- return wrap->NewProxy(true);
- }
- }
- Py_RETURN_NONE;
-}
-
-
-
-
-static PyObject *gPyGetAppliedImpulse(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
- float appliedImpulse = 0.f;
-
-#if defined(_WIN64)
- __int64 constraintid;
- if (PyArg_ParseTuple(args,"L",&constraintid))
-#else
- long constraintid;
- if (PyArg_ParseTuple(args,"l",&constraintid))
-#endif
- {
- if (PHY_GetActiveEnvironment())
- {
- appliedImpulse = PHY_GetActiveEnvironment()->GetAppliedImpulse(constraintid);
- }
- }
- else {
- return NULL;
- }
-
- return PyFloat_FromDouble(appliedImpulse);
-}
-
-
-static PyObject *gPyRemoveConstraint(PyObject *self,
- PyObject *args,
- PyObject *kwds)
-{
-#if defined(_WIN64)
- __int64 constraintid;
- if (PyArg_ParseTuple(args,"L",&constraintid))
-#else
- long constraintid;
- if (PyArg_ParseTuple(args,"l",&constraintid))
-#endif
- {
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->RemoveConstraintById(constraintid);
- }
- }
- else {
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyExportBulletFile(PyObject *, PyObject *args)
-{
- char* filename;
- if (!PyArg_ParseTuple(args,"s:exportBulletFile",&filename))
- return NULL;
-
- if (PHY_GetActiveEnvironment())
- {
- PHY_GetActiveEnvironment()->ExportFile(filename);
- }
- Py_RETURN_NONE;
-}
-
-static struct PyMethodDef physicsconstraints_methods[] = {
- {"setGravity",(PyCFunction) gPySetGravity,
- METH_VARARGS, (const char*)gPySetGravity__doc__},
- {"setDebugMode",(PyCFunction) gPySetDebugMode,
- METH_VARARGS, (const char *)gPySetDebugMode__doc__},
-
- /// settings that influence quality of the rigidbody dynamics
- {"setNumIterations",(PyCFunction) gPySetNumIterations,
- METH_VARARGS, (const char *)gPySetNumIterations__doc__},
-
- {"setNumTimeSubSteps",(PyCFunction) gPySetNumTimeSubSteps,
- METH_VARARGS, (const char *)gPySetNumTimeSubSteps__doc__},
-
- {"setDeactivationTime",(PyCFunction) gPySetDeactivationTime,
- METH_VARARGS, (const char *)gPySetDeactivationTime__doc__},
-
- {"setDeactivationLinearTreshold",(PyCFunction) gPySetDeactivationLinearTreshold,
- METH_VARARGS, (const char *)gPySetDeactivationLinearTreshold__doc__},
- {"setDeactivationAngularTreshold",(PyCFunction) gPySetDeactivationAngularTreshold,
- METH_VARARGS, (const char *)gPySetDeactivationAngularTreshold__doc__},
-
- {"setContactBreakingTreshold",(PyCFunction) gPySetContactBreakingTreshold,
- METH_VARARGS, (const char *)gPySetContactBreakingTreshold__doc__},
- {"setCcdMode",(PyCFunction) gPySetCcdMode,
- METH_VARARGS, (const char *)gPySetCcdMode__doc__},
- {"setSorConstant",(PyCFunction) gPySetSorConstant,
- METH_VARARGS, (const char *)gPySetSorConstant__doc__},
- {"setSolverTau",(PyCFunction) gPySetSolverTau,
- METH_VARARGS, (const char *)gPySetSolverTau__doc__},
- {"setSolverDamping",(PyCFunction) gPySetSolverDamping,
- METH_VARARGS, (const char *)gPySetSolverDamping__doc__},
-
- {"setLinearAirDamping",(PyCFunction) gPySetLinearAirDamping,
- METH_VARARGS, (const char *)gPySetLinearAirDamping__doc__},
-
- {"setUseEpa",(PyCFunction) gPySetUseEpa,
- METH_VARARGS, (const char *)gPySetUseEpa__doc__},
- {"setSolverType",(PyCFunction) gPySetSolverType,
- METH_VARARGS, (const char *)gPySetSolverType__doc__},
-
-
- {"createConstraint",(PyCFunction) gPyCreateConstraint,
- METH_VARARGS|METH_KEYWORDS, (const char *)gPyCreateConstraint__doc__},
- {"getVehicleConstraint",(PyCFunction) gPyGetVehicleConstraint,
- METH_VARARGS, (const char *)gPyGetVehicleConstraint__doc__},
-
- {"getCharacter",(PyCFunction) gPyGetCharacter,
- METH_VARARGS, (const char *)gPyGetCharacter__doc__},
-
- {"removeConstraint",(PyCFunction) gPyRemoveConstraint,
- METH_VARARGS, (const char *)gPyRemoveConstraint__doc__},
- {"getAppliedImpulse",(PyCFunction) gPyGetAppliedImpulse,
- METH_VARARGS, (const char *)gPyGetAppliedImpulse__doc__},
-
- {"exportBulletFile",(PyCFunction)gPyExportBulletFile,
- METH_VARARGS, "export a .bullet file"},
-
- //sentinel
- { NULL, (PyCFunction) NULL, 0, NULL }
-};
-
-static struct PyModuleDef PhysicsConstraints_module_def = {
- PyModuleDef_HEAD_INIT,
- "PhysicsConstraints", /* m_name */
- PhysicsConstraints_module_documentation, /* m_doc */
- 0, /* m_size */
- physicsconstraints_methods, /* m_methods */
- 0, /* m_reload */
- 0, /* m_traverse */
- 0, /* m_clear */
- 0, /* m_free */
-};
-
-PyMODINIT_FUNC initConstraintPythonBinding()
-{
-
- PyObject *ErrorObject;
- PyObject *m;
- PyObject *d;
- PyObject *item;
-
- m = PyModule_Create(&PhysicsConstraints_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), PhysicsConstraints_module_def.m_name, m);
-
- // Add some symbolic constants to the module
- d = PyModule_GetDict(m);
- ErrorObject = PyUnicode_FromString("PhysicsConstraints.error");
- PyDict_SetItemString(d, "error", ErrorObject);
- Py_DECREF(ErrorObject);
-
-#ifdef WITH_BULLET
- //Debug Modes constants to be used with setDebugMode() python function
- KX_MACRO_addTypesToDict(d, DBG_NODEBUG, btIDebugDraw::DBG_NoDebug);
- KX_MACRO_addTypesToDict(d, DBG_DRAWWIREFRAME, btIDebugDraw::DBG_DrawWireframe);
- KX_MACRO_addTypesToDict(d, DBG_DRAWAABB, btIDebugDraw::DBG_DrawAabb);
- KX_MACRO_addTypesToDict(d, DBG_DRAWFREATURESTEXT, btIDebugDraw::DBG_DrawFeaturesText);
- KX_MACRO_addTypesToDict(d, DBG_DRAWCONTACTPOINTS, btIDebugDraw::DBG_DrawContactPoints);
- KX_MACRO_addTypesToDict(d, DBG_NOHELPTEXT, btIDebugDraw::DBG_NoHelpText);
- KX_MACRO_addTypesToDict(d, DBG_DRAWTEXT, btIDebugDraw::DBG_DrawText);
- KX_MACRO_addTypesToDict(d, DBG_PROFILETIMINGS, btIDebugDraw::DBG_ProfileTimings);
- KX_MACRO_addTypesToDict(d, DBG_ENABLESATCOMPARISION, btIDebugDraw::DBG_EnableSatComparison);
- KX_MACRO_addTypesToDict(d, DBG_DISABLEBULLETLCP, btIDebugDraw::DBG_DisableBulletLCP);
- KX_MACRO_addTypesToDict(d, DBG_ENABLECCD, btIDebugDraw::DBG_EnableCCD);
- KX_MACRO_addTypesToDict(d, DBG_DRAWCONSTRAINTS, btIDebugDraw::DBG_DrawConstraints);
- KX_MACRO_addTypesToDict(d, DBG_DRAWCONSTRAINTLIMITS, btIDebugDraw::DBG_DrawConstraintLimits);
- KX_MACRO_addTypesToDict(d, DBG_FASTWIREFRAME, btIDebugDraw::DBG_FastWireframe);
-#endif // WITH_BULLET
-
- //Constraint types to be used with createConstraint() python function
- KX_MACRO_addTypesToDict(d, POINTTOPOINT_CONSTRAINT, PHY_POINT2POINT_CONSTRAINT);
- KX_MACRO_addTypesToDict(d, LINEHINGE_CONSTRAINT, PHY_LINEHINGE_CONSTRAINT);
- KX_MACRO_addTypesToDict(d, ANGULAR_CONSTRAINT, PHY_ANGULAR_CONSTRAINT);
- KX_MACRO_addTypesToDict(d, CONETWIST_CONSTRAINT, PHY_CONE_TWIST_CONSTRAINT);
- KX_MACRO_addTypesToDict(d, VEHICLE_CONSTRAINT, PHY_VEHICLE_CONSTRAINT);
- KX_MACRO_addTypesToDict(d, GENERIC_6DOF_CONSTRAINT, PHY_GENERIC_6DOF_CONSTRAINT);
-
- // Check for errors
- if (PyErr_Occurred()) {
- Py_FatalError("can't initialize module PhysicsConstraints");
- }
-
- return m;
-}
-
-#if 0
-static void KX_RemovePythonConstraintBinding()
-{
-}
-#endif
-
-void PHY_SetActiveEnvironment(class PHY_IPhysicsEnvironment* env)
-{
- g_CurrentActivePhysicsEnvironment = env;
-}
-
-PHY_IPhysicsEnvironment* PHY_GetActiveEnvironment()
-{
- return g_CurrentActivePhysicsEnvironment;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.h b/source/gameengine/Ketsji/KX_PyConstraintBinding.h
deleted file mode 100644
index 2bf9f7e197d..00000000000
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.h
+++ /dev/null
@@ -1,45 +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_PyConstraintBinding.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_PYCONSTRAINTBINDING_H__
-#define __KX_PYCONSTRAINTBINDING_H__
-
-#ifdef WITH_PYTHON
-
-#include <Python.h>
-
-PyMODINIT_FUNC initConstraintPythonBinding();
-
-void PHY_SetActiveEnvironment(class PHY_IPhysicsEnvironment* env);
-PHY_IPhysicsEnvironment* PHY_GetActiveEnvironment();
-#endif /* WITH_PYTHON */
-
-#endif /* __KX_PYCONSTRAINTBINDING_H__ */
diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp
deleted file mode 100644
index ee05fd442ab..00000000000
--- a/source/gameengine/Ketsji/KX_PyMath.cpp
+++ /dev/null
@@ -1,215 +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 *****
- * Initialize Python thingies.
- */
-
-/** \file gameengine/Ketsji/KX_PyMath.cpp
- * \ingroup ketsji
- */
-
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#ifdef WITH_PYTHON
-
-#include "MT_Vector3.h"
-#include "MT_Vector4.h"
-#include "MT_Matrix4x4.h"
-#include "MT_Point2.h"
-
-#include "EXP_ListValue.h"
-
-#include "EXP_Python.h"
-#include "KX_PyMath.h"
-
-bool PyOrientationTo(PyObject *pyval, MT_Matrix3x3 &rot, const char *error_prefix)
-{
- int size= PySequence_Size(pyval);
-
- if (size == 4)
- {
- MT_Quaternion qrot;
- if (PyQuatTo(pyval, qrot))
- {
- rot.setRotation(qrot);
- return true;
- }
- }
- else if (size == 3) {
- /* 3x3 matrix or euler */
- MT_Vector3 erot;
- if (PyVecTo(pyval, erot))
- {
- rot.setEuler(erot);
- return true;
- }
- PyErr_Clear();
-
- if (PyMatTo(pyval, rot))
- {
- return true;
- }
- }
-
- PyErr_Format(PyExc_TypeError, "%s, could not set the orientation from a 3x3 matrix, quaternion or euler sequence", error_prefix);
- return false;
-}
-
-bool PyQuatTo(PyObject *pyval, MT_Quaternion &qrot)
-{
- if (!PyVecTo(pyval, qrot))
- return false;
-
- /* annoying!, Blender/Mathutils have the W axis first! */
- MT_Scalar w = qrot[0]; /* from python, this is actually the W */
- qrot[0] = qrot[1];
- qrot[1] = qrot[2];
- qrot[2] = qrot[3];
- qrot[3] = w;
-
- return true;
-}
-
-PyObject *PyObjectFrom(const MT_Matrix4x4 &mat)
-{
-#ifdef USE_MATHUTILS
- float fmat[16];
- mat.getValue(fmat);
- return Matrix_CreatePyObject(fmat, 4, 4, NULL);
-#else
- PyObject *collist = PyList_New(4);
- PyObject *col;
- int i;
-
- for (i=0; i < 4; i++) {
- col = PyList_New(4);
- PyList_SET_ITEM(col, 0, PyFloat_FromDouble(mat[0][i]));
- PyList_SET_ITEM(col, 1, PyFloat_FromDouble(mat[1][i]));
- PyList_SET_ITEM(col, 2, PyFloat_FromDouble(mat[2][i]));
- PyList_SET_ITEM(col, 3, PyFloat_FromDouble(mat[3][i]));
- PyList_SET_ITEM(collist, i, col);
- }
-
- return collist;
-#endif
-}
-
-PyObject *PyObjectFrom(const MT_Matrix3x3 &mat)
-{
-#ifdef USE_MATHUTILS
- float fmat[9];
- mat.getValue3x3(fmat);
- return Matrix_CreatePyObject(fmat, 3, 3, NULL);
-#else
- PyObject *collist = PyList_New(3);
- PyObject *col;
- int i;
-
- for (i=0; i < 3; i++) {
- col = PyList_New(3);
- PyList_SET_ITEM(col, 0, PyFloat_FromDouble(mat[0][i]));
- PyList_SET_ITEM(col, 1, PyFloat_FromDouble(mat[1][i]));
- PyList_SET_ITEM(col, 2, PyFloat_FromDouble(mat[2][i]));
- PyList_SET_ITEM(collist, i, col);
- }
-
- return collist;
-#endif
-}
-
-#ifdef USE_MATHUTILS
-PyObject *PyObjectFrom(const MT_Quaternion &qrot)
-{
- /* NOTE, were re-ordering here for Mathutils compat */
- float fvec[4];
- qrot.getValue(fvec);
- return Quaternion_CreatePyObject(fvec, NULL);
-}
-#endif
-
-PyObject *PyObjectFrom(const MT_Tuple4 &vec)
-{
-#ifdef USE_MATHUTILS
- float fvec[4];
- vec.getValue(fvec);
- return Vector_CreatePyObject(fvec, 4, NULL);
-#else
- PyObject *list = PyList_New(4);
- PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
- PyList_SET_ITEM(list, 1, PyFloat_FromDouble(vec[1]));
- PyList_SET_ITEM(list, 2, PyFloat_FromDouble(vec[2]));
- PyList_SET_ITEM(list, 3, PyFloat_FromDouble(vec[3]));
- return list;
-#endif
-}
-
-PyObject *PyObjectFrom(const MT_Tuple3 &vec)
-{
-#ifdef USE_MATHUTILS
- float fvec[3];
- vec.getValue(fvec);
- return Vector_CreatePyObject(fvec, 3, NULL);
-#else
- PyObject *list = PyList_New(3);
- PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
- PyList_SET_ITEM(list, 1, PyFloat_FromDouble(vec[1]));
- PyList_SET_ITEM(list, 2, PyFloat_FromDouble(vec[2]));
- return list;
-#endif
-}
-
-PyObject *PyObjectFrom(const MT_Tuple2 &vec)
-{
-#ifdef USE_MATHUTILS
- float fvec[2];
- vec.getValue(fvec);
- return Vector_CreatePyObject(fvec, 2, NULL);
-#else
- PyObject *list = PyList_New(2);
- PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
- PyList_SET_ITEM(list, 1, PyFloat_FromDouble(vec[1]));
- return list;
-#endif
-}
-
-PyObject *PyColorFromVector(const MT_Vector3 &vec)
-{
-#ifdef USE_MATHUTILS
- float fvec[3];
- vec.getValue(fvec);
- return Color_CreatePyObject(fvec, NULL);
-#else
- PyObject *list = PyList_New(3);
- PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0]));
- PyList_SET_ITEM(list, 1, PyFloat_FromDouble(vec[1]));
- PyList_SET_ITEM(list, 2, PyFloat_FromDouble(vec[2]));
- return list;
-#endif
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h
deleted file mode 100644
index 917fd0fcda6..00000000000
--- a/source/gameengine/Ketsji/KX_PyMath.h
+++ /dev/null
@@ -1,281 +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_PyMath.h
- * \ingroup ketsji
- * \brief Initialize Python thingies.
- */
-
-#ifndef __KX_PYMATH_H__
-#define __KX_PYMATH_H__
-
-#include "MT_Point2.h"
-#include "MT_Point3.h"
-#include "MT_Vector2.h"
-#include "MT_Vector3.h"
-#include "MT_Vector4.h"
-#include "MT_Matrix3x3.h"
-#include "MT_Matrix4x4.h"
-
-#include "EXP_Python.h"
-#include "EXP_PyObjectPlus.h"
-
-#ifdef WITH_PYTHON
-#ifdef USE_MATHUTILS
-extern "C" {
-#include "../../blender/python/mathutils/mathutils.h" /* so we can have mathutils callbacks */
-}
-#endif
-
-inline unsigned int Size(const MT_Matrix4x4&) { return 4; }
-inline unsigned int Size(const MT_Matrix3x3&) { return 3; }
-inline unsigned int Size(const MT_Tuple2&) { return 2; }
-inline unsigned int Size(const MT_Tuple3&) { return 3; }
-inline unsigned int Size(const MT_Tuple4&) { return 4; }
-
-/**
- * Converts the given python matrix (column-major) to an MT class (row-major).
- */
-template<class T>
-bool PyMatTo(PyObject *pymat, T& mat)
-{
- bool noerror = true;
- mat.setIdentity();
-
-
-#ifdef USE_MATHUTILS
-
- if (MatrixObject_Check(pymat))
- {
- MatrixObject *pymatrix = (MatrixObject *)pymat;
-
- if (BaseMath_ReadCallback(pymatrix) == -1)
- return false;
-
- if (pymatrix->num_col != Size(mat) || pymatrix->num_row != Size(mat))
- return false;
-
- for (unsigned int row = 0; row < Size(mat); row++)
- {
- for (unsigned int col = 0; col < Size(mat); col++)
- {
- mat[row][col] = *(pymatrix->matrix + col * pymatrix->num_row + row);
- }
- }
- }
- else
-
-#endif /* USE_MATHUTILS */
-
-
- if (PySequence_Check(pymat))
- {
- unsigned int rows = PySequence_Size(pymat);
- if (rows != Size(mat))
- return false;
-
- for (unsigned int row = 0; noerror && row < rows; row++)
- {
- PyObject *pyrow = PySequence_GetItem(pymat, row); /* new ref */
- if (!PyErr_Occurred() && PySequence_Check(pyrow))
- {
- unsigned int cols = PySequence_Size(pyrow);
- if (cols != Size(mat)) {
- noerror = false;
- }
- else {
- for (unsigned int col = 0; col < cols; col++) {
- PyObject *item = PySequence_GetItem(pyrow, col); /* new ref */
- mat[row][col] = PyFloat_AsDouble(item);
- Py_DECREF(item);
- }
- }
- }
- else {
- noerror = false;
- }
- Py_DECREF(pyrow);
- }
- } else
- noerror = false;
-
- if (noerror==false)
- PyErr_SetString(PyExc_TypeError, "could not be converted to a matrix (sequence of sequences)");
-
- return noerror;
-}
-
-/**
- * Converts a python sequence to a MT class.
- */
-template<class T>
-bool PyVecTo(PyObject *pyval, T& vec)
-{
-#ifdef USE_MATHUTILS
- /* no need for BaseMath_ReadCallback() here, reading the sequences will do this */
-
- if (VectorObject_Check(pyval)) {
- VectorObject *pyvec= (VectorObject *)pyval;
- if (BaseMath_ReadCallback(pyvec) == -1) {
- return false; /* exception raised */
- }
- if (pyvec->size != Size(vec)) {
- PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", pyvec->size, Size(vec));
- return false;
- }
- vec.setValue((float *) pyvec->vec);
- return true;
- }
- else if (QuaternionObject_Check(pyval)) {
- QuaternionObject *pyquat= (QuaternionObject *)pyval;
- if (BaseMath_ReadCallback(pyquat) == -1) {
- return false; /* exception raised */
- }
- if (4 != Size(vec)) {
- PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 4, Size(vec));
- return false;
- }
- /* xyzw -> wxyz reordering is done by PyQuatTo */
- vec.setValue((float *) pyquat->quat);
- return true;
- }
- else if (EulerObject_Check(pyval)) {
- EulerObject *pyeul= (EulerObject *)pyval;
- if (BaseMath_ReadCallback(pyeul) == -1) {
- return false; /* exception raised */
- }
- if (3 != Size(vec)) {
- PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", 3, Size(vec));
- return false;
- }
- vec.setValue((float *) pyeul->eul);
- return true;
- }
- else
-#endif
- if (PyTuple_Check(pyval)) {
- unsigned int numitems = PyTuple_GET_SIZE(pyval);
- if (numitems != Size(vec)) {
- PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", numitems, Size(vec));
- return false;
- }
-
- for (unsigned int x = 0; x < numitems; x++)
- vec[x] = PyFloat_AsDouble(PyTuple_GET_ITEM(pyval, x)); /* borrow ref */
-
- if (PyErr_Occurred()) {
- PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float");
- return false;
- }
-
- return true;
- }
- else if (PyObject_TypeCheck(pyval, (PyTypeObject *)&PyObjectPlus::Type)) {
- /* note, include this check because PySequence_Check does too much introspection
- * on the PyObject (like getting its __class__, on a BGE type this means searching up
- * the parent list each time only to discover its not a sequence.
- * GameObjects are often used as an alternative to vectors so this is a common case
- * better to do a quick check for it, likely the error below will be ignored.
- *
- * This is not 'correct' since we have proxy type CListValues's which could
- * contain floats/ints but there no cases of CValueLists being this way
- */
- PyErr_Format(PyExc_AttributeError, "expected a sequence type");
- return false;
- }
- else if (PySequence_Check(pyval)) {
- unsigned int numitems = PySequence_Size(pyval);
- if (numitems != Size(vec)) {
- PyErr_Format(PyExc_AttributeError, "error setting vector, %d args, should be %d", numitems, Size(vec));
- return false;
- }
-
- for (unsigned int x = 0; x < numitems; x++) {
- PyObject *item = PySequence_GetItem(pyval, x); /* new ref */
- vec[x] = PyFloat_AsDouble(item);
- Py_DECREF(item);
- }
-
- if (PyErr_Occurred()) {
- PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float");
- return false;
- }
-
- return true;
- }
- else {
- PyErr_Format(PyExc_AttributeError, "not a sequence type, expected a sequence of numbers size %d", Size(vec));
- }
-
- return false;
-}
-
-
-bool PyQuatTo(PyObject *pyval, MT_Quaternion &qrot);
-
-bool PyOrientationTo(PyObject *pyval, MT_Matrix3x3 &mat, const char *error_prefix);
-
-/**
- * Converts an MT_Matrix4x4 to a python object.
- */
-PyObject *PyObjectFrom(const MT_Matrix4x4 &mat);
-
-/**
- * Converts an MT_Matrix3x3 to a python object.
- */
-PyObject *PyObjectFrom(const MT_Matrix3x3 &mat);
-
-/**
- * Converts an MT_Tuple2 to a python object.
- */
-PyObject *PyObjectFrom(const MT_Tuple2 &vec);
-
-/**
- * Converts an MT_Tuple3 to a python object
- */
-PyObject *PyObjectFrom(const MT_Tuple3 &vec);
-
-#ifdef USE_MATHUTILS
-/**
- * Converts an MT_Quaternion to a python object.
- */
-PyObject *PyObjectFrom(const MT_Quaternion &qrot);
-#endif
-
-/**
- * Converts an MT_Tuple4 to a python object.
- */
-PyObject *PyObjectFrom(const MT_Tuple4 &pos);
-
-#endif
-
-/**
- * Converts an MT_Vector3 to a python color object.
- */
-PyObject *PyColorFromVector(const MT_Vector3 &vec);
-
-#endif /* WITH_PYTHON */
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
deleted file mode 100644
index 5540aad7a3f..00000000000
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ /dev/null
@@ -1,2953 +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 *****
- * Initialize Python thingies.
- */
-
-/** \file gameengine/Ketsji/KX_PythonInit.cpp
- * \ingroup ketsji
- */
-
-#include "GPU_glew.h"
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#ifdef WITH_PYTHON
-# ifdef _XOPEN_SOURCE
-# undef _XOPEN_SOURCE
-# endif
-# include <Python.h>
-
-extern "C" {
- # include "BLI_utildefines.h"
- # include "python_utildefines.h"
- # include "bpy_internal_import.h" /* from the blender python api, but we want to import text too! */
- # include "py_capi_utils.h"
- # include "mathutils.h" // 'mathutils' module copied here so the blenderlayer can use.
- # include "bgl.h"
- # include "blf_py_api.h"
-
- # include "marshal.h" /* python header for loading/saving dicts */
-}
-#include "../../../../intern/audaspace/intern/AUD_PyInit.h"
-
-#endif /* WITH_PYTHON */
-
-#include "KX_PythonInit.h"
-
-// directory header for py function getBlendFileList
-#ifndef WIN32
-# include <dirent.h>
-# include <stdlib.h>
-#else
-# include <io.h>
-# include "BLI_winstuff.h"
-#endif
-
-//python physics binding
-#include "KX_PyConstraintBinding.h"
-
-#include "KX_KetsjiEngine.h"
-#include "KX_RadarSensor.h"
-#include "KX_RaySensor.h"
-#include "KX_ArmatureSensor.h"
-#include "KX_SceneActuator.h"
-#include "KX_GameActuator.h"
-#include "KX_ParentActuator.h"
-#include "KX_SCA_DynamicActuator.h"
-#include "KX_SteeringActuator.h"
-#include "KX_NavMeshObject.h"
-#include "KX_MouseActuator.h"
-#include "KX_TrackToActuator.h"
-
-#include "SCA_IInputDevice.h"
-#include "SCA_PropertySensor.h"
-#include "SCA_RandomActuator.h"
-#include "SCA_KeyboardSensor.h" /* IsPrintable, ToCharacter */
-#include "SCA_JoystickManager.h" /* JOYINDEX_MAX */
-#include "SCA_PythonJoystick.h"
-#include "SCA_PythonKeyboard.h"
-#include "SCA_PythonMouse.h"
-#include "KX_ConstraintActuator.h"
-#include "KX_SoundActuator.h"
-#include "KX_StateActuator.h"
-#include "BL_ActionActuator.h"
-#include "BL_ArmatureObject.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_ICanvas.h"
-#include "RAS_IOffScreen.h"
-#include "RAS_BucketManager.h"
-#include "RAS_2DFilterManager.h"
-#include "MT_Vector3.h"
-#include "MT_Point3.h"
-#include "EXP_ListValue.h"
-#include "EXP_InputParser.h"
-#include "KX_Scene.h"
-
-#include "NG_NetworkScene.h" //Needed for sendMessage()
-
-#include "BL_Shader.h"
-#include "BL_Action.h"
-
-#include "KX_PyMath.h"
-
-#include "EXP_PyObjectPlus.h"
-
-#include "KX_PythonInitTypes.h"
-
-/* we only need this to get a list of libraries from the main struct */
-#include "DNA_ID.h"
-#include "DNA_scene_types.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-
-extern "C" {
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_appdir.h"
-#include "BKE_blender_version.h"
-#include "BLI_blenlib.h"
-#include "GPU_material.h"
-#include "MEM_guardedalloc.h"
-}
-
-/* for converting new scenes */
-#include "KX_BlenderSceneConverter.h"
-#include "KX_LibLoadStatus.h"
-#include "KX_MeshProxy.h" /* for creating a new library of mesh objects */
-extern "C" {
- #include "BKE_idcode.h"
-}
-
-// 'local' copy of canvas ptr, for window height/width python scripts
-
-#ifdef WITH_PYTHON
-
-static RAS_ICanvas* gp_Canvas = NULL;
-static char gp_GamePythonPath[FILE_MAX] = "";
-static char gp_GamePythonPathOrig[FILE_MAX] = ""; // not super happy about this, but we need to remember the first loaded file for the global/dict load save
-
-static SCA_PythonKeyboard* gp_PythonKeyboard = NULL;
-static SCA_PythonMouse* gp_PythonMouse = NULL;
-static SCA_PythonJoystick* gp_PythonJoysticks[JOYINDEX_MAX] = {NULL};
-#endif // WITH_PYTHON
-
-static KX_Scene* gp_KetsjiScene = NULL;
-static KX_KetsjiEngine* gp_KetsjiEngine = NULL;
-static RAS_IRasterizer* gp_Rasterizer = NULL;
-
-
-void KX_SetActiveScene(class KX_Scene* scene)
-{
- gp_KetsjiScene = scene;
-}
-
-class KX_Scene* KX_GetActiveScene()
-{
- return gp_KetsjiScene;
-}
-
-class KX_KetsjiEngine* KX_GetActiveEngine()
-{
- return gp_KetsjiEngine;
-}
-
-/* why is this in python? */
-void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)
-{
- if (gp_Rasterizer)
- gp_Rasterizer->DrawDebugLine(gp_KetsjiScene, from, to, color);
-}
-
-void KX_RasterizerDrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
- const MT_Vector3& normal, int nsector)
-{
- if (gp_Rasterizer)
- gp_Rasterizer->DrawDebugCircle(gp_KetsjiScene, center, radius, color, normal, nsector);
-}
-
-#ifdef WITH_PYTHON
-
-
-static struct {
- PyObject *path;
- PyObject *meta_path;
- PyObject *modules;
-} gp_sys_backup = {NULL};
-
-/* Macro for building the keyboard translation */
-//#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyLong_FromLong(SCA_IInputDevice::KX_##name))
-//#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, item=PyLong_FromLong(name)); Py_DECREF(item)
-/* For the defines for types from logic bricks, we do stuff explicitly... */
-#define KX_MACRO_addTypesToDict(dict, name, value) KX_MACRO_addTypesToDict_fn(dict, #name, value)
-static void KX_MACRO_addTypesToDict_fn(PyObject *dict, const char *name, long value)
-{
- PyObject *item;
-
- item = PyLong_FromLong(value);
- PyDict_SetItemString(dict, name, item);
- Py_DECREF(item);
-}
-
-
-
-// temporarily python stuff, will be put in another place later !
-#include "EXP_Python.h"
-#include "SCA_PythonController.h"
-// List of methods defined in the module
-
-static PyObject *ErrorObject;
-
-PyDoc_STRVAR(gPyGetRandomFloat_doc,
-"getRandomFloat()\n"
-"returns a random floating point value in the range [0..1]"
-);
-static PyObject *gPyGetRandomFloat(PyObject *)
-{
- return PyFloat_FromDouble(MT_random());
-}
-
-static PyObject *gPySetGravity(PyObject *, PyObject *value)
-{
- MT_Vector3 vec;
- if (!PyVecTo(value, vec))
- return NULL;
-
- if (gp_KetsjiScene)
- gp_KetsjiScene->SetGravity(vec);
-
- Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(gPyExpandPath_doc,
-"expandPath(path)\n"
-"Converts a blender internal path into a proper file system path.\n"
-" path - the string path to convert.\n"
-"Use / as directory separator in path\n"
-"You can use '//' at the start of the string to define a relative path."
-"Blender replaces that string by the directory of the current .blend or runtime file to make a full path name.\n"
-"The function also converts the directory separator to the local file system format."
-);
-static PyObject *gPyExpandPath(PyObject *, PyObject *args)
-{
- char expanded[FILE_MAX];
- char* filename;
-
- if (!PyArg_ParseTuple(args,"s:ExpandPath",&filename))
- return NULL;
-
- BLI_strncpy(expanded, filename, FILE_MAX);
- BLI_path_abs(expanded, gp_GamePythonPath);
- return PyC_UnicodeFromByte(expanded);
-}
-
-PyDoc_STRVAR(gPyStartGame_doc,
-"startGame(blend)\n"
-"Loads the blend file"
-);
-static PyObject *gPyStartGame(PyObject *, PyObject *args)
-{
- char* blendfile;
-
- if (!PyArg_ParseTuple(args, "s:startGame", &blendfile))
- return NULL;
-
- gp_KetsjiEngine->RequestExit(KX_EXIT_REQUEST_START_OTHER_GAME);
- gp_KetsjiEngine->SetNameNextGame(blendfile);
-
- Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(gPyEndGame_doc,
-"endGame()\n"
-"Ends the current game"
-);
-static PyObject *gPyEndGame(PyObject *)
-{
- gp_KetsjiEngine->RequestExit(KX_EXIT_REQUEST_QUIT_GAME);
-
- //printf("%s\n", gp_GamePythonPath);
-
- Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(gPyRestartGame_doc,
-"restartGame()\n"
-"Restarts the current game by reloading the .blend file"
-);
-static PyObject *gPyRestartGame(PyObject *)
-{
- gp_KetsjiEngine->RequestExit(KX_EXIT_REQUEST_RESTART_GAME);
- gp_KetsjiEngine->SetNameNextGame(gp_GamePythonPath);
-
- Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(gPySaveGlobalDict_doc,
-"saveGlobalDict()\n"
-"Saves bge.logic.globalDict to a file"
-);
-static PyObject *gPySaveGlobalDict(PyObject *)
-{
- char marshal_path[512];
- char *marshal_buffer = NULL;
- unsigned int marshal_length;
- FILE *fp = NULL;
-
- pathGamePythonConfig(marshal_path);
- marshal_length = saveGamePythonConfig(&marshal_buffer);
-
- if (marshal_length && marshal_buffer)
- {
- fp = fopen(marshal_path, "wb");
-
- if (fp)
- {
- if (fwrite(marshal_buffer, 1, marshal_length, fp) != marshal_length)
- printf("Warning: could not write marshal data\n");
-
- fclose(fp);
- } else {
- printf("Warning: could not open marshal file\n");
- }
- } else {
- printf("Warning: could not create marshal buffer\n");
- }
-
- if (marshal_buffer)
- delete [] marshal_buffer;
-
- Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(gPyLoadGlobalDict_doc,
-"LoadGlobalDict()\n"
-"Loads bge.logic.globalDict from a file"
-);
-static PyObject *gPyLoadGlobalDict(PyObject *)
-{
- char marshal_path[512];
- char *marshal_buffer = NULL;
- int marshal_length;
- FILE *fp = NULL;
- int result;
-
- pathGamePythonConfig(marshal_path);
-
- fp = fopen(marshal_path, "rb");
-
- if (fp) {
- // obtain file size:
- fseek (fp, 0, SEEK_END);
- marshal_length = ftell(fp);
- if (marshal_length == -1) {
- printf("Warning: could not read position of '%s'\n", marshal_path);
- fclose(fp);
- Py_RETURN_NONE;
- }
- rewind(fp);
-
- marshal_buffer = (char*)malloc (sizeof(char)*marshal_length);
-
- result = fread(marshal_buffer, 1, marshal_length, fp);
-
- if (result == marshal_length) {
- loadGamePythonConfig(marshal_buffer, marshal_length);
- } else {
- printf("Warning: could not read all of '%s'\n", marshal_path);
- }
-
- free(marshal_buffer);
- fclose(fp);
- } else {
- printf("Warning: could not open '%s'\n", marshal_path);
- }
-
- Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(gPyGetProfileInfo_doc,
-"getProfileInfo()\n"
-"returns a dictionary with profiling information"
-);
-static PyObject *gPyGetProfileInfo(PyObject *)
-{
- return gp_KetsjiEngine->GetPyProfileDict();
-}
-
-PyDoc_STRVAR(gPySendMessage_doc,
-"sendMessage(subject, [body, to, from])\n"
-"sends a message in same manner as a message actuator"
-" subject = Subject of the message"
-" body = Message body"
-" to = Name of object to send the message to"
-" from = Name of object to send the string from"
-);
-static PyObject *gPySendMessage(PyObject *, PyObject *args)
-{
- char* subject;
- char* body = (char *)"";
- char* to = (char *)"";
- char* from = (char *)"";
-
- if (!PyArg_ParseTuple(args, "s|sss:sendMessage", &subject, &body, &to, &from))
- return NULL;
-
- gp_KetsjiScene->GetNetworkScene()->SendMessage(to, from, subject, body);
-
- Py_RETURN_NONE;
-}
-
-// this gets a pointer to an array filled with floats
-static PyObject *gPyGetSpectrum(PyObject *)
-{
- PyObject *resultlist = PyList_New(512);
-
- for (int index = 0; index < 512; index++)
- {
- PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0));
- }
-
- return resultlist;
-}
-
-static PyObject *gPySetLogicTicRate(PyObject *, PyObject *args)
-{
- float ticrate;
- if (!PyArg_ParseTuple(args, "f:setLogicTicRate", &ticrate))
- return NULL;
-
- KX_KetsjiEngine::SetTicRate(ticrate);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetLogicTicRate(PyObject *)
-{
- return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate());
-}
-
-static PyObject *gPySetExitKey(PyObject *, PyObject *args)
-{
- short exitkey;
- if (!PyArg_ParseTuple(args, "h:setExitKey", &exitkey))
- return NULL;
- KX_KetsjiEngine::SetExitKey(exitkey);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetExitKey(PyObject *)
-{
- return PyLong_FromLong(KX_KetsjiEngine::GetExitKey());
-}
-
-static PyObject *gPySetRender(PyObject *, PyObject *args)
-{
- int render;
- if (!PyArg_ParseTuple(args, "i:setRender", &render))
- return NULL;
- KX_KetsjiEngine::SetRender(render);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetRender(PyObject *)
-{
- return PyBool_FromLong(KX_KetsjiEngine::GetRender());
-}
-
-
-static PyObject *gPySetMaxLogicFrame(PyObject *, PyObject *args)
-{
- int frame;
- if (!PyArg_ParseTuple(args, "i:setMaxLogicFrame", &frame))
- return NULL;
-
- KX_KetsjiEngine::SetMaxLogicFrame(frame);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetMaxLogicFrame(PyObject *)
-{
- return PyLong_FromLong(KX_KetsjiEngine::GetMaxLogicFrame());
-}
-
-static PyObject *gPySetMaxPhysicsFrame(PyObject *, PyObject *args)
-{
- int frame;
- if (!PyArg_ParseTuple(args, "i:setMaxPhysicsFrame", &frame))
- return NULL;
-
- KX_KetsjiEngine::SetMaxPhysicsFrame(frame);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetMaxPhysicsFrame(PyObject *)
-{
- return PyLong_FromLong(KX_KetsjiEngine::GetMaxPhysicsFrame());
-}
-
-static PyObject *gPySetPhysicsTicRate(PyObject *, PyObject *args)
-{
- float ticrate;
- if (!PyArg_ParseTuple(args, "f:setPhysicsTicRate", &ticrate))
- return NULL;
-
- PHY_GetActiveEnvironment()->SetFixedTimeStep(true,ticrate);
- Py_RETURN_NONE;
-}
-#if 0 // unused
-static PyObject *gPySetPhysicsDebug(PyObject *, PyObject *args)
-{
- int debugMode;
- if (!PyArg_ParseTuple(args, "i:setPhysicsDebug", &debugMode))
- return NULL;
-
- PHY_GetActiveEnvironment()->setDebugMode(debugMode);
- Py_RETURN_NONE;
-}
-#endif
-
-
-static PyObject *gPyGetPhysicsTicRate(PyObject *)
-{
- return PyFloat_FromDouble(PHY_GetActiveEnvironment()->GetFixedTimeStep());
-}
-
-static PyObject *gPySetAnimRecordFrame(PyObject *, PyObject *args)
-{
- int anim_record_frame;
-
- if (!PyArg_ParseTuple(args, "i:setAnimRecordFrame", &anim_record_frame))
- return NULL;
-
- if (anim_record_frame < 0 && (U.flag & USER_NONEGFRAMES)) {
- PyErr_Format(PyExc_ValueError, "Frame number must be non-negative (was %i).", anim_record_frame);
- return NULL;
- }
-
- gp_KetsjiEngine->setAnimRecordFrame(anim_record_frame);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetAnimRecordFrame(PyObject *)
-{
- return PyLong_FromLong(gp_KetsjiEngine->getAnimRecordFrame());
-}
-
-static PyObject *gPyGetAverageFrameRate(PyObject *)
-{
- return PyFloat_FromDouble(KX_KetsjiEngine::GetAverageFrameRate());
-}
-
-static PyObject *gPyGetUseExternalClock(PyObject *)
-{
- return PyBool_FromLong(gp_KetsjiEngine->GetUseExternalClock());
-}
-
-static PyObject *gPySetUseExternalClock(PyObject *, PyObject *args)
-{
- bool bUseExternalClock;
-
- if (!PyArg_ParseTuple(args, "p:setUseExternalClock", &bUseExternalClock))
- return NULL;
-
- gp_KetsjiEngine->SetUseExternalClock(bUseExternalClock);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetClockTime(PyObject *)
-{
- return PyFloat_FromDouble(gp_KetsjiEngine->GetClockTime());
-}
-
-static PyObject *gPySetClockTime(PyObject *, PyObject *args)
-{
- double externalClockTime;
-
- if (!PyArg_ParseTuple(args, "d:setClockTime", &externalClockTime))
- return NULL;
-
- gp_KetsjiEngine->SetClockTime(externalClockTime);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetFrameTime(PyObject *)
-{
- return PyFloat_FromDouble(gp_KetsjiEngine->GetFrameTime());
-}
-
-static PyObject *gPyGetRealTime(PyObject *)
-{
- return PyFloat_FromDouble(gp_KetsjiEngine->GetRealTime());
-}
-
-static PyObject *gPyGetTimeScale(PyObject *)
-{
- return PyFloat_FromDouble(gp_KetsjiEngine->GetTimeScale());
-}
-
-static PyObject *gPySetTimeScale(PyObject *, PyObject *args)
-{
- double time_scale;
-
- if (!PyArg_ParseTuple(args, "d:setTimeScale", &time_scale))
- return NULL;
-
- gp_KetsjiEngine->SetTimeScale(time_scale);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetBlendFileList(PyObject *, PyObject *args)
-{
- char cpath[sizeof(gp_GamePythonPath)];
- char *searchpath = NULL;
- PyObject *list, *value;
-
- DIR *dp;
- struct dirent *dirp;
-
- if (!PyArg_ParseTuple(args, "|s:getBlendFileList", &searchpath))
- return NULL;
-
- list = PyList_New(0);
-
- if (searchpath) {
- BLI_strncpy(cpath, searchpath, FILE_MAX);
- BLI_path_abs(cpath, gp_GamePythonPath);
- } else {
- /* Get the dir only */
- BLI_split_dir_part(gp_GamePythonPath, cpath, sizeof(cpath));
- }
-
- if ((dp = opendir(cpath)) == NULL) {
- /* todo, show the errno, this shouldnt happen anyway if the blendfile is readable */
- fprintf(stderr, "Could not read directory (%s) failed, code %d (%s)\n", cpath, errno, strerror(errno));
- return list;
- }
-
- while ((dirp = readdir(dp)) != NULL) {
- if (BLI_testextensie(dirp->d_name, ".blend")) {
- value = PyC_UnicodeFromByte(dirp->d_name);
- PyList_Append(list, value);
- Py_DECREF(value);
- }
- }
-
- closedir(dp);
- return list;
-}
-
-PyDoc_STRVAR(gPyAddScene_doc,
-"addScene(name, [overlay])\n"
-"Adds a scene to the game engine.\n"
-" name = Name of the scene\n"
-" overlay = Overlay or underlay"
-);
-static PyObject *gPyAddScene(PyObject *, PyObject *args)
-{
- char* name;
- int overlay = 1;
-
- if (!PyArg_ParseTuple(args, "s|i:addScene", &name , &overlay))
- return NULL;
-
- gp_KetsjiEngine->ConvertAndAddScene(name, (overlay != 0));
-
- Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(gPyGetCurrentScene_doc,
-"getCurrentScene()\n"
-"Gets a reference to the current scene."
-);
-static PyObject *gPyGetCurrentScene(PyObject *self)
-{
- return gp_KetsjiScene->GetProxy();
-}
-
-PyDoc_STRVAR(gPyGetSceneList_doc,
-"getSceneList()\n"
-"Return a list of converted scenes."
-);
-static PyObject *gPyGetSceneList(PyObject *self)
-{
- KX_KetsjiEngine* m_engine = KX_GetActiveEngine();
- PyObject *list;
- KX_SceneList* scenes = m_engine->CurrentScenes();
- int numScenes = scenes->size();
- int i;
-
- list = PyList_New(numScenes);
-
- for (i=0;i<numScenes;i++)
- {
- KX_Scene* scene = scenes->at(i);
- PyList_SET_ITEM(list, i, scene->GetProxy());
- }
-
- return list;
-}
-
-static PyObject *pyPrintStats(PyObject *,PyObject *,PyObject *)
-{
- gp_KetsjiScene->GetSceneConverter()->PrintStats();
- Py_RETURN_NONE;
-}
-
-static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
-{
- if (gp_Rasterizer)
- gp_Rasterizer->PrintHardwareInfo();
- else
- printf("Warning: no rasterizer detected for PrintGLInfo!\n");
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gLibLoad(PyObject *, PyObject *args, PyObject *kwds)
-{
- KX_Scene *kx_scene= gp_KetsjiScene;
- char *path;
- char *group;
- Py_buffer py_buffer;
- py_buffer.buf = NULL;
- char *err_str= NULL;
- KX_LibLoadStatus *status = NULL;
-
- short options=0;
- int load_actions=0, verbose=0, load_scripts=1, async=0;
-
- static const char *kwlist[] = {"path", "group", "buffer", "load_actions", "verbose", "load_scripts", "async", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|y*iiIi:LibLoad", const_cast<char**>(kwlist),
- &path, &group, &py_buffer, &load_actions, &verbose, &load_scripts, &async))
- return NULL;
-
- /* setup options */
- if (load_actions != 0)
- options |= KX_BlenderSceneConverter::LIB_LOAD_LOAD_ACTIONS;
- if (verbose != 0)
- options |= KX_BlenderSceneConverter::LIB_LOAD_VERBOSE;
- if (load_scripts != 0)
- options |= KX_BlenderSceneConverter::LIB_LOAD_LOAD_SCRIPTS;
- if (async != 0)
- options |= KX_BlenderSceneConverter::LIB_LOAD_ASYNC;
-
- if (!py_buffer.buf)
- {
- char abs_path[FILE_MAX];
- // Make the path absolute
- BLI_strncpy(abs_path, path, sizeof(abs_path));
- BLI_path_abs(abs_path, gp_GamePythonPath);
-
- if ((status=kx_scene->GetSceneConverter()->LinkBlendFilePath(abs_path, group, kx_scene, &err_str, options))) {
- return status->GetProxy();
- }
- }
- else
- {
-
- if ((status=kx_scene->GetSceneConverter()->LinkBlendFileMemory(py_buffer.buf, py_buffer.len, path, group, kx_scene, &err_str, options))) {
- PyBuffer_Release(&py_buffer);
- return status->GetProxy();
- }
-
- PyBuffer_Release(&py_buffer);
- }
-
- if (err_str) {
- PyErr_SetString(PyExc_ValueError, err_str);
- return NULL;
- }
-
- Py_RETURN_FALSE;
-}
-
-static PyObject *gLibNew(PyObject *, PyObject *args)
-{
- KX_Scene *kx_scene= gp_KetsjiScene;
- char *path;
- char *group;
- const char *name;
- PyObject *names;
- int idcode;
-
- if (!PyArg_ParseTuple(args,"ssO!:LibNew",&path, &group, &PyList_Type, &names))
- return NULL;
-
- if (kx_scene->GetSceneConverter()->GetMainDynamicPath(path))
- {
- PyErr_SetString(PyExc_KeyError, "the name of the path given exists");
- return NULL;
- }
-
- idcode= BKE_idcode_from_name(group);
- if (idcode==0) {
- PyErr_Format(PyExc_ValueError, "invalid group given \"%s\"", group);
- return NULL;
- }
-
- Main *maggie=BKE_main_new();
- kx_scene->GetSceneConverter()->GetMainDynamic().push_back(maggie);
- strncpy(maggie->name, path, sizeof(maggie->name)-1);
-
- /* Copy the object into main */
- if (idcode==ID_ME) {
- PyObject *ret= PyList_New(0);
- PyObject *item;
- for (Py_ssize_t i= 0; i < PyList_GET_SIZE(names); i++) {
- name= _PyUnicode_AsString(PyList_GET_ITEM(names, i));
- if (name) {
- RAS_MeshObject *meshobj= kx_scene->GetSceneConverter()->ConvertMeshSpecial(kx_scene, maggie, name);
- if (meshobj) {
- KX_MeshProxy* meshproxy = new KX_MeshProxy(meshobj);
- item= meshproxy->NewProxy(true);
- PyList_Append(ret, item);
- Py_DECREF(item);
- }
- }
- else {
- PyErr_Clear(); /* wasnt a string, ignore for now */
- }
- }
-
- return ret;
- }
- else {
- PyErr_Format(PyExc_ValueError, "only \"Mesh\" group currently supported");
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gLibFree(PyObject *, PyObject *args)
-{
- KX_Scene *kx_scene= gp_KetsjiScene;
- char *path;
-
- if (!PyArg_ParseTuple(args,"s:LibFree",&path))
- return NULL;
-
- if (kx_scene->GetSceneConverter()->FreeBlendFile(path))
- {
- Py_RETURN_TRUE;
- }
- else {
- Py_RETURN_FALSE;
- }
-}
-
-static PyObject *gLibList(PyObject *, PyObject *args)
-{
- vector<Main*> &dynMaggie = gp_KetsjiScene->GetSceneConverter()->GetMainDynamic();
- int i= 0;
- PyObject *list= PyList_New(dynMaggie.size());
-
- for (vector<Main*>::iterator it=dynMaggie.begin(); !(it==dynMaggie.end()); it++)
- {
- PyList_SET_ITEM(list, i++, PyUnicode_FromString( (*it)->name) );
- }
-
- return list;
-}
-
-struct PyNextFrameState pynextframestate;
-static PyObject *gPyNextFrame(PyObject *)
-{
- if (pynextframestate.func == NULL) Py_RETURN_NONE;
- if (pynextframestate.state == NULL) Py_RETURN_NONE; //should never happen; raise exception instead?
-
- if (pynextframestate.func(pynextframestate.state)) //nonzero = stop
- {
- Py_RETURN_TRUE;
- }
- else // 0 = go on
- {
- Py_RETURN_FALSE;
- }
-}
-
-
-static struct PyMethodDef game_methods[] = {
- {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, (const char *)gPyExpandPath_doc},
- {"startGame", (PyCFunction)gPyStartGame, METH_VARARGS, (const char *)gPyStartGame_doc},
- {"endGame", (PyCFunction)gPyEndGame, METH_NOARGS, (const char *)gPyEndGame_doc},
- {"restartGame", (PyCFunction)gPyRestartGame, METH_NOARGS, (const char *)gPyRestartGame_doc},
- {"saveGlobalDict", (PyCFunction)gPySaveGlobalDict, METH_NOARGS, (const char *)gPySaveGlobalDict_doc},
- {"loadGlobalDict", (PyCFunction)gPyLoadGlobalDict, METH_NOARGS, (const char *)gPyLoadGlobalDict_doc},
- {"sendMessage", (PyCFunction)gPySendMessage, METH_VARARGS, (const char *)gPySendMessage_doc},
- {"getCurrentController", (PyCFunction) SCA_PythonController::sPyGetCurrentController, METH_NOARGS, SCA_PythonController::sPyGetCurrentController__doc__},
- {"getCurrentScene", (PyCFunction) gPyGetCurrentScene, METH_NOARGS, gPyGetCurrentScene_doc},
- {"getSceneList", (PyCFunction) gPyGetSceneList, METH_NOARGS, (const char *)gPyGetSceneList_doc},
- {"addScene", (PyCFunction)gPyAddScene, METH_VARARGS, (const char *)gPyAddScene_doc},
- {"getRandomFloat",(PyCFunction) gPyGetRandomFloat, METH_NOARGS, (const char *)gPyGetRandomFloat_doc},
- {"setGravity",(PyCFunction) gPySetGravity, METH_O, (const char *)"set Gravitation"},
- {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS, (const char *)"get audio spectrum"},
- {"getMaxLogicFrame", (PyCFunction) gPyGetMaxLogicFrame, METH_NOARGS, (const char *)"Gets the max number of logic frame per render frame"},
- {"setMaxLogicFrame", (PyCFunction) gPySetMaxLogicFrame, METH_VARARGS, (const char *)"Sets the max number of logic frame per render frame"},
- {"getMaxPhysicsFrame", (PyCFunction) gPyGetMaxPhysicsFrame, METH_NOARGS, (const char *)"Gets the max number of physics frame per render frame"},
- {"setMaxPhysicsFrame", (PyCFunction) gPySetMaxPhysicsFrame, METH_VARARGS, (const char *)"Sets the max number of physics farme per render frame"},
- {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, (const char *)"Gets the logic tic rate"},
- {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, (const char *)"Sets the logic tic rate"},
- {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, (const char *)"Gets the physics tic rate"},
- {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, (const char *)"Sets the physics tic rate"},
- {"getAnimRecordFrame", (PyCFunction) gPyGetAnimRecordFrame, METH_NOARGS, (const char *)"Gets the current frame number used for animation recording"},
- {"setAnimRecordFrame", (PyCFunction) gPySetAnimRecordFrame, METH_VARARGS, (const char *)"Sets the current frame number used for animation recording"},
- {"getExitKey", (PyCFunction) gPyGetExitKey, METH_NOARGS, (const char *)"Gets the key used to exit the game engine"},
- {"setExitKey", (PyCFunction) gPySetExitKey, METH_VARARGS, (const char *)"Sets the key used to exit the game engine"},
- {"setRender", (PyCFunction) gPySetRender, METH_VARARGS, (const char *)"Set the global render flag"},
- {"getRender", (PyCFunction) gPyGetRender, METH_NOARGS, (const char *)"get the global render flag value"},
- {"getUseExternalClock", (PyCFunction) gPyGetUseExternalClock, METH_NOARGS, (const char *)"Get if we use the time provided by an external clock"},
- {"setUseExternalClock", (PyCFunction) gPySetUseExternalClock, METH_VARARGS, (const char *)"Set if we use the time provided by an external clock"},
- {"getClockTime", (PyCFunction) gPyGetClockTime, METH_NOARGS, (const char *)"Get the last BGE render time. "
- "The BGE render time is the simulated time corresponding to the next scene that will be renderered"},
- {"setClockTime", (PyCFunction) gPySetClockTime, METH_VARARGS, (const char *)"Set the BGE render time. "
- "The BGE render time is the simulated time corresponding to the next scene that will be rendered"},
- {"getFrameTime", (PyCFunction) gPyGetFrameTime, METH_NOARGS, (const char *)"Get the BGE last frametime. "
- "The BGE frame time is the simulated time corresponding to the last call of the logic system"},
- {"getRealTime", (PyCFunction) gPyGetRealTime, METH_NOARGS, (const char *)"Get the real system time. "
- "The real-time corresponds to the system time" },
- {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (const char *)"Gets the estimated average frame rate"},
- {"getTimeScale", (PyCFunction) gPyGetTimeScale, METH_NOARGS, (const char *)"Get the time multiplier"},
- {"setTimeScale", (PyCFunction) gPySetTimeScale, METH_VARARGS, (const char *)"Set the time multiplier"},
- {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (const char *)"Gets a list of blend files in the same directory as the current blend file"},
- {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (const char *)"Prints GL Extension Info"},
- {"PrintMemInfo", (PyCFunction)pyPrintStats, METH_NOARGS, (const char *)"Print engine statistics"},
- {"NextFrame", (PyCFunction)gPyNextFrame, METH_NOARGS, (const char *)"Render next frame (if Python has control)"},
- {"getProfileInfo", (PyCFunction)gPyGetProfileInfo, METH_NOARGS, gPyGetProfileInfo_doc},
- /* library functions */
- {"LibLoad", (PyCFunction)gLibLoad, METH_VARARGS|METH_KEYWORDS, (const char *)""},
- {"LibNew", (PyCFunction)gLibNew, METH_VARARGS, (const char *)""},
- {"LibFree", (PyCFunction)gLibFree, METH_VARARGS, (const char *)""},
- {"LibList", (PyCFunction)gLibList, METH_VARARGS, (const char *)""},
-
- {NULL, (PyCFunction) NULL, 0, NULL }
-};
-
-static PyObject *gPyGetWindowHeight(PyObject *, PyObject *args)
-{
- return PyLong_FromLong((gp_Canvas ? gp_Canvas->GetHeight() : 0));
-}
-
-
-
-static PyObject *gPyGetWindowWidth(PyObject *, PyObject *args)
-{
- return PyLong_FromLong((gp_Canvas ? gp_Canvas->GetWidth() : 0));
-}
-
-
-
-// temporarility visibility thing, will be moved to rasterizer/renderer later
-bool gUseVisibilityTemp = false;
-
-static PyObject *gPyEnableVisibility(PyObject *, PyObject *args)
-{
- int visible;
- if (!PyArg_ParseTuple(args,"i:enableVisibility",&visible))
- return NULL;
-
- gUseVisibilityTemp = (visible != 0);
- Py_RETURN_NONE;
-}
-
-
-
-static PyObject *gPyShowMouse(PyObject *, PyObject *args)
-{
- int visible;
- if (!PyArg_ParseTuple(args,"i:showMouse",&visible))
- return NULL;
-
- if (visible)
- {
- if (gp_Canvas)
- gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
- } else
- {
- if (gp_Canvas)
- gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
- }
-
- Py_RETURN_NONE;
-}
-
-
-
-static PyObject *gPySetMousePosition(PyObject *, PyObject *args)
-{
- int x,y;
- if (!PyArg_ParseTuple(args,"ii:setMousePosition",&x,&y))
- return NULL;
-
- if (gp_Canvas)
- gp_Canvas->SetMousePosition(x,y);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPySetEyeSeparation(PyObject *, PyObject *args)
-{
- float sep;
- if (!PyArg_ParseTuple(args, "f:setEyeSeparation", &sep))
- return NULL;
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setEyeSeparation(float), Rasterizer not available");
- return NULL;
- }
-
- gp_Rasterizer->SetEyeSeparation(sep);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetEyeSeparation(PyObject *)
-{
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getEyeSeparation(), Rasterizer not available");
- return NULL;
- }
-
- return PyFloat_FromDouble(gp_Rasterizer->GetEyeSeparation());
-}
-
-static PyObject *gPySetFocalLength(PyObject *, PyObject *args)
-{
- float focus;
- if (!PyArg_ParseTuple(args, "f:setFocalLength", &focus))
- return NULL;
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setFocalLength(float), Rasterizer not available");
- return NULL;
- }
-
- gp_Rasterizer->SetFocalLength(focus);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetFocalLength(PyObject *, PyObject *, PyObject *)
-{
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getFocalLength(), Rasterizer not available");
- return NULL;
- }
-
- return PyFloat_FromDouble(gp_Rasterizer->GetFocalLength());
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetStereoEye(PyObject *, PyObject *, PyObject *)
-{
- int flag = RAS_IRasterizer::RAS_STEREO_LEFTEYE;
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getStereoEye(), Rasterizer not available");
- return NULL;
- }
-
- if (gp_Rasterizer->Stereo())
- flag = gp_Rasterizer->GetEye();
-
- return PyLong_FromLong(flag);
-}
-
-static PyObject *gPySetBackgroundColor(PyObject *, PyObject *value)
-{
- MT_Vector4 vec;
- if (!PyVecTo(value, vec))
- return NULL;
-
- KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo();
- if (!wi->hasWorld()) {
- PyErr_SetString(PyExc_RuntimeError, "bge.render.SetBackgroundColor(color), World not available");
- return NULL;
- }
-
- ShowDeprecationWarning("setBackgroundColor()", "KX_WorldInfo.background_color");
- wi->setBackColor((float)vec[0], (float)vec[1], (float)vec[2]);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyMakeScreenshot(PyObject *, PyObject *args)
-{
- char* filename;
- if (!PyArg_ParseTuple(args,"s:makeScreenshot",&filename))
- return NULL;
-
- if (gp_Canvas)
- {
- gp_Canvas->MakeScreenShot(filename);
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyEnableMotionBlur(PyObject *, PyObject *args)
-{
- float motionblurvalue;
- if (!PyArg_ParseTuple(args,"f:enableMotionBlur",&motionblurvalue))
- return NULL;
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.enableMotionBlur(float), Rasterizer not available");
- return NULL;
- }
-
- gp_Rasterizer->EnableMotionBlur(motionblurvalue);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyDisableMotionBlur(PyObject *)
-{
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.disableMotionBlur(), Rasterizer not available");
- return NULL;
- }
-
- gp_Rasterizer->DisableMotionBlur();
-
- Py_RETURN_NONE;
-}
-
-static int getGLSLSettingFlag(const char *setting)
-{
- if (strcmp(setting, "lights") == 0)
- return GAME_GLSL_NO_LIGHTS;
- else if (strcmp(setting, "shaders") == 0)
- return GAME_GLSL_NO_SHADERS;
- else if (strcmp(setting, "shadows") == 0)
- return GAME_GLSL_NO_SHADOWS;
- else if (strcmp(setting, "ramps") == 0)
- return GAME_GLSL_NO_RAMPS;
- else if (strcmp(setting, "nodes") == 0)
- return GAME_GLSL_NO_NODES;
- else if (strcmp(setting, "extra_textures") == 0)
- return GAME_GLSL_NO_EXTRA_TEX;
- else
- return -1;
-}
-
-static PyObject *gPySetGLSLMaterialSetting(PyObject *,
- PyObject *args,
- PyObject *)
-{
- GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings();
- char *setting;
- int enable, flag, sceneflag;
-
- if (!PyArg_ParseTuple(args,"si:setGLSLMaterialSetting",&setting,&enable))
- return NULL;
-
- flag = getGLSLSettingFlag(setting);
-
- if (flag == -1) {
- PyErr_SetString(PyExc_ValueError, "Rasterizer.setGLSLMaterialSetting(string): glsl setting is not known");
- return NULL;
- }
-
- sceneflag= gs->glslflag;
-
- if (enable)
- gs->glslflag &= ~flag;
- else
- gs->glslflag |= flag;
-
- /* display lists and GLSL materials need to be remade */
- if (sceneflag != gs->glslflag) {
- GPU_materials_free();
- if (gp_KetsjiEngine) {
- KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes();
- KX_SceneList::iterator it;
-
- for (it=scenes->begin(); it!=scenes->end(); it++) {
- // temporarily store the glsl settings in the scene for the GLSL materials
- (*it)->GetBlenderScene()->gm.flag = gs->glslflag;
- if ((*it)->GetBucketManager()) {
- (*it)->GetBucketManager()->ReleaseDisplayLists();
- (*it)->GetBucketManager()->ReleaseMaterials();
- }
- }
- }
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetGLSLMaterialSetting(PyObject *,
- PyObject *args,
- PyObject *)
-{
- GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings();
- char *setting;
- int enabled = 0, flag;
-
- if (!PyArg_ParseTuple(args,"s:getGLSLMaterialSetting",&setting))
- return NULL;
-
- flag = getGLSLSettingFlag(setting);
-
- if (flag == -1) {
- PyErr_SetString(PyExc_ValueError, "Rasterizer.getGLSLMaterialSetting(string): glsl setting is not known");
- return NULL;
- }
-
- enabled = ((gs->glslflag & flag) != 0);
- return PyLong_FromLong(enabled);
-}
-
-#define KX_BLENDER_MULTITEX_MATERIAL 1
-#define KX_BLENDER_GLSL_MATERIAL 2
-
-static PyObject *gPySetMaterialType(PyObject *,
- PyObject *args,
- PyObject *)
-{
- GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings();
- int type;
-
- if (!PyArg_ParseTuple(args,"i:setMaterialType",&type))
- return NULL;
-
- if (type == KX_BLENDER_GLSL_MATERIAL)
- gs->matmode= GAME_MAT_GLSL;
- else if (type == KX_BLENDER_MULTITEX_MATERIAL)
- gs->matmode= GAME_MAT_MULTITEX;
- else {
- PyErr_SetString(PyExc_ValueError, "Rasterizer.setMaterialType(int): material type is not known");
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetMaterialType(PyObject *)
-{
- GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings();
- int flag;
-
- if (gs->matmode == GAME_MAT_GLSL)
- flag = KX_BLENDER_GLSL_MATERIAL;
- else
- flag = KX_BLENDER_MULTITEX_MATERIAL;
-
- return PyLong_FromLong(flag);
-}
-
-static PyObject *gPySetAnisotropicFiltering(PyObject *, PyObject *args)
-{
- short level;
-
- if (!PyArg_ParseTuple(args, "h:setAnisotropicFiltering", &level))
- return NULL;
-
- if (level != 1 && level != 2 && level != 4 && level != 8 && level != 16) {
- PyErr_SetString(PyExc_ValueError, "Rasterizer.setAnisotropicFiltering(level): Expected value of 1, 2, 4, 8, or 16 for value");
- return NULL;
- }
-
- gp_Rasterizer->SetAnisotropicFiltering(level);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetAnisotropicFiltering(PyObject *, PyObject *args)
-{
- return PyLong_FromLong(gp_Rasterizer->GetAnisotropicFiltering());
-}
-
-static PyObject *gPyDrawLine(PyObject *, PyObject *args)
-{
- PyObject *ob_from;
- PyObject *ob_to;
- PyObject *ob_color;
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.drawLine(obFrom, obTo, color): Rasterizer not available");
- return NULL;
- }
-
- if (!PyArg_ParseTuple(args,"OOO:drawLine",&ob_from,&ob_to,&ob_color))
- return NULL;
-
- MT_Vector3 from;
- MT_Vector3 to;
- MT_Vector3 color;
- if (!PyVecTo(ob_from, from))
- return NULL;
- if (!PyVecTo(ob_to, to))
- return NULL;
- if (!PyVecTo(ob_color, color))
- return NULL;
-
- gp_Rasterizer->DrawDebugLine(gp_KetsjiScene, from, to, color);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPySetWindowSize(PyObject *, PyObject *args)
-{
- int width, height;
- if (!PyArg_ParseTuple(args, "ii:resize", &width, &height))
- return NULL;
-
- gp_Canvas->ResizeWindow(width, height);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPySetFullScreen(PyObject *, PyObject *value)
-{
- gp_Canvas->SetFullScreen(PyObject_IsTrue(value));
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetFullScreen(PyObject *)
-{
- return PyBool_FromLong(gp_Canvas->GetFullScreen());
-}
-
-static PyObject *gPySetMipmapping(PyObject *, PyObject *args)
-{
- int val = 0;
-
- if (!PyArg_ParseTuple(args, "i:setMipmapping", &val))
- return NULL;
-
- if (val < 0 || val > RAS_IRasterizer::RAS_MIPMAP_MAX) {
- PyErr_SetString(PyExc_ValueError, "Rasterizer.setMipmapping(val): invalid mipmaping option");
- return NULL;
- }
-
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMipmapping(val): Rasterizer not available");
- return NULL;
- }
-
- gp_Rasterizer->SetMipmapping((RAS_IRasterizer::MipmapOption)val);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetMipmapping(PyObject *)
-{
- if (!gp_Rasterizer) {
- PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getMipmapping(): Rasterizer not available");
- return NULL;
- }
- return PyLong_FromLong(gp_Rasterizer->GetMipmapping());
-}
-
-static PyObject *gPySetVsync(PyObject *, PyObject *args)
-{
- int interval;
-
- if (!PyArg_ParseTuple(args, "i:setVsync", &interval))
- return NULL;
-
- if (interval < 0 || interval > VSYNC_ADAPTIVE) {
- PyErr_SetString(PyExc_ValueError, "Rasterizer.setVsync(value): value must be VSYNC_OFF, VSYNC_ON, or VSYNC_ADAPTIVE");
- return NULL;
- }
-
- if (interval == VSYNC_ADAPTIVE)
- interval = -1;
- gp_Canvas->SetSwapInterval((interval == VSYNC_ON) ? 1 : 0);
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetVsync(PyObject *)
-{
- int interval = 0;
- gp_Canvas->GetSwapInterval(interval);
- return PyLong_FromLong(interval);
-}
-
-static PyObject *gPyShowFramerate(PyObject *, PyObject *args)
-{
- int visible;
- if (!PyArg_ParseTuple(args,"i:showFramerate",&visible))
- return NULL;
-
- if (visible && gp_KetsjiEngine)
- gp_KetsjiEngine->SetShowFramerate(true);
- else
- gp_KetsjiEngine->SetShowFramerate(false);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyShowProfile(PyObject *, PyObject *args)
-{
- int visible;
- if (!PyArg_ParseTuple(args,"i:showProfile",&visible))
- return NULL;
-
- if (visible && gp_KetsjiEngine)
- gp_KetsjiEngine->SetShowProfile(true);
- else
- gp_KetsjiEngine->SetShowProfile(false);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyShowProperties(PyObject *, PyObject *args)
-{
- int visible;
- if (!PyArg_ParseTuple(args,"i:showProperties",&visible))
- return NULL;
-
- if (visible && gp_KetsjiEngine)
- gp_KetsjiEngine->SetShowProperties(true);
- else
- gp_KetsjiEngine->SetShowProperties(false);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyAutoDebugList(PyObject *, PyObject *args)
-{
- int add;
- if (!PyArg_ParseTuple(args,"i:autoAddProperties",&add))
- return NULL;
-
- if (add && gp_KetsjiEngine)
- gp_KetsjiEngine->SetAutoAddDebugProperties(true);
- else
- gp_KetsjiEngine->SetAutoAddDebugProperties(false);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyClearDebugList(PyObject *)
-{
- if (gp_KetsjiScene)
- gp_KetsjiScene->RemoveAllDebugProperties();
-
- Py_RETURN_NONE;
-}
-
-static PyObject *gPyGetDisplayDimensions(PyObject *)
-{
- PyObject *result;
- int width, height;
-
- gp_Canvas->GetDisplayDimensions(width, height);
-
- result = PyTuple_New(2);
- PyTuple_SET_ITEMS(result,
- PyLong_FromLong(width),
- PyLong_FromLong(height));
-
- return result;
-}
-
-
-/* python wrapper around RAS_IOffScreen
- * Should eventually gets its own file
- */
-
-static void PyRASOffScreen__tp_dealloc(PyRASOffScreen *self)
-{
- if (self->ofs)
- delete self->ofs;
- Py_TYPE(self)->tp_free((PyObject *)self);
-}
-
-PyDoc_STRVAR(py_RASOffScreen_doc,
-"RASOffscreen(width, height) -> new GPU Offscreen object"
-"initialized to hold a framebuffer object of ``width`` x ``height``.\n"
-""
-);
-
-PyDoc_STRVAR(RASOffScreen_width_doc, "Offscreen buffer width.\n\n:type: integer");
-static PyObject *RASOffScreen_width_get(PyRASOffScreen *self, void *UNUSED(type))
-{
- return PyLong_FromLong(self->ofs->GetWidth());
-}
-
-PyDoc_STRVAR(RASOffScreen_height_doc, "Offscreen buffer height.\n\n:type: GLsizei");
-static PyObject *RASOffScreen_height_get(PyRASOffScreen *self, void *UNUSED(type))
-{
- return PyLong_FromLong(self->ofs->GetHeight());
-}
-
-PyDoc_STRVAR(RASOffScreen_color_doc, "Offscreen buffer texture object (if target is RAS_OFS_RENDER_TEXTURE).\n\n:type: GLuint");
-static PyObject *RASOffScreen_color_get(PyRASOffScreen *self, void *UNUSED(type))
-{
- return PyLong_FromLong(self->ofs->GetColor());
-}
-
-static PyGetSetDef RASOffScreen_getseters[] = {
- {(char *)"width", (getter)RASOffScreen_width_get, (setter)NULL, RASOffScreen_width_doc, NULL},
- {(char *)"height", (getter)RASOffScreen_height_get, (setter)NULL, RASOffScreen_height_doc, NULL},
- {(char *)"color", (getter)RASOffScreen_color_get, (setter)NULL, RASOffScreen_color_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
-};
-
-static int PyRASOffScreen__tp_init(PyRASOffScreen *self, PyObject *args, PyObject *kwargs)
-{
- int width, height, samples, target;
- const char *keywords[] = {"width", "height", "samples", "target", NULL};
-
- samples = 0;
- target = RAS_IOffScreen::RAS_OFS_RENDER_BUFFER;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|ii:RASOffscreen", (char **)keywords, &width, &height, &samples, &target)) {
- return -1;
- }
-
- if (width <= 0) {
- PyErr_SetString(PyExc_ValueError, "negative 'width' given");
- return -1;
- }
-
- if (height <= 0) {
- PyErr_SetString(PyExc_ValueError, "negative 'height' given");
- return -1;
- }
-
- if (samples < 0) {
- PyErr_SetString(PyExc_ValueError, "negative 'samples' given");
- return -1;
- }
-
- if (target != RAS_IOffScreen::RAS_OFS_RENDER_BUFFER && target != RAS_IOffScreen::RAS_OFS_RENDER_TEXTURE)
- {
- PyErr_SetString(PyExc_ValueError, "invalid 'target' given, can only be RAS_OFS_RENDER_BUFFER or RAS_OFS_RENDER_TEXTURE");
- return -1;
- }
- if (!gp_Rasterizer)
- {
- PyErr_SetString(PyExc_SystemError, "no rasterizer");
- return -1;
- }
- self->ofs = gp_Rasterizer->CreateOffScreen(width, height, samples, target);
- if (!self->ofs) {
- PyErr_SetString(PyExc_SystemError, "creation failed");
- return -1;
- }
- return 0;
-}
-
-PyTypeObject PyRASOffScreen_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "RASOffScreen", /* tp_name */
- sizeof(PyRASOffScreen), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)PyRASOffScreen__tp_dealloc, /* tp_dealloc */
- NULL, /* tp_print */
- NULL, /* tp_getattr */
- NULL, /* tp_setattr */
- NULL, /* tp_compare */
- NULL, /* tp_repr */
- NULL, /* tp_as_number */
- NULL, /* tp_as_sequence */
- NULL, /* tp_as_mapping */
- NULL, /* tp_hash */
- NULL, /* tp_call */
- NULL, /* tp_str */
- NULL, /* tp_getattro */
- NULL, /* tp_setattro */
- NULL, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- py_RASOffScreen_doc, /* Documentation string */
- NULL, /* tp_traverse */
- NULL, /* tp_clear */
- NULL, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- NULL, /* tp_iter */
- NULL, /* tp_iternext */
- NULL, /* tp_methods */
- NULL, /* tp_members */
- RASOffScreen_getseters, /* tp_getset */
- NULL, /* tp_base */
- NULL, /* tp_dict */
- NULL, /* tp_descr_get */
- NULL, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)PyRASOffScreen__tp_init, /* tp_init */
- (allocfunc)PyType_GenericAlloc, /* tp_alloc */
- (newfunc)PyType_GenericNew, /* tp_new */
- (freefunc)0, /* tp_free */
- NULL, /* tp_is_gc */
- NULL, /* tp_bases */
- NULL, /* tp_mro */
- NULL, /* tp_cache */
- NULL, /* tp_subclasses */
- NULL, /* tp_weaklist */
- (destructor) NULL /* tp_del */
-};
-
-
-static PyObject *gPyOffScreenCreate(PyObject *UNUSED(self), PyObject *args)
-{
- int width;
- int height;
- int samples;
- int target;
-
- samples = 0;
- if (!PyArg_ParseTuple(args, "ii|ii:offScreenCreate", &width, &height, &samples, &target))
- return NULL;
-
- return PyObject_CallObject((PyObject *) &PyRASOffScreen_Type, args);
-}
-
-PyDoc_STRVAR(Rasterizer_module_documentation,
-"This is the Python API for the game engine of Rasterizer"
-);
-
-static struct PyMethodDef rasterizer_methods[] = {
- {"getWindowWidth",(PyCFunction) gPyGetWindowWidth,
- METH_VARARGS, "getWindowWidth doc"},
- {"getWindowHeight",(PyCFunction) gPyGetWindowHeight,
- METH_VARARGS, "getWindowHeight doc"},
- {"makeScreenshot",(PyCFunction)gPyMakeScreenshot,
- METH_VARARGS, "make Screenshot doc"},
- {"enableVisibility",(PyCFunction) gPyEnableVisibility,
- METH_VARARGS, "enableVisibility doc"},
- {"showMouse",(PyCFunction) gPyShowMouse,
- METH_VARARGS, "showMouse(bool visible)"},
- {"setMousePosition",(PyCFunction) gPySetMousePosition,
- METH_VARARGS, "setMousePosition(int x,int y)"},
- {"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_O,"set Background Color (rgb)"},
- {"enableMotionBlur",(PyCFunction)gPyEnableMotionBlur,METH_VARARGS,"enable motion blur"},
- {"disableMotionBlur",(PyCFunction)gPyDisableMotionBlur,METH_NOARGS,"disable motion blur"},
-
- {"setEyeSeparation", (PyCFunction) gPySetEyeSeparation, METH_VARARGS, "set the eye separation for stereo mode"},
- {"getEyeSeparation", (PyCFunction) gPyGetEyeSeparation, METH_NOARGS, "get the eye separation for stereo mode"},
- {"setFocalLength", (PyCFunction) gPySetFocalLength, METH_VARARGS, "set the focal length for stereo mode"},
- {"getFocalLength", (PyCFunction) gPyGetFocalLength, METH_VARARGS, "get the focal length for stereo mode"},
- {"getStereoEye", (PyCFunction) gPyGetStereoEye, METH_VARARGS, "get the current stereoscopy eye being rendered"},
- {"setMaterialMode",(PyCFunction) gPySetMaterialType,
- METH_VARARGS, "set the material mode to use for OpenGL rendering"},
- {"getMaterialMode",(PyCFunction) gPyGetMaterialType,
- METH_NOARGS, "get the material mode being used for OpenGL rendering"},
- {"setGLSLMaterialSetting",(PyCFunction) gPySetGLSLMaterialSetting,
- METH_VARARGS, "set the state of a GLSL material setting"},
- {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting,
- METH_VARARGS, "get the state of a GLSL material setting"},
- {"setAnisotropicFiltering", (PyCFunction) gPySetAnisotropicFiltering,
- METH_VARARGS, "set the anisotropic filtering level (must be one of 1, 2, 4, 8, 16)"},
- {"getAnisotropicFiltering", (PyCFunction) gPyGetAnisotropicFiltering,
- METH_VARARGS, "get the anisotropic filtering level"},
- {"drawLine", (PyCFunction) gPyDrawLine,
- METH_VARARGS, "draw a line on the screen"},
- {"setWindowSize", (PyCFunction) gPySetWindowSize, METH_VARARGS, ""},
- {"setFullScreen", (PyCFunction) gPySetFullScreen, METH_O, ""},
- {"getFullScreen", (PyCFunction) gPyGetFullScreen, METH_NOARGS, ""},
- {"getDisplayDimensions", (PyCFunction) gPyGetDisplayDimensions, METH_NOARGS,
- "Get the actual dimensions, in pixels, of the physical display (e.g., the monitor)."},
- {"setMipmapping", (PyCFunction) gPySetMipmapping, METH_VARARGS, ""},
- {"getMipmapping", (PyCFunction) gPyGetMipmapping, METH_NOARGS, ""},
- {"setVsync", (PyCFunction) gPySetVsync, METH_VARARGS, ""},
- {"getVsync", (PyCFunction) gPyGetVsync, METH_NOARGS, ""},
- {"showFramerate",(PyCFunction) gPyShowFramerate, METH_VARARGS, "show or hide the framerate"},
- {"showProfile",(PyCFunction) gPyShowProfile, METH_VARARGS, "show or hide the profile"},
- {"showProperties",(PyCFunction) gPyShowProperties, METH_VARARGS, "show or hide the debug properties"},
- {"autoDebugList",(PyCFunction) gPyAutoDebugList, METH_VARARGS, "enable or disable auto adding debug properties to the debug list"},
- {"clearDebugList",(PyCFunction) gPyClearDebugList, METH_NOARGS, "clears the debug property list"},
- {"offScreenCreate", (PyCFunction) gPyOffScreenCreate, METH_VARARGS, "create an offscreen buffer object, arguments are width and height in pixels"},
- { NULL, (PyCFunction) NULL, 0, NULL }
-};
-
-
-
-PyDoc_STRVAR(GameLogic_module_documentation,
-"This is the Python API for the game engine of bge.logic"
-);
-
-static struct PyModuleDef GameLogic_module_def = {
- {}, /* m_base */
- "GameLogic", /* m_name */
- GameLogic_module_documentation, /* m_doc */
- 0, /* m_size */
- game_methods, /* m_methods */
- 0, /* m_reload */
- 0, /* m_traverse */
- 0, /* m_clear */
- 0, /* m_free */
-};
-
-PyMODINIT_FUNC initGameLogicPythonBinding()
-{
- PyObject *m;
- PyObject *d;
- PyObject *item; /* temp PyObject *storage */
-
- gUseVisibilityTemp=false;
-
- PyObjectPlus::ClearDeprecationWarning(); /* Not that nice to call here but makes sure warnings are reset between loading scenes */
-
- m = PyModule_Create(&GameLogic_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), GameLogic_module_def.m_name, m);
-
-
- // Add some symbolic constants to the module
- d = PyModule_GetDict(m);
-
- // can be overwritten later for gameEngine instances that can load new blend files and re-initialize this module
- // for now its safe to make sure it exists for other areas such as the web plugin
-
- PyDict_SetItemString(d, "globalDict", item=PyDict_New()); Py_DECREF(item);
-
- // Add keyboard and mouse attributes to this module
- MT_assert(!gp_PythonKeyboard);
- gp_PythonKeyboard = new SCA_PythonKeyboard(gp_KetsjiEngine->GetKeyboardDevice());
- PyDict_SetItemString(d, "keyboard", gp_PythonKeyboard->NewProxy(true));
-
- MT_assert(!gp_PythonMouse);
- gp_PythonMouse = new SCA_PythonMouse(gp_KetsjiEngine->GetMouseDevice(), gp_Canvas);
- PyDict_SetItemString(d, "mouse", gp_PythonMouse->NewProxy(true));
-
- PyObject* joylist = PyList_New(JOYINDEX_MAX);
- for (int i=0; i<JOYINDEX_MAX; ++i) {
- SCA_Joystick *joy = SCA_Joystick::GetInstance(i);
- PyObject *item;
-
- if (joy && joy->Connected()) {
- gp_PythonJoysticks[i] = new SCA_PythonJoystick(joy);
- item = gp_PythonJoysticks[i]->NewProxy(true);
- }
- else {
- if (joy) {
- joy->ReleaseInstance();
- }
- item = Py_None;
- }
-
- Py_INCREF(item);
- PyList_SET_ITEM(joylist, i, item);
- }
- PyDict_SetItemString(d, "joysticks", joylist);
-
- ErrorObject = PyUnicode_FromString("GameLogic.error");
- PyDict_SetItemString(d, "error", ErrorObject);
- Py_DECREF(ErrorObject);
-
- // XXXX Add constants here
- /* To use logic bricks, we need some sort of constants. Here, we associate */
- /* constants and sumbolic names. Add them to dictionary d. */
-
- /* 1. true and false: needed for everyone */
- KX_MACRO_addTypesToDict(d, KX_TRUE, SCA_ILogicBrick::KX_TRUE);
- KX_MACRO_addTypesToDict(d, KX_FALSE, SCA_ILogicBrick::KX_FALSE);
-
- /* 2. Property sensor */
- KX_MACRO_addTypesToDict(d, KX_PROPSENSOR_EQUAL, SCA_PropertySensor::KX_PROPSENSOR_EQUAL);
- KX_MACRO_addTypesToDict(d, KX_PROPSENSOR_NOTEQUAL, SCA_PropertySensor::KX_PROPSENSOR_NOTEQUAL);
- KX_MACRO_addTypesToDict(d, KX_PROPSENSOR_INTERVAL, SCA_PropertySensor::KX_PROPSENSOR_INTERVAL);
- KX_MACRO_addTypesToDict(d, KX_PROPSENSOR_CHANGED, SCA_PropertySensor::KX_PROPSENSOR_CHANGED);
- KX_MACRO_addTypesToDict(d, KX_PROPSENSOR_EXPRESSION, SCA_PropertySensor::KX_PROPSENSOR_EXPRESSION);
- KX_MACRO_addTypesToDict(d, KX_PROPSENSOR_LESSTHAN, SCA_PropertySensor::KX_PROPSENSOR_LESSTHAN);
- KX_MACRO_addTypesToDict(d, KX_PROPSENSOR_GREATERTHAN, SCA_PropertySensor::KX_PROPSENSOR_GREATERTHAN);
-
- /* 3. Constraint actuator */
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_LOCX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_LOCY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_LOCZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ROTX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ROTY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ROTZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRPX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRPY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRPZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPZ);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRNX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRNY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRNZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNZ);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ORIX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ORIY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ORIZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_FHPX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPX);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_FHPY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPY);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_FHPZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPZ);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_FHNX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNX);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_FHNY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNY);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_FHNZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNZ);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_NORMAL, KX_ConstraintActuator::KX_ACT_CONSTRAINT_NORMAL);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_MATERIAL, KX_ConstraintActuator::KX_ACT_CONSTRAINT_MATERIAL);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_PERMANENT, KX_ConstraintActuator::KX_ACT_CONSTRAINT_PERMANENT);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DISTANCE, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DISTANCE);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_LOCAL, KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCAL);
- KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DOROTFH, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DOROTFH);
-
- /* 4. Random distribution types */
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_BOOL_CONST, SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST);
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_BOOL_UNIFORM, SCA_RandomActuator::KX_RANDOMACT_BOOL_UNIFORM);
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_BOOL_BERNOUILLI, SCA_RandomActuator::KX_RANDOMACT_BOOL_BERNOUILLI);
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_INT_CONST, SCA_RandomActuator::KX_RANDOMACT_INT_CONST);
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_INT_UNIFORM, SCA_RandomActuator::KX_RANDOMACT_INT_UNIFORM);
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_INT_POISSON, SCA_RandomActuator::KX_RANDOMACT_INT_POISSON);
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_FLOAT_CONST, SCA_RandomActuator::KX_RANDOMACT_FLOAT_CONST);
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_FLOAT_UNIFORM, SCA_RandomActuator::KX_RANDOMACT_FLOAT_UNIFORM);
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_FLOAT_NORMAL, SCA_RandomActuator::KX_RANDOMACT_FLOAT_NORMAL);
- KX_MACRO_addTypesToDict(d, KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL, SCA_RandomActuator::KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL);
-
- /* 5. Sound actuator */
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_PLAYSTOP, KX_SoundActuator::KX_SOUNDACT_PLAYSTOP);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_PLAYEND, KX_SoundActuator::KX_SOUNDACT_PLAYEND);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPSTOP, KX_SoundActuator::KX_SOUNDACT_LOOPSTOP);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPEND, KX_SoundActuator::KX_SOUNDACT_LOOPEND);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP, KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP);
-
- /* 6. Action actuator */
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PLAY, ACT_ACTION_PLAY);
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PINGPONG, ACT_ACTION_PINGPONG);
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_FLIPPER, ACT_ACTION_FLIPPER);
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPSTOP, ACT_ACTION_LOOP_STOP);
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPEND, ACT_ACTION_LOOP_END);
- KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PROPERTY, ACT_ACTION_FROM_PROP);
-
- /* 7. GL_BlendFunc */
- KX_MACRO_addTypesToDict(d, BL_ZERO, GL_ZERO);
- KX_MACRO_addTypesToDict(d, BL_ONE, GL_ONE);
- KX_MACRO_addTypesToDict(d, BL_SRC_COLOR, GL_SRC_COLOR);
- KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
- KX_MACRO_addTypesToDict(d, BL_DST_COLOR, GL_DST_COLOR);
- KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_DST_COLOR);
- KX_MACRO_addTypesToDict(d, BL_SRC_ALPHA, GL_SRC_ALPHA);
- KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- KX_MACRO_addTypesToDict(d, BL_DST_ALPHA, GL_DST_ALPHA);
- KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
- KX_MACRO_addTypesToDict(d, BL_SRC_ALPHA_SATURATE, GL_SRC_ALPHA_SATURATE);
-
-
- /* 8. UniformTypes */
- KX_MACRO_addTypesToDict(d, SHD_TANGENT, BL_Shader::SHD_TANGENT);
- KX_MACRO_addTypesToDict(d, MODELVIEWMATRIX, BL_Shader::MODELVIEWMATRIX);
- KX_MACRO_addTypesToDict(d, MODELVIEWMATRIX_TRANSPOSE, BL_Shader::MODELVIEWMATRIX_TRANSPOSE);
- KX_MACRO_addTypesToDict(d, MODELVIEWMATRIX_INVERSE, BL_Shader::MODELVIEWMATRIX_INVERSE);
- KX_MACRO_addTypesToDict(d, MODELVIEWMATRIX_INVERSETRANSPOSE, BL_Shader::MODELVIEWMATRIX_INVERSETRANSPOSE);
- KX_MACRO_addTypesToDict(d, MODELMATRIX, BL_Shader::MODELMATRIX);
- KX_MACRO_addTypesToDict(d, MODELMATRIX_TRANSPOSE, BL_Shader::MODELMATRIX_TRANSPOSE);
- KX_MACRO_addTypesToDict(d, MODELMATRIX_INVERSE, BL_Shader::MODELMATRIX_INVERSE);
- KX_MACRO_addTypesToDict(d, MODELMATRIX_INVERSETRANSPOSE, BL_Shader::MODELMATRIX_INVERSETRANSPOSE);
- KX_MACRO_addTypesToDict(d, VIEWMATRIX, BL_Shader::VIEWMATRIX);
- KX_MACRO_addTypesToDict(d, VIEWMATRIX_TRANSPOSE, BL_Shader::VIEWMATRIX_TRANSPOSE);
- KX_MACRO_addTypesToDict(d, VIEWMATRIX_INVERSE, BL_Shader::VIEWMATRIX_INVERSE);
- KX_MACRO_addTypesToDict(d, VIEWMATRIX_INVERSETRANSPOSE, BL_Shader::VIEWMATRIX_INVERSETRANSPOSE);
- KX_MACRO_addTypesToDict(d, CAM_POS, BL_Shader::CAM_POS);
- KX_MACRO_addTypesToDict(d, CONSTANT_TIMER, BL_Shader::CONSTANT_TIMER);
-
- /* 9. state actuator */
- KX_MACRO_addTypesToDict(d, KX_STATE1, (1<<0));
- KX_MACRO_addTypesToDict(d, KX_STATE2, (1<<1));
- KX_MACRO_addTypesToDict(d, KX_STATE3, (1<<2));
- KX_MACRO_addTypesToDict(d, KX_STATE4, (1<<3));
- KX_MACRO_addTypesToDict(d, KX_STATE5, (1<<4));
- KX_MACRO_addTypesToDict(d, KX_STATE6, (1<<5));
- KX_MACRO_addTypesToDict(d, KX_STATE7, (1<<6));
- KX_MACRO_addTypesToDict(d, KX_STATE8, (1<<7));
- KX_MACRO_addTypesToDict(d, KX_STATE9, (1<<8));
- KX_MACRO_addTypesToDict(d, KX_STATE10, (1<<9));
- KX_MACRO_addTypesToDict(d, KX_STATE11, (1<<10));
- KX_MACRO_addTypesToDict(d, KX_STATE12, (1<<11));
- KX_MACRO_addTypesToDict(d, KX_STATE13, (1<<12));
- KX_MACRO_addTypesToDict(d, KX_STATE14, (1<<13));
- KX_MACRO_addTypesToDict(d, KX_STATE15, (1<<14));
- KX_MACRO_addTypesToDict(d, KX_STATE16, (1<<15));
- KX_MACRO_addTypesToDict(d, KX_STATE17, (1<<16));
- KX_MACRO_addTypesToDict(d, KX_STATE18, (1<<17));
- KX_MACRO_addTypesToDict(d, KX_STATE19, (1<<18));
- KX_MACRO_addTypesToDict(d, KX_STATE20, (1<<19));
- KX_MACRO_addTypesToDict(d, KX_STATE21, (1<<20));
- KX_MACRO_addTypesToDict(d, KX_STATE22, (1<<21));
- KX_MACRO_addTypesToDict(d, KX_STATE23, (1<<22));
- KX_MACRO_addTypesToDict(d, KX_STATE24, (1<<23));
- KX_MACRO_addTypesToDict(d, KX_STATE25, (1<<24));
- KX_MACRO_addTypesToDict(d, KX_STATE26, (1<<25));
- KX_MACRO_addTypesToDict(d, KX_STATE27, (1<<26));
- KX_MACRO_addTypesToDict(d, KX_STATE28, (1<<27));
- KX_MACRO_addTypesToDict(d, KX_STATE29, (1<<28));
- KX_MACRO_addTypesToDict(d, KX_STATE30, (1<<29));
-
- /* All Sensors */
- KX_MACRO_addTypesToDict(d, KX_SENSOR_JUST_ACTIVATED, SCA_ISensor::KX_SENSOR_JUST_ACTIVATED);
- KX_MACRO_addTypesToDict(d, KX_SENSOR_ACTIVE, SCA_ISensor::KX_SENSOR_ACTIVE);
- KX_MACRO_addTypesToDict(d, KX_SENSOR_JUST_DEACTIVATED, SCA_ISensor::KX_SENSOR_JUST_DEACTIVATED);
- KX_MACRO_addTypesToDict(d, KX_SENSOR_INACTIVE, SCA_ISensor::KX_SENSOR_INACTIVE);
-
- /* Radar Sensor */
- KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_POS_X, KX_RadarSensor::KX_RADAR_AXIS_POS_X);
- KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_POS_Y, KX_RadarSensor::KX_RADAR_AXIS_POS_Y);
- KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_POS_Z, KX_RadarSensor::KX_RADAR_AXIS_POS_Z);
- KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_NEG_X, KX_RadarSensor::KX_RADAR_AXIS_NEG_X);
- KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_NEG_Y, KX_RadarSensor::KX_RADAR_AXIS_NEG_Y);
- KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_NEG_Z, KX_RadarSensor::KX_RADAR_AXIS_NEG_Z);
-
- /* Ray Sensor */
- KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_POS_X, KX_RaySensor::KX_RAY_AXIS_POS_X);
- KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_POS_Y, KX_RaySensor::KX_RAY_AXIS_POS_Y);
- KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_POS_Z, KX_RaySensor::KX_RAY_AXIS_POS_Z);
- KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_NEG_X, KX_RaySensor::KX_RAY_AXIS_NEG_X);
- KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_NEG_Y, KX_RaySensor::KX_RAY_AXIS_NEG_Y);
- KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_NEG_Z, KX_RaySensor::KX_RAY_AXIS_NEG_Z);
-
- /* TrackTo Actuator */
- KX_MACRO_addTypesToDict(d, KX_TRACK_UPAXIS_POS_X, KX_TrackToActuator::KX_TRACK_UPAXIS_POS_X);
- KX_MACRO_addTypesToDict(d, KX_TRACK_UPAXIS_POS_Y, KX_TrackToActuator::KX_TRACK_UPAXIS_POS_Y);
- KX_MACRO_addTypesToDict(d, KX_TRACK_UPAXIS_POS_Z, KX_TrackToActuator::KX_TRACK_UPAXIS_POS_Z);
- KX_MACRO_addTypesToDict(d, KX_TRACK_TRAXIS_POS_X, KX_TrackToActuator::KX_TRACK_TRAXIS_POS_X);
- KX_MACRO_addTypesToDict(d, KX_TRACK_TRAXIS_POS_Y, KX_TrackToActuator::KX_TRACK_TRAXIS_POS_Y);
- KX_MACRO_addTypesToDict(d, KX_TRACK_TRAXIS_POS_Z, KX_TrackToActuator::KX_TRACK_TRAXIS_POS_Z);
- KX_MACRO_addTypesToDict(d, KX_TRACK_TRAXIS_NEG_X, KX_TrackToActuator::KX_TRACK_TRAXIS_NEG_X);
- KX_MACRO_addTypesToDict(d, KX_TRACK_TRAXIS_NEG_Y, KX_TrackToActuator::KX_TRACK_TRAXIS_NEG_Y);
- KX_MACRO_addTypesToDict(d, KX_TRACK_TRAXIS_NEG_Z, KX_TrackToActuator::KX_TRACK_TRAXIS_NEG_Z);
-
- /* Dynamic actuator */
- KX_MACRO_addTypesToDict(d, KX_DYN_RESTORE_DYNAMICS, KX_SCA_DynamicActuator::KX_DYN_RESTORE_DYNAMICS);
- KX_MACRO_addTypesToDict(d, KX_DYN_DISABLE_DYNAMICS, KX_SCA_DynamicActuator::KX_DYN_DISABLE_DYNAMICS);
- KX_MACRO_addTypesToDict(d, KX_DYN_ENABLE_RIGID_BODY, KX_SCA_DynamicActuator::KX_DYN_ENABLE_RIGID_BODY);
- KX_MACRO_addTypesToDict(d, KX_DYN_DISABLE_RIGID_BODY, KX_SCA_DynamicActuator::KX_DYN_DISABLE_RIGID_BODY);
- KX_MACRO_addTypesToDict(d, KX_DYN_SET_MASS, KX_SCA_DynamicActuator::KX_DYN_SET_MASS);
-
- /* Input & Mouse Sensor */
- KX_MACRO_addTypesToDict(d, KX_INPUT_NONE, SCA_InputEvent::KX_NO_INPUTSTATUS);
- KX_MACRO_addTypesToDict(d, KX_INPUT_JUST_ACTIVATED, SCA_InputEvent::KX_JUSTACTIVATED);
- KX_MACRO_addTypesToDict(d, KX_INPUT_ACTIVE, SCA_InputEvent::KX_ACTIVE);
- KX_MACRO_addTypesToDict(d, KX_INPUT_JUST_RELEASED, SCA_InputEvent::KX_JUSTRELEASED);
-
- KX_MACRO_addTypesToDict(d, KX_MOUSE_BUT_LEFT, SCA_IInputDevice::KX_LEFTMOUSE);
- KX_MACRO_addTypesToDict(d, KX_MOUSE_BUT_MIDDLE, SCA_IInputDevice::KX_MIDDLEMOUSE);
- KX_MACRO_addTypesToDict(d, KX_MOUSE_BUT_RIGHT, SCA_IInputDevice::KX_RIGHTMOUSE);
-
- /* 2D Filter Actuator */
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_ENABLED, RAS_2DFilterManager::RAS_2DFILTER_ENABLED);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_DISABLED, RAS_2DFilterManager::RAS_2DFILTER_DISABLED);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_NOFILTER, RAS_2DFilterManager::RAS_2DFILTER_NOFILTER);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_MOTIONBLUR, RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_BLUR, RAS_2DFilterManager::RAS_2DFILTER_BLUR);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_SHARPEN, RAS_2DFilterManager::RAS_2DFILTER_SHARPEN);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_DILATION, RAS_2DFilterManager::RAS_2DFILTER_DILATION);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_EROSION, RAS_2DFilterManager::RAS_2DFILTER_EROSION);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_LAPLACIAN, RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_SOBEL, RAS_2DFilterManager::RAS_2DFILTER_SOBEL);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_PREWITT, RAS_2DFilterManager::RAS_2DFILTER_PREWITT);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_GRAYSCALE, RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_SEPIA, RAS_2DFilterManager::RAS_2DFILTER_SEPIA);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_INVERT, RAS_2DFilterManager::RAS_2DFILTER_INVERT);
- KX_MACRO_addTypesToDict(d, RAS_2DFILTER_CUSTOMFILTER, RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER);
-
- /* Sound Actuator */
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_PLAYSTOP, KX_SoundActuator::KX_SOUNDACT_PLAYSTOP);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_PLAYEND, KX_SoundActuator::KX_SOUNDACT_PLAYEND);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPSTOP, KX_SoundActuator::KX_SOUNDACT_LOOPSTOP);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPEND, KX_SoundActuator:: KX_SOUNDACT_LOOPEND);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL);
- KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP, KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP);
-
- /* State Actuator */
- KX_MACRO_addTypesToDict(d, KX_STATE_OP_CPY, KX_StateActuator::OP_CPY);
- KX_MACRO_addTypesToDict(d, KX_STATE_OP_SET, KX_StateActuator::OP_SET);
- KX_MACRO_addTypesToDict(d, KX_STATE_OP_CLR, KX_StateActuator::OP_CLR);
- KX_MACRO_addTypesToDict(d, KX_STATE_OP_NEG, KX_StateActuator::OP_NEG);
-
- /* Game Actuator Modes */
- KX_MACRO_addTypesToDict(d, KX_GAME_LOAD, KX_GameActuator::KX_GAME_LOAD);
- KX_MACRO_addTypesToDict(d, KX_GAME_START, KX_GameActuator::KX_GAME_START);
- KX_MACRO_addTypesToDict(d, KX_GAME_RESTART, KX_GameActuator::KX_GAME_RESTART);
- KX_MACRO_addTypesToDict(d, KX_GAME_QUIT, KX_GameActuator::KX_GAME_QUIT);
- KX_MACRO_addTypesToDict(d, KX_GAME_SAVECFG, KX_GameActuator::KX_GAME_SAVECFG);
- KX_MACRO_addTypesToDict(d, KX_GAME_LOADCFG, KX_GameActuator::KX_GAME_LOADCFG);
- KX_MACRO_addTypesToDict(d, KX_GAME_SCREENSHOT, KX_GameActuator::KX_GAME_SCREENSHOT);
-
- /* Scene Actuator Modes */
- KX_MACRO_addTypesToDict(d, KX_SCENE_RESTART, KX_SceneActuator::KX_SCENE_RESTART);
- KX_MACRO_addTypesToDict(d, KX_SCENE_SET_SCENE, KX_SceneActuator::KX_SCENE_SET_SCENE);
- KX_MACRO_addTypesToDict(d, KX_SCENE_SET_CAMERA, KX_SceneActuator::KX_SCENE_SET_CAMERA);
- KX_MACRO_addTypesToDict(d, KX_SCENE_ADD_FRONT_SCENE, KX_SceneActuator::KX_SCENE_ADD_FRONT_SCENE);
- KX_MACRO_addTypesToDict(d, KX_SCENE_ADD_BACK_SCENE, KX_SceneActuator::KX_SCENE_ADD_BACK_SCENE);
- KX_MACRO_addTypesToDict(d, KX_SCENE_REMOVE_SCENE, KX_SceneActuator::KX_SCENE_REMOVE_SCENE);
- KX_MACRO_addTypesToDict(d, KX_SCENE_SUSPEND, KX_SceneActuator::KX_SCENE_SUSPEND);
- KX_MACRO_addTypesToDict(d, KX_SCENE_RESUME, KX_SceneActuator::KX_SCENE_RESUME);
-
- /* Parent Actuator Modes */
- KX_MACRO_addTypesToDict(d, KX_PARENT_SET, KX_ParentActuator::KX_PARENT_SET);
- KX_MACRO_addTypesToDict(d, KX_PARENT_REMOVE, KX_ParentActuator::KX_PARENT_REMOVE);
-
- /* BL_ArmatureConstraint type */
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_TRACKTO, CONSTRAINT_TYPE_TRACKTO);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_KINEMATIC);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_ROTLIKE, CONSTRAINT_TYPE_ROTLIKE);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_LOCLIKE, CONSTRAINT_TYPE_LOCLIKE);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_MINMAX, CONSTRAINT_TYPE_MINMAX);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_SIZELIKE, CONSTRAINT_TYPE_SIZELIKE);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_LOCKTRACK, CONSTRAINT_TYPE_LOCKTRACK);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_STRETCHTO, CONSTRAINT_TYPE_STRETCHTO);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_CLAMPTO);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_TRANSFORM, CONSTRAINT_TYPE_TRANSFORM);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_TYPE_DISTLIMIT, CONSTRAINT_TYPE_DISTLIMIT);
- /* BL_ArmatureConstraint ik_type */
- KX_MACRO_addTypesToDict(d, CONSTRAINT_IK_COPYPOSE, CONSTRAINT_IK_COPYPOSE);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_IK_DISTANCE, CONSTRAINT_IK_DISTANCE);
- /* BL_ArmatureConstraint ik_mode */
- KX_MACRO_addTypesToDict(d, CONSTRAINT_IK_MODE_INSIDE, LIMITDIST_INSIDE);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_IK_MODE_OUTSIDE, LIMITDIST_OUTSIDE);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_IK_MODE_ONSURFACE, LIMITDIST_ONSURFACE);
- /* BL_ArmatureConstraint ik_flag */
- KX_MACRO_addTypesToDict(d, CONSTRAINT_IK_FLAG_TIP, CONSTRAINT_IK_TIP);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_IK_FLAG_ROT, CONSTRAINT_IK_ROT);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_IK_FLAG_STRETCH, CONSTRAINT_IK_STRETCH);
- KX_MACRO_addTypesToDict(d, CONSTRAINT_IK_FLAG_POS, CONSTRAINT_IK_POS);
- /* KX_ArmatureSensor type */
- KX_MACRO_addTypesToDict(d, KX_ARMSENSOR_STATE_CHANGED, SENS_ARM_STATE_CHANGED);
- KX_MACRO_addTypesToDict(d, KX_ARMSENSOR_LIN_ERROR_BELOW, SENS_ARM_LIN_ERROR_BELOW);
- KX_MACRO_addTypesToDict(d, KX_ARMSENSOR_LIN_ERROR_ABOVE, SENS_ARM_LIN_ERROR_ABOVE);
- KX_MACRO_addTypesToDict(d, KX_ARMSENSOR_ROT_ERROR_BELOW, SENS_ARM_ROT_ERROR_BELOW);
- KX_MACRO_addTypesToDict(d, KX_ARMSENSOR_ROT_ERROR_ABOVE, SENS_ARM_ROT_ERROR_ABOVE);
-
- /* BL_ArmatureActuator type */
- KX_MACRO_addTypesToDict(d, KX_ACT_ARMATURE_RUN, ACT_ARM_RUN);
- KX_MACRO_addTypesToDict(d, KX_ACT_ARMATURE_ENABLE, ACT_ARM_ENABLE);
- KX_MACRO_addTypesToDict(d, KX_ACT_ARMATURE_DISABLE, ACT_ARM_DISABLE);
- KX_MACRO_addTypesToDict(d, KX_ACT_ARMATURE_SETTARGET, ACT_ARM_SETTARGET);
- KX_MACRO_addTypesToDict(d, KX_ACT_ARMATURE_SETWEIGHT, ACT_ARM_SETWEIGHT);
- KX_MACRO_addTypesToDict(d, KX_ACT_ARMATURE_SETINFLUENCE, ACT_ARM_SETINFLUENCE);
-
- /* BL_Armature Channel rotation_mode */
- KX_MACRO_addTypesToDict(d, ROT_MODE_QUAT, ROT_MODE_QUAT);
- KX_MACRO_addTypesToDict(d, ROT_MODE_XYZ, ROT_MODE_XYZ);
- KX_MACRO_addTypesToDict(d, ROT_MODE_XZY, ROT_MODE_XZY);
- KX_MACRO_addTypesToDict(d, ROT_MODE_YXZ, ROT_MODE_YXZ);
- KX_MACRO_addTypesToDict(d, ROT_MODE_YZX, ROT_MODE_YZX);
- KX_MACRO_addTypesToDict(d, ROT_MODE_ZXY, ROT_MODE_ZXY);
- KX_MACRO_addTypesToDict(d, ROT_MODE_ZYX, ROT_MODE_ZYX);
-
- /* Steering actuator */
- KX_MACRO_addTypesToDict(d, KX_STEERING_SEEK, KX_SteeringActuator::KX_STEERING_SEEK);
- KX_MACRO_addTypesToDict(d, KX_STEERING_FLEE, KX_SteeringActuator::KX_STEERING_FLEE);
- KX_MACRO_addTypesToDict(d, KX_STEERING_PATHFOLLOWING, KX_SteeringActuator::KX_STEERING_PATHFOLLOWING);
-
- /* KX_NavMeshObject render mode */
- KX_MACRO_addTypesToDict(d, RM_WALLS, KX_NavMeshObject::RM_WALLS);
- KX_MACRO_addTypesToDict(d, RM_POLYS, KX_NavMeshObject::RM_POLYS);
- KX_MACRO_addTypesToDict(d, RM_TRIS, KX_NavMeshObject::RM_TRIS);
-
- /* BL_Action play modes */
- KX_MACRO_addTypesToDict(d, KX_ACTION_MODE_PLAY, BL_Action::ACT_MODE_PLAY);
- KX_MACRO_addTypesToDict(d, KX_ACTION_MODE_LOOP, BL_Action::ACT_MODE_LOOP);
- KX_MACRO_addTypesToDict(d, KX_ACTION_MODE_PING_PONG, BL_Action::ACT_MODE_PING_PONG);
-
- /* BL_Action blend modes */
- KX_MACRO_addTypesToDict(d, KX_ACTION_BLEND_BLEND, BL_Action::ACT_BLEND_BLEND);
- KX_MACRO_addTypesToDict(d, KX_ACTION_BLEND_ADD, BL_Action::ACT_BLEND_ADD);
-
- /* Mouse Actuator object axis*/
- KX_MACRO_addTypesToDict(d, KX_ACT_MOUSE_OBJECT_AXIS_X, KX_MouseActuator::KX_ACT_MOUSE_OBJECT_AXIS_X);
- KX_MACRO_addTypesToDict(d, KX_ACT_MOUSE_OBJECT_AXIS_Y, KX_MouseActuator::KX_ACT_MOUSE_OBJECT_AXIS_Y);
- KX_MACRO_addTypesToDict(d, KX_ACT_MOUSE_OBJECT_AXIS_Z, KX_MouseActuator::KX_ACT_MOUSE_OBJECT_AXIS_Z);
-
-
- // Check for errors
- if (PyErr_Occurred())
- {
- Py_FatalError("can't initialize module bge.logic");
- }
-
- return m;
-}
-
-/**
- * Explanation of
- *
- * - backupPySysObjects() : stores sys.path in #gp_sys_backup
- * - initPySysObjects(main) : initializes the blendfile and library paths
- * - restorePySysObjects() : restores sys.path from #gp_sys_backup
- *
- * These exist so the current blend dir "//" can always be used to import modules from.
- * the reason we need a few functions for this is that python is not only used by the game engine
- * so we cant just add to sys.path all the time, it would leave pythons state in a mess.
- * It would also be incorrect since loading blend files for new levels etc would always add to sys.path
- *
- * To play nice with blenders python, the sys.path is backed up and the current blendfile along
- * with all its lib paths are added to the sys path.
- * When loading a new blendfile, the original sys.path is restored and the new paths are added over the top.
- */
-
-/**
- * So we can have external modules mixed with our blend files.
- */
-static void backupPySysObjects(void)
-{
- PyObject *sys_path = PySys_GetObject("path");
- PyObject *sys_meta_path = PySys_GetObject("meta_path");
- PyObject *sys_mods = PySys_GetObject("modules");
-
- /* paths */
- Py_XDECREF(gp_sys_backup.path); /* just in case its set */
- gp_sys_backup.path = PyList_GetSlice(sys_path, 0, INT_MAX); /* copy the list */
-
- /* meta_paths */
- Py_XDECREF(gp_sys_backup.meta_path); /* just in case its set */
- gp_sys_backup.meta_path = PyList_GetSlice(sys_meta_path, 0, INT_MAX); /* copy the list */
-
- /* modules */
- Py_XDECREF(gp_sys_backup.modules); /* just in case its set */
- gp_sys_backup.modules = PyDict_Copy(sys_mods); /* copy the dict */
-
-}
-
-/* for initPySysObjects only,
- * takes a blend path and adds a scripts dir from it
- *
- * "/home/me/foo.blend" -> "/home/me/scripts"
- */
-static void initPySysObjects__append(PyObject *sys_path, const char *filename)
-{
- PyObject *item;
- char expanded[FILE_MAX];
-
- BLI_split_dir_part(filename, expanded, sizeof(expanded)); /* get the dir part of filename only */
- BLI_path_abs(expanded, gp_GamePythonPath); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */
- BLI_cleanup_file(gp_GamePythonPath, expanded); /* Don't use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */
- item = PyC_UnicodeFromByte(expanded);
-
-// printf("SysPath - '%s', '%s', '%s'\n", expanded, filename, gp_GamePythonPath);
-
- if (PySequence_Index(sys_path, item) == -1) {
- PyErr_Clear(); /* PySequence_Index sets a ValueError */
- PyList_Insert(sys_path, 0, item);
- }
-
- Py_DECREF(item);
-}
-static void initPySysObjects(Main *maggie)
-{
- PyObject *sys_path = PySys_GetObject("path");
- PyObject *sys_meta_path = PySys_GetObject("meta_path");
-
- if (gp_sys_backup.path == NULL) {
- /* backup */
- backupPySysObjects();
- }
- else {
- /* get the original sys path when the BGE started */
- PyList_SetSlice(sys_path, 0, INT_MAX, gp_sys_backup.path);
- PyList_SetSlice(sys_meta_path, 0, INT_MAX, gp_sys_backup.meta_path);
- }
-
- Library *lib= (Library *)maggie->library.first;
-
- while (lib) {
- /* lib->name wont work in some cases (on win32),
- * even when expanding with gp_GamePythonPath, using lib->filename is less trouble */
- initPySysObjects__append(sys_path, lib->filepath);
- lib= (Library *)lib->id.next;
- }
-
- initPySysObjects__append(sys_path, gp_GamePythonPath);
-
-// fprintf(stderr, "\nNew Path: %d ", PyList_GET_SIZE(sys_path));
-// PyObject_Print(sys_path, stderr, 0);
-}
-
-static void restorePySysObjects(void)
-{
- if (gp_sys_backup.path == NULL) {
- return;
- }
-
- /* will never fail */
- PyObject *sys_path = PySys_GetObject("path");
- PyObject *sys_meta_path = PySys_GetObject("meta_path");
- PyObject *sys_mods = PySys_GetObject("modules");
-
- /* paths */
- PyList_SetSlice(sys_path, 0, INT_MAX, gp_sys_backup.path);
- Py_DECREF(gp_sys_backup.path);
- gp_sys_backup.path = NULL;
-
- /* meta_path */
- PyList_SetSlice(sys_meta_path, 0, INT_MAX, gp_sys_backup.meta_path);
- Py_DECREF(gp_sys_backup.meta_path);
- gp_sys_backup.meta_path = NULL;
-
- /* modules */
- PyDict_Clear(sys_mods);
- PyDict_Update(sys_mods, gp_sys_backup.modules);
- Py_DECREF(gp_sys_backup.modules);
- gp_sys_backup.modules = NULL;
-
-
-// fprintf(stderr, "\nRestore Path: %d ", PyList_GET_SIZE(sys_path));
-// PyObject_Print(sys_path, stderr, 0);
-}
-
-void addImportMain(struct Main *maggie)
-{
- bpy_import_main_extra_add(maggie);
-}
-
-void removeImportMain(struct Main *maggie)
-{
- bpy_import_main_extra_remove(maggie);
-}
-
-
-PyDoc_STRVAR(BGE_module_documentation,
- "This module contains submodules for the Blender Game Engine.\n"
-);
-
-static struct PyModuleDef BGE_module_def = {
- PyModuleDef_HEAD_INIT,
- "bge", /* m_name */
- BGE_module_documentation, /* m_doc */
- 0, /* m_size */
- NULL, /* m_methods */
- NULL, /* m_reload */
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL, /* m_free */
-};
-
-PyMODINIT_FUNC initBGE(void)
-{
- PyObject *mod;
- PyObject *submodule;
- PyObject *sys_modules = PyThreadState_GET()->interp->modules;
- const char *mod_full;
-
- mod = PyModule_Create(&BGE_module_def);
-
- /* skip "bge." */
-#define SUBMOD (mod_full + 4)
-
- mod_full = "bge.app";
- PyModule_AddObject(mod, SUBMOD, (submodule = initApplicationPythonBinding()));
- PyDict_SetItemString(sys_modules, mod_full, submodule);
- Py_INCREF(submodule);
-
- mod_full = "bge.constraints";
- PyModule_AddObject(mod, SUBMOD, (submodule = initConstraintPythonBinding()));
- PyDict_SetItemString(sys_modules, mod_full, submodule);
- Py_INCREF(submodule);
-
- mod_full = "bge.events";
- PyModule_AddObject(mod, SUBMOD, (submodule = initGameKeysPythonBinding()));
- PyDict_SetItemString(sys_modules, mod_full, submodule);
- Py_INCREF(submodule);
-
- mod_full = "bge.logic";
- PyModule_AddObject(mod, SUBMOD, (submodule = initGameLogicPythonBinding()));
- PyDict_SetItemString(sys_modules, mod_full, submodule);
- Py_INCREF(submodule);
-
- mod_full = "bge.render";
- PyModule_AddObject(mod, SUBMOD, (submodule = initRasterizerPythonBinding()));
- PyDict_SetItemString(sys_modules, mod_full, submodule);
- Py_INCREF(submodule);
-
- mod_full = "bge.texture";
- PyModule_AddObject(mod, SUBMOD, (submodule = initVideoTexturePythonBinding()));
- PyDict_SetItemString(sys_modules, mod_full, submodule);
- Py_INCREF(submodule);
-
- mod_full = "bge.types";
- PyModule_AddObject(mod, SUBMOD, (submodule = initGameTypesPythonBinding()));
- PyDict_SetItemString(sys_modules, mod_full, submodule);
- Py_INCREF(submodule);
-
-#undef SUBMOD
-
- return mod;
-}
-
-
-/* minimal required blender modules to run blenderplayer */
-static struct _inittab bge_internal_modules[] = {
- {"mathutils", PyInit_mathutils},
- {"bgl", BPyInit_bgl},
- {"blf", BPyInit_blf},
- {"aud", AUD_initPython},
- {NULL, NULL}
-};
-
-/**
- * Python is not initialized.
- * see bpy_interface.c's BPY_python_start() which shares the same functionality in blender.
- */
-PyObject *initGamePlayerPythonScripting(Main *maggie, int argc, char** argv)
-{
- /* Yet another gotcha in the py api
- * Cant run PySys_SetArgv more than once because this adds the
- * binary dir to the sys.path each time.
- * Id have thought python being totally restarted would make this ok but
- * somehow it remembers the sys.path - Campbell
- */
- static bool first_time = true;
- const char * const py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL);
-
- /* not essential but nice to set our name */
- static wchar_t program_path_wchar[FILE_MAX]; /* python holds a reference */
- BLI_strncpy_wchar_from_utf8(program_path_wchar, BKE_appdir_program_path(), ARRAY_SIZE(program_path_wchar));
- Py_SetProgramName(program_path_wchar);
-
- /* Update, Py3.3 resolves attempting to parse non-existing header */
-#if 0
- /* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to
- * parse from the 'sysconfig' module which is used by 'site',
- * so for now disable site. alternatively we could copy the file. */
- if (py_path_bundle != NULL) {
- Py_NoSiteFlag = 1; /* inhibits the automatic importing of 'site' */
- }
-#endif
-
- Py_FrozenFlag = 1;
-
- /* must run before python initializes */
- PyImport_ExtendInittab(bge_internal_modules);
-
- /* find local python installation */
- PyC_SetHomePath(py_path_bundle);
-
- Py_Initialize();
-
- if (argv && first_time) { /* browser plugins don't currently set this */
- // Until python support ascii again, we use our own.
- // PySys_SetArgv(argc, argv);
- int i;
- PyObject *py_argv= PyList_New(argc);
-
- for (i=0; i<argc; i++)
- PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i]));
-
- PySys_SetObject("argv", py_argv);
- Py_DECREF(py_argv);
- }
-
- /* Initialize thread support (also acquires lock) */
- PyEval_InitThreads();
-
- bpy_import_init(PyEval_GetBuiltins());
-
- bpy_import_main_set(maggie);
-
- initPySysObjects(maggie);
-
- /* mathutils types are used by the BGE even if we don't import them */
- {
- PyObject *mod = PyImport_ImportModuleLevel("mathutils", NULL, NULL, NULL, 0);
- Py_DECREF(mod);
- }
-
-#ifdef WITH_AUDASPACE
- /* accessing a SoundActuator's sound results in a crash if aud is not initialized... */
- {
- PyObject *mod = PyImport_ImportModuleLevel("aud", NULL, NULL, NULL, 0);
- Py_DECREF(mod);
- }
-#endif
-
- PyDict_SetItemString(PyImport_GetModuleDict(), "bge", initBGE());
-
- first_time = false;
-
- PyObjectPlus::ClearDeprecationWarning();
-
- return PyC_DefaultNameSpace(NULL);
-}
-
-void exitGamePlayerPythonScripting()
-{
- /* Clean up the Python mouse and keyboard */
- delete gp_PythonKeyboard;
- gp_PythonKeyboard = NULL;
-
- delete gp_PythonMouse;
- gp_PythonMouse = NULL;
-
- for (int i=0; i<JOYINDEX_MAX; ++i) {
- if (gp_PythonJoysticks[i]) {
- delete gp_PythonJoysticks[i];
- gp_PythonJoysticks[i] = NULL;
- }
- }
-
- /* since python restarts we cant let the python backup of the sys.path hang around in a global pointer */
- restorePySysObjects(); /* get back the original sys.path and clear the backup */
-
- Py_Finalize();
- bpy_import_main_set(NULL);
- PyObjectPlus::ClearDeprecationWarning();
-}
-
-
-
-/**
- * Python is already initialized.
- */
-PyObject *initGamePythonScripting(Main *maggie)
-{
- /* no need to Py_SetProgramName, it was already taken care of in BPY_python_start */
-
- bpy_import_main_set(maggie);
-
- initPySysObjects(maggie);
-
-#ifdef WITH_AUDASPACE
- /* accessing a SoundActuator's sound results in a crash if aud is not initialized... */
- {
- PyObject *mod= PyImport_ImportModuleLevel("aud", NULL, NULL, NULL, 0);
- Py_DECREF(mod);
- }
-#endif
-
- PyDict_SetItemString(PyImport_GetModuleDict(), "bge", initBGE());
-
- PyObjectPlus::NullDeprecationWarning();
-
- return PyC_DefaultNameSpace(NULL);
-}
-
-void exitGamePythonScripting()
-{
- /* Clean up the Python mouse and keyboard */
- delete gp_PythonKeyboard;
- gp_PythonKeyboard = NULL;
-
- delete gp_PythonMouse;
- gp_PythonMouse = NULL;
-
- for (int i=0; i<JOYINDEX_MAX; ++i) {
- if (gp_PythonJoysticks[i]) {
- delete gp_PythonJoysticks[i];
- gp_PythonJoysticks[i] = NULL;
- }
- }
-
- restorePySysObjects(); /* get back the original sys.path and clear the backup */
- bpy_import_main_set(NULL);
- PyObjectPlus::ClearDeprecationWarning();
-}
-
-/* similar to the above functions except it sets up the namespace
- * and other more general things */
-void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene *startscene, Main *blenderdata,
- PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv)
-{
- PyObject *modules, *dictionaryobject;
-
- gp_Canvas = ketsjiengine->GetCanvas();
- gp_Rasterizer = ketsjiengine->GetRasterizer();
- gp_KetsjiEngine = ketsjiengine;
- gp_KetsjiScene = startscene;
-
- if (argv) /* player only */
- dictionaryobject= initGamePlayerPythonScripting(blenderdata, argc, argv);
- else
- dictionaryobject= initGamePythonScripting(blenderdata);
-
- ketsjiengine->SetPyNamespace(dictionaryobject);
-
- modules = PyImport_GetModuleDict();
-
- *gameLogic = PyDict_GetItemString(modules, "GameLogic");
- /* is set in initGameLogicPythonBinding so only set here if we want it to persist between scenes */
- if (pyGlobalDict)
- PyDict_SetItemString(PyModule_GetDict(*gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
-
- *gameLogic_keys = PyDict_Keys(PyModule_GetDict(*gameLogic));
-}
-
-static struct PyModuleDef Rasterizer_module_def = {
- PyModuleDef_HEAD_INIT,
- "Rasterizer", /* m_name */
- Rasterizer_module_documentation, /* m_doc */
- 0, /* m_size */
- rasterizer_methods, /* m_methods */
- 0, /* m_reload */
- 0, /* m_traverse */
- 0, /* m_clear */
- 0, /* m_free */
-};
-
-PyMODINIT_FUNC initRasterizerPythonBinding()
-{
- PyObject *m;
- PyObject *d;
-
- PyType_Ready(&PyRASOffScreen_Type);
-
- m = PyModule_Create(&Rasterizer_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), Rasterizer_module_def.m_name, m);
-
-
- // Add some symbolic constants to the module
- d = PyModule_GetDict(m);
- ErrorObject = PyUnicode_FromString("Rasterizer.error");
- PyDict_SetItemString(d, "error", ErrorObject);
- Py_DECREF(ErrorObject);
-
- /* needed for get/setMaterialType */
- KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL);
- KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL);
-
- KX_MACRO_addTypesToDict(d, RAS_MIPMAP_NONE, RAS_IRasterizer::RAS_MIPMAP_NONE);
- KX_MACRO_addTypesToDict(d, RAS_MIPMAP_NEAREST, RAS_IRasterizer::RAS_MIPMAP_NEAREST);
- KX_MACRO_addTypesToDict(d, RAS_MIPMAP_LINEAR, RAS_IRasterizer::RAS_MIPMAP_LINEAR);
-
- /* for get/setVsync */
- KX_MACRO_addTypesToDict(d, VSYNC_OFF, VSYNC_OFF);
- KX_MACRO_addTypesToDict(d, VSYNC_ON, VSYNC_ON);
- KX_MACRO_addTypesToDict(d, VSYNC_ADAPTIVE, VSYNC_ADAPTIVE);
-
- /* stereoscopy */
- KX_MACRO_addTypesToDict(d, LEFT_EYE, RAS_IRasterizer::RAS_STEREO_LEFTEYE);
- KX_MACRO_addTypesToDict(d, RIGHT_EYE, RAS_IRasterizer::RAS_STEREO_RIGHTEYE);
-
- /* offscreen render */
- KX_MACRO_addTypesToDict(d, RAS_OFS_RENDER_BUFFER, RAS_IOffScreen::RAS_OFS_RENDER_BUFFER);
- KX_MACRO_addTypesToDict(d, RAS_OFS_RENDER_TEXTURE, RAS_IOffScreen::RAS_OFS_RENDER_TEXTURE);
-
-
- // XXXX Add constants here
-
- // Check for errors
- if (PyErr_Occurred())
- {
- Py_FatalError("can't initialize module Rasterizer");
- }
-
- return m;
-}
-
-
-
-/* ------------------------------------------------------------------------- */
-/* GameKeys: symbolic constants for key mapping */
-/* ------------------------------------------------------------------------- */
-
-PyDoc_STRVAR(GameKeys_module_documentation,
-"This modules provides defines for key-codes"
-);
-
-PyDoc_STRVAR(gPyEventToString_doc,
-"EventToString(event)\n"
-"Take a valid event from the GameKeys module or Keyboard Sensor and return a name"
-);
-
-static PyObject *gPyEventToString(PyObject *, PyObject *value)
-{
- PyObject *mod, *dict, *key, *val, *ret = NULL;
- Py_ssize_t pos = 0;
-
- mod = PyImport_ImportModule( "GameKeys" );
- if (!mod)
- return NULL;
-
- dict = PyModule_GetDict(mod);
-
- while (PyDict_Next(dict, &pos, &key, &val)) {
- if (PyObject_RichCompareBool(value, val, Py_EQ)) {
- ret = key;
- break;
- }
- }
-
- PyErr_Clear(); // in case there was an error clearing
- Py_DECREF(mod);
- if (!ret) PyErr_SetString(PyExc_ValueError, "GameKeys.EventToString(int): expected a valid int keyboard event");
- else Py_INCREF(ret);
-
- return ret;
-}
-
-
-PyDoc_STRVAR(gPyEventToCharacter_doc,
-"EventToCharacter(event, is_shift)\n"
-"Take a valid event from the GameKeys module or Keyboard Sensor and return a character"
-);
-
-static PyObject *gPyEventToCharacter(PyObject *, PyObject *args)
-{
- int event, shift;
- if (!PyArg_ParseTuple(args,"ii:EventToCharacter", &event, &shift))
- return NULL;
-
- if (IsPrintable(event)) {
- char ch[2] = {'\0', '\0'};
- ch[0] = ToCharacter(event, (bool)shift);
- return PyUnicode_FromString(ch);
- }
- else {
- return PyUnicode_FromString("");
- }
-}
-
-
-static struct PyMethodDef gamekeys_methods[] = {
- {"EventToCharacter", (PyCFunction)gPyEventToCharacter, METH_VARARGS, (const char *)gPyEventToCharacter_doc},
- {"EventToString", (PyCFunction)gPyEventToString, METH_O, (const char *)gPyEventToString_doc},
- { NULL, (PyCFunction) NULL, 0, NULL }
-};
-
-static struct PyModuleDef GameKeys_module_def = {
- PyModuleDef_HEAD_INIT,
- "GameKeys", /* m_name */
- GameKeys_module_documentation, /* m_doc */
- 0, /* m_size */
- gamekeys_methods, /* m_methods */
- 0, /* m_reload */
- 0, /* m_traverse */
- 0, /* m_clear */
- 0, /* m_free */
-};
-
-PyMODINIT_FUNC initGameKeysPythonBinding()
-{
- PyObject *m;
- PyObject *d;
-
- m = PyModule_Create(&GameKeys_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), GameKeys_module_def.m_name, m);
-
- // Add some symbolic constants to the module
- d = PyModule_GetDict(m);
-
- // XXXX Add constants here
-
- KX_MACRO_addTypesToDict(d, AKEY, SCA_IInputDevice::KX_AKEY);
- KX_MACRO_addTypesToDict(d, BKEY, SCA_IInputDevice::KX_BKEY);
- KX_MACRO_addTypesToDict(d, CKEY, SCA_IInputDevice::KX_CKEY);
- KX_MACRO_addTypesToDict(d, DKEY, SCA_IInputDevice::KX_DKEY);
- KX_MACRO_addTypesToDict(d, EKEY, SCA_IInputDevice::KX_EKEY);
- KX_MACRO_addTypesToDict(d, FKEY, SCA_IInputDevice::KX_FKEY);
- KX_MACRO_addTypesToDict(d, GKEY, SCA_IInputDevice::KX_GKEY);
- KX_MACRO_addTypesToDict(d, HKEY, SCA_IInputDevice::KX_HKEY);
- KX_MACRO_addTypesToDict(d, IKEY, SCA_IInputDevice::KX_IKEY);
- KX_MACRO_addTypesToDict(d, JKEY, SCA_IInputDevice::KX_JKEY);
- KX_MACRO_addTypesToDict(d, KKEY, SCA_IInputDevice::KX_KKEY);
- KX_MACRO_addTypesToDict(d, LKEY, SCA_IInputDevice::KX_LKEY);
- KX_MACRO_addTypesToDict(d, MKEY, SCA_IInputDevice::KX_MKEY);
- KX_MACRO_addTypesToDict(d, NKEY, SCA_IInputDevice::KX_NKEY);
- KX_MACRO_addTypesToDict(d, OKEY, SCA_IInputDevice::KX_OKEY);
- KX_MACRO_addTypesToDict(d, PKEY, SCA_IInputDevice::KX_PKEY);
- KX_MACRO_addTypesToDict(d, QKEY, SCA_IInputDevice::KX_QKEY);
- KX_MACRO_addTypesToDict(d, RKEY, SCA_IInputDevice::KX_RKEY);
- KX_MACRO_addTypesToDict(d, SKEY, SCA_IInputDevice::KX_SKEY);
- KX_MACRO_addTypesToDict(d, TKEY, SCA_IInputDevice::KX_TKEY);
- KX_MACRO_addTypesToDict(d, UKEY, SCA_IInputDevice::KX_UKEY);
- KX_MACRO_addTypesToDict(d, VKEY, SCA_IInputDevice::KX_VKEY);
- KX_MACRO_addTypesToDict(d, WKEY, SCA_IInputDevice::KX_WKEY);
- KX_MACRO_addTypesToDict(d, XKEY, SCA_IInputDevice::KX_XKEY);
- KX_MACRO_addTypesToDict(d, YKEY, SCA_IInputDevice::KX_YKEY);
- KX_MACRO_addTypesToDict(d, ZKEY, SCA_IInputDevice::KX_ZKEY);
-
- KX_MACRO_addTypesToDict(d, ZEROKEY, SCA_IInputDevice::KX_ZEROKEY);
- KX_MACRO_addTypesToDict(d, ONEKEY, SCA_IInputDevice::KX_ONEKEY);
- KX_MACRO_addTypesToDict(d, TWOKEY, SCA_IInputDevice::KX_TWOKEY);
- KX_MACRO_addTypesToDict(d, THREEKEY, SCA_IInputDevice::KX_THREEKEY);
- KX_MACRO_addTypesToDict(d, FOURKEY, SCA_IInputDevice::KX_FOURKEY);
- KX_MACRO_addTypesToDict(d, FIVEKEY, SCA_IInputDevice::KX_FIVEKEY);
- KX_MACRO_addTypesToDict(d, SIXKEY, SCA_IInputDevice::KX_SIXKEY);
- KX_MACRO_addTypesToDict(d, SEVENKEY, SCA_IInputDevice::KX_SEVENKEY);
- KX_MACRO_addTypesToDict(d, EIGHTKEY, SCA_IInputDevice::KX_EIGHTKEY);
- KX_MACRO_addTypesToDict(d, NINEKEY, SCA_IInputDevice::KX_NINEKEY);
-
- KX_MACRO_addTypesToDict(d, CAPSLOCKKEY, SCA_IInputDevice::KX_CAPSLOCKKEY);
-
- KX_MACRO_addTypesToDict(d, LEFTCTRLKEY, SCA_IInputDevice::KX_LEFTCTRLKEY);
- KX_MACRO_addTypesToDict(d, LEFTALTKEY, SCA_IInputDevice::KX_LEFTALTKEY);
- KX_MACRO_addTypesToDict(d, RIGHTALTKEY, SCA_IInputDevice::KX_RIGHTALTKEY);
- KX_MACRO_addTypesToDict(d, RIGHTCTRLKEY, SCA_IInputDevice::KX_RIGHTCTRLKEY);
- KX_MACRO_addTypesToDict(d, RIGHTSHIFTKEY, SCA_IInputDevice::KX_RIGHTSHIFTKEY);
- KX_MACRO_addTypesToDict(d, LEFTSHIFTKEY, SCA_IInputDevice::KX_LEFTSHIFTKEY);
-
- KX_MACRO_addTypesToDict(d, ESCKEY, SCA_IInputDevice::KX_ESCKEY);
- KX_MACRO_addTypesToDict(d, TABKEY, SCA_IInputDevice::KX_TABKEY);
- KX_MACRO_addTypesToDict(d, RETKEY, SCA_IInputDevice::KX_RETKEY);
- KX_MACRO_addTypesToDict(d, ENTERKEY, SCA_IInputDevice::KX_RETKEY);
- KX_MACRO_addTypesToDict(d, SPACEKEY, SCA_IInputDevice::KX_SPACEKEY);
- KX_MACRO_addTypesToDict(d, LINEFEEDKEY, SCA_IInputDevice::KX_LINEFEEDKEY);
- KX_MACRO_addTypesToDict(d, BACKSPACEKEY, SCA_IInputDevice::KX_BACKSPACEKEY);
- KX_MACRO_addTypesToDict(d, DELKEY, SCA_IInputDevice::KX_DELKEY);
- KX_MACRO_addTypesToDict(d, SEMICOLONKEY, SCA_IInputDevice::KX_SEMICOLONKEY);
- KX_MACRO_addTypesToDict(d, PERIODKEY, SCA_IInputDevice::KX_PERIODKEY);
- KX_MACRO_addTypesToDict(d, COMMAKEY, SCA_IInputDevice::KX_COMMAKEY);
- KX_MACRO_addTypesToDict(d, QUOTEKEY, SCA_IInputDevice::KX_QUOTEKEY);
- KX_MACRO_addTypesToDict(d, ACCENTGRAVEKEY, SCA_IInputDevice::KX_ACCENTGRAVEKEY);
- KX_MACRO_addTypesToDict(d, MINUSKEY, SCA_IInputDevice::KX_MINUSKEY);
- KX_MACRO_addTypesToDict(d, SLASHKEY, SCA_IInputDevice::KX_SLASHKEY);
- KX_MACRO_addTypesToDict(d, BACKSLASHKEY, SCA_IInputDevice::KX_BACKSLASHKEY);
- KX_MACRO_addTypesToDict(d, EQUALKEY, SCA_IInputDevice::KX_EQUALKEY);
- KX_MACRO_addTypesToDict(d, LEFTBRACKETKEY, SCA_IInputDevice::KX_LEFTBRACKETKEY);
- KX_MACRO_addTypesToDict(d, RIGHTBRACKETKEY, SCA_IInputDevice::KX_RIGHTBRACKETKEY);
-
- KX_MACRO_addTypesToDict(d, LEFTARROWKEY, SCA_IInputDevice::KX_LEFTARROWKEY);
- KX_MACRO_addTypesToDict(d, DOWNARROWKEY, SCA_IInputDevice::KX_DOWNARROWKEY);
- KX_MACRO_addTypesToDict(d, RIGHTARROWKEY, SCA_IInputDevice::KX_RIGHTARROWKEY);
- KX_MACRO_addTypesToDict(d, UPARROWKEY, SCA_IInputDevice::KX_UPARROWKEY);
-
- KX_MACRO_addTypesToDict(d, PAD2 , SCA_IInputDevice::KX_PAD2);
- KX_MACRO_addTypesToDict(d, PAD4 , SCA_IInputDevice::KX_PAD4);
- KX_MACRO_addTypesToDict(d, PAD6 , SCA_IInputDevice::KX_PAD6);
- KX_MACRO_addTypesToDict(d, PAD8 , SCA_IInputDevice::KX_PAD8);
-
- KX_MACRO_addTypesToDict(d, PAD1 , SCA_IInputDevice::KX_PAD1);
- KX_MACRO_addTypesToDict(d, PAD3 , SCA_IInputDevice::KX_PAD3);
- KX_MACRO_addTypesToDict(d, PAD5 , SCA_IInputDevice::KX_PAD5);
- KX_MACRO_addTypesToDict(d, PAD7 , SCA_IInputDevice::KX_PAD7);
- KX_MACRO_addTypesToDict(d, PAD9 , SCA_IInputDevice::KX_PAD9);
-
- KX_MACRO_addTypesToDict(d, PADPERIOD, SCA_IInputDevice::KX_PADPERIOD);
- KX_MACRO_addTypesToDict(d, PADSLASHKEY, SCA_IInputDevice::KX_PADSLASHKEY);
- KX_MACRO_addTypesToDict(d, PADASTERKEY, SCA_IInputDevice::KX_PADASTERKEY);
-
-
- KX_MACRO_addTypesToDict(d, PAD0, SCA_IInputDevice::KX_PAD0);
- KX_MACRO_addTypesToDict(d, PADMINUS, SCA_IInputDevice::KX_PADMINUS);
- KX_MACRO_addTypesToDict(d, PADENTER, SCA_IInputDevice::KX_PADENTER);
- KX_MACRO_addTypesToDict(d, PADPLUSKEY, SCA_IInputDevice::KX_PADPLUSKEY);
-
-
- KX_MACRO_addTypesToDict(d, F1KEY, SCA_IInputDevice::KX_F1KEY);
- KX_MACRO_addTypesToDict(d, F2KEY, SCA_IInputDevice::KX_F2KEY);
- KX_MACRO_addTypesToDict(d, F3KEY, SCA_IInputDevice::KX_F3KEY);
- KX_MACRO_addTypesToDict(d, F4KEY, SCA_IInputDevice::KX_F4KEY);
- KX_MACRO_addTypesToDict(d, F5KEY, SCA_IInputDevice::KX_F5KEY);
- KX_MACRO_addTypesToDict(d, F6KEY, SCA_IInputDevice::KX_F6KEY);
- KX_MACRO_addTypesToDict(d, F7KEY, SCA_IInputDevice::KX_F7KEY);
- KX_MACRO_addTypesToDict(d, F8KEY, SCA_IInputDevice::KX_F8KEY);
- KX_MACRO_addTypesToDict(d, F9KEY, SCA_IInputDevice::KX_F9KEY);
- KX_MACRO_addTypesToDict(d, F10KEY, SCA_IInputDevice::KX_F10KEY);
- KX_MACRO_addTypesToDict(d, F11KEY, SCA_IInputDevice::KX_F11KEY);
- KX_MACRO_addTypesToDict(d, F12KEY, SCA_IInputDevice::KX_F12KEY);
- KX_MACRO_addTypesToDict(d, F13KEY, SCA_IInputDevice::KX_F13KEY);
- KX_MACRO_addTypesToDict(d, F14KEY, SCA_IInputDevice::KX_F14KEY);
- KX_MACRO_addTypesToDict(d, F15KEY, SCA_IInputDevice::KX_F15KEY);
- KX_MACRO_addTypesToDict(d, F16KEY, SCA_IInputDevice::KX_F16KEY);
- KX_MACRO_addTypesToDict(d, F17KEY, SCA_IInputDevice::KX_F17KEY);
- KX_MACRO_addTypesToDict(d, F18KEY, SCA_IInputDevice::KX_F18KEY);
- KX_MACRO_addTypesToDict(d, F19KEY, SCA_IInputDevice::KX_F19KEY);
-
- KX_MACRO_addTypesToDict(d, OSKEY, SCA_IInputDevice::KX_OSKEY);
-
- KX_MACRO_addTypesToDict(d, PAUSEKEY, SCA_IInputDevice::KX_PAUSEKEY);
- KX_MACRO_addTypesToDict(d, INSERTKEY, SCA_IInputDevice::KX_INSERTKEY);
- KX_MACRO_addTypesToDict(d, HOMEKEY, SCA_IInputDevice::KX_HOMEKEY);
- KX_MACRO_addTypesToDict(d, PAGEUPKEY, SCA_IInputDevice::KX_PAGEUPKEY);
- KX_MACRO_addTypesToDict(d, PAGEDOWNKEY, SCA_IInputDevice::KX_PAGEDOWNKEY);
- KX_MACRO_addTypesToDict(d, ENDKEY, SCA_IInputDevice::KX_ENDKEY);
-
- // MOUSE
- KX_MACRO_addTypesToDict(d, LEFTMOUSE, SCA_IInputDevice::KX_LEFTMOUSE);
- KX_MACRO_addTypesToDict(d, MIDDLEMOUSE, SCA_IInputDevice::KX_MIDDLEMOUSE);
- KX_MACRO_addTypesToDict(d, RIGHTMOUSE, SCA_IInputDevice::KX_RIGHTMOUSE);
- KX_MACRO_addTypesToDict(d, WHEELUPMOUSE, SCA_IInputDevice::KX_WHEELUPMOUSE);
- KX_MACRO_addTypesToDict(d, WHEELDOWNMOUSE, SCA_IInputDevice::KX_WHEELDOWNMOUSE);
- KX_MACRO_addTypesToDict(d, MOUSEX, SCA_IInputDevice::KX_MOUSEX);
- KX_MACRO_addTypesToDict(d, MOUSEY, SCA_IInputDevice::KX_MOUSEY);
-
- // Check for errors
- if (PyErr_Occurred())
- {
- Py_FatalError("can't initialize module GameKeys");
- }
-
- return m;
-}
-
-
-
-/* ------------------------------------------------------------------------- */
-/* Application: application values that remain unchanged during runtime */
-/* ------------------------------------------------------------------------- */
-
-PyDoc_STRVAR(Application_module_documentation,
- "This module contains application values that remain unchanged during runtime."
- );
-
-static struct PyModuleDef Application_module_def = {
- PyModuleDef_HEAD_INIT,
- "bge.app", /* m_name */
- Application_module_documentation, /* m_doc */
- 0, /* m_size */
- NULL, /* m_methods */
- 0, /* m_reload */
- 0, /* m_traverse */
- 0, /* m_clear */
- 0, /* m_free */
-};
-
-PyMODINIT_FUNC initApplicationPythonBinding()
-{
- PyObject *m;
- PyObject *d;
-
- m = PyModule_Create(&Application_module_def);
-
- // Add some symbolic constants to the module
- d = PyModule_GetDict(m);
-
- PyDict_SetItemString(d, "version", Py_BuildValue("(iii)",
- BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION));
- PyDict_SetItemString(d, "version_string", PyUnicode_FromFormat("%d.%02d (sub %d)",
- BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION));
- PyDict_SetItemString(d, "version_char", PyUnicode_FromString(
- STRINGIFY(BLENDER_VERSION_CHAR)));
-
- PyDict_SetItemString(d, "has_texture_ffmpeg",
-#ifdef WITH_FFMPEG
- Py_True
-#else
- Py_False
-#endif
- );
- PyDict_SetItemString(d, "has_joystick",
-#ifdef WITH_SDL
- Py_True
-#else
- Py_False
-#endif
- );
- PyDict_SetItemString(d, "has_physics",
-#ifdef WITH_BULLET
- Py_True
-#else
- Py_False
-#endif
- );
-
- // Check for errors
- if (PyErr_Occurred()) {
- PyErr_Print();
- PyErr_Clear();
- }
-
- return m;
-}
-
-
-// utility function for loading and saving the globalDict
-int saveGamePythonConfig( char **marshal_buffer)
-{
- int marshal_length = 0;
- PyObject *gameLogic = PyImport_ImportModule("GameLogic");
- if (gameLogic) {
- PyObject *pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module
- if (pyGlobalDict) {
-#ifdef Py_MARSHAL_VERSION
- PyObject *pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5
-#else
- PyObject *pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict );
-#endif
- if (pyGlobalDictMarshal) {
- // for testing only
- // PyObject_Print(pyGlobalDictMarshal, stderr, 0);
- char *marshal_cstring;
-
- marshal_cstring = PyBytes_AsString(pyGlobalDictMarshal); // py3 uses byte arrays
- marshal_length= PyBytes_Size(pyGlobalDictMarshal);
- *marshal_buffer = new char[marshal_length + 1];
- memcpy(*marshal_buffer, marshal_cstring, marshal_length);
- Py_DECREF(pyGlobalDictMarshal);
- } else {
- printf("Error, bge.logic.globalDict could not be marshal'd\n");
- }
- } else {
- printf("Error, bge.logic.globalDict was removed\n");
- }
- Py_DECREF(gameLogic);
- } else {
- PyErr_Clear();
- printf("Error, bge.logic failed to import bge.logic.globalDict will be lost\n");
- }
- return marshal_length;
-}
-
-int loadGamePythonConfig(char *marshal_buffer, int marshal_length)
-{
- /* Restore the dict */
- if (marshal_buffer) {
- PyObject *gameLogic = PyImport_ImportModule("GameLogic");
-
- if (gameLogic) {
- PyObject *pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length);
- if (pyGlobalDict) {
- PyObject *pyGlobalDict_orig = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module.
- if (pyGlobalDict_orig) {
- PyDict_Clear(pyGlobalDict_orig);
- PyDict_Update(pyGlobalDict_orig, pyGlobalDict);
- } else {
- /* this should not happen, but cant find the original globalDict, just assign it then */
- PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
- }
- Py_DECREF(gameLogic);
- Py_DECREF(pyGlobalDict);
- return 1;
- } else {
- Py_DECREF(gameLogic);
- PyErr_Clear();
- printf("Error could not marshall string\n");
- }
- }
- else {
- PyErr_Clear();
- printf("Error, bge.logic failed to import bge.logic.globalDict will be lost\n");
- }
- }
- return 0;
-}
-
-void pathGamePythonConfig(char *path)
-{
- int len = strlen(gp_GamePythonPathOrig); // Always use the first loaded blend filename
-
- BLI_strncpy(path, gp_GamePythonPathOrig, sizeof(gp_GamePythonPathOrig));
-
- /* replace extension */
- if (BLI_testextensie(path, ".blend")) {
- strcpy(path+(len-6), ".bgeconf");
- } else {
- strcpy(path+len, ".bgeconf");
- }
-}
-
-void setGamePythonPath(const char *path)
-{
- BLI_strncpy(gp_GamePythonPath, path, sizeof(gp_GamePythonPath));
- BLI_cleanup_file(NULL, gp_GamePythonPath); /* not absolutely needed but makes resolving path problems less confusing later */
-
- if (gp_GamePythonPathOrig[0] == '\0')
- BLI_strncpy(gp_GamePythonPathOrig, path, sizeof(gp_GamePythonPathOrig));
-}
-
-// we need this so while blender is open (not blenderplayer)
-// loading new blendfiles will reset this on starting the
-// engine but loading blend files within the BGE wont overwrite gp_GamePythonPathOrig
-void resetGamePythonPath()
-{
- gp_GamePythonPathOrig[0] = '\0';
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h
deleted file mode 100644
index 6550934a916..00000000000
--- a/source/gameengine/Ketsji/KX_PythonInit.h
+++ /dev/null
@@ -1,95 +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_PythonInit.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_PYTHONINIT_H__
-#define __KX_PYTHONINIT_H__
-
-#include "EXP_Python.h"
-#include "STR_String.h"
-#include "MT_Vector3.h"
-
-class KX_KetsjiEngine;
-class KX_Scene;
-
-typedef enum {
- psl_Lowest = 0,
- psl_Highest,
-} TPythonSecurityLevel;
-
-extern bool gUseVisibilityTemp;
-
-#ifdef WITH_PYTHON
-PyMODINIT_FUNC initBGE(void);
-PyMODINIT_FUNC initApplicationPythonBinding(void);
-PyMODINIT_FUNC initGameLogicPythonBinding(void);
-PyMODINIT_FUNC initGameKeysPythonBinding(void);
-PyMODINIT_FUNC initRasterizerPythonBinding(void);
-PyMODINIT_FUNC initVideoTexturePythonBinding(void);
-PyObject *initGamePlayerPythonScripting(struct Main *maggie, int argc, char **argv);
-PyObject *initGamePythonScripting(struct Main *maggie);
-
-void exitGamePlayerPythonScripting();
-void exitGamePythonScripting();
-void setupGamePython(KX_KetsjiEngine *ketsjiengine, KX_Scene *startscene, Main *blenderdata,
- PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char **argv);
-void setGamePythonPath(const char *path);
-void resetGamePythonPath();
-void pathGamePythonConfig(char *path);
-int saveGamePythonConfig(char **marshal_buffer);
-int loadGamePythonConfig(char *marshal_buffer, int marshal_length);
-#endif
-
-void addImportMain(struct Main *maggie);
-void removeImportMain(struct Main *maggie);
-
-class KX_KetsjiEngine;
-class KX_Scene;
-
-void KX_SetActiveScene(KX_Scene *scene);
-KX_Scene *KX_GetActiveScene();
-KX_KetsjiEngine *KX_GetActiveEngine();
-
-typedef int (*PyNextFrameFunc)(void *);
-
-struct PyNextFrameState {
- /** can be either a GPG_NextFrameState or a BL_KetsjiNextFrameState */
- void *state;
- /** can be either GPG_PyNextFrame or BL_KetsjiPyNextFrame */
- PyNextFrameFunc func;
-};
-extern struct PyNextFrameState pynextframestate;
-
-void KX_RasterizerDrawDebugLine(const MT_Vector3 &from,const MT_Vector3 &to,const MT_Vector3 &color);
-void KX_RasterizerDrawDebugCircle(const MT_Vector3 &center, const MT_Scalar radius, const MT_Vector3 &color,
- const MT_Vector3 &normal, int nsector);
-
-
-#endif /* __KX_PYTHONINIT_H__ */
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
deleted file mode 100644
index 4a999e37f2b..00000000000
--- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
+++ /dev/null
@@ -1,286 +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): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_PythonInitTypes.cpp
- * \ingroup ketsji
- */
-
-#ifdef WITH_PYTHON
-
-#include "KX_PythonInitTypes.h"
-
-/* Only for Class::Parents */
-#include "BL_BlenderShader.h"
-#include "BL_ShapeActionActuator.h"
-#include "BL_ArmatureActuator.h"
-#include "BL_ArmatureConstraint.h"
-#include "BL_ArmatureObject.h"
-#include "BL_ArmatureChannel.h"
-#include "KX_WorldInfo.h"
-#include "KX_ArmatureSensor.h"
-#include "KX_BlenderMaterial.h"
-#include "KX_CameraActuator.h"
-#include "KX_CharacterWrapper.h"
-#include "KX_ConstraintActuator.h"
-#include "KX_ConstraintWrapper.h"
-#include "KX_GameActuator.h"
-#include "KX_LibLoadStatus.h"
-#include "KX_Light.h"
-#include "KX_FontObject.h"
-#include "KX_MeshProxy.h"
-#include "KX_MouseFocusSensor.h"
-#include "KX_NetworkMessageActuator.h"
-#include "KX_NetworkMessageSensor.h"
-#include "KX_ObjectActuator.h"
-#include "KX_ParentActuator.h"
-#include "KX_PolyProxy.h"
-#include "KX_SCA_AddObjectActuator.h"
-#include "KX_SCA_EndObjectActuator.h"
-#include "KX_SCA_ReplaceMeshActuator.h"
-#include "KX_SceneActuator.h"
-#include "KX_StateActuator.h"
-#include "KX_SteeringActuator.h"
-#include "KX_TrackToActuator.h"
-#include "KX_VehicleWrapper.h"
-#include "KX_VertexProxy.h"
-#include "SCA_2DFilterActuator.h"
-#include "SCA_ANDController.h"
-#include "SCA_ActuatorSensor.h"
-#include "SCA_AlwaysSensor.h"
-#include "SCA_DelaySensor.h"
-#include "SCA_JoystickSensor.h"
-#include "SCA_KeyboardSensor.h"
-#include "SCA_MouseSensor.h"
-#include "SCA_NANDController.h"
-#include "SCA_NORController.h"
-#include "SCA_ORController.h"
-#include "SCA_RandomSensor.h"
-#include "SCA_XNORController.h"
-#include "SCA_XORController.h"
-#include "SCA_PythonJoystick.h"
-#include "SCA_PythonKeyboard.h"
-#include "SCA_PythonMouse.h"
-#include "KX_NearSensor.h"
-#include "KX_RadarSensor.h"
-#include "KX_RaySensor.h"
-#include "KX_SCA_DynamicActuator.h"
-#include "KX_SoundActuator.h"
-#include "KX_TouchSensor.h"
-#include "KX_VisibilityActuator.h"
-#include "SCA_PropertySensor.h"
-#include "SCA_PythonController.h"
-#include "SCA_RandomActuator.h"
-#include "SCA_IController.h"
-#include "KX_NavMeshObject.h"
-#include "KX_MouseActuator.h"
-#include "EXP_ListWrapper.h"
-
-static void PyType_Attr_Set(PyGetSetDef *attr_getset, PyAttributeDef *attr)
-{
- attr_getset->name= (char *)attr->m_name;
- attr_getset->doc= NULL;
-
- attr_getset->get= reinterpret_cast<getter>(PyObjectPlus::py_get_attrdef);
-
- if (attr->m_access==KX_PYATTRIBUTE_RO)
- attr_getset->set= NULL;
- else
- attr_getset->set= reinterpret_cast<setter>(PyObjectPlus::py_set_attrdef);
-
- attr_getset->closure= reinterpret_cast<void *>(attr);
-}
-
-static void PyType_Ready_ADD(PyObject *dict, PyTypeObject *tp, PyAttributeDef *attributes, PyAttributeDef *attributesPtr, int init_getset)
-{
- PyAttributeDef *attr;
-
- if (init_getset) {
- /* we need to do this for all types before calling PyType_Ready
- * since they will call the parents PyType_Ready and those might not have initialized vars yet */
-
- //if (tp->tp_base==NULL)
- // printf("Debug: No Parents - '%s'\n" , tp->tp_name);
-
- if (tp->tp_getset==NULL && ((attributes && attributes->m_name) || (attributesPtr && attributesPtr->m_name))) {
- PyGetSetDef *attr_getset;
- int attr_tot= 0;
-
- if (attributes) {
- for (attr= attributes; attr->m_name; attr++, attr_tot++)
- attr->m_usePtr = false;
- }
- if (attributesPtr) {
- for (attr= attributesPtr; attr->m_name; attr++, attr_tot++)
- attr->m_usePtr = true;
- }
-
- tp->tp_getset = attr_getset = reinterpret_cast<PyGetSetDef *>(PyMem_Malloc((attr_tot+1) * sizeof(PyGetSetDef))); // XXX - Todo, free
-
- if (attributes) {
- for (attr= attributes; attr->m_name; attr++, attr_getset++) {
- PyType_Attr_Set(attr_getset, attr);
- }
- }
- if (attributesPtr) {
- for (attr= attributesPtr; attr->m_name; attr++, attr_getset++) {
- PyType_Attr_Set(attr_getset, attr);
- }
- }
- memset(attr_getset, 0, sizeof(PyGetSetDef));
- }
- } else {
- PyType_Ready(tp);
- PyDict_SetItemString(dict, tp->tp_name, reinterpret_cast<PyObject *>(tp));
- }
-
-}
-
-
-#define PyType_Ready_Attr(d, n, i) PyType_Ready_ADD(d, &n::Type, n::Attributes, NULL, i)
-#define PyType_Ready_AttrPtr(d, n, i) PyType_Ready_ADD(d, &n::Type, n::Attributes, n::AttributesPtr, i)
-
-
-
-PyDoc_STRVAR(GameTypes_module_documentation,
-"This module provides access to the game engine data types."
-);
-static struct PyModuleDef GameTypes_module_def = {
- PyModuleDef_HEAD_INIT,
- "GameTypes", /* m_name */
- GameTypes_module_documentation, /* m_doc */
- 0, /* m_size */
- NULL, /* m_methods */
- NULL, /* m_reload */
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL, /* m_free */
-};
-
-
-PyMODINIT_FUNC initGameTypesPythonBinding(void)
-{
- PyObject *m;
- PyObject *dict;
-
- m = PyModule_Create(&GameTypes_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), GameTypes_module_def.m_name, m);
-
- dict = PyModule_GetDict(m);
-
- for (int init_getset= 1; init_getset > -1; init_getset--) { /* run twice, once to init the getsets another to run PyType_Ready */
- PyType_Ready_Attr(dict, BL_ActionActuator, init_getset);
- PyType_Ready_Attr(dict, BL_Shader, init_getset);
- PyType_Ready_Attr(dict, BL_ShapeActionActuator, init_getset);
- PyType_Ready_Attr(dict, BL_ArmatureObject, init_getset);
- PyType_Ready_Attr(dict, BL_ArmatureActuator, init_getset);
- PyType_Ready_Attr(dict, BL_ArmatureConstraint, init_getset);
- PyType_Ready_AttrPtr(dict, BL_ArmatureBone, init_getset);
- PyType_Ready_AttrPtr(dict, BL_ArmatureChannel, init_getset);
- // PyType_Ready_Attr(dict, CPropValue, init_getset); // doesn't use Py_Header
- PyType_Ready_Attr(dict, CListValue, init_getset);
- PyType_Ready_Attr(dict, CListWrapper, init_getset);
- PyType_Ready_Attr(dict, CValue, init_getset);
- PyType_Ready_Attr(dict, KX_ArmatureSensor, init_getset);
- PyType_Ready_Attr(dict, KX_BlenderMaterial, init_getset);
- PyType_Ready_Attr(dict, KX_Camera, init_getset);
- PyType_Ready_Attr(dict, KX_CameraActuator, init_getset);
- PyType_Ready_Attr(dict, KX_CharacterWrapper, init_getset);
- PyType_Ready_Attr(dict, KX_ConstraintActuator, init_getset);
- PyType_Ready_Attr(dict, KX_ConstraintWrapper, init_getset);
- PyType_Ready_Attr(dict, KX_GameActuator, init_getset);
- PyType_Ready_Attr(dict, KX_GameObject, init_getset);
- PyType_Ready_Attr(dict, KX_LibLoadStatus, init_getset);
- PyType_Ready_Attr(dict, KX_LightObject, init_getset);
- PyType_Ready_Attr(dict, KX_FontObject, init_getset);
- PyType_Ready_Attr(dict, KX_MeshProxy, init_getset);
- PyType_Ready_Attr(dict, KX_MouseFocusSensor, init_getset);
- PyType_Ready_Attr(dict, KX_NearSensor, init_getset);
- PyType_Ready_Attr(dict, KX_NetworkMessageActuator, init_getset);
- PyType_Ready_Attr(dict, KX_NetworkMessageSensor, init_getset);
- 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_RadarSensor, init_getset);
- PyType_Ready_Attr(dict, KX_RaySensor, init_getset);
- PyType_Ready_Attr(dict, KX_SCA_AddObjectActuator, init_getset);
- PyType_Ready_Attr(dict, KX_SCA_DynamicActuator, init_getset);
- PyType_Ready_Attr(dict, KX_SCA_EndObjectActuator, init_getset);
- PyType_Ready_Attr(dict, KX_SCA_ReplaceMeshActuator, init_getset);
- PyType_Ready_Attr(dict, KX_Scene, init_getset);
- PyType_Ready_Attr(dict, KX_WorldInfo, init_getset);
- PyType_Ready_Attr(dict, KX_NavMeshObject, init_getset);
- PyType_Ready_Attr(dict, KX_SceneActuator, init_getset);
- PyType_Ready_Attr(dict, KX_SoundActuator, init_getset);
- PyType_Ready_Attr(dict, KX_StateActuator, init_getset);
- PyType_Ready_Attr(dict, KX_SteeringActuator, init_getset);
- PyType_Ready_Attr(dict, KX_TouchSensor, init_getset);
- PyType_Ready_Attr(dict, KX_TrackToActuator, init_getset);
- PyType_Ready_Attr(dict, KX_VehicleWrapper, init_getset);
- PyType_Ready_Attr(dict, KX_VertexProxy, init_getset);
- PyType_Ready_Attr(dict, KX_VisibilityActuator, init_getset);
- PyType_Ready_Attr(dict, KX_MouseActuator, init_getset);
- PyType_Ready_Attr(dict, PyObjectPlus, init_getset);
- PyType_Ready_Attr(dict, SCA_2DFilterActuator, init_getset);
- PyType_Ready_Attr(dict, SCA_ANDController, init_getset);
- // PyType_Ready_Attr(dict, SCA_Actuator, init_getset); // doesn't use Py_Header
- PyType_Ready_Attr(dict, SCA_ActuatorSensor, init_getset);
- PyType_Ready_Attr(dict, SCA_AlwaysSensor, init_getset);
- PyType_Ready_Attr(dict, SCA_DelaySensor, init_getset);
- PyType_Ready_Attr(dict, SCA_ILogicBrick, init_getset);
- PyType_Ready_Attr(dict, SCA_IObject, init_getset);
- PyType_Ready_Attr(dict, SCA_ISensor, init_getset);
- PyType_Ready_Attr(dict, SCA_JoystickSensor, init_getset);
- PyType_Ready_Attr(dict, SCA_KeyboardSensor, init_getset);
- PyType_Ready_Attr(dict, SCA_MouseSensor, init_getset);
- PyType_Ready_Attr(dict, SCA_NANDController, init_getset);
- PyType_Ready_Attr(dict, SCA_NORController, init_getset);
- PyType_Ready_Attr(dict, SCA_ORController, init_getset);
- PyType_Ready_Attr(dict, SCA_PropertyActuator, init_getset);
- PyType_Ready_Attr(dict, SCA_PropertySensor, init_getset);
- PyType_Ready_Attr(dict, SCA_PythonController, init_getset);
- PyType_Ready_Attr(dict, SCA_RandomActuator, init_getset);
- PyType_Ready_Attr(dict, SCA_RandomSensor, init_getset);
- PyType_Ready_Attr(dict, SCA_XNORController, init_getset);
- PyType_Ready_Attr(dict, SCA_XORController, init_getset);
- PyType_Ready_Attr(dict, SCA_IController, init_getset);
- PyType_Ready_Attr(dict, SCA_PythonJoystick, init_getset);
- PyType_Ready_Attr(dict, SCA_PythonKeyboard, init_getset);
- PyType_Ready_Attr(dict, SCA_PythonMouse, init_getset);
- }
-
-#ifdef USE_MATHUTILS
- /* Init mathutils callbacks */
- KX_GameObject_Mathutils_Callback_Init();
- KX_ObjectActuator_Mathutils_Callback_Init();
- KX_WorldInfo_Mathutils_Callback_Init();
- KX_BlenderMaterial_Mathutils_Callback_Init();
-#endif
-
- return m;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.h b/source/gameengine/Ketsji/KX_PythonInitTypes.h
deleted file mode 100644
index cfc49a1dc93..00000000000
--- a/source/gameengine/Ketsji/KX_PythonInitTypes.h
+++ /dev/null
@@ -1,40 +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): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_PythonInitTypes.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_PYTHON_INIT_TYPES__
-#define __KX_PYTHON_INIT_TYPES__
-
-#ifdef WITH_PYTHON
-#include <Python.h>
-PyMODINIT_FUNC initGameTypesPythonBinding(void);
-#endif
-
-#endif /* __KX_PYTHON_INIT_TYPES__ */
diff --git a/source/gameengine/Ketsji/KX_PythonMain.cpp b/source/gameengine/Ketsji/KX_PythonMain.cpp
deleted file mode 100644
index 740bb102fd9..00000000000
--- a/source/gameengine/Ketsji/KX_PythonMain.cpp
+++ /dev/null
@@ -1,71 +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.
- *
- * Contributor(s): Benoit Bolsee
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Ketsji/KX_PythonMain.cpp
- * \ingroup ketsji
- */
-
-#include "KX_PythonMain.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stddef.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_string.h"
-#include "BLI_listbase.h"
-
-#include "BKE_text.h"
-#include "BKE_main.h"
-#include "BKE_idprop.h"
-
-
-#ifdef __cplusplus
-}
-#endif
-
-extern "C" char *KX_GetPythonMain(struct Scene *scene)
-{
- /* examine custom scene properties */
- if (scene->id.properties) {
- IDProperty *item = IDP_GetPropertyTypeFromGroup(scene->id.properties, "__main__", IDP_STRING);
- if (item) {
- return BLI_strdup(IDP_String(item));
- }
- }
-
- return NULL;
-}
-
-extern "C" char *KX_GetPythonCode(Main *bmain, char *python_main)
-{
- Text *text;
-
- if ((text = (Text *)BLI_findstring(&bmain->text, python_main, offsetof(ID, name) + 2))) {
- return txt_to_buf(text);
- }
-
- return NULL;
-}
diff --git a/source/gameengine/Ketsji/KX_PythonMain.h b/source/gameengine/Ketsji/KX_PythonMain.h
deleted file mode 100644
index c627a4a147a..00000000000
--- a/source/gameengine/Ketsji/KX_PythonMain.h
+++ /dev/null
@@ -1,41 +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_PythonMain.h
- * \ingroup ketsji
- */
-
-#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);
-extern "C" char *KX_GetPythonCode(struct Main *main, char *python_main);
-
-#endif /* __KX_PYTHON_MAIN__ */
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp
deleted file mode 100644
index 861e3f70296..00000000000
--- a/source/gameengine/Ketsji/KX_RadarSensor.cpp
+++ /dev/null
@@ -1,230 +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_RadarSensor.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_RadarSensor.h"
-#include "KX_GameObject.h"
-#include "KX_PyMath.h"
-#include "PHY_IPhysicsController.h"
-#include "PHY_IMotionState.h"
-#include "DNA_sensor_types.h"
-
-/**
- * RadarSensor constructor. Creates a near-sensor derived class, with a cone collision shape.
- */
-KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr,
- KX_GameObject* gameobj,
- PHY_IPhysicsController* physCtrl,
- double coneradius,
- double coneheight,
- int axis,
- double margin,
- double resetmargin,
- bool bFindMaterial,
- const STR_String& touchedpropname)
-
- : KX_NearSensor(
- eventmgr,
- gameobj,
- //DT_NewCone(coneradius,coneheight),
- margin,
- resetmargin,
- bFindMaterial,
- touchedpropname,
- physCtrl),
-
- m_coneradius(coneradius),
- m_coneheight(coneheight),
- m_axis(axis)
-{
- m_client_info->m_type = KX_ClientObjectInfo::SENSOR;
- //m_client_info->m_clientobject = gameobj;
- //m_client_info->m_auxilary_info = NULL;
- //sumoObj->setClientObject(&m_client_info);
-}
-
-KX_RadarSensor::~KX_RadarSensor()
-{
-
-}
-
-CValue* KX_RadarSensor::GetReplica()
-{
- KX_RadarSensor* replica = new KX_RadarSensor(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-/**
- * Transforms the collision object. A cone is not correctly centered
- * for usage. */
-void KX_RadarSensor::SynchronizeTransform()
-{
- // Getting the parent location was commented out. Why?
- MT_Transform trans;
- trans.setOrigin(((KX_GameObject*)GetParent())->NodeGetWorldPosition());
- trans.setBasis(((KX_GameObject*)GetParent())->NodeGetWorldOrientation());
- // What is the default orientation? pointing in the -y direction?
- // is the geometry correctly converted?
-
- // a collision cone is oriented
- // center the cone correctly
- // depends on the radar 'axis'
- switch (m_axis)
- {
- case SENS_RADAR_X_AXIS: // +X Axis
- {
- MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
- trans.rotate(rotquatje);
- trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0));
- break;
- };
- case SENS_RADAR_Y_AXIS: // +Y Axis
- {
- MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180));
- trans.rotate(rotquatje);
- trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0));
- break;
- };
- case SENS_RADAR_Z_AXIS: // +Z Axis
- {
- MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90));
- trans.rotate(rotquatje);
- trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0));
- break;
- };
- case SENS_RADAR_NEG_X_AXIS: // -X Axis
- {
- MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90));
- trans.rotate(rotquatje);
- trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0));
- break;
- };
- case SENS_RADAR_NEG_Y_AXIS: // -Y Axis
- {
- //MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180));
- //trans.rotate(rotquatje);
- trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0));
- break;
- };
- case SENS_RADAR_NEG_Z_AXIS: // -Z Axis
- {
- MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90));
- trans.rotate(rotquatje);
- trans.translate(MT_Vector3 (0, -m_coneheight/2.0f, 0));
- break;
- };
- default:
- {
- }
- }
-
- //Using a temp variable to translate MT_Point3 to float[3].
- //float[3] works better for the Python interface.
- MT_Point3 temp = trans.getOrigin();
- m_cone_origin[0] = temp[0];
- m_cone_origin[1] = temp[1];
- m_cone_origin[2] = temp[2];
-
- temp = trans(MT_Point3(0, -m_coneheight/2.0f, 0));
- m_cone_target[0] = temp[0];
- m_cone_target[1] = temp[1];
- m_cone_target[2] = temp[2];
-
-
- if (m_physCtrl)
- {
- PHY_IMotionState* motionState = m_physCtrl->GetMotionState();
- const MT_Point3& pos = trans.getOrigin();
- float ori[12];
- trans.getBasis().getValue(ori);
- motionState->SetWorldPosition(pos[0], pos[1], pos[2]);
- motionState->SetWorldOrientation(ori);
- m_physCtrl->WriteMotionStateToDynamics(true);
- }
-
-}
-
-/* ------------------------------------------------------------------------- */
-/* Python Functions */
-/* ------------------------------------------------------------------------- */
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python Integration Hooks */
-/* ------------------------------------------------------------------------- */
-PyTypeObject KX_RadarSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_RadarSensor",
- 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,
- &KX_NearSensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_RadarSensor::Methods[] = {
- {NULL} //Sentinel
-};
-
-PyAttributeDef KX_RadarSensor::Attributes[] = {
- KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneOrigin", KX_RadarSensor, m_cone_origin, 3),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneTarget", KX_RadarSensor, m_cone_target, 3),
- KX_PYATTRIBUTE_FLOAT_RO("distance", KX_RadarSensor, m_coneheight),
- KX_PYATTRIBUTE_RO_FUNCTION("angle", KX_RadarSensor, pyattr_get_angle),
- KX_PYATTRIBUTE_INT_RW("axis", 0, 5, true, KX_RadarSensor, m_axis),
- {NULL} //Sentinel
-};
-
-PyObject *KX_RadarSensor::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_RadarSensor* self = static_cast<KX_RadarSensor*>(self_v);
-
- // The original angle from the gui was converted, so we recalculate the value here to maintain
- // consistency between Python and the gui
- return PyFloat_FromDouble(MT_degrees(atan(self->m_coneradius / self->m_coneheight)) * 2);
-
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h
deleted file mode 100644
index 6a2d50ffa3a..00000000000
--- a/source/gameengine/Ketsji/KX_RadarSensor.h
+++ /dev/null
@@ -1,100 +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_RadarSensor.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_RADARSENSOR_H__
-#define __KX_RADARSENSOR_H__
-
-#include "KX_NearSensor.h"
-#include "MT_Point3.h"
-
-/**
- * Radar 'cone' sensor. Very similar to a near-sensor, but instead of a sphere, a cone is used.
- */
-class KX_RadarSensor : public KX_NearSensor
-{
- protected:
- Py_Header
-
- float m_coneradius;
-
- /**
- * Height of the cone.
- */
- float m_coneheight;
- int m_axis;
-
- /**
- * The previous position of the origin of the cone.
- */
- float m_cone_origin[3];
-
- /**
- * The previous direction of the cone (origin to bottom plane).
- */
- float m_cone_target[3];
-
-public:
-
- KX_RadarSensor(SCA_EventManager* eventmgr,
- KX_GameObject* gameobj,
- PHY_IPhysicsController* physCtrl,
- double coneradius,
- double coneheight,
- int axis,
- double margin,
- double resetmargin,
- bool bFindMaterial,
- const STR_String& touchedpropname);
- KX_RadarSensor();
- virtual ~KX_RadarSensor();
- virtual void SynchronizeTransform();
- virtual CValue* GetReplica();
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
- enum RadarAxis {
- KX_RADAR_AXIS_POS_X = 0,
- KX_RADAR_AXIS_POS_Y,
- KX_RADAR_AXIS_POS_Z,
- KX_RADAR_AXIS_NEG_X,
- KX_RADAR_AXIS_NEG_Y,
- KX_RADAR_AXIS_NEG_Z
- };
-
- virtual sensortype GetSensorType() { return ST_RADAR; }
- /* python */
-#ifdef WITH_PYTHON
- static PyObject* pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-#endif
-};
-
-#endif /* __KX_RADARSENSOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp
deleted file mode 100644
index 478019c6304..00000000000
--- a/source/gameengine/Ketsji/KX_RayCast.cpp
+++ /dev/null
@@ -1,121 +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 *****
- * KX_MouseFocusSensor determines mouse in/out/over events.
- */
-
-/** \file gameengine/Ketsji/KX_RayCast.cpp
- * \ingroup ketsji
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "KX_RayCast.h"
-
-#include "MT_Point3.h"
-#include "MT_Vector3.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_IPhysicsController.h"
-
-KX_RayCast::KX_RayCast(PHY_IPhysicsController* ignoreController, bool faceNormal, bool faceUV)
- :PHY_IRayCastFilterCallback(ignoreController, faceNormal, faceUV)
-{
-}
-
-void KX_RayCast::reportHit(PHY_RayCastResult* result)
-{
- m_hitFound = true;
- m_hitPoint = MT_Vector3(result->m_hitPoint);
- m_hitNormal = MT_Vector3(result->m_hitNormal);
- m_hitUVOK = result->m_hitUVOK;
- m_hitUV = MT_Vector2(result->m_hitUV);
- m_hitMesh = result->m_meshObject;
- m_hitPolygon = result->m_polygon;
-}
-
-bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_Point3& _frompoint, const MT_Point3& topoint, KX_RayCast& callback)
-{
- if (physics_environment==NULL) return false; /* prevents crashing in some cases */
-
- // Loops over all physics objects between frompoint and topoint,
- // calling callback.RayHit for each one.
- //
- // callback.RayHit should return true to stop looking, or false to continue.
- //
- // returns true if an object was found, false if not.
-
- MT_Point3 frompoint(_frompoint);
- const MT_Vector3 todir( (topoint - frompoint).safe_normalized() );
- MT_Point3 prevpoint(_frompoint+todir*(-1.f));
-
- PHY_IPhysicsController* hit_controller;
-
- 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());
-
- if (!info)
- {
- printf("no info!\n");
- MT_assert(info && "Physics controller with no client object info");
- break;
- }
-
- // The biggest danger to endless loop, prevent this by checking that the
- // hit point always progresses along the ray direction..
- prevpoint -= callback.m_hitPoint;
- if (prevpoint.length2() < MT_EPSILON)
- break;
-
- if (callback.RayHit(info))
- // caller may decide to stop the loop and still cancel the hit
- return callback.m_hitFound;
-
- // Skip past the object and keep tracing.
- // Note that retrieving in a single shot multiple hit points would be possible
- // but it would require some change in Bullet.
- prevpoint = callback.m_hitPoint;
- /* We add 0.001 of fudge, so that if the margin && radius == 0.0, we don't endless loop. */
- MT_Scalar marg = 0.001f + hit_controller->GetMargin();
- marg *= 2.f;
- /* Calculate the other side of this object */
- MT_Scalar h = MT_abs(todir.dot(callback.m_hitNormal));
- if (h <= 0.01f)
- // the normal is almost orthogonal to the ray direction, cannot compute the other side
- break;
- marg /= h;
- frompoint = callback.m_hitPoint + marg * todir;
- // verify that we are not passed the to point
- if ((topoint - frompoint).dot(todir) < 0.f)
- break;
- }
- return false;
-}
-
diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h
deleted file mode 100644
index c977fb8f385..00000000000
--- a/source/gameengine/Ketsji/KX_RayCast.h
+++ /dev/null
@@ -1,149 +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_RayCast.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_RAYCAST_H__
-#define __KX_RAYCAST_H__
-
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_IPhysicsController.h"
-#include "MT_Vector2.h"
-#include "MT_Point3.h"
-#include "MT_Vector3.h"
-
-class RAS_MeshObject;
-struct KX_ClientObjectInfo;
-
-/**
- * Defines a function for doing a ray cast.
- *
- * eg KX_RayCast::RayTest(ignore_physics_controller, physics_environment, frompoint, topoint, result_point, result_normal, KX_RayCast::Callback<MyClass, MyDataClass>(this, data)
- *
- * Calls myclass->NeedRayCast(client, data) for all client in environment
- * and myclass->RayHit(client, hit_point, hit_normal, data) for all client
- * between frompoint and topoint
- *
- * myclass->NeedRayCast should return true to ray test the current client.
- *
- * myclass->RayHit should return true to end the raycast, false to ignore the current client and to continue.
- *
- * Returns true if a client was accepted, false if nothing found.
- */
-class KX_RayCast : public PHY_IRayCastFilterCallback
-{
-public:
- bool m_hitFound;
- MT_Point3 m_hitPoint;
- MT_Vector3 m_hitNormal;
- const RAS_MeshObject* m_hitMesh;
- int m_hitPolygon;
- int m_hitUVOK; // !=0 if UV coordinate in m_hitUV is valid
- MT_Vector2 m_hitUV;
-
- KX_RayCast(PHY_IPhysicsController* ignoreController, bool faceNormal, bool faceUV);
- virtual ~KX_RayCast() {}
-
- /**
- * The physic environment returns the ray casting result through this function
- */
- virtual void reportHit(PHY_RayCastResult* result);
-
- /** ray test callback.
- * either override this in your class, or use a callback wrapper.
- */
- virtual bool RayHit(KX_ClientObjectInfo* client) = 0;
-
- /**
- * Callback wrapper.
- *
- * Construct with KX_RayCast::Callback<MyClass, MyDataClass>(this, data)
- * and pass to KX_RayCast::RayTest
- */
- template<class T, class dataT> class Callback;
-
- /// Public interface.
- /// Implement bool RayHit in your class to receive ray callbacks.
- static bool RayTest(
- PHY_IPhysicsEnvironment* physics_environment,
- const MT_Point3& frompoint,
- const MT_Point3& topoint,
- KX_RayCast& callback);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_RayCast")
-#endif
-};
-
-template<class T, class dataT>
-class KX_RayCast::Callback : public KX_RayCast
-{
- T *self;
- /**
- * Some user info passed as argument in constructor.
- * It contains all info needed to check client in NeedRayCast
- * and RayHit.
- */
- dataT *data;
-public:
- Callback(T *_self, PHY_IPhysicsController *controller = NULL, dataT *_data = NULL, bool faceNormal = false, bool faceUV = false)
- : KX_RayCast(controller, faceNormal, faceUV),
- self(_self),
- data(_data)
- {
- }
-
- ~Callback() {}
-
- virtual bool RayHit(KX_ClientObjectInfo* client)
- {
- return self->RayHit(client, this, data);
- }
-
- virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller)
- {
- KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(controller->GetNewClientInfo());
-
- if (!info)
- {
- MT_assert(info && "Physics controller with no client object info");
- return false;
- }
- return self->NeedRayCast(info, data);
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_RayCast::Callback")
-#endif
-};
-
-
-#endif
diff --git a/source/gameengine/Ketsji/KX_RayEventManager.cpp b/source/gameengine/Ketsji/KX_RayEventManager.cpp
deleted file mode 100644
index 661c7eb6f64..00000000000
--- a/source/gameengine/Ketsji/KX_RayEventManager.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Manager for ray events
- *
- *
- * ***** 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_RayEventManager.cpp
- * \ingroup ketsji
- */
-
-#include "KX_RayEventManager.h"
-#include "SCA_LogicManager.h"
-#include "SCA_ISensor.h"
-#include <vector>
-
-using namespace std;
-
-#include <iostream>
-#include <stdio.h>
-
-void KX_RayEventManager::NextFrame()
-{
- SG_DList::iterator<SCA_ISensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- (*it)->Activate(m_logicmgr);
- }
-}
-
diff --git a/source/gameengine/Ketsji/KX_RayEventManager.h b/source/gameengine/Ketsji/KX_RayEventManager.h
deleted file mode 100644
index 07506b9e32b..00000000000
--- a/source/gameengine/Ketsji/KX_RayEventManager.h
+++ /dev/null
@@ -1,53 +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_RayEventManager.h
- * \ingroup ketsji
- * \brief Manager for ray events
- */
-
-#ifndef __KX_RAYEVENTMANAGER_H__
-#define __KX_RAYEVENTMANAGER_H__
-#include "SCA_EventManager.h"
-#include <vector>
-using namespace std;
-
-class KX_RayEventManager : public SCA_EventManager
-{
-public:
- KX_RayEventManager(class SCA_LogicManager* logicmgr)
- : SCA_EventManager(logicmgr, RAY_EVENTMGR)
- {}
- virtual void NextFrame();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_RayEventManager")
-#endif
-};
-
-#endif /* __KX_RAYEVENTMANAGER_H__ */
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
deleted file mode 100644
index 4ffb5f332db..00000000000
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Cast a ray and feel for objects
- *
- *
- * ***** 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_RaySensor.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_RaySensor.h"
-#include "SCA_EventManager.h"
-#include "SCA_RandomEventManager.h"
-#include "SCA_LogicManager.h"
-#include "SCA_IObject.h"
-#include "KX_ClientObjectInfo.h"
-#include "KX_GameObject.h"
-#include "KX_Scene.h"
-#include "KX_RayCast.h"
-#include "KX_PyMath.h"
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_IPhysicsController.h"
-#include "DNA_sensor_types.h"
-#include "RAS_MeshObject.h"
-
-#include <stdio.h>
-
-
-KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- const STR_String& propname,
- bool bFindMaterial,
- bool bXRay,
- double distance,
- int axis,
- KX_Scene* ketsjiScene)
- : SCA_ISensor(gameobj,eventmgr),
- m_propertyname(propname),
- m_bFindMaterial(bFindMaterial),
- m_bXRay(bXRay),
- m_distance(distance),
- m_scene(ketsjiScene),
- m_axis(axis),
- m_hitMaterial("")
-{
- Init();
-}
-
-void KX_RaySensor::Init()
-{
- m_bTriggered = (m_invert)?true:false;
- m_rayHit = false;
- m_hitObject = NULL;
- m_reset = true;
-}
-
-KX_RaySensor::~KX_RaySensor()
-{
- /* Nothing to be done here. */
-}
-
-
-
-CValue* KX_RaySensor::GetReplica()
-{
- KX_RaySensor* replica = new KX_RaySensor(*this);
- replica->ProcessReplica();
- replica->Init();
-
- return replica;
-}
-
-
-
-bool KX_RaySensor::IsPositiveTrigger()
-{
- bool result = m_rayHit;
-
- if (m_invert)
- result = !result;
-
- return result;
-}
-
-bool KX_RaySensor::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void *UNUSED(data))
-{
-
- KX_GameObject* hitKXObj = client->m_gameobject;
- bool bFound = false;
- bool hitMaterial = false;
-
- if (m_propertyname.Length() == 0)
- {
- bFound = true;
- }
- else
- {
- if (m_bFindMaterial) {
- for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) {
- RAS_MeshObject *meshObj = hitKXObj->GetMesh(i);
- for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
- bFound = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
- if (bFound) {
- hitMaterial = true;
- break;
- }
- }
- }
- }
- else {
- bFound = hitKXObj->GetProperty(m_propertyname) != NULL;
- }
- }
-
- if (bFound)
- {
- m_rayHit = true;
- m_hitObject = hitKXObj;
- m_hitPosition[0] = result->m_hitPoint[0];
- m_hitPosition[1] = result->m_hitPoint[1];
- m_hitPosition[2] = result->m_hitPoint[2];
-
- m_hitNormal[0] = result->m_hitNormal[0];
- m_hitNormal[1] = result->m_hitNormal[1];
- m_hitNormal[2] = result->m_hitNormal[2];
-
- m_hitMaterial = hitMaterial;
- }
- // no multi-hit search yet
- return true;
-}
-
-/* this function is used to pre-filter the object before casting the ray on them.
- * This is useful for "X-Ray" option when we want to see "through" unwanted object.
- */
-bool KX_RaySensor::NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data))
-{
- KX_GameObject *hitKXObj = client->m_gameobject;
-
- if (client->m_type > KX_ClientObjectInfo::ACTOR)
- {
- // Unknown type of object, skip it.
- // Should not occur as the sensor objects are filtered in RayTest()
- printf("Invalid client type %d found ray casting\n", client->m_type);
- return false;
- }
- if (m_bXRay && m_propertyname.Length() != 0)
- {
- if (m_bFindMaterial) {
- bool found = false;
- for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) {
- RAS_MeshObject *meshObj = hitKXObj->GetMesh(i);
- for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
- found = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
- if (found)
- break;
- }
- }
- if (!found)
- return false;
- }
- else {
- if (hitKXObj->GetProperty(m_propertyname) == NULL)
- return false;
- }
- }
- return true;
-}
-
-bool KX_RaySensor::Evaluate()
-{
- bool result = false;
- bool reset = m_reset && m_level;
- m_rayHit = false;
- m_hitObject = NULL;
- m_hitPosition[0] = 0;
- m_hitPosition[1] = 0;
- m_hitPosition[2] = 0;
-
- m_hitNormal[0] = 1;
- m_hitNormal[1] = 0;
- m_hitNormal[2] = 0;
-
- KX_GameObject* obj = (KX_GameObject*)GetParent();
- MT_Point3 frompoint = obj->NodeGetWorldPosition();
- MT_Matrix3x3 matje = obj->NodeGetWorldOrientation();
- MT_Matrix3x3 invmat = matje.inverse();
-
- MT_Vector3 todir;
- m_reset = false;
- switch (m_axis)
- {
- case SENS_RAY_X_AXIS: // X
- {
- todir[0] = invmat[0][0];
- todir[1] = invmat[0][1];
- todir[2] = invmat[0][2];
- break;
- }
- case SENS_RAY_Y_AXIS: // Y
- {
- todir[0] = invmat[1][0];
- todir[1] = invmat[1][1];
- todir[2] = invmat[1][2];
- break;
- }
- case SENS_RAY_Z_AXIS: // Z
- {
- todir[0] = invmat[2][0];
- todir[1] = invmat[2][1];
- todir[2] = invmat[2][2];
- break;
- }
- case SENS_RAY_NEG_X_AXIS: // -X
- {
- todir[0] = -invmat[0][0];
- todir[1] = -invmat[0][1];
- todir[2] = -invmat[0][2];
- break;
- }
- case SENS_RAY_NEG_Y_AXIS: // -Y
- {
- todir[0] = -invmat[1][0];
- todir[1] = -invmat[1][1];
- todir[2] = -invmat[1][2];
- break;
- }
- case SENS_RAY_NEG_Z_AXIS: // -Z
- {
- todir[0] = -invmat[2][0];
- todir[1] = -invmat[2][1];
- todir[2] = -invmat[2][2];
- break;
- }
- }
- todir.normalize();
- m_rayDirection[0] = todir[0];
- m_rayDirection[1] = todir[1];
- m_rayDirection[2] = todir[2];
-
- MT_Point3 topoint = frompoint + (m_distance) * todir;
- PHY_IPhysicsEnvironment* pe = m_scene->GetPhysicsEnvironment();
-
- if (!pe)
- {
- std::cout << "WARNING: Ray sensor " << GetName() << ": There is no physics environment!" << std::endl;
- std::cout << " Check universe for malfunction." << std::endl;
- return false;
- }
-
- PHY_IPhysicsController *spc = obj->GetPhysicsController();
- KX_GameObject *parent = obj->GetParent();
- if (!spc && parent)
- spc = parent->GetPhysicsController();
-
-
- PHY_IPhysicsEnvironment* physics_environment = this->m_scene->GetPhysicsEnvironment();
-
-
- KX_RayCast::Callback<KX_RaySensor, void> callback(this, spc);
- KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback);
-
- /* now pass this result to some controller */
-
- if (m_rayHit)
- {
- if (!m_bTriggered)
- {
- // notify logicsystem that ray is now hitting
- result = true;
- m_bTriggered = true;
- }
- else
- {
- // notify logicsystem that ray is STILL hitting ...
- result = false;
-
- }
- }
- else
- {
- if (m_bTriggered)
- {
- m_bTriggered = false;
- // notify logicsystem that ray JUST left the Object
- result = true;
- }
- else
- {
- result = false;
- }
-
- }
- if (reset)
- // force an event
- result = true;
-
- return result;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_RaySensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_RaySensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-
-};
-
-PyMethodDef KX_RaySensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_RaySensor::Attributes[] = {
- KX_PYATTRIBUTE_BOOL_RW("useMaterial", KX_RaySensor, m_bFindMaterial),
- KX_PYATTRIBUTE_BOOL_RW("useXRay", KX_RaySensor, m_bXRay),
- KX_PYATTRIBUTE_FLOAT_RW("range", 0, 10000, KX_RaySensor, m_distance),
- KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, KX_RaySensor, m_propertyname),
- KX_PYATTRIBUTE_INT_RW("axis", 0, 5, true, KX_RaySensor, m_axis),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RO("hitPosition", KX_RaySensor, m_hitPosition, 3),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RO("rayDirection", KX_RaySensor, m_rayDirection, 3),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RO("hitNormal", KX_RaySensor, m_hitNormal, 3),
- KX_PYATTRIBUTE_STRING_RO("hitMaterial", KX_RaySensor, m_hitMaterial),
- KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_RaySensor, pyattr_get_hitobject),
- { NULL } //Sentinel
-};
-
-PyObject *KX_RaySensor::pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_RaySensor* self = static_cast<KX_RaySensor*>(self_v);
- if (self->m_hitObject)
- return self->m_hitObject->GetProxy();
-
- Py_RETURN_NONE;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h
deleted file mode 100644
index 1901bb04f86..00000000000
--- a/source/gameengine/Ketsji/KX_RaySensor.h
+++ /dev/null
@@ -1,109 +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_RaySensor.h
- * \ingroup ketsji
- * \brief Cast a ray and feel for objects
- */
-
-#ifndef __KX_RAYSENSOR_H__
-#define __KX_RAYSENSOR_H__
-
-#include "SCA_ISensor.h"
-#include "MT_Point3.h"
-#include "SCA_IScene.h" /* only for scene replace */
-#include "KX_Scene.h" /* only for scene replace */
-
-#include "BLI_utildefines.h"
-
-struct KX_ClientObjectInfo;
-class KX_RayCast;
-
-class KX_RaySensor : public SCA_ISensor
-{
- Py_Header
- STR_String m_propertyname;
- bool m_bFindMaterial;
- bool m_bXRay;
- float m_distance;
- class KX_Scene* m_scene;
- bool m_bTriggered;
- int m_axis;
- bool m_rayHit;
- float m_hitPosition[3];
- SCA_IObject* m_hitObject;
- float m_hitNormal[3];
- float m_rayDirection[3];
- STR_String m_hitMaterial;
-
-public:
- KX_RaySensor(class SCA_EventManager* eventmgr,
- SCA_IObject* gameobj,
- const STR_String& propname,
- bool bFindMaterial,
- bool bXRay,
- double distance,
- int axis,
- class KX_Scene* ketsjiScene);
- virtual ~KX_RaySensor();
- virtual CValue* GetReplica();
-
- virtual bool Evaluate();
- virtual bool IsPositiveTrigger();
- virtual void Init();
-
- /// \see KX_RayCast
- bool RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void *UNUSED(data));
- /// \see KX_RayCast
- bool NeedRayCast(KX_ClientObjectInfo *client, void *UNUSED(data));
-
- virtual void Replace_IScene(SCA_IScene *val)
- {
- m_scene= static_cast<KX_Scene *>(val);
- }
-
- //Python Interface
- // odd order, see: SENS_RAY_X_AXIS
- enum RayAxis {
- KX_RAY_AXIS_POS_X = 1,
- KX_RAY_AXIS_POS_Y = 0,
- KX_RAY_AXIS_POS_Z = 2,
- KX_RAY_AXIS_NEG_X = 3,
- KX_RAY_AXIS_NEG_Y = 4,
- KX_RAY_AXIS_NEG_Z = 5,
- };
-
-#ifdef WITH_PYTHON
-
- /* Attributes */
- static PyObject *pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
-#endif /* WITH_PYTHON */
-
-};
-
-#endif /* __KX_RAYSENSOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
deleted file mode 100644
index bb38d8269b7..00000000000
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ /dev/null
@@ -1,284 +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_SCA_AddObjectActuator.cpp
- * \ingroup ketsji
- *
- * Add an object when this actuator is triggered
- */
-
-/* Previously existed as:
- * \source\gameengine\GameLogic\SCA_AddObjectActuator.cpp
- * Please look here for revision history. */
-
-#include "KX_SCA_AddObjectActuator.h"
-#include "SCA_IScene.h"
-#include "KX_GameObject.h"
-#include "EXP_PyObjectPlus.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj,
- SCA_IObject *original,
- int time,
- SCA_IScene* scene,
- const float *linvel,
- bool linv_local,
- const float *angvel,
- bool angv_local)
- :
- SCA_IActuator(gameobj, KX_ACT_ADD_OBJECT),
- m_OriginalObject(original),
- m_scene(scene),
-
- m_localLinvFlag(linv_local),
- m_localAngvFlag(angv_local)
-{
- m_linear_velocity[0] = linvel[0];
- m_linear_velocity[1] = linvel[1];
- m_linear_velocity[2] = linvel[2];
- m_angular_velocity[0] = angvel[0];
- m_angular_velocity[1] = angvel[1];
- m_angular_velocity[2] = angvel[2];
-
- if (m_OriginalObject)
- m_OriginalObject->RegisterActuator(this);
-
- m_lastCreatedObject = NULL;
- m_timeProp = time;
-}
-
-
-
-KX_SCA_AddObjectActuator::~KX_SCA_AddObjectActuator()
-{
- if (m_OriginalObject)
- m_OriginalObject->UnregisterActuator(this);
- if (m_lastCreatedObject)
- m_lastCreatedObject->UnregisterActuator(this);
-}
-
-
-
-bool KX_SCA_AddObjectActuator::Update()
-{
- //bool result = false; /*unused*/
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent) return false; // do nothing on negative events
-
- InstantAddObject();
-
-
- return false;
-}
-
-
-
-
-SCA_IObject* KX_SCA_AddObjectActuator::GetLastCreatedObject() const
-{
- return m_lastCreatedObject;
-}
-
-
-
-CValue* KX_SCA_AddObjectActuator::GetReplica()
-{
- KX_SCA_AddObjectActuator* replica = new KX_SCA_AddObjectActuator(*this);
-
- if (replica == NULL)
- return NULL;
-
- // this will copy properties and so on...
- replica->ProcessReplica();
-
- return replica;
-}
-
-void KX_SCA_AddObjectActuator::ProcessReplica()
-{
- if (m_OriginalObject)
- m_OriginalObject->RegisterActuator(this);
- m_lastCreatedObject=NULL;
- SCA_IActuator::ProcessReplica();
-}
-
-bool KX_SCA_AddObjectActuator::UnlinkObject(SCA_IObject* clientobj)
-{
- if (clientobj == m_OriginalObject)
- {
- // this object is being deleted, we cannot continue to track it.
- m_OriginalObject = NULL;
- return true;
- }
- if (clientobj == m_lastCreatedObject)
- {
- // this object is being deleted, we cannot continue to track it.
- m_lastCreatedObject = NULL;
- return true;
- }
- return false;
-}
-
-void KX_SCA_AddObjectActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_OriginalObject];
- if (h_obj) {
- if (m_OriginalObject)
- m_OriginalObject->UnregisterActuator(this);
- m_OriginalObject = (SCA_IObject*)(*h_obj);
- m_OriginalObject->RegisterActuator(this);
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_SCA_AddObjectActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_SCA_AddObjectActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
- {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_NOARGS, NULL},
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_SCA_AddObjectActuator::Attributes[] = {
- KX_PYATTRIBUTE_RW_FUNCTION("object",KX_SCA_AddObjectActuator,pyattr_get_object,pyattr_set_object),
- KX_PYATTRIBUTE_RO_FUNCTION("objectLastCreated",KX_SCA_AddObjectActuator,pyattr_get_objectLastCreated),
- KX_PYATTRIBUTE_INT_RW("time",0,2000,true,KX_SCA_AddObjectActuator,m_timeProp),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RW("linearVelocity",-FLT_MAX,FLT_MAX,KX_SCA_AddObjectActuator,m_linear_velocity,3),
- KX_PYATTRIBUTE_FLOAT_ARRAY_RW("angularVelocity",-FLT_MAX,FLT_MAX,KX_SCA_AddObjectActuator,m_angular_velocity,3),
- { NULL } //Sentinel
-};
-
-PyObject *KX_SCA_AddObjectActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self);
- if (!actuator->m_OriginalObject)
- Py_RETURN_NONE;
- else
- return actuator->m_OriginalObject->GetProxy();
-}
-
-int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self);
- KX_GameObject *gameobj;
-
- if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_SCA_AddObjectActuator"))
- return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
-
- if (actuator->m_OriginalObject != NULL)
- actuator->m_OriginalObject->UnregisterActuator(actuator);
-
- actuator->m_OriginalObject = (SCA_IObject*)gameobj;
-
- if (actuator->m_OriginalObject)
- actuator->m_OriginalObject->RegisterActuator(actuator);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self);
- if (!actuator->m_lastCreatedObject)
- Py_RETURN_NONE;
- else
- return actuator->m_lastCreatedObject->GetProxy();
-}
-
-PyObject *KX_SCA_AddObjectActuator::PyInstantAddObject()
-{
- InstantAddObject();
-
- Py_RETURN_NONE;
-}
-
-#endif // WITH_PYTHON
-
-void KX_SCA_AddObjectActuator::InstantAddObject()
-{
- if (m_OriginalObject)
- {
- // Add an identical object, with properties inherited from the original object
- // Now it needs to be added to the current scene.
- SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp );
- KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica);
- game_obj->setLinearVelocity(m_linear_velocity, m_localLinvFlag);
- game_obj->setAngularVelocity(m_angular_velocity,m_localAngvFlag);
- game_obj->ResolveCombinedVelocities(m_linear_velocity, m_angular_velocity, m_localLinvFlag, m_localAngvFlag);
-
- // keep a copy of the last object, to allow python scripters to change it
- if (m_lastCreatedObject)
- {
- //Let's not keep a reference to the object: it's bad, if the object is deleted
- //this will force to keep a "zombie" in the game for no good reason.
- //m_scene->DelayedReleaseObject(m_lastCreatedObject);
- //m_lastCreatedObject->Release();
-
- //Instead we use the registration mechanism
- m_lastCreatedObject->UnregisterActuator(this);
- m_lastCreatedObject = NULL;
- }
-
- m_lastCreatedObject = replica;
- // no reference
- //m_lastCreatedObject->AddRef();
- // but registration
- m_lastCreatedObject->RegisterActuator(this);
- // finished using replica? then release it
- replica->Release();
- }
-}
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
deleted file mode 100644
index 976f3c58d68..00000000000
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
+++ /dev/null
@@ -1,133 +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_SCA_AddObjectActuator.h
- * \ingroup ketsji
- * \attention Previously existed as: source/gameengine/GameLogic/SCA_AddObjectActuator.h
- * Please look here for revision history.
- */
-
-#ifndef __KX_SCA_ADDOBJECTACTUATOR_H__
-#define __KX_SCA_ADDOBJECTACTUATOR_H__
-
-/* Actuator tree */
-#include "SCA_IActuator.h"
-#include "SCA_LogicManager.h"
-
-#include "MT_Vector3.h"
-
-
-class SCA_IScene;
-
-class KX_SCA_AddObjectActuator : public SCA_IActuator
-{
- Py_Header
-
- /// Time field: lifetime of the new object
- int m_timeProp;
-
- /// Original object reference (object to replicate)
- SCA_IObject* m_OriginalObject;
-
- /// Object will be added to the following scene
- SCA_IScene* m_scene;
-
- /// Linear velocity upon creation of the object.
- float m_linear_velocity[3];
- /// Apply the velocity locally
- bool m_localLinvFlag;
-
- /// Angular velocity upon creation of the object.
- float m_angular_velocity[3];
- /// Apply the velocity locally
- bool m_localAngvFlag;
-
-
-
-
- SCA_IObject* m_lastCreatedObject;
-
-public:
-
- /**
- * This class also has the default constructors
- * available. Use with care!
- */
-
- KX_SCA_AddObjectActuator(
- SCA_IObject *gameobj,
- SCA_IObject *original,
- int time,
- SCA_IScene* scene,
- const float *linvel,
- bool linv_local,
- const float *angvel,
- bool angv_local
- );
-
- ~KX_SCA_AddObjectActuator(void);
-
- CValue*
- GetReplica(
- );
-
- virtual void
- ProcessReplica();
-
- virtual void Replace_IScene(SCA_IScene *val)
- {
- m_scene= val;
- };
-
- virtual bool
- UnlinkObject(SCA_IObject* clientobj);
-
- virtual void
- Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
-
- virtual bool
- Update();
-
- SCA_IObject *
- GetLastCreatedObject(
- ) const;
-
- void InstantAddObject();
-
-#ifdef WITH_PYTHON
-
- KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,InstantAddObject);
-
- static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
-
-#endif /* WITH_PYTHON */
-
-}; /* end of class KX_SCA_AddObjectActuator : public KX_EditObjectActuator */
-
-#endif /* __KX_SCA_ADDOBJECTACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
deleted file mode 100644
index a4220424c6f..00000000000
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
+++ /dev/null
@@ -1,160 +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_SCA_DynamicActuator.cpp
- * \ingroup ketsji
- * Adjust dynamics settings for this object
- */
-
-/* Previously existed as:
- * \source\gameengine\GameLogic\SCA_DynamicActuator.cpp
- * Please look here for revision history. */
-
-#include "KX_SCA_DynamicActuator.h"
-#include "PHY_IPhysicsController.h"
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-
-PyTypeObject KX_SCA_DynamicActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_SCA_DynamicActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_SCA_DynamicActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = {
- KX_PYATTRIBUTE_SHORT_RW("mode",0,4,false,KX_SCA_DynamicActuator,m_dyn_operation),
- KX_PYATTRIBUTE_FLOAT_RW("mass",0.0f,FLT_MAX,KX_SCA_DynamicActuator,m_setmass),
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_SCA_DynamicActuator::KX_SCA_DynamicActuator(SCA_IObject *gameobj,
- short dyn_operation,
- float setmass) :
-
- SCA_IActuator(gameobj, KX_ACT_DYNAMIC),
- m_dyn_operation(dyn_operation),
- m_setmass(setmass)
-{
-} /* End of constructor */
-
-
-KX_SCA_DynamicActuator::~KX_SCA_DynamicActuator()
-{
- // there's nothing to be done here, really....
-} /* end of destructor */
-
-
-
-bool KX_SCA_DynamicActuator::Update()
-{
- // bool result = false; /*unused*/
- KX_GameObject *obj = (KX_GameObject*) GetParent();
- bool bNegativeEvent = IsNegativeEvent();
- PHY_IPhysicsController* controller;
- RemoveAllEvents();
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
-
- if (!obj)
- return false; // object not accessible, shouldnt happen
- controller = obj->GetPhysicsController();
- if (!controller)
- return false; // no physic object
-
- switch (m_dyn_operation)
- {
- case 0:
- // Child objects must be static, so we block changing to dynamic
- if (!obj->GetParent())
- controller->RestoreDynamics();
- break;
- case 1:
- controller->SuspendDynamics();
- break;
- case 2:
- controller->SetRigidBody(true);
- break;
- case 3:
- controller->SetRigidBody(false);
- break;
- case 4:
- controller->SetMass(m_setmass);
- break;
- }
-
- return false;
-}
-
-
-
-CValue* KX_SCA_DynamicActuator::GetReplica()
-{
- KX_SCA_DynamicActuator* replica =
- new KX_SCA_DynamicActuator(*this);
-
- if (replica == NULL)
- return NULL;
-
- replica->ProcessReplica();
- return replica;
-};
-
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
deleted file mode 100644
index 4eb337c54f5..00000000000
--- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
+++ /dev/null
@@ -1,76 +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): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file KX_SCA_DynamicActuator.h
- * \ingroup ketsji
- * \brief Add object to the game world on action of this actuator
- */
-
-#ifndef __KX_SCA_DYNAMICACTUATOR_H__
-#define __KX_SCA_DYNAMICACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "SCA_PropertyActuator.h"
-#include "SCA_LogicManager.h"
-
-#include "KX_GameObject.h"
-
-class KX_SCA_DynamicActuator : public SCA_IActuator
-{
- Py_Header
-
- // dynamics operation to apply to the game object
- short m_dyn_operation;
- float m_setmass;
- public:
- KX_SCA_DynamicActuator(
- SCA_IObject* gameobj,
- short dyn_operation,
- float setmass
- );
-
- ~KX_SCA_DynamicActuator(
- );
-
- CValue*
- GetReplica(
- );
-
- virtual bool
- Update();
-
- //Python Interface
- enum DynamicOperation {
- KX_DYN_RESTORE_DYNAMICS = 0,
- KX_DYN_DISABLE_DYNAMICS,
- KX_DYN_ENABLE_RIGID_BODY,
- KX_DYN_DISABLE_RIGID_BODY,
- KX_DYN_SET_MASS,
- };
-};
-
-#endif
diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
deleted file mode 100644
index 81c9dc91603..00000000000
--- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
+++ /dev/null
@@ -1,125 +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_SCA_EndObjectActuator.cpp
- * \ingroup ketsji
- */
-
-
-//
-
-// Remove the actuator's parent when triggered
-//
-// Previously existed as:
-// \source\gameengine\GameLogic\SCA_EndObjectActuator.cpp
-// Please look here for revision history.
-
-#include "SCA_IActuator.h"
-#include "KX_SCA_EndObjectActuator.h"
-#include "SCA_IScene.h"
-
-KX_SCA_EndObjectActuator::KX_SCA_EndObjectActuator(SCA_IObject *gameobj,
- SCA_IScene* scene):
- SCA_IActuator(gameobj, KX_ACT_END_OBJECT),
- m_scene(scene)
-{
- // intentionally empty
-} /* End of constructor */
-
-
-
-KX_SCA_EndObjectActuator::~KX_SCA_EndObjectActuator()
-{
- // there's nothing to be done here, really....
-} /* end of destructor */
-
-
-
-bool KX_SCA_EndObjectActuator::Update()
-{
- // bool result = false; /*unused*/
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
- m_scene->DelayedRemoveObject(GetParent());
-
- return false;
-}
-
-
-
-CValue* KX_SCA_EndObjectActuator::GetReplica()
-{
- KX_SCA_EndObjectActuator* replica =
- new KX_SCA_EndObjectActuator(*this);
- if (replica == NULL) return NULL;
-
- replica->ProcessReplica();
- return replica;
-};
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions : integration hooks */
-/* ------------------------------------------------------------------------- */
-
-PyTypeObject KX_SCA_EndObjectActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_SCA_EndObjectActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_SCA_EndObjectActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_SCA_EndObjectActuator::Attributes[] = {
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h
deleted file mode 100644
index 3399ed90667..00000000000
--- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h
+++ /dev/null
@@ -1,74 +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_SCA_EndObjectActuator.h
- * \ingroup ketsji
- * \brief Add object to the game world on action of this actuator
- * \attention Previously existed as: source/gameengine/GameLogic/SCA_EndObjectActuator.h
- * Please look here for revision history.
- */
-
-#ifndef __KX_SCA_ENDOBJECTACTUATOR_H__
-#define __KX_SCA_ENDOBJECTACTUATOR_H__
-
-#include "SCA_IActuator.h"
-
-class SCA_IScene;
-
-class KX_SCA_EndObjectActuator : public SCA_IActuator
-{
- Py_Header
- SCA_IScene* m_scene;
-
- public:
- KX_SCA_EndObjectActuator(
- SCA_IObject* gameobj,
- SCA_IScene* scene
- );
-
- ~KX_SCA_EndObjectActuator();
-
- CValue*
- GetReplica(
- );
-
- virtual bool
- Update();
-
- virtual void Replace_IScene(SCA_IScene *val)
- {
- m_scene= val;
- };
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
-}; /* end of class KX_EditObjectActuator : public SCA_PropertyActuator */
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
deleted file mode 100644
index 1bf76de0b40..00000000000
--- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
+++ /dev/null
@@ -1,182 +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_SCA_ReplaceMeshActuator.cpp
- * \ingroup ketsji
- *
- * Replace the mesh for this actuator's parent
- */
-
-//
-// Previously existed as:
-
-// \source\gameengine\GameLogic\SCA_ReplaceMeshActuator.cpp
-
-// Please look here for revision history.
-
-#include <stddef.h>
-
-#include "KX_SCA_ReplaceMeshActuator.h"
-#include "KX_MeshProxy.h"
-
-#include "EXP_PyObjectPlus.h"
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-
-PyTypeObject KX_SCA_ReplaceMeshActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_SCA_ReplaceMeshActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = {
- KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh),
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_SCA_ReplaceMeshActuator::Attributes[] = {
- KX_PYATTRIBUTE_RW_FUNCTION("mesh", KX_SCA_ReplaceMeshActuator, pyattr_get_mesh, pyattr_set_mesh),
- KX_PYATTRIBUTE_BOOL_RW ("useDisplayMesh", KX_SCA_ReplaceMeshActuator, m_use_gfx),
- KX_PYATTRIBUTE_BOOL_RW ("usePhysicsMesh", KX_SCA_ReplaceMeshActuator, m_use_phys),
- { NULL } //Sentinel
-};
-
-PyObject *KX_SCA_ReplaceMeshActuator::pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SCA_ReplaceMeshActuator* actuator = static_cast<KX_SCA_ReplaceMeshActuator*>(self);
- if (!actuator->m_mesh)
- Py_RETURN_NONE;
- KX_MeshProxy* meshproxy = new KX_MeshProxy(actuator->m_mesh);
- return meshproxy->NewProxy(true);
-}
-
-int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_SCA_ReplaceMeshActuator* actuator = static_cast<KX_SCA_ReplaceMeshActuator*>(self);
- RAS_MeshObject* new_mesh;
-
- if (!ConvertPythonToMesh(actuator->GetLogicManager(), value, &new_mesh, true, "actuator.mesh = value: KX_SCA_ReplaceMeshActuator"))
- return PY_SET_ATTR_FAIL;
-
- actuator->m_mesh = new_mesh;
- return PY_SET_ATTR_SUCCESS;
-}
-
-KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh,
-"instantReplaceMesh() : immediately replace mesh without delay\n")
-{
- InstantReplaceMesh();
- Py_RETURN_NONE;
-}
-
-#endif // WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_SCA_ReplaceMeshActuator::KX_SCA_ReplaceMeshActuator(SCA_IObject *gameobj,
- class RAS_MeshObject *mesh,
- SCA_IScene* scene,
- bool use_gfx,
- bool use_phys) :
-
- SCA_IActuator(gameobj, KX_ACT_REPLACE_MESH),
- m_mesh(mesh),
- m_scene(scene),
- m_use_gfx(use_gfx),
- m_use_phys(use_phys)
-{
-} /* End of constructor */
-
-
-
-KX_SCA_ReplaceMeshActuator::~KX_SCA_ReplaceMeshActuator()
-{
- // there's nothing to be done here, really....
-} /* end of destructor */
-
-
-
-bool KX_SCA_ReplaceMeshActuator::Update()
-{
- // bool result = false; /*unused*/
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
-
- if (m_mesh || m_use_phys) /* NULL mesh is ok if were updating physics */
- m_scene->ReplaceMesh(GetParent(),m_mesh, m_use_gfx, m_use_phys);
-
- return false;
-}
-
-
-
-CValue* KX_SCA_ReplaceMeshActuator::GetReplica()
-{
- KX_SCA_ReplaceMeshActuator* replica =
- new KX_SCA_ReplaceMeshActuator(*this);
-
- if (replica == NULL)
- return NULL;
-
- replica->ProcessReplica();
-
- return replica;
-};
-
-void KX_SCA_ReplaceMeshActuator::InstantReplaceMesh()
-{
- if (m_mesh) m_scene->ReplaceMesh(GetParent(),m_mesh, m_use_gfx, m_use_phys);
-}
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
deleted file mode 100644
index 4370b5d4a4f..00000000000
--- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
+++ /dev/null
@@ -1,96 +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_SCA_ReplaceMeshActuator.h
- * \ingroup ketsji
- * \brief Add object to the game world on action of this actuator
- * \attention Previously existed as: source/gameengine/GameLogic/SCA_ReplaceMeshActuator.h
- * Please look here for revision history.
- */
-
-#ifndef __KX_SCA_REPLACEMESHACTUATOR_H__
-#define __KX_SCA_REPLACEMESHACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "SCA_PropertyActuator.h"
-#include "SCA_LogicManager.h"
-#include "SCA_IScene.h"
-
-#include "RAS_MeshObject.h"
-
-class KX_SCA_ReplaceMeshActuator : public SCA_IActuator
-{
- Py_Header
-
- // mesh reference (mesh to replace)
- RAS_MeshObject* m_mesh;
- SCA_IScene* m_scene;
- bool m_use_gfx;
- bool m_use_phys;
-
- public:
- KX_SCA_ReplaceMeshActuator(
- SCA_IObject* gameobj,
- RAS_MeshObject *mesh,
- SCA_IScene* scene,
- bool use_gfx,
- bool use_phys
- );
-
- ~KX_SCA_ReplaceMeshActuator(
- );
-
- CValue*
- GetReplica(
- );
-
- virtual bool
- Update();
-
- void InstantReplaceMesh();
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- virtual void Replace_IScene(SCA_IScene *val)
- {
- m_scene= val;
- };
-
- static PyObject *pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,instantReplaceMesh);
-
-#endif /* WITH_PYTHON */
-
-};
-
-#endif /* __KX_SCA_REPLACEMESHACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
deleted file mode 100644
index 5a13cf5440d..00000000000
--- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
+++ /dev/null
@@ -1,155 +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_SG_BoneParentNodeRelationship.cpp
- * \ingroup ketsji
- */
-
-
-#include <iostream>
-
-#include "KX_SG_BoneParentNodeRelationship.h"
-
-#include "MT_Matrix4x4.h"
-#include "BL_ArmatureObject.h"
-
-
-/**
- * Implementation of classes defined in KX_SG_BoneParentNodeRelationship.h
- */
-
-/**
- * first of all KX_SG_BoneParentRelation
- */
-
- KX_BoneParentRelation *
-KX_BoneParentRelation::
-New(Bone* bone
-) {
- return new KX_BoneParentRelation(bone);
-}
-
- bool
-KX_BoneParentRelation::
-UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
-) {
- MT_assert(child != NULL);
-
- // This way of accessing child coordinates is a bit cumbersome
- // be nice to have non constant reference access to these values.
-
- const MT_Vector3 & child_scale = child->GetLocalScale();
- const MT_Point3 & child_pos = child->GetLocalPosition();
- const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation();
- // we don't know if the armature has been updated or not, assume yes
- parentUpdated = true;
-
- // the childs world locations which we will update.
-
- MT_Vector3 child_w_scale;
- MT_Point3 child_w_pos;
- MT_Matrix3x3 child_w_rotation;
-
- bool valid_parent_transform = false;
-
- if (parent)
- {
- BL_ArmatureObject *armature = (BL_ArmatureObject*)(parent->GetSGClientObject());
- if (armature)
- {
- MT_Matrix4x4 parent_matrix;
- if (armature->GetBoneMatrix(m_bone, parent_matrix))
- {
- // Get the child's transform, and the bone matrix.
- MT_Matrix4x4 child_transform (
- MT_Transform(child_pos + MT_Vector3(0.0f, armature->GetBoneLength(m_bone), 0.0f),
- child_rotation.scaled(
- child_scale[0],
- child_scale[1],
- child_scale[2])));
-
- // The child's world transform is parent * child
- parent_matrix = parent->GetWorldTransform() * parent_matrix;
- child_transform = parent_matrix * child_transform;
-
- // Recompute the child transform components from the transform.
- child_w_scale.setValue(
- MT_Vector3(child_transform[0][0], child_transform[0][1], child_transform[0][2]).length(),
- MT_Vector3(child_transform[1][0], child_transform[1][1], child_transform[1][2]).length(),
- MT_Vector3(child_transform[2][0], child_transform[2][1], child_transform[2][2]).length());
- child_w_rotation.setValue(child_transform[0][0], child_transform[0][1], child_transform[0][2],
- child_transform[1][0], child_transform[1][1], child_transform[1][2],
- child_transform[2][0], child_transform[2][1], child_transform[2][2]);
- child_w_rotation.scale(1.0f/child_w_scale[0], 1.0f/child_w_scale[1], 1.0f/child_w_scale[2]);
-
- child_w_pos = MT_Point3(child_transform[0][3], child_transform[1][3], child_transform[2][3]);
-
- valid_parent_transform = true;
- }
- }
- }
-
- if (valid_parent_transform)
- {
- child->SetWorldScale(child_w_scale);
- child->SetWorldPosition(child_w_pos);
- child->SetWorldOrientation(child_w_rotation);
- }
- else {
- child->SetWorldFromLocalTransform();
- }
- child->ClearModified();
- // this node must always be updated, so reschedule it for next time
- child->ActivateRecheduleUpdateCallback();
- return valid_parent_transform;
-}
-
- SG_ParentRelation *
-KX_BoneParentRelation::
-NewCopy(
-) {
- KX_BoneParentRelation* bone_parent = new KX_BoneParentRelation(m_bone);
- return bone_parent;
-}
-
-KX_BoneParentRelation::
-~KX_BoneParentRelation(
-) {
- //nothing to do
-}
-
-
-KX_BoneParentRelation::
-KX_BoneParentRelation(Bone* bone
-)
-: m_bone(bone)
-{
- // nothing to do
-}
diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h
deleted file mode 100644
index 6f4fd482198..00000000000
--- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h
+++ /dev/null
@@ -1,96 +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_SG_BoneParentNodeRelationship.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_SG_BONEPARENTNODERELATIONSHIP_H__
-#define __KX_SG_BONEPARENTNODERELATIONSHIP_H__
-
-#include "SG_Spatial.h"
-#include "SG_ParentRelation.h"
-
-struct Bone;
-
-/**
- * Bone parent relationship parents a child SG_Spatial frame to a
- * bone in an armature object.
- */
-class KX_BoneParentRelation : public SG_ParentRelation
-{
-
-public :
- /**
- * Allocate and construct a new KX_SG_BoneParentRelation
- * on the heap.
- *
- * bone is the bone id to use. Currently it is a pointer
- * to a Blender struct Bone - this should be fixed if
- */
-
- static
- KX_BoneParentRelation *
- New(Bone* bone
- );
-
- /**
- * Updates the childs world coordinates relative to the parent's
- * world coordinates.
- *
- * Parent should be a BL_ArmatureObject.
- */
- bool
- UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
- );
-
- /**
- * Create a copy of this relationship
- */
- SG_ParentRelation *
- NewCopy(
- );
-
- ~KX_BoneParentRelation(
- );
-
-private :
- Bone* m_bone;
- KX_BoneParentRelation(Bone* bone
- );
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BoneParentRelation")
-#endif
-};
-
-#endif
diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp
deleted file mode 100644
index e80de76861e..00000000000
--- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp
+++ /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 gameengine/Ketsji/KX_SG_NodeRelationships.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_SG_NodeRelationships.h"
-
-/**
- * Implementation of classes defined in KX_SG_NodeRelationships.h
- */
-
-/**
- * first of all KX_NormalParentRelation
- */
-
- KX_NormalParentRelation *
-KX_NormalParentRelation::
-New(
-) {
- return new KX_NormalParentRelation();
-}
-
- bool
-KX_NormalParentRelation::
-UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
-) {
- MT_assert(child != NULL);
-
- if (!parentUpdated && !child->IsModified())
- return false;
-
- parentUpdated = true;
-
- if (parent==NULL) { /* Simple case */
- child->SetWorldFromLocalTransform();
- child->ClearModified();
- return true; //false;
- }
- else {
- // the childs world locations which we will update.
- const MT_Vector3 & p_world_scale = parent->GetWorldScaling();
- const MT_Point3 & p_world_pos = parent->GetWorldPosition();
- const MT_Matrix3x3 & p_world_rotation = parent->GetWorldOrientation();
-
- child->SetWorldScale(p_world_scale * child->GetLocalScale());
- child->SetWorldOrientation(p_world_rotation * child->GetLocalOrientation());
- child->SetWorldPosition(p_world_pos + p_world_scale * (p_world_rotation * child->GetLocalPosition()));
- child->ClearModified();
- return true;
- }
-}
-
- SG_ParentRelation *
-KX_NormalParentRelation::
-NewCopy(
-) {
- return new KX_NormalParentRelation();
-}
-
-KX_NormalParentRelation::
-~KX_NormalParentRelation(
-) {
- //nothing to do
-}
-
-
-KX_NormalParentRelation::
-KX_NormalParentRelation(
-) {
- // nothing to do
-}
-
-/**
- * Next KX_VertexParentRelation
- */
-
-
- KX_VertexParentRelation *
-KX_VertexParentRelation::
-New(
-) {
- return new KX_VertexParentRelation();
-}
-
-/**
- * Method inherited from KX_ParentRelation
- */
-
- bool
-KX_VertexParentRelation::
-UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
-) {
-
- MT_assert(child != NULL);
-
- if (!parentUpdated && !child->IsModified())
- return false;
-
- child->SetWorldScale(child->GetLocalScale());
-
- if (parent)
- child->SetWorldPosition(child->GetLocalPosition()+parent->GetWorldPosition());
- else
- child->SetWorldPosition(child->GetLocalPosition());
-
- child->SetWorldOrientation(child->GetLocalOrientation());
- child->ClearModified();
- return true; //parent != NULL;
-}
-
-/**
- * Method inherited from KX_ParentRelation
- */
-
- SG_ParentRelation *
-KX_VertexParentRelation::
-NewCopy(
-) {
- return new KX_VertexParentRelation();
-};
-
-KX_VertexParentRelation::
-~KX_VertexParentRelation(
-) {
- //nothing to do
-}
-
-
-KX_VertexParentRelation::
-KX_VertexParentRelation(
-) {
- //nothing to do
-}
-
-
-/**
- * Slow parent relationship
- */
-
- KX_SlowParentRelation *
-KX_SlowParentRelation::
-New(
- MT_Scalar relaxation
-) {
- return new KX_SlowParentRelation(relaxation);
-}
-
-/**
- * Method inherited from KX_ParentRelation
- */
-
- bool
-KX_SlowParentRelation::
-UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
-) {
- MT_assert(child != NULL);
-
- // the child will move even if the parent is not
- parentUpdated = true;
-
- const MT_Vector3 & child_scale = child->GetLocalScale();
- const MT_Point3 & child_pos = child->GetLocalPosition();
- const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation();
-
- // the childs world locations which we will update.
-
- MT_Vector3 child_w_scale;
- MT_Point3 child_w_pos;
- MT_Matrix3x3 child_w_rotation;
-
- if (parent) {
-
- // This is a slow parent relation
- // first compute the normal child world coordinates.
-
- MT_Vector3 child_n_scale;
- MT_Point3 child_n_pos;
- MT_Matrix3x3 child_n_rotation;
-
- const MT_Vector3 & p_world_scale = parent->GetWorldScaling();
- const MT_Point3 & p_world_pos = parent->GetWorldPosition();
- const MT_Matrix3x3 & p_world_rotation = parent->GetWorldOrientation();
-
- child_n_scale = p_world_scale * child_scale;
- child_n_rotation = p_world_rotation * child_rotation;
-
- child_n_pos = p_world_pos + p_world_scale *
- (p_world_rotation * child_pos);
-
-
- if (m_initialized) {
-
- // get the current world positions
-
- child_w_scale = child->GetWorldScaling();
- child_w_pos = child->GetWorldPosition();
- child_w_rotation = child->GetWorldOrientation();
-
- // now 'interpolate' the normal coordinates with the last
- // world coordinates to get the new world coordinates.
-
- MT_Scalar weight = MT_Scalar(1)/(m_relax + 1);
- child_w_scale = (m_relax * child_w_scale + child_n_scale) * weight;
- child_w_pos = (m_relax * child_w_pos + child_n_pos) * weight;
- // for rotation we must go through quaternion
- MT_Quaternion child_w_quat = child_w_rotation.getRotation().slerp(child_n_rotation.getRotation(), weight);
- child_w_rotation.setRotation(child_w_quat);
- //FIXME: update physics controller.
- } else {
- child_w_scale = child_n_scale;
- child_w_pos = child_n_pos;
- child_w_rotation = child_n_rotation;
- m_initialized = true;
- }
-
- } else {
-
- child_w_scale = child_scale;
- child_w_pos = child_pos;
- child_w_rotation = child_rotation;
- }
-
- child->SetWorldScale(child_w_scale);
- child->SetWorldPosition(child_w_pos);
- child->SetWorldOrientation(child_w_rotation);
- child->ClearModified();
- // this node must always be updated, so reschedule it for next time
- child->ActivateRecheduleUpdateCallback();
-
- return true; //parent != NULL;
-}
-
-/**
- * Method inherited from KX_ParentRelation
- */
-
- SG_ParentRelation *
-KX_SlowParentRelation::
-NewCopy(
-) {
- return new KX_SlowParentRelation(m_relax);
-}
-
-KX_SlowParentRelation::
-KX_SlowParentRelation(
- MT_Scalar relaxation
-):
- m_relax(relaxation),
- m_initialized(false)
-{
- //nothing to do
-}
-
-KX_SlowParentRelation::
-~KX_SlowParentRelation(
-) {
- //nothing to do
-}
-
-
-
-
diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h
deleted file mode 100644
index 5d777f5028f..00000000000
--- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h
+++ /dev/null
@@ -1,231 +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_SG_NodeRelationships.h
- * \ingroup ketsji
- * \section KX_SG_NodeRelationships
- * This file provides common concrete implementations of
- * SG_ParentRelation used by the game engine. These are
- * KX_SlowParentRelation a slow parent relationship.
- * KX_NormalParentRelation a normal parent relationship where
- * orientation and position are inherited from the parent by
- * the child.
- * KX_VertexParentRelation only location information is
- * inherited by the child.
- */
-
-#ifndef __KX_SG_NODERELATIONSHIPS_H__
-#define __KX_SG_NODERELATIONSHIPS_H__
-
-#include "SG_Spatial.h"
-#include "SG_ParentRelation.h"
-
-class KX_NormalParentRelation : public SG_ParentRelation
-{
-
-public :
- /**
- * Allocate and construct a new KX_NormalParentRelation
- * on the heap.
- */
-
- static
- KX_NormalParentRelation *
- New(
- );
-
- /**
- * Method inherited from KX_ParentRelation
- */
-
- bool
- UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
- );
-
- /**
- * Method inherited from KX_ParentRelation
- */
-
- SG_ParentRelation *
- NewCopy(
- );
-
- ~KX_NormalParentRelation(
- );
-
-private :
-
- KX_NormalParentRelation(
- );
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_NormalParentRelation")
-#endif
-};
-
-
-class KX_VertexParentRelation : public SG_ParentRelation
-{
-
-public :
-
- /**
- * Allocate and construct a new KX_VertexParentRelation
- * on the heap.
- */
-
- static
- KX_VertexParentRelation *
- New(
- );
-
- /**
- * Method inherited from KX_ParentRelation
- */
-
- bool
- UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
- );
-
- /**
- * Method inherited from KX_ParentRelation
- */
-
- SG_ParentRelation *
- NewCopy(
- );
-
- ~KX_VertexParentRelation(
- );
-
- bool
- IsVertexRelation(
- ) {
- return true;
- }
-
-private :
-
- KX_VertexParentRelation(
- );
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_VertexParentRelation")
-#endif
-};
-
-
-class KX_SlowParentRelation : public SG_ParentRelation
-{
-
-public :
-
- /**
- * Allocate and construct a new KX_VertexParentRelation
- * on the heap.
- */
-
- static
- KX_SlowParentRelation *
- New(
- MT_Scalar relaxation
- );
-
- /**
- * Method inherited from KX_ParentRelation
- */
-
- bool
- UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
- );
-
- /**
- * Method inherited from KX_ParentRelation
- */
-
- SG_ParentRelation *
- NewCopy(
- );
-
- MT_Scalar
- GetTimeOffset(
- ) { return m_relax; }
-
- void
- SetTimeOffset(
- MT_Scalar relaxation
- ) { m_relax = relaxation; }
-
- ~KX_SlowParentRelation(
- );
-
- bool
- IsSlowRelation(
- ) {
- return true;
- }
-
-private :
-
- KX_SlowParentRelation(
- MT_Scalar relaxation
- );
-
- // the relaxation coefficient.
-
- MT_Scalar m_relax;
-
- /**
- * Looks like a hack flag to me.
- * We need to compute valid world coordinates the first
- * time we update spatial data of the child. This is done
- * by just doing a normal parent relation the first time
- * UpdateChildCoordinates is called and then doing the
- * slow parent relation
- */
-
- bool m_initialized;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_SlowParentRelation")
-#endif
-};
-
-#endif
diff --git a/source/gameengine/Ketsji/KX_ScalarInterpolator.cpp b/source/gameengine/Ketsji/KX_ScalarInterpolator.cpp
deleted file mode 100644
index e234a9621b8..00000000000
--- a/source/gameengine/Ketsji/KX_ScalarInterpolator.cpp
+++ /dev/null
@@ -1,39 +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_ScalarInterpolator.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_ScalarInterpolator.h"
-#include "KX_IScalarInterpolator.h"
-
-void KX_ScalarInterpolator::Execute(float currentTime) const
-{
- *m_target = m_ipo->GetValue(currentTime);
-}
diff --git a/source/gameengine/Ketsji/KX_ScalarInterpolator.h b/source/gameengine/Ketsji/KX_ScalarInterpolator.h
deleted file mode 100644
index 5d8c3163376..00000000000
--- a/source/gameengine/Ketsji/KX_ScalarInterpolator.h
+++ /dev/null
@@ -1,69 +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_ScalarInterpolator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_SCALARINTERPOLATOR_H__
-#define __KX_SCALARINTERPOLATOR_H__
-
-#include "MT_Scalar.h"
-#include "KX_IInterpolator.h"
-
-class KX_IScalarInterpolator;
-
-class KX_ScalarInterpolator : public KX_IInterpolator {
-public:
- KX_ScalarInterpolator(MT_Scalar* target,
- KX_IScalarInterpolator *ipo) :
- m_target(target),
- m_ipo(ipo)
- {}
-
- virtual ~KX_ScalarInterpolator() {}
- virtual void Execute(float currentTime) const;
- void SetNewTarget(MT_Scalar* newtarget)
- {
- m_target=newtarget;
- }
- MT_Scalar* GetTarget()
- {
- return m_target;
- }
-private:
- MT_Scalar* m_target;
- KX_IScalarInterpolator *m_ipo;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ScalarInterpolator")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_ScalingInterpolator.cpp b/source/gameengine/Ketsji/KX_ScalingInterpolator.cpp
deleted file mode 100644
index dd40cbd22fd..00000000000
--- a/source/gameengine/Ketsji/KX_ScalingInterpolator.cpp
+++ /dev/null
@@ -1,42 +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_ScalingInterpolator.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_ScalingInterpolator.h"
-#include "MT_Vector3.h"
-#include "KX_IScalarInterpolator.h"
-
-void KX_ScalingInterpolator::Execute(float currentTime) const
-{
- m_target.setValue(m_ipos[0]->GetValue(currentTime),
- m_ipos[1]->GetValue(currentTime),
- m_ipos[2]->GetValue(currentTime));
-}
diff --git a/source/gameengine/Ketsji/KX_ScalingInterpolator.h b/source/gameengine/Ketsji/KX_ScalingInterpolator.h
deleted file mode 100644
index 52b6d0cf8cc..00000000000
--- a/source/gameengine/Ketsji/KX_ScalingInterpolator.h
+++ /dev/null
@@ -1,64 +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_ScalingInterpolator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_SCALINGINTERPOLATOR_H__
-#define __KX_SCALINGINTERPOLATOR_H__
-
-#include "KX_IInterpolator.h"
-
-class MT_Vector3;
-class KX_IScalarInterpolator;
-
-class KX_ScalingInterpolator : public KX_IInterpolator {
-public:
- KX_ScalingInterpolator(MT_Vector3& target,
- KX_IScalarInterpolator *ipos[])
- : m_target(target)
- {
- m_ipos[0] = ipos[0];
- m_ipos[1] = ipos[1];
- m_ipos[2] = ipos[2];
- }
-
- virtual void Execute(float currentTime) const;
-
-private:
- MT_Vector3& m_target;
- KX_IScalarInterpolator *m_ipos[3];
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ScalingInterpolator")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
deleted file mode 100644
index 0e6b04c6df5..00000000000
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ /dev/null
@@ -1,2644 +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 *****
- * Ketsji scene. Holds references to all scene data.
- */
-
-/** \file gameengine/Ketsji/KX_Scene.cpp
- * \ingroup ketsji
- */
-
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include <stdio.h>
-
-#include "KX_Scene.h"
-#include "KX_PythonInit.h"
-#include "MT_assert.h"
-#include "KX_KetsjiEngine.h"
-#include "KX_BlenderMaterial.h"
-#include "KX_FontObject.h"
-#include "RAS_IPolygonMaterial.h"
-#include "EXP_ListValue.h"
-#include "SCA_LogicManager.h"
-#include "SCA_TimeEventManager.h"
-//#include "SCA_AlwaysEventManager.h"
-//#include "SCA_RandomEventManager.h"
-//#include "KX_RayEventManager.h"
-#include "SCA_2DFilterActuator.h"
-#include "SCA_PythonController.h"
-#include "KX_TouchEventManager.h"
-#include "SCA_KeyboardManager.h"
-#include "SCA_MouseManager.h"
-//#include "SCA_PropertyEventManager.h"
-#include "SCA_ActuatorEventManager.h"
-#include "SCA_BasicEventManager.h"
-#include "KX_Camera.h"
-#include "SCA_JoystickManager.h"
-#include "KX_PyMath.h"
-#include "RAS_MeshObject.h"
-#include "SCA_IScene.h"
-
-#include "RAS_IRasterizer.h"
-#include "RAS_ICanvas.h"
-#include "RAS_BucketManager.h"
-
-#include "EXP_FloatValue.h"
-#include "SCA_IController.h"
-#include "SCA_IActuator.h"
-#include "SG_Node.h"
-#include "BL_System.h"
-#include "SG_Controller.h"
-#include "SG_IObject.h"
-#include "SG_Tree.h"
-#include "DNA_group_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_property_types.h"
-
-#include "KX_SG_NodeRelationships.h"
-
-#include "KX_NetworkEventManager.h"
-#include "NG_NetworkScene.h"
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_IGraphicController.h"
-#include "PHY_IPhysicsController.h"
-#include "KX_BlenderSceneConverter.h"
-#include "KX_MotionState.h"
-
-#include "BL_ModifierDeformer.h"
-#include "BL_ShapeDeformer.h"
-#include "BL_DeformableGameObject.h"
-#include "KX_ObstacleSimulation.h"
-
-#ifdef WITH_BULLET
-# include "KX_SoftBodyDeformer.h"
-#endif
-
-#ifdef WITH_PYTHON
-# include "EXP_PythonCallBack.h"
-#endif
-
-#include "KX_Light.h"
-
-#include "BKE_group.h"
-#include "BLI_task.h"
-
-static void *KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene)
-{
- KX_GameObject* replica = ((KX_Scene*)scene)->AddNodeReplicaObject(node,(KX_GameObject*)gameobj);
-
- if (replica)
- replica->Release();
-
- return (void*)replica;
-}
-
-static void *KX_SceneDestructionFunc(SG_IObject* node,void* gameobj,void* scene)
-{
- ((KX_Scene*)scene)->RemoveNodeDestructObject(node,(KX_GameObject*)gameobj);
-
- return NULL;
-};
-
-bool KX_Scene::KX_ScenegraphUpdateFunc(SG_IObject* node,void* gameobj,void* scene)
-{
- return ((SG_Node*)node)->Schedule(((KX_Scene*)scene)->m_sghead);
-}
-
-bool KX_Scene::KX_ScenegraphRescheduleFunc(SG_IObject* node,void* gameobj,void* scene)
-{
- return ((SG_Node*)node)->Reschedule(((KX_Scene*)scene)->m_sghead);
-}
-
-SG_Callbacks KX_Scene::m_callbacks = SG_Callbacks(
- KX_SceneReplicationFunc,
- KX_SceneDestructionFunc,
- KX_GameObject::UpdateTransformFunc,
- KX_Scene::KX_ScenegraphUpdateFunc,
- KX_Scene::KX_ScenegraphRescheduleFunc);
-
-// temporarily var until there is a button in the userinterface
-// (defined in KX_PythonInit.cpp)
-extern bool gUseVisibilityTemp;
-
-KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
- class SCA_IInputDevice* mousedevice,
- class NG_NetworkDeviceInterface *ndi,
- const STR_String& sceneName,
- Scene *scene,
- class RAS_ICanvas* canvas):
- PyObjectPlus(),
- m_keyboardmgr(NULL),
- m_mousemgr(NULL),
- m_sceneConverter(NULL),
- m_physicsEnvironment(0),
- m_sceneName(sceneName),
- m_networkDeviceInterface(ndi),
- m_active_camera(NULL),
- m_ueberExecutionPriority(0),
- m_blenderScene(scene),
- m_isActivedHysteresis(false),
- m_lodHysteresisValue(0)
-{
- m_suspendedtime = 0.0;
- m_suspendeddelta = 0.0;
-
- m_dbvt_culling = false;
- m_dbvt_occlusion_res = 0;
- m_activity_culling = false;
- m_suspend = false;
- m_isclearingZbuffer = true;
- m_isShadowDone = false;
- m_tempObjectList = new CListValue();
- m_objectlist = new CListValue();
- m_parentlist = new CListValue();
- m_lightlist= new CListValue();
- m_inactivelist = new CListValue();
- m_euthanasyobjects = new CListValue();
- m_animatedlist = new CListValue();
-
- m_logicmgr = new SCA_LogicManager();
-
- m_timemgr = new SCA_TimeEventManager(m_logicmgr);
- m_keyboardmgr = new SCA_KeyboardManager(m_logicmgr,keyboarddevice);
- m_mousemgr = new SCA_MouseManager(m_logicmgr,mousedevice, canvas);
-
- //SCA_AlwaysEventManager* alwaysmgr = new SCA_AlwaysEventManager(m_logicmgr);
- //SCA_PropertyEventManager* propmgr = new SCA_PropertyEventManager(m_logicmgr);
- SCA_ActuatorEventManager* actmgr = new SCA_ActuatorEventManager(m_logicmgr);
- //SCA_RandomEventManager* rndmgr = new SCA_RandomEventManager(m_logicmgr);
- SCA_BasicEventManager* basicmgr = new SCA_BasicEventManager(m_logicmgr);
- //KX_RayEventManager* raymgr = new KX_RayEventManager(m_logicmgr);
-
- KX_NetworkEventManager* netmgr = new KX_NetworkEventManager(m_logicmgr, ndi);
-
-
-
- //m_logicmgr->RegisterEventManager(alwaysmgr);
- //m_logicmgr->RegisterEventManager(propmgr);
- m_logicmgr->RegisterEventManager(actmgr);
- m_logicmgr->RegisterEventManager(m_keyboardmgr);
- m_logicmgr->RegisterEventManager(m_mousemgr);
- m_logicmgr->RegisterEventManager(m_timemgr);
- //m_logicmgr->RegisterEventManager(rndmgr);
- //m_logicmgr->RegisterEventManager(raymgr);
- m_logicmgr->RegisterEventManager(netmgr);
- m_logicmgr->RegisterEventManager(basicmgr);
-
-
- SYS_SystemHandle hSystem = SYS_GetSystem();
- bool nojoystick= SYS_GetCommandLineInt(hSystem,"nojoystick",0);
- if (!nojoystick)
- {
- SCA_JoystickManager *joymgr = new SCA_JoystickManager(m_logicmgr);
- m_logicmgr->RegisterEventManager(joymgr);
- }
-
- MT_assert (m_networkDeviceInterface != NULL);
- m_networkScene = new NG_NetworkScene(m_networkDeviceInterface);
-
- m_rootnode = NULL;
-
- m_bucketmanager=new RAS_BucketManager();
-
- bool showObstacleSimulation = (scene->gm.flag & GAME_SHOW_OBSTACLE_SIMULATION) != 0;
- switch (scene->gm.obstacleSimulation)
- {
- case OBSTSIMULATION_TOI_rays:
- m_obstacleSimulation = new KX_ObstacleSimulationTOI_rays((MT_Scalar)scene->gm.levelHeight, showObstacleSimulation);
- break;
- case OBSTSIMULATION_TOI_cells:
- m_obstacleSimulation = new KX_ObstacleSimulationTOI_cells((MT_Scalar)scene->gm.levelHeight, showObstacleSimulation);
- break;
- default:
- m_obstacleSimulation = NULL;
- }
-
-#ifdef WITH_PYTHON
- m_attr_dict = NULL;
- m_draw_call_pre = NULL;
- m_draw_call_post = NULL;
- m_draw_setup_call_pre = NULL;
-#endif
-}
-
-
-
-KX_Scene::~KX_Scene()
-{
- // The release of debug properties used to be in SCA_IScene::~SCA_IScene
- // It's still there but we remove all properties here otherwise some
- // reference might be hanging and causing late release of objects
- RemoveAllDebugProperties();
-
- while (GetRootParentList()->GetCount() > 0)
- {
- KX_GameObject* parentobj = (KX_GameObject*) GetRootParentList()->GetValue(0);
- this->RemoveObject(parentobj);
- }
-
- if (m_obstacleSimulation)
- delete m_obstacleSimulation;
-
- if (m_objectlist)
- m_objectlist->Release();
-
- if (m_parentlist)
- m_parentlist->Release();
-
- if (m_inactivelist)
- m_inactivelist->Release();
-
- if (m_lightlist)
- m_lightlist->Release();
-
- if (m_tempObjectList)
- m_tempObjectList->Release();
-
- if (m_euthanasyobjects)
- m_euthanasyobjects->Release();
-
- if (m_animatedlist)
- m_animatedlist->Release();
-
- if (m_logicmgr)
- delete m_logicmgr;
-
- if (m_physicsEnvironment)
- delete m_physicsEnvironment;
-
- if (m_networkScene)
- delete m_networkScene;
-
- if (m_bucketmanager)
- {
- delete m_bucketmanager;
- }
-
-#ifdef WITH_PYTHON
- if (m_attr_dict) {
- PyDict_Clear(m_attr_dict);
- /* Py_CLEAR: Py_DECREF's and NULL's */
- Py_CLEAR(m_attr_dict);
- }
-
- /* these may be NULL but the macro checks */
- Py_CLEAR(m_draw_call_pre);
- Py_CLEAR(m_draw_call_post);
-#endif
-}
-
-RAS_BucketManager* KX_Scene::GetBucketManager()
-{
- return m_bucketmanager;
-}
-
-
-CListValue* KX_Scene::GetTempObjectList()
-{
- return m_tempObjectList;
-}
-
-CListValue* KX_Scene::GetObjectList()
-{
- return m_objectlist;
-}
-
-
-CListValue* KX_Scene::GetRootParentList()
-{
- return m_parentlist;
-}
-
-CListValue* KX_Scene::GetInactiveList()
-{
- return m_inactivelist;
-}
-
-
-
-CListValue* KX_Scene::GetLightList()
-{
- return m_lightlist;
-}
-
-SCA_LogicManager* KX_Scene::GetLogicManager()
-{
- return m_logicmgr;
-}
-
-SCA_TimeEventManager* KX_Scene::GetTimeEventManager()
-{
- return m_timemgr;
-}
-
-
-
-
-list<class KX_Camera*>* KX_Scene::GetCameras()
-{
- return &m_cameras;
-}
-
-void KX_Scene::SetFramingType(RAS_FrameSettings & frame_settings)
-{
- m_frame_settings = frame_settings;
-};
-
-/**
- * Return a const reference to the framing
- * type set by the above call.
- * The contents are not guaranteed to be sensible
- * if you don't call the above function.
- */
-const RAS_FrameSettings& KX_Scene::GetFramingType() const
-{
- return m_frame_settings;
-};
-
-
-
-/**
- * Store the current scene's viewport on the
- * game engine canvas.
- */
-void KX_Scene::SetSceneViewport(const RAS_Rect &viewport)
-{
- m_viewport = viewport;
-}
-
-
-
-const RAS_Rect& KX_Scene::GetSceneViewport() const
-{
- return m_viewport;
-}
-
-
-
-void KX_Scene::SetWorldInfo(class KX_WorldInfo* worldinfo)
-{
- m_worldinfo = worldinfo;
-}
-
-
-
-class KX_WorldInfo* KX_Scene::GetWorldInfo()
-{
- return m_worldinfo;
-}
-
-
-const STR_String& KX_Scene::GetName()
-{
- return m_sceneName;
-}
-
-
-void KX_Scene::Suspend()
-{
- m_suspend = true;
-}
-
-void KX_Scene::Resume()
-{
- m_suspend = false;
-}
-
-void KX_Scene::SetActivityCulling(bool b)
-{
- m_activity_culling = b;
-}
-
-bool KX_Scene::IsSuspended()
-{
- return m_suspend;
-}
-
-bool KX_Scene::IsClearingZBuffer()
-{
- return m_isclearingZbuffer;
-}
-
-void KX_Scene::EnableZBufferClearing(bool isclearingZbuffer)
-{
- m_isclearingZbuffer = isclearingZbuffer;
-}
-
-void KX_Scene::AddObjectDebugProperties(class KX_GameObject* gameobj)
-{
- Object* blenderobject = gameobj->GetBlenderObject();
- bProperty* prop = (bProperty*)blenderobject->prop.first;
-
- while (prop) {
- if (prop->flag & PROP_DEBUG)
- AddDebugProperty(gameobj,STR_String(prop->name));
- prop = prop->next;
- }
-
- if (blenderobject->scaflag & OB_DEBUGSTATE)
- AddDebugProperty(gameobj,STR_String("__state__"));
-}
-
-void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gameobj)
-{
- KX_GameObject* orgobj = (KX_GameObject*)gameobj;
- if (NewRemoveObject(orgobj) != 0)
- {
- // object is not yet deleted because a reference is hanging somewhere.
- // This should not happen anymore since we use proxy object for Python
- // confident enough to put an assert?
- //assert(false);
- printf("Zombie object! name=%s\n", orgobj->GetName().ReadPtr());
- orgobj->SetSGNode(NULL);
- PHY_IGraphicController* ctrl = orgobj->GetGraphicController();
- if (ctrl)
- {
- // a graphic controller is set, we must delete it as the node will be deleted
- delete ctrl;
- orgobj->SetGraphicController(NULL);
- }
- }
- if (node)
- delete node;
-}
-
-KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CValue* gameobj)
-{
- // for group duplication, limit the duplication of the hierarchy to the
- // objects that are part of the group.
- if (!IsObjectInGroup(gameobj))
- return NULL;
-
- KX_GameObject* orgobj = (KX_GameObject*)gameobj;
- KX_GameObject* newobj = (KX_GameObject*)orgobj->GetReplica();
- m_map_gameobject_to_replica.insert(orgobj, newobj);
-
- // also register 'timers' (time properties) of the replica
- int numprops = newobj->GetPropertyCount();
-
- for (int i = 0; i < numprops; i++)
- {
- CValue* prop = newobj->GetProperty(i);
-
- if (prop->GetProperty("timer"))
- this->m_timemgr->AddTimeProperty(prop);
- }
-
- if (node)
- {
- newobj->SetSGNode((SG_Node*)node);
- }
- else
- {
- m_rootnode = new SG_Node(newobj,this,KX_Scene::m_callbacks);
-
- // this fixes part of the scaling-added object bug
- SG_Node* orgnode = orgobj->GetSGNode();
- m_rootnode->SetLocalScale(orgnode->GetLocalScale());
- m_rootnode->SetLocalPosition(orgnode->GetLocalPosition());
- m_rootnode->SetLocalOrientation(orgnode->GetLocalOrientation());
-
- // define the relationship between this node and it's parent.
- KX_NormalParentRelation * parent_relation =
- KX_NormalParentRelation::New();
- m_rootnode->SetParentRelation(parent_relation);
-
- newobj->SetSGNode(m_rootnode);
- }
-
- SG_IObject* replicanode = newobj->GetSGNode();
-// SG_Node* rootnode = (replicanode == m_rootnode ? NULL : m_rootnode);
-
- replicanode->SetSGClientObject(newobj);
-
- // this is the list of object that are send to the graphics pipeline
- m_objectlist->Add(newobj->AddRef());
- if (newobj->GetGameObjectType()==SCA_IObject::OBJ_LIGHT)
- m_lightlist->Add(newobj->AddRef());
- else if (newobj->GetGameObjectType()==SCA_IObject::OBJ_TEXT)
- AddFont((KX_FontObject*)newobj);
- newobj->AddMeshUser();
-
- // logic cannot be replicated, until the whole hierarchy is replicated.
- m_logicHierarchicalGameObjects.push_back(newobj);
- //replicate controllers of this node
- SGControllerList scenegraphcontrollers = orgobj->GetSGNode()->GetSGControllerList();
- replicanode->RemoveAllControllers();
- SGControllerList::iterator cit;
- //int numcont = scenegraphcontrollers.size();
-
- for (cit = scenegraphcontrollers.begin();!(cit==scenegraphcontrollers.end());++cit)
- {
- // controller replication is quite complicated
- // only replicate ipo controller for now
-
- SG_Controller* replicacontroller = (*cit)->GetReplica((SG_Node*) replicanode);
- if (replicacontroller)
- {
- replicacontroller->SetObject(replicanode);
- replicanode->AddSGController(replicacontroller);
- }
- }
- // replicate graphic controller
- if (orgobj->GetGraphicController())
- {
- PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode());
- PHY_IGraphicController* newctrl = orgobj->GetGraphicController()->GetReplica(motionstate);
- newctrl->SetNewClientInfo(newobj->getClientInfo());
- newobj->SetGraphicController(newctrl);
- }
-
- // 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);
-
- // Child objects must be static
- if (parent)
- newctrl->SuspendDynamics();
- }
-
- return newobj;
-}
-
-
-
-// before calling this method KX_Scene::ReplicateLogic(), make sure to
-// have called 'GameObject::ReParentLogic' for each object this
-// hierarchy that's because first ALL bricks must exist in the new
-// replica of the hierarchy in order to make cross-links work properly
-// !
-// It is VERY important that the order of sensors and actuators in
-// the replicated object is preserved: it is used to reconnect the logic.
-// This method is more robust then using the bricks name in case of complex
-// group replication. The replication of logic bricks is done in
-// SCA_IObject::ReParentLogic(), make sure it preserves the order of the bricks.
-void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
-{
- /* add properties to debug list, for added objects and DupliGroups */
- if (KX_GetActiveEngine()->GetAutoAddDebugProperties()) {
- AddObjectDebugProperties(newobj);
- }
- // also relink the controller to sensors/actuators
- SCA_ControllerList& controllers = newobj->GetControllers();
- //SCA_SensorList& sensors = newobj->GetSensors();
- //SCA_ActuatorList& actuators = newobj->GetActuators();
-
- for (SCA_ControllerList::iterator itc = controllers.begin(); !(itc==controllers.end());itc++)
- {
- SCA_IController* cont = (*itc);
- cont->SetUeberExecutePriority(m_ueberExecutionPriority);
- vector<SCA_ISensor*> linkedsensors = cont->GetLinkedSensors();
- vector<SCA_IActuator*> linkedactuators = cont->GetLinkedActuators();
-
- // disconnect the sensors and actuators
- // do it directly on the list at this controller is not connected to anything at this stage
- cont->GetLinkedSensors().clear();
- cont->GetLinkedActuators().clear();
-
- // now relink each sensor
- for (vector<SCA_ISensor*>::iterator its = linkedsensors.begin();!(its==linkedsensors.end());its++)
- {
- SCA_ISensor* oldsensor = (*its);
- SCA_IObject* oldsensorobj = oldsensor->GetParent();
- SCA_IObject* newsensorobj = NULL;
-
- // the original owner of the sensor has been replicated?
- void **h_obj = m_map_gameobject_to_replica[oldsensorobj];
- if (h_obj)
- newsensorobj = (SCA_IObject*)(*h_obj);
- if (!newsensorobj)
- {
- // 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);
- }
- else
- {
- // yes, then the new sensor has the same position
- SCA_SensorList& sensorlist = oldsensorobj->GetSensors();
- SCA_SensorList::iterator sit;
- SCA_ISensor* newsensor = NULL;
- int sensorpos;
-
- for (sensorpos=0, sit=sensorlist.begin(); sit!=sensorlist.end(); sit++, sensorpos++)
- {
- if ((*sit) == oldsensor)
- {
- newsensor = newsensorobj->GetSensors().at(sensorpos);
- break;
- }
- }
- assert(newsensor != NULL);
- m_logicmgr->RegisterToSensor(cont,newsensor);
- }
- }
-
- // now relink each actuator
- for (vector<SCA_IActuator*>::iterator ita = linkedactuators.begin();!(ita==linkedactuators.end());ita++)
- {
- SCA_IActuator* oldactuator = (*ita);
- SCA_IObject* oldactuatorobj = oldactuator->GetParent();
- SCA_IObject* newactuatorobj = NULL;
-
- // the original owner of the sensor has been replicated?
- void **h_obj = m_map_gameobject_to_replica[oldactuatorobj];
- if (h_obj)
- newactuatorobj = (SCA_IObject*)(*h_obj);
-
- if (!newactuatorobj)
- {
- // 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);
- }
- else
- {
- // yes, then the new sensor has the same position
- SCA_ActuatorList& actuatorlist = oldactuatorobj->GetActuators();
- SCA_ActuatorList::iterator ait;
- SCA_IActuator* newactuator = NULL;
- int actuatorpos;
-
- for (actuatorpos=0, ait=actuatorlist.begin(); ait!=actuatorlist.end(); ait++, actuatorpos++)
- {
- if ((*ait) == oldactuator)
- {
- newactuator = newactuatorobj->GetActuators().at(actuatorpos);
- break;
- }
- }
- assert(newactuator != NULL);
- m_logicmgr->RegisterToActuator(cont,newactuator);
- newactuator->SetUeberExecutePriority(m_ueberExecutionPriority);
- }
- }
- }
- // ready to set initial state
- newobj->ResetState();
-}
-
-void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
-{
- KX_GameObject* groupobj = (KX_GameObject*) obj;
- KX_GameObject* replica;
- KX_GameObject* gameobj;
- Object* blgroupobj = groupobj->GetBlenderObject();
- Group* group;
- vector<KX_GameObject*> duplilist;
-
- if (!groupobj->GetSGNode() ||
- !groupobj->IsDupliGroup() ||
- level>MAX_DUPLI_RECUR)
- return;
-
- // we will add one group at a time
- m_logicHierarchicalGameObjects.clear();
- m_map_gameobject_to_replica.clear();
- m_ueberExecutionPriority++;
- // for groups will do something special:
- // we will force the creation of objects to those in the group only
- // Again, this is match what Blender is doing (it doesn't care of parent relationship)
- m_groupGameObjects.clear();
-
- group = blgroupobj->dup_group;
- FOREACH_GROUP_BASE_BEGIN(group, base)
- {
- Object *blenderobj = base->object;
- if (blgroupobj == blenderobj)
- // this check is also in group_duplilist()
- continue;
-
- gameobj = (KX_GameObject*)m_logicmgr->FindGameObjByBlendObj(blenderobj);
- if (gameobj == NULL)
- {
- // this object has not been converted!!!
- // Should not happen as dupli group are created automatically
- continue;
- }
-
- gameobj->SetBlenderGroupObject(blgroupobj);
-
- if ((base->flag & BASE_VISIBLED) == 0) {
- // object is not visible in the 3D view, will not be instantiated
- continue;
- }
- m_groupGameObjects.insert(gameobj);
- }
- FOREACH_GROUP_BASE_END;
-
- set<CValue*>::iterator oit;
- for (oit=m_groupGameObjects.begin(); oit != m_groupGameObjects.end(); oit++)
- {
- gameobj = (KX_GameObject*)(*oit);
-
- KX_GameObject *parent = gameobj->GetParent();
- if (parent != NULL)
- {
- // this object is not a top parent. Either it is the child of another
- // object in the group and it will be added automatically when the parent
- // is added. Or it is the child of an object outside the group and the group
- // is inconsistent, skip it anyway
- continue;
- }
- replica = (KX_GameObject*) AddNodeReplicaObject(NULL,gameobj);
- // add to 'rootparent' list (this is the list of top hierarchy objects, updated each frame)
- m_parentlist->Add(replica->AddRef());
-
- // recurse replication into children nodes
- NodeList& children = gameobj->GetSGNode()->GetSGChildren();
-
- replica->GetSGNode()->ClearSGChildren();
- for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
- {
- SG_Node* orgnode = (*childit);
- SG_Node* childreplicanode = orgnode->GetSGReplica();
- if (childreplicanode)
- replica->GetSGNode()->AddChild(childreplicanode);
- }
- // don't replicate logic now: we assume that the objects in the group can have
- // logic relationship, even outside parent relationship
- // In order to match 3D view, the position of groupobj is used as a
- // transformation matrix instead of the new position. This means that
- // the group reference point is 0,0,0
-
- // get the rootnode's scale
- MT_Vector3 newscale = groupobj->NodeGetWorldScaling();
- // set the replica's relative scale with the rootnode's scale
- replica->NodeSetRelativeScale(newscale);
-
- MT_Point3 offset(group->dupli_ofs);
- MT_Point3 newpos = groupobj->NodeGetWorldPosition() +
- newscale*(groupobj->NodeGetWorldOrientation() * (gameobj->NodeGetWorldPosition()-offset));
- replica->NodeSetLocalPosition(newpos);
- // set the orientation after position for softbody!
- MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldOrientation();
- replica->NodeSetLocalOrientation(newori);
- // update scenegraph for entire tree of children
- replica->GetSGNode()->UpdateWorldData(0);
- replica->GetSGNode()->SetBBox(gameobj->GetSGNode()->BBox());
- replica->GetSGNode()->SetRadius(gameobj->GetSGNode()->Radius());
- // we can now add the graphic controller to the physic engine
- replica->ActivateGraphicController(true);
-
- // done with replica
- replica->Release();
- }
-
- // the logic must be replicated first because we need
- // the new logic bricks before relinking
- vector<KX_GameObject*>::iterator git;
- for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
- {
- (*git)->ReParentLogic();
- }
-
- // relink any pointers as necessary, sort of a temporary solution
- for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
- {
- // this will also relink the actuator to objects within the hierarchy
- (*git)->Relink(&m_map_gameobject_to_replica);
- // add the object in the layer of the parent
- (*git)->SetLayer(groupobj->GetLayer());
- }
-
- // replicate crosslinks etc. between logic bricks
- for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
- {
- ReplicateLogic((*git));
- }
-
- // now look if object in the hierarchy have dupli group and recurse
- for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
- {
- /* Replicate all constraints. */
- if ((*git)->GetPhysicsController()) {
- (*git)->GetPhysicsController()->ReplicateConstraints((*git), m_logicHierarchicalGameObjects);
- (*git)->ClearConstraints();
- }
-
- if ((*git) != groupobj && (*git)->IsDupliGroup())
- // can't instantiate group immediately as it destroys m_logicHierarchicalGameObjects
- duplilist.push_back((*git));
-
- if ((*git)->GetBlenderGroupObject() == blgroupobj) {
- // set references for dupli-group
- // groupobj holds a list of all objects, that belongs to this group
- groupobj->AddInstanceObjects((*git));
-
- // every object gets the reference to its dupli-group object
- (*git)->SetDupliGroupObject(groupobj);
- }
- }
-
- for (git = duplilist.begin(); !(git == duplilist.end()); ++git)
- {
- DupliGroupRecurse((*git), level+1);
- }
-}
-
-
-SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
- class CValue* referenceobject,
- int lifespan)
-{
-
- m_logicHierarchicalGameObjects.clear();
- m_map_gameobject_to_replica.clear();
- m_groupGameObjects.clear();
-
- KX_GameObject* originalobj = (KX_GameObject*) originalobject;
- KX_GameObject* referenceobj = (KX_GameObject*) referenceobject;
-
- m_ueberExecutionPriority++;
-
- // lets create a replica
- KX_GameObject* replica = (KX_GameObject*) AddNodeReplicaObject(NULL,originalobj);
-
- // add a timebomb to this object
- // lifespan of zero means 'this object lives forever'
- if (lifespan > 0)
- {
- // for now, convert between so called frames and realtime
- m_tempObjectList->Add(replica->AddRef());
- // this convert the life from frames to sort-of seconds, hard coded 0.02 that assumes we have 50 frames per second
- // if you change this value, make sure you change it in KX_GameObject::pyattr_get_life property too
- CValue *fval = new CFloatValue(lifespan*0.02f);
- replica->SetProperty("::timebomb",fval);
- fval->Release();
- }
-
- // add to 'rootparent' list (this is the list of top hierarchy objects, updated each frame)
- m_parentlist->Add(replica->AddRef());
-
- // recurse replication into children nodes
-
- NodeList& children = originalobj->GetSGNode()->GetSGChildren();
-
- replica->GetSGNode()->ClearSGChildren();
- for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
- {
- SG_Node* orgnode = (*childit);
- SG_Node* childreplicanode = orgnode->GetSGReplica();
- if (childreplicanode)
- replica->GetSGNode()->AddChild(childreplicanode);
- }
-
- if (referenceobj) {
- // At this stage all the objects in the hierarchy have been duplicated,
- // we can update the scenegraph, we need it for the duplication of logic
- MT_Point3 newpos = referenceobj->NodeGetWorldPosition();
- replica->NodeSetLocalPosition(newpos);
-
- MT_Matrix3x3 newori = referenceobj->NodeGetWorldOrientation();
- replica->NodeSetLocalOrientation(newori);
-
- // get the rootnode's scale
- MT_Vector3 newscale = referenceobj->GetSGNode()->GetRootSGParent()->GetLocalScale();
- // set the replica's relative scale with the rootnode's scale
- replica->NodeSetRelativeScale(newscale);
- }
-
- replica->GetSGNode()->UpdateWorldData(0);
- replica->GetSGNode()->SetBBox(originalobj->GetSGNode()->BBox());
- replica->GetSGNode()->SetRadius(originalobj->GetSGNode()->Radius());
- // the size is correct, we can add the graphic controller to the physic engine
- replica->ActivateGraphicController(true);
-
- // now replicate logic
- vector<KX_GameObject*>::iterator git;
- for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
- {
- (*git)->ReParentLogic();
- }
-
- // relink any pointers as necessary, sort of a temporary solution
- for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
- {
- // this will also relink the actuators in the hierarchy
- (*git)->Relink(&m_map_gameobject_to_replica);
- if (referenceobj) {
- // add the object in the layer of the reference object
- (*git)->SetLayer(referenceobj->GetLayer());
- }
- else {
- // We don't know what layer set, so we set all visible layers in the blender scene.
- (*git)->SetLayer(m_blenderScene->lay);
- }
- }
-
- // replicate crosslinks etc. between logic bricks
- for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
- {
- ReplicateLogic((*git));
- }
-
- // check if there are objects with dupligroup in the hierarchy
- vector<KX_GameObject*> duplilist;
- for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
- {
- if ((*git)->IsDupliGroup())
- {
- // separate list as m_logicHierarchicalGameObjects is also used by DupliGroupRecurse()
- duplilist.push_back(*git);
- }
- }
- for (git = duplilist.begin();!(git==duplilist.end());++git)
- {
- DupliGroupRecurse(*git, 0);
- }
- // don't release replica here because we are returning it, not done with it...
- return replica;
-}
-
-
-
-void KX_Scene::RemoveObject(class CValue* gameobj)
-{
- KX_GameObject* newobj = (KX_GameObject*) gameobj;
-
- // disconnect child from parent
- SG_Node* node = newobj->GetSGNode();
-
- if (node)
- {
- node->DisconnectFromParent();
-
- // recursively destruct
- node->Destruct();
- }
- //no need to do that: the object is destroyed and memory released
- //newobj->SetSGNode(0);
-}
-
-void KX_Scene::RemoveDupliGroup(class CValue *gameobj)
-{
- KX_GameObject *newobj = (KX_GameObject *) gameobj;
-
- if (newobj->IsDupliGroup()) {
- for (int i = 0; i < newobj->GetInstanceObjects()->GetCount(); i++) {
- CValue *obj = newobj->GetInstanceObjects()->GetValue(i);
- DelayedRemoveObject(obj);
- }
- }
-}
-
-void KX_Scene::DelayedRemoveObject(class CValue* gameobj)
-{
- RemoveDupliGroup(gameobj);
-
- if (!m_euthanasyobjects->SearchValue(gameobj))
- {
- m_euthanasyobjects->Add(gameobj->AddRef());
- }
-}
-
-int KX_Scene::NewRemoveObject(class CValue* gameobj)
-{
- int ret;
- KX_GameObject* newobj = (KX_GameObject*) gameobj;
-
- /* remove property from debug list */
- RemoveObjectDebugProperties(newobj);
-
- /* Invalidate the python reference, since the object may exist in script lists
- * its possible that it wont be automatically invalidated, so do it manually here,
- *
- * if for some reason the object is added back into the scene python can always get a new Proxy
- */
- newobj->InvalidateProxy();
-
- // keep the blender->game object association up to date
- // note that all the replicas of an object will have the same
- // blender object, that's why we need to check the game object
- // as only the deletion of the original object must be recorded
- m_logicmgr->UnregisterGameObj(newobj->GetBlenderObject(), gameobj);
-
- //todo: look at this
- //GetPhysicsEnvironment()->RemovePhysicsController(gameobj->getPhysicsController());
-
- // remove all sensors/controllers/actuators from logicsystem...
-
- SCA_SensorList& sensors = newobj->GetSensors();
- for (SCA_SensorList::iterator its = sensors.begin();
- !(its==sensors.end());its++)
- {
- m_logicmgr->RemoveSensor(*its);
- }
-
- SCA_ControllerList& controllers = newobj->GetControllers();
- for (SCA_ControllerList::iterator itc = controllers.begin();
- !(itc==controllers.end());itc++)
- {
- m_logicmgr->RemoveController(*itc);
- (*itc)->ReParent(NULL);
- }
-
- SCA_ActuatorList& actuators = newobj->GetActuators();
- for (SCA_ActuatorList::iterator ita = actuators.begin();
- !(ita==actuators.end());ita++)
- {
- m_logicmgr->RemoveActuator(*ita);
- }
- // the sensors/controllers/actuators must also be released, this is done in ~SCA_IObject
-
- // now remove the timer properties from the time manager
- int numprops = newobj->GetPropertyCount();
-
- for (int i = 0; i < numprops; i++)
- {
- CValue* propval = newobj->GetProperty(i);
- if (propval->GetProperty("timer"))
- {
- m_timemgr->RemoveTimeProperty(propval);
- }
- }
-
- // if the object is the dupligroup proxy, you have to cleanup all m_pDupliGroupObject's in all
- // instances refering to this group
- if (newobj->GetInstanceObjects()) {
- for (int i = 0; i < newobj->GetInstanceObjects()->GetCount(); i++) {
- KX_GameObject* instance = (KX_GameObject*)newobj->GetInstanceObjects()->GetValue(i);
- instance->RemoveDupliGroupObject();
- }
- }
-
- // if this object was part of a group, make sure to remove it from that group's instance list
- KX_GameObject* group = newobj->GetDupliGroupObject();
- if (group)
- group->RemoveInstanceObject(newobj);
-
- newobj->RemoveMeshes();
-
- switch (newobj->GetGameObjectType()) {
- case SCA_IObject::OBJ_CAMERA:
- m_cameras.remove((KX_Camera *)newobj);
- break;
- case SCA_IObject::OBJ_TEXT:
- m_fonts.remove((KX_FontObject *)newobj);
- break;
- }
-
- ret = 1;
- if (newobj->GetGameObjectType()==SCA_IObject::OBJ_LIGHT && m_lightlist->RemoveValue(newobj))
- ret = newobj->Release();
- if (m_objectlist->RemoveValue(newobj))
- ret = newobj->Release();
- if (m_tempObjectList->RemoveValue(newobj))
- ret = newobj->Release();
- if (m_parentlist->RemoveValue(newobj))
- ret = newobj->Release();
- if (m_inactivelist->RemoveValue(newobj))
- ret = newobj->Release();
- if (m_euthanasyobjects->RemoveValue(newobj))
- ret = newobj->Release();
- if (m_animatedlist->RemoveValue(newobj))
- ret = newobj->Release();
-
- /* Warning 'newobj' maye be freed now, only compare, don't access */
-
-
- if (newobj == m_active_camera)
- {
- //no AddRef done on m_active_camera so no Release
- //m_active_camera->Release();
- m_active_camera = NULL;
- }
-
- /* currently does nothing, keep in case we need to Unregister something */
-#if 0
- if (m_sceneConverter)
- m_sceneConverter->UnregisterGameObject(newobj);
-#endif
-
- // return value will be 0 if the object is actually deleted (all reference gone)
-
- return ret;
-}
-
-
-
-void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool use_phys)
-{
- KX_GameObject* gameobj = static_cast<KX_GameObject*>(obj);
- RAS_MeshObject* mesh = static_cast<RAS_MeshObject*>(meshobj);
-
- if (!gameobj) {
- std::cout << "KX_Scene::ReplaceMesh Warning: invalid object, doing nothing" << std::endl;
- return;
- }
-
- if (use_gfx && mesh != NULL)
- {
- gameobj->RemoveMeshes();
- gameobj->AddMesh(mesh);
-
- if (gameobj->m_isDeformable)
- {
- BL_DeformableGameObject* newobj = static_cast<BL_DeformableGameObject*>( gameobj );
-
- if (newobj->GetDeformer())
- {
- delete newobj->GetDeformer();
- newobj->SetDeformer(NULL);
- }
-
- if (mesh->GetMesh())
- {
- // we must create a new deformer but which one?
- KX_GameObject* parentobj = newobj->GetParent();
- // this always return the original game object (also for replicate)
- Object* blendobj = newobj->GetBlenderObject();
- // object that owns the new mesh
- Object* oldblendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName()));
- Mesh* blendmesh = mesh->GetMesh();
-
- bool bHasModifier = BL_ModifierDeformer::HasCompatibleDeformer(blendobj);
- bool bHasShapeKey = blendmesh->key != NULL && blendmesh->key->type==KEY_RELATIVE;
- bool bHasDvert = blendmesh->dvert != NULL;
- bool bHasArmature =
- BL_ModifierDeformer::HasArmatureDeformer(blendobj) &&
- parentobj && // current parent is armature
- parentobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE &&
- oldblendobj && // needed for mesh deform
- blendobj->parent && // original object had armature (not sure this test is needed)
- blendobj->parent->type == OB_ARMATURE &&
- blendmesh->dvert!=NULL; // mesh has vertex group
-#ifdef WITH_BULLET
- bool bHasSoftBody = (!parentobj && (blendobj->gameflag & OB_SOFT_BODY));
-#endif
-
- if (oldblendobj==NULL) {
- if (bHasModifier || bHasShapeKey || bHasDvert || bHasArmature) {
- std::cout << "warning: ReplaceMesh() new mesh is not used in an object from the current scene, you will get incorrect behavior" << std::endl;
- bHasShapeKey= bHasDvert= bHasArmature=bHasModifier= false;
- }
- }
-
- if (bHasModifier)
- {
- BL_ModifierDeformer* modifierDeformer;
- if (bHasShapeKey || bHasArmature)
- {
- modifierDeformer = new BL_ModifierDeformer(
- newobj,
- m_blenderScene,
- oldblendobj, blendobj,
- mesh,
- true,
- static_cast<BL_ArmatureObject*>( parentobj->AddRef() )
- );
- modifierDeformer->LoadShapeDrivers(parentobj);
- }
- else
- {
- modifierDeformer = new BL_ModifierDeformer(
- newobj,
- m_blenderScene,
- oldblendobj, blendobj,
- mesh,
- false,
- NULL
- );
- }
- newobj->SetDeformer(modifierDeformer);
- }
- else if (bHasShapeKey) {
- BL_ShapeDeformer* shapeDeformer;
- if (bHasArmature)
- {
- shapeDeformer = new BL_ShapeDeformer(
- newobj,
- oldblendobj, blendobj,
- mesh,
- true,
- true,
- static_cast<BL_ArmatureObject*>( parentobj->AddRef() )
- );
- shapeDeformer->LoadShapeDrivers(parentobj);
- }
- else
- {
- shapeDeformer = new BL_ShapeDeformer(
- newobj,
- oldblendobj, blendobj,
- mesh,
- false,
- true,
- NULL
- );
- }
- newobj->SetDeformer( shapeDeformer);
- }
- else if (bHasArmature)
- {
- BL_SkinDeformer* skinDeformer = new BL_SkinDeformer(
- newobj,
- oldblendobj, blendobj,
- mesh,
- true,
- true,
- static_cast<BL_ArmatureObject*>( parentobj->AddRef() )
- );
- newobj->SetDeformer(skinDeformer);
- }
- else if (bHasDvert)
- {
- BL_MeshDeformer* meshdeformer = new BL_MeshDeformer(
- newobj, oldblendobj, mesh
- );
- newobj->SetDeformer(meshdeformer);
- }
-#ifdef WITH_BULLET
- else if (bHasSoftBody)
- {
- KX_SoftBodyDeformer *softdeformer = new KX_SoftBodyDeformer(mesh, newobj);
- newobj->SetDeformer(softdeformer);
- }
-#endif
- }
- }
-
- gameobj->AddMeshUser();
- }
-
- if (use_phys) { /* update the new assigned mesh with the physics mesh */
- if (gameobj->GetPhysicsController())
- gameobj->GetPhysicsController()->ReinstancePhysicsShape(NULL, use_gfx?NULL:mesh);
- }
-}
-
-/* Font Object routines */
-void KX_Scene::AddFont(KX_FontObject* font)
-{
- if (!FindFont(font))
- m_fonts.push_back(font);
-}
-
-KX_FontObject* KX_Scene::FindFont(KX_FontObject* font)
-{
- list<KX_FontObject*>::iterator it = m_fonts.begin();
-
- while ((it != m_fonts.end()) && ((*it) != font))
- {
- ++it;
- }
-
- return ((it == m_fonts.end()) ? NULL : (*it));
-}
-
-
-/* Camera Object routines */
-KX_Camera* KX_Scene::FindCamera(KX_Camera* cam)
-{
- list<KX_Camera*>::iterator it = m_cameras.begin();
-
- while ((it != m_cameras.end()) && ((*it) != cam)) {
- it++;
- }
-
- return ((it == m_cameras.end()) ? NULL : (*it));
-}
-
-
-KX_Camera* KX_Scene::FindCamera(STR_String& name)
-{
- list<KX_Camera*>::iterator it = m_cameras.begin();
-
- while ((it != m_cameras.end()) && ((*it)->GetName() != name)) {
- it++;
- }
-
- return ((it == m_cameras.end()) ? NULL : (*it));
-}
-
-void KX_Scene::AddCamera(KX_Camera* cam)
-{
- if (!FindCamera(cam))
- m_cameras.push_back(cam);
-}
-
-
-KX_Camera* KX_Scene::GetActiveCamera()
-{
- // NULL if not defined
- return m_active_camera;
-}
-
-
-void KX_Scene::SetActiveCamera(KX_Camera* cam)
-{
- // only set if the cam is in the active list? Or add it otherwise?
- if (!FindCamera(cam)) {
- AddCamera(cam);
- if (cam) std::cout << "Added cam " << cam->GetName() << std::endl;
- }
-
- m_active_camera = cam;
-}
-
-void KX_Scene::SetCameraOnTop(KX_Camera* cam)
-{
- if (!FindCamera(cam)) {
- // adding is always done at the back, so that's all that needs to be done
- AddCamera(cam);
- if (cam) std::cout << "Added cam " << cam->GetName() << std::endl;
- } else {
- m_cameras.remove(cam);
- m_cameras.push_back(cam);
- }
-}
-
-void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera* cam, int layer)
-{
- int intersect = KX_Camera::INTERSECT;
- KX_GameObject *gameobj = node->Client()?(KX_GameObject*) node->Client()->GetSGClientObject():NULL;
- bool visible = (gameobj && gameobj->GetVisible() && (!layer || (gameobj->GetLayer() & layer)));
- bool dotest = visible || node->Left() || node->Right();
-
- /* If the camera is inside the box, assume intersect. */
- if (dotest && !node->inside( cam->NodeGetWorldPosition()))
- {
- MT_Scalar radius = node->Radius();
- MT_Point3 center = node->Center();
-
- intersect = cam->SphereInsideFrustum(center, radius);
-
- if (intersect == KX_Camera::INTERSECT)
- {
- MT_Point3 box[8];
- node->get(box);
- intersect = cam->BoxInsideFrustum(box);
- }
- }
-
- switch (intersect)
- {
- case KX_Camera::OUTSIDE:
- MarkSubTreeVisible(node, rasty, false, cam);
- break;
- case KX_Camera::INTERSECT:
- if (gameobj)
- MarkVisible(rasty, gameobj, cam, layer);
- if (node->Left())
- MarkVisible(node->Left(), rasty, cam, layer);
- if (node->Right())
- MarkVisible(node->Right(), rasty, cam, layer);
- break;
- case KX_Camera::INSIDE:
- MarkSubTreeVisible(node, rasty, true, cam, layer);
- break;
- }
-}
-
-void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible, KX_Camera* cam, int layer)
-{
- if (node->Client())
- {
- KX_GameObject *gameobj = (KX_GameObject*) node->Client()->GetSGClientObject();
- if (gameobj->GetVisible())
- {
- if (visible)
- {
- int nummeshes = gameobj->GetMeshCount();
-
- // this adds the vertices to the display list
- for (int m=0;m<nummeshes;m++)
- (gameobj->GetMesh(m))->SchedulePolygons(rasty->GetDrawingMode());
- }
-
- gameobj->SetCulled(!visible);
- gameobj->UpdateBuckets(false);
- }
- }
- if (node->Left())
- MarkSubTreeVisible(node->Left(), rasty, visible, cam, layer);
- if (node->Right())
- MarkSubTreeVisible(node->Right(), rasty, visible, cam, layer);
-}
-
-void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Camera* cam,int layer)
-{
- // User (Python/Actuator) has forced object invisible...
- if (!gameobj->GetSGNode() || !gameobj->GetVisible())
- return;
-
- // Shadow lamp layers
- if (layer && !(gameobj->GetLayer() & layer)) {
- gameobj->SetCulled(true);
- gameobj->UpdateBuckets(false);
- return;
- }
-
- // If Frustum culling is off, the object is always visible.
- bool vis = !cam->GetFrustumCulling();
-
- // If the camera is inside this node, then the object is visible.
- if (!vis)
- {
- vis = gameobj->GetSGNode()->inside( cam->GetCameraLocation() );
- }
-
- // Test the object's bound sphere against the view frustum.
- if (!vis)
- {
- MT_Vector3 scale = gameobj->GetSGNode()->GetWorldScaling();
- MT_Scalar radius = fabs(scale[scale.closestAxis()] * gameobj->GetSGNode()->Radius());
- switch (cam->SphereInsideFrustum(gameobj->NodeGetWorldPosition(), radius))
- {
- case KX_Camera::INSIDE:
- vis = true;
- break;
- case KX_Camera::OUTSIDE:
- vis = false;
- break;
- case KX_Camera::INTERSECT:
- // Test the object's bound box against the view frustum.
- MT_Point3 box[8];
- gameobj->GetSGNode()->getBBox(box);
- vis = cam->BoxInsideFrustum(box) != KX_Camera::OUTSIDE;
- break;
- }
- }
-
- if (vis)
- {
- int nummeshes = gameobj->GetMeshCount();
-
- for (int m=0;m<nummeshes;m++)
- {
- // this adds the vertices to the display list
- (gameobj->GetMesh(m))->SchedulePolygons(rasty->GetDrawingMode());
- }
- // Visibility/ non-visibility are marked
- // elsewhere now.
- gameobj->SetCulled(false);
- gameobj->UpdateBuckets(false);
- } else {
- gameobj->SetCulled(true);
- gameobj->UpdateBuckets(false);
- }
-}
-
-void KX_Scene::PhysicsCullingCallback(KX_ClientObjectInfo *objectInfo, void* cullingInfo)
-{
- KX_GameObject* gameobj = objectInfo->m_gameobject;
- if (!gameobj->GetVisible())
- // ideally, invisible objects should be removed from the culling tree temporarily
- return;
- if (((CullingInfo*)cullingInfo)->m_layer && !(gameobj->GetLayer() & ((CullingInfo*)cullingInfo)->m_layer))
- // used for shadow: object is not in shadow layer
- return;
-
- // make object visible
- gameobj->SetCulled(false);
- gameobj->UpdateBuckets(false);
-}
-
-void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int layer)
-{
- bool dbvt_culling = false;
- if (m_dbvt_culling)
- {
- /* Reset KX_GameObject m_bCulled to true before doing culling
- * since DBVT culling will only set it to false.
- * This is similar to what RAS_BucketManager does for RAS_MeshSlot culling.
- */
- for (int i = 0; i < m_objectlist->GetCount(); i++) {
- KX_GameObject *gameobj = static_cast<KX_GameObject*>(m_objectlist->GetValue(i));
- gameobj->SetCulled(true);
- }
-
- // test culling through Bullet
- MT_Vector4 planes[6];
- // get the clip planes
- MT_Vector4* cplanes = cam->GetNormalizedClipPlanes();
- // and convert
- planes[0].setValue(cplanes[4].getValue()); // near
- planes[1].setValue(cplanes[5].getValue()); // far
- planes[2].setValue(cplanes[0].getValue()); // left
- planes[3].setValue(cplanes[1].getValue()); // right
- planes[4].setValue(cplanes[2].getValue()); // top
- planes[5].setValue(cplanes[3].getValue()); // bottom
- CullingInfo info(layer);
-
- float mvmat[16] = {0};
- cam->GetModelviewMatrix().getValue(mvmat);
- float pmat[16] = {0};
- cam->GetProjectionMatrix().getValue(pmat);
-
- dbvt_culling = m_physicsEnvironment->CullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res,
- KX_GetActiveEngine()->GetCanvas()->GetViewPort(),
- mvmat, pmat);
- }
- if (!dbvt_culling) {
- // the physics engine couldn't help us, do it the hard way
- for (int i = 0; i < m_objectlist->GetCount(); i++)
- {
- MarkVisible(rasty, static_cast<KX_GameObject*>(m_objectlist->GetValue(i)), cam, layer);
- }
- }
-}
-
-// logic stuff
-void KX_Scene::LogicBeginFrame(double curtime)
-{
- // have a look at temp objects ...
- int lastobj = m_tempObjectList->GetCount() - 1;
-
- for (int i = lastobj; i >= 0; i--)
- {
- CValue* objval = m_tempObjectList->GetValue(i);
- CFloatValue* propval = (CFloatValue*) objval->GetProperty("::timebomb");
-
- if (propval)
- {
- float timeleft = (float)(propval->GetNumber() - 1.0/KX_KetsjiEngine::GetTicRate());
-
- if (timeleft > 0)
- {
- propval->SetFloat(timeleft);
- }
- else
- {
- DelayedRemoveObject(objval);
- // remove obj
- }
- }
- else
- {
- // all object is the tempObjectList should have a clock
- }
- }
- m_logicmgr->BeginFrame(curtime, 1.0/KX_KetsjiEngine::GetTicRate());
-}
-
-void KX_Scene::AddAnimatedObject(CValue* gameobj)
-{
- gameobj->AddRef();
- m_animatedlist->Add(gameobj);
-}
-
-static void update_anim_thread_func(TaskPool *pool, void *taskdata, int UNUSED(threadid))
-{
- KX_GameObject *gameobj, *child, *parent;
- CListValue *children;
- bool needs_update;
- double curtime = *(double*)BLI_task_pool_userdata(pool);
-
- gameobj = (KX_GameObject*)taskdata;
-
- // Non-armature updates are fast enough, so just update them
- needs_update = gameobj->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE;
-
- if (!needs_update) {
- // If we got here, we're looking to update an armature, so check its children meshes
- // to see if we need to bother with a more expensive pose update
- children = gameobj->GetChildren();
-
- 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->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();
- }
-
- if (needs_update) {
- gameobj->UpdateActionManager(curtime);
- children = gameobj->GetChildren();
- parent = gameobj->GetParent();
-
- // Only do deformers here if they are not parented to an armature, otherwise the armature will
- // handle updating its children
- if (gameobj->GetDeformer() && (!parent || parent->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE))
- gameobj->GetDeformer()->Update();
-
- for (int j=0; j<children->GetCount(); ++j) {
- child = (KX_GameObject*)children->GetValue(j);
-
- if (child->GetDeformer()) {
- child->GetDeformer()->Update();
- }
- }
-
- children->Release();
- }
-}
-
-void KX_Scene::UpdateAnimations(double curtime)
-{
- TaskPool *pool = BLI_task_pool_create(KX_GetActiveEngine()->GetTaskScheduler(), &curtime);
-
- for (int i=0; i<m_animatedlist->GetCount(); ++i) {
- BLI_task_pool_push(pool, update_anim_thread_func, m_animatedlist->GetValue(i), false, TASK_PRIORITY_LOW);
- }
-
- BLI_task_pool_work_and_wait(pool);
- BLI_task_pool_free(pool);
-}
-
-void KX_Scene::LogicUpdateFrame(double curtime, bool frame)
-{
- m_logicmgr->UpdateFrame(curtime, frame);
-}
-
-
-
-void KX_Scene::LogicEndFrame()
-{
- m_logicmgr->EndFrame();
- int numobj;
-
- KX_GameObject* obj;
-
- while ((numobj = m_euthanasyobjects->GetCount()) > 0)
- {
- // remove the object from this list to make sure we will not hit it again
- obj = (KX_GameObject*)m_euthanasyobjects->GetValue(numobj-1);
- m_euthanasyobjects->Remove(numobj-1);
- obj->Release();
- RemoveObject(obj);
- }
-
- //prepare obstacle simulation for new frame
- if (m_obstacleSimulation)
- m_obstacleSimulation->UpdateObstacles();
-}
-
-
-
-/**
- * UpdateParents: SceneGraph transformation update.
- */
-void KX_Scene::UpdateParents(double curtime)
-{
- // we use the SG dynamic list
- SG_Node* node;
-
- while ((node = SG_Node::GetNextScheduled(m_sghead)) != NULL)
- {
- node->UpdateWorldData(curtime);
- }
-
- //for (int i=0; i<GetRootParentList()->GetCount(); i++)
- //{
- // KX_GameObject* parentobj = (KX_GameObject*)GetRootParentList()->GetValue(i);
- // parentobj->NodeUpdateGS(curtime);
- //}
-
- // the list must be empty here
- assert(m_sghead.Empty());
- // some nodes may be ready for reschedule, move them to schedule list for next time
- while ((node = SG_Node::GetNextRescheduled(m_sghead)) != NULL)
- {
- node->Schedule(m_sghead);
- }
-}
-
-
-RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat, bool &bucketCreated)
-{
- return m_bucketmanager->FindBucket(polymat, bucketCreated);
-}
-
-
-
-void KX_Scene::RenderBuckets(const MT_Transform & cameratransform,
- class RAS_IRasterizer* rasty)
-{
- m_bucketmanager->Renderbuckets(cameratransform,rasty);
- KX_BlenderMaterial::EndFrame();
-}
-
-void KX_Scene::RenderFonts()
-{
- list<KX_FontObject*>::iterator it = m_fonts.begin();
- while (it != m_fonts.end()) {
- (*it)->DrawFontText();
- ++it;
- }
-}
-
-void KX_Scene::UpdateObjectLods(void)
-{
- KX_GameObject* gameobj;
-
- if (!this->m_active_camera)
- return;
-
- MT_Vector3 cam_pos = this->m_active_camera->NodeGetWorldPosition();
-
- for (int i = 0; i < this->GetObjectList()->GetCount(); i++) {
- gameobj = (KX_GameObject*) GetObjectList()->GetValue(i);
- if (!gameobj->GetCulled()) {
- gameobj->UpdateLod(cam_pos);
- }
- }
-}
-
-void KX_Scene::SetLodHysteresis(bool active)
-{
- m_isActivedHysteresis = active;
-}
-
-bool KX_Scene::IsActivedLodHysteresis(void)
-{
- return m_isActivedHysteresis;
-}
-
-void KX_Scene::SetLodHysteresisValue(int hysteresisvalue)
-{
- m_lodHysteresisValue = hysteresisvalue;
-}
-
-int KX_Scene::GetLodHysteresisValue(void)
-{
- return m_lodHysteresisValue;
-}
-
-void KX_Scene::UpdateObjectActivity(void)
-{
- if (m_activity_culling) {
- /* determine the activity criterium and set objects accordingly */
- int i=0;
-
- MT_Point3 camloc = GetActiveCamera()->NodeGetWorldPosition(); //GetCameraLocation();
-
- for (i=0;i<GetObjectList()->GetCount();i++)
- {
- KX_GameObject* ob = (KX_GameObject*) GetObjectList()->GetValue(i);
-
- if (!ob->GetIgnoreActivityCulling()) {
- /* Simple test: more than 10 away from the camera, count
- * Manhattan distance. */
- MT_Point3 obpos = ob->NodeGetWorldPosition();
-
- if ((fabsf(camloc[0] - obpos[0]) > m_activity_box_radius) ||
- (fabsf(camloc[1] - obpos[1]) > m_activity_box_radius) ||
- (fabsf(camloc[2] - obpos[2]) > m_activity_box_radius) )
- {
- ob->Suspend();
- }
- else {
- ob->Resume();
- }
- }
- }
- }
-}
-
-void KX_Scene::SetActivityCullingRadius(float f)
-{
- if (f < 0.5f)
- f = 0.5f;
- m_activity_box_radius = f;
-}
-
-NG_NetworkDeviceInterface* KX_Scene::GetNetworkDeviceInterface()
-{
- return m_networkDeviceInterface;
-}
-
-NG_NetworkScene* KX_Scene::GetNetworkScene()
-{
- return m_networkScene;
-}
-
-void KX_Scene::SetNetworkDeviceInterface(NG_NetworkDeviceInterface* newInterface)
-{
- m_networkDeviceInterface = newInterface;
-}
-
-void KX_Scene::SetNetworkScene(NG_NetworkScene *newScene)
-{
- m_networkScene = newScene;
-}
-
-
-void KX_Scene::SetGravity(const MT_Vector3& gravity)
-{
- GetPhysicsEnvironment()->SetGravity(gravity[0],gravity[1],gravity[2]);
-}
-
-MT_Vector3 KX_Scene::GetGravity()
-{
- MT_Vector3 gravity;
-
- GetPhysicsEnvironment()->GetGravity(gravity);
-
- return gravity;
-}
-
-void KX_Scene::SetSceneConverter(class KX_BlenderSceneConverter* sceneConverter)
-{
- m_sceneConverter = sceneConverter;
-}
-
-void KX_Scene::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* physEnv)
-{
- m_physicsEnvironment = physEnv;
- if (m_physicsEnvironment) {
- KX_TouchEventManager* touchmgr = new KX_TouchEventManager(m_logicmgr, physEnv);
- m_logicmgr->RegisterEventManager(touchmgr);
- }
-}
-
-void KX_Scene::setSuspendedTime(double suspendedtime)
-{
- m_suspendedtime = suspendedtime;
-}
-double KX_Scene::getSuspendedTime()
-{
- return m_suspendedtime;
-}
-void KX_Scene::setSuspendedDelta(double suspendeddelta)
-{
- m_suspendeddelta = suspendeddelta;
-}
-double KX_Scene::getSuspendedDelta()
-{
- return m_suspendeddelta;
-}
-
-short KX_Scene::GetAnimationFPS()
-{
- return m_blenderScene->r.frs_sec;
-}
-
-static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *from, KX_Scene *to)
-{
- SCA_LogicManager *logicmgr= to->GetLogicManager();
-
- brick->Replace_IScene(to);
- brick->Replace_NetworkScene(to->GetNetworkScene());
- brick->SetLogicManager(to->GetLogicManager());
-
- // If we end up replacing a KX_TouchEventManager, we need to make sure
- // physics controllers are properly in place. In other words, do this
- // after merging physics controllers!
- SCA_ISensor *sensor= dynamic_cast<class SCA_ISensor *>(brick);
- if (sensor) {
- sensor->Replace_EventManager(logicmgr);
- }
-
- SCA_2DFilterActuator *filter_actuator = dynamic_cast<class SCA_2DFilterActuator*>(brick);
- if (filter_actuator) {
- filter_actuator->SetScene(to);
- }
-
-#ifdef WITH_PYTHON
- // Python must be called from the main thread unless we want to deal
- // with GIL issues. So, this is delayed until here in case of async
- // libload (originally in KX_ConvertControllers)
- SCA_PythonController *pyctrl = dynamic_cast<SCA_PythonController*>(brick);
- if (pyctrl) {
- pyctrl->SetNamespace(KX_GetActiveEngine()->GetPyNamespace());
-
- if (pyctrl->m_mode==SCA_PythonController::SCA_PYEXEC_SCRIPT)
- pyctrl->Compile();
- }
-#endif
-}
-
-static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene *from)
-{
- {
- SCA_ActuatorList& actuators= gameobj->GetActuators();
- SCA_ActuatorList::iterator ita;
-
- for (ita = actuators.begin(); !(ita==actuators.end()); ++ita)
- {
- MergeScene_LogicBrick(*ita, from, to);
- }
- }
-
-
- {
- SCA_SensorList& sensors= gameobj->GetSensors();
- SCA_SensorList::iterator its;
-
- for (its = sensors.begin(); !(its==sensors.end()); ++its)
- {
- MergeScene_LogicBrick(*its, from, to);
- }
- }
-
- {
- SCA_ControllerList& controllers= gameobj->GetControllers();
- SCA_ControllerList::iterator itc;
-
- for (itc = controllers.begin(); !(itc==controllers.end()); ++itc)
- {
- SCA_IController *cont= *itc;
- MergeScene_LogicBrick(cont, from, to);
- }
- }
-
- /* graphics controller */
- PHY_IController *ctrl = gameobj->GetGraphicController();
- if (ctrl) {
- /* SHOULD update the m_cullingTree */
- ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
- }
-
- ctrl = gameobj->GetPhysicsController();
- if (ctrl) {
- ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
- }
-
- /* SG_Node can hold a scene reference */
- SG_Node *sg= gameobj->GetSGNode();
- if (sg) {
- if (sg->GetSGClientInfo() == from) {
- sg->SetSGClientInfo(to);
-
- /* Make sure to grab the children too since they might not be tied to a game object */
- NodeList children = sg->GetSGChildren();
- for (int i=0; i<children.size(); i++)
- children[i]->SetSGClientInfo(to);
- }
- }
- /* If the object is a light, update it's scene */
- if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT)
- ((KX_LightObject*)gameobj)->UpdateScene(to);
-
- if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_CAMERA)
- to->AddCamera((KX_Camera*)gameobj);
-
- // All armatures should be in the animated object list to be umpdated.
- if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
- to->AddAnimatedObject(gameobj);
-
- /* Add the object to the scene's logic manager */
- to->GetLogicManager()->RegisterGameObjectName(gameobj->GetName(), gameobj);
- to->GetLogicManager()->RegisterGameObj(gameobj->GetBlenderObject(), gameobj);
-
- for (int i = 0; i < gameobj->GetMeshCount(); ++i) {
- RAS_MeshObject *meshobj = gameobj->GetMesh(i);
- // Register the mesh object by name and blender object.
- to->GetLogicManager()->RegisterGameMeshName(meshobj->GetName(), gameobj->GetBlenderObject());
- to->GetLogicManager()->RegisterMeshName(meshobj->GetName(), meshobj);
- }
-}
-
-bool KX_Scene::MergeScene(KX_Scene *other)
-{
- PHY_IPhysicsEnvironment *env = this->GetPhysicsEnvironment();
- PHY_IPhysicsEnvironment *env_other = other->GetPhysicsEnvironment();
-
- if ((env==NULL) != (env_other==NULL)) /* TODO - even when both scenes have NONE physics, the other is loaded with bullet enabled, ??? */
- {
- printf("KX_Scene::MergeScene: physics scenes type differ, aborting\n");
- printf("\tsource %d, terget %d\n", (int)(env!=NULL), (int)(env_other!=NULL));
- return false;
- }
-
- if (GetSceneConverter() != other->GetSceneConverter()) {
- printf("KX_Scene::MergeScene: converters differ, aborting\n");
- return false;
- }
-
-
- GetBucketManager()->MergeBucketManager(other->GetBucketManager(), this);
-
-
- /* active + inactive == all ??? - lets hope so */
- for (int i = 0; i < other->GetObjectList()->GetCount(); i++)
- {
- KX_GameObject* gameobj = (KX_GameObject*)other->GetObjectList()->GetValue(i);
- MergeScene_GameObject(gameobj, this, other);
-
- /* add properties to debug list for LibLoad objects */
- if (KX_GetActiveEngine()->GetAutoAddDebugProperties()) {
- AddObjectDebugProperties(gameobj);
- }
-
- gameobj->UpdateBuckets(false); /* only for active objects */
- }
-
- for (int i = 0; i < other->GetInactiveList()->GetCount(); i++)
- {
- KX_GameObject* gameobj = (KX_GameObject*)other->GetInactiveList()->GetValue(i);
- MergeScene_GameObject(gameobj, this, other);
- }
-
- if (env) {
- env->MergeEnvironment(env_other);
- CListValue *otherObjects = other->GetObjectList();
-
- // List of all physics objects to merge (needed by ReplicateConstraints).
- std::vector<KX_GameObject *> physicsObjects;
- for (unsigned int i = 0; i < otherObjects->GetCount(); ++i) {
- KX_GameObject *gameobj = (KX_GameObject *)otherObjects->GetValue(i);
- if (gameobj->GetPhysicsController()) {
- physicsObjects.push_back(gameobj);
- }
- }
-
- for (unsigned int i = 0; i < physicsObjects.size(); ++i) {
- KX_GameObject *gameobj = physicsObjects[i];
- // Replicate all constraints in the right physics environment.
- gameobj->GetPhysicsController()->ReplicateConstraints(gameobj, physicsObjects);
- gameobj->ClearConstraints();
- }
- }
-
-
- GetTempObjectList()->MergeList(other->GetTempObjectList());
- other->GetTempObjectList()->ReleaseAndRemoveAll();
-
- GetObjectList()->MergeList(other->GetObjectList());
- other->GetObjectList()->ReleaseAndRemoveAll();
-
- GetInactiveList()->MergeList(other->GetInactiveList());
- other->GetInactiveList()->ReleaseAndRemoveAll();
-
- GetRootParentList()->MergeList(other->GetRootParentList());
- other->GetRootParentList()->ReleaseAndRemoveAll();
-
- GetLightList()->MergeList(other->GetLightList());
- other->GetLightList()->ReleaseAndRemoveAll();
-
- /* move materials across, assume they both use the same scene-converters
- * Do this after lights are merged so materials can use the lights in shaders
- */
- GetSceneConverter()->MergeScene(this, other);
-
- /* merge logic */
- {
- SCA_LogicManager *logicmgr= GetLogicManager();
- SCA_LogicManager *logicmgr_other= other->GetLogicManager();
-
- vector<class SCA_EventManager*>evtmgrs= logicmgr->GetEventManagers();
- //vector<class SCA_EventManager*>evtmgrs_others= logicmgr_other->GetEventManagers();
-
- //SCA_EventManager *evtmgr;
- SCA_EventManager *evtmgr_other;
-
- for (unsigned int i= 0; i < evtmgrs.size(); i++) {
- evtmgr_other= logicmgr_other->FindEventManager(evtmgrs[i]->GetType());
-
- if (evtmgr_other) /* unlikely but possible one scene has a joystick and not the other */
- evtmgr_other->Replace_LogicManager(logicmgr);
-
- /* when merging objects sensors are moved across into the new manager, don't need to do this here */
- }
-
- /* grab any timer properties from the other scene */
- SCA_TimeEventManager *timemgr= GetTimeEventManager();
- SCA_TimeEventManager *timemgr_other= other->GetTimeEventManager();
- vector<CValue*> times = timemgr_other->GetTimeValues();
-
- for (unsigned int i= 0; i < times.size(); i++) {
- timemgr->AddTimeProperty(times[i]);
- }
-
- }
- return true;
-}
-
-void KX_Scene::Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
-{
- m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text);
-}
-
-void KX_Scene::Render2DFilters(RAS_ICanvas* canvas)
-{
- m_filtermanager.RenderFilters(canvas);
-}
-
-#ifdef WITH_PYTHON
-
-void KX_Scene::RunDrawingCallbacks(PyObject *cb_list)
-{
- if (!cb_list || PyList_GET_SIZE(cb_list) == 0)
- return;
-
- RunPythonCallBackList(cb_list, NULL, 0, 0);
-}
-
-//----------------------------------------------------------------------------
-//Python
-
-PyTypeObject KX_Scene::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_Scene",
- sizeof(PyObjectPlus_Proxy),
- 0,
- py_base_dealloc,
- 0,
- 0,
- 0,
- 0,
- py_base_repr,
- 0,
- &Sequence,
- &Mapping,
- 0,0,0,0,0,0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- 0,0,0,0,0,0,0,
- Methods,
- 0,
- 0,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_Scene::Methods[] = {
- KX_PYMETHODTABLE(KX_Scene, addObject),
- KX_PYMETHODTABLE(KX_Scene, end),
- KX_PYMETHODTABLE(KX_Scene, restart),
- KX_PYMETHODTABLE(KX_Scene, replace),
- KX_PYMETHODTABLE(KX_Scene, suspend),
- KX_PYMETHODTABLE(KX_Scene, resume),
- KX_PYMETHODTABLE(KX_Scene, drawObstacleSimulation),
-
-
- /* dict style access */
- KX_PYMETHODTABLE(KX_Scene, get),
-
- {NULL,NULL} //Sentinel
-};
-static PyObject *Map_GetItem(PyObject *self_v, PyObject *item)
-{
- KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v);
- const char *attr_str= _PyUnicode_AsString(item);
- PyObject *pyconvert;
-
- if (self == NULL) {
- PyErr_SetString(PyExc_SystemError, "val = scene[key]: KX_Scene, " BGE_PROXY_ERROR_MSG);
- return NULL;
- }
-
- if (!self->m_attr_dict)
- self->m_attr_dict = PyDict_New();
-
- if (self->m_attr_dict && (pyconvert=PyDict_GetItem(self->m_attr_dict, item))) {
-
- if (attr_str)
- PyErr_Clear();
- Py_INCREF(pyconvert);
- return pyconvert;
- }
- else {
- if (attr_str) PyErr_Format(PyExc_KeyError, "value = scene[key]: KX_Scene, key \"%s\" does not exist", attr_str);
- else PyErr_SetString(PyExc_KeyError, "value = scene[key]: KX_Scene, key does not exist");
- return NULL;
- }
-
-}
-
-static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
-{
- KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v);
- const char *attr_str= _PyUnicode_AsString(key);
- if (attr_str==NULL)
- PyErr_Clear();
-
- if (self == NULL) {
- PyErr_SetString(PyExc_SystemError, "scene[key] = value: KX_Scene, " BGE_PROXY_ERROR_MSG);
- return -1;
- }
-
- if (!self->m_attr_dict)
- self->m_attr_dict = PyDict_New();
-
- if (val==NULL) { /* del ob["key"] */
- int del= 0;
-
- if (self->m_attr_dict)
- del |= (PyDict_DelItem(self->m_attr_dict, key)==0) ? 1:0;
-
- if (del==0) {
- if (attr_str) PyErr_Format(PyExc_KeyError, "scene[key] = value: KX_Scene, key \"%s\" could not be set", attr_str);
- else PyErr_SetString(PyExc_KeyError, "del scene[key]: KX_Scene, key could not be deleted");
- return -1;
- }
- else if (self->m_attr_dict) {
- PyErr_Clear(); /* PyDict_DelItem sets an error when it fails */
- }
- }
- else { /* ob["key"] = value */
- int set = 0;
-
- if (self->m_attr_dict==NULL) /* lazy init */
- self->m_attr_dict= PyDict_New();
-
-
- if (PyDict_SetItem(self->m_attr_dict, key, val)==0)
- set= 1;
- else
- PyErr_SetString(PyExc_KeyError, "scene[key] = value: KX_Scene, key not be added to internal dictionary");
-
- if (set==0)
- return -1; /* pythons error value */
-
- }
-
- return 0; /* success */
-}
-
-static int Seq_Contains(PyObject *self_v, PyObject *value)
-{
- KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v);
-
- if (self == NULL) {
- PyErr_SetString(PyExc_SystemError, "val in scene: KX_Scene, " BGE_PROXY_ERROR_MSG);
- return -1;
- }
-
- if (!self->m_attr_dict)
- self->m_attr_dict = PyDict_New();
-
- if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value))
- return 1;
-
- return 0;
-}
-
-PyMappingMethods KX_Scene::Mapping = {
- (lenfunc)NULL, /* inquiry mp_length */
- (binaryfunc)Map_GetItem, /* binaryfunc mp_subscript */
- (objobjargproc)Map_SetItem, /* objobjargproc mp_ass_subscript */
-};
-
-PySequenceMethods KX_Scene::Sequence = {
- NULL, /* Cant set the len otherwise it can evaluate as false */
- NULL, /* sq_concat */
- NULL, /* sq_repeat */
- NULL, /* sq_item */
- NULL, /* sq_slice */
- NULL, /* sq_ass_item */
- NULL, /* sq_ass_slice */
- (objobjproc)Seq_Contains, /* sq_contains */
- (binaryfunc) NULL, /* sq_inplace_concat */
- (ssizeargfunc) NULL, /* sq_inplace_repeat */
-};
-
-PyObject *KX_Scene::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
- return PyUnicode_From_STR_String(self->GetName());
-}
-
-PyObject *KX_Scene::pyattr_get_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
- return self->GetObjectList()->GetProxy();
-}
-
-PyObject *KX_Scene::pyattr_get_objects_inactive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
- return self->GetInactiveList()->GetProxy();
-}
-
-PyObject *KX_Scene::pyattr_get_lights(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
- return self->GetLightList()->GetProxy();
-}
-
-PyObject *KX_Scene::pyattr_get_world(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
- KX_WorldInfo *world = self->GetWorldInfo();
-
- if (world->GetName() != "") {
- return world->GetProxy();
- }
- else {
- Py_RETURN_NONE;
- }
-}
-
-PyObject *KX_Scene::pyattr_get_cameras(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- /* With refcounts in this case...
- * the new CListValue is owned by python, so its possible python holds onto it longer then the BGE
- * however this is the same with "scene.objects + []", when you make a copy by adding lists.
- */
-
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
- CListValue* clist = new CListValue();
-
- /* return self->GetCameras()->GetProxy(); */
-
- list<KX_Camera*>::iterator it = self->GetCameras()->begin();
- while (it != self->GetCameras()->end()) {
- clist->Add((*it)->AddRef());
- it++;
- }
-
- return clist->NewProxy(true);
-}
-
-PyObject *KX_Scene::pyattr_get_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
- KX_Camera* cam= self->GetActiveCamera();
- if (cam)
- return self->GetActiveCamera()->GetProxy();
- else
- Py_RETURN_NONE;
-}
-
-
-int KX_Scene::pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
- KX_Camera *camOb;
-
- if (!ConvertPythonToCamera(value, &camOb, false, "scene.active_camera = value: KX_Scene"))
- return PY_SET_ATTR_FAIL;
-
- self->SetActiveCamera(camOb);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Scene::pyattr_get_drawing_callback_pre(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
-
- if (self->m_draw_call_pre==NULL)
- self->m_draw_call_pre= PyList_New(0);
- Py_INCREF(self->m_draw_call_pre);
- return self->m_draw_call_pre;
-}
-
-PyObject *KX_Scene::pyattr_get_drawing_callback_post(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
-
- if (self->m_draw_call_post==NULL)
- self->m_draw_call_post= PyList_New(0);
- Py_INCREF(self->m_draw_call_post);
- return self->m_draw_call_post;
-}
-
-PyObject *KX_Scene::pyattr_get_drawing_setup_callback_pre(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
-
- if (self->m_draw_setup_call_pre == NULL)
- self->m_draw_setup_call_pre = PyList_New(0);
-
- Py_INCREF(self->m_draw_setup_call_pre);
- return self->m_draw_setup_call_pre;
-}
-
-int KX_Scene::pyattr_set_drawing_callback_pre(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
-
- if (!PyList_CheckExact(value))
- {
- PyErr_SetString(PyExc_ValueError, "Expected a list");
- return PY_SET_ATTR_FAIL;
- }
- Py_XDECREF(self->m_draw_call_pre);
-
- Py_INCREF(value);
- self->m_draw_call_pre = value;
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-int KX_Scene::pyattr_set_drawing_callback_post(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
-
- if (!PyList_CheckExact(value))
- {
- PyErr_SetString(PyExc_ValueError, "Expected a list");
- return PY_SET_ATTR_FAIL;
- }
- Py_XDECREF(self->m_draw_call_post);
-
- Py_INCREF(value);
- self->m_draw_call_post = value;
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-int KX_Scene::pyattr_set_drawing_setup_callback_pre(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
-
- if (!PyList_CheckExact(value)) {
- PyErr_SetString(PyExc_ValueError, "Expected a list");
- return PY_SET_ATTR_FAIL;
- }
-
- Py_XDECREF(self->m_draw_setup_call_pre);
- Py_INCREF(value);
-
- self->m_draw_setup_call_pre = value;
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_Scene::pyattr_get_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
-
- return PyObjectFrom(self->GetGravity());
-}
-
-int KX_Scene::pyattr_set_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_Scene* self = static_cast<KX_Scene*>(self_v);
-
- MT_Vector3 vec;
- if (!PyVecTo(value, vec))
- return PY_SET_ATTR_FAIL;
-
- self->SetGravity(vec);
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyAttributeDef KX_Scene::Attributes[] = {
- KX_PYATTRIBUTE_RO_FUNCTION("name", KX_Scene, pyattr_get_name),
- KX_PYATTRIBUTE_RO_FUNCTION("objects", KX_Scene, pyattr_get_objects),
- KX_PYATTRIBUTE_RO_FUNCTION("objectsInactive", KX_Scene, pyattr_get_objects_inactive),
- KX_PYATTRIBUTE_RO_FUNCTION("lights", KX_Scene, pyattr_get_lights),
- KX_PYATTRIBUTE_RO_FUNCTION("cameras", KX_Scene, pyattr_get_cameras),
- KX_PYATTRIBUTE_RO_FUNCTION("world", KX_Scene, pyattr_get_world),
- KX_PYATTRIBUTE_RW_FUNCTION("active_camera", KX_Scene, pyattr_get_active_camera, pyattr_set_active_camera),
- KX_PYATTRIBUTE_RW_FUNCTION("pre_draw", KX_Scene, pyattr_get_drawing_callback_pre, pyattr_set_drawing_callback_pre),
- KX_PYATTRIBUTE_RW_FUNCTION("post_draw", KX_Scene, pyattr_get_drawing_callback_post, pyattr_set_drawing_callback_post),
- KX_PYATTRIBUTE_RW_FUNCTION("pre_draw_setup", KX_Scene, pyattr_get_drawing_setup_callback_pre, pyattr_set_drawing_setup_callback_pre),
- KX_PYATTRIBUTE_RW_FUNCTION("gravity", KX_Scene, pyattr_get_gravity, pyattr_set_gravity),
- KX_PYATTRIBUTE_BOOL_RO("suspended", KX_Scene, m_suspend),
- KX_PYATTRIBUTE_BOOL_RO("activity_culling", KX_Scene, m_activity_culling),
- KX_PYATTRIBUTE_FLOAT_RW("activity_culling_radius", 0.5f, FLT_MAX, KX_Scene, m_activity_box_radius),
- KX_PYATTRIBUTE_BOOL_RO("dbvt_culling", KX_Scene, m_dbvt_culling),
- { NULL } //Sentinel
-};
-
-KX_PYMETHODDEF_DOC(KX_Scene, addObject,
-"addObject(object, other, time=0)\n"
-"Returns the added object.\n")
-{
- PyObject *pyob, *pyreference = Py_None;
- KX_GameObject *ob, *reference;
-
- int time = 0;
-
- if (!PyArg_ParseTuple(args, "O|Oi:addObject", &pyob, &pyreference, &time))
- return NULL;
-
- if (!ConvertPythonToGameObject(m_logicmgr, pyob, &ob, false, "scene.addObject(object, reference, time): KX_Scene (first argument)") ||
- !ConvertPythonToGameObject(m_logicmgr, pyreference, &reference, true, "scene.addObject(object, reference, time): KX_Scene (second argument)"))
- return NULL;
-
- if (!m_inactivelist->SearchValue(ob)) {
- PyErr_Format(PyExc_ValueError, "scene.addObject(object, reference, time): KX_Scene (first argument): object must be in an inactive layer");
- return NULL;
- }
- SCA_IObject *replica = AddReplicaObject((SCA_IObject*)ob, reference, time);
-
- // release here because AddReplicaObject AddRef's
- // the object is added to the scene so we don't want python to own a reference
- replica->Release();
- return replica->GetProxy();
-}
-
-KX_PYMETHODDEF_DOC(KX_Scene, end,
-"end()\n"
-"Removes this scene from the game.\n")
-{
-
- KX_GetActiveEngine()->RemoveScene(m_sceneName);
-
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(KX_Scene, restart,
- "restart()\n"
- "Restarts this scene.\n")
-{
- KX_GetActiveEngine()->ReplaceScene(m_sceneName, m_sceneName);
-
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(KX_Scene, replace,
- "replace(newScene)\n"
- "Replaces this scene with another one.\n"
- "Return True if the new scene exists and scheduled for replacement, False otherwise.\n")
-{
- char* name;
-
- if (!PyArg_ParseTuple(args, "s:replace", &name))
- return NULL;
-
- if (KX_GetActiveEngine()->ReplaceScene(m_sceneName, name))
- Py_RETURN_TRUE;
-
- Py_RETURN_FALSE;
-}
-
-KX_PYMETHODDEF_DOC(KX_Scene, suspend,
- "suspend()\n"
- "Suspends this scene.\n")
-{
- Suspend();
-
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(KX_Scene, resume,
- "resume()\n"
- "Resumes this scene.\n")
-{
- Resume();
-
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(KX_Scene, drawObstacleSimulation,
- "drawObstacleSimulation()\n"
- "Draw debug visualization of obstacle simulation.\n")
-{
- if (GetObstacleSimulation())
- GetObstacleSimulation()->DrawObstacles();
-
- Py_RETURN_NONE;
-}
-
-/* Matches python dict.get(key, [default]) */
-KX_PYMETHODDEF_DOC(KX_Scene, get, "")
-{
- PyObject *key;
- PyObject *def = Py_None;
- PyObject *ret;
-
- if (!PyArg_ParseTuple(args, "O|O:get", &key, &def))
- return NULL;
-
- if (m_attr_dict && (ret=PyDict_GetItem(m_attr_dict, key))) {
- Py_INCREF(ret);
- return ret;
- }
-
- Py_INCREF(def);
- return def;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h
deleted file mode 100644
index 6d8ae8a321b..00000000000
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ /dev/null
@@ -1,697 +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_Scene.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_SCENE_H__
-#define __KX_SCENE_H__
-
-
-#include "KX_PhysicsEngineEnums.h"
-
-#include <vector>
-#include <set>
-#include <list>
-
-#include "CTR_Map.h"
-#include "CTR_HashedPtr.h"
-#include "SG_IObject.h"
-#include "SCA_IScene.h"
-#include "MT_Transform.h"
-
-#include "RAS_FramingManager.h"
-#include "RAS_Rect.h"
-
-
-#include "EXP_PyObjectPlus.h"
-#include "RAS_2DFilterManager.h"
-
-/**
- * \section Forward declarations
- */
-struct SM_MaterialProps;
-struct SM_ShapeProps;
-struct Scene;
-
-class CTR_HashedPtr;
-class CListValue;
-class CValue;
-class SCA_LogicManager;
-class SCA_KeyboardManager;
-class SCA_TimeEventManager;
-class SCA_MouseManager;
-class SCA_ISystem;
-class SCA_IInputDevice;
-class NG_NetworkDeviceInterface;
-class NG_NetworkScene;
-class SG_IObject;
-class SG_Node;
-class SG_Tree;
-class KX_WorldInfo;
-class KX_Camera;
-class KX_GameObject;
-class KX_LightObject;
-class RAS_BucketManager;
-class RAS_MaterialBucket;
-class RAS_IPolyMaterial;
-class RAS_IRasterizer;
-class RAS_IRenderTools;
-class SCA_JoystickManager;
-class btCollisionShape;
-class KX_BlenderSceneConverter;
-struct KX_ClientObjectInfo;
-class KX_ObstacleSimulation;
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/* for ID freeing */
-#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT))
-
-/**
- * The KX_Scene holds all data for an independent scene. It relates
- * KX_Objects to the specific objects in the modules.
- * */
-class KX_Scene : public PyObjectPlus, public SCA_IScene
-{
- Py_Header
-
-#ifdef WITH_PYTHON
- PyObject* m_attr_dict;
- PyObject* m_draw_call_pre;
- PyObject* m_draw_call_post;
- PyObject* m_draw_setup_call_pre;
-#endif
-
- struct CullingInfo {
- int m_layer;
- CullingInfo(int layer) : m_layer(layer) {}
- };
-
-protected:
- RAS_BucketManager* m_bucketmanager;
- CListValue* m_tempObjectList;
-
- /**
- * The list of objects which have been removed during the
- * course of one frame. They are actually destroyed in
- * LogicEndFrame() via a call to RemoveObject().
- */
- CListValue* m_euthanasyobjects;
-
- CListValue* m_objectlist;
- CListValue* m_parentlist; // all 'root' parents
- CListValue* m_lightlist;
- CListValue* m_inactivelist; // all objects that are not in the active layer
- CListValue* m_animatedlist; // all animated objects
-
- SG_QList m_sghead; // list of nodes that needs scenegraph update
- // the Dlist is not object that must be updated
- // the Qlist is for objects that needs to be rescheduled
- // for updates after udpate is over (slow parent, bone parent)
-
-
- /**
- * The set of cameras for this scene
- */
- std::list<class KX_Camera*> m_cameras;
-
- /**
- * The set of fonts for this scene
- */
- std::list<class KX_FontObject*> m_fonts;
-
-
- /**
- * Various SCA managers used by the scene
- */
- SCA_LogicManager* m_logicmgr;
- SCA_KeyboardManager* m_keyboardmgr;
- SCA_MouseManager* m_mousemgr;
- SCA_TimeEventManager* m_timemgr;
-
- // Scene converter where many scene entities are registered
- // Used to deregister objects that are deleted
- class KX_BlenderSceneConverter* m_sceneConverter;
- /**
- * physics engine abstraction
- */
- //e_PhysicsEngine m_physicsEngine; //who needs this ?
- class PHY_IPhysicsEnvironment* m_physicsEnvironment;
-
- /**
- * Does this scene clear the z-buffer?
- */
- bool m_isclearingZbuffer;
-
- /**
- * Does the shadow buffer needs calculing
- */
- bool m_isShadowDone;
-
- /**
- * The name of the scene
- */
- STR_String m_sceneName;
-
- /**
- * stores the world-settings for a scene
- */
- KX_WorldInfo* m_worldinfo;
-
- /**
- * \section Different scenes, linked to ketsji scene
- */
-
- /**
- * Network scene.
- */
- NG_NetworkDeviceInterface* m_networkDeviceInterface;
- NG_NetworkScene* m_networkScene;
-
- /**
- * A temporary variable used to parent objects together on
- * replication. Don't get confused by the name it is not
- * the scene's root node!
- */
- SG_Node* m_rootnode;
-
- /**
- * The active camera for the scene
- */
- KX_Camera* m_active_camera;
-
- /**
- * Another temporary variable outstaying its welcome
- * used in AddReplicaObject to map game objects to their
- * replicas so pointers can be updated.
- */
- CTR_Map <CTR_HashedPtr, void*> m_map_gameobject_to_replica;
-
- /**
- * Another temporary variable outstaying its welcome
- * used in AddReplicaObject to keep a record of all added
- * objects. Logic can only be updated when all objects
- * have been updated. This stores a list of the new objects.
- */
- std::vector<KX_GameObject*> m_logicHierarchicalGameObjects;
-
- /**
- * This temporary variable will contain the list of
- * object that can be added during group instantiation.
- * objects outside this list will not be added (can
- * happen with children that are outside the group).
- * Used in AddReplicaObject. If the list is empty, it
- * means don't care.
- */
- std::set<CValue*> m_groupGameObjects;
-
- /**
- * Pointer to system variable passed in in constructor
- * only used in constructor so we do not need to keep it
- * around in this class.
- */
-
- SCA_ISystem* m_kxsystem;
-
- /**
- * The execution priority of replicated object actuators?
- */
- int m_ueberExecutionPriority;
-
- /**
- * Activity 'bubble' settings :
- * Suspend (freeze) the entire scene.
- */
- bool m_suspend;
-
- /**
- * Radius in Manhattan distance of the box for activity culling.
- */
- float m_activity_box_radius;
-
- /**
- * Toggle to enable or disable activity culling.
- */
- bool m_activity_culling;
-
- /**
- * Toggle to enable or disable culling via DBVT broadphase of Bullet.
- */
- bool m_dbvt_culling;
-
- /**
- * Occlusion culling resolution
- */
- int m_dbvt_occlusion_res;
-
- /**
- * The framing settings used by this scene
- */
-
- RAS_FrameSettings m_frame_settings;
-
- /**
- * This scenes viewport into the game engine
- * canvas.Maintained externally, initially [0,0] -> [0,0]
- */
- RAS_Rect m_viewport;
-
- /**
- * Visibility testing functions.
- */
- void MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera*cam,int layer=0);
- void MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible, KX_Camera*cam,int layer=0);
- void MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj, KX_Camera*cam, int layer=0);
- static void PhysicsCullingCallback(KX_ClientObjectInfo* objectInfo, void* cullingInfo);
-
- double m_suspendedtime;
- double m_suspendeddelta;
-
- struct Scene* m_blenderScene;
-
- RAS_2DFilterManager m_filtermanager;
-
- KX_ObstacleSimulation* m_obstacleSimulation;
-
- /**
- * LOD Hysteresis settings
- */
- bool m_isActivedHysteresis;
- int m_lodHysteresisValue;
-
-public:
- KX_Scene(class SCA_IInputDevice* keyboarddevice,
- class SCA_IInputDevice* mousedevice,
- class NG_NetworkDeviceInterface* ndi,
- const STR_String& scenename,
- struct Scene* scene,
- class RAS_ICanvas* canvas);
-
- virtual
- ~KX_Scene();
-
- RAS_BucketManager* GetBucketManager();
- RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial* polymat, bool &bucketCreated);
- void RenderBuckets(const MT_Transform& cameratransform,
- RAS_IRasterizer* rasty);
-
- /**
- * Update all transforms according to the scenegraph.
- */
- static bool KX_ScenegraphUpdateFunc(SG_IObject* node,void* gameobj,void* scene);
- static bool KX_ScenegraphRescheduleFunc(SG_IObject* node,void* gameobj,void* scene);
- void UpdateParents(double curtime);
- void DupliGroupRecurse(CValue* gameobj, int level);
- bool IsObjectInGroup(CValue* gameobj)
- {
- return (m_groupGameObjects.empty() ||
- m_groupGameObjects.find(gameobj) != m_groupGameObjects.end());
- }
- void AddObjectDebugProperties(class KX_GameObject* gameobj);
- SCA_IObject* AddReplicaObject(CValue* gameobj,
- CValue* locationobj,
- int lifespan=0);
- KX_GameObject* AddNodeReplicaObject(SG_IObject* node,
- CValue* gameobj);
- void RemoveNodeDestructObject(SG_IObject* node,
- CValue* gameobj);
- void RemoveObject(CValue* gameobj);
- void RemoveDupliGroup(CValue *gameobj);
- void DelayedRemoveObject(CValue* gameobj);
-
- int NewRemoveObject(CValue* gameobj);
- void ReplaceMesh(CValue* gameobj,
- void* meshob, bool use_gfx, bool use_phys);
-
- void AddAnimatedObject(CValue* gameobj);
-
- /**
- * \section Logic stuff
- * Initiate an update of the logic system.
- */
- void LogicBeginFrame(double curtime);
- void LogicUpdateFrame(double curtime, bool frame);
- void UpdateAnimations(double curtime);
-
- void
- LogicEndFrame(
- );
-
- CListValue*
- GetTempObjectList(
- );
-
- CListValue*
- GetObjectList(
- );
-
- CListValue*
- GetInactiveList(
- );
-
- CListValue*
- GetRootParentList(
- );
-
- CListValue*
- GetLightList(
- );
-
- SCA_LogicManager *
- GetLogicManager(
- );
-
- SCA_TimeEventManager *
- GetTimeEventManager(
- );
-
- /** Font Routines */
-
- /** Find a font in the scene by pointer. */
- KX_FontObject*
- FindFont(
- KX_FontObject*
- );
-
- /** Add a camera to this scene. */
- void
- AddFont(
- KX_FontObject*
- );
-
- /** Render the fonts in this scene. */
- void
- RenderFonts(
- );
-
- /** Camera Routines */
-
- std::list<class KX_Camera*>*
- GetCameras(
- );
-
-
- /** Find a camera in the scene by pointer. */
- KX_Camera*
- FindCamera(
- KX_Camera*
- );
-
- /** Find a scene in the scene by name. */
- KX_Camera*
- FindCamera(
- STR_String&
- );
-
- /** Add a camera to this scene. */
- void
- AddCamera(
- KX_Camera*
- );
-
- /** Find the currently active camera. */
- KX_Camera*
- GetActiveCamera(
- );
-
- /**
- * Set this camera to be the active camera in the scene. If the
- * camera is not present in the camera list, it will be added
- */
-
- void
- SetActiveCamera(
- class KX_Camera*
- );
-
- /**
- * Move this camera to the end of the list so that it is rendered last.
- * If the camera is not on the list, it will be added
- */
- void
- SetCameraOnTop(
- class KX_Camera*
- );
-
- /**
- * Activates new desired canvas width set at design time.
- * \param width The new desired width.
- */
- void
- SetCanvasDesignWidth(
- unsigned int width
- );
- /**
- * Activates new desired canvas height set at design time.
- * \param width The new desired height.
- */
- void
- SetCanvasDesignHeight(
- unsigned int height
- );
- /**
- * Returns the current desired canvas width set at design time.
- * \return The desired width.
- */
- unsigned int
- GetCanvasDesignWidth(
- void
- ) const;
-
- /**
- * Returns the current desired canvas height set at design time.
- * \return The desired height.
- */
- unsigned int
- GetCanvasDesignHeight(
- void
- ) const;
-
- /**
- * Set the framing options for this scene
- */
-
- void
- SetFramingType(
- RAS_FrameSettings & frame_settings
- );
-
- /**
- * Return a const reference to the framing
- * type set by the above call.
- * The contents are not guaranteed to be sensible
- * if you don't call the above function.
- */
-
- const
- RAS_FrameSettings &
- GetFramingType(
- ) const;
-
- /**
- * Store the current scene's viewport on the
- * game engine canvas.
- */
- void SetSceneViewport(const RAS_Rect &viewport);
-
- /**
- * Get the current scene's viewport on the
- * game engine canvas. This maintained
- * externally in KX_GameEngine
- */
- const RAS_Rect& GetSceneViewport() const;
-
- /**
- * \section Accessors to different scenes of this scene
- */
- void SetNetworkDeviceInterface(NG_NetworkDeviceInterface* newInterface);
- void SetNetworkScene(NG_NetworkScene *newScene);
- void SetWorldInfo(class KX_WorldInfo* wi);
- KX_WorldInfo* GetWorldInfo();
- void CalculateVisibleMeshes(RAS_IRasterizer* rasty, KX_Camera *cam, int layer=0);
- KX_Camera* GetpCamera();
- NG_NetworkDeviceInterface* GetNetworkDeviceInterface();
- NG_NetworkScene* GetNetworkScene();
- KX_BlenderSceneConverter *GetSceneConverter() { return m_sceneConverter; }
-
- /**
- * Replicate the logic bricks associated to this object.
- */
-
- void ReplicateLogic(class KX_GameObject* newobj);
- static SG_Callbacks m_callbacks;
-
- const STR_String& GetName();
-
- // Suspend the entire scene.
- void Suspend();
-
- // Resume a suspended scene.
- void Resume();
-
- // Update the mesh for objects based on level of detail settings
- void UpdateObjectLods(void);
-
- // LoD Hysteresis functions
- void SetLodHysteresis(bool active);
- bool IsActivedLodHysteresis();
- void SetLodHysteresisValue(int hysteresisvalue);
- int GetLodHysteresisValue();
-
- // Update the activity box settings for objects in this scene, if needed.
- void UpdateObjectActivity(void);
-
- // Enable/disable activity culling.
- void SetActivityCulling(bool b);
-
- // Set the radius of the activity culling box.
- void SetActivityCullingRadius(float f);
- bool IsSuspended();
- bool IsClearingZBuffer();
- void EnableZBufferClearing(bool isclearingZbuffer);
- bool IsShadowDone() { return m_isShadowDone; }
- void SetShadowDone(bool b) { m_isShadowDone = b; }
- // use of DBVT tree for camera culling
- void SetDbvtCulling(bool b) { m_dbvt_culling = b; }
- bool GetDbvtCulling() { return m_dbvt_culling; }
- void SetDbvtOcclusionRes(int i) { m_dbvt_occlusion_res = i; }
- int GetDbvtOcclusionRes() { return m_dbvt_occlusion_res; }
-
- void SetSceneConverter(class KX_BlenderSceneConverter* sceneConverter);
-
- class PHY_IPhysicsEnvironment* GetPhysicsEnvironment()
- {
- return m_physicsEnvironment;
- }
-
- void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* physEnv);
-
- void SetGravity(const MT_Vector3& gravity);
- MT_Vector3 GetGravity();
-
- short GetAnimationFPS();
-
- /**
- * Sets the node tree for this scene.
- */
- void SetNodeTree(SG_Tree* root);
-
- /**
- * 2D Filters
- */
- void Update2DFilter(std::vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
- void Render2DFilters(RAS_ICanvas* canvas);
-
- KX_ObstacleSimulation* GetObstacleSimulation() { return m_obstacleSimulation; }
-
-#ifdef WITH_PYTHON
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- KX_PYMETHOD_DOC(KX_Scene, addObject);
- KX_PYMETHOD_DOC(KX_Scene, end);
- KX_PYMETHOD_DOC(KX_Scene, restart);
- KX_PYMETHOD_DOC(KX_Scene, replace);
- KX_PYMETHOD_DOC(KX_Scene, suspend);
- KX_PYMETHOD_DOC(KX_Scene, resume);
- KX_PYMETHOD_DOC(KX_Scene, get);
- KX_PYMETHOD_DOC(KX_Scene, drawObstacleSimulation);
-
-
- /* attributes */
- static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_objects(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_objects_inactive(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_lights(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_cameras(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_world(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_active_camera(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_drawing_callback_pre(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_drawing_callback_pre(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_drawing_callback_post(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_drawing_callback_post(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_drawing_setup_callback_pre(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_drawing_setup_callback_pre(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject* pyattr_get_gravity(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_gravity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- virtual PyObject *py_repr(void) { return PyUnicode_From_STR_String(GetName()); }
-
- /* getitem/setitem */
- static PyMappingMethods Mapping;
- static PySequenceMethods Sequence;
-
- /**
- * Run the registered python drawing functions.
- */
- void RunDrawingCallbacks(PyObject *cb_list);
-
- PyObject *GetPreDrawCB() { return m_draw_call_pre; }
- PyObject *GetPostDrawCB() { return m_draw_call_post; }
- PyObject *GetPreDrawSetupCB() { return m_draw_setup_call_pre; }
-#endif
-
- /**
- * Sets the time the scene was suspended
- */
- void setSuspendedTime(double suspendedtime);
- /**
- * Returns the "curtime" the scene was suspended
- */
- double getSuspendedTime();
- /**
- * Sets the difference between the local time of the scene (when it
- * was running and not suspended) and the "curtime"
- */
- void setSuspendedDelta(double suspendeddelta);
- /**
- * Returns the difference between the local time of the scene (when it
- * was running and not suspended) and the "curtime"
- */
- double getSuspendedDelta();
- /**
- * Returns the Blender scene this was made from
- */
- struct Scene *GetBlenderScene() { return m_blenderScene; }
-
- bool MergeScene(KX_Scene *other);
-
-
- //void PrintStats(int verbose_level) {
- // m_bucketmanager->PrintStats(verbose_level)
- //}
-};
-
-typedef std::vector<KX_Scene*> KX_SceneList;
-
-#endif /* __KX_SCENE_H__ */
diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp
deleted file mode 100644
index 6fe33fd2f63..00000000000
--- a/source/gameengine/Ketsji/KX_SceneActuator.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Set scene/camera stuff
- *
- *
- * ***** 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_SceneActuator.cpp
- * \ingroup ketsji
- */
-
-
-#include "SCA_IActuator.h"
-#include "KX_SceneActuator.h"
-#include <iostream>
-#include "KX_Scene.h"
-#include "KX_Camera.h"
-#include "KX_KetsjiEngine.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_SceneActuator::KX_SceneActuator(SCA_IObject *gameobj,
- int mode,
- KX_Scene *scene,
- KX_KetsjiEngine* ketsjiEngine,
- const STR_String& nextSceneName,
- KX_Camera* camera)
- : SCA_IActuator(gameobj, KX_ACT_SCENE)
-{
- m_mode = mode;
- m_scene = scene;
- m_KetsjiEngine=ketsjiEngine;
- m_camera = camera;
- m_nextSceneName = nextSceneName;
- if (m_camera)
- m_camera->RegisterActuator(this);
-} /* End of constructor */
-
-
-
-KX_SceneActuator::~KX_SceneActuator()
-{
- if (m_camera)
- m_camera->UnregisterActuator(this);
-} /* end of destructor */
-
-
-
-CValue* KX_SceneActuator::GetReplica()
-{
- KX_SceneActuator* replica = new KX_SceneActuator(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_SceneActuator::ProcessReplica()
-{
- if (m_camera)
- m_camera->RegisterActuator(this);
- SCA_IActuator::ProcessReplica();
-}
-
-bool KX_SceneActuator::UnlinkObject(SCA_IObject* clientobj)
-{
- if (clientobj == (SCA_IObject*)m_camera)
- {
- // this object is being deleted, we cannot continue to track it.
- m_camera = NULL;
- return true;
- }
- return false;
-}
-
-void KX_SceneActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_camera];
- if (h_obj) {
- if (m_camera)
- m_camera->UnregisterActuator(this);
- m_camera = (KX_Camera*)(*h_obj);
- m_camera->RegisterActuator(this);
- }
-}
-
-
-bool KX_SceneActuator::Update()
-{
- // bool result = false; /*unused*/
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
-
- switch (m_mode)
- {
- case KX_SCENE_RESTART:
- {
- m_KetsjiEngine->ReplaceScene(m_scene->GetName(),m_scene->GetName());
- break;
- }
- case KX_SCENE_SET_CAMERA:
- if (m_camera)
- {
- m_scene->SetActiveCamera(m_camera);
- }
- else
- {
- // if no camera is set and the parent object is a camera, use it as the camera
- SCA_IObject* parent = GetParent();
- if (parent->GetGameObjectType()==SCA_IObject::OBJ_CAMERA)
- {
- m_scene->SetActiveCamera((KX_Camera*)parent);
- }
- }
- break;
- default:
- break;
- }
-
- if (!m_nextSceneName.Length())
- return false;
-
- switch (m_mode)
- {
- case KX_SCENE_SET_SCENE:
- {
- m_KetsjiEngine->ReplaceScene(m_scene->GetName(),m_nextSceneName);
- break;
- }
- case KX_SCENE_ADD_FRONT_SCENE:
- {
- bool overlay=true;
- m_KetsjiEngine->ConvertAndAddScene(m_nextSceneName,overlay);
- break;
- }
- case KX_SCENE_ADD_BACK_SCENE:
- {
- bool overlay=false;
- m_KetsjiEngine->ConvertAndAddScene(m_nextSceneName,overlay);
- break;
- }
- case KX_SCENE_REMOVE_SCENE:
- {
- m_KetsjiEngine->RemoveScene(m_nextSceneName);
- break;
- }
- case KX_SCENE_SUSPEND:
- {
- m_KetsjiEngine->SuspendScene(m_nextSceneName);
- break;
- }
- case KX_SCENE_RESUME:
- {
- m_KetsjiEngine->ResumeScene(m_nextSceneName);
- break;
- }
- default:
- ; /* do nothing? this is an internal error !!! */
- }
-
- return false;
-}
-
-
-
-/* returns a camera if the name is valid */
-KX_Camera* KX_SceneActuator::FindCamera(const char *camName)
-{
- KX_SceneList* sl = m_KetsjiEngine->CurrentScenes();
- STR_String name = STR_String(camName);
- KX_SceneList::iterator it = sl->begin();
- KX_Camera* cam = NULL;
-
- while ((it != sl->end()) && (!cam))
- {
- cam = (*it)->FindCamera(name);
- it++;
- }
-
- return cam;
-}
-
-
-
-KX_Scene* KX_SceneActuator::FindScene(const char *sceneName)
-{
- return m_KetsjiEngine->FindScene(sceneName);
-}
-
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_SceneActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_SceneActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_SceneActuator::Methods[] =
-{
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_SceneActuator::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW("scene",0,MAX_ID_NAME-2,true,KX_SceneActuator,m_nextSceneName),
- KX_PYATTRIBUTE_RW_FUNCTION("camera",KX_SceneActuator,pyattr_get_camera,pyattr_set_camera),
- KX_PYATTRIBUTE_BOOL_RW("useRestart", KX_SceneActuator, m_restart),
- KX_PYATTRIBUTE_INT_RW("mode", KX_SCENE_NODEF+1, KX_SCENE_MAX-1, true, KX_SceneActuator, m_mode),
- { NULL } //Sentinel
-};
-
-PyObject *KX_SceneActuator::pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SceneActuator* actuator = static_cast<KX_SceneActuator*>(self);
- if (!actuator->m_camera)
- Py_RETURN_NONE;
-
- return actuator->m_camera->GetProxy();
-}
-
-int KX_SceneActuator::pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_SceneActuator* actuator = static_cast<KX_SceneActuator*>(self);
- KX_Camera *camOb;
-
- if (!ConvertPythonToCamera(value, &camOb, true, "actu.camera = value: KX_SceneActuator"))
- return PY_SET_ATTR_FAIL;
-
- if (actuator->m_camera)
- actuator->m_camera->UnregisterActuator(actuator);
-
- if (camOb==NULL) {
- actuator->m_camera= NULL;
- }
- else {
- actuator->m_camera = camOb;
- actuator->m_camera->RegisterActuator(actuator);
- }
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h
deleted file mode 100644
index 389e9208ef3..00000000000
--- a/source/gameengine/Ketsji/KX_SceneActuator.h
+++ /dev/null
@@ -1,109 +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_SceneActuator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_SCENEACTUATOR_H__
-#define __KX_SCENEACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "SCA_IScene.h" /* Replace_IScene only */
-#include "KX_Scene.h" /* Replace_IScene only */
-
-class KX_SceneActuator : public SCA_IActuator
-{
- Py_Header
-
- int m_mode;
- // (restart) has become a toggle internally... not in the interface though
- bool m_restart;
- // (set Scene) Scene
- /** The current scene. */
- class KX_Scene* m_scene;
- class KX_KetsjiEngine* m_KetsjiEngine;
- /** The scene to switch to. */
- STR_String m_nextSceneName;
-
- // (Set Camera) Object
- class KX_Camera* m_camera;
-
- /** Is this a valid scene? */
- class KX_Scene* FindScene(const char* sceneName);
- /** Is this a valid camera? */
- class KX_Camera* FindCamera(const char* cameraName);
-
- public:
- enum SCA_SceneActuatorMode
- {
- KX_SCENE_NODEF = 0,
- KX_SCENE_RESTART,
- KX_SCENE_SET_SCENE,
- KX_SCENE_SET_CAMERA,
- KX_SCENE_ADD_FRONT_SCENE,
- KX_SCENE_ADD_BACK_SCENE,
- KX_SCENE_REMOVE_SCENE,
- KX_SCENE_SUSPEND,
- KX_SCENE_RESUME,
- KX_SCENE_MAX
- };
-
- KX_SceneActuator(SCA_IObject* gameobj,
- int mode,
- KX_Scene* scene,
- KX_KetsjiEngine* ketsjiEngine,
- const STR_String& nextSceneName,
- KX_Camera* camera);
- virtual ~KX_SceneActuator();
-
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
- virtual bool UnlinkObject(SCA_IObject* clientobj);
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
-
- virtual bool Update();
-
-#ifdef WITH_PYTHON
-
- virtual void Replace_IScene(SCA_IScene *val)
- {
- m_scene= static_cast<KX_Scene *>(val);
- };
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- static PyObject *pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
-#endif /* WITH_PYTHON */
-
-}; /* end of class KXSceneActuator */
-
-#endif
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
deleted file mode 100644
index a09429450cb..00000000000
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- * KX_SoundActuator.cpp
- *
- *
- * ***** 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_SoundActuator.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_SoundActuator.h"
-
-#ifdef WITH_AUDASPACE
-typedef float sample_t;
-# include <python/PyAPI.h>
-# include <AUD_Sound.h>
-# include <AUD_Special.h>
-# include <AUD_Device.h>
-# include <AUD_Handle.h>
-#endif
-
-#include "KX_GameObject.h"
-#include "KX_PyMath.h" // needed for PyObjectFrom()
-#include "KX_PythonInit.h"
-#include "KX_Camera.h"
-#include <iostream>
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
- AUD_Sound* sound,
- float volume,
- float pitch,
- bool is3d,
- KX_3DSoundSettings settings,
- KX_SOUNDACT_TYPE type)//,
- : SCA_IActuator(gameobj, KX_ACT_SOUND)
-{
- m_sound = sound ? AUD_Sound_copy(sound) : NULL;
- m_handle = NULL;
- m_volume = volume;
- m_pitch = pitch;
- m_is3d = is3d;
- m_3d = settings;
- m_type = type;
- m_isplaying = false;
-}
-
-
-
-KX_SoundActuator::~KX_SoundActuator()
-{
- if (m_handle) {
- AUD_Handle_stop(m_handle);
- }
-
- if (m_sound) {
- AUD_Sound_free(m_sound);
- }
-}
-
-void KX_SoundActuator::play()
-{
- if (m_handle) {
- AUD_Handle_stop(m_handle);
- m_handle = NULL;
- }
-
- if (!m_sound)
- return;
-
- // this is the sound that will be played and not deleted afterwards
- AUD_Sound* sound = m_sound;
-
- bool loop = false;
-
- switch (m_type)
- {
- case KX_SOUNDACT_LOOPBIDIRECTIONAL:
- case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
- sound = AUD_Sound_pingpong(sound);
- ATTR_FALLTHROUGH;
- case KX_SOUNDACT_LOOPEND:
- case KX_SOUNDACT_LOOPSTOP:
- loop = true;
- break;
- case KX_SOUNDACT_PLAYSTOP:
- case KX_SOUNDACT_PLAYEND:
- default:
- break;
- }
-
- AUD_Device* device = AUD_Device_getCurrent();
- m_handle = AUD_Device_play(device, sound, false);
- AUD_Device_free(device);
-
- // in case of pingpong, we have to free the sound
- if (sound != m_sound)
- AUD_Sound_free(sound);
-
- if (m_handle != NULL) {
- if (m_is3d) {
- AUD_Handle_setRelative(m_handle, true);
- AUD_Handle_setVolumeMaximum(m_handle, m_3d.max_gain);
- AUD_Handle_setVolumeMinimum(m_handle, m_3d.min_gain);
- AUD_Handle_setDistanceReference(m_handle, m_3d.reference_distance);
- AUD_Handle_setDistanceMaximum(m_handle, m_3d.max_distance);
- AUD_Handle_setAttenuation(m_handle, m_3d.rolloff_factor);
- AUD_Handle_setConeAngleInner(m_handle, m_3d.cone_inner_angle);
- AUD_Handle_setConeAngleOuter(m_handle, m_3d.cone_outer_angle);
- AUD_Handle_setConeVolumeOuter(m_handle, m_3d.cone_outer_gain);
- }
-
- if (loop)
- AUD_Handle_setLoopCount(m_handle, -1);
- AUD_Handle_setPitch(m_handle, m_pitch);
- AUD_Handle_setVolume(m_handle, m_volume);
- }
-
- m_isplaying = true;
-}
-
-CValue* KX_SoundActuator::GetReplica()
-{
- KX_SoundActuator* replica = new KX_SoundActuator(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_SoundActuator::ProcessReplica()
-{
- SCA_IActuator::ProcessReplica();
- m_handle = NULL;
- m_sound = AUD_Sound_copy(m_sound);
-}
-
-bool KX_SoundActuator::Update(double curtime, bool frame)
-{
- if (!frame)
- return true;
- bool result = false;
-
- // do nothing on negative events, otherwise sounds are played twice!
- bool bNegativeEvent = IsNegativeEvent();
- bool bPositiveEvent = m_posevent;
-
- RemoveAllEvents();
-
- if (!m_sound)
- return false;
-
- // actual audio device playing state
- bool isplaying = m_handle ? (AUD_Handle_getStatus(m_handle) == AUD_STATUS_PLAYING) : false;
-
- if (bNegativeEvent)
- {
- // here must be a check if it is still playing
- if (m_isplaying && isplaying)
- {
- switch (m_type)
- {
- case KX_SOUNDACT_PLAYSTOP:
- case KX_SOUNDACT_LOOPSTOP:
- case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
- {
- // stop immediately
- if (m_handle)
- {
- AUD_Handle_stop(m_handle);
- m_handle = NULL;
- }
- break;
- }
- case KX_SOUNDACT_PLAYEND:
- {
- // do nothing, sound will stop anyway when it's finished
- break;
- }
- case KX_SOUNDACT_LOOPEND:
- case KX_SOUNDACT_LOOPBIDIRECTIONAL:
- {
- // stop the looping so that the sound stops when it finished
- if (m_handle)
- AUD_Handle_setLoopCount(m_handle, 0);
- break;
- }
- default:
- // implement me !!
- break;
- }
- }
- // remember that we tried to stop the actuator
- m_isplaying = false;
- }
-
-#if 1
- // Warning: when de-activating the actuator, after a single negative event this runs again with...
- // m_posevent==false && m_posevent==false, in this case IsNegativeEvent() returns false
- // and assumes this is a positive event.
- // check that we actually have a positive event so as not to play sounds when being disabled.
- else if (bPositiveEvent) /* <- added since 2.49 */
-#else
- else // <- works in most cases except a loop-end sound will never stop unless
- // the negative pulse is done continuesly
-#endif
- {
- if (!m_isplaying)
- play();
- }
- // verify that the sound is still playing
- isplaying = m_handle ? (AUD_Handle_getStatus(m_handle) == AUD_STATUS_PLAYING) : false;
-
- if (isplaying)
- {
- if (m_is3d)
- {
- KX_Camera* cam = KX_GetActiveScene()->GetActiveCamera();
- if (cam)
- {
- KX_GameObject* obj = (KX_GameObject*)this->GetParent();
- MT_Point3 p;
- MT_Matrix3x3 Mo;
- float data[4];
-
- Mo = cam->NodeGetWorldOrientation().inverse();
- p = (obj->NodeGetWorldPosition() - cam->NodeGetWorldPosition());
- p = Mo * p;
- p.getValue(data);
- AUD_Handle_setLocation(m_handle, data);
- p = (obj->GetLinearVelocity() - cam->GetLinearVelocity());
- p = Mo * p;
- p.getValue(data);
- AUD_Handle_setVelocity(m_handle, data);
- (Mo * obj->NodeGetWorldOrientation()).getRotation().getValue(data);
- AUD_Handle_setOrientation(m_handle, data);
- }
- }
- result = true;
- }
- else
- {
- m_isplaying = false;
- result = false;
- }
- return result;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_SoundActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_SoundActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_SoundActuator::Methods[] = {
- KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, startSound),
- KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, pauseSound),
- KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, stopSound),
- {NULL, NULL} //Sentinel
-};
-
-PyAttributeDef KX_SoundActuator::Attributes[] = {
- KX_PYATTRIBUTE_BOOL_RO("is3D", KX_SoundActuator, m_is3d),
- KX_PYATTRIBUTE_RW_FUNCTION("volume_maximum", KX_SoundActuator, pyattr_get_3d_property, pyattr_set_3d_property),
- KX_PYATTRIBUTE_RW_FUNCTION("volume_minimum", KX_SoundActuator, pyattr_get_3d_property, pyattr_set_3d_property),
- KX_PYATTRIBUTE_RW_FUNCTION("distance_reference", KX_SoundActuator, pyattr_get_3d_property, pyattr_set_3d_property),
- KX_PYATTRIBUTE_RW_FUNCTION("distance_maximum", KX_SoundActuator, pyattr_get_3d_property, pyattr_set_3d_property),
- KX_PYATTRIBUTE_RW_FUNCTION("attenuation", KX_SoundActuator, pyattr_get_3d_property, pyattr_set_3d_property),
- KX_PYATTRIBUTE_RW_FUNCTION("cone_angle_inner", KX_SoundActuator, pyattr_get_3d_property, pyattr_set_3d_property),
- KX_PYATTRIBUTE_RW_FUNCTION("cone_angle_outer", KX_SoundActuator, pyattr_get_3d_property, pyattr_set_3d_property),
- KX_PYATTRIBUTE_RW_FUNCTION("cone_volume_outer", KX_SoundActuator, pyattr_get_3d_property, pyattr_set_3d_property),
- KX_PYATTRIBUTE_RW_FUNCTION("sound", KX_SoundActuator, pyattr_get_sound, pyattr_set_sound),
-
- KX_PYATTRIBUTE_RW_FUNCTION("time", KX_SoundActuator, pyattr_get_audposition, pyattr_set_audposition),
- KX_PYATTRIBUTE_RW_FUNCTION("volume", KX_SoundActuator, pyattr_get_gain, pyattr_set_gain),
- KX_PYATTRIBUTE_RW_FUNCTION("pitch", KX_SoundActuator, pyattr_get_pitch, pyattr_set_pitch),
- KX_PYATTRIBUTE_ENUM_RW("mode",KX_SoundActuator::KX_SOUNDACT_NODEF+1,KX_SoundActuator::KX_SOUNDACT_MAX-1,false,KX_SoundActuator,m_type),
- { NULL } //Sentinel
-};
-
-/* Methods ----------------------------------------------------------------- */
-KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound,
-"startSound()\n"
-"\tStarts the sound.\n")
-{
- switch (m_handle ? AUD_Handle_getStatus(m_handle) : AUD_STATUS_INVALID) {
- case AUD_STATUS_PLAYING:
- break;
- case AUD_STATUS_PAUSED:
- AUD_Handle_resume(m_handle);
- break;
- default:
- play();
- }
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound,
-"pauseSound()\n"
-"\tPauses the sound.\n")
-{
- if (m_handle)
- AUD_Handle_pause(m_handle);
- Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound,
-"stopSound()\n"
-"\tStops the sound.\n")
-{
- if (m_handle)
- {
- AUD_Handle_stop(m_handle);
- m_handle = NULL;
- }
- Py_RETURN_NONE;
-}
-
-/* Atribute setting and getting -------------------------------------------- */
-PyObject *KX_SoundActuator::pyattr_get_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- const char* prop = attrdef->m_name;
- float result_value = 0.0f;
-
- if (!strcmp(prop, "volume_maximum")) {
- result_value = actuator->m_3d.max_gain;
-
- } else if (!strcmp(prop, "volume_minimum")) {
- result_value = actuator->m_3d.min_gain;
-
- } else if (!strcmp(prop, "distance_reference")) {
- result_value = actuator->m_3d.reference_distance;
-
- } else if (!strcmp(prop, "distance_maximum")) {
- result_value = actuator->m_3d.max_distance;
-
- } else if (!strcmp(prop, "attenuation")) {
- result_value = actuator->m_3d.rolloff_factor;
-
- } else if (!strcmp(prop, "cone_angle_inner")) {
- result_value = actuator->m_3d.cone_inner_angle;
-
- } else if (!strcmp(prop, "cone_angle_outer")) {
- result_value = actuator->m_3d.cone_outer_angle;
-
- } else if (!strcmp(prop, "cone_volume_outer")) {
- result_value = actuator->m_3d.cone_outer_gain;
-
- } else {
- Py_RETURN_NONE;
- }
-
- PyObject *result = PyFloat_FromDouble(result_value);
- return result;
-}
-
-PyObject *KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- float position = 0.0f;
-
- if (actuator->m_handle)
- position = AUD_Handle_getPosition(actuator->m_handle);
-
- PyObject *result = PyFloat_FromDouble(position);
-
- return result;
-}
-
-PyObject *KX_SoundActuator::pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- float gain = actuator->m_volume;
-
- PyObject *result = PyFloat_FromDouble(gain);
-
- return result;
-}
-
-PyObject *KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- float pitch = actuator->m_pitch;
-
- PyObject *result = PyFloat_FromDouble(pitch);
-
- return result;
-}
-
-PyObject *KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- if (actuator->m_sound)
- return (PyObject *)AUD_getPythonSound(actuator->m_sound);
- else
- Py_RETURN_NONE;
-}
-
-int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- const char* prop = attrdef->m_name;
- float prop_value = 0.0f;
-
- if (!PyArg_Parse(value, "f", &prop_value))
- return PY_SET_ATTR_FAIL;
-
- // if sound is working and 3D, set the new setting
- if (!actuator->m_is3d)
- return PY_SET_ATTR_FAIL;
-
- if (!strcmp(prop, "volume_maximum")) {
- actuator->m_3d.max_gain = prop_value;
- if (actuator->m_handle)
- AUD_Handle_setVolumeMaximum(actuator->m_handle, prop_value);
-
- } else if (!strcmp(prop, "volume_minimum")) {
- actuator->m_3d.min_gain = prop_value;
- if (actuator->m_handle)
- AUD_Handle_setVolumeMinimum(actuator->m_handle, prop_value);
-
- } else if (!strcmp(prop, "distance_reference")) {
- actuator->m_3d.reference_distance = prop_value;
- if (actuator->m_handle)
- AUD_Handle_setDistanceReference(actuator->m_handle, prop_value);
-
- } else if (!strcmp(prop, "distance_maximum")) {
- actuator->m_3d.max_distance = prop_value;
- if (actuator->m_handle)
- AUD_Handle_setDistanceMaximum(actuator->m_handle, prop_value);
-
- } else if (!strcmp(prop, "attenuation")) {
- actuator->m_3d.rolloff_factor = prop_value;
- if (actuator->m_handle)
- AUD_Handle_setAttenuation(actuator->m_handle, prop_value);
-
- } else if (!strcmp(prop, "cone_angle_inner")) {
- actuator->m_3d.cone_inner_angle = prop_value;
- if (actuator->m_handle)
- AUD_Handle_setConeAngleInner(actuator->m_handle, prop_value);
-
- } else if (!strcmp(prop, "cone_angle_outer")) {
- actuator->m_3d.cone_outer_angle = prop_value;
- if (actuator->m_handle)
- AUD_Handle_setConeAngleOuter(actuator->m_handle, prop_value);
-
- } else if (!strcmp(prop, "cone_volume_outer")) {
- actuator->m_3d.cone_outer_gain = prop_value;
- if (actuator->m_handle)
- AUD_Handle_setConeVolumeOuter(actuator->m_handle, prop_value);
-
- } else {
- return PY_SET_ATTR_FAIL;
- }
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
-
- float position = 1.0f;
- if (!PyArg_Parse(value, "f", &position))
- return PY_SET_ATTR_FAIL;
-
- if (actuator->m_handle)
- AUD_Handle_setPosition(actuator->m_handle, position);
- return PY_SET_ATTR_SUCCESS;
-}
-
-int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- float gain = 1.0f;
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- if (!PyArg_Parse(value, "f", &gain))
- return PY_SET_ATTR_FAIL;
-
- actuator->m_volume = gain;
- if (actuator->m_handle)
- AUD_Handle_setVolume(actuator->m_handle, gain);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- float pitch = 1.0f;
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- if (!PyArg_Parse(value, "f", &pitch))
- return PY_SET_ATTR_FAIL;
-
- actuator->m_pitch = pitch;
- if (actuator->m_handle)
- AUD_Handle_setPitch(actuator->m_handle, pitch);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-int KX_SoundActuator::pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- PyObject *sound = NULL;
- KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
- if (!PyArg_Parse(value, "O", &sound))
- return PY_SET_ATTR_FAIL;
-
- AUD_Sound *snd = AUD_getSoundFromPython(sound);
-
- if (snd)
- {
- AUD_Sound_free(actuator->m_sound);
- actuator->m_sound = snd;
- return PY_SET_ATTR_SUCCESS;
- }
-
- return PY_SET_ATTR_FAIL;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h
deleted file mode 100644
index 4f3e6f707e0..00000000000
--- a/source/gameengine/Ketsji/KX_SoundActuator.h
+++ /dev/null
@@ -1,127 +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_SoundActuator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_SOUNDACTUATOR_H__
-#define __KX_SOUNDACTUATOR_H__
-
-#include "SCA_IActuator.h"
-
-#ifdef WITH_AUDASPACE
-# include <AUD_Sound.h>
-# include <AUD_Handle.h>
-#endif
-
-#include "BKE_sound.h"
-
-typedef struct KX_3DSoundSettings {
- float min_gain;
- float max_gain;
- float reference_distance;
- float max_distance;
- float rolloff_factor;
- float cone_inner_angle;
- float cone_outer_angle;
- float cone_outer_gain;
-} KX_3DSoundSettings;
-
-class KX_SoundActuator : public SCA_IActuator
-{
- Py_Header
- bool m_isplaying;
- AUD_Sound* m_sound;
- float m_volume;
- float m_pitch;
- bool m_is3d;
- KX_3DSoundSettings m_3d;
- AUD_Handle* m_handle;
-
- void play();
-
-public:
-
- enum KX_SOUNDACT_TYPE
- {
- KX_SOUNDACT_NODEF = 0,
- KX_SOUNDACT_PLAYSTOP,
- KX_SOUNDACT_PLAYEND,
- KX_SOUNDACT_LOOPSTOP,
- KX_SOUNDACT_LOOPEND,
- KX_SOUNDACT_LOOPBIDIRECTIONAL,
- KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP,
- KX_SOUNDACT_MAX
- };
-
- KX_SOUNDACT_TYPE m_type;
-
- KX_SoundActuator(SCA_IObject* gameobj,
- AUD_Sound *sound,
- float volume,
- float pitch,
- bool is3d,
- KX_3DSoundSettings settings,
- KX_SOUNDACT_TYPE type);
-
- ~KX_SoundActuator();
-
- virtual bool Update(double curtime, bool frame);
-
- CValue* GetReplica();
- void ProcessReplica();
-
-#ifdef WITH_PYTHON
-
- /* -------------------------------------------------------------------- */
- /* Python interface --------------------------------------------------- */
- /* -------------------------------------------------------------------- */
-
- KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, startSound);
- KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, pauseSound);
- KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, stopSound);
-
- static int pyattr_set_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- static PyObject *pyattr_get_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
-
-#endif /* WITH_PYTHON */
-
-};
-
-#endif /* __KX_SOUNDACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp
deleted file mode 100644
index d918f87c4bf..00000000000
--- a/source/gameengine/Ketsji/KX_StateActuator.cpp
+++ /dev/null
@@ -1,171 +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 *****
- * Actuator to toggle visibility/invisibility of objects
- */
-
-/** \file gameengine/Ketsji/KX_StateActuator.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_StateActuator.h"
-#include "KX_GameObject.h"
-
-KX_StateActuator::KX_StateActuator(
- SCA_IObject* gameobj,
- int operation,
- unsigned int mask
- )
- : SCA_IActuator(gameobj, KX_ACT_STATE),
- m_operation(operation),
- m_mask(mask)
-{
- // intentionally empty
-}
-
-KX_StateActuator::~KX_StateActuator(
- void
- )
-{
- // intentionally empty
-}
-
-// used to put state actuator to be executed before any other actuators
-SG_QList KX_StateActuator::m_stateActuatorHead;
-
-CValue*
-KX_StateActuator::GetReplica(
- void
- )
-{
- KX_StateActuator* replica = new KX_StateActuator(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-bool
-KX_StateActuator::Update()
-{
- bool bNegativeEvent = IsNegativeEvent();
- unsigned int objMask;
-
- // execution of state actuator means that we are in the execution phase, reset this pointer
- // because all the active actuator of this object will be removed for sure.
- m_gameobj->m_firstState = NULL;
- RemoveAllEvents();
- if (bNegativeEvent) return false;
-
- KX_GameObject *obj = (KX_GameObject*) GetParent();
-
- objMask = obj->GetState();
- switch (m_operation)
- {
- case OP_CPY:
- objMask = m_mask;
- break;
- case OP_SET:
- objMask |= m_mask;
- break;
- case OP_CLR:
- objMask &= ~m_mask;
- break;
- case OP_NEG:
- objMask ^= m_mask;
- break;
- default:
- // unsupported operation, no nothing
- return false;
- }
- obj->SetState(objMask);
- return false;
-}
-
-// this function is only used to deactivate actuators outside the logic loop
-// e.g. when an object is deleted.
-void KX_StateActuator::Deactivate()
-{
- if (QDelink())
- {
- // the actuator was in the active list
- if (m_stateActuatorHead.QEmpty())
- // no more state object active
- m_stateActuatorHead.Delink();
- }
-}
-
-void KX_StateActuator::Activate(SG_DList& head)
-{
- // sort the state actuators per object on the global list
- if (QEmpty())
- {
- InsertSelfActiveQList(m_stateActuatorHead, &m_gameobj->m_firstState);
- // add front to make sure it runs before other actuators
- head.AddFront(&m_stateActuatorHead);
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_StateActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_StateActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_StateActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_StateActuator::Attributes[] = {
- KX_PYATTRIBUTE_INT_RW("operation",KX_StateActuator::OP_NOP+1,KX_StateActuator::OP_COUNT-1,false,KX_StateActuator,m_operation),
- KX_PYATTRIBUTE_INT_RW("mask",0,0x3FFFFFFF,false,KX_StateActuator,m_mask),
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_StateActuator.h b/source/gameengine/Ketsji/KX_StateActuator.h
deleted file mode 100644
index 5ed065d3604..00000000000
--- a/source/gameengine/Ketsji/KX_StateActuator.h
+++ /dev/null
@@ -1,97 +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_StateActuator.h
- * \ingroup ketsji
- * \brief Actuator to toggle visibility/invisibility of objects
- */
-
-#ifndef __KX_STATEACTUATOR_H__
-#define __KX_STATEACTUATOR_H__
-
-#include "SCA_IActuator.h"
-
-
-/*
- * Use of SG_DList : element of actuator being deactivated
- * Head: SCA_LogicManager::m_removedActuators
- * Use of SG_QList : element of global activated state actuator list
- * Head: KX_StateActuator::m_stateActuatorHead
- */
-class KX_StateActuator : public SCA_IActuator
-{
- Py_Header
-
- /** Make visible? */
- enum {
- OP_NOP = -1,
- OP_CPY = 0,
- OP_SET,
- OP_CLR,
- OP_NEG,
- OP_COUNT
- };
- // SG_Dlist: element of objects with active actuators, always put in front of the list
- // Head: SCA_LogicManager::m_activeActuators
- // SG_QList: Head of active state actuators list globally
- // Elements: KX_StateActuator
- static SG_QList m_stateActuatorHead;
- int m_operation;
- int m_mask;
-
- public:
-
- KX_StateActuator(
- SCA_IObject* gameobj,
- int operation,
- unsigned int mask
- );
-
- virtual
- ~KX_StateActuator(
- void
- );
-
- virtual CValue*
- GetReplica(
- void
- );
-
- virtual bool
- Update();
-
- virtual void Deactivate();
- virtual void Activate(SG_DList& head);
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.cpp b/source/gameengine/Ketsji/KX_SteeringActuator.cpp
deleted file mode 100644
index d3a7b665e61..00000000000
--- a/source/gameengine/Ketsji/KX_SteeringActuator.cpp
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * Add steering behaviors
- *
- *
- * ***** 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 *****
- */
-
-#include "BLI_math.h"
-#include "KX_SteeringActuator.h"
-#include "KX_GameObject.h"
-#include "KX_NavMeshObject.h"
-#include "KX_ObstacleSimulation.h"
-#include "KX_PythonInit.h"
-#include "KX_PyMath.h"
-#include "Recast.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_SteeringActuator::KX_SteeringActuator(SCA_IObject *gameobj,
- int mode,
- KX_GameObject *target,
- KX_GameObject *navmesh,
- float distance,
- float velocity,
- float acceleration,
- float turnspeed,
- bool isSelfTerminated,
- int pathUpdatePeriod,
- KX_ObstacleSimulation* simulation,
- short facingmode,
- bool normalup,
- bool enableVisualization,
- bool lockzvel)
- : SCA_IActuator(gameobj, KX_ACT_STEERING),
- m_target(target),
- m_mode(mode),
- m_distance(distance),
- m_velocity(velocity),
- m_acceleration(acceleration),
- m_turnspeed(turnspeed),
- m_simulation(simulation),
- m_updateTime(0),
- m_obstacle(NULL),
- m_isActive(false),
- m_isSelfTerminated(isSelfTerminated),
- m_enableVisualization(enableVisualization),
- m_facingMode(facingmode),
- m_normalUp(normalup),
- m_pathLen(0),
- m_pathUpdatePeriod(pathUpdatePeriod),
- m_lockzvel(lockzvel),
- m_wayPointIdx(-1),
- m_steerVec(MT_Vector3(0, 0, 0))
-{
- m_navmesh = static_cast<KX_NavMeshObject*>(navmesh);
- if (m_navmesh)
- m_navmesh->RegisterActuator(this);
- if (m_target)
- m_target->RegisterActuator(this);
-
- if (m_simulation)
- m_obstacle = m_simulation->GetObstacle((KX_GameObject*)gameobj);
- KX_GameObject* parent = ((KX_GameObject*)gameobj)->GetParent();
- if (m_facingMode>0 && parent)
- {
- m_parentlocalmat = parent->GetSGNode()->GetLocalOrientation();
- }
- else
- m_parentlocalmat.setIdentity();
-}
-
-KX_SteeringActuator::~KX_SteeringActuator()
-{
- if (m_navmesh)
- m_navmesh->UnregisterActuator(this);
- if (m_target)
- m_target->UnregisterActuator(this);
-}
-
-CValue* KX_SteeringActuator::GetReplica()
-{
- KX_SteeringActuator* replica = new KX_SteeringActuator(*this);
- // replication just copy the m_base pointer => common random generator
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_SteeringActuator::ProcessReplica()
-{
- if (m_target)
- m_target->RegisterActuator(this);
- if (m_navmesh)
- m_navmesh->RegisterActuator(this);
- SCA_IActuator::ProcessReplica();
-}
-
-void KX_SteeringActuator::ReParent(SCA_IObject* parent)
-{
- SCA_IActuator::ReParent(parent);
- if (m_simulation)
- m_obstacle = m_simulation->GetObstacle((KX_GameObject*)m_gameobj);
-}
-
-bool KX_SteeringActuator::UnlinkObject(SCA_IObject* clientobj)
-{
- if (clientobj == m_target)
- {
- m_target = NULL;
- return true;
- }
- else if (clientobj == m_navmesh)
- {
- m_navmesh = NULL;
- return true;
- }
- return false;
-}
-
-void KX_SteeringActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_target];
- if (h_obj) {
- if (m_target)
- m_target->UnregisterActuator(this);
- m_target = (KX_GameObject*)(*h_obj);
- m_target->RegisterActuator(this);
- }
-
- h_obj = (*obj_map)[m_navmesh];
- if (h_obj) {
- if (m_navmesh)
- m_navmesh->UnregisterActuator(this);
- m_navmesh = (KX_NavMeshObject*)(*h_obj);
- m_navmesh->RegisterActuator(this);
- }
-}
-
-bool KX_SteeringActuator::Update(double curtime, bool frame)
-{
- if (frame)
- {
- double delta = curtime - m_updateTime;
- m_updateTime = curtime;
-
- if (m_posevent && !m_isActive)
- {
- delta = 0.0;
- m_pathUpdateTime = -1.0;
- m_updateTime = curtime;
- m_isActive = true;
- }
- bool bNegativeEvent = IsNegativeEvent();
- if (bNegativeEvent)
- m_isActive = false;
-
- RemoveAllEvents();
-
- if (!delta)
- return true;
-
- if (bNegativeEvent || !m_target)
- return false; // do nothing on negative events
-
- KX_GameObject *obj = (KX_GameObject*) GetParent();
- const MT_Point3& mypos = obj->NodeGetWorldPosition();
- const MT_Point3& targpos = m_target->NodeGetWorldPosition();
- MT_Vector3 vectotarg = targpos - mypos;
- MT_Vector3 vectotarg2d = vectotarg;
- vectotarg2d.z() = 0.0f;
- m_steerVec = MT_Vector3(0.0f, 0.0f, 0.0f);
- bool apply_steerforce = false;
- bool terminate = true;
-
- switch (m_mode) {
- case KX_STEERING_SEEK:
- if (vectotarg2d.length2()>m_distance*m_distance)
- {
- terminate = false;
- m_steerVec = vectotarg;
- m_steerVec.normalize();
- apply_steerforce = true;
- }
- break;
- case KX_STEERING_FLEE:
- if (vectotarg2d.length2()<m_distance*m_distance)
- {
- terminate = false;
- m_steerVec = -vectotarg;
- m_steerVec.normalize();
- apply_steerforce = true;
- }
- break;
- case KX_STEERING_PATHFOLLOWING:
- if (m_navmesh && vectotarg.length2()>m_distance*m_distance)
- {
- terminate = false;
-
- static const MT_Scalar WAYPOINT_RADIUS(0.25f);
-
- if (m_pathUpdateTime<0 || (m_pathUpdatePeriod>=0 &&
- curtime - m_pathUpdateTime>((double)m_pathUpdatePeriod/1000.0)))
- {
- m_pathUpdateTime = curtime;
- m_pathLen = m_navmesh->FindPath(mypos, targpos, m_path, MAX_PATH_LENGTH);
- m_wayPointIdx = m_pathLen > 1 ? 1 : -1;
- }
-
- if (m_wayPointIdx>0)
- {
- MT_Vector3 waypoint(&m_path[3*m_wayPointIdx]);
- if ((waypoint-mypos).length2()<WAYPOINT_RADIUS*WAYPOINT_RADIUS)
- {
- m_wayPointIdx++;
- if (m_wayPointIdx>=m_pathLen)
- {
- m_wayPointIdx = -1;
- terminate = true;
- }
- else
- waypoint.setValue(&m_path[3*m_wayPointIdx]);
- }
-
- m_steerVec = waypoint - mypos;
- apply_steerforce = true;
-
-
- if (m_enableVisualization)
- {
- //debug draw
- static const MT_Vector3 PATH_COLOR(1.0f,0.0f,0.0f);
- m_navmesh->DrawPath(m_path, m_pathLen, PATH_COLOR);
- }
- }
-
- }
- break;
- }
-
- if (apply_steerforce)
- {
- bool isdyna = obj->IsDynamic();
- if (isdyna)
- m_steerVec.z() = 0;
- if (!m_steerVec.fuzzyZero())
- m_steerVec.normalize();
- MT_Vector3 newvel = m_velocity * m_steerVec;
-
- //adjust velocity to avoid obstacles
- if (m_simulation && m_obstacle /*&& !newvel.fuzzyZero()*/)
- {
- if (m_enableVisualization)
- KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(1.0f, 0.0f, 0.0f));
- m_simulation->AdjustObstacleVelocity(m_obstacle, m_mode!=KX_STEERING_PATHFOLLOWING ? m_navmesh : NULL,
- newvel, m_acceleration*(float)delta, m_turnspeed/(180.0f*(float)(M_PI*delta)));
- if (m_enableVisualization)
- KX_RasterizerDrawDebugLine(mypos, mypos + newvel, MT_Vector3(0.0f, 1.0f, 0.0f));
- }
-
- HandleActorFace(newvel);
- if (isdyna)
- {
- //temporary solution: set 2D steering velocity directly to obj
- //correct way is to apply physical force
- MT_Vector3 curvel = obj->GetLinearVelocity();
-
- if (m_lockzvel)
- newvel.z() = 0.0f;
- else
- newvel.z() = curvel.z();
-
- obj->setLinearVelocity(newvel, false);
- }
- else
- {
- MT_Vector3 movement = delta*newvel;
- obj->ApplyMovement(movement, false);
- }
- }
- else
- {
- if (m_simulation && m_obstacle)
- {
- m_obstacle->dvel[0] = 0.f;
- m_obstacle->dvel[1] = 0.f;
- }
-
- }
-
- if (terminate && m_isSelfTerminated)
- return false;
- }
-
- return true;
-}
-
-const MT_Vector3& KX_SteeringActuator::GetSteeringVec()
-{
- static MT_Vector3 ZERO_VECTOR(0, 0, 0);
- if (m_isActive)
- return m_steerVec;
- else
- return ZERO_VECTOR;
-}
-
-inline float vdot2(const float* a, const float* b)
-{
- return a[0]*b[0] + a[2]*b[2];
-}
-static bool barDistSqPointToTri(const float* p, const float* a, const float* b, const float* c)
-{
- float v0[3], v1[3], v2[3];
- rcVsub(v0, c,a);
- rcVsub(v1, b,a);
- rcVsub(v2, p,a);
-
- const float dot00 = vdot2(v0, v0);
- const float dot01 = vdot2(v0, v1);
- const float dot02 = vdot2(v0, v2);
- const float dot11 = vdot2(v1, v1);
- const float dot12 = vdot2(v1, v2);
-
- // Compute barycentric coordinates
- float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01);
- float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
- float v = (dot00 * dot12 - dot01 * dot02) * invDenom;
-
- float ud = u<0.f ? -u : (u>1.f ? u-1.f : 0.f);
- float vd = v<0.f ? -v : (v>1.f ? v-1.f : 0.f);
- return ud * ud + vd * vd;
-}
-
-inline void flipAxes(float* vec)
-{
- std::swap(vec[1],vec[2]);
-}
-
-static bool getNavmeshNormal(dtStatNavMesh* navmesh, const MT_Vector3& pos, MT_Vector3& normal)
-{
- static const float polyPickExt[3] = {2, 4, 2};
- float spos[3];
- pos.getValue(spos);
- flipAxes(spos);
- dtStatPolyRef sPolyRef = navmesh->findNearestPoly(spos, polyPickExt);
- if (sPolyRef == 0)
- return false;
- const dtStatPoly* p = navmesh->getPoly(sPolyRef-1);
- const dtStatPolyDetail* pd = navmesh->getPolyDetail(sPolyRef-1);
-
- float distMin = FLT_MAX;
- int idxMin = -1;
- for (int i = 0; i < pd->ntris; ++i)
- {
- const unsigned char* t = navmesh->getDetailTri(pd->tbase+i);
- const float* v[3];
- for (int j = 0; j < 3; ++j)
- {
- if (t[j] < p->nv)
- v[j] = navmesh->getVertex(p->v[t[j]]);
- else
- v[j] = navmesh->getDetailVertex(pd->vbase+(t[j]-p->nv));
- }
- float dist = barDistSqPointToTri(spos, v[0], v[1], v[2]);
- if (dist<distMin)
- {
- distMin = dist;
- idxMin = i;
- }
- }
-
- if (idxMin>=0)
- {
- const unsigned char* t = navmesh->getDetailTri(pd->tbase+idxMin);
- const float* v[3];
- for (int j = 0; j < 3; ++j)
- {
- if (t[j] < p->nv)
- v[j] = navmesh->getVertex(p->v[t[j]]);
- else
- v[j] = navmesh->getDetailVertex(pd->vbase+(t[j]-p->nv));
- }
- MT_Vector3 tri[3];
- for (size_t j=0; j<3; j++)
- tri[j].setValue(v[j][0],v[j][2],v[j][1]);
- MT_Vector3 a,b;
- a = tri[1]-tri[0];
- b = tri[2]-tri[0];
- normal = b.cross(a).safe_normalized();
- return true;
- }
-
- return false;
-}
-
-void KX_SteeringActuator::HandleActorFace(MT_Vector3& velocity)
-{
- if (m_facingMode==0 && (!m_navmesh || !m_normalUp))
- return;
- KX_GameObject* curobj = (KX_GameObject*) GetParent();
- MT_Vector3 dir = m_facingMode==0 ? curobj->NodeGetLocalOrientation().getColumn(1) : velocity;
- if (dir.fuzzyZero())
- return;
- dir.normalize();
- MT_Vector3 up(0,0,1);
- MT_Vector3 left;
- MT_Matrix3x3 mat;
-
- if (m_navmesh && m_normalUp)
- {
- dtStatNavMesh* navmesh = m_navmesh->GetNavMesh();
- MT_Vector3 normal;
- MT_Vector3 trpos = m_navmesh->TransformToLocalCoords(curobj->NodeGetWorldPosition());
- if (getNavmeshNormal(navmesh, trpos, normal))
- {
-
- left = (dir.cross(up)).safe_normalized();
- dir = (-left.cross(normal)).safe_normalized();
- up = normal;
- }
- }
-
- switch (m_facingMode)
- {
- case 1: // TRACK X
- {
- left = dir.safe_normalized();
- dir = -(left.cross(up)).safe_normalized();
- break;
- };
- case 2: // TRACK Y
- {
- left = (dir.cross(up)).safe_normalized();
- break;
- }
-
- case 3: // track Z
- {
- left = up.safe_normalized();
- up = dir.safe_normalized();
- dir = left;
- left = (dir.cross(up)).safe_normalized();
- break;
- }
-
- case 4: // TRACK -X
- {
- left = -dir.safe_normalized();
- dir = -(left.cross(up)).safe_normalized();
- break;
- };
- case 5: // TRACK -Y
- {
- left = (-dir.cross(up)).safe_normalized();
- dir = -dir;
- break;
- }
- case 6: // track -Z
- {
- left = up.safe_normalized();
- up = -dir.safe_normalized();
- dir = left;
- left = (dir.cross(up)).safe_normalized();
- break;
- }
- }
-
- mat.setValue (
- left[0], dir[0],up[0],
- left[1], dir[1],up[1],
- left[2], dir[2],up[2]
- );
-
-
-
- KX_GameObject* parentObject = curobj->GetParent();
- if (parentObject)
- {
- MT_Point3 localpos;
- localpos = curobj->GetSGNode()->GetLocalPosition();
- MT_Matrix3x3 parentmatinv;
- parentmatinv = parentObject->NodeGetWorldOrientation ().inverse ();
- mat = parentmatinv * mat;
- mat = m_parentlocalmat * mat;
- curobj->NodeSetLocalOrientation(mat);
- curobj->NodeSetLocalPosition(localpos);
- }
- else
- {
- curobj->NodeSetLocalOrientation(mat);
- }
-
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_SteeringActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_SteeringActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_SteeringActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_SteeringActuator::Attributes[] = {
- KX_PYATTRIBUTE_INT_RW("behavior", KX_STEERING_NODEF+1, KX_STEERING_MAX-1, true, KX_SteeringActuator, m_mode),
- KX_PYATTRIBUTE_RW_FUNCTION("target", KX_SteeringActuator, pyattr_get_target, pyattr_set_target),
- KX_PYATTRIBUTE_RW_FUNCTION("navmesh", KX_SteeringActuator, pyattr_get_navmesh, pyattr_set_navmesh),
- KX_PYATTRIBUTE_FLOAT_RW("distance", 0.0f, 1000.0f, KX_SteeringActuator, m_distance),
- KX_PYATTRIBUTE_FLOAT_RW("velocity", 0.0f, 1000.0f, KX_SteeringActuator, m_velocity),
- KX_PYATTRIBUTE_FLOAT_RW("acceleration", 0.0f, 1000.0f, KX_SteeringActuator, m_acceleration),
- KX_PYATTRIBUTE_FLOAT_RW("turnspeed", 0.0f, 720.0f, KX_SteeringActuator, m_turnspeed),
- KX_PYATTRIBUTE_BOOL_RW("selfterminated", KX_SteeringActuator, m_isSelfTerminated),
- KX_PYATTRIBUTE_BOOL_RW("enableVisualization", KX_SteeringActuator, m_enableVisualization),
- KX_PYATTRIBUTE_RO_FUNCTION("steeringVec", KX_SteeringActuator, pyattr_get_steeringVec),
- KX_PYATTRIBUTE_SHORT_RW("facingMode", 0, 6, true, KX_SteeringActuator, m_facingMode),
- KX_PYATTRIBUTE_INT_RW("pathUpdatePeriod", -1, 100000, true, KX_SteeringActuator, m_pathUpdatePeriod),
- KX_PYATTRIBUTE_BOOL_RW("lockZVelocity", KX_SteeringActuator, m_lockzvel),
- { NULL } //Sentinel
-};
-
-PyObject *KX_SteeringActuator::pyattr_get_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self);
- if (!actuator->m_target)
- Py_RETURN_NONE;
- else
- return actuator->m_target->GetProxy();
-}
-
-int KX_SteeringActuator::pyattr_set_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self);
- KX_GameObject *gameobj;
-
- if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_SteeringActuator"))
- return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
-
- if (actuator->m_target != NULL)
- actuator->m_target->UnregisterActuator(actuator);
-
- actuator->m_target = (KX_GameObject*) gameobj;
-
- if (actuator->m_target)
- actuator->m_target->RegisterActuator(actuator);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_SteeringActuator::pyattr_get_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self);
- if (!actuator->m_navmesh)
- Py_RETURN_NONE;
- else
- return actuator->m_navmesh->GetProxy();
-}
-
-int KX_SteeringActuator::pyattr_set_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self);
- KX_GameObject *gameobj;
-
- if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_SteeringActuator"))
- return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
-
- if (dynamic_cast<KX_NavMeshObject *>(gameobj) == NULL) {
- PyErr_Format(PyExc_TypeError, "KX_NavMeshObject is expected");
- return PY_SET_ATTR_FAIL;
- }
-
- if (actuator->m_navmesh != NULL)
- actuator->m_navmesh->UnregisterActuator(actuator);
-
- actuator->m_navmesh = static_cast<KX_NavMeshObject*>(gameobj);
-
- if (actuator->m_navmesh)
- actuator->m_navmesh->RegisterActuator(actuator);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-PyObject *KX_SteeringActuator::pyattr_get_steeringVec(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_SteeringActuator* actuator = static_cast<KX_SteeringActuator*>(self);
- const MT_Vector3& steeringVec = actuator->GetSteeringVec();
- return PyObjectFrom(steeringVec);
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
-
diff --git a/source/gameengine/Ketsji/KX_SteeringActuator.h b/source/gameengine/Ketsji/KX_SteeringActuator.h
deleted file mode 100644
index 3273471c166..00000000000
--- a/source/gameengine/Ketsji/KX_SteeringActuator.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Add steering behaviors
- *
- * ***** 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: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __KX_STEERINGACTUATOR_H__
-#define __KX_STEERINGACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "SCA_LogicManager.h"
-#include "MT_Matrix3x3.h"
-
-class KX_GameObject;
-class KX_NavMeshObject;
-struct KX_Obstacle;
-class KX_ObstacleSimulation;
-const int MAX_PATH_LENGTH = 128;
-
-class KX_SteeringActuator : public SCA_IActuator
-{
- Py_Header
-
- /** Target object */
- KX_GameObject *m_target;
- KX_NavMeshObject *m_navmesh;
- int m_mode;
- float m_distance;
- float m_velocity;
- float m_acceleration;
- float m_turnspeed;
- KX_ObstacleSimulation* m_simulation;
-
- double m_updateTime;
- KX_Obstacle* m_obstacle;
- bool m_isActive;
- bool m_isSelfTerminated;
- bool m_enableVisualization;
- short m_facingMode;
- bool m_normalUp;
- float m_path[MAX_PATH_LENGTH*3];
- int m_pathLen;
- int m_pathUpdatePeriod;
- double m_pathUpdateTime;
- bool m_lockzvel;
- int m_wayPointIdx;
- MT_Matrix3x3 m_parentlocalmat;
- MT_Vector3 m_steerVec;
- void HandleActorFace(MT_Vector3& velocity);
-public:
- enum KX_STEERINGACT_MODE
- {
- KX_STEERING_NODEF = 0,
- KX_STEERING_SEEK,
- KX_STEERING_FLEE,
- KX_STEERING_PATHFOLLOWING,
- KX_STEERING_MAX
- };
-
- KX_SteeringActuator(class SCA_IObject* gameobj,
- int mode,
- KX_GameObject *target,
- KX_GameObject *navmesh,
- float distance,
- float velocity,
- float acceleration,
- float turnspeed,
- bool isSelfTerminated,
- int pathUpdatePeriod,
- KX_ObstacleSimulation* simulation,
- short facingmode,
- bool normalup,
- bool enableVisualization,
- bool lockzvel);
- virtual ~KX_SteeringActuator();
- virtual bool Update(double curtime, bool frame);
-
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
- virtual void ReParent(SCA_IObject* parent);
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
- virtual bool UnlinkObject(SCA_IObject* clientobj);
- const MT_Vector3& GetSteeringVec();
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- /* These are used to get and set m_target */
- static PyObject *pyattr_get_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_steeringVec(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
-
-
-#endif /* WITH_PYTHON */
-
-}; /* end of class KX_SteeringActuator : public SCA_PropertyActuator */
-
-#endif /* __KX_STEERINGACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_TimeCategoryLogger.cpp b/source/gameengine/Ketsji/KX_TimeCategoryLogger.cpp
deleted file mode 100644
index 13717993c4c..00000000000
--- a/source/gameengine/Ketsji/KX_TimeCategoryLogger.cpp
+++ /dev/null
@@ -1,141 +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_TimeCategoryLogger.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_TimeCategoryLogger.h"
-
-KX_TimeCategoryLogger::KX_TimeCategoryLogger(unsigned int maxNumMeasurements)
-: m_maxNumMeasurements(maxNumMeasurements)
-{
-}
-
-
-KX_TimeCategoryLogger::~KX_TimeCategoryLogger(void)
-{
- DisposeLoggers();
-}
-
-
-void KX_TimeCategoryLogger::SetMaxNumMeasurements(unsigned int maxNumMeasurements)
-{
- KX_TimeLoggerMap::iterator it;
- for (it = m_loggers.begin(); it != m_loggers.end(); it++) {
- it->second->SetMaxNumMeasurements(maxNumMeasurements);
- }
- m_maxNumMeasurements = maxNumMeasurements;
-}
-
-
-unsigned int KX_TimeCategoryLogger::GetMaxNumMeasurements(void) const
-{
- return m_maxNumMeasurements;
-}
-
-
-void KX_TimeCategoryLogger::AddCategory(TimeCategory tc)
-{
- // Only add if not already present
- if (m_loggers.find(tc) == m_loggers.end()) {
- KX_TimeLogger* logger = new KX_TimeLogger(m_maxNumMeasurements);
- //assert(logger);
- m_loggers.insert(KX_TimeLoggerMap::value_type(tc, logger));
- }
-}
-
-
-void KX_TimeCategoryLogger::StartLog(TimeCategory tc, double now, bool endOtherCategories)
-{
- if (endOtherCategories) {
- KX_TimeLoggerMap::iterator it;
- for (it = m_loggers.begin(); it != m_loggers.end(); it++) {
- if (it->first != tc) {
- it->second->EndLog(now);
- }
- }
- }
- //assert(m_loggers[tc] != m_loggers.end());
- m_loggers[tc]->StartLog(now);
-}
-
-
-void KX_TimeCategoryLogger::EndLog(TimeCategory tc, double now)
-{
- //assert(m_loggers[tc] != m_loggers.end());
- m_loggers[tc]->EndLog(now);
-}
-
-
-void KX_TimeCategoryLogger::EndLog(double now)
-{
- KX_TimeLoggerMap::iterator it;
- for (it = m_loggers.begin(); it != m_loggers.end(); it++) {
- it->second->EndLog(now);
- }
-}
-
-
-void KX_TimeCategoryLogger::NextMeasurement(double now)
-{
- KX_TimeLoggerMap::iterator it;
- for (it = m_loggers.begin(); it != m_loggers.end(); it++) {
- it->second->NextMeasurement(now);
- }
-}
-
-
-double KX_TimeCategoryLogger::GetAverage(TimeCategory tc)
-{
- //assert(m_loggers[tc] != m_loggers.end());
- return m_loggers[tc]->GetAverage();
-}
-
-
-double KX_TimeCategoryLogger::GetAverage(void)
-{
- double time = 0.0;
-
- KX_TimeLoggerMap::iterator it;
- for (it = m_loggers.begin(); it != m_loggers.end(); it++) {
- time += it->second->GetAverage();
- }
-
- return time;
-}
-
-
-void KX_TimeCategoryLogger::DisposeLoggers(void)
-{
- KX_TimeLoggerMap::iterator it;
- for (it = m_loggers.begin(); it != m_loggers.end(); it++) {
- delete it->second;
- }
-}
-
diff --git a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h
deleted file mode 100644
index e097454fca7..00000000000
--- a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h
+++ /dev/null
@@ -1,136 +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_TimeCategoryLogger.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_TIMECATEGORYLOGGER_H__
-#define __KX_TIMECATEGORYLOGGER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* suppress stl-MSVC debug info warning */
-#endif
-
-#include <map>
-
-#include "KX_TimeLogger.h"
-
-/**
- * Stores and manages time measurements by category.
- * Categories can be added dynamically.
- * Average measurements can be established for each separate category
- * or for all categories together.
- */
-class KX_TimeCategoryLogger {
-public:
- typedef int TimeCategory;
-
- /**
- * Constructor.
- * \param maxNumMesasurements Maximum number of measurements stored (> 1).
- */
- KX_TimeCategoryLogger(unsigned int maxNumMeasurements = 10);
-
- /**
- * Destructor.
- */
- virtual ~KX_TimeCategoryLogger(void);
-
- /**
- * Changes the maximum number of measurements that can be stored.
- */
- virtual void SetMaxNumMeasurements(unsigned int maxNumMeasurements);
-
- /**
- * Changes the maximum number of measurements that can be stored.
- */
- virtual unsigned int GetMaxNumMeasurements(void) const;
-
- /**
- * Adds a category.
- * \param category The new category.
- */
- virtual void AddCategory(TimeCategory tc);
-
- /**
- * Starts logging in current measurement for the given category.
- * \param tc The category to log to.
- * \param now The current time.
- * \param endOtherCategories Whether to stop logging to other categories.
- */
- virtual void StartLog(TimeCategory tc, double now, bool endOtherCategories = true);
-
- /**
- * End logging in current measurement for the given category.
- * \param tc The category to log to.
- * \param now The current time.
- */
- virtual void EndLog(TimeCategory tc, double now);
-
- /**
- * End logging in current measurement for all categories.
- * \param now The current time.
- */
- virtual void EndLog(double now);
-
- /**
- * Logs time in next measurement.
- * \param now The current time.
- */
- virtual void NextMeasurement(double now);
-
- /**
- * Returns average of all but the current measurement time.
- * \return The average of all but the current measurement.
- */
- virtual double GetAverage(TimeCategory tc);
-
- /**
- * Returns average for grand total.
- */
- virtual double GetAverage(void);
-
-protected:
- /**
- * Disposes loggers.
- */
- virtual void DisposeLoggers(void);
-
- /** Storage for the loggers. */
- typedef std::map<TimeCategory, KX_TimeLogger*> KX_TimeLoggerMap;
- KX_TimeLoggerMap m_loggers;
- /** Maximum number of measurements. */
- unsigned int m_maxNumMeasurements;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_TimeCategoryLogger")
-#endif
-};
-
-#endif /* __KX_TIMECATEGORYLOGGER_H__ */
diff --git a/source/gameengine/Ketsji/KX_TimeLogger.cpp b/source/gameengine/Ketsji/KX_TimeLogger.cpp
deleted file mode 100644
index 12106245c4d..00000000000
--- a/source/gameengine/Ketsji/KX_TimeLogger.cpp
+++ /dev/null
@@ -1,117 +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_TimeLogger.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_TimeLogger.h"
-
-KX_TimeLogger::KX_TimeLogger(unsigned int maxNumMeasurements) :
- m_maxNumMeasurements(maxNumMeasurements),
- m_logStart(0),
- m_logging(false)
-{
-}
-
-
-KX_TimeLogger::~KX_TimeLogger(void)
-{
-}
-
-
-void KX_TimeLogger::SetMaxNumMeasurements(unsigned int maxNumMeasurements)
-{
- if ((m_maxNumMeasurements != maxNumMeasurements) && maxNumMeasurements) {
- // Actual removing is done in NextMeasurement()
- m_maxNumMeasurements = maxNumMeasurements;
- }
-}
-
-
-unsigned int KX_TimeLogger::GetMaxNumMeasurements(void) const
-{
- return m_maxNumMeasurements;
-}
-
-
-void KX_TimeLogger::StartLog(double now)
-{
- if (!m_logging) {
- m_logging = true;
- m_logStart = now;
- }
-}
-
-
-void KX_TimeLogger::EndLog(double now)
-{
- if (m_logging) {
- m_logging = false;
- double time = now - m_logStart;
- if (m_measurements.size() > 0) {
- m_measurements[0] += time;
- }
- }
-}
-
-
-void KX_TimeLogger::NextMeasurement(double now)
-{
- // End logging to current measurement
- EndLog(now);
-
- // Add a new measurement at the front
- double m = 0.0;
- m_measurements.push_front(m);
-
- // Remove measurement if we grow beyond the maximum size
- if ((m_measurements.size()) > m_maxNumMeasurements) {
- while (m_measurements.size() > m_maxNumMeasurements) {
- m_measurements.pop_back();
- }
- }
-}
-
-
-
-double KX_TimeLogger::GetAverage(void) const
-{
- double avg = 0.0;
-
- unsigned int numMeasurements = m_measurements.size();
- if (numMeasurements > 1) {
- for (unsigned int i = 1; i < numMeasurements; i++) {
- avg += m_measurements[i];
- }
- avg /= (double)numMeasurements - 1.0;
- }
-
- return avg;
-}
-
diff --git a/source/gameengine/Ketsji/KX_TimeLogger.h b/source/gameengine/Ketsji/KX_TimeLogger.h
deleted file mode 100644
index 59d7bdc84e3..00000000000
--- a/source/gameengine/Ketsji/KX_TimeLogger.h
+++ /dev/null
@@ -1,114 +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_TimeLogger.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_TIMELOGGER_H__
-#define __KX_TIMELOGGER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* suppress stl-MSVC debug info warning */
-#endif
-
-#include <deque>
-
-#ifdef WITH_CXX_GUARDEDALLOC
-# include "MEM_guardedalloc.h"
-#endif
-
-/**
- * Stores and manages time measurements.
- */
-class KX_TimeLogger {
-public:
- /**
- * Constructor.
- * \param maxNumMesasurements Maximum number of measurements stored (>1).
- */
- KX_TimeLogger(unsigned int maxNumMeasurements = 10);
-
- /**
- * Destructor.
- */
- virtual ~KX_TimeLogger(void);
-
- /**
- * Changes the maximum number of measurements that can be stored.
- */
- virtual void SetMaxNumMeasurements(unsigned int maxNumMeasurements);
-
- /**
- * Changes the maximum number of measurements that can be stored.
- */
- virtual unsigned int GetMaxNumMeasurements(void) const;
-
- /**
- * Starts logging in current measurement.
- * \param now The current time.
- */
- virtual void StartLog(double now);
-
- /**
- * End logging in current measurement.
- * \param now The current time.
- */
- virtual void EndLog(double now);
-
- /**
- * Logs time in next measurement.
- * \param now The current time.
- */
- virtual void NextMeasurement(double now);
-
- /**
- * Returns average of all but the current measurement.
- * \return The average of all but the current measurement.
- */
- virtual double GetAverage(void) const;
-
-protected:
- /** Storage for the measurements. */
- std::deque<double> m_measurements;
-
- /** Maximum number of measurements. */
- unsigned int m_maxNumMeasurements;
-
- /** Time at start of logging. */
- double m_logStart;
-
- /** State of logging. */
- bool m_logging;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_TimeLogger")
-#endif
-};
-
-#endif /* __KX_TIMELOGGER_H__ */
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
deleted file mode 100644
index 7f167652464..00000000000
--- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp
+++ /dev/null
@@ -1,246 +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_TouchEventManager.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_TouchEventManager.h"
-#include "SCA_ISensor.h"
-#include "KX_TouchSensor.h"
-#include "KX_GameObject.h"
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_IPhysicsController.h"
-
-
-KX_TouchEventManager::KX_TouchEventManager(class SCA_LogicManager* logicmgr,
- PHY_IPhysicsEnvironment* physEnv)
- : SCA_EventManager(logicmgr, TOUCH_EVENTMGR),
- m_physEnv(physEnv)
-{
- //notm_scene->addTouchCallback(STATIC_RESPONSE, KX_TouchEventManager::collisionResponse, this);
-
- //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);
-
-}
-
-bool KX_TouchEventManager::NewHandleCollision(void* object1, void* object2, const PHY_CollData *coll_data)
-{
-
- PHY_IPhysicsController* obj1 = static_cast<PHY_IPhysicsController*>(object1);
- PHY_IPhysicsController* obj2 = static_cast<PHY_IPhysicsController*>(object2);
-
- m_newCollisions.insert(NewCollision(obj1, obj2, coll_data));
-
- return false;
-}
-
-
-bool KX_TouchEventManager::newCollisionResponse(void *client_data,
- void *object1,
- void *object2,
- const PHY_CollData *coll_data)
-{
- KX_TouchEventManager *touchmgr = (KX_TouchEventManager *) client_data;
- touchmgr->NewHandleCollision(object1, object2, coll_data);
- return false;
-}
-
-bool KX_TouchEventManager::newBroadphaseResponse(void *client_data,
- void *object1,
- void *object2,
- const PHY_CollData *coll_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 = (ctrl2) ? static_cast<KX_ClientObjectInfo*>(ctrl2->GetNewClientInfo()) : NULL;
-
- // This call back should only be called for controllers of Near and Radar sensor
- if (!info1)
- return true;
-
- // Get KX_GameObjects for callbacks
- KX_GameObject* gobj1 = info1->m_gameobject;
- KX_GameObject* gobj2 = (info2) ? info2->m_gameobject : NULL;
-
- bool has_py_callbacks = false;
-
-#ifdef WITH_PYTHON
- // Consider callbacks for broadphase inclusion if it's a sensor object type
- if (gobj1 && gobj2)
- has_py_callbacks = gobj1->m_collisionCallbacks || gobj2->m_collisionCallbacks;
-#else
- (void)gobj1;
- (void)gobj2;
-#endif
-
- switch (info1->m_type)
- {
- case KX_ClientObjectInfo::SENSOR:
- if (info1->m_sensors.size() == 1)
- {
- // only one sensor for this type of object
- KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*info1->m_sensors.begin());
- return touchsensor->BroadPhaseFilterCollision(object1, object2);
- }
- break;
- case KX_ClientObjectInfo::OBSENSOR:
- case KX_ClientObjectInfo::OBACTORSENSOR:
- // this object may have multiple collision sensors,
- // check is any of them is interested in this object
- for (std::list<SCA_ISensor*>::iterator it = info1->m_sensors.begin();
- it != info1->m_sensors.end();
- ++it)
- {
- if ((*it)->GetSensorType() == SCA_ISensor::ST_TOUCH)
- {
- KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*it);
- if (touchsensor->BroadPhaseSensorFilterCollision(object1, object2))
- return true;
- }
- }
-
- return has_py_callbacks;
-
- // quiet the compiler
- case KX_ClientObjectInfo::STATIC:
- case KX_ClientObjectInfo::ACTOR:
- case KX_ClientObjectInfo::RESERVED1:
- /* do nothing*/
- break;
- }
- return true;
-}
-
-void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor)
-{
- KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(sensor);
- if (m_sensors.AddBack(touchsensor))
- // the sensor was effectively inserted, register it
- touchsensor->RegisterSumo(this);
-}
-
-void KX_TouchEventManager::RemoveSensor(SCA_ISensor* sensor)
-{
- KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(sensor);
- if (touchsensor->Delink())
- // the sensor was effectively removed, unregister it
- touchsensor->UnregisterSumo(this);
-}
-
-
-
-void KX_TouchEventManager::EndFrame()
-{
- SG_DList::iterator<KX_TouchSensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- {
- (*it)->EndFrame();
- }
-}
-
-
-
-void KX_TouchEventManager::NextFrame()
-{
- SG_DList::iterator<KX_TouchSensor> it(m_sensors);
- for (it.begin();!it.end();++it)
- (*it)->SynchronizeTransform();
-
- for (std::set<NewCollision>::iterator cit = m_newCollisions.begin(); cit != m_newCollisions.end(); ++cit)
- {
- // Controllers
- PHY_IPhysicsController* ctrl1 = (*cit).first;
- PHY_IPhysicsController* ctrl2 = (*cit).second;
-
- // Sensor iterator
- list<SCA_ISensor*>::iterator sit;
-
- // First client info
- 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
- if (client_info) {
- for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
- static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision(ctrl1, ctrl2, NULL);
- }
- }
-
- // Second client info
- client_info = static_cast<KX_ClientObjectInfo *>(ctrl2->GetNewClientInfo());
- // Second gameobject
- KX_GameObject *kxObj2 = KX_GameObject::GetClientObject(client_info);
- if (client_info) {
- for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
- static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision(ctrl2, ctrl1, NULL);
- }
- }
- // Run python callbacks
- PHY_CollData *colldata = cit->colldata;
- kxObj1->RunCollisionCallbacks(kxObj2, colldata->m_point1, colldata->m_normal);
- kxObj2->RunCollisionCallbacks(kxObj1, colldata->m_point2, -colldata->m_normal);
-
- delete cit->colldata;
- }
-
- m_newCollisions.clear();
-
- for (it.begin();!it.end();++it)
- (*it)->Activate(m_logicmgr);
- }
-
-
-KX_TouchEventManager::NewCollision::NewCollision(PHY_IPhysicsController *first,
- PHY_IPhysicsController *second,
- const PHY_CollData *colldata)
- : first(first), second(second), colldata(new PHY_CollData(*colldata))
-{}
-
-KX_TouchEventManager::NewCollision::NewCollision(const NewCollision &to_copy)
- : first(to_copy.first), second(to_copy.second), colldata(to_copy.colldata)
-{}
-
-bool KX_TouchEventManager::NewCollision::operator<(const NewCollision &other) const
-{
- //see strict weak ordering: https://support.microsoft.com/en-us/kb/949171
- if (first == other.first) {
- if (second == other.second) {
- return colldata < other.colldata;
- }
- return second < other.second;
- }
- return first < other.first;
-}
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h
deleted file mode 100644
index d9c6fdad307..00000000000
--- a/source/gameengine/Ketsji/KX_TouchEventManager.h
+++ /dev/null
@@ -1,109 +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_TouchEventManager.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_TOUCHEVENTMANAGER_H__
-#define __KX_TOUCHEVENTMANAGER_H__
-
-
-#include "SCA_EventManager.h"
-#include "KX_TouchSensor.h"
-#include "KX_GameObject.h"
-
-#include <vector>
-#include <set>
-
-class SCA_ISensor;
-class PHY_IPhysicsEnvironment;
-
-class KX_TouchEventManager : public SCA_EventManager
-{
- /**
- * Contains two colliding objects and the first contact point.
- */
- class NewCollision {
- public:
- PHY_IPhysicsController *first;
- PHY_IPhysicsController *second;
- PHY_CollData *colldata;
-
- /**
- * Creates a copy of the given PHY_CollData; freeing that copy should be done by the owner of
- * the NewCollision object.
- *
- * This allows us to efficiently store NewCollision objects in a std::set without creating more
- * copies of colldata, as the NewCollision copy constructor reuses the pointer and doesn't clone
- * it again. */
- NewCollision(PHY_IPhysicsController *first,
- PHY_IPhysicsController *second,
- const PHY_CollData *colldata);
- NewCollision(const NewCollision &to_copy);
- bool operator<(const NewCollision &other) const;
- };
-
- PHY_IPhysicsEnvironment* m_physEnv;
-
- std::set<NewCollision> m_newCollisions;
-
-
- static bool newCollisionResponse(void *client_data,
- void *object1,
- void *object2,
- const PHY_CollData *coll_data);
-
- static bool newBroadphaseResponse(void *client_data,
- void *object1,
- void *object2,
- const PHY_CollData *coll_data);
-
- virtual bool NewHandleCollision(void* obj1,void* obj2,
- const PHY_CollData * coll_data);
-
-
-
-
-
-public:
- KX_TouchEventManager(class SCA_LogicManager* logicmgr,
- PHY_IPhysicsEnvironment* physEnv);
- virtual void NextFrame();
- virtual void EndFrame();
- virtual void RegisterSensor(SCA_ISensor* sensor);
- virtual void RemoveSensor(SCA_ISensor* sensor);
- SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
- PHY_IPhysicsEnvironment *GetPhysicsEnvironment() { return m_physEnv; }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_TouchEventManager")
-#endif
-};
-
-#endif /* __KX_TOUCHEVENTMANAGER_H__ */
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
deleted file mode 100644
index 593d3e844e8..00000000000
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Senses touch and collision events
- *
- *
- * ***** 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_TouchSensor.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_TouchSensor.h"
-#include "SCA_EventManager.h"
-#include "SCA_LogicManager.h"
-#include "KX_GameObject.h"
-#include "KX_TouchEventManager.h"
-
-#include "PHY_IPhysicsController.h"
-
-#include "RAS_MeshObject.h"
-
-#include <iostream>
-#include "PHY_IPhysicsEnvironment.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-void KX_TouchSensor::SynchronizeTransform()
-{
- // the touch sensor does not require any synchronization: it uses
- // the same physical object which is already synchronized by Blender
-}
-
-
-void KX_TouchSensor::EndFrame()
-{
- m_colliders->ReleaseAndRemoveAll();
- m_hitObject = NULL;
- m_bTriggered = false;
- m_bColliderHash = 0;
-}
-
-void KX_TouchSensor::UnregisterToManager()
-{
- // before unregistering the sensor, make sure we release all references
- EndFrame();
- SCA_ISensor::UnregisterToManager();
-}
-
-bool KX_TouchSensor::Evaluate()
-{
- bool result = false;
- bool reset = m_reset && m_level;
- m_reset = false;
- if (m_bTriggered != m_bLastTriggered)
- {
- m_bLastTriggered = m_bTriggered;
- if (!m_bTriggered)
- m_hitObject = NULL;
- result = true;
- }
- if (reset)
- // force an event
- result = true;
-
- if (m_bTouchPulse) { /* pulse on changes to the colliders */
- int count = m_colliders->GetCount();
-
- if (m_bLastCount!=count || m_bColliderHash!=m_bLastColliderHash) {
- m_bLastCount = count;
- m_bLastColliderHash= m_bColliderHash;
- result = true;
- }
- }
- return result;
-}
-
-KX_TouchSensor::KX_TouchSensor(SCA_EventManager* eventmgr,KX_GameObject* gameobj,bool bFindMaterial,bool bTouchPulse,const STR_String& touchedpropname)
-:SCA_ISensor(gameobj,eventmgr),
-m_touchedpropname(touchedpropname),
-m_bFindMaterial(bFindMaterial),
-m_bTouchPulse(bTouchPulse),
-m_hitMaterial("")
-/*m_sumoObj(sumoObj),*/
-{
-// KX_TouchEventManager* touchmgr = (KX_TouchEventManager*) eventmgr;
-// m_resptable = touchmgr->GetResponseTable();
-
-// m_solidHandle = m_sumoObj->getObjectHandle();
-
- m_colliders = new CListValue();
-
- KX_ClientObjectInfo *client_info = gameobj->getClientInfo();
- //client_info->m_gameobject = gameobj;
- //client_info->m_auxilary_info = NULL;
- client_info->m_sensors.push_back(this);
-
- m_physCtrl = gameobj->GetPhysicsController();
- MT_assert( !gameobj->GetPhysicsController() || m_physCtrl );
- Init();
-}
-
-void KX_TouchSensor::Init()
-{
- m_bCollision = false;
- m_bTriggered = false;
- m_bLastTriggered = (m_invert)?true:false;
- m_bLastCount = 0;
- m_bColliderHash = m_bLastColliderHash = 0;
- m_hitObject = NULL;
- m_reset = true;
-}
-
-KX_TouchSensor::~KX_TouchSensor()
-{
- //DT_ClearObjectResponse(m_resptable,m_solidHandle);
- m_colliders->Release();
-}
-
-CValue* KX_TouchSensor::GetReplica()
-{
- KX_TouchSensor* replica = new KX_TouchSensor(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-void KX_TouchSensor::ProcessReplica()
-{
- SCA_ISensor::ProcessReplica();
- m_colliders = new CListValue();
- Init();
-}
-
-void KX_TouchSensor::ReParent(SCA_IObject* parent)
-{
- KX_GameObject *gameobj = static_cast<KX_GameObject *>(parent);
- PHY_IPhysicsController *sphy = ((KX_GameObject*)parent)->GetPhysicsController();
- if (sphy)
- m_physCtrl = sphy;
-
-// m_solidHandle = m_sumoObj->getObjectHandle();
- KX_ClientObjectInfo *client_info = gameobj->getClientInfo();
- //client_info->m_gameobject = gameobj;
- //client_info->m_auxilary_info = NULL;
-
- client_info->m_sensors.push_back(this);
- SCA_ISensor::ReParent(parent);
-}
-
-void KX_TouchSensor::RegisterSumo(KX_TouchEventManager *touchman)
-{
- if (m_physCtrl)
- {
- if (touchman->GetPhysicsEnvironment()->RequestCollisionCallback(m_physCtrl))
- {
- KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->GetNewClientInfo());
- if (client_info->isSensor())
- touchman->GetPhysicsEnvironment()->AddSensor(m_physCtrl);
- }
- }
-}
-void KX_TouchSensor::UnregisterSumo(KX_TouchEventManager* touchman)
-{
- if (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());
- if (client_info->isSensor())
- touchman->GetPhysicsEnvironment()->RemoveSensor(m_physCtrl);
- }
- }
-}
-
-// this function is called only for sensor objects
-// return true if the controller can collide with the object
-bool KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2)
-{
- assert(obj1==m_physCtrl && 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_GameObject* otherobj = ( client_info ? client_info->m_gameobject : NULL);
-
- // we can only check on persistent characteristic: m_link and m_suspended are not
- // good candidate because they are transient. That must be handled at another level
- if (!otherobj ||
- otherobj == myparent || // don't interact with our parent
- (my_client_info->m_type == KX_ClientObjectInfo::OBACTORSENSOR &&
- client_info->m_type != KX_ClientObjectInfo::ACTOR)) // only with actor objects
- return false;
-
- bool found = m_touchedpropname.IsEmpty();
- if (!found)
- {
- if (m_bFindMaterial) {
- for (unsigned int i = 0; i < otherobj->GetMeshCount(); ++i) {
- RAS_MeshObject *meshObj = otherobj->GetMesh(i);
- for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
- found = strcmp(m_touchedpropname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
- if (found)
- break;
- }
- }
- }
- else {
- found = (otherobj->GetProperty(m_touchedpropname) != NULL);
- }
- }
- return found;
-}
-
-bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_CollData* colldata)
-{
-// KX_TouchEventManager* toucheventmgr = (KX_TouchEventManager*)m_eventmgr;
- KX_GameObject* parent = (KX_GameObject*)GetParent();
-
- // 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());
-
- KX_GameObject* gameobj = ( client_info ?
- client_info->m_gameobject :
- NULL);
-
- // add the same check as in SCA_ISensor::Activate(),
- // we don't want to record collision when the sensor is not active.
- if (m_links && !m_suspended &&
- gameobj && (gameobj != parent) && client_info->isActor())
- {
-
- bool found = m_touchedpropname.IsEmpty();
- bool hitMaterial = false;
- if (!found)
- {
- if (m_bFindMaterial) {
- for (unsigned int i = 0; i < gameobj->GetMeshCount(); ++i) {
- RAS_MeshObject *meshObj = gameobj->GetMesh(i);
- for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
- found = strcmp(m_touchedpropname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
- if (found) {
- hitMaterial = true;
- break;
- }
- }
- }
- }
- else {
- found = (gameobj->GetProperty(m_touchedpropname) != NULL);
- }
- }
- if (found)
- {
- if (!m_colliders->SearchValue(gameobj)) {
- m_colliders->Add(gameobj->AddRef());
-
- if (m_bTouchPulse)
- m_bColliderHash += (uint_ptr)(static_cast<void *>(&gameobj));
- }
- m_bTriggered = true;
- m_hitObject = gameobj;
- m_hitMaterial = hitMaterial;
- //printf("KX_TouchSensor::HandleCollision\n");
- }
-
- }
- return false; // was DT_CONTINUE but this was defined in sumo as false.
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_TouchSensor::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_TouchSensor",
- 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,
- &SCA_ISensor::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_TouchSensor::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_TouchSensor::Attributes[] = {
- KX_PYATTRIBUTE_STRING_RW("propName",0,MAX_PROP_NAME,false,KX_TouchSensor,m_touchedpropname),
- KX_PYATTRIBUTE_BOOL_RW("useMaterial",KX_TouchSensor,m_bFindMaterial),
- KX_PYATTRIBUTE_BOOL_RW("usePulseCollision",KX_TouchSensor,m_bTouchPulse),
- KX_PYATTRIBUTE_STRING_RO("hitMaterial", KX_TouchSensor, m_hitMaterial),
- KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_TouchSensor, pyattr_get_object_hit),
- KX_PYATTRIBUTE_RO_FUNCTION("hitObjectList", KX_TouchSensor, pyattr_get_object_hit_list),
- { NULL } //Sentinel
-};
-
-/* Python API */
-
-PyObject *KX_TouchSensor::pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_TouchSensor* self = static_cast<KX_TouchSensor*>(self_v);
-
- if (self->m_hitObject)
- return self->m_hitObject->GetProxy();
- else
- Py_RETURN_NONE;
-}
-
-PyObject *KX_TouchSensor::pyattr_get_object_hit_list(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_TouchSensor* self = static_cast<KX_TouchSensor*>(self_v);
- return self->m_colliders->GetProxy();
-}
-
-#endif
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h
deleted file mode 100644
index e1b5725a32b..00000000000
--- a/source/gameengine/Ketsji/KX_TouchSensor.h
+++ /dev/null
@@ -1,138 +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_TouchSensor.h
- * \ingroup ketsji
- * \brief Senses touch and collision events
- */
-
-#ifndef __KX_TOUCHSENSOR_H__
-#define __KX_TOUCHSENSOR_H__
-
-#include "SCA_ISensor.h"
-#include "EXP_ListValue.h"
-
-struct PHY_CollData;
-
-#include "KX_ClientObjectInfo.h"
-
-#if defined(_WIN64)
-typedef unsigned __int64 uint_ptr;
-#else
-typedef unsigned long uint_ptr;
-#endif
-
-class KX_TouchEventManager;
-
-class KX_TouchSensor : public SCA_ISensor
-{
-protected:
- Py_Header
-
- /**
- * The sensor should only look for objects with this property.
- */
- STR_String m_touchedpropname;
- bool m_bFindMaterial;
- bool m_bTouchPulse; /* changes in the colliding objects trigger pulses */
-
- class PHY_IPhysicsController* m_physCtrl;
-
- bool m_bCollision;
- bool m_bTriggered;
- bool m_bLastTriggered;
-
- // Use with m_bTouchPulse to detect changes
- int m_bLastCount; /* size of m_colliders last tick */
- uint_ptr m_bColliderHash; /* hash collision objects pointers to trigger in case one object collides and another takes its place */
- uint_ptr m_bLastColliderHash;
-
- SCA_IObject* m_hitObject;
- class CListValue* m_colliders;
- STR_String m_hitMaterial;
-
-public:
- KX_TouchSensor(class SCA_EventManager* eventmgr,
- class KX_GameObject* gameobj,
- bool bFindMaterial,
- bool bTouchPulse,
- const STR_String& touchedpropname);
- virtual ~KX_TouchSensor();
-
- virtual CValue* GetReplica();
- virtual void ProcessReplica();
- virtual void SynchronizeTransform();
- virtual bool Evaluate();
- virtual void Init();
- virtual void ReParent(SCA_IObject* parent);
-
- virtual void RegisterSumo(KX_TouchEventManager* touchman);
- virtual void UnregisterSumo(KX_TouchEventManager* touchman);
- virtual void UnregisterToManager();
-
-#if 0
- virtual DT_Bool HandleCollision(void* obj1,void* obj2,
- const DT_CollData * coll_data);
-#endif
-
- virtual bool NewHandleCollision(void*obj1,void*obj2,const PHY_CollData* colldata);
-
- // Allows to do pre-filtering and save computation time
- // obj1 = sensor physical controller, obj2 = physical controller of second object
- // return value = true if collision should be checked on pair of object
- virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2) { return true; }
- virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2);
- virtual sensortype GetSensorType() { return ST_TOUCH; }
-
-
- virtual bool IsPositiveTrigger() {
- bool result = m_bTriggered;
- if (m_invert) result = !result;
- return result;
- }
-
- virtual void EndFrame();
-
- class PHY_IPhysicsController* GetPhysicsController() { return m_physCtrl; }
-
-
- // todo: put some info for collision maybe
-
-#ifdef WITH_PYTHON
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
- static PyObject* pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject* pyattr_get_object_hit_list(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-
-#endif
-
-};
-
-#endif /* __KX_TOUCHSENSOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
deleted file mode 100644
index a8fa9b0815d..00000000000
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ /dev/null
@@ -1,430 +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_TrackToActuator.cpp
- * \ingroup ketsji
- *
- * Replace the mesh for this actuator's parent
- */
-
-/* m_trackflag is used to determine the forward tracking direction
- * m_upflag for the up direction
- * normal situation is +y for forward, +z for up */
-
-#include "MT_Scalar.h"
-#include "SCA_IActuator.h"
-#include "KX_TrackToActuator.h"
-#include "SCA_IScene.h"
-#include "SCA_LogicManager.h"
-#include <math.h>
-#include <iostream>
-#include "KX_GameObject.h"
-
-#include "EXP_PyObjectPlus.h"
-
-/* ------------------------------------------------------------------------- */
-/* Native functions */
-/* ------------------------------------------------------------------------- */
-
-KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
- SCA_IObject *ob,
- int time,
- bool allow3D,
- int trackflag,
- int upflag)
- : SCA_IActuator(gameobj, KX_ACT_TRACKTO)
-{
- m_time = time;
- m_allow3D = allow3D;
- m_object = ob;
- m_trackflag = trackflag;
- m_upflag = upflag;
- m_parentobj = 0;
-
- if (m_object)
- m_object->RegisterActuator(this);
-
- {
- // if the object is vertex parented, don't check parent orientation as the link is broken
- if (!((KX_GameObject*)gameobj)->IsVertexParent()) {
- m_parentobj = ((KX_GameObject*)gameobj)->GetParent(); // check if the object is parented
- if (m_parentobj) {
- // if so, store the initial local rotation
- // this is needed to revert the effect of the parent inverse node (TBC)
- m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
- // use registration mechanism rather than AddRef, it creates zombie objects
- m_parentobj->RegisterActuator(this);
- }
- }
- }
-
-} /* End of constructor */
-
-
-
-/* old function from Blender */
-static MT_Matrix3x3 EulToMat3(float eul[3])
-{
- MT_Matrix3x3 mat;
- float ci, cj, ch, si, sj, sh, cc, cs, sc, ss;
-
- ci = cosf(eul[0]);
- cj = cosf(eul[1]);
- ch = cosf(eul[2]);
- si = sinf(eul[0]);
- sj = sinf(eul[1]);
- sh = sinf(eul[2]);
- cc = ci*ch;
- cs = ci*sh;
- sc = si*ch;
- ss = si*sh;
-
- mat[0][0] = cj*ch;
- mat[1][0] = sj*sc-cs;
- mat[2][0] = sj*cc+ss;
- mat[0][1] = cj*sh;
- mat[1][1] = sj*ss+cc;
- mat[2][1] = sj*cs-sc;
- mat[0][2] = -sj;
- mat[1][2] = cj*si;
- mat[2][2] = cj*ci;
-
- return mat;
-}
-
-
-
-/* old function from Blender */
-static void Mat3ToEulOld(MT_Matrix3x3 mat, float eul[3])
-{
- const float cy = sqrtf(mat[0][0] * mat[0][0] + mat[0][1] * mat[0][1]);
-
- if (cy > (float)(16.0f * FLT_EPSILON)) {
- eul[0] = atan2f( mat[1][2], mat[2][2]);
- eul[1] = atan2f(-mat[0][2], cy);
- eul[2] = atan2f( mat[0][1], mat[0][0]);
- }
- else {
- eul[0] = atan2f(-mat[2][1], mat[1][1]);
- eul[1] = atan2f(-mat[0][2], cy);
- eul[2] = 0.0f;
- }
-}
-
-
-
-/* old function from Blender */
-static void compatible_eulFast(float *eul, float *oldrot)
-{
- float dx, dy, dz;
-
- /* angular difference of 360 degrees */
-
- dx = eul[0] - oldrot[0];
- dy = eul[1] - oldrot[1];
- dz = eul[2] - oldrot[2];
-
- if (fabsf(dx) > (float)MT_PI) {
- if (dx > 0.0f) eul[0] -= (float)MT_2_PI; else eul[0] += (float)MT_2_PI;
- }
- if (fabsf(dy) > (float)MT_PI) {
- if (dy > 0.0f) eul[1] -= (float)MT_2_PI; else eul[1] += (float)MT_2_PI;
- }
- if (fabsf(dz) > (float)MT_PI) {
- if (dz > 0.0f) eul[2] -= (float)MT_2_PI; else eul[2] += (float)MT_2_PI;
- }
-}
-
-
-
-static MT_Matrix3x3 matrix3x3_interpol(MT_Matrix3x3 oldmat, MT_Matrix3x3 mat, int m_time)
-{
- float eul[3], oldeul[3];
-
- Mat3ToEulOld(oldmat, oldeul);
- Mat3ToEulOld(mat, eul);
- compatible_eulFast(eul, oldeul);
-
- eul[0] = (m_time * oldeul[0] + eul[0]) / (1.0f + m_time);
- eul[1] = (m_time * oldeul[1] + eul[1]) / (1.0f + m_time);
- eul[2] = (m_time * oldeul[2] + eul[2]) / (1.0f + m_time);
-
- return EulToMat3(eul);
-}
-
-static float basis_cross(int n, int m)
-{
- switch (n - m) {
- case 1:
- case -2:
- return 1.0f;
-
- case -1:
- case 2:
- return -1.0f;
-
- default:
- return 0.0f;
- }
-}
-
-/* vectomat function obtained from constrain.c and modified to work with MOTO library */
-static MT_Matrix3x3 vectomat(MT_Vector3 vec, short axis, short upflag, short threedimup)
-{
- MT_Matrix3x3 mat;
- MT_Vector3 y(MT_Scalar(0.0f), MT_Scalar(1.0f), MT_Scalar(0.0f));
- MT_Vector3 z(MT_Scalar(0.0f), MT_Scalar(0.0f), MT_Scalar(1.0f)); /* world Z axis is the global up axis */
- MT_Vector3 proj;
- MT_Vector3 right;
- MT_Scalar mul;
- int right_index;
-
- /* Normalized Vec vector*/
- vec = vec.safe_normalized_vec(z);
-
- /* if 2D doesn't move the up vector */
- if (!threedimup) {
- vec.setValue(MT_Scalar(vec[0]), MT_Scalar(vec[1]), MT_Scalar(0.0f));
- vec = (vec - z.dot(vec)*z).safe_normalized_vec(z);
- }
-
- if (axis > 2)
- axis -= 3;
- else
- vec = -vec;
-
- /* project the up vector onto the plane specified by vec */
- /* first z onto vec... */
- mul = z.dot(vec) / vec.dot(vec);
- proj = vec * mul;
- /* then onto the plane */
- proj = z - proj;
- /* proj specifies the transformation of the up axis */
- proj = proj.safe_normalized_vec(y);
-
- /* Normalized cross product of vec and proj specifies transformation of the right axis */
- right = proj.cross(vec);
- right.normalize();
-
- if (axis != upflag) {
- right_index = 3 - axis - upflag;
-
- /* account for up direction, track direction */
- right = right * basis_cross(axis, upflag);
- mat.setRow(right_index, right);
- mat.setRow(upflag, proj);
- mat.setRow(axis, vec);
- mat = mat.inverse();
- }
- /* identity matrix - don't do anything if the two axes are the same */
- else {
- mat.setIdentity();
- }
-
- return mat;
-}
-
-KX_TrackToActuator::~KX_TrackToActuator()
-{
- if (m_object)
- m_object->UnregisterActuator(this);
- if (m_parentobj)
- m_parentobj->UnregisterActuator(this);
-} /* end of destructor */
-
-void KX_TrackToActuator::ProcessReplica()
-{
- // the replica is tracking the same object => register it
- if (m_object)
- m_object->RegisterActuator(this);
- if (m_parentobj)
- m_parentobj->RegisterActuator(this);
- SCA_IActuator::ProcessReplica();
-}
-
-
-bool KX_TrackToActuator::UnlinkObject(SCA_IObject* clientobj)
-{
- if (clientobj == m_object)
- {
- // this object is being deleted, we cannot continue to track it.
- m_object = NULL;
- return true;
- }
- if (clientobj == m_parentobj)
- {
- m_parentobj = NULL;
- return true;
- }
- return false;
-}
-
-void KX_TrackToActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
-{
- void **h_obj = (*obj_map)[m_object];
- if (h_obj) {
- if (m_object)
- m_object->UnregisterActuator(this);
- m_object = (SCA_IObject*)(*h_obj);
- m_object->RegisterActuator(this);
- }
-
- void **h_parobj = (*obj_map)[m_parentobj];
- if (h_parobj) {
- if (m_parentobj)
- m_parentobj->UnregisterActuator(this);
- m_parentobj= (KX_GameObject*)(*h_parobj);
- m_parentobj->RegisterActuator(this);
- }
-}
-
-
-bool KX_TrackToActuator::Update(double curtime, bool frame)
-{
- bool result = false;
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent)
- {
- // do nothing on negative events
- }
- else if (m_object)
- {
- KX_GameObject* curobj = (KX_GameObject*) GetParent();
- MT_Vector3 dir = curobj->NodeGetWorldPosition() - ((KX_GameObject*)m_object)->NodeGetWorldPosition();
- MT_Matrix3x3 mat;
- MT_Matrix3x3 oldmat;
-
- mat = vectomat(dir, m_trackflag, m_upflag, m_allow3D);
- oldmat = curobj->NodeGetWorldOrientation();
-
- /* erwin should rewrite this! */
- mat = matrix3x3_interpol(oldmat, mat, m_time);
-
- /* check if the model is parented and calculate the child transform */
- if (m_parentobj) {
-
- MT_Point3 localpos;
- localpos = curobj->GetSGNode()->GetLocalPosition();
- // Get the inverse of the parent matrix
- MT_Matrix3x3 parentmatinv;
- parentmatinv = m_parentobj->NodeGetWorldOrientation().inverse();
- // transform the local coordinate system into the parents system
- mat = parentmatinv * mat;
- // append the initial parent local rotation matrix
- mat = m_parentlocalmat * mat;
-
- // set the models tranformation properties
- curobj->NodeSetLocalOrientation(mat);
- curobj->NodeSetLocalPosition(localpos);
- //curobj->UpdateTransform();
- }
- else {
- curobj->NodeSetLocalOrientation(mat);
- }
-
- result = true;
- }
-
- return result;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_TrackToActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_TrackToActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_TrackToActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_TrackToActuator::Attributes[] = {
- KX_PYATTRIBUTE_INT_RW("time",0,1000,true,KX_TrackToActuator,m_time),
- KX_PYATTRIBUTE_BOOL_RW("use3D",KX_TrackToActuator,m_allow3D),
- KX_PYATTRIBUTE_INT_RW("upAxis", 0, 2, true, KX_TrackToActuator,m_upflag),
- KX_PYATTRIBUTE_INT_RW("trackAxis", 0, 5, true, KX_TrackToActuator,m_trackflag),
- KX_PYATTRIBUTE_RW_FUNCTION("object", KX_TrackToActuator, pyattr_get_object, pyattr_set_object),
-
- { NULL } //Sentinel
-};
-
-PyObject *KX_TrackToActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_TrackToActuator* actuator = static_cast<KX_TrackToActuator*>(self);
- if (!actuator->m_object)
- Py_RETURN_NONE;
- else
- return actuator->m_object->GetProxy();
-}
-
-int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_TrackToActuator* actuator = static_cast<KX_TrackToActuator*>(self);
- KX_GameObject *gameobj;
-
- if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: KX_TrackToActuator"))
- return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
-
- if (actuator->m_object != NULL)
- actuator->m_object->UnregisterActuator(actuator);
-
- actuator->m_object = (SCA_IObject*) gameobj;
-
- if (actuator->m_object)
- actuator->m_object->RegisterActuator(actuator);
-
- return PY_SET_ATTR_SUCCESS;
-}
-
-#endif // WITH_PYTHON
-
-/* eof */
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h
deleted file mode 100644
index 124014eede2..00000000000
--- a/source/gameengine/Ketsji/KX_TrackToActuator.h
+++ /dev/null
@@ -1,98 +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_TrackToActuator.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_TRACKTOACTUATOR_H__
-#define __KX_TRACKTOACTUATOR_H__
-
-#include "SCA_IActuator.h"
-#include "SCA_IObject.h"
-#include "MT_Matrix3x3.h"
-#include "KX_GameObject.h"
-
-
-class KX_TrackToActuator : public SCA_IActuator
-{
- Py_Header
- // Object reference. Actually, we use the object's 'life'
- SCA_IObject* m_object;
- // 3d toggle
- bool m_allow3D;
- // time field
- int m_time;
- int m_trackflag;
- int m_upflag;
-
- MT_Matrix3x3 m_parentlocalmat;
- KX_GameObject* m_parentobj;
-
- public:
- KX_TrackToActuator(SCA_IObject* gameobj, SCA_IObject *ob, int time,
- bool threedee,int trackflag,int upflag);
- virtual ~KX_TrackToActuator();
- virtual CValue* GetReplica() {
- KX_TrackToActuator* replica = new KX_TrackToActuator(*this);
- replica->ProcessReplica();
- return replica;
- };
-
- virtual void ProcessReplica();
- virtual bool UnlinkObject(SCA_IObject* clientobj);
- virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
- virtual bool Update(double curtime, bool frame);
-
- //Python Interface
- enum UpAxis {
- KX_TRACK_UPAXIS_POS_X = 0,
- KX_TRACK_UPAXIS_POS_Y,
- KX_TRACK_UPAXIS_POS_Z
- };
- enum TrackAxis {
- KX_TRACK_TRAXIS_POS_X = 0,
- KX_TRACK_TRAXIS_POS_Y,
- KX_TRACK_TRAXIS_POS_Z,
- KX_TRACK_TRAXIS_NEG_X,
- KX_TRACK_TRAXIS_NEG_Y,
- KX_TRACK_TRAXIS_NEG_Z
- };
-
-#ifdef WITH_PYTHON
-
- /* Python part */
-
- /* These are used to get and set m_ob */
- static PyObject *pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
-#endif /* WITH_PYTHON */
-
-}; /* end of class KX_TrackToActuator : public KX_EditObjectActuator */
-
-#endif /* __KX_TRACKTOACTUATOR_H__ */
diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
deleted file mode 100644
index ddae645802c..00000000000
--- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
+++ /dev/null
@@ -1,380 +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_VehicleWrapper.cpp
- * \ingroup ketsji
- */
-
-#include "EXP_PyObjectPlus.h"
-
-#include "KX_VehicleWrapper.h"
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_IVehicle.h"
-#include "KX_PyMath.h"
-#include "KX_GameObject.h"
-#include "KX_MotionState.h"
-#include "KX_PythonInit.h"
-
-KX_VehicleWrapper::KX_VehicleWrapper(
- PHY_IVehicle* vehicle,
- PHY_IPhysicsEnvironment* physenv) :
- PyObjectPlus(),
- m_vehicle(vehicle),
- m_physenv(physenv)
-{
-}
-
-KX_VehicleWrapper::~KX_VehicleWrapper()
-{
- int numMotion = m_motionStates.size();
- for (int i=0;i<numMotion;i++)
- {
- PHY_IMotionState* motionState = m_motionStates[i];
- delete motionState;
- }
- m_motionStates.clear();
-}
-
-#ifdef WITH_PYTHON
-
-
-static bool raise_exc_wheel(PHY_IVehicle *vehicle, int i, const char *method)
-{
- if (i < 0 || i >= vehicle->GetNumWheels()) {
- PyErr_Format(PyExc_ValueError,
- "%s(...): wheel index %d out of range (0 to %d).", method, i, vehicle->GetNumWheels() - 1);
- return true;
- }
- else {
- return false;
- }
-}
-
-#define WHEEL_INDEX_CHECK_OR_RETURN(i, method) \
- if (raise_exc_wheel(m_vehicle, i, method)) {return NULL;} (void)0
-
-
-PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args)
-{
-
- PyObject *pylistPos,*pylistDir,*pylistAxleDir;
- PyObject *wheelGameObject;
- float suspensionRestLength,wheelRadius;
- int hasSteering;
-
-
- if (PyArg_ParseTuple(args,"OOOOffi:addWheel",&wheelGameObject,&pylistPos,&pylistDir,&pylistAxleDir,&suspensionRestLength,&wheelRadius,&hasSteering))
- {
- KX_GameObject *gameOb;
- if (!ConvertPythonToGameObject(KX_GetActiveScene()->GetLogicManager(), wheelGameObject, &gameOb, false, "vehicle.addWheel(...): KX_VehicleWrapper (first argument)"))
- return NULL;
-
- if (gameOb->GetSGNode())
- {
- MT_Vector3 attachPos,attachDir,attachAxle;
- if (!PyVecTo(pylistPos,attachPos)) {
- PyErr_SetString(PyExc_AttributeError,
- "addWheel(...) Unable to add wheel. attachPos must be a vector with 3 elements.");
- return NULL;
- }
- if (!PyVecTo(pylistDir,attachDir)) {
- PyErr_SetString(PyExc_AttributeError,
- "addWheel(...) Unable to add wheel. downDir must be a vector with 3 elements.");
- return NULL;
- }
- if (!PyVecTo(pylistAxleDir,attachAxle)) {
- PyErr_SetString(PyExc_AttributeError,
- "addWheel(...) Unable to add wheel. axleDir must be a vector with 3 elements.");
- return NULL;
- }
-
- //someone reverse some conventions inside Bullet (axle winding)
- attachAxle = -attachAxle;
-
- if (wheelRadius <= 0) {
- PyErr_SetString(PyExc_AttributeError,
- "addWheel(...) Unable to add wheel. wheelRadius must be positive.");
- return NULL;
- }
-
- PHY_IMotionState *motionState = new KX_MotionState(gameOb->GetSGNode());
- m_vehicle->AddWheel(motionState,attachPos,attachDir,attachAxle,suspensionRestLength,wheelRadius,hasSteering);
- }
-
- } else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-PyObject *KX_VehicleWrapper::PyGetWheelPosition(PyObject *args)
-{
-
- int wheelIndex;
-
- if (PyArg_ParseTuple(args,"i:getWheelPosition",&wheelIndex))
- {
- float position[3];
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "getWheelPosition");
-
- m_vehicle->GetWheelPosition(wheelIndex,position[0],position[1],position[2]);
- MT_Vector3 pos(position[0],position[1],position[2]);
- return PyObjectFrom(pos);
- }
- return NULL;
-}
-
-PyObject *KX_VehicleWrapper::PyGetWheelRotation(PyObject *args)
-{
- int wheelIndex;
- if (PyArg_ParseTuple(args,"i:getWheelRotation",&wheelIndex))
- {
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "getWheelRotation");
-
- return PyFloat_FromDouble(m_vehicle->GetWheelRotation(wheelIndex));
- }
- return NULL;
-}
-
-PyObject *KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject *args)
-{
- int wheelIndex;
- if (PyArg_ParseTuple(args,"i:getWheelOrientationQuaternion",&wheelIndex))
- {
- float orn[4];
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "getWheelOrientationQuaternion");
-
- m_vehicle->GetWheelOrientationQuaternion(wheelIndex,orn[0],orn[1],orn[2],orn[3]);
- MT_Quaternion quatorn(orn[0],orn[1],orn[2],orn[3]);
- MT_Matrix3x3 ornmat(quatorn);
- return PyObjectFrom(ornmat);
- }
- return NULL;
-
-}
-
-
-PyObject *KX_VehicleWrapper::PyGetNumWheels(PyObject *args)
-{
- return PyLong_FromLong(m_vehicle->GetNumWheels());
-}
-
-
-PyObject *KX_VehicleWrapper::PyGetConstraintId(PyObject *args)
-{
- return PyLong_FromLong(m_vehicle->GetUserConstraintId());
-}
-
-
-PyObject *KX_VehicleWrapper::PyApplyEngineForce(PyObject *args)
-{
- float force;
- int wheelIndex;
-
- if (PyArg_ParseTuple(args,"fi:applyEngineForce",&force,&wheelIndex))
- {
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "applyEngineForce");
-
- force *= -1.f;//someone reverse some conventions inside Bullet (axle winding)
- m_vehicle->ApplyEngineForce(force,wheelIndex);
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-PyObject *KX_VehicleWrapper::PySetTyreFriction(PyObject *args)
-{
- float wheelFriction;
- int wheelIndex;
-
- if (PyArg_ParseTuple(args,"fi:setTyreFriction",&wheelFriction,&wheelIndex))
- {
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "setTyreFriction");
-
- m_vehicle->SetWheelFriction(wheelFriction,wheelIndex);
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-PyObject *KX_VehicleWrapper::PySetSuspensionStiffness(PyObject *args)
-{
- float suspensionStiffness;
- int wheelIndex;
-
- if (PyArg_ParseTuple(args,"fi:setSuspensionStiffness",&suspensionStiffness,&wheelIndex))
- {
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "setSuspensionStiffness");
-
- m_vehicle->SetSuspensionStiffness(suspensionStiffness,wheelIndex);
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-PyObject *KX_VehicleWrapper::PySetSuspensionDamping(PyObject *args)
-{
- float suspensionDamping;
- int wheelIndex;
-
- if (PyArg_ParseTuple(args,"fi:setSuspensionDamping",&suspensionDamping,&wheelIndex))
- {
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "setSuspensionDamping");
-
- m_vehicle->SetSuspensionDamping(suspensionDamping,wheelIndex);
- } else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-PyObject *KX_VehicleWrapper::PySetSuspensionCompression(PyObject *args)
-{
- float suspensionCompression;
- int wheelIndex;
-
- if (PyArg_ParseTuple(args,"fi:setSuspensionCompression",&suspensionCompression,&wheelIndex))
- {
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "setSuspensionCompression");
-
- m_vehicle->SetSuspensionCompression(suspensionCompression,wheelIndex);
- } else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-PyObject *KX_VehicleWrapper::PySetRollInfluence(PyObject *args)
-{
- float rollInfluence;
- int wheelIndex;
-
- if (PyArg_ParseTuple(args,"fi:setRollInfluence",&rollInfluence,&wheelIndex))
- {
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "setRollInfluence");
-
- m_vehicle->SetRollInfluence(rollInfluence,wheelIndex);
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-PyObject *KX_VehicleWrapper::PyApplyBraking(PyObject *args)
-{
- float braking;
- int wheelIndex;
-
- if (PyArg_ParseTuple(args,"fi:applyBraking",&braking,&wheelIndex))
- {
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "applyBraking");
-
- m_vehicle->ApplyBraking(braking,wheelIndex);
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-PyObject *KX_VehicleWrapper::PySetSteeringValue(PyObject *args)
-{
- float steeringValue;
- int wheelIndex;
-
- if (PyArg_ParseTuple(args,"fi:setSteeringValue",&steeringValue,&wheelIndex))
- {
- WHEEL_INDEX_CHECK_OR_RETURN(wheelIndex, "setSteeringValue");
-
- m_vehicle->SetSteeringValue(steeringValue,wheelIndex);
- }
- else {
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-
-PyObject *KX_VehicleWrapper::PyGetConstraintType(PyObject *args)
-{
- return PyLong_FromLong(m_vehicle->GetUserConstraintType());
-}
-
-
-
-
-
-//python specific stuff
-PyTypeObject KX_VehicleWrapper::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_VehicleWrapper",
- 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
-};
-
-PyMethodDef KX_VehicleWrapper::Methods[] = {
- {"addWheel",(PyCFunction) KX_VehicleWrapper::sPyAddWheel, METH_VARARGS},
- {"getNumWheels",(PyCFunction) KX_VehicleWrapper::sPyGetNumWheels, METH_VARARGS},
- {"getWheelOrientationQuaternion",(PyCFunction) KX_VehicleWrapper::sPyGetWheelOrientationQuaternion, METH_VARARGS},
- {"getWheelRotation",(PyCFunction) KX_VehicleWrapper::sPyGetWheelRotation, METH_VARARGS},
- {"getWheelPosition",(PyCFunction) KX_VehicleWrapper::sPyGetWheelPosition, METH_VARARGS},
- {"getConstraintId",(PyCFunction) KX_VehicleWrapper::sPyGetConstraintId, METH_VARARGS},
- {"getConstraintType",(PyCFunction) KX_VehicleWrapper::sPyGetConstraintType, METH_VARARGS},
- {"setSteeringValue",(PyCFunction) KX_VehicleWrapper::sPySetSteeringValue, METH_VARARGS},
- {"applyEngineForce",(PyCFunction) KX_VehicleWrapper::sPyApplyEngineForce, METH_VARARGS},
- {"applyBraking",(PyCFunction) KX_VehicleWrapper::sPyApplyBraking, METH_VARARGS},
- {"setTyreFriction",(PyCFunction) KX_VehicleWrapper::sPySetTyreFriction, METH_VARARGS},
- {"setSuspensionStiffness",(PyCFunction) KX_VehicleWrapper::sPySetSuspensionStiffness, METH_VARARGS},
- {"setSuspensionDamping",(PyCFunction) KX_VehicleWrapper::sPySetSuspensionDamping, METH_VARARGS},
- {"setSuspensionCompression",(PyCFunction) KX_VehicleWrapper::sPySetSuspensionCompression, METH_VARARGS},
- {"setRollInfluence",(PyCFunction) KX_VehicleWrapper::sPySetRollInfluence, METH_VARARGS},
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_VehicleWrapper::Attributes[] = {
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.h b/source/gameengine/Ketsji/KX_VehicleWrapper.h
deleted file mode 100644
index 22b9591f48b..00000000000
--- a/source/gameengine/Ketsji/KX_VehicleWrapper.h
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/** \file KX_VehicleWrapper.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_VEHICLEWRAPPER_H__
-#define __KX_VEHICLEWRAPPER_H__
-
-#include "EXP_Value.h"
-class PHY_IVehicle;
-class PHY_IMotionState;
-
-#include <vector>
-
-///Python interface to physics vehicles (primarily 4-wheel cars and 2wheel bikes)
-class KX_VehicleWrapper : public PyObjectPlus
-{
- Py_Header
-
- std::vector<PHY_IMotionState*> m_motionStates;
-
-public:
- KX_VehicleWrapper(PHY_IVehicle* vehicle,class PHY_IPhysicsEnvironment* physenv);
- virtual ~KX_VehicleWrapper ();
- int getConstraintId();
-
-#ifdef WITH_PYTHON
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,AddWheel);
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetNumWheels);
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetWheelOrientationQuaternion);
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetWheelRotation);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetWheelPosition);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetConstraintId);
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,GetConstraintType);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetSteeringValue);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,ApplyEngineForce);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,ApplyBraking);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetTyreFriction);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetSuspensionStiffness);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetSuspensionDamping);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetSuspensionCompression);
-
- KX_PYMETHOD_VARARGS(KX_VehicleWrapper,SetRollInfluence);
-#endif /* WITH_PYTHON */
-
-private:
- PHY_IVehicle* m_vehicle;
- PHY_IPhysicsEnvironment* m_physenv;
-};
-
-#endif /* __KX_VEHICLEWRAPPER_H__ */
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp
deleted file mode 100644
index 40f4c462801..00000000000
--- a/source/gameengine/Ketsji/KX_VertexProxy.cpp
+++ /dev/null
@@ -1,595 +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_VertexProxy.cpp
- * \ingroup ketsji
- */
-
-
-#ifdef WITH_PYTHON
-
-#include "KX_VertexProxy.h"
-#include "KX_MeshProxy.h"
-#include "RAS_TexVert.h"
-
-#include "KX_PyMath.h"
-
-PyTypeObject KX_VertexProxy::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_VertexProxy",
- 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,
- &CValue::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_VertexProxy::Methods[] = {
- {"getXYZ", (PyCFunction)KX_VertexProxy::sPyGetXYZ,METH_NOARGS},
- {"setXYZ", (PyCFunction)KX_VertexProxy::sPySetXYZ,METH_O},
- {"getUV", (PyCFunction)KX_VertexProxy::sPyGetUV1, METH_NOARGS},
- {"setUV", (PyCFunction)KX_VertexProxy::sPySetUV1, METH_O},
-
- {"getUV2", (PyCFunction)KX_VertexProxy::sPyGetUV2,METH_NOARGS},
- {"setUV2", (PyCFunction)KX_VertexProxy::sPySetUV2,METH_VARARGS},
-
- {"getRGBA", (PyCFunction)KX_VertexProxy::sPyGetRGBA,METH_NOARGS},
- {"setRGBA", (PyCFunction)KX_VertexProxy::sPySetRGBA,METH_O},
- {"getNormal", (PyCFunction)KX_VertexProxy::sPyGetNormal,METH_NOARGS},
- {"setNormal", (PyCFunction)KX_VertexProxy::sPySetNormal,METH_O},
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_VertexProxy::Attributes[] = {
- KX_PYATTRIBUTE_RW_FUNCTION("x", KX_VertexProxy, pyattr_get_x, pyattr_set_x),
- KX_PYATTRIBUTE_RW_FUNCTION("y", KX_VertexProxy, pyattr_get_y, pyattr_set_y),
- KX_PYATTRIBUTE_RW_FUNCTION("z", KX_VertexProxy, pyattr_get_z, pyattr_set_z),
-
- KX_PYATTRIBUTE_RW_FUNCTION("r", KX_VertexProxy, pyattr_get_r, pyattr_set_r),
- KX_PYATTRIBUTE_RW_FUNCTION("g", KX_VertexProxy, pyattr_get_g, pyattr_set_g),
- KX_PYATTRIBUTE_RW_FUNCTION("b", KX_VertexProxy, pyattr_get_b, pyattr_set_b),
- KX_PYATTRIBUTE_RW_FUNCTION("a", KX_VertexProxy, pyattr_get_a, pyattr_set_a),
-
- KX_PYATTRIBUTE_RW_FUNCTION("u", KX_VertexProxy, pyattr_get_u, pyattr_set_u),
- KX_PYATTRIBUTE_RW_FUNCTION("v", KX_VertexProxy, pyattr_get_v, pyattr_set_v),
-
- KX_PYATTRIBUTE_RW_FUNCTION("u2", KX_VertexProxy, pyattr_get_u2, pyattr_set_u2),
- KX_PYATTRIBUTE_RW_FUNCTION("v2", KX_VertexProxy, pyattr_get_v2, pyattr_set_v2),
-
- KX_PYATTRIBUTE_RW_FUNCTION("XYZ", KX_VertexProxy, pyattr_get_XYZ, pyattr_set_XYZ),
- KX_PYATTRIBUTE_RW_FUNCTION("UV", KX_VertexProxy, pyattr_get_UV, pyattr_set_UV),
- KX_PYATTRIBUTE_RW_FUNCTION("uvs", KX_VertexProxy, pyattr_get_uvs, pyattr_set_uvs),
-
- KX_PYATTRIBUTE_RW_FUNCTION("color", KX_VertexProxy, pyattr_get_color, pyattr_set_color),
- KX_PYATTRIBUTE_RW_FUNCTION("normal", KX_VertexProxy, pyattr_get_normal, pyattr_set_normal),
-
- { NULL } //Sentinel
-};
-
-PyObject *KX_VertexProxy::pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getXYZ()[0]);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getXYZ()[1]);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getXYZ()[2]);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getRGBA()[0]/255.0);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getRGBA()[1]/255.0);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getRGBA()[2]/255.0);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getRGBA()[3]/255.0);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getUV(0)[0]);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getUV(0)[1]);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getUV(1)[0]);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyFloat_FromDouble(self->m_vertex->getUV(1)[1]);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyObjectFrom(MT_Vector3(self->m_vertex->getXYZ()));
-}
-
-PyObject *KX_VertexProxy::pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyObjectFrom(MT_Point2(self->m_vertex->getUV(0)));
-}
-
-PyObject *KX_VertexProxy::pyattr_get_uvs(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
-
- PyObject* uvlist = PyList_New(RAS_TexVert::MAX_UNIT);
- for (int i=0; i<RAS_TexVert::MAX_UNIT; ++i)
- {
- PyList_SET_ITEM(uvlist, i, PyObjectFrom(MT_Point2(self->m_vertex->getUV(i))));
- }
-
- return uvlist;
-}
-
-PyObject *KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- const unsigned char *colp = self->m_vertex->getRGBA();
- MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]);
- color /= 255.0f;
- return PyObjectFrom(color);
-}
-
-PyObject *KX_VertexProxy::pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- return PyObjectFrom(MT_Vector3(self->m_vertex->getNormal()));
-}
-
-int KX_VertexProxy::pyattr_set_x(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- MT_Point3 pos(self->m_vertex->getXYZ());
- pos.x() = val;
- self->m_vertex->SetXYZ(pos);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_y(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- MT_Point3 pos(self->m_vertex->getXYZ());
- pos.y() = val;
- self->m_vertex->SetXYZ(pos);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_z(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- MT_Point3 pos(self->m_vertex->getXYZ());
- pos.z() = val;
- self->m_vertex->SetXYZ(pos);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_u(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- MT_Point2 uv = self->m_vertex->getUV(0);
- uv[0] = val;
- self->m_vertex->SetUV(0, uv);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_v(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- MT_Point2 uv = self->m_vertex->getUV(0);
- uv[1] = val;
- self->m_vertex->SetUV(0, uv);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_u2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- MT_Point2 uv = self->m_vertex->getUV(1);
- uv[0] = val;
- self->m_vertex->SetUV(1, uv);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_v2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- MT_Point2 uv = self->m_vertex->getUV(1);
- uv[1] = val;
- self->m_vertex->SetUV(1, uv);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_r(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
- unsigned char *cp = (unsigned char*) &icol;
- val *= 255.0f;
- cp[0] = (unsigned char) val;
- self->m_vertex->SetRGBA(icol);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_g(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
- unsigned char *cp = (unsigned char*) &icol;
- val *= 255.0f;
- cp[1] = (unsigned char) val;
- self->m_vertex->SetRGBA(icol);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_b(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
- unsigned char *cp = (unsigned char*) &icol;
- val *= 255.0f;
- cp[2] = (unsigned char) val;
- self->m_vertex->SetRGBA(icol);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_a(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PyFloat_Check(value))
- {
- float val = PyFloat_AsDouble(value);
- unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
- unsigned char *cp = (unsigned char*) &icol;
- val *= 255.0f;
- cp[3] = (unsigned char) val;
- self->m_vertex->SetRGBA(icol);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_XYZ(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PySequence_Check(value))
- {
- MT_Point3 vec;
- if (PyVecTo(value, vec))
- {
- self->m_vertex->SetXYZ(vec);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_UV(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PySequence_Check(value))
- {
- MT_Point2 vec;
- if (PyVecTo(value, vec)) {
- self->m_vertex->SetUV(0, vec);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_uvs(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
- if (PySequence_Check(value))
- {
- MT_Point2 vec;
- for (int i=0; i<PySequence_Size(value) && i<RAS_TexVert::MAX_UNIT; ++i)
- {
- if (PyVecTo(PySequence_GetItem(value, i), vec))
- {
- self->m_vertex->SetUV(i, vec);
- self->m_mesh->SetMeshModified(true);
- }
- else
- {
- PyErr_SetString(PyExc_AttributeError, STR_String().Format("list[%d] was not a vector", i).ReadPtr());
- return PY_SET_ATTR_FAIL;
- }
- }
-
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_color(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PySequence_Check(value))
- {
- MT_Vector4 vec;
- if (PyVecTo(value, vec))
- {
- self->m_vertex->SetRGBA(vec);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- }
- return PY_SET_ATTR_FAIL;
-}
-
-int KX_VertexProxy::pyattr_set_normal(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v);
- if (PySequence_Check(value))
- {
- MT_Vector3 vec;
- if (PyVecTo(value, vec))
- {
- self->m_vertex->SetNormal(vec);
- self->m_mesh->SetMeshModified(true);
- return PY_SET_ATTR_SUCCESS;
- }
- }
- return PY_SET_ATTR_FAIL;
-}
-
-KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex)
-: m_vertex(vertex),
- m_mesh(mesh)
-{
- /* see bug [#27071] */
- Py_INCREF(m_mesh->GetProxy());
-}
-
-KX_VertexProxy::~KX_VertexProxy()
-{
- /* see bug [#27071] */
- Py_DECREF(m_mesh->GetProxy());
-}
-
-
-
-// stuff for cvalue related things
-CValue* KX_VertexProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;}
-CValue* KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;}
-static STR_String sVertexName = "vertex";
-const STR_String & KX_VertexProxy::GetText() {return sVertexName;};
-double KX_VertexProxy::GetNumber() { return -1;}
-STR_String& KX_VertexProxy::GetName() { return sVertexName;}
-void KX_VertexProxy::SetName(const char *) { };
-CValue* KX_VertexProxy::GetReplica() { return NULL;}
-
-// stuff for python integration
-
-PyObject *KX_VertexProxy::PyGetXYZ()
-{
- return PyObjectFrom(MT_Point3(m_vertex->getXYZ()));
-}
-
-PyObject *KX_VertexProxy::PySetXYZ(PyObject *value)
-{
- MT_Point3 vec;
- if (!PyVecTo(value, vec))
- return NULL;
-
- m_vertex->SetXYZ(vec);
- m_mesh->SetMeshModified(true);
- Py_RETURN_NONE;
-}
-
-PyObject *KX_VertexProxy::PyGetNormal()
-{
- return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
-}
-
-PyObject *KX_VertexProxy::PySetNormal(PyObject *value)
-{
- MT_Vector3 vec;
- if (!PyVecTo(value, vec))
- return NULL;
-
- m_vertex->SetNormal(vec);
- m_mesh->SetMeshModified(true);
- Py_RETURN_NONE;
-}
-
-
-PyObject *KX_VertexProxy::PyGetRGBA()
-{
- int *rgba = (int *) m_vertex->getRGBA();
- return PyLong_FromLong(*rgba);
-}
-
-PyObject *KX_VertexProxy::PySetRGBA(PyObject *value)
-{
- if (PyLong_Check(value)) {
- int rgba = PyLong_AsLong(value);
- m_vertex->SetRGBA(rgba);
- m_mesh->SetMeshModified(true);
- Py_RETURN_NONE;
- }
- else {
- MT_Vector4 vec;
- if (PyVecTo(value, vec))
- {
- m_vertex->SetRGBA(vec);
- m_mesh->SetMeshModified(true);
- Py_RETURN_NONE;
- }
- }
-
- PyErr_SetString(PyExc_TypeError, "vert.setRGBA(value): KX_VertexProxy, expected a 4D vector or an int");
- return NULL;
-}
-
-
-PyObject *KX_VertexProxy::PyGetUV1()
-{
- return PyObjectFrom(MT_Vector2(m_vertex->getUV(0)));
-}
-
-PyObject *KX_VertexProxy::PySetUV1(PyObject *value)
-{
- MT_Point2 vec;
- if (!PyVecTo(value, vec))
- return NULL;
-
- m_vertex->SetUV(0, vec);
- m_mesh->SetMeshModified(true);
- Py_RETURN_NONE;
-}
-
-PyObject *KX_VertexProxy::PyGetUV2()
-{
- return PyObjectFrom(MT_Vector2(m_vertex->getUV(1)));
-}
-
-PyObject *KX_VertexProxy::PySetUV2(PyObject *args)
-{
- MT_Point2 vec;
- if (!PyVecTo(args, vec))
- return NULL;
-
- m_vertex->SetUV(1, vec);
- m_mesh->SetMeshModified(true);
- Py_RETURN_NONE;
-}
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h
deleted file mode 100644
index 8070825ad11..00000000000
--- a/source/gameengine/Ketsji/KX_VertexProxy.h
+++ /dev/null
@@ -1,112 +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_VertexProxy.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_VERTEXPROXY_H__
-#define __KX_VERTEXPROXY_H__
-
-#ifdef WITH_PYTHON
-
-#include "SCA_IObject.h"
-
-class KX_VertexProxy : public CValue
-{
- Py_Header
-protected:
-
- class RAS_TexVert* m_vertex;
- class KX_MeshProxy* m_mesh;
-public:
- KX_VertexProxy(class KX_MeshProxy*mesh, class RAS_TexVert* vertex);
- virtual ~KX_VertexProxy();
-
- // stuff for cvalue related things
- CValue* Calc(VALUE_OPERATOR op, CValue *val);
- CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
- const STR_String & GetText();
- double GetNumber();
- STR_String& GetName();
- void SetName(const char *name); // Set the name of the value
- CValue* GetReplica();
-
-
-// stuff for python integration
-
- static PyObject *pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_uvs(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_x(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_y(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_z(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_u(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_v(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_u2(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_v2(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_r(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_g(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_b(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_a(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_XYZ(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_UV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_color(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_normal(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static int pyattr_set_uvs(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
-
- KX_PYMETHOD_NOARGS(KX_VertexProxy,GetXYZ);
- KX_PYMETHOD_O(KX_VertexProxy,SetXYZ);
- KX_PYMETHOD_NOARGS(KX_VertexProxy,GetUV1);
- KX_PYMETHOD_O(KX_VertexProxy,SetUV1);
-
- KX_PYMETHOD_NOARGS(KX_VertexProxy,GetUV2);
- KX_PYMETHOD_VARARGS(KX_VertexProxy,SetUV2);
-
- KX_PYMETHOD_NOARGS(KX_VertexProxy,GetRGBA);
- KX_PYMETHOD_O(KX_VertexProxy,SetRGBA);
- KX_PYMETHOD_NOARGS(KX_VertexProxy,GetNormal);
- KX_PYMETHOD_O(KX_VertexProxy,SetNormal);
-
-};
-
-#endif /* WITH_PYTHON */
-
-#endif /* __KX_VERTEXPROXY_H__ */
diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
deleted file mode 100644
index 6f689e228b9..00000000000
--- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
+++ /dev/null
@@ -1,127 +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 *****
- * Actuator to toggle visibility/invisibility of objects
- */
-
-/** \file gameengine/Ketsji/KX_VisibilityActuator.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_VisibilityActuator.h"
-#include "KX_GameObject.h"
-
-KX_VisibilityActuator::KX_VisibilityActuator(
- SCA_IObject* gameobj,
- bool visible,
- bool occlusion,
- bool recursive
- )
- : SCA_IActuator(gameobj, KX_ACT_VISIBILITY),
- m_visible(visible),
- m_occlusion(occlusion),
- m_recursive(recursive)
-{
- // intentionally empty
-}
-
-KX_VisibilityActuator::~KX_VisibilityActuator(
- void
- )
-{
- // intentionally empty
-}
-
-CValue*
-KX_VisibilityActuator::GetReplica(
- void
- )
-{
- KX_VisibilityActuator* replica = new KX_VisibilityActuator(*this);
- replica->ProcessReplica();
- return replica;
-}
-
-bool
-KX_VisibilityActuator::Update()
-{
- bool bNegativeEvent = IsNegativeEvent();
-
- RemoveAllEvents();
- if (bNegativeEvent) return false;
-
- KX_GameObject *obj = (KX_GameObject*) GetParent();
-
- obj->SetVisible(m_visible, m_recursive);
- obj->SetOccluder(m_occlusion, m_recursive);
- obj->UpdateBuckets(m_recursive);
-
- return false;
-}
-
-#ifdef WITH_PYTHON
-
-/* ------------------------------------------------------------------------- */
-/* Python functions */
-/* ------------------------------------------------------------------------- */
-
-
-
-/* Integration hooks ------------------------------------------------------- */
-PyTypeObject KX_VisibilityActuator::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_VisibilityActuator",
- 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,
- &SCA_IActuator::Type,
- 0,0,0,0,0,0,
- py_base_new
-};
-
-PyMethodDef KX_VisibilityActuator::Methods[] = {
- {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_VisibilityActuator::Attributes[] = {
- KX_PYATTRIBUTE_BOOL_RW("visibility", KX_VisibilityActuator, m_visible),
- KX_PYATTRIBUTE_BOOL_RW("useOcclusion", KX_VisibilityActuator, m_occlusion),
- KX_PYATTRIBUTE_BOOL_RW("useRecursion", KX_VisibilityActuator, m_recursive),
- { NULL } //Sentinel
-};
-
-#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h
deleted file mode 100644
index a207844db74..00000000000
--- a/source/gameengine/Ketsji/KX_VisibilityActuator.h
+++ /dev/null
@@ -1,75 +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_VisibilityActuator.h
- * \ingroup ketsji
- * \brief Actuator to toggle visibility/invisibility of objects
- */
-
-#ifndef __KX_VISIBILITYACTUATOR_H__
-#define __KX_VISIBILITYACTUATOR_H__
-
-#include "SCA_IActuator.h"
-
-class KX_VisibilityActuator : public SCA_IActuator
-{
- Py_Header
-
- /** Make visible? */
- bool m_visible;
- bool m_occlusion;
- bool m_recursive;
-
- public:
-
- KX_VisibilityActuator(
- SCA_IObject* gameobj,
- bool visible,
- bool occlusion,
- bool recursive);
-
- virtual
- ~KX_VisibilityActuator(
- void
- );
-
- virtual CValue*
- GetReplica(
- void
- );
-
- virtual bool
- Update();
-
- /* --------------------------------------------------------------------- */
- /* Python interface ---------------------------------------------------- */
- /* --------------------------------------------------------------------- */
-
-};
-
-#endif
-
diff --git a/source/gameengine/Ketsji/KX_WorldInfo.cpp b/source/gameengine/Ketsji/KX_WorldInfo.cpp
deleted file mode 100644
index be8b1ce92fc..00000000000
--- a/source/gameengine/Ketsji/KX_WorldInfo.cpp
+++ /dev/null
@@ -1,494 +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_WorldInfo.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_WorldInfo.h"
-#include "KX_PythonInit.h"
-#include "KX_PyMath.h"
-#include "RAS_IRasterizer.h"
-#include "GPU_material.h"
-
-/* This little block needed for linking to Blender... */
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#endif
-
-/* This list includes only data type definitions */
-#include "DNA_scene_types.h"
-#include "DNA_world_types.h"
-
-#include "BLI_math.h"
-
-#include "BKE_global.h"
-#include "BKE_scene.h"
-/* end of blender include block */
-
-
-KX_WorldInfo::KX_WorldInfo(Scene *blenderscene, World *blenderworld)
-{
- if (blenderworld) {
- m_name = blenderworld->id.name + 2;
- m_do_color_management = BKE_scene_check_color_management_enabled(blenderscene);
- m_hasworld = true;
- m_hasmist = ((blenderworld->mode) & WO_MIST ? true : false);
- m_misttype = blenderworld->mistype;
- m_miststart = blenderworld->miststa;
- m_mistdistance = blenderworld->mistdist;
- m_mistintensity = blenderworld->misi;
- setMistColor(blenderworld->horr, blenderworld->horg, blenderworld->horb);
- setBackColor(blenderworld->horr, blenderworld->horg, blenderworld->horb);
- setAmbientColor(blenderworld->ambr, blenderworld->ambg, blenderworld->ambb);
- }
- else {
- m_hasworld = false;
- }
-}
-
-KX_WorldInfo::~KX_WorldInfo()
-{
-}
-
-const STR_String& KX_WorldInfo::GetName()
-{
- return m_name;
-}
-
-bool KX_WorldInfo::hasWorld()
-{
- return m_hasworld;
-}
-
-void KX_WorldInfo::setBackColor(float r, float g, float b)
-{
- m_backgroundcolor[0] = r;
- m_backgroundcolor[1] = g;
- m_backgroundcolor[2] = b;
-
- if (m_do_color_management) {
- linearrgb_to_srgb_v3_v3(m_con_backgroundcolor, m_backgroundcolor);
- }
- else {
- copy_v3_v3(m_con_backgroundcolor, m_backgroundcolor);
- }
-}
-
-const float *KX_WorldInfo::getBackColorConverted() const
-{
- return m_con_backgroundcolor;
-}
-
-void KX_WorldInfo::setMistType(short type)
-{
- m_misttype = type;
-}
-
-void KX_WorldInfo::setUseMist(bool enable)
-{
- m_hasmist = enable;
-}
-
-void KX_WorldInfo::setMistStart(float d)
-{
- m_miststart = d;
-}
-
-void KX_WorldInfo::setMistDistance(float d)
-{
- m_mistdistance = d;
-}
-
-void KX_WorldInfo::setMistIntensity(float intensity)
-{
- m_mistintensity = intensity;
-}
-void KX_WorldInfo::setMistColor(float r, float g, float b)
-{
- m_mistcolor[0] = r;
- m_mistcolor[1] = g;
- m_mistcolor[2] = b;
-
- if (m_do_color_management) {
- linearrgb_to_srgb_v3_v3(m_con_mistcolor, m_mistcolor);
- }
- else {
- copy_v3_v3(m_con_mistcolor, m_mistcolor);
- }
-}
-
-void KX_WorldInfo::setAmbientColor(float r, float g, float b)
-{
- m_ambientcolor[0] = r;
- m_ambientcolor[1] = g;
- m_ambientcolor[2] = b;
-
- if (m_do_color_management) {
- linearrgb_to_srgb_v3_v3(m_con_ambientcolor, m_ambientcolor);
- }
- else {
- copy_v3_v3(m_con_ambientcolor, m_ambientcolor);
- }
-}
-
-void KX_WorldInfo::UpdateBackGround()
-{
- if (m_hasworld) {
- RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer();
-
- if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) {
- m_rasterizer->SetBackColor(m_con_backgroundcolor);
- GPU_horizon_update_color(m_backgroundcolor);
- }
- }
-}
-
-void KX_WorldInfo::UpdateWorldSettings()
-{
- if (m_hasworld) {
- RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer();
-
- if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) {
- m_rasterizer->SetAmbientColor(m_con_ambientcolor);
- GPU_ambient_update_color(m_ambientcolor);
-
- if (m_hasmist) {
- m_rasterizer->SetFog(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_con_mistcolor);
- GPU_mist_update_values(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_mistcolor);
- m_rasterizer->EnableFog(true);
- GPU_mist_update_enable(true);
- }
- else {
- m_rasterizer->EnableFog(false);
- GPU_mist_update_enable(false);
- }
- }
- }
-}
-
-#ifdef WITH_PYTHON
-
-/* -------------------------------------------------------------------------
- * Python functions
- * ------------------------------------------------------------------------- */
-PyObject *KX_WorldInfo::py_repr(void)
-{
- return PyUnicode_From_STR_String(GetName());
-}
-
-/* -------------------------------------------------------------------------
- * Python Integration Hooks
- * ------------------------------------------------------------------------- */
-PyTypeObject KX_WorldInfo::Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "KX_WorldInfo",
- 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
-};
-
-PyMethodDef KX_WorldInfo::Methods[] = {
- {NULL,NULL} /* Sentinel */
-};
-
-PyAttributeDef KX_WorldInfo::Attributes[] = {
- KX_PYATTRIBUTE_BOOL_RW("mistEnable", KX_WorldInfo, m_hasmist),
- KX_PYATTRIBUTE_FLOAT_RW("mistStart", 0.0f, 10000.0f, KX_WorldInfo, m_miststart),
- KX_PYATTRIBUTE_FLOAT_RW("mistDistance", 0.001f, 10000.0f, KX_WorldInfo, m_mistdistance),
- KX_PYATTRIBUTE_FLOAT_RW("mistIntensity", 0.0f, 1.0f, KX_WorldInfo, m_mistintensity),
- KX_PYATTRIBUTE_SHORT_RW("mistType", 0, 2, true, KX_WorldInfo, m_misttype),
- KX_PYATTRIBUTE_RO_FUNCTION("KX_MIST_QUADRATIC", KX_WorldInfo, pyattr_get_mist_typeconst),
- KX_PYATTRIBUTE_RO_FUNCTION("KX_MIST_LINEAR", KX_WorldInfo, pyattr_get_mist_typeconst),
- KX_PYATTRIBUTE_RO_FUNCTION("KX_MIST_INV_QUADRATIC", KX_WorldInfo, pyattr_get_mist_typeconst),
- KX_PYATTRIBUTE_RW_FUNCTION("mistColor", KX_WorldInfo, pyattr_get_mist_color, pyattr_set_mist_color),
- KX_PYATTRIBUTE_RW_FUNCTION("backgroundColor", KX_WorldInfo, pyattr_get_back_color, pyattr_set_back_color),
- KX_PYATTRIBUTE_RW_FUNCTION("ambientColor", KX_WorldInfo, pyattr_get_ambient_color, pyattr_set_ambient_color),
- { NULL } /* Sentinel */
-};
-
-/* Attribute get/set functions */
-
-#ifdef USE_MATHUTILS
-
-/*----------------------mathutils callbacks ----------------------------*/
-
-/* subtype */
-#define MATHUTILS_COL_CB_MIST_COLOR 1
-#define MATHUTILS_COL_CB_BACK_COLOR 2
-#define MATHUTILS_COL_CB_AMBIENT_COLOR 3
-
-static unsigned char mathutils_world_color_cb_index = -1; /* index for our callbacks */
-
-static int mathutils_world_generic_check(BaseMathObject *bmo)
-{
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
- return 0;
-}
-
-static int mathutils_world_color_get(BaseMathObject *bmo, int subtype)
-{
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
- if (self == NULL)
- return -1;
-
- switch (subtype) {
- case MATHUTILS_COL_CB_MIST_COLOR:
- copy_v3_v3(bmo->data, self->m_mistcolor);
- break;
- case MATHUTILS_COL_CB_BACK_COLOR:
- copy_v3_v3(bmo->data, self->m_backgroundcolor);
- break;
- case MATHUTILS_COL_CB_AMBIENT_COLOR:
- copy_v3_v3(bmo->data, self->m_ambientcolor);
- break;
- default:
- return -1;
- }
- return 0;
-}
-
-static int mathutils_world_color_set(BaseMathObject *bmo, int subtype)
-{
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
-
- if (self == NULL)
- return -1;
-
- switch (subtype) {
- case MATHUTILS_COL_CB_MIST_COLOR:
- self->setMistColor(bmo->data[0], bmo->data[1], bmo->data[2]);
- break;
- case MATHUTILS_COL_CB_BACK_COLOR:
- self->setBackColor(bmo->data[0], bmo->data[1], bmo->data[2]);
- break;
- case MATHUTILS_COL_CB_AMBIENT_COLOR:
- self->setAmbientColor(bmo->data[0], bmo->data[1], bmo->data[2]);
- break;
- default:
- return -1;
- }
- return 0;
-}
-
-static int mathutils_world_color_get_index(BaseMathObject *bmo, int subtype, int index)
-{
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
-
- if (self == NULL)
- return -1;
-
- switch (subtype) {
- case MATHUTILS_COL_CB_MIST_COLOR:
- {
- const float *color = self->m_mistcolor;
- bmo->data[index] = color[index];
- }
- break;
- case MATHUTILS_COL_CB_BACK_COLOR:
- {
- const float *color = self->m_backgroundcolor;
- bmo->data[index] = color[index];
- }
- break;
- case MATHUTILS_COL_CB_AMBIENT_COLOR:
- {
- const float *color = self->m_ambientcolor;
- bmo->data[index] = color[index];
- }
- break;
- default:
- return -1;
- }
- return 0;
-}
-
-static int mathutils_world_color_set_index(BaseMathObject *bmo, int subtype, int index)
-{
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
-
- if (self == NULL)
- return -1;
-
- float color[4];
- switch (subtype) {
- case MATHUTILS_COL_CB_MIST_COLOR:
- copy_v3_v3(color, self->m_mistcolor);
- color[index] = bmo->data[index];
- self->setMistColor(color[0], color[1], color[2]);
- break;
- case MATHUTILS_COL_CB_BACK_COLOR:
- copy_v3_v3(color, self->m_backgroundcolor);
- color[index] = bmo->data[index];
- self->setBackColor(color[0], color[1], color[2]);
- break;
- case MATHUTILS_COL_CB_AMBIENT_COLOR:
- copy_v3_v3(color, self->m_ambientcolor);
- color[index] = bmo->data[index];
- self->setAmbientColor(color[0], color[1], color[2]);
- break;
- default:
- return -1;
- }
- return 0;
-}
-
-static Mathutils_Callback mathutils_world_color_cb = {
- mathutils_world_generic_check,
- mathutils_world_color_get,
- mathutils_world_color_set,
- mathutils_world_color_get_index,
- mathutils_world_color_set_index
-};
-
-void KX_WorldInfo_Mathutils_Callback_Init()
-{
- // register mathutils callbacks, ok to run more than once.
- mathutils_world_color_cb_index = Mathutils_RegisterCallback(&mathutils_world_color_cb);
-}
-#endif // USE_MATHUTILS
-
-
-PyObject *KX_WorldInfo::pyattr_get_mist_typeconst(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
- PyObject *retvalue;
-
- const char* type = attrdef->m_name;
-
- if (!strcmp(type, "KX_MIST_QUADRATIC")) {
- retvalue = PyLong_FromLong(KX_MIST_QUADRATIC);
- }
- else if (!strcmp(type, "KX_MIST_LINEAR")) {
- retvalue = PyLong_FromLong(KX_MIST_LINEAR);
- }
- else if (!strcmp(type, "KX_MIST_INV_QUADRATIC")) {
- retvalue = PyLong_FromLong(KX_MIST_INV_QUADRATIC);
- }
- else {
- /* should never happen */
- PyErr_SetString(PyExc_TypeError, "invalid mist type");
- retvalue = NULL;
- }
-
- return retvalue;
-}
-
-PyObject *KX_WorldInfo::pyattr_get_mist_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Color_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v),
- mathutils_world_color_cb_index, MATHUTILS_COL_CB_MIST_COLOR);
-#else
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
- return PyObjectFrom(MT_Vector3(self->m_mistcolor));
-#endif
-}
-
-int KX_WorldInfo::pyattr_set_mist_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
-
- MT_Vector3 color;
- if (PyVecTo(value, color))
- {
- self->setMistColor(color[0], color[1], color[2]);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_WorldInfo::pyattr_get_back_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-
-#ifdef USE_MATHUTILS
- return Color_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v),
- mathutils_world_color_cb_index, MATHUTILS_COL_CB_BACK_COLOR);
-#else
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
- return PyObjectFrom(MT_Vector3(self->m_backgroundcolor));
-#endif
-}
-
-int KX_WorldInfo::pyattr_set_back_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
-
- MT_Vector3 color;
- if (PyVecTo(value, color))
- {
- self->setBackColor(color[0], color[1], color[2]);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-PyObject *KX_WorldInfo::pyattr_get_ambient_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-#ifdef USE_MATHUTILS
- return Color_CreatePyObject_cb(
- BGE_PROXY_FROM_REF_BORROW(self_v),
- mathutils_world_color_cb_index, MATHUTILS_COL_CB_AMBIENT_COLOR);
-#else
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
- return PyObjectFrom(MT_Vector3(self->m_ambientcolor));
-#endif
-}
-
-int KX_WorldInfo::pyattr_set_ambient_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
-{
- KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
-
- MT_Vector3 color;
- if (PyVecTo(value, color))
- {
- self->setAmbientColor(color[0], color[1], color[2]);
- return PY_SET_ATTR_SUCCESS;
- }
- return PY_SET_ATTR_FAIL;
-}
-
-#endif /* WITH_PYTHON */
diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h
deleted file mode 100644
index b155faf2837..00000000000
--- a/source/gameengine/Ketsji/KX_WorldInfo.h
+++ /dev/null
@@ -1,105 +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_WorldInfo.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_WORLDINFO_H__
-#define __KX_WORLDINFO_H__
-
-#include "MT_Scalar.h"
-#include "KX_KetsjiEngine.h"
-#include "EXP_PyObjectPlus.h"
-
-#ifdef USE_MATHUTILS
-void KX_WorldInfo_Mathutils_Callback_Init(void);
-#endif
-
-struct Scene;
-struct World;
-
-class KX_WorldInfo : public PyObjectPlus
-{
- Py_Header
-
- STR_String m_name;
- bool m_do_color_management;
- bool m_hasworld;
- bool m_hasmist;
- short m_misttype;
- float m_miststart;
- float m_mistdistance;
- float m_mistintensity;
- float m_mistcolor[3];
- float m_backgroundcolor[3];
- float m_ambientcolor[3];
- float m_con_mistcolor[3];
- float m_con_backgroundcolor[3];
- float m_con_ambientcolor[3];
-
-public:
- /**
- * Mist options
- */
- enum MistType {
- KX_MIST_QUADRATIC,
- KX_MIST_LINEAR,
- KX_MIST_INV_QUADRATIC,
- };
-
- KX_WorldInfo(Scene *blenderscene, World *blenderworld);
- ~KX_WorldInfo();
-
- const STR_String &GetName();
- bool hasWorld();
- void setUseMist(bool enable);
- void setMistType(short type);
- void setMistStart(float d);
- void setMistDistance(float d);
- void setMistIntensity(float intensity);
- void setMistColor(float r, float g, float b);
- void setBackColor(float r, float g, float b);
- const float *getBackColorConverted() const;
- void setAmbientColor(float r, float g, float b);
- void UpdateBackGround();
- void UpdateWorldSettings();
-
-#ifdef WITH_PYTHON
- /* attributes */
- static PyObject *pyattr_get_mist_typeconst(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static PyObject *pyattr_get_mist_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_mist_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_back_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_back_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- static PyObject *pyattr_get_ambient_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
- static int pyattr_set_ambient_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
- virtual PyObject *py_repr(void);
-#endif
-};
-
-#endif /* __KX_WORLDINFO_H__ */
diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.cpp b/source/gameengine/Ketsji/KX_WorldIpoController.cpp
deleted file mode 100644
index 1123e07ebcc..00000000000
--- a/source/gameengine/Ketsji/KX_WorldIpoController.cpp
+++ /dev/null
@@ -1,125 +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_WorldIpoController.cpp
- * \ingroup ketsji
- */
-
-
-#include "KX_WorldIpoController.h"
-#include "KX_ScalarInterpolator.h"
-#include "KX_WorldInfo.h"
-#include "KX_PythonInit.h"
-#include "KX_Scene.h"
-
-#if defined(_WIN64)
-typedef unsigned __int64 uint_ptr;
-#else
-typedef unsigned long uint_ptr;
-#endif
-
-bool KX_WorldIpoController::Update(double currentTime)
-{
- if (m_modified) {
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- (*i)->Execute(m_ipotime);
- }
-
- KX_WorldInfo *world = KX_GetActiveScene()->GetWorldInfo();
-
- if (m_modify_mist_start) {
- world->setMistStart(m_mist_start);
- }
-
- if (m_modify_mist_dist) {
- world->setMistDistance(m_mist_dist);
- }
-
- if (m_modify_mist_intensity) {
- world->setMistIntensity(m_mist_intensity);
- }
-
- if (m_modify_horizon_color) {
- world->setBackColor(m_hori_rgb[0], m_hori_rgb[1], m_hori_rgb[2]);
- world->setMistColor(m_hori_rgb[0], m_hori_rgb[1], m_hori_rgb[2]);
- }
-
- if (m_modify_ambient_color) {
- world->setAmbientColor(m_ambi_rgb[0], m_ambi_rgb[1], m_ambi_rgb[2]);
- }
-
- m_modified = false;
- }
- return false;
-}
-
-
-void KX_WorldIpoController::AddInterpolator(KX_IInterpolator* interp)
-{
- this->m_interpolators.push_back(interp);
-}
-
-
-SG_Controller* KX_WorldIpoController::GetReplica(class SG_Node* destnode)
-{
- KX_WorldIpoController* iporeplica = new KX_WorldIpoController(*this);
- // clear object that ipo acts on
- iporeplica->ClearObject();
-
- // dirty hack, ask Gino for a better solution in the ipo implementation
- // hacken en zagen, in what we call datahiding, not written for replication :(
-
- T_InterpolatorList oldlist = m_interpolators;
- iporeplica->m_interpolators.clear();
-
- T_InterpolatorList::iterator i;
- for (i = oldlist.begin(); !(i == oldlist.end()); ++i) {
- KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i));
- iporeplica->AddInterpolator(copyipo);
-
- MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
- uint_ptr orgbase = (uint_ptr)this;
- uint_ptr orgloc = (uint_ptr)scaal;
- uint_ptr offset = orgloc-orgbase;
- uint_ptr newaddrbase = (uint_ptr)iporeplica + offset;
- MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
- copyipo->SetNewTarget((MT_Scalar*)blaptr);
- }
-
- return iporeplica;
-}
-
-KX_WorldIpoController::~KX_WorldIpoController()
-{
-
- T_InterpolatorList::iterator i;
- for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
- delete (*i);
- }
-
-}
diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.h b/source/gameengine/Ketsji/KX_WorldIpoController.h
deleted file mode 100644
index 704f421573e..00000000000
--- a/source/gameengine/Ketsji/KX_WorldIpoController.h
+++ /dev/null
@@ -1,117 +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_WorldIpoController.h
- * \ingroup ketsji
- */
-
-#ifndef __KX_WORLDIPOCONTROLLER_H__
-#define __KX_WORLDIPOCONTROLLER_H__
-
-#include "SG_Controller.h"
-#include "SG_Spatial.h"
-#include "KX_IInterpolator.h"
-
-class KX_WorldIpoController : public SG_Controller
-{
-public:
- MT_Scalar m_mist_start;
- MT_Scalar m_mist_dist;
- MT_Scalar m_mist_intensity;
- MT_Scalar m_hori_rgb[3];
- MT_Scalar m_ambi_rgb[3];
-
-private:
- T_InterpolatorList m_interpolators;
- unsigned short m_modify_mist_start : 1;
- unsigned short m_modify_mist_dist : 1;
- unsigned short m_modify_mist_intensity : 1;
- unsigned short m_modify_horizon_color : 1;
- unsigned short m_modify_ambient_color : 1;
- bool m_modified;
-
- double m_ipotime;
-
-public:
- KX_WorldIpoController() :
- m_modify_mist_start(false),
- m_modify_mist_dist(false),
- m_modify_mist_intensity(false),
- m_modify_horizon_color(false),
- m_modify_ambient_color(false),
- m_modified(true),
- m_ipotime(0.0)
- {}
-
- virtual ~KX_WorldIpoController();
-
- virtual SG_Controller* GetReplica(class SG_Node* destnode);
-
- virtual bool Update(double time);
-
- virtual void SetSimulatedTime(double time) {
- m_ipotime = time;
- m_modified = true;
- }
-
- void SetModifyMistStart(bool modify) {
- m_modify_mist_start = modify;
- }
-
- void SetModifyMistDist(bool modify) {
- m_modify_mist_dist = modify;
- }
-
- void SetModifyMistIntensity(bool modify) {
- m_modify_mist_intensity = modify;
- }
-
- void SetModifyHorizonColor(bool modify) {
- m_modify_horizon_color = modify;
- }
-
- void SetModifyAmbientColor(bool modify) {
- m_modify_ambient_color = modify;
- }
-
- void
- SetOption(
- int option,
- int value
- ) {
- // intentionally empty
- };
-
- void AddInterpolator(KX_IInterpolator* interp);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_WorldIpoController")
-#endif
-};
-
-#endif /* __KX_WORLDIPOCONTROLLER_H__ */
diff --git a/source/gameengine/Network/CMakeLists.txt b/source/gameengine/Network/CMakeLists.txt
deleted file mode 100644
index 019fc3e6032..00000000000
--- a/source/gameengine/Network/CMakeLists.txt
+++ /dev/null
@@ -1,48 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../../../intern/container
- ../../../intern/string
- ../../blender/blenlib
-)
-
-set(INC_SYS
- ../../../intern/moto/include
-)
-
-set(SRC
- NG_NetworkMessage.cpp
- NG_NetworkObject.cpp
- NG_NetworkScene.cpp
-
- NG_NetworkDeviceInterface.h
- NG_NetworkMessage.h
- NG_NetworkObject.h
- NG_NetworkScene.h
-)
-
-blender_add_lib(ge_logic_ngnetwork "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt
deleted file mode 100644
index 75877575614..00000000000
--- a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt
+++ /dev/null
@@ -1,43 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ..
- ../../../../intern/container
- ../../../../intern/string
-)
-
-set(INC_SYS
-
-)
-
-set(SRC
- NG_LoopBackNetworkDeviceInterface.cpp
-
- NG_LoopBackNetworkDeviceInterface.h
-)
-
-blender_add_lib(ge_logic_loopbacknetwork "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp
deleted file mode 100644
index c57bd304ca2..00000000000
--- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp
+++ /dev/null
@@ -1,112 +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 *****
- * LoopbackNetworkDeviceInterface derived from NG_NetworkDeviceInterface
- */
-
-/** \file gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp
- * \ingroup bgenetlb
- */
-
-
-#include "NG_LoopBackNetworkDeviceInterface.h"
-#include "NG_NetworkMessage.h"
-
-using namespace std;
-
-// temporary debugging printf's
-#ifdef NAN_NET_DEBUG
- #include <stdio.h>
-#endif
-
-NG_LoopBackNetworkDeviceInterface::NG_LoopBackNetworkDeviceInterface()
-{
- m_currentQueue=0;
- Online(); // LoopBackdevices are 'online' immediately
-}
-
-NG_LoopBackNetworkDeviceInterface::~NG_LoopBackNetworkDeviceInterface()
-{
-}
-
-// perhaps this should go to the shared/common implementation too
-void NG_LoopBackNetworkDeviceInterface::NextFrame()
-{
- // Release reference to the messages while emptying the queue
- while (m_messages[m_currentQueue].size() > 0) {
-#ifdef NAN_NET_DEBUG
- printf("NG_LBNDI::NextFrame %d '%s'\n", m_currentQueue, m_messages[m_currentQueue][0]->GetSubject().ReadPtr());
-#endif
- // Should do assert(m_events[0]);
- m_messages[m_currentQueue][0]->Release();
- m_messages[m_currentQueue].pop_front();
- }
- //m_messages[m_currentQueue].clear();
-
- m_currentQueue=1-m_currentQueue;
-}
-
-void NG_LoopBackNetworkDeviceInterface::SendNetworkMessage(NG_NetworkMessage* nwmsg)
-{
-#ifdef NAN_NET_DEBUG
- printf("NG_LBNDI::SendNetworkMessage %d, '%s'->'%s' '%s' '%s'\n",
- 1-m_currentQueue,
- nwmsg->GetDestinationName().ReadPtr(),
- nwmsg->GetSenderName().ReadPtr(),
- nwmsg->GetSubject().ReadPtr(),
- nwmsg->GetMessageText().ReadPtr());
-#endif
- int backqueue = 1-m_currentQueue;
-
- nwmsg->AddRef();
- m_messages[backqueue].push_back(nwmsg);
-}
-
-vector<NG_NetworkMessage*> NG_LoopBackNetworkDeviceInterface::RetrieveNetworkMessages()
-{
- vector<NG_NetworkMessage*> messages;
-
- std::deque<NG_NetworkMessage*>::iterator mesit=m_messages[m_currentQueue].begin();
- for (; !(mesit == m_messages[m_currentQueue].end()); ++mesit)
- {
-
- // We don't increase the reference count for these messages. We
- // are passing a vector of messages in the interface and not
- // explicitily storing the messgaes for long term usage
-
- messages.push_back(*mesit);
-
-#ifdef NAN_NET_DEBUG
- printf("NG_LBNDI::RetrieveNetworkMessages %d '%s'->'%s' '%s' '%s'\n",
- m_currentQueue,
- (*mesit)->GetDestinationName().ReadPtr(),
- (*mesit)->GetSenderName().ReadPtr(),
- (*mesit)->GetSubject().ReadPtr(),
- (*mesit)->GetMessageText().ReadPtr());
-#endif
- }
- return messages;
-}
-
diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h
deleted file mode 100644
index 8bbb1e91e35..00000000000
--- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h
+++ /dev/null
@@ -1,63 +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 NG_LoopBackNetworkDeviceInterface.h
- * \ingroup bgenetlb
- * \brief LoopbackNetworkDeviceInterface derived from NG_NetworkDeviceInterface
- */
-#ifndef __NG_LOOPBACKNETWORKDEVICEINTERFACE_H__
-#define __NG_LOOPBACKNETWORKDEVICEINTERFACE_H__
-
-#include <deque>
-#include "NG_NetworkDeviceInterface.h"
-
-class NG_LoopBackNetworkDeviceInterface : public NG_NetworkDeviceInterface
-{
- std::deque<NG_NetworkMessage*> m_messages[2];
- int m_currentQueue;
-
-public:
- NG_LoopBackNetworkDeviceInterface();
- virtual ~NG_LoopBackNetworkDeviceInterface();
-
- /**
- * Clear message buffer
- */
- virtual void NextFrame();
-
- bool Connect(char *address, unsigned int port, char *password,
- unsigned int localport, unsigned int timeout)
- {
- return true;
- }
- bool Disconnect(void) {return true;}
-
- virtual void SendNetworkMessage(class NG_NetworkMessage* msg);
- virtual std::vector<NG_NetworkMessage*> RetrieveNetworkMessages();
-};
-
-#endif /* __NG_LOOPBACKNETWORKDEVICEINTERFACE_H__ */
diff --git a/source/gameengine/Network/NG_NetworkDeviceInterface.h b/source/gameengine/Network/NG_NetworkDeviceInterface.h
deleted file mode 100644
index 7fcf799db31..00000000000
--- a/source/gameengine/Network/NG_NetworkDeviceInterface.h
+++ /dev/null
@@ -1,82 +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 NG_NetworkDeviceInterface.h
- * \ingroup bgenet
- * \brief Functions like (de)initialize network, get library version
- * To be derived by loopback and network libraries
- */
-
-#ifndef __NG_NETWORKDEVICEINTERFACE_H__
-#define __NG_NETWORKDEVICEINTERFACE_H__
-
-#include "NG_NetworkMessage.h"
-#include <vector>
-
-class NG_NetworkDeviceInterface
-{
-private:
- // candidates for shared/common implementation class
- bool m_online;
-public:
- NG_NetworkDeviceInterface() {}
- virtual ~NG_NetworkDeviceInterface() {}
-
- virtual void NextFrame()=0;
-
- /**
- * Mark network connection online
- */
- void Online(void) { m_online = true; }
- /**
- * Mark network connection offline
- */
- void Offline(void) { m_online = false; }
- /**
- * Is the network connection established ?
- */
- bool IsOnline(void) { return m_online; }
-
- virtual bool Connect(char *address, unsigned int port, char *password,
- unsigned int localport, unsigned int timeout)=0;
- virtual bool Disconnect(void)=0;
-
- virtual void SendNetworkMessage(NG_NetworkMessage* msg)=0;
- /**
- * read NG_NetworkMessage from library buffer, may be
- * irrelevant for loopbackdevices
- */
-
- virtual std::vector<NG_NetworkMessage*> RetrieveNetworkMessages()=0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkDeviceInterface")
-#endif
-};
-
-#endif /* __NG_NETWORKDEVICEINTERFACE_H__ */
diff --git a/source/gameengine/Network/NG_NetworkMessage.cpp b/source/gameengine/Network/NG_NetworkMessage.cpp
deleted file mode 100644
index 23ae2529b7a..00000000000
--- a/source/gameengine/Network/NG_NetworkMessage.cpp
+++ /dev/null
@@ -1,55 +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 *****
- * generic Network Message implementation
- */
-
-/** \file gameengine/Network/NG_NetworkMessage.cpp
- * \ingroup bgenet
- */
-
-#include "NG_NetworkMessage.h"
-#include <assert.h>
-
-int NG_NetworkMessage::s_nextID = 3; // just some number to start with
-
-NG_NetworkMessage::NG_NetworkMessage(
- const STR_String& to,
- const STR_String& from,
- const STR_String& subject,
- const STR_String& body) :
- m_uniqueMessageID(s_nextID++),
- m_refcount(1),
- m_to(to),
- m_from(from),
- m_subject(subject),
- m_message(body)
-{
-}
-
-NG_NetworkMessage::~NG_NetworkMessage()
-{
- assert(m_refcount==0);
-}
diff --git a/source/gameengine/Network/NG_NetworkMessage.h b/source/gameengine/Network/NG_NetworkMessage.h
deleted file mode 100644
index 6ed266557fc..00000000000
--- a/source/gameengine/Network/NG_NetworkMessage.h
+++ /dev/null
@@ -1,138 +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 NG_NetworkMessage.h
- * \ingroup bgenet
- * \brief generic Network Message class
- */
-#ifndef __NG_NETWORKMESSAGE_H__
-#define __NG_NETWORKMESSAGE_H__
-
-#include "STR_HashedString.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class NG_NetworkMessage
-{
- static int s_nextID;
- int m_uniqueMessageID; // intern counting MessageID
- unsigned int m_ClientId;
- int m_refcount;
-
- STR_String m_to; // receiver
- STR_String m_from; // sender
- STR_String m_subject; // empty or propName
- STR_String m_message; // message or propValue
-
-protected:
- ~NG_NetworkMessage();
-
-public:
- NG_NetworkMessage(
- const STR_String& to,
- const STR_String& from,
- const STR_String& subject,
- const STR_String& body);
-
- void AddRef() {
- m_refcount++;
- }
-
- // This is not nice code you should'nt need to resort to
- // delete this.
- void Release()
- {
- if (! --m_refcount)
- {
- delete this;
- }
- }
-
- /**
- * set the content of this message
- */
- void SetMessageText(const STR_String& msgtext) {
- m_message = msgtext;
- }
-
- /**
- * get the (read-only) To part of this message
- */
- const STR_String& GetDestinationName() { return m_to; }
-
- /**
- * get the (read-only) From part of this message
- */
- const STR_String& GetSenderName() { return m_from; }
-
- /**
- * get the (read-only) Subject part of this message
- */
- const STR_String& GetSubject() { return m_subject; }
-
- /**
- * get the (read-only) Body part of this message
- */
- const STR_String& GetMessageText() {
-//cout << "GetMessageText " << m_message << "\n";
- return m_message;
- }
- const STR_String& GetMessageText() const {
-//cout << "GetMessageText " << m_message << "\n";
- return m_message;
- }
-
- /**
- * Set the NetworkMessage sender identifier
- */
- void SetSender(unsigned int ClientId) {
- m_ClientId = ClientId;
- }
-
- /**
- * Get the NetworkMessage sender identifier
- */
- unsigned int GetSender(void) {
- return m_ClientId;
- }
-
- /**
- * get the unique Network Message ID
- */
- int GetMessageID() {
- return m_uniqueMessageID;
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkMessage")
-#endif
-};
-
-#endif /* __NG_NETWORKMESSAGE_H__ */
diff --git a/source/gameengine/Network/NG_NetworkObject.cpp b/source/gameengine/Network/NG_NetworkObject.cpp
deleted file mode 100644
index 5cd42a2e45a..00000000000
--- a/source/gameengine/Network/NG_NetworkObject.cpp
+++ /dev/null
@@ -1,46 +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 *****
- * NetworkGame_NetworkObject generic Network Object implementation
- */
-
-/** \file gameengine/Network/NG_NetworkObject.cpp
- * \ingroup bgenet
- */
-
-#include "NG_NetworkObject.h"
-
-NG_NetworkObject::NG_NetworkObject()
-{
-}
-
-NG_NetworkObject::~NG_NetworkObject()
-{
-}
-
-const STR_String& NG_NetworkObject::GetName()
-{
- return m_name;
-}
diff --git a/source/gameengine/Network/NG_NetworkObject.h b/source/gameengine/Network/NG_NetworkObject.h
deleted file mode 100644
index 54459cad55d..00000000000
--- a/source/gameengine/Network/NG_NetworkObject.h
+++ /dev/null
@@ -1,55 +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 NG_NetworkObject.h
- * \ingroup bgenet
- * \brief generic Network Object class
- */
-#ifndef __NG_NETWORKOBJECT_H__
-#define __NG_NETWORKOBJECT_H__
-
-#include "STR_String.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class NG_NetworkObject
-{
- STR_String m_name;
-public:
- NG_NetworkObject();
- ~NG_NetworkObject();
- const STR_String& GetName();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkObject")
-#endif
-};
-
-#endif /* __NG_NETWORKOBJECT_H__ */
diff --git a/source/gameengine/Network/NG_NetworkScene.cpp b/source/gameengine/Network/NG_NetworkScene.cpp
deleted file mode 100644
index 3dbfb53d03d..00000000000
--- a/source/gameengine/Network/NG_NetworkScene.cpp
+++ /dev/null
@@ -1,272 +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 *****
- * NetworkSceneManagement generic implementation
- */
-
-/** \file gameengine/Network/NG_NetworkScene.cpp
- * \ingroup bgenet
- */
-
-#include <stdio.h>
-#include <MT_assert.h>
-#include <algorithm>
-
-#include "NG_NetworkScene.h"
-#include "NG_NetworkDeviceInterface.h"
-#include "NG_NetworkMessage.h"
-#include "NG_NetworkObject.h"
-
-NG_NetworkScene::NG_NetworkScene(NG_NetworkDeviceInterface* nic)
-{
- m_networkdevice = nic;
-}
-
-NG_NetworkScene::~NG_NetworkScene()
-{
- ClearAllMessageMaps();
-}
-
-/**
- * progress one frame, handle all network traffic
- */
-void NG_NetworkScene::proceed(double curtime)
-{
- if (!m_networkdevice) return;
- if (!m_networkdevice->IsOnline()) return;
-
- ClearAllMessageMaps();
-
- // read all NetworkMessages from the device
- vector<NG_NetworkMessage*> messages =
- m_networkdevice->RetrieveNetworkMessages();
-
- vector<NG_NetworkMessage*>::iterator mesit = messages.begin();
- for (; !(mesit == messages.end()); mesit++) {
- NG_NetworkMessage* message = (*mesit);
- vector<NG_NetworkMessage*>* tmplist=NULL;
-
- vector<NG_NetworkMessage*>** tmplistptr =
- m_messagesByDestinationName[message->GetDestinationName()];
- // if there is already a vector of messages, append, else create
- // a new vector and insert into map
- if (!tmplistptr) {
- tmplist = new vector<NG_NetworkMessage*>;
- m_messagesByDestinationName.insert(message->GetDestinationName(),
- tmplist);
- } else {
- tmplist = *tmplistptr;
- }
- message->AddRef();
- tmplist->push_back(message);
- tmplist = NULL;
-
- tmplistptr = m_messagesBySenderName[message->GetSenderName()];
- // if there is already a vector of messages, append, else create
- // a new vector and insert into map
- if (!tmplistptr) {
- tmplist = new vector<NG_NetworkMessage*>;
- m_messagesBySenderName.insert(message->GetSenderName(), tmplist);
- } else {
- tmplist = *tmplistptr;
- }
- message->AddRef();
- tmplist->push_back(message);
- tmplist = NULL;
-
- tmplistptr = m_messagesBySubject[message->GetSubject()];
- // if there is already a vector of messages, append, else create
- // a new vector and insert into map
- if (!tmplistptr) {
- tmplist = new vector<NG_NetworkMessage*>;
- m_messagesBySubject.insert(message->GetSubject(), tmplist);
- } else {
- tmplist = *tmplistptr;
- }
- message->AddRef();
- tmplist->push_back(message);
- tmplist = NULL;
- }
-}
-
-/**
- * add a network object to the network scene
- */
-void NG_NetworkScene::AddObject(NG_NetworkObject* object)
-{
- if (! m_networkdevice->IsOnline()) return;
-
- const STR_String& name = object->GetName();
- m_networkObjects.insert(name, object);
-}
-
-/**
- * remove a network object from the network scene
- */
-void NG_NetworkScene::RemoveObject(NG_NetworkObject* object)
-{
- if (! m_networkdevice->IsOnline()) return;
-
- const STR_String& name = object->GetName();
- m_networkObjects.remove(name);
-}
-
-/**
- * remove all network scene objects at once
- */
-void NG_NetworkScene::RemoveAllObjects()
-{
- m_networkObjects.clear();
-}
-
-/**
- * get a single network object given its name
- */
-NG_NetworkObject* NG_NetworkScene::FindNetworkObject(const STR_String& objname)
-{
- NG_NetworkObject *nwobj = NULL;
- if (! m_networkdevice->IsOnline()) return nwobj;
-
- NG_NetworkObject **nwobjptr = m_networkObjects[objname];
- if (nwobjptr) {
- nwobj = *nwobjptr;
- }
-
- return nwobj;
-}
-
-bool NG_NetworkScene::ConstraintsAreValid(
- const STR_String& from,
- const STR_String& subject,
- NG_NetworkMessage* message)
-{
- vector<NG_NetworkMessage*>** fromlistptr = m_messagesBySenderName[from];
- vector<NG_NetworkMessage*>** subjectlistptr = m_messagesBySubject[subject];
-
- vector<NG_NetworkMessage*>* fromlist = (fromlistptr ? *fromlistptr : NULL);
- vector<NG_NetworkMessage*>* subjectlist = (subjectlistptr ? *subjectlistptr : NULL);
-
- return (
- ( from.IsEmpty() || (!fromlist ? false : (!(std::find(fromlist->begin(), fromlist->end(), message) == fromlist->end())))
- ) &&
- ( subject.IsEmpty() || (!subjectlist ? false : (!(std::find(subjectlist->begin(), subjectlist->end(), message) == subjectlist->end())))
- ));
-}
-
-vector<NG_NetworkMessage*> NG_NetworkScene::FindMessages(
- const STR_String& to,
- const STR_String& from,
- const STR_String& subject,
- bool spamallowed)
-{
- vector<NG_NetworkMessage*> foundmessages;
- bool notfound = false;
-
- // broad phase
- notfound = ((to.IsEmpty() || spamallowed) ? notfound : m_messagesByDestinationName[to] == NULL);
- if (!notfound)
- notfound = (from.IsEmpty() ? notfound : m_messagesBySenderName[from] == NULL);
- if (!notfound)
- notfound = (subject.IsEmpty() ? notfound : m_messagesBySubject[subject] == NULL);
- if (notfound) {
- // it's definitely NOT in the scene, so stop looking
- } else { // narrow phase
- // possibly it's there, but maybe not (false hit)
- if (to.IsEmpty()) {
- // take all messages, and check other fields
- MT_assert(!"objectnames that are empty are not valid, so make it a hobby project :)\n");
- } else {
- //todo: find intersection of messages (that are in other 2 maps)
- vector<NG_NetworkMessage*>** tolistptr = m_messagesByDestinationName[to];
- if (tolistptr) {
- vector<NG_NetworkMessage*>* tolist = *tolistptr;
- vector<NG_NetworkMessage*>::iterator listit;
- for (listit=tolist->begin();!(listit==tolist->end());listit++) {
- NG_NetworkMessage* message = *listit;
- if (ConstraintsAreValid(from, subject, message)) {
- message->AddRef();
- foundmessages.push_back(message);
- }
- }
- }
- // TODO find intersection of messages (that are in other 2 maps)
- if (spamallowed) {
- tolistptr = m_messagesByDestinationName[""];
- if (tolistptr) {
- vector<NG_NetworkMessage*>* tolist = *tolistptr;
- vector<NG_NetworkMessage*>::iterator listit;
- for (listit=tolist->begin();!(listit==tolist->end());listit++) {
- NG_NetworkMessage* message = *listit;
- if (ConstraintsAreValid(from, subject, message)) {
- message->AddRef();
- foundmessages.push_back(message);
- }
- }
- }
- }
- }
- }
- return foundmessages;
-}
-
-void NG_NetworkScene::SendMessage(
- const STR_String& to,
- const STR_String& from,
- const STR_String& subject,
- const STR_String& message)
-{
- NG_NetworkMessage* msg = new NG_NetworkMessage(to, from, subject, message);
- m_networkdevice->SendNetworkMessage(msg);
- msg->Release();
-}
-
-void NG_NetworkScene::ClearAllMessageMaps(void)
-{
- ClearMessageMap(m_messagesByDestinationName);
- ClearMessageMap(m_messagesBySenderName);
- ClearMessageMap(m_messagesBySubject);
-}
-
-void NG_NetworkScene::ClearMessageMap(TMessageMap& map)
-{
- // Release the messages in the map
- for (int i = 0; i < map.size(); i++) {
- vector<NG_NetworkMessage*>* msglist;
- msglist = *(map.at(i));
-
- // Iterate through the current vector and release all it's messages
- vector<NG_NetworkMessage*>::iterator msgit;
- for (msgit = msglist->begin(); msgit != msglist->end(); msgit++) {
- (*msgit)->Release();
- }
-
- // Delete the actual vector
- delete (msglist);
- }
-
- // Empty the map
- map.clear();
-}
-
diff --git a/source/gameengine/Network/NG_NetworkScene.h b/source/gameengine/Network/NG_NetworkScene.h
deleted file mode 100644
index e6233852ee2..00000000000
--- a/source/gameengine/Network/NG_NetworkScene.h
+++ /dev/null
@@ -1,118 +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 NG_NetworkScene.h
- * \ingroup bgenet
- * \brief NetworkSceneManagement generic class
- */
-#ifndef __NG_NETWORKSCENE_H__
-#define __NG_NETWORKSCENE_H__
-
-#include "CTR_Map.h"
-#include "STR_HashedString.h"
-#include <vector>
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-//MSVC defines SendMessage as a win api function, even though we aren't using it
-#ifdef SendMessage
-# undef SendMessage
-#endif
-
-using namespace std;
-
-class NG_NetworkDeviceInterface;
-
-class NG_NetworkScene
-{
- class NG_NetworkDeviceInterface *m_networkdevice;
- CTR_Map<STR_HashedString, class NG_NetworkObject *> m_networkObjects;
-
- // CTR_Maps used as a 'Bloom' filter
- typedef CTR_Map<STR_HashedString, std::vector<class NG_NetworkMessage*>* > TMessageMap;
- TMessageMap m_messagesByDestinationName;
- TMessageMap m_messagesBySenderName;
- TMessageMap m_messagesBySubject;
-
-public:
- NG_NetworkScene(NG_NetworkDeviceInterface *nic);
- ~NG_NetworkScene();
-
- /**
- * progress one frame, handle all network traffic
- */
- void proceed(double curtime);
-
- /**
- * add a networkobject to the scene
- */
- void AddObject(NG_NetworkObject* object);
-
- /**
- * remove a networkobject to the scene
- */
- void RemoveObject(NG_NetworkObject* object);
-
- /**
- * remove all objects at once
- */
- void RemoveAllObjects();
-
- /**
- * send a message (ascii text) over the network
- */
- void SendMessage(const STR_String& to,const STR_String& from,const STR_String& subject,const STR_String& message);
-
- /**
- * find an object by name
- */
- NG_NetworkObject* FindNetworkObject(const STR_String& objname);
-
- bool ConstraintsAreValid(const STR_String& from,const STR_String& subject,class NG_NetworkMessage* message);
- vector<NG_NetworkMessage*> FindMessages(const STR_String& to,const STR_String& from,const STR_String& subject,bool spamallowed);
-
-protected:
- /**
- * Releases messages in message map members.
- */
- void ClearAllMessageMaps(void);
-
- /**
- * Releases messages for the given message map.
- * \param map Message map with messages.
- */
- void ClearMessageMap(TMessageMap& map);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkScene")
-#endif
-};
-
-#endif /* __NG_NETWORKSCENE_H__ */
diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt
deleted file mode 100644
index 8b00f1b47fa..00000000000
--- a/source/gameengine/Physics/Bullet/CMakeLists.txt
+++ /dev/null
@@ -1,73 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-# since this includes bullet we get errors from the headers too
-remove_strict_flags()
-
-set(INC
- .
- ../common
- ../../Converter
- ../../Expressions
- ../../GameLogic
- ../../Ketsji
- ../../Rasterizer
- ../../SceneGraph
- ../../../blender/blenkernel
- ../../../blender/blenlib
- ../../../blender/gpu
- ../../../blender/makesdna
- ../../../../intern/container
- ../../../../intern/guardedalloc
- ../../../../intern/glew-mx
- ../../../../intern/string
-)
-
-set(INC_SYS
- ../../../../intern/moto/include
- ${GLEW_INCLUDE_PATH}
- ${PYTHON_INCLUDE_DIRS}
-)
-
-set(SRC
- CcdPhysicsEnvironment.cpp
- CcdPhysicsController.cpp
- CcdGraphicController.cpp
-
- CcdGraphicController.h
- CcdPhysicsController.h
- CcdPhysicsEnvironment.h
-)
-
-if(WITH_BULLET)
- list(APPEND INC_SYS
- ${BULLET_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_BULLET)
-endif()
-
-add_definitions(${GL_DEFINITIONS})
-
-blender_add_lib(ge_phys_bullet "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
deleted file mode 100644
index 470a5431843..00000000000
--- a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/** \file gameengine/Physics/Bullet/CcdGraphicController.cpp
- * \ingroup physbullet
- */
-/*
-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 "CcdPhysicsEnvironment.h"
-#include "CcdGraphicController.h"
-#include "btBulletDynamicsCommon.h"
-#include "MT_Point3.h"
-
-
-CcdGraphicController::CcdGraphicController (CcdPhysicsEnvironment* phyEnv, PHY_IMotionState* motionState) :
- m_localAabbMin(0.f, 0.f, 0.f),
- m_localAabbMax(0.f, 0.f, 0.f),
- m_motionState(motionState),
- m_phyEnv(phyEnv),
- m_handle(NULL),
- m_newClientInfo(NULL)
-{
-}
-
-CcdGraphicController::~CcdGraphicController()
-{
- if (m_phyEnv)
- m_phyEnv->RemoveCcdGraphicController(this);
-
- if (m_motionState)
- delete m_motionState;
-}
-
-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)
-{
- 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)
-{
- 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)
-{
- 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)
-{
- 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]);
-
- btVector3 localAabbMin = m_localAabbMin;
- btVector3 localAabbMax = m_localAabbMax;
- btVector3 tmpAabbMin = m_localAabbMin * scale;
- btVector3 tmpAabbMax = m_localAabbMax * scale;
-
- localAabbMin[0] = (scale.getX() >= 0.0f) ? tmpAabbMin[0] : tmpAabbMax[0];
- localAabbMin[1] = (scale.getY() >= 0.0f) ? tmpAabbMin[1] : tmpAabbMax[1];
- localAabbMin[2] = (scale.getZ() >= 0.0f) ? tmpAabbMin[2] : tmpAabbMax[2];
- localAabbMax[0] = (scale.getX() <= 0.0f) ? tmpAabbMin[0] : tmpAabbMax[0];
- localAabbMax[1] = (scale.getY() <= 0.0f) ? tmpAabbMin[1] : tmpAabbMax[1];
- localAabbMax[2] = (scale.getZ() <= 0.0f) ? tmpAabbMin[2] : tmpAabbMax[2];
-
- btVector3 localHalfExtents = btScalar(0.5f)*(localAabbMax-localAabbMin);
- btVector3 localCenter = btScalar(0.5f)*(localAabbMax+localAabbMin);
-
- btMatrix3x3 abs_b = rot.absolute();
- btVector3 center = rot*localCenter + pos;
- btVector3 extent = abs_b*localHalfExtents;
- aabbMin = center - extent;
- aabbMax = center + extent;
-}
-
-bool CcdGraphicController::SetGraphicTransform()
-{
- if (!m_handle)
- return false;
- btVector3 aabbMin;
- btVector3 aabbMax;
- GetAabb(aabbMin, aabbMax);
- // update Aabb in broadphase
- m_phyEnv->GetCullingTree()->setAabb(m_handle,aabbMin,aabbMax,NULL);
- return true;
-}
-
-PHY_IGraphicController* CcdGraphicController::GetReplica(class PHY_IMotionState* motionState)
-{
- CcdGraphicController* replica = new CcdGraphicController(*this);
- replica->m_motionState = motionState;
- replica->m_newClientInfo = NULL;
- replica->m_handle = NULL;
- // don't add the graphic controller now: work around a bug in Bullet with rescaling,
- // (the scale of the controller is not yet defined).
- //m_phyEnv->addCcdGraphicController(replica);
- return replica;
-}
-
-void CcdGraphicController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* env)
-{
- CcdPhysicsEnvironment* phyEnv = static_cast<CcdPhysicsEnvironment*>(env);
- /* Updates the m_phyEnv's m_cullingTree & m_cullingCache */
- if (GetBroadphaseHandle()) {
- /* insert into the new physics scene */
- Activate(false);
- m_phyEnv= phyEnv;
- Activate(true);
- }
- else {
- m_phyEnv= phyEnv;
- }
-}
-
-void CcdGraphicController::Activate(bool active)
-{
- if (active)
- m_phyEnv->AddCcdGraphicController(this);
- else
- m_phyEnv->RemoveCcdGraphicController(this);
-
-}
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h
deleted file mode 100644
index e76ad86301e..00000000000
--- a/source/gameengine/Physics/Bullet/CcdGraphicController.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-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.
-*/
-
-/** \file CcdGraphicController.h
- * \ingroup physbullet
- */
-
-
-#ifndef __CCDGRAPHICCONTROLLER_H__
-#define __CCDGRAPHICCONTROLLER_H__
-
-#include "PHY_IGraphicController.h"
-
-#include "btBulletDynamicsCommon.h"
-#include "LinearMath/btTransform.h"
-
-#include "PHY_IMotionState.h"
-#include "MT_Point3.h"
-
-class CcdPhysicsEnvironment;
-class btCollisionObject;
-
-///CcdGraphicController is a graphic object that supports view frustrum culling and occlusion
-class CcdGraphicController : public PHY_IGraphicController
-{
-public:
- CcdGraphicController(CcdPhysicsEnvironment* phyEnv, PHY_IMotionState* motionState);
-
- 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]);
-
- PHY_IMotionState* GetMotionState() { return m_motionState; }
- void GetAabb(btVector3& aabbMin, btVector3& aabbMax);
-
- virtual void SetBroadphaseHandle(btBroadphaseProxy* handle) { m_handle = handle; }
- virtual btBroadphaseProxy* GetBroadphaseHandle() { return m_handle; }
-
- virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* env);
-
- ////////////////////////////////////
- // PHY_IGraphicController interface
- ////////////////////////////////////
-
- /**
- * Updates the Aabb based on the motion state
- */
- virtual bool SetGraphicTransform();
- /**
- * Add/remove to environment
- */
- virtual void Activate(bool active);
-
- // client info for culling
- virtual void* GetNewClientInfo() { return m_newClientInfo; }
- virtual void SetNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; }
- virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate);
-
-private:
- // unscaled aabb corner
- btVector3 m_localAabbMin;
- btVector3 m_localAabbMax;
-
- PHY_IMotionState* m_motionState;
- CcdPhysicsEnvironment* m_phyEnv;
- btBroadphaseProxy* m_handle;
- void* m_newClientInfo;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdGraphicController")
-#endif
-};
-
-#endif /* BULLET2_PHYSICSCONTROLLER_H */
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
deleted file mode 100644
index b3cee944880..00000000000
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ /dev/null
@@ -1,2668 +0,0 @@
-/** \file gameengine/Physics/Bullet/CcdPhysicsController.cpp
- * \ingroup physbullet
- */
-/*
-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 WIN32
-#include <stdint.h>
-#endif
-
-#include "CcdPhysicsController.h"
-#include "btBulletDynamicsCommon.h"
-#include "BulletCollision/CollisionDispatch/btGhostObject.h"
-#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
-#include "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h"
-
-#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"
-#include "BulletSoftBody/btSoftBodyInternals.h"
-#include "BulletSoftBody/btSoftBodyHelpers.h"
-#include "LinearMath/btConvexHull.h"
-#include "BulletCollision/Gimpact/btGImpactShape.h"
-
-#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
-
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-
-extern "C"{
- #include "BLI_utildefines.h"
- #include "BKE_cdderivedmesh.h"
-}
-
-
-class BP_Proxy;
-
-///todo: fill all the empty CcdPhysicsController methods, hook them up to the btRigidBody class
-
-//'temporarily' global variables
-//float gDeactivationTime = 2.f;
-//bool gDisableDeactivation = false;
-extern float gDeactivationTime;
-extern bool gDisableDeactivation;
-
-
-float gLinearSleepingTreshold;
-float gAngularSleepingTreshold;
-
-BlenderBulletCharacterController::BlenderBulletCharacterController(btMotionState *motionState, btPairCachingGhostObject *ghost, btConvexShape* shape, float stepHeight)
- : btKinematicCharacterController(ghost,shape,stepHeight,2),
- m_motionState(motionState),
- m_jumps(0),
- m_maxJumps(1)
-{
-}
-
-void BlenderBulletCharacterController::updateAction(btCollisionWorld *collisionWorld, btScalar dt)
-{
- if (onGround())
- m_jumps = 0;
-
- btKinematicCharacterController::updateAction(collisionWorld,dt);
- m_motionState->setWorldTransform(getGhostObject()->getWorldTransform());
-}
-
-unsigned char BlenderBulletCharacterController::getMaxJumps() const
-{
- return m_maxJumps;
-}
-
-void BlenderBulletCharacterController::setMaxJumps(unsigned char maxJumps)
-{
- m_maxJumps = maxJumps;
-}
-
-unsigned char BlenderBulletCharacterController::getJumpCount() const
-{
- return m_jumps;
-}
-
-bool BlenderBulletCharacterController::canJump() const
-{
- return (onGround() && m_maxJumps > 0) || m_jumps < m_maxJumps;
-}
-
-void BlenderBulletCharacterController::jump()
-{
- if (!canJump())
- return;
-
- m_verticalVelocity = m_jumpSpeed;
- m_wasJumping = true;
- m_jumps++;
-}
-
-const btVector3& BlenderBulletCharacterController::getWalkDirection()
-{
- return m_walkDirection;
-}
-
-bool CleanPairCallback::processOverlap(btBroadphasePair &pair)
-{
- if ((pair.m_pProxy0 == m_cleanProxy) || (pair.m_pProxy1 == m_cleanProxy)) {
- m_pairCache->cleanOverlappingPair(pair, m_dispatcher);
- CcdPhysicsController *ctrl0 = (CcdPhysicsController*)(((btCollisionObject*)pair.m_pProxy0->m_clientObject)->getUserPointer());
- CcdPhysicsController *ctrl1 = (CcdPhysicsController*)(((btCollisionObject*)pair.m_pProxy1->m_clientObject)->getUserPointer());
- ctrl0->GetCollisionObject()->activate(false);
- ctrl1->GetCollisionObject()->activate(false);
- }
- return false;
-}
-
-CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
-:m_cci(ci)
-{
- m_prototypeTransformInitialized = false;
- m_softbodyMappingDone = false;
- m_collisionDelay = 0;
- m_newClientInfo = 0;
- m_registerCount = 0;
- m_softBodyTransformInitialized = false;
- m_parentCtrl = 0;
- // copy pointers locally to allow smart release
- m_MotionState = ci.m_MotionState;
- m_collisionShape = ci.m_collisionShape;
- // apply scaling before creating rigid body
- m_collisionShape->setLocalScaling(m_cci.m_scaling);
- if (m_cci.m_mass)
- m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
- // shape info is shared, increment ref count
- m_shapeInfo = ci.m_shapeInfo;
- if (m_shapeInfo)
- m_shapeInfo->AddRef();
-
- m_bulletChildShape = NULL;
-
- m_bulletMotionState = 0;
- m_characterController = 0;
- m_savedCollisionFlags = 0;
- m_savedCollisionFilterGroup = 0;
- m_savedCollisionFilterMask = 0;
- m_savedMass = 0.0f;
- m_savedDyna = false;
- m_suspended = false;
-
- CreateRigidbody();
-}
-
-void CcdPhysicsController::addCcdConstraintRef(btTypedConstraint* c)
-{
- int index = m_ccdConstraintRefs.findLinearSearch(c);
- if (index == m_ccdConstraintRefs.size())
- m_ccdConstraintRefs.push_back(c);
-}
-
-void CcdPhysicsController::removeCcdConstraintRef(btTypedConstraint* c)
-{
- m_ccdConstraintRefs.remove(c);
-}
-
-btTypedConstraint* CcdPhysicsController::getCcdConstraintRef(int index)
-{
- return m_ccdConstraintRefs[index];
-}
-
-int CcdPhysicsController::getNumCcdConstraintRefs() const
-{
- return m_ccdConstraintRefs.size();
-}
-
-btTransform& CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState* motionState)
-{
- static btTransform trans;
- btVector3 tmp;
- motionState->GetWorldPosition(tmp.m_floats[0], tmp.m_floats[1], tmp.m_floats[2]);
- trans.setOrigin(tmp);
-
- float ori[12];
- motionState->GetWorldOrientation(ori);
- trans.getBasis().setFromOpenGLSubMatrix(ori);
- //btQuaternion orn;
- //motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
- //trans.setRotation(orn);
- return trans;
-
-}
-
-class BlenderBulletMotionState : public btMotionState
-{
- PHY_IMotionState* m_blenderMotionState;
-
-public:
-
- BlenderBulletMotionState(PHY_IMotionState* bms)
- :m_blenderMotionState(bms)
- {
-
- }
-
- void getWorldTransform(btTransform& worldTrans ) const
- {
- btVector3 pos;
- float ori[12];
-
- 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());
- btQuaternion rotQuat = worldTrans.getRotation();
- m_blenderMotionState->SetWorldOrientation(rotQuat[0],rotQuat[1],rotQuat[2],rotQuat[3]);
- m_blenderMotionState->CalculateWorldTransformations();
- }
-
-};
-
-btRigidBody* CcdPhysicsController::GetRigidBody()
-{
- return btRigidBody::upcast(m_object);
-}
-const btRigidBody* CcdPhysicsController::GetRigidBody() const
-{
- return btRigidBody::upcast(m_object);
-}
-
-btCollisionObject* CcdPhysicsController::GetCollisionObject()
-{
- return m_object;
-}
-btSoftBody* CcdPhysicsController::GetSoftBody()
-{
- return btSoftBody::upcast(m_object);
-}
-btKinematicCharacterController* CcdPhysicsController::GetCharacterController()
-{
- return m_characterController;
-}
-
-#include "BulletSoftBody/btSoftBodyHelpers.h"
-
-
-bool CcdPhysicsController::CreateSoftbody()
-{
- int shapeType = m_cci.m_collisionShape ? m_cci.m_collisionShape->getShapeType() : 0;
-
- //disable soft body until first sneak preview is ready
- if (!m_cci.m_bSoft || !m_cci.m_collisionShape ||
- ((shapeType != CONVEX_HULL_SHAPE_PROXYTYPE)&&
- (shapeType != TRIANGLE_MESH_SHAPE_PROXYTYPE) &&
- (shapeType != SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)))
- {
- return false;
- }
-
- btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
- rbci.m_linearDamping = m_cci.m_linearDamping;
- rbci.m_angularDamping = m_cci.m_angularDamping;
- rbci.m_friction = m_cci.m_friction;
- rbci.m_restitution = m_cci.m_restitution;
-
- btVector3 p(0.0f,0.0f,0.0f);// = 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();
-
- if (m_cci.m_collisionShape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE) {
- btConvexHullShape* convexHull = (btConvexHullShape* )m_cci.m_collisionShape;
- {
- int nvertices = convexHull->getNumPoints();
- const btVector3* vertices = convexHull->getPoints();
-
- HullDesc hdsc(QF_TRIANGLES,nvertices,vertices);
- HullResult hres;
- HullLibrary hlib; /*??*/
- hdsc.mMaxVertices=nvertices;
- hlib.CreateConvexHull(hdsc,hres);
-
- psb = new btSoftBody(&worldInfo, (int)hres.mNumOutputVertices,
- &hres.m_OutputVertices[0], 0);
- for (int i = 0; i < (int)hres.mNumFaces; ++i) {
- const unsigned int idx[3] = {hres.m_Indices[i * 3 + 0],
- hres.m_Indices[i * 3 + 1],
- 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]);
- psb->appendFace(idx[0], idx[1], idx[2]);
- }
- hlib.ReleaseResult(hres);
- }
- }
- else {
- int numtris = 0;
- if (m_cci.m_collisionShape->getShapeType() ==SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
- {
- btScaledBvhTriangleMeshShape* scaledtrimeshshape = (btScaledBvhTriangleMeshShape*) m_cci.m_collisionShape;
- btBvhTriangleMeshShape* trimeshshape = scaledtrimeshshape->getChildShape();
-
- ///only deal with meshes that have 1 sub part/component, for now
- if (trimeshshape->getMeshInterface()->getNumSubParts()==1)
- {
- unsigned char* vertexBase;
- btScalar* scaledVertexBase;
- btVector3 localScaling;
- PHY_ScalarType vertexType;
- int numverts;
- int vertexstride;
- unsigned char* indexbase;
- int indexstride;
- PHY_ScalarType indexType;
- trimeshshape->getMeshInterface()->getLockedVertexIndexBase(&vertexBase,numverts,vertexType,vertexstride,&indexbase,indexstride,numtris,indexType);
- localScaling = scaledtrimeshshape->getLocalScaling();
- scaledVertexBase = new btScalar[numverts*3];
- for (int i=0; i<numverts*3; i+=3)
- {
- scaledVertexBase[i] = ((const btScalar*)vertexBase)[i] * localScaling.getX();
- scaledVertexBase[i+1] = ((const btScalar*)vertexBase)[i+1] * localScaling.getY();
- scaledVertexBase[i+2] = ((const btScalar*)vertexBase)[i+2] * localScaling.getZ();
- }
- psb = btSoftBodyHelpers::CreateFromTriMesh(worldInfo,scaledVertexBase,(const int*)indexbase,numtris,false);
- delete [] scaledVertexBase;
- }
- } else
- {
- btTriangleMeshShape* trimeshshape = (btTriangleMeshShape*) m_cci.m_collisionShape;
- ///only deal with meshes that have 1 sub part/component, for now
- if (trimeshshape->getMeshInterface()->getNumSubParts()==1)
- {
- unsigned char* vertexBase;
- PHY_ScalarType vertexType;
- int numverts;
- int vertexstride;
- unsigned char* indexbase;
- int indexstride;
- PHY_ScalarType indexType;
- trimeshshape->getMeshInterface()->getLockedVertexIndexBase(&vertexBase,numverts,vertexType,vertexstride,&indexbase,indexstride,numtris,indexType);
-
- psb = btSoftBodyHelpers::CreateFromTriMesh(worldInfo,(const btScalar*)vertexBase,(const int*)indexbase,numtris,false);
- }
- }
- // store face tag so that we can find our original face when doing ray casting
- btSoftBody::Face* ft;
- int i;
- for (i=0, ft=&psb->m_faces[0]; i<numtris; ++i, ++ft)
- {
- // Hack!! use m_tag to store the face number, normally it is a pointer
- // add 1 to make sure it is never 0
- ft->m_tag = (void*)((uintptr_t)(i+1));
- }
- }
- if (m_cci.m_margin > 0.f)
- {
- psb->getCollisionShape()->setMargin(m_cci.m_margin);
- psb->updateBounds();
- }
- m_object = psb;
-
- //btSoftBody::Material* pm=psb->appendMaterial();
- btSoftBody::Material* pm=psb->m_materials[0];
- pm->m_kLST = m_cci.m_soft_linStiff;
- pm->m_kAST = m_cci.m_soft_angStiff;
- pm->m_kVST = m_cci.m_soft_volume;
- psb->m_cfg.collisions = 0;
-
- if (m_cci.m_soft_collisionflags & CCD_BSB_COL_CL_RS)
- {
- psb->m_cfg.collisions += btSoftBody::fCollision::CL_RS;
- } else
- {
- psb->m_cfg.collisions += btSoftBody::fCollision::SDF_RS;
- }
- if (m_cci.m_soft_collisionflags & CCD_BSB_COL_CL_SS)
- {
- psb->m_cfg.collisions += btSoftBody::fCollision::CL_SS;
- } else
- {
- psb->m_cfg.collisions += btSoftBody::fCollision::VF_SS;
- }
-
-
- psb->m_cfg.kSRHR_CL = m_cci.m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
- psb->m_cfg.kSKHR_CL = m_cci.m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
- psb->m_cfg.kSSHR_CL = m_cci.m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
- psb->m_cfg.kSR_SPLT_CL = m_cci.m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
-
- psb->m_cfg.kSK_SPLT_CL = m_cci.m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- psb->m_cfg.kSS_SPLT_CL = m_cci.m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- psb->m_cfg.kVCF = m_cci.m_soft_kVCF; /* Velocities correction factor (Baumgarte) */
- psb->m_cfg.kDP = m_cci.m_soft_kDP; /* Damping coefficient [0,1] */
-
- psb->m_cfg.kDG = m_cci.m_soft_kDG; /* Drag coefficient [0,+inf] */
- psb->m_cfg.kLF = m_cci.m_soft_kLF; /* Lift coefficient [0,+inf] */
- psb->m_cfg.kPR = m_cci.m_soft_kPR; /* Pressure coefficient [-inf,+inf] */
- psb->m_cfg.kVC = m_cci.m_soft_kVC; /* Volume conversation coefficient [0,+inf] */
-
- psb->m_cfg.kDF = m_cci.m_soft_kDF; /* Dynamic friction coefficient [0,1] */
- psb->m_cfg.kMT = m_cci.m_soft_kMT; /* Pose matching coefficient [0,1] */
- psb->m_cfg.kCHR = m_cci.m_soft_kCHR; /* Rigid contacts hardness [0,1] */
- psb->m_cfg.kKHR = m_cci.m_soft_kKHR; /* Kinetic contacts hardness [0,1] */
-
- psb->m_cfg.kSHR = m_cci.m_soft_kSHR; /* Soft contacts hardness [0,1] */
- psb->m_cfg.kAHR = m_cci.m_soft_kAHR; /* Anchors hardness [0,1] */
-
- if (m_cci.m_gamesoftFlag & CCD_BSB_BENDING_CONSTRAINTS)//OB_SB_GOAL)
- {
- psb->generateBendingConstraints(2,pm);
- }
-
- psb->m_cfg.piterations = m_cci.m_soft_piterations;
- psb->m_cfg.viterations = m_cci.m_soft_viterations;
- psb->m_cfg.diterations = m_cci.m_soft_diterations;
- psb->m_cfg.citerations = m_cci.m_soft_citerations;
-
- if (m_cci.m_gamesoftFlag & CCD_BSB_SHAPE_MATCHING)//OB_SB_GOAL)
- {
- psb->setPose(false,true);//
- } else
- {
- psb->setPose(true,false);
- }
-
- psb->randomizeConstraints();
-
- if (m_cci.m_soft_collisionflags & (CCD_BSB_COL_CL_RS+CCD_BSB_COL_CL_SS))
- {
- psb->generateClusters(m_cci.m_soft_numclusteriterations);
- }
-
- psb->setTotalMass(m_cci.m_mass);
-
- psb->setCollisionFlags(0);
-
- ///create a mapping between graphics mesh vertices and soft body vertices
- {
- RAS_MeshObject* rasMesh= GetShapeInfo()->GetMesh();
-
- if (rasMesh && !m_softbodyMappingDone)
- {
- //printf("apply\n");
- RAS_MeshSlot::iterator it;
- RAS_MeshMaterial *mmat;
- RAS_MeshSlot *slot;
- size_t i;
-
- //for each material
- for (int m=0;m<rasMesh->NumMaterials();m++)
- {
- mmat = rasMesh->GetMeshMaterial(m);
-
- slot = mmat->m_baseslot;
- for (slot->begin(it); !slot->end(it); slot->next(it))
- {
- int index = 0;
- for (i=it.startvertex; i<it.endvertex; i++,index++)
- {
- RAS_TexVert* vertex = &it.vertex[i];
- //search closest index, and store it in vertex
- vertex->setSoftBodyIndex(0);
- btScalar maxDistSqr = 1e30;
- btSoftBody::tNodeArray& nodes(psb->m_nodes);
- btVector3 xyz = btVector3(vertex->getXYZ()[0],vertex->getXYZ()[1],vertex->getXYZ()[2]);
- for (int n=0;n<nodes.size();n++)
- {
- btScalar distSqr = (nodes[n].m_x - xyz).length2();
- if (distSqr<maxDistSqr)
- {
- maxDistSqr = distSqr;
-
- vertex->setSoftBodyIndex(n);
- }
- }
- }
- }
- }
- }
- }
- m_softbodyMappingDone = true;
-
- 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);
-
- if (!m_prototypeTransformInitialized)
- {
- m_prototypeTransformInitialized = true;
- m_softBodyTransformInitialized = true;
- psb->transform(startTrans);
- }
- m_object->setCollisionFlags(m_object->getCollisionFlags() | m_cci.m_collisionFlags);
- if (m_cci.m_do_anisotropic)
- m_object->setAnisotropicFriction(m_cci.m_anisotropicFriction);
- return true;
-}
-
-bool CcdPhysicsController::CreateCharacterController()
-{
- if (!m_cci.m_bCharacter)
- return false;
-
- m_object = new btPairCachingGhostObject();
- m_object->setCollisionShape(m_collisionShape);
- m_object->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
-
- btTransform trans;
- m_bulletMotionState->getWorldTransform(trans);
- m_object->setWorldTransform(trans);
-
- m_characterController = new BlenderBulletCharacterController(m_bulletMotionState,(btPairCachingGhostObject*)m_object,(btConvexShape*)m_collisionShape,m_cci.m_stepHeight);
-
- m_characterController->setJumpSpeed(m_cci.m_jumpSpeed);
- m_characterController->setFallSpeed(m_cci.m_fallSpeed);
- m_characterController->setMaxJumps(m_cci.m_maxJumps);
-
- return true;
-}
-
-void CcdPhysicsController::CreateRigidbody()
-{
-
- //btTransform trans = GetTransformFromMotionState(m_MotionState);
- m_bulletMotionState = new BlenderBulletMotionState(m_MotionState);
-
- ///either create a btCollisionObject, btRigidBody or btSoftBody
- if (CreateSoftbody() || CreateCharacterController())
- // soft body created, done
- return;
-
- //create a rgid collision object
- btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
- rbci.m_linearDamping = m_cci.m_linearDamping;
- rbci.m_angularDamping = m_cci.m_angularDamping;
- rbci.m_friction = m_cci.m_friction;
- rbci.m_restitution = m_cci.m_restitution;
- m_object = new btRigidBody(rbci);
-
- //
- // init the rigidbody properly
- //
-
- //setMassProps this also sets collisionFlags
- //convert collision flags!
- //special case: a near/radar sensor controller should not be defined static or it will
- //generate loads of static-static collision messages on the console
- if (m_cci.m_bSensor)
- {
- // reset the flags that have been set so far
- GetCollisionObject()->setCollisionFlags(0);
- // sensor must never go to sleep: they need to detect continously
- GetCollisionObject()->setActivationState(DISABLE_DEACTIVATION);
- }
- GetCollisionObject()->setCollisionFlags(m_object->getCollisionFlags() | m_cci.m_collisionFlags);
- btRigidBody* body = GetRigidBody();
-
- if (body)
- {
- body->setGravity( m_cci.m_gravity);
- body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping);
-
- if (!m_cci.m_bRigid)
- {
- body->setAngularFactor(0.f);
- }
- // use bullet's default contact processing theshold, blender's old default of 1 is too small here.
- // if there's really a need to change this, it should be exposed in the ui first.
-// body->setContactProcessingThreshold(m_cci.m_contactProcessingThreshold);
- body->setSleepingThresholds(gLinearSleepingTreshold, gAngularSleepingTreshold);
-
- }
- if (m_object && m_cci.m_do_anisotropic)
- {
- m_object->setAnisotropicFriction(m_cci.m_anisotropicFriction);
- }
-
-}
-
-static void DeleteBulletShape(btCollisionShape* shape, bool free)
-{
- if (shape->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE) {
- /* If we use Bullet scaled shape (btScaledBvhTriangleMeshShape) we have to
- * free the child of the unscaled shape (btTriangleMeshShape) here.
- */
- btTriangleMeshShape *meshShape = ((btScaledBvhTriangleMeshShape *)shape)->getChildShape();
- if (meshShape)
- delete meshShape;
- }
- if (free) {
- delete shape;
- }
-}
-
-bool CcdPhysicsController::DeleteControllerShape( )
-{
- if (m_collisionShape)
- {
- // collision shape is always unique to the controller, can delete it here
- if (m_collisionShape->isCompound())
- {
- // bullet does not delete the child shape, must do it here
- btCompoundShape* compoundShape = (btCompoundShape*)m_collisionShape;
- int numChild = compoundShape->getNumChildShapes();
- for (int i=numChild-1 ; i >= 0; i--)
- {
- btCollisionShape* childShape = compoundShape->getChildShape(i);
- DeleteBulletShape(childShape, true);
- }
- }
- DeleteBulletShape(m_collisionShape, true);
-
- return true;
- }
-
- return false;
-}
-
-bool CcdPhysicsController::ReplaceControllerShape(btCollisionShape *newShape)
-{
- if (m_collisionShape)
- DeleteControllerShape();
-
- // If newShape is NULL it means to create a new Bullet shape.
- if (!newShape)
- newShape = m_shapeInfo->CreateBulletShape(m_cci.m_margin, m_cci.m_bGimpact, !m_cci.m_bSoft);
-
- m_object->setCollisionShape(newShape);
- m_collisionShape = newShape;
- m_cci.m_collisionShape = newShape;
-
- btSoftBody *softBody = GetSoftBody();
- if (softBody) {
- btSoftRigidDynamicsWorld *world = GetPhysicsEnvironment()->GetDynamicsWorld();
- // remove the old softBody
- world->removeSoftBody(softBody);
-
- // soft body must be recreated
- delete m_object;
- m_object = NULL;
- // force complete reinitialization
- m_softbodyMappingDone = false;
- m_prototypeTransformInitialized = false;
- m_softBodyTransformInitialized = false;
-
- CreateSoftbody();
- assert(m_object);
-
- btSoftBody *newSoftBody = GetSoftBody();
- // set the user
- newSoftBody->setUserPointer(this);
- // add the new softbody
- world->addSoftBody(newSoftBody);
- }
-
- return true;
-}
-
-CcdPhysicsController::~CcdPhysicsController()
-{
- //will be reference counted, due to sharing
- if (m_cci.m_physicsEnv)
- m_cci.m_physicsEnv->RemoveCcdPhysicsController(this);
-
- if (m_MotionState)
- delete m_MotionState;
- if (m_bulletMotionState)
- delete m_bulletMotionState;
- if (m_characterController)
- delete m_characterController;
- delete m_object;
-
- DeleteControllerShape();
-
- if (m_shapeInfo)
- {
- m_shapeInfo->Release();
- }
-}
-
-void CcdPhysicsController::SimulationTick(float timestep)
-{
- btRigidBody *body = GetRigidBody();
- if (!body || body->isStaticObject())
- return;
-
- // Clamp linear velocity
- if (m_cci.m_clamp_vel_max > 0.0f || m_cci.m_clamp_vel_min > 0.0f) {
- const btVector3 &linvel = body->getLinearVelocity();
- btScalar len = linvel.length();
-
- if (m_cci.m_clamp_vel_max > 0.0f && len > m_cci.m_clamp_vel_max)
- body->setLinearVelocity(linvel * (m_cci.m_clamp_vel_max / len));
- else if (m_cci.m_clamp_vel_min > 0.0f && !btFuzzyZero(len) && len < m_cci.m_clamp_vel_min)
- body->setLinearVelocity(linvel * (m_cci.m_clamp_vel_min / len));
- }
-
- // Clamp angular velocity
- if (m_cci.m_clamp_angvel_max > 0.0f || m_cci.m_clamp_angvel_min > 0.0f) {
- const btVector3 &angvel = body->getAngularVelocity();
- btScalar len = angvel.length();
-
- if (m_cci.m_clamp_angvel_max > 0.0f && len > m_cci.m_clamp_angvel_max)
- body->setAngularVelocity(angvel * (m_cci.m_clamp_angvel_max / len));
- else if (m_cci.m_clamp_angvel_min > 0.0f && !btFuzzyZero(len) && len < m_cci.m_clamp_angvel_min)
- body->setAngularVelocity(angvel * (m_cci.m_clamp_angvel_min / len));
- }
-}
-
-
-/**
- * SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
- */
-bool CcdPhysicsController::SynchronizeMotionStates(float time)
-{
- //sync non-static to motionstate, and static from motionstate (todo: add kinematic etc.)
-
- btSoftBody* sb = GetSoftBody();
- if (sb)
- {
- if (sb->m_pose.m_bframe)
- {
- btVector3 worldPos = sb->m_pose.m_com;
- 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]);
- }
- 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->CalculateWorldTransformations();
- return true;
- }
-
- btRigidBody* body = GetRigidBody();
-
- if (body && !body->isStaticObject())
- {
- const btTransform& xform = body->getCenterOfMassTransform();
- const btMatrix3x3& worldOri = xform.getBasis();
- 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();
-
- float scale[3];
- m_MotionState->GetWorldScaling(scale[0],scale[1],scale[2]);
- btVector3 scaling(scale[0],scale[1],scale[2]);
- GetCollisionShape()->setLocalScaling(scaling);
- } else
- {
- btVector3 worldPos;
- btQuaternion worldquat;
-
-/* m_MotionState->getWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
- m_MotionState->getWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
- btTransform oldTrans = m_body->getCenterOfMassTransform();
- btTransform newTrans(worldquat,worldPos);
-
- SetCenterOfMassTransform(newTrans);
- //need to keep track of previous position for friction effects...
-
- m_MotionState->calculateWorldTransformations();
-*/
- float scale[3];
- m_MotionState->GetWorldScaling(scale[0],scale[1],scale[2]);
- btVector3 scaling(scale[0],scale[1],scale[2]);
- GetCollisionShape()->setLocalScaling(scaling);
- }
- return true;
-
-}
-
- /**
- * WriteMotionStateToDynamics synchronizes dynas, kinematic and deformable entities (and do 'late binding')
- */
-
-void CcdPhysicsController::WriteMotionStateToDynamics(bool nondynaonly)
-{
- btTransform& xform = CcdPhysicsController::GetTransformFromMotionState(m_MotionState);
- SetCenterOfMassTransform(xform);
-}
-
-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;
- m_collisionShape = NULL;
-
- // Clear all old constraints.
- m_ccdConstraintRefs.clear();
-
- // always create a new shape to avoid scaling bug
- if (m_shapeInfo)
- {
- m_shapeInfo->AddRef();
- m_collisionShape = m_shapeInfo->CreateBulletShape(m_cci.m_margin, m_cci.m_bGimpact, !m_cci.m_bSoft);
-
- if (m_collisionShape)
- {
- // new shape has no scaling, apply initial scaling
- //m_collisionShape->setMargin(m_cci.m_margin);
- m_collisionShape->setLocalScaling(m_cci.m_scaling);
-
- if (m_cci.m_mass)
- m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
- }
- }
-
- // load some characterists that are not
- btRigidBody* oldbody = GetRigidBody();
- m_object = 0;
- CreateRigidbody();
- btRigidBody* body = GetRigidBody();
- if (body)
- {
- if (m_cci.m_mass)
- {
- body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
- }
-
- if (oldbody)
- {
- body->setLinearFactor(oldbody->getLinearFactor());
- body->setAngularFactor(oldbody->getAngularFactor());
- if (oldbody->getActivationState() == DISABLE_DEACTIVATION)
- body->setActivationState(DISABLE_DEACTIVATION);
- }
- }
- // sensor object are added when needed
- if (!m_cci.m_bSensor)
- m_cci.m_physicsEnv->AddCcdPhysicsController(this);
-
-
-}
-
-void CcdPhysicsController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env)
-{
- // can safely assume CCD environment
- CcdPhysicsEnvironment *physicsEnv = static_cast<CcdPhysicsEnvironment*>(env);
-
- if (m_cci.m_physicsEnv != physicsEnv)
- {
- // 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))
- {
- 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
- // in the right spot when lib loading.
- this->GetCollisionObject()->setActivationState(ACTIVE_TAG);
- }
- m_cci.m_physicsEnv = physicsEnv;
- }
-}
-
-void CcdPhysicsController::SetCenterOfMassTransform(btTransform& xform)
-{
- btRigidBody* body = GetRigidBody();
- if (body)
- {
- body->setCenterOfMassTransform(xform);
- } else
- {
- //either collision object or soft body?
- if (GetSoftBody())
- {
-
- } else
- {
-
- if (m_object->isStaticOrKinematicObject())
- {
- m_object->setInterpolationWorldTransform(m_object->getWorldTransform());
- } else
- {
- m_object->setInterpolationWorldTransform(xform);
- }
- m_object->setWorldTransform(xform);
- }
- }
-}
-
- // kinematic methods
-void CcdPhysicsController::RelativeTranslate(const MT_Vector3& dlocin,bool local)
-{
- 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;
- }
-
- btVector3 dloc(dlocin.x(), dlocin.y(), dlocin.z());
- btTransform xform = m_object->getWorldTransform();
-
- if (local)
- dloc = xform.getBasis()*dloc;
-
- xform.setOrigin(xform.getOrigin() + dloc);
- SetCenterOfMassTransform(xform);
- }
-
-}
-
-void CcdPhysicsController::RelativeRotate(const MT_Matrix3x3& rotval,bool local)
-{
- 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;
- }
-
- 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;
- GetWorldOrientation(currentOrn);
-
- btTransform xform = m_object->getWorldTransform();
-
- xform.setBasis(xform.getBasis()*(local ?
- drotmat : (currentOrn.inverse() * drotmat * currentOrn)));
-
- SetCenterOfMassTransform(xform);
- }
-}
-
-
-void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat)
-{
- float ori[12];
- m_MotionState->GetWorldOrientation(ori);
- mat.setFromOpenGLSubMatrix(ori);
-}
-
-MT_Matrix3x3 CcdPhysicsController::GetOrientation()
-{
- 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(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)
-{
- if (m_object)
- {
- m_object->activate(true);
- if (m_object->isStaticObject() && !m_cci.m_bSensor)
- {
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
- }
- // not required
- //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal);
- btTransform xform = m_object->getWorldTransform();
- xform.setBasis(orn);
- SetCenterOfMassTransform(xform);
- // not required
- //m_bulletMotionState->setWorldTransform(xform);
- //only once!
- if (!m_softBodyTransformInitialized && GetSoftBody())
- {
- m_softbodyStartTrans.setBasis(orn);
- xform.setOrigin(m_softbodyStartTrans.getOrigin());
- GetSoftBody()->transform(xform);
- m_softBodyTransformInitialized = true;
- }
-
- }
-
-}
-
-void CcdPhysicsController::SetPosition(const MT_Vector3& pos)
-{
- 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, this function is only used to update the physic controller
- //m_MotionState->setWorldPosition(posX,posY,posZ);
- btTransform xform = m_object->getWorldTransform();
- xform.setOrigin(btVector3(pos.x(), pos.y(), pos.z()));
- SetCenterOfMassTransform(xform);
- if (!m_softBodyTransformInitialized)
- m_softbodyStartTrans.setOrigin(xform.getOrigin());
- // not required
- //m_bulletMotionState->setWorldTransform(xform);
- }
-}
-
-void CcdPhysicsController::ForceWorldTransform(const btMatrix3x3& mat, const btVector3& pos)
-{
- if (m_object)
- {
- btTransform& xform = m_object->getWorldTransform();
- xform.setBasis(mat);
- xform.setOrigin(pos);
- }
-}
-
-
-void CcdPhysicsController::ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
-{
-}
-
-void CcdPhysicsController::RefreshCollisions()
-{
- // the object is in an inactive layer so it's useless to update it and can cause problems
- if (!GetPhysicsEnvironment()->IsActiveCcdPhysicsController(this))
- return;
-
- btSoftRigidDynamicsWorld *dw = GetPhysicsEnvironment()->GetDynamicsWorld();
- btBroadphaseProxy *proxy = m_object->getBroadphaseHandle();
- btDispatcher *dispatcher = dw->getDispatcher();
- btOverlappingPairCache *pairCache = dw->getPairCache();
-
- CleanPairCallback cleanPairs(proxy, pairCache, dispatcher);
- pairCache->processAllOverlappingPairs(&cleanPairs, dispatcher);
-
- // Forcibly recreate the physics object
- btBroadphaseProxy* handle = m_object->getBroadphaseHandle();
- GetPhysicsEnvironment()->UpdateCcdPhysicsController(this, GetMass(), m_object->getCollisionFlags(), handle->m_collisionFilterGroup, handle->m_collisionFilterMask);
-}
-
-void CcdPhysicsController::SuspendDynamics(bool ghost)
-{
- btRigidBody *body = GetRigidBody();
- if (body && !m_suspended && !GetConstructionInfo().m_bSensor && GetPhysicsEnvironment()->IsActiveCcdPhysicsController(this))
- {
- btBroadphaseProxy* handle = body->getBroadphaseHandle();
-
- m_savedCollisionFlags = body->getCollisionFlags();
- m_savedMass = GetMass();
- m_savedDyna = m_cci.m_bDyna;
- m_savedCollisionFilterGroup = handle->m_collisionFilterGroup;
- m_savedCollisionFilterMask = handle->m_collisionFilterMask;
- m_suspended = true;
- GetPhysicsEnvironment()->UpdateCcdPhysicsController(this,
- 0.0f,
- btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)),
- btBroadphaseProxy::StaticFilter,
- btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
- m_cci.m_bDyna = false;
- }
-}
-
-void CcdPhysicsController::RestoreDynamics()
-{
- btRigidBody *body = GetRigidBody();
- if (body && m_suspended && GetPhysicsEnvironment()->IsActiveCcdPhysicsController(this))
- {
- // 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_cci.m_bDyna = m_savedDyna;
- m_suspended = false;
- }
-}
-
-void CcdPhysicsController::GetPosition(MT_Vector3& pos) const
-{
- const btTransform& xform = m_object->getWorldTransform();
- pos[0] = xform.getOrigin().x();
- pos[1] = xform.getOrigin().y();
- pos[2] = xform.getOrigin().z();
-}
-
-void CcdPhysicsController::SetScaling(const MT_Vector3& scale)
-{
- 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(scale.x(),scale.y(),scale.z());
-
- if (m_object && m_object->getCollisionShape())
- {
- m_object->activate(true); // without this, sleeping objects scale wont be applied in bullet if python changes the scale - Campbell.
- m_object->getCollisionShape()->setLocalScaling(m_cci.m_scaling);
-
- //printf("no inertia recalc for fixed objects with mass=0\n");
- btRigidBody* body = GetRigidBody();
- if (body && m_cci.m_mass)
- {
- body->getCollisionShape()->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
- body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
- }
-
- }
- }
-}
-
-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)
- {
- btBroadphaseProxy* handle = body->getBroadphaseHandle();
- GetPhysicsEnvironment()->UpdateCcdPhysicsController(this,
- newmass,
- body->getCollisionFlags(),
- handle->m_collisionFilterGroup,
- handle->m_collisionFilterMask);
- }
-}
-
- // physics methods
-void CcdPhysicsController::ApplyTorque(const MT_Vector3& torquein,bool local)
-{
- btVector3 torque(torquein.x(),torquein.y(),torquein.z());
- btTransform xform = m_object->getWorldTransform();
-
-
- if (m_object && torque.length2() > (SIMD_EPSILON*SIMD_EPSILON))
- {
- btRigidBody* body = GetRigidBody();
- m_object->activate();
- if (m_object->isStaticObject())
- {
- if (!m_cci.m_bSensor)
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
- return;
- }
- if (local)
- {
- torque = xform.getBasis()*torque;
- }
- if (body)
- {
- if (m_cci.m_bRigid)
- {
- body->applyTorque(torque);
- }
- else
- {
- //workaround for incompatibility between 'DYNAMIC' game object, and angular factor
- //a DYNAMIC object has some inconsistency: it has no angular effect due to collisions, but still has torque
- const btVector3 angFac = body->getAngularFactor();
- btVector3 tmpFac(1,1,1);
- body->setAngularFactor(tmpFac);
- body->applyTorque(torque);
- body->setAngularFactor(angFac);
- }
- }
- }
-}
-
-void CcdPhysicsController::ApplyForce(const MT_Vector3& forcein,bool local)
-{
- btVector3 force(forcein.x(),forcein.y(),forcein.z());
-
-
- if (m_object && force.length2() > (SIMD_EPSILON*SIMD_EPSILON))
- {
- m_object->activate();
- if (m_object->isStaticObject())
- {
- if (!m_cci.m_bSensor)
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
- return;
- }
- btTransform xform = m_object->getWorldTransform();
-
- if (local)
- {
- force = xform.getBasis()*force;
- }
- btRigidBody* body = GetRigidBody();
- if (body)
- body->applyCentralForce(force);
- btSoftBody* soft = GetSoftBody();
- if (soft)
- {
- // the force is applied on each node, must reduce it in the same extend
- if (soft->m_nodes.size() > 0)
- force /= soft->m_nodes.size();
- soft->addForce(force);
- }
- }
-}
-void CcdPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
-{
- btVector3 angvel(ang_vel.x(),ang_vel.y(),ang_vel.z());
-
- /* Refuse tiny tiny velocities, as they might cause instabilities. */
- float vel_squared = angvel.length2();
- if (vel_squared > 0 && vel_squared <= (SIMD_EPSILON*SIMD_EPSILON))
- angvel = btVector3(0, 0, 0);
-
- 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);
- return;
- }
- btTransform xform = m_object->getWorldTransform();
- if (local)
- {
- angvel = xform.getBasis()*angvel;
- }
- btRigidBody* body = GetRigidBody();
- if (body)
- body->setAngularVelocity(angvel);
- }
-
-}
-void CcdPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
-{
- btVector3 linVel(lin_vel.x(),lin_vel.y(),lin_vel.z());
-
- /* Refuse tiny tiny velocities, as they might cause instabilities. */
- float vel_squared = linVel.length2();
- if (vel_squared > 0 && vel_squared <= (SIMD_EPSILON*SIMD_EPSILON))
- linVel = btVector3(0, 0, 0);
-
- 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);
- return;
- }
-
- btSoftBody* soft = GetSoftBody();
- if (soft)
- {
- if (local)
- {
- linVel = m_softbodyStartTrans.getBasis()*linVel;
- }
- soft->setVelocity(linVel);
- } else
- {
- btTransform xform = m_object->getWorldTransform();
- if (local)
- {
- linVel = xform.getBasis()*linVel;
- }
- btRigidBody* body = GetRigidBody();
- if (body)
- body->setLinearVelocity(linVel);
- }
- }
-}
-void CcdPhysicsController::ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein, bool local)
-{
- btVector3 pos;
- btVector3 impulse(impulsein.x(), impulsein.y(), impulsein.z());
-
- if (m_object && impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON))
- {
- m_object->activate();
- if (m_object->isStaticObject())
- {
- if (!m_cci.m_bSensor)
- m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
- return;
- }
-
- btTransform xform = m_object->getWorldTransform();
-
- if (local)
- {
- pos = btVector3(attach.x(), attach.y(), attach.z());
- impulse = xform.getBasis() * impulse;
- }
- else {
- /* If the point of impulse application is not equal to the object position
- * then an angular momentum is generated in the object*/
- pos = btVector3(attach.x()-xform.getOrigin().x(), attach.y()-xform.getOrigin().y(), attach.z()-xform.getOrigin().z());
- }
-
- btRigidBody* body = GetRigidBody();
- if (body)
- body->applyImpulse(impulse,pos);
-
- }
-
-}
-
-void CcdPhysicsController::Jump()
-{
- if (m_object && m_characterController)
- m_characterController->jump();
-}
-
-void CcdPhysicsController::SetActive(bool active)
-{
-}
-
-float CcdPhysicsController::GetLinearDamping() const
-{
- const btRigidBody* body = GetRigidBody();
- if (body)
- return body->getLinearDamping();
- return 0;
-}
-
-float CcdPhysicsController::GetAngularDamping() const
-{
- const btRigidBody* body = GetRigidBody();
- if (body)
- return body->getAngularDamping();
- return 0;
-}
-
-void CcdPhysicsController::SetLinearDamping(float damping)
-{
- SetDamping(damping, GetAngularDamping());
-}
-
-void CcdPhysicsController::SetAngularDamping(float damping)
-{
- SetDamping(GetLinearDamping(), damping);
-}
-
-void CcdPhysicsController::SetDamping(float linear, float angular)
-{
- btRigidBody* body = GetRigidBody();
- if (!body) return;
-
- body->setDamping(linear, angular);
-}
-
-
- // reading out information from physics
-MT_Vector3 CcdPhysicsController::GetLinearVelocity()
-{
- btRigidBody* body = GetRigidBody();
- if (body)
- {
- const btVector3& linvel = body->getLinearVelocity();
- return MT_Vector3(linvel.x(), linvel.y(), linvel.z());
- }
-
- return MT_Vector3(0.f, 0.f, 0.f);
-}
-
-MT_Vector3 CcdPhysicsController::GetAngularVelocity()
-{
- btRigidBody* body = GetRigidBody();
- if (body)
- {
- const btVector3& angvel= body->getAngularVelocity();
- return MT_Vector3(angvel.x(), angvel.y(), angvel.z());
- }
-
- return MT_Vector3(0.f, 0.f, 0.f);
-}
-
-MT_Vector3 CcdPhysicsController::GetVelocity(const MT_Point3 &posin)
-{
- btVector3 pos(posin.x(), posin.y(), posin.z());
- btRigidBody* body = GetRigidBody();
- if (body)
- {
- btVector3 linvel = body->getVelocityInLocalPoint(pos);
- return MT_Vector3(linvel.x(), linvel.y(), linvel.z());
- }
-
- return MT_Vector3(0.f, 0.f, 0.f);
-}
-
-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)
-{
- btRigidBody* body = GetRigidBody();
- if (body)
- {
- m_cci.m_bRigid = rigid;
- if (!rigid) {
- body->setAngularFactor(0.f);
- body->setAngularVelocity(btVector3(0.f, 0.f, 0.f));
- }
- else
- body->setAngularFactor(m_cci.m_angularFactor);
- }
-}
-
- // clientinfo for raycasts for example
-void* CcdPhysicsController::GetNewClientInfo()
-{
- return m_newClientInfo;
-}
-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;
- }
-}
-
-
-void CcdPhysicsController::UpdateDeactivation(float timeStep)
-{
- btRigidBody* body = GetRigidBody();
- if (body)
- {
- body->updateDeactivation( timeStep);
- }
-}
-
-bool CcdPhysicsController::WantsSleeping()
-{
- btRigidBody* body = GetRigidBody();
- if (body)
- {
- return body->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)
- 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.0f/rootScale[0];
- rootScale[1] = 1.0f/rootScale[1];
- rootScale[2] = 1.0f/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()->RemoveCcdPhysicsController(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()->AddCcdPhysicsController(childCtrl);
-}
-
-PHY_IPhysicsController* CcdPhysicsController::GetReplica()
-{
- CcdPhysicsController* replica = new CcdPhysicsController(*this);
- return replica;
-}
-
-// 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()
- CcdConstructionInfo cinfo = m_cci;
- if (m_shapeInfo)
- {
- // This situation does not normally happen
- cinfo.m_collisionShape = m_shapeInfo->CreateBulletShape(m_cci.m_margin, m_cci.m_bGimpact, !m_cci.m_bSoft);
- }
- else if (m_collisionShape)
- {
- switch (m_collisionShape->getShapeType())
- {
- case SPHERE_SHAPE_PROXYTYPE:
- {
- btSphereShape* orgShape = (btSphereShape*)m_collisionShape;
- cinfo.m_collisionShape = new btSphereShape(*orgShape);
- break;
- }
-
- case CONE_SHAPE_PROXYTYPE:
- {
- btConeShape* orgShape = (btConeShape*)m_collisionShape;
- cinfo.m_collisionShape = new btConeShape(*orgShape);
- break;
- }
-
- default:
- {
- return 0;
- }
- }
- }
-
- cinfo.m_MotionState = new DefaultMotionState();
- cinfo.m_shapeInfo = m_shapeInfo;
-
- CcdPhysicsController* replica = new CcdPhysicsController(cinfo);
- return replica;
-}
-
-/* Refresh the physics object from either an object or a mesh.
- * from_gameobj and from_meshobj can be NULL
- *
- * when setting the mesh, the following vars get priority
- * 1) from_meshobj - creates the phys mesh from RAS_MeshObject
- * 2) from_gameobj - creates the phys mesh from the DerivedMesh where possible, else the RAS_MeshObject
- * 3) this - update the phys mesh from DerivedMesh or RAS_MeshObject
- *
- * Most of the logic behind this is in m_shapeInfo->UpdateMesh(...)
- */
-bool CcdPhysicsController::ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject *from_meshobj)
-{
- if (m_shapeInfo->m_shapeType != PHY_SHAPE_MESH)
- return false;
-
- if (!from_gameobj && !from_meshobj)
- from_gameobj = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)GetNewClientInfo());
-
- /* updates the arrays used for making the new bullet mesh */
- m_shapeInfo->UpdateMesh(from_gameobj, from_meshobj);
-
- /* create the new bullet mesh */
- GetPhysicsEnvironment()->UpdateCcdPhysicsControllerShape(m_shapeInfo);
-
- return true;
-}
-
-void CcdPhysicsController::ReplicateConstraints(KX_GameObject *replica, std::vector<KX_GameObject*> constobj)
-{
- if (replica->GetConstraints().size() == 0 || !replica->GetPhysicsController())
- return;
-
- PHY_IPhysicsEnvironment *physEnv = GetPhysicsEnvironment();
-
- vector<bRigidBodyJointConstraint*> constraints = replica->GetConstraints();
- vector<bRigidBodyJointConstraint*>::iterator consit;
-
- /* Object could have some constraints, iterate over all of theme to ensure that every constraint is recreated. */
- for (consit = constraints.begin(); consit != constraints.end(); ++consit) {
- /* Try to find the constraint targets in the list of group objects. */
- bRigidBodyJointConstraint *dat = (*consit);
- vector<KX_GameObject*>::iterator memit;
- for (memit = constobj.begin(); memit != constobj.end(); ++memit) {
- KX_GameObject *member = (*memit);
- /* If the group member is the actual target for the constraint. */
- if (dat->tar->id.name + 2 == member->GetName() && member->GetPhysicsController())
- physEnv->SetupObjectConstraints(replica, member, dat);
- }
- }
-
-}
-
-///////////////////////////////////////////////////////////
-///A small utility class, DefaultMotionState
-///
-///////////////////////////////////////////////////////////
-
-DefaultMotionState::DefaultMotionState()
-{
- m_worldTransform.setIdentity();
- m_localScaling.setValue(1.f,1.f,1.f);
-}
-
-
-DefaultMotionState::~DefaultMotionState()
-{
-
-}
-
-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)
-{
- scaleX = m_localScaling.getX();
- scaleY = m_localScaling.getY();
- scaleZ = m_localScaling.getZ();
-}
-
-void DefaultMotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
-{
- btQuaternion quat = m_worldTransform.getRotation();
- quatIma0 = quat.x();
- quatIma1 = quat.y();
- quatIma2 = quat.z();
- quatReal = quat[3];
-}
-
-void DefaultMotionState::GetWorldOrientation(float* ori)
-{
- m_worldTransform.getBasis().getOpenGLSubMatrix(ori);
-}
-
-void DefaultMotionState::SetWorldOrientation(const float* ori)
-{
- m_worldTransform.getBasis().setFromOpenGLSubMatrix(ori);
-}
-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)
-{
- btQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal);
- m_worldTransform.setRotation( orn );
-}
-
-void DefaultMotionState::CalculateWorldTransformations()
-{
-
-}
-
-// Shape constructor
-std::map<RAS_MeshObject*, CcdShapeConstructionInfo*> CcdShapeConstructionInfo::m_meshShapeMap;
-
-CcdShapeConstructionInfo* CcdShapeConstructionInfo::FindMesh(RAS_MeshObject* mesh, struct DerivedMesh* dm, bool polytope)
-{
- if (polytope || dm)
- // not yet supported
- return NULL;
-
- std::map<RAS_MeshObject*,CcdShapeConstructionInfo*>::const_iterator mit = m_meshShapeMap.find(mesh);
- if (mit != m_meshShapeMap.end())
- return mit->second;
- return NULL;
-}
-
-bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh *dm, bool polytope)
-{
- int numpolys, numverts;
-
- // assume no shape information
- // no support for dynamic change of shape yet
- assert(IsUnused());
- m_shapeType = PHY_SHAPE_NONE;
- m_meshObject = NULL;
- bool free_dm = false;
-
- // No mesh object or mesh has no polys
- if (!meshobj || !meshobj->HasColliderPolygon()) {
- m_vertexArray.clear();
- m_polygonIndexArray.clear();
- m_triFaceArray.clear();
- m_triFaceUVcoArray.clear();
- return false;
- }
-
- if (!dm) {
- free_dm = true;
- dm = CDDM_from_mesh(meshobj->GetMesh());
- }
-
- // Some meshes with modifiers returns 0 polys, call DM_ensure_tessface avoid this.
- DM_ensure_tessface(dm);
-
- MVert *mvert = dm->getVertArray(dm);
- MFace *mface = dm->getTessFaceArray(dm);
- numpolys = dm->getNumTessFaces(dm);
- numverts = dm->getNumVerts(dm);
- MTFace *tface = (MTFace *)dm->getTessFaceDataArray(dm, CD_MTFACE);
-
- /* double lookup */
- const int *index_mf_to_mpoly = (const int *)dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
- const int *index_mp_to_orig = (const int *)dm->getPolyDataArray(dm, CD_ORIGINDEX);
- if (!index_mf_to_mpoly) {
- index_mp_to_orig = NULL;
- }
-
- m_shapeType = (polytope) ? PHY_SHAPE_POLYTOPE : PHY_SHAPE_MESH;
-
- /* Convert blender geometry into bullet mesh, need these vars for mapping */
- std::vector<bool> vert_tag_array(numverts, false);
- unsigned int tot_bt_verts = 0;
-
- if (polytope) {
- // Tag verts we're using
- for (int p2 = 0; p2 < numpolys; p2++) {
- MFace *mf = &mface[p2];
- const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
- RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL;
-
- // only add polygons that have the collision flag set
- if (poly && poly->IsCollider()) {
- if (!vert_tag_array[mf->v1]) {
- vert_tag_array[mf->v1] = true;
- tot_bt_verts++;
- }
- if (!vert_tag_array[mf->v2]) {
- vert_tag_array[mf->v2] = true;
- tot_bt_verts++;
- }
- if (!vert_tag_array[mf->v3]) {
- vert_tag_array[mf->v3] = true;
- tot_bt_verts++;
- }
- if (mf->v4 && !vert_tag_array[mf->v4]) {
- vert_tag_array[mf->v4] = true;
- tot_bt_verts++;
- }
- }
- }
-
- /* Can happen with ngons */
- if (!tot_bt_verts) {
- goto cleanup_empty_mesh;
- }
-
- m_vertexArray.resize(tot_bt_verts * 3);
-
- btScalar *bt = &m_vertexArray[0];
-
- for (int p2 = 0; p2 < numpolys; p2++) {
- MFace *mf = &mface[p2];
- const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
- RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL;
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider()) {
- if (vert_tag_array[mf->v1]) {
- const float *vtx = mvert[mf->v1].co;
- vert_tag_array[mf->v1] = false;
- *bt++ = vtx[0];
- *bt++ = vtx[1];
- *bt++ = vtx[2];
- }
- if (vert_tag_array[mf->v2]) {
- const float *vtx = mvert[mf->v2].co;
- vert_tag_array[mf->v2] = false;
- *bt++ = vtx[0];
- *bt++ = vtx[1];
- *bt++ = vtx[2];
- }
- if (vert_tag_array[mf->v3]) {
- const float *vtx = mvert[mf->v3].co;
- vert_tag_array[mf->v3] = false;
- *bt++ = vtx[0];
- *bt++ = vtx[1];
- *bt++ = vtx[2];
- }
- if (mf->v4 && vert_tag_array[mf->v4]) {
- const float *vtx = mvert[mf->v4].co;
- vert_tag_array[mf->v4] = false;
- *bt++ = vtx[0];
- *bt++ = vtx[1];
- *bt++ = vtx[2];
- }
- }
- }
- }
- else {
- unsigned int tot_bt_tris = 0;
- std::vector<int> vert_remap_array(numverts, 0);
-
- // Tag verts we're using
- for (int p2 = 0; p2 < numpolys; p2++) {
- MFace *mf = &mface[p2];
- const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
- RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL;
-
- // only add polygons that have the collision flag set
- if (poly && poly->IsCollider()) {
- if (!vert_tag_array[mf->v1]) {
- vert_tag_array[mf->v1] = true;
- vert_remap_array[mf->v1] = tot_bt_verts;
- tot_bt_verts++;
- }
- if (!vert_tag_array[mf->v2]) {
- vert_tag_array[mf->v2] = true;
- vert_remap_array[mf->v2] = tot_bt_verts;
- tot_bt_verts++;
- }
- if (!vert_tag_array[mf->v3]) {
- vert_tag_array[mf->v3] = true;
- vert_remap_array[mf->v3] = tot_bt_verts;
- tot_bt_verts++;
- }
- if (mf->v4 && !vert_tag_array[mf->v4]) {
- vert_tag_array[mf->v4] = true;
- vert_remap_array[mf->v4] = tot_bt_verts;
- tot_bt_verts++;
- }
- tot_bt_tris += (mf->v4 ? 2 : 1); /* a quad or a tri */
- }
- }
-
- /* Can happen with ngons */
- if (!tot_bt_verts) {
- goto cleanup_empty_mesh;
- }
-
- m_vertexArray.resize(tot_bt_verts * 3);
- m_polygonIndexArray.resize(tot_bt_tris);
- m_triFaceArray.resize(tot_bt_tris * 3);
- btScalar *bt = &m_vertexArray[0];
- int *poly_index_pt = &m_polygonIndexArray[0];
- int *tri_pt = &m_triFaceArray[0];
-
- UVco *uv_pt = NULL;
- if (tface) {
- m_triFaceUVcoArray.resize(tot_bt_tris * 3);
- uv_pt = &m_triFaceUVcoArray[0];
- }
- else
- m_triFaceUVcoArray.clear();
-
- for (int p2 = 0; p2 < numpolys; p2++) {
- MFace *mf = &mface[p2];
- MTFace *tf = (tface) ? &tface[p2] : NULL;
- const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
- RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL;
-
- // only add polygons that have the collisionflag set
- if (poly && poly->IsCollider()) {
- MVert *v1 = &mvert[mf->v1];
- MVert *v2 = &mvert[mf->v2];
- MVert *v3 = &mvert[mf->v3];
-
- // the face indices
- tri_pt[0] = vert_remap_array[mf->v1];
- tri_pt[1] = vert_remap_array[mf->v2];
- tri_pt[2] = vert_remap_array[mf->v3];
- tri_pt = tri_pt + 3;
- if (tf) {
- uv_pt[0].uv[0] = tf->uv[0][0];
- uv_pt[0].uv[1] = tf->uv[0][1];
- uv_pt[1].uv[0] = tf->uv[1][0];
- uv_pt[1].uv[1] = tf->uv[1][1];
- uv_pt[2].uv[0] = tf->uv[2][0];
- uv_pt[2].uv[1] = tf->uv[2][1];
- uv_pt += 3;
- }
-
- // m_polygonIndexArray
- *poly_index_pt = origi;
- poly_index_pt++;
-
- // the vertex location
- if (vert_tag_array[mf->v1]) { /* *** v1 *** */
- vert_tag_array[mf->v1] = false;
- *bt++ = v1->co[0];
- *bt++ = v1->co[1];
- *bt++ = v1->co[2];
- }
- if (vert_tag_array[mf->v2]) { /* *** v2 *** */
- vert_tag_array[mf->v2] = false;
- *bt++ = v2->co[0];
- *bt++ = v2->co[1];
- *bt++ = v2->co[2];
- }
- if (vert_tag_array[mf->v3]) { /* *** v3 *** */
- vert_tag_array[mf->v3] = false;
- *bt++ = v3->co[0];
- *bt++ = v3->co[1];
- *bt++ = v3->co[2];
- }
-
- if (mf->v4)
- {
- MVert *v4 = &mvert[mf->v4];
-
- tri_pt[0] = vert_remap_array[mf->v1];
- tri_pt[1] = vert_remap_array[mf->v3];
- tri_pt[2] = vert_remap_array[mf->v4];
- tri_pt = tri_pt + 3;
- if (tf)
- {
- uv_pt[0].uv[0] = tf->uv[0][0];
- uv_pt[0].uv[1] = tf->uv[0][1];
- uv_pt[1].uv[0] = tf->uv[2][0];
- uv_pt[1].uv[1] = tf->uv[2][1];
- uv_pt[2].uv[0] = tf->uv[3][0];
- uv_pt[2].uv[1] = tf->uv[3][1];
- uv_pt += 3;
- }
-
- // m_polygonIndexArray
- *poly_index_pt = origi;
- poly_index_pt++;
-
- // the vertex location
- if (vert_tag_array[mf->v4]) { /* *** v4 *** */
- vert_tag_array[mf->v4] = false;
- *bt++ = v4->co[0];
- *bt++ = v4->co[1];
- *bt++ = v4->co[2];
- }
- }
- }
- }
-
-
- /* If this ever gets confusing, print out an OBJ file for debugging */
-#if 0
- printf("# vert count %d\n", m_vertexArray.size());
- for (i = 0; i < m_vertexArray.size(); i += 1) {
- printf("v %.6f %.6f %.6f\n", m_vertexArray[i].x(), m_vertexArray[i].y(), m_vertexArray[i].z());
- }
-
- printf("# face count %d\n", m_triFaceArray.size());
- for (i = 0; i < m_triFaceArray.size(); i += 3) {
- printf("f %d %d %d\n", m_triFaceArray[i] + 1, m_triFaceArray[i + 1] + 1, m_triFaceArray[i + 2] + 1);
- }
-#endif
-
- }
-
-#if 0
- if (validpolys == false)
- {
- // should not happen
- m_shapeType = PHY_SHAPE_NONE;
- return false;
- }
-#endif
-
- m_meshObject = meshobj;
- if (free_dm) {
- dm->release(dm);
- dm = NULL;
- }
-
- // sharing only on static mesh at present, if you change that, you must also change in FindMesh
- if (!polytope && !dm) {
- // triangle shape can be shared, store the mesh object in the map
- m_meshShapeMap.insert(std::pair<RAS_MeshObject *, CcdShapeConstructionInfo *>(meshobj, this));
- }
- return true;
-
-
-cleanup_empty_mesh:
- m_shapeType = PHY_SHAPE_NONE;
- m_meshObject = NULL;
- m_vertexArray.clear();
- m_polygonIndexArray.clear();
- m_triFaceArray.clear();
- m_triFaceUVcoArray.clear();
- if (free_dm) {
- dm->release(dm);
- }
- return false;
-}
-
-#include <cstdio>
-
-/* Updates the arrays used by CreateBulletShape(),
- * take care that recalcLocalAabb() runs after CreateBulletShape is called.
- * */
-bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject *gameobj, class RAS_MeshObject *meshobj)
-{
- int numpolys;
- int numverts;
-
- unsigned int tot_bt_tris = 0;
- unsigned int tot_bt_verts = 0;
-
- int i, j;
- int v_orig;
-
- /* Use for looping over verts in a face as a try or 2 tris */
- const int quad_verts[7] = {0, 1, 2, 0, 2, 3, -1};
- const int tri_verts[4] = {0, 1, 2, -1};
- const int *fv_pt;
-
- if (!gameobj && !meshobj)
- return false;
-
- if (m_shapeType != PHY_SHAPE_MESH)
- return false;
-
- RAS_Deformer *deformer = gameobj ? gameobj->GetDeformer() : NULL;
- DerivedMesh *dm = NULL;
-
- if (deformer)
- dm = deformer->GetPhysicsMesh();
-
- /* get the mesh from the object if not defined */
- if (!meshobj) {
- /* modifier mesh */
- if (dm)
- meshobj = deformer->GetRasMesh();
-
- /* game object first mesh */
- if (!meshobj) {
- if (gameobj->GetMeshCount() > 0) {
- meshobj = gameobj->GetMesh(0);
- }
- }
- }
-
- if (dm && deformer->GetRasMesh() == meshobj) {
- /*
- * Derived Mesh Update
- *
- * */
-
- MVert *mvert = dm->getVertArray(dm);
- MFace *mface = dm->getTessFaceArray(dm);
- numpolys = dm->getNumTessFaces(dm);
- numverts = dm->getNumVerts(dm);
-
- /* double lookup */
- const int *index_mf_to_mpoly = (const int *)dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
- const int *index_mp_to_orig = (const int *)dm->getPolyDataArray(dm, CD_ORIGINDEX);
- if (!index_mf_to_mpoly) {
- index_mp_to_orig = NULL;
- }
-
- MFace *mf;
- MVert *mv;
-
- if (CustomData_has_layer(&dm->faceData, CD_MTFACE)) {
- MTFace *tface = (MTFace *)dm->getTessFaceDataArray(dm, CD_MTFACE);
- MTFace *tf;
-
- std::vector<bool> vert_tag_array(numverts, false);
- std::vector<int> vert_remap_array(numverts, 0);
-
- for (mf = mface, tf = tface, i = 0; i < numpolys; mf++, tf++, i++) {
- // 2.8x TODO: use GEMAT_NOPHYSICS.
- // if (tf->mode & TF_DYNAMIC)
- {
- int flen;
-
- if (mf->v4) {
- tot_bt_tris += 2;
- flen = 4;
- }
- else {
- tot_bt_tris++;
- flen = 3;
- }
-
- for (j = 0; j < flen; j++) {
- v_orig = (*(&mf->v1 + j));
-
- if (!vert_tag_array[v_orig]) {
- vert_tag_array[v_orig] = true;
- vert_remap_array[v_orig] = tot_bt_verts;
- tot_bt_verts++;
- }
- }
- }
- }
-
- m_vertexArray.resize(tot_bt_verts * 3);
- btScalar *bt = &m_vertexArray[0];
-
- m_triFaceArray.resize(tot_bt_tris * 3);
- int *tri_pt = &m_triFaceArray[0];
-
- m_triFaceUVcoArray.resize(tot_bt_tris * 3);
- UVco *uv_pt = &m_triFaceUVcoArray[0];
-
- m_polygonIndexArray.resize(tot_bt_tris);
- int *poly_index_pt = &m_polygonIndexArray[0];
-
- for (mf = mface, tf = tface, i = 0; i < numpolys; mf++, tf++, i++) {
- // 2.8x TODO: use GEMAT_NOPHYSICS.
- // if (tf->mode & TF_DYNAMIC)
- {
- int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, i) : i;
-
- if (mf->v4) {
- fv_pt = quad_verts;
- *poly_index_pt++ = origi;
- *poly_index_pt++ = origi;
- }
- else {
- fv_pt = tri_verts;
- *poly_index_pt++ = origi;
- }
-
- for (; *fv_pt > -1; fv_pt++) {
- v_orig = (*(&mf->v1 + (*fv_pt)));
-
- if (vert_tag_array[v_orig])
- {
- mv = mvert + v_orig;
- *bt++ = mv->co[0];
- *bt++ = mv->co[1];
- *bt++ = mv->co[2];
-
- vert_tag_array[v_orig] = false;
- }
- *tri_pt++ = vert_remap_array[v_orig];
- uv_pt->uv[0] = tf->uv[*fv_pt][0];
- uv_pt->uv[1] = tf->uv[*fv_pt][1];
- uv_pt++;
- }
- }
- }
- }
- else {
- /* no need for a vertex mapping. simple/fast */
-
- tot_bt_verts = numverts;
-
- for (mf = mface, i = 0; i < numpolys; mf++, i++) {
- tot_bt_tris += (mf->v4 ? 2 : 1);
- }
-
- m_vertexArray.resize(tot_bt_verts * 3);
- btScalar *bt = &m_vertexArray[0];
-
- m_triFaceArray.resize(tot_bt_tris * 3);
- int *tri_pt = &m_triFaceArray[0];
-
- m_polygonIndexArray.resize(tot_bt_tris);
- int *poly_index_pt = &m_polygonIndexArray[0];
-
- m_triFaceUVcoArray.clear();
-
- for (mv = mvert, i = 0; i < numverts; mv++, i++) {
- *bt++ = mv->co[0]; *bt++ = mv->co[1]; *bt++ = mv->co[2];
- }
-
- for (mf = mface, i = 0; i < numpolys; mf++, i++) {
- int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, i) : i;
-
- if (mf->v4) {
- fv_pt = quad_verts;
- *poly_index_pt++ = origi;
- *poly_index_pt++ = origi;
- }
- else {
- fv_pt = tri_verts;
- *poly_index_pt++ = origi;
- }
-
- for (; *fv_pt > -1; fv_pt++)
- *tri_pt++ = (*(&mf->v1 + (*fv_pt)));
- }
- }
- }
- else { /*
- * RAS Mesh Update
- *
- * */
- /* Note!, gameobj can be NULL here */
-
- /* transverts are only used for deformed RAS_Meshes, the RAS_TexVert data
- * is too hard to get at, see below for details */
- float(*transverts)[3] = NULL;
- int transverts_tot = 0; /* with deformed meshes - should always be greater than the max orginal index, or we get crashes */
-
- if (deformer) {
- /* map locations from the deformed array
- *
- * Could call deformer->Update(); but rely on redraw updating.
- * */
- transverts = deformer->GetTransVerts(&transverts_tot);
- }
-
- // Tag verts we're using
- numpolys = meshobj->NumPolygons();
- numverts = meshobj->m_sharedvertex_map.size();
- const float *xyz;
-
-
- std::vector<bool> vert_tag_array(numverts, false);
- std::vector<int> vert_remap_array(numverts, 0);
-
- for (int p = 0; p < numpolys; p++) {
- RAS_Polygon *poly = meshobj->GetPolygon(p);
- if (poly->IsCollider()) {
- for (i = 0; i < poly->VertexCount(); i++) {
- v_orig = poly->GetVertex(i)->getOrigIndex();
- if (!vert_tag_array[v_orig]) {
- vert_tag_array[v_orig] = true;
- vert_remap_array[v_orig] = tot_bt_verts;
- tot_bt_verts++;
- }
- }
- tot_bt_tris += (poly->VertexCount() == 4 ? 2 : 1);
- }
- }
-
- // This case happens when none of the polys are colliders
- if (tot_bt_tris == 0 || tot_bt_verts == 0)
- return false;
-
- m_vertexArray.resize(tot_bt_verts * 3);
- btScalar *bt = &m_vertexArray[0];
-
- m_triFaceArray.resize(tot_bt_tris * 3);
- int *tri_pt = &m_triFaceArray[0];
-
- /* cant be used for anything useful in this case, since we don't rely on the original mesh
- * will just be an array like pythons range(tot_bt_tris) */
- m_polygonIndexArray.resize(tot_bt_tris);
-
-
- int p = 0;
- int t = 0;
- while (t < tot_bt_tris) {
- RAS_Polygon *poly = meshobj->GetPolygon(p);
-
- if (poly->IsCollider()) {
- /* quad or tri loop */
- fv_pt = (poly->VertexCount() == 3 ? tri_verts : quad_verts);
-
- for (; *fv_pt > -1; fv_pt++) {
- v_orig = poly->GetVertex(*fv_pt)->getOrigIndex();
- if (vert_tag_array[v_orig]) {
- if (transverts) {
- /* deformed mesh, using RAS_TexVert locations would be too troublesome
- * because they are use the gameob as a hash in the material slot */
- *bt++ = transverts[v_orig][0];
- *bt++ = transverts[v_orig][1];
- *bt++ = transverts[v_orig][2];
- }
- else {
- /* static mesh python may have modified */
- xyz = meshobj->GetVertexLocation(v_orig);
- *bt++ = xyz[0];
- *bt++ = xyz[1];
- *bt++ = xyz[2];
- }
- vert_tag_array[v_orig] = false;
- }
- *tri_pt++ = vert_remap_array[v_orig];
- }
- }
- // first triangle
- m_polygonIndexArray[t] = p;
-
- // if the poly is a quad we transform it in two triangles
- if (poly->VertexCount() == 4) {
- t++;
- // second triangle
- m_polygonIndexArray[t] = p;
- }
- t++;
- p++;
- }
- }
-
-#if 0
- /* needs #include <cstdio> */
- printf("# vert count %d\n", m_vertexArray.size());
- for (int i = 0; i < m_vertexArray.size(); i += 3) {
- printf("v %.6f %.6f %.6f\n", m_vertexArray[i], m_vertexArray[i + 1], m_vertexArray[i + 2]);
- }
-
- printf("# face count %d\n", m_triFaceArray.size());
- for (int i = 0; i < m_triFaceArray.size(); i += 3) {
- printf("f %d %d %d\n", m_triFaceArray[i] + 1, m_triFaceArray[i + 1] + 1, m_triFaceArray[i + 2] + 1);
- }
-#endif
-
- /* force recreation of the m_triangleIndexVertexArray.
- * If this has multiple users we cant delete */
- if (m_triangleIndexVertexArray) {
- m_forceReInstance = true;
- }
-
- // Make sure to also replace the mesh in the shape map! Otherwise we leave dangling references when we free.
- // Note, this whole business could cause issues with shared meshes. If we update one mesh, do we replace
- // them all?
- std::map<RAS_MeshObject *, CcdShapeConstructionInfo *>::iterator mit = m_meshShapeMap.find(m_meshObject);
- if (mit != m_meshShapeMap.end()) {
- m_meshShapeMap.erase(mit);
- m_meshShapeMap[meshobj] = this;
- }
-
- m_meshObject = meshobj;
-
- if (dm) {
- dm->needsFree = 1;
- dm->release(dm);
- }
- return true;
-}
-
-bool CcdShapeConstructionInfo::SetProxy(CcdShapeConstructionInfo* shapeInfo)
-{
- if (shapeInfo == NULL)
- return false;
- // no support for dynamic change
- assert(IsUnused());
- m_shapeType = PHY_SHAPE_PROXY;
- m_shapeProxy = shapeInfo;
- return true;
-}
-
-btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin, bool useGimpact, bool useBvh)
-{
- btCollisionShape* collisionShape = 0;
- btCompoundShape* compoundShape = 0;
-
- if (m_shapeType == PHY_SHAPE_PROXY && m_shapeProxy != NULL)
- return m_shapeProxy->CreateBulletShape(margin, useGimpact, useBvh);
-
- switch (m_shapeType)
- {
- default:
- break;
-
- case PHY_SHAPE_BOX:
- collisionShape = new btBoxShape(m_halfExtend);
- collisionShape->setMargin(margin);
- break;
-
- case PHY_SHAPE_SPHERE:
- collisionShape = new btSphereShape(m_radius);
- collisionShape->setMargin(margin);
- break;
-
- case PHY_SHAPE_CYLINDER:
- collisionShape = new btCylinderShapeZ(m_halfExtend);
- collisionShape->setMargin(margin);
- break;
-
- case PHY_SHAPE_CONE:
- collisionShape = new btConeShapeZ(m_radius, m_height);
- collisionShape->setMargin(margin);
- break;
-
- case PHY_SHAPE_POLYTOPE:
- collisionShape = new btConvexHullShape(&m_vertexArray[0], m_vertexArray.size()/3, 3*sizeof(btScalar));
- collisionShape->setMargin(margin);
- break;
-
- case PHY_SHAPE_CAPSULE:
- collisionShape = new btCapsuleShapeZ(m_radius, m_height);
- collisionShape->setMargin(margin);
- break;
-
- case PHY_SHAPE_MESH:
- // Let's use the latest btScaledBvhTriangleMeshShape: it allows true sharing of
- // triangle mesh information between duplicates => drastic performance increase when
- // duplicating complex mesh objects.
- // BUT it causes a small performance decrease when sharing is not required:
- // 9 multiplications/additions and one function call for each triangle that passes the mid phase filtering
- // One possible optimization is to use directly the btBvhTriangleMeshShape when the scale is 1,1,1
- // and btScaledBvhTriangleMeshShape otherwise.
- if (useGimpact) {
- if (!m_triangleIndexVertexArray || m_forceReInstance) {
- if (m_triangleIndexVertexArray)
- delete m_triangleIndexVertexArray;
-
- m_triangleIndexVertexArray = new btTriangleIndexVertexArray(
- m_polygonIndexArray.size(),
- m_triFaceArray.data(),
- 3 * sizeof(int),
- m_vertexArray.size() / 3,
- &m_vertexArray[0],
- 3 * sizeof(btScalar));
- m_forceReInstance = false;
- }
-
- btGImpactMeshShape *gimpactShape = new btGImpactMeshShape(m_triangleIndexVertexArray);
- gimpactShape->setMargin(margin);
- gimpactShape->updateBound();
- collisionShape = gimpactShape;
- }
- else {
- if (!m_triangleIndexVertexArray || m_forceReInstance) {
- ///enable welding, only for the objects that need it (such as soft bodies)
- if (0.0f != m_weldingThreshold1) {
- btTriangleMesh *collisionMeshData = new btTriangleMesh(true, false);
- collisionMeshData->m_weldingThreshold = m_weldingThreshold1;
- bool removeDuplicateVertices = true;
- // m_vertexArray not in multiple of 3 anymore, use m_triFaceArray
- for (unsigned int i = 0; i < m_triFaceArray.size(); i += 3) {
- btScalar *bt = &m_vertexArray[3 * m_triFaceArray[i]];
- btVector3 v1(bt[0], bt[1], bt[2]);
- bt = &m_vertexArray[3 * m_triFaceArray[i + 1]];
- btVector3 v2(bt[0], bt[1], bt[2]);
- bt = &m_vertexArray[3 * m_triFaceArray[i + 2]];
- btVector3 v3(bt[0], bt[1], bt[2]);
- collisionMeshData->addTriangle(v1, v2, v3, removeDuplicateVertices);
- }
- m_triangleIndexVertexArray = collisionMeshData;
- }
- else {
- m_triangleIndexVertexArray = new btTriangleIndexVertexArray(
- m_polygonIndexArray.size(),
- m_triFaceArray.data(),
- 3 * sizeof(int),
- m_vertexArray.size() / 3,
- &m_vertexArray[0],
- 3 * sizeof(btScalar));
- }
-
- m_forceReInstance = false;
- }
-
- btBvhTriangleMeshShape *unscaledShape = new btBvhTriangleMeshShape(m_triangleIndexVertexArray, true, useBvh);
- unscaledShape->setMargin(margin);
- collisionShape = new btScaledBvhTriangleMeshShape(unscaledShape, btVector3(1.0f, 1.0f, 1.0f));
- collisionShape->setMargin(margin);
- }
- break;
-
- case PHY_SHAPE_COMPOUND:
- if (m_shapeArray.size() > 0)
- {
- compoundShape = new btCompoundShape();
- for (std::vector<CcdShapeConstructionInfo*>::iterator sit = m_shapeArray.begin();
- sit != m_shapeArray.end();
- sit++)
- {
- collisionShape = (*sit)->CreateBulletShape(margin, useGimpact, useBvh);
- if (collisionShape)
- {
- collisionShape->setLocalScaling((*sit)->m_childScale);
- compoundShape->addChildShape((*sit)->m_childTrans, collisionShape);
- }
- }
- collisionShape = compoundShape;
- }
- break;
- }
- return collisionShape;
-}
-
-void CcdShapeConstructionInfo::AddShape(CcdShapeConstructionInfo* shapeInfo)
-{
- m_shapeArray.push_back(shapeInfo);
- shapeInfo->AddRef();
-}
-
-CcdShapeConstructionInfo::~CcdShapeConstructionInfo()
-{
- for (std::vector<CcdShapeConstructionInfo*>::iterator sit = m_shapeArray.begin();
- sit != m_shapeArray.end();
- sit++)
- {
- (*sit)->Release();
- }
- m_shapeArray.clear();
-
- if (m_triangleIndexVertexArray)
- delete m_triangleIndexVertexArray;
- m_vertexArray.clear();
- if (m_shapeType == PHY_SHAPE_MESH && m_meshObject != NULL)
- {
- std::map<RAS_MeshObject*,CcdShapeConstructionInfo*>::iterator mit = m_meshShapeMap.find(m_meshObject);
- if (mit != m_meshShapeMap.end() && mit->second == this)
- {
- m_meshShapeMap.erase(mit);
- }
- }
- if (m_shapeType == PHY_SHAPE_PROXY && m_shapeProxy != NULL)
- {
- m_shapeProxy->Release();
- }
-}
-
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
deleted file mode 100644
index 831e7346df7..00000000000
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ /dev/null
@@ -1,832 +0,0 @@
-/*
-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.
-*/
-
-/** \file CcdPhysicsController.h
- * \ingroup physbullet
- */
-
-
-#ifndef __CCDPHYSICSCONTROLLER_H__
-#define __CCDPHYSICSCONTROLLER_H__
-
-#include <vector>
-#include <map>
-
-#include "PHY_IPhysicsController.h"
-
-/// PHY_IPhysicsController is the abstract simplified Interface to a physical object.
-/// It contains the IMotionState and IDeformableMesh Interfaces.
-#include "btBulletDynamicsCommon.h"
-#include "BulletDynamics/Character/btKinematicCharacterController.h"
-#include "LinearMath/btTransform.h"
-
-#include "PHY_IMotionState.h"
-#include "PHY_ICharacter.h"
-
-extern float gDeactivationTime;
-extern float gLinearSleepingTreshold;
-extern float gAngularSleepingTreshold;
-extern bool gDisableDeactivation;
-class CcdPhysicsEnvironment;
-class btMotionState;
-class RAS_MeshObject;
-struct DerivedMesh;
-class btCollisionShape;
-
-
-#define CCD_BSB_SHAPE_MATCHING 2
-#define CCD_BSB_BENDING_CONSTRAINTS 8
-#define CCD_BSB_AERO_VPOINT 16 /* aero model, Vertex normals are oriented toward velocity*/
-#define CCD_BSB_AERO_VTWOSIDE 32 /* aero model, Vertex normals are flipped to match velocity */
-
-/* BulletSoftBody.collisionflags */
-#define CCD_BSB_COL_SDF_RS 2 /* SDF based rigid vs soft */
-#define CCD_BSB_COL_CL_RS 4 /* Cluster based rigid vs soft */
-#define CCD_BSB_COL_CL_SS 8 /* Cluster based soft vs soft */
-#define CCD_BSB_COL_VF_SS 16 /* Vertex/Face based soft vs soft */
-
-
-// Shape contructor
-// It contains all the information needed to create a simple bullet shape at runtime
-class CcdShapeConstructionInfo
-{
-public:
- struct UVco
- {
- float uv[2];
- };
-
- static CcdShapeConstructionInfo* FindMesh(class RAS_MeshObject* mesh, struct DerivedMesh* dm, bool polytope);
-
- CcdShapeConstructionInfo() :
- m_shapeType(PHY_SHAPE_NONE),
- m_radius(1.0f),
- m_height(1.0f),
- m_halfExtend(0.f,0.f,0.f),
- m_childScale(1.0f,1.0f,1.0f),
- m_userData(NULL),
- m_refCount(1),
- m_meshObject(NULL),
- m_triangleIndexVertexArray(NULL),
- m_forceReInstance(false),
- m_weldingThreshold1(0.f),
- m_shapeProxy(NULL)
- {
- m_childTrans.setIdentity();
- }
-
- ~CcdShapeConstructionInfo();
-
- CcdShapeConstructionInfo* AddRef()
- {
- m_refCount++;
- return this;
- }
-
- int Release()
- {
- if (--m_refCount > 0)
- return m_refCount;
- delete this;
- return 0;
- }
-
- bool IsUnused(void)
- {
- return (m_meshObject==NULL && m_shapeArray.size() == 0 && m_shapeProxy == NULL);
- }
-
- void AddShape(CcdShapeConstructionInfo* shapeInfo);
-
- btStridingMeshInterface *GetMeshInterface()
- {
- return m_triangleIndexVertexArray;
- }
-
- CcdShapeConstructionInfo* GetChildShape(int i)
- {
- if (i < 0 || i >= (int)m_shapeArray.size())
- return NULL;
-
- return m_shapeArray.at(i);
- }
- int FindChildShape(CcdShapeConstructionInfo* shapeInfo, void* userData)
- {
- if (shapeInfo == NULL)
- return -1;
- for (int i=0; i<(int)m_shapeArray.size(); i++)
- {
- CcdShapeConstructionInfo* childInfo = m_shapeArray.at(i);
- if ((userData == NULL || userData == childInfo->m_userData) &&
- (childInfo == shapeInfo ||
- (childInfo->m_shapeType == PHY_SHAPE_PROXY &&
- childInfo->m_shapeProxy == shapeInfo)))
- return i;
- }
- return -1;
- }
-
- bool RemoveChildShape(int i)
- {
- if (i < 0 || i >= (int)m_shapeArray.size())
- return false;
- m_shapeArray.at(i)->Release();
- if (i < (int)m_shapeArray.size()-1)
- m_shapeArray[i] = m_shapeArray.back();
- m_shapeArray.pop_back();
- return true;
- }
-
- bool SetMesh(class RAS_MeshObject* mesh, struct DerivedMesh* dm, bool polytope);
- RAS_MeshObject* GetMesh(void)
- {
- return m_meshObject;
- }
-
- bool UpdateMesh(class KX_GameObject* gameobj, class RAS_MeshObject* mesh);
-
-
- bool SetProxy(CcdShapeConstructionInfo* shapeInfo);
- CcdShapeConstructionInfo* GetProxy(void)
- {
- return m_shapeProxy;
- }
-
- btCollisionShape* CreateBulletShape(btScalar margin, bool useGimpact=false, bool useBvh=true);
-
- // member variables
- PHY_ShapeType m_shapeType;
- btScalar m_radius;
- btScalar m_height;
- btVector3 m_halfExtend;
- btTransform m_childTrans;
- btVector3 m_childScale;
- void* m_userData;
- btAlignedObjectArray<btScalar> m_vertexArray; // Contains both vertex array for polytope shape and
- // triangle array for concave mesh shape. Each vertex is 3 consecutive values
- // In this case a triangle is made of 3 consecutive points
- std::vector<int> m_polygonIndexArray; // Contains the array of polygon index in the
- // original mesh that correspond to shape triangles.
- // only set for concave mesh shape.
-
- std::vector<int> m_triFaceArray; // Contains an array of triplets of face indices
- // quads turn into 2 tris
-
- std::vector<UVco> m_triFaceUVcoArray; // Contains an array of pair of UV coordinate for each vertex of faces
- // quads turn into 2 tris
-
- void setVertexWeldingThreshold1(float threshold)
- {
- m_weldingThreshold1 = threshold*threshold;
- }
-protected:
- static std::map<RAS_MeshObject*, CcdShapeConstructionInfo*> m_meshShapeMap;
- int m_refCount; // this class is shared between replicas
- // keep track of users so that we can release it
- RAS_MeshObject* m_meshObject; // Keep a pointer to the original mesh
- // The list of vertexes and indexes for the triangle mesh, shared between Bullet shape.
- btTriangleIndexVertexArray *m_triangleIndexVertexArray;
- std::vector<CcdShapeConstructionInfo*> m_shapeArray; // for compound shapes
- bool m_forceReInstance; //use gimpact for concave dynamic/moving collision detection
- float m_weldingThreshold1; //welding closeby vertices together can improve softbody stability etc.
- CcdShapeConstructionInfo* m_shapeProxy; // only used for PHY_SHAPE_PROXY, pointer to actual shape info
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdShapeConstructionInfo")
-#endif
-};
-
-struct CcdConstructionInfo
-{
-
- ///CollisionFilterGroups provides some optional usage of basic collision filtering
- ///this is done during broadphase, so very early in the pipeline
- ///more advanced collision filtering should be done in btCollisionDispatcher::NeedsCollision
- enum CollisionFilterGroups
- {
- DefaultFilter = 1,
- StaticFilter = 2,
- KinematicFilter = 4,
- DebrisFilter = 8,
- SensorFilter = 16,
- CharacterFilter = 32,
- AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorFilter | CharacterFilter,
- };
-
-
- CcdConstructionInfo()
- :m_localInertiaTensor(1.f, 1.f, 1.f),
- m_gravity(0,0,0),
- m_scaling(1.f,1.f,1.f),
- m_linearFactor(0.f, 0.f, 0.f),
- m_angularFactor(0.f, 0.f, 0.f),
- m_mass(0.f),
- m_clamp_vel_min(-1.f),
- m_clamp_vel_max(-1.f),
- m_clamp_angvel_min(0.0f),
- m_clamp_angvel_max(0.0f),
- m_restitution(0.1f),
- m_friction(0.5f),
- m_linearDamping(0.1f),
- m_angularDamping(0.1f),
- m_margin(0.06f),
- m_gamesoftFlag(0),
- m_soft_linStiff(1.f),
- m_soft_angStiff(1.f),
- m_soft_volume(1.f),
- m_soft_viterations(0),
- m_soft_piterations(1),
- m_soft_diterations(0),
- m_soft_citerations(4),
- m_soft_kSRHR_CL(0.1f),
- m_soft_kSKHR_CL(1.f),
- m_soft_kSSHR_CL(0.5f),
- m_soft_kSR_SPLT_CL(0.5f),
- m_soft_kSK_SPLT_CL(0.5f),
- m_soft_kSS_SPLT_CL(0.5f),
- m_soft_kVCF(1.f),
- m_soft_kDP(0.f),
- m_soft_kDG(0.f),
- m_soft_kLF(0.f),
- m_soft_kPR(0.f),
- m_soft_kVC(0.f),
- m_soft_kDF(0.2f),
- m_soft_kMT(0),
- m_soft_kCHR(1.0f),
- m_soft_kKHR(0.1f),
- 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),
- m_bCharacter(false),
- m_bGimpact(false),
- m_collisionFilterGroup(DefaultFilter),
- m_collisionFilterMask(AllFilter),
- m_collisionShape(0),
- m_MotionState(0),
- m_shapeInfo(0),
- m_physicsEnv(0),
- m_inertiaFactor(1.f),
- m_do_anisotropic(false),
- m_anisotropicFriction(1.f,1.f,1.f),
- m_do_fh(false),
- m_do_rot_fh(false),
- m_fh_spring(0.f),
- m_fh_damping(0.f),
- m_fh_distance(1.f),
- m_fh_normal(false)
- // m_contactProcessingThreshold(1e10f)
- {
-
- }
-
- btVector3 m_localInertiaTensor;
- btVector3 m_gravity;
- btVector3 m_scaling;
- btVector3 m_linearFactor;
- btVector3 m_angularFactor;
- btScalar m_mass;
- btScalar m_clamp_vel_min;
- btScalar m_clamp_vel_max;
- btScalar m_clamp_angvel_min; // Minimum angular velocity, in radians/sec.
- btScalar m_clamp_angvel_max; // Maximum angular velocity, in radians/sec.
- btScalar m_restitution;
- btScalar m_friction;
- btScalar m_linearDamping;
- btScalar m_angularDamping;
- btScalar m_margin;
-
- ////////////////////
- float m_stepHeight;
- float m_jumpSpeed;
- float m_fallSpeed;
- unsigned char m_maxJumps;
-
- int m_gamesoftFlag;
- float m_soft_linStiff; /* linear stiffness 0..1 */
- float m_soft_angStiff; /* angular stiffness 0..1 */
- float m_soft_volume; /* volume preservation 0..1 */
-
- int m_soft_viterations; /* Velocities solver iterations */
- int m_soft_piterations; /* Positions solver iterations */
- int m_soft_diterations; /* Drift solver iterations */
- int m_soft_citerations; /* Cluster solver iterations */
-
- float m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
- float m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
- float m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
- float m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
-
- float m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- float m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- float m_soft_kVCF; /* Velocities correction factor (Baumgarte) */
- float m_soft_kDP; /* Damping coefficient [0,1] */
-
- float m_soft_kDG; /* Drag coefficient [0,+inf] */
- float m_soft_kLF; /* Lift coefficient [0,+inf] */
- float m_soft_kPR; /* Pressure coefficient [-inf,+inf] */
- float m_soft_kVC; /* Volume conversation coefficient [0,+inf] */
-
- float m_soft_kDF; /* Dynamic friction coefficient [0,1] */
- float m_soft_kMT; /* Pose matching coefficient [0,1] */
- float m_soft_kCHR; /* Rigid contacts hardness [0,1] */
- float m_soft_kKHR; /* Kinetic contacts hardness [0,1] */
-
- float m_soft_kSHR; /* Soft contacts hardness [0,1] */
- float m_soft_kAHR; /* Anchors hardness [0,1] */
- int m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
- int m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/
-///////////////////
-
-
-
- int m_collisionFlags;
- bool m_bDyna;
- bool m_bRigid;
- bool m_bSoft;
- bool m_bSensor;
- bool m_bCharacter;
- bool m_bGimpact; // use Gimpact for mesh body
-
- ///optional use of collision group/mask:
- ///only collision with object goups that match the collision mask.
- ///this is very basic early out. advanced collision filtering should be
- ///done in the btCollisionDispatcher::NeedsCollision and NeedsResponse
- ///both values default to 1
- short int m_collisionFilterGroup;
- short int m_collisionFilterMask;
-
- ///these pointers are used as argument passing for the CcdPhysicsController constructor
- ///and not anymore after that
- class btCollisionShape* m_collisionShape;
- class PHY_IMotionState* m_MotionState;
- class CcdShapeConstructionInfo* m_shapeInfo;
-
- CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication
- float m_inertiaFactor;//tweak the inertia (hooked up to Blender 'formfactor'
- bool m_do_anisotropic;
- btVector3 m_anisotropicFriction;
-
- bool m_do_fh; ///< Should the object have a linear Fh spring?
- bool m_do_rot_fh; ///< Should the object have an angular Fh spring?
- btScalar m_fh_spring; ///< Spring constant (both linear and angular)
- btScalar m_fh_damping; ///< Damping factor (linear and angular) in range [0, 1]
- btScalar m_fh_distance; ///< The range above the surface where Fh is active.
- bool m_fh_normal; ///< Should the object slide off slopes?
- float m_radius;//for fh backwards compatibility
-
- ///m_contactProcessingThreshold allows to process contact points with positive distance
- ///normally only contacts with negative distance (penetration) are solved
- ///however, rigid body stacking is more stable when positive contacts are still passed into the constraint solver
- ///this might sometimes lead to collisions with 'internal edges' such as a sliding character controller
- ///so disable/set m_contactProcessingThreshold to zero for sliding characters etc.
- // float m_contactProcessingThreshold;///< Process contacts with positive distance in range [0..INF]
-};
-
-class btRigidBody;
-class btCollisionObject;
-class btSoftBody;
-class btPairCachingGhostObject;
-
-class BlenderBulletCharacterController : public btKinematicCharacterController, public PHY_ICharacter
-{
-private:
- btMotionState* m_motionState;
- unsigned char m_jumps;
- unsigned char m_maxJumps;
-
-public:
- BlenderBulletCharacterController(btMotionState *motionState, btPairCachingGhostObject *ghost, btConvexShape* shape, float stepHeight);
-
- virtual void updateAction(btCollisionWorld *collisionWorld, btScalar dt);
-
- unsigned char getMaxJumps() const;
-
- void setMaxJumps(unsigned char maxJumps);
-
- unsigned char getJumpCount() const;
-
- virtual bool canJump() const;
-
- 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 unsigned char GetMaxJumps() { return getMaxJumps(); }
- virtual void SetMaxJumps(unsigned char maxJumps) { setMaxJumps(maxJumps); }
- virtual unsigned char 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
-};
-
-class CleanPairCallback : public btOverlapCallback
-{
- btBroadphaseProxy *m_cleanProxy;
- btOverlappingPairCache *m_pairCache;
- btDispatcher *m_dispatcher;
-
-public:
- CleanPairCallback(btBroadphaseProxy *cleanProxy, btOverlappingPairCache *pairCache, btDispatcher *dispatcher)
- :m_cleanProxy(cleanProxy),
- m_pairCache(pairCache),
- m_dispatcher(dispatcher)
- {
- }
-
- virtual bool processOverlap(btBroadphasePair &pair);
-};
-
-///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution.
-class CcdPhysicsController : public PHY_IPhysicsController
-{
-protected:
- btCollisionObject* m_object;
- BlenderBulletCharacterController* m_characterController;
-
-
- class PHY_IMotionState* m_MotionState;
- btMotionState* m_bulletMotionState;
- class btCollisionShape* m_collisionShape;
- class CcdShapeConstructionInfo* m_shapeInfo;
- btCollisionShape* m_bulletChildShape;
-
- btAlignedObjectArray<btTypedConstraint*> m_ccdConstraintRefs; // keep track of typed constraints referencing this rigid body
- friend class CcdPhysicsEnvironment; // needed when updating the controller
-
- //some book keeping for replication
- bool m_softbodyMappingDone;
- bool m_softBodyTransformInitialized;
- bool m_prototypeTransformInitialized;
- btTransform m_softbodyStartTrans;
-
-
- void* m_newClientInfo;
- int m_registerCount; // needed when multiple sensors use the same controller
- CcdConstructionInfo m_cci;//needed for replication
-
- CcdPhysicsController* m_parentCtrl;
-
- int m_savedCollisionFlags;
- short m_savedCollisionFilterGroup;
- short m_savedCollisionFilterMask;
- MT_Scalar m_savedMass;
- bool m_savedDyna;
- bool m_suspended;
-
-
- void GetWorldOrientation(btMatrix3x3& mat);
-
- void CreateRigidbody();
- bool CreateSoftbody();
- bool CreateCharacterController();
-
- bool Register() {
- return (m_registerCount++ == 0) ? true : false;
- }
- bool Unregister() {
- return (--m_registerCount == 0) ? true : false;
- }
-
- bool Registered() const
- {
- return (m_registerCount != 0);
- }
-
- void addCcdConstraintRef(btTypedConstraint* c);
- void removeCcdConstraintRef(btTypedConstraint* c);
- btTypedConstraint* getCcdConstraintRef(int index);
- int getNumCcdConstraintRefs() const;
-
- void SetWorldOrientation(const btMatrix3x3& mat);
- void ForceWorldTransform(const btMatrix3x3& mat, const btVector3& pos);
-
- public:
-
- int m_collisionDelay;
-
-
- CcdPhysicsController (const CcdConstructionInfo& ci);
-
- /**
- * Delete the current Bullet shape used in the rigid body.
- */
- bool DeleteControllerShape();
-
- /**
- * Delete the old Bullet shape and set the new Bullet shape : newShape
- * \param newShape The new Bullet shape to set, if is NULL we create a new Bullet shape
- */
- bool ReplaceControllerShape(btCollisionShape *newShape);
-
- virtual ~CcdPhysicsController();
-
- CcdConstructionInfo& GetConstructionInfo()
- {
- return m_cci;
- }
- const CcdConstructionInfo& GetConstructionInfo() const
- {
- return m_cci;
- }
-
-
- btRigidBody* GetRigidBody();
- const btRigidBody* GetRigidBody() const;
- btCollisionObject* GetCollisionObject();
- btSoftBody* GetSoftBody();
- btKinematicCharacterController* GetCharacterController();
-
- CcdShapeConstructionInfo* GetShapeInfo() { return m_shapeInfo; }
-
- btCollisionShape* GetCollisionShape() {
- return m_object->getCollisionShape();
- }
- ////////////////////////////////////
- // PHY_IPhysicsController interface
- ////////////////////////////////////
-
-
- /**
- * SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
- */
- virtual bool SynchronizeMotionStates(float time);
-
- /**
- * Called for every physics simulation step. Use this method for
- * things like limiting linear and angular velocity.
- */
- void SimulationTick(float timestep);
-
- /**
- * WriteMotionStateToDynamics ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
- */
-
- virtual void WriteMotionStateToDynamics(bool nondynaonly);
- virtual void WriteDynamicsToMotionState();
-
- // controller replication
- virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl);
- virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env);
-
- // kinematic methods
- 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 ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein, bool local);
- 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);
-
- virtual float GetLinearDamping() const;
- virtual float GetAngularDamping() const;
- virtual void SetLinearDamping(float damping);
- virtual void SetAngularDamping(float damping);
- virtual void SetDamping(float linear, float angular);
-
- // reading out information from physics
- 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 ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
- virtual void RefreshCollisions();
- 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 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
- {
- return m_cci.m_collisionFilterGroup;
- }
- ///There should be no 'SetCollisionFilterGroup' method, as changing this during run-time is will result in errors
- short int GetCollisionFilterMask() const
- {
- return m_cci.m_collisionFilterMask;
- }
-
- virtual void CalcXform() {}
- virtual void SetMargin(float margin)
- {
- if (m_collisionShape) {
- m_collisionShape->setMargin(margin);
- // if the shape use a unscaled shape we have also to set the correct margin in it
- if (m_collisionShape->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
- ((btScaledBvhTriangleMeshShape *)m_collisionShape)->getChildShape()->setMargin(margin);
- }
- }
- virtual float GetMargin() const
- {
- return (m_collisionShape) ? m_collisionShape->getMargin() : 0.f;
- }
- virtual float GetRadius() const
- {
- // this is not the actual shape radius, it's only used for Fh support
- return m_cci.m_radius;
- }
- virtual void SetRadius(float margin)
- {
- if (m_collisionShape && m_collisionShape->getShapeType() == SPHERE_SHAPE_PROXYTYPE)
- {
- btSphereShape* sphereShape = static_cast<btSphereShape*>(m_collisionShape);
- sphereShape->setUnscaledRadius(margin);
- }
- m_cci.m_radius = margin;
- }
-
- // velocity clamping
- virtual void SetLinVelocityMin(float val)
- {
- m_cci.m_clamp_vel_min= val;
- }
- virtual float GetLinVelocityMin() const
- {
- return m_cci.m_clamp_vel_min;
- }
- virtual void SetLinVelocityMax(float val)
- {
- m_cci.m_clamp_vel_max= val;
- }
- virtual float GetLinVelocityMax() const
- {
- return m_cci.m_clamp_vel_max;
- }
-
- virtual void SetAngularVelocityMin(float val)
- {
- m_cci.m_clamp_angvel_min = val;
- }
- virtual float GetAngularVelocityMin() const
- {
- return m_cci.m_clamp_angvel_min;
- }
- virtual void SetAngularVelocityMax(float val)
- {
- m_cci.m_clamp_angvel_max = val;
- }
- virtual float GetAngularVelocityMax() const
- {
- return m_cci.m_clamp_angvel_max;
- }
-
- bool WantsSleeping();
-
- void UpdateDeactivation(float timeStep);
-
- void SetCenterOfMassTransform(btTransform& xform);
-
- static btTransform& GetTransformFromMotionState(PHY_IMotionState* motionState);
-
- void setAabb(const btVector3& aabbMin,const btVector3& aabbMax);
-
-
- class PHY_IMotionState* GetMotionState()
- {
- return m_MotionState;
- }
-
- const class PHY_IMotionState* GetMotionState() const
- {
- return m_MotionState;
- }
-
- class CcdPhysicsEnvironment* GetPhysicsEnvironment()
- {
- return m_cci.m_physicsEnv;
- }
-
- void SetParentCtrl(CcdPhysicsController* parentCtrl)
- {
- m_parentCtrl = parentCtrl;
- }
-
- CcdPhysicsController* GetParentCtrl()
- {
- return m_parentCtrl;
- }
-
- const CcdPhysicsController* GetParentCtrl() const
- {
- return m_parentCtrl;
- }
-
- virtual bool IsDynamic()
- {
- return GetConstructionInfo().m_bDyna;
- }
-
- virtual bool IsSuspended() const
- {
- return m_suspended;
- }
-
- virtual bool IsCompound()
- {
- return GetConstructionInfo().m_shapeInfo->m_shapeType == PHY_SHAPE_COMPOUND;
- }
-
- virtual bool ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj);
-
- /* Method to replicate rigid body joint contraints for group instances. */
- virtual void ReplicateConstraints(KX_GameObject *gameobj, std::vector<KX_GameObject*> constobj);
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdPhysicsController")
-#endif
-};
-
-
-
-
-///DefaultMotionState implements standard motionstate, using btTransform
-class DefaultMotionState : public PHY_IMotionState
-
-{
- public:
- DefaultMotionState();
-
- 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 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();
-
- btTransform m_worldTransform;
- btVector3 m_localScaling;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:DefaultMotionState")
-#endif
-};
-
-
-#endif /* __CCDPHYSICSCONTROLLER_H__ */
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
deleted file mode 100644
index 78d2d88cc65..00000000000
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ /dev/null
@@ -1,3795 +0,0 @@
-/** \file gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
- * \ingroup physbullet
- */
-/*
-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 "CcdPhysicsEnvironment.h"
-#include "CcdPhysicsController.h"
-#include "CcdGraphicController.h"
-
-#include <algorithm>
-#include "btBulletDynamicsCommon.h"
-#include "LinearMath/btIDebugDraw.h"
-#include "BulletCollision/CollisionDispatch/btGhostObject.h"
-#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
-#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
-#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h"
-#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
-#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
-
-//profiling/timings
-#include "LinearMath/btQuickprof.h"
-
-
-#include "PHY_IMotionState.h"
-#include "PHY_ICharacter.h"
-#include "PHY_Pro.h"
-#include "KX_GameObject.h"
-#include "KX_PythonInit.h" // for KX_RasterizerDrawDebugLine
-#include "KX_BlenderSceneConverter.h"
-#include "RAS_MeshObject.h"
-#include "RAS_Polygon.h"
-#include "RAS_TexVert.h"
-
-#include "DNA_scene_types.h"
-#include "DNA_world_types.h"
-#include "DNA_object_force_types.h"
-
-extern "C" {
- #include "BLI_utildefines.h"
- #include "BKE_object.h"
-}
-
-#define CCD_CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
-
-#ifdef NEW_BULLET_VEHICLE_SUPPORT
-#include "BulletDynamics/Vehicle/btRaycastVehicle.h"
-#include "BulletDynamics/Vehicle/btVehicleRaycaster.h"
-#include "BulletDynamics/Vehicle/btWheelInfo.h"
-#include "PHY_IVehicle.h"
-static btRaycastVehicle::btVehicleTuning gTuning;
-
-#endif //NEW_BULLET_VEHICLE_SUPPORT
-#include "LinearMath/btAabbUtil2.h"
-#include "MT_Matrix4x4.h"
-#include "MT_Vector3.h"
-#include "MT_MinMax.h"
-
-#ifdef WIN32
-void DrawRasterizerLine(const float* from,const float* to,int color);
-#endif
-
-
-#include "BulletDynamics/ConstraintSolver/btContactConstraint.h"
-
-
-#include <stdio.h>
-#include <string.h> // for memset
-
-// This was copied from the old KX_ConvertPhysicsObjects
-#ifdef WIN32
-#ifdef _MSC_VER
-//only use SIMD Hull code under Win32
-//#define TEST_HULL 1
-#ifdef TEST_HULL
-#define USE_HULL 1
-//#define TEST_SIMD_HULL 1
-
-#include "NarrowPhaseCollision/Hull.h"
-#endif //#ifdef TEST_HULL
-
-#endif //_MSC_VER
-#endif //WIN32
-
-#ifdef NEW_BULLET_VEHICLE_SUPPORT
-class WrapperVehicle : public PHY_IVehicle
-{
-
- btRaycastVehicle* m_vehicle;
- PHY_IPhysicsController* m_chassis;
-
-public:
-
- WrapperVehicle(btRaycastVehicle* vehicle,PHY_IPhysicsController* chassis)
- :m_vehicle(vehicle),
- m_chassis(chassis)
- {
- }
-
- ~WrapperVehicle()
- {
- delete m_vehicle;
- }
-
- btRaycastVehicle* GetVehicle()
- {
- return m_vehicle;
- }
-
- PHY_IPhysicsController* GetChassis()
- {
- return m_chassis;
- }
-
- virtual void AddWheel(
- PHY_IMotionState* motionState,
- MT_Vector3 connectionPoint,
- MT_Vector3 downDirection,
- MT_Vector3 axleDirection,
- float suspensionRestLength,
- float wheelRadius,
- bool hasSteering
- )
- {
- btVector3 connectionPointCS0(connectionPoint[0],connectionPoint[1],connectionPoint[2]);
- btVector3 wheelDirectionCS0(downDirection[0],downDirection[1],downDirection[2]);
- btVector3 wheelAxle(axleDirection[0],axleDirection[1],axleDirection[2]);
-
-
- btWheelInfo& info = m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxle,
- suspensionRestLength,wheelRadius,gTuning,hasSteering);
- info.m_clientInfo = motionState;
-
- }
-
- void SyncWheels()
- {
- int numWheels = GetNumWheels();
- int i;
- for (i=0;i<numWheels;i++)
- {
- btWheelInfo& info = m_vehicle->getWheelInfo(i);
- PHY_IMotionState* motionState = (PHY_IMotionState*)info.m_clientInfo;
- // m_vehicle->updateWheelTransformsWS(info,false);
- m_vehicle->updateWheelTransform(i,false);
- 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());
-
- }
- }
-
- virtual int GetNumWheels() const
- {
- return m_vehicle->getNumWheels();
- }
-
- virtual void GetWheelPosition(int wheelIndex,float& posX,float& posY,float& posZ) const
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
- {
- btVector3 origin = m_vehicle->getWheelTransformWS(wheelIndex).getOrigin();
-
- posX = origin.x();
- posY = origin.y();
- posZ = origin.z();
- }
- }
-
- virtual void GetWheelOrientationQuaternion(int wheelIndex,float& quatX,float& quatY,float& quatZ,float& quatW) const
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
- {
- btQuaternion quat = m_vehicle->getWheelTransformWS(wheelIndex).getRotation();
-
- quatX = quat.x();
- quatY = quat.y();
- quatZ = quat.z();
- quatW = quat.w();
- }
- }
-
- virtual float GetWheelRotation(int wheelIndex) const
- {
- float rotation = 0.f;
-
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
- {
- btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
- rotation = info.m_rotation;
- }
-
- return rotation;
- }
-
-
-
- virtual int GetUserConstraintId() const
- {
- return m_vehicle->getUserConstraintId();
- }
-
- virtual int GetUserConstraintType() const
- {
- return m_vehicle->getUserConstraintType();
- }
-
- virtual void SetSteeringValue(float steering,int wheelIndex)
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels())) {
- m_vehicle->setSteeringValue(steering,wheelIndex);
- }
- }
-
- virtual void ApplyEngineForce(float force,int wheelIndex)
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels())) {
- m_vehicle->applyEngineForce(force,wheelIndex);
- }
- }
-
- virtual void ApplyBraking(float braking,int wheelIndex)
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
- {
- btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
- info.m_brake = braking;
- }
- }
-
- virtual void SetWheelFriction(float friction,int wheelIndex)
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
- {
- btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
- info.m_frictionSlip = friction;
- }
-
- }
-
- virtual void SetSuspensionStiffness(float suspensionStiffness,int wheelIndex)
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
- {
- btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
- info.m_suspensionStiffness = suspensionStiffness;
-
- }
- }
-
- virtual void SetSuspensionDamping(float suspensionDamping,int wheelIndex)
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
- {
- btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
- info.m_wheelsDampingRelaxation = suspensionDamping;
- }
- }
-
- virtual void SetSuspensionCompression(float suspensionCompression,int wheelIndex)
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
- {
- btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
- info.m_wheelsDampingCompression = suspensionCompression;
- }
- }
-
-
-
- virtual void SetRollInfluence(float rollInfluence,int wheelIndex)
- {
- if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
- {
- btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
- info.m_rollInfluence = rollInfluence;
- }
- }
-
- virtual void SetCoordinateSystem(int rightIndex,int upIndex,int forwardIndex)
- {
- m_vehicle->setCoordinateSystem(rightIndex,upIndex,forwardIndex);
- }
-
-
-
-};
-
-class BlenderVehicleRaycaster: public btDefaultVehicleRaycaster
-{
- btDynamicsWorld* m_dynamicsWorld;
-public:
- BlenderVehicleRaycaster(btDynamicsWorld* world)
- :btDefaultVehicleRaycaster(world), m_dynamicsWorld(world)
- {
- }
-
- virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result)
- {
- // RayResultCallback& resultCallback;
-
- btCollisionWorld::ClosestRayResultCallback rayCallback(from,to);
-
- // We override btDefaultVehicleRaycaster so we can set this flag, otherwise our
- // vehicles go crazy (http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=9662)
- rayCallback.m_flags |= btTriangleRaycastCallback::kF_UseSubSimplexConvexCastRaytest;
-
- m_dynamicsWorld->rayTest(from, to, rayCallback);
-
- if (rayCallback.hasHit())
- {
-
- const btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
- if (body && body->hasContactResponse())
- {
- result.m_hitPointInWorld = rayCallback.m_hitPointWorld;
- result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld;
- result.m_hitNormalInWorld.normalize();
- result.m_distFraction = rayCallback.m_closestHitFraction;
- return (void*)body;
- }
- }
- return 0;
- }
-};
-#endif //NEW_BULLET_VEHICLE_SUPPORT
-
-class CcdOverlapFilterCallBack : public btOverlapFilterCallback
-{
-private:
- class CcdPhysicsEnvironment* m_physEnv;
-public:
- CcdOverlapFilterCallBack(CcdPhysicsEnvironment* env) :
- m_physEnv(env)
- {
- }
- virtual ~CcdOverlapFilterCallBack()
- {
- }
- // return true when pairs need collision
- virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const;
-};
-
-
-void CcdPhysicsEnvironment::SetDebugDrawer(btIDebugDraw* debugDrawer)
-{
- if (debugDrawer && m_dynamicsWorld)
- m_dynamicsWorld->setDebugDrawer(debugDrawer);
- m_debugDrawer = debugDrawer;
-}
-
-#if 0
-static void DrawAabb(btIDebugDraw* debugDrawer,const btVector3& from,const btVector3& to,const btVector3& color)
-{
- btVector3 halfExtents = (to-from)* 0.5f;
- btVector3 center = (to+from) *0.5f;
- int i,j;
-
- btVector3 edgecoord(1.f,1.f,1.f),pa,pb;
- for (i=0;i<4;i++)
- {
- for (j=0;j<3;j++)
- {
- pa = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],
- edgecoord[2]*halfExtents[2]);
- pa+=center;
-
- int othercoord = j%3;
- edgecoord[othercoord]*=-1.f;
- pb = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],
- edgecoord[2]*halfExtents[2]);
- pb+=center;
-
- debugDrawer->drawLine(pa,pb,color);
- }
- edgecoord = btVector3(-1.f,-1.f,-1.f);
- if (i<3)
- edgecoord[i]*=-1.f;
- }
-}
-#endif
-
-
-
-
-
-CcdPhysicsEnvironment::CcdPhysicsEnvironment(bool useDbvtCulling,btDispatcher* dispatcher,btOverlappingPairCache* pairCache)
-:m_cullingCache(NULL),
-m_cullingTree(NULL),
-m_numIterations(10),
-m_numTimeSubSteps(1),
-m_ccdMode(0),
-m_solverType(-1),
-m_profileTimings(0),
-m_enableSatCollisionDetection(false),
-m_deactivationTime(2.0f),
-m_linearDeactivationThreshold(0.8f),
-m_angularDeactivationThreshold(1.0f),
-m_contactBreakingThreshold(0.02f),
-m_solver(NULL),
-m_ownPairCache(NULL),
-m_filterCallback(NULL),
-m_ghostPairCallback(NULL),
-m_ownDispatcher(NULL),
-m_scalingPropagated(false)
-{
-
- for (int i=0;i<PHY_NUM_RESPONSE;i++)
- {
- m_triggerCallbacks[i] = 0;
- }
-
-// m_collisionConfiguration = new btDefaultCollisionConfiguration();
- m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
- //m_collisionConfiguration->setConvexConvexMultipointIterations();
-
- if (!dispatcher)
- {
- btCollisionDispatcher* disp = new btCollisionDispatcher(m_collisionConfiguration);
- dispatcher = disp;
- btGImpactCollisionAlgorithm::registerAlgorithm(disp);
- m_ownDispatcher = dispatcher;
- }
-
- //m_broadphase = new btAxisSweep3(btVector3(-1000,-1000,-1000),btVector3(1000,1000,1000));
- //m_broadphase = new btSimpleBroadphase();
- m_broadphase = new btDbvtBroadphase();
- // avoid any collision in the culling tree
- if (useDbvtCulling) {
- m_cullingCache = new btNullPairCache();
- m_cullingTree = new btDbvtBroadphase(m_cullingCache);
- }
-
- m_filterCallback = new CcdOverlapFilterCallBack(this);
- m_ghostPairCallback = new btGhostPairCallback();
- m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback);
- m_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(m_ghostPairCallback);
-
- 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->setInternalTickCallback(&CcdPhysicsEnvironment::StaticSimulationSubtickCallback, this);
- //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);
-}
-
-void CcdPhysicsEnvironment::AddCcdPhysicsController(CcdPhysicsController* ctrl)
-{
- // the controller is already added we do nothing
- if (!m_controllers.insert(ctrl).second) {
- return;
- }
-
- btRigidBody* body = ctrl->GetRigidBody();
- btCollisionObject* obj = ctrl->GetCollisionObject();
-
- //this m_userPointer is just used for triggers, see CallbackTriggers
- obj->setUserPointer(ctrl);
- if (body) {
- body->setGravity(m_gravity);
- body->setSleepingThresholds(m_linearDeactivationThreshold, m_angularDeactivationThreshold);
- }
-
- if (body)
- {
- //use explicit group/filter for finer control over collision in bullet => near/radar sensor
- m_dynamicsWorld->addRigidBody(body, ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask());
- } else
- {
- if (ctrl->GetSoftBody())
- {
- btSoftBody* softBody = ctrl->GetSoftBody();
- m_dynamicsWorld->addSoftBody(softBody);
- } else
- {
- if (obj->getCollisionShape())
- {
- m_dynamicsWorld->addCollisionObject(obj, ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask());
- }
- if (ctrl->GetCharacterController())
- {
- m_dynamicsWorld->addAction(ctrl->GetCharacterController());
- }
- }
- }
- if (obj->isStaticOrKinematicObject())
- {
- obj->setActivationState(ISLAND_SLEEPING);
- }
-
- assert(obj->getBroadphaseHandle());
-}
-
-void CcdPhysicsEnvironment::RemoveConstraint(btTypedConstraint *con)
-{
- btRigidBody &rbA = con->getRigidBodyA();
- btRigidBody &rbB = con->getRigidBodyB();
- rbA.activate();
- rbB.activate();
- m_dynamicsWorld->removeConstraint(con);
-
- if (rbA.getUserPointer()) {
- ((CcdPhysicsController *)rbA.getUserPointer())->removeCcdConstraintRef(con);
- }
-
- if (rbB.getUserPointer()) {
- ((CcdPhysicsController *)rbB.getUserPointer())->removeCcdConstraintRef(con);
- }
-
- /* Since we remove the constraint in the onwer and the target, we can delete it,
- * KX_ConstraintWrapper keep the constraint id not the pointer, so no problems. */
- delete con;
-}
-
-bool CcdPhysicsEnvironment::RemoveCcdPhysicsController(CcdPhysicsController* ctrl)
-{
- // if the physics controller is already removed we do nothing
- if (!m_controllers.erase(ctrl)) {
- return false;
- }
-
- //also remove constraint
- btRigidBody* body = ctrl->GetRigidBody();
- if (body)
- {
- btBroadphaseProxy *proxy = ctrl->GetCollisionObject()->getBroadphaseHandle();
- btDispatcher *dispatcher = m_dynamicsWorld->getDispatcher();
- btOverlappingPairCache *pairCache = m_dynamicsWorld->getPairCache();
-
- CleanPairCallback cleanPairs(proxy, pairCache, dispatcher);
- pairCache->processAllOverlappingPairs(&cleanPairs, dispatcher);
-
- for (int i = ctrl->getNumCcdConstraintRefs() - 1; i >= 0; i--)
- {
- btTypedConstraint* con = ctrl->getCcdConstraintRef(i);
- RemoveConstraint(con);
- }
- 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)
- RemoveConstraintById(vehicle_constraint);
- } else
- {
- //if a softbody
- if (ctrl->GetSoftBody())
- {
- m_dynamicsWorld->removeSoftBody(ctrl->GetSoftBody());
- } else
- {
- m_dynamicsWorld->removeCollisionObject(ctrl->GetCollisionObject());
-
- if (ctrl->GetCharacterController())
- {
- m_dynamicsWorld->removeAction(ctrl->GetCharacterController());
- }
- }
- }
-
- return true;
-}
-
-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
- btRigidBody* body = ctrl->GetRigidBody();
- btSoftBody *softBody = ctrl->GetSoftBody();
- btCollisionObject* obj = ctrl->GetCollisionObject();
- if (obj)
- {
- btVector3 inertia(0.0f,0.0f,0.0f);
- m_dynamicsWorld->removeCollisionObject(obj);
- obj->setCollisionFlags(newCollisionFlags);
- if (body)
- {
- if (newMass)
- body->getCollisionShape()->calculateLocalInertia(newMass, inertia);
- body->setMassProps(newMass, inertia);
- m_dynamicsWorld->addRigidBody(body, newCollisionGroup, newCollisionMask);
- }
- else if (softBody) {
- m_dynamicsWorld->addSoftBody(softBody);
- }
- else {
- m_dynamicsWorld->addCollisionObject(obj, newCollisionGroup, newCollisionMask);
- }
- }
- // to avoid nasty interaction, we must update the property of the controller as well
- ctrl->m_cci.m_mass = newMass;
- ctrl->m_cci.m_collisionFilterGroup = newCollisionGroup;
- ctrl->m_cci.m_collisionFilterMask = newCollisionMask;
- ctrl->m_cci.m_collisionFlags = newCollisionFlags;
-}
-
-void CcdPhysicsEnvironment::RefreshCcdPhysicsController(CcdPhysicsController* ctrl)
-{
- btCollisionObject* obj = ctrl->GetCollisionObject();
- if (obj)
- {
- btBroadphaseProxy* proxy = obj->getBroadphaseHandle();
- if (proxy)
- {
- m_dynamicsWorld->getPairCache()->cleanProxyFromPairs(proxy,m_dynamicsWorld->getDispatcher());
- }
- }
-}
-
-bool CcdPhysicsEnvironment::IsActiveCcdPhysicsController(CcdPhysicsController *ctrl)
-{
- return (m_controllers.find(ctrl) != m_controllers.end());
-}
-
-void CcdPhysicsEnvironment::AddCcdGraphicController(CcdGraphicController* ctrl)
-{
- if (m_cullingTree && !ctrl->GetBroadphaseHandle())
- {
- btVector3 minAabb;
- btVector3 maxAabb;
- ctrl->GetAabb(minAabb, maxAabb);
-
- ctrl->SetBroadphaseHandle(m_cullingTree->createProxy(
- minAabb,
- maxAabb,
- INVALID_SHAPE_PROXYTYPE, // this parameter is not used
- ctrl,
- 0, // this object does not collision with anything
- 0,
- NULL, // dispatcher => this parameter is not used
- 0));
-
- assert(ctrl->GetBroadphaseHandle());
- }
-}
-
-void CcdPhysicsEnvironment::RemoveCcdGraphicController(CcdGraphicController* ctrl)
-{
- if (m_cullingTree)
- {
- btBroadphaseProxy* bp = ctrl->GetBroadphaseHandle();
- if (bp)
- {
- m_cullingTree->destroyProxy(bp,NULL);
- ctrl->SetBroadphaseHandle(0);
- }
- }
-}
-
-void CcdPhysicsEnvironment::UpdateCcdPhysicsControllerShape(CcdShapeConstructionInfo *shapeInfo)
-{
- for (std::set<CcdPhysicsController *>::iterator it = m_controllers.begin(); it != m_controllers.end(); ++it) {
- CcdPhysicsController *ctrl = *it;
-
- if (ctrl->GetShapeInfo() != shapeInfo)
- continue;
-
- ctrl->ReplaceControllerShape(NULL);
- RefreshCcdPhysicsController(ctrl);
- }
-}
-
-void CcdPhysicsEnvironment::BeginFrame()
-{
-
-}
-
-void CcdPhysicsEnvironment::DebugDrawWorld()
-{
- if (m_dynamicsWorld->getDebugDrawer() && m_dynamicsWorld->getDebugDrawer()->getDebugMode() >0)
- m_dynamicsWorld->debugDrawWorld();
-}
-
-void CcdPhysicsEnvironment::StaticSimulationSubtickCallback(btDynamicsWorld *world, btScalar timeStep)
-{
- // Get the pointer to the CcdPhysicsEnvironment associated with this Bullet world.
- CcdPhysicsEnvironment *this_ = static_cast<CcdPhysicsEnvironment*>(world->getWorldUserInfo());
- this_->SimulationSubtickCallback(timeStep);
-}
-
-void CcdPhysicsEnvironment::SimulationSubtickCallback(btScalar timeStep)
-{
- std::set<CcdPhysicsController*>::iterator it;
-
- for (it = m_controllers.begin(); it != m_controllers.end(); it++) {
- (*it)->SimulationTick(timeStep);
- }
-}
-
-bool CcdPhysicsEnvironment::ProceedDeltaTime(double curTime,float timeStep,float interval)
-{
- std::set<CcdPhysicsController*>::iterator it;
- int i;
-
- // Update Bullet global variables.
- gDeactivationTime = m_deactivationTime;
- gContactBreakingThreshold = m_contactBreakingThreshold;
-
- for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
- {
- (*it)->SynchronizeMotionStates(timeStep);
- }
-
- float subStep = timeStep / float(m_numTimeSubSteps);
- i = m_dynamicsWorld->stepSimulation(interval,25,subStep);//perform always a full simulation step
-//uncomment next line to see where Bullet spend its time (printf in console)
-//CProfileManager::dumpAll();
-
- ProcessFhSprings(curTime,i*subStep);
-
- for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
- {
- (*it)->SynchronizeMotionStates(timeStep);
- }
-
- //for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
- //{
- // (*it)->SynchronizeMotionStates(timeStep);
- //}
-
- for (i=0;i<m_wrapperVehicles.size();i++)
- {
- WrapperVehicle* veh = m_wrapperVehicles[i];
- veh->SyncWheels();
- }
-
-
- CallbackTriggers();
-
- return true;
-}
-
-class ClosestRayResultCallbackNotMe : public btCollisionWorld::ClosestRayResultCallback
-{
- btCollisionObject* m_owner;
- btCollisionObject* m_parent;
-
-public:
- ClosestRayResultCallbackNotMe(const btVector3& rayFromWorld,const btVector3& rayToWorld,btCollisionObject* owner,btCollisionObject* parent)
- :btCollisionWorld::ClosestRayResultCallback(rayFromWorld,rayToWorld),
- m_owner(owner),
- m_parent(parent)
- {
-
- }
-
- virtual bool needsCollision(btBroadphaseProxy* proxy0) const
- {
- //don't collide with self
- if (proxy0->m_clientObject == m_owner)
- return false;
-
- if (proxy0->m_clientObject == m_parent)
- return false;
-
- return btCollisionWorld::ClosestRayResultCallback::needsCollision(proxy0);
- }
-
-};
-
-void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval)
-{
- std::set<CcdPhysicsController*>::iterator it;
- // Add epsilon to the tick rate for numerical stability
- int numIter = (int)(interval*(KX_KetsjiEngine::GetTicRate() + 0.001f));
-
- for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
- {
- CcdPhysicsController* ctrl = (*it);
- btRigidBody* body = ctrl->GetRigidBody();
-
- 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();
- btRigidBody* parentBody = parentCtrl?parentCtrl->GetRigidBody() : 0;
- btRigidBody* cl_object = parentBody ? parentBody : body;
-
- if (body->isStaticOrKinematicObject())
- continue;
-
- btVector3 rayDirLocal(0,0,-10);
-
- //m_dynamicsWorld
- //ctrl->GetRigidBody();
- btVector3 rayFromWorld = body->getCenterOfMassPosition();
- //btVector3 rayToWorld = rayFromWorld + body->getCenterOfMassTransform().getBasis() * rayDirLocal;
- //ray always points down the z axis in world space...
- btVector3 rayToWorld = rayFromWorld + rayDirLocal;
-
- ClosestRayResultCallbackNotMe resultCallback(rayFromWorld,rayToWorld,body,parentBody);
-
- m_dynamicsWorld->rayTest(rayFromWorld,rayToWorld,resultCallback);
- if (resultCallback.hasHit())
- {
- //we hit this one: resultCallback.m_collisionObject;
- CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(resultCallback.m_collisionObject->getUserPointer());
-
- if (controller)
- {
- if (controller->GetConstructionInfo().m_fh_distance < SIMD_EPSILON)
- continue;
-
- btRigidBody* hit_object = controller->GetRigidBody();
- if (!hit_object)
- continue;
-
- CcdConstructionInfo& hitObjShapeProps = controller->GetConstructionInfo();
-
- float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->GetConstructionInfo().m_radius;
- if (distance >= hitObjShapeProps.m_fh_distance)
- continue;
-
-
-
- //btVector3 ray_dir = cl_object->getCenterOfMassTransform().getBasis()* rayDirLocal.normalized();
- btVector3 ray_dir = rayDirLocal.normalized();
- btVector3 normal = resultCallback.m_hitNormalWorld;
- normal.normalize();
-
- for (int i=0; i<numIter; i++)
- {
- if (ctrl->GetConstructionInfo().m_do_fh)
- {
- btVector3 lspot = cl_object->getCenterOfMassPosition() +
- rayDirLocal * resultCallback.m_closestHitFraction;
-
-
-
-
- lspot -= hit_object->getCenterOfMassPosition();
- btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot);
- btScalar rel_vel_ray = ray_dir.dot(rel_vel);
- btScalar spring_extent = 1.0f - distance / hitObjShapeProps.m_fh_distance;
-
- btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring;
- btScalar i_damp = rel_vel_ray * hitObjShapeProps.m_fh_damping;
-
- cl_object->setLinearVelocity(cl_object->getLinearVelocity() + (-(i_spring + i_damp) * ray_dir));
- if (hitObjShapeProps.m_fh_normal)
- {
- cl_object->setLinearVelocity(cl_object->getLinearVelocity()+(i_spring + i_damp) *(normal - normal.dot(ray_dir) * ray_dir));
- }
-
- btVector3 lateral = rel_vel - rel_vel_ray * ray_dir;
-
-
- 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;
- const btVector3& friction_scaling = cl_object->getAnisotropicFriction();
- loc_lateral *= friction_scaling;
- lateral = lcs * loc_lateral;
- }
-
- btScalar rel_vel_lateral = lateral.length();
-
- if (rel_vel_lateral > SIMD_EPSILON) {
- btScalar friction_factor = hit_object->getFriction();//cl_object->getFriction();
-
- btScalar max_friction = friction_factor * btMax(btScalar(0.0f), i_spring);
-
- btScalar rel_mom_lateral = rel_vel_lateral / cl_object->getInvMass();
-
- btVector3 friction = (rel_mom_lateral > max_friction) ?
- -lateral * (max_friction / rel_vel_lateral) :
- -lateral;
-
- cl_object->applyCentralImpulse(friction);
- }
- }
-
-
- 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;
- btVector3 ang_vel = cl_object->getAngularVelocity();
-
- // only rotations that tilt relative to the normal are damped
- ang_vel -= ang_vel.dot(normal) * normal;
-
- btVector3 t_damp = ang_vel * hitObjShapeProps.m_fh_damping;
-
- cl_object->setAngularVelocity(cl_object->getAngularVelocity() + (t_spring - t_damp));
- }
- }
- }
- }
- }
- }
-}
-
-int CcdPhysicsEnvironment::GetDebugMode() const
-{
- if (m_debugDrawer) {
- return m_debugDrawer->getDebugMode();
- }
- return 0;
-}
-
-void CcdPhysicsEnvironment::SetDebugMode(int debugMode)
-{
- if (m_debugDrawer) {
- m_debugDrawer->setDebugMode(debugMode);
- }
-}
-
-void CcdPhysicsEnvironment::SetNumIterations(int numIter)
-{
- m_numIterations = numIter;
-}
-void CcdPhysicsEnvironment::SetDeactivationTime(float dTime)
-{
- m_deactivationTime = dTime;
-}
-void CcdPhysicsEnvironment::SetDeactivationLinearTreshold(float linTresh)
-{
- m_linearDeactivationThreshold = linTresh;
-
- // Update from all controllers.
- for (std::set<CcdPhysicsController*>::iterator it = m_controllers.begin(); it != m_controllers.end(); it++) {
- if ((*it)->GetRigidBody())
- (*it)->GetRigidBody()->setSleepingThresholds(m_linearDeactivationThreshold, m_angularDeactivationThreshold);
- }
-}
-void CcdPhysicsEnvironment::SetDeactivationAngularTreshold(float angTresh)
-{
- m_angularDeactivationThreshold = angTresh;
-
- // Update from all controllers.
- for (std::set<CcdPhysicsController*>::iterator it = m_controllers.begin(); it != m_controllers.end(); it++) {
- if ((*it)->GetRigidBody())
- (*it)->GetRigidBody()->setSleepingThresholds(m_linearDeactivationThreshold, m_angularDeactivationThreshold);
- }
-}
-
-void CcdPhysicsEnvironment::SetContactBreakingTreshold(float contactBreakingTreshold)
-{
- m_contactBreakingThreshold = contactBreakingTreshold;
-}
-
-
-void CcdPhysicsEnvironment::SetCcdMode(int ccdMode)
-{
- m_ccdMode = ccdMode;
-}
-
-
-void CcdPhysicsEnvironment::SetSolverSorConstant(float sor)
-{
- m_dynamicsWorld->getSolverInfo().m_sor = sor;
-}
-
-void CcdPhysicsEnvironment::SetSolverTau(float tau)
-{
- m_dynamicsWorld->getSolverInfo().m_tau = tau;
-}
-void CcdPhysicsEnvironment::SetSolverDamping(float damping)
-{
- m_dynamicsWorld->getSolverInfo().m_damping = damping;
-}
-
-
-void CcdPhysicsEnvironment::SetLinearAirDamping(float damping)
-{
- //gLinearAirDamping = damping;
-}
-
-void CcdPhysicsEnvironment::SetUseEpa(bool epa)
-{
- //gUseEpa = epa;
-}
-
-void CcdPhysicsEnvironment::SetSolverType(int solverType)
-{
-
- switch (solverType)
- {
- case 1:
- {
- if (m_solverType != solverType)
- {
-
- m_solver = new btSequentialImpulseConstraintSolver();
-
-
- break;
- }
- }
-
- case 0:
- default:
- if (m_solverType != solverType)
- {
-// m_solver = new OdeConstraintSolver();
-
- break;
- }
-
- };
-
- m_solverType = solverType;
-}
-
-
-
-void CcdPhysicsEnvironment::GetGravity(MT_Vector3& grav)
-{
- const btVector3& gravity = m_dynamicsWorld->getGravity();
- grav[0] = gravity.getX();
- grav[1] = gravity.getY();
- grav[2] = gravity.getZ();
-}
-
-
-void CcdPhysicsEnvironment::SetGravity(float x,float y,float z)
-{
- m_gravity = btVector3(x,y,z);
- m_dynamicsWorld->setGravity(m_gravity);
- m_dynamicsWorld->getWorldInfo().m_gravity.setValue(x,y,z);
-}
-
-
-
-
-static int gConstraintUid = 1;
-
-//Following the COLLADA physics specification for constraints
-int CcdPhysicsEnvironment::CreateUniversalD6Constraint(
- class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther,
- btTransform& frameInA,
- btTransform& frameInB,
- const btVector3& linearMinLimits,
- const btVector3& linearMaxLimits,
- const btVector3& angularMinLimits,
- const btVector3& angularMaxLimits,int flags
-)
-{
-
- bool disableCollisionBetweenLinkedBodies = (0!=(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION));
-
- //we could either add some logic to recognize ball-socket and hinge, or let that up to the user
- //perhaps some warning or hint that hinge/ball-socket is more efficient?
-
-
- btGeneric6DofConstraint* genericConstraint = 0;
- CcdPhysicsController* ctrl0 = (CcdPhysicsController*) ctrlRef;
- CcdPhysicsController* ctrl1 = (CcdPhysicsController*) ctrlOther;
-
- btRigidBody* rb0 = ctrl0->GetRigidBody();
- btRigidBody* rb1 = ctrl1->GetRigidBody();
-
- if (rb1)
- {
-
-
- bool useReferenceFrameA = true;
- genericConstraint = new btGeneric6DofSpringConstraint(
- *rb0,*rb1,
- frameInA,frameInB,useReferenceFrameA);
- genericConstraint->setLinearLowerLimit(linearMinLimits);
- genericConstraint->setLinearUpperLimit(linearMaxLimits);
- genericConstraint->setAngularLowerLimit(angularMinLimits);
- genericConstraint->setAngularUpperLimit(angularMaxLimits);
- } else
- {
- // TODO: Implement single body case...
- //No, we can use a fixed rigidbody in above code, rather than unnecessary duplation of code
-
- }
-
- if (genericConstraint)
- {
- // m_constraints.push_back(genericConstraint);
- m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies);
-
- genericConstraint->setUserConstraintId(gConstraintUid++);
- genericConstraint->setUserConstraintType(PHY_GENERIC_6DOF_CONSTRAINT);
- //64 bit systems can't cast pointer to int. could use size_t instead.
- return genericConstraint->getUserConstraintId();
- }
- return 0;
-}
-
-void CcdPhysicsEnvironment::RemoveConstraintById(int constraintId)
-{
- // For soft body constraints
- if (constraintId == 0)
- return;
-
- int i;
- int numConstraints = m_dynamicsWorld->getNumConstraints();
- for (i=0;i<numConstraints;i++)
- {
- btTypedConstraint* constraint = m_dynamicsWorld->getConstraint(i);
- if (constraint->getUserConstraintId() == constraintId)
- {
- RemoveConstraint(constraint);
- 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;
- }
-}
-
-
-struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
-{
- PHY_IRayCastFilterCallback& m_phyRayFilter;
- const btCollisionShape* m_hitTriangleShape;
- int m_hitTriangleIndex;
-
-
- FilterClosestRayResultCallback (PHY_IRayCastFilterCallback& phyRayFilter,const btVector3& rayFrom,const btVector3& rayTo)
- : btCollisionWorld::ClosestRayResultCallback(rayFrom,rayTo),
- m_phyRayFilter(phyRayFilter),
- m_hitTriangleShape(NULL),
- m_hitTriangleIndex(0)
- {
- }
-
- virtual ~FilterClosestRayResultCallback()
- {
- }
-
- virtual bool needsCollision(btBroadphaseProxy* proxy0) const
- {
- if (!(proxy0->m_collisionFilterGroup & m_collisionFilterMask))
- return false;
- if (!(m_collisionFilterGroup & proxy0->m_collisionFilterMask))
- return false;
- btCollisionObject* object = (btCollisionObject*)proxy0->m_clientObject;
- CcdPhysicsController* phyCtrl = static_cast<CcdPhysicsController*>(object->getUserPointer());
- if (phyCtrl == m_phyRayFilter.m_ignoreController)
- return false;
- return m_phyRayFilter.needBroadphaseRayCast(phyCtrl);
- }
-
- virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace)
- {
- //CcdPhysicsController* curHit = static_cast<CcdPhysicsController*>(rayResult.m_collisionObject->getUserPointer());
- // save shape information as ClosestRayResultCallback::AddSingleResult() does not do it
- if (rayResult.m_localShapeInfo)
- {
- m_hitTriangleShape = rayResult.m_collisionObject->getCollisionShape();
- m_hitTriangleIndex = rayResult.m_localShapeInfo->m_triangleIndex;
- } else
- {
- m_hitTriangleShape = NULL;
- m_hitTriangleIndex = 0;
- }
- return ClosestRayResultCallback::addSingleResult(rayResult,normalInWorldSpace);
- }
-
-};
-
-static bool GetHitTriangle(btCollisionShape* shape, CcdShapeConstructionInfo* shapeInfo, int hitTriangleIndex, btVector3 triangle[])
-{
- // this code is copied from Bullet
- const unsigned char *vertexbase;
- int numverts;
- PHY_ScalarType type;
- int stride;
- const unsigned char *indexbase;
- int indexstride;
- int numfaces;
- PHY_ScalarType indicestype;
- btStridingMeshInterface* meshInterface = shapeInfo->GetMeshInterface();
-
- if (!meshInterface)
- return false;
-
- meshInterface->getLockedReadOnlyVertexIndexBase(
- &vertexbase,
- numverts,
- type,
- stride,
- &indexbase,
- indexstride,
- numfaces,
- indicestype,
- 0);
-
- unsigned int* gfxbase = (unsigned int*)(indexbase+hitTriangleIndex*indexstride);
- const btVector3& meshScaling = shape->getLocalScaling();
- for (int j=2;j>=0;j--)
- {
- int graphicsindex = (indicestype == PHY_SHORT) ? ((unsigned short *)gfxbase)[j] : gfxbase[j];
-
- btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
-
- triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
- }
- meshInterface->unLockReadOnlyVertexBase(0);
- return true;
-}
-
-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);
-
- btVector3 hitPointWorld,normalWorld;
-
- //Either Ray Cast with or without filtering
-
- //btCollisionWorld::ClosestRayResultCallback rayCallback(rayFrom,rayTo);
- FilterClosestRayResultCallback rayCallback(filterCallback,rayFrom,rayTo);
-
-
- PHY_RayCastResult result;
- memset(&result, 0, sizeof(result));
-
- // don't collision with sensor object
- rayCallback.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
- // use faster (less accurate) ray callback, works better with 0 collision margins
- rayCallback.m_flags |= btTriangleRaycastCallback::kF_UseSubSimplexConvexCastRaytest;
- //, ,filterCallback.m_faceNormal);
-
- m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback);
- if (rayCallback.hasHit())
- {
- CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(rayCallback.m_collisionObject->getUserPointer());
- result.m_controller = controller;
- result.m_hitPoint[0] = rayCallback.m_hitPointWorld.getX();
- result.m_hitPoint[1] = rayCallback.m_hitPointWorld.getY();
- result.m_hitPoint[2] = rayCallback.m_hitPointWorld.getZ();
-
- if (rayCallback.m_hitTriangleShape != NULL)
- {
- // identify the mesh polygon
- CcdShapeConstructionInfo* shapeInfo = controller->m_shapeInfo;
- if (shapeInfo)
- {
- btCollisionShape* shape = controller->GetCollisionObject()->getCollisionShape();
- if (shape->isCompound())
- {
- btCompoundShape* compoundShape = (btCompoundShape*)shape;
- CcdShapeConstructionInfo* compoundShapeInfo = shapeInfo;
- // need to search which sub-shape has been hit
- for (int i=0; i<compoundShape->getNumChildShapes(); i++)
- {
- shapeInfo = compoundShapeInfo->GetChildShape(i);
- shape=compoundShape->getChildShape(i);
- if (shape == rayCallback.m_hitTriangleShape)
- break;
- }
- }
- if (shape == rayCallback.m_hitTriangleShape &&
- rayCallback.m_hitTriangleIndex < shapeInfo->m_polygonIndexArray.size())
- {
- // save original collision shape triangle for soft body
- int hitTriangleIndex = rayCallback.m_hitTriangleIndex;
-
- result.m_meshObject = shapeInfo->GetMesh();
- if (shape->isSoftBody())
- {
- // soft body using different face numbering because of randomization
- // hopefully we have stored the original face number in m_tag
- const btSoftBody* softBody = static_cast<const btSoftBody*>(rayCallback.m_collisionObject);
- if (softBody->m_faces[hitTriangleIndex].m_tag != 0)
- {
- rayCallback.m_hitTriangleIndex = (int)((uintptr_t)(softBody->m_faces[hitTriangleIndex].m_tag)-1);
- }
- }
- // retrieve the original mesh polygon (in case of quad->tri conversion)
- result.m_polygon = shapeInfo->m_polygonIndexArray.at(rayCallback.m_hitTriangleIndex);
- // hit triangle in world coordinate, for face normal and UV coordinate
- btVector3 triangle[3];
- bool triangleOK = false;
- if (filterCallback.m_faceUV && (3*rayCallback.m_hitTriangleIndex) < shapeInfo->m_triFaceUVcoArray.size())
- {
- // interpolate the UV coordinate of the hit point
- CcdShapeConstructionInfo::UVco* uvCo = &shapeInfo->m_triFaceUVcoArray[3*rayCallback.m_hitTriangleIndex];
- // 1. get the 3 coordinate of the triangle in world space
- btVector3 v1, v2, v3;
- if (shape->isSoftBody())
- {
- // soft body give points directly in world coordinate
- const btSoftBody* softBody = static_cast<const btSoftBody*>(rayCallback.m_collisionObject);
- v1 = softBody->m_faces[hitTriangleIndex].m_n[0]->m_x;
- v2 = softBody->m_faces[hitTriangleIndex].m_n[1]->m_x;
- v3 = softBody->m_faces[hitTriangleIndex].m_n[2]->m_x;
- } else
- {
- // for rigid body we must apply the world transform
- triangleOK = GetHitTriangle(shape, shapeInfo, hitTriangleIndex, triangle);
- if (!triangleOK)
- // if we cannot get the triangle, no use to continue
- goto SKIP_UV_NORMAL;
- v1 = rayCallback.m_collisionObject->getWorldTransform()(triangle[0]);
- v2 = rayCallback.m_collisionObject->getWorldTransform()(triangle[1]);
- v3 = rayCallback.m_collisionObject->getWorldTransform()(triangle[2]);
- }
- // 2. compute barycentric coordinate of the hit point
- btVector3 v = v2-v1;
- btVector3 w = v3-v1;
- btVector3 u = v.cross(w);
- btScalar A = u.length();
-
- v = v2-rayCallback.m_hitPointWorld;
- w = v3-rayCallback.m_hitPointWorld;
- u = v.cross(w);
- btScalar A1 = u.length();
-
- v = rayCallback.m_hitPointWorld-v1;
- w = v3-v1;
- u = v.cross(w);
- btScalar A2 = u.length();
-
- btVector3 baryCo;
- baryCo.setX(A1/A);
- baryCo.setY(A2/A);
- baryCo.setZ(1.0f-baryCo.getX()-baryCo.getY());
- // 3. compute UV coordinate
- result.m_hitUV[0] = baryCo.getX()*uvCo[0].uv[0] + baryCo.getY()*uvCo[1].uv[0] + baryCo.getZ()*uvCo[2].uv[0];
- result.m_hitUV[1] = baryCo.getX()*uvCo[0].uv[1] + baryCo.getY()*uvCo[1].uv[1] + baryCo.getZ()*uvCo[2].uv[1];
- result.m_hitUVOK = 1;
- }
-
- // Bullet returns the normal from "outside".
- // If the user requests the real normal, compute it now
- if (filterCallback.m_faceNormal)
- {
- if (shape->isSoftBody())
- {
- // we can get the real normal directly from the body
- const btSoftBody* softBody = static_cast<const btSoftBody*>(rayCallback.m_collisionObject);
- rayCallback.m_hitNormalWorld = softBody->m_faces[hitTriangleIndex].m_normal;
- } else
- {
- if (!triangleOK)
- triangleOK = GetHitTriangle(shape, shapeInfo, hitTriangleIndex, triangle);
- if (triangleOK)
- {
- btVector3 triangleNormal;
- triangleNormal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]);
- rayCallback.m_hitNormalWorld = rayCallback.m_collisionObject->getWorldTransform().getBasis()*triangleNormal;
- }
- }
- }
- SKIP_UV_NORMAL:
- ;
- }
- }
- }
- if (rayCallback.m_hitNormalWorld.length2() > (SIMD_EPSILON*SIMD_EPSILON))
- {
- rayCallback.m_hitNormalWorld.normalize();
- } else
- {
- rayCallback.m_hitNormalWorld.setValue(1,0,0);
- }
- result.m_hitNormal[0] = rayCallback.m_hitNormalWorld.getX();
- result.m_hitNormal[1] = rayCallback.m_hitNormalWorld.getY();
- result.m_hitNormal[2] = rayCallback.m_hitNormalWorld.getZ();
- filterCallback.reportHit(&result);
- }
-
-
- return result.m_controller;
-}
-
-// Handles occlusion culling.
-// The implementation is based on the CDTestFramework
-struct OcclusionBuffer
-{
- struct WriteOCL
- {
- static inline bool Process(btScalar &q, btScalar v)
- {
- if (q < v) {
- q = v;
- }
- return false;
- }
- static inline void Occlusion(bool &flag)
- {
- flag = true;
- }
- };
-
- struct QueryOCL
- {
- static inline bool Process(btScalar &q, btScalar v)
- {
- return (q <= v);
- }
- static inline void Occlusion(bool &flag)
- {
- }
- };
-
- btScalar *m_buffer;
- size_t m_bufferSize;
- bool m_initialized;
- bool m_occlusion;
- int m_sizes[2];
- btScalar m_scales[2];
- btScalar m_offsets[2];
- btScalar m_wtc[16]; // world to clip transform
- btScalar m_mtc[16]; // model to clip transform
- // constructor: size=largest dimension of the buffer.
- // Buffer size depends on aspect ratio
- OcclusionBuffer()
- {
- m_initialized = false;
- m_occlusion = false;
- m_buffer = NULL;
- m_bufferSize = 0;
- }
- // multiplication of column major matrices: m = m1 * m2
- template<typename T1, typename T2>
- void CMmat4mul(btScalar *m, const T1 *m1, const T2 *m2)
- {
- m[0] = btScalar(m1[0] * m2[0] + m1[4] * m2[1] + m1[8] * m2[2] + m1[12] * m2[3]);
- m[1] = btScalar(m1[1] * m2[0] + m1[5] * m2[1] + m1[9] * m2[2] + m1[13] * m2[3]);
- m[2] = btScalar(m1[2] * m2[0] + m1[6] * m2[1] + m1[10] * m2[2] + m1[14] * m2[3]);
- m[3] = btScalar(m1[3] * m2[0] + m1[7] * m2[1] + m1[11] * m2[2] + m1[15] * m2[3]);
-
- m[4] = btScalar(m1[0] * m2[4] + m1[4] * m2[5] + m1[8] * m2[6] + m1[12] * m2[7]);
- m[5] = btScalar(m1[1] * m2[4] + m1[5] * m2[5] + m1[9] * m2[6] + m1[13] * m2[7]);
- m[6] = btScalar(m1[2] * m2[4] + m1[6] * m2[5] + m1[10] * m2[6] + m1[14] * m2[7]);
- m[7] = btScalar(m1[3] * m2[4] + m1[7] * m2[5] + m1[11] * m2[6] + m1[15] * m2[7]);
-
- m[8] = btScalar(m1[0] * m2[8] + m1[4] * m2[9] + m1[8] * m2[10] + m1[12] * m2[11]);
- m[9] = btScalar(m1[1] * m2[8] + m1[5] * m2[9] + m1[9] * m2[10] + m1[13] * m2[11]);
- m[10] = btScalar(m1[2] * m2[8] + m1[6] * m2[9] + m1[10] * m2[10] + m1[14] * m2[11]);
- m[11] = btScalar(m1[3] * m2[8] + m1[7] * m2[9] + m1[11] * m2[10] + m1[15] * m2[11]);
-
- m[12] = btScalar(m1[0] * m2[12] + m1[4] * m2[13] + m1[8] * m2[14] + m1[12] * m2[15]);
- m[13] = btScalar(m1[1] * m2[12] + m1[5] * m2[13] + m1[9] * m2[14] + m1[13] * m2[15]);
- m[14] = btScalar(m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15]);
- m[15] = btScalar(m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]);
- }
-
- void setup(int size, const int *view, float modelview[16], float projection[16])
- {
- m_initialized = false;
- m_occlusion = false;
- // compute the size of the buffer
- int maxsize = (view[2] > view[3]) ? view[2] : view[3];
- assert(maxsize > 0);
- double ratio = 1.0 / (2 * maxsize);
- // ensure even number
- m_sizes[0] = 2 * ((int)(size * view[2] * ratio + 0.5));
- m_sizes[1] = 2 * ((int)(size * view[3] * ratio + 0.5));
- m_scales[0] = btScalar(m_sizes[0] / 2);
- m_scales[1] = btScalar(m_sizes[1] / 2);
- m_offsets[0] = m_scales[0] + 0.5f;
- m_offsets[1] = m_scales[1] + 0.5f;
- // prepare matrix
- // at this time of the rendering, the modelview matrix is the
- // world to camera transformation and the projection matrix is
- // camera to clip transformation. combine both so that
- CMmat4mul(m_wtc, projection, modelview);
- }
-
- void initialize()
- {
- size_t newsize = (m_sizes[0] * m_sizes[1]) * sizeof(btScalar);
- if (m_buffer) {
- // see if we can reuse
- if (newsize > m_bufferSize) {
- free(m_buffer);
- m_buffer = NULL;
- m_bufferSize = 0;
- }
- }
- if (!m_buffer) {
- m_buffer = (btScalar *)calloc(1, newsize);
- m_bufferSize = newsize;
- }
- else {
- // buffer exists already, just clears it
- memset(m_buffer, 0, newsize);
- }
- // memory allocate must succeed
- assert(m_buffer != NULL);
- m_initialized = true;
- m_occlusion = false;
- }
-
- void SetModelMatrix(float *fl)
- {
- CMmat4mul(m_mtc,m_wtc,fl);
- if (!m_initialized) {
- initialize();
- }
- }
-
- // transform a segment in world coordinate to clip coordinate
- void transformW(const btVector3 &x, btVector4 &t)
- {
- t[0] = x[0] * m_wtc[0] + x[1] * m_wtc[4] + x[2] * m_wtc[8] + m_wtc[12];
- t[1] = x[0] * m_wtc[1] + x[1] * m_wtc[5] + x[2] * m_wtc[9] + m_wtc[13];
- t[2] = x[0] * m_wtc[2] + x[1] * m_wtc[6] + x[2] * m_wtc[10] + m_wtc[14];
- t[3] = x[0] * m_wtc[3] + x[1] * m_wtc[7] + x[2] * m_wtc[11] + m_wtc[15];
- }
-
- void transformM(const float *x, btVector4 &t)
- {
- t[0] = x[0] * m_mtc[0] + x[1] * m_mtc[4] + x[2] * m_mtc[8] + m_mtc[12];
- t[1] = x[0] * m_mtc[1] + x[1] * m_mtc[5] + x[2] * m_mtc[9] + m_mtc[13];
- t[2] = x[0] * m_mtc[2] + x[1] * m_mtc[6] + x[2] * m_mtc[10] + m_mtc[14];
- t[3] = x[0] * m_mtc[3] + x[1] * m_mtc[7] + x[2] * m_mtc[11] + m_mtc[15];
- }
- // convert polygon to device coordinates
- static bool project(btVector4 *p, int n)
- {
- for (int i = 0; i < n; ++i) {
- p[i][2] = 1 / p[i][3];
- p[i][0] *= p[i][2];
- p[i][1] *= p[i][2];
- }
- return true;
- }
- // pi: closed polygon in clip coordinate, NP = number of segments
- // po: same polygon with clipped segments removed
- template <const int NP>
- static int clip(const btVector4 *pi, btVector4 *po)
- {
- btScalar s[2 * NP];
- btVector4 pn[2 * NP];
- int i, j, m, n, ni;
- // deal with near clipping
- for (i = 0, m = 0; i < NP; ++i) {
- s[i] = pi[i][2] + pi[i][3];
- if (s[i] < 0) {
- m += 1 << i;
- }
- }
- if (m == ((1 << NP) - 1)) {
- return 0;
- }
- if (m != 0) {
- for (i = NP - 1, j = 0, n = 0; j < NP; i = j++) {
- const btVector4 &a = pi[i];
- const btVector4 &b = pi[j];
- const btScalar t = s[i] / (a[3] + a[2] - b[3] - b[2]);
- if ((t > 0) && (t < 1)) {
- pn[n][0] = a[0] + (b[0] - a[0]) * t;
- pn[n][1] = a[1] + (b[1] - a[1]) * t;
- pn[n][2] = a[2] + (b[2] - a[2]) * t;
- pn[n][3] = a[3] + (b[3] - a[3]) * t;
- ++n;
- }
- if (s[j] > 0) {
- pn[n++] = b;
- }
- }
- // ready to test far clipping, start from the modified polygon
- pi = pn;
- ni = n;
- }
- else {
- // no clipping on the near plane, keep same vector
- ni = NP;
- }
- // now deal with far clipping
- for (i = 0, m = 0; i < ni; ++i) {
- s[i] = pi[i][2] - pi[i][3];
- if (s[i] > 0) {
- m += 1 << i;
- }
- }
- if (m == ((1 << ni) - 1)) {
- return 0;
- }
- if (m != 0) {
- for (i = ni - 1, j = 0, n = 0;j < ni; i = j++) {
- const btVector4 &a = pi[i];
- const btVector4 &b = pi[j];
- const btScalar t = s[i] / (a[2] - a[3] - b[2] + b[3]);
- if ((t > 0) && (t < 1)) {
- po[n][0] = a[0] + (b[0] - a[0]) * t;
- po[n][1] = a[1] + (b[1] - a[1]) * t;
- po[n][2] = a[2] + (b[2] - a[2]) * t;
- po[n][3] = a[3] + (b[3] - a[3]) * t;
- ++n;
- }
- if (s[j] < 0) {
- po[n++] = b;
- }
- }
- return n;
- }
- for (int i = 0; i < ni; ++i) {
- po[i] = pi[i];
- }
- return ni;
- }
- // write or check a triangle to buffer. a,b,c in device coordinates (-1,+1)
- template <typename POLICY>
- inline bool draw(const btVector4 &a,
- const btVector4 &b,
- const btVector4 &c,
- const float face,
- const btScalar minarea)
- {
- const btScalar a2 = btCross(b - a, c - a)[2];
- if ((face * a2) < 0.0f || btFabs(a2) < minarea) {
- return false;
- }
- // further down we are normally going to write to the Zbuffer, mark it so
- POLICY::Occlusion(m_occlusion);
-
- int x[3], y[3], ib = 1, ic = 2;
- btScalar z[3];
- x[0] = (int)(a.x() * m_scales[0] + m_offsets[0]);
- y[0] = (int)(a.y() * m_scales[1] + m_offsets[1]);
- z[0] = a.z();
- if (a2 < 0.f) {
- // negative aire is possible with double face => must
- // change the order of b and c otherwise the algorithm doesn't work
- ib = 2;
- ic = 1;
- }
- x[ib] = (int)(b.x() * m_scales[0] + m_offsets[0]);
- x[ic] = (int)(c.x() * m_scales[0] + m_offsets[0]);
- y[ib] = (int)(b.y() * m_scales[1] + m_offsets[1]);
- y[ic] = (int)(c.y() * m_scales[1] + m_offsets[1]);
- z[ib] = b.z();
- z[ic] = c.z();
- const int mix = btMax(0, btMin(x[0], btMin(x[1], x[2])));
- const int mxx = btMin(m_sizes[0], 1 + btMax(x[0], btMax(x[1], x[2])));
- const int miy = btMax(0, btMin(y[0], btMin(y[1], y[2])));
- const int mxy = btMin(m_sizes[1], 1 + btMax(y[0], btMax(y[1], y[2])));
- const int width = mxx - mix;
- const int height = mxy - miy;
- if ((width * height) <= 1) {
- // degenerated in at most one single pixel
- btScalar *scan = &m_buffer[miy * m_sizes[0] + mix];
- // use for loop to detect the case where width or height == 0
- for (int iy = miy; iy < mxy; ++iy) {
- for (int ix = mix; ix < mxx; ++ix) {
- if (POLICY::Process(*scan, z[0])) {
- return true;
- }
- if (POLICY::Process(*scan, z[1])) {
- return true;
- }
- if (POLICY::Process(*scan, z[2])) {
- return true;
- }
- }
- }
- }
- else if (width == 1) {
- // Degenerated in at least 2 vertical lines
- // The algorithm below doesn't work when face has a single pixel width
- // We cannot use general formulas because the plane is degenerated.
- // We have to interpolate along the 3 edges that overlaps and process each pixel.
- // sort the y coord to make formula simpler
- int ytmp;
- btScalar ztmp;
- if (y[0] > y[1]) {
- ytmp = y[1];
- y[1] = y[0];
- y[0] = ytmp;
- ztmp = z[1];
- z[1] = z[0];
- z[0] = ztmp;
- }
- if (y[0] > y[2]) {
- ytmp = y[2];
- y[2] = y[0];
- y[0] = ytmp;
- ztmp = z[2];
- z[2] = z[0];
- z[0] = ztmp;
- }
- if (y[1] > y[2]) {
- ytmp = y[2];
- y[2] = y[1];
- y[1] = ytmp;
- ztmp = z[2];
- z[2] = z[1];
- z[1] = ztmp;
- }
- int dy[] = {y[0] - y[1],
- y[1] - y[2],
- y[2] - y[0]};
- btScalar dzy[3];
- dzy[0] = (dy[0]) ? (z[0] - z[1]) / dy[0] : btScalar(0.0f);
- dzy[1] = (dy[1]) ? (z[1] - z[2]) / dy[1] : btScalar(0.0f);
- dzy[2] = (dy[2]) ? (z[2] - z[0]) / dy[2] : btScalar(0.0f);
- btScalar v[3] = {dzy[0] * (miy - y[0]) + z[0],
- dzy[1] * (miy - y[1]) + z[1],
- dzy[2] * (miy - y[2]) + z[2]};
- dy[0] = y[1] - y[0];
- dy[1] = y[0] - y[1];
- dy[2] = y[2] - y[0];
- btScalar *scan = &m_buffer[miy * m_sizes[0] + mix];
- for (int iy = miy; iy < mxy; ++iy) {
- if (dy[0] >= 0 && POLICY::Process(*scan, v[0])) {
- return true;
- }
- if (dy[1] >= 0 && POLICY::Process(*scan, v[1])) {
- return true;
- }
- if (dy[2] >= 0 && POLICY::Process(*scan, v[2])) {
- return true;
- }
- scan += m_sizes[0];
- v[0] += dzy[0];
- v[1] += dzy[1];
- v[2] += dzy[2];
- dy[0]--;
- dy[1]++;
- dy[2]--;
- }
- }
- else if (height == 1) {
- // Degenerated in at least 2 horizontal lines
- // The algorithm below doesn't work when face has a single pixel width
- // We cannot use general formulas because the plane is degenerated.
- // We have to interpolate along the 3 edges that overlaps and process each pixel.
- int xtmp;
- btScalar ztmp;
- if (x[0] > x[1]) {
- xtmp = x[1];
- x[1] = x[0];
- x[0] = xtmp;
- ztmp = z[1];
- z[1] = z[0];
- z[0] = ztmp;
- }
- if (x[0] > x[2]) {
- xtmp = x[2];
- x[2] = x[0];
- x[0] = xtmp;
- ztmp = z[2];
- z[2] = z[0];
- z[0] = ztmp;
- }
- if (x[1] > x[2]) {
- xtmp = x[2];
- x[2] = x[1];
- x[1] = xtmp;
- ztmp = z[2];
- z[2] = z[1];
- z[1] = ztmp;
- }
- int dx[] = {x[0] - x[1],
- x[1] - x[2],
- x[2] - x[0]};
- btScalar dzx[3];
- dzx[0] = (dx[0]) ? (z[0]-z[1]) / dx[0] : btScalar(0.0f);
- dzx[1] = (dx[1]) ? (z[1]-z[2]) / dx[1] : btScalar(0.0f);
- dzx[2] = (dx[2]) ? (z[2]-z[0]) / dx[2] : btScalar(0.0f);
- btScalar v[3] = {dzx[0] * (mix - x[0]) + z[0],
- dzx[1] * (mix - x[1]) + z[1],
- dzx[2] * (mix - x[2]) + z[2]};
- dx[0] = x[1] - x[0];
- dx[1] = x[0] - x[1];
- dx[2] = x[2] - x[0];
- btScalar *scan = &m_buffer[miy * m_sizes[0] + mix];
- for (int ix = mix; ix < mxx; ++ix) {
- if (dx[0] >= 0 && POLICY::Process(*scan, v[0])) {
- return true;
- }
- if (dx[1] >= 0 && POLICY::Process(*scan, v[1])) {
- return true;
- }
- if (dx[2] >= 0 && POLICY::Process(*scan, v[2])) {
- return true;
- }
- scan++;
- v[0] += dzx[0];
- v[1] += dzx[1];
- v[2] += dzx[2];
- dx[0]--;
- dx[1]++;
- dx[2]--;
- }
- }
- else {
- // general case
- const int dx[] = {y[0] - y[1],
- y[1] - y[2],
- y[2] - y[0]};
- const int dy[] = {x[1] - x[0] - dx[0] * width,
- x[2] - x[1] - dx[1] * width,
- x[0] - x[2] - dx[2] * width};
- const int a = x[2] * y[0] + x[0] * y[1] - x[2] * y[1] - x[0] * y[2] + x[1] * y[2] - x[1] * y[0];
- const btScalar ia = 1 / (btScalar)a;
- const btScalar dzx = ia * (y[2] * (z[1] - z[0]) + y[1] * (z[0] - z[2]) + y[0] * (z[2] - z[1]));
- const btScalar dzy = ia * (x[2] * (z[0] - z[1]) + x[0] * (z[1] - z[2]) + x[1] * (z[2] - z[0])) - (dzx * width);
- int c[] = {miy * x[1] + mix * y[0] - x[1] * y[0] - mix * y[1] + x[0] * y[1] - miy * x[0],
- miy * x[2] + mix * y[1] - x[2] * y[1] - mix * y[2] + x[1] * y[2] - miy * x[1],
- miy * x[0] + mix * y[2] - x[0] * y[2] - mix * y[0] + x[2] * y[0] - miy * x[2]};
- btScalar v = ia * ((z[2] * c[0]) + (z[0] * c[1]) + (z[1] * c[2]));
- btScalar *scan = &m_buffer[miy * m_sizes[0]];
-
- for (int iy = miy; iy < mxy; ++iy) {
- for (int ix = mix; ix < mxx; ++ix) {
- if ((c[0] >= 0) && (c[1] >= 0) && (c[2] >= 0)) {
- if (POLICY::Process(scan[ix], v)) {
- return true;
- }
- }
- c[0] += dx[0]; c[1] += dx[1]; c[2] += dx[2]; v += dzx;
- }
- c[0] += dy[0]; c[1] += dy[1]; c[2] += dy[2]; v += dzy;
- scan += m_sizes[0];
- }
- }
- return false;
- }
- // clip than write or check a polygon
- template <const int NP, typename POLICY>
- inline bool clipDraw(const btVector4 *p,
- const float face,
- btScalar minarea)
- {
- btVector4 o[NP * 2];
- int n = clip<NP>(p, o);
- bool earlyexit = false;
- if (n) {
- project(o, n);
- for (int i = 2; i < n && !earlyexit; ++i) {
- earlyexit |= draw<POLICY>(o[0], o[i - 1], o[i], face, minarea);
- }
- }
- return earlyexit;
- }
- // add a triangle (in model coordinate)
- // face = 0.f if face is double side,
- // = 1.f if face is single sided and scale is positive
- // = -1.f if face is single sided and scale is negative
- void appendOccluderM(const float *a,
- const float *b,
- const float *c,
- const float face)
- {
- btVector4 p[3];
- transformM(a, p[0]);
- transformM(b, p[1]);
- transformM(c, p[2]);
- clipDraw<3, WriteOCL>(p, face, btScalar(0.0f));
- }
- // add a quad (in model coordinate)
- void appendOccluderM(const float *a,
- const float *b,
- const float *c,
- const float *d,
- const float face)
- {
- btVector4 p[4];
- transformM(a, p[0]);
- transformM(b, p[1]);
- transformM(c, p[2]);
- transformM(d, p[3]);
- clipDraw<4, WriteOCL>(p, face, btScalar(0.0f));
- }
- // query occluder for a box (c=center, e=extend) in world coordinate
- inline bool queryOccluderW(const btVector3 &c,
- const btVector3 &e)
- {
- if (!m_occlusion) {
- // no occlusion yet, no need to check
- return true;
- }
- btVector4 x[8];
- transformW(btVector3(c[0] - e[0], c[1] - e[1], c[2] - e[2]), x[0]);
- transformW(btVector3(c[0] + e[0], c[1] - e[1], c[2] - e[2]), x[1]);
- transformW(btVector3(c[0] + e[0], c[1] + e[1], c[2] - e[2]), x[2]);
- transformW(btVector3(c[0] - e[0], c[1] + e[1], c[2] - e[2]), x[3]);
- transformW(btVector3(c[0] - e[0], c[1] - e[1], c[2] + e[2]), x[4]);
- transformW(btVector3(c[0] + e[0], c[1] - e[1], c[2] + e[2]), x[5]);
- transformW(btVector3(c[0] + e[0], c[1] + e[1], c[2] + e[2]), x[6]);
- transformW(btVector3(c[0] - e[0], c[1] + e[1], c[2] + e[2]), x[7]);
-
- for (int i = 0; i < 8; ++i) {
- // the box is clipped, it's probably a large box, don't waste our time to check
- if ((x[i][2] + x[i][3]) <= 0) {
- return true;
- }
- }
- static const int d[] = {1, 0, 3, 2,
- 4, 5, 6, 7,
- 4, 7, 3, 0,
- 6, 5, 1, 2,
- 7, 6, 2, 3,
- 5, 4, 0, 1};
- for (unsigned int i = 0; i < (sizeof(d) / sizeof(d[0]));) {
- const btVector4 p[] = {x[d[i + 0]],
- x[d[i + 1]],
- x[d[i + 2]],
- x[d[i + 3]]};
- i += 4;
- if (clipDraw<4, QueryOCL>(p, 1.0f, 0.0f)) {
- return true;
- }
- }
- return false;
- }
-};
-
-
-struct DbvtCullingCallback : btDbvt::ICollide
-{
- PHY_CullingCallback m_clientCallback;
- void* m_userData;
- OcclusionBuffer *m_ocb;
-
- DbvtCullingCallback(PHY_CullingCallback clientCallback, void* userData)
- {
- m_clientCallback = clientCallback;
- m_userData = userData;
- m_ocb = NULL;
- }
- bool Descent(const btDbvtNode* node)
- {
- return(m_ocb->queryOccluderW(node->volume.Center(),node->volume.Extents()));
- }
- void Process(const btDbvtNode* node,btScalar depth)
- {
- Process(node);
- }
- void Process(const btDbvtNode* leaf)
- {
- 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();
- if (m_ocb)
- {
- // means we are doing occlusion culling. Check if this object is an occluders
- KX_GameObject* gameobj = KX_GameObject::GetClientObject(info);
- if (gameobj && gameobj->GetOccluder())
- {
- float *fl = gameobj->GetOpenGLMatrixPtr()->getPointer();
- // this will create the occlusion buffer if not already done
- // and compute the transformation from model local space to clip space
- m_ocb->SetModelMatrix(fl);
- float face = (gameobj->IsNegativeScaling()) ? -1.0f : 1.0f;
- // walk through the meshes and for each add to buffer
- for (int i=0; i<gameobj->GetMeshCount(); i++)
- {
- RAS_MeshObject* meshobj = gameobj->GetMesh(i);
- const float *v1, *v2, *v3, *v4;
-
- int polycount = meshobj->NumPolygons();
- for (int j=0; j<polycount; j++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(j);
- switch (poly->VertexCount())
- {
- case 3:
- v1 = poly->GetVertex(0)->getXYZ();
- v2 = poly->GetVertex(1)->getXYZ();
- v3 = poly->GetVertex(2)->getXYZ();
- m_ocb->appendOccluderM(v1,v2,v3,((poly->IsTwoside())?0.f:face));
- break;
- case 4:
- v1 = poly->GetVertex(0)->getXYZ();
- v2 = poly->GetVertex(1)->getXYZ();
- v3 = poly->GetVertex(2)->getXYZ();
- v4 = poly->GetVertex(3)->getXYZ();
- m_ocb->appendOccluderM(v1,v2,v3,v4,((poly->IsTwoside())?0.f:face));
- break;
- }
- }
- }
- }
- }
- if (info)
- (*m_clientCallback)(info, m_userData);
- }
-};
-
-static OcclusionBuffer gOcb;
-bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, float modelview[16], float projection[16])
-{
- if (!m_cullingTree)
- return false;
- DbvtCullingCallback dispatcher(callback, userData);
- btVector3 planes_n[6];
- btScalar planes_o[6];
- if (nplanes > 6)
- nplanes = 6;
- for (int i=0; i<nplanes; i++)
- {
- planes_n[i].setValue(planes[i][0], planes[i][1], planes[i][2]);
- planes_o[i] = planes[i][3];
- }
- // if occlusionRes != 0 => occlusion culling
- if (occlusionRes)
- {
- gOcb.setup(occlusionRes, viewport, modelview, projection);
- dispatcher.m_ocb = &gOcb;
- // occlusion culling, the direction of the view is taken from the first plan which MUST be the near plane
- btDbvt::collideOCL(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher);
- btDbvt::collideOCL(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher);
- }
- else {
- btDbvt::collideKDOP(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,nplanes,dispatcher);
- btDbvt::collideKDOP(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,nplanes,dispatcher);
- }
- return true;
-}
-
-int CcdPhysicsEnvironment::GetNumContactPoints()
-{
- return 0;
-}
-
-void CcdPhysicsEnvironment::GetContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)
-{
-
-}
-
-
-
-
-btBroadphaseInterface* CcdPhysicsEnvironment::GetBroadphase()
-{
- return m_dynamicsWorld->getBroadphase();
-}
-
-btDispatcher* CcdPhysicsEnvironment::GetDispatcher()
-{
- return m_dynamicsWorld->getDispatcher();
-}
-
-void CcdPhysicsEnvironment::MergeEnvironment(PHY_IPhysicsEnvironment *other_env)
-{
- CcdPhysicsEnvironment *other = dynamic_cast<CcdPhysicsEnvironment*>(other_env);
- if (other == NULL) {
- printf("KX_Scene::MergeScene: Other scene is not using Bullet physics, not merging physics.\n");
- return;
- }
-
- std::set<CcdPhysicsController*>::iterator it;
-
- while (other->m_controllers.begin() != other->m_controllers.end())
- {
- it= other->m_controllers.begin();
- CcdPhysicsController* ctrl= (*it);
-
- other->RemoveCcdPhysicsController(ctrl);
- this->AddCcdPhysicsController(ctrl);
- }
-}
-
-CcdPhysicsEnvironment::~CcdPhysicsEnvironment()
-{
-
-#ifdef NEW_BULLET_VEHICLE_SUPPORT
- m_wrapperVehicles.clear();
-#endif //NEW_BULLET_VEHICLE_SUPPORT
-
- //m_broadphase->DestroyScene();
- //delete broadphase ? release reference on broadphase ?
-
- //first delete scene, then dispatcher, because pairs have to release manifolds on the dispatcher
- //delete m_dispatcher;
- delete m_dynamicsWorld;
-
-
- if (NULL != m_ownPairCache)
- delete m_ownPairCache;
-
- if (NULL != m_ownDispatcher)
- delete m_ownDispatcher;
-
- if (NULL != m_solver)
- delete m_solver;
-
- if (NULL != m_debugDrawer)
- delete m_debugDrawer;
-
- if (NULL != m_filterCallback)
- delete m_filterCallback;
-
- if (NULL != m_ghostPairCallback)
- delete m_ghostPairCallback;
-
- if (NULL != m_collisionConfiguration)
- delete m_collisionConfiguration;
-
- if (NULL != m_broadphase)
- delete m_broadphase;
-
- if (NULL != m_cullingTree)
- delete m_cullingTree;
-
- if (NULL != m_cullingCache)
- delete m_cullingCache;
-
-}
-
-
-float CcdPhysicsEnvironment::GetConstraintParam(int constraintId,int param)
-{
- btTypedConstraint* typedConstraint = GetConstraintById(constraintId);
- if (!typedConstraint)
- return 0.0f;
-
- switch (typedConstraint->getUserConstraintType())
- {
- case PHY_GENERIC_6DOF_CONSTRAINT:
- {
-
- switch (param)
- {
- case 0: case 1: case 2:
- {
- //param = 0..2 are linear constraint values
- btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
- genCons->calculateTransforms();
- return genCons->getRelativePivotPosition(param);
- break;
- }
- case 3: case 4: case 5:
- {
- //param = 3..5 are relative constraint (Euler) angles
- btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
- genCons->calculateTransforms();
- return genCons->getAngle(param-3);
- break;
- }
- default:
- {
- }
- }
- break;
- };
- default:
- {
- };
- };
- return 0.f;
-}
-
-void CcdPhysicsEnvironment::SetConstraintParam(int constraintId,int param,float value0,float value1)
-{
- btTypedConstraint* typedConstraint = GetConstraintById(constraintId);
- if (!typedConstraint)
- return;
-
- switch (typedConstraint->getUserConstraintType())
- {
- case PHY_GENERIC_6DOF_CONSTRAINT:
- {
-
- switch (param)
- {
- case 0: case 1: case 2: case 3: case 4: case 5:
- {
- //param = 0..5 are constraint limits, with low/high limit value
- btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
- genCons->setLimit(param,value0,value1);
- break;
- }
- case 6: case 7: case 8:
- {
- //param = 6,7,8 are translational motors, with value0=target velocity, value1 = max motor force
- btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
- int transMotorIndex = param-6;
- btTranslationalLimitMotor* transMotor = genCons->getTranslationalLimitMotor();
- transMotor->m_targetVelocity[transMotorIndex] = value0;
- transMotor->m_maxMotorForce[transMotorIndex] = value1;
- transMotor->m_enableMotor[transMotorIndex] = (value1>0.f);
- break;
- }
- case 9: case 10: case 11:
- {
- //param = 9,10,11 are rotational motors, with value0=target velocity, value1 = max motor force
- btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
- int angMotorIndex = param-9;
- btRotationalLimitMotor* rotMotor = genCons->getRotationalLimitMotor(angMotorIndex);
- rotMotor->m_enableMotor = (value1 > 0.f);
- rotMotor->m_targetVelocity = value0;
- rotMotor->m_maxMotorForce = value1;
- break;
- }
-
- case 12: case 13: case 14: case 15: case 16: case 17:
- {
- //param 12-17 are for motorized springs on each of the degrees of freedom
- btGeneric6DofSpringConstraint* genCons = (btGeneric6DofSpringConstraint*)typedConstraint;
- int springIndex = param-12;
- if (value0!=0.f)
- {
- bool springEnabled = true;
- genCons->setStiffness(springIndex,value0);
- genCons->setDamping(springIndex,value1);
- genCons->enableSpring(springIndex,springEnabled);
- genCons->setEquilibriumPoint(springIndex);
- } else
- {
- bool springEnabled = false;
- genCons->enableSpring(springIndex,springEnabled);
- }
- break;
- }
-
- default:
- {
- }
- };
- break;
- };
- case PHY_CONE_TWIST_CONSTRAINT:
- {
- switch (param)
- {
- case 3: case 4: case 5:
- {
- //param = 3,4,5 are constraint limits, high limit values
- btConeTwistConstraint* coneTwist = (btConeTwistConstraint*)typedConstraint;
- if (value1<0.0f)
- coneTwist->setLimit(param,btScalar(BT_LARGE_FLOAT));
- else
- coneTwist->setLimit(param,value1);
- break;
- }
- default:
- {
- }
- };
- break;
- };
- case PHY_ANGULAR_CONSTRAINT:
- case PHY_LINEHINGE_CONSTRAINT:
- {
- switch (param)
- {
- case 3:
- {
- //param = 3 is a constraint limit, with low/high limit value
- btHingeConstraint* hingeCons = (btHingeConstraint*)typedConstraint;
- hingeCons->setLimit(value0,value1);
- break;
- }
- default:
- {
- }
- }
- break;
- };
- default:
- {
- };
- };
-}
-
-btTypedConstraint* CcdPhysicsEnvironment::GetConstraintById(int constraintId)
-{
- // For soft body constraints
- if (constraintId == 0)
- return NULL;
-
- int numConstraints = m_dynamicsWorld->getNumConstraints();
- int i;
- for (i=0;i<numConstraints;i++)
- {
- btTypedConstraint* constraint = m_dynamicsWorld->getConstraint(i);
- if (constraint->getUserConstraintId()==constraintId)
- {
- return constraint;
- }
- }
- return 0;
-}
-
-
-void CcdPhysicsEnvironment::AddSensor(PHY_IPhysicsController* ctrl)
-{
- CcdPhysicsController* ctrl1 = (CcdPhysicsController* )ctrl;
- AddCcdPhysicsController(ctrl1);
-}
-
-bool CcdPhysicsEnvironment::RemoveCollisionCallback(PHY_IPhysicsController* ctrl)
-{
- CcdPhysicsController* ccdCtrl = (CcdPhysicsController*)ctrl;
- return ccdCtrl->Unregister();
-}
-
-
-void CcdPhysicsEnvironment::RemoveSensor(PHY_IPhysicsController* ctrl)
-{
- RemoveCcdPhysicsController((CcdPhysicsController*)ctrl);
-}
-
-void CcdPhysicsEnvironment::AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
-{
- /* printf("addTouchCallback\n(response class = %i)\n",response_class);
-
- //map PHY_ convention into SM_ convention
- switch (response_class)
- {
- case PHY_FH_RESPONSE:
- printf("PHY_FH_RESPONSE\n");
- break;
- case PHY_SENSOR_RESPONSE:
- printf("PHY_SENSOR_RESPONSE\n");
- break;
- case PHY_CAMERA_RESPONSE:
- printf("PHY_CAMERA_RESPONSE\n");
- break;
- case PHY_OBJECT_RESPONSE:
- printf("PHY_OBJECT_RESPONSE\n");
- break;
- case PHY_STATIC_RESPONSE:
- printf("PHY_STATIC_RESPONSE\n");
- break;
- default:
- assert(0);
- return;
- }
- */
-
- m_triggerCallbacks[response_class] = callback;
- m_triggerCallbacksUserPtrs[response_class] = user;
-
-}
-bool CcdPhysicsEnvironment::RequestCollisionCallback(PHY_IPhysicsController* ctrl)
-{
- CcdPhysicsController* ccdCtrl = static_cast<CcdPhysicsController*>(ctrl);
- return ccdCtrl->Register();
-}
-
-void CcdPhysicsEnvironment::CallbackTriggers()
-{
- bool draw_contact_points = m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints);
-
- if (!m_triggerCallbacks[PHY_OBJECT_RESPONSE] && !draw_contact_points)
- return;
-
- //walk over all overlapping pairs, and if one of the involved bodies is registered for trigger callback, perform callback
- btDispatcher* dispatcher = m_dynamicsWorld->getDispatcher();
- int numManifolds = dispatcher->getNumManifolds();
- for (int i=0;i<numManifolds;i++)
- {
- bool colliding_ctrl0 = true;
- btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
- int numContacts = manifold->getNumContacts();
- if (!numContacts) continue;
-
- const btRigidBody* rb0 = static_cast<const btRigidBody*>(manifold->getBody0());
- const btRigidBody* rb1 = static_cast<const btRigidBody*>(manifold->getBody1());
- if (draw_contact_points)
- {
- for (int j=0;j<numContacts;j++)
- {
- btVector3 color(1,1,0);
- const btManifoldPoint& cp = manifold->getContactPoint(j);
- m_debugDrawer->drawContactPoint(cp.m_positionWorldOnB,
- cp.m_normalWorldOnB,
- cp.getDistance(),
- cp.getLifeTime(),
- color);
- }
- }
-
- //m_internalOwner is set in 'addPhysicsController'
- CcdPhysicsController* ctrl0 = static_cast<CcdPhysicsController*>(rb0->getUserPointer());
- CcdPhysicsController* ctrl1 = static_cast<CcdPhysicsController*>(rb1->getUserPointer());
- bool usecallback = false;
-
- // Test if one of the controller is registered and use collision callback.
- if (ctrl0->Registered())
- usecallback = true;
- else if (ctrl1->Registered()) {
- colliding_ctrl0 = false;
- usecallback = true;
- }
-
- if (usecallback) {
- static PHY_CollData coll_data;
- const btManifoldPoint &cp = manifold->getContactPoint(0);
-
- /* Make sure that "point1" is always on the object we report on, and
- * "point2" on the other object. Also ensure the normal is oriented
- * correctly. */
- btVector3 point1 = colliding_ctrl0 ? cp.m_positionWorldOnA : cp.m_positionWorldOnB;
- btVector3 point2 = colliding_ctrl0 ? cp.m_positionWorldOnB : cp.m_positionWorldOnA;
- btVector3 normal = colliding_ctrl0 ? -cp.m_normalWorldOnB : cp.m_normalWorldOnB;
-
- coll_data.m_point1 = MT_Vector3(point1.m_floats);
- coll_data.m_point2 = MT_Vector3(point2.m_floats);
- coll_data.m_normal = MT_Vector3(normal.m_floats);
-
- m_triggerCallbacks[PHY_OBJECT_RESPONSE](m_triggerCallbacksUserPtrs[PHY_OBJECT_RESPONSE],
- ctrl0, ctrl1, &coll_data);
- }
- // Bullet does not refresh the manifold contact point for object without contact response
- // may need to remove this when a newer Bullet version is integrated
- if (!dispatcher->needsResponse(rb0, rb1))
- {
- // Refresh algorithm fails sometimes when there is penetration
- // (usuall the case with ghost and sensor objects)
- // Let's just clear the manifold, in any case, it is recomputed on each frame.
- manifold->clearManifold(); //refreshContactPoints(rb0->getCenterOfMassTransform(),rb1->getCenterOfMassTransform());
- }
- }
-}
-
-// This call back is called before a pair is added in the cache
-// Handy to remove objects that must be ignored by sensors
-bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
-{
- btCollisionObject *colObj0, *colObj1;
- CcdPhysicsController *sensorCtrl, *objCtrl;
-
- KX_GameObject *kxObj0 = KX_GameObject::GetClientObject(
- (KX_ClientObjectInfo*)
- ((CcdPhysicsController*)
- (((btCollisionObject*)proxy0->m_clientObject)->getUserPointer()))
- ->GetNewClientInfo());
- KX_GameObject *kxObj1 = KX_GameObject::GetClientObject(
- (KX_ClientObjectInfo*)
- ((CcdPhysicsController*)
- (((btCollisionObject*)proxy1->m_clientObject)->getUserPointer()))
- ->GetNewClientInfo());
-
- // First check the filters. Note that this is called during scene
- // conversion, so we can't assume the KX_GameObject instances exist. This
- // may make some objects erroneously collide on the first frame, but the
- // alternative is to have them erroneously miss.
- bool collides;
- collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
- collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
- if (kxObj0 && kxObj1) {
- collides = collides && kxObj0->CheckCollision(kxObj1);
- collides = collides && kxObj1->CheckCollision(kxObj0);
- }
- if (!collides)
- return false;
-
- // additional check for sensor object
- if (proxy0->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger)
- {
- // this is a sensor object, the other one can't be a sensor object because
- // they exclude each other in the above test
- assert(!(proxy1->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger));
- colObj0 = (btCollisionObject*)proxy0->m_clientObject;
- colObj1 = (btCollisionObject*)proxy1->m_clientObject;
- }
- else if (proxy1->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger)
- {
- colObj0 = (btCollisionObject*)proxy1->m_clientObject;
- colObj1 = (btCollisionObject*)proxy0->m_clientObject;
- }
- else
- {
- return true;
- }
- if (!colObj0 || !colObj1)
- return false;
- sensorCtrl = static_cast<CcdPhysicsController*>(colObj0->getUserPointer());
- objCtrl = static_cast<CcdPhysicsController*>(colObj1->getUserPointer());
- if (m_physEnv->m_triggerCallbacks[PHY_BROADPH_RESPONSE])
- {
- return m_physEnv->m_triggerCallbacks[PHY_BROADPH_RESPONSE](m_physEnv->m_triggerCallbacksUserPtrs[PHY_BROADPH_RESPONSE], sensorCtrl, objCtrl, 0);
- }
- return true;
-}
-
-
-#ifdef NEW_BULLET_VEHICLE_SUPPORT
-
-//complex constraint for vehicles
-PHY_IVehicle* CcdPhysicsEnvironment::GetVehicleConstraint(int constraintId)
-{
- int i;
-
- int numVehicles = m_wrapperVehicles.size();
- for (i=0;i<numVehicles;i++)
- {
- WrapperVehicle* wrapperVehicle = m_wrapperVehicles[i];
- if (wrapperVehicle->GetVehicle()->getUserConstraintId() == constraintId)
- return wrapperVehicle;
- }
-
- return 0;
-}
-
-#endif //NEW_BULLET_VEHICLE_SUPPORT
-
-
-PHY_ICharacter* CcdPhysicsEnvironment::GetCharacterController(KX_GameObject *ob)
-{
- CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController();
- return (controller) ? dynamic_cast<BlenderBulletCharacterController*>(controller->GetCharacterController()) : NULL;
-}
-
-
-PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radius,const MT_Vector3& position)
-{
-
- CcdConstructionInfo cinfo;
- memset(&cinfo, 0, sizeof(cinfo)); /* avoid uninitialized values */
- cinfo.m_collisionShape = new btSphereShape(radius); // memory leak! The shape is not deleted by Bullet and we cannot add it to the KX_Scene.m_shapes list
- cinfo.m_MotionState = 0;
- cinfo.m_physicsEnv = this;
- // declare this object as Dyamic rather than static!!
- // The reason as it is designed to detect all type of object, including static object
- // It would cause static-static message to be printed on the console otherwise
- cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_STATIC_OBJECT;
- DefaultMotionState* motionState = new DefaultMotionState();
- cinfo.m_MotionState = motionState;
- // we will add later the possibility to select the filter from option
- cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
- cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter;
- cinfo.m_bSensor = true;
- motionState->m_worldTransform.setIdentity();
- motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2]));
-
- CcdPhysicsController* sphereController = new CcdPhysicsController(cinfo);
-
- return sphereController;
-}
-
-int findClosestNode(btSoftBody* sb,const btVector3& worldPoint);
-int findClosestNode(btSoftBody* sb,const btVector3& worldPoint)
-{
- int node = -1;
-
- btSoftBody::tNodeArray& nodes(sb->m_nodes);
- float maxDistSqr = 1e30f;
-
- for (int n=0;n<nodes.size();n++)
- {
- btScalar distSqr = (nodes[n].m_x - worldPoint).length2();
- if (distSqr<maxDistSqr)
- {
- maxDistSqr = distSqr;
- node = n;
- }
- }
- return node;
-}
-
-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,
- float axis2X,float axis2Y,float axis2Z,int flags
- )
-{
-
- bool disableCollisionBetweenLinkedBodies = (0!=(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION));
-
-
-
- CcdPhysicsController* c0 = (CcdPhysicsController*)ctrl0;
- CcdPhysicsController* c1 = (CcdPhysicsController*)ctrl1;
-
- btRigidBody* rb0 = c0 ? c0->GetRigidBody() : 0;
- btRigidBody* rb1 = c1 ? c1->GetRigidBody() : 0;
-
-
-
-
- bool rb0static = rb0 ? rb0->isStaticOrKinematicObject() : true;
- bool rb1static = rb1 ? rb1->isStaticOrKinematicObject() : true;
-
- btCollisionObject* colObj0 = c0->GetCollisionObject();
- if (!colObj0)
- {
- return 0;
- }
-
- btVector3 pivotInA(pivotX,pivotY,pivotZ);
-
-
-
- //it might be a soft body, let's try
- btSoftBody* sb0 = c0 ? c0->GetSoftBody() : 0;
- btSoftBody* sb1 = c1 ? c1->GetSoftBody() : 0;
- if (sb0 && sb1)
- {
- //not between two soft bodies?
- return 0;
- }
-
- if (sb0)
- {
- //either cluster or node attach, let's find closest node first
- //the soft body doesn't have a 'real' world transform, so get its initial world transform for now
- btVector3 pivotPointSoftWorld = sb0->m_initialWorldTransform(pivotInA);
- int node=findClosestNode(sb0,pivotPointSoftWorld);
- if (node >=0)
- {
- bool clusterconstaint = false;
-/*
- switch (type)
- {
- case PHY_LINEHINGE_CONSTRAINT:
- {
- if (sb0->clusterCount() && rb1)
- {
- btSoftBody::LJoint::Specs ls;
- ls.erp=0.5f;
- ls.position=sb0->clusterCom(0);
- sb0->appendLinearJoint(ls,rb1);
- clusterconstaint = true;
- break;
- }
- }
- case PHY_GENERIC_6DOF_CONSTRAINT:
- {
- if (sb0->clusterCount() && rb1)
- {
- btSoftBody::AJoint::Specs as;
- as.erp = 1;
- as.cfm = 1;
- as.axis.setValue(axisX,axisY,axisZ);
- sb0->appendAngularJoint(as,rb1);
- clusterconstaint = true;
- break;
- }
-
- break;
- }
- default:
- {
-
- }
- };
- */
-
- if (!clusterconstaint)
- {
- if (rb1)
- {
- sb0->appendAnchor(node,rb1,disableCollisionBetweenLinkedBodies);
- } else
- {
- sb0->setMass(node,0.f);
- }
- }
-
-
- }
- return 0;//can't remove soft body anchors yet
- }
-
- if (sb1)
- {
- btVector3 pivotPointAWorld = colObj0->getWorldTransform()(pivotInA);
- int node=findClosestNode(sb1,pivotPointAWorld);
- if (node >=0)
- {
- bool clusterconstaint = false;
-
- /*
- switch (type)
- {
- case PHY_LINEHINGE_CONSTRAINT:
- {
- if (sb1->clusterCount() && rb0)
- {
- btSoftBody::LJoint::Specs ls;
- ls.erp=0.5f;
- ls.position=sb1->clusterCom(0);
- sb1->appendLinearJoint(ls,rb0);
- clusterconstaint = true;
- break;
- }
- }
- case PHY_GENERIC_6DOF_CONSTRAINT:
- {
- if (sb1->clusterCount() && rb0)
- {
- btSoftBody::AJoint::Specs as;
- as.erp = 1;
- as.cfm = 1;
- as.axis.setValue(axisX,axisY,axisZ);
- sb1->appendAngularJoint(as,rb0);
- clusterconstaint = true;
- break;
- }
-
- break;
- }
- default:
- {
-
-
- }
- };*/
-
-
- if (!clusterconstaint)
- {
- if (rb0)
- {
- sb1->appendAnchor(node,rb0,disableCollisionBetweenLinkedBodies);
- } else
- {
- sb1->setMass(node,0.f);
- }
- }
-
-
- }
- return 0;//can't remove soft body anchors yet
- }
-
- if (rb0static && rb1static)
- {
-
- return 0;
- }
-
-
- if (!rb0)
- return 0;
-
- btVector3 pivotInB = rb1 ? rb1->getCenterOfMassTransform().inverse()(rb0->getCenterOfMassTransform()(pivotInA)) :
- rb0->getCenterOfMassTransform() * pivotInA;
- btVector3 axisInA(axisX,axisY,axisZ);
-
-
- bool angularOnly = false;
-
- switch (type)
- {
- case PHY_POINT2POINT_CONSTRAINT:
- {
- // If either of the controllers is missing, we can't do anything.
- if (!c0 || !c1) return 0;
-
- btPoint2PointConstraint* p2p = 0;
-
- if (rb1)
- {
- p2p = new btPoint2PointConstraint(*rb0,
- *rb1,pivotInA,pivotInB);
- } else
- {
- p2p = new btPoint2PointConstraint(*rb0,
- pivotInA);
- }
-
- c0->addCcdConstraintRef(p2p);
- c1->addCcdConstraintRef(p2p);
- m_dynamicsWorld->addConstraint(p2p,disableCollisionBetweenLinkedBodies);
-// m_constraints.push_back(p2p);
-
- p2p->setUserConstraintId(gConstraintUid++);
- p2p->setUserConstraintType(type);
- //64 bit systems can't cast pointer to int. could use size_t instead.
- return p2p->getUserConstraintId();
-
- break;
- }
-
- case PHY_GENERIC_6DOF_CONSTRAINT:
- {
- // If either of the controllers is missing, we can't do anything.
- if (!c0 || !c1) return 0;
-
- btGeneric6DofConstraint* genericConstraint = 0;
-
- if (rb1)
- {
- btTransform frameInA;
- btTransform frameInB;
-
- btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z);
- if (axis1.length() == 0.0f)
- {
- btPlaneSpace1( axisInA, axis1, axis2 );
- }
-
- frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(),
- axisInA.y(), axis1.y(), axis2.y(),
- axisInA.z(), axis1.z(), axis2.z() );
- frameInA.setOrigin( pivotInA );
-
- btTransform inv = rb1->getCenterOfMassTransform().inverse();
-
- btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA;
-
- frameInB = inv * globalFrameA;
- bool useReferenceFrameA = true;
-
- genericConstraint = new btGeneric6DofSpringConstraint(
- *rb0,*rb1,
- frameInA,frameInB,useReferenceFrameA);
-
-
- } else
- {
- static btRigidBody s_fixedObject2( 0,0,0);
- btTransform frameInA;
- btTransform frameInB;
-
- btVector3 axis1, axis2;
- btPlaneSpace1( axisInA, axis1, axis2 );
-
- frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(),
- axisInA.y(), axis1.y(), axis2.y(),
- axisInA.z(), axis1.z(), axis2.z() );
-
- frameInA.setOrigin( pivotInA );
-
- ///frameInB in worldspace
- frameInB = rb0->getCenterOfMassTransform() * frameInA;
-
- bool useReferenceFrameA = true;
- genericConstraint = new btGeneric6DofSpringConstraint(
- *rb0,s_fixedObject2,
- frameInA,frameInB,useReferenceFrameA);
- }
-
- if (genericConstraint)
- {
- //m_constraints.push_back(genericConstraint);
- c0->addCcdConstraintRef(genericConstraint);
- c1->addCcdConstraintRef(genericConstraint);
- m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies);
- genericConstraint->setUserConstraintId(gConstraintUid++);
- genericConstraint->setUserConstraintType(type);
- //64 bit systems can't cast pointer to int. could use size_t instead.
- return genericConstraint->getUserConstraintId();
- }
-
- break;
- }
- case PHY_CONE_TWIST_CONSTRAINT:
- {
- // If either of the controllers is missing, we can't do anything.
- if (!c0 || !c1) return 0;
-
- btConeTwistConstraint* coneTwistContraint = 0;
-
-
- if (rb1)
- {
- btTransform frameInA;
- btTransform frameInB;
-
- btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z);
- if (axis1.length() == 0.0f)
- {
- btPlaneSpace1( axisInA, axis1, axis2 );
- }
-
- frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(),
- axisInA.y(), axis1.y(), axis2.y(),
- axisInA.z(), axis1.z(), axis2.z() );
- frameInA.setOrigin( pivotInA );
-
- btTransform inv = rb1->getCenterOfMassTransform().inverse();
-
- btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA;
-
- frameInB = inv * globalFrameA;
-
- coneTwistContraint = new btConeTwistConstraint( *rb0,*rb1,
- frameInA,frameInB);
-
-
- } else
- {
- static btRigidBody s_fixedObject2( 0,0,0);
- btTransform frameInA;
- btTransform frameInB;
-
- btVector3 axis1, axis2;
- btPlaneSpace1( axisInA, axis1, axis2 );
-
- frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(),
- axisInA.y(), axis1.y(), axis2.y(),
- axisInA.z(), axis1.z(), axis2.z() );
-
- frameInA.setOrigin( pivotInA );
-
- ///frameInB in worldspace
- frameInB = rb0->getCenterOfMassTransform() * frameInA;
-
- coneTwistContraint = new btConeTwistConstraint(
- *rb0,s_fixedObject2,
- frameInA,frameInB);
- }
-
- if (coneTwistContraint)
- {
- //m_constraints.push_back(genericConstraint);
- c0->addCcdConstraintRef(coneTwistContraint);
- c1->addCcdConstraintRef(coneTwistContraint);
- m_dynamicsWorld->addConstraint(coneTwistContraint,disableCollisionBetweenLinkedBodies);
- coneTwistContraint->setUserConstraintId(gConstraintUid++);
- coneTwistContraint->setUserConstraintType(type);
- //64 bit systems can't cast pointer to int. could use size_t instead.
- return coneTwistContraint->getUserConstraintId();
- }
-
-
-
- break;
- }
- case PHY_ANGULAR_CONSTRAINT:
- angularOnly = true;
-
-
- case PHY_LINEHINGE_CONSTRAINT:
- {
- // If either of the controllers is missing, we can't do anything.
- if (!c0 || !c1) return 0;
-
- btHingeConstraint* hinge = 0;
-
- if (rb1)
- {
- // We know the orientations so we should use them instead of
- // having btHingeConstraint fill in the blanks any way it wants to.
- btTransform frameInA;
- btTransform frameInB;
-
- btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z);
- if (axis1.length() == 0.0f)
- {
- btPlaneSpace1( axisInA, axis1, axis2 );
- }
-
- // Internally btHingeConstraint's hinge-axis is z
- frameInA.getBasis().setValue( axis1.x(), axis2.x(), axisInA.x(),
- axis1.y(), axis2.y(), axisInA.y(),
- axis1.z(), axis2.z(), axisInA.z() );
-
- frameInA.setOrigin( pivotInA );
-
- btTransform inv = rb1->getCenterOfMassTransform().inverse();
-
- btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA;
-
- frameInB = inv * globalFrameA;
-
- hinge = new btHingeConstraint(*rb0,*rb1,frameInA,frameInB);
-
-
- } else
- {
- static btRigidBody s_fixedObject2( 0,0,0);
-
- btTransform frameInA;
- btTransform frameInB;
-
- btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z);
- if (axis1.length() == 0.0f)
- {
- btPlaneSpace1( axisInA, axis1, axis2 );
- }
-
- // Internally btHingeConstraint's hinge-axis is z
- frameInA.getBasis().setValue( axis1.x(), axis2.x(), axisInA.x(),
- axis1.y(), axis2.y(), axisInA.y(),
- axis1.z(), axis2.z(), axisInA.z() );
- frameInA.setOrigin( pivotInA );
- frameInB = rb0->getCenterOfMassTransform() * frameInA;
-
- hinge = new btHingeConstraint(*rb0, s_fixedObject2, frameInA, frameInB);
- }
- hinge->setAngularOnly(angularOnly);
-
- //m_constraints.push_back(hinge);
- c0->addCcdConstraintRef(hinge);
- c1->addCcdConstraintRef(hinge);
- m_dynamicsWorld->addConstraint(hinge,disableCollisionBetweenLinkedBodies);
- hinge->setUserConstraintId(gConstraintUid++);
- hinge->setUserConstraintType(type);
- //64 bit systems can't cast pointer to int. could use size_t instead.
- return hinge->getUserConstraintId();
- break;
- }
-#ifdef NEW_BULLET_VEHICLE_SUPPORT
-
- case PHY_VEHICLE_CONSTRAINT:
- {
- btRaycastVehicle::btVehicleTuning* tuning = new btRaycastVehicle::btVehicleTuning();
- btRigidBody* chassis = rb0;
- btDefaultVehicleRaycaster* raycaster = new BlenderVehicleRaycaster(m_dynamicsWorld);
- btRaycastVehicle* vehicle = new btRaycastVehicle(*tuning,chassis,raycaster);
- WrapperVehicle* wrapperVehicle = new WrapperVehicle(vehicle,ctrl0);
- m_wrapperVehicles.push_back(wrapperVehicle);
- m_dynamicsWorld->addVehicle(vehicle);
- vehicle->setUserConstraintId(gConstraintUid++);
- vehicle->setUserConstraintType(type);
- return vehicle->getUserConstraintId();
-
- break;
- };
-#endif //NEW_BULLET_VEHICLE_SUPPORT
-
- default:
- {
- }
- };
-
- //btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB
-
- return 0;
-
-}
-
-
-
-PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float coneradius,float coneheight)
-{
- CcdConstructionInfo cinfo;
-//don't memset cinfo: this is C++ and values should be set in the constructor!
-
- // we don't need a CcdShapeConstructionInfo for this shape:
- // it is simple enough for the standard copy constructor (see CcdPhysicsController::GetReplica)
- cinfo.m_collisionShape = new btConeShape(coneradius,coneheight);
- cinfo.m_MotionState = 0;
- cinfo.m_physicsEnv = this;
- cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_STATIC_OBJECT;
- DefaultMotionState* motionState = new DefaultMotionState();
- cinfo.m_MotionState = motionState;
-
- // we will add later the possibility to select the filter from option
- cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
- cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter;
- cinfo.m_bSensor = true;
- motionState->m_worldTransform.setIdentity();
-// motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2]));
-
- CcdPhysicsController* sphereController = new CcdPhysicsController(cinfo);
-
-
- return sphereController;
-}
-
-float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid)
-{
- // For soft body constraints
- if (constraintid == 0)
- return 0.0f;
-
- int i;
- int numConstraints = m_dynamicsWorld->getNumConstraints();
- for (i=0;i<numConstraints;i++)
- {
- btTypedConstraint* constraint = m_dynamicsWorld->getConstraint(i);
- if (constraint->getUserConstraintId() == constraintid)
- {
- return constraint->getAppliedImpulse();
- }
- }
-
- return 0.f;
-}
-
-void CcdPhysicsEnvironment::ExportFile(const char* filename)
-{
- btDefaultSerializer* serializer = new btDefaultSerializer();
-
-
- for (int i=0;i<m_dynamicsWorld->getNumCollisionObjects();i++)
- {
-
- btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
-
- CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(colObj->getUserPointer());
- if (controller)
- {
- const char* name = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)controller->GetNewClientInfo())->GetName();
- if (name)
- {
- serializer->registerNameForPointer(colObj,name);
- }
- }
- }
-
- m_dynamicsWorld->serialize(serializer);
-
- FILE* file = fopen(filename,"wb");
- if (file)
- {
- fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
- fclose(file);
- }
-}
-
-struct BlenderDebugDraw : public btIDebugDraw
-{
- BlenderDebugDraw () :
- m_debugMode(0)
- {
- }
-
- int m_debugMode;
-
- virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
- {
- if (m_debugMode >0)
- {
- MT_Vector3 kxfrom(from[0],from[1],from[2]);
- MT_Vector3 kxto(to[0],to[1],to[2]);
- MT_Vector3 kxcolor(color[0],color[1],color[2]);
-
- KX_RasterizerDrawDebugLine(kxfrom,kxto,kxcolor);
- }
- }
-
- virtual void reportErrorWarning(const char* warningString)
- {
-
- }
-
- virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)
- {
- drawLine(PointOnB, PointOnB + normalOnB, color);
- drawSphere(PointOnB, 0.1f, color);
- }
-
- virtual void setDebugMode(int debugMode)
- {
- m_debugMode = debugMode;
- }
- virtual int getDebugMode() const
- {
- return m_debugMode;
- }
- ///todo: find out if Blender can do this
- virtual void draw3dText(const btVector3& location,const char* textString)
- {
-
- }
-
-};
-
-CcdPhysicsEnvironment *CcdPhysicsEnvironment::Create(Scene *blenderscene, bool visualizePhysics)
-{
- CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment((blenderscene->gm.mode & WO_DBVT_CULLING) != 0);
- ccdPhysEnv->SetDebugDrawer(new BlenderDebugDraw());
- ccdPhysEnv->SetDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold);
- ccdPhysEnv->SetDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold);
- ccdPhysEnv->SetDeactivationTime(blenderscene->gm.deactivationtime);
-
- if (visualizePhysics)
- ccdPhysEnv->SetDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints);
-
- return ccdPhysEnv;
-}
-
-void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject *meshobj, DerivedMesh *dm, KX_Scene *kxscene, PHY_ShapeProps *shapeprops, PHY_MaterialProps *smmaterial, PHY_IMotionState *motionstate, int activeLayerBitInfo, bool isCompoundChild, bool hasCompoundChildren)
-{
- Object* blenderobject = gameobj->GetBlenderObject();
-
- bool isbulletdyna = (blenderobject->gameflag & OB_DYNAMIC) != 0;
- bool isbulletsensor = (blenderobject->gameflag & OB_SENSOR) != 0;
- bool isbulletchar = (blenderobject->gameflag & OB_CHARACTER) != 0;
- bool isbulletsoftbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0;
- bool isbulletrigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
- bool useGimpact = false;
- CcdConstructionInfo ci;
- class CcdShapeConstructionInfo *shapeInfo = new CcdShapeConstructionInfo();
-
- // get Root Parent of blenderobject
- Object *blenderparent = blenderobject->parent;
- while (blenderparent && blenderparent->parent) {
- blenderparent = blenderparent->parent;
- }
-
- KX_GameObject *parent = NULL;
- if (blenderparent)
- {
- KX_BlenderSceneConverter *converter = (KX_BlenderSceneConverter*)KX_GetActiveEngine()->GetSceneConverter();
- parent = converter->FindGameObject(blenderparent);
- isbulletsoftbody = false;
- }
-
- if (!isbulletdyna)
- {
- ci.m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
- }
- if ((blenderobject->gameflag & (OB_GHOST | OB_SENSOR | OB_CHARACTER)) != 0)
- {
- ci.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE;
- }
-
- ci.m_MotionState = motionstate;
- ci.m_gravity = btVector3(0,0,0);
- ci.m_linearFactor = btVector3(((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_X_AXIS) !=0)? 0 : 1,
- ((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_AXIS) !=0)? 0 : 1,
- ((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_AXIS) !=0)? 0 : 1);
- ci.m_angularFactor = btVector3(((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_X_ROT_AXIS) !=0)? 0 : 1,
- ((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_ROT_AXIS) !=0)? 0 : 1,
- ((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_ROT_AXIS) !=0)? 0 : 1);
- ci.m_localInertiaTensor =btVector3(0,0,0);
- ci.m_mass = isbulletdyna ? shapeprops->m_mass : 0.f;
- ci.m_clamp_vel_min = shapeprops->m_clamp_vel_min;
- ci.m_clamp_vel_max = shapeprops->m_clamp_vel_max;
- ci.m_clamp_angvel_min = shapeprops->m_clamp_angvel_min;
- ci.m_clamp_angvel_max = shapeprops->m_clamp_angvel_max;
- ci.m_stepHeight = isbulletchar ? shapeprops->m_step_height : 0.f;
- ci.m_jumpSpeed = isbulletchar ? shapeprops->m_jump_speed : 0.f;
- ci.m_fallSpeed = isbulletchar ? shapeprops->m_fall_speed : 0.f;
- ci.m_maxJumps = isbulletchar ? shapeprops->m_max_jumps : 0;
-
- //mmm, for now, take this for the size of the dynamicobject
- // Blender uses inertia for radius of dynamic object
- shapeInfo->m_radius = ci.m_radius = blenderobject->inertia;
- useGimpact = ((isbulletdyna || isbulletsensor) && !isbulletsoftbody);
-
- if (isbulletsoftbody)
- {
- if (blenderobject->bsoft)
- {
- ci.m_margin = blenderobject->bsoft->margin;
- ci.m_gamesoftFlag = blenderobject->bsoft->flag;
-
- ci.m_soft_linStiff = blenderobject->bsoft->linStiff;
- ci.m_soft_angStiff = blenderobject->bsoft->angStiff; /* angular stiffness 0..1 */
- ci.m_soft_volume = blenderobject->bsoft->volume; /* volume preservation 0..1 */
-
- ci.m_soft_viterations = blenderobject->bsoft->viterations; /* Velocities solver iterations */
- ci.m_soft_piterations = blenderobject->bsoft->piterations; /* Positions solver iterations */
- ci.m_soft_diterations = blenderobject->bsoft->diterations; /* Drift solver iterations */
- ci.m_soft_citerations = blenderobject->bsoft->citerations; /* Cluster solver iterations */
-
- ci.m_soft_kSRHR_CL = blenderobject->bsoft->kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
- ci.m_soft_kSKHR_CL = blenderobject->bsoft->kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
- ci.m_soft_kSSHR_CL = blenderobject->bsoft->kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
- ci.m_soft_kSR_SPLT_CL = blenderobject->bsoft->kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
-
- ci.m_soft_kSK_SPLT_CL = blenderobject->bsoft->kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- ci.m_soft_kSS_SPLT_CL = blenderobject->bsoft->kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
- ci.m_soft_kVCF = blenderobject->bsoft->kVCF; /* Velocities correction factor (Baumgarte) */
- ci.m_soft_kDP = blenderobject->bsoft->kDP; /* Damping coefficient [0,1] */
-
- ci.m_soft_kDG = blenderobject->bsoft->kDG; /* Drag coefficient [0,+inf] */
- ci.m_soft_kLF = blenderobject->bsoft->kLF; /* Lift coefficient [0,+inf] */
- ci.m_soft_kPR = blenderobject->bsoft->kPR; /* Pressure coefficient [-inf,+inf] */
- ci.m_soft_kVC = blenderobject->bsoft->kVC; /* Volume conversation coefficient [0,+inf] */
-
- ci.m_soft_kDF = blenderobject->bsoft->kDF; /* Dynamic friction coefficient [0,1] */
- ci.m_soft_kMT = blenderobject->bsoft->kMT; /* Pose matching coefficient [0,1] */
- ci.m_soft_kCHR = blenderobject->bsoft->kCHR; /* Rigid contacts hardness [0,1] */
- ci.m_soft_kKHR = blenderobject->bsoft->kKHR; /* Kinetic contacts hardness [0,1] */
-
- ci.m_soft_kSHR = blenderobject->bsoft->kSHR; /* Soft contacts hardness [0,1] */
- ci.m_soft_kAHR = blenderobject->bsoft->kAHR; /* Anchors hardness [0,1] */
- ci.m_soft_collisionflags = blenderobject->bsoft->collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
- ci.m_soft_numclusteriterations = blenderobject->bsoft->numclusteriterations; /* number of iterations to refine collision clusters*/
-
- }
- else
- {
- ci.m_margin = 0.f;
- ci.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT;
-
- ci.m_soft_linStiff = 0.5f;
- ci.m_soft_angStiff = 1.f; /* angular stiffness 0..1 */
- ci.m_soft_volume = 1.f; /* volume preservation 0..1 */
-
- ci.m_soft_viterations = 0;
- ci.m_soft_piterations = 1;
- ci.m_soft_diterations = 0;
- ci.m_soft_citerations = 4;
-
- ci.m_soft_kSRHR_CL = 0.1f;
- ci.m_soft_kSKHR_CL = 1.f;
- ci.m_soft_kSSHR_CL = 0.5f;
- ci.m_soft_kSR_SPLT_CL = 0.5f;
-
- ci.m_soft_kSK_SPLT_CL = 0.5f;
- ci.m_soft_kSS_SPLT_CL = 0.5f;
- ci.m_soft_kVCF = 1;
- ci.m_soft_kDP = 0;
-
- ci.m_soft_kDG = 0;
- ci.m_soft_kLF = 0;
- ci.m_soft_kPR = 0;
- ci.m_soft_kVC = 0;
-
- ci.m_soft_kDF = 0.2f;
- ci.m_soft_kMT = 0.05f;
- ci.m_soft_kCHR = 1.0f;
- ci.m_soft_kKHR = 0.1f;
-
- ci.m_soft_kSHR = 1.f;
- ci.m_soft_kAHR = 0.7f;
- ci.m_soft_collisionflags = OB_BSB_COL_SDF_RS + OB_BSB_COL_VF_SS;
- ci.m_soft_numclusteriterations = 16;
- }
- }
- else
- {
- ci.m_margin = blenderobject->margin;
- }
-
- ci.m_localInertiaTensor = btVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f);
-
- btCollisionShape* bm = 0;
-
- char bounds = isbulletdyna ? OB_BOUND_SPHERE : OB_BOUND_TRIANGLE_MESH;
- if (!(blenderobject->gameflag & OB_BOUNDS))
- {
- if (blenderobject->gameflag & OB_SOFT_BODY)
- bounds = OB_BOUND_TRIANGLE_MESH;
- else if (blenderobject->gameflag & OB_CHARACTER)
- bounds = OB_BOUND_SPHERE;
- }
- else
- {
- if (ELEM(blenderobject->collision_boundtype, OB_BOUND_CONVEX_HULL, OB_BOUND_TRIANGLE_MESH)
- && blenderobject->type != OB_MESH)
- {
- // Can't use triangle mesh or convex hull on a non-mesh object, fall-back to sphere
- bounds = OB_BOUND_SPHERE;
- }
- else
- bounds = blenderobject->collision_boundtype;
- }
-
- // Get bounds information
- float bounds_center[3], bounds_extends[3];
- BoundBox *bb= BKE_object_boundbox_get(blenderobject);
- if (bb==NULL)
- {
- bounds_center[0] = bounds_center[1] = bounds_center[2] = 0.0f;
- bounds_extends[0] = bounds_extends[1] = bounds_extends[2] = 1.0f;
- }
- else
- {
- bounds_extends[0] = 0.5f * fabsf(bb->vec[0][0] - bb->vec[4][0]);
- bounds_extends[1] = 0.5f * fabsf(bb->vec[0][1] - bb->vec[2][1]);
- bounds_extends[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]);
-
- bounds_center[0] = 0.5f * (bb->vec[0][0] + bb->vec[4][0]);
- bounds_center[1] = 0.5f * (bb->vec[0][1] + bb->vec[2][1]);
- bounds_center[2] = 0.5f * (bb->vec[0][2] + bb->vec[1][2]);
- }
-
- switch (bounds)
- {
- case OB_BOUND_SPHERE:
- {
- //float radius = objprop->m_radius;
- //btVector3 inertiaHalfExtents (
- // radius,
- // radius,
- // radius);
-
- //blender doesn't support multisphere, but for testing:
-
- //bm = new MultiSphereShape(inertiaHalfExtents,,&trans.getOrigin(),&radius,1);
- shapeInfo->m_shapeType = PHY_SHAPE_SPHERE;
- // XXX We calculated the radius but didn't use it?
- // objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], MT_max(bb.m_extends[1], bb.m_extends[2]));
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- };
- case OB_BOUND_BOX:
- {
- shapeInfo->m_halfExtend.setValue(
- 2.f * bounds_extends[0],
- 2.f * bounds_extends[1],
- 2.f * bounds_extends[2]);
-
- shapeInfo->m_halfExtend /= 2.0f;
- shapeInfo->m_halfExtend = shapeInfo->m_halfExtend.absolute();
- shapeInfo->m_shapeType = PHY_SHAPE_BOX;
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- };
- case OB_BOUND_CYLINDER:
- {
- float radius = MT_max(bounds_extends[0], bounds_extends[1]);
- shapeInfo->m_halfExtend.setValue(
- radius,
- radius,
- bounds_extends[2]
- );
- shapeInfo->m_shapeType = PHY_SHAPE_CYLINDER;
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- }
-
- case OB_BOUND_CONE:
- {
- shapeInfo->m_radius = MT_max(bounds_extends[0], bounds_extends[1]);
- shapeInfo->m_height = 2.f * bounds_extends[2];
- shapeInfo->m_shapeType = PHY_SHAPE_CONE;
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- }
- case OB_BOUND_CONVEX_HULL:
- {
- shapeInfo->SetMesh(meshobj, dm,true);
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- }
- case OB_BOUND_CAPSULE:
- {
- shapeInfo->m_radius = MT_max(bounds_extends[0], bounds_extends[1]);
- shapeInfo->m_height = 2.f * (bounds_extends[2] - shapeInfo->m_radius);
- if (shapeInfo->m_height < 0.f)
- shapeInfo->m_height = 0.f;
- shapeInfo->m_shapeType = PHY_SHAPE_CAPSULE;
- bm = shapeInfo->CreateBulletShape(ci.m_margin);
- break;
- }
- case OB_BOUND_TRIANGLE_MESH:
- {
- // mesh shapes can be shared, check first if we already have a shape on that mesh
- class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, dm, false);
- if (sharedShapeInfo != NULL)
- {
- shapeInfo->Release();
- shapeInfo = sharedShapeInfo;
- shapeInfo->AddRef();
- } else
- {
- shapeInfo->SetMesh(meshobj, dm, false);
- }
-
- // Soft bodies can benefit from welding, don't do it on non-soft bodies
- if (isbulletsoftbody)
- {
- // disable welding: it doesn't bring any additional stability and it breaks the relation between soft body collision shape and graphic mesh
- // shapeInfo->setVertexWeldingThreshold1((blenderobject->bsoft) ? blenderobject->bsoft->welding ? 0.f);
- shapeInfo->setVertexWeldingThreshold1(0.f); //todo: expose this to the UI
- }
-
- bm = shapeInfo->CreateBulletShape(ci.m_margin, useGimpact, !isbulletsoftbody);
- //should we compute inertia for dynamic shape?
- //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
-
- break;
- }
- }
-
-
-// ci.m_localInertiaTensor.setValue(0.1f,0.1f,0.1f);
-
- if (!bm)
- {
- delete motionstate;
- shapeInfo->Release();
- return;
- }
-
- //bm->setMargin(ci.m_margin);
-
-
- if (isCompoundChild)
- {
- //find parent, compound shape and add to it
- //take relative transform into account!
- CcdPhysicsController* parentCtrl = (CcdPhysicsController*)parent->GetPhysicsController();
- assert(parentCtrl);
-
- // only makes compound shape if parent has a physics controller (i.e not an empty, etc)
- if (parentCtrl) {
- CcdShapeConstructionInfo* parentShapeInfo = parentCtrl->GetShapeInfo();
- btRigidBody* rigidbody = parentCtrl->GetRigidBody();
- btCollisionShape* colShape = rigidbody->getCollisionShape();
- assert(colShape->isCompound());
- btCompoundShape* compoundShape = (btCompoundShape*)colShape;
-
- // compute the local transform from parent, this may include several node in the chain
- SG_Node* gameNode = gameobj->GetSGNode();
- SG_Node* parentNode = parent->GetSGNode();
- // relative transform
- MT_Vector3 parentScale = parentNode->GetWorldScaling();
- parentScale[0] = MT_Scalar(1.0f)/parentScale[0];
- parentScale[1] = MT_Scalar(1.0f)/parentScale[1];
- parentScale[2] = MT_Scalar(1.0f)/parentScale[2];
- MT_Vector3 relativeScale = gameNode->GetWorldScaling() * parentScale;
- MT_Matrix3x3 parentInvRot = parentNode->GetWorldOrientation().transposed();
- MT_Vector3 relativePos = parentInvRot*((gameNode->GetWorldPosition()-parentNode->GetWorldPosition())*parentScale);
- MT_Matrix3x3 relativeRot = parentInvRot*gameNode->GetWorldOrientation();
-
- shapeInfo->m_childScale.setValue(relativeScale[0],relativeScale[1],relativeScale[2]);
- bm->setLocalScaling(shapeInfo->m_childScale);
- shapeInfo->m_childTrans.getOrigin().setValue(relativePos[0],relativePos[1],relativePos[2]);
- float rot[12];
- relativeRot.getValue(rot);
- shapeInfo->m_childTrans.getBasis().setFromOpenGLSubMatrix(rot);
-
- parentShapeInfo->AddShape(shapeInfo);
- compoundShape->addChildShape(shapeInfo->m_childTrans,bm);
- //do some recalc?
- //recalc inertia for rigidbody
- if (!rigidbody->isStaticOrKinematicObject())
- {
- btVector3 localInertia;
- float mass = 1.f/rigidbody->getInvMass();
- compoundShape->calculateLocalInertia(mass,localInertia);
- rigidbody->setMassProps(mass,localInertia);
- }
- shapeInfo->Release();
- // delete motionstate as it's not used
- delete motionstate;
- }
- return;
- }
-
- if (hasCompoundChildren)
- {
- // create a compound shape info
- CcdShapeConstructionInfo *compoundShapeInfo = new CcdShapeConstructionInfo();
- compoundShapeInfo->m_shapeType = PHY_SHAPE_COMPOUND;
- compoundShapeInfo->AddShape(shapeInfo);
- // create the compound shape manually as we already have the child shape
- btCompoundShape* compoundShape = new btCompoundShape();
- compoundShape->addChildShape(shapeInfo->m_childTrans,bm);
- // now replace the shape
- bm = compoundShape;
- shapeInfo->Release();
- shapeInfo = compoundShapeInfo;
- }
-
-
-
-
-
-
-#ifdef TEST_SIMD_HULL
- if (bm->IsPolyhedral())
- {
- PolyhedralConvexShape* polyhedron = static_cast<PolyhedralConvexShape*>(bm);
- if (!polyhedron->m_optionalHull)
- {
- //first convert vertices in 'Point3' format
- int numPoints = polyhedron->GetNumVertices();
- Point3* points = new Point3[numPoints+1];
- //first 4 points should not be co-planar, so add central point to satisfy MakeHull
- points[0] = Point3(0.f,0.f,0.f);
-
- btVector3 vertex;
- for (int p=0;p<numPoints;p++)
- {
- polyhedron->GetVertex(p,vertex);
- points[p+1] = Point3(vertex.getX(),vertex.getY(),vertex.getZ());
- }
-
- Hull* hull = Hull::MakeHull(numPoints+1,points);
- polyhedron->m_optionalHull = hull;
- }
-
- }
-#endif //TEST_SIMD_HULL
-
-
- ci.m_collisionShape = bm;
- ci.m_shapeInfo = shapeInfo;
- ci.m_friction = smmaterial->m_friction;//tweak the friction a bit, so the default 0.5 works nice
- ci.m_restitution = smmaterial->m_restitution;
- ci.m_physicsEnv = this;
- // drag / damping is inverted
- ci.m_linearDamping = 1.f - shapeprops->m_lin_drag;
- ci.m_angularDamping = 1.f - shapeprops->m_ang_drag;
- //need a bit of damping, else system doesn't behave well
- ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behavior
-
- ci.m_do_anisotropic = shapeprops->m_do_anisotropic;
- ci.m_anisotropicFriction.setValue(shapeprops->m_friction_scaling[0],shapeprops->m_friction_scaling[1],shapeprops->m_friction_scaling[2]);
-
-
-//////////
- //do Fh, do Rot Fh
- ci.m_do_fh = shapeprops->m_do_fh;
- ci.m_do_rot_fh = shapeprops->m_do_rot_fh;
- ci.m_fh_damping = smmaterial->m_fh_damping;
- ci.m_fh_distance = smmaterial->m_fh_distance;
- ci.m_fh_normal = smmaterial->m_fh_normal;
- ci.m_fh_spring = smmaterial->m_fh_spring;
-
- ci.m_collisionFilterGroup =
- (isbulletsensor) ? short(CcdConstructionInfo::SensorFilter) :
- (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) :
- (isbulletchar) ? short(CcdConstructionInfo::CharacterFilter) :
- short(CcdConstructionInfo::StaticFilter);
- ci.m_collisionFilterMask =
- (isbulletsensor) ? short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter) :
- (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) :
- (isbulletchar) ? short(CcdConstructionInfo::AllFilter) :
- short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
- ci.m_bRigid = isbulletdyna && isbulletrigidbody;
- ci.m_bSoft = isbulletsoftbody;
- 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]);
- CcdPhysicsController* physicscontroller = new CcdPhysicsController(ci);
- // shapeInfo is reference counted, decrement now as we don't use it anymore
- if (shapeInfo)
- shapeInfo->Release();
-
- gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
-
- // record animation for dynamic objects
- if (isbulletdyna)
- gameobj->SetRecordAnimation(true);
-
- physicscontroller->SetNewClientInfo(gameobj->getClientInfo());
-
- // don't add automatically sensor object, they are added when a collision sensor is registered
- if (!isbulletsensor && (blenderobject->lay & activeLayerBitInfo) != 0)
- {
- this->AddCcdPhysicsController( physicscontroller);
- }
-
- {
- btRigidBody* rbody = physicscontroller->GetRigidBody();
-
- if (rbody)
- {
- rbody->setLinearFactor(ci.m_linearFactor);
-
- if (isbulletrigidbody)
- {
- rbody->setAngularFactor(ci.m_angularFactor);
- }
-
- if (rbody && (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0)
- {
- rbody->setActivationState(DISABLE_DEACTIVATION);
- }
- }
- }
-
- if (parent)
- physicscontroller->SuspendDynamics(false);
-
- CcdPhysicsController* parentCtrl = parent ? (CcdPhysicsController*)parent->GetPhysicsController() : 0;
- physicscontroller->SetParentCtrl(parentCtrl);
-
-
- //Now done directly in ci.m_collisionFlags so that it propagates to replica
- //if (objprop->m_ghost)
- //{
- // rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
- //}
-
- if (isbulletdyna && !isbulletrigidbody)
- {
-#if 0
- //setting the inertia could achieve similar results to constraint the up
- //but it is prone to instability, so use special 'Angular' constraint
- btVector3 inertia = physicscontroller->GetRigidBody()->getInvInertiaDiagLocal();
- inertia.setX(0.f);
- inertia.setZ(0.f);
-
- physicscontroller->GetRigidBody()->setInvInertiaDiagLocal(inertia);
- physicscontroller->GetRigidBody()->updateInertiaTensor();
-#endif
-
- //this->createConstraint(physicscontroller,0,PHY_ANGULAR_CONSTRAINT,0,0,0,0,0,1);
-
- //Now done directly in ci.m_bRigid so that it propagates to replica
- //physicscontroller->GetRigidBody()->setAngularFactor(0.f);
- ;
- }
-
-
- STR_String materialname;
- if (meshobj)
- materialname = meshobj->GetMaterialName(0);
-
-
-#if 0
- ///test for soft bodies
- if (objprop->m_softbody && physicscontroller)
- {
- btSoftBody* softBody = physicscontroller->GetSoftBody();
- if (softBody && gameobj->GetMesh(0))//only the first mesh, if any
- {
- //should be a mesh then, so add a soft body deformer
- KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer( gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj);
- gameobj->SetDeformer(softbodyDeformer);
- }
- }
-#endif
-}
-
-
-void CcdPhysicsEnvironment::SetupObjectConstraints(KX_GameObject *obj_src, KX_GameObject *obj_dest,
- bRigidBodyJointConstraint *dat)
-{
- PHY_IPhysicsController *phy_src = obj_src->GetPhysicsController();
- PHY_IPhysicsController *phy_dest = obj_dest->GetPhysicsController();
- PHY_IPhysicsEnvironment *phys_env = obj_src->GetScene()->GetPhysicsEnvironment();
-
- /* We need to pass a full constraint frame, not just axis. */
- MT_Matrix3x3 localCFrame(MT_Vector3(dat->axX,dat->axY,dat->axZ));
- MT_Vector3 axis0 = localCFrame.getColumn(0);
- MT_Vector3 axis1 = localCFrame.getColumn(1);
- MT_Vector3 axis2 = localCFrame.getColumn(2);
- MT_Vector3 scale = obj_src->NodeGetWorldScaling();
-
- /* Apply not only the pivot and axis values, but also take scale into count
- * this is not working well, if only one or two axis are scaled, but works ok on
- * homogeneous scaling. */
- int constraintId = phys_env->CreateConstraint(
- phy_src, phy_dest, (PHY_ConstraintType)dat->type,
- (float)(dat->pivX * scale.x()), (float)(dat->pivY * scale.y()), (float)(dat->pivZ * scale.z()),
- (float)(axis0.x() * scale.x()), (float)(axis0.y() * scale.y()), (float)(axis0.z() * scale.z()),
- (float)(axis1.x() * scale.x()), (float)(axis1.y() * scale.y()), (float)(axis1.z() * scale.z()),
- (float)(axis2.x() * scale.x()), (float)(axis2.y() * scale.y()), (float)(axis2.z() * scale.z()),
- dat->flag);
-
- /* PHY_POINT2POINT_CONSTRAINT = 1,
- * PHY_LINEHINGE_CONSTRAINT = 2,
- * PHY_ANGULAR_CONSTRAINT = 3,
- * PHY_CONE_TWIST_CONSTRAINT = 4,
- * PHY_VEHICLE_CONSTRAINT = 11,
- * PHY_GENERIC_6DOF_CONSTRAINT = 12 */
-
- if (!constraintId)
- return;
-
- int dof = 0;
- int dof_max = 0;
- int dofbit = 0;
-
- switch (dat->type) {
- /* Set all the limits for generic 6DOF constraint. */
- case PHY_GENERIC_6DOF_CONSTRAINT:
- dof_max = 6;
- dofbit = 1;
- break;
- /* Set XYZ angular limits for cone twist constraint. */
- case PHY_CONE_TWIST_CONSTRAINT:
- dof = 3;
- dof_max = 6;
- dofbit = 1 << 3;
- break;
- /* Set only X angular limits for line hinge and angular constraint. */
- case PHY_LINEHINGE_CONSTRAINT:
- case PHY_ANGULAR_CONSTRAINT:
- dof = 3;
- dof_max = 4;
- dofbit = 1 << 3;
- break;
- default:
- break;
- }
-
- for (; dof < dof_max; dof++) {
- if (dat->flag & dofbit) {
- phys_env->SetConstraintParam(constraintId, dof, dat->minLimit[dof], dat->maxLimit[dof]);
- }
- else {
- /* minLimit > maxLimit means free (no limit) for this degree of freedom. */
- phys_env->SetConstraintParam(constraintId, dof, 1.0f, -1.0f);
- }
- dofbit <<= 1;
- }
-
-}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
deleted file mode 100644
index a64d2c8f15f..00000000000
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
-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.
-*/
-
-/** \file CcdPhysicsEnvironment.h
- * \ingroup physbullet
- * See also \ref bulletdoc
- */
-
-#ifndef __CCDPHYSICSENVIRONMENT_H__
-#define __CCDPHYSICSENVIRONMENT_H__
-
-#include "PHY_IPhysicsEnvironment.h"
-#include "KX_KetsjiEngine.h"
-
-#include <vector>
-#include <set>
-#include <map>
-class CcdPhysicsController;
-class CcdGraphicController;
-#include "LinearMath/btVector3.h"
-#include "LinearMath/btTransform.h"
-
-
-
-
-class btTypedConstraint;
-class btSimulationIslandManager;
-class btCollisionDispatcher;
-class btDispatcher;
-//#include "btBroadphaseInterface.h"
-
-//switch on/off new vehicle support
-#define NEW_BULLET_VEHICLE_SUPPORT 1
-
-#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
-
-class WrapperVehicle;
-class btPersistentManifold;
-class btBroadphaseInterface;
-struct btDbvtBroadphase;
-class btOverlappingPairCache;
-class btIDebugDraw;
-class btDynamicsWorld;
-class PHY_IVehicle;
-class CcdOverlapFilterCallBack;
-class CcdShapeConstructionInfo;
-
-/** CcdPhysicsEnvironment is an experimental mainloop for physics simulation using optional continuous collision detection.
- * Physics Environment takes care of stepping the simulation and is a container for physics entities.
- * It stores rigidbodies,constraints, materials etc.
- * A derived class may be able to 'construct' entities by loading and/or converting
- */
-class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
-{
- friend class CcdOverlapFilterCallBack;
- btVector3 m_gravity;
-
- // Removes the constraint and his references from the owner and the target.
- void RemoveConstraint(btTypedConstraint *con);
-
-protected:
- btIDebugDraw* m_debugDrawer;
-
- class btDefaultCollisionConfiguration* m_collisionConfiguration;
- class btBroadphaseInterface* m_broadphase; // broadphase for dynamic world
- // for culling only
- btOverlappingPairCache* m_cullingCache;
- struct btDbvtBroadphase* m_cullingTree; // broadphase for culling
-
- //solver iterations
- int m_numIterations;
-
- //timestep subdivisions
- int m_numTimeSubSteps;
-
-
- int m_ccdMode;
- int m_solverType;
- int m_profileTimings;
- bool m_enableSatCollisionDetection;
-
- float m_deactivationTime;
- float m_linearDeactivationThreshold;
- float m_angularDeactivationThreshold;
- float m_contactBreakingThreshold;
-
- void ProcessFhSprings(double curTime,float timeStep);
-
- public:
- CcdPhysicsEnvironment(bool useDbvtCulling, btDispatcher* dispatcher=0, btOverlappingPairCache* pairCache=0);
-
- virtual ~CcdPhysicsEnvironment();
-
- /////////////////////////////////////
- //PHY_IPhysicsEnvironment interface
- /////////////////////////////////////
-
- /// Perform an integration step of duration 'timeStep'.
-
- virtual void SetDebugDrawer(btIDebugDraw* debugDrawer);
-
- 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);
-
- virtual int GetNumTimeSubSteps()
- {
- return m_numTimeSubSteps;
- }
-
- virtual void BeginFrame();
- virtual void EndFrame() {}
- /// Perform an integration step of duration 'timeStep'.
- virtual bool ProceedDeltaTime(double curTime,float timeStep,float interval);
-
- /**
- * Called by Bullet for every physical simulation (sub)tick.
- * Our constructor registers this callback to Bullet, which stores a pointer to 'this' in
- * the btDynamicsWorld::getWorldUserInfo() pointer.
- */
- static void StaticSimulationSubtickCallback(btDynamicsWorld *world, btScalar timeStep);
- void SimulationSubtickCallback(btScalar timeStep);
-
- virtual void DebugDrawWorld();
-// virtual bool proceedDeltaTimeOneStep(float timeStep);
-
- virtual void SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
- {
- SetNumTimeSubSteps((int)(fixedTimeStep / KX_KetsjiEngine::GetTicRate()));
- }
- //returns 0.f if no fixed timestep is used
-
- virtual float GetFixedTimeStep() { return 0.f; }
-
- virtual void SetDebugMode(int debugMode);
- virtual int GetDebugMode()const;
-
- 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,
- 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
- );
-
-
- //Following the COLLADA physics specification for constraints
- virtual int CreateUniversalD6Constraint(
- class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther,
- btTransform& localAttachmentFrameRef,
- btTransform& localAttachmentOther,
- const btVector3& linearMinLimits,
- const btVector3& linearMaxLimits,
- const btVector3& angularMinLimits,
- const btVector3& angularMaxLimits,int flags
- );
-
-
- virtual void SetConstraintParam(int constraintId,int param,float value,float value1);
-
- virtual float GetConstraintParam(int constraintId,int param);
-
- virtual void RemoveConstraintById(int constraintid);
-
- virtual float getAppliedImpulse(int constraintid);
-
-
- virtual void CallbackTriggers();
-
-
-#ifdef NEW_BULLET_VEHICLE_SUPPORT
- //complex constraint for vehicles
- virtual PHY_IVehicle* GetVehicleConstraint(int constraintId);
-#else
- 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);
-
- 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, float modelview[16], float 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);
- //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 void GetContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
-
- //////////////////////
- //CcdPhysicsEnvironment interface
- ////////////////////////
-
- void AddCcdPhysicsController(CcdPhysicsController* ctrl);
-
- bool RemoveCcdPhysicsController(CcdPhysicsController* ctrl);
-
- void UpdateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask);
-
- void RefreshCcdPhysicsController(CcdPhysicsController* ctrl);
-
- bool IsActiveCcdPhysicsController(CcdPhysicsController *ctrl);
-
- void AddCcdGraphicController(CcdGraphicController* ctrl);
-
- void RemoveCcdGraphicController(CcdGraphicController* ctrl);
-
- /**
- * Update all physics controllers shape which use the same shape construction info.
- * Call RecreateControllerShape on controllers which use the same shape
- * construction info that argument shapeInfo.
- * You need to call this function when the shape construction info changed.
- */
- void UpdateCcdPhysicsControllerShape(CcdShapeConstructionInfo *shapeInfo);
-
- btBroadphaseInterface* GetBroadphase();
- btDbvtBroadphase* GetCullingTree() { return m_cullingTree; }
-
- btDispatcher* GetDispatcher();
-
-
- bool IsSatCollisionDetectionEnabled() const
- {
- return m_enableSatCollisionDetection;
- }
-
- void EnableSatCollisionDetection(bool enableSat)
- {
- m_enableSatCollisionDetection = enableSat;
- }
-
-
- const btPersistentManifold* GetManifold(int index) const;
-
-
- void SyncMotionStates(float timeStep);
-
- class btSoftRigidDynamicsWorld* GetDynamicsWorld()
- {
- return m_dynamicsWorld;
- }
-
- class btConstraintSolver* GetConstraintSolver();
-
- void MergeEnvironment(PHY_IPhysicsEnvironment *other_env);
-
- static CcdPhysicsEnvironment *Create(struct Scene *blenderscene, bool visualizePhysics);
-
- virtual void ConvertObject(KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- DerivedMesh* dm,
- KX_Scene* kxscene,
- PHY_ShapeProps* shapeprops,
- PHY_MaterialProps* smmaterial,
- PHY_IMotionState *motionstate,
- int activeLayerBitInfo,
- bool isCompoundChild,
- bool hasCompoundChildren);
-
- /* Set the rigid body joints constraints values for converted objects and replicated group instances. */
- virtual void SetupObjectConstraints(KX_GameObject *obj_src, KX_GameObject *obj_dest,
- bRigidBodyJointConstraint *dat);
-
- protected:
-
-
-
- std::set<CcdPhysicsController*> m_controllers;
-
- PHY_ResponseCallback m_triggerCallbacks[PHY_NUM_RESPONSE];
- void* m_triggerCallbacksUserPtrs[PHY_NUM_RESPONSE];
-
- std::vector<WrapperVehicle*> m_wrapperVehicles;
-
- //use explicit btSoftRigidDynamicsWorld/btDiscreteDynamicsWorld* so that we have access to
- //btDiscreteDynamicsWorld::addRigidBody(body,filter,group)
- //so that we can set the body collision filter/group at the time of creation
- //and not afterwards (breaks the collision system for radar/near sensor)
- //Ideally we would like to have access to this function from the btDynamicsWorld interface
- //class btDynamicsWorld* m_dynamicsWorld;
- class btSoftRigidDynamicsWorld* m_dynamicsWorld;
-
- class btConstraintSolver* m_solver;
-
- class btOverlappingPairCache* m_ownPairCache;
-
- class CcdOverlapFilterCallBack* m_filterCallback;
-
- class btGhostPairCallback* m_ghostPairCallback;
-
- class btDispatcher* m_ownDispatcher;
-
- bool m_scalingPropagated;
-
- virtual void ExportFile(const char* filename);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdPhysicsEnvironment")
-#endif
-};
-
-#endif /* __CCDPHYSICSENVIRONMENT_H__ */
diff --git a/source/gameengine/Physics/Dummy/CMakeLists.txt b/source/gameengine/Physics/Dummy/CMakeLists.txt
deleted file mode 100644
index 692331f1ce4..00000000000
--- a/source/gameengine/Physics/Dummy/CMakeLists.txt
+++ /dev/null
@@ -1,41 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../common
-)
-
-set(INC_SYS
- ../../../../intern/moto/include
-)
-
-set(SRC
- DummyPhysicsEnvironment.cpp
-
- DummyPhysicsEnvironment.h
-)
-
-blender_add_lib(ge_phys_dummy "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
deleted file mode 100644
index 99db56bfcef..00000000000
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
+++ /dev/null
@@ -1,121 +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/Physics/Dummy/DummyPhysicsEnvironment.cpp
- * \ingroup physdummy
- */
-
-
-#include <stddef.h>
-
-#include "DummyPhysicsEnvironment.h"
-#include "PHY_IMotionState.h"
-
-DummyPhysicsEnvironment::DummyPhysicsEnvironment()
-{
- // create physicsengine data
-}
-
-
-
-DummyPhysicsEnvironment::~DummyPhysicsEnvironment()
-{
- //destroy physicsengine data
-}
-
-void DummyPhysicsEnvironment::BeginFrame()
-{
- // beginning of logic frame: apply forces
-}
-
-void DummyPhysicsEnvironment::EndFrame()
-{
- // end of logic frame: clear forces
-}
-
-
-
-bool DummyPhysicsEnvironment::ProceedDeltaTime(double curTime,float timeStep,float interval)
-{
- //step physics simulation, typically perform
-
- //collision detection
- //solve constraints
- //integrate solution
- // return true if an update was done.
- return true;
-}
-void DummyPhysicsEnvironment::SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
-{
-}
-
-float DummyPhysicsEnvironment::GetFixedTimeStep()
-{
- return 0.f;
-}
-
-int DummyPhysicsEnvironment::GetDebugMode() const
-{
- return 0;
-}
-
-void DummyPhysicsEnvironment::SetGravity(float x,float y,float z)
-{
-}
-
-void DummyPhysicsEnvironment::GetGravity(class MT_Vector3& grav)
-{
-}
-
-
-
-
-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
- )
-{
-
- int constraintid = 0;
- return constraintid;
-
-}
-
-void DummyPhysicsEnvironment::RemoveConstraintById(int constraintid)
-{
- if (constraintid)
- {
- }
-}
-
-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
deleted file mode 100644
index 3e9379dd60d..00000000000
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
+++ /dev/null
@@ -1,134 +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 DummyPhysicsEnvironment.h
- * \ingroup physdummy
- */
-
-#ifndef __DUMMYPHYSICSENVIRONMENT_H__
-#define __DUMMYPHYSICSENVIRONMENT_H__
-
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_IMotionState.h"
-
-/**
- * DummyPhysicsEnvironment is an empty placeholder
- * Alternatives are ODE,Sumo and Dynamo PhysicsEnvironments
- * Use DummyPhysicsEnvironment as a base to integrate your own physics engine
- * Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.)
- *
- * A derived class may be able to 'construct' entities by loading and/or converting
- */
-class DummyPhysicsEnvironment : public PHY_IPhysicsEnvironment
-{
-
-public:
- DummyPhysicsEnvironment ();
- virtual ~DummyPhysicsEnvironment ();
- 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 int GetDebugMode() const;
-
- 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,
- 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 RemoveConstraintById(int constraintid);
-
- //complex constraint for vehicles
- virtual PHY_IVehicle* GetVehicleConstraint(int constraintId)
- {
- return 0;
- }
-
- // Character physics wrapper
- 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, float modelview[16], float 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 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 float GetConstraintParam(int constraintId,int param)
- {
- return 0.f;
- }
-
- virtual void MergeEnvironment(PHY_IPhysicsEnvironment *other_env)
- {
- // Dummy, nothing to do here
- }
-
- virtual void ConvertObject(KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- DerivedMesh* dm,
- KX_Scene* kxscene,
- PHY_ShapeProps* shapeprops,
- PHY_MaterialProps* smmaterial,
- PHY_IMotionState *motionstate,
- int activeLayerBitInfo,
- bool isCompoundChild,
- bool hasCompoundChildren)
- {
- // All we need to do is handle the motionstate (we're supposed to own it)
- delete motionstate;
- }
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:DummyPhysicsEnvironment")
-#endif
-};
-
-#endif /* __DUMMYPHYSICSENVIRONMENT_H__ */
diff --git a/source/gameengine/Physics/common/PHY_DynamicTypes.h b/source/gameengine/Physics/common/PHY_DynamicTypes.h
deleted file mode 100644
index d10f48ad7a4..00000000000
--- a/source/gameengine/Physics/common/PHY_DynamicTypes.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-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.
-*/
-
-/** \file PHY_DynamicTypes.h
- * \ingroup phys
- */
-
-#ifndef __PHY_DYNAMICTYPES_H__
-#define __PHY_DYNAMICTYPES_H__
-
-#include "MT_Vector3.h"
-
-struct KX_ClientObjectInfo;
-
-enum
-{
- PHY_FH_RESPONSE,
- PHY_SENSOR_RESPONSE, /* Touch Sensors */
- PHY_CAMERA_RESPONSE, /* Visibility Culling */
- PHY_OBJECT_RESPONSE, /* Object Dynamic Geometry Response */
- PHY_STATIC_RESPONSE, /* Static Geometry Response */
- PHY_BROADPH_RESPONSE, /* broadphase Response */
-
- PHY_NUM_RESPONSE
-};
-
-typedef struct PHY_CollData {
- MT_Vector3 m_point1; /* Point in object1 in world coordinates */
- MT_Vector3 m_point2; /* Point in object2 in world coordinates */
- MT_Vector3 m_normal; /* point2 - point1 */
-} PHY_CollData;
-
-
-typedef bool (*PHY_ResponseCallback)(void *client_data,
- void *client_object1,
- void *client_object2,
- const PHY_CollData *coll_data);
-typedef void (*PHY_CullingCallback)(KX_ClientObjectInfo* info, void* param);
-
-
-/// PHY_PhysicsType enumerates all possible Physics Entities.
-/// It is mainly used to create/add Physics Objects
-
-typedef enum PHY_PhysicsType {
- PHY_CONVEX_RIGIDBODY=16386,
- PHY_CONCAVE_RIGIDBODY=16399,
- PHY_CONVEX_FIXEDBODY=16388,//'collision object'
- PHY_CONCAVE_FIXEDBODY=16401,
- PHY_CONVEX_KINEMATICBODY=16387,//
- PHY_CONCAVE_KINEMATICBODY=16400,
- PHY_CONVEX_PHANTOMBODY=16398,
- PHY_CONCAVE_PHANTOMBODY=16402
-} PHY_PhysicsType;
-
-/// PHY_ConstraintType enumerates all supported Constraint Types
-typedef enum PHY_ConstraintType {
- PHY_POINT2POINT_CONSTRAINT=1,
- PHY_LINEHINGE_CONSTRAINT=2,
- PHY_ANGULAR_CONSTRAINT = 3,//hinge without ball socket
- PHY_CONE_TWIST_CONSTRAINT = 4,
- PHY_VEHICLE_CONSTRAINT=11,//complex 'constraint' that turns a rigidbody into a vehicle
- PHY_GENERIC_6DOF_CONSTRAINT=12,//can leave any of the 6 degree of freedom 'free' or 'locked'
-
-} PHY_ConstraintType;
-
-typedef enum PHY_ShapeType {
- PHY_SHAPE_NONE,
- PHY_SHAPE_BOX,
- PHY_SHAPE_SPHERE,
- PHY_SHAPE_CYLINDER,
- PHY_SHAPE_CONE,
- PHY_SHAPE_CAPSULE,
- PHY_SHAPE_MESH,
- PHY_SHAPE_POLYTOPE,
- PHY_SHAPE_COMPOUND,
- PHY_SHAPE_PROXY
-} PHY_ShapeType;
-
-#endif /* __PHY_DYNAMICTYPES_H__ */
diff --git a/source/gameengine/Physics/common/PHY_ICharacter.h b/source/gameengine/Physics/common/PHY_ICharacter.h
deleted file mode 100644
index 1a924904b7d..00000000000
--- a/source/gameengine/Physics/common/PHY_ICharacter.h
+++ /dev/null
@@ -1,39 +0,0 @@
-
-/** \file PHY_ICharacter.h
- * \ingroup phys
- */
-
-#ifndef __PHY_ICHARACTER_H__
-#define __PHY_ICHARACTER_H__
-
-//PHY_ICharacter provides a generic interface for "character" controllers
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class PHY_ICharacter
-{
-public:
- virtual ~PHY_ICharacter() {};
-
- virtual void Jump()= 0;
- virtual bool OnGround()= 0;
-
- virtual float GetGravity()= 0;
- virtual void SetGravity(float gravity)= 0;
-
- virtual unsigned char GetMaxJumps() = 0;
- virtual void SetMaxJumps(unsigned char maxJumps) = 0;
-
- virtual unsigned char GetJumpCount() = 0;
-
- virtual void SetWalkDirection(const class MT_Vector3& dir)=0;
- virtual MT_Vector3 GetWalkDirection()=0;
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_ICharacter")
-#endif
-};
-
-#endif //__PHY_ICHARACTER_H__
diff --git a/source/gameengine/Physics/common/PHY_IController.h b/source/gameengine/Physics/common/PHY_IController.h
deleted file mode 100644
index 741fae8d2ad..00000000000
--- a/source/gameengine/Physics/common/PHY_IController.h
+++ /dev/null
@@ -1,63 +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 PHY_IController.h
- * \ingroup phys
- */
-
-#ifndef __PHY_ICONTROLLER_H__
-#define __PHY_ICONTROLLER_H__
-
-#include "PHY_DynamicTypes.h"
-
-class PHY_IPhysicsEnvironment;
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/**
- * PHY_IController is the abstract simplified Interface to objects
- * controlled by the physics engine. This includes the physics objects
- * and the graphics object for view frustrum and occlusion culling.
- */
-class PHY_IController
-{
- public:
- virtual ~PHY_IController() {};
- // clientinfo for raycasts for example
- virtual void* GetNewClientInfo()=0;
- virtual void SetNewClientInfo(void* clientinfo)=0;
- virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env)=0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IController")
-#endif
-};
-
-#endif /* __PHY_ICONTROLLER_H__ */
diff --git a/source/gameengine/Physics/common/PHY_IGraphicController.h b/source/gameengine/Physics/common/PHY_IGraphicController.h
deleted file mode 100644
index b047edd93eb..00000000000
--- a/source/gameengine/Physics/common/PHY_IGraphicController.h
+++ /dev/null
@@ -1,60 +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 PHY_IGraphicController.h
- * \ingroup phys
- */
-
-#ifndef __PHY_IGRAPHICCONTROLLER_H__
-#define __PHY_IGRAPHICCONTROLLER_H__
-
-#include "PHY_IController.h"
-
-
-/**
- * PHY_IPhysicsController is the abstract simplified Interface to a physical object.
- * It contains the IMotionState and IDeformableMesh Interfaces.
- */
-class PHY_IGraphicController : public PHY_IController
-{
- public:
- /**
- * SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
- */
- 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 PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate) {return 0;}
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IController")
-#endif
-};
-
-#endif /* __PHY_IGRAPHICCONTROLLER_H__ */
diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h
deleted file mode 100644
index e803d658713..00000000000
--- a/source/gameengine/Physics/common/PHY_IMotionState.h
+++ /dev/null
@@ -1,68 +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 PHY_IMotionState.h
- * \ingroup phys
- */
-
-#ifndef __PHY_IMOTIONSTATE_H__
-#define __PHY_IMOTIONSTATE_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/**
- * PHY_IMotionState is the Interface to explicitly synchronize the world transformation.
- * Default implementations for mayor graphics libraries like OpenGL and DirectX can be provided.
- */
-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;
- // 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 SetWorldPosition(float posX,float posY,float posZ)=0;
- virtual void SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)=0;
-
-
- virtual void CalculateWorldTransformations()=0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IMotionState")
-#endif
-};
-
-#endif /* __PHY_IMOTIONSTATE_H__ */
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h
deleted file mode 100644
index 4c6e8c71ef7..00000000000
--- a/source/gameengine/Physics/common/PHY_IPhysicsController.h
+++ /dev/null
@@ -1,154 +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 PHY_IPhysicsController.h
- * \ingroup phys
- */
-
-#ifndef __PHY_IPHYSICSCONTROLLER_H__
-#define __PHY_IPHYSICSCONTROLLER_H__
-
-#include <vector>
-#include "PHY_IController.h"
-
-class PHY_IMotionState;
-class PHY_IPhysicsEnvironment;
-
-class MT_Vector3;
-class MT_Point3;
-class MT_Matrix3x3;
-
-class KX_GameObject;
-class RAS_MeshObject;
-
-/**
- * PHY_IPhysicsController is the abstract simplified Interface to a physical object.
- * It contains the IMotionState and IDeformableMesh Interfaces.
- */
-class PHY_IPhysicsController : public PHY_IController
-{
-
- public:
- virtual ~PHY_IPhysicsController() {};
- /**
- * SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
- */
- virtual bool SynchronizeMotionStates(float time)=0;
- /**
- * WriteMotionStateToDynamics ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
- */
-
- virtual void WriteMotionStateToDynamics(bool nondynaonly)=0;
- virtual void WriteDynamicsToMotionState()=0;
- 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(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 ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulse,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 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 float GetLinearDamping() const=0;
- virtual float GetAngularDamping() const=0;
- virtual void SetLinearDamping(float damping)=0;
- virtual void SetAngularDamping(float damping)=0;
- virtual void SetDamping(float linear, float angular)=0;
-
- virtual void RefreshCollisions() = 0;
- virtual void SuspendDynamics(bool ghost=false)=0;
- virtual void RestoreDynamics()=0;
-
- virtual void SetActive(bool active)=0;
-
- // reading out information from physics
- 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 PHY_IPhysicsController* GetReplica() {return 0;}
- virtual PHY_IPhysicsController* GetReplicaForSensors() {return 0;}
-
- virtual void CalcXform() =0;
- virtual void SetMargin(float margin) =0;
- virtual float GetMargin() const=0;
- virtual float GetRadius() const=0;
- virtual void SetRadius(float margin) = 0;
-
- virtual float GetLinVelocityMin() const=0;
- virtual void SetLinVelocityMin(float val) = 0;
- virtual float GetLinVelocityMax() const=0;
- virtual void SetLinVelocityMax(float val) = 0;
-
- virtual void SetAngularVelocityMin(float val) = 0;
- virtual float GetAngularVelocityMin() const = 0;
- virtual void SetAngularVelocityMax(float val) = 0;
- virtual float GetAngularVelocityMax() const = 0;
-
- 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;
- virtual bool IsSuspended() const = 0;
-
- virtual bool ReinstancePhysicsShape(KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj) = 0;
-
- /* Method to replicate rigid body joint contraints for group instances. */
- virtual void ReplicateConstraints(KX_GameObject *gameobj, std::vector<KX_GameObject*> constobj) = 0;
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IPhysicsController")
-#endif
-};
-
-#endif /* __PHY_IPHYSICSCONTROLLER_H__ */
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
deleted file mode 100644
index 72ec7b1edd0..00000000000
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ /dev/null
@@ -1,226 +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 PHY_IPhysicsEnvironment.h
- * \ingroup phys
- */
-
-#ifndef __PHY_IPHYSICSENVIRONMENT_H__
-#define __PHY_IPHYSICSENVIRONMENT_H__
-
-#include "PHY_DynamicTypes.h"
-#include "MT_Vector2.h"
-#include "MT_Vector3.h"
-#include "MT_Vector4.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class PHY_IVehicle;
-class PHY_ICharacter;
-class RAS_MeshObject;
-class PHY_IPhysicsController;
-
-
-class RAS_MeshObject;
-struct DerivedMesh;
-class KX_GameObject;
-class KX_Scene;
-
-struct PHY_ShapeProps;
-struct PHY_MaterialProps;
-class PHY_IMotionState;
-struct bRigidBodyJointConstraint;
-
-/**
- * pass back information from rayTest
- */
-struct PHY_RayCastResult
-{
- PHY_IPhysicsController* m_controller;
- MT_Vector3 m_hitPoint;
- MT_Vector3 m_hitNormal;
- const RAS_MeshObject* m_meshObject; // !=NULL for mesh object (only for Bullet controllers)
- int m_polygon; // index of the polygon hit by the ray,
- // only if m_meshObject != NULL
- int m_hitUVOK; // !=0 if UV coordinate in m_hitUV is valid
- MT_Vector2 m_hitUV; // UV coordinates of hit point
-};
-
-/**
- * This class replaces the ignoreController parameter of rayTest function.
- * It allows more sophisticated filtering on the physics controller before computing the ray intersection to save CPU.
- * It is only used to its full extend by the Ccd physics environment (Bullet).
- */
-class PHY_IRayCastFilterCallback
-{
-public:
- PHY_IPhysicsController* m_ignoreController;
- bool m_faceNormal;
- bool m_faceUV;
-
- virtual ~PHY_IRayCastFilterCallback()
- {
- }
-
- virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller)
- {
- return true;
- }
-
- virtual void reportHit(PHY_RayCastResult* result) = 0;
-
- PHY_IRayCastFilterCallback(PHY_IPhysicsController* ignoreController, bool faceNormal=false, bool faceUV=false)
- :m_ignoreController(ignoreController),
- m_faceNormal(faceNormal),
- m_faceUV(faceUV)
- {
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IRayCastFilterCallback")
-#endif
-};
-
-/**
- * Physics Environment takes care of stepping the simulation and is a container for physics entities
- * (rigidbodies,constraints, materials etc.)
- * A derived class may be able to 'construct' entities by loading and/or converting
- */
-class PHY_IPhysicsEnvironment
-{
- public:
- 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;
- ///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;
- //returns 0.f if no fixed timestep is used
- virtual float GetFixedTimeStep()=0;
-
- ///getDebugMode return the actual debug visualization state
- virtual int GetDebugMode()const=0;
- ///setDebugMode is used to support several ways of debug lines, contact point visualization
- virtual void SetDebugMode(int debugMode) {}
- ///setNumIterations set the number of iterations for iterative solvers
- virtual void SetNumIterations(int numIter) {}
- ///setNumTimeSubSteps set the number of divisions of the timestep. Tradeoff quality versus performance.
- 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) {}
- ///setDeactivationLinearTreshold sets the linear velocity treshold, see setDeactivationTime
- virtual void SetDeactivationLinearTreshold(float linTresh) {}
- ///setDeactivationAngularTreshold sets the angular velocity treshold, see setDeactivationTime
- virtual void SetDeactivationAngularTreshold(float angTresh) {}
- ///setContactBreakingTreshold sets tresholds to do with contact point management
- virtual void SetContactBreakingTreshold(float contactBreakingTreshold) {}
- ///continuous collision detection mode, very experimental for Bullet
- 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) {}
- ///setSolverType, internal setting, chooses solvertype, PSOR, Dantzig, impulse based, penalty based
- virtual void SetSolverType(int solverType) {}
- ///setTau sets the spring constant of a penalty based solver
- virtual void SetSolverTau(float tau) {}
- ///setDamping sets the damper constant of a penalty based solver
- virtual void SetSolverDamping(float damping) {}
- ///linear air damping for rigidbodies
- virtual void SetLinearAirDamping(float damping) {}
- /// penetrationdepth setting
- virtual void SetUseEpa(bool epa) {}
-
- 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,
- 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 RemoveConstraintById(int constraintid) = 0;
- virtual float GetAppliedImpulse(int constraintid) { return 0.0f; }
-
-
- //complex constraint for vehicles
- virtual PHY_IVehicle* GetVehicleConstraint(int constraintId) =0;
-
- // Character physics wrapper
- 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;
-
- //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, float modelview[16], float 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;
- //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 ExportFile(const char* filename) {};
-
- virtual void MergeEnvironment(PHY_IPhysicsEnvironment *other_env) = 0;
-
- virtual void ConvertObject(KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- DerivedMesh* dm,
- KX_Scene* kxscene,
- PHY_ShapeProps* shapeprops,
- PHY_MaterialProps* smmaterial,
- PHY_IMotionState *motionstate,
- int activeLayerBitInfo,
- bool isCompoundChild,
- bool hasCompoundChildren) = 0;
-
- /* Set the rigid body joints constraints values for converted objects and replicated group instances. */
- virtual void SetupObjectConstraints(KX_GameObject *obj_src, KX_GameObject *obj_dest,
- bRigidBodyJointConstraint *dat) {}
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IPhysicsEnvironment")
-#endif
-};
-
-#endif /* __PHY_IPHYSICSENVIRONMENT_H__ */
diff --git a/source/gameengine/Physics/common/PHY_IVehicle.h b/source/gameengine/Physics/common/PHY_IVehicle.h
deleted file mode 100644
index 7e4a49e923e..00000000000
--- a/source/gameengine/Physics/common/PHY_IVehicle.h
+++ /dev/null
@@ -1,69 +0,0 @@
-
-/** \file PHY_IVehicle.h
- * \ingroup phys
- */
-
-#ifndef __PHY_IVEHICLE_H__
-#define __PHY_IVEHICLE_H__
-
-//PHY_IVehicle provides a generic interface for (raycast based) vehicles. Mostly targetting 4 wheel cars and 2 wheel motorbikes.
-
-class PHY_IMotionState;
-#include "PHY_DynamicTypes.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class PHY_IVehicle
-{
-public:
- virtual ~PHY_IVehicle() {};
-
- virtual void AddWheel(
- PHY_IMotionState* motionState,
- MT_Vector3 connectionPoint,
- MT_Vector3 downDirection,
- MT_Vector3 axleDirection,
- float suspensionRestLength,
- float wheelRadius,
- bool hasSteering
- ) = 0;
-
-
- virtual int GetNumWheels() const = 0;
-
- virtual void GetWheelPosition(int wheelIndex,float& posX,float& posY,float& posZ) const = 0;
- virtual void GetWheelOrientationQuaternion(int wheelIndex,float& quatX,float& quatY,float& quatZ,float& quatW) const = 0;
- virtual float GetWheelRotation(int wheelIndex) const = 0;
-
- virtual int GetUserConstraintId() const =0;
- virtual int GetUserConstraintType() const =0;
-
- //some basic steering/braking/tuning/balancing (bikes)
-
- virtual void SetSteeringValue(float steering,int wheelIndex) = 0;
-
- virtual void ApplyEngineForce(float force,int wheelIndex) = 0;
-
- virtual void ApplyBraking(float braking,int wheelIndex) = 0;
-
- virtual void SetWheelFriction(float friction,int wheelIndex) = 0;
-
- virtual void SetSuspensionStiffness(float suspensionStiffness,int wheelIndex) = 0;
-
- virtual void SetSuspensionDamping(float suspensionStiffness,int wheelIndex) = 0;
-
- virtual void SetSuspensionCompression(float suspensionStiffness,int wheelIndex) = 0;
-
- virtual void SetRollInfluence(float rollInfluence,int wheelIndex) = 0;
-
- virtual void SetCoordinateSystem(int rightIndex,int upIndex,int forwardIndex) =0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IVehicle")
-#endif
-};
-
-#endif /* __PHY_IVEHICLE_H__ */
diff --git a/source/gameengine/Physics/common/PHY_Pro.h b/source/gameengine/Physics/common/PHY_Pro.h
deleted file mode 100644
index bfe574e73cb..00000000000
--- a/source/gameengine/Physics/common/PHY_Pro.h
+++ /dev/null
@@ -1,68 +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 PHY_Pro.h
- * \ingroup phys
- */
-
-#ifndef __PHY_PRO_H__
-#define __PHY_PRO_H__
-
-#include <MT_Scalar.h>
-
-// Properties of dynamic objects
-struct PHY_ShapeProps {
- MT_Scalar m_mass; // Total mass
- MT_Scalar m_inertia; // Inertia, should be a tensor some time
- MT_Scalar m_lin_drag; // Linear drag (air, water) 0 = concrete, 1 = vacuum, inverted and called dampening in blenders UI
- MT_Scalar m_ang_drag; // Angular drag, inverted and called dampening in blenders UI
- MT_Scalar m_friction_scaling[3]; // Scaling for anisotropic friction. Component in range [0, 1]
- MT_Scalar m_clamp_vel_min; // Clamp the minimum velocity, this ensures an object moves at a minimum speed unless its stationary
- MT_Scalar m_clamp_vel_max; // Clamp max velocity
- MT_Scalar m_clamp_angvel_min; // Clamp the minimum angular velocity.
- MT_Scalar m_clamp_angvel_max; // Clamp the maximum angular velocity.
- bool m_do_anisotropic; // Should I do anisotropic friction?
- bool m_do_fh; // Should the object have a linear Fh spring?
- bool m_do_rot_fh; // Should the object have an angular Fh spring?
- MT_Scalar m_step_height; // Max height of climbable steps (Character)
- MT_Scalar m_jump_speed; // Velocity of jumps (Character)
- MT_Scalar m_fall_speed; // Max velocity of falling (Character)
- unsigned char m_max_jumps; // Max ammount of jumps (Character)
-};
-
-
-// Properties of collidable objects (non-ghost objects)
-struct PHY_MaterialProps {
- MT_Scalar m_restitution; // restitution of energie after a collision 0 = inelastic, 1 = elastic
- MT_Scalar m_friction; // Coulomb friction (= ratio between the normal en maximum friction force)
- MT_Scalar m_fh_spring; // Spring constant (both linear and angular)
- MT_Scalar m_fh_damping; // Damping factor (linear and angular) in range [0, 1]
- MT_Scalar m_fh_distance; // The range above the surface where Fh is active.
- bool m_fh_normal; // Should the object slide off slopes?
-};
-
-#endif /* __PHY_PRO_H__ */
diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt
deleted file mode 100644
index fc7dc90e03b..00000000000
--- a/source/gameengine/Rasterizer/CMakeLists.txt
+++ /dev/null
@@ -1,92 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../Expressions
- ../Ketsji
- ../SceneGraph
- ../../blender/makesdna
- ../../blender/blenlib
- ../../blender/blenkernel
- ../../blender/gpu
- ../../blender/imbuf
- ../../../intern/container
- ../../../intern/glew-mx
- ../../../intern/guardedalloc
- ../../../intern/string
-)
-
-set(INC_SYS
- ../../../intern/moto/include
- ${GLEW_INCLUDE_PATH}
- ${PYTHON_INCLUDE_DIRS}
-)
-
-set(SRC
- RAS_2DFilterManager.cpp
- RAS_BucketManager.cpp
- RAS_FramingManager.cpp
- RAS_IPolygonMaterial.cpp
- RAS_MaterialBucket.cpp
- RAS_MeshObject.cpp
- RAS_Polygon.cpp
- RAS_TexVert.cpp
- RAS_texmatrix.cpp
- RAS_ICanvas.cpp
-
- RAS_2DFilterManager.h
- RAS_BucketManager.h
- RAS_CameraData.h
- RAS_Deformer.h
- RAS_FramingManager.h
- RAS_ICanvas.h
- RAS_IPolygonMaterial.h
- RAS_IRasterizer.h
- RAS_ILightObject.h
- RAS_IOffScreen.h
- RAS_ISync.h
- RAS_MaterialBucket.h
- RAS_MeshObject.h
- RAS_ObjectColor.h
- RAS_Polygon.h
- RAS_Rect.h
- RAS_TexMatrix.h
- RAS_TexVert.h
- RAS_OpenGLFilters/RAS_Blur2DFilter.h
- RAS_OpenGLFilters/RAS_Dilation2DFilter.h
- RAS_OpenGLFilters/RAS_Erosion2DFilter.h
- RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
- RAS_OpenGLFilters/RAS_Invert2DFilter.h
- RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
- RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
- RAS_OpenGLFilters/RAS_Sepia2DFilter.h
- RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
- RAS_OpenGLFilters/RAS_Sobel2DFilter.h
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-blender_add_lib(ge_rasterizer "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
deleted file mode 100644
index f379e2eb486..00000000000
--- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
+++ /dev/null
@@ -1,562 +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.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/Rasterizer/RAS_2DFilterManager.cpp
- * \ingroup bgerast
- */
-
-#include "BLI_utildefines.h"
-
-#include "RAS_OpenGLFilters/RAS_Blur2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Sharpen2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Dilation2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Erosion2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Laplacian2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Sobel2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Prewitt2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_GrayScale2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h"
-#include "RAS_OpenGLFilters/RAS_Invert2DFilter.h"
-
-#include "STR_String.h"
-#include "RAS_ICanvas.h"
-#include "RAS_Rect.h"
-#include "RAS_2DFilterManager.h"
-#include <iostream>
-
-#include "GPU_glew.h"
-
-#include <stdio.h>
-
-#include "EXP_Value.h"
-
-RAS_2DFilterManager::RAS_2DFilterManager():
-texturewidth(-1), textureheight(-1),
-/* numberoffilters(0), */ /* UNUSED */ need_tex_update(true)
-{
- isshadersupported = GLEW_ARB_shader_objects &&
- GLEW_ARB_fragment_shader && GLEW_ARB_multitexture;
-
- /* used to return before 2.49 but need to initialize values so don't */
- if (!isshadersupported)
- std::cout<<"shaders not supported!" << std::endl;
-
- int passindex;
- for (passindex =0; passindex<MAX_RENDER_PASS; passindex++)
- {
- m_filters[passindex] = 0;
- m_enabled[passindex] = 0;
- texflag[passindex] = 0;
- m_gameObjects[passindex] = NULL;
- }
- texname[0] = texname[1] = texname[2] = -1;
- errorprinted= false;
-}
-
-RAS_2DFilterManager::~RAS_2DFilterManager()
-{
- FreeTextures();
-
- for (int passindex = 0; passindex < MAX_RENDER_PASS; passindex++) {
- if (m_filters[passindex]) {
- glDeleteObjectARB(m_filters[passindex]);
- }
- }
-}
-
-void RAS_2DFilterManager::PrintShaderErrors(unsigned int shader, const char *task, const char *code)
-{
- GLcharARB log[5000];
- GLsizei length = 0;
- const char *c, *pos, *end;
- int line = 1;
-
- if (errorprinted)
- return;
-
- errorprinted= true;
-
- glGetInfoLogARB(shader, sizeof(log), &length, log);
- end = code + strlen(code);
-
- printf("2D Filter GLSL Shader: %s error:\n", task);
-
- c = code;
- while ((c < end) && (pos = strchr(c, '\n'))) {
- printf("%2d ", line);
- fwrite(c, (pos+1)-c, 1, stdout);
- c = pos+1;
- line++;
- }
-
- puts(c);
- puts(log);
- puts("\n");
-}
-
-unsigned int RAS_2DFilterManager::CreateShaderProgram(const char* shadersource)
-{
- GLuint program = 0;
- GLuint fShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER);
- GLint success;
-
- glShaderSourceARB(fShader, 1, (const char**)&shadersource, NULL);
-
- glCompileShaderARB(fShader);
-
-
- glGetObjectParameterivARB(fShader, GL_COMPILE_STATUS, &success);
- if (!success) {
- /*Shader Comile Error*/
- PrintShaderErrors(fShader, "compile", shadersource);
- goto fail;
- }
-
- program = glCreateProgramObjectARB();
- glAttachObjectARB(program, fShader);
-
- glLinkProgramARB(program);
- glGetObjectParameterivARB(program, GL_LINK_STATUS, &success);
- if (!success) {
- /*Program Link Error*/
- PrintShaderErrors(fShader, "link", shadersource);
- goto fail;
- }
-
- glValidateProgramARB(program);
- glGetObjectParameterivARB(program, GL_VALIDATE_STATUS, &success);
- if (!success) {
- /*Program Validation Error*/
- PrintShaderErrors(fShader, "validate", shadersource);
- goto fail;
- }
-
- /* owned by 'program' */
- if (fShader) {
- glDeleteObjectARB(fShader);
- }
-
- return program;
-
-
-fail:
- if (fShader) {
- glDeleteObjectARB(fShader);
- }
-
- if (program) {
- glDeleteObjectARB(program);
- }
- return 0;
-}
-
-unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode)
-{
- switch (filtermode) {
- case RAS_2DFILTER_BLUR:
- return CreateShaderProgram(BlurFragmentShader);
- case RAS_2DFILTER_SHARPEN:
- return CreateShaderProgram(SharpenFragmentShader);
- case RAS_2DFILTER_DILATION:
- return CreateShaderProgram(DilationFragmentShader);
- case RAS_2DFILTER_EROSION:
- return CreateShaderProgram(ErosionFragmentShader);
- case RAS_2DFILTER_LAPLACIAN:
- return CreateShaderProgram(LaplacionFragmentShader);
- case RAS_2DFILTER_SOBEL:
- return CreateShaderProgram(SobelFragmentShader);
- case RAS_2DFILTER_PREWITT:
- return CreateShaderProgram(PrewittFragmentShader);
- case RAS_2DFILTER_GRAYSCALE:
- return CreateShaderProgram(GrayScaleFragmentShader);
- case RAS_2DFILTER_SEPIA:
- return CreateShaderProgram(SepiaFragmentShader);
- case RAS_2DFILTER_INVERT:
- return CreateShaderProgram(InvertFragmentShader);
- }
- return 0;
-}
-
-void RAS_2DFilterManager::AnalyseShader(int passindex, vector<STR_String>& propNames)
-{
- texflag[passindex] = 0;
- if (glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture") != -1)
- {
- if (GLEW_ARB_depth_texture)
- texflag[passindex] |= 0x1;
- }
- if (glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture") != -1)
- {
- texflag[passindex] |= 0x2;
- }
-
- if (m_gameObjects[passindex])
- {
- int objProperties = propNames.size();
- int i;
- for (i=0; i<objProperties; i++)
- if (glGetUniformLocationARB(m_filters[passindex], propNames[i]) != -1)
- m_properties[passindex].push_back(propNames[i]);
- }
-}
-
-void RAS_2DFilterManager::StartShaderProgram(int passindex)
-{
- GLint uniformLoc;
- glUseProgramObjectARB(m_filters[passindex]);
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTexture");
- glActiveTextureARB(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texname[0]);
-
- if (uniformLoc != -1)
- {
- glUniform1iARB(uniformLoc, 0);
- }
-
- /* send depth texture to glsl program if it needs */
- if (texflag[passindex] & 0x1) {
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture");
- glActiveTextureARB(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, texname[1]);
-
- if (uniformLoc != -1)
- {
- glUniform1iARB(uniformLoc, 1);
- }
- }
-
- /* send luminance texture to glsl program if it needs */
- if (texflag[passindex] & 0x2) {
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture");
- glActiveTextureARB(GL_TEXTURE2);
- glBindTexture(GL_TEXTURE_2D, texname[2]);
-
- if (uniformLoc != -1)
- {
- glUniform1iARB(uniformLoc, 2);
- }
- }
-
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_TextureCoordinateOffset");
- if (uniformLoc != -1)
- {
- glUniform2fvARB(uniformLoc, 9, textureoffsets);
- }
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureWidth");
- if (uniformLoc != -1)
- {
- glUniform1fARB(uniformLoc,texturewidth);
- }
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureHeight");
- if (uniformLoc != -1)
- {
- glUniform1fARB(uniformLoc,textureheight);
- }
-
- int i, objProperties = m_properties[passindex].size();
- for (i=0; i<objProperties; i++)
- {
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], m_properties[passindex][i]);
-
- if (uniformLoc == -1)
- continue;
-
- CValue *property = ((CValue *)m_gameObjects[passindex])->GetProperty(m_properties[passindex][i]);
-
- if (!property)
- continue;
-
- switch (property->GetValueType()) {
- case VALUE_INT_TYPE:
- glUniform1iARB(uniformLoc, property->GetNumber());
- break;
- case VALUE_FLOAT_TYPE:
- glUniform1fARB(uniformLoc, property->GetNumber());
- break;
- default:
- break;
- }
- }
-}
-
-void RAS_2DFilterManager::EndShaderProgram()
-{
- glUseProgramObjectARB(0);
-}
-
-void RAS_2DFilterManager::FreeTextures()
-{
- if (texname[0]!=(unsigned int)-1)
- glDeleteTextures(1, (GLuint*)&texname[0]);
- if (texname[1]!=(unsigned int)-1)
- glDeleteTextures(1, (GLuint*)&texname[1]);
- if (texname[2]!=(unsigned int)-1)
- glDeleteTextures(1, (GLuint*)&texname[2]);
-}
-
-void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance)
-{
- FreeTextures();
-
- glGenTextures(1, (GLuint*)&texname[0]);
- glBindTexture(GL_TEXTURE_2D, texname[0]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGBA,
- GL_UNSIGNED_BYTE, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-
- if (depth) {
- glGenTextures(1, (GLuint*)&texname[1]);
- glBindTexture(GL_TEXTURE_2D, texname[1]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight,
- 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,
- GL_NONE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- }
-
- if (luminance) {
- glGenTextures(1, (GLuint*)&texname[2]);
- glBindTexture(GL_TEXTURE_2D, texname[2]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16, texturewidth, textureheight,
- 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- }
-}
-
-void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas)
-{
- /* RAS_Rect canvas_rect = canvas->GetWindowArea(); */ /* UNUSED */
- texturewidth = canvas->GetWidth()+1;
- textureheight = canvas->GetHeight()+1;
- GLint i,j;
-
- if (!GL_ARB_texture_non_power_of_two)
- {
- i = 0;
- while ((1 << i) <= texturewidth)
- i++;
- texturewidth = (1 << (i));
-
- // Now for height
- i = 0;
- while ((1 << i) <= textureheight)
- i++;
- textureheight = (1 << (i));
- }
-
- GLfloat xInc = 1.0f / (GLfloat)texturewidth;
- GLfloat yInc = 1.0f / (GLfloat)textureheight;
-
- for (i = 0; i < 3; i++)
- {
- for (j = 0; j < 3; j++)
- {
- textureoffsets[(((i*3)+j)*2)+0] = (-1.0f * xInc) + ((GLfloat)i * xInc);
- textureoffsets[(((i*3)+j)*2)+1] = (-1.0f * yInc) + ((GLfloat)j * yInc);
- }
- }
-}
-
-void RAS_2DFilterManager::UpdateCanvasTextureCoord(const int viewport[4])
-{
- /*
- * This function update canvascoord[].
- * These parameters are used to create texcoord[1]
- * That way we can access the texcoord relative to the canvas:
- * (0.0,0.0) bottom left, (1.0,1.0) top right, (0.5,0.5) center
- */
- canvascoord[0] = (GLfloat) viewport[0] / -viewport[2];
- canvascoord[1] = (GLfloat) (texturewidth - viewport[0]) / viewport[2];
-
- canvascoord[2] = (GLfloat) viewport[1] / -viewport[3];
- canvascoord[3] = (GLfloat)(textureheight - viewport[1]) / viewport[3];
-}
-
-void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas)
-{
- bool need_depth=false;
- bool need_luminance=false;
- int num_filters = 0;
-
- int passindex;
-
- if (!isshadersupported)
- return;
-
- for (passindex =0; passindex<MAX_RENDER_PASS; passindex++)
- {
- if (m_filters[passindex] && m_enabled[passindex]) {
- num_filters ++;
- if (texflag[passindex] & 0x1)
- need_depth = true;
- if (texflag[passindex] & 0x2)
- need_luminance = true;
- if (need_depth && need_luminance)
- break;
- }
- }
-
- if (num_filters <= 0)
- return;
-
- const int *viewport = canvas->GetViewPort();
-
- if (texturewidth != viewport[2] || textureheight != viewport[3])
- {
- UpdateOffsetMatrix(canvas);
- UpdateCanvasTextureCoord(viewport);
- need_tex_update = true;
- }
-
- if (need_tex_update)
- {
- SetupTextures(need_depth, need_luminance);
- need_tex_update = false;
- }
-
- if (need_depth) {
- glActiveTextureARB(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, texname[1]);
- glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, viewport[0], viewport[1], viewport[2], viewport[3], 0);
- }
-
- if (need_luminance) {
- glActiveTextureARB(GL_TEXTURE2);
- glBindTexture(GL_TEXTURE_2D, texname[2]);
- glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, viewport[0], viewport[1], viewport[2], viewport[3], 0);
- }
-
- // reverting to texunit 0, without this we get bug [#28462]
- glActiveTextureARB(GL_TEXTURE0);
-
- // We do this to make side-by-side stereo rendering work correctly with 2D filters. It would probably be nicer to just set the viewport,
- // but it can be easier for writing shaders to have the coordinates for the whole screen instead of just part of the screen.
- RAS_Rect scissor_rect = canvas->GetDisplayArea();
-
- glScissor(scissor_rect.GetLeft() + viewport[0],
- scissor_rect.GetBottom() + viewport[1],
- scissor_rect.GetWidth() + 1,
- scissor_rect.GetHeight() + 1);
-
- glDisable(GL_DEPTH_TEST);
- // in case the previous material was wire
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- // if the last rendered face had alpha add it would messes with the color of the plane we apply 2DFilter to
- glDisable(GL_BLEND);
- // fix for [#34523] alpha buffer is now available for all OSs
- glDisable(GL_ALPHA_TEST);
-
- glPushMatrix(); //GL_MODELVIEW
- glLoadIdentity(); // GL_MODELVIEW
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- for (passindex =0; passindex<MAX_RENDER_PASS; passindex++)
- {
- if (m_filters[passindex] && m_enabled[passindex])
- {
- StartShaderProgram(passindex);
-
- glActiveTextureARB(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texname[0]);
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, viewport[0], viewport[1], viewport[2], viewport[3], 0); // Don't use texturewidth and textureheight in case we don't have NPOT support
- glClear(GL_COLOR_BUFFER_BIT);
-
- glBegin(GL_QUADS);
- glColor4f(1.f, 1.f, 1.f, 1.f);
- glTexCoord2f(1.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[1], canvascoord[3]); glVertex2f(1.0f,1.0f);
- glTexCoord2f(0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[0], canvascoord[3]); glVertex2f(-1.0f,1.0f);
- glTexCoord2f(0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[0], canvascoord[2]); glVertex2f(-1.0f,-1.0f);
- glTexCoord2f(1.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, canvascoord[1], canvascoord[2]); glVertex2f(1.0f,-1.0f);
- glEnd();
- }
- }
-
- glEnable(GL_DEPTH_TEST);
- EndShaderProgram();
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-}
-
-void RAS_2DFilterManager::EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text)
-{
- if (!isshadersupported)
- return;
- if (pass<0 || pass>=MAX_RENDER_PASS)
- return;
- need_tex_update = true;
- if (mode == RAS_2DFILTER_DISABLED)
- {
- m_enabled[pass] = 0;
- return;
- }
-
- if (mode == RAS_2DFILTER_ENABLED)
- {
- m_enabled[pass] = 1;
- return;
- }
-
- if (mode == RAS_2DFILTER_NOFILTER)
- {
- if (m_filters[pass])
- glDeleteObjectARB(m_filters[pass]);
- m_enabled[pass] = 0;
- m_filters[pass] = 0;
- m_gameObjects[pass] = NULL;
- m_properties[pass].clear();
- texflag[pass] = 0;
- return;
- }
-
- if (mode == RAS_2DFILTER_CUSTOMFILTER)
- {
- if (m_filters[pass])
- glDeleteObjectARB(m_filters[pass]);
- m_filters[pass] = CreateShaderProgram(text.Ptr());
- m_gameObjects[pass] = gameObj;
- AnalyseShader(pass, propNames);
- m_enabled[pass] = 1;
- return;
- }
-
- // We've checked all other cases, which means we must be dealing with a builtin filter
- if (m_filters[pass])
- glDeleteObjectARB(m_filters[pass]);
- m_filters[pass] = CreateShaderProgram(mode);
- m_gameObjects[pass] = NULL;
- AnalyseShader(pass, propNames);
- m_enabled[pass] = 1;
-}
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h
deleted file mode 100644
index bb727fe3b29..00000000000
--- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h
+++ /dev/null
@@ -1,114 +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_2DFilterManager.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_2DFILTERMANAGER_H__
-#define __RAS_2DFILTERMANAGER_H__
-
-#define MAX_RENDER_PASS 100
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_ICanvas;
-
-class RAS_2DFilterManager
-{
-private:
- unsigned int CreateShaderProgram(const char* shadersource);
- unsigned int CreateShaderProgram(int filtermode);
- void AnalyseShader(int passindex, std::vector<STR_String>& propNames);
- void StartShaderProgram(int passindex);
- void EndShaderProgram();
- void PrintShaderErrors(unsigned int shader, const char *task, const char *code);
-
- void SetupTextures(bool depth, bool luminance);
- void FreeTextures();
-
- void UpdateOffsetMatrix(RAS_ICanvas* canvas);
- void UpdateCanvasTextureCoord(const int viewport[4]);
-
- float canvascoord[4];
- float textureoffsets[18];
- /* float view[4]; */ /* UNUSED */
- /* texname[0] contains render to texture, texname[1] contains depth texture, texname[2] contains luminance texture*/
- unsigned int texname[3];
- int texturewidth;
- int textureheight;
- /* int numberoffilters; */ /* UNUSED */
- /* bit 0: enable/disable depth texture
- * bit 1: enable/disable luminance texture*/
- short texflag[MAX_RENDER_PASS];
-
- bool isshadersupported;
- bool errorprinted;
- bool need_tex_update;
-
- unsigned int m_filters[MAX_RENDER_PASS];
- short m_enabled[MAX_RENDER_PASS];
-
- // stores object properties to send to shaders in each pass
- std::vector<STR_String> m_properties[MAX_RENDER_PASS];
- void* m_gameObjects[MAX_RENDER_PASS];
-public:
- enum RAS_2DFILTER_MODE {
- RAS_2DFILTER_ENABLED = -2,
- RAS_2DFILTER_DISABLED = -1,
- RAS_2DFILTER_NOFILTER = 0,
- RAS_2DFILTER_MOTIONBLUR,
- RAS_2DFILTER_BLUR,
- RAS_2DFILTER_SHARPEN,
- RAS_2DFILTER_DILATION,
- RAS_2DFILTER_EROSION,
- RAS_2DFILTER_LAPLACIAN,
- RAS_2DFILTER_SOBEL,
- RAS_2DFILTER_PREWITT,
- RAS_2DFILTER_GRAYSCALE,
- RAS_2DFILTER_SEPIA,
- RAS_2DFILTER_INVERT,
- RAS_2DFILTER_CUSTOMFILTER,
- RAS_2DFILTER_NUMBER_OF_FILTERS
- };
-
- RAS_2DFilterManager();
-
- ~RAS_2DFilterManager();
-
- void RenderFilters(RAS_ICanvas* canvas);
-
- void EnableFilter(std::vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_2DFilterManager")
-#endif
-};
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp
deleted file mode 100644
index deca7cbed9f..00000000000
--- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp
+++ /dev/null
@@ -1,380 +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_BucketManager.cpp
- * \ingroup bgerast
- */
-
-#ifdef _MSC_VER
- /* don't show these anoying STL warnings */
-# pragma warning (disable:4786)
-#endif
-
-#include "RAS_MaterialBucket.h"
-#include "RAS_MeshObject.h"
-#include "RAS_Polygon.h"
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_IRasterizer.h"
-
-#include "RAS_BucketManager.h"
-
-#include <algorithm>
-/* sorting */
-
-struct RAS_BucketManager::sortedmeshslot
-{
-public:
- MT_Scalar m_z; /* depth */
- RAS_MeshSlot *m_ms; /* mesh slot */
- RAS_MaterialBucket *m_bucket; /* buck mesh slot came from */
-
- sortedmeshslot() {}
-
- void set(RAS_MeshSlot *ms, RAS_MaterialBucket *bucket, const MT_Vector3& pnorm)
- {
- // would be good to use the actual bounding box center instead
- MT_Point3 pos(ms->m_OpenGLMatrix[12], ms->m_OpenGLMatrix[13], ms->m_OpenGLMatrix[14]);
-
- m_z = MT_dot(pnorm, pos);
- m_ms = ms;
- m_bucket = bucket;
- }
-};
-
-struct RAS_BucketManager::backtofront
-{
- bool operator()(const sortedmeshslot &a, const sortedmeshslot &b)
- {
- return (a.m_z < b.m_z) || (a.m_z == b.m_z && a.m_ms < b.m_ms);
- }
-};
-
-struct RAS_BucketManager::fronttoback
-{
- bool operator()(const sortedmeshslot &a, const sortedmeshslot &b)
- {
- return (a.m_z > b.m_z) || (a.m_z == b.m_z && a.m_ms > b.m_ms);
- }
-};
-
-/* bucket manager */
-
-RAS_BucketManager::RAS_BucketManager()
-{
-
-}
-
-RAS_BucketManager::~RAS_BucketManager()
-{
- BucketList::iterator it;
-
- for (it = m_SolidBuckets.begin(); it != m_SolidBuckets.end(); it++)
- delete (*it);
-
- for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++)
- delete(*it);
-
- m_SolidBuckets.clear();
- m_AlphaBuckets.clear();
-}
-
-void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha)
-{
- BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator mit;
- size_t size = 0, i = 0;
-
- /* Camera's near plane equation: pnorm.dot(point) + pval,
- * but we leave out pval since it's constant anyway */
- const MT_Vector3 pnorm(cameratrans.getBasis()[2]);
-
- for (bit = buckets.begin(); bit != buckets.end(); ++bit)
- {
- SG_DList::iterator<RAS_MeshSlot> mit((*bit)->GetActiveMeshSlots());
- for (mit.begin(); !mit.end(); ++mit)
- size++;
- }
-
- slots.resize(size);
-
- for (bit = buckets.begin(); bit != buckets.end(); ++bit)
- {
- RAS_MaterialBucket* bucket = *bit;
- RAS_MeshSlot* ms;
- // remove the mesh slot from the list, it culls them automatically for next frame
- while ((ms = bucket->GetNextActiveMeshSlot())) {
- slots[i++].set(ms, bucket, pnorm);
- }
- }
-
- if (alpha)
- sort(slots.begin(), slots.end(), backtofront());
- else
- sort(slots.begin(), slots.end(), fronttoback());
-}
-
-void RAS_BucketManager::RenderAlphaBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
-{
- vector<sortedmeshslot> slots;
- vector<sortedmeshslot>::iterator sit;
-
- // Having depth masks disabled/enabled gives different artifacts in
- // case no sorting is done or is done inexact. For compatibility, we
- // disable it.
- if (rasty->GetDrawingMode() != RAS_IRasterizer::KX_SHADOW)
- rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_DISABLED);
-
- OrderBuckets(cameratrans, m_AlphaBuckets, slots, true);
-
- for (sit=slots.begin(); sit!=slots.end(); ++sit) {
- rasty->SetClientObject(sit->m_ms->m_clientObj);
-
- 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 frustum culling
- sit->m_ms->SetCulled(true);
- }
-
- rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
-}
-
-void RAS_BucketManager::RenderSolidBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
-{
- BucketList::iterator bit;
-
- rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
-
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
-#if 1
- RAS_MaterialBucket* bucket = *bit;
- RAS_MeshSlot* ms;
- // remove the mesh slot from the list, it culls them automatically for next frame
- while ((ms = bucket->GetNextActiveMeshSlot())) {
- 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 frustum culling
- ms->SetCulled(true);
- }
-#else
- list<RAS_MeshSlot>::iterator mit;
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- if (mit->IsCulled())
- continue;
-
- rasty->SetClientObject(rasty, mit->m_clientObj);
-
- 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 frustum culling
- mit->SetCulled(true);
- }
-#endif
- }
-
- /* this code draws meshes order front-to-back instead to reduce overdraw.
- * it turned out slower due to much material state switching, a more clever
- * algorithm might do better. */
-#if 0
- vector<sortedmeshslot> slots;
- vector<sortedmeshslot>::iterator sit;
-
- OrderBuckets(cameratrans, m_SolidBuckets, slots, false);
-
- for (sit=slots.begin(); sit!=slots.end(); ++sit) {
- rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj);
-
- 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)
-{
- /* beginning each frame, clear (texture/material) caching information */
- rasty->ClearCachingInfo();
-
- RenderSolidBuckets(cameratrans, rasty);
- RenderAlphaBuckets(cameratrans, rasty);
-
- /* If we're drawing shadows and bucket wasn't rendered (outside of the lamp frustum or doesn't cast shadows)
- * then the mesh is still modified, so we don't want to set MeshModified to false yet (it will mess up
- * updating display lists). Just leave this step for the main render pass.
- */
- if (rasty->GetDrawingMode() != RAS_IRasterizer::KX_SHADOW) {
- /* All meshes should be up to date now */
- /* Don't do this while processing buckets because some meshes are split between buckets */
- BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator mit;
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- mit->m_mesh->SetMeshModified(false);
- }
- }
- for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) {
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- mit->m_mesh->SetMeshModified(false);
- }
- }
- }
-
-
- rasty->SetClientObject(NULL);
-}
-
-RAS_MaterialBucket *RAS_BucketManager::FindBucket(RAS_IPolyMaterial *material, bool &bucketCreated)
-{
- BucketList::iterator it;
-
- bucketCreated = false;
-
- for (it = m_SolidBuckets.begin(); it != m_SolidBuckets.end(); it++)
- if (*(*it)->GetPolyMaterial() == *material)
- return *it;
-
- for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++)
- if (*(*it)->GetPolyMaterial() == *material)
- return *it;
-
- RAS_MaterialBucket *bucket = new RAS_MaterialBucket(material);
- bucketCreated = true;
-
- if (bucket->IsAlpha())
- m_AlphaBuckets.push_back(bucket);
- else
- m_SolidBuckets.push_back(bucket);
-
- return bucket;
-}
-
-void RAS_BucketManager::OptimizeBuckets(MT_Scalar distance)
-{
- BucketList::iterator bit;
-
- distance = 10.0f;
-
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit)
- (*bit)->Optimize(distance);
- for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit)
- (*bit)->Optimize(distance);
-}
-
-void RAS_BucketManager::ReleaseDisplayLists(RAS_IPolyMaterial *mat)
-{
- BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator mit;
-
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
- if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- if (mit->m_DisplayList) {
- mit->m_DisplayList->Release();
- mit->m_DisplayList = NULL;
- }
- }
- }
- }
-
- for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) {
- if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
- if (mit->m_DisplayList) {
- mit->m_DisplayList->Release();
- mit->m_DisplayList = NULL;
- }
- }
- }
- }
-}
-
-void RAS_BucketManager::ReleaseMaterials(RAS_IPolyMaterial * mat)
-{
- BucketList::iterator bit;
- list<RAS_MeshSlot>::iterator mit;
-
- for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
- if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
- (*bit)->GetPolyMaterial()->ReleaseMaterial();
- }
- }
-
- for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) {
- if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
- (*bit)->GetPolyMaterial()->ReleaseMaterial();
- }
- }
-}
-
-/* frees the bucket, only used when freeing scenes */
-void RAS_BucketManager::RemoveMaterial(RAS_IPolyMaterial * mat)
-{
- BucketList::iterator bit, bitp;
- list<RAS_MeshSlot>::iterator mit;
- int i;
-
-
- for (i=0; i<m_SolidBuckets.size(); i++) {
- RAS_MaterialBucket *bucket = m_SolidBuckets[i];
- if (mat == bucket->GetPolyMaterial()) {
- m_SolidBuckets.erase(m_SolidBuckets.begin()+i);
- delete bucket;
- i--;
- }
- }
-
- for (int i=0; i<m_AlphaBuckets.size(); i++) {
- RAS_MaterialBucket *bucket = m_AlphaBuckets[i];
- if (mat == bucket->GetPolyMaterial()) {
- m_AlphaBuckets.erase(m_AlphaBuckets.begin()+i);
- delete bucket;
- i--;
- }
- }
-}
-
-//#include <stdio.h>
-
-void RAS_BucketManager::MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene)
-{
- /* concatenate lists */
- // printf("BEFORE %d %d\n", GetSolidBuckets().size(), GetAlphaBuckets().size());
-
- GetSolidBuckets().insert( GetSolidBuckets().end(), other->GetSolidBuckets().begin(), other->GetSolidBuckets().end() );
- other->GetSolidBuckets().clear();
-
- GetAlphaBuckets().insert( GetAlphaBuckets().end(), other->GetAlphaBuckets().begin(), other->GetAlphaBuckets().end() );
- other->GetAlphaBuckets().clear();
- //printf("AFTER %d %d\n", GetSolidBuckets().size(), GetAlphaBuckets().size());
-}
-
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h
deleted file mode 100644
index 5ed212ebee0..00000000000
--- a/source/gameengine/Rasterizer/RAS_BucketManager.h
+++ /dev/null
@@ -1,93 +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_BucketManager.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_BUCKETMANAGER_H__
-#define __RAS_BUCKETMANAGER_H__
-
-#include "MT_Transform.h"
-#include "RAS_MaterialBucket.h"
-
-#include <vector>
-
-class RAS_BucketManager
-{
-public:
- typedef std::vector<class RAS_MaterialBucket*> BucketList;
-private:
- BucketList m_SolidBuckets;
- BucketList m_AlphaBuckets;
-
- struct sortedmeshslot;
- struct backtofront;
- struct fronttoback;
-
-public:
- RAS_BucketManager();
- virtual ~RAS_BucketManager();
-
- void Renderbuckets(const MT_Transform & cameratrans, RAS_IRasterizer* rasty);
-
- RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial *material, bool &bucketCreated);
- void OptimizeBuckets(MT_Scalar distance);
-
- void ReleaseDisplayLists(RAS_IPolyMaterial *material = NULL);
- void ReleaseMaterials(RAS_IPolyMaterial *material = NULL);
-
- void RemoveMaterial(RAS_IPolyMaterial *mat); // freeing scenes only
-
- /* for merging */
- void MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene);
- BucketList & GetSolidBuckets() {return m_SolidBuckets;}
- BucketList & GetAlphaBuckets() {return m_AlphaBuckets;}
-
- /*void PrintStats(int verbose_level) {
- printf("\nMappings...\n");
- printf("\t m_SolidBuckets: %d\n", m_SolidBuckets.size());
- printf("\t\t m_SolidBuckets: %d\n", m_SolidBuckets.size());
- printf("\t m_AlphaBuckets: %d\n", m_AlphaBuckets.size());
- }*/
-
-
-private:
- void OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha);
-
- void RenderSolidBuckets(const MT_Transform& cameratrans,
- RAS_IRasterizer* rasty);
- void RenderAlphaBuckets(const MT_Transform& cameratrans,
- RAS_IRasterizer* rasty);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_BucketManager")
-#endif
-};
-
-#endif /* __RAS_BUCKETMANAGER_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h
deleted file mode 100644
index bc8433afd05..00000000000
--- a/source/gameengine/Rasterizer/RAS_CameraData.h
+++ /dev/null
@@ -1,79 +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_CameraData.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_CAMERADATA_H__
-#define __RAS_CAMERADATA_H__
-
-struct RAS_CameraData
-{
- float m_lens;
- float m_scale;
- float m_sensor_x;
- float m_sensor_y;
- short m_sensor_fit;
- float m_shift_x;
- float m_shift_y;
- float m_clipstart;
- float m_clipend;
- bool m_perspective;
- bool m_viewport;
- int m_viewportleft;
- int m_viewportbottom;
- int m_viewportright;
- int m_viewporttop;
- float m_focallength;
-
- RAS_CameraData(float lens = 35.0f, float scale = 6.0f, float sensor_x = 32.0f, float sensor_y = 18.0f, short sensor_fit = 0,
- float shift_x = 0.0f, float shift_y = 0.0f,
- float clipstart = 0.1f, float clipend = 5000.0f, bool perspective = true,
- float focallength = 3.0f, bool viewport = false, int viewportleft = 0, int viewportbottom = 0,
- int viewportright = 0, int viewporttop = 0) :
- m_lens(lens),
- m_scale(scale),
- m_sensor_x(sensor_x),
- m_sensor_y(sensor_y),
- m_sensor_fit(sensor_fit),
- m_shift_x(shift_x),
- m_shift_y(shift_y),
- m_clipstart(clipstart),
- m_clipend(clipend),
- m_perspective(perspective),
- m_viewport(viewport),
- m_viewportleft(viewportleft),
- m_viewportbottom(viewportbottom),
- m_viewportright(viewportright),
- m_viewporttop(viewporttop),
- m_focallength(focallength)
- {
- }
-};
-
-#endif /* __RAS_CAMERADATA_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h
deleted file mode 100644
index 058f2304f3d..00000000000
--- a/source/gameengine/Rasterizer/RAS_Deformer.h
+++ /dev/null
@@ -1,103 +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_Deformer.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_DEFORMER_H__
-#define __RAS_DEFORMER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786) /* get rid of stupid stl-visual compiler debug warning */
-#endif
-
-#include <stdlib.h>
-#include "CTR_Map.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-struct DerivedMesh;
-class RAS_MeshObject;
-
-class RAS_Deformer
-{
-public:
- RAS_Deformer() : m_pMesh(NULL), m_bDynamic(false) {}
- virtual ~RAS_Deformer() {}
- virtual void Relink(CTR_Map<class CTR_HashedPtr, void*>*map)=0;
- virtual bool Apply(class RAS_IPolyMaterial *polymat)=0;
- virtual bool Update(void)=0;
- virtual bool UpdateBuckets(void)=0;
- virtual RAS_Deformer *GetReplica()=0;
- virtual void ProcessReplica()=0;
- virtual bool SkipVertexTransform()
- {
- return false;
- }
- virtual bool ShareVertexArray()
- {
- return true;
- }
- virtual bool UseVertexArray()
- {
- return true;
- }
- // true when deformer produces varying vertex (shape or armature)
- bool IsDynamic()
- {
- return m_bDynamic;
- }
- virtual struct DerivedMesh* GetFinalMesh()
- {
- return NULL;
- }
- virtual struct DerivedMesh* GetPhysicsMesh()
- {
- return NULL;
- }
- virtual class RAS_MeshObject* GetRasMesh()
- {
- /* m_pMesh does not seem to be being used?? */
- return NULL;
- }
- virtual float (* GetTransVerts(int *tot))[3] { *tot= 0; return NULL; }
-
-protected:
- class RAS_MeshObject *m_pMesh;
- bool m_bDynamic;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_Deformer")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp
deleted file mode 100644
index 8b0ec22fde3..00000000000
--- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp
+++ /dev/null
@@ -1,425 +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_FramingManager.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_FramingManager.h"
-#include "RAS_Rect.h"
-
- void
-RAS_FramingManager::
-ComputeDefaultFrustum(
- const float camnear,
- const float camfar,
- const float lens,
- const float sensor_x, const float sensor_y,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- const float design_aspect_ratio,
- RAS_FrameFrustum & frustum
-) {
- float size;
- float halfSize;
- float sizeX;
- float sizeY;
- float offsetX;
- float offsetY;
-
- if (sensor_fit==RAS_SENSORFIT_AUTO) {
- size = sensor_x * camnear / lens;
- halfSize = size * 0.5f;
-
- if (design_aspect_ratio > 1.f) {
- // halfsize defines the width
- sizeX = halfSize;
- sizeY = halfSize/design_aspect_ratio;
- } else {
- // halfsize defines the height
- sizeX = halfSize * design_aspect_ratio;
- sizeY = halfSize;
- }
- }
- else if (sensor_fit==RAS_SENSORFIT_HOR) {
- size = sensor_x * camnear / lens;
- halfSize = size * 0.5f;
- sizeX = halfSize;
- sizeY = halfSize/design_aspect_ratio;
- }
- else {
- size = sensor_y * camnear / lens;
- halfSize = size * 0.5f;
- sizeX = halfSize * design_aspect_ratio;
- sizeY = halfSize;
- }
-
- offsetX = size * shift_x;
- offsetY = size * shift_y;
-
- frustum.x2 = sizeX + offsetX;
- frustum.x1 = -sizeX + offsetX;
- frustum.y2 = sizeY + offsetY;
- frustum.y1 = -sizeY + offsetY;
- frustum.camnear = camnear;
- frustum.camfar = camfar;
-}
-
- void
-RAS_FramingManager::
-ComputeDefaultOrtho(
- const float camnear,
- const float camfar,
- const float scale,
- const float design_aspect_ratio,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- RAS_FrameFrustum & frustum
-)
-{
- float halfSize = scale*0.5f;
- float sizeX;
- float sizeY;
- float offsetX;
- float offsetY;
-
- if (sensor_fit==RAS_SENSORFIT_AUTO) {
- if (design_aspect_ratio > 1.f) {
- // halfsize defines the width
- sizeX = halfSize;
- sizeY = halfSize/design_aspect_ratio;
- } else {
- // halfsize defines the height
- sizeX = halfSize * design_aspect_ratio;
- sizeY = halfSize;
- }
- }
- else if (sensor_fit==RAS_SENSORFIT_HOR) {
- sizeX = halfSize;
- sizeY = halfSize/design_aspect_ratio;
- }
- else {
- sizeX = halfSize * design_aspect_ratio;
- sizeY = halfSize;
- }
-
- offsetX = scale * shift_x;
- offsetY = scale * shift_y;
-
- frustum.x2 = sizeX + offsetX;
- frustum.x1 = -sizeX + offsetX;
- frustum.y2 = sizeY + offsetY;
- frustum.y1 = -sizeY + offsetY;
- frustum.camnear = camnear;
- frustum.camfar = camfar;
-}
-
-
- void
-RAS_FramingManager::
-ComputeBestFitViewRect(
- const RAS_Rect &availableViewport,
- const float design_aspect_ratio,
- RAS_Rect &viewport
-) {
- // try and honour the aspect ratio when setting the
- // drawable area. If we don't do this we are liable
- // to get a lot of distortion in the rendered image.
-
- int width = availableViewport.GetWidth();
- int height = availableViewport.GetHeight();
- float window_aspect = float(width)/float(height);
-
- if (window_aspect < design_aspect_ratio) {
- int v_height = (int)(width / design_aspect_ratio);
- int left_over = (height - v_height) / 2;
-
- viewport.SetLeft(availableViewport.GetLeft());
- viewport.SetBottom(availableViewport.GetBottom() + left_over);
- viewport.SetRight(availableViewport.GetLeft() + width);
- viewport.SetTop(availableViewport.GetBottom() + left_over + v_height);
-
- } else {
- int v_width = (int)(height * design_aspect_ratio);
- int left_over = (width - v_width) / 2;
-
- viewport.SetLeft(availableViewport.GetLeft() + left_over);
- viewport.SetBottom(availableViewport.GetBottom());
- viewport.SetRight(availableViewport.GetLeft() + v_width + left_over);
- viewport.SetTop(availableViewport.GetBottom() + height);
- }
-}
-
- void
-RAS_FramingManager::
-ComputeViewport(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- RAS_Rect &viewport
-) {
-
- RAS_FrameSettings::RAS_FrameType type = settings.FrameType();
- const int winx = availableViewport.GetWidth();
- const int winy = availableViewport.GetHeight();
-
- const float design_width = float(settings.DesignAspectWidth());
- const float design_height = float(settings.DesignAspectHeight());
-
- float design_aspect_ratio = float(1);
-
- if (design_height == float(0)) {
- // well this is ill defined
- // lets just scale the thing
-
- type = RAS_FrameSettings::e_frame_scale;
- } else {
- design_aspect_ratio = design_width/design_height;
- }
-
- switch (type) {
-
- case RAS_FrameSettings::e_frame_scale :
- case RAS_FrameSettings::e_frame_extend:
- {
- viewport.SetLeft(availableViewport.GetLeft());
- viewport.SetBottom(availableViewport.GetBottom());
- viewport.SetRight(availableViewport.GetLeft() + int(winx));
- viewport.SetTop(availableViewport.GetBottom() + int(winy));
-
- break;
- }
-
- case RAS_FrameSettings::e_frame_bars:
- {
- ComputeBestFitViewRect(
- availableViewport,
- design_aspect_ratio,
- viewport
- );
-
- break;
- }
- default :
- break;
- }
-}
-
- void
-RAS_FramingManager::
-ComputeFrustum(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- const RAS_Rect &viewport,
- const float lens,
- const float sensor_x, const float sensor_y, const short sensor_fit,
- const float shift_x,
- const float shift_y,
- const float camnear,
- const float camfar,
- RAS_FrameFrustum &frustum
-) {
-
- RAS_FrameSettings::RAS_FrameType type = settings.FrameType();
-
- const float design_width = float(settings.DesignAspectWidth());
- const float design_height = float(settings.DesignAspectHeight());
-
- float design_aspect_ratio = float(1);
-
- if (design_height == float(0)) {
- // well this is ill defined
- // lets just scale the thing
-
- type = RAS_FrameSettings::e_frame_scale;
- } else {
- design_aspect_ratio = design_width/design_height;
- }
-
- ComputeDefaultFrustum(
- camnear,
- camfar,
- lens,
- sensor_x,
- sensor_y,
- sensor_fit,
- shift_x,
- shift_y,
- design_aspect_ratio,
- frustum
- );
-
- switch (type) {
-
- case RAS_FrameSettings::e_frame_extend:
- {
- float x_scale, y_scale;
- switch (sensor_fit) {
- case RAS_SENSORFIT_HOR:
- {
- x_scale = 1.0f;
- y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth());
- break;
- }
- case RAS_SENSORFIT_VERT:
- {
- x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight());
- y_scale = 1.0f;
- break;
- }
- case RAS_SENSORFIT_AUTO:
- default:
- {
- RAS_Rect vt;
- ComputeBestFitViewRect(
- availableViewport,
- design_aspect_ratio,
- vt
- );
-
- // now scale the calculated frustum by the difference
- // between vt and the viewport in each axis.
- // These are always > 1
-
- x_scale = float(viewport.GetWidth())/float(vt.GetWidth());
- y_scale = float(viewport.GetHeight())/float(vt.GetHeight());
- break;
- }
- }
-
- frustum.x1 *= x_scale;
- frustum.x2 *= x_scale;
- frustum.y1 *= y_scale;
- frustum.y2 *= y_scale;
-
- break;
- }
- case RAS_FrameSettings::e_frame_scale :
- case RAS_FrameSettings::e_frame_bars:
- default :
- break;
- }
-}
-
- void
-RAS_FramingManager::
- ComputeOrtho(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- const RAS_Rect &viewport,
- const float scale,
- const float camnear,
- const float camfar,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- RAS_FrameFrustum &frustum
- )
-{
- RAS_FrameSettings::RAS_FrameType type = settings.FrameType();
-
- const float design_width = float(settings.DesignAspectWidth());
- const float design_height = float(settings.DesignAspectHeight());
-
- float design_aspect_ratio = float(1);
-
- if (design_height == float(0)) {
- // well this is ill defined
- // lets just scale the thing
- type = RAS_FrameSettings::e_frame_scale;
- } else {
- design_aspect_ratio = design_width/design_height;
- }
-
-
- ComputeDefaultOrtho(
- camnear,
- camfar,
- scale,
- design_aspect_ratio,
- sensor_fit,
- shift_x,
- shift_y,
- frustum
- );
-
- switch (type) {
-
- case RAS_FrameSettings::e_frame_extend:
- {
- float x_scale, y_scale;
- switch (sensor_fit) {
- case RAS_SENSORFIT_HOR:
- {
- x_scale = 1.0f;
- y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth());
- break;
- }
- case RAS_SENSORFIT_VERT:
- {
- x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight());
- y_scale = 1.0f;
- break;
- }
- case RAS_SENSORFIT_AUTO:
- default:
- {
- RAS_Rect vt;
- ComputeBestFitViewRect(
- availableViewport,
- design_aspect_ratio,
- vt
- );
-
- // now scale the calculated frustum by the difference
- // between vt and the viewport in each axis.
- // These are always > 1
-
- x_scale = float(viewport.GetWidth())/float(vt.GetWidth());
- y_scale = float(viewport.GetHeight())/float(vt.GetHeight());
- break;
- }
- }
-
- frustum.x1 *= x_scale;
- frustum.x2 *= x_scale;
- frustum.y1 *= y_scale;
- frustum.y2 *= y_scale;
-
- break;
- }
- case RAS_FrameSettings::e_frame_scale :
- case RAS_FrameSettings::e_frame_bars:
- default :
- break;
- }
-
-}
-
-
diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h
deleted file mode 100644
index cb86a7a4484..00000000000
--- a/source/gameengine/Rasterizer/RAS_FramingManager.h
+++ /dev/null
@@ -1,316 +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_FramingManager.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_FRAMINGMANAGER_H__
-#define __RAS_FRAMINGMANAGER_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_Rect;
-
-/**
- * \section RAS_FrameSettings
- * This is a value type describing the framing used
- * by a particular scene in the game engine.
- * Each KX_Scene contains a RAS_FrameSetting describing
- * how the frustum and viewport are to be modified
- * depending on the canvas size.
- *
- * e_frame_scale means that the viewport is set to the current
- * canvas size. If the view frustum aspect ratio is different
- * to the canvas aspect this will lead to stretching.
- *
- * e_frame_extend means that the best fit viewport will be
- * computed based upon the design aspect ratio
- * and the view frustum will be adjusted so that
- * more of the scene is visible.
- *
- * e_frame_bars means that the best fit viewport will be
- * be computed based upon the design aspect ratio.
- */
-
-class RAS_FrameSettings
-{
-public :
- /**
- * enum defining the policy to use
- * in each axis.
- */
- enum RAS_FrameType {
- e_frame_scale,
- e_frame_extend,
- e_frame_bars
- };
-
- /**
- * Constructor
- */
-
- RAS_FrameSettings(
- RAS_FrameType frame_type,
- float bar_r,
- float bar_g,
- float bar_b,
- unsigned int design_aspect_width,
- unsigned int design_aspect_height
- ):
- m_frame_type(frame_type),
- m_bar_r(bar_r),
- m_bar_g(bar_g),
- m_bar_b(bar_b),
- m_design_aspect_width(design_aspect_width),
- m_design_aspect_height(design_aspect_height)
- {
- };
-
- RAS_FrameSettings(
- ):
- m_frame_type(e_frame_scale),
- m_bar_r(0),
- m_bar_g(0),
- m_bar_b(0),
- m_design_aspect_width(1),
- m_design_aspect_height(1)
- {
- };
-
- /**
- * Accessors
- */
-
- const
- RAS_FrameType &
- FrameType(
- ) const {
- return m_frame_type;
- };
-
- void
- SetFrameType(
- RAS_FrameType type
- ) {
- m_frame_type = type;
- };
-
- float
- BarRed(
- ) const {
- return m_bar_r;
- };
-
- float
- BarGreen(
- ) const {
- return m_bar_g;
- };
-
- float
- BarBlue(
- ) const {
- return m_bar_b;
- };
-
- unsigned int
- DesignAspectWidth(
- ) const {
- return m_design_aspect_width;
- };
-
- unsigned int
- DesignAspectHeight(
- ) const {
- return m_design_aspect_height;
- };
-
-private :
-
- RAS_FrameType m_frame_type;
- float m_bar_r;
- float m_bar_g;
- float m_bar_b;
- unsigned int m_design_aspect_width;
- unsigned int m_design_aspect_height;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_FrameSettings")
-#endif
-};
-
-struct RAS_FrameFrustum
-{
- float camnear,camfar;
- float x1,y1;
- float x2,y2;
-};
-
-/* must match R_CULLING_... from DNA_scene_types.h */
-enum RAS_CullingMode
-{
- RAS_CULLING_DBVT = 0,
- RAS_CULLING_NORMAL,
- RAS_CULLING_NONE
-};
-
-/* Should match CAMERA_SENSOR_FIT... from DNA_camera_types.h */
-enum RAS_SensorFit
-{
- RAS_SENSORFIT_AUTO = 0,
- RAS_SENSORFIT_HOR,
- RAS_SENSORFIT_VERT
-};
-
-/**
- * \section RAS_FramingManager
- * This class helps to compute a view frustum
- * and a viewport rectangle given the
- * above settings and a description of the
- * current canvas dimensions.
- *
- * You do not have to instantiate this class
- * directly, it only contains static helper functions
- */
-
-class RAS_FramingManager
-{
-public :
-
- /**
- * Compute a viewport given
- * a RAS_FrameSettings and a description of the
- * canvas.
- */
-
- static
- void
- ComputeViewport(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- RAS_Rect &viewport
- );
-
-
- /**
- * compute a frustum given a valid viewport,
- * RAS_FrameSettings, canvas description
- * and camera description
- */
-
- static
- void
- ComputeOrtho(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- const RAS_Rect &viewport,
- const float scale,
- const float camnear,
- const float camfar,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- RAS_FrameFrustum &frustum
- );
-
- static
- void
- ComputeFrustum(
- const RAS_FrameSettings &settings,
- const RAS_Rect &availableViewport,
- const RAS_Rect &viewport,
- const float lens,
- const float sensor_x, const float sensor_y, const short sensor_fit,
- const float shift_x,
- const float shift_y,
- const float camnear,
- const float camfar,
- RAS_FrameFrustum &frustum
- );
-
- static
- void
- ComputeDefaultFrustum(
- const float camnear,
- const float camfar,
- const float lens,
- const float sensor_x, const float sensor_y,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- const float design_aspect_ratio,
- RAS_FrameFrustum & frustum
- );
-
- static
- void
- ComputeDefaultOrtho(
- const float camnear,
- const float camfar,
- const float scale,
- const float design_aspect_ratio,
- const short sensor_fit,
- const float shift_x,
- const float shift_y,
- RAS_FrameFrustum & frustum
- );
-
-private :
-
- static
- void
- ComputeBestFitViewRect(
- const RAS_Rect &availableViewport,
- const float design_aspect_ratio,
- RAS_Rect &viewport
- );
-
-
-
- /**
- * Private constructor - this class is not meant
- * for instantiation.
- */
-
- RAS_FramingManager(
- );
-
- RAS_FramingManager(
- const RAS_FramingManager &
- );
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_FramingManager")
-#endif
-};
-
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.cpp b/source/gameengine/Rasterizer/RAS_ICanvas.cpp
deleted file mode 100644
index 808d257f8f0..00000000000
--- a/source/gameengine/Rasterizer/RAS_ICanvas.cpp
+++ /dev/null
@@ -1,128 +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/Rasterizer/RAS_ICanvas.cpp
- * \ingroup bgerast
- */
-
-#include "RAS_ICanvas.h"
-#include "DNA_scene_types.h"
-
-#include "BKE_image.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "BLI_task.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
-
-#include "MEM_guardedalloc.h"
-
-extern "C" {
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-}
-
-
-// Task data for saving screenshots in a different thread.
-struct ScreenshotTaskData
-{
- unsigned int *dumprect;
- int dumpsx;
- int dumpsy;
- char *path;
- ImageFormatData *im_format;
-};
-
-/**
- * Function that actually performs the image compression and saving to disk of a screenshot.
- * Run in a separate thread by RAS_ICanvas::save_screenshot().
- *
- * @param taskdata Must point to a ScreenshotTaskData object. This function takes ownership
- * of all pointers in the ScreenshotTaskData, and frees them.
- */
-void save_screenshot_thread_func(TaskPool *__restrict pool, void *taskdata, int threadid);
-
-
-RAS_ICanvas::RAS_ICanvas()
-{
- m_taskscheduler = BLI_task_scheduler_create(TASK_SCHEDULER_AUTO_THREADS);
- m_taskpool = BLI_task_pool_create(m_taskscheduler, NULL);
-}
-
-RAS_ICanvas::~RAS_ICanvas()
-{
- if (m_taskpool) {
- BLI_task_pool_work_and_wait(m_taskpool);
- BLI_task_pool_free(m_taskpool);
- m_taskpool = NULL;
- }
-
- if (m_taskscheduler) {
- BLI_task_scheduler_free(m_taskscheduler);
- m_taskscheduler = NULL;
- }
-}
-
-
-void save_screenshot_thread_func(TaskPool *__restrict UNUSED(pool), void *taskdata, int UNUSED(threadid))
-{
- ScreenshotTaskData *task = static_cast<ScreenshotTaskData *>(taskdata);
-
- /* create and save imbuf */
- ImBuf *ibuf = IMB_allocImBuf(task->dumpsx, task->dumpsy, 24, 0);
- ibuf->rect = task->dumprect;
-
- BKE_imbuf_write_as(ibuf, task->path, task->im_format, false);
-
- ibuf->rect = NULL;
- IMB_freeImBuf(ibuf);
- MEM_freeN(task->dumprect);
- MEM_freeN(task->path);
- MEM_freeN(task->im_format);
-}
-
-
-void RAS_ICanvas::save_screenshot(const char *filename, int dumpsx, int dumpsy, unsigned int *dumprect,
- ImageFormatData * im_format)
-{
- /* create file path */
- char *path = (char *)MEM_mallocN(FILE_MAX, "screenshot-path");
- BLI_strncpy(path, filename, FILE_MAX);
- BLI_path_abs(path, G.main->name);
- BLI_path_frame(path, m_frame, 0);
- m_frame++;
- BKE_image_path_ensure_ext_from_imtype(path, im_format->imtype);
-
- /* Save the actual file in a different thread, so that the
- * game engine can keep running at full speed. */
- ScreenshotTaskData *task = (ScreenshotTaskData *)MEM_mallocN(sizeof(ScreenshotTaskData), "screenshot-data");
- task->dumprect = dumprect;
- task->dumpsx = dumpsx;
- task->dumpsy = dumpsy;
- task->path = path;
- task->im_format = im_format;
-
- BLI_task_pool_push(m_taskpool,
- save_screenshot_thread_func,
- task,
- true, // free task data
- TASK_PRIORITY_LOW);
-}
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h
deleted file mode 100644
index 91cc13c8f85..00000000000
--- a/source/gameengine/Rasterizer/RAS_ICanvas.h
+++ /dev/null
@@ -1,287 +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_ICanvas.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_ICANVAS_H__
-#define __RAS_ICANVAS_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_Rect;
-struct TaskScheduler;
-struct TaskPool;
-struct ImageFormatData;
-
-/**
- * 2D rendering device context. The connection from 3d rendercontext to 2d surface.
- */
-class RAS_ICanvas
-{
-public:
- enum BufferType {
- COLOR_BUFFER=1,
- DEPTH_BUFFER=2
- };
-
- enum RAS_MouseState
- {
- MOUSE_INVISIBLE=1,
- MOUSE_WAIT,
- MOUSE_NORMAL
- };
-
- RAS_ICanvas();
- virtual ~RAS_ICanvas();
-
- virtual
- void
- Init(
- ) = 0;
-
- virtual
- void
- BeginFrame(
- )=0;
-
- virtual
- void
- EndFrame(
- )=0;
-
- /**
- * Initializes the canvas for drawing. Drawing to the canvas is
- * only allowed between BeginDraw() and EndDraw().
- *
- * \retval false Acquiring the canvas failed.
- * \retval true Acquiring the canvas succeeded.
- *
- */
-
- virtual
- bool
- BeginDraw(
- )=0;
-
- /**
- * Unitializes the canvas for drawing.
- */
-
- virtual
- void
- EndDraw(
- )=0;
-
-
- /// probably needs some arguments for PS2 in future
- virtual
- void
- SwapBuffers(
- )=0;
-
- virtual
- void
- SetSwapInterval(
- int interval
- )=0;
-
- virtual
- bool
- GetSwapInterval(
- int& intervalOut
- )=0;
-
- virtual
- void
- ClearBuffer(
- int type
- )=0;
-
- virtual
- void
- ClearColor(
- float r,
- float g,
- float b,
- float a
- )=0;
-
- virtual
- int
- GetWidth(
- ) const = 0;
-
- virtual
- int
- GetHeight(
- ) const = 0;
-
- virtual
- int
- GetMouseX(int x
- )=0;
-
- virtual
- int
- GetMouseY(int y
- )= 0;
-
- virtual
- float
- GetMouseNormalizedX(int x
- )=0;
-
- virtual
- float
- GetMouseNormalizedY(int y
- )= 0;
-
- virtual
- const RAS_Rect &
- GetDisplayArea(
- ) const = 0;
-
- virtual
- void
- SetDisplayArea(RAS_Rect *rect
- ) = 0;
-
- /**
- * Used to get canvas area within blender.
- */
- virtual
- RAS_Rect &
- GetWindowArea(
- ) = 0;
-
- /**
- * Set the visible view-port
- */
-
- virtual
- void
- SetViewPort(
- int x1, int y1,
- int x2, int y2
- ) = 0;
-
- /**
- * Update the Canvas' viewport (used when the viewport changes without using SetViewPort()
- * eg: Shadow buffers and FBOs
- */
-
- virtual
- void
- UpdateViewPort(
- int x1, int y1,
- int x2, int y2
- ) = 0;
-
- /**
- * Get the visible viewport
- */
- virtual
- const int*
- GetViewPort() = 0;
-
- virtual
- void
- SetMouseState(
- RAS_MouseState mousestate
- )=0;
-
- virtual
- void
- SetMousePosition(
- int x,
- int y
- )=0;
-
- virtual
- RAS_MouseState
- GetMouseState()
- {
- return m_mousestate;
- }
-
- virtual
- void
- MakeScreenShot(
- const char* filename
- )=0;
-
- virtual void GetDisplayDimensions(int &width, int &height) = 0;
-
- virtual
- void
- ResizeWindow(
- int width,
- int height
- )=0;
-
- virtual
- void
- SetFullScreen(
- bool enable
- )=0;
-
- virtual
- bool
- GetFullScreen()=0;
-
-
-
-protected:
- RAS_MouseState m_mousestate;
- int m_frame; /// frame number for screenshots.
- TaskScheduler *m_taskscheduler;
- TaskPool *m_taskpool;
-
- /**
- * Saves screenshot data to a file. The actual compression and disk I/O is performed in
- * a separate thread.
- *
- * @param filename name of the file, can contain "###" for sequential numbering. A copy of the string
- * is made, so the pointer can be freed by the caller.
- * @param dumpsx width in pixels.
- * @param dumpsy height in pixels.
- * @param dumprect pixel data; ownership is passed to this function, which also frees the data.
- * @param im_format image format for the file; ownership is passed to this function, which also frees the data.
- */
- void save_screenshot(const char *filename, int dumpsx, int dumpsy, unsigned int *dumprect,
- ImageFormatData * im_format);
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_ICanvas")
-#endif
-};
-
-#endif /* __RAS_ICANVAS_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_ILightObject.h b/source/gameengine/Rasterizer/RAS_ILightObject.h
deleted file mode 100644
index a3d55c925d6..00000000000
--- a/source/gameengine/Rasterizer/RAS_ILightObject.h
+++ /dev/null
@@ -1,95 +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): Mitchell Stokes
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_ILightObject.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_LIGHTOBJECT_H__
-#define __RAS_LIGHTOBJECT_H__
-
-class RAS_ICanvas;
-
-class KX_Camera;
-class KX_Scene;
-
-class MT_Transform;
-class MT_Matrix4x4;
-
-struct Image;
-
-class RAS_ILightObject
-{
-public:
- enum LightType {
- LIGHT_SPOT,
- LIGHT_SUN,
- LIGHT_NORMAL
- };
- bool m_modified;
- int m_layer;
- void *m_scene;
- void *m_light;
-
- float m_energy;
- float m_distance;
- float m_shadowclipstart;
- float m_shadowfrustumsize;
- float m_shadowclipend;
- float m_shadowbias;
- float m_shadowbleedbias;
- short m_shadowmaptype;
- float m_shadowcolor[3];
-
- float m_color[3];
-
- float m_att1;
- float m_att2;
- float m_coeff_const, m_coeff_lin, m_coeff_quad;
- float m_spotsize;
- float m_spotblend;
-
- LightType m_type;
-
- bool m_nodiffuse;
- bool m_nospecular;
- bool m_glsl;
-
- virtual ~RAS_ILightObject() {}
- virtual RAS_ILightObject* Clone() = 0;
-
- virtual bool HasShadowBuffer() = 0;
- virtual int GetShadowBindCode() = 0;
- virtual MT_Matrix4x4 GetShadowMatrix() = 0;
- virtual int GetShadowLayer() = 0;
- virtual void BindShadowBuffer(RAS_ICanvas *canvas, KX_Camera *cam, MT_Transform& camtrans) = 0;
- virtual void UnbindShadowBuffer() = 0;
- virtual Image *GetTextureImage(short texslot) = 0;
- virtual void Update() = 0;
-};
-
-#endif /* __RAS_LIGHTOBJECT_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_IOffScreen.h b/source/gameengine/Rasterizer/RAS_IOffScreen.h
deleted file mode 100644
index d61a31504b8..00000000000
--- a/source/gameengine/Rasterizer/RAS_IOffScreen.h
+++ /dev/null
@@ -1,84 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_IOffScreen.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_OFFSCREEN_H__
-#define __RAS_OFFSCREEN_H__
-
-#include "EXP_Python.h"
-
-class RAS_ICanvas;
-
-class MT_Transform;
-
-struct Image;
-
-class RAS_IOffScreen
-{
-public:
- enum RAS_OFS_BIND_MODE {
- RAS_OFS_BIND_RENDER = 0,
- RAS_OFS_BIND_READ,
- };
- enum RAS_OFS_RENDER_TARGET {
- RAS_OFS_RENDER_BUFFER = 0, // use render buffer as render target
- RAS_OFS_RENDER_TEXTURE, // use texture as render target
- };
-
- int m_width;
- int m_height;
- int m_samples;
- int m_color; // if used, holds the texture object, 0 if not used
-
- virtual ~RAS_IOffScreen() {}
-
- virtual bool Create(int width, int height, int samples, RAS_OFS_RENDER_TARGET target) = 0;
- virtual void Destroy() = 0;
- virtual void Bind(RAS_OFS_BIND_MODE mode) = 0;
- virtual void Blit() = 0;
- virtual void Unbind() = 0;
- virtual void MipMap() = 0;
-
- virtual int GetWidth() { return m_width; }
- virtual int GetHeight() { return m_height; }
- virtual int GetSamples() { return m_samples; }
- virtual int GetColor() { return m_color; }
-};
-
-#ifdef WITH_PYTHON
-typedef struct {
- PyObject_HEAD
- RAS_IOffScreen *ofs;
-} PyRASOffScreen;
-
-extern PyTypeObject PyRASOffScreen_Type;
-#endif
-
-#endif /* __RAS_OFFSCREEN_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
deleted file mode 100644
index 1d22d2debf9..00000000000
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
+++ /dev/null
@@ -1,292 +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_IPolygonMaterial.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_IRasterizer.h"
-
-#include "DNA_material_types.h"
-
-void RAS_IPolyMaterial::Initialize(
- const STR_String& texname,
- const STR_String& matname,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int alphablend,
- bool alpha,
- bool zsort,
- bool light,
- bool image,
- struct GameSettings* game)
-{
- m_texturename = texname;
- m_materialname = matname;
- m_materialindex = materialindex;
- m_tile = tile;
- m_tilexrep = tilexrep;
- m_tileyrep = tileyrep;
- m_alphablend = alphablend;
- m_alpha = alpha;
- m_zsort = zsort;
- m_light = light;
- m_polymatid = m_newpolymatid++;
- m_flag = 0;
- m_multimode = 0;
- m_shininess = 35.0f;
- m_specular.setValue(0.5f,0.5f,0.5f);
- m_specularity = 1.0f;
- m_diffuse.setValue(0.5f,0.5f,0.5f);
- m_drawingmode = ConvertFaceMode(game, image);
-}
-
-RAS_IPolyMaterial::RAS_IPolyMaterial()
- : m_texturename("__Dummy_Texture_Name__"),
- m_materialname("__Dummy_Material_Name__"),
- m_tile(0),
- m_tilexrep(0),
- m_tileyrep(0),
- m_drawingmode (0),
- m_alphablend(0),
- m_alpha(false),
- m_zsort(false),
- m_light(false),
- m_materialindex(0),
- m_polymatid(0),
- m_flag(0),
- m_multimode(0)
-{
- m_shininess = 35.0f;
- m_specular = MT_Vector3(0.5f,0.5f,0.5f);
- m_specularity = 1.0f;
- m_diffuse = MT_Vector3(0.5f,0.5f,0.5f);
-}
-
-RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname,
- const STR_String& matname,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int alphablend,
- bool alpha,
- bool zsort)
- : m_texturename(texname),
- m_materialname(matname),
- m_tile(tile),
- m_tilexrep(tilexrep),
- m_tileyrep(tileyrep),
- m_alphablend(alphablend),
- m_alpha(alpha),
- m_zsort(zsort),
- m_materialindex(materialindex),
- m_polymatid(m_newpolymatid++),
- m_flag(0),
- m_multimode(0)
-{
- m_shininess = 35.0f;
- m_specular = MT_Vector3(0.5f,0.5f,0.5f);
- m_specularity = 1.0f;
- m_diffuse = MT_Vector3(0.5f,0.5f,0.5f);
-}
-
-
-bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const
-{
- if (m_flag &RAS_BLENDERMAT)
- {
- bool test = (
- this->m_multimode == lhs.m_multimode &&
- this->m_flag == lhs.m_flag &&
- this->m_drawingmode == lhs.m_drawingmode &&
- this->m_alphablend == lhs.m_alphablend &&
- this->m_texturename.hash() == lhs.m_texturename.hash() &&
- this->m_materialname.hash() == lhs.m_materialname.hash()
- );
-
- return test;
- }
- else
- {
- return (
- this->m_tile == lhs.m_tile &&
- this->m_tilexrep == lhs.m_tilexrep &&
- this->m_tileyrep == lhs.m_tileyrep &&
- this->m_alphablend == lhs.m_alphablend &&
- this->m_alpha == lhs.m_alpha &&
- this->m_zsort == lhs.m_zsort &&
- this->m_light == lhs.m_light &&
- this->m_drawingmode == lhs.m_drawingmode &&
- this->m_texturename.hash() == lhs.m_texturename.hash() &&
- this->m_materialname.hash() == lhs.m_materialname.hash()
- );
- }
-}
-
-int RAS_IPolyMaterial::ConvertFaceMode(struct GameSettings *game, bool image) const
-{
- if (!game) return (image?GEMAT_TEX:0);
-
- int modefinal = 0;
-
- int orimode = game->face_orientation;
- int alpha_blend = game->alpha_blend;
- int flags = game->flag & (GEMAT_TEXT | GEMAT_BACKCULL);
-
- modefinal = orimode | alpha_blend | flags;
- modefinal |= (image ? GEMAT_TEX : 0);
-
- return modefinal;
-}
-
-void RAS_IPolyMaterial::GetMaterialRGBAColor(unsigned char *rgba) const
-{
- *rgba++ = 0xFF;
- *rgba++ = 0xFF;
- *rgba++ = 0xFF;
- *rgba++ = 0xFF;
-}
-
-bool RAS_IPolyMaterial::Less(const RAS_IPolyMaterial& rhs) const
-{
- if (Equals(rhs))
- return false;
-
- return m_polymatid < rhs.m_polymatid;
-}
-
-bool RAS_IPolyMaterial::IsAlpha() const
-{
- return m_alpha || m_zsort;
-}
-
-bool RAS_IPolyMaterial::IsZSort() const
-{
- return m_zsort;
-}
-
-unsigned int RAS_IPolyMaterial::hash() const
-{
- return m_texturename.hash();
-}
-
-int RAS_IPolyMaterial::GetDrawingMode() const
-{
- return m_drawingmode;
-}
-
-const STR_String& RAS_IPolyMaterial::GetMaterialName() const
-{
- return m_materialname;
-}
-
-dword RAS_IPolyMaterial::GetMaterialNameHash() const
-{
- return m_materialname.hash();
-}
-
-const STR_String& RAS_IPolyMaterial::GetTextureName() const
-{
- return m_texturename;
-}
-
-int RAS_IPolyMaterial::GetMaterialIndex() const
-{
- return m_materialindex;
-}
-
-Material *RAS_IPolyMaterial::GetBlenderMaterial() const
-{
- return NULL;
-}
-
-Image *RAS_IPolyMaterial::GetBlenderImage() const
-{
- return NULL;
-}
-
-unsigned int *RAS_IPolyMaterial::GetMCol() const
-{
- return NULL;
-}
-
-Scene* RAS_IPolyMaterial::GetBlenderScene() const
-{
- return NULL;
-}
-
-void RAS_IPolyMaterial::ReleaseMaterial()
-{
-}
-
-unsigned int RAS_IPolyMaterial::GetFlag() const
-{
- return m_flag;
-}
-
-bool RAS_IPolyMaterial::UsesLighting(RAS_IRasterizer *rasty) const
-{
- bool dolights = false;
-
- if (m_flag & RAS_BLENDERMAT) {
- dolights = (m_flag & RAS_MULTILIGHT) != 0;
- }
- else if (rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID) {
- /* pass */
- }
- else if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW) {
- /* pass */
- }
- else {
- dolights = m_light;
- }
-
- return dolights;
-}
-
-bool RAS_IPolyMaterial::CastsShadows() const
-{
- return (m_flag & RAS_CASTSHADOW) != 0;
-}
-
-bool RAS_IPolyMaterial::OnlyShadow() const
-{
- return (m_flag & RAS_ONLYSHADOW) != 0;
-}
-
-bool RAS_IPolyMaterial::UsesObjectColor() const
-{
- return !(m_flag & RAS_BLENDERGLSL);
-}
-
-unsigned int RAS_IPolyMaterial::m_newpolymatid = 0;
-
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
deleted file mode 100644
index 7023d305510..00000000000
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
+++ /dev/null
@@ -1,206 +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_IPolygonMaterial.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_IPOLYGONMATERIAL_H__
-#define __RAS_IPOLYGONMATERIAL_H__
-
-#include "STR_HashedString.h"
-
-#include "MT_Vector3.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_IRasterizer;
-struct Material;
-struct Image;
-struct Scene;
-class SCA_IScene;
-struct GameSettings;
-
-enum MaterialProps
-{
- RAS_ZSORT =1,
- RAS_TRANSPARENT =2,
- RAS_TRIANGLE =4,
- RAS_MULTITEX =8,
- RAS_MULTILIGHT =16,
- RAS_BLENDERMAT =32,
- RAS_GLSHADER =64,
- RAS_AUTOGEN =128,
- RAS_NORMAL =256,
- RAS_DEFMULTI =512,
- RAS_BLENDERGLSL =1024,
- RAS_CASTSHADOW =2048,
- RAS_ONLYSHADOW =4096,
-};
-
-/**
- * Polygon Material on which the material buckets are sorted
- *
- */
-class RAS_IPolyMaterial
-{
- //todo: remove these variables from this interface/protocol class
-protected:
- STR_HashedString m_texturename;
- STR_HashedString m_materialname; //also needed for touchsensor
- int m_tile;
- int m_tilexrep,m_tileyrep;
- int m_drawingmode;
- int m_alphablend;
- bool m_alpha;
- bool m_zsort;
- bool m_light;
- int m_materialindex;
-
- unsigned int m_polymatid;
- static unsigned int m_newpolymatid;
-
- // will move...
- unsigned int m_flag;//MaterialProps
- int m_multimode; // sum of values
-public:
- MT_Vector3 m_diffuse;
- float m_shininess;
- MT_Vector3 m_specular;
- float m_specularity;
-
- /** Used to store caching information for materials. */
- typedef void* TCachingInfo;
-
- // care! these are taken from blender polygonflags, see file DNA_mesh_types.h for #define TF_BILLBOARD etc.
- enum MaterialFlags
- {
- BILLBOARD_SCREENALIGNED = 512, /* GEMAT_HALO */
- BILLBOARD_AXISALIGNED = 1024, /* GEMAT_BILLBOARD */
- SHADOW =2048 /* GEMAT_SHADOW */
- };
-
- RAS_IPolyMaterial();
- RAS_IPolyMaterial(const STR_String& texname,
- const STR_String& matname,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int transp,
- bool alpha,
- bool zsort);
- void Initialize(const STR_String& texname,
- const STR_String& matname,
- int materialindex,
- int tile,
- int tilexrep,
- int tileyrep,
- int transp,
- bool alpha,
- bool zsort,
- bool light,
- bool image,
- struct GameSettings* game);
-
- virtual ~RAS_IPolyMaterial() {}
-
- /**
- * 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 0; }
-
- /**
- * Activates the material in the 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.
- */
- virtual bool Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const
- {
- return false;
- }
- virtual void ActivateMeshSlot(const class RAS_MeshSlot & ms, RAS_IRasterizer* rasty) const {}
-
- virtual bool Equals(const RAS_IPolyMaterial& lhs) const;
- bool Less(const RAS_IPolyMaterial& rhs) const;
- //int GetLightLayer() const;
- bool IsAlpha() const;
- bool IsZSort() const;
- unsigned int hash() const;
- int GetDrawingMode() const;
- const STR_String& GetMaterialName() const;
- dword GetMaterialNameHash() const;
- const STR_String& GetTextureName() const;
- unsigned int GetFlag() const;
- int GetMaterialIndex() const;
-
- virtual Material* GetBlenderMaterial() const;
- virtual Image* GetBlenderImage() const;
- virtual unsigned int* GetMCol() const;
- virtual Scene* GetBlenderScene() const;
- virtual void ReleaseMaterial();
- virtual void GetMaterialRGBAColor(unsigned char *rgba) const;
- virtual bool UsesLighting(RAS_IRasterizer *rasty) const;
- virtual bool UsesObjectColor() const;
- virtual bool CastsShadows() const;
- virtual bool OnlyShadow() const;
-
- virtual void Replace_IScene(SCA_IScene *val) {} /* overridden by KX_BlenderMaterial */
-
- /**
- * \return the equivalent drawing mode for the material settings (equivalent to old TexFace tface->mode).
- */
- int ConvertFaceMode(struct GameSettings *game, bool image) const;
-
- /*
- * PreCalculate texture gen
- */
- virtual void OnConstruction() {}
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IPolyMaterial")
-#endif
-};
-
-inline bool operator ==( const RAS_IPolyMaterial & rhs,const RAS_IPolyMaterial & lhs)
-{
- return ( rhs.Equals(lhs));
-}
-
-inline bool operator < ( const RAS_IPolyMaterial & lhs, const RAS_IPolyMaterial & rhs)
-{
- return lhs.Less(rhs);
-}
-
-#endif /* __RAS_IPOLYGONMATERIAL_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
deleted file mode 100644
index dc92408915b..00000000000
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ /dev/null
@@ -1,506 +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_IRasterizer.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_IRASTERIZER_H__
-#define __RAS_IRASTERIZER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "STR_HashedString.h"
-
-#include "MT_CmMatrix4x4.h"
-#include "MT_Matrix4x4.h"
-
-#include "RAS_TexVert.h"
-
-#include <vector>
-using namespace std;
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class RAS_ICanvas;
-class RAS_IPolyMaterial;
-class RAS_MeshSlot;
-class RAS_ILightObject;
-class SCA_IScene;
-class RAS_IOffScreen;
-class RAS_ISync;
-
-typedef vector<unsigned short> KX_IndexArray;
-typedef vector<RAS_TexVert> KX_VertexArray;
-typedef vector<KX_VertexArray *> vecVertexArray;
-typedef vector<KX_IndexArray *> vecIndexArrays;
-
-/**
- * 3D rendering device context interface.
- */
-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() {};
-
- /**
- * Drawing types
- */
- enum DrawType {
- KX_BOUNDINGBOX = 1,
- KX_WIREFRAME,
- KX_SOLID,
- KX_SHADED,
- KX_TEXTURED,
- KX_SHADOW,
- };
-
- /**
- * Drawing modes
- */
-
- enum DrawMode {
- KX_MODE_LINES = 1,
- KX_MODE_TRIANGLES,
- KX_MODE_QUADS,
- };
-
- /**
- * Valid SetDepthMask parameters
- */
- enum DepthMask {
- KX_DEPTHMASK_ENABLED = 1,
- KX_DEPTHMASK_DISABLED,
- };
-
- /**
- */
- enum {
- RAS_RENDER_3DPOLYGON_TEXT = 64, /* GEMAT_TEXT */
- KX_BACKCULL = 16, /* GEMAT_BACKCULL */
- KX_TEX = 4096, /* GEMAT_TEX */
- KX_LINES = 32768,
- };
-
- /**
- * Stereo mode types
- */
- enum StereoMode {
- RAS_STEREO_NOSTEREO = 1,
- RAS_STEREO_QUADBUFFERED,
- RAS_STEREO_ABOVEBELOW,
- RAS_STEREO_INTERLACED,
- RAS_STEREO_ANAGLYPH,
- RAS_STEREO_SIDEBYSIDE,
- RAS_STEREO_VINTERLACE,
- RAS_STEREO_DOME,
- RAS_STEREO_3DTVTOPBOTTOM,
-
- RAS_STEREO_MAXSTEREO
- };
-
- /**
- * Texture gen modes.
- */
- enum TexCoGen {
- RAS_TEXCO_GEN, /* < GPU will generate texture coordinates */
- RAS_TEXCO_ORCO, /* < Vertex coordinates (object space) */
- RAS_TEXCO_GLOB, /* < Vertex coordinates (world space) */
- RAS_TEXCO_UV, /* < UV coordinates */
- RAS_TEXCO_OBJECT, /* < Use another object's position as coordinates */
- RAS_TEXCO_LAVECTOR, /* < Light vector as coordinates */
- RAS_TEXCO_VIEW, /* < View vector as coordinates */
- RAS_TEXCO_STICKY, /* < Sticky coordinates */
- RAS_TEXCO_WINDOW, /* < Window coordinates */
- RAS_TEXCO_NORM, /* < Normal coordinates */
- RAS_TEXTANGENT, /* < */
- RAS_TEXCO_VCOL, /* < Vertex Color */
- RAS_TEXCO_DISABLE, /* < Disable this texture unit (cached) */
- };
-
- /**
- * Render pass identifiers for stereo.
- */
- enum StereoEye {
- RAS_STEREO_LEFTEYE = 1,
- RAS_STEREO_RIGHTEYE,
- };
-
- /**
- * Mipmap options
- */
- enum MipmapOption {
- RAS_MIPMAP_NONE,
- RAS_MIPMAP_NEAREST,
- RAS_MIPMAP_LINEAR,
-
- RAS_MIPMAP_MAX, /* Should always be last */
- };
-
- /**
- * SetDepthMask enables or disables writing a fragment's depth value
- * to the Z buffer.
- */
- virtual void SetDepthMask(DepthMask depthmask) = 0;
-
- /**
- * SetMaterial sets the material settings for subsequent primitives
- * to be rendered with.
- * The material will be cached.
- */
- virtual bool SetMaterial(const RAS_IPolyMaterial &mat) = 0;
-
- /**
- * Init initializes the renderer.
- */
- virtual bool Init() = 0;
-
- /**
- * Exit cleans up the renderer.
- */
- virtual void Exit() = 0;
-
- /**
- * BeginFrame is called at the start of each frame.
- */
- virtual bool BeginFrame(double time) = 0;
-
- /**
- * ClearColorBuffer clears the color buffer.
- */
- virtual void ClearColorBuffer() = 0;
-
- /**
- * ClearDepthBuffer clears the depth buffer.
- */
- virtual void ClearDepthBuffer() = 0;
-
- /**
- * ClearCachingInfo clears the currently cached material.
- */
- virtual void ClearCachingInfo(void) = 0;
-
- /**
- * EndFrame is called at the end of each frame.
- */
- virtual void EndFrame() = 0;
-
- /**
- * SetRenderArea sets the render area from the 2d canvas.
- * Returns true if only of subset of the canvas is used.
- */
- virtual void SetRenderArea() = 0;
-
- // Stereo Functions
- /**
- * SetStereoMode will set the stereo mode
- */
- virtual void SetStereoMode(const StereoMode stereomode) = 0;
-
- /**
- * Stereo can be used to query if the rasterizer is in stereo mode.
- * \return true if stereo mode is enabled.
- */
- virtual bool Stereo() = 0;
- virtual StereoMode GetStereoMode() = 0;
- virtual bool InterlacedStereo() = 0;
-
- /**
- * Sets which eye buffer subsequent primitives will be rendered to.
- */
- virtual void SetEye(const StereoEye eye) = 0;
- virtual StereoEye GetEye() = 0;
-
- /**
- * Sets the distance between eyes for stereo mode.
- */
- virtual void SetEyeSeparation(const float eyeseparation) = 0;
- virtual float GetEyeSeparation() = 0;
-
- /**
- * Sets the focal length for stereo mode.
- */
- virtual void SetFocalLength(const float focallength) = 0;
- virtual float GetFocalLength() = 0;
-
- /**
- * Create an offscreen render buffer that can be used as target for render.
- * For the time being, it is only used in VideoTexture for custom render.
- */
- virtual RAS_IOffScreen *CreateOffScreen(int width, int height, int samples, int target) = 0;
-
- /**
- * Create a sync object
- * For use with offscreen render
- */
- virtual RAS_ISync *CreateSync(int type) = 0;
-
- /**
- * SwapBuffers swaps the back buffer with the front buffer.
- */
- virtual void SwapBuffers() = 0;
-
- // Drawing Functions
- /**
- * IndexPrimitives: Renders primitives from mesh slot.
- */
- virtual void IndexPrimitives(class RAS_MeshSlot &ms) = 0;
-
- /**
- * IndexPrimitives_3DText will render text into the polygons.
- */
- virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat) = 0;
-
- virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat) = 0;
-
- /* This one should become our final version, methinks. */
- /**
- * Set the projection matrix for the rasterizer. This projects
- * from camera coordinates to window coordinates.
- * \param mat The projection matrix.
- */
- virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat) = 0;
-
- /**
- * Sets the modelview matrix.
- */
- virtual void SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Matrix3x3 &ori,
- const MT_Point3 &pos, const MT_Vector3 &scale, bool perspective) = 0;
-
- /**
- */
- virtual const MT_Point3& GetCameraPosition() = 0;
- virtual bool GetCameraOrtho() = 0;
-
- /**
- * Fog
- */
- virtual void SetFog(short type, float start, float dist, float intensity, float color[3]) = 0;
- virtual void DisplayFog() = 0;
- virtual void EnableFog(bool enable) = 0;
-
- virtual void SetBackColor(float color[3]) = 0;
-
- /**
- * \param drawingmode = KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
- */
- virtual void SetDrawingMode(int drawingmode) = 0;
-
- /**
- * \return the current drawing mode: KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
- */
- virtual int GetDrawingMode() = 0;
-
- /**
- * Sets face culling
- */
- virtual void SetCullFace(bool enable) = 0;
-
- /**
- * Sets wireframe mode.
- */
- virtual void SetLines(bool enable) = 0;
-
- /**
- */
- virtual double GetTime() = 0;
-
- /**
- * Generates a projection matrix from the specified frustum.
- * \param left the left clipping plane
- * \param right the right clipping plane
- * \param bottom the bottom clipping plane
- * \param top the top clipping plane
- * \param frustnear the near clipping plane
- * \param frustfar the far clipping plane
- * \return a 4x4 matrix representing the projection transform.
- */
- virtual MT_Matrix4x4 GetFrustumMatrix(
- float left, float right, float bottom, float top,
- float frustnear, float frustfar,
- float focallength = 0.0f, bool perspective = true) = 0;
-
- /**
- * Generates a orthographic projection matrix from the specified frustum.
- * \param left the left clipping plane
- * \param right the right clipping plane
- * \param bottom the bottom clipping plane
- * \param top the top clipping plane
- * \param frustnear the near clipping plane
- * \param frustfar the far clipping plane
- * \return a 4x4 matrix representing the projection transform.
- */
- virtual MT_Matrix4x4 GetOrthoMatrix(
- float left, float right, float bottom, float top,
- float frustnear, float frustfar) = 0;
-
- /**
- * Sets the specular color component of the lighting equation.
- */
- virtual void SetSpecularity(float specX, float specY, float specZ, float specval) = 0;
-
- /**
- * Sets the specular exponent component of the lighting equation.
- */
- virtual void SetShinyness(float shiny) = 0;
-
- /**
- * Sets the diffuse color component of the lighting equation.
- */
- virtual void SetDiffuse(float difX,float difY, float difZ, float diffuse) = 0;
-
- /**
- * Sets the emissive color component of the lighting equation.
- */
- virtual void SetEmissive(float eX, float eY, float eZ, float e) = 0;
-
- virtual void SetAmbientColor(float color[3]) = 0;
- virtual void SetAmbient(float factor) = 0;
-
- /**
- * Sets a polygon offset. z depth will be: z1 = mult*z0 + add
- */
- virtual void SetPolygonOffset(float mult, float add) = 0;
-
- virtual void DrawDebugLine(SCA_IScene *scene, const MT_Vector3 &from, const MT_Vector3 &to, const MT_Vector3& color) = 0;
- virtual void DrawDebugCircle(SCA_IScene *scene, const MT_Vector3 &center, const MT_Scalar radius,
- const MT_Vector3 &color, const MT_Vector3 &normal, int nsector) = 0;
- virtual void FlushDebugShapes(SCA_IScene *scene) = 0;
-
- virtual void SetTexCoordNum(int num) = 0;
- virtual void SetAttribNum(int num) = 0;
- virtual void SetTexCoord(TexCoGen coords, int unit) = 0;
- virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0) = 0;
-
- virtual const MT_Matrix4x4 &GetViewMatrix() const = 0;
- virtual const MT_Matrix4x4 &GetViewInvMatrix() const = 0;
-
- virtual bool QueryLists() { return false; }
- virtual bool QueryArrays() { return false; }
-
- virtual void EnableMotionBlur(float motionblurvalue) = 0;
- virtual void DisableMotionBlur() = 0;
-
- virtual float GetMotionBlurValue() = 0;
- virtual int GetMotionBlurState() = 0;
- virtual void SetMotionBlurState(int newstate) = 0;
-
- virtual void SetAlphaBlend(int alphablend) = 0;
- virtual void SetFrontFace(bool ccw) = 0;
-
- virtual void SetAnisotropicFiltering(short level) = 0;
- virtual short GetAnisotropicFiltering() = 0;
-
- virtual void SetMipmapping(MipmapOption val) = 0;
- virtual MipmapOption GetMipmapping() = 0;
-
- virtual void SetUsingOverrideShader(bool val) = 0;
- virtual bool GetUsingOverrideShader() = 0;
-
- /**
- * Render Tools
- */
- virtual void applyTransform(float *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,
- const float color[4], const float mat[16], 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 RAS_ILightObject *CreateLight() = 0;
-
- virtual void AddLight(RAS_ILightObject *lightobject) = 0;
-
- virtual void RemoveLight(RAS_ILightObject *lightobject) = 0;
-
- virtual void MotionBlur() = 0;
-
- virtual void SetClientObject(void *obj) = 0;
-
- virtual void SetAuxilaryClientInfo(void *inf) = 0;
-
- /**
- * Prints information about what the hardware supports.
- */
- virtual void PrintHardwareInfo() = 0;
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRasterizer")
-#endif
-};
-
-#endif /* __RAS_IRASTERIZER_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_ISync.h b/source/gameengine/Rasterizer/RAS_ISync.h
deleted file mode 100644
index 7e34172c2a3..00000000000
--- a/source/gameengine/Rasterizer/RAS_ISync.h
+++ /dev/null
@@ -1,48 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file RAS_ISync.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_ISYNC_H__
-#define __RAS_ISYNC_H__
-
-class RAS_ISync
-{
-public:
- enum RAS_SYNC_TYPE {
- RAS_SYNC_TYPE_FENCE = 0,
- };
- virtual ~RAS_ISync() {}
-
- virtual bool Create(RAS_SYNC_TYPE type) = 0;
- virtual void Destroy() = 0;
- virtual void Wait() = 0;
-};
-
-#endif /* __RAS_ISYNC_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
deleted file mode 100644
index 9cd8f77adfd..00000000000
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
+++ /dev/null
@@ -1,679 +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_MaterialBucket.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_MaterialBucket.h"
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_TexVert.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_MeshObject.h"
-#include "RAS_Deformer.h" // __NLA
-
-/* mesh slot */
-
-RAS_MeshSlot::RAS_MeshSlot() : SG_QList()
-{
- m_clientObj = NULL;
- m_pDeformer = NULL;
- m_OpenGLMatrix = NULL;
- m_mesh = NULL;
- m_bucket = NULL;
- m_bVisible = false;
- m_bCulled = true;
- m_bObjectColor = false;
- m_RGBAcolor = MT_Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- m_DisplayList = NULL;
- m_bDisplayList = true;
- m_joinSlot = NULL;
- m_pDerivedMesh = NULL;
-}
-
-RAS_MeshSlot::~RAS_MeshSlot()
-{
- RAS_DisplayArrayList::iterator it;
-
-#ifdef USE_SPLIT
- Split(true);
-
- while (m_joinedSlots.size())
- m_joinedSlots.front()->Split(true);
-#endif
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- (*it)->m_users--;
- if ((*it)->m_users == 0)
- delete *it;
- }
-
- if (m_DisplayList) {
- m_DisplayList->Release();
- m_DisplayList = NULL;
- }
-}
-
-RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot) : SG_QList()
-{
- RAS_DisplayArrayList::iterator it;
-
- m_clientObj = NULL;
- m_pDeformer = NULL;
- m_pDerivedMesh = NULL;
- m_OpenGLMatrix = NULL;
- m_mesh = slot.m_mesh;
- m_bucket = slot.m_bucket;
- m_bVisible = slot.m_bVisible;
- m_bCulled = slot.m_bCulled;
- m_bObjectColor = slot.m_bObjectColor;
- m_RGBAcolor = slot.m_RGBAcolor;
- m_DisplayList = NULL;
- m_bDisplayList = slot.m_bDisplayList;
- m_joinSlot = NULL;
- m_currentArray = slot.m_currentArray;
- m_displayArrays = slot.m_displayArrays;
- m_joinedSlots = slot.m_joinedSlots;
-
- m_startarray = slot.m_startarray;
- m_startvertex = slot.m_startvertex;
- m_startindex = slot.m_startindex;
- m_endarray = slot.m_endarray;
- m_endvertex = slot.m_endvertex;
- m_endindex = slot.m_endindex;
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- // don't copy display arrays for now because it breaks python
- // access to vertices, but we'll need a solution if we want to
- // join display arrays for reducing draw calls.
- //*it = new RAS_DisplayArray(**it);
- //(*it)->m_users = 1;
-
- (*it)->m_users++;
- }
-}
-
-void RAS_MeshSlot::init(RAS_MaterialBucket *bucket, int numverts)
-{
- m_bucket = bucket;
-
- SetDisplayArray(numverts);
-
- m_startarray = 0;
- m_startvertex = 0;
- m_startindex = 0;
- m_endarray = 0;
- m_endvertex = 0;
- m_endindex = 0;
-}
-
-void RAS_MeshSlot::begin(RAS_MeshSlot::iterator& it)
-{
- int startvertex, endvertex;
- int startindex, endindex;
-
- it.array = m_displayArrays.empty() ? NULL : m_displayArrays[m_startarray];
-
- if (it.array == NULL || it.array->m_index.size() == 0 || it.array->m_vertex.size() == 0) {
- it.array = NULL;
- it.vertex = NULL;
- it.index = NULL;
- it.startvertex = 0;
- it.endvertex = 0;
- it.totindex = 0;
- }
- else {
- startvertex = m_startvertex;
- endvertex = (m_startarray == m_endarray)? m_endvertex: it.array->m_vertex.size();
- startindex = m_startindex;
- endindex = (m_startarray == m_endarray)? m_endindex: it.array->m_index.size();
-
- it.vertex = &it.array->m_vertex[0];
- it.index = &it.array->m_index[startindex];
- it.startvertex = startvertex;
- it.endvertex = endvertex;
- it.totindex = endindex-startindex;
- it.arraynum = m_startarray;
- }
-}
-
-void RAS_MeshSlot::next(RAS_MeshSlot::iterator& it)
-{
- int startvertex, endvertex;
- int startindex, endindex;
-
- if (it.arraynum == (size_t)m_endarray) {
- it.array = NULL;
- it.vertex = NULL;
- it.index = NULL;
- it.startvertex = 0;
- it.endvertex = 0;
- it.totindex = 0;
- }
- else {
- it.arraynum++;
- it.array = m_displayArrays[it.arraynum];
-
- startindex = 0;
- endindex = (it.arraynum == (size_t)m_endarray)? m_endindex: it.array->m_index.size();
- startvertex = 0;
- endvertex = (it.arraynum == (size_t)m_endarray)? m_endvertex: it.array->m_vertex.size();
-
- it.vertex = &it.array->m_vertex[0];
- it.index = &it.array->m_index[startindex];
- it.startvertex = startvertex;
- it.endvertex = endvertex;
- it.totindex = endindex-startindex;
- }
-}
-
-bool RAS_MeshSlot::end(RAS_MeshSlot::iterator& it)
-{
- return (it.array == NULL);
-}
-
-RAS_DisplayArray *RAS_MeshSlot::CurrentDisplayArray()
-{
- return m_currentArray;
-}
-
-void RAS_MeshSlot::SetDisplayArray(int numverts)
-{
- RAS_DisplayArrayList::iterator it;
- RAS_DisplayArray *darray = NULL;
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- darray = *it;
-
- if (darray->m_type == numverts) {
- if (darray->m_index.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_INDEX)
- darray = NULL;
- else if (darray->m_vertex.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_VERTEX)
- darray = NULL;
- else
- break;
- }
- else
- darray = NULL;
- }
-
- if (!darray) {
- darray = new RAS_DisplayArray();
- darray->m_users = 1;
-
- if (numverts == 2) darray->m_type = RAS_DisplayArray::LINE;
- else if (numverts == 3) darray->m_type = RAS_DisplayArray::TRIANGLE;
- else darray->m_type = RAS_DisplayArray::QUAD;
-
- m_displayArrays.push_back(darray);
-
- if (numverts == 2)
- darray->m_type = RAS_DisplayArray::LINE;
- else if (numverts == 3)
- darray->m_type = RAS_DisplayArray::TRIANGLE;
- else if (numverts == 4)
- darray->m_type = RAS_DisplayArray::QUAD;
-
- m_endarray = m_displayArrays.size()-1;
- m_endvertex = 0;
- m_endindex = 0;
- }
-
- m_currentArray = darray;
-}
-
-void RAS_MeshSlot::AddPolygon(int numverts)
-{
- SetDisplayArray(numverts);
-}
-
-int RAS_MeshSlot::AddVertex(const RAS_TexVert& tv)
-{
- RAS_DisplayArray *darray;
- int offset;
-
- darray = m_currentArray;
- darray->m_vertex.push_back(tv);
- offset = darray->m_vertex.size()-1;
-
- if (darray == m_displayArrays[m_endarray])
- m_endvertex++;
-
- return offset;
-}
-
-void RAS_MeshSlot::AddPolygonVertex(int offset)
-{
- RAS_DisplayArray *darray;
-
- darray = m_currentArray;
- darray->m_index.push_back(offset);
-
- if (darray == m_displayArrays[m_endarray])
- m_endindex++;
-}
-
-void RAS_MeshSlot::UpdateDisplayArraysOffset()
-{
- unsigned int offset = 0;
- for (unsigned short i = 0; i < m_displayArrays.size(); ++i) {
- RAS_DisplayArray *darray = m_displayArrays[i];
- darray->m_offset = offset;
- offset += darray->m_vertex.size();
- }
-}
-
-void RAS_MeshSlot::SetDeformer(RAS_Deformer* deformer)
-{
- if (deformer && m_pDeformer != deformer) {
- RAS_DisplayArrayList::iterator it;
- if (deformer->ShareVertexArray()) {
- // this deformer uses the base vertex array, first release the current ones
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- (*it)->m_users--;
- if ((*it)->m_users == 0)
- delete *it;
- }
- m_displayArrays.clear();
- // then hook to the base ones
- RAS_MeshMaterial *mmat = m_mesh->GetMeshMaterial(m_bucket->GetPolyMaterial());
- if (mmat && mmat->m_baseslot) {
- m_displayArrays = mmat->m_baseslot->m_displayArrays;
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- (*it)->m_users++;
- }
- }
- }
- else {
- // no sharing
- // we create local copy of RAS_DisplayArray when we have a deformer:
- // this way we can avoid conflict between the vertex cache of duplicates
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- if (deformer->UseVertexArray()) {
- // the deformer makes use of vertex array, make sure we have our local copy
- if ((*it)->m_users > 1) {
- // only need to copy if there are other users
- // note that this is the usual case as vertex arrays are held by the material base slot
- RAS_DisplayArray *newarray = new RAS_DisplayArray(*(*it));
- newarray->m_users = 1;
- (*it)->m_users--;
- *it = newarray;
- }
- } else {
- // the deformer is not using vertex array (Modifier), release them
- (*it)->m_users--;
- if ((*it)->m_users == 0)
- delete *it;
- }
- }
- if (!deformer->UseVertexArray()) {
- m_displayArrays.clear();
- m_startarray = 0;
- m_startvertex = 0;
- m_startindex = 0;
- m_endarray = 0;
- m_endvertex = 0;
- m_endindex = 0;
- }
- }
- }
- m_pDeformer = deformer;
-}
-
-bool RAS_MeshSlot::Equals(RAS_MeshSlot *target)
-{
- if (!m_OpenGLMatrix || !target->m_OpenGLMatrix)
- return false;
- if (m_pDeformer || target->m_pDeformer)
- return false;
- if (m_bVisible != target->m_bVisible)
- return false;
- if (m_bObjectColor != target->m_bObjectColor)
- return false;
- if (m_bObjectColor && !(m_RGBAcolor == target->m_RGBAcolor))
- return false;
-
- return true;
-}
-
-bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance)
-{
- RAS_DisplayArrayList::iterator it;
- iterator mit;
- size_t i;
-
- // verify if we can join
- if (m_joinSlot || (m_joinedSlots.empty() == false) || target->m_joinSlot)
- return false;
-
- if (!Equals(target))
- return false;
-
- MT_Vector3 co(&m_OpenGLMatrix[12]);
- MT_Vector3 targetco(&target->m_OpenGLMatrix[12]);
-
- if ((co - targetco).length() > distance)
- return false;
-
- MT_Matrix4x4 mat(m_OpenGLMatrix);
- MT_Matrix4x4 targetmat(target->m_OpenGLMatrix);
- targetmat.invert();
-
- MT_Matrix4x4 transform = targetmat*mat;
-
- // m_mesh, clientobj
- m_joinSlot = target;
- m_joinInvTransform = transform;
- m_joinInvTransform.invert();
- target->m_joinedSlots.push_back(this);
-
- MT_Matrix4x4 ntransform = m_joinInvTransform.transposed();
- ntransform[0][3] = ntransform[1][3] = ntransform[2][3] = 0.0f;
-
- for (begin(mit); !end(mit); next(mit))
- for (i=mit.startvertex; i<mit.endvertex; i++)
- mit.vertex[i].Transform(transform, ntransform);
-
- /* We know we'll need a list at least this big, reserve in advance */
- target->m_displayArrays.reserve(target->m_displayArrays.size() + m_displayArrays.size());
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- target->m_displayArrays.push_back(*it);
- target->m_endarray++;
- target->m_endvertex = target->m_displayArrays.back()->m_vertex.size();
- target->m_endindex = target->m_displayArrays.back()->m_index.size();
- }
-
- if (m_DisplayList) {
- m_DisplayList->Release();
- m_DisplayList = NULL;
- }
- if (target->m_DisplayList) {
- target->m_DisplayList->Release();
- target->m_DisplayList = NULL;
- }
-
- return true;
-#if 0
- return false;
-#endif
-}
-
-bool RAS_MeshSlot::Split(bool force)
-{
- list<RAS_MeshSlot*>::iterator jit;
- RAS_MeshSlot *target = m_joinSlot;
- RAS_DisplayArrayList::iterator it, jt;
- iterator mit;
- size_t i, found0 = 0, found1 = 0;
-
- if (target && (force || !Equals(target))) {
- m_joinSlot = NULL;
-
- for (jit=target->m_joinedSlots.begin(); jit!=target->m_joinedSlots.end(); jit++) {
- if (*jit == this) {
- target->m_joinedSlots.erase(jit);
- found0 = 1;
- break;
- }
- }
-
- if (!found0)
- abort();
-
- for (it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
- found1 = 0;
- for (jt=target->m_displayArrays.begin(); jt!=target->m_displayArrays.end(); jt++) {
- if (*jt == *it) {
- target->m_displayArrays.erase(jt);
- target->m_endarray--;
- found1 = 1;
- break;
- }
- }
-
- if (!found1)
- abort();
- }
-
- if (target->m_displayArrays.empty() == false) {
- target->m_endvertex = target->m_displayArrays.back()->m_vertex.size();
- target->m_endindex = target->m_displayArrays.back()->m_index.size();
- }
- else {
- target->m_endvertex = 0;
- target->m_endindex = 0;
- }
-
- MT_Matrix4x4 ntransform = m_joinInvTransform.inverse().transposed();
- ntransform[0][3] = ntransform[1][3] = ntransform[2][3] = 0.0f;
-
- for (begin(mit); !end(mit); next(mit))
- for (i=mit.startvertex; i<mit.endvertex; i++)
- mit.vertex[i].Transform(m_joinInvTransform, ntransform);
-
- if (target->m_DisplayList) {
- target->m_DisplayList->Release();
- target->m_DisplayList = NULL;
- }
-
- return true;
- }
-
- return false;
-}
-
-
-#ifdef USE_SPLIT
-bool RAS_MeshSlot::IsCulled()
-{
- if (m_joinSlot)
- return true;
- if (!m_bCulled)
- return false;
- list<RAS_MeshSlot*>::iterator it;
- for (it=m_joinedSlots.begin(); it!=m_joinedSlots.end(); it++)
- if (!(*it)->m_bCulled)
- return false;
- return true;
-}
-#endif
-
-/* material bucket sorting */
-
-struct RAS_MaterialBucket::less
-{
- bool operator()(const RAS_MaterialBucket* x, const RAS_MaterialBucket* y) const
- {
- return *x->GetPolyMaterial() < *y->GetPolyMaterial();
- }
-};
-
-/* material bucket */
-
-RAS_MaterialBucket::RAS_MaterialBucket(RAS_IPolyMaterial* mat)
-{
- m_material = mat;
-}
-
-RAS_MaterialBucket::~RAS_MaterialBucket()
-{
-}
-
-RAS_IPolyMaterial* RAS_MaterialBucket::GetPolyMaterial() const
-{
- return m_material;
-}
-
-bool RAS_MaterialBucket::IsAlpha() const
-{
- return (m_material->IsAlpha());
-}
-
-bool RAS_MaterialBucket::IsZSort() const
-{
- return (m_material->IsZSort());
-}
-
-RAS_MeshSlot* RAS_MaterialBucket::AddMesh(int numverts)
-{
- RAS_MeshSlot *ms;
-
- m_meshSlots.push_back(RAS_MeshSlot());
-
- ms = &m_meshSlots.back();
- ms->init(this, numverts);
-
- return ms;
-}
-
-RAS_MeshSlot* RAS_MaterialBucket::CopyMesh(RAS_MeshSlot *ms)
-{
- m_meshSlots.push_back(RAS_MeshSlot(*ms));
-
- return &m_meshSlots.back();
-}
-
-void RAS_MaterialBucket::RemoveMesh(RAS_MeshSlot* ms)
-{
- list<RAS_MeshSlot>::iterator it;
-
- for (it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++) {
- if (&*it == ms) {
- m_meshSlots.erase(it);
- return;
- }
- }
-}
-
-list<RAS_MeshSlot>::iterator RAS_MaterialBucket::msBegin()
-{
- return m_meshSlots.begin();
-}
-
-list<RAS_MeshSlot>::iterator RAS_MaterialBucket::msEnd()
-{
- return m_meshSlots.end();
-}
-
-bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty)
-{
- bool uselights;
-
- if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && !m_material->CastsShadows())
- return false;
-
- if (rasty->GetDrawingMode() != RAS_IRasterizer::KX_SHADOW && m_material->OnlyShadow())
- return false;
-
- if (!rasty->SetMaterial(*m_material))
- return false;
-
- uselights= m_material->UsesLighting(rasty);
- rasty->ProcessLighting(uselights, cameratrans);
-
- return true;
-}
-
-void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_MeshSlot &ms)
-{
- m_material->ActivateMeshSlot(ms, rasty);
-
- if (ms.m_pDeformer)
- {
- if (ms.m_pDeformer->Apply(m_material))
- ms.m_mesh->SetMeshModified(true);
- // KX_ReInstanceShapeFromMesh(ms.m_mesh); // Recompute the physics mesh. (Can't call KX_* from RAS_)
- }
-
- if (IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
- ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix));
-
- rasty->PushMatrix();
- if (!ms.m_pDeformer || !ms.m_pDeformer->SkipVertexTransform())
- {
- rasty->applyTransform(ms.m_OpenGLMatrix,m_material->GetDrawingMode());
- }
-
- if (rasty->QueryLists())
- if (ms.m_DisplayList)
- ms.m_DisplayList->SetModified(ms.m_mesh->MeshModified());
-
- // verify if we can use display list, not for deformed object, and
- // also don't create a new display list when drawing shadow buffers,
- // then it won't have texture coordinates for actual drawing. also
- // for zsort we can't make a display list, since the polygon order
- // changes all the time.
- if (ms.m_pDeformer && ms.m_pDeformer->IsDynamic())
- ms.m_bDisplayList = false;
- else if (!ms.m_DisplayList && rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW)
- ms.m_bDisplayList = false;
- else if (IsZSort())
- ms.m_bDisplayList = false;
- else if (m_material->UsesObjectColor() && ms.m_bObjectColor)
- ms.m_bDisplayList = false;
- else
- ms.m_bDisplayList = true;
-
- if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) {
- // for text drawing using faces
- rasty->IndexPrimitives_3DText(ms, m_material);
- }
- else {
- rasty->IndexPrimitives(ms);
- }
-
- rasty->PopMatrix();
-}
-
-void RAS_MaterialBucket::Optimize(MT_Scalar distance)
-{
- /* TODO: still have to check before this works correct:
- * - lightlayer, frontface, text, billboard
- * - make it work with physics */
-
-#if 0
- list<RAS_MeshSlot>::iterator it;
- list<RAS_MeshSlot>::iterator jt;
-
- // greed joining on all following buckets
- for (it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++)
- for (jt=it, jt++; jt!=m_meshSlots.end(); jt++)
- jt->Join(&*it, distance);
-#endif
-}
-
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
deleted file mode 100644
index 75cc382c78c..00000000000
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h
+++ /dev/null
@@ -1,267 +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_MaterialBucket.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_MATERIALBUCKET_H__
-#define __RAS_MATERIALBUCKET_H__
-
-#include "RAS_TexVert.h"
-#include "CTR_Map.h"
-#include "SG_QList.h"
-
-#include "MT_Transform.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 */
-
-class KX_ListSlot
-{
-protected:
- int m_refcount;
-public:
- KX_ListSlot() { m_refcount = 1; }
- virtual ~KX_ListSlot() {}
- virtual int Release() {
- if (--m_refcount > 0)
- return m_refcount;
- delete this;
- return 0;
- }
- virtual KX_ListSlot* AddRef() {
- m_refcount++;
- return this;
- }
- virtual void SetModified(bool mod)=0;
-};
-
-/* An array with data used for OpenGL drawing */
-
-class RAS_DisplayArray
-{
-public:
- /** The offset relation to the previous RAS_DisplayArray.
- * For the user vertex are one big list but in C++ source
- * it's two different lists if we use quads and triangles.
- * So to fix that we add an offset.
- * This value is set in UpdateDisplayArraysOffset().
- */
- unsigned int m_offset;
- vector<RAS_TexVert> m_vertex;
- vector<unsigned short> m_index;
- /* LINE currently isn't used */
- enum { LINE = 2, TRIANGLE = 3, QUAD = 4 } m_type;
- //RAS_MeshSlot *m_origSlot;
-
- /* Number of RAS_MeshSlot using this array */
- int m_users;
-
- enum { BUCKET_MAX_INDEX = 65535 };
- enum { BUCKET_MAX_VERTEX = 65535 };
-};
-
-/* Entry of a RAS_MeshObject into RAS_MaterialBucket */
-typedef std::vector<RAS_DisplayArray*> RAS_DisplayArrayList;
-
-// The QList is used to link the mesh slots to the object
-// The DList is used to link the visible mesh slots to the material bucket
-class RAS_MeshSlot : public SG_QList
-{
- friend class RAS_ListRasterizer;
-private:
- // indices into display arrays
- int m_startarray;
- int m_endarray;
- int m_startindex;
- int m_endindex;
- int m_startvertex;
- int m_endvertex;
- RAS_DisplayArrayList m_displayArrays;
-
- // for construction only
- RAS_DisplayArray* m_currentArray;
-
-public:
- // for rendering
- RAS_MaterialBucket* m_bucket;
- RAS_MeshObject* m_mesh;
- void* m_clientObj;
- RAS_Deformer* m_pDeformer;
- DerivedMesh* m_pDerivedMesh;
- float* m_OpenGLMatrix;
- // visibility
- bool m_bVisible;
- bool m_bCulled;
- // object color
- bool m_bObjectColor;
- MT_Vector4 m_RGBAcolor;
- // display lists
- KX_ListSlot* m_DisplayList;
- bool m_bDisplayList;
- // joined mesh slots
- RAS_MeshSlot* m_joinSlot;
- MT_Matrix4x4 m_joinInvTransform;
- list<RAS_MeshSlot*> m_joinedSlots;
-
- RAS_MeshSlot();
- RAS_MeshSlot(const RAS_MeshSlot& slot);
- virtual ~RAS_MeshSlot();
-
- void init(RAS_MaterialBucket *bucket, int numverts);
-
- struct iterator {
- RAS_DisplayArray *array;
- RAS_TexVert *vertex;
- unsigned short *index;
- size_t startvertex;
- size_t endvertex;
- size_t totindex;
- size_t arraynum;
- };
-
- void begin(iterator& it);
- void next(iterator& it);
- bool end(iterator& it);
-
- /* used during construction */
- void SetDisplayArray(int numverts);
- RAS_DisplayArray *CurrentDisplayArray();
- void SetDeformer(RAS_Deformer* deformer);
-
- void AddPolygon(int numverts);
- int AddVertex(const RAS_TexVert& tv);
- void AddPolygonVertex(int offset);
-
- /// Update offset of each display array
- void UpdateDisplayArraysOffset();
-
- /* optimization */
- bool Split(bool force=false);
- bool Join(RAS_MeshSlot *target, MT_Scalar distance);
- bool Equals(RAS_MeshSlot *target);
-#ifdef USE_SPLIT
- bool IsCulled();
-#else
- bool IsCulled() { return m_bCulled; }
-#endif
- void SetCulled(bool culled) { m_bCulled = culled; }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MeshSlot")
-#endif
-};
-
-/* Used by RAS_MeshObject, to point to it's slots in a bucket */
-
-class RAS_MeshMaterial
-{
-public:
- RAS_MeshSlot *m_baseslot;
- class RAS_MaterialBucket *m_bucket;
-
- /* the KX_GameObject is used as a key here */
- CTR_Map<CTR_HashedPtr,RAS_MeshSlot*> m_slots;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MeshMaterial")
-#endif
-};
-
-/* Contains a list of display arrays with the same material,
- * and a mesh slot for each mesh that uses display arrays in
- * this bucket */
-
-class RAS_MaterialBucket
-{
-public:
- RAS_MaterialBucket(RAS_IPolyMaterial* mat);
- virtual ~RAS_MaterialBucket();
-
- /* Bucket Sorting */
- struct less;
- typedef set<RAS_MaterialBucket*, less> Set;
-
- /* Material Properties */
- RAS_IPolyMaterial* GetPolyMaterial() const;
- bool IsAlpha() const;
- bool IsZSort() const;
-
- /* Rendering */
- 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();
- list<RAS_MeshSlot>::iterator msEnd();
-
- class RAS_MeshSlot* AddMesh(int numverts);
- class RAS_MeshSlot* CopyMesh(class RAS_MeshSlot *ms);
- void RemoveMesh(class RAS_MeshSlot* ms);
- void Optimize(MT_Scalar distance);
- void ActivateMesh(RAS_MeshSlot* slot)
- {
- m_activeMeshSlotsHead.AddBack(slot);
- }
- SG_DList& GetActiveMeshSlots()
- {
- return m_activeMeshSlotsHead;
- }
- RAS_MeshSlot* GetNextActiveMeshSlot()
- {
- return (RAS_MeshSlot*)m_activeMeshSlotsHead.Remove();
- }
-
-private:
- list<RAS_MeshSlot> m_meshSlots; // all the mesh slots
- RAS_IPolyMaterial* m_material;
- SG_DList m_activeMeshSlotsHead; // only those which must be rendered
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MaterialBucket")
-#endif
-};
-
-#endif /* __RAS_MATERIAL_BUCKET */
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
deleted file mode 100644
index 4360464ed32..00000000000
--- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp
+++ /dev/null
@@ -1,573 +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_MeshObject.cpp
- * \ingroup bgerast
- */
-
-#include "DNA_key_types.h"
-#include "DNA_mesh_types.h"
-
-#include "CTR_HashedPtr.h"
-
-#include "RAS_MeshObject.h"
-#include "RAS_Polygon.h"
-#include "RAS_IPolygonMaterial.h"
-#include "RAS_Deformer.h"
-#include "MT_Point3.h"
-
-#include <algorithm>
-
-
-/* polygon sorting */
-
-struct RAS_MeshObject::polygonSlot
-{
- float m_z;
- int m_index[4];
-
- polygonSlot() {}
-
- /* pnorm is the normal from the plane equation that the distance from is
- * used to sort again. */
- void get(const RAS_TexVert *vertexarray, const unsigned short *indexarray,
- int offset, int nvert, const MT_Vector3& pnorm)
- {
- MT_Vector3 center(0, 0, 0);
- int i;
-
- for (i=0; i<nvert; i++) {
- m_index[i] = indexarray[offset+i];
- center += vertexarray[m_index[i]].getXYZ();
- }
-
- /* note we don't divide center by the number of vertices, since all
- * polygons have the same number of vertices, and that we leave out
- * the 4-th component of the plane equation since it is constant. */
- m_z = MT_dot(pnorm, center);
- }
-
- void set(unsigned short *indexarray, int offset, int nvert)
- {
- int i;
-
- for (i=0; i<nvert; i++)
- indexarray[offset+i] = m_index[i];
- }
-};
-
-struct RAS_MeshObject::backtofront
-{
- bool operator()(const polygonSlot &a, const polygonSlot &b) const
- {
- return a.m_z < b.m_z;
- }
-};
-
-struct RAS_MeshObject::fronttoback
-{
- bool operator()(const polygonSlot &a, const polygonSlot &b) const
- {
- return a.m_z > b.m_z;
- }
-};
-
-/* mesh object */
-
-STR_String RAS_MeshObject::s_emptyname = "";
-
-RAS_MeshObject::RAS_MeshObject(Mesh* mesh)
- : m_bModified(true),
- m_bMeshModified(true),
- m_mesh(mesh)
-{
- if (m_mesh && m_mesh->key)
- {
- KeyBlock *kb;
- int count=0;
- // initialize weight cache for shape objects
- // count how many keys in this mesh
- for (kb= (KeyBlock *)m_mesh->key->block.first; kb; kb= (KeyBlock *)kb->next)
- count++;
- m_cacheWeightIndex.resize(count,-1);
- }
-}
-
-RAS_MeshObject::~RAS_MeshObject()
-{
- vector<RAS_Polygon*>::iterator it;
-
- for (it=m_Polygons.begin(); it!=m_Polygons.end(); it++)
- delete (*it);
-
- m_sharedvertex_map.clear();
- m_Polygons.clear();
- m_materials.clear();
-}
-
-bool RAS_MeshObject::MeshModified()
-{
- return m_bMeshModified;
-}
-
-//unsigned int RAS_MeshObject::GetLightLayer()
-//{
-// return m_lightlayer;
-//}
-
-
-
-int RAS_MeshObject::NumMaterials()
-{
- return m_materials.size();
-}
-
-const STR_String& RAS_MeshObject::GetMaterialName(unsigned int matid)
-{
- RAS_MeshMaterial* mmat = GetMeshMaterial(matid);
-
- if (mmat)
- return mmat->m_bucket->GetPolyMaterial()->GetMaterialName();
-
- return s_emptyname;
-}
-
-RAS_MeshMaterial* RAS_MeshObject::GetMeshMaterial(unsigned int matid)
-{
- if ((m_materials.empty() == false) && (matid < m_materials.size()))
- {
- list<RAS_MeshMaterial>::iterator it = m_materials.begin();
- while (matid--) ++it;
- return &*it;
- }
-
- return NULL;
-}
-
-
-
-int RAS_MeshObject::NumPolygons()
-{
- return m_Polygons.size();
-}
-
-
-
-RAS_Polygon* RAS_MeshObject::GetPolygon(int num) const
-{
- return m_Polygons[num];
-}
-
-
-
-
- list<RAS_MeshMaterial>::iterator GetFirstMaterial();
- list<RAS_MeshMaterial>::iterator GetLastMaterial();
-list<RAS_MeshMaterial>::iterator RAS_MeshObject::GetFirstMaterial()
-{
- return m_materials.begin();
-}
-
-
-
-list<RAS_MeshMaterial>::iterator RAS_MeshObject::GetLastMaterial()
-{
- return m_materials.end();
-}
-
-
-
-void RAS_MeshObject::SetName(const char *name)
-{
- m_name = name;
-}
-
-
-
-STR_String& RAS_MeshObject::GetName()
-{
- return m_name;
-}
-
-
-
-const STR_String& RAS_MeshObject::GetTextureName(unsigned int matid)
-{
- RAS_MeshMaterial* mmat = GetMeshMaterial(matid);
-
- if (mmat)
- return mmat->m_bucket->GetPolyMaterial()->GetTextureName();
-
- return s_emptyname;
-}
-
-RAS_MeshMaterial *RAS_MeshObject::GetMeshMaterial(RAS_IPolyMaterial *mat)
-{
- list<RAS_MeshMaterial>::iterator mit;
-
- /* find a mesh material */
- for (mit = m_materials.begin(); mit != m_materials.end(); mit++)
- if (mit->m_bucket->GetPolyMaterial() == mat)
- return &*mit;
-
- return NULL;
-}
-
-int RAS_MeshObject::GetMaterialId(RAS_IPolyMaterial *mat)
-{
- list<RAS_MeshMaterial>::iterator mit;
- int imat;
-
- /* find a mesh material */
- for (imat=0, mit = m_materials.begin(); mit != m_materials.end(); mit++, imat++)
- if (mit->m_bucket->GetPolyMaterial() == mat)
- return imat;
-
- return -1;
-}
-
-RAS_Polygon* RAS_MeshObject::AddPolygon(RAS_MaterialBucket *bucket, int numverts)
-{
- RAS_MeshMaterial *mmat;
- RAS_Polygon *poly;
- RAS_MeshSlot *slot;
-
- /* find a mesh material */
- mmat = GetMeshMaterial(bucket->GetPolyMaterial());
-
- /* none found, create a new one */
- if (!mmat) {
- RAS_MeshMaterial meshmat;
- meshmat.m_bucket = bucket;
- meshmat.m_baseslot = meshmat.m_bucket->AddMesh(numverts);
- meshmat.m_baseslot->m_mesh = this;
- m_materials.push_back(meshmat);
- mmat = &m_materials.back();
- }
-
- /* add it to the bucket, this also adds new display arrays */
- slot = mmat->m_baseslot;
- slot->AddPolygon(numverts);
-
- /* create a new polygon */
- RAS_DisplayArray *darray = slot->CurrentDisplayArray();
- poly = new RAS_Polygon(bucket, darray, numverts);
- m_Polygons.push_back(poly);
-
- return poly;
-}
-
-void RAS_MeshObject::DebugColor(unsigned int abgr)
-{
- /*int numpolys = NumPolygons();
-
- for (int i=0;i<numpolys;i++) {
- RAS_Polygon* poly = m_polygons[i];
- for (int v=0;v<poly->VertexCount();v++)
- RAS_TexVert* vtx = poly->GetVertex(v)->setDebugRGBA(abgr);
- }
- */
-
- /* m_debugcolor = abgr; */
-}
-
-void RAS_MeshObject::SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba)
-{
- RAS_MeshMaterial *mmat = GetMeshMaterial(mat);
- RAS_MeshSlot *slot = mmat->m_baseslot;
- RAS_MeshSlot::iterator it;
- size_t i;
-
- for (slot->begin(it); !slot->end(it); slot->next(it))
- for (i=it.startvertex; i<it.endvertex; i++)
- it.vertex[i].SetRGBA(rgba);
-}
-
-void RAS_MeshObject::AddVertex(RAS_Polygon *poly, int i,
- const MT_Point3& xyz,
- const MT_Point2 uvs[RAS_TexVert::MAX_UNIT],
- const MT_Vector4& tangent,
- const unsigned int rgba,
- const MT_Vector3& normal,
- bool flat,
- int origindex)
-{
- RAS_TexVert texvert(xyz, uvs, tangent, rgba, normal, flat, origindex);
- RAS_MeshMaterial *mmat;
- RAS_DisplayArray *darray;
- RAS_MeshSlot *slot;
- int offset;
-
- mmat = GetMeshMaterial(poly->GetMaterial()->GetPolyMaterial());
- slot = mmat->m_baseslot;
- darray = slot->CurrentDisplayArray();
-
- { /* Shared Vertex! */
- /* find vertices shared between faces, with the restriction
- * that they exist in the same display array, and have the
- * same uv coordinate etc */
- vector<SharedVertex>& sharedmap = m_sharedvertex_map[origindex];
- vector<SharedVertex>::iterator it;
-
- for (it = sharedmap.begin(); it != sharedmap.end(); it++)
- {
- if (it->m_darray != darray)
- continue;
- if (!it->m_darray->m_vertex[it->m_offset].closeTo(&texvert))
- continue;
-
- /* found one, add it and we're done */
- if (poly->IsVisible())
- slot->AddPolygonVertex(it->m_offset);
- poly->SetVertexOffset(i, it->m_offset);
- return;
- }
- }
-
- /* no shared vertex found, add a new one */
- offset = slot->AddVertex(texvert);
- if (poly->IsVisible())
- slot->AddPolygonVertex(offset);
- poly->SetVertexOffset(i, offset);
-
- { /* Shared Vertex! */
- SharedVertex shared;
- shared.m_darray = darray;
- shared.m_offset = offset;
- m_sharedvertex_map[origindex].push_back(shared);
- }
-}
-
-int RAS_MeshObject::NumVertices(RAS_IPolyMaterial* mat)
-{
- RAS_MeshMaterial *mmat;
- RAS_MeshSlot *slot;
- RAS_MeshSlot::iterator it;
- size_t len = 0;
-
- mmat = GetMeshMaterial(mat);
- slot = mmat->m_baseslot;
- for (slot->begin(it); !slot->end(it); slot->next(it))
- len += it.endvertex - it.startvertex;
-
- return len;
-}
-
-
-RAS_TexVert* RAS_MeshObject::GetVertex(unsigned int matid,
- unsigned int index)
-{
- RAS_MeshMaterial *mmat;
- RAS_MeshSlot *slot;
- RAS_MeshSlot::iterator it;
- size_t len;
-
- mmat = GetMeshMaterial(matid);
-
- if (!mmat)
- return NULL;
-
- slot = mmat->m_baseslot;
- len = 0;
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- if (index >= len + it.endvertex - it.startvertex)
- len += it.endvertex - it.startvertex;
- else
- return &it.vertex[index - len];
- }
-
- return NULL;
-}
-
-const float* RAS_MeshObject::GetVertexLocation(unsigned int orig_index)
-{
- vector<SharedVertex>& sharedmap = m_sharedvertex_map[orig_index];
- vector<SharedVertex>::iterator it= sharedmap.begin();
- return it->m_darray->m_vertex[it->m_offset].getXYZ();
-}
-
-void RAS_MeshObject::AddMeshUser(void *clientobj, SG_QList *head, RAS_Deformer* deformer)
-{
- list<RAS_MeshMaterial>::iterator it;
- list<RAS_MeshMaterial>::iterator mit;
-
- for (it = m_materials.begin();it!=m_materials.end();++it) {
- /* always copy from the base slot, which is never removed
- * since new objects can be created with the same mesh data */
- if (deformer && !deformer->UseVertexArray())
- {
- // HACK!
- // this deformer doesn't use vertex array => derive mesh
- // we must keep only the mesh slots that have unique material id
- // this is to match the derived mesh drawing function
- // Need a better solution in the future: scan the derive mesh and create vertex array
- RAS_IPolyMaterial* curmat = it->m_bucket->GetPolyMaterial();
- if (curmat->GetFlag() & RAS_BLENDERGLSL)
- {
- for (mit = m_materials.begin(); mit != it; ++mit)
- {
- RAS_IPolyMaterial* mat = mit->m_bucket->GetPolyMaterial();
- if ((mat->GetFlag() & RAS_BLENDERGLSL) &&
- mat->GetMaterialIndex() == curmat->GetMaterialIndex())
- // no need to convert current mesh slot
- break;
- }
- if (mit != it)
- continue;
- }
- }
- RAS_MeshSlot *ms = it->m_bucket->CopyMesh(it->m_baseslot);
- ms->m_clientObj = clientobj;
- ms->SetDeformer(deformer);
- it->m_slots.insert(clientobj, ms);
- head->QAddBack(ms);
- }
-}
-
-void RAS_MeshObject::RemoveFromBuckets(void *clientobj)
-{
- list<RAS_MeshMaterial>::iterator it;
-
- for (it = m_materials.begin();it!=m_materials.end();++it) {
- RAS_MeshSlot **msp = it->m_slots[clientobj];
-
- if (!msp)
- continue;
-
- RAS_MeshSlot *ms = *msp;
-
- it->m_bucket->RemoveMesh(ms);
- it->m_slots.remove(clientobj);
- }
-}
-
-void RAS_MeshObject::EndConversion()
-{
-#if 0
- m_sharedvertex_map.clear(); // SharedVertex
- vector<vector<SharedVertex> > shared_null(0);
- shared_null.swap( m_sharedvertex_map ); /* really free the memory */
-#endif
-
- for (std::list<RAS_MeshMaterial>::iterator it = m_materials.begin();
- it != m_materials.end();
- ++it)
- {
- RAS_MeshSlot *ms = it->m_baseslot;
- ms->UpdateDisplayArraysOffset();
- }
-}
-
-//void RAS_MeshObject::Transform(const MT_Transform& trans)
-//{
- //m_trans.translate(MT_Vector3(0,0,1));//.operator *=(trans);
-
-// for (int i=0;i<m_Polygons.size();i++)
-// {
-// m_Polygons[i]->Transform(trans);
-// }
-//}
-
-
-/*
-void RAS_MeshObject::RelativeTransform(const MT_Vector3& vec)
-{
- for (int i=0;i<m_Polygons.size();i++)
- {
- m_Polygons[i]->RelativeTransform(vec);
- }
-}
-*/
-
-void RAS_MeshObject::SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform)
-{
- // Limitations: sorting is quite simple, and handles many
- // cases wrong, partially due to polygons being sorted per
- // bucket.
- //
- // a) mixed triangles/quads are sorted wrong
- // b) mixed materials are sorted wrong
- // c) more than 65k faces are sorted wrong
- // d) intersecting objects are sorted wrong
- // e) intersecting polygons are sorted wrong
- //
- // a) can be solved by making all faces either triangles or quads
- // if they need to be z-sorted. c) could be solved by allowing
- // larger buckets, b) and d) cannot be solved easily if we want
- // to avoid excessive state changes while drawing. e) would
- // require splitting polygons.
-
- RAS_MeshSlot::iterator it;
- size_t j;
-
- for (ms.begin(it); !ms.end(it); ms.next(it)) {
- unsigned int nvert = (int)it.array->m_type;
- unsigned int totpoly = it.totindex/nvert;
-
- if (totpoly <= 1)
- continue;
- if (it.array->m_type == RAS_DisplayArray::LINE)
- continue;
-
- // Extract camera Z plane...
- const MT_Vector3 pnorm(transform.getBasis()[2]);
- // unneeded: const MT_Scalar pval = transform.getOrigin()[2];
-
- vector<polygonSlot> poly_slots(totpoly);
-
- /* get indices and z into temporary array */
- for (j=0; j<totpoly; j++)
- poly_slots[j].get(it.vertex, it.index, j*nvert, nvert, pnorm);
-
- /* sort (stable_sort might be better, if flickering happens?) */
- std::sort(poly_slots.begin(), poly_slots.end(), backtofront());
-
- /* get indices from temporary array again */
- for (j=0; j<totpoly; j++)
- poly_slots[j].set(it.index, j*nvert, nvert);
- }
-}
-
-
-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)
- {
- m_bModified = false;
- m_bMeshModified = true;
- }
-}
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h
deleted file mode 100644
index a6f1a1cafc6..00000000000
--- a/source/gameengine/Rasterizer/RAS_MeshObject.h
+++ /dev/null
@@ -1,161 +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_MeshObject.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_MESHOBJECT_H__
-#define __RAS_MESHOBJECT_H__
-
-#ifdef _MSC_VER
- /* disable the STL warnings ("debug information length > 255") */
-# pragma warning (disable:4786)
-#endif
-
-#include <vector>
-#include <list>
-
-#include "RAS_MaterialBucket.h"
-#include "MT_Transform.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
- * buckets, referenced by the list of RAS_MeshMaterials. */
-
-class RAS_MeshObject
-{
-private:
- /* unsigned int m_debugcolor; */ /* UNUSED */
-
- bool m_bModified;
- bool m_bMeshModified;
-
- STR_String m_name;
- static STR_String s_emptyname;
-
- vector<RAS_Polygon*> m_Polygons;
-
- /* polygon sorting */
- struct polygonSlot;
- struct backtofront;
- struct fronttoback;
-
-protected:
- vector<int> m_cacheWeightIndex;
- list<RAS_MeshMaterial> m_materials;
- Mesh* m_mesh;
-
-public:
- // for now, meshes need to be in a certain layer (to avoid sorting on lights in realtime)
- RAS_MeshObject(Mesh* mesh);
- virtual ~RAS_MeshObject();
-
-
- /* materials */
- int NumMaterials();
- const STR_String& GetMaterialName(unsigned int matid);
- const STR_String& GetTextureName(unsigned int matid);
-
- RAS_MeshMaterial* GetMeshMaterial(unsigned int matid);
- RAS_MeshMaterial* GetMeshMaterial(RAS_IPolyMaterial *mat);
- int GetMaterialId(RAS_IPolyMaterial *mat);
-
- list<RAS_MeshMaterial>::iterator GetFirstMaterial();
- list<RAS_MeshMaterial>::iterator GetLastMaterial();
-
- //unsigned int GetLightLayer();
-
- /* name */
- void SetName(const char *name);
- STR_String& GetName();
-
- /* modification state */
- bool MeshModified();
- void SetMeshModified(bool v) { m_bMeshModified = v; }
-
- /* original blender mesh */
- Mesh* GetMesh() { return m_mesh; }
-
- /* mesh construction */
-
- virtual RAS_Polygon* AddPolygon(RAS_MaterialBucket *bucket, int numverts);
- virtual void AddVertex(RAS_Polygon *poly, int i,
- const MT_Point3& xyz,
- const MT_Point2 uvs[RAS_TexVert::MAX_UNIT],
- const MT_Vector4& tangent,
- const unsigned int rgbacolor,
- const MT_Vector3& normal,
- bool flat,
- int origindex);
-
- void SchedulePolygons(int drawingmode);
-
- /* vertex and polygon acces */
- int NumVertices(RAS_IPolyMaterial* mat);
- RAS_TexVert* GetVertex(unsigned int matid, unsigned int index);
- const float* GetVertexLocation(unsigned int orig_index);
-
- int NumPolygons();
- RAS_Polygon* GetPolygon(int num) const;
-
- /* buckets */
- virtual void AddMeshUser(void *clientobj, SG_QList *head, RAS_Deformer* deformer);
-
- void RemoveFromBuckets(void *clientobj);
- void EndConversion();
-
- /* colors */
- void DebugColor(unsigned int abgr);
- void SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba);
-
- /* polygon sorting by Z for alpha */
- void SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform);
-
-
- bool HasColliderPolygon();
-
- /* for construction to find shared vertices */
- struct SharedVertex {
- RAS_DisplayArray *m_darray;
- int m_offset;
- };
-
- vector<vector<SharedVertex> > m_sharedvertex_map;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MeshObject")
-#endif
-};
-
-#endif /* __RAS_MESHOBJECT_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_ObjectColor.h b/source/gameengine/Rasterizer/RAS_ObjectColor.h
deleted file mode 100644
index 77feffccffc..00000000000
--- a/source/gameengine/Rasterizer/RAS_ObjectColor.h
+++ /dev/null
@@ -1,41 +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_ObjectColor.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_OBJECTCOLOR_H__
-#define __RAS_OBJECTCOLOR_H__
-
-struct RAS_ObjectColor {
- float m_red;
- float m_green;
- float m_blue;
-};
-
-#endif /* __RAS_OBJECTCOLOR_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h
deleted file mode 100644
index 3f1644a5c60..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h
+++ /dev/null
@@ -1,55 +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_Blur2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_BLUR2DFILTER_H__
-#define __RAS_BLUR2DFILTER_H__
-
-static const char *BlurFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] +
- (2.0*sample[3]) + sample[4] + (2.0*sample[5]) +
- sample[6] + (2.0*sample[7]) + sample[8]) / 13.0;
-}
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h
deleted file mode 100644
index 4e863cb6f8d..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h
+++ /dev/null
@@ -1,55 +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_Dilation2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_DILATION2DFILTER_H__
-#define __RAS_DILATION2DFILTER_H__
-
-static const char *DilationFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
- vec4 maxValue = vec4(0.0);
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- maxValue = max(sample[i], maxValue);
- }
-
- gl_FragColor = maxValue;
-}
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h
deleted file mode 100644
index 56e2c22fe2e..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h
+++ /dev/null
@@ -1,54 +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_Erosion2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_EROSION2DFILTER_H__
-#define __RAS_EROSION2DFILTER_H__
-
-static const char *ErosionFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
- vec4 minValue = vec4(1.0);
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- minValue = min(sample[i], minValue);
- }
-
- gl_FragColor = minValue;
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
deleted file mode 100644
index 932d5b16fed..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
+++ /dev/null
@@ -1,45 +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_GrayScale2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_GRAYSCALE2DFILTER_H__
-#define __RAS_GRAYSCALE2DFILTER_H__
-
-static const char *GrayScaleFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-
-void main(void)
-{
- vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
- float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
- gl_FragColor = vec4(gray, gray, gray, texcolor.a);
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h
deleted file mode 100644
index dce303916ea..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h
+++ /dev/null
@@ -1,45 +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_Invert2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_INVERT2DFILTER_H__
-#define __RAS_INVERT2DFILTER_H__
-
-static const char *InvertFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-
-void main(void)
-{
- vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
- gl_FragColor.rgb = 1.0 - texcolor.rgb;
- gl_FragColor.a = texcolor.a;
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
deleted file mode 100644
index 9ec5092817d..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
+++ /dev/null
@@ -1,57 +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_Laplacian2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_LAPLACIAN2DFILTER_H__
-#define __RAS_LAPLACIAN2DFILTER_H__
-
-static const char *LaplacionFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- gl_FragColor = (sample[4] * 8.0) -
- (sample[0] + sample[1] + sample[2] +
- sample[3] + sample[5] +
- sample[6] + sample[7] + sample[8]);
- gl_FragColor = vec4(gl_FragColor.rgb, 1.0);
-}
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
deleted file mode 100644
index 4ae6009fdeb..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
+++ /dev/null
@@ -1,62 +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_Prewitt2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_PREWITT2DFILTER_H__
-#define __RAS_PREWITT2DFILTER_H__
-
-static const char *PrewittFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- vec4 horizEdge = sample[2] + sample[5] + sample[8] -
- (sample[0] + sample[3] + sample[6]);
-
- vec4 vertEdge = sample[0] + sample[1] + sample[2] -
- (sample[6] + sample[7] + sample[8]);
-
- gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) +
- (vertEdge.rgb * vertEdge.rgb));
- gl_FragColor.a = 1.0;
-}
-
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h
deleted file mode 100644
index 16b4e71dfdb..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h
+++ /dev/null
@@ -1,45 +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_Sepia2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_SEPIA2DFILTER_H__
-#define __RAS_SEPIA2DFILTER_H__
-
-static const char *SepiaFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-
-void main(void)
-{
- vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
- float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
- gl_FragColor = vec4(gray * vec3(1.2, 1.0, 0.8), texcolor.a);
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
deleted file mode 100644
index 7512393815b..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
+++ /dev/null
@@ -1,55 +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_Sharpen2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_SHARPEN2DFILTER_H__
-#define __RAS_SHARPEN2DFILTER_H__
-
-static const char *SharpenFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- gl_FragColor = (sample[4] * 9.0) -
- (sample[0] + sample[1] + sample[2] +
- sample[3] + sample[5] +
- sample[6] + sample[7] + sample[8]);
-}
-);
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h
deleted file mode 100644
index 088ac10a56a..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h
+++ /dev/null
@@ -1,61 +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_Sobel2DFilter.h
- * \ingroup bgerastoglfilters
- */
-
-#ifndef __RAS_SOBEL2DFILTER_H__
-#define __RAS_SOBEL2DFILTER_H__
-
-static const char *SobelFragmentShader = STRINGIFY(
-uniform sampler2D bgl_RenderedTexture;
-uniform vec2 bgl_TextureCoordinateOffset[9];
-
-void main(void)
-{
- vec4 sample[9];
-
- for (int i = 0; i < 9; i++)
- {
- sample[i] = texture2D(bgl_RenderedTexture,
- gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
- }
-
- vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] -
- (sample[0] + (2.0*sample[3]) + sample[6]);
-
- vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] -
- (sample[6] + (2.0*sample[7]) + sample[8]);
-
- gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) +
- (vertEdge.rgb * vertEdge.rgb));
- gl_FragColor.a = 1.0;
-}
-);
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
deleted file mode 100644
index 89e31b62b41..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
+++ /dev/null
@@ -1,72 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- ..
- # XXX Remove these <<<
- ../../BlenderRoutines
- ../../Expressions
- ../../GameLogic
- ../../Ketsji
- ../../Physics/common
- # >>>
- ../../SceneGraph
- ../../../blender/blenfont
- ../../../blender/blenkernel
- ../../../blender/blenlib
- ../../../blender/gpu
- ../../../blender/makesdna
- ../../../../intern/container
- ../../../../intern/glew-mx
- ../../../../intern/string
-)
-
-set(INC_SYS
- ../../../../intern/moto/include
- ${GLEW_INCLUDE_PATH}
-)
-
-set(SRC
- RAS_ListRasterizer.cpp
- RAS_OpenGLLight.cpp
- RAS_OpenGLOffScreen.cpp
- RAS_OpenGLSync.cpp
- RAS_OpenGLRasterizer.cpp
- RAS_StorageVA.cpp
- RAS_StorageVBO.cpp
-
- RAS_IStorage.h
- RAS_ListRasterizer.h
- RAS_OpenGLLight.h
- RAS_OpenGLOffScreen.h
- RAS_OpenGLSync.h
- RAS_OpenGLRasterizer.h
- RAS_StorageVA.h
- RAS_StorageVBO.h
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-blender_add_lib(ge_oglrasterizer "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h
deleted file mode 100644
index ae0cdcd84af..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h
+++ /dev/null
@@ -1,56 +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 *****
- */
-
-#ifndef __KX_STORAGE
-#define __KX_STORAGE
-
-#ifdef WITH_CXX_GUARDEDALLOC
- #include "MEM_guardedalloc.h"
-#endif
-
-class RAS_MeshSlot;
-
-class RAS_IStorage
-{
-
-public:
- virtual ~RAS_IStorage() {};
-
- virtual bool Init()=0;
- virtual void Exit()=0;
-
- virtual void IndexPrimitives(RAS_MeshSlot& ms)=0;
-
- virtual void SetDrawingMode(int drawingmode)=0;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IStorage")
-#endif
-};
-
-#endif //__KX_STORAGE
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
deleted file mode 100644
index 71c8cfe745f..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
+++ /dev/null
@@ -1,278 +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/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
- * \ingroup bgerastogl
- */
-
-#include <iostream>
-
-#include "RAS_ListRasterizer.h"
-
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-
-#include "GPU_glew.h"
-
-#include "RAS_MaterialBucket.h"
-#include "RAS_TexVert.h"
-#include "MT_assert.h"
-
-//#if defined(DEBUG)
-//#ifdef WIN32
-//#define spit(x) std::cout << x << std::endl;
-//#endif //WIN32
-//#else
-#define spit(x)
-//#endif
-
-RAS_ListSlot::RAS_ListSlot(RAS_ListRasterizer* rasty)
-: KX_ListSlot(),
- m_list(0),
- m_flag(LIST_MODIFY|LIST_CREATE),
- m_matnr(0),
- m_rasty(rasty)
-{
-}
-
-int RAS_ListSlot::Release()
-{
- if (--m_refcount > 0)
- return m_refcount;
- m_rasty->RemoveListSlot(this);
- delete this;
- return 0;
-}
-
-RAS_ListSlot::~RAS_ListSlot()
-{
- RemoveList();
-}
-
-
-void RAS_ListSlot::RemoveList()
-{
- if (m_list != 0) {
- spit("Releasing display list (" << m_list << ")");
- glDeleteLists((GLuint)m_list, 1);
- m_list =0;
- }
-}
-
-void RAS_ListSlot::DrawList()
-{
- if (m_flag &LIST_MODIFY) {
- if (m_flag &LIST_CREATE) {
- if (m_list == 0) {
- m_list = (unsigned int)glGenLists(1);
- m_flag = m_flag &~ LIST_CREATE;
- spit("Created display list (" << m_list << ")");
- }
- }
- if (m_list != 0)
- glNewList((GLuint)m_list, GL_COMPILE);
-
- m_flag |= LIST_BEGIN;
- return;
- }
- glCallList(m_list);
-}
-
-void RAS_ListSlot::EndList()
-{
- if (m_flag & LIST_BEGIN) {
- glEndList();
- m_flag = m_flag &~(LIST_BEGIN|LIST_MODIFY);
- m_flag |= LIST_END;
- glCallList(m_list);
- }
-}
-
-void RAS_ListSlot::SetModified(bool mod)
-{
- if (mod && !(m_flag & LIST_MODIFY)) {
- spit("Modifying list (" << m_list << ")");
- m_flag = m_flag &~ LIST_END;
- m_flag |= LIST_MODIFY;
- }
-}
-
-bool RAS_ListSlot::End()
-{
- return (m_flag &LIST_END)!=0;
-}
-
-
-
-RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, RAS_STORAGE_TYPE storage)
-: RAS_OpenGLRasterizer(canvas, storage)
-{
-}
-
-RAS_ListRasterizer::~RAS_ListRasterizer()
-{
- ReleaseAlloc();
-}
-
-void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list)
-{
- if (list->m_flag & LIST_DERIVEDMESH) {
- RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();
- while (it != mDerivedMeshLists.end()) {
- RAS_ListSlots *slots = it->second;
- if (slots->size() > list->m_matnr && slots->at(list->m_matnr) == list) {
- (*slots)[list->m_matnr] = NULL;
- // check if all slots are NULL and if yes, delete the entry
- int i;
- for (i=slots->size(); i-- > 0; ) {
- if (slots->at(i) != NULL)
- break;
- }
- if (i < 0) {
- slots->clear();
- delete slots;
- mDerivedMeshLists.erase(it);
- }
- break;
- }
- ++it;
- }
- } else {
- RAS_ArrayLists::iterator it = mArrayLists.begin();
- while (it != mArrayLists.end()) {
- if (it->second == list) {
- mArrayLists.erase(it);
- break;
- }
- it++;
- }
- }
-}
-
-RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
-{
- /*
- * Keep a copy of constant lists submitted for rendering,
- * this guards against (replicated)new...delete every frame,
- * and we can reuse lists!
- * :: sorted by mesh slot
- */
- RAS_ListSlot* localSlot = (RAS_ListSlot*)ms.m_DisplayList;
- if (!localSlot) {
- if (ms.m_pDerivedMesh) {
- // that means that we draw based on derived mesh, a display list is possible
- // Note that we come here only for static derived mesh
- int matnr = ms.m_bucket->GetPolyMaterial()->GetMaterialIndex();
- RAS_ListSlot* nullSlot = NULL;
- RAS_ListSlots *listVector;
- RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.find(ms.m_pDerivedMesh);
- if (it == mDerivedMeshLists.end()) {
- listVector = new RAS_ListSlots(matnr+4, nullSlot);
- localSlot = new RAS_ListSlot(this);
- localSlot->m_flag |= LIST_DERIVEDMESH;
- localSlot->m_matnr = matnr;
- listVector->at(matnr) = localSlot;
- mDerivedMeshLists.insert(std::pair<DerivedMesh*, RAS_ListSlots*>(ms.m_pDerivedMesh, listVector));
- } else {
- listVector = it->second;
- if (listVector->size() <= matnr)
- listVector->resize(matnr+4, nullSlot);
- if ((localSlot = listVector->at(matnr)) == NULL) {
- localSlot = new RAS_ListSlot(this);
- localSlot->m_flag |= LIST_DERIVEDMESH;
- localSlot->m_matnr = matnr;
- listVector->at(matnr) = localSlot;
- } else {
- localSlot->AddRef();
- }
- }
- } else {
- RAS_ArrayLists::iterator it = mArrayLists.find(ms.m_displayArrays);
- if (it == mArrayLists.end()) {
- localSlot = new RAS_ListSlot(this);
- mArrayLists.insert(std::pair<RAS_DisplayArrayList, RAS_ListSlot*>(ms.m_displayArrays, localSlot));
- } else {
- localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
- }
- }
- }
- MT_assert(localSlot);
- return localSlot;
-}
-
-void RAS_ListRasterizer::ReleaseAlloc()
-{
- for (RAS_ArrayLists::iterator it = mArrayLists.begin();it != mArrayLists.end();++it)
- delete it->second;
- mArrayLists.clear();
- for (RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin();it != mDerivedMeshLists.end();++it) {
- RAS_ListSlots* slots = it->second;
- for (int i=slots->size(); i-- > 0; ) {
- RAS_ListSlot* slot = slots->at(i);
- if (slot)
- delete slot;
- }
- slots->clear();
- delete slots;
- }
- mDerivedMeshLists.clear();
-}
-
-void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
-{
- RAS_ListSlot* localSlot =0;
-
- if (ms.m_bDisplayList) {
- localSlot = FindOrAdd(ms);
- localSlot->DrawList();
-
- if (localSlot->End()) {
- // save slot here too, needed for replicas and object using same mesh
- // => they have the same vertexarray but different mesh slot
- ms.m_DisplayList = localSlot;
- return;
- }
- }
-
- RAS_OpenGLRasterizer::IndexPrimitives(ms);
-
- if (ms.m_bDisplayList) {
- localSlot->EndList();
- ms.m_DisplayList = localSlot;
- }
-}
-
-bool RAS_ListRasterizer::Init(void)
-{
- return RAS_OpenGLRasterizer::Init();
-}
-
-void RAS_ListRasterizer::SetDrawingMode(int drawingmode)
-{
- RAS_OpenGLRasterizer::SetDrawingMode(drawingmode);
-}
-
-void RAS_ListRasterizer::Exit()
-{
- RAS_OpenGLRasterizer::Exit();
-}
-
-// eof
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
deleted file mode 100644
index e3e6931311b..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
+++ /dev/null
@@ -1,77 +0,0 @@
-
-/** \file RAS_ListRasterizer.h
- * \ingroup bgerastogl
- */
-
-#ifndef __RAS_LISTRASTERIZER_H__
-#define __RAS_LISTRASTERIZER_H__
-
-#include "RAS_MaterialBucket.h"
-#include "RAS_OpenGLRasterizer.h"
-#include <vector>
-#include <map>
-
-class RAS_ListRasterizer;
-class RAS_ListSlot : public KX_ListSlot
-{
- friend class RAS_ListRasterizer;
- unsigned int m_list;
- unsigned int m_flag;
- unsigned int m_matnr;
- RAS_ListRasterizer* m_rasty;
-public:
- RAS_ListSlot(RAS_ListRasterizer* rasty);
- virtual ~RAS_ListSlot();
- virtual void SetModified(bool mod);
- virtual int Release();
-
- void RemoveList();
- void DrawList();
- void EndList();
- bool End();
-
-};
-
-enum RAS_ListSlotFlags {
- LIST_CREATE =1,
- LIST_MODIFY =2,
- LIST_BEGIN =4,
- LIST_END =8,
- LIST_DERIVEDMESH=16,
-};
-
-struct DerivedMesh;
-
-typedef std::map<RAS_DisplayArrayList, RAS_ListSlot*> RAS_ArrayLists;
-typedef std::vector<RAS_ListSlot*> RAS_ListSlots; // indexed by material slot number
-typedef std::map<DerivedMesh*, RAS_ListSlots*> RAS_DerivedMeshLists;
-
-class RAS_ListRasterizer : public RAS_OpenGLRasterizer
-{
- RAS_ArrayLists mArrayLists;
- RAS_DerivedMeshLists mDerivedMeshLists;
-
- RAS_ListSlot* FindOrAdd(class RAS_MeshSlot& ms);
- void ReleaseAlloc();
-
-public:
- void RemoveListSlot(RAS_ListSlot* list);
- RAS_ListRasterizer(RAS_ICanvas* canvas, bool lock, RAS_STORAGE_TYPE storage);
- virtual ~RAS_ListRasterizer();
-
- virtual void IndexPrimitives(class RAS_MeshSlot& ms);
-
- virtual bool Init();
- virtual void Exit();
-
- virtual void SetDrawingMode(int drawingmode);
-
- virtual bool QueryLists() {return true;}
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_ListRasterizer")
-#endif
-};
-
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
deleted file mode 100644
index 18254357f85..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp
+++ /dev/null
@@ -1,300 +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): Mitchell Stokes
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "GPU_glew.h"
-
-#include <stdio.h>
-
-
-#include "RAS_OpenGLLight.h"
-#include "RAS_OpenGLRasterizer.h"
-#include "RAS_ICanvas.h"
-
-#include "MT_CmMatrix4x4.h"
-
-#include "KX_Camera.h"
-#include "KX_Light.h"
-#include "KX_Scene.h"
-
-#include "DNA_lamp_types.h"
-#include "DNA_scene_types.h"
-
-#include "GPU_lamp.h"
-#include "GPU_material.h"
-
-RAS_OpenGLLight::RAS_OpenGLLight(RAS_OpenGLRasterizer *ras)
- :m_rasterizer(ras)
-{
-}
-
-RAS_OpenGLLight::~RAS_OpenGLLight()
-{
- GPULamp *lamp;
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
- Lamp *la = (Lamp*)kxlight->GetBlenderObject()->data;
-
- if ((lamp = GetGPULamp())) {
- float obmat[4][4] = {{0}};
- GPU_lamp_update(lamp, 0, 0, obmat);
- GPU_lamp_update_distance(lamp, la->dist, la->att1, la->att2, la->coeff_const, la->coeff_lin, la->coeff_quad);
- GPU_lamp_update_spot(lamp, la->spotsize, la->spotblend);
- }
-}
-
-bool RAS_OpenGLLight::ApplyFixedFunctionLighting(KX_Scene *kxscene, int oblayer, int slot)
-{
- KX_Scene* lightscene = (KX_Scene*)m_scene;
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
- float vec[4];
- int scenelayer = ~0;
-
- if (kxscene && kxscene->GetBlenderScene())
- scenelayer = kxscene->GetBlenderScene()->lay;
-
- /* only use lights in the same layer as the object */
- if (!(m_layer & oblayer))
- return false;
- /* only use lights in the same scene, and in a visible layer */
- if (kxscene != lightscene || !(m_layer & scenelayer))
- return false;
-
- // lights don't get their openGL matrix updated, do it now
- if (kxlight->GetSGNode()->IsDirty())
- kxlight->GetOpenGLMatrix();
-
- MT_CmMatrix4x4& worldmatrix= *kxlight->GetOpenGLMatrixPtr();
-
- vec[0] = worldmatrix(0,3);
- vec[1] = worldmatrix(1,3);
- vec[2] = worldmatrix(2,3);
- vec[3] = 1.0f;
-
- if (m_type==RAS_ILightObject::LIGHT_SUN) {
-
- vec[0] = worldmatrix(0,2);
- vec[1] = worldmatrix(1,2);
- vec[2] = worldmatrix(2,2);
- //vec[0] = base->object->obmat[2][0];
- //vec[1] = base->object->obmat[2][1];
- //vec[2] = base->object->obmat[2][2];
- vec[3] = 0.0f;
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec);
- }
- else {
- //vec[3] = 1.0f;
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec);
- glLightf((GLenum)(GL_LIGHT0+slot), GL_CONSTANT_ATTENUATION, 1.0f);
- glLightf((GLenum)(GL_LIGHT0+slot), GL_LINEAR_ATTENUATION, m_att1/m_distance);
- // without this next line it looks backward compatible.
- //attennuation still is acceptable
- glLightf((GLenum)(GL_LIGHT0+slot), GL_QUADRATIC_ATTENUATION, m_att2/(m_distance*m_distance));
-
- if (m_type==RAS_ILightObject::LIGHT_SPOT) {
- vec[0] = -worldmatrix(0,2);
- vec[1] = -worldmatrix(1,2);
- vec[2] = -worldmatrix(2,2);
- //vec[0] = -base->object->obmat[2][0];
- //vec[1] = -base->object->obmat[2][1];
- //vec[2] = -base->object->obmat[2][2];
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPOT_DIRECTION, vec);
- glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, m_spotsize / 2.0f);
- glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_EXPONENT, 128.0f * m_spotblend);
- }
- else {
- glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, 180.0f);
- }
- }
-
- if (m_nodiffuse) {
- vec[0] = vec[1] = vec[2] = vec[3] = 0.0f;
- }
- else {
- vec[0] = m_energy*m_color[0];
- vec[1] = m_energy*m_color[1];
- vec[2] = m_energy*m_color[2];
- vec[3] = 1.0f;
- }
-
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_DIFFUSE, vec);
- if (m_nospecular)
- {
- vec[0] = vec[1] = vec[2] = vec[3] = 0.0f;
- }
- else if (m_nodiffuse) {
- vec[0] = m_energy*m_color[0];
- vec[1] = m_energy*m_color[1];
- vec[2] = m_energy*m_color[2];
- vec[3] = 1.0f;
- }
-
- glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPECULAR, vec);
- glEnable((GLenum)(GL_LIGHT0+slot));
-
- return true;
-}
-
-GPULamp *RAS_OpenGLLight::GetGPULamp()
-{
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
-
- if (m_glsl)
- return GPU_lamp_from_blender(kxlight->GetScene()->GetBlenderScene(), kxlight->GetBlenderObject(), kxlight->GetBlenderGroupObject());
- else
- return NULL;
-}
-
-
-bool RAS_OpenGLLight::HasShadowBuffer()
-{
- GPULamp *lamp;
-
- if ((lamp = GetGPULamp()))
- return GPU_lamp_has_shadow_buffer(lamp);
- else
- return false;
-}
-
-int RAS_OpenGLLight::GetShadowBindCode()
-{
- GPULamp *lamp;
-
- if ((lamp = GetGPULamp()))
- return GPU_lamp_shadow_bind_code(lamp);
- return -1;
-}
-
-MT_Matrix4x4 RAS_OpenGLLight::GetShadowMatrix()
-{
- GPULamp *lamp;
-
- if ((lamp = GetGPULamp()))
- return MT_Matrix4x4(GPU_lamp_dynpersmat(lamp));
- MT_Matrix4x4 mat;
- mat.setIdentity();
- return mat;
-}
-
-int RAS_OpenGLLight::GetShadowLayer()
-{
- GPULamp *lamp;
-
- if ((lamp = GetGPULamp()))
- return GPU_lamp_shadow_layer(lamp);
- else
- return 0;
-}
-
-void RAS_OpenGLLight::BindShadowBuffer(RAS_ICanvas *canvas, KX_Camera *cam, MT_Transform& camtrans)
-{
- GPULamp *lamp;
- float viewmat[4][4], winmat[4][4];
- int winsize;
-
- /* bind framebuffer */
- lamp = GetGPULamp();
- GPU_lamp_shadow_buffer_bind(lamp, viewmat, &winsize, winmat);
-
- if (GPU_lamp_shadow_buffer_type(lamp) == LA_SHADMAP_VARIANCE)
- m_rasterizer->SetUsingOverrideShader(true);
-
- /* GPU_lamp_shadow_buffer_bind() changes the viewport, so update the canvas */
- canvas->UpdateViewPort(0, 0, winsize, winsize);
-
- /* setup camera transformation */
- MT_Matrix4x4 modelviewmat((float*)viewmat);
- MT_Matrix4x4 projectionmat((float*)winmat);
-
- MT_Transform trans = MT_Transform((float*)viewmat);
- camtrans.invert(trans);
-
- cam->SetModelviewMatrix(modelviewmat);
- cam->SetProjectionMatrix(projectionmat);
-
- cam->NodeSetLocalPosition(camtrans.getOrigin());
- cam->NodeSetLocalOrientation(camtrans.getBasis());
- cam->NodeUpdateGS(0);
-
- /* setup rasterizer transformations */
- /* SetViewMatrix may use stereomode which we temporarily disable here */
- RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode();
- m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO);
- m_rasterizer->SetProjectionMatrix(projectionmat);
- m_rasterizer->SetViewMatrix(modelviewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), cam->NodeGetLocalScaling(), cam->GetCameraData()->m_perspective);
- m_rasterizer->SetStereoMode(stereomode);
-}
-
-void RAS_OpenGLLight::UnbindShadowBuffer()
-{
- GPULamp *lamp = GetGPULamp();
- GPU_lamp_shadow_buffer_unbind(lamp);
-
- if (GPU_lamp_shadow_buffer_type(lamp) == LA_SHADMAP_VARIANCE)
- m_rasterizer->SetUsingOverrideShader(false);
-}
-
-Image *RAS_OpenGLLight::GetTextureImage(short texslot)
-{
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
- Lamp *la = (Lamp*)kxlight->GetBlenderObject()->data;
-
- if (texslot >= MAX_MTEX || texslot < 0)
- {
- printf("KX_LightObject::GetTextureImage(): texslot exceeds slot bounds (0-%d)\n", MAX_MTEX-1);
- return NULL;
- }
-
- if (la->mtex[texslot])
- return la->mtex[texslot]->tex->ima;
-
- return NULL;
-}
-
-void RAS_OpenGLLight::Update()
-{
- GPULamp *lamp;
- KX_LightObject* kxlight = (KX_LightObject*)m_light;
-
- if ((lamp = GetGPULamp()) != NULL && kxlight->GetSGNode()) {
- float obmat[4][4];
- // lights don't get their openGL matrix updated, do it now
- if (kxlight->GetSGNode()->IsDirty())
- kxlight->GetOpenGLMatrix();
- float *dobmat = kxlight->GetOpenGLMatrixPtr()->getPointer();
-
- for (int i=0; i<4; i++)
- for (int j=0; j<4; j++, dobmat++)
- obmat[i][j] = (float)*dobmat;
- int hide = kxlight->GetVisible() ? 0 : 1;
- GPU_lamp_update(lamp, m_layer, hide, obmat);
- GPU_lamp_update_colors(lamp, m_color[0], m_color[1],
- m_color[2], m_energy);
- GPU_lamp_update_distance(lamp, m_distance, m_att1, m_att2, m_coeff_const, m_coeff_lin, m_coeff_quad);
- GPU_lamp_update_spot(lamp, m_spotsize, m_spotblend);
- }
-}
-
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.h
deleted file mode 100644
index a520b18c434..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.h
+++ /dev/null
@@ -1,56 +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): Mitchell Stokes
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "RAS_ILightObject.h"
-
-class RAS_OpenGLRasterizer;
-struct GPULamp;
-struct Image;
-
-class RAS_OpenGLLight : public RAS_ILightObject
-{
-
- RAS_OpenGLRasterizer *m_rasterizer;
-
- GPULamp *GetGPULamp();
-public:
- RAS_OpenGLLight(RAS_OpenGLRasterizer *ras);
- ~RAS_OpenGLLight();
-
- bool ApplyFixedFunctionLighting(KX_Scene *kxscene, int oblayer, int slot);
-
- RAS_OpenGLLight* Clone() { return new RAS_OpenGLLight(*this); }
-
- bool HasShadowBuffer();
- int GetShadowBindCode();
- MT_Matrix4x4 GetShadowMatrix();
- int GetShadowLayer();
- void BindShadowBuffer(RAS_ICanvas *canvas, KX_Camera *cam, MT_Transform& camtrans);
- void UnbindShadowBuffer();
- Image *GetTextureImage(short texslot);
- void Update();
-};
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.cpp
deleted file mode 100644
index 58b3c61bd05..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.cpp
+++ /dev/null
@@ -1,347 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "GPU_glew.h"
-
-#include <stdio.h>
-
-#include "RAS_OpenGLOffScreen.h"
-#include "RAS_ICanvas.h"
-
-RAS_OpenGLOffScreen::RAS_OpenGLOffScreen(RAS_ICanvas *canvas)
- :m_canvas(canvas), m_depthrb(0), m_colorrb(0), m_depthtx(0), m_colortx(0),
- m_fbo(0), m_blitfbo(0), m_blitrbo(0), m_blittex(0), m_target(RAS_OFS_RENDER_BUFFER), m_bound(false)
-{
- m_width = 0;
- m_height = 0;
- m_samples = 0;
- m_color = 0;
-}
-
-RAS_OpenGLOffScreen::~RAS_OpenGLOffScreen()
-{
- Destroy();
-}
-
-bool RAS_OpenGLOffScreen::Create(int width, int height, int samples, RAS_OFS_RENDER_TARGET target)
-{
- GLenum status;
- GLuint glo[2], fbo;
- GLint max_samples;
- GLenum textarget;
-
- if (m_fbo) {
- printf("RAS_OpenGLOffScreen::Create(): buffer exists already, destroy first\n");
- return false;
- }
- if (target != RAS_IOffScreen::RAS_OFS_RENDER_BUFFER &&
- target != RAS_IOffScreen::RAS_OFS_RENDER_TEXTURE)
- {
- printf("RAS_OpenGLOffScreen::Create(): invalid offscren target\n");
- return false;
- }
- if (!GLEW_EXT_framebuffer_object) {
- printf("RAS_OpenGLOffScreen::Create(): frame buffer not supported\n");
- return false;
- }
- if (samples) {
- if (!GLEW_EXT_framebuffer_multisample ||
- !GLEW_EXT_framebuffer_blit)
- {
- samples = 0;
- }
- }
- if (samples && target == RAS_OFS_RENDER_TEXTURE) {
- // we need this in addition if we use multisample textures
- if (!GLEW_ARB_texture_multisample ||
- !GLEW_EXT_framebuffer_multisample_blit_scaled)
- {
- samples = 0;
- }
- }
- if (samples) {
- max_samples = 0;
- glGetIntegerv(GL_MAX_SAMPLES_EXT , &max_samples);
- if (samples > max_samples)
- samples = max_samples;
- }
- m_target = target;
- fbo = 0;
- glGenFramebuffersEXT(1, &fbo);
- if (fbo == 0) {
- printf("RAS_OpenGLOffScreen::Create(): frame buffer creation failed: %d\n", (int)glGetError());
- return false;
- }
- m_fbo = fbo;
- glo[0] = glo[1] = 0;
- if (target == RAS_OFS_RENDER_TEXTURE) {
- glGenTextures(2, glo);
- if (glo[0] == 0 || glo[1] == 0) {
- printf("RAS_OpenGLOffScreen::Create(): texture creation failed: %d\n", (int)glGetError());
- goto L_ERROR;
- }
- m_depthtx = glo[0];
- m_color = m_colortx = glo[1];
- if (samples) {
- textarget = GL_TEXTURE_2D_MULTISAMPLE;
- glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_depthtx);
- glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, GL_DEPTH_COMPONENT, width, height, true);
- glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_colortx);
- glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, GL_RGBA8, width, height, true);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
- }
- else {
- textarget = GL_TEXTURE_2D;
- glBindTexture(GL_TEXTURE_2D, m_depthtx);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
- glBindTexture(GL_TEXTURE_2D, m_colortx);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, textarget, m_depthtx, 0);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, textarget, m_colortx, 0);
- }
- else {
- glGenRenderbuffersEXT(2, glo);
- if (glo[0] == 0 || glo[1] == 0) {
- printf("RAS_OpenGLOffScreen::Create(): render buffer creation failed: %d\n", (int)glGetError());
- goto L_ERROR;
- }
- m_depthrb = glo[0];
- m_colorrb = glo[1];
- glBindRenderbufferEXT(GL_RENDERBUFFER, m_depthrb);
- glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, samples, GL_DEPTH_COMPONENT, width, height);
- glBindRenderbufferEXT(GL_RENDERBUFFER, m_colorrb);
- glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, samples, GL_RGBA8, width, height);
- glBindRenderbufferEXT(GL_RENDERBUFFER, 0);
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER, m_depthrb);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER, m_colorrb);
- }
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- printf("RAS_OpenGLOffScreen::Create(): frame buffer incomplete: %d\n", (int)status);
- goto L_ERROR;
- }
- m_width = width;
- m_height = height;
-
- if (samples > 0) {
- GLuint blit_tex;
- GLuint blit_fbo;
- // create a secondary FBO to blit to before the pixel can be read
-
- /* write into new single-sample buffer */
- glGenFramebuffersEXT(1, &blit_fbo);
- if (!blit_fbo) {
- printf("RAS_OpenGLOffScreen::Create(): failed creating a FBO for multi-sample offscreen buffer\n");
- goto L_ERROR;
- }
- m_blitfbo = blit_fbo;
- blit_tex = 0;
- if (target == RAS_OFS_RENDER_TEXTURE) {
- glGenTextures(1, &blit_tex);
- if (!blit_tex) {
- printf("RAS_OpenGLOffScreen::Create(): failed creating a texture for multi-sample offscreen buffer\n");
- goto L_ERROR;
- }
- // m_color is the texture where the final render goes, the blit texture in this case
- m_color = m_blittex = blit_tex;
- glBindTexture(GL_TEXTURE_2D, m_blittex);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glBindTexture(GL_TEXTURE_2D, 0);
- glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_blitfbo);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_blittex, 0);
- }
- else {
- /* create render buffer for new 'fbo_blit' */
- glGenRenderbuffersEXT(1, &blit_tex);
- if (!blit_tex) {
- printf("RAS_OpenGLOffScreen::Create(): failed creating a render buffer for multi-sample offscreen buffer\n");
- goto L_ERROR;
- }
- m_blitrbo = blit_tex;
- glBindRenderbufferEXT(GL_RENDERBUFFER, m_blitrbo);
- glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 0, GL_RGBA8, width, height);
- glBindRenderbufferEXT(GL_RENDERBUFFER, 0);
- glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_blitfbo);
- glFramebufferRenderbufferEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER, m_blitrbo);
- }
- status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER_EXT);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0);
- if (status != GL_FRAMEBUFFER_COMPLETE) {
- printf("RAS_OpenGLOffScreen::Create(): frame buffer for multi-sample offscreen buffer incomplete: %d\n", (int)status);
- goto L_ERROR;
- }
- // remember that multisample is enabled
- m_samples = 1;
- }
- return true;
-
-L_ERROR:
- Destroy();
- return false;
-}
-
-void RAS_OpenGLOffScreen::Destroy()
-{
- GLuint globj;
- Unbind();
- if (m_fbo) {
- globj = m_fbo;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- if (m_target == RAS_OFS_RENDER_TEXTURE) {
- GLenum textarget = (m_samples) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, textarget, 0, 0);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, textarget, 0, 0);
- }
- else {
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, 0);
- }
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT(1, &globj);
- m_fbo = 0;
- }
- if (m_depthrb) {
- globj = m_depthrb;
- glDeleteRenderbuffers(1, &globj);
- m_depthrb = 0;
- }
- if (m_colorrb) {
- globj = m_colorrb;
- glDeleteRenderbuffers(1, &globj);
- m_colorrb = 0;
- }
- if (m_depthtx) {
- globj = m_depthtx;
- glDeleteTextures(1, &globj);
- m_depthtx = 0;
- }
- if (m_colortx) {
- globj = m_colortx;
- glDeleteTextures(1, &globj);
- m_colortx = 0;
- }
- if (m_blitfbo) {
- globj = m_blitfbo;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_blitfbo);
- if (m_target == RAS_OFS_RENDER_TEXTURE) {
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0);
- }
- else {
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, 0);
- }
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT(1, &globj);
- m_blitfbo = 0;
- }
- if (m_blitrbo) {
- globj = m_blitrbo;
- glDeleteRenderbuffers(1, &globj);
- m_blitrbo = 0;
- }
- if (m_blittex) {
- globj = m_blittex;
- glDeleteTextures(1, &globj);
- m_blittex = 0;
- }
- m_width = 0;
- m_height = 0;
- m_samples = 0;
- m_color = 0;
- m_target = RAS_OFS_RENDER_BUFFER;
-}
-
-void RAS_OpenGLOffScreen::Bind(RAS_OFS_BIND_MODE mode)
-{
- if (m_fbo) {
- if (mode == RAS_OFS_BIND_RENDER) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
- glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
- glViewport(0, 0, m_width, m_height);
- glDisable(GL_SCISSOR_TEST);
- }
- else if (!m_blitfbo) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
- }
- else {
- glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_blitfbo);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
- }
- m_bound = true;
- }
-}
-
-void RAS_OpenGLOffScreen::Unbind()
-{
- if (!m_bound)
- return;
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glEnable(GL_SCISSOR_TEST);
- glReadBuffer(GL_BACK);
- glDrawBuffer(GL_BACK);
- m_bound = false;
-}
-
-void RAS_OpenGLOffScreen::MipMap()
-{
- if (m_color) {
- glBindTexture(GL_TEXTURE_2D, m_color);
- glGenerateMipmap(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
-}
-
-void RAS_OpenGLOffScreen::Blit()
-{
- if (m_bound && m_blitfbo) {
- // set the draw target to the secondary FBO, the read target is still the multisample FBO
- glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, m_blitfbo);
-
- // sample the primary
- glBlitFramebufferEXT(0, 0, m_width, m_height, 0, 0, m_width, m_height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
-
- // make sure the next glReadPixels will read from the secondary buffer
- glBindFramebufferEXT(GL_READ_FRAMEBUFFER, m_blitfbo);
- }
-}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.h
deleted file mode 100644
index 3f6845f1e21..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLOffScreen.h
+++ /dev/null
@@ -1,65 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __RAS_OPENGLOFFSCREEN__
-#define __RAS_OPENGLOFFSCREEN__
-
-#include "RAS_IOffScreen.h"
-#include "GPU_extensions.h"
-
-class RAS_ICanvas;
-
-class RAS_OpenGLOffScreen : public RAS_IOffScreen
-{
- RAS_ICanvas *m_canvas;
- // these are GL objects
- unsigned int m_depthrb;
- unsigned int m_colorrb;
- unsigned int m_depthtx;
- unsigned int m_colortx;
- unsigned int m_fbo;
- unsigned int m_blitfbo;
- unsigned int m_blitrbo;
- unsigned int m_blittex;
- RAS_OFS_RENDER_TARGET m_target;
- bool m_bound;
-
-
-public:
- RAS_OpenGLOffScreen(RAS_ICanvas *canvas);
- ~RAS_OpenGLOffScreen();
-
- bool Create(int width, int height, int samples, RAS_OFS_RENDER_TARGET target);
- void Destroy();
- void Bind(RAS_OFS_BIND_MODE mode);
- void Blit();
- void Unbind();
- void MipMap();
-};
-
-#endif /* __RAS_OPENGLOFFSCREEN__ */
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
deleted file mode 100644
index d1c3162f752..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ /dev/null
@@ -1,1694 +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_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
- * \ingroup bgerastogl
- */
-
-
-#include <math.h>
-#include <stdlib.h>
-
-#include "RAS_OpenGLRasterizer.h"
-
-#include "GPU_glew.h"
-
-#include "RAS_ICanvas.h"
-#include "RAS_Rect.h"
-#include "RAS_TexVert.h"
-#include "RAS_MeshObject.h"
-#include "RAS_Polygon.h"
-#include "RAS_ILightObject.h"
-#include "MT_CmMatrix4x4.h"
-
-#include "RAS_OpenGLLight.h"
-#include "RAS_OpenGLOffScreen.h"
-#include "RAS_OpenGLSync.h"
-
-#include "RAS_StorageVA.h"
-#include "RAS_StorageVBO.h"
-
-#include "GPU_draw.h"
-#include "GPU_extensions.h"
-#include "GPU_material.h"
-#include "GPU_shader.h"
-
-extern "C"{
- #include "BLF_api.h"
- #include "BKE_DerivedMesh.h"
- #include "DNA_material_types.h"
-}
-
-
-// XXX Clean these up <<<
-#include "EXP_Value.h"
-#include "KX_Scene.h"
-#include "KX_RayCast.h"
-#include "KX_GameObject.h"
-// >>>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-/**
- * 32x32 bit masks for vinterlace stereo mode
- */
-static GLuint left_eye_vinterlace_mask[32];
-static GLuint right_eye_vinterlace_mask[32];
-
-/**
- * 32x32 bit masks for hinterlace stereo mode.
- * Left eye = &hinterlace_mask[0]
- * Right eye = &hinterlace_mask[1]
- */
-static GLuint hinterlace_mask[33];
-
-RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, RAS_STORAGE_TYPE storage)
- :RAS_IRasterizer(canvas),
- m_2DCanvas(canvas),
- m_fogenabled(false),
- m_time(0.0f),
- m_campos(0.0f, 0.0f, 0.0f),
- m_camortho(false),
- m_camnegscale(false),
- m_stereomode(RAS_STEREO_NOSTEREO),
- m_curreye(RAS_STEREO_LEFTEYE),
- m_eyeseparation(0.0f),
- m_focallength(0.0f),
- m_setfocallength(false),
- m_noOfScanlines(32),
- m_motionblur(0),
- m_motionblurvalue(-1.0f),
- m_usingoverrideshader(false),
- m_clientobject(NULL),
- m_auxilaryClientInfo(NULL),
- m_drawingmode(KX_TEXTURED),
- m_texco_num(0),
- m_attrib_num(0),
- //m_last_alphablend(GPU_BLEND_SOLID),
- m_last_frontface(true),
- m_materialCachingInfo(0),
- m_storage_type(storage)
-{
- m_viewmatrix.setIdentity();
- m_viewinvmatrix.setIdentity();
-
- for (int i = 0; i < 32; i++)
- {
- left_eye_vinterlace_mask[i] = 0x55555555;
- right_eye_vinterlace_mask[i] = 0xAAAAAAAA;
- hinterlace_mask[i] = (i&1)*0xFFFFFFFF;
- }
- hinterlace_mask[32] = 0;
-
- m_prevafvalue = GPU_get_anisotropic();
-
- if (m_storage_type == RAS_VBO /*|| m_storage_type == RAS_AUTO_STORAGE && GLEW_ARB_vertex_buffer_object*/) {
- m_storage = new RAS_StorageVBO(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer);
- }
- else if ((m_storage_type == RAS_VA) || (m_storage_type == RAS_AUTO_STORAGE)) {
- m_storage = new RAS_StorageVA(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer);
- }
- else {
- printf("Unknown rasterizer storage type, falling back to vertex arrays\n");
- m_storage = new RAS_StorageVA(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer);
- }
-
- glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights);
- if (m_numgllights < 8)
- m_numgllights = 8;
-}
-
-
-
-RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer()
-{
- // Restore the previous AF value
- GPU_set_anisotropic(m_prevafvalue);
-
- if (m_storage)
- delete m_storage;
-}
-
-bool RAS_OpenGLRasterizer::Init()
-{
- bool storage_init;
- GPU_state_init();
-
-
- m_ambr = 0.0f;
- m_ambg = 0.0f;
- m_ambb = 0.0f;
-
- glDisable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
- //m_last_alphablend = GPU_BLEND_SOLID;
- GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
-
- glFrontFace(GL_CCW);
- m_last_frontface = true;
-
- m_redback = 0.4375f;
- m_greenback = 0.4375f;
- m_blueback = 0.4375f;
- m_alphaback = 0.0f;
-
- glClearColor(m_redback,m_greenback,m_blueback,m_alphaback);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-
- glShadeModel(GL_SMOOTH);
-
- storage_init = m_storage->Init();
-
- return true && storage_init;
-}
-
-
-void RAS_OpenGLRasterizer::SetAmbientColor(float color[3])
-{
- m_ambr = color[0];
- m_ambg = color[1];
- m_ambb = color[2];
-}
-
-void RAS_OpenGLRasterizer::SetAmbient(float factor)
-{
- float ambient[] = {m_ambr * factor, m_ambg * factor, m_ambb * factor, 1.0f};
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
-}
-
-void RAS_OpenGLRasterizer::SetBackColor(float color[3])
-{
- m_redback = color[0];
- m_greenback = color[1];
- m_blueback = color[2];
- m_alphaback = 0.0f;
-}
-
-void RAS_OpenGLRasterizer::SetFog(short type, float start, float dist, float intensity, float color[3])
-{
- float params[4] = {color[0], color[1], color[2], 1.0f};
- glFogi(GL_FOG_MODE, GL_LINEAR);
- glFogf(GL_FOG_DENSITY, intensity / 10.0f);
- glFogf(GL_FOG_START, start);
- glFogf(GL_FOG_END, start + dist);
- glFogfv(GL_FOG_COLOR, params);
-}
-
-void RAS_OpenGLRasterizer::EnableFog(bool enable)
-{
- m_fogenabled = enable;
-}
-
-void RAS_OpenGLRasterizer::DisplayFog()
-{
- if ((m_drawingmode >= KX_SOLID) && m_fogenabled) {
- glEnable(GL_FOG);
- }
- else {
- glDisable(GL_FOG);
- }
-}
-
-bool RAS_OpenGLRasterizer::SetMaterial(const RAS_IPolyMaterial& mat)
-{
- return mat.Activate(this, m_materialCachingInfo);
-}
-
-
-
-void RAS_OpenGLRasterizer::Exit()
-{
- m_storage->Exit();
-
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
- glClearDepth(1.0f);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glClearColor(m_redback, m_greenback, m_blueback, m_alphaback);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glDepthMask (GL_TRUE);
- glDepthFunc(GL_LEQUAL);
- glBlendFunc(GL_ONE, GL_ZERO);
-
- glDisable(GL_POLYGON_STIPPLE);
-
- glDisable(GL_LIGHTING);
- if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
- glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
-
- EndFrame();
-}
-
-bool RAS_OpenGLRasterizer::BeginFrame(double time)
-{
- m_time = time;
-
- // Blender camera routine destroys the settings
- if (m_drawingmode < KX_SOLID)
- {
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- }
- else
- {
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_CULL_FACE);
- }
-
- glDisable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
- //m_last_alphablend = GPU_BLEND_SOLID;
- GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
-
- glFrontFace(GL_CCW);
- m_last_frontface = true;
-
- glShadeModel(GL_SMOOTH);
-
- 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;
-}
-
-
-
-void RAS_OpenGLRasterizer::SetDrawingMode(int drawingmode)
-{
- m_drawingmode = drawingmode;
-
- if (m_drawingmode == KX_WIREFRAME)
- glDisable(GL_CULL_FACE);
-
- m_storage->SetDrawingMode(drawingmode);
-}
-
-int RAS_OpenGLRasterizer::GetDrawingMode()
-{
- return m_drawingmode;
-}
-
-
-void RAS_OpenGLRasterizer::SetDepthMask(DepthMask depthmask)
-{
- glDepthMask(depthmask == KX_DEPTHMASK_DISABLED ? GL_FALSE : GL_TRUE);
-}
-
-
-void RAS_OpenGLRasterizer::ClearColorBuffer()
-{
- m_2DCanvas->ClearColor(m_redback,m_greenback,m_blueback,m_alphaback);
- m_2DCanvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER);
-}
-
-
-void RAS_OpenGLRasterizer::ClearDepthBuffer()
-{
- m_2DCanvas->ClearBuffer(RAS_ICanvas::DEPTH_BUFFER);
-}
-
-
-void RAS_OpenGLRasterizer::ClearCachingInfo(void)
-{
- m_materialCachingInfo = 0;
-}
-
-void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene)
-{
- std::vector<OglDebugShape> &debugShapes = m_debugShapes[scene];
- if (debugShapes.empty())
- return;
-
- // DrawDebugLines
- GLboolean light, tex;
-
- light= glIsEnabled(GL_LIGHTING);
- tex= glIsEnabled(GL_TEXTURE_2D);
-
- if (light) glDisable(GL_LIGHTING);
- if (tex) glDisable(GL_TEXTURE_2D);
-
- // draw lines
- glBegin(GL_LINES);
- for (unsigned int i = 0; i < debugShapes.size(); i++) {
- if (debugShapes[i].m_type != OglDebugShape::LINE)
- continue;
- glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f);
- const MT_Scalar *fromPtr = &debugShapes[i].m_pos.x();
- const MT_Scalar *toPtr= &debugShapes[i].m_param.x();
- glVertex3fv(fromPtr);
- glVertex3fv(toPtr);
- }
- glEnd();
-
- // draw circles
- for (unsigned int i = 0; i < debugShapes.size(); i++) {
- if (debugShapes[i].m_type != OglDebugShape::CIRCLE)
- continue;
- glBegin(GL_LINE_LOOP);
- glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f);
-
- static const MT_Vector3 worldUp(0.0f, 0.0f, 1.0f);
- MT_Vector3 norm = debugShapes[i].m_param;
- MT_Matrix3x3 tr;
- if (norm.fuzzyZero() || norm == worldUp)
- {
- tr.setIdentity();
- }
- else
- {
- MT_Vector3 xaxis, yaxis;
- xaxis = MT_cross(norm, worldUp);
- yaxis = MT_cross(xaxis, norm);
- tr.setValue(xaxis.x(), xaxis.y(), xaxis.z(),
- yaxis.x(), yaxis.y(), yaxis.z(),
- norm.x(), norm.y(), norm.z());
- }
- MT_Scalar rad = debugShapes[i].m_param2.x();
- int n = (int)debugShapes[i].m_param2.y();
- for (int j = 0; j<n; j++)
- {
- MT_Scalar theta = j*(float)M_PI*2/n;
- MT_Vector3 pos(cosf(theta) * rad, sinf(theta) * rad, 0.0f);
- pos = pos*tr;
- pos += debugShapes[i].m_pos;
- const MT_Scalar* posPtr = &pos.x();
- glVertex3fv(posPtr);
- }
- glEnd();
- }
-
- if (light) glEnable(GL_LIGHTING);
- if (tex) glEnable(GL_TEXTURE_2D);
-
- debugShapes.clear();
-}
-
-void RAS_OpenGLRasterizer::EndFrame()
-{
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-
- glDisable(GL_MULTISAMPLE_ARB);
-
- m_2DCanvas->EndFrame();
-}
-
-void RAS_OpenGLRasterizer::SetRenderArea()
-{
- RAS_Rect area;
- // only above/below stereo method needs viewport adjustment
- switch (m_stereomode)
- {
- case RAS_STEREO_ABOVEBELOW:
- switch (m_curreye) {
- case RAS_STEREO_LEFTEYE:
- // upper half of window
- area.SetLeft(0);
- area.SetBottom(m_2DCanvas->GetHeight() -
- int(m_2DCanvas->GetHeight() - m_noOfScanlines) / 2);
-
- area.SetRight(int(m_2DCanvas->GetWidth()));
- area.SetTop(int(m_2DCanvas->GetHeight()));
- m_2DCanvas->SetDisplayArea(&area);
- break;
- case RAS_STEREO_RIGHTEYE:
- // lower half of window
- area.SetLeft(0);
- area.SetBottom(0);
- area.SetRight(int(m_2DCanvas->GetWidth()));
- area.SetTop(int(m_2DCanvas->GetHeight() - m_noOfScanlines) / 2);
- m_2DCanvas->SetDisplayArea(&area);
- break;
- }
- break;
- case RAS_STEREO_3DTVTOPBOTTOM:
- switch (m_curreye) {
- case RAS_STEREO_LEFTEYE:
- // upper half of window
- area.SetLeft(0);
- area.SetBottom(m_2DCanvas->GetHeight() -
- m_2DCanvas->GetHeight() / 2);
-
- area.SetRight(m_2DCanvas->GetWidth());
- area.SetTop(m_2DCanvas->GetHeight());
- m_2DCanvas->SetDisplayArea(&area);
- break;
- case RAS_STEREO_RIGHTEYE:
- // lower half of window
- area.SetLeft(0);
- area.SetBottom(0);
- area.SetRight(m_2DCanvas->GetWidth());
- area.SetTop(m_2DCanvas->GetHeight() / 2);
- m_2DCanvas->SetDisplayArea(&area);
- break;
- }
- break;
- case RAS_STEREO_SIDEBYSIDE:
- switch (m_curreye)
- {
- case RAS_STEREO_LEFTEYE:
- // Left half of window
- area.SetLeft(0);
- area.SetBottom(0);
- area.SetRight(m_2DCanvas->GetWidth()/2);
- area.SetTop(m_2DCanvas->GetHeight());
- m_2DCanvas->SetDisplayArea(&area);
- break;
- case RAS_STEREO_RIGHTEYE:
- // Right half of window
- area.SetLeft(m_2DCanvas->GetWidth()/2);
- area.SetBottom(0);
- area.SetRight(m_2DCanvas->GetWidth());
- area.SetTop(m_2DCanvas->GetHeight());
- m_2DCanvas->SetDisplayArea(&area);
- break;
- }
- break;
- default:
- // every available pixel
- area.SetLeft(0);
- area.SetBottom(0);
- area.SetRight(int(m_2DCanvas->GetWidth()));
- area.SetTop(int(m_2DCanvas->GetHeight()));
- m_2DCanvas->SetDisplayArea(&area);
- break;
- }
-}
-
-void RAS_OpenGLRasterizer::SetStereoMode(const StereoMode stereomode)
-{
- m_stereomode = stereomode;
-}
-
-RAS_IRasterizer::StereoMode RAS_OpenGLRasterizer::GetStereoMode()
-{
- return m_stereomode;
-}
-
-bool RAS_OpenGLRasterizer::Stereo()
-{
- if (m_stereomode > RAS_STEREO_NOSTEREO) // > 0
- return true;
- else
- return false;
-}
-
-bool RAS_OpenGLRasterizer::InterlacedStereo()
-{
- return m_stereomode == RAS_STEREO_VINTERLACE || m_stereomode == RAS_STEREO_INTERLACED;
-}
-
-void RAS_OpenGLRasterizer::SetEye(const StereoEye eye)
-{
- m_curreye = eye;
- switch (m_stereomode)
- {
- case RAS_STEREO_QUADBUFFERED:
- glDrawBuffer(m_curreye == RAS_STEREO_LEFTEYE ? GL_BACK_LEFT : GL_BACK_RIGHT);
- break;
- case RAS_STEREO_ANAGLYPH:
- if (m_curreye == RAS_STEREO_LEFTEYE) {
- glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
- }
- else {
- //glAccum(GL_LOAD, 1.0f);
- glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
- ClearDepthBuffer();
- }
- break;
- case RAS_STEREO_VINTERLACE:
- {
- // OpenGL stippling is deprecated, it is no longer possible to affect all shaders
- // this way, offscreen rendering and then compositing may be the better solution
- glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple((const GLubyte*) ((m_curreye == RAS_STEREO_LEFTEYE) ? left_eye_vinterlace_mask : right_eye_vinterlace_mask));
- if (m_curreye == RAS_STEREO_RIGHTEYE)
- ClearDepthBuffer();
- break;
- }
- case RAS_STEREO_INTERLACED:
- {
- glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple((const GLubyte*) &hinterlace_mask[m_curreye == RAS_STEREO_LEFTEYE?0:1]);
- if (m_curreye == RAS_STEREO_RIGHTEYE)
- ClearDepthBuffer();
- break;
- }
- default:
- break;
- }
-}
-
-RAS_IRasterizer::StereoEye RAS_OpenGLRasterizer::GetEye()
-{
- return m_curreye;
-}
-
-
-void RAS_OpenGLRasterizer::SetEyeSeparation(const float eyeseparation)
-{
- m_eyeseparation = eyeseparation;
-}
-
-float RAS_OpenGLRasterizer::GetEyeSeparation()
-{
- return m_eyeseparation;
-}
-
-void RAS_OpenGLRasterizer::SetFocalLength(const float focallength)
-{
- m_focallength = focallength;
- m_setfocallength = true;
-}
-
-float RAS_OpenGLRasterizer::GetFocalLength()
-{
- return m_focallength;
-}
-
-RAS_IOffScreen *RAS_OpenGLRasterizer::CreateOffScreen(int width, int height, int samples, int target)
-{
- RAS_IOffScreen *ofs;
-
- ofs = new RAS_OpenGLOffScreen(m_2DCanvas);
-
- if (!ofs->Create(width, height, samples, (RAS_IOffScreen::RAS_OFS_RENDER_TARGET)target)) {
- delete ofs;
- return NULL;
- }
- return ofs;
-}
-
-RAS_ISync *RAS_OpenGLRasterizer::CreateSync(int type)
-{
- RAS_ISync *sync;
-
- sync = new RAS_OpenGLSync();
-
- if (!sync->Create((RAS_ISync::RAS_SYNC_TYPE)type)) {
- delete sync;
- return NULL;
- }
- return sync;
-}
-
-void RAS_OpenGLRasterizer::SwapBuffers()
-{
- m_2DCanvas->SwapBuffers();
-}
-
-
-
-const MT_Matrix4x4& RAS_OpenGLRasterizer::GetViewMatrix() const
-{
- return m_viewmatrix;
-}
-
-const MT_Matrix4x4& RAS_OpenGLRasterizer::GetViewInvMatrix() const
-{
- return m_viewinvmatrix;
-}
-
-void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms,
- 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);
- glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
- }
- else
- glEnableClientState(GL_COLOR_ARRAY);
-
- for (ms.begin(it); !ms.end(it); ms.next(it)) {
- RAS_TexVert *vertex;
- size_t i, j, numvert;
-
- numvert = it.array->m_type;
-
- if (it.array->m_type == RAS_DisplayArray::LINE) {
- // line drawing, no text
- glBegin(GL_LINES);
-
- for (i=0; i<it.totindex; i+=2)
- {
- vertex = &it.vertex[it.index[i]];
- glVertex3fv(vertex->getXYZ());
-
- vertex = &it.vertex[it.index[i+1]];
- glVertex3fv(vertex->getXYZ());
- }
-
- glEnd();
- }
- else {
- // triangle and quad text drawing
- for (i=0; i<it.totindex; i+=numvert)
- {
- float v[4][3];
- const float *v_ptr[4] = {NULL};
- const float *uv_ptr[4] = {NULL};
- int glattrib, unit;
-
- for (j=0; j<numvert; j++) {
- vertex = &it.vertex[it.index[i+j]];
-
- v[j][0] = vertex->getXYZ()[0];
- v[j][1] = vertex->getXYZ()[1];
- v[j][2] = vertex->getXYZ()[2];
- v_ptr[j] = v[j];
-
- uv_ptr[j] = vertex->getUV(0);
- }
-
- // find the right opengl attribute
- glattrib = -1;
- if (GLEW_ARB_vertex_program)
- for (unit=0; unit<m_attrib_num; unit++)
- if (m_attrib[unit] == RAS_TEXCO_UV)
- glattrib = unit;
-
- GPU_render_text(
- polymat->GetDrawingMode(), mytext, mytext.Length(), polymat->GetMCol(),
- v_ptr, uv_ptr, glattrib);
-
- ClearCachingInfo();
- }
- }
- }
-
- glDisableClientState(GL_COLOR_ARRAY);
-}
-
-void RAS_OpenGLRasterizer::SetTexCoordNum(int num)
-{
- m_texco_num = num;
- if (m_texco_num > RAS_MAX_TEXCO)
- m_texco_num = RAS_MAX_TEXCO;
-}
-
-void RAS_OpenGLRasterizer::SetAttribNum(int num)
-{
- m_attrib_num = num;
- if (m_attrib_num > RAS_MAX_ATTRIB)
- m_attrib_num = RAS_MAX_ATTRIB;
-}
-
-void RAS_OpenGLRasterizer::SetTexCoord(TexCoGen coords, int unit)
-{
- // this changes from material to material
- if (unit < RAS_MAX_TEXCO)
- m_texco[unit] = coords;
-}
-
-void RAS_OpenGLRasterizer::SetAttrib(TexCoGen coords, int unit, int layer)
-{
- // this changes from material to material
- if (unit < RAS_MAX_ATTRIB) {
- m_attrib[unit] = coords;
- m_attrib_layer[unit] = layer;
- }
-}
-
-void RAS_OpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
-{
- if (ms.m_pDerivedMesh)
- DrawDerivedMesh(ms);
- else
- m_storage->IndexPrimitives(ms);
-}
-
-// Code for hooking into Blender's mesh drawing for derived meshes.
-// If/when we use more of Blender's drawing code, we may be able to
-// clean this up
-static bool current_wireframe;
-static RAS_MaterialBucket *current_bucket;
-static RAS_IPolyMaterial *current_polymat;
-static RAS_MeshSlot *current_ms;
-static RAS_MeshObject *current_mesh;
-static int current_blmat_nr;
-static GPUVertexAttribs current_gpu_attribs;
-static int CheckMaterialDM(int matnr, void *attribs)
-{
- // only draw the current material
- if (matnr != current_blmat_nr)
- return 0;
- GPUVertexAttribs *gattribs = (GPUVertexAttribs *)attribs;
- if (gattribs)
- memcpy(gattribs, &current_gpu_attribs, sizeof(GPUVertexAttribs));
- return 1;
-}
-
-void RAS_OpenGLRasterizer::DrawDerivedMesh(class RAS_MeshSlot &ms)
-{
- // mesh data is in derived mesh
- current_bucket = ms.m_bucket;
- current_polymat = current_bucket->GetPolyMaterial();
- current_ms = &ms;
- current_mesh = ms.m_mesh;
- current_wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME;
- // MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL); /* UNUSED */
-
- // handle two-side
- if (current_polymat->GetDrawingMode() & RAS_IRasterizer::KX_BACKCULL)
- this->SetCullFace(true);
- else
- this->SetCullFace(false);
-
-#if 0
- if (current_polymat->GetFlag() & RAS_BLENDERGLSL)
-#endif
- {
- // GetMaterialIndex return the original mface material index,
- // increment by 1 to match what derived mesh is doing
- current_blmat_nr = current_polymat->GetMaterialIndex()+1;
- // For GLSL we need to retrieve the GPU material attribute
- Material* blmat = current_polymat->GetBlenderMaterial();
- Scene* blscene = current_polymat->GetBlenderScene();
- if (!current_wireframe && blscene && blmat)
- GPU_material_vertex_attributes(GPU_material_from_blender(blscene, blmat, false), &current_gpu_attribs);
- else
- memset(&current_gpu_attribs, 0, sizeof(current_gpu_attribs));
- // DM draw can mess up blending mode, restore at the end
- int current_blend_mode = GPU_get_material_alpha_blend();
- ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM);
- GPU_set_material_alpha_blend(current_blend_mode);
- }
-}
-
-void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
-{
- glMatrixMode(GL_PROJECTION);
- float* matrix = &mat(0, 0);
- glLoadMatrixf(matrix);
-
- m_camortho = (mat(3, 3) != 0.0f);
-}
-
-void RAS_OpenGLRasterizer::SetProjectionMatrix(const MT_Matrix4x4 & mat)
-{
- glMatrixMode(GL_PROJECTION);
- float matrix[16];
- /* Get into argument. Looks a bit dodgy, but it's ok. */
- mat.getValue(matrix);
- glLoadMatrixf(matrix);
-
- m_camortho = (mat[3][3] != 0.0f);
-}
-
-MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
- float left,
- float right,
- float bottom,
- float top,
- float frustnear,
- float frustfar,
- float focallength,
- bool
-) {
- MT_Matrix4x4 result;
- float mat[16];
-
- // correction for stereo
- if (Stereo())
- {
- float near_div_focallength;
- float offset;
-
- // if Rasterizer.setFocalLength is not called we use the camera focallength
- if (!m_setfocallength)
- // if focallength is null we use a value known to be reasonable
- m_focallength = (focallength == 0.f) ? m_eyeseparation * 30.0f
- : focallength;
-
- near_div_focallength = frustnear / m_focallength;
- offset = 0.5f * m_eyeseparation * near_div_focallength;
- switch (m_curreye) {
- case RAS_STEREO_LEFTEYE:
- left += offset;
- right += offset;
- break;
- case RAS_STEREO_RIGHTEYE:
- left -= offset;
- right -= offset;
- break;
- }
- // leave bottom and top untouched
- if (m_stereomode == RAS_STEREO_3DTVTOPBOTTOM) {
- // restore the vertical frustum because the 3DTV will
- // expand the top and bottom part to the full size of the screen
- bottom *= 2.0f;
- top *= 2.0f;
- }
- }
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(left, right, bottom, top, frustnear, frustfar);
-
- glGetFloatv(GL_PROJECTION_MATRIX, mat);
- result.setValue(mat);
-
- return result;
-}
-
-MT_Matrix4x4 RAS_OpenGLRasterizer::GetOrthoMatrix(
- float left,
- float right,
- float bottom,
- float top,
- float frustnear,
- float frustfar
-) {
- MT_Matrix4x4 result;
- float mat[16];
-
- // stereo is meaningless for orthographic, disable it
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(left, right, bottom, top, frustnear, frustfar);
-
- glGetFloatv(GL_PROJECTION_MATRIX, mat);
- result.setValue(mat);
-
- return result;
-}
-
-
-// next arguments probably contain redundant info, for later...
-void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat,
- const MT_Matrix3x3 & camOrientMat3x3,
- const MT_Point3 & pos,
- const MT_Vector3 &scale,
- bool perspective)
-{
- m_viewmatrix = mat;
-
- // correction for stereo
- if (Stereo() && perspective)
- {
- MT_Vector3 unitViewDir(0.0f, -1.0f, 0.0f); // minus y direction, Blender convention
- MT_Vector3 unitViewupVec(0.0f, 0.0f, 1.0f);
- MT_Vector3 viewDir, viewupVec;
- MT_Vector3 eyeline;
-
- // actual viewDir
- viewDir = camOrientMat3x3 * unitViewDir; // this is the moto convention, vector on right hand side
- // actual viewup vec
- viewupVec = camOrientMat3x3 * unitViewupVec;
-
- // vector between eyes
- eyeline = viewDir.cross(viewupVec);
-
- switch (m_curreye) {
- case RAS_STEREO_LEFTEYE:
- {
- // translate to left by half the eye distance
- MT_Transform transform;
- transform.setIdentity();
- transform.translate(-(eyeline * m_eyeseparation / 2.0f));
- m_viewmatrix *= transform;
- }
- break;
- case RAS_STEREO_RIGHTEYE:
- {
- // translate to right by half the eye distance
- MT_Transform transform;
- transform.setIdentity();
- transform.translate(eyeline * m_eyeseparation / 2.0f);
- m_viewmatrix *= transform;
- }
- break;
- }
- }
-
- bool negX = (scale[0] < 0.0f);
- bool negY = (scale[1] < 0.0f);
- bool negZ = (scale[2] < 0.0f);
- if (negX || negY || negZ) {
- m_viewmatrix.tscale((negX)?-1.0f:1.0f, (negY)?-1.0f:1.0f, (negZ)?-1.0f:1.0f, 1.0);
- }
- m_viewinvmatrix = m_viewmatrix;
- m_viewinvmatrix.invert();
-
- // note: getValue gives back column major as needed by OpenGL
- MT_Scalar glviewmat[16];
- m_viewmatrix.getValue(glviewmat);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(glviewmat);
- m_campos = pos;
- m_camnegscale = negX ^ negY ^ negZ;
-}
-
-
-const MT_Point3& RAS_OpenGLRasterizer::GetCameraPosition()
-{
- return m_campos;
-}
-
-bool RAS_OpenGLRasterizer::GetCameraOrtho()
-{
- return m_camortho;
-}
-
-void RAS_OpenGLRasterizer::SetCullFace(bool enable)
-{
- if (enable)
- glEnable(GL_CULL_FACE);
- else
- glDisable(GL_CULL_FACE);
-}
-
-void RAS_OpenGLRasterizer::SetLines(bool enable)
-{
- if (enable)
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- else
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-}
-
-void RAS_OpenGLRasterizer::SetSpecularity(float specX,
- float specY,
- float specZ,
- float specval)
-{
- GLfloat mat_specular[] = {specX, specY, specZ, specval};
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
-}
-
-
-
-void RAS_OpenGLRasterizer::SetShinyness(float shiny)
-{
- GLfloat mat_shininess[] = { shiny };
- glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
-}
-
-
-
-void RAS_OpenGLRasterizer::SetDiffuse(float difX,float difY,float difZ,float diffuse)
-{
- GLfloat mat_diffuse [] = {difX, difY,difZ, diffuse};
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
-}
-
-void RAS_OpenGLRasterizer::SetEmissive(float eX, float eY, float eZ, float e)
-{
- GLfloat mat_emit [] = {eX,eY,eZ,e};
- glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_emit);
-}
-
-
-double RAS_OpenGLRasterizer::GetTime()
-{
- return m_time;
-}
-
-void RAS_OpenGLRasterizer::SetPolygonOffset(float mult, float add)
-{
- glPolygonOffset(mult, add);
- GLint mode = GL_POLYGON_OFFSET_FILL;
- if (m_drawingmode < KX_SHADED)
- mode = GL_POLYGON_OFFSET_LINE;
- if (mult != 0.0f || add != 0.0f)
- glEnable(mode);
- else
- glDisable(mode);
-}
-
-void RAS_OpenGLRasterizer::EnableMotionBlur(float motionblurvalue)
-{
- /* don't just set m_motionblur to 1, but check if it is 0 so
- * we don't reset a motion blur that is already enabled */
- if (m_motionblur == 0)
- m_motionblur = 1;
- m_motionblurvalue = motionblurvalue;
-}
-
-void RAS_OpenGLRasterizer::DisableMotionBlur()
-{
- m_motionblur = 0;
- m_motionblurvalue = -1.0f;
-}
-
-void RAS_OpenGLRasterizer::SetAlphaBlend(int alphablend)
-{
- /* Variance shadow maps don't handle alpha well, best to not allow it for now */
- if (m_drawingmode == KX_SHADOW && m_usingoverrideshader)
- GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
- else
- GPU_set_material_alpha_blend(alphablend);
-/*
- if (alphablend == m_last_alphablend)
- return;
-
- if (alphablend == GPU_BLEND_SOLID) {
- glDisable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- else if (alphablend == GPU_BLEND_ADD) {
- glBlendFunc(GL_ONE, GL_ONE);
- glEnable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
- }
- else if (alphablend == GPU_BLEND_ALPHA) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.0f);
- }
- else if (alphablend == GPU_BLEND_CLIP) {
- glDisable(GL_BLEND);
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.5f);
- }
-
- m_last_alphablend = alphablend;
-*/
-}
-
-void RAS_OpenGLRasterizer::SetFrontFace(bool ccw)
-{
- if (m_camnegscale)
- ccw = !ccw;
-
- if (m_last_frontface == ccw)
- return;
-
- if (ccw)
- glFrontFace(GL_CCW);
- else
- glFrontFace(GL_CW);
-
- m_last_frontface = ccw;
-}
-
-void RAS_OpenGLRasterizer::SetAnisotropicFiltering(short level)
-{
- GPU_set_anisotropic((float)level);
-}
-
-short RAS_OpenGLRasterizer::GetAnisotropicFiltering()
-{
- return (short)GPU_get_anisotropic();
-}
-
-void RAS_OpenGLRasterizer::SetMipmapping(MipmapOption val)
-{
- if (val == RAS_IRasterizer::RAS_MIPMAP_LINEAR)
- {
- GPU_set_linear_mipmap(1);
- GPU_set_mipmap(1);
- }
- else if (val == RAS_IRasterizer::RAS_MIPMAP_NEAREST)
- {
- GPU_set_linear_mipmap(0);
- GPU_set_mipmap(1);
- }
- else
- {
- GPU_set_linear_mipmap(0);
- GPU_set_mipmap(0);
- }
-}
-
-RAS_IRasterizer::MipmapOption RAS_OpenGLRasterizer::GetMipmapping()
-{
- if (GPU_get_mipmap()) {
- if (GPU_get_linear_mipmap()) {
- return RAS_IRasterizer::RAS_MIPMAP_LINEAR;
- }
- else {
- return RAS_IRasterizer::RAS_MIPMAP_NEAREST;
- }
- }
- else {
- return RAS_IRasterizer::RAS_MIPMAP_NONE;
- }
-}
-
-void RAS_OpenGLRasterizer::SetUsingOverrideShader(bool val)
-{
- m_usingoverrideshader = val;
-}
-
-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<RAS_OpenGLLight*>::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_OpenGLLight* light = (*lit);
-
- if (light->ApplyFixedFunctionLighting(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;
-}
-
-RAS_ILightObject *RAS_OpenGLRasterizer::CreateLight()
-{
- return new RAS_OpenGLLight(this);
-}
-
-void RAS_OpenGLRasterizer::AddLight(RAS_ILightObject* lightobject)
-{
- RAS_OpenGLLight* gllight = dynamic_cast<RAS_OpenGLLight*>(lightobject);
- assert(gllight);
- m_lights.push_back(gllight);
-}
-
-void RAS_OpenGLRasterizer::RemoveLight(RAS_ILightObject* lightobject)
-{
- RAS_OpenGLLight* gllight = dynamic_cast<RAS_OpenGLLight*>(lightobject);
- assert(gllight);
-
- std::vector<RAS_OpenGLLight*>::iterator lit =
- std::find(m_lights.begin(),m_lights.end(),gllight);
-
- if (!(lit==m_lights.end()))
- m_lights.erase(lit);
-}
-
-bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, float *oglmatrix)
-{
- if (result->m_hitMesh) {
-
- RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon);
- if (!poly->IsVisible())
- return false;
-
- 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
-
- float 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};
-
- glTranslatef(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- //glMultMatrixd(oglmatrix);
- glMultMatrixf(maat);
- return true;
- }
- else {
- return false;
- }
-}
-
-void RAS_OpenGLRasterizer::applyTransform(float* 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.0f, 0.0f, 0.0f)
- // 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.0f);
-
- 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];
-
- float 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};
-
- glTranslatef(objpos[0],objpos[1],objpos[2]);
- glMultMatrixf(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();
-
- KX_RayCast::Callback<RAS_OpenGLRasterizer, float> callback(this, physics_controller, oglmatrix);
- if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
- {
- // couldn't find something to cast the shadow on...
- glMultMatrixf(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
- glMultMatrixf(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_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- glDisable(GL_TEXTURE_GEN_Q);
- glDisable(GL_TEXTURE_GEN_R);
- }
- 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,
- const float color[4], const float mat[16], 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, 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, 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, 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.0f);
- SetMotionBlurState(2);
- }
- else if (motionblurvalue >= 0.0f && motionblurvalue <= 1.0f) {
- glAccum(GL_MULT, motionblurvalue);
- glAccum(GL_ACCUM, 1-motionblurvalue);
- glAccum(GL_RETURN, 1.0f);
- 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;
-}
-
-void RAS_OpenGLRasterizer::PrintHardwareInfo()
-{
- #define pprint(x) std::cout << x << std::endl;
-
- pprint("GL_VENDOR: " << glGetString(GL_VENDOR));
- pprint("GL_RENDERER: " << glGetString(GL_RENDERER));
- pprint("GL_VERSION: " << glGetString(GL_VERSION));
- bool support=0;
- pprint("Supported Extensions...");
- pprint(" GL_ARB_shader_objects supported? "<< (GLEW_ARB_shader_objects?"yes.":"no."));
-
- support= GLEW_ARB_vertex_shader;
- pprint(" GL_ARB_vertex_shader supported? "<< (support?"yes.":"no."));
- if (support) {
- pprint(" ----------Details----------");
- int max=0;
- glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, (GLint*)&max);
- pprint(" Max uniform components." << max);
-
- glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, (GLint*)&max);
- pprint(" Max varying floats." << max);
-
- glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max);
- pprint(" Max vertex texture units." << max);
-
- glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max);
- pprint(" Max combined texture units." << max);
- pprint("");
- }
-
- support=GLEW_ARB_fragment_shader;
- pprint(" GL_ARB_fragment_shader supported? "<< (support?"yes.":"no."));
- if (support) {
- pprint(" ----------Details----------");
- int max=0;
- glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, (GLint*)&max);
- pprint(" Max uniform components." << max);
- pprint("");
- }
-
- support = GLEW_ARB_texture_cube_map;
- pprint(" GL_ARB_texture_cube_map supported? "<< (support?"yes.":"no."));
- if (support) {
- pprint(" ----------Details----------");
- int size=0;
- glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, (GLint*)&size);
- pprint(" Max cubemap size." << size);
- pprint("");
- }
-
- support = GLEW_ARB_multitexture;
- pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no."));
- if (support) {
- pprint(" ----------Details----------");
- int units=0;
- glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units);
- pprint(" Max texture units available. " << units);
- pprint("");
- }
-
- pprint(" GL_ARB_texture_env_combine supported? "<< (GLEW_ARB_texture_env_combine?"yes.":"no."));
-
- pprint(" GL_ARB_texture_non_power_of_two supported " << (GPU_full_non_power_of_two_support()?"yes.":"no."));
-}
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
deleted file mode 100644
index 9561e207dba..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
+++ /dev/null
@@ -1,343 +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_OpenGLRasterizer.h
- * \ingroup bgerastogl
- */
-
-#ifndef __RAS_OPENGLRASTERIZER_H__
-#define __RAS_OPENGLRASTERIZER_H__
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "MT_CmMatrix4x4.h"
-#include <vector>
-#include <map>
-using namespace std;
-
-#include "RAS_IRasterizer.h"
-#include "RAS_MaterialBucket.h"
-#include "RAS_IPolygonMaterial.h"
-
-#include "BLI_utildefines.h"
-
-class RAS_IStorage;
-class RAS_ICanvas;
-class RAS_OpenGLLight;
-
-#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_VA,
- RAS_VBO,
-};
-
-struct OglDebugShape
-{
- enum SHAPE_TYPE{
- LINE,
- CIRCLE,
- };
- SHAPE_TYPE m_type;
- MT_Vector3 m_pos;
- MT_Vector3 m_param;
- MT_Vector3 m_param2;
- MT_Vector3 m_color;
-};
-
-/**
- * 3D rendering device context.
- */
-class RAS_OpenGLRasterizer : public RAS_IRasterizer
-{
- RAS_ICanvas *m_2DCanvas;
-
- /* fogging vars */
- bool m_fogenabled;
-
- float m_redback;
- float m_greenback;
- float m_blueback;
- float m_alphaback;
-
- float m_ambr;
- float m_ambg;
- float m_ambb;
- double m_time;
- MT_Matrix4x4 m_viewmatrix;
- MT_Matrix4x4 m_viewinvmatrix;
- MT_Point3 m_campos;
- bool m_camortho;
- bool m_camnegscale;
-
- StereoMode m_stereomode;
- StereoEye m_curreye;
- float m_eyeseparation;
- float m_focallength;
- bool m_setfocallength;
- int m_noOfScanlines;
-
- short m_prevafvalue;
-
- /* motion blur */
- int m_motionblur;
- float m_motionblurvalue;
-
- bool m_usingoverrideshader;
-
- /* Render tools */
- void *m_clientobject;
- void *m_auxilaryClientInfo;
- std::vector<RAS_OpenGLLight *> 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];
- TexCoGen m_attrib[RAS_MAX_ATTRIB];
- int m_attrib_layer[RAS_MAX_ATTRIB];
- int m_texco_num;
- int m_attrib_num;
- /* int m_last_alphablend; */
- bool m_last_frontface;
-
- /* Stores the caching information for the last material activated. */
- RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo;
-
- /* Making use of a Strategy design pattern for storage behavior.
- * Examples of concrete strategies: Vertex Arrays, VBOs, Immediate Mode*/
- int m_storage_type;
- RAS_IStorage *m_storage;
-
-public:
- double GetTime();
- RAS_OpenGLRasterizer(RAS_ICanvas *canv, RAS_STORAGE_TYPE storage);
- virtual ~RAS_OpenGLRasterizer();
-
- /*enum DrawType
- {
- KX_BOUNDINGBOX = 1,
- KX_WIREFRAME,
- KX_SOLID,
- KX_SHADED,
- KX_TEXTURED
- };
-
- enum DepthMask
- {
- KX_DEPTHMASK_ENABLED =1,
- KX_DEPTHMASK_DISABLED,
- };*/
- virtual void SetDepthMask(DepthMask depthmask);
-
- virtual bool SetMaterial(const RAS_IPolyMaterial &mat);
- virtual bool Init();
- virtual void Exit();
- virtual bool BeginFrame(double time);
- virtual void ClearColorBuffer();
- virtual void ClearDepthBuffer();
- virtual void ClearCachingInfo(void);
- virtual void EndFrame();
- virtual void SetRenderArea();
-
- virtual void SetStereoMode(const StereoMode stereomode);
- virtual RAS_IRasterizer::StereoMode GetStereoMode();
- virtual bool Stereo();
- virtual bool InterlacedStereo();
- virtual void SetEye(const StereoEye eye);
- virtual StereoEye GetEye();
- virtual void SetEyeSeparation(const float eyeseparation);
- virtual float GetEyeSeparation();
- virtual void SetFocalLength(const float focallength);
- virtual float GetFocalLength();
- virtual RAS_IOffScreen *CreateOffScreen(int width, int height, int samples, int target);
- virtual RAS_ISync *CreateSync(int type);
- virtual void SwapBuffers();
-
- virtual void IndexPrimitives(class RAS_MeshSlot &ms);
- virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat);
- virtual void DrawDerivedMesh(class RAS_MeshSlot &ms);
-
- virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat);
- virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat);
- virtual void SetViewMatrix(
- const MT_Matrix4x4 &mat,
- const MT_Matrix3x3 &ori,
- const MT_Point3 &pos,
- const MT_Vector3 &scale,
- bool perspective);
-
- virtual const MT_Point3& GetCameraPosition();
- virtual bool GetCameraOrtho();
-
- virtual void SetFog(short type, float start, float dist, float intensity, float color[3]);
- virtual void EnableFog(bool enable);
- virtual void DisplayFog();
-
- virtual void SetBackColor(float color[3]);
-
- virtual void SetDrawingMode(int drawingmode);
- virtual int GetDrawingMode();
-
- virtual void SetCullFace(bool enable);
- virtual void SetLines(bool enable);
-
- virtual MT_Matrix4x4 GetFrustumMatrix(
- float left, float right, float bottom, float top,
- float frustnear, float frustfar,
- float focallength, bool perspective);
- virtual MT_Matrix4x4 GetOrthoMatrix(
- float left, float right, float bottom, float top,
- float frustnear, float frustfar);
-
- virtual void SetSpecularity(float specX, float specY, float specZ, float specval);
- virtual void SetShinyness(float shiny);
- virtual void SetDiffuse(float difX, float difY, float difZ, float diffuse);
- virtual void SetEmissive(float eX, float eY, float eZ, float e);
-
- virtual void SetAmbientColor(float color[3]);
- virtual void SetAmbient(float factor);
-
- virtual void SetPolygonOffset(float mult, float add);
-
- virtual void FlushDebugShapes(SCA_IScene *scene);
-
- virtual void DrawDebugLine(SCA_IScene *scene, const MT_Vector3 &from,const MT_Vector3 &to, const MT_Vector3 &color)
- {
- OglDebugShape line;
- line.m_type = OglDebugShape::LINE;
- line.m_pos= from;
- line.m_param = to;
- line.m_color = color;
- m_debugShapes[scene].push_back(line);
- }
-
- virtual void DrawDebugCircle(SCA_IScene *scene, const MT_Vector3 &center, const MT_Scalar radius,
- const MT_Vector3 &color, const MT_Vector3 &normal, int nsector)
- {
- OglDebugShape line;
- line.m_type = OglDebugShape::CIRCLE;
- line.m_pos= center;
- line.m_param = normal;
- line.m_color = color;
- line.m_param2.x() = radius;
- line.m_param2.y() = (float) nsector;
- m_debugShapes[scene].push_back(line);
- }
-
- // We store each debug shape by scene.
- std::map<SCA_IScene *, std::vector<OglDebugShape> > m_debugShapes;
-
- virtual void SetTexCoordNum(int num);
- virtual void SetAttribNum(int num);
- virtual void SetTexCoord(TexCoGen coords, int unit);
- virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0);
-
- void TexCoord(const RAS_TexVert &tv);
-
- const MT_Matrix4x4 &GetViewMatrix() const;
- const MT_Matrix4x4 &GetViewInvMatrix() const;
-
- virtual void EnableMotionBlur(float motionblurvalue);
- virtual void DisableMotionBlur();
- virtual float GetMotionBlurValue() { return m_motionblurvalue; }
- virtual int GetMotionBlurState() { return m_motionblur; }
- virtual void SetMotionBlurState(int newstate)
- {
- if (newstate < 0)
- m_motionblur = 0;
- else if (newstate > 2)
- m_motionblur = 2;
- else
- m_motionblur = newstate;
- }
-
- virtual void SetAlphaBlend(int alphablend);
- virtual void SetFrontFace(bool ccw);
-
- virtual void SetAnisotropicFiltering(short level);
- virtual short GetAnisotropicFiltering();
-
- virtual void SetMipmapping(MipmapOption val);
- virtual MipmapOption GetMipmapping();
-
- 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,
- const float color[4], const float mat[16], float aspect);
- void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char *text,
- int xco, int yco, int width, int height);
-
- void applyTransform(float *oglmatrix, int objectdrawmode);
-
- void PushMatrix();
- void PopMatrix();
-
- /// \see KX_RayCast
- bool RayHit(struct KX_ClientObjectInfo *client, class KX_RayCast *result, float *oglmatrix);
- /// \see KX_RayCast
- bool NeedRayCast(struct KX_ClientObjectInfo *, void *UNUSED(data)) { return true; }
-
- RAS_ILightObject* CreateLight();
- void AddLight(RAS_ILightObject* lightobject);
-
- void RemoveLight(RAS_ILightObject* lightobject);
- int ApplyLights(int objectlayer, const MT_Transform& viewmat);
-
- void MotionBlur();
-
- void SetClientObject(void *obj);
-
- void SetAuxilaryClientInfo(void *inf);
-
- /**
- * Prints information about what the hardware supports.
- */
- virtual void PrintHardwareInfo();
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_OpenGLRasterizer")
-#endif
-};
-
-#endif /* __RAS_OPENGLRASTERIZER_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.cpp
deleted file mode 100644
index 26b956cd74e..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.cpp
+++ /dev/null
@@ -1,82 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "GPU_glew.h"
-
-#include <stdio.h>
-
-#include "RAS_OpenGLSync.h"
-
-RAS_OpenGLSync::RAS_OpenGLSync()
- :m_sync(NULL)
-{
-}
-
-RAS_OpenGLSync::~RAS_OpenGLSync()
-{
- Destroy();
-}
-
-bool RAS_OpenGLSync::Create(RAS_SYNC_TYPE type)
-{
- if (m_sync) {
- printf("RAS_OpenGLSync::Create(): sync already exists, destroy first\n");
- return false;
- }
- if (type != RAS_SYNC_TYPE_FENCE) {
- printf("RAS_OpenGLSync::Create(): only RAS_SYNC_TYPE_FENCE are currently supported\n");
- return false;
- }
- if (!GLEW_ARB_sync) {
- printf("RAS_OpenGLSync::Create(): ARB_sync extension is needed to create sync object\n");
- return false;
- }
- m_sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
- if (!m_sync) {
- printf("RAS_OpenGLSync::Create(): glFenceSync() failed");
- return false;
- }
- return true;
-}
-
-void RAS_OpenGLSync::Destroy()
-{
- if (m_sync) {
- glDeleteSync(m_sync);
- m_sync = NULL;
- }
-}
-
-void RAS_OpenGLSync::Wait()
-{
- if (m_sync) {
- // this is needed to ensure that the sync is in the GPU
- glFlush();
- // block until the operation have completed
- glWaitSync(m_sync, 0, GL_TIMEOUT_IGNORED);
- }
-}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.h
deleted file mode 100644
index 4ba96903856..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLSync.h
+++ /dev/null
@@ -1,50 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __RAS_OPENGLSYNC__
-#define __RAS_OPENGLSYNC__
-
-
-#include "RAS_ISync.h"
-
-struct __GLsync;
-
-class RAS_OpenGLSync : public RAS_ISync
-{
-private:
- struct __GLsync *m_sync;
-
-public:
- RAS_OpenGLSync();
- ~RAS_OpenGLSync();
-
- virtual bool Create(RAS_SYNC_TYPE type);
- virtual void Destroy();
- virtual void Wait();
-};
-
-#endif /* __RAS_OPENGLSYNC__ */
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp
deleted file mode 100644
index f980116f5f8..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp
+++ /dev/null
@@ -1,260 +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 *****
- */
-
-#include "RAS_StorageVA.h"
-
-#include "GPU_glew.h"
-
-RAS_StorageVA::RAS_StorageVA(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer) :
- m_drawingmode(RAS_IRasterizer::KX_TEXTURED),
- m_texco_num(texco_num),
- m_attrib_num(attrib_num),
- m_last_texco_num(0),
- m_last_attrib_num(0),
- m_texco(texco),
- m_attrib(attrib),
- m_attrib_layer(attrib_layer)
-{
-}
-
-RAS_StorageVA::~RAS_StorageVA()
-{
-}
-
-bool RAS_StorageVA::Init()
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- return true;
-}
-
-void RAS_StorageVA::Exit()
-{
-}
-
-void RAS_StorageVA::IndexPrimitives(class RAS_MeshSlot& ms)
-{
- static const GLsizei stride = sizeof(RAS_TexVert);
- bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME, use_color_array = true;
- RAS_MeshSlot::iterator it;
- GLenum drawmode;
-
- if (!wireframe)
- EnableTextures(true);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
-
- // use glDrawElements to draw each vertexarray
- for (ms.begin(it); !ms.end(it); ms.next(it)) {
- if (it.totindex == 0)
- continue;
-
- // drawing mode
- if (it.array->m_type == RAS_DisplayArray::TRIANGLE)
- drawmode = GL_TRIANGLES;
- else if (it.array->m_type == RAS_DisplayArray::QUAD)
- drawmode = GL_QUADS;
- else
- drawmode = GL_LINES;
-
- // colors
- if (drawmode != GL_LINES && !wireframe) {
- if (ms.m_bObjectColor) {
- const MT_Vector4& rgba = ms.m_RGBAcolor;
-
- glDisableClientState(GL_COLOR_ARRAY);
- glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
- use_color_array = false;
- }
- else {
- glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
- glEnableClientState(GL_COLOR_ARRAY);
- use_color_array = true;
- }
- }
- else
- glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
-
- glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ());
- glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal());
-
- if (!wireframe) {
- TexCoordPtr(it.vertex);
- if (use_color_array)
- glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.vertex->getRGBA());
- }
-
- // here the actual drawing takes places
- glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.index);
- }
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- if (!wireframe) {
- glDisableClientState(GL_COLOR_ARRAY);
- EnableTextures(false);
- }
-}
-
-void RAS_StorageVA::TexCoordPtr(const RAS_TexVert *tv)
-{
- /* note: this function must closely match EnableTextures to enable/disable
- * the right arrays, otherwise coordinate and attribute pointers from other
- * materials can still be used and cause crashes */
- int unit;
-
- if (GLEW_ARB_multitexture)
- {
- for (unit = 0; unit < *m_texco_num; unit++)
- {
- glClientActiveTextureARB(GL_TEXTURE0_ARB+unit);
- switch (m_texco[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getXYZ());
- break;
- case RAS_IRasterizer::RAS_TEXCO_UV:
- glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV(unit));
- break;
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getNormal());
- break;
- case RAS_IRasterizer::RAS_TEXTANGENT:
- glTexCoordPointer(4, GL_FLOAT, sizeof(RAS_TexVert),tv->getTangent());
- break;
- default:
- break;
- }
- }
-
- glClientActiveTextureARB(GL_TEXTURE0_ARB);
- }
-
- if (GLEW_ARB_vertex_program) {
- for (unit = 0; unit < *m_attrib_num; unit++) {
- switch (m_attrib[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getXYZ());
- break;
- case RAS_IRasterizer::RAS_TEXCO_UV:
- glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV(m_attrib_layer[unit]));
- break;
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getNormal());
- break;
- case RAS_IRasterizer::RAS_TEXTANGENT:
- glVertexAttribPointerARB(unit, 4, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getTangent());
- break;
- case RAS_IRasterizer::RAS_TEXCO_VCOL:
- glVertexAttribPointerARB(unit, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(RAS_TexVert), tv->getRGBA());
- break;
- default:
- break;
- }
- }
- }
-}
-
-void RAS_StorageVA::EnableTextures(bool enable)
-{
- RAS_IRasterizer::TexCoGen *texco, *attrib;
- int unit, texco_num, attrib_num;
-
- /* we cache last texcoords and attribs to ensure we disable the ones that
- * were actually last set */
- if (enable) {
- texco = m_texco;
- texco_num = *m_texco_num;
- attrib = m_attrib;
- attrib_num = *m_attrib_num;
-
- memcpy(m_last_texco, m_texco, sizeof(RAS_IRasterizer::TexCoGen)*(*m_texco_num));
- m_last_texco_num = *m_texco_num;
- memcpy(m_last_attrib, m_attrib, sizeof(RAS_IRasterizer::TexCoGen)*(*m_attrib_num));
- m_last_attrib_num = *m_attrib_num;
- }
- else {
- texco = m_last_texco;
- texco_num = m_last_texco_num;
- attrib = m_last_attrib;
- attrib_num = m_last_attrib_num;
- }
-
- if (GLEW_ARB_multitexture) {
- for (unit = 0; unit < texco_num; unit++) {
- glClientActiveTextureARB(GL_TEXTURE0_ARB + unit);
-
- switch (texco[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- case RAS_IRasterizer::RAS_TEXCO_UV:
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- case RAS_IRasterizer::RAS_TEXTANGENT:
- if (enable) glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- else glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- break;
- default:
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- break;
- }
- }
-
- glClientActiveTextureARB(GL_TEXTURE0_ARB);
- }
- else {
- if (texco_num) {
- if (enable) glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- else glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- }
- }
-
- if (GLEW_ARB_vertex_program) {
- for (unit = 0; unit < attrib_num; unit++) {
- switch (attrib[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- case RAS_IRasterizer::RAS_TEXCO_UV:
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- case RAS_IRasterizer::RAS_TEXTANGENT:
- case RAS_IRasterizer::RAS_TEXCO_VCOL:
- if (enable) glEnableVertexAttribArrayARB(unit);
- else glDisableVertexAttribArrayARB(unit);
- break;
- default:
- glDisableVertexAttribArrayARB(unit);
- break;
- }
- }
- }
-
- if (!enable) {
- m_last_texco_num = 0;
- m_last_attrib_num = 0;
- }
-}
-
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
deleted file mode 100644
index a5a3170ed77..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
+++ /dev/null
@@ -1,77 +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 *****
- */
-
-#ifndef __KX_VERTEXARRAYSTORAGE
-#define __KX_VERTEXARRAYSTORAGE
-
-#include "RAS_IStorage.h"
-#include "RAS_IRasterizer.h"
-
-#include "RAS_OpenGLRasterizer.h"
-
-class RAS_StorageVA : public RAS_IStorage
-{
-
-public:
- RAS_StorageVA(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer);
- virtual ~RAS_StorageVA();
-
- virtual bool Init();
- virtual void Exit();
-
- virtual void IndexPrimitives(RAS_MeshSlot& ms);
-
- virtual void SetDrawingMode(int drawingmode) {m_drawingmode = drawingmode;};
-
-protected:
- int m_drawingmode;
-
- int* m_texco_num;
- int* m_attrib_num;
-
- int m_last_texco_num;
- int m_last_attrib_num;
-
- RAS_IRasterizer::TexCoGen* m_texco;
- RAS_IRasterizer::TexCoGen* m_attrib;
- int* m_attrib_layer;
-
- RAS_IRasterizer::TexCoGen m_last_texco[RAS_MAX_TEXCO];
- RAS_IRasterizer::TexCoGen m_last_attrib[RAS_MAX_ATTRIB];
-
- virtual void EnableTextures(bool enable);
- virtual void TexCoordPtr(const RAS_TexVert *tv);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
-public:
- void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageVA"); }
- void operator delete( void *mem ) { MEM_freeN(mem); }
-#endif
-};
-
-#endif //__KX_VERTEXARRAYSTORAGE
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp
deleted file mode 100644
index 4ba5882a46e..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp
+++ /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 *****
- */
-
-#include "RAS_StorageVBO.h"
-#include "RAS_MeshObject.h"
-
-#include "GPU_glew.h"
-
-VBO::VBO(RAS_DisplayArray *data, unsigned int indices)
-{
- this->data = data;
- this->size = data->m_vertex.size();
- this->indices = indices;
- this->stride = sizeof(RAS_TexVert);
-
- // Determine drawmode
- if (data->m_type == data->QUAD)
- this->mode = GL_QUADS;
- else if (data->m_type == data->TRIANGLE)
- this->mode = GL_TRIANGLES;
- else
- this->mode = GL_LINE;
-
- // Generate Buffers
- glGenBuffersARB(1, &this->ibo);
- glGenBuffersARB(1, &this->vbo_id);
-
- // Fill the buffers with initial data
- UpdateIndices();
- UpdateData();
-
- // Establish offsets
- this->vertex_offset = (void*)(((RAS_TexVert*)0)->getXYZ());
- this->normal_offset = (void*)(((RAS_TexVert*)0)->getNormal());
- this->tangent_offset = (void*)(((RAS_TexVert*)0)->getTangent());
- this->color_offset = (void*)(((RAS_TexVert*)0)->getRGBA());
- this->uv_offset = (void*)(((RAS_TexVert*)0)->getUV(0));
-}
-
-VBO::~VBO()
-{
- glDeleteBuffersARB(1, &this->ibo);
- glDeleteBuffersARB(1, &this->vbo_id);
-}
-
-void VBO::UpdateData()
-{
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, this->vbo_id);
- glBufferData(GL_ARRAY_BUFFER, this->stride*this->size, &this->data->m_vertex[0], GL_STATIC_DRAW);
-}
-
-void VBO::UpdateIndices()
-{
- glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, this->ibo);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, data->m_index.size() * sizeof(GLushort),
- &data->m_index[0], GL_STATIC_DRAW);
-}
-
-void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer)
-{
- int unit;
-
- // Bind buffers
- glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, this->ibo);
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, this->vbo_id);
-
- // Vertexes
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, this->stride, this->vertex_offset);
-
- // Normals
- glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(GL_FLOAT, this->stride, this->normal_offset);
-
- // Colors
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer(4, GL_UNSIGNED_BYTE, this->stride, this->color_offset);
-
- for (unit = 0; unit < texco_num; ++unit)
- {
- glClientActiveTexture(GL_TEXTURE0_ARB + unit);
- switch (texco[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(3, GL_FLOAT, this->stride, this->vertex_offset);
- break;
- case RAS_IRasterizer::RAS_TEXCO_UV:
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, this->stride, (void*)((intptr_t)this->uv_offset+(sizeof(GLfloat)*2*unit)));
- break;
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(3, GL_FLOAT, this->stride, this->normal_offset);
- break;
- case RAS_IRasterizer::RAS_TEXTANGENT:
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(4, GL_FLOAT, this->stride, this->tangent_offset);
- break;
- default:
- break;
- }
- }
- glClientActiveTextureARB(GL_TEXTURE0_ARB);
-
- if (GLEW_ARB_vertex_program)
- {
- for (unit = 0; unit < attrib_num; ++unit)
- {
- switch (attrib[unit]) {
- case RAS_IRasterizer::RAS_TEXCO_ORCO:
- case RAS_IRasterizer::RAS_TEXCO_GLOB:
- glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, this->stride, this->vertex_offset);
- glEnableVertexAttribArrayARB(unit);
- break;
- case RAS_IRasterizer::RAS_TEXCO_UV:
- glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, this->stride, (void*)((intptr_t)this->uv_offset+attrib_layer[unit]*sizeof(GLfloat)*2));
- glEnableVertexAttribArrayARB(unit);
- break;
- case RAS_IRasterizer::RAS_TEXCO_NORM:
- glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, stride, this->normal_offset);
- glEnableVertexAttribArrayARB(unit);
- break;
- case RAS_IRasterizer::RAS_TEXTANGENT:
- glVertexAttribPointerARB(unit, 4, GL_FLOAT, GL_FALSE, this->stride, this->tangent_offset);
- glEnableVertexAttribArrayARB(unit);
- break;
- case RAS_IRasterizer::RAS_TEXCO_VCOL:
- glVertexAttribPointerARB(unit, 4, GL_UNSIGNED_BYTE, GL_TRUE, this->stride, this->color_offset);
- glEnableVertexAttribArrayARB(unit);
- default:
- break;
- }
- }
- }
-
- glDrawElements(this->mode, this->indices, GL_UNSIGNED_SHORT, 0);
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-
- if (GLEW_ARB_vertex_program)
- {
- for (int i = 0; i < attrib_num; ++i)
- glDisableVertexAttribArrayARB(i);
- }
-
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
- glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
-}
-
-RAS_StorageVBO::RAS_StorageVBO(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer):
- m_drawingmode(RAS_IRasterizer::KX_TEXTURED),
- m_texco_num(texco_num),
- m_attrib_num(attrib_num),
- m_texco(texco),
- m_attrib(attrib),
- m_attrib_layer(attrib_layer)
-{
-}
-
-RAS_StorageVBO::~RAS_StorageVBO()
-{
-}
-
-bool RAS_StorageVBO::Init()
-{
- return true;
-}
-
-void RAS_StorageVBO::Exit()
-{
- VBOMap::iterator it = m_vbo_lookup.begin();
- while (it != m_vbo_lookup.end()) {
- delete it->second;
- ++it;
- }
- m_vbo_lookup.clear();
-}
-
-void RAS_StorageVBO::IndexPrimitives(RAS_MeshSlot& ms)
-{
- RAS_MeshSlot::iterator it;
- VBO *vbo;
-
- for (ms.begin(it); !ms.end(it); ms.next(it))
- {
- vbo = m_vbo_lookup[it.array];
-
- if (vbo == 0)
- m_vbo_lookup[it.array] = vbo = new VBO(it.array, it.totindex);
-
- // Update the vbo
- if (ms.m_mesh->MeshModified())
- {
- vbo->UpdateData();
- }
-
- vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer);
- }
-}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
deleted file mode 100644
index c82b6a3206d..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
+++ /dev/null
@@ -1,100 +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 *****
- */
-
-#ifndef __KX_VERTEXBUFFEROBJECTSTORAGE
-#define __KX_VERTEXBUFFEROBJECTSTORAGE
-
-#include <map>
-#include "GPU_glew.h"
-
-#include "RAS_IStorage.h"
-#include "RAS_IRasterizer.h"
-
-#include "RAS_OpenGLRasterizer.h"
-
-class VBO
-{
-public:
- VBO(RAS_DisplayArray *data, unsigned int indices);
- ~VBO();
-
- void Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer);
-
- void UpdateData();
- void UpdateIndices();
-private:
- RAS_DisplayArray* data;
- GLuint size;
- GLuint stride;
- GLuint indices;
- GLenum mode;
- GLuint ibo;
- GLuint vbo_id;
-
- void* vertex_offset;
- void* normal_offset;
- void* color_offset;
- void* tangent_offset;
- void* uv_offset;
-};
-
-typedef std::map<RAS_DisplayArray*, VBO*> VBOMap;
-
-class RAS_StorageVBO : public RAS_IStorage
-{
-
-public:
- RAS_StorageVBO(int *texco_num, RAS_IRasterizer::TexCoGen *texco, int *attrib_num, RAS_IRasterizer::TexCoGen *attrib, int *attrib_layer);
- virtual ~RAS_StorageVBO();
-
- virtual bool Init();
- virtual void Exit();
-
- virtual void IndexPrimitives(RAS_MeshSlot& ms);
-
- virtual void SetDrawingMode(int drawingmode) {m_drawingmode = drawingmode;};
-
-protected:
- int m_drawingmode;
-
- int* m_texco_num;
- int* m_attrib_num;
-
- RAS_IRasterizer::TexCoGen* m_texco;
- RAS_IRasterizer::TexCoGen* m_attrib;
- int* m_attrib_layer;
-
- VBOMap m_vbo_lookup;
-
-#ifdef WITH_CXX_GUARDEDALLOC
-public:
- void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_StorageVA"); }
- void operator delete( void *mem ) { MEM_freeN(mem); }
-#endif
-};
-
-#endif //__KX_VERTEXBUFFEROBJECTSTORAGE
diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp
deleted file mode 100644
index 3274ded4406..00000000000
--- a/source/gameengine/Rasterizer/RAS_Polygon.cpp
+++ /dev/null
@@ -1,123 +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_Polygon.cpp
- * \ingroup bgerast
- */
-
-#ifdef _MSC_VER
-# pragma warning (disable:4786)
-#endif
-
-#include "RAS_Polygon.h"
-#include "RAS_MaterialBucket.h"
-
-RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert)
-{
- m_bucket = bucket;
- m_darray = darray;
- m_offset[0] = m_offset[1] = m_offset[2] = m_offset[3] = 0;
- m_numvert = numvert;
-
-// m_edgecode = 255;
- m_polyflags = 0;
-}
-
-int RAS_Polygon::VertexCount()
-{
- return m_numvert;
-}
-
-void RAS_Polygon::SetVertexOffset(int i, unsigned short offset)
-{
- m_offset[i] = offset;
-}
-
-RAS_TexVert *RAS_Polygon::GetVertex(int i)
-{
- return &m_darray->m_vertex[m_offset[i]];
-}
-
-unsigned int RAS_Polygon::GetVertexOffsetAbsolute(unsigned short i)
-{
- return m_offset[i] + m_darray->m_offset;
-}
-
-/*
-int RAS_Polygon::GetEdgeCode()
-{
- return m_edgecode;
-}
-
-void RAS_Polygon::SetEdgeCode(int edgecode)
-{
- m_edgecode = edgecode;
-}*/
-
-
-bool RAS_Polygon::IsVisible()
-{
- return (m_polyflags & VISIBLE) != 0;
-}
-
-void RAS_Polygon::SetVisible(bool visible)
-{
- if (visible) m_polyflags |= VISIBLE;
- else m_polyflags &= ~VISIBLE;
-}
-
-bool RAS_Polygon::IsCollider()
-{
- return (m_polyflags & COLLIDER) != 0;
-}
-
-void RAS_Polygon::SetCollider(bool visible)
-{
- if (visible) m_polyflags |= COLLIDER;
- else m_polyflags &= ~COLLIDER;
-}
-
-bool RAS_Polygon::IsTwoside()
-{
- return (m_polyflags & TWOSIDE) != 0;
-}
-
-void RAS_Polygon::SetTwoside(bool twoside)
-{
- if (twoside) m_polyflags |= TWOSIDE;
- else m_polyflags &= ~TWOSIDE;
-}
-
-RAS_MaterialBucket* RAS_Polygon::GetMaterial()
-{
- return m_bucket;
-}
-
-RAS_DisplayArray* RAS_Polygon::GetDisplayArray()
-{
- return m_darray;
-}
diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h
deleted file mode 100644
index 597e80ffdfb..00000000000
--- a/source/gameengine/Rasterizer/RAS_Polygon.h
+++ /dev/null
@@ -1,101 +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_Polygon.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_POLYGON_H__
-#define __RAS_POLYGON_H__
-
-class RAS_DisplayArray;
-class RAS_MaterialBucket;
-class RAS_TexVert;
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/* polygon flags */
-
-class RAS_Polygon
-{
- /* location */
- RAS_MaterialBucket* m_bucket;
- RAS_DisplayArray* m_darray;
- unsigned short m_offset[4];
- unsigned short m_numvert;
-
- /* flags */
-#if 1
- unsigned short m_polyflags;
-#else
- unsigned char m_edgecode;
- unsigned char m_polyflags;
-#endif
-
-public:
- enum {
- VISIBLE = 1,
- COLLIDER = 2,
- TWOSIDE = 4
- };
-
- RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray* darray, int numvert);
- virtual ~RAS_Polygon() {};
-
- int VertexCount();
- RAS_TexVert* GetVertex(int i);
-
- void SetVertexOffset(int i, unsigned short offset);
- unsigned int GetVertexOffsetAbsolute(unsigned short i);
-
- // each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc.
- // - Not used yet!
-/* int GetEdgeCode();
- void SetEdgeCode(int edgecode); */
-
- bool IsVisible();
- void SetVisible(bool visible);
-
- bool IsCollider();
- void SetCollider(bool collider);
-
- bool IsTwoside();
- void SetTwoside(bool twoside);
-
- RAS_MaterialBucket* GetMaterial();
- RAS_DisplayArray* GetDisplayArray();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_Polygon")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/Rasterizer/RAS_Rect.h b/source/gameengine/Rasterizer/RAS_Rect.h
deleted file mode 100644
index fc99c9159db..00000000000
--- a/source/gameengine/Rasterizer/RAS_Rect.h
+++ /dev/null
@@ -1,104 +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_Rect.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_RECT_H__
-#define __RAS_RECT_H__
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/**
- * \section interface class.
- * RAS_Rect just encodes a simple rectangle.
- * \note Should be part of a generic library
- */
-class RAS_Rect
-{
-public: // todo: make a decent class, and make private
- int m_x1, m_y1;
- int m_x2, m_y2;
-
-public:
- RAS_Rect() : m_x1(0), m_y1(0), m_x2(0), m_y2(0) {}
- int GetWidth(
- ) const {
- return m_x2 - m_x1;
- }
- int GetHeight(
- ) const {
- return m_y2 - m_y1;
- }
- int GetLeft(
- ) const {
- return m_x1;
- }
- int GetRight(
- ) const {
- return m_x2;
- }
- int GetBottom(
- ) const {
- return m_y1;
- }
- int GetTop(
- ) const {
- return m_y2;
- }
-
- void SetLeft(
- int x1)
- {
- m_x1 = x1;
- }
- void SetBottom(
- int y1)
- {
- m_y1 = y1;
- }
- void SetRight(
- int x2)
- {
- m_x2 = x2;
- }
- void SetTop(
- int y2)
- {
- m_y2 = y2;
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_Rect")
-#endif
-};
-
-#endif /* __RAS_RECT_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_TexMatrix.h b/source/gameengine/Rasterizer/RAS_TexMatrix.h
deleted file mode 100644
index a2dd291d016..00000000000
--- a/source/gameengine/Rasterizer/RAS_TexMatrix.h
+++ /dev/null
@@ -1,42 +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_TexMatrix.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_TEXMATRIX_H__
-#define __RAS_TEXMATRIX_H__
-
-#include "MT_Matrix3x3.h"
-#include "MT_Point3.h"
-#include "MT_Point2.h"
-#include "RAS_TexVert.h"
-
-void RAS_CalcTexMatrix(RAS_TexVert p[3],MT_Point3& origin,MT_Vector3& udir,MT_Vector3& vdir);
-
-#endif /* __RAS_TEXMATRIX_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp
deleted file mode 100644
index 2e176360d61..00000000000
--- a/source/gameengine/Rasterizer/RAS_TexVert.cpp
+++ /dev/null
@@ -1,164 +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_TexVert.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_TexVert.h"
-#include "MT_Matrix4x4.h"
-#include "BLI_math.h"
-
-RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
- const MT_Point2 uvs[MAX_UNIT],
- const MT_Vector4& tangent,
- const unsigned int rgba,
- const MT_Vector3& normal,
- const bool flat,
- const unsigned int origindex)
-{
- xyz.getValue(m_localxyz);
- SetRGBA(rgba);
- SetNormal(normal);
- tangent.getValue(m_tangent);
- m_flag = (flat) ? FLAT: 0;
- m_origindex = origindex;
- m_unit = 2;
- m_softBodyIndex = -1;
-
- for (int i = 0; i < MAX_UNIT; ++i)
- {
- uvs[i].getValue(m_uvs[i]);
- }
-}
-
-const MT_Point3& RAS_TexVert::xyz()
-{
- g_pt3.setValue(m_localxyz);
- return g_pt3;
-}
-
-void RAS_TexVert::SetRGBA(const MT_Vector4& rgba)
-{
- unsigned char *colp = (unsigned char*) &m_rgba;
- colp[0] = (unsigned char) (rgba[0] * 255.0f);
- colp[1] = (unsigned char) (rgba[1] * 255.0f);
- colp[2] = (unsigned char) (rgba[2] * 255.0f);
- colp[3] = (unsigned char) (rgba[3] * 255.0f);
-}
-
-
-void RAS_TexVert::SetXYZ(const MT_Point3& xyz)
-{
- xyz.getValue(m_localxyz);
-}
-
-void RAS_TexVert::SetXYZ(const float xyz[3])
-{
- copy_v3_v3(m_localxyz, xyz);
-}
-
-void RAS_TexVert::SetUV(int index, const MT_Point2& uv)
-{
- uv.getValue(m_uvs[index]);
-}
-
-void RAS_TexVert::SetUV(int index, const float uv[2])
-{
- copy_v2_v2(m_uvs[index], uv);
-}
-
-void RAS_TexVert::SetRGBA(const unsigned int rgba)
-{
- m_rgba = rgba;
-}
-
-
-void RAS_TexVert::SetFlag(const short flag)
-{
- m_flag = flag;
-}
-
-void RAS_TexVert::SetUnit(const unsigned int u)
-{
- m_unit = (u <= (unsigned int) MAX_UNIT) ? u: (unsigned int)MAX_UNIT;
-}
-
-void RAS_TexVert::SetNormal(const MT_Vector3& normal)
-{
- normal.getValue(m_normal);
-}
-
-void RAS_TexVert::SetTangent(const MT_Vector3& tangent)
-{
- tangent.getValue(m_tangent);
-}
-
-
-// compare two vertices, and return true if both are almost identical (they can be shared)
-bool RAS_TexVert::closeTo(const RAS_TexVert* other)
-{
- const float eps = FLT_EPSILON;
- for (int i = 0; i < MAX_UNIT; i++) {
- if (!compare_v2v2(m_uvs[i], other->m_uvs[i], eps)) {
- return false;
- }
- }
-
- return (/* m_flag == other->m_flag && */
- /* at the moment the face only stores the smooth/flat setting so don't bother comparing it */
- (m_rgba == other->m_rgba) &&
- compare_v3v3(m_normal, other->m_normal, eps) &&
- compare_v3v3(m_tangent, other->m_tangent, eps)
- /* don't bother comparing m_localxyz since we know there from the same vert */
- /* && compare_v3v3(m_localxyz, other->m_localxyz, eps))*/
- );
-}
-
-short RAS_TexVert::getFlag() const
-{
- return m_flag;
-}
-
-
-unsigned int RAS_TexVert::getUnit() const
-{
- return m_unit;
-}
-
-void RAS_TexVert::Transform(const MT_Matrix4x4& mat, const MT_Matrix4x4& nmat)
-{
- SetXYZ((mat * MT_Vector4(m_localxyz[0], m_localxyz[1], m_localxyz[2], 1.0f)).getValue());
- SetNormal((nmat * MT_Vector4(m_normal[0], m_normal[1], m_normal[2], 1.0f)).getValue());
- SetTangent((nmat * MT_Vector4(m_tangent[0], m_tangent[1], m_tangent[2], 1.0f)).getValue());
-}
-
-void RAS_TexVert::TransformUV(int index, const MT_Matrix4x4& mat)
-{
- SetUV(index, (mat * MT_Vector4(m_uvs[index][0], m_uvs[index][1], 0.0f, 1.0f)).getValue());
-}
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h
deleted file mode 100644
index 8d08549d97e..00000000000
--- a/source/gameengine/Rasterizer/RAS_TexVert.h
+++ /dev/null
@@ -1,146 +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_TexVert.h
- * \ingroup bgerast
- */
-
-#ifndef __RAS_TEXVERT_H__
-#define __RAS_TEXVERT_H__
-
-
-#include "MT_Point3.h"
-#include "MT_Point2.h"
-#include "MT_Transform.h"
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-static MT_Point3 g_pt3;
-static MT_Point2 g_pt2;
-
-class RAS_TexVert
-{
-
- float m_localxyz[3]; // 3*4 = 12
- float m_uvs[8][2]; // 8*2*4=64 //8 = MAX_UNIT
- unsigned int m_rgba; // 4
- float m_tangent[4]; // 4*4 = 16
- float m_normal[3]; // 3*4 = 12
- short m_flag; // 2
- short m_softBodyIndex; //2
- unsigned int m_unit; // 4
- unsigned int m_origindex; // 4
- char m_padding[8]; // 8
- //---------
- // 128
- // 32 bytes alignment improves performance on ATI cards.
-
-public:
- enum {
- FLAT = 1,
- MAX_UNIT = 8
- };
-
- short getFlag() const;
- unsigned int getUnit() const;
-
- RAS_TexVert()// :m_xyz(0,0,0),m_uv(0,0),m_rgba(0)
- {}
- RAS_TexVert(const MT_Point3& xyz,
- const MT_Point2 uvs[MAX_UNIT],
- const MT_Vector4& tangent,
- const unsigned int rgba,
- const MT_Vector3& normal,
- const bool flat,
- const unsigned int origindex);
- ~RAS_TexVert() {};
-
- const float* getUV (int unit) const {
- return m_uvs[unit];
- };
-
- const float* getXYZ() const {
- return m_localxyz;
- };
-
- const float* getNormal() const {
- return m_normal;
- }
-
- short int getSoftBodyIndex() const
- {
- return m_softBodyIndex;
- }
-
- void setSoftBodyIndex(short int sbIndex)
- {
- m_softBodyIndex = sbIndex;
- }
-
- const float* getTangent() const {
- return m_tangent;
- }
-
- const unsigned char* getRGBA() const {
- return (unsigned char *) &m_rgba;
- }
-
- unsigned int getOrigIndex() const {
- return m_origindex;
- }
-
- void SetXYZ(const MT_Point3& xyz);
- void SetXYZ(const float xyz[3]);
- void SetUV(int index, const MT_Point2& uv);
- void SetUV(int index, const float uv[2]);
-
- void SetRGBA(const unsigned int rgba);
- void SetNormal(const MT_Vector3& normal);
- void SetTangent(const MT_Vector3& tangent);
- void SetFlag(const short flag);
- void SetUnit(const unsigned u);
-
- void SetRGBA(const MT_Vector4& rgba);
- const MT_Point3& xyz();
-
- void Transform(const class MT_Matrix4x4& mat,
- const class MT_Matrix4x4& nmat);
- void TransformUV(int index, const MT_Matrix4x4& mat);
-
- // compare two vertices, to test if they can be shared, used for
- // splitting up based on uv's, colors, etc
- bool closeTo(const RAS_TexVert* other);
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_TexVert")
-#endif
-};
-
-#endif /* __RAS_TEXVERT_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_texmatrix.cpp b/source/gameengine/Rasterizer/RAS_texmatrix.cpp
deleted file mode 100644
index d30a3d3a75d..00000000000
--- a/source/gameengine/Rasterizer/RAS_texmatrix.cpp
+++ /dev/null
@@ -1,131 +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_texmatrix.cpp
- * \ingroup bgerast
- */
-
-
-#include "RAS_TexMatrix.h"
-
-void RAS_CalcTexMatrix(RAS_TexVert p[3],MT_Point3& origin,MT_Vector3& udir,MT_Vector3& vdir)
-{
-// precondition: 3 vertices are non-collinear
-
- MT_Vector3 vec1 = p[1].xyz()-p[0].xyz();
- MT_Vector3 vec2 = p[2].xyz()-p[0].xyz();
- MT_Vector3 normal = vec1.cross(vec2);
- normal.normalize();
-
- // determine which coordinate we drop, ie. max coordinate in the normal
-
-
- int ZCOORD = normal.closestAxis();
- int XCOORD = (ZCOORD+1)%3;
- int YCOORD = (ZCOORD+2)%3;
-
- // ax+by+cz+d=0
- MT_Scalar d = -p[0].xyz().dot(normal);
-
-
- MT_Matrix3x3 mat3( p[0].getUV(0)[0],p[0].getUV(0)[1], 1,
- p[1].getUV(0)[0],p[1].getUV(0)[1], 1,
- p[2].getUV(0)[0],p[2].getUV(0)[1], 1);
-
-
- MT_Matrix3x3 mat3inv = mat3.inverse();
-
- MT_Vector3 p123x(p[0].xyz()[XCOORD],p[1].xyz()[XCOORD],p[2].xyz()[XCOORD]);
- MT_Vector3 resultx = mat3inv*p123x;
- MT_Vector3 p123y(p[0].xyz()[YCOORD],p[1].xyz()[YCOORD],p[2].xyz()[YCOORD]);
- MT_Vector3 resulty = mat3inv*p123y;
-
- // normal[ZCOORD] is not zero, because it's chosen to be maximal (absolute), and normal has length 1,
- // so at least on of the coords is <> 0
-
- //droppedvalue udir.dot(normal) =0
- MT_Scalar droppedu = -(resultx.x()*normal[XCOORD]+resulty.x()*normal[YCOORD])/normal[ZCOORD];
- udir[XCOORD] = resultx.x();
- udir[YCOORD] = resulty.x();
- udir[ZCOORD] = droppedu;
- MT_Scalar droppedv = -(resultx.y()*normal[XCOORD]+resulty.y()*normal[YCOORD])/normal[ZCOORD];
- vdir[XCOORD] = resultx.y();
- vdir[YCOORD] = resulty.y();
- vdir[ZCOORD] = droppedv;
- // droppedvalue b = -(ax+cz+d)/y;
- MT_Scalar droppedvalue = -((resultx.z()*normal[XCOORD] + resulty.z()*normal[YCOORD]+d))/normal[ZCOORD];
- origin[XCOORD] = resultx.z();
- origin[YCOORD] = resulty.z();
- origin[ZCOORD] = droppedvalue;
-
-
-}
-
-#ifdef _TEXOWNMAIN
-
-int main()
-{
-
- MT_Point2 puv0={0,0};
- MT_Point3 pxyz0 (0,0,128);
-
- MT_Scalar puv1[2] = {1,0};
- MT_Point3 pxyz1(128,0,128);
-
- MT_Scalar puv2[2] = {1,1};
- MT_Point3 pxyz2(128,0,0);
-
- RAS_TexVert p0(pxyz0,puv0);
- RAS_TexVert p1(pxyz1,puv1);
- RAS_TexVert p2(pxyz2,puv2);
-
- RAS_TexVert vertices[3] =
- {
- p0,
- p1,
- p2
- };
-
- MT_Vector3 udir,vdir;
- MT_Point3 origin;
- CalcTexMatrix(vertices,origin,udir,vdir);
-
- MT_Point3 testpoint(128,32,64);
-
- MT_Scalar lenu = udir.length2();
- MT_Scalar lenv = vdir.length2();
-
- MT_Scalar testu=((pxyz2-origin).dot(udir))/lenu;
- MT_Scalar testv=((pxyz2-origin).dot(vdir))/lenv;
-
-
-
-
- return 0;
-}
-
-#endif // _TEXOWNMAIN
diff --git a/source/gameengine/SceneGraph/CMakeLists.txt b/source/gameengine/SceneGraph/CMakeLists.txt
deleted file mode 100644
index bbad429bbcd..00000000000
--- a/source/gameengine/SceneGraph/CMakeLists.txt
+++ /dev/null
@@ -1,53 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
-)
-
-set(INC_SYS
- ../../../intern/moto/include
-)
-
-set(SRC
- SG_BBox.cpp
- SG_Controller.cpp
- SG_IObject.cpp
- SG_Node.cpp
- SG_Spatial.cpp
- SG_Tree.cpp
-
- SG_BBox.h
- SG_Controller.h
- SG_DList.h
- SG_IObject.h
- SG_Node.h
- SG_ParentRelation.h
- SG_QList.h
- SG_Spatial.h
- SG_Tree.h
-)
-
-blender_add_lib(ge_scenegraph "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/SceneGraph/SG_BBox.cpp b/source/gameengine/SceneGraph/SG_BBox.cpp
deleted file mode 100644
index f9d83d37384..00000000000
--- a/source/gameengine/SceneGraph/SG_BBox.cpp
+++ /dev/null
@@ -1,262 +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 *****
- * Bounding Box
- */
-
-/** \file gameengine/SceneGraph/SG_BBox.cpp
- * \ingroup bgesg
- */
-
-
-#include <math.h>
-
-#include "SG_BBox.h"
-#include "SG_Node.h"
-
-SG_BBox::SG_BBox() :
- m_min(0.0f, 0.0f, 0.0f),
- m_max(0.0f, 0.0f, 0.0f)
-{
-}
-
-SG_BBox::SG_BBox(const MT_Point3 &min, const MT_Point3 &max) :
- m_min(min),
- m_max(max)
-{
-}
-
-SG_BBox::SG_BBox(const SG_BBox &other, const MT_Transform &world) :
- m_min(world(other.m_min)),
- m_max(world(other.m_max))
-{
- *this += world(MT_Point3(m_min[0], m_min[1], m_max[2]));
- *this += world(MT_Point3(m_min[0], m_max[1], m_min[2]));
- *this += world(MT_Point3(m_min[0], m_max[1], m_max[2]));
- *this += world(MT_Point3(m_max[0], m_min[1], m_min[2]));
- *this += world(MT_Point3(m_max[0], m_min[1], m_max[2]));
- *this += world(MT_Point3(m_max[0], m_max[1], m_min[2]));
-}
-
-SG_BBox::SG_BBox(const SG_BBox &other) :
- m_min(other.m_min),
- m_max(other.m_max)
-{
-}
-
-SG_BBox::~ SG_BBox()
-{
-}
-
-SG_BBox& SG_BBox::operator +=(const MT_Point3 &point)
-{
- if (point[0] < m_min[0])
- m_min[0] = point[0];
- else if (point[0] > m_max[0])
- m_max[0] = point[0];
-
- if (point[1] < m_min[1])
- m_min[1] = point[1];
- else if (point[1] > m_max[1])
- m_max[1] = point[1];
-
- if (point[2] < m_min[2])
- m_min[2] = point[2];
- else if (point[2] > m_max[2])
- m_max[2] = point[2];
-
- return *this;
-}
-
-SG_BBox& SG_BBox::operator += (const SG_BBox &bbox)
-{
- *this += bbox.m_min;
- *this += bbox.m_max;
-
- return *this;
-}
-
-SG_BBox SG_BBox::operator +(const SG_BBox &bbox2) const
-{
- SG_BBox ret = *this;
- ret += bbox2;
- return ret;
-}
-
-MT_Scalar SG_BBox::volume() const
-{
- MT_Vector3 size = m_max - m_min;
- return size[0]*size[1]*size[2];
-}
-#if 0
-void SG_BBox::translate(const MT_Vector3& dx)
-{
- m_min += dx;
- m_max += dx;
-}
-
-void SG_BBox::scale(const MT_Vector3& size, const MT_Point3& point)
-{
- MT_Vector3 center = (m_max - m_min)/2. + point;
- m_max = (m_max - center)*size;
- m_min = (m_min - center)*size;
-}
-#endif
-
-SG_BBox SG_BBox::transform(const MT_Transform &world) const
-{
- SG_BBox bbox(world(m_min), world(m_max));
- bbox += world(MT_Point3(m_min[0], m_min[1], m_max[2]));
- bbox += world(MT_Point3(m_min[0], m_max[1], m_min[2]));
- bbox += world(MT_Point3(m_min[0], m_max[1], m_max[2]));
- bbox += world(MT_Point3(m_max[0], m_min[1], m_min[2]));
- bbox += world(MT_Point3(m_max[0], m_min[1], m_max[2]));
- bbox += world(MT_Point3(m_max[0], m_max[1], m_min[2]));
- return bbox;
-}
-
-bool SG_BBox::inside(const MT_Point3 &point) const
-{
- return point[0] >= m_min[0] && point[0] <= m_max[0] &&
- point[1] >= m_min[1] && point[1] <= m_max[1] &&
- point[2] >= m_min[2] && point[2] <= m_max[2];
-}
-
-bool SG_BBox::inside(const SG_BBox& other) const
-{
- return inside(other.m_min) && inside(other.m_max);
-}
-
-bool SG_BBox::intersects(const SG_BBox& other) const
-{
- return inside(other.m_min) != inside(other.m_max);
-}
-
-bool SG_BBox::outside(const SG_BBox& other) const
-{
- return !inside(other.m_min) && !inside(other.m_max);
-}
-
-SG_BBox::intersect SG_BBox::test(const SG_BBox& other) const
-{
- bool point1(inside(other.m_min)), point2(inside(other.m_max));
-
- return point1?(point2?INSIDE:INTERSECT):(point2?INTERSECT:OUTSIDE);
-}
-
-void SG_BBox::get(MT_Point3 *box, const MT_Transform &world) const
-{
- *box++ = world(m_min);
- *box++ = world(MT_Point3(m_min[0], m_min[1], m_max[2]));
- *box++ = world(MT_Point3(m_min[0], m_max[1], m_min[2]));
- *box++ = world(MT_Point3(m_min[0], m_max[1], m_max[2]));
- *box++ = world(MT_Point3(m_max[0], m_min[1], m_min[2]));
- *box++ = world(MT_Point3(m_max[0], m_min[1], m_max[2]));
- *box++ = world(MT_Point3(m_max[0], m_max[1], m_min[2]));
- *box++ = world(m_max);
-}
-
-void SG_BBox::getaa(MT_Point3 *box, const MT_Transform &world) const
-{
- const MT_Point3 min(world(m_min)), max(world(m_max));
- *box++ = min;
- *box++ = MT_Point3(min[0], min[1], max[2]);
- *box++ = MT_Point3(min[0], max[1], min[2]);
- *box++ = MT_Point3(min[0], max[1], max[2]);
- *box++ = MT_Point3(max[0], min[1], min[2]);
- *box++ = MT_Point3(max[0], min[1], max[2]);
- *box++ = MT_Point3(max[0], max[1], min[2]);
- *box++ = max;
-}
-
-void SG_BBox::getmm(MT_Point3 *box, const MT_Transform &world) const
-{
- const MT_Point3 min(world(m_min)), max(world(m_max));
- *box++ = min;
- *box++ = max;
-}
-
-void SG_BBox::split(SG_BBox &left, SG_BBox &right) const
-{
- MT_Scalar sizex = m_max[0] - m_min[0];
- MT_Scalar sizey = m_max[1] - m_min[1];
- MT_Scalar sizez = m_max[2] - m_min[2];
- if (sizex < sizey)
- {
- if (sizey > sizez)
- {
- left.m_min = m_min;
- left.m_max[0] = m_max[0];
- left.m_max[1] = m_min[1] + sizey/2.0f;
- left.m_max[2] = m_max[2];
-
- right.m_min[0] = m_min[0];
- right.m_min[1] = m_min[1] + sizey/2.0f;
- right.m_min[2] = m_min[2];
- right.m_max = m_max;
- std::cout << "splity" << std::endl;
- }
- else {
- left.m_min = m_min;
- left.m_max[0] = m_max[0];
- left.m_max[1] = m_max[1];
- left.m_max[2] = m_min[2] + sizez/2.0f;
-
- right.m_min[0] = m_min[0];
- right.m_min[1] = m_min[1];
- right.m_min[2] = m_min[2] + sizez/2.0f;
- right.m_max = m_max;
- std::cout << "splitz" << std::endl;
- }
- }
- else {
- if (sizex > sizez) {
- left.m_min = m_min;
- left.m_max[0] = m_min[0] + sizex/2.0f;
- left.m_max[1] = m_max[1];
- left.m_max[2] = m_max[2];
-
- right.m_min[0] = m_min[0] + sizex/2.0f;
- right.m_min[1] = m_min[1];
- right.m_min[2] = m_min[2];
- right.m_max = m_max;
- std::cout << "splitx" << std::endl;
- }
- else {
- left.m_min = m_min;
- left.m_max[0] = m_max[0];
- left.m_max[1] = m_max[1];
- left.m_max[2] = m_min[2] + sizez/2.0f;
-
- right.m_min[0] = m_min[0];
- right.m_min[1] = m_min[1];
- right.m_min[2] = m_min[2] + sizez/2.0f;
- right.m_max = m_max;
- std::cout << "splitz" << std::endl;
- }
- }
-
- //std::cout << "Left: " << left.m_min << " -> " << left.m_max << " Right: " << right.m_min << " -> " << right.m_max << std::endl;
-}
diff --git a/source/gameengine/SceneGraph/SG_BBox.h b/source/gameengine/SceneGraph/SG_BBox.h
deleted file mode 100644
index 3c524dc7f18..00000000000
--- a/source/gameengine/SceneGraph/SG_BBox.h
+++ /dev/null
@@ -1,143 +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 SG_BBox.h
- * \ingroup bgesg
- * \brief Bounding Box
- */
-
-#ifndef __SG_BBOX_H__
-#define __SG_BBOX_H__
-
-#include "MT_Scalar.h"
-#include "MT_Point3.h"
-#include "MT_Vector3.h"
-#include "MT_Transform.h"
-
-#include <vector>
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-class SG_Node;
-
-/**
- * Bounding box class.
- * Holds the minimum and maximum axis aligned points of a node's bounding box,
- * in world coordinates.
- */
-class SG_BBox
-{
- MT_Point3 m_min;
- MT_Point3 m_max;
-public:
- typedef enum { INSIDE, INTERSECT, OUTSIDE } intersect;
- SG_BBox();
- SG_BBox(const MT_Point3 &min, const MT_Point3 &max);
- SG_BBox(const SG_BBox &other, const MT_Transform &world);
- SG_BBox(const SG_BBox &other);
- ~SG_BBox();
-
- /**
- * Enlarges the bounding box to contain the specified point.
- */
- SG_BBox& operator +=(const MT_Point3 &point);
- /**
- * Enlarges the bounding box to contain the specified bound box.
- */
- SG_BBox& operator +=(const SG_BBox &bbox);
-
- SG_BBox operator + (const SG_BBox &bbox2) const;
-#if 0
- /**
- * Translates the bounding box.
- */
- void translate(const MT_Vector3 &dx);
- /**
- * Scales the bounding box about the optional point.
- */
- void scale(const MT_Vector3 &size, const MT_Point3 &point = MT_Point3(0.0f, 0.0f, 0.0f));
-#endif
- SG_BBox transform(const MT_Transform &world) const;
- /**
- * Computes the volume of the bounding box.
- */
- MT_Scalar volume() const;
-
- /**
- * Test if the given point is inside this bounding box.
- */
- bool inside(const MT_Point3 &point) const;
-
- /**
- * Test if the given bounding box is inside this bounding box.
- */
- bool inside(const SG_BBox &other) const;
-
- /**
- * Test if the given bounding box is outside this bounding box.
- */
- bool outside(const SG_BBox &other) const;
-
- /**
- * Test if the given bounding box intersects this bounding box.
- */
- bool intersects(const SG_BBox &other) const;
-
- /**
- * Test the given bounding box with this bounding box.
- */
- intersect test(const SG_BBox &other) const;
-
- /**
- * Get the eight points that define this bounding box.
- *
- * \param world a world transform to apply to the produced points bounding box.
- */
- void get(MT_Point3 *box, const MT_Transform &world) const;
- /**
- * Get the eight points that define this axis aligned bounding box.
- * This differs from SG_BBox::get() in that the produced box will be world axis aligned.
- * The maximum & minimum local points will be transformed *before* splitting to 8 points.
- * \param world a world transform to be applied.
- */
- void getaa(MT_Point3 *box, const MT_Transform &world) const;
-
- void getmm(MT_Point3 *box, const MT_Transform &world) const;
-
- void split(SG_BBox &left, SG_BBox &right) const;
-
- friend class SG_Tree;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_BBox")
-#endif
-};
-
-#endif /* __SG_BBOX_H__ */
diff --git a/source/gameengine/SceneGraph/SG_Controller.cpp b/source/gameengine/SceneGraph/SG_Controller.cpp
deleted file mode 100644
index 264942415c9..00000000000
--- a/source/gameengine/SceneGraph/SG_Controller.cpp
+++ /dev/null
@@ -1,46 +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/SceneGraph/SG_Controller.cpp
- * \ingroup bgesg
- */
-
-#include "SG_Controller.h"
-
- void
-SG_Controller::
-SetObject(SG_IObject* obj)
-{
- m_pObject = obj; // no checks yet ?
-}
-
- void
-SG_Controller::
-ClearObject(
-) {
- m_pObject = NULL;
-}
diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h
deleted file mode 100644
index a173633e13c..00000000000
--- a/source/gameengine/SceneGraph/SG_Controller.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Implementationclass to derive controllers from
- *
- *
- * ***** 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 SG_Controller.h
- * \ingroup bgesg
- */
-
-#ifndef __SG_CONTROLLER_H__
-#define __SG_CONTROLLER_H__
-
-#include "SG_IObject.h"
-
-/**
- * A scenegraph controller
- */
-class SG_Controller
-{
-public:
- SG_Controller(
- ) :
- m_pObject(NULL) {
- }
-
- virtual
- ~SG_Controller(
- ) {};
-
- virtual
- bool
- Update(
- double time
- )=0;
-
- virtual
- void
- SetObject (
- SG_IObject* object
- );
-
- void
- ClearObject(
- );
-
- virtual
- void
- SetSimulatedTime(
- double time
- )=0;
-
- virtual
- SG_Controller*
- GetReplica(
- class SG_Node* destnode
- )=0;
-
- /**
- * Hacky way of passing options to specific controllers
- * \param option An integer identifying the option.
- * \param value The value of this option.
- * \attention This has been placed here to give sca-elements
- * \attention some control over the controllers. This is
- * \attention necessary because the identity of the controller
- * \attention is lost on the way here.
- */
- virtual
- void
- SetOption(
- int option,
- int value
- )=0;
-
- /**
- * Option-identifiers: SG_CONTR_<controller-type>_<option>.
- * Options only apply to a specific controller type. The
- * semantics are defined by whoever uses the setting.
- */
- enum SG_Controller_option {
- SG_CONTR_NODEF = 0,
- SG_CONTR_IPO_IPO_AS_FORCE,
- SG_CONTR_IPO_IPO_ADD,
- SG_CONTR_IPO_LOCAL,
- SG_CONTR_IPO_RESET,
- SG_CONTR_CAMIPO_LENS,
- SG_CONTR_CAMIPO_CLIPEND,
- SG_CONTR_CAMIPO_CLIPSTART,
- SG_CONTR_MAX
- };
-
-protected:
- SG_IObject* m_pObject;
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_Controller")
-#endif
-};
-
-#endif /* __SG_CONTROLLER_H__ */
diff --git a/source/gameengine/SceneGraph/SG_DList.h b/source/gameengine/SceneGraph/SG_DList.h
deleted file mode 100644
index 90153f14c07..00000000000
--- a/source/gameengine/SceneGraph/SG_DList.h
+++ /dev/null
@@ -1,251 +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 SG_DList.h
- * \ingroup bgesg
- */
-
-#ifndef __SG_DLIST_H__
-#define __SG_DLIST_H__
-
-#include <stdlib.h>
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
-#endif
-
-/**
- * Double circular linked list
- */
-class SG_DList
-{
-protected :
- SG_DList* m_flink;
- SG_DList* m_blink;
-
-public:
- template<typename T> class iterator
- {
- private:
- SG_DList& m_head;
- T* m_current;
- public:
- typedef iterator<T> _myT;
- iterator(SG_DList& head) : m_head(head), m_current(NULL) {}
- ~iterator() {}
-
- void begin()
- {
- m_current = (T*)m_head.Peek();
- }
- void back()
- {
- m_current = (T*)m_head.Back();
- }
- bool end()
- {
- return (m_current == (T*)m_head.Self());
- }
- bool add_back(T* item)
- {
- return m_current->AddBack(item);
- }
- T* operator*()
- {
- return m_current;
- }
- _myT& operator++()
- {
- // no check of NULL! make sure you don't try to increment beyond end
- m_current = (T*)m_current->Peek();
- return *this;
- }
- _myT& operator--()
- {
- // no check of NULL! make sure you don't try to increment beyond end
- m_current = (T*)m_current->Back();
- return *this;
- }
- };
-
- template<typename T> class const_iterator
- {
- private:
- const SG_DList& m_head;
- const T* m_current;
- public:
- typedef const_iterator<T> _myT;
- const_iterator(const SG_DList& head) : m_head(head), m_current(NULL) {}
- ~const_iterator() {}
-
- void begin()
- {
- m_current = (const T*)m_head.Peek();
- }
- void back()
- {
- m_current = (const T*)m_head.Back();
- }
- bool end()
- {
- return (m_current == (const T*)m_head.Self());
- }
- const T* operator*()
- {
- return m_current;
- }
- _myT& operator++()
- {
- // no check of NULL! make sure you don't try to increment beyond end
- m_current = (const T*)m_current->Peek();
- return *this;
- }
- _myT& operator--()
- {
- // no check of NULL! make sure you don't try to increment beyond end
- m_current = (const T*)m_current->Back();
- return *this;
- }
- };
-
- SG_DList()
- {
- m_flink = m_blink = this;
- }
- SG_DList(const SG_DList& other)
- {
- m_flink = m_blink = this;
- }
- virtual ~SG_DList()
- {
- Delink();
- }
-
- inline bool Empty() // Check for empty queue
- {
- return ( m_flink == this );
- }
- bool AddBack( SG_DList *item ) // Add to the back
- {
- if (!item->Empty())
- return false;
- item->m_blink = m_blink;
- item->m_flink = this;
- m_blink->m_flink = item;
- m_blink = item;
- return true;
- }
- bool AddFront( SG_DList *item ) // Add to the back
- {
- if (!item->Empty())
- return false;
- item->m_flink = m_flink;
- item->m_blink = this;
- m_flink->m_blink = item;
- m_flink = item;
- return true;
- }
- SG_DList *Remove() // Remove from the front
- {
- if (Empty())
- {
- return NULL;
- }
- SG_DList* item = m_flink;
- m_flink = item->m_flink;
- m_flink->m_blink = this;
- item->m_flink = item->m_blink = item;
- return item;
- }
- bool Delink() // Remove from the middle
- {
- if (Empty())
- return false;
- m_blink->m_flink = m_flink;
- m_flink->m_blink = m_blink;
- m_flink = m_blink = this;
- return true;
- }
- inline SG_DList *Peek() // Look at front without removing
- {
- return m_flink;
- }
- inline SG_DList *Back() // Look at front without removing
- {
- return m_blink;
- }
- inline SG_DList *Self()
- {
- return this;
- }
- inline const SG_DList *Peek() const // Look at front without removing
- {
- return (const SG_DList*)m_flink;
- }
- inline const SG_DList *Back() const // Look at front without removing
- {
- return (const SG_DList*)m_blink;
- }
- inline const SG_DList *Self() const
- {
- return this;
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_DList")
-#endif
-};
-
-/**
- * SG_DListHead : Template class that implements copy constructor to duplicate list automatically
- * The elements of the list must have themselves a copy constructor.
- */
-template<typename T> class SG_DListHead : public SG_DList
-{
-public:
- typedef SG_DListHead<T> _myT;
- SG_DListHead() : SG_DList() {}
- SG_DListHead(const _myT& other) : SG_DList()
- {
- // copy the list, assuming objects of type T
- const_iterator<T> eit(other);
- T* elem;
- for (eit.begin(); !eit.end(); ++eit) {
- elem = (*eit)->GetReplica();
- AddBack(elem);
- }
- }
- virtual ~SG_DListHead() {}
- T* Remove()
- {
- return static_cast<T*>(SG_DList::Remove());
- }
-
-};
-
-#endif /* __SG_DLIST_H__ */
diff --git a/source/gameengine/SceneGraph/SG_IObject.cpp b/source/gameengine/SceneGraph/SG_IObject.cpp
deleted file mode 100644
index 9ae32a89ff8..00000000000
--- a/source/gameengine/SceneGraph/SG_IObject.cpp
+++ /dev/null
@@ -1,111 +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/SceneGraph/SG_IObject.cpp
- * \ingroup bgesg
- */
-
-
-#include "SG_IObject.h"
-#include "SG_Controller.h"
-
-#include <algorithm>
-
-SG_Stage gSG_Stage = SG_STAGE_UNKNOWN;
-
-SG_IObject::
-SG_IObject(
- void* clientobj,
- void* clientinfo,
- SG_Callbacks& callbacks
-):
- SG_QList(),
- m_SGclientObject(clientobj),
- m_SGclientInfo(clientinfo)
-{
- m_callbacks = callbacks;
-}
-
-SG_IObject::
-SG_IObject(
- const SG_IObject &other
-) :
- SG_QList(),
- m_SGclientObject(other.m_SGclientObject),
- m_SGclientInfo(other.m_SGclientInfo),
- m_callbacks(other.m_callbacks)
-{
- //nothing to do
-}
-
- void
-SG_IObject::
-AddSGController(
- SG_Controller* cont
-) {
- m_SGcontrollers.push_back(cont);
-}
-
- void
-SG_IObject::
-RemoveSGController(
- SG_Controller* cont
-) {
- SGControllerList::iterator contit;
-
- m_SGcontrollers.erase(std::remove(m_SGcontrollers.begin(), m_SGcontrollers.end(), cont));
-}
-
- void
-SG_IObject::
-RemoveAllControllers(
-) {
- m_SGcontrollers.clear();
-}
-
-void SG_IObject::SetControllerTime(double time)
-{
- SGControllerList::iterator contit;
- for (contit = m_SGcontrollers.begin();contit!=m_SGcontrollers.end();++contit)
- {
- (*contit)->SetSimulatedTime(time);
- }
-}
-
-/// Needed for replication
-
-
-SG_IObject::
-~SG_IObject()
-{
- SGControllerList::iterator contit;
-
- for (contit = m_SGcontrollers.begin();contit!=m_SGcontrollers.end();++contit)
- {
- delete (*contit);
- }
-}
diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h
deleted file mode 100644
index 2dcf3c6492e..00000000000
--- a/source/gameengine/SceneGraph/SG_IObject.h
+++ /dev/null
@@ -1,374 +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 SG_IObject.h
- * \ingroup bgesg
- */
-
-#ifndef __SG_IOBJECT_H__
-#define __SG_IOBJECT_H__
-
-#include "SG_QList.h"
-#include <vector>
-
-// used for debugging: stage of the game engine main loop at which a Scenegraph modification is done
-enum SG_Stage
-{
- SG_STAGE_UNKNOWN = 0,
- SG_STAGE_NETWORK,
- SG_STAGE_NETWORK_UPDATE,
- SG_STAGE_PHYSICS1,
- SG_STAGE_PHYSICS1_UPDATE,
- SG_STAGE_CONTROLLER,
- SG_STAGE_CONTROLLER_UPDATE,
- SG_STAGE_ACTUATOR,
- SG_STAGE_ACTUATOR_UPDATE,
- SG_STAGE_ANIMATION_UPDATE,
- SG_STAGE_PHYSICS2,
- SG_STAGE_PHYSICS2_UPDATE,
- SG_STAGE_SCENE,
- SG_STAGE_RENDER,
- SG_STAGE_CONVERTER,
- SG_STAGE_CULLING,
- SG_STAGE_MAX
-};
-
-extern SG_Stage gSG_Stage;
-
-inline void SG_SetActiveStage(SG_Stage stage)
-{
- gSG_Stage = stage;
-}
-
-
-
-class SG_Controller;
-class SG_IObject;
-
-typedef std::vector<SG_Controller*> SGControllerList;
-
-typedef void* (*SG_ReplicationNewCallback)(
- SG_IObject* sgobject,
- void* clientobj,
- void* clientinfo
-);
-
-typedef void* (*SG_DestructionNewCallback)(
- SG_IObject* sgobject,
- void* clientobj,
- void* clientinfo
-);
-
-typedef void (*SG_UpdateTransformCallback)(
- SG_IObject* sgobject,
- void* clientobj,
- void* clientinfo
-);
-
-typedef bool (*SG_ScheduleUpdateCallback)(
- SG_IObject* sgobject,
- void* clientobj,
- void* clientinfo
-);
-
-typedef bool (*SG_RescheduleUpdateCallback)(
- SG_IObject* sgobject,
- void* clientobj,
- void* clientinfo
-);
-
-
-/**
- * SG_Callbacks hold 2 call backs to the outside world.
- * The first is meant to be called when objects are replicated.
- * And allows the outside world to synchronize external objects
- * with replicated nodes and their children.
- * The second is called when a node is destroyed and again
- * is their for synchronization purposes
- * These callbacks may both be NULL.
- * The efficacy of this approach has not been proved some
- * alternatives might be to perform all replication and destruction
- * externally.
- * To define a class interface rather than a simple function
- * call back so that replication information can be transmitted from
- * parent->child.
- */
-struct SG_Callbacks
-{
- SG_Callbacks(
- ):
- m_replicafunc(NULL),
- m_destructionfunc(NULL),
- m_updatefunc(NULL),
- m_schedulefunc(NULL),
- m_reschedulefunc(NULL)
- {
- }
-
- SG_Callbacks(
- SG_ReplicationNewCallback repfunc,
- SG_DestructionNewCallback destructfunc,
- SG_UpdateTransformCallback updatefunc,
- SG_ScheduleUpdateCallback schedulefunc,
- SG_RescheduleUpdateCallback reschedulefunc
- ):
- m_replicafunc(repfunc),
- m_destructionfunc(destructfunc),
- m_updatefunc(updatefunc),
- m_schedulefunc(schedulefunc),
- m_reschedulefunc(reschedulefunc)
- {
- }
-
- SG_ReplicationNewCallback m_replicafunc;
- SG_DestructionNewCallback m_destructionfunc;
- SG_UpdateTransformCallback m_updatefunc;
- SG_ScheduleUpdateCallback m_schedulefunc;
- SG_RescheduleUpdateCallback m_reschedulefunc;
-};
-
-/**
- * base object that can be part of the scenegraph.
- */
-class SG_IObject : public SG_QList
-{
-private :
-
- void* m_SGclientObject;
- void* m_SGclientInfo;
- SG_Callbacks m_callbacks;
- SGControllerList m_SGcontrollers;
-
-public:
- virtual ~SG_IObject();
-
-
- /**
- * Add a pointer to a controller allocated on the heap, to
- * this node. This memory for this controller becomes the
- * responsibility of this class. It will be deleted when
- * this object is deleted.
- */
-
- void
- AddSGController(
- SG_Controller* cont
- );
-
- /**
- * Remove a pointer to a controller from this node.
- * This does not delete the controller itself! Be careful to
- * avoid memory leaks.
- */
- void
- RemoveSGController(
- SG_Controller* cont
- );
-
- /**
- * Clear the array of pointers to controllers associated with
- * this node. This does not delete the controllers themselves!
- * This should be used very carefully to avoid memory
- * leaks.
- */
-
- void
- RemoveAllControllers(
- );
-
- /// Needed for replication
-
- /**
- * Return a reference to this node's controller list.
- * Whilst we don't wish to expose full control of the container
- * to the user we do allow them to call non_const methods
- * on pointers in the container. C++ topic: how to do this in
- * using STL?
- */
-
- SGControllerList& GetSGControllerList()
- {
- return m_SGcontrollers;
- }
-
- /**
- *
- */
- SG_Callbacks& GetCallBackFunctions()
- {
- return m_callbacks;
- }
-
- /**
- * Get the client object associated with this
- * node. This interface allows you to associate
- * arbitrary external objects with this node. They are
- * passed to the callback functions when they are
- * activated so you can synchronize these external objects
- * upon replication and destruction
- * This may be NULL.
- */
-
- inline const void* GetSGClientObject() const
- {
- return m_SGclientObject;
- }
-
- inline void* GetSGClientObject()
- {
- return m_SGclientObject;
- }
-
- /**
- * Set the client object for this node. This is just a
- * pointer to an object allocated that should exist for
- * the duration of the lifetime of this object, or until
- * this function is called again.
- */
-
- void SetSGClientObject(void* clientObject)
- {
- m_SGclientObject = clientObject;
- }
-
-
- /* needed for scene switching */
- inline const void* GetSGClientInfo() const
- {
- return m_SGclientInfo;
- }
- inline void* GetSGClientInfo()
- {
- return m_SGclientInfo;
- }
- void SetSGClientInfo(void* clientInfo)
- {
- m_SGclientInfo = clientInfo;
- }
-
-
- /**
- * Set the current simulation time for this node.
- * The implementation of this function runs through
- * the nodes list of controllers and calls their SetSimulatedTime methods
- */
-
- void SetControllerTime(double time);
-
- virtual
- void
- Destruct(
- ) = 0;
-
-protected :
-
- bool
- ActivateReplicationCallback(
- SG_IObject *replica
- )
- {
- if (m_callbacks.m_replicafunc)
- {
- // Call client provided replication func
- if (m_callbacks.m_replicafunc(replica,m_SGclientObject,m_SGclientInfo) == NULL)
- return false;
- }
- return true;
- }
-
-
- void
- ActivateDestructionCallback(
- )
- {
- if (m_callbacks.m_destructionfunc)
- {
- // Call client provided destruction function on this!
- m_callbacks.m_destructionfunc(this,m_SGclientObject,m_SGclientInfo);
- }
- else
- {
- // no callback but must still destroy the node to avoid memory leak
- delete this;
- }
- }
-
- void
- ActivateUpdateTransformCallback(
- )
- {
- if (m_callbacks.m_updatefunc)
- {
- // Call client provided update func.
- m_callbacks.m_updatefunc(this, m_SGclientObject, m_SGclientInfo);
- }
- }
-
- bool
- ActivateScheduleUpdateCallback(
- )
- {
- // HACK, this check assumes that the scheduled nodes are put on a DList (see SG_Node.h)
- // The early check on Empty() allows up to avoid calling the callback function
- // when the node is already scheduled for update.
- if (Empty() && m_callbacks.m_schedulefunc)
- {
- // Call client provided update func.
- return m_callbacks.m_schedulefunc(this, m_SGclientObject, m_SGclientInfo);
- }
- return false;
- }
-
- void
- ActivateRecheduleUpdateCallback(
- )
- {
- if (m_callbacks.m_reschedulefunc)
- {
- // Call client provided update func.
- m_callbacks.m_reschedulefunc(this, m_SGclientObject, m_SGclientInfo);
- }
- }
-
-
- SG_IObject(
- void* clientobj,
- void* clientinfo,
- SG_Callbacks& callbacks
- );
-
- SG_IObject(
- const SG_IObject &other
- );
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_IObject")
-#endif
-};
-
-#endif /* __SG_IOBJECT_H__ */
diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp
deleted file mode 100644
index 04d9a306fc4..00000000000
--- a/source/gameengine/SceneGraph/SG_Node.cpp
+++ /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 gameengine/SceneGraph/SG_Node.cpp
- * \ingroup bgesg
- */
-
-
-#include "SG_Node.h"
-#include "SG_ParentRelation.h"
-#include <algorithm>
-
-using namespace std;
-
-
-SG_Node::SG_Node(
- void* clientobj,
- void* clientinfo,
- SG_Callbacks& callbacks
-
-)
- : SG_Spatial(clientobj,clientinfo,callbacks),
- m_SGparent(NULL)
-{
- m_modified = true;
-}
-
-SG_Node::SG_Node(
- const SG_Node & other
-) :
- SG_Spatial(other),
- m_children(other.m_children),
- m_SGparent(other.m_SGparent)
-{
- m_modified = true;
-}
-
-SG_Node::~SG_Node()
-{
-}
-
-
-SG_Node* SG_Node::GetSGReplica()
-{
- SG_Node* replica = new SG_Node(*this);
- if (replica == NULL) return NULL;
-
- ProcessSGReplica(&replica);
-
- return replica;
-}
-
- void
-SG_Node::
-ProcessSGReplica(
- SG_Node** replica
-) {
- // Apply the replication call back function.
- if (!ActivateReplicationCallback(*replica))
- {
- delete (*replica);
- *replica = NULL;
- return;
- }
-
- // clear the replica node of it's parent.
- static_cast<SG_Node*>(*replica)->m_SGparent = NULL;
-
- if (m_children.begin() != m_children.end())
- {
- // if this node has children, the replica has too, so clear and clone children
- (*replica)->ClearSGChildren();
-
- NodeList::iterator childit;
- for (childit = m_children.begin();childit!=m_children.end();++childit)
- {
- SG_Node* childnode = (*childit)->GetSGReplica();
- if (childnode)
- (*replica)->AddChild(childnode);
- }
- }
- // Nodes without children and without client object are
- // not worth to keep, they will just take up CPU
- // This can happen in partial replication of hierarchy
- // during group duplication.
- if ((*replica)->m_children.empty() &&
- (*replica)->GetSGClientObject() == NULL)
- {
- delete (*replica);
- *replica = NULL;
- }
-}
-
-
- void
-SG_Node::
-Destruct()
-{
- // Not entirely sure what Destruct() expects to happen.
- // I think it probably means just to call the DestructionCallback
- // in the right order on all the children - rather than free any memory
-
- // We'll delete m_parent_relation now anyway.
-
- delete(m_parent_relation);
- m_parent_relation = NULL;
-
- if (m_children.begin() != m_children.end())
- {
- NodeList::iterator childit;
- for (childit = m_children.begin();childit!=m_children.end();++childit)
- {
- // call the SG_Node destruct method on each of our children }-)
- (*childit)->Destruct();
- }
- }
-
- ActivateDestructionCallback();
-}
-
-const
- SG_Node *
-SG_Node::
-GetRootSGParent(
-) const {
- return (m_SGparent ? (const SG_Node*) m_SGparent->GetRootSGParent() : (const SG_Node*) this);
-}
-
-bool SG_Node::IsAncessor(const SG_Node* child) const
-{
- return (!child->m_SGparent) ? false :
- (child->m_SGparent == this) ? true : IsAncessor(child->m_SGparent);
-}
-
- void
-SG_Node::
-DisconnectFromParent(
-) {
- if (m_SGparent)
- {
- m_SGparent->RemoveChild(this);
- m_SGparent = NULL;
- }
-
-}
-
-void SG_Node::AddChild(SG_Node* child)
-{
- m_children.push_back(child);
- child->SetSGParent(this); // this way ?
-}
-
-void SG_Node::RemoveChild(SG_Node* child)
-{
- NodeList::iterator childfound = find(m_children.begin(),m_children.end(),child);
-
- if (childfound != m_children.end())
- {
- m_children.erase(childfound);
- }
-}
-
-
-
-void SG_Node::UpdateWorldData(double time, bool parentUpdated)
-{
- //if (!GetSGParent())
- // return;
-
- if (UpdateSpatialData(GetSGParent(),time,parentUpdated))
- // to update the
- ActivateUpdateTransformCallback();
-
- // The node is updated, remove it from the update list
- Delink();
-
- // update children's worlddata
- for (NodeList::iterator it = m_children.begin();it!=m_children.end();++it)
- {
- (*it)->UpdateWorldData(time, parentUpdated);
- }
-}
-
-
-
-void SG_Node::SetSimulatedTime(double time,bool recurse)
-{
-
- // update the controllers of this node.
- SetControllerTime(time);
-
- // update children's simulate time.
- if (recurse)
- {
- for (NodeList::iterator it = m_children.begin();it!=m_children.end();++it)
- {
- (*it)->SetSimulatedTime(time,recurse);
- }
- }
-}
-
-
-
diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h
deleted file mode 100644
index bde64f21305..00000000000
--- a/source/gameengine/SceneGraph/SG_Node.h
+++ /dev/null
@@ -1,278 +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 SG_Node.h
- * \ingroup bgesg
- */
-
-#ifndef __SG_NODE_H__
-#define __SG_NODE_H__
-
-#include "SG_Spatial.h"
-#include <vector>
-
-typedef std::vector<SG_Node*> NodeList;
-
-/**
- * Scenegraph node.
- */
-class SG_Node : public SG_Spatial
-{
-public:
- SG_Node(
- void* clientobj,
- void* clientinfo,
- SG_Callbacks& callbacks
- );
-
- SG_Node(
- const SG_Node & other
- );
-
- virtual ~SG_Node();
-
-
- /**
- * Add a child to this object. This also informs the child of
- * it's parent.
- * This just stores a pointer to the child and does not
- * make a deep copy.
- */
-
- void
- AddChild(
- SG_Node* child
- );
-
- /**
- * Remove a child node from this object. This just removes the child
- * pointer from the list of children - it does not destroy the child.
- * This does not inform the child that this node is no longer it's parent.
- * If the node was not a child of this object no action is performed.
- */
-
- void
- RemoveChild(
- SG_Node* child
- );
-
- /**
- * Return true if the node is the ancestor of child
- */
- bool
- IsAncessor(
- const SG_Node* child
- ) const;
- /**
- * Get the current list of children. Do not use this interface for
- * adding or removing children please use the methods of this class for
- * that.
- * \return a reference to the list of children of this node.
- */
-
- NodeList& GetSGChildren()
- {
- return this->m_children;
- }
-
- /**
- * Get the current list of children.
- * \return a const reference to the current list of children of this node.
- */
-
- const NodeList& GetSGChildren() const
- {
- return this->m_children;
- }
-
- /**
- * Clear the list of children associated with this node
- */
-
- void ClearSGChildren()
- {
- m_children.clear();
- }
-
- /**
- * return the parent of this node if it exists.
- */
-
- SG_Node* GetSGParent() const
- {
- return m_SGparent;
- }
-
- /**
- * Set the parent of this node.
- */
-
- void SetSGParent(SG_Node* parent)
- {
- m_SGparent = parent;
- }
-
- /**
- * Return the top node in this node's Scene graph hierarchy
- */
-
- const
- SG_Node*
- GetRootSGParent(
- ) const;
-
- /**
- * Disconnect this node from it's parent
- */
-
- void
- DisconnectFromParent(
- );
-
- /**
- * Return vertex parent status.
- */
- bool IsVertexParent()
- {
- if (m_parent_relation)
- {
- return m_parent_relation->IsVertexRelation();
- }
- return false;
- }
-
-
- /**
- * Return slow parent status.
- */
-
- bool IsSlowParent()
- {
- if (m_parent_relation)
- {
- return m_parent_relation->IsSlowRelation();
- }
- return false;
- }
-
-
-
-
- /**
- * Update the spatial data of this node. Iterate through
- * the children of this node and update their world data.
- */
-
- void
- UpdateWorldData(
- double time,
- bool parentUpdated=false
- );
-
- /**
- * Update the simulation time of this node. Iterate through
- * the children nodes and update their simulated time.
- */
-
- void
- SetSimulatedTime(
- double time,
- bool recurse
- );
-
- /**
- * Schedule this node for update by placing it in head queue
- */
- bool Schedule(SG_QList& head)
- {
- // Put top parent in front of list to make sure they are updated before their
- // children => the children will be udpated and removed from the list before
- // we get to them, should they be in the list too.
- return (m_SGparent)?head.AddBack(this):head.AddFront(this);
- }
-
- /**
- * Used during Scenegraph update
- */
- static SG_Node* GetNextScheduled(SG_QList& head)
- {
- return static_cast<SG_Node*>(head.Remove());
- }
-
- /**
- * Make this node ready for schedule on next update. This is needed for nodes
- * that must always be updated (slow parent, bone parent)
- */
- bool Reschedule(SG_QList& head)
- {
- return head.QAddBack(this);
- }
-
- /**
- * Used during Scenegraph update
- */
- static SG_Node* GetNextRescheduled(SG_QList& head)
- {
- return static_cast<SG_Node*>(head.QRemove());
- }
-
- /**
- * Node replication functions.
- */
-
- SG_Node*
- GetSGReplica(
- );
-
- void
- Destruct(
- );
-
-private:
-
- void
- ProcessSGReplica(
- SG_Node** replica
- );
-
- /**
- * The list of children of this node.
- */
- NodeList m_children;
-
- /**
- * The parent of this node may be NULL
- */
- SG_Node* m_SGparent;
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_Node")
-#endif
-};
-
-#endif /* __SG_NODE_H__ */
diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h
deleted file mode 100644
index ce45b42c148..00000000000
--- a/source/gameengine/SceneGraph/SG_ParentRelation.h
+++ /dev/null
@@ -1,139 +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 SG_ParentRelation.h
- * \ingroup bgesg
- * \page SG_ParentRelationPage SG_ParentRelation
- *
- * \section SG_ParentRelationSection SG_ParentRelation
- *
- * This is an abstract interface class to the Scene Graph library.
- * It allows you to specify how child nodes react to parent nodes.
- * Normally a child will use it's parent's transforms to compute
- * it's own global transforms. How this is performed depends on
- * the type of relation. For example if the parent is a vertex
- * parent to this child then the child should not inherit any
- * rotation information from the parent. Or if the parent is a
- * 'slow parent' to this child then the child should react
- * slowly to changes in the parent's position. The exact relation
- * is left for you to implement by filling out this interface
- * with concrete examples.
- *
- * There is exactly one SG_ParentRelation per SG_Node. Subclasses
- * should not be value types and should be allocated on the heap.
- *
- */
-
-#ifndef __SG_PARENTRELATION_H__
-#define __SG_PARENTRELATION_H__
-
-class SG_Spatial;
-
-class SG_ParentRelation {
-
-public :
- /**
- * Update the childs local and global coordinates
- * based upon the parents global coordinates.
- * You must also handle the case when this node has no
- * parent (parent == NULL). Usually you should just
- * copy the local coordinates of the child to the
- * world coordinates.
- */
-
- virtual
- bool
- UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
- ) = 0;
-
- virtual
- ~SG_ParentRelation(
- ) {};
-
- /**
- * You must provide a way of duplicating an
- * instance of an SG_ParentRelation. This should
- * return a pointer to a new duplicate allocated
- * on the heap. Responsibility for deleting the
- * duplicate resides with the caller of this method.
- */
-
- virtual
- SG_ParentRelation *
- NewCopy(
- ) = 0;
-
- /**
- * Vertex Parent Relation are special: they don't propagate rotation
- */
- virtual
- bool
- IsVertexRelation(
- ) {
- return false;
- }
-
- /**
- * Need this to see if we are able to adjust time-offset from the python api
- */
- virtual
- bool
- IsSlowRelation(
- ) {
- return false;
- }
-protected :
-
- /**
- * Protected constructors
- * this class is not meant to be instantiated.
- */
-
- SG_ParentRelation(
- ) {
- };
-
- /**
- * Copy construction should not be implemented
- */
-
- SG_ParentRelation(
- const SG_ParentRelation &
- );
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_ParentRelation")
-#endif
-};
-
-#endif
-
diff --git a/source/gameengine/SceneGraph/SG_QList.h b/source/gameengine/SceneGraph/SG_QList.h
deleted file mode 100644
index 663f29ebd88..00000000000
--- a/source/gameengine/SceneGraph/SG_QList.h
+++ /dev/null
@@ -1,164 +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 SG_QList.h
- * \ingroup bgesg
- */
-
-#ifndef __SG_QLIST_H__
-#define __SG_QLIST_H__
-
-#include "SG_DList.h"
-
-/**
- * Double-Double circular linked list
- * For storing an object is two lists simultaneously
- */
-class SG_QList : public SG_DList
-{
-protected :
- SG_QList* m_fqlink;
- SG_QList* m_bqlink;
-
-public:
- template<typename T> class iterator
- {
- private:
- SG_QList& m_head;
- T* m_current;
- public:
- typedef iterator<T> _myT;
- iterator(SG_QList& head, SG_QList* current=NULL) : m_head(head) { m_current = (T*)current; }
- ~iterator() {}
-
- void begin()
- {
- m_current = (T*)m_head.QPeek();
- }
- void back()
- {
- m_current = (T*)m_head.QBack();
- }
- bool end()
- {
- return (m_current == (T*)m_head.Self());
- }
- bool add_back(T* item)
- {
- return m_current->QAddBack(item);
- }
- T* operator*()
- {
- return m_current;
- }
- _myT& operator++()
- {
- m_current = (T*)m_current->QPeek();
- return *this;
- }
- _myT& operator--()
- {
- // no check on NULL! make sure you don't try to increment beyond end
- m_current = (T*)m_current->QBack();
- return *this;
- }
- };
-
- SG_QList() : SG_DList()
- {
- m_fqlink = m_bqlink = this;
- }
- SG_QList(const SG_QList& other) : SG_DList()
- {
- m_fqlink = m_bqlink = this;
- }
- virtual ~SG_QList()
- {
- QDelink();
- }
-
- inline bool QEmpty() // Check for empty queue
- {
- return ( m_fqlink == this );
- }
- bool QAddBack( SG_QList *item ) // Add to the back
- {
- if (!item->QEmpty())
- return false;
- item->m_bqlink = m_bqlink;
- item->m_fqlink = this;
- m_bqlink->m_fqlink = item;
- m_bqlink = item;
- return true;
- }
- bool QAddFront( SG_QList *item ) // Add to the back
- {
- if (!item->Empty())
- return false;
- item->m_fqlink = m_fqlink;
- item->m_bqlink = this;
- m_fqlink->m_bqlink = item;
- m_fqlink = item;
- return true;
- }
- SG_QList *QRemove() // Remove from the front
- {
- if (QEmpty())
- {
- return NULL;
- }
- SG_QList* item = m_fqlink;
- m_fqlink = item->m_fqlink;
- m_fqlink->m_bqlink = this;
- item->m_fqlink = item->m_bqlink = item;
- return item;
- }
- bool QDelink() // Remove from the middle
- {
- if (QEmpty())
- return false;
- m_bqlink->m_fqlink = m_fqlink;
- m_fqlink->m_bqlink = m_bqlink;
- m_fqlink = m_bqlink = this;
- return true;
- }
- inline SG_QList *QPeek() // Look at front without removing
- {
- return m_fqlink;
- }
- inline SG_QList *QBack() // Look at front without removing
- {
- return m_bqlink;
- }
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_QList")
-#endif
-};
-
-#endif /* __SG_QLIST_H__ */
diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp
deleted file mode 100644
index 5cb75873237..00000000000
--- a/source/gameengine/SceneGraph/SG_Spatial.cpp
+++ /dev/null
@@ -1,217 +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/SceneGraph/SG_Spatial.cpp
- * \ingroup bgesg
- */
-
-
-#include "SG_Node.h"
-#include "SG_Spatial.h"
-#include "SG_Controller.h"
-#include "SG_ParentRelation.h"
-
-SG_Spatial::
-SG_Spatial(
- void* clientobj,
- void* clientinfo,
- SG_Callbacks& callbacks
-):
-
- SG_IObject(clientobj,clientinfo,callbacks),
- m_localPosition(0.0f,0.0f,0.0f),
- m_localRotation(1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,1.0f),
- m_localScaling(1.0f,1.0f,1.0f),
-
- m_worldPosition(0.0f,0.0f,0.0f),
- m_worldRotation(1.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,1.0f),
- m_worldScaling(1.0f,1.0f,1.0f),
-
- m_parent_relation (NULL),
-
- m_bbox(MT_Point3(-1.0f, -1.0f, -1.0f), MT_Point3(1.0f, 1.0f, 1.0f)),
- m_radius(1.0f),
- m_modified(false),
- m_ogldirty(false)
-{
-}
-
-SG_Spatial::
-SG_Spatial(
- const SG_Spatial& other
-) :
- SG_IObject(other),
- m_localPosition(other.m_localPosition),
- m_localRotation(other.m_localRotation),
- m_localScaling(other.m_localScaling),
-
- m_worldPosition(other.m_worldPosition),
- m_worldRotation(other.m_worldRotation),
- m_worldScaling(other.m_worldScaling),
-
- m_parent_relation(NULL),
-
- m_bbox(other.m_bbox),
- m_radius(other.m_radius),
- m_modified(false),
- m_ogldirty(false)
-{
- // duplicate the parent relation for this object
- m_parent_relation = other.m_parent_relation->NewCopy();
-}
-
-SG_Spatial::
-~SG_Spatial()
-{
- delete (m_parent_relation);
-}
-
- void
-SG_Spatial::
-SetParentRelation(
- SG_ParentRelation *relation
-) {
- delete (m_parent_relation);
- m_parent_relation = relation;
- SetModified();
-}
-
-
-/**
- * Update Spatial Data.
- * Calculates WorldTransform., (either doing its self or using the linked SGControllers)
- */
-
-
- bool
-SG_Spatial::
-UpdateSpatialData(
- const SG_Spatial *parent,
- double time,
- bool& parentUpdated)
-{
- bool bComputesWorldTransform = false;
-
- // update spatial controllers
-
- SGControllerList::iterator cit = GetSGControllerList().begin();
- SGControllerList::const_iterator c_end = GetSGControllerList().end();
-
- for (;cit!=c_end;++cit)
- {
- if ((*cit)->Update(time))
- bComputesWorldTransform = true;
- }
-
- // If none of the objects updated our values then we ask the
- // parent_relation object owned by this class to update
- // our world coordinates.
-
- if (!bComputesWorldTransform)
- bComputesWorldTransform = ComputeWorldTransforms(parent, parentUpdated);
-
- return bComputesWorldTransform;
-}
-
-/**
- * Position and translation methods
- */
-
-
- void
-SG_Spatial::
-RelativeTranslate(
- const MT_Vector3& trans,
- const SG_Spatial *parent,
- bool local
-) {
- if (local) {
- m_localPosition += m_localRotation * trans;
- }
- else {
- if (parent) {
- m_localPosition += trans * parent->GetWorldOrientation();
- }
- else {
- m_localPosition += trans;
- }
- }
- SetModified();
-}
-
-
-/**
- * Scaling methods.
- */
-
-
-/**
- * Orientation and rotation methods.
- */
-
-
- void
-SG_Spatial::
-RelativeRotate(
- const MT_Matrix3x3& rot,
- bool local
-) {
- m_localRotation = m_localRotation * (
- local ?
- rot
- :
- (GetWorldOrientation().inverse() * rot * GetWorldOrientation()));
- SetModified();
-}
-
-
-
-MT_Transform SG_Spatial::GetWorldTransform() const
-{
- return MT_Transform(m_worldPosition,
- m_worldRotation.scaled(
- m_worldScaling[0], m_worldScaling[1], m_worldScaling[2]));
-}
-
-bool SG_Spatial::inside(const MT_Point3 &point) const
-{
- MT_Scalar radius = m_worldScaling[m_worldScaling.closestAxis()]*m_radius;
- return (m_worldPosition.distance2(point) <= radius*radius) ?
- m_bbox.transform(GetWorldTransform()).inside(point) :
- false;
-}
-
-void SG_Spatial::getBBox(MT_Point3 *box) const
-{
- m_bbox.get(box, GetWorldTransform());
-}
-
-void SG_Spatial::getAABBox(MT_Point3 *box) const
-{
- m_bbox.getaa(box, GetWorldTransform());
-}
-
diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h
deleted file mode 100644
index aa917fa70db..00000000000
--- a/source/gameengine/SceneGraph/SG_Spatial.h
+++ /dev/null
@@ -1,294 +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 SG_Spatial.h
- * \ingroup bgesg
- */
-
-#ifndef __SG_SPATIAL_H__
-#define __SG_SPATIAL_H__
-
-#include <MT_Vector3.h>
-#include <MT_Point3.h>
-#include <MT_Matrix3x3.h> // or Quaternion later ?
-#include "SG_IObject.h"
-#include "SG_BBox.h"
-#include "SG_ParentRelation.h"
-
-
-class SG_Node;
-class SG_ParentRelation;
-
-/**
- * SG_Spatial contains spatial information (local & world position, rotation
- * and scaling) for a Scene graph node.
- * It also contains a link to the node's parent.
- */
-class SG_Spatial : public SG_IObject
-{
-
-protected:
- MT_Point3 m_localPosition;
- MT_Matrix3x3 m_localRotation;
- MT_Vector3 m_localScaling;
-
- MT_Point3 m_worldPosition;
- MT_Matrix3x3 m_worldRotation;
- MT_Vector3 m_worldScaling;
-
- SG_ParentRelation * m_parent_relation;
-
- SG_BBox m_bbox;
- MT_Scalar m_radius;
- bool m_modified;
- bool m_ogldirty; // true if the openGL matrix for this object must be recomputed
-
-public:
- inline void ClearModified()
- {
- m_modified = false;
- m_ogldirty = true;
- }
- inline void SetModified()
- {
- m_modified = true;
- ActivateScheduleUpdateCallback();
- }
- inline void ClearDirty()
- {
- m_ogldirty = false;
- }
- /**
- * Define the relationship this node has with it's parent
- * node. You should pass an unshared instance of an SG_ParentRelation
- * allocated on the heap to this method. Ownership of this
- * instance is assumed by this class.
- * You may call this function several times in the lifetime
- * of a node to change the relationship dynamically.
- * You must call this method before the first call to UpdateSpatialData().
- * An assertion will be fired at run-time in debug if this is not
- * the case.
- * The relation is activated only if no controllers of this object
- * updated the coordinates of the child.
- */
-
- void
- SetParentRelation(
- SG_ParentRelation *relation
- );
-
- SG_ParentRelation * GetParentRelation()
- {
- return m_parent_relation;
- }
-
-
-
-
- /**
- * Apply a translation relative to the current position.
- * if local then the translation is assumed to be in the
- * local coordinates of this object. If not then the translation
- * is assumed to be in global coordinates. In this case
- * you must provide a pointer to the parent of this object if it
- * exists otherwise if there is no parent set it to NULL
- */
-
- void
- RelativeTranslate(
- const MT_Vector3& trans,
- const SG_Spatial *parent,
- bool local
- );
-
- void SetLocalPosition(const MT_Point3& trans)
- {
- m_localPosition = trans;
- SetModified();
- }
-
- void SetWorldPosition(const MT_Point3& trans)
- {
- m_worldPosition = trans;
- }
-
-
- void
- RelativeRotate(
- const MT_Matrix3x3& rot,
- bool local
- );
-
- void SetLocalOrientation(const MT_Matrix3x3& rot)
- {
- m_localRotation = rot;
- SetModified();
- }
-
- // rot is arrange like openGL matrix
- void SetLocalOrientation(const float* rot)
- {
- m_localRotation.setValue(rot);
- SetModified();
- }
-
- void SetWorldOrientation(const MT_Matrix3x3& rot)
- {
- m_worldRotation = rot;
- }
-
- void RelativeScale(const MT_Vector3& scale)
- {
- m_localScaling = m_localScaling * scale;
- SetModified();
- }
-
- void SetLocalScale(const MT_Vector3& scale)
- {
- m_localScaling = scale;
- SetModified();
- }
-
- void SetWorldScale(const MT_Vector3& scale)
- {
- m_worldScaling = scale;
- }
-
- const MT_Point3& GetLocalPosition() const
- {
- return m_localPosition;
- }
-
- const MT_Matrix3x3& GetLocalOrientation() const
- {
- return m_localRotation;
- }
-
- const MT_Vector3& GetLocalScale() const
- {
- return m_localScaling;
- }
-
- const MT_Point3& GetWorldPosition() const
- {
- return m_worldPosition;
- }
-
- const MT_Matrix3x3& GetWorldOrientation() const
- {
- return m_worldRotation;
- }
-
- const MT_Vector3& GetWorldScaling() const
- {
- return m_worldScaling;
- }
-
- void SetWorldFromLocalTransform()
- {
- m_worldPosition= m_localPosition;
- m_worldScaling= m_localScaling;
- m_worldRotation= m_localRotation;
- }
-
-
-
- MT_Transform GetWorldTransform() const;
-
- bool ComputeWorldTransforms(const SG_Spatial *parent, bool& parentUpdated)
- {
- return m_parent_relation->UpdateChildCoordinates(this,parent,parentUpdated);
- }
-
-
- /**
- * Bounding box functions.
- */
- SG_BBox& BBox()
- {
- return m_bbox;
- }
-
- void SetBBox(SG_BBox& bbox)
- {
- m_bbox = bbox;
- }
-
-
- bool inside(const MT_Point3 &point) const;
- void getBBox(MT_Point3 *box) const;
- void getAABBox(MT_Point3 *box) const;
-
- MT_Scalar Radius() const { return m_radius; }
- void SetRadius(MT_Scalar radius) { m_radius = radius; }
- bool IsModified() { return m_modified; }
- bool IsDirty() { return m_ogldirty; }
-
-protected:
- friend class SG_Controller;
- friend class KX_BoneParentRelation;
- friend class KX_VertexParentRelation;
- friend class KX_SlowParentRelation;
- friend class KX_NormalParentRelation;
-
- /**
- * Protected constructor this class is not
- * designed for direct instantiation
- */
-
- SG_Spatial(
- void* clientobj,
- void* clientinfo,
- SG_Callbacks& callbacks
- );
-
- SG_Spatial(
- const SG_Spatial& other
- );
-
-
- virtual ~SG_Spatial();
-
- /**
- * Update the world coordinates of this spatial node. This also informs
- * any controllers to update this object.
- */
-
- bool
- UpdateSpatialData(
- const SG_Spatial *parent,
- double time,
- bool& parentUpdated
- );
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_Spatial")
-#endif
-};
-
-#endif /* __SG_SPATIAL_H__ */
diff --git a/source/gameengine/SceneGraph/SG_Tree.cpp b/source/gameengine/SceneGraph/SG_Tree.cpp
deleted file mode 100644
index 87feb2c012a..00000000000
--- a/source/gameengine/SceneGraph/SG_Tree.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 *****
- * Bounding Box
- */
-
-/** \file gameengine/SceneGraph/SG_Tree.cpp
- * \ingroup bgesg
- */
-
-
-#include <math.h>
-
-#include "SG_BBox.h"
-#include "SG_Tree.h"
-#include "SG_Node.h"
-
-SG_Tree::SG_Tree() :
- m_left(NULL),
- m_right(NULL),
- m_parent(NULL),
- m_radius(0.0f),
- m_client_object(NULL)
-{
-}
-
-SG_Tree::SG_Tree(SG_Tree* left, SG_Tree* right) :
- m_left(left),
- m_right(right),
- m_parent(NULL),
- m_client_object(NULL)
-{
- if (m_left)
- {
- m_bbox = m_left->m_bbox;
- m_left->m_parent = this;
- }
- if (m_right)
- {
- m_bbox += m_right->m_bbox;
- m_right->m_parent = this;
- }
- m_center = (m_bbox.m_min + m_bbox.m_max)/2.0f;
- m_radius = (m_bbox.m_max - m_bbox.m_min).length();
-}
-
-SG_Tree::SG_Tree(SG_Node* client) :
- m_left(NULL),
- m_right(NULL),
- m_parent(NULL),
- m_client_object(client)
-{
- m_bbox = SG_BBox(client->BBox(), client->GetWorldTransform());
- m_center = (m_bbox.m_min + m_bbox.m_max)/2.0f;
- m_radius = (m_bbox.m_max - m_bbox.m_min).length();
-}
-
-SG_Tree::~SG_Tree()
-{
-}
-
-MT_Scalar SG_Tree::volume() const
-{
- return m_bbox.volume();
-}
-
-void SG_Tree::dump() const
-{
- if (m_left)
- m_left->dump();
- if (m_client_object)
- std::cout << m_client_object << std::endl;
- else
- std::cout << this << " ";
- if (m_right)
- m_right->dump();
-}
-
-SG_Tree* SG_Tree::Left() const
-{
- return m_left;
-}
-
-SG_Tree* SG_Tree::Right() const
-{
- return m_right;
-}
-
-SG_Node* SG_Tree::Client() const
-{
- return m_client_object;
-}
-
-SG_Tree* SG_Tree::Find(SG_Node *node)
-{
- if (m_client_object == node)
- return this;
-
- SG_Tree *left = m_left, *right = m_right;
-
- if (left && right)
- {
- if (right->m_bbox.intersects(node->BBox()))
- std::swap(left, right);
- }
-
- if (left)
- {
- SG_Tree* ret = left->Find(node);
- if (ret) return ret;
- }
-
- if (right)
- {
- SG_Tree* ret = right->Find(node);
- if (ret) return ret;
- }
-
- return NULL;
-}
-
-void SG_Tree::get(MT_Point3 *box) const
-{
- MT_Transform identity;
- identity.setIdentity();
- m_bbox.get(box, identity);
-}
-
-bool SG_Tree::inside(const MT_Point3 &point) const
-{
- return m_bbox.inside(point);
-}
-
-const SG_BBox& SG_Tree::BBox() const
-{
- return m_bbox;
-}
-
-void SG_Tree::SetLeft(SG_Tree *left)
-{
- m_left = left;
- m_bbox += left->m_bbox;
- m_center = (m_bbox.m_min + m_bbox.m_max)/2.0f;
- m_radius = (m_bbox.m_max - m_bbox.m_min).length();
-}
-
-void SG_Tree::SetRight(SG_Tree *right)
-{
- m_right = right;
- m_bbox += right->m_bbox;
- m_center = (m_bbox.m_min + m_bbox.m_max)/2.0f;
- m_radius = (m_bbox.m_max - m_bbox.m_min).length();
-}
-
-/**
- * A Half array is a square 2d array where cell(x, y) is undefined
- * if x < y.
- */
-template<typename T>
-class HalfArray
-{
- std::vector<std::vector<T> > m_array;
-public:
- HalfArray() {}
- ~HalfArray() {}
-
- void resize(unsigned int size)
- {
- m_array.resize(size);
- for ( unsigned int i = 0; i < size; i++)
- {
- m_array[i].resize(size - i);
- }
- }
-
- T& operator() (unsigned int x, unsigned int y)
- {
- assert(x >= y);
- return m_array[y][x - y];
- }
-
- void erase_column (unsigned int x)
- {
- for (unsigned int y = 0; y <= x; y++)
- m_array[y].erase(m_array[y].begin() + x - y);
- }
-
- void delete_column (unsigned int x)
- {
- for (unsigned int y = 0; y < x; y++)
- {
- delete m_array[y][x - y];
- m_array[y].erase(m_array[y].begin() + x - y);
- }
- }
-
- void erase_row (unsigned int y)
- {
- m_array.erase(m_array.begin() + y);
- }
-};
-
-SG_TreeFactory::SG_TreeFactory()
-{
-}
-
-SG_TreeFactory::~SG_TreeFactory()
-{
-}
-
-void SG_TreeFactory::Add(SG_Node* client)
-{
- if (client)
- m_objects.insert(new SG_Tree(client));
-}
-
-void SG_TreeFactory::Add(SG_Tree* tree)
-{
- m_objects.insert(tree);
-}
-
-SG_Tree* SG_TreeFactory::MakeTreeDown(SG_BBox &bbox)
-{
- if (m_objects.empty())
- return NULL;
- if (m_objects.size() == 1)
- return *m_objects.begin();
-
- TreeSet::iterator it = m_objects.begin();
- SG_Tree *root = *it;
- if (m_objects.size() == 2)
- {
- root->SetRight(*(++it));
- return root;
- }
-
- if (m_objects.size() == 3)
- {
- root->SetLeft(*(++it));
- root->SetRight(*(++it));
- return root;
- }
-
- if (bbox.volume() < 1.0f)
- return MakeTreeUp();
-
- SG_TreeFactory lefttree;
- SG_TreeFactory righttree;
-
- SG_BBox left, right;
- int hasleft = 0, hasright = 0;
- bbox.split(left, right);
-
- if (left.test(root->BBox()) == SG_BBox::INSIDE)
- {
- lefttree.Add(root);
- root = NULL;
- }
-
- if (root && right.test(root->BBox()) == SG_BBox::INSIDE)
- {
- righttree.Add(root);
- root = NULL;
- }
-
- for (++it; it != m_objects.end(); ++it)
- {
- switch (left.test((*it)->BBox()))
- {
- case SG_BBox::INSIDE:
- // Object is inside left tree;
- lefttree.Add(*it);
- hasleft++;
- break;
- case SG_BBox::OUTSIDE:
- righttree.Add(*it);
- hasright++;
- break;
- case SG_BBox::INTERSECT:
- if (left.inside((*it)->Client()->GetWorldPosition()))
- {
- lefttree.Add(*it);
- hasleft++;
- }
- else {
- righttree.Add(*it);
- hasright++;
- }
- break;
- }
- }
- std::cout << "Left: " << hasleft << " Right: " << hasright << " Count: " << m_objects.size() << std::endl;
-
- SG_Tree *leftnode = NULL;
- if (hasleft)
- leftnode = lefttree.MakeTreeDown(left);
-
- SG_Tree *rightnode = NULL;
- if (hasright)
- rightnode = righttree.MakeTreeDown(right);
-
- if (!root)
- root = new SG_Tree(leftnode, rightnode);
- else
- {
- if (leftnode)
- root->SetLeft(leftnode);
- if (rightnode)
- root->SetRight(rightnode);
- }
-
- return root;
-}
-
-SG_Tree* SG_TreeFactory::MakeTree()
-{
- if (m_objects.size() < 8)
- return MakeTreeUp();
-
- TreeSet::iterator it = m_objects.begin();
- SG_BBox bbox((*it)->BBox());
- for (++it; it != m_objects.end(); ++it)
- bbox += (*it)->BBox();
-
- return MakeTreeDown(bbox);
-}
-
-SG_Tree* SG_TreeFactory::MakeTreeUp()
-{
- unsigned int num_objects = m_objects.size();
-
- if (num_objects < 1)
- return NULL;
- if (num_objects < 2)
- return *m_objects.begin();
-
- HalfArray<SG_Tree*> sizes;
- sizes.resize(num_objects);
-
- unsigned int x, y;
- TreeSet::iterator xit, yit;
- for ( y = 0, yit = m_objects.begin(); y < num_objects; y++, ++yit)
- {
- sizes(y, y) = *yit;
- xit = yit;
- for ( x = y+1, ++xit; x < num_objects; x++, ++xit)
- {
- sizes(x, y) = new SG_Tree(*xit, *yit);
-
- }
- }
- while (num_objects > 2)
- {
- /* Find the pair of bboxes that produce the smallest combined bbox. */
- unsigned int minx = UINT_MAX, miny = UINT_MAX;
- MT_Scalar min_volume = FLT_MAX;
- SG_Tree *min = NULL;
- //char temp[16];
- for ( y = 0; y < num_objects; y++)
- {
- for ( x = y+1; x < num_objects; x++)
- {
- if (sizes(x, y)->volume() < min_volume)
- {
- min = sizes(x, y);
- minx = x;
- miny = y;
- min_volume = sizes(x, y)->volume();
- }
- }
- }
-
- /* Remove other bboxes that contain the two bboxes */
- sizes.delete_column(miny);
-
- for ( x = miny + 1; x < num_objects; x++)
- {
- if (x == minx)
- continue;
- delete sizes(x, miny);
- }
- sizes.erase_row(miny);
-
- num_objects--;
- minx--;
- sizes(minx, minx) = min;
- for ( x = minx + 1; x < num_objects; x++)
- {
- delete sizes(x, minx);
- sizes(x, minx) = new SG_Tree(min, sizes(x, x));
- }
- for ( y = 0; y < minx; y++)
- {
- delete sizes(minx, y);
- sizes(minx, y) = new SG_Tree(sizes(y, y), min);
- }
- }
- return sizes(1, 0);
-}
-
diff --git a/source/gameengine/SceneGraph/SG_Tree.h b/source/gameengine/SceneGraph/SG_Tree.h
deleted file mode 100644
index 339862c652f..00000000000
--- a/source/gameengine/SceneGraph/SG_Tree.h
+++ /dev/null
@@ -1,163 +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 SG_Tree.h
- * \ingroup bgesg
- */
-
-#ifndef __SG_TREE_H__
-#define __SG_TREE_H__
-
-#include "MT_Point3.h"
-#include "SG_BBox.h"
-
-#include <set>
-
-class SG_Node;
-
-
-/**
- * SG_Tree.
- * Holds a binary tree of SG_Nodes.
- */
-class SG_Tree
-{
- SG_Tree* m_left;
- SG_Tree* m_right;
- SG_Tree* m_parent;
- SG_BBox m_bbox;
- MT_Point3 m_center;
- MT_Scalar m_radius;
- SG_Node* m_client_object;
-public:
- SG_Tree();
- SG_Tree(SG_Tree* left, SG_Tree* right);
-
- SG_Tree(SG_Node* client);
- ~SG_Tree();
-
- /**
- * Computes the volume of the bounding box.
- */
- MT_Scalar volume() const;
-
- /**
- * Prints the tree (for debugging.)
- */
- void dump() const;
-
- /**
- * Returns the left node.
- */
- SG_Tree *Left() const;
- SG_Tree *Right() const;
- SG_Node *Client() const;
-
- SG_Tree* Find(SG_Node *node);
- /**
- * Gets the eight corners of this treenode's bounding box,
- * in world coordinates.
- * \param box: an array of 8 MT_Point3
- * \example MT_Point3 box[8];
- * treenode->get(box);
- */
- void get(MT_Point3 *box) const;
- /**
- * Get the tree node's bounding box.
- */
- const SG_BBox& BBox() const;
-
- /**
- * Test if the given bounding box is inside this bounding box.
- */
- bool inside(const MT_Point3 &point) const;
-
- void SetLeft(SG_Tree *left);
- void SetRight(SG_Tree *right);
-
- MT_Point3 Center() const { return m_center; }
- MT_Scalar Radius() { return m_radius; }
-
- //friend class SG_TreeFactory;
-
- struct greater
- {
- bool operator()(const SG_Tree *a, const SG_Tree *b)
- {
- return a->volume() > b->volume();
- }
- };
-
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_Tree")
-#endif
-};
-
-
-/**
- * SG_TreeFactory generates an SG_Tree from a list of SG_Nodes.
- * It joins pairs of SG_Nodes to minimize the size of the resultant
- * bounding box.
- * cf building an optimized Huffman tree.
- * \warning O(n^3)!!!
- */
-class SG_TreeFactory
-{
- typedef std::multiset<SG_Tree*, SG_Tree::greater> TreeSet;
- TreeSet m_objects;
-public:
- SG_TreeFactory();
- ~SG_TreeFactory();
-
- /**
- * Add a node to be added to the tree.
- */
- void Add(SG_Node* client);
- void Add(SG_Tree* tree);
-
- /**
- * Build the tree from the set of nodes added by
- * the Add method.
- */
- SG_Tree* MakeTreeUp();
-
- /**
- * Build the tree from the set of nodes top down.
- */
- SG_Tree* MakeTreeDown(SG_BBox &bbox);
-
- SG_Tree* MakeTree();
-
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_TreeFactory")
-#endif
-};
-
-#endif /* __SG_BBOX_H__ */
diff --git a/source/gameengine/VideoTexture/BlendType.h b/source/gameengine/VideoTexture/BlendType.h
deleted file mode 100644
index 561c6e8768f..00000000000
--- a/source/gameengine/VideoTexture/BlendType.h
+++ /dev/null
@@ -1,86 +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.
- *
- * Copyright (c) 2006 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file BlendType.h
- * \ingroup bgevideotex
- */
-
-#ifndef __BLENDTYPE_H__
-#define __BLENDTYPE_H__
-
-
-/// class allows check type of blender python object and access its contained object
-/// MUST ONLY BE USED FOR KX classes that are descendent of PyObjectPlus
-template <class PyObj> class BlendType
-{
-public:
- /// constructor
- BlendType (const char * name) : m_name(name), m_objType(NULL) {}
-
- /// check blender type and return pointer to contained object or NULL (if type is not valid)
- PyObj *checkType(PyObject *obj)
- {
- // if pointer to type isn't set
- if (m_objType == NULL)
- {
- // compare names of type
- if (strcmp(Py_TYPE(obj)->tp_name, m_name) == 0)
- // if name of type match, save pointer to type
- m_objType = Py_TYPE(obj);
- else
- // if names of type don't match, return NULL
- return NULL;
- }
- // if pointer to type is set and don't match to type of provided object, return NULL
- else if (Py_TYPE(obj) != m_objType)
- return NULL;
- // return pointer to object, this class can only be used for KX object =>
- // the Py object is actually a proxy
- return (PyObj *)BGE_PROXY_REF(obj);
- }
-
- /// parse arguments to get object
- PyObj *parseArg(PyObject *args)
- {
- // parse arguments
- PyObject *obj;
- if (PyArg_ParseTuple(args, "O", &obj)) {
- // if successfully parsed, return pointer to object
- return checkType(obj);
- }
- // otherwise return NULL
- return NULL;
- }
-
-protected:
- /// name of Python type
- const char * m_name;
- /// pointer to Python type
- PyTypeObject *m_objType;
-};
-
-
-#endif
diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt
deleted file mode 100644
index 1eb09b02e05..00000000000
--- a/source/gameengine/VideoTexture/CMakeLists.txt
+++ /dev/null
@@ -1,119 +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) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ../BlenderRoutines
- ../Expressions
- ../GameLogic
- ../Ketsji
- ../Rasterizer
- ../Rasterizer/RAS_OpenGLRasterizer
- ../SceneGraph
- ../../blender/blenkernel
- ../../blender/blenlib
- ../../blender/editors/include
- ../../blender/gpu
- ../../blender/imbuf
- ../../blender/makesdna
- ../../blender/python
- ../../blender/python/generic
- ../../../intern/container
- ../../../intern/ffmpeg
- ../../../intern/glew-mx
- ../../../intern/guardedalloc
- ../../../intern/string
- ../../../intern/decklink
- ../../../intern/gpudirect
- ../../../intern/atomic
-)
-
-set(INC_SYS
- ../../../intern/moto/include
- ${GLEW_INCLUDE_PATH}
-)
-
-add_definitions(${GL_DEFINITIONS})
-
-set(SRC
- Exception.cpp
- FilterBase.cpp
- FilterBlueScreen.cpp
- FilterColor.cpp
- FilterNormal.cpp
- FilterSource.cpp
- ImageBase.cpp
- ImageBuff.cpp
- ImageMix.cpp
- ImageRender.cpp
- ImageViewport.cpp
- PyTypeList.cpp
- Texture.cpp
- DeckLink.cpp
- VideoBase.cpp
- VideoFFmpeg.cpp
- VideoDeckLink.cpp
- blendVideoTex.cpp
-
- BlendType.h
- Common.h
- Exception.h
- FilterBase.h
- FilterBlueScreen.h
- FilterColor.h
- FilterNormal.h
- FilterSource.h
- ImageBase.h
- ImageBuff.h
- ImageMix.h
- ImageRender.h
- ImageViewport.h
- PyTypeList.h
- Texture.h
- DeckLink.h
- VideoBase.h
- VideoFFmpeg.h
- VideoDeckLink.h
-)
-
-if(WITH_CODEC_FFMPEG)
- list(APPEND INC_SYS
- ${FFMPEG_INCLUDE_DIRS}
- ${PTHREADS_INCLUDE_DIRS}
- )
- add_definitions(-DWITH_FFMPEG)
-
- remove_strict_flags_file(
- VideoFFmpeg.cpp
- VideoDeckLink
- DeckLink
- )
-endif()
-
-if(WITH_GAMEENGINE_DECKLINK)
- add_definitions(-DWITH_GAMEENGINE_DECKLINK)
-endif()
-
-blender_add_lib(ge_videotex "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/gameengine/VideoTexture/Common.h b/source/gameengine/VideoTexture/Common.h
deleted file mode 100644
index 22ea177addc..00000000000
--- a/source/gameengine/VideoTexture/Common.h
+++ /dev/null
@@ -1,64 +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.
- *
- * Copyright (c) 2006 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file VideoTexture/Common.h
- * \ingroup bgevideotex
- */
-
-#if defined WIN32
-#define WINDOWS_LEAN_AND_MEAN
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef _HRESULT_DEFINED
-#define _HRESULT_DEFINED
-#define HRESULT long
-#endif
-
-#ifndef DWORD
-#define DWORD unsigned long
-#endif
-
-#ifndef S_OK
-#define S_OK ((HRESULT)0L)
-#endif
-
-#ifndef BYTE
-#define BYTE unsigned char
-#endif
-
-#ifndef WIN32
-#define Sleep(time) sleep(time)
-#endif
-
-#ifndef FAILED
-#define FAILED(Status) ((HRESULT)(Status)<0)
-#endif
-
-#include <iostream>
diff --git a/source/gameengine/VideoTexture/DeckLink.cpp b/source/gameengine/VideoTexture/DeckLink.cpp
deleted file mode 100644
index fa8ab8c641c..00000000000
--- a/source/gameengine/VideoTexture/DeckLink.cpp
+++ /dev/null
@@ -1,813 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/Texture.cpp
- * \ingroup bgevideotex
- */
-
-#ifdef WITH_GAMEENGINE_DECKLINK
-
-// implementation
-
-// FFmpeg defines its own version of stdint.h on Windows.
-// Decklink needs FFmpeg, so it uses its version of stdint.h
-// this is necessary for INT64_C macro
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-// this is necessary for UINTPTR_MAX (used by atomic-ops)
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS
-#endif
-
-#include "atomic_ops.h"
-
-#include "EXP_PyObjectPlus.h"
-#include "KX_KetsjiEngine.h"
-#include "KX_PythonInit.h"
-#include "DeckLink.h"
-
-#include <memory.h>
-
-// macro for exception handling and logging
-#define CATCH_EXCP catch (Exception & exp) \
-{ exp.report(); return NULL; }
-
-static struct
-{
- const char *name;
- BMDDisplayMode mode;
-} sModeStringTab[] = {
- { "NTSC", bmdModeNTSC },
- { "NTSC2398", bmdModeNTSC2398 },
- { "PAL", bmdModePAL },
- { "NTSCp", bmdModeNTSCp },
- { "PALp", bmdModePALp },
-
- /* HD 1080 Modes */
-
- { "HD1080p2398", bmdModeHD1080p2398 },
- { "HD1080p24", bmdModeHD1080p24 },
- { "HD1080p25", bmdModeHD1080p25 },
- { "HD1080p2997", bmdModeHD1080p2997 },
- { "HD1080p30", bmdModeHD1080p30 },
- { "HD1080i50", bmdModeHD1080i50 },
- { "HD1080i5994", bmdModeHD1080i5994 },
- { "HD1080i6000", bmdModeHD1080i6000 },
- { "HD1080p50", bmdModeHD1080p50 },
- { "HD1080p5994", bmdModeHD1080p5994 },
- { "HD1080p6000", bmdModeHD1080p6000 },
-
- /* HD 720 Modes */
-
- { "HD720p50", bmdModeHD720p50 },
- { "HD720p5994", bmdModeHD720p5994 },
- { "HD720p60", bmdModeHD720p60 },
-
- /* 2k Modes */
-
- { "2k2398", bmdMode2k2398 },
- { "2k24", bmdMode2k24 },
- { "2k25", bmdMode2k25 },
-
- /* DCI Modes (output only) */
-
- { "2kDCI2398", bmdMode2kDCI2398 },
- { "2kDCI24", bmdMode2kDCI24 },
- { "2kDCI25", bmdMode2kDCI25 },
-
- /* 4k Modes */
-
- { "4K2160p2398", bmdMode4K2160p2398 },
- { "4K2160p24", bmdMode4K2160p24 },
- { "4K2160p25", bmdMode4K2160p25 },
- { "4K2160p2997", bmdMode4K2160p2997 },
- { "4K2160p30", bmdMode4K2160p30 },
- { "4K2160p50", bmdMode4K2160p50 },
- { "4K2160p5994", bmdMode4K2160p5994 },
- { "4K2160p60", bmdMode4K2160p60 },
- // sentinel
- { NULL }
-};
-
-static struct
-{
- const char *name;
- BMDPixelFormat format;
-} sFormatStringTab[] = {
- { "8BitYUV", bmdFormat8BitYUV },
- { "10BitYUV", bmdFormat10BitYUV },
- { "8BitARGB", bmdFormat8BitARGB },
- { "8BitBGRA", bmdFormat8BitBGRA },
- { "10BitRGB", bmdFormat10BitRGB },
- { "12BitRGB", bmdFormat12BitRGB },
- { "12BitRGBLE", bmdFormat12BitRGBLE },
- { "10BitRGBXLE", bmdFormat10BitRGBXLE },
- { "10BitRGBX", bmdFormat10BitRGBX },
- // sentinel
- { NULL }
-};
-
-ExceptionID DeckLinkBadDisplayMode, DeckLinkBadPixelFormat;
-ExpDesc DeckLinkBadDisplayModeDesc(DeckLinkBadDisplayMode, "Invalid or unsupported display mode");
-ExpDesc DeckLinkBadPixelFormatDesc(DeckLinkBadPixelFormat, "Invalid or unsupported pixel format");
-
-HRESULT decklink_ReadDisplayMode(const char *format, size_t len, BMDDisplayMode *displayMode)
-{
- int i;
-
- if (len == 0)
- len = strlen(format);
- for (i = 0; sModeStringTab[i].name != NULL; i++) {
- if (strlen(sModeStringTab[i].name) == len &&
- !strncmp(sModeStringTab[i].name, format, len))
- {
- *displayMode = sModeStringTab[i].mode;
- return S_OK;
- }
- }
- if (len != 4)
- THRWEXCP(DeckLinkBadDisplayMode, S_OK);
- // assume the user entered directly the mode value as a 4 char string
- *displayMode = (BMDDisplayMode)((((uint32_t)format[0]) << 24) + (((uint32_t)format[1]) << 16) + (((uint32_t)format[2]) << 8) + ((uint32_t)format[3]));
- return S_OK;
-}
-
-HRESULT decklink_ReadPixelFormat(const char *format, size_t len, BMDPixelFormat *pixelFormat)
-{
- int i;
-
- if (!len)
- len = strlen(format);
- for (i = 0; sFormatStringTab[i].name != NULL; i++) {
- if (strlen(sFormatStringTab[i].name) == len &&
- !strncmp(sFormatStringTab[i].name, format, len))
- {
- *pixelFormat = sFormatStringTab[i].format;
- return S_OK;
- }
- }
- if (len != 4)
- THRWEXCP(DeckLinkBadPixelFormat, S_OK);
- // assume the user entered directly the mode value as a 4 char string
- *pixelFormat = (BMDPixelFormat)((((uint32_t)format[0]) << 24) + (((uint32_t)format[1]) << 16) + (((uint32_t)format[2]) << 8) + ((uint32_t)format[3]));
- return S_OK;
-}
-
-class DeckLink3DFrameWrapper : public IDeckLinkVideoFrame, IDeckLinkVideoFrame3DExtensions
-{
-public:
- // IUnknown
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
- {
- if (!memcmp(&iid, &IID_IDeckLinkVideoFrame3DExtensions, sizeof(iid))) {
- if (mpRightEye) {
- *ppv = (IDeckLinkVideoFrame3DExtensions*)this;
- return S_OK;
- }
- }
- return E_NOTIMPL;
- }
- virtual ULONG STDMETHODCALLTYPE AddRef(void) { return 1U; }
- virtual ULONG STDMETHODCALLTYPE Release(void) { return 1U; }
- // IDeckLinkVideoFrame
- virtual long STDMETHODCALLTYPE GetWidth(void) { return mpLeftEye->GetWidth(); }
- virtual long STDMETHODCALLTYPE GetHeight(void) { return mpLeftEye->GetHeight(); }
- virtual long STDMETHODCALLTYPE GetRowBytes(void) { return mpLeftEye->GetRowBytes(); }
- virtual BMDPixelFormat STDMETHODCALLTYPE GetPixelFormat(void) { return mpLeftEye->GetPixelFormat(); }
- virtual BMDFrameFlags STDMETHODCALLTYPE GetFlags(void) { return mpLeftEye->GetFlags(); }
- virtual HRESULT STDMETHODCALLTYPE GetBytes(void **buffer) { return mpLeftEye->GetBytes(buffer); }
- virtual HRESULT STDMETHODCALLTYPE GetTimecode(BMDTimecodeFormat format,IDeckLinkTimecode **timecode)
- { return mpLeftEye->GetTimecode(format, timecode); }
- virtual HRESULT STDMETHODCALLTYPE GetAncillaryData(IDeckLinkVideoFrameAncillary **ancillary)
- { return mpLeftEye->GetAncillaryData(ancillary); }
- // IDeckLinkVideoFrame3DExtensions
- virtual BMDVideo3DPackingFormat STDMETHODCALLTYPE Get3DPackingFormat(void)
- {
- return bmdVideo3DPackingLeftOnly;
- }
- virtual HRESULT STDMETHODCALLTYPE GetFrameForRightEye(
- /* [out] */ IDeckLinkVideoFrame **rightEyeFrame)
- {
- mpRightEye->AddRef();
- *rightEyeFrame = mpRightEye;
- return S_OK;
- }
- // Constructor
- DeckLink3DFrameWrapper(IDeckLinkVideoFrame *leftEye, IDeckLinkVideoFrame *rightEye)
- {
- mpLeftEye = leftEye;
- mpRightEye = rightEye;
- }
- // no need for a destructor, it's just a wrapper
-private:
- IDeckLinkVideoFrame *mpLeftEye;
- IDeckLinkVideoFrame *mpRightEye;
-};
-
-static void decklink_Reset(DeckLink *self)
-{
- self->m_lastClock = 0.0;
- self->mDLOutput = NULL;
- self->mUse3D = false;
- self->mDisplayMode = bmdModeUnknown;
- self->mKeyingSupported = false;
- self->mHDKeyingSupported = false;
- self->mSize[0] = 0;
- self->mSize[1] = 0;
- self->mFrameSize = 0;
- self->mLeftFrame = NULL;
- self->mRightFrame = NULL;
- self->mKeyer = NULL;
- self->mUseKeying = false;
- self->mKeyingLevel = 255;
- self->mUseExtend = false;
-}
-
-#ifdef __BIG_ENDIAN__
-#define CONV_PIXEL(i) ((((i)>>16)&0xFF00)+(((i)&0xFF00)<<16)+((i)&0xFF00FF))
-#else
-#define CONV_PIXEL(i) ((((i)&0xFF)<<16)+(((i)>>16)&0xFF)+((i)&0xFF00FF00))
-#endif
-
-// adapt the pixel format and picture size from VideoTexture (RGBA) to DeckLink (BGRA)
-static void decklink_ConvImage(uint32_t *dest, const short *destSize, const uint32_t *source, const short *srcSize, bool extend)
-{
- short w, h, x, y;
- const uint32_t *s;
- uint32_t *d, p;
- bool sameSize = (destSize[0] == srcSize[0] && destSize[1] == srcSize[1]);
-
- if (sameSize || !extend) {
- // here we convert pixel by pixel
- w = (destSize[0] < srcSize[0]) ? destSize[0] : srcSize[0];
- h = (destSize[1] < srcSize[1]) ? destSize[1] : srcSize[1];
- for (y = 0; y < h; ++y) {
- s = source + y*srcSize[0];
- d = dest + y*destSize[0];
- for (x = 0; x < w; ++x, ++s, ++d) {
- *d = CONV_PIXEL(*s);
- }
- }
- }
- else {
- // here we scale
- // interpolation accumulator
- int accHeight = srcSize[1] >> 1;
- d = dest;
- s = source;
- // process image rows
- for (y = 0; y < srcSize[1]; ++y) {
- // increase height accum
- accHeight += destSize[1];
- // if pixel row has to be drawn
- if (accHeight >= srcSize[1]) {
- // decrease accum
- accHeight -= srcSize[1];
- // width accum
- int accWidth = srcSize[0] >> 1;
- // process row
- for (x = 0; x < srcSize[0]; ++x, ++s) {
- // increase width accum
- accWidth += destSize[0];
- // convert pixel
- p = CONV_PIXEL(*s);
- // if pixel has to be drown one or more times
- while (accWidth >= srcSize[0]) {
- // decrease accum
- accWidth -= srcSize[0];
- *d++ = p;
- }
- }
- // if there should be more identical lines
- while (accHeight >= srcSize[1]) {
- accHeight -= srcSize[1];
- // copy previous line
- memcpy(d, d - destSize[0], 4 * destSize[0]);
- d += destSize[0];
- }
- }
- else {
- // if we skip a source line
- s += srcSize[0];
- }
- }
- }
-}
-
-// DeckLink object allocation
-static PyObject *DeckLink_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- // allocate object
- DeckLink * self = reinterpret_cast<DeckLink*>(type->tp_alloc(type, 0));
- // initialize object structure
- decklink_Reset(self);
- // m_leftEye is a python object, it's handled by python
- self->m_leftEye = NULL;
- self->m_rightEye = NULL;
- // return allocated object
- return reinterpret_cast<PyObject*>(self);
-}
-
-
-// forward declaration
-PyObject *DeckLink_close(DeckLink *self);
-int DeckLink_setSource(DeckLink *self, PyObject *value, void *closure);
-
-
-// DeckLink object deallocation
-static void DeckLink_dealloc(DeckLink *self)
-{
- // release renderer
- Py_XDECREF(self->m_leftEye);
- // close decklink
- PyObject *ret = DeckLink_close(self);
- Py_DECREF(ret);
- // release object
- Py_TYPE((PyObject *)self)->tp_free((PyObject *)self);
-}
-
-
-ExceptionID AutoDetectionNotAvail, DeckLinkOpenCard, DeckLinkBadFormat, DeckLinkInternalError;
-ExpDesc AutoDetectionNotAvailDesc(AutoDetectionNotAvail, "Auto detection not yet available");
-ExpDesc DeckLinkOpenCardDesc(DeckLinkOpenCard, "Cannot open card for output");
-ExpDesc DeckLinkBadFormatDesc(DeckLinkBadFormat, "Invalid or unsupported output format, use <mode>[/3D]");
-ExpDesc DeckLinkInternalErrorDesc(DeckLinkInternalError, "DeckLink API internal error, please report");
-
-// DeckLink object initialization
-static int DeckLink_init(DeckLink *self, PyObject *args, PyObject *kwds)
-{
- IDeckLinkIterator* pIterator;
- IDeckLinkAttributes* pAttributes;
- IDeckLinkDisplayModeIterator* pDisplayModeIterator;
- IDeckLinkDisplayMode* pDisplayMode;
- IDeckLink* pDL;
- char* p3D;
- BOOL flag;
- size_t len;
- int i;
- uint32_t displayFlags;
- BMDVideoOutputFlags outputFlags;
- BMDDisplayModeSupport support;
- uint32_t* bytes;
-
-
- // material ID
- short cardIdx = 0;
- // texture ID
- char *format = NULL;
-
- static const char *kwlist[] = {"cardIdx", "format", NULL};
- // get parameters
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|hs",
- const_cast<char**>(kwlist), &cardIdx, &format))
- return -1;
-
- try {
- if (format == NULL) {
- THRWEXCP(AutoDetectionNotAvail, S_OK);
- }
-
- if ((p3D = strchr(format, '/')) != NULL && strcmp(p3D, "/3D"))
- THRWEXCP(DeckLinkBadFormat, S_OK);
- self->mUse3D = (p3D) ? true : false;
- // read the mode
- len = (p3D) ? (size_t)(p3D - format) : strlen(format);
- // throws if bad mode
- decklink_ReadDisplayMode(format, len, &self->mDisplayMode);
-
- pIterator = BMD_CreateDeckLinkIterator();
- pDL = NULL;
- if (pIterator) {
- i = 0;
- while (pIterator->Next(&pDL) == S_OK) {
- if (i == cardIdx) {
- break;
- }
- i++;
- pDL->Release();
- pDL = NULL;
- }
- pIterator->Release();
- }
-
- if (!pDL) {
- THRWEXCP(DeckLinkOpenCard, S_OK);
- }
- // detect the capabilities
- if (pDL->QueryInterface(IID_IDeckLinkAttributes, (void**)&pAttributes) == S_OK) {
- if (pAttributes->GetFlag(BMDDeckLinkSupportsInternalKeying, &flag) == S_OK && flag) {
- self->mKeyingSupported = true;
- if (pAttributes->GetFlag(BMDDeckLinkSupportsHDKeying, &flag) == S_OK && flag) {
- self->mHDKeyingSupported = true;
- }
- }
- pAttributes->Release();
- }
-
- if (pDL->QueryInterface(IID_IDeckLinkOutput, (void**)&self->mDLOutput) != S_OK) {
- self->mDLOutput = NULL;
- }
- if (self->mKeyingSupported) {
- pDL->QueryInterface(IID_IDeckLinkKeyer, (void **)&self->mKeyer);
- }
- // we don't need the device anymore, release to avoid leaking
- pDL->Release();
-
- if (!self->mDLOutput)
- THRWEXCP(DeckLinkOpenCard, S_OK);
-
- if (self->mDLOutput->GetDisplayModeIterator(&pDisplayModeIterator) != S_OK)
- THRWEXCP(DeckLinkInternalError, S_OK);
-
- displayFlags = (self->mUse3D) ? bmdDisplayModeSupports3D : 0;
- outputFlags = (self->mUse3D) ? bmdVideoOutputDualStream3D : bmdVideoOutputFlagDefault;
- pDisplayMode = NULL;
- i = 0;
- while (pDisplayModeIterator->Next(&pDisplayMode) == S_OK) {
- if (pDisplayMode->GetDisplayMode() == self->mDisplayMode
- && (pDisplayMode->GetFlags() & displayFlags) == displayFlags) {
- if (self->mDLOutput->DoesSupportVideoMode(self->mDisplayMode, bmdFormat8BitBGRA, outputFlags, &support, NULL) != S_OK ||
- support == bmdDisplayModeNotSupported)
- {
- printf("Warning: DeckLink card %d reports no BGRA support, proceed anyway\n", cardIdx);
- }
- break;
- }
- pDisplayMode->Release();
- pDisplayMode = NULL;
- i++;
- }
- pDisplayModeIterator->Release();
-
- if (!pDisplayMode)
- THRWEXCP(DeckLinkBadFormat, S_OK);
- self->mSize[0] = pDisplayMode->GetWidth();
- self->mSize[1] = pDisplayMode->GetHeight();
- self->mFrameSize = 4*self->mSize[0]*self->mSize[1];
- pDisplayMode->Release();
- if (self->mDLOutput->EnableVideoOutput(self->mDisplayMode, outputFlags) != S_OK)
- // this shouldn't fail
- THRWEXCP(DeckLinkOpenCard, S_OK);
-
- if (self->mDLOutput->CreateVideoFrame(self->mSize[0], self->mSize[1], self->mSize[0] * 4, bmdFormat8BitBGRA, bmdFrameFlagFlipVertical, &self->mLeftFrame) != S_OK)
- THRWEXCP(DeckLinkInternalError, S_OK);
- // clear alpha channel in the frame buffer
- self->mLeftFrame->GetBytes((void **)&bytes);
- memset(bytes, 0, self->mFrameSize);
- if (self->mUse3D) {
- if (self->mDLOutput->CreateVideoFrame(self->mSize[0], self->mSize[1], self->mSize[0] * 4, bmdFormat8BitBGRA, bmdFrameFlagFlipVertical, &self->mRightFrame) != S_OK)
- THRWEXCP(DeckLinkInternalError, S_OK);
- // clear alpha channel in the frame buffer
- self->mRightFrame->GetBytes((void **)&bytes);
- memset(bytes, 0, self->mFrameSize);
- }
- }
- catch (Exception & exp)
- {
- printf("DeckLink: exception when opening card %d: %s\n", cardIdx, exp.what());
- exp.report();
- // normally, the object should be deallocated
- return -1;
- }
- // initialization succeeded
- return 0;
-}
-
-
-// close added decklink
-PyObject *DeckLink_close(DeckLink * self)
-{
- if (self->mLeftFrame)
- self->mLeftFrame->Release();
- if (self->mRightFrame)
- self->mRightFrame->Release();
- if (self->mKeyer)
- self->mKeyer->Release();
- if (self->mDLOutput)
- self->mDLOutput->Release();
- decklink_Reset(self);
- Py_RETURN_NONE;
-}
-
-
-// refresh decklink key frame
-static PyObject *DeckLink_refresh(DeckLink *self, PyObject *args)
-{
- // get parameter - refresh source
- PyObject *param;
- double ts = -1.0;
-
- if (!PyArg_ParseTuple(args, "O|d:refresh", &param, &ts) || !PyBool_Check(param)) {
- // report error
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return NULL;
- }
- // some trick here: we are in the business of loading a key frame in decklink,
- // no use to do it if we are still in the same rendering frame.
- // We find this out by looking at the engine current clock time
- KX_KetsjiEngine* engine = KX_GetActiveEngine();
- if (engine->GetClockTime() != self->m_lastClock)
- {
- self->m_lastClock = engine->GetClockTime();
- // set source refresh
- bool refreshSource = (param == Py_True);
- uint32_t *leftEye = NULL;
- uint32_t *rightEye = NULL;
- // try to process key frame from source
- try {
- // check if optimization is possible
- if (self->m_leftEye != NULL) {
- ImageBase *leftImage = self->m_leftEye->m_image;
- short * srcSize = leftImage->getSize();
- self->mLeftFrame->GetBytes((void **)&leftEye);
- if (srcSize[0] == self->mSize[0] && srcSize[1] == self->mSize[1])
- {
- // buffer has same size, can load directly
- if (!leftImage->loadImage(leftEye, self->mFrameSize, GL_BGRA, ts))
- leftEye = NULL;
- }
- else {
- // scaling is required, go the hard way
- unsigned int *src = leftImage->getImage(0, ts);
- if (src != NULL)
- decklink_ConvImage(leftEye, self->mSize, src, srcSize, self->mUseExtend);
- else
- leftEye = NULL;
- }
- }
- if (leftEye) {
- if (self->mUse3D && self->m_rightEye != NULL) {
- ImageBase *rightImage = self->m_rightEye->m_image;
- short * srcSize = rightImage->getSize();
- self->mRightFrame->GetBytes((void **)&rightEye);
- if (srcSize[0] == self->mSize[0] && srcSize[1] == self->mSize[1])
- {
- // buffer has same size, can load directly
- rightImage->loadImage(rightEye, self->mFrameSize, GL_BGRA, ts);
- }
- else {
- // scaling is required, go the hard way
- unsigned int *src = rightImage->getImage(0, ts);
- if (src != NULL)
- decklink_ConvImage(rightEye, self->mSize, src, srcSize, self->mUseExtend);
- }
- }
- if (self->mUse3D) {
- DeckLink3DFrameWrapper frame3D(
- (IDeckLinkVideoFrame*)self->mLeftFrame,
- (IDeckLinkVideoFrame*)self->mRightFrame);
- self->mDLOutput->DisplayVideoFrameSync(&frame3D);
- }
- else {
- self->mDLOutput->DisplayVideoFrameSync((IDeckLinkVideoFrame*)self->mLeftFrame);
- }
- }
- // refresh texture source, if required
- if (refreshSource) {
- if (self->m_leftEye)
- self->m_leftEye->m_image->refresh();
- if (self->m_rightEye)
- self->m_rightEye->m_image->refresh();
- }
- }
- CATCH_EXCP;
- }
- Py_RETURN_NONE;
-}
-
-// get source object
-static PyObject *DeckLink_getSource(DeckLink *self, PyObject *value, void *closure)
-{
- // if source exists
- if (self->m_leftEye != NULL) {
- Py_INCREF(self->m_leftEye);
- return reinterpret_cast<PyObject*>(self->m_leftEye);
- }
- // otherwise return None
- Py_RETURN_NONE;
-}
-
-
-// set source object
-int DeckLink_setSource(DeckLink *self, PyObject *value, void *closure)
-{
- // check new value
- if (value == NULL || !pyImageTypes.in(Py_TYPE(value))) {
- // report value error
- PyErr_SetString(PyExc_TypeError, "Invalid type of value");
- return -1;
- }
- // increase ref count for new value
- Py_INCREF(value);
- // release previous
- Py_XDECREF(self->m_leftEye);
- // set new value
- self->m_leftEye = reinterpret_cast<PyImage*>(value);
- // return success
- return 0;
-}
-
-// get source object
-static PyObject *DeckLink_getRight(DeckLink *self, PyObject *value, void *closure)
-{
- // if source exists
- if (self->m_rightEye != NULL)
- {
- Py_INCREF(self->m_rightEye);
- return reinterpret_cast<PyObject*>(self->m_rightEye);
- }
- // otherwise return None
- Py_RETURN_NONE;
-}
-
-
-// set source object
-static int DeckLink_setRight(DeckLink *self, PyObject *value, void *closure)
-{
- // check new value
- if (value == NULL || !pyImageTypes.in(Py_TYPE(value)))
- {
- // report value error
- PyErr_SetString(PyExc_TypeError, "Invalid type of value");
- return -1;
- }
- // increase ref count for new value
- Py_INCREF(value);
- // release previous
- Py_XDECREF(self->m_rightEye);
- // set new value
- self->m_rightEye = reinterpret_cast<PyImage*>(value);
- // return success
- return 0;
-}
-
-
-static PyObject *DeckLink_getKeying(DeckLink *self, PyObject *value, void *closure)
-{
- if (self->mUseKeying) Py_RETURN_TRUE;
- else Py_RETURN_FALSE;
-}
-
-static int DeckLink_setKeying(DeckLink *self, PyObject *value, void *closure)
-{
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- if (self->mKeyer != NULL)
- {
- if (value == Py_True)
- {
- if (self->mKeyer->Enable(false) != S_OK)
- {
- PyErr_SetString(PyExc_RuntimeError, "Error enabling keyer");
- return -1;
- }
- self->mUseKeying = true;
- self->mKeyer->SetLevel(self->mKeyingLevel);
- }
- else
- {
- self->mKeyer->Disable();
- self->mUseKeying = false;
- }
- }
- // success
- return 0;
-}
-
-static PyObject *DeckLink_getLevel(DeckLink *self, PyObject *value, void *closure)
-{
- return Py_BuildValue("h", self->mKeyingLevel);
-}
-
-static int DeckLink_setLevel(DeckLink *self, PyObject *value, void *closure)
-{
- long level;
- if (value == NULL || !PyLong_Check(value)) {
- PyErr_SetString(PyExc_TypeError, "The value must be an integer from 0 to 255");
- return -1;
- }
- level = PyLong_AsLong(value);
- if (level > 255)
- level = 255;
- else if (level < 0)
- level = 0;
- self->mKeyingLevel = (uint8_t)level;
- if (self->mUseKeying) {
- if (self->mKeyer->SetLevel(self->mKeyingLevel) != S_OK) {
- PyErr_SetString(PyExc_RuntimeError, "Error changin level of keyer");
- return -1;
- }
- }
- // success
- return 0;
-}
-
-static PyObject *DeckLink_getExtend(DeckLink *self, PyObject *value, void *closure)
-{
- if (self->mUseExtend) Py_RETURN_TRUE;
- else Py_RETURN_FALSE;
-}
-
-static int DeckLink_setExtend(DeckLink *self, PyObject *value, void *closure)
-{
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- self->mUseExtend = (value == Py_True);
- return 0;
-}
-
-// class DeckLink methods
-static PyMethodDef decklinkMethods[] =
-{
- { "close", (PyCFunction)DeckLink_close, METH_NOARGS, "Close dynamic decklink and restore original"},
- { "refresh", (PyCFunction)DeckLink_refresh, METH_VARARGS, "Refresh decklink from source"},
- {NULL} /* Sentinel */
-};
-
-// class DeckLink attributes
-static PyGetSetDef decklinkGetSets[] =
-{
- { (char*)"source", (getter)DeckLink_getSource, (setter)DeckLink_setSource, (char*)"source of decklink (left eye)", NULL},
- { (char*)"right", (getter)DeckLink_getRight, (setter)DeckLink_setRight, (char*)"source of decklink (right eye)", NULL },
- { (char*)"keying", (getter)DeckLink_getKeying, (setter)DeckLink_setKeying, (char*)"whether keying is enabled (frame is alpha-composited with passthrough output)", NULL },
- { (char*)"level", (getter)DeckLink_getLevel, (setter)DeckLink_setLevel, (char*)"change the level of keying (overall alpha level of key frame, 0 to 255)", NULL },
- { (char*)"extend", (getter)DeckLink_getExtend, (setter)DeckLink_setExtend, (char*)"whether image should stretched to fit frame", NULL },
- { NULL }
-};
-
-
-// class DeckLink declaration
-PyTypeObject DeckLinkType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.DeckLink", /*tp_name*/
- sizeof(DeckLink), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)DeckLink_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "DeckLink objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- decklinkMethods, /* tp_methods */
- 0, /* tp_members */
- decklinkGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)DeckLink_init, /* tp_init */
- 0, /* tp_alloc */
- DeckLink_new, /* tp_new */
-};
-
-#endif /* WITH_GAMEENGINE_DECKLINK */
diff --git a/source/gameengine/VideoTexture/DeckLink.h b/source/gameengine/VideoTexture/DeckLink.h
deleted file mode 100644
index 4528fe7cec0..00000000000
--- a/source/gameengine/VideoTexture/DeckLink.h
+++ /dev/null
@@ -1,86 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file VideoTexture/DeckLink.h
- * \ingroup bgevideotex
- */
-
-#ifndef __DECKLINK_H__
-#define __DECKLINK_H__
-
-#ifdef WITH_GAMEENGINE_DECKLINK
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "DNA_image_types.h"
-
-#include "DeckLinkAPI.h"
-
-#include "ImageBase.h"
-#include "BlendType.h"
-#include "Exception.h"
-
-
-// type DeckLink declaration
-struct DeckLink
-{
- PyObject_HEAD
-
- // last refresh
- double m_lastClock;
- // decklink card to which we output
- IDeckLinkOutput * mDLOutput;
- IDeckLinkKeyer * mKeyer;
- IDeckLinkMutableVideoFrame *mLeftFrame;
- IDeckLinkMutableVideoFrame *mRightFrame;
- bool mUse3D;
- bool mUseKeying;
- bool mUseExtend;
- bool mKeyingSupported;
- bool mHDKeyingSupported;
- uint8_t mKeyingLevel;
- BMDDisplayMode mDisplayMode;
- short mSize[2];
- uint32_t mFrameSize;
-
- // image source
- PyImage * m_leftEye;
- PyImage * m_rightEye;
-};
-
-
-// DeckLink type description
-extern PyTypeObject DeckLinkType;
-
-// helper function
-HRESULT decklink_ReadDisplayMode(const char *format, size_t len, BMDDisplayMode *displayMode);
-HRESULT decklink_ReadPixelFormat(const char *format, size_t len, BMDPixelFormat *displayMode);
-
-#endif /* WITH_GAMEENGINE_DECKLINK */
-
-#endif /* __DECKLINK_H__ */
diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp
deleted file mode 100644
index 9f82987ea62..00000000000
--- a/source/gameengine/VideoTexture/Exception.cpp
+++ /dev/null
@@ -1,241 +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.
- *
- * Copyright (c) 2006 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/Exception.cpp
- * \ingroup bgevideotex
- */
-
-#include <sstream>
-#include <fstream>
-
-#include "EXP_PyObjectPlus.h"
-
-#include "Exception.h"
-
-
-// exception identificators
-ExceptionID ErrGeneral, ErrNotFound;
-
-// exception descriptions
-ExpDesc errGenerDesc(ErrGeneral, "General Error");
-ExpDesc errNFoundDesc(ErrNotFound, "Error description not found");
-
-
-
-// implementation of ExpDesc
-
-// constructor
-ExpDesc::ExpDesc (ExceptionID & exp, const char *desc, RESULT hres)
-: m_expID(exp), m_hRslt(hres), m_description(desc)
-{
-}
-
-// destructor
-ExpDesc::~ExpDesc (void) {}
-
-// list of descriptions
-std::vector<ExpDesc*> ExpDesc::m_expDescs;
-
-
-// class Exception
-
-
-// last exception description
-std::string Exception::m_lastError;
-
-// log file name
-const char * Exception::m_logFile = NULL;
-
-
-// basic constructor
-Exception::Exception ()
-{
- // default values
- m_expID = &ErrNotFound;
- m_hRslt = S_OK;
- m_line = 0;
-}
-
-
-// destructor
-Exception::~Exception () throw() { }
-
-
-// copy constructor
-Exception::Exception (const Exception & xpt)
-{ copy (xpt); }
-
-
-// assignment operator
-Exception & Exception::operator= (const Exception & xpt)
-{ copy (xpt); return *this; }
-
-
-// get exception description
-const char * Exception::what()
-{
- // set exception description
- setXptDesc();
- // return c string
- return m_desc.c_str();
-}
-
-
-// debug version - with file and line of exception
-Exception::Exception (ExceptionID & expID, RESULT rslt, const char *fil, int lin)
-: m_expID (&expID), m_hRslt (rslt)
-{
- // set file and line
- if (fil[0] != '\0' || lin > 0)
- setFileLine (fil, lin);
- else
- m_line = -1;
-}
-
-
-// set file and line
-void Exception::setFileLine (const char *fil, int lin)
-{
- if (fil != NULL) m_fileName = fil;
- m_line = lin;
-}
-
-
-// report exception
-void Exception::report(void)
-{
- // set exception description
- setXptDesc();
- // set python error
- PyErr_SetString(PyExc_RuntimeError, what());
- // if log file is set
- if (m_logFile != NULL)
- {
- // write description to log
- std::ofstream logf (m_logFile, std::ios_base::app);
- logf << m_fileName << ':' << m_line << ':' << m_desc << std::endl;
- logf.flush();
- logf.close();
- }
-}
-
-
-// set exception description
-void Exception::setXptDesc (void)
-{
- // if description is not set
- if (m_desc.size() == 0)
- {
- // start of search -1
- // found description "NotFound" 0
- // found description without matching result 1
- // found description with matching result 2
- int best = -1;
- // find exception description
- for (std::vector<ExpDesc*>::iterator it = ExpDesc::m_expDescs.begin(); it != ExpDesc::m_expDescs.end(); ++it)
- {
- // use "NotFound", if there is not better
- if (best < 0 && (*it)->isExp(&ErrNotFound) > 0)
- {
- (*it)->loadDesc(m_desc);
- best = 0;
- }
- // match exception
- int nBest = (*it)->isExp(m_expID, m_hRslt);
- // if exception is matching better
- if (nBest > 0 && best < nBest)
- {
- // set description
- (*it)->loadDesc(m_desc);
- best = nBest;
- // if matching exactly, finish search
- if (best == 2) break;
- }
- }
- // add result code
- // length of result code
- const size_t rsltSize = 11;
- // delimit description
- //const char delimRslt[] = ": ";
- // set text of description
- char rsltTxt[rsltSize];
- std::ostringstream os;
- os << std::hex << m_hRslt << ": " << '\0';
- // copy result to description
- m_desc.insert(0, rsltTxt);
- // copy exception description to last exception string
- m_lastError = m_desc;
- }
-}
-
-
-// copy exception data
-void Exception::copy (const Exception & xpt)
-{
- // standard data
- m_expID = xpt.m_expID;
- m_hRslt = xpt.m_hRslt;
- m_desc = xpt.m_desc;
-
- // debug data
- m_fileName = xpt.m_fileName;
- m_line = xpt.m_line;
-}
-
-void registerAllExceptions(void)
-{
- errGenerDesc.registerDesc();
- errNFoundDesc.registerDesc();
- MaterialNotAvailDesc.registerDesc();
- ImageSizesNotMatchDesc.registerDesc();
- ImageHasExportsDesc.registerDesc();
- InvalidColorChannelDesc.registerDesc();
- InvalidImageModeDesc.registerDesc();
- SceneInvalidDesc.registerDesc();
- CameraInvalidDesc.registerDesc();
- ObserverInvalidDesc.registerDesc();
- MirrorInvalidDesc.registerDesc();
- MirrorSizeInvalidDesc.registerDesc();
- MirrorNormalInvalidDesc.registerDesc();
- MirrorHorizontalDesc.registerDesc();
- MirrorTooSmallDesc.registerDesc();
- SourceVideoEmptyDesc.registerDesc();
- SourceVideoCreationDesc.registerDesc();
- OffScreenInvalidDesc.registerDesc();
-#ifdef WITH_GAMEENGINE_DECKLINK
- AutoDetectionNotAvailDesc.registerDesc();
- DeckLinkBadDisplayModeDesc.registerDesc();
- DeckLinkBadPixelFormatDesc.registerDesc();
- DeckLinkOpenCardDesc.registerDesc();
- DeckLinkBadFormatDesc.registerDesc();
- DeckLinkInternalErrorDesc.registerDesc();
- SourceVideoOnlyCaptureDesc.registerDesc();
- VideoDeckLinkBadFormatDesc.registerDesc();
- VideoDeckLinkOpenCardDesc.registerDesc();
- VideoDeckLinkDvpInternalErrorDesc.registerDesc();
- VideoDeckLinkPinMemoryErrorDesc.registerDesc();
-#endif
-}
diff --git a/source/gameengine/VideoTexture/Exception.h b/source/gameengine/VideoTexture/Exception.h
deleted file mode 100644
index c4de85ff34d..00000000000
--- a/source/gameengine/VideoTexture/Exception.h
+++ /dev/null
@@ -1,239 +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.
- *
- * Copyright (c) 2006 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/Exception.h
- * \ingroup bgevideotex
- */
-
-#ifndef __EXCEPTION_H__
-#define __EXCEPTION_H__
-
-#include <exception>
-#include <vector>
-#include <string>
-#include <algorithm>
-
-#include "Common.h"
-
-
-#define CHCKHRSLTV(fnc,val,err) \
-{ \
- HRESULT macroHRslt = (fnc); \
- if (macroHRslt != val) \
- throw Exception (err, macroHRslt, __FILE__, __LINE__); \
-}
-
-#define THRWEXCP(err,hRslt) throw Exception (err, hRslt, __FILE__, __LINE__)
-
-
-#if defined WIN32
-
-#define CHCKHRSLT(fnc,err) \
-{ \
- HRESULT macroHRslt = (fnc); \
- if (FAILED(macroHRslt)) \
- throw Exception (err, macroHRslt, __FILE__, __LINE__); \
-}
-
-#else
-
-#define CHCKHRSLT(fnc,err) CHCKHRSLTV(fnc,S_OK,err)
-
-#endif
-
-
-// forward declarations
-class ExceptionID;
-class Exception;
-
-
-// exception identificators
-extern ExceptionID ErrGeneral, ErrNotFound;
-
-
-// result type
-typedef long RESULT;
-
-
-// class ExceptionID for exception identification
-class ExceptionID
-{
-public:
- // constructor a destructor
- ExceptionID (void) {}
- ~ExceptionID (void) {}
-
-private:
- // not allowed
- ExceptionID (const ExceptionID & obj) throw() {}
- ExceptionID & operator= (const ExceptionID & obj) throw() { return *this; }
-};
-
-
-// class ExpDesc for exception description
-class ExpDesc
-{
-public:
- // constructor a destructor
- ExpDesc (ExceptionID & exp, const char * desc, RESULT hres = S_OK);
- ~ExpDesc (void);
-
- // comparision function
- // returns 0, if exception identification don't match at all
- // returns 1, if only exception identification is matching
- // returns 2, if both exception identification and result are matching
- int isExp (ExceptionID *exp, RESULT hres = S_OK) throw()
- {
- // check exception identification
- if (&m_expID == exp)
- {
- // check result value
- if (m_hRslt == hres) return 2;
- // only identification match
- if (m_hRslt == S_OK) return 1;
- }
- // no match
- return 0;
- }
-
- // get exception description
- void loadDesc (std::string & desc) throw()
- {
- desc = m_description;
- }
-
- void registerDesc(void)
- {
- if (std::find(m_expDescs.begin(), m_expDescs.end(), this) == m_expDescs.end())
- m_expDescs.push_back(this);
- }
- // list of exception descriptions
- static std::vector<ExpDesc*> m_expDescs;
-
-private:
- // exception ID
- ExceptionID & m_expID;
- // result
- RESULT m_hRslt;
- // description
- const char * m_description;
-
- // not allowed
- ExpDesc (const ExpDesc & obj) : m_expID (ErrNotFound) {}
- ExpDesc & operator= (const ExpDesc & obj) { return *this; }
-};
-
-
-
-// class Exception
-class Exception : public std::exception
-{
-public:
- // constructor
- Exception ();
- // destructor
- virtual ~Exception () throw();
- // copy constructor
- Exception (const Exception & xpt);
- // assignment operator
- Exception & operator= (const Exception & xpt);
- // get exception description
- virtual const char * what(void);
-
- // debug version of constructor
- Exception (ExceptionID & expID, RESULT rslt, const char * fil, int lin);
- // set source file and line of exception
- void setFileLine (const char * fil, int lin);
-
- // get description in string
- std::string & getDesc (void) throw() { return m_desc; }
-
- // report exception
- virtual void report (void);
-
- // get exception id
- ExceptionID * getID (void) throw() { return m_expID; }
-
- /// last exception description
- static std::string m_lastError;
-
- /// log file name
- static const char * m_logFile;
-
-protected:
- // exception identification
- ExceptionID * m_expID;
- // RESULT code
- RESULT m_hRslt;
-
- // exception description
- std::string m_desc;
-
- // set exception description
- virtual void setXptDesc (void);
-
- // copy exception
- void copy (const Exception & xpt);
-
- // file name where exception was thrown
- std::string m_fileName;
- // line number in file
- int m_line;
-
-};
-
-extern ExpDesc MaterialNotAvailDesc;
-extern ExpDesc ImageSizesNotMatchDesc;
-extern ExpDesc ImageHasExportsDesc;
-extern ExpDesc InvalidColorChannelDesc;
-extern ExpDesc InvalidImageModeDesc;
-extern ExpDesc SceneInvalidDesc;
-extern ExpDesc CameraInvalidDesc;
-extern ExpDesc ObserverInvalidDesc;
-extern ExpDesc OffScreenInvalidDesc;
-extern ExpDesc MirrorInvalidDesc;
-extern ExpDesc MirrorSizeInvalidDesc;
-extern ExpDesc MirrorNormalInvalidDesc;
-extern ExpDesc MirrorHorizontalDesc;
-extern ExpDesc MirrorTooSmallDesc;
-extern ExpDesc SourceVideoEmptyDesc;
-extern ExpDesc SourceVideoCreationDesc;
-extern ExpDesc DeckLinkBadDisplayModeDesc;
-extern ExpDesc DeckLinkBadPixelFormatDesc;
-extern ExpDesc AutoDetectionNotAvailDesc;
-extern ExpDesc DeckLinkOpenCardDesc;
-extern ExpDesc DeckLinkBadFormatDesc;
-extern ExpDesc DeckLinkInternalErrorDesc;
-extern ExpDesc SourceVideoOnlyCaptureDesc;
-extern ExpDesc VideoDeckLinkBadFormatDesc;
-extern ExpDesc VideoDeckLinkOpenCardDesc;
-extern ExpDesc VideoDeckLinkDvpInternalErrorDesc;
-extern ExpDesc VideoDeckLinkPinMemoryErrorDesc;
-
-extern ExceptionID InvalidImageMode;
-
-void registerAllExceptions(void);
-#endif
diff --git a/source/gameengine/VideoTexture/FilterBase.cpp b/source/gameengine/VideoTexture/FilterBase.cpp
deleted file mode 100644
index b41a2095890..00000000000
--- a/source/gameengine/VideoTexture/FilterBase.cpp
+++ /dev/null
@@ -1,160 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/FilterBase.cpp
- * \ingroup bgevideotex
- */
-
-
-#include "FilterBase.h"
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-
-// FilterBase class implementation
-
-// constructor
-FilterBase::FilterBase (void) : m_previous(NULL) {}
-
-
-// destructor
-FilterBase::~FilterBase (void)
-{
- // release Python objects, if not released yet
- release();
-}
-
-
-// release python objects
-void FilterBase::release (void)
-{
- // release previous filter object
- setPrevious(NULL);
-}
-
-
-// set new previous filter
-void FilterBase::setPrevious(PyFilter *filt, bool useRefCnt)
-{
- // if reference counting has to be used
- if (useRefCnt)
- {
- // reference new filter
- if (filt != NULL) Py_INCREF(filt);
- // release old filter
- Py_XDECREF(m_previous);
- }
- // set new previous filter
- m_previous = filt;
-}
-
-
-// find first filter
-FilterBase * FilterBase::findFirst (void)
-{
- // find first filter in chain
- FilterBase * frst;
- for (frst = this; frst->m_previous != NULL; frst = frst->m_previous->m_filter) {};
- // set first filter
- return frst;
-}
-
-
-
-// list offilter types
-PyTypeList pyFilterTypes;
-
-
-
-// functions for python interface
-
-
-// object allocation
-PyObject *Filter_allocNew (PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- // allocate object
- PyFilter *self = reinterpret_cast<PyFilter*>(type->tp_alloc(type, 0));
- // initialize object structure
- self->m_filter = NULL;
- // return allocated object
- return reinterpret_cast<PyObject*>(self);
-}
-
-// object deallocation
-void Filter_dealloc(PyFilter *self)
-{
- // release object attributes
- if (self->m_filter != NULL)
- {
- self->m_filter->release();
- delete self->m_filter;
- self->m_filter = NULL;
- }
- Py_TYPE((PyObject *)self)->tp_free((PyObject *)self);
-}
-
-
-// get previous pixel filter object
-PyObject *Filter_getPrevious (PyFilter *self, void *closure)
-{
- // if filter object is available
- if (self->m_filter != NULL)
- {
- // pixel filter object
- PyObject *filt = reinterpret_cast<PyObject*>(self->m_filter->getPrevious());
- // if filter is present
- if (filt != NULL)
- {
- // return it
- Py_INCREF(filt);
- return filt;
- }
- }
- // otherwise return none
- Py_RETURN_NONE;
-}
-
-
-// set previous pixel filter object
-int Filter_setPrevious(PyFilter *self, PyObject *value, void *closure)
-{
- // if filter object is available
- if (self->m_filter != NULL)
- {
- // check new value
- if (value == NULL || !pyFilterTypes.in(Py_TYPE(value)))
- {
- // report value error
- PyErr_SetString(PyExc_TypeError, "Invalid type of value");
- return -1;
- }
- // set new value
- self->m_filter->setPrevious(reinterpret_cast<PyFilter*>(value));
- }
- // return success
- return 0;
-}
diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h
deleted file mode 100644
index db688d551d0..00000000000
--- a/source/gameengine/VideoTexture/FilterBase.h
+++ /dev/null
@@ -1,161 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file FilterBase.h
- * \ingroup bgevideotex
- */
-
-#ifndef __FILTERBASE_H__
-#define __FILTERBASE_H__
-
-#include "Common.h"
-
-#include "EXP_PyObjectPlus.h"
-
-#include "PyTypeList.h"
-
-#define VT_C(v,idx) ((unsigned char*)&v)[idx]
-#define VT_R(v) ((unsigned char*)&v)[0]
-#define VT_G(v) ((unsigned char*)&v)[1]
-#define VT_B(v) ((unsigned char*)&v)[2]
-#define VT_A(v) ((unsigned char*)&v)[3]
-#define VT_RGBA(v,r,g,b,a) VT_R(v)=(unsigned char)r, VT_G(v)=(unsigned char)g, VT_B(v)=(unsigned char)b, VT_A(v)=(unsigned char)a
-
-#ifdef __BIG_ENDIAN__
-# define VT_SWAPBR(i) ((((i) >> 16) & 0xFF00) + (((i) & 0xFF00) << 16) + ((i) & 0xFF00FF))
-#else
-# define VT_SWAPBR(i) ((((i) & 0xFF) << 16) + (((i) >> 16) & 0xFF) + ((i) & 0xFF00FF00))
-#endif
-
-
-// forward declaration
-class FilterBase;
-
-
-// python structure for filter
-struct PyFilter
-{
- PyObject_HEAD
- // source object
- FilterBase * m_filter;
-};
-
-
-/// base class for pixel filters
-class FilterBase
-{
-public:
- /// constructor
- FilterBase (void);
- /// destructor
- virtual ~FilterBase (void);
- // release python objects
- virtual void release (void);
-
- /// convert pixel
- template <class SRC> unsigned int convert (SRC src, short x, short y,
- short * size, unsigned int pixSize)
- {
- return filter(src, x, y, size, pixSize,
- convertPrevious(src, x, y, size, pixSize));
- }
-
- /// get previous filter
- PyFilter * getPrevious (void) { return m_previous; }
- /// set previous filter
- void setPrevious (PyFilter *filt, bool useRefCnt = true);
-
- /// find first filter in chain
- FilterBase * findFirst (void);
-
- /// get first filter's source pixel size
- unsigned int firstPixelSize (void) { return findFirst()->getPixelSize(); }
-
-protected:
- /// previous pixel filter
- PyFilter * m_previous;
-
- /// filter pixel, source byte buffer
- virtual unsigned int filter(unsigned char *src, short x, short y,
- short *size, unsigned int pixSize, unsigned int val = 0)
- { return val; }
- /// filter pixel, source int buffer
- virtual unsigned int filter(unsigned int *src, short x, short y,
- short *size, unsigned int pixSize, unsigned int val = 0)
- { return val; }
- /// filter pixel, source float buffer
- virtual unsigned int filter(float *src, short x, short y,
- short *size, unsigned int pixSize, unsigned int val = 0)
- { return val; }
-
- /// get source pixel size
- virtual unsigned int getPixelSize(void) { return 1; }
-
- /// get converted pixel from previous filters
- template <class SRC> unsigned int convertPrevious (SRC src, short x, short y,
- short * size, unsigned int pixSize)
- {
- // if previous filter doesn't exists, return source pixel
- if (m_previous == NULL) return *src;
- // otherwise return converted pixel
- return m_previous->m_filter->convert(src, x, y, size, pixSize);
- }
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("GE:FilterBase")
-#endif
-};
-
-
-// list of python filter types
-extern PyTypeList pyFilterTypes;
-
-
-// functions for python interface
-
-// object initialization
-template <class T> static int Filter_init (PyObject *pySelf, PyObject *args, PyObject *kwds)
-{
- PyFilter *self = reinterpret_cast<PyFilter*>(pySelf);
- // create filter object
- if (self->m_filter != NULL) delete self->m_filter;
- self->m_filter = new T();
- // initialization succeded
- return 0;
-}
-
-// object allocation
-PyObject *Filter_allocNew(PyTypeObject *type, PyObject *args, PyObject *kwds);
-// object deallocation
-void Filter_dealloc(PyFilter *self);
-
-// get previous pixel filter object
-PyObject *Filter_getPrevious(PyFilter *self, void *closure);
-// set previous pixel filter object
-int Filter_setPrevious(PyFilter *self, PyObject *value, void *closure);
-
-
-#endif
diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp
deleted file mode 100644
index a25d09e1eee..00000000000
--- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp
+++ /dev/null
@@ -1,190 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/FilterBlueScreen.cpp
- * \ingroup bgevideotex
- */
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "FilterBlueScreen.h"
-
-#include "FilterBase.h"
-#include "PyTypeList.h"
-
-// implementation FilterBlueScreen
-
-// constructor
-FilterBlueScreen::FilterBlueScreen (void)
-{
- // set color to blue
- setColor(0, 0, 255);
- // set limits
- setLimits(64, 64);
-}
-
-// set color
-void FilterBlueScreen::setColor (unsigned char red, unsigned char green, unsigned char blue)
-{
- m_color[0] = red;
- m_color[1] = green;
- m_color[2] = blue;
-}
-
-// set limits for color variation
-void FilterBlueScreen::setLimits (unsigned short minLimit, unsigned short maxLimit)
-{
- m_limits[0] = minLimit;
- m_limits[1] = maxLimit > minLimit ? maxLimit : minLimit;
- // calculate square values
- for (short idx = 0; idx < 2; ++idx)
- m_squareLimits[idx] = m_limits[idx] * m_limits[idx];
- // limits distance
- m_limitDist = m_squareLimits[1] - m_squareLimits[0];
-}
-
-
-
-// cast Filter pointer to FilterBlueScreen
-inline FilterBlueScreen * getFilter (PyFilter *self)
-{ return static_cast<FilterBlueScreen*>(self->m_filter); }
-
-
-// python methods and get/sets
-
-// get color
-static PyObject *getColor (PyFilter *self, void *closure)
-{
- return Py_BuildValue("[BBB]", getFilter(self)->getColor()[0],
- getFilter(self)->getColor()[1], getFilter(self)->getColor()[2]);
-}
-
-// set color
-static int setColor(PyFilter *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL ||
- !(PyTuple_Check(value) || PyList_Check(value)) ||
- PySequence_Fast_GET_SIZE(value) != 3 ||
- !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) ||
- !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)) ||
- !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2)))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 3 ints");
- return -1;
- }
- // set color
- getFilter(self)->setColor(
- (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
- (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1))),
- (unsigned char)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2))));
- // success
- return 0;
-}
-
-// get limits
-static PyObject *getLimits (PyFilter *self, void *closure)
-{
- return Py_BuildValue("[II]", getFilter(self)->getLimits()[0],
- getFilter(self)->getLimits()[1]);
-}
-
-// set limit
-static int setLimits(PyFilter *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL ||
- !(PyTuple_Check(value) || PyList_Check(value)) ||
- PySequence_Fast_GET_SIZE(value) != 2 ||
- !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) ||
- !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
- return -1;
- }
- // set limits
- getFilter(self)->setLimits(
- (unsigned short)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
- (unsigned short)(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1))));
- // success
- return 0;
-}
-
-
-// attributes structure
-static PyGetSetDef filterBSGetSets[] =
-{
- {(char*)"color", (getter)getColor, (setter)setColor, (char*)"blue screen color", NULL},
- {(char*)"limits", (getter)getLimits, (setter)setLimits, (char*)"blue screen color limits", NULL},
- // attributes from FilterBase class
- {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
- {NULL}
-};
-
-// define python type
-PyTypeObject FilterBlueScreenType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.FilterBlueScreen", /*tp_name*/
- sizeof(PyFilter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Filter_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Filter for Blue Screen objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- NULL, /* tp_methods */
- 0, /* tp_members */
- filterBSGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Filter_init<FilterBlueScreen>, /* tp_init */
- 0, /* tp_alloc */
- Filter_allocNew, /* tp_new */
-};
-
diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.h b/source/gameengine/VideoTexture/FilterBlueScreen.h
deleted file mode 100644
index cf74a6705b7..00000000000
--- a/source/gameengine/VideoTexture/FilterBlueScreen.h
+++ /dev/null
@@ -1,105 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of blendTex library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file FilterBlueScreen.h
- * \ingroup bgevideotex
- */
-
-#ifndef __FILTERBLUESCREEN_H__
-#define __FILTERBLUESCREEN_H__
-
-#include "Common.h"
-
-#include "FilterBase.h"
-
-
-/// pixel filter for blue screen
-class FilterBlueScreen : public FilterBase
-{
-public:
- /// constructor
- FilterBlueScreen (void);
- /// destructor
- virtual ~FilterBlueScreen (void) {}
-
- /// get color
- unsigned char * getColor (void) { return m_color; }
- /// set color
- void setColor (unsigned char red, unsigned char green, unsigned char blue);
-
- /// get limits for color variation
- unsigned short * getLimits (void) { return m_limits; }
- /// set limits for color variation
- void setLimits (unsigned short minLimit, unsigned short maxLimit);
-
-protected:
- /// blue screen color (red component first)
- unsigned char m_color[3];
- /// limits for color variation - first defines, where ends fully transparent
- /// color, second defines, where begins fully opaque color
- unsigned short m_limits[2];
- /// squared limits for color variation
- unsigned int m_squareLimits[2];
- /// distance between squared limits
- unsigned int m_limitDist;
-
- /// filter pixel template, source int buffer
- template <class SRC> unsigned int tFilter (SRC src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- {
- // calculate differences
- int difRed = int(VT_R(val)) - int(m_color[0]);
- int difGreen = int(VT_G(val)) - int(m_color[1]);
- int difBlue = int(VT_B(val)) - int(m_color[2]);
- // calc distance from "blue screen" color
- unsigned int dist = (unsigned int)(difRed * difRed + difGreen * difGreen
- + difBlue * difBlue);
- // condition for fully transparent color
- if (m_squareLimits[0] >= dist)
- // return color with zero alpha
- VT_A(val) = 0;
- // condition for fully opaque color
- else if (m_squareLimits[1] <= dist)
- // return normal color
- VT_A(val) = 0xFF;
- // otherwise calc alpha
- else
- VT_A(val) = (((dist - m_squareLimits[0]) << 8) / m_limitDist);
- return val;
- }
-
- /// virtual filtering function for byte source
- virtual unsigned int filter (unsigned char *src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
- /// virtual filtering function for unsigned int source
- virtual unsigned int filter (unsigned int *src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
-};
-
-
-#endif
diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp
deleted file mode 100644
index 15a7e9e4cd1..00000000000
--- a/source/gameengine/VideoTexture/FilterColor.cpp
+++ /dev/null
@@ -1,354 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/FilterColor.cpp
- * \ingroup bgevideotex
- */
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "FilterColor.h"
-
-#include "FilterBase.h"
-#include "PyTypeList.h"
-
-// implementation FilterGray
-
-// attributes structure
-static PyGetSetDef filterGrayGetSets[] =
-{ // attributes from FilterBase class
- {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
- {NULL}
-};
-
-// define python type
-PyTypeObject FilterGrayType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.FilterGray", /*tp_name*/
- sizeof(PyFilter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Filter_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Filter for grayscale effect", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- NULL, /* tp_methods */
- 0, /* tp_members */
- filterGrayGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Filter_init<FilterGray>, /* tp_init */
- 0, /* tp_alloc */
- Filter_allocNew, /* tp_new */
-};
-
-
-// implementation FilterColor
-
-// constructor
-FilterColor::FilterColor (void)
-{
- // reset color matrix to identity
- for (int r = 0; r < 4; ++r)
- for (int c = 0; c < 5; ++c)
- m_matrix[r][c] = (r == c) ? 256 : 0;
-}
-
-// set color matrix
-void FilterColor::setMatrix (ColorMatrix & mat)
-{
- // copy matrix
- for (int r = 0; r < 4; ++r)
- for (int c = 0; c < 5; ++c)
- m_matrix[r][c] = mat[r][c];
-}
-
-
-
-// cast Filter pointer to FilterColor
-inline FilterColor * getFilterColor (PyFilter *self)
-{ return static_cast<FilterColor*>(self->m_filter); }
-
-
-// python methods and get/sets
-
-// get color matrix
-static PyObject *getMatrix (PyFilter *self, void *closure)
-{
- ColorMatrix & mat = getFilterColor(self)->getMatrix();
- return Py_BuildValue("((hhhhh)(hhhhh)(hhhhh)(hhhhh))",
- mat[0][0], mat[0][1], mat[0][2], mat[0][3], mat[0][4],
- mat[1][0], mat[1][1], mat[1][2], mat[1][3], mat[1][4],
- mat[2][0], mat[2][1], mat[2][2], mat[2][3], mat[2][4],
- mat[3][0], mat[3][1], mat[3][2], mat[3][3], mat[3][4]);
-}
-
-// set color matrix
-static int setMatrix(PyFilter *self, PyObject *value, void *closure)
-{
- // matrix to store items
- ColorMatrix mat;
- // check validity of parameter
- bool valid = value != NULL && PySequence_Check(value)
- && PySequence_Size(value) == 4;
- // check rows
- for (int r = 0; valid && r < 4; ++r)
- {
- // get row object
- PyObject *row = PySequence_Fast_GET_ITEM(value, r);
- // check sequence
- valid = PySequence_Check(row) && PySequence_Size(row) == 5;
- // check items
- for (int c = 0; valid && c < 5; ++c)
- {
- // item must be int
- valid = PyLong_Check(PySequence_Fast_GET_ITEM(row, c));
- // if it is valid, save it in matrix
- if (valid)
- mat[r][c] = short(PyLong_AsLong(PySequence_Fast_GET_ITEM(row, c)));
- }
- }
- // if parameter is not valid, report error
- if (!valid)
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a matrix [4][5] of ints");
- return -1;
- }
- // set color matrix
- getFilterColor(self)->setMatrix(mat);
- // success
- return 0;
-}
-
-
-// attributes structure
-static PyGetSetDef filterColorGetSets[] =
-{
- {(char*)"matrix", (getter)getMatrix, (setter)setMatrix, (char*)"matrix [4][5] for color calculation", NULL},
- // attributes from FilterBase class
- {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
- {NULL}
-};
-
-// define python type
-PyTypeObject FilterColorType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.FilterColor", /*tp_name*/
- sizeof(PyFilter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Filter_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Filter for color calculations", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- NULL, /* tp_methods */
- 0, /* tp_members */
- filterColorGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Filter_init<FilterColor>, /* tp_init */
- 0, /* tp_alloc */
- Filter_allocNew, /* tp_new */
-};
-
-// implementation FilterLevel
-
-// constructor
-FilterLevel::FilterLevel (void)
-{
- // reset color levels
- for (int r = 0; r < 4; ++r)
- {
- levels[r][0] = 0;
- levels[r][1] = 0xFF;
- levels[r][2] = 0xFF;
- }
-}
-
-// set color levels
-void FilterLevel::setLevels (ColorLevel & lev)
-{
- // copy levels
- for (int r = 0; r < 4; ++r)
- {
- for (int c = 0; c < 2; ++c)
- levels[r][c] = lev[r][c];
- levels[r][2] = lev[r][0] < lev[r][1] ? lev[r][1] - lev[r][0] : 1;
- }
-}
-
-
-// cast Filter pointer to FilterLevel
-inline FilterLevel * getFilterLevel (PyFilter *self)
-{ return static_cast<FilterLevel*>(self->m_filter); }
-
-
-// python methods and get/sets
-
-// get color levels
-static PyObject *getLevels (PyFilter *self, void *closure)
-{
- ColorLevel & lev = getFilterLevel(self)->getLevels();
- return Py_BuildValue("((HH)(HH)(HH)(HH))",
- lev[0][0], lev[0][1], lev[1][0], lev[1][1],
- lev[2][0], lev[2][1], lev[3][0], lev[3][1]);
-}
-
-// set color levels
-static int setLevels(PyFilter *self, PyObject *value, void *closure)
-{
- // matrix to store items
- ColorLevel lev;
- // check validity of parameter
- bool valid = value != NULL && PySequence_Check(value)
- && PySequence_Size(value) == 4;
- // check rows
- for (int r = 0; valid && r < 4; ++r)
- {
- // get row object
- PyObject *row = PySequence_Fast_GET_ITEM(value, r);
- // check sequence
- valid = PySequence_Check(row) && PySequence_Size(row) == 2;
- // check items
- for (int c = 0; valid && c < 2; ++c)
- {
- // item must be int
- valid = PyLong_Check(PySequence_Fast_GET_ITEM(row, c));
- // if it is valid, save it in matrix
- if (valid)
- lev[r][c] = (unsigned short)(PyLong_AsLong(PySequence_Fast_GET_ITEM(row, c)));
- }
- }
- // if parameter is not valid, report error
- if (!valid)
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a matrix [4][2] of ints");
- return -1;
- }
- // set color matrix
- getFilterLevel(self)->setLevels(lev);
- // success
- return 0;
-}
-
-
-// attributes structure
-static PyGetSetDef filterLevelGetSets[] =
-{
- {(char*)"levels", (getter)getLevels, (setter)setLevels, (char*)"levels matrix [4] (min, max)", NULL},
- // attributes from FilterBase class
- {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
- {NULL}
-};
-
-// define python type
-PyTypeObject FilterLevelType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.FilterLevel", /*tp_name*/
- sizeof(PyFilter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Filter_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Filter for levels calculations", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- NULL, /* tp_methods */
- 0, /* tp_members */
- filterLevelGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Filter_init<FilterLevel>, /* tp_init */
- 0, /* tp_alloc */
- Filter_allocNew, /* tp_new */
-};
-
diff --git a/source/gameengine/VideoTexture/FilterColor.h b/source/gameengine/VideoTexture/FilterColor.h
deleted file mode 100644
index d042863d7e8..00000000000
--- a/source/gameengine/VideoTexture/FilterColor.h
+++ /dev/null
@@ -1,176 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of blendTex library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file FilterColor.h
- * \ingroup bgevideotex
- */
-
-#ifndef __FILTERCOLOR_H__
-#define __FILTERCOLOR_H__
-
-#include "Common.h"
-
-#include "FilterBase.h"
-
-
-/// pixel filter for grayscale
-class FilterGray : public FilterBase
-{
-public:
- /// constructor
- FilterGray (void) {}
- /// destructor
- virtual ~FilterGray (void) {}
-
-protected:
- /// filter pixel template, source int buffer
- template <class SRC> unsigned int tFilter (SRC src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- {
- // calculate gray value
- unsigned int gray = (28 * (VT_B(val)) + 151 * (VT_G(val))
- + 77 * (VT_R(val))) >> 8;
- // return grayscale value
- VT_R(val) = gray;
- VT_G(val) = gray;
- VT_B(val) = gray;
- return val;
- }
-
- /// virtual filtering function for byte source
- virtual unsigned int filter (unsigned char * src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
- /// virtual filtering function for unsigned int source
- virtual unsigned int filter (unsigned int * src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
-};
-
-
-/// type for color matrix
-typedef short ColorMatrix[4][5];
-
-/// pixel filter for color calculation
-class FilterColor : public FilterBase
-{
-public:
- /// constructor
- FilterColor (void);
- /// destructor
- virtual ~FilterColor (void) {}
-
- /// get color matrix
- ColorMatrix & getMatrix (void) { return m_matrix; }
- /// set color matrix
- void setMatrix (ColorMatrix & mat);
-
-protected:
- /// color calculation matrix
- ColorMatrix m_matrix;
-
- /// calculate one color component
- unsigned char calcColor (unsigned int val, short idx)
- {
- return (((m_matrix[idx][0] * (VT_R(val)) + m_matrix[idx][1] * (VT_G(val)) +
- m_matrix[idx][2] * (VT_B(val)) + m_matrix[idx][3] * (VT_A(val)) +
- m_matrix[idx][4]) >> 8) & 0xFF);
- }
-
- /// filter pixel template, source int buffer
- template <class SRC> unsigned int tFilter (SRC src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- {
- // return calculated color
- int color;
- VT_RGBA(color, calcColor(val, 0), calcColor(val, 1), calcColor(val, 2), calcColor(val, 3));
- return color;
- }
-
- /// virtual filtering function for byte source
- virtual unsigned int filter (unsigned char * src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
- /// virtual filtering function for unsigned int source
- virtual unsigned int filter (unsigned int * src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
-};
-
-
-/// type for color levels
-typedef unsigned short ColorLevel[4][3];
-
-/// pixel filter for color calculation
-class FilterLevel : public FilterBase
-{
-public:
- /// constructor
- FilterLevel (void);
- /// destructor
- virtual ~FilterLevel (void) {}
-
- /// get color matrix
- ColorLevel & getLevels (void) { return levels; }
- /// set color matrix
- void setLevels (ColorLevel & lev);
-
-protected:
- /// color calculation matrix
- ColorLevel levels;
-
- /// calculate one color component
- unsigned int calcColor (unsigned int val, short idx)
- {
- unsigned int col = VT_C(val,idx);
- if (col <= levels[idx][0]) col = 0;
- else if (col >= levels[idx][1]) col = 0xFF;
- else col = (((col - levels[idx][0]) << 8) / levels[idx][2]) & 0xFF;
- return col;
- }
-
- /// filter pixel template, source int buffer
- template <class SRC> unsigned int tFilter (SRC src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- {
- // return calculated color
- int color;
- VT_RGBA(color, calcColor(val, 0), calcColor(val, 1), calcColor(val, 2), calcColor(val, 3));
- return color;
- }
-
- /// virtual filtering function for byte source
- virtual unsigned int filter (unsigned char * src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
- /// virtual filtering function for unsigned int source
- virtual unsigned int filter (unsigned int * src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
-};
-
-
-#endif
diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp
deleted file mode 100644
index 3a5333710fd..00000000000
--- a/source/gameengine/VideoTexture/FilterNormal.cpp
+++ /dev/null
@@ -1,173 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/FilterNormal.cpp
- * \ingroup bgevideotex
- */
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "FilterNormal.h"
-
-#include "FilterBase.h"
-#include "PyTypeList.h"
-
-// implementation FilterNormal
-
-// constructor
-FilterNormal::FilterNormal (void) : m_colIdx(0)
-{
- // set default depth
- setDepth(4);
-}
-
-// set color shift
-void FilterNormal::setColor (unsigned short colIdx)
-{
- // check validity of index
- if (colIdx < 3)
- // set color shift
- m_colIdx = colIdx;
-}
-
-// set depth
-void FilterNormal::setDepth (float depth)
-{
- m_depth = depth;
- m_depthScale = depth / depthScaleKoef;
-}
-
-
-// cast Filter pointer to FilterNormal
-inline FilterNormal * getFilter (PyFilter *self)
-{ return static_cast<FilterNormal*>(self->m_filter); }
-
-
-// python methods and get/sets
-
-// get index of color used to calculate normal
-static PyObject *getColor (PyFilter *self, void *closure)
-{
- return Py_BuildValue("H", getFilter(self)->getColor());
-}
-
-// set index of color used to calculate normal
-static int setColor(PyFilter *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL || !PyLong_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "filt.colorIdx = int: VideoTexture.FilterNormal, expected the value must be a int");
- return -1;
- }
- // set color index
- getFilter(self)->setColor((unsigned short)(PyLong_AsLong(value)));
- // success
- return 0;
-}
-
-
-// get depth
-static PyObject *getDepth (PyFilter *self, void *closure)
-{
- return Py_BuildValue("f", getFilter(self)->getDepth());
-}
-
-// set depth
-static int setDepth(PyFilter *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value)
- {
- float depth= (float)PyFloat_AsDouble(value);
- if ((depth==-1 && PyErr_Occurred()) == 0) /* no error converting to a float? */
- {
- // set depth
- getFilter(self)->setDepth(depth);
- // success
- return 0;
- }
- }
-
- PyErr_SetString(PyExc_TypeError, "filt.depth = float: VideoTexture.FilterNormal, expected the value must be a float");
- return -1;
-}
-
-
-// attributes structure
-static PyGetSetDef filterNormalGetSets[] =
-{
- {(char*)"colorIdx", (getter)getColor, (setter)setColor, (char*)"index of color used to calculate normal (0 - red, 1 - green, 2 - blue)", NULL},
- {(char*)"depth", (getter)getDepth, (setter)setDepth, (char*)"depth of relief", NULL},
- // attributes from FilterBase class
- {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
- {NULL}
-};
-
-// define python type
-PyTypeObject FilterNormalType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.FilterNormal", /*tp_name*/
- sizeof(PyFilter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Filter_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Filter for Blue Screen objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- NULL, /* tp_methods */
- 0, /* tp_members */
- filterNormalGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Filter_init<FilterNormal>, /* tp_init */
- 0, /* tp_alloc */
- Filter_allocNew, /* tp_new */
-};
-
diff --git a/source/gameengine/VideoTexture/FilterNormal.h b/source/gameengine/VideoTexture/FilterNormal.h
deleted file mode 100644
index 951ecb84d9d..00000000000
--- a/source/gameengine/VideoTexture/FilterNormal.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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of blendTex library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file FilterNormal.h
- * \ingroup bgevideotex
- */
-
-#ifndef __FILTERNORMAL_H__
-#define __FILTERNORMAL_H__
-
-#include "Common.h"
-
-#include "FilterBase.h"
-
-
-// scale constants for normals
-const float depthScaleKoef = 255.0;
-const float normScaleKoef = float(depthScaleKoef / 2.0);
-
-
-/// pixel filter for normal mapping
-class FilterNormal : public FilterBase
-{
-public:
- /// constructor
- FilterNormal (void);
- /// destructor
- virtual ~FilterNormal (void) {}
-
- /// get index of color used to calculate normals
- unsigned short getColor (void) { return m_colIdx; }
- /// set index of color used to calculate normals
- void setColor (unsigned short colIdx);
-
- /// get depth
- float getDepth (void) { return m_depth; }
- /// set depth
- void setDepth (float depth);
-
-protected:
- /// depth of normal relief
- float m_depth;
- /// scale to calculate normals
- float m_depthScale;
-
- /// color index, 0=red, 1=green, 2=blue, 3=alpha
- unsigned short m_colIdx;
-
- /// filter pixel, source int buffer
- template <class SRC> unsigned int tFilter (SRC *src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- {
- // get value of required color
- int actPix = int(VT_C(val,m_colIdx));
- int upPix = actPix;
- int leftPix = actPix;
- // get upper and left pixel from actual pixel
- if (y > 0)
- {
- val = convertPrevious(src - pixSize * size[0], x, y - 1, size, pixSize);
- upPix = VT_C(val,m_colIdx);
- }
- if (x > 0)
- {
- val = convertPrevious(src - pixSize, x - 1, y, size, pixSize);
- leftPix = VT_C(val,m_colIdx);
- }
- // height differences (from blue color)
- float dx = (actPix - leftPix) * m_depthScale;
- float dy = (actPix - upPix) * m_depthScale;
- // normalize vector
- float dz = float(normScaleKoef / sqrt(dx * dx + dy * dy + 1.0));
- dx = dx * dz + normScaleKoef;
- dy = dy * dz + normScaleKoef;
- dz += normScaleKoef;
- // return normal vector converted to color
- VT_RGBA(val, dx, dy, dz, 0xFF);
- return val;
- }
-
- /// filter pixel, source byte buffer
- virtual unsigned int filter (unsigned char * src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
- /// filter pixel, source int buffer
- virtual unsigned int filter (unsigned int * src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- { return tFilter(src, x, y, size, pixSize, val); }
-};
-
-
-#endif
diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp
deleted file mode 100644
index c8faa1f9f07..00000000000
--- a/source/gameengine/VideoTexture/FilterSource.cpp
+++ /dev/null
@@ -1,176 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/FilterSource.cpp
- * \ingroup bgevideotex
- */
-
-// implementation
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "FilterSource.h"
-
-#include "FilterBase.h"
-#include "PyTypeList.h"
-
-
-// FilterRGB24
-
-// define python type
-PyTypeObject FilterRGB24Type =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.FilterRGB24", /*tp_name*/
- sizeof(PyFilter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Filter_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Source filter RGB24 objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- NULL, /* tp_methods */
- 0, /* tp_members */
- NULL, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Filter_init<FilterRGB24>, /* tp_init */
- 0, /* tp_alloc */
- Filter_allocNew, /* tp_new */
-};
-
-// FilterRGBA32
-
-// define python type
-PyTypeObject FilterRGBA32Type =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.FilterRGBA32", /*tp_name*/
- sizeof(PyFilter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Filter_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Source filter RGBA32 objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- NULL, /* tp_methods */
- 0, /* tp_members */
- NULL, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Filter_init<FilterRGBA32>, /* tp_init */
- 0, /* tp_alloc */
- Filter_allocNew, /* tp_new */
-};
-
-// FilterBGR24
-
-// define python type
-PyTypeObject FilterBGR24Type =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.FilterBGR24", /*tp_name*/
- sizeof(PyFilter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Filter_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Source filter BGR24 objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- NULL, /* tp_methods */
- 0, /* tp_members */
- NULL, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Filter_init<FilterBGR24>, /* tp_init */
- 0, /* tp_alloc */
- Filter_allocNew, /* tp_new */
-};
-
diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h
deleted file mode 100644
index 820576dfff9..00000000000
--- a/source/gameengine/VideoTexture/FilterSource.h
+++ /dev/null
@@ -1,352 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of blendTex library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file FilterSource.h
- * \ingroup bgevideotex
- */
-
-#ifndef __FILTERSOURCE_H__
-#define __FILTERSOURCE_H__
-
-#include "Common.h"
-
-#include "FilterBase.h"
-
-/// class for RGB24 conversion
-class FilterRGB24 : public FilterBase
-{
-public:
- /// constructor
- FilterRGB24 (void) {}
- /// destructor
- virtual ~FilterRGB24 (void) {}
-
- /// get source pixel size
- virtual unsigned int getPixelSize (void) { return 3; }
-
-protected:
- /// filter pixel, source byte buffer
- virtual unsigned int filter (unsigned char *src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- { VT_RGBA(val,src[0],src[1],src[2],0xFF); return val; }
-};
-
-/// class for RGBA32 conversion
-class FilterRGBA32 : public FilterBase
-{
-public:
- /// constructor
- FilterRGBA32 (void) {}
- /// destructor
- virtual ~FilterRGBA32 (void) {}
-
- /// get source pixel size
- virtual unsigned int getPixelSize (void) { return 4; }
-
-protected:
- /// filter pixel, source byte buffer
- virtual unsigned int filter (unsigned char *src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- {
- if ((intptr_t(src)&0x3) == 0)
- return *(unsigned int*)src;
- else
- {
- VT_RGBA(val,src[0],src[1],src[2],src[3]);
- return val;
- }
- }
-};
-
-/// class for BGRA32 conversion
-class FilterBGRA32 : public FilterBase
-{
-public:
- /// constructor
- FilterBGRA32 (void) {}
- /// destructor
- virtual ~FilterBGRA32 (void) {}
-
- /// get source pixel size
- virtual unsigned int getPixelSize (void) { return 4; }
-
-protected:
- /// filter pixel, source byte buffer
- virtual unsigned int filter(
- unsigned char *src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- {
- VT_RGBA(val,src[2],src[1],src[0],src[3]);
- return val;
- }
-};
-
-
-/// class for BGR24 conversion
-class FilterBGR24 : public FilterBase
-{
-public:
- /// constructor
- FilterBGR24 (void) {}
- /// destructor
- virtual ~FilterBGR24 (void) {}
-
- /// get source pixel size
- virtual unsigned int getPixelSize (void) { return 3; }
-
-protected:
- /// filter pixel, source byte buffer
- virtual unsigned int filter (unsigned char *src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- { VT_RGBA(val,src[2],src[1],src[0],0xFF); return val; }
-};
-
-/// class for Z_buffer conversion
-class FilterZZZA : public FilterBase
-{
-public:
- /// constructor
- FilterZZZA (void) {}
- /// destructor
- virtual ~FilterZZZA (void) {}
-
- /// get source pixel size
- virtual unsigned int getPixelSize (void) { return 1; }
-
-protected:
- /// filter pixel, source float buffer
- virtual unsigned int filter (float *src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- {
- // calculate gray value
- // convert float to unsigned char
- unsigned int depth = int(src[0] * 255);
- // return depth scale value
- VT_R(val) = depth;
- VT_G(val) = depth;
- VT_B(val) = depth;
- VT_A(val) = 0xFF;
-
- return val;
- }
-};
-
-
-/// class for Z_buffer conversion
-class FilterDEPTH : public FilterBase
-{
-public:
- /// constructor
- FilterDEPTH (void) {}
- /// destructor
- virtual ~FilterDEPTH (void) {}
-
- /// get source pixel size
- virtual unsigned int getPixelSize (void) { return 1; }
-
-protected:
- /// filter pixel, source float buffer
- virtual unsigned int filter (float *src, short x, short y,
- short *size, unsigned int pixSize, unsigned int val)
- {
- /* Copy the float value straight away
- * The user can retrieve the original float value by using
- * 'F' mode in BGL buffer */
- memcpy(&val, src, sizeof (unsigned int));
- return val;
- }
-};
-
-
-
-
-/// class for YV12 conversion
-class FilterYV12 : public FilterBase
-{
-public:
- /// constructor
- FilterYV12 (void): m_buffV(NULL), m_buffU(NULL), m_pitchUV(0) {}
- /// destructor
- virtual ~FilterYV12 (void) {}
-
- /// get source pixel size
- virtual unsigned int getPixelSize (void) { return 1; }
-
- /// set pointers to color buffers
- void setBuffs (unsigned char * buff, short * size)
- {
- unsigned int buffSize = size[0] * size[1];
- m_buffV = buff + buffSize;
- m_buffU = m_buffV + (buffSize >> 2);
- m_pitchUV = size[0] >> 1;
- }
-
-protected:
- /// begin of V buffer
- unsigned char * m_buffV;
- /// begin of U buffer
- unsigned char * m_buffU;
- /// pitch for V & U buffers
- short m_pitchUV;
-
- /// interpolation function
- int interpol (int a, int b, int c, int d)
- { return (9 * (b + c) - a - d + 8) >> 4; }
-
- /// common horizontal interpolation
- int interpolH (unsigned char *src)
- { return interpol(*(src-1), *src, *(src+1), *(src+2)); }
-
- /// common vertical interpolation
- int interpolV (unsigned char *src)
- { return interpol(*(src-m_pitchUV), *src, *(src+m_pitchUV), *(src+2*m_pitchUV)); }
-
- /// common joined vertical and horizontal interpolation
- int interpolVH (unsigned char *src)
- {
- return interpol(interpolV(src-1), interpolV(src), interpolV(src+1),
- interpolV(src+2));
- }
-
- /// is pixel on edge
- bool isEdge (short x, short y, const short size[2])
- { return x <= 1 || x >= size[0] - 4 || y <= 1 || y >= size[1] - 4; }
-
- /// get the first parameter on the low edge
- unsigned char * interParA (unsigned char *src, short x, short size, short shift)
- { return x > 1 ? src - shift : src; }
- /// get the third parameter on the high edge
- unsigned char * interParC (unsigned char *src, short x, short size, short shift)
- { return x < size - 2 ? src + shift : src; }
- /// get the fourth parameter on the high edge
- unsigned char * interParD (unsigned char *src, short x, short size, short shift)
- { return x < size - 4 ? src + 2 * shift : x < size - 2 ? src + shift : src; }
-
- /// horizontal interpolation on edges
- int interpolEH (unsigned char *src, short x, short size)
- {
- return interpol(*interParA(src, x, size, 1), *src,
- *interParC(src, x, size, 1), *interParD(src, x, size, 1));
- }
-
- /// vertical interpolation on edges
- int interpolEV (unsigned char *src, short y, short size)
- {
- return interpol(*interParA(src, y, size, m_pitchUV), *src,
- *interParC(src, y, size, m_pitchUV), *interParD(src, y, size, m_pitchUV));
- }
-
- /// joined vertical and horizontal interpolation on edges
- int interpolEVH (unsigned char *src, short x, short y, short * size)
- {
- return interpol(interpolEV(interParA(src, x, size[0], 1), y, size[1]),
- interpolEV(src, y, size[1]), interpolEV(interParC(src, x, size[0], 1), y, size[1]),
- interpolEV(interParD(src, x, size[0], 1), y, size[1]));
- }
-
-
- /// filter pixel, source byte buffer
- virtual unsigned int filter (unsigned char *src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val)
- {
- // V & U offset
- long offset = (x >> 1) + m_pitchUV * (y >> 1);
- // get modified YUV -> CDE: C = Y - 16; D = U - 128; E = V - 128
- int c = *src - 16;
- int d = m_buffU[offset] - 128;
- int e = m_buffV[offset] - 128;
- // if horizontal interpolation is needed
- if ((x & 1) == 1) {
- // if vertical interpolation is needed too
- if ((y & 1) == 1)
- {
- // if this pixel is on the edge
- if (isEdge(x, y, size))
- {
- // get U & V from edge
- d = interpolEVH(m_buffU + offset, x, y, size) - 128;
- e = interpolEVH(m_buffV + offset, x, y, size) - 128;
- }
- // otherwise get U & V from inner range
- else
- {
- d = interpolVH(m_buffU + offset) - 128;
- e = interpolVH(m_buffV + offset) - 128;
- }
- // otherwise use horizontal interpolation only
- }
- else {
- // if this pixel is on the edge
- if (isEdge(x, y, size))
- {
- // get U & V from edge
- d = interpolEH(m_buffU + offset, x, size[0]) - 128;
- e = interpolEH(m_buffV + offset, x, size[0]) - 128;
- }
- // otherwise get U & V from inner range
- else
- {
- d = interpolH(m_buffU + offset) - 128;
- e = interpolH(m_buffV + offset) - 128;
- }
- // otherwise if only vertical interpolation is needed
- }
- }
- else if ((y & 1) == 1) {
- // if this pixel is on the edge
- if (isEdge(x, y, size))
- {
- // get U & V from edge
- d = interpolEV(m_buffU + offset, y, size[1]) - 128;
- e = interpolEV(m_buffV + offset, y, size[1]) - 128;
- }
- // otherwise get U & V from inner range
- else
- {
- d = interpolV(m_buffU + offset) - 128;
- e = interpolV(m_buffV + offset) - 128;
- }
- }
- // convert to RGB
- // R = clip(( 298 * C + 409 * E + 128) >> 8)
- // G = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8)
- // B = clip(( 298 * C + 516 * D + 128) >> 8)
- int red = (298 * c + 409 * e + 128) >> 8;
- if (red >= 0x100) red = 0xFF;
- else if (red < 0) red = 0;
- int green = (298 * c - 100 * d - 208 * e) >> 8;
- if (green >= 0x100) green = 0xFF;
- else if (green < 0) green = 0;
- int blue = (298 * c + 516 * d + 128) >> 8;
- if (blue >= 0x100) blue = 0xFF;
- else if (blue < 0) blue = 0;
- // return result
- VT_RGBA(val, red, green, blue, 0xFF);
- return val;
- }
-};
-
-#endif /* __FILTERSOURCE_H__ */
diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp
deleted file mode 100644
index a547d2a7a85..00000000000
--- a/source/gameengine/VideoTexture/ImageBase.cpp
+++ /dev/null
@@ -1,834 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/ImageBase.cpp
- * \ingroup bgevideotex
- */
-
-#include "ImageBase.h"
-extern "C" {
-#include "bgl.h"
-}
-
-#include <vector>
-#include <string.h>
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "FilterBase.h"
-
-#include "Exception.h"
-
-#if (defined(WIN32) || defined(WIN64))
-#define strcasecmp _stricmp
-#endif
-
-// ImageBase class implementation
-
-ExceptionID ImageHasExports;
-ExceptionID InvalidColorChannel;
-ExceptionID InvalidImageMode;
-
-ExpDesc ImageHasExportsDesc(ImageHasExports, "Image has exported buffers, cannot resize");
-ExpDesc InvalidColorChannelDesc(InvalidColorChannel, "Invalid or too many color channels specified. At most 4 values within R, G, B, A, 0, 1");
-ExpDesc InvalidImageModeDesc(InvalidImageMode, "Invalid image mode, only RGBA and BGRA are supported");
-
-// constructor
-ImageBase::ImageBase (bool staticSrc) : m_image(NULL), m_imgSize(0),
-m_avail(false), m_scale(false), m_scaleChange(false), m_flip(false),
-m_zbuff(false),
-m_depth(false),
-m_staticSources(staticSrc), m_pyfilter(NULL)
-{
- m_size[0] = m_size[1] = 0;
- m_exports = 0;
-}
-
-
-// destructor
-ImageBase::~ImageBase (void)
-{
- // release image
- if (m_image)
- delete [] m_image;
-}
-
-
-// release python objects
-bool ImageBase::release (void)
-{
- // iterate sources
- for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
- {
- // release source object
- delete *it;
- *it = NULL;
- }
- // release filter object
- Py_XDECREF(m_pyfilter);
- m_pyfilter = NULL;
- return true;
-}
-
-
-// get image
-unsigned int * ImageBase::getImage (unsigned int texId, double ts)
-{
- // if image is not available
- if (!m_avail)
- {
- // if there are any sources
- if (!m_sources.empty())
- {
- // get images from sources
- for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
- // get source image
- (*it)->getImage(ts);
- // init image
- init(m_sources[0]->getSize()[0], m_sources[0]->getSize()[1]);
- }
- // calculate new image
- calcImage(texId, ts);
- }
- // if image is available, return it, otherwise NULL
- return m_avail ? m_image : NULL;
-}
-
-bool ImageBase::loadImage(unsigned int *buffer, unsigned int size, unsigned int format, double ts)
-{
- unsigned int *d, *s, v, len;
- if (getImage(0, ts) != NULL && size >= getBuffSize()) {
- switch (format) {
- case GL_RGBA:
- memcpy(buffer, m_image, getBuffSize());
- break;
- case GL_BGRA:
- len = (unsigned int)m_size[0] * m_size[1];
- for (s=m_image, d=buffer; len; len--) {
- v = *s++;
- *d++ = VT_SWAPBR(v);
- }
- break;
- default:
- THRWEXCP(InvalidImageMode,S_OK);
- }
- return true;
- }
- return false;
-}
-
-// refresh image source
-void ImageBase::refresh (void)
-{
- // invalidate this image
- m_avail = false;
- // refresh all sources
- for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
- (*it)->refresh();
-}
-
-
-// get source object
-PyImage * ImageBase::getSource (const char *id)
-{
- // find source
- ImageSourceList::iterator src = findSource(id);
- // return it, if found
- return src != m_sources.end() ? (*src)->getSource() : NULL;
-}
-
-
-// set source object
-bool ImageBase::setSource (const char *id, PyImage *source)
-{
- // find source
- ImageSourceList::iterator src = findSource(id);
- // check source loop
- if (source != NULL && source->m_image->loopDetect(this))
- return false;
- // if found, set new object
- if (src != m_sources.end())
- // if new object is not empty or sources are static
- if (source != NULL || m_staticSources)
- // replace previous source
- (*src)->setSource(source);
- // otherwise delete source
- else
- m_sources.erase(src);
- // if source is not found and adding is allowed
- else
- if (!m_staticSources)
- {
- // create new source
- ImageSource * newSrc = newSource(id);
- newSrc->setSource(source);
- // if source was created, add it to source list
- if (newSrc != NULL) m_sources.push_back(newSrc);
- }
- // otherwise source wasn't set
- else
- return false;
- // source was set
- return true;
-}
-
-
-// set pixel filter
-void ImageBase::setFilter (PyFilter * filt)
-{
- // reference new filter
- if (filt != NULL) Py_INCREF(filt);
- // release previous filter
- Py_XDECREF(m_pyfilter);
- // set new filter
- m_pyfilter = filt;
-}
-
-void ImageBase::swapImageBR()
-{
- unsigned int size, v, *s;
-
- if (m_avail) {
- size = 1 * m_size[0] * m_size[1];
- for (s=m_image; size; size--) {
- v = *s;
- *s++ = VT_SWAPBR(v);
- }
- }
-}
-
-// initialize image data
-void ImageBase::init (short width, short height)
-{
- // if image has to be scaled
- if (m_scale)
- {
- // recalc sizes of image
- width = calcSize(width);
- height = calcSize(height);
- }
- // if sizes differ
- if (width != m_size[0] || height != m_size[1])
- {
- if (m_exports > 0)
- THRWEXCP(ImageHasExports,S_OK);
-
- // new buffer size
- unsigned int newSize = width * height;
- // if new buffer is larger than previous
- if (newSize > m_imgSize)
- {
- // set new buffer size
- m_imgSize = newSize;
- // release previous and create new buffer
- if (m_image)
- delete [] m_image;
- m_image = new unsigned int[m_imgSize];
- }
- // new image size
- m_size[0] = width;
- m_size[1] = height;
- // scale was processed
- m_scaleChange = false;
- }
-}
-
-
-// find source
-ImageSourceList::iterator ImageBase::findSource (const char *id)
-{
- // iterate sources
- ImageSourceList::iterator it;
- for (it = m_sources.begin(); it != m_sources.end(); ++it)
- // if id matches, return iterator
- if ((*it)->is(id)) return it;
- // source not found
- return it;
-}
-
-
-// check sources sizes
-bool ImageBase::checkSourceSizes (void)
-{
- // reference size
- short * refSize = NULL;
- // iterate sources
- for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
- {
- // get size of current source
- short * curSize = (*it)->getSize();
- // if size is available and is not empty
- if (curSize[0] != 0 && curSize[1] != 0) {
- // if reference size is not set
- if (refSize == NULL) {
- // set current size as reference
- refSize = curSize;
- // otherwise check with current size
- }
- else if (curSize[0] != refSize[0] || curSize[1] != refSize[1]) {
- // if they don't match, report it
- return false;
- }
- }
- }
- // all sizes match
- return true;
-}
-
-
-// compute nearest power of 2 value
-short ImageBase::calcSize (short size)
-{
- // while there is more than 1 bit in size value
- while ((size & (size - 1)) != 0)
- // clear last bit
- size = size & (size - 1);
- // return result
- return size;
-}
-
-
-// perform loop detection
-bool ImageBase::loopDetect (ImageBase * img)
-{
- // if this object is the same as parameter, loop is detected
- if (this == img) return true;
- // check all sources
- for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
- // if source detected loop, return this result
- if ((*it)->getSource() != NULL && (*it)->getSource()->m_image->loopDetect(img))
- return true;
- // no loop detected
- return false;
-}
-
-
-// ImageSource class implementation
-
-// constructor
-ImageSource::ImageSource (const char *id) : m_source(NULL), m_image(NULL)
-{
- // copy id
- int idx;
- for (idx = 0; id[idx] != '\0' && idx < SourceIdSize - 1; ++idx)
- m_id[idx] = id[idx];
- m_id[idx] = '\0';
-}
-
-// destructor
-ImageSource::~ImageSource (void)
-{
- // release source
- setSource(NULL);
-}
-
-
-// compare id
-bool ImageSource::is (const char *id)
-{
- for (char *myId = m_id; *myId != '\0'; ++myId, ++id)
- if (*myId != *id) return false;
- return *id == '\0';
-}
-
-
-// set source object
-void ImageSource::setSource (PyImage *source)
-{
- // reference new source
- if (source != NULL) Py_INCREF(source);
- // release previous source
- Py_XDECREF(m_source);
- // set new source
- m_source = source;
-}
-
-
-// get image from source
-unsigned int * ImageSource::getImage (double ts)
-{
- // if source is available
- if (m_source != NULL)
- // get image from source
- m_image = m_source->m_image->getImage(0, ts);
- // otherwise reset buffer
- else
- m_image = NULL;
- // return image
- return m_image;
-}
-
-
-// refresh source
-void ImageSource::refresh (void)
-{
- // if source is available, refresh it
- if (m_source != NULL) m_source->m_image->refresh();
-}
-
-
-
-// list of image types
-PyTypeList pyImageTypes;
-
-
-
-// functions for python interface
-
-// object allocation
-PyObject *Image_allocNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- // allocate object
- PyImage *self = reinterpret_cast<PyImage*>(type->tp_alloc(type, 0));
- // initialize object structure
- self->m_image = NULL;
- // return allocated object
- return reinterpret_cast<PyObject*>(self);
-}
-
-// object deallocation
-void Image_dealloc(PyImage *self)
-{
- // release object attributes
- if (self->m_image != NULL)
- {
- if (self->m_image->m_exports > 0)
- {
- PyErr_SetString(PyExc_SystemError,
- "deallocated Image object has exported buffers");
- PyErr_Print();
- }
- // if release requires deleting of object, do it
- if (self->m_image->release())
- delete self->m_image;
- self->m_image = NULL;
- }
- Py_TYPE((PyObject *)self)->tp_free((PyObject *)self);
-}
-
-// get image data
-PyObject *Image_getImage(PyImage *self, char *mode)
-{
- try
- {
- unsigned int * image = self->m_image->getImage();
- if (image)
- {
- // build BGL buffer
- int dimensions = self->m_image->getBuffSize();
- Buffer * buffer;
- if (mode == NULL || !strcasecmp(mode, "RGBA"))
- {
- buffer = BGL_MakeBuffer( GL_BYTE, 1, &dimensions, image);
- }
- else if (!strcasecmp(mode, "F"))
- {
- // this mode returns the image as an array of float.
- // This makes sense ONLY for the depth buffer:
- // source = VideoTexture.ImageViewport()
- // source.depth = True
- // depth = VideoTexture.imageToArray(source, 'F')
-
- // adapt dimension from byte to float
- dimensions /= sizeof(float);
- buffer = BGL_MakeBuffer( GL_FLOAT, 1, &dimensions, image);
- }
- else
- {
- int i, c, ncolor, pixels;
- int offset[4];
- unsigned char *s, *d;
- // scan the mode to get the channels requested, no more than 4
- for (i=ncolor=0; mode[i] != 0 && ncolor < 4; i++)
- {
- switch (toupper(mode[i]))
- {
- case 'R':
- offset[ncolor++] = 0;
- break;
- case 'G':
- offset[ncolor++] = 1;
- break;
- case 'B':
- offset[ncolor++] = 2;
- break;
- case 'A':
- offset[ncolor++] = 3;
- break;
- case '0':
- offset[ncolor++] = -1;
- break;
- case '1':
- offset[ncolor++] = -2;
- break;
- // if you add more color code, change the switch further down
- default:
- THRWEXCP(InvalidColorChannel,S_OK);
- }
- }
- if (mode[i] != 0) {
- THRWEXCP(InvalidColorChannel,S_OK);
- }
- // first get the number of pixels
- pixels = dimensions / 4;
- // multiple by the number of channels, each is one byte
- dimensions = pixels * ncolor;
- // get an empty buffer
- buffer = BGL_MakeBuffer( GL_BYTE, 1, &dimensions, NULL);
- // and fill it
- for (i = 0, d = (unsigned char *)buffer->buf.asbyte, s = (unsigned char *)image;
- i < pixels;
- i++, d += ncolor, s += 4)
- {
- for (c=0; c<ncolor; c++)
- {
- switch (offset[c])
- {
- case 0: d[c] = s[0]; break;
- case 1: d[c] = s[1]; break;
- case 2: d[c] = s[2]; break;
- case 3: d[c] = s[3]; break;
- case -1: d[c] = 0; break;
- case -2: d[c] = 0xFF; break;
- }
- }
- }
- }
- return (PyObject *)buffer;
- }
- }
- catch (Exception & exp)
- {
- exp.report();
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
-// get image size
-PyObject *Image_getSize (PyImage *self, void *closure)
-{
- return Py_BuildValue("(hh)", self->m_image->getSize()[0],
- self->m_image->getSize()[1]);
-}
-
-// refresh image
-PyObject *Image_refresh (PyImage *self, PyObject *args)
-{
- Py_buffer buffer;
- bool done = true;
- char *mode = NULL;
- double ts = -1.0;
- unsigned int format;
-
- memset(&buffer, 0, sizeof(buffer));
- if (PyArg_ParseTuple(args, "|s*sd:refresh", &buffer, &mode, &ts)) {
- if (buffer.buf) {
- // a target buffer is provided, verify its format
- if (buffer.readonly) {
- PyErr_SetString(PyExc_TypeError, "Buffers passed in argument must be writable");
- }
- else if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- PyErr_SetString(PyExc_TypeError, "Buffers passed in argument must be contiguous in memory");
- }
- else if (((intptr_t)buffer.buf & 3) != 0) {
- PyErr_SetString(PyExc_TypeError, "Buffers passed in argument must be aligned to 4 bytes boundary");
- }
- else {
- // ready to get the image into our buffer
- try {
- if (mode == NULL || !strcmp(mode, "RGBA"))
- format = GL_RGBA;
- else if (!strcmp(mode, "BGRA"))
- format = GL_BGRA;
- else
- THRWEXCP(InvalidImageMode,S_OK);
-
- done = self->m_image->loadImage((unsigned int *)buffer.buf, buffer.len, format, ts);
- }
- catch (Exception & exp) {
- exp.report();
- }
- }
- PyBuffer_Release(&buffer);
- if (PyErr_Occurred()) {
- return NULL;
- }
- }
- }
- else {
- return NULL;
- }
-
- self->m_image->refresh();
- if (done)
- Py_RETURN_TRUE;
- Py_RETURN_FALSE;
-}
-
-// get scale
-PyObject *Image_getScale (PyImage *self, void *closure)
-{
- if (self->m_image != NULL && self->m_image->getScale()) Py_RETURN_TRUE;
- else Py_RETURN_FALSE;
-}
-
-// set scale
-int Image_setScale(PyImage *self, PyObject *value, void *closure)
-{
- // check parameter, report failure
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- // set scale
- if (self->m_image != NULL) self->m_image->setScale(value == Py_True);
- // success
- return 0;
-}
-
-// get flip
-PyObject *Image_getFlip (PyImage *self, void *closure)
-{
- if (self->m_image != NULL && self->m_image->getFlip()) Py_RETURN_TRUE;
- else Py_RETURN_FALSE;
-}
-
-// set flip
-int Image_setFlip(PyImage *self, PyObject *value, void *closure)
-{
- // check parameter, report failure
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- // set scale
- if (self->m_image != NULL) self->m_image->setFlip(value == Py_True);
- // success
- return 0;
-}
-
-// get zbuff
-PyObject *Image_getZbuff(PyImage *self, void *closure)
-{
- if (self->m_image != NULL && self->m_image->getZbuff()) Py_RETURN_TRUE;
- else Py_RETURN_FALSE;
-}
-
-// set zbuff
-int Image_setZbuff(PyImage *self, PyObject *value, void *closure)
-{
- // check parameter, report failure
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- // set scale
- if (self->m_image != NULL) self->m_image->setZbuff(value == Py_True);
- // success
- return 0;
-}
-
-// get depth
-PyObject *Image_getDepth(PyImage *self, void *closure)
-{
- if (self->m_image != NULL && self->m_image->getDepth()) Py_RETURN_TRUE;
- else Py_RETURN_FALSE;
-}
-
-// set depth
-int Image_setDepth(PyImage *self, PyObject *value, void *closure)
-{
- // check parameter, report failure
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- // set scale
- if (self->m_image != NULL) self->m_image->setDepth(value == Py_True);
- // success
- return 0;
-}
-
-
-
-
-// get filter source object
-PyObject *Image_getSource(PyImage *self, PyObject *args)
-{
- // get arguments
- char *id;
- if (!PyArg_ParseTuple(args, "s:getSource", &id))
- return NULL;
- if (self->m_image != NULL)
- {
- // get source object
- PyObject *src = reinterpret_cast<PyObject*>(self->m_image->getSource(id));
- // if source is available
- if (src != NULL)
- {
- // return source
- Py_INCREF(src);
- return src;
- }
- }
- // source was not found
- Py_RETURN_NONE;
-}
-
-
-// set filter source object
-PyObject *Image_setSource(PyImage *self, PyObject *args)
-{
- // get arguments
- char *id;
- PyObject *obj;
- if (!PyArg_ParseTuple(args, "sO:setSource", &id, &obj))
- return NULL;
- if (self->m_image != NULL)
- {
- // check type of object
- if (pyImageTypes.in(Py_TYPE(obj)))
- {
- // convert to image struct
- PyImage * img = reinterpret_cast<PyImage*>(obj);
- // set source
- if (!self->m_image->setSource(id, img))
- {
- // if not set, retport error
- PyErr_SetString(PyExc_RuntimeError, "Invalid source or id");
- return NULL;
- }
- }
- // else report error
- else
- {
- PyErr_SetString(PyExc_RuntimeError, "Invalid type of object");
- return NULL;
- }
- }
- // return none
- Py_RETURN_NONE;
-}
-
-
-// get pixel filter object
-PyObject *Image_getFilter(PyImage *self, void *closure)
-{
- // if image object is available
- if (self->m_image != NULL)
- {
- // pixel filter object
- PyObject *filt = reinterpret_cast<PyObject*>(self->m_image->getFilter());
- // if filter is present
- if (filt != NULL)
- {
- // return it
- Py_INCREF(filt);
- return filt;
- }
- }
- // otherwise return none
- Py_RETURN_NONE;
-}
-
-
-// set pixel filter object
-int Image_setFilter(PyImage *self, PyObject *value, void *closure)
-{
- // if image object is available
- if (self->m_image != NULL)
- {
- // check new value
- if (value == NULL || !pyFilterTypes.in(Py_TYPE(value)))
- {
- // report value error
- PyErr_SetString(PyExc_TypeError, "Invalid type of value");
- return -1;
- }
- // set new value
- self->m_image->setFilter(reinterpret_cast<PyFilter*>(value));
- }
- // return success
- return 0;
-}
-PyObject *Image_valid(PyImage *self, void *closure)
-{
- if (self->m_image->isImageAvailable())
- {
- Py_RETURN_TRUE;
- }
- else
- {
- Py_RETURN_FALSE;
- }
-}
-
-static int Image_getbuffer(PyImage *self, Py_buffer *view, int flags)
-{
- unsigned int * image;
- int ret;
-
- try {
- // can throw in case of resize
- image = self->m_image->getImage();
- }
- catch (Exception & exp) {
- exp.report();
- return -1;
- }
-
- if (!image) {
- PyErr_SetString(PyExc_BufferError, "Image buffer is not available");
- return -1;
- }
- if (view == NULL)
- {
- self->m_image->m_exports++;
- return 0;
- }
- ret = PyBuffer_FillInfo(view, (PyObject *)self, image, self->m_image->getBuffSize(), 0, flags);
- if (ret >= 0)
- self->m_image->m_exports++;
- return ret;
-}
-
-static void Image_releaseBuffer(PyImage *self, Py_buffer *buffer)
-{
- self->m_image->m_exports--;
-}
-
-PyBufferProcs imageBufferProcs =
-{
- (getbufferproc)Image_getbuffer,
- (releasebufferproc)Image_releaseBuffer
-};
-
diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h
deleted file mode 100644
index 5a09c9a67b3..00000000000
--- a/source/gameengine/VideoTexture/ImageBase.h
+++ /dev/null
@@ -1,392 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of blendTex library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ImageBase.h
- * \ingroup bgevideotex
- */
-
-#ifndef __IMAGEBASE_H__
-#define __IMAGEBASE_H__
-
-#include "Common.h"
-
-#include <vector>
-#include "EXP_PyObjectPlus.h"
-
-#include "PyTypeList.h"
-
-#include "FilterBase.h"
-
-#include "GPU_glew.h"
-
-// forward declarations
-struct PyImage;
-class ImageSource;
-
-
-/// type for list of image sources
-typedef std::vector<ImageSource*> ImageSourceList;
-
-
-/// base class for image filters
-class ImageBase
-{
-public:
- /// constructor
- ImageBase (bool staticSrc = false);
- /// destructor
- virtual ~ImageBase(void);
- /// release contained objects, if returns true, object should be deleted
- virtual bool release(void);
-
- /// is an image available
- bool isImageAvailable(void)
- { return m_avail; }
- /// get image
- unsigned int *getImage(unsigned int texId = 0, double timestamp=-1.0);
- /// get image size
- short * getSize(void) { return m_size; }
- /// get image buffer size
- unsigned long getBuffSize(void)
- { return m_size[0] * m_size[1] * sizeof(unsigned int); }
- /// refresh image - invalidate its current content
- virtual void refresh(void);
-
- /// get scale
- bool getScale(void) { return m_scale; }
- /// set scale
- void setScale(bool scale) { m_scale = scale; m_scaleChange = true; }
- /// get vertical flip
- bool getFlip(void) { return m_flip; }
- /// set vertical flip
- void setFlip(bool flip) { m_flip = flip; }
- /// get Z buffer
- bool getZbuff(void) { return m_zbuff; }
- /// set Z buffer
- void setZbuff(bool zbuff) { m_zbuff = zbuff; }
- /// get depth
- bool getDepth(void) { return m_depth; }
- /// set depth
- void setDepth(bool depth) { m_depth = depth; }
-
- /// get source object
- PyImage * getSource(const char *id);
- /// set source object, return true, if source was set
- bool setSource(const char *id, PyImage *source);
-
- /// get pixel filter
- PyFilter * getFilter(void) { return m_pyfilter; }
- /// set pixel filter
- void setFilter(PyFilter * filt);
-
- /// calculate size(nearest power of 2)
- static short calcSize(short size);
-
- /// calculate image from sources and send it to a target buffer instead of a texture
- /// format is GL_RGBA or GL_BGRA
- virtual bool loadImage(unsigned int *buffer, unsigned int size, unsigned int format, double ts);
-
- /// swap the B and R channel in-place in the image buffer
- void swapImageBR();
-
- /// number of buffer pointing to m_image, public because not handled by this class
- int m_exports;
-
-protected:
- /// image buffer
- unsigned int * m_image;
- /// image buffer size
- unsigned int m_imgSize;
- /// image size
- short m_size[2];
- /// image is available
- bool m_avail;
-
- /// scale image to power 2 sizes
- bool m_scale;
- /// scale was changed
- bool m_scaleChange;
- /// flip image vertically
- bool m_flip;
- /// use the Z buffer as a texture
- bool m_zbuff;
- /// extract the Z buffer with unisgned int precision
- bool m_depth;
-
- /// source image list
- ImageSourceList m_sources;
- /// flag for disabling addition and deletion of sources
- bool m_staticSources;
-
- /// pixel filter
- PyFilter * m_pyfilter;
-
- /// initialize image data
- void init(short width, short height);
-
- /// find source
- ImageSourceList::iterator findSource(const char *id);
-
- /// create new source
- virtual ImageSource *newSource(const char *id) { return NULL; }
-
- /// check source sizes
- bool checkSourceSizes(void);
-
- /// calculate image from sources and set its availability
- virtual void calcImage(unsigned int texId, double ts) {}
-
- /// perform loop detection
- bool loopDetect(ImageBase * img);
-
- /// template for image conversion
- template<class FLT, class SRC> void convImage(FLT & filter, SRC srcBuff,
- short * srcSize)
- {
- // destination buffer
- unsigned int * dstBuff = m_image;
- // pixel size from filter
- unsigned int pixSize = filter.firstPixelSize();
- // if no scaling is needed
- if (srcSize[0] == m_size[0] && srcSize[1] == m_size[1])
- // if flipping isn't required
- if (!m_flip)
- // copy bitmap
- for (short y = 0; y < m_size[1]; ++y)
- for (short x = 0; x < m_size[0]; ++x, ++dstBuff, srcBuff += pixSize)
- // copy pixel
- *dstBuff = filter.convert(srcBuff, x, y, srcSize, pixSize);
- // otherwise flip image top to bottom
- else
- {
- // go to last row of image
- srcBuff += srcSize[0] * (srcSize[1] - 1) * pixSize;
- // copy bitmap
- for (short y = m_size[1] - 1; y >= 0; --y, srcBuff -= 2 * srcSize[0] * pixSize)
- for (short x = 0; x < m_size[0]; ++x, ++dstBuff, srcBuff += pixSize)
- // copy pixel
- *dstBuff = filter.convert(srcBuff, x, y, srcSize, pixSize);
- }
- // else scale picture (nearest neighbor)
- else
- {
- // interpolation accumulator
- int accHeight = srcSize[1] >> 1;
- // if flipping is required
- if (m_flip)
- // go to last row of image
- srcBuff += srcSize[0] * (srcSize[1] - 1) * pixSize;
- // process image rows
- for (int y = 0; y < srcSize[1]; ++y)
- {
- // increase height accum
- accHeight += m_size[1];
- // if pixel row has to be drawn
- if (accHeight >= srcSize[1])
- {
- // decrease accum
- accHeight -= srcSize[1];
- // width accum
- int accWidth = srcSize[0] >> 1;
- // process row
- for (int x = 0; x < srcSize[0]; ++x)
- {
- // increase width accum
- accWidth += m_size[0];
- // if pixel has to be drawn
- if (accWidth >= srcSize[0])
- {
- // decrease accum
- accWidth -= srcSize[0];
- // convert pixel
- *dstBuff = filter.convert(srcBuff, x, m_flip ? srcSize[1] - y - 1 : y,
- srcSize, pixSize);
- // next pixel
- ++dstBuff;
- }
- // shift source pointer
- srcBuff += pixSize;
- }
- }
- // if pixel row will not be drawn
- else
- // move source pointer to next row
- srcBuff += pixSize * srcSize[0];
- // if y flipping is required
- if (m_flip)
- // go to previous row of image
- srcBuff -= 2 * pixSize * srcSize[0];
- }
- }
- }
-
- // template for specific filter preprocessing
- template <class F, class SRC> void filterImage (F & filt, SRC srcBuff, short *srcSize)
- {
- // find first filter in chain
- FilterBase * firstFilter = NULL;
- if (m_pyfilter != NULL) firstFilter = m_pyfilter->m_filter->findFirst();
- // if first filter is available
- if (firstFilter != NULL)
- {
- // python wrapper for filter
- PyFilter pyFilt;
- pyFilt.m_filter = &filt;
- // set specified filter as first in chain
- firstFilter->setPrevious(&pyFilt, false);
- // convert video image
- convImage(*(m_pyfilter->m_filter), srcBuff, srcSize);
- // delete added filter
- firstFilter->setPrevious(NULL, false);
- }
- // otherwise use given filter for conversion
- else convImage(filt, srcBuff, srcSize);
- // source was processed
- m_avail = true;
- }
-};
-
-
-// python structure for image filter
-struct PyImage
-{
- PyObject_HEAD
- // source object
- ImageBase * m_image;
-};
-
-
-// size of id
-const int SourceIdSize = 32;
-
-
-/// class for source of image
-class ImageSource
-{
-public:
- /// constructor
- ImageSource (const char *id);
- /// destructor
- virtual ~ImageSource (void);
-
- /// get id
- const char * getId (void) { return m_id; }
- /// compare id to argument
- bool is (const char *id);
-
- /// get source object
- PyImage * getSource (void) { return m_source; }
- /// set source object
- void setSource (PyImage *source);
-
- /// get image from source
- unsigned int * getImage (double ts=-1.0);
- /// get buffered image
- unsigned int * getImageBuf (void) { return m_image; }
- /// refresh source
- void refresh (void);
-
- /// get image size
- short * getSize (void)
- {
- static short defSize [] = {0, 0};
- return m_source != NULL ? m_source->m_image->getSize() : defSize;
- }
-
-protected:
- /// id of source
- char m_id [SourceIdSize];
- /// pointer to source structure
- PyImage * m_source;
- /// buffered image from source
- unsigned int * m_image;
-
-private:
- /// default constructor is forbidden
- ImageSource (void) {}
-};
-
-// list of python image types
-extern PyTypeList pyImageTypes;
-
-
-// functions for python interface
-
-// object initialization
-template <class T> static int Image_init(PyObject *pySelf, PyObject *args, PyObject *kwds)
-{
- PyImage *self = reinterpret_cast<PyImage *>(pySelf);
- // create source object
- if (self->m_image != NULL) delete self->m_image;
- self->m_image = new T();
- // initialization succeded
- return 0;
-}
-
-// object allocation
-PyObject *Image_allocNew(PyTypeObject *type, PyObject *args, PyObject *kwds);
-// object deallocation
-void Image_dealloc(PyImage *self);
-
-// get image data
-PyObject *Image_getImage(PyImage *self, char *mode);
-// get image size
-PyObject *Image_getSize(PyImage *self, void *closure);
-// refresh image - invalidate current content
-PyObject *Image_refresh(PyImage *self, PyObject *args);
-
-// get scale
-PyObject *Image_getScale(PyImage *self, void *closure);
-// set scale
-int Image_setScale(PyImage *self, PyObject *value, void *closure);
-// get flip
-PyObject *Image_getFlip(PyImage *self, void *closure);
-// set flip
-int Image_setFlip(PyImage *self, PyObject *value, void *closure);
-
-// get filter source object
-PyObject *Image_getSource(PyImage *self, PyObject *args);
-// set filter source object
-PyObject *Image_setSource(PyImage *self, PyObject *args);
-// get Z buffer
-PyObject *Image_getZbuff(PyImage *self, void *closure);
-// set Z buffer
-int Image_setZbuff(PyImage *self, PyObject *value, void *closure);
-// get depth
-PyObject *Image_getDepth(PyImage *self, void *closure);
-// set depth
-int Image_setDepth(PyImage *self, PyObject *value, void *closure);
-
-// get pixel filter object
-PyObject *Image_getFilter(PyImage *self, void *closure);
-// set pixel filter object
-int Image_setFilter(PyImage *self, PyObject *value, void *closure);
-// check if a buffer can be extracted
-PyObject *Image_valid(PyImage *self, void *closure);
-// for buffer access to PyImage objects
-extern PyBufferProcs imageBufferProcs;
-
-#endif
diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp
deleted file mode 100644
index 77270865b17..00000000000
--- a/source/gameengine/VideoTexture/ImageBuff.cpp
+++ /dev/null
@@ -1,424 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/ImageBuff.cpp
- * \ingroup bgevideotex
- */
-
-// implementation
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "ImageBuff.h"
-#include "Exception.h"
-#include "ImageBase.h"
-#include "FilterSource.h"
-
-// use ImBuf API for image manipulation
-extern "C" {
-#include "IMB_imbuf_types.h"
-#include "IMB_imbuf.h"
-#include "bgl.h"
-};
-
-// default filter
-FilterRGB24 defFilter;
-
-// forward declaration;
-extern PyTypeObject ImageBuffType;
-
-static int ImageBuff_init(PyObject *pySelf, PyObject *args, PyObject *kwds)
-{
- short width = -1;
- short height = -1;
- unsigned char color = 0;
- PyObject *py_scale = Py_False;
- ImageBuff *image;
-
- PyImage *self = reinterpret_cast<PyImage*>(pySelf);
- // create source object
- if (self->m_image != NULL)
- delete self->m_image;
- image = new ImageBuff();
- self->m_image = image;
-
- if (PyArg_ParseTuple(args, "hh|bO!:ImageBuff", &width, &height, &color, &PyBool_Type, &py_scale))
- {
- // initialize image buffer
- image->setScale(py_scale == Py_True);
- image->clear(width, height, color);
- }
- else
- {
- // check if at least one argument was passed
- if (width != -1 || height != -1)
- // yes and they didn't match => it's an error
- return -1;
- // empty argument list is okay
- PyErr_Clear();
- }
- // initialization succeded
- return 0;
-
-}
-
-ImageBuff::~ImageBuff (void)
-{
- if (m_imbuf)
- IMB_freeImBuf(m_imbuf);
-}
-
-
-// load image from buffer
-void ImageBuff::load(unsigned char *img, short width, short height)
-{
- // loading a new buffer implies to reset the imbuf if any, because the size may change
- if (m_imbuf)
- {
- IMB_freeImBuf(m_imbuf);
- m_imbuf = NULL;
- }
- // initialize image buffer
- init(width, height);
- // original size
- short orgSize[2] = {width, height};
- // is filter available
- if (m_pyfilter != NULL)
- // use it to process image
- convImage(*(m_pyfilter->m_filter), img, orgSize);
- else
- // otherwise use default filter
- convImage(defFilter, img, orgSize);
- // image is available
- m_avail = true;
-}
-
-void ImageBuff::clear(short width, short height, unsigned char color)
-{
- unsigned char *p;
- int size;
-
- // loading a new buffer implies to reset the imbuf if any, because the size may change
- if (m_imbuf)
- {
- IMB_freeImBuf(m_imbuf);
- m_imbuf = NULL;
- }
- // initialize image buffer
- init(width, height);
- // the width/height may be different due to scaling
- size = (m_size[0] * m_size[1]);
- // initialize memory with color for all channels
- memset(m_image, color, size*4);
- // and change the alpha channel
- p = &((unsigned char*)m_image)[3];
- for (; size>0; size--)
- {
- *p = 0xFF;
- p += 4;
- }
- // image is available
- m_avail = true;
-}
-
-// img must point to a array of RGBA data of size width*height
-void ImageBuff::plot(unsigned char *img, short width, short height, short x, short y, short mode)
-{
- struct ImBuf *tmpbuf;
-
- if (m_size[0] == 0 || m_size[1] == 0 || width <= 0 || height <= 0)
- return;
-
- if (!m_imbuf) {
- // allocate most basic imbuf, we will assign the rect buffer on the fly
- m_imbuf = IMB_allocImBuf(m_size[0], m_size[1], 0, 0);
- }
-
- tmpbuf = IMB_allocImBuf(width, height, 0, 0);
-
- // assign temporarily our buffer to the ImBuf buffer, we use the same format
- tmpbuf->rect = (unsigned int*)img;
- m_imbuf->rect = m_image;
- IMB_rectblend(m_imbuf, m_imbuf, tmpbuf, NULL, NULL, NULL, 0, x, y, x, y, 0, 0, width, height, (IMB_BlendMode)mode, false);
- // remove so that MB_freeImBuf will free our buffer
- m_imbuf->rect = NULL;
- tmpbuf->rect = NULL;
- IMB_freeImBuf(tmpbuf);
-}
-
-void ImageBuff::plot(ImageBuff *img, short x, short y, short mode)
-{
- if (m_size[0] == 0 || m_size[1] == 0 || img->m_size[0] == 0 || img->m_size[1] == 0)
- return;
-
- if (!m_imbuf) {
- // allocate most basic imbuf, we will assign the rect buffer on the fly
- m_imbuf = IMB_allocImBuf(m_size[0], m_size[1], 0, 0);
- }
- if (!img->m_imbuf) {
- // allocate most basic imbuf, we will assign the rect buffer on the fly
- img->m_imbuf = IMB_allocImBuf(img->m_size[0], img->m_size[1], 0, 0);
- }
- // assign temporarily our buffer to the ImBuf buffer, we use the same format
- img->m_imbuf->rect = img->m_image;
- m_imbuf->rect = m_image;
- IMB_rectblend(m_imbuf, m_imbuf, img->m_imbuf, NULL, NULL, NULL, 0, x, y, x, y, 0, 0, img->m_imbuf->x, img->m_imbuf->y, (IMB_BlendMode)mode, false);
- // remove so that MB_freeImBuf will free our buffer
- m_imbuf->rect = NULL;
- img->m_imbuf->rect = NULL;
-}
-
-
-// cast Image pointer to ImageBuff
-inline ImageBuff *getImageBuff(PyImage *self)
-{ return static_cast<ImageBuff *>(self->m_image); }
-
-
-// python methods
-
-static bool testPyBuffer(Py_buffer *buffer, int width, int height, unsigned int pixsize)
-{
- if (buffer->itemsize != 1)
- {
- PyErr_SetString(PyExc_ValueError, "Buffer must be an array of bytes");
- return false;
- }
- if (buffer->len != width*height*pixsize)
- {
- PyErr_SetString(PyExc_ValueError, "Buffer hasn't the correct size");
- return false;
- }
- // multi dimension are ok as long as there is no hole in the memory
- Py_ssize_t size = buffer->itemsize;
- for (int i=buffer->ndim-1; i>=0 ; i--)
- {
- if (buffer->suboffsets != NULL && buffer->suboffsets[i] >= 0)
- {
- PyErr_SetString(PyExc_ValueError, "Buffer must be of one block");
- return false;
- }
- if (buffer->strides != NULL && buffer->strides[i] != size)
- {
- PyErr_SetString(PyExc_ValueError, "Buffer must be of one block");
- return false;
- }
- if (i > 0)
- size *= buffer->shape[i];
- }
- return true;
-}
-
-static bool testBGLBuffer(Buffer *buffer, int width, int height, unsigned int pixsize)
-{
- unsigned int size = BGL_typeSize(buffer->type);
- for (int i=0; i<buffer->ndimensions; i++)
- {
- size *= buffer->dimensions[i];
- }
- if (size != width*height*pixsize)
- {
- PyErr_SetString(PyExc_ValueError, "Buffer hasn't the correct size");
- return false;
- }
- return true;
-}
-
-
-// load image
-static PyObject *load(PyImage *self, PyObject *args)
-{
- // parameters: string image buffer, its size, width, height
- Py_buffer buffer;
- Buffer *bglBuffer;
- short width;
- short height;
- unsigned int pixSize;
-
- // calc proper buffer size
- // use pixel size from filter
- if (self->m_image->getFilter() != NULL)
- pixSize = self->m_image->getFilter()->m_filter->firstPixelSize();
- else
- pixSize = defFilter.firstPixelSize();
-
- // parse parameters
- if (!PyArg_ParseTuple(args, "s*hh:load", &buffer, &width, &height))
- {
- PyErr_Clear();
- // check if it is BGL buffer
- if (!PyArg_ParseTuple(args, "O!hh:load", &BGL_bufferType, &bglBuffer, &width, &height))
- {
- // report error
- return NULL;
- }
- else
- {
- if (testBGLBuffer(bglBuffer, width, height, pixSize))
- {
- try
- {
- // if correct, load image
- getImageBuff(self)->load((unsigned char*)bglBuffer->buf.asvoid, width, height);
- }
- catch (Exception & exp)
- {
- exp.report();
- }
- }
- }
- }
- else
- {
- // check if buffer size is correct
- if (testPyBuffer(&buffer, width, height, pixSize))
- {
- try
- {
- // if correct, load image
- getImageBuff(self)->load((unsigned char*)buffer.buf, width, height);
- }
- catch (Exception & exp)
- {
- exp.report();
- }
- }
- PyBuffer_Release(&buffer);
- }
- if (PyErr_Occurred())
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *plot(PyImage *self, PyObject *args)
-{
- PyImage * other;
- Buffer* bglBuffer;
- Py_buffer buffer;
- //unsigned char * buff;
- //unsigned int buffSize;
- short width;
- short height;
- short x, y;
- short mode = IMB_BLEND_COPY;
-
- if (PyArg_ParseTuple(args, "s*hhhh|h:plot", &buffer, &width, &height, &x, &y, &mode))
- {
- // correct decoding, verify that buffer size is correct
- // we need a continuous memory buffer
- if (testPyBuffer(&buffer, width, height, 4))
- {
- getImageBuff(self)->plot((unsigned char*)buffer.buf, width, height, x, y, mode);
- }
- PyBuffer_Release(&buffer);
- if (PyErr_Occurred())
- return NULL;
- Py_RETURN_NONE;
- }
- PyErr_Clear();
- // try the other format
- if (PyArg_ParseTuple(args, "O!hh|h:plot", &ImageBuffType, &other, &x, &y, &mode))
- {
- getImageBuff(self)->plot(getImageBuff(other), x, y, mode);
- Py_RETURN_NONE;
- }
- PyErr_Clear();
- // try the last format (BGL buffer)
- if (!PyArg_ParseTuple(args, "O!hhhh|h:plot", &BGL_bufferType, &bglBuffer, &width, &height, &x, &y, &mode))
- {
- PyErr_SetString(PyExc_TypeError, "Expecting ImageBuff or Py buffer or BGL buffer as first argument; width, height next; postion x, y and mode as last arguments");
- return NULL;
- }
- if (testBGLBuffer(bglBuffer, width, height, 4))
- {
- getImageBuff(self)->plot((unsigned char*)bglBuffer->buf.asvoid, width, height, x, y, mode);
- }
- if (PyErr_Occurred())
- return NULL;
- Py_RETURN_NONE;
-}
-
-// methods structure
-static PyMethodDef imageBuffMethods[] = {
- {"load", (PyCFunction)load, METH_VARARGS, "Load image from buffer"},
- {"plot", (PyCFunction)plot, METH_VARARGS, "update image buffer"},
- {NULL}
-};
-// attributes structure
-static PyGetSetDef imageBuffGetSets[] = {
- // attributes from ImageBase class
- {(char*)"valid", (getter)Image_valid, NULL, (char*)"bool to tell if an image is available", NULL},
- {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
- {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
- {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL},
- {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
- {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
- {NULL}
-};
-
-
-// define python type
-PyTypeObject ImageBuffType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.ImageBuff", /*tp_name*/
- sizeof(PyImage), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Image_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Image source from image buffer", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- imageBuffMethods, /* tp_methods */
- 0, /* tp_members */
- imageBuffGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ImageBuff_init, /* tp_init */
- 0, /* tp_alloc */
- Image_allocNew, /* tp_new */
-};
-
diff --git a/source/gameengine/VideoTexture/ImageBuff.h b/source/gameengine/VideoTexture/ImageBuff.h
deleted file mode 100644
index 19299506747..00000000000
--- a/source/gameengine/VideoTexture/ImageBuff.h
+++ /dev/null
@@ -1,69 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ImageBuff.h
- * \ingroup bgevideotex
- */
-
-#ifndef __IMAGEBUFF_H__
-#define __IMAGEBUFF_H__
-
-
-#include "Common.h"
-
-#include "ImageBase.h"
-
-struct ImBuf;
-
-/// class for image buffer
-class ImageBuff : public ImageBase
-{
-private:
- struct ImBuf *m_imbuf; // temporary structure for buffer manipulation
-public:
- /// constructor
- ImageBuff (void) : ImageBase(true), m_imbuf(NULL) {}
-
- /// destructor
- virtual ~ImageBuff (void);
-
- /// load image from buffer
- void load (unsigned char * img, short width, short height);
- /// clear image with color set on RGB channels and 0xFF on alpha channel
- void clear (short width, short height, unsigned char color);
-
- /// plot image from extern RGBA buffer to image at position x,y using one of IMB_BlendMode
- void plot (unsigned char * img, short width, short height, short x, short y, short mode);
- /// plot image from other ImageBuf to image at position x,y using one of IMB_BlendMode
- void plot (ImageBuff* img, short x, short y, short mode);
-
- /// refresh image - do nothing
- virtual void refresh (void) {}
-};
-
-
-#endif
-
diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp
deleted file mode 100644
index 2de00f5ba05..00000000000
--- a/source/gameengine/VideoTexture/ImageMix.cpp
+++ /dev/null
@@ -1,216 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/ImageMix.cpp
- * \ingroup bgevideotex
- */
-
-
-// implementation
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "ImageMix.h"
-
-#include "ImageBase.h"
-
-#include "Exception.h"
-
-
-// cast ImageSource pointer to ImageSourceMix
-inline ImageSourceMix *getImageSourceMix(ImageSource *src)
-{ return static_cast<ImageSourceMix*>(src); }
-
-
-// get weight
-short ImageMix::getWeight(const char *id)
-{
- // find source
- ImageSourceList::iterator src = findSource(id);
- // if found, return its weight
- return src != m_sources.end() ? getImageSourceMix(*src)->getWeight() : 0;
-}
-
-// set weight
-bool ImageMix::setWeight(const char *id, short weight)
-{
- // find source
- ImageSourceList::iterator src = findSource(id);
- // if source isn't found, report it
- if (src == m_sources.end()) return false;
- // set its weight
- getImageSourceMix(*src)->setWeight(weight);
- return true;
-}
-
-ExceptionID ImageSizesNotMatch;
-
-ExpDesc ImageSizesNotMatchDesc(ImageSizesNotMatch, "Image sizes of sources are different");
-
-// calculate image from sources and set its availability
-void ImageMix::calcImage(unsigned int texId, double ts)
-{
- // check source sizes
- if (!checkSourceSizes()) THRWEXCP(ImageSizesNotMatch, S_OK);
- // set offsets to image buffers
- for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
- // if image buffer is available
- if ((*it)->getImageBuf() != NULL)
- // set its offset
- getImageSourceMix(*it)->setOffset(m_sources[0]->getImageBuf());
- // otherwise don't calculate image
- else
- return;
- // if there is only single source
- if (m_sources.size() == 1)
- {
- // use single filter
- FilterBase mixFilt;
- // fiter and convert image
- filterImage(mixFilt, m_sources[0]->getImageBuf(), m_sources[0]->getSize());
- }
- // otherwise use mix filter to merge source images
- else
- {
- FilterImageMix mixFilt (m_sources);
- // fiter and convert image
- filterImage(mixFilt, m_sources[0]->getImageBuf(), m_sources[0]->getSize());
- }
-}
-
-
-
-// cast Image pointer to ImageMix
-inline ImageMix * getImageMix(PyImage *self)
-{ return static_cast<ImageMix*>(self->m_image); }
-
-
-// python methods
-
-// get source weight
-static PyObject *getWeight(PyImage *self, PyObject *args)
-{
- // weight
- short weight = 0;
- // get arguments
- char *id;
- if (!PyArg_ParseTuple(args, "s:getWeight", &id))
- return NULL;
- if (self->m_image != NULL)
- // get weight
- weight = getImageMix(self)->getWeight(id);
- // return weight
- return Py_BuildValue("h", weight);
-}
-
-
-// set source weight
-static PyObject *setWeight(PyImage *self, PyObject *args)
-{
- // get arguments
- char *id;
- short weight = 0;
- if (!PyArg_ParseTuple(args, "sh:setWeight", &id, &weight))
- return NULL;
- if (self->m_image != NULL)
- // set weight
- if (!getImageMix(self)->setWeight(id, weight))
- {
- // if not set, report error
- PyErr_SetString(PyExc_RuntimeError, "Invalid id of source");
- return NULL;
- }
- // return none
- Py_RETURN_NONE;
-}
-
-
-// methods structure
-static PyMethodDef imageMixMethods[] = {
- {"getSource", (PyCFunction)Image_getSource, METH_VARARGS, "get image source"},
- {"setSource", (PyCFunction)Image_setSource, METH_VARARGS, "set image source"},
- {"getWeight", (PyCFunction)getWeight, METH_VARARGS, "get image source weight"},
- {"setWeight", (PyCFunction)setWeight, METH_VARARGS, "set image source weight"},
- // methods from ImageBase class
- {"refresh", (PyCFunction)Image_refresh, METH_VARARGS, "Refresh image - invalidate its current content"},
- {NULL}
-};
-// attributes structure
-static PyGetSetDef imageMixGetSets[] = {
- // attributes from ImageBase class
- {(char*)"valid", (getter)Image_valid, NULL, (char*)"bool to tell if an image is available", NULL},
- {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
- {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
- {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL},
- {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
- {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
- {NULL}
-};
-
-
-// define python type
-PyTypeObject ImageMixType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.ImageMix", /*tp_name*/
- sizeof(PyImage), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Image_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Image mixer", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- imageMixMethods, /* tp_methods */
- 0, /* tp_members */
- imageMixGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Image_init<ImageMix>, /* tp_init */
- 0, /* tp_alloc */
- Image_allocNew, /* tp_new */
-};
-
diff --git a/source/gameengine/VideoTexture/ImageMix.h b/source/gameengine/VideoTexture/ImageMix.h
deleted file mode 100644
index 161a8b375ea..00000000000
--- a/source/gameengine/VideoTexture/ImageMix.h
+++ /dev/null
@@ -1,131 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ImageMix.h
- * \ingroup bgevideotex
- */
-
-#ifndef __IMAGEMIX_H__
-#define __IMAGEMIX_H__
-
-
-#include "Common.h"
-
-#include "ImageBase.h"
-#include "FilterBase.h"
-
-
-/// class for source mixing
-class ImageSourceMix : public ImageSource
-{
-public:
- /// constructor
- ImageSourceMix (const char *id) : ImageSource(id), m_offset(0), m_weight(0x100) {}
- /// destructor
- virtual ~ImageSourceMix (void) {}
-
- /// get offset
- long long getOffset (void) { return m_offset; }
- /// set offset
- void setOffset (unsigned int * firstImg) { m_offset = m_image - firstImg; }
-
- /// get weight
- short getWeight (void) { return m_weight; }
- /// set weight
- void setWeight (short weight) { m_weight = weight; }
-
-protected:
- /// buffer offset to the first source buffer
- long long m_offset;
- /// source weight
- short m_weight;
-};
-
-
-/// class for image mixer
-class ImageMix : public ImageBase
-{
-public:
- /// constructor
- ImageMix (void) : ImageBase(false) {}
-
- /// destructor
- virtual ~ImageMix (void) {}
-
- /// get weight
- short getWeight(const char *id);
- /// set weight
- bool setWeight(const char *id, short weight);
-
-protected:
-
- /// create new source
- virtual ImageSource *newSource(const char *id) { return new ImageSourceMix(id); }
-
- /// calculate image from sources and set its availability
- virtual void calcImage (unsigned int texId, double ts);
-};
-
-
-/// pixel filter for image mixer
-class FilterImageMix : public FilterBase
-{
-public:
- /// constructor
- FilterImageMix (ImageSourceList & sources) : m_sources(sources) {}
- /// destructor
- virtual ~FilterImageMix (void) {}
-
-protected:
- /// source list
- ImageSourceList & m_sources;
-
- /// filter pixel, source int buffer
- virtual unsigned int filter (unsigned int * src, short x, short y,
- short * size, unsigned int pixSize, unsigned int val = 0)
- {
- // resulting pixel color
- int color[] = {0, 0, 0, 0};
- // iterate sources
- for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
- {
- // get pointer to mixer source
- ImageSourceMix * mixSrc = static_cast<ImageSourceMix*>(*it);
- // add weighted source pixel to result
- color[0] += mixSrc->getWeight() * (src[mixSrc->getOffset()] & 0xFF);
- color[1] += mixSrc->getWeight() * ((src[mixSrc->getOffset()] >> 8) & 0xFF);
- color[2] += mixSrc->getWeight() * ((src[mixSrc->getOffset()] >> 16) & 0xFF);
- color[3] += mixSrc->getWeight() * ((src[mixSrc->getOffset()] >> 24) & 0xFF);
- }
- // return resulting color
- return ((color[0] >> 8) & 0xFF) | (color[1] & 0xFF00)
- | ((color[2] << 8) & 0xFF0000) | ((color[3] << 16) & 0xFF000000);
- }
-};
-
-
-#endif
-
diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp
deleted file mode 100644
index 57062343b67..00000000000
--- a/source/gameengine/VideoTexture/ImageRender.cpp
+++ /dev/null
@@ -1,946 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/ImageRender.cpp
- * \ingroup bgevideotex
- */
-
-// implementation
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-#include <float.h>
-#include <math.h>
-
-
-#include "GPU_glew.h"
-
-#include "KX_PythonInit.h"
-#include "DNA_scene_types.h"
-#include "RAS_CameraData.h"
-#include "RAS_MeshObject.h"
-#include "RAS_Polygon.h"
-#include "RAS_IOffScreen.h"
-#include "RAS_ISync.h"
-#include "BLI_math.h"
-
-#include "ImageRender.h"
-#include "ImageBase.h"
-#include "BlendType.h"
-#include "Exception.h"
-#include "Texture.h"
-
-ExceptionID SceneInvalid, CameraInvalid, ObserverInvalid, OffScreenInvalid;
-ExceptionID MirrorInvalid, MirrorSizeInvalid, MirrorNormalInvalid, MirrorHorizontal, MirrorTooSmall;
-ExpDesc SceneInvalidDesc(SceneInvalid, "Scene object is invalid");
-ExpDesc CameraInvalidDesc(CameraInvalid, "Camera object is invalid");
-ExpDesc ObserverInvalidDesc(ObserverInvalid, "Observer object is invalid");
-ExpDesc OffScreenInvalidDesc(OffScreenInvalid, "Offscreen object is invalid");
-ExpDesc MirrorInvalidDesc(MirrorInvalid, "Mirror object is invalid");
-ExpDesc MirrorSizeInvalidDesc(MirrorSizeInvalid, "Mirror has no vertex or no size");
-ExpDesc MirrorNormalInvalidDesc(MirrorNormalInvalid, "Cannot determine mirror plane");
-ExpDesc MirrorHorizontalDesc(MirrorHorizontal, "Mirror is horizontal in local space");
-ExpDesc MirrorTooSmallDesc(MirrorTooSmall, "Mirror is too small");
-
-// constructor
-ImageRender::ImageRender (KX_Scene *scene, KX_Camera * camera, PyRASOffScreen * offscreen) :
- ImageViewport(offscreen),
- m_render(true),
- m_done(false),
- m_scene(scene),
- m_camera(camera),
- m_owncamera(false),
- m_offscreen(offscreen),
- m_sync(NULL),
- m_observer(NULL),
- m_mirror(NULL),
- m_clip(100.f),
- m_mirrorHalfWidth(0.f),
- m_mirrorHalfHeight(0.f)
-{
- // initialize background color to scene background color as default
- setBackgroundFromScene(m_scene);
- // retrieve rendering objects
- m_engine = KX_GetActiveEngine();
- m_rasterizer = m_engine->GetRasterizer();
- m_canvas = m_engine->GetCanvas();
- // keep a reference to the offscreen buffer
- if (m_offscreen) {
- Py_INCREF(m_offscreen);
- }
-}
-
-// destructor
-ImageRender::~ImageRender (void)
-{
- if (m_owncamera)
- m_camera->Release();
- if (m_sync)
- delete m_sync;
- Py_XDECREF(m_offscreen);
-}
-
-// get background color
-float ImageRender::getBackground (int idx)
-{
- return (idx < 0 || idx > 3) ? 0.0f : m_background[idx] * 255.0f;
-}
-
-// set background color
-void ImageRender::setBackground (float red, float green, float blue, float alpha)
-{
- m_background[0] = (red < 0.0f) ? 0.0f : (red > 255.0f) ? 1.0f : red / 255.0f;
- m_background[1] = (green < 0.0f) ? 0.0f : (green > 255.0f) ? 1.0f : green / 255.0f;
- m_background[2] = (blue < 0.0f) ? 0.0f : (blue > 255.0f) ? 1.0f : blue / 255.0f;
- m_background[3] = (alpha < 0.0f) ? 0.0f : (alpha > 255.0f) ? 1.0f : alpha / 255.0f;
-}
-
-// set background color from scene
-void ImageRender::setBackgroundFromScene (KX_Scene *scene)
-{
- if (scene) {
- const float *background_color = scene->GetWorldInfo()->getBackColorConverted();
- copy_v3_v3(m_background, background_color);
- m_background[3] = 1.0f;
- }
- else {
- const float blue_color[] = {0.0f, 0.0f, 1.0f, 1.0f};
- copy_v4_v4(m_background, blue_color);
- }
-}
-
-
-// capture image from viewport
-void ImageRender::calcViewport (unsigned int texId, double ts, unsigned int format)
-{
- // render the scene from the camera
- if (!m_done) {
- if (!Render()) {
- return;
- }
- }
- else if (m_offscreen) {
- m_offscreen->ofs->Bind(RAS_IOffScreen::RAS_OFS_BIND_READ);
- }
- // wait until all render operations are completed
- WaitSync();
- // get image from viewport (or FBO)
- ImageViewport::calcViewport(texId, ts, format);
- if (m_offscreen) {
- m_offscreen->ofs->Unbind();
- }
-}
-
-bool ImageRender::Render()
-{
- RAS_FrameFrustum frustum;
-
- if (!m_render ||
- m_rasterizer->GetDrawingMode() != RAS_IRasterizer::KX_TEXTURED || // no need for texture
- m_camera->GetViewport() || // camera must be inactive
- m_camera == m_scene->GetActiveCamera())
- {
- // no need to compute texture in non texture rendering
- return false;
- }
-
- if (!m_scene->IsShadowDone())
- m_engine->RenderShadowBuffers(m_scene);
-
- if (m_mirror)
- {
- // mirror mode, compute camera frustum, position and orientation
- // convert mirror position and normal in world space
- const MT_Matrix3x3 & mirrorObjWorldOri = m_mirror->GetSGNode()->GetWorldOrientation();
- const MT_Point3 & mirrorObjWorldPos = m_mirror->GetSGNode()->GetWorldPosition();
- const MT_Vector3 & mirrorObjWorldScale = m_mirror->GetSGNode()->GetWorldScaling();
- MT_Point3 mirrorWorldPos =
- mirrorObjWorldPos + mirrorObjWorldScale * (mirrorObjWorldOri * m_mirrorPos);
- MT_Vector3 mirrorWorldZ = mirrorObjWorldOri * m_mirrorZ;
- // get observer world position
- const MT_Point3 & observerWorldPos = m_observer->GetSGNode()->GetWorldPosition();
- // get plane D term = mirrorPos . normal
- MT_Scalar mirrorPlaneDTerm = mirrorWorldPos.dot(mirrorWorldZ);
- // compute distance of observer to mirror = D - observerPos . normal
- MT_Scalar observerDistance = mirrorPlaneDTerm - observerWorldPos.dot(mirrorWorldZ);
- // if distance < 0.01 => observer is on wrong side of mirror, don't render
- if (observerDistance < 0.01)
- return false;
- // set camera world position = observerPos + normal * 2 * distance
- MT_Point3 cameraWorldPos = observerWorldPos + (MT_Scalar(2.0)*observerDistance)*mirrorWorldZ;
- m_camera->GetSGNode()->SetLocalPosition(cameraWorldPos);
- // set camera orientation: z=normal, y=mirror_up in world space, x= y x z
- MT_Vector3 mirrorWorldY = mirrorObjWorldOri * m_mirrorY;
- MT_Vector3 mirrorWorldX = mirrorObjWorldOri * m_mirrorX;
- MT_Matrix3x3 cameraWorldOri(
- mirrorWorldX[0], mirrorWorldY[0], mirrorWorldZ[0],
- mirrorWorldX[1], mirrorWorldY[1], mirrorWorldZ[1],
- mirrorWorldX[2], mirrorWorldY[2], mirrorWorldZ[2]);
- m_camera->GetSGNode()->SetLocalOrientation(cameraWorldOri);
- m_camera->GetSGNode()->UpdateWorldData(0.0);
- // compute camera frustum:
- // get position of mirror relative to camera: offset = mirrorPos-cameraPos
- MT_Vector3 mirrorOffset = mirrorWorldPos - cameraWorldPos;
- // convert to camera orientation
- mirrorOffset = mirrorOffset * cameraWorldOri;
- // scale mirror size to world scale:
- // get closest local axis for mirror Y and X axis and scale height and width by local axis scale
- MT_Scalar x, y;
- x = fabs(m_mirrorY[0]);
- y = fabs(m_mirrorY[1]);
- float height = (x > y) ?
- ((x > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]):
- ((y > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]);
- x = fabs(m_mirrorX[0]);
- y = fabs(m_mirrorX[1]);
- float width = (x > y) ?
- ((x > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]):
- ((y > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]);
- width *= m_mirrorHalfWidth;
- height *= m_mirrorHalfHeight;
- // left = offsetx-width
- // right = offsetx+width
- // top = offsety+height
- // bottom = offsety-height
- // near = -offsetz
- // far = near+100
- frustum.x1 = mirrorOffset[0]-width;
- frustum.x2 = mirrorOffset[0]+width;
- frustum.y1 = mirrorOffset[1]-height;
- frustum.y2 = mirrorOffset[1]+height;
- frustum.camnear = -mirrorOffset[2];
- frustum.camfar = -mirrorOffset[2]+m_clip;
- }
- // Store settings to be restored later
- const RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode();
- RAS_Rect area = m_canvas->GetWindowArea();
-
- // The screen area that ImageViewport will copy is also the rendering zone
- if (m_offscreen) {
- // bind the fbo and set the viewport to full size
- m_offscreen->ofs->Bind(RAS_IOffScreen::RAS_OFS_BIND_RENDER);
- // this is needed to stop crashing in canvas check
- m_canvas->UpdateViewPort(0, 0, m_offscreen->ofs->GetWidth(), m_offscreen->ofs->GetHeight());
- }
- else {
- m_canvas->SetViewPort(m_position[0], m_position[1], m_position[0]+m_capSize[0]-1, m_position[1]+m_capSize[1]-1);
- }
- 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(m_engine->GetClockTime());
- m_scene->GetWorldInfo()->UpdateWorldSettings();
- 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);
- if (m_mirror)
- {
- // frustum was computed above
- // get frustum matrix and set projection matrix
- MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix(
- frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar);
-
- m_camera->SetProjectionMatrix(projmat);
- }
- else if (m_camera->hasValidProjectionMatrix()) {
- m_rasterizer->SetProjectionMatrix(m_camera->GetProjectionMatrix());
- }
- else {
- float lens = m_camera->GetLens();
- float sensor_x = m_camera->GetSensorWidth();
- float sensor_y = m_camera->GetSensorHeight();
- float shift_x = m_camera->GetShiftHorizontal();
- float shift_y = m_camera->GetShiftVertical();
- bool orthographic = !m_camera->GetCameraData()->m_perspective;
- float nearfrust = m_camera->GetCameraNear();
- float farfrust = m_camera->GetCameraFar();
- float aspect_ratio = 1.0f;
- Scene *blenderScene = m_scene->GetBlenderScene();
- MT_Matrix4x4 projmat;
-
- // compute the aspect ratio from frame blender scene settings so that render to texture
- // works the same in Blender and in Blender player
- if (blenderScene->r.ysch != 0)
- aspect_ratio = float(blenderScene->r.xsch*blenderScene->r.xasp) / float(blenderScene->r.ysch*blenderScene->r.yasp);
-
- if (orthographic) {
-
- RAS_FramingManager::ComputeDefaultOrtho(
- nearfrust,
- farfrust,
- m_camera->GetScale(),
- aspect_ratio,
- m_camera->GetSensorFit(),
- shift_x,
- shift_y,
- frustum
- );
-
- projmat = m_rasterizer->GetOrthoMatrix(
- frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar);
- }
- else {
- RAS_FramingManager::ComputeDefaultFrustum(
- nearfrust,
- farfrust,
- lens,
- sensor_x,
- sensor_y,
- RAS_SENSORFIT_AUTO,
- shift_x,
- shift_y,
- aspect_ratio,
- frustum);
-
- projmat = m_rasterizer->GetFrustumMatrix(
- frustum.x1, frustum.x2, frustum.y1, frustum.y2, frustum.camnear, frustum.camfar);
- }
- m_camera->SetProjectionMatrix(projmat);
- }
-
- MT_Transform camtrans(m_camera->GetWorldToCamera());
- MT_Matrix4x4 viewmat(camtrans);
-
- m_rasterizer->SetViewMatrix(viewmat, m_camera->NodeGetWorldOrientation(), m_camera->NodeGetWorldPosition(), m_camera->NodeGetLocalScaling(), m_camera->GetCameraData()->m_perspective);
- m_camera->SetModelviewMatrix(viewmat);
- // restore the stereo mode now that the matrix is computed
- m_rasterizer->SetStereoMode(stereomode);
-
- if (m_rasterizer->Stereo()) {
- // stereo mode change render settings that disturb this render, cancel them all
- // we don't need to restore them as they are set before each frame render.
- glDrawBuffer(GL_BACK_LEFT);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glDisable(GL_POLYGON_STIPPLE);
- }
-
- m_scene->CalculateVisibleMeshes(m_rasterizer,m_camera);
-
- m_engine->UpdateAnimations(m_scene);
-
- m_scene->RenderBuckets(camtrans, m_rasterizer);
-
- m_scene->RenderFonts();
-
- // restore the canvas area now that the render is completed
- m_canvas->GetWindowArea() = area;
- m_canvas->EndFrame();
-
- // In case multisample is active, blit the FBO
- if (m_offscreen)
- m_offscreen->ofs->Blit();
- // end of all render operations, let's create a sync object just in case
- if (m_sync) {
- // a sync from a previous render, should not happen
- delete m_sync;
- m_sync = NULL;
- }
- m_sync = m_rasterizer->CreateSync(RAS_ISync::RAS_SYNC_TYPE_FENCE);
- // remember that we have done render
- m_done = true;
- // the image is not available at this stage
- m_avail = false;
- return true;
-}
-
-void ImageRender::Unbind()
-{
- if (m_offscreen)
- {
- m_offscreen->ofs->Unbind();
- }
-}
-
-void ImageRender::WaitSync()
-{
- if (m_sync) {
- m_sync->Wait();
- // done with it, deleted it
- delete m_sync;
- m_sync = NULL;
- }
- if (m_offscreen) {
- // this is needed to finalize the image if the target is a texture
- m_offscreen->ofs->MipMap();
- }
- // all rendered operation done and complete, invalidate render for next time
- m_done = false;
-}
-
-// cast Image pointer to ImageRender
-inline ImageRender * getImageRender (PyImage *self)
-{ return static_cast<ImageRender*>(self->m_image); }
-
-
-// python methods
-
-// Blender Scene type
-static BlendType<KX_Scene> sceneType ("KX_Scene");
-// Blender Camera type
-static BlendType<KX_Camera> cameraType ("KX_Camera");
-
-
-// object initialization
-static int ImageRender_init(PyObject *pySelf, PyObject *args, PyObject *kwds)
-{
- // parameters - scene object
- PyObject *scene;
- // camera object
- PyObject *camera;
- // offscreen buffer object
- PyRASOffScreen *offscreen = NULL;
- // parameter keywords
- static const char *kwlist[] = {"sceneObj", "cameraObj", "ofsObj", NULL};
- // get parameters
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|O",
- const_cast<char**>(kwlist), &scene, &camera, &offscreen))
- return -1;
- try
- {
- // get scene pointer
- KX_Scene * scenePtr (NULL);
- if (scene != NULL) scenePtr = sceneType.checkType(scene);
- // throw exception if scene is not available
- if (scenePtr == NULL) THRWEXCP(SceneInvalid, S_OK);
-
- // get camera pointer
- KX_Camera * cameraPtr (NULL);
- if (camera != NULL) cameraPtr = cameraType.checkType(camera);
- // throw exception if camera is not available
- if (cameraPtr == NULL) THRWEXCP(CameraInvalid, S_OK);
-
- if (offscreen) {
- if (Py_TYPE(offscreen) != &PyRASOffScreen_Type) {
- THRWEXCP(OffScreenInvalid, S_OK);
- }
- }
- // get pointer to image structure
- PyImage *self = reinterpret_cast<PyImage*>(pySelf);
- // create source object
- if (self->m_image != NULL) delete self->m_image;
- self->m_image = new ImageRender(scenePtr, cameraPtr, offscreen);
- }
- catch (Exception & exp)
- {
- exp.report();
- return -1;
- }
- // initialization succeded
- return 0;
-}
-
-static PyObject *ImageRender_refresh(PyImage *self, PyObject *args)
-{
- ImageRender *imageRender = getImageRender(self);
-
- if (!imageRender) {
- PyErr_SetString(PyExc_TypeError, "Incomplete ImageRender() object");
- return NULL;
- }
- if (PyArg_ParseTuple(args, "")) {
- // refresh called with no argument.
- // For other image objects it simply invalidates the image buffer
- // For ImageRender it triggers a render+sync
- // Note that this only makes sense when doing offscreen render on texture
- if (!imageRender->isDone()) {
- if (!imageRender->Render()) {
- Py_RETURN_FALSE;
- }
- // as we are not trying to read the pixels, just unbind
- imageRender->Unbind();
- }
- // wait until all render operations are completed
- // this will also finalize the texture
- imageRender->WaitSync();
- Py_RETURN_TRUE;
- }
- else {
- // fallback on standard processing
- PyErr_Clear();
- return Image_refresh(self, args);
- }
-}
-
-// refresh image
-static PyObject *ImageRender_render(PyImage *self)
-{
- ImageRender *imageRender = getImageRender(self);
-
- if (!imageRender) {
- PyErr_SetString(PyExc_TypeError, "Incomplete ImageRender() object");
- return NULL;
- }
- if (!imageRender->Render()) {
- Py_RETURN_FALSE;
- }
- // we are not reading the pixels now, unbind
- imageRender->Unbind();
- Py_RETURN_TRUE;
-}
-
-
-// get background color
-static PyObject *getBackground (PyImage *self, void *closure)
-{
- return Py_BuildValue("[ffff]",
- getImageRender(self)->getBackground(0),
- getImageRender(self)->getBackground(1),
- getImageRender(self)->getBackground(2),
- getImageRender(self)->getBackground(3));
-}
-
-// set color
-static int setBackground(PyImage *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 4
- || (!PyFloat_Check(PySequence_Fast_GET_ITEM(value, 0)) && !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)))
- || (!PyFloat_Check(PySequence_Fast_GET_ITEM(value, 1)) && !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
- || (!PyFloat_Check(PySequence_Fast_GET_ITEM(value, 2)) && !PyLong_Check(PySequence_Fast_GET_ITEM(value, 2)))
- || (!PyFloat_Check(PySequence_Fast_GET_ITEM(value, 3)) && !PyLong_Check(PySequence_Fast_GET_ITEM(value, 3)))) {
-
- PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 4 floats or ints between 0.0 and 255.0");
- return -1;
- }
- // set background color
- getImageRender(self)->setBackground(
- PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)),
- PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)),
- PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 2)),
- PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 3)));
- // success
- return 0;
-}
-
-
-// methods structure
-static PyMethodDef imageRenderMethods[] =
-{ // methods from ImageBase class
- {"refresh", (PyCFunction)ImageRender_refresh, METH_VARARGS, "Refresh image - invalidate its current content after optionally transferring its content to a target buffer"},
- {"render", (PyCFunction)ImageRender_render, METH_NOARGS, "Render scene - run before refresh() to performs asynchronous render"},
- {NULL}
-};
-// attributes structure
-static PyGetSetDef imageRenderGetSets[] =
-{
- {(char*)"background", (getter)getBackground, (setter)setBackground, (char*)"background color", NULL},
- // attribute from ImageViewport
- {(char*)"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, (char*)"size of render area", NULL},
- {(char*)"alpha", (getter)ImageViewport_getAlpha, (setter)ImageViewport_setAlpha, (char*)"use alpha in texture", NULL},
- {(char*)"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, (char*)"use whole viewport to render", NULL},
- // attributes from ImageBase class
- {(char*)"valid", (getter)Image_valid, NULL, (char*)"bool to tell if an image is available", NULL},
- {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
- {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
- {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL},
- {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
- {(char*)"zbuff", (getter)Image_getZbuff, (setter)Image_setZbuff, (char*)"use depth buffer as texture", NULL},
- {(char*)"depth", (getter)Image_getDepth, (setter)Image_setDepth, (char*)"get depth information from z-buffer using unsigned int precision", NULL},
- {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
- {NULL}
-};
-
-
-// define python type
-PyTypeObject ImageRenderType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.ImageRender", /*tp_name*/
- sizeof(PyImage), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Image_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Image source from render", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- imageRenderMethods, /* tp_methods */
- 0, /* tp_members */
- imageRenderGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ImageRender_init, /* tp_init */
- 0, /* tp_alloc */
- Image_allocNew, /* tp_new */
-};
-
-// object initialization
-static int ImageMirror_init(PyObject *pySelf, PyObject *args, PyObject *kwds)
-{
- // parameters - scene object
- PyObject *scene;
- // reference object for mirror
- PyObject *observer;
- // object holding the mirror
- PyObject *mirror;
- // material of the mirror
- short materialID = 0;
- // parameter keywords
- static const char *kwlist[] = {"scene", "observer", "mirror", "material", NULL};
- // get parameters
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOO|h",
- const_cast<char**>(kwlist), &scene, &observer, &mirror, &materialID))
- return -1;
- try
- {
- // get scene pointer
- KX_Scene * scenePtr (NULL);
- if (scene != NULL && PyObject_TypeCheck(scene, &KX_Scene::Type))
- scenePtr = static_cast<KX_Scene*>BGE_PROXY_REF(scene);
- else
- THRWEXCP(SceneInvalid, S_OK);
-
- if (scenePtr==NULL) /* in case the python proxy reference is invalid */
- THRWEXCP(SceneInvalid, S_OK);
-
- // get observer pointer
- KX_GameObject * observerPtr (NULL);
- if (observer != NULL && PyObject_TypeCheck(observer, &KX_GameObject::Type))
- observerPtr = static_cast<KX_GameObject*>BGE_PROXY_REF(observer);
- else if (observer != NULL && PyObject_TypeCheck(observer, &KX_Camera::Type))
- observerPtr = static_cast<KX_Camera*>BGE_PROXY_REF(observer);
- else
- THRWEXCP(ObserverInvalid, S_OK);
-
- if (observerPtr==NULL) /* in case the python proxy reference is invalid */
- THRWEXCP(ObserverInvalid, S_OK);
-
- // get mirror pointer
- KX_GameObject * mirrorPtr (NULL);
- if (mirror != NULL && PyObject_TypeCheck(mirror, &KX_GameObject::Type))
- mirrorPtr = static_cast<KX_GameObject*>BGE_PROXY_REF(mirror);
- else
- THRWEXCP(MirrorInvalid, S_OK);
-
- if (mirrorPtr==NULL) /* in case the python proxy reference is invalid */
- THRWEXCP(MirrorInvalid, S_OK);
-
- // locate the material in the mirror
- RAS_IPolyMaterial * material = getMaterial(mirror, materialID);
- if (material == NULL)
- THRWEXCP(MaterialNotAvail, S_OK);
-
- // get pointer to image structure
- PyImage *self = reinterpret_cast<PyImage*>(pySelf);
-
- // create source object
- if (self->m_image != NULL)
- {
- delete self->m_image;
- self->m_image = NULL;
- }
- self->m_image = new ImageRender(scenePtr, observerPtr, mirrorPtr, material);
- }
- catch (Exception & exp)
- {
- exp.report();
- return -1;
- }
- // initialization succeeded
- return 0;
-}
-
-// get background color
-static PyObject *getClip (PyImage *self, void *closure)
-{
- return PyFloat_FromDouble(getImageRender(self)->getClip());
-}
-
-// set clip
-static int setClip(PyImage *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- double clip;
- if (value == NULL || !PyFloat_Check(value) || (clip = PyFloat_AsDouble(value)) < 0.01 || clip > 5000.0)
- {
- PyErr_SetString(PyExc_TypeError, "The value must be an float between 0.01 and 5000");
- return -1;
- }
- // set background color
- getImageRender(self)->setClip(float(clip));
- // success
- return 0;
-}
-
-// attributes structure
-static PyGetSetDef imageMirrorGetSets[] =
-{
- {(char*)"clip", (getter)getClip, (setter)setClip, (char*)"clipping distance", NULL},
- // attribute from ImageRender
- {(char*)"background", (getter)getBackground, (setter)setBackground, (char*)"background color", NULL},
- // attribute from ImageViewport
- {(char*)"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, (char*)"size of render area", NULL},
- {(char*)"alpha", (getter)ImageViewport_getAlpha, (setter)ImageViewport_setAlpha, (char*)"use alpha in texture", NULL},
- {(char*)"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, (char*)"use whole viewport to render", NULL},
- // attributes from ImageBase class
- {(char*)"valid", (getter)Image_valid, NULL, (char*)"bool to tell if an image is available", NULL},
- {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
- {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
- {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL},
- {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
- {(char*)"zbuff", (getter)Image_getZbuff, (setter)Image_setZbuff, (char*)"use depth buffer as texture", NULL},
- {(char*)"depth", (getter)Image_getDepth, (setter)Image_setDepth, (char*)"get depth information from z-buffer using unsigned int precision", NULL},
- {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
- {NULL}
-};
-
-
-// constructor
-ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObject *mirror, RAS_IPolyMaterial *mat) :
- ImageViewport(),
- m_render(false),
- m_done(false),
- m_scene(scene),
- m_offscreen(NULL),
- m_sync(NULL),
- m_observer(observer),
- m_mirror(mirror),
- m_clip(100.f)
-{
- // this constructor is used for automatic planar mirror
- // create a camera, take all data by default, in any case we will recompute the frustum on each frame
- RAS_CameraData camdata;
- vector<RAS_TexVert*> mirrorVerts;
- vector<RAS_TexVert*>::iterator it;
- float mirrorArea = 0.f;
- float mirrorNormal[3] = {0.f, 0.f, 0.f};
- float mirrorUp[3];
- float dist, vec[3], axis[3];
- float zaxis[3] = {0.f, 0.f, 1.f};
- float yaxis[3] = {0.f, 1.f, 0.f};
- float mirrorMat[3][3];
- float left, right, top, bottom, back;
- // make sure this camera will delete its node
- m_camera= new KX_Camera(scene, KX_Scene::m_callbacks, camdata, true, true);
- m_camera->SetName("__mirror__cam__");
- // don't add the camera to the scene object list, it doesn't need to be accessible
- m_owncamera = true;
- // retrieve rendering objects
- m_engine = KX_GetActiveEngine();
- m_rasterizer = m_engine->GetRasterizer();
- m_canvas = m_engine->GetCanvas();
- // locate the vertex assigned to mat and do following calculation in mesh coordinates
- for (int meshIndex = 0; meshIndex < mirror->GetMeshCount(); meshIndex++)
- {
- RAS_MeshObject* mesh = mirror->GetMesh(meshIndex);
- int numPolygons = mesh->NumPolygons();
- for (int polygonIndex=0; polygonIndex < numPolygons; polygonIndex++)
- {
- RAS_Polygon* polygon = mesh->GetPolygon(polygonIndex);
- if (polygon->GetMaterial()->GetPolyMaterial() == mat)
- {
- RAS_TexVert *v1, *v2, *v3, *v4;
- float normal[3];
- float area;
- // this polygon is part of the mirror
- v1 = polygon->GetVertex(0);
- v2 = polygon->GetVertex(1);
- v3 = polygon->GetVertex(2);
- mirrorVerts.push_back(v1);
- mirrorVerts.push_back(v2);
- mirrorVerts.push_back(v3);
- if (polygon->VertexCount() == 4) {
- v4 = polygon->GetVertex(3);
- mirrorVerts.push_back(v4);
- area = normal_quad_v3(normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ(), (float*)v4->getXYZ());
- }
- else {
- area = normal_tri_v3(normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ());
- }
- area = fabs(area);
- mirrorArea += area;
- mul_v3_fl(normal, area);
- add_v3_v3v3(mirrorNormal, mirrorNormal, normal);
- }
- }
- }
- if (mirrorVerts.size() == 0 || mirrorArea < FLT_EPSILON)
- {
- // no vertex or zero size mirror
- THRWEXCP(MirrorSizeInvalid, S_OK);
- }
- // compute average normal of mirror faces
- mul_v3_fl(mirrorNormal, 1.0f/mirrorArea);
- if (normalize_v3(mirrorNormal) == 0.f)
- {
- // no normal
- THRWEXCP(MirrorNormalInvalid, S_OK);
- }
- // the mirror plane has an equation of the type ax+by+cz = d where (a,b,c) is the normal vector
- // if the mirror is more vertical then horizontal, the Z axis is the up direction.
- // otherwise the Y axis is the up direction.
- // If the mirror is not perfectly vertical(horizontal), the Z(Y) axis projection on the mirror
- // plan by the normal will be the up direction.
- if (fabsf(mirrorNormal[2]) > fabsf(mirrorNormal[1]) &&
- fabsf(mirrorNormal[2]) > fabsf(mirrorNormal[0]))
- {
- // the mirror is more horizontal than vertical
- copy_v3_v3(axis, yaxis);
- }
- else
- {
- // the mirror is more vertical than horizontal
- copy_v3_v3(axis, zaxis);
- }
- dist = dot_v3v3(mirrorNormal, axis);
- if (fabsf(dist) < FLT_EPSILON)
- {
- // the mirror is already fully aligned with up axis
- copy_v3_v3(mirrorUp, axis);
- }
- else
- {
- // projection of axis to mirror plane through normal
- copy_v3_v3(vec, mirrorNormal);
- mul_v3_fl(vec, dist);
- sub_v3_v3v3(mirrorUp, axis, vec);
- if (normalize_v3(mirrorUp) == 0.f)
- {
- // should not happen
- THRWEXCP(MirrorHorizontal, S_OK);
- return;
- }
- }
- // compute rotation matrix between local coord and mirror coord
- // to match camera orientation, we select mirror z = -normal, y = up, x = y x z
- negate_v3_v3(mirrorMat[2], mirrorNormal);
- copy_v3_v3(mirrorMat[1], mirrorUp);
- cross_v3_v3v3(mirrorMat[0], mirrorMat[1], mirrorMat[2]);
- // transpose to make it a orientation matrix from local space to mirror space
- transpose_m3(mirrorMat);
- // transform all vertex to plane coordinates and determine mirror position
- left = FLT_MAX;
- right = -FLT_MAX;
- bottom = FLT_MAX;
- top = -FLT_MAX;
- back = -FLT_MAX; // most backward vertex (=highest Z coord in mirror space)
- for (it = mirrorVerts.begin(); it != mirrorVerts.end(); it++)
- {
- copy_v3_v3(vec, (float*)(*it)->getXYZ());
- mul_m3_v3(mirrorMat, vec);
- if (vec[0] < left)
- left = vec[0];
- if (vec[0] > right)
- right = vec[0];
- if (vec[1] < bottom)
- bottom = vec[1];
- if (vec[1] > top)
- top = vec[1];
- if (vec[2] > back)
- back = vec[2];
- }
- // now store this information in the object for later rendering
- m_mirrorHalfWidth = (right-left)*0.5f;
- m_mirrorHalfHeight = (top-bottom)*0.5f;
- if (m_mirrorHalfWidth < 0.01f || m_mirrorHalfHeight < 0.01f)
- {
- // mirror too small
- THRWEXCP(MirrorTooSmall, S_OK);
- }
- // mirror position in mirror coord
- vec[0] = (left+right)*0.5f;
- vec[1] = (top+bottom)*0.5f;
- vec[2] = back;
- // convert it in local space: transpose again the matrix to get back to mirror to local transform
- transpose_m3(mirrorMat);
- mul_m3_v3(mirrorMat, vec);
- // mirror position in local space
- m_mirrorPos.setValue(vec[0], vec[1], vec[2]);
- // mirror normal vector (pointed towards the back of the mirror) in local space
- m_mirrorZ.setValue(-mirrorNormal[0], -mirrorNormal[1], -mirrorNormal[2]);
- m_mirrorY.setValue(mirrorUp[0], mirrorUp[1], mirrorUp[2]);
- m_mirrorX = m_mirrorY.cross(m_mirrorZ);
- m_render = true;
-
- // set mirror background color to scene background color as default
- setBackgroundFromScene(m_scene);
-}
-
-
-
-
-// define python type
-PyTypeObject ImageMirrorType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.ImageMirror", /*tp_name*/
- sizeof(PyImage), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Image_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Image source from mirror", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- imageRenderMethods, /* tp_methods */
- 0, /* tp_members */
- imageMirrorGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ImageMirror_init, /* tp_init */
- 0, /* tp_alloc */
- Image_allocNew, /* tp_new */
-};
-
-
diff --git a/source/gameengine/VideoTexture/ImageRender.h b/source/gameengine/VideoTexture/ImageRender.h
deleted file mode 100644
index d062db44348..00000000000
--- a/source/gameengine/VideoTexture/ImageRender.h
+++ /dev/null
@@ -1,125 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ImageRender.h
- * \ingroup bgevideotex
- */
-
-#ifndef __IMAGERENDER_H__
-#define __IMAGERENDER_H__
-
-
-#include "Common.h"
-
-#include "KX_Scene.h"
-#include "KX_Camera.h"
-#include "DNA_screen_types.h"
-#include "RAS_ICanvas.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_IOffScreen.h"
-#include "RAS_ISync.h"
-
-#include "ImageViewport.h"
-
-
-/// class for render 3d scene
-class ImageRender : public ImageViewport
-{
-public:
- /// constructor
- ImageRender(KX_Scene *scene, KX_Camera *camera, PyRASOffScreen *offscreen);
- ImageRender(KX_Scene *scene, KX_GameObject *observer, KX_GameObject *mirror, RAS_IPolyMaterial * mat);
-
- /// destructor
- virtual ~ImageRender (void);
-
- /// get background color
- float getBackground (int idx);
- /// set background color
- void setBackground (float red, float green, float blue, float alpha);
-
- /// clipping distance
- float getClip (void) { return m_clip; }
- /// set whole buffer use
- void setClip (float clip) { m_clip = clip; }
- /// render status
- bool isDone() { return m_done; }
- /// render frame (public so that it is accessible from python)
- bool Render();
- /// in case fbo is used, method to unbind
- void Unbind();
- /// wait for render to complete
- void WaitSync();
-
-protected:
- /// true if ready to render
- bool m_render;
- /// is render done already?
- bool m_done;
- /// rendered scene
- KX_Scene * m_scene;
- /// camera for render
- KX_Camera * m_camera;
- /// do we own the camera?
- bool m_owncamera;
- /// if offscreen render
- PyRASOffScreen *m_offscreen;
- /// object to synchronize render even if no buffer transfer
- RAS_ISync *m_sync;
- /// for mirror operation
- KX_GameObject * m_observer;
- KX_GameObject * m_mirror;
- float m_clip; // clipping distance
- float m_mirrorHalfWidth; // mirror width in mirror space
- float m_mirrorHalfHeight; // mirror height in mirror space
- MT_Point3 m_mirrorPos; // mirror center position in local space
- MT_Vector3 m_mirrorZ; // mirror Z axis in local space
- MT_Vector3 m_mirrorY; // mirror Y axis in local space
- MT_Vector3 m_mirrorX; // mirror X axis in local space
- /// canvas
- RAS_ICanvas* m_canvas;
- /// rasterizer
- RAS_IRasterizer* m_rasterizer;
- /// engine
- KX_KetsjiEngine* m_engine;
-
- /// background color
- float m_background[4];
-
-
- /// render 3d scene to image
- virtual void calcImage (unsigned int texId, double ts) { calcViewport(texId, ts, GL_RGBA); }
-
- /// render 3d scene to image
- virtual void calcViewport (unsigned int texId, double ts, unsigned int format);
-
- void setBackgroundFromScene(KX_Scene *scene);
- void SetWorldSettings(KX_WorldInfo* wi);
-};
-
-
-#endif
-
diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp
deleted file mode 100644
index ad3d8875e28..00000000000
--- a/source/gameengine/VideoTexture/ImageViewport.cpp
+++ /dev/null
@@ -1,467 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/ImageViewport.cpp
- * \ingroup bgevideotex
- */
-
-// implementation
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "GPU_glew.h"
-
-#include "KX_PythonInit.h"
-#include "RAS_ICanvas.h"
-#include "Texture.h"
-#include "ImageBase.h"
-#include "VideoBase.h"
-#include "FilterSource.h"
-#include "ImageViewport.h"
-
-
-// constructor
-ImageViewport::ImageViewport (PyRASOffScreen *offscreen) : m_alpha(false), m_texInit(false)
-{
- // get viewport rectangle
- if (offscreen) {
- m_viewport[0] = 0;
- m_viewport[1] = 0;
- m_viewport[2] = offscreen->ofs->GetWidth();
- m_viewport[3] = offscreen->ofs->GetHeight();
- }
- else {
- RAS_Rect rect = KX_GetActiveEngine()->GetCanvas()->GetWindowArea();
- m_viewport[0] = rect.GetLeft();
- m_viewport[1] = rect.GetBottom();
- m_viewport[2] = rect.GetWidth();
- m_viewport[3] = rect.GetHeight();
- }
-
- //glGetIntegerv(GL_VIEWPORT, m_viewport);
- // create buffer for viewport image
- // Warning: this buffer is also used to get the depth buffer as an array of
- // float (1 float = 4 bytes per pixel)
- m_viewportImage = new BYTE [4 * getViewportSize()[0] * getViewportSize()[1]];
- // set attributes
- setWhole((offscreen) ? true : false);
-}
-
-// destructor
-ImageViewport::~ImageViewport (void)
-{
- delete [] m_viewportImage;
-}
-
-
-// use whole viewport to capture image
-void ImageViewport::setWhole (bool whole)
-{
- // set whole
- m_whole = whole;
- // set capture size to viewport size, if whole,
- // otherwise place area in the middle of viewport
- for (int idx = 0; idx < 2; ++idx)
- {
- // capture size
- m_capSize[idx] = whole ? short(getViewportSize()[idx])
- : calcSize(short(getViewportSize()[idx]));
- // position
- m_position[idx] = whole ? 0 : ((getViewportSize()[idx] - m_capSize[idx]) >> 1);
- }
- // init image
- init(m_capSize[0], m_capSize[1]);
- // set capture position
- setPosition();
-}
-
-void ImageViewport::setCaptureSize (short size[2])
-{
- m_whole = false;
- if (size == NULL)
- size = m_capSize;
- for (int idx = 0; idx < 2; ++idx)
- {
- if (size[idx] < 1)
- m_capSize[idx] = 1;
- else if (size[idx] > getViewportSize()[idx])
- m_capSize[idx] = short(getViewportSize()[idx]);
- else
- m_capSize[idx] = size[idx];
- }
- init(m_capSize[0], m_capSize[1]);
- // set capture position
- setPosition();
-}
-
-// set position of capture rectangle
-void ImageViewport::setPosition (GLint pos[2])
-{
- // if new position is not provided, use existing position
- if (pos == NULL) pos = m_position;
- // save position
- for (int idx = 0; idx < 2; ++idx)
- m_position[idx] = pos[idx] < 0 ? 0 : pos[idx] >= getViewportSize()[idx]
- - m_capSize[idx] ? getViewportSize()[idx] - m_capSize[idx] : pos[idx];
- // recalc up left corner
- for (int idx = 0; idx < 2; ++idx)
- m_upLeft[idx] = m_position[idx] + m_viewport[idx];
-}
-
-
-// capture image from viewport
-void ImageViewport::calcViewport (unsigned int texId, double ts, unsigned int format)
-{
- // if scale was changed
- if (m_scaleChange)
- // reset image
- init(m_capSize[0], m_capSize[1]);
- // if texture wasn't initialized
- if (!m_texInit && texId != 0) {
- // initialize it
- loadTexture(texId, m_image, m_size);
- m_texInit = true;
- }
- // if texture can be directly created
- if (texId != 0 && m_pyfilter == NULL && m_size[0] == m_capSize[0] &&
- m_size[1] == m_capSize[1] && !m_flip && !m_zbuff && !m_depth)
- {
- // just copy current viewport to texture
- glBindTexture(GL_TEXTURE_2D, texId);
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1]);
- glBindTexture(GL_TEXTURE_2D, 0);
- // image is not available
- m_avail = false;
- }
- // otherwise copy viewport to buffer, if image is not available
- else if (!m_avail) {
- if (m_zbuff) {
- // Use read pixels with the depth buffer
- // *** misusing m_viewportImage here, but since it has the correct size
- // (4 bytes per pixel = size of float) and we just need it to apply
- // the filter, it's ok
- glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1],
- GL_DEPTH_COMPONENT, GL_FLOAT, m_viewportImage);
- // filter loaded data
- FilterZZZA filt;
- filterImage(filt, (float *)m_viewportImage, m_capSize);
- }
- else {
-
- if (m_depth) {
- // Use read pixels with the depth buffer
- // See warning above about m_viewportImage.
- glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1],
- GL_DEPTH_COMPONENT, GL_FLOAT, m_viewportImage);
- // filter loaded data
- FilterDEPTH filt;
- filterImage(filt, (float *)m_viewportImage, m_capSize);
- }
- else {
-
- // get frame buffer data
- if (m_alpha) {
- // as we are reading the pixel in the native format, we can read directly in the image buffer
- // if we are sure that no processing is needed on the image
- if (m_size[0] == m_capSize[0] &&
- m_size[1] == m_capSize[1] &&
- !m_flip &&
- !m_pyfilter)
- {
- glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], format,
- GL_UNSIGNED_BYTE, m_image);
- m_avail = true;
- }
- else if (!m_pyfilter) {
- glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], format,
- GL_UNSIGNED_BYTE, m_viewportImage);
- FilterRGBA32 filt;
- filterImage(filt, m_viewportImage, m_capSize);
- }
- else {
- glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGBA,
- GL_UNSIGNED_BYTE, m_viewportImage);
- FilterRGBA32 filt;
- filterImage(filt, m_viewportImage, m_capSize);
- if (format == GL_BGRA) {
- // in place byte swapping
- swapImageBR();
- }
- }
- }
- else {
- glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB,
- GL_UNSIGNED_BYTE, m_viewportImage);
- // filter loaded data
- FilterRGB24 filt;
- filterImage(filt, m_viewportImage, m_capSize);
- if (format == GL_BGRA) {
- // in place byte swapping
- swapImageBR();
- }
- }
- }
- }
- }
-}
-
-bool ImageViewport::loadImage(unsigned int *buffer, unsigned int size, unsigned int format, double ts)
-{
- unsigned int *tmp_image;
- bool ret;
-
- // if scale was changed
- if (m_scaleChange) {
- // reset image
- init(m_capSize[0], m_capSize[1]);
- }
-
- // size must be identical
- if (size < getBuffSize())
- return false;
-
- if (m_avail) {
- // just copy
- return ImageBase::loadImage(buffer, size, format, ts);
- }
- else {
- tmp_image = m_image;
- m_image = buffer;
- calcViewport(0, ts, format);
- ret = m_avail;
- m_image = tmp_image;
- // since the image was not loaded to our buffer, it's not valid
- m_avail = false;
- }
- return ret;
-}
-
-
-// cast Image pointer to ImageViewport
-inline ImageViewport * getImageViewport (PyImage *self)
-{ return static_cast<ImageViewport*>(self->m_image); }
-
-
-// python methods
-
-
-// get whole
-PyObject *ImageViewport_getWhole (PyImage *self, void *closure)
-{
- if (self->m_image != NULL && getImageViewport(self)->getWhole()) Py_RETURN_TRUE;
- else Py_RETURN_FALSE;
-}
-
-// set whole
-int ImageViewport_setWhole(PyImage *self, PyObject *value, void *closure)
-{
- // check parameter, report failure
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- try
- {
- // set whole, can throw in case of resize and buffer exports
- if (self->m_image != NULL) getImageViewport(self)->setWhole(value == Py_True);
- }
- catch (Exception & exp)
- {
- exp.report();
- return -1;
- }
- // success
- return 0;
-}
-
-// get alpha
-PyObject *ImageViewport_getAlpha (PyImage *self, void *closure)
-{
- if (self->m_image != NULL && getImageViewport(self)->getAlpha()) Py_RETURN_TRUE;
- else Py_RETURN_FALSE;
-}
-
-// set whole
-int ImageViewport_setAlpha(PyImage *self, PyObject *value, void *closure)
-{
- // check parameter, report failure
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- // set alpha
- if (self->m_image != NULL) getImageViewport(self)->setAlpha(value == Py_True);
- // success
- return 0;
-}
-
-
-// get position
-static PyObject *ImageViewport_getPosition (PyImage *self, void *closure)
-{
- GLint *pos = getImageViewport(self)->getPosition();
- PyObject *ret = PyTuple_New(2);
- PyTuple_SET_ITEM(ret, 0, PyLong_FromLong(pos[0]));
- PyTuple_SET_ITEM(ret, 1, PyLong_FromLong(pos[1]));
- return ret;
-}
-
-// set position
-static int ImageViewport_setPosition(PyImage *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL ||
- !(PyTuple_Check(value) || PyList_Check(value)) ||
- PySequence_Fast_GET_SIZE(value) != 2 ||
- !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) ||
- !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
- return -1;
- }
- // set position
- GLint pos[2] = {
- GLint(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
- GLint(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1)))
- };
- getImageViewport(self)->setPosition(pos);
- // success
- return 0;
-}
-
-// get capture size
-PyObject *ImageViewport_getCaptureSize (PyImage *self, void *closure)
-{
- short *size = getImageViewport(self)->getCaptureSize();
- PyObject *ret = PyTuple_New(2);
- PyTuple_SET_ITEM(ret, 0, PyLong_FromLong(size[0]));
- PyTuple_SET_ITEM(ret, 1, PyLong_FromLong(size[1]));
- return ret;
-}
-
-// set capture size
-int ImageViewport_setCaptureSize(PyImage *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL ||
- !(PyTuple_Check(value) || PyList_Check(value)) ||
- PySequence_Fast_GET_SIZE(value) != 2 ||
- !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) ||
- !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
- return -1;
- }
- // set capture size
- short size[2] = {
- short(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
- short(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1)))
- };
- try
- {
- // can throw in case of resize and buffer exports
- getImageViewport(self)->setCaptureSize(size);
- }
- catch (Exception & exp)
- {
- exp.report();
- return -1;
- }
- // success
- return 0;
-}
-
-
-// methods structure
-static PyMethodDef imageViewportMethods[] =
-{ // methods from ImageBase class
- {"refresh", (PyCFunction)Image_refresh, METH_VARARGS, "Refresh image - invalidate its current content"},
- {NULL}
-};
-// attributes structure
-static PyGetSetDef imageViewportGetSets[] =
-{
- {(char*)"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, (char*)"use whole viewport to capture", NULL},
- {(char*)"position", (getter)ImageViewport_getPosition, (setter)ImageViewport_setPosition, (char*)"upper left corner of captured area", NULL},
- {(char*)"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, (char*)"size of viewport area being captured", NULL},
- {(char*)"alpha", (getter)ImageViewport_getAlpha, (setter)ImageViewport_setAlpha, (char*)"use alpha in texture", NULL},
- // attributes from ImageBase class
- {(char*)"valid", (getter)Image_valid, NULL, (char*)"bool to tell if an image is available", NULL},
- {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
- {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
- {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL},
- {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
- {(char*)"zbuff", (getter)Image_getZbuff, (setter)Image_setZbuff, (char*)"use depth buffer as texture", NULL},
- {(char*)"depth", (getter)Image_getDepth, (setter)Image_setDepth, (char*)"get depth information from z-buffer as array of float", NULL},
- {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
- {NULL}
-};
-
-
-// define python type
-PyTypeObject ImageViewportType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.ImageViewport", /*tp_name*/
- sizeof(PyImage), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Image_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Image source from viewport", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- imageViewportMethods, /* tp_methods */
- 0, /* tp_members */
- imageViewportGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Image_init<ImageViewport>, /* tp_init */
- 0, /* tp_alloc */
- Image_allocNew, /* tp_new */
-};
diff --git a/source/gameengine/VideoTexture/ImageViewport.h b/source/gameengine/VideoTexture/ImageViewport.h
deleted file mode 100644
index 8a7e9cfd2ba..00000000000
--- a/source/gameengine/VideoTexture/ImageViewport.h
+++ /dev/null
@@ -1,113 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ImageViewport.h
- * \ingroup bgevideotex
- */
-
-#ifndef __IMAGEVIEWPORT_H__
-#define __IMAGEVIEWPORT_H__
-
-
-#include "Common.h"
-
-#include "ImageBase.h"
-#include "RAS_IOffScreen.h"
-
-
-/// class for viewport access
-class ImageViewport : public ImageBase
-{
-public:
- /// constructor
- ImageViewport (PyRASOffScreen *offscreen=NULL);
-
- /// destructor
- virtual ~ImageViewport (void);
-
- /// is whole buffer used
- bool getWhole (void) { return m_whole; }
- /// set whole buffer use
- void setWhole (bool whole);
-
- /// is alpha channel used
- bool getAlpha (void) { return m_alpha; }
- /// set whole buffer use
- void setAlpha (bool alpha) { m_alpha = alpha; }
-
- /// get capture size in viewport
- short * getCaptureSize (void) { return m_capSize; }
- /// set capture size in viewport
- void setCaptureSize (short size[2] = NULL);
-
- /// get position in viewport
- GLint * getPosition (void) { return m_position; }
- /// set position in viewport
- void setPosition (GLint pos[2] = NULL);
-
- /// capture image from viewport to user buffer
- virtual bool loadImage(unsigned int *buffer, unsigned int size, unsigned int format, double ts);
-
-protected:
- /// frame buffer rectangle
- GLint m_viewport[4];
-
- /// size of captured area
- short m_capSize[2];
- /// use whole viewport
- bool m_whole;
- /// use alpha channel
- bool m_alpha;
-
- /// position of capture rectangle in viewport
- GLint m_position[2];
- /// upper left point for capturing
- GLint m_upLeft[2];
-
- /// buffer to copy viewport
- BYTE * m_viewportImage;
- /// texture is initialized
- bool m_texInit;
-
- /// capture image from viewport
- virtual void calcImage (unsigned int texId, double ts) { calcViewport(texId, ts, GL_RGBA); }
-
- /// capture image from viewport
- virtual void calcViewport (unsigned int texId, double ts, unsigned int format);
-
- /// get viewport size
- GLint * getViewportSize (void) { return m_viewport + 2; }
-};
-
-PyObject *ImageViewport_getCaptureSize(PyImage *self, void *closure);
-int ImageViewport_setCaptureSize(PyImage *self, PyObject *value, void *closure);
-PyObject *ImageViewport_getWhole(PyImage *self, void *closure);
-int ImageViewport_setWhole(PyImage *self, PyObject *value, void *closure);
-PyObject *ImageViewport_getAlpha(PyImage *self, void *closure);
-int ImageViewport_setAlpha(PyImage *self, PyObject *value, void *closure);
-
-#endif
-
diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp
deleted file mode 100644
index 18f477f6178..00000000000
--- a/source/gameengine/VideoTexture/PyTypeList.cpp
+++ /dev/null
@@ -1,97 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of blendTex library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/PyTypeList.cpp
- * \ingroup bgevideotex
- */
-
-#include "PyTypeList.h"
-
-#include <memory>
-#include <vector>
-
-#include "EXP_PyObjectPlus.h"
-
-/// destructor
-PyTypeList::~PyTypeList()
-{
- // if list exists
- if (m_list.get() != NULL)
- for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it)
- delete *it;
-}
-
-/// check, if type is in list
-bool PyTypeList::in (PyTypeObject *type)
-{
- // if list exists
- if (m_list.get() != NULL)
- // iterate items in list
- for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it)
- // if item is found, return with success
- if ((*it)->getType() == type) return true;
- // otherwise return not found
- return false;
-}
-
-/// add type to list
-void PyTypeList::add (PyTypeObject *type, const char *name)
-{
- // if list doesn't exist, create it
- if (m_list.get() == NULL)
- m_list.reset(new PyTypeListType());
- if (!in(type))
- // add new item to list
- m_list->push_back(new PyTypeListItem(type, name));
-}
-
-/// prepare types
-bool PyTypeList::ready (void)
-{
- // if list exists
- if (m_list.get() != NULL)
- // iterate items in list
- for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it)
- // if preparation failed, report it
- if (PyType_Ready((*it)->getType()) < 0) return false;
- // success
- return true;
-}
-
-/// register types to module
-void PyTypeList::reg(PyObject *module)
-{
- // if list exists
- if (m_list.get() != NULL)
- // iterate items in list
- for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it)
- {
- // increase ref count
- Py_INCREF((*it)->getType());
- // add type to module
- PyModule_AddObject(module, (*it)->getName(), (PyObject *)(*it)->getType());
- }
-}
diff --git a/source/gameengine/VideoTexture/PyTypeList.h b/source/gameengine/VideoTexture/PyTypeList.h
deleted file mode 100644
index ce0eb81e656..00000000000
--- a/source/gameengine/VideoTexture/PyTypeList.h
+++ /dev/null
@@ -1,100 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of blendTex library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file PyTypeList.h
- * \ingroup bgevideotex
- */
-
-#ifndef __PYTYPELIST_H__
-#define __PYTYPELIST_H__
-
-#include "Common.h"
-
-#include <memory>
-#include <vector>
-
-#include "EXP_PyObjectPlus.h"
-
-// forward declaration
-class PyTypeListItem;
-
-// type for list of types
-typedef std::vector<PyTypeListItem*> PyTypeListType;
-
-
-/// class to store list of python types
-class PyTypeList
-{
-public:
- /// destructor
- ~PyTypeList();
-
- /// check, if type is in list
- bool in (PyTypeObject *type);
-
- /// add type to list
- void add (PyTypeObject *type, const char * name);
-
- /// prepare types
- bool ready (void);
-
- /// register types to module
- void reg(PyObject *module);
-
-protected:
- /// pointer to list of types
-#if (__cplusplus > 199711L) /* || (defined(_MSC_VER) && _MSC_VER >= 1800) */
- std::unique_ptr<PyTypeListType> m_list;
-#else
- std::auto_ptr<PyTypeListType> m_list;
-#endif
-};
-
-
-/// class for item of python type list
-class PyTypeListItem
-{
-public:
- /// constructor adds type into list
- PyTypeListItem (PyTypeObject *type, const char * name)
- : m_type(type), m_name(name)
- { }
-
- /// does type match
- PyTypeObject *getType (void) { return m_type; }
-
- /// get name of type
- const char * getName (void) { return m_name; }
-
-protected:
- /// pointer to type object
- PyTypeObject *m_type;
- /// name of type
- const char *m_name;
-};
-
-
-#endif
diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp
deleted file mode 100644
index 48dc4c705bf..00000000000
--- a/source/gameengine/VideoTexture/Texture.cpp
+++ /dev/null
@@ -1,533 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/Texture.cpp
- * \ingroup bgevideotex
- */
-
-// implementation
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "KX_GameObject.h"
-#include "KX_Light.h"
-#include "RAS_MeshObject.h"
-#include "RAS_ILightObject.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_image_types.h"
-#include "IMB_imbuf_types.h"
-#include "BKE_image.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "KX_BlenderMaterial.h"
-#include "BL_Texture.h"
-
-#include "KX_KetsjiEngine.h"
-#include "KX_PythonInit.h"
-#include "Texture.h"
-#include "ImageBase.h"
-#include "Exception.h"
-
-#include <memory.h>
-#include "GPU_glew.h"
-
-extern "C" {
- #include "IMB_imbuf.h"
-}
-
-// macro for exception handling and logging
-#define CATCH_EXCP catch (Exception & exp) \
-{ exp.report(); return NULL; }
-
-
-// Blender GameObject type
-static BlendType<KX_GameObject> gameObjectType ("KX_GameObject");
-static BlendType<KX_LightObject> lightObjectType ("KX_LightObject");
-
-
-// load texture
-void loadTexture(unsigned int texId, unsigned int *texture, short *size,
- bool mipmap)
-{
- // load texture for rendering
- glBindTexture(GL_TEXTURE_2D, texId);
- if (mipmap)
- {
- int i;
- ImBuf *ibuf;
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- ibuf = IMB_allocFromBuffer(texture, NULL, size[0], size[1]);
-
- IMB_makemipmap(ibuf, true);
-
- for (i = 0; i < ibuf->miptot; i++) {
- ImBuf *mip = IMB_getmipmap(ibuf, i);
-
- glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, mip->x, mip->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect);
- }
- IMB_freeImBuf(ibuf);
- }
- else
- {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, size[0], size[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
- }
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-}
-
-
-// get pointer to material
-RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID)
-{
- // if object is available
- if (obj != NULL)
- {
- // get pointer to texture image
- KX_GameObject * gameObj = gameObjectType.checkType(obj);
- if (gameObj != NULL && gameObj->GetMeshCount() > 0)
- {
- // get material from mesh
- RAS_MeshObject * mesh = gameObj->GetMesh(0);
- RAS_MeshMaterial *meshMat = mesh->GetMeshMaterial(matID);
- if (meshMat != NULL && meshMat->m_bucket != NULL)
- // return pointer to polygon or blender material
- return meshMat->m_bucket->GetPolyMaterial();
- }
- }
- // otherwise material was not found
- return NULL;
-}
-
-// get pointer to a lamp
-static KX_LightObject *getLamp(PyObject *obj)
-{
- // if object is available
- if (obj == NULL) return NULL;
-
- // returns NULL if obj is not a KX_LightObject
- return lightObjectType.checkType(obj);
-}
-
-
-// get material ID
-short getMaterialID(PyObject *obj, const char *name)
-{
- // search for material
- for (short matID = 0;; ++matID)
- {
- // get material
- RAS_IPolyMaterial * mat = getMaterial(obj, matID);
- // if material is not available, report that no material was found
- if (mat == NULL)
- break;
- // name is a material name if it starts with MA and a UV texture name if it starts with IM
- if (name[0] == 'I' && name[1] == 'M') {
- // if texture name matches
- if (strcmp(mat->GetTextureName().ReadPtr(), name) == 0)
- return matID;
- }
- else {
- // if material name matches
- if (strcmp(mat->GetMaterialName().ReadPtr(), name) == 0)
- return matID;
- }
- }
- // material was not found
- return -1;
-}
-
-
-// Texture object allocation
-static PyObject *Texture_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- // allocate object
- Texture * self = reinterpret_cast<Texture*>(type->tp_alloc(type, 0));
- // initialize object structure
- self->m_actTex = 0;
- self->m_orgSaved = false;
- self->m_imgBuf = NULL;
- self->m_imgTexture = NULL;
- self->m_matTexture = NULL;
- self->m_mipmap = false;
- self->m_scaledImBuf = NULL;
- self->m_source = NULL;
- self->m_lastClock = 0.0;
- // return allocated object
- return reinterpret_cast<PyObject*>(self);
-}
-
-
-// forward declaration
-PyObject *Texture_close(Texture *self);
-int Texture_setSource(Texture *self, PyObject *value, void *closure);
-
-
-// Texture object deallocation
-static void Texture_dealloc(Texture *self)
-{
- // release renderer
- Py_XDECREF(self->m_source);
- // close texture
- PyObject *ret = Texture_close(self);
- Py_DECREF(ret);
- // release scaled image buffer
- IMB_freeImBuf(self->m_scaledImBuf);
- // release object
- Py_TYPE((PyObject *)self)->tp_free((PyObject *)self);
-}
-
-
-ExceptionID MaterialNotAvail;
-ExpDesc MaterialNotAvailDesc(MaterialNotAvail, "Texture material is not available");
-
-// Texture object initialization
-static int Texture_init(Texture *self, PyObject *args, PyObject *kwds)
-{
- // parameters - game object with video texture
- PyObject *obj = NULL;
- // material ID
- short matID = 0;
- // texture ID
- short texID = 0;
- // texture object with shared texture ID
- Texture * texObj = NULL;
-
- static const char *kwlist[] = {"gameObj", "materialID", "textureID", "textureObj", NULL};
-
- // get parameters
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|hhO!",
- const_cast<char**>(kwlist), &obj, &matID, &texID, &TextureType,
- &texObj))
- return -1;
-
- // if parameters are available
- if (obj != NULL)
- {
- // process polygon material or blender material
- try
- {
- // get pointer to texture image
- RAS_IPolyMaterial * mat = getMaterial(obj, matID);
- KX_LightObject * lamp = getLamp(obj);
- if (mat != NULL)
- {
- // is it blender material or polygon material
- if (mat->GetFlag() & RAS_BLENDERGLSL)
- {
- self->m_imgTexture = static_cast<KX_BlenderMaterial*>(mat)->getImage(texID);
- self->m_useMatTexture = false;
- } else
- {
- // get blender material texture
- self->m_matTexture = static_cast<KX_BlenderMaterial*>(mat)->getTex(texID);
- self->m_useMatTexture = true;
- }
- }
- else if (lamp != NULL)
- {
- self->m_imgTexture = lamp->GetLightData()->GetTextureImage(texID);
- self->m_useMatTexture = false;
- }
-
- // check if texture is available, if not, initialization failed
- if (self->m_imgTexture == NULL && self->m_matTexture == NULL)
- // throw exception if initialization failed
- THRWEXCP(MaterialNotAvail, S_OK);
-
- // if texture object is provided
- if (texObj != NULL)
- {
- // copy texture code
- self->m_actTex = texObj->m_actTex;
- self->m_mipmap = texObj->m_mipmap;
- if (texObj->m_source != NULL)
- Texture_setSource(self, reinterpret_cast<PyObject*>(texObj->m_source), NULL);
- }
- else
- // otherwise generate texture code
- glGenTextures(1, (GLuint*)&self->m_actTex);
- }
- catch (Exception & exp)
- {
- exp.report();
- return -1;
- }
- }
- // initialization succeded
- return 0;
-}
-
-
-// close added texture
-PyObject *Texture_close(Texture * self)
-{
- // restore texture
- if (self->m_orgSaved)
- {
- self->m_orgSaved = false;
- // restore original texture code
- if (self->m_useMatTexture)
- self->m_matTexture->swapTexture(self->m_orgTex);
- else
- {
- self->m_imgTexture->bindcode[TEXTARGET_TEXTURE_2D] = self->m_orgTex;
- BKE_image_release_ibuf(self->m_imgTexture, self->m_imgBuf, NULL);
- self->m_imgBuf = NULL;
- }
- // drop actual texture
- if (self->m_actTex != 0)
- {
- glDeleteTextures(1, (GLuint *)&self->m_actTex);
- self->m_actTex = 0;
- }
- }
- Py_RETURN_NONE;
-}
-
-
-// refresh texture
-static PyObject *Texture_refresh(Texture *self, PyObject *args)
-{
- // get parameter - refresh source
- PyObject *param;
- double ts = -1.0;
-
- if (!PyArg_ParseTuple(args, "O|d:refresh", &param, &ts) || !PyBool_Check(param))
- {
- // report error
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return NULL;
- }
- // some trick here: we are in the business of loading a texture,
- // no use to do it if we are still in the same rendering frame.
- // We find this out by looking at the engine current clock time
- KX_KetsjiEngine* engine = KX_GetActiveEngine();
- if (engine->GetClockTime() != self->m_lastClock)
- {
- self->m_lastClock = engine->GetClockTime();
- // set source refresh
- bool refreshSource = (param == Py_True);
- // try to proces texture from source
- try
- {
- // if source is available
- if (self->m_source != NULL)
- {
- // check texture code
- if (!self->m_orgSaved)
- {
- self->m_orgSaved = true;
- // save original image code
- if (self->m_useMatTexture)
- self->m_orgTex = self->m_matTexture->swapTexture(self->m_actTex);
- else
- {
- // Swapping will work only if the GPU has already loaded the image.
- // If not, it will delete and overwrite our texture on next render.
- // To avoid that, we acquire the image buffer now.
- // WARNING: GPU has a ImageUser to pass, we don't. Using NULL
- // works on image file, not necessarily on other type of image.
- self->m_imgBuf = BKE_image_acquire_ibuf(self->m_imgTexture, NULL, NULL);
- self->m_orgTex = self->m_imgTexture->bindcode[TEXTARGET_TEXTURE_2D];
- self->m_imgTexture->bindcode[TEXTARGET_TEXTURE_2D] = self->m_actTex;
- }
- }
-
- // get texture
- unsigned int * texture = self->m_source->m_image->getImage(self->m_actTex, ts);
- // if texture is available
- if (texture != NULL)
- {
- // get texture size
- short * orgSize = self->m_source->m_image->getSize();
- // calc scaled sizes
- short size[2];
- if (GLEW_ARB_texture_non_power_of_two)
- {
- size[0] = orgSize[0];
- size[1] = orgSize[1];
- }
- else
- {
- size[0] = ImageBase::calcSize(orgSize[0]);
- size[1] = ImageBase::calcSize(orgSize[1]);
- }
- // scale texture if needed
- if (size[0] != orgSize[0] || size[1] != orgSize[1])
- {
- IMB_freeImBuf(self->m_scaledImBuf);
- self->m_scaledImBuf = IMB_allocFromBuffer(texture, NULL, orgSize[0], orgSize[1]);
- IMB_scaleImBuf(self->m_scaledImBuf, size[0], size[1]);
-
- // use scaled image instead original
- texture = self->m_scaledImBuf->rect;
- }
- // load texture for rendering
- loadTexture(self->m_actTex, texture, size, self->m_mipmap);
- }
- // refresh texture source, if required
- if (refreshSource) {
- self->m_source->m_image->refresh();
- }
- }
- }
- CATCH_EXCP;
- }
- Py_RETURN_NONE;
-}
-
-// get OpenGL Bind Id
-static PyObject *Texture_getBindId(Texture *self, void *closure)
-{
- unsigned int id = self->m_actTex;
- return Py_BuildValue("h", id);
-}
-
-// get mipmap value
-static PyObject *Texture_getMipmap(Texture *self, void *closure)
-{
- // return true if flag is set, otherwise false
- if (self->m_mipmap) Py_RETURN_TRUE;
- else Py_RETURN_FALSE;
-}
-
-// set mipmap value
-static int Texture_setMipmap(Texture *self, PyObject *value, void *closure)
-{
- // check parameter, report failure
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- // set mipmap
- self->m_mipmap = value == Py_True;
- // success
- return 0;
-}
-
-
-// get source object
-static PyObject *Texture_getSource(Texture *self, PyObject *value, void *closure)
-{
- // if source exists
- if (self->m_source != NULL)
- {
- Py_INCREF(self->m_source);
- return reinterpret_cast<PyObject*>(self->m_source);
- }
- // otherwise return None
- Py_RETURN_NONE;
-}
-
-
-// set source object
-int Texture_setSource(Texture *self, PyObject *value, void *closure)
-{
- // check new value
- if (value == NULL || !pyImageTypes.in(Py_TYPE(value)))
- {
- // report value error
- PyErr_SetString(PyExc_TypeError, "Invalid type of value");
- return -1;
- }
- // increase ref count for new value
- Py_INCREF(value);
- // release previous
- Py_XDECREF(self->m_source);
- // set new value
- self->m_source = reinterpret_cast<PyImage*>(value);
- // return success
- return 0;
-}
-
-
-// class Texture methods
-static PyMethodDef textureMethods[] =
-{
- { "close", (PyCFunction)Texture_close, METH_NOARGS, "Close dynamic texture and restore original"},
- { "refresh", (PyCFunction)Texture_refresh, METH_VARARGS, "Refresh texture from source"},
- {NULL} /* Sentinel */
-};
-
-// class Texture attributes
-static PyGetSetDef textureGetSets[] =
-{
- {(char*)"source", (getter)Texture_getSource, (setter)Texture_setSource, (char*)"source of texture", NULL},
- {(char*)"mipmap", (getter)Texture_getMipmap, (setter)Texture_setMipmap, (char*)"mipmap texture", NULL},
- {(char*)"bindId", (getter)Texture_getBindId, NULL, (char*)"OpenGL Bind Name", NULL},
- {NULL}
-};
-
-
-// class Texture declaration
-PyTypeObject TextureType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.Texture", /*tp_name*/
- sizeof(Texture), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Texture_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Texture objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- textureMethods, /* tp_methods */
- 0, /* tp_members */
- textureGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Texture_init, /* tp_init */
- 0, /* tp_alloc */
- Texture_new, /* tp_new */
-};
diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h
deleted file mode 100644
index dc38b4181bb..00000000000
--- a/source/gameengine/VideoTexture/Texture.h
+++ /dev/null
@@ -1,99 +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.
- *
- * Copyright (c) 2006 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file VideoTexture/Texture.h
- * \ingroup bgevideotex
- */
-
-#ifndef __TEXTURE_H__
-#define __TEXTURE_H__
-
-#include "EXP_PyObjectPlus.h"
-#include <structmember.h>
-
-#include "DNA_image_types.h"
-#include "BL_Texture.h"
-#include "KX_BlenderMaterial.h"
-
-#include "ImageBase.h"
-#include "BlendType.h"
-#include "Exception.h"
-
-
-struct ImBuf;
-
-// type Texture declaration
-struct Texture
-{
- PyObject_HEAD
-
- // texture is using blender material
- bool m_useMatTexture;
-
- // video texture bind code
- unsigned int m_actTex;
- // original texture bind code
- unsigned int m_orgTex;
- // original texture saved
- bool m_orgSaved;
-
- // kernel image buffer, to make sure the image is loaded before we swap the bindcode
- struct ImBuf *m_imgBuf;
- // texture image for game materials
- Image * m_imgTexture;
- // texture for blender materials
- BL_Texture * m_matTexture;
-
- // use mipmapping
- bool m_mipmap;
-
- // scaled image buffer
- ImBuf * m_scaledImBuf;
- // last refresh
- double m_lastClock;
-
- // image source
- PyImage * m_source;
-};
-
-
-// Texture type description
-extern PyTypeObject TextureType;
-
-// load texture
-void loadTexture(unsigned int texId, unsigned int *texture, short *size,
- bool mipmap = false);
-
-// get material
-RAS_IPolyMaterial *getMaterial(PyObject *obj, short matID);
-
-// get material ID
-short getMaterialID(PyObject *obj, const char *name);
-
-// Exceptions
-extern ExceptionID MaterialNotAvail;
-
-#endif
diff --git a/source/gameengine/VideoTexture/VideoBase.cpp b/source/gameengine/VideoTexture/VideoBase.cpp
deleted file mode 100644
index d373055b5df..00000000000
--- a/source/gameengine/VideoTexture/VideoBase.cpp
+++ /dev/null
@@ -1,254 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/VideoBase.cpp
- * \ingroup bgevideotex
- */
-
-#if defined WIN32
-#define WINDOWS_LEAN_AND_MEAN
-#include <windows.h>
-#endif
-
-#include "VideoBase.h"
-
-#include "FilterSource.h"
-
-// VideoBase implementation
-
-
-// initialize image data
-void VideoBase::init(short width, short height)
-{
- // save original sizes
- m_orgSize[0] = width;
- m_orgSize[1] = height;
- // call base class initialization
- ImageBase::init(width, height);
-}
-
-
-// process video frame
-void VideoBase::process (BYTE *sample)
-{
- // if scale was changed
- if (m_scaleChange)
- // reset image
- init(m_orgSize[0], m_orgSize[1]);
- // if image is allocated and is able to store new image
- if (m_image != NULL && !m_avail)
- {
- // filters used
- // convert video format to image
- switch (m_format)
- {
- case RGBA32:
- {
- FilterRGBA32 filtRGBA;
- // use filter object for format to convert image
- filterImage(filtRGBA, sample, m_orgSize);
- // finish
- break;
- }
- case RGB24:
- {
- FilterRGB24 filtRGB;
- // use filter object for format to convert image
- filterImage(filtRGB, sample, m_orgSize);
- // finish
- break;
- }
- case YV12:
- {
- // use filter object for format to convert image
- FilterYV12 filtYUV;
- filtYUV.setBuffs(sample, m_orgSize);
- filterImage(filtYUV, sample, m_orgSize);
- // finish
- break;
- }
- case None:
- break; /* assert? */
- }
- }
-}
-
-
-// python functions
-
-
-// exceptions for video source initialization
-ExceptionID SourceVideoEmpty, SourceVideoCreation;
-ExpDesc SourceVideoEmptyDesc(SourceVideoEmpty, "Source Video is empty");
-ExpDesc SourceVideoCreationDesc(SourceVideoCreation, "SourceVideo object was not created");
-
-// open video source
-void Video_open(VideoBase *self, char *file, short captureID)
-{
- // if file is empty, throw exception
- if (file == NULL) THRWEXCP(SourceVideoEmpty, S_OK);
-
- // open video file or capture device
- if (captureID >= 0)
- self->openCam(file, captureID);
- else
- self->openFile(file);
-}
-
-
-// play video
-PyObject *Video_play(PyImage *self)
-{ if (getVideo(self)->play()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
-
-// pause video
-PyObject *Video_pause(PyImage *self)
-{ if (getVideo(self)->pause()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
-
-PyObject *Video_stop(PyImage *self)
-{ if (getVideo(self)->stop()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
-
-// get status
-PyObject *Video_getStatus(PyImage *self, void *closure)
-{
- return Py_BuildValue("h", getVideo(self)->getStatus());
-}
-
-// refresh video
-PyObject *Video_refresh(PyImage *self, PyObject *args)
-{
- Py_buffer buffer;
- char *mode = NULL;
- unsigned int format;
- double ts = -1.0;
-
- memset(&buffer, 0, sizeof(buffer));
- if (PyArg_ParseTuple(args, "|s*sd:refresh", &buffer, &mode, &ts)) {
- if (buffer.buf) {
- // a target buffer is provided, verify its format
- if (buffer.readonly) {
- PyErr_SetString(PyExc_TypeError, "Buffers passed in argument must be writable");
- }
- else if (!PyBuffer_IsContiguous(&buffer, 'C')) {
- PyErr_SetString(PyExc_TypeError, "Buffers passed in argument must be contiguous in memory");
- }
- else if (((intptr_t)buffer.buf & 3) != 0) {
- PyErr_SetString(PyExc_TypeError, "Buffers passed in argument must be aligned to 4 bytes boundary");
- }
- else {
- // ready to get the image into our buffer
- try {
- if (mode == NULL || !strcmp(mode, "RGBA"))
- format = GL_RGBA;
- else if (!strcmp(mode, "BGRA"))
- format = GL_BGRA;
- else
- THRWEXCP(InvalidImageMode,S_OK);
-
- if (!self->m_image->loadImage((unsigned int *)buffer.buf, buffer.len, format, ts)) {
- PyErr_SetString(PyExc_TypeError, "Could not load the buffer, perhaps size is not compatible");
- }
- }
- catch (Exception & exp) {
- exp.report();
- }
- }
- PyBuffer_Release(&buffer);
- if (PyErr_Occurred())
- return NULL;
- }
- }
- else
- {
- return NULL;
- }
- getVideo(self)->refresh();
- return Video_getStatus(self, NULL);
-}
-
-
-// get range
-PyObject *Video_getRange(PyImage *self, void *closure)
-{
- return Py_BuildValue("[ff]", getVideo(self)->getRange()[0],
- getVideo(self)->getRange()[1]);
-}
-
-// set range
-int Video_setRange(PyImage *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2 ||
- /* XXX - this is incorrect if the sequence is not a list/tuple! */
- !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 0)) ||
- !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 1)))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 float");
- return -1;
- }
- // set range
- getVideo(self)->setRange(PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)),
- PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)));
- // success
- return 0;
-}
-
-// get repeat
-PyObject *Video_getRepeat (PyImage *self, void *closure)
-{ return Py_BuildValue("h", getVideo(self)->getRepeat()); }
-
-// set repeat
-int Video_setRepeat(PyImage *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL || !PyLong_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be an int");
- return -1;
- }
- // set repeat
- getVideo(self)->setRepeat(int(PyLong_AsLong(value)));
- // success
- return 0;
-}
-
-// get frame rate
-PyObject *Video_getFrameRate (PyImage *self, void *closure)
-{ return Py_BuildValue("f", double(getVideo(self)->getFrameRate())); }
-
-// set frame rate
-int Video_setFrameRate(PyImage *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL || !PyFloat_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a float");
- return -1;
- }
- // set repeat
- getVideo(self)->setFrameRate(float(PyFloat_AsDouble(value)));
- // success
- return 0;
-}
diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h
deleted file mode 100644
index 77f46fdccd8..00000000000
--- a/source/gameengine/VideoTexture/VideoBase.h
+++ /dev/null
@@ -1,207 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file VideoBase.h
- * \ingroup bgevideotex
- */
-
-#ifndef __VIDEOBASE_H__
-#define __VIDEOBASE_H__
-
-
-#include "EXP_PyObjectPlus.h"
-
-#include "ImageBase.h"
-
-#include "Exception.h"
-
-// source states
-const int SourceError = -1;
-const int SourceEmpty = 0;
-const int SourceReady = 1;
-const int SourcePlaying = 2;
-const int SourceStopped = 3;
-
-
-// video source formats
-enum VideoFormat { None, RGB24, YV12, RGBA32 };
-
-
-/// base class for video source
-class VideoBase : public ImageBase
-{
-public:
- /// constructor
- VideoBase (void) : ImageBase(true), m_format(None), m_status(SourceEmpty),
- m_repeat(0), m_frameRate(1.0)
- {
- m_orgSize[0] = m_orgSize[1] = 0;
- m_range[0] = m_range[1] = 0.0;
- }
-
- /// destructor
- virtual ~VideoBase (void) {}
-
- /// open video file
- virtual void openFile(char *file)
- {
- m_isFile = true;
- m_status = SourceReady;
- }
- /// open video capture device
- virtual void openCam(char *file, short camIdx)
- {
- m_isFile = false;
- m_status = SourceReady;
- }
-
- /// play video
- virtual bool play (void)
- {
- if (m_status == SourceReady || m_status == SourceStopped)
- {
- m_status = SourcePlaying;
- return true;
- }
- return false;
- }
- /// pause video
- virtual bool pause (void)
- {
- if (m_status == SourcePlaying)
- {
- m_status = SourceStopped;
- return true;
- }
- return false;
- }
- /// stop video
- virtual bool stop (void)
- {
- if (m_status == SourcePlaying)
- {
- m_status = SourceStopped;
- return true;
- }
- return false;
- }
-
- // get video status
- int getStatus (void) { return m_status; }
-
- /// get play range
- const double * getRange (void) { return m_range; }
- /// set play range
- virtual void setRange (double start, double stop)
- {
- if (m_isFile)
- {
- m_range[0] = start;
- m_range[1] = stop;
- }
- }
-
- // get video repeat
- int getRepeat (void) { return m_repeat; }
- /// set video repeat
- virtual void setRepeat (int rep)
- { if (m_isFile) m_repeat = rep; }
-
- /// get frame rate
- float getFrameRate (void) { return m_frameRate; }
- /// set frame rate
- virtual void setFrameRate (float rate)
- { if (m_isFile) m_frameRate = rate > 0.0f ? rate : 1.0f; }
-
-protected:
- /// video format
- VideoFormat m_format;
- /// original video size
- short m_orgSize[2];
-
- /// video status
- int m_status;
-
- /// is source file
- bool m_isFile;
-
- /// replay range
- double m_range[2];
- /// repeat count
- int m_repeat;
- /// frame rate
- float m_frameRate;
-
- /// initialize image data
- void init (short width, short height);
-
- /// process source data
- void process (BYTE * sample);
-};
-
-
-
-// python fuctions
-
-
-// cast Image pointer to Video
-inline VideoBase *getVideo(PyImage *self)
-{ return static_cast<VideoBase*>(self->m_image); }
-
-
-extern ExceptionID SourceVideoCreation;
-
-// object initialization
-template <class T> void Video_init(PyImage *self)
-{
- // create source video object
- if (self->m_image != NULL) delete self->m_image;
- HRESULT hRslt = S_OK;
- self->m_image = new T(&hRslt);
- CHCKHRSLT(hRslt, SourceVideoCreation);
-}
-
-
-// video functions
-void Video_open(VideoBase *self, char *file, short captureID);
-PyObject *Video_play(PyImage *self);
-PyObject *Video_pause(PyImage *self);
-PyObject *Video_stop(PyImage *self);
-PyObject *Video_refresh(PyImage *self, PyObject *args);
-PyObject *Video_getStatus(PyImage *self, void *closure);
-PyObject *Video_getRange(PyImage *self, void *closure);
-int Video_setRange(PyImage *self, PyObject *value, void *closure);
-PyObject *Video_getRepeat(PyImage *self, void *closure);
-int Video_setRepeat(PyImage *self, PyObject *value, void *closure);
-PyObject *Video_getFrameRate(PyImage *self, void *closure);
-int Video_setFrameRate(PyImage *self, PyObject *value, void *closure);
-
-/* py api */
-extern PyTypeObject ImageRenderType;
-extern PyTypeObject ImageMirrorType;
-extern PyTypeObject ImageViewportType;
-
-#endif /* __VIDEOBASE_H__ */
diff --git a/source/gameengine/VideoTexture/VideoDeckLink.cpp b/source/gameengine/VideoTexture/VideoDeckLink.cpp
deleted file mode 100644
index c588a4b33cf..00000000000
--- a/source/gameengine/VideoTexture/VideoDeckLink.cpp
+++ /dev/null
@@ -1,1228 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/VideoDeckLink.cpp
- * \ingroup bgevideotex
- */
-
-#ifdef WITH_GAMEENGINE_DECKLINK
-
-// FFmpeg defines its own version of stdint.h on Windows.
-// Decklink needs FFmpeg, so it uses its version of stdint.h
-// this is necessary for INT64_C macro
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-// this is necessary for UINTPTR_MAX (used by atomic-ops)
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS
-#ifdef __STDC_LIMIT_MACROS /* else it may be unused */
-#endif
-#endif
-#include <stdint.h>
-#include <string.h>
-#ifndef WIN32
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/mman.h>
-#endif
-
-#include "atomic_ops.h"
-
-#include "MEM_guardedalloc.h"
-#include "PIL_time.h"
-#include "VideoDeckLink.h"
-#include "DeckLink.h"
-#include "Exception.h"
-#include "KX_KetsjiEngine.h"
-#include "KX_PythonInit.h"
-
-extern ExceptionID DeckLinkInternalError;
-ExceptionID SourceVideoOnlyCapture, VideoDeckLinkBadFormat, VideoDeckLinkOpenCard, VideoDeckLinkDvpInternalError, VideoDeckLinkPinMemoryError;
-ExpDesc SourceVideoOnlyCaptureDesc(SourceVideoOnlyCapture, "This video source only allows live capture");
-ExpDesc VideoDeckLinkBadFormatDesc(VideoDeckLinkBadFormat, "Invalid or unsupported capture format, should be <mode>/<pixel>[/3D]");
-ExpDesc VideoDeckLinkOpenCardDesc(VideoDeckLinkOpenCard, "Cannot open capture card, check if driver installed");
-ExpDesc VideoDeckLinkDvpInternalErrorDesc(VideoDeckLinkDvpInternalError, "DVP API internal error, please report");
-ExpDesc VideoDeckLinkPinMemoryErrorDesc(VideoDeckLinkPinMemoryError, "Error pinning memory");
-
-
-#ifdef WIN32
-////////////////////////////////////////////
-// SynInfo
-//
-// Sets up a semaphore which is shared between the GPU and CPU and used to
-// synchronise access to DVP buffers.
-#define DVP_CHECK(cmd) if ((cmd) != DVP_STATUS_OK) THRWEXCP(VideoDeckLinkDvpInternalError, S_OK)
-
-struct SyncInfo
-{
- SyncInfo(uint32_t semaphoreAllocSize, uint32_t semaphoreAddrAlignment)
- {
- mSemUnaligned = (uint32_t*)malloc(semaphoreAllocSize + semaphoreAddrAlignment - 1);
-
- // Apply alignment constraints
- uint64_t val = (uint64_t)mSemUnaligned;
- val += semaphoreAddrAlignment - 1;
- val &= ~((uint64_t)semaphoreAddrAlignment - 1);
- mSem = (uint32_t*)val;
-
- // Initialise
- mSem[0] = 0;
- mReleaseValue = 0;
- mAcquireValue = 0;
-
- // Setup DVP sync object and import it
- DVPSyncObjectDesc syncObjectDesc;
- syncObjectDesc.externalClientWaitFunc = NULL;
- syncObjectDesc.sem = (uint32_t*)mSem;
-
- DVP_CHECK(dvpImportSyncObject(&syncObjectDesc, &mDvpSync));
-
- }
- ~SyncInfo()
- {
- dvpFreeSyncObject(mDvpSync);
- free((void*)mSemUnaligned);
- }
-
- volatile uint32_t* mSem;
- volatile uint32_t* mSemUnaligned;
- volatile uint32_t mReleaseValue;
- volatile uint32_t mAcquireValue;
- DVPSyncObjectHandle mDvpSync;
-};
-
-////////////////////////////////////////////
-// TextureTransferDvp: transfer with GPUDirect
-////////////////////////////////////////////
-
-class TextureTransferDvp : public TextureTransfer
-{
-public:
- TextureTransferDvp(DVPBufferHandle dvpTextureHandle, TextureDesc *pDesc, void *address, uint32_t allocatedSize)
- {
- DVPSysmemBufferDesc sysMemBuffersDesc;
-
- mExtSync = NULL;
- mGpuSync = NULL;
- mDvpSysMemHandle = 0;
- mDvpTextureHandle = 0;
- mTextureHeight = 0;
- mAllocatedSize = 0;
- mBuffer = NULL;
-
- if (!_PinBuffer(address, allocatedSize))
- THRWEXCP(VideoDeckLinkPinMemoryError, S_OK);
- mAllocatedSize = allocatedSize;
- mBuffer = address;
-
- try {
- if (!mBufferAddrAlignment) {
- DVP_CHECK(dvpGetRequiredConstantsGLCtx(&mBufferAddrAlignment, &mBufferGpuStrideAlignment,
- &mSemaphoreAddrAlignment, &mSemaphoreAllocSize,
- &mSemaphorePayloadOffset, &mSemaphorePayloadSize));
- }
- mExtSync = new SyncInfo(mSemaphoreAllocSize, mSemaphoreAddrAlignment);
- mGpuSync = new SyncInfo(mSemaphoreAllocSize, mSemaphoreAddrAlignment);
- sysMemBuffersDesc.width = pDesc->width;
- sysMemBuffersDesc.height = pDesc->height;
- sysMemBuffersDesc.stride = pDesc->stride;
- switch (pDesc->format) {
- case GL_RED_INTEGER:
- sysMemBuffersDesc.format = DVP_RED_INTEGER;
- break;
- default:
- sysMemBuffersDesc.format = DVP_BGRA;
- break;
- }
- switch (pDesc->type) {
- case GL_UNSIGNED_BYTE:
- sysMemBuffersDesc.type = DVP_UNSIGNED_BYTE;
- break;
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- sysMemBuffersDesc.type = DVP_UNSIGNED_INT_2_10_10_10_REV;
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- sysMemBuffersDesc.type = DVP_UNSIGNED_INT_8_8_8_8;
- break;
- case GL_UNSIGNED_INT_10_10_10_2:
- sysMemBuffersDesc.type = DVP_UNSIGNED_INT_10_10_10_2;
- break;
- default:
- sysMemBuffersDesc.type = DVP_UNSIGNED_INT;
- break;
- }
- sysMemBuffersDesc.size = pDesc->width * pDesc->height * 4;
- sysMemBuffersDesc.bufAddr = mBuffer;
- DVP_CHECK(dvpCreateBuffer(&sysMemBuffersDesc, &mDvpSysMemHandle));
- DVP_CHECK(dvpBindToGLCtx(mDvpSysMemHandle));
- mDvpTextureHandle = dvpTextureHandle;
- mTextureHeight = pDesc->height;
- }
- catch (Exception &) {
- clean();
- throw;
- }
- }
- ~TextureTransferDvp()
- {
- clean();
- }
-
- virtual void PerformTransfer()
- {
- // perform the transfer
- // tell DVP that the old texture buffer will no longer be used
- dvpMapBufferEndAPI(mDvpTextureHandle);
- // do we need this?
- mGpuSync->mReleaseValue++;
- dvpBegin();
- // Copy from system memory to GPU texture
- dvpMapBufferWaitDVP(mDvpTextureHandle);
- dvpMemcpyLined(mDvpSysMemHandle, mExtSync->mDvpSync, mExtSync->mAcquireValue, DVP_TIMEOUT_IGNORED,
- mDvpTextureHandle, mGpuSync->mDvpSync, mGpuSync->mReleaseValue, 0, mTextureHeight);
- dvpMapBufferEndDVP(mDvpTextureHandle);
- dvpEnd();
- dvpMapBufferWaitAPI(mDvpTextureHandle);
- // the transfer is now complete and the texture is ready for use
- }
-
-private:
- static uint32_t mBufferAddrAlignment;
- static uint32_t mBufferGpuStrideAlignment;
- static uint32_t mSemaphoreAddrAlignment;
- static uint32_t mSemaphoreAllocSize;
- static uint32_t mSemaphorePayloadOffset;
- static uint32_t mSemaphorePayloadSize;
-
- void clean()
- {
- if (mDvpSysMemHandle) {
- dvpUnbindFromGLCtx(mDvpSysMemHandle);
- dvpDestroyBuffer(mDvpSysMemHandle);
- }
- if (mExtSync)
- delete mExtSync;
- if (mGpuSync)
- delete mGpuSync;
- if (mBuffer)
- _UnpinBuffer(mBuffer, mAllocatedSize);
- }
- SyncInfo* mExtSync;
- SyncInfo* mGpuSync;
- DVPBufferHandle mDvpSysMemHandle;
- DVPBufferHandle mDvpTextureHandle;
- uint32_t mTextureHeight;
- uint32_t mAllocatedSize;
- void* mBuffer;
-};
-
-uint32_t TextureTransferDvp::mBufferAddrAlignment;
-uint32_t TextureTransferDvp::mBufferGpuStrideAlignment;
-uint32_t TextureTransferDvp::mSemaphoreAddrAlignment;
-uint32_t TextureTransferDvp::mSemaphoreAllocSize;
-uint32_t TextureTransferDvp::mSemaphorePayloadOffset;
-uint32_t TextureTransferDvp::mSemaphorePayloadSize;
-
-#endif
-
-////////////////////////////////////////////
-// TextureTransferOGL: transfer using standard OGL buffers
-////////////////////////////////////////////
-
-class TextureTransferOGL : public TextureTransfer
-{
-public:
- TextureTransferOGL(GLuint texId, TextureDesc *pDesc, void *address)
- {
- memcpy(&mDesc, pDesc, sizeof(mDesc));
- mTexId = texId;
- mBuffer = address;
-
- // as we cache transfer object, we will create one texture to hold the buffer
- glGenBuffers(1, &mUnpinnedTextureBuffer);
- // create a storage for it
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mUnpinnedTextureBuffer);
- glBufferData(GL_PIXEL_UNPACK_BUFFER, pDesc->size, NULL, GL_DYNAMIC_DRAW);
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
- }
- ~TextureTransferOGL()
- {
- glDeleteBuffers(1, &mUnpinnedTextureBuffer);
- }
-
- virtual void PerformTransfer()
- {
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mUnpinnedTextureBuffer);
- glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, mDesc.size, mBuffer);
- glBindTexture(GL_TEXTURE_2D, mTexId);
- // NULL for last arg indicates use current GL_PIXEL_UNPACK_BUFFER target as texture data
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mDesc.width, mDesc.height, mDesc.format, mDesc.type, NULL);
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
- }
-private:
- // intermediate texture to receive the buffer
- GLuint mUnpinnedTextureBuffer;
- // target texture to receive the image
- GLuint mTexId;
- // buffer
- void *mBuffer;
- // characteristic of the image
- TextureDesc mDesc;
-};
-
-////////////////////////////////////////////
-// TextureTransferPMB: transfer using pinned memory buffer
-////////////////////////////////////////////
-
-class TextureTransferPMD : public TextureTransfer
-{
-public:
- TextureTransferPMD(GLuint texId, TextureDesc *pDesc, void *address, uint32_t allocatedSize)
- {
- memcpy(&mDesc, pDesc, sizeof(mDesc));
- mTexId = texId;
- mBuffer = address;
- mAllocatedSize = allocatedSize;
-
- _PinBuffer(address, allocatedSize);
-
- // as we cache transfer object, we will create one texture to hold the buffer
- glGenBuffers(1, &mPinnedTextureBuffer);
- // create a storage for it
- glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, mPinnedTextureBuffer);
- glBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, pDesc->size, address, GL_STREAM_DRAW);
- glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
- }
- ~TextureTransferPMD()
- {
- glDeleteBuffers(1, &mPinnedTextureBuffer);
- if (mBuffer)
- _UnpinBuffer(mBuffer, mAllocatedSize);
- }
-
- virtual void PerformTransfer()
- {
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mPinnedTextureBuffer);
- glBindTexture(GL_TEXTURE_2D, mTexId);
- // NULL for last arg indicates use current GL_PIXEL_UNPACK_BUFFER target as texture data
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mDesc.width, mDesc.height, mDesc.format, mDesc.type, NULL);
- // wait for the trasnfer to complete
- GLsync fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
- glClientWaitSync(fence, GL_SYNC_FLUSH_COMMANDS_BIT, 40 * 1000 * 1000); // timeout in nanosec
- glDeleteSync(fence);
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
- }
-private:
- // intermediate texture to receive the buffer
- GLuint mPinnedTextureBuffer;
- // target texture to receive the image
- GLuint mTexId;
- // buffer
- void *mBuffer;
- // the allocated size
- uint32_t mAllocatedSize;
- // characteristic of the image
- TextureDesc mDesc;
-};
-
-bool TextureTransfer::_PinBuffer(void *address, uint32_t size)
-{
-#ifdef WIN32
- return VirtualLock(address, size);
-#elif defined(_POSIX_MEMLOCK_RANGE)
- return !mlock(address, size);
-#endif
-}
-
-void TextureTransfer::_UnpinBuffer(void* address, uint32_t size)
-{
-#ifdef WIN32
- VirtualUnlock(address, size);
-#elif defined(_POSIX_MEMLOCK_RANGE)
- munlock(address, size);
-#endif
-}
-
-
-
-////////////////////////////////////////////
-// PinnedMemoryAllocator
-////////////////////////////////////////////
-
-
-// static members
-bool PinnedMemoryAllocator::mGPUDirectInitialized = false;
-bool PinnedMemoryAllocator::mHasDvp = false;
-bool PinnedMemoryAllocator::mHasAMDPinnedMemory = false;
-size_t PinnedMemoryAllocator::mReservedProcessMemory = 0;
-
-bool PinnedMemoryAllocator::ReserveMemory(size_t size)
-{
-#ifdef WIN32
- // Increase the process working set size to allow pinning of memory.
- if (size <= mReservedProcessMemory)
- return true;
- SIZE_T dwMin = 0, dwMax = 0;
- HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_SET_QUOTA, FALSE, GetCurrentProcessId());
- if (!hProcess)
- return false;
-
- // Retrieve the working set size of the process.
- if (!dwMin && !GetProcessWorkingSetSize(hProcess, &dwMin, &dwMax))
- return false;
-
- BOOL res = SetProcessWorkingSetSize(hProcess, (size - mReservedProcessMemory) + dwMin, (size - mReservedProcessMemory) + dwMax);
- if (!res)
- return false;
- mReservedProcessMemory = size;
- CloseHandle(hProcess);
- return true;
-#else
- struct rlimit rlim;
- if (getrlimit(RLIMIT_MEMLOCK, &rlim) == 0) {
- if (rlim.rlim_cur < size) {
- if (rlim.rlim_max < size)
- rlim.rlim_max = size;
- rlim.rlim_cur = size;
- return !setrlimit(RLIMIT_MEMLOCK, &rlim);
- }
- }
- return false;
-#endif
-}
-
-PinnedMemoryAllocator::PinnedMemoryAllocator(unsigned cacheSize, size_t memSize) :
-mRefCount(1U),
-#ifdef WIN32
-mDvpCaptureTextureHandle(0),
-#endif
-mTexId(0),
-mBufferCacheSize(cacheSize)
-{
- pthread_mutex_init(&mMutex, NULL);
- // do it once
- if (!mGPUDirectInitialized) {
-#ifdef WIN32
- // In windows, AMD_pinned_memory option is not available,
- // we must use special DVP API only available for Quadro cards
- const char* renderer = (const char *)glGetString(GL_RENDERER);
- mHasDvp = (strstr(renderer, "Quadro") != NULL);
-
- if (mHasDvp) {
- // In case the DLL is not in place, don't fail, just fallback on OpenGL
- if (dvpInitGLContext(DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT) != DVP_STATUS_OK) {
- printf("Warning: Could not initialize DVP context, fallback on OpenGL transfer.\nInstall dvp.dll to take advantage of nVidia GPUDirect.\n");
- mHasDvp = false;
- }
- }
-#endif
- if (GLEW_AMD_pinned_memory)
- mHasAMDPinnedMemory = true;
-
- mGPUDirectInitialized = true;
- }
- if (mHasDvp || mHasAMDPinnedMemory) {
- ReserveMemory(memSize);
- }
-}
-
-PinnedMemoryAllocator::~PinnedMemoryAllocator()
-{
- void *address;
- // first clean the cache if not already done
- while (!mBufferCache.empty()) {
- address = mBufferCache.back();
- mBufferCache.pop_back();
- _ReleaseBuffer(address);
- }
- // clean preallocated buffers
- while (!mAllocatedSize.empty()) {
- address = mAllocatedSize.begin()->first;
- _ReleaseBuffer(address);
- }
-
-#ifdef WIN32
- if (mDvpCaptureTextureHandle)
- dvpDestroyBuffer(mDvpCaptureTextureHandle);
-#endif
-}
-
-void PinnedMemoryAllocator::TransferBuffer(void* address, TextureDesc* texDesc, GLuint texId)
-{
- uint32_t allocatedSize = 0;
- TextureTransfer *pTransfer = NULL;
-
- Lock();
- if (mAllocatedSize.count(address) > 0)
- allocatedSize = mAllocatedSize[address];
- Unlock();
- if (!allocatedSize)
- // internal error!!
- return;
- if (mTexId != texId)
- {
- // first time we try to send data to the GPU, allocate a buffer for the texture
- glBindTexture(GL_TEXTURE_2D, texId);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- glTexImage2D(GL_TEXTURE_2D, 0, texDesc->internalFormat, texDesc->width, texDesc->height, 0, texDesc->format, texDesc->type, NULL);
- glBindTexture(GL_TEXTURE_2D, 0);
- mTexId = texId;
- }
-#ifdef WIN32
- if (mHasDvp)
- {
- if (!mDvpCaptureTextureHandle)
- {
- // bind DVP to the OGL texture
- DVP_CHECK(dvpCreateGPUTextureGL(texId, &mDvpCaptureTextureHandle));
- }
- }
-#endif
- Lock();
- if (mPinnedBuffer.count(address) > 0)
- {
- pTransfer = mPinnedBuffer[address];
- }
- Unlock();
- if (!pTransfer)
- {
-#ifdef WIN32
- if (mHasDvp)
- pTransfer = new TextureTransferDvp(mDvpCaptureTextureHandle, texDesc, address, allocatedSize);
- else
-#endif
- if (mHasAMDPinnedMemory) {
- pTransfer = new TextureTransferPMD(texId, texDesc, address, allocatedSize);
- }
- else {
- pTransfer = new TextureTransferOGL(texId, texDesc, address);
- }
- if (pTransfer)
- {
- Lock();
- mPinnedBuffer[address] = pTransfer;
- Unlock();
- }
- }
- if (pTransfer)
- pTransfer->PerformTransfer();
-}
-
-// IUnknown methods
-HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::QueryInterface(REFIID /*iid*/, LPVOID* /*ppv*/)
-{
- return E_NOTIMPL;
-}
-
-ULONG STDMETHODCALLTYPE PinnedMemoryAllocator::AddRef(void)
-{
- return atomic_add_and_fetch_uint32(&mRefCount, 1U);
-}
-
-ULONG STDMETHODCALLTYPE PinnedMemoryAllocator::Release(void)
-{
- uint32_t newCount = atomic_sub_and_fetch_uint32(&mRefCount, 1U);
- if (newCount == 0)
- delete this;
- return (ULONG)newCount;
-}
-
-// IDeckLinkMemoryAllocator methods
-HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::AllocateBuffer(dl_size_t bufferSize, void* *allocatedBuffer)
-{
- Lock();
- if (mBufferCache.empty())
- {
- // Allocate memory on a page boundary
- // Note: aligned alloc exist in Blender but only for small alignment, use direct allocation then.
- // Note: the DeckLink API tries to allocate up to 65 buffer in advance, we will limit this to 3
- // because we don't need any caching
- if (mAllocatedSize.size() >= mBufferCacheSize)
- *allocatedBuffer = NULL;
- else {
-#ifdef WIN32
- *allocatedBuffer = VirtualAlloc(NULL, bufferSize, MEM_COMMIT | MEM_RESERVE | MEM_WRITE_WATCH, PAGE_READWRITE);
-#else
- if (posix_memalign(allocatedBuffer, 4096, bufferSize) != 0)
- *allocatedBuffer = NULL;
-#endif
- mAllocatedSize[*allocatedBuffer] = bufferSize;
- }
- }
- else {
- // Re-use most recently ReleaseBuffer'd address
- *allocatedBuffer = mBufferCache.back();
- mBufferCache.pop_back();
- }
- Unlock();
- return (*allocatedBuffer) ? S_OK : E_OUTOFMEMORY;
-}
-
-HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::ReleaseBuffer(void* buffer)
-{
- HRESULT result = S_OK;
- Lock();
- if (mBufferCache.size() < mBufferCacheSize) {
- mBufferCache.push_back(buffer);
- }
- else {
- result = _ReleaseBuffer(buffer);
- }
- Unlock();
- return result;
-}
-
-
-HRESULT PinnedMemoryAllocator::_ReleaseBuffer(void* buffer)
-{
- TextureTransfer *pTransfer;
- if (mAllocatedSize.count(buffer) == 0) {
- // Internal error!!
- return S_OK;
- }
- else {
- // No room left in cache, so un-pin (if it was pinned) and free this buffer
- if (mPinnedBuffer.count(buffer) > 0) {
- pTransfer = mPinnedBuffer[buffer];
- mPinnedBuffer.erase(buffer);
- delete pTransfer;
- }
-#ifdef WIN32
- VirtualFree(buffer, 0, MEM_RELEASE);
-#else
- free(buffer);
-#endif
- mAllocatedSize.erase(buffer);
- }
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::Commit()
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE PinnedMemoryAllocator::Decommit()
-{
- void *buffer;
- Lock();
- while (!mBufferCache.empty()) {
- // Cleanup any frames allocated and pinned in AllocateBuffer() but not freed in ReleaseBuffer()
- buffer = mBufferCache.back();
- mBufferCache.pop_back();
- _ReleaseBuffer(buffer);
- }
- Unlock();
- return S_OK;
-}
-
-
-////////////////////////////////////////////
-// Capture Delegate Class
-////////////////////////////////////////////
-
-CaptureDelegate::CaptureDelegate(VideoDeckLink* pOwner) : mpOwner(pOwner)
-{
-}
-
-HRESULT CaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame* inputFrame, IDeckLinkAudioInputPacket* /*audioPacket*/)
-{
- if (!inputFrame) {
- // It's possible to receive a NULL inputFrame, but a valid audioPacket. Ignore audio-only frame.
- return S_OK;
- }
- if ((inputFrame->GetFlags() & bmdFrameHasNoInputSource) == bmdFrameHasNoInputSource) {
- // let's not bother transferring frames if there is no source
- return S_OK;
- }
- mpOwner->VideoFrameArrived(inputFrame);
- return S_OK;
-}
-
-HRESULT CaptureDelegate::VideoInputFormatChanged(BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode *newDisplayMode, BMDDetectedVideoInputFormatFlags detectedSignalFlags)
-{
- return S_OK;
-}
-
-
-
-
-// macro for exception handling and logging
-#define CATCH_EXCP catch (Exception & exp) \
-{ exp.report(); m_status = SourceError; }
-
-// class VideoDeckLink
-
-
-// constructor
-VideoDeckLink::VideoDeckLink (HRESULT * hRslt) : VideoBase(),
-mDLInput(NULL),
-mUse3D(false),
-mFrameWidth(0),
-mFrameHeight(0),
-mpAllocator(NULL),
-mpCaptureDelegate(NULL),
-mpCacheFrame(NULL),
-mClosing(false)
-{
- mDisplayMode = (BMDDisplayMode)0;
- mPixelFormat = (BMDPixelFormat)0;
- pthread_mutex_init(&mCacheMutex, NULL);
-}
-
-// destructor
-VideoDeckLink::~VideoDeckLink ()
-{
- LockCache();
- mClosing = true;
- if (mpCacheFrame)
- {
- mpCacheFrame->Release();
- mpCacheFrame = NULL;
- }
- UnlockCache();
- if (mDLInput != NULL)
- {
- // Cleanup for Capture
- mDLInput->StopStreams();
- mDLInput->SetCallback(NULL);
- mDLInput->DisableVideoInput();
- mDLInput->DisableAudioInput();
- mDLInput->FlushStreams();
- if (mDLInput->Release() != 0) {
- printf("Reference count not NULL on DeckLink device when closing it, please report!\n");
- }
- mDLInput = NULL;
- }
-
- if (mpAllocator)
- {
- // if the device was properly cleared, this should be 0
- if (mpAllocator->Release() != 0) {
- printf("Reference count not NULL on Allocator when closing it, please report!\n");
- }
- mpAllocator = NULL;
- }
- if (mpCaptureDelegate)
- {
- delete mpCaptureDelegate;
- mpCaptureDelegate = NULL;
- }
-}
-
-void VideoDeckLink::refresh(void)
-{
- m_avail = false;
-}
-
-// release components
-bool VideoDeckLink::release()
-{
- // release
- return true;
-}
-
-// open video file
-void VideoDeckLink::openFile (char *filename)
-{
- // only live capture on this device
- THRWEXCP(SourceVideoOnlyCapture, S_OK);
-}
-
-
-// open video capture device
-void VideoDeckLink::openCam (char *format, short camIdx)
-{
- IDeckLinkDisplayModeIterator* pDLDisplayModeIterator;
- BMDDisplayModeSupport modeSupport;
- IDeckLinkDisplayMode* pDLDisplayMode;
- IDeckLinkIterator* pIterator;
- BMDTimeValue frameDuration;
- BMDTimeScale frameTimescale;
- IDeckLink* pDL;
- uint32_t displayFlags, inputFlags;
- char *pPixel, *p3D, *pEnd, *pSize;
- size_t len;
- int i, modeIdx, cacheSize;
-
- // format is constructed as <displayMode>/<pixelFormat>[/3D][:<cacheSize>]
- // <displayMode> takes the form of BMDDisplayMode identifier minus the 'bmdMode' prefix.
- // This implementation understands all the modes defined in SDK 10.3.1 but you can alternatively
- // use the 4 characters internal representation of the mode (e.g. 'HD1080p24' == '24ps')
- // <pixelFormat> takes the form of BMDPixelFormat identifier minus the 'bmdFormat' prefix.
- // This implementation understand all the formats defined in SDK 10.32.1 but you can alternatively
- // use the 4 characters internal representation of the format (e.g. '10BitRGB' == 'r210')
- // Not all combinations of mode and pixel format are possible and it also depends on the card!
- // Use /3D postfix if you are capturing a 3D stream with frame packing
- // Example: To capture FullHD 1920x1080@24Hz with 3D packing and 4:4:4 10 bits RGB pixel format, use
- // "HD1080p24/10BitRGB/3D" (same as "24ps/r210/3D")
- // (this will be the normal capture format for FullHD on the DeckLink 4k extreme)
-
- if ((pSize = strchr(format, ':')) != NULL) {
- cacheSize = strtol(pSize+1, &pEnd, 10);
- }
- else {
- cacheSize = 8;
- pSize = format + strlen(format);
- }
- if ((pPixel = strchr(format, '/')) == NULL ||
- ((p3D = strchr(pPixel + 1, '/')) != NULL && strncmp(p3D, "/3D", pSize-p3D)))
- THRWEXCP(VideoDeckLinkBadFormat, S_OK);
- mUse3D = (p3D) ? true : false;
- // to simplify pixel format parsing
- if (!p3D)
- p3D = pSize;
-
- // read the mode
- len = (size_t)(pPixel - format);
- // accept integer display mode
-
- try {
- // throws if bad mode
- decklink_ReadDisplayMode(format, len, &mDisplayMode);
- // found a valid mode, remember that we do not look for an index
- modeIdx = -1;
- }
- catch (Exception &) {
- // accept also purely numerical mode as a mode index
- modeIdx = strtol(format, &pEnd, 10);
- if (pEnd != pPixel || modeIdx < 0)
- // not a pure number, give up
- throw;
- }
-
- // skip /
- pPixel++;
- len = (size_t)(p3D - pPixel);
- // throws if bad format
- decklink_ReadPixelFormat(pPixel, len, &mPixelFormat);
-
- // Caution: DeckLink API used from this point, make sure entity are released before throwing
- // open the card
- pIterator = BMD_CreateDeckLinkIterator();
- if (pIterator) {
- i = 0;
- while (pIterator->Next(&pDL) == S_OK) {
- if (i == camIdx) {
- if (pDL->QueryInterface(IID_IDeckLinkInput, (void**)&mDLInput) != S_OK)
- mDLInput = NULL;
- pDL->Release();
- break;
- }
- i++;
- pDL->Release();
- }
- pIterator->Release();
- }
- if (!mDLInput)
- THRWEXCP(VideoDeckLinkOpenCard, S_OK);
-
-
- // check if display mode and pixel format are supported
- if (mDLInput->GetDisplayModeIterator(&pDLDisplayModeIterator) != S_OK)
- THRWEXCP(DeckLinkInternalError, S_OK);
-
- pDLDisplayMode = NULL;
- displayFlags = (mUse3D) ? bmdDisplayModeSupports3D : 0;
- inputFlags = (mUse3D) ? bmdVideoInputDualStream3D : bmdVideoInputFlagDefault;
- while (pDLDisplayModeIterator->Next(&pDLDisplayMode) == S_OK)
- {
- if (modeIdx == 0 || pDLDisplayMode->GetDisplayMode() == mDisplayMode) {
- // in case we get here because of modeIdx, make sure we have mDisplayMode set
- mDisplayMode = pDLDisplayMode->GetDisplayMode();
- if ((pDLDisplayMode->GetFlags() & displayFlags) == displayFlags &&
- mDLInput->DoesSupportVideoMode(mDisplayMode, mPixelFormat, inputFlags, &modeSupport, NULL) == S_OK &&
- modeSupport == bmdDisplayModeSupported)
- {
- break;
- }
- }
- pDLDisplayMode->Release();
- pDLDisplayMode = NULL;
- if (modeIdx-- == 0) {
- // reached the correct mode index but it does not meet the pixel format, give up
- break;
- }
- }
- pDLDisplayModeIterator->Release();
-
- if (pDLDisplayMode == NULL)
- THRWEXCP(VideoDeckLinkBadFormat, S_OK);
-
- mFrameWidth = pDLDisplayMode->GetWidth();
- mFrameHeight = pDLDisplayMode->GetHeight();
- mTextureDesc.height = (mUse3D) ? 2 * mFrameHeight : mFrameHeight;
- pDLDisplayMode->GetFrameRate(&frameDuration, &frameTimescale);
- pDLDisplayMode->Release();
- // for information, in case the application wants to know
- m_size[0] = mFrameWidth;
- m_size[1] = mTextureDesc.height;
- m_frameRate = (float)frameTimescale / (float)frameDuration;
-
- switch (mPixelFormat)
- {
- case bmdFormat8BitYUV:
- // 2 pixels per word
- mTextureDesc.stride = mFrameWidth * 2;
- mTextureDesc.width = mFrameWidth / 2;
- mTextureDesc.internalFormat = GL_RGBA;
- mTextureDesc.format = GL_BGRA;
- mTextureDesc.type = GL_UNSIGNED_BYTE;
- break;
- case bmdFormat10BitYUV:
- // 6 pixels in 4 words, rounded to 48 pixels
- mTextureDesc.stride = ((mFrameWidth + 47) / 48) * 128;
- mTextureDesc.width = mTextureDesc.stride/4;
- mTextureDesc.internalFormat = GL_RGB10_A2;
- mTextureDesc.format = GL_BGRA;
- mTextureDesc.type = GL_UNSIGNED_INT_2_10_10_10_REV;
- break;
- case bmdFormat8BitARGB:
- mTextureDesc.stride = mFrameWidth * 4;
- mTextureDesc.width = mFrameWidth;
- mTextureDesc.internalFormat = GL_RGBA;
- mTextureDesc.format = GL_BGRA;
- mTextureDesc.type = GL_UNSIGNED_INT_8_8_8_8;
- break;
- case bmdFormat8BitBGRA:
- mTextureDesc.stride = mFrameWidth * 4;
- mTextureDesc.width = mFrameWidth;
- mTextureDesc.internalFormat = GL_RGBA;
- mTextureDesc.format = GL_BGRA;
- mTextureDesc.type = GL_UNSIGNED_BYTE;
- break;
- case bmdFormat10BitRGBXLE:
- // 1 pixel per word, rounded to 64 pixels
- mTextureDesc.stride = ((mFrameWidth + 63) / 64) * 256;
- mTextureDesc.width = mTextureDesc.stride/4;
- mTextureDesc.internalFormat = GL_RGB10_A2;
- mTextureDesc.format = GL_RGBA;
- mTextureDesc.type = GL_UNSIGNED_INT_10_10_10_2;
- break;
- case bmdFormat10BitRGBX:
- case bmdFormat10BitRGB:
- // 1 pixel per word, rounded to 64 pixels
- mTextureDesc.stride = ((mFrameWidth + 63) / 64) * 256;
- mTextureDesc.width = mTextureDesc.stride/4;
- mTextureDesc.internalFormat = GL_R32UI;
- mTextureDesc.format = GL_RED_INTEGER;
- mTextureDesc.type = GL_UNSIGNED_INT;
- break;
- case bmdFormat12BitRGB:
- case bmdFormat12BitRGBLE:
- // 8 pixels in 9 word
- mTextureDesc.stride = (mFrameWidth * 36) / 8;
- mTextureDesc.width = mTextureDesc.stride/4;
- mTextureDesc.internalFormat = GL_R32UI;
- mTextureDesc.format = GL_RED_INTEGER;
- mTextureDesc.type = GL_UNSIGNED_INT;
- break;
- default:
- // for unknown pixel format, this will be resolved when a frame arrives
- mTextureDesc.format = GL_RED_INTEGER;
- mTextureDesc.type = GL_UNSIGNED_INT;
- break;
- }
- // reserve memory for cache frame + 1 to accomodate for pixel format that we don't know yet
- // note: we can't use stride as it is not yet known if the pixel format is unknown
- // use instead the frame width as in worst case it's not much different (e.g. HD720/10BITYUV: 1296 pixels versus 1280)
- // note: some pixel format take more than 4 bytes take that into account (9/8 versus 1)
- mpAllocator = new PinnedMemoryAllocator(cacheSize, mFrameWidth*mTextureDesc.height * 4 * (1+cacheSize*9/8));
-
- if (mDLInput->SetVideoInputFrameMemoryAllocator(mpAllocator) != S_OK)
- THRWEXCP(DeckLinkInternalError, S_OK);
-
- mpCaptureDelegate = new CaptureDelegate(this);
- if (mDLInput->SetCallback(mpCaptureDelegate) != S_OK)
- THRWEXCP(DeckLinkInternalError, S_OK);
-
- if (mDLInput->EnableVideoInput(mDisplayMode, mPixelFormat, ((mUse3D) ? bmdVideoInputDualStream3D : bmdVideoInputFlagDefault)) != S_OK)
- // this shouldn't failed, we tested above
- THRWEXCP(DeckLinkInternalError, S_OK);
-
- // just in case it is needed to capture from certain cards, we don't check error because we don't need audio
- mDLInput->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, 2);
-
- // open base class
- VideoBase::openCam(format, camIdx);
-
- // ready to capture, will start when application calls play()
-}
-
-// play video
-bool VideoDeckLink::play (void)
-{
- try
- {
- // if object is able to play
- if (VideoBase::play())
- {
- mDLInput->FlushStreams();
- return (mDLInput->StartStreams() == S_OK);
- }
- }
- CATCH_EXCP;
- return false;
-}
-
-
-// pause video
-bool VideoDeckLink::pause (void)
-{
- try
- {
- if (VideoBase::pause())
- {
- mDLInput->PauseStreams();
- return true;
- }
- }
- CATCH_EXCP;
- return false;
-}
-
-// stop video
-bool VideoDeckLink::stop (void)
-{
- try
- {
- VideoBase::stop();
- mDLInput->StopStreams();
- return true;
- }
- CATCH_EXCP;
- return false;
-}
-
-
-// set video range
-void VideoDeckLink::setRange (double start, double stop)
-{
-}
-
-// set framerate
-void VideoDeckLink::setFrameRate (float rate)
-{
-}
-
-
-// image calculation
-// send cache frame directly to GPU
-void VideoDeckLink::calcImage (unsigned int texId, double ts)
-{
- IDeckLinkVideoInputFrame* pFrame;
- LockCache();
- pFrame = mpCacheFrame;
- mpCacheFrame = NULL;
- UnlockCache();
- if (pFrame) {
- // BUG: the dvpBindToGLCtx function fails the first time it is used, don't know why.
- // This causes an exception to be thrown.
- // This should be fixed but in the meantime we will catch the exception because
- // it is crucial that we release the frame to keep the reference count right on the DeckLink device
- try {
- uint32_t rowSize = pFrame->GetRowBytes();
- uint32_t textureSize = rowSize * pFrame->GetHeight();
- void* videoPixels = NULL;
- void* rightEyePixels = NULL;
- if (!mTextureDesc.stride) {
- // we could not compute the texture size earlier (unknown pixel size)
- // let's do it now
- mTextureDesc.stride = rowSize;
- mTextureDesc.width = mTextureDesc.stride / 4;
- }
- if (mTextureDesc.stride != rowSize) {
- // unexpected frame size, ignore
- // TBD: print a warning
- }
- else {
- pFrame->GetBytes(&videoPixels);
- if (mUse3D) {
- IDeckLinkVideoFrame3DExtensions *if3DExtensions = NULL;
- IDeckLinkVideoFrame *rightEyeFrame = NULL;
- if (pFrame->QueryInterface(IID_IDeckLinkVideoFrame3DExtensions, (void **)&if3DExtensions) == S_OK &&
- if3DExtensions->GetFrameForRightEye(&rightEyeFrame) == S_OK) {
- rightEyeFrame->GetBytes(&rightEyePixels);
- textureSize += ((uint64_t)rightEyePixels - (uint64_t)videoPixels);
- }
- if (rightEyeFrame)
- rightEyeFrame->Release();
- if (if3DExtensions)
- if3DExtensions->Release();
- }
- mTextureDesc.size = mTextureDesc.width * mTextureDesc.height * 4;
- if (mTextureDesc.size == textureSize) {
- // this means that both left and right frame are contiguous and that there is no padding
- // do the transfer
- mpAllocator->TransferBuffer(videoPixels, &mTextureDesc, texId);
- }
- }
- }
- catch (Exception &) {
- pFrame->Release();
- throw;
- }
- // this will trigger PinnedMemoryAllocator::RealaseBuffer
- pFrame->Release();
- }
- // currently we don't pass the image to the application
- m_avail = false;
-}
-
-// A frame is available from the board
-// Called from an internal thread, just pass the frame to the main thread
-void VideoDeckLink::VideoFrameArrived(IDeckLinkVideoInputFrame* inputFrame)
-{
- IDeckLinkVideoInputFrame* pOldFrame = NULL;
- LockCache();
- if (!mClosing)
- {
- pOldFrame = mpCacheFrame;
- mpCacheFrame = inputFrame;
- inputFrame->AddRef();
- }
- UnlockCache();
- // old frame no longer needed, just release it
- if (pOldFrame)
- pOldFrame->Release();
-}
-
-// python methods
-
-// object initialization
-static int VideoDeckLink_init(PyObject *pySelf, PyObject *args, PyObject *kwds)
-{
- static const char *kwlist[] = { "format", "capture", NULL };
- PyImage *self = reinterpret_cast<PyImage*>(pySelf);
- // see openCam for a description of format
- char * format = NULL;
- // capture device number, i.e. DeckLink card number, default first one
- short capt = 0;
-
- if (!GLEW_VERSION_1_5) {
- PyErr_SetString(PyExc_RuntimeError, "VideoDeckLink requires at least OpenGL 1.5");
- return -1;
- }
- // get parameters
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|h",
- const_cast<char**>(kwlist), &format, &capt))
- return -1;
-
- try {
- // create video object
- Video_init<VideoDeckLink>(self);
-
- // open video source, control comes back to VideoDeckLink::openCam
- Video_open(getVideo(self), format, capt);
- }
- catch (Exception & exp) {
- exp.report();
- return -1;
- }
- // initialization succeded
- return 0;
-}
-
-// methods structure
-static PyMethodDef videoMethods[] =
-{ // methods from VideoBase class
- {"play", (PyCFunction)Video_play, METH_NOARGS, "Play (restart) video"},
- {"pause", (PyCFunction)Video_pause, METH_NOARGS, "pause video"},
- {"stop", (PyCFunction)Video_stop, METH_NOARGS, "stop video (play will replay it from start)"},
- {"refresh", (PyCFunction)Video_refresh, METH_VARARGS, "Refresh video - get its status"},
- {NULL}
-};
-// attributes structure
-static PyGetSetDef videoGetSets[] =
-{ // methods from VideoBase class
- {(char*)"status", (getter)Video_getStatus, NULL, (char*)"video status", NULL},
- {(char*)"framerate", (getter)Video_getFrameRate, NULL, (char*)"frame rate", NULL},
- // attributes from ImageBase class
- {(char*)"valid", (getter)Image_valid, NULL, (char*)"bool to tell if an image is available", NULL},
- {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
- {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
- {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL},
- {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
- {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
- {NULL}
-};
-
-// python type declaration
-PyTypeObject VideoDeckLinkType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.VideoDeckLink", /*tp_name*/
- sizeof(PyImage), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Image_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "DeckLink video source", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- videoMethods, /* tp_methods */
- 0, /* tp_members */
- videoGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)VideoDeckLink_init, /* tp_init */
- 0, /* tp_alloc */
- Image_allocNew, /* tp_new */
-};
-
-
-
-////////////////////////////////////////////
-// DeckLink Capture Delegate Class
-////////////////////////////////////////////
-
-#endif // WITH_GAMEENGINE_DECKLINK
-
diff --git a/source/gameengine/VideoTexture/VideoDeckLink.h b/source/gameengine/VideoTexture/VideoDeckLink.h
deleted file mode 100644
index d5419176691..00000000000
--- a/source/gameengine/VideoTexture/VideoDeckLink.h
+++ /dev/null
@@ -1,256 +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) 2015, Blender Foundation
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file VideoDeckLink.h
- * \ingroup bgevideotex
- */
-
-#ifndef __VIDEODECKLINK_H__
-#define __VIDEODECKLINK_H__
-
-#ifdef WITH_GAMEENGINE_DECKLINK
-
-/* this needs to be parsed with __cplusplus defined before included through DeckLink_compat.h */
-#if defined(__FreeBSD__)
-# include <inttypes.h>
-#endif
-#include <map>
-#include <set>
-
-extern "C" {
-#include <pthread.h>
-#include "DNA_listBase.h"
-#include "BLI_threads.h"
-#include "BLI_blenlib.h"
-}
-#include "GPU_glew.h"
-#ifdef WIN32
-#include "dvpapi.h"
-#endif
-#include "DeckLinkAPI.h"
-#include "VideoBase.h"
-
-class PinnedMemoryAllocator;
-
-struct TextureDesc
-{
- uint32_t width;
- uint32_t height;
- uint32_t stride;
- uint32_t size;
- GLenum internalFormat;
- GLenum format;
- GLenum type;
- TextureDesc()
- {
- width = 0;
- height = 0;
- stride = 0;
- size = 0;
- internalFormat = 0;
- format = 0;
- type = 0;
- }
-};
-
-class CaptureDelegate;
-
-// type VideoDeckLink declaration
-class VideoDeckLink : public VideoBase
-{
- friend class CaptureDelegate;
-public:
- /// constructor
- VideoDeckLink (HRESULT * hRslt);
- /// destructor
- virtual ~VideoDeckLink ();
-
- /// open video/image file
- virtual void openFile(char *file);
- /// open video capture device
- virtual void openCam(char *driver, short camIdx);
-
- /// release video source
- virtual bool release (void);
- /// overwrite base refresh to handle fixed image
- virtual void refresh(void);
- /// play video
- virtual bool play (void);
- /// pause video
- virtual bool pause (void);
- /// stop video
- virtual bool stop (void);
- /// set play range
- virtual void setRange (double start, double stop);
- /// set frame rate
- virtual void setFrameRate (float rate);
-
-protected:
- // format and codec information
- /// image calculation
- virtual void calcImage (unsigned int texId, double ts);
-
-private:
- void VideoFrameArrived(IDeckLinkVideoInputFrame* inputFrame);
- void LockCache()
- {
- pthread_mutex_lock(&mCacheMutex);
- }
- void UnlockCache()
- {
- pthread_mutex_unlock(&mCacheMutex);
- }
-
- IDeckLinkInput* mDLInput;
- BMDDisplayMode mDisplayMode;
- BMDPixelFormat mPixelFormat;
- bool mUse3D;
- uint32_t mFrameWidth;
- uint32_t mFrameHeight;
- TextureDesc mTextureDesc;
- PinnedMemoryAllocator* mpAllocator;
- CaptureDelegate* mpCaptureDelegate;
-
- // cache frame in transit between the callback thread and the main BGE thread
- // keep only one frame in cache because we just want to keep up with real time
- pthread_mutex_t mCacheMutex;
- IDeckLinkVideoInputFrame* mpCacheFrame;
- bool mClosing;
-
-};
-
-inline VideoDeckLink *getDeckLink(PyImage *self)
-{
- return static_cast<VideoDeckLink*>(self->m_image);
-}
-
-////////////////////////////////////////////
-// TextureTransfer : Abstract class to perform a transfer to GPU memory using fast transfer if available
-////////////////////////////////////////////
-class TextureTransfer
-{
-public:
- TextureTransfer() {}
- virtual ~TextureTransfer() { }
-
- virtual void PerformTransfer() = 0;
-protected:
- static bool _PinBuffer(void *address, uint32_t size);
- static void _UnpinBuffer(void* address, uint32_t size);
-};
-
-////////////////////////////////////////////
-// PinnedMemoryAllocator
-////////////////////////////////////////////
-
-// PinnedMemoryAllocator implements the IDeckLinkMemoryAllocator interface and can be used instead of the
-// built-in frame allocator, by setting with SetVideoInputFrameMemoryAllocator() or SetVideoOutputFrameMemoryAllocator().
-//
-// For this sample application a custom frame memory allocator is used to ensure each address
-// of frame memory is aligned on a 4kB boundary required by the OpenGL pinned memory extension.
-// If the pinned memory extension is not available, this allocator will still be used and
-// demonstrates how to cache frame allocations for efficiency.
-//
-// The frame cache delays the releasing of buffers until the cache fills up, thereby avoiding an
-// allocate plus pin operation for every frame, followed by an unpin and deallocate on every frame.
-
-
-class PinnedMemoryAllocator : public IDeckLinkMemoryAllocator
-{
-public:
- PinnedMemoryAllocator(unsigned cacheSize, size_t memSize);
- virtual ~PinnedMemoryAllocator();
-
- void TransferBuffer(void* address, TextureDesc* texDesc, GLuint texId);
-
- // IUnknown methods
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv);
- virtual ULONG STDMETHODCALLTYPE AddRef(void);
- virtual ULONG STDMETHODCALLTYPE Release(void);
-
- // IDeckLinkMemoryAllocator methods
- virtual HRESULT STDMETHODCALLTYPE AllocateBuffer(dl_size_t bufferSize, void* *allocatedBuffer);
- virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(void* buffer);
- virtual HRESULT STDMETHODCALLTYPE Commit();
- virtual HRESULT STDMETHODCALLTYPE Decommit();
-
-private:
- static bool mGPUDirectInitialized;
- static bool mHasDvp;
- static bool mHasAMDPinnedMemory;
- static size_t mReservedProcessMemory;
- static bool ReserveMemory(size_t size);
-
- void Lock()
- {
- pthread_mutex_lock(&mMutex);
- }
- void Unlock()
- {
- pthread_mutex_unlock(&mMutex);
- }
- HRESULT _ReleaseBuffer(void* buffer);
-
- uint32_t mRefCount;
- // protect the cache and the allocated map,
- // not the pinnedBuffer map as it is only used from main thread
- pthread_mutex_t mMutex;
- std::map<void*, uint32_t> mAllocatedSize;
- std::vector<void*> mBufferCache;
- std::map<void *, TextureTransfer*> mPinnedBuffer;
-#ifdef WIN32
- DVPBufferHandle mDvpCaptureTextureHandle;
-#endif
- // target texture in GPU
- GLuint mTexId;
- uint32_t mBufferCacheSize;
-};
-
-////////////////////////////////////////////
-// Capture Delegate Class
-////////////////////////////////////////////
-
-class CaptureDelegate : public IDeckLinkInputCallback
-{
- VideoDeckLink* mpOwner;
-
-public:
- CaptureDelegate(VideoDeckLink* pOwner);
-
- // IUnknown needs only a dummy implementation
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
- virtual ULONG STDMETHODCALLTYPE AddRef() { return 1; }
- virtual ULONG STDMETHODCALLTYPE Release() { return 1; }
-
- virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket *audioPacket);
- virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode *newDisplayMode, BMDDetectedVideoInputFormatFlags detectedSignalFlags);
-};
-
-
-#endif /* WITH_GAMEENGINE_DECKLINK */
-
-#endif /* __VIDEODECKLINK_H__ */
diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
deleted file mode 100644
index 11ec97ca5f8..00000000000
--- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp
+++ /dev/null
@@ -1,1392 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/VideoFFmpeg.cpp
- * \ingroup bgevideotex
- */
-
-
-#ifdef WITH_FFMPEG
-
-// INT64_C fix for some linux machines (C99ism)
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#ifdef __STDC_CONSTANT_MACROS /* quiet warning */
-#endif
-#endif
-
-#include <stdint.h>
-
-
-#include "MEM_guardedalloc.h"
-#include "PIL_time.h"
-
-#include <string>
-
-#include "VideoFFmpeg.h"
-#include "Exception.h"
-
-
-// default framerate
-const double defFrameRate = 25.0;
-
-// macro for exception handling and logging
-#define CATCH_EXCP catch (Exception & exp) \
-{ exp.report(); m_status = SourceError; }
-
-// class RenderVideo
-
-// constructor
-VideoFFmpeg::VideoFFmpeg (HRESULT * hRslt) : VideoBase(),
-m_codec(NULL), m_formatCtx(NULL), m_codecCtx(NULL),
-m_frame(NULL), m_frameDeinterlaced(NULL), m_frameRGB(NULL), m_imgConvertCtx(NULL),
-m_deinterlace(false), m_preseek(0), m_videoStream(-1), m_baseFrameRate(25.0),
-m_lastFrame(-1), m_eof(false), m_externTime(false), m_curPosition(-1), m_startTime(0),
-m_captWidth(0), m_captHeight(0), m_captRate(0.f), m_isImage(false),
-m_isThreaded(false), m_isStreaming(false), m_stopThread(false), m_cacheStarted(false)
-{
- // set video format
- m_format = RGB24;
- // force flip because ffmpeg always return the image in the wrong orientation for texture
- setFlip(true);
- // construction is OK
- *hRslt = S_OK;
- BLI_listbase_clear(&m_thread);
- pthread_mutex_init(&m_cacheMutex, NULL);
- BLI_listbase_clear(&m_frameCacheFree);
- BLI_listbase_clear(&m_frameCacheBase);
- BLI_listbase_clear(&m_packetCacheFree);
- BLI_listbase_clear(&m_packetCacheBase);
-}
-
-// destructor
-VideoFFmpeg::~VideoFFmpeg ()
-{
-}
-
-void VideoFFmpeg::refresh(void)
-{
- // a fixed image will not refresh because it is loaded only once at creation
- if (m_isImage)
- return;
- m_avail = false;
-}
-
-// release components
-bool VideoFFmpeg::release()
-{
- // release
- stopCache();
- if (m_codecCtx)
- {
- avcodec_close(m_codecCtx);
- m_codecCtx = NULL;
- }
- if (m_formatCtx)
- {
- avformat_close_input(&m_formatCtx);
- m_formatCtx = NULL;
- }
- if (m_frame)
- {
- av_free(m_frame);
- m_frame = NULL;
- }
- if (m_frameDeinterlaced)
- {
- MEM_freeN(m_frameDeinterlaced->data[0]);
- av_free(m_frameDeinterlaced);
- m_frameDeinterlaced = NULL;
- }
- if (m_frameRGB)
- {
- MEM_freeN(m_frameRGB->data[0]);
- av_free(m_frameRGB);
- m_frameRGB = NULL;
- }
- if (m_imgConvertCtx)
- {
- sws_freeContext(m_imgConvertCtx);
- m_imgConvertCtx = NULL;
- }
- m_codec = NULL;
- m_status = SourceStopped;
- m_lastFrame = -1;
- return true;
-}
-
-AVFrame *VideoFFmpeg::allocFrameRGB()
-{
- AVFrame *frame;
- frame = av_frame_alloc();
- if (m_format == RGBA32)
- {
- avpicture_fill((AVPicture*)frame,
- (uint8_t*)MEM_callocN(avpicture_get_size(
- AV_PIX_FMT_RGBA,
- m_codecCtx->width, m_codecCtx->height),
- "ffmpeg rgba"),
- AV_PIX_FMT_RGBA, m_codecCtx->width, m_codecCtx->height);
- } else
- {
- avpicture_fill((AVPicture*)frame,
- (uint8_t*)MEM_callocN(avpicture_get_size(
- AV_PIX_FMT_RGB24,
- m_codecCtx->width, m_codecCtx->height),
- "ffmpeg rgb"),
- AV_PIX_FMT_RGB24, m_codecCtx->width, m_codecCtx->height);
- }
- return frame;
-}
-
-// set initial parameters
-void VideoFFmpeg::initParams (short width, short height, float rate, bool image)
-{
- m_captWidth = width;
- m_captHeight = height;
- m_captRate = rate;
- m_isImage = image;
-}
-
-
-int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVDictionary **formatParams)
-{
- AVFormatContext *formatCtx = NULL;
- int i, videoStream;
- AVCodec *codec;
- AVCodecContext *codecCtx;
-
- if (avformat_open_input(&formatCtx, filename, inputFormat, formatParams)!=0)
- return -1;
-
- if (avformat_find_stream_info(formatCtx, NULL) < 0)
- {
- avformat_close_input(&formatCtx);
- return -1;
- }
-
- /* Find the first video stream */
- videoStream=-1;
- for (i=0; i<formatCtx->nb_streams; i++)
- {
- if (formatCtx->streams[i] &&
- get_codec_from_stream(formatCtx->streams[i]) &&
- (get_codec_from_stream(formatCtx->streams[i])->codec_type==AVMEDIA_TYPE_VIDEO))
- {
- videoStream=i;
- break;
- }
- }
-
- if (videoStream==-1)
- {
- avformat_close_input(&formatCtx);
- return -1;
- }
-
- codecCtx = get_codec_from_stream(formatCtx->streams[videoStream]);
-
- /* Find the decoder for the video stream */
- codec=avcodec_find_decoder(codecCtx->codec_id);
- if (codec==NULL)
- {
- avformat_close_input(&formatCtx);
- return -1;
- }
- codecCtx->workaround_bugs = 1;
- if (avcodec_open2(codecCtx, codec, NULL) < 0)
- {
- avformat_close_input(&formatCtx);
- return -1;
- }
-
-#ifdef FFMPEG_OLD_FRAME_RATE
- if (codecCtx->frame_rate>1000 && codecCtx->frame_rate_base==1)
- codecCtx->frame_rate_base=1000;
- m_baseFrameRate = (double)codecCtx->frame_rate / (double)codecCtx->frame_rate_base;
-#else
- m_baseFrameRate = av_q2d(av_get_r_frame_rate_compat(formatCtx, formatCtx->streams[videoStream]));
-#endif
- if (m_baseFrameRate <= 0.0)
- m_baseFrameRate = defFrameRate;
-
- m_codec = codec;
- m_codecCtx = codecCtx;
- m_formatCtx = formatCtx;
- m_videoStream = videoStream;
- m_frame = av_frame_alloc();
- m_frameDeinterlaced = av_frame_alloc();
-
- // allocate buffer if deinterlacing is required
- avpicture_fill((AVPicture*)m_frameDeinterlaced,
- (uint8_t*)MEM_callocN(avpicture_get_size(
- m_codecCtx->pix_fmt,
- m_codecCtx->width, m_codecCtx->height),
- "ffmpeg deinterlace"),
- m_codecCtx->pix_fmt, m_codecCtx->width, m_codecCtx->height);
-
- // check if the pixel format supports Alpha
- if (m_codecCtx->pix_fmt == AV_PIX_FMT_RGB32 ||
- m_codecCtx->pix_fmt == AV_PIX_FMT_BGR32 ||
- m_codecCtx->pix_fmt == AV_PIX_FMT_RGB32_1 ||
- m_codecCtx->pix_fmt == AV_PIX_FMT_BGR32_1)
- {
- // allocate buffer to store final decoded frame
- m_format = RGBA32;
- // allocate sws context
- m_imgConvertCtx = sws_getContext(
- m_codecCtx->width,
- m_codecCtx->height,
- m_codecCtx->pix_fmt,
- m_codecCtx->width,
- m_codecCtx->height,
- AV_PIX_FMT_RGBA,
- SWS_FAST_BILINEAR,
- NULL, NULL, NULL);
- } else
- {
- // allocate buffer to store final decoded frame
- m_format = RGB24;
- // allocate sws context
- m_imgConvertCtx = sws_getContext(
- m_codecCtx->width,
- m_codecCtx->height,
- m_codecCtx->pix_fmt,
- m_codecCtx->width,
- m_codecCtx->height,
- AV_PIX_FMT_RGB24,
- SWS_FAST_BILINEAR,
- NULL, NULL, NULL);
- }
- m_frameRGB = allocFrameRGB();
-
- if (!m_imgConvertCtx) {
- avcodec_close(m_codecCtx);
- m_codecCtx = NULL;
- avformat_close_input(&m_formatCtx);
- m_formatCtx = NULL;
- av_free(m_frame);
- m_frame = NULL;
- MEM_freeN(m_frameDeinterlaced->data[0]);
- av_free(m_frameDeinterlaced);
- m_frameDeinterlaced = NULL;
- MEM_freeN(m_frameRGB->data[0]);
- av_free(m_frameRGB);
- m_frameRGB = NULL;
- return -1;
- }
- return 0;
-}
-
-/*
- * This thread is used to load video frame asynchronously.
- * It provides a frame caching service.
- * The main thread is responsible for positioning the frame pointer in the
- * file correctly before calling startCache() which starts this thread.
- * The cache is organized in two layers: 1) a cache of 20-30 undecoded packets to keep
- * memory and CPU low 2) a cache of 5 decoded frames.
- * If the main thread does not find the frame in the cache (because the video has restarted
- * or because the GE is lagging), it stops the cache with StopCache() (this is a synchronous
- * function: it sends a signal to stop the cache thread and wait for confirmation), then
- * change the position in the stream and restarts the cache thread.
- */
-void *VideoFFmpeg::cacheThread(void *data)
-{
- VideoFFmpeg* video = (VideoFFmpeg*)data;
- // holds the frame that is being decoded
- CacheFrame *currentFrame = NULL;
- CachePacket *cachePacket;
- bool endOfFile = false;
- int frameFinished = 0;
- double timeBase = av_q2d(video->m_formatCtx->streams[video->m_videoStream]->time_base);
- int64_t startTs = video->m_formatCtx->streams[video->m_videoStream]->start_time;
-
- if (startTs == AV_NOPTS_VALUE)
- startTs = 0;
-
- while (!video->m_stopThread)
- {
- // packet cache is used solely by this thread, no need to lock
- // In case the stream/file contains other stream than the one we are looking for,
- // allow a bit of cycling to get rid quickly of those frames
- frameFinished = 0;
- while ( !endOfFile
- && (cachePacket = (CachePacket *)video->m_packetCacheFree.first) != NULL
- && frameFinished < 25)
- {
- // free packet => packet cache is not full yet, just read more
- if (av_read_frame(video->m_formatCtx, &cachePacket->packet)>=0)
- {
- if (cachePacket->packet.stream_index == video->m_videoStream)
- {
- // make sure fresh memory is allocated for the packet and move it to queue
- av_dup_packet(&cachePacket->packet);
- BLI_remlink(&video->m_packetCacheFree, cachePacket);
- BLI_addtail(&video->m_packetCacheBase, cachePacket);
- break;
- } else {
- // this is not a good packet for us, just leave it on free queue
- // Note: here we could handle sound packet
- av_free_packet(&cachePacket->packet);
- frameFinished++;
- }
-
- } else {
- if (video->m_isFile)
- // this mark the end of the file
- endOfFile = true;
- // if we cannot read a packet, no need to continue
- break;
- }
- }
- // frame cache is also used by main thread, lock
- if (currentFrame == NULL)
- {
- // no current frame being decoded, take free one
- pthread_mutex_lock(&video->m_cacheMutex);
- if ((currentFrame = (CacheFrame *)video->m_frameCacheFree.first) != NULL)
- BLI_remlink(&video->m_frameCacheFree, currentFrame);
- pthread_mutex_unlock(&video->m_cacheMutex);
- }
- if (currentFrame != NULL)
- {
- // this frame is out of free and busy queue, we can manipulate it without locking
- frameFinished = 0;
- while (!frameFinished && (cachePacket = (CachePacket *)video->m_packetCacheBase.first) != NULL)
- {
- BLI_remlink(&video->m_packetCacheBase, cachePacket);
- // use m_frame because when caching, it is not used in main thread
- // we can't use currentFrame directly because we need to convert to RGB first
- avcodec_decode_video2(video->m_codecCtx,
- video->m_frame, &frameFinished,
- &cachePacket->packet);
- if (frameFinished)
- {
- AVFrame * input = video->m_frame;
-
- /* This means the data wasnt read properly, this check stops crashing */
- if ( input->data[0]!=0 || input->data[1]!=0
- || input->data[2]!=0 || input->data[3]!=0)
- {
- if (video->m_deinterlace)
- {
- if (avpicture_deinterlace(
- (AVPicture*) video->m_frameDeinterlaced,
- (const AVPicture*) video->m_frame,
- video->m_codecCtx->pix_fmt,
- video->m_codecCtx->width,
- video->m_codecCtx->height) >= 0)
- {
- input = video->m_frameDeinterlaced;
- }
- }
- // convert to RGB24
- sws_scale(video->m_imgConvertCtx,
- input->data,
- input->linesize,
- 0,
- video->m_codecCtx->height,
- currentFrame->frame->data,
- currentFrame->frame->linesize);
- // move frame to queue, this frame is necessarily the next one
- video->m_curPosition = (long)((cachePacket->packet.dts-startTs) * (video->m_baseFrameRate*timeBase) + 0.5);
- currentFrame->framePosition = video->m_curPosition;
- pthread_mutex_lock(&video->m_cacheMutex);
- BLI_addtail(&video->m_frameCacheBase, currentFrame);
- pthread_mutex_unlock(&video->m_cacheMutex);
- currentFrame = NULL;
- }
- }
- av_free_packet(&cachePacket->packet);
- BLI_addtail(&video->m_packetCacheFree, cachePacket);
- }
- if (currentFrame && endOfFile)
- {
- // no more packet and end of file => put a special frame that indicates that
- currentFrame->framePosition = -1;
- pthread_mutex_lock(&video->m_cacheMutex);
- BLI_addtail(&video->m_frameCacheBase, currentFrame);
- pthread_mutex_unlock(&video->m_cacheMutex);
- currentFrame = NULL;
- // no need to stay any longer in this thread
- break;
- }
- }
- // small sleep to avoid unnecessary looping
- PIL_sleep_ms(10);
- }
- // before quitting, put back the current frame to queue to allow freeing
- if (currentFrame)
- {
- pthread_mutex_lock(&video->m_cacheMutex);
- BLI_addtail(&video->m_frameCacheFree, currentFrame);
- pthread_mutex_unlock(&video->m_cacheMutex);
- }
- return 0;
-}
-
-// start thread to cache video frame from file/capture/stream
-// this function should be called only when the position in the stream is set for the
-// first frame to cache
-bool VideoFFmpeg::startCache()
-{
- if (!m_cacheStarted && m_isThreaded)
- {
- m_stopThread = false;
- for (int i=0; i<CACHE_FRAME_SIZE; i++)
- {
- CacheFrame *frame = new CacheFrame();
- frame->frame = allocFrameRGB();
- BLI_addtail(&m_frameCacheFree, frame);
- }
- for (int i=0; i<CACHE_PACKET_SIZE; i++)
- {
- CachePacket *packet = new CachePacket();
- BLI_addtail(&m_packetCacheFree, packet);
- }
- BLI_threadpool_init(&m_thread, cacheThread, 1);
- BLI_threadpool_insert(&m_thread, this);
- m_cacheStarted = true;
- }
- return m_cacheStarted;
-}
-
-void VideoFFmpeg::stopCache()
-{
- if (m_cacheStarted)
- {
- m_stopThread = true;
- BLI_threadpool_end(&m_thread);
- // now delete the cache
- CacheFrame *frame;
- CachePacket *packet;
- while ((frame = (CacheFrame *)m_frameCacheBase.first) != NULL)
- {
- BLI_remlink(&m_frameCacheBase, frame);
- MEM_freeN(frame->frame->data[0]);
- av_free(frame->frame);
- delete frame;
- }
- while ((frame = (CacheFrame *)m_frameCacheFree.first) != NULL)
- {
- BLI_remlink(&m_frameCacheFree, frame);
- MEM_freeN(frame->frame->data[0]);
- av_free(frame->frame);
- delete frame;
- }
- while ((packet = (CachePacket *)m_packetCacheBase.first) != NULL)
- {
- BLI_remlink(&m_packetCacheBase, packet);
- av_free_packet(&packet->packet);
- delete packet;
- }
- while ((packet = (CachePacket *)m_packetCacheFree.first) != NULL)
- {
- BLI_remlink(&m_packetCacheFree, packet);
- delete packet;
- }
- m_cacheStarted = false;
- }
-}
-
-void VideoFFmpeg::releaseFrame(AVFrame *frame)
-{
- if (frame == m_frameRGB)
- {
- // this is not a frame from the cache, ignore
- return;
- }
- // this frame MUST be the first one of the queue
- pthread_mutex_lock(&m_cacheMutex);
- CacheFrame *cacheFrame = (CacheFrame *)m_frameCacheBase.first;
- assert (cacheFrame != NULL && cacheFrame->frame == frame);
- BLI_remlink(&m_frameCacheBase, cacheFrame);
- BLI_addtail(&m_frameCacheFree, cacheFrame);
- pthread_mutex_unlock(&m_cacheMutex);
-}
-
-// open video file
-void VideoFFmpeg::openFile (char *filename)
-{
- if (openStream(filename, NULL, NULL) != 0)
- return;
-
- if (m_codecCtx->gop_size)
- m_preseek = (m_codecCtx->gop_size < 25) ? m_codecCtx->gop_size+1 : 25;
- else if (m_codecCtx->has_b_frames)
- m_preseek = 25; // should determine gopsize
- else
- m_preseek = 0;
-
- // get video time range
- m_range[0] = 0.0;
- m_range[1] = (double)m_formatCtx->duration / AV_TIME_BASE;
-
- // open base class
- VideoBase::openFile(filename);
-
- if (
- // ffmpeg reports that http source are actually non stream
- // but it is really not desirable to seek on http file, so force streaming.
- // It would be good to find this information from the context but there are no simple indication
- !strncmp(filename, "http://", 7) ||
- !strncmp(filename, "rtsp://", 7) ||
- (m_formatCtx->pb && !m_formatCtx->pb->seekable)
- )
- {
- // the file is in fact a streaming source, treat as cam to prevent seeking
- m_isFile = false;
- // but it's not handled exactly like a camera.
- m_isStreaming = true;
- // for streaming it is important to do non blocking read
- m_formatCtx->flags |= AVFMT_FLAG_NONBLOCK;
- }
-
- if (m_isImage)
- {
- // the file is to be treated as an image, i.e. load the first frame only
- m_isFile = false;
- // in case of reload, the filename is taken from m_imageName, no need to change it
- if (m_imageName.Ptr() != filename)
- m_imageName = filename;
- m_preseek = 0;
- m_avail = false;
- play();
- }
- // check if we should do multi-threading?
- if (!m_isImage && BLI_system_thread_count() > 1)
- {
- // never thread image: there are no frame to read ahead
- // no need to thread if the system has a single core
- m_isThreaded = true;
- }
-}
-
-
-// open video capture device
-void VideoFFmpeg::openCam (char *file, short camIdx)
-{
- // open camera source
- AVInputFormat *inputFormat;
- AVDictionary *formatParams = NULL;
- char filename[28], rateStr[20];
-
-#ifdef WIN32
- // video capture on windows only through Video For Windows driver
- inputFormat = av_find_input_format("vfwcap");
- if (!inputFormat)
- // Video For Windows not supported??
- return;
- sprintf(filename, "%d", camIdx);
-#else
- // In Linux we support two types of devices: VideoForLinux and DV1394.
- // the user specify it with the filename:
- // [<device_type>][:<standard>]
- // <device_type> : 'v4l' for VideoForLinux, 'dv1394' for DV1394. By default 'v4l'
- // <standard> : 'pal', 'secam' or 'ntsc'. By default 'ntsc'
- // The driver name is constructed automatically from the device type:
- // v4l : /dev/video<camIdx>
- // dv1394: /dev/dv1394/<camIdx>
- // If you have different driver name, you can specify the driver name explicitly
- // instead of device type. Examples of valid filename:
- // /dev/v4l/video0:pal
- // /dev/ieee1394/1:ntsc
- // dv1394:secam
- // v4l:pal
- char *p;
-
- if (file && strstr(file, "1394") != NULL)
- {
- // the user specifies a driver, check if it is v4l or d41394
- inputFormat = av_find_input_format("dv1394");
- sprintf(filename, "/dev/dv1394/%d", camIdx);
- } else
- {
- const char *formats[] = {"video4linux2,v4l2", "video4linux2", "video4linux"};
- int i, formatsCount = sizeof(formats) / sizeof(char*);
- for (i = 0; i < formatsCount; i++) {
- inputFormat = av_find_input_format(formats[i]);
- if (inputFormat)
- break;
- }
- sprintf(filename, "/dev/video%d", camIdx);
- }
- if (!inputFormat)
- // these format should be supported, check ffmpeg compilation
- return;
- if (file && strncmp(file, "/dev", 4) == 0)
- {
- // user does not specify a driver
- strncpy(filename, file, sizeof(filename));
- filename[sizeof(filename)-1] = 0;
- if ((p = strchr(filename, ':')) != 0)
- *p = 0;
- }
- if (file && (p = strchr(file, ':')) != NULL) {
- av_dict_set(&formatParams, "standard", p+1, 0);
- }
-#endif
- //frame rate
- if (m_captRate <= 0.f)
- m_captRate = defFrameRate;
- sprintf(rateStr, "%f", m_captRate);
-
- av_dict_set(&formatParams, "framerate", rateStr, 0);
-
- if (m_captWidth > 0 && m_captHeight > 0) {
- char video_size[64];
- BLI_snprintf(video_size, sizeof(video_size), "%dx%d", m_captWidth, m_captHeight);
- av_dict_set(&formatParams, "video_size", video_size, 0);
- }
-
- if (openStream(filename, inputFormat, &formatParams) != 0)
- return;
-
- // for video capture it is important to do non blocking read
- m_formatCtx->flags |= AVFMT_FLAG_NONBLOCK;
- // open base class
- VideoBase::openCam(file, camIdx);
- // check if we should do multi-threading?
- if (BLI_system_thread_count() > 1)
- {
- // no need to thread if the system has a single core
- m_isThreaded = true;
- }
-
- av_dict_free(&formatParams);
-}
-
-// play video
-bool VideoFFmpeg::play (void)
-{
- try
- {
- // if object is able to play
- if (VideoBase::play())
- {
- // set video position
- setPositions();
-
- if (m_isStreaming)
- {
- av_read_play(m_formatCtx);
- }
-
- // return success
- return true;
- }
- }
- CATCH_EXCP;
- return false;
-}
-
-
-// pause video
-bool VideoFFmpeg::pause (void)
-{
- try
- {
- if (VideoBase::pause())
- {
- if (m_isStreaming)
- {
- av_read_pause(m_formatCtx);
- }
- return true;
- }
- }
- CATCH_EXCP;
- return false;
-}
-
-// stop video
-bool VideoFFmpeg::stop (void)
-{
- try
- {
- VideoBase::stop();
- // force restart when play
- m_lastFrame = -1;
- return true;
- }
- CATCH_EXCP;
- return false;
-}
-
-
-// set video range
-void VideoFFmpeg::setRange (double start, double stop)
-{
- try
- {
- // set range
- if (m_isFile)
- {
- VideoBase::setRange(start, stop);
- // set range for video
- setPositions();
- }
- }
- CATCH_EXCP;
-}
-
-// set framerate
-void VideoFFmpeg::setFrameRate (float rate)
-{
- VideoBase::setFrameRate(rate);
-}
-
-
-// image calculation
-// load frame from video
-void VideoFFmpeg::calcImage (unsigned int texId, double ts)
-{
- if (m_status == SourcePlaying)
- {
- // get actual time
- double startTime = PIL_check_seconds_timer();
- double actTime;
- // timestamp passed from audio actuators can sometimes be slightly negative
- if (m_isFile && ts >= -0.5)
- {
- // allow setting timestamp only when not streaming
- actTime = ts;
- if (actTime * actFrameRate() < m_lastFrame)
- {
- // user is asking to rewind, force a cache clear to make sure we will do a seek
- // note that this does not decrement m_repeat if ts didn't reach m_range[1]
- stopCache();
- }
- }
- else
- {
- if (m_lastFrame == -1 && !m_isFile)
- m_startTime = startTime;
- actTime = startTime - m_startTime;
- }
- // if video has ended
- if (m_isFile && actTime * m_frameRate >= m_range[1])
- {
- // in any case, this resets the cache
- stopCache();
- // if repeats are set, decrease them
- if (m_repeat > 0)
- --m_repeat;
- // if video has to be replayed
- if (m_repeat != 0)
- {
- // reset its position
- actTime -= (m_range[1] - m_range[0]) / m_frameRate;
- m_startTime += (m_range[1] - m_range[0]) / m_frameRate;
- }
- // if video has to be stopped, stop it
- else
- {
- m_status = SourceStopped;
- return;
- }
- }
- // actual frame
- long actFrame = (m_isImage) ? m_lastFrame+1 : long(actTime * actFrameRate());
- // if actual frame differs from last frame
- if (actFrame != m_lastFrame)
- {
- AVFrame* frame;
- // get image
- if ((frame = grabFrame(actFrame)) != NULL)
- {
- if (!m_isFile && !m_cacheStarted)
- {
- // streaming without cache: detect synchronization problem
- double execTime = PIL_check_seconds_timer() - startTime;
- if (execTime > 0.005)
- {
- // exec time is too long, it means that the function was blocking
- // resynchronize the stream from this time
- m_startTime += execTime;
- }
- }
- // save actual frame
- m_lastFrame = actFrame;
- // init image, if needed
- init(short(m_codecCtx->width), short(m_codecCtx->height));
- // process image
- process((BYTE*)(frame->data[0]));
- // finished with the frame, release it so that cache can reuse it
- releaseFrame(frame);
- // in case it is an image, automatically stop reading it
- if (m_isImage)
- {
- m_status = SourceStopped;
- // close the file as we don't need it anymore
- release();
- }
- } else if (m_isStreaming)
- {
- // we didn't get a frame and we are streaming, this may be due to
- // a delay in the network or because we are getting the frame too fast.
- // In the later case, shift time by a small amount to compensate for a drift
- m_startTime += 0.001;
- }
- }
- }
-}
-
-
-// set actual position
-void VideoFFmpeg::setPositions (void)
-{
- // set video start time
- m_startTime = PIL_check_seconds_timer();
- // if file is played and actual position is before end position
- if (!m_eof && m_lastFrame >= 0 && (!m_isFile || m_lastFrame < m_range[1] * actFrameRate()))
- // continue from actual position
- m_startTime -= double(m_lastFrame) / actFrameRate();
- else {
- m_startTime -= m_range[0];
- // start from beginning, stop cache just in case
- stopCache();
- }
-}
-
-// position pointer in file, position in second
-AVFrame *VideoFFmpeg::grabFrame(long position)
-{
- AVPacket packet;
- int frameFinished;
- int posFound = 1;
- bool frameLoaded = false;
- int64_t targetTs = 0;
- CacheFrame *frame;
- int64_t dts = 0;
-
- if (m_cacheStarted)
- {
- // when cache is active, we must not read the file directly
- do {
- pthread_mutex_lock(&m_cacheMutex);
- frame = (CacheFrame *)m_frameCacheBase.first;
- pthread_mutex_unlock(&m_cacheMutex);
- // no need to remove the frame from the queue: the cache thread does not touch the head, only the tail
- if (frame == NULL)
- {
- // no frame in cache, in case of file it is an abnormal situation
- if (m_isFile)
- {
- // go back to no threaded reading
- stopCache();
- break;
- }
- return NULL;
- }
- if (frame->framePosition == -1)
- {
- // this frame mark the end of the file (only used for file)
- // leave in cache to make sure we don't miss it
- m_eof = true;
- return NULL;
- }
- // for streaming, always return the next frame,
- // that's what grabFrame does in non cache mode anyway.
- if (m_isStreaming || frame->framePosition == position)
- {
- return frame->frame;
- }
- // for cam, skip old frames to keep image realtime.
- // There should be no risk of clock drift since it all happens on the same CPU
- if (frame->framePosition > position)
- {
- // this can happen after rewind if the seek didn't find the first frame
- // the frame in the buffer is ahead of time, just leave it there
- return NULL;
- }
- // this frame is not useful, release it
- pthread_mutex_lock(&m_cacheMutex);
- BLI_remlink(&m_frameCacheBase, frame);
- BLI_addtail(&m_frameCacheFree, frame);
- pthread_mutex_unlock(&m_cacheMutex);
- } while (true);
- }
- double timeBase = av_q2d(m_formatCtx->streams[m_videoStream]->time_base);
- int64_t startTs = m_formatCtx->streams[m_videoStream]->start_time;
- if (startTs == AV_NOPTS_VALUE)
- startTs = 0;
-
- // come here when there is no cache or cache has been stopped
- // locate the frame, by seeking if necessary (seeking is only possible for files)
- if (m_isFile)
- {
- // first check if the position that we are looking for is in the preseek range
- // if so, just read the frame until we get there
- if (position > m_curPosition + 1
- && m_preseek
- && position - (m_curPosition + 1) < m_preseek)
- {
- while (av_read_frame(m_formatCtx, &packet)>=0)
- {
- if (packet.stream_index == m_videoStream)
- {
- avcodec_decode_video2(
- m_codecCtx,
- m_frame, &frameFinished,
- &packet);
- if (frameFinished)
- {
- m_curPosition = (long)((packet.dts-startTs) * (m_baseFrameRate*timeBase) + 0.5);
- }
- }
- av_free_packet(&packet);
- if (position == m_curPosition+1)
- break;
- }
- }
- // if the position is not in preseek, do a direct jump
- if (position != m_curPosition + 1)
- {
- int64_t pos = (int64_t)((position - m_preseek) / (m_baseFrameRate*timeBase));
-
- if (pos < 0)
- pos = 0;
-
- pos += startTs;
-
- if (position <= m_curPosition || !m_eof)
- {
-#if 0
- // Tried to make this work but couldn't: seeking on byte is ignored by the
- // format plugin and it will generally continue to read from last timestamp.
- // Too bad because frame seek is not always able to get the first frame
- // of the file.
- if (position <= m_preseek)
- {
- // we can safely go the beginning of the file
- if (av_seek_frame(m_formatCtx, m_videoStream, 0, AVSEEK_FLAG_BYTE) >= 0)
- {
- // binary seek does not reset the timestamp, must do it now
- av_update_cur_dts(m_formatCtx, m_formatCtx->streams[m_videoStream], startTs);
- m_curPosition = 0;
- }
- }
- else
-#endif
- {
- // current position is now lost, guess a value.
- if (av_seek_frame(m_formatCtx, m_videoStream, pos, AVSEEK_FLAG_BACKWARD) >= 0)
- {
- // current position is now lost, guess a value.
- // It's not important because it will be set at this end of this function
- m_curPosition = position - m_preseek - 1;
- }
- }
- }
- // this is the timestamp of the frame we're looking for
- targetTs = (int64_t)(position / (m_baseFrameRate * timeBase)) + startTs;
-
- posFound = 0;
- avcodec_flush_buffers(m_codecCtx);
- }
- } else if (m_isThreaded)
- {
- // cache is not started but threading is possible
- // better not read the stream => make take some time, better start caching
- if (startCache())
- return NULL;
- // Abnormal!!! could not start cache, fall back on direct read
- m_isThreaded = false;
- }
-
- // find the correct frame, in case of streaming and no cache, it means just
- // return the next frame. This is not quite correct, may need more work
- while (av_read_frame(m_formatCtx, &packet) >= 0)
- {
- if (packet.stream_index == m_videoStream)
- {
- AVFrame *input = m_frame;
- short counter = 0;
-
- /* If m_isImage, while the data is not read properly (png, tiffs, etc formats may need several pass), else don't need while loop*/
- do {
- avcodec_decode_video2(m_codecCtx, m_frame, &frameFinished, &packet);
- counter++;
- } while ((input->data[0] == 0 && input->data[1] == 0 && input->data[2] == 0 && input->data[3] == 0) && counter < 10 && m_isImage);
-
- // remember dts to compute exact frame number
- dts = packet.dts;
- if (frameFinished && !posFound)
- {
- if (dts >= targetTs)
- {
- posFound = 1;
- }
- }
-
- if (frameFinished && posFound == 1)
- {
- AVFrame * input = m_frame;
-
- /* This means the data wasnt read properly,
- * this check stops crashing */
- if ( input->data[0]==0 && input->data[1]==0
- && input->data[2]==0 && input->data[3]==0)
- {
- av_free_packet(&packet);
- break;
- }
-
- if (m_deinterlace)
- {
- if (avpicture_deinterlace(
- (AVPicture*) m_frameDeinterlaced,
- (const AVPicture*) m_frame,
- m_codecCtx->pix_fmt,
- m_codecCtx->width,
- m_codecCtx->height) >= 0)
- {
- input = m_frameDeinterlaced;
- }
- }
- // convert to RGB24
- sws_scale(m_imgConvertCtx,
- input->data,
- input->linesize,
- 0,
- m_codecCtx->height,
- m_frameRGB->data,
- m_frameRGB->linesize);
- av_free_packet(&packet);
- frameLoaded = true;
- break;
- }
- }
- av_free_packet(&packet);
- }
- m_eof = m_isFile && !frameLoaded;
- if (frameLoaded)
- {
- m_curPosition = (long)((dts-startTs) * (m_baseFrameRate*timeBase) + 0.5);
- if (m_isThreaded)
- {
- // normal case for file: first locate, then start cache
- if (!startCache())
- {
- // Abnormal!! could not start cache, return to non-cache mode
- m_isThreaded = false;
- }
- }
- return m_frameRGB;
- }
- return NULL;
-}
-
-
-// python methods
-
-
-// cast Image pointer to VideoFFmpeg
-inline VideoFFmpeg * getVideoFFmpeg (PyImage *self)
-{ return static_cast<VideoFFmpeg*>(self->m_image); }
-
-
-// object initialization
-static int VideoFFmpeg_init(PyObject *pySelf, PyObject *args, PyObject *kwds)
-{
- PyImage *self = reinterpret_cast<PyImage*>(pySelf);
- // parameters - video source
- // file name or format type for capture (only for Linux: video4linux or dv1394)
- char * file = NULL;
- // capture device number
- short capt = -1;
- // capture width, only if capt is >= 0
- short width = 0;
- // capture height, only if capt is >= 0
- short height = 0;
- // capture rate, only if capt is >= 0
- float rate = 25.f;
-
- static const char *kwlist[] = {"file", "capture", "rate", "width", "height", NULL};
-
- // get parameters
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|hfhh",
- const_cast<char**>(kwlist), &file, &capt, &rate, &width, &height))
- return -1;
-
- try
- {
- // create video object
- Video_init<VideoFFmpeg>(self);
-
- // set thread usage
- getVideoFFmpeg(self)->initParams(width, height, rate);
-
- // open video source
- Video_open(getVideo(self), file, capt);
- }
- catch (Exception & exp)
- {
- exp.report();
- return -1;
- }
- // initialization succeded
- return 0;
-}
-
-static PyObject *VideoFFmpeg_getPreseek(PyImage *self, void *closure)
-{
- return Py_BuildValue("h", getFFmpeg(self)->getPreseek());
-}
-
-// set range
-static int VideoFFmpeg_setPreseek(PyImage *self, PyObject *value, void *closure)
-{
- // check validity of parameter
- if (value == NULL || !PyLong_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be an integer");
- return -1;
- }
- // set preseek
- getFFmpeg(self)->setPreseek(PyLong_AsLong(value));
- // success
- return 0;
-}
-
-// get deinterlace
-static PyObject *VideoFFmpeg_getDeinterlace(PyImage *self, void *closure)
-{
- if (getFFmpeg(self)->getDeinterlace())
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-// set flip
-static int VideoFFmpeg_setDeinterlace(PyImage *self, PyObject *value, void *closure)
-{
- // check parameter, report failure
- if (value == NULL || !PyBool_Check(value))
- {
- PyErr_SetString(PyExc_TypeError, "The value must be a bool");
- return -1;
- }
- // set deinterlace
- getFFmpeg(self)->setDeinterlace(value == Py_True);
- // success
- return 0;
-}
-
-// methods structure
-static PyMethodDef videoMethods[] =
-{ // methods from VideoBase class
- {"play", (PyCFunction)Video_play, METH_NOARGS, "Play (restart) video"},
- {"pause", (PyCFunction)Video_pause, METH_NOARGS, "pause video"},
- {"stop", (PyCFunction)Video_stop, METH_NOARGS, "stop video (play will replay it from start)"},
- {"refresh", (PyCFunction)Video_refresh, METH_VARARGS, "Refresh video - get its status"},
- {NULL}
-};
-// attributes structure
-static PyGetSetDef videoGetSets[] =
-{ // methods from VideoBase class
- {(char*)"status", (getter)Video_getStatus, NULL, (char*)"video status", NULL},
- {(char*)"range", (getter)Video_getRange, (setter)Video_setRange, (char*)"replay range", NULL},
- {(char*)"repeat", (getter)Video_getRepeat, (setter)Video_setRepeat, (char*)"repeat count, -1 for infinite repeat", NULL},
- {(char*)"framerate", (getter)Video_getFrameRate, (setter)Video_setFrameRate, (char*)"frame rate", NULL},
- // attributes from ImageBase class
- {(char*)"valid", (getter)Image_valid, NULL, (char*)"bool to tell if an image is available", NULL},
- {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
- {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
- {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL},
- {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
- {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
- {(char*)"preseek", (getter)VideoFFmpeg_getPreseek, (setter)VideoFFmpeg_setPreseek, (char*)"nb of frames of preseek", NULL},
- {(char*)"deinterlace", (getter)VideoFFmpeg_getDeinterlace, (setter)VideoFFmpeg_setDeinterlace, (char*)"deinterlace image", NULL},
- {NULL}
-};
-
-// python type declaration
-PyTypeObject VideoFFmpegType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.VideoFFmpeg", /*tp_name*/
- sizeof(PyImage), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Image_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "FFmpeg video source", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- videoMethods, /* tp_methods */
- 0, /* tp_members */
- videoGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)VideoFFmpeg_init, /* tp_init */
- 0, /* tp_alloc */
- Image_allocNew, /* tp_new */
-};
-
-// object initialization
-static int ImageFFmpeg_init(PyObject *pySelf, PyObject *args, PyObject *kwds)
-{
- PyImage *self = reinterpret_cast<PyImage*>(pySelf);
- // parameters - video source
- // file name or format type for capture (only for Linux: video4linux or dv1394)
- char * file = NULL;
-
- // get parameters
- if (!PyArg_ParseTuple(args, "s:ImageFFmpeg", &file))
- return -1;
-
- try
- {
- // create video object
- Video_init<VideoFFmpeg>(self);
-
- getVideoFFmpeg(self)->initParams(0, 0, 1.0, true);
-
- // open video source
- Video_open(getVideo(self), file, -1);
- }
- catch (Exception & exp)
- {
- exp.report();
- return -1;
- }
- // initialization succeded
- return 0;
-}
-
-static PyObject *Image_reload(PyImage *self, PyObject *args)
-{
- char * newname = NULL;
- if (!PyArg_ParseTuple(args, "|s:reload", &newname))
- return NULL;
- if (self->m_image != NULL)
- {
- VideoFFmpeg* video = getFFmpeg(self);
- // check type of object
- if (!newname)
- newname = video->getImageName();
- if (!newname) {
- // if not set, retport error
- PyErr_SetString(PyExc_RuntimeError, "No image file name given");
- return NULL;
- }
- // make sure the previous file is cleared
- video->release();
- // open the new file
- video->openFile(newname);
- }
- Py_RETURN_NONE;
-}
-
-// methods structure
-static PyMethodDef imageMethods[] =
-{ // methods from VideoBase class
- {"refresh", (PyCFunction)Video_refresh, METH_VARARGS, "Refresh image, i.e. load it"},
- {"reload", (PyCFunction)Image_reload, METH_VARARGS, "Reload image, i.e. reopen it"},
- {NULL}
-};
-// attributes structure
-static PyGetSetDef imageGetSets[] =
-{ // methods from VideoBase class
- {(char*)"status", (getter)Video_getStatus, NULL, (char*)"video status", NULL},
- // attributes from ImageBase class
- {(char*)"valid", (getter)Image_valid, NULL, (char*)"bool to tell if an image is available", NULL},
- {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
- {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
- {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL},
- {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
- {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
- {NULL}
-};
-
-// python type declaration
-PyTypeObject ImageFFmpegType =
-{
- PyVarObject_HEAD_INIT(NULL, 0)
- "VideoTexture.ImageFFmpeg", /*tp_name*/
- sizeof(PyImage), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Image_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &imageBufferProcs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "FFmpeg image source", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- imageMethods, /* tp_methods */
- 0, /* tp_members */
- imageGetSets, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ImageFFmpeg_init, /* tp_init */
- 0, /* tp_alloc */
- Image_allocNew, /* tp_new */
-};
-
-#endif //WITH_FFMPEG
-
-
diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h
deleted file mode 100644
index 0a49a0b19bb..00000000000
--- a/source/gameengine/VideoTexture/VideoFFmpeg.h
+++ /dev/null
@@ -1,219 +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.
- *
- * Copyright (c) 2007 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file VideoFFmpeg.h
- * \ingroup bgevideotex
- */
-
-#ifndef __VIDEOFFMPEG_H__
-#define __VIDEOFFMPEG_H__
-
-#ifdef WITH_FFMPEG
-/* this needs to be parsed with __cplusplus defined before included through ffmpeg_compat.h */
-#if defined(__FreeBSD__)
-# include <inttypes.h>
-#endif
-extern "C" {
-#include <pthread.h>
-#include "ffmpeg_compat.h"
-#include "DNA_listBase.h"
-#include "BLI_threads.h"
-#include "BLI_blenlib.h"
-}
-
-#if LIBAVFORMAT_VERSION_INT < (49 << 16)
-# define FFMPEG_OLD_FRAME_RATE 1
-#else
-# define FFMPEG_CODEC_IS_POINTER 1
-#endif
-
-#ifdef FFMPEG_CODEC_IS_POINTER
-static inline AVCodecContext *get_codec_from_stream(AVStream* stream)
-{
- return stream->codec;
-}
-#else
-static inline AVCodecContext *get_codec_from_stream(AVStream* stream)
-{
- return &stream->codec;
-}
-#endif
-
-#include "VideoBase.h"
-
-#define CACHE_FRAME_SIZE 10
-#define CACHE_PACKET_SIZE 30
-
-// type VideoFFmpeg declaration
-class VideoFFmpeg : public VideoBase
-{
-public:
- /// constructor
- VideoFFmpeg (HRESULT * hRslt);
- /// destructor
- virtual ~VideoFFmpeg ();
-
- /// set initial parameters
- void initParams (short width, short height, float rate, bool image=false);
- /// open video/image file
- virtual void openFile(char *file);
- /// open video capture device
- virtual void openCam(char *driver, short camIdx);
-
- /// release video source
- virtual bool release (void);
- /// overwrite base refresh to handle fixed image
- virtual void refresh(void);
- /// play video
- virtual bool play (void);
- /// pause video
- virtual bool pause (void);
- /// stop video
- virtual bool stop (void);
- /// set play range
- virtual void setRange (double start, double stop);
- /// set frame rate
- virtual void setFrameRate (float rate);
- // some specific getters and setters
- int getPreseek(void) { return m_preseek; }
- void setPreseek(int preseek) { if (preseek >= 0) m_preseek = preseek; }
- bool getDeinterlace(void) { return m_deinterlace; }
- void setDeinterlace(bool deinterlace) { m_deinterlace = deinterlace; }
- char *getImageName(void) { return (m_isImage) ? m_imageName.Ptr() : NULL; }
-
-protected:
- // format and codec information
- AVCodec *m_codec;
- AVFormatContext *m_formatCtx;
- AVCodecContext *m_codecCtx;
- // raw frame extracted from video file
- AVFrame *m_frame;
- // deinterlaced frame if codec requires it
- AVFrame *m_frameDeinterlaced;
- // decoded RGB24 frame if codec requires it
- AVFrame *m_frameRGB;
- // conversion from raw to RGB is done with sws_scale
- struct SwsContext *m_imgConvertCtx;
- // should the codec be deinterlaced?
- bool m_deinterlace;
- // number of frame of preseek
- int m_preseek;
- // order number of stream holding the video in format context
- int m_videoStream;
-
- // the actual frame rate
- double m_baseFrameRate;
-
- /// last displayed frame
- long m_lastFrame;
-
- /// end of file reached
- bool m_eof;
-
- /// flag to indicate that time is coming from application
- bool m_externTime;
-
- /// current file pointer position in file expressed in frame number
- long m_curPosition;
-
- /// time of video play start
- double m_startTime;
-
- /// width of capture in pixel
- short m_captWidth;
-
- /// height of capture in pixel
- short m_captHeight;
-
- /// frame rate of capture in frames per seconds
- float m_captRate;
-
- /// is file an image?
- bool m_isImage;
-
- /// is image loading done in a separate thread?
- bool m_isThreaded;
-
- /// is streaming or camera?
- bool m_isStreaming;
-
- /// keep last image name
- STR_String m_imageName;
-
- /// image calculation
- virtual void calcImage (unsigned int texId, double ts);
-
- /// set actual position
- void setPositions (void);
-
- /// get actual framerate
- double actFrameRate (void) { return m_frameRate * m_baseFrameRate; }
-
- /// common function to video file and capture
- int openStream(const char *filename, AVInputFormat *inputFormat, AVDictionary **formatParams);
-
- /// check if a frame is available and load it in pFrame, return true if a frame could be retrieved
- AVFrame* grabFrame(long frame);
-
- /// in case of caching, put the frame back in free queue
- void releaseFrame(AVFrame* frame);
-
- /// start thread to load the video file/capture/stream
- bool startCache();
- void stopCache();
-
-private:
- typedef struct {
- Link link;
- long framePosition;
- AVFrame *frame;
- } CacheFrame;
- typedef struct {
- Link link;
- AVPacket packet;
- } CachePacket;
-
- bool m_stopThread;
- bool m_cacheStarted;
- ListBase m_thread;
- ListBase m_frameCacheBase; // list of frames that are ready
- ListBase m_frameCacheFree; // list of frames that are unused
- ListBase m_packetCacheBase; // list of packets that are ready for decoding
- ListBase m_packetCacheFree; // list of packets that are unused
- pthread_mutex_t m_cacheMutex;
-
- AVFrame *allocFrameRGB();
- static void *cacheThread(void *);
-};
-
-inline VideoFFmpeg *getFFmpeg(PyImage *self)
-{
- return static_cast<VideoFFmpeg*>(self->m_image);
-}
-
-#endif /* WITH_FFMPEG */
-
-#endif /* __VIDEOFFMPEG_H__ */
diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp
deleted file mode 100644
index 9b046d46412..00000000000
--- a/source/gameengine/VideoTexture/blendVideoTex.cpp
+++ /dev/null
@@ -1,266 +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.
- *
- * Copyright (c) 2006 The Zdeno Ash Miklas
- *
- * This source file is part of VideoTexture library
- *
- * Contributor(s):
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file gameengine/VideoTexture/blendVideoTex.cpp
- * \ingroup bgevideotex
- */
-
-#include "EXP_PyObjectPlus.h"
-
-#include "KX_PythonInit.h"
-
-#include <RAS_IPolygonMaterial.h>
-
-//Old API
-//#include "TexPlayer.h"
-//#include "TexImage.h"
-//#include "TexFrameBuff.h"
-
-//#include "TexPlayerGL.h"
-
-#include "ImageBase.h"
-#include "VideoBase.h"
-#include "FilterBase.h"
-#include "Texture.h"
-
-#include "Exception.h"
-
-// access to IMB_BLEND_* constants
-extern "C"
-{
-#include "IMB_imbuf.h"
-};
-
-
-// get material id
-static PyObject *getMaterialID (PyObject *self, PyObject *args)
-{
- // parameters - game object with video texture
- PyObject *obj = NULL;
- // material name
- char * matName;
-
- // get parameters
- if (!PyArg_ParseTuple(args, "Os:materialID", &obj, &matName))
- return NULL;
- // get material id
- short matID = getMaterialID(obj, matName);
- // if material was not found, report errot
- if (matID < 0)
- {
- PyErr_SetString(PyExc_RuntimeError, "VideoTexture.materialID(ob, string): Object doesn't have material with given name");
- return NULL;
- }
- // return material ID
- return Py_BuildValue("h", matID);
-}
-
-
-// get last error description
-static PyObject *getLastError (PyObject *self, PyObject *args)
-{
- return PyUnicode_FromString(Exception::m_lastError.c_str());
-}
-
-// set log file
-static PyObject *setLogFile (PyObject *self, PyObject *args)
-{
- // get parameters
- if (!PyArg_ParseTuple(args, "s:setLogFile", &Exception::m_logFile))
- return Py_BuildValue("i", -1);
- // log file was loaded
- return Py_BuildValue("i", 0);
-}
-
-
-// image to numpy array
-static PyObject *imageToArray(PyObject *self, PyObject *args)
-{
- // parameter is Image object
- PyObject *pyImg;
- char *mode = NULL;
- if (!PyArg_ParseTuple(args, "O|s:imageToArray", &pyImg, &mode) || !pyImageTypes.in(Py_TYPE(pyImg)))
- {
- // if object is incorect, report error
- PyErr_SetString(PyExc_TypeError, "VideoTexture.imageToArray(image): The value must be a image source object");
- return NULL;
- }
- // get image structure
- PyImage * img = reinterpret_cast<PyImage*>(pyImg);
- return Image_getImage(img, mode);
-}
-
-
-// metody modulu
-static PyMethodDef moduleMethods[] =
-{
- {"materialID", getMaterialID, METH_VARARGS, "Gets object's Blender Material ID"},
- {"getLastError", getLastError, METH_NOARGS, "Gets last error description"},
- {"setLogFile", setLogFile, METH_VARARGS, "Sets log file name"},
- {"imageToArray", imageToArray, METH_VARARGS, "get buffer from image source, color channels are selectable"},
- {NULL} /* Sentinel */
-};
-
-#ifdef WITH_FFMPEG
-extern PyTypeObject VideoFFmpegType;
-extern PyTypeObject ImageFFmpegType;
-#endif
-#ifdef WITH_GAMEENGINE_DECKLINK
-extern PyTypeObject VideoDeckLinkType;
-extern PyTypeObject DeckLinkType;
-#endif
-extern PyTypeObject FilterBlueScreenType;
-extern PyTypeObject FilterGrayType;
-extern PyTypeObject FilterColorType;
-extern PyTypeObject FilterLevelType;
-extern PyTypeObject FilterNormalType;
-extern PyTypeObject FilterRGB24Type;
-extern PyTypeObject FilterRGBA32Type;
-extern PyTypeObject FilterBGR24Type;
-extern PyTypeObject ImageBuffType;
-extern PyTypeObject ImageMixType;
-
-static void registerAllTypes(void)
-{
-#ifdef WITH_FFMPEG
- pyImageTypes.add(&VideoFFmpegType, "VideoFFmpeg");
- pyImageTypes.add(&ImageFFmpegType, "ImageFFmpeg");
-#endif
-#ifdef WITH_GAMEENGINE_DECKLINK
- pyImageTypes.add(&VideoDeckLinkType, "VideoDeckLink");
-#endif
- pyImageTypes.add(&ImageBuffType, "ImageBuff");
- pyImageTypes.add(&ImageMixType, "ImageMix");
- pyImageTypes.add(&ImageRenderType, "ImageRender");
- pyImageTypes.add(&ImageMirrorType, "ImageMirror");
- pyImageTypes.add(&ImageViewportType, "ImageViewport");
-
- pyFilterTypes.add(&FilterBlueScreenType, "FilterBlueScreen");
- pyFilterTypes.add(&FilterGrayType, "FilterGray");
- pyFilterTypes.add(&FilterColorType, "FilterColor");
- pyFilterTypes.add(&FilterLevelType, "FilterLevel");
- pyFilterTypes.add(&FilterNormalType, "FilterNormal");
- pyFilterTypes.add(&FilterRGB24Type, "FilterRGB24");
- pyFilterTypes.add(&FilterRGBA32Type, "FilterRGBA32");
- pyFilterTypes.add(&FilterBGR24Type, "FilterBGR24");
-}
-
-PyDoc_STRVAR(VideoTexture_module_documentation,
-"Module that allows to play video files on textures in GameBlender."
-);
-
-static struct PyModuleDef VideoTexture_module_def = {
- PyModuleDef_HEAD_INIT,
- "VideoTexture", /* m_name */
- VideoTexture_module_documentation, /* m_doc */
- 0, /* m_size */
- moduleMethods, /* m_methods */
- 0, /* m_reload */
- 0, /* m_traverse */
- 0, /* m_clear */
- 0, /* m_free */
-};
-
-PyMODINIT_FUNC initVideoTexturePythonBinding(void)
-{
- PyObject *m;
-
- // initialize GL extensions
- //bgl::InitExtensions(0);
-
- // prepare classes
- registerAllTypes();
- registerAllExceptions();
-
- if (!pyImageTypes.ready())
- return NULL;
- if (!pyFilterTypes.ready())
- return NULL;
- if (PyType_Ready(&TextureType) < 0)
- return NULL;
-#ifdef WITH_GAMEENGINE_DECKLINK
- if (PyType_Ready(&DeckLinkType) < 0)
- return NULL;
-#endif
-
- m = PyModule_Create(&VideoTexture_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), VideoTexture_module_def.m_name, m);
-
- if (m == NULL)
- return NULL;
-
- // initialize classes
- pyImageTypes.reg(m);
- pyFilterTypes.reg(m);
-
- Py_INCREF(&TextureType);
- PyModule_AddObject(m, "Texture", (PyObject *)&TextureType);
-#ifdef WITH_GAMEENGINE_DECKLINK
- Py_INCREF(&DeckLinkType);
- PyModule_AddObject(m, "DeckLink", (PyObject *)&DeckLinkType);
-#endif
- PyModule_AddIntConstant(m, "SOURCE_ERROR", SourceError);
- PyModule_AddIntConstant(m, "SOURCE_EMPTY", SourceEmpty);
- PyModule_AddIntConstant(m, "SOURCE_READY", SourceReady);
- PyModule_AddIntConstant(m, "SOURCE_PLAYING", SourcePlaying);
- PyModule_AddIntConstant(m, "SOURCE_STOPPED", SourceStopped);
-
- PyModule_AddIntConstant(m, "IMB_BLEND_MIX", IMB_BLEND_MIX);
- PyModule_AddIntConstant(m, "IMB_BLEND_ADD", IMB_BLEND_ADD);
- PyModule_AddIntConstant(m, "IMB_BLEND_SUB", IMB_BLEND_SUB);
- PyModule_AddIntConstant(m, "IMB_BLEND_MUL", IMB_BLEND_MUL);
- PyModule_AddIntConstant(m, "IMB_BLEND_LIGHTEN", IMB_BLEND_LIGHTEN);
- PyModule_AddIntConstant(m, "IMB_BLEND_DARKEN", IMB_BLEND_DARKEN);
- PyModule_AddIntConstant(m, "IMB_BLEND_ERASE_ALPHA", IMB_BLEND_ERASE_ALPHA);
- PyModule_AddIntConstant(m, "IMB_BLEND_ADD_ALPHA", IMB_BLEND_ADD_ALPHA);
- PyModule_AddIntConstant(m, "IMB_BLEND_OVERLAY", IMB_BLEND_OVERLAY);
- PyModule_AddIntConstant(m, "IMB_BLEND_HARDLIGHT", IMB_BLEND_HARDLIGHT);
- PyModule_AddIntConstant(m, "IMB_BLEND_COLORBURN", IMB_BLEND_COLORBURN);
- PyModule_AddIntConstant(m, "IMB_BLEND_LINEARBURN", IMB_BLEND_LINEARBURN);
- PyModule_AddIntConstant(m, "IMB_BLEND_COLORDODGE", IMB_BLEND_COLORDODGE);
- PyModule_AddIntConstant(m, "IMB_BLEND_SCREEN", IMB_BLEND_SCREEN);
- PyModule_AddIntConstant(m, "IMB_BLEND_SOFTLIGHT", IMB_BLEND_SOFTLIGHT);
- PyModule_AddIntConstant(m, "IMB_BLEND_PINLIGHT", IMB_BLEND_PINLIGHT);
- PyModule_AddIntConstant(m, "IMB_BLEND_VIVIDLIGHT", IMB_BLEND_VIVIDLIGHT);
- PyModule_AddIntConstant(m, "IMB_BLEND_LINEARLIGHT", IMB_BLEND_LINEARLIGHT);
- PyModule_AddIntConstant(m, "IMB_BLEND_DIFFERENCE", IMB_BLEND_DIFFERENCE);
- PyModule_AddIntConstant(m, "IMB_BLEND_EXCLUSION", IMB_BLEND_EXCLUSION);
- PyModule_AddIntConstant(m, "IMB_BLEND_HUE", IMB_BLEND_HUE);
- PyModule_AddIntConstant(m, "IMB_BLEND_SATURATION", IMB_BLEND_SATURATION);
- PyModule_AddIntConstant(m, "IMB_BLEND_LUMINOSITY", IMB_BLEND_LUMINOSITY);
- PyModule_AddIntConstant(m, "IMB_BLEND_COLOR", IMB_BLEND_COLOR);
-
- PyModule_AddIntConstant(m, "IMB_BLEND_COPY", IMB_BLEND_COPY);
- PyModule_AddIntConstant(m, "IMB_BLEND_COPY_RGB", IMB_BLEND_COPY_RGB);
- PyModule_AddIntConstant(m, "IMB_BLEND_COPY_ALPHA", IMB_BLEND_COPY_ALPHA);
-
- // init last error description
- Exception::m_lastError = "";
-
- return m;
-}
-
-// registration to Image types, put here because of silly linker bug
diff --git a/source/tools b/source/tools
-Subproject 7695e14cfc5820ac66546e0e515914d85ab81af
+Subproject f35d8e55afffb9da50cc13b14615ed280f9e558
diff --git a/tests/gtests/alembic/abc_export_test.cc b/tests/gtests/alembic/abc_export_test.cc
index b040f375221..cbf4ed43fe8 100644
--- a/tests/gtests/alembic/abc_export_test.cc
+++ b/tests/gtests/alembic/abc_export_test.cc
@@ -15,10 +15,10 @@ extern "C" {
class TestableAbcExporter : public AbcExporter {
public:
- TestableAbcExporter(Main *bmain, EvaluationContext *eval_ctx,
+ TestableAbcExporter(Main *bmain,
Scene *scene, ViewLayer *view_layer, Depsgraph *depsgraph,
const char *filename, ExportSettings &settings)
- : AbcExporter(bmain, eval_ctx, scene, view_layer, depsgraph, filename, settings)
+ : AbcExporter(bmain, scene, view_layer, depsgraph, filename, settings)
{
}
@@ -40,7 +40,6 @@ class AlembicExportTest : public testing::Test
protected:
ExportSettings settings;
Scene scene;
- EvaluationContext eval_ctx;
Depsgraph *depsgraph;
TestableAbcExporter *exporter;
Main *bmain;
@@ -57,8 +56,8 @@ protected:
bmain = BKE_main_new();
/* TODO(sergey): Pass scene layer somehow? */
- DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_VIEWPORT);
- depsgraph = DEG_graph_new();
+ ViewLayer *view_layer = (ViewLayer *)scene.view_layers.first;
+ depsgraph = DEG_graph_new(&scene, view_layer, DAG_EVAL_VIEWPORT);
exporter = NULL;
}
@@ -74,7 +73,7 @@ protected:
void createExporter()
{
ViewLayer *view_layer = (ViewLayer *)scene.view_layers.first;
- exporter = new TestableAbcExporter(bmain, &eval_ctx, &scene, view_layer, depsgraph, "somefile.abc", settings);
+ exporter = new TestableAbcExporter(bmain, &scene, view_layer, depsgraph, "somefile.abc", settings);
}
};
diff --git a/tests/gtests/blenlib/BLI_linklist_lockfree_test.cc b/tests/gtests/blenlib/BLI_linklist_lockfree_test.cc
new file mode 100644
index 00000000000..b5b790079d5
--- /dev/null
+++ b/tests/gtests/blenlib/BLI_linklist_lockfree_test.cc
@@ -0,0 +1,130 @@
+/* Apache License, Version 2.0 */
+
+#include "testing/testing.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_linklist_lockfree.h"
+#include "BLI_task.h"
+#include "BLI_threads.h"
+
+
+TEST(LockfreeLinkList, Init)
+{
+ LockfreeLinkList list;
+ BLI_linklist_lockfree_init(&list);
+ EXPECT_EQ(list.head, &list.dummy_node);
+ EXPECT_EQ(list.tail, &list.dummy_node);
+ BLI_linklist_lockfree_free(&list, NULL);
+}
+
+TEST(LockfreeLinkList, InsertSingle)
+{
+ LockfreeLinkList list;
+ LockfreeLinkNode node;
+ BLI_linklist_lockfree_init(&list);
+ BLI_linklist_lockfree_insert(&list, &node);
+ EXPECT_EQ(list.head, &list.dummy_node);
+ EXPECT_EQ(list.head->next, &node);
+ EXPECT_EQ(list.tail, &node);
+ BLI_linklist_lockfree_free(&list, NULL);
+}
+
+TEST(LockfreeLinkList, InsertMultiple)
+{
+ static const int num_nodes = 128;
+ LockfreeLinkList list;
+ LockfreeLinkNode nodes[num_nodes];
+ BLI_linklist_lockfree_init(&list);
+ /* Insert all the nodes. */
+ for (int i = 0; i < num_nodes; ++i) {
+ BLI_linklist_lockfree_insert(&list, &nodes[i]);
+ }
+ /* Check head and tail. */
+ EXPECT_EQ(list.head, &list.dummy_node);
+ EXPECT_EQ(list.tail, &nodes[num_nodes - 1]);
+ /* Check rest of the nodes. */
+ int node_index = 0;
+ for (LockfreeLinkNode *node = BLI_linklist_lockfree_begin(&list);
+ node != NULL;
+ node = node->next, ++node_index)
+ {
+ EXPECT_EQ(node, &nodes[node_index]);
+ if (node_index != num_nodes - 1) {
+ EXPECT_EQ(node->next, &nodes[node_index + 1]);
+ }
+ }
+ /* Free list. */
+ BLI_linklist_lockfree_free(&list, NULL);
+}
+
+namespace {
+
+struct IndexedNode {
+ IndexedNode *next;
+ int index;
+};
+
+void concurrent_insert(TaskPool *__restrict pool,
+ void *taskdata,
+ int /*threadid*/)
+{
+ LockfreeLinkList *list = (LockfreeLinkList *)BLI_task_pool_userdata(pool);
+ CHECK_NOTNULL(list);
+ IndexedNode *node = (IndexedNode *)MEM_mallocN(sizeof(IndexedNode),
+ "test node");
+ node->index = GET_INT_FROM_POINTER(taskdata);
+ BLI_linklist_lockfree_insert(list, (LockfreeLinkNode *)node);
+}
+
+
+} // namespace
+
+TEST(LockfreeLinkList, InsertMultipleConcurrent)
+{
+ static const int num_threads = 512;
+ static const int num_nodes = 655360;
+ /* Initialize list. */
+ LockfreeLinkList list;
+ BLI_linklist_lockfree_init(&list);
+ /* Initialize task scheduler and pool. */
+ TaskScheduler *scheduler = BLI_task_scheduler_create(num_threads);
+ TaskPool *pool = BLI_task_pool_create_suspended(scheduler, &list);
+ /* Push tasks to the pool. */
+ for (int i = 0; i < num_nodes; ++i) {
+ BLI_task_pool_push(pool,
+ concurrent_insert,
+ SET_INT_IN_POINTER(i),
+ false,
+ TASK_PRIORITY_HIGH);
+ }
+ /* Run all the tasks. */
+ BLI_threaded_malloc_begin();
+ BLI_task_pool_work_and_wait(pool);
+ BLI_threaded_malloc_end();
+ /* Verify we've got all the data properly inserted. */
+ EXPECT_EQ(list.head, &list.dummy_node);
+ bool *visited_nodes = (bool *)MEM_callocN(sizeof(bool) * num_nodes,
+ "visited nodes");
+ /* First, we make sure that none of the nodes are added twice. */
+ for (LockfreeLinkNode *node_v = BLI_linklist_lockfree_begin(&list);
+ node_v != NULL;
+ node_v = node_v->next)
+ {
+ IndexedNode *node = (IndexedNode *)node_v;
+ EXPECT_GE(node->index, 0);
+ EXPECT_LT(node->index, num_nodes);
+ EXPECT_FALSE(visited_nodes[node->index]);
+ visited_nodes[node->index] = true;
+ }
+ /* Then we make sure node was added. */
+ for (int node_index = 0; node_index < num_nodes; ++node_index) {
+ EXPECT_TRUE(visited_nodes[node_index]);
+ }
+ MEM_freeN(visited_nodes);
+ /* Cleanup data. */
+ BLI_linklist_lockfree_free(&list, MEM_freeN);
+ BLI_task_pool_free(pool);
+ BLI_task_scheduler_free(scheduler);
+}
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
index ea2b2741f8c..7be18330ac3 100644
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ b/tests/gtests/blenlib/CMakeLists.txt
@@ -47,6 +47,7 @@ BLENDER_TEST(BLI_ghash "bf_blenlib")
BLENDER_TEST(BLI_hash_mm2a "bf_blenlib")
BLENDER_TEST(BLI_heap "bf_blenlib")
BLENDER_TEST(BLI_kdopbvh "bf_blenlib")
+BLENDER_TEST(BLI_linklist_lockfree "bf_blenlib")
BLENDER_TEST(BLI_listbase "bf_blenlib")
BLENDER_TEST(BLI_math_base "bf_blenlib")
BLENDER_TEST(BLI_math_color "bf_blenlib")
diff --git a/tests/python/bl_rst_completeness.py b/tests/python/bl_rst_completeness.py
index d8dfac66d13..3266621c43b 100644
--- a/tests/python/bl_rst_completeness.py
+++ b/tests/python/bl_rst_completeness.py
@@ -21,8 +21,6 @@
# run this script in the game engine.
# or on the command line with...
# ./blender.bin --background -noaudio --python tests/python/bl_rst_completeness.py
-
-# Paste this into the bge and run on an always actuator.
'''
filepath = "/src/blender/tests/python/bl_rst_completeness.py"
exec(compile(open(filepath).read(), filepath, 'exec'))
@@ -38,20 +36,9 @@ sys.path.append(THIS_DIR)
import rst_to_doctree_mini
-try:
- import bge
-except:
- bge = None
# (file, module)
modules = (
- ("bge.constraints.rst", "bge.constraints", False),
- ("bge.events.rst", "bge.events", False),
- ("bge.logic.rst", "bge.logic", False),
- ("bge.render.rst", "bge.render", False),
- ("bge.texture.rst", "bge.texture", False),
- ("bge.types.rst", "bge.types", False),
-
("bgl.rst", "bgl", True),
("gpu.rst", "gpu", False),
)
@@ -137,13 +124,7 @@ def module_validate(filepath, mod, mod_name, doctree, partial_ok):
def main():
- if bge is None:
- print("Skipping BGE modules!")
-
for filename, modname, partial_ok in modules:
- if bge is None and modname.startswith("bge"):
- continue
-
filepath = os.path.join(RST_DIR, filename)
if not os.path.exists(filepath):
raise Exception("%r not found" % filepath)
diff --git a/tests/python/collada/CMakeLists.txt b/tests/python/collada/CMakeLists.txt
index 421e4ba7667..4307eec3791 100644
--- a/tests/python/collada/CMakeLists.txt
+++ b/tests/python/collada/CMakeLists.txt
@@ -62,5 +62,7 @@ macro (COLLADA_TEST module test_name blend_file)
)
endmacro()
-COLLADA_TEST(mesh simple mesh_simple.blend)
-COLLADA_TEST(animation simple suzannes_parent_inverse.blend)
+# Tests are disabled because they only work on Windows
+# Tests will be redone completely to work reliable
+#COLLADA_TEST(mesh simple mesh_simple.blend)
+#COLLADA_TEST(animation simple suzannes_parent_inverse.blend)
diff --git a/tests/python/view_layer/view_layer_common.py b/tests/python/view_layer/view_layer_common.py
index 1ccd836c8d1..4ca0fec0796 100644
--- a/tests/python/view_layer/view_layer_common.py
+++ b/tests/python/view_layer/view_layer_common.py
@@ -69,7 +69,7 @@ def get_layer(scene, layer):
name = layer.get(b'name')
data['name'] = name
- data['engine'] = scene.get((b'view_render', b'engine_id'))
+ data['engine'] = scene.get((b'r', b'engine'))
active_base = layer.get_pointer(b'basact')
if active_base: